From nobody Wed Dec 17 10:52:32 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 3F56D25D1F8; Mon, 12 May 2025 08:57:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747040271; cv=none; b=JsnUOu6U49leQpvChgcLLE5UpqgXde+VQIzAerzMm2LwzAIZl37S8ciqqt+y/UIft7PP5LeJSpFVzQ/UJYsng7xhzS0KKXkqVI/qkWksJamoMy7jBmEYliv4v/VMTVAR0CDVM0FrC2fZGzxejmk+BIQiA8CALV4t5fmP8ciukP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747040271; c=relaxed/simple; bh=0KNdT4K2HwqU0ZdMB4peGWxDogoI8jp/u9JVa2ytbX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cv7eCWKS5+FYzuvV9eMevv2VcJG1Q/OSaJjLobF/KlMn019HKl1e5KZ/FhxEXeRF57fIjW0qckJ4N31U/nk4z/LXjCWPQeD1gDc2GBAhmjoChCHmQdHSGZDvQbBv3TPC3OxKPe8sphjPfcet/PbmRCzgF4LaK1ylCdt9LeQ4eAM= 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=IqweOwXN; arc=none smtp.client-ip=192.198.163.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="IqweOwXN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747040267; x=1778576267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0KNdT4K2HwqU0ZdMB4peGWxDogoI8jp/u9JVa2ytbX4=; b=IqweOwXNZp4+HuGrYzWtlXPpkBA+4Gr5YWrc+fNy0Zs5FEBzZnY+JGEy 3M0OsHBJmVgF36RGbYLs06TTPpS+TfaNsLbL4btiqXUHIDFicu4DN3NrE hqBuPK+AI+8IB1BitMOr2uvFa0BN4K8kb3G1nSf2Lr/AVhEHZXBNZXwdl pt7irpSk6jOwPpk9MR2IfHvbYkf7u7aPbWLTSeehu8rHvet0zO8P4msOt rCPzU1k/GGoSVKLHYyuH72TkyTh83dJh4Rm3FBjrwNBCpolmimT4LCbD5 PH75C+hImz1J5LuuAMfHQCDep515xHNhQTCybxlW8VnKccR138j34m20q A==; X-CSE-ConnectionGUID: KfU7m4ykR+mzrUy9MSb/Zw== X-CSE-MsgGUID: eMqnrVoyR4W9ErGRl2ZzLw== X-IronPort-AV: E=McAfee;i="6700,10204,11430"; a="59488731" X-IronPort-AV: E=Sophos;i="6.15,281,1739865600"; d="scan'208";a="59488731" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2025 01:57:46 -0700 X-CSE-ConnectionGUID: WRlz5RKLQWufey33GcoE5A== X-CSE-MsgGUID: D04i/FHNSvWzKMcTrXMsTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,281,1739865600"; d="scan'208";a="138235787" Received: from 984fee019967.jf.intel.com ([10.165.54.94]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2025 01:57:46 -0700 From: Chao Gao To: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, tglx@linutronix.de, dave.hansen@intel.com, seanjc@google.com, pbonzini@redhat.com Cc: peterz@infradead.org, rick.p.edgecombe@intel.com, weijiang.yang@intel.com, john.allen@amd.com, bp@alien8.de, chang.seok.bae@intel.com, xin3.li@intel.com, Chao Gao , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Kees Cook , Stanislav Spassov , Eric Biggers Subject: [PATCH v7 4/6] x86/fpu: Remove xfd argument from __fpstate_reset() Date: Mon, 12 May 2025 01:57:07 -0700 Message-ID: <20250512085735.564475-5-chao.gao@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250512085735.564475-1-chao.gao@intel.com> References: <20250512085735.564475-1-chao.gao@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The initial values for fpstate::xfd differ between guest and host fpstates. Currently, the initial values are passed as an argument to __fpstate_reset(). But, __fpstate_reset() already assigns different default features and sizes based on the type of fpstates (i.e., guest or host). So, handle fpstate::xfd in a similar way to highlight the differences in the initial xfd value between guest and host fpstates Suggested-by: Sean Christopherson Signed-off-by: Chao Gao Link: https://lore.kernel.org/all/aBuf7wiiDT0Wflhk@google.com/ --- v7: new. arch/x86/kernel/fpu/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 0d501bd25d79..a3cafed350e0 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -211,7 +211,7 @@ void fpu_reset_from_exception_fixup(void) } =20 #if IS_ENABLED(CONFIG_KVM) -static void __fpstate_reset(struct fpstate *fpstate, u64 xfd); +static void __fpstate_reset(struct fpstate *fpstate); =20 static void fpu_lock_guest_permissions(void) { @@ -246,8 +246,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu) fpstate->is_valloc =3D true; fpstate->is_guest =3D true; =20 - /* Leave xfd to 0 (the reset value defined by spec) */ - __fpstate_reset(fpstate, 0); + __fpstate_reset(fpstate); fpstate_init_user(fpstate); =20 gfpu->fpstate =3D fpstate; @@ -536,7 +535,7 @@ void fpstate_init_user(struct fpstate *fpstate) fpstate_init_fstate(fpstate); } =20 -static void __fpstate_reset(struct fpstate *fpstate, u64 xfd) +static void __fpstate_reset(struct fpstate *fpstate) { /* * Initialize sizes and feature masks. Supervisor features and @@ -546,21 +545,23 @@ static void __fpstate_reset(struct fpstate *fpstate, = u64 xfd) if (fpstate->is_guest) { fpstate->size =3D guest_default_cfg.size; fpstate->xfeatures =3D guest_default_cfg.features; + /* Leave xfd to 0 (the reset value defined by spec) */ + fpstate->xfd =3D 0; } else { fpstate->size =3D fpu_kernel_cfg.default_size; fpstate->xfeatures =3D fpu_kernel_cfg.default_features; + fpstate->xfd =3D init_fpstate.xfd; } =20 fpstate->user_size =3D fpu_user_cfg.default_size; fpstate->user_xfeatures =3D fpu_user_cfg.default_features; - fpstate->xfd =3D xfd; } =20 void fpstate_reset(struct fpu *fpu) { /* Set the fpstate pointer to the default fpstate */ fpu->fpstate =3D &fpu->__fpstate; - __fpstate_reset(fpu->fpstate, init_fpstate.xfd); + __fpstate_reset(fpu->fpstate); =20 /* Initialize the permission related info in fpu */ fpu->perm.__state_perm =3D fpu_kernel_cfg.default_features; --=20 2.47.1