Skip to content

Commit d9c431e

Browse files
committed
feat(x86)64: add host vs guest cpu feature test
Add test comparing host and guest default cpu features. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 1907824 commit d9c431e

File tree

1 file changed

+271
-0
lines changed

1 file changed

+271
-0
lines changed

tests/integration_tests/functional/test_cpu_features.py

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import time
1515
from difflib import unified_diff
1616
from pathlib import Path
17+
from packaging import version
1718

1819
import pytest
1920

@@ -22,6 +23,7 @@
2223
from framework.defs import SUPPORTED_HOST_KERNELS
2324
from framework.properties import global_props
2425
from framework.utils_cpu_templates import SUPPORTED_CPU_TEMPLATES
26+
from framework.utils_cpuid import CPU_FEATURES_CMD, CpuModel
2527

2628
PLATFORM = platform.machine()
2729
UNSUPPORTED_HOST_KERNEL = (
@@ -203,6 +205,275 @@ def test_brand_string(uvm_plain_any):
203205
assert False
204206

205207

208+
@pytest.mark.skipif(
209+
PLATFORM != "x86_64",
210+
reason="This is x86_64 specific test.",
211+
)
212+
def test_host_vs_guest_cpu_features_x86_64(uvm_nano):
213+
"""Check CPU features host vs guest"""
214+
215+
vm = uvm_nano
216+
vm.add_net_iface()
217+
vm.start()
218+
host_feats = set(utils.check_output(CPU_FEATURES_CMD).stdout.strip().split(" "))
219+
guest_feats = set(vm.ssh.check_output(CPU_FEATURES_CMD).stdout.strip().split(" "))
220+
221+
cpu_model = cpuid_utils.get_cpu_codename()
222+
match cpu_model:
223+
case CpuModel.AMD_MILAN:
224+
host_guest_diff_5_10 = {
225+
"amd_ppin",
226+
"aperfmperf",
227+
"bpext",
228+
"cat_l3",
229+
"cdp_l3",
230+
"cpb",
231+
"cqm",
232+
"cqm_llc",
233+
"cqm_mbm_local",
234+
"cqm_mbm_total",
235+
"cqm_occup_llc",
236+
"decodeassists",
237+
"extapic",
238+
"extd_apicid",
239+
"flushbyasid",
240+
"hw_pstate",
241+
"ibs",
242+
"irperf",
243+
"lbrv",
244+
"mba",
245+
"monitor",
246+
"mwaitx",
247+
"overflow_recov",
248+
"pausefilter",
249+
"perfctr_llc",
250+
"perfctr_nb",
251+
"pfthreshold",
252+
"rdpru",
253+
"rdt_a",
254+
"sev",
255+
"sev_es",
256+
"skinit",
257+
"smca",
258+
"sme",
259+
"succor",
260+
"svm_lock",
261+
"tce",
262+
"tsc_scale",
263+
"v_vmsave_vmload",
264+
"vgif",
265+
"vmcb_clean",
266+
"wdt",
267+
}
268+
269+
host_guest_diff_6_1 = (
270+
host_guest_diff_5_10
271+
- {
272+
"lbrv",
273+
"pausefilter",
274+
"pfthreshold",
275+
"sme",
276+
"tsc_scale",
277+
"v_vmsave_vmload",
278+
"vgif",
279+
"vmcb_clean",
280+
}
281+
+ {"brs", "rapl", "v_spec_ctrl"}
282+
)
283+
284+
if version.parse(utils.get_kernel_version()) < version.parse("6.1"):
285+
assert host_feats - guest_feats == host_guest_diff_5_10
286+
else:
287+
assert host_feats - guest_feats == host_guest_diff_6_1
288+
289+
assert guest_feats - host_feats == {
290+
"hypervisor",
291+
"tsc_adjust",
292+
"tsc_deadline_timer",
293+
"tsc_known_freq",
294+
}
295+
case CpuModel.INTEL_SKYLAKE:
296+
assert host_feats - guest_feats == {
297+
"acpi",
298+
"aperfmperf",
299+
"arch_perfmon",
300+
"art",
301+
"bts",
302+
"cat_l3",
303+
"cdp_l3",
304+
"cqm",
305+
"cqm_llc",
306+
"cqm_mbm_local",
307+
"cqm_mbm_total",
308+
"cqm_occup_llc",
309+
"dca",
310+
"ds_cpl",
311+
"dtes64",
312+
"dtherm",
313+
"dts",
314+
"epb",
315+
"ept",
316+
"ept_ad",
317+
"est",
318+
"flexpriority",
319+
"flush_l1d",
320+
"hwp",
321+
"hwp_act_window",
322+
"hwp_epp",
323+
"hwp_pkg_req",
324+
"ida",
325+
"intel_ppin",
326+
"intel_pt",
327+
"mba",
328+
"monitor",
329+
"pbe",
330+
"pdcm",
331+
"pebs",
332+
"pln",
333+
"pts",
334+
"rdt_a",
335+
"sdbg",
336+
"smx",
337+
"tm",
338+
"tm2",
339+
"tpr_shadow",
340+
"vmx",
341+
"vnmi",
342+
"vpid",
343+
"xtpr",
344+
}
345+
assert guest_feats - host_feats == {
346+
"hypervisor",
347+
"tsc_known_freq",
348+
"umip",
349+
}
350+
case CpuModel.INTEL_CASCADELAKE:
351+
assert host_feats - guest_feats == {
352+
"acpi",
353+
"aperfmperf",
354+
"arch_perfmon",
355+
"art",
356+
"bts",
357+
"cat_l3",
358+
"cdp_l3",
359+
"cqm",
360+
"cqm_llc",
361+
"cqm_mbm_local",
362+
"cqm_mbm_total",
363+
"cqm_occup_llc",
364+
"dca",
365+
"ds_cpl",
366+
"dtes64",
367+
"dtherm",
368+
"dts",
369+
"epb",
370+
"ept",
371+
"ept_ad",
372+
"est",
373+
"flexpriority",
374+
"flush_l1d",
375+
"hwp",
376+
"hwp_act_window",
377+
"hwp_epp",
378+
"hwp_pkg_req",
379+
"ida",
380+
"intel_ppin",
381+
"intel_pt",
382+
"mba",
383+
"monitor",
384+
"pbe",
385+
"pdcm",
386+
"pebs",
387+
"pln",
388+
"pts",
389+
"rdt_a",
390+
"sdbg",
391+
"smx",
392+
"tm",
393+
"tm2",
394+
"tpr_shadow",
395+
"vmx",
396+
"vnmi",
397+
"vpid",
398+
"xtpr",
399+
}
400+
assert guest_feats - host_feats == {
401+
"hypervisor",
402+
"tsc_known_freq",
403+
"umip",
404+
}
405+
case CpuModel.INTEL_ICELAKE:
406+
host_guest_diff_5_10 = {
407+
"DTES64",
408+
"HWP_ACT_WINDOW",
409+
"PDCM",
410+
"acpi",
411+
"aperfmperf",
412+
"arch_perfmon",
413+
"art",
414+
"bts",
415+
"cat_l3",
416+
"cqm",
417+
"cqm_llc",
418+
"cqm_mbm_local",
419+
"cqm_mbm_total",
420+
"cqm_occup_llc",
421+
"dca",
422+
"ds_cpl",
423+
"dtherm",
424+
"dts",
425+
"epb",
426+
"ept",
427+
"ept_ad",
428+
"est",
429+
"flexpriority",
430+
"flush_l1d",
431+
"hwp",
432+
"hwp_epp",
433+
"hwp_pkg_req",
434+
"ida",
435+
"intel_ppin",
436+
"intel_pt",
437+
"mba",
438+
"monitor",
439+
"pbe",
440+
"pconfig",
441+
"pebs",
442+
"pln",
443+
"pts",
444+
"rdt_a",
445+
"sdbg",
446+
"smx",
447+
"split_lock_detect",
448+
"tm",
449+
"tm2",
450+
"tme",
451+
"tpr_shadow",
452+
"vmx",
453+
"vnmi",
454+
"vpid",
455+
"xtpr",
456+
}
457+
host_guest_diff_6_1 = host_guest_diff_5_10 - {
458+
"bts",
459+
"dtes64",
460+
"dts",
461+
"pebs",
462+
}
463+
464+
if version.parse(utils.get_kernel_version()) < version.parse("6.1"):
465+
assert host_feats - guest_feats == host_guest_diff_5_10
466+
else:
467+
assert host_feats - guest_feats == host_guest_diff_6_1
468+
469+
assert guest_feats - host_feats == {
470+
"hypervisor",
471+
"tsc_known_freq",
472+
}
473+
case _:
474+
assert False, f"Cpu model {cpu_model} is not supported"
475+
476+
206477
# From the `Intel® 64 Architecture x2APIC Specification`
207478
# (https://courses.cs.washington.edu/courses/cse451/24wi/documentation/x2apic.pdf):
208479
# > The X2APIC MSRs cannot to be loaded and stored on VMX transitions. A VMX transition fails

0 commit comments

Comments
 (0)