Skip to content

Commit 58d9ceb

Browse files
committed
ARC: pt_regs: create seperate type for ecr
Reduces duplication in each ISA specific pt_regs Tested-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected] Signed-off-by: Vineet Gupta <[email protected]>
1 parent d4624bf commit 58d9ceb

File tree

7 files changed

+33
-45
lines changed

7 files changed

+33
-45
lines changed

arch/arc/include/asm/ptrace.h

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212

1313
#ifndef __ASSEMBLY__
1414

15+
typedef union {
16+
struct {
17+
#ifdef CONFIG_CPU_BIG_ENDIAN
18+
unsigned long state:8, vec:8, cause:8, param:8;
19+
#else
20+
unsigned long param:8, cause:8, vec:8, state:8;
21+
#endif
22+
};
23+
unsigned long full;
24+
} ecr_reg;
25+
1526
/* THE pt_regs: Defines how regs are saved during entry into kernel */
1627

1728
#ifdef CONFIG_ISA_ARCOMPACT
@@ -40,40 +51,18 @@ struct pt_regs {
4051
* Last word used by Linux for extra state mgmt (syscall-restart)
4152
* For interrupts, use artificial ECR values to note current prio-level
4253
*/
43-
union {
44-
struct {
45-
#ifdef CONFIG_CPU_BIG_ENDIAN
46-
unsigned long state:8, ecr_vec:8,
47-
ecr_cause:8, ecr_param:8;
48-
#else
49-
unsigned long ecr_param:8, ecr_cause:8,
50-
ecr_vec:8, state:8;
51-
#endif
52-
};
53-
unsigned long event;
54-
};
54+
ecr_reg ecr;
5555
};
5656

57-
#define MAX_REG_OFFSET offsetof(struct pt_regs, event)
57+
#define MAX_REG_OFFSET offsetof(struct pt_regs, ecr)
5858

5959
#else
6060

6161
struct pt_regs {
6262

6363
unsigned long orig_r0;
6464

65-
union {
66-
struct {
67-
#ifdef CONFIG_CPU_BIG_ENDIAN
68-
unsigned long state:8, ecr_vec:8,
69-
ecr_cause:8, ecr_param:8;
70-
#else
71-
unsigned long ecr_param:8, ecr_cause:8,
72-
ecr_vec:8, state:8;
73-
#endif
74-
};
75-
unsigned long event;
76-
};
65+
ecr_reg ecr; /* Exception Cause Reg */
7766

7867
unsigned long bta; /* erbta */
7968

@@ -131,13 +120,13 @@ struct callee_regs {
131120
/* return 1 if PC in delay slot */
132121
#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
133122

134-
#define in_syscall(regs) ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
135-
#define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
123+
#define in_syscall(regs) ((regs->ecr.vec == ECR_V_TRAP) && !regs->ecr.param)
124+
#define in_brkpt_trap(regs) ((regs->ecr.vec == ECR_V_TRAP) && regs->ecr.param)
136125

137126
#define STATE_SCALL_RESTARTED 0x01
138127

139-
#define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
140-
#define syscall_restartable(reg) !(reg->state & STATE_SCALL_RESTARTED)
128+
#define syscall_wont_restart(regs) (regs->ecr.state |= STATE_SCALL_RESTARTED)
129+
#define syscall_restartable(regs) !(regs->ecr.state & STATE_SCALL_RESTARTED)
141130

142131
#define current_pt_regs() \
143132
({ \

arch/arc/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(void)
4646
BLANK();
4747

4848
DEFINE(PT_status32, offsetof(struct pt_regs, status32));
49-
DEFINE(PT_event, offsetof(struct pt_regs, event));
49+
DEFINE(PT_event, offsetof(struct pt_regs, ecr));
5050
DEFINE(PT_bta, offsetof(struct pt_regs, bta));
5151
DEFINE(PT_sp, offsetof(struct pt_regs, sp));
5252
DEFINE(PT_r0, offsetof(struct pt_regs, r0));

arch/arc/kernel/kgdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void kgdb_trap(struct pt_regs *regs)
175175
* with trap_s 4 (compiled) breakpoints, continuation needs to
176176
* start after the breakpoint.
177177
*/
178-
if (regs->ecr_param == 3)
178+
if (regs->ecr.param == 3)
179179
instruction_pointer(regs) -= BREAK_INSTR_SIZE;
180180

181181
kgdb_handle_exception(1, SIGTRAP, 0, regs);

arch/arc/kernel/ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ static const struct pt_regs_offset regoffset_table[] = {
4646
REG_OFFSET_NAME(r0),
4747
REG_OFFSET_NAME(sp),
4848
REG_OFFSET_NAME(orig_r0),
49-
REG_OFFSET_NAME(event),
49+
REG_OFFSET_NAME(ecr),
5050
REG_OFFSET_END,
5151
};
5252

5353
#else
5454

5555
static const struct pt_regs_offset regoffset_table[] = {
5656
REG_OFFSET_NAME(orig_r0),
57-
REG_OFFSET_NAME(event),
57+
REG_OFFSET_NAME(ecr),
5858
REG_OFFSET_NAME(bta),
5959
REG_OFFSET_NAME(r26),
6060
REG_OFFSET_NAME(fp),

arch/arc/kernel/traps.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
110110
*/
111111
void do_non_swi_trap(unsigned long address, struct pt_regs *regs)
112112
{
113-
unsigned int param = regs->ecr_param;
114-
115-
switch (param) {
113+
switch (regs->ecr.param) {
116114
case 1:
117115
trap_is_brkpt(address, regs);
118116
break;

arch/arc/kernel/troubleshoot.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static void show_ecr_verbose(struct pt_regs *regs)
115115
/* For Data fault, this is data address not instruction addr */
116116
address = current->thread.fault_address;
117117

118-
vec = regs->ecr_vec;
119-
cause_code = regs->ecr_cause;
118+
vec = regs->ecr.vec;
119+
cause_code = regs->ecr.cause;
120120

121121
/* For DTLB Miss or ProtV, display the memory involved too */
122122
if (vec == ECR_V_DTLB_MISS) {
@@ -154,7 +154,7 @@ static void show_ecr_verbose(struct pt_regs *regs)
154154
pr_cont("Misaligned r/w from 0x%08lx\n", address);
155155
#endif
156156
} else if (vec == ECR_V_TRAP) {
157-
if (regs->ecr_param == 5)
157+
if (regs->ecr.param == 5)
158158
pr_cont("gcc generated __builtin_trap\n");
159159
} else {
160160
pr_cont("Check Programmer's Manual\n");
@@ -184,9 +184,10 @@ void show_regs(struct pt_regs *regs)
184184
if (user_mode(regs))
185185
show_faulting_vma(regs->ret); /* faulting code, not data */
186186

187-
pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\nSTAT: 0x%08lx",
188-
regs->event, current->thread.fault_address, regs->ret,
189-
regs->status32);
187+
pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\n",
188+
regs->ecr.full, current->thread.fault_address, regs->ret);
189+
190+
pr_info("STAT32: 0x%08lx", regs->status32);
190191

191192
#define STS_BIT(r, bit) r->status32 & STATUS_##bit##_MASK ? #bit" " : ""
192193

arch/arc/mm/fault.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
100100
if (faulthandler_disabled() || !mm)
101101
goto no_context;
102102

103-
if (regs->ecr_cause & ECR_C_PROTV_STORE) /* ST/EX */
103+
if (regs->ecr.cause & ECR_C_PROTV_STORE) /* ST/EX */
104104
write = 1;
105-
else if ((regs->ecr_vec == ECR_V_PROTV) &&
106-
(regs->ecr_cause == ECR_C_PROTV_INST_FETCH))
105+
else if ((regs->ecr.vec == ECR_V_PROTV) &&
106+
(regs->ecr.cause == ECR_C_PROTV_INST_FETCH))
107107
exec = 1;
108108

109109
flags = FAULT_FLAG_DEFAULT;

0 commit comments

Comments
 (0)