Received: by 10.213.65.68 with SMTP id h4csp236782imn; Fri, 23 Mar 2018 03:36:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELvpxwdW+yuIq/ON+uR+Zcq5sVGMgdb6FPObPofNNZ47IgrcDIDIihVF6zUCkXMio6FNceq+ X-Received: by 10.99.120.196 with SMTP id t187mr20935753pgc.149.1521801361257; Fri, 23 Mar 2018 03:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521801361; cv=none; d=google.com; s=arc-20160816; b=Ot8Gvyf6JouA/hLR5IndVAcUZ/hHPNa2g59w5Eb4elDabl810q57xZaMeMTkM3TOuA NApgG1HrcfPGrPDj97JeavVL4FeDsprMTp0xPnRb8Y8e5Ud2VVOit4LnKB+0ilSeYRuL tDGkOtRz/zT/xXambDutZix62EEGG0OrTnqCy05pk0F6ZrAzI0AekEHs6LwOhUpjWRR1 MGaJ5HBvZ5u+3TyBSbCaFWCYY++LSyNR7seKYUKC6ZMjTAWVOwC7u55JCkebrsON+olT boNou6ZCe9c1N7wxEqTw9SF4h24Af1ZCebYExRPFWQo0I5OdUnTVUoLxVhNT1pX6Okr1 efrw== 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=DQrD9TrMjtgPk9qlmvHEf4k6c66iZeJdpoA+iIEVtzM=; b=JZLThgvZMugefdCwbZPvCNayaQgmur74m111bJgLDLnPfIuzndbbJ3VnjsAVuyWENG tGIKcB4EqpvX6Z+P6Ivipl4bz3YDS7g6QiwIW3TLIMsnOsIiyDxETDkaNWaJk0lVbbA5 RGfP9zE5egUz8TdKY2zwjv6+P/cDYn7gcfKFnqltFtkVwCkT9qLedcnsnanLnIcuNKAH Zt82WBUdv5rURKgsY8LR2s4aFA9AA1aPWZ8R6ZkDRM93r6q0JAFcOtYbAEHgKZtkpNHC KWo+g2YLCLowjsvxHVPd5oMSC1ZDcjiYMHBzM9gWXRbo/kdGb3To+Q0j5vXTrRtpV0Zs yMJw== 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 w130si6463932pfd.280.2018.03.23.03.35.46; Fri, 23 Mar 2018 03:36:01 -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 S1756092AbeCWKe5 (ORCPT + 99 others); Fri, 23 Mar 2018 06:34:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47452 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933886AbeCWKSB (ORCPT ); Fri, 23 Mar 2018 06:18:01 -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 9413EF0D; Fri, 23 Mar 2018 10:18:00 +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 3.18 13/47] KVM: PPC: Book3S PR: Exit KVM on failed mapping Date: Fri, 23 Mar 2018 10:55:04 +0100 Message-Id: <20180323094248.688129346@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094248.117679641@linuxfoundation.org> References: <20180323094248.117679641@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 3.18-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 @@ -176,12 +176,15 @@ map_again: ret = ppc_md.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 @@ -625,7 +625,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) &&