|
36 | 36 |
|
37 | 37 | #ifdef CONFIG_X86_FRED |
38 | 38 | #include <linux/kernel.h> |
| 39 | +#include <linux/sched/task_stack.h> |
39 | 40 |
|
40 | 41 | #include <asm/ptrace.h> |
41 | 42 |
|
@@ -87,12 +88,30 @@ void cpu_init_fred_exceptions(void); |
87 | 88 | void cpu_init_fred_rsps(void); |
88 | 89 | void fred_complete_exception_setup(void); |
89 | 90 |
|
| 91 | +DECLARE_PER_CPU(unsigned long, fred_rsp0); |
| 92 | + |
| 93 | +static __always_inline void fred_sync_rsp0(unsigned long rsp0) |
| 94 | +{ |
| 95 | + __this_cpu_write(fred_rsp0, rsp0); |
| 96 | +} |
| 97 | + |
| 98 | +static __always_inline void fred_update_rsp0(void) |
| 99 | +{ |
| 100 | + unsigned long rsp0 = (unsigned long) task_stack_page(current) + THREAD_SIZE; |
| 101 | + |
| 102 | + if (cpu_feature_enabled(X86_FEATURE_FRED) && (__this_cpu_read(fred_rsp0) != rsp0)) { |
| 103 | + wrmsrns(MSR_IA32_FRED_RSP0, rsp0); |
| 104 | + __this_cpu_write(fred_rsp0, rsp0); |
| 105 | + } |
| 106 | +} |
90 | 107 | #else /* CONFIG_X86_FRED */ |
91 | 108 | static __always_inline unsigned long fred_event_data(struct pt_regs *regs) { return 0; } |
92 | 109 | static inline void cpu_init_fred_exceptions(void) { } |
93 | 110 | static inline void cpu_init_fred_rsps(void) { } |
94 | 111 | static inline void fred_complete_exception_setup(void) { } |
95 | | -static __always_inline void fred_entry_from_kvm(unsigned int type, unsigned int vector) { } |
| 112 | +static inline void fred_entry_from_kvm(unsigned int type, unsigned int vector) { } |
| 113 | +static inline void fred_sync_rsp0(unsigned long rsp0) { } |
| 114 | +static inline void fred_update_rsp0(void) { } |
96 | 115 | #endif /* CONFIG_X86_FRED */ |
97 | 116 | #endif /* !__ASSEMBLY__ */ |
98 | 117 |
|
|
0 commit comments