Skip to content

Commit

Permalink
Fix handling of LOCK with TEST instructions.
Browse files Browse the repository at this point in the history
Besides CMP, also TEST instructions cause #UD when the LOCK prefix is used.
  • Loading branch information
acoglio committed Apr 19, 2018
1 parent 83e0321 commit b3bf5f0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions books/projects/x86isa/machine/instructions/arith-and-logic.lisp
Expand Up @@ -173,10 +173,10 @@
(mod (the (unsigned-byte 2) (mrm-mod modr/m)))
(reg (the (unsigned-byte 3) (mrm-reg modr/m)))

(lock? (eql #.*lock*
(prefixes-slice :group-1-prefix prefixes)))
((when (and lock? (eql operation #.*OP-CMP*)))
;; CMP does not allow a LOCK prefix.
(lock? (eql #.*lock* (prefixes-slice :group-1-prefix prefixes)))
((when (and lock? (or (eql operation #.*OP-CMP*)
(eql operation #.*OP-TEST*))))
;; CMP and TEST do not allow a LOCK prefix.
(!!fault-fresh :ud nil :lock-prefix prefixes)) ;; #UD

(p2 (prefixes-slice :group-2-prefix prefixes))
Expand Down Expand Up @@ -398,10 +398,10 @@
(mod (the (unsigned-byte 2) (mrm-mod modr/m)))
(reg (the (unsigned-byte 3) (mrm-reg modr/m)))

(lock (eql #.*lock*
(prefixes-slice :group-1-prefix prefixes)))
((when (and lock (eql operation #.*OP-CMP*)))
;; CMP does not allow a LOCK prefix.
(lock (eql #.*lock* (prefixes-slice :group-1-prefix prefixes)))
((when (and lock (or (eql operation #.*OP-CMP*)
(eql operation #.*OP-TEST*))))
;; CMP and TEST do not allow a LOCK prefix.
(!!fault-fresh :ud nil :lock-prefix prefixes)) ;; #UD

(p2 (prefixes-slice :group-2-prefix prefixes))
Expand Down

0 comments on commit b3bf5f0

Please sign in to comment.