[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220419170649.1022246-31-ira.weiny@intel.com>
Date: Tue, 19 Apr 2022 10:06:35 -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 30/44] memremap_pages: Set PKS pkey in PTEs if requested
From: Ira Weiny <ira.weiny@...el.com>
When a devmap caller requests protections, the dev_pagemap PTE's need to
have a PKEY set.
When PGMAP_PROTECTIONS is requested add the pkey to the page
protections.
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
Changes for V9
From Dave Hansen
use pkey
---
mm/memremap.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/memremap.c b/mm/memremap.c
index 4dfb3025cee3..215ab9c51917 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -81,6 +81,14 @@ static void devmap_protection_enable(void)
static_branch_inc(&dev_pgmap_protection_static_key);
}
+static pgprot_t devmap_protection_adjust_pgprot(pgprot_t prot)
+{
+ pgprotval_t val;
+
+ val = pgprot_val(prot);
+ return __pgprot(val | _PAGE_PKEY(PKS_KEY_PGMAP_PROTECTION));
+}
+
static void devmap_protection_disable(void)
{
static_branch_dec(&dev_pgmap_protection_static_key);
@@ -91,6 +99,10 @@ static void devmap_protection_disable(void)
static void devmap_protection_enable(void) { }
static void devmap_protection_disable(void) { }
+static pgprot_t devmap_protection_adjust_pgprot(pgprot_t prot)
+{
+ return prot;
+}
#endif /* CONFIG_DEVMAP_ACCESS_PROTECTION */
static void pgmap_array_delete(struct range *range)
@@ -333,6 +345,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
if (!pgmap_protection_available())
return ERR_PTR(-EINVAL);
devmap_protection_enable();
+ params.pgprot = devmap_protection_adjust_pgprot(params.pgprot);
}
switch (pgmap->type) {
--
2.35.1
Powered by blists - more mailing lists