Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1769728pxb; Tue, 26 Oct 2021 15:44:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiElcQb28I6bDK6G2XpJZm3ID4gJg/4v/zYQ7oKG33PPAkzyG84DJmds9VCt4G3+yrf+ic X-Received: by 2002:a17:90b:4b46:: with SMTP id mi6mr1784605pjb.161.1635288262442; Tue, 26 Oct 2021 15:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635288262; cv=none; d=google.com; s=arc-20160816; b=U/7M8ApVNiXBI6OvXw9qxS+HxjFXeqUzWuSbvUqSOe/YlcQOpLZ06iAlyZ8JKyWNYH ImFhlSKYCg3LKdwlaiuRhPYqSd03JqFKO8UE5L+ZqT5ebC7nlv3804PrAD9l5rMQQJHm 02G85SbaH6olpw4A18wo6mAXgbblX88gqiSWQxtM/H5l4N9kRKe2REvKQZosQs9zQuy+ rvjzcLEZXFB6TUStLn7MYF16LG9jUp37gwr1qvgq3O8Uhg9O0hxWFrzfaeVlsh4zWrIt c/3FBbm2yjDN9ceTImY/8UR8ohsfFl6VGIHd0teLj7gIh4tvDIXz2iQskGUQj4l4ZRZg KU8A== 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=kl2/dPNxvG/GNXjEVHJWOlu2WEe55FBLF7nHskx6G8I=; b=yrNxmpxEzgBR6ESx+7MOsHmToUPnTEyeO39xzPQxLT2R1dqu/sSEIucBjvCF96PXBT Kw3tWVYQ4DOOoKV5nc5iZUSRtDrOJxKMiTrrqygPSCVkv/qLf/IUWt8y5ykWG5icvzBm hpfCI/SzuY2ebiCG/q1mG1inGUTmzbzxey8ED3KstNMjnIW4GQHoVRu72TzGV5Xeu5Ax EFHlBYKZKmoN2lcDeZgT3iM+00HNrsFp95j4c6n41GKG8uv5uDPraAUHSE3JG8qvcsfY WD1Y5/miHl9FB2KoGuNmGhcHEZSX79cH7nlgq4vjohvdR/aOvjVAQsKgJnxW2MzpfJH1 VAQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BEAm8ZlU; 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 na16si2949093pjb.128.2021.10.26.15.44.09; Tue, 26 Oct 2021 15:44:22 -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=BEAm8ZlU; 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 S237554AbhJZQTq (ORCPT + 99 others); Tue, 26 Oct 2021 12:19:46 -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 S237345AbhJZQTH (ORCPT ); Tue, 26 Oct 2021 12:19:07 -0400 Date: Tue, 26 Oct 2021 16:16:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1635265003; 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=kl2/dPNxvG/GNXjEVHJWOlu2WEe55FBLF7nHskx6G8I=; b=BEAm8ZlU2iJvccfFkr+9mTZLt7EzcetYZAV/1GgP52JDpRvbf9gb2K0OqqzMOHV0VERUFe hsfASeUBdEbUjN5TlZG6ZRVXTMbeRm9G/qoGrNIFZjq2fcmcLVk0GIbhkG4+SBCOTRlYVA eCOQH/mkbzWfgtLyTKseWIuFth9pLfANEPIgomXP/aWsSPcLXmc4crqQlCxtsORtFh+juw vYhkwa/smwbEBnh2hHA4wGaTF4/77+NKXysgiP1rOKJjopZ70X+N7fM7X0QVqkuee9rYio 4FfrFHcv0iDed48dZWLsU0Up6UKwVePEKzEOY1Udj4bg5YVifp5Vrq/LT4WgFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1635265003; 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=kl2/dPNxvG/GNXjEVHJWOlu2WEe55FBLF7nHskx6G8I=; b=KdUES9swXXjYZKFllsCVprbd0f7vGjor4zFc82I7DNrQg8F5K9ZJnFD4Fj3M1An54megJC HPROmn2m/tYxBjBg== 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: Reset permission and fpstate on exec() Cc: "Chang S. Bae" , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20211021225527.10184-12-chang.seok.bae@intel.com> References: <20211021225527.10184-12-chang.seok.bae@intel.com> MIME-Version: 1.0 Message-ID: <163526500203.626.4159930425184008220.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: e61d6310a0f80cb986fd2076d432760b3619fb6d Gitweb: https://git.kernel.org/tip/e61d6310a0f80cb986fd2076d432760b3619fb6d Author: Chang S. Bae AuthorDate: Thu, 21 Oct 2021 15:55:15 -07:00 Committer: Borislav Petkov CommitterDate: Tue, 26 Oct 2021 10:18:09 +02:00 x86/fpu: Reset permission and fpstate on exec() On exec(), extended register states saved in the buffer is cleared. With dynamic features, each task carries variables besides the register states. The struct fpu has permission information and struct fpstate contains buffer size and feature masks. They are all dynamically updated with dynamic features. Reset the current task's entire FPU data before an exec() so that the new task starts with default permission and fpstate. Rename the register state reset function because the old naming confuses as it does not reset struct fpstate. Signed-off-by: Chang S. Bae Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20211021225527.10184-12-chang.seok.bae@intel.com --- arch/x86/kernel/fpu/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 1ff6b83..3349068 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -544,7 +544,7 @@ static inline void restore_fpregs_from_init_fpstate(u64 features_mask) /* * Reset current->fpu memory state to the init values. */ -static void fpu_reset_fpstate(void) +static void fpu_reset_fpregs(void) { struct fpu *fpu = ¤t->thread.fpu; @@ -579,7 +579,7 @@ void fpu__clear_user_states(struct fpu *fpu) fpregs_lock(); if (!cpu_feature_enabled(X86_FEATURE_FPU)) { - fpu_reset_fpstate(); + fpu_reset_fpregs(); fpregs_unlock(); return; } @@ -609,7 +609,8 @@ void fpu__clear_user_states(struct fpu *fpu) void fpu_flush_thread(void) { - fpu_reset_fpstate(); + fpstate_reset(¤t->thread.fpu); + fpu_reset_fpregs(); } /* * Load FPU context before returning to userspace.