Skip to contentSkip to conversation

mm: PAGE_KERNEL_* fallbacks

PATCH Superseded Luis R. Rodriguez 3 participants 9 messages May 10, 2018 – May 14, 2018

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luis R. Rodriguez

author maintainer
#0 lore raw

v2 cover mm: PAGE_KERNEL_* fallbacks

While dusting out the firmware loader closet I spotted a PAGE_KERNEL_* fallback hack. This hurts my eyes, and it should also be blinding others. Turns out we have other PAGE_KERNEL_* fallback hacks in other places.

This moves them to asm-generic, and keeps track of architectures which need some love or review. At least 0-day was happy with the changes.

Matthew Wilcox did put together a PAGE_KERNEL_RO patch for ia64, that needs review and testing, and if it goes well it should be merged.

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           | 36 +++++++++++++++++++++++++
 mm/nommu.c                              |  4 ---
 mm/vmalloc.c                            |  4 ---
 4 files changed, 36 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH v2 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 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 and document which architectures needs further evaluation for which PAGE_KERNEL_* flag.

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.

Architectures which don't define this yet:

o alpha
o ia64
o m68k
o mips
o sparc64
o sparc

---
 drivers/base/firmware_loader/fallback.c |  5 -----
 include/asm-generic/pgtable.h           | 24 ++++++++++++++++++++++++
 2 files changed, 24 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 +24 -0
index f59639afaa39..890fc54f4713 100644
@@ -1083,6 +1083,30 @@ 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.
+ */
+
+/*
+ * Current architectures known to not define PAGE_KERNEL_RO:
+ *
+ *  o alpha
+ *  o ia64
+ *  o m68k
+ *  o mips
+ *  o sparc64
+ *  o sparc
+ */
+#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 v2 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.

Architectures which do not define PAGE_KERNEL_EXEC yet:

o alpha
o mips
o openrisc
o sparc64

---
 include/asm-generic/pgtable.h | 12 ++++++++++++
 mm/nommu.c                    |  4 ----
 mm/vmalloc.c                  |  4 ----
 3 files changed, 12 insertions(+), 8 deletions(-)
include/asm-generic/pgtable.h +12 -0
index 890fc54f4713..39e9bd66c786 100644
@@ -1107,6 +1107,18 @@ static inline void init_espfix_bsp(void) { }
 # define PAGE_KERNEL_RO PAGE_KERNEL
 #endif
 
+/*
+ * Current architectures known to not define PAGE_KERNEL_EXEC:
+ *
+ *  o alpha
+ *  o mips
+ *  o openrisc
+ *  o sparc64
+ */
+#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
#3 lore raw

Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

Hi Luis,

Quoted 10 lines · 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.

Architectures which do not define PAGE_KERNEL_EXEC yet:

o alpha
o mips
o openrisc
o sparc64

The above list seems to be far from complete?

Quoted 2 lines

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#4 lore raw

Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

Quoted 7 lines · Geert Uytterhoeven

Hi Luis,

Quoted 4 lines · 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.

Quoted 8 lines
Quoted 6 lines

Architectures which do not define PAGE_KERNEL_EXEC yet:

o alpha
o mips
o openrisc
o sparc64

The above list seems to be far from complete?

I'll look again. If you know of others lemme know.

Luis

author maintainer
#5 lore raw

Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures

Quoted 10 lines · Luis R. Rodriguez
Quoted 9 lines · Geert Uytterhoeven

Hi Luis,

Quoted 6 lines · 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.

Architectures which do not define PAGE_KERNEL_EXEC yet:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

o alpha
o mips
o openrisc
o sparc64

The above list seems to be far from complete?

I'll look again. If you know of others lemme know.

You know, better just ignore documenting these. I'll respin without that.

Luis

maintainer
#6 lore raw
In reply to Luis R. Rodriguez
Quoted 15 lines · Luis R. Rodriguez

While dusting out the firmware loader closet I spotted a PAGE_KERNEL_* fallback hack. This hurts my eyes, and it should also be blinding others. Turns out we have other PAGE_KERNEL_* fallback hacks in other places.

This moves them to asm-generic, and keeps track of architectures which need some love or review. At least 0-day was happy with the changes.

Matthew Wilcox did put together a PAGE_KERNEL_RO patch for ia64, that needs review and testing, and if it goes well it should be merged.

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

Quoted 5 lines
 drivers/base/firmware_loader/fallback.c |  5 ----
 include/asm-generic/pgtable.h           | 36 +++++++++++++++++++++++++
 mm/nommu.c                              |  4 ---
 mm/vmalloc.c                            |  4 ---
 4 files changed, 36 insertions(+), 13 deletions(-)

No list of changes that happened from v1? :(

author maintainer
#7 lore raw
Quoted 16 lines · Greg KH
Quoted 15 lines · Luis R. Rodriguez

While dusting out the firmware loader closet I spotted a PAGE_KERNEL_* fallback hack. This hurts my eyes, and it should also be blinding others. Turns out we have other PAGE_KERNEL_* fallback hacks in other places.

This moves them to asm-generic, and keeps track of architectures which need some love or review. At least 0-day was happy with the changes.

Matthew Wilcox did put together a PAGE_KERNEL_RO patch for ia64, that needs review and testing, and if it goes well it should be merged.

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

Quoted 7 lines
Quoted 5 lines
 drivers/base/firmware_loader/fallback.c |  5 ----
 include/asm-generic/pgtable.h           | 36 +++++++++++++++++++++++++
 mm/nommu.c                              |  4 ---
 mm/vmalloc.c                            |  4 ---
 4 files changed, 36 insertions(+), 13 deletions(-)

No list of changes that happened from v1? :(

Didn't know you'd want it for such simple patch set, but I'll provide one for v3 and also list the changes in v2.

Luis

maintainer
#8 lore raw
Quoted 23 lines · Luis R. Rodriguez
Quoted 22 lines · Greg KH
Quoted 20 lines · Luis R. Rodriguez

While dusting out the firmware loader closet I spotted a PAGE_KERNEL_* fallback hack. This hurts my eyes, and it should also be blinding others. Turns out we have other PAGE_KERNEL_* fallback hacks in other places.

This moves them to asm-generic, and keeps track of architectures which need some love or review. At least 0-day was happy with the changes.

Matthew Wilcox did put together a PAGE_KERNEL_RO patch for ia64, that needs review and testing, and if it goes well it should be merged.

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           | 36 +++++++++++++++++++++++++
 mm/nommu.c                              |  4 ---
 mm/vmalloc.c                            |  4 ---
 4 files changed, 36 insertions(+), 13 deletions(-)
Quoted 4 lines
Quoted 1 line

No list of changes that happened from v1? :(

Didn't know you'd want it for such simple patch set, but I'll provide one for v3 and also list the changes in v2.

Nothing is "trivial" really, and given the huge rate of patch submissions, how is anyone supposed to remember what you did in the last one?

thanks,

greg k-h