Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1110240pxb; Thu, 21 Oct 2021 16:08:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqhxjWtxpjaLC6IxCCYFM/1HD0/A5iE/1xfnAlTPZVw6VDCSvQoHgz+SXRo1f1f2PR7o+t X-Received: by 2002:a63:470b:: with SMTP id u11mr6509463pga.441.1634857691833; Thu, 21 Oct 2021 16:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634857691; cv=none; d=google.com; s=arc-20160816; b=g5wlVqp4tdYIwhzfzDZABHTSQ4ulhZELy3Xg023CHRP6ZZSM7b2+tvVewtgpf2ylQu FTkxGOyI07axbwBEImkFN8icqht3F75DmUhSKQ6C3FFs0nrvIqzKXJxOIvroCa97OVbt LevYS3cWN16QgDfixXZofZyIsiZpVtvwcCGv3HK+SaRBXmpATSkMxbsyGPZR67kHHdWQ N/ZLejOq8wseiRN9OYVJ436I3WAsbEFEvbyziq3LeVqHBzXVk3nuZS/uGY3nxxavVpd+ 450//jI/RpL3FaOKbDqF/UndlcDu1dEJistDL4W1kigrXD7HL1pvnrxLInxywkFLAFEz 6RwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=damurgY3Egb3Q5qZIixAR3y6/mylU5j0WQY84PZWdoE=; b=y+1Vm7NQQp9v7m/pijidLGN/calSQeIXf18Xn4hKLS4N2dMpHOD6WsJCqUpgWzsbd7 G4Nzv3K6qiDkERndbJHpoMFfi7p6WXDzLdGDrq8I8DD0CmGlcBqbIAL/6iP2NHUD/7Xx +ePzS9c4oxoNewDIs4IEiiimEgOFSqbLxdjYFahvB14lf2hKADmIc7Bhp1eIZPVNni9S BCwX9H3ewp134SOHS95XgC0hLg8JmXvtlvMiE8uDuefKHyjXwexKg0Q1wKFk/hBM3Q70 /3feEikMArfLjbQZnVBkWE+t3Dcusz9nERZfloYE+0tFg84PGC1Timg1Tmrr7WM08/vD SKcQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q85si5062245pgq.112.2021.10.21.16.07.54; Thu, 21 Oct 2021 16:08:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232490AbhJUXHh (ORCPT + 99 others); Thu, 21 Oct 2021 19:07:37 -0400 Received: from mga05.intel.com ([192.55.52.43]:58072 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbhJUXHR (ORCPT ); Thu, 21 Oct 2021 19:07:17 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10144"; a="315380052" X-IronPort-AV: E=Sophos;i="5.87,170,1631602800"; d="scan'208";a="315380052" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 16:02:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,170,1631602800"; d="scan'208";a="445033352" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by orsmga006.jf.intel.com with ESMTP; 21 Oct 2021 16:02:24 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, dave.hansen@linux.intel.com, arjan@linux.intel.com, ravi.v.shankar@intel.com, chang.seok.bae@intel.com Subject: [PATCH 11/23] x86/fpu: Reset permission and fpstate on exec() Date: Thu, 21 Oct 2021 15:55:15 -0700 Message-Id: <20211021225527.10184-12-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211021225527.10184-1-chang.seok.bae@intel.com> References: <20211021225527.10184-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes from the tglx tree: * Add as a new patch. --- 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 177f27687261..073a8fc281d8 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -547,7 +547,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; @@ -582,7 +582,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; } @@ -612,7 +612,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. -- 2.17.1