Skip to content

Commit 5d246a9

Browse files
committed
sq
Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent bd80606 commit 5d246a9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/data/msr/msr_reader.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
// SPDX-License-Identifier: Apache-2.0
1+
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
33

4-
// Helper script used to read MSR values from ranges known to contain MSRs.
4+
# Helper script used to read MSR values from ranges known to contain MSRs.
55

6+
import os
67
import mmap
78

89
msr_fd = open("/dev/cpu/0/msr", "r+b")
9-
msrs = mmap.mmap(msr_fd.fileno(), 0)
1010

11-
def print_msr(msr):
12-
msr_bytes = msrs[msr:msr+8]
13-
if len(msr_bytes) == 8:
11+
def print_msr(msr: int):
12+
msr_bytes = os.pread(msr_fd, 8, msr)
13+
if msr_bytes:
1414
msr_value = int.from_bytes(msr_bytes)
1515
print("{msr:#x},{msr_value:#x}")
1616

0 commit comments

Comments
 (0)