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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231215150040.3342183-3-james.clark@arm.com>
Date: Fri, 15 Dec 2023 15:00:39 +0000
From: James Clark <james.clark@....com>
To: linux-arm-kernel@...ts.infradead.org,
	linux-perf-users@...r.kernel.org,
	linux-next@...r.kernel.org,
	will@...nel.org,
	u.kleine-koenig@...gutronix.de
Cc: James Clark <james.clark@....com>,
	Mark Rutland <mark.rutland@....com>,
	Nathan Chancellor <nathan@...nel.org>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>,
	Anshuman Khandual <anshuman.khandual@....com>,
	Suzuki K Poulose <suzuki.poulose@....com>,
	linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Subject: [PATCH 2/2] arm: perf: Fix ARCH=arm build with GCC in armv8pmu_set_event_filter()

LLVM ignores everything inside the if statement and doesn't generate
errors, but GCC does, resulting in the following:

  drivers/perf/arm_pmuv3.c: In function armv8pmu_set_event_filter:
  include/linux/bits.h:34:29: error: left shift count >= width of type [-Werror=shift-count-overflow]
  34 |         (((~UL(0)) - (UL(1) << (l)) + 1) & \

Fix it by changing the if to #if. This results in an unused function
warning for armv8pmu_event_threshold_control(), so suppress that too.

Fixes: 816c26754447 ("arm64: perf: Add support for event counting threshold")
Signed-off-by: James Clark <james.clark@....com>
---
 drivers/perf/arm_pmuv3.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c
index 3ed2086cefc3..8aa23878019a 100644
--- a/drivers/perf/arm_pmuv3.c
+++ b/drivers/perf/arm_pmuv3.c
@@ -338,7 +338,7 @@ static bool armv8pmu_event_want_user_access(struct perf_event *event)
 	return ATTR_CFG_GET_FLD(&event->attr, rdpmc);
 }
 
-static u8 armv8pmu_event_threshold_control(struct perf_event_attr *attr)
+static __maybe_unused u8 armv8pmu_event_threshold_control(struct perf_event_attr *attr)
 {
 	u8 th_compare = ATTR_CFG_GET_FLD(attr, threshold_compare);
 	u8 th_count = ATTR_CFG_GET_FLD(attr, threshold_count);
@@ -1040,11 +1040,13 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
 		return -EINVAL;
 	}
 
-	if (IS_ENABLED(CONFIG_ARM64) && th) {
+#if IS_ENABLED(CONFIG_ARM64)
+	if (th) {
 		config_base |= FIELD_PREP(ARMV8_PMU_EVTYPE_TH, th);
 		config_base |= FIELD_PREP(ARMV8_PMU_EVTYPE_TC,
 					  armv8pmu_event_threshold_control(attr));
 	}
+#endif
 
 	/*
 	 * Install the filter into config_base as this is used to
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ