Skip to content

Commit ed48e1f

Browse files
rppttorvalds
authored andcommitted
microblaze: use pgtable-nopmd instead of 4level-fixup
microblaze has only two-level page tables and can use pgtable-nopmd and folding of the upper layers. Replace usage of include/asm-generic/4level-fixup.h and explicit definition of __PAGETABLE_PMD_FOLDED in microblaze with include/asm-generic/pgtable-nopmd.h and adjust page table manipulation macros and functions accordingly. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Cc: Anatoly Pugachev <[email protected]> Cc: Anton Ivanov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: Helge Deller <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Mark Salter <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michal Simek <[email protected]> Cc: Peter Rosin <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rolf Eike Beer <[email protected]> Cc: Russell King <[email protected]> Cc: Russell King <[email protected]> Cc: Sam Creasey <[email protected]> Cc: Vincent Chen <[email protected]> Cc: Vineet Gupta <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 60e50f3 commit ed48e1f

File tree

6 files changed

+25
-56
lines changed

6 files changed

+25
-56
lines changed

arch/microblaze/include/asm/page.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ typedef struct { unsigned long pte; } pte_t;
9090
typedef struct { unsigned long pgprot; } pgprot_t;
9191
/* FIXME this can depend on linux kernel version */
9292
# ifdef CONFIG_MMU
93-
typedef struct { unsigned long pmd; } pmd_t;
9493
typedef struct { unsigned long pgd; } pgd_t;
9594
# else /* CONFIG_MMU */
9695
typedef struct { unsigned long ste[64]; } pmd_t;
@@ -103,7 +102,6 @@ typedef struct { p4d_t pge[1]; } pgd_t;
103102
# define pgprot_val(x) ((x).pgprot)
104103

105104
# ifdef CONFIG_MMU
106-
# define pmd_val(x) ((x).pmd)
107105
# define pgd_val(x) ((x).pgd)
108106
# else /* CONFIG_MMU */
109107
# define pmd_val(x) ((x).ste[0])
@@ -112,7 +110,6 @@ typedef struct { p4d_t pge[1]; } pgd_t;
112110
# endif /* CONFIG_MMU */
113111

114112
# define __pte(x) ((pte_t) { (x) })
115-
# define __pmd(x) ((pmd_t) { (x) })
116113
# define __pgd(x) ((pgd_t) { (x) })
117114
# define __pgprot(x) ((pgprot_t) { (x) })
118115

arch/microblaze/include/asm/pgalloc.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ static inline void free_pgd(pgd_t *pgd)
4141

4242
#define pmd_pgtable(pmd) pmd_page(pmd)
4343

44-
/*
45-
* We don't have any real pmd's, and this code never triggers because
46-
* the pgd will always be present..
47-
*/
48-
#define pmd_alloc_one_fast(mm, address) ({ BUG(); ((pmd_t *)1); })
49-
#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
50-
5144
extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
5245

5346
#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte))
@@ -58,15 +51,6 @@ extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm);
5851
#define pmd_populate_kernel(mm, pmd, pte) \
5952
(pmd_val(*(pmd)) = (unsigned long) (pte))
6053

61-
/*
62-
* We don't have any real pmd's, and this code never triggers because
63-
* the pgd will always be present..
64-
*/
65-
#define pmd_alloc_one(mm, address) ({ BUG(); ((pmd_t *)2); })
66-
#define pmd_free(mm, x) do { } while (0)
67-
#define __pmd_free_tlb(tlb, x, addr) pmd_free((tlb)->mm, x)
68-
#define pgd_populate(mm, pmd, pte) BUG()
69-
7054
#endif /* CONFIG_MMU */
7155

7256
#endif /* _ASM_MICROBLAZE_PGALLOC_H */

arch/microblaze/include/asm/pgtable.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ extern int mem_init_done;
5959

6060
#else /* CONFIG_MMU */
6161

62-
#include <asm-generic/4level-fixup.h>
63-
64-
#define __PAGETABLE_PMD_FOLDED 1
62+
#include <asm-generic/pgtable-nopmd.h>
6563

6664
#ifdef __KERNEL__
6765
#ifndef __ASSEMBLY__
@@ -138,13 +136,8 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
138136
*
139137
*/
140138

141-
/* PMD_SHIFT determines the size of the area mapped by the PTE pages */
142-
#define PMD_SHIFT (PAGE_SHIFT + PTE_SHIFT)
143-
#define PMD_SIZE (1UL << PMD_SHIFT)
144-
#define PMD_MASK (~(PMD_SIZE-1))
145-
146139
/* PGDIR_SHIFT determines what a top-level page table entry can map */
147-
#define PGDIR_SHIFT PMD_SHIFT
140+
#define PGDIR_SHIFT (PAGE_SHIFT + PTE_SHIFT)
148141
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
149142
#define PGDIR_MASK (~(PGDIR_SIZE-1))
150143

@@ -165,9 +158,6 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
165158
#define pte_ERROR(e) \
166159
printk(KERN_ERR "%s:%d: bad pte "PTE_FMT".\n", \
167160
__FILE__, __LINE__, pte_val(e))
168-
#define pmd_ERROR(e) \
169-
printk(KERN_ERR "%s:%d: bad pmd %08lx.\n", \
170-
__FILE__, __LINE__, pmd_val(e))
171161
#define pgd_ERROR(e) \
172162
printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \
173163
__FILE__, __LINE__, pgd_val(e))
@@ -313,18 +303,6 @@ extern unsigned long empty_zero_page[1024];
313303
__pte(((pte_basic_t)(pfn) << PFN_SHIFT_OFFSET) | pgprot_val(prot))
314304

315305
#ifndef __ASSEMBLY__
316-
/*
317-
* The "pgd_xxx()" functions here are trivial for a folded two-level
318-
* setup: the pgd is never bad, and a pmd always exists (as it's folded
319-
* into the pgd entry)
320-
*/
321-
static inline int pgd_none(pgd_t pgd) { return 0; }
322-
static inline int pgd_bad(pgd_t pgd) { return 0; }
323-
static inline int pgd_present(pgd_t pgd) { return 1; }
324-
#define pgd_clear(xp) do { } while (0)
325-
#define pgd_page(pgd) \
326-
((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
327-
328306
/*
329307
* The following only work if pte_present() is true.
330308
* Undefined behaviour if not..
@@ -479,12 +457,6 @@ static inline void ptep_mkdirty(struct mm_struct *mm,
479457
#define pgd_index(address) ((address) >> PGDIR_SHIFT)
480458
#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
481459

482-
/* Find an entry in the second-level page table.. */
483-
static inline pmd_t *pmd_offset(pgd_t *dir, unsigned long address)
484-
{
485-
return (pmd_t *) dir;
486-
}
487-
488460
/* Find an entry in the third-level page table.. */
489461
#define pte_index(address) \
490462
(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))

arch/microblaze/kernel/signal.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
160160
int err = 0, sig = ksig->sig;
161161
unsigned long address = 0;
162162
#ifdef CONFIG_MMU
163+
pgd_t *pgdp;
164+
p4d_t *p4dp;
165+
pud_t *pudp;
163166
pmd_t *pmdp;
164167
pte_t *ptep;
165168
#endif
@@ -195,9 +198,10 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
195198

196199
address = ((unsigned long)frame->tramp);
197200
#ifdef CONFIG_MMU
198-
pmdp = pmd_offset(pud_offset(
199-
pgd_offset(current->mm, address),
200-
address), address);
201+
pgdp = pgd_offset(current->mm, address);
202+
p4dp = p4d_offset(pgdp, address);
203+
pudp = pud_offset(p4dp, address);
204+
pmdp = pmd_offset(pudp, address);
201205

202206
preempt_disable();
203207
ptep = pte_offset_map(pmdp, address);

arch/microblaze/mm/init.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ EXPORT_SYMBOL(kmap_prot);
5353

5454
static inline pte_t *virt_to_kpte(unsigned long vaddr)
5555
{
56-
return pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr),
57-
vaddr), vaddr);
56+
pgd_t *pgd = pgd_offset_k(vaddr);
57+
p4d_t *p4d = p4d_offset(pgd, vaddr);
58+
pud_t *pud = pud_offset(p4d, vaddr);
59+
60+
return pte_offset_kernel(pmd_offset(pud, vaddr), vaddr);
5861
}
5962

6063
static void __init highmem_init(void)

arch/microblaze/mm/pgtable.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@ EXPORT_SYMBOL(iounmap);
134134

135135
int map_page(unsigned long va, phys_addr_t pa, int flags)
136136
{
137+
p4d_t *p4d;
138+
pud_t *pud;
137139
pmd_t *pd;
138140
pte_t *pg;
139141
int err = -ENOMEM;
142+
140143
/* Use upper 10 bits of VA to index the first level map */
141-
pd = pmd_offset(pgd_offset_k(va), va);
144+
p4d = p4d_offset(pgd_offset_k(va), va);
145+
pud = pud_offset(p4d, va);
146+
pd = pmd_offset(pud, va);
142147
/* Use middle 10 bits of VA to index the second-level map */
143148
pg = pte_alloc_kernel(pd, va); /* from powerpc - pgtable.c */
144149
/* pg = pte_alloc_kernel(&init_mm, pd, va); */
@@ -188,13 +193,17 @@ void __init mapin_ram(void)
188193
static int get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep)
189194
{
190195
pgd_t *pgd;
196+
p4d_t *p4d;
197+
pud_t *pud;
191198
pmd_t *pmd;
192199
pte_t *pte;
193200
int retval = 0;
194201

195202
pgd = pgd_offset(mm, addr & PAGE_MASK);
196203
if (pgd) {
197-
pmd = pmd_offset(pgd, addr & PAGE_MASK);
204+
p4d = p4d_offset(pgd, addr & PAGE_MASK);
205+
pud = pud_offset(p4d, addr & PAGE_MASK);
206+
pmd = pmd_offset(pud, addr & PAGE_MASK);
198207
if (pmd_present(*pmd)) {
199208
pte = pte_offset_kernel(pmd, addr & PAGE_MASK);
200209
if (pte) {

0 commit comments

Comments
 (0)