From patchwork Wed Aug 14 10:41:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 171263 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp645737ily; Wed, 14 Aug 2019 03:42:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAr2iQfA+2N2HqXBYCVB9CpnRCTipIhCAu+Ub5FMQUXaCtMXw5rl97J00VpHTV/q+aqlgP X-Received: by 2002:a17:902:830c:: with SMTP id bd12mr42838968plb.237.1565779324986; Wed, 14 Aug 2019 03:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565779324; cv=none; d=google.com; s=arc-20160816; b=XPEGpS0JPm4G9/A6CDRjo84J675bjNCmpuESssQavNVniiwIvv7BQ6gtI+p2yUHfcf oGS4Nwc1t4e47zzDQUHgYfxjoLPdZ2kpCEc8O1NyZ/5Ve0XKWHgfouWQeL7rsjLP876r j4huHV13Dt/n5xYSRX68jDUSGcE0AThW3uGogHxh2J5NFMRCxPzdXua2WADHI27y+Uw8 xt5uHBExPGKyUM4UrEOin6u5woEuy8+72zqcT1HhhMAE2k+b+YbmIUbkC5mfeXwzMMiD ACniIpScEKQiqfE71xKY7Zx+zT0ylRcPuw3HhpSB2xlHbMxaV2GXKsC74+l68weB4dKF tMIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=LJ9lxStny/Kz6Ifmw1iSFUoWZEd/oFrXGADW9zcK2kc=; b=lOB1xXO5lcDJoctBTbYuxzZYnVt2ucJ+VeiJi4K/1I/cne41S/QlRIVjQKgJwTBRo6 slNYO5QKD6HiAgPnm4/Vqyiap8JSnoSFcK5Y4knzW8c30wzeeAfCMjQ9qatNFHZCJDQf 8Q6ftnyDzhNaJt+hjOXe+CuCJYgvj8q08UlxXw8FGzRg/+XA6olUr+UhdppQ21+ti4TW blIVilNZ4dSf8dXke7lYpaYnRVSLjPa9wT/+Z89xjeDgOi6454FIgdP43BGcaeVCoiGr pbpntLL8LPL1j1nyzLSo1MSJkE3TE9oAWnYLsgPRscqEYdCcv53YiE3rTejr0MFCbgXr FYZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si67050421pgr.514.2019.08.14.03.42.04; Wed, 14 Aug 2019 03:42:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727638AbfHNKmD (ORCPT + 28 others); Wed, 14 Aug 2019 06:42:03 -0400 Received: from foss.arm.com ([217.140.110.172]:52008 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727573AbfHNKl7 (ORCPT ); Wed, 14 Aug 2019 06:41:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C58AA1597; Wed, 14 Aug 2019 03:41:58 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 056CB3F706; Wed, 14 Aug 2019 03:41:56 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, akpm@linux-foundation.org, bigeasy@linutronix.de, bp@suse.de, catalin.marinas@arm.com, davem@davemloft.net, hch@lst.de, kan.liang@intel.com, mark.rutland@arm.com, mingo@kernel.org, peterz@infradead.org, riel@surriel.com, will@kernel.org Subject: [PATCH 8/9] x86/fpu: correctly check for kthreads Date: Wed, 14 Aug 2019 11:41:30 +0100 Message-Id: <20190814104131.20190-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190814104131.20190-1-mark.rutland@arm.com> References: <20190814104131.20190-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Per commit: 0cecca9d03c964ab ("x86/fpu: Eager switch PKRU state") ... switch_fpu_state() is trying to distinguish user threads from kthreads, such that kthreads consistently use init_pkru_value. It does do by looking at current->mm. In general, a non-NULL current->mm doesn't imply that current is a kthread, as kthreads can install an mm via use_mm(), and so it's preferable to use is_kthread() to determine whether a thread is a kthread. For consistency, let's use is_kthread() here. Signed-off-by: Mark Rutland Cc: Borislav Petkov Cc: Christoph Hellwig Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Rik van Riel Cc: Sebastian Andrzej Siewior --- arch/x86/include/asm/fpu/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 Acked-by: Sebastian Andrzej Siewior diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 4c95c365058a..ed3d85fa7c67 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -607,7 +607,7 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) * PKRU state is switched eagerly because it needs to be valid before we * return to userland e.g. for a copy_to_user() operation. */ - if (current->mm) { + if (!is_kthread(current)) { pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); if (pk) pkru_val = pk->pkru;