Skip to contentSkip to conversation

mm: PAGE_KERNEL_* fallbacks

PATCH In review Luis R. Rodriguez 2 participants 8 messages May 10, 2018 – May 30, 2018

Subsystems (6)
lore
Share & tools
lore

Luis R. Rodriguez

author maintainer
#0 lore raw

v3 cover mm: PAGE_KERNEL_* fallbacks

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

All these patches have been tested by 0-day.

Questions, and specially flames are greatly appreciated.

v3:

Removed documentation effort to keep tabs on which architectures currently don't defint the respective PAGE_* flags. Keeping tabs on this is just not worth it.

Ran a spell checker on all patches :)

v2:

I added a patch for PAGE_KERNEL_EXEC as suggested by Matthew Wilcox.

v1:

I sent out a patch just for dealing witht he fallback mechanism for PAGE_KERNEL_RO.

Luis R. Rodriguez (2):
mm: provide a fallback for PAGE_KERNEL_RO for architectures
mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

 drivers/base/firmware_loader/fallback.c |  5 -----
 include/asm-generic/pgtable.h           | 18 ++++++++++++++++++
 mm/nommu.c                              |  4 ----
 mm/vmalloc.c                            |  4 ----
 4 files changed, 18 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH v3 1/2 mm: provide a fallback for PAGE_KERNEL_RO for architectures

Some architectures do not define certain PAGE_KERNEL_* flags, this is either because:

a) The way to implement some of these flags is *not yet ported*, or
b) The architecture *has no way* to describe them

Over time we have accumulated a few PAGE_KERNEL_* fallback work arounds for architectures in the kernel which do not define them using *relatively safe* equivalents. Move these scattered fallback hacks into asm-generic.

We start off with PAGE_KERNEL_RO using PAGE_KERNEL as a fallback. This has been in place on the firmware loader for years. Move the fallback into the respective asm-generic header.

---
 drivers/base/firmware_loader/fallback.c |  5 -----
 include/asm-generic/pgtable.h           | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/base/firmware_loader/fallback.c +0 -5
index 358354148dec..36f016b753e0 100644
@@ -219,11 +219,6 @@ static ssize_t firmware_loading_show(struct device *dev,
 	return sprintf(buf, "%d\n", loading);
 }
 
-/* Some architectures don't have PAGE_KERNEL_RO */
-#ifndef PAGE_KERNEL_RO
-#define PAGE_KERNEL_RO PAGE_KERNEL
-#endif
-
 /* one pages buffer should be mapped/unmapped only once */
 static int map_fw_priv_pages(struct fw_priv *fw_priv)
 {
include/asm-generic/pgtable.h +14 -0
index f59639afaa39..4e310e543fc8 100644
@@ -1083,6 +1083,20 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
 static inline void init_espfix_bsp(void) { }
 #endif
 
+/*
+ * Architecture PAGE_KERNEL_* fallbacks
+ *
+ * Some architectures don't define certain PAGE_KERNEL_* flags. This is either
+ * because they really don't support them, or the port needs to be updated to
+ * reflect the required functionality. Below are a set of relatively safe
+ * fallbacks, as best effort, which we can count on in lieu of the architectures
+ * not defining them on their own yet.
+ */
+
+#ifndef PAGE_KERNEL_RO
+# define PAGE_KERNEL_RO PAGE_KERNEL
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #ifndef io_remap_pfn_range
Signature · 1 line
2.17.0
author maintainer
#2 lore raw

PATCH v3 2/2 mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

In reply to Luis R. Rodriguez

Some architectures just don't have PAGE_KERNEL_EXEC. The mm/nommu.c and mm/vmalloc.c code have been using PAGE_KERNEL as a fallback for years. Move this fallback to asm-generic.

---
 include/asm-generic/pgtable.h | 4 ++++
 mm/nommu.c                    | 4 ----
 mm/vmalloc.c                  | 4 ----
 3 files changed, 4 insertions(+), 8 deletions(-)
include/asm-generic/pgtable.h +4 -0
index 4e310e543fc8..81371468ed5a 100644
@@ -1097,6 +1097,10 @@ static inline void init_espfix_bsp(void) { }
 # define PAGE_KERNEL_RO PAGE_KERNEL
 #endif
 
+#ifndef PAGE_KERNEL_EXEC
+# define PAGE_KERNEL_EXEC PAGE_KERNEL
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #ifndef io_remap_pfn_range
mm/nommu.c +0 -4
index 13723736d38f..08ad4dcd281d 100644
@@ -364,10 +364,6 @@ void *vzalloc_node(unsigned long size, int node)
 }
 EXPORT_SYMBOL(vzalloc_node);
 
-#ifndef PAGE_KERNEL_EXEC
-# define PAGE_KERNEL_EXEC PAGE_KERNEL
-#endif
-
 /**
  *	vmalloc_exec  -  allocate virtually contiguous, executable memory
  *	@size:		allocation size
mm/vmalloc.c +0 -4
index ebff729cc956..89543d13e32a 100644
@@ -1920,10 +1920,6 @@ void *vzalloc_node(unsigned long size, int node)
 }
 EXPORT_SYMBOL(vzalloc_node);
 
-#ifndef PAGE_KERNEL_EXEC
-# define PAGE_KERNEL_EXEC PAGE_KERNEL
-#endif
-
 /**
  *	vmalloc_exec  -  allocate virtually contiguous, executable memory
  *	@size:		allocation size
Signature · 1 line
2.17.0
author maintainer
#3 lore raw
In reply to Luis R. Rodriguez
Quoted 7 lines · Luis R. Rodriguez

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

All these patches have been tested by 0-day.

Questions, and specially flames are greatly appreciated.

*Poke*

Who's tree should this go through?

Luis

Quoted 32 lines

v3:

Removed documentation effort to keep tabs on which architectures currently don't defint the respective PAGE_* flags. Keeping tabs on this is just not worth it.

Ran a spell checker on all patches :)

v2:

I added a patch for PAGE_KERNEL_EXEC as suggested by Matthew Wilcox.

v1:

I sent out a patch just for dealing witht he fallback mechanism for PAGE_KERNEL_RO.

Luis R. Rodriguez (2):
mm: provide a fallback for PAGE_KERNEL_RO for architectures
mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

 drivers/base/firmware_loader/fallback.c |  5 -----
 include/asm-generic/pgtable.h           | 18 ++++++++++++++++++
 mm/nommu.c                              |  4 ----
 mm/vmalloc.c                            |  4 ----
 4 files changed, 18 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.0
Signature · 1 line
Do not panic
author maintainer
#4 lore raw
Quoted 10 lines · Luis R. Rodriguez
Quoted 7 lines · Luis R. Rodriguez

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

All these patches have been tested by 0-day.

Questions, and specially flames are greatly appreciated.

*Poke*

Greg, since this does touch the firmware loader as well, *poke*.

Luis

author maintainer
#5 lore raw
Quoted 6 lines · Luis R. Rodriguez
Quoted 5 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

All these patches have been tested by 0-day.

Questions, and specially flames are greatly appreciated.

*Poke*

Greg, since this does touch the firmware loader as well, *poke*.

*Re-re-poke*

Luis

maintainer
#6 lore raw
Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Luis R. Rodriguez
Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines · Luis R. Rodriguez

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

All these patches have been tested by 0-day.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Questions, and specially flames are greatly appreciated.

*Poke*

Greg, since this does touch the firmware loader as well, *poke*.

*Re-re-poke*

Hah, they are not for me to take, sorry, that's up to the mm maintainer.

good luck!

greg k-h

author maintainer
#7 lore raw
Quoted 12 lines · Greg KH
Quoted 11 lines · Luis R. Rodriguez
Quoted 10 lines · Luis R. Rodriguez
Quoted 9 lines · Luis R. Rodriguez
Quoted 7 lines · Luis R. Rodriguez

This is the 3rd iteration for moving PAGE_KERNEL_* fallback definitions into asm-generic headers. Greg asked for a Changelog for patch iteration changes, its below.

All these patches have been tested by 0-day.

Questions, and specially flames are greatly appreciated.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

*Poke*

Greg, since this does touch the firmware loader as well, *poke*.

*Re-re-poke*

Hah, they are not for me to take, sorry, that's up to the mm maintainer.

I'm not sure it is up to mm actually, since this is all include/asm-generic/pgtable.h it seems this falls onto Arnd. Its probably *best* mm folks decide though.

Arnd, are you OK if Andrew picks this up if he finds no issues with the patches?

I'll bouncing copies to Andrew now.

Luis