amd-debug-tools 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
amd_debug/kernel.py CHANGED
@@ -115,24 +115,16 @@ def sscanf_bios_args(line):
115
115
 
116
116
  converted_args = []
117
117
  arg_index = 0
118
- for specifier in format_specifiers:
118
+ for _specifier in format_specifiers:
119
119
  if arg_index < len(arguments):
120
120
  value = arguments[arg_index]
121
121
  if value == "Unknown":
122
122
  converted_args.append(-1)
123
- elif specifier.lower() == "x":
123
+ else:
124
124
  try:
125
125
  converted_args.append(int(value, 16))
126
126
  except ValueError:
127
127
  return None
128
- else: # Decimal conversion
129
- try:
130
- converted_args.append(int(value))
131
- except ValueError:
132
- try:
133
- converted_args.append(int(value, 16))
134
- except ValueError:
135
- return None
136
128
  arg_index += 1
137
129
  else:
138
130
  break
@@ -1145,26 +1145,13 @@ class PrerequisiteValidator(AmdTool):
1145
1145
  found_iommu = True
1146
1146
  debug_str += f"Found IOMMU {dev.sys_path}\n"
1147
1147
  break
1148
+
1149
+ # User turned off IOMMU, no problems
1148
1150
  if not found_iommu:
1149
1151
  self.db.record_prereq("IOMMU disabled", "✅")
1150
1152
  return True
1151
- p = os.path.join("/", "sys", "firmware", "acpi", "tables", "IVRS")
1152
- with open(p, "rb") as f:
1153
- data = f.read()
1154
- if len(data) < 40:
1155
- raise ValueError(
1156
- "IVRS table appears too small to contain virtualization info."
1157
- )
1158
- virt_info = struct.unpack_from("I", data, 36)[0]
1159
- debug_str += f"Virtualization info: 0x{virt_info:x}"
1160
- found_dmar = (virt_info & 0x2) != 0
1161
- self.db.record_debug(debug_str)
1162
- if not found_dmar:
1163
- self.db.record_prereq(
1164
- "IOMMU is misconfigured: Pre-boot DMA protection not enabled", "❌"
1165
- )
1166
- self.failures += [DMArNotEnabled()]
1167
- return False
1153
+
1154
+ # Look for MSFT0201 in DSDT/SSDT
1168
1155
  for dev in self.pyudev.list_devices(subsystem="acpi"):
1169
1156
  if "MSFT0201" in dev.sys_path:
1170
1157
  found_acpi = True
@@ -1174,13 +1161,39 @@ class PrerequisiteValidator(AmdTool):
1174
1161
  )
1175
1162
  self.failures += [MissingIommuACPI("MSFT0201")]
1176
1163
  return False
1177
- # check that policy is bound to it
1164
+
1165
+ # Check that policy is bound to it
1178
1166
  for dev in self.pyudev.list_devices(subsystem="platform"):
1179
1167
  if "MSFT0201" in dev.sys_path:
1180
1168
  p = os.path.join(dev.sys_path, "iommu")
1181
1169
  if not os.path.exists(p):
1182
1170
  self.failures += [MissingIommuPolicy("MSFT0201")]
1183
1171
  return False
1172
+
1173
+ # Check pre-boot DMA
1174
+ p = os.path.join("/", "sys", "firmware", "acpi", "tables", "IVRS")
1175
+ with open(p, "rb") as f:
1176
+ data = f.read()
1177
+ if len(data) < 40:
1178
+ raise ValueError(
1179
+ "IVRS table appears too small to contain virtualization info."
1180
+ )
1181
+ virt_info = struct.unpack_from("I", data, 36)[0]
1182
+ debug_str += f"IVRS: Virtualization info: 0x{virt_info:x}\n"
1183
+ found_ivrs_dmar = (virt_info & 0x2) != 0
1184
+
1185
+ # check for MSFT0201 in IVRS (alternative to pre-boot DMA)
1186
+ target_bytes = "MSFT0201".encode("utf-8")
1187
+ found_ivrs_msft0201 = data.find(target_bytes) != -1
1188
+ debug_str += f"IVRS: Found MSFT0201: {found_ivrs_msft0201}"
1189
+
1190
+ self.db.record_debug(debug_str)
1191
+ if not found_ivrs_dmar and not found_ivrs_msft0201:
1192
+ self.db.record_prereq(
1193
+ "IOMMU is misconfigured: Pre-boot DMA protection not enabled", "❌"
1194
+ )
1195
+ self.failures += [DMArNotEnabled()]
1196
+ return False
1184
1197
  self.db.record_prereq("IOMMU properly configured", "✅")
1185
1198
  return True
1186
1199
 
@@ -1190,6 +1203,8 @@ class PrerequisiteValidator(AmdTool):
1190
1203
  return True
1191
1204
  if self.cpu_model not in [0x74, 0x78]:
1192
1205
  return True
1206
+ if not self.smu_version:
1207
+ return True
1193
1208
  if version.parse(self.smu_version) > version.parse("76.60.0"):
1194
1209
  return True
1195
1210
  if version.parse(self.smu_version) < version.parse("76.18.0"):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -7,9 +7,9 @@ test_database.py,sha256=q5ZjI5u20f7ki6iCY5o1iPi0YOvPz1_W0LTDraU8mN4,10040
7
7
  test_display.py,sha256=hHggv-zBthF1BlwWWSjzAm7BBw1DWcElwil5xAuz87g,5822
8
8
  test_failures.py,sha256=H1UxXeVjhJs9-j9yas4vwAha676GX1Es7Kz8RN2B590,6845
9
9
  test_installer.py,sha256=oDMCvaKqqAWjTggltacnasQ-s1gyUvXPDcNrCUGnux4,10216
10
- test_kernel.py,sha256=RW-eLbae02Bhwfu1cegqA1pTj6AS5IqD5lLe-6T0Rjo,7871
10
+ test_kernel.py,sha256=xw7zpLcZjiRLWvO7vyHQ03_CjmKd_Np8ULhc-WhUV6A,7872
11
11
  test_launcher.py,sha256=80xVbidrbx8ixMt_x5Uvfn7nFnB637nX69yIZTifyuk,1511
12
- test_prerequisites.py,sha256=DiB2SkZJf7OFEta1SifoEHyszuvKOfjs967CsHE6rg4,83244
12
+ test_prerequisites.py,sha256=5fHtdMSGMf7sjDykIUfOP2h7XOAe-jNhJoZ0Vll5B58,84982
13
13
  test_pstate.py,sha256=a9oAJ9-LANX32XNQhplz6Y75VNYc__QqoSBKIrwvANg,6058
14
14
  test_s2idle.py,sha256=YpFGpH84xvjI9mY6uBSKapa74hZnG8ZwBShXsJXpmyQ,33540
15
15
  test_sleep_report.py,sha256=ANuxYi_C1oSKAi4xUU2wBu4SwJtcZA7VPpazBe3_WUQ,6922
@@ -24,8 +24,8 @@ amd_debug/database.py,sha256=GkRg3cmaNceyQ2_hy0MBAlMbnTDPHo2co2o4ObWpnQg,10621
24
24
  amd_debug/display.py,sha256=5L9x9tI_UoulHpIvuxuVASRtdXta7UCW_JjTb5StEB0,953
25
25
  amd_debug/failures.py,sha256=z4O4Q-akv3xYGssSZFCqE0cDE4P9F_aw1hxil3McoD4,22910
26
26
  amd_debug/installer.py,sha256=tNWhlfxQEA30guk-fzMvcc237hf_PARVQuHaH3sTp4A,14287
27
- amd_debug/kernel.py,sha256=UAlxlXNuZxtHVtrfCmTp12YombVaUs4mizOxwuXTX2M,12038
28
- amd_debug/prerequisites.py,sha256=_SlRzYvWQpZt8VdioOAA2bMt1G9TbNs75swr60Yu1V4,50005
27
+ amd_debug/kernel.py,sha256=HpX-QRh8tgkvqKnExfo2JrYqfcbMY8GNgDrC2VVV0Oc,11638
28
+ amd_debug/prerequisites.py,sha256=E5_VpRd2mHiNYQBf13JqsoA5iiJS13wxcH3RERS_qJw,50502
29
29
  amd_debug/pstate.py,sha256=lLRsayKi7KOXZCQ6Zjm2pNaobpjLXcgLHXZ9Zt40Fd4,9559
30
30
  amd_debug/s2idle-hook,sha256=LLiaqPtGd0qetu9n6EYxKHZaIdHpVQDONdOuSc0pfFg,1695
31
31
  amd_debug/s2idle.py,sha256=lr1wcuJcpvI5pL2gNHqrc7n5E7EYCztvaAYYFPMlGYk,13259
@@ -37,9 +37,9 @@ amd_debug/templates/html,sha256=JfGhpmHIB2C2GItdGI1kuC8uayqEVgrpQvAWAj35eZ4,1458
37
37
  amd_debug/templates/md,sha256=r8X2aehnH2gzj0WHYTZ5K9wAqC5y39i_3nkDORSC0uM,787
38
38
  amd_debug/templates/stdout,sha256=hyoOJ96K2dJfnWRWhyCuariLKbEHXvs9mstV_g5aMdI,469
39
39
  amd_debug/templates/txt,sha256=nNdsvbPFOhGdL7VA-_4k5aN3nB-6ouGQt6AsWst7T3w,649
40
- amd_debug_tools-0.2.4.dist-info/licenses/LICENSE,sha256=RBlZI6r3MRGzymI2VDX2iW__D2APDbMhu_Xg5t6BWeo,1066
41
- amd_debug_tools-0.2.4.dist-info/METADATA,sha256=jzff0ncunf8ZwS6z90_U577R4OEOlZyf3tVtGA8RHsg,6877
42
- amd_debug_tools-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
- amd_debug_tools-0.2.4.dist-info/entry_points.txt,sha256=HC11T2up0pPfroAn6Pg5M2jOZXhkWIipToJ1YPTKqu8,116
44
- amd_debug_tools-0.2.4.dist-info/top_level.txt,sha256=XYjxExbUTEtiIlag_5iQvZSVOC1EIxhKM4NLklReQ0k,234
45
- amd_debug_tools-0.2.4.dist-info/RECORD,,
40
+ amd_debug_tools-0.2.5.dist-info/licenses/LICENSE,sha256=RBlZI6r3MRGzymI2VDX2iW__D2APDbMhu_Xg5t6BWeo,1066
41
+ amd_debug_tools-0.2.5.dist-info/METADATA,sha256=Dkhw4XQncTgjECNEa3Nk6HCYBzqa5lPAS_IbIli7cvA,6877
42
+ amd_debug_tools-0.2.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
43
+ amd_debug_tools-0.2.5.dist-info/entry_points.txt,sha256=HC11T2up0pPfroAn6Pg5M2jOZXhkWIipToJ1YPTKqu8,116
44
+ amd_debug_tools-0.2.5.dist-info/top_level.txt,sha256=XYjxExbUTEtiIlag_5iQvZSVOC1EIxhKM4NLklReQ0k,234
45
+ amd_debug_tools-0.2.5.dist-info/RECORD,,
test_kernel.py CHANGED
@@ -85,7 +85,7 @@ class TestKernelLog(unittest.TestCase):
85
85
 
86
86
  # test a real post code line
87
87
  line = 'ex_trace_args: " POST CODE: %X ACPI TIMER: %X TIME: %d.%d ms\\n", b0003f33, 83528798, 0, 77, 0, 0'
88
- expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.77 ms"
88
+ expected_output = "POST CODE: B0003F33 ACPI TIMER: 83528798 TIME: 0.119 ms"
89
89
  result = sscanf_bios_args(line)
90
90
  self.assertEqual(result, expected_output)
91
91
 
test_prerequisites.py CHANGED
@@ -143,6 +143,16 @@ class TestPrerequisiteValidator(unittest.TestCase):
143
143
  result = self.validator.check_port_pm_override()
144
144
  self.assertTrue(result)
145
145
 
146
+ @patch("amd_debug.prerequisites.version.parse")
147
+ def test_check_port_pm_override_smu_version_missing(self, mock_version_parse):
148
+ """Test check_port_pm_override with SMU version undefined"""
149
+ self.validator.cpu_family = 0x19
150
+ self.validator.cpu_model = 0x74
151
+ mock_version_parse.side_effect = lambda v: v if isinstance(v, str) else None
152
+ self.validator.smu_version = ""
153
+ result = self.validator.check_port_pm_override()
154
+ self.assertTrue(result)
155
+
146
156
  @patch("amd_debug.prerequisites.version.parse")
147
157
  def test_check_port_pm_override_smu_version_too_low(self, mock_version_parse):
148
158
  """Test check_port_pm_override with SMU version < 76.18.0"""
@@ -185,15 +195,18 @@ class TestPrerequisiteValidator(unittest.TestCase):
185
195
  new_callable=unittest.mock.mock_open,
186
196
  read_data=b"\x00" * 45,
187
197
  )
188
- def test_check_iommu_no_dma_protection(self, _mock_open):
189
- """Test check_iommu when DMA protection is not enabled"""
198
+ @patch("amd_debug.prerequisites.os.path.exists", return_value=True)
199
+ def test_check_iommu_no_dma_protection_no_msft0201(self, _mock_open, _mock_exists):
200
+ """Test check_iommu when DMA protection is not enabled and no MSFT0201 in IVRS"""
190
201
  self.validator.cpu_family = 0x1A
191
202
  self.validator.cpu_model = 0x20
192
203
  iommu_device = MagicMock(sys_path="/sys/devices/iommu")
204
+ acpi_device = MagicMock(sys_path="/sys/devices/acpi/MSFT0201")
205
+ platform_device = MagicMock(sys_path="/sys/devices/platform/MSFT0201")
193
206
  self.mock_pyudev.list_devices.side_effect = [
194
207
  [iommu_device],
195
- [],
196
- [],
208
+ [acpi_device],
209
+ [platform_device],
197
210
  ]
198
211
  result = self.validator.check_iommu()
199
212
  self.assertFalse(result)
@@ -204,6 +217,27 @@ class TestPrerequisiteValidator(unittest.TestCase):
204
217
  "IOMMU is misconfigured: Pre-boot DMA protection not enabled", "❌"
205
218
  )
206
219
 
220
+ @patch(
221
+ "amd_debug.prerequisites.open",
222
+ new_callable=unittest.mock.mock_open,
223
+ read_data=b"\x00" * 45 + "MSFT0201".encode("utf-8"),
224
+ )
225
+ @patch("amd_debug.prerequisites.os.path.exists", return_value=True)
226
+ def test_check_iommu_no_dma_protection_BUT_msft0201(self, _mock_open, _mock_exists):
227
+ """Test check_iommu when DMA protection is not enabled BUT MSFT0201 is in IVRS"""
228
+ self.validator.cpu_family = 0x1A
229
+ self.validator.cpu_model = 0x20
230
+ iommu_device = MagicMock(sys_path="/sys/devices/iommu")
231
+ acpi_device = MagicMock(sys_path="/sys/devices/acpi/MSFT0201")
232
+ platform_device = MagicMock(sys_path="/sys/devices/platform/MSFT0201")
233
+ self.mock_pyudev.list_devices.side_effect = [
234
+ [iommu_device],
235
+ [acpi_device],
236
+ [platform_device],
237
+ ]
238
+ result = self.validator.check_iommu()
239
+ self.assertTrue(result)
240
+
207
241
  @patch(
208
242
  "amd_debug.prerequisites.open",
209
243
  new_callable=unittest.mock.mock_open,