[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 02/28] i386/xen: fix per-vCPU upcall vector for Xen emulation
From: |
David Woodhouse |
Subject: |
[PATCH v3 02/28] i386/xen: fix per-vCPU upcall vector for Xen emulation |
Date: |
Wed, 25 Oct 2023 15:50:16 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
The per-vCPU upcall vector support had three problems. Firstly it was
using the wrong hypercall argument and would always return -EFAULT when
the guest tried to set it up. Secondly it was using the wrong ioctl() to
pass the vector to the kernel and thus the *kernel* would always return
-EINVAL. Finally, even when delivering the event directly from userspace
with an MSI, it put the destination CPU ID into the wrong bits of the
MSI address.
Linux doesn't (yet) use this mode so it went without decent testing
for a while.
Fixes: 105b47fdf2d0 ("i386/xen: implement HVMOP_set_evtchn_upcall_vector")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
---
target/i386/kvm/xen-emu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index 0055441b2e..7c504d9fa4 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -306,7 +306,7 @@ static int kvm_xen_set_vcpu_callback_vector(CPUState *cs)
trace_kvm_xen_set_vcpu_callback(cs->cpu_index, vector);
- return kvm_vcpu_ioctl(cs, KVM_XEN_HVM_SET_ATTR, &xva);
+ return kvm_vcpu_ioctl(cs, KVM_XEN_VCPU_SET_ATTR, &xva);
}
static void do_set_vcpu_callback_vector(CPUState *cs, run_on_cpu_data data)
@@ -440,7 +440,8 @@ void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id,
int type)
* deliver it as an MSI.
*/
MSIMessage msg = {
- .address = APIC_DEFAULT_ADDRESS | X86_CPU(cs)->apic_id,
+ .address = APIC_DEFAULT_ADDRESS |
+ (X86_CPU(cs)->apic_id << MSI_ADDR_DEST_ID_SHIFT),
.data = vector | (1UL << MSI_DATA_LEVEL_SHIFT),
};
kvm_irqchip_send_msi(kvm_state, msg);
@@ -849,8 +850,7 @@ static bool kvm_xen_hcall_hvm_op(struct kvm_xen_exit *exit,
X86CPU *cpu,
int ret = -ENOSYS;
switch (cmd) {
case HVMOP_set_evtchn_upcall_vector:
- ret = kvm_xen_hcall_evtchn_upcall_vector(exit, cpu,
- exit->u.hcall.params[0]);
+ ret = kvm_xen_hcall_evtchn_upcall_vector(exit, cpu, arg);
break;
case HVMOP_pagetable_dying:
--
2.40.1
- [PATCH v3 07/28] hw/xen: use correct default protocol for xen-block on x86, (continued)
- [PATCH v3 07/28] hw/xen: use correct default protocol for xen-block on x86, David Woodhouse, 2023/10/25
- [PATCH v3 28/28] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/10/25
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, Eric Blake, 2023/10/25
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/10/25
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, Andrew Cooper, 2023/10/25
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/10/25
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, Kevin Wolf, 2023/10/26
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/10/26
- Re: [PATCH v3 28/28] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/10/26
[PATCH v3 02/28] i386/xen: fix per-vCPU upcall vector for Xen emulation,
David Woodhouse <=
[PATCH v3 12/28] hw/xen: populate store frontend nodes with XenStore PFN/port, David Woodhouse, 2023/10/25
[PATCH v3 20/28] net: do not delete nics in net_cleanup(), David Woodhouse, 2023/10/25
[PATCH v3 04/28] hw/xen: don't clear map_track[] in xen_gnttab_reset(), David Woodhouse, 2023/10/25
[PATCH v3 01/28] i386/xen: Don't advertise XENFEAT_supervisor_mode_kernel, David Woodhouse, 2023/10/25
[PATCH v3 10/28] include: update Xen public headers to Xen 4.17.2 release, David Woodhouse, 2023/10/25
[PATCH v3 15/28] hw/xen: do not repeatedly try to create a failing backend device, David Woodhouse, 2023/10/25
[PATCH v3 18/28] hw/xen: only remove peers of PCI NICs on unplug, David Woodhouse, 2023/10/25
[PATCH v3 25/28] hw/pci: add pci_init_nic_devices(), pci_init_nic_in_slot(), David Woodhouse, 2023/10/25