From: Kumar Gala <galak@kernel.crashing.org>
To: Paul Mackerras <paulus@samba.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH] [POWERPC] Rework EXC_LEVEL_EXCEPTION_PROLOG code
Date: Wed, 30 Apr 2008 04:27:07 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0804300424040.31028@blarg.am.freescale.net> (raw)
* Cleanup the code a bit my allocating an INT_FRAME on our exception
stack there by make references go from GPR11-INT_FRAME_SIZE(r8) to
just GPR(r8)
* simplify {lvl}_transfer_to_handler code by moving the copying of the
temp registers we use if we come from user space into the PROLOG
* If the exception came from kernel mode copy thread_info flags,
preempt, and task pointer from the process thread_info.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
I'm not sure if the copying of TI_FLAGS, TI_PREEMPT, and TI_TASK
are really needed. I'm a bit concerned what to do if we get a
CriticalInput while in kernel mode and the handler causes a reschedule.
arch/powerpc/kernel/entry_32.S | 13 ----------
arch/powerpc/kernel/head_booke.h | 47 ++++++++++++++++++++++++-------------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 0c8614d..816dd54 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -44,29 +44,16 @@
#endif
#ifdef CONFIG_BOOKE
-#include "head_booke.h"
-#define TRANSFER_TO_HANDLER_EXC_LEVEL(exc_level) \
- mtspr exc_level##_SPRG,r8; \
- BOOKE_LOAD_EXC_LEVEL_STACK(exc_level); \
- lwz r0,GPR10-INT_FRAME_SIZE(r8); \
- stw r0,GPR10(r11); \
- lwz r0,GPR11-INT_FRAME_SIZE(r8); \
- stw r0,GPR11(r11); \
- mfspr r8,exc_level##_SPRG
-
.globl mcheck_transfer_to_handler
mcheck_transfer_to_handler:
- TRANSFER_TO_HANDLER_EXC_LEVEL(MCHECK)
b transfer_to_handler_full
.globl debug_transfer_to_handler
debug_transfer_to_handler:
- TRANSFER_TO_HANDLER_EXC_LEVEL(DEBUG)
b transfer_to_handler_full
.globl crit_transfer_to_handler
crit_transfer_to_handler:
- TRANSFER_TO_HANDLER_EXC_LEVEL(CRIT)
/* fall through */
#endif
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index d647e05..78baec5 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -78,12 +78,12 @@
slwi r8,r8,2; \
addis r8,r8,level##_STACK_TOP@ha; \
lwz r8,level##_STACK_TOP@l(r8); \
- addi r8,r8,THREAD_SIZE;
+ addi r8,r8,THREAD_SIZE-INT_FRAME_SIZE;
#else
#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
lis r8,level##_STACK_TOP@ha; \
lwz r8,level##_STACK_TOP@l(r8); \
- addi r8,r8,THREAD_SIZE;
+ addi r8,r8,THREAD_SIZE-INT_FRAME_SIZE;
#endif
/*
@@ -97,22 +97,35 @@
#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
mtspr exc_level##_SPRG,r8; \
BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
- stw r10,GPR10-INT_FRAME_SIZE(r8); \
- stw r11,GPR11-INT_FRAME_SIZE(r8); \
+ stw r9,GPR9(r8); /* save various registers */\
+ stw r10,GPR10(r8); \
+ stw r11,GPR11(r8); \
+ mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
+ lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
+ addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE; /* Alloc exception frm */\
mfcr r10; /* save CR in r10 for now */\
- mfspr r11,exc_level_srr1; /* check whether user or kernel */\
- andi. r11,r11,MSR_PR; \
- mr r11,r8; \
- mfspr r8,exc_level##_SPRG; \
+ mfspr r9,exc_level_srr1; /* check whether user or kernel */\
+ andi. r9,r9,MSR_PR; \
beq 1f; \
/* COMING FROM USER MODE */ \
- mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
- lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
- addi r11,r11,THREAD_SIZE; \
-1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\
+ lwz r9,GPR9(r8); /* copy regs from exception stack */\
+ stw r9,GPR9(r11); \
+ lwz r9,GPR10(r8); \
+ stw r9,GPR10(r11); \
+ lwz r9,GPR11(r8); \
+ stw r9,GPR11(r11); \
+ b 2f; \
+ /* COMING FROM PRIV MODE */ \
+1: lwz r9,TI_FLAGS-THREAD_SIZE(r11); \
+ stw r9,TI_FLAGS-THREAD_SIZE(r8); \
+ lwz r9,TI_PREEMPT-THREAD_SIZE(r11); \
+ stw r9,TI_PREEMPT-THREAD_SIZE(r8); \
+ lwz r9,TI_TASK-THREAD_SIZE(r11); \
+ stw r9,TI_TASK-THREAD_SIZE(r8); \
+ mr r11,r8; \
+2: mfspr r8,exc_level##_SPRG; \
stw r10,_CCR(r11); /* save various registers */\
stw r12,GPR12(r11); \
- stw r9,GPR9(r11); \
mflr r10; \
stw r10,_LINK(r11); \
mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
@@ -255,8 +268,8 @@ label:
lwz r12,GPR12(r11); \
mtspr DEBUG_SPRG,r8; \
BOOKE_LOAD_EXC_LEVEL_STACK(DEBUG); /* r8 points to the debug stack */ \
- lwz r10,GPR10-INT_FRAME_SIZE(r8); \
- lwz r11,GPR11-INT_FRAME_SIZE(r8); \
+ lwz r10,GPR10(r8); \
+ lwz r11,GPR11(r8); \
mfspr r8,DEBUG_SPRG; \
\
RFDI; \
@@ -308,8 +321,8 @@ label:
lwz r12,GPR12(r11); \
mtspr CRIT_SPRG,r8; \
BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
- lwz r10,GPR10-INT_FRAME_SIZE(r8); \
- lwz r11,GPR11-INT_FRAME_SIZE(r8); \
+ lwz r10,GPR10(r8); \
+ lwz r11,GPR11(r8); \
mfspr r8,CRIT_SPRG; \
\
rfci; \
--
1.5.4.1
next reply other threads:[~2008-04-30 9:31 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 9:27 Kumar Gala [this message]
2008-04-30 21:54 ` [PATCH] [POWERPC] Rework EXC_LEVEL_EXCEPTION_PROLOG code Benjamin Herrenschmidt
2008-04-30 22:13 ` Kumar Gala
2008-04-30 22:18 ` Benjamin Herrenschmidt
2008-04-30 23:24 ` Kumar Gala
2008-04-30 22:22 ` Benjamin Herrenschmidt
2008-04-30 23:28 ` Kumar Gala
2008-04-30 23:52 ` Benjamin Herrenschmidt
2008-04-30 23:47 ` Paul Mackerras
2008-05-01 6:01 ` Kumar Gala
2008-05-01 7:53 ` Benjamin Herrenschmidt
2008-05-01 13:22 ` Kumar Gala
2008-05-01 14:26 ` Josh Boyer
2008-05-01 14:31 ` Kumar Gala
2008-05-05 11:57 ` Gabriel Paubert
2008-05-05 12:06 ` Benjamin Herrenschmidt
2008-05-01 8:24 ` Paul Mackerras
2008-05-01 13:17 ` Kumar Gala
2008-05-01 16:14 ` Scott Wood
2008-05-01 16:22 ` Scott Wood
2008-05-01 16:33 ` Kumar Gala
2008-05-01 16:42 ` Scott Wood
2008-05-01 17:48 ` Kumar Gala
2008-05-01 19:02 ` Scott Wood
2008-05-01 23:34 ` Paul Mackerras
2008-05-02 4:02 ` Kumar Gala
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=Pine.LNX.4.64.0804300424040.31028@blarg.am.freescale.net \
--to=galak@kernel.crashing.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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).