Skip to content

Commit 63bb76d

Browse files
penbergpalmer-dabbelt
authored andcommitted
mm: pgtable: Make generic pgprot_* macros available for no-MMU
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 <[email protected]> Reviewed-by: Mike Rapoport <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Pekka Enberg <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 3e7b669 commit 63bb76d

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

include/linux/pgtable.h

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -647,40 +647,6 @@ static inline int arch_unmap_one(struct mm_struct *mm,
647647
#define flush_tlb_fix_spurious_fault(vma, address) flush_tlb_page(vma, address)
648648
#endif
649649

650-
#ifndef pgprot_nx
651-
#define pgprot_nx(prot) (prot)
652-
#endif
653-
654-
#ifndef pgprot_noncached
655-
#define pgprot_noncached(prot) (prot)
656-
#endif
657-
658-
#ifndef pgprot_writecombine
659-
#define pgprot_writecombine pgprot_noncached
660-
#endif
661-
662-
#ifndef pgprot_writethrough
663-
#define pgprot_writethrough pgprot_noncached
664-
#endif
665-
666-
#ifndef pgprot_device
667-
#define pgprot_device pgprot_noncached
668-
#endif
669-
670-
#ifndef pgprot_modify
671-
#define pgprot_modify pgprot_modify
672-
static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
673-
{
674-
if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
675-
newprot = pgprot_noncached(newprot);
676-
if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
677-
newprot = pgprot_writecombine(newprot);
678-
if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
679-
newprot = pgprot_device(newprot);
680-
return newprot;
681-
}
682-
#endif
683-
684650
/*
685651
* When walking page tables, get the address of the next boundary,
686652
* 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,
840806
* No-op macros that just return the current protection value. Defined here
841807
* because these macros can be used used even if CONFIG_MMU is not defined.
842808
*/
809+
810+
#ifndef pgprot_nx
811+
#define pgprot_nx(prot) (prot)
812+
#endif
813+
814+
#ifndef pgprot_noncached
815+
#define pgprot_noncached(prot) (prot)
816+
#endif
817+
818+
#ifndef pgprot_writecombine
819+
#define pgprot_writecombine pgprot_noncached
820+
#endif
821+
822+
#ifndef pgprot_writethrough
823+
#define pgprot_writethrough pgprot_noncached
824+
#endif
825+
826+
#ifndef pgprot_device
827+
#define pgprot_device pgprot_noncached
828+
#endif
829+
830+
#ifdef CONFIG_MMU
831+
#ifndef pgprot_modify
832+
#define pgprot_modify pgprot_modify
833+
static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
834+
{
835+
if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
836+
newprot = pgprot_noncached(newprot);
837+
if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
838+
newprot = pgprot_writecombine(newprot);
839+
if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
840+
newprot = pgprot_device(newprot);
841+
return newprot;
842+
}
843+
#endif
844+
#endif /* CONFIG_MMU */
845+
843846
#ifndef pgprot_encrypted
844847
#define pgprot_encrypted(prot) (prot)
845848
#endif

0 commit comments

Comments
 (0)