[Git][cmucl/cmucl][issue-97-define-ud2-inst] Use UD1 instead of UD2

Raymond Toy gitlab at common-lisp.net
Thu Apr 8 00:37:40 UTC 2021



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


Commits:
f8abdf9a by Raymond Toy at 2021-04-07T17:36:51-07:00
Use UD1 instead of UD2

The definition of BTC and friends conflicted with UD1, so fix that.
Without this, our UD1 instruction got printed out as BTC.

Update x86-arch to look for ud1 instead of ud2.

- - - - -


2 changed files:

- src/compiler/x86/insts.lisp
- src/lisp/x86-arch.c


Changes:

=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -1778,8 +1778,8 @@
 (disassem:define-instruction-format
     (bit-test-reg/mem 24
 		      :default-printer '(:name :tab reg/mem ", " reg))
-  (prefix	:field (byte 8 0)	:value #b0001111)
-  (op		:field (byte 3 11))
+  (prefix	:field (byte 8 0) :value #b0001111)
+  (op		:field (byte 8 8))
   ;;(test		:fields (list (byte 2 14) (byte 3 8)))
   (reg/mem	:fields (list (byte 2 22) (byte 3 16))
 		:type 'reg/mem)
@@ -1788,22 +1788,22 @@
   (imm))
 
 (define-instruction bt (segment src index)
-  (:printer bit-test-reg/mem ((op #b100)))
+  (:printer bit-test-reg/mem ((op #b10100011)))
   (:emitter
    (emit-bit-test-and-mumble segment src index #b100)))
 
 (define-instruction btc (segment src index)
-  (:printer bit-test-reg/mem ((op #b111)))
+  (:printer bit-test-reg/mem ((op #b10111011)))
   (:emitter
    (emit-bit-test-and-mumble segment src index #b111)))
 
 (define-instruction btr (segment src index)
-  (:printer bit-test-reg/mem ((op #b110)))
+  (:printer bit-test-reg/mem ((op #b10110011)))
   (:emitter
    (emit-bit-test-and-mumble segment src index #b110)))
 
 (define-instruction bts (segment src index)
-  (:printer bit-test-reg/mem ((op #b101)))
+  (:printer bit-test-reg/mem ((op #b10101011)))
   (:emitter
    (emit-bit-test-and-mumble segment src index #b101)))
 
@@ -2062,11 +2062,11 @@
  (code :field (byte 8 8)))
 
 
-(disassem:define-instruction-format (break 24 :default-printer '(:name :tab code))
-  (op :fields (list (byte 8 0) (byte 8 8)) :value '(#xb00001111 #b00001011))
+(disassem:define-instruction-format (ud1 24 :default-printer '(:name :tab code))
+  (op :fields (list (byte 8 0) (byte 8 8)) :value '(#xb00001111 #b10111001))
   (code :field (byte 8 16)))
 
-(define-emitter emit-break-inst 24
+(define-emitter emit-ud1-inst 24
   (byte 8 0) (byte 8 8) (byte 8 16))
 
 (defun snarf-error-junk (sap offset &optional length-only)
@@ -2102,7 +2102,7 @@
 (defun break-control (chunk inst stream dstate)
   (declare (ignore inst))
   (flet ((nt (x) (if stream (disassem:note x dstate))))
-    (case (break-code chunk dstate)
+    (case (ud1-code chunk dstate)
       (#.vm:error-trap
        (nt "Error trap")
        (disassem:handle-break-args #'snarf-error-junk stream dstate))
@@ -2122,11 +2122,11 @@
 ;; This is really the int3 instruction.
 (define-instruction break (segment code)
   (:declare (type (unsigned-byte 8) code))
-  (:printer break ((op '(#b00001111 #b00001011)))
+  (:printer ud1 ((op '(#b00001111 #b10111001)))
 	    '(:name :tab code)
 	    :control #'break-control)
   (:emitter
-   (emit-break-inst segment #b00001111 #b00001011 code)))
+   (emit-ud1-inst segment #b00001111 #b10111001 code)))
 
 #+nil
 (define-instruction ud2 (segment)


=====================================
src/lisp/x86-arch.c
=====================================
@@ -361,14 +361,14 @@ sigill_handler(HANDLER_ARGS)
             (stderr, "pc %x\n",  *(unsigned short *)SC_PC(context)));
 
     /*
-     * Make sure the trapping instruction is UD2.  Abort if not.
+     * Make sure the trapping instruction is UD1.  Abort if not.
      *
      * TODO: aborting is probably not the best idea.  Could get here
      * from other illegal instructions in, say, C code?  Maybe we
      * should call interrupt_handle_now, as we do below for an unknown
      * trap code?
      */
-    if (*(unsigned short *) SC_PC(context) == 0x0b0f) {
+    if (*(unsigned short *) SC_PC(context) == 0xb90f) {
         trap = *(((char *)SC_PC(context)) + 2);
     } else {
         abort();



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/f8abdf9a5d35ba0195ed03b67dccf0eb9034b866

-- 
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/f8abdf9a5d35ba0195ed03b67dccf0eb9034b866
You're receiving this email because of your account on gitlab.common-lisp.net.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20210408/b8254689/attachment-0001.html>


More information about the cmucl-cvs mailing list