Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Charles Mirabile <cmirabil@redhat.com>
To: sashal@kernel.org
Cc: cmirabil@redhat.com, pjw@kernel.org, radu@rendec.net,
	samuel.holland@sifive.com, stable-commits@vger.kernel.org,
	stable@vger.kernel.org, tglx@kernel.org,
	Pengpeng Hou <hppiscas@163.com>
Subject: [PATCH] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
Date: Tue, 17 Nov 2026 21:04:45 -0500	[thread overview]
Message-ID: <20261118020449.1810623-1-cmirabil@redhat.com> (raw)
In-Reply-To: <2026-11-17-1-daily-reply-0007@kernel.org>

Hi—

On Tue, Nov 17, 2026 at 07:23:02PM -0500, Sasha Levin wrote:
> > This patch makes substantial changes to the driver and how it
> > processes interrupts. I am not sure it is a great candidate for
> > stable.
> 
> Agreed. I dropped it, and the BIT() fix that needed it, from the 6.18, 6.12,
> 6.6 and 6.1 queues. The same applies to your notices for the other three trees.
> 
> Could you send git-am-able BIT()-only backports of 0f214e5bbee5
> ("irqchip/sifive-plic: Avoid signed shift in interrupt enable mask"), one per
> tree ([PATCH 6.18.y] through [PATCH 6.1.y])? I'll queue them. 7.3 already has
> the cache patch in its base release, so it keeps the original fix.

The following (below the scissors) can be am'd on top of all of the trees.
I am not sure exactly what format is desirable for a stable commit, but I
did add the upstream commit hash and my SoB.

> 
> -- 
> Thanks,
> Sasha

Best—Charlie

-- >8 --
commit 9ebdbab003ec949b3739f548f527c18b811d6568
Author: Pengpeng Hou <hppiscas@163.com>
Date: Sun, 20 Sep 2026 21:06:53 +0800

[Upstream commit 0f214e5bbee59d5952d3c061fd65ed9a1e175981]

__plic_toggle() builds a 32-bit interrupt enable mask using a signed
integer literal. A valid interrupt selecting bit 31 evaluates 1 << 31,
which shifts a signed int into its sign bit.

Use BIT(), matching the equivalent mask construction in plic_irq_eoi().
The resulting mask remains representable in u32 on both RV32 and RV64.

The issue was found by our static-analysis tool.

Fixes: 8237f8bc4f6e ("irqchip: add a SiFive PLIC driver")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Assisted-by: gpt 5
Link: https://patch.msgid.link/caplitmus-rv.v2.plic.87a8fc444de44e109889ba28703c76f3@163.com
Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
---
 drivers/irqchip/irq-sifive-plic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index ca70641982ed6..0995e1fdd5b47 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -97,7 +97,7 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type);
 static void __plic_toggle(void __iomem *enable_base, int hwirq, int enable)
 {
 	u32 __iomem *reg = enable_base + (hwirq / 32) * sizeof(u32);
-	u32 hwirq_mask = 1 << (hwirq % 32);
+	u32 hwirq_mask = BIT(hwirq % 32);
 
 	if (enable)
 		writel(readl(reg) | hwirq_mask, reg);
-- 
2.56.0



  parent reply	other threads:[~2026-11-18  2:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261117161945.1965350-1-sashal@kernel.org>
2026-11-17 17:01 ` Patch "irqchip/sifive-plic: Cache the interrupt enable state" has been added to the 6.18-stable tree Charles Mirabile
2026-11-18  0:19   ` Sasha Levin
2026-11-18  0:23     ` Sasha Levin
2026-11-18  2:04     ` Charles Mirabile [this message]
2026-11-19 16:08   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118020449.1810623-1-cmirabil@redhat.com \
    --to=cmirabil@redhat.com \
    --cc=hppiscas@163.com \
    --cc=pjw@kernel.org \
    --cc=radu@rendec.net \
    --cc=samuel.holland@sifive.com \
    --cc=sashal@kernel.org \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox