[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ys2LDaKFE9+aoZKr@kernel.org>
Date: Tue, 12 Jul 2022 17:54:05 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: "Kalra, Ashish" <Ashish.Kalra@....com>
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 09/49] x86/fault: Add support to handle the RMP
fault for user address
On Tue, Jul 12, 2022 at 02:29:18PM +0000, Kalra, Ashish wrote:
> [AMD Official Use Only - General]
>
> >> +static int handle_user_rmp_page_fault(struct pt_regs *regs, unsigned long error_code,
> >> + unsigned long address)
> >> +{
> >> + int rmp_level, level;
> >> + pte_t *pte;
> >> + u64 pfn;
> >> +
> >> + pte = lookup_address_in_mm(current->mm, address, &level);
>
> >As discussed in [1], the lookup should be done in kvm->mm, along the lines of host_pfn_mapping_level().
>
> With lookup_address_in_mm() now removed in 5.19, this is now using
> lookup_address_in_pgd() though still using non init-mm, and as mentioned
> here in [1], it makes sense to not use lookup_address_in_pgd() as it does
> not play nice with userspace mappings, e.g. doesn't disable IRQs to block
> TLB shootdowns and doesn't use READ_ONCE() to ensure an upper level entry
> isn't converted to a huge page between checking the PAGE_SIZE bit and
> grabbing the address of the next level down.
>
> But is KVM going to provide its own variant of lookup_address_in_pgd()
> that is safe for use with user addresses, i.e., a generic version of
> lookup_address() on kvm->mm or we need to duplicate page table walking
> code of host_pfn_mapping_level() ?
It's probably cpen coded for the sole reason that there is only one
call site, i.e. there has not been rational reason to have a helper
function.
Helpers are usually created only in-need basis, and since the need
comes from this patch set, it should include a patch, which simply
encapsulates it into a helper.
>
> Thanks,
> Ashish
BR, Jarkko
Powered by blists - more mailing lists