[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.5 14/21] target-i386: hyper-v: Correct kvm_hv_handle_exit re
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.5 14/21] target-i386: hyper-v: Correct kvm_hv_handle_exit return value |
Date: |
Mon, 27 May 2024 10:24:24 +0300 |
From: donsheng <dongsheng.x.zhang@intel.com>
This bug fix addresses the incorrect return value of kvm_hv_handle_exit for
KVM_EXIT_HYPERV_SYNIC, which should be EXCP_INTERRUPT.
Handling of KVM_EXIT_HYPERV_SYNIC in QEMU needs to be synchronous.
This means that async_synic_update should run in the current QEMU vCPU
thread before returning to KVM, returning EXCP_INTERRUPT to guarantee this.
Returning 0 can cause async_synic_update to run asynchronously.
One problem (kvm-unit-tests's hyperv_synic test fails with timeout error)
caused by this bug:
When a guest VM writes to the HV_X64_MSR_SCONTROL MSR to enable Hyper-V SynIC,
a VM exit is triggered and processed by the kvm_hv_handle_exit function of the
QEMU vCPU. This function then calls the async_synic_update function to set
synic->sctl_enabled to true. A true value of synic->sctl_enabled is required
before creating SINT routes using the hyperv_sint_route_new() function.
If kvm_hv_handle_exit returns 0 for KVM_EXIT_HYPERV_SYNIC, the current QEMU
vCPU thread may return to KVM and enter the guest VM before running
async_synic_update. In such case, the hyperv_synic test’s subsequent call to
synic_ctl(HV_TEST_DEV_SINT_ROUTE_CREATE, ...) immediately after writing to
HV_X64_MSR_SCONTROL can cause QEMU’s hyperv_sint_route_new() function to return
prematurely (because synic->sctl_enabled is false).
If the SINT route is not created successfully, the SINT interrupt will not be
fired, resulting in a timeout error in the hyperv_synic test.
Fixes: 267e071bd6d6 (“hyperv: make overlay pages for SynIC”)
Suggested-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Dongsheng Zhang <dongsheng.x.zhang@intel.com>
Message-ID: <20240521200114.11588-1-dongsheng.x.zhang@intel.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 84d4b72854869821eb89813c195927fdd3078c12)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/kvm/hyperv.c b/target/i386/kvm/hyperv.c
index e3ac978648..0a2e2a07e9 100644
--- a/target/i386/kvm/hyperv.c
+++ b/target/i386/kvm/hyperv.c
@@ -81,7 +81,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit
*exit)
*/
async_safe_run_on_cpu(CPU(cpu), async_synic_update, RUN_ON_CPU_NULL);
- return 0;
+ return EXCP_INTERRUPT;
case KVM_EXIT_HYPERV_HCALL: {
uint16_t code = exit->u.hcall.input & 0xffff;
bool fast = exit->u.hcall.input & HV_HYPERCALL_FAST;
--
2.39.2
- [Stable-8.2.5 10/21] configure: Fix error message when C compiler is not working, (continued)
- [Stable-8.2.5 10/21] configure: Fix error message when C compiler is not working, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 03/21] target/sparc: Fix FMUL8x16, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 05/21] hw/remote/vfio-user: Fix config space access byte order, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 12/21] ui/gtk: Check if fence_fd is equal to or greater than 0, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 09/21] configure: quote -D options that are passed through to meson, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 11/21] ui/gtk: Fix mouse/motion event scaling issue with GTK display backend, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 16/21] target/loongarch/kvm: Fix VM recovery from disk failures, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 15/21] hw/core/machine: move compatibility flags for VirtIO-net USO to machine 8.1, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 13/21] tcg/loongarch64: Fill out tcg_out_{ld, st} for vector regs, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 17/21] hw/loongarch: Fix fdt memory node wrong 'reg', Michael Tokarev, 2024/05/27
- [Stable-8.2.5 14/21] target-i386: hyper-v: Correct kvm_hv_handle_exit return value,
Michael Tokarev <=
- [Stable-8.2.5 18/21] hw/loongarch/virt: Fix FDT memory node address width, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 19/21] dockerfiles: add 'MAKE' env variable to remaining containers, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 20/21] target/i386: disable jmp_opt if EFLAGS.RF is 1, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 21/21] target/i386: no single-step exception after MOV or POP SS, Michael Tokarev, 2024/05/27