Skip to content

Commit fa26198

Browse files
arndbjoergroedel
authored andcommitted
iommu/io-pgtable-arm: dynamically allocate selftest device struct
In general a 'struct device' is way too large to be put on the kernel stack. Apparently something just caused it to grow a slightly larger, which pushed the arm_lpae_do_selftests() function over the warning limit in some configurations: drivers/iommu/io-pgtable-arm.c:1423:19: error: stack frame size (1032) exceeds limit (1024) in 'arm_lpae_do_selftests' [-Werror,-Wframe-larger-than] 1423 | static int __init arm_lpae_do_selftests(void) | ^ Change the function to use a dynamically allocated faux_device instead of the on-stack device structure. Fixes: ca25ec2 ("iommu/io-pgtable-arm: Remove iommu_dev==NULL special case") Link: https://lore.kernel.org/all/ab75a444-22a1-47f5-b3c0-253660395b5a@arm.com/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/20250423164826.2931382-1-arnd@kernel.org Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 21c0357 commit fa26198

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/bitops.h>
1414
#include <linux/io-pgtable.h>
1515
#include <linux/kernel.h>
16+
#include <linux/device/faux.h>
1617
#include <linux/sizes.h>
1718
#include <linux/slab.h>
1819
#include <linux/types.h>
@@ -1437,15 +1438,17 @@ static int __init arm_lpae_do_selftests(void)
14371438
};
14381439

14391440
int i, j, k, pass = 0, fail = 0;
1440-
struct device dev;
1441+
struct faux_device *dev;
14411442
struct io_pgtable_cfg cfg = {
14421443
.tlb = &dummy_tlb_ops,
14431444
.coherent_walk = true,
1444-
.iommu_dev = &dev,
14451445
};
14461446

1447-
/* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
1448-
set_dev_node(&dev, NUMA_NO_NODE);
1447+
dev = faux_device_create("io-pgtable-test", NULL, 0);
1448+
if (!dev)
1449+
return -ENOMEM;
1450+
1451+
cfg.iommu_dev = &dev->dev;
14491452

14501453
for (i = 0; i < ARRAY_SIZE(pgsize); ++i) {
14511454
for (j = 0; j < ARRAY_SIZE(address_size); ++j) {
@@ -1465,6 +1468,8 @@ static int __init arm_lpae_do_selftests(void)
14651468
}
14661469

14671470
pr_info("selftest: completed with %d PASS %d FAIL\n", pass, fail);
1471+
faux_device_destroy(dev);
1472+
14681473
return fail ? -EFAULT : 0;
14691474
}
14701475
subsys_initcall(arm_lpae_do_selftests);

0 commit comments

Comments
 (0)