jk@plx.UUCP (jk) (06/14/84)
I am interested in hearing about solutions others have used for instruction restarts on 68000's. My current "challange" is the Bourne shell and the way it catches SIGSEGV's and sbrk()'s to grow its data space. We currently have code in our kernel that tries to match the saved instruction register with some number of instructions before the (bogus) saved pc. This works in most cases, like automatic stack extension. It fails miserably if it finds the right opcode but it is not the correct instruction or it is not the opcode field of an instruction. In the case of the sh this is disaterous as the sh blindly sbrk()'s more space, returns from the signal catching code to re-execute the wrong instruction again, sbrk()'s for more space.....boom, boom out go the lights. Has anyone got a good solution for this problem? Thanks in advance, (no cute signoff yet) jk ..!decvax!sun!plx!jk
wes@felix.UUCP (Wes Chalfant) (06/28/84)
> I am interested in hearing about solutions others have used for > instruction restarts on 68000's. My current "challange" is the > Bourne shell and the way it catches SIGSEGV's and sbrk()'s to > grow its data space. We ran into the same problem with the Bourne shell here. We are running on a 68010 rather than a 68000, but our version of UNIX does not yet support the type of segmentation violation signal handler that the Bourne shell requires. I am not even convinced that we want to support such a functionality, since the 68010 does not restart instructions (like the VAX), but instead saves the internal processor state on a bus error and then retries the failing bus cycle on return from exception. In order for this to work on a 68010, the processor state information would have to be saved somewhere, the user code re-entered in the bus error handler, the kernel re-entered after the bus error handler, and then the processor state restored (doable, but a bit of a mess). We found it easier to just fix the Bourne shell. It takes two lines in blok.c: *** blok.c.orig Wed Jun 27 17:03:04 1984 --- blok.c Mon Jun 18 10:18:33 1984 *************** *** 66,71 reqd += brkincr; reqd &= ~(brkincr-1); blokp=bloktop; bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd); bloktop->word=BLK(ADR(end)+1); BEGIN REG STKPTR stakadr=STK(bloktop+2); --- 66,81 ----- reqd += brkincr; reqd &= ~(brkincr-1); blokp=bloktop; bloktop=bloktop->word=BLK(Rcheat(bloktop)+reqd); + #ifndef notdef /* don't you just love double negatives? */ + /* at this point, bloktop may be beyond the break. I haven't been + * able to make the 68010 allow you to continue from a user bus + * trap after executing a signal handler that fixes up the bus + * trap, so we'll simply do a more intelligent thing and test + * the bloody thing before we use it. -- wes + */ + if (&bloktop->word >= brkend) + fault(MEMF); + #endif bloktop->word=BLK(ADR(end)+1); BEGIN REG STKPTR stakadr=STK(bloktop+2); ****** As we generally use the Bourne shell very little, we haven't tested this extensively, but this does fix our known cases of the shell failing. Wes Chalfant FileNet Corporation {ucbvax,decvax}!trwrb!felix!wes