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+
140147AMD_GENOA_HOST_ONLY_FEATS = AMD_MILAN_HOST_ONLY_FEATS | {
141148 "avic" ,
142149 "flush_l1d" ,
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 from AUTOIBRS, v6.3)
171+ "ibrs_enhanced" ,
172+ # Propagated to the guest since:
173+ # https://github.com/torvalds/linux/commit/45cf86f26148 (KVM advertises FLUSH_L1D, v6.2)
174+ # https://github.com/torvalds/linux/commit/da3db168fb67 (KVM virtualises MSR_IA32_FLUSH_CMD on SVM, v6.4)
175+ "flush_l1d" ,
176+ } | {"debug_swap" , "cpuid_fault" , "xtopology" , "la57" , "vnmi" }
177+
178+ INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED = {
179+ # Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
180+ # are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
181+ # https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
182+ "ibpb_exit_to_user" ,
183+ "pebs" ,
184+ # Propagated to the guest since:
185+ # https://github.com/torvalds/linux/commit/45cf86f26148 (KVM advertises FLUSH_L1D, v6.2)
186+ "flush_l1d" ,
187+ "dts" ,
188+ "dtes64" ,
189+ "bts" ,
190+ }
191+ INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED = {"la57" }
192+
193+ # Intel Ice Lake is not vulnerable to VMScape (BHB clearing software mitigation), so
194+ # "ibpb_exit_to_user" is not needed.
195+ # https://docs.kernel.org/admin-guide/hw-vuln/vmscape.html#affected-processors
196+ INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 = INTEL_HOST_ONLY_FEATS - {
197+ "ibpb_exit_to_user" ,
198+ "cdp_l3" ,
199+ } | {"pconfig" , "tme" , "split_lock_detect" }
200+
201+ INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 = INTEL_ICELAKE_HOST_ONLY_FEATS_5_10 - {
202+ "bts" ,
203+ "dtes64" ,
204+ "dts" ,
205+ "pebs" ,
206+ }
207+
208+ INTEL_ICELAKE_HOST_ONLY_FEATS_6_18 = INTEL_ICELAKE_HOST_ONLY_FEATS_6_1 - {
209+ "flush_l1d" ,
210+ } | {"la57" }
211+
156212
157213def test_host_vs_guest_cpu_features (uvm_plain_any ):
158214 """Check CPU features host vs guest"""
@@ -169,16 +225,20 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
169225 case CpuModel .AMD_MILAN :
170226 if global_props .host_linux_version_tpl < (6 , 1 ):
171227 assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
172- else :
228+ elif global_props . host_linux_version_tpl < ( 6 , 18 ) :
173229 assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
230+ else :
231+ assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_18
174232
175233 assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
176234
177235 case CpuModel .AMD_GENOA :
178236 if global_props .host_linux_version_tpl < (6 , 1 ):
179237 assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
180- else :
238+ elif global_props . host_linux_version_tpl < ( 6 , 18 ) :
181239 assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
240+ else :
241+ assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_18
182242
183243 assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
184244
@@ -189,7 +249,11 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
189249 # Ubuntu hasn't backported the patch for VMScape yet.
190250 # This is only requried for Intel Cascade Lake since we only run
191251 # tests on Intel Cascade Lake for Ubuntu.
192- if "amzn" not in global_props .host_os :
252+ # Since v6.11, flags declared in cpufeatures.h without a quoted /proc/cpuinfo name
253+ # are hidden. VMSCAPE added IBPB_EXIT_TO_USER without one, so v6.18+ amzn2023 hides it.
254+ # https://github.com/torvalds/linux/commit/78ce84b9e0a54a0c91a7449f321c1f852c0cd3fc
255+ host_version = global_props .host_linux_version_tpl
256+ if "amzn" not in global_props .host_os or host_version >= (6 , 18 ):
193257 expected_host_minus_guest -= {"ibpb_exit_to_user" }
194258
195259 # Linux kernel v6.4+ passes through the CPUID bit for "flush_l1d" to guests.
@@ -214,29 +278,13 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
214278 assert guest_feats - host_feats == expected_guest_minus_host
215279
216280 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
281+ host_version = global_props .host_linux_version_tpl
282+ if host_version < (6 , 1 ):
283+ assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_5_10
284+ elif host_version < (6 , 18 ):
285+ assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_1
238286 else :
239- assert host_feats - guest_feats == host_guest_diff_6_1
287+ assert host_feats - guest_feats == INTEL_ICELAKE_HOST_ONLY_FEATS_6_18
240288 assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip" }
241289 case CpuModel .INTEL_SAPPHIRE_RAPIDS | CpuModel .INTEL_GRANITE_RAPIDS :
242290 expected_host_minus_guest = INTEL_HOST_ONLY_FEATS .copy ()
@@ -359,6 +407,10 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
359407 "tsc_known_freq" ,
360408 }
361409
410+ if host_version >= (6 , 18 ):
411+ expected_host_minus_guest -= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_REMOVED
412+ expected_host_minus_guest |= INTEL_SPR_GNR_HOST_ONLY_FEATS_6_18_ADDED
413+
362414 assert host_feats - guest_feats == expected_host_minus_guest
363415 assert guest_feats - host_feats == expected_guest_minus_host
364416 case CpuModel .ARM_NEOVERSE_N1 :
0 commit comments