From nobody Sun Feb 8 15:41:30 2026 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 1496689285448786.7879075906312; Mon, 5 Jun 2017 12:01:25 -0700 (PDT) Received: from localhost ([::1]:34726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxFi-0002sy-Dv for importer@patchew.org; Mon, 05 Jun 2017 15:01:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHxE0-0001ht-PO for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHxDy-0007k8-SG for qemu-devel@nongnu.org; Mon, 05 Jun 2017 14:59:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dHxDy-0007jL-KK; Mon, 05 Jun 2017 14:59:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75CECC0467C7; Mon, 5 Jun 2017 18:59:33 +0000 (UTC) Received: from localhost (ovpn-116-6.gru2.redhat.com [10.97.116.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3ED286E0D; Mon, 5 Jun 2017 18:59:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75CECC0467C7 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 75CECC0467C7 From: Eduardo Habkost To: Peter Maydell , Stefan Hajnoczi Date: Mon, 5 Jun 2017 15:59:18 -0300 Message-Id: <20170605185927.12111-2-ehabkost@redhat.com> In-Reply-To: <20170605185927.12111-1-ehabkost@redhat.com> References: <20170605185927.12111-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 05 Jun 2017 18:59:33 +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] [PULL 01/10] 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-devel@nongnu.org, qemu-stable@nongnu.org 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 ("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 --- 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..4166ce54b7 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 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 /* Test feature parsing */ add_feature_test("x86/cpuid/features/plus", --=20 2.11.0.259.g40922b1