[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 17/36] spapr_drc: don't allow 'empty' DRCs to be unisol
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 17/36] spapr_drc: don't allow 'empty' DRCs to be unisolated or allocated |
Date: |
Wed, 23 Sep 2015 11:55:19 +1000 |
From: Michael Roth <address@hidden>
Logical resources start with allocation-state:UNUSABLE /
isolation-state:ISOLATED. During hotplug, guests will transition
them to allocation-state:USABLE, and then to
isolation-state:UNISOLATED.
For cases where we cannot transition to allocation-state:USABLE,
in this case due to no device/resource being association with
the logical DRC, we should return an error -3.
For physical DRCs, we default to allocation-state:USABLE and stay
there, so in this case we should report an error -3 when the guest
attempts to make the isolation-state:ISOLATED transition for a DRC
with no device associated.
These are as documented in PAPR 2.7, 13.5.3.4.
We also ensure allocation-state:USABLE when the guest attempts
transition to isolation-state:UNISOLATED to deal with misbehaving
guests attempting to bring online an unallocated logical resource.
This is as documented in PAPR 2.7, 13.7.
Currently we implement no such error logic. Fix this by handling
these error cases as PAPR defines.
Cc: Bharata B Rao <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_drc.c | 21 +++++++++++++++++++++
include/hw/ppc/spapr.h | 1 +
2 files changed, 22 insertions(+)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 9ce844a..faf8760 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -66,6 +66,16 @@ static int set_isolation_state(sPAPRDRConnector *drc,
DPRINTFN("drc: %x, set_isolation_state: %x", get_index(drc), state);
+ if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) {
+ /* cannot unisolate a non-existant resource, and, or resources
+ * which are in an 'UNUSABLE' allocation state. (PAPR 2.7, 13.5.3.5)
+ */
+ if (!drc->dev ||
+ drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
+ return RTAS_OUT_NO_SUCH_INDICATOR;
+ }
+ }
+
drc->isolation_state = state;
if (drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) {
@@ -107,6 +117,17 @@ static int set_allocation_state(sPAPRDRConnector *drc,
DPRINTFN("drc: %x, set_allocation_state: %x", get_index(drc), state);
+ if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
+ /* if there's no resource/device associated with the DRC, there's
+ * no way for us to put it in an allocation state consistent with
+ * being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
+ * result in an RTAS return code of -3 / "no such indicator"
+ */
+ if (!drc->dev) {
+ return RTAS_OUT_NO_SUCH_INDICATOR;
+ }
+ }
+
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {
drc->allocation_state = state;
if (drc->awaiting_release &&
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index cbe3463..8a0a74d 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -409,6 +409,7 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);
#define RTAS_OUT_BUSY -2
#define RTAS_OUT_PARAM_ERROR -3
#define RTAS_OUT_NOT_SUPPORTED -3
+#define RTAS_OUT_NO_SUCH_INDICATOR -3
#define RTAS_OUT_NOT_AUTHORIZED -9002
/* RTAS tokens */
--
2.4.3
- [Qemu-ppc] [PULL 08/36] spapr_drc: Fix potential undefined behaviour, (continued)
- [Qemu-ppc] [PULL 08/36] spapr_drc: Fix potential undefined behaviour, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 27/36] spapr: Provide better error message when slots exceed max allowed, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 21/36] spapr: Use QEMU limit for maximum CPUs number, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 26/36] spapr: Don't allow memory hotplug to memory less nodes, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 35/36] sPAPR: Revert don't enable EEH on emulated PCI devices, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 19/36] spapr_drc: use RTAS return codes for methods called by RTAS, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 10/36] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 14/36] pseries: Fix incorrect calculation of threads per socket for chip-id, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 15/36] spapr: Enable in-kernel H_SET_MODE handling, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 16/36] spapr_pci: fix device tree props for MSI/MSI-X, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 17/36] spapr_drc: don't allow 'empty' DRCs to be unisolated or allocated,
David Gibson <=
- [Qemu-ppc] [PULL 22/36] spapr: Add LMB DR connectors, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 07/36] spapr: add dumpdtb support, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 33/36] ppc/spapr: Fix buffer overflow in spapr_populate_drconf_memory(), David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 30/36] spapr: Support hotplug by specifying DRC count, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 36/36] sPAPR: Enable EEH on VFIO PCI device only, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 29/36] spapr: Revert to address@hidden representation for non-hotplugged memory, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 31/36] spapr: Move memory hotplug to RTAS_LOG_V6_HP_ID_DRC_COUNT type, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 32/36] spapr: Fix default NUMA node allocation for threads, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 28/36] spapr: Populate ibm, associativity-lookup-arrays correctly for non-NUMA, David Gibson, 2015/09/22
- [Qemu-ppc] [PULL 23/36] spapr: Support ibm, dynamic-reconfiguration-memory, David Gibson, 2015/09/22