Skip to content

Commit 8858049

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 3f35d0f commit 8858049

File tree

1 file changed

+268
-0
lines changed

1 file changed

+268
-0
lines changed

tests/integration_tests/functional/test_cpu_features.py

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
from pathlib import Path
1717

1818
import pytest
19+
from packaging import version
1920

2021
import framework.utils_cpuid as cpuid_utils
2122
from framework import utils
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,272 @@ 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 = host_guest_diff_5_10 - {
270+
"lbrv",
271+
"pausefilter",
272+
"pfthreshold",
273+
"sme",
274+
"tsc_scale",
275+
"v_vmsave_vmload",
276+
"vgif",
277+
"vmcb_clean",
278+
} | {"brs", "rapl", "v_spec_ctrl"}
279+
280+
if version.parse(utils.get_kernel_version()) < version.parse("6.1"):
281+
assert host_feats - guest_feats == host_guest_diff_5_10
282+
else:
283+
assert host_feats - guest_feats == host_guest_diff_6_1
284+
285+
assert guest_feats - host_feats == {
286+
"hypervisor",
287+
"tsc_adjust",
288+
"tsc_deadline_timer",
289+
"tsc_known_freq",
290+
}
291+
case CpuModel.INTEL_SKYLAKE:
292+
assert host_feats - guest_feats == {
293+
"acpi",
294+
"aperfmperf",
295+
"arch_perfmon",
296+
"art",
297+
"bts",
298+
"cat_l3",
299+
"cdp_l3",
300+
"cqm",
301+
"cqm_llc",
302+
"cqm_mbm_local",
303+
"cqm_mbm_total",
304+
"cqm_occup_llc",
305+
"dca",
306+
"ds_cpl",
307+
"dtes64",
308+
"dtherm",
309+
"dts",
310+
"epb",
311+
"ept",
312+
"ept_ad",
313+
"est",
314+
"flexpriority",
315+
"flush_l1d",
316+
"hwp",
317+
"hwp_act_window",
318+
"hwp_epp",
319+
"hwp_pkg_req",
320+
"ida",
321+
"intel_ppin",
322+
"intel_pt",
323+
"mba",
324+
"monitor",
325+
"pbe",
326+
"pdcm",
327+
"pebs",
328+
"pln",
329+
"pts",
330+
"rdt_a",
331+
"sdbg",
332+
"smx",
333+
"tm",
334+
"tm2",
335+
"tpr_shadow",
336+
"vmx",
337+
"vnmi",
338+
"vpid",
339+
"xtpr",
340+
}
341+
assert guest_feats - host_feats == {
342+
"hypervisor",
343+
"tsc_known_freq",
344+
"umip",
345+
}
346+
case CpuModel.INTEL_CASCADELAKE:
347+
assert host_feats - guest_feats == {
348+
"acpi",
349+
"aperfmperf",
350+
"arch_perfmon",
351+
"art",
352+
"bts",
353+
"cat_l3",
354+
"cdp_l3",
355+
"cqm",
356+
"cqm_llc",
357+
"cqm_mbm_local",
358+
"cqm_mbm_total",
359+
"cqm_occup_llc",
360+
"dca",
361+
"ds_cpl",
362+
"dtes64",
363+
"dtherm",
364+
"dts",
365+
"epb",
366+
"ept",
367+
"ept_ad",
368+
"est",
369+
"flexpriority",
370+
"flush_l1d",
371+
"hwp",
372+
"hwp_act_window",
373+
"hwp_epp",
374+
"hwp_pkg_req",
375+
"ida",
376+
"intel_ppin",
377+
"intel_pt",
378+
"mba",
379+
"monitor",
380+
"pbe",
381+
"pdcm",
382+
"pebs",
383+
"pln",
384+
"pts",
385+
"rdt_a",
386+
"sdbg",
387+
"smx",
388+
"tm",
389+
"tm2",
390+
"tpr_shadow",
391+
"vmx",
392+
"vnmi",
393+
"vpid",
394+
"xtpr",
395+
}
396+
assert guest_feats - host_feats == {
397+
"hypervisor",
398+
"tsc_known_freq",
399+
"umip",
400+
}
401+
case CpuModel.INTEL_ICELAKE:
402+
host_guest_diff_5_10 = {
403+
"dtes64",
404+
"hwp_act_window",
405+
"pdcm",
406+
"acpi",
407+
"aperfmperf",
408+
"arch_perfmon",
409+
"art",
410+
"bts",
411+
"cat_l3",
412+
"cqm",
413+
"cqm_llc",
414+
"cqm_mbm_local",
415+
"cqm_mbm_total",
416+
"cqm_occup_llc",
417+
"dca",
418+
"ds_cpl",
419+
"dtherm",
420+
"dts",
421+
"epb",
422+
"ept",
423+
"ept_ad",
424+
"est",
425+
"flexpriority",
426+
"flush_l1d",
427+
"hwp",
428+
"hwp_epp",
429+
"hwp_pkg_req",
430+
"ida",
431+
"intel_ppin",
432+
"intel_pt",
433+
"mba",
434+
"monitor",
435+
"pbe",
436+
"pconfig",
437+
"pebs",
438+
"pln",
439+
"pts",
440+
"rdt_a",
441+
"sdbg",
442+
"smx",
443+
"split_lock_detect",
444+
"tm",
445+
"tm2",
446+
"tme",
447+
"tpr_shadow",
448+
"vmx",
449+
"vnmi",
450+
"vpid",
451+
"xtpr",
452+
}
453+
host_guest_diff_6_1 = host_guest_diff_5_10 - {
454+
"bts",
455+
"dtes64",
456+
"dts",
457+
"pebs",
458+
}
459+
460+
if version.parse(utils.get_kernel_version()) < version.parse("6.1"):
461+
assert host_feats - guest_feats == host_guest_diff_5_10
462+
else:
463+
assert host_feats - guest_feats == host_guest_diff_6_1
464+
465+
assert guest_feats - host_feats == {
466+
"hypervisor",
467+
"tsc_known_freq",
468+
}
469+
case _:
470+
if os.environ.get("BUILDKITE") is not None:
471+
assert False, f"Cpu model {cpu_model} is not supported"
472+
473+
206474
# From the `Intel® 64 Architecture x2APIC Specification`
207475
# (https://courses.cs.washington.edu/courses/cse451/24wi/documentation/x2apic.pdf):
208476
# > The X2APIC MSRs cannot to be loaded and stored on VMX transitions. A VMX transition fails

0 commit comments

Comments
 (0)