diff options
author | Mark Rutland <mark.rutland@arm.com> | 2016-05-31 07:33:01 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2016-06-21 12:07:09 -0400 |
commit | 275f344bec51e9100bae81f3cc8c6940bbfb24c0 (patch) | |
tree | eac2a9c274c24ac8e3e8e15dca05f9ffb5c24938 | |
parent | b67a8b29df7e6410c605c2759707c96512b15578 (diff) |
arm64: add macro to extract ESR_ELx.EC
Several places open-code extraction of the EC field from an ESR_ELx
value, in subtly different ways. This is unfortunate duplication and
variation, and the precise logic used to extract the field is a
distraction.
This patch adds a new macro, ESR_ELx_EC(), to extract the EC field from
an ESR_ELx value in a consistent fashion.
Existing open-coded extractions in core arm64 code are moved over to the
new helper. KVM code is left as-is for the moment.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Huang Shijie <shijie.huang@arm.com>
Cc: Dave P Martin <dave.martin@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/include/asm/esr.h | 1 | ||||
-rw-r--r-- | arch/arm64/kernel/traps.c | 2 | ||||
-rw-r--r-- | arch/arm64/mm/fault.c | 2 |
3 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h index 77eeb2cc648f..f772e15c4766 100644 --- a/arch/arm64/include/asm/esr.h +++ b/arch/arm64/include/asm/esr.h | |||
@@ -74,6 +74,7 @@ | |||
74 | 74 | ||
75 | #define ESR_ELx_EC_SHIFT (26) | 75 | #define ESR_ELx_EC_SHIFT (26) |
76 | #define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) | 76 | #define ESR_ELx_EC_MASK (UL(0x3F) << ESR_ELx_EC_SHIFT) |
77 | #define ESR_ELx_EC(esr) (((esr) & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT) | ||
77 | 78 | ||
78 | #define ESR_ELx_IL (UL(1) << 25) | 79 | #define ESR_ELx_IL (UL(1) << 25) |
79 | #define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) | 80 | #define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1) |
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index d9da2c56e4f8..a4250a59f2b9 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c | |||
@@ -456,7 +456,7 @@ static const char *esr_class_str[] = { | |||
456 | 456 | ||
457 | const char *esr_get_class_string(u32 esr) | 457 | const char *esr_get_class_string(u32 esr) |
458 | { | 458 | { |
459 | return esr_class_str[esr >> ESR_ELx_EC_SHIFT]; | 459 | return esr_class_str[ESR_ELx_EC(esr)]; |
460 | } | 460 | } |
461 | 461 | ||
462 | /* | 462 | /* |
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 013e2cbe7924..d2c124cbd18c 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c | |||
@@ -244,7 +244,7 @@ out: | |||
244 | 244 | ||
245 | static inline int permission_fault(unsigned int esr) | 245 | static inline int permission_fault(unsigned int esr) |
246 | { | 246 | { |
247 | unsigned int ec = (esr & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT; | 247 | unsigned int ec = ESR_ELx_EC(esr); |
248 | unsigned int fsc_type = esr & ESR_ELx_FSC_TYPE; | 248 | unsigned int fsc_type = esr & ESR_ELx_FSC_TYPE; |
249 | 249 | ||
250 | return (ec == ESR_ELx_EC_DABT_CUR && fsc_type == ESR_ELx_FSC_PERM); | 250 | return (ec == ESR_ELx_EC_DABT_CUR && fsc_type == ESR_ELx_FSC_PERM); |