[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/4] xen/drivers/char/pl011: fix IRQ registration failure propagation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Date: Thu, 9 Apr 2026 13:50:26 +0000
  • Accept-language: en-US
  • 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
  • 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=oAfXz+4yU574RkHhJeRj5xLLKToN+/aJ1HqmB1NjL18=; b=lBFWPfHaIA9xCfDpBnKdi7P+xkmArhsVhfSbBUACKq+vsv7MaCpNgpaZOclRTdo48D5taV9/5riGPl5z4PhcWUNlfJlVkOTlVlk59FxdsFH9sTt8d8zVRe6kjNctdIU7NodHQxS6OSXjltgxqgSrtbX0yKiNyn99BWEJ5cE600xGvkgNj43DcXV88KOjhcsh2ZkstL12T9yzMD8v8Or6jdDvluCQ5CsKEk3nS4gLmgGOTKWLunAvv3Ikf9Kf+J/XUoIYXFLkk5b4Hy0IijU5YpeM6uzkaaIMjiSA1OZh/c0gjS5PbVcMxKMULL2tIXkmqoiMsLv1SvxoqgKFcQ2IsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZEfJF4ynxgz78H1SxcSfW8YAO81vVYou7L3/yqCJ9By+AdlBgJDI85NWr1y//DKwfEa1aDxPyx2OkwTBVjw1cQjlQs7CvGFJxzTUD6bJI835auTSTeK7sE2ubxXc5PSxq4ubGJnZwcqZjQlPBgUsiWQn6dgikC87MK9T/qqmtZihB27M1IOboMRhZmc0EJGf/hX/VbbA/0DXFEUx1TXo/ObPQX2GTg5JdfcFSguNw4nxTy9KANDFYhVWBpHMVBpOC0PtpUhDfqTexb2sRG9bHk7j99EigABQMRVHH1hWuR1A4+/Kzdp7VTgMTXSVV8cRB7B7R5vkliqhm4wZ1Hqivg==
  • 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"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Delivery-date: Thu, 09 Apr 2026 13:50:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcyCfRI6UUL+j1Mk2LAfnsFV7fPA==
  • Thread-topic: [PATCH v2 2/4] xen/drivers/char/pl011: fix IRQ registration failure propagation

In pl011_init_postirq(), two code paths could reach the
interrupt-unmask write to IMSC without a handler being registered:

- When no valid IRQ number was provided (uart->irq <= 0), the original
  positive-condition guard (if uart->irq > 0) skipped the irqaction
  setup but still fell through to the IMSC write, unmasking
  RTI|OEI|BEI|PEI|FEI|TXI|RXI with no handler installed.

- When setup_irq() returned an error, only an error message was
  printed and execution continued to the IMSC write, arming all
  hardware interrupt lines with no handler to service them. On
  platforms where the GIC receives these asserted lines, the result
  is either repeated spurious-interrupt warnings or an unhandled
  interrupt fault.

Restructure pl011_init_postirq() to use early returns: return
immediately when no valid IRQ is provided, and return after logging
the error when setup_irq() fails. The interrupt-enable write to IMSC
is only reached when IRQ registration succeeds.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
---



 xen/drivers/char/pl011.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 5f9913367d..918b9d4d4a 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -150,13 +150,18 @@ static void __init pl011_init_postirq(struct serial_port 
*port)
     struct pl011 *uart = port->uart;
     int rc;
 
-    if ( uart->irq > 0 )
+    /* Don't unmask interrupts if no valid irq was provided */
+    if ( uart->irq <= 0 )
+        return;
+
+    uart->irqaction.handler = pl011_interrupt;
+    uart->irqaction.name    = "pl011";
+    uart->irqaction.dev_id  = port;
+    if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
     {
-        uart->irqaction.handler = pl011_interrupt;
-        uart->irqaction.name    = "pl011";
-        uart->irqaction.dev_id  = port;
-        if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
-            printk("ERROR: Failed to allocate pl011 IRQ %d\n", uart->irq);
+        printk("ERROR: Failed to allocate pl011 IRQ %d\n", uart->irq);
+        /* Do not unmask interrupts if irq handler wasn't set */
+        return;
     }
 
     /* Clear pending error interrupts */
-- 
2.43.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.