Consider when an exception is thrown from user mode:
The exception handler will save all registers, then mask out EXL and IE, then write the masked value back to $Status. Because the code was running in user mode, this will dump us back to user mode in the middle of the exception handler in KSEG0, which will throw a TLB exception immediately.
This PR is a simple change to mask out KSU as well. I validated that it works with my custom exception handler, and even puts me back into my original user mode code with KSU set properly.
Consider when an exception is thrown from user mode:
The exception handler will save all registers, then mask out EXL and IE, then write the masked value back to $Status. Because the code was running in user mode, this will dump us back to user mode in the middle of the exception handler in KSEG0, which will throw a TLB exception immediately.
This PR is a simple change to mask out KSU as well. I validated that it works with my custom exception handler, and even puts me back into my original user mode code with KSU set properly.