Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1774859pxb; Tue, 26 Oct 2021 15:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIGz7AFzkwP0JGHrAWybJtBFIFAXFdWqnsJmc+spLrTywkG3pSrVrgIXNBBgI8UZ19f3Xi X-Received: by 2002:a17:907:3f18:: with SMTP id hq24mr13761364ejc.151.1635288723731; Tue, 26 Oct 2021 15:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635288723; cv=none; d=google.com; s=arc-20160816; b=nSHhzLITAz0ZwCcCMYxlqR9iWyPdcs6SJgMWUpiiIBSRwoN4GuJsll9CbMrap9EjJB Q1VgSWWfhOGSvgjcxtqYygB4j0l8sx1MJz1jUEb1nr2J1FtgQNXuAR27OkoKEdSvPmzR qLJLWYGowahl9El+1oUx4vWCp3mcdWchiJgZFGBipL6AbGhpOAaVj24tTvic6Re3OL8M /6I+RILiT6+E+vLvasOG0GchAlgkS1Yw/4Trzrcv9TO0NIlCLMzPu5p24DozlIyfFqD8 zP/vXkrNjvEatLUSO/1ewTgzzlcGesdhf9JkJDap8abi1LPAY8A+qe6LnyLdJ6uTAjBZ 40FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=BdghuU66TBlI2LDNlvIdBVesAL/bvj3emUYRWWAJtjY=; b=fvMvsluswQ4P2X8ePC103d7C1ta4DJPYGhpiHq9lwoq42UQmeZUjuRbBmnx1XnmtOB be7722Lt3YGh/E6NTVTBg5LFG66XhzlCYGu6OOTtOQTfJMfT8TvaBbQCwkV00i0CO+Tb Xd/8V8aNQsfwapQO2A3Heqf6PNxPdTgCS8jc3SCoFZNOIySB735wEsTzWhAJ1nZQCLuB EHGqnmXPE1uNGu//fPOwSA8kH0YgbqW99kosWwggt8KTXGgryjgjsnNFBtZgzv8ykM5K wxveGU4/by7UbVOpYtB7jP/VwL6e8u2hG6MrQoGGMgyhI2DCWIo0gy69ObKnpDzS1sXt 3+ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZuPZbD+k; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si7715333ejy.319.2021.10.26.15.51.39; Tue, 26 Oct 2021 15:52:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZuPZbD+k; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237636AbhJZQUB (ORCPT + 99 others); Tue, 26 Oct 2021 12:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbhJZQTL (ORCPT ); Tue, 26 Oct 2021 12:19:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E12EC061767; Tue, 26 Oct 2021 09:16:47 -0700 (PDT) Date: Tue, 26 Oct 2021 16:16:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1635265005; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdghuU66TBlI2LDNlvIdBVesAL/bvj3emUYRWWAJtjY=; b=ZuPZbD+kPi1afWG9/Qlyvw0I7KgDApW+VYi+p5Afs6hhTrtD4J9T7yjj06/8PBDZsPZcnI 77Q0hsVW9VpA+5rPpLoa2kX2VUe802M8FVM3jNDTY1lA4lq3+9fLvxpJ58xx6Yr4i31IcS bJk6b0jPKc/bFCwZiJ3jxWYlknIrgLz3g5GQMmMAJ/93oervMoTCOXKbQKLNdKVMbenHNF eXN/wwQKJzpghlvMWzA+PsHS2zR709i8t4sDuqr8Abe8OfE0pVrcEnLkD6TcoOJma3wU86 gskz0C/EAMHVmeeXJ+btZi9xdTtmLKmjW2+EsYQoe3l4r0DJNlf59LQHdH8JXA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1635265005; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdghuU66TBlI2LDNlvIdBVesAL/bvj3emUYRWWAJtjY=; b=9R+Bm0Cw/Yqbn9gGOb+F2TN3THWuzVqcETSShTPBL1SmAQhfKzSzzD0C1Hq/2FDfC9IYLd CRS9r7lKq0ZTeDDg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fpu] x86/fpu: Add basic helpers for dynamically enabled features Cc: Thomas Gleixner , "Chang S. Bae" , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20211021225527.10184-8-chang.seok.bae@intel.com> References: <20211021225527.10184-8-chang.seok.bae@intel.com> MIME-Version: 1.0 Message-ID: <163526500485.626.11095255835330131135.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/fpu branch of tip: Commit-ID: 23686ef25d4ae81bc12fe3994d1905191fcf71f8 Gitweb: https://git.kernel.org/tip/23686ef25d4ae81bc12fe3994d1905191fcf71f8 Author: Thomas Gleixner AuthorDate: Thu, 21 Oct 2021 15:55:11 -07:00 Committer: Borislav Petkov CommitterDate: Tue, 26 Oct 2021 10:18:09 +02:00 x86/fpu: Add basic helpers for dynamically enabled features To allow building up the infrastructure required to support dynamically enabled FPU features, add: - XFEATURES_MASK_DYNAMIC This constant will hold xfeatures which can be dynamically enabled. - fpu_state_size_dynamic() A static branch for 64-bit and a simple 'return false' for 32-bit. This helper allows to add dynamic-feature-specific changes to common code which is shared between 32-bit and 64-bit without #ifdeffery. Signed-off-by: Thomas Gleixner Signed-off-by: Chang S. Bae Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20211021225527.10184-8-chang.seok.bae@intel.com --- arch/x86/include/asm/fpu/xstate.h | 21 +++++++++++++++++++++ arch/x86/kernel/fpu/core.c | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 43ae89d..cf28546 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -43,6 +43,9 @@ #define XFEATURE_MASK_USER_RESTORE \ (XFEATURE_MASK_USER_SUPPORTED & ~XFEATURE_MASK_PKRU) +/* Features which are dynamically enabled for a process on request */ +#define XFEATURE_MASK_USER_DYNAMIC 0ULL + /* All currently supported supervisor features */ #define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID) @@ -96,4 +99,22 @@ int xfeature_size(int xfeature_nr); void xsaves(struct xregs_state *xsave, u64 mask); void xrstors(struct xregs_state *xsave, u64 mask); +#ifdef CONFIG_X86_64 +DECLARE_STATIC_KEY_FALSE(__fpu_state_size_dynamic); +#endif + +#ifdef CONFIG_X86_64 +DECLARE_STATIC_KEY_FALSE(__fpu_state_size_dynamic); + +static __always_inline __pure bool fpu_state_size_dynamic(void) +{ + return static_branch_unlikely(&__fpu_state_size_dynamic); +} +#else +static __always_inline __pure bool fpu_state_size_dynamic(void) +{ + return false; +} +#endif + #endif diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index b05f6a3..4018083 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -25,6 +25,10 @@ #define CREATE_TRACE_POINTS #include +#ifdef CONFIG_X86_64 +DEFINE_STATIC_KEY_FALSE(__fpu_state_size_dynamic); +#endif + /* The FPU state configuration data for kernel and user space */ struct fpu_state_config fpu_kernel_cfg __ro_after_init; struct fpu_state_config fpu_user_cfg __ro_after_init;