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_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_HOST_ONLY_FEATS_6_1  =  AMD_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_HOST_ONLY_FEATS  |  {
138+     "avic" ,
139+     "flush_l1d" ,
140+     "ibrs_enhanced" ,
141+ }
142+ 
143+ AMD_GENOA_HOST_ONLY_FEATS_6_1  =  AMD_HOST_ONLY_FEATS_6_1  |  {
144+     "amd_lbr_v2" ,
145+     "avic" ,
146+     "cppc" ,
147+     "flush_l1d" ,
148+     "ibrs_enhanced" ,
149+     "perfmon_v2" ,
150+     "x2avic" ,
151+ } -  {"brs" }
152+ 
73153
74154def  test_host_vs_guest_cpu_features (uvm_nano ):
75155    """Check CPU features host vs guest""" 
@@ -82,73 +162,20 @@ def test_host_vs_guest_cpu_features(uvm_nano):
82162
83163    match  CPU_MODEL :
84164        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-             }
165+             if  global_props .host_linux_version_tpl  <  (6 , 1 ):
166+                 assert  host_feats  -  guest_feats  ==  AMD_HOST_ONLY_FEATS 
167+             else :
168+                 assert  host_feats  -  guest_feats  ==  AMD_HOST_ONLY_FEATS_6_1 
129169
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" }
170+             assert  guest_feats  -  host_feats  ==  AMD_GUEST_ONLY_FEATS 
140171
172+         case  CpuModel .AMD_GENOA :
141173            if  global_props .host_linux_version_tpl  <  (6 , 1 ):
142-                 assert  host_feats  -  guest_feats  ==  host_guest_diff_5_10 
174+                 assert  host_feats  -  guest_feats  ==  AMD_GENOA_HOST_ONLY_FEATS 
143175            else :
144-                 assert  host_feats  -  guest_feats  ==  host_guest_diff_6_1 
176+                 assert  host_feats  -  guest_feats  ==  AMD_GENOA_HOST_ONLY_FEATS_6_1 
145177
146-             assert  guest_feats  -  host_feats  ==  {
147-                 "hypervisor" ,
148-                 "tsc_adjust" ,
149-                 "tsc_deadline_timer" ,
150-                 "tsc_known_freq" ,
151-             }
178+             assert  guest_feats  -  host_feats  ==  AMD_GUEST_ONLY_FEATS 
152179
153180        case  CpuModel .AMD_GENOA :
154181            # Return here to allow the test to pass until CPU features to enable are confirmed 
0 commit comments