From 1f4f5525e22947d0371ad2c6d999e40a32a66d6f Mon Sep 17 00:00:00 2001 From: Francesco Palmarini Date: Mon, 10 May 2021 20:46:45 +0200 Subject: [PATCH] Fix MSR string to int conversion in fatal method call in writemsr and readmsr (fix #252) --- lenovo_fix.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lenovo_fix.py b/lenovo_fix.py index 59093d9..acb0cdd 100755 --- a/lenovo_fix.py +++ b/lenovo_fix.py @@ -223,11 +223,11 @@ def writemsr(msr, val): except (IOError, OSError) as e: if e.errno == EPERM or e.errno == EACCES: fatal( - 'Unable to write to MSR {:x}. Try to disable Secure Boot ' - 'and check if your kernel does not restrict access to MSR.'.format(msr) + 'Unable to write to MSR {} ({:x}). Try to disable Secure Boot ' + 'and check if your kernel does not restrict access to MSR.'.format(msr, MSR_DICT[msr]) ) elif e.errno == EIO: - fatal('Unable to write to MSR {:x}. Unknown error.'.format(msr)) + fatal('Unable to write to MSR {} ({:x}). Unknown error.'.format(msr, MSR_DICT[msr])) else: raise e @@ -253,14 +253,14 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False): output.append(get_value_for_bits(val, from_bit, to_bit)) if flatten: if len(set(output)) > 1: - warning('Found multiple values for {:s} (0x{:x}). This should never happen.') + warning('Found multiple values for {:s} ({:x}). This should never happen.'.format(msr, MSR_DICT[msr])) return output[0] return output[cpu] if cpu is not None else output except (IOError, OSError) as e: if e.errno == EPERM or e.errno == EACCES: - fatal('Unable to read from MSR {:x}. Try to disable Secure Boot.'.format(msr)) + fatal('Unable to read from MSR {} ({:x}). Try to disable Secure Boot.'.format(msr, MSR_DICT[msr])) elif e.errno == EIO: - fatal('Unable to read to MSR {:x}. Unknown error.'.format(msr)) + fatal('Unable to read to MSR {} ({:x}). Unknown error.'.format(msr, MSR_DICT[msr])) else: raise e