Received: by 10.213.65.68 with SMTP id h4csp247551imn; Fri, 23 Mar 2018 03:52:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELsdh+aR76V3M/tajeCwaxF0fGP4flZxcZ8xl9IyJEfTEIbzlFhWYmu/9y25gJ2YPlhOjmyq X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr9836972pll.292.1521802356194; Fri, 23 Mar 2018 03:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802356; cv=none; d=google.com; s=arc-20160816; b=m80CzyWeN4wZWlmU88JXfgGMXOtMr6i6hmbpqpwAVlA0swJeZIpbm/XZXg/nSXFBZf pgFRsfQXoDijYlTWVPPA8ooKvV/SOZKMioNTkUns3pHhGq2zQtFu+tzJ87tWfappzGvY gGA1YGDehFjiGbQfHx5WNaa/IQD1fx/RyeRvzQWC1X87HMa5djSwchC5foP7QKjl1swM L59cWMxwMBW8xytcB5Yk1bsj8AOzc55IXLHq27zYkiQBhvxM1rOWGAQCZMaFHsKPJwfU dd8vKxeX5M4a0DrBQ1th3UYPYOZ813VdvkAYlFtKOt/BlTjbT47YYaafa7+PQlT5kptT 8ADg== 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=0ve5/U4UWzgFo+o5KCd2YFt0RAIx7/e3frPLl+Qo1VI=; b=LbodXtan1G6Qc/LslXxsNFfh21CVe4eTCvUjjN4Y0Ae9L1FLcmanYyL54xAxzGXnCh vcO0H/BAb6OGnb+Fv5w8/8FjCHRGGtAh+wDBXCv+pOocLVxuXbfNPoYDAq2sqm3aDIRX CRT3N6iaKKi7eL09j95xL6Z2bZkcQvCF/dG22bXbhAnBAvlcRqLvMSHpWgg04fsJ1iVs gXwpuFM4JGlGtTfkMX271+9Xp5UWIaQCkFfCzBxc3g7NHieGnPtp2AJVxF6dcMbYQSml z2AfNNsDH7wFINDmGTDJagfcDlWTQpAMREEN4+tBZVR34njLLmJGd8KiUfZmYXgIeFI4 oLeQ== 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 k6-v6si8929522pln.103.2018.03.23.03.52.21; Fri, 23 Mar 2018 03:52:36 -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 S1753728AbeCWKvS (ORCPT + 99 others); Fri, 23 Mar 2018 06:51:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45194 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933172AbeCWKO0 (ORCPT ); Fri, 23 Mar 2018 06:14:26 -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 72B1A1245; Fri, 23 Mar 2018 10:14:25 +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.4 23/97] KVM: PPC: Book3S PR: Exit KVM on failed mapping Date: Fri, 23 Mar 2018 10:54:10 +0100 Message-Id: <20180323094158.925063329@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@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.4-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 = 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) &&