qemu/include
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
..
authz
block nbd: Use enum for various negotiation modes 2023-07-19 15:26:13 -05:00
chardev
crypto
disas
exec accel/tcg: Track current value of can_do_io in the TB 2023-10-03 02:01:36 +03:00
fpu
gdbstub
hw hw/cxl: Fix out of bound array access 2023-10-03 02:00:54 +03:00
io io: remove io watch if TLS channel is closed during handshake 2023-08-01 18:45:27 +01:00
libdecnumber
migration
monitor
net
qapi
qemu util/uuid: Remove UUID_FMT_LEN 2023-11-09 16:39:13 +03:00
qom
scsi
semihosting
standard-headers
sysemu hw/xen: select kernel mode for per-vCPU event channel upcall vector 2023-11-09 16:39:13 +03:00
tcg
ui virtio-gpu-udmabuf: correct naming of QemuDmaBuf size properties 2023-07-17 15:22:28 +04:00
user
elf.h linux-user/elfload: Fix /proc/cpuinfo features: on s390x 2023-07-18 09:36:27 +02:00
glib-compat.h
qemu-io.h
qemu-main.h