https://sourceware.org/bugzilla/show_bug.cgi?id=34000

            Bug ID: 34000
           Summary: [libopcodes] [x86-64] Some instructions fail to decode
                    when unneeded prefixes are present
           Product: binutils
           Version: 2.47 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: jos.craaijo at ou dot nl
  Target Milestone: ---

I have found the following two valid instructions that fail to decode:

1.) f20fbcff (BSF with unnecessary REP prefix)
2.) 660f01d9 (VMMCALL with unnecessary DATA prefix)

Other disassemblers do decode them:

Disassembling F20FBCFF:
libopcodes: "(bad) .byte 0xff"
capstone: (fails to decode)
XED: "bsf edi, edi"
zydis: "bsf edi, edi"
iced: "bsf edi,edi"

Disassembling 660F01D9:
libopcodes: "(bad) .byte 0xd9"
capstone: "vmmcall"
XED: "vmmcall"
zydis: "vmmcall"
iced: "vmmcall"

I have also verified that these instructions do indeed exist on my AMD 5980HS
CPU.

A test program for the first instruction is:

#include <stdio.h>
#include <stdint.h>

int main() {
    __asm__ volatile(
        ".byte 0xF2, 0x0F, 0xBC, 0xFF"
    );

    printf("Executed successfully\n");

    return 0;
}

The second instruction can also be tested by modifying the bytes in the inline
assembly.
However, note that the second instruction is AMD-only and only valid when
running inside a virtual machine.
Testing on bare metal will result in an undefined instruction exception.
I tested it on QEMU with KVM enabled.

I will try to write a patch to fix this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to