Sort the fw_cfg file list, add IPMI BIOS table entries
v6 cover Sort the fw_cfg file list, add IPMI BIOS table entries
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
PATCH v6 1/6 Sort the fw_cfg file list
From: Gerd Hoffmann <[email protected]>
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.
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.
--- 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(-)
hw/core/loader.c +14 -0
@@ -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;
hw/i386/pc.c +4 -0
@@ -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)
hw/i386/pc_piix.c +1 -0
@@ -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 ); }
hw/i386/pc_q35.c +1 -0
@@ -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 ); }
hw/nvram/fw_cfg.c +123 -8
174 lines not on this page · raw message
include/hw/boards.h +2 -1
@@ -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;
include/hw/loader.h +2 -0
@@ -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);
include/hw/nvram/fw_cfg.h +8 -0
@@ -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[];
tests/Makefile +1 -1
@@ -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)
vl.c +8 -2
@@ -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 ();
Signature · 1 line
2.5.0
PATCH v6 2/6 pc: Postpone SMBIOS table installation to post machine init
In reply to [email protected]From: Corey Minyard <[email protected]>
This is the same place that the ACPI SSDT table gets added, so that devices can add themselves to the SMBIOS table.
--- hw/i386/pc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/i386/pc.c +6 -5
@@ -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)
Signature · 1 line
2.5.0
PATCH v6 3/6 smbios: Move table build tools into an include file.
In reply to [email protected]From: Corey Minyard <[email protected]>
This will let things in other files (like IPMI) build SMBIOS tables.
--- 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
hw/smbios/smbios.c +6 -64
@@ -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 */
hw/smbios/smbios_build.h new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v6 4/6 ipmi: Add SMBIOS table entry
In reply to [email protected]From: Corey Minyard <[email protected]>
Add an IPMI table entry to the SMBIOS.
--- 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
default-configs/i386-softmmu.mak +1 -0
@@ -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
default-configs/x86_64-softmmu.mak +1 -0
@@ -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
hw/smbios/Makefile.objs +2 -0
@@ -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
hw/smbios/ipmi.c new file +76 -0
76 lines not on this page · raw message
hw/smbios/noipmi.c new file +14 -0
@@ -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 ) +{ +}
hw/smbios/smbios.c +2 -0
@@ -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 ();
include/hw/smbios/ipmi.h new file +15 -0
@@ -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 */
Signature · 1 line
2.5.0
PATCH v6 5/6 acpi: Add IPMI table entries
In reply to [email protected]From: Corey Minyard <[email protected]>
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.
--- 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
hw/acpi/Makefile.objs +2 -0
@@ -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
hw/acpi/ipmi.c new file +117 -0
117 lines not on this page · raw message
hw/acpi/noipmi.c new file +14 -0
@@ -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) +{ +}
hw/i386/acpi-build.c +4 -0
@@ -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,
include/hw/acpi/ipmi.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* QEMU IPMI ACPI handling +* +* Copyright (c) 2015 Corey Minyard <[email protected]> +* +* 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 */
Signature · 1 line
2.5.0
PATCH v6 6/6 bios: Add tests for the IPMI ACPI and SMBIOS entries
In reply to [email protected]From: Corey Minyard <[email protected]>
--- 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
tests/acpi-test-data/pc/DSDT.ipmikcs new file binary +0 -0
tests/acpi-test-data/q35/DSDT.ipmibt new file binary +0 -0
tests/bios-tables-test.c +54 -4
123 lines not on this page · raw message
Signature · 1 line
2.5.0
Quoted 2 lines · On Thu, Apr 07, 2016 at 09:12:57AM -0500, [email protected] wrote:
This patch set includes the
fw_configfile list sorting, which seems to have kind of stalled.
v5 is in my tree but I'll replace it with v6.
Quoted 8 lines
Changes from v5:
Added a check to rom_[re]set_order_override() functions to see if
fw_cfgis 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.