qemu/target/i386
Vitaly Kuznetsov d3177e2e43 target/i386: Make sure SynIC state is really updated before KVM_RUN
'hyperv_synic' test from KVM unittests was observed to be flaky on certain
hardware (hangs sometimes). Debugging shows that the problem happens in
hyperv_sint_route_new() when the test tries to set up a new SynIC
route. The function bails out on:

 if (!synic->sctl_enabled) {
         goto cleanup;
 }

but the test writes to HV_X64_MSR_SCONTROL just before it starts
establishing SINT routes. Further investigation shows that
synic_update() (called from async_synic_update()) happens after the SINT
setup attempt and not before. Apparently, the comment before
async_safe_run_on_cpu() in kvm_hv_handle_exit() does not correctly describe
the guarantees async_safe_run_on_cpu() gives. In particular, async worked
added to a CPU is actually processed from qemu_wait_io_event() which is not
always called before KVM_RUN, i.e. kvm_cpu_exec() checks whether an exit
request is pending for a CPU and if not, keeps running the vCPU until it
meets an exit it can't handle internally. Hyper-V specific MSR writes are
not automatically trigger an exit.

Fix the issue by simply raising an exit request for the vCPU where SynIC
update was queued. This is not a performance critical path as SynIC state
does not get updated so often (and async_safe_run_on_cpu() is a big hammer
anyways).

Reported-by: Jan Richter <jarichte@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/20240917160051.2637594-4-vkuznets@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-10-17 12:30:21 +02:00
..
hvf hvf: Split up hv_vm_create logic per arch 2024-09-13 15:31:46 +01:00
kvm target/i386: Make sure SynIC state is really updated before KVM_RUN 2024-10-17 12:30:21 +02:00
nvmm cpu: move Qemu[Thread|Cond] setup into common code 2024-06-04 10:02:39 +02:00
tcg target/i386: Fix tss access size in switch_tss_ra 2024-08-21 09:11:26 +10:00
whpx cpu: move Qemu[Thread|Cond] setup into common code 2024-06-04 10:02:39 +02:00
arch_dump.c
arch_memory_mapping.c
confidential-guest.c
confidential-guest.h target/i386: add support for masking CPUID features in confidential guests 2024-07-04 07:47:11 +02:00
cpu-apic.c
cpu-dump.c target/i386: fix CC_OP dump 2024-06-28 14:44:52 +02:00
cpu-internal.h
cpu-param.h license: Update deprecated SPDX tag LGPL-2.0+ to LGPL-2.0-or-later 2024-09-20 10:11:59 +03:00
cpu-qom.h
cpu-sysemu.c
cpu.c target/i386: Fix conditional CONFIG_SYNDBG enablement 2024-10-17 12:30:21 +02:00
cpu.h target/i386: Add support save/load HWCR MSR 2024-10-17 12:30:21 +02:00
gdbstub.c target/i386/gdbstub: Expose orig_ax 2024-10-13 10:05:51 -07:00
helper.c i386: Fix MCE support for AMD hosts 2024-06-08 10:33:38 +02:00
helper.h target/i386: replace read_crN helper with read_cr8 2024-06-17 09:47:39 +02:00
host-cpu.c target/i386: Advertise MWAIT iff host supports 2024-06-30 19:51:44 +03:00
host-cpu.h
Kconfig i386: select correct components for no-board build 2024-05-10 15:45:15 +02:00
machine.c target/i386: Add support save/load HWCR MSR 2024-10-17 12:30:21 +02:00
meson.build
monitor.c
ops_sse.h target/i386: set CC_OP in helpers if they want CC_OP_EFLAGS 2024-05-25 13:28:01 +02:00
sev-sysemu-stub.c hw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled 2024-06-05 11:01:06 +02:00
sev.c qapi/crypto: Rename QCryptoHashAlgorithm to *Algo, and drop prefix 2024-09-10 14:02:16 +02:00
sev.h hw/i386/sev: Add support to encrypt BIOS when SEV-SNP is enabled 2024-06-05 11:01:06 +02:00
svm.h
trace-events target/i386/sev: Use size_t for object sizes 2024-06-28 19:26:54 +02:00
trace.h
xsave_helper.c