arm64: mm: fix spurious fault detection
Mark Rutland
reviewerPATCH 1/1 arm64: mm: fix spurious fault detection
When detecting a spurious EL1 translation fault, we attempt to compare ESR_EL1.DFSC with PAR_EL1.FST. We erroneously use FIELD_PREP() to extract PAR_EL1.FST, when we should be using FIELD_GET().
In the wise words of Robin Murphy:
| FIELD_GET() is a UBFX, FIELD_PREP() is a BFI
Using FIELD_PREP() means that that dfsc & ESR_ELx_FSC_TYPE is always zero, and hence not equal to ESR_ELx_FSC_FAULT. Thus we detect any unhandled translation fault as spurious.
... so let's use FIELD_GET() to ensure we don't decide all translation faults are spurious. ESR_EL1.DFSC occupies bits [5:0], and requires no shifting.
--- arch/arm64/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/fault.c +1 -1
@@ -266,7 +266,7 @@ static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr,* If we got a different type of fault from the AT instruction, * treat the translation fault as spurious. */ - dfsc =FIELD_PREP (SYS_PAR_EL1_FST , par); + dfsc =FIELD_GET (SYS_PAR_EL1_FST , par);return (dfsc & ESR_ELx_FSC_TYPE) != ESR_ELx_FSC_FAULT; }
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewer[Correcting Will's address]
Quoted 16 lines · Mark Rutland
When detecting a spurious EL1 translation fault, we attempt to compare ESR_EL1.DFSC with PAR_EL1.FST. We erroneously use
FIELD_PREP()to extract PAR_EL1.FST, when we should be usingFIELD_GET().In the wise words of Robin Murphy:
|
FIELD_GET()is a UBFX,FIELD_PREP()is a BFIUsing
FIELD_PREP()means that that dfsc &ESR_ELx_FSC_TYPEis always zero, and hence not equal toESR_ELx_FSC_FAULT. Thus we detect any unhandled translation fault as spurious.... so let's use
FIELD_GET()to ensure we don't decide all translation faults are spurious. ESR_EL1.DFSC occupies bits [5:0], and requires no shifting.
Quoted 6 lines
Fixes 42f91093b043332a ("arm64: mm: Ignore spurious translation faults taken from the kernel")Signed-off-by Mark Rutland <[email protected]>Reported-by Robin Murphy <[email protected]>Cc Catalin Marinas <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>
Whoops, that should be <[email protected]>.
Mark.
Quoted 25 lines
--- arch/arm64/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/mm/fault.c +1
-1@@ -266,7 +266,7 @@ static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr,* If we got a different type of fault from the AT instruction, * treat the translation fault as spurious. */ - dfsc =FIELD_PREP (SYS_PAR_EL1_FST , par); + dfsc =FIELD_GET (SYS_PAR_EL1_FST , par);return (dfsc & ESR_ELx_FSC_TYPE) != ESR_ELx_FSC_FAULT; }Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
arch/arm64/mm/fault.c static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr,
Quoted 31 lines · Mark Rutland
When detecting a spurious EL1 translation fault, we attempt to compare ESR_EL1.DFSC with PAR_EL1.FST. We erroneously use
FIELD_PREP()to extract PAR_EL1.FST, when we should be usingFIELD_GET().In the wise words of Robin Murphy:
|
FIELD_GET()is a UBFX,FIELD_PREP()is a BFIUsing
FIELD_PREP()means that that dfsc &ESR_ELx_FSC_TYPEis always zero, and hence not equal toESR_ELx_FSC_FAULT. Thus we detect any unhandled translation fault as spurious.... so let's use
FIELD_GET()to ensure we don't decide all translation faults are spurious. ESR_EL1.DFSC occupies bits [5:0], and requires no shifting.Fixes 42f91093b043332a ("arm64: mm: Ignore spurious translation faults taken from the kernel")Signed-off-by Mark Rutland <[email protected]>Reported-by Robin Murphy <[email protected]>Cc Catalin Marinas <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>--- arch/arm64/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/mm/fault.c +0
-0@@ -266,7 +266,7 @@ static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr,
A small nit, pt_regs pointer argument is not required and can be dropped.
arch/arm64/mm/fault.c static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr, · line 269
Quoted 5 lines
arch/arm64/mm/fault.c +1
-1* If we got a different type of fault from the AT instruction, * treat the translation fault as spurious. */ - dfsc =FIELD_PREP (SYS_PAR_EL1_FST , par); + dfsc =FIELD_GET (SYS_PAR_EL1_FST , par);
FIELD_* functions are not getting used any where other drivers. Though this patch did not add that but just wondering why there are no non-driver use cases for these helpers.
arch/arm64/mm/fault.c static bool __kprobes is_spurious_el1_translation_fault(unsigned long addr, · line 272
Quoted 4 lines
arch/arm64/mm/fault.c +0
-0return (dfsc & ESR_ELx_FSC_TYPE) != ESR_ELx_FSC_FAULT; }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel