Re: [PATCH 04/28] KVM: x86/mmu: shuffle high bits of SPTEs in preparation for MBEC

Sean Christopherson
2026-04-30T18:15:05Z

On Thu, Apr 30, 2026, Paolo Bonzini wrote:
> Access tracking will need to save bit 10 when MBEC is enabled.
> Right now it is simply shifting the R and X bits into bits 54 and 56,
> but bit 10 would not fit with the same scheme. Reorganize the
> high bits so that access tracking will use bits 52, 54 and 62.
> As a side effect, the free bits are compacted slightly, with
> 56-59 still unused.

> @@ -84,8 +94,8 @@ static_assert(!(SPTE_TDP_AD_MASK & SHADOW_ACC_TRACK_SAVED_MASK));
> * to not overlap the A/D type mask or the saved access bits of access-tracked
> * SPTEs when A/D bits are disabled.
> */
> -#define EPT_SPTE_HOST_WRITABLE BIT_ULL(57)
> -#define EPT_SPTE_MMU_WRITABLE BIT_ULL(58)

FWIW, I originally chose bits 57 and 58 so that HOST-writable and MMU-writable
would occupy the high byte, e.g. for faster access (in theory). But that's
uninteresting in practice because the mask is stored in a global variable, i.e.
the compiler can't optimize the SPTE access anyways.