From owner-p4-projects@FreeBSD.ORG Sat Aug 5 17:07:02 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1B7D216A4E1; Sat, 5 Aug 2006 17:07:02 +0000 (UTC) X-Original-To: perforce@FreeBSD.org 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 D479D16A4E0 for ; Sat, 5 Aug 2006 17:07:01 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8833643D45 for ; Sat, 5 Aug 2006 17:07:01 +0000 (GMT) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k75H71pu023498 for ; Sat, 5 Aug 2006 17:07:01 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k75H712Z023495 for perforce@freebsd.org; Sat, 5 Aug 2006 17:07:01 GMT (envelope-from gonzo@FreeBSD.org) Date: Sat, 5 Aug 2006 17:07:01 GMT Message-Id: <200608051707.k75H712Z023495@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 103258 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2006 17:07:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=103258 Change 103258 by gonzo@gonzo_hq on 2006/08/05 17:06:07 o Prevent td2 sp register from being overwritten by td1 one's during pcb copying. o Unmask IRQ5 (timer) in cpu_thread_setup. Otherwise we'll get hardclock switched off forever after cpu_throw. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips/vm_machdep.c#6 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips/vm_machdep.c#6 (text+ko) ==== @@ -67,10 +67,16 @@ cpu_fork(register struct thread *td, register struct proc *p2, struct thread *td2, int flags) { + register_t sp; + if ((flags & RFPROC) == 0) return; cpu_thread_setup(td2); + /* + * Preserve SP from beeing overwritten. + */ + sp = td2->td_pcb->pcb_regs[PCB_REG_SP]; /* Copy the pcb */ bcopy(td->td_pcb, td2->td_pcb, sizeof(struct pcb)); @@ -88,18 +94,24 @@ td2->td_pcb->pcb_regs[PCB_REG_S0] = (register_t)fork_return; td2->td_pcb->pcb_regs[PCB_REG_S1] = (register_t)td2; td2->td_pcb->pcb_regs[PCB_REG_S2] = (register_t)td2->td_frame; + /* + * Restore original stack. + */ + td2->td_pcb->pcb_regs[PCB_REG_SP] = sp; + + /* Setup to release sched_lock in fork_exit(). */ + td2->td_md.md_spinlock_count = 1; + td2->td_md.md_saved_sr = td2->td_pcb->pcb_regs[PCB_REG_SR]; /* * Now cpu_switch() can schedule the new process. */ - - /* Setup to release sched_lock in fork_exit(). */ - td2->td_md.md_spinlock_count = 1; } void cpu_switch(struct thread *old, struct thread *new) { + if (!savectx(old->td_pcb)) { pmap_deactivate(old); cpu_throw(old, new); @@ -171,7 +183,13 @@ td->td_pcb = (struct pcb *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; td->td_frame = (struct trapframe *)td->td_pcb - 1; - td->td_pcb->pcb_regs[PCB_REG_SR] = MIPS_SR_INT_IE; + + /* + * Enable interrupts and unmask timer interrupt (HW IRQ5) + */ + td->td_pcb->pcb_regs[PCB_REG_SR] = MIPS_SR_INT_IE | + (((1 << 5) << 8) << 2); + /* Stack pointer. */ td->td_pcb->pcb_regs[PCB_REG_SP] = (register_t)_ALIGN(td->td_frame - 1); }