That code looks the same as that provided by Freescale that I'm using with gcc:
asm_set_ipl:
_asm_set_ipl:
link a6,#-8
movem.l d6-d7,(sp)
move.w sr,d7 /* current sr */
move.l d7,d0 /* prepare return value */
andi.l #0x0700,d0 /* mask out IPL */
lsr.l #8,d0 /* IPL */
... and so on ...
The Manual states:
3.3.4.5 Privilege Violation
The attempted execution of a supervisor mode instruction while in user mode generates a privilege
violation exception. See ColdFire Programmer’s Reference Manual for a list of supervisor-mode
instructions.
So it seems like the only way to get that error is to be in User mode and try to access something that isn't allowed.
The manual also warns:
The V2 ColdFire processor uses an imprecise reporting mechanism for access errors on operand writes.
Because the actual write cycle may be decoupled from the processor’s issuing of the operation, the
signaling of an access error appears to be decoupled from the instruction that generated the write.
Accordingly, the PC contained in the exception stack frame merely represents the location in the program
when the access error was signaled. All programming model updates associated with the write instruction
are completed. The NOP instruction can collect access errors for writes.
You may be triggering the error earlier somehow, and the "blame" might be delayed, so the one it says it as fault may not be. So I'd suggest putting lots of NOPs between all of the instructions in that function and see if the exception "blames" something else.
I would suggest you also manually decode the Exception Frame that it pushes on the stack, and if you need more help, provide both the RAW and decoded exception frames in any further posts.
Disassemble that function and see if the compiler did anything unexpected too.
Tom