Skip to content

Commit e7956c9

Browse files
author
James Morse
committed
arm64: proton-pack: Expose whether the platform is mitigated by firmware
is_spectre_bhb_fw_affected() allows the caller to determine if the CPU is known to need a firmware mitigation. CPUs are either on the list of CPUs we know about, or firmware has been queried and reported that the platform is affected - and mitigated by firmware. This helper is not useful to determine if the platform is mitigated by firmware. A CPU could be on the know list, but the firmware may not be implemented. Its affected but not mitigated. spectre_bhb_enable_mitigation() handles this distinction by checking the firmware state before enabling the mitigation. Add a helper to expose this state. This will be used by the BPF JIT to determine if calling firmware for a mitigation is necessary and supported. Signed-off-by: James Morse <[email protected]> Reviewed-by: Catalin Marinas <[email protected]>
1 parent 63de8ab commit e7956c9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

arch/arm64/include/asm/spectre.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ enum mitigation_state arm64_get_meltdown_state(void);
9797

9898
enum mitigation_state arm64_get_spectre_bhb_state(void);
9999
bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope);
100+
bool is_spectre_bhb_fw_mitigated(void);
100101
void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *__unused);
101102
bool try_emulate_el1_ssbs(struct pt_regs *regs, u32 instr);
102103

arch/arm64/kernel/proton-pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,11 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)
10941094
update_mitigation_state(&spectre_bhb_state, state);
10951095
}
10961096

1097+
bool is_spectre_bhb_fw_mitigated(void)
1098+
{
1099+
return test_bit(BHB_FW, &system_bhb_mitigations);
1100+
}
1101+
10971102
/* Patched to NOP when enabled */
10981103
void noinstr spectre_bhb_patch_loop_mitigation_enable(struct alt_instr *alt,
10991104
__le32 *origptr,

0 commit comments

Comments
 (0)