Re: [PATCH v19 043/130] KVM: TDX: create/free TDX vcpu structure

Isaku Yamahata
2024-03-21T20:21:50Z

On Thu, Mar 21, 2024 at 09:30:12AM +0800,
Chao Gao <chao.gao@intel.com> wrote:

> >+int tdx_vcpu_create(struct kvm_vcpu *vcpu)
> >+{
> >+ struct kvm_tdx *kvm_tdx = to_kvm_tdx(vcpu->kvm);
> >+
> >+ WARN_ON_ONCE(vcpu->arch.cpuid_entries);
> >+ WARN_ON_ONCE(vcpu->arch.cpuid_nent);
> >+
> >+ /* TDX only supports x2APIC, which requires an in-kernel local APIC. */
>
> Cannot QEMU emulate x2APIC? In my understanding, the reason is TDX module always
> enables APICv for TDs. So, KVM cannot intercept every access to APIC and forward
> them to QEMU for emulation.

You're right. Let me update it as follows.

/*
* TDX module always enables APICv for TDs. So, KVM cannot intercept every
* access to APIC and forward them to user space VMM.
*/

> >+ if (!vcpu->arch.apic)
>
> will "if (!irqchip_in_kernel(vcpu->kvm))" work? looks this is the custome for such
> a check.

It should work because kvm_arch_vcpu_create(). Will update it.
--
Isaku Yamahata <isaku.yamahata@intel.com>