|
|
1.1 ! root 1: ! 2: # ! 3: # Kernel stack not valid event test. ! 4: # This test is entered in Kernel mode, running virtual on ISP. ! 5: # The test then REI to USER which will execute a KCALL with an ! 6: # invalid Kernel stack. Kernel stack not valid fault is expected ! 7: # to occure. ! 8: # ! 9: # R0 = error code ! 10: # 1 - Did not generate Kernel stack not valid when executing ! 11: # Kcall with a invalid KSP ! 12: # R1 = KSP after Kcall exception, R2 = P2BR, R3 = P2LR ! 13: # 2 - Too many parameters pushed on ISP ! 14: # R1 = ISP after KSP not valid exception ! 15: # 3 - ISP is not correct after KSP not valid exception ! 16: # R1 = actual, R2 = expected ! 17: # 4 - Current PSL is not correct after KSP not valid exception ! 18: # R1 = actual, R2 = expected ! 19: # 5 - PC pushed on ISP is not correct after KSP not valid exception ! 20: # R1 = actual, R2 = expected ! 21: # 6 - PSL pushed on ISP is not correct after KSP not valid exception ! 22: # R1 = actual, R2 = expected ! 23: # ! 24: .set LAST_VPGNO,0xfffff /* Last virtual page no */ ! 25: .set TST_PTEP2,LAST_VPGNO ! 26: .set P2ADDR,0x80000000 ! 27: .set EXP_UPSL,0x01000000 /* User mode, IPL = 0 */ ! 28: ! 29: .globl _ksnv_evt ! 30: _ksnv_evt: ! 31: .word 0x1fff /* Save r0-r12 */ ! 32: ! 33: mtpr $0x1f,$IPL ! 34: movl $1,tst_cnt ! 35: ! 36: # Set up P2PT : 2 entries ! 37: # PTE 0 : Physical page 254, PTE_V off, Kernel R/W ! 38: # PTE 1 : Physical page 255, PTE_V off, Kernel R/W ! 39: # ! 40: movab _u0p2pt,r10 /* System virtual addr of P2PT */ ! 41: orl3 $254,$PG_KW,(r10) /* PTE 0 : Kernel write, V bit off */ ! 42: orl3 $255,$PG_KW,4(r10) /* PTE 1 : Kernel write, V bit off */ ! 43: subl3 $((LAST_VPGNO - 1) << 2),r10,r11 ! 44: /* Virtual address of P2BR */ ! 45: ! 46: # Set up P0PT ! 47: # virtual page 0 = physical page of routine _uxtest ! 48: # ! 49: clrl r2 ! 50: andl3 $_uxtest,$0x3fffffff,r1 ! 51: andl3 $0x000003ff,r1,r7 /* R7 : offset to 1st instruction */ ! 52: shrl $PGSHIFT,r1,r1 /* Page no. of _uxtest */ ! 53: andl3 $_eutest+NBPG-1,$0x3fffffff,r3 ! 54: shrl $PGSHIFT,r3,r3 /* Last page no. of _uxtest */ ! 55: 1: orl3 $PG_V|PG_URKW,r1,_u0p0pt[r2] ! 56: incl r2 ! 57: aoblss r3,r1,1b ! 58: ! 59: movl $_pcb0,r1 /* Initialize PCB slightly */ ! 60: movl $((LAST_VPGNO<<PGSHIFT)|0x8|P2ADDR),PCB_KSP(r1) ! 61: /* Set up KSP */ ! 62: movl r7,PCB_PC(r1) /* Set PCB_PC */ ! 63: movl $EXP_UPSL,PCB_PSL(r1) /* Set PCB_PSL : User */ ! 64: movab _u0p0pt,PCB_P0BR(r1) /* Set PCB_P0BR */ ! 65: movl $2,PCB_P0LR(r1) /* Set PCB_P0LR : 2 PTEs */ ! 66: movl r11,PCB_P2BR(r1) /* Set PCB_P2BR */ ! 67: movl $0xffffd,PCB_P2LR(r1) /* Two PTE for P2PT */ ! 68: andl2 $0x3fffffff,r1 ! 69: mtpr r1,$PCBB /* Init PCBB */ ! 70: ! 71: /* Set expected parameters */ ! 72: movab fpc0,exp_pc /* expected PC pushed on ISP */ ! 73: movpsl r1 ! 74: andl3 $0xfbfffff0,r1,exp_psl /* Exp. PSL pushed on ISP : IS off */ ! 75: movl $0x41f0000,exp_cpsl /* Expected PSL after fault : */ ! 76: /* Mode : Kernel, IS : on, IPL => 0x1f. */ ! 77: /* the rest are screwed up on Kstack not */ ! 78: /* valid exception ! */ ! 79: movl $-1,-(sp) /* Set marker for ISP */ ! 80: movab (sp),r8 ! 81: subl3 $0x8,r8,exp_isp /* Expected ISP after fault */ ! 82: ! 83: movl fp,sfp /* Save FP */ ! 84: more: movl _scb+SYSVEC,_savvec0 /* Save current syscall vector */ ! 85: movl _scb+KSPVEC,_savvec1 ! 86: movab _u0ret,_scb+SYSVEC /* New vector for KCALL */ ! 87: movab _ksnotvalid,_scb+KSPVEC /* New vector for Kstack not valid */ ! 88: mtpr $0,$TBIA ! 89: fpc0: ldpctx /* Save ISP, Switch context to user, should */ ! 90: /* Cause Kstack not valid fault !! */ ! 91: rei ! 92: halt ! 93: # ! 94: # ! 95: /* KCALL handler */ ! 96: .align 2 ! 97: _u0ret: ! 98: /* Error -- did not receive kernel stack not valid */ ! 99: /* fault during KCALL which try to push 3 parameters on */ ! 100: /* an invalid Kernel stack. */ ! 101: mtpr $HIGH,$IPL ! 102: movl _savvec0,_scb+SYSVEC /* Restore original vectors */ ! 103: movl _savvec1,_scb+KSPVEC ! 104: movl $1,r0 ! 105: movab (sp),r1 /* Kernel stack pointer */ ! 106: mfpr $P2BR,r2 /* P2 page table base */ ! 107: mfpr $P2LR,r3 /* P2 page table base */ ! 108: jmp *badrtn ! 109: ! 110: ! 111: /* Kernel stack not valid event handler; serviced on ISP */ ! 112: .align 2 ! 113: _ksnotvalid: ! 114: movl _savvec1,_scb+KSPVEC /* Restore original vectors */ ! 115: movl _savvec0,_scb+SYSVEC ! 116: ! 117: movab (sp),r1 /* actual ISP */ ! 118: addl3 $8,r1,r7 ! 119: cmpl $-1,(r7) /* Check marker on ISP */ ! 120: jeql 1f ! 121: movl $2,r0 ! 122: jmp *badrtn /* Too many params. pushed on ISP */ ! 123: 1: ! 124: movl exp_isp,r2 ! 125: cmpl r1,r2 /* Make sure ISP is correct */ ! 126: beql 0f ! 127: movl $3,r0 ! 128: jmp *badrtn ! 129: ! 130: 0: movpsl r1 /* Check current PSL */ ! 131: andl2 $0xfffffff0,r1 ! 132: movl exp_cpsl,r2 /* Expected PSL after fault */ ! 133: cmpl r1,r2 ! 134: beql 1f ! 135: movl $4,r0 /* Error code = 2 */ ! 136: jmp *badrtn /* PSL not right after kernel stack not */ ! 137: /* valid fault; r1 = actual; r2 = expected */ ! 138: 1: ! 139: movl exp_pc,r2 /* Get expected PC */ ! 140: movl (sp),r1 /* Pop actual PC from ISP */ ! 141: cmpl r1,r2 ! 142: beql 1f ! 143: movl $5,r0 /* Error : incorrect PC on ISP */ ! 144: jmp *badrtn /* Error code r0 = 3 */ ! 145: 1: ! 146: movl 4(sp),r1 /* Pop actual PSL on ISP */ ! 147: andl3 $0xffffffff0,4(sp),r1 ! 148: movl exp_psl,r2 /* R2 : expected PSL */ ! 149: cmpl r1,r2 ! 150: beql 1f ! 151: movl $6,r0 /* Error : incorrect PSL */ ! 152: jmp *badrtn /* Error code r0 = 4 */ ! 153: 1: ! 154: andl3 $_kc_flt,$0x3ff,exp_pc /* Set expected PC */ ! 155: movl $0x41d0000,exp_cpsl /* IPL should raised to 0x1d */ ! 156: movl $EXP_UPSL,exp_psl /* Expected PSL pushed on ISP */ ! 157: ! 158: movab _u0p2pt,r10 /* System virtual addr of P2PT */ ! 159: orl2 $0x80000000,4(r10) /* Set V_bit of PTE1 On */ ! 160: movl $0,r0 ! 161: mtpr $1,$TBIA ! 162: endt: ! 163: movl (sp)+,r12 /* Pop PC, PSL out of ISP */ ! 164: movl (sp)+,r12 ! 165: decl tst_cnt /* decrement test count */ ! 166: blss 0f /* branch if less than 0 */ ! 167: movab _u0ret,_scb+SYSVEC /* New vector for KCALL */ ! 168: movab _ksnotvalid,_scb+KSPVEC /* New vector for Kstack not valid */ ! 169: jmp fpc0 /* restart LDPCTX : Should be O.K */ ! 170: 0: ! 171: movl (sp)+,r0 /* Pop marker off ISP */ ! 172: movl sfp,fp /* Restore FP */ ! 173: ret /* Done !! return to monitor */ ! 174: # ! 175: # ! 176: # ! 177: .globl _uxtest ! 178: _uxtest: ! 179: clrl r0 ! 180: _kc_flt: ! 181: kcall $DONE /* KCALL should cause Kernel stack not valid fault */ ! 182: /* when try to push the 3rd paramater on Kstack */ ! 183: _eutest: ! 184: halt ! 185: ! 186: .align 2 ! 187: exp_pc: ! 188: .long 0 ! 189: exp_psl: ! 190: .long 0 ! 191: exp_cpsl: ! 192: .long 0 /* Expected current PSL */ ! 193: exp_isp: ! 194: .long 0 /* expected ISP while in Kstack not valid handler */ ! 195: sfp: ! 196: .long 0 /* saved FP */ ! 197: tst_cnt: ! 198: .long 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.