88import pytest
99
1010import framework .utils_cpuid as cpuid_utils
11- from framework .utils_cpuid import CpuModel
11+ from framework import utils
12+ from framework .utils_cpuid import CPU_FEATURES_CMD , CpuModel
1213
1314PLATFORM = platform .machine ()
1415
@@ -48,7 +49,7 @@ def _check_cpu_features_arm(test_microvm, guest_kv, template_name=None):
4849 case CpuModel .ARM_NEOVERSE_V1 , _, None :
4950 expected_cpu_features = DEFAULT_G3_FEATURES_5_10
5051
51- _ , stdout , _ = test_microvm .ssh .check_output (r"lscpu |grep -oP '^Flags:\s+\K.+'" )
52+ _ , stdout , _ = test_microvm .ssh .check_output (CPU_FEATURES_CMD )
5253 flags = set (stdout .strip ().split (" " ))
5354 assert flags == expected_cpu_features
5455
@@ -63,6 +64,37 @@ def get_cpu_template_dir(cpu_template):
6364 return cpu_template if cpu_template else "none"
6465
6566
67+ @pytest .mark .skipif (
68+ PLATFORM != "aarch64" ,
69+ reason = "This is aarch64 specific test." ,
70+ )
71+ def test_host_vs_guest_cpu_features_aarch64 (uvm_nano ):
72+ """Check CPU features host vs guest"""
73+
74+ vm = uvm_nano
75+ vm .add_net_iface ()
76+ vm .start ()
77+ host_feats = set (utils .check_output (CPU_FEATURES_CMD ).stdout .strip ().split (" " ))
78+ guest_feats = set (vm .ssh .check_output (CPU_FEATURES_CMD ).stdout .strip ().split (" " ))
79+
80+ cpu_model = cpuid_utils .get_cpu_model_name ()
81+ match cpu_model :
82+ case CpuModel .ARM_NEOVERSE_N1 :
83+ assert host_feats - guest_feats == set ()
84+ assert guest_feats - host_feats == {"ssbs" }
85+ case CpuModel .ARM_NEOVERSE_V1 :
86+ assert host_feats - guest_feats == {
87+ "paca" ,
88+ "pacg" ,
89+ "sve" ,
90+ "svebf16" ,
91+ "svei8mm" ,
92+ }
93+ assert guest_feats - host_feats == {"ssbs" }
94+ case _:
95+ assert False , f"Cpu model { cpu_model } is not supported"
96+
97+
6698@pytest .mark .skipif (
6799 PLATFORM != "aarch64" ,
68100 reason = "This is aarch64 specific test." ,
0 commit comments