Privileged Instructions - 2024.2 English

MicroBlaze Processor Reference Guide (UG984)

Document ID
UG984
Release Date
2024-11-27
Version
2024.2 English

The following MicroBlaze instructions are privileged:

  • GET, GETD, PUT, PUTD (except when explicitly allowed)
  • WIC, WDC
  • MTS, MTSE
  • MSRCLR, MSRSET (except when only the C bit is affected)
  • BRK
  • RTID, RTBD, RTED
  • BRKI (except when jumping to physical address C_BASE_VECTORS + 0x8 or C_BASE_VECTORS + 0x18)
  • SLEEP, HIBERNATE, SUSPEND
  • LBUEA, LHUEA, LWEA, SBEA, SHEA, SWEA (except when explicitly allowed)

Attempted use of these instructions when running in user mode causes a privileged instruction exception. When setting the parameter C_MMU_PRIVILEGED_INSTR to 1 or 3, the instructions GET, GETD, PUT, and PUTD are not considered privileged, and can be executed when running in user mode.

CAUTION:
It is strongly discouraged to do this, unless absolutely necessary for performance reasons, because it allows application processes to interfere with each other.

When setting the parameter C_MMU_PRIVILEGED_INSTR to 2 or 3, the extended address instructions LBUEA, LHUEA, LWEA, SBEA, SHEA, and SWEA are not considered privileged, and will bypass the MMU translation, treating the extended address as a physical address. This is useful to run software in virtual mode while still having direct access to the full physical address space, but is discouraged in all cases where protection between application processes is necessary.

There are six ways to leave user mode and virtual mode:

  1. Hardware generated reset (including debug reset)
  2. Hardware exception
  3. Non-maskable break or hardware break
  4. Interrupt
  5. Executing "BRALID Re,C_BASE_VECTORS + 0x8" to perform a user vector exception
  6. Executing the software break instructions "BRKI" jumping to physical address C_BASE_VECTORS + 0x8 or C_BASE_VECTORS + 0x18

In all of these cases, except hardware generated reset, the user mode and virtual mode status is saved in the MSR UMS and VMS bits.

Application (user-mode) programs transfer control to system-service routines (privileged mode programs) using the BRALID or BRKI instruction, jumping to physical address C_BASE_VECTORS + 0x8. Executing this instruction causes a system-call exception to occur. The exception handler determines which system-service routine to call and whether the calling application has permission to call that service. If permission is granted, the exception handler performs the actual procedure call to the system-service routine on behalf of the application program.

The execution environment expected by the system-service routine requires the execution of prologue instructions to set up that environment. Those instructions usually create the block of storage that holds procedural information (the activation record), update and initialize pointers, and save volatile registers (the registers that the system-service routine uses). Prologue code can be inserted by the linker when creating an executable module, or it can be included as stub code in either the system-call interrupt handler or the system-library routines.

Returns from the system-service routine reverse the process described above. Epilogue code is executed to unwind and deallocate the activation record, restore pointers, and restore volatile registers. The interrupt handler executes a return from exception instruction (RTED) to return to the application.