File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 13
13
XIP_FIXUP_OFFSET gp
14
14
.endm
15
15
16
+ /* Load the per-CPU IRQ shadow call stack to gp. */
17
+ .macro scs_load_irq_stack tmp
18
+ load_per_cpu gp , irq_shadow_call_stack_ptr , \tmp
19
+ .endm
20
+
16
21
/* Load task_scs_sp(current) to gp. */
17
22
.macro scs_load_current
18
23
REG_L gp , TASK_TI_SCS_SP (tp )
34
39
35
40
.macro scs_load_init_stack
36
41
.endm
42
+ .macro scs_load_irq_stack tmp
43
+ .endm
37
44
.macro scs_load_current
38
45
.endm
39
46
.macro scs_load_current_if_task_changed prev
Original file line number Diff line number Diff line change @@ -237,12 +237,19 @@ SYM_FUNC_START(call_on_irq_stack)
237
237
REG_S s0, STACKFRAME_FP(sp )
238
238
addi s0, sp , STACKFRAME_SIZE_ON_STACK
239
239
240
+ /* Switch to the per-CPU shadow call stack */
241
+ scs_save_current
242
+ scs_load_irq_stack t0
243
+
240
244
/* Switch to the per-CPU IRQ stack and call the handler */
241
245
load_per_cpu t0, irq_stack_ptr, t1
242
246
li t1, IRQ_STACK_SIZE
243
247
add sp , t0, t1
244
248
jalr a1
245
249
250
+ /* Switch back to the thread shadow call stack */
251
+ scs_load_current
252
+
246
253
/* Switch back to the thread stack and restore ra and s0 */
247
254
addi sp , s0, -STACKFRAME_SIZE_ON_STACK
248
255
REG_L ra, STACKFRAME_RA(sp )
Original file line number Diff line number Diff line change 9
9
#include <linux/irqchip.h>
10
10
#include <linux/irqdomain.h>
11
11
#include <linux/module.h>
12
+ #include <linux/scs.h>
12
13
#include <linux/seq_file.h>
13
14
#include <asm/sbi.h>
14
15
#include <asm/smp.h>
@@ -34,6 +35,24 @@ EXPORT_SYMBOL_GPL(riscv_get_intc_hwnode);
34
35
#ifdef CONFIG_IRQ_STACKS
35
36
#include <asm/irq_stack.h>
36
37
38
+ DECLARE_PER_CPU (ulong * , irq_shadow_call_stack_ptr );
39
+
40
+ #ifdef CONFIG_SHADOW_CALL_STACK
41
+ DEFINE_PER_CPU (ulong * , irq_shadow_call_stack_ptr );
42
+ #endif
43
+
44
+ static void init_irq_scs (void )
45
+ {
46
+ int cpu ;
47
+
48
+ if (!scs_is_enabled ())
49
+ return ;
50
+
51
+ for_each_possible_cpu (cpu )
52
+ per_cpu (irq_shadow_call_stack_ptr , cpu ) =
53
+ scs_alloc (cpu_to_node (cpu ));
54
+ }
55
+
37
56
DEFINE_PER_CPU (ulong * , irq_stack_ptr );
38
57
39
58
#ifdef CONFIG_VMAP_STACK
@@ -76,6 +95,7 @@ void do_softirq_own_stack(void)
76
95
#endif /* CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK */
77
96
78
97
#else
98
+ static void init_irq_scs (void ) {}
79
99
static void init_irq_stacks (void ) {}
80
100
#endif /* CONFIG_IRQ_STACKS */
81
101
@@ -87,6 +107,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
87
107
88
108
void __init init_IRQ (void )
89
109
{
110
+ init_irq_scs ();
90
111
init_irq_stacks ();
91
112
irqchip_init ();
92
113
if (!handle_arch_irq )
You can’t perform that action at this time.
0 commit comments