[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SN6PR12MB27676993AE36B0A4ECB662548E869@SN6PR12MB2767.namprd12.prod.outlook.com>
Date: Tue, 12 Jul 2022 15:32:34 +0000
From: "Kalra, Ashish" <Ashish.Kalra@....com>
To: Jarkko Sakkinen <jarkko@...nel.org>
CC: "x86@...nel.org" <x86@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-coco@...ts.linux.dev" <linux-coco@...ts.linux.dev>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"jroedel@...e.de" <jroedel@...e.de>,
"Lendacky, Thomas" <Thomas.Lendacky@....com>,
"hpa@...or.com" <hpa@...or.com>,
"ardb@...nel.org" <ardb@...nel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"vkuznets@...hat.com" <vkuznets@...hat.com>,
"jmattson@...gle.com" <jmattson@...gle.com>,
"luto@...nel.org" <luto@...nel.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"slp@...hat.com" <slp@...hat.com>,
"pgonda@...gle.com" <pgonda@...gle.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"srinivas.pandruvada@...ux.intel.com"
<srinivas.pandruvada@...ux.intel.com>,
"rientjes@...gle.com" <rientjes@...gle.com>,
"dovmurik@...ux.ibm.com" <dovmurik@...ux.ibm.com>,
"tobin@....com" <tobin@....com>, "bp@...en8.de" <bp@...en8.de>,
"Roth, Michael" <Michael.Roth@....com>,
"vbabka@...e.cz" <vbabka@...e.cz>,
"kirill@...temov.name" <kirill@...temov.name>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"tony.luck@...el.com" <tony.luck@...el.com>,
"marcorr@...gle.com" <marcorr@...gle.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"alpergun@...gle.com" <alpergun@...gle.com>,
"dgilbert@...hat.com" <dgilbert@...hat.com>
Subject: RE: [PATCH Part2 v6 41/49] KVM: SVM: Add support to handle the RMP
nested page fault
[AMD Official Use Only - General]
Yes, this is fixed in 5.19 rebase.
Thanks,
Ashish
-----Original Message-----
From: Jarkko Sakkinen <jarkko@...nel.org>
Sent: Tuesday, July 12, 2022 7:49 AM
To: Kalra, Ashish <Ashish.Kalra@....com>
Cc: x86@...nel.org; linux-kernel@...r.kernel.org; kvm@...r.kernel.org; linux-coco@...ts.linux.dev; linux-mm@...ck.org; linux-crypto@...r.kernel.org; tglx@...utronix.de; mingo@...hat.com; jroedel@...e.de; Lendacky, Thomas <Thomas.Lendacky@....com>; hpa@...or.com; ardb@...nel.org; pbonzini@...hat.com; seanjc@...gle.com; vkuznets@...hat.com; jmattson@...gle.com; luto@...nel.org; dave.hansen@...ux.intel.com; slp@...hat.com; pgonda@...gle.com; peterz@...radead.org; srinivas.pandruvada@...ux.intel.com; rientjes@...gle.com; dovmurik@...ux.ibm.com; tobin@....com; bp@...en8.de; Roth, Michael <Michael.Roth@....com>; vbabka@...e.cz; kirill@...temov.name; ak@...ux.intel.com; tony.luck@...el.com; marcorr@...gle.com; sathyanarayanan.kuppuswamy@...ux.intel.com; alpergun@...gle.com; dgilbert@...hat.com
Subject: Re: [PATCH Part2 v6 41/49] KVM: SVM: Add support to handle the RMP nested page fault
On Tue, Jul 12, 2022 at 03:45:13PM +0300, Jarkko Sakkinen wrote:
> 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 <brijesh.singh@....com>
> > >
> > > 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 <brijesh.singh@....com>
> > > ---
> > > 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.
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index 0e1f4d92b89b..33267f619e61 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -164,6 +164,8 @@ static inline void kvm_mmu_load_pgd(struct kvm_vcpu *vcpu) kvm_pfn_t kvm_mmu_map_tdp_page(struct kvm_vcpu *vcpu, gpa_t gpa,
u32 error_code, int max_level);
+bool kvm_mmu_get_tdp_walk(struct kvm_vcpu *vcpu, gpa_t gpa, kvm_pfn_t *pfn, int *level):
+
/*
* Check if a given access (described through the I/D, W/R and U/S bits of a
* page fault error code pfec) causes a permission fault with the given PTE
BTW, kvm_mmu_map_tdp_page() ought to be in single line since it's less than
100 characters.
BR, Jarkko
Powered by blists - more mailing lists