* [Qemu-devel] [FIX v1 PATCH] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add
@ 2015-08-31 5:38 Bharata B Rao
2015-08-31 23:55 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Bharata B Rao @ 2015-08-31 5:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Bharata B Rao, qemu-ppc, Michael Roth, david
If drmgr is used in the guest to hotplug a device before a device_add
has been issued via the QEMU monitor, QEMU segfaults in configure_connector
call. This occurs due to accessing of NULL FDT which otherwise would have
been created and associated with the DRC during device_add command.
Check for NULL FDT and return failure from configure_connector call.
As per PAPR+, an error value of -9003 seems appropriate for this failure.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
---
Changes in v1:
- Use error value of -9003 instead of RTAS_OUT_HW_ERROR.
v0: http://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03026.html
hw/ppc/spapr_rtas.c | 6 ++++++
include/hw/ppc/spapr_drc.h | 15 ++++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index e99e25f..3b7b20b 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -522,6 +522,12 @@ static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
fdt = drck->get_fdt(drc, NULL);
+ if (!fdt) {
+ DPRINTF("rtas_ibm_configure_connector: Missing FDT for DRC index: %xh\n",
+ drc_index);
+ rc = SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE;
+ goto out;
+ }
ccs = spapr_ccs_find(spapr, drc_index);
if (!ccs) {
diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h
index 60cda35..28ffeae 100644
--- a/include/hw/ppc/spapr_drc.h
+++ b/include/hw/ppc/spapr_drc.h
@@ -119,13 +119,14 @@ typedef enum {
} sPAPRDREntitySense;
typedef enum {
- SPAPR_DR_CC_RESPONSE_NEXT_SIB = 1, /* currently unused */
- SPAPR_DR_CC_RESPONSE_NEXT_CHILD = 2,
- SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY = 3,
- SPAPR_DR_CC_RESPONSE_PREV_PARENT = 4,
- SPAPR_DR_CC_RESPONSE_SUCCESS = 0,
- SPAPR_DR_CC_RESPONSE_ERROR = -1,
- SPAPR_DR_CC_RESPONSE_CONTINUE = -2,
+ SPAPR_DR_CC_RESPONSE_NEXT_SIB = 1, /* currently unused */
+ SPAPR_DR_CC_RESPONSE_NEXT_CHILD = 2,
+ SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY = 3,
+ SPAPR_DR_CC_RESPONSE_PREV_PARENT = 4,
+ SPAPR_DR_CC_RESPONSE_SUCCESS = 0,
+ SPAPR_DR_CC_RESPONSE_ERROR = -1,
+ SPAPR_DR_CC_RESPONSE_CONTINUE = -2,
+ SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE = -9003,
} sPAPRDRCCResponse;
typedef void (spapr_drc_detach_cb)(DeviceState *d, void *opaque);
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [FIX v1 PATCH] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add
2015-08-31 5:38 [Qemu-devel] [FIX v1 PATCH] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add Bharata B Rao
@ 2015-08-31 23:55 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2015-08-31 23:55 UTC (permalink / raw)
To: Bharata B Rao; +Cc: qemu-ppc, qemu-devel, Michael Roth
[-- Attachment #1: Type: text/plain, Size: 860 bytes --]
On Mon, Aug 31, 2015 at 11:08:13AM +0530, Bharata B Rao wrote:
> If drmgr is used in the guest to hotplug a device before a device_add
> has been issued via the QEMU monitor, QEMU segfaults in configure_connector
> call. This occurs due to accessing of NULL FDT which otherwise would have
> been created and associated with the DRC during device_add command.
>
> Check for NULL FDT and return failure from configure_connector call.
> As per PAPR+, an error value of -9003 seems appropriate for this failure.
>
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Applied to spapr-next, thanks.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-01 0:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 5:38 [Qemu-devel] [FIX v1 PATCH] spapr_rtas: Prevent QEMU crash during hotplug without a prior device_add Bharata B Rao
2015-08-31 23:55 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).