Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp535362pxb; Fri, 28 Jan 2022 04:51:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOxELyKZwsCBvWaEKNoxf+Yh1p1jhq/n8dTq1KBLwHJ14u39C0tfdKP+i10X3jV7v7Nilt X-Received: by 2002:a17:907:7e8e:: with SMTP id qb14mr6697970ejc.478.1643374269329; Fri, 28 Jan 2022 04:51:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643374269; cv=none; d=google.com; s=arc-20160816; b=QzpZkWkChG5TckmGI2xDsvrCayWitYI45ue2qgLNyfmimXPSAcbJd2XonRrcsSeZIM r8pQuioe49b19Q+Cu6ydGxJmQmg2/1jEWQVWyz6MeBtU6sKfX62QgLZV07k7/1Dd6cVH P76e7lNcWsSJW1ACyt5ni7Qs2A3whBeAwbMjHZMRuQhPLYgeZ9JZXzb3KzgK1yptOU48 tNulleVvUz2Ad2zIRcW5DzjMFdl/3v2kEo/tZ0E6SnubMut0Om4CYok8KwsCeqsisgna iNEjkBGcjE8lf8KRk3yG228t6kYN/uZu+QVgdFbwSjKd2K3CPUlBpSWloy0JZ2AD2zF0 JubQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mwZ6NnjaNLE4lwxa4cGGOUF0IPMkzqlA5c39rhBlk0M=; b=NCm3Px1u8wli49gxiFfVF+olAcWW9xsGF71QwTtKqYVDXk5WrsHRL8x5grHwtfBPsT 0EyqbAii/WrwvgwGWOZfJ+6ZEVTFs97ZLlzYkJBrjAPrYSCkKZlSufC7kIgxVZXX8rSG 5PCK+ly26VOV6DL8fHexmwX/dxyyC1b4gj7au1pN5qvGRmh8nsXSrk5iuer6zd7rpeek Ta2MYrunCpK8yCB8R2w0pcyDBE1xTO1gz1tFGTnO4jJRNdVedjNZgx8KeGZSSZIyQDUO M1QXy02T7ymvjPfzwyiW/UtebvDEQU6zKuLccor0Zx3tnRHNYVf0D9lVPi3zrnPNnXlQ kUuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NN1lDplo; 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=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 27si2913855eja.324.2022.01.28.04.50.44; Fri, 28 Jan 2022 04:51:09 -0800 (PST) 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=@intel.com header.s=Intel header.b=NN1lDplo; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244775AbiA0Rz3 (ORCPT + 99 others); Thu, 27 Jan 2022 12:55:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:19418 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244712AbiA0RzP (ORCPT ); Thu, 27 Jan 2022 12:55:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643306115; x=1674842115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NOpGQHbLg5P47A/NaN991tZuJORFucxdhxqawe4Tf4o=; b=NN1lDplokQSk92k5E8edBTaxR2pCD7yA0s/Oemuzn7osUYaFTdzgBb5b fBgrRapZPfWZ0lC3EpiljD87uypwqHD13XKEvDg/jjwmliNeSa0V/UhvE qtQVQzjTudz0zlXOyZSKz7NPPCsgoraffNgNPBBPx2wJg5TFdiFF8xgUT aGHt0bGcsWwUsIel9IDbYLyP9bUSaZxo7CTNSUJiWNvR2THqx/VPX5b0W 27XiA0BtiENeJLVUK4BYCMxPLweLcMhcWiDWEwf2hPOV6zeCzDmPrsq1V JZp9cn1LC9dbPcTAAFGVpw3t/2/UzgZZeaMdWhdXFxEmFhcYVCpCgceMz w==; X-IronPort-AV: E=McAfee;i="6200,9189,10239"; a="234302427" X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="234302427" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:10 -0800 X-IronPort-AV: E=Sophos;i="5.88,321,1635231600"; d="scan'208";a="674796103" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2022 09:55:09 -0800 From: ira.weiny@intel.com To: Dave Hansen , "H. Peter Anvin" , Dan Williams Cc: Ira Weiny , Fenghua Yu , Rick Edgecombe , linux-kernel@vger.kernel.org Subject: [PATCH V8 17/44] mm/pkeys: Introduce pks_mk_noaccess() Date: Thu, 27 Jan 2022 09:54:38 -0800 Message-Id: <20220127175505.851391-18-ira.weiny@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220127175505.851391-1-ira.weiny@intel.com> References: <20220127175505.851391-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny After a valid access for a PKS protected page Users will need to change the protections back to No Access for their Pkey Define pks_mk_noaccess() to update the specified Pkey Add documentation. Signed-off-by: Ira Weiny --- Changes for V8 Make the call inline Split this patch out from 'Add PKS kernel API' Include documentation in this patch --- Documentation/core-api/protection-keys.rst | 2 +- include/linux/pkeys.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/core-api/protection-keys.rst b/Documentation/core-api/protection-keys.rst index e4a27b93f3d4..115afc67153f 100644 --- a/Documentation/core-api/protection-keys.rst +++ b/Documentation/core-api/protection-keys.rst @@ -145,7 +145,7 @@ Changing permissions of individual keys --------------------------------------- .. kernel-doc:: include/linux/pks-keys.h - :identifiers: pks_mk_readwrite + :identifiers: pks_mk_readwrite pks_mk_noaccess MSR details ----------- diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h index 73b554b99123..5f4965f5449b 100644 --- a/include/linux/pkeys.h +++ b/include/linux/pkeys.h @@ -57,6 +57,18 @@ static inline bool arch_pkeys_enabled(void) void pks_update_protection(int pkey, u32 protection); +/** + * pks_mk_noaccess() - Disable all access to the domain + * @pkey: the pkey for which the access should change. + * + * Disable all access to the domain specified by pkey. This is not a global + * update and only affects the current running thread. + */ +static inline void pks_mk_noaccess(int pkey) +{ + pks_update_protection(pkey, PKEY_DISABLE_ACCESS); +} + /** * pks_mk_readwrite() - Make the domain Read/Write * @pkey: the pkey for which the access should change. @@ -71,6 +83,7 @@ static inline void pks_mk_readwrite(int pkey) #else /* !CONFIG_ARCH_ENABLE_SUPERVISOR_PKEYS */ +static inline void pks_mk_noaccess(int pkey) {} static inline void pks_mk_readwrite(int pkey) {} #endif /* CONFIG_ARCH_ENABLE_SUPERVISOR_PKEYS */ -- 2.31.1