On Tue, Sep 06, 2022 at 01:25:10PM +0300, Jarkko Sakkinen wrote: > On Tue, Aug 09, 2022 at 06:55:43PM +0200, Borislav Petkov wrote: > > On Mon, Jun 20, 2022 at 11:03:43PM +0000, Ashish Kalra wrote: > > > + pfn = pte_pfn(*pte); > > > + > > > + /* If its large page then calculte the fault pfn */ > > > + if (level > PG_LEVEL_4K) { > > > + unsigned long mask; > > > + > > > + mask = pages_per_hpage(level) - pages_per_hpage(level - 1); > > > + pfn |= (address >> PAGE_SHIFT) & mask; > > > > Oh boy, this is unnecessarily complicated. Isn't this > > > > pfn |= pud_index(address); > > > > or > > pfn |= pmd_index(address); > > I played with this a bit and ended up with > > pfn = pte_pfn(*pte) | PFN_DOWN(address & page_level_mask(level - 1)); > > Unless I got something terribly wrong, this should do the > same (see the attached patch) as the existing calculations. IMHO a better name for this function would be do_user_rmp_addr_fault() as it is more consistent with the existing function names. BR, Jarkko