qemu/hw/i386/kvm
David Woodhouse 18e83f28bf 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>
2023-11-06 10:03:45 +00:00
..
apic.c i386/kvm: The value passed to strerror should be positive 2021-06-05 21:01:17 +02:00
clock.c kvm: i386: require KVM_CAP_ADJUST_CLOCK 2023-10-25 19:53:38 +02:00
clock.h hw/i386: Rename 'hw/kvm/clock.h' -> 'hw/i386/kvm/clock.h' 2023-08-31 19:47:43 +02:00
i8254.c kvm: i8254: require KVM_CAP_PIT2 and KVM_CAP_PIT_STATE2 2023-10-25 19:53:38 +02:00
i8259.c hw/intc: Extract the IRQ counting functions into a separate file 2023-01-13 16:22:57 +01:00
ioapic.c sysemu/kvm: Restrict kvm_pc_setup_irq_routing() to x86 targets 2023-09-07 13:32:37 +02:00
meson.build meson: Replace CONFIG_SOFTMMU -> CONFIG_SYSTEM_ONLY 2023-06-20 10:01:30 +02:00
trace-events hw/xen: Add xenstore wire implementation and implementation stubs 2023-03-07 17:04:30 +00:00
trace.h hw/xen: Implement emulated PIRQ hypercall support 2023-03-01 09:09:01 +00:00
xen_evtchn.c hw/xen: select kernel mode for per-vCPU event channel upcall vector 2023-11-06 10:03:45 +00:00
xen_evtchn.h hw/xen: Simplify emulated Xen platform init 2023-06-07 15:07:10 +01:00
xen_gnttab.c hw/xen: Implement soft reset for emulated gnttab 2023-03-07 17:04:30 +00:00
xen_gnttab.h hw/xen: Implement soft reset for emulated gnttab 2023-03-07 17:04:30 +00:00
xen_overlay.c hw/xen: Support mapping grant frames 2023-03-01 09:07:52 +00:00
xen_overlay.h hw/xen: Support mapping grant frames 2023-03-01 09:07:52 +00:00
xen_xenstore.c i386: spelling fixes 2023-09-20 07:54:34 +03:00
xen_xenstore.h hw/xen: Add xen_xenstore device for xenstore emulation 2023-03-01 09:08:26 +00:00
xen-stubs.c hw/xen: Support MSI mapping to PIRQ 2023-03-01 09:09:22 +00:00
xenstore_impl.c i386: spelling fixes 2023-09-20 07:54:34 +03:00
xenstore_impl.h hw/xen: Add xenstore operations to allow redirection to internal emulation 2023-03-07 17:04:30 +00:00