ARCv2 port to Linux - (A) prepratory patches
PATCH 15/19 ARC: entry.S: micro-optimize Trap handler
In reply to Vineet GuptaElide the need to re-read ECR in Trap handler by ensuring that EXCEPTION_PROLOGUE does that at the very end just before returning to Trap handler
ARCv2 EXCEPTION_PROLOGUE already did that, so same for ARcompact and the common trap handler adjusted to use cached ECR
--- arch/arc/include/asm/entry-compact.h | 5 +++-- arch/arc/kernel/entry.S | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-)
arch/arc/include/asm/entry-compact.h +3 -2
@@ -181,8 +181,6 @@/* ARC700 doesn't provide auto-stack switching */ SWITCH_TO_KERNEL_STK - lr r9, [ecr] - st r9, [sp, 8] /* ECR */ st r0, [sp, 4] /* orig_r0, needed only for sys calls *//* Restore r9 used to code the early prologue */
@@ -198,6 +196,9 @@ PUSHAX lp_end PUSHAX lp_start PUSHAX erbta + + lr r9, [ecr] + st r9, [sp, PT_event] /* EV_Trap expects r9 to have ECR */ .endm/*--------------------------------------------------------------
arch/arc/kernel/entry.S +2 -2
@@ -258,8 +258,8 @@ ENTRY(EV_Trap) EXCEPTION_PROLOGUE ;============ TRAP 1 :breakpoints - lr r10, [ecr] - bmsk.f 0, r10, 7 + ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR) + bmsk.f 0, r9, 7 bnz trap_with_param ;============ TRAP (no param): syscall top level
Signature · 1 line
1.9.1
PATCH 16/19 ARC: entry.S: use single EXCEPTION_PROLOGUE
In reply to Vineet GuptaReturning from pure kernel mode and exception mode use the same code anyways. Remove one the duplicate blocks
--- arch/arc/kernel/entry-compact.S | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
arch/arc/kernel/entry-compact.S +6 -8
@@ -321,14 +321,11 @@ END(call_do_page_fault) ; decide that. ; if Returning from Exception - bbit0 r10, STATUS_AE_BIT, not_exception - EXCEPTION_EPILOGUE - rtie + btst r10, STATUS_AE_BIT + bnz .Lexcep_ret ; Not Exception so maybe Interrupts (Level 1 or 2) -not_exception: - #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS ; Level 2 interrupt return Path - from hardware standpoint
@@ -377,16 +374,17 @@ not_level2_interrupt: #endif - bbit0 r10, STATUS_A1_BIT, not_level1_interrupt + bbit0 r10, STATUS_A1_BIT, .Lpure_k_mode_ret ;return from level 1 INTERRUPT_EPILOGUE 1 debug_marker_l1: rtie -not_level1_interrupt: +.Lexcep_ret: +.Lpure_k_mode_ret: - ;this case is for syscalls or Exceptions (with fake rtie) + ;this case is for syscalls or Exceptions or pure kernel mode EXCEPTION_EPILOGUE debug_marker_syscall:
Signature · 1 line
1.9.1
PATCH 18/19 ARC: Make way for pt_regs != user_regs_struct
In reply to Vineet GuptaThese have been register compatible so far. However ARCv2 mandates different pt_regs layout (due to h/w auto save). To keep pt_regs same for both, we start by removing the assumption - used mainly for block copies between the 2 structs in signal handling and ptrace
--- arch/arc/kernel/ptrace.c | 90 ++++++++++++++++++++++++++++++++++++++++++++---- arch/arc/kernel/signal.c | 55 +++++++++++++++++++++++++++-- 2 files changed, 136 insertions(+), 9 deletions(-)
arch/arc/kernel/ptrace.c +83 -7
@@ -47,10 +47,47 @@ static int genregs_get(struct task_struct *target, offsetof(struct user_regs_struct, LOC) + 4);REG_O_ZERO (pad); -REG_O_CHUNK (scratch, callee, ptregs); +REG_O_ONE (scratch.bta, &ptregs->bta); +REG_O_ONE (scratch.lp_start, &ptregs->lp_start); +REG_O_ONE (scratch.lp_end, &ptregs->lp_end); +REG_O_ONE (scratch.lp_count, &ptregs->lp_count); +REG_O_ONE (scratch.status32, &ptregs->status32); +REG_O_ONE (scratch.ret, &ptregs->ret); +REG_O_ONE (scratch.blink, &ptregs->blink); +REG_O_ONE (scratch.fp, &ptregs->fp); +REG_O_ONE (scratch.gp, &ptregs->r26); +REG_O_ONE (scratch.r12, &ptregs->r12); +REG_O_ONE (scratch.r11, &ptregs->r11); +REG_O_ONE (scratch.r10, &ptregs->r10); +REG_O_ONE (scratch.r9, &ptregs->r9); +REG_O_ONE (scratch.r8, &ptregs->r8); +REG_O_ONE (scratch.r7, &ptregs->r7); +REG_O_ONE (scratch.r6, &ptregs->r6); +REG_O_ONE (scratch.r5, &ptregs->r5); +REG_O_ONE (scratch.r4, &ptregs->r4); +REG_O_ONE (scratch.r3, &ptregs->r3); +REG_O_ONE (scratch.r2, &ptregs->r2); +REG_O_ONE (scratch.r1, &ptregs->r1); +REG_O_ONE (scratch.r0, &ptregs->r0); +REG_O_ONE (scratch.sp, &ptregs->sp); +REG_O_ZERO (pad2); -REG_O_CHUNK (callee, efa, cregs); -REG_O_CHUNK (efa, stop_pc, &target->thread.fault_address); + +REG_O_ONE (callee.r25, &cregs->r25); +REG_O_ONE (callee.r24, &cregs->r24); +REG_O_ONE (callee.r23, &cregs->r23); +REG_O_ONE (callee.r22, &cregs->r22); +REG_O_ONE (callee.r21, &cregs->r21); +REG_O_ONE (callee.r20, &cregs->r20); +REG_O_ONE (callee.r19, &cregs->r19); +REG_O_ONE (callee.r18, &cregs->r18); +REG_O_ONE (callee.r17, &cregs->r17); +REG_O_ONE (callee.r16, &cregs->r16); +REG_O_ONE (callee.r15, &cregs->r15); +REG_O_ONE (callee.r14, &cregs->r14); +REG_O_ONE (callee.r13, &cregs->r13); + +REG_O_ONE (efa, &target->thread.fault_address);if (!ret) {if (in_brkpt_trap (ptregs)) {
@@ -97,12 +134,51 @@ static int genregs_set(struct task_struct *target, offsetof(struct user_regs_struct, LOC) + 4);REG_IGNORE_ONE (pad); -/* TBD: disallow updates to STATUS32 etc*/ -REG_IN_CHUNK (scratch, pad2, ptregs);/* pt_regs[bta..sp] */ + +REG_IN_ONE (scratch.bta, &ptregs->bta); +REG_IN_ONE (scratch.lp_start, &ptregs->lp_start); +REG_IN_ONE (scratch.lp_end, &ptregs->lp_end); +REG_IN_ONE (scratch.lp_count, &ptregs->lp_count); + +REG_IGNORE_ONE (scratch.status32); + +REG_IN_ONE (scratch.ret, &ptregs->ret); +REG_IN_ONE (scratch.blink, &ptregs->blink); +REG_IN_ONE (scratch.fp, &ptregs->fp); +REG_IN_ONE (scratch.gp, &ptregs->r26); +REG_IN_ONE (scratch.r12, &ptregs->r12); +REG_IN_ONE (scratch.r11, &ptregs->r11); +REG_IN_ONE (scratch.r10, &ptregs->r10); +REG_IN_ONE (scratch.r9, &ptregs->r9); +REG_IN_ONE (scratch.r8, &ptregs->r8); +REG_IN_ONE (scratch.r7, &ptregs->r7); +REG_IN_ONE (scratch.r6, &ptregs->r6); +REG_IN_ONE (scratch.r5, &ptregs->r5); +REG_IN_ONE (scratch.r4, &ptregs->r4); +REG_IN_ONE (scratch.r3, &ptregs->r3); +REG_IN_ONE (scratch.r2, &ptregs->r2); +REG_IN_ONE (scratch.r1, &ptregs->r1); +REG_IN_ONE (scratch.r0, &ptregs->r0); +REG_IN_ONE (scratch.sp, &ptregs->sp); +REG_IGNORE_ONE (pad2); -REG_IN_CHUNK (callee, efa, cregs);/* callee_regs[r25..r13] */ + +REG_IN_ONE (callee.r25, &cregs->r25); +REG_IN_ONE (callee.r24, &cregs->r24); +REG_IN_ONE (callee.r23, &cregs->r23); +REG_IN_ONE (callee.r22, &cregs->r22); +REG_IN_ONE (callee.r21, &cregs->r21); +REG_IN_ONE (callee.r20, &cregs->r20); +REG_IN_ONE (callee.r19, &cregs->r19); +REG_IN_ONE (callee.r18, &cregs->r18); +REG_IN_ONE (callee.r17, &cregs->r17); +REG_IN_ONE (callee.r16, &cregs->r16); +REG_IN_ONE (callee.r15, &cregs->r15); +REG_IN_ONE (callee.r14, &cregs->r14); +REG_IN_ONE (callee.r13, &cregs->r13); +REG_IGNORE_ONE (efa);/* efa update invalid */ -REG_IGNORE_ONE (stop_pc);/* PC updated via @ret */ +REG_IGNORE_ONE (stop_pc);/* PC updated via @ret */ return ret; }
arch/arc/kernel/signal.c +53 -2
74 lines not on this page · raw message
Signature · 1 line
1.9.1
cover ARCv2 port to Linux - (A) prepratory patches
Hi,
ARCv2 is the next generation ISA from Synopsys and basis for the HS3{4,6,8} families of processors which retain the traditional ARC mantra of low power and configurability and are now more performant and feature rich.
Linux has been ported to HS38x series, a 10 stage pipeline core which supports MMU (with huge pages) and SMP (upto 4 cores) among other features.
- www.synopsys.com/dw/ipdir.php?ds=arc-hs38-processor
- http://news.synopsys.com/2014-10-14-New-DesignWare-ARC-HS38-Processor-Doubles-Performance-for-Embedded-Linux-Applications
- http://www.embedded.com/electronics-news/4435975/Synopsys-ARC-HS38-core-gives-2X-boost-to-Linux-based-apps
This sub-series introduces changes to existing in-tree port of ARC700 core (based on ARCompact ISA) to allow for better code sharing with new ARCv2 code.
The actual ARCv2 port will follow as a seperate series.
Please review !
Thx,
-Vineet
Vineet Gupta (19):
ARC: mm/cache_arc700.c -> mm/cache.c
ARC: cacheflush: move some code around, delete old comments
ARC: cacheflush: No need to retain DC_CTRL from __before_dc_op()
ARC: untangle cache flush loop
ARC: entry.S: common'ize scrtach reg freeup in intr + exceptions
ARC: entry.S: Introduce INTERRUPT_{PROLOGUE,EPILOGUE}
ARC: entry.S: canonical'ize EXCEPTION_{PROLOGUE,EPILOGUE}
ARC: entry.S: confine EXCEPTION_* macros to one file
ARC: entry.S: FAKE_RET_FROM_EXCPN can always use r9
ARC: entry.S: Trap handler to use r10 for syscall vs. brkpt decision
ARC: entry.S: comments cleanup
ARC: entry.S: Ensure that restore_regs is local to compilation unit
ARC: entry.S: split into ARCompact ISA specific, common bits
ARC: entry.S: move some code around for cache locality in return path
ARC: entry.S: micro-optimize Trap handler
ARC: entry.S: use single EXCEPTION_PROLOGUE
ARC: entry.S: [arcompact] simplify SWITCH_TO_KERNEL_STK
ARC: Make way for pt_regs != user_regs_struct
ARC: intc: split into ARCompact ISA specific, common bits
arch/arc/include/asm/arcregs.h | 3 -
arch/arc/include/asm/entry-compact.h | 307 +++++++++++++++++++
arch/arc/include/asm/entry.h | 357 +---------------------
arch/arc/include/asm/irqflags-compact.h | 181 +++++++++++
arch/arc/include/asm/irqflags.h | 168 +---------
arch/arc/kernel/Makefile | 4 +-
arch/arc/kernel/entry-compact.S | 393 ++++++++++++++++++++++++
arch/arc/kernel/entry.S | 527 +++++---------------------------
arch/arc/kernel/intc-compact.c | 230 ++++++++++++++
arch/arc/kernel/irq.c | 210 -------------
arch/arc/kernel/process.c | 3 +-
arch/arc/kernel/ptrace.c | 90 +++++-
arch/arc/kernel/signal.c | 55 +++-
arch/arc/mm/Makefile | 2 +-
arch/arc/mm/{cache_arc700.c => cache.c} | 367 ++++++++++------------
arch/arc/mm/tlbex.S | 16 +-
16 files changed, 1494 insertions(+), 1419 deletions(-)
create mode 100644 arch/arc/include/asm/entry-compact.h
create mode 100644 arch/arc/include/asm/irqflags-compact.h
create mode 100644 arch/arc/kernel/entry-compact.S
create mode 100644 arch/arc/kernel/intc-compact.c
rename arch/arc/mm/{cache_arc700.c => cache.c} (77%)Signature · 1 line
1.9.1
PATCH 3/19 ARC: cacheflush: No need to retain DC_CTRL from __before_dc_op()
That is because __after_dc_op() already reads it for status check, so it is better anyways to use that "newer" value.
Also reduces the clutter in callers for passing from/to these routines.
--- arch/arc/mm/cache.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
arch/arc/mm/cache.c +17 -19
@@ -207,32 +207,32 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr,* Machine specific helpers for Entire D-Cache or Per Line ops */ -static inline unsigned int __before_dc_op (const int op) +static inline void __before_dc_op (const int op) { -unsigned int reg = reg; -if (op ==OP_FLUSH_N_INV ) {/* Dcache provides 2 cmd: FLUSH or INV * INV inturn has sub-modes: DISCARD or FLUSH-BEFORE * flush-n-inv is achieved by INV cmd but with IM=1 * So toggle INV sub-mode depending on op request and default */ - reg =read_aux_reg (ARC_REG_DC_CTRL ); -write_aux_reg (ARC_REG_DC_CTRL , reg |DC_CTRL_INV_MODE_FLUSH ) +write_aux_reg (ARC_REG_DC_CTRL , +read_aux_reg (ARC_REG_DC_CTRL ) |DC_CTRL_INV_MODE_FLUSH ) ; } - -return reg; } -static inline void __after_dc_op (const int op,unsigned int reg) +static inline void __after_dc_op (const int op) { -if (op &OP_FLUSH )/* flush / flush-n-inv both wait */ -while (read_aux_reg (ARC_REG_DC_CTRL ) &DC_CTRL_FLUSH_STATUS ); +if (op &OP_FLUSH ) { +unsigned int reg; -/* Switch back to default Invalidate mode */ -if (op ==OP_FLUSH_N_INV ) -write_aux_reg (ARC_REG_DC_CTRL , reg & ~DC_CTRL_INV_MODE_FLUSH ); +/* flush / flush-n-inv both wait */ +while ((reg =read_aux_reg (ARC_REG_DC_CTRL )) &DC_CTRL_FLUSH_STATUS ); + +/* Switch back to default Invalidate mode */ +if (op ==OP_FLUSH_N_INV ) +write_aux_reg (ARC_REG_DC_CTRL , reg & ~DC_CTRL_INV_MODE_FLUSH ); + } }/*
@@ -243,10 +243,9 @@ static inline void __after_dc_op(const int op, unsigned int reg)*/ static inline void __dc_entire_op (const int op) { -unsigned int ctrl_reg;int aux; - ctrl_reg =__before_dc_op (op); +__before_dc_op (op);if (op &OP_INV )/* Inv or flush-n-inv use same cmd reg */ aux =ARC_REG_DC_IVDC ;
@@ -255,7 +254,7 @@ static inline void __dc_entire_op(const int op)write_aux_reg (aux,0x1 ); -__after_dc_op (op, ctrl_reg); +__after_dc_op (op); }/* For kernel mappings cache operation: index is same as paddr */
@@ -268,15 +267,14 @@ static inline void __dc_line_op(unsigned long paddr, unsigned long vaddr, unsigned long sz, const int op) {unsigned long flags; -unsigned int ctrl_reg;local_irq_save (flags); - ctrl_reg =__before_dc_op (op); +__before_dc_op (op);__cache_line_loop (paddr, vaddr, sz, op); -__after_dc_op (op, ctrl_reg); +__after_dc_op (op);local_irq_restore (flags); }
Signature · 1 line
1.9.1
PATCH 4/19 ARC: untangle cache flush loop
In reply to Vineet Gupta- Remove the ifdef'ery and write distinct versions for each mmu ver even if there is some code duplication
--- arch/arc/mm/cache.c | 80 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 25 deletions(-)
arch/arc/mm/cache.c +55 -25
@@ -140,25 +140,19 @@ dc_chk:* "tag" bits are provided in PTAG, index bits in existing IVIL/IVDL/FLDL regs */ -static inline void __cache_line_loop (unsigned long paddr,unsigned long vaddr, -unsigned long sz,const int op) +static inline +void __cache_line_loop_v2 (unsigned long paddr,unsigned long vaddr, +unsigned long sz,const int op) { -unsigned int aux_cmd, aux_tag; +unsigned int aux_cmd;int num_lines; -const int full_page_op =__builtin_constant_p (sz) && sz ==PAGE_SIZE ; +const int full_page =__builtin_constant_p (sz) && sz ==PAGE_SIZE ;if (op ==OP_INV_IC ) { aux_cmd =ARC_REG_IC_IVIL ; -#if (CONFIG_ARC_MMU_VER >2 ) - aux_tag =ARC_REG_IC_PTAG ; -#endif - } -else { + }else {/* d$ cmd: INV (discard or wback-n-discard) OR FLUSH (wback) */ aux_cmd = op &OP_INV ?ARC_REG_DC_IVDL :ARC_REG_DC_FLDL ; -#if (CONFIG_ARC_MMU_VER >2 ) - aux_tag =ARC_REG_DC_PTAG ; -#endif }/* Ensure we properly floor/ceil the non-line aligned/sized requests
@@ -167,7 +161,7 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr,* -@paddr will be cache-line aligned already (being page aligned) * -@sz will be integral multiple of line size (being page sized). */ -if (!full_page_op) { +if (!full_page) { sz += paddr & ~CACHE_LINE_MASK ; paddr &=CACHE_LINE_MASK ; vaddr &=CACHE_LINE_MASK ;
@@ -175,32 +169,68 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr, num_lines =DIV_ROUND_UP (sz,L1_CACHE_BYTES ); -#if (CONFIG_ARC_MMU_VER <=2 )/* MMUv2 and before: paddr contains stuffed vaddrs bits */ paddr |= (vaddr >>PAGE_SHIFT ) &0x1F ; -#else -/* if V-P const for loop, PTAG can be written once outside loop */ -if (full_page_op) + +while (num_lines-- >0 ) { +write_aux_reg (aux_cmd, paddr); + paddr +=L1_CACHE_BYTES ; + } +} + +static inline +void __cache_line_loop_v3 (unsigned long paddr,unsigned long vaddr, +unsigned long sz,const int op) +{ +unsigned int aux_cmd, aux_tag; +int num_lines; +const int full_page =__builtin_constant_p (sz) && sz ==PAGE_SIZE ; + +if (op ==OP_INV_IC ) { + aux_cmd =ARC_REG_IC_IVIL ; + aux_tag =ARC_REG_IC_PTAG ; + }else { + aux_cmd = op &OP_INV ?ARC_REG_DC_IVDL :ARC_REG_DC_FLDL ; + aux_tag =ARC_REG_DC_PTAG ; + } + +/* Ensure we properly floor/ceil the non-line aligned/sized requests +* and have @paddr - aligned to cache line and integral @num_lines. +* This however can be avoided for page sized since: +* -@paddr will be cache-line aligned already (being page aligned) +* -@sz will be integral multiple of line size (being page sized). +*/ +if (!full_page) { + sz += paddr & ~CACHE_LINE_MASK ; + paddr &=CACHE_LINE_MASK ; + vaddr &=CACHE_LINE_MASK ; + } + num_lines =DIV_ROUND_UP (sz,L1_CACHE_BYTES ); + +/* +* MMUv3, cache ops require paddr seperately +* if V-P const for loop, PTAG can be written once outside loop +*/ +if (full_page)write_aux_reg (aux_tag, paddr); -#endif while (num_lines-- >0 ) { -#if (CONFIG_ARC_MMU_VER >2 ) -/* MMUv3, cache ops require paddr seperately */ -if (!full_page_op) { +if (!full_page) {write_aux_reg (aux_tag, paddr); paddr +=L1_CACHE_BYTES ; }write_aux_reg (aux_cmd, vaddr); vaddr +=L1_CACHE_BYTES ; -#else -write_aux_reg (aux_cmd, paddr); - paddr +=L1_CACHE_BYTES ; -#endif } } +#if (CONFIG_ARC_MMU_VER <3 ) +#define __cache_line_loop __cache_line_loop_v2 +#elif (CONFIG_ARC_MMU_VER ==3 ) +#define __cache_line_loop __cache_line_loop_v3 +#endif +#ifdef CONFIG_ARC_HAS_DCACHE /***************************************************************
Signature · 1 line
1.9.1
PATCH 5/19 ARC: entry.S: common'ize scrtach reg freeup in intr + exceptions
In reply to Vineet Gupta--- arch/arc/include/asm/entry.h | 35 ++++++++++++++++------------------- arch/arc/kernel/entry.S | 10 ++-------- 2 files changed, 18 insertions(+), 27 deletions(-)
arch/arc/include/asm/entry.h +16 -19
@@ -360,26 +360,26 @@ .endm/*-------------------------------------------------------------- -* For early Exception Prologue, a core reg is temporarily needed to +* For early Exception/ISR Prologue, a core reg is temporarily needed to * code the rest of prolog (stack switching). This is done by stashing * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP). * * Before saving the full regfile - this reg is restored back, only * to be saved again on kernel mode stack, as part of pt_regs. *-------------------------------------------------------------*/ -.macro EXCPN_PROLOG_FREEUP_REG reg +.macro PROLOG_FREEUP_REG reg, mem #ifdef CONFIG_SMP sr \reg, [ARC_REG_SCRATCH_DATA0] #else - st \reg, [@ex_saved_reg1] + st \reg, [\mem] #endif .endm -.macro EXCPN_PROLOG_RESTORE_REG reg +.macro PROLOG_RESTORE_REG reg, mem #ifdef CONFIG_SMP lr \reg, [ARC_REG_SCRATCH_DATA0] #else - ld \reg, [@ex_saved_reg1] + ld \reg, [\mem] #endif .endm
@@ -393,7 +393,7 @@ .macro EXCEPTION_PROLOGUE /* Need at least 1 reg to code the early exception prologue */ -EXCPN_PROLOG_FREEUP_REG r9 + PROLOG_FREEUP_REG r9, @ex_saved_reg1 /* U/K mode at time of exception (stack not switched if already K) */ lr r9, [erstatus]
@@ -421,7 +421,7 @@ st r0, [sp, 4] /* orig_r0, needed only for sys calls *//* Restore r9 used to code the early prologue */ - EXCPN_PROLOG_RESTORE_REG r9 + PROLOG_RESTORE_REG r9, @ex_saved_reg1 SAVE_R0_TO_R12 PUSH gp
@@ -471,12 +471,8 @@*-------------------------------------------------------------*/ .macro SAVE_ALL_INT1 -/* restore original r9 to be saved as part of reg-file */ -#ifdef CONFIG_SMP - lr r9, [ARC_REG_SCRATCH_DATA0] -#else - ld r9, [@int1_saved_reg] -#endif + /* restore original r9 */ + PROLOG_RESTORE_REG r9, @int1_saved_reg /* now we are ready to save the remaining context :) */ st event_IRQ1, [sp, 8] /* Dummy ECR */
@@ -496,12 +492,13 @@ .macro SAVE_ALL_INT2 -/* TODO-vineetg: SMP we can't use global nor can we use -* SCRATCH0 as we do for int1 because while int1 is using -* it, int2 can come -*/ - /* retsore original r9 , saved in sys_saved_r9 */ - ld r9, [@int2_saved_reg] +/* +* In SMP we can't use mem nor can we use SCRARCH_DATA0 +* as we do for int1 because int2 can clobber it +* Hence 2 levels of intr are NOT allowed in SMP (by Kconfig) +*/ + /* restore original r9 */ + PROLOG_RESTORE_REG r9, @int2_saved_reg /* now we are ready to save the remaining context :) */ st event_IRQ2, [sp, 8] /* Dummy ECR */
arch/arc/kernel/entry.S +2 -8
@@ -186,9 +186,8 @@ reserved: ; processor restart ; --------------------------------------------- ENTRY(handle_interrupt_level2) - ; TODO-vineetg for SMP this wont work ; free up r9 as scratchpad - st r9, [@int2_saved_reg] + PROLOG_FREEUP_REG r9, @int2_saved_reg ;Which mode (user/kernel) was the system in when intr occured lr r9, [status32_l2]
@@ -234,12 +233,7 @@ END(handle_interrupt_level2) ; --------------------------------------------- ENTRY(handle_interrupt_level1) - /* free up r9 as scratchpad */ -#ifdef CONFIG_SMP - sr r9, [ARC_REG_SCRATCH_DATA0] -#else - st r9, [@int1_saved_reg] -#endif + PROLOG_FREEUP_REG r9, @int1_saved_reg ;Which mode (user/kernel) was the system in when intr occured lr r9, [status32_l1]
Signature · 1 line
1.9.1
PATCH 6/19 ARC: entry.S: Introduce INTERRUPT_{PROLOGUE,EPILOGUE}
In reply to Vineet Gupta-common'ize macros for level 1 and level 2 interrupts
--- arch/arc/include/asm/arcregs.h | 3 -- arch/arc/include/asm/entry.h | 77 +++++++++++------------------------------- arch/arc/kernel/entry.S | 22 +++--------- 3 files changed, 23 insertions(+), 79 deletions(-)
arch/arc/include/asm/arcregs.h +0 -3
@@ -76,9 +76,6 @@#define ECR_C_BIT_DTLB_LD_MISS 8#define ECR_C_BIT_DTLB_ST_MISS 9 -/* Dummy ECR values for Interrupts */ -#define event_IRQ1 0x0031abcd -#define event_IRQ2 0x0032abcd/* Auxiliary registers */ #define AUX_IDENTITY 4
arch/arc/include/asm/entry.h +19 -58
117 lines not on this page · raw message
arch/arc/kernel/entry.S +4 -18
@@ -186,14 +186,7 @@ reserved: ; processor restart ; --------------------------------------------- ENTRY(handle_interrupt_level2) - ; free up r9 as scratchpad - PROLOG_FREEUP_REG r9, @int2_saved_reg - - ;Which mode (user/kernel) was the system in when intr occured - lr r9, [status32_l2] - - SWITCH_TO_KERNEL_STK - SAVE_ALL_INT2 + INTERRUPT_PROLOGUE 2 ;------------------------------------------------------ ; if L2 IRQ interrupted a L1 ISR, disable preemption
@@ -233,13 +226,7 @@ END(handle_interrupt_level2) ; --------------------------------------------- ENTRY(handle_interrupt_level1) - PROLOG_FREEUP_REG r9, @int1_saved_reg - - ;Which mode (user/kernel) was the system in when intr occured - lr r9, [status32_l1] - - SWITCH_TO_KERNEL_STK - SAVE_ALL_INT1 + INTERRUPT_PROLOGUE 1 lr r0, [icause1] and r0, r0, 0x1f
@@ -698,7 +685,7 @@ not_exception: 149: ;return from level 2 - RESTORE_ALL_INT2 + INTERRUPT_EPILOGUE 2 debug_marker_l2: rtie
@@ -709,8 +696,7 @@ not_level2_interrupt: bbit0 r10, STATUS_A1_BIT, not_level1_interrupt ;return from level 1 - - RESTORE_ALL_INT1 + INTERRUPT_EPILOGUE 1 debug_marker_l1: rtie
Signature · 1 line
1.9.1
PATCH 8/19 ARC: entry.S: confine EXCEPTION_* macros to one file
In reply to Vineet Gupta--- arch/arc/kernel/entry.S | 16 ++++++++++++++++ arch/arc/mm/tlbex.S | 16 +--------------- 2 files changed, 17 insertions(+), 15 deletions(-)
arch/arc/kernel/entry.S +16 -0
@@ -368,6 +368,22 @@ ENTRY(EV_TLBProtV) END(EV_TLBProtV) +; Wrapper for Linux page fault handler called from EV_TLBMiss* +; Very similar to ProtV handler case (6a) above, but avoids the extra checks +; for Misaligned access +; +ENTRY(call_do_page_fault) + + EXCEPTION_PROLOGUE + lr r0, [efa] ; Faulting Data address + mov r1, sp + FAKE_RET_FROM_EXCPN r9 + + mov blink, ret_from_exception + b do_page_fault + +END(call_do_page_fault) + ; --------------------------------------------- ; Privilege Violation Exception Handler ; ---------------------------------------------
arch/arc/mm/tlbex.S +1 -15
@@ -366,19 +366,5 @@ do_slow_path_pf: ; Slow path TLB Miss handled as a regular ARC Exception ; (stack switching / save the complete reg-file). - EXCEPTION_PROLOGUE - - ; ------- setup args for Linux Page fault Hanlder --------- - mov_s r1, sp - lr r0, [efa] - - ; We don't want exceptions to be disabled while the fault is handled. - ; Now that we have saved the context we return from exception hence - ; exceptions get re-enable - - FAKE_RET_FROM_EXCPN r9 - - bl do_page_fault - b ret_from_exception - + b call_do_page_fault END(EV_TLBMissD)
Signature · 1 line
1.9.1
PATCH 1/19 ARC: mm/cache_arc700.c -> mm/cache.c
In reply to Vineet Gupta---
arch/arc/mm/Makefile | 2 +-
arch/arc/mm/{cache_arc700.c => cache.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename arch/arc/mm/{cache_arc700.c => cache.c} (100%)arch/arc/mm/Makefile +1 -1
@@ -7,4 +7,4 @@ # obj-y := extable.o ioremap.o dma.o fault.o init.o -obj-y += tlb.o tlbex.o cache_arc700.o mmap.o +obj-y += tlb.o tlbex.o cache.o mmap.o
arch/arc/mm/cache.c renamed from arch/arc/mm/cache_arc700.c +0 -0
Signature · 1 line
1.9.1
PATCH 2/19 ARC: cacheflush: move some code around, delete old comments
In reply to Vineet Gupta--- arch/arc/mm/cache.c | 267 ++++++++++++++++++++-------------------------------- 1 file changed, 102 insertions(+), 165 deletions(-)
arch/arc/mm/cache.c +102 -165
@@ -1,64 +1,12 @@/* -* ARC700 VIPT Cache Management +* ARC Cache Management * +* Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. -* -* vineetg: May 2011: for Non-aliasing VIPT D-cache following can be NOPs -* -flush_cache_dup_mm (fork) -* -likewise for flush_cache_mm (exit/execve) -* -likewise for flush_cache_range,flush_cache_page (munmap, exit, COW-break) -* -* vineetg: Apr 2011 -* -Now that MMU can support larger pg sz (16K), the determiniation of -* aliasing shd not be based on assumption of 8k pg -* -* vineetg: Mar 2011 -* -optimised version of flush_icache_range( ) for making I/D coherent -* when vaddr is available (agnostic of num of aliases) -* -* vineetg: Mar 2011 -* -Added documentation about I-cache aliasing on ARC700 and the way it -* was handled up until MMU V2. -* -Spotted a three year old bug when killing the 4 aliases, which needs -* bottom 2 bits, so we need to do paddr | {0x00, 0x01, 0x02, 0x03} -* instead of paddr | {0x00, 0x01, 0x10, 0x11} -* (Rajesh you owe me one now) -* -* vineetg: Dec 2010 -* -Off-by-one error when computing num_of_lines to flush -* This broke signal handling with bionic which uses synthetic sigret stub -* -* vineetg: Mar 2010 -* -GCC can't generate ZOL for core cache flush loops. -* Conv them into iterations based as opposed to while (start < end) types -* -* Vineetg: July 2009 -* -In I-cache flush routine we used to chk for aliasing for every line INV. -* Instead now we setup routines per cache geometry and invoke them -* via function pointers. -* -* Vineetg: Jan 2009 -* -Cache Line flush routines used to flush an extra line beyond end addr -* because check was while (end >= start) instead of (end > start) -* =Some call sites had to work around by doing -1, -4 etc to end param -* =Some callers didnt care. This was spec bad in case of INV routines -* which would discard valid data (cause of the horrible ext2 bug -* in ARC IDE driver) -* -* vineetg: June 11th 2008: Fixed flush_icache_range( ) -* -Since ARC700 caches are not coherent (I$ doesnt snoop D$) both need -* to be flushed, which it was not doing. -* -load_module( ) passes vmalloc addr (Kernel Virtual Addr) to the API, -* however ARC cache maintenance OPs require PHY addr. Thus need to do -* vmalloc_to_phy. -* -Also added optimisation there, that for range > PAGE SIZE we flush the -* entire cache in one shot rather than line by line. For e.g. a module -* with Code sz 600k, old code flushed 600k worth of cache (line-by-line), -* while cache is only 16 or 32k. */ #include <linux/module.h>
@@ -142,54 +90,8 @@ dc_chk: }/* -* 1. Validate the Cache Geomtery (compile time config matches hardware) -* 2. If I-cache suffers from aliasing, setup work arounds (difft flush rtn) -* (aliasing D-cache configurations are not supported YET) -* 3. Enable the Caches, setup default flush mode for D-Cache -* 3. Calculate the SHMLBA used by user space +* Line Operation on {I,D}-Cache */ -void arc_cache_init (void ) -{ -unsigned int __maybe_unused cpu =smp_processor_id (); -char str[256 ]; - -printk (arc_cache_mumbojumbo (0 , str,sizeof (str))); - -if (IS_ENABLED (CONFIG_ARC_HAS_ICACHE )) { -struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; - -if (!ic->ver) -panic ("cache support enabled but non-existent cache\n" ); - -if (ic->line_len !=L1_CACHE_BYTES ) -panic ("ICache line [%d] != kernel Config [%d]" , - ic->line_len,L1_CACHE_BYTES ); - -if (ic->ver !=CONFIG_ARC_MMU_VER ) -panic ("Cache ver [%d] doesn't match MMU ver [%d]\n" , - ic->ver,CONFIG_ARC_MMU_VER ); - } - -if (IS_ENABLED (CONFIG_ARC_HAS_DCACHE )) { -struct cpuinfo_arc_cache *dc = &cpuinfo_arc700[cpu].dcache; -int handled; - -if (!dc->ver) -panic ("cache support enabled but non-existent cache\n" ); - -if (dc->line_len !=L1_CACHE_BYTES ) -panic ("DCache line [%d] != kernel Config [%d]" , - dc->line_len,L1_CACHE_BYTES ); - -/* check for D-Cache aliasing */ - handled =IS_ENABLED (CONFIG_ARC_CACHE_VIPT_ALIASING ); - -if (dc->alias && !handled) -panic ("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n" ); -else if (!dc->alias && handled) -panic ("Don't need CONFIG_ARC_CACHE_VIPT_ALIASING\n" ); - } -}#define OP_INV 0x1#define OP_FLUSH 0x2
@@ -197,16 +99,55 @@ void arc_cache_init(void)#define OP_INV_IC 0x4/* -* Common Helper for Line Operations on {I,D}-Cache +* I-Cache Aliasing in ARC700 VIPT caches (MMU v1-v3) +* +* ARC VIPT I-cache uses vaddr to index into cache and paddr to match the tag. +* The orig Cache Management Module "CDU" only required paddr to invalidate a +* certain line since it sufficed as index in Non-Aliasing VIPT cache-geometry. +* Infact for distinct V1,V2,P: all of {V1-P},{V2-P},{P-P} would end up fetching +* the exact same line. +* +* However for larger Caches (way-size > page-size) - i.e. in Aliasing config, +* paddr alone could not be used to correctly index the cache. +* +* ------------------ +* MMU v1/v2 (Fixed Page Size 8k) +* ------------------ +* The solution was to provide CDU with these additonal vaddr bits. These +* would be bits [x:13], x would depend on cache-geometry, 13 comes from +* standard page size of 8k. +* H/w folks chose [17:13] to be a future safe range, and moreso these 5 bits +* of vaddr could easily be "stuffed" in the paddr as bits [4:0] since the +* orig 5 bits of paddr were anyways ignored by CDU line ops, as they +* represent the offset within cache-line. The adv of using this "clumsy" +* interface for additional info was no new reg was needed in CDU programming +* model. +* +* 17:13 represented the max num of bits passable, actual bits needed were +* fewer, based on the num-of-aliases possible. +* -for 2 alias possibility, only bit 13 needed (32K cache) +* -for 4 alias possibility, bits 14:13 needed (64K cache) +* +* ------------------ +* MMU v3 +* ------------------ +* This ver of MMU supports variable page sizes (1k-16k): although Linux will +* only support 8k (default), 16k and 4k. +* However from hardware perspective, smaller page sizes aggrevate aliasing +* meaning more vaddr bits needed to disambiguate the cache-line-op ; +* the existing scheme of piggybacking won't work for certain configurations. +* Two new registers IC_PTAG and DC_PTAG inttoduced. +* "tag" bits are provided in PTAG, index bits in existing IVIL/IVDL/FLDL regs */ +static inline void __cache_line_loop (unsigned long paddr,unsigned long vaddr, -unsigned long sz,const int cacheop) +unsigned long sz,const int op) {unsigned int aux_cmd, aux_tag;int num_lines;const int full_page_op =__builtin_constant_p (sz) && sz ==PAGE_SIZE ; -if (cacheop ==OP_INV_IC ) { +if (op ==OP_INV_IC ) { aux_cmd =ARC_REG_IC_IVIL ;#if (CONFIG_ARC_MMU_VER >2 ) aux_tag =ARC_REG_IC_PTAG ;
@@ -214,7 +155,7 @@ static inline void __cache_line_loop(unsigned long paddr, unsigned long vaddr, }else {/* d$ cmd: INV (discard or wback-n-discard) OR FLUSH (wback) */ - aux_cmd = cacheop &OP_INV ?ARC_REG_DC_IVDL :ARC_REG_DC_FLDL ; + aux_cmd = op &OP_INV ?ARC_REG_DC_IVDL :ARC_REG_DC_FLDL ;#if (CONFIG_ARC_MMU_VER >2 ) aux_tag =ARC_REG_DC_PTAG ;#endif
@@ -296,107 +237,60 @@ static inline void __after_dc_op(const int op, unsigned int reg)/* * Operation on Entire D-Cache -* @cacheop = {OP_INV, OP_FLUSH, OP_FLUSH_N_INV} +* @op = {OP_INV, OP_FLUSH, OP_FLUSH_N_INV} * Note that constant propagation ensures all the checks are gone * in generated code */ -static inline void __dc_entire_op (const int cacheop) +static inline void __dc_entire_op (const int op) {unsigned int ctrl_reg;int aux; - ctrl_reg =__before_dc_op (cacheop); + ctrl_reg =__before_dc_op (op); -if (cacheop &OP_INV )/* Inv or flush-n-inv use same cmd reg */ +if (op &OP_INV )/* Inv or flush-n-inv use same cmd reg */ aux =ARC_REG_DC_IVDC ;else aux =ARC_REG_DC_FLSH ;write_aux_reg (aux,0x1 ); -__after_dc_op (cacheop, ctrl_reg); +__after_dc_op (op, ctrl_reg); }/* For kernel mappings cache operation: index is same as paddr */ #define __dc_line_op_k (p, sz, op) __dc_line_op(p, p, sz, op)/* -* D-Cache : Per Line INV (discard or wback+discard) or FLUSH (wback) +* Operation on D-Cache: Per Line INV (discard or wback+discard) or FLUSH (wback) */ static inline void __dc_line_op (unsigned long paddr,unsigned long vaddr, -unsigned long sz,const int cacheop) +unsigned long sz,const int op) {unsigned long flags;unsigned int ctrl_reg;local_irq_save (flags); - ctrl_reg =__before_dc_op (cacheop); + ctrl_reg =__before_dc_op (op); -__cache_line_loop (paddr, vaddr, sz, cacheop); +__cache_line_loop (paddr, vaddr, sz, op); -__after_dc_op (cacheop, ctrl_reg); +__after_dc_op (op, ctrl_reg);local_irq_restore (flags); }#else -#define __dc_entire_op (cacheop) -#define __dc_line_op (paddr, vaddr, sz, cacheop) -#define __dc_line_op_k (paddr, sz, cacheop) +#define __dc_entire_op (op) +#define __dc_line_op (paddr, vaddr, sz, op) +#define __dc_line_op_k (paddr, sz, op)#endif /* CONFIG_ARC_HAS_DCACHE */ -#ifdef CONFIG_ARC_HAS_ICACHE -/* -* I-Cache Aliasing in ARC700 VIPT caches -* -* ARC VIPT I-cache uses vaddr to index into cache and paddr to match the tag. -* The orig Cache Management Module "CDU" only required paddr to invalidate a -* certain line since it sufficed as index in Non-Aliasing VIPT cache-geometry. -* Infact for distinct V1,V2,P: all of {V1-P},{V2-P},{P-P} would end up fetching -* the exact same line. -* -* However for larger Caches (way-size > page-size) - i.e. in Aliasing config, -* paddr alone could not be used to correctly index the cache. -* -* ------------------ -* MMU v1/v2 (Fixed Page Size 8k) -* ------------------ -* The solution was to provide CDU with these additonal vaddr bits. These -* would be bits [x:13], x would depend on cache-geometry, 13 comes from -* standard page size of 8k. -* H/w folks chose [17:13] to be a future safe range, and moreso these 5 bits -* of vaddr could easily be "stuffed" in the paddr as bits [4:0] since the -* orig 5 bits of paddr were anyways ignored by CDU line ops, as they -* represent the offset within cache-line. The adv of using this "clumsy" -* interface for additional info was no new reg was needed in CDU programming -* model. -* -* 17:13 represented the max num of bits passable, actual bits needed were -* fewer, based on the num-of-aliases possible. -* -for 2 alias possibility, only bit 13 needed (32K cache) -* -for 4 alias possibility, bits 14:13 needed (64K cache) -* -* ------------------ -* MMU v3 -* ------------------ -* This ver of MMU supports variable page sizes (1k-16k): although Linux will -* only support 8k (default), 16k and 4k. -* However from hardware perspective, smaller page sizes aggrevate aliasing -* meaning more vaddr bits needed to disambiguate the cache-line-op ; -* the existing scheme of piggybacking won't work for certain configurations. -* Two new registers IC_PTAG and DC_PTAG inttoduced. -* "tag" bits are provided in PTAG, index bits in existing IVIL/IVDL/FLDL regs -*/ - -/*********************************************************** -* Machine specific helper for per line I-Cache invalidate. -*/ -static inline void __ic_entire_inv (void ) {write_aux_reg (ARC_REG_IC_IVIC ,1 );
@@ -721,3 +615,46 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags)flush_cache_all ();return 0 ; } + +void arc_cache_init (void ) +{ +unsigned int __maybe_unused cpu =smp_processor_id (); +char str[256 ]; + +printk (arc_cache_mumbojumbo (0 , str,sizeof (str))); + +if (IS_ENABLED (CONFIG_ARC_HAS_ICACHE )) { +struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; + +if (!ic->ver) +panic ("cache support enabled but non-existent cache\n" ); + +if (ic->line_len !=L1_CACHE_BYTES ) +panic ("ICache line [%d] != kernel Config [%d]" , + ic->line_len,L1_CACHE_BYTES ); + +if (ic->ver !=CONFIG_ARC_MMU_VER ) +panic ("Cache ver [%d] doesn't match MMU ver [%d]\n" , + ic->ver,CONFIG_ARC_MMU_VER ); + } + +if (IS_ENABLED (CONFIG_ARC_HAS_DCACHE )) { +struct cpuinfo_arc_cache *dc = &cpuinfo_arc700[cpu].dcache; +int handled; + +if (!dc->ver) +panic ("cache support enabled but non-existent cache\n" ); + +if (dc->line_len !=L1_CACHE_BYTES ) +panic ("DCache line [%d] != kernel Config [%d]" , + dc->line_len,L1_CACHE_BYTES ); + +/* check for D-Cache aliasing */ + handled =IS_ENABLED (CONFIG_ARC_CACHE_VIPT_ALIASING ); + +if (dc->alias && !handled) +panic ("Enable CONFIG_ARC_CACHE_VIPT_ALIASING\n" ); +else if (!dc->alias && handled) +panic ("Disable CONFIG_ARC_CACHE_VIPT_ALIASING\n" ); + } +}
Signature · 1 line
1.9.1
PATCH 7/19 ARC: entry.S: canonical'ize EXCEPTION_{PROLOGUE,EPILOGUE}
In reply to Vineet Gupta-EXCEPTION_EPILOGUE introduced -EXCEPTION_PROLOGUE now also includes reg file saving
--- arch/arc/include/asm/entry.h | 17 +---------------- arch/arc/kernel/entry.S | 4 ++-- 2 files changed, 3 insertions(+), 18 deletions(-)
arch/arc/include/asm/entry.h +1 -16
@@ -401,21 +401,6 @@/* ARC700 doesn't provide auto-stack switching */ SWITCH_TO_KERNEL_STK -/* save the regfile */ - SAVE_ALL_SYS -.endm - -/*-------------------------------------------------------------- -* Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc) -* Requires SP to be already switched to kernel mode Stack -* sp points to the next free element on the stack at exit of this macro. -* Registers are pushed / popped in the order defined in struct ptregs -* in asm/ptrace.h -* Note that syscalls are implemented via TRAP which is also a exception -* from CPU's point of view -*-------------------------------------------------------------*/ -.macro SAVE_ALL_SYS - lr r9, [ecr] st r9, [sp, 8] /* ECR */ st r0, [sp, 4] /* orig_r0, needed only for sys calls */
@@ -446,7 +431,7 @@* for memory load operations. If used in that way interrupts are deffered * by hardware and that is not good. *-------------------------------------------------------------*/ -.macro RESTORE_ALL_SYS +.macro EXCEPTION_EPILOGUE POPAX erbta POPAX lp_startPOPAX lp_end
arch/arc/kernel/entry.S +2 -2
@@ -638,7 +638,7 @@ restore_regs : ; if Returning from Exception bbit0 r10, STATUS_AE_BIT, not_exception - RESTORE_ALL_SYS + EXCEPTION_EPILOGUE rtie ; Not Exception so maybe Interrupts (Level 1 or 2)
@@ -704,7 +704,7 @@ not_level1_interrupt: ;this case is for syscalls or Exceptions (with fake rtie) - RESTORE_ALL_SYS + EXCEPTION_EPILOGUE debug_marker_syscall: rtie
Signature · 1 line
1.9.1
PATCH 9/19 ARC: entry.S: FAKE_RET_FROM_EXCPN can always use r9
In reply to Vineet Gupta--- arch/arc/include/asm/entry.h | 16 ++++++++-------- arch/arc/kernel/entry.S | 24 +++++++++++------------- 2 files changed, 19 insertions(+), 21 deletions(-)
arch/arc/include/asm/entry.h +8 -8
@@ -331,14 +331,14 @@* Look at EV_ProtV to see how this is actually used *-------------------------------------------------------------*/ -.macro FAKE_RET_FROM_EXCPN reg - - ld \reg, [sp, PT_status32] - bic \reg, \reg, (STATUS_U_MASK|STATUS_DE_MASK) - bset \reg, \reg, STATUS_L_BIT - sr \reg, [erstatus] - mov \reg, 55f - sr \reg, [eret] +.macro FAKE_RET_FROM_EXCPN + + ld r9, [sp, PT_status32] + bic r9, r9, (STATUS_U_MASK|STATUS_DE_MASK) + bset r9, r9, STATUS_L_BIT + sr r9, [erstatus] + mov r9, 55f + sr r9, [eret] rtie 55:
arch/arc/kernel/entry.S +11 -13
@@ -261,7 +261,7 @@ ENTRY(instr_service) lr r0, [efa] mov r1, sp - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN bl do_insterror_or_kprobe b ret_from_exception
@@ -278,7 +278,7 @@ ENTRY(mem_service) lr r0, [efa] mov r1, sp - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN bl do_memory_error b ret_from_exception
@@ -330,12 +330,11 @@ ENTRY(EV_TLBProtV) lr r2, [ecr] lr r0, [efa] ; Faulting Data address - ; --------(4) Return from CPU Exception Mode --------- - ; Fake a rtie, but rtie to next label - ; That way, subsequently, do_page_fault ( ) executes in pure kernel - ; mode with further Exceptions enabled + ; Exception auto-disables further Intr/exceptions. + ; Re-enable them by pretending to return from exception + ; (so rest of handler executes in pure K mode) - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN mov r1, sp
@@ -377,7 +376,7 @@ ENTRY(call_do_page_fault) EXCEPTION_PROLOGUE lr r0, [efa] ; Faulting Data address mov r1, sp - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN mov blink, ret_from_exception b do_page_fault
@@ -394,7 +393,7 @@ ENTRY(EV_PrivilegeV) lr r0, [efa] mov r1, sp - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN bl do_privilege_fault b ret_from_exception
@@ -410,7 +409,7 @@ ENTRY(EV_Extension) lr r0, [efa] mov r1, sp - FAKE_RET_FROM_EXCPN r9 + FAKE_RET_FROM_EXCPN bl do_extension_fault b ret_from_exception
@@ -472,7 +471,7 @@ trap_with_param: ; Now that we have read EFA, it is safe to do "fake" rtie ; and get out of CPU exception mode - FAKE_RET_FROM_EXCPN r11 + FAKE_RET_FROM_EXCPN ; Save callee regs in case gdb wants to have a look ; SP will grow up by size of CALLEE Reg-File
@@ -512,8 +511,7 @@ ENTRY(EV_Trap) ; ======= (5a) Trap is due to System Call ======== - ; Before doing anything, return from CPU Exception Mode - FAKE_RET_FROM_EXCPN r11 + FAKE_RET_FROM_EXCPN ; If syscall tracing ongoing, invoke pre-pos-hooks GET_CURR_THR_INFO_FLAGS r10
Signature · 1 line
1.9.1
PATCH 10/19 ARC: entry.S: Trap handler to use r10 for syscall vs. brkpt decision
In reply to Vineet Gupta--- arch/arc/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arc/kernel/entry.S +2 -2
@@ -505,8 +505,8 @@ ENTRY(EV_Trap) EXCEPTION_PROLOGUE ;------- (4) What caused the Trap -------------- - lr r12, [ecr] - bmsk.f 0, r12, 7 + lr r10, [ecr] + bmsk.f 0, r10, 7 bnz trap_with_param ; ======= (5a) Trap is due to System Call ========
Signature · 1 line
1.9.1
PATCH 11/19 ARC: entry.S: comments cleanup
In reply to Vineet Gupta--- arch/arc/kernel/entry.S | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-)
arch/arc/kernel/entry.S +20 -26
@@ -322,13 +322,8 @@ ENTRY(EV_TLBProtV) EXCEPTION_PROLOGUE - ;---------(3) Save some more regs----------------- - ; vineetg: Mar 6th: Random Seg Fault issue #1 - ; ecr and efa were not saved in case an Intr sneaks in - ; after fake rtie - lr r2, [ecr] - lr r0, [efa] ; Faulting Data address + lr r0, [efa] ; Faulting Data address (not part of pt_regs saved above) ; Exception auto-disables further Intr/exceptions. ; Re-enable them by pretending to return from exception
@@ -336,7 +331,7 @@ ENTRY(EV_TLBProtV) FAKE_RET_FROM_EXCPN - mov r1, sp + mov r1, sp ; Handle to pt_regs ;------ (5) Type of Protection Violation? ---------- ;
@@ -415,8 +410,11 @@ ENTRY(EV_Extension) b ret_from_exception END(EV_Extension) -;######################### System Call Tracing ######################### +;################ Trap Handling (Syscall, Breakpoint) ################## +; --------------------------------------------- +; syscall Tracing +; --------------------------------------------- tracesys: ; save EFA in case tracer wants the PC of traced task ; using ERET won't work since next-PC has already committed
@@ -459,10 +457,9 @@ tracesys_exit: b ret_from_exception ; NOT ret_from_system_call at is saves r0 which ; we'd done before calling post hook above -;################### Break Point TRAP ########################## - - ; ======= (5b) Trap is due to Break-Point ========= - +; --------------------------------------------- +; Breakpoint TRAP +; --------------------------------------------- trap_with_param: ; stop_pc info by gdb needs this info
@@ -490,36 +487,33 @@ trap_with_param: b ret_from_exception -;##################### Trap Handling ############################## -; -; EV_Trap caused by TRAP_S and TRAP0 instructions. -;------------------------------------------------------------------ -; (1) System Calls -; :parameters in r0-r7. -; :r8 has the system call number -; (2) Break Points -;------------------------------------------------------------------ +; --------------------------------------------- +; syscall TRAP +; ABI: (r0-r7) upto 8 args, (r8) syscall number +; --------------------------------------------- ENTRY(EV_Trap) EXCEPTION_PROLOGUE - ;------- (4) What caused the Trap -------------- + ;============ TRAP 1 :breakpoints lr r10, [ecr] bmsk.f 0, r10, 7 bnz trap_with_param - ; ======= (5a) Trap is due to System Call ======== + ;============ TRAP (no param): syscall top level + ; First return from Exception to pure K mode (Exception/IRQs renabled) FAKE_RET_FROM_EXCPN - ; If syscall tracing ongoing, invoke pre-pos-hooks + ; If syscall tracing ongoing, invoke pre-post-hooks GET_CURR_THR_INFO_FLAGS r10 btst r10, TIF_SYSCALL_TRACE bnz tracesys ; this never comes back - ;============ This is normal System Call case ========== - ; Sys-call num shd not exceed the total system calls avail + ;============ Normal syscall case + + ; syscall num shd not exceed the total system calls avail cmp r8, NR_syscalls mov.hi r0, -ENOSYS bhi ret_from_system_call
Signature · 1 line
1.9.1
PATCH 12/19 ARC: entry.S: Ensure that restore_regs is local to compilation unit
In reply to Vineet GuptaThis fixes the possible link/relo errors, since restore_regs will be provided by ISA code, but called from ARC common code. The .L prefix reassures binutils that it will be in same compilation unit.
--- arch/arc/kernel/entry.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arc/kernel/entry.S +4 -4
@@ -554,7 +554,7 @@ resume_user_mode_begin: ; Fast Path return to user mode if no pending work GET_CURR_THR_INFO_FLAGS r9 and.f 0, r9, _TIF_WORK_MASK - bz restore_regs + bz .Lrestore_regs ; --- (Slow Path #1) task preemption --- bbit0 r9, TIF_NEED_RESCHED, .Lchk_pend_signals
@@ -613,11 +613,11 @@ resume_kernel_mode: ; Can't preempt if preemption disabled GET_CURR_THR_INFO_FROM_SP r10 ld r8, [r10, THREAD_INFO_PREEMPT_COUNT] - brne r8, 0, restore_regs + brne r8, 0, .Lrestore_regs ; check if this task's NEED_RESCHED flag set ld r9, [r10, THREAD_INFO_FLAGS] - bbit0 r9, TIF_NEED_RESCHED, restore_regs + bbit0 r9, TIF_NEED_RESCHED, .Lrestore_regs ; Invoke PREEMPTION bl preempt_schedule_irq
@@ -633,7 +633,7 @@ resume_kernel_mode: ; IRQ shd definitely not happen between now and rtie ; All 2 entry points to here already disable interrupts -restore_regs : +.Lrestore_regs: TRACE_ASM_IRQ_ENABLE
Signature · 1 line
1.9.1
PATCH 13/19 ARC: entry.S: split into ARCompact ISA specific, common bits
In reply to Vineet Gupta--- arch/arc/include/asm/entry-compact.h | 306 +++++++++++++++++++++++++++ arch/arc/include/asm/entry.h | 300 +------------------------- arch/arc/kernel/Makefile | 4 +- arch/arc/kernel/entry-compact.S | 393 +++++++++++++++++++++++++++++++++++ arch/arc/kernel/entry.S | 389 +--------------------------------- 5 files changed, 711 insertions(+), 681 deletions(-) create mode 100644 arch/arc/include/asm/entry-compact.h create mode 100644 arch/arc/kernel/entry-compact.S
arch/arc/include/asm/entry-compact.h new file +306 -0
@@ -0,0 +1,306 @@ +/* +* Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) +* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Vineetg: March 2009 (Supporting 2 levels of Interrupts) +* Stack switching code can no longer reliably rely on the fact that +* if we are NOT in user mode, stack is switched to kernel mode. +* e.g. L2 IRQ interrupted a L1 ISR which had not yet completed +* it's prologue including stack switching from user mode +* +* Vineetg: Aug 28th 2008: Bug #94984 +* -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap +* Normally CPU does this automatically, however when doing FAKE rtie, +* we also need to explicitly do this. The problem in macros +* FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit +* was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context +* +* Vineetg: May 5th 2008 +* -Modified CALLEE_REG save/restore macros to handle the fact that +* r25 contains the kernel current task ptr +* - Defined Stack Switching Macro to be reused in all intr/excp hdlrs +* - Shaved off 11 instructions from RESTORE_ALL_INT1 by using the +* address Write back load ld.ab instead of seperate ld/add instn +* +* Amit Bhor, Sameer Dhavale: Codito Technologies 2004 +*/ + +#ifndef __ASM_ARC_ENTRY_COMPACT_H +#define __ASM_ARC_ENTRY_COMPACT_H + +#include <asm/asm-offsets.h> +#include <asm/thread_info.h> /* For THREAD_SIZE */ + +/*-------------------------------------------------------------- +* Switch to Kernel Mode stack if SP points to User Mode stack +* +* Entry : r9 contains pre-IRQ/exception/trap status32 +* Exit : SP is set to kernel mode stack pointer +* If CURR_IN_REG, r25 set to "current" task pointer +* Clobbers: r9 +*-------------------------------------------------------------*/ + +.macro SWITCH_TO_KERNEL_STK + + /* User Mode when this happened ? Yes: Proceed to switch stack */ + bbit1 r9, STATUS_U_BIT, 88f + +/* OK we were already in kernel mode when this event happened, thus can +* assume SP is kernel mode SP. _NO_ need to do any stack switching +*/ + +#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS +/* However.... +* If Level 2 Interrupts enabled, we may end up with a corner case: +* 1. User Task executing +* 2. L1 IRQ taken, ISR starts (CPU auto-switched to KERNEL mode) +* 3. But before it could switch SP from USER to KERNEL stack +* a L2 IRQ "Interrupts" L1 +* Thay way although L2 IRQ happened in Kernel mode, stack is still +* not switched. +* To handle this, we may need to switch stack even if in kernel mode +* provided SP has values in range of USER mode stack ( < 0x7000_0000 ) +*/ + brlo sp, VMALLOC_START, 88f + +/* TODO: vineetg: +* We need to be a bit more cautious here. What if a kernel bug in +* L1 ISR, caused SP to go whaco (some small value which looks like +* USER stk) and then we take L2 ISR. +* Above brlo alone would treat it as a valid L1-L2 sceanrio +* instead of shouting alound +* The only feasible way is to make sure this L2 happened in +* L1 prelogue ONLY i.e. ilink2 is less than a pre-set marker in +* L1 ISR before it switches stack +*/ + +#endif + +/* Save Pre Intr/Exception KERNEL MODE SP on kernel stack +* safe-keeping not really needed, but it keeps the epilogue code +* (SP restore) simpler/uniform. +*/ + b.d 66f + mov r9, sp + +88: /*------Intr/Ecxp happened in user mode, "switch" stack ------ */ + + GET_CURR_TASK_ON_CPU r9 + +/* With current tsk in r9, get it's kernel mode stack base */ + GET_TSK_STACK_BASE r9, r9 + +66: +#ifdef CONFIG_ARC_CURR_IN_REG +/* +* Treat r25 as scratch reg, save it on stack first +* Load it with current task pointer +*/ + st r25, [r9, -4] + GET_CURR_TASK_ON_CPU r25 +#endif + +/* Save Pre Intr/Exception User SP on kernel stack */ + st.a sp, [r9, -16] ; Make room for orig_r0, ECR, user_r25 + +/* CAUTION: +* SP should be set at the very end when we are done with everything +* In case of 2 levels of interrupt we depend on value of SP to assume +* that everything else is done (loading r25 etc) +*/ + +/* set SP to point to kernel mode stack */ + mov sp, r9 + +/* ----- Stack Switched to kernel Mode, Now save REG FILE ----- */ + +.endm + +/*------------------------------------------------------------ + * "FAKE" a rtie to return from CPU Exception context + * This is to re-enable Exceptions within exception + * Look at EV_ProtV to see how this is actually used + *-------------------------------------------------------------*/ + +.macro FAKE_RET_FROM_EXCPN + + ld r9, [sp, PT_status32] + bic r9, r9, (STATUS_U_MASK|STATUS_DE_MASK) + bset r9, r9, STATUS_L_BIT + sr r9, [erstatus] + mov r9, 55f + sr r9, [eret] + + rtie +55: +.endm + +/*-------------------------------------------------------------- +* For early Exception/ISR Prologue, a core reg is temporarily needed to +* code the rest of prolog (stack switching). This is done by stashing +* it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP). +* +* Before saving the full regfile - this reg is restored back, only +* to be saved again on kernel mode stack, as part of pt_regs. +*-------------------------------------------------------------*/ +.macro PROLOG_FREEUP_REG reg, mem +#ifdef CONFIG_SMP + sr \reg, [ARC_REG_SCRATCH_DATA0] +#else + st \reg, [\mem] +#endif +.endm + +.macro PROLOG_RESTORE_REG reg, mem +#ifdef CONFIG_SMP + lr \reg, [ARC_REG_SCRATCH_DATA0] +#else + ld \reg, [\mem] +#endif +.endm + +/*-------------------------------------------------------------- + * Exception Entry prologue + * -Switches stack to K mode (if not already) + * -Saves the register file + * + * After this it is safe to call the "C" handlers + *-------------------------------------------------------------*/ +.macro EXCEPTION_PROLOGUE + +/* Need at least 1 reg to code the early exception prologue */ + PROLOG_FREEUP_REG r9, @ex_saved_reg1 + + /* U/K mode at time of exception (stack not switched if already K) */ + lr r9, [erstatus] + +/* ARC700 doesn't provide auto-stack switching */ + SWITCH_TO_KERNEL_STK + + lr r9, [ecr] + st r9, [sp, 8] /* ECR */ + st r0, [sp, 4] /* orig_r0, needed only for sys calls */ + +/* Restore r9 used to code the early prologue */ + PROLOG_RESTORE_REG r9, @ex_saved_reg1 + + SAVE_R0_TO_R12 + PUSH gp + PUSH fp + PUSH blink + PUSHAX eret + PUSHAX erstatus + PUSH lp_count + PUSHAX lp_end + PUSHAX lp_start + PUSHAX erbta +.endm + +/*-------------------------------------------------------------- +* Restore all registers used by system call or Exceptions +* SP should always be pointing to the next free stack element +* when entering this macro. +* +* NOTE: +* +* It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg +* for memory load operations. If used in that way interrupts are deffered +* by hardware and that is not good. +*-------------------------------------------------------------*/ +.macro EXCEPTION_EPILOGUE + POPAX erbta + POPAX lp_start + POPAX lp_end + + POP r9 + mov lp_count, r9 ;LD to lp_count is not allowed + + POPAX erstatus + POPAX eret + POP blink + POP fp + POP gp + RESTORE_R12_TO_R0 + + ld sp, [sp] /* restore original sp */ + /* orig_r0, ECR, user_r25 skipped automatically */ +.endm + +/* Dummy ECR values for Interrupts */ +#define event_IRQ1 0x0031abcd +#define event_IRQ2 0x0032abcd + +.macro INTERRUPT_PROLOGUE LVL + +/* free up r9 as scratchpad */ + PROLOG_FREEUP_REG r9, @int\LVL\()_saved_reg + + /* Which mode (user/kernel) was the system in when intr occured */ + lr r9, [status32_l\LVL\()] + + SWITCH_TO_KERNEL_STK + + /* restore original r9 */ + PROLOG_RESTORE_REG r9, @int\LVL\()_saved_reg + + /* now we are ready to save the remaining context */ + st 0x003\LVL\()abcd, [sp, 8] /* Dummy ECR */ + st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ + + SAVE_R0_TO_R12 + PUSH gp + PUSH fp + PUSH blink + PUSH ilink\LVL\() + PUSHAX status32_l\LVL\() + PUSH lp_count + PUSHAX lp_end + PUSHAX lp_start + PUSHAX bta_l\LVL\() +.endm + +/*-------------------------------------------------------------- + * Restore all registers used by interrupt handlers. + * + * NOTE: + * + * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg + * for memory load operations. If used in that way interrupts are deffered + * by hardware and that is not good. + *-------------------------------------------------------------*/ +.macro INTERRUPT_EPILOGUE LVL + POPAX bta_l\LVL\() + POPAX lp_start + POPAX lp_end + + POP r9 + mov lp_count, r9 ;LD to lp_count is not allowed + + POPAX status32_l\LVL\() + POP ilink\LVL\() + POP blink + POP fp + POP gp + RESTORE_R12_TO_R0 + + ld sp, [sp] /* restore original sp */ + /* orig_r0, ECR, user_r25 skipped automatically */ +.endm + +/* Get thread_info of "current" tsk */ +.macro GET_CURR_THR_INFO_FROM_SP reg + bic \reg, sp, (THREAD_SIZE - 1) +.endm + +/* Get CPU-ID of this core */ +.macro GET_CPU_ID reg + lr \reg, [identity] + lsr \reg, \reg, 8 + bmsk \reg, \reg, 7 +.endm + +#endif /* __ASM_ARC_ENTRY_COMPACT_H */
arch/arc/include/asm/entry.h +3 -297
336 lines not on this page · raw message
arch/arc/kernel/Makefile +2 -2
@@ -8,9 +8,9 @@ # Pass UTS_MACHINE for user_regset definition CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' -obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o +obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o process.o devtree.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o -obj-y += devtree.o +obj-y += entry-compact.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o
arch/arc/kernel/entry-compact.S new file +393 -0
393 lines not on this page · raw message
arch/arc/kernel/entry.S +7 -382
425 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 14/19 ARC: entry.S: move some code around for cache locality in return path
In reply to Vineet Gupta--- arch/arc/kernel/entry-compact.S | 2 + arch/arc/kernel/entry.S | 98 +++++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 48 deletions(-)
arch/arc/kernel/entry-compact.S +2 -0
@@ -391,3 +391,5 @@ not_level1_interrupt: EXCEPTION_EPILOGUE debug_marker_syscall: rtie + +END(ret_from_exception)
arch/arc/kernel/entry.S +50 -48
109 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 19/19 ARC: intc: split into ARCompact ISA specific, common bits
In reply to Vineet Gupta--- arch/arc/include/asm/entry-compact.h | 1 + arch/arc/include/asm/irqflags-compact.h | 181 +++++++++++++++++++++++++ arch/arc/include/asm/irqflags.h | 168 +---------------------- arch/arc/kernel/Makefile | 2 +- arch/arc/kernel/intc-compact.c | 230 ++++++++++++++++++++++++++++++++ arch/arc/kernel/irq.c | 210 ----------------------------- arch/arc/kernel/process.c | 3 +- 7 files changed, 416 insertions(+), 379 deletions(-) create mode 100644 arch/arc/include/asm/irqflags-compact.h create mode 100644 arch/arc/kernel/intc-compact.c
arch/arc/include/asm/entry-compact.h +1 -0
@@ -33,6 +33,7 @@#define __ASM_ARC_ENTRY_COMPACT_H#include <asm/asm-offsets.h> +#include <asm/irqflags-compact.h> #include <asm/thread_info.h> /* For THREAD_SIZE */ /*--------------------------------------------------------------
arch/arc/include/asm/irqflags-compact.h new file +181 -0
181 lines not on this page · raw message
arch/arc/include/asm/irqflags.h +2 -166
177 lines not on this page · raw message
arch/arc/kernel/Makefile +1 -1
@@ -10,7 +10,7 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o process.o devtree.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o -obj-y += entry-compact.o +obj-y += entry-compact.o intc-compact.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o
arch/arc/kernel/intc-compact.c new file +230 -0
230 lines not on this page · raw message
arch/arc/kernel/irq.c +0 -210
223 lines not on this page · raw message
arch/arc/kernel/process.c +1 -2
@@ -166,8 +166,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long usp)* [L] ZOL loop inhibited to begin with - cleared by a LP insn * Interrupts enabled */ - regs->status32 =STATUS_U_MASK |STATUS_L_MASK | -STATUS_E1_MASK |STATUS_E2_MASK ; + regs->status32 =STATUS_U_MASK |STATUS_L_MASK |STATUS_IE_MASK ;/* bogus seed values for debugging */ regs->lp_start =0x10 ;
Signature · 1 line
1.9.1
PATCH 17/19 ARC: entry.S: [arcompact] simplify SWITCH_TO_KERNEL_STK
In reply to Vineet GuptaPreviously this macro was overloaded with stack switching, saving SP at right slot in pt_regs, saving/setup of r25 and setting SP baseline to where pt_regs->sp is saved (vs. bottom of pt_regs)
Now it only does SP switch, and leaves SP pointing to bottom of pt_regs.
r25 saving is no longer done here to allow for future reordering of regfile in pt_regs w/o touching this macro
--- arch/arc/include/asm/entry-compact.h | 71 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-)
arch/arc/include/asm/entry-compact.h +35 -36
@@ -39,8 +39,8 @@* Switch to Kernel Mode stack if SP points to User Mode stack * * Entry : r9 contains pre-IRQ/exception/trap status32 -* Exit : SP is set to kernel mode stack pointer -* If CURR_IN_REG, r25 set to "current" task pointer +* Exit : SP set to K mode stack +* SP at the time of entry (K/U) saved @ pt_regs->sp * Clobbers: r9 *-------------------------------------------------------------*/
@@ -80,12 +80,11 @@#endif -/* Save Pre Intr/Exception KERNEL MODE SP on kernel stack -* safe-keeping not really needed, but it keeps the epilogue code -* (SP restore) simpler/uniform. -*/ +/*------Intr/Ecxp happened in kernel mode, SP already setup ------ */ +/* save it nevertheless @ pt_regs->sp for uniformity */ + b.d 66f -mov r9, sp + st sp, [sp, PT_sp - SZ_PT_REGS] 88: /*------Intr/Ecxp happened in user mode, "switch" stack ------ */
@@ -94,30 +93,12 @@/* With current tsk in r9, get it's kernel mode stack base */ GET_TSK_STACK_BASE r9, r9 -66: -#ifdef CONFIG_ARC_CURR_IN_REG -/* -* Treat r25 as scratch reg, save it on stack first -* Load it with current task pointer -*/ - st r25, [r9, -4] - GET_CURR_TASK_ON_CPU r25 -#endif - -/* Save Pre Intr/Exception User SP on kernel stack */ - st.a sp, [r9, -16] ; Make room for orig_r0, ECR, user_r25 - -/* CAUTION: -* SP should be set at the very end when we are done with everything -* In case of 2 levels of interrupt we depend on value of SP to assume -* that everything else is done (loading r25 etc) -*/ - -/* set SP to point to kernel mode stack */ - mov sp, r9 - -/* ----- Stack Switched to kernel Mode, Now save REG FILE ----- */ +/* save U mode SP @ pt_regs->sp */ + st sp, [r9, PT_sp - SZ_PT_REGS] +/* final SP switch */ + mov sp, r9 +66: .endm/*------------------------------------------------------------
@@ -181,11 +162,21 @@/* ARC700 doesn't provide auto-stack switching */ SWITCH_TO_KERNEL_STK - st r0, [sp, 4] /* orig_r0, needed only for sys calls */ +#ifdef CONFIG_ARC_CURR_IN_REG +/* Treat r25 as scratch reg (save it on stack) and load with "current" */ + PUSH r25 + GET_CURR_TASK_ON_CPU r25 +#else + sub sp, sp, 4 +#endif + + st.a r0, [sp, -8] /* orig_r0 needed for syscall (skip ECR slot) */ + sub sp, sp, 4 /* skip pt_regs->sp, already saved above *//* Restore r9 used to code the early prologue */ PROLOG_RESTORE_REG r9, @ex_saved_reg1 + /* now we are ready to save the regfile */ SAVE_R0_TO_R12 PUSH gp PUSH fp
@@ -245,12 +236,20 @@ SWITCH_TO_KERNEL_STK -/* restore original r9 */ - PROLOG_RESTORE_REG r9, @int\LVL\()_saved_reg +#ifdef CONFIG_ARC_CURR_IN_REG +/* Treat r25 as scratch reg (save it on stack) and load with "current" */ + PUSH r25 + GET_CURR_TASK_ON_CPU r25 +#else + sub sp, sp, 4 +#endif - /* now we are ready to save the remaining context */ - st 0x003\LVL\()abcd, [sp, 8] /* Dummy ECR */ - st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ + PUSH 0x003\LVL\()abcd /* Dummy ECR */ + sub sp, sp, 8 /* skip orig_r0 (not needed) +skip pt_regs->sp, already saved above */ + +/* Restore r9 used to code the early prologue */ + PROLOG_RESTORE_REG r9, @int\LVL\()_saved_reg SAVE_R0_TO_R12 PUSH gp
Signature · 1 line
1.9.1
Quoted 13 lines · Vineet Gupta
Hi,
ARCv2 is the next generation ISA from Synopsys and basis for the HS3{4,6,8} families of processors which retain the traditional ARC mantra of low power and configurability and are now more performant and feature rich.
Linux has been ported to HS38x series, a 10 stage pipeline core which supports MMU (with huge pages) and SMP (upto 4 cores) among other features.
- www.synopsys.com/dw/ipdir.php?ds=arc-hs38-processor
- http://news.synopsys.com/2014-10-14-New-DesignWare-ARC-HS38-Processor-Doubles-Performance-for-Embedded-Linux-Applications
- http://www.embedded.com/electronics-news/4435975/Synopsys-ARC-HS38-core-gives-2X-boost-to-Linux-based-apps
Quoted 6 lines
This sub-series introduces changes to existing in-tree port of ARC700 core (based on ARCompact ISA) to allow for better code sharing with new ARCv2 code.
The actual ARCv2 port will follow as a seperate series.
Please review !
The complete code is also available in git tree
git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git # for-HS-upstream
Thx,
-Vineet