From owner-p4-projects@FreeBSD.ORG Tue Apr 15 19:20:06 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3ED6737B404; Tue, 15 Apr 2003 19:20:06 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D27BC37B401 for ; Tue, 15 Apr 2003 19:20:05 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 661C743FBF for ; Tue, 15 Apr 2003 19:20:05 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h3G2K50U080503 for ; Tue, 15 Apr 2003 19:20:05 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3G2K4xk080500 for perforce@freebsd.org; Tue, 15 Apr 2003 19:20:04 -0700 (PDT) Date: Tue, 15 Apr 2003 19:20:04 -0700 (PDT) Message-Id: <200304160220.h3G2K4xk080500@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 29038 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Apr 2003 02:20:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=29038 Change 29038 by marcel@marcel_nfs on 2003/04/15 19:19:30 Stop using contigmalloc() for allocating thread stacks. Use malloc() instead. Cursory testing didn't cause nested TLB faults yet, so it isn't immediately breaking anything. Once we have the syscall path worked out more, we should be able to cause a nested TLB fault. This will be used to write the exception handling code and see if we can make it work at all... Affected files ... .. //depot/projects/ia64_epc/sys/ia64/ia64/mp_machdep.c#5 edit .. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#4 edit .. //depot/projects/ia64_epc/sys/ia64/include/proc.h#2 edit Differences ... ==== //depot/projects/ia64_epc/sys/ia64/ia64/mp_machdep.c#5 (text+ko) ==== @@ -214,22 +214,8 @@ pc->pc_current_pmap = kernel_pmap; pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask; if (pc->pc_cpuid > 0) { - void *ks; - - /* - * Use contigmalloc for stack so that we can - * use a region 7 address for it which makes - * it impossible to accidentally lose when - * recording a trapframe. - */ - ks = contigmalloc(KSTACK_PAGES * PAGE_SIZE, M_TEMP, - M_WAITOK, - 0ul, - 256*1024*1024 - 1, - PAGE_SIZE, - 256*1024*1024); - - ap_stack = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)ks)); + ap_stack = malloc(KSTACK_PAGES * PAGE_SIZE, M_PMAP, + M_WAITOK); ap_pcpu = pc; ap_delay = 2000; ap_awake = 0; ==== //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#4 (text+ko) ==== @@ -127,6 +127,10 @@ MALLOC_DEFINE(M_PMAP, "PMAP", "PMAP Structures"); +#ifndef KSTACK_MAX_PAGES +#define KSTACK_MAX_PAGES 32 +#endif + #ifndef PMAP_SHPGPERPROC #define PMAP_SHPGPERPROC 200 #endif @@ -727,10 +731,6 @@ return 0; } -#ifndef KSTACK_MAX_PAGES -#define KSTACK_MAX_PAGES 32 -#endif - /* * Create the KSTACK for a new thread. * This routine directly affects the fork perf for a process/thread. @@ -738,27 +738,14 @@ void pmap_new_thread(struct thread *td, int pages) { - vm_offset_t *ks; /* Bounds check */ if (pages <= 1) pages = KSTACK_PAGES; else if (pages > KSTACK_MAX_PAGES) pages = KSTACK_MAX_PAGES; - - /* - * Use contigmalloc for user area so that we can use a region - * 7 address for it which makes it impossible to accidentally - * lose when recording a trapframe. - */ - ks = contigmalloc(pages * PAGE_SIZE, M_PMAP, M_WAITOK, 0ul, - 256*1024*1024 - 1, PAGE_SIZE, 256*1024*1024); - if (ks == NULL) - panic("pmap_new_thread: could not contigmalloc %d pages\n", - pages); - - td->td_md.md_kstackvirt = ks; - td->td_kstack = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)ks)); + td->td_kstack = (vm_offset_t)malloc(pages * PAGE_SIZE, M_PMAP, + M_WAITOK); td->td_kstack_pages = pages; } @@ -769,12 +756,10 @@ void pmap_dispose_thread(struct thread *td) { - int pages; - pages = td->td_kstack_pages; - contigfree(td->td_md.md_kstackvirt, pages * PAGE_SIZE, M_PMAP); - td->td_md.md_kstackvirt = NULL; + free((void*)td->td_kstack, M_PMAP); td->td_kstack = 0; + td->td_kstack_pages = 0; } /* @@ -784,16 +769,9 @@ pmap_new_altkstack(struct thread *td, int pages) { - /* - * Shuffle the original stack. Save the virtual kstack address - * instead of the physical address because 1) we can derive the - * physical address from the virtual address and 2) we need the - * virtual address in pmap_dispose_thread. - */ + td->td_altkstack = td->td_kstack; td->td_altkstack_obj = td->td_kstack_obj; - td->td_altkstack = (vm_offset_t)td->td_md.md_kstackvirt; td->td_altkstack_pages = td->td_kstack_pages; - pmap_new_thread(td, pages); } @@ -802,13 +780,7 @@ { pmap_dispose_thread(td); - - /* - * Restore the original kstack. Note that td_altkstack holds the - * virtual kstack address of the previous kstack. - */ - td->td_md.md_kstackvirt = (void*)td->td_altkstack; - td->td_kstack = IA64_PHYS_TO_RR7(ia64_tpa(td->td_altkstack)); + 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; ==== //depot/projects/ia64_epc/sys/ia64/include/proc.h#2 (text+ko) ==== @@ -37,7 +37,6 @@ struct mdthread { u_long md_flags; - void *md_kstackvirt; /* virtual address of td_kstack */ vm_offset_t md_bspstore; /* initial ar.bspstore */ register_t md_savecrit; }; @@ -50,7 +49,7 @@ #define MDP_UAC_MASK (MDP_UAC_NOPRINT | MDP_UAC_NOFIX | MDP_UAC_SIGBUS) struct mdproc { - struct user *md_uservirt; /* virtual address of p_addr */ + int __dummy; /* Avoid having an empty struct. */ }; #endif /* !_MACHINE_PROC_H_ */