Enabling GHES support on x86 means that both PIIX4 and ICH9 PM controllers need to expose ghes state.
Implement that, as suggested by Igor. Suggested-by: Igor Mammedov <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected]/ Signed-off-by: Mauro Carvalho Chehab <[email protected]> --- hw/acpi/ich9.c | 19 +++++++++++++++++++ hw/acpi/piix4.c | 25 +++++++++++++++++++++++++ hw/isa/lpc_ich9.c | 6 ++++++ include/hw/acpi/ich9.h | 2 ++ include/hw/acpi/piix4.h | 2 ++ 5 files changed, 54 insertions(+) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 5e8f8a7eafa3..7e2199891431 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -222,6 +222,24 @@ static const VMStateDescription vmstate_pcihp_state = { } }; +static bool ich9_hest_needed(void *opaque) +{ + ICH9LPCPMRegs *pm = opaque; + + return pm->ghes_state.hest_addr_le != 0; +} + +static const VMStateDescription vmstate_ich9_hest = { + .name = "ich9_pm/hest", + .version_id = 1, + .minimum_version_id = 1, + .needed = ich9_hest_needed, + .fields = (const VMStateField[]) { + VMSTATE_UINT64(ghes_state.hest_addr_le, ICH9LPCPMRegs), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_ich9_pm = { .name = "ich9_pm", .version_id = 1, @@ -244,6 +262,7 @@ const VMStateDescription vmstate_ich9_pm = { &vmstate_tco_io_state, &vmstate_cpuhp_state, &vmstate_pcihp_state, + &vmstate_ich9_hest, NULL } }; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 9b7f50c7afac..48fa833c66ef 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -224,6 +224,24 @@ static bool vmstate_test_migrate_acpi_index(void *opaque, int version_id) !s->not_migrate_acpi_index; } +static bool piix4_hest_needed(void *opaque) +{ + PIIX4PMState *s = opaque; + + return s->ghes_state.hest_addr_le != 0; +} + +static const VMStateDescription vmstate_piix4_hest = { + .name = "piix4_pm/hest", + .version_id = 1, + .minimum_version_id = 1, + .needed = piix4_hest_needed, + .fields = (const VMStateField[]) { + VMSTATE_UINT64(ghes_state.hest_addr_le, PIIX4PMState), + VMSTATE_END_OF_LIST() + } +}; + /* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from @@ -259,6 +277,7 @@ static const VMStateDescription vmstate_acpi = { .subsections = (const VMStateDescription * const []) { &vmstate_memhp_state, &vmstate_cpuhp_state, + &vmstate_piix4_hest, NULL } }; @@ -551,6 +570,11 @@ static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list) acpi_cpu_ospm_status(&s->cpuhp_state, list); } +static AcpiGhesState *piix4_get_ghes_state(AcpiDeviceIf *adev) +{ + return &PIIX4_PM(adev)->ghes_state; +} + static void piix4_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { PIIX4PMState *s = PIIX4_PM(adev); @@ -607,6 +631,7 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data) hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus; adevc->ospm_status = piix4_ospm_status; adevc->send_event = piix4_send_gpe; + adevc->get_ghes_state = piix4_get_ghes_state; } static const TypeInfo piix4_pm_info = { diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index edf9783ec8d4..00d940f16314 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -847,6 +847,11 @@ static const Property ich9_lpc_properties[] = { pm.periodic_timer_enabled, true), }; +static AcpiGhesState *ich9_get_ghes_state(AcpiDeviceIf *adev) +{ + return &ICH9_LPC_DEVICE(adev)->pm.ghes_state; +} + static void ich9_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { ICH9LPCState *s = ICH9_LPC_DEVICE(adev); @@ -911,6 +916,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data) hc->is_hotpluggable_bus = ich9_pm_is_hotpluggable_bus; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; + adevc->get_ghes_state = ich9_get_ghes_state; amldevc->build_dev_aml = build_ich9_isa_aml; } diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 30990fcef53f..772f1a8937d7 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -27,6 +27,7 @@ #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/ich9_tco.h" +#include "hw/acpi/ghes.h" #include "hw/acpi/cpu.h" #define ACPI_PCIHP_ADDR_ICH9 0x0cc0 @@ -38,6 +39,7 @@ typedef struct ICH9LPCPMRegs { * PM1a_CNT_BLK = 2 in FADT so it is defined as uint16_t. */ ACPIREGS acpi_regs; + AcpiGhesState ghes_state; MemoryRegion io; MemoryRegion io_gpe; diff --git a/include/hw/acpi/piix4.h b/include/hw/acpi/piix4.h index 863382a814ad..8732574e9c03 100644 --- a/include/hw/acpi/piix4.h +++ b/include/hw/acpi/piix4.h @@ -29,6 +29,7 @@ #include "hw/i2c/pm_smbus.h" #include "hw/isa/apm.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/ghes.h" #define TYPE_PIIX4_PM "PIIX4_PM" OBJECT_DECLARE_SIMPLE_TYPE(PIIX4PMState, PIIX4_PM) @@ -43,6 +44,7 @@ struct PIIX4PMState { MemoryRegion io_gpe; ACPIREGS ar; + AcpiGhesState ghes_state; APMState apm; -- 2.55.0
