From 50a45c1ad2e1d7323b7ebb6f98215d4021adba24 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Tue, 11 Jun 2013 18:56:54 +0530 Subject: [PATCH] ARC: pt_regs cleanup #4: no need to keep backup of r8 (RIP orig_r8) Historically, pt_regs have had orig_r8, an overloaded container for (1) backup copy of syscall number (in case of syscall Trap Exceptions) (2) additional system state: (syscall/Exception/Interrupt) There is no point in keeping (1) since syscall number is never clobbered in-place, in pt_regs (unlike r0 which duals as first syscall arg as well as syscall return value and in case of syscall restart, the orig arg0 needs restoring after having been updated in-place with syscall ret value). So remove stuffing of syscall num in orig_r8 - simplifies SAVE_ALL_TRAP Use it exclusively for (2) hence rename to @event - RIP orig_r8 Signed-off-by: Vineet Gupta --- arch/arc/include/asm/entry.h | 29 +++++++++-------------------- arch/arc/include/asm/ptrace.h | 30 +++++++++++------------------- arch/arc/include/asm/syscall.h | 5 ++--- arch/arc/include/uapi/asm/ptrace.h | 2 +- arch/arc/kernel/asm-offsets.c | 2 +- arch/arc/kernel/entry.S | 6 +++--- arch/arc/kernel/process.c | 2 +- 7 files changed, 28 insertions(+), 48 deletions(-) diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 72a7ed47117a..4a7e7ea0ed3d 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -309,7 +309,7 @@ #endif /* Save Pre Intr/Exception User SP on kernel stack */ - st.a sp, [r9, -16] ; Make room for orig_r0, orig_r8, user_r25 + st.a sp, [r9, -16] ; Make room for orig_r0, event, user_r25 /* CAUTION: * SP should be set at the very end when we are done with everything @@ -393,7 +393,7 @@ *-------------------------------------------------------------*/ .macro SAVE_ALL_EXCEPTION marker - st \marker, [sp, 8] /* orig_r8 */ + st \marker, [sp, 8] /* event */ st r0, [sp, 4] /* orig_r0, needed only for sys calls */ /* Restore r9 used to code the early prologue */ @@ -415,25 +415,14 @@ * Save scratch regs for exceptions *-------------------------------------------------------------*/ .macro SAVE_ALL_SYS - SAVE_ALL_EXCEPTION orig_r8_IS_EXCPN + SAVE_ALL_EXCEPTION event_EXCPN .endm /*-------------------------------------------------------------- * Save scratch regs for sys calls *-------------------------------------------------------------*/ .macro SAVE_ALL_TRAP - /* - * Setup pt_regs->orig_r8. - * Encode syscall number (r8) in upper short word of event type (r9) - * N.B. #1: This is already endian safe (see ptrace.h) - * #2: Only r9 can be used as scratch as it is already clobbered - * and it's contents are no longer needed by the latter part - * of exception prologue - */ - lsl r9, r8, 16 - or r9, r9, orig_r8_IS_SCALL - - SAVE_ALL_EXCEPTION r9 + SAVE_ALL_EXCEPTION event_SCALL .endm /*-------------------------------------------------------------- @@ -463,7 +452,7 @@ RESTORE_R12_TO_R0 ld sp, [sp] /* restore original sp */ - /* orig_r0, orig_r8, user_r25 skipped automatically */ + /* orig_r0, event, user_r25 skipped automatically */ .endm @@ -480,7 +469,7 @@ #endif /* now we are ready to save the remaining context :) */ - st orig_r8_IS_IRQ1, [sp, 8] /* Event Type */ + st event_IRQ1, [sp, 8] /* Event Type */ st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ SAVE_R0_TO_R12 @@ -505,7 +494,7 @@ ld r9, [@int2_saved_reg] /* now we are ready to save the remaining context :) */ - st orig_r8_IS_IRQ2, [sp, 8] /* Event Type */ + st event_IRQ2, [sp, 8] /* Event Type */ st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ SAVE_R0_TO_R12 @@ -546,7 +535,7 @@ RESTORE_R12_TO_R0 ld sp, [sp] /* restore original sp */ - /* orig_r0, orig_r8, user_r25 skipped automatically */ + /* orig_r0, event, user_r25 skipped automatically */ .endm .macro RESTORE_ALL_INT2 @@ -565,7 +554,7 @@ RESTORE_R12_TO_R0 ld sp, [sp] /* restore original sp */ - /* orig_r0, orig_r8, user_r25 skipped automatically */ + /* orig_r0, event, user_r25 skipped automatically */ .endm diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index 7b2de6f7025a..e98b9c2c34e1 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -45,15 +45,7 @@ struct pt_regs { long orig_r0; /*to distinguish bet excp, syscall, irq */ - union { -#ifdef CONFIG_CPU_BIG_ENDIAN - /* so that assembly code is same for LE/BE */ - unsigned long orig_r8:16, event:16; -#else - unsigned long event:16, orig_r8:16; -#endif - long orig_r8_word; - }; + unsigned long event; long user_r25; }; @@ -94,11 +86,11 @@ struct callee_regs { /* return 1 if PC in delay slot */ #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK) -#define in_syscall(regs) (regs->event & orig_r8_IS_SCALL) -#define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT) +#define in_syscall(regs) (regs->event & event_SCALL) +#define in_brkpt_trap(regs) (regs->event & event_BRKPT) -#define syscall_wont_restart(regs) (regs->event |= orig_r8_IS_SCALL_RESTARTED) -#define syscall_restartable(regs) !(regs->event & orig_r8_IS_SCALL_RESTARTED) +#define syscall_wont_restart(regs) (regs->event |= event_SCALL_RESTARTED) +#define syscall_restartable(regs) !(regs->event & event_SCALL_RESTARTED) #define current_pt_regs() \ ({ \ @@ -115,11 +107,11 @@ static inline long regs_return_value(struct pt_regs *regs) #endif /* !__ASSEMBLY__ */ -#define orig_r8_IS_SCALL 0x0001 -#define orig_r8_IS_SCALL_RESTARTED 0x0002 -#define orig_r8_IS_BRKPT 0x0004 -#define orig_r8_IS_EXCPN 0x0008 -#define orig_r8_IS_IRQ1 0x0010 -#define orig_r8_IS_IRQ2 0x0020 +#define event_SCALL 0x0001 +#define event_SCALL_RESTARTED 0x0002 +#define event_BRKPT 0x0004 +#define event_EXCPN 0x0008 +#define event_IRQ1 0x0010 +#define event_IRQ2 0x0020 #endif /* __ASM_PTRACE_H */ diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h index 33ab3048e9b2..29de09804306 100644 --- a/arch/arc/include/asm/syscall.h +++ b/arch/arc/include/asm/syscall.h @@ -18,7 +18,7 @@ static inline long syscall_get_nr(struct task_struct *task, struct pt_regs *regs) { if (user_mode(regs) && in_syscall(regs)) - return regs->orig_r8; + return regs->r8; else return -1; } @@ -26,8 +26,7 @@ syscall_get_nr(struct task_struct *task, struct pt_regs *regs) static inline void syscall_rollback(struct task_struct *task, struct pt_regs *regs) { - /* XXX: I can't fathom how pt_regs->r8 will be clobbered ? */ - regs->r8 = regs->orig_r8; + regs->r0 = regs->orig_r0; } static inline long diff --git a/arch/arc/include/uapi/asm/ptrace.h b/arch/arc/include/uapi/asm/ptrace.h index 2052ae67aed4..286b466e13fa 100644 --- a/arch/arc/include/uapi/asm/ptrace.h +++ b/arch/arc/include/uapi/asm/ptrace.h @@ -41,7 +41,7 @@ struct user_regs_struct { long r19, r18, r17, r16, r15, r14, r13; } callee; long efa; /* break pt addr, for break points in delay slots */ - long stop_pc; /* give dbg stop_pc directly after checking orig_r8 */ + long stop_pc; /* give dbg stop_pc after ensuring a brkpt trap */ }; #endif /* !__ASSEMBLY__ */ diff --git a/arch/arc/kernel/asm-offsets.c b/arch/arc/kernel/asm-offsets.c index 75f05b83d77d..6c3aa0edb9b5 100644 --- a/arch/arc/kernel/asm-offsets.c +++ b/arch/arc/kernel/asm-offsets.c @@ -46,7 +46,7 @@ int main(void) BLANK(); DEFINE(PT_status32, offsetof(struct pt_regs, status32)); - DEFINE(PT_orig_r8, offsetof(struct pt_regs, orig_r8_word)); + DEFINE(PT_event, offsetof(struct pt_regs, event)); DEFINE(PT_sp, offsetof(struct pt_regs, sp)); DEFINE(PT_r0, offsetof(struct pt_regs, r0)); DEFINE(PT_r1, offsetof(struct pt_regs, r1)); diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index fd5f9160bbd2..18321241f07b 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -495,7 +495,7 @@ tracesys_exit: trap_with_param: ; stop_pc info by gdb needs this info - stw orig_r8_IS_BRKPT, [sp, PT_orig_r8] + st event_BRKPT, [sp, PT_event] mov r0, r12 lr r1, [efa] @@ -705,8 +705,8 @@ not_exception: ; things to what they were, before returning from L2 context ;---------------------------------------------------------------- - ldw r9, [sp, PT_orig_r8] ; get orig_r8 to make sure it is - brne r9, orig_r8_IS_IRQ2, 149f ; infact a L2 ISR ret path + ld r9, [sp, PT_event] ; Ensure L2 ISR ret path + brne r9, event_IRQ2, 149f ld r9, [sp, PT_status32] ; get statu32_l2 (saved in pt_regs) bbit0 r9, STATUS_A1_BIT, 149f ; L1 not active when L2 IRQ, so normal diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index a3cc6a577039..3e748f1b1f8a 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -76,7 +76,7 @@ asmlinkage void ret_from_fork(void); * ------------------ * | SP | * | orig_r0 | - * | orig_r8 | + * | event | * | user_r25 | * ------------------ <===== END of PAGE */ -- 2.39.5