From d48f99f01f682d8e765f409d98c3395a3c9dfe37 Mon Sep 17 00:00:00 2001 From: Dmytro Firsov Date: Thu, 23 Jun 2022 12:37:47 +0300 Subject: [PATCH] xenvm: evtchn: fix undefined value during event handling This commit fixes issue with undefined value during position calculations. Shift for positions may be >32, so we need to explicitly use unsigned long casting to prevent unexpected behavior during event handling. Thanks @jgrall for suggestion. Signed-off-by: Dmytro Firsov --- drivers/xen/events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index a29836a28c..e176f36e38 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -227,12 +227,12 @@ static void events_isr(void *data) while (pos_selector) { /* Find first position, clear it in selector and process */ pos_index = __builtin_ffsl(pos_selector) - 1; - pos_selector &= ~(1 << pos_index); + pos_selector &= ~(((xen_ulong_t) 1) << pos_index); /* Find all active evtchn on selected position */ while ((events_pending = get_pending_events(pos_index)) != 0) { event_index = __builtin_ffsl(events_pending) - 1; - events_pending &= (1 << event_index); + events_pending &= (((xen_ulong_t) 1) << event_index); port = (pos_index * 8 * sizeof(xen_ulong_t)) + event_index;