From nobody Tue Nov 4 15:46:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503968078060755.4681957558523; Mon, 28 Aug 2017 17:54:38 -0700 (PDT) Received: from localhost ([::1]:42099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUnb-0001lE-Os for importer@patchew.org; Mon, 28 Aug 2017 20:54:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCe-0001V1-VC for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCb-0005kv-JP for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCb-0005jZ-AK for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0FKh1044218 for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmsrsj1vk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:19 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:16 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GGNN30015690; Tue, 29 Aug 2017 00:16:16 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66DDF124050; Mon, 28 Aug 2017 20:13:36 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 2FBBD124035; Mon, 28 Aug 2017 20:13:36 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:26 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603F83 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964A96 Message-Id: <1503965694-10794-52-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 51/79] pc: Use "min-[x]level" on compat_props X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eduardo Habkost Since the automatic cpuid-level code was introduced in commit c39c0edf9bb3b968ba95484465a50c7b19f4aa3a ("target-i386: Automatically set level/xlevel/xlevel2 when needed"), the CPU model tables just define the default CPUID level code (set using "min-level"). Setting "[x]level" forces CPUID level to a specific value and disable the automatic-level logic. But the PC compat code was not updated and the existing "[x]level" compat properties broke compatibility for people using features that triggered the auto-level code. To keep previous behavior, we should set "min-[x]level" instead of "[x]level" on compat_props. This was not a problem for most cases, because old machine-types don't have full-cpuid-auto-level enabled. The only common use case it broke was the CPUID[7] auto-level code, that was already enabled since the first CPUID[7] feature was introduced (in QEMU 1.4.0). This causes the regression reported at: https://bugzilla.redhat.com/show_bug.cgi?id=3D1454641 Change the PC compat code to use "min-[x]level" instead of "[x]level" on compat_props, and add new test cases to ensure we don't break this again. Reported-by: "Guo, Zhiyi" Fixes: c39c0edf9bb ("target-i386: Automatically set level/xlevel/xlevel2 wh= en needed") Cc: qemu-stable@nongnu.org Acked-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost (cherry picked from commit 1f43571604da85c62f25f3ba6d275b1b5ea76ca2) Signed-off-by: Michael Roth --- include/hw/i386/pc.h | 42 +++++++++++++++++++++------------------= --- tests/test-x86-cpuid-compat.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f278b3a..564486f 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -558,75 +558,75 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64= _t *); .value =3D "off",\ },{\ .driver =3D "qemu64" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(4),\ },{\ .driver =3D "kvm64" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(5),\ },{\ .driver =3D "pentium3" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(2),\ },{\ .driver =3D "n270" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(5),\ },{\ .driver =3D "Conroe" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(4),\ },{\ .driver =3D "Penryn" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(4),\ },{\ .driver =3D "Nehalem" "-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(4),\ },{\ .driver =3D "n270" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Penryn" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Conroe" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Nehalem" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Westmere" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "SandyBridge" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "IvyBridge" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Haswell" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Haswell-noTSX" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Broadwell" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D "Broadwell-noTSX" "-" TYPE_X86_CPU,\ - .property =3D "xlevel",\ + .property =3D "min-xlevel",\ .value =3D stringify(0x8000000a),\ },{\ .driver =3D TYPE_X86_CPU,\ @@ -852,7 +852,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t= *); .value =3D stringify(2),\ },{\ .driver =3D "Conroe-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(2),\ },{\ .driver =3D "Penryn-" TYPE_X86_CPU,\ @@ -860,7 +860,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t= *); .value =3D stringify(2),\ },{\ .driver =3D "Penryn-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(2),\ },{\ .driver =3D "Nehalem-" TYPE_X86_CPU,\ @@ -868,7 +868,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t= *); .value =3D stringify(2),\ },{\ .driver =3D "Nehalem-" TYPE_X86_CPU,\ - .property =3D "level",\ + .property =3D "min-level",\ .value =3D stringify(2),\ },{\ .driver =3D "virtio-net-pci",\ diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 79a2e69..b449f54 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -228,6 +228,44 @@ int main(int argc, char **argv) add_cpuid_test("x86/cpuid/auto-xlevel2/pc-2.7", "-machine pc-i440fx-2.7 -cpu 486,+xstore", "xlevel2", 0); + /* + * QEMU 1.4.0 had auto-level enabled for CPUID[7], already, + * and the compat code that sets default level shouldn't + * disable the auto-level=3D7 code: + */ + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-1.4/off", + "-machine pc-i440fx-1.4 -cpu Nehalem", + "level", 2); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-1.5/on", + "-machine pc-i440fx-1.4 -cpu Nehalem,+smap", + "level", 7); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.3/off", + "-machine pc-i440fx-2.3 -cpu Penryn", + "level", 4); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.3/on", + "-machine pc-i440fx-2.3 -cpu Penryn,+erms", + "level", 7); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.9/off", + "-machine pc-i440fx-2.9 -cpu Conroe", + "level", 10); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.9/on", + "-machine pc-i440fx-2.9 -cpu Conroe,+erms", + "level", 10); + + /* + * xlevel doesn't have any feature that triggers auto-level + * code on old machine-types. Just check that the compat code + * is working correctly: + */ + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.3", + "-machine pc-i440fx-2.3 -cpu SandyBridge", + "xlevel", 0x8000000a); + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-off", + "-machine pc-i440fx-2.4 -cpu SandyBridge,", + "xlevel", 0x80000008); + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-on", + "-machine pc-i440fx-2.4 -cpu SandyBridge,+npt", + "xlevel", 0x80000008); =20 return g_test_run(); } --=20 2.7.4