From 55328d8eef6c4d6653fae84232957638bc008e43 Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Sat, 10 Oct 2015 20:40:06 +0100 Subject: [PATCH] xen: Introduce xen_support_evtchn_bind xen_vector_callback_enabled is x86 specific and supporting evtchn rebind on others architectures may be different. Introduce a new helper to check if we can rebind the event channel. Note that xen_intr_assign_cpu was only checking if xen_vector_callback_enabled. Although it looks like to me that rebind should be supported for PVH. --- sys/dev/xen/debug/debug.c | 2 +- sys/x86/include/xen/xen-os.h | 7 +++++++ sys/x86/xen/xen_intr.c | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/dev/xen/debug/debug.c b/sys/dev/xen/debug/debug.c index 31bb70979cf9..a8b9b17969ee 100644 --- a/sys/dev/xen/debug/debug.c +++ b/sys/dev/xen/debug/debug.c @@ -95,7 +95,7 @@ xendebug_identify(driver_t *driver, device_t parent) KASSERT(xen_domain(), ("Trying to add Xen debug device to non-xen guest")); - if (xen_hvm_domain() && !xen_vector_callback_enabled) + if (!xen_support_evtchn_rebind()) return; if (BUS_ADD_CHILD(parent, 0, "debug", 0) == NULL) diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h index c3cff89036e2..507ddf1e5856 100644 --- a/sys/x86/include/xen/xen-os.h +++ b/sys/x86/include/xen/xen-os.h @@ -42,6 +42,13 @@ xen_pmap(vm_paddr_t pa, vm_size_t size) return (pmap_mapdev(pa, size)); } +static inline bool +xen_support_evtchn_rebind(void) +{ + + return (!xen_hvm_domain() || xen_vector_callback_enabled == 0); +} + #endif /* !__ASSEMBLY__ */ #endif /* _MACHINE_X86_XEN_XEN_OS_H_ */ diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index b49376bd7e54..7925b37b056b 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -531,7 +531,7 @@ xen_intr_handle_upcall(struct trapframe *trap_frame) s = HYPERVISOR_shared_info; v = DPCPU_GET(vcpu_info); - if (xen_hvm_domain() && !xen_vector_callback_enabled) { + if (!xen_support_evtchn_rebind()) { KASSERT((cpu == 0), ("Fired PCI event callback on wrong CPU")); } @@ -871,7 +871,7 @@ xen_intr_assign_cpu(struct intsrc *base_isrc, u_int apic_id) u_int to_cpu, vcpu_id; int error, masked; - if (xen_vector_callback_enabled == 0) + if (!xen_support_evtchn_rebind()) return (EOPNOTSUPP); to_cpu = apic_cpuid(apic_id); -- 2.39.5