Re: [PATCH RFC v9 12/51] x86/fault: Report RMP page faults for kernel addresses

Dave Hansen
2023-06-12T16:30:41Z

On 6/11/23 21:25, Michael Roth wrote:
> dump_pagetable(address);
> +
> + if (error_code & X86_PF_RMP) {
> + unsigned int level;
> + pgd_t *pgd;
> + pte_t *pte;
> +
> + pgd = __va(read_cr3_pa());
> + pgd += pgd_index(address);
> + pte = lookup_address_in_pgd(pgd, address, &level);
> +
> + sev_dump_rmpentry(pte_pfn(*pte));
> + }
> }

It would be nice to trim this hunk down. Can you make it:

if (error_code & X86_PF_RMP)
sev_dump_rmpentry(address);

and hide the rest of the logic in the helper?

Oh, and lookup_address_in_pgd() can return NULL. It's not great to page
fault in the page fault handler. Could you fix that up too, please?