Re: [PATCH v3 3/3] KVM: VMX: Drop TDX_SHARED_BIT_PWL_{4,5} and dedup related code
From: Yan Zhao
Date: Mon Sep 14 2026 - 05:08:58 EST
On Wed, Sep 02, 2026 at 04:09:32PM -0700, 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: Yan Zhao <yan.y.zhao@xxxxxxxxx>
Tested-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>