Skip to content

Commit c883e74

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 c883e74

1 file changed

Lines changed: 59 additions & 25 deletions

File tree

tests/integration_tests/functional/test_cpu_features_host_vs_guest.py

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

140+
# On v6.18+ amzn2023, "ibpb_exit_to_user" is hidden from /proc/cpuinfo.
141+
AMD_MILAN_HOST_ONLY_FEATS_6_18 = AMD_MILAN_HOST_ONLY_FEATS_6_1 - {
142+
"ibpb_exit_to_user",
143+
} | {"xtopology", "debug_swap"}
144+
140145
AMD_GENOA_HOST_ONLY_FEATS = AMD_MILAN_HOST_ONLY_FEATS | {
141146
"avic",
142147
"flush_l1d",
@@ -153,6 +158,41 @@
153158
"x2avic",
154159
}
155160

161+
AMD_GENOA_HOST_ONLY_FEATS_6_18 = AMD_GENOA_HOST_ONLY_FEATS_6_1 - {
162+
"ibpb_exit_to_user",
163+
"ibrs_enhanced",
164+
"flush_l1d",
165+
} | {"debug_swap", "cpuid_fault", "xtopology", "la57", "vnmi"}
166+
167+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED = {
168+
"ibpb_exit_to_user",
169+
"pebs",
170+
"flush_l1d",
171+
"dts",
172+
"dtes64",
173+
"bts",
174+
}
175+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED = {"la57"}
176+
177+
# Intel Ice Lake is not vulnerable to VMScape (BHB clearing software mitigation), so
178+
# "ibpb_exit_to_user" is not needed.
179+
# https://docs.kernel.org/admin-guide/hw-vuln/vmscape.html#affected-processors
180+
INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 = INTEL_HOST_ONLY_FEATS - {
181+
"ibpb_exit_to_user",
182+
"cdp_l3",
183+
} | {"pconfig", "tme", "split_lock_detect"}
184+
185+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 = INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 - {
186+
"bts",
187+
"dtes64",
188+
"dts",
189+
"pebs",
190+
}
191+
192+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_18 = INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 - {
193+
"flush_l1d",
194+
} | {"la57"}
195+
156196

157197
def test_host_vs_guest_cpu_features(uvm_plain_any):
158198
"""Check CPU features host vs guest"""
@@ -169,16 +209,20 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
169209
case CpuModel.AMD_MILAN:
170210
if global_props.host_linux_version_tpl < (6, 1):
171211
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
172-
else:
212+
elif global_props.host_linux_version_tpl < (6, 18):
173213
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
214+
else:
215+
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_18
174216

175217
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
176218

177219
case CpuModel.AMD_GENOA:
178220
if global_props.host_linux_version_tpl < (6, 1):
179221
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
180-
else:
222+
elif global_props.host_linux_version_tpl < (6, 18):
181223
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
224+
else:
225+
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_18
182226

183227
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
184228

@@ -189,7 +233,9 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
189233
# Ubuntu hasn't backported the patch for VMScape yet.
190234
# This is only requried for Intel Cascade Lake since we only run
191235
# tests on Intel Cascade Lake for Ubuntu.
192-
if "amzn" not in global_props.host_os:
236+
# Amazon Linux v6.18+ also dropped "ibpb_exit_to_user" from /proc/cpuinfo.
237+
host_version = global_props.host_linux_version_tpl
238+
if "amzn" not in global_props.host_os or host_version >= (6, 18):
193239
expected_host_minus_guest -= {"ibpb_exit_to_user"}
194240

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

216262
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
263+
host_version = global_props.host_linux_version_tpl
264+
if host_version < (6, 1):
265+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_5_10
266+
elif host_version < (6, 18):
267+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_1
238268
else:
239-
assert host_feats - guest_feats == host_guest_diff_6_1
269+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_18
240270
assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip"}
241271
case CpuModel.INTEL_SAPPHIRE_RAPIDS | CpuModel.INTEL_GRANITE_RAPIDS:
242272
expected_host_minus_guest = INTEL_HOST_ONLY_FEATS.copy()
@@ -359,6 +389,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
359389
"tsc_known_freq",
360390
}
361391

392+
if host_version >= (6, 18):
393+
expected_host_minus_guest -= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED
394+
expected_host_minus_guest |= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED
395+
362396
assert host_feats - guest_feats == expected_host_minus_guest
363397
assert guest_feats - host_feats == expected_guest_minus_host
364398
case CpuModel.ARM_NEOVERSE_N1:

0 commit comments

Comments
 (0)