* [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries
@ 2016-04-07 14:12 minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 1/6] Sort the fw_cfg file list minyard
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:12 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
This patch set includes the fw_config file list sorting, which seems
to have kind of stalled.
Changes from v5:
Added a check to rom_[re]set_order_override() functions to see if fw_cfg
is set. This could cause a crash in certain circumstances.
Regenerated the BIOS test tables for other changes.
-corey
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 1/6] Sort the fw_cfg file list
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
@ 2016-04-07 14:12 ` minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 2/6] pc: Postpone SMBIOS table installation to post machine init minyard
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:12 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Gerd Hoffmann <kraxel@redhat.com>
Entries are inserted in filename order instead of being
appended to the end in case sorting is enabled.
This will avoid any future issues of moving the file creation
around, it doesn't matter what order they are created now,
the will always be in filename order.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Added machine type handling for compatibility. This was
a fairly complex change, this will preserve the order of fw_cfg
for older versions no matter what order the firmware files
actually come in. A list is kept of the correct legacy order
and the entries will be inserted based upon their order in
the list. Except that some entries are ordered (in a specific
area of the list) based upon what order they appear on the
command line. Special handling is added for those entries.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/core/loader.c | 14 +++++
hw/i386/pc.c | 4 ++
hw/i386/pc_piix.c | 1 +
hw/i386/pc_q35.c | 1 +
hw/nvram/fw_cfg.c | 131 +++++++++++++++++++++++++++++++++++++++++++---
include/hw/boards.h | 3 +-
include/hw/loader.h | 2 +
include/hw/nvram/fw_cfg.h | 8 +++
tests/Makefile | 2 +-
vl.c | 10 +++-
10 files changed, 164 insertions(+), 12 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 6b949fe..c049957 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1053,6 +1053,20 @@ void rom_set_fw(FWCfgState *f)
fw_cfg = f;
}
+void rom_set_order_override(int order)
+{
+ if (!fw_cfg)
+ return;
+ fw_cfg_set_order_override(fw_cfg, order);
+}
+
+void rom_reset_order_override(void)
+{
+ if (!fw_cfg)
+ return;
+ fw_cfg_reset_order_override(fw_cfg);
+}
+
static Rom *find_rom(hwaddr addr)
{
Rom *rom;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2ac97c4..99437e0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1406,6 +1406,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
{
DeviceState *dev = NULL;
+ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_VGA);
if (pci_bus) {
PCIDevice *pcidev = pci_vga_init(pci_bus);
dev = pcidev ? &pcidev->qdev : NULL;
@@ -1413,6 +1414,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)
ISADevice *isadev = isa_vga_init(isa_bus);
dev = isadev ? DEVICE(isadev) : NULL;
}
+ rom_reset_order_override();
return dev;
}
@@ -1541,6 +1543,7 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
{
int i;
+ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_NIC);
for (i = 0; i < nb_nics; i++) {
NICInfo *nd = &nd_table[i];
@@ -1550,6 +1553,7 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
pci_nic_init_nofail(nd, pci_bus, "e1000", NULL);
}
}
+ rom_reset_order_override();
}
void pc_pci_device_init(PCIBus *pci_bus)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 6a69b23..7f50116 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -434,6 +434,7 @@ static void pc_i440fx_2_5_machine_options(MachineClass *m)
m->alias = NULL;
m->is_default = 0;
pcmc->save_tsc_khz = false;
+ m->legacy_fw_cfg_order = 1;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_5);
}
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 9ee939b..04aae89 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -298,6 +298,7 @@ static void pc_q35_2_5_machine_options(MachineClass *m)
pc_q35_2_6_machine_options(m);
m->alias = NULL;
pcmc->save_tsc_khz = false;
+ m->legacy_fw_cfg_order = 1;
SET_MACHINE_COMPAT(m, PC_COMPAT_2_5);
}
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index d96932f..999f480 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -28,6 +28,7 @@
#include "hw/isa/isa.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/sysbus.h"
+#include "hw/boards.h"
#include "trace.h"
#include "qemu/error-report.h"
#include "qemu/config-file.h"
@@ -69,11 +70,14 @@ struct FWCfgState {
/*< public >*/
FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
+ int entry_order[FW_CFG_MAX_ENTRY];
FWCfgFiles *files;
uint16_t cur_entry;
uint32_t cur_offset;
Notifier machine_ready;
+ int fw_cfg_order_override;
+
bool dma_enabled;
dma_addr_t dma_addr;
AddressSpace *dma_as;
@@ -665,12 +669,87 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
fw_cfg_add_bytes(s, key, copy, sizeof(value));
}
+void fw_cfg_set_order_override(FWCfgState *s, int order)
+{
+ assert(s->fw_cfg_order_override == 0);
+ s->fw_cfg_order_override = order;
+}
+
+void fw_cfg_reset_order_override(FWCfgState *s)
+{
+ assert(s->fw_cfg_order_override != 0);
+ s->fw_cfg_order_override = 0;
+}
+
+/*
+ * This is the legacy order list. For legacy systems, files are in
+ * the fw_cfg in the order defined below, by the "order" value. Note
+ * that some entries (VGA ROMs, NIC option ROMS, etc.) go into a
+ * specific area, but there may be more than one and they occur in the
+ * order that the user specifies them on the command line. Those are
+ * handled in a special manner, using the order override above.
+ *
+ * For non-legacy, the files are sorted by filename to avoid this kind
+ * of complexity in the future.
+ *
+ * This is only for x86, other arches don't implement versioning so
+ * they won't set legacy mode.
+ */
+static struct {
+ const char *name;
+ int order;
+} fw_cfg_order[] = {
+ { "etc/boot-menu-wait", 10 },
+ { "bootsplash.jpg", 11 },
+ { "bootsplash.bmp", 12 },
+ { "etc/boot-fail-wait", 15 },
+ { "etc/smbios/smbios-tables", 20 },
+ { "etc/smbios/smbios-anchor", 30 },
+ { "etc/e820", 40 },
+ { "etc/reserved-memory-end", 50 },
+ { "genroms/kvmvapic.bin", 55 },
+ { "genroms/linuxboot.bin", 60 },
+ { }, /* VGA ROMs from pc_vga_init come here, 70. */
+ { }, /* NIC option ROMs from pc_nic_init come here, 80. */
+ { "etc/system-states", 90 },
+ { }, /* User ROMs come here, 100. */
+ { }, /* Device FW comes here, 110. */
+ { "etc/extra-pci-roots", 120 },
+ { "etc/acpi/tables", 130 },
+ { "etc/table-loader", 140 },
+ { "etc/tpm/log", 150 },
+ { "etc/acpi/rsdp", 160 },
+ { "bootorder", 170 },
+
+#define FW_CFG_ORDER_OVERRIDE_LAST 200
+};
+
+static int get_fw_cfg_order(FWCfgState *s, const char *name)
+{
+ int i;
+
+ if (s->fw_cfg_order_override > 0)
+ return s->fw_cfg_order_override;
+
+ for (i = 0; i < ARRAY_SIZE(fw_cfg_order); i++) {
+ if (fw_cfg_order[i].name == NULL)
+ continue;
+ if (strcmp(name, fw_cfg_order[i].name) == 0)
+ return fw_cfg_order[i].order;
+ }
+ /* Stick unknown stuff at the end. */
+ error_report("warning: Unknown firmware file in legacy mode: %s\n", name);
+ return FW_CFG_ORDER_OVERRIDE_LAST;
+}
+
void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
FWCfgReadCallback callback, void *callback_opaque,
void *data, size_t len)
{
- int i, index;
+ int i, index, count;
size_t dsize;
+ MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+ int order = 0;
if (!s->files) {
dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
@@ -678,13 +757,48 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, s->files, dsize);
}
- index = be32_to_cpu(s->files->count);
- assert(index < FW_CFG_FILE_SLOTS);
+ count = be32_to_cpu(s->files->count);
+ assert(count < FW_CFG_FILE_SLOTS);
- pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),
- filename);
- for (i = 0; i < index; i++) {
- if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
+ /* Find the insertion point. */
+ if (mc->legacy_fw_cfg_order) {
+ /*
+ * Sort by order. For files with the same order, we keep them
+ * in the sequence in which they were added.
+ */
+ order = get_fw_cfg_order(s, filename);
+ for (index = count;
+ index > 0 && order < s->entry_order[index - 1];
+ index--);
+ } else {
+ /* Sort by file name. */
+ for (index = count;
+ index > 0 && strcmp(filename, s->files->f[index - 1].name) < 0;
+ index--);
+ }
+
+ /*
+ * Move all the entries from the index point and after down one
+ * to create a slot for the new entry. Because calculations are
+ * being done with the index, make it so that "i" is the current
+ * index and "i - 1" is the one being copied from, thus the
+ * unusual start and end in the for statement.
+ */
+ for (i = count + 1; i > index; i--) {
+ s->files->f[i] = s->files->f[i - 1];
+ s->files->f[i].select = cpu_to_be16(FW_CFG_FILE_FIRST + i);
+ s->entries[0][FW_CFG_FILE_FIRST + i] =
+ s->entries[0][FW_CFG_FILE_FIRST + i - 1];
+ s->entry_order[i] = s->entry_order[i - 1];
+ }
+
+ memset(&s->files->f[index], 0, sizeof(FWCfgFile));
+ memset(&s->entries[0][FW_CFG_FILE_FIRST + index], 0, sizeof(FWCfgEntry));
+
+ pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), filename);
+ for (i = 0; i <= count; i++) {
+ if (i != index &&
+ strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
error_report("duplicate fw_cfg file name: %s",
s->files->f[index].name);
exit(1);
@@ -696,9 +810,10 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
s->files->f[index].size = cpu_to_be32(len);
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
+ s->entry_order[index] = order;
trace_fw_cfg_add_file(s, index, s->files->f[index].name, len);
- s->files->count = cpu_to_be32(index+1);
+ s->files->count = cpu_to_be32(count+1);
}
void fw_cfg_add_file(FWCfgState *s, const char *filename,
diff --git a/include/hw/boards.h b/include/hw/boards.h
index aad5f2a..8d4fe56 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -108,7 +108,8 @@ struct MachineClass {
no_cdrom:1,
no_sdcard:1,
has_dynamic_sysbus:1,
- pci_allow_0_address:1;
+ pci_allow_0_address:1,
+ legacy_fw_cfg_order:1;
int is_default;
const char *default_machine_opts;
const char *default_boot_order;
diff --git a/include/hw/loader.h b/include/hw/loader.h
index b3d1358..4879b63 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -128,6 +128,8 @@ int rom_add_elf_program(const char *name, void *data, size_t datasize,
size_t romsize, hwaddr addr);
int rom_check_and_register_reset(void);
void rom_set_fw(FWCfgState *f);
+void rom_set_order_override(int order);
+void rom_reset_order_override(void);
int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
void *rom_ptr(hwaddr addr);
void hmp_info_roms(Monitor *mon, const QDict *qdict);
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index d516989..d008112 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -11,6 +11,14 @@ typedef struct FWCfgFile {
char name[FW_CFG_MAX_FILE_PATH];
} FWCfgFile;
+#define FW_CFG_ORDER_OVERRIDE_VGA 70
+#define FW_CFG_ORDER_OVERRIDE_NIC 80
+#define FW_CFG_ORDER_OVERRIDE_USER 100
+#define FW_CFG_ORDER_OVERRIDE_DEVICE 110
+
+void fw_cfg_set_order_override(FWCfgState *fw_cfg, int order);
+void fw_cfg_reset_order_override(FWCfgState *fw_cfg);
+
typedef struct FWCfgFiles {
uint32_t count;
FWCfgFile f[];
diff --git a/tests/Makefile b/tests/Makefile
index 651d8b2..9de9598 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -83,7 +83,7 @@ check-unit-y += tests/test-crypto-cipher$(EXESUF)
check-unit-y += tests/test-crypto-secret$(EXESUF)
check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlscredsx509$(EXESUF)
check-unit-$(CONFIG_GNUTLS) += tests/test-crypto-tlssession$(EXESUF)
-check-unit-$(CONFIG_LINUX) += tests/test-qga$(EXESUF)
+#check-unit-$(CONFIG_LINUX) += tests/test-qga$(EXESUF)
check-unit-y += tests/test-timed-average$(EXESUF)
check-unit-y += tests/test-io-task$(EXESUF)
check-unit-y += tests/test-io-channel-socket$(EXESUF)
diff --git a/vl.c b/vl.c
index 3629336..9df534f 100644
--- a/vl.c
+++ b/vl.c
@@ -2297,8 +2297,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
gchar *buf;
size_t size;
const char *name, *file, *str;
+ FWCfgState *fw_cfg = (FWCfgState *) opaque;
- if (opaque == NULL) {
+ if (fw_cfg == NULL) {
error_report("fw_cfg device not available");
return -1;
}
@@ -2332,7 +2333,10 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
return -1;
}
}
- fw_cfg_add_file((FWCfgState *)opaque, name, buf, size);
+ /* For legacy, keep user files in a specific global order. */
+ fw_cfg_set_order_override(fw_cfg, FW_CFG_ORDER_OVERRIDE_USER);
+ fw_cfg_add_file(fw_cfg, name, buf, size);
+ fw_cfg_reset_order_override(fw_cfg);
return 0;
}
@@ -4535,10 +4539,12 @@ int main(int argc, char **argv, char **envp)
igd_gfx_passthru();
/* init generic devices */
+ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
if (qemu_opts_foreach(qemu_find_opts("device"),
device_init_func, NULL, NULL)) {
exit(1);
}
+ rom_reset_order_override();
/* Did we create any drives that we failed to create a device for? */
drive_check_orphaned();
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 2/6] pc: Postpone SMBIOS table installation to post machine init
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 1/6] Sort the fw_cfg file list minyard
@ 2016-04-07 14:12 ` minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 3/6] smbios: Move table build tools into an include file minyard
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:12 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
This is the same place that the ACPI SSDT table gets added, so that
devices can add themselves to the SMBIOS table.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
hw/i386/pc.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..5e78ef4 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -764,8 +764,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)
acpi_tables, acpi_tables_len);
fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
- pc_build_smbios(fw_cfg);
-
fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
&e820_reserve, sizeof(e820_reserve));
fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1161,6 +1159,7 @@ void pc_machine_done(Notifier *notifier, void *data)
{
PCMachineState *pcms = container_of(notifier,
PCMachineState, machine_done);
+ FWCfgState *fw_cfg = pcms->fw_cfg;
PCIBus *bus = pcms->bus;
if (bus) {
@@ -1172,15 +1171,17 @@ void pc_machine_done(Notifier *notifier, void *data)
extra_hosts++;
}
}
- if (extra_hosts && pcms->fw_cfg) {
+ if (extra_hosts && fw_cfg) {
uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(extra_hosts);
- fw_cfg_add_file(pcms->fw_cfg,
- "etc/extra-pci-roots", val, sizeof(*val));
+ fw_cfg_add_file(fw_cfg, "etc/extra-pci-roots", val, sizeof(*val));
}
}
acpi_setup();
+ if (fw_cfg) {
+ pc_build_smbios(fw_cfg);
+ }
}
void pc_guest_info_init(PCMachineState *pcms)
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 3/6] smbios: Move table build tools into an include file.
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 1/6] Sort the fw_cfg file list minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 2/6] pc: Postpone SMBIOS table installation to post machine init minyard
@ 2016-04-07 14:13 ` minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry minyard
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:13 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
This will let things in other files (like IPMI) build SMBIOS tables.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
hw/smbios/smbios.c | 70 ++++---------------------------------------
hw/smbios/smbios_build.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 64 deletions(-)
create mode 100644 hw/smbios/smbios_build.h
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index cb8a111..5dc3e43 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -24,6 +24,7 @@
#include "hw/smbios/smbios.h"
#include "hw/loader.h"
#include "exec/cpu-common.h"
+#include "smbios_build.h"
/* legacy structures and constants for <= 2.0 machines */
struct smbios_header {
@@ -53,10 +54,10 @@ static bool smbios_uuid_encoded = true;
/* end: legacy structures & constants for <= 2.0 machines */
-static uint8_t *smbios_tables;
-static size_t smbios_tables_len;
-static unsigned smbios_table_max;
-static unsigned smbios_table_cnt;
+uint8_t *smbios_tables;
+size_t smbios_tables_len;
+unsigned smbios_table_max;
+unsigned smbios_table_cnt;
static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_21;
static SmbiosEntryPoint ep;
@@ -429,7 +430,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)
/* end: legacy setup functions for <= 2.0 machines */
-static bool smbios_skip_table(uint8_t type, bool required_table)
+bool smbios_skip_table(uint8_t type, bool required_table)
{
if (test_bit(type, have_binfile_bitmap)) {
return true; /* user provided their own binary blob(s) */
@@ -443,65 +444,6 @@ static bool smbios_skip_table(uint8_t type, bool required_table)
return true;
}
-#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required) \
- struct smbios_type_##tbl_type *t; \
- size_t t_off; /* table offset into smbios_tables */ \
- int str_index = 0; \
- do { \
- /* should we skip building this table ? */ \
- if (smbios_skip_table(tbl_type, tbl_required)) { \
- return; \
- } \
- \
- /* use offset of table t within smbios_tables */ \
- /* (pointer must be updated after each realloc) */ \
- t_off = smbios_tables_len; \
- smbios_tables_len += sizeof(*t); \
- smbios_tables = g_realloc(smbios_tables, smbios_tables_len); \
- t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
- \
- t->header.type = tbl_type; \
- t->header.length = sizeof(*t); \
- t->header.handle = cpu_to_le16(tbl_handle); \
- } while (0)
-
-#define SMBIOS_TABLE_SET_STR(tbl_type, field, value) \
- do { \
- int len = (value != NULL) ? strlen(value) + 1 : 0; \
- if (len > 1) { \
- smbios_tables = g_realloc(smbios_tables, \
- smbios_tables_len + len); \
- memcpy(smbios_tables + smbios_tables_len, value, len); \
- smbios_tables_len += len; \
- /* update pointer post-realloc */ \
- t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
- t->field = ++str_index; \
- } else { \
- t->field = 0; \
- } \
- } while (0)
-
-#define SMBIOS_BUILD_TABLE_POST \
- do { \
- size_t term_cnt, t_size; \
- \
- /* add '\0' terminator (add two if no strings defined) */ \
- term_cnt = (str_index == 0) ? 2 : 1; \
- smbios_tables = g_realloc(smbios_tables, \
- smbios_tables_len + term_cnt); \
- memset(smbios_tables + smbios_tables_len, 0, term_cnt); \
- smbios_tables_len += term_cnt; \
- \
- /* update smbios max. element size */ \
- t_size = smbios_tables_len - t_off; \
- if (t_size > smbios_table_max) { \
- smbios_table_max = t_size; \
- } \
- \
- /* update smbios element count */ \
- smbios_table_cnt++; \
- } while (0)
-
static void smbios_build_type_0_table(void)
{
SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS */
diff --git a/hw/smbios/smbios_build.h b/hw/smbios/smbios_build.h
new file mode 100644
index 0000000..2257721
--- /dev/null
+++ b/hw/smbios/smbios_build.h
@@ -0,0 +1,77 @@
+/*
+ * SMBIOS Support
+ *
+ * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ * Copyright (C) 2013 Red Hat, Inc.
+ */
+
+#ifndef QEMU_SMBIOS_BUILD_H
+#define QEMU_SMBIOS_BUILD_H
+
+bool smbios_skip_table(uint8_t type, bool required_table);
+
+extern uint8_t *smbios_tables;
+extern size_t smbios_tables_len;
+extern unsigned smbios_table_max;
+extern unsigned smbios_table_cnt;
+
+#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required) \
+ struct smbios_type_##tbl_type *t; \
+ size_t t_off; /* table offset into smbios_tables */ \
+ int str_index = 0; \
+ do { \
+ /* should we skip building this table ? */ \
+ if (smbios_skip_table(tbl_type, tbl_required)) { \
+ return; \
+ } \
+ \
+ /* use offset of table t within smbios_tables */ \
+ /* (pointer must be updated after each realloc) */ \
+ t_off = smbios_tables_len; \
+ smbios_tables_len += sizeof(*t); \
+ smbios_tables = g_realloc(smbios_tables, smbios_tables_len); \
+ t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
+ \
+ t->header.type = tbl_type; \
+ t->header.length = sizeof(*t); \
+ t->header.handle = cpu_to_le16(tbl_handle); \
+ } while (0)
+
+#define SMBIOS_TABLE_SET_STR(tbl_type, field, value) \
+ do { \
+ int len = (value != NULL) ? strlen(value) + 1 : 0; \
+ if (len > 1) { \
+ smbios_tables = g_realloc(smbios_tables, \
+ smbios_tables_len + len); \
+ memcpy(smbios_tables + smbios_tables_len, value, len); \
+ smbios_tables_len += len; \
+ /* update pointer post-realloc */ \
+ t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
+ t->field = ++str_index; \
+ } else { \
+ t->field = 0; \
+ } \
+ } while (0)
+
+#define SMBIOS_BUILD_TABLE_POST \
+ do { \
+ size_t term_cnt, t_size; \
+ \
+ /* add '\0' terminator (add two if no strings defined) */ \
+ term_cnt = (str_index == 0) ? 2 : 1; \
+ smbios_tables = g_realloc(smbios_tables, \
+ smbios_tables_len + term_cnt); \
+ memset(smbios_tables + smbios_tables_len, 0, term_cnt); \
+ smbios_tables_len += term_cnt; \
+ \
+ /* update smbios max. element size */ \
+ t_size = smbios_tables_len - t_off; \
+ if (t_size > smbios_table_max) { \
+ smbios_table_max = t_size; \
+ } \
+ \
+ /* update smbios element count */ \
+ smbios_table_cnt++; \
+ } while (0)
+
+#endif /* QEMU_SMBIOS_BUILD_H */
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
` (2 preceding siblings ...)
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 3/6] smbios: Move table build tools into an include file minyard
@ 2016-04-07 14:13 ` minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries minyard
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:13 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
Add an IPMI table entry to the SMBIOS.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
default-configs/i386-softmmu.mak | 1 +
default-configs/x86_64-softmmu.mak | 1 +
hw/smbios/Makefile.objs | 2 +
hw/smbios/ipmi.c | 76 ++++++++++++++++++++++++++++++++++++++
hw/smbios/noipmi.c | 14 +++++++
hw/smbios/smbios.c | 2 +
include/hw/smbios/ipmi.h | 15 ++++++++
7 files changed, 111 insertions(+)
create mode 100644 hw/smbios/ipmi.c
create mode 100644 hw/smbios/noipmi.c
create mode 100644 include/hw/smbios/ipmi.h
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index b177e52..c94431d 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -20,6 +20,7 @@ CONFIG_I8254=y
CONFIG_PCSPK=y
CONFIG_PCKBD=y
CONFIG_FDC=y
+CONFIG_SMBIOS=y
CONFIG_ACPI=y
CONFIG_ACPI_X86=y
CONFIG_ACPI_X86_ICH=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 6e3b312..256294d 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -20,6 +20,7 @@ CONFIG_I8254=y
CONFIG_PCSPK=y
CONFIG_PCKBD=y
CONFIG_FDC=y
+CONFIG_SMBIOS=y
CONFIG_ACPI=y
CONFIG_ACPI_X86=y
CONFIG_ACPI_X86_ICH=y
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
index f69a92f..5578f51 100644
--- a/hw/smbios/Makefile.objs
+++ b/hw/smbios/Makefile.objs
@@ -1 +1,3 @@
common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
diff --git a/hw/smbios/ipmi.c b/hw/smbios/ipmi.c
new file mode 100644
index 0000000..b4b6151
--- /dev/null
+++ b/hw/smbios/ipmi.c
@@ -0,0 +1,76 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/smbios/ipmi.h"
+#include "hw/smbios/smbios.h"
+#include "qemu/error-report.h"
+#include "smbios_build.h"
+
+/* SMBIOS type 38 - IPMI */
+struct smbios_type_38 {
+ struct smbios_structure_header header;
+ uint8_t interface_type;
+ uint8_t ipmi_spec_revision;
+ uint8_t i2c_slave_address;
+ uint8_t nv_storage_device_address;
+ uint64_t base_address;
+ uint8_t base_address_modifier;
+ uint8_t interrupt_number;
+} QEMU_PACKED;
+
+static void ipmi_encode_one_smbios(IPMIFwInfo *info)
+{
+ uint64_t baseaddr = info->base_address;
+ SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true);
+
+ t->interface_type = info->interface_type;
+ t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4)
+ | info->ipmi_spec_minor_revision);
+ t->i2c_slave_address = info->i2c_slave_address;
+ t->nv_storage_device_address = 0;
+
+ /* or 1 to set it to I/O space */
+ switch (info->memspace) {
+ case IPMI_MEMSPACE_IO: baseaddr |= 1; break;
+ case IPMI_MEMSPACE_MEM32: break;
+ case IPMI_MEMSPACE_MEM64: break;
+ case IPMI_MEMSPACE_SMBUS: baseaddr <<= 1; break;
+ }
+
+ t->base_address = cpu_to_le64(baseaddr);
+
+ t->base_address_modifier = 0;
+ if (info->irq_type == IPMI_LEVEL_IRQ) {
+ t->base_address_modifier |= 1;
+ }
+ switch (info->register_spacing) {
+ case 1: break;
+ case 4: t->base_address_modifier |= 1 << 6; break;
+ case 16: t->base_address_modifier |= 2 << 6; break;
+ default:
+ error_report("IPMI register spacing %d is not compatible with"
+ " SMBIOS, ignoring this entry.", info->register_spacing);
+ return;
+ }
+ t->interrupt_number = info->interrupt_number;
+
+ SMBIOS_BUILD_TABLE_POST;
+}
+
+void smbios_build_type_38_table(void)
+{
+ IPMIFwInfo *info = ipmi_first_fwinfo();
+
+ while (info) {
+ ipmi_encode_one_smbios(info);
+ info = ipmi_next_fwinfo(info);
+ }
+}
diff --git a/hw/smbios/noipmi.c b/hw/smbios/noipmi.c
new file mode 100644
index 0000000..ad669a4
--- /dev/null
+++ b/hw/smbios/noipmi.c
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 5dc3e43..74c7102 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -25,6 +25,7 @@
#include "hw/loader.h"
#include "exec/cpu-common.h"
#include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
/* legacy structures and constants for <= 2.0 machines */
struct smbios_header {
@@ -848,6 +849,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
}
smbios_build_type_32_table();
+ smbios_build_type_38_table();
smbios_build_type_127_table();
smbios_validate_table();
diff --git a/include/hw/smbios/ipmi.h b/include/hw/smbios/ipmi.h
new file mode 100644
index 0000000..fd53c96
--- /dev/null
+++ b/include/hw/smbios/ipmi.h
@@ -0,0 +1,15 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_SMBIOS_IPMI_H
+#define QEMU_SMBIOS_IPMI_H
+
+void smbios_build_type_38_table(void);
+
+#endif /* QEMU_SMBIOS_IPMI_H */
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
` (3 preceding siblings ...)
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry minyard
@ 2016-04-07 14:13 ` minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 6/6] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
2016-04-07 14:18 ` [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries Michael S. Tsirkin
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:13 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
Use the new ACPI table construction tools to create an ACPI
entry for IPMI. This adds a function called from build_dsdt
to add an DSDT entry for IPMI if IPMI is compiled in and has
registered firmware. It also adds a dummy function if IPMI
is not compiled in.
This conforms to section "C3-2 Locating IPMI System Interfaces in
ACPI Name Space" in the IPMI 2.0 specification.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
hw/acpi/Makefile.objs | 2 +
hw/acpi/ipmi.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++
hw/acpi/noipmi.c | 14 ++++++
hw/i386/acpi-build.c | 4 ++
include/hw/acpi/ipmi.h | 16 +++++++
5 files changed, 153 insertions(+)
create mode 100644 hw/acpi/ipmi.c
create mode 100644 hw/acpi/noipmi.c
create mode 100644 include/hw/acpi/ipmi.h
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index faee86c..b8d5c84 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -6,3 +6,5 @@ obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
common-obj-$(CONFIG_ACPI) += acpi_interface.o
common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
common-obj-$(CONFIG_ACPI) += aml-build.o
+common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c
new file mode 100644
index 0000000..731f4ad
--- /dev/null
+++ b/hw/acpi/ipmi.c
@@ -0,0 +1,117 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/ipmi.h"
+
+static Aml *aml_ipmi_crs(IPMIFwInfo *info)
+{
+ Aml *crs = aml_resource_template();
+ uint8_t regspacing = info->register_spacing;
+
+ /*
+ * The base address is fixed and cannot change. That may be different
+ * if someone does PCI, but we aren't there yet.
+ */
+ switch (info->memspace) {
+ case IPMI_MEMSPACE_IO:
+ aml_append(crs, aml_io(AML_DECODE16, info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_MEM32:
+ aml_append(crs,
+ aml_dword_memory(AML_POS_DECODE,
+ AML_MIN_FIXED, AML_MAX_FIXED,
+ AML_NON_CACHEABLE, AML_READ_WRITE,
+ 0xffffffff,
+ info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_MEM64:
+ aml_append(crs,
+ aml_qword_memory(AML_POS_DECODE,
+ AML_MIN_FIXED, AML_MAX_FIXED,
+ AML_NON_CACHEABLE, AML_READ_WRITE,
+ 0xffffffffffffffffULL,
+ info->base_address,
+ info->base_address + info->register_length - 1,
+ regspacing, info->register_length));
+ break;
+ case IPMI_MEMSPACE_SMBUS:
+ aml_append(crs, aml_return(aml_int(info->base_address)));
+ break;
+ default:
+ abort();
+ }
+
+ if (info->interrupt_number) {
+ aml_append(crs, aml_irq_no_flags(info->interrupt_number));
+ }
+
+ return crs;
+}
+
+static void
+ipmi_encode_one_acpi(Aml *table, IPMIFwInfo *info)
+{
+ Aml *scope, *dev, *method;
+ uint16_t version = ((info->ipmi_spec_major_revision << 8)
+ | (info->ipmi_spec_minor_revision << 4));
+
+ /*
+ * The ACPI parent is a little bit of a pain. It could be in
+ * different places depending on the device. It could be an SMBus,
+ * it could be ISA, it could be PCI, etc. Only the device really
+ * knows, so it has to pass it in.
+ */
+ if (!info->acpi_parent) {
+ ipmi_debug("device %s not compatible with ACPI, no parent given.",
+ info->interface_name);
+ return;
+ }
+
+ scope = aml_scope("%s", info->acpi_parent);
+
+ dev = aml_device("MI0");
+ aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
+ aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
+ info->interface_name)));
+ aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
+ aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
+
+ /*
+ * The spec seems to require these to be methods. All the examples
+ * show them this way and it doesn't seem to work if they are not.
+ */
+ method = aml_method("_IFT", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_return(aml_int(info->interface_type)));
+ aml_append(dev, method);
+ method = aml_method("_SRV", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_return(aml_int(version)));
+ aml_append(dev, method);
+
+ aml_append(scope, dev);
+
+ aml_append(table, scope);
+}
+
+void acpi_add_ipmi(Aml *table)
+{
+ IPMIFwInfo *info = ipmi_first_fwinfo();
+
+ while (info) {
+ ipmi_encode_one_acpi(table, info);
+ info = ipmi_next_fwinfo(info);
+ }
+}
diff --git a/hw/acpi/noipmi.c b/hw/acpi/noipmi.c
new file mode 100644
index 0000000..4aae336
--- /dev/null
+++ b/hw/acpi/noipmi.c
@@ -0,0 +1,14 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/acpi/ipmi.h"
+
+void acpi_add_ipmi(Aml *ssdt)
+{
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 35180ef..17efa08 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -59,6 +59,8 @@
#include "qapi/qmp/qint.h"
#include "qom/qom-qobject.h"
+#include "hw/acpi/ipmi.h"
+
/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
* -M pc-i440fx-2.0. Even if the actual amount of AML generated grows
* a little bit, there should be plenty of free space since the DSDT
@@ -2354,6 +2356,8 @@ build_dsdt(GArray *table_data, GArray *linker,
aml_append(dsdt, sb_scope);
}
+ acpi_add_ipmi(dsdt);
+
/* copy AML table into ACPI tables blob and patch header there */
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
diff --git a/include/hw/acpi/ipmi.h b/include/hw/acpi/ipmi.h
new file mode 100644
index 0000000..313ce37
--- /dev/null
+++ b/include/hw/acpi/ipmi.h
@@ -0,0 +1,16 @@
+/*
+ * QEMU IPMI ACPI handling
+ *
+ * Copyright (c) 2015 Corey Minyard <cminyard@mvista.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_ACPI_IPMI_H
+#define HW_ACPI_IPMI_H
+
+#include "hw/acpi/aml-build.h"
+
+void acpi_add_ipmi(Aml *ssdt);
+
+#endif /* HW_ACPI_IPMI_H */
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 6/6] bios: Add tests for the IPMI ACPI and SMBIOS entries
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
` (4 preceding siblings ...)
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries minyard
@ 2016-04-07 14:13 ` minyard
2016-04-07 14:18 ` [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries Michael S. Tsirkin
6 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-04-07 14:13 UTC (permalink / raw)
To: Michael S. Tsirkin, Gerd Hoffmann, Paolo Bonzini, qemu-devel
Cc: Corey Minyard
From: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
tests/acpi-test-data/pc/DSDT.ipmikcs | Bin 0 -> 5683 bytes
tests/acpi-test-data/q35/DSDT.ipmibt | Bin 0 -> 8456 bytes
tests/bios-tables-test.c | 58 ++++++++++++++++++++++++++++++++---
3 files changed, 54 insertions(+), 4 deletions(-)
create mode 100644 tests/acpi-test-data/pc/DSDT.ipmikcs
create mode 100644 tests/acpi-test-data/q35/DSDT.ipmibt
diff --git a/tests/acpi-test-data/pc/DSDT.ipmikcs b/tests/acpi-test-data/pc/DSDT.ipmikcs
new file mode 100644
index 0000000000000000000000000000000000000000..280aeb3059eb9220108b9a2b7f0ac07819023b06
GIT binary patch
literal 5683
zcmb7IUvC@75ud#yrQ?#6j?!6{?Kmc6J8sh2<{w*j(4r7|M~Req)R{-QF3#v3B^jmL
zq&_Gy5Jd<eGpOw3EoEJ_Z?wy|0`^B}AN!b(kbZ>}jr|mL=8j9Tat?3_@OEeBw==W5
zGqZbV*hZ^32f+STUel{~wtU;t4dgKZpgy%~Ep`W-J)^whvZNGa&ckHT$46Pweqxl@
zSJ<CB-k&`0<3}EA`>^p$eX`N^KY#3P0D&HC_?%NmU2yHP>vT_9dM&58)tZqiea&UX
zEg4Nv-1VBlR8t8t6{TubS^~rngkp4~YPC#A0et;^5@OCnmFU@9m4=bEnueRz7G1kl
z0-rdZPptN*9#_47>Z_gyJui81Fo6ElSG_j;v7Lf{{U<(v0iRY}y=iAMd}=>|Ge+eQ
z1K0ue{3Y^++;zGqtlRlw;A=_-hOSuoqAmeHP?zFkFg;eYOKyn6g(cjToGx*Xqr30?
z>Jn+8kpR`pFj==M4F=ai)=Sip^)fc9e&(_)43jped$HNlQE9kjNn9-Qcb*?xVLtev
zN(;bN*fwl~G_eCt_u7rJF@npomIzj5G|^z72OcmSwFO()E=V|Er+dL%TOSRao;^BH
z;qe7f30P8=4SlqUlS7YA@%a_@t^BPFu@&}Geu)dUumtbL0^RxLx>XXJy=>HGvMTU6
zU*kE(UvP<^$NvmJ#Si!g{5w9)6~$dPDw*S4qc9x*Nk}-|pVzI{$k!NX^WoOhl6w6K
z-0lH9jg984^7IP(ME*opl!d*(pGr($GxK6m<1CCop@udjO3f?zl?=*)8mL(&HH9N;
zxHQs(I~u7+dL^MA1@)*^<uHi$E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;A#}9p-j)GnnT2%p6BcVcTMnE%B(D#Mb83CP%gbJ;*0y-N7EeWj{`Qfy*
zNT|?yOhAuCLCZqxoPf?nLWS1j0(v|Ostc|20y-ZF6<SXS=!qz(A+(+p(36o+q4ku2
zo{EB2gx0qN^sPv!(0W=xPe(zQh1RzP^zBHf(0WEd&-@TntDZ7$HCj?XwcEiLjeV+h
z_X0vi0;^d_WQh=xB_yySg_1oYNRr;|B=I}fzKvyNNJ&JEWHF?$I1FWE>*`2G#xTW)
zGP1Tfl94$~)S-;*T_f4_ZU?I?p2+()CY+%0Oh)=pjwkcJjj1E#_$Gz)p<E>zlR(I`
z0evW6A{xV4$oB&JP#(+}15?QHFxj{DF*(f|Lu@3cc^hMLnmGo`NS-BnOumFPZu>~S
zM>NW{GjxZ<kAC#^hPDvTx^*_}7+hA@;$ug0`1P<JGiww<^tIxh1mKqfyVXqJ^FO@j
n{&w>tyq?gf*ReDES?aGTCgBUL;?|b&hQKtAFRQm;kOb+!4tZ%z
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/DSDT.ipmibt b/tests/acpi-test-data/q35/DSDT.ipmibt
new file mode 100644
index 0000000000000000000000000000000000000000..6704538dee7dcfade6a1dc74eda5b8b832d7c6a2
GIT binary patch
literal 8456
zcmb7KO>Y~=8J;C6YBeOKrL>l1$BtFCNSd@xWXo~VPncYO+FWT((oO;z;7X2LxoMh(
z;s8mE0JZ|;!-oQi>Y%;RfzJ60&9TSa8la~FMGw6eMSP0-yzg+N8PWn`9d_rPeV+H7
zXFujy?x@nKblo2a;k3(ZL8G%+ekBSj=yQY+)TX`H%v=+_JC$<1@8nV$r*}8UZEVV}
z|I<qOO5OSMX8d^^-})$a))TSug?E2rJ^A3{cta5A?TtiAYIx7|JLP`wP84*yPELF&
z^V}{wx%`)u7X9T5QP3>A-ddia+x0x+Ww+mGR`R8<rR(+s)k?elQl%~2{*`9MaXVL{
zNVq|_-4cFfs=w9=GWT8=LFMH$gWBZIW^qn>z3?9^-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RIe>>L*m04kwhH4kk2C
zIyAgOMB8tkKj;4_j9v+y(F>5Ew|{V%ejKiKx|uQ1&2X)HHTfM51}de$6jm=Tr^bK|
zx`zYs%CcXN)I3)x1yOT(8MibZ=+^SG+MN-;*RL+071z{rfalIXhK?0+?fHye38SZi
zZe=E(Q^Xh4ZkX*w6}_Z(KU2Gs+LhHVP&>R&Q~9de)v#)tAC~6zQ(9dsPs%@hTo5Vz
z^rwqK8?2T+%s<RKF8UpH!M?@ehxz@uz?bg7<^`3wko3Ase<{I7_+=X5S9^PZ{f-Za
zuYOIdYC#6)Nv+?GJo?mcJn&c_?UrOtIch=5y0e&F%sN<_^Pahe*`l-3pUq|*6hix4
zf7Z>&6lOw-UZ5jX)ceJO<lgpkwU-0s9fix)@Cq)`SwfFg@g}?pCyy!@k6okd(%Zh2
zd5(U1MD1!vzXV9U`{32T5JXoN8)I|Tc+zk3-{hS|=*KHREp>mBmy5l-c@Ajuz2Nme
zSP3HBEc}Ocy0Fw0yEOIFq8%;uBItC5U+CjrbP!Z8icP;r6Ko1o?xy&V=r>)Oxo6Xk
zg9YYm2TQCx-SWg~oKO5rkz#=c)ri72*59RE=-oX<L7JwCMVd6QX;G_%7M>oA`Xm8L
z;)3Lf5053LQ=UEXG+@#Gh~i_iU8DyIn@+IkXKBVwd9{pMV$OAzm$9}=3--P3XFJO;
zsQ`DHBk*$2Ia9$5PmQy>vBHgP6s&fISI!#R)bjCKCTvnlT0edY-`eOJv<o+rH*WSf
qZs9WXe+BT{8L!m-OZ;0n>7_+jF;;+^HJogj_9b4?u8Q59Nc|sVisEVj
literal 0
HcmV?d00001
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 0a80ddf..e681ced 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -50,6 +50,8 @@ typedef struct {
GArray *tables;
uint32_t smbios_ep_addr;
struct smbios_21_entry_point smbios_ep_table;
+ uint8_t *required_struct_types;
+ int required_struct_types_len;
} test_data;
#define ACPI_READ_FIELD(field, addr) \
@@ -335,7 +337,7 @@ static void test_acpi_tables(test_data *data)
for (i = 0; i < tables_nr; i++) {
AcpiSdtTable ssdt_table;
- memset(&ssdt_table, 0 , sizeof(ssdt_table));
+ memset(&ssdt_table, 0, sizeof(ssdt_table));
uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
test_dst_table(&ssdt_table, addr);
g_array_append_val(data->tables, ssdt_table);
@@ -654,7 +656,6 @@ static void test_smbios_structs(test_data *data)
uint32_t addr = ep_table->structure_table_address;
int i, len, max_len = 0;
uint8_t type, prv, crt;
- uint8_t required_struct_types[] = {0, 1, 3, 4, 16, 17, 19, 32, 127};
/* walk the smbios tables */
for (i = 0; i < ep_table->number_of_structures; i++) {
@@ -694,8 +695,8 @@ static void test_smbios_structs(test_data *data)
g_assert_cmpuint(ep_table->max_structure_size, ==, max_len);
/* required struct types must all be present */
- for (i = 0; i < ARRAY_SIZE(required_struct_types); i++) {
- g_assert(test_bit(required_struct_types[i], struct_bitmap));
+ for (i = 0; i < data->required_struct_types_len; i++) {
+ g_assert(test_bit(data->required_struct_types[i], struct_bitmap));
}
}
@@ -735,6 +736,9 @@ static void test_acpi_one(const char *params, test_data *data)
g_free(args);
}
+static uint8_t base_required_struct_types[] =
+ {0, 1, 3, 4, 16, 17, 19, 32, 127};
+
static void test_acpi_piix4_tcg(void)
{
test_data data;
@@ -744,6 +748,8 @@ static void test_acpi_piix4_tcg(void)
*/
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-machine accel=tcg", &data);
free_test_data(&data);
}
@@ -755,6 +761,8 @@ static void test_acpi_piix4_tcg_bridge(void)
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".bridge";
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-machine accel=tcg -device pci-bridge,chassis_nr=1", &data);
free_test_data(&data);
}
@@ -765,6 +773,8 @@ static void test_acpi_q35_tcg(void)
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-machine q35,accel=tcg", &data);
free_test_data(&data);
}
@@ -776,11 +786,49 @@ static void test_acpi_q35_tcg_bridge(void)
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".bridge";
+ data.required_struct_types = base_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-machine q35,accel=tcg -device pci-bridge,chassis_nr=1",
&data);
free_test_data(&data);
}
+static uint8_t ipmi_required_struct_types[] =
+ {0, 1, 3, 4, 16, 17, 19, 32, 38, 127};
+
+static void test_acpi_q35_tcg_ipmi(void)
+{
+ test_data data;
+
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_Q35;
+ data.variant = ".ipmibt";
+ data.required_struct_types = ipmi_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
+ test_acpi_one("-machine q35,accel=tcg -device ipmi-bmc-sim,id=bmc0"
+ " -device isa-ipmi-bt,bmc=bmc0",
+ &data);
+ free_test_data(&data);
+}
+
+static void test_acpi_piix4_tcg_ipmi(void)
+{
+ test_data data;
+
+ /* Supplying -machine accel argument overrides the default (qtest).
+ * This is to make guest actually run.
+ */
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_PC;
+ data.variant = ".ipmikcs";
+ data.required_struct_types = ipmi_required_struct_types;
+ data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
+ test_acpi_one("-machine accel=tcg -device ipmi-bmc-sim,id=bmc0"
+ " -device isa-ipmi-kcs,irq=0,bmc=bmc0",
+ &data);
+ free_test_data(&data);
+}
+
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
@@ -797,6 +845,8 @@ int main(int argc, char *argv[])
qtest_add_func("acpi/piix4/tcg/bridge", test_acpi_piix4_tcg_bridge);
qtest_add_func("acpi/q35/tcg", test_acpi_q35_tcg);
qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge);
+ qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi);
+ qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
}
ret = g_test_run();
boot_sector_cleanup(disk);
--
2.5.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
` (5 preceding siblings ...)
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 6/6] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
@ 2016-04-07 14:18 ` Michael S. Tsirkin
6 siblings, 0 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2016-04-07 14:18 UTC (permalink / raw)
To: minyard; +Cc: Paolo Bonzini, Gerd Hoffmann, qemu-devel
On Thu, Apr 07, 2016 at 09:12:57AM -0500, minyard@acm.org wrote:
> This patch set includes the fw_config file list sorting, which seems
> to have kind of stalled.
v5 is in my tree but I'll replace it with v6.
> Changes from v5:
>
> Added a check to rom_[re]set_order_override() functions to see if fw_cfg
> is set. This could cause a crash in certain circumstances.
>
> Regenerated the BIOS test tables for other changes.
>
> -corey
Pls remember to repost once 2.6 is out.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry
2016-05-23 17:40 [Qemu-devel] [PATCH v6 0/6] Add IPMI to firmware tables minyard
@ 2016-05-23 17:40 ` minyard
0 siblings, 0 replies; 9+ messages in thread
From: minyard @ 2016-05-23 17:40 UTC (permalink / raw)
To: Igor Mammedov, Michael S . Tsirkin, Paolo Bonzini, qemu-devel,
minyard, cminyard
From: Corey Minyard <cminyard@mvista.com>
Add an IPMI table entry to the SMBIOS.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
---
Makefile.objs | 2 +-
hw/Makefile.objs | 2 +
hw/smbios/Makefile.objs | 1 +
hw/smbios/smbios.c | 2 +
hw/smbios/smbios_type_38.c | 114 +++++++++++++++++++++++++++++++++++++++++++++
hw/stubs/Makefile.objs | 1 +
hw/stubs/smbios_type_38.c | 14 ++++++
include/hw/smbios/ipmi.h | 15 ++++++
8 files changed, 150 insertions(+), 1 deletion(-)
create mode 100644 hw/smbios/smbios_type_38.c
create mode 100644 hw/stubs/Makefile.objs
create mode 100644 hw/stubs/smbios_type_38.c
create mode 100644 include/hw/smbios/ipmi.h
diff --git a/Makefile.objs b/Makefile.objs
index 8f705f6..fe4a47f 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -1,6 +1,6 @@
#######################################################################
# Common libraries for tools and emulators
-stub-obj-y = stubs/ crypto/
+stub-obj-y = stubs/ crypto/ hw/
util-obj-y = util/ qobject/ qapi/
util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 4a07ed4..83a979b 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -36,3 +36,5 @@ devices-dirs-$(CONFIG_SMBIOS) += smbios/
devices-dirs-y += core/
common-obj-y += $(devices-dirs-y)
obj-y += $(devices-dirs-y)
+
+stub-obj-y += stubs/
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
index f69a92f..c3d3753 100644
--- a/hw/smbios/Makefile.objs
+++ b/hw/smbios/Makefile.objs
@@ -1 +1,2 @@
common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += smbios_type_38.o
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 5dc3e43..74c7102 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -25,6 +25,7 @@
#include "hw/loader.h"
#include "exec/cpu-common.h"
#include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
/* legacy structures and constants for <= 2.0 machines */
struct smbios_header {
@@ -848,6 +849,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
}
smbios_build_type_32_table();
+ smbios_build_type_38_table();
smbios_build_type_127_table();
smbios_validate_table();
diff --git a/hw/smbios/smbios_type_38.c b/hw/smbios/smbios_type_38.c
new file mode 100644
index 0000000..e9cd824
--- /dev/null
+++ b/hw/smbios/smbios_type_38.c
@@ -0,0 +1,114 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/smbios/ipmi.h"
+#include "hw/smbios/smbios.h"
+#include "qemu/error-report.h"
+#include "smbios_build.h"
+
+/* SMBIOS type 38 - IPMI */
+struct smbios_type_38 {
+ struct smbios_structure_header header;
+ uint8_t interface_type;
+ uint8_t ipmi_spec_revision;
+ uint8_t i2c_slave_address;
+ uint8_t nv_storage_device_address;
+ uint64_t base_address;
+ uint8_t base_address_modifier;
+ uint8_t interrupt_number;
+} QEMU_PACKED;
+
+static void smbios_build_one_type_38(IPMIFwInfo *info)
+{
+ uint64_t baseaddr = info->base_address;
+ SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true);
+
+ t->interface_type = info->interface_type;
+ t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4)
+ | info->ipmi_spec_minor_revision);
+ t->i2c_slave_address = info->i2c_slave_address;
+ t->nv_storage_device_address = 0;
+
+ /* or 1 to set it to I/O space */
+ switch (info->memspace) {
+ case IPMI_MEMSPACE_IO:
+ baseaddr |= 1;
+ break;
+ case IPMI_MEMSPACE_MEM32:
+ case IPMI_MEMSPACE_MEM64:
+ break;
+ case IPMI_MEMSPACE_SMBUS:
+ baseaddr <<= 1;
+ break;
+ }
+
+ t->base_address = cpu_to_le64(baseaddr);
+
+ t->base_address_modifier = 0;
+ if (info->irq_type == IPMI_LEVEL_IRQ) {
+ t->base_address_modifier |= 1;
+ }
+ switch (info->register_spacing) {
+ case 1:
+ break;
+ case 4:
+ t->base_address_modifier |= 1 << 6;
+ break;
+ case 16:
+ t->base_address_modifier |= 2 << 6;
+ break;
+ default:
+ error_report("IPMI register spacing %d is not compatible with"
+ " SMBIOS, ignoring this entry.", info->register_spacing);
+ return;
+ }
+ t->interrupt_number = info->interrupt_number;
+
+ SMBIOS_BUILD_TABLE_POST;
+}
+
+static void smbios_add_ipmi_devices(BusState *bus)
+{
+ BusChild *kid;
+
+ QTAILQ_FOREACH(kid, &bus->children, sibling) {
+ DeviceState *dev = kid->child;
+ Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE);
+ BusState *childbus;
+
+ if (obj) {
+ IPMIInterface *ii;
+ IPMIInterfaceClass *iic;
+ IPMIFwInfo info;
+
+ ii = IPMI_INTERFACE(obj);
+ iic = IPMI_INTERFACE_GET_CLASS(obj);
+ memset(&info, 0, sizeof(info));
+ iic->get_fwinfo(ii, &info);
+ smbios_build_one_type_38(&info);
+ continue;
+ }
+
+ QLIST_FOREACH(childbus, &dev->child_bus, sibling) {
+ smbios_add_ipmi_devices(childbus);
+ }
+ }
+}
+
+void smbios_build_type_38_table(void)
+{
+ BusState *bus;
+
+ bus = sysbus_get_default();
+ if (bus) {
+ smbios_add_ipmi_devices(bus);
+ }
+}
diff --git a/hw/stubs/Makefile.objs b/hw/stubs/Makefile.objs
new file mode 100644
index 0000000..60047e6
--- /dev/null
+++ b/hw/stubs/Makefile.objs
@@ -0,0 +1 @@
+stub-obj-$(CONFIG_SMBIOS) += smbios_type_38.o
diff --git a/hw/stubs/smbios_type_38.c b/hw/stubs/smbios_type_38.c
new file mode 100644
index 0000000..ad669a4
--- /dev/null
+++ b/hw/stubs/smbios_type_38.c
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
diff --git a/include/hw/smbios/ipmi.h b/include/hw/smbios/ipmi.h
new file mode 100644
index 0000000..fd53c96
--- /dev/null
+++ b/include/hw/smbios/ipmi.h
@@ -0,0 +1,15 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QEMU_SMBIOS_IPMI_H
+#define QEMU_SMBIOS_IPMI_H
+
+void smbios_build_type_38_table(void);
+
+#endif /* QEMU_SMBIOS_IPMI_H */
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-05-23 17:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-07 14:12 [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 1/6] Sort the fw_cfg file list minyard
2016-04-07 14:12 ` [Qemu-devel] [PATCH v6 2/6] pc: Postpone SMBIOS table installation to post machine init minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 3/6] smbios: Move table build tools into an include file minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 5/6] acpi: Add IPMI table entries minyard
2016-04-07 14:13 ` [Qemu-devel] [PATCH v6 6/6] bios: Add tests for the IPMI ACPI and SMBIOS entries minyard
2016-04-07 14:18 ` [Qemu-devel] [PATCH v6 0/6] Sort the fw_cfg file list, add IPMI BIOS table entries Michael S. Tsirkin
-- strict thread matches above, loose matches on Subject: below --
2016-05-23 17:40 [Qemu-devel] [PATCH v6 0/6] Add IPMI to firmware tables minyard
2016-05-23 17:40 ` [Qemu-devel] [PATCH v6 4/6] ipmi: Add SMBIOS table entry minyard
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).