* [PATCH v2 0/1] arm: perf: Fix ARCH=arm build with GCC
@ 2023-12-15 17:56 James Clark
2023-12-15 17:56 ` [PATCH v2 1/1] " James Clark
2023-12-17 13:41 ` [PATCH v2 0/1] " Will Deacon
0 siblings, 2 replies; 5+ messages in thread
From: James Clark @ 2023-12-15 17:56 UTC (permalink / raw)
To: linux-arm-kernel, linux-perf-users, linux-next, will,
u.kleine-koenig, mark.rutland
Cc: James Clark, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Suzuki K Poulose, Anshuman Khandual, linux-kernel,
llvm
Changes since V1:
* Instead of wrapping everything in #if, just use GENMASK_ULL instead
which fixes both issues in one commit.
A fix for the broken build with GCC currently in linux-next
(next-20231214)
James Clark (1):
arm: perf: Fix ARCH=arm build with GCC
include/linux/perf/arm_pmuv3.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] arm: perf: Fix ARCH=arm build with GCC
2023-12-15 17:56 [PATCH v2 0/1] arm: perf: Fix ARCH=arm build with GCC James Clark
@ 2023-12-15 17:56 ` James Clark
2023-12-15 18:20 ` Uwe Kleine-König
2023-12-16 12:44 ` Mark Rutland
2023-12-17 13:41 ` [PATCH v2 0/1] " Will Deacon
1 sibling, 2 replies; 5+ messages in thread
From: James Clark @ 2023-12-15 17:56 UTC (permalink / raw)
To: linux-arm-kernel, linux-perf-users, linux-next, will,
u.kleine-koenig, mark.rutland
Cc: James Clark, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Anshuman Khandual, Suzuki K Poulose, linux-kernel,
llvm
LLVM ignores everything inside the if statement and doesn't generate
errors, but GCC doesn't ignore it, resulting in the following error:
drivers/perf/arm_pmuv3.c: In function ‘armv8pmu_write_evtype’:
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 using GENMASK_ULL which doesn't overflow on arm32 (even though
the value is never used there).
Fixes: 3115ee021bfb ("arm64: perf: Include threshold control fields in PMEVTYPER mask")
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Closes: https://lore.kernel.org/linux-arm-kernel/20231215120817.h2f3akgv72zhrtqo@pengutronix.de/
Signed-off-by: James Clark <james.clark@arm.com>
---
include/linux/perf/arm_pmuv3.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h
index 0f4d62ef3a9a..46377e134d67 100644
--- a/include/linux/perf/arm_pmuv3.h
+++ b/include/linux/perf/arm_pmuv3.h
@@ -234,8 +234,8 @@
* PMXEVTYPER: Event selection reg
*/
#define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */
-#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32)
-#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61)
+#define ARMV8_PMU_EVTYPE_TH GENMASK_ULL(43, 32) /* arm64 only */
+#define ARMV8_PMU_EVTYPE_TC GENMASK_ULL(63, 61) /* arm64 only */
/*
* Event filters for PMUv3
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] arm: perf: Fix ARCH=arm build with GCC
2023-12-15 17:56 ` [PATCH v2 1/1] " James Clark
@ 2023-12-15 18:20 ` Uwe Kleine-König
2023-12-16 12:44 ` Mark Rutland
1 sibling, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2023-12-15 18:20 UTC (permalink / raw)
To: James Clark
Cc: linux-arm-kernel, linux-perf-users, linux-next, will,
mark.rutland, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Anshuman Khandual, Suzuki K Poulose, linux-kernel,
llvm
[-- Attachment #1.1: Type: text/plain, Size: 1881 bytes --]
On Fri, Dec 15, 2023 at 05:56:48PM +0000, James Clark wrote:
> LLVM ignores everything inside the if statement and doesn't generate
> errors, but GCC doesn't ignore it, resulting in the following error:
>
> drivers/perf/arm_pmuv3.c: In function ‘armv8pmu_write_evtype’:
> 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 using GENMASK_ULL which doesn't overflow on arm32 (even though
> the value is never used there).
>
> Fixes: 3115ee021bfb ("arm64: perf: Include threshold control fields in PMEVTYPER mask")
> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Closes: https://lore.kernel.org/linux-arm-kernel/20231215120817.h2f3akgv72zhrtqo@pengutronix.de/
> Signed-off-by: James Clark <james.clark@arm.com>
> ---
> include/linux/perf/arm_pmuv3.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h
> index 0f4d62ef3a9a..46377e134d67 100644
> --- a/include/linux/perf/arm_pmuv3.h
> +++ b/include/linux/perf/arm_pmuv3.h
> @@ -234,8 +234,8 @@
> * PMXEVTYPER: Event selection reg
> */
> #define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */
> -#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32)
> -#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61)
> +#define ARMV8_PMU_EVTYPE_TH GENMASK_ULL(43, 32) /* arm64 only */
> +#define ARMV8_PMU_EVTYPE_TC GENMASK_ULL(63, 61) /* arm64 only */
As expected this fixes compilation on my end, too and it's nicer than
v1.
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] arm: perf: Fix ARCH=arm build with GCC
2023-12-15 17:56 ` [PATCH v2 1/1] " James Clark
2023-12-15 18:20 ` Uwe Kleine-König
@ 2023-12-16 12:44 ` Mark Rutland
1 sibling, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2023-12-16 12:44 UTC (permalink / raw)
To: James Clark, will, catalin.marinas
Cc: linux-arm-kernel, linux-perf-users, linux-next, u.kleine-koenig,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Anshuman Khandual, Suzuki K Poulose, linux-kernel, llvm
On Fri, Dec 15, 2023 at 05:56:48PM +0000, James Clark wrote:
> LLVM ignores everything inside the if statement and doesn't generate
> errors, but GCC doesn't ignore it, resulting in the following error:
>
> drivers/perf/arm_pmuv3.c: In function 'armv8pmu_write_evtype':
> 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 using GENMASK_ULL which doesn't overflow on arm32 (even though
> the value is never used there).
It would be nice if this could explain the overflow problem, i.e.
| The GENMASK() macro creates masks of type unsigned long, and we use this to
| geenrate the ARMV8_PMU_EVTYPE_TH and ARMV8_PMU_EVTYPE_TC constants. These
| include bits above bit 31, and generating these requires shifting more than the
| size of unsigned long on 32-bit ARM.
|
| Consequently when building for 32-bit arm, GCC warns about their use:
|
| drivers/perf/arm_pmuv3.c: In function 'armv8pmu_write_evtype':
| include/linux/bits.h:34:29: error: left shift count >= width of type [-Werror=shift-count-overflow]
| 34 | (((~UL(0)) - (UL(1) << (l)) + 1) & \
|
| ... though LLVM does not warn as the actual usage is not reachable on 32-bit
| ARM due to `if (IS_ENABLED(...)` checks.
|
| Avoid the warning by using GENMACK_ULL(), which doesn't overflow on 32-bit arm.
> Fixes: 3115ee021bfb ("arm64: perf: Include threshold control fields in PMEVTYPER mask")
> Reported-by: Uwe Kleine-K"onig <u.kleine-koenig@pengutronix.de>
> Closes: https://lore.kernel.org/linux-arm-kernel/20231215120817.h2f3akgv72zhrtqo@pengutronix.de/
> Signed-off-by: James Clark <james.clark@arm.com>
Thanks for this!
Acked-by: Mark Rutland <mark.rutland@arm.com>
Will, Catalin, the broken commit is queued in the arm64 for-next/perf branch
(and merged into for-next/core); is this something we can easily fold in?
Mark.
> ---
> include/linux/perf/arm_pmuv3.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/perf/arm_pmuv3.h b/include/linux/perf/arm_pmuv3.h
> index 0f4d62ef3a9a..46377e134d67 100644
> --- a/include/linux/perf/arm_pmuv3.h
> +++ b/include/linux/perf/arm_pmuv3.h
> @@ -234,8 +234,8 @@
> * PMXEVTYPER: Event selection reg
> */
> #define ARMV8_PMU_EVTYPE_EVENT GENMASK(15, 0) /* Mask for EVENT bits */
> -#define ARMV8_PMU_EVTYPE_TH GENMASK(43, 32)
> -#define ARMV8_PMU_EVTYPE_TC GENMASK(63, 61)
> +#define ARMV8_PMU_EVTYPE_TH GENMASK_ULL(43, 32) /* arm64 only */
> +#define ARMV8_PMU_EVTYPE_TC GENMASK_ULL(63, 61) /* arm64 only */
>
> /*
> * Event filters for PMUv3
> --
> 2.34.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/1] arm: perf: Fix ARCH=arm build with GCC
2023-12-15 17:56 [PATCH v2 0/1] arm: perf: Fix ARCH=arm build with GCC James Clark
2023-12-15 17:56 ` [PATCH v2 1/1] " James Clark
@ 2023-12-17 13:41 ` Will Deacon
1 sibling, 0 replies; 5+ messages in thread
From: Will Deacon @ 2023-12-17 13:41 UTC (permalink / raw)
To: linux-arm-kernel, mark.rutland, linux-next, u.kleine-koenig,
linux-perf-users, James Clark
Cc: catalin.marinas, kernel-team, Will Deacon, Nathan Chancellor,
Anshuman Khandual, Nick Desaulniers, llvm, Suzuki K Poulose,
Bill Wendling, Justin Stitt, linux-kernel
On Fri, 15 Dec 2023 17:56:47 +0000, James Clark wrote:
> Changes since V1:
>
> * Instead of wrapping everything in #if, just use GENMASK_ULL instead
> which fixes both issues in one commit.
>
> A fix for the broken build with GCC currently in linux-next
> (next-20231214)
>
> [...]
Applied to will (for-next/perf), thanks!
[1/1] arm: perf: Fix ARCH=arm build with GCC
https://git.kernel.org/will/c/bb339db4d363
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-17 13:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15 17:56 [PATCH v2 0/1] arm: perf: Fix ARCH=arm build with GCC James Clark
2023-12-15 17:56 ` [PATCH v2 1/1] " James Clark
2023-12-15 18:20 ` Uwe Kleine-König
2023-12-16 12:44 ` Mark Rutland
2023-12-17 13:41 ` [PATCH v2 0/1] " Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).