Split detection of QEMU FW CFG into two phases: detection and parsing of complex structures. The qemu_cfg_preinit() function does not require malloc() to be available.
Signed-off-by: Rob Bradford robert.bradford@intel.com --- src/fw/paravirt.c | 11 +++++++++-- src/fw/paravirt.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 597bd1c..7044378 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -124,6 +124,8 @@ qemu_preinit(void) kvm_detect(); }
+ qemu_cfg_preinit(); + // On emulators, get memory size from nvram. u32 rs = ((rtc_read(CMOS_MEM_EXTMEM2_LOW) << 16) | (rtc_read(CMOS_MEM_EXTMEM2_HIGH) << 24)); @@ -571,8 +573,7 @@ struct QemuCfgFile { char name[56]; };
-void qemu_cfg_init(void) -{ +void qemu_cfg_preinit(void) { if (!runningOnQEMU()) return;
@@ -595,6 +596,12 @@ void qemu_cfg_init(void) dprintf(1, "QEMU fw_cfg DMA interface supported\n"); cfg_dma_enabled = 1; } +} + +void qemu_cfg_init(void) +{ + if (!qemu_cfg_enabled()) + return;
// Populate romfiles for legacy fw_cfg entries qemu_cfg_legacy(); diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h index a14d83e..2c4792a 100644 --- a/src/fw/paravirt.h +++ b/src/fw/paravirt.h @@ -54,6 +54,7 @@ int qemu_cfg_dma_enabled(void); void qemu_preinit(void); void qemu_platform_setup(void); void qemu_cfg_init(void); +void qemu_cfg_preinit(void);
u16 qemu_get_present_cpus_count(void); int qemu_cfg_write_file(void *src, struct romfile_s *file, u32 offset, u32 len);