mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86 mm init cleanup
@ 2000-11-18 16:22 Brian Gerst
  2000-11-18 16:29 ` Tigran Aivazian
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Gerst @ 2000-11-18 16:22 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Patch against test11.  This patch moves the setting of %cr4 out of the
loops and makes the code a bit more readable.  Tested with standard
pagetables, PSE, and PAE.

-- 

						Brian Gerst

[-- Attachment #2: mminit.diff --]
[-- Type: text/plain, Size: 2223 bytes --]

diff -urN linux-2.4.0t11p5/arch/i386/mm/init.c linux/arch/i386/mm/init.c
--- linux-2.4.0t11p5/arch/i386/mm/init.c	Mon Oct 23 17:42:33 2000
+++ linux/arch/i386/mm/init.c	Thu Nov 16 20:55:20 2000
@@ -315,7 +315,7 @@
 
 static void __init pagetable_init (void)
 {
-	unsigned long vaddr, end;
+	unsigned long vaddr, end, __pe;
 	pgd_t *pgd, *pgd_base;
 	int i, j, k;
 	pmd_t *pmd;
@@ -334,11 +334,23 @@
 		__pgd_clear(pgd);
 	}
 #endif
-	i = __pgd_offset(PAGE_OFFSET);
+
+	__pe = _KERNPG_TABLE;
+	if (cpu_has_pse) {
+		set_in_cr4(X86_CR4_PSE);
+		__pe += _PAGE_PSE;
+		boot_cpu_data.wp_works_ok = 1;
+		if (cpu_has_pge) {
+			set_in_cr4(X86_CR4_PGE);
+			__pe += _PAGE_GLOBAL;
+		}
+	}
+
+	vaddr = PAGE_OFFSET;
+	i = __pgd_offset(vaddr);
 	pgd = pgd_base + i;
 
 	for (; i < PTRS_PER_PGD; pgd++, i++) {
-		vaddr = i*PGDIR_SIZE;
 		if (end && (vaddr >= end))
 			break;
 #if CONFIG_X86_PAE
@@ -350,35 +362,24 @@
 		if (pmd != pmd_offset(pgd, 0))
 			BUG();
 		for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
-			vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
 			if (end && (vaddr >= end))
 				break;
 			if (cpu_has_pse) {
-				unsigned long __pe;
-
-				set_in_cr4(X86_CR4_PSE);
-				boot_cpu_data.wp_works_ok = 1;
-				__pe = _KERNPG_TABLE + _PAGE_PSE + __pa(vaddr);
-				/* Make it "global" too if supported */
-				if (cpu_has_pge) {
-					set_in_cr4(X86_CR4_PGE);
-					__pe += _PAGE_GLOBAL;
+				set_pmd(pmd, __pmd(__pe + __pa(vaddr)));
+				vaddr += PMD_SIZE;
+			} else {
+				pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+				set_pmd(pmd, __pmd(__pe + __pa(pte)));
+
+				if (pte != pte_offset(pmd, 0))
+					BUG();
+
+				for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
+					if (end && (vaddr >= end))
+						break;
+					*pte = mk_pte_phys(__pa(vaddr), PAGE_KERNEL);
+					vaddr += PAGE_SIZE;
 				}
-				set_pmd(pmd, __pmd(__pe));
-				continue;
-			}
-
-			pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
-			set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte)));
-
-			if (pte != pte_offset(pmd, 0))
-				BUG();
-
-			for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
-				vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
-				if (end && (vaddr >= end))
-					break;
-				*pte = mk_pte_phys(__pa(vaddr), PAGE_KERNEL);
 			}
 		}
 	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86 mm init cleanup
  2000-11-18 16:22 [PATCH] x86 mm init cleanup Brian Gerst
@ 2000-11-18 16:29 ` Tigran Aivazian
  2000-11-18 16:39   ` Brian Gerst
  0 siblings, 1 reply; 3+ messages in thread
From: Tigran Aivazian @ 2000-11-18 16:29 UTC (permalink / raw)
  To: Brian Gerst; +Cc: Linus Torvalds, Linux kernel mailing list

On Sat, 18 Nov 2000, Brian Gerst wrote:

> Patch against test11.  This patch moves the setting of %cr4 out of the
> loops and makes the code a bit more readable.  Tested with standard
> pagetables, PSE, and PAE.
> 
> 

Brian,

while you were there, so close to paging_init() why not also correct the
wrong comment at the top of the function? It talks about 0-4M pagetables
whereas we really setup (see head.S) 0-8M.

Regards,
Tigran

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86 mm init cleanup
  2000-11-18 16:29 ` Tigran Aivazian
@ 2000-11-18 16:39   ` Brian Gerst
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Gerst @ 2000-11-18 16:39 UTC (permalink / raw)
  To: Tigran Aivazian; +Cc: Linus Torvalds, Linux kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]

Tigran Aivazian wrote:
> 
> On Sat, 18 Nov 2000, Brian Gerst wrote:
> 
> > Patch against test11.  This patch moves the setting of %cr4 out of the
> > loops and makes the code a bit more readable.  Tested with standard
> > pagetables, PSE, and PAE.
> >
> >
> 
> Brian,
> 
> while you were there, so close to paging_init() why not also correct the
> wrong comment at the top of the function? It talks about 0-4M pagetables
> whereas we really setup (see head.S) 0-8M.
> 
> Regards,
> Tigran

Add this little patch then

-- 

						Brian Gerst

[-- Attachment #2: mminit2.diff --]
[-- Type: text/plain, Size: 472 bytes --]

diff -urN linux-2.4.0t11p7/arch/i386/mm/init.c linux/arch/i386/mm/init.c
--- linux-2.4.0t11p7/arch/i386/mm/init.c	Mon Oct 23 17:42:33 2000
+++ linux/arch/i386/mm/init.c	Sat Nov 18 11:38:02 2000
@@ -437,7 +437,7 @@
 }
 
 /*
- * paging_init() sets up the page tables - note that the first 4MB are
+ * paging_init() sets up the page tables - note that the first 8MB are
  * already mapped by head.S.
  *
  * This routines also unmaps the page at virtual kernel address 0, so

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-11-18 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-18 16:22 [PATCH] x86 mm init cleanup Brian Gerst
2000-11-18 16:29 ` Tigran Aivazian
2000-11-18 16:39   ` Brian Gerst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®