Re: WARN_ON(!svm->tsc_scaling_enabled)

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

 



On Sat, 2022-02-19 at 05:22 +0200, Dāvis Mosāns wrote:
> Hi,
> 
> I'm using:
> 
> kvm ignore_msrs=1
> kvm_amd nested=1
> 
> invtsc=on
> tsc-deadline=on
> tsc-scale=off
> svm=on
> 
> and my dmesg gets spammed with warnings like every second.
> Also sometimes guest VM freezes when booting.
> 
> 
> if (svm->tsc_ratio_msr != kvm_default_tsc_scaling_ratio) {
>     WARN_ON(!svm->tsc_scaling_enabled);
>     nested_svm_update_tsc_ratio_msr(vcpu);
> }
> 
> WARNING: CPU: 6 PID: 21336 at arch/x86/kvm/svm/nested.c:582
> nested_vmcb02_prepare_control (arch/x86/kvm/svm/nested.c:582
> (discriminator 1)) kvm_amd
> RIP: 0010:nested_vmcb02_prepare_control (arch/x86/kvm/svm/nested.c:582
> (discriminator 1)) kvm_amd
> Call Trace:
>  <TASK>
> enter_svm_guest_mode (arch/x86/kvm/svm/nested.c:480 (discriminator 3)
> arch/x86/kvm/svm/nested.c:491 (discriminator 3)
> arch/x86/kvm/svm/nested.c:647 (discriminator 3)) kvm_amd
> nested_svm_vmrun (arch/x86/kvm/svm/nested.c:726) kvm_amd
> kvm_arch_vcpu_ioctl_run (arch/x86/kvm/x86.c:10243 arch/x86/kvm/x86.c:10449) kvm
> kvm_vcpu_ioctl (arch/x86/kvm/../../../virt/kvm/kvm_main.c:3908) kvm
> __x64_sys_ioctl (fs/ioctl.c:52 fs/ioctl.c:874 fs/ioctl.c:860 fs/ioctl.c:860)
> do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
> ? kvm_on_user_return (./arch/x86/include/asm/paravirt.h:194
> ./arch/x86/include/asm/paravirt.h:227 arch/x86/kvm/x86.c:370) kvm
> ? fire_user_return_notifiers (kernel/user-return-notifier.c:42
> (discriminator 11))
> ? exit_to_user_mode_prepare (./arch/x86/include/asm/entry-common.h:53
> kernel/entry/common.c:209)
> ? syscall_exit_to_user_mode (./arch/x86/include/asm/jump_label.h:55
> ./arch/x86/include/asm/nospec-branch.h:302
> ./arch/x86/include/asm/entry-common.h:94 kernel/entry/common.c:131
> kernel/entry/common.c:302)
> ? do_syscall_64 (arch/x86/entry/common.c:87)
> 
> Maybe this warning is wrong?

The warning is not wrong. The svm->tsc_ratio_msr is the nested TSC scale ratio,
which should never have non default value if you don't exposed TSC scaling to the guest.

What I think is happening though is that svm_set_msr does allow to set MSR_AMD64_TSC_RATIO even if
the guest cpuid doesn't support TSC scaling if the write comes from the  host (that is qemu).

On qemu side I see that when guest tsc scaling is disabled, MSR_AMD64_TSC_RATIO ends up beeing
0, and still uploaded to KVM, which I think triggers this warning.

So the warning should IMHO be removed, but also the code should be changed to ignore
the value of the MSR_AMD64_TSC_RATIO when the nested tsc scaling is disabled.

I'll send a patch to fix this soon.

Best regards,
	Maxim Levitsky

> 
> Best regards,
> Dāvis
> 





[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