Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARCv2: entry: comments about hardware auto-save on taken interrupts

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+62 -16
+62 -16
arch/arc/include/asm/entry-arcv2.h
··· 7 7 #include <asm/irqflags-arcv2.h> 8 8 #include <asm/thread_info.h> /* For THREAD_SIZE */ 9 9 10 + /* 11 + * Interrupt/Exception stack layout (pt_regs) for ARCv2 12 + * (End of struct aligned to end of page [unless nested]) 13 + * 14 + * INTERRUPT EXCEPTION 15 + * 16 + * manual --------------------- manual 17 + * | orig_r0 | 18 + * | event/ECR | 19 + * | bta | 20 + * | user_r25 | 21 + * | gp | 22 + * | fp | 23 + * | sp | 24 + * | r12 | 25 + * | r30 | 26 + * | r58 | 27 + * | r59 | 28 + * hw autosave --------------------- 29 + * optional | r0 | 30 + * | r1 | 31 + * ~ ~ 32 + * | r9 | 33 + * | r10 | 34 + * | r11 | 35 + * | blink | 36 + * | lpe | 37 + * | lps | 38 + * | lpc | 39 + * | ei base | 40 + * | ldi base | 41 + * | jli base | 42 + * --------------------- 43 + * hw autosave | pc / eret | 44 + * mandatory | stat32 / erstatus | 45 + * --------------------- 46 + */ 47 + 10 48 /*------------------------------------------------------------------------*/ 11 49 .macro INTERRUPT_PROLOGUE called_from 12 - 13 - ; Before jumping to Interrupt Vector, hardware micro-ops did following: 50 + ; (A) Before jumping to Interrupt Vector, hardware micro-ops did following: 14 51 ; 1. SP auto-switched to kernel mode stack 15 - ; 2. STATUS32.Z flag set to U mode at time of interrupt (U:1, K:0) 16 - ; 3. Auto saved: r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI, PC, STAT32 52 + ; 2. STATUS32.Z flag set if in U mode at time of interrupt (U:1,K:0) 53 + ; 3. Auto save: (mandatory) Push PC and STAT32 on stack 54 + ; hardware does even if CONFIG_ARC_IRQ_NO_AUTOSAVE 55 + ; 4. Auto save: (optional) r0-r11, blink, LPE,LPS,LPC, JLI,LDI,EI 17 56 ; 18 - ; Now manually save: r12, sp, fp, gp, r25 57 + ; (B) Manually saved some regs: r12,r25,r30, sp,fp,gp, ACCL pair 19 58 20 59 #ifdef CONFIG_ARC_IRQ_NO_AUTOSAVE 21 60 .ifnc \called_from, exception ··· 96 57 ; - U mode: retrieve it from AUX_USER_SP 97 58 ; - K mode: add the offset from current SP where H/w starts auto push 98 59 ; 99 - ; Utilize the fact that Z bit is set if Intr taken in U mode 60 + ; 1. Utilize the fact that Z bit is set if Intr taken in U mode 61 + ; 2. Upon entry SP is always saved (for any inspection, unwinding etc), 62 + ; but on return, restored only if U mode 63 + 100 64 mov.nz r9, sp 101 - add.nz r9, r9, SZ_PT_REGS - PT_sp - 4 65 + add.nz r9, r9, SZ_PT_REGS - PT_sp - 4 ; K mode SP 102 66 bnz 1f 103 67 104 - lr r9, [AUX_USER_SP] 68 + lr r9, [AUX_USER_SP] ; U mode SP 105 69 1: 106 - PUSH r9 ; SP 70 + PUSH r9 ; SP (pt_regs->sp) 107 71 108 72 PUSH fp 109 73 PUSH gp ··· 127 85 /*------------------------------------------------------------------------*/ 128 86 .macro INTERRUPT_EPILOGUE called_from 129 87 88 + ; INPUT: r0 has STAT32 of calling context 89 + ; INPUT: Z flag set if returning to K mode 130 90 .ifnc \called_from, exception 131 91 add sp, sp, 12 ; skip BTA/ECR/orig_r0 placeholderss 132 92 .endif ··· 142 98 POP gp 143 99 POP fp 144 100 145 - ; Don't touch AUX_USER_SP if returning to K mode (Z bit set) 146 - ; (Z bit set on K mode is inverse of INTERRUPT_PROLOGUE) 147 - add.z sp, sp, 4 101 + ; Restore SP (into AUX_USER_SP) only if returning to U mode 102 + ; - for K mode, it will be implicitly restored as stack is unwound 103 + ; - Z flag set on K is inverse of what hardware does on interrupt entry 104 + ; but that doesn't really matter 148 105 bz 1f 149 106 150 107 POPAX AUX_USER_SP ··· 190 145 /*------------------------------------------------------------------------*/ 191 146 .macro EXCEPTION_PROLOGUE 192 147 193 - ; Before jumping to Exception Vector, hardware micro-ops did following: 148 + ; (A) Before jumping to Exception Vector, hardware micro-ops did following: 194 149 ; 1. SP auto-switched to kernel mode stack 195 - ; 2. STATUS32.Z flag set to U mode at time of interrupt (U:1,K:0) 150 + ; 2. STATUS32.Z flag set if in U mode at time of exception (U:1,K:0) 196 151 ; 197 - ; Now manually save the complete reg file 152 + ; (B) Manually save the complete reg file below 198 153 199 154 PUSH r9 ; freeup a register: slot of erstatus 200 155 ··· 240 195 PUSHAX ecr ; r9 contains ECR, expected by EV_Trap 241 196 242 197 PUSH r0 ; orig_r0 198 + ; OUTPUT: r9 has ECR 243 199 .endm 244 200 245 201 /*------------------------------------------------------------------------*/ 246 202 .macro EXCEPTION_EPILOGUE 247 203 248 - ; Assumes r0 has PT_status32 204 + ; INPUT: r0 has STAT32 of calling context 249 205 btst r0, STATUS_U_BIT ; Z flag set if K, used in INTERRUPT_EPILOGUE 250 206 251 207 add sp, sp, 8 ; orig_r0/ECR don't need restoring