From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365180; cv=none; d=zohomail.com; s=zohoarc; b=PSqBofjeN8VUYoxGfKkv8nYDhRi5ZLxawke3ojPfe+5U//a5/LNy8mdiGneDyZh3+LKKALuKQa6Kh7lSxSkRpZFHGNySWABEiXT3ZhMMTGr/tYVhlkcrb4fI6gO4AaPe0dUBOoX/HSfk0TgqKOD46SlBVyZrzr2COVLqwb+prHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365180; 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=/Xib8NJkqLHaUCPROEuFz6OXv9KVGcb/z3bmRVRMFdc=; b=FNxi+oDAIxrTaLmMnrrKUjSbEjdoB6nJ0aEmEl7DtYu2+/7pXFPIscvdtqypx9N7sBjQQIShBEYcEGaRWJJe3Yf/rb5TfQ2GXv2u0JfCW3UNjRdJbAqbTlrHLX9aMgyiUTwqMtCS5UYxxZffZnj/3hTJ7XsavsFrJ7RD9gqW4ko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173036518005118.457164224572807; Thu, 31 Oct 2024 01:59:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R0h-0000iX-Hh; Thu, 31 Oct 2024 04:58:31 -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 1t6R0d-0000hU-U3 for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:27 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R0c-0003Ct-Cu for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:27 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:23 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365106; x=1761901106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cBVM67PjgPHVUfUCuivJND+qiKNLwjMKHkFx1MDlePg=; b=DgHO+12g4ljb5/8lzT9LJsJitPyNDwrmSEuvYYR2ICi5eShrBb/wlFTD G3aivr5dbMdvlHdWhUuRnTU8CvhzI3iFSxlMJPVxQbKNaxPq5GM2xLc/h LBz8MBopwnzfdejCsvo8TOicmXL5dJjVkZW284BNSTZKR/TERFYml+fCr Xixebkd2XPjyeZSqeTTpsU5rh5zbTgJ6Pa1YQN87Ns7JphTDMh+XMB3Xo 93VOvwdrPb2egigaKY7celSxOx73H3aPo2yV4Ma3E1x7axLFfB4U1qxR8 95OQKiK52P5GngnI7qQ04ZAsHbpDtEl4XcHJ1ga15t7o9C4SvqKtidwIu A==; X-CSE-ConnectionGUID: H5OkrsbGRseHLB0I8AoyJg== X-CSE-MsgGUID: KRfpvuNAR0OXBXIeUgHGjA== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492670" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492670" X-CSE-ConnectionGUID: qey9tPBBTgqKLHV5K6BFkA== X-CSE-MsgGUID: sopHw02hRpmu+/KsG6i+sA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489451" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 1/8] target/i386: cpu: set correct supported XCR0 features for TCG Date: Thu, 31 Oct 2024 16:52:26 +0800 Message-Id: <20241031085233.425388-2-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365181334116600 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- target/i386/cpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1ff1af032e..b912dba2e5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1296,7 +1296,9 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { .needs_ecx =3D true, .ecx =3D 0, .reg =3D R_EAX, }, - .tcg_features =3D ~0U, + .tcg_features =3D XSTATE_FP_MASK | XSTATE_SSE_MASK | + XSTATE_YMM_MASK | XSTATE_BNDREGS_MASK | XSTATE_BNDCSR_MASK | + XSTATE_PKRU_MASK, .migratable_flags =3D XSTATE_FP_MASK | XSTATE_SSE_MASK | XSTATE_YMM_MASK | XSTATE_BNDREGS_MASK | XSTATE_BNDCSR_MASK | XSTATE_OPMASK_MASK | XSTATE_ZMM_Hi256_MASK | XSTATE_Hi16_ZMM_M= ASK | @@ -1309,7 +1311,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { .needs_ecx =3D true, .ecx =3D 0, .reg =3D R_EDX, }, - .tcg_features =3D ~0U, + .tcg_features =3D 0U, }, /*Below are MSR exposed features*/ [FEAT_ARCH_CAPABILITIES] =3D { --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365174; cv=none; d=zohomail.com; s=zohoarc; b=ZyINDNqoZrte5SrMm1SQ/cET4FggNMtzBpGbMUCleNiJ0t4GrWE8i6cI61+iAIBZZS1WZwsBx+cktwbtfpzT+tBuSVwdlpkXST1hGd8xh0J6mqKuFaftyop3ua/79dtsuBcxPIwZJX+7ss8jhzQ3kBK6ieMejnhf9Smn/SLqKog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365174; 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=pJ3yAycmcsmMsuiVIV2bqvvHG0vbZ3VJ1y9U9/OMqp0=; b=lJYxceZ4fnWF//iLKTsuBIrljHYXpzuZ8M4sMCHDeWZ0XZMle/VoWR96B0eGFazkWGqM7aNFXIVUq+qJhdyatoeOi+EULIlGhkH0HeONiCrpxYrIQ1vlaleAAmwP5aHgTRQR5bgMKMAgA+1MWSSs9dZz/0mA/QGppcBvb6z7Hss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730365174665598.8810794364608; Thu, 31 Oct 2024 01:59:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R0g-0000i6-LJ; Thu, 31 Oct 2024 04:58:30 -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 1t6R0f-0000hi-55 for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:29 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R0d-0003DC-C0 for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:28 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:25 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365107; x=1761901107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z19p8e9e9XND5Q1ITuGrozBRS19cwjl+L4Bn8F62g48=; b=dX+/FIiTvkRsmMtjnZB+pZj4W2NH5L+j0d4iBg0Y/5iX9aRkHtKIhZtf mom+xUYor+2HYcPBsqjcX+ad3mmBvy7VttR9V0BvpOC0LjLeV4cgotGuF hZ3TS9U/wEmVBfVeAU2/hrYyBDrPxSZgROXHoq1U+0pUf327fKnUi3/Bl H/Xcmler+OGVJXroarzj9+w0ldew1meGyvd9PEq4+U6dRBFKKh81bY9Qf VwrWHJ1jRiG+1ho3TcjqqNPpvjNnx2p9WPigWKiQVy6Cz6uIU/UW238rQ M6xeuy5j8GDwcO2mPeevHBmhDLAWEORJ9n3qq1L00c3QA4/7ycXNY5wkc g==; X-CSE-ConnectionGUID: UFVokdjaT8OQl1tnSbhKyw== X-CSE-MsgGUID: gWWqRkkiRbm1RFS8Tsk5zA== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492674" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492674" X-CSE-ConnectionGUID: qXq2jr3zR7yEwDd5vURq2Q== X-CSE-MsgGUID: Y6TKblfERNu78hWSJ7SQNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489504" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 2/8] target/i386: do not rely on ExtSaveArea for accelerator-supported XCR0 bits Date: Thu, 31 Oct 2024 16:52:27 +0800 Message-Id: <20241031085233.425388-3-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365175259116600 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Right now, QEMU is using the "feature" and "bits" fields of ExtSaveArea to query the accelerator for the support status of extended save areas. This is a problem for AVX10, which attaches two feature bits (AVX512F and AVX10) to the same extended save states. To keep the AVX10 hacks to the minimum, limit usage of esa->features and esa->bits. Instead, just query the accelerator for the 0xD leaf. Do it in common code and clear esa->size if an extended save state is unsupported. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- target/i386/cpu.c | 33 +++++++++++++++++++++++++++++++-- target/i386/kvm/kvm-cpu.c | 4 ---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b912dba2e5..f8b5c28caf 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7069,6 +7069,15 @@ static void x86_cpu_set_sgxlepubkeyhash(CPUX86State = *env) #endif } =20 +static bool cpuid_has_xsave_feature(CPUX86State *env, const ExtSaveArea *e= sa) +{ + if (!esa->size) { + return false; + } + + return (env->features[esa->feature] & esa->bits); +} + static void x86_cpu_reset_hold(Object *obj, ResetType type) { CPUState *cs =3D CPU(obj); @@ -7177,7 +7186,7 @@ static void x86_cpu_reset_hold(Object *obj, ResetType= type) if (!((1 << i) & CPUID_XSTATE_XCR0_MASK)) { continue; } - if (env->features[esa->feature] & esa->bits) { + if (cpuid_has_xsave_feature(env, esa)) { xcr0 |=3D 1ull << i; } } @@ -7315,7 +7324,7 @@ static void x86_cpu_enable_xsave_components(X86CPU *c= pu) mask =3D 0; for (i =3D 0; i < ARRAY_SIZE(x86_ext_save_areas); i++) { const ExtSaveArea *esa =3D &x86_ext_save_areas[i]; - if (env->features[esa->feature] & esa->bits) { + if (cpuid_has_xsave_feature(env, esa)) { mask |=3D (1ULL << i); } } @@ -7987,6 +7996,26 @@ static void x86_cpu_register_feature_bit_props(X86CP= UClass *xcc, =20 static void x86_cpu_post_initfn(Object *obj) { + static bool first =3D true; + uint64_t supported_xcr0; + int i; + + if (first) { + first =3D false; + + supported_xcr0 =3D + ((uint64_t) x86_cpu_get_supported_feature_word(NULL, FEAT_XSAV= E_XCR0_HI) << 32) | + x86_cpu_get_supported_feature_word(NULL, FEAT_XSAVE_XCR0_LO); + + for (i =3D XSTATE_SSE_BIT + 1; i < XSAVE_STATE_AREA_COUNT; i++) { + ExtSaveArea *esa =3D &x86_ext_save_areas[i]; + + if (!(supported_xcr0 & (1 << i))) { + esa->size =3D 0; + } + } + } + accel_cpu_instance_init(CPU(obj)); } =20 diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6bf8dcfc60..99d1941cf5 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -143,10 +143,6 @@ static void kvm_cpu_xsave_init(void) if (!esa->size) { continue; } - if ((x86_cpu_get_supported_feature_word(NULL, esa->feature) & esa-= >bits) - !=3D esa->bits) { - continue; - } host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx); if (eax !=3D 0) { assert(esa->size =3D=3D eax); --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365208; cv=none; d=zohomail.com; s=zohoarc; b=TwBnaGLCaUH/BDpdea54x1jMvyWh8AHZrHLjBT1jOmXQJ7lM2oP1B06UoOW7aFIDrjZ/DxKTRqX4CDzJvr3NvaIMhCVVQCScf4cly1nvOq8lTW7klCTZDGbvdBChNXouDLQWEhN3PHPGSHr/HmKMtkqqDdJarfmLYoQ0nyZDWOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365208; 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=5S/F0jx1T4M5nnOwyC2HJMrgiFX5KS8CM25GbBHJ7Z0=; b=m2zEyPFFWpaGyYV/+wKHX7s63r3pdG6qWASNat2GxNHDrmLntluaEAb3UCcCwmkRxAGNpQhjhOv4qtUMsD4e0OcERcvDHF88IAxMiBd3130ccsNstgfwdfNd9ra3DNxwUcGNLc3GdQP9hJajuWBXUGzyVQP7nzJiRuqXuGPdSuE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173036520807983.49013274323738; Thu, 31 Oct 2024 02:00:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R0h-0000ic-PG; Thu, 31 Oct 2024 04:58:31 -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 1t6R0g-0000iI-NL for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:30 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R0f-0003Df-7g for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:30 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:27 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365109; x=1761901109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9VjjJYDFcgFlWNJ1FOvFU9s2rvOXHSEg5LYj3IBDpC4=; b=emWixkBKKuSuQwRXqK1lyxwbnTBoOxgEOFVarzwjbZj/NbBaI5KyQXgn MdHotUPlF2ZeIXTSp0CEn2zcZxaKtDKaj9pXpGIoqxRNyhc5uU2Bn95wl EAWy1qGnTfL+JUNR8aUFjU7XtzH2QxgE0GYg3E0sBkcs+BAMZazqh94pY 6h+jIoV8F2FODuFr9QXRnGr+dsZDRHKKiX0KvkLU4f7S5j0NKj7u39MvY OFmnH39KQ3fwSRIOXpmxRpOEvPLWIHhQI7FtIcTBskVUoYzHfGKHsF7pm hipJqDbxzBqWF0AV4z9r15osq00XeNHT69TFNsMMjTBNCCsjRQ7uPV+uG w==; X-CSE-ConnectionGUID: YwknYi9UQmCbi1vRkpSl5Q== X-CSE-MsgGUID: jR/35ci4Qs+JwO5s57IUqQ== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492678" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492678" X-CSE-ConnectionGUID: egAIj5/iTq6fwvHykiUjiA== X-CSE-MsgGUID: Q9e0wZbwRwG9rLtFGutQNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489510" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 3/8] target/i386: return bool from x86_cpu_filter_features Date: Thu, 31 Oct 2024 16:52:28 +0800 Message-Id: <20241031085233.425388-4-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365209491116600 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Prepare for filtering non-boolean features such as AVX10 version. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu Signed-off-by: Tao Su --- target/i386/cpu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f8b5c28caf..8fbbf1fd9e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5818,7 +5818,7 @@ static void x86_cpu_parse_featurestr(const char *type= name, char *features, } } =20 -static void x86_cpu_filter_features(X86CPU *cpu, bool verbose); +static bool x86_cpu_filter_features(X86CPU *cpu, bool verbose); =20 /* Build a list with the name of all features on a feature word array */ static void x86_cpu_list_feature_names(FeatureWordArray features, @@ -7523,9 +7523,9 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **err= p) * Finishes initialization of CPUID data, filters CPU feature * words based on host availability of each feature. * - * Returns: 0 if all flags are supported by the host, non-zero otherwise. + * Returns: true if any flag is not supported by the host, false otherwise. */ -static void x86_cpu_filter_features(X86CPU *cpu, bool verbose) +static bool x86_cpu_filter_features(X86CPU *cpu, bool verbose) { CPUX86State *env =3D &cpu->env; FeatureWord w; @@ -7577,6 +7577,8 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool= verbose) mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INT= EL_PT, prefix); } } + + return x86_cpu_have_filtered_features(cpu); } =20 static void x86_cpu_hyperv_realize(X86CPU *cpu) @@ -7674,14 +7676,14 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) } } =20 - x86_cpu_filter_features(cpu, cpu->check_cpuid || cpu->enforce_cpuid); - - if (cpu->enforce_cpuid && x86_cpu_have_filtered_features(cpu)) { - error_setg(&local_err, - accel_uses_host_cpuid() ? + if (x86_cpu_filter_features(cpu, cpu->check_cpuid || cpu->enforce_cpui= d)) { + if (cpu->enforce_cpuid) { + error_setg(&local_err, + accel_uses_host_cpuid() ? "Host doesn't support requested features" : "TCG doesn't support requested features"); - goto out; + goto out; + } } =20 /* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365143; cv=none; d=zohomail.com; s=zohoarc; b=VfSHALEXiHazbOpuMJ7tNBZCRMnhokRdOW9FMRHNnh/tVkL5ry2Rgco0bhZQoyKMcNKoyIBk4qkVNrIkHttCDRXvzd35U3Y6MFpamCGCFg2LLvtubS5N6k+ptFIMh8k7hJY4El+7QdkDGzPLxgnLSJWdY7EyI2EZ3pUiBwavVW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365143; 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=xAvqIqSPlobPBW7ZqvBE5z+bKwKjkiDx+1EPgYcQmnE=; b=XQ58QsLqPJVKyUc6GeoKyU2Hj+OdGdgqPImYsVYQsR3QpuEbJ5NDvooDsUE8JL/3t5nRw+A1zOtMYBIdHFfRb5X8mroweB6S0JSp+0mQSbyYVQkqi8t+vbjsFxrUw0GYyU+fcalfXfXnsPoeATqQDGOLoe52SuDnFjCQf+l9SUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730365143040599.4299591396942; Thu, 31 Oct 2024 01:59:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R0k-0000ji-9Z; Thu, 31 Oct 2024 04:58:34 -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 1t6R0i-0000jB-Bv for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:32 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R0g-0003DC-8j for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:32 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:29 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365110; x=1761901110; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UZyMMsRXa4iSyGY5eUFRZzJg2dephFzFFBTZxRIx7WU=; b=O/zzXcdZFzc9TqGXY9e4AqZp5eMR1gKxNdEghSV8kLD8UVY8PV+3sash QeZG84W+Gk45w98k8EfJzHrxWu4/+v9YUXYSnNNW3fBcfgcotGG/WR+Ho LQIlCshqwyAaE/R0lB5AgbuSCrZ779IqlC8QpxwpE6Q9cZ6ET5nWyGYMS LnzCeKdoYKk0M9QNwpsGnLppFvh3kguq8dpg46Qr/MV3SmksrMkRHl1c2 TzbUq8Da8XezMtKCBsRiEFxR9ZRu4eHlGXHtv54YYyUpXLVl0r0gsncXc LQrjP42ZCU9h1zUfFWoWZemHMhNT3fHzsg56MyNzzkk3z4kS64kwzOCAw Q==; X-CSE-ConnectionGUID: CFHZlx8BQyq1WYlXjsZE9w== X-CSE-MsgGUID: cc+S5JNvT3+s0fA6fGsvNQ== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492682" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492682" X-CSE-ConnectionGUID: eaUpzwv2TPSgW/M56Ak/hg== X-CSE-MsgGUID: 1BFyTnwgS1iRaFkRYgfW6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489519" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 4/8] target/i386: add AVX10 feature and AVX10 version property Date: Thu, 31 Oct 2024 16:52:29 +0800 Message-Id: <20241031085233.425388-5-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365144863116600 Content-Type: text/plain; charset="utf-8" When AVX10 enable bit is set, the 0x24 leaf will be present as "AVX10 Converged Vector ISA leaf" containing fields for the version number and the supported vector bit lengths. Introduce avx10-version property so that avx10 version can be controlled by user and cpu model. Per spec, avx10 version can never be 0, the default value of avx10-version is set to 0 to determine whether it is specified by user. The default can come from the device model or, for the max model, from KVM's reported value. Signed-off-by: Tao Su Link: https://lore.kernel.org/r/20241028024512.156724-3-tao1.su@linux.intel= .com Link: https://lore.kernel.org/r/20241028024512.156724-4-tao1.su@linux.intel= .com Signed-off-by: Paolo Bonzini Tested-by: Xuelian Guo Reviewed-by: Zhao Liu --- target/i386/cpu.c | 64 ++++++++++++++++++++++++++++++++++++++----- target/i386/cpu.h | 4 +++ target/i386/kvm/kvm.c | 3 +- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8fbbf1fd9e..284ff062df 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -46,6 +46,9 @@ #include "cpu-internal.h" =20 static void x86_cpu_realizefn(DeviceState *dev, Error **errp); +static void x86_cpu_get_supported_cpuid(uint32_t func, uint32_t index, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx); =20 /* Helpers for building CPUID[2] descriptors: */ =20 @@ -1132,7 +1135,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { "avx-vnni-int8", "avx-ne-convert", NULL, NULL, "amx-complex", NULL, "avx-vnni-int16", NULL, NULL, NULL, "prefetchiti", NULL, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, "avx10", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -1967,6 +1970,7 @@ typedef struct X86CPUDefinition { int family; int model; int stepping; + uint8_t avx10_version; FeatureWordArray features; const char *model_id; const CPUCaches *const cache_info; @@ -6309,6 +6313,9 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUMod= el *model) */ object_property_set_str(OBJECT(cpu), "vendor", def->vendor, &error_abo= rt); =20 + object_property_set_uint(OBJECT(cpu), "avx10-version", def->avx10_vers= ion, + &error_abort); + x86_cpu_apply_version_props(cpu, model); =20 /* @@ -6837,6 +6844,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } break; } + case 0x24: { + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + if ((env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) && count = =3D=3D 0) { + *ebx =3D env->features[FEAT_24_0_EBX] | env->avx10_version; + } + break; + } case 0x40000000: /* * CPUID code in kvm_arch_init_vcpu() ignores stuff @@ -7417,6 +7434,12 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } + + if ((env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) && !env->a= vx10_version) { + uint32_t eax, ebx, ecx, edx; + x86_cpu_get_supported_cpuid(0x24, 0, &eax, &ebx, &ecx, &edx); + env->avx10_version =3D ebx & 0xff; + } } =20 for (i =3D 0; i < ARRAY_SIZE(feature_dependencies); i++) { @@ -7480,6 +7503,11 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **er= rp) x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x1F); } =20 + /* 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); @@ -7530,6 +7558,10 @@ static bool x86_cpu_filter_features(X86CPU *cpu, boo= l verbose) CPUX86State *env =3D &cpu->env; FeatureWord w; const char *prefix =3D NULL; + bool have_filtered_features; + + uint32_t eax_0, ebx_0, ecx_0, edx_0; + uint32_t eax_1, ebx_1, ecx_1, edx_1; =20 if (verbose) { prefix =3D accel_uses_host_cpuid() @@ -7551,13 +7583,10 @@ static bool x86_cpu_filter_features(X86CPU *cpu, bo= ol verbose) */ if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && kvm_enabled()) { - uint32_t eax_0, ebx_0, ecx_0, edx_0_unused; - uint32_t eax_1, ebx_1, ecx_1_unused, edx_1_unused; - x86_cpu_get_supported_cpuid(0x14, 0, - &eax_0, &ebx_0, &ecx_0, &edx_0_unused); + &eax_0, &ebx_0, &ecx_0, &edx_0); x86_cpu_get_supported_cpuid(0x14, 1, - &eax_1, &ebx_1, &ecx_1_unused, &edx_1_= unused); + &eax_1, &ebx_1, &ecx_1, &edx_1); =20 if (!eax_0 || ((ebx_0 & INTEL_PT_MINIMAL_EBX) !=3D INTEL_PT_MINIMAL_EBX) || @@ -7578,7 +7607,27 @@ static bool x86_cpu_filter_features(X86CPU *cpu, boo= l verbose) } } =20 - return x86_cpu_have_filtered_features(cpu); + have_filtered_features =3D x86_cpu_have_filtered_features(cpu); + + if (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10) { + x86_cpu_get_supported_cpuid(0x24, 0, + &eax_0, &ebx_0, &ecx_0, &edx_0); + uint8_t version =3D ebx_0 & 0xff; + + if (version < env->avx10_version) { + if (prefix) { + warn_report("%s: avx10.%d. Adjust to avx10.%d", + prefix, env->avx10_version, version); + } + env->avx10_version =3D version; + have_filtered_features =3D true; + } + } else if (env->avx10_version && prefix) { + warn_report("%s: avx10.%d.", prefix, env->avx10_version); + have_filtered_features =3D true; + } + + return have_filtered_features; } =20 static void x86_cpu_hyperv_realize(X86CPU *cpu) @@ -8362,6 +8411,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("min-level", X86CPU, env.cpuid_min_level, 0), DEFINE_PROP_UINT32("min-xlevel", X86CPU, env.cpuid_min_xlevel, 0), 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_leve= l, true), DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 74886d1580..d845384dcd 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -972,6 +972,8 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu= , FeatureWord w); #define CPUID_7_1_EDX_AMX_COMPLEX (1U << 8) /* PREFETCHIT0/1 Instructions */ #define CPUID_7_1_EDX_PREFETCHITI (1U << 14) +/* Support for Advanced Vector Extensions 10 */ +#define CPUID_7_1_EDX_AVX10 (1U << 19) /* Flexible return and event delivery (FRED) */ #define CPUID_7_1_EAX_FRED (1U << 17) /* Load into IA32_KERNEL_GS_BASE (LKGS) */ @@ -1918,6 +1920,8 @@ typedef struct CPUArchState { uint32_t cpuid_vendor3; uint32_t cpuid_version; FeatureWordArray features; + /* AVX10 version */ + uint8_t avx10_version; /* Features that were explicitly enabled/disabled */ FeatureWordArray user_features; uint32_t cpuid_model[12]; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index fd9f198892..8e17942c3b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1923,7 +1923,8 @@ static uint32_t kvm_x86_build_cpuid(CPUX86State *env, case 0x7: case 0x14: case 0x1d: - case 0x1e: { + case 0x1e: + case 0x24: { uint32_t times; =20 c->function =3D i; --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365167; cv=none; d=zohomail.com; s=zohoarc; b=J2K82sLeo+D3/aZHi3gAeOLkE8vHF5dn4c/4EcvP+5nFYvm/K5kZeDJWCrNZeC0yEQUHQkp3Bob2HWtGotT2gAuC28GIoo2wYSZ3C7MF6ds4MxYkcWuDJyA9lyu+5FAAG0js8/ZaOgDJPwxzRJt7J4d1iZy+q79+6TIY9yo3eJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365167; 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=QZtVkEpAey5/7gjZVeNvJufIWsnEJ8gJCipNITjfi9U=; b=YDi3XWNVzb6hOozHhuJr9H3bOxoTDAEGD18niVgUlVpZwrbx5s4b2HxddAjR3CijmXEUfwThy7XXD4/3Cv5pZ9q1Pr+QgvneVjOdi1l1GcwnSOtEDwt2BLeRxjGZJ0txirefbiGXb82nmeOUvosF+9eBQlC+LnN1UJBVklMfR8o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730365167672412.5814027010242; Thu, 31 Oct 2024 01:59:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R0l-0000js-GM; Thu, 31 Oct 2024 04:58:35 -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 1t6R0k-0000jZ-7F for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:34 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R0i-0003Df-I7 for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:33 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:32 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365112; x=1761901112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2I6/6P79f4JXvf6/DXeQbTo6OJI0mWYZ67sPRPD1190=; b=ffpR9SzFjxfjEKdwElRzwZRNHcjDktKu1xQCUlPZqPFN+82X0EJ0Jn0Q jDcMOh4gywE4svJMZgiARVkvrxeiDR3mtWq/T0VzRmirOePyI386Ot/rN ZbQgWirPfbkQH6ikhpd5Sy8fv48pXtZ2lcD0+BZDU8623O9eJrtIrvBCd kQKR87kKhl3eoIya9jq26+ybnsPpDCPTE9jP37FmIb+5lo57+YawuXdeN MBgkjgDry1Md+ORm22mQpTJSRkYThB719PaEsL4aISVlBTxi4VF5XeFb5 vRZ1gCaV0SapSnqkkdNxEYeuk5TRLDhTJIrja/qmHi+GtBJlQDA3vv0af A==; X-CSE-ConnectionGUID: Mr74xCzRQ3KzQls4NKM/KA== X-CSE-MsgGUID: IEFi/yMXRDGbxAg+N4F48A== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492690" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492690" X-CSE-ConnectionGUID: jKS2wT4RSF6CcFtUll5oDQ== X-CSE-MsgGUID: JnXFS98bSpegqxc+I5avAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489528" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 5/8] target/i386: add CPUID.24 features for AVX10 Date: Thu, 31 Oct 2024 16:52:30 +0800 Message-Id: <20241031085233.425388-6-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365169578116600 Content-Type: text/plain; charset="utf-8" Introduce features for the supported vector bit lengths. Signed-off-by: Tao Su Link: https://lore.kernel.org/r/20241028024512.156724-3-tao1.su@linux.intel= .com Link: https://lore.kernel.org/r/20241028024512.156724-4-tao1.su@linux.intel= .com Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu Tested-by: Xuelian Guo --- target/i386/cpu.c | 15 +++++++++++++++ target/i386/cpu.h | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 284ff062df..762c69d0b9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -901,6 +901,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendo= r1, #define TCG_SGX_12_0_EAX_FEATURES 0 #define TCG_SGX_12_0_EBX_FEATURES 0 #define TCG_SGX_12_1_EAX_FEATURES 0 +#define TCG_24_0_EBX_FEATURES 0 =20 #if defined CONFIG_USER_ONLY #define CPUID_8000_0008_EBX_KERNEL_FEATURES (CPUID_8000_0008_EBX_IBPB | \ @@ -1166,6 +1167,20 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { }, .tcg_features =3D TCG_7_2_EDX_FEATURES, }, + [FEAT_24_0_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + [16] =3D "avx10-128", + [17] =3D "avx10-256", + [18] =3D "avx10-512", + }, + .cpuid =3D { + .eax =3D 0x24, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EBX, + }, + .tcg_features =3D TCG_24_0_EBX_FEATURES, + }, [FEAT_8000_0007_EDX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d845384dcd..5566a13f4f 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -662,6 +662,7 @@ typedef enum FeatureWord { FEAT_XSAVE_XSS_HI, /* CPUID[EAX=3D0xd,ECX=3D1].EDX */ 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 */ FEATURE_WORDS, } FeatureWord; =20 @@ -990,6 +991,13 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cp= u, FeatureWord w); /* Packets which contain IP payload have LIP values */ #define CPUID_14_0_ECX_LIP (1U << 31) =20 +/* AVX10 128-bit vector support is present */ +#define CPUID_24_0_EBX_AVX10_128 (1U << 16) +/* AVX10 256-bit vector support is present */ +#define CPUID_24_0_EBX_AVX10_256 (1U << 17) +/* AVX10 512-bit vector support is present */ +#define CPUID_24_0_EBX_AVX10_512 (1U << 18) + /* RAS Features */ #define CPUID_8000_0007_EBX_OVERFLOW_RECOV (1U << 0) #define CPUID_8000_0007_EBX_SUCCOR (1U << 1) --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365160; cv=none; d=zohomail.com; s=zohoarc; b=ZTu21or90jFcWwdelCTwEpSqQs7shDKPNuVooI9QRUrpnmuGJD4qEXGk7Jctqy0UZbi301MGzl6It284ufMm2Px/mSt6ODkceq8AuMZh3KEd2D/k4f/KGFwVS+RCZn6pEmKLp1n7Y9gE5Rmxl2amozthYesPD+2i/dgEbaf9XzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365160; 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=c/gvyOzYIi879jzcote+ZYX/s/HNrQ2zfOe6xYpc9JA=; b=S1BYl5QXnQuIcoN+RNuDdh90cKEr5jyErqkD55xfWVt3Ft7OEZECFrPpCWZulG48pkpoSuXW9JvSOKn2YGi27DB87fZ4D774Jc2cr0d6jZcH589ZD8az220ueVrik3EcqPFZXYytjBRWYQsSTsvwEPD4RgJRZNT9DciT+5Goy50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730365160522116.8675806662344; Thu, 31 Oct 2024 01:59:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R1D-0000pH-Q0; Thu, 31 Oct 2024 04:59:03 -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 1t6R16-0000lk-8q for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:57 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R13-0003GX-TZ for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:56 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:34 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365134; x=1761901134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BjgUHeb+QxtWbqmhNFPKp+hAK9Yqmy9MNVj33Q2H5jo=; b=Ev7Mry7A9r6RxsIR0tIcWSJ/eIACTrI9eo22FralJUKEAluj0exsx5Pa 7DgLgbbbfgQxhYDHdWUFWmA8kOp27S3vLQ0pDEriYMGzti9j09kurnf95 P3w8eadwrKGgOr4/zuO17eH25hmWv68BNqwULKomJD4pqC5MO+BFlcZLS QeGf9PUiSorjgCpdbk9Ni1vl7Lbxs20uUEZdzYqxAQeipf+hdGMBhfqsF V5hLQBspLO+SALRHL1LY6ykeat2+dgSlu3E1puE7boVXmHg/+sv+K7LZt 9plvSFN0POY0SsOolngXmSUT+EmI7kSh54Sc3LtJ9LIUCH0U0/pTgfeQw A==; X-CSE-ConnectionGUID: ZSXGVEXiTmS/Mfcl4zizIA== X-CSE-MsgGUID: j8OUy4g8RqOWzKZoFodrzw== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492718" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492718" X-CSE-ConnectionGUID: kmin5mpBRca/vH3+wU8iMQ== X-CSE-MsgGUID: nOUsool0RvKeSU1VKzDMaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489542" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 6/8] target/i386: Add feature dependencies for AVX10 Date: Thu, 31 Oct 2024 16:52:31 +0800 Message-Id: <20241031085233.425388-7-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365161277116600 Content-Type: text/plain; charset="utf-8" Since the highest supported vector length for a processor implies that all lesser vector lengths are also supported, add the dependencies of the supported vector lengths. If all vector lengths aren't supported, clear AVX10 enable bit as well. Note that the order of AVX10 related dependencies should be kept as: CPUID_24_0_EBX_AVX10_128 -> CPUID_24_0_EBX_AVX10_256, CPUID_24_0_EBX_AVX10_256 -> CPUID_24_0_EBX_AVX10_512, CPUID_24_0_EBX_AVX10_VL_MASK -> CPUID_7_1_EDX_AVX10, CPUID_7_1_EDX_AVX10 -> CPUID_24_0_EBX, so that prevent user from setting weird CPUID combinations, e.g. 256-bits and 512-bits are supported but 128-bits is not, no vector lengths are supported but AVX10 enable bit is still set. Since AVX10_128 will be reserved as 1, adding these dependencies has the bonus that when user sets -cpu host,-avx10-128, CPUID_7_1_EDX_AVX10 and CPUID_24_0_EBX will be disabled automatically. Tested-by: Xuelian Guo Signed-off-by: Tao Su Link: https://lore.kernel.org/r/20241028024512.156724-5-tao1.su@linux.intel= .com Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 16 ++++++++++++++++ target/i386/cpu.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 762c69d0b9..d8d86edd67 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1765,6 +1765,22 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, .to =3D { FEAT_SGX_12_1_EAX, ~0ull }, }, + { + .from =3D { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_128 }, + .to =3D { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_256 }, + }, + { + .from =3D { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_256 }, + .to =3D { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_512 }, + }, + { + .from =3D { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_VL_MASK= }, + .to =3D { FEAT_7_1_EDX, CPUID_7_1_EDX_AVX10 }, + }, + { + .from =3D { FEAT_7_1_EDX, CPUID_7_1_EDX_AVX10 }, + .to =3D { FEAT_24_0_EBX, ~0ull }, + }, }; =20 typedef struct X86RegisterInfo32 { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5566a13f4f..e4c947b478 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -997,6 +997,10 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cp= u, FeatureWord w); #define CPUID_24_0_EBX_AVX10_256 (1U << 17) /* AVX10 512-bit vector support is present */ #define CPUID_24_0_EBX_AVX10_512 (1U << 18) +/* AVX10 vector length support mask */ +#define CPUID_24_0_EBX_AVX10_VL_MASK (CPUID_24_0_EBX_AVX10_128 | \ + CPUID_24_0_EBX_AVX10_256 | \ + CPUID_24_0_EBX_AVX10_512) =20 /* RAS Features */ #define CPUID_8000_0007_EBX_OVERFLOW_RECOV (1U << 0) --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365215; cv=none; d=zohomail.com; s=zohoarc; b=Tmtfv27bsjnT/FxFqTB2DH0bpMeO11j9OCJw0X6xlMZ1JW+CKjGVKF7ugvJ5BdBw0CvN0D4d/hndvkDXyO6jGp04K2/VEch56g5b3Yu4ZY/PC5gPGS10DpwhDVNHhYNQbmY+myThww3aCZkl6qsaZuBn6MrFcZoJR+Be1yvaK/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365215; 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=0zEiE+bks0usqJh221ILuZwMs7dAfLkrMC0UeJyyvPc=; b=n6hrvuPRZf7uB4KSF4jhT0tZG2rZK/PH4l2oInMKchYO3vNYN0Ln12MOK3Y3GYt8dd5jhOhBDqfkduho8B47341L3KKkNQeRlpInZ2zZhTTkHq/6WXNA9BbVONOS988imO5hfHMWtoSr5e1rsPKNWcbFDLJYhm8BtIbqBM/rHGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17303652152747.849328433219966; Thu, 31 Oct 2024 02:00:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R1G-0000sw-H4; Thu, 31 Oct 2024 04:59:06 -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 1t6R18-0000m7-M4 for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:59 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R16-0003GX-Rp for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:58:58 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:36 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365137; x=1761901137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O+ps4gCQE+MIUJn7vxlxvfPld8Y2qokFJ/P0+6xKo2k=; b=WLGxoXFienHry37dADWmZA0tz86+QibccR87D3R2qeuA/lmBqm8yWH3e U6bseQrRGn9HeKNYUdqeBtW+SFIAbFaF9if6FM4ZoCb/+KL8o1yI8SRpJ 0xFcA7CS1HXDmHHzYdyWQtXCSdc99ueo3pkhRr0/P6ndTtBu6m8XP+2bN 5I5sG8PGQ/8LSWZryzGH/U4csYO3fb5rykcN/+8+Ps1L1Hu+rkTtpbGXm CF3V+UMR0SOkzhPJ6ZsOJ7HRj8Zl3iIVeHleBPKyPSMuVAeH/mLaJXuBa +esjjUGwo5DROLzXcvO71BkDABlQacCh47F93sxIaiwU8eNWl1CR87JTj Q==; X-CSE-ConnectionGUID: HM//nMkZQ/KZlVcbZ4YcVQ== X-CSE-MsgGUID: 5ec3n6D0SSy+A1nU0I3mBQ== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492759" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492759" X-CSE-ConnectionGUID: rcJGz0P2RVyuMBIxEhv2fw== X-CSE-MsgGUID: 9MkbZiopTOC8FY7CLgf8Hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489564" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 7/8] target/i386: Add AVX512 state when AVX10 is supported Date: Thu, 31 Oct 2024 16:52:32 +0800 Message-Id: <20241031085233.425388-8-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365215418116600 Content-Type: text/plain; charset="utf-8" AVX10 state enumeration in CPUID leaf D and enabling in XCR0 register are identical to AVX512 state regardless of the supported vector lengths. Given that some E-cores will support AVX10 but not support AVX512, add AVX512 state components to guest when AVX10 is enabled. Based on a patch by Tao Su Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu Tested-by: Xuelian Guo Signed-off-by: Tao Su --- target/i386/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d8d86edd67..cc7e4ce665 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7123,7 +7123,15 @@ static bool cpuid_has_xsave_feature(CPUX86State *env= , const ExtSaveArea *esa) return false; } =20 - return (env->features[esa->feature] & esa->bits); + if (env->features[esa->feature] & esa->bits) { + return true; + } + if (esa->feature =3D=3D FEAT_7_0_EBX && esa->bits =3D=3D CPUID_7_0_EBX= _AVX512F + && (env->features[FEAT_7_1_EDX] & CPUID_7_1_EDX_AVX10)) { + return true; + } + + return false; } =20 static void x86_cpu_reset_hold(Object *obj, ResetType type) --=20 2.34.1 From nobody Sat Nov 23 17:36:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1730365174; cv=none; d=zohomail.com; s=zohoarc; b=mwhX+Tax2u8f89Xc3Yx0l235IeV8I/Zqgqvlah9S/+sAjTA2AOxWC0AciCD6LorQka9M7h9T8QOFET+2iJ9p9S9UYyeHm46KOKEYncKyn4fWf7hShCuuG7gFksJ7P9wBV8hr/EVFxDGhuc8XD++afLKS741mFhP807M+GxsIOrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730365174; 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=Uigyx8iybmp4+rGX9hDZ46G2n2qLrS/KIjdZRXnIanc=; b=hfzVBxLmPLEQX4yE6xbCcOAs4442Q1KgZpuMvJiTeW9xyXQjP9FLU8YjGXKyte4Y3nF8i88YekSlw2byCgfCpFqN0oBNTUDPwKSi9J7bnXECV4MaipAaUHab93ADsgc20YLHkUyKkFGoGEPVe5ZYZPTwcYxac3qXKIfDwfecCc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730365174543854.1176199211012; Thu, 31 Oct 2024 01:59:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6R1F-0000rP-FU; Thu, 31 Oct 2024 04:59:05 -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 1t6R1A-0000mJ-DI for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:59:00 -0400 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t6R18-0003Gu-Mo for qemu-devel@nongnu.org; Thu, 31 Oct 2024 04:59:00 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 01:58:38 -0700 Received: from st-server.bj.intel.com ([10.240.193.102]) by orviesa010.jf.intel.com with ESMTP; 31 Oct 2024 01:58:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730365139; x=1761901139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X/D2vNdScCHmz0+RWJ9LwHGG/iCwnHpfrXS7AkXMf9I=; b=C93mkFydpJXkWEMn6CryTrCFX8H8r+XGezBEqEc2nZbpgdqFZAx/4Vf2 OXjq+XDulsUgeH+MgJ60bWrpVF+22nt0HpA3P2axvWXus+cgkWaFZvc3+ tNvrfF2/BAHLze1aBSz7pb+j2HgnKfhI57P18/RI9xY626J4H1ZSReefA A0ZP2UOakwC4or4WPSkbjvzzQVV0kJ9VLoY95YBFQoQsq8oXBbWW8VMcw AxQ4Di0INfIBQn5iry9CTU/uyNONsxxyWUXWmBySBiIuRbL299zNhGUt7 vVAb72wswHdgoEo7IgQThJRaX+FvfdAc/JiQJ5AtCV+kG8cIP9v6i4rsM w==; X-CSE-ConnectionGUID: UbiHwaeLRIeAP4zcK0ozAw== X-CSE-MsgGUID: LPbobEWCTLmdlCOFFadN0A== X-IronPort-AV: E=McAfee;i="6700,10204,11241"; a="55492766" X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="55492766" X-CSE-ConnectionGUID: BJQPn5EbQYiRKqRP8vXgLw== X-CSE-MsgGUID: Un6EcnpVQAqn66k/DCBiXw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82489581" From: Tao Su To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mtosatti@redhat.com, xiaoyao.li@intel.com, zhao1.liu@intel.com, xuelian.guo@intel.com, tao1.su@linux.intel.com Subject: [PATCH v3 8/8] target/i386: Introduce GraniteRapids-v2 model Date: Thu, 31 Oct 2024 16:52:33 +0800 Message-Id: <20241031085233.425388-9-tao1.su@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031085233.425388-1-tao1.su@linux.intel.com> References: <20241031085233.425388-1-tao1.su@linux.intel.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: none client-ip=192.198.163.7; envelope-from=tao1.su@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -46 X-Spam_score: -4.7 X-Spam_bar: ---- X-Spam_report: (-4.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 @intel.com) X-ZM-MESSAGEID: 1730365175280116600 Content-Type: text/plain; charset="utf-8" Update GraniteRapids CPU model to add AVX10 and the missing features(ss, tsc-adjust, cldemote, movdiri, movdir64b). Tested-by: Xuelian Guo Signed-off-by: Tao Su Link: https://lore.kernel.org/r/20241028024512.156724-7-tao1.su@linux.intel= .com Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index cc7e4ce665..8846314775 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4381,6 +4381,23 @@ static const X86CPUDefinition builtin_x86_defs[] =3D= { .model_id =3D "Intel Xeon Processor (GraniteRapids)", .versions =3D (X86CPUVersionDefinition[]) { { .version =3D 1 }, + { + .version =3D 2, + .props =3D (PropValue[]) { + { "ss", "on" }, + { "tsc-adjust", "on" }, + { "cldemote", "on" }, + { "movdiri", "on" }, + { "movdir64b", "on" }, + { "avx10", "on" }, + { "avx10-128", "on" }, + { "avx10-256", "on" }, + { "avx10-512", "on" }, + { "avx10-version", "1" }, + { "stepping", "1" }, + { /* end of list */ } + } + }, { /* end of list */ }, }, }, --=20 2.34.1