SMT: Apply settings according to configuration
[ipfire-2.x.git] / src / initscripts / system / smt
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/smt
4 ########################################################################
5
6 . /etc/sysconfig/rc
7 . ${rc_functions}
8
9 eval $(/usr/local/bin/readhash /var/ipfire/main/security)
10
11 case "${1}" in
12         start)
13                 # Nothing to do here when SMT is forced on
14                 if [ "${ENABLE_SMT}" = "on" ]; then
15                         exit 0
16                 fi
17
18                 # Nothing to do if this processor is not vulnerable
19                 # to Fallout/RIDL.
20                 if [ -r "/sys/devices/system/cpu/vulnerabilities/mds" ]; then
21                         if [ "$(</sys/devices/system/cpu/vulnerabilities/mds)" = "Not affected" ]; then
22                                 exit 0
23                         fi
24
25                         # Disable SMT when supported and enabled
26                         if [ "$(</sys/devices/system/cpu/smt/control)" = "on" ]; then
27                                 boot_mesg "Disabling Simultaneous Multi-Threading (SMT)..."
28                                 echo "forceoff" > /sys/devices/system/cpu/smt/control
29                                 echo_ok
30                         fi
31                 fi
32                 ;;
33
34         *)
35                 echo "Usage: ${0} {start}"
36                 exit 1
37                 ;;
38 esac
39
40 # End $rc_base/init.d/smt