@@ -48,35 +48,6 @@ def clean_and_mkdir(dir_path):
4848 os .makedirs (dir_path )
4949
5050
51- def _check_cpuid_x86 (test_microvm , expected_cpu_count , expected_htt ):
52- expected_cpu_features = {
53- "maximum IDs for CPUs in pkg" : f"{ expected_cpu_count :#x} ({ expected_cpu_count } )" ,
54- "CLFLUSH line size" : "0x8 (8)" ,
55- "hypervisor guest status" : "true" ,
56- "hyper-threading / multi-core supported" : expected_htt ,
57- }
58-
59- cpuid_utils .check_guest_cpuid_output (
60- test_microvm , "cpuid -1" , None , "=" , expected_cpu_features
61- )
62-
63-
64- def _check_extended_cache_features (vm ):
65- l3_params = cpuid_utils .get_guest_cpuid (vm , "0x80000006" )[(0x80000006 , 0 , "edx" )]
66-
67- # fmt: off
68- line_size = (l3_params >> 0 ) & 0xFF
69- lines_per_tag = (l3_params >> 8 ) & 0xF
70- assoc = (l3_params >> 12 ) & 0xF
71- cache_size = (l3_params >> 18 ) & 0x3FFF
72- # fmt: on
73-
74- assert line_size > 0
75- assert lines_per_tag == 0x1 # This is hardcoded in the AMD spec
76- assert assoc == 0x9 # This is hardcoded in the AMD spec
77- assert cache_size > 0
78-
79-
8051def get_cpu_template_name_str (cpu_template ):
8152 """
8253 Utility function to return a valid string which will be used as
@@ -131,7 +102,16 @@ def test_cpuid(uvm_plain_any, num_vcpus, htt):
131102 vm .basic_config (vcpu_count = num_vcpus , smt = htt )
132103 vm .add_net_iface ()
133104 vm .start ()
134- _check_cpuid_x86 (vm , num_vcpus , "true" if num_vcpus > 1 else "false" )
105+
106+ expected_cpu_features = {
107+ "maximum IDs for CPUs in pkg" : f"{ num_vcpus :#x} ({ num_vcpus } )" ,
108+ "CLFLUSH line size" : "0x8 (8)" ,
109+ "hypervisor guest status" : "true" ,
110+ "hyper-threading / multi-core supported" : "true" if num_vcpus > 1 else "false" ,
111+ }
112+ cpuid_utils .check_guest_cpuid_output (
113+ vm , "cpuid -1" , None , "=" , expected_cpu_features
114+ )
135115
136116
137117@pytest .mark .skipif (
@@ -147,7 +127,20 @@ def test_extended_cache_features(uvm_plain_any):
147127 vm .basic_config ()
148128 vm .add_net_iface ()
149129 vm .start ()
150- _check_extended_cache_features (vm )
130+
131+ l3_params = cpuid_utils .get_guest_cpuid (vm , "0x80000006" )[(0x80000006 , 0 , "edx" )]
132+
133+ # fmt: off
134+ line_size = (l3_params >> 0 ) & 0xFF
135+ lines_per_tag = (l3_params >> 8 ) & 0xF
136+ assoc = (l3_params >> 12 ) & 0xF
137+ cache_size = (l3_params >> 18 ) & 0x3FFF
138+ # fmt: on
139+
140+ assert line_size > 0
141+ assert lines_per_tag == 0x1 # This is hardcoded in the AMD spec
142+ assert assoc == 0x9 # This is hardcoded in the AMD spec
143+ assert cache_size > 0
151144
152145
153146def test_brand_string (uvm_plain_any ):
0 commit comments