From: "tiejun.chen" <tiejun.chen@windriver.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 3/4] ppc32/kprobe: complete kprobe and migrate exception frame
Date: Thu, 15 Dec 2011 19:19:31 +0800 [thread overview]
Message-ID: <4EE9D7C3.8050506@windriver.com> (raw)
In-Reply-To: <1323909460.21839.42.camel@pasglop>
Looks we have to go into 'restore' at last as I said previously. I send v2 based
on your all comments.
>> I assume it may not necessary to reorganize ret_from_except for *ppc32* .
>
> It might be cleaner but I can do that myself later.
>
I have this version but I'm not 100% sure if its as you expect :)
#define _TIF_WORK_MASK (_TIF_USER_WORK_MASK | _TIF_EMULATE_STACK_STORE)
======
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 56212bc..e52b586 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -791,41 +791,29 @@ ret_from_except:
SYNC /* Some chip revs have problems here... */
MTMSRD(r10) /* disable interrupts */
- lwz r3,_MSR(r1) /* Returning to user mode? */
- andi. r0,r3,MSR_PR
- beq resume_kernel
-
user_exc_return: /* r10 contains MSR_KERNEL here */
/* Check current_thread_info()->flags */
rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
lwz r9,TI_FLAGS(r9)
- andi. r0,r9,_TIF_USER_WORK_MASK
- bne do_work
+ andi. r0,r9,_TIF_WORK_MASK
+ beq restore
-restore_user:
-#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
- /* Check whether this process has its own DBCR0 value. The internal
- debug mode bit tells us that dbcr0 should be loaded. */
- lwz r0,THREAD+THREAD_DBCR0(r2)
- andis. r10,r0,DBCR0_IDM@h
- bnel- load_dbcr0
-#endif
+ lwz r3,_MSR(r1) /* Returning to user mode? */
+ andi. r0,r3,MSR_PR
+ bne do_user_work
#ifdef CONFIG_PREEMPT
- b restore
-
/* N.B. the only way to get here is from the beq following ret_from_except. */
-resume_kernel:
/* check current_thread_info->preempt_count */
rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
lwz r0,TI_PREEMPT(r9)
cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
- bne restore
+ bne 2f
lwz r0,TI_FLAGS(r9)
andi. r0,r0,_TIF_NEED_RESCHED
- beq+ restore
+ beq+ 2f
andi. r0,r3,MSR_EE /* interrupts off? */
- beq restore /* don't schedule if so */
+ beq 2f /* don't schedule if so */
#ifdef CONFIG_TRACE_IRQFLAGS
/* Lockdep thinks irqs are enabled, we need to call
* preempt_schedule_irq with IRQs off, so we inform lockdep
@@ -844,12 +832,54 @@ resume_kernel:
*/
bl trace_hardirqs_on
#endif
-#else
-resume_kernel:
+2:
#endif /* CONFIG_PREEMPT */
+ /* check current_thread_info, _TIF_EMULATE_STACK_STORE */
+ rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
+ lwz r0,TI_FLAGS(r9)
+ andis. r0,r0,_TIF_EMULATE_STACK_STORE@h
+ beq+ restore
+
+ addi r9,r1,INT_FRAME_SIZE /* Get the kprobed function entry */
+
+ lwz r3,GPR1(r1)
+ subi r3,r3,INT_FRAME_SIZE /* dst: Allocate a trampoline exception
frame */
+ mr r4,r1 /* src: current exception frame */
+ li r5,INT_FRAME_SIZE /* size: INT_FRAME_SIZE */
+ mr r1,r3 /* Reroute the trampoline frame to r1 */
+ bl memcpy /* Copy from the original to the
trampoline */
+
+ /* Do real store operation to complete stwu */
+ lwz r5,GPR1(r1)
+ stw r9,0(r5)
+
+ /* Do real store operation to complete stwu */
+ lwz r5,GPR1(r1)
+ stw r9,0(r5)
+
+ /* Clear _TIF_EMULATE_STACK_STORE flag */
+ rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
+ lis r11,_TIF_EMULATE_STACK_STORE@h
+ addi r9,r9,TI_FLAGS
+0: lwarx r8,0,r9
+ andc r8,r8,r11
+#ifdef CONFIG_IBM405_ERR77
+ dcbt 0,r9
+#endif
+ stwcx. r8,0,r9
+ bne- 0b
+
/* interrupts are hard-disabled at this point */
restore:
+#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
+ lwz r3,_MSR(r1) /* Returning to user mode? */
+ andi. r0,r3,MSR_PR
+ beq 1f
+ /* Check whether this process has its own DBCR0 value. The internal
+ debug mode bit tells us that dbcr0 should be loaded. */
+ lwz r0,THREAD+THREAD_DBCR0(r2)
+ andis. r10,r0,DBCR0_IDM@h
+ bnel- load_dbcr0
+1:
+#endif
+
#ifdef CONFIG_44x
BEGIN_MMU_FTR_SECTION
b 1f
@@ -1159,7 +1189,7 @@ global_dbcr0:
.previous
#endif /* !(CONFIG_4xx || CONFIG_BOOKE) */
-do_work: /* r10 contains MSR_KERNEL here */
+do_user_work: /* r10 contains MSR_KERNEL here */
andi. r0,r9,_TIF_NEED_RESCHED
beq do_user_signal
@@ -1184,7 +1214,7 @@ recheck:
andi. r0,r9,_TIF_NEED_RESCHED
bne- do_resched
andi. r0,r9,_TIF_USER_WORK_MASK
- beq restore_user
+ beq restore
do_user_signal: /* r10 contains MSR_KERNEL here */
ori r10,r10,MSR_EE
SYNC
Tiejun
Thanks
Tiejun
next prev parent reply other threads:[~2011-12-15 11:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 8:50 ppc32/kprobe: Fix a bug for kprobe stwu r1 Tiejun Chen
2011-12-12 8:50 ` [PATCH 1/4] powerpc/kprobe: introduce a new thread flag Tiejun Chen
2011-12-12 22:58 ` Benjamin Herrenschmidt
2011-12-13 4:56 ` tiejun.chen
2011-12-12 8:50 ` [PATCH 2/4] ppc32/kprobe: introduce copy_exc_stack Tiejun Chen
2011-12-12 23:01 ` Benjamin Herrenschmidt
2011-12-13 4:58 ` tiejun.chen
2011-12-12 8:50 ` [PATCH 3/4] ppc32/kprobe: complete kprobe and migrate exception frame Tiejun Chen
2011-12-12 23:19 ` Benjamin Herrenschmidt
2011-12-13 4:54 ` tiejun.chen
2011-12-13 8:21 ` tiejun.chen
2011-12-13 10:11 ` tiejun.chen
2011-12-13 10:36 ` tiejun.chen
2011-12-15 0:37 ` Benjamin Herrenschmidt
2011-12-15 11:19 ` tiejun.chen [this message]
2011-12-12 8:50 ` [PATCH 4/4] ppc32/kprobe: don't emulate store when kprobe stwu r1 Tiejun Chen
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=4EE9D7C3.8050506@windriver.com \
--to=tiejun.chen@windriver.com \
--cc=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 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.