LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Bharat Bhushan <r65777@freescale.com>
Cc: Bharat Bhushan <Bharat.Bhushan@freescale.com>,
	stuart.yoder@freescale.com, James.Yang@freescale.com,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/2 v2] powerpc: restore dbcr0 on user space exit
Date: Thu, 16 May 2013 11:54:17 -0500	[thread overview]
Message-ID: <1368723257.8202.43@snotra> (raw)
In-Reply-To: <1368682472-4268-3-git-send-email-Bharat.Bhushan@freescale.com> (from r65777@freescale.com on Thu May 16 00:34:32 2013)

On 05/16/2013 12:34:32 AM, Bharat Bhushan wrote:
> On BookE (Branch taken + Single Step) is as same as Branch Taken
> on BookS and in Linux we simulate BookS behavior for BookE as well.
> When doing so, in Branch taken handling we want to set DBCR0_IC but
> we update the current->thread->dbcr0 and not DBCR0.
>=20
> Now on 64bit the current->thread.dbcr0 (and other debug registers)
> is synchronized ONLY on context switch flow. But after handling
> Branch taken in debug exception if we return back to user space
> without context switch then single stepping change (DBCR0_ICMP)
> does not get written in h/w DBCR0 and Instruction Complete exception
> does not happen.
>=20
> This fixes using ptrace reliably on BookE-PowerPC
>=20
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> v1->v2
>  - Subject line was not having 2/2
>=20
>  arch/powerpc/kernel/asm-offsets.c |    1 +
>  arch/powerpc/kernel/entry_64.S    |   24 ++++++++++++++++++++----
>  2 files changed, 21 insertions(+), 4 deletions(-)
>=20
> diff --git a/arch/powerpc/kernel/asm-offsets.c =20
> b/arch/powerpc/kernel/asm-offsets.c
> index b51a97c..1e2f450 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -103,6 +103,7 @@ int main(void)
>  #endif /* CONFIG_VSX */
>  #ifdef CONFIG_PPC64
>  	DEFINE(KSP_VSID, offsetof(struct thread_struct, ksp_vsid));
> +	DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
>  #else /* CONFIG_PPC64 */
>  	DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
>  #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
> diff --git a/arch/powerpc/kernel/entry_64.S =20
> b/arch/powerpc/kernel/entry_64.S
> index 794889b..561630d 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -614,7 +614,9 @@ _GLOBAL(ret_from_except_lite)
>  	 * from the interrupt.
>  	 */
>  #ifdef CONFIG_PPC_BOOK3E
> +	ld	r3,PACACURRENT(r13)
>  	wrteei	0
> +	lwz	r10,(THREAD+THREAD_DBCR0)(r3)

I know I asked you to move these earlier, but this is probably too =20
early... wrteei has synchronization, so it will probably have to wait =20
until the ld completes, defeating the purpose of moving it earlier.

Ideal would probably be to load PACACURRENT immediately after _MSR(r1), =20
and load DBCR0 just after "beq resume_kernel".

Or, move DBCR0 to therad_info as I suggested internally.

Regardless of what you do, could you run a basic syscall benchmark =20
(e.g. from lmbench) before and after the patch?

-Scott=

  reply	other threads:[~2013-05-16 16:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16  5:34 [PATCH 0/2 v2] powerpc: Make ptrace work reliably Bharat Bhushan
2013-05-16  5:34 ` [PATCH 1/2 v2] powerpc: debug control and status registers are 32bit Bharat Bhushan
2013-05-16  5:34   ` [PATCH 2/2 v2] powerpc: restore dbcr0 on user space exit Bharat Bhushan
2013-05-16 16:54     ` Scott Wood [this message]
2013-05-16 17:03       ` Bhushan Bharat-R65777

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=1368723257.8202.43@snotra \
    --to=scottwood@freescale.com \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=James.Yang@freescale.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=r65777@freescale.com \
    --cc=stuart.yoder@freescale.com \
    /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