Skip to content

Instantly share code, notes, and snippets.

@samcv samcv/ryzen-msr.sh
Created Oct 15, 2018

Embed
What would you like to do?
#!/usr/bin/env bash
# based on https://lists.freebsd.org/pipermail/freebsd-current/2018-June/069799.html
get_value () {
location="$1"
cpu="$2"
rdmsr --processor "$cpu" --decimal "$location" || exit "$?"
}
write_value () {
location="$1"
value="$2"
cpu="$3"
wrmsr --processor "$cpu" "$location" "$value" || exit "$?"
}
apply_fix () {
location="$1"
to_or="$2"
fix_no="$3"
exit_code=0
for i in `seq 0 $(($(nproc)-1))`; do
cpu="$i"
current_value=$(get_value $location $cpu)
new_value=$(("$current_value" | "$to_or"))
write_value "$location" "$new_value" "$cpu"
if [[ $(get_value $location $cpu) != $new_value ]]; then
printf "May not have been set for fix %i Wrote value %X but value is now at %X\n" "$fix_no" $new_value $(get_value $location $cpu)
fi
done
}
## Comments are the errata numbers
# 1021
apply_fix 0xc0011029 0x2000 1021
# 1033
apply_fix 0xc0011020 0x10 1033
# 1049
apply_fix 0xc0011028 0x10 1049
# 1095
apply_fix 0xc0011020 0x200000000000000 1095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.