Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!oliveb!pyramid!voder!blia!ted From: ted@blia.UUCP Newsgroups: comp.os.vms Subject: Re: internals Message-ID: <2887@blia.BLI.COM> Date: Mon, 29-Jun-87 16:12:11 EDT Article-I.D.: blia.2887 Posted: Mon Jun 29 16:12:11 1987 Date-Received: Sat, 4-Jul-87 00:44:36 EDT References: <8706281911.AA23198@ucbvax.Berkeley.EDU> Distribution: world Organization: Britton Lee, Los Gatos, CA Lines: 52 Summary: CHMK instruction is part of each system service In article <8706281911.AA23198@ucbvax.Berkeley.EDU>, WARNOCK@prism.clemson.EDU (Todd Warnock) writes: > It's my understanding that ANYONE can issue a CHMK instruction successfully. > (not to be confused with a successful call to the similar system service...) > Exactly what is the difference in the two ? What actually requires the > CHMKNL privilege ? The CHMK instruction is used by a system service call to signal the VMS executive that kernal mode work is required. Executing this instruction causes the processor to change to kernal mode (switching stacks) and call the CHMK dispatch routine. This code checks the one word code in the CHMK instruction and dispatches to the corresponding kernal mode routine for that system service. The flow of control for a typical system service is as follows: Address space containing the code Mode | Action ---- -- ------------------------------------------------------------------- user P0 User program call system service routine (SYS$xxxxx). user S0 User mode portion does initial checking of arguments and if the requested service can be done in user mode, does so and returns to the caller. Otherwise, executes CHMK instruction with code value for desired kernal mode routine. krnl S0 CHMK dispatcher checks code word on CHMK instruction and calls the corresponding executive routine. krnl S0 Executive CAREFULLY checks arguments and user privileges (since the user code could have executed CHMK instruction directly, bypassing checks in step 2 above). If these are valid, does the desired work (typically reading and modifying system data structures). Afterwards, returns to the user mode caller. On the other hand, the Change Mode to Kernal system service does a CHMK instruction to dispatch to the executive routine. This routine verifies that the user has CHMKNL privilege and if so, calls the specified user routine in kernal mode. Thus the CHMK instruction gives carefully controlled access to routines in the executive to complete execution of system service calls. No privilege is required. The Change Mode to Kernal system service does a CHMK which effectively calls a routine that calls the user subroutine in kernal mode. The intermediate routine verifies that the user has CHMKNL privilege. Hope this explains everything. Small details in the above may be wrong; I don't have the internals book or the fiche handy at the moment. -- Ted Marshall ...!ucbvax!mtxinu!blia!ted mtxinu!blia!ted@Berkeley.EDU Britton Lee, Inc., 14600 Winchester Blvd, Los Gatos, Ca 95030 (408)378-7000 The opinions expressed above are those of the poster and not his employer.