18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Interface for managing mitigations for Spectre vulnerabilities. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2020 Google LLC 68c2ecf20Sopenharmony_ci * Author: Will Deacon <will@kernel.org> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef __ASM_SPECTRE_H 108c2ecf20Sopenharmony_ci#define __ASM_SPECTRE_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <asm/cpufeature.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* Watch out, ordering is important here. */ 158c2ecf20Sopenharmony_cienum mitigation_state { 168c2ecf20Sopenharmony_ci SPECTRE_UNAFFECTED, 178c2ecf20Sopenharmony_ci SPECTRE_MITIGATED, 188c2ecf20Sopenharmony_ci SPECTRE_VULNERABLE, 198c2ecf20Sopenharmony_ci}; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistruct pt_regs; 228c2ecf20Sopenharmony_cistruct task_struct; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cienum mitigation_state arm64_get_spectre_v2_state(void); 258c2ecf20Sopenharmony_cibool has_spectre_v2(const struct arm64_cpu_capabilities *cap, int scope); 268c2ecf20Sopenharmony_civoid spectre_v2_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cienum mitigation_state arm64_get_spectre_v4_state(void); 298c2ecf20Sopenharmony_cibool has_spectre_v4(const struct arm64_cpu_capabilities *cap, int scope); 308c2ecf20Sopenharmony_civoid spectre_v4_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 318c2ecf20Sopenharmony_civoid spectre_v4_enable_task_mitigation(struct task_struct *tsk); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cienum mitigation_state arm64_get_spectre_bhb_state(void); 348c2ecf20Sopenharmony_cibool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope); 358c2ecf20Sopenharmony_ciu8 spectre_bhb_loop_affected(int scope); 368c2ecf20Sopenharmony_civoid spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *__unused); 378c2ecf20Sopenharmony_cibool try_emulate_el1_ssbs(struct pt_regs *regs, u32 instr); 388c2ecf20Sopenharmony_ci#endif /* __ASM_SPECTRE_H */ 39