[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v6 2/7] xen/events: don't allow binding a global virq from any domain
Today Xen will happily allow binding a global virq by a domain which isn't configured to receive it. This won't result in any bad actions, but the bind will appear to have succeeded with no event ever being received by that event channel. Instead of allowing the bind, error out if the domain isn't set to handle that virq. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- V6: - new patch --- xen/common/event_channel.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index f2b64c48fb..62060dc66b 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -120,6 +120,13 @@ static uint8_t get_xen_consumer(xen_event_channel_notification_t fn) /* Get the notification function for a given Xen-bound event channel. */ #define xen_notification_fn(e) (xen_consumers[(e)->xen_consumer-1]) +static struct domain *global_virq_handlers[NR_VIRQS] __read_mostly; + +static struct domain *get_global_virq_handler(unsigned int virq) +{ + return global_virq_handlers[virq] ?: hardware_domain; +} + static bool virq_is_global(unsigned int virq) { switch ( virq ) @@ -479,8 +486,13 @@ int evtchn_bind_virq(evtchn_bind_virq_t *bind, evtchn_port_t port) */ virq = array_index_nospec(virq, ARRAY_SIZE(v->virq_to_evtchn)); - if ( virq_is_global(virq) && (vcpu != 0) ) - return -EINVAL; + if ( virq_is_global(virq) ) + { + if ( get_global_virq_handler(virq) != d ) + return -EBUSY; + if ( vcpu != 0 ) + return -EINVAL; + } if ( (v = domain_vcpu(d, vcpu)) == NULL ) return -ENOENT; @@ -965,15 +977,13 @@ void send_guest_pirq(struct domain *d, const struct pirq *pirq) } } -static struct domain *global_virq_handlers[NR_VIRQS] __read_mostly; - static DEFINE_SPINLOCK(global_virq_handlers_lock); void send_global_virq(uint32_t virq) { ASSERT(virq_is_global(virq)); - send_guest_global_virq(global_virq_handlers[virq] ?: hardware_domain, virq); + send_guest_global_virq(get_global_virq_handler(virq), virq); } int set_global_virq_handler(struct domain *d, uint32_t virq) -- 2.43.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |