[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 06/20] spapr: Don't misuse DR-indicator in spapr_recove
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 06/20] spapr: Don't misuse DR-indicator in spapr_recover_pending_dimm_state() |
Date: |
Fri, 9 Jun 2017 15:26:38 +1000 |
With some combinations of migration and hotplug we can lost temporary state
indicating how many DRCs (guest side hotplug handles) are still connected
to a DIMM object in the process of removal. When we hit that situation
spapr_recover_pending_dimm_state() is used to scan more extensively and
work out the right number.
It does this using drc->indicator state to determine what state of
disconnection the DRC is in. However, this is not safe, because the
indicator state is guest settable - in fact it's more-or-less a purely
guest->host notification mechanism which should have no bearing on the
internals of hotplug state management.
So, replace the test for this with a test on drc->dev, which is a purely
qemu side managed variable, and updated the same BQL critical section as
the indicator state.
This does introduce an off-by-one change, because the indicator state was
updated before the call to spapr_lmb_release() on the current DRC, whereas
drc->dev is updated afterwards. That's corrected by always decrementing
the nr_lmbs value instead of only doing so in the case where we didn't
have to recover information.
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Michael Roth <address@hidden>
Acked-by: Michael Roth <address@hidden>
---
hw/ppc/spapr.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 9b7ae28..b2311dc 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2676,7 +2676,7 @@ static sPAPRDIMMState
*spapr_recover_pending_dimm_state(sPAPRMachineState *ms,
drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB,
addr / SPAPR_MEMORY_BLOCK_SIZE);
g_assert(drc);
- if (drc->indicator_state != SPAPR_DR_INDICATOR_STATE_INACTIVE) {
+ if (drc->dev) {
avail_lmbs++;
}
addr += SPAPR_MEMORY_BLOCK_SIZE;
@@ -2700,10 +2700,11 @@ void spapr_lmb_release(DeviceState *dev)
* during the unplug process. In this case recover it. */
if (ds == NULL) {
ds = spapr_recover_pending_dimm_state(spapr, PC_DIMM(dev));
- if (ds->nr_lmbs) {
- return;
- }
- } else if (--ds->nr_lmbs) {
+ /* The DRC being examined by the caller at least must be counted */
+ g_assert(ds->nr_lmbs);
+ }
+
+ if (--ds->nr_lmbs) {
return;
}
--
2.9.4
- [Qemu-ppc] [PULL 00/20] ppc-for-2.10 queue 20170609, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 02/20] target/ppc: fix memory leak in kvmppc_is_mem_backend_page_size_ok(), David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 03/20] spapr: fix memory leak in spapr_memory_pre_plug(), David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 06/20] spapr: Don't misuse DR-indicator in spapr_recover_pending_dimm_state(),
David Gibson <=
- [Qemu-ppc] [PULL 10/20] spapr: Fold spapr_phb_{add, remove}_pci_device() into their only callers, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 01/20] target/ppc: pass const string to kvmppc_is_mem_backend_page_size_ok(), David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 14/20] hw/ppc/spapr: Adjust firmware name for PCI bridges, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 04/20] pseries: Correct panic behaviour for pseries machine type, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 07/20] spapr: Clean up RTAS set-indicator, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 19/20] xics: drop ICPStateClass::cpu_setup() handler, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 11/20] spapr: Rework DRC name handling, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 15/20] hw/cpu: core.c can be compiled as common object, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 08/20] spapr: Clean up handling of DR-indicator, David Gibson, 2017/06/09
- [Qemu-ppc] [PULL 09/20] spapr: Change DRC attach & detach methods to functions, David Gibson, 2017/06/09