On Tue, Nov 7, 2023 at 11:29 AM Isaku Yamahata <isaku.yamahata@xxxxxxxxxxxxxxx> wrote: > > I meant bus clock frequency, not bus lock. Sorry for typo. > > On Tue, Nov 07, 2023 at 11:22:32AM -0800, > isaku.yamahata@xxxxxxxxx wrote: > > > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > > > Add KVM_CAP_X86_BUS_FREQUENCY_CONTROL capability to configure the core > > crystal clock (or processor's bus clock) for APIC timer emulation. Allow > > KVM_ENABLE_CAPABILITY(KVM_CAP_X86_BUS_FREUQNCY_CONTROL) to set the > > frequency. When using this capability, the user space VMM should configure > > CPUID[0x15] to advertise the frequency. > > > > TDX virtualizes CPUID[0x15] for the core crystal clock to be 25MHz. The > > x86 KVM hardcodes its freuqncy for APIC timer to be 1GHz. This mismatch > > causes the vAPIC timer to fire earlier than the guest expects. [1] The KVM > > APIC timer emulation uses hrtimer, whose unit is nanosecond. > > > > There are options to reconcile the mismatch. 1) Make apic bus clock frequency > > configurable (this patch). 2) TDX KVM code adjusts TMICT value. This is hacky > > and it results in losing MSB bits from 32 bit width to 30 bit width. 3). Make > > the guest kernel use tsc deadline timer instead of acpi oneshot/periodic timer. > > This is guest kernel choice. It's out of control of VMM. > > > > [1] https://lore.kernel.org/lkml/20231006011255.4163884-1-vannapurve@xxxxxxxxxx/ > > > > Isaku Yamahata (2): > > KVM: x86: Make the hardcoded APIC bus frequency vm variable > > KVM: X86: Add a capability to configure bus frequency for APIC timer I think I know the answer, but do you have any tests for this new feature?