diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c index 94cf81b74fe..082388591b5 100644 --- a/sys/alpha/alpha/pmap.c +++ b/sys/alpha/alpha/pmap.c @@ -1063,35 +1063,6 @@ pmap_dispose_thread(td) vm_object_deallocate(ksobj); } -/* - * Set up a variable sized alternate kstack. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - /* * Allow the kernel stack for a thread to be prejudicially paged out. */ diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index d3cdb59f893..38a5f5b3658 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -996,36 +996,6 @@ pmap_dispose_thread(td) vm_object_deallocate(ksobj); } -/* - * Set up a variable sized alternate kstack. Though it may look MI, it may - * need to be different on certain arches like ia64. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - /* * Allow the Kernel stack for a thread to be prejudicially paged out. */ diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index c9135707753..c9a910ea67a 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1099,36 +1099,6 @@ pmap_dispose_thread(td) vm_object_deallocate(ksobj); } -/* - * Set up a variable sized alternate kstack. Though it may look MI, it may - * need to be different on certain arches like ia64. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(td) - struct thread *td; -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - /* * Allow the Kernel stack for a thread to be prejudicially paged out. */ diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 2e9d472d9ed..dd6ba1df2f7 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -796,32 +796,6 @@ pmap_dispose_thread(struct thread *td) td->td_kstack_pages = 0; } -/* - * Set up a variable sized alternate kstack. This appears to be MI. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - - td->td_altkstack = td->td_kstack; - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack_pages = td->td_kstack_pages; - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - - pmap_dispose_thread(td); - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - /* * Allow the KSTACK for a thread to be prejudicially paged out. */ diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index e9e38ab3025..4c514dfadc7 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -460,7 +460,7 @@ again: /* Allocate and switch to an alternate kstack if specified */ if (pages != 0) - pmap_new_altkstack(td2, pages); + vm_thread_new_altkstack(td2, pages); PROC_LOCK(p2); PROC_LOCK(p1); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 548f0976fce..c798b682815 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -168,7 +168,7 @@ proc_dtor(void *mem, int size, void *arg) * freed, so you gotta do this here. */ if (((p->p_flag & P_KTHREAD) != 0) && (td->td_altkstack != 0)) - pmap_dispose_altkstack(td); + vm_thread_dispose_altkstack(td); /* * We want to make sure we know the initial linkages. diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index 00528814ac5..4808b4ddd8d 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -1652,31 +1652,6 @@ pmap_dispose_thread(struct thread *td) vm_object_deallocate(ksobj); } -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - void pmap_swapin_thread(struct thread *td) { diff --git a/sys/powerpc/powerpc/mmu_oea.c b/sys/powerpc/powerpc/mmu_oea.c index 00528814ac5..4808b4ddd8d 100644 --- a/sys/powerpc/powerpc/mmu_oea.c +++ b/sys/powerpc/powerpc/mmu_oea.c @@ -1652,31 +1652,6 @@ pmap_dispose_thread(struct thread *td) vm_object_deallocate(ksobj); } -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - void pmap_swapin_thread(struct thread *td) { diff --git a/sys/powerpc/powerpc/pmap.c b/sys/powerpc/powerpc/pmap.c index 00528814ac5..4808b4ddd8d 100644 --- a/sys/powerpc/powerpc/pmap.c +++ b/sys/powerpc/powerpc/pmap.c @@ -1652,31 +1652,6 @@ pmap_dispose_thread(struct thread *td) vm_object_deallocate(ksobj); } -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - void pmap_swapin_thread(struct thread *td) { diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index c58d4b4c6da..4e308591107 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -1030,34 +1030,6 @@ pmap_dispose_thread(struct thread *td) vm_object_deallocate(ksobj); } -/* - * Set up a variable sized alternate kstack. - */ -void -pmap_new_altkstack(struct thread *td, int pages) -{ - /* shuffle the original stack */ - td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = td->td_kstack; - td->td_altkstack_pages = td->td_kstack_pages; - - pmap_new_thread(td, pages); -} - -void -pmap_dispose_altkstack(struct thread *td) -{ - pmap_dispose_thread(td); - - /* restore the original kstack */ - td->td_kstack = td->td_altkstack; - td->td_kstack_obj = td->td_altkstack_obj; - td->td_kstack_pages = td->td_altkstack_pages; - td->td_altkstack = 0; - td->td_altkstack_obj = NULL; - td->td_altkstack_pages = 0; -} - /* * Allow the kernel stack for a thread to be prejudicially paged out. */ diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h index 1a1e232059f..36ca187387f 100644 --- a/sys/vm/pmap.h +++ b/sys/vm/pmap.h @@ -131,8 +131,6 @@ void pmap_prefault(pmap_t, vm_offset_t, vm_map_entry_t); int pmap_mincore(pmap_t pmap, vm_offset_t addr); void pmap_new_thread(struct thread *td, int pages); void pmap_dispose_thread(struct thread *td); -void pmap_new_altkstack(struct thread *td, int pages); -void pmap_dispose_altkstack(struct thread *td); void pmap_swapout_thread(struct thread *td); void pmap_swapin_thread(struct thread *td); void pmap_activate(struct thread *td); diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index eafc30075e8..4718effac50 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -96,5 +96,7 @@ void vm_object_print(/* db_expr_t */ long, boolean_t, /* db_expr_t */ long, int vm_fault_quick(caddr_t v, int prot); void vm_proc_new(struct proc *p); void vm_proc_dispose(struct proc *p); +void vm_thread_new_altkstack(struct thread *td, int pages); +void vm_thread_dispose_altkstack(struct thread *td); #endif /* _KERNEL */ #endif /* !_VM_EXTERN_H_ */ diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index ec15d968cd0..2145c0c2f72 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -387,6 +387,37 @@ retry: } #endif +/* + * Set up a variable-sized alternate kstack. + */ +void +vm_thread_new_altkstack(struct thread *td, int pages) +{ + + td->td_altkstack = td->td_kstack; + td->td_altkstack_obj = td->td_kstack_obj; + td->td_altkstack_pages = td->td_kstack_pages; + + pmap_new_thread(td, pages); +} + +/* + * Restore the original kstack. + */ +void +vm_thread_dispose_altkstack(struct thread *td) +{ + + pmap_dispose_thread(td); + + td->td_kstack = td->td_altkstack; + td->td_kstack_obj = td->td_altkstack_obj; + td->td_kstack_pages = td->td_altkstack_pages; + td->td_altkstack = 0; + td->td_altkstack_obj = NULL; + td->td_altkstack_pages = 0; +} + /* * Implement fork's actions on an address space. * Here we arrange for the address space to be copied or referenced,