xref: /openbmc/qemu/tests/functional/test_x86_cpu_model_versions.py (revision eabebca69b7fca7cf85f6cd39ac58a7f04986b47)
1*be849ef7SThomas Huth#!/usr/bin/env python3
2*be849ef7SThomas Huth#
3*be849ef7SThomas Huth# Basic validation of x86 versioned CPU models and CPU model aliases
4*be849ef7SThomas Huth#
5*be849ef7SThomas Huth#  Copyright (c) 2019 Red Hat Inc
6*be849ef7SThomas Huth#
7*be849ef7SThomas Huth# Author:
8*be849ef7SThomas Huth#  Eduardo Habkost <ehabkost@redhat.com>
9*be849ef7SThomas Huth#
10*be849ef7SThomas Huth# This library is free software; you can redistribute it and/or
11*be849ef7SThomas Huth# modify it under the terms of the GNU Lesser General Public
12*be849ef7SThomas Huth# License as published by the Free Software Foundation; either
13*be849ef7SThomas Huth# version 2.1 of the License, or (at your option) any later version.
14*be849ef7SThomas Huth#
15*be849ef7SThomas Huth# This library is distributed in the hope that it will be useful,
16*be849ef7SThomas Huth# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*be849ef7SThomas Huth# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18*be849ef7SThomas Huth# Lesser General Public License for more details.
19*be849ef7SThomas Huth#
20*be849ef7SThomas Huth# You should have received a copy of the GNU Lesser General Public
21*be849ef7SThomas Huth# License along with this library; if not, see <http://www.gnu.org/licenses/>.
22*be849ef7SThomas Huth#
23*be849ef7SThomas Huth
24*be849ef7SThomas Huthimport re
25*be849ef7SThomas Huth
26*be849ef7SThomas Huthfrom qemu_test import QemuSystemTest
27*be849ef7SThomas Huth
28*be849ef7SThomas Huthclass X86CPUModelAliases(QemuSystemTest):
29*be849ef7SThomas Huth    """
30*be849ef7SThomas Huth    Validation of PC CPU model versions and CPU model aliases
31*be849ef7SThomas Huth    """
32*be849ef7SThomas Huth    def validate_aliases(self, cpus):
33*be849ef7SThomas Huth        for c in cpus.values():
34*be849ef7SThomas Huth            if 'alias-of' in c:
35*be849ef7SThomas Huth                # all aliases must point to a valid CPU model name:
36*be849ef7SThomas Huth                self.assertIn(c['alias-of'], cpus,
37*be849ef7SThomas Huth                              '%s.alias-of (%s) is not a valid CPU model name' % (c['name'], c['alias-of']))
38*be849ef7SThomas Huth                # aliases must not point to aliases
39*be849ef7SThomas Huth                self.assertNotIn('alias-of', cpus[c['alias-of']],
40*be849ef7SThomas Huth                                 '%s.alias-of (%s) points to another alias' % (c['name'], c['alias-of']))
41*be849ef7SThomas Huth
42*be849ef7SThomas Huth                # aliases must not be static
43*be849ef7SThomas Huth                self.assertFalse(c['static'])
44*be849ef7SThomas Huth
45*be849ef7SThomas Huth    def validate_variant_aliases(self, cpus):
46*be849ef7SThomas Huth        # -noTSX, -IBRS and -IBPB variants of CPU models are special:
47*be849ef7SThomas Huth        # they shouldn't have their own versions:
48*be849ef7SThomas Huth        self.assertNotIn("Haswell-noTSX-v1", cpus,
49*be849ef7SThomas Huth                         "Haswell-noTSX shouldn't be versioned")
50*be849ef7SThomas Huth        self.assertNotIn("Broadwell-noTSX-v1", cpus,
51*be849ef7SThomas Huth                         "Broadwell-noTSX shouldn't be versioned")
52*be849ef7SThomas Huth        self.assertNotIn("Nehalem-IBRS-v1", cpus,
53*be849ef7SThomas Huth                         "Nehalem-IBRS shouldn't be versioned")
54*be849ef7SThomas Huth        self.assertNotIn("Westmere-IBRS-v1", cpus,
55*be849ef7SThomas Huth                         "Westmere-IBRS shouldn't be versioned")
56*be849ef7SThomas Huth        self.assertNotIn("SandyBridge-IBRS-v1", cpus,
57*be849ef7SThomas Huth                         "SandyBridge-IBRS shouldn't be versioned")
58*be849ef7SThomas Huth        self.assertNotIn("IvyBridge-IBRS-v1", cpus,
59*be849ef7SThomas Huth                         "IvyBridge-IBRS shouldn't be versioned")
60*be849ef7SThomas Huth        self.assertNotIn("Haswell-noTSX-IBRS-v1", cpus,
61*be849ef7SThomas Huth                         "Haswell-noTSX-IBRS shouldn't be versioned")
62*be849ef7SThomas Huth        self.assertNotIn("Haswell-IBRS-v1", cpus,
63*be849ef7SThomas Huth                         "Haswell-IBRS shouldn't be versioned")
64*be849ef7SThomas Huth        self.assertNotIn("Broadwell-noTSX-IBRS-v1", cpus,
65*be849ef7SThomas Huth                         "Broadwell-noTSX-IBRS shouldn't be versioned")
66*be849ef7SThomas Huth        self.assertNotIn("Broadwell-IBRS-v1", cpus,
67*be849ef7SThomas Huth                         "Broadwell-IBRS shouldn't be versioned")
68*be849ef7SThomas Huth        self.assertNotIn("Skylake-Client-IBRS-v1", cpus,
69*be849ef7SThomas Huth                         "Skylake-Client-IBRS shouldn't be versioned")
70*be849ef7SThomas Huth        self.assertNotIn("Skylake-Server-IBRS-v1", cpus,
71*be849ef7SThomas Huth                         "Skylake-Server-IBRS shouldn't be versioned")
72*be849ef7SThomas Huth        self.assertNotIn("EPYC-IBPB-v1", cpus,
73*be849ef7SThomas Huth                         "EPYC-IBPB shouldn't be versioned")
74*be849ef7SThomas Huth
75*be849ef7SThomas Huth    def test_4_0_alias_compatibility(self):
76*be849ef7SThomas Huth        """
77*be849ef7SThomas Huth        Check if pc-*-4.0 unversioned CPU model won't be reported as aliases
78*be849ef7SThomas Huth        """
79*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
80*be849ef7SThomas Huth        # pc-*-4.0 won't expose non-versioned CPU models as aliases
81*be849ef7SThomas Huth        # We do this to help management software to keep compatibility
82*be849ef7SThomas Huth        # with older QEMU versions that didn't have the versioned CPU model
83*be849ef7SThomas Huth        self.vm.add_args('-S')
84*be849ef7SThomas Huth        self.vm.launch()
85*be849ef7SThomas Huth        cpus = dict((m['name'], m) for m in
86*be849ef7SThomas Huth                    self.vm.cmd('query-cpu-definitions'))
87*be849ef7SThomas Huth
88*be849ef7SThomas Huth        self.assertFalse(cpus['Cascadelake-Server']['static'],
89*be849ef7SThomas Huth                         'unversioned Cascadelake-Server CPU model must not be static')
90*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['Cascadelake-Server'],
91*be849ef7SThomas Huth                         'Cascadelake-Server must not be an alias')
92*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
93*be849ef7SThomas Huth                         'Cascadelake-Server-v1 must not be an alias')
94*be849ef7SThomas Huth
95*be849ef7SThomas Huth        self.assertFalse(cpus['qemu64']['static'],
96*be849ef7SThomas Huth                         'unversioned qemu64 CPU model must not be static')
97*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['qemu64'],
98*be849ef7SThomas Huth                         'qemu64 must not be an alias')
99*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['qemu64-v1'],
100*be849ef7SThomas Huth                         'qemu64-v1 must not be an alias')
101*be849ef7SThomas Huth
102*be849ef7SThomas Huth        self.validate_variant_aliases(cpus)
103*be849ef7SThomas Huth
104*be849ef7SThomas Huth        # On pc-*-4.0, no CPU model should be reported as an alias:
105*be849ef7SThomas Huth        for name,c in cpus.items():
106*be849ef7SThomas Huth            self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (name))
107*be849ef7SThomas Huth
108*be849ef7SThomas Huth    def test_4_1_alias(self):
109*be849ef7SThomas Huth        """
110*be849ef7SThomas Huth        Check if unversioned CPU model is an alias pointing to right version
111*be849ef7SThomas Huth        """
112*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.1')
113*be849ef7SThomas Huth        self.vm.add_args('-S')
114*be849ef7SThomas Huth        self.vm.launch()
115*be849ef7SThomas Huth
116*be849ef7SThomas Huth        cpus = dict((m['name'], m) for m in
117*be849ef7SThomas Huth                    self.vm.cmd('query-cpu-definitions'))
118*be849ef7SThomas Huth
119*be849ef7SThomas Huth        self.assertFalse(cpus['Cascadelake-Server']['static'],
120*be849ef7SThomas Huth                         'unversioned Cascadelake-Server CPU model must not be static')
121*be849ef7SThomas Huth        self.assertEqual(cpus['Cascadelake-Server'].get('alias-of'),
122*be849ef7SThomas Huth                         'Cascadelake-Server-v1',
123*be849ef7SThomas Huth                         'Cascadelake-Server must be an alias of Cascadelake-Server-v1')
124*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
125*be849ef7SThomas Huth                         'Cascadelake-Server-v1 must not be an alias')
126*be849ef7SThomas Huth
127*be849ef7SThomas Huth        self.assertFalse(cpus['qemu64']['static'],
128*be849ef7SThomas Huth                         'unversioned qemu64 CPU model must not be static')
129*be849ef7SThomas Huth        self.assertEqual(cpus['qemu64'].get('alias-of'), 'qemu64-v1',
130*be849ef7SThomas Huth                         'qemu64 must be an alias of qemu64-v1')
131*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['qemu64-v1'],
132*be849ef7SThomas Huth                         'qemu64-v1 must not be an alias')
133*be849ef7SThomas Huth
134*be849ef7SThomas Huth        self.validate_variant_aliases(cpus)
135*be849ef7SThomas Huth
136*be849ef7SThomas Huth        # On pc-*-4.1, -noTSX and -IBRS models should be aliases:
137*be849ef7SThomas Huth        self.assertEqual(cpus["Haswell"].get('alias-of'),
138*be849ef7SThomas Huth                         "Haswell-v1",
139*be849ef7SThomas Huth                         "Haswell must be an alias")
140*be849ef7SThomas Huth        self.assertEqual(cpus["Haswell-noTSX"].get('alias-of'),
141*be849ef7SThomas Huth                         "Haswell-v2",
142*be849ef7SThomas Huth                         "Haswell-noTSX must be an alias")
143*be849ef7SThomas Huth        self.assertEqual(cpus["Haswell-IBRS"].get('alias-of'),
144*be849ef7SThomas Huth                         "Haswell-v3",
145*be849ef7SThomas Huth                         "Haswell-IBRS must be an alias")
146*be849ef7SThomas Huth        self.assertEqual(cpus["Haswell-noTSX-IBRS"].get('alias-of'),
147*be849ef7SThomas Huth                         "Haswell-v4",
148*be849ef7SThomas Huth                         "Haswell-noTSX-IBRS must be an alias")
149*be849ef7SThomas Huth
150*be849ef7SThomas Huth        self.assertEqual(cpus["Broadwell"].get('alias-of'),
151*be849ef7SThomas Huth                         "Broadwell-v1",
152*be849ef7SThomas Huth                         "Broadwell must be an alias")
153*be849ef7SThomas Huth        self.assertEqual(cpus["Broadwell-noTSX"].get('alias-of'),
154*be849ef7SThomas Huth                         "Broadwell-v2",
155*be849ef7SThomas Huth                         "Broadwell-noTSX must be an alias")
156*be849ef7SThomas Huth        self.assertEqual(cpus["Broadwell-IBRS"].get('alias-of'),
157*be849ef7SThomas Huth                         "Broadwell-v3",
158*be849ef7SThomas Huth                         "Broadwell-IBRS must be an alias")
159*be849ef7SThomas Huth        self.assertEqual(cpus["Broadwell-noTSX-IBRS"].get('alias-of'),
160*be849ef7SThomas Huth                         "Broadwell-v4",
161*be849ef7SThomas Huth                         "Broadwell-noTSX-IBRS must be an alias")
162*be849ef7SThomas Huth
163*be849ef7SThomas Huth        self.assertEqual(cpus["Nehalem"].get('alias-of'),
164*be849ef7SThomas Huth                         "Nehalem-v1",
165*be849ef7SThomas Huth                         "Nehalem must be an alias")
166*be849ef7SThomas Huth        self.assertEqual(cpus["Nehalem-IBRS"].get('alias-of'),
167*be849ef7SThomas Huth                         "Nehalem-v2",
168*be849ef7SThomas Huth                         "Nehalem-IBRS must be an alias")
169*be849ef7SThomas Huth
170*be849ef7SThomas Huth        self.assertEqual(cpus["Westmere"].get('alias-of'),
171*be849ef7SThomas Huth                         "Westmere-v1",
172*be849ef7SThomas Huth                         "Westmere must be an alias")
173*be849ef7SThomas Huth        self.assertEqual(cpus["Westmere-IBRS"].get('alias-of'),
174*be849ef7SThomas Huth                         "Westmere-v2",
175*be849ef7SThomas Huth                         "Westmere-IBRS must be an alias")
176*be849ef7SThomas Huth
177*be849ef7SThomas Huth        self.assertEqual(cpus["SandyBridge"].get('alias-of'),
178*be849ef7SThomas Huth                         "SandyBridge-v1",
179*be849ef7SThomas Huth                         "SandyBridge must be an alias")
180*be849ef7SThomas Huth        self.assertEqual(cpus["SandyBridge-IBRS"].get('alias-of'),
181*be849ef7SThomas Huth                         "SandyBridge-v2",
182*be849ef7SThomas Huth                         "SandyBridge-IBRS must be an alias")
183*be849ef7SThomas Huth
184*be849ef7SThomas Huth        self.assertEqual(cpus["IvyBridge"].get('alias-of'),
185*be849ef7SThomas Huth                         "IvyBridge-v1",
186*be849ef7SThomas Huth                         "IvyBridge must be an alias")
187*be849ef7SThomas Huth        self.assertEqual(cpus["IvyBridge-IBRS"].get('alias-of'),
188*be849ef7SThomas Huth                         "IvyBridge-v2",
189*be849ef7SThomas Huth                         "IvyBridge-IBRS must be an alias")
190*be849ef7SThomas Huth
191*be849ef7SThomas Huth        self.assertEqual(cpus["Skylake-Client"].get('alias-of'),
192*be849ef7SThomas Huth                         "Skylake-Client-v1",
193*be849ef7SThomas Huth                         "Skylake-Client must be an alias")
194*be849ef7SThomas Huth        self.assertEqual(cpus["Skylake-Client-IBRS"].get('alias-of'),
195*be849ef7SThomas Huth                         "Skylake-Client-v2",
196*be849ef7SThomas Huth                         "Skylake-Client-IBRS must be an alias")
197*be849ef7SThomas Huth
198*be849ef7SThomas Huth        self.assertEqual(cpus["Skylake-Server"].get('alias-of'),
199*be849ef7SThomas Huth                         "Skylake-Server-v1",
200*be849ef7SThomas Huth                         "Skylake-Server must be an alias")
201*be849ef7SThomas Huth        self.assertEqual(cpus["Skylake-Server-IBRS"].get('alias-of'),
202*be849ef7SThomas Huth                         "Skylake-Server-v2",
203*be849ef7SThomas Huth                         "Skylake-Server-IBRS must be an alias")
204*be849ef7SThomas Huth
205*be849ef7SThomas Huth        self.assertEqual(cpus["EPYC"].get('alias-of'),
206*be849ef7SThomas Huth                         "EPYC-v1",
207*be849ef7SThomas Huth                         "EPYC must be an alias")
208*be849ef7SThomas Huth        self.assertEqual(cpus["EPYC-IBPB"].get('alias-of'),
209*be849ef7SThomas Huth                         "EPYC-v2",
210*be849ef7SThomas Huth                         "EPYC-IBPB must be an alias")
211*be849ef7SThomas Huth
212*be849ef7SThomas Huth        self.validate_aliases(cpus)
213*be849ef7SThomas Huth
214*be849ef7SThomas Huth    def test_none_alias(self):
215*be849ef7SThomas Huth        """
216*be849ef7SThomas Huth        Check if unversioned CPU model is an alias pointing to some version
217*be849ef7SThomas Huth        """
218*be849ef7SThomas Huth        self.set_machine('none')
219*be849ef7SThomas Huth        self.vm.add_args('-S')
220*be849ef7SThomas Huth        self.vm.launch()
221*be849ef7SThomas Huth
222*be849ef7SThomas Huth        cpus = dict((m['name'], m) for m in
223*be849ef7SThomas Huth                    self.vm.cmd('query-cpu-definitions'))
224*be849ef7SThomas Huth
225*be849ef7SThomas Huth        self.assertFalse(cpus['Cascadelake-Server']['static'],
226*be849ef7SThomas Huth                         'unversioned Cascadelake-Server CPU model must not be static')
227*be849ef7SThomas Huth        self.assertTrue(re.match('Cascadelake-Server-v[0-9]+', cpus['Cascadelake-Server']['alias-of']),
228*be849ef7SThomas Huth                        'Cascadelake-Server must be an alias of versioned CPU model')
229*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'],
230*be849ef7SThomas Huth                         'Cascadelake-Server-v1 must not be an alias')
231*be849ef7SThomas Huth
232*be849ef7SThomas Huth        self.assertFalse(cpus['qemu64']['static'],
233*be849ef7SThomas Huth                         'unversioned qemu64 CPU model must not be static')
234*be849ef7SThomas Huth        self.assertTrue(re.match('qemu64-v[0-9]+', cpus['qemu64']['alias-of']),
235*be849ef7SThomas Huth                        'qemu64 must be an alias of versioned CPU model')
236*be849ef7SThomas Huth        self.assertNotIn('alias-of', cpus['qemu64-v1'],
237*be849ef7SThomas Huth                         'qemu64-v1 must not be an alias')
238*be849ef7SThomas Huth
239*be849ef7SThomas Huth        self.validate_aliases(cpus)
240*be849ef7SThomas Huth
241*be849ef7SThomas Huth
242*be849ef7SThomas Huthclass CascadelakeArchCapabilities(QemuSystemTest):
243*be849ef7SThomas Huth    """
244*be849ef7SThomas Huth    Validation of Cascadelake arch-capabilities
245*be849ef7SThomas Huth    """
246*be849ef7SThomas Huth    def get_cpu_prop(self, prop):
247*be849ef7SThomas Huth        cpu_path = self.vm.cmd('query-cpus-fast')[0].get('qom-path')
248*be849ef7SThomas Huth        return self.vm.cmd('qom-get', path=cpu_path, property=prop)
249*be849ef7SThomas Huth
250*be849ef7SThomas Huth    def test_4_1(self):
251*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.1')
252*be849ef7SThomas Huth        # machine-type only:
253*be849ef7SThomas Huth        self.vm.add_args('-S')
254*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
255*be849ef7SThomas Huth                        'Cascadelake-Server,x-force-features=on,check=off,'
256*be849ef7SThomas Huth                        'enforce=off')
257*be849ef7SThomas Huth        self.vm.launch()
258*be849ef7SThomas Huth        self.assertFalse(self.get_cpu_prop('arch-capabilities'),
259*be849ef7SThomas Huth                         'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities')
260*be849ef7SThomas Huth
261*be849ef7SThomas Huth    def test_4_0(self):
262*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
263*be849ef7SThomas Huth        self.vm.add_args('-S')
264*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
265*be849ef7SThomas Huth                        'Cascadelake-Server,x-force-features=on,check=off,'
266*be849ef7SThomas Huth                        'enforce=off')
267*be849ef7SThomas Huth        self.vm.launch()
268*be849ef7SThomas Huth        self.assertFalse(self.get_cpu_prop('arch-capabilities'),
269*be849ef7SThomas Huth                         'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities')
270*be849ef7SThomas Huth
271*be849ef7SThomas Huth    def test_set_4_0(self):
272*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
273*be849ef7SThomas Huth        # command line must override machine-type if CPU model is not versioned:
274*be849ef7SThomas Huth        self.vm.add_args('-S')
275*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
276*be849ef7SThomas Huth                        'Cascadelake-Server,x-force-features=on,check=off,'
277*be849ef7SThomas Huth                        'enforce=off,+arch-capabilities')
278*be849ef7SThomas Huth        self.vm.launch()
279*be849ef7SThomas Huth        self.assertTrue(self.get_cpu_prop('arch-capabilities'),
280*be849ef7SThomas Huth                        'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities')
281*be849ef7SThomas Huth
282*be849ef7SThomas Huth    def test_unset_4_1(self):
283*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.1')
284*be849ef7SThomas Huth        self.vm.add_args('-S')
285*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
286*be849ef7SThomas Huth                        'Cascadelake-Server,x-force-features=on,check=off,'
287*be849ef7SThomas Huth                        'enforce=off,-arch-capabilities')
288*be849ef7SThomas Huth        self.vm.launch()
289*be849ef7SThomas Huth        self.assertFalse(self.get_cpu_prop('arch-capabilities'),
290*be849ef7SThomas Huth                         'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities')
291*be849ef7SThomas Huth
292*be849ef7SThomas Huth    def test_v1_4_0(self):
293*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
294*be849ef7SThomas Huth        # versioned CPU model overrides machine-type:
295*be849ef7SThomas Huth        self.vm.add_args('-S')
296*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
297*be849ef7SThomas Huth                        'Cascadelake-Server-v1,x-force-features=on,check=off,'
298*be849ef7SThomas Huth                        'enforce=off')
299*be849ef7SThomas Huth        self.vm.launch()
300*be849ef7SThomas Huth        self.assertFalse(self.get_cpu_prop('arch-capabilities'),
301*be849ef7SThomas Huth                         'pc-i440fx-4.0 + Cascadelake-Server-v1 should not have arch-capabilities')
302*be849ef7SThomas Huth
303*be849ef7SThomas Huth    def test_v2_4_0(self):
304*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
305*be849ef7SThomas Huth        self.vm.add_args('-S')
306*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
307*be849ef7SThomas Huth                        'Cascadelake-Server-v2,x-force-features=on,check=off,'
308*be849ef7SThomas Huth                        'enforce=off')
309*be849ef7SThomas Huth        self.vm.launch()
310*be849ef7SThomas Huth        self.assertTrue(self.get_cpu_prop('arch-capabilities'),
311*be849ef7SThomas Huth                        'pc-i440fx-4.0 + Cascadelake-Server-v2 should have arch-capabilities')
312*be849ef7SThomas Huth
313*be849ef7SThomas Huth    def test_v1_set_4_0(self):
314*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.0')
315*be849ef7SThomas Huth        # command line must override machine-type and versioned CPU model:
316*be849ef7SThomas Huth        self.vm.add_args('-S')
317*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
318*be849ef7SThomas Huth                        'Cascadelake-Server-v1,x-force-features=on,check=off,'
319*be849ef7SThomas Huth                        'enforce=off,+arch-capabilities')
320*be849ef7SThomas Huth        self.vm.launch()
321*be849ef7SThomas Huth        self.assertTrue(self.get_cpu_prop('arch-capabilities'),
322*be849ef7SThomas Huth                        'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
323*be849ef7SThomas Huth
324*be849ef7SThomas Huth    def test_v2_unset_4_1(self):
325*be849ef7SThomas Huth        self.set_machine('pc-i440fx-4.1')
326*be849ef7SThomas Huth        self.vm.add_args('-S')
327*be849ef7SThomas Huth        self.set_vm_arg('-cpu',
328*be849ef7SThomas Huth                        'Cascadelake-Server-v2,x-force-features=on,check=off,'
329*be849ef7SThomas Huth                        'enforce=off,-arch-capabilities')
330*be849ef7SThomas Huth        self.vm.launch()
331*be849ef7SThomas Huth        self.assertFalse(self.get_cpu_prop('arch-capabilities'),
332*be849ef7SThomas Huth                         'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capabilities should not have arch-capabilities')
333*be849ef7SThomas Huth
334*be849ef7SThomas Huthif __name__ == '__main__':
335*be849ef7SThomas Huth    QemuSystemTest.main()
336