Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU
@ 2020-07-15  5:33 Pekka Enberg
  2020-07-15  5:33 ` [PATCH v2 2/2] riscv: Use generic pgprot_* macros from <linux/pgtable.h> Pekka Enberg
  2020-07-15 17:39 ` [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU David Rientjes
  0 siblings, 2 replies; 5+ messages in thread
From: Pekka Enberg @ 2020-07-15  5:33 UTC (permalink / raw)
  To: linux-riscv, linux-mm
  Cc: Pekka Enberg, Tom Lendacky, Palmer Dabbelt, Mike Rapoport

From: Pekka Enberg <penberg@kernel.org>

The <linux/pgtable.h> header defines some generic pgprot_*
implementations, but they are only available when CONFIG_MMU is enabled.
The RISC-V architecture, for example, therefore defines some of these
pgprot_* macros for !NOMMU.

Let's make the pgprot_* generic available even for !NOMMU so we can
remove the RISC-V specific definitions.

Compile-tested with x86 defconfig, and riscv defconfig and !MMU defconfig.

Suggested-by: Palmer Dabbelt <palmerdabbelt@google.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
v1 -> v2: Wrap pgprot_modify() -- which is specific to mmap -- with
	  CONFIG_MMU to fix a build issue on ARM reported by kernel test
          robot <lkp@intel.com>.

 include/linux/pgtable.h | 71 +++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 56c1e8eb7bb0..53e97da1e8e2 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -647,40 +647,6 @@ static inline int arch_unmap_one(struct mm_struct *mm,
 #define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
 #endif
 
-#ifndef pgprot_nx
-#define pgprot_nx(prot)	(prot)
-#endif
-
-#ifndef pgprot_noncached
-#define pgprot_noncached(prot)	(prot)
-#endif
-
-#ifndef pgprot_writecombine
-#define pgprot_writecombine pgprot_noncached
-#endif
-
-#ifndef pgprot_writethrough
-#define pgprot_writethrough pgprot_noncached
-#endif
-
-#ifndef pgprot_device
-#define pgprot_device pgprot_noncached
-#endif
-
-#ifndef pgprot_modify
-#define pgprot_modify pgprot_modify
-static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
-{
-	if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
-		newprot = pgprot_noncached(newprot);
-	if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
-		newprot = pgprot_writecombine(newprot);
-	if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
-		newprot = pgprot_device(newprot);
-	return newprot;
-}
-#endif
-
 /*
  * When walking page tables, get the address of the next boundary,
  * or the end address of the range if that comes earlier.  Although no
@@ -840,6 +806,43 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma,
  * No-op macros that just return the current protection value. Defined here
  * because these macros can be used used even if CONFIG_MMU is not defined.
  */
+
+#ifndef pgprot_nx
+#define pgprot_nx(prot)	(prot)
+#endif
+
+#ifndef pgprot_noncached
+#define pgprot_noncached(prot)	(prot)
+#endif
+
+#ifndef pgprot_writecombine
+#define pgprot_writecombine pgprot_noncached
+#endif
+
+#ifndef pgprot_writethrough
+#define pgprot_writethrough pgprot_noncached
+#endif
+
+#ifndef pgprot_device
+#define pgprot_device pgprot_noncached
+#endif
+
+#ifdef CONFIG_MMU
+#ifndef pgprot_modify
+#define pgprot_modify pgprot_modify
+static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
+{
+	if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
+		newprot = pgprot_noncached(newprot);
+	if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
+		newprot = pgprot_writecombine(newprot);
+	if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
+		newprot = pgprot_device(newprot);
+	return newprot;
+}
+#endif
+#endif /* CONFIG_MMU */
+
 #ifndef pgprot_encrypted
 #define pgprot_encrypted(prot)	(prot)
 #endif
-- 
2.26.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v2 2/2] riscv: Use generic pgprot_* macros from <linux/pgtable.h>
  2020-07-15  5:33 [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU Pekka Enberg
@ 2020-07-15  5:33 ` Pekka Enberg
  2020-07-15 17:39 ` [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU David Rientjes
  1 sibling, 0 replies; 5+ messages in thread
From: Pekka Enberg @ 2020-07-15  5:33 UTC (permalink / raw)
  To: linux-riscv, linux-mm; +Cc: Pekka Enberg, Palmer Dabbelt

From: Pekka Enberg <penberg@kernel.org>

The <linux/pgtable.h> header now defines generic pgprot_ macros also for
the no-MMU configuration, so let's use them.

Cc: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
 arch/riscv/include/asm/mmio.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/riscv/include/asm/mmio.h b/arch/riscv/include/asm/mmio.h
index 56053c9838b2..aff6c33ab0c0 100644
--- a/arch/riscv/include/asm/mmio.h
+++ b/arch/riscv/include/asm/mmio.h
@@ -14,12 +14,6 @@
 #include <linux/types.h>
 #include <asm/mmiowb.h>
 
-#ifndef CONFIG_MMU
-#define pgprot_noncached(x)	(x)
-#define pgprot_writecombine(x)	(x)
-#define pgprot_device(x)	(x)
-#endif /* CONFIG_MMU */
-
 /* Generic IO read/write.  These perform native-endian accesses. */
 #define __raw_writeb __raw_writeb
 static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
-- 
2.26.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU
  2020-07-15  5:33 [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU Pekka Enberg
  2020-07-15  5:33 ` [PATCH v2 2/2] riscv: Use generic pgprot_* macros from <linux/pgtable.h> Pekka Enberg
@ 2020-07-15 17:39 ` David Rientjes
  2020-07-17  6:14   ` Pekka Enberg
  1 sibling, 1 reply; 5+ messages in thread
From: David Rientjes @ 2020-07-15 17:39 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Tom Lendacky, Palmer Dabbelt, Mike Rapoport, Pekka Enberg,
	linux-mm, linux-riscv

On Wed, 15 Jul 2020, Pekka Enberg wrote:

> From: Pekka Enberg <penberg@kernel.org>
> 
> The <linux/pgtable.h> header defines some generic pgprot_*
> implementations, but they are only available when CONFIG_MMU is enabled.
> The RISC-V architecture, for example, therefore defines some of these
> pgprot_* macros for !NOMMU.
> 
> Let's make the pgprot_* generic available even for !NOMMU so we can
> remove the RISC-V specific definitions.
> 
> Compile-tested with x86 defconfig, and riscv defconfig and !MMU defconfig.
> 
> Suggested-by: Palmer Dabbelt <palmerdabbelt@google.com>
> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Pekka Enberg <penberg@kernel.org>

Acked-by: David Rientjes <rientjes@google.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU
  2020-07-15 17:39 ` [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU David Rientjes
@ 2020-07-17  6:14   ` Pekka Enberg
  2020-07-22  3:29     ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2020-07-17  6:14 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: linux-mm, linux-riscv, Palmer Dabbelt, Tom Lendacky, Mike Rapoport

On Wed, 15 Jul 2020, Pekka Enberg wrote:
> > From: Pekka Enberg <penberg@kernel.org>
> >
> > The <linux/pgtable.h> header defines some generic pgprot_*
> > implementations, but they are only available when CONFIG_MMU is enabled.
> > The RISC-V architecture, for example, therefore defines some of these
> > pgprot_* macros for !NOMMU.
> >
> > Let's make the pgprot_* generic available even for !NOMMU so we can
> > remove the RISC-V specific definitions.
> >
> > Compile-tested with x86 defconfig, and riscv defconfig and !MMU defconfig.
> >
> > Suggested-by: Palmer Dabbelt <palmerdabbelt@google.com>
> > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> > Cc: Tom Lendacky <thomas.lendacky@amd.com>
> > Signed-off-by: Pekka Enberg <penberg@kernel.org>

On Wed, Jul 15, 2020 at 8:39 PM David Rientjes <rientjes@google.com> wrote:
> Acked-by: David Rientjes <rientjes@google.com>

Palmer, will you pick up these patches in the riscv tree, or should I
ask Andrew to queue them in -mm?

- Pekka

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU
  2020-07-17  6:14   ` Pekka Enberg
@ 2020-07-22  3:29     ` Palmer Dabbelt
  0 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2020-07-22  3:29 UTC (permalink / raw)
  To: penberg; +Cc: thomas.lendacky, rppt, linux-mm, rientjes, akpm, linux-riscv

On Thu, 16 Jul 2020 23:14:10 PDT (-0700), penberg@gmail.com wrote:
> On Wed, 15 Jul 2020, Pekka Enberg wrote:
>> > From: Pekka Enberg <penberg@kernel.org>
>> >
>> > The <linux/pgtable.h> header defines some generic pgprot_*
>> > implementations, but they are only available when CONFIG_MMU is enabled.
>> > The RISC-V architecture, for example, therefore defines some of these
>> > pgprot_* macros for !NOMMU.
>> >
>> > Let's make the pgprot_* generic available even for !NOMMU so we can
>> > remove the RISC-V specific definitions.
>> >
>> > Compile-tested with x86 defconfig, and riscv defconfig and !MMU defconfig.
>> >
>> > Suggested-by: Palmer Dabbelt <palmerdabbelt@google.com>
>> > Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
>> > Cc: Tom Lendacky <thomas.lendacky@amd.com>
>> > Signed-off-by: Pekka Enberg <penberg@kernel.org>
>
> On Wed, Jul 15, 2020 at 8:39 PM David Rientjes <rientjes@google.com> wrote:
>> Acked-by: David Rientjes <rientjes@google.com>
>
> Palmer, will you pick up these patches in the riscv tree, or should I
> ask Andrew to queue them in -mm?

I just put them on for-next.  Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15  5:33 [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU Pekka Enberg
2020-07-15  5:33 ` [PATCH v2 2/2] riscv: Use generic pgprot_* macros from <linux/pgtable.h> Pekka Enberg
2020-07-15 17:39 ` [PATCH v2 1/2] mm: pgtable: Make generic pgprot_* macros available for no-MMU David Rientjes
2020-07-17  6:14   ` Pekka Enberg
2020-07-22  3:29     ` Palmer Dabbelt

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git