net: gmac_rockchip: Fix misuse of GENMASK macro
Subsystems (6)
PATCH 1/9 net: gmac_rockchip: Fix misuse of GENMASK macro
Swap the arguments as that seems to have been the author's intention.
Note: This fix wasn't tested on hardware and will result in more bits
being set by the underlying writel() in rk_clrsetreg(), which might bring unexpected behavioural changes.
--- drivers/net/gmac_rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/gmac_rockchip.c +1 -1
@@ -350,7 +350,7 @@ static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)struct px30_grf *grf;enum {PX30_GMAC_PHY_INTF_SEL_SHIFT =4 , -PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (4 ,6 ), +PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (6 ,4 ),PX30_GMAC_PHY_INTF_SEL_RMII =BIT (6 ), };
Signature · 1 line
2.35.1.723.g4982287a31-goog
PATCH 2/9 lib: crypt: Avoid redefining static_assert
Use the macro introduced by commit ef0f4e834c66 ("build_bug.h: add wrapper for _Static_assert") by importing <linux/build_bug.h>.
--- lib/crypt/crypt-port.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
lib/crypt/crypt-port.h +1 -2
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* Copyright (C) 2020 Steffen Jaeckel <[email protected]> */ +#include <linux/build_bug.h> #include <linux/types.h> #include <vsprintf.h>
@@ -10,8 +11,6 @@#define ARG_UNUSED (x) (x) -#define static_assert (a, b) _Static_assert(a, b) -#define strtoul (cp, endp, base) simple_strtoul(cp, endp, base)extern const unsigned char ascii64[65 ];
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 2/9] lib: crypt: Avoid redefining static_assert
Quoted 10 lines · Pierre-Clément Tosi
Use the macro introduced by commit
ef0f4e834c66("build_bug.h: add wrapper for_Static_assert") by importing <linux/build_bug.h>.Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Steffen Jaeckel <[email protected]>--- lib/crypt/crypt-port.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Steffen Jaeckel
Reviewed-byRe: [PATCH 2/9] lib: crypt: Avoid redefining static_assert
Quoted 5 lines · Simon Glass
Quoted 4 lines · Pierre-Clément Tosi
Use the macro introduced by commit
ef0f4e834c66("build_bug.h: add wrapper for_Static_assert") by importing <linux/build_bug.h>.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Steffen Jaeckel <[email protected]>--- lib/crypt/crypt-port.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Reviewed-by Simon Glass <[email protected]>
PATCH 3/9 scripts: Makefile.lib: Pass __UBOOT__ to DTC's CPP
In reply to Pierre-Clément TosiSome headers included (possibly indirectly) from .dts files might have U-Boot specific content relying on the __UBOOT__ macro passed to CPP when building C code. In that case, it would be sensible for DTC to see that content instead of the non-U-Boot one. To do so, pass the macro to the pre-processor when generate DTC inputs.
--- scripts/Makefile.lib | 1 + 1 file changed, 1 insertion(+)
scripts/Makefile.lib +1 -0
@@ -192,6 +192,7 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \ -D__ASSEMBLY__ \ + -D__UBOOT__ \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 3/9] scripts: Makefile.lib: Pass __UBOOT__ to DTC's CPP
Hi Pierre-Clément,
Quoted 6 lines · Pierre-Clément Tosi
Some headers included (possibly indirectly) from .dts files might have U-Boot specific content relying on the
__UBOOT__macro passed to CPP when building C code. In that case, it would be sensible for DTC to see that content instead of the non-U-Boot one. To do so, pass the macro to the pre-processor when generate DTC inputs.
Can you give an example of such a situation?
Quoted 6 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>--- scripts/Makefile.lib | 1 + 1 file changed, 1 insertion(+)
Quoted 16 lines
scripts/Makefile.lib +1
-1@@ -192,6 +192,7 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \ -D__ASSEMBLY__ \ + -D__UBOOT__ \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into --2.35.1.723.g4982287a31-goog
Re: [PATCH 3/9] scripts: Makefile.lib: Pass __UBOOT__ to DTC's CPP
Quoted 11 lines · Simon Glass
Hi Pierre-Clément,
Quoted 6 lines · Pierre-Clément Tosi
Some headers included (possibly indirectly) from .dts files might have U-Boot specific content relying on the
__UBOOT__macro passed to CPP when building C code. In that case, it would be sensible for DTC to see that content instead of the non-U-Boot one. To do so, pass the macro to the pre-processor when generate DTC inputs.Can you give an example of such a situation?
This patch isn't fixing an existing issue. Instead, it preempts one that following patches, adding "#ifndef __UBOOT__/{code not supported in U-Boot}" in Linux headers, would bring. But IMO (and IIUC), it makes sense on its own given the meaning that CPP macro has in C code and how it's systematically set through KBUILD_CPPFLAGS.
Quoted 27 lines
Quoted 7 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>--- scripts/Makefile.lib | 1 + 1 file changed, 1 insertion(+)Reviewed-by Simon Glass <[email protected]>Quoted 16 lines
scripts/Makefile.lib +1
-1@@ -192,6 +192,7 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \ -D__ASSEMBLY__ \ + -D__UBOOT__ \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into --2.35.1.723.g4982287a31-goog
Signature · 1 line
Pierre
PATCH 4/9 linux/const.h: Upgrade & Merge vDSO and uAPI
In reply to Pierre-Clément TosiImport the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
Inline <vdso/const.h> and <uapi/linux/const.h>. This is wrapped in "#ifndef __UBOOT__/#include/#else/{inline}" to better document the origin of the code being added to the U-Boot header (but not present in the original header) and make diff tools happier when comparing the file with its reference, which should be useful when porting future changes from the Linux header and/or if we decide to also import those included headers into the U-Boot codebase.
--- include/linux/const.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
include/linux/const.h +21 -1
@@ -2,8 +2,13 @@#ifndef _LINUX_CONST_H#define _LINUX_CONST_H -/* const.h: Macros for dealing with constants. */ +#ifndef __UBOOT__ +#include <vdso/const.h> +#else +#ifndef __UBOOT__ +#include <uapi/linux/const.h> +#else /* Some constant macros are used in both assembler and * C code. Therefore we cannot annotate them always with * 'UL' and other type specifiers unilaterally. We
@@ -28,7 +33,22 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x)) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask)) + +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif +#define UL (x) (_UL(x))#define ULL (x) (_ULL(x)) +#endif + +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))#endif /* _LINUX_CONST_H */
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 4/9] linux/const.h: Upgrade & Merge vDSO and uAPI
Hi Pierre-Clément,
Quoted 40 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Inline <
vdso/const.h> and <uapi/linux/const.h>. This is wrapped in "#ifndef __UBOOT__/#include/#else/{inline}" to better document the origin of the code being added to the U-Boot header (but not present in the original header) and make diff tools happier when comparing the file with its reference, which should be useful when porting future changes from the Linux header and/or if we decide to also import those included headers into the U-Boot codebase.Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/const.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)include/linux/const.h +6
-1@@ -2,8 +2,13 @@#ifndef _LINUX_CONST_H#define _LINUX_CONST_H -/* const.h: Macros for dealing with constants. */ +#ifndef __UBOOT__ +#include <vdso/const.h> +#else +#ifndef __UBOOT__ +#include <uapi/linux/const.h> +#else /* Some constant macros are used in both assembler and * C code. Therefore we cannot annotate them always with * 'UL' and other type specifiers unilaterally. We
include/linux/const.h line 37
Quoted 5 lines
include/linux/const.h +2
-0@@ -28,7 +33,22 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x)) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))
How does this compare to the existing ALIGN()? It looks the same to me.
Quoted 18 lines
include/linux/const.h +13
-1+ +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif +#define UL (x) (_UL(x))#define ULL (x) (_ULL(x)) +#endif + +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))#endif /* _LINUX_CONST_H */ --
Quoted 2 lines
2.35.1.723.g4982287a31-goog
REgards,
Simon
Re: [PATCH 4/9] linux/const.h: Upgrade & Merge vDSO and uAPI
Quoted 46 lines · Simon Glass
Hi Pierre-Clément,
Quoted 43 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Inline <
vdso/const.h> and <uapi/linux/const.h>. This is wrapped in "#ifndef __UBOOT__/#include/#else/{inline}" to better document the origin of the code being added to the U-Boot header (but not present in the original header) and make diff tools happier when comparing the file with its reference, which should be useful when porting future changes from the Linux header and/or if we decide to also import those included headers into the U-Boot codebase.Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/const.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)include/linux/const.h +6
-1@@ -2,8 +2,13 @@#ifndef _LINUX_CONST_H#define _LINUX_CONST_H -/* const.h: Macros for dealing with constants. */ +#ifndef __UBOOT__ +#include <vdso/const.h> +#else +#ifndef __UBOOT__ +#include <uapi/linux/const.h> +#else /* Some constant macros are used in both assembler and * C code. Therefore we cannot annotate them always with * 'UL' and other type specifiers unilaterally. We @@ -28,7 +33,22 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x))
Quoted 5 lines
include/linux/const.h line 37
Quoted 2 lines
include/linux/const.h +2
-0+#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))How does this compare to the existing
ALIGN()? It looks the same to me.
__ALIGN_KERNEL() is the uAPI counterpart to the ALIGN() kernel macro (or is it the other way around?) so they're intended to be similar in implementation; the key difference being the double-leading-underscore notation, which bears a special meaning as per the C Standard, and allows __ALIGN_KERNEL() to be considerably easier to export. In fact, the kernel currently defines
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
For the reason why this patch introduces it here, I've taken the conservative approach of meticulously copying the original headers over, in their entirety (as far as feasible), in order to make future upgrades as smooth as possible.
This patch inlines those vDSO and uAPI headers instead of bringing them as the stand-alone files they are in the kernel as it looks like no other kernel header of that kind has been imported but IMO, it would make more sense to do the later. What do you think?
Quoted 23 lines
Quoted 18 lines
include/linux/const.h +13
-1+ +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif +#define UL (x) (_UL(x))#define ULL (x) (_ULL(x)) +#endif + +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))#endif /* _LINUX_CONST_H */ --Quoted 2 lines
2.35.1.723.g4982287a31-goog
REgards,
Simon
Signature · 1 line
Pierre
Simon Glass
Reviewed-byRe: [PATCH 4/9] linux/const.h: Upgrade & Merge vDSO and uAPI
Hi Pierre-Clément,
Quoted 62 lines · Pierre-Clément Tosi
Quoted 46 lines · Simon Glass
Hi Pierre-Clément,
Quoted 43 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Inline <
vdso/const.h> and <uapi/linux/const.h>. This is wrapped in "#ifndef __UBOOT__/#include/#else/{inline}" to better document the origin of the code being added to the U-Boot header (but not present in the original header) and make diff tools happier when comparing the file with its reference, which should be useful when porting future changes from the Linux header and/or if we decide to also import those included headers into the U-Boot codebase.Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/const.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)include/linux/const.h +6
-1@@ -2,8 +2,13 @@#ifndef _LINUX_CONST_H#define _LINUX_CONST_H -/* const.h: Macros for dealing with constants. */ +#ifndef __UBOOT__ +#include <vdso/const.h> +#else +#ifndef __UBOOT__ +#include <uapi/linux/const.h> +#else /* Some constant macros are used in both assembler and * C code. Therefore we cannot annotate them always with * 'UL' and other type specifiers unilaterally. We @@ -28,7 +33,22 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x))Quoted 5 lines
include/linux/const.h line 37
Quoted 2 lines
include/linux/const.h +2
-0+#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))How does this compare to the existing
ALIGN()? It looks the same to me.
__ALIGN_KERNEL()is the uAPI counterpart to theALIGN()kernel macro (or is it the other way around?) so they're intended to be similar in implementation; the key difference being the double-leading-underscore notation, which bears a special meaning as per the C Standard, and allows__ALIGN_KERNEL()to be considerably easier to export. In fact, the kernel currently defines#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
Quoted 8 lines
For the reason why this patch introduces it here, I've taken the conservative approach of meticulously copying the original headers over, in their entirety (as far as feasible), in order to make future upgrades as smooth as possible.
This patch inlines those vDSO and uAPI headers instead of bringing them as the stand-alone files they are in the kernel as it looks like no other kernel header of that kind has been imported but IMO, it would make more sense to do the later. What do you think?
OK I see. Using stand-alone files makes it easier to keep things in sync in the future, but I don't have a strong opinion on it.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
include/linux/const.h +13
-0+ +#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d)) +#endif +#define UL (x) (_UL(x))#define ULL (x) (_ULL(x)) +#endif + +/* +* This returns a constant expression while determining if an argument is +* a constant expression, most importantly without evaluating the argument. +* Glory to Martin Uecker <[email protected]> +*/ +#define __is_constexpr (x) \ + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
include/linux/const.h +0
-1#endif /* _LINUX_CONST_H */ --2.35.1.723.g4982287a31-goog
Regards,
Simon
PATCH 5/9 include: Import <linux/bits.h> & Update bitops.h
In reply to Pierre-Clément TosiImport the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
Inline the included <vdso/bits.h> and prevent U-Boot from including <asm/bitsperlong.h> as BITS_PER_LONG is defined in <asm/types.h>.
Remove now-duplicate definitions from <linux/bitops.h>.
Note: This brings extra compile-time checks through GENMASK_INPUT_CHECK.
--- include/linux/bitops.h | 27 ++++++--------------- include/linux/bits.h | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 include/linux/bits.h
include/linux/bitops.h +7 -20
@@ -5,37 +5,24 @@#include <asm/types.h> #include <asm-generic/bitsperlong.h> +#include <linux/bits.h> #include <linux/compiler.h> #ifdef __KERNEL__ -#define BIT (nr) (1UL << (nr)) -#define BIT_ULL (nr) (1ULL << (nr)) -#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) -#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) -#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG) -#define BITS_PER_BYTE 8#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))#endif /* kernel.h includes log.h which include bitops.h */ #include <linux/kernel.h> -/* -* Create a contiguous bitmask starting at bit position @l and ending at -* position @h. For example -* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. -*/ #ifdef CONFIG_SANDBOX -#define GENMASK (h, l) \ - (((~0UL) << (l)) & (~0UL >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h)))) -#else -#define GENMASK (h, l) \ - (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#ifdef __GENMASK +#undef __GENMASK +#endif +#define __GENMASK (h, l) \ + (((~UL(0)) - (UL(1) << (l)) + 1) & \ + (~UL(0) >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h))))#endif - -#define GENMASK_ULL (h, l) \ - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))/* * ffs: find first bit set. This is defined the same way as
include/linux/bits.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 5/9] include: Import <linux/bits.h> & Update bitops.h
Quoted 12 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Inline the included <
vdso/bits.h> and prevent U-Boot from including <asm/bitsperlong.h> asBITS_PER_LONGis defined in <asm/types.h>.Remove now-duplicate definitions from <
linux/bitops.h>.Note: This brings extra compile-time checks through
GENMASK_INPUT_CHECK.
Quoted 9 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/bitops.h | 27 ++++++--------------- include/linux/bits.h | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 include/linux/bits.h
PATCH 6/9 include: Carve <linux/export.h> out of compat.h
In reply to Pierre-Clément TosiAs Linux source code might include that header directly and as it is a simple "leaf header" (probably won't include other headers) that is unlikely to be relevant to U-Boot, replicate the upstream header definitions in a dedicated <linux/export.h> and include it in the pre-existing compat.h for existing users.
--- include/linux/compat.h | 4 +--- include/linux/export.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 include/linux/export.h
include/linux/compat.h +1 -3
@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/err.h> +#include <linux/export.h> #include <linux/kernel.h> #ifdef CONFIG_XEN
@@ -175,13 +176,10 @@ typedef unsigned long blkcnt_t;#endif /* module */ -#define THIS_MODULE 0#define try_module_get (...) 1#define module_put (...) do { } while (0)#define module_init (...)#define module_exit (...) -#define EXPORT_SYMBOL (...) -#define EXPORT_SYMBOL_GPL (...)#define module_param (...)#define module_param_call (...)#define MODULE_PARM_DESC (...)
include/linux/export.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_EXPORT_H +#define _LINUX_EXPORT_H + +/* +* Export symbols from the kernel to modules. Forked from module.h +* to reduce the amount of pointless cruft we feed to gcc when only +* exporting a simple symbol or two. +* +* Try not to add #includes here. It slows compilation and makes kernel +* hackers place grumpy comments in header files. +*/ + +#ifndef __ASSEMBLY__ + +#define THIS_MODULE 0 + +#define EXPORT_SYMBOL (...) +#define EXPORT_SYMBOL_GPL (...) +#define EXPORT_SYMBOL_NS (...) +#define EXPORT_SYMBOL_NS_GPL (...) + +#endif /* !__ASSEMBLY__ */ + +#endif /* _LINUX_EXPORT_H */
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 6/9] include: Carve <linux/export.h> out of compat.h
Quoted 7 lines · Pierre-Clément Tosi
As Linux source code might include that header directly and as it is a simple "leaf header" (probably won't include other headers) that is unlikely to be relevant to U-Boot, replicate the upstream header definitions in a dedicated <
linux/export.h> and include it in the pre-existingcompat.hfor existing users.
Quoted 8 lines
Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/compat.h | 4 +--- include/linux/export.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 include/linux/export.h
PATCH 7/9 include: Upgrade <linux/typecheck.h>
In reply to Pierre-Clément TosiUpgrade the header to version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
--- include/linux/typecheck.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/typecheck.h +10 -0
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef TYPECHECK_H_INCLUDED #define TYPECHECK_H_INCLUDED
@@ -21,4 +22,13 @@ (void )__tmp; \ }) +/* +* Check at compile time that something is a pointer type. +*/ +#define typecheck_pointer (x) \ +({ typeof(x) __dummy; \ + (void)sizeof(*__dummy); \ + 1; \ +}) +#endif /* TYPECHECK_H_INCLUDED */
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 7/9] include: Upgrade <linux/typecheck.h>
Hi,
Quoted 11 lines · Pierre-Clément Tosi
Upgrade the header to version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/typecheck.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
But I don't understand how this works at all. Could you add a comment?
Quoted 25 lines
include/linux/typecheck.h +10
-1@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef TYPECHECK_H_INCLUDED #define TYPECHECK_H_INCLUDED @@ -21,4 +22,13 @@ (void )__tmp; \ }) +/* +* Check at compile time that something is a pointer type. +*/ +#define typecheck_pointer (x) \ +({ typeof(x) __dummy; \ + (void)sizeof(*__dummy); \ + 1; \ +}) +#endif /* TYPECHECK_H_INCLUDED */ --
Quoted 2 lines
2.35.1.723.g4982287a31-goog
Regards,
Simon
Re: [PATCH 7/9] include: Upgrade <linux/typecheck.h>
Quoted 15 lines · Simon Glass
Hi,
Quoted 11 lines · Pierre-Clément Tosi
Upgrade the header to version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/typecheck.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>But I don't understand how this works at all. Could you add a comment?
This patch is a simple upgrade of the header. I needed it for another patch stack and, given how trivial and self-contained it is, I thought I would slip it into this one.
If your "this" refers to the macro itself, an error should be generated by the compiler when dereferencing a non-pointer and it avoids introducing side effects through the use of __dummy but I'm not sure what the sizeof is there for; is it perhaps compliant for an implementation to keep generating code when encountering a dereferenced non-pointer (leading to a bogus result, from UB) so that sizeof forces it to depend on that expression being of a valid type? Or is it to do with catching variables of incomplete type e.g. arrays of unknown size? It was introduced by commit cb0f80039fb7 ("bitops: Add non-atomic bitops for pointers"), which doesn't provide much information either.
Quoted 31 lines
Quoted 26 lines
include/linux/typecheck.h +10
-1@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef TYPECHECK_H_INCLUDED #define TYPECHECK_H_INCLUDED @@ -21,4 +22,13 @@ (void )__tmp; \ }) +/* +* Check at compile time that something is a pointer type. +*/ +#define typecheck_pointer (x) \ +({ typeof(x) __dummy; \ + (void)sizeof(*__dummy); \ + 1; \ +}) +#endif /* TYPECHECK_H_INCLUDED */ --Quoted 2 lines
2.35.1.723.g4982287a31-goog
Regards,
Simon
Signature · 1 line
Pierre
Re: [PATCH 7/9] include: Upgrade <linux/typecheck.h>
Hi Pierre-Clément,
Quoted 25 lines · Pierre-Clément Tosi
Quoted 15 lines · Simon Glass
Hi,
Quoted 11 lines · Pierre-Clément Tosi
Upgrade the header to version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- include/linux/typecheck.h | 10 ++++++++++ 1 file changed, 10 insertions(+)Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>But I don't understand how this works at all. Could you add a comment?
This patch is a simple upgrade of the header. I needed it for another patch stack and, given how trivial and self-contained it is, I thought I would slip it into this one.
Quoted 9 lines
If your "this" refers to the macro itself, an error should be generated by the compiler when dereferencing a non-pointer and it avoids introducing side effects through the use of
__dummybut I'm not sure what the sizeof is there for; is it perhaps compliant for an implementation to keep generating code when encountering a dereferenced non-pointer (leading to a bogus result, from UB) so that sizeof forces it to depend on that expression being of a valid type? Or is it to do with catching variables of incomplete type e.g. arrays of unknown size? It was introduced by commitcb0f80039fb7("bitops: Add non-atomic bitops for pointers"), which doesn't provide much information either.
Hmm OK. The Linux people are quite averse to comments. If you have time you could send a patch to comment the macro and see if someone responds and dispels the uncertainty.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
include/linux/typecheck.h +1
-0@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef TYPECHECK_H_INCLUDED #define TYPECHECK_H_INCLUDED @@ -21,4 +22,13 @@ (void )__tmp; \ })
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
include/linux/typecheck.h +4
-0+/* +* Check at compile time that something is a pointer type. +*/ +#define typecheck_pointer (x) \Quoted 8 lines
Quoted 8 lines
include/linux/typecheck.h +5
-1+({typeof (x) __dummy; \ + (void )sizeof (*__dummy); \ +1 ; \ +}) +#endif /* TYPECHECK_H_INCLUDED */ --2.35.1.723.g4982287a31-goog
Regards,
Simon
PATCH 8/9 arm64: Import <asm/sysreg.h> from Linux
In reply to Pierre-Clément TosiImport the header and its companion <asm/gpr-num.h> from version 5.16:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
Prevent U-Boot from including <linux/kasan-tags.h> and <asm/alternative.h> as those are not relevant.
--- arch/arm/include/asm/gpr-num.h | 26 + arch/arm/include/asm/sysreg.h | 1317 ++++++++++++++++++++++++++++++++ 2 files changed, 1343 insertions(+) create mode 100644 arch/arm/include/asm/gpr-num.h create mode 100644 arch/arm/include/asm/sysreg.h
arch/arm/include/asm/gpr-num.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GPR_NUM_H +#define __ASM_GPR_NUM_H + +#ifdef __ASSEMBLY__ + + .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 + .equ .L__gpr_num_x\num, \num + .equ .L__gpr_num_w\num, \num + .endr + .equ .L__gpr_num_xzr, 31 + .equ .L__gpr_num_wzr, 31 + +#else /* __ASSEMBLY__ */ + +#define __DEFINE_ASM_GPR_NUMS \ +" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" \ +" .equ .L__gpr_num_x\\num, \\num\n" \ +" .equ .L__gpr_num_w\\num, \\num\n" \ +" .endr\n" \ +" .equ .L__gpr_num_xzr, 31\n" \ +" .equ .L__gpr_num_wzr, 31\n" + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_GPR_NUM_H */
arch/arm/include/asm/sysreg.h new file +1317 -0
1,317 lines not on this page · raw message
Signature · 1 line
2.35.1.723.g4982287a31-goog
PATCH 9/9 arm64: Import <asm/esr.h> from Linux
In reply to Pierre-Clément TosiImport the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9
--- arch/arm/include/asm/esr.h | 343 +++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 arch/arm/include/asm/esr.h
arch/arm/include/asm/esr.h new file +343 -0
@@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2013 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/ + +#ifndef __ASM_ESR_H +#define __ASM_ESR_H + +#include <asm/memory.h> +#include <asm/sysreg.h> + +#define ESR_ELx_EC_UNKNOWN (0x00) +#define ESR_ELx_EC_WFx (0x01) +/* Unallocated EC: 0x02 */ +#define ESR_ELx_EC_CP15_32 (0x03) +#define ESR_ELx_EC_CP15_64 (0x04) +#define ESR_ELx_EC_CP14_MR (0x05) +#define ESR_ELx_EC_CP14_LS (0x06) +#define ESR_ELx_EC_FP_ASIMD (0x07) +#define ESR_ELx_EC_CP10_ID (0x08)/* EL2 only */ +#define ESR_ELx_EC_PAC (0x09)/* EL2 and above */ +/* Unallocated EC: 0x0A - 0x0B */ +#define ESR_ELx_EC_CP14_64 (0x0C) +#define ESR_ELx_EC_BTI (0x0D) +#define ESR_ELx_EC_ILL (0x0E) +/* Unallocated EC: 0x0F - 0x10 */ +#define ESR_ELx_EC_SVC32 (0x11) +#define ESR_ELx_EC_HVC32 (0x12)/* EL2 only */ +#define ESR_ELx_EC_SMC32 (0x13)/* EL2 and above */ +/* Unallocated EC: 0x14 */ +#define ESR_ELx_EC_SVC64 (0x15) +#define ESR_ELx_EC_HVC64 (0x16)/* EL2 and above */ +#define ESR_ELx_EC_SMC64 (0x17)/* EL2 and above */ +#define ESR_ELx_EC_SYS64 (0x18) +#define ESR_ELx_EC_SVE (0x19) +#define ESR_ELx_EC_ERET (0x1a)/* EL2 only */ +/* Unallocated EC: 0x1B */ +#define ESR_ELx_EC_FPAC (0x1C)/* EL1 and above */ +/* Unallocated EC: 0x1D - 0x1E */ +#define ESR_ELx_EC_IMP_DEF (0x1f)/* EL3 only */ +#define ESR_ELx_EC_IABT_LOW (0x20) +#define ESR_ELx_EC_IABT_CUR (0x21) +#define ESR_ELx_EC_PC_ALIGN (0x22) +/* Unallocated EC: 0x23 */ +#define ESR_ELx_EC_DABT_LOW (0x24) +#define ESR_ELx_EC_DABT_CUR (0x25) +#define ESR_ELx_EC_SP_ALIGN (0x26) +/* Unallocated EC: 0x27 */ +#define ESR_ELx_EC_FP_EXC32 (0x28) +/* Unallocated EC: 0x29 - 0x2B */ +#define ESR_ELx_EC_FP_EXC64 (0x2C) +/* Unallocated EC: 0x2D - 0x2E */ +#define ESR_ELx_EC_SERROR (0x2F) +#define ESR_ELx_EC_BREAKPT_LOW (0x30) +#define ESR_ELx_EC_BREAKPT_CUR (0x31) +#define ESR_ELx_EC_SOFTSTP_LOW (0x32) +#define ESR_ELx_EC_SOFTSTP_CUR (0x33) +#define ESR_ELx_EC_WATCHPT_LOW (0x34) +#define ESR_ELx_EC_WATCHPT_CUR (0x35) +/* Unallocated EC: 0x36 - 0x37 */ +#define ESR_ELx_EC_BKPT32 (0x38) +/* Unallocated EC: 0x39 */ +#define ESR_ELx_EC_VECTOR32 (0x3A)/* EL2 only */ +/* Unallocated EC: 0x3B */ +#define ESR_ELx_EC_BRK64 (0x3C) +/* Unallocated EC: 0x3D - 0x3F */ +#define ESR_ELx_EC_MAX (0x3F) + +#define ESR_ELx_EC_SHIFT (26) +#define ESR_ELx_EC_WIDTH (6) +#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) +#define ESR_ELx_EC (esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) + +#define ESR_ELx_IL_SHIFT (25) +#define ESR_ELx_IL (UL(1) << ESR_ELx_IL_SHIFT) +#define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) + +/* ISS field definitions shared by different classes */ +#define ESR_ELx_WNR_SHIFT (6) +#define ESR_ELx_WNR (UL(1) << ESR_ELx_WNR_SHIFT) + +/* Asynchronous Error Type */ +#define ESR_ELx_IDS_SHIFT (24) +#define ESR_ELx_IDS (UL(1) << ESR_ELx_IDS_SHIFT) +#define ESR_ELx_AET_SHIFT (10) +#define ESR_ELx_AET (UL(0x7) << ESR_ELx_AET_SHIFT) + +#define ESR_ELx_AET_UC (UL(0) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEU (UL(1) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEO (UL(2) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UER (UL(3) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT) + +/* Shared ISS field definitions for Data/Instruction aborts */ +#define ESR_ELx_SET_SHIFT (11) +#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT) +#define ESR_ELx_FnV_SHIFT (10) +#define ESR_ELx_FnV (UL(1) << ESR_ELx_FnV_SHIFT) +#define ESR_ELx_EA_SHIFT (9) +#define ESR_ELx_EA (UL(1) << ESR_ELx_EA_SHIFT) +#define ESR_ELx_S1PTW_SHIFT (7) +#define ESR_ELx_S1PTW (UL(1) << ESR_ELx_S1PTW_SHIFT) + +/* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ +#define ESR_ELx_FSC (0x3F) +#define ESR_ELx_FSC_TYPE (0x3C) +#define ESR_ELx_FSC_LEVEL (0x03) +#define ESR_ELx_FSC_EXTABT (0x10) +#define ESR_ELx_FSC_MTE (0x11) +#define ESR_ELx_FSC_SERROR (0x11) +#define ESR_ELx_FSC_ACCESS (0x08) +#define ESR_ELx_FSC_FAULT (0x04) +#define ESR_ELx_FSC_PERM (0x0C) + +/* ISS field definitions for Data Aborts */ +#define ESR_ELx_ISV_SHIFT (24) +#define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) +#define ESR_ELx_SAS_SHIFT (22) +#define ESR_ELx_SAS (UL(3) << ESR_ELx_SAS_SHIFT) +#define ESR_ELx_SSE_SHIFT (21) +#define ESR_ELx_SSE (UL(1) << ESR_ELx_SSE_SHIFT) +#define ESR_ELx_SRT_SHIFT (16) +#define ESR_ELx_SRT_MASK (UL(0x1F) << ESR_ELx_SRT_SHIFT) +#define ESR_ELx_SF_SHIFT (15) +#define ESR_ELx_SF (UL(1) << ESR_ELx_SF_SHIFT) +#define ESR_ELx_AR_SHIFT (14) +#define ESR_ELx_AR (UL(1) << ESR_ELx_AR_SHIFT) +#define ESR_ELx_CM_SHIFT (8) +#define ESR_ELx_CM (UL(1) << ESR_ELx_CM_SHIFT) + +/* ISS field definitions for exceptions taken in to Hyp */ +#define ESR_ELx_CV (UL(1) << 24) +#define ESR_ELx_COND_SHIFT (20) +#define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) +#define ESR_ELx_WFx_ISS_TI (UL(1) << 0) +#define ESR_ELx_WFx_ISS_WFI (UL(0) << 0) +#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0) +#define ESR_ELx_xVC_IMM_MASK ((1UL << 16) - 1) + +#define DISR_EL1_IDS (UL(1) << 24) +/* +* DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean +* different things in the future... +*/ +#define DISR_EL1_ESR_MASK (ESR_ELx_AET | ESR_ELx_EA | ESR_ELx_FSC) + +/* ESR value templates for specific events */ +#define ESR_ELx_WFx_MASK (ESR_ELx_EC_MASK | ESR_ELx_WFx_ISS_TI) +#define ESR_ELx_WFx_WFI_VAL ((ESR_ELx_EC_WFx << ESR_ELx_EC_SHIFT) | \ + ESR_ELx_WFx_ISS_WFI) + +/* BRK instruction trap from AArch64 state */ +#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff + +/* ISS field definitions for System instruction traps */ +#define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 +#define ESR_ELx_SYS64_ISS_RES0_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_RES0_SHIFT) +#define ESR_ELx_SYS64_ISS_DIR_MASK 0x1 +#define ESR_ELx_SYS64_ISS_DIR_READ 0x1 +#define ESR_ELx_SYS64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_SYS64_ISS_RT_SHIFT 5 +#define ESR_ELx_SYS64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_SYS64_ISS_RT_SHIFT) +#define ESR_ELx_SYS64_ISS_CRM_SHIFT 1 +#define ESR_ELx_SYS64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRM_SHIFT) +#define ESR_ELx_SYS64_ISS_CRN_SHIFT 10 +#define ESR_ELx_SYS64_ISS_CRN_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRN_SHIFT) +#define ESR_ELx_SYS64_ISS_OP1_SHIFT 14 +#define ESR_ELx_SYS64_ISS_OP1_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP1_SHIFT) +#define ESR_ELx_SYS64_ISS_OP2_SHIFT 17 +#define ESR_ELx_SYS64_ISS_OP2_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP2_SHIFT) +#define ESR_ELx_SYS64_ISS_OP0_SHIFT 20 +#define ESR_ELx_SYS64_ISS_OP0_MASK (UL(0x3) << ESR_ELx_SYS64_ISS_OP0_SHIFT) +#define ESR_ELx_SYS64_ISS_SYS_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_CRM_MASK) +#define ESR_ELx_SYS64_ISS_SYS_VAL (op0, op1, op2, crn, crm) \ + (((op0) << ESR_ELx_SYS64_ISS_OP0_SHIFT) | \ + ((op1) << ESR_ELx_SYS64_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_SYS64_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_SYS64_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_SYS64_ISS_CRM_SHIFT)) + +#define ESR_ELx_SYS64_ISS_SYS_OP_MASK (ESR_ELx_SYS64_ISS_SYS_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_RT (esr) \ + (((esr) & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT) +/* +* User space cache operations have the following sysreg encoding +* in System instructions. +* op0=1, op1=3, op2=1, crn=7, crm={ 5, 10, 11, 12, 13, 14 }, WRITE (L=0) +*/ +#define ESR_ELx_SYS64_ISS_CRM_DC_CIVAC 14 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVADP 13 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAP 12 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAU 11 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAC 10 +#define ESR_ELx_SYS64_ISS_CRM_IC_IVAU 5 + +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(1, 3, 1, 7, 0) | \ + ESR_ELx_SYS64_ISS_DIR_WRITE) +/* +* User space MRS operations which are supported for emulation +* have the following sysreg encoding in System instructions. +* op0 = 3, op1= 0, crn = 0, {crm = 0, 4-7}, READ (L = 1) +*/ +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(3, 0, 0, 0, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CTR ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 1, 0, 0) +#define ESR_ELx_SYS64_ISS_SYS_CTR_READ (ESR_ELx_SYS64_ISS_SYS_CTR | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCT (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 2, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCTSS (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 6, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTFRQ (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 0, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define esr_sys64_to_sysreg (e) \ + sys_reg((((e) & ESR_ELx_SYS64_ISS_OP0_MASK) >> \ + ESR_ELx_SYS64_ISS_OP0_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +#define esr_cp15_to_sysreg (e) \ + sys_reg(3, \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +/* +* ISS field definitions for floating-point exception traps +* (FP_EXC_32/FP_EXC_64). +* +* (The FPEXC_* constants are used instead for common bits.) +*/ + +#define ESR_ELx_FP_EXC_TFV (UL(1) << 23) + +/* +* ISS field definitions for CP15 accesses +*/ +#define ESR_ELx_CP15_32_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_32_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_32_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_32_ISS_RT_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_32_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRM_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRN_SHIFT 10 +#define ESR_ELx_CP15_32_ISS_CRN_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP1_SHIFT 14 +#define ESR_ELx_CP15_32_ISS_OP1_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP2_SHIFT 17 +#define ESR_ELx_CP15_32_ISS_OP2_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) + +#define ESR_ELx_CP15_32_ISS_SYS_MASK (ESR_ELx_CP15_32_ISS_OP1_MASK | \ + ESR_ELx_CP15_32_ISS_OP2_MASK | \ + ESR_ELx_CP15_32_ISS_CRN_MASK | \ + ESR_ELx_CP15_32_ISS_CRM_MASK | \ + ESR_ELx_CP15_32_ISS_DIR_MASK) +#define ESR_ELx_CP15_32_ISS_SYS_VAL (op1, op2, crn, crm) \ + (((op1) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_CP15_32_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_64_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT_SHIFT) + +#define ESR_ELx_CP15_64_ISS_RT2_SHIFT 10 +#define ESR_ELx_CP15_64_ISS_RT2_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT2_SHIFT) + +#define ESR_ELx_CP15_64_ISS_OP1_SHIFT 16 +#define ESR_ELx_CP15_64_ISS_OP1_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_64_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_CRM_SHIFT) + +#define ESR_ELx_CP15_64_ISS_SYS_VAL (op1, crm) \ + (((op1) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) | \ + ((crm) << ESR_ELx_CP15_64_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_SYS_MASK (ESR_ELx_CP15_64_ISS_OP1_MASK | \ + ESR_ELx_CP15_64_ISS_CRM_MASK | \ + ESR_ELx_CP15_64_ISS_DIR_MASK) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCT (ESR_ELx_CP15_64_ISS_SYS_VAL(1, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCTSS (ESR_ELx_CP15_64_ISS_SYS_VAL(9, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_32_ISS_SYS_CNTFRQ (ESR_ELx_CP15_32_ISS_SYS_VAL(0, 0, 14, 0) |\ + ESR_ELx_CP15_32_ISS_DIR_READ) + +#ifndef __ASSEMBLY__ +#include <asm/types.h> + +static inline bool esr_is_data_abort (u32 esr) +{ +const u32 ec =ESR_ELx_EC (esr); + +return ec == ESR_ELx_EC_DABT_LOW || ec == ESR_ELx_EC_DABT_CUR; +} + +const char *esr_get_class_string (u32 esr); +#endif /* __ASSEMBLY */ + +#endif /* __ASM_ESR_H */
Signature · 1 line
2.35.1.723.g4982287a31-goog
Re: [PATCH 9/9] arm64: Import <asm/esr.h> from Linux
Quoted 18 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/include/asm/esr.h | 343 +++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+)create mode 100644
arch/arm/include/asm/esr.harch/arm/include/asm/esr.h new file +1
-0@@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: GPL-2.0-only */
arch/arm/include/asm/esr.h line 11
Quoted 10 lines
arch/arm/include/asm/esr.h new file +10
-0+/* +* Copyright (C) 2013 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/ + +#ifndef __ASM_ESR_H +#define __ASM_ESR_H + +#include <asm/memory.h> +#include <asm/sysreg.h>
I think this is just needed for the UL macros. See e.g. [1].
--Sean
Quoted 333 lines
arch/arm/include/asm/esr.h new file +332
-0+ +#define ESR_ELx_EC_UNKNOWN (0x00) +#define ESR_ELx_EC_WFx (0x01) +/* Unallocated EC: 0x02 */ +#define ESR_ELx_EC_CP15_32 (0x03) +#define ESR_ELx_EC_CP15_64 (0x04) +#define ESR_ELx_EC_CP14_MR (0x05) +#define ESR_ELx_EC_CP14_LS (0x06) +#define ESR_ELx_EC_FP_ASIMD (0x07) +#define ESR_ELx_EC_CP10_ID (0x08)/* EL2 only */ +#define ESR_ELx_EC_PAC (0x09)/* EL2 and above */ +/* Unallocated EC: 0x0A - 0x0B */ +#define ESR_ELx_EC_CP14_64 (0x0C) +#define ESR_ELx_EC_BTI (0x0D) +#define ESR_ELx_EC_ILL (0x0E) +/* Unallocated EC: 0x0F - 0x10 */ +#define ESR_ELx_EC_SVC32 (0x11) +#define ESR_ELx_EC_HVC32 (0x12)/* EL2 only */ +#define ESR_ELx_EC_SMC32 (0x13)/* EL2 and above */ +/* Unallocated EC: 0x14 */ +#define ESR_ELx_EC_SVC64 (0x15) +#define ESR_ELx_EC_HVC64 (0x16)/* EL2 and above */ +#define ESR_ELx_EC_SMC64 (0x17)/* EL2 and above */ +#define ESR_ELx_EC_SYS64 (0x18) +#define ESR_ELx_EC_SVE (0x19) +#define ESR_ELx_EC_ERET (0x1a)/* EL2 only */ +/* Unallocated EC: 0x1B */ +#define ESR_ELx_EC_FPAC (0x1C)/* EL1 and above */ +/* Unallocated EC: 0x1D - 0x1E */ +#define ESR_ELx_EC_IMP_DEF (0x1f)/* EL3 only */ +#define ESR_ELx_EC_IABT_LOW (0x20) +#define ESR_ELx_EC_IABT_CUR (0x21) +#define ESR_ELx_EC_PC_ALIGN (0x22) +/* Unallocated EC: 0x23 */ +#define ESR_ELx_EC_DABT_LOW (0x24) +#define ESR_ELx_EC_DABT_CUR (0x25) +#define ESR_ELx_EC_SP_ALIGN (0x26) +/* Unallocated EC: 0x27 */ +#define ESR_ELx_EC_FP_EXC32 (0x28) +/* Unallocated EC: 0x29 - 0x2B */ +#define ESR_ELx_EC_FP_EXC64 (0x2C) +/* Unallocated EC: 0x2D - 0x2E */ +#define ESR_ELx_EC_SERROR (0x2F) +#define ESR_ELx_EC_BREAKPT_LOW (0x30) +#define ESR_ELx_EC_BREAKPT_CUR (0x31) +#define ESR_ELx_EC_SOFTSTP_LOW (0x32) +#define ESR_ELx_EC_SOFTSTP_CUR (0x33) +#define ESR_ELx_EC_WATCHPT_LOW (0x34) +#define ESR_ELx_EC_WATCHPT_CUR (0x35) +/* Unallocated EC: 0x36 - 0x37 */ +#define ESR_ELx_EC_BKPT32 (0x38) +/* Unallocated EC: 0x39 */ +#define ESR_ELx_EC_VECTOR32 (0x3A)/* EL2 only */ +/* Unallocated EC: 0x3B */ +#define ESR_ELx_EC_BRK64 (0x3C) +/* Unallocated EC: 0x3D - 0x3F */ +#define ESR_ELx_EC_MAX (0x3F) + +#define ESR_ELx_EC_SHIFT (26) +#define ESR_ELx_EC_WIDTH (6) +#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) +#define ESR_ELx_EC (esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) + +#define ESR_ELx_IL_SHIFT (25) +#define ESR_ELx_IL (UL(1) << ESR_ELx_IL_SHIFT) +#define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) + +/* ISS field definitions shared by different classes */ +#define ESR_ELx_WNR_SHIFT (6) +#define ESR_ELx_WNR (UL(1) << ESR_ELx_WNR_SHIFT) + +/* Asynchronous Error Type */ +#define ESR_ELx_IDS_SHIFT (24) +#define ESR_ELx_IDS (UL(1) << ESR_ELx_IDS_SHIFT) +#define ESR_ELx_AET_SHIFT (10) +#define ESR_ELx_AET (UL(0x7) << ESR_ELx_AET_SHIFT) + +#define ESR_ELx_AET_UC (UL(0) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEU (UL(1) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEO (UL(2) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UER (UL(3) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT) + +/* Shared ISS field definitions for Data/Instruction aborts */ +#define ESR_ELx_SET_SHIFT (11) +#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT) +#define ESR_ELx_FnV_SHIFT (10) +#define ESR_ELx_FnV (UL(1) << ESR_ELx_FnV_SHIFT) +#define ESR_ELx_EA_SHIFT (9) +#define ESR_ELx_EA (UL(1) << ESR_ELx_EA_SHIFT) +#define ESR_ELx_S1PTW_SHIFT (7) +#define ESR_ELx_S1PTW (UL(1) << ESR_ELx_S1PTW_SHIFT) + +/* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ +#define ESR_ELx_FSC (0x3F) +#define ESR_ELx_FSC_TYPE (0x3C) +#define ESR_ELx_FSC_LEVEL (0x03) +#define ESR_ELx_FSC_EXTABT (0x10) +#define ESR_ELx_FSC_MTE (0x11) +#define ESR_ELx_FSC_SERROR (0x11) +#define ESR_ELx_FSC_ACCESS (0x08) +#define ESR_ELx_FSC_FAULT (0x04) +#define ESR_ELx_FSC_PERM (0x0C) + +/* ISS field definitions for Data Aborts */ +#define ESR_ELx_ISV_SHIFT (24) +#define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) +#define ESR_ELx_SAS_SHIFT (22) +#define ESR_ELx_SAS (UL(3) << ESR_ELx_SAS_SHIFT) +#define ESR_ELx_SSE_SHIFT (21) +#define ESR_ELx_SSE (UL(1) << ESR_ELx_SSE_SHIFT) +#define ESR_ELx_SRT_SHIFT (16) +#define ESR_ELx_SRT_MASK (UL(0x1F) << ESR_ELx_SRT_SHIFT) +#define ESR_ELx_SF_SHIFT (15) +#define ESR_ELx_SF (UL(1) << ESR_ELx_SF_SHIFT) +#define ESR_ELx_AR_SHIFT (14) +#define ESR_ELx_AR (UL(1) << ESR_ELx_AR_SHIFT) +#define ESR_ELx_CM_SHIFT (8) +#define ESR_ELx_CM (UL(1) << ESR_ELx_CM_SHIFT) + +/* ISS field definitions for exceptions taken in to Hyp */ +#define ESR_ELx_CV (UL(1) << 24) +#define ESR_ELx_COND_SHIFT (20) +#define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) +#define ESR_ELx_WFx_ISS_TI (UL(1) << 0) +#define ESR_ELx_WFx_ISS_WFI (UL(0) << 0) +#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0) +#define ESR_ELx_xVC_IMM_MASK ((1UL << 16) - 1) + +#define DISR_EL1_IDS (UL(1) << 24) +/* +* DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean +* different things in the future... +*/ +#define DISR_EL1_ESR_MASK (ESR_ELx_AET | ESR_ELx_EA | ESR_ELx_FSC) + +/* ESR value templates for specific events */ +#define ESR_ELx_WFx_MASK (ESR_ELx_EC_MASK | ESR_ELx_WFx_ISS_TI) +#define ESR_ELx_WFx_WFI_VAL ((ESR_ELx_EC_WFx << ESR_ELx_EC_SHIFT) | \ + ESR_ELx_WFx_ISS_WFI) + +/* BRK instruction trap from AArch64 state */ +#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff + +/* ISS field definitions for System instruction traps */ +#define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 +#define ESR_ELx_SYS64_ISS_RES0_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_RES0_SHIFT) +#define ESR_ELx_SYS64_ISS_DIR_MASK 0x1 +#define ESR_ELx_SYS64_ISS_DIR_READ 0x1 +#define ESR_ELx_SYS64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_SYS64_ISS_RT_SHIFT 5 +#define ESR_ELx_SYS64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_SYS64_ISS_RT_SHIFT) +#define ESR_ELx_SYS64_ISS_CRM_SHIFT 1 +#define ESR_ELx_SYS64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRM_SHIFT) +#define ESR_ELx_SYS64_ISS_CRN_SHIFT 10 +#define ESR_ELx_SYS64_ISS_CRN_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRN_SHIFT) +#define ESR_ELx_SYS64_ISS_OP1_SHIFT 14 +#define ESR_ELx_SYS64_ISS_OP1_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP1_SHIFT) +#define ESR_ELx_SYS64_ISS_OP2_SHIFT 17 +#define ESR_ELx_SYS64_ISS_OP2_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP2_SHIFT) +#define ESR_ELx_SYS64_ISS_OP0_SHIFT 20 +#define ESR_ELx_SYS64_ISS_OP0_MASK (UL(0x3) << ESR_ELx_SYS64_ISS_OP0_SHIFT) +#define ESR_ELx_SYS64_ISS_SYS_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_CRM_MASK) +#define ESR_ELx_SYS64_ISS_SYS_VAL (op0, op1, op2, crn, crm) \ + (((op0) << ESR_ELx_SYS64_ISS_OP0_SHIFT) | \ + ((op1) << ESR_ELx_SYS64_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_SYS64_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_SYS64_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_SYS64_ISS_CRM_SHIFT)) + +#define ESR_ELx_SYS64_ISS_SYS_OP_MASK (ESR_ELx_SYS64_ISS_SYS_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_RT (esr) \ + (((esr) & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT) +/* +* User space cache operations have the following sysreg encoding +* in System instructions. +* op0=1, op1=3, op2=1, crn=7, crm={ 5, 10, 11, 12, 13, 14 }, WRITE (L=0) +*/ +#define ESR_ELx_SYS64_ISS_CRM_DC_CIVAC 14 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVADP 13 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAP 12 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAU 11 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAC 10 +#define ESR_ELx_SYS64_ISS_CRM_IC_IVAU 5 + +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(1, 3, 1, 7, 0) | \ + ESR_ELx_SYS64_ISS_DIR_WRITE) +/* +* User space MRS operations which are supported for emulation +* have the following sysreg encoding in System instructions. +* op0 = 3, op1= 0, crn = 0, {crm = 0, 4-7}, READ (L = 1) +*/ +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(3, 0, 0, 0, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CTR ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 1, 0, 0) +#define ESR_ELx_SYS64_ISS_SYS_CTR_READ (ESR_ELx_SYS64_ISS_SYS_CTR | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCT (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 2, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCTSS (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 6, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTFRQ (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 0, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define esr_sys64_to_sysreg (e) \ + sys_reg((((e) & ESR_ELx_SYS64_ISS_OP0_MASK) >> \ + ESR_ELx_SYS64_ISS_OP0_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +#define esr_cp15_to_sysreg (e) \ + sys_reg(3, \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +/* +* ISS field definitions for floating-point exception traps +* (FP_EXC_32/FP_EXC_64). +* +* (The FPEXC_* constants are used instead for common bits.) +*/ + +#define ESR_ELx_FP_EXC_TFV (UL(1) << 23) + +/* +* ISS field definitions for CP15 accesses +*/ +#define ESR_ELx_CP15_32_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_32_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_32_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_32_ISS_RT_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_32_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRM_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRN_SHIFT 10 +#define ESR_ELx_CP15_32_ISS_CRN_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP1_SHIFT 14 +#define ESR_ELx_CP15_32_ISS_OP1_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP2_SHIFT 17 +#define ESR_ELx_CP15_32_ISS_OP2_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) + +#define ESR_ELx_CP15_32_ISS_SYS_MASK (ESR_ELx_CP15_32_ISS_OP1_MASK | \ + ESR_ELx_CP15_32_ISS_OP2_MASK | \ + ESR_ELx_CP15_32_ISS_CRN_MASK | \ + ESR_ELx_CP15_32_ISS_CRM_MASK | \ + ESR_ELx_CP15_32_ISS_DIR_MASK) +#define ESR_ELx_CP15_32_ISS_SYS_VAL (op1, op2, crn, crm) \ + (((op1) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_CP15_32_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_64_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT_SHIFT) + +#define ESR_ELx_CP15_64_ISS_RT2_SHIFT 10 +#define ESR_ELx_CP15_64_ISS_RT2_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT2_SHIFT) + +#define ESR_ELx_CP15_64_ISS_OP1_SHIFT 16 +#define ESR_ELx_CP15_64_ISS_OP1_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_64_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_CRM_SHIFT) + +#define ESR_ELx_CP15_64_ISS_SYS_VAL (op1, crm) \ + (((op1) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) | \ + ((crm) << ESR_ELx_CP15_64_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_SYS_MASK (ESR_ELx_CP15_64_ISS_OP1_MASK | \ + ESR_ELx_CP15_64_ISS_CRM_MASK | \ + ESR_ELx_CP15_64_ISS_DIR_MASK) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCT (ESR_ELx_CP15_64_ISS_SYS_VAL(1, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCTSS (ESR_ELx_CP15_64_ISS_SYS_VAL(9, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_32_ISS_SYS_CNTFRQ (ESR_ELx_CP15_32_ISS_SYS_VAL(0, 0, 14, 0) |\ + ESR_ELx_CP15_32_ISS_DIR_READ) + +#ifndef __ASSEMBLY__ +#include <asm/types.h> + +static inline bool esr_is_data_abort (u32 esr) +{ +const u32 ec =ESR_ELx_EC (esr); + +return ec == ESR_ELx_EC_DABT_LOW || ec == ESR_ELx_EC_DABT_CUR; +} + +const char *esr_get_class_string (u32 esr); +#endif /* __ASSEMBLY */ + +#endif /* __ASM_ESR_H */
Re: [PATCH 9/9] arm64: Import <asm/esr.h> from Linux
Quoted 23 lines · Sean Anderson
Quoted 22 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/include/asm/esr.h | 343 +++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+)create mode 100644
arch/arm/include/asm/esr.harch/arm/include/asm/esr.h new file +5
-0@@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2013 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/
Quoted 8 lines
arch/arm/include/asm/esr.h line 11
Quoted 6 lines
arch/arm/include/asm/esr.h new file +6
-0+ +#ifndef __ASM_ESR_H +#define __ASM_ESR_H + +#include <asm/memory.h> +#include <asm/sysreg.h> I think this is just needed for the UL macros. See e.g. [1].
I think you're right about <asm/memory.h> being included for UL(), as pointed out by commit d7a33f4fbd12 ("arm64/debug: Add missing #includes"), which could (should?) be replaced by <linux/const.h>. But the esr_*_to_sysreg() macros require <asm/sysreg.h> and, even if it's unlikely for U-Boot to use them, that header brings many useful macros of its own anyway.
Quoted 4 lines
--Sean
Thanks, I wasn't aware of that patch; should I drop this one or instead rebase it on top of yours to re-#include sysreg.h once it's been made available by this series?
Quoted 336 lines
Quoted 334 lines
arch/arm/include/asm/esr.h new file +332
-0+ +#define ESR_ELx_EC_UNKNOWN (0x00) +#define ESR_ELx_EC_WFx (0x01) +/* Unallocated EC: 0x02 */ +#define ESR_ELx_EC_CP15_32 (0x03) +#define ESR_ELx_EC_CP15_64 (0x04) +#define ESR_ELx_EC_CP14_MR (0x05) +#define ESR_ELx_EC_CP14_LS (0x06) +#define ESR_ELx_EC_FP_ASIMD (0x07) +#define ESR_ELx_EC_CP10_ID (0x08)/* EL2 only */ +#define ESR_ELx_EC_PAC (0x09)/* EL2 and above */ +/* Unallocated EC: 0x0A - 0x0B */ +#define ESR_ELx_EC_CP14_64 (0x0C) +#define ESR_ELx_EC_BTI (0x0D) +#define ESR_ELx_EC_ILL (0x0E) +/* Unallocated EC: 0x0F - 0x10 */ +#define ESR_ELx_EC_SVC32 (0x11) +#define ESR_ELx_EC_HVC32 (0x12)/* EL2 only */ +#define ESR_ELx_EC_SMC32 (0x13)/* EL2 and above */ +/* Unallocated EC: 0x14 */ +#define ESR_ELx_EC_SVC64 (0x15) +#define ESR_ELx_EC_HVC64 (0x16)/* EL2 and above */ +#define ESR_ELx_EC_SMC64 (0x17)/* EL2 and above */ +#define ESR_ELx_EC_SYS64 (0x18) +#define ESR_ELx_EC_SVE (0x19) +#define ESR_ELx_EC_ERET (0x1a)/* EL2 only */ +/* Unallocated EC: 0x1B */ +#define ESR_ELx_EC_FPAC (0x1C)/* EL1 and above */ +/* Unallocated EC: 0x1D - 0x1E */ +#define ESR_ELx_EC_IMP_DEF (0x1f)/* EL3 only */ +#define ESR_ELx_EC_IABT_LOW (0x20) +#define ESR_ELx_EC_IABT_CUR (0x21) +#define ESR_ELx_EC_PC_ALIGN (0x22) +/* Unallocated EC: 0x23 */ +#define ESR_ELx_EC_DABT_LOW (0x24) +#define ESR_ELx_EC_DABT_CUR (0x25) +#define ESR_ELx_EC_SP_ALIGN (0x26) +/* Unallocated EC: 0x27 */ +#define ESR_ELx_EC_FP_EXC32 (0x28) +/* Unallocated EC: 0x29 - 0x2B */ +#define ESR_ELx_EC_FP_EXC64 (0x2C) +/* Unallocated EC: 0x2D - 0x2E */ +#define ESR_ELx_EC_SERROR (0x2F) +#define ESR_ELx_EC_BREAKPT_LOW (0x30) +#define ESR_ELx_EC_BREAKPT_CUR (0x31) +#define ESR_ELx_EC_SOFTSTP_LOW (0x32) +#define ESR_ELx_EC_SOFTSTP_CUR (0x33) +#define ESR_ELx_EC_WATCHPT_LOW (0x34) +#define ESR_ELx_EC_WATCHPT_CUR (0x35) +/* Unallocated EC: 0x36 - 0x37 */ +#define ESR_ELx_EC_BKPT32 (0x38) +/* Unallocated EC: 0x39 */ +#define ESR_ELx_EC_VECTOR32 (0x3A)/* EL2 only */ +/* Unallocated EC: 0x3B */ +#define ESR_ELx_EC_BRK64 (0x3C) +/* Unallocated EC: 0x3D - 0x3F */ +#define ESR_ELx_EC_MAX (0x3F) + +#define ESR_ELx_EC_SHIFT (26) +#define ESR_ELx_EC_WIDTH (6) +#define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) +#define ESR_ELx_EC (esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) + +#define ESR_ELx_IL_SHIFT (25) +#define ESR_ELx_IL (UL(1) << ESR_ELx_IL_SHIFT) +#define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) + +/* ISS field definitions shared by different classes */ +#define ESR_ELx_WNR_SHIFT (6) +#define ESR_ELx_WNR (UL(1) << ESR_ELx_WNR_SHIFT) + +/* Asynchronous Error Type */ +#define ESR_ELx_IDS_SHIFT (24) +#define ESR_ELx_IDS (UL(1) << ESR_ELx_IDS_SHIFT) +#define ESR_ELx_AET_SHIFT (10) +#define ESR_ELx_AET (UL(0x7) << ESR_ELx_AET_SHIFT) + +#define ESR_ELx_AET_UC (UL(0) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEU (UL(1) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UEO (UL(2) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_UER (UL(3) << ESR_ELx_AET_SHIFT) +#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT) + +/* Shared ISS field definitions for Data/Instruction aborts */ +#define ESR_ELx_SET_SHIFT (11) +#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT) +#define ESR_ELx_FnV_SHIFT (10) +#define ESR_ELx_FnV (UL(1) << ESR_ELx_FnV_SHIFT) +#define ESR_ELx_EA_SHIFT (9) +#define ESR_ELx_EA (UL(1) << ESR_ELx_EA_SHIFT) +#define ESR_ELx_S1PTW_SHIFT (7) +#define ESR_ELx_S1PTW (UL(1) << ESR_ELx_S1PTW_SHIFT) + +/* Shared ISS fault status code(IFSC/DFSC) for Data/Instruction aborts */ +#define ESR_ELx_FSC (0x3F) +#define ESR_ELx_FSC_TYPE (0x3C) +#define ESR_ELx_FSC_LEVEL (0x03) +#define ESR_ELx_FSC_EXTABT (0x10) +#define ESR_ELx_FSC_MTE (0x11) +#define ESR_ELx_FSC_SERROR (0x11) +#define ESR_ELx_FSC_ACCESS (0x08) +#define ESR_ELx_FSC_FAULT (0x04) +#define ESR_ELx_FSC_PERM (0x0C) + +/* ISS field definitions for Data Aborts */ +#define ESR_ELx_ISV_SHIFT (24) +#define ESR_ELx_ISV (UL(1) << ESR_ELx_ISV_SHIFT) +#define ESR_ELx_SAS_SHIFT (22) +#define ESR_ELx_SAS (UL(3) << ESR_ELx_SAS_SHIFT) +#define ESR_ELx_SSE_SHIFT (21) +#define ESR_ELx_SSE (UL(1) << ESR_ELx_SSE_SHIFT) +#define ESR_ELx_SRT_SHIFT (16) +#define ESR_ELx_SRT_MASK (UL(0x1F) << ESR_ELx_SRT_SHIFT) +#define ESR_ELx_SF_SHIFT (15) +#define ESR_ELx_SF (UL(1) << ESR_ELx_SF_SHIFT) +#define ESR_ELx_AR_SHIFT (14) +#define ESR_ELx_AR (UL(1) << ESR_ELx_AR_SHIFT) +#define ESR_ELx_CM_SHIFT (8) +#define ESR_ELx_CM (UL(1) << ESR_ELx_CM_SHIFT) + +/* ISS field definitions for exceptions taken in to Hyp */ +#define ESR_ELx_CV (UL(1) << 24) +#define ESR_ELx_COND_SHIFT (20) +#define ESR_ELx_COND_MASK (UL(0xF) << ESR_ELx_COND_SHIFT) +#define ESR_ELx_WFx_ISS_TI (UL(1) << 0) +#define ESR_ELx_WFx_ISS_WFI (UL(0) << 0) +#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0) +#define ESR_ELx_xVC_IMM_MASK ((1UL << 16) - 1) + +#define DISR_EL1_IDS (UL(1) << 24) +/* +* DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean +* different things in the future... +*/ +#define DISR_EL1_ESR_MASK (ESR_ELx_AET | ESR_ELx_EA | ESR_ELx_FSC) + +/* ESR value templates for specific events */ +#define ESR_ELx_WFx_MASK (ESR_ELx_EC_MASK | ESR_ELx_WFx_ISS_TI) +#define ESR_ELx_WFx_WFI_VAL ((ESR_ELx_EC_WFx << ESR_ELx_EC_SHIFT) | \ + ESR_ELx_WFx_ISS_WFI) + +/* BRK instruction trap from AArch64 state */ +#define ESR_ELx_BRK64_ISS_COMMENT_MASK 0xffff + +/* ISS field definitions for System instruction traps */ +#define ESR_ELx_SYS64_ISS_RES0_SHIFT 22 +#define ESR_ELx_SYS64_ISS_RES0_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_RES0_SHIFT) +#define ESR_ELx_SYS64_ISS_DIR_MASK 0x1 +#define ESR_ELx_SYS64_ISS_DIR_READ 0x1 +#define ESR_ELx_SYS64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_SYS64_ISS_RT_SHIFT 5 +#define ESR_ELx_SYS64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_SYS64_ISS_RT_SHIFT) +#define ESR_ELx_SYS64_ISS_CRM_SHIFT 1 +#define ESR_ELx_SYS64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRM_SHIFT) +#define ESR_ELx_SYS64_ISS_CRN_SHIFT 10 +#define ESR_ELx_SYS64_ISS_CRN_MASK (UL(0xf) << ESR_ELx_SYS64_ISS_CRN_SHIFT) +#define ESR_ELx_SYS64_ISS_OP1_SHIFT 14 +#define ESR_ELx_SYS64_ISS_OP1_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP1_SHIFT) +#define ESR_ELx_SYS64_ISS_OP2_SHIFT 17 +#define ESR_ELx_SYS64_ISS_OP2_MASK (UL(0x7) << ESR_ELx_SYS64_ISS_OP2_SHIFT) +#define ESR_ELx_SYS64_ISS_OP0_SHIFT 20 +#define ESR_ELx_SYS64_ISS_OP0_MASK (UL(0x3) << ESR_ELx_SYS64_ISS_OP0_SHIFT) +#define ESR_ELx_SYS64_ISS_SYS_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_CRM_MASK) +#define ESR_ELx_SYS64_ISS_SYS_VAL (op0, op1, op2, crn, crm) \ + (((op0) << ESR_ELx_SYS64_ISS_OP0_SHIFT) | \ + ((op1) << ESR_ELx_SYS64_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_SYS64_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_SYS64_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_SYS64_ISS_CRM_SHIFT)) + +#define ESR_ELx_SYS64_ISS_SYS_OP_MASK (ESR_ELx_SYS64_ISS_SYS_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_RT (esr) \ + (((esr) & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT) +/* +* User space cache operations have the following sysreg encoding +* in System instructions. +* op0=1, op1=3, op2=1, crn=7, crm={ 5, 10, 11, 12, 13, 14 }, WRITE (L=0) +*/ +#define ESR_ELx_SYS64_ISS_CRM_DC_CIVAC 14 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVADP 13 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAP 12 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAU 11 +#define ESR_ELx_SYS64_ISS_CRM_DC_CVAC 10 +#define ESR_ELx_SYS64_ISS_CRM_IC_IVAU 5 + +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_OP2_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_EL0_CACHE_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(1, 3, 1, 7, 0) | \ + ESR_ELx_SYS64_ISS_DIR_WRITE) +/* +* User space MRS operations which are supported for emulation +* have the following sysreg encoding in System instructions. +* op0 = 3, op1= 0, crn = 0, {crm = 0, 4-7}, READ (L = 1) +*/ +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_MASK (ESR_ELx_SYS64_ISS_OP0_MASK | \ + ESR_ELx_SYS64_ISS_OP1_MASK | \ + ESR_ELx_SYS64_ISS_CRN_MASK | \ + ESR_ELx_SYS64_ISS_DIR_MASK) +#define ESR_ELx_SYS64_ISS_SYS_MRS_OP_VAL \ + (ESR_ELx_SYS64_ISS_SYS_VAL(3, 0, 0, 0, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CTR ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 1, 0, 0) +#define ESR_ELx_SYS64_ISS_SYS_CTR_READ (ESR_ELx_SYS64_ISS_SYS_CTR | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCT (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 2, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTVCTSS (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 6, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define ESR_ELx_SYS64_ISS_SYS_CNTFRQ (ESR_ELx_SYS64_ISS_SYS_VAL(3, 3, 0, 14, 0) | \ + ESR_ELx_SYS64_ISS_DIR_READ) + +#define esr_sys64_to_sysreg (e) \ + sys_reg((((e) & ESR_ELx_SYS64_ISS_OP0_MASK) >> \ + ESR_ELx_SYS64_ISS_OP0_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +#define esr_cp15_to_sysreg (e) \ + sys_reg(3, \ + (((e) & ESR_ELx_SYS64_ISS_OP1_MASK) >> \ + ESR_ELx_SYS64_ISS_OP1_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRN_MASK) >> \ + ESR_ELx_SYS64_ISS_CRN_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_CRM_MASK) >> \ + ESR_ELx_SYS64_ISS_CRM_SHIFT), \ + (((e) & ESR_ELx_SYS64_ISS_OP2_MASK) >> \ + ESR_ELx_SYS64_ISS_OP2_SHIFT)) + +/* +* ISS field definitions for floating-point exception traps +* (FP_EXC_32/FP_EXC_64). +* +* (The FPEXC_* constants are used instead for common bits.) +*/ + +#define ESR_ELx_FP_EXC_TFV (UL(1) << 23) + +/* +* ISS field definitions for CP15 accesses +*/ +#define ESR_ELx_CP15_32_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_32_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_32_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_32_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_32_ISS_RT_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_32_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRM_SHIFT) +#define ESR_ELx_CP15_32_ISS_CRN_SHIFT 10 +#define ESR_ELx_CP15_32_ISS_CRN_MASK (UL(0xf) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP1_SHIFT 14 +#define ESR_ELx_CP15_32_ISS_OP1_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_32_ISS_OP2_SHIFT 17 +#define ESR_ELx_CP15_32_ISS_OP2_MASK (UL(0x7) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) + +#define ESR_ELx_CP15_32_ISS_SYS_MASK (ESR_ELx_CP15_32_ISS_OP1_MASK | \ + ESR_ELx_CP15_32_ISS_OP2_MASK | \ + ESR_ELx_CP15_32_ISS_CRN_MASK | \ + ESR_ELx_CP15_32_ISS_CRM_MASK | \ + ESR_ELx_CP15_32_ISS_DIR_MASK) +#define ESR_ELx_CP15_32_ISS_SYS_VAL (op1, op2, crn, crm) \ + (((op1) << ESR_ELx_CP15_32_ISS_OP1_SHIFT) | \ + ((op2) << ESR_ELx_CP15_32_ISS_OP2_SHIFT) | \ + ((crn) << ESR_ELx_CP15_32_ISS_CRN_SHIFT) | \ + ((crm) << ESR_ELx_CP15_32_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_DIR_MASK 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_READ 0x1 +#define ESR_ELx_CP15_64_ISS_DIR_WRITE 0x0 + +#define ESR_ELx_CP15_64_ISS_RT_SHIFT 5 +#define ESR_ELx_CP15_64_ISS_RT_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT_SHIFT) + +#define ESR_ELx_CP15_64_ISS_RT2_SHIFT 10 +#define ESR_ELx_CP15_64_ISS_RT2_MASK (UL(0x1f) << ESR_ELx_CP15_64_ISS_RT2_SHIFT) + +#define ESR_ELx_CP15_64_ISS_OP1_SHIFT 16 +#define ESR_ELx_CP15_64_ISS_OP1_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) +#define ESR_ELx_CP15_64_ISS_CRM_SHIFT 1 +#define ESR_ELx_CP15_64_ISS_CRM_MASK (UL(0xf) << ESR_ELx_CP15_64_ISS_CRM_SHIFT) + +#define ESR_ELx_CP15_64_ISS_SYS_VAL (op1, crm) \ + (((op1) << ESR_ELx_CP15_64_ISS_OP1_SHIFT) | \ + ((crm) << ESR_ELx_CP15_64_ISS_CRM_SHIFT)) + +#define ESR_ELx_CP15_64_ISS_SYS_MASK (ESR_ELx_CP15_64_ISS_OP1_MASK | \ + ESR_ELx_CP15_64_ISS_CRM_MASK | \ + ESR_ELx_CP15_64_ISS_DIR_MASK) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCT (ESR_ELx_CP15_64_ISS_SYS_VAL(1, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_64_ISS_SYS_CNTVCTSS (ESR_ELx_CP15_64_ISS_SYS_VAL(9, 14) | \ + ESR_ELx_CP15_64_ISS_DIR_READ) + +#define ESR_ELx_CP15_32_ISS_SYS_CNTFRQ (ESR_ELx_CP15_32_ISS_SYS_VAL(0, 0, 14, 0) |\ + ESR_ELx_CP15_32_ISS_DIR_READ) + +#ifndef __ASSEMBLY__ +#include <asm/types.h> + +static inline bool esr_is_data_abort (u32 esr) +{ +const u32 ec =ESR_ELx_EC (esr); + +return ec == ESR_ELx_EC_DABT_LOW || ec == ESR_ELx_EC_DABT_CUR; +} + +const char *esr_get_class_string (u32 esr); +#endif /* __ASSEMBLY */ + +#endif /* __ASM_ESR_H */
Signature · 1 line
Pierre
Re: [PATCH 9/9] arm64: Import <asm/esr.h> from Linux
Quoted 40 lines · Pierre-Clément Tosi
Quoted 23 lines · Sean Anderson
Quoted 22 lines · Pierre-Clément Tosi
Import the header from version 5.16 of the kernel:
commit df0cc57e057f18e44dac8e6c18aba47ab53202f9Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Tom Rini <[email protected]>--- arch/arm/include/asm/esr.h | 343 +++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+)create mode 100644
arch/arm/include/asm/esr.harch/arm/include/asm/esr.h new file +5
-0@@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2013 - ARM Ltd +* Author: Marc Zyngier <[email protected]> +*/ Quoted 8 lines
arch/arm/include/asm/esr.h line 11
Quoted 6 lines
arch/arm/include/asm/esr.h new file +6
-0+ +#ifndef __ASM_ESR_H +#define __ASM_ESR_H + +#include <asm/memory.h> +#include <asm/sysreg.h> I think this is just needed for the UL macros. See e.g. [1].
I think you're right about <
asm/memory.h> being included forUL(), as pointed out by commitd7a33f4fbd12("arm64/debug: Add missing #includes"), which could (should?) be replaced by <linux/const.h>. But the esr_*_to_sysreg() macros require <asm/sysreg.h> and, even if it's unlikely for U-Boot to use them, that header brings many useful macros of its own anyway.Quoted 1 line
Quoted 7 lines
Quoted 3 lines
--Sean
Thanks, I wasn't aware of that patch; should I drop this one or instead rebase it on top of yours to re-#include
sysreg.honce it's been made available by this series?
That would be best. checkpatch does not like sysreg.h very much :)
--Sean
Quoted 31 lines · Pierre-Clément Tosi
Swap the arguments as that seems to have been the author's intention.
Note: This fix wasn't tested on hardware and will result in more bits
being set by the underlyingwritel()inrk_clrsetreg(), which might bring unexpected behavioural changes.Fixes b07911840025 ("net: gmac_rockchip: add support for px30")Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Joe Hershberger <[email protected]>Cc Heiko Stuebner <[email protected]>Cc Kever Yang <[email protected]>Cc Tom Rini <[email protected]>--- drivers/net/gmac_rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/gmac_rockchip.c +1
-2@@ -350,7 +350,7 @@ static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)struct px30_grf *grf;enum {PX30_GMAC_PHY_INTF_SEL_SHIFT =4 , -PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (4 ,6 ), +PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (6 ,4 ),PX30_GMAC_PHY_INTF_SEL_RMII =BIT (6 ), }; --
Quoted 2 lines
2.35.1.723.g4982287a31-goog
I would love to see tested-by before I merge this.
Add David,
Hi David,
Could you help to check this patch?
Thanks,
- Kever
Quoted 29 lines · Pierre-Clément Tosi
Swap the arguments as that seems to have been the author's intention.
Note: This fix wasn't tested on hardware and will result in more bits
being set by the underlyingwritel()inrk_clrsetreg(), which might bring unexpected behavioural changes.Fixes b07911840025 ("net: gmac_rockchip: add support for px30")Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Joe Hershberger <[email protected]>Cc Heiko Stuebner <[email protected]>Cc Kever Yang <[email protected]>Cc Tom Rini <[email protected]>--- drivers/net/gmac_rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/gmac_rockchip.c +1
-1@@ -350,7 +350,7 @@ static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)struct px30_grf *grf;enum {PX30_GMAC_PHY_INTF_SEL_SHIFT =4 , -PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (4 ,6 ), +PX30_GMAC_PHY_INTF_SEL_MASK =GENMASK (6 ,4 ),PX30_GMAC_PHY_INTF_SEL_RMII =BIT (6 ), };
David Wu
Reviewed-byHi Pierre-Clément,
Thanks for your correction, there was wrong mask here.
Quoted 39 lines · Kever Yang
Add David,
Hi David,
Could you help to check this patch?
Thanks,
- KeverQuoted 29 lines · Pierre-Clément Tosi
Swap the arguments as that seems to have been the author's intention.
Note: This fix wasn't tested on hardware and will result in more bits being set by the underlying
writel()inrk_clrsetreg(), which might bring unexpected behavioural changes.Fixes b07911840025 ("net: gmac_rockchip: add support for px30")Signed-off-by Pierre-Clément Tosi <[email protected]>Cc Joe Hershberger <[email protected]>Cc Heiko Stuebner <[email protected]>Cc Kever Yang <[email protected]>Cc Tom Rini <[email protected]>---
drivers/net/gmac_rockchip.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/gmac_rockchip.c +1
-1@@ -350,7 +350,7 @@ static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata) struct px30_grf *grf; enum { PX30_GMAC_PHY_INTF_SEL_SHIFT = 4, - PX30_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 6), + PX30_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4), PX30_GMAC_PHY_INTF_SEL_RMII = BIT(6), };