|
|
8b1478 |
From 38633bfc500ac284a13f7da53ea5aabacb8006e1 Mon Sep 17 00:00:00 2001
|
|
|
8b1478 |
From: "plai@redhat.com" <plai@redhat.com>
|
|
|
8b1478 |
Date: Tue, 4 Jun 2019 21:47:26 +0200
|
|
|
8b1478 |
Subject: [PATCH 07/23] i386: kvm: Disable arch_capabilities if MSR can't be
|
|
|
8b1478 |
set
|
|
|
8b1478 |
|
|
|
8b1478 |
RH-Author: plai@redhat.com
|
|
|
8b1478 |
Message-id: <1559684847-10889-8-git-send-email-plai@redhat.com>
|
|
|
8b1478 |
Patchwork-id: 88536
|
|
|
8b1478 |
O-Subject: [RHEL7.7 qemu-kvm-rhev PATCH v4 7/8] i386: kvm: Disable arch_capabilities if MSR can't be set
|
|
|
8b1478 |
Bugzilla: 1709972
|
|
|
8b1478 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
8b1478 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
8b1478 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
8b1478 |
|
|
|
8b1478 |
From: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
8b1478 |
|
|
|
8b1478 |
KVM has two bugs in the handling of MSR_IA32_ARCH_CAPABILITIES:
|
|
|
8b1478 |
|
|
|
8b1478 |
1) Linux commit commit 1eaafe91a0df ("kvm: x86: IA32_ARCH_CAPABILITIES
|
|
|
8b1478 |
is always supported") makes GET_SUPPORTED_CPUID return
|
|
|
8b1478 |
arch_capabilities even if running on SVM. This makes "-cpu
|
|
|
8b1478 |
host,migratable=off" incorrectly expose arch_capabilities on CPUID on
|
|
|
8b1478 |
AMD hosts (where the MSR is not emulated by KVM).
|
|
|
8b1478 |
|
|
|
8b1478 |
2) KVM_GET_MSR_INDEX_LIST does not return MSR_IA32_ARCH_CAPABILITIES if
|
|
|
8b1478 |
the MSR is not supported by the host CPU. This makes QEMU not
|
|
|
8b1478 |
initialize the MSR properly at kvm_put_msrs() on those hosts.
|
|
|
8b1478 |
|
|
|
8b1478 |
Work around both bugs on the QEMU side, by checking if the MSR
|
|
|
8b1478 |
was returned by KVM_GET_MSR_INDEX_LIST before returning the
|
|
|
8b1478 |
feature flag on kvm_arch_get_supported_cpuid().
|
|
|
8b1478 |
|
|
|
8b1478 |
This has the unfortunate side effect of making arch_capabilities
|
|
|
8b1478 |
unavailable on hosts without hardware support for the MSR until bug #2
|
|
|
8b1478 |
is fixed on KVM, but I can't see another way to work around bug #1
|
|
|
8b1478 |
without that side effect.
|
|
|
8b1478 |
|
|
|
8b1478 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
8b1478 |
Message-Id: <20190125220606.4864-2-ehabkost@redhat.com>
|
|
|
8b1478 |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
8b1478 |
(cherry picked from commit 485b1d256bcb0874bcde0223727c159b6837e6f8)
|
|
|
8b1478 |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
8b1478 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
8b1478 |
---
|
|
|
8b1478 |
target/i386/kvm.c | 9 +++++++++
|
|
|
8b1478 |
1 file changed, 9 insertions(+)
|
|
|
8b1478 |
|
|
|
8b1478 |
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
|
|
|
8b1478 |
index c99c0ef..7afad93 100644
|
|
|
8b1478 |
--- a/target/i386/kvm.c
|
|
|
8b1478 |
+++ b/target/i386/kvm.c
|
|
|
8b1478 |
@@ -374,6 +374,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
|
|
8b1478 |
if (host_tsx_blacklisted()) {
|
|
|
8b1478 |
ret &= ~(CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_HLE);
|
|
|
8b1478 |
}
|
|
|
8b1478 |
+ } else if (function == 7 && index == 0 && reg == R_EDX) {
|
|
|
8b1478 |
+ /*
|
|
|
8b1478 |
+ * Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
|
|
|
8b1478 |
+ * We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES is
|
|
|
8b1478 |
+ * returned by KVM_GET_MSR_INDEX_LIST.
|
|
|
8b1478 |
+ */
|
|
|
8b1478 |
+ if (!has_msr_arch_capabs) {
|
|
|
8b1478 |
+ ret &= ~CPUID_7_0_EDX_ARCH_CAPABILITIES;
|
|
|
8b1478 |
+ }
|
|
|
8b1478 |
} else if (function == 0x80000001 && reg == R_ECX) {
|
|
|
8b1478 |
/*
|
|
|
8b1478 |
* It's safe to enable TOPOEXT even if it's not returned by
|
|
|
8b1478 |
--
|
|
|
8b1478 |
1.8.3.1
|
|
|
8b1478 |
|