NonStop S-Series Server Description Manual (G06.24+)

TNS Execution Modes
HP NonStop S-Series Server Description Manual520331-003
6-84
Invoking Privilege for CALLABLE Procedures
Invoking Privilege for CALLABLE Procedures
Unlike TNS processors (CISC-based), which invoke privilege in the microcode of the
calling instruction, RISC-based processors such as NonStop S-series processors,
always go through a sequence of events involving an exception to set the privileged
state. Figure 6-45 shows the sequences for the three execution modes; the first two
are discussed in this topic and the third in Section 7, Native Execution Mode. In all
three cases, a program shown on the left side of the illustration is calling the
CALLABLE procedure shown at the right side of the figure.
The mechanism is different for CALLABLE transitions in each operating mode and for
the special case of a transition to native mode, but each path has some form of the
same requirements:
Verify that this exception arises from an attempt to call a legitimate CALLABLE
procedure.
Ensure that the process state is proper for entering privileged state in the current
execution mode. For example, force the stack pointer into a valid range.
Make any appropriate state changes corresponding to the privilege transition.
Allow the process to proceed in privileged state.
In TNS mode, when the millicode encounters a procedure call instruction such as
PCAL, it first verifies a legal call by comparing the address given as the target
procedure with the range of CALLABLE procedure addresses given in the procedure
entry point (PEP) table. If the address is legal, the millicode then issues a syscall
exception, and the syscall exception handler revalidates that the address is within the
legal range, grants the necessary privilege, and transfers to the procedure.
In accelerated mode, the PCAL (or other calling instruction) has been translated to a
sequence of RISC instructions. The calling sequence resulting from the translated
PCAL invokes a gateway sequence that checks whether the caller is already
privileged. To do so, the gateway attempts to load a specific byte in Kseg2 (in the
SPAD page). If the gateway can legally load the byte (which is discarded), that means
the caller is already privileged, can bypass the succeeding operations, and can transfer
to the target CALLABLE procedure.
If, however, the load fails (because the Kseg2 address requires privilege), that means
that the caller is unprivileged. This event causes an address error exception, invoking
the address error exception handler. This exception handler recognizes that the
address being used indicated a request to access a CALLABLE accelerated procedure
and verifies that the exception occurred at an address within the designated gateway
table for an accelerated code region (SL, UL, or UC).