I have a task created by xTaskCreateStatic() with mpu wrapper version 1 used.
And this task is running in unprivileged mode as far as I know. I checked it by using portIS_PRIVILEGED().
Inside this task, I could not access registers like Systick or NVIC and need to use portRAISE_PRIVILEGE() to access them, which I could understand.
However, I found it could access xPortIsInsideInterrupt() which reads from IPSR without the need to raise privilege for my task.
I am kind of confused as I thought all special registers from CPU CORE including IPSR could not be accessed(even read) from an unprivileged task.
When the processor is executing an exception handler, holds the exception number of the exception being processed. Otherwise, the IPSR value is zero.
The processor writes to the IPSR on exception entry and exit. Software can use an MRS instruction, to read the IPSR,
but the processor ignores writes to the IPSR by an MSR instruction. The IPSR Exception Number field is defined as
follows:
• In Thread mode, the value is 0.
• In Handler mode, holds the exception number of the currently-executing exception.
An exception number indicates the currently executing exception and its entry vector.
Also, read of IPSR in unprivileged mode returns zero.
If unprivileged code attempts to read any stack pointer, the priority masks, or the IPSR, the read returns zero.