Index: conf/ldscript.i386 =================================================================== RCS file: /home/ncvs/src/sys/conf/ldscript.i386,v retrieving revision 1.5 diff -u -u -r1.5 ldscript.i386 --- conf/ldscript.i386 18 Sep 2001 01:12:43 -0000 1.5 +++ conf/ldscript.i386 23 Aug 2002 02:59:40 -0000 @@ -6,7 +6,7 @@ SECTIONS { /* Read-only sections, merged into text segment: */ - . = kernbase + 0x00100000 + SIZEOF_HEADERS; + . = kernbase + kernload + SIZEOF_HEADERS; .interp : { *(.interp) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } Index: i386/i386/genassym.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/genassym.c,v retrieving revision 1.128 diff -u -u -r1.128 genassym.c --- i386/i386/genassym.c 12 Jul 2002 20:17:06 -0000 1.128 +++ i386/i386/genassym.c 23 Aug 2002 03:58:11 -0000 @@ -117,6 +117,7 @@ ASSYM(USRSTACK, USRSTACK); ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); ASSYM(KERNBASE, KERNBASE); +ASSYM(KERNLOAD, KERNLOAD); ASSYM(MCLBYTES, MCLBYTES); ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3)); ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi)); Index: i386/i386/locore.s =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/locore.s,v retrieving revision 1.158 diff -u -u -r1.158 locore.s --- i386/i386/locore.s 12 Jul 2002 07:56:08 -0000 1.158 +++ i386/i386/locore.s 23 Aug 2002 02:56:57 -0000 @@ -109,10 +109,12 @@ #endif /* SMP */ /* - * Compiled KERNBASE location + * Compiled KERNBASE location and the kernel load address */ .globl kernbase .set kernbase,KERNBASE + .globl kernload + .set kernload,KERNLOAD /* * Globals Index: i386/i386/machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v retrieving revision 1.525 diff -u -u -r1.525 machdep.c --- i386/i386/machdep.c 18 Jul 2002 00:42:53 -0000 1.525 +++ i386/i386/machdep.c 23 Aug 2002 04:26:12 -0000 @@ -1502,7 +1502,7 @@ /* * block out kernel memory as not available. */ - if (pa >= 0x100000 && pa < first) + if (pa >= KERNLOAD && pa < first) continue; page_bad = FALSE; Index: i386/i386/pmap.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/pmap.c,v retrieving revision 1.363 diff -u -u -r1.363 pmap.c --- i386/i386/pmap.c 21 Aug 2002 23:39:52 -0000 1.363 +++ i386/i386/pmap.c 23 Aug 2002 03:28:59 -0000 @@ -224,8 +224,6 @@ static vm_offset_t pmap_kmem_choose(vm_offset_t addr); static void *pmap_allocf(uma_zone_t zone, int bytes, u_int8_t *flags, int wait); -static pd_entry_t pdir4mb; - /* * Routine: pmap_pte * Function: @@ -365,43 +363,8 @@ for (i = 0; i < NKPT; i++) PTD[i] = 0; - pgeflag = 0; -#ifndef DISABLE_PG_G - if (cpu_feature & CPUID_PGE) - pgeflag = PG_G; -#endif - -/* - * Initialize the 4MB page size flag - */ - pseflag = 0; -/* - * The 4MB page version of the initial - * kernel page mapping. - */ - pdir4mb = 0; - -#ifndef DISABLE_PSE - if (cpu_feature & CPUID_PSE) { - pd_entry_t ptditmp; - /* - * Note that we have enabled PSE mode - */ - pseflag = PG_PS; - ptditmp = *(PTmap + i386_btop(KERNBASE)); - ptditmp &= ~(NBPDR - 1); - ptditmp |= PG_V | PG_RW | PG_PS | PG_U | pgeflag; - pdir4mb = ptditmp; - } -#endif -#ifndef SMP - /* - * Turn on PGE/PSE. SMP does this later on since the - * 4K page tables are required for AP boot (for now). - * XXX fixme. - */ + /* Check and turn on PGE/PSE. */ pmap_set_opt(); -#endif #ifdef SMP if (cpu_apic_address == 0) panic("pmap_bootstrap: no local apic! (non-SMP hardware?)"); @@ -423,32 +386,44 @@ pt_entry_t *pte; vm_offset_t va, endva; - if (pgeflag && (cpu_feature & CPUID_PGE)) { + pgeflag = 0; +#ifndef DISABLE_PG_G + if (cpu_feature & CPUID_PGE) { + pgeflag = PG_G; load_cr4(rcr4() | CR4_PGE); invltlb(); /* Insurance */ } +#endif + pseflag = 0; #ifndef DISABLE_PSE - if (pseflag && (cpu_feature & CPUID_PSE)) { + if (cpu_feature & CPUID_PSE) { + pseflag = PG_PS; load_cr4(rcr4() | CR4_PSE); invltlb(); /* Insurance */ } #endif if (PCPU_GET(cpuid) == 0) { #ifndef DISABLE_PSE - if (pdir4mb) { - kernel_pmap->pm_pdir[KPTDI] = PTD[KPTDI] = pdir4mb; - invltlb(); /* Insurance */ + if (pseflag) { + pd_entry_t *pte, ptditmp; + + /* Turn on the 4MB pages for the kernel text/data/bss */ + va = KERNBASE + KERNLOAD; + endva = KERNBASE + KERNend; + while (va < endva) { + pte = vtopte(va); + ptditmp = *pte; + ptditmp &= ~(NBPDR - 1); + ptditmp |= PG_V | PG_RW | PG_PS | pgeflag; + *pte = ptditmp; + invltlb(); /* Insurance */ + va += NBPDR; + } } #endif - if (pgeflag) { + if (pgeflag && !pseflag) { /* Turn on PG_G for text, data, bss pages. */ - va = (vm_offset_t)btext; -#ifndef DISABLE_PSE - if (pseflag && (cpu_feature & CPUID_PSE)) { - if (va < KERNBASE + (1 << PDRSHIFT)) - va = KERNBASE + (1 << PDRSHIFT); - } -#endif + va = KERNBASE + KERNLOAD; endva = KERNBASE + KERNend; while (va < endva) { pte = vtopte(va); @@ -1818,8 +1793,7 @@ va = i386_ptob(sindex); anyvalid++; - if (pmap_remove_pte(pmap, - ptbase + sindex, va)) + if (pmap_remove_pte(pmap, ptbase + sindex, va)) break; } } @@ -3277,7 +3251,6 @@ vm_size_t size; { vm_offset_t va, tmpva, offset; - pt_entry_t *pte; offset = pa & PAGE_MASK; size = roundup(offset + size, PAGE_SIZE); @@ -3290,8 +3263,7 @@ pa = pa & PG_FRAME; for (tmpva = va; size > 0; ) { - pte = vtopte(tmpva); - *pte = pa | PG_RW | PG_V | pgeflag; + pmap_kenter(tmpva, pa); size -= PAGE_SIZE; tmpva += PAGE_SIZE; pa += PAGE_SIZE; Index: i386/include/vmparam.h =================================================================== RCS file: /home/ncvs/src/sys/i386/include/vmparam.h,v retrieving revision 1.33 diff -u -u -r1.33 vmparam.h --- i386/include/vmparam.h 30 Mar 2000 07:17:01 -0000 1.33 +++ i386/include/vmparam.h 23 Aug 2002 02:59:11 -0000 @@ -84,6 +84,13 @@ /* + * Kernel physical load address. + */ +#ifndef KERNLOAD +#define KERNLOAD 0x400000 +#endif + +/* * Virtual addresses of things. Derived from the page directory and * page table indexes from pmap.h for precision. * Because of the page that is both a PD and PT, it looks a little