From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB349C433EF for ; Tue, 12 Jul 2022 12:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 650FC940069; Tue, 12 Jul 2022 08:45:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DA96940063; Tue, 12 Jul 2022 08:45:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47933940069; Tue, 12 Jul 2022 08:45:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 31721940063 for ; Tue, 12 Jul 2022 08:45:17 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ED8E5341C0 for ; Tue, 12 Jul 2022 12:45:16 +0000 (UTC) X-FDA: 79678418232.20.A99845A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf08.hostedemail.com (Postfix) with ESMTP id 50A0E160054 for ; Tue, 12 Jul 2022 12:45:16 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DBD7BB81822; Tue, 12 Jul 2022 12:45:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CCEFC3411C; Tue, 12 Jul 2022 12:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657629913; bh=Z7uBLnz/DRYYUi1c3mBwJe1ITtYV+QlSxaED9zWUWOE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fAB4ZLQ5u9s5+ERLbLPMGHU2VPCv/X9tmI2ZMF5pMPGtJCpkUabuD/31rBOdUJUhm XLnVtEdlIl2qdb7/r2SruLu+VfXDQJb2jq8c4n9SlEnIoURhYLQ7XW5oLuezTZpGke D2rtZqDi6MoF3FioLoUpv0QzFKgBwBZl1/iHWfDPIzkhrQ/d2xhRbV0RHCfMWt965v vPBG1YoLLLkwcO0y2Pq+gNY68HnnGViNZxNQfaahVQwqA5AaQjIZ2omicoJIT9gYrt vlvu05duUtN1n4Xk5ELg9D23ih0ctC0UwV9weze5Ra8usf7NDJfaBYnVbF0tmeuynM HKeGEyhVsXFww== Date: Tue, 12 Jul 2022 15:45:10 +0300 From: Jarkko Sakkinen To: Ashish Kalra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, bp@alien8.de, michael.roth@amd.com, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, dgilbert@redhat.com Subject: Re: [PATCH Part2 v6 41/49] KVM: SVM: Add support to handle the RMP nested page fault Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fAB4ZLQ5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of jarkko@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=jarkko@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657629916; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eJypybTE1Ytd8IC8InaIekyC/yFfi+NJ+u14oUCyl+E=; b=7xHOESpzRgMK9RUt3uLsYgFcIbamG8ijHAY8z/PNhW6rjJwwbKAHlhdpFZ1vBI+JXwRWSs Xmq/EA5ZlsHE70nXQJLG7XM79aS9IC8znB5CiYTxvoYAe6pKl6mGjw8Wye3ewcU07VTwmV y1jXFppoHRGmTWtc/kpasF31nuzwwqg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657629916; a=rsa-sha256; cv=none; b=TPDpzSR5KRZKtzefMzm/ImpdrUIq7ptvk7HKn/A8TVEMz2LvfsIKoHh3NGJxZBfw1dE/1B 6U9nH/ydpOqpLIzqi6pvZH4vwtNWmZmRRSVQVQqLSCSMAeYM8+qhEc9A5q4neiN0x0/hYu F6xY3HLXUxJB+kGtWLbY2+KZABqNBRY= Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fAB4ZLQ5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of jarkko@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=jarkko@kernel.org X-Rspam-User: X-Rspamd-Server: rspam08 X-Stat-Signature: acqp7iae9z6h9pbisnum3bccsn9yhsad X-Rspamd-Queue-Id: 50A0E160054 X-HE-Tag: 1657629916-564645 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jul 12, 2022 at 03:34:00PM +0300, Jarkko Sakkinen wrote: > On Mon, Jun 20, 2022 at 11:13:03PM +0000, Ashish Kalra wrote: > > From: Brijesh Singh > > > > When SEV-SNP is enabled in the guest, the hardware places restrictions on > > all memory accesses based on the contents of the RMP table. When hardware > > encounters RMP check failure caused by the guest memory access it raises > > the #NPF. The error code contains additional information on the access > > type. See the APM volume 2 for additional information. > > > > Signed-off-by: Brijesh Singh > > --- > > arch/x86/kvm/svm/sev.c | 76 ++++++++++++++++++++++++++++++++++++++++++ > > arch/x86/kvm/svm/svm.c | 14 +++++--- > > 2 files changed, 86 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > > index 4ed90331bca0..7fc0fad87054 100644 > > --- a/arch/x86/kvm/svm/sev.c > > +++ b/arch/x86/kvm/svm/sev.c > > @@ -4009,3 +4009,79 @@ void sev_post_unmap_gfn(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn) > > > > spin_unlock(&sev->psc_lock); > > } > > + > > +void handle_rmp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code) > > +{ > > + int rmp_level, npt_level, rc, assigned; > > + struct kvm *kvm = vcpu->kvm; > > + gfn_t gfn = gpa_to_gfn(gpa); > > + bool need_psc = false; > > + enum psc_op psc_op; > > + kvm_pfn_t pfn; > > + bool private; > > + > > + write_lock(&kvm->mmu_lock); > > + > > + if (unlikely(!kvm_mmu_get_tdp_walk(vcpu, gpa, &pfn, &npt_level))) > > This function does not exist. Should it be kvm_mmu_get_tdp_page? Ugh, ignore that. This the actual issue: $ git grep kvm_mmu_get_tdp_walk arch/x86/kvm/mmu/mmu.c:bool kvm_mmu_get_tdp_walk(struct kvm_vcpu *vcpu, gpa_t gpa, kvm_pfn_t *pfn, int *level) arch/x86/kvm/mmu/mmu.c:EXPORT_SYMBOL_GPL(kvm_mmu_get_tdp_walk); arch/x86/kvm/svm/sev.c: rc = kvm_mmu_get_tdp_walk(vcpu, gpa, &pfn, &npt_level); It's not declared in any header. BR, Jarkko