arm64/cache: Fix cache_type_cwg() for register generation
v2 cover arm64/cache: Fix cache_type_cwg() for register generation
Ard noticed that in converting CTR_EL0 to automatic generation we broke cache_type_cwg() since it was using a non-standard way of specifying _MASK that masks after rather than before shifting to retrieve the value. We could fix this directly in a single patch but there has been demand to also convert to use the SYS_FIELD_GET() accessor which requires a few preparatory patches to make that safe for direct use in cache.h.
v2:
- Use SYS_FIELD_GET()
Mark Brown (3):
arm64/sysreg: Directly include bitfield.h arm64/sysreg: Guard SYS_FIELD_ macros for asm arm64/cache: Fix cache_type_cwg() for register generation
arch/arm64/include/asm/cache.h | 2 +- arch/arm64/include/asm/sysreg.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
base-commit: 568035b01cfb107af8d2e4bd2fb9aea22cf5b868
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/3 arm64/sysreg: Directly include bitfield.h
The SYS_FIELD_ macros in sysreg.h use definitions from bitfield.h but there is no direct inclusion of it, add one to ensure that sysreg.h is directly usable.
--- arch/arm64/include/asm/sysreg.h | 1 + 1 file changed, 1 insertion(+)
arch/arm64/include/asm/sysreg.h +1 -0
@@ -1116,6 +1116,7 @@#else +#include <linux/bitfield.h> #include <linux/build_bug.h> #include <linux/types.h> #include <asm/alternative.h>
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/3 arm64/sysreg: Guard SYS_FIELD_ macros for asm
In reply to Mark BrownThe SYS_FIELD_ macros are not safe for assembly contexts, move them inside the guarded section.
--- arch/arm64/include/asm/sysreg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/sysreg.h +2 -2
@@ -1210,8 +1210,6 @@ par; \ }) -#endif -#define SYS_FIELD_GET (reg, field, val) \ FIELD_GET(reg##_##field##_MASK, val)
@@ -1221,4 +1219,6 @@#define SYS_FIELD_PREP_ENUM (reg, field, val) \ FIELD_PREP(reg##_##field##_MASK, reg##_##field##_##val) +#endif +#endif /* __ASM_SYSREG_H */
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 3/3 arm64/cache: Fix cache_type_cwg() for register generation
In reply to Mark BrownArd noticed that since we converted CTR_EL0 to automatic generation we have been seeing errors on some systems handling the value of cache_type_cwg() such as
CPU features: No Cache Writeback Granule information, assuming 128
This is because the manual definition of CTR_EL0_CWG_MASK was done without a shift while our convention is to define the mask after shifting. This means that the user in cache_type_cwg() was broken as it was written for the manually written shift then mask. Fix this by converting to use SYS_FIELD_GET().
The only other field where the _MASK for this register is used is IminLine which is at offset 0 so unaffected.
--- arch/arm64/include/asm/cache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/cache.h +1 -1
@@ -71,7 +71,7 @@ static __always_inline int icache_is_vpipt(void)static inline u32 cache_type_cwg (void ) { -return (read_cpuid_cachetype () >>CTR_EL0_CWG_SHIFT ) &CTR_EL0_CWG_MASK ; +return SYS_FIELD_GET (CTR_EL0 ,CWG ,read_cpuid_cachetype ()); }#define __read_mostly __section(".data..read_mostly")
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Mark Brown
Ard noticed that in converting
CTR_EL0to automatic generation we brokecache_type_cwg()since it was using a non-standard way of specifying_MASKthat masks after rather than before shifting to retrieve the value. We could fix this directly in a single patch but there has been demand to also convert to use theSYS_FIELD_GET()accessor which requires a few preparatory patches to make that safe for direct use incache.h.[...]
Applied to arm64 (for-next/fixes), thanks!
[1/3] arm64/sysreg: Directly include bitfield.h
https://git.kernel.org/arm64/c/02e483f8d414 [2/3] arm64/sysreg: Guard SYS_FIELD_ macros for asm https://git.kernel.org/arm64/c/a10edea4efbb [3/3] arm64/cache: Fix cache_type_cwg() for register generation https://git.kernel.org/arm64/c/53d2d84a1f6d
Cheers,
Signature · 10 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel