Re: [PATCH v2] KVM: x86/mmu: Add sanity check that MMIO SPTE mask doesn't overlap gen

From: Huang, Kai
Date: Fri Aug 05 2022 - 20:50:04 EST


On Fri, 2022-08-05 at 19:41 +0000, Sean Christopherson wrote:
> Add compile-time and init-time sanity checks to ensure that the MMIO SPTE
> mask doesn't overlap the MMIO SPTE generation or the MMU-present bit.
> The generation currently avoids using bit 63, but that's as much
> coincidence as it is strictly necessarly. That will change in the future,
> as TDX support will require setting bit 63 (SUPPRESS_VE) in the mask.
>
> Explicitly carve out the bits that are allowed in the mask so that any
> future shuffling of SPTE bits doesn't silently break MMIO caching (KVM
> has broken MMIO caching more than once due to overlapping the generation
> with other things).
>
> Suggested-by: Kai Huang <kai.huang@xxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
>
> Kai, I didn't included your review since I pretty much rewrote the entire
> comment.
>
> v2: Prevent overlap with SPTE_MMU_PRESENT_MASK
> v1: https://lore.kernel.org/all/20220803213354.951376-1-seanjc@xxxxxxxxxx

Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>


--
Thanks,
-Kai