From 9040e6dfa8c3fed87695a3de555d2c775727bb51 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Fri, 1 Mar 2019 11:35:48 +0800 Subject: i386, acpi: check acpi_memory_hotplug capacity in pre_plug Currently we do device realization like below: hotplug_handler_pre_plug() dc->realize() hotplug_handler_plug() Before we do device realization and plug, we should allocate necessary resources and check if memory-hotplug-support property is enabled. At the piix4 and ich9, the memory-hotplug-support property is checked at plug stage. This means that device has been realized and mapped into guest address space 'pc_dimm_plug()' by the time acpi plug handler is called, where it might fail and crash QEMU due to reaching g_assert_not_reached() (piix4) or error_abort (ich9). Fix it by checking if memory hotplug is enabled at pre_plug stage where we can gracefully abort hotplug request. Signed-off-by: Wei Yang CC: Igor Mammedov CC: Eric Blake Signed-off-by: Wei Yang Message-Id: <20190301033548.6691-1-richardw.yang@linux.intel.com> Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/i386') diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 1cdaff5..6077d27 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2090,6 +2090,8 @@ static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, return; } + hotplug_handler_pre_plug(pcms->acpi_dev, dev, errp); + if (is_nvdimm && !ms->nvdimms_state->is_enabled) { error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"); return; -- cgit v1.1