qemu/target/i386
David Woodhouse 5450203719 hw/xen: select kernel mode for per-vCPU event channel upcall vector
A guest which has configured the per-vCPU upcall vector may set the
HVM_PARAM_CALLBACK_IRQ param to fairly much anything other than zero.

For example, Linux v6.0+ after commit b1c3497e604 ("x86/xen: Add support
for HVMOP_set_evtchn_upcall_vector") will just do this after setting the
vector:

       /* Trick toolstack to think we are enlightened. */
       if (!cpu)
               rc = xen_set_callback_via(1);

That's explicitly setting the delivery to GSI#1, but it's supposed to be
overridden by the per-vCPU vector setting. This mostly works in Qemu
*except* for the logic to enable the in-kernel handling of event channels,
which falsely determines that the kernel cannot accelerate GSI delivery
in this case.

Add a kvm_xen_has_vcpu_callback_vector() to report whether vCPU#0 has
the vector set, and use that in xen_evtchn_set_callback_param() to
enable the kernel acceleration features even when the param *appears*
to be set to target a GSI.

Preserve the Xen behaviour that when HVM_PARAM_CALLBACK_IRQ is set to
*zero* the event channel delivery is disabled completely. (Which is
what that bizarre guest behaviour is working round in the first place.)

Cc: qemu-stable@nongnu.org
Fixes: 91cce75617 ("hw/xen: Add xen_evtchn device for event channel emulation")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
(cherry picked from commit 18e83f28bf39ffd2784aeb2e4e229096a86d349b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-11-09 16:39:13 +03:00
..
hax exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
hvf accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState 2023-06-28 14:14:22 +02:00
kvm hw/xen: select kernel mode for per-vCPU event channel upcall vector 2023-11-09 16:39:13 +03:00
nvmm exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
tcg target/i386: fix memory operand size for CVTPS2PD 2023-10-04 17:34:46 +03:00
whpx exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
arch_dump.c
arch_memory_mapping.c
cpu-dump.c
cpu-internal.h
cpu-param.h
cpu-qom.h
cpu-sysemu.c
cpu.c target/i386: Add new CPU model GraniteRapids 2023-07-07 12:52:27 +02:00
cpu.h target/i386: Add new bit definitions of MSR_IA32_ARCH_CAPABILITIES 2023-07-07 12:52:27 +02:00
gdbstub.c
helper.c target/i386/helper: Shuffle do_cpu_init() 2023-06-13 11:28:58 +02:00
helper.h target/i386: implement SYSCALL/SYSRET in 32-bit emulators 2023-06-26 10:23:56 +02:00
host-cpu.c
host-cpu.h
Kconfig
machine.c
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
monitor.c
ops_sse.h target/i386: Use aesdec_ISB_ISR_IMC_AK 2023-07-08 07:30:18 +01:00
sev-sysemu-stub.c
sev.c
sev.h
svm.h
trace-events
trace.h
xsave_helper.c