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>
This commit is contained in:
Jeremy Fitzhardinge 2008-03-17 16:37:13 -07:00 committed by Ingo Molnar
parent 90e9f53662
commit 68db065c84
8 changed files with 17 additions and 18 deletions

View file

@ -8,6 +8,7 @@
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/hpet.h> #include <asm/hpet.h>
#include <asm/pgtable.h>
#include <asm/reboot_fixups.h> #include <asm/reboot_fixups.h>
#include <asm/reboot.h> #include <asm/reboot.h>
@ -15,7 +16,6 @@
# include <linux/dmi.h> # include <linux/dmi.h>
# include <linux/ctype.h> # include <linux/ctype.h>
# include <linux/mc146818rtc.h> # include <linux/mc146818rtc.h>
# include <asm/pgtable.h>
#else #else
# include <asm/iommu.h> # include <asm/iommu.h>
#endif #endif
@ -275,7 +275,7 @@ void machine_real_restart(unsigned char *code, int length)
/* Remap the kernel at virtual address zero, as well as offset zero /* Remap the kernel at virtual address zero, as well as offset zero
from the kernel segment. This assumes the kernel segment starts at from the kernel segment. This assumes the kernel segment starts at
virtual address PAGE_OFFSET. */ virtual address PAGE_OFFSET. */
memcpy(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, memcpy(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS); sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
/* /*

View file

@ -1039,8 +1039,8 @@ int __cpuinit native_cpu_up(unsigned int cpu)
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
/* init low mem mapping */ /* init low mem mapping */
clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS)); min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
flush_tlb_all(); flush_tlb_all();
#endif #endif

View file

@ -320,7 +320,7 @@ static void check_zeroed_page(u32 pfn, int type, struct page *page)
* pdes need to be zeroed. * pdes need to be zeroed.
*/ */
if (type & VMI_PAGE_CLONE) if (type & VMI_PAGE_CLONE)
limit = USER_PTRS_PER_PGD; limit = KERNEL_PGD_BOUNDARY;
for (i = 0; i < limit; i++) for (i = 0; i < limit; i++)
BUG_ON(ptr[i]); BUG_ON(ptr[i]);
} }

View file

@ -560,8 +560,8 @@ static void __init do_boot_cpu(__u8 cpu)
hijack_source.idt.Offset, stack_start.sp)); hijack_source.idt.Offset, stack_start.sp));
/* init lowmem identity mapping */ /* init lowmem identity mapping */
clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS)); min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
flush_tlb_all(); flush_tlb_all();
if (quad_boot) { if (quad_boot) {

View file

@ -457,7 +457,7 @@ void zap_low_mappings(void)
* Note that "pgd_clear()" doesn't do it for * Note that "pgd_clear()" doesn't do it for
* us, because pgd_clear() is a no-op on i386. * us, because pgd_clear() is a no-op on i386.
*/ */
for (i = 0; i < USER_PTRS_PER_PGD; i++) { for (i = 0; i < KERNEL_PGD_BOUNDARY; i++) {
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page))); set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
#else #else

View file

@ -104,7 +104,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
* -- wli * -- wli
*/ */
#define UNSHARED_PTRS_PER_PGD \ #define UNSHARED_PTRS_PER_PGD \
(SHARED_KERNEL_PMD ? USER_PTRS_PER_PGD : PTRS_PER_PGD) (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
static void pgd_ctor(void *p) static void pgd_ctor(void *p)
{ {
@ -112,7 +112,7 @@ static void pgd_ctor(void *p)
unsigned long flags; unsigned long flags;
/* Clear usermode parts of PGD */ /* Clear usermode parts of PGD */
memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t)); memset(pgd, 0, KERNEL_PGD_BOUNDARY*sizeof(pgd_t));
spin_lock_irqsave(&pgd_lock, flags); spin_lock_irqsave(&pgd_lock, flags);
@ -121,12 +121,12 @@ static void pgd_ctor(void *p)
references from swapper_pg_dir. */ references from swapper_pg_dir. */
if (PAGETABLE_LEVELS == 2 || if (PAGETABLE_LEVELS == 2 ||
(PAGETABLE_LEVELS == 3 && SHARED_KERNEL_PMD)) { (PAGETABLE_LEVELS == 3 && SHARED_KERNEL_PMD)) {
clone_pgd_range(pgd + USER_PTRS_PER_PGD, clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY,
swapper_pg_dir + USER_PTRS_PER_PGD, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
KERNEL_PGD_PTRS); KERNEL_PGD_PTRS);
paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT, paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT,
__pa(swapper_pg_dir) >> PAGE_SHIFT, __pa(swapper_pg_dir) >> PAGE_SHIFT,
USER_PTRS_PER_PGD, KERNEL_PGD_BOUNDARY,
KERNEL_PGD_PTRS); KERNEL_PGD_PTRS);
} }
@ -201,7 +201,7 @@ static int pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd)
return 0; return 0;
} }
if (i >= USER_PTRS_PER_PGD) if (i >= KERNEL_PGD_BOUNDARY)
memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]), memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
sizeof(pmd_t) * PTRS_PER_PMD); sizeof(pmd_t) * PTRS_PER_PMD);

View file

@ -1,7 +1,6 @@
#ifndef _ASM_X86_PGTABLE_H #ifndef _ASM_X86_PGTABLE_H
#define _ASM_X86_PGTABLE_H #define _ASM_X86_PGTABLE_H
#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)
#define FIRST_USER_ADDRESS 0 #define FIRST_USER_ADDRESS 0
#define _PAGE_BIT_PRESENT 0 /* is present */ #define _PAGE_BIT_PRESENT 0 /* is present */
@ -330,6 +329,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
# include "pgtable_64.h" # include "pgtable_64.h"
#endif #endif
#define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
#define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
enum { enum {

View file

@ -48,9 +48,6 @@ void paging_init(void);
#define PGDIR_SIZE (1UL << PGDIR_SHIFT) #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
#define PGDIR_MASK (~(PGDIR_SIZE - 1)) #define PGDIR_MASK (~(PGDIR_SIZE - 1))
#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
/* Just any arbitrary offset to the start of the vmalloc VM area: the /* Just any arbitrary offset to the start of the vmalloc VM area: the
* current 8MB value just means that there will be a 8MB "hole" after the * current 8MB value just means that there will be a 8MB "hole" after the
* physical memory until the kernel virtual memory starts. That means that * physical memory until the kernel virtual memory starts. That means that