22# SPDX-License-Identifier: Apache-2.0
33
44# pylint: disable=too-many-statements
5+ # pylint: disable=too-many-branches
56
67"""
78Check CPU features in the host vs the guest.
7071 "xtpr" ,
7172}
7273
74+ AMD_MILAN_HOST_ONLY_FEATS = {
75+ "amd_ppin" ,
76+ "aperfmperf" ,
77+ "bpext" ,
78+ "cat_l3" ,
79+ "cdp_l3" ,
80+ "cpb" ,
81+ "cqm" ,
82+ "cqm_llc" ,
83+ "cqm_mbm_local" ,
84+ "cqm_mbm_total" ,
85+ "cqm_occup_llc" ,
86+ "decodeassists" ,
87+ "extapic" ,
88+ "extd_apicid" ,
89+ "flushbyasid" ,
90+ "hw_pstate" ,
91+ "ibs" ,
92+ "irperf" ,
93+ "lbrv" ,
94+ "mba" ,
95+ "monitor" ,
96+ "mwaitx" ,
97+ "overflow_recov" ,
98+ "pausefilter" ,
99+ "perfctr_llc" ,
100+ "perfctr_nb" ,
101+ "pfthreshold" ,
102+ "rdpru" ,
103+ "rdt_a" ,
104+ "sev" ,
105+ "sev_es" ,
106+ "skinit" ,
107+ "smca" ,
108+ "sme" ,
109+ "succor" ,
110+ "svm_lock" ,
111+ "tce" ,
112+ "tsc_scale" ,
113+ "v_vmsave_vmload" ,
114+ "vgif" ,
115+ "vmcb_clean" ,
116+ "wdt" ,
117+ }
118+
119+ AMD_GUEST_ONLY_FEATS = {
120+ "hypervisor" ,
121+ "tsc_adjust" ,
122+ "tsc_deadline_timer" ,
123+ "tsc_known_freq" ,
124+ }
125+
126+ AMD_MILAN_HOST_ONLY_FEATS_6_1 = AMD_MILAN_HOST_ONLY_FEATS - {
127+ "lbrv" ,
128+ "pausefilter" ,
129+ "pfthreshold" ,
130+ "sme" ,
131+ "tsc_scale" ,
132+ "v_vmsave_vmload" ,
133+ "vgif" ,
134+ "vmcb_clean" ,
135+ } | {"brs" , "rapl" , "v_spec_ctrl" }
136+
137+ AMD_GENOA_HOST_ONLY_FEATS = AMD_MILAN_HOST_ONLY_FEATS | {
138+ "avic" ,
139+ "flush_l1d" ,
140+ "ibrs_enhanced" ,
141+ }
142+
143+ AMD_GENOA_HOST_ONLY_FEATS_6_1 = AMD_MILAN_HOST_ONLY_FEATS_6_1 | AMD_GENOA_HOST_ONLY_FEATS | {
144+ "amd_lbr_v2" ,
145+ "cppc" ,
146+ "perfmon_v2" ,
147+ "x2avic" ,
148+ } - {"brs" }
149+
73150
74151def test_host_vs_guest_cpu_features (uvm_nano ):
75152 """Check CPU features host vs guest"""
@@ -82,77 +159,20 @@ def test_host_vs_guest_cpu_features(uvm_nano):
82159
83160 match CPU_MODEL :
84161 case CpuModel .AMD_MILAN :
85- host_guest_diff_5_10 = {
86- "amd_ppin" ,
87- "aperfmperf" ,
88- "bpext" ,
89- "cat_l3" ,
90- "cdp_l3" ,
91- "cpb" ,
92- "cqm" ,
93- "cqm_llc" ,
94- "cqm_mbm_local" ,
95- "cqm_mbm_total" ,
96- "cqm_occup_llc" ,
97- "decodeassists" ,
98- "extapic" ,
99- "extd_apicid" ,
100- "flushbyasid" ,
101- "hw_pstate" ,
102- "ibs" ,
103- "irperf" ,
104- "lbrv" ,
105- "mba" ,
106- "monitor" ,
107- "mwaitx" ,
108- "overflow_recov" ,
109- "pausefilter" ,
110- "perfctr_llc" ,
111- "perfctr_nb" ,
112- "pfthreshold" ,
113- "rdpru" ,
114- "rdt_a" ,
115- "sev" ,
116- "sev_es" ,
117- "skinit" ,
118- "smca" ,
119- "sme" ,
120- "succor" ,
121- "svm_lock" ,
122- "tce" ,
123- "tsc_scale" ,
124- "v_vmsave_vmload" ,
125- "vgif" ,
126- "vmcb_clean" ,
127- "wdt" ,
128- }
129-
130- host_guest_diff_6_1 = host_guest_diff_5_10 - {
131- "lbrv" ,
132- "pausefilter" ,
133- "pfthreshold" ,
134- "sme" ,
135- "tsc_scale" ,
136- "v_vmsave_vmload" ,
137- "vgif" ,
138- "vmcb_clean" ,
139- } | {"brs" , "rapl" , "v_spec_ctrl" }
140-
141162 if global_props .host_linux_version_tpl < (6 , 1 ):
142- assert host_feats - guest_feats == host_guest_diff_5_10
163+ assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS
143164 else :
144- assert host_feats - guest_feats == host_guest_diff_6_1
165+ assert host_feats - guest_feats == AMD_MILAN_HOST_ONLY_FEATS_6_1
145166
146- assert guest_feats - host_feats == {
147- "hypervisor" ,
148- "tsc_adjust" ,
149- "tsc_deadline_timer" ,
150- "tsc_known_freq" ,
151- }
167+ assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
152168
153169 case CpuModel .AMD_GENOA :
154- # Return here to allow the test to pass until CPU features to enable are confirmed
155- return
170+ if global_props .host_linux_version_tpl < (6 , 1 ):
171+ assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS
172+ else :
173+ assert host_feats - guest_feats == AMD_GENOA_HOST_ONLY_FEATS_6_1
174+
175+ assert guest_feats - host_feats == AMD_GUEST_ONLY_FEATS
156176
157177 case CpuModel .INTEL_SKYLAKE :
158178 assert host_feats - guest_feats == INTEL_HOST_ONLY_FEATS
0 commit comments