[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <76493240-46c4-61d1-8ce5-a4c5f6c1ecb8@redhat.com>
Date: Mon, 21 Feb 2022 14:22:19 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Maxim Levitsky <mlevitsk@...hat.com>, kvm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Dāvis Mosāns <davispuh@...il.com>
Subject: Re: [PATCH] KVM: nSVM: fix nested tsc scaling when not enabled but
MSR_AMD64_TSC_RATIO set
On 2/21/22 14:17, Maxim Levitsky wrote:
>> It's not clear how QEMU ends up writing MSR_AMD64_TSC_RATIO_DEFAULT
>> rather than 0, but we clearly have a bug in KVM. It should not allow
>> writing 0 in the first place if tsc-ratio is not available in the VM.
>
> Qemu currently (the code is very new so it can be changed) writes the initial value of
> 0 to this msr if tsc scaling is disabled in the guest, or MSR_AMD64_TSC_RATIO_DEFAULT
> if the tsc scaling is enabled.
It's released in 6.2, though, right?
> The guest can change it only when TSC scaling is enabled for it.
> If tsc scaling is not enabled, both guest reads or writes of this MSR get #GP.
> I only allowed qemu writes of this msr because I thought that qemu might
> first set the MSR and then set guest CPUID.
>
> Also, for example the MSR_IA32_XSS uses the same logic in KVM.
>
> As for why qemu sets this msr regardless of guest CPUID bit,
> it seemed to be cleaner this way - kvm_put_msrs in qemu seems not to
> check guest CPUID but rather only check that KVM supports this msr,
> which will be true regardless of guest's CPUID bit.
Yes, I agree it's cleaner in QEMU and consistent with others in KVM.
However the value that is written should be the default one (which is
usually zero, but not always and not in this case).
Paolo
Powered by blists - more mailing lists