linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 10/13] powerpc/book3e: Fix single step when using HW page tables
Date: Fri,  9 Jul 2010 16:16:52 +1000	[thread overview]
Message-ID: <1278656215-24705-10-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1278656215-24705-9-git-send-email-benh@kernel.crashing.org>

We patch the TLB miss exception vectors to point to alternate
functions when using HW page table on BookE.

However, we were patching in a new branch in the first instruction
of the exception handler instead of the second one, thus overriding
the nop that is in the first instruction.

This cause problems when single stepping as we rely on that nop for
the single step to stop properly within the exception vector range
rather than on the target of the branch.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/exceptions-64e.S |    6 ++++++
 arch/powerpc/mm/tlb_nohash.c         |   13 +++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 316465a..5c43063 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -191,6 +191,12 @@ exc_##n##_bad_stack:							    \
 	sth	r1,PACA_TRAP_SAVE(r13);	/* store trap */		    \
 	b	bad_stack_book3e;	/* bad stack error */
 
+/* WARNING: If you change the layout of this stub, make sure you chcek
+	*   the debug exception handler which handles single stepping
+	*   into exceptions from userspace, and the MM code in
+	*   arch/powerpc/mm/tlb_nohash.c which patches the branch here
+	*   and would need to be updated if that branch is moved
+	*/
 #define	EXCEPTION_STUB(loc, label)					\
 	. = interrupt_base_book3e + loc;				\
 	nop;	/* To make debug interrupts happy */			\
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index e81d5d6..2ce42bf 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -391,10 +391,15 @@ static void __early_init_mmu(int boot_cpu)
 		/* Check if HW loader is supported */
 		if ((tlb0cfg & TLBnCFG_IND) &&
 		    (tlb0cfg & TLBnCFG_PT)) {
-			patch_branch(ibase + (0x1c0 / 4),
-			     (unsigned long)&exc_data_tlb_miss_htw_book3e, 0);
-			patch_branch(ibase + (0x1e0 / 4),
-			     (unsigned long)&exc_instruction_tlb_miss_htw_book3e, 0);
+			/* Our exceptions vectors start with a NOP and -then- a branch
+			 * to deal with single stepping from userspace which stops on
+			 * the second instruction. Thus we need to patch the second
+			 * instruction of the exception, not the first one
+			 */
+			patch_branch(ibase + (0x1c0 / 4) + 1,
+				(unsigned long)&exc_data_tlb_miss_htw_book3e, 0);
+			patch_branch(ibase + (0x1e0 / 4) + 1,
+				(unsigned long)&exc_instruction_tlb_miss_htw_book3e, 0);
 			book3e_htw_enabled = 1;
 		}
 		pr_info("MMU: Book3E Page Tables %s\n",
-- 
1.6.3.3

  reply	other threads:[~2010-07-09  6:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09  6:16 [PATCH 01/13] powerpc/book3e: mtmsr should not be mtmsrd on book3e 64-bit Benjamin Herrenschmidt
2010-07-09  6:16 ` [PATCH 02/13] powerpc/book3e: Hack to get gdb moving along on Book3E 64-bit Benjamin Herrenschmidt
2010-07-09  6:16   ` [PATCH 03/13] powerpc/book3e: Move doorbell_exception from traps.c to dbell.c Benjamin Herrenschmidt
2010-07-09  6:16     ` [PATCH 04/13] powerpc/book3e: More doorbell cleanups. Sample the PIR register Benjamin Herrenschmidt
2010-07-09  6:16       ` [PATCH 05/13] powerpc/book3e: Don't re-trigger decrementer on lazy irq restore Benjamin Herrenschmidt
2010-07-09  6:16         ` [PATCH 06/13] powerpc/book3e: Hookup doorbells exceptions on 64-bit Book3E Benjamin Herrenschmidt
2010-07-09  6:16           ` [PATCH 07/13] powerpc/book3e: Use set_irq_regs() in the msgsnd/msgrcv IPI path Benjamin Herrenschmidt
2010-07-09  6:16             ` [PATCH 08/13] powerpc/book3e: Resend doorbell exceptions to ourself Benjamin Herrenschmidt
2010-07-09  6:16               ` [PATCH 09/13] powerpc/book3e: Add generic 64-bit idle powersave support Benjamin Herrenschmidt
2010-07-09  6:16                 ` Benjamin Herrenschmidt [this message]
2010-07-09  6:16                   ` [PATCH 11/13] powerpc/book3e: Add TLB dump in xmon for Book3E Benjamin Herrenschmidt
2010-07-09  6:16                     ` [PATCH 12/13] powerpc/book3e: Adjust the page sizes list based on MMU config Benjamin Herrenschmidt
2010-07-09  6:16                       ` [PATCH 13/13] powerpc/oprofile: Don't build server oprofile drivers on 64-bit BookE Benjamin Herrenschmidt
2010-07-14  4:09                 ` [PATCH 09/13] powerpc/book3e: Add generic 64-bit idle powersave support Benjamin Herrenschmidt
2010-07-09  8:52   ` [PATCH 02/13] powerpc/book3e: Hack to get gdb moving along on Book3E 64-bit K.Prasad

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=1278656215-24705-10-git-send-email-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.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).