SMBIOS Support for ARM
v3 cover SMBIOS Support for ARM
SMBIOS tables present userful system hardware info to management applications, such as DMI tools. Even though SMBIOS was originally developed for Intel x86, it has been extended to both Itanium and ARM (32bit & 64bit). More and more ARM server releases, such as RHEL Server for ARM, start to integrate support for SMBIOS.
This patchset is intendted to provid SMBIOS tables for ARM mach-virt machine. The SMBIOS tables are created and stored in fw_cfg, relying on OVMF (AAVMF) to parse/present SMBIOS entry.
RFC version have been tested by Laszlo using his customized version of AAVMF. This new version (V3) integrates SMBIOS 3.0 support for ARM mach-virt. I have tested this version using a customized AAVMF created by Laszlo, who has submitted his patches to OVMF mailing list.
V2->V3:
* Removed unncessary ram_size paramemter (patch 3 in V2, Laszlo)
* Fixed UUID encode (Laszlo)
* Added -smbios option (Leif)
* Fixed misc variable defintion (Laszlo)
* V2 regression tested on x86 (Gabriel and Leif)
V1->V2:
* Add NULL checking for fw_cfg (Shannon Zhao)
* Init 3.0 entry point table max size to smbios_tables_len (Laszlo)
* Minor re-arrangement of smbios.h layout with function headers to the bottom
* Validated SMBIOS 3.0 tables with a customized AAVMF created by Laszlo
RFC->V1:
* Add SMBIOS 3.0 support for buidling SMBIOS
* Switch from SMBIOS 2.1 to 3.0 for ARM mach-virt
* RFC version Tested-by Laszlo Ersek and Acked-by Gabriel Somlo
Thanks,
-Wei
Wei Huang (5):
smbios: extract x86 smbios building code into a function
smbios: remove dependency on x86 e820 tables
smbios: move smbios code into a common folder
smbios: add smbios 3.0 support
smbios: implement smbios support for mach-virt
arch_init.c | 2 +-
default-configs/arm-softmmu.mak | 1 +
default-configs/i386-softmmu.mak | 1 +
default-configs/x86_64-softmmu.mak | 1 +
hw/Makefile.objs | 1 +
hw/arm/virt.c | 25 +++++++++
hw/i386/Makefile.objs | 2 +-
hw/i386/pc.c | 56 +++++++++++++------
hw/i386/pc_piix.c | 5 +-
hw/i386/pc_q35.c | 5 +-
hw/smbios/Makefile.objs | 1 +
hw/{i386 => smbios}/smbios.c | 102 +++++++++++++++++++++++------------
include/hw/{i386 => smbios}/smbios.h | 53 ++++++++++++++----
qemu-options.hx | 2 +-
tests/bios-tables-test.c | 2 +-
vl.c | 2 +-
16 files changed, 191 insertions(+), 70 deletions(-)
create mode 100644 hw/smbios/Makefile.objs
rename hw/{i386 => smbios}/smbios.c (93%)
rename include/hw/{i386 => smbios}/smbios.h (85%)Signature · 1 line
1.8.3.1
PATCH v3 1/5 smbios: extract x86 smbios building code into a function
This patch extracts out the procedure of buidling x86 SMBIOS tables into a dedicated function.
--- hw/i386/pc.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
hw/i386/pc.c +22 -16
@@ -718,11 +718,30 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)return x86_cpu_apic_id_from_index (max_cpus -1 ) +1 ; } -static FWCfgState *bochs_bios_init (void ) +static void pc_build_smbios (FWCfgState *fw_cfg) { -FWCfgState *fw_cfg;uint8_t *smbios_tables, *smbios_anchor;size_t smbios_tables_len, smbios_anchor_len; + + smbios_tables =smbios_get_table_legacy (&smbios_tables_len); +if (smbios_tables) { +fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , + smbios_tables, smbios_tables_len); + } + +smbios_get_tables (&smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } +} + +static FWCfgState *bochs_bios_init (void ) +{ +FWCfgState *fw_cfg;uint64_t *numa_fw_cfg;int i, j;unsigned int apic_id_limit =pc_apic_id_limit (max_cpus);
@@ -748,20 +767,7 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_tables =smbios_get_table_legacy (&smbios_tables_len); -if (smbios_tables) { -fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , - smbios_tables, smbios_tables_len); - } - -smbios_get_tables (&smbios_tables, &smbios_tables_len, - &smbios_anchor, &smbios_anchor_len); -if (smbios_anchor) { -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , - smbios_tables, smbios_tables_len); -fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , - smbios_anchor, smbios_anchor_len); - } +pc_build_smbios (fw_cfg);fw_cfg_add_bytes (fw_cfg,FW_CFG_E820_TABLE , &e820_reserve,sizeof (e820_reserve));
Signature · 1 line
1.8.3.1
PATCH v3 2/5 smbios: remove dependency on x86 e820 tables
In reply to Wei HuangCurrent smbios builds type 19 table from e820, which is x86 specific. This patch removes smbios' dependency on e820 by passing an array of memory area to smbios_get_tables().
--- hw/i386/pc.c | 18 +++++++++++++++++- hw/i386/smbios.c | 14 +++++++------- include/hw/i386/smbios.h | 10 +++++++++- 3 files changed, 33 insertions(+), 9 deletions(-)
hw/i386/pc.c +17 -1
@@ -722,6 +722,8 @@ static void pc_build_smbios(FWCfgState *fw_cfg) {uint8_t *smbios_tables, *smbios_anchor;size_t smbios_tables_len, smbios_anchor_len; +struct smbios_phys_mem_area *mem_array; +unsigned i, array_count; smbios_tables =smbios_get_table_legacy (&smbios_tables_len);if (smbios_tables) {
@@ -729,8 +731,22 @@ static void pc_build_smbios(FWCfgState *fw_cfg) smbios_tables, smbios_tables_len); } -smbios_get_tables (&smbios_tables, &smbios_tables_len, +/* build the array of physical mem area from e820 table */ + mem_array =g_malloc0 (sizeof (*mem_array) *e820_get_num_entries ()); +for (i =0 , array_count =0 ; i <e820_get_num_entries (); i++) { +uint64_t addr, len; + +if (e820_get_entry (i,E820_RAM , &addr, &len)) { + mem_array[array_count].address = addr; + mem_array[array_count].length = len; + array_count++; + } + } +smbios_get_tables (mem_array, array_count, + &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len); +g_free (mem_array); +if (smbios_anchor) {fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , smbios_tables, smbios_tables_len);
hw/i386/smbios.c +7 -7
@@ -831,10 +831,12 @@ static void smbios_entry_point_setup(void) ep.structure_table_address =cpu_to_le32 (0 ); } -void smbios_get_tables (uint8_t **tables,size_t *tables_len, +void smbios_get_tables (const struct smbios_phys_mem_area *mem_array, +const unsigned int mem_array_size, +uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len) { -unsigned i, dimm_cnt, instance; +unsigned i, dimm_cnt;if (smbios_legacy) { *tables = *anchor =NULL ;
@@ -867,11 +869,9 @@ void smbios_get_tables(uint8_t **tables, size_t *tables_len,smbios_build_type_17_table (i,GET_DIMM_SZ ); } -for (i =0 , instance =0 ; i <e820_get_num_entries (); i++) { -uint64_t address, length; -if (e820_get_entry (i,E820_RAM , &address, &length)) { -smbios_build_type_19_table (instance++, address, length); - } +for (i =0 ; i < mem_array_size; i++) { +smbios_build_type_19_table (i, mem_array[i].address, + mem_array[i].length); }smbios_build_type_32_table ();
include/hw/i386/smbios.h +9 -1
@@ -17,13 +17,21 @@#define SMBIOS_MAX_TYPE 127 +/* memory area description, used by type 19 table */ +struct smbios_phys_mem_area { +uint64_t address; +uint64_t length; +}; +void smbios_entry_add (QemuOpts *opts);void smbios_set_cpuid (uint32_t version,uint32_t features);void smbios_set_defaults (const char *manufacturer,const char *product,const char *version,bool legacy_mode,bool uuid_encoded);uint8_t *smbios_get_table_legacy (size_t *length); -void smbios_get_tables (uint8_t **tables,size_t *tables_len, +void smbios_get_tables (const struct smbios_phys_mem_area *mem_array, +const unsigned int mem_array_size, +uint8_t **tables,size_t *tables_len,uint8_t **anchor,size_t *anchor_len);/*
Signature · 1 line
1.8.3.1
PATCH v3 3/5 smbios: move smbios code into a common folder
In reply to Wei HuangTo share smbios among different architectures, this patch moves SMBIOS code (smbios.c and smbios.h) from x86 specific folders into new hw/smbios directories. As a result, CONFIG_SMBIOS=y is defined in x86 default config files.
---
arch_init.c | 2 +-
default-configs/i386-softmmu.mak | 1 +
default-configs/x86_64-softmmu.mak | 1 +
hw/Makefile.objs | 1 +
hw/i386/Makefile.objs | 2 +-
hw/i386/pc.c | 2 +-
hw/i386/pc_piix.c | 2 +-
hw/i386/pc_q35.c | 2 +-
hw/smbios/Makefile.objs | 1 +
hw/{i386 => smbios}/smbios.c | 5 ++---
include/hw/{i386 => smbios}/smbios.h | 0
tests/bios-tables-test.c | 2 +-
vl.c | 2 +-
13 files changed, 13 insertions(+), 10 deletions(-)
create mode 100644 hw/smbios/Makefile.objs
rename hw/{i386 => smbios}/smbios.c (99%)
rename include/hw/{i386 => smbios}/smbios.h (100%)arch_init.c +1 -1
@@ -26,7 +26,7 @@#include "sysemu/arch_init.h" #include "hw/pci/pci.h" #include "hw/audio/audio.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qmp-commands.h"
default-configs/i386-softmmu.mak +1 -0
@@ -49,3 +49,4 @@ CONFIG_MEM_HOTPLUG=y CONFIG_XIO3130=y CONFIG_IOH3420=y CONFIG_I82801B11=y +CONFIG_SMBIOS=y
default-configs/x86_64-softmmu.mak +1 -0
@@ -50,3 +50,4 @@ CONFIG_MEM_HOTPLUG=y CONFIG_XIO3130=y CONFIG_IOH3420=y CONFIG_I82801B11=y +CONFIG_SMBIOS=y
hw/Makefile.objs +1 -0
@@ -31,6 +31,7 @@ devices-dirs-$(CONFIG_VIRTIO) += virtio/ devices-dirs-$(CONFIG_SOFTMMU) += watchdog/ devices-dirs-$(CONFIG_SOFTMMU) += xen/ devices-dirs-$(CONFIG_MEM_HOTPLUG) += mem/ +devices-dirs-$(CONFIG_SMBIOS) += smbios/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y)
hw/i386/Makefile.objs +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_KVM) += kvm/ -obj-y += multiboot.o smbios.o +obj-y += multiboot.o obj-y += pc.o pc_piix.o pc_q35.o obj-y += pc_sysfw.o obj-y += intel_iommu.o
hw/i386/pc.c +1 -1
@@ -33,7 +33,7 @@#include "hw/pci/pci_bus.h" #include "hw/nvram/fw_cfg.h" #include "hw/timer/hpet.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "hw/loader.h" #include "elf.h" #include "multiboot.h"
hw/i386/pc_piix.c +1 -1
@@ -28,7 +28,7 @@#include "hw/loader.h" #include "hw/i386/pc.h" #include "hw/i386/apic.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" #include "hw/usb.h"
hw/i386/pc_q35.c +1 -1
@@ -39,7 +39,7 @@#include "hw/pci-host/q35.h" #include "exec/address-spaces.h" #include "hw/i386/ich9.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb.h"
hw/smbios/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +common-obj-$(CONFIG_SMBIOS) += smbios.o
hw/smbios/smbios.c renamed from hw/i386/smbios.c +2 -3
@@ -19,10 +19,9 @@#include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "sysemu/cpus.h" -#include "hw/i386/pc.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "hw/loader.h" - +#include "exec/cpu-common.h" /* legacy structures and constants for <= 2.0 machines */ struct smbios_header {
include/hw/smbios/smbios.h renamed from include/hw/i386/smbios.h +0 -0
tests/bios-tables-test.c +1 -1
@@ -18,7 +18,7 @@#include "libqtest.h" #include "qemu/compiler.h" #include "hw/acpi/acpi-defs.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "qemu/bitmap.h" #define MACHINE_PC "pc"
vl.c +1 -1
@@ -68,7 +68,7 @@ int main(int argc, char **argv)#include "hw/isa/isa.h" #include "hw/bt.h" #include "sysemu/watchdog.h" -#include "hw/i386/smbios.h" +#include "hw/smbios/smbios.h" #include "hw/xen/xen.h" #include "hw/qdev.h" #include "hw/loader.h"
Signature · 1 line
1.8.3.1
PATCH v3 4/5 smbios: add smbios 3.0 support
In reply to Wei HuangThis patch adds support for SMBIOS 3.0 entry point. When caller invokes smbios_set_defaults(), it can specify entry point as 2.1 or 3.0. Then smbios_get_tables() will return the entry point table in right format.
--- hw/i386/pc_piix.c | 3 +- hw/i386/pc_q35.c | 3 +- hw/smbios/smbios.c | 83 +++++++++++++++++++++++++++++++++------------- include/hw/smbios/smbios.h | 51 ++++++++++++++++++++-------- 4 files changed, 101 insertions(+), 39 deletions(-)
hw/i386/pc_piix.c +2 -1
@@ -173,7 +173,8 @@ static void pc_init1(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (i440FX + PIIX, 1996)" , - mc->name, smbios_legacy_mode, smbios_uuid_encoded); + mc->name, smbios_legacy_mode, smbios_uuid_encoded, +SMBIOS_ENTRY_POINT_21 ); }/* allocate ram and load rom/bios */
hw/i386/pc_q35.c +2 -1
@@ -165,7 +165,8 @@ static void pc_q35_init(MachineState *machine)if (smbios_defaults) {/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (Q35 + ICH9, 2009)" , - mc->name, smbios_legacy_mode, smbios_uuid_encoded); + mc->name, smbios_legacy_mode, smbios_uuid_encoded, +SMBIOS_ENTRY_POINT_21 ); }/* allocate ram and load rom/bios */
hw/smbios/smbios.c +60 -23
111 lines not on this page · raw message
include/hw/smbios/smbios.h +37 -14
72 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support
Quoted 48 lines · Wei Huang
This patch adds support for SMBIOS 3.0 entry point. When caller invokes
smbios_set_defaults(), it can specify entry point as 2.1 or 3.0. Thensmbios_get_tables()will return the entry point table in right format.Acked-by Gabriel Somlo <[email protected]>Tested-by Gabriel Somlo <[email protected]>Tested-by Leif Lindholm <[email protected]>Signed-off-by Wei Huang <[email protected]>--- hw/i386/pc_piix.c | 3 +- hw/i386/pc_q35.c | 3 +- hw/smbios/smbios.c | 83 +++++++++++++++++++++++++++++++++------------- include/hw/smbios/smbios.h | 51 ++++++++++++++++++++-------- 4 files changed, 101 insertions(+), 39 deletions(-)hw/i386/pc_piix.c +2
-1@@ -173,7 +173,8 @@ static void pc_init1(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (i440FX + PIIX, 1996)" , - mc->name, smbios_legacy_mode, smbios_uuid_encoded); + mc->name, smbios_legacy_mode, smbios_uuid_encoded, +SMBIOS_ENTRY_POINT_21 ); }/* allocate ram and load rom/bios */ hw/i386/pc_q35.c +2
-1@@ -165,7 +165,8 @@ static void pc_q35_init(MachineState *machine)if (smbios_defaults) {/* These values are guest ABI, do not change */ smbios_set_defaults ("QEMU" ,"Standard PC (Q35 + ICH9, 2009)" , - mc->name, smbios_legacy_mode, smbios_uuid_encoded); + mc->name, smbios_legacy_mode, smbios_uuid_encoded, +SMBIOS_ENTRY_POINT_21 ); }/* allocate ram and load rom/bios */ hw/smbios/smbios.c +0
-0
hw/smbios/smbios.c static uint8_t *smbios_tables; · line 61
Quoted 8 lines
hw/smbios/smbios.c +4
-1@@ -55,7 +55,10 @@ static uint8_t *smbios_tables;static size_t smbios_tables_len;static unsigned smbios_table_max;static unsigned smbios_table_cnt; -static struct smbios_entry_point ep; +static SmbiosEntryPointType smbios_ep_type =SMBIOS_ENTRY_POINT_21 ; + +static SmbiosEntryPoint ep; +static size_t ep_length;
I think it's better to drop ep_length and write a function that retrieves length from ep, based on anchor string. Don't duplicate information.
Quoted 187 lines
hw/smbios/smbios.c +56
-22static int smbios_type4_count =0 ;static bool smbios_immutable;@@ -771,11 +774,12 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)void smbios_set_defaults (const char *manufacturer,const char *product,const char *version,bool legacy_mode, -bool uuid_encoded) +bool uuid_encoded,SmbiosEntryPointType ep_type) { smbios_have_defaults = true; smbios_legacy = legacy_mode; smbios_uuid_encoded = uuid_encoded; + smbios_ep_type = ep_type;/* drop unwanted version of command-line file blob(s) */ if (smbios_legacy) {@@ -808,26 +812,59 @@ void smbios_set_defaults(const char *manufacturer, const char *product,static void smbios_entry_point_setup (void ) { -memcpy (ep.anchor_string,"_SM_" ,4 ); -memcpy (ep.intermediate_anchor_string,"_DMI_" ,5 ); - ep.length =sizeof (struct smbios_entry_point ); - ep.entry_point_revision =0 ;/* formatted_area reserved, per spec v2.1+ */ -memset (ep.formatted_area,0 ,5 ); - -/* compliant with smbios spec v2.8 */ - ep.smbios_major_version =2 ; - ep.smbios_minor_version =8 ; - ep.smbios_bcd_revision =0x28 ; - -/* set during table construction, but BIOS may override: */ - ep.structure_table_length =cpu_to_le16 (smbios_tables_len); - ep.max_structure_size =cpu_to_le16 (smbios_table_max); - ep.number_of_structures =cpu_to_le16 (smbios_table_cnt); - -/* BIOS must recalculate: */ - ep.checksum =0 ; - ep.intermediate_checksum =0 ; - ep.structure_table_address =cpu_to_le32 (0 ); +switch (smbios_ep_type) { +case SMBIOS_ENTRY_POINT_21 : +memcpy (ep.ep21.anchor_string,"_SM_" ,4 ); +memcpy (ep.ep21.intermediate_anchor_string,"_DMI_" ,5 ); + ep.ep21.length =sizeof (struct smbios_21_entry_point ); + ep.ep21.entry_point_revision =0 ;/* formatted_area reserved */ +memset (ep.ep21.formatted_area,0 ,5 ); + +/* compliant with smbios spec v2.8 */ + ep.ep21.smbios_major_version =2 ; + ep.ep21.smbios_minor_version =8 ; + ep.ep21.smbios_bcd_revision =0x28 ; + +/* set during table construction, but BIOS may override: */ + ep.ep21.structure_table_length =cpu_to_le16 (smbios_tables_len); + ep.ep21.max_structure_size =cpu_to_le16 (smbios_table_max); + ep.ep21.number_of_structures =cpu_to_le16 (smbios_table_cnt); + +/* BIOS must recalculate */ + ep.ep21.checksum =0 ; + ep.ep21.intermediate_checksum =0 ; + ep.ep21.structure_table_address =cpu_to_le32 (0 ); + +/* setup the anchor point length */ + ep_length =sizeof (struct smbios_21_entry_point ); + +break ; +case SMBIOS_ENTRY_POINT_30 : +memcpy (ep.ep30.anchor_string,"_SM3_" ,5 ); + ep.ep30.length =sizeof (struct smbios_30_entry_point ); + ep.ep30.entry_point_revision =1 ; + ep.ep30.reserved =0 ; + +/* compliant with smbios spec 3.0 */ + ep.ep30.smbios_major_version =3 ; + ep.ep30.smbios_minor_version =0 ; + ep.ep30.smbios_doc_rev =0 ; + +/* set during table construct, but BIOS might override */ + ep.ep30.structure_table_max_size =cpu_to_le32 (smbios_tables_len); + +/* BIOS must recalculate */ + ep.ep30.checksum =0 ; + ep.ep30.structure_table_address =cpu_to_le64 (0 ); + +/* setup anchor point length */ + ep_length =sizeof (struct smbios_30_entry_point ); + +break ; +default : +abort (); +break ; + } } void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,@@ -885,7 +922,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, *tables = smbios_tables; *tables_len = smbios_tables_len; *anchor = (uint8_t *)&ep; - *anchor_len =sizeof (struct smbios_entry_point ); + *anchor_len = ep_length; }static void save_opt (const char **dest,QemuOpts *opts,const char *name)include/hw/smbios/smbios.h +37
-14@@ -23,25 +23,19 @@ struct smbios_phys_mem_area {uint64_t length; }; -void smbios_entry_add (QemuOpts *opts); -void smbios_set_cpuid (uint32_t version,uint32_t features); -void smbios_set_defaults (const char *manufacturer,const char *product, -const char *version,bool legacy_mode, -bool uuid_encoded); -uint8_t *smbios_get_table_legacy (size_t *length); -void smbios_get_tables (const struct smbios_phys_mem_area *mem_array, -const unsigned int mem_array_size, -uint8_t **tables,size_t *tables_len, -uint8_t **anchor,size_t *anchor_len); -/* * SMBIOS spec defined tables */ +typedef enum SmbiosEntryPointType { +SMBIOS_ENTRY_POINT_21 , +SMBIOS_ENTRY_POINT_30 , +}SmbiosEntryPointType ; -/* SMBIOS entry point (anchor). -* BIOS must place this at a 16-bit-aligned address between 0xf0000 and 0xfffff. +/* SMBIOS entry point +* BIOS must place this at a 16-bit-aligned address between 0xf0000 +* and 0xfffff. */ -struct smbios_entry_point { +struct smbios_21_entry_point {uint8_t anchor_string[4 ];uint8_t checksum;uint8_t length;@@ -58,6 +52,25 @@ struct smbios_entry_point {uint8_t smbios_bcd_revision; }QEMU_PACKED ; +/* SMBIOS 3.0 entry point */ +struct smbios_30_entry_point { +uint8_t anchor_string[5 ]; +uint8_t checksum; +uint8_t length; +uint8_t smbios_major_version; +uint8_t smbios_minor_version; +uint8_t smbios_doc_rev; +uint8_t entry_point_revision; +uint8_t reserved; +uint32_t structure_table_max_size; +uint64_t structure_table_address; +}QEMU_PACKED ; + +typedef union { +struct smbios_21_entry_point ep21; +struct smbios_30_entry_point ep30; +} QEMU_PACKED SmbiosEntryPoint; +/* This goes at the beginning of every SMBIOS structure. */ struct smbios_structure_header {uint8_t type;@@ -232,4 +245,14 @@ struct smbios_type_127 { struct smbios_structure_header header; }QEMU_PACKED ; +void smbios_entry_add (QemuOpts *opts); +void smbios_set_cpuid (uint32_t version,uint32_t features); +void smbios_set_defaults (const char *manufacturer,const char *product, +const char *version,bool legacy_mode, +bool uuid_encoded,SmbiosEntryPointType ep_type); +uint8_t *smbios_get_table_legacy (size_t *length); +void smbios_get_tables (const struct smbios_phys_mem_area *mem_array, +const unsigned int mem_array_size, +uint8_t **tables,size_t *tables_len, +uint8_t **anchor,size_t *anchor_len);#endif /*QEMU_SMBIOS_H */ Signature · 1 line
1.8.3.1
PATCH v3 5/5 smbios: implement smbios support for mach-virt
In reply to Wei HuangThis patch generates smbios tables for ARM mach-virt. Also add CONFIG_SMBIOS=y for ARM default config.
--- default-configs/arm-softmmu.mak | 1 + hw/arm/virt.c | 25 +++++++++++++++++++++++++ qemu-options.hx | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-)
default-configs/arm-softmmu.mak +1 -0
@@ -102,3 +102,4 @@ CONFIG_XIO3130=y CONFIG_IOH3420=y CONFIG_I82801B11=y CONFIG_ACPI=y +CONFIG_SMBIOS=y
hw/arm/virt.c +25 -0
@@ -48,6 +48,7 @@#include "hw/arm/sysbus-fdt.h" #include "hw/platform-bus.h" #include "hw/arm/fdt.h" +#include "hw/smbios/smbios.h" /* Number of external interrupt lines to configure the GIC with */ #define NUM_IRQS 256
@@ -780,12 +781,36 @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)return board->fdt; } +static void virt_build_smbios (VirtGuestInfo *guest_info) +{ +FWCfgState *fw_cfg = guest_info->fw_cfg; +uint8_t *smbios_tables, *smbios_anchor; +size_t smbios_tables_len, smbios_anchor_len; + +if (!fw_cfg) +return ; + +smbios_set_defaults ("QEMU" ,"QEMU Virtual Machine" , +"1.0" , false, true,SMBIOS_ENTRY_POINT_30 ); + +smbios_get_tables (NULL ,0 , &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len); + +if (smbios_anchor) { +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-tables" , + smbios_tables, smbios_tables_len); +fw_cfg_add_file (fw_cfg,"etc/smbios/smbios-anchor" , + smbios_anchor, smbios_anchor_len); + } +} +static void virt_guest_info_machine_done (Notifier *notifier,void *data) {VirtGuestInfoState *guest_info_state =container_of (notifier, VirtGuestInfoState, machine_done);virt_acpi_setup (&guest_info_state->info); +virt_build_smbios (&guest_info_state->info); }static void machvirt_init (MachineState *machine)
qemu-options.hx +1 -1
@@ -1412,7 +1412,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, "-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n" " [,asset=str][,part=str][,speed=%d]\n" " specify SMBIOS type 17 fields\n", - QEMU_ARCH_I386) + QEMU_ARCH_I386 | QEMU_ARCH_ARM) STEXI @item -smbios file=@var{binary} @findex -smbios
Signature · 1 line
1.8.3.1
Quoted 15 lines · Wei Huang
SMBIOS tables present userful system hardware info to management applications, such as DMI tools. Even though SMBIOS was originally developed for Intel x86, it has been extended to both Itanium and ARM (32bit & 64bit). More and more ARM server releases, such as RHEL Server for ARM, start to integrate support for SMBIOS.
This patchset is intendted to provid SMBIOS tables for ARM mach-virt machine. The SMBIOS tables are created and stored in
fw_cfg, relying on OVMF (AAVMF) to parse/present SMBIOS entry.RFC version have been tested by Laszlo using his customized version of AAVMF. This new version (V3) integrates SMBIOS 3.0 support for ARM mach-virt. I have tested this version using a customized AAVMF created by Laszlo, who has submitted his patches to OVMF mailing list.
Quoted 6 lines
V2->V3:
* Removed unncessaryram_sizeparamemter (patch 3 in V2, Laszlo)
* Fixed UUID encode (Laszlo)
* Added -smbios option (Leif)
* Fixed misc variable defintion (Laszlo)
* V2 regression tested on x86 (Gabriel and Leif)
* Main changes are in Patch 4 and 5.
* I left Laszlo out in Acked-by of Patch 4 as most comments were from him in this patch.
* I tested UUID and it did show up correctly inside the guest VM.
Thanks,
-Wei
Quoted 43 lines
V1->V2:
* Add NULL checking forfw_cfg(Shannon Zhao)
* Init 3.0 entry point table max size tosmbios_tables_len(Laszlo)
* Minor re-arrangement ofsmbios.hlayout with function headers to the bottom
* Validated SMBIOS 3.0 tables with a customized AAVMF created by Laszlo
RFC->V1:
* Add SMBIOS 3.0 support for buidling SMBIOS
* Switch from SMBIOS 2.1 to 3.0 for ARM mach-virt
* RFC version Tested-by Laszlo Ersek and Acked-by Gabriel SomloThanks,
-WeiWei Huang (5):
smbios: extract x86 smbios building code into a function
smbios: remove dependency on x86 e820 tables
smbios: move smbios code into a common folder
smbios: add smbios 3.0 support
smbios: implement smbios support for mach-virtarch_init.c | 2 +- default-configs/arm-softmmu.mak | 1 + default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/arm/virt.c | 25 +++++++++ hw/i386/Makefile.objs | 2 +- hw/i386/pc.c | 56 +++++++++++++------ hw/i386/pc_piix.c | 5 +- hw/i386/pc_q35.c | 5 +- hw/smbios/Makefile.objs | 1 + hw/{i386 => smbios}/smbios.c | 102 +++++++++++++++++++++++------------ include/hw/{i386 => smbios}/smbios.h | 53 ++++++++++++++---- qemu-options.hx | 2 +- tests/bios-tables-test.c | 2 +- vl.c | 2 +- 16 files changed, 191 insertions(+), 70 deletions(-) create mode 100644 hw/smbios/Makefile.objs rename hw/{i386 => smbios}/smbios.c (93%) rename include/hw/{i386 => smbios}/smbios.h (85%)