irqchip/gic-v5: Fix kmemleak L2 IST table entries false positives
Subsystems (3)
Lorenzo Pieralisi
maintainerPATCH 1/1 irqchip/gic-v5: Fix kmemleak L2 IST table entries false positives
L2 IST table entries are allocated with the kmalloc interface and their physical addresses are programmed in the GIC (either IST base address register or L1 IST table entries) but their virtual addresses are not stored in any kernel data structure because they are not needed at runtime - the L2 IST table entries are managed through system instructions but never dereferenced directly by the driver.
This triggers kmemleak false positive reports:
unreferenced object 0xffff00080039a000 (size 4096):
comm "swapper/0", pid 0, jiffies 4294892296 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 0):
kmemleak_alloc+0x34/0x40
__kmalloc_noprof+0x320/0x464
gicv5_irs_iste_alloc+0x1a4/0x484
gicv5_irq_lpi_domain_alloc+0xe4/0x194
irq_domain_alloc_irqs_parent+0x78/0xd8
gicv5_irq_ipi_domain_alloc+0x180/0x238
irq_domain_alloc_irqs_locked+0x238/0x7d4
__irq_domain_alloc_irqs+0x88/0x114
gicv5_of_init+0x284/0x37c
of_irq_init+0x3b8/0xb18
irqchip_init+0x18/0x40
init_IRQ+0x104/0x164
start_kernel+0x1a4/0x3d4
__primary_switched+0x8c/0x94Instruct kmemleak to ignore L2 IST table memory allocation virtual addresses to prevent these false positive reports.
--- drivers/irqchip/irq-gic-v5-irs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic-v5-irs.c +3 -0
@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h>
@@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);return 0 ; }
@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);/* * Make sure we invalidate the cache line pulled before the IRS
Signature · 1 line
2.48.0
Quoted 65 lines · Lorenzo Pieralisi
L2 IST table entries are allocated with the kmalloc interface and their physical addresses are programmed in the GIC (either IST base address register or L1 IST table entries) but their virtual addresses are not stored in any kernel data structure because they are not needed at runtime - the L2 IST table entries are managed through system instructions but never dereferenced directly by the driver.
This triggers kmemleak false positive reports:
unreferenced object
0xffff00080039a000(size 4096):
comm "swapper/0", pid 0, jiffies 4294892296 hex dump (first 32 bytes):00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 0): kmemleak_alloc+0x34/0x40 __kmalloc_noprof+0x320/0x464 gicv5_irs_iste_alloc+0x1a4/0x484 gicv5_irq_lpi_domain_alloc+0xe4/0x194 irq_domain_alloc_irqs_parent+0x78/0xd8 gicv5_irq_ipi_domain_alloc+0x180/0x238 irq_domain_alloc_irqs_locked+0x238/0x7d4 __irq_domain_alloc_irqs+0x88/0x114 gicv5_of_init+0x284/0x37c of_irq_init+0x3b8/0xb18 irqchip_init+0x18/0x40 init_IRQ+0x104/0x164 start_kernel+0x1a4/0x3d4 __primary_switched+0x8c/0x94Instruct kmemleak to ignore L2 IST table memory allocation virtual addresses to prevent these false positive reports.
Reported-by Jinjie Ruan <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>--- drivers/irqchip/irq-gic-v5-irs.c | 3 +++ 1 file changed, 3 insertions(+)drivers/irqchip/irq-gic-v5-irs.c +2
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h> @@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);return 0 ; }
drivers/irqchip/irq-gic-v5-irs.c int gicv5_irs_iste_alloc(const u32 lpi) · line 240
Quoted 7 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);/* * Make sure we invalidate the cache line pulled before the IRS
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 64 lines · Lorenzo Pieralisi
L2 IST table entries are allocated with the kmalloc interface and their physical addresses are programmed in the GIC (either IST base address register or L1 IST table entries) but their virtual addresses are not stored in any kernel data structure because they are not needed at runtime - the L2 IST table entries are managed through system instructions but never dereferenced directly by the driver.
This triggers kmemleak false positive reports:
unreferenced object
0xffff00080039a000(size 4096):
comm "swapper/0", pid 0, jiffies 4294892296 hex dump (first 32 bytes):00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 0): kmemleak_alloc+0x34/0x40 __kmalloc_noprof+0x320/0x464 gicv5_irs_iste_alloc+0x1a4/0x484 gicv5_irq_lpi_domain_alloc+0xe4/0x194 irq_domain_alloc_irqs_parent+0x78/0xd8 gicv5_irq_ipi_domain_alloc+0x180/0x238 irq_domain_alloc_irqs_locked+0x238/0x7d4 __irq_domain_alloc_irqs+0x88/0x114 gicv5_of_init+0x284/0x37c of_irq_init+0x3b8/0xb18 irqchip_init+0x18/0x40 init_IRQ+0x104/0x164 start_kernel+0x1a4/0x3d4 __primary_switched+0x8c/0x94Instruct kmemleak to ignore L2 IST table memory allocation virtual addresses to prevent these false positive reports.
Reported-by Jinjie Ruan <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>--- drivers/irqchip/irq-gic-v5-irs.c | 3 +++ 1 file changed, 3 insertions(+)drivers/irqchip/irq-gic-v5-irs.c +2
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h> @@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);return 0 ; }
drivers/irqchip/irq-gic-v5-irs.c int gicv5_irs_iste_alloc(const u32 lpi) · line 237
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);
Thanks,
Zenghui
Quoted 8 lines · Lorenzo Pieralisi
L2 IST table entries are allocated with the kmalloc interface and their physical addresses are programmed in the GIC (either IST base address register or L1 IST table entries) but their virtual addresses are not stored in any kernel data structure because they are not needed at runtime - the L2 IST table entries are managed through system instructions but never dereferenced directly by the driver.
[...]
Quoted 31 lines
Reported-by Jinjie Ruan <[email protected]>Signed-off-by Lorenzo Pieralisi <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>--- drivers/irqchip/irq-gic-v5-irs.c | 3 +++ 1 file changed, 3 insertions(+)drivers/irqchip/irq-gic-v5-irs.c +2
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h> @@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);return 0 ; }
drivers/irqchip/irq-gic-v5-irs.c int gicv5_irs_iste_alloc(const u32 lpi) · line 237
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);
Quoted 3 lines
drivers/irqchip/irq-gic-v5-irs.c +0
-0/* * Make sure we invalidate the cache line pulled before the IRS
The following commit has been merged into the irq/urgent branch of tip:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: 1a2cce5b91eeeac24104cbccd8cd3a4dfbdbaa7a Gitweb: https://git.kernel.org/tip/1a2cce5b91eeeac24104cbccd8cd3a4dfbdbaa7a Author: Lorenzo Pieralisi <[email protected]> AuthorDate: Mon, 11 Aug 2025 15:50:01 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Sun, 24 Aug 2025 12:12:53 +02:00
irqchip/gic-v5: Fix kmemleak L2 IST table entries false positives
L2 IST table entries are allocated with the kmalloc interface and their physical addresses are programmed in the GIC (either IST base address register or L1 IST table entries) but their virtual addresses are not stored in any kernel data structure because they are not needed at runtime
- the L2 IST table entries are managed through system instructions but never dereferenced directly by the driver.
This triggers kmemleak false positive reports:
unreferenced object 0xffff00080039a000 (size 4096):
comm "swapper/0", pid 0, jiffies 4294892296 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 0):
kmemleak_alloc+0x34/0x40
__kmalloc_noprof+0x320/0x464
gicv5_irs_iste_alloc+0x1a4/0x484
gicv5_irq_lpi_domain_alloc+0xe4/0x194
irq_domain_alloc_irqs_parent+0x78/0xd8
gicv5_irq_ipi_domain_alloc+0x180/0x238
irq_domain_alloc_irqs_locked+0x238/0x7d4
__irq_domain_alloc_irqs+0x88/0x114
gicv5_of_init+0x284/0x37c
of_irq_init+0x3b8/0xb18
irqchip_init+0x18/0x40
init_IRQ+0x104/0x164
start_kernel+0x1a4/0x3d4
__primary_switched+0x8c/0x94Instruct kmemleak to ignore L2 IST table memory allocation virtual addresses to prevent these false positive reports.
--- drivers/irqchip/irq-gic-v5-irs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic-v5-irs.c +3 -0
@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h>
@@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);return 0 ; }
@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);/* * Make sure we invalidate the cache line pulled before the IRS
Quoted 13 lines · Lorenzo Pieralisi
drivers/irqchip/irq-gic-v5-irs.c +1
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt +#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h>
drivers/irqchip/irq-gic-v5-irs.c static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_data · line 121
Quoted 4 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0@@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);
Nit: if you ever respin, please add a short comment on why this is a false positive (easier to see it in the code than the git logs).
drivers/irqchip/irq-gic-v5-irs.c int gicv5_irs_iste_alloc(const u32 lpi) · line 237
Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0return 0 ; }@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);
Same here.
Signature · 1 line
Catalin
Lorenzo Pieralisi
maintainerQuoted 9 lines · Catalin Marinas
Quoted 8 lines · Lorenzo Pieralisi
drivers/irqchip/irq-gic-v5-irs.c +0
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmt
Quoted 12 lines
drivers/irqchip/irq-gic-v5-irs.c static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_data · line 121
Quoted 9 lines
drivers/irqchip/irq-gic-v5-irs.c +2
-0+#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h> @@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);Nit: if you ever respin, please add a short comment on why this is a false positive (easier to see it in the code than the git logs).
It was merged as-is (have been away for a couple of weeks) but I can send a patch adding the comments to clarify the code as a follow-up.
Thanks,
Lorenzo
Quoted 13 lines
drivers/irqchip/irq-gic-v5-irs.c int gicv5_irs_iste_alloc(const u32 lpi) · line 237
Quoted 8 lines
drivers/irqchip/irq-gic-v5-irs.c +1
-0return 0 ; }@@ -232,6 +234,7 @@ int gicv5_irs_iste_alloc(const u32 lpi)kfree (l2ist);return ret; } +kmemleak_ignore (l2ist);Same here.
Signature · 1 line
Catalin
Quoted 23 lines · Lorenzo Pieralisi
Quoted 9 lines · Catalin Marinas
Quoted 8 lines · Lorenzo Pieralisi
drivers/irqchip/irq-gic-v5-irs.c +0
-0@@ -5,6 +5,7 @@#define pr_fmt (fmt) "GICv5 IRS: " fmtQuoted 12 lines
drivers/irqchip/irq-gic-v5-irs.c static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_data · line 121
Quoted 9 lines
drivers/irqchip/irq-gic-v5-irs.c +2
-0+#include <linux/kmemleak.h> #include <linux/log2.h> #include <linux/of.h> #include <linux/of_address.h> @@ -117,6 +118,7 @@ static int __init gicv5_irs_init_ist_linear(struct gicv5_irs_chip_data *irs_datakfree (ist);return ret; } +kmemleak_ignore (ist);Nit: if you ever respin, please add a short comment on why this is a false positive (easier to see it in the code than the git logs).
Quoted 2 lines
It was merged as-is (have been away for a couple of weeks) but I can send a patch adding the comments to clarify the code as a follow-up.
No need to. One can always do a git blame ;).
Signature · 1 line
Catalin