
From: Andi Kleen <ak@suse.de>

arm: converted Not compile tested, may be broken now. 

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/arm/kernel/ecard.c        |    8 ++++----
 25-akpm/arch/arm/kernel/signal.c       |    2 +-
 25-akpm/arch/arm/mach-sa1100/assabet.c |    2 +-
 25-akpm/arch/arm/mm/consistent.c       |    3 ++-
 25-akpm/arch/arm/mm/copypage-v6.c      |    2 +-
 25-akpm/arch/arm/mm/fault-armv.c       |    2 +-
 25-akpm/arch/arm/mm/fault.c            |    2 +-
 25-akpm/arch/arm/mm/ioremap.c          |    2 +-
 25-akpm/arch/arm/mm/minicache.c        |    2 +-
 25-akpm/arch/arm/mm/mm-armv.c          |   11 ++++++-----
 25-akpm/include/asm-arm/mmu_context.h  |    2 +-
 25-akpm/include/asm-arm/page.h         |    2 ++
 25-akpm/include/asm-arm/pgalloc.h      |    4 ++--
 25-akpm/include/asm-arm/pgtable.h      |   10 ++++------
 14 files changed, 28 insertions(+), 26 deletions(-)

diff -puN arch/arm/kernel/ecard.c~4level-architecture-changes-for-arm arch/arm/kernel/ecard.c
--- 25/arch/arm/kernel/ecard.c~4level-architecture-changes-for-arm	2004-11-30 01:08:14.999307664 -0800
+++ 25-akpm/arch/arm/kernel/ecard.c	2004-11-30 01:08:15.022304168 -0800
@@ -226,13 +226,13 @@ static void ecard_init_pgtables(struct m
 	 */
 	pgd_t *src_pgd, *dst_pgd;
 
-	src_pgd = pgd_offset(mm, IO_BASE);
-	dst_pgd = pgd_offset(mm, IO_START);
+	src_pgd = pml4_pgd_offset(pml4_offset(mm, IO_BASE), IO_BASE);
+	dst_pgd = pml4_pgd_offset(pml4_offset(mm, IO_START), IO_START);
 
 	memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (IO_SIZE / PGDIR_SIZE));
 
-	src_pgd = pgd_offset(mm, EASI_BASE);
-	dst_pgd = pgd_offset(mm, EASI_START);
+	src_pgd = pml4_pgd_offset(pml4_offset(mm, EASI_BASE), EASI_BASE);
+	dst_pgd = pml4_pgd_offset(pml4_offset(mm, EASI_START), EASI_START);
 
 	memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE));
 
diff -puN arch/arm/kernel/signal.c~4level-architecture-changes-for-arm arch/arm/kernel/signal.c
--- 25/arch/arm/kernel/signal.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.000307512 -0800
+++ 25-akpm/arch/arm/kernel/signal.c	2004-11-30 01:08:15.023304016 -0800
@@ -142,7 +142,7 @@ struct iwmmxt_sigframe {
 static int page_present(struct mm_struct *mm, void __user *uptr, int wr)
 {
 	unsigned long addr = (unsigned long)uptr;
-	pgd_t *pgd = pgd_offset(mm, addr);
+ 	pgd_t *pgd = pml4_pgd_offset(pml4_offset(mm, addr), addr);
 	if (pgd_present(*pgd)) {
 		pmd_t *pmd = pmd_offset(pgd, addr);
 		if (pmd_present(*pmd)) {
diff -puN arch/arm/mach-sa1100/assabet.c~4level-architecture-changes-for-arm arch/arm/mach-sa1100/assabet.c
--- 25/arch/arm/mach-sa1100/assabet.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.002307208 -0800
+++ 25-akpm/arch/arm/mach-sa1100/assabet.c	2004-11-30 01:08:15.023304016 -0800
@@ -218,7 +218,7 @@ static void __init map_sa1100_gpio_regs(
 	int prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_IO);
 	pmd_t pmd;
 	pmd_val(pmd) = phys | prot;
-	set_pmd(pmd_offset(pgd_offset_k(virt), virt), pmd);
+	set_pmd(pmd_offset(pml4_pgd_offset_k(pml4_offset_k(virt), virt), virt), pmd);
 }
 
 /*
diff -puN arch/arm/mm/consistent.c~4level-architecture-changes-for-arm arch/arm/mm/consistent.c
--- 25/arch/arm/mm/consistent.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.003307056 -0800
+++ 25-akpm/arch/arm/mm/consistent.c	2004-11-30 01:08:15.024303864 -0800
@@ -341,7 +341,8 @@ static int __init consistent_init(void)
 	spin_lock(&init_mm.page_table_lock);
 
 	do {
-		pgd = pgd_offset(&init_mm, CONSISTENT_BASE);
+		pgd = pml4_pgd_offset_k(pml4_offset_k(CONSISTENT_BASE),
+				      CONSISTENT_BASE);
 		pmd = pmd_alloc(&init_mm, pgd, CONSISTENT_BASE);
 		if (!pmd) {
 			printk(KERN_ERR "%s: no pmd tables\n", __func__);
diff -puN arch/arm/mm/copypage-v6.c~4level-architecture-changes-for-arm arch/arm/mm/copypage-v6.c
--- 25/arch/arm/mm/copypage-v6.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.005306752 -0800
+++ 25-akpm/arch/arm/mm/copypage-v6.c	2004-11-30 01:08:15.025303712 -0800
@@ -131,7 +131,7 @@ static int __init v6_userpage_init(void)
 		pgd_t *pgd;
 		pmd_t *pmd;
 
-		pgd = pgd_offset_k(from_address);
+		pgd = pml4_pgd_offset_k(pml4_offset_k(from_address));
 		pmd = pmd_alloc(&init_mm, pgd, from_address);
 		if (!pmd)
 			BUG();
diff -puN arch/arm/mm/fault-armv.c~4level-architecture-changes-for-arm arch/arm/mm/fault-armv.c
--- 25/arch/arm/mm/fault-armv.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.006306600 -0800
+++ 25-akpm/arch/arm/mm/fault-armv.c	2004-11-30 01:08:15.025303712 -0800
@@ -34,7 +34,7 @@ static int adjust_pte(struct vm_area_str
 	pte_t *pte, entry;
 	int ret = 0;
 
-	pgd = pgd_offset(vma->vm_mm, address);
+	pgd = pml4_pgd_offset(pml4_offset(vma->vm_mm, address), address);
 	if (pgd_none(*pgd))
 		goto no_pgd;
 	if (pgd_bad(*pgd))
diff -puN arch/arm/mm/fault.c~4level-architecture-changes-for-arm arch/arm/mm/fault.c
--- 25/arch/arm/mm/fault.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.008306296 -0800
+++ 25-akpm/arch/arm/mm/fault.c	2004-11-30 01:08:15.026303560 -0800
@@ -34,7 +34,7 @@ void show_pte(struct mm_struct *mm, unsi
 		mm = &init_mm;
 
 	printk(KERN_ALERT "pgd = %p\n", mm->pgd);
-	pgd = pgd_offset(mm, addr);
+	pgd = pml4_pgd_offset(pml4_offset(mm, addr), addr);
 	printk(KERN_ALERT "[%08lx] *pgd=%08lx", addr, pgd_val(*pgd));
 
 	do {
diff -puN arch/arm/mm/ioremap.c~4level-architecture-changes-for-arm arch/arm/mm/ioremap.c
--- 25/arch/arm/mm/ioremap.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.009306144 -0800
+++ 25-akpm/arch/arm/mm/ioremap.c	2004-11-30 01:08:15.026303560 -0800
@@ -94,7 +94,7 @@ remap_area_pages(unsigned long start, un
 	pgd_t * dir;
 
 	phys_addr -= address;
-	dir = pgd_offset(&init_mm, address);
+	dir = pml4_pgd_offset(pml4_offset(&init_mm, address), address);
 	BUG_ON(address >= end);
 	spin_lock(&init_mm.page_table_lock);
 	do {
diff -puN arch/arm/mm/minicache.c~4level-architecture-changes-for-arm arch/arm/mm/minicache.c
--- 25/arch/arm/mm/minicache.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.011305840 -0800
+++ 25-akpm/arch/arm/mm/minicache.c	2004-11-30 01:08:15.026303560 -0800
@@ -57,7 +57,7 @@ static int __init minicache_init(void)
 
 	spin_lock(&init_mm.page_table_lock);
 
-	pgd = pgd_offset_k(minicache_address);
+	pgd = pml4_pgd_offset_k(pml4_offset_k(minicache_address), minicache_address);
 	pmd = pmd_alloc(&init_mm, pgd, minicache_address);
 	if (!pmd)
 		BUG();
diff -puN arch/arm/mm/mm-armv.c~4level-architecture-changes-for-arm arch/arm/mm/mm-armv.c
--- 25/arch/arm/mm/mm-armv.c~4level-architecture-changes-for-arm	2004-11-30 01:08:15.012305688 -0800
+++ 25-akpm/arch/arm/mm/mm-armv.c	2004-11-30 01:08:15.027303408 -0800
@@ -144,7 +144,7 @@ __setup("noalign", noalign_setup);
 /*
  * need to get a 16k page for level 1
  */
-pgd_t *get_pgd_slow(struct mm_struct *mm)
+pgd_t *__pgd_alloc(struct mm_struct *mm, pml4_t *pml4, unsigned long addr)
 {
 	pgd_t *new_pgd, *init_pgd;
 	pmd_t *new_pmd, *init_pmd;
@@ -156,7 +156,7 @@ pgd_t *get_pgd_slow(struct mm_struct *mm
 
 	memzero(new_pgd, FIRST_KERNEL_PGD_NR * sizeof(pgd_t));
 
-	init_pgd = pgd_offset_k(0);
+	init_pgd = pml4_pgd_offset_k(pml4_offset_k(0), 0);
 
 	if (vectors_base() == 0) {
 		/*
@@ -246,7 +246,7 @@ alloc_init_section(unsigned long virt, u
 {
 	pmd_t *pmdp;
 
-	pmdp = pmd_offset(pgd_offset_k(virt), virt);
+	pmdp = pmd_offset(pml4_pgd_offset_k(pml4_offset_k(virt), virt), virt);
 	if (virt & (1 << 20))
 		pmdp++;
 
@@ -266,7 +266,7 @@ alloc_init_page(unsigned long virt, unsi
 	pmd_t *pmdp;
 	pte_t *ptep;
 
-	pmdp = pmd_offset(pgd_offset_k(virt), virt);
+	pmdp = pmd_offset(pml4_pgd_offset_k(pml4_offset_k(virt), virt), virt);
 
 	if (pmd_none(*pmdp)) {
 		unsigned long pmdval;
@@ -290,7 +290,8 @@ alloc_init_page(unsigned long virt, unsi
  */
 static inline void clear_mapping(unsigned long virt)
 {
-	pmd_clear(pmd_offset(pgd_offset_k(virt), virt));
+	pmd_clear(pmd_offset(pml4_pgd_offset_k(pml4_offset_k(virt), virt),
+			     virt));
 }
 
 struct mem_types {
diff -puN include/asm-arm/mmu_context.h~4level-architecture-changes-for-arm include/asm-arm/mmu_context.h
--- 25/include/asm-arm/mmu_context.h~4level-architecture-changes-for-arm	2004-11-30 01:08:15.014305384 -0800
+++ 25-akpm/include/asm-arm/mmu_context.h	2004-11-30 01:08:15.028303256 -0800
@@ -85,7 +85,7 @@ switch_mm(struct mm_struct *prev, struct
 	if (prev != next) {
 		cpu_set(cpu, next->cpu_vm_mask);
 		check_context(next);
-		cpu_switch_mm(next->pgd, next);
+		cpu_switch_mm(next->pml4, next);
 		cpu_clear(cpu, prev->cpu_vm_mask);
 	}
 }
diff -puN include/asm-arm/page.h~4level-architecture-changes-for-arm include/asm-arm/page.h
--- 25/include/asm-arm/page.h~4level-architecture-changes-for-arm	2004-11-30 01:08:15.015305232 -0800
+++ 25-akpm/include/asm-arm/page.h	2004-11-30 01:08:15.028303256 -0800
@@ -187,6 +187,8 @@ static inline int get_order(unsigned lon
 
 #include <asm/memory.h>
 
+#include <asm-generic/nopml4-page.h>
+
 #endif /* !__ASSEMBLY__ */
 
 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
diff -puN include/asm-arm/pgalloc.h~4level-architecture-changes-for-arm include/asm-arm/pgalloc.h
--- 25/include/asm-arm/pgalloc.h~4level-architecture-changes-for-arm	2004-11-30 01:08:15.016305080 -0800
+++ 25-akpm/include/asm-arm/pgalloc.h	2004-11-30 01:08:15.028303256 -0800
@@ -21,10 +21,8 @@
 #define pmd_free(pmd)			do { } while (0)
 #define pgd_populate(mm,pmd,pte)	BUG()
 
-extern pgd_t *get_pgd_slow(struct mm_struct *mm);
 extern void free_pgd_slow(pgd_t *pgd);
 
-#define pgd_alloc(mm)			get_pgd_slow(mm)
 #define pgd_free(pgd)			free_pgd_slow(pgd)
 
 #define check_pgt_cache()		do { } while (0)
@@ -129,4 +127,6 @@ pmd_populate(struct mm_struct *mm, pmd_t
 	flush_pmd_entry(pmdp);
 }
 
+#include <asm-generic/nopml4-pgalloc.h>
+
 #endif
diff -puN include/asm-arm/pgtable.h~4level-architecture-changes-for-arm include/asm-arm/pgtable.h
--- 25/include/asm-arm/pgtable.h~4level-architecture-changes-for-arm	2004-11-30 01:08:15.018304776 -0800
+++ 25-akpm/include/asm-arm/pgtable.h	2004-11-30 01:08:15.029303104 -0800
@@ -101,7 +101,7 @@ extern void __pgd_error(const char *file
 #define PGDIR_MASK		(~(PGDIR_SIZE-1))
 
 #define FIRST_USER_PGD_NR	1
-#define USER_PTRS_PER_PGD	((TASK_SIZE/PGDIR_SIZE) - FIRST_USER_PGD_NR)
+#define USER_PGDS_IN_LAST_PML4	((TASK_SIZE/PGDIR_SIZE) - FIRST_USER_PGD_NR)
 
 /*
  * Hardware page table definitions.
@@ -365,11 +365,7 @@ static inline pte_t *pmd_page_kernel(pmd
 
 /* to find an entry in a page-table-directory */
 #define pgd_index(addr)		((addr) >> PGDIR_SHIFT)
-
-#define pgd_offset(mm, addr)	((mm)->pgd+pgd_index(addr))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(addr)	pgd_offset(&init_mm, addr)
+#define pgd_index_k(addr)	pgd_index(addr)
 
 /* Find an entry in the second-level page table.. */
 #define pmd_offset(dir, addr)	((pmd_t *)(dir))
@@ -416,6 +412,8 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD
 
 #define pgtable_cache_init() do { } while (0)
 
+#include <asm-generic/nopml4-pgtable.h>
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* _ASMARM_PGTABLE_H */
_
