linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: mm: fix spurious fault detection
@ 2019-10-04 13:58 Mark Rutland
  2019-10-04 14:00 ` Mark Rutland
  2019-10-05  9:06 ` Anshuman Khandual
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Rutland @ 2019-10-04 13:58 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Mark Rutland, Catalin Marinas, Robin Murphy, James Morse, Will Deacon

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.

Fixes: 42f91093b043332a ("arm64: mm: Ignore spurious translation faults taken from the kernel")
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reported-by: Robin Murphy <robin.murphy@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will.deacon@kernel.org>
---
 arch/arm64/mm/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 115d7a0e4b08..b0074b91913b 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -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;
 }
 
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: mm: fix spurious fault detection
  2019-10-04 13:58 [PATCH] arm64: mm: fix spurious fault detection Mark Rutland
@ 2019-10-04 14:00 ` Mark Rutland
  2019-10-05  9:06 ` Anshuman Khandual
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2019-10-04 14:00 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Catalin Marinas, Robin Murphy, James Morse, Will Deacon

[Correcting Will's address]

On Fri, Oct 04, 2019 at 02:58:47PM +0100, Mark Rutland wrote:
> 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.
> 
> Fixes: 42f91093b043332a ("arm64: mm: Ignore spurious translation faults taken from the kernel")
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Reported-by: Robin Murphy <robin.murphy@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Will Deacon <will.deacon@kernel.org>

Whoops, that should be <will@kernel.org>.

Mark.

> ---
>  arch/arm64/mm/fault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index 115d7a0e4b08..b0074b91913b 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -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;
>  }
>  
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: mm: fix spurious fault detection
  2019-10-04 13:58 [PATCH] arm64: mm: fix spurious fault detection Mark Rutland
  2019-10-04 14:00 ` Mark Rutland
@ 2019-10-05  9:06 ` Anshuman Khandual
  1 sibling, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2019-10-05  9:06 UTC (permalink / raw)
  To: Mark Rutland, linux-arm-kernel
  Cc: Catalin Marinas, Robin Murphy, James Morse, Will Deacon


On 10/04/2019 07:28 PM, Mark Rutland wrote:
> 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.
> 
> Fixes: 42f91093b043332a ("arm64: mm: Ignore spurious translation faults taken from the kernel")
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Reported-by: Robin Murphy <robin.murphy@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Will Deacon <will.deacon@kernel.org>
> ---
>  arch/arm64/mm/fault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
> index 115d7a0e4b08..b0074b91913b 100644
> --- a/arch/arm64/mm/fault.c
> +++ b/arch/arm64/mm/fault.c
> @@ -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.

>  	 * 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.

>  	return (dfsc & ESR_ELx_FSC_TYPE) != ESR_ELx_FSC_FAULT;
>  }
>  
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-05  9:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 13:58 [PATCH] arm64: mm: fix spurious fault detection Mark Rutland
2019-10-04 14:00 ` Mark Rutland
2019-10-05  9:06 ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).