2021-06-09 01:56:02 +00:00
|
|
|
#!/bin/sh -e
|
2019-12-12 17:25:28 +00:00
|
|
|
|
2021-04-28 12:10:30 +00:00
|
|
|
MSR_FILE=/sys/module/msr/parameters/allow_writes
|
2019-12-12 17:25:28 +00:00
|
|
|
|
2021-04-28 12:10:30 +00:00
|
|
|
if test -e "$MSR_FILE"; then
|
|
|
|
echo on > $MSR_FILE
|
|
|
|
else
|
|
|
|
modprobe msr allow_writes=on
|
|
|
|
fi
|
|
|
|
|
2024-08-29 12:47:30 +00:00
|
|
|
if grep -E 'AMD Ryzen|AMD EPYC|AuthenticAMD' /proc/cpuinfo > /dev/null;
|
2019-12-12 17:25:28 +00:00
|
|
|
then
|
2022-10-09 19:55:30 +00:00
|
|
|
if grep "cpu family[[:space:]]\{1,\}:[[:space:]]25" /proc/cpuinfo > /dev/null;
|
2020-11-12 14:55:27 +00:00
|
|
|
then
|
2022-10-09 19:55:30 +00:00
|
|
|
if grep "model[[:space:]]\{1,\}:[[:space:]]97" /proc/cpuinfo > /dev/null;
|
|
|
|
then
|
|
|
|
echo "Detected Zen4 CPU"
|
|
|
|
wrmsr -a 0xc0011020 0x4400000000000
|
|
|
|
wrmsr -a 0xc0011021 0x4000000000040
|
|
|
|
wrmsr -a 0xc0011022 0x8680000401570000
|
|
|
|
wrmsr -a 0xc001102b 0x2040cc10
|
|
|
|
echo "MSR register values for Zen4 applied"
|
|
|
|
else
|
|
|
|
echo "Detected Zen3 CPU"
|
|
|
|
wrmsr -a 0xc0011020 0x4480000000000
|
|
|
|
wrmsr -a 0xc0011021 0x1c000200000040
|
2022-11-17 22:24:28 +00:00
|
|
|
wrmsr -a 0xc0011022 0xc000000401570000
|
|
|
|
wrmsr -a 0xc001102b 0x2000cc10
|
2022-10-09 19:55:30 +00:00
|
|
|
echo "MSR register values for Zen3 applied"
|
|
|
|
fi
|
2024-08-28 11:49:27 +00:00
|
|
|
elif grep "cpu family[[:space:]]\{1,\}:[[:space:]]26" /proc/cpuinfo > /dev/null;
|
|
|
|
then
|
|
|
|
echo "Detected Zen5 CPU"
|
|
|
|
wrmsr -a 0xc0011020 0x4400000000000
|
|
|
|
wrmsr -a 0xc0011021 0x4000000000040
|
|
|
|
wrmsr -a 0xc0011022 0x8680000401570000
|
|
|
|
wrmsr -a 0xc001102b 0x2040cc10
|
|
|
|
echo "MSR register values for Zen5 applied"
|
2020-11-12 14:55:27 +00:00
|
|
|
else
|
2021-04-28 12:10:30 +00:00
|
|
|
echo "Detected Zen1/Zen2 CPU"
|
2020-11-12 14:55:27 +00:00
|
|
|
wrmsr -a 0xc0011020 0
|
|
|
|
wrmsr -a 0xc0011021 0x40
|
|
|
|
wrmsr -a 0xc0011022 0x1510000
|
|
|
|
wrmsr -a 0xc001102b 0x2000cc16
|
2021-04-28 12:10:30 +00:00
|
|
|
echo "MSR register values for Zen1/Zen2 applied"
|
2020-11-12 14:55:27 +00:00
|
|
|
fi
|
2021-06-09 01:56:02 +00:00
|
|
|
elif grep "Intel" /proc/cpuinfo > /dev/null;
|
2019-12-12 17:25:28 +00:00
|
|
|
then
|
2021-04-28 12:10:30 +00:00
|
|
|
echo "Detected Intel CPU"
|
2020-01-12 02:42:48 +00:00
|
|
|
wrmsr -a 0x1a4 0xf
|
2019-12-12 17:25:28 +00:00
|
|
|
echo "MSR register values for Intel applied"
|
|
|
|
else
|
|
|
|
echo "No supported CPU detected"
|
|
|
|
fi
|