Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7F3271476 for ; Fri, 24 Oct 2025 06:34:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761287691; cv=none; b=FyA90WwI4zCVWr/TBREyxd39dNU3hP5Lg5LOTdgYOtX0pTWVoWw4HHE2voE10Kye9Tlx+N/xG2PJg0wUU+9MJ+/6mROkX/cCU6kVywL/uDxq23oIddrnMAFrhfL+T0BVhBnhfpkfFDFGsCSS2VkVRL1P5eLhaG7Q/4BTOovvMWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761287691; c=relaxed/simple; bh=7tOeAaUzQYqTAHH7/NYu9sDsu+/WQtAS5FGKwnZ2ICw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nNCvuYeIVB+v7c3HDo88Dxeybn9hkRpEBwifYaOYjS4f8PVXdKpqr35EqVgYF0NHmya5McNKvQJs5bBWFK797KHZpiHdg1Ek14vJTM6rfqltQ/QKuIU+8fbCE9XOvXIJ06R5uZJ4i7TjF07NiJGNm3dpXjxY0qv2qYVUt3US4To= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HwQE1YpP; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HwQE1YpP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761287691; x=1792823691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7tOeAaUzQYqTAHH7/NYu9sDsu+/WQtAS5FGKwnZ2ICw=; b=HwQE1YpPRmCRhgGSXE8FU31rcnhHC6r/KQpa7QfcxEh9iJyw16/aq7tf WVEaBLhXpyX6ngAUtZZjSYhd9UtdVca6Ih2fPP2/WbKgV8RSoIyCYVLrL +MGPcTAOIiQaxbnXj0dZnDzIUC14seZ7333z7nJIFLpngS+LxNliLq5bF TwS2XfdCvQPccumdeMkYDgHZKe2/QoHd2xZix/DK2YTlzbBuPCX8E1R+B eBxSMaxqSVec/YtlZNFvoeEQt90tUaRNmKRD3S3BUbrjiqLs2BFv/0bMO zH/cvQ1NUUr7ubIvoWkGhRnqeQlAygO6fGJUFTcMggi1SBQckily3dbFk A==; X-CSE-ConnectionGUID: yqykNnVKRmWxe4ZxDq7UwA== X-CSE-MsgGUID: zrf5X+t4SMensAu+JpuDKA== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="86095554" X-IronPort-AV: E=Sophos;i="6.19,251,1754982000"; d="scan'208";a="86095554" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2025 23:34:51 -0700 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" 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 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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] = { }, [XSTATE_ARCH_LBR_BIT] = { .feature = FEAT_7_0_EDX, .bits = CPUID_7_0_EDX_ARCH_LBR, - .offset = 0 /*supervisor mode component, offset = 0 */, - .size = sizeof(XSavesArchLBR), + .size = sizeof(XSaveArchLBR), }, [XSTATE_XTILE_CFG_BIT] = { .feature = FEAT_7_0_EDX, .bits = 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 { #define ARCH_LBR_NR_ENTRIES 32 -/* 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; QEMU_BUILD_BUG_ON(sizeof(XSaveAVX) != 0x100); QEMU_BUILD_BUG_ON(sizeof(XSaveBNDREG) != 0x40); @@ -1766,7 +1766,7 @@ QEMU_BUILD_BUG_ON(sizeof(XSaveHi16_ZMM) != 0x400); QEMU_BUILD_BUG_ON(sizeof(XSavePKRU) != 0x8); QEMU_BUILD_BUG_ON(sizeof(XSaveXTILECFG) != 0x40); QEMU_BUILD_BUG_ON(sizeof(XSaveXTILEDATA) != 0x2000); -QEMU_BUILD_BUG_ON(sizeof(XSavesArchLBR) != 0x328); +QEMU_BUILD_BUG_ON(sizeof(XSaveArchLBR) != 0x328); typedef struct ExtSaveArea { uint32_t feature, bits; -- 2.34.1