HeadsUp: FIRST_USER_PGD_NR and USER_PTRS_PER_PGD

From: Russell King (rmk@arm.linux.org.uk)
Date: Sun Feb 27 2000 - 10:56:54 EST


Hi,

I'd like to propose the following change so that the ARM architecture can
be cleanly handled in the kernel cleanly.

The ARM architecture needs to keep the very first virtual page mapped. The
reason is that the machine exception vectors are stored within this page.
In order to achieve this, I need to prevent the first pte table from being
freed by the clear_page_tables code.

Luckily, clear_page_tables takes an index for the first pmd table (and therefore
on a two-level system, the first pte table) to start clearing from. Therefore,
the change below is trivial - we just need a new definition `FIRST_USER_PGD_NR'
to be able to specify the first PMD to start clearing from.

However, please note that USER_PTRS_PER_PGD is the number of USER pmd table pointers
in the pgd table. Therefore, the first user pmd pointer is obtained by:

        pgd + FIRST_USER_PGD_NR

and the last user pmd pointer by:

        pgd + FIRST_USER_PGD_NR + USER_PTRS_PER_PGD - 1

This means that:

        pgd + USER_PTRS_PER_PGD

is no longer valid. Here is the patch for the change, which hopefully covers
all architectures correctly.

diff -urN linux-orig/include/asm-alpha/pgtable.h linux/include/asm-alpha/pgtable.h
--- linux-orig/include/asm-alpha/pgtable.h Tue Feb 15 00:12:31 2000
+++ linux/include/asm-alpha/pgtable.h Sat Feb 26 11:24:55 2000
@@ -40,6 +40,7 @@
 #define PTRS_PER_PMD (1UL << (PAGE_SHIFT-3))
 #define PTRS_PER_PGD ((1UL << (PAGE_SHIFT-3))-1)
 #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 /* Number of pointers that fit on a page: this will go away. */
 #define PTRS_PER_PAGE (1UL << (PAGE_SHIFT-3))
diff -urN linux-orig/include/asm-arm/pgtable.h linux/include/asm-arm/pgtable.h
--- linux-orig/include/asm-arm/pgtable.h Tue Feb 15 00:12:31 2000
+++ linux/include/asm-arm/pgtable.h Sat Feb 26 14:27:03 2000
@@ -32,7 +32,8 @@
 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
 #define PGDIR_MASK (~(PGDIR_SIZE-1))
 
-#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 1
+#define USER_PTRS_PER_PGD ((TASK_SIZE/PGDIR_SIZE) - FIRST_USER_PGD_NR)
 
 /*
  * The table below defines the page protection levels that we insert into our
diff -urN linux-orig/include/asm-i386/pgtable.h linux/include/asm-i386/pgtable.h
--- linux-orig/include/asm-i386/pgtable.h Sun Feb 27 09:45:09 2000
+++ linux/include/asm-i386/pgtable.h Sun Feb 27 10:17:06 2000
@@ -113,6 +113,7 @@
 #define PGDIR_MASK (~(PGDIR_SIZE-1))
 
 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
diff -urN linux-orig/include/asm-ia64/pgtable.h linux/include/asm-ia64/pgtable.h
--- linux-orig/include/asm-ia64/pgtable.h Sun Feb 27 09:45:09 2000
+++ linux/include/asm-ia64/pgtable.h Sun Feb 27 10:17:06 2000
@@ -87,6 +87,7 @@
 #define PGDIR_MASK (~(PGDIR_SIZE-1))
 #define PTRS_PER_PGD (__IA64_UL(1) << (PAGE_SHIFT-3))
 #define USER_PTRS_PER_PGD PTRS_PER_PGD
+#define FIRST_USER_PGD_NR 0
 
 /*
  * Definitions for second level:
diff -urN linux-orig/include/asm-m68k/pgtable.h linux/include/asm-m68k/pgtable.h
--- linux-orig/include/asm-m68k/pgtable.h Tue Feb 15 00:12:31 2000
+++ linux/include/asm-m68k/pgtable.h Sat Feb 26 11:24:55 2000
@@ -43,6 +43,7 @@
 #define PTRS_PER_PMD 8
 #define PTRS_PER_PGD 128
 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 /* Virtual address region for use by kernel_map() */
 #define KMAP_START 0xd0000000
diff -urN linux-orig/include/asm-mips/pgtable.h linux/include/asm-mips/pgtable.h
--- linux-orig/include/asm-mips/pgtable.h Sun Feb 27 09:45:10 2000
+++ linux/include/asm-mips/pgtable.h Sun Feb 27 10:17:24 2000
@@ -79,6 +79,7 @@
 #define PTRS_PER_PMD 1
 #define PTRS_PER_PGD 1024
 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 #define VMALLOC_START KSEG2
 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
diff -urN linux-orig/include/asm-ppc/pgtable.h linux/include/asm-ppc/pgtable.h
--- linux-orig/include/asm-ppc/pgtable.h Fri Feb 18 20:53:10 2000
+++ linux/include/asm-ppc/pgtable.h Sat Feb 26 11:24:55 2000
@@ -138,6 +138,7 @@
 #define PTRS_PER_PMD 1
 #define PTRS_PER_PGD 1024
 #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
diff -urN linux-orig/include/asm-sh/pgtable.h linux/include/asm-sh/pgtable.h
--- linux-orig/include/asm-sh/pgtable.h Tue Feb 15 00:12:32 2000
+++ linux/include/asm-sh/pgtable.h Sat Feb 26 11:24:55 2000
@@ -91,6 +91,7 @@
 #define PGDIR_MASK (~(PGDIR_SIZE-1))
 
 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_PGD_NR 0
 
 #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
 #define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
diff -urN linux-orig/include/asm-sparc/pgtable.h linux/include/asm-sparc/pgtable.h
--- linux-orig/include/asm-sparc/pgtable.h Mon Feb 21 22:43:03 2000
+++ linux/include/asm-sparc/pgtable.h Sat Feb 26 11:24:55 2000
@@ -118,6 +118,7 @@
 #define PTRS_PER_PMD BTFIXUP_SIMM13(ptrs_per_pmd)
 #define PTRS_PER_PGD BTFIXUP_SIMM13(ptrs_per_pgd)
 #define USER_PTRS_PER_PGD BTFIXUP_SIMM13(user_ptrs_per_pgd)
+#define FIRST_USER_PGD_NR 0
 
 #define PAGE_NONE __pgprot(BTFIXUP_INT(page_none))
 #define PAGE_SHARED __pgprot(BTFIXUP_INT(page_shared))
diff -urN linux-orig/include/asm-sparc64/pgtable.h linux/include/asm-sparc64/pgtable.h
--- linux-orig/include/asm-sparc64/pgtable.h Mon Feb 21 22:43:03 2000
+++ linux/include/asm-sparc64/pgtable.h Sat Feb 26 11:24:55 2000
@@ -51,6 +51,7 @@
 /* Kernel has a separate 44bit address space. */
 #define USER_PTRS_PER_PGD ((const int)((current->thread.flags & SPARC_FLAG_32BIT) ? \
                                  (1) : (PTRS_PER_PGD)))
+#define FIRST_USER_PGD_NR 0
 
 #define PTE_TABLE_SIZE 0x2000 /* 1024 entries 8 bytes each */
 #define PMD_TABLE_SIZE 0x2000 /* 2048 entries 4 bytes each */
diff -urN linux-orig/mm/mmap.c linux/mm/mmap.c
--- linux-orig/mm/mmap.c Fri Feb 18 20:53:11 2000
+++ linux/mm/mmap.c Sat Feb 26 11:21:18 2000
@@ -860,7 +860,7 @@
         if (mm->map_count)
                 printk("exit_mmap: map count is %d\n", mm->map_count);
 
- clear_page_tables(mm, 0, USER_PTRS_PER_PGD);
+ clear_page_tables(mm, FIRST_USER_PGD_NR, USER_PTRS_PER_PGD);
 }
 
 /* Insert vm structure into process list sorted by address

   _____
  |_____| ------------------------------------------------- ---+---+-
  | | Russell King rmk@arm.linux.org.uk --- ---
  | | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
  | +-+-+ --- -+-
  / | THE developer of ARM Linux |+| /|\
 / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:17 EST