* [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM
@ 2015-08-12 2:08 Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 1/5] smbios: extract x86 smbios building code into a function Wei Huang
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
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%)
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [ARM SMBIOS V3 PATCH 1/5] smbios: extract x86 smbios building code into a function
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
@ 2015-08-12 2:08 ` Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 2/5] smbios: remove dependency on x86 e820 tables Wei Huang
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
This patch extracts out the procedure of buidling x86 SMBIOS tables
into a dedicated function.
Acked-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Wei Huang <wei@redhat.com>
---
hw/i386/pc.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7661ea9..00e45f3 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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));
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [ARM SMBIOS V3 PATCH 2/5] smbios: remove dependency on x86 e820 tables
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 1/5] smbios: extract x86 smbios building code into a function Wei Huang
@ 2015-08-12 2:08 ` Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 3/5] smbios: move smbios code into a common folder Wei Huang
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
Current 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().
Acked-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Wei Huang <wei@redhat.com>
---
hw/i386/pc.c | 18 +++++++++++++++++-
hw/i386/smbios.c | 14 +++++++-------
include/hw/i386/smbios.h | 10 +++++++++-
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 00e45f3..34e9133 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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);
diff --git a/hw/i386/smbios.c b/hw/i386/smbios.c
index 1341e02..6f715c6 100644
--- a/hw/i386/smbios.c
+++ b/hw/i386/smbios.c
@@ -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();
diff --git a/include/hw/i386/smbios.h b/include/hw/i386/smbios.h
index d2850be..4269aab 100644
--- a/include/hw/i386/smbios.h
+++ b/include/hw/i386/smbios.h
@@ -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);
/*
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [ARM SMBIOS V3 PATCH 3/5] smbios: move smbios code into a common folder
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 1/5] smbios: extract x86 smbios building code into a function Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 2/5] smbios: remove dependency on x86 e820 tables Wei Huang
@ 2015-08-12 2:08 ` Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support Wei Huang
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
To 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.
Acked-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Wei Huang <wei@redhat.com>
---
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%)
diff --git a/arch_init.c b/arch_init.c
index 725c638..38f5fb9 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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"
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 48b5762..5eaafa1 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -49,3 +49,4 @@ CONFIG_MEM_HOTPLUG=y
CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
+CONFIG_SMBIOS=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 4962ed7..28e2099 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -50,3 +50,4 @@ CONFIG_MEM_HOTPLUG=y
CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
+CONFIG_SMBIOS=y
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 73afa41..7e7c241 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -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)
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index bd4f147..723a4d8 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -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
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 34e9133..3987096 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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"
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a896624..653c710 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -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"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 974aead..d83df14 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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"
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
new file mode 100644
index 0000000..f69a92f
--- /dev/null
+++ b/hw/smbios/Makefile.objs
@@ -0,0 +1 @@
+common-obj-$(CONFIG_SMBIOS) += smbios.o
diff --git a/hw/i386/smbios.c b/hw/smbios/smbios.c
similarity index 99%
rename from hw/i386/smbios.c
rename to hw/smbios/smbios.c
index 6f715c6..efdbb5d 100644
--- a/hw/i386/smbios.c
+++ b/hw/smbios/smbios.c
@@ -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 {
diff --git a/include/hw/i386/smbios.h b/include/hw/smbios/smbios.h
similarity index 100%
rename from include/hw/i386/smbios.h
rename to include/hw/smbios/smbios.h
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 0de1742..613867a 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -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"
diff --git a/vl.c b/vl.c
index 0adbbd6..584ca88 100644
--- a/vl.c
+++ b/vl.c
@@ -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"
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
` (2 preceding siblings ...)
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 3/5] smbios: move smbios code into a common folder Wei Huang
@ 2015-08-12 2:08 ` Wei Huang
2015-08-12 9:12 ` Michael S. Tsirkin
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 5/5] smbios: implement smbios support for mach-virt Wei Huang
2015-08-12 2:11 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
5 siblings, 1 reply; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
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.
Acked-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Wei Huang <wei@redhat.com>
---
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(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 653c710..04636b1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -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 */
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index d83df14..061507d 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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 */
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index efdbb5d..de3cab5 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -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;
static 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)
diff --git a/include/hw/smbios/smbios.h b/include/hw/smbios/smbios.h
index 4269aab..7d999cd 100644
--- a/include/hw/smbios/smbios.h
+++ b/include/hw/smbios/smbios.h
@@ -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 */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [ARM SMBIOS V3 PATCH 5/5] smbios: implement smbios support for mach-virt
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
` (3 preceding siblings ...)
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support Wei Huang
@ 2015-08-12 2:08 ` Wei Huang
2015-08-12 2:11 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
5 siblings, 0 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:08 UTC (permalink / raw)
To: qemu-devel
Cc: wei, peter.maydell, drjones, ard.biesheuvel, ehabkost,
ivan.khoronzhuk, mst, somlo, zhaoshenglong, leif.lindholm,
roy.franz, pbonzini, imammedo, lersek, jdelvare, rth
This patch generates smbios tables for ARM mach-virt. Also add
CONFIG_SMBIOS=y for ARM default config.
Acked-by: Gabriel Somlo <somlo@cmu.edu>
Tested-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: Wei Huang <wei@redhat.com>
---
default-configs/arm-softmmu.mak | 1 +
hw/arm/virt.c | 25 +++++++++++++++++++++++++
qemu-options.hx | 2 +-
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index 74f1db3..99b41e9 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -102,3 +102,4 @@ CONFIG_XIO3130=y
CONFIG_IOH3420=y
CONFIG_I82801B11=y
CONFIG_ACPI=y
+CONFIG_SMBIOS=y
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4846892..b7c1822 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -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)
diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..efce775 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
` (4 preceding siblings ...)
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 5/5] smbios: implement smbios support for mach-virt Wei Huang
@ 2015-08-12 2:11 ` Wei Huang
5 siblings, 0 replies; 8+ messages in thread
From: Wei Huang @ 2015-08-12 2:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, drjones, ard.biesheuvel, ehabkost, ivan.khoronzhuk,
mst, somlo, zhaoshenglong, leif.lindholm, roy.franz, pbonzini,
imammedo, lersek, jdelvare, rth
On 08/11/2015 09:08 PM, Wei Huang wrote:
> 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)
* 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
>
> 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%)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support Wei Huang
@ 2015-08-12 9:12 ` Michael S. Tsirkin
0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2015-08-12 9:12 UTC (permalink / raw)
To: Wei Huang
Cc: peter.maydell, drjones, ehabkost, ivan.khoronzhuk, ard.biesheuvel,
somlo, zhaoshenglong, qemu-devel, leif.lindholm, roy.franz,
pbonzini, imammedo, lersek, jdelvare, rth
On Tue, Aug 11, 2015 at 10:08:21PM -0400, Wei Huang wrote:
> 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.
>
> Acked-by: Gabriel Somlo <somlo@cmu.edu>
> Tested-by: Gabriel Somlo <somlo@cmu.edu>
> Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
> Signed-off-by: Wei Huang <wei@redhat.com>
> ---
> 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(-)
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 653c710..04636b1 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -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 */
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index d83df14..061507d 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -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 */
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index efdbb5d..de3cab5 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -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.
>
> static 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)
> diff --git a/include/hw/smbios/smbios.h b/include/hw/smbios/smbios.h
> index 4269aab..7d999cd 100644
> --- a/include/hw/smbios/smbios.h
> +++ b/include/hw/smbios/smbios.h
> @@ -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 */
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-08-12 9:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 2:08 [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 1/5] smbios: extract x86 smbios building code into a function Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 2/5] smbios: remove dependency on x86 e820 tables Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 3/5] smbios: move smbios code into a common folder Wei Huang
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 4/5] smbios: add smbios 3.0 support Wei Huang
2015-08-12 9:12 ` Michael S. Tsirkin
2015-08-12 2:08 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 5/5] smbios: implement smbios support for mach-virt Wei Huang
2015-08-12 2:11 ` [Qemu-devel] [ARM SMBIOS V3 PATCH 0/5] SMBIOS Support for ARM Wei Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).