From nobody Wed Nov 5 16:35:42 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.zoho.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 1496678411431711.3453468343632; Mon, 5 Jun 2017 09:00:11 -0700 (PDT) Received: from localhost ([::1]:34024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHuQK-0007PN-Ut for importer@patchew.org; Mon, 05 Jun 2017 12:00:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHuNN-0004gH-GR for qemu-devel@nongnu.org; Mon, 05 Jun 2017 11:57:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHuNK-0000pJ-EH for qemu-devel@nongnu.org; Mon, 05 Jun 2017 11:57:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47309) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dHuNK-0000on-6a for qemu-devel@nongnu.org; Mon, 05 Jun 2017 11:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A94DC04B31F; Mon, 5 Jun 2017 15:57:00 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 573BD7B12B; Mon, 5 Jun 2017 15:56:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A94DC04B31F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0A94DC04B31F From: Eduardo Habkost To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Mon, 5 Jun 2017 12:56:55 -0300 Message-Id: <20170605155655.19315-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 05 Jun 2017 15:57:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] 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: Igor Mammedov , Richard Henderson 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" Since the automatic cpuid-level code was introduced in commit c39c0edf9bb3b968ba95484465a50c7b19f4aa3a, 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" Signd-off-by: Eduardo Habkost Acked-by: Michael S. Tsirkin --- 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 e447f5d8f4..d071c9c0e9 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -566,75 +566,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,\ @@ -860,7 +860,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,\ @@ -868,7 +868,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,\ @@ -876,7 +876,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 6c71e46391..652216f531 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -313,6 +313,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 don't have any feature that triggers auto-level + * code on old machine-types. Just check if 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 /* Test feature parsing */ add_feature_test("x86/cpuid/features/plus", --=20 2.11.0.259.g40922b1