[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/18] spapr_drc: Prevent detach racing against attac
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 09/18] spapr_drc: Prevent detach racing against attach for CPU DR |
Date: |
Fri, 17 Jun 2016 16:36:30 +1000 |
From: Bharata B Rao <address@hidden>
If a CPU is hot removed while hotplug of the same is still in progress,
the guest crashes. Prevent this by ensuring that detach is done only
after attach has completed.
The existing code already prevents such race for PCI hotplug. However
given that CPU is a logical DR unlike PCI and starts with ISOLATED
state, we need a logic that works for CPU too.
Signed-off-by: Bharata B Rao <address@hidden>
Reviewed-by: Michael Roth <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
[Don't set awaiting_attach for PCI devices]
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_drc.c | 12 ++++++++++++
include/hw/ppc/spapr_drc.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 94c875d..d276db3a 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -140,6 +140,8 @@ static uint32_t set_allocation_state(sPAPRDRConnector *drc,
DPRINTFN("finalizing device removal");
drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,
drc->detach_cb_opaque, NULL);
+ } else if (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
+ drc->awaiting_allocation = false;
}
}
return RTAS_OUT_SUCCESS;
@@ -373,6 +375,10 @@ static void attach(sPAPRDRConnector *drc, DeviceState *d,
void *fdt,
drc->signalled = (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI)
? true : coldplug;
+ if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {
+ drc->awaiting_allocation = true;
+ }
+
object_property_add_link(OBJECT(drc), "device",
object_get_typename(OBJECT(drc->dev)),
(Object **)(&drc->dev),
@@ -421,6 +427,12 @@ static void detach(sPAPRDRConnector *drc, DeviceState *d,
return;
}
+ if (drc->awaiting_allocation) {
+ drc->awaiting_release = true;
+ DPRINTFN("awaiting allocation to complete before removal");
+ return;
+ }
+
drc->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;
if (drc->detach_cb) {
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index fa21ba0..08e8411 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -152,6 +152,7 @@ typedef struct sPAPRDRConnector {
bool awaiting_release;
bool signalled;
+ bool awaiting_allocation;
/* device pointer, via link property */
DeviceState *dev;
--
2.5.5
- [Qemu-devel] [PULL 01/18] hw/ppc/spapr: Silence deprecation message in qtest mode, (continued)
- [Qemu-devel] [PULL 01/18] hw/ppc/spapr: Silence deprecation message in qtest mode, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 02/18] ppc / sparc: Add a tester for checking whether OpenBIOS runs successfully, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 04/18] vfio: Fix broken EEH, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 08/18] xics, xics_kvm: Handle CPU unplug correctly, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 07/18] cpu: Abstract CPU core type, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 15/18] spapr: CPU hot unplug support, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 11/18] spapr: Abstract CPU core device and type specific core devices, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 10/18] qom: API to get instance_size of a type, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 16/18] QMP: Add query-hotpluggable-cpus, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 09/18] spapr_drc: Prevent detach racing against attach for CPU DR,
David Gibson <=
- [Qemu-devel] [PULL 14/18] spapr: CPU hotplug support, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 18/18] spapr: implement query-hotpluggable-cpus callback, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 13/18] spapr: convert boot CPUs into CPU core devices, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 03/18] target-ppc: Bug in BookE wait instruction, David Gibson, 2016/06/17
- [Qemu-devel] [PULL 17/18] hmp: Add 'info hotpluggable-cpus' HMP command, David Gibson, 2016/06/17
- Re: [Qemu-devel] [PULL 00/18] ppc-for-2.7 queue 20160617, Peter Maydell, 2016/06/17