Subject: pmap_activate(), powerpc/powerpc/pmap.c
To: None <port-macppc@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-macppc
Date: 01/13/2001 10:29:03
In connection with the porting effort I mentioned a while ago, I had
some trouble which I eventually traced to pmap_activate(), in
powerpc/powerpc/pmap.c.  I find the following code sequence (compressed
by snipping comments and blank lines)

		__asm __volatile("mfsr %0,14" : "=r"(ksr) :);
		rpm = pcb->pcb_pmreal;
		for (i = 0; i < 16; i++) {
			seg = rpm->pm_sr[i];
			__asm __volatile("mtsrin %0,%1"
			    :: "r"(seg), "r"(i << ADDR_SR_SHFT));
		}
		__asm __volatile("mtsr 14,%0" :: "r"(ksr));

Detailed investigation indicated that when the loop reached 14 and did
the mtsrin for sr 14, the machine went out to lunch - it apparently
started trapping recursively through routines like pte_spill.

Changing it to

		rpm = pcb->pcb_pmreal;
		for (i = 0; i < 16; i++) if (i != 14) {
			seg = rpm->pm_sr[i];
			__asm __volatile("mtsrin %0,%1"
			    :: "r"(seg), "r"(i << ADDR_SR_SHFT));
		}

made the problems go away.  But I have to wonder why this wasn't done
in the first place, which makes me think I'm missing something.  Am I?
Or is this really equivalent and I can forget the issue?

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B