Skip to content

Commit 1f4f552

Browse files
authored
Fix MSR string to int conversion in fatal method call in writemsr and readmsr (fix #252)
1 parent dbcef1e commit 1f4f552

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lenovo_fix.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ def writemsr(msr, val):
223223
except (IOError, OSError) as e:
224224
if e.errno == EPERM or e.errno == EACCES:
225225
fatal(
226-
'Unable to write to MSR {:x}. Try to disable Secure Boot '
227-
'and check if your kernel does not restrict access to MSR.'.format(msr)
226+
'Unable to write to MSR {} ({:x}). Try to disable Secure Boot '
227+
'and check if your kernel does not restrict access to MSR.'.format(msr, MSR_DICT[msr])
228228
)
229229
elif e.errno == EIO:
230-
fatal('Unable to write to MSR {:x}. Unknown error.'.format(msr))
230+
fatal('Unable to write to MSR {} ({:x}). Unknown error.'.format(msr, MSR_DICT[msr]))
231231
else:
232232
raise e
233233

@@ -253,14 +253,14 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False):
253253
output.append(get_value_for_bits(val, from_bit, to_bit))
254254
if flatten:
255255
if len(set(output)) > 1:
256-
warning('Found multiple values for {:s} (0x{:x}). This should never happen.')
256+
warning('Found multiple values for {:s} ({:x}). This should never happen.'.format(msr, MSR_DICT[msr]))
257257
return output[0]
258258
return output[cpu] if cpu is not None else output
259259
except (IOError, OSError) as e:
260260
if e.errno == EPERM or e.errno == EACCES:
261-
fatal('Unable to read from MSR {:x}. Try to disable Secure Boot.'.format(msr))
261+
fatal('Unable to read from MSR {} ({:x}). Try to disable Secure Boot.'.format(msr, MSR_DICT[msr]))
262262
elif e.errno == EIO:
263-
fatal('Unable to read to MSR {:x}. Unknown error.'.format(msr))
263+
fatal('Unable to read to MSR {} ({:x}). Unknown error.'.format(msr, MSR_DICT[msr]))
264264
else:
265265
raise e
266266

0 commit comments

Comments
 (0)