grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/2] Add support for SMBIOS3 entry point structures


From: Leif Lindholm
Subject: Re: [PATCH v4 1/2] Add support for SMBIOS3 entry point structures
Date: Mon, 17 Aug 2015 20:31:38 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi David,

Splendid timing. SMBIOS 3.0 support, as well as SMBIOS support for
ARM* platforms is just about to go into upstream QEMU.

I can confirm that with these patches, and a recent EDK2 build of
"ArmVirtPkg" for arm64, your example command line works:
grub> smbios --type 1 --get-string 4
QEMU
grub>

GRUB also finds both the SMBIOS and SMBIOS3 entry points.

For someone who would like to try this out themselves, I've taken the
two remaining patches from Wei Huang and stuck them on top of current
QEMU HEAD in a branch at:
https://git.linaro.org/people/leif.lindholm/qemu.git/shortlog/refs/heads/virt-smbios

Build it with
./configure --prefix=/usr/local --target-list=aarch64-softmmu
make -j8
sudo make install

Then grab
http://snapshots.linaro.org/components/kernel/linaro-edk2-prep/GCC49/13/release/qemu64/QEMU_EFI.fd

And launch QEMU with
qemu-system-aarch64 -nographic -M virt -cpu cortex-a57 -hda fat:<directory> 
-bios QEMU_EFI.fd

where you have a suitable grub binary (I use grub-mkstandalone) in
<directory>.

/
    Leif

On Sat, Aug 15, 2015 at 10:26:56PM -0400, David Michael wrote:
> If both SMBIOS v2 and v3 entry point structures are found, both are
> registered instead of preferring one version since they can point
> to different tables at different memory locations.
> 
> This also modifies the fakebios command so that the entire SMBIOS
> (v2) EPS is copied instead of just the intermediate DMI structure.
> ---
> 
> Hi,
> 
> Sorry for the long delay with the SMBIOS update.
> 
> This patch adds the SMBIOS v3 entry points to the other locations where
> v2 is supported, so in case the patch with the new command needs more
> work, maybe this can still be applied to add the new table definition.
> 
> I haven't actually been able to locate any machines supporting the
> SMBIOS v3.0.0 specification.  The best I managed was building and
> running a virtual EFI firmware image that supported SMBIOS3_TABLE_GUID,
> but this is untested other than that.
> 
> David
> 
>  grub-core/commands/efi/loadbios.c    | 18 ++++++++++++++---
>  grub-core/commands/efi/lsefisystab.c |  1 +
>  grub-core/efiemu/i386/pc/cfgtables.c | 38 
> ++++++++++++++++++++++++++----------
>  include/grub/efi/api.h               |  5 +++++
>  4 files changed, 49 insertions(+), 13 deletions(-)
> 
> diff --git a/grub-core/commands/efi/loadbios.c 
> b/grub-core/commands/efi/loadbios.c
> index 132cadb..b34cf15 100644
> --- a/grub-core/commands/efi/loadbios.c
> +++ b/grub-core/commands/efi/loadbios.c
> @@ -30,6 +30,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
>  static grub_efi_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
>  static grub_efi_guid_t acpi2_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
>  static grub_efi_guid_t smbios_guid = GRUB_EFI_SMBIOS_TABLE_GUID;
> +static grub_efi_guid_t smbios3_guid = GRUB_EFI_SMBIOS3_TABLE_GUID;
>  
>  #define EBDA_SEG_ADDR        0x40e
>  #define LOW_MEM_ADDR 0x413
> @@ -93,7 +94,7 @@ static void
>  fake_bios_data (int use_rom)
>  {
>    unsigned i;
> -  void *acpi, *smbios;
> +  void *acpi, *smbios, *smbios3;
>    grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
>  
>    ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
> @@ -103,6 +104,7 @@ fake_bios_data (int use_rom)
>  
>    acpi = 0;
>    smbios = 0;
> +  smbios3 = 0;
>    for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
>      {
>        grub_efi_packed_guid_t *guid =
> @@ -127,6 +129,11 @@ fake_bios_data (int use_rom)
>         smbios = grub_efi_system_table->configuration_table[i].vendor_table;
>         grub_dprintf ("efi", "SMBIOS: %p\n", smbios);
>       }
> +      else if (! grub_memcmp (guid, &smbios3_guid, sizeof (grub_efi_guid_t)))
> +     {
> +       smbios3 = grub_efi_system_table->configuration_table[i].vendor_table;
> +       grub_dprintf ("efi", "SMBIOS3: %p\n", smbios3);
> +     }
>      }
>  
>    *ebda_seg_ptr = FAKE_EBDA_SEG;
> @@ -137,8 +144,13 @@ fake_bios_data (int use_rom)
>    if (acpi)
>      grub_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
>  
> -  if ((use_rom) && (smbios))
> -    grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios + 16, 16);
> +  if (use_rom)
> +    {
> +      if (smbios)
> +     grub_memcpy ((char *) SBIOS_ADDR, (char *) smbios, 31);
> +      if (smbios3)
> +     grub_memcpy ((char *) SBIOS_ADDR + 32, (char *) smbios3, 24);
> +    }
>  }
>  
>  static grub_err_t
> diff --git a/grub-core/commands/efi/lsefisystab.c 
> b/grub-core/commands/efi/lsefisystab.c
> index 8717db9..256af43 100644
> --- a/grub-core/commands/efi/lsefisystab.c
> +++ b/grub-core/commands/efi/lsefisystab.c
> @@ -39,6 +39,7 @@ static const struct guid_mapping guid_mappings[] =
>      { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
>      { GRUB_EFI_SAL_TABLE_GUID, "SAL"},
>      { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
> +    { GRUB_EFI_SMBIOS3_TABLE_GUID, "SMBIOS3"},
>      { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
>      { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}
>    };
> diff --git a/grub-core/efiemu/i386/pc/cfgtables.c 
> b/grub-core/efiemu/i386/pc/cfgtables.c
> index 492c07c..ff4e10e 100644
> --- a/grub-core/efiemu/i386/pc/cfgtables.c
> +++ b/grub-core/efiemu/i386/pc/cfgtables.c
> @@ -30,12 +30,17 @@ grub_machine_efiemu_init_tables (void)
>    void *table;
>    grub_err_t err;
>    grub_efi_guid_t smbios = GRUB_EFI_SMBIOS_TABLE_GUID;
> +  grub_efi_guid_t smbios3 = GRUB_EFI_SMBIOS3_TABLE_GUID;
>    grub_efi_guid_t acpi20 = GRUB_EFI_ACPI_20_TABLE_GUID;
>    grub_efi_guid_t acpi = GRUB_EFI_ACPI_TABLE_GUID;
> +  grub_uint8_t found_smbios = 0;
>  
>    err = grub_efiemu_unregister_configuration_table (smbios);
>    if (err)
>      return err;
> +  err = grub_efiemu_unregister_configuration_table (smbios3);
> +  if (err)
> +    return err;
>    err = grub_efiemu_unregister_configuration_table (acpi);
>    if (err)
>      return err;
> @@ -60,17 +65,30 @@ grub_machine_efiemu_init_tables (void)
>  
>    for (ptr = (grub_uint8_t *) 0xf0000; ptr < (grub_uint8_t *) 0x100000;
>         ptr += 16)
> -    if (grub_memcmp (ptr, "_SM_", 4) == 0
> +    if (found_smbios != 2
> +     && grub_memcmp (ptr, "_SM_", 4) == 0
>       && grub_byte_checksum (ptr, *(ptr + 5)) == 0)
> -      break;
> -
> -  if (ptr < (grub_uint8_t *) 0x100000)
> -    {
> -      grub_dprintf ("efiemu", "Registering SMBIOS\n");
> -      err = grub_efiemu_register_configuration_table (smbios, 0, 0, ptr);
> -      if (err)
> -     return err;
> -    }
> +      {
> +     grub_dprintf ("efiemu", "Registering SMBIOS\n");
> +     err = grub_efiemu_register_configuration_table (smbios, 0, 0, ptr);
> +     if (err)
> +       return err;
> +     if (found_smbios == 3)
> +       break;
> +     found_smbios = 2;
> +      }
> +    else if (found_smbios != 3
> +          && grub_memcmp (ptr, "_SM3_", 5) == 0
> +          && grub_byte_checksum (ptr, *(ptr + 6)) == 0)
> +      {
> +     grub_dprintf ("efiemu", "Registering SMBIOS3\n");
> +     err = grub_efiemu_register_configuration_table (smbios3, 0, 0, ptr);
> +     if (err)
> +       return err;
> +     if (found_smbios == 2)
> +       break;
> +     found_smbios = 3;
> +      }
>  
>    return GRUB_ERR_NONE;
>  }
> diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
> index 1a5e38c..b96059d 100644
> --- a/include/grub/efi/api.h
> +++ b/include/grub/efi/api.h
> @@ -266,6 +266,11 @@
>      { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
>    }
>  
> +#define GRUB_EFI_SMBIOS3_TABLE_GUID  \
> +  { 0xf2fd1544, 0x9794, 0x4a2c, \
> +    { 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \
> +  }
> +
>  #define GRUB_EFI_SAL_TABLE_GUID \
>    { 0xeb9d2d32, 0x2d88, 0x11d3, \
>        { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]