linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks
@ 2018-05-10  1:44 Luis R. Rodriguez
  2018-05-10  1:44 ` [PATCH v2 1/2] mm: provide a fallback for PAGE_KERNEL_RO for architectures Luis R. Rodriguez
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10  1:44 UTC (permalink / raw)
  To: arnd
  Cc: gregkh, willy, geert, linux-m68k, linux-arch, linux-mm,
	linux-kernel, 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(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/2] mm: provide a fallback for PAGE_KERNEL_RO for architectures
  2018-05-10  1:44 [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Luis R. Rodriguez
@ 2018-05-10  1:44 ` Luis R. Rodriguez
  2018-05-10  1:44 ` [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC " Luis R. Rodriguez
  2018-05-10  6:07 ` [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Greg KH
  2 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10  1:44 UTC (permalink / raw)
  To: arnd
  Cc: gregkh, willy, geert, linux-m68k, linux-arch, linux-mm,
	linux-kernel, Luis R. Rodriguez

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

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 drivers/base/firmware_loader/fallback.c |  5 -----
 include/asm-generic/pgtable.h           | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index 358354148dec..36f016b753e0 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -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)
 {
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index f59639afaa39..890fc54f4713 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -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
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures
  2018-05-10  1:44 [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Luis R. Rodriguez
  2018-05-10  1:44 ` [PATCH v2 1/2] mm: provide a fallback for PAGE_KERNEL_RO for architectures Luis R. Rodriguez
@ 2018-05-10  1:44 ` Luis R. Rodriguez
  2018-05-10  7:45   ` Geert Uytterhoeven
  2018-05-10  6:07 ` [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Greg KH
  2 siblings, 1 reply; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10  1:44 UTC (permalink / raw)
  To: arnd
  Cc: gregkh, willy, geert, linux-m68k, linux-arch, linux-mm,
	linux-kernel, 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

Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 include/asm-generic/pgtable.h | 12 ++++++++++++
 mm/nommu.c                    |  4 ----
 mm/vmalloc.c                  |  4 ----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 890fc54f4713..39e9bd66c786 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -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
diff --git a/mm/nommu.c b/mm/nommu.c
index 13723736d38f..08ad4dcd281d 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -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
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ebff729cc956..89543d13e32a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -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
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks
  2018-05-10  1:44 [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Luis R. Rodriguez
  2018-05-10  1:44 ` [PATCH v2 1/2] mm: provide a fallback for PAGE_KERNEL_RO for architectures Luis R. Rodriguez
  2018-05-10  1:44 ` [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC " Luis R. Rodriguez
@ 2018-05-10  6:07 ` Greg KH
  2018-05-10 17:15   ` Luis R. Rodriguez
  2 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2018-05-10  6:07 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: arnd, willy, geert, linux-m68k, linux-arch, linux-mm, linux-kernel

On Wed, May 09, 2018 at 06:44:45PM -0700, Luis R. Rodriguez wrote:
> 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(-)

No list of changes that happened from v1?  :(

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures
  2018-05-10  1:44 ` [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC " Luis R. Rodriguez
@ 2018-05-10  7:45   ` Geert Uytterhoeven
  2018-05-10 15:33     ` Luis R. Rodriguez
  0 siblings, 1 reply; 9+ messages in thread
From: Geert Uytterhoeven @ 2018-05-10  7:45 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Arnd Bergmann, Greg KH, Matthew Wilcox, linux-m68k, Linux-Arch,
	Linux MM, Linux Kernel Mailing List

Hi Luis,

On Thu, May 10, 2018 at 3:44 AM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:
> 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?

> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures
  2018-05-10  7:45   ` Geert Uytterhoeven
@ 2018-05-10 15:33     ` Luis R. Rodriguez
  2018-05-10 17:14       ` Luis R. Rodriguez
  0 siblings, 1 reply; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10 15:33 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Luis R. Rodriguez, Arnd Bergmann, Greg KH, Matthew Wilcox,
	linux-m68k, Linux-Arch, Linux MM, Linux Kernel Mailing List

On Thu, May 10, 2018 at 09:45:56AM +0200, Geert Uytterhoeven wrote:
> Hi Luis,
> 
> On Thu, May 10, 2018 at 3:44 AM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:
> > 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?

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

  Luis

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC for architectures
  2018-05-10 15:33     ` Luis R. Rodriguez
@ 2018-05-10 17:14       ` Luis R. Rodriguez
  0 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10 17:14 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Geert Uytterhoeven, Arnd Bergmann, Greg KH, Matthew Wilcox,
	linux-m68k, Linux-Arch, Linux MM, Linux Kernel Mailing List

On Thu, May 10, 2018 at 03:33:55PM +0000, Luis R. Rodriguez wrote:
> On Thu, May 10, 2018 at 09:45:56AM +0200, Geert Uytterhoeven wrote:
> > Hi Luis,
> > 
> > On Thu, May 10, 2018 at 3:44 AM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:
> > > 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?
> 
> I'll look again. If you know of others lemme know.

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

  Luis

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks
  2018-05-10  6:07 ` [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Greg KH
@ 2018-05-10 17:15   ` Luis R. Rodriguez
  2018-05-14 14:23     ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Luis R. Rodriguez @ 2018-05-10 17:15 UTC (permalink / raw)
  To: Greg KH
  Cc: Luis R. Rodriguez, arnd, willy, geert, linux-m68k, linux-arch,
	linux-mm, linux-kernel

On Thu, May 10, 2018 at 08:07:33AM +0200, Greg KH wrote:
> On Wed, May 09, 2018 at 06:44:45PM -0700, Luis R. Rodriguez wrote:
> > 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(-)
> 
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks
  2018-05-10 17:15   ` Luis R. Rodriguez
@ 2018-05-14 14:23     ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2018-05-14 14:23 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: arnd, willy, geert, linux-m68k, linux-arch, linux-mm, linux-kernel

On Thu, May 10, 2018 at 05:15:20PM +0000, Luis R. Rodriguez wrote:
> On Thu, May 10, 2018 at 08:07:33AM +0200, Greg KH wrote:
> > On Wed, May 09, 2018 at 06:44:45PM -0700, Luis R. Rodriguez wrote:
> > > 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(-)
> > 
> > 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-14 14:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10  1:44 [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Luis R. Rodriguez
2018-05-10  1:44 ` [PATCH v2 1/2] mm: provide a fallback for PAGE_KERNEL_RO for architectures Luis R. Rodriguez
2018-05-10  1:44 ` [PATCH v2 2/2] mm: provide a fallback for PAGE_KERNEL_EXEC " Luis R. Rodriguez
2018-05-10  7:45   ` Geert Uytterhoeven
2018-05-10 15:33     ` Luis R. Rodriguez
2018-05-10 17:14       ` Luis R. Rodriguez
2018-05-10  6:07 ` [PATCH v2 0/2] mm: PAGE_KERNEL_* fallbacks Greg KH
2018-05-10 17:15   ` Luis R. Rodriguez
2018-05-14 14:23     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).