From nobody Mon Oct 27 14:23:07 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=1761287771; cv=none; d=zohomail.com; s=zohoarc; b=BloHU3ybunWtHJ4tBWpMieaNOvhS1XOC9cipCmMVaFD11ijOPKr7GbqgKlCcB+1SclZxMd58CNNMx6xlLIdmJC5RNubMWWxpkL4N1/lIyfCoQ4ZCjnca/n1kTYXU5/Ct5HDvQgmlMIuVqniNynvLvL76mG0zVlJFDY4udq3KhJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761287771; 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=opjcb2FU+wFxLlLZWfRaUj7u/m/7/jaAWjWktbepGyY=; b=nDxpuR1gPrRU/ZpLXaPOd1vs4kHaoO/FAgChO7LYkfIb0udDAtX9jNx7H2gnY0tQFixVY6JYDepQiX1niWR5XUEGHnE05ZRFnAwP2MoMC6uXps4WRmd9A0e/3BjMDVGAio2ucXGRB3WvnWTAaXxjDzBUrO7N3BxkikeOdFTTHmY= 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 1761287770996914.0195449331453; Thu, 23 Oct 2025 23:36:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vCBOQ-0003VH-9K; Fri, 24 Oct 2025 02:35:18 -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 1vCBON-0003Uk-RP for qemu-devel@nongnu.org; Fri, 24 Oct 2025 02:35:16 -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 1vCBOM-0003kG-1w for qemu-devel@nongnu.org; Fri, 24 Oct 2025 02:35:15 -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:35:13 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by fmviesa006.fm.intel.com with ESMTP; 23 Oct 2025 23:35:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761287714; x=1792823714; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J1ZCUKwfTEEbJGJiWsUOSMTCasUamsf1kDC1iuV9N+A=; b=noVzHKXW61QqyDG98KPjWet6GuRDKvqFRJ7HiJEJCllLegSsjSDBzxsn DDiWcBEt0SQUFiXqN2xfR99V2mEBw57GVHZyarABfcTe8lsTevTY7WMw6 8vr5b8ZHoXHc/BRcRds+m/WDKzjqASymRBeN14fBU2URFCbpm9N6jT/xf fQ8eWlOkueWq28Ya2Ru5JMrcOpRSOm82ejt0fLnxbpL4qf+NWKZEymQLi 2CnhCJ+zsVW7Fkw4CvZgl67WAHTpaSTCWAc0iPHPtgl6BV+t/Z4idzLBO PRV+bPm8w/PhYMdWlP9RhiEBGqmPFdfid8C0tlm2k+FzmPdpxB/CtDUEX A==; X-CSE-ConnectionGUID: aA0kSKw1REeIAqG8ZrYb2A== X-CSE-MsgGUID: yMlAYASBRw+jZfJ0VacySw== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="74137888" X-IronPort-AV: E=Sophos;i="6.19,251,1754982000"; d="scan'208";a="74137888" X-CSE-ConnectionGUID: nKAAY43bRoCSRywEKzFVvA== X-CSE-MsgGUID: nVLkiWPbQ++CaQKbs7y7uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,251,1754982000"; d="scan'208";a="184276057" 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 09/20] i386/cpu: Fix supervisor xstate initialization Date: Fri, 24 Oct 2025 14:56:21 +0800 Message-Id: <20251024065632.1448606-10-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: 1761287774601158501 Content-Type: text/plain; charset="utf-8" From: Chao Gao Arch lbr is a supervisor xstate, but its area is not covered in x86_cpu_init_xsave(). Fix it by checking supported xss bitmap. In addition, drop the (uint64_t) type casts for supported_xcr0 since x86_cpu_get_supported_feature_word() returns uint64_t so that the cast is not needed. Then ensure line length is within 90 characters. Tested-by: Farrah Chen Signed-off-by: Chao Gao Co-developed-by: Zhao Liu Signed-off-by: Zhao Liu Reviewed-by: Xiaoyao Li --- target/i386/cpu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5cd335bb5574..1917376dbea9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -9707,20 +9707,23 @@ static void x86_cpu_post_initfn(Object *obj) static void x86_cpu_init_xsave(void) { static bool first =3D true; - uint64_t supported_xcr0; + uint64_t supported_xcr0, supported_xss; int i; =20 if (first) { first =3D false; =20 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_HI) | x86_cpu_get_supported_feature_word(NULL, FEAT_XSAVE_XCR0_LO); + supported_xss =3D + x86_cpu_get_supported_feature_word(NULL, FEAT_XSAVE_XSS_HI) <<= 32 | + x86_cpu_get_supported_feature_word(NULL, FEAT_XSAVE_XSS_LO); =20 for (i =3D XSTATE_SSE_BIT + 1; i < XSAVE_STATE_AREA_COUNT; i++) { ExtSaveArea *esa =3D &x86_ext_save_areas[i]; =20 - if (!(supported_xcr0 & (1 << i))) { + if (!((supported_xcr0 | supported_xss) & (1 << i))) { esa->size =3D 0; } } --=20 2.34.1