Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A988C98318 for ; Thu, 24 Sep 2026 20:58:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1433039.1653873 (Exim 4.92) (envelope-from ) id 1x9qWI-0005S3-71; Thu, 24 Sep 2026 20:58:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1433039.1653873; Thu, 24 Sep 2026 20:58:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x9qWI-0005Rw-4E; Thu, 24 Sep 2026 20:58:18 +0000 Received: by outflank-mailman (input) for mailman id 1433039; Thu, 24 Sep 2026 20:58:16 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x9qWG-0005Rj-Ds for xen-devel@lists.xenproject.org; Thu, 24 Sep 2026 20:58:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x9qWF-00CMcQ-Qu for xen-devel@lists.xenproject.org; Thu, 24 Sep 2026 22:58:15 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6ab58ebf-8faa-0a2a0a5109dd-0a2a4509c090-26 for ; Thu, 24 Sep 2026 22:58:15 +0200 Received: from [40.107.130.140] (helo=MRWPR03CU001.outbound.protection.outlook.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6ab58ee7-be1a-0a2a45090019-286b828ce1c5-3 for ; Thu, 24 Sep 2026 22:58:15 +0200 Received: from DB3PR0302MB9208.eurprd03.prod.outlook.com (2603:10a6:10:430::13) by GV1PR03MB10503.eurprd03.prod.outlook.com (2603:10a6:150:16f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Thu, 24 Sep 2026 20:58:10 +0000 Received: from DB3PR0302MB9208.eurprd03.prod.outlook.com ([fe80::f257:38e:c0af:df28]) by DB3PR0302MB9208.eurprd03.prod.outlook.com ([fe80::f257:38e:c0af:df28%5]) with mapi id 15.21.0451.014; Thu, 24 Sep 2026 20:58:09 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=atvXbPtNEYEJ7yUjCeF4ae0byOyKys/Zf1iIjhnK81x0b6o5JZJ5M5Cdp9cwJOu/7JZCjLGMKRwl4UNfaNaFRVmdFPcHYUU6fk5x7J3zGuhrOSYGRVt8AuJrY75a3NXdHC1fyQdEaAAQwjIHDVRRMayvTDqyrxDXavJrm0rWGDEgpXEGMV4AmVQSMvouyVsTJLca/8VjkbFDMHaux/XjdXu2i6dAQ7oJZgosaPihy9oMe6VsDK39dQ3+mHejZIgQYxjvUj/OODeBshPsOdR7YMz2ubCnuU4b+JeqnkAqnvG2yzoLL4pVogWFcQlACTUv/g5J6sVqzuCiqByxxmXLCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9FEWI+Mu3FCaR/ob7J4Ho5auTDYHoiCQQ5iGwusxYkY=; b=AIIE7uvBQcXvNqia0QG/vtlp0gJTgGCmCDNpbHrjwn0oB7i9Xft2s7OYyTGRsrxQHz/91BgQZQPeMMtb5SNM0Nwm0mJzXhCGw5ouHtjb9VdetKpFtUQTTUgR4bxp8kj39WcpQAheC+12CQOjnifjYdzhFDZFhx9Y11l4Pv7v4QLYZ7hCOo0U0xV1RbxQkQtMlsy/Pd8iSyQPh+Tmv/MwZDtsvia7qaRKEijX8dV8f/r8nqhjKFSXEsv2oTxhAulXxcHaYDQrmSeLSkbBddZSKkRCD02ykfcpe0099KsVfJHN6LFdn5oJLv1pGVnJgsWXgrqcUJZB3pKGQXDCBeRehA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9FEWI+Mu3FCaR/ob7J4Ho5auTDYHoiCQQ5iGwusxYkY=; b=kXnalXmN9eztwE5KlJap/Hc2gKhOWucGm4oDIoXTDJiBMAd00WBh080lU/ZCvf7qSra/nS56VGD8gQgF0IFtFbxGAfb5B8B2g9ffUc7DBbOPComNH4aCqUIT42J2npJ+nO0aOT281FxPQxF9KrdwXwgXjWdj8aKDmzzy0qz5JtG6T/7Kl5taC3zN2/aP4x1YgDEAA7VVDyKn7Au7uYABvx5NRIgKfZcoO1ckoAcCMnrQ+wirIiOS++Yj6FoJmwluKHCPOCLgKUWOjCUsXWoiK+RxCJhdqPwWj4FaMP0xgBCCduI68SS2z0+zV7Z5+PFGnZKaIx6BLEhPC1csemb1IA== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com; From: Mykola Kvach To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jens Wiklander Subject: [PATCH v5 0/4] xen/arm: Fix eSPI IRQ handling Date: Thu, 24 Sep 2026 23:57:52 +0300 Message-ID: X-Mailer: git-send-email 2.53.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: WA0P291CA0022.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1::22) To DB3PR0302MB9208.eurprd03.prod.outlook.com (2603:10a6:10:430::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB3PR0302MB9208:EE_|GV1PR03MB10503:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ce9cfcf-ff79-42ec-27a9-08df1a7e8a37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|23010399003|7416014|376014|1800799024|11063799006|56012099006|10067099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: yx6ZVKPKYcsT8wYFACGpqNzvb41uFqAeN8Irl6zQsT1inwLGukEAIXDOX5c4/jWei8TC5e0LpeVSQIf1eOIdqxcuDAx+7YEmKUezkYxxNQXWPbjglxWcqNMim1zuaW/5FTkwyAbDFoacsmMwP39xnrwKN9oU3ekAK7GMd4ROx5EXH2bY/kKAmw6TAOwsPfapXv11u5hF4IOfNYQBOxghY9ZAlJSF3ly92R7UBkmjH0Ui+mDoGbmefzH9/8BXlLMkisL9bzA9CDH5oHtddxIPm+xeyS5fReGX/hWx5AqyGXkeH0e6ULkKRr1wjKEaD+AadXDgvnl2wiBpDPCbM+Z+AR698aHCZr/R92bKlA4SRmNmo44e8kmliznnW4dOPqQlEvexx2fsyTzPR1smUjxaYPJ28UWdhjawtn1uQEkVXuWXOxuj43rMdz5ke7oGe/6upTRuMbqzCdqNYAs6Cadki5UcO2WWu9M3PmcAg2WXJnLUIuMqdc1z1wHkMUS2ZKcKE6Agmuj5Pdg68+MCL36pZt10eox0urFOGyGrVQU0MtDTVyFx/jngtv+todtHypdqGc/gFuhFeO8FlAkcUHR/Frk2Ck1gNK4991/u6a6Ln4Q1084btNauvA3RIW4hpA4/2eUFwpRLWNvLscCcIWTHPj/LYY8HpYh8bqMpECJYSCo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB3PR0302MB9208.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(23010399003)(7416014)(376014)(1800799024)(11063799006)(56012099006)(10067099003)(18002099003)(6133799003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pAHWxusjT+tKjiIt+0hMMVC2ztXEpOG4ByxVSVA4F6jgnbaNnD5N9TJ0xm5I?= =?us-ascii?Q?GKiE0fZarQMyaoKHCbvOr7vIordpqhAtCLcE7b2au1k2yhJ8zH8n4MSdRraH?= =?us-ascii?Q?Fqo3ZRIh0j2QoMYF6fUsoD6DnvztMKnKrMbJUeqftAvCqQNOMkAGkdkGhz4/?= =?us-ascii?Q?frtpFyr0cYQWGmEuvw4E98Nh3i4G261pfcjybgq6CdpmPsrShXN02eveRMpM?= =?us-ascii?Q?wQKYRmwQYwYsj6uKrde8tZGBQga4B/qvh9oNZtEz7dWib0BBGE9xM7ACMV1y?= =?us-ascii?Q?SjCvWJmXOUxe6SXRPL0HkLlSuj0KEWEKjLYQFNZJsH3njbywEBBC9p/Kr2iS?= =?us-ascii?Q?TY2b3VhcMFa2r0XDDwvYRoxmRIRe8kHW4cKX+viklkjUuJWlWkHP5eXMzlBE?= =?us-ascii?Q?SjFJyinlns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AOcHMZ2E?= =?us-ascii?Q?ToFFJUhwjgKt+0I3S47dNuS1u8o6oTpQgk3Q+lulCMyBEp8c7D8YTDnufTLE?= =?us-ascii?Q?14u+d6HvUGIhDyA+l2BCVn4OqLedGV7MxWr2OvLbFQda0aeV4XZJ1MN6w/ms?= =?us-ascii?Q?EBpvMaTq/On/NJtjZ8bpWxyjXN6V6HiV51ZNjISRyV+4ND9Bg2RqK9wwAxck?= =?us-ascii?Q?kKhTZJVhj2YWmGw7Y2Wu+aar3tAoADwYiYpQ7wf6H8AWS6n6WC8rfgMWcLo0?= =?us-ascii?Q?UbPyxBCG8M/SsS1LmbBh27jOpipNx9pYKJGlrEIv/fMceYrGm0hnOKwAiyV0?= =?us-ascii?Q?lhsixivR2lA1PHVFab8IX4Up34vBc+pUNo056O0NNOOTSTVDlgJzMGGUK61r?= =?us-ascii?Q?90Dh1/C9Vga1v0jVSV2AZPfI9JvWF9knfAPx7Tw/4OPTqtwANq6OvgOCMUlx?= =?us-ascii?Q?6js9w6+HMw=3D=3D?= X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ce9cfcf-ff79-42ec-27a9-08df1a7e8a37 X-MS-Exchange-CrossTenant-AuthSource: DB3PR0302MB9208.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2026 20:58:09.8672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vC9H98kbc3bRk/kgDNnJhyDZoWd0uvd1C68vq/qyUcf5Zc0Hj9owXU3q62l08EoKGP7zsc/VpitcavzmO823Vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR03MB10503 X-purgate-ID: tlsNG-bad1c0/1790283495-BFCD7034-44A4E690/0/0 X-purgate-type: clean X-purgate-size: 5223 This series fixes sparse eSPI INTID handling and checks errors returned by irq_set_type(). Patch 1 checks irq_set_type() failures in the GTDT, MADT, SPCR, and FF-A paths. GTDT and MADT could retain rejected timer or maintenance INTIDs and later use them in direct descriptor lookups. This patch also fixes MISRA C Rule 17.7 violations. It is now first in the series, as requested during review, so callers handle errors before stricter IRQ validation is introduced. Patch 2 makes is_espi() check the architectural INTID range regardless of CONFIG_GICV3_ESPI. If the GIC reports an eSPI without compiled-in support, Xen stops with BUG_ON(), as there is no descriptor or pending_irq storage for it. Virtual eSPI pending lookups without support are treated as unreachable: the stub asserts in debug builds and retains a NULL return. Xen has IRQ descriptors for INTIDs below NR_IRQS and, with eSPI support, for eSPIs starting at 4096. It has no descriptors for INTIDs 1024 through 4095. Patch 3 checks INTIDs in setup_irq() and irq_set_spi_type() before descriptor lookup. irq_set_spi_type() checks descriptor-backed ranges because it can run before the GIC line counts are known. setup_irq() checks implemented lines using those counts. Patch 4 fixes the vGIC allocation bitmap. Reserving an eSPI used a compact bitmap index, but freeing it used the raw virtual INTID. This could write past the bitmap and leave the eSPI reserved. Both vGIC implementations now use vgic_is_valid_line() when reserving and freeing vIRQs. Testing of the v5 review changes, before the latest rebase and reordering: - Arm64 build with CONFIG_NEW_VGIC=y, CONFIG_GICV2=y, and CONFIG_DEBUG=y. - QEMU GICv2 guest tests: 10 checks passed, covering SPI delivery, enable/disable behavior, affinity changes, SGIs, and the virtual timer. Testing from earlier revisions, before the final v5 edits: - QEMU and FVP tests with CONFIG_GICV3_ESPI, CONFIG_HAS_ITS, and CONFIG_DEBUG enabled and disabled. - Physical and virtual eSPI delivery on FVP, including delivery to both vCPUs and retriggering an active eSPI. - Injected an unsupported physical eSPI and confirmed BUG_ON() in both debug and release builds. - Arm64 builds with CONFIG_GICV3_ESPI and CONFIG_DEBUG enabled and disabled. - Arm64 debug builds with CONFIG_ACPI=y and CONFIG_FFA=y, both with and without CONFIG_GICV3_ESPI. - FVP Device Tree boot with 64 eSPIs; Linux dom0 started. - QEMU virt UEFI/ACPI boot to a dom0 initramfs shell, covering the GTDT, GICv3 MADT, and PL011 SPCR paths. Changes in v5: - Move the irq_set_type() error-handling patch to the beginning. - Explain why an eSPI cannot be handled without compiled-in support. - Make both espi_to_pending() helpers static inline and constify d. - Add ASSERT_UNREACHABLE() to the disabled-eSPI stub. - Preserve the unmapped LPI comment and clarify that eSPI lookup without support must not occur. - Add the vgic_is_valid_line() guard to vgic_free_virq() in the new vGIC implementation and use the same helper in vgic_reserve_virq(). Changes in v4: - Use BUG_ON() when the GIC reports an eSPI without compiled-in support. - Return NULL for virtual eSPI pending lookups when support is disabled. - Remove the redundant CONFIG_GICV3_ESPI check in IRQ dispatch. - Share irq_has_desc() with the assertion in __irq_to_desc(). - Log invalid IRQs rejected by setup_irq(). - Document the compressed vIRQ allocation bitmap above the conversion helpers, with an ASCII diagram and a reference to struct vgic_dist. - Clarify the is_espi() commit message and drop unrelated blank-line removals. - Add Reviewed-by tags. Changes in v3: - Add a preparatory patch making is_espi() a pure range predicate and move configuration policy and debug checks to callers. - Add the requested assertion before regular descriptor lookup. - Avoid partial MADT and UART state updates after irq_set_type() failures. - Apply cosmetic cleanups from review. Changes in v2: - Check descriptor ranges in irq_set_spi_type() and implemented GIC lines in setup_irq(). - Keep the is_espi() debug check when CONFIG_GICV3_ESPI is disabled. - Remove a redundant CONFIG_GICV3_ESPI guard from the vGIC code. - Add a patch checking irq_set_type() errors in the GTDT, MADT, SPCR, and FF-A paths. - Target master instead of the 4.22 release. Mykola Kvach (4): xen/arm: handle irq_set_type() failures xen/arm: make is_espi() a pure range predicate xen/arm: validate IRQs before descriptor lookup xen/arm: vgic: free eSPIs using the bitmap index xen/arch/arm/gic-v2.c | 15 ++++--- xen/arch/arm/gic-v3.c | 15 ++++--- xen/arch/arm/gic.c | 6 +++ xen/arch/arm/include/asm/irq.h | 11 ------ xen/arch/arm/irq.c | 28 +++++++++++-- xen/arch/arm/tee/ffa_notif.c | 11 +++++- xen/arch/arm/time.c | 18 +++++++-- xen/arch/arm/vgic.c | 72 +++++++++++++++++++++++----------- xen/arch/arm/vgic/vgic.c | 5 ++- xen/drivers/char/ns16550.c | 8 +++- xen/drivers/char/pl011.c | 4 +- 11 files changed, 135 insertions(+), 58 deletions(-) -- 2.53.0