Skip to content

Commit 2440dbb

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 3bd1eee commit 2440dbb

1 file changed

Lines changed: 78 additions & 25 deletions

File tree

tests/integration_tests/functional/test_cpu_features_host_vs_guest.py

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

140+
# Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
141+
# are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
142+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
143+
AMD_MILAN_HOST_ONLY_FEATS_6_18 = AMD_MILAN_HOST_ONLY_FEATS_6_1 - {
144+
"ibpb_exit_to_user",
145+
} | {"xtopology", "debug_swap"}
146+
140147
AMD_GENOA_HOST_ONLY_FEATS = AMD_MILAN_HOST_ONLY_FEATS | {
141148
"avic",
142149
"flush_l1d",
@@ -153,6 +160,56 @@
153160
"x2avic",
154161
}
155162

163+
AMD_GENOA_HOST_ONLY_FEATS_6_18 = AMD_GENOA_HOST_ONLY_FEATS_6_1 - {
164+
# Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
165+
# are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
166+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
167+
"ibpb_exit_to_user",
168+
# Propagated to the guest since:
169+
# https://github.com/torvalds/linux/commit/8c19b6f257fa (KVM AUTOIBRS, v6.3)
170+
# https://github.com/torvalds/linux/commit/e7862eda309e (guest synthesises ibrs_enhanced
171+
# from AUTOIBRS, v6.3; backported to 5.10 and 6.1 LTSs, so our guest kernels pick it up)
172+
"ibrs_enhanced",
173+
# Propagated to the guest since:
174+
# https://github.com/torvalds/linux/commit/45cf86f26148 (KVM advertises FLUSH_L1D, v6.2)
175+
# https://github.com/torvalds/linux/commit/da3db168fb67 (KVM virtualises MSR_IA32_FLUSH_CMD on SVM, v6.4)
176+
"flush_l1d",
177+
} | {"debug_swap", "cpuid_fault", "xtopology", "la57", "vnmi"}
178+
179+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED = {
180+
# Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
181+
# are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
182+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
183+
"ibpb_exit_to_user",
184+
"pebs",
185+
# Propagated to the guest since:
186+
# https://github.com/torvalds/linux/commit/45cf86f26148 (KVM advertises FLUSH_L1D, v6.2)
187+
"flush_l1d",
188+
"dts",
189+
"dtes64",
190+
"bts",
191+
}
192+
INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED = {"la57"}
193+
194+
# Intel Ice Lake is not vulnerable to VMScape (BHB clearing software mitigation), so
195+
# "ibpb_exit_to_user" is not needed.
196+
# https://docs.kernel.org/admin-guide/hw-vuln/vmscape.html#affected-processors
197+
INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 = INTEL_HOST_ONLY_FEATS - {
198+
"ibpb_exit_to_user",
199+
"cdp_l3",
200+
} | {"pconfig", "tme", "split_lock_detect"}
201+
202+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 = INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 - {
203+
"bts",
204+
"dtes64",
205+
"dts",
206+
"pebs",
207+
}
208+
209+
INTEL_ICELAKE_HOST_ONLY_FEATS_6_18 = INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 - {
210+
"flush_l1d",
211+
} | {"la57"}
212+
156213

157214
def test_host_vs_guest_cpu_features(uvm_plain_any):
158215
"""Check CPU features host vs guest"""
@@ -169,16 +226,20 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
169226
case CpuModel.AMD_MILAN:
170227
if global_props.host_linux_version_tpl < (6, 1):
171228
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
172-
else:
229+
elif global_props.host_linux_version_tpl < (6, 18):
173230
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
231+
else:
232+
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_18
174233

175234
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
176235

177236
case CpuModel.AMD_GENOA:
178237
if global_props.host_linux_version_tpl < (6, 1):
179238
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
180-
else:
239+
elif global_props.host_linux_version_tpl < (6, 18):
181240
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
241+
else:
242+
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_18
182243

183244
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
184245

@@ -189,7 +250,11 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
189250
# Ubuntu hasn't backported the patch for VMScape yet.
190251
# This is only requried for Intel Cascade Lake since we only run
191252
# tests on Intel Cascade Lake for Ubuntu.
192-
if "amzn" not in global_props.host_os:
253+
# Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
254+
# are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
255+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
256+
host_version = global_props.host_linux_version_tpl
257+
if "amzn" not in global_props.host_os or host_version >= (6, 18):
193258
expected_host_minus_guest -= {"ibpb_exit_to_user"}
194259

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

216281
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
282+
host_version = global_props.host_linux_version_tpl
283+
if host_version < (6, 1):
284+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_5_10
285+
elif host_version < (6, 18):
286+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_1
238287
else:
239-
assert host_feats - guest_feats == host_guest_diff_6_1
288+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_18
240289
assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip"}
241290
case CpuModel.INTEL_SAPPHIRE_RAPIDS | CpuModel.INTEL_GRANITE_RAPIDS:
242291
expected_host_minus_guest = INTEL_HOST_ONLY_FEATS.copy()
@@ -359,6 +408,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
359408
"tsc_known_freq",
360409
}
361410

411+
if host_version >= (6, 18):
412+
expected_host_minus_guest -= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED
413+
expected_host_minus_guest |= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED
414+
362415
assert host_feats - guest_feats == expected_host_minus_guest
363416
assert guest_feats - host_feats == expected_guest_minus_host
364417
case CpuModel.ARM_NEOVERSE_N1:

0 commit comments

Comments
 (0)