Skip to content

Commit 78e7c5a

Browse files
Anshuman Khandualtorvalds
authored andcommitted
mm/special: create generic fallbacks for pte_special() and pte_mkspecial()
Currently there are many platforms that dont enable ARCH_HAS_PTE_SPECIAL but required to define quite similar fallback stubs for special page table entry helpers such as pte_special() and pte_mkspecial(), as they get build in generic MM without a config check. This creates two generic fallback stub definitions for these helpers, eliminating much code duplication. mips platform has a special case where pte_special() and pte_mkspecial() visibility is wider than what ARCH_HAS_PTE_SPECIAL enablement requires. This restricts those symbol visibility in order to avoid redefinitions which is now exposed through this new generic stubs and subsequent build failure. arm platform set_pte_at() definition needs to be moved into a C file just to prevent a build failure. [[email protected]: use defined(CONFIG_ARCH_HAS_PTE_SPECIAL) in mips per Thomas] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Anshuman Khandual <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Guo Ren <[email protected]> [csky] Acked-by: Geert Uytterhoeven <[email protected]> [m68k] Acked-by: Stafford Horne <[email protected]> [openrisc] Acked-by: Helge Deller <[email protected]> [parisc] Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Russell King <[email protected]> Cc: Brian Cain <[email protected]> Cc: Tony Luck <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Sam Creasey <[email protected]> Cc: Michal Simek <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Paul Burton <[email protected]> Cc: Nick Hu <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Vincent Chen <[email protected]> Cc: Ley Foon Tan <[email protected]> Cc: Jonas Bonn <[email protected]> Cc: Stefan Kristiansson <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Anton Ivanov <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Chris Zankel <[email protected]> Cc: Max Filippov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6cb4d9a commit 78e7c5a

File tree

21 files changed

+58
-95
lines changed

21 files changed

+58
-95
lines changed

arch/alpha/include/asm/pgtable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,13 @@ extern inline void pud_clear(pud_t * pudp) { pud_val(*pudp) = 0; }
268268
extern inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_FOW); }
269269
extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
270270
extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
271-
extern inline int pte_special(pte_t pte) { return 0; }
272271

273272
extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOW; return pte; }
274273
extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(__DIRTY_BITS); return pte; }
275274
extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~(__ACCESS_BITS); return pte; }
276275
extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_FOW; return pte; }
277276
extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= __DIRTY_BITS; return pte; }
278277
extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; return pte; }
279-
extern inline pte_t pte_mkspecial(pte_t pte) { return pte; }
280278

281279
#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
282280

arch/arm/include/asm/pgtable-2level.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
211211
#define pmd_addr_end(addr,end) (end)
212212

213213
#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
214-
#define pte_special(pte) (0)
215-
static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
216214

217215
/*
218216
* We don't have huge page support for short descriptors, for the moment

arch/arm/include/asm/pgtable.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,8 @@ static inline void __sync_icache_dcache(pte_t pteval)
243243
extern void __sync_icache_dcache(pte_t pteval);
244244
#endif
245245

246-
static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
247-
pte_t *ptep, pte_t pteval)
248-
{
249-
unsigned long ext = 0;
250-
251-
if (addr < TASK_SIZE && pte_valid_user(pteval)) {
252-
if (!pte_special(pteval))
253-
__sync_icache_dcache(pteval);
254-
ext |= PTE_EXT_NG;
255-
}
256-
257-
set_pte_ext(ptep, pteval, ext);
258-
}
246+
void set_pte_at(struct mm_struct *mm, unsigned long addr,
247+
pte_t *ptep, pte_t pteval);
259248

260249
static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
261250
{

arch/arm/mm/mmu.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,3 +1646,17 @@ void __init early_mm_init(const struct machine_desc *mdesc)
16461646
build_mem_type_table();
16471647
early_paging_init(mdesc);
16481648
}
1649+
1650+
void set_pte_at(struct mm_struct *mm, unsigned long addr,
1651+
pte_t *ptep, pte_t pteval)
1652+
{
1653+
unsigned long ext = 0;
1654+
1655+
if (addr < TASK_SIZE && pte_valid_user(pteval)) {
1656+
if (!pte_special(pteval))
1657+
__sync_icache_dcache(pteval);
1658+
ext |= PTE_EXT_NG;
1659+
}
1660+
1661+
set_pte_ext(ptep, pteval, ext);
1662+
}

arch/csky/include/asm/pgtable.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
110110
extern void load_pgd(unsigned long pg_dir);
111111
extern pte_t invalid_pte_table[PTRS_PER_PTE];
112112

113-
static inline int pte_special(pte_t pte) { return 0; }
114-
static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
115-
116113
static inline void set_pte(pte_t *p, pte_t pte)
117114
{
118115
*p = pte;

arch/hexagon/include/asm/pgtable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* located in head.S */
158158

159159
/* Seems to be zero even in architectures where the zero page is firewalled? */
160160
#define FIRST_USER_ADDRESS 0UL
161-
#define pte_special(pte) 0
162-
#define pte_mkspecial(pte) (pte)
163161

164162
/* HUGETLB not working currently */
165163
#ifdef CONFIG_HUGETLB_PAGE

arch/ia64/include/asm/pgtable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ extern unsigned long VMALLOC_END;
298298
#define pte_exec(pte) ((pte_val(pte) & _PAGE_AR_RX) != 0)
299299
#define pte_dirty(pte) ((pte_val(pte) & _PAGE_D) != 0)
300300
#define pte_young(pte) ((pte_val(pte) & _PAGE_A) != 0)
301-
#define pte_special(pte) 0
302301

303302
/*
304303
* Note: we convert AR_RWX to AR_RX and AR_RW to AR_R by clearing the 2nd bit in the
@@ -311,7 +310,6 @@ extern unsigned long VMALLOC_END;
311310
#define pte_mkclean(pte) (__pte(pte_val(pte) & ~_PAGE_D))
312311
#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D))
313312
#define pte_mkhuge(pte) (__pte(pte_val(pte)))
314-
#define pte_mkspecial(pte) (pte)
315313

316314
/*
317315
* Because ia64's Icache and Dcache is not coherent (on a cpu), we need to

arch/m68k/include/asm/mcf_pgtable.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ static inline int pte_young(pte_t pte)
235235
return pte_val(pte) & CF_PAGE_ACCESSED;
236236
}
237237

238-
static inline int pte_special(pte_t pte)
239-
{
240-
return 0;
241-
}
242-
243238
static inline pte_t pte_wrprotect(pte_t pte)
244239
{
245240
pte_val(pte) &= ~CF_PAGE_WRITABLE;
@@ -312,11 +307,6 @@ static inline pte_t pte_mkcache(pte_t pte)
312307
return pte;
313308
}
314309

315-
static inline pte_t pte_mkspecial(pte_t pte)
316-
{
317-
return pte;
318-
}
319-
320310
#define swapper_pg_dir kernel_pg_dir
321311
extern pgd_t kernel_pg_dir[PTRS_PER_PGD];
322312

arch/m68k/include/asm/motorola_pgtable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)
174174
static inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_RONLY); }
175175
static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
176176
static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
177-
static inline int pte_special(pte_t pte) { return 0; }
178177

179178
static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_RONLY; return pte; }
180179
static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
@@ -192,7 +191,6 @@ static inline pte_t pte_mkcache(pte_t pte)
192191
pte_val(pte) = (pte_val(pte) & _CACHEMASK040) | m68k_supervisor_cachemode;
193192
return pte;
194193
}
195-
static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
196194

197195
#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
198196

arch/m68k/include/asm/sun3_pgtable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ static inline void pmd_clear (pmd_t *pmdp) { pmd_val (*pmdp) = 0; }
155155
static inline int pte_write(pte_t pte) { return pte_val(pte) & SUN3_PAGE_WRITEABLE; }
156156
static inline int pte_dirty(pte_t pte) { return pte_val(pte) & SUN3_PAGE_MODIFIED; }
157157
static inline int pte_young(pte_t pte) { return pte_val(pte) & SUN3_PAGE_ACCESSED; }
158-
static inline int pte_special(pte_t pte) { return 0; }
159158

160159
static inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_WRITEABLE; return pte; }
161160
static inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~SUN3_PAGE_MODIFIED; return pte; }
@@ -168,7 +167,6 @@ static inline pte_t pte_mknocache(pte_t pte) { pte_val(pte) |= SUN3_PAGE_NOCACHE
168167
//static inline pte_t pte_mkcache(pte_t pte) { pte_val(pte) &= SUN3_PAGE_NOCACHE; return pte; }
169168
// until then, use:
170169
static inline pte_t pte_mkcache(pte_t pte) { return pte; }
171-
static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
172170

173171
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
174172
extern pgd_t kernel_pg_dir[PTRS_PER_PGD];

0 commit comments

Comments
 (0)