Commit 275f344b authored by Mark Rutland's avatar Mark Rutland Committed by Catalin Marinas
Browse files

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

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: default avatarMark Rutland <>
Tested-by: default avatarHuang Shijie <>
Cc: Dave P Martin <>
Cc: James Morse <>
Cc: Marc Zyngier <>
Cc: Will Deacon <>
Signed-off-by: default avatarCatalin Marinas <>
parent b67a8b29
......@@ -74,6 +74,7 @@
#define ESR_ELx_EC_SHIFT (26)
#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 (UL(1) << 25)
#define ESR_ELx_ISS_MASK (ESR_ELx_IL - 1)
......@@ -456,7 +456,7 @@ static const char *esr_class_str[] = {
const char *esr_get_class_string(u32 esr)
return esr_class_str[esr >> ESR_ELx_EC_SHIFT];
return esr_class_str[ESR_ELx_EC(esr)];
......@@ -244,7 +244,7 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
static inline int permission_fault(unsigned int esr)
unsigned int ec = (esr & ESR_ELx_EC_MASK) >> ESR_ELx_EC_SHIFT;
unsigned int ec = ESR_ELx_EC(esr);
unsigned int fsc_type = esr & ESR_ELx_FSC_TYPE;
return (ec == ESR_ELx_EC_DABT_CUR && fsc_type == ESR_ELx_FSC_PERM);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment