Skip to content

Instantly share code, notes, and snippets.

@catwith1hat
Created February 27, 2024 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catwith1hat/d2482d937a38947f4457dbceb6424c33 to your computer and use it in GitHub Desktop.
Save catwith1hat/d2482d937a38947f4457dbceb6424c33 to your computer and use it in GitHub Desktop.
$ cat msr-fix.sh
#!/bin/sh
bit_setter() {
  ORIG=$(rdmsr $1)
  if [ "$?" -ne 0 ]; then
    return
  fi
  decimal_value=$((16#${ORIG}))
  modified_decimal_value=$((decimal_value | $((1 << $2))))
  NEW=$(printf "%08x" ${modified_decimal_value})
  OLD=$(printf "%08x" ${decimal_value})
  echo "$1: $OLD"
  echo " -> $NEW"
  wrmsr -a "$1" 0x${NEW}
}
bit_setter 0x194 20; bit_setter 0x0E2 15; bit_setter 0x1A2 31; bit_setter 0x1AA 13; bit_setter 0x1FC 23; 
bit_setter 0x601 31; bit_setter 0x618 63; bit_setter 0x61C 63; bit_setter 0x638 31; bit_setter 0x648 31; 
bit_setter 0x64C 31; bit_setter 0x65C 63; bit_setter 0x665 63; bit_setter 0x1A0 20
$ ./msr-fix.sh
0x194: 00110000
-> 00110000
0x0E2: 1e008000
-> 1e008000
0x1A2: 00641200
-> 80641200
0x1AA: 00401cc0
-> 00403cc0
wrmsr: CPU 5 cannot set MSR 0x000001aa to 0x0000000000403cc0
0x1FC: 0038005d
-> 00b8005d
0x601: 00000000
-> 80000000
0x618: 00000000
-> 8000000000000000
rdmsr: CPU 0 cannot read MSR 0x0000061c
0x638: 00000000
-> 80000000
0x648: 0000001c
-> 8000001c
wrmsr: CPU 5 cannot set MSR 0x00000648 to 0x000000008000001c
0x64C: 00000000
-> 80000000
0x65C: 00140208
-> 8000000000140208
rdmsr: CPU 0 cannot read MSR 0x00000665
0x1A0: 4000850089
-> 4000950089
wrmsr: CPU 5 cannot set MSR 0x000001a0 to 0x0000004000950089
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment