linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: only advance singlestep for user instruction traps
Date: Thu, 5 Apr 2018 10:51:45 +0900	[thread overview]
Message-ID: <20180405015144.GC19607@linaro.org> (raw)
In-Reply-To: <20180403102251.42309-1-mark.rutland@arm.com>

On Tue, Apr 03, 2018 at 11:22:51AM +0100, Mark Rutland wrote:
> Our arm64_skip_faulting_instruction() helper advances the userspace
> singlestep state machine, but this is also called by the kernel BRK
> handler, as used for WARN*().
> 
> Thus, if we happen to hit a WARN*() while the user singlestep state
> machine is in the active-no-pending state, we'll advance to the
> active-pending state without having executed a user instruction, and
> will take a step exception earlier than expected when we return to
> userspace.
> 
> Let's fix this by only advancing the state machine when skipping a user
> instruction.

Is it possible to have TIF_SINGLESTEP set even if !user_mode()?

If WARN*() is only an issue, why not fix bug_handler() directly?

-Takahiro AKASHI


> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Andrey Konovalov <andreyknvl@google.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm64/kernel/traps.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index ba964da31a25..75625a401a4e 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -277,7 +277,8 @@ void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size)
>  	 * If we were single stepping, we want to get the step exception after
>  	 * we return from the trap.
>  	 */
> -	user_fastforward_single_step(current);
> +	if (user_mode(regs))
> +		user_fastforward_single_step(current);
>  }
>  
>  static LIST_HEAD(undef_hook);
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2018-04-05  1:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 10:22 [PATCH] arm64: only advance singlestep for user instruction traps Mark Rutland
2018-04-05  1:51 ` AKASHI Takahiro [this message]
2018-04-05 10:05   ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180405015144.GC19607@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).