From fa66ea10334dff6e1e9c732a0b2890ec257533af Mon Sep 17 00:00:00 2001 From: erpalma Date: Fri, 19 Mar 2021 19:22:06 +0100 Subject: [PATCH] handle EIO errno when reading/writing MSRs (fix #242) --- lenovo_fix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lenovo_fix.py b/lenovo_fix.py index dac6cbd..bbfda9c 100755 --- a/lenovo_fix.py +++ b/lenovo_fix.py @@ -12,7 +12,7 @@ import subprocess import sys from collections import defaultdict from datetime import datetime -from errno import EACCES, EPERM +from errno import EACCES, EIO, EPERM from multiprocessing import cpu_count from platform import uname from threading import Event, Thread @@ -226,6 +226,8 @@ def writemsr(msr, val): 'Unable to write to MSR. Try to disable Secure Boot ' 'and check if your kernel does not restrict access to MSR.' ) + elif e.errno == EIO: + fatal('Unable to write to MSR. Unknown error.') else: raise e @@ -257,6 +259,8 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False): except (IOError, OSError) as e: if e.errno == EPERM or e.errno == EACCES: fatal('Unable to read from MSR. Try to disable Secure Boot.') + elif e.errno == EIO: + fatal('Unable to read to MSR. Unknown error.') else: raise e