Skip to content

Commit 7e7981a

Browse files
committed
test: Update CPU features host-vs-guest expectations for kernel 6.18
Amazon Linux 6.18 host kernel changes which CPU feature flags appear in /proc/cpuinfo. Update test_host_vs_guest_cpu_features expected host-only flag sets for each x86 CPU model when running on host kernel >= 6.18: Signed-off-by: Jack Thomson <jackabt@amazon.com>
1 parent 53b382a commit 7e7981a

1 file changed

Lines changed: 67 additions & 25 deletions

File tree

tests/integration_tests/functional/test_cpu_features_host_vs_guest.py

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@
137137
"sme",
138138
} | {"brs", "rapl", "v_spec_ctrl"}
139139

140+
# "ibpb_exit_to_user" is no longer visible on v6.18+ amzn2023 since
141+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
142+
AMD_MILAN_HOST_ONLY_FEATS_6_18 = AMD_MILAN_HOST_ONLY_FEATS_6_1 - {
143+
"ibpb_exit_to_user",
144+
} | {"xtopology", "debug_swap"}
145+
140146
AMD_GENOA_HOST_ONLY_FEATS = AMD_MILAN_HOST_ONLY_FEATS | {
141147
"avic",
142148
"flush_l1d",
@@ -153,6 +159,47 @@
153159
"x2avic",
154160
}
155161

162+
AMD_GENOA_HOST_ONLY_FEATS_6_18 = AMD_GENOA_HOST_ONLY_FEATS_6_1 - {
163+
"ibpb_exit_to_user",
164+
# Propagated to the guest since:
165+
# https://github.com/torvalds/linux/commit/8c19b6f257fa (KVM AUTOIBRS, v6.3)
166+
# https://github.com/torvalds/linux/commit/e7862eda309e (guest synthesises ibrs_enhanced from AUTOIBRS, v6.3)
167+
"ibrs_enhanced",
168+
# Propagated to the guest since:
169+
# https://github.com/torvalds/linux/commit/45cf86f26148 (KVM advertises FLUSH_L1D, v6.2)
170+
# https://github.com/torvalds/linux/commit/da3db168fb67 (KVM virtualises MSR_IA32_FLUSH_CMD on SVM, v6.4)
171+
"flush_l1d",
172+
} | {"debug_swap", "cpuid_fault", "xtopology", "la57", "vnmi"}
173+
174+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED = {
175+
"ibpb_exit_to_user",
176+
"pebs",
177+
"flush_l1d",
178+
"dts",
179+
"dtes64",
180+
"bts",
181+
}
182+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED = {"la57"}
183+
184+
# Intel Ice Lake is not vulnerable to VMScape (BHB clearing software mitigation), so
185+
# "ibpb_exit_to_user" is not needed.
186+
# https://docs.kernel.org/admin-guide/hw-vuln/vmscape.html#affected-processors
187+
INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 = INTEL_HOST_ONLY_FEATS - {
188+
"ibpb_exit_to_user",
189+
"cdp_l3",
190+
} | {"pconfig", "tme", "split_lock_detect"}
191+
192+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 = INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 - {
193+
"bts",
194+
"dtes64",
195+
"dts",
196+
"pebs",
197+
}
198+
199+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_18 = INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 - {
200+
"flush_l1d",
201+
} | {"la57"}
202+
156203

157204
def test_host_vs_guest_cpu_features(uvm_plain_any):
158205
"""Check CPU features host vs guest"""
@@ -169,16 +216,20 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
169216
case CpuModel.AMD_MILAN:
170217
if global_props.host_linux_version_tpl < (6, 1):
171218
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
172-
else:
219+
elif global_props.host_linux_version_tpl < (6, 18):
173220
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
221+
else:
222+
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_18
174223

175224
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
176225

177226
case CpuModel.AMD_GENOA:
178227
if global_props.host_linux_version_tpl < (6, 1):
179228
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
180-
else:
229+
elif global_props.host_linux_version_tpl < (6, 18):
181230
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
231+
else:
232+
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_18
182233

183234
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
184235

@@ -189,7 +240,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
189240
# Ubuntu hasn't backported the patch for VMScape yet.
190241
# This is only requried for Intel Cascade Lake since we only run
191242
# tests on Intel Cascade Lake for Ubuntu.
192-
if "amzn" not in global_props.host_os:
243+
# "ibpb_exit_to_user" is no longer visible on v6.18+ amzn2023 since
244+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
245+
host_version = global_props.host_linux_version_tpl
246+
if "amzn" not in global_props.host_os or host_version >= (6, 18):
193247
expected_host_minus_guest -= {"ibpb_exit_to_user"}
194248

195249
# Linux kernel v6.4+ passes through the CPUID bit for "flush_l1d" to guests.
@@ -214,29 +268,13 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
214268
assert guest_feats - host_feats == expected_guest_minus_host
215269

216270
case CpuModel.INTEL_ICELAKE:
217-
expected_host_minus_guest = INTEL_HOST_ONLY_FEATS
218-
219-
# As long as BHB clearing software mitigation is enabled, Intel Ice Lake is not
220-
# vulnerable to VMScape and "IBPB before exit to userspace" is not needed.
221-
# https://docs.kernel.org/admin-guide/hw-vuln/vmscape.html#affected-processors
222-
expected_host_minus_guest -= {"ibpb_exit_to_user"}
223-
224-
host_guest_diff_5_10 = expected_host_minus_guest - {"cdp_l3"} | {
225-
"pconfig",
226-
"tme",
227-
"split_lock_detect",
228-
}
229-
host_guest_diff_6_1 = host_guest_diff_5_10 - {
230-
"bts",
231-
"dtes64",
232-
"dts",
233-
"pebs",
234-
}
235-
236-
if global_props.host_linux_version_tpl < (6, 1):
237-
assert host_feats - guest_feats == host_guest_diff_5_10
271+
host_version = global_props.host_linux_version_tpl
272+
if host_version < (6, 1):
273+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_5_10
274+
elif host_version < (6, 18):
275+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_1
238276
else:
239-
assert host_feats - guest_feats == host_guest_diff_6_1
277+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_18
240278
assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip"}
241279
case CpuModel.INTEL_SAPPHIRE_RAPIDS | CpuModel.INTEL_GRANITE_RAPIDS:
242280
expected_host_minus_guest = INTEL_HOST_ONLY_FEATS.copy()
@@ -359,6 +397,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
359397
"tsc_known_freq",
360398
}
361399

400+
if host_version >= (6, 18):
401+
expected_host_minus_guest -= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED
402+
expected_host_minus_guest |= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED
403+
362404
assert host_feats - guest_feats == expected_host_minus_guest
363405
assert guest_feats - host_feats == expected_guest_minus_host
364406
case CpuModel.ARM_NEOVERSE_N1:

0 commit comments

Comments
 (0)