[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1652169227-38383-1-git-send-email-shannon.zhao@linux.alibaba.com>
Date: Tue, 10 May 2022 15:53:47 +0800
From: Shannon Zhao <shannon.zhao@...ux.alibaba.com>
To: kvm@...r.kernel.org, pbonzini@...hat.com, seanjc@...gle.com
Cc: linux-kernel@...r.kernel.org, yijunzhu@...ux.alibaba.com
Subject: [PATCH] KVM: SVM: Set HWCR[TscFreqSel] to host's value
KVM sets CPUID.80000007H:EDX[8] to 1, but not set HWCR[TscFreqSel].
This will cause guest kernel printing below log on AMD platform even
though the hardware TSC exactly counts with P0 frequency.
"[Firmware Bug]: TSC doesn't count with P0 frequency!"
Fix it by setting HWCR[TscFreqSel] to host's value to indicate whether
the TSC increments at the P0 frequency.
Signed-off-by: Shannon Zhao <shannon.zhao@...ux.alibaba.com>
---
arch/x86/kvm/svm/svm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 7e45d03..fb4bb51 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1139,6 +1139,11 @@ static void __svm_vcpu_reset(struct kvm_vcpu *vcpu)
svm_init_osvw(vcpu);
vcpu->arch.microcode_version = 0x01000065;
svm->tsc_ratio_msr = kvm_default_tsc_scaling_ratio;
+ /*
+ * TSC frequency select is HWCR[24], set it to host's value to indicate
+ * whether the TSC increments at the P0 frequency.
+ */
+ vcpu->arch.msr_hwcr = native_read_msr(MSR_K7_HWCR) & BIT_ULL(24);
if (sev_es_guest(vcpu->kvm))
sev_es_vcpu_reset(svm);
--
1.8.3.1
Powered by blists - more mailing lists