|
|
bf143f |
From f96220d64a31a4a52b2d132a503048579946f982 Mon Sep 17 00:00:00 2001
|
|
|
bf143f |
From: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
bf143f |
Date: Thu, 18 Aug 2022 17:01:13 +0200
|
|
|
bf143f |
Subject: [PATCH 3/3] i386: do kvm_put_msr_feature_control() first thing when
|
|
|
bf143f |
vCPU is reset
|
|
|
bf143f |
|
|
|
bf143f |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
bf143f |
RH-MergeRequest: 219: Synchronize qemu-6.2.0-20.el8.1 build from RHEL 8.7 to RHEL 8.8
|
|
|
bf143f |
RH-Bugzilla: 2125271
|
|
|
bf143f |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
bf143f |
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
bf143f |
RH-Commit: [2/2] 08e1e67db96801e4a35aa6b60a93b2c2f1641220
|
|
|
bf143f |
|
|
|
bf143f |
kvm_put_sregs2() fails to reset 'locked' CR4/CR0 bits upon vCPU reset when
|
|
|
bf143f |
it is in VMX root operation. Do kvm_put_msr_feature_control() before
|
|
|
bf143f |
kvm_put_sregs2() to (possibly) kick vCPU out of VMX root operation. It also
|
|
|
bf143f |
seems logical to do kvm_put_msr_feature_control() before
|
|
|
bf143f |
kvm_put_nested_state() and not after it, especially when 'real' nested
|
|
|
bf143f |
state is set.
|
|
|
bf143f |
|
|
|
bf143f |
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
bf143f |
Message-Id: <20220818150113.479917-3-vkuznets@redhat.com>
|
|
|
bf143f |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
bf143f |
(cherry picked from commit 45ed68a1a3a19754ade954d75a3c9d13ff560e5c)
|
|
|
bf143f |
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
bf143f |
---
|
|
|
bf143f |
target/i386/kvm/kvm.c | 17 ++++++++++++-----
|
|
|
bf143f |
1 file changed, 12 insertions(+), 5 deletions(-)
|
|
|
bf143f |
|
|
|
bf143f |
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
|
bf143f |
index 81d729dc40..a06221d3e5 100644
|
|
|
bf143f |
--- a/target/i386/kvm/kvm.c
|
|
|
bf143f |
+++ b/target/i386/kvm/kvm.c
|
|
|
bf143f |
@@ -4255,6 +4255,18 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
|
|
|
bf143f |
|
|
|
bf143f |
assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
|
|
|
bf143f |
|
|
|
bf143f |
+ /*
|
|
|
bf143f |
+ * Put MSR_IA32_FEATURE_CONTROL first, this ensures the VM gets out of VMX
|
|
|
bf143f |
+ * root operation upon vCPU reset. kvm_put_msr_feature_control() should also
|
|
|
bf143f |
+ * preceed kvm_put_nested_state() when 'real' nested state is set.
|
|
|
bf143f |
+ */
|
|
|
bf143f |
+ if (level >= KVM_PUT_RESET_STATE) {
|
|
|
bf143f |
+ ret = kvm_put_msr_feature_control(x86_cpu);
|
|
|
bf143f |
+ if (ret < 0) {
|
|
|
bf143f |
+ return ret;
|
|
|
bf143f |
+ }
|
|
|
bf143f |
+ }
|
|
|
bf143f |
+
|
|
|
bf143f |
/* must be before kvm_put_nested_state so that EFER.SVME is set */
|
|
|
bf143f |
ret = kvm_put_sregs(x86_cpu);
|
|
|
bf143f |
if (ret < 0) {
|
|
|
bf143f |
@@ -4266,11 +4278,6 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
|
|
|
bf143f |
if (ret < 0) {
|
|
|
bf143f |
return ret;
|
|
|
bf143f |
}
|
|
|
bf143f |
-
|
|
|
bf143f |
- ret = kvm_put_msr_feature_control(x86_cpu);
|
|
|
bf143f |
- if (ret < 0) {
|
|
|
bf143f |
- return ret;
|
|
|
bf143f |
- }
|
|
|
bf143f |
}
|
|
|
bf143f |
|
|
|
bf143f |
if (level == KVM_PUT_FULL_STATE) {
|
|
|
bf143f |
--
|
|
|
bf143f |
2.35.3
|
|
|
bf143f |
|