Skip to content

Commit f1177c7

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 f1177c7

1 file changed

Lines changed: 73 additions & 25 deletions

File tree

tests/integration_tests/functional/test_cpu_features_host_vs_guest.py

Lines changed: 73 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,53 @@
153159
"x2avic",
154160
}
155161

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

157210
def test_host_vs_guest_cpu_features(uvm_plain_any):
158211
"""Check CPU features host vs guest"""
@@ -169,16 +222,20 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
169222
case CpuModel.AMD_MILAN:
170223
if global_props.host_linux_version_tpl < (6, 1):
171224
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
172-
else:
225+
elif global_props.host_linux_version_tpl < (6, 18):
173226
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
227+
else:
228+
assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_18
174229

175230
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
176231

177232
case CpuModel.AMD_GENOA:
178233
if global_props.host_linux_version_tpl < (6, 1):
179234
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
180-
else:
235+
elif global_props.host_linux_version_tpl < (6, 18):
181236
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
237+
else:
238+
assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_18
182239

183240
assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
184241

@@ -189,7 +246,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
189246
# Ubuntu hasn't backported the patch for VMScape yet.
190247
# This is only requried for Intel Cascade Lake since we only run
191248
# tests on Intel Cascade Lake for Ubuntu.
192-
if "amzn" not in global_props.host_os:
249+
# "ibpb_exit_to_user" is no longer visible on v6.18+ amzn2023 since
250+
# https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
251+
host_version = global_props.host_linux_version_tpl
252+
if "amzn" not in global_props.host_os or host_version >= (6, 18):
193253
expected_host_minus_guest -= {"ibpb_exit_to_user"}
194254

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

216276
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
277+
host_version = global_props.host_linux_version_tpl
278+
if host_version < (6, 1):
279+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_5_10
280+
elif host_version < (6, 18):
281+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_1
238282
else:
239-
assert host_feats - guest_feats == host_guest_diff_6_1
283+
assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_18
240284
assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip"}
241285
case CpuModel.INTEL_SAPPHIRE_RAPIDS | CpuModel.INTEL_GRANITE_RAPIDS:
242286
expected_host_minus_guest = INTEL_HOST_ONLY_FEATS.copy()
@@ -359,6 +403,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
359403
"tsc_known_freq",
360404
}
361405

406+
if host_version >= (6, 18):
407+
expected_host_minus_guest -= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED
408+
expected_host_minus_guest |= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED
409+
362410
assert host_feats - guest_feats == expected_host_minus_guest
363411
assert guest_feats - host_feats == expected_guest_minus_host
364412
case CpuModel.ARM_NEOVERSE_N1:

0 commit comments

Comments
 (0)