@@ -238,8 +238,7 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
238238 else :
239239 assert host_feats - guest_feats == host_guest_diff_6_1
240240 assert guest_feats - host_feats == INTEL_GUEST_ONLY_FEATS - {"umip" }
241-
242- case CpuModel .INTEL_SAPPHIRE_RAPIDS :
241+ case CpuModel .INTEL_SAPPHIRE_RAPIDS | CpuModel .INTEL_GRANITE_RAPIDS :
243242 expected_host_minus_guest = INTEL_HOST_ONLY_FEATS .copy ()
244243 expected_guest_minus_host = INTEL_GUEST_ONLY_FEATS .copy ()
245244
@@ -275,25 +274,32 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
275274 # L3 variants are listed in INTEL_HOST_ONLY_FEATS.
276275 "cat_l2" ,
277276 "cdp_l2" ,
278- # This is a synthesized bit for split lock detection that raise an Alignment Check
279- # (#AC) exception if an operand of an atomic operation crosses two cache lines. It
280- # is not enumerated on CPUID, instead detected by actually attempting to read from
281- # MSR address 0x33 (MSR_MEMORY_CTRL in Intel SDM, MSR_TEST_CTRL in Linux kernel).
282- "split_lock_detect" ,
283277 # Firecracker disables WAITPKG in CPUID normalization.
284278 # https://github.com/firecracker-microvm/firecracker/pull/5118
285279 "waitpkg" ,
286280 }
287281
282+ # FIX: Split lock detection should be enabled on Granite Rapids too. This is a temporary patch
283+ # to prevent recurrent, known test failures. Once addressed, split lock detection will be enabled
284+ # on both Sapphire and Granite Rapids.
285+ if CPU_MODEL == CpuModel .INTEL_SAPPHIRE_RAPIDS :
286+ # This is a synthesized bit for split lock detection that raise an Alignment Check
287+ # (#AC) exception if an operand of an atomic operation crosses two cache lines. It
288+ # is not enumerated on CPUID, instead detected by actually attempting to read from
289+ # MSR address 0x33 (MSR_MEMORY_CTRL in Intel SDM, MSR_TEST_CTRL in Linux kernel).
290+ expected_host_minus_guest |= {"split_lock_detect" }
291+
292+ elif CPU_MODEL == CpuModel .INTEL_GRANITE_RAPIDS :
293+ # VMScape mitigation. Granite Rapids CPUs are not affected, and therefore do not need
294+ # this feature.
295+ expected_host_minus_guest -= {
296+ "ibpb_exit_to_user" ,
297+ }
298+
288299 # The following features are also not virtualized by KVM yet but are only supported on
289300 # newer kernel versions.
290301 if host_version >= (5 , 18 ):
291302 expected_host_minus_guest |= {
292- # Hardware Feedback Interface (HFI) is a feature that gives OSes a performance
293- # and energy efficiency capability data for each CPU that can be used to
294- # influence task placement decisions.
295- # https://github.com/torvalds/linux/commit/7b8f40b3de75c971a4e5f9308b06deb59118dbac
296- "hfi" ,
297303 # Indirect Brach Tracking (IBT) is a feature where the CPU ensures that indirect
298304 # branch targets start with ENDBRANCH instruction (`endbr32` or `endbr64`),
299305 # which executes as a no-op; if anything else is found, a control-protection
@@ -302,6 +308,25 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
302308 "ibt" ,
303309 }
304310
311+ if CPU_MODEL == CpuModel .INTEL_SAPPHIRE_RAPIDS :
312+ expected_host_minus_guest |= {
313+ # Hardware Feedback Interface (HFI) is a feature that gives OSes a performance
314+ # and energy efficiency capability data for each CPU that can be used to
315+ # influence task placement decisions. Only available on Sapphire Rapids.
316+ # https://github.com/torvalds/linux/commit/7b8f40b3de75c971a4e5f9308b06deb59118dbac
317+ "hfi" ,
318+ }
319+
320+ # FIX: This should also be backported to 5.10. Lower priority than split_lock_detect
321+ # though.
322+ elif host_version < (5 , 19 ) and CPU_MODEL == CpuModel .INTEL_GRANITE_RAPIDS :
323+ expected_host_minus_guest -= {
324+ # From v5.19 onwards, PPIN is detected by reading MSRs. On versions before,
325+ # a static list of architectures is enumerated. As of now, Granite Rapids has
326+ # not been backported to this list, and hence PPIN is not enabled.
327+ "intel_ppin" ,
328+ }
329+
305330 # AVX512 FP16 is supported and passed through on v5.11+.
306331 # https://github.com/torvalds/linux/commit/e1b35da5e624f8b09d2e98845c2e4c84b179d9a4
307332 # https://github.com/torvalds/linux/commit/2224fc9efb2d6593fbfb57287e39ba4958b188ba
@@ -337,7 +362,6 @@ def test_host_vs_guest_cpu_features(uvm_plain_any):
337362
338363 assert host_feats - guest_feats == expected_host_minus_guest
339364 assert guest_feats - host_feats == expected_guest_minus_host
340-
341365 case CpuModel .ARM_NEOVERSE_N1 :
342366 expected_guest_minus_host = set ()
343367 expected_host_minus_guest = set ()
0 commit comments