Re: [PATCH] KVM: VMX: Explicitly track TDX VMs' root level instead of guessing it from CPUID

From: Edgecombe, Rick P

Date: Wed Aug 19 2026 - 10:40:05 EST


On Tue, 2026-08-18 at 17:59 -0700, Sean Christopherson wrote:
> > Wait, no, this knowledge embeds in kvm_mmu_set_mirror_root_level() anyway.
> > So I'd think to just have the below.
>
> I started with that, but I didn't like bleeding that level of detail into the
> MMU.  Or rather, I didn't like baking in the assumption that there is exactly
> one "direct bits", that the one bit is a pivot between normal and mirror root,
> and that the pivot bit is the most significant bit of the effective GPA space.
>
> On the other hand, the MMU already knows about mirror roots, and needs to know
> that mirror roots can have predetermined levels, so explicitly storing that
> level doesn't add new assumptions.

Yea.

And with the log as is, the exact reasoning to add a mirror_root_level is not
clear. To me at least. So if we want to keep it, some extra justification would
help. But for a bug fix, I'd think to keep it simple and then do
mirror_root_level as a separate change.

>
> > If comparing gfn_direct_bits to gfn_direct_bits doesn't make sense, then
> > let's just drop the KVM_BUG_ON().
>
> Why?  Defense in depth is often useful.

It's fair. And especially TDX code is tucked away enough away that leaning
towards more checks is probably good.