|
|
2ec96d |
From e9ae571d86a83652aa43f9b866f619709b1feda2 Mon Sep 17 00:00:00 2001
|
|
|
2ec96d |
From: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
2ec96d |
Date: Wed, 9 Oct 2019 17:51:47 +0200
|
|
|
2ec96d |
Subject: [PATCH 09/10] i386: kvm: Disable arch_capabilities if MSR can't be
|
|
|
2ec96d |
set
|
|
|
2ec96d |
|
|
|
2ec96d |
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
2ec96d |
Message-id: <20191009175148.1361-10-ehabkost@redhat.com>
|
|
|
2ec96d |
Patchwork-id: 91365
|
|
|
2ec96d |
O-Subject: [RHEL-7.7.z qemu-kvm PATCH 09/10] i386: kvm: Disable arch_capabilities if MSR can't be set
|
|
|
2ec96d |
Bugzilla: 1730606
|
|
|
2ec96d |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
2ec96d |
RH-Acked-by: Bandan Das <bsd@redhat.com>
|
|
|
2ec96d |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
2ec96d |
|
|
|
2ec96d |
KVM has two bugs in the handling of MSR_IA32_ARCH_CAPABILITIES:
|
|
|
2ec96d |
|
|
|
2ec96d |
1) Linux commit commit 1eaafe91a0df ("kvm: x86: IA32_ARCH_CAPABILITIES
|
|
|
2ec96d |
is always supported") makes GET_SUPPORTED_CPUID return
|
|
|
2ec96d |
arch_capabilities even if running on SVM. This makes "-cpu
|
|
|
2ec96d |
host,migratable=off" incorrectly expose arch_capabilities on CPUID on
|
|
|
2ec96d |
AMD hosts (where the MSR is not emulated by KVM).
|
|
|
2ec96d |
|
|
|
2ec96d |
2) KVM_GET_MSR_INDEX_LIST does not return MSR_IA32_ARCH_CAPABILITIES if
|
|
|
2ec96d |
the MSR is not supported by the host CPU. This makes QEMU not
|
|
|
2ec96d |
initialize the MSR properly at kvm_put_msrs() on those hosts.
|
|
|
2ec96d |
|
|
|
2ec96d |
Work around both bugs on the QEMU side, by checking if the MSR
|
|
|
2ec96d |
was returned by KVM_GET_MSR_INDEX_LIST before returning the
|
|
|
2ec96d |
feature flag on kvm_arch_get_supported_cpuid().
|
|
|
2ec96d |
|
|
|
2ec96d |
This has the unfortunate side effect of making arch_capabilities
|
|
|
2ec96d |
unavailable on hosts without hardware support for the MSR until bug #2
|
|
|
2ec96d |
is fixed on KVM, but I can't see another way to work around bug #1
|
|
|
2ec96d |
without that side effect.
|
|
|
2ec96d |
|
|
|
2ec96d |
7.8 backport conflicts (plai):
|
|
|
2ec96d |
target/i386/kvm.c changes to target-i386/kvm.c
|
|
|
2ec96d |
|
|
|
2ec96d |
7.7.z backport notes (ehabkost):
|
|
|
2ec96d |
* Cherry pick from 7.8 tree with no conflicts
|
|
|
2ec96d |
|
|
|
2ec96d |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
2ec96d |
Message-Id: <20190125220606.4864-2-ehabkost@redhat.com>
|
|
|
2ec96d |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
2ec96d |
(cherry picked from commit 485b1d256bcb0874bcde0223727c159b6837e6f8)
|
|
|
2ec96d |
Signed-off-by: Paul Lai <plai@redhat.com>
|
|
|
2ec96d |
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
2ec96d |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
2ec96d |
---
|
|
|
2ec96d |
target-i386/kvm.c | 9 +++++++++
|
|
|
2ec96d |
1 file changed, 9 insertions(+)
|
|
|
2ec96d |
|
|
|
2ec96d |
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
|
|
|
2ec96d |
index bc3a514..0374b7a 100644
|
|
|
2ec96d |
--- a/target-i386/kvm.c
|
|
|
2ec96d |
+++ b/target-i386/kvm.c
|
|
|
2ec96d |
@@ -234,6 +234,15 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
|
|
|
2ec96d |
if (!kvm_irqchip_in_kernel()) {
|
|
|
2ec96d |
ret &= ~CPUID_EXT_X2APIC;
|
|
|
2ec96d |
}
|
|
|
2ec96d |
+ } else if (function == 7 && index == 0 && reg == R_EDX) {
|
|
|
2ec96d |
+ /*
|
|
|
2ec96d |
+ * Linux v4.17-v4.20 incorrectly return ARCH_CAPABILITIES on SVM hosts.
|
|
|
2ec96d |
+ * We can detect the bug by checking if MSR_IA32_ARCH_CAPABILITIES is
|
|
|
2ec96d |
+ * returned by KVM_GET_MSR_INDEX_LIST.
|
|
|
2ec96d |
+ */
|
|
|
2ec96d |
+ if (!has_msr_arch_capabs) {
|
|
|
2ec96d |
+ ret &= ~CPUID_7_0_EDX_ARCH_CAPABILITIES;
|
|
|
2ec96d |
+ }
|
|
|
2ec96d |
} else if (function == 0x80000001 && reg == R_EDX) {
|
|
|
2ec96d |
/* On Intel, kvm returns cpuid according to the Intel spec,
|
|
|
2ec96d |
* so add missing bits according to the AMD spec:
|
|
|
2ec96d |
--
|
|
|
2ec96d |
1.8.3.1
|
|
|
2ec96d |
|