File tree Expand file tree Collapse file tree 4 files changed +32
-30
lines changed Expand file tree Collapse file tree 4 files changed +32
-30
lines changed Original file line number Diff line number Diff line change 1212#define USER_ASID_FLAG (UL(1) << USER_ASID_BIT)
1313#define TTBR_ASID_MASK (UL(0xffff) << 48)
1414
15- #define BP_HARDEN_EL2_SLOTS 4
16- #define __BP_HARDEN_HYP_VECS_SZ (BP_HARDEN_EL2_SLOTS * SZ_2K)
17-
1815#ifndef __ASSEMBLY__
1916
2017#include <linux/refcount.h>
@@ -41,32 +38,6 @@ static inline bool arm64_kernel_unmapped_at_el0(void)
4138 return cpus_have_const_cap (ARM64_UNMAP_KERNEL_AT_EL0 );
4239}
4340
44- typedef void (* bp_hardening_cb_t )(void );
45-
46- struct bp_hardening_data {
47- int hyp_vectors_slot ;
48- bp_hardening_cb_t fn ;
49- };
50-
51- DECLARE_PER_CPU_READ_MOSTLY (struct bp_hardening_data , bp_hardening_data );
52-
53- static inline struct bp_hardening_data * arm64_get_bp_hardening_data (void )
54- {
55- return this_cpu_ptr (& bp_hardening_data );
56- }
57-
58- static inline void arm64_apply_bp_hardening (void )
59- {
60- struct bp_hardening_data * d ;
61-
62- if (!cpus_have_const_cap (ARM64_SPECTRE_V2 ))
63- return ;
64-
65- d = arm64_get_bp_hardening_data ();
66- if (d -> fn )
67- d -> fn ();
68- }
69-
7041extern void arm64_memblock_init (void );
7142extern void paging_init (void );
7243extern void bootmem_init (void );
Original file line number Diff line number Diff line change 99#ifndef __ASM_SPECTRE_H
1010#define __ASM_SPECTRE_H
1111
12+ #define BP_HARDEN_EL2_SLOTS 4
13+ #define __BP_HARDEN_HYP_VECS_SZ (BP_HARDEN_EL2_SLOTS * SZ_2K)
14+
15+ #ifndef __ASSEMBLY__
16+
17+ #include <linux/percpu.h>
18+
1219#include <asm/cpufeature.h>
20+ #include <asm/virt.h>
1321
1422/* Watch out, ordering is important here. */
1523enum mitigation_state {
@@ -20,6 +28,27 @@ enum mitigation_state {
2028
2129struct task_struct ;
2230
31+ typedef void (* bp_hardening_cb_t )(void );
32+
33+ struct bp_hardening_data {
34+ int hyp_vectors_slot ;
35+ bp_hardening_cb_t fn ;
36+ };
37+
38+ DECLARE_PER_CPU_READ_MOSTLY (struct bp_hardening_data , bp_hardening_data );
39+
40+ static inline void arm64_apply_bp_hardening (void )
41+ {
42+ struct bp_hardening_data * d ;
43+
44+ if (!cpus_have_const_cap (ARM64_SPECTRE_V2 ))
45+ return ;
46+
47+ d = this_cpu_ptr (& bp_hardening_data );
48+ if (d -> fn )
49+ d -> fn ();
50+ }
51+
2352enum mitigation_state arm64_get_spectre_v2_state (void );
2453bool has_spectre_v2 (const struct arm64_cpu_capabilities * cap , int scope );
2554void spectre_v2_enable_mitigation (const struct arm64_cpu_capabilities * __unused );
@@ -29,4 +58,5 @@ bool has_spectre_v4(const struct arm64_cpu_capabilities *cap, int scope);
2958void spectre_v4_enable_mitigation (const struct arm64_cpu_capabilities * __unused );
3059void spectre_v4_enable_task_mitigation (struct task_struct * tsk );
3160
61+ #endif /* __ASSEMBLY__ */
3262#endif /* __ASM_SPECTRE_H */
Original file line number Diff line number Diff line change @@ -1405,7 +1405,7 @@ static void cpu_hyp_reset(void)
14051405 */
14061406static void cpu_set_hyp_vector (void )
14071407{
1408- struct bp_hardening_data * data = arm64_get_bp_hardening_data ( );
1408+ struct bp_hardening_data * data = this_cpu_ptr ( & bp_hardening_data );
14091409 void * vect = kern_hyp_va (kvm_ksym_ref (__kvm_hyp_vector ));
14101410 int slot = -1 ;
14111411
Original file line number Diff line number Diff line change 1313#include <asm/kvm_arm.h>
1414#include <asm/kvm_asm.h>
1515#include <asm/mmu.h>
16+ #include <asm/spectre.h>
1617
1718.macro save_caller_saved_regs_vect
1819 / * x0 and x1 were saved in the vector entry * /
You can’t perform that action at this time.
0 commit comments