Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/lisp/x86-arch.c
    ... ... @@ -369,7 +369,12 @@ sigill_handler(HANDLER_ARGS)
    369 369
          * trap code?
    
    370 370
          */
    
    371 371
         if (*(unsigned short *) SC_PC(context) == 0xb90f) {
    
    372
    -        trap = *(((char *)SC_PC(context)) + 2);
    
    372
    +        /*
    
    373
    +         * This must match what the lisp code is doing.  The trap
    
    374
    +         * number is placed in the low 6-bits of the 3rd byte of the
    
    375
    +         * instruction.
    
    376
    +         */
    
    377
    +        trap = *(((char *)SC_PC(context)) + 2) & 63;
    
    373 378
         } else {
    
    374 379
             abort();
    
    375 380
         }
    

  • src/lisp/x86-assem.S
    ... ... @@ -18,6 +18,16 @@
    18 18
     #include "internals.h"
    
    19 19
     #include "lispregs.h"
    
    20 20
     
    
    21
    +/*
    
    22
    + * Emit the appropriate instruction used for implementing traps.
    
    23
    + * Currently, this is the UD1 instruction.  However, it make it
    
    24
    + * easy to add the trap code, use a sequence of bytes.  The code
    
    25
    + * is smashed into the mod r/m byte with the mod bits set to
    
    26
    + * #b11.  This MUST be coordinated with the Lisp code and the C
    
    27
    + * code.
    
    28
    + *
    
    29
    + * Also, clang doesn't recognize the ud1 instruction.
    
    30
    + */
    
    21 31
     #define TRAP_CODE(code) \
    
    22 32
     	.byte 0x0f		; \
    
    23 33
     	.byte 0xb9		; \
    
    ... ... @@ -249,10 +259,7 @@ ENDFUNC(sse_restore)
    249 259
      * The undefined-function trampoline.
    
    250 260
      */
    
    251 261
     FUNCDEF(undefined_tramp)
    
    252
    -	# UD1
    
    253
    -	.byte	0x0f
    
    254
    -	.byte	0xb9
    
    255
    -	.byte	trap_Error
    
    262
    +	TRAP_CODE(trap_Error)
    
    256 263
             /* Number of argument bytes */
    
    257 264
             .byte   2
    
    258 265
     	.byte	UNDEFINED_SYMBOL_ERROR
    
    ... ... @@ -300,40 +307,28 @@ GNAME(function_end_breakpoint_trap):
    300 307
     	.byte	0xb9
    
    301 308
     	.byte 	0xc0 + trap_PendingInterrupt
    
    302 309
     	*/
    
    303
    -	# UD1
    
    304
    -	.byte	0x0f
    
    305
    -	.byte	0xb9
    
    306
    -	.byte 	0xc0 + trap_FunctionEndBreakpoint
    
    310
    +	TRAP_CODE(trap_FunctionEndBreakpoint)
    
    307 311
     	hlt			# Should never return here.
    
    312
    +ENDFUNC(function_end_breakpoint_trap)
    
    308 313
     
    
    309 314
     	.globl GNAME(function_end_breakpoint_end)
    
    310 315
     GNAME(function_end_breakpoint_end):
    
    311 316
     
    
    312
    -
    
    313 317
     FUNCDEF(do_pending_interrupt)
    
    314
    -	# UD1
    
    315
    -	.byte	0x0f
    
    316
    -	.byte	0xb9
    
    317
    -	.byte 	trap_PendingInterrupt
    
    318
    +	TRAP_CODE(trap_PendingInterrupt)
    
    318 319
     	ret
    
    319 320
     ENDFUNC(do_pending_interrupt)
    
    320 321
     	
    
    321 322
     #ifdef trap_DynamicSpaceOverflowError
    
    322 323
     FUNCDEF(do_dynamic_space_overflow_error)
    
    323
    -	# UD1
    
    324
    -	.byte	0x0f
    
    325
    -	.byte	0xb9
    
    326
    -	.byte 	trap_DynamicSpaceOverflowError
    
    324
    +	TRAP_CODE(trap_DynamicSpaceOverflowError)
    
    327 325
     	ret
    
    328 326
     ENDFUNC(do_dynamic_space_overflow_error)
    
    329 327
     #endif				
    
    330 328
     	
    
    331 329
     #ifdef trap_DynamicSpaceOverflowWarning
    
    332 330
     FUNCDEF(do_dynamic_space_overflow_warning)
    
    333
    -	# UD1
    
    334
    -	.byte	0x0f
    
    335
    -	.byte	0xb9
    
    336
    -	.byte 	trap_DynamicSpaceOverflowWarning
    
    331
    +	TRAP_CODE(trap_DynamicSpaceOverflowWarning)
    
    337 332
     	ret
    
    338 333
     ENDFUNC(do_dynamic_space_overflow_warning)
    
    339 334
     #endif				
    
    ... ... @@ -515,10 +510,7 @@ FUNCDEF(undefined_foreign_symbol_trap)
    515 510
             movl 8(%ebp),%eax
    
    516 511
     
    
    517 512
     	/* Now trap to Lisp */
    
    518
    -	# UD1
    
    519
    -	.byte	0x0f
    
    520
    -	.byte	0xb9
    
    521
    -	.byte	trap_Error
    
    513
    +	TRAP_CODE(trap_Error)
    
    522 514
             /* Number of argument bytes */
    
    523 515
             .byte   2
    
    524 516
     	.byte	UNDEFINED_FOREIGN_SYMBOL_ERROR