mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 15:15:47 +00:00
arm64: proton-pack: Report Spectre-BHB vulnerabilities as part of Spectre-v2
commit dee435be76
upstream.
Speculation attacks against some high-performance processors can
make use of branch history to influence future speculation as part of
a spectre-v2 attack. This is not mitigated by CSV2, meaning CPUs that
previously reported 'Not affected' are now moderately mitigated by CSV2.
Update the value in /sys/devices/system/cpu/vulnerabilities/spectre_v2
to also show the state of the BHB mitigation.
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d7066114dc
commit
8e55b9b0e7
2 changed files with 36 additions and 2 deletions
|
@ -93,5 +93,7 @@ void spectre_v4_enable_task_mitigation(struct task_struct *tsk);
|
||||||
|
|
||||||
enum mitigation_state arm64_get_meltdown_state(void);
|
enum mitigation_state arm64_get_meltdown_state(void);
|
||||||
|
|
||||||
|
enum mitigation_state arm64_get_spectre_bhb_state(void);
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __ASM_SPECTRE_H */
|
#endif /* __ASM_SPECTRE_H */
|
||||||
|
|
|
@ -96,14 +96,39 @@ static bool spectre_v2_mitigations_off(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *get_bhb_affected_string(enum mitigation_state bhb_state)
|
||||||
|
{
|
||||||
|
switch (bhb_state) {
|
||||||
|
case SPECTRE_UNAFFECTED:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
case SPECTRE_VULNERABLE:
|
||||||
|
return ", but not BHB";
|
||||||
|
case SPECTRE_MITIGATED:
|
||||||
|
return ", BHB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr,
|
ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
|
enum mitigation_state bhb_state = arm64_get_spectre_bhb_state();
|
||||||
|
const char *bhb_str = get_bhb_affected_string(bhb_state);
|
||||||
|
const char *v2_str = "Branch predictor hardening";
|
||||||
|
|
||||||
switch (spectre_v2_state) {
|
switch (spectre_v2_state) {
|
||||||
case SPECTRE_UNAFFECTED:
|
case SPECTRE_UNAFFECTED:
|
||||||
return sprintf(buf, "Not affected\n");
|
if (bhb_state == SPECTRE_UNAFFECTED)
|
||||||
|
return sprintf(buf, "Not affected\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platforms affected by Spectre-BHB can't report
|
||||||
|
* "Not affected" for Spectre-v2.
|
||||||
|
*/
|
||||||
|
v2_str = "CSV2";
|
||||||
|
fallthrough;
|
||||||
case SPECTRE_MITIGATED:
|
case SPECTRE_MITIGATED:
|
||||||
return sprintf(buf, "Mitigation: Branch predictor hardening\n");
|
return sprintf(buf, "Mitigation: %s%s\n", v2_str, bhb_str);
|
||||||
case SPECTRE_VULNERABLE:
|
case SPECTRE_VULNERABLE:
|
||||||
fallthrough;
|
fallthrough;
|
||||||
default:
|
default:
|
||||||
|
@ -771,6 +796,13 @@ int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum mitigation_state spectre_bhb_state;
|
||||||
|
|
||||||
|
enum mitigation_state arm64_get_spectre_bhb_state(void)
|
||||||
|
{
|
||||||
|
return spectre_bhb_state;
|
||||||
|
}
|
||||||
|
|
||||||
/* Patched to NOP when enabled */
|
/* Patched to NOP when enabled */
|
||||||
void noinstr spectre_bhb_patch_loop_mitigation_enable(struct alt_instr *alt,
|
void noinstr spectre_bhb_patch_loop_mitigation_enable(struct alt_instr *alt,
|
||||||
__le32 *origptr,
|
__le32 *origptr,
|
||||||
|
|
Loading…
Reference in a new issue