Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Mar 2007 20:52:28 GMT
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 116002 for review
Message-ID:  <200703162052.l2GKqS9E017466@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116002

Change 116002 by gonzo@gonzo_jeeves on 2007/03/16 20:51:48

	o Clearly define places where to enable interrupts and where not to:
	    - Interrupts must not be enabled in cpu_throw, so we does not
	        set IE bit in status register in PCB. That's because we have
		sched_lock aquired right before fork_exit - so no interrupts.
	    - Interrupts must be enabled on sched_lock unlocking in 
	        spinlock_exit routine. So we set IE bit and unmask IRQ5(timer)
		in md_saved_sr field.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips/vm_machdep.c#13 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips/vm_machdep.c#13 (text+ko) ====

@@ -100,6 +100,13 @@
        	 */
 	td2->td_pcb->pcb_regs[PCB_REG_SP] = sp;
 
+	/*
+	 * DO NOT ENABLE ANY INTERRUPTS HERE: 
+	 *	after cpu_throw we're supposed to be with sched_lock locked
+	 *	and this means - no interrupts enabled.
+	 */	 
+	td2->td_pcb->pcb_regs[PCB_REG_SR] = 0;
+
 	/* 
 	 * Return values for fork syscall for child:
 	 *     v0 == 0 -> actual return value
@@ -110,9 +117,13 @@
 	td2->td_frame->tf_regs[TF_V1] = 1;
 	td2->td_frame->tf_regs[TF_A3] = 0;
 
-	/* Setup to release sched_lock in fork_exit(). */
+	/* 
+	 * Setup to release sched_lock in fork_exit(). By unlocking
+	 * sched_lock we'll enable interrupts and unmask timer 
+	 * interrupt (HW IRQ5)
+	 */
 	td2->td_md.md_spinlock_count = 1;
-	td2->td_md.md_saved_sr = td2->td_pcb->pcb_regs[PCB_REG_SR];
+	td2->td_md.md_saved_sr = MIPS_SR_INT_IE | (((1 << 5) << 8) << 2);
 
 	/*
  	 * Now cpu_switch() can schedule the new process.
@@ -215,11 +226,6 @@
 			    + (KSTACK_PAGES - 1) * PAGE_SIZE) - 1;
 	td->td_frame = (struct trapframe *)td->td_pcb - 1;
 
-	/*
-	 * 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. Should be double-word aligned due to EABI */
 	td->td_pcb->pcb_regs[PCB_REG_SP] = 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703162052.l2GKqS9E017466>