1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Interface for managing mitigations for Spectre vulnerabilities. 4 * 5 * Copyright (C) 2020 Google LLC 6 * Author: Will Deacon <will@kernel.org> 7 */ 8 9 #ifndef __ASM_SPECTRE_H 10 #define __ASM_SPECTRE_H 11 12 #include <asm/cpufeature.h> 13 14 /* Watch out, ordering is important here. */ 15 enum mitigation_state { 16 SPECTRE_UNAFFECTED, 17 SPECTRE_MITIGATED, 18 SPECTRE_VULNERABLE, 19 }; 20 21 struct pt_regs; 22 struct task_struct; 23 24 enum mitigation_state arm64_get_spectre_v2_state(void); 25 bool has_spectre_v2(const struct arm64_cpu_capabilities *cap, int scope); 26 void spectre_v2_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 27 28 enum mitigation_state arm64_get_spectre_v4_state(void); 29 bool has_spectre_v4(const struct arm64_cpu_capabilities *cap, int scope); 30 void spectre_v4_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 31 void spectre_v4_enable_task_mitigation(struct task_struct *tsk); 32 33 enum mitigation_state arm64_get_spectre_bhb_state(void); 34 bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope); 35 u8 spectre_bhb_loop_affected(int scope); 36 void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 37 bool try_emulate_el1_ssbs(struct pt_regs *regs, u32 instr); 38 #endif /* __ASM_SPECTRE_H */ 39