[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220310172019.850939-36-ira.weiny@intel.com>
Date: Thu, 10 Mar 2022 09:20:09 -0800
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 V9 35/45] memremap_pages: Introduce pgmap_protection_available()
From: Ira Weiny <ira.weiny@...el.com>
PMEM will flag additional dev_pagemap protection through (struct
dev_pagemap)->flags. However, it is more efficient to know if that
protection is available prior to requesting it and failing the mapping.
Define pgmap_protection_available() to check if protection is available
prior to being requested. The name of pgmap_protection_available() was
specifically chosen to isolate the implementation of the protection from
higher level users.
Signed-off-by: Ira Weiny <ira.weiny@...el.com>
---
Changes for V9
Clean up commit message
From Dan Williams
make call stack static inline throughout this call and
pks_available() such that callers calls
cpu_feature_enabled() directly
Changes for V8
Split this out to it's own patch.
s/pgmap_protection_enabled/pgmap_protection_available
---
include/linux/mm.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5744a3fc4716..9ab799403004 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -31,6 +31,7 @@
#include <linux/sizes.h>
#include <linux/sched.h>
#include <linux/pgtable.h>
+#include <linux/pks.h>
#include <linux/kasan.h>
struct mempolicy;
@@ -1143,6 +1144,22 @@ static inline bool is_pci_p2pdma_page(const struct page *page)
page->pgmap->type == MEMORY_DEVICE_PCI_P2PDMA;
}
+#ifdef CONFIG_DEVMAP_ACCESS_PROTECTION
+
+static inline bool pgmap_protection_available(void)
+{
+ return pks_available();
+}
+
+#else
+
+static inline bool pgmap_protection_available(void)
+{
+ return false;
+}
+
+#endif /* CONFIG_DEVMAP_ACCESS_PROTECTION */
+
/* 127: arbitrary random number, small enough to assemble well */
#define folio_ref_zero_or_close_to_overflow(folio) \
((unsigned int) folio_ref_count(folio) + 127u <= 127u)
--
2.35.1
Powered by blists - more mailing lists