[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/14] spapr: fix core unplug crash
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 01/14] spapr: fix core unplug crash |
Date: |
Mon, 18 Jul 2016 14:38:37 +1000 |
From: Greg Kurz <address@hidden>
If the host has 8 threads/core and the guest is started with:
-smp cores=1,threads=4,maxcpus=12
It is possible to crash QEMU by doing:
(qemu) device_add host-spapr-cpu-core,core-id=16,id=foo
(qemu) device_del foo
Segmentation fault
This happens because spapr_core_unplug() assumes cpu_dt_id == core_id.
As long as cpu_dt_id is derived from the non-table cpu_index, this is
only true when you plug cores with contiguous ids.
It is safer to be consistent: the DR connector was created with an
index that is immediately written to cc->core_id, and spapr_core_plug()
also relies on cc->core_id.
Let's use it also in spapr_core_unplug().
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Bharata B Rao <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_cpu_core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 9347f07..bc52b3c 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -126,11 +126,9 @@ static void spapr_core_release(DeviceState *dev, void
*opaque)
void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
- sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
- PowerPCCPU *cpu = POWERPC_CPU(core->threads);
- int id = ppc_get_vcpu_dt_id(cpu);
+ CPUCore *cc = CPU_CORE(dev);
sPAPRDRConnector *drc =
- spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
+ spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, cc->core_id);
sPAPRDRConnectorClass *drck;
Error *local_err = NULL;
--
2.7.4
- [Qemu-devel] [PULL 00/14] ppc-for-2.7 queue 20160718, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 02/14] dbdma: always define DBDMA_DPRINTF and enable debug with DEBUG_DBDMA, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 07/14] dbdma: reset io->processing flag for unassigned DBDMA channel rw accesses, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 14/14] ppc: Yet another fix for the huge page support detection mechanism, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 06/14] dbdma: set FLUSH bit upon reception of flush command for unassigned DBDMA channels, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 03/14] dbdma: add per-channel debugging enabled via DEBUG_DBDMA_CHANMASK, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 01/14] spapr: fix core unplug crash,
David Gibson <=
- [Qemu-devel] [PULL 13/14] target-ppc: fix left shift overflow in hpte_page_shift, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 08/14] ppc: Fix support for odd MSR combinations, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 04/14] dbdma: fix endian of DBDMA_CMDPTR_LO during branch, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 11/14] ppc: abort if compat property contains an unknown value, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 05/14] dbdma: fix load_word/store_word value endianness, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 12/14] ppc/mmu-hash64: Remove duplicated #include statement, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 10/14] spapr: Ensure CPU cores are added contiguously and removed in LIFO order, David Gibson, 2016/07/18
- [Qemu-devel] [PULL 09/14] vfio/spapr: Remove stale ioctl() call, David Gibson, 2016/07/18
- Re: [Qemu-devel] [PULL 00/14] ppc-for-2.7 queue 20160718, Peter Maydell, 2016/07/18