From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 872B53128D0; Mon, 27 Oct 2025 18:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591538; cv=none; b=XoZOKfWLOXL1bdezoUGpa+DHZu0rfzN/X4bBXmAS+HqHlfrYdGLAW13QmASuBmp9t6HYnnMnVsU+c3oOH6eLjcGIBPgA8n346MxE/GsebsXNRHPd+Ab0PHkEB6bd7nfia1DLvVv6BdKeltr7cZVpwCn9ea7cNyv0R2Ax5Ajv3mw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761591538; c=relaxed/simple; bh=Gwq9cTAeAnTkvnZcdJCQEWdW/5MdeNM+7ESiE0BsFOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VpilR/RiGncY903nELevkDQ9gmOGayGddCGSAwT+HPWH6/8/Co18oZzIXFebOdxPISbFf3bh2kmLjNkXLvVk7QjlFWDlBvk9d2vFGnfxI6+DITJnv46PVpYP9N6ef0AmShJPMfF2zT2pfbTdN5AgDmbr+0C2laAi7SUPxxWyZf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Xat1+Hcj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Xat1+Hcj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B82EC4CEF1; Mon, 27 Oct 2025 18:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761591538; bh=Gwq9cTAeAnTkvnZcdJCQEWdW/5MdeNM+7ESiE0BsFOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xat1+HcjPSExa2XIKANAmzu/Hf5FRDU3ydY4t3PMyY2MuoioPqu6P6kqR1Av4z/ur wVdqAuyWgeLV0jCU3XxSzGz7Dbd94RrI1jaNDhDTm2kHevzS4YTa/MQxIg6qOex6DZ i1pX+dTKgre7ukbyrszkP1yR2BoRnM9DIG7jS6ks= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jason Andryuk , Juergen Gross , Sasha Levin Subject: [PATCH 5.10 236/332] xen/events: Update virq_to_irq on migration Date: Mon, 27 Oct 2025 19:34:49 +0100 Message-ID: <20251027183531.053625135@linuxfoundation.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251027183524.611456697@linuxfoundation.org> References: <20251027183524.611456697@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Andryuk [ Upstream commit 3fcc8e146935415d69ffabb5df40ecf50e106131 ] VIRQs come in 3 flavors, per-VPU, per-domain, and global, and the VIRQs are tracked in per-cpu virq_to_irq arrays. Per-domain and global VIRQs must be bound on CPU 0, and bind_virq_to_irq() sets the per_cpu virq_to_irq at registration time Later, the interrupt can migrate, and info->cpu is updated. When calling __unbind_from_irq(), the per-cpu virq_to_irq is cleared for a different cpu. If bind_virq_to_irq() is called again with CPU 0, the stale irq is returned. There won't be any irq_info for the irq, so things break. Make xen_rebind_evtchn_to_cpu() update the per_cpu virq_to_irq mappings to keep them update to date with the current cpu. This ensures the correct virq_to_irq is cleared in __unbind_from_irq(). Fixes: e46cdb66c8fc ("xen: event channels") Cc: stable@vger.kernel.org Signed-off-by: Jason Andryuk Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Message-ID: <20250828003604.8949-4-jason.andryuk@amd.com> [ Adjust context ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_base.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -1746,9 +1746,20 @@ static int xen_rebind_evtchn_to_cpu(stru * virq or IPI channel, which don't actually need to be rebound. Ignore * it, but don't do the xenlinux-level rebind in that case. */ - if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) + if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) { + int old_cpu = info->cpu; + bind_evtchn_to_cpu(evtchn, tcpu); + if (info->type == IRQT_VIRQ) { + int virq = info->u.virq; + int irq = per_cpu(virq_to_irq, old_cpu)[virq]; + + per_cpu(virq_to_irq, old_cpu)[virq] = -1; + per_cpu(virq_to_irq, tcpu)[virq] = irq; + } + } + do_unmask(info, EVT_MASK_REASON_TEMPORARY); return 0;