@@ -149,7 +149,14 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,
#endif
fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1);
- fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg));
+#ifdef CONFIG_HPET
+ PCMachineState *pcms =
+ (PCMachineState *)object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE);
+ if (pcms && pcms->hpet_enabled) {
+ fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg));
+ }
+#endif
+
/* allocate memory for the NUMA channel: one (64bit) word for the number
* of nodes, one word for each VCPU->node and one word for each node to
* hold the amount of memory.
At present, the hpet_cfg is written unconditionally since 40ac17cd56eb ("pass info about hpets to seabios.]"), because it concerns ACPI HPET is created unconditionally. But that fact has changed since 51124bbfd2ea ("i386: acpi: Don't build HPET ACPI entry if HPET is disabled") and ACPI checks if HPET device exists in (hw/i386/acpi-build.c). Therefore, configure HPET firmware information if and only if HPET is enabled. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> --- Resend: * Resend the patch since it was missed on https://lore.kernel.org/qemu-devel/. --- hw/i386/fw_cfg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)