Map the kernel text read-only if !DDB. Also, shorten many parts of the page

table startup by judicious application of lea.
This commit is contained in:
mycroft 1994-10-25 14:31:24 +00:00
parent 3f30686b83
commit 9f00060fdf
1 changed files with 58 additions and 39 deletions

View File

@ -37,7 +37,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * from: @(#)locore.s 7.3 (Berkeley) 5/13/91
* $Id: locore.s,v 1.85 1994/10/09 09:19:29 mycroft Exp $ * $Id: locore.s,v 1.86 1994/10/25 14:31:24 mycroft Exp $
*/ */
/* /*
@ -360,24 +360,25 @@ try586: /* Use the `cpuid' instruction. */
stosl stosl
/* Find end of kernel image. */ /* Find end of kernel image. */
movl $(_end-KERNBASE),%ecx movl $(_end-KERNBASE),%edi
#if defined(DDB) && !defined(SYMTAB_SPACE) #if defined(DDB) && !defined(SYMTAB_SPACE)
/* Save the symbols (if loaded). */ /* Save the symbols (if loaded). */
movl _esym-KERNBASE,%eax movl _esym-KERNBASE,%eax
testl %eax,%eax testl %eax,%eax
jz 1f jz 1f
movl %eax,%ecx subl $KERNBASE,%eax
subl $KERNBASE,%ecx movl %eax,%edi
1: 1:
#endif #endif
movl %ecx,%edi # edi = esym ?: end
addl $PGOFSET,%ecx # page align up /* Calculate where to start the bootstrap tables. */
andl $(~PGOFSET),%ecx movl %edi,%esi # edi = esym ?: end
movl %ecx,%esi # esi = start of tables addl $PGOFSET,%esi # page align up
subl %edi,%ecx andl $~PGOFSET,%esi
addl $((NKPDE+UPAGES+2)*NBPG),%ecx # size of tables
/* Clear memory for bootstrap tables. */ /* Clear memory for bootstrap tables. */
leal ((2+UPAGES+NKPDE)*NBPG)(%esi),%ecx # end of tables
subl %edi,%ecx # size of tables
shrl $2,%ecx shrl $2,%ecx
xorl %eax,%eax xorl %eax,%eax
cld cld
@ -401,53 +402,71 @@ try586: /* Use the `cpuid' instruction. */
/* /*
* Build initial page tables. * Build initial page tables.
*/ */
/* First, map the kernel text, data, and BSS. */ leal ((2+UPAGES)*NBPG)(%esi),%ebx # physical address of KPT in proc 0,
movl %esi,%ecx # this much memory, movl %ebx,_KPTphys-KERNBASE # in the kernel page table,
shrl $PGSHIFT,%ecx # for this many pte s
addl $(NKPDE+UPAGES+2),%ecx # including our early context /* XXX Map the first MB of memory read-write. */
movl $(PG_V|PG_KW),%eax # having these bits set, movl $(0+PG_V|PG_KW),%eax # having these bits set,
leal ((UPAGES+2)*NBPG)(%esi),%ebx # physical address of KPT in proc 0, movl $(KERNTEXTOFF-KERNBASE),%ecx
movl %ebx,_KPTphys-KERNBASE # in the kernel page table, shrl $PGSHIFT,%ecx
fillkpt
/* Calculate end of text segment, rounded to a page. */
leal (_etext-KERNBASE+PGOFSET),%edx
andl $~PGOFSET,%edx
/* Map the kernel text read-only. */
leal (KERNBASE-KERNTEXTOFF)(%edx),%ecx
shrl $PGSHIFT,%ecx
andl $PG_FRAME,%eax
#ifdef DDB
orl $(PG_V|PG_KW),%eax
#else
orl $(PG_V|PG_KR),%eax
#endif
fillkpt
/* Map the data, BSS, and bootstrap tables read-write. */
leal ((2+UPAGES+NKPDE)*NBPG)(%esi),%ecx # end of tables
subl %edx,%ecx # subtract end of text
shrl $PGSHIFT,%ecx
andl $PG_FRAME,%eax
orl $(PG_V|PG_KW),%eax
fillkpt fillkpt
/* Map ISA I/O memory. */ /* Map ISA I/O memory. */
movl $(IOM_SIZE>>PGSHIFT),%ecx # for this many pte s, movl $(IOM_SIZE>>PGSHIFT),%ecx # for this many pte s,
movl $(IOM_BEGIN|PG_V|PG_UW/*|PG_N*/),%eax # having these bits set movl $(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax # having these bits set
movl %ebx,_atdevphys-KERNBASE # remember phys addr of ptes movl %ebx,_atdevphys-KERNBASE # remember phys addr of ptes
fillkpt fillkpt
/* Map proc 0's kernel stack into user page table page. */ /* Map proc 0's kernel stack into user page table page. */
movl $UPAGES,%ecx # for this many pte s, movl $UPAGES,%ecx # for this many pte s,
leal (2*NBPG)(%esi),%eax # physical address in proc 0 leal (2*NBPG+KERNBASE)(%esi),%edx
leal (KERNBASE)(%eax),%edx movl %edx,_proc0paddr-KERNBASE # remember VA for 0th process init
movl %edx,_proc0paddr-KERNBASE # remember VA for 0th process init leal (2*NBPG+PG_V|PG_KW)(%esi),%eax # physical address in proc 0
orl $(PG_V|PG_KW),%eax # having these bits set, leal (2*NBPG-UPAGES*4)(%esi),%ebx # physical address of stack pt in proc 0
leal (1*NBPG)(%esi),%ebx # physical address of stack pt in proc 0
addl $((NPTEPD-UPAGES)*4),%ebx
fillkpt fillkpt
/* /*
* Construct a page table directory. * Construct a page table directory.
*/ */
/* Install a PDE for temporary double map of kernel text. */ /* Install a PDE for temporary double map of kernel text. */
movl _KPTphys-KERNBASE,%eax # physical address of kernel page tables leal ((2+UPAGES)*NBPG+PG_V|PG_KW)(%esi),%eax # pte for KPT in proc 0,
orl $(PG_V|PG_UW),%eax # pde entry is valid movl %eax,(%esi) # which is where temp maps!
movl %eax,(%esi) # which is where temp maps!
/* Map kernel PDEs. */ /* Map kernel PDEs. */
movl $NKPDE,%ecx # for this many pde s, movl $NKPDE,%ecx # for this many pde s,
leal (KPTDI*4)(%esi),%ebx # offset of pde for kernel leal (KPTDI*4)(%esi),%ebx # offset of pde for kernel
fillkpt fillkpt
/* Install a PDE recursively mapping page directory as a page table! */ /* Install a PDE recursively mapping page directory as a page table! */
movl %esi,%eax # phys address of ptd in proc 0 leal (0*NBPG+PG_V|PG_KW)(%esi),%eax # pte for ptd
orl $(PG_V|PG_UW),%eax # pde entry is valid movl %eax,(PTDPTDI*4)(%esi) # which is where PTmap maps!
movl %eax,(PTDPTDI*4)(%esi) # which is where PTmap maps!
/* Install a PDE to map kernel stack for proc 0. */ /* Install a PDE to map kernel stack for proc 0. */
leal (1*NBPG)(%esi),%eax # physical address of pt in proc 0 leal (1*NBPG+PG_V|PG_KW)(%esi),%eax # pte for pt in proc 0
orl $(PG_V|PG_KW),%eax # pde entry is valid movl %eax,(UPTDI*4)(%esi) # which is where kernel stack maps!
movl %eax,(UPTDI*4)(%esi) # which is where kernel stack maps!
#ifdef BDB #ifdef BDB
/* Copy and convert stuff from old GDT and IDT for debugger. */ /* Copy and convert stuff from old GDT and IDT for debugger. */