All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: handle sys and undef traps consistently
@ 2017-01-27 16:15 Mark Rutland
  2017-01-27 16:35 ` Catalin Marinas
  2017-01-27 16:41 ` Suzuki K Poulose
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Rutland @ 2017-01-27 16:15 UTC (permalink / raw)
  To: linux-arm-kernel

If an EL0 instruction in the SYS class triggers an exception, do_sysintr
looks for a sys64_hook matching the instruction, and if none is found,
injects a SIGILL. This mirrors what we do for undefined instruction
encodings in do_undefinstr, where we look for an undef_hook matching the
instruction, and if none is found, inject a SIGILL.

Over time, new SYS instruction encodings may be allocated. Prior to
allocation, exceptions resulting from these would be handled by
do_undefinstr, whereas after allocation these may be handled by
do_sysintr.

To ensure that we have consistent behaviour if and when this happens, it
would be beneficial to have do_sysinstr fall back to do_undefinstr.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/kernel/traps.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 8187229..7c3fc06 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -531,7 +531,12 @@ asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs)
 			return;
 		}
 
-	force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
+	/*
+	 * New SYS instructions may previously have been undefined at EL0. Fall
+	 * back to our usual undefined instruction handler so that we handle
+	 * these consistently.
+	 */
+	do_undefinstr(regs);
 }
 
 long compat_arm_syscall(struct pt_regs *regs);
-- 
1.9.1

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

* [PATCH] arm64: handle sys and undef traps consistently
  2017-01-27 16:15 [PATCH] arm64: handle sys and undef traps consistently Mark Rutland
@ 2017-01-27 16:35 ` Catalin Marinas
  2017-01-27 16:41 ` Suzuki K Poulose
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2017-01-27 16:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jan 27, 2017 at 04:15:38PM +0000, Mark Rutland wrote:
> If an EL0 instruction in the SYS class triggers an exception, do_sysintr
> looks for a sys64_hook matching the instruction, and if none is found,
> injects a SIGILL. This mirrors what we do for undefined instruction
> encodings in do_undefinstr, where we look for an undef_hook matching the
> instruction, and if none is found, inject a SIGILL.
> 
> Over time, new SYS instruction encodings may be allocated. Prior to
> allocation, exceptions resulting from these would be handled by
> do_undefinstr, whereas after allocation these may be handled by
> do_sysintr.
> 
> To ensure that we have consistent behaviour if and when this happens, it
> would be beneficial to have do_sysinstr fall back to do_undefinstr.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Suzuki Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

* [PATCH] arm64: handle sys and undef traps consistently
  2017-01-27 16:15 [PATCH] arm64: handle sys and undef traps consistently Mark Rutland
  2017-01-27 16:35 ` Catalin Marinas
@ 2017-01-27 16:41 ` Suzuki K Poulose
  1 sibling, 0 replies; 3+ messages in thread
From: Suzuki K Poulose @ 2017-01-27 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 27/01/17 16:15, Mark Rutland wrote:
> If an EL0 instruction in the SYS class triggers an exception, do_sysintr
> looks for a sys64_hook matching the instruction, and if none is found,
> injects a SIGILL. This mirrors what we do for undefined instruction
> encodings in do_undefinstr, where we look for an undef_hook matching the
> instruction, and if none is found, inject a SIGILL.
>
> Over time, new SYS instruction encodings may be allocated. Prior to
> allocation, exceptions resulting from these would be handled by
> do_undefinstr, whereas after allocation these may be handled by
> do_sysintr.
>
> To ensure that we have consistent behaviour if and when this happens, it
> would be beneficial to have do_sysinstr fall back to do_undefinstr.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Suzuki Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/kernel/traps.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index 8187229..7c3fc06 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -531,7 +531,12 @@ asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs)
>  			return;
>  		}
>
> -	force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
> +	/*
> +	 * New SYS instructions may previously have been undefined at EL0. Fall
> +	 * back to our usual undefined instruction handler so that we handle
> +	 * these consistently.
> +	 */
> +	do_undefinstr(regs);
>  }
>
>  long compat_arm_syscall(struct pt_regs *regs);
>

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>

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

end of thread, other threads:[~2017-01-27 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27 16:15 [PATCH] arm64: handle sys and undef traps consistently Mark Rutland
2017-01-27 16:35 ` Catalin Marinas
2017-01-27 16:41 ` Suzuki K Poulose

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.