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(-) -- 2.17.0
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. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- drivers/base/firmware_loader/fallback.c | 5 ----- include/asm-generic/pgtable.h | 14 ++++++++++++++ 2 files changed, 14 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..4e310e543fc8 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -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 -- 2.17.0
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. Suggested-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- include/asm-generic/pgtable.h | 4 ++++ mm/nommu.c | 4 ---- mm/vmalloc.c | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 4e310e543fc8..81371468ed5a 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -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 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
On Thu, May 10, 2018 at 11:55:05AM -0700, Luis R. Rodriguez wrote: > 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 > > 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(-) > > -- > 2.17.0 > > -- Do not panic
On Wed, May 16, 2018 at 06:44:03PM +0200, Luis R. Rodriguez wrote:
> On Thu, May 10, 2018 at 11:55:05AM -0700, Luis R. Rodriguez wrote:
> > 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
On Wed, May 23, 2018 at 11:35:51PM +0200, Luis R. Rodriguez wrote:
> On Wed, May 16, 2018 at 06:44:03PM +0200, Luis R. Rodriguez wrote:
> > On Thu, May 10, 2018 at 11:55:05AM -0700, Luis R. Rodriguez wrote:
> > > 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*.
*Re-re-poke*
Luis
On Wed, May 30, 2018 at 09:55:00PM +0200, Luis R. Rodriguez wrote:
> On Wed, May 23, 2018 at 11:35:51PM +0200, Luis R. Rodriguez wrote:
> > On Wed, May 16, 2018 at 06:44:03PM +0200, Luis R. Rodriguez wrote:
> > > On Thu, May 10, 2018 at 11:55:05AM -0700, Luis R. Rodriguez wrote:
> > > > 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*.
>
> *Re-re-poke*
Hah, they are not for me to take, sorry, that's up to the mm maintainer.
good luck!
greg k-h
On Wed, May 30, 2018 at 10:06:08PM +0200, Greg KH wrote:
> On Wed, May 30, 2018 at 09:55:00PM +0200, Luis R. Rodriguez wrote:
> > On Wed, May 23, 2018 at 11:35:51PM +0200, Luis R. Rodriguez wrote:
> > > On Wed, May 16, 2018 at 06:44:03PM +0200, Luis R. Rodriguez wrote:
> > > > On Thu, May 10, 2018 at 11:55:05AM -0700, Luis R. Rodriguez wrote:
> > > > > 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*.
> >
> > *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