• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Introduction
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • Syscalls
          • Cpuid
          • X86isa-state
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
            • Get-prefixes
            • Vex-0f3a-execute
            • Vex-0f38-execute
            • Vex-0f-execute
            • Two-byte-opcode-execute
            • Second-three-byte-opcode-execute
            • One-byte-opcode-execute
            • First-three-byte-opcode-execute
            • Evex-0f3a-execute
            • Evex-0f38-execute
            • Evex-0f-execute
            • X86-fetch-decode-execute
            • Vex-decode-and-execute
            • Evex-decode-and-execute
              • Opcode-maps
              • X86-run
              • Implemented-opcodes
              • Three-byte-opcode-decode-and-execute
              • X86-run-halt-count
              • Two-byte-opcode-decode-and-execute
              • X86-run-steps
              • X86-fetch-decode-execute-halt
              • X86-run-halt
              • X86-run-steps1
            • Physical-memory
            • Decoding-and-spec-utils
            • Instructions
            • X86-modes
            • Segmentation
            • Register-readers-and-writers
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • Proof-utilities
          • To-do
          • Concrete-simulation-examples
          • Model-validation
          • Utils
          • Debugging-code-proofs
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • X86-decoder

    Evex-decode-and-execute

    Signature
    (evex-decode-and-execute proc-mode start-rip temp-rip 
                             prefixes rex-byte evex-prefixes x86) 
     
      → 
    x86
    Arguments
    temp-rip — temp-rip points to the byte following the first two EVEX prefixes that were already read and placed in the evex-prefixes structure in x86-fetch-decode-execute.
    evex-prefixes — Only byte0 and byte1 fields are populated when this function is called.

    evex-decode-and-execute dispatches control to EVEX-encoded instructions.

    Reference: Intel Vol. 2A, Section 2.6: Intel(R) AVX-512 Encoding

    Definitions and Theorems

    Function: evex-decode-and-execute

    (defun
     evex-decode-and-execute
     (proc-mode start-rip temp-rip
                prefixes rex-byte evex-prefixes x86)
     (declare (xargs :stobjs (x86)))
     (declare (type (integer 0 4) proc-mode)
              (type (signed-byte 48) start-rip)
              (type (signed-byte 48) temp-rip)
              (type (unsigned-byte 52) prefixes)
              (type (unsigned-byte 8) rex-byte)
              (type (unsigned-byte 32) evex-prefixes))
     (declare (xargs :guard (and (evex-prefixes-p evex-prefixes)
                                 (prefixes-p prefixes))))
     (let
      ((__function__ 'evex-decode-and-execute))
      (declare (ignorable __function__))
      (b*
       ((ctx 'evex-decode-and-execute)
        ((when (not (equal rex-byte 0)))
         (!!fault-fresh :ud
                        :evex-prefixes evex-prefixes
                        :rex rex-byte))
        ((when (equal (the (unsigned-byte 8)
                           (prefixes->lck prefixes))
                      240))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :lock-prefix))
        ((when (equal (the (unsigned-byte 8)
                           (prefixes->rep prefixes))
                      242))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :f2-prefix))
        ((when (equal (the (unsigned-byte 8)
                           (prefixes->rep prefixes))
                      243))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :f3-prefix))
        ((when (equal (the (unsigned-byte 8)
                           (prefixes->opr prefixes))
                      102))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :66-prefix))
        (evex-byte1 (evex-prefixes->byte1 evex-prefixes))
        ((when (not (equal (evex-byte1->res evex-byte1) 0)))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :byte1-reserved-bits))
        ((mv evex-0f-map?
             evex-0f38-map? evex-0f3a-map?)
         (mv (equal (evex-byte1->mm evex-byte1) 1)
             (equal (evex-byte1->mm evex-byte1) 2)
             (equal (evex-byte1->mm evex-byte1) 3)))
        ((when (not (or evex-0f-map?
                        evex-0f38-map? evex-0f3a-map?)))
         (!!fault-fresh :ud
                        :evex-prefixes evex-prefixes
                        :mm evex-byte1))
        ((mv flg0 (the (unsigned-byte 8) evex-byte2)
             x86)
         (rme08 proc-mode temp-rip 1 :x x86))
        ((when flg0)
         (!!ms-fresh :evex-byte2-read-error flg0))
        ((mv flg1 temp-rip)
         (add-to-*ip proc-mode temp-rip 1 x86))
        ((when flg1)
         (!!ms-fresh :increment-error flg1))
        (evex-prefixes (!evex-prefixes->byte2 evex-byte2 evex-prefixes))
        ((when (not (equal (evex-byte2->res evex-byte2) 1)))
         (!!fault-fresh :ud :evex-prefixes
                        evex-prefixes :byte2-reserved-bit))
        ((mv flg2 (the (unsigned-byte 8) evex-byte3)
             x86)
         (rme08 proc-mode temp-rip 1 :x x86))
        ((when flg2)
         (!!ms-fresh :evex-byte3-read-error flg2))
        ((mv flg3 temp-rip)
         (add-to-*ip proc-mode temp-rip 1 x86))
        ((when flg3)
         (!!ms-fresh :increment-error flg3))
        ((mv flg4 (the (unsigned-byte 8) opcode)
             x86)
         (rme08 proc-mode temp-rip 1 :x x86))
        ((when flg4)
         (!!ms-fresh :opcode-read-error flg4))
        ((mv flg5 temp-rip)
         (add-to-*ip proc-mode temp-rip 1 x86))
        ((when flg5)
         (!!ms-fresh :increment-error flg5))
        ((mv flg6 (the (unsigned-byte 8) modr/m)
             x86)
         (rme08 proc-mode temp-rip 1 :x x86))
        ((when flg6)
         (!!ms-fresh :modr/m-byte-read-error flg6))
        ((mv flg7 temp-rip)
         (add-to-*ip proc-mode temp-rip 1 x86))
        ((when flg7)
         (!!ms-fresh :increment-error flg7))
        (sib? (b* ((p4? (eql 103
                             (the (unsigned-byte 8)
                                  (prefixes->adr prefixes))))
                   (16-bit-addressp
                        (eql 2
                             (select-address-size proc-mode p4? x86))))
                  (x86-decode-sib-p modr/m 16-bit-addressp)))
        ((mv flg8 (the (unsigned-byte 8) sib)
             x86)
         (if sib? (rme08 proc-mode temp-rip 1 :x x86)
             (mv nil 0 x86)))
        ((when flg8)
         (!!ms-fresh :sib-byte-read-error flg8))
        ((mv flg9 temp-rip)
         (if sib?
             (add-to-*ip proc-mode temp-rip 1 x86)
             (mv nil temp-rip)))
        ((when flg9)
         (!!ms-fresh :increment-error flg9)))
       (cond
           (evex-0f-map?
                (evex-0f-execute proc-mode
                                 start-rip temp-rip prefixes rex-byte
                                 evex-prefixes opcode modr/m sib x86))
           (evex-0f38-map?
                (evex-0f38-execute proc-mode
                                   start-rip temp-rip prefixes rex-byte
                                   evex-prefixes opcode modr/m sib x86))
           (evex-0f3a-map?
                (evex-0f3a-execute proc-mode
                                   start-rip temp-rip prefixes rex-byte
                                   evex-prefixes opcode modr/m sib x86))
           (t (!!ms-fresh :illegal-value-of-evex-mm))))))

    Theorem: x86p-evex-decode-and-execute

    (defthm
     x86p-evex-decode-and-execute
     (implies
      (x86p x86)
      (x86p
        (evex-decode-and-execute proc-mode start-rip temp-rip
                                 prefixes rex-byte evex-prefixes x86))))