Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1769591pxb; Tue, 26 Oct 2021 15:44:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcrQ8fHtk3FxdO5hG/Z2OxU6NJsysAcgp1tLMQBewkNHNyC0mHhC+2GR8idMfNnhyLCO11 X-Received: by 2002:a63:b448:: with SMTP id n8mr21349398pgu.31.1635288250606; Tue, 26 Oct 2021 15:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635288250; cv=none; d=google.com; s=arc-20160816; b=AEWN4EsIK7jAV1yvYomT2Sgqk3j/qZnfmTuTDOzz7UKA4BYBW66KyrXuaoQ5KhawAO 9iIhC2lX6bOlQEPjtXGR4x3VzTGmLDe2OH7NUgvaT8R/ChsCJxCvRVaHHHhsBwhm6/Va MKZXLu9c20pxr8Dmiohjnf/GQxfMTQr3IGXzzXRZYdjAUY2yObc5z/tqwh3eJWUx6wP5 QK/9d7gxvobXq2efT/DXarx9EFEiRIqllx7L+poW8rOxs3VIXYgE/POMzDKB1gFDwK+K a/jK/C8ckJ4AeYoTfYoJNQo9B/wY1SWMZ8JTEvtGL9fY3sLSiBeVB08cyL7csL6KjjSr ePWg== 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=rI3L6NWRbAk/UxwHxAMhlHIaFcQAAhRBainOt9/pvis=; b=oKxtaGwnRanRzQvck3VxdVZBK+9hi5H/fmHisBOlhcvgFgIneKQSu4kXQe+LwhvoUd GljWPJyk/9iJ9spE51Sk8zLBOvifeg4aackASX8FcbWWmXq4w5LkoUJvCiWM83YQJtHh o7pEduY9zcbNjbvcaDYn+c8t+18A20Ucb6tjSPFw/ApEdJ/uke5FimPePJkDG7JulIW0 pVCppQlgrNe7+oBKb1IEzqHcNjd6zcj+vQ+zVcwiY5nwO/vOa6NWFkOMHaKOJKwDrEph yZpeeEdEGToMiSQ1w+lImUUllNKIKywbz1Uv/nJNMDnoGACQe0UvyDvcT9E/mMD268ON Xbvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4lxkMfSP; dkim=neutral (no key) header.i=@linutronix.de; 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 oa2si2872840pjb.123.2021.10.26.15.43.52; Tue, 26 Oct 2021 15:44:10 -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=4lxkMfSP; dkim=neutral (no key) header.i=@linutronix.de; 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 S237481AbhJZQT2 (ORCPT + 99 others); Tue, 26 Oct 2021 12:19:28 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:34588 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237335AbhJZQTF (ORCPT ); Tue, 26 Oct 2021 12:19:05 -0400 Date: Tue, 26 Oct 2021 16:16:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1635265000; 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=rI3L6NWRbAk/UxwHxAMhlHIaFcQAAhRBainOt9/pvis=; b=4lxkMfSPtLCtDOmVFZJ5rF+gEsw9mKVTW27voDOEQ9Ydrgau2gd1OQku9rBAJ9ObmY9sQj YD50ql2jnst9J0k2v+1f80o3ECBtnhU7QwysCwyoScVH30cKqrcpxuKfoyzANWXRZ4dOup 1XKQRZaYygZyj1sGnJCu2dDSLMYHTOHj+4AC0PMKqglyuIi4xK1+0LBwTYTLKO99WfE5vo qlFiNRcOuGi11SrWa5V6meWTVQyZhOdTgum8WnMGnVwCYmcpq21ztu9xd3FKMtjtliFrLK 1JtJpAxo3RqkcPfNQwrEkYePSRBsPvpKPAL2kE5dsWpQS/2xqHZo7Hh2DgHJnA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1635265000; 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=rI3L6NWRbAk/UxwHxAMhlHIaFcQAAhRBainOt9/pvis=; b=ngeHkUtrODCyQj4B79RceNuG+paJTL+U5795raPDgbFLYRhCxQb5sV1+s0kcML7aqJJYr2 UV16ub8fbDY04fAA== From: "tip-bot2 for Chang S. Bae" 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 XFD state to fpstate Cc: "Chang S. Bae" , Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20211021225527.10184-15-chang.seok.bae@intel.com> References: <20211021225527.10184-15-chang.seok.bae@intel.com> MIME-Version: 1.0 Message-ID: <163526499987.626.11601427955477389497.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: 8bf26758ca9659866b844dd51037314b4c0fa6bd Gitweb: https://git.kernel.org/tip/8bf26758ca9659866b844dd51037314b4c0fa6bd Author: Chang S. Bae AuthorDate: Thu, 21 Oct 2021 15:55:18 -07:00 Committer: Borislav Petkov CommitterDate: Tue, 26 Oct 2021 10:18:09 +02:00 x86/fpu: Add XFD state to fpstate Add storage for XFD register state to struct fpstate. This will be used to store the XFD MSR state. This will be used for switching the XFD MSR when FPU content is restored. Add a per-CPU variable to cache the current MSR value so the MSR has only to be written when the values are different. Signed-off-by: Chang S. Bae Signed-off-by: Thomas Gleixner Signed-off-by: Chang S. Bae Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20211021225527.10184-15-chang.seok.bae@intel.com --- arch/x86/include/asm/fpu/types.h | 3 +++ arch/x86/kernel/fpu/core.c | 2 ++ arch/x86/kernel/fpu/xstate.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h index 595122f..b189763 100644 --- a/arch/x86/include/asm/fpu/types.h +++ b/arch/x86/include/asm/fpu/types.h @@ -322,6 +322,9 @@ struct fpstate { /* @user_xfeatures: xfeatures valid in UABI buffers */ u64 user_xfeatures; + /* @xfd: xfeatures disabled to trap userspace use. */ + u64 xfd; + /* @is_valloc: Indicator for dynamically allocated state */ unsigned int is_valloc : 1; diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 3349068..3b72cdd 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -27,6 +27,7 @@ #ifdef CONFIG_X86_64 DEFINE_STATIC_KEY_FALSE(__fpu_state_size_dynamic); +DEFINE_PER_CPU(u64, xfd_state); #endif /* The FPU state configuration data for kernel and user space */ @@ -409,6 +410,7 @@ static void __fpstate_reset(struct fpstate *fpstate) fpstate->user_size = fpu_user_cfg.default_size; fpstate->xfeatures = fpu_kernel_cfg.default_features; fpstate->user_xfeatures = fpu_user_cfg.default_features; + fpstate->xfd = init_fpstate.xfd; } void fpstate_reset(struct fpu *fpu) diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index 4ce1dc0..32a4dee 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -5,6 +5,10 @@ #include #include +#ifdef CONFIG_X86_64 +DECLARE_PER_CPU(u64, xfd_state); +#endif + static inline void xstate_init_xcomp_bv(struct xregs_state *xsave, u64 mask) { /*