* [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
@ 2026-09-20 13:06 Pengpeng Hou
2026-10-14 8:58 ` Pengpeng Hou
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pengpeng Hou @ 2026-09-20 13:06 UTC (permalink / raw)
To: radu, tglx
Cc: Pengpeng Hou, Charles Mirabile, linux-kernel, linux-riscv,
Lucas Zampieri, Paul Walmsley, Samuel Holland
__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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
2026-09-20 13:06 [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Pengpeng Hou
@ 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
2 siblings, 0 replies; 4+ messages in thread
From: Pengpeng Hou @ 2026-10-14 8:58 UTC (permalink / raw)
To: radu, tglx
Cc: cmirabil, lzampier, pjw, samuel.holland, linux-kernel,
linux-riscv, hppiscas
Hi Radu, Thomas,
A brief follow-up on this v2. It corrects the Fixes tag as requested,
with the code change unchanged.
Please let me know whether it is queued or if any further changes are
needed.
Thanks,
Pengpeng
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: irq/drivers] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
2026-09-20 13:06 [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Pengpeng Hou
2026-10-14 8:58 ` Pengpeng Hou
@ 2026-10-15 9:54 ` tip-bot2 for Pengpeng Hou
2026-11-01 22:16 ` [PATCH v2] " patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Pengpeng Hou @ 2026-10-15 9:54 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Pengpeng Hou, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the irq/drivers branch of tip:
Commit-ID: 0f214e5bbee59d5952d3c061fd65ed9a1e175981
Gitweb: https://git.kernel.org/tip/0f214e5bbee59d5952d3c061fd65ed9a1e175981
Author: Pengpeng Hou <hppiscas@163.com>
AuthorDate: Sun, 20 Sep 2026 21:06:53 +08:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Thu, 15 Oct 2026 11:50:47 +02:00
irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
__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
---
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 70a7478..4156493 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;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
2026-09-20 13:06 [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Pengpeng Hou
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 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-11-01 22:16 UTC (permalink / raw)
To: Pengpeng Hou
Cc: linux-riscv, radu, tglx, cmirabil, linux-kernel, lzampier, pjw,
samuel.holland
Hello:
This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <tglx@kernel.org>:
On Sun, 20 Sep 2026 21:06:53 +0800 you wrote:
> __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.
>
> [...]
Here is the summary with links:
- [v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
https://git.kernel.org/riscv/c/0f214e5bbee5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-01 22:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-20 13:06 [PATCH v2] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Pengpeng Hou
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
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®