Re: [PATCH v2 33/49] KVM: x86: Advertise TSC_DEADLINE_TIMER in KVM_GET_SUPPORTED_CPUID
From: Sean Christopherson
Date: Tue Jul 09 2024 - 15:28:19 EST
On Thu, Jul 04, 2024, Maxim Levitsky wrote:
> On Fri, 2024-05-17 at 10:39 -0700, Sean Christopherson wrote:
> > 4.47 KVM_PPC_GET_PVINFO
> > -----------------------
> > diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> > index 699ce4261e9c..d1f427284ccc 100644
> > --- a/arch/x86/kvm/cpuid.c
> > +++ b/arch/x86/kvm/cpuid.c
> > @@ -680,8 +680,8 @@ void kvm_set_cpu_caps(void)
> > F(FMA) | F(CX16) | 0 /* xTPR Update */ | F(PDCM) |
> > F(PCID) | 0 /* Reserved, DCA */ | F(XMM4_1) |
> > F(XMM4_2) | EMUL_F(X2APIC) | F(MOVBE) | F(POPCNT) |
> > - 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
> > - F(F16C) | F(RDRAND)
> > + EMUL_F(TSC_DEADLINE_TIMER) | F(AES) | F(XSAVE) |
> > + 0 /* OSXSAVE */ | F(AVX) | F(F16C) | F(RDRAND)
> > );
> >
> > kvm_cpu_cap_init(CPUID_1_EDX,
>
> Hi,
>
> I have a mixed feeling about this.
>
> First of all KVM_GET_SUPPORTED_CPUID documentation explicitly states that it
> returns bits that are supported in *default* configuration TSC_DEADLINE_TIMER
> and arguably X2APIC are only supported after enabling various caps, e.g not
> default configuration.
Another side topic, in the near future, I think we should push to make an in-kernel
local APIC a hard requirement. AFAIK, userspace local APIC gets no meaningful
test coverage, and IIRC we have known bugs where a userspace APIC doesn't work
as it should, e.g. commit 6550c4df7e50 ("KVM: nVMX: Fix interrupt window request
with "Acknowledge interrupt on exit"").
> However, since X2APIC also in KVM_GET_SUPPORTED_CPUID (also wrongly IMHO),
> for consistency it does make sense to add TSC_DEADLINE_TIMER as well.
>
> I do think that we need at least to update the documentation of KVM_GET_SUPPORTED_CPUID
> and KVM_GET_EMULATED_CPUID, as I state in a review of a later patch.
+1