Refactor exception entry on 40x/6xx/8xx
cover Refactor exception entry on 40x/6xx/8xx
This serie refactors exception entry macros for 40x, 6xx and 8xx
This serie will benefit to the implementation of CONFIG_VMAP, and also to Ben's serie on MSR_EE.
First patch of this serie is a part of the CONFIG_THREAD_INFO_IN_TASK serie. This avoids a conflict between the two series.
Christophe Leroy (11):
powerpc/32: Rename THREAD_INFO to TASK_STACK powerpc/32: Refactor EXCEPTION entry macros for head_8xx.S and
head_32.S
powerpc/32: Add a macro for setting MSR_RI in EXCEPTION_PROLOG_2 powerpc/32: add CLR_MSR_WE() in EXCEPTION_PROLOG in head_32.h powerpc/32: add START_EXCEPTION() in head_32.h powerpc/32: move LOAD_MSR_KERNEL() into head_32.h and use it powerpc/40x: Don't use SPRN_SPRG_SCRATCH2 in EXCEPTION_PROLOG powerpc/40x: add exception frame marker
powerpc/40x: Split and rename NORMAL_EXCEPTION_PROLOG powerpc/40x: Add EXC_XFER_TEMPLATE_CRITICAL() powerpc/40x: Refactor exception entry macros by using head_32.h
arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kernel/entry_32.S | 11 +--- arch/powerpc/kernel/head_32.S | 101 ++-------------------------- arch/powerpc/kernel/head_32.h | 124 +++++++++++++++++++++++++++++++++++ arch/powerpc/kernel/head_40x.S | 120 ++++++++------------------------- arch/powerpc/kernel/head_8xx.S | 103 ++--------------------------- arch/powerpc/kernel/head_booke.h | 4 +- arch/powerpc/kernel/head_fsl_booke.S | 2 +- 8 files changed, 167 insertions(+), 300 deletions(-) create mode 100644 arch/powerpc/kernel/head_32.h
Signature · 1 line
2.13.3
PATCH 1/11 powerpc/32: Rename THREAD_INFO to TASK_STACK
This patch renames THREAD_INFO to TASK_STACK, because it is in fact the offset of the pointer to the stack in task_struct so this pointer will not be impacted by the move of THREAD_INFO.
--- arch/powerpc/kernel/asm-offsets.c | 2 +- arch/powerpc/kernel/entry_32.S | 2 +- arch/powerpc/kernel/head_32.S | 2 +- arch/powerpc/kernel/head_40x.S | 4 ++-- arch/powerpc/kernel/head_8xx.S | 2 +- arch/powerpc/kernel/head_booke.h | 4 ++-- arch/powerpc/kernel/head_fsl_booke.S | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/kernel/asm-offsets.c +1 -1
@@ -90,7 +90,7 @@ int main(void)DEFINE (SIGSEGV ,SIGSEGV );DEFINE (NMI_MASK ,NMI_MASK );#else -OFFSET (THREAD_INFO , task_struct, stack); +OFFSET (TASK_STACK , task_struct, stack);DEFINE (THREAD_INFO_GAP ,_ALIGN_UP (sizeof (struct thread_info ),16 ));OFFSET (KSP_LIMIT , thread_struct, ksp_limit);#endif /* CONFIG_PPC64 */
arch/powerpc/kernel/entry_32.S +1 -1
@@ -1166,7 +1166,7 @@ ret_from_debug_exc: mfspr r9,SPRN_SPRG_THREAD lwz r10,SAVED_KSP_LIMIT(r1) stw r10,KSP_LIMIT(r9) - lwz r9,THREAD_INFO-THREAD(r9) + lwz r9,TASK_STACK-THREAD(r9) CURRENT_THREAD_INFO(r10, r1) lwz r10,TI_PREEMPT(r10) stw r10,TI_PREEMPT(r9)
arch/powerpc/kernel/head_32.S +1 -1
@@ -261,7 +261,7 @@ __secondary_hold_acknowledge: tophys(r11,r1); /* use tophys(r1) if kernel */ \ beq 1f; \ mfspr r11,SPRN_SPRG_THREAD; \ - lwz r11,THREAD_INFO-THREAD(r11); \ + lwz r11,TASK_STACK-THREAD(r11); \ addi r11,r11,THREAD_SIZE; \ tophys(r11,r11); \ 1: subi r11,r11,INT_FRAME_SIZE /* alloc exc. frame */
arch/powerpc/kernel/head_40x.S +2 -2
@@ -115,7 +115,7 @@ _ENTRY(saved_ksp_limit) andi. r11,r11,MSR_PR; \ beq 1f; \ mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\ - lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ + lwz r1,TASK_STACK-THREAD(r1); /* this thread's kernel stack */\ addi r1,r1,THREAD_SIZE; \ 1: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ tophys(r11,r1); \
@@ -158,7 +158,7 @@ _ENTRY(saved_ksp_limit) beq 1f; \ /* COMING FROM USER MODE */ \ mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\ - lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ + lwz r11,TASK_STACK-THREAD(r11); /* this thread's kernel stack */\ 1: addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE; /* Alloc an excpt frm */\ tophys(r11,r11); \ stw r10,_CCR(r11); /* save various registers */\
arch/powerpc/kernel/head_8xx.S +1 -1
@@ -142,7 +142,7 @@ instruction_counter: tophys(r11,r1); /* use tophys(r1) if kernel */ \ beq 1f; \ mfspr r11,SPRN_SPRG_THREAD; \ - lwz r11,THREAD_INFO-THREAD(r11); \ + lwz r11,TASK_STACK-THREAD(r11); \ addi r11,r11,THREAD_SIZE; \ tophys(r11,r11); \ 1: subi r11,r11,INT_FRAME_SIZE /* alloc exc. frame */
arch/powerpc/kernel/head_booke.h +2 -2
@@ -55,7 +55,7 @@ END_BTB_FLUSH_SECTION beq 1f; \BOOKE_CLEAR_BTB (r11) \/* if from user, start at top of this thread's kernel stack */ \ - lwz r11, THREAD_INFO-THREAD(r10); \ + lwz r11, TASK_STACK - THREAD(r10); \ALLOC_STACK_FRAME (r11,THREAD_SIZE ); \ 1 : subi r11, r11, INT_FRAME_SIZE; /* Allocate exception frame */ \stw r13,_CCR (r11 );/* save various registers */ \
@@ -142,7 +142,7 @@ END_BTB_FLUSH_SECTIONBOOKE_CLEAR_BTB (r10) \ andi. r11,r11,MSR_PR; \mfspr r11,SPRN_SPRG_THREAD ;/* if from user, start at top of */ \ - lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ + lwz r11, TASK_STACK - THREAD(r11); /* this thread's kernel stack */\addi r11,r11,EXC_LVL_FRAME_OVERHEAD ;/* allocate stack frame */ \ beq 1f; \/* COMING FROM USER MODE */ \
arch/powerpc/kernel/head_fsl_booke.S +1 -1
@@ -717,7 +717,7 @@ finish_tlb_load: /* Get the next_tlbcam_idx percpu var */ #ifdef CONFIG_SMP - lwz r12, THREAD_INFO-THREAD(r12) + lwz r12, TASK_STACK-THREAD(r12) lwz r15, TI_CPU(r12) lis r14, __per_cpu_offset@h ori r14, r14, __per_cpu_offset@l
Signature · 1 line
2.13.3
PATCH 2/11 powerpc/32: Refactor EXCEPTION entry macros for head_8xx.S and head_32.S
In reply to Christophe LeroyEXCEPTION_PROLOG is similar in head_8xx.S and head_32.S
This patch creates head_32.h and moves EXCEPTION_PROLOG macro into it.
It also moves EXCEPTION() and EXC_XFER_XXXX() macros which are also similar. For that, the 8xx needs to define a dummy DO_KVM asm macro.
--- arch/powerpc/kernel/head_32.S | 99 +-------------------------------------- arch/powerpc/kernel/head_32.h | 104 +++++++++++++++++++++++++++++++++++++++++ arch/powerpc/kernel/head_8xx.S | 101 ++------------------------------------- 3 files changed, 111 insertions(+), 193 deletions(-) create mode 100644 arch/powerpc/kernel/head_32.h
arch/powerpc/kernel/head_32.S +2 -97
@@ -37,6 +37,8 @@ #include <asm/export.h> #include <asm/feature-fixups.h> +#include "head_32.h" + /* 601 only have IBAT; cr0.eq is set on 601 when using this macro */ #define LOAD_BAT(n, reg, RA, RB) \ /* see the comment for clear_bats() -- Cort */ \
@@ -242,103 +244,6 @@ __secondary_hold_spinloop: __secondary_hold_acknowledge: .long -1 -/* - * Exception entry code. This code runs with address translation - * turned off, i.e. using physical addresses. - * We assume sprg3 has the physical address of the current - * task's thread_struct. - */ -#define EXCEPTION_PROLOG \ - mtspr SPRN_SPRG_SCRATCH0,r10; \ - mtspr SPRN_SPRG_SCRATCH1,r11; \ - mfcr r10; \ - EXCEPTION_PROLOG_1; \ - EXCEPTION_PROLOG_2 - -#define EXCEPTION_PROLOG_1 \ - mfspr r11,SPRN_SRR1; /* check whether user or kernel */ \ - andi. r11,r11,MSR_PR; \ - tophys(r11,r1); /* use tophys(r1) if kernel */ \ - beq 1f; \ - mfspr r11,SPRN_SPRG_THREAD; \ - lwz r11,TASK_STACK-THREAD(r11); \ - addi r11,r11,THREAD_SIZE; \ - tophys(r11,r11); \ -1: subi r11,r11,INT_FRAME_SIZE /* alloc exc. frame */ - - -#define EXCEPTION_PROLOG_2 \ - stw r10,_CCR(r11); /* save registers */ \ - stw r12,GPR12(r11); \ - stw r9,GPR9(r11); \ - mfspr r10,SPRN_SPRG_SCRATCH0; \ - stw r10,GPR10(r11); \ - mfspr r12,SPRN_SPRG_SCRATCH1; \ - stw r12,GPR11(r11); \ - mflr r10; \ - stw r10,_LINK(r11); \ - mfspr r12,SPRN_SRR0; \ - mfspr r9,SPRN_SRR1; \ - stw r1,GPR1(r11); \ - stw r1,0(r11); \ - tovirt(r1,r11); /* set new kernel sp */ \ - li r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions */ \ - MTMSRD(r10); /* (except for mach check in rtas) */ \ - stw r0,GPR0(r11); \ - lis r10,STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */ \ - addi r10,r10,STACK_FRAME_REGS_MARKER@l; \ - stw r10,8(r11); \ - SAVE_4GPRS(3, r11); \ - SAVE_2GPRS(7, r11) - -/* - * Note: code which follows this uses cr0.eq (set if from kernel), - * r11, r12 (SRR0), and r9 (SRR1). - * - * Note2: once we have set r1 we are in a position to take exceptions - * again, and we could thus set MSR:RI at that point. - */ - -/* - * Exception vectors. - */ -#define EXCEPTION(n, label, hdlr, xfer) \ - . = n; \ - DO_KVM n; \ -label: \ - EXCEPTION_PROLOG; \ - addi r3,r1,STACK_FRAME_OVERHEAD; \ - xfer(n, hdlr) - -#define EXC_XFER_TEMPLATE(n, hdlr, trap, copyee, tfer, ret) \ - li r10,trap; \ - stw r10,_TRAP(r11); \ - li r10,MSR_KERNEL; \ - copyee(r10, r9); \ - bl tfer; \ -i##n: \ - .long hdlr; \ - .long ret - -#define COPY_EE(d, s) rlwimi d,s,0,16,16 -#define NOCOPY(d, s) - -#define EXC_XFER_STD(n, hdlr) \ - EXC_XFER_TEMPLATE(n, hdlr, n, NOCOPY, transfer_to_handler_full, \ - ret_from_except_full) - -#define EXC_XFER_LITE(n, hdlr) \ - EXC_XFER_TEMPLATE(n, hdlr, n+1, NOCOPY, transfer_to_handler, \ - ret_from_except) - -#define EXC_XFER_EE(n, hdlr) \ - EXC_XFER_TEMPLATE(n, hdlr, n, COPY_EE, transfer_to_handler_full, \ - ret_from_except_full) - -#define EXC_XFER_EE_LITE(n, hdlr) \ - EXC_XFER_TEMPLATE(n, hdlr, n+1, COPY_EE, transfer_to_handler, \ - ret_from_except) - /* System reset */ /* core99 pmac starts the seconary here by changing the vector, and putting it back to what it was (unknown_exception) when done. */
arch/powerpc/kernel/head_32.h new file +104 -0
104 lines not on this page · raw message
arch/powerpc/kernel/head_8xx.S +5 -96
113 lines not on this page · raw message
Signature · 1 line
2.13.3
PATCH 3/11 powerpc/32: Add a macro for setting MSR_RI in EXCEPTION_PROLOG_2
In reply to Christophe LeroySetting MSR_RI applies to head_32 and head_8xx, but not to head_40x. So in order to refactor EXCEPTION_PROLOG for 40x too, this patch adds a macro for setting MSR_RI.
In the meantime, this gives the opportunity to make it simpler on the 8xx as writing in SPRN_EID sets MSR_RI.
--- arch/powerpc/kernel/head_32.S | 2 ++ arch/powerpc/kernel/head_32.h | 7 +++++-- arch/powerpc/kernel/head_8xx.S | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-)
arch/powerpc/kernel/head_32.S +2 -0
@@ -37,6 +37,8 @@ #include <asm/export.h> #include <asm/feature-fixups.h> +#define SET_AND_STORE_MSR_RI(reg) li reg,MSR_KERNEL & ~(MSR_IR|MSR_DR); MTMSRD(reg) + #include "head_32.h" /* 601 only have IBAT; cr0.eq is set on 601 when using this macro */
arch/powerpc/kernel/head_32.h +5 -2
@@ -4,6 +4,10 @@#include <asm/ptrace.h> /* for STACK_FRAME_REGS_MARKER */ +#ifndef SET_AND_STORE_MSR_RI +#define SET_AND_STORE_MSR_RI (reg) +#endif +/* * Exception entry code. This code runs with address translation * turned off, i.e. using physical addresses.
@@ -44,8 +48,7 @@stw r1,GPR1 (r11 ); \ stw r1,0(r11); \tovirt (r1,r11);/* set new kernel sp */ \ - li r10,MSR_KERNEL & ~(MSR_IR|MSR_DR); /* can take exceptions */ \ -MTMSRD (r10);/* (except for mach check in rtas) */ \ +SET_AND_STORE_MSR_RI (r10);/* can take exceptions */ \stw r0,GPR0 (r11 ); \ lis r10,STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */ \ addi r10,r10,STACK_FRAME_REGS_MARKER@l; \
arch/powerpc/kernel/head_8xx.S +2 -0
@@ -36,6 +36,8 @@ .macro DO_KVM intno .endm +#define SET_AND_STORE_MSR_RI(reg) mtspr SPRN_EID, reg + #include "head_32.h" #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
Signature · 1 line
2.13.3
PATCH 4/11 powerpc/32: add CLR_MSR_WE() in EXCEPTION_PROLOG in head_32.h
In reply to Christophe LeroyAdd CLR_MSR_WE() macro to allow 40x to clear
that bit from the register containing msr value.
This is the only difference between common EXCEPTION_PROLOG and 40x one. This patch will allow 40x to use the common one.
--- arch/powerpc/kernel/head_32.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/kernel/head_32.h +5 -0
@@ -8,6 +8,10 @@#define SET_AND_STORE_MSR_RI (reg)#endif +#ifndef CLR_MSR_WE +#define CLR_MSR_WE (reg) +#endif +/* * Exception entry code. This code runs with address translation * turned off, i.e. using physical addresses.
@@ -49,6 +53,7 @@ stw r1,0(r11); \tovirt (r1,r11);/* set new kernel sp */ \SET_AND_STORE_MSR_RI (r10);/* can take exceptions */ \ +CLR_MSR_WE (r9); \stw r0,GPR0 (r11 ); \ lis r10,STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */ \ addi r10,r10,STACK_FRAME_REGS_MARKER@l; \
Signature · 1 line
2.13.3
PATCH 5/11 powerpc/32: add START_EXCEPTION() in head_32.h
In reply to Christophe LeroyAdd START_EXCEPTION() in head_32.h for preparing the use of head_32.h in head_40x.S
--- arch/powerpc/kernel/head_32.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/powerpc/kernel/head_32.h +5 -2
@@ -72,10 +72,13 @@/* * Exception vectors. */ -#define EXCEPTION (n, label, hdlr, xfer) \ +#define START_EXCEPTION (n, label) \ . = n; \ DO_KVM n; \ -label: \ +label: + +#define EXCEPTION (n, label, hdlr, xfer) \ + START_EXCEPTION(n, label) \ EXCEPTION_PROLOG; \ addi r3,r1,STACK_FRAME_OVERHEAD; \ xfer(n, hdlr)
Signature · 1 line
2.13.3
PATCH 6/11 powerpc/32: move LOAD_MSR_KERNEL() into head_32.h and use it
In reply to Christophe LeroyAs preparation for using head_32.h for head_40x.S, move LOAD_MSR_KERNEL() there and use it to load r10 with MSR_KERNEL value.
--- arch/powerpc/kernel/entry_32.S | 9 +-------- arch/powerpc/kernel/head_32.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 9 deletions(-)
arch/powerpc/kernel/entry_32.S +1 -8
@@ -37,14 +37,7 @@ #include <asm/feature-fixups.h> #include <asm/barrier.h> -/* - * MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE. - */ -#if MSR_KERNEL >= 0x10000 -#define LOAD_MSR_KERNEL(r, x) lis r,(x)@h; ori r,r,(x)@l -#else -#define LOAD_MSR_KERNEL(r, x) li r,(x) -#endif +#include "head_32.h" /* * Align to 4k in order to ensure that all functions modyfing srr0/srr1
arch/powerpc/kernel/head_32.h +10 -1
@@ -13,6 +13,15 @@#endif /* +* MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE. +*/ +#if MSR_KERNEL >=0x10000 +#define LOAD_MSR_KERNEL (r, x) lis r,(x)@h; ori r,r,(x)@l +#else +#define LOAD_MSR_KERNEL (r, x) li r,(x) +#endif + +/* * Exception entry code. This code runs with address translation * turned off, i.e. using physical addresses. * We assume sprg3 has the physical address of the current
@@ -86,7 +95,7 @@#define EXC_XFER_TEMPLATE (n, hdlr, trap, copyee, tfer, ret) \ li r10,trap; \ stw r10,_TRAP(r11); \ - li r10,MSR_KERNEL; \ + LOAD_MSR_KERNEL(r10, MSR_KERNEL); \ copyee(r10, r9); \ bl tfer; \ i##n: \
Signature · 1 line
2.13.3
PATCH 7/11 powerpc/40x: Don't use SPRN_SPRG_SCRATCH2 in EXCEPTION_PROLOG
In reply to Christophe LeroyUnlike said in the comment, r1 is not reused by the critical exception handler, as it uses a dedicated critirq_ctx stack. Decrementing r1 early is then unneeded.
Should the above be valid, the code is crap buggy anyway as r1 gets some intermediate values that would jeopardise the
whole process (for instance after mfspr r1,SPRN_SPRG_THREAD)
Using SPRN_SPRG_SCRATCH2 to save r1 is then not needed, r11 can be used instead. This avoids one mtspr and one mfspr and makes the prolog closer to what's done on 6xx and 8xx.
--- arch/powerpc/kernel/head_40x.S | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
arch/powerpc/kernel/head_40x.S +9 -12
@@ -102,23 +102,20 @@ _ENTRY(saved_ksp_limit) * Exception vector entry code. This code runs with address translation * turned off (i.e. using physical addresses). We assume SPRG_THREAD has * the physical address of the current task thread_struct. - * Note that we have to have decremented r1 before we write to any fields - * of the exception frame, since a critical interrupt could occur at any - * time, and it will write to the area immediately below the current r1. */ #define NORMAL_EXCEPTION_PROLOG \ mtspr SPRN_SPRG_SCRATCH0,r10; /* save two registers to work with */\ mtspr SPRN_SPRG_SCRATCH1,r11; \ - mtspr SPRN_SPRG_SCRATCH2,r1; \ mfcr r10; /* save CR in r10 for now */\ mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ andi. r11,r11,MSR_PR; \ - beq 1f; \ - mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\ - lwz r1,TASK_STACK-THREAD(r1); /* this thread's kernel stack */\ - addi r1,r1,THREAD_SIZE; \ -1: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ tophys(r11,r1); \ + beq 1f; \ + mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\ + lwz r11,TASK_STACK-THREAD(r11); /* this thread's kernel stack */\ + addi r11,r11,THREAD_SIZE; \ + tophys(r11,r11); \ +1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\ stw r10,_CCR(r11); /* save various registers */\ stw r12,GPR12(r11); \ stw r9,GPR9(r11); \
@@ -128,11 +125,11 @@ _ENTRY(saved_ksp_limit) stw r12,GPR11(r11); \ mflr r10; \ stw r10,_LINK(r11); \ - mfspr r10,SPRN_SPRG_SCRATCH2; \ mfspr r12,SPRN_SRR0; \ - stw r10,GPR1(r11); \ + stw r1,GPR1(r11); \ mfspr r9,SPRN_SRR1; \ - stw r10,0(r11); \ + stw r1,0(r11); \ + tovirt(r1,r11); /* set new kernel sp */ \ rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ stw r0,GPR0(r11); \ SAVE_4GPRS(3, r11); \
Signature · 1 line
2.13.3
PATCH 8/11 powerpc/40x: add exception frame marker
In reply to Christophe LeroyThis patch adds STACK_FRAME_REGS_MARKER in the stack at exception entry in order to see interrupts in call traces as below:
[ 0.013964] Call Trace: [ 0.014014] [c0745db0] [c007a9d4] tick_periodic.constprop.5+0xd8/0x104 (unreliable) [ 0.014086] [c0745dc0] [c007aa20] tick_handle_periodic+0x20/0x9c [ 0.014181] [c0745de0] [c0009cd0] timer_interrupt+0xa0/0x264 [ 0.014258] [c0745e10] [c000e484] ret_from_except+0x0/0x14 [ 0.014390] --- interrupt: 901 at console_unlock.part.7+0x3f4/0x528 [ 0.014390] LR = console_unlock.part.7+0x3f0/0x528 [ 0.014455] [c0745ee0] [c0050334] console_unlock.part.7+0x114/0x528 (unreliable) [ 0.014542] [c0745f30] [c00524e0] register_console+0x3d8/0x44c [ 0.014625] [c0745f60] [c0675aac] cpm_uart_console_init+0x18/0x2c [ 0.014709] [c0745f70] [c06614f4] console_init+0x114/0x1cc [ 0.014795] [c0745fb0] [c0658b68] start_kernel+0x300/0x3d8 [ 0.014864] [c0745ff0] [c00022cc] start_here+0x44/0x98
--- arch/powerpc/kernel/head_40x.S | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/kernel/head_40x.S +6 -0
@@ -132,6 +132,9 @@ _ENTRY(saved_ksp_limit) tovirt(r1,r11); /* set new kernel sp */ \ rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ stw r0,GPR0(r11); \ + lis r10, STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */\ + addi r10, r10, STACK_FRAME_REGS_MARKER@l; \ + stw r10, 8(r11); \ SAVE_4GPRS(3, r11); \ SAVE_2GPRS(7, r11)
@@ -174,6 +177,9 @@ _ENTRY(saved_ksp_limit) tovirt(r1,r11); \ rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ stw r0,GPR0(r11); \ + lis r10, STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */\ + addi r10, r10, STACK_FRAME_REGS_MARKER@l; \ + stw r10, 8(r11); \ SAVE_4GPRS(3, r11); \ SAVE_2GPRS(7, r11)
Signature · 1 line
2.13.3
PATCH 9/11 powerpc/40x: Split and rename NORMAL_EXCEPTION_PROLOG
In reply to Christophe LeroyThis patch splits NORMAL_EXCEPTION_PROLOG in the same way as in head_8xx.S and head_32.S and renames it EXCEPTION_PROLOG() as well to match head_32.h
--- arch/powerpc/kernel/head_40x.S | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
arch/powerpc/kernel/head_40x.S +16 -10
@@ -103,10 +103,14 @@ _ENTRY(saved_ksp_limit) * turned off (i.e. using physical addresses). We assume SPRG_THREAD has * the physical address of the current task thread_struct. */ -#define NORMAL_EXCEPTION_PROLOG \ +#define EXCEPTION_PROLOG \ mtspr SPRN_SPRG_SCRATCH0,r10; /* save two registers to work with */\ mtspr SPRN_SPRG_SCRATCH1,r11; \ mfcr r10; /* save CR in r10 for now */\ + EXCEPTION_PROLOG_1; \ + EXCEPTION_PROLOG_2 + +#define EXCEPTION_PROLOG_1 \ mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ andi. r11,r11,MSR_PR; \ tophys(r11,r1); \
@@ -115,7 +119,9 @@ _ENTRY(saved_ksp_limit) lwz r11,TASK_STACK-THREAD(r11); /* this thread's kernel stack */\ addi r11,r11,THREAD_SIZE; \ tophys(r11,r11); \ -1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\ +1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */ + +#define EXCEPTION_PROLOG_2 \ stw r10,_CCR(r11); /* save various registers */\ stw r12,GPR12(r11); \ stw r9,GPR9(r11); \
@@ -205,7 +211,7 @@ label: #define EXCEPTION(n, label, hdlr, xfer) \ START_EXCEPTION(n, label); \ - NORMAL_EXCEPTION_PROLOG; \ + EXCEPTION_PROLOG; \ addi r3,r1,STACK_FRAME_OVERHEAD; \ xfer(n, hdlr)
@@ -396,7 +402,7 @@ label: * This is caused by a fetch from non-execute or guarded pages. */ START_EXCEPTION(0x0400, InstructionAccess) - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG mr r4,r12 /* Pass SRR0 as arg2 */ li r5,0 /* Pass zero as arg3 */ EXC_XFER_LITE(0x400, handle_page_fault)
@@ -406,7 +412,7 @@ label: /* 0x0600 - Alignment Exception */ START_EXCEPTION(0x0600, Alignment) - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG mfspr r4,SPRN_DEAR /* Grab the DEAR and save it */ stw r4,_DEAR(r11) addi r3,r1,STACK_FRAME_OVERHEAD
@@ -414,7 +420,7 @@ label: /* 0x0700 - Program Exception */ START_EXCEPTION(0x0700, ProgramCheck) - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG mfspr r4,SPRN_ESR /* Grab the ESR and save it */ stw r4,_ESR(r11) addi r3,r1,STACK_FRAME_OVERHEAD
@@ -427,7 +433,7 @@ label: /* 0x0C00 - System Call Exception */ START_EXCEPTION(0x0C00, SystemCall) - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG EXC_XFER_EE_LITE(0xc00, DoSyscall) EXCEPTION(0x0D00, Trap_0D, unknown_exception, EXC_XFER_EE)
@@ -733,7 +739,7 @@ label: /* Programmable Interval Timer (PIT) Exception. (from 0x1000) */ Decrementer: - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG lis r0,TSR_PIS@h mtspr SPRN_TSR,r0 /* Clear the PIT exception */ addi r3,r1,STACK_FRAME_OVERHEAD
@@ -741,7 +747,7 @@ Decrementer: /* Fixed Interval Timer (FIT) Exception. (from 0x1010) */ FITException: - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG addi r3,r1,STACK_FRAME_OVERHEAD; EXC_XFER_EE(0x1010, unknown_exception)
@@ -759,7 +765,7 @@ WDTException: * if they can't resolve the lightweight TLB fault. */ DataAccess: - NORMAL_EXCEPTION_PROLOG + EXCEPTION_PROLOG mfspr r5,SPRN_ESR /* Grab the ESR, save it, pass arg3 */ stw r5,_ESR(r11) mfspr r4,SPRN_DEAR /* Grab the DEAR, save it, pass arg2 */
Signature · 1 line
2.13.3
PATCH 10/11 powerpc/40x: Add EXC_XFER_TEMPLATE_CRITICAL()
In reply to Christophe LeroyThis patch adds EXC_XFER_TEMPLATE_CRITICAL() for handling transfer to critical exception handler. This will allow to move the normal exception to using the standard EXC_XFER_TEMPLATE() defined in head_32.h
--- arch/powerpc/kernel/head_40x.S | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
arch/powerpc/kernel/head_40x.S +11 -10
@@ -219,9 +219,7 @@ label: START_EXCEPTION(n, label); \ CRITICAL_EXCEPTION_PROLOG; \ addi r3,r1,STACK_FRAME_OVERHEAD; \ - EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \ - NOCOPY, crit_transfer_to_handler, \ - ret_from_crit_exc) + EXC_XFER_TEMPLATE_CRITICAL(hdlr, n+2) #define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret) \ li r10,trap; \
@@ -233,6 +231,14 @@ label: .long hdlr; \ .long ret +#define EXC_XFER_TEMPLATE_CRITICAL(hdlr, trap) \ + li r10,trap; \ + stw r10,_TRAP(r11); \ + li r10, MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE); \ + bl crit_transfer_to_handler; \ + .long hdlr; \ + .long ret_from_crit_exc + #define COPY_EE(d, s) rlwimi d,s,0,16,16 #define NOCOPY(d, s)
@@ -733,9 +739,7 @@ label: /* continue normal handling for a critical exception... */ 2: mfspr r4,SPRN_DBSR addi r3,r1,STACK_FRAME_OVERHEAD - EXC_XFER_TEMPLATE(DebugException, 0x2002, \ - (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \ - NOCOPY, crit_transfer_to_handler, ret_from_crit_exc) + EXC_XFER_TEMPLATE_CRITICAL(DebugException, 0x2002) /* Programmable Interval Timer (PIT) Exception. (from 0x1000) */ Decrementer:
@@ -755,10 +759,7 @@ FITException: WDTException: CRITICAL_EXCEPTION_PROLOG; addi r3,r1,STACK_FRAME_OVERHEAD; - EXC_XFER_TEMPLATE(WatchdogException, 0x1020+2, - (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), - NOCOPY, crit_transfer_to_handler, - ret_from_crit_exc) + EXC_XFER_TEMPLATE_CRITICAL(WatchdogException, 0x1020+2) /* * The other Data TLB exceptions bail out to this point
Signature · 1 line
2.13.3
PATCH 11/11 powerpc/40x: Refactor exception entry macros by using head_32.h
In reply to Christophe LeroyRefactor exception entry macros by using the ones defined in head_32.h
--- arch/powerpc/kernel/head_40x.S | 94 ++++-------------------------------------- 1 file changed, 8 insertions(+), 86 deletions(-)
arch/powerpc/kernel/head_40x.S +8 -86
@@ -44,6 +44,14 @@ #include <asm/export.h> #include <asm/asm-405.h> +.macro DO_KVM intno +.endm + +/* clear MSR_WE (necessary?)*/ +#define CLR_MSR_WE(reg) rlwinm reg, reg, 0, ~MSR_WE + +#include "head_32.h" + /* As with the other PowerPC ports, it is expected that when code * execution begins here, the following registers contain valid, yet * optional, information:
@@ -99,52 +107,6 @@ _ENTRY(saved_ksp_limit) .space 4 /* - * Exception vector entry code. This code runs with address translation - * turned off (i.e. using physical addresses). We assume SPRG_THREAD has - * the physical address of the current task thread_struct. - */ -#define EXCEPTION_PROLOG \ - mtspr SPRN_SPRG_SCRATCH0,r10; /* save two registers to work with */\ - mtspr SPRN_SPRG_SCRATCH1,r11; \ - mfcr r10; /* save CR in r10 for now */\ - EXCEPTION_PROLOG_1; \ - EXCEPTION_PROLOG_2 - -#define EXCEPTION_PROLOG_1 \ - mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ - andi. r11,r11,MSR_PR; \ - tophys(r11,r1); \ - beq 1f; \ - mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\ - lwz r11,TASK_STACK-THREAD(r11); /* this thread's kernel stack */\ - addi r11,r11,THREAD_SIZE; \ - tophys(r11,r11); \ -1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */ - -#define EXCEPTION_PROLOG_2 \ - stw r10,_CCR(r11); /* save various registers */\ - stw r12,GPR12(r11); \ - stw r9,GPR9(r11); \ - mfspr r10,SPRN_SPRG_SCRATCH0; \ - stw r10,GPR10(r11); \ - mfspr r12,SPRN_SPRG_SCRATCH1; \ - stw r12,GPR11(r11); \ - mflr r10; \ - stw r10,_LINK(r11); \ - mfspr r12,SPRN_SRR0; \ - stw r1,GPR1(r11); \ - mfspr r9,SPRN_SRR1; \ - stw r1,0(r11); \ - tovirt(r1,r11); /* set new kernel sp */ \ - rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ - stw r0,GPR0(r11); \ - lis r10, STACK_FRAME_REGS_MARKER@ha; /* exception frame marker */\ - addi r10, r10, STACK_FRAME_REGS_MARKER@l; \ - stw r10, 8(r11); \ - SAVE_4GPRS(3, r11); \ - SAVE_2GPRS(7, r11) - -/* * Exception prolog for critical exceptions. This is a little different * from the normal exception prolog above since a critical exception * can potentially occur at any point during normal exception processing.
@@ -205,32 +167,12 @@ _ENTRY(saved_ksp_limit) /* * Exception vectors. */ -#define START_EXCEPTION(n, label) \ - . = n; \ -label: - -#define EXCEPTION(n, label, hdlr, xfer) \ - START_EXCEPTION(n, label); \ - EXCEPTION_PROLOG; \ - addi r3,r1,STACK_FRAME_OVERHEAD; \ - xfer(n, hdlr) - #define CRITICAL_EXCEPTION(n, label, hdlr) \ START_EXCEPTION(n, label); \ CRITICAL_EXCEPTION_PROLOG; \ addi r3,r1,STACK_FRAME_OVERHEAD; \ EXC_XFER_TEMPLATE_CRITICAL(hdlr, n+2) -#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret) \ - li r10,trap; \ - stw r10,_TRAP(r11); \ - lis r10,msr@h; \ - ori r10,r10,msr@l; \ - copyee(r10, r9); \ - bl tfer; \ - .long hdlr; \ - .long ret - #define EXC_XFER_TEMPLATE_CRITICAL(hdlr, trap) \ li r10,trap; \ stw r10,_TRAP(r11); \
@@ -239,26 +181,6 @@ label: .long hdlr; \ .long ret_from_crit_exc -#define COPY_EE(d, s) rlwimi d,s,0,16,16 -#define NOCOPY(d, s) - -#define EXC_XFER_STD(n, hdlr) \ - EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \ - ret_from_except_full) - -#define EXC_XFER_LITE(n, hdlr) \ - EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \ - ret_from_except) - -#define EXC_XFER_EE(n, hdlr) \ - EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \ - ret_from_except_full) - -#define EXC_XFER_EE_LITE(n, hdlr) \ - EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \ - ret_from_except) - - /* * 0x0100 - Critical Interrupt Exception */
Signature · 1 line
2.13.3
Quoted 4 lines · Christophe Leroy
This serie refactors exception entry macros for 40x, 6xx and 8xx
This serie will benefit to the implementation of
CONFIG_VMAP, and also to Ben's serie onMSR_EE.
We don't have a CONFIG_VMAP. Do you mean CONFIG_VMAP_STACK ?
Le 28/01/2019 à 15:15, Christoph Hellwig a écrit :
Quoted 8 lines · Christophe Leroy
Quoted 4 lines
This serie refactors exception entry macros for 40x, 6xx and 8xx
This serie will benefit to the implementation of
CONFIG_VMAP, and also to Ben's serie onMSR_EE.We don't have a
CONFIG_VMAP. Do you meanCONFIG_VMAP_STACK?
Yes that's what I mean, sorry.