aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-03-17 19:37:13 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-24 17:57:31 -0400
commit68db065c845bd9d0eb96946ab104b4c82d0ae9da (patch)
treea12f007e11538af668227d6da1c476af6329899f
parent90e9f53662826db3cdd6d99bd394d727b05160c1 (diff)
x86: unify KERNEL_PGD_PTRS
Make KERNEL_PGD_PTRS common, as previously it was only being defined for 32-bit. There are a couple of follow-on changes from this: - KERNEL_PGD_PTRS was being defined in terms of USER_PGD_PTRS. The definition of USER_PGD_PTRS doesn't really make much sense on x86-64, since it can have two different user address-space configurations. I renamed USER_PGD_PTRS to KERNEL_PGD_BOUNDARY, which is meaningful for all of 32/32, 32/64 and 64/64 process configurations. - USER_PTRS_PER_PGD was also defined and was being used for similar purposes. Converting its users to KERNEL_PGD_BOUNDARY left it completely unused, and so I removed it. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: Andi Kleen <ak@suse.de> Cc: Zach Amsden <zach@vmware.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/kernel/reboot.c4
-rw-r--r--arch/x86/kernel/smpboot.c4
-rw-r--r--arch/x86/kernel/vmi_32.c2
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c4
-rw-r--r--arch/x86/mm/init_32.c2
-rw-r--r--arch/x86/mm/pgtable.c12
-rw-r--r--include/asm-x86/pgtable.h4
-rw-r--r--include/asm-x86/pgtable_32.h3
8 files changed, 17 insertions, 18 deletions
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 19c9386ac118..1791a751a772 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -8,6 +8,7 @@
8#include <asm/apic.h> 8#include <asm/apic.h>
9#include <asm/desc.h> 9#include <asm/desc.h>
10#include <asm/hpet.h> 10#include <asm/hpet.h>
11#include <asm/pgtable.h>
11#include <asm/reboot_fixups.h> 12#include <asm/reboot_fixups.h>
12#include <asm/reboot.h> 13#include <asm/reboot.h>
13 14
@@ -15,7 +16,6 @@
15# include <linux/dmi.h> 16# include <linux/dmi.h>
16# include <linux/ctype.h> 17# include <linux/ctype.h>
17# include <linux/mc146818rtc.h> 18# include <linux/mc146818rtc.h>
18# include <asm/pgtable.h>
19#else 19#else
20# include <asm/iommu.h> 20# include <asm/iommu.h>
21#endif 21#endif
@@ -275,7 +275,7 @@ void machine_real_restart(unsigned char *code, int length)
275 /* Remap the kernel at virtual address zero, as well as offset zero 275 /* Remap the kernel at virtual address zero, as well as offset zero
276 from the kernel segment. This assumes the kernel segment starts at 276 from the kernel segment. This assumes the kernel segment starts at
277 virtual address PAGE_OFFSET. */ 277 virtual address PAGE_OFFSET. */
278 memcpy(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 278 memcpy(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
279 sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS); 279 sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
280 280
281 /* 281 /*
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6a925394bc7e..2de2f7a2ed5d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1039,8 +1039,8 @@ int __cpuinit native_cpu_up(unsigned int cpu)
1039 1039
1040#ifdef CONFIG_X86_32 1040#ifdef CONFIG_X86_32
1041 /* init low mem mapping */ 1041 /* init low mem mapping */
1042 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 1042 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
1043 min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS)); 1043 min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
1044 flush_tlb_all(); 1044 flush_tlb_all();
1045#endif 1045#endif
1046 1046
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index 44f7ca153b71..956f38927aa7 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -320,7 +320,7 @@ static void check_zeroed_page(u32 pfn, int type, struct page *page)
320 * pdes need to be zeroed. 320 * pdes need to be zeroed.
321 */ 321 */
322 if (type & VMI_PAGE_CLONE) 322 if (type & VMI_PAGE_CLONE)
323 limit = USER_PTRS_PER_PGD; 323 limit = KERNEL_PGD_BOUNDARY;
324 for (i = 0; i < limit; i++) 324 for (i = 0; i < limit; i++)
325 BUG_ON(ptr[i]); 325 BUG_ON(ptr[i]);
326} 326}
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index 96f60c7cd124..394046effd78 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -560,8 +560,8 @@ static void __init do_boot_cpu(__u8 cpu)
560 hijack_source.idt.Offset, stack_start.sp)); 560 hijack_source.idt.Offset, stack_start.sp));
561 561
562 /* init lowmem identity mapping */ 562 /* init lowmem identity mapping */
563 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 563 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
564 min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS)); 564 min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
565 flush_tlb_all(); 565 flush_tlb_all();
566 566
567 if (quad_boot) { 567 if (quad_boot) {
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index df490905f377..08aa1878fad4 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -457,7 +457,7 @@ void zap_low_mappings(void)
457 * Note that "pgd_clear()" doesn't do it for 457 * Note that "pgd_clear()" doesn't do it for
458 * us, because pgd_clear() is a no-op on i386. 458 * us, because pgd_clear() is a no-op on i386.
459 */ 459 */
460 for (i = 0; i < USER_PTRS_PER_PGD; i++) { 460 for (i = 0; i < KERNEL_PGD_BOUNDARY; i++) {
461#ifdef CONFIG_X86_PAE 461#ifdef CONFIG_X86_PAE
462 set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page))); 462 set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
463#else 463#else
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index af0c50161d95..e2ac320e6151 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -104,7 +104,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
104 * -- wli 104 * -- wli
105 */ 105 */
106#define UNSHARED_PTRS_PER_PGD \ 106#define UNSHARED_PTRS_PER_PGD \
107 (SHARED_KERNEL_PMD ? USER_PTRS_PER_PGD : PTRS_PER_PGD) 107 (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
108 108
109static void pgd_ctor(void *p) 109static void pgd_ctor(void *p)
110{ 110{
@@ -112,7 +112,7 @@ static void pgd_ctor(void *p)
112 unsigned long flags; 112 unsigned long flags;
113 113
114 /* Clear usermode parts of PGD */ 114 /* Clear usermode parts of PGD */
115 memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); 115 memset(pgd, 0, KERNEL_PGD_BOUNDARY*sizeof(pgd_t));
116 116
117 spin_lock_irqsave(&pgd_lock, flags); 117 spin_lock_irqsave(&pgd_lock, flags);
118 118
@@ -121,12 +121,12 @@ static void pgd_ctor(void *p)
121 references from swapper_pg_dir. */ 121 references from swapper_pg_dir. */
122 if (PAGETABLE_LEVELS == 2 || 122 if (PAGETABLE_LEVELS == 2 ||
123 (PAGETABLE_LEVELS == 3 && SHARED_KERNEL_PMD)) { 123 (PAGETABLE_LEVELS == 3 && SHARED_KERNEL_PMD)) {
124 clone_pgd_range(pgd + USER_PTRS_PER_PGD, 124 clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY,
125 swapper_pg_dir + USER_PTRS_PER_PGD, 125 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
126 KERNEL_PGD_PTRS); 126 KERNEL_PGD_PTRS);
127 paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT, 127 paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT,
128 __pa(swapper_pg_dir) >> PAGE_SHIFT, 128 __pa(swapper_pg_dir) >> PAGE_SHIFT,
129 USER_PTRS_PER_PGD, 129 KERNEL_PGD_BOUNDARY,
130 KERNEL_PGD_PTRS); 130 KERNEL_PGD_PTRS);
131 } 131 }
132 132
@@ -201,7 +201,7 @@ static int pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd)
201 return 0; 201 return 0;
202 } 202 }
203 203
204 if (i >= USER_PTRS_PER_PGD) 204 if (i >= KERNEL_PGD_BOUNDARY)
205 memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]), 205 memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
206 sizeof(pmd_t) * PTRS_PER_PMD); 206 sizeof(pmd_t) * PTRS_PER_PMD);
207 207
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 4ebea41ea70e..e61075e70a54 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -1,7 +1,6 @@
1#ifndef _ASM_X86_PGTABLE_H 1#ifndef _ASM_X86_PGTABLE_H
2#define _ASM_X86_PGTABLE_H 2#define _ASM_X86_PGTABLE_H
3 3
4#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)
5#define FIRST_USER_ADDRESS 0 4#define FIRST_USER_ADDRESS 0
6 5
7#define _PAGE_BIT_PRESENT 0 /* is present */ 6#define _PAGE_BIT_PRESENT 0 /* is present */
@@ -330,6 +329,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
330# include "pgtable_64.h" 329# include "pgtable_64.h"
331#endif 330#endif
332 331
332#define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
333#define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
334
333#ifndef __ASSEMBLY__ 335#ifndef __ASSEMBLY__
334 336
335enum { 337enum {
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index c4a643674458..cc52da32fbe2 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -48,9 +48,6 @@ void paging_init(void);
48#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 48#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
49#define PGDIR_MASK (~(PGDIR_SIZE - 1)) 49#define PGDIR_MASK (~(PGDIR_SIZE - 1))
50 50
51#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
52#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
53
54/* Just any arbitrary offset to the start of the vmalloc VM area: the 51/* Just any arbitrary offset to the start of the vmalloc VM area: the
55 * current 8MB value just means that there will be a 8MB "hole" after the 52 * current 8MB value just means that there will be a 8MB "hole" after the
56 * physical memory until the kernel virtual memory starts. That means that 53 * physical memory until the kernel virtual memory starts. That means that