Skip to content

Commit 4e014a1

Browse files
committed
test(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 2babc80 commit 4e014a1

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

tests/integration_tests/functional/test_cpu_features.py

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from framework.defs import SUPPORTED_HOST_KERNELS
2323
from framework.properties import global_props
2424
from framework.utils_cpu_templates import SUPPORTED_CPU_TEMPLATES
25+
from framework.utils_cpuid import CPU_FEATURES_CMD, CpuModel
2526

2627
PLATFORM = platform.machine()
2728
UNSUPPORTED_HOST_KERNEL = (
@@ -203,6 +204,272 @@ def test_brand_string(uvm_plain_any):
203204
assert False
204205

205206

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

0 commit comments

Comments
 (0)