Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
66 lines
2.3 KiB
Python
Executable File
66 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Copyright (c) 2025 Intel Corporation
|
|
#
|
|
# Test for Indirect Target Selection(ITS) mitigation sysfs status.
|
|
|
|
import sys, os, re
|
|
this_dir = os.path.dirname(os.path.realpath(__file__))
|
|
sys.path.insert(0, this_dir + '/../../kselftest')
|
|
import ksft
|
|
|
|
from common import *
|
|
|
|
bug = "indirect_target_selection"
|
|
mitigation = get_sysfs(bug)
|
|
|
|
ITS_MITIGATION_ALIGNED_THUNKS = "Mitigation: Aligned branch/return thunks"
|
|
ITS_MITIGATION_RETPOLINE_STUFF = "Mitigation: Retpolines, Stuffing RSB"
|
|
ITS_MITIGATION_VMEXIT_ONLY = "Mitigation: Vulnerable, KVM: Not affected"
|
|
ITS_MITIGATION_VULNERABLE = "Vulnerable"
|
|
|
|
def check_mitigation():
|
|
if mitigation == ITS_MITIGATION_ALIGNED_THUNKS:
|
|
if cmdline_has(f'{bug}=stuff') and sysfs_has("spectre_v2", "Retpolines"):
|
|
bug_check_fail(bug, ITS_MITIGATION_ALIGNED_THUNKS, ITS_MITIGATION_RETPOLINE_STUFF)
|
|
return
|
|
if cmdline_has(f'{bug}=vmexit') and cpuinfo_has('its_native_only'):
|
|
bug_check_fail(bug, ITS_MITIGATION_ALIGNED_THUNKS, ITS_MITIGATION_VMEXIT_ONLY)
|
|
return
|
|
bug_check_pass(bug, ITS_MITIGATION_ALIGNED_THUNKS)
|
|
return
|
|
|
|
if mitigation == ITS_MITIGATION_RETPOLINE_STUFF:
|
|
if cmdline_has(f'{bug}=stuff') and sysfs_has("spectre_v2", "Retpolines"):
|
|
bug_check_pass(bug, ITS_MITIGATION_RETPOLINE_STUFF)
|
|
return
|
|
if sysfs_has('retbleed', 'Stuffing'):
|
|
bug_check_pass(bug, ITS_MITIGATION_RETPOLINE_STUFF)
|
|
return
|
|
bug_check_fail(bug, ITS_MITIGATION_RETPOLINE_STUFF, ITS_MITIGATION_ALIGNED_THUNKS)
|
|
|
|
if mitigation == ITS_MITIGATION_VMEXIT_ONLY:
|
|
if cmdline_has(f'{bug}=vmexit') and cpuinfo_has('its_native_only'):
|
|
bug_check_pass(bug, ITS_MITIGATION_VMEXIT_ONLY)
|
|
return
|
|
bug_check_fail(bug, ITS_MITIGATION_VMEXIT_ONLY, ITS_MITIGATION_ALIGNED_THUNKS)
|
|
|
|
if mitigation == ITS_MITIGATION_VULNERABLE:
|
|
if sysfs_has("spectre_v2", "Vulnerable"):
|
|
bug_check_pass(bug, ITS_MITIGATION_VULNERABLE)
|
|
else:
|
|
bug_check_fail(bug, "Mitigation", ITS_MITIGATION_VULNERABLE)
|
|
|
|
bug_status_unknown(bug, mitigation)
|
|
return
|
|
|
|
ksft.print_header()
|
|
ksft.set_plan(1)
|
|
ksft.print_msg(f'{bug}: {mitigation} ...')
|
|
|
|
if not basic_checks_sufficient(bug, mitigation):
|
|
check_mitigation()
|
|
|
|
ksft.finished()
|