[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220419170649.1022246-16-ira.weiny@intel.com>
Date: Tue, 19 Apr 2022 10:06:20 -0700
From: ira.weiny@...el.com
To: Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Dan Williams <dan.j.williams@...el.com>
Cc: Ira Weiny <ira.weiny@...el.com>, Fenghua Yu <fenghua.yu@...el.com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH V10 15/44] mm/pkeys: Introduce pks_set_noaccess()
From: Ira Weiny <ira.weiny@...el.com>
After a valid access consumers will want to change PKS protections back
to No Access for their pkey.
Define pks_set_noaccess() to update the specified pkey.
Add documentation.
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
Changes for V9
Move to pks.h
Change pkey type to u8
From 0day
Fix documentation link
From Dave Hansen
use pkey
s/pks_mk*/pks_set*/
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/pks.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 3af92e1cbffd..78904d98519b 100644
--- a/Documentation/core-api/protection-keys.rst
+++ b/Documentation/core-api/protection-keys.rst
@@ -147,7 +147,7 @@ Changing permissions of individual keys
---------------------------------------
.. kernel-doc:: include/linux/pks.h
- :identifiers: pks_set_readwrite
+ :identifiers: pks_set_readwrite pks_set_noaccess
MSR details
~~~~~~~~~~~
diff --git a/include/linux/pks.h b/include/linux/pks.h
index 8b705a937b19..9f18f8b4cbb1 100644
--- a/include/linux/pks.h
+++ b/include/linux/pks.h
@@ -10,6 +10,18 @@
void pks_update_protection(u8 pkey, u8 protection);
+/**
+ * pks_set_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_set_noaccess(u8 pkey)
+{
+ pks_update_protection(pkey, PKEY_DISABLE_ACCESS);
+}
+
/**
* pks_set_readwrite() - Make the domain Read/Write
* @pkey: the pkey for which the access should change.
@@ -24,6 +36,7 @@ static inline void pks_set_readwrite(u8 pkey)
#else /* !CONFIG_ARCH_ENABLE_SUPERVISOR_PKEYS */
+static inline void pks_set_noaccess(u8 pkey) {}
static inline void pks_set_readwrite(u8 pkey) {}
#endif /* CONFIG_ARCH_ENABLE_SUPERVISOR_PKEYS */
--
2.35.1
Powered by blists - more mailing lists