qemu/include/sysemu
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
..
accel-blocker.h
accel-ops.h
arch_init.h
balloon.h
block-backend-common.h
block-backend-global-state.h
block-backend-io.h block: add blk_io_plug_call() API 2023-06-01 07:34:03 -04:00
block-backend.h
block-ram-registrar.h
blockdev.h
cpu-throttle.h
cpu-timers.h
cpus.h
cryptodev-vhost-user.h
cryptodev-vhost.h
cryptodev.h
device_tree.h
dirtylimit.h migration: Extend query-migrate to provide dirty page limit info 2023-07-26 10:55:56 +02:00
dirtyrate.h
dma.h
dump-arch.h
dump.h
event-loop-base.h
hax.h accel: Document generic accelerator headers 2023-06-28 13:55:35 +02:00
hostmem.h
hvf.h hvf: add guest debugging handlers for Apple Silicon hosts 2023-06-06 10:19:30 +01:00
hvf_int.h accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState 2023-06-28 14:14:22 +02:00
hw_accel.h
iothread.h
kvm.h kvm: Introduce kvm_arch_get_default_type hook 2023-08-24 18:43:47 +03:00
kvm_int.h
kvm_xen.h hw/xen: select kernel mode for per-vCPU event channel upcall vector 2023-11-09 16:39:13 +03:00
memory_mapping.h
numa.h
nvmm.h accel: Document generic accelerator headers 2023-06-28 13:55:35 +02:00
os-posix.h
os-win32.h console/win32: allocate shareable display surface 2023-06-27 17:08:56 +02:00
qtest.h
replay.h
reset.h
rng-random.h
rng.h
rtc.h
runstate-action.h
runstate.h runstate: drop unused runstate_store() 2023-06-02 01:03:19 +02:00
seccomp.h
stats.h
sysemu.h
tcg.h accel: Document generic accelerator headers 2023-06-28 13:55:35 +02:00
tpm.h
tpm_backend.h
tpm_util.h
vhost-user-backend.h
watchdog.h
whpx.h accel: Document generic accelerator headers 2023-06-28 13:55:35 +02:00
xen-mapcache.h
xen.h accel: Document generic accelerator headers 2023-06-28 13:55:35 +02:00