Skip to contentSkip to conversation

SMBIOS Support for ARM

PATCH Applied Wei Huang 3 participants 8 messages Aug 26, 2015 – Sep 1, 2015

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

v5 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.

Given that refractoring patches have been accepted by upstream. This new version (V5) 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. Compatibility tests for x86 VMs (Linux & Windows) also passed.

V4->V5:
* Fixed tests/bios-tables-test
* Validated with ARM64/x86-64 VMs and passed "make test"

V3->V4:
* Patch 1 - 3 accepted by mst tree. So start from Patch 4 & 5
* Remove ep_length; Instead infer anchor_length from anchor string (mst)

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 (2):
smbios: add smbios 3.0 support
smbios: implement smbios support for mach-virt

 default-configs/arm-softmmu.mak |  1 +
 hw/arm/virt.c                   | 25 ++++++++++++
 hw/i386/pc_piix.c               |  3 +-
 hw/i386/pc_q35.c                |  3 +-
 hw/smbios/smbios.c              | 84 ++++++++++++++++++++++++++++++-----------
 include/hw/smbios/smbios.h      | 62 +++++++++++++++++++++++-------
 qemu-options.hx                 |  2 +-
 tests/bios-tables-test.c        |  6 +--
 8 files changed, 143 insertions(+), 43 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v5 1/2 smbios: add smbios 3.0 support

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. 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         | 84 +++++++++++++++++++++++++++++++++-------------
 include/hw/smbios/smbios.h | 62 ++++++++++++++++++++++++++--------
 tests/bios-tables-test.c   |  6 ++--
 5 files changed, 116 insertions(+), 42 deletions(-)
hw/i386/pc_piix.c +2 -1
index 9558467..b82921d 100644
@@ -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
index c07d65b..7217cbf 100644
@@ -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 +61 -23

112 lines not on this page · raw message

include/hw/smbios/smbios.h +48 -14

83 lines not on this page · raw message

tests/bios-tables-test.c +3 -3
index 613867a..9686328 100644
@@ -50,7 +50,7 @@ typedef struct {
     int rsdt_tables_nr;
     GArray *tables;
     uint32_t smbios_ep_addr;
-    struct smbios_entry_point smbios_ep_table;
+    struct smbios_21_entry_point smbios_ep_table;
 } test_data;
 
 #define LOW(x) ((x) & 0xff)
@@ -601,7 +601,7 @@ static void test_acpi_asl(test_data *data)
 
 static bool smbios_ep_table_ok(test_data *data)
 {
-    struct smbios_entry_point *ep_table = &data->smbios_ep_table;
+    struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
     uint32_t addr = data->smbios_ep_addr;
 
     ACPI_READ_ARRAY(ep_table->anchor_string, addr);
@@ -681,7 +681,7 @@ static inline bool smbios_single_instance(uint8_t type)
 static void test_smbios_structs(test_data *data)
 {
     DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
-    struct smbios_entry_point *ep_table = &data->smbios_ep_table;
+    struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
     uint32_t addr = ep_table->structure_table_address;
     int i, len, max_len = 0;
     uint8_t type, prv, crt;
Signature · 1 line
1.8.3.1
Reviewed-by on v5 1/2
#2 lore raw

Re: [Qemu-devel] [ARM SMBIOS V5 PATCH 1/2] smbios: add smbios 3.0 support

Quoted 8 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. Then smbios_get_tables() will return the entry point table in right format.

Quoted 7 lines
---
 hw/i386/pc_piix.c          |  3 +-
 hw/i386/pc_q35.c           |  3 +-
 hw/smbios/smbios.c         | 84 +++++++++++++++++++++++++++++++++-------------
 include/hw/smbios/smbios.h | 62 ++++++++++++++++++++++++++--------
 tests/bios-tables-test.c   |  6 ++--
 5 files changed, 116 insertions(+), 42 deletions(-)

Diffed against v4.

(although my reviews are obviously not the bottleneck here, so I wonder why I bother at all)

#3 lore raw

Re: [Qemu-devel] [ARM SMBIOS V5 PATCH 1/2] smbios: add smbios 3.0 support

Quoted 17 lines · Laszlo Ersek
Quoted 8 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. Then smbios_get_tables() will return the entry point table in right format.

Quoted 7 lines
---
 hw/i386/pc_piix.c          |  3 +-
 hw/i386/pc_q35.c           |  3 +-
 hw/smbios/smbios.c         | 84 +++++++++++++++++++++++++++++++++-------------
 include/hw/smbios/smbios.h | 62 ++++++++++++++++++++++++++--------
 tests/bios-tables-test.c   |  6 ++--
 5 files changed, 116 insertions(+), 42 deletions(-)
Quoted 6 lines

Diffed against v4.

(although my reviews are obviously not the bottleneck here, so I wonder why I bother at all)

Just a note to say that I do appreciate the code review, especially as here when the patches deal with something that's not my area of expertise.

thanks
-- PMM

author
#4 lore raw

PATCH v5 2/2 smbios: implement smbios support for mach-virt

In reply to Wei Huang

This 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
index 74f1db3..99b41e9 100644
@@ -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
index d5a8417..e3a8f36 100644
@@ -50,6 +50,7 @@
 #include "hw/arm/fdt.h"
 #include "hw/intc/arm_gic_common.h"
 #include "kvm_arm.h"
+#include "hw/smbios/smbios.h"
 
 /* Number of external interrupt lines to configure the GIC with */
 #define NUM_IRQS 256
@@ -788,12 +789,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
index 77f5853..efce775 100644
@@ -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
#5 lore raw

Re: [Qemu-devel] [ARM SMBIOS V5 PATCH 2/2] smbios: implement smbios support for mach-virt

Quoted 10 lines · Wei Huang

This patch generates smbios tables for ARM mach-virt. Also add CONFIG_SMBIOS=y for ARM default config.

hw/arm/virt.c static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) · line 799

Quoted 8 lines
hw/arm/virt.c +8 -0
+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;

Missing braces for if (). You can catch this sort of thing yourself by running scripts/checkpatch.pl on your patches.

In this case this looks like the only issue with this patchset, so I'll fix it when I put it into target-arm.next.

thanks
-- PMM

#6 lore raw
In reply to Wei Huang
Quoted 6 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.

Quoted 8 lines

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.

Given that refractoring patches have been accepted by upstream. This new version (V5) 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.

To be precise, the necessary edk2 patches have been upstream for a while. The commit range is b265ed92^..c3db5a8c.

Thanks
Laszlo

Quoted 46 lines

Compatibility tests
for x86 VMs (Linux & Windows) also passed.

V4->V5:
* Fixed tests/bios-tables-test
* Validated with ARM64/x86-64 VMs and passed "make test"

V3->V4:
* Patch 1 - 3 accepted by mst tree. So start from Patch 4 & 5
* Remove ep_length; Instead infer anchor_length from anchor string (mst)

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 (2):
smbios: add smbios 3.0 support
smbios: implement smbios support for mach-virt

 default-configs/arm-softmmu.mak |  1 +
 hw/arm/virt.c                   | 25 ++++++++++++
 hw/i386/pc_piix.c               |  3 +-
 hw/i386/pc_q35.c                |  3 +-
 hw/smbios/smbios.c              | 84 ++++++++++++++++++++++++++++++-----------
 include/hw/smbios/smbios.h      | 62 +++++++++++++++++++++++-------
 qemu-options.hx                 |  2 +-
 tests/bios-tables-test.c        |  6 +--
 8 files changed, 143 insertions(+), 43 deletions(-)
#7 lore raw
In reply to Wei Huang
Quoted 10 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.

Quoted 5 lines

Given that refractoring patches have been accepted by upstream. This new version (V5) 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. Compatibility tests for x86 VMs (Linux & Windows) also passed.

Thanks, applied to target-arm.next.

-- PMM