Re: [PATCH v3 3/3] KVM: VMX: Drop TDX_SHARED_BIT_PWL_{4,5} and dedup related code

From: Xiaoyao Li

Date: Wed Sep 09 2026 - 13:13:41 EST


On 9/3/2026 7:09 AM, Sean Christopherson wrote:
> Fold the GPA => GFN conversion and bitshift logic for identifying the S-bit
> given the EPT root level into tdx_set_mirror_root_level() to dedup the math
> and drop TDX_SHARED_BIT_PWL_{4,5} in the process. In addition to deduping
> a small amount of code, using the level to compute the S-bit position more
> or less eliminates the risk of the mirror_root_level and gfn_direct_bits
> getting out of sync.
>
> Opportunistically switch the sanity check in tdx_load_mmu_pgd() to check
> the mirror root level, not the S-Bit location, now that it's all but
> impossible for the two things to get out of sync.
>
> For all intents and purposes, no functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Reviewed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>