
From: Andi Kleen <ak@suse.de>

sh		converted, but doesn't compile for other reasons

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

 25-akpm/arch/sh/mm/cache-sh4.c       |    4 ++--
 25-akpm/arch/sh/mm/fault.c           |    4 ++--
 25-akpm/arch/sh/mm/hugetlbpage.c     |    4 ++--
 25-akpm/arch/sh/mm/init.c            |   11 +++++++++++
 25-akpm/arch/sh/mm/ioremap.c         |    2 +-
 25-akpm/arch/sh/mm/pg-sh4.c          |    4 ++--
 25-akpm/include/asm-sh/mmu_context.h |    2 +-
 25-akpm/include/asm-sh/page.h        |    2 ++
 25-akpm/include/asm-sh/pgalloc.h     |   12 ++----------
 25-akpm/include/asm-sh/pgtable.h     |    9 ++++-----
 10 files changed, 29 insertions(+), 25 deletions(-)

diff -puN arch/sh/mm/cache-sh4.c~4level-architecture-changes-for-sh arch/sh/mm/cache-sh4.c
--- 25/arch/sh/mm/cache-sh4.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.250381456 -0800
+++ 25-akpm/arch/sh/mm/cache-sh4.c	2004-11-03 21:53:24.267378872 -0800
@@ -301,7 +301,7 @@ void flush_cache_range(struct vm_area_st
 	unsigned long phys;
 	unsigned long d = 0;
 
-	dir = pgd_offset(vma->vm_mm, p);
+	dir = pml4_pgd_offset(pml4_offset(vma->vm_mm, p), p);
 	pmd = pmd_offset(dir, p);
 
 	do {
@@ -354,7 +354,7 @@ void flush_cache_page(struct vm_area_str
 	pte_t entry;
 	unsigned long phys;
 
-	dir = pgd_offset(vma->vm_mm, address);
+	dir = pml4_pgd_offset(pml4_offset(vma->vm_mm, address), address);
 	pmd = pmd_offset(dir, address);
 	if (pmd_none(*pmd) || pmd_bad(*pmd))
 		return;
diff -puN arch/sh/mm/fault.c~4level-architecture-changes-for-sh arch/sh/mm/fault.c
--- 25/arch/sh/mm/fault.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.252381152 -0800
+++ 25-akpm/arch/sh/mm/fault.c	2004-11-03 21:53:24.267378872 -0800
@@ -209,13 +209,13 @@ asmlinkage int __do_page_fault(struct pt
 #endif
 
 	if (address >= P3SEG && address < addrmax)
-		dir = pgd_offset_k(address);
+		dir = pml4_pgd_offset(pml4_offset_k(address), address);
 	else if (address >= TASK_SIZE)
 		return 1;
 	else if (!current->mm)
 		return 1;
 	else
-		dir = pgd_offset(current->mm, address);
+		dir = pml4_pgd_offset(pml4_offset(current->mm,address),address);
 
 	pmd = pmd_offset(dir, address);
 	if (pmd_none(*pmd))
diff -puN arch/sh/mm/hugetlbpage.c~4level-architecture-changes-for-sh arch/sh/mm/hugetlbpage.c
--- 25/arch/sh/mm/hugetlbpage.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.253381000 -0800
+++ 25-akpm/arch/sh/mm/hugetlbpage.c	2004-11-03 21:53:24.268378720 -0800
@@ -30,7 +30,7 @@ static pte_t *huge_pte_alloc(struct mm_s
 	pmd_t *pmd;
 	pte_t *pte = NULL;
 
-	pgd = pgd_offset(mm, addr);
+	pgd = pml4_pgd_offset(pml4_offset(mm, addr), addr);
 	if (pgd) {
 		pmd = pmd_alloc(mm, pgd, addr);
 		if (pmd)
@@ -45,7 +45,7 @@ static pte_t *huge_pte_offset(struct mm_
 	pmd_t *pmd;
 	pte_t *pte = NULL;
 
-	pgd = pgd_offset(mm, addr);
+	pgd = pml4_pgd_offset(pml4_offset(mm, addr), addr);
 	if (pgd) {
 		pmd = pmd_offset(pgd, addr);
 		if (pmd)
diff -puN arch/sh/mm/init.c~4level-architecture-changes-for-sh arch/sh/mm/init.c
--- 25/arch/sh/mm/init.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.255380696 -0800
+++ 25-akpm/arch/sh/mm/init.c	2004-11-03 21:53:24.268378720 -0800
@@ -313,3 +313,14 @@ void free_initrd_mem(unsigned long start
 }
 #endif
 
+
+pgd_t *__pgd_alloc(struct mm_struct *mm, pml4_t *dummy, unsigned long addr)
+{
+	unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
+	pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
+
+	if (pgd)
+		memset(pgd, 0, pgd_size);
+
+	return pgd;
+}
diff -puN arch/sh/mm/ioremap.c~4level-architecture-changes-for-sh arch/sh/mm/ioremap.c
--- 25/arch/sh/mm/ioremap.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.256380544 -0800
+++ 25-akpm/arch/sh/mm/ioremap.c	2004-11-03 21:53:24.269378568 -0800
@@ -75,7 +75,7 @@ int remap_area_pages(unsigned long addre
 	unsigned long end = address + size;
 
 	phys_addr -= address;
-	dir = pgd_offset_k(address);
+	dir = pml4_pgd_offset(pml4_offset_k(address), address);
 	flush_cache_all();
 	if (address >= end)
 		BUG();
diff -puN arch/sh/mm/pg-sh4.c~4level-architecture-changes-for-sh arch/sh/mm/pg-sh4.c
--- 25/arch/sh/mm/pg-sh4.c~4level-architecture-changes-for-sh	2004-11-03 21:53:24.257380392 -0800
+++ 25-akpm/arch/sh/mm/pg-sh4.c	2004-11-03 21:53:24.269378568 -0800
@@ -42,7 +42,7 @@ void clear_user_page(void *to, unsigned 
 					   _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
 		unsigned long phys_addr = PHYSADDR(to);
 		unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
-		pgd_t *dir = pgd_offset_k(p3_addr);
+		pgd_t *dir = pml4_pgd_offset(pml4_offset_k(p3_addr), p3_addr);
 		pmd_t *pmd = pmd_offset(dir, p3_addr);
 		pte_t *pte = pte_offset_kernel(pmd, p3_addr);
 		pte_t entry;
@@ -81,7 +81,7 @@ void copy_user_page(void *to, void *from
 					   _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
 		unsigned long phys_addr = PHYSADDR(to);
 		unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
-		pgd_t *dir = pgd_offset_k(p3_addr);
+		pgd_t *dir = pml4_pgd_offset(pml4_offset_k(p3_addr), p3_addr);
 		pmd_t *pmd = pmd_offset(dir, p3_addr);
 		pte_t *pte = pte_offset_kernel(pmd, p3_addr);
 		pte_t entry;
diff -puN include/asm-sh/mmu_context.h~4level-architecture-changes-for-sh include/asm-sh/mmu_context.h
--- 25/include/asm-sh/mmu_context.h~4level-architecture-changes-for-sh	2004-11-03 21:53:24.259380088 -0800
+++ 25-akpm/include/asm-sh/mmu_context.h	2004-11-03 21:53:24.269378568 -0800
@@ -133,7 +133,7 @@ static __inline__ void switch_mm(struct 
 				 struct task_struct *tsk)
 {
 	if (likely(prev != next)) {
-		unsigned long __pgdir = (unsigned long)next->pgd;
+		unsigned long __pgdir = (unsigned long)next->pml4;
 
 		__asm__ __volatile__("mov.l	%0, %1"
 				     : /* no output */
diff -puN include/asm-sh/page.h~4level-architecture-changes-for-sh include/asm-sh/page.h
--- 25/include/asm-sh/page.h~4level-architecture-changes-for-sh	2004-11-03 21:53:24.260379936 -0800
+++ 25-akpm/include/asm-sh/page.h	2004-11-03 21:53:24.270378416 -0800
@@ -139,6 +139,8 @@ static __inline__ int get_order(unsigned
 
 #endif
 
+#include <asm-generic/nopml4-page.h>
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_PAGE_H */
diff -puN include/asm-sh/pgalloc.h~4level-architecture-changes-for-sh include/asm-sh/pgalloc.h
--- 25/include/asm-sh/pgalloc.h~4level-architecture-changes-for-sh	2004-11-03 21:53:24.262379632 -0800
+++ 25-akpm/include/asm-sh/pgalloc.h	2004-11-03 21:53:24.270378416 -0800
@@ -23,16 +23,6 @@ static inline void pmd_populate(struct m
 /*
  * Allocate and free page tables.
  */
-static inline pgd_t *pgd_alloc(struct mm_struct *mm)
-{
-	unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
-	pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
-
-	if (pgd)
-		memset(pgd, 0, pgd_size);
-
-	return pgd;
-}
 
 static inline void pgd_free(pgd_t *pgd)
 {
@@ -90,4 +80,6 @@ static inline void pte_free(struct page 
 #define PG_mapped			PG_arch_1
 #endif
 
+#include <asm-generic/nopml4-pgalloc.h>
+
 #endif /* __ASM_SH_PGALLOC_H */
diff -puN include/asm-sh/pgtable.h~4level-architecture-changes-for-sh include/asm-sh/pgtable.h
--- 25/include/asm-sh/pgtable.h~4level-architecture-changes-for-sh	2004-11-03 21:53:24.263379480 -0800
+++ 25-akpm/include/asm-sh/pgtable.h	2004-11-03 21:53:24.271378264 -0800
@@ -41,7 +41,7 @@ extern unsigned long empty_zero_page[102
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE-1))
 
-#define USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
+#define USER_PGDS_IN_LAST_PML4	(TASK_SIZE/PGDIR_SIZE)
 #define FIRST_USER_PGD_NR	0
 
 #define PTE_PHYS_MASK	0x1ffff000
@@ -231,10 +231,7 @@ static inline pte_t pte_modify(pte_t pte
 
 /* to find an entry in a page-table-directory. */
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
-#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
-
-/* to find an entry in a kernel page-table-directory */
-#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+#define pgd_index_k(address) pgd_index(address)
 
 /* Find an entry in the third-level page table.. */
 #define pte_index(address) \
@@ -293,5 +290,7 @@ extern pte_t ptep_get_and_clear(pte_t *p
 
 #include <asm-generic/pgtable.h>
 
+#include <asm-generic/nopml4-pgtable.h>
+
 #endif /* __ASM_SH_PAGE_H */
 
_
