From: Pengpeng Hou <hppiscas@163.com>
To: radu@rendec.net, tglx@kernel.org
Cc: Pengpeng Hou <hppiscas@163.com>,
Charles Mirabile <cmirabil@redhat.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
Lucas Zampieri <lzampier@redhat.com>,
Paul Walmsley <pjw@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>
Subject: [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
Date: Sun, 20 Sep 2026 21:06:53 +0800 [thread overview]
Message-ID: <caplitmus-rv.v2.plic.87a8fc444de44e109889ba28703c76f3@163.com> (raw)
__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")
Assisted-by: gpt 5
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
Changes since v1: https://lore.kernel.org/r/20260825151000.1-plic-bit31-caplitmus-rv@iscas.ac.cn/
- Fix the Fixes tag as requested by Radu; keep the code change unchanged.
- Rebase on 518e5b794c06.
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 5b0dac1..d3d4187 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -108,7 +108,7 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type);
static void __plic_toggle(struct plic_handler *handler, int hwirq, int enable)
{
u32 __iomem *base = handler->enable_base;
- u32 hwirq_mask = 1 << (hwirq % 32);
+ u32 hwirq_mask = BIT(hwirq % 32);
int group = hwirq / 32;
u32 value;
base-commit: 518e5b794c06c0f0eb40df3e202274a66202c137
next reply other threads:[~2026-09-20 13:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 13:06 Pengpeng Hou [this message]
2026-10-14 8:58 ` Pengpeng Hou
2026-10-15 9:54 ` [tip: irq/drivers] " tip-bot2 for Pengpeng Hou
2026-11-01 22:16 ` [PATCH v2] " patchwork-bot+linux-riscv
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=caplitmus-rv.v2.plic.87a8fc444de44e109889ba28703c76f3@163.com \
--to=hppiscas@163.com \
--cc=cmirabil@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lzampier@redhat.com \
--cc=pjw@kernel.org \
--cc=radu@rendec.net \
--cc=samuel.holland@sifive.com \
--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
all inboxes | Powered by JetHome®