From patchwork Tue Nov 3 10:08:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 539284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E5B5014030E for ; Tue, 3 Nov 2015 21:09:13 +1100 (AEDT) Received: from localhost ([::1]:46797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtYWd-0000cd-Oz for incoming@patchwork.ozlabs.org; Tue, 03 Nov 2015 05:09:11 -0500 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 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 3 Nov 2015 15:38:37 +0530 X-Helo: d28dlp02.in.ibm.com X-MailFrom: bharata@linux.vnet.ibm.com X-RcptTo: qemu-ppc@nongnu.org Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id CE7E83940061; Tue, 3 Nov 2015 15:38:36 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA3A8Rlu64553062; Tue, 3 Nov 2015 15:38:28 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA3A8PTD020687; Tue, 3 Nov 2015 15:38:26 +0530 Received: from bharata.in.ibm.com ([9.124.35.139]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tA3A8PXv020664; Tue, 3 Nov 2015 15:38:25 +0530 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Tue, 3 Nov 2015 15:38:19 +0530 Message-Id: <1446545299-19446-1-git-send-email-bharata@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15110310-0021-0000-0000-00000843A5C0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 122.248.162.6 Cc: Bharata B Rao , qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH for-2.5 1/1] spapr: Handle failure of KVM_PPC_ALLOCATE_HTAB ioctl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Michael Roth --- 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"); }