Skip to content

Commit cbe79ea

Browse files
committed
fix(test): Handle invpcid_single in guest/host feature comparison
Linux kernel v6.6+ drops the synthetic feature flag. While the ubuntu host kernel (v6.8) has the change, the Amazon Linux kernels (v5.10 and v6.1) and the guest kernels (v5.10 and v6.1) don't. Fixes: 4e014a1 ("test(x86_64): add host vs guest cpu feature test") Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent f51fbd5 commit cbe79ea

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tests/integration_tests/functional/test_cpu_features_x86_64.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def test_host_vs_guest_cpu_features_x86_64(uvm_nano):
343343
"umip",
344344
}
345345
case CpuModel.INTEL_CASCADELAKE:
346-
expected = {
346+
expected_host_minus_guest = {
347347
"acpi",
348348
"aperfmperf",
349349
"arch_perfmon",
@@ -392,19 +392,32 @@ def test_host_vs_guest_cpu_features_x86_64(uvm_nano):
392392
"vpid",
393393
"xtpr",
394394
}
395+
expected_guest_minus_host = {
396+
"hypervisor",
397+
"tsc_known_freq",
398+
"umip",
399+
}
400+
395401
# Linux kernel v6.4+ passes through the CPUID bit for "flush_l1d" to guests.
396402
# https://github.com/torvalds/linux/commit/45cf86f26148e549c5ba4a8ab32a390e4bde216e
397403
#
398404
# Our test ubuntu host kernel is v6.8 and has the commit.
399405
if global_props.host_linux_version_tpl >= (6, 4):
400-
expected -= {"flush_l1d"}
401-
assert host_feats - guest_feats == expected
406+
expected_host_minus_guest -= {"flush_l1d"}
402407

403-
assert guest_feats - host_feats == {
404-
"hypervisor",
405-
"tsc_known_freq",
406-
"umip",
407-
}
408+
# Linux kernel v6.6+ drops the "invpcid_single" synthetic feature bit.
409+
# https://github.com/torvalds/linux/commit/54e3d9434ef61b97fd3263c141b928dc5635e50d
410+
#
411+
# Our test ubuntu host kernel is v6.8 and has the commit.
412+
host_has_invpcid_single = global_props.host_linux_version_tpl < (6, 6)
413+
guest_has_invpcid_single = vm.guest_kernel_version < (6, 6)
414+
if host_has_invpcid_single and not guest_has_invpcid_single:
415+
expected_host_minus_guest |= {"invpcid_single"}
416+
if not host_has_invpcid_single and guest_has_invpcid_single:
417+
expected_guest_minus_host |= {"invpcid_single"}
418+
419+
assert host_feats - guest_feats == expected_host_minus_guest
420+
assert guest_feats - host_feats == expected_guest_minus_host
408421
case CpuModel.INTEL_ICELAKE:
409422
host_guest_diff_5_10 = {
410423
"dtes64",

0 commit comments

Comments
 (0)