From patchwork Thu May 27 23:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 12285775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E6CC47089 for ; Thu, 27 May 2021 23:57:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 72D6361006 for ; Thu, 27 May 2021 23:57:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72D6361006 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D0A9C6B0070; Thu, 27 May 2021 19:57:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCF776B0071; Thu, 27 May 2021 19:57:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D6676B0072; Thu, 27 May 2021 19:57:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 3955C6B0070 for ; Thu, 27 May 2021 19:57:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D0CD2ABF4 for ; Thu, 27 May 2021 23:57:37 +0000 (UTC) X-FDA: 78188675754.22.2C9F118 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf22.hostedemail.com (Postfix) with ESMTP id 12E15C007753 for ; Thu, 27 May 2021 23:57:28 +0000 (UTC) IronPort-SDR: v4qcDwbOhvlpv0xLGB74MZOGunAjgsGcnZt0iheTupwxqa2YI05ukXltggCu9khjT6jwsuCo2b ZnSdd9AJ8kEQ== X-IronPort-AV: E=McAfee;i="6200,9189,9997"; a="199820404" X-IronPort-AV: E=Sophos;i="5.83,228,1616482800"; d="scan'208";a="199820404" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2021 16:57:36 -0700 IronPort-SDR: ZeIFmsdsFsOlue/8YEFXyR6NydiZCn/WmQ1NjqfrLjrWgFb8OJC/EeEGhPimHBbp8ROR/GbO2m 9PPKTfr6G0RQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,228,1616482800"; d="scan'208";a="472807339" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by FMSMGA003.fm.intel.com with ESMTP; 27 May 2021 16:57:35 -0700 Subject: [PATCH 2/5] x86/pkeys: rename write_pkru() To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org,Dave Hansen ,tglx@linutronix.de,mingo@redhat.com,bp@alien8.de,x86@kernel.org,luto@kernel.org,shuah@kernel.org,babu.moger@amd.com,dave.kleikamp@oracle.com,linuxram@us.ibm.com,bauerman@linux.ibm.com,bigeasy@linutronix.de From: Dave Hansen Date: Thu, 27 May 2021 16:51:13 -0700 References: <20210527235109.B2A9F45F@viggo.jf.intel.com> In-Reply-To: <20210527235109.B2A9F45F@viggo.jf.intel.com> Message-Id: <20210527235113.C5DAFE12@viggo.jf.intel.com> X-Rspamd-Queue-Id: 12E15C007753 Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf22.hostedemail.com: domain of dave.hansen@linux.intel.com has no SPF policy when checking 192.55.52.93) smtp.mailfrom=dave.hansen@linux.intel.com X-Rspamd-Server: rspam04 X-Stat-Signature: yr1n7n1aqhyxnmm5qxa1hdk8fdoryda3 X-HE-Tag: 1622159848-795055 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Dave Hansen write_pkru() was once concerned purely with writing to the PKRU register. However, the current task XSAVE buffer must also be updated in a coordinated way. Change the naming to reflect that this is an operation which applies to a task (current) and its state in addition to the register itself. Signed-off-by: Dave Hansen Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: x86@kernel.org Cc: Andy Lutomirski Cc: Shuah Khan Cc: Babu Moger Cc: Dave Kleikamp Cc: Ram Pai Cc: Thiago Jung Bauermann Cc: Sebastian Andrzej Siewior --- b/arch/x86/include/asm/fpu/xstate.h | 6 +++++- b/arch/x86/kernel/fpu/xstate.c | 2 +- b/arch/x86/mm/pkeys.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff -puN arch/x86/include/asm/fpu/xstate.h~rename-write_pkru arch/x86/include/asm/fpu/xstate.h --- a/arch/x86/include/asm/fpu/xstate.h~rename-write_pkru 2021-05-27 16:40:24.618705468 -0700 +++ b/arch/x86/include/asm/fpu/xstate.h 2021-05-27 16:40:24.631705468 -0700 @@ -124,7 +124,11 @@ static inline u32 read_pkru(void) return 0; } -static inline void write_pkru(u32 pkru) +/* + * Update all of the PKRU state for the current task: + * PKRU register and PKRU xstate. + */ +static inline void current_write_pkru(u32 pkru) { struct pkru_state *pk; diff -puN arch/x86/kernel/fpu/xstate.c~rename-write_pkru arch/x86/kernel/fpu/xstate.c --- a/arch/x86/kernel/fpu/xstate.c~rename-write_pkru 2021-05-27 16:40:24.620705468 -0700 +++ b/arch/x86/kernel/fpu/xstate.c 2021-05-27 16:40:24.633705468 -0700 @@ -1026,7 +1026,7 @@ int arch_set_user_pkey_access(struct tas old_pkru &= ~((PKRU_AD_BIT|PKRU_WD_BIT) << pkey_shift); /* Write old part along with new part: */ - write_pkru(old_pkru | new_pkru_bits); + current_write_pkru(old_pkru | new_pkru_bits); return 0; } diff -puN arch/x86/mm/pkeys.c~rename-write_pkru arch/x86/mm/pkeys.c --- a/arch/x86/mm/pkeys.c~rename-write_pkru 2021-05-27 16:40:24.626705468 -0700 +++ b/arch/x86/mm/pkeys.c 2021-05-27 16:40:24.634705468 -0700 @@ -139,7 +139,7 @@ void copy_init_pkru_to_fpregs(void) * Override the PKRU state that came from 'init_fpstate' * with the baseline from the process. */ - write_pkru(init_pkru_value_snapshot); + current_write_pkru(init_pkru_value_snapshot); } static ssize_t init_pkru_read_file(struct file *file, char __user *user_buf,