diff options
author | julian <julian@FreeBSD.org> | 2002-07-03 20:47:50 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2002-07-03 20:47:50 +0000 |
commit | 45b02b9551294d78d4788fe276832f3f61ab5028 (patch) | |
tree | 4bbed7197d45468c827166e9c931a77ee945a17b /sys/i386 | |
parent | 9925a6e0691b36505c6695c8ebbf51e056ccf7f7 (diff) | |
download | FreeBSD-src-45b02b9551294d78d4788fe276832f3f61ab5028.zip FreeBSD-src-45b02b9551294d78d4788fe276832f3f61ab5028.tar.gz |
Add comments and slightly rearrange the thread stack assignment code
to try make it less obscure.
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/pmap.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 68b94ba..146d463 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1012,23 +1012,29 @@ pmap_new_thread(struct thread *td) #ifdef KSTACK_GUARD /* get a kernel virtual address for the kstack for this thread */ - ks = kmem_alloc_nofault(kernel_map, - (KSTACK_PAGES + 1) * PAGE_SIZE); + ks = kmem_alloc_nofault(kernel_map, (KSTACK_PAGES + 1) * PAGE_SIZE); if (ks == 0) panic("pmap_new_thread: kstack allocation failed"); - ks += PAGE_SIZE; - td->td_kstack = ks; - ptek = vtopte(ks - PAGE_SIZE); + /* + * Set the first page to be the unmapped guard page. + */ + ptek = vtopte(ks); oldpte = *ptek; *ptek = 0; if (oldpte) { #ifdef I386_CPU updateneeded = 1; #else - invlpg(ks - PAGE_SIZE); + invlpg(ks); #endif } + + /* + * move to the next page, which is where the real stack starts. + */ + ks += PAGE_SIZE; + td->td_kstack = ks; ptek++; #else /* get a kernel virtual address for the kstack for this thread */ @@ -1038,6 +1044,10 @@ pmap_new_thread(struct thread *td) td->td_kstack = ks; ptek = vtopte(ks); #endif + /* + * For the length of the stack, link in a real page of ram for each + * page of stack. + */ for (i = 0; i < KSTACK_PAGES; i++) { /* * Get a kernel stack page @@ -1050,16 +1060,16 @@ pmap_new_thread(struct thread *td) m->wire_count++; cnt.v_wire_count++; - oldpte = *(ptek + i); /* * Enter the page into the kernel address space. */ - *(ptek + i) = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag; + oldpte = ptek[i]; + ptek[i] = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag; if (oldpte) { #ifdef I386_CPU updateneeded = 1; #else - invlpg(ks + i * PAGE_SIZE); + invlpg(ks + (i * PAGE_SIZE)); #endif } |