Skip to content

Commit

Permalink
fix(test): Handle invpcid_single in guest-host feature comparison
Browse files Browse the repository at this point in the history
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 <itazur@amazon.com>
  • Loading branch information
zulinx86 committed Nov 7, 2024
1 parent a9956b0 commit b276fc1
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tests/integration_tests/functional/test_cpu_features_x86_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_host_vs_guest_cpu_features_x86_64(uvm_nano):
"umip",
}
case CpuModel.INTEL_CASCADELAKE:
expected = {
expected_host_minus_guest = {
"acpi",
"aperfmperf",
"arch_perfmon",
Expand Down Expand Up @@ -392,19 +392,32 @@ def test_host_vs_guest_cpu_features_x86_64(uvm_nano):
"vpid",
"xtpr",
}
expected_guest_minus_host = {
"hypervisor",
"tsc_known_freq",
"umip",
}

# Linux kernel v6.4+ passes through the CPUID bit for "flush_l1d" to guests.
# https://github.com/torvalds/linux/commit/45cf86f26148e549c5ba4a8ab32a390e4bde216e
#
# Our test ubuntu host kernel is v6.8 and has the commit.
if global_props.host_linux_version_tpl >= (6, 4):
expected -= {"flush_l1d"}
assert host_feats - guest_feats == expected
expected_host_minus_guest -= {"flush_l1d"}

assert guest_feats - host_feats == {
"hypervisor",
"tsc_known_freq",
"umip",
}
# Linux kernel v6.6+ drops the "invpcid_single" synthetic feature bit.
# https://github.com/torvalds/linux/commit/54e3d9434ef61b97fd3263c141b928dc5635e50d
#
# Our test ubuntu host kernel is v6.8 and has the commit.
host_has_invpcid_single = global_props.host_linux_version_tpl < (6, 6)
guest_has_invpcid_single = vm.guest_kernel_version < (6, 6)
if host_has_invpcid_single and not guest_has_invpcid_single:
expected_host_minus_guest |= {"invpcid_single"}
if not host_has_invpcid_single and guest_has_invpcid_single:
expected_guest_minus_host |= {"invpcid_single"}

assert host_feats - guest_feats == expected_host_minus_guest
assert guest_feats - host_feats == expected_guest_minus_host
case CpuModel.INTEL_ICELAKE:
host_guest_diff_5_10 = {
"dtes64",
Expand Down

0 comments on commit b276fc1

Please sign in to comment.