linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ian Campbell <ijc@hellion.org.uk>, Andi Kleen <ak@suse.de>,
	Zach Amsden <zach@vmware.com>
Subject: [PATCH 22 of 31] x86: unify KERNEL_PGD_PTRS
Date: Mon, 17 Mar 2008 16:37:13 -0700	[thread overview]
Message-ID: <a75818f2d2cccec8e757.1205797033@localhost> (raw)
In-Reply-To: <patchbomb.1205797011@localhost>

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>
Cc: Ingo Molnar <mingo@elte.hu>

---
 arch/x86/kernel/reboot.c            |    4 ++--
 arch/x86/kernel/smpboot_32.c        |    4 ++--
 arch/x86/kernel/vmi_32.c            |    2 +-
 arch/x86/mach-voyager/voyager_smp.c |    4 ++--
 arch/x86/mm/init_32.c               |    2 +-
 arch/x86/mm/pgtable.c               |   12 ++++++------
 include/asm-x86/pgtable.h           |    4 +++-
 include/asm-x86/pgtable_32.h        |    3 ---
 8 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -8,6 +8,7 @@
 #include <asm/apic.h>
 #include <asm/desc.h>
 #include <asm/hpet.h>
+#include <asm/pgtable.h>
 #include <asm/reboot_fixups.h>
 #include <asm/reboot.h>
 
@@ -15,7 +16,6 @@
 # include <linux/dmi.h>
 # include <linux/ctype.h>
 # include <linux/mc146818rtc.h>
-# include <asm/pgtable.h>
 #else
 # include <asm/iommu.h>
 #endif
@@ -266,7 +266,7 @@
 	/* Remap the kernel at virtual address zero, as well as offset zero
 	   from the kernel segment.  This assumes the kernel segment starts at
 	   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);
 
 	/*
diff --git a/arch/x86/kernel/smpboot_32.c b/arch/x86/kernel/smpboot_32.c
--- a/arch/x86/kernel/smpboot_32.c
+++ b/arch/x86/kernel/smpboot_32.c
@@ -782,8 +782,8 @@
 	INIT_WORK(&info.task, do_warm_boot_cpu);
 
 	/* init low mem mapping */
-	clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
-			min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS));
+	clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
+			min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
 	flush_tlb_all();
 	schedule_work(&info.task);
 	wait_for_completion(&done);
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -320,7 +320,7 @@
 	 * pdes need to be zeroed.
 	 */
 	if (type & VMI_PAGE_CLONE)
-		limit = USER_PTRS_PER_PGD;
+		limit = KERNEL_PGD_BOUNDARY;
 	for (i = 0; i < limit; i++)
 		BUG_ON(ptr[i]);
 }
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -566,8 +566,8 @@
 		hijack_source.idt.Offset, stack_start.sp));
 
 	/* init lowmem identity mapping */
-	clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
-			min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS));
+	clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
+			min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
 	flush_tlb_all();
 
 	if (quad_boot) {
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -467,7 +467,7 @@
 	 * Note that "pgd_clear()" doesn't do it for
 	 * 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
 		set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
 #else
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -104,7 +104,7 @@
  * -- wli
  */
 #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)
 {
@@ -112,7 +112,7 @@
 	unsigned long flags;
 
 	/* 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);
 
@@ -121,12 +121,12 @@
 	   references from swapper_pg_dir. */
 	if (PAGETABLE_LEVELS == 2 ||
 	    (PAGETABLE_LEVELS == 3 && SHARED_KERNEL_PMD)) {
-		clone_pgd_range(pgd + USER_PTRS_PER_PGD,
-				swapper_pg_dir + USER_PTRS_PER_PGD,
+		clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY,
+				swapper_pg_dir + KERNEL_PGD_BOUNDARY,
 				KERNEL_PGD_PTRS);
 		paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT,
 					 __pa(swapper_pg_dir) >> PAGE_SHIFT,
-					 USER_PTRS_PER_PGD,
+					 KERNEL_PGD_BOUNDARY,
 					 KERNEL_PGD_PTRS);
 	}
 
@@ -201,7 +201,7 @@
 			return 0;
 		}
 
-		if (i >= USER_PTRS_PER_PGD)
+		if (i >= KERNEL_PGD_BOUNDARY)
 			memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
 			       sizeof(pmd_t) * PTRS_PER_PMD);
 
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -1,7 +1,6 @@
 #ifndef _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 _PAGE_BIT_PRESENT	0
@@ -240,6 +239,9 @@
 # include "pgtable_64.h"
 #endif
 
+#define KERNEL_PGD_BOUNDARY	pgd_index(PAGE_OFFSET)
+#define KERNEL_PGD_PTRS		(PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
+
 #ifndef __ASSEMBLY__
 
 enum {
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -47,9 +47,6 @@
 
 #define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
 #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
  * current 8MB value just means that there will be a 8MB "hole" after the



  parent reply	other threads:[~2008-03-18  5:25 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 23:36 [PATCH 00 of 31] x86: unification and xen updates Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 01 of 31] xen: fix RMW when unmasking events Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 02 of 31] xen: fix UP setup of shared_info Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 03 of 31] x86: convert pgalloc_64.h from macros to inlines Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 04 of 31] x86: add common mm/pgtable.c Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 05 of 31] x86: put paravirt stubs into common asm/pgalloc.h Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 06 of 31] x86: move pte functions " Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 07 of 31] x86: move pmd " Jeremy Fitzhardinge
2008-03-17 23:36 ` [PATCH 08 of 31] x86: move pgalloc pud and pgd operations into common place Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 09 of 31] x86: move all the pgd_list handling to one place Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 10 of 31] x86: rename paravirt_alloc_pt etc after the pagetable structure Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 11 of 31] x86: add pud_alloc for 4-level pagetables Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 12 of 31] x86/pgtable.h: demacro ptep_set_access_flags Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 13 of 31] x86/pgtable.h: demacro ptep_test_and_clear_young Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 14 of 31] x86/pgtable.h: demacro ptep_clear_flush_young Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 15 of 31] x86: demacro pgalloc paravirt stubs Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 16 of 31] xen: use appropriate pte types Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 17 of 31] xen: make use of pte_t union Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 18 of 31] xen: unify pte operations Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 19 of 31] xen: use phys_addr_t when referring to physical addresses Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 20 of 31] xen: unify pte operations on machine frames Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 21 of 31] xen: make sure iret faults are trapped Jeremy Fitzhardinge
2008-03-17 23:37 ` Jeremy Fitzhardinge [this message]
2008-03-17 23:37 ` [PATCH 23 of 31] x86: unify pgd ctor/dtor Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 24 of 31] xen: add support for callbackops hypercall Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 25 of 31] x86: only enable interrupts when kernel state has been set up Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 26 of 31] xen: support sysenter/sysexit if hypervisor does Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 27 of 31] xen: implement a debug-interrupt handler Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 28 of 31] xen: make sure retriggered events are set pending Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 29 of 31] xen: short-cut for recursive event handling Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 30 of 31] xen: no need for domU to worry about MCE/MCA Jeremy Fitzhardinge
2008-03-17 23:37 ` [PATCH 31 of 31] xen: jump to iret fixup Jeremy Fitzhardinge
2008-03-18 21:33 ` [PATCH 00 of 31] x86: unification and xen updates Zachary Amsden
2008-03-18 21:37   ` Jeremy Fitzhardinge
2008-03-19  9:22 ` Ian Campbell
2008-03-19 15:11   ` Jeremy Fitzhardinge
2008-03-19 16:50     ` Ian Campbell
2008-03-19 18:45       ` Jeremy Fitzhardinge
2008-03-19 19:07     ` Ingo Molnar
2008-03-19 19:19       ` Jeremy Fitzhardinge
2008-03-19 19:05 ` Ingo Molnar
2008-03-19 19:46   ` Ingo Molnar
2008-03-19 20:02     ` Jeremy Fitzhardinge
2008-03-19 20:09       ` Ingo Molnar
2008-03-19 21:12         ` Jeremy Fitzhardinge
2008-03-19 21:33         ` Ingo Molnar
2008-03-19 21:54           ` Jeremy Fitzhardinge
2008-03-19 22:00             ` Ingo Molnar
2008-03-19 21:58               ` Jeremy Fitzhardinge
2008-03-19 22:04                 ` Ingo Molnar
2008-03-19 22:15                   ` Jeremy Fitzhardinge
2008-03-19 23:52                     ` Ingo Molnar
2008-03-20 20:24                       ` Jeremy Fitzhardinge
2008-03-21 13:17                         ` Ingo Molnar
2008-03-21 14:35                           ` Ingo Molnar
2008-03-21 15:15                             ` Jeremy Fitzhardinge
2008-03-21 15:25                               ` Ingo Molnar
2008-03-22  2:34                                 ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a75818f2d2cccec8e757.1205797033@localhost \
    --to=jeremy@goop.org \
    --cc=ak@suse.de \
    --cc=ijc@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=zach@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).