From patchwork Thu May 8 13:35:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 888602 Delivered-To: patch@linaro.org Received: by 2002:adf:b60d:0:b0:3a1:f579:ae88 with SMTP id f13csp9222wre; Thu, 8 May 2025 06:43:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUg6nQQ0vXvIw+IWEX03vLJHuOgku+xijNAd0goIJEt1KxwjaKLW/KHxCT77LmQ8rEQo602YQ==@linaro.org X-Google-Smtp-Source: AGHT+IGDrot+wXG1MkEQEWe/QwTi6rJemm7RV6E8rPLPcP9YHAcQBUrBT5sZPRmBoUbXeuTiY5Pt X-Received: by 2002:a05:6214:f03:b0:6f2:a457:19a with SMTP id 6a1803df08f44-6f542ad7344mr129467426d6.25.1746711811570; Thu, 08 May 2025 06:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746711811; cv=none; d=google.com; s=arc-20240605; b=iBoJ2cr06a/ySCjIN5a4R1d6OdaXmSt6TPdRnqAhTEwHE1rM4mPl1WtK8BqKUhxv/L 34RW9nGBytIgu6p5RAenPiDr3KRZ8JP1hnFo9ybkOra/blNT5w4Ekm2tn2nboBDwZodU P+vt5F3axmtMbBUMzIgUm9E0jXuMOIqXMAzJv7pIMgIgysHC4SVon3RDuixnOz/zYrD8 AJAOV8M62y/P00GBAAfiNGPZbTK6/Z6ehIbjNvWAqrMHGX/SCQbxOqMzw9CimRmW8OsW /U+j1LOHmcSb55pBK++17XucfM8YsEc7J1ctK+t2qJ159HSDWSi4AX3s4A7MUjWnF9V1 824w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4ftaUxFMOJWyPcpYYJywN7GZrXuW4pScDj+n5IUMy18=; fh=t4sCPXSJJxzszaJF+1Mm6mpQfCAwhf2cujSX+L6g5pY=; b=hhu+ID0LBzpVtVg6VWuUSYGCvA02mwarDZqpQ6fcrjBZ56fHJEpn+Iffr450nyC0ay u7RskeQH4jxC/5bKyjN5y31omaBCuurdOsa7vjOXqzuEesc76aUc46LKgQKzfIKlKJZ7 bbfIYn3Qjdwn1xpw5QQMGAqiymvFC3LHVnSRF3Q/44SH9DacciiGScq0cnnu4fPKCiDp kNNm65cD/W/7iWZTiak5+dXqHMo/PH9JJtdsbaVscSUuvk1hL+6muMbv96B04D9KmW0i o82Lpxgw3fO73bJe4Mn2DyMSiD1ANt5Zvo3JWZ4irFooCxgq/cxvNRQme3yLXN+F7EpB FNbA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRQBUfY7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f5427c576bsi41950066d6.334.2025.05.08.06.43.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 May 2025 06:43:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRQBUfY7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uD1Wv-0005bz-09; Thu, 08 May 2025 09:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uD1Ws-0005VZ-Nw for qemu-devel@nongnu.org; Thu, 08 May 2025 09:43:14 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uD1Wo-0004oz-Rl for qemu-devel@nongnu.org; Thu, 08 May 2025 09:43:14 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-227b828de00so9655645ad.1 for ; Thu, 08 May 2025 06:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746711789; x=1747316589; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4ftaUxFMOJWyPcpYYJywN7GZrXuW4pScDj+n5IUMy18=; b=vRQBUfY7jAiZ/J9ugccgjCUdR2u2+nXIZQmL6kBfZAk1ZSeSh40LZ90aLQO21+IioW NxITz0Ciu37fwZuRs0SmjXn4L+SHfg9LpPlfsGwKSf8hx89j4OpWj+Nj/LE4QnVEMDu9 jyGJTrDaUWeQGJS3nFpa/R1GGzn9+rRBuLgZ5Dhh23JVMd++guV8hgb6aGFp08zeuiTG 1wISoj/yVpC0Wi03MjPimedKboyOhUokIrI91iqhe1yXUs7HakMfYYRax2u7GL1qk2ge N4b4XHmb+DQz8s7sT8qWusXWtRIB8hXDSmCP10t8L+sp63Ql1gieW9Vb/UF0LvK2utJQ z9Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746711789; x=1747316589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ftaUxFMOJWyPcpYYJywN7GZrXuW4pScDj+n5IUMy18=; b=qyKDphJzaz7IzpRrzSrt/9U1HTP5nn1xT1m/PZuBtQjws082CZ2+X/WKVRTFg+wxdL X0+KaVfWwCQrwjAk9gJxxbeOjcb08mHaDHcW81Nlu3N0td0RtBP8tw48tGPn6bBx15Ph hQNjDQ3fRKJW03rt9K4A4dTNs/oRF44/y7lMrNHGpjV5bGC2huwCpav3eCi1Xt0H2ZD0 qMRYqpemh8S558ZG/cJCh5vjTR8owid6i+6kA78T32eendUxD+carXITdsykOMotldVS HMp4UIy48ZH4OaU72MrGa6WBthJpxk4w3kG0ykrLLavlWJqfK5S3FYwtNjEJD6xZRGm7 sbxA== X-Gm-Message-State: AOJu0YxqOFA/661PUqdNM617VvT2s0WpIM+b2SBdwQvcLUhfRuqySze3 xj0mupsvRZC6wemeFL51pNt+1pArIPNHA5SnNoT89pLO/m7uAKbN+/CpxzXce7lZ0lZjRTrCydi TpTz1ug== X-Gm-Gg: ASbGncs3W9pyRC741b2yzZVhpqj5Sh2BSyqZDluGys3005TzkzEjwBIeJ46bM1IfNL3 z0hbre3Bj3FFe6q2nJCrC+qPW3cfRC1CmASMOVkA4MNHlCt2Wse4y2iz92r2U9w9IbEESzTVWqF LavetnUjBV2oj76QxY6YnHr8Y9TnUQoO8hA+uy7i8L0k6Mcpzcfhg77L/t79Zn5XoQxmuA/k7QC xaS+cll4kU8DGstdPJImUmQWNoS3vzUQWj9xzxmogJgsHlB+JwezLnMpf2Zo0Z49/pUq8fGpx92 ouWIGs3640sadg4b7kfArpQwl1SQW+V/Etu8+ZzvugV+tx/67tK233DRZdjfh8jSeKw9XrYjYSk 7qe6ks850vJcqHYI= X-Received: by 2002:a17:903:2310:b0:223:62f5:fd44 with SMTP id d9443c01a7336-22e5ec997b4mr119109545ad.40.1746711787379; Thu, 08 May 2025 06:43:07 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b22b0594a67sm240599a12.23.2025.05.08.06.42.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 May 2025 06:43:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , kvm@vger.kernel.org, Sergio Lopez , Gerd Hoffmann , Peter Maydell , Laurent Vivier , Jiaxun Yang , Yi Liu , "Michael S. Tsirkin" , Eduardo Habkost , Marcel Apfelbaum , Alistair Francis , Daniel Henrique Barboza , Marcelo Tosatti , qemu-riscv@nongnu.org, Weiwei Li , Amit Shah , Zhao Liu , Yanan Wang , Helge Deller , Palmer Dabbelt , Ani Sinha , Igor Mammedov , Fabiano Rosas , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Liu Zhiwei , =?utf-8?q?Cl=C3=A9ment_Mathieu--?= =?utf-8?q?Drif?= , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Huacai Chen , Jason Wang Subject: [PATCH v4 19/27] target/i386/cpu: Remove CPUX86State::full_cpuid_auto_level field Date: Thu, 8 May 2025 15:35:42 +0200 Message-ID: <20250508133550.81391-20-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250508133550.81391-1-philmd@linaro.org> References: <20250508133550.81391-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The CPUX86State::full_cpuid_auto_level boolean was only disabled for the pc-q35-2.7 and pc-i440fx-2.7 machines, which got removed. Being now always %true, we can remove it and simplify x86_cpu_expand_features(). Signed-off-by: Philippe Mathieu-Daudé --- target/i386/cpu.h | 3 -- target/i386/cpu.c | 106 ++++++++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 58 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7585407da54..b5cbd91c156 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2241,9 +2241,6 @@ struct ArchCPU { */ bool legacy_multi_node; - /* Enable auto level-increase for all CPUID leaves */ - bool full_cpuid_auto_level; - /* Only advertise CPUID leaves defined by the vendor */ bool vendor_cpuid_only; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fb505d13122..6b9a1f2251a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7843,68 +7843,65 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp) /* CPUID[EAX=7,ECX=0].EBX always increased level automatically: */ x86_cpu_adjust_feat_level(cpu, FEAT_7_0_EBX); - if (cpu->full_cpuid_auto_level) { - x86_cpu_adjust_feat_level(cpu, FEAT_1_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_1_ECX); - x86_cpu_adjust_feat_level(cpu, FEAT_6_EAX); - x86_cpu_adjust_feat_level(cpu, FEAT_7_0_ECX); - x86_cpu_adjust_feat_level(cpu, FEAT_7_1_EAX); - x86_cpu_adjust_feat_level(cpu, FEAT_7_1_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_7_2_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_ECX); - x86_cpu_adjust_feat_level(cpu, FEAT_8000_0007_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_8000_0008_EBX); - x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX); - x86_cpu_adjust_feat_level(cpu, FEAT_SVM); - x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); + x86_cpu_adjust_feat_level(cpu, FEAT_1_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_1_ECX); + x86_cpu_adjust_feat_level(cpu, FEAT_6_EAX); + x86_cpu_adjust_feat_level(cpu, FEAT_7_0_ECX); + x86_cpu_adjust_feat_level(cpu, FEAT_7_1_EAX); + x86_cpu_adjust_feat_level(cpu, FEAT_7_1_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_7_2_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_8000_0001_ECX); + x86_cpu_adjust_feat_level(cpu, FEAT_8000_0007_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_8000_0008_EBX); + x86_cpu_adjust_feat_level(cpu, FEAT_C000_0001_EDX); + x86_cpu_adjust_feat_level(cpu, FEAT_SVM); + x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); - /* Intel Processor Trace requires CPUID[0x14] */ - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) { - if (cpu->intel_pt_auto_level) { - x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14); - } else if (cpu->env.cpuid_min_level < 0x14) { - mark_unavailable_features(cpu, FEAT_7_0_EBX, - CPUID_7_0_EBX_INTEL_PT, - "Intel PT need CPUID leaf 0x14, please set by \"-cpu ...,intel-pt=on,min-level=0x14\""); - } + /* Intel Processor Trace requires CPUID[0x14] */ + if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) { + if (cpu->intel_pt_auto_level) { + x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14); + } else if (cpu->env.cpuid_min_level < 0x14) { + mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT, + "Intel PT need CPUID leaf 0x14, please set by \"-cpu ...,intel-pt=on,min-level=0x14\""); } + } - /* - * Intel CPU topology with multi-dies support requires CPUID[0x1F]. - * For AMD Rome/Milan, cpuid level is 0x10, and guest OS should detect - * extended toplogy by leaf 0xB. Only adjust it for Intel CPU, unless - * cpu->vendor_cpuid_only has been unset for compatibility with older - * machine types. - */ - if (x86_has_extended_topo(env->avail_cpu_topo) && - (IS_INTEL_CPU(env) || !cpu->vendor_cpuid_only)) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x1F); - } + /* + * Intel CPU topology with multi-dies support requires CPUID[0x1F]. + * For AMD Rome/Milan, cpuid level is 0x10, and guest OS should detect + * extended toplogy by leaf 0xB. Only adjust it for Intel CPU, unless + * cpu->vendor_cpuid_only has been unset for compatibility with older + * machine types. + */ + if (x86_has_extended_topo(env->avail_cpu_topo) && + (IS_INTEL_CPU(env) || !cpu->vendor_cpuid_only)) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x1F); + } - /* Advanced Vector Extensions 10 (AVX10) requires CPUID[0x24] */ - if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x24); - } + /* Advanced Vector Extensions 10 (AVX10) requires CPUID[0x24] */ + if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x24); + } - /* SVM requires CPUID[0x8000000A] */ - if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); - } + /* SVM requires CPUID[0x8000000A] */ + if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); + } - /* SEV requires CPUID[0x8000001F] */ - if (sev_enabled()) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); - } + /* SEV requires CPUID[0x8000001F] */ + if (sev_enabled()) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); + } - if (env->features[FEAT_8000_0021_EAX]) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x80000021); - } + if (env->features[FEAT_8000_0021_EAX]) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x80000021); + } - /* SGX requires CPUID[0x12] for EPC enumeration */ - if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_SGX) { - x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x12); - } + /* SGX requires CPUID[0x12] for EPC enumeration */ + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_SGX) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x12); } /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set */ @@ -8820,7 +8817,6 @@ static const Property x86_cpu_properties[] = { DEFINE_PROP_UINT32("min-xlevel2", X86CPU, env.cpuid_min_xlevel2, 0), DEFINE_PROP_UINT8("avx10-version", X86CPU, env.avx10_version, 0), DEFINE_PROP_UINT64("ucode-rev", X86CPU, ucode_rev, 0), - DEFINE_PROP_BOOL("full-cpuid-auto-level", X86CPU, full_cpuid_auto_level, true), DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor), DEFINE_PROP_BOOL("x-vendor-cpuid-only", X86CPU, vendor_cpuid_only, true), DEFINE_PROP_BOOL("x-amd-topoext-features-only", X86CPU, amd_topoext_features_only, true),