diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index fab3111..a440af8 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1797,6 +1797,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) /* setup proc 0's pcb */ thread0.td_pcb->pcb_flags = 0; thread0.td_pcb->pcb_cr3 = KPML4phys; + thread0.td_pcb->pcb_signature = PCB_SIGNATURE; thread0.td_frame = &proc0_tf; env = getenv("kernelname"); diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index f7c0d2d..3f91156 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1405,6 +1405,28 @@ void pmap_qremove(vm_offset_t sva, int count) { vm_offset_t va; + struct pcb *pcb; + int i; + + for (i = 1; i <= count; i++) { + pcb = (struct pcb *)(sva + i * PAGE_SIZE - sizeof(struct pcb)); + if (pcb->pcb_signature == PCB_SIGNATURE) + panic("pmap_qremove pcb"); + } + + va = sva; + while (count-- > 0) { + pmap_kremove(va); + va += PAGE_SIZE; + } + pmap_invalidate_range(kernel_pmap, sva, va); +} + +void pmap_qremove_stack(vm_offset_t sva, int count); +void +pmap_qremove_stack(vm_offset_t sva, int count) +{ + vm_offset_t va; va = sva; while (count-- > 0) { diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h index 1af8f6d..1ba529f 100644 --- a/sys/amd64/include/pcb.h +++ b/sys/amd64/include/pcb.h @@ -43,7 +43,9 @@ #include #include +#define PCB_SIGNATURE 0xdead10235201cafe struct pcb { + register_t pcb_signature; register_t pcb_r15; register_t pcb_r14; register_t pcb_r13; diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index c552cb7..10c8123 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -95,6 +95,8 @@ __FBSDID("$FreeBSD$"); #include #include +void pmap_qremove_stack(vm_offset_t sva, int count); + /* * System initialization * @@ -411,7 +413,7 @@ vm_thread_new(struct thread *td, int pages) atomic_add_int(&kstacks, 1); if (KSTACK_GUARD_PAGES != 0) { - pmap_qremove(ks, KSTACK_GUARD_PAGES); + pmap_qremove_stack(ks, KSTACK_GUARD_PAGES); ks += KSTACK_GUARD_PAGES * PAGE_SIZE; } td->td_kstack_obj = ksobj; @@ -447,7 +449,7 @@ vm_thread_stack_dispose(vm_object_t ksobj, vm_offset_t ks, int pages) int i; atomic_add_int(&kstacks, -1); - pmap_qremove(ks, pages); + pmap_qremove_stack(ks, pages); VM_OBJECT_LOCK(ksobj); for (i = 0; i < pages; i++) { m = vm_page_lookup(ksobj, i); @@ -536,7 +538,7 @@ vm_thread_swapout(struct thread *td) cpu_thread_swapout(td); pages = td->td_kstack_pages; ksobj = td->td_kstack_obj; - pmap_qremove(td->td_kstack, pages); + pmap_qremove_stack(td->td_kstack, pages); VM_OBJECT_LOCK(ksobj); for (i = 0; i < pages; i++) { m = vm_page_lookup(ksobj, i);