@@ -97,19 +97,26 @@ _save_context:
97
97
la gp, __global_pointer$
98
98
.option pop
99
99
100
- la ra, ret_from_exception
100
+ #ifdef CONFIG_TRACE_IRQFLAGS
101
+ call trace_hardirqs_off
102
+ #endif
101
103
/*
102
104
* MSB of cause differentiates between
103
105
* interrupts and exceptions
104
106
*/
105
107
bge s4 , zero, 1f
106
108
109
+ la ra, ret_from_exception
110
+
107
111
/* Handle interrupts */
108
112
move a0 , sp /* pt_regs */
109
113
la a1 , handle_arch_irq
110
114
REG_L a1 , (a1 )
111
115
jr a1
112
116
1 :
117
+ #ifdef CONFIG_TRACE_IRQFLAGS
118
+ call trace_hardirqs_on
119
+ #endif
113
120
/*
114
121
* Exceptions run with interrupts enabled or disabled depending on the
115
122
* state of SR_PIE in m/sstatus.
@@ -119,6 +126,7 @@ _save_context:
119
126
csrs CSR_STATUS, SR_IE
120
127
121
128
1 :
129
+ la ra, ret_from_exception
122
130
/* Handle syscalls */
123
131
li t0, EXC_SYSCALL
124
132
beq s4 , t0, handle_syscall
@@ -137,6 +145,17 @@ _save_context:
137
145
tail do_trap_unknown
138
146
139
147
handle_syscall:
148
+ #ifdef CONFIG_TRACE_IRQFLAGS
149
+ /* Recover a0 - a7 for system calls */
150
+ REG_L a0 , PT_A0(sp )
151
+ REG_L a1 , PT_A1(sp )
152
+ REG_L a2 , PT_A2(sp )
153
+ REG_L a3 , PT_A3(sp )
154
+ REG_L a4 , PT_A4(sp )
155
+ REG_L a5 , PT_A5(sp )
156
+ REG_L a6 , PT_A6(sp )
157
+ REG_L a7 , PT_A7(sp )
158
+ #endif
140
159
/* save the initial A0 value (needed in signal handlers) */
141
160
REG_S a0 , PT_ORIG_A0(sp )
142
161
/*
@@ -190,6 +209,9 @@ ret_from_syscall_rejected:
190
209
ret_from_exception:
191
210
REG_L s0, PT_STATUS(sp )
192
211
csrc CSR_STATUS, SR_IE
212
+ #ifdef CONFIG_TRACE_IRQFLAGS
213
+ call trace_hardirqs_off
214
+ #endif
193
215
#ifdef CONFIG_RISCV_M_MODE
194
216
/* the MPP value is too large to be used as an immediate arg for addi */
195
217
li t0, SR_MPP
@@ -216,6 +238,16 @@ resume_userspace:
216
238
csrw CSR_SCRATCH, tp
217
239
218
240
restore_all:
241
+ #ifdef CONFIG_TRACE_IRQFLAGS
242
+ REG_L s1, PT_STATUS(sp )
243
+ andi t0, s1, SR_PIE
244
+ beqz t0, 1f
245
+ call trace_hardirqs_on
246
+ j 2f
247
+ 1 :
248
+ call trace_hardirqs_off
249
+ 2 :
250
+ #endif
219
251
REG_L a0 , PT_STATUS(sp )
220
252
/*
221
253
* The current load reservation is effectively part of the processor's
0 commit comments