hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL
[qemu/ar7.git] / tests / acceptance / x86_cpu_model_versions.py
blob1c9fd6a56e1ade76d7c68618c0e57cc5ecee1db8
1 #!/usr/bin/env python
3 # Basic validation of x86 versioned CPU models and CPU model aliases
5 # Copyright (c) 2019 Red Hat Inc
7 # Author:
8 # Eduardo Habkost <ehabkost@redhat.com>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 import avocado_qemu
26 import re
28 def get_cpu_prop(vm, prop):
29 cpu_path = vm.command('query-cpus')[0].get('qom_path')
30 return vm.command('qom-get', path=cpu_path, property=prop)
32 class X86CPUModelAliases(avocado_qemu.Test):
33 """
34 Validation of PC CPU model versions and CPU model aliases
36 :avocado: tags=arch:x86_64
37 """
38 def validate_aliases(self, cpus):
39 for c in cpus.values():
40 if 'alias-of' in c:
41 # all aliases must point to a valid CPU model name:
42 self.assertIn(c['alias-of'], cpus,
43 '%s.alias-of (%s) is not a valid CPU model name' % (c['name'], c['alias-of']))
44 # aliases must not point to aliases
45 self.assertNotIn('alias-of', cpus[c['alias-of']],
46 '%s.alias-of (%s) points to another alias' % (c['name'], c['alias-of']))
48 # aliases must not be static
49 self.assertFalse(c['static'])
51 def validate_variant_aliases(self, cpus):
52 # -noTSX, -IBRS and -IBPB variants of CPU models are special:
53 # they shouldn't have their own versions:
54 self.assertNotIn("Haswell-noTSX-v1", cpus,
55 "Haswell-noTSX shouldn't be versioned")
56 self.assertNotIn("Broadwell-noTSX-v1", cpus,
57 "Broadwell-noTSX shouldn't be versioned")
58 self.assertNotIn("Nehalem-IBRS-v1", cpus,
59 "Nehalem-IBRS shouldn't be versioned")
60 self.assertNotIn("Westmere-IBRS-v1", cpus,
61 "Westmere-IBRS shouldn't be versioned")
62 self.assertNotIn("SandyBridge-IBRS-v1", cpus,
63 "SandyBridge-IBRS shouldn't be versioned")
64 self.assertNotIn("IvyBridge-IBRS-v1", cpus,
65 "IvyBridge-IBRS shouldn't be versioned")
66 self.assertNotIn("Haswell-noTSX-IBRS-v1", cpus,
67 "Haswell-noTSX-IBRS shouldn't be versioned")
68 self.assertNotIn("Haswell-IBRS-v1", cpus,
69 "Haswell-IBRS shouldn't be versioned")
70 self.assertNotIn("Broadwell-noTSX-IBRS-v1", cpus,
71 "Broadwell-noTSX-IBRS shouldn't be versioned")
72 self.assertNotIn("Broadwell-IBRS-v1", cpus,
73 "Broadwell-IBRS shouldn't be versioned")
74 self.assertNotIn("Skylake-Client-IBRS-v1", cpus,
75 "Skylake-Client-IBRS shouldn't be versioned")
76 self.assertNotIn("Skylake-Server-IBRS-v1", cpus,
77 "Skylake-Server-IBRS shouldn't be versioned")
78 self.assertNotIn("EPYC-IBPB-v1", cpus,
79 "EPYC-IBPB shouldn't be versioned")
81 def test_4_0_alias_compatibility(self):
82 """Check if pc-*-4.0 unversioned CPU model won't be reported as aliases"""
83 # pc-*-4.0 won't expose non-versioned CPU models as aliases
84 # We do this to help management software to keep compatibility
85 # with older QEMU versions that didn't have the versioned CPU model
86 self.vm.add_args('-S')
87 self.vm.set_machine('pc-i440fx-4.0')
88 self.vm.launch()
89 cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
91 self.assertFalse(cpus['Cascadelake-Server']['static'],
92 'unversioned Cascadelake-Server CPU model must not be static')
93 self.assertNotIn('alias-of', cpus['Cascadelake-Server'],
94 'Cascadelake-Server must not be an alias')
95 self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
96 'Cascadelake-Server-v1 must not be an alias')
98 self.assertFalse(cpus['qemu64']['static'],
99 'unversioned qemu64 CPU model must not be static')
100 self.assertNotIn('alias-of', cpus['qemu64'],
101 'qemu64 must not be an alias')
102 self.assertNotIn('alias-of', cpus['qemu64-v1'],
103 'qemu64-v1 must not be an alias')
105 self.validate_variant_aliases(cpus)
107 # On pc-*-4.0, no CPU model should be reported as an alias:
108 for name,c in cpus.items():
109 self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name))
111 def test_4_1_alias(self):
112 """Check if unversioned CPU model is an alias pointing to right version"""
113 self.vm.add_args('-S')
114 self.vm.set_machine('pc-i440fx-4.1')
115 self.vm.launch()
117 cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
119 self.assertFalse(cpus['Cascadelake-Server']['static'],
120 'unversioned Cascadelake-Server CPU model must not be static')
121 self.assertEquals(cpus['Cascadelake-Server'].get('alias-of'), 'Cascadelake-Server-v1',
122 'Cascadelake-Server must be an alias of Cascadelake-Server-v1')
123 self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
124 'Cascadelake-Server-v1 must not be an alias')
126 self.assertFalse(cpus['qemu64']['static'],
127 'unversioned qemu64 CPU model must not be static')
128 self.assertEquals(cpus['qemu64'].get('alias-of'), 'qemu64-v1',
129 'qemu64 must be an alias of qemu64-v1')
130 self.assertNotIn('alias-of', cpus['qemu64-v1'],
131 'qemu64-v1 must not be an alias')
133 self.validate_variant_aliases(cpus)
135 # On pc-*-4.1, -noTSX and -IBRS models should be aliases:
136 self.assertEquals(cpus["Haswell"].get('alias-of'),
137 "Haswell-v1",
138 "Haswell must be an alias")
139 self.assertEquals(cpus["Haswell-noTSX"].get('alias-of'),
140 "Haswell-v2",
141 "Haswell-noTSX must be an alias")
142 self.assertEquals(cpus["Haswell-IBRS"].get('alias-of'),
143 "Haswell-v3",
144 "Haswell-IBRS must be an alias")
145 self.assertEquals(cpus["Haswell-noTSX-IBRS"].get('alias-of'),
146 "Haswell-v4",
147 "Haswell-noTSX-IBRS must be an alias")
149 self.assertEquals(cpus["Broadwell"].get('alias-of'),
150 "Broadwell-v1",
151 "Broadwell must be an alias")
152 self.assertEquals(cpus["Broadwell-noTSX"].get('alias-of'),
153 "Broadwell-v2",
154 "Broadwell-noTSX must be an alias")
155 self.assertEquals(cpus["Broadwell-IBRS"].get('alias-of'),
156 "Broadwell-v3",
157 "Broadwell-IBRS must be an alias")
158 self.assertEquals(cpus["Broadwell-noTSX-IBRS"].get('alias-of'),
159 "Broadwell-v4",
160 "Broadwell-noTSX-IBRS must be an alias")
162 self.assertEquals(cpus["Nehalem"].get('alias-of'),
163 "Nehalem-v1",
164 "Nehalem must be an alias")
165 self.assertEquals(cpus["Nehalem-IBRS"].get('alias-of'),
166 "Nehalem-v2",
167 "Nehalem-IBRS must be an alias")
169 self.assertEquals(cpus["Westmere"].get('alias-of'),
170 "Westmere-v1",
171 "Westmere must be an alias")
172 self.assertEquals(cpus["Westmere-IBRS"].get('alias-of'),
173 "Westmere-v2",
174 "Westmere-IBRS must be an alias")
176 self.assertEquals(cpus["SandyBridge"].get('alias-of'),
177 "SandyBridge-v1",
178 "SandyBridge must be an alias")
179 self.assertEquals(cpus["SandyBridge-IBRS"].get('alias-of'),
180 "SandyBridge-v2",
181 "SandyBridge-IBRS must be an alias")
183 self.assertEquals(cpus["IvyBridge"].get('alias-of'),
184 "IvyBridge-v1",
185 "IvyBridge must be an alias")
186 self.assertEquals(cpus["IvyBridge-IBRS"].get('alias-of'),
187 "IvyBridge-v2",
188 "IvyBridge-IBRS must be an alias")
190 self.assertEquals(cpus["Skylake-Client"].get('alias-of'),
191 "Skylake-Client-v1",
192 "Skylake-Client must be an alias")
193 self.assertEquals(cpus["Skylake-Client-IBRS"].get('alias-of'),
194 "Skylake-Client-v2",
195 "Skylake-Client-IBRS must be an alias")
197 self.assertEquals(cpus["Skylake-Server"].get('alias-of'),
198 "Skylake-Server-v1",
199 "Skylake-Server must be an alias")
200 self.assertEquals(cpus["Skylake-Server-IBRS"].get('alias-of'),
201 "Skylake-Server-v2",
202 "Skylake-Server-IBRS must be an alias")
204 self.assertEquals(cpus["EPYC"].get('alias-of'),
205 "EPYC-v1",
206 "EPYC must be an alias")
207 self.assertEquals(cpus["EPYC-IBPB"].get('alias-of'),
208 "EPYC-v2",
209 "EPYC-IBPB must be an alias")
211 self.validate_aliases(cpus)
213 def test_none_alias(self):
214 """Check if unversioned CPU model is an alias pointing to some version"""
215 self.vm.add_args('-S')
216 self.vm.set_machine('none')
217 self.vm.launch()
219 cpus = dict((m['name'], m) for m in self.vm.command('query-cpu-definitions'))
221 self.assertFalse(cpus['Cascadelake-Server']['static'],
222 'unversioned Cascadelake-Server CPU model must not be static')
223 self.assertTrue(re.match('Cascadelake-Server-v[0-9]+', cpus['Cascadelake-Server']['alias-of']),
224 'Cascadelake-Server must be an alias of versioned CPU model')
225 self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
226 'Cascadelake-Server-v1 must not be an alias')
228 self.assertFalse(cpus['qemu64']['static'],
229 'unversioned qemu64 CPU model must not be static')
230 self.assertTrue(re.match('qemu64-v[0-9]+', cpus['qemu64']['alias-of']),
231 'qemu64 must be an alias of versioned CPU model')
232 self.assertNotIn('alias-of', cpus['qemu64-v1'],
233 'qemu64-v1 must not be an alias')
235 self.validate_aliases(cpus)
237 def test_Cascadelake_arch_capabilities_result(self):
238 # machine-type only:
239 vm = self.get_vm()
240 vm.add_args('-S')
241 vm.set_machine('pc-i440fx-4.1')
242 vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
243 vm.launch()
244 self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
245 'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities')
247 vm = self.get_vm()
248 vm.add_args('-S')
249 vm.set_machine('pc-i440fx-4.0')
250 vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off')
251 vm.launch()
252 self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
253 'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities')
255 # command line must override machine-type if CPU model is not versioned:
256 vm = self.get_vm()
257 vm.add_args('-S')
258 vm.set_machine('pc-i440fx-4.0')
259 vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities')
260 vm.launch()
261 self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
262 'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities')
264 vm = self.get_vm()
265 vm.add_args('-S')
266 vm.set_machine('pc-i440fx-4.1')
267 vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,-arch-capabilities')
268 vm.launch()
269 self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
270 'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities')
272 # versioned CPU model overrides machine-type:
273 vm = self.get_vm()
274 vm.add_args('-S')
275 vm.set_machine('pc-i440fx-4.0')
276 vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off')
277 vm.launch()
278 self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
279 'pc-i440fx-4.1 + Cascadelake-Server-v1 should not have arch-capabilities')
281 vm = self.get_vm()
282 vm.add_args('-S')
283 vm.set_machine('pc-i440fx-4.0')
284 vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off')
285 vm.launch()
286 self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
287 'pc-i440fx-4.1 + Cascadelake-Server-v1 should have arch-capabilities')
289 # command line must override machine-type and versioned CPU model:
290 vm = self.get_vm()
291 vm.add_args('-S')
292 vm.set_machine('pc-i440fx-4.0')
293 vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities')
294 vm.launch()
295 self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
296 'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
298 vm = self.get_vm()
299 vm.add_args('-S')
300 vm.set_machine('pc-i440fx-4.1')
301 vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off,-arch-capabilities')
302 vm.launch()
303 self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
304 'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capabilities should not have arch-capabilities')