Re: [PATCHv3 0/3] x86/tdx: Fix one more load_unaligned_zeropad() issue

From: Dave Hansen
Date: Thu Jul 06 2023 - 13:45:39 EST


On 7/6/23 09:48, Michael Kelley (LINUX) wrote:
> When a page is transitioning, the caller can and should ensure
> that it is not being accessed during the transition. But we have
> the load_unaligned_zeropad() wildcard. So do the following for
> the transition sequence in __set_memory_enc_pgtable():
>
> 1. Remove aliasing mappings
> 2. Remove the PRESENT bit from the PTEs of all transitioning pages
> 3. Flush the TLB globally
> 4. Flush the data cache if needed
> 5. Set/clear the encryption attribute as appropriate
> 6. Notify the hypervisor of the page status change
> 7. Add back the PRESENT bit
>
> With this approach, load_unaligned_zeropad() just takes the
> normal page-fault-based fixup path if it touches a page that is
> transitioning.

Yes, this does seem much simpler. It funnels everything through the
page fault handler and also doesn't require because careful about the
ordering of the private<=>shared conversions.