Re: [PATCH v2 11/25] x86/sev: Adjust directmap to avoid inadvertant RMP faults

From: Borislav Petkov
Date: Fri Jan 26 2024 - 10:35:51 EST


On Thu, Jan 25, 2024 at 10:11:11PM -0600, Michael Roth wrote:
> +static int adjust_direct_map(u64 pfn, int rmp_level)
> +{
> + unsigned long vaddr = (unsigned long)pfn_to_kaddr(pfn);
> + unsigned int level;
> + int npages, ret;
> + pte_t *pte;

Again, something I asked the last time but no reply:

Looking at Documentation/arch/x86/x86_64/mm.rst, the direct map starts
at page_offset_base so this here should at least check

if (vaddr < __PAGE_OFFSET)
return 0;

I'm not sure about the upper end. Right now, the adjusting should not
happen only for the direct map but also for the whole kernel address
space range because we don't want to cause any mismatch between page
mappings anywhere.

Which means, this function should be called adjust_kernel_map() or so...

Hmmm.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette