ARC: entry: SAVE_ABI_CALLEE_REG: ISA/ABI specific helper
authorVineet Gupta <vgupta@kernel.org>
Thu, 21 May 2020 20:33:24 +0000 (13:33 -0700)
committerVineet Gupta <vgupta@kernel.org>
Sat, 9 Dec 2023 00:30:24 +0000 (16:30 -0800)
And for ARcompact variant replace the PUSH/POP macros with gas provided
push/pop pseudo-instructions

This allows ISA specific implementation

e.g. Current ARCv2 PUSH/POP could be replaced with STD/LDL to save 2
registers at a time (w/o bothering with SP update each time) or
perhaps use ENTER_S/LEAVE_S to reduce code size

For ARCv3 ABI changed so callee regs are now r14-r26 (vs. r13-r25)
thus would need a different implementation.

Signed-off-by: Vineet Gupta <vgupta@kernel.org>
arch/arc/include/asm/entry-arcv2.h
arch/arc/include/asm/entry-compact.h
arch/arc/include/asm/entry.h
arch/arc/include/asm/ptrace.h

index 4d13320e0c1b6363a628439bd79bae0042d00a79..3802a2daaf8692a643873b80b035488ce4b29ba2 100644 (file)
                                /* M = 8-1  N = 8 */
 .endm
 
+.macro SAVE_ABI_CALLEE_REGS
+       push    r13
+       push    r14
+       push    r15
+       push    r16
+       push    r17
+       push    r18
+       push    r19
+       push    r20
+       push    r21
+       push    r22
+       push    r23
+       push    r24
+       push    r25
+.endm
+
+.macro RESTORE_ABI_CALLEE_REGS
+       pop     r25
+       pop     r24
+       pop     r23
+       pop     r22
+       pop     r21
+       pop     r20
+       pop     r19
+       pop     r18
+       pop     r17
+       pop     r16
+       pop     r15
+       pop     r14
+       pop     r13
+.endm
+
 #endif
index a0e760eb35a80e9faefa3d16389b01eac6dcea00..9841f1186417003a8e0011b65328046f6189fd51 100644 (file)
 #include <asm/irqflags-compact.h>
 #include <asm/thread_info.h>   /* For THREAD_SIZE */
 
+.macro SAVE_ABI_CALLEE_REGS
+       push    r13
+       push    r14
+       push    r15
+       push    r16
+       push    r17
+       push    r18
+       push    r19
+       push    r20
+       push    r21
+       push    r22
+       push    r23
+       push    r24
+       push    r25
+.endm
+
+.macro RESTORE_ABI_CALLEE_REGS
+       pop     r25
+       pop     r24
+       pop     r23
+       pop     r22
+       pop     r21
+       pop     r20
+       pop     r19
+       pop     r18
+       pop     r17
+       pop     r16
+       pop     r15
+       pop     r14
+       pop     r13
+.endm
+
 /*--------------------------------------------------------------
  * Switch to Kernel Mode stack if SP points to User Mode stack
  *
index 49c2e090cb5c1f97786838eb9e3d82200c1d43ed..8e4e40d2d54adccb39eddcee50956339b7f1322c 100644 (file)
 
 .endm
 
-/*--------------------------------------------------------------
- * Helpers to save/restore callee-saved regs:
- * used by several macros below
- *-------------------------------------------------------------*/
-.macro SAVE_R13_TO_R25
-       PUSH    r13
-       PUSH    r14
-       PUSH    r15
-       PUSH    r16
-       PUSH    r17
-       PUSH    r18
-       PUSH    r19
-       PUSH    r20
-       PUSH    r21
-       PUSH    r22
-       PUSH    r23
-       PUSH    r24
-       PUSH    r25
-.endm
-
-.macro RESTORE_R25_TO_R13
-       POP     r25
-       POP     r24
-       POP     r23
-       POP     r22
-       POP     r21
-       POP     r20
-       POP     r19
-       POP     r18
-       POP     r17
-       POP     r16
-       POP     r15
-       POP     r14
-       POP     r13
-.endm
-
 /*
  * save user mode callee regs as struct callee_regs
  *  - needed by fork/do_signal/unaligned-access-emulation.
  */
 .macro SAVE_CALLEE_SAVED_USER
-       SAVE_R13_TO_R25
+       SAVE_ABI_CALLEE_REGS
 .endm
 
 /*
  *  - could have been changed by ptrace tracer or unaligned-access fixup
  */
 .macro RESTORE_CALLEE_SAVED_USER
-       RESTORE_R25_TO_R13
+       RESTORE_ABI_CALLEE_REGS
 .endm
 
 /*
  * save/restore kernel mode callee regs at the time of context switch
  */
 .macro SAVE_CALLEE_SAVED_KERNEL
-       SAVE_R13_TO_R25
+       SAVE_ABI_CALLEE_REGS
 .endm
 
 .macro RESTORE_CALLEE_SAVED_KERNEL
-       RESTORE_R25_TO_R13
+       RESTORE_ABI_CALLEE_REGS
 .endm
 
 /*--------------------------------------------------------------
index 4a2b30fb5a985e588079e574a871c09688e341da..00b9318e551e7e31fc2eeff345d6d722f4e3efb6 100644 (file)
@@ -54,6 +54,10 @@ struct pt_regs {
        ecr_reg ecr;
 };
 
+struct callee_regs {
+       unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
+};
+
 #define MAX_REG_OFFSET offsetof(struct pt_regs, ecr)
 
 #else
@@ -92,16 +96,14 @@ struct pt_regs {
        unsigned long status32;
 };
 
-#define MAX_REG_OFFSET offsetof(struct pt_regs, status32)
-
-#endif
-
-/* Callee saved registers - need to be saved only when you are scheduled out */
-
 struct callee_regs {
        unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
 };
 
+#define MAX_REG_OFFSET offsetof(struct pt_regs, status32)
+
+#endif
+
 #define instruction_pointer(regs)      ((regs)->ret)
 #define profile_pc(regs)               instruction_pointer(regs)