Received: by 10.213.65.68 with SMTP id h4csp277072imn; Fri, 23 Mar 2018 04:33:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELtg5GnmhRbHYLpFI+pCsdtH8XiT9RJewISoRdckLbVGP+jIBYUAVI5sok+59/6L5nSa72ZZ X-Received: by 10.101.98.72 with SMTP id q8mr6409225pgv.338.1521804792797; Fri, 23 Mar 2018 04:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804792; cv=none; d=google.com; s=arc-20160816; b=MxkKlRjDBPfz7zjJYSilkgLbWl0jcFWQHd7CosIfETA/ieWWa4skBbO3UNqk+/gfoe hvNUq34uNQVup+WOGnfpeFQA7QoDJ4JWFVGOo3Oi/JcZLS66nFTxOm/j7UR5KLB3/gWx q+K+B2y5WGkSaT1C8IhauFjttS/jcNahmd7/WcOvxlo6w8bhIhSFH1+taOEAYoF4Udhc oW2twHMC8/zyofm7fw4Ufw4FjvjX0nEmQk38o7jJ0VgHeyulza+NX3LnqyEdgowxM2F5 8D60GjNkNL8FrWuLMDZ9CqrOM+uxit+3NP5iBcF0eGya9sw2qaoY9FaoHJin/9dg2VOc qbZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=lwicMceTzq6ImF7nnM/3Uljsv4wS0g1TLETV2FOYEFE=; b=QRHb3a6lSYIhNMLkFFQ97yidIy/KQcwFSu0pX51LkkQ+o6tAAyR3tgo7DxrgrdPCxE 5Uzl6QVdFH9cov9zu1N/wN4kcbe+JlM9RtyKNZv2C0ErPSaspAaL0kFW/NxePCr2K6ON 37W8KS5utnheo8ibNHSiEGo50KYU0+DGFo2lwFeCY4ZCcpYsueKfmp7THa58tvysTL8Z sx7Suj9MTOPiE1cQokPfdf373pnzHpbipuTju69NE2quNUanl/Sh3NiecSdAc8wCAEWS Md5NIMqetcuspt3v8DMBcS+JINfPdpYTBF1Bq9HVNhOFNqljsbSnQxR1X0RqcXmQ1AKW /5Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a63si1853337pfc.131.2018.03.23.04.32.58; Fri, 23 Mar 2018 04:33:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755260AbeCWLb6 (ORCPT + 99 others); Fri, 23 Mar 2018 07:31:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40620 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755131AbeCWKF5 (ORCPT ); Fri, 23 Mar 2018 06:05:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 775AD29; Fri, 23 Mar 2018 10:05:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , David Gibson , Paul Mackerras , Sasha Levin Subject: [PATCH 4.9 033/177] KVM: PPC: Book3S PR: Exit KVM on failed mapping Date: Fri, 23 Mar 2018 10:52:41 +0100 Message-Id: <20180323094206.632272999@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexey Kardashevskiy [ Upstream commit bd9166ffe624000140fc6b606b256df01fc0d060 ] At the moment kvmppc_mmu_map_page() returns -1 if mmu_hash_ops.hpte_insert() fails for any reason so the page fault handler resumes the guest and it faults on the same address again. This adds distinction to kvmppc_mmu_map_page() to return -EIO if mmu_hash_ops.hpte_insert() failed for a reason other than full pteg. At the moment only pSeries_lpar_hpte_insert() returns -2 if plpar_pte_enter() failed with a code other than H_PTEG_FULL. Other mmu_hash_ops.hpte_insert() instances can only fail with -1 "full pteg". With this change, if PR KVM fails to update HPT, it can signal the userspace about this instead of returning to guest and having the very same page fault over and over again. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Signed-off-by: Paul Mackerras Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_64_mmu_host.c | 5 ++++- arch/powerpc/kvm/book3s_pr.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -177,12 +177,15 @@ map_again: ret = mmu_hash_ops.hpte_insert(hpteg, vpn, hpaddr, rflags, vflags, hpsize, hpsize, MMU_SEGSIZE_256M); - if (ret < 0) { + if (ret == -1) { /* If we couldn't map a primary PTE, try a secondary */ hash = ~hash; vflags ^= HPTE_V_SECONDARY; attempt++; goto map_again; + } else if (ret < 0) { + r = -EIO; + goto out_unlock; } else { trace_kvm_book3s_64_mmu_map(rflags, hpteg, vpn, hpaddr, orig_pte); --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -627,7 +627,11 @@ int kvmppc_handle_pagefault(struct kvm_r kvmppc_mmu_unmap_page(vcpu, &pte); } /* The guest's PTE is not mapped yet. Map on the host */ - kvmppc_mmu_map_page(vcpu, &pte, iswrite); + if (kvmppc_mmu_map_page(vcpu, &pte, iswrite) == -EIO) { + /* Exit KVM if mapping failed */ + run->exit_reason = KVM_EXIT_INTERNAL_ERROR; + return RESUME_HOST; + } if (data) vcpu->stat.sp_storage++; else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&