Re: [PATCH v4 9/9] KVM: VMX: Consolidate the exit handler for VMX and TDX
From: Sean Christopherson
Date: Wed Aug 26 2026 - 10:00:05 EST
On Wed, Aug 26, 2026, Nikolay Borisov wrote:
>
>
> On 8/26/26 13:43, Xiaoyao Li wrote:
> > On 8/26/2026 6:03 PM, Nikolay Borisov wrote:
> > > > @@ -960,7 +978,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
> > > > .vcpu_needs_initialization =
> > > > vt_op_tdx_only(vcpu_needs_initialization),
> > > > .vcpu_run = vt_op(vcpu_run),
> > > > - .handle_exit = vt_op(handle_exit),
> > > > + .handle_exit = vt_handle_exit,
> > >
> > > nit: Why isn't this vt_op() for the sake of consistency and
> > > introduce needless churn ?
> >
> > I didn't see how to make vt_op() still work here while dedupping the
> > code. Do you have a better idea?
>
> Indeed, I saw that vt_op is actually different for the TDX/!TDX case. I
> guess that function is always bound to have some quirk - i.e it has an
> #ifdef guard inside even though is_td_vcpu() is defined for the !TDX case
> but tdx_handle_exit() isn't. It's named VT, even though it's defined in the
> "vmx section" ...
Because the name and the implementation are two separate things. The scope is
"vt_" to communicate that the operation is common to all flavors of VT, i.e. to
both VMX and TDX. But when support for TDX is disabled, there's no need to
trampoline through the routing code and so the vt_op() implementation wires the
hooks up directly to the VMX functions.
.handle_exit doesn't use vt_op() because the implementation of vt_handle_exit()
itself is completely common to VMX and TDX, i.e. there is no routing code and
thus no need to define a wrapper via vt_op().