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