- s390x/sclp: Simplify get_sclp_device() - target/ppc: Remove msr_pr macro - docs/system/target-arm: Re-alphabetize board list - migration: Extend query-migrate to provide dirty page limit info - migration: Implement dirty-limit convergence algo - migration: Put the detection logic before auto-converge checking - migration: Refactor auto-converge capability logic - migration: Introduce dirty-limit capability - qapi/migration: Introduce vcpu-dirty-limit parameters - qapi/migration: Introduce x-vcpu-dirty-limit-period parameter - Change the value of no_ged from true to false - Allow UNIX socket option for VNC websocket - tpm_emulator: Avoid double initialization during - chardev/char-socket: Update AF_UNIX for Windows - KVM: dirty ring: add missing memory barrier - i386: reset KVM nested state upon CPU reset - esp: Handle CMD_BUSRESET by resetting the SCSI bus - dbus-vmstate: Restrict error checks to registered proxies in dbus_get_proxies - vfio/pci: Add Ascend310b scend910b support - target/i386: Export RFDS bit to guests - target/i386: Add new CPU model SierraForest - target/i386: Introduce Icelake-Server-v7 to enable TSX - hw/virtio: handle un-configured shutdown in virtio-pci - target/s390x: display deprecation status in '-cpu help' - target/i386: display deprecation status in '-cpu help' - pc-bios/s390-ccw: Fix booting with logical block size < physical block size Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
91 lines
2.9 KiB
Diff
91 lines
2.9 KiB
Diff
From 6257f125bc58952f49cbbc28210099a6333152a8 Mon Sep 17 00:00:00 2001
|
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
Date: Tue, 14 May 2024 10:05:16 +0000
|
|
Subject: [PATCH] i386: reset KVM nested state upon CPU reset mainline
|
|
inclusion commit 3cafdb67504a34a0305260f0c86a73d5a3fb000b category: bugfix
|
|
|
|
---------------------------------------------------------------
|
|
|
|
Make sure env->nested_state is cleaned up when a vCPU is reset, it may
|
|
be stale after an incoming migration, kvm_arch_put_registers() may
|
|
end up failing or putting vCPU in a weird state.
|
|
|
|
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
Message-Id: <20220818150113.479917-2-vkuznets@redhat.com>
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
---
|
|
target/i386/kvm/kvm.c | 37 +++++++++++++++++++++++++++----------
|
|
1 file changed, 27 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
index 99be7f6155..9f3ddd5da2 100644
|
|
--- a/target/i386/kvm/kvm.c
|
|
+++ b/target/i386/kvm/kvm.c
|
|
@@ -1623,6 +1623,30 @@ static void kvm_init_xsave(CPUX86State *env)
|
|
env->xsave_buf_len);
|
|
}
|
|
|
|
+static void kvm_init_nested_state(CPUX86State *env)
|
|
+{
|
|
+ struct kvm_vmx_nested_state_hdr *vmx_hdr;
|
|
+ uint32_t size;
|
|
+
|
|
+ if (!env->nested_state) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ size = env->nested_state->size;
|
|
+
|
|
+ memset(env->nested_state, 0, size);
|
|
+ env->nested_state->size = size;
|
|
+
|
|
+ if (cpu_has_vmx(env)) {
|
|
+ env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX;
|
|
+ vmx_hdr = &env->nested_state->hdr.vmx;
|
|
+ vmx_hdr->vmxon_pa = -1ull;
|
|
+ vmx_hdr->vmcs12_pa = -1ull;
|
|
+ } else if (cpu_has_svm(env)) {
|
|
+ env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM;
|
|
+ }
|
|
+}
|
|
+
|
|
int kvm_arch_init_vcpu(CPUState *cs)
|
|
{
|
|
struct {
|
|
@@ -2051,19 +2075,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
|
|
assert(max_nested_state_len >= offsetof(struct kvm_nested_state, data));
|
|
|
|
if (cpu_has_vmx(env) || cpu_has_svm(env)) {
|
|
- struct kvm_vmx_nested_state_hdr *vmx_hdr;
|
|
-
|
|
env->nested_state = g_malloc0(max_nested_state_len);
|
|
env->nested_state->size = max_nested_state_len;
|
|
|
|
- if (cpu_has_vmx(env)) {
|
|
- env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX;
|
|
- vmx_hdr = &env->nested_state->hdr.vmx;
|
|
- vmx_hdr->vmxon_pa = -1ull;
|
|
- vmx_hdr->vmcs12_pa = -1ull;
|
|
- } else {
|
|
- env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM;
|
|
- }
|
|
+ kvm_init_nested_state(env);
|
|
}
|
|
}
|
|
|
|
@@ -2126,6 +2141,8 @@ void kvm_arch_reset_vcpu(X86CPU *cpu)
|
|
/* enabled by default */
|
|
env->poll_control_msr = 1;
|
|
|
|
+ kvm_init_nested_state(env);
|
|
+
|
|
sev_es_set_reset_vector(CPU(cpu));
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|