RE: [PATCH Part2 v6 09/49] x86/fault: Add support to handle the RMP fault for user address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only - General]

So essentially we want to map the faulting address to a RMP entry, considering the fact that a 2M host hugepage can be mapped as 
4K RMP table entries and 1G host hugepage can be mapped as 2M RMP table entries.

Hence, this mask computation is done as:
mask = pages_per_hpage(level) - pages_per_hpage(level -1);

and the final faulting pfn is computed as:
pfn |= (address >> PAGE_SHIFT) & mask;
      
Thanks,
Ashish    

-----Original Message-----
From: Kalra, Ashish 
Sent: Saturday, September 3, 2022 12:51 AM
To: Borislav Petkov <bp@xxxxxxxxx>
Cc: x86@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; kvm@xxxxxxxxxxxxxxx; linux-coco@xxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx; linux-crypto@xxxxxxxxxxxxxxx; tglx@xxxxxxxxxxxxx; mingo@xxxxxxxxxx; jroedel@xxxxxxx; Lendacky, Thomas <Thomas.Lendacky@xxxxxxx>; hpa@xxxxxxxxx; ardb@xxxxxxxxxx; pbonzini@xxxxxxxxxx; seanjc@xxxxxxxxxx; vkuznets@xxxxxxxxxx; jmattson@xxxxxxxxxx; luto@xxxxxxxxxx; dave.hansen@xxxxxxxxxxxxxxx; slp@xxxxxxxxxx; pgonda@xxxxxxxxxx; peterz@xxxxxxxxxxxxx; srinivas.pandruvada@xxxxxxxxxxxxxxx; rientjes@xxxxxxxxxx; dovmurik@xxxxxxxxxxxxx; tobin@xxxxxxx; Roth, Michael <Michael.Roth@xxxxxxx>; vbabka@xxxxxxx; kirill@xxxxxxxxxxxxx; ak@xxxxxxxxxxxxxxx; tony.luck@xxxxxxxxx; marcorr@xxxxxxxxxx; sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx; alpergun@xxxxxxxxxx; dgilbert@xxxxxxxxxx; jarkko@xxxxxxxxxx
Subject: RE: [PATCH Part2 v6 09/49] x86/fault: Add support to handle the RMP fault for user address

[AMD Official Use Only - General]

Hello Boris,

>> Yes we want to map the faulting address to a RMP entry, but hugepage 
>> entries in RMP table are basically subpage 4K entries. So it is a 4K 
>> entry when the page is a 2M one and also a 4K entry when the page is 
>> a 1G one.

>Wait, what?!

>APM v2 section "15.36.11 Large Page Management" and PSMASH are then for what exactly?

This is what exactly PSMASH is for, in case the 2MB RMP entry needs to be smashed if guest PVALIDATES a 4K page, the HV will need to PSMASH the 2MB RMP entry to corresponding 4K RMP entries during #VMEXIT(NPF).

What I meant above is that 4K RMP table entries need to be available in case the 2MB RMP entry needs to be smashed. 

>> That's why the computation to get a 4K page index within a 2M/1G 
>> hugepage mapping is required.

>What if a guest RMP-faults on a 2M page and there's a corresponding 2M RMP entry? What do you need the 4K entry then for?

There is no fault here, if guest pvalidates a 2M page that is backed by a 2MB RMP entry.
We need the 4K entries in case the guest pvalidates a 4K page that is mapped by a 2MB RMP entry.

>Hell, __snp_lookup_rmpentry() even tries to return the proper page level...

>/me looks in disbelief in your direction...

Thanks,
Ashish




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux