Re: [RFC Part2 PATCH 04/30] x86/mm: split the physmap when adding the page in RMP table

From: Andy Lutomirski
Date: Mon Apr 19 2021 - 14:37:26 EST




> On Apr 19, 2021, at 11:33 AM, Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>
> On 4/19/21 11:10 AM, Andy Lutomirski wrote:
>> I’m confused by this scenario. This should only affect physical pages
>> that are in the 2M area that contains guest memory. But, if we have a
>> 2M direct map PMD entry that contains kernel data and guest private
>> memory, we’re already in a situation in which the kernel touching
>> that memory would machine check, right?
>
> Not machine check, but page fault. Do machine checks even play a
> special role in SEV-SNP? I thought that was only TDX?

Brain fart.

>
> My point was just that you can't _easily_ do the 2M->4k kernel mapping
> demotion in a page fault handler, like I think Borislav was suggesting.

We are certainly toast if this hits the stack. Or if it hits a page table or the GDT or IDT :). The latter delightful choices would be triple faults.

I sure hope the code we use to split a mapping is properly NMI safe.

>
>> ISTM we should fully unmap any guest private page from the kernel and
>> all host user pagetables before actually making it be a guest private
>> page.
>
> Yes, that sounds attractive. Then, we'd actually know if the host
> kernel was doing stray reads somehow because we'd get a fault there too.