NonStop S-Series Server Description Manual (G06.27+)
Native Execution Mode
HP NonStop S-Series Server Description Manual—520331-004
7-12
Stack Switching for Native Privilege Transition
Stack Switching for Native Privilege Transition
If a nonprivileged process, operating in nonprivileged native mode, calls a callable
procedure, the process must switch its operation from the main stack to the privileged
stack. This switch is performed as part of the transition to privileged mode (discussed
in Invoking Privilege Requires Taking an Exception on page 7-10).
The stack switch is accomplished by these steps. The step numbers correspond to the
numbered callouts in Figure 7-6.
1. The call in nonprivileged code to a callable procedure causes a privilege exception,
invoking the exception handler in millicode. (See Invoking Privilege Requires
Taking an Exception on page 7-10.)
2. Upon verifying this exception as an invocation of a legitimate callable procedure,
the exception handler passes control to the Enter_Priv routine. This routine builds
a special stack frame on the privileged stack, beginning with the caller’s return
address (ra) and existing stack pointer address (sp). These items are followed
with space for the maximum number of arguments.
3. The Enter_Priv routine now moves sp to the privileged stack (above the parameter
area) and invokes the called callable procedure. The return address in register ra
now designates the Exit_Priv millicode for use in Step 6.
4. The called procedure allocates its frame on the privileged stack.
5. The called procedure transfers parameters from the caller’s frame on the main
stack to the new frame on the privileged stack. (Parameters passed in registers a0
through a3 are undisturbed by Enter_Priv and so need no copying.) The
procedure executes on the privileged stack until ready to return, placing any return
values in processor registers.
6. The called procedure exits normally to the address it finds in the ra register.
Because this register was set to point at the Exit_Priv routine (Step 2), control
passes to that routine.
7. The Exit_Priv routine switches the mode back to nonprivileged and retrieves the ra
and sp values that were stored at the beginning of the privileged stack. These are
the caller’s values. Loading these values into the ra and sp registers, the millicode
returns control to the caller. Any values returned in v0 and v1 by the callable
procedure are undisturbed by the Exit_Priv operation.