qemu-e2k/target/i386
David Woodhouse ddf0fd9ae1 hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback
The GSI callback (and later PCI_INTX) is a level triggered interrupt. It
is asserted when an event channel is delivered to vCPU0, and is supposed
to be cleared when the vcpu_info->evtchn_upcall_pending field for vCPU0
is cleared again.

Thankfully, Xen does *not* assert the GSI if the guest sets its own
evtchn_upcall_pending field; we only need to assert the GSI when we
have delivered an event for ourselves. So that's the easy part, kind of.

There's a slight complexity in that we need to hold the BQL before we
can call qemu_set_irq(), and we definitely can't do that while holding
our own port_lock (because we'll need to take that from the qemu-side
functions that the PV backend drivers will call). So if we end up
wanting to set the IRQ in a context where we *don't* already hold the
BQL, defer to a BH.

However, we *do* need to poll for the evtchn_upcall_pending flag being
cleared. In an ideal world we would poll that when the EOI happens on
the PIC/IOAPIC. That's how it works in the kernel with the VFIO eventfd
pairs — one is used to trigger the interrupt, and the other works in the
other direction to 'resample' on EOI, and trigger the first eventfd
again if the line is still active.

However, QEMU doesn't seem to do that. Even VFIO level interrupts seem
to be supported by temporarily unmapping the device's BARs from the
guest when an interrupt happens, then trapping *all* MMIO to the device
and sending the 'resample' event on *every* MMIO access until the IRQ
is cleared! Maybe in future we'll plumb the 'resample' concept through
QEMU's irq framework but for now we'll do what Xen itself does: just
check the flag on every vmexit if the upcall GSI is known to be
asserted.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
2023-03-01 09:06:44 +00:00
..
hax target/i386: Remove NEED_CPU_H guard from target-specific headers 2023-02-27 22:29:01 +01:00
hvf target/i386: Remove NEED_CPU_H guard from target-specific headers 2023-02-27 22:29:01 +01:00
kvm hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback 2023-03-01 09:06:44 +00:00
nvmm
tcg target/i386: Fix BZHI instruction 2023-02-27 09:18:55 +01:00
whpx hw: Move ioapic*.h to intc/ 2023-02-27 22:29:01 +01:00
arch_dump.c
arch_memory_mapping.c
cpu-dump.c target/i386: Remove x86_cpu_dump_local_apic_state() dead stub 2023-02-27 22:29:01 +01:00
cpu-internal.h
cpu-param.h
cpu-qom.h
cpu-sysemu.c
cpu.c i386/kvm: handle Xen HVM cpuid leaves 2023-03-01 08:22:49 +00:00
cpu.h hw/xen: Support HVM_PARAM_CALLBACK_TYPE_GSI callback 2023-03-01 09:06:44 +00:00
gdbstub.c
helper.c
helper.h
host-cpu.c
host-cpu.h
Kconfig
machine.c hw/xen: Implement EVTCHNOP_bind_virq 2023-03-01 08:22:50 +00:00
meson.build
monitor.c
ops_sse_header.h
ops_sse.h
sev-sysemu-stub.c
sev.c
sev.h
shift_helper_template.h
svm.h
trace-events
trace.h
xsave_helper.c