From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 27-NOV-1990 09:34:43.40
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Tracing system services - question and temp. bug fix

Received:  by crdgw1.ge.com (5.57/GE 1.79)
	 id AA14597; Tue, 27 Nov 90 08:54:45 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Tue, 27 NOV 90 05:36:14 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA09682; Tue, 27 Nov 90 05:16:47 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 27 Nov 90 10:59:21 GMT
From: eru!hagbard!sunic!mcsun!cernvax!chx400!cgch!fizciba-geigy.ch!bnebga@bloom-beacon.mit.edu
Organization: Ciba-Geigy AG, Basel, Switzerland
Subject: Tracing system services - question and temp. bug fix
Message-Id: <1990Nov27.115457@fizciba-geigy.ch>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

Can anyone tell me what happens to the IPL as a result of a CHMK instruction? 
Is it reasonable for code running at an elevated IPL to use the CHMK
instruction? I do not have a copy of the VAX architecture handbook.

The question arises in connection with the sytem service tracing program which
I recently posted. The system would crash with a reserved operand exception
when tracing the $crembx system service. An analysis of the system dump
indicated that an REI instruction had attempted to raise the IPL from 0 to 2; I
guess this is what caused the crash. 

If IPL is preserved across a change mode trap I would guess that what causes
the crash is that a system service is invoked via the P1 table at raised IPL;
then one of the system services that trace invokes (perhaps $qio) sets IPL to
0; when we finally try to REI from the original system service call we find
that REI is trying to raise IPL. Is this plausible?

Appended to this message is a patch to disable tracing of system service calls
at elevated IPL and a few more notes on the behaviour of sstrace.

Gary Nebbett (/pn=gary.nebbett/ou=chcgbs30/@ciba-geigy.ch)

------------------------------------------------------------------------
-----------
************
File SSREADME.TXT;2
   28   sstrace does not trace user-written system services, or any other
system
   29   service implemented in a shareable image (like $MOUNT, some security
system
   30   services, etc).
   31   
   32   sstrace uses EFN 0; if an application also uses EFN 0 without an IOSB
then the
   33   behaviour of the application may be affected. It is unlikely (hopefully)
that
   34   any DEC applications would be so foolish as to do this.
   35   
   36   I CURRENTLY KNOW OF THREE IMPORTANT THINGS THAT YOU SHOULD BE WARNED
ABOUT WITH
******
File SSREADME.TXT;1
   28   I CURRENTLY KNOW OF THREE IMPORTANT THINGS THAT YOU SHOULD BE WARNED
ABOUT WITH
************
************
File SSREADME.TXT;2
   46      bugcheck will occur which will crash the system. It may be the case
that
   47      this will only occur if the process has, at some time in its life,
run the
   48      debugger (and hence also possesses a debugger created  version of the
vector 
   49      table).
   50   
******
File SSREADME.TXT;1
   38      bugcheck will occur which will crash the system.
   39   
************
------------------------------------------------------------------------
-----------
************
File SSLOADG.MAR;2
   14   ; MODIFIED BY:  Gary Nebbett, 27th November, 1990
   15   ;                         Add check for current IPL - skip trace if not
zero
   16   ;
******
File SSLOADG.MAR;1
   14   ; MODIFIED BY:
   15   ;
************
************
File SSLOADG.MAR;2
   57   ;       A check for the current IPL level is also made; if the current
IPL is
   58   ;       not zero then the trace functions are skipped. This test was
added
   59   ;       after problems tracing the $crembx system service indicated that
an
   60   ;       REI instruction was trying to raise IPL from 0 to 2 and hence
causing
   61   ;       a reserved operand fault.
   62   ;
   63   ;
******
File SSLOADG.MAR;1
   56   ;
************
************
File SSLOADG.MAR;2
   96           MOVPSL  R1                      ; move PSL into R1
   97           EXTZV   #16, #5, R1, R0         ; extract the IPL from the PSL
   98           BNEQ    HIGHIPL                 ; only trace functions invoked
at IPL=0
   99           EXTZV   #22, #4, R1, R0         ; extract the current and
previous access modes from the PSL
  100           BNEQ    STACKOK                 ; only check for stack space if
current and previous mode = K
  101           PROBEW  #0, #512, -516(SP)      ; probe next 512 bytes of stack
for write access
  102           BNEQ    STACKOK                 ; if stack space is scarce do
not invoke trace function
  103   HIGHIPL:
  104           POPL    R0                      ; get saved return address -
will be in range of P1 vector table
******
File SSLOADG.MAR;1
   89           MOVPSL  R1                      ; move PSL into R1
   90           EXTZV   #22, #4, R1, R0         ; extract the current and
previous access modes from the PSL
   91           BNEQ    STACKOK                 ; only check for stack space if
current and previous mode = K
   92           PROBEW  #0, #512, -516(SP)      ; probe next 512 bytes of stack
for write access
   93           BNEQ    STACKOK                 ; if stack space is scarce do
not invoke trace function
   94           POPL    R0                      ; get saved return address -
will be in range of P1 vector table
************

