From nobody Thu Jan 8 13:18:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1766829168; cv=none; d=zohomail.com; s=zohoarc; b=AsNDliUevErssRluG9tc45T6WPI3FuqRdGTu7FbTiEhnYaGALmv4eUDXcUAgrTmqERTuz4u4Th/8iinmGHOA/9VKbqhMFhkkJH5Si3VOlq7OJ2/eRpG3d2sNJBcvuz9bL+ia1AV5EfQwJMPGGx3xVF5jCXTLxlFmZgVo3yVW17g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766829168; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DCo0WW35FwlSIdHbwn+36kcSmEpNticlzRreJHisgYM=; b=C3tWKRSsYz0n7VW/1ttCRljquuKAHg+TlyfZLsSYNpJFQyrsVKjs84eQBI9Sov3vK0hem/HKJD3y2W0cSliuOXaLMmnx8zDFwlWe+ncd4A5JUMY57ziTi5l4NyY3zxM1fCMVjYmy1eE0HQdhXGTWA5UKTB6170kooMs0JX75/dY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1766829168942959.8665985656922; Sat, 27 Dec 2025 01:52:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vZQvE-0004eK-QA; Sat, 27 Dec 2025 04:49:16 -0500 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 1vZQvD-0004bh-Fq for qemu-devel@nongnu.org; Sat, 27 Dec 2025 04:49:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vZQvB-0006zf-Dw for qemu-devel@nongnu.org; Sat, 27 Dec 2025 04:49:15 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-VkSZEnxoNFWzTUGzrp_FEw-1; Sat, 27 Dec 2025 04:49:11 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-47a83800743so43407965e9.0 for ; Sat, 27 Dec 2025 01:49:11 -0800 (PST) Received: from [192.168.10.48] ([151.95.145.106]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be26a81b6sm499566245e9.0.2025.12.27.01.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 01:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766828952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DCo0WW35FwlSIdHbwn+36kcSmEpNticlzRreJHisgYM=; b=Sm1uaBYSa2zDgDDnwDRNaVFZ0yz1xww2dzX+eR0g02gwJJ7bxS2lqYZ/L6TFynbdXcNYBI J95mLnzo79/vWwfFXw8RfRZ1niuMuqkU8UBwzlRg3DEG7+qVm1E+t7G8yN0TzW/l0raoyX 2a5GI6oe26LI4oH6jwQx5Ea/m/MhAKg= X-MC-Unique: VkSZEnxoNFWzTUGzrp_FEw-1 X-Mimecast-MFC-AGG-ID: VkSZEnxoNFWzTUGzrp_FEw_1766828950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766828949; x=1767433749; 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=DCo0WW35FwlSIdHbwn+36kcSmEpNticlzRreJHisgYM=; b=Jy8+Dl1maT6GrD6rHxv3J2oVJmSVwXasJj++udYhwGwQBlyPMGv46cnjTssOp2ACYA RuFQBCYpsVSlDvD5ejJlB34BaK+sXZB6RVjYzdUBT5FCrjSHG/CoNwLACCDI8Y344ys4 5S38KtFi/iuuLngRVV3Beoy+Dg87EP5ENDjD3krtGjN6iSpZ1jWgY1isKuKuO0+45qRT KHbR1kd+knB8hYsMt6npvrnM3sdxCryZXloweGI06Zphsx+ef8DKtlIYKJxrqGc4x/Rq bZ/6c1nY8BOkKHU4vHH4wIzE1Sr/EHAQ1TvC8vmDjOX061zqyH7DZh2A9gYFgpXXsS+k EuRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766828949; x=1767433749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DCo0WW35FwlSIdHbwn+36kcSmEpNticlzRreJHisgYM=; b=ZMo1POsB3FjeEGhb6EAVgGbg4QIBP5cghcq86WXiittwFKx1XtHtv40Orh+G7Yy5q9 cN2zHIHfRSO6TgPKsPxHOwHJONoRhO6ZI6Ohrp3ptWXm/SkYxkVRf3LRoUxqKds+hIXY 8LHoqCsVXeGTVlkb+PJBHCyG+9MuwjX9iCLISLIL10sKj2LRqcBkpmwXE07cxba1X5Dp /CrdubQ8sLu+T5ch144hWo41MLfDqLaCK8zCoGs4VKBiJevHa9SNhexBTEEwzuJY3RBe cs3i/p9sK7Vud3arUS1RDo+ttyrLRQmtCxFpUDOEKob0qnBPcAfQfaQgrfEYpx3UFFv8 N2Vg== X-Gm-Message-State: AOJu0YyVR3/VgmuUdELHiyDCReWvrXuggNPgopWilCTGrGkm0O7A9sje Lky3NCKnaxaANqI2YW24maVRA8v0NgH2NmzCsVnaDNoTg8SmfgWiofIGPa4DqXMkY5X5UWBQFcr iItD/sfNW0mD4QVoZAaRr8yh9H+J5A6JVXbzeNqtipR29+dLJld4DMx162+u7ClNXLH1WC32bd4 33J+3K1u42XRmVZCmIm0jgVQLLP4L/fbJsTVf1otPx X-Gm-Gg: AY/fxX5YL7HW7EQOmZv0ZZoUF2DwYP3o+LQCCGDSaVJmOsyu81CxzCV1rVt3ixDDK8K imcxdIdRuY9+I9nK8vWNlT27P7FwC8xOHyWo3JbDXshBlbiPpQksJ1aFgn9YYEYvslfMgy3+sWt O3VqPLSZscmleXlKl5GWDu545y3BRnVzZr4drzJfV3/9uAGmmD8C22qhDwaubNliysv6Uk22CFk FFy+7PfVOjnq+BAixbSRKw1coCiRY1Q7JetlCEDAV0WmZ1gEoMmApP2yH/oHDuxRg8pLpyHuIm+ Iivs2Izin6THNP0cxWomV0PcJQJei5JW4BFvKxPNodpsr80AHOQ1XDNxo07H4FjxTQFFF3Pnfpf rPNa9Up0vbvRgFW71HGbuQ8999K625Ro17PGZ3cCMR5PflSEWfKs6aO9Hhd6WEZ4k4R2YPLALyF VCbt8NUC8IBnMrhpY= X-Received: by 2002:a05:600c:8b82:b0:47b:deb9:163d with SMTP id 5b1f17b1804b1-47d18b99b99mr262142495e9.7.1766828948834; Sat, 27 Dec 2025 01:49:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IErKeyc4GIUQr2bEY7GdiO3LuoT+sQ2Qbc9eFpOCuNjKYa2268P8sjkr1sSqmHIwKDMMgweVA== X-Received: by 2002:a05:600c:8b82:b0:47b:deb9:163d with SMTP id 5b1f17b1804b1-47d18b99b99mr262142305e9.7.1766828948414; Sat, 27 Dec 2025 01:49:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu , Farrah Chen , Zide Chen , Xiaoyao Li , Xudong Hao , Peter Fang Subject: [PULL 102/153] i386/cpu: Support APX CPUIDs Date: Sat, 27 Dec 2025 10:47:07 +0100 Message-ID: <20251227094759.35658-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251227091622.20725-1-pbonzini@redhat.com> References: <20251227091622.20725-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1766829169385158500 Content-Type: text/plain; charset="utf-8" From: Zhao Liu APX is enumerated by CPUID.(EAX=3D0x7, ECX=3D1).EDX[21]. And this feature bit also indicates the existence of dedicated CPUID leaf 0x29, called the Intel APX Advanced Performance Extensions Leaf. This new CPUID leaf now is populated with enumerations for a select set of Intel APX sub-features. CPUID.(EAX=3D0x29, ECX=3D0) - EAX * Maximum Subleaf CPUID.(EAX=3D0x29, ECX=3D0).EAX[31:0] =3D 0 - EBX * Reserved CPUID.(EAX=3D0x29, ECX=3D0).EBX[31:1] =3D 0 * APX_NCI_NDD_NF CPUID.(EAX=3D0x29, ECX=3D0).EBX[0:0] =3D 1, which enumerates the presence of New Conditional Instructions (NCIs), explicit New Data Destination (NDD) controls, and explicit Flags Suppression (NF) controls for select sets of EVEX-encoded Intel APX instructions (present in EVEX map=3D4, and EVEX map=3D2 0x0F38). - ECX * Reserved CPUID.(EAX=3D0x29, ECX=3D0).ECX[31:0] =3D 0 - EDX * Reserved CPUID.(EAX=3D0x29, ECX=3D0).EDX[31:0] =3D 0 Note, APX_NCI_NDD_NF is documented as always enabled for Intel processors since APX spec (revision v7.0). Now any Intel processor that enumerates support for APX_F (CPUID.(EAX=3D0x7, ECX=3D1).EDX[21]) will also enumerate support for APX_NCI_NDD_NF. Tested-by: Xudong Hao Co-developed-by: Zide Chen Signed-off-by: Zide Chen Co-developed-by: Peter Fang Signed-off-by: Peter Fang Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20251211070942.3612547-9-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 8 ++++++++ target/i386/cpu.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 691ed974684..fc634883649 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -710,6 +710,7 @@ typedef enum FeatureWord { FEAT_7_1_EDX, /* CPUID[EAX=3D7,ECX=3D1].EDX */ FEAT_7_2_EDX, /* CPUID[EAX=3D7,ECX=3D2].EDX */ FEAT_24_0_EBX, /* CPUID[EAX=3D0x24,ECX=3D0].EBX */ + FEAT_29_0_EBX, /* CPUID[EAX=3D0x29,ECX=3D0].EBX */ FEATURE_WORDS, } FeatureWord; =20 @@ -1092,6 +1093,13 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w); CPUID_24_0_EBX_AVX10_256 | \ CPUID_24_0_EBX_AVX10_512) =20 +/* + * New Conditional Instructions (NCIs), explicit New Data Destination (NDD) + * controls, and explicit Flags Suppression (NF) controls for select sets = of + * EVEX-encoded Intel APX instructions + */ +#define CPUID_29_0_EBX_APX_NCI_NDD_NF (1U << 0) + /* RAS Features */ #define CPUID_8000_0007_EBX_OVERFLOW_RECOV (1U << 0) #define CPUID_8000_0007_EBX_SUCCOR (1U << 1) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3c9ed7cd5f7..c9efd3a9d46 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1036,6 +1036,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t ven= dor1, #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 #define TCG_24_0_EBX_FEATURES 0 +#define TCG_29_0_EBX_FEATURES 0 =20 #if defined CONFIG_USER_ONLY #define CPUID_8000_0008_EBX_KERNEL_FEATURES (CPUID_8000_0008_EBX_IBPB | \ @@ -1301,7 +1302,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "amx-complex", NULL, "avx-vnni-int16", NULL, NULL, NULL, "prefetchiti", NULL, NULL, NULL, NULL, "avx10", - NULL, NULL, NULL, NULL, + NULL, "apxf", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }, @@ -1345,6 +1346,25 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { }, .tcg_features =3D TCG_24_0_EBX_FEATURES, }, + [FEAT_29_0_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + "apx-nci-ndd-nf", NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid =3D { + .eax =3D 0x29, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EBX, + }, + .tcg_features =3D TCG_29_0_EBX_FEATURES, + }, [FEAT_8000_0007_EDX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { @@ -1996,6 +2016,10 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_1_EDX, CPUID_7_1_EDX_AVX10 }, .to =3D { FEAT_24_0_EBX, ~0ull }, }, + { + .from =3D { FEAT_7_1_EDX, CPUID_7_1_EDX_APXF }, + .to =3D { FEAT_29_0_EBX, ~0ull }, + }, }; =20 typedef struct X86RegisterInfo32 { @@ -8411,6 +8435,15 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } break; } + case 0x29: + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + if ((env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_APXF) && count = =3D=3D 0) { + *ebx =3D env->features[FEAT_29_0_EBX]; + } + break; case 0x40000000: /* * CPUID code in kvm_arch_init_vcpu() ignores stuff @@ -9190,6 +9223,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x24); } =20 + /* Advanced Performance Extensions (APX) requires CPUID[0x29] */ + if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_APXF) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x29); + } + /* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); --=20 2.52.0