From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtYWH-0000HW-M5 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:08:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtYWD-00067B-NF for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:08:49 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:37220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtYWC-00066Y-O5 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 05:08:45 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Nov 2015 15:38:40 +0530 From: Bharata B Rao Date: Tue, 3 Nov 2015 15:38:19 +0530 Message-Id: <1446545299-19446-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH for-2.5 1/1] spapr: Handle failure of KVM_PPC_ALLOCATE_HTAB ioctl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Bharata B Rao , qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au KVM_PPC_ALLOCATE_HTAB ioctl can return -ENOMEM for KVM guests and QEMU never handled this correctly. But this didn't cause any problems till now as KVM_PPC_ALLOCATE_HTAB ioctl returned with smaller than requested HTAB when enough contiguous memory wasn't available in the host. After the proposed kernel change: https://patchwork.ozlabs.org/patch/530501/, KVM_PPC_ALLOCATE_HTAB ioctl will not fallback to lower sized HTAB allocation and will fail if requested HTAB size can't be met. Check for such failures in QEMU and abort appropriately. This will prevent guest kernel from hanging/freezing during early boot by doing graceful exit when host is unable to allocate requested HTAB. Signed-off-by: Bharata B Rao --- hw/ppc/spapr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e1202ce..ec6e141 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1022,7 +1022,7 @@ static void spapr_alloc_htab(sPAPRMachineState *spapr) shift = kvmppc_reset_htab(spapr->htab_shift); - if (shift > 0) { + if (shift != 0) { /* Kernel handles htab, we don't need to allocate one */ if (shift != spapr->htab_shift) { error_setg(&error_abort, "Failed to allocate HTAB of requested size, try with smaller maxmem"); @@ -1055,7 +1055,7 @@ static void spapr_reset_htab(sPAPRMachineState *spapr) int index; shift = kvmppc_reset_htab(spapr->htab_shift); - if (shift > 0) { + if (shift != 0) { if (shift != spapr->htab_shift) { error_setg(&error_abort, "Requested HTAB allocation failed during reset"); } -- 2.1.0