On 03/07/21 00:04, isaku.yamahata@xxxxxxxxx wrote:
Let userspace, or in the case of TDX, KVM itself, enable X2APIC even if X2APIC is not reported as supported in the guest's CPU model. KVM generally does not force specific ordering between ioctls(), e.g. this forces userspace to configure CPUID before MSRs.
You already have to do this, see for example MSR_IA32_PERF_CAPABILITIES: struct kvm_msr_entry msr_ent = {.index = msr, .data = 0}; if (!msr_info->host_initiated) return 1; if (guest_cpuid_has(vcpu, X86_FEATURE_PDCM) && kvm_get_msr_feature(&msr_ent)) return 1; if (data & ~msr_ent.data) return 1; Is this patch necessary? If not, I think it can be dropped. Paolo
And for TDX, vCPUs will always run with X2APIC enabled, e.g. KVM will want/need to enable X2APIC from time zero.