lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250620115149.132845-1-arnd@kernel.org>
Date: Fri, 20 Jun 2025 13:51:42 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Robin Murphy <robin.murphy@....com>,
	Will Deacon <will@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Nathan Chancellor <nathan@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>,
	Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>,
	Ilkka Koskinen <ilkka@...amperecomputing.com>,
	linux-arm-kernel@...ts.infradead.org,
	linux-perf-users@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Subject: [PATCH] perf/arm-cmn: reduce stack usage in arm_cmn_probe()

From: Arnd Bergmann <arnd@...db.de>

This function has a rather large stack usage, which triggers the
warning limit with clang if I reduce the default to 1280 bytes:

drivers/perf/arm-cmn.c:2541:12: error: stack frame size (1312) exceeds limit (1280) in 'arm_cmn_probe' [-Werror,-Wframe-larger-than]

This is a combination of two problems:

 - The arm_cmn_discover() function has some large local variables and
   gets inlined here by clang (but not gcc)

 - The (struct pmu) assignment adds an extra copy of the pmu structure
   on the stack and does a memcpy() from that

Address the first one here by marking arm_cmn_discover() as noinline_for_stack,
making clang behave more like gcc here. This gets it under the warning
limit, though the total stack usage does not actually get reduced.

It would be nice to also change the way struct pmu is initialized, but I
see that this is done consistently for all pmu drivers. Ideally the function
pointers should be moved into a 'static const' structure per driver as this
is done in most other subsystems.

Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 drivers/perf/arm-cmn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 031d45d0fe3d..430c89760391 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2243,7 +2243,8 @@ static enum cmn_node_type arm_cmn_subtype(enum cmn_node_type type)
 	}
 }
 
-static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
+static noinline_for_stack int arm_cmn_discover(struct arm_cmn *cmn,
+					       unsigned int rgn_offset)
 {
 	void __iomem *cfg_region;
 	struct arm_cmn_node cfg, *dn;
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ