linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: kernel: Fix unmasked debug exceptions when restoring mdscr_el1
Date: Fri, 26 Aug 2016 17:39:47 +0100	[thread overview]
Message-ID: <20160826163947.GB23885@red-moon> (raw)
In-Reply-To: <1472223822-21059-1-git-send-email-james.morse@arm.com>

On Fri, Aug 26, 2016 at 04:03:42PM +0100, James Morse wrote:
> Changes to make the resume from cpu_suspend() code behave more like
> secondary boot caused debug exceptions to be unmasked early by
> __cpu_setup(). We then go on to restore mdscr_el1 in cpu_do_resume(),
> potentially taking break or watch points based on uninitialised registers.

Another option would be moving enable_dbg() out of __cpu_setup() and
calling when it returns in the cold boot path, that would not change
much in terms of debugging but we would avoid fiddling about with
daif three times in the resume path just to restore it to what it
was on suspend entry :)

Thanks !
Lorenzo

> Mask debug exceptions in cpu_do_resume(), which is specific to resume
> from cpu_suspend(). Debug exceptions will be restored to their original
> state by local_dbg_restore() in cpu_suspend(), which runs after
> hw_breakpoint_restore() has re-initialised the other registers.
> 
> Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Fixes: cabe1c81ea5b ("arm64: Change cpu_resume() to enable mmu early then access sleep_sp by va")
> Cc: <stable@vger.kernel.org> #4.7
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
>  arch/arm64/mm/proc.S | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
> index 5bb61de23201..9d37e967fa19 100644
> --- a/arch/arm64/mm/proc.S
> +++ b/arch/arm64/mm/proc.S
> @@ -100,7 +100,16 @@ ENTRY(cpu_do_resume)
>  
>  	msr	tcr_el1, x8
>  	msr	vbar_el1, x9
> +
> +	/*
> +	 * __cpu_setup() cleared MDSCR_EL1.MDE and friends, before unmasking
> +	 * debug exceptions. By restoring MDSCR_EL1 here, we may take a debug
> +	 * exception. Mask them until local_dbg_restore() in cpu_suspend()
> +	 * resets them.
> +	 */
> +	disable_dbg
>  	msr	mdscr_el1, x10
> +
>  	msr	sctlr_el1, x12
>  	/*
>  	 * Restore oslsr_el1 by writing oslar_el1
> -- 
> 2.8.0.rc3
> 

  reply	other threads:[~2016-08-26 16:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 15:03 [PATCH] arm64: kernel: Fix unmasked debug exceptions when restoring mdscr_el1 James Morse
2016-08-26 16:39 ` Lorenzo Pieralisi [this message]
2016-08-31  7:35   ` James Morse
2016-08-30 16:53 ` Will Deacon

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=20160826163947.GB23885@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --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).