Re: [PATCH] KVM: x86: Use current rather than snapshotted TSC frequency if it is constant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sean Christopherson <seanjc@xxxxxxxxxx> writes:

> +Vitaly
>
> On Thu, Apr 14, 2022, Anton Romanov wrote:

...

>> @@ -8646,9 +8659,12 @@ static void tsc_khz_changed(void *data)
>>  	struct cpufreq_freqs *freq = data;
>>  	unsigned long khz = 0;
>>  
>> +	if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
>> +		return;
>
> Vitaly,
>
> The Hyper-V guest code also sets cpu_tsc_khz, should we WARN if that notifier is
> invoked and Hyper-V told us there's a constant TSC?
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ab336f7c82e4..ca8e20f5ffc0 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -8701,6 +8701,8 @@ static void kvm_hyperv_tsc_notifier(void)
>         struct kvm *kvm;
>         int cpu;
>
> +       WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_CONSTANT_TSC));
> +
>         mutex_lock(&kvm_lock);
>         list_for_each_entry(kvm, &vm_list, vm_list)
>                 kvm_make_mclock_inprogress_request(kvm);
>

(apologies for the delayed reply)

No, I think Hyper-V's "Reenlightenment" feature overrides (re-defines?)
X86_FEATURE_CONSTANT_TSC. E.g. I've checked a VM on E5-2667 v4
(Broadwell) CPU with no TSC scaling. This VM has 'constant_tsc' and will
certainly get reenlightenment irq on migration.

Note, Hyper-V has its own 'Invariant TSC control', see commit
dce7cd62754b5 ("x86/hyperv: Allow guests to enable InvariantTSC"). When
enabled, X86_FEATURE_TSC_RELIABLE is forced. I *think* (haven't checked
as I don't have two suitable hosts to test migration handy) this will
suppress reenlightenment so the check should be

       WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_TSC_RELIABLE));

instead. There is a chance that reenlightenment notifications still
arrive but the reported 'new' TSC frequency remains unchanged (silly,
but possible), I'll need to check.

-- 
Vitaly




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux