From nobody Mon Oct 27 14:20:53 2025 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1761287751; cv=none; d=zohomail.com; s=zohoarc; b=i4/u2x4kK2B2wgv5Yan/n3vXKm8vr5coZZDlEJvYHGlCTYzF4Bhhu+UygqQ0YgK8yzc4+W/CIMQzk6PqbgOwJGzTLIKAuCTjwTHvLPd6EPu3Fu5D0jplpvYyzI7PfVQNe7mB4NVlFA5GreH3Q0zSlPP3sHjhgVde+p/QqAUWXEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761287751; 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=EEapGj8O2HPoc2Id0Kp2Qq85KcGRGvscttCsu6UUw/Q=; b=F+/fKHI0jo0gRP2a0THuy2qkvNUXeq0Ki+Qwjbunr1qXXbyd/clbJKx8Qhzb4aTAWyYzJQirwKhulvvobNBvPz5wFvjmMC6Cy+5gXFMP2wM2eMJkDbbf54evTtLT5GMLQ/hVLdTcZYk5f8V5AKApi8GsR4oLxemQ1kwjtwEcXsA= 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 1761287751541462.8386146735529; Thu, 23 Oct 2025 23:35:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vCBO5-0003Mp-PQ; Fri, 24 Oct 2025 02:34:57 -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 1vCBO2-0003Mf-F8 for qemu-devel@nongnu.org; Fri, 24 Oct 2025 02:34:54 -0400 Received: from mgamail.intel.com ([192.198.163.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vCBO0-0003kG-Jk for qemu-devel@nongnu.org; Fri, 24 Oct 2025 02:34:54 -0400 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2025 23:34:50 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by fmviesa006.fm.intel.com with ESMTP; 23 Oct 2025 23:34:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761287693; x=1792823693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7tOeAaUzQYqTAHH7/NYu9sDsu+/WQtAS5FGKwnZ2ICw=; b=k03xps8+O6b5dWKpQ/TYyJkMkdSdZkcX2LpOoHoT+VbDGa22VBEM5IDK 3c40pNCE2a0qdFWR6gbdybAsp3wo1Fd3iO96goDjlB8lzWYF/JpwLw+hM G0R1CuiGTL3vsxuT4R+9xv24uMMYWolezBvodkVNclmrS340pN6LfIt/E MrDBo6keeb9Zoq24V5EtBkQZ+n/PgBU3IFThG2UM3d/U+b39xCtXDiXLf jM3KZgKkWWcp6nqNNJFr1wHkPMrggXvFMUuJ6tpRpjniyVspA2v3F63G9 n2ed2Q2JEknqPA/JmmZWadeEKnf4fZ2DltVjAFhiNhT3UkYrvvN6ZIG3B A==; X-CSE-ConnectionGUID: kzU/KriMRx221R8/sKRz0A== X-CSE-MsgGUID: 45rMmzArSkqrL2YXgJMZ0A== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="74137856" X-IronPort-AV: E=Sophos;i="6.19,251,1754982000"; d="scan'208";a="74137856" X-CSE-ConnectionGUID: iSPyFyu9TS+/duopMWN8EA== X-CSE-MsgGUID: UFkaiXBHQoesSMsDwixM+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,251,1754982000"; d="scan'208";a="184275896" From: Zhao Liu To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chao Gao , John Allen , Babu Moger , Mathias Krause , Dapeng Mi , Zide Chen , Chenyi Qiang , Xiaoyao Li , Farrah Chen , Zhao Liu Subject: [PATCH v3 03/20] i386/cpu: Clean up arch lbr xsave struct and comment Date: Fri, 24 Oct 2025 14:56:15 +0800 Message-Id: <20251024065632.1448606-4-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024065632.1448606-1-zhao1.liu@intel.com> References: <20251024065632.1448606-1-zhao1.liu@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: pass client-ip=192.198.163.9; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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 @intel.com) X-ZM-MESSAGEID: 1761287754549158500 Content-Type: text/plain; charset="utf-8" Arch LBR state is area 15, not 19. Fix this comment. And considerring other areas don't mention user or supervisor state, for consistent style, remove "Supervisor mode" from its comment. Moreover, rename XSavesArchLBR to XSaveArchLBR since there's no need to emphasize XSAVES in naming; the XSAVE related structure is mainly used to represent memory layout. In addition, arch lbr specifies its offset of xsave component as 0. But this cannot help on anything. The offset of ExtSaveArea is initialized by accelerators (e.g., hvf_cpu_xsave_init(), kvm_cpu_xsave_init() and x86_tcg_cpu_xsave_init()), so explicitly setting the offset doesn't work and CPUID 0xD encoding has already ensure supervisor states won't have non-zero offsets. Drop the offset initialization and its comment from the xsave area of arch lbr. Tested-by: Farrah Chen Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li Reviewed-by: Zide Chen --- target/i386/cpu.c | 3 +-- target/i386/cpu.h | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f0e179c2d235..b9a5a0400dea 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2058,8 +2058,7 @@ ExtSaveArea x86_ext_save_areas[XSAVE_STATE_AREA_COUNT= ] =3D { }, [XSTATE_ARCH_LBR_BIT] =3D { .feature =3D FEAT_7_0_EDX, .bits =3D CPUID_7_0_EDX_ARCH_LBR, - .offset =3D 0 /*supervisor mode component, offset =3D 0 */, - .size =3D sizeof(XSavesArchLBR), + .size =3D sizeof(XSaveArchLBR), }, [XSTATE_XTILE_CFG_BIT] =3D { .feature =3D FEAT_7_0_EDX, .bits =3D CPUID_7_0_EDX_AMX_TILE, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d0da9bfe58ce..886a941e481c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1747,15 +1747,15 @@ typedef struct { =20 #define ARCH_LBR_NR_ENTRIES 32 =20 -/* Ext. save area 19: Supervisor mode Arch LBR state */ -typedef struct XSavesArchLBR { +/* Ext. save area 15: Arch LBR state */ +typedef struct XSaveArchLBR { uint64_t lbr_ctl; uint64_t lbr_depth; uint64_t ler_from; uint64_t ler_to; uint64_t ler_info; LBREntry lbr_records[ARCH_LBR_NR_ENTRIES]; -} XSavesArchLBR; +} XSaveArchLBR; =20 QEMU_BUILD_BUG_ON(sizeof(XSaveAVX) !=3D 0x100); QEMU_BUILD_BUG_ON(sizeof(XSaveBNDREG) !=3D 0x40); @@ -1766,7 +1766,7 @@ QEMU_BUILD_BUG_ON(sizeof(XSaveHi16_ZMM) !=3D 0x400); QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) !=3D 0x8); QEMU_BUILD_BUG_ON(sizeof(XSaveXTILECFG) !=3D 0x40); QEMU_BUILD_BUG_ON(sizeof(XSaveXTILEDATA) !=3D 0x2000); -QEMU_BUILD_BUG_ON(sizeof(XSavesArchLBR) !=3D 0x328); +QEMU_BUILD_BUG_ON(sizeof(XSaveArchLBR) !=3D 0x328); =20 typedef struct ExtSaveArea { uint32_t feature, bits; --=20 2.34.1