Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoder/formatter failures #233

Open
0xd4d opened this issue Jul 23, 2020 · 7 comments
Open

Decoder/formatter failures #233

0xd4d opened this issue Jul 23, 2020 · 7 comments
Assignees

Comments

@0xd4d
Copy link

0xd4d commented Jul 23, 2020

{er} is ignored, see the SDM

62F17E187AC1 vcvtudq2pd zmm0, ymm1
ERROR: GENERAL_ERROR Could not decode at offset: 0x0 PC: 0x0: [62F17E187AC1000000000000000000]
62F17E18E6C1 vcvtdq2pd zmm0, ymm1
ERROR: GENERAL_ERROR Could not decode at offset: 0x0 PC: 0x0: [62F17E18E6C1000000000000000000]

Offset is unsigned and should not be sign-extended (32-bit code)

669AADE44E6D call far 0xffffe4ad, 0x6d4e
66EAADE44E6D jmp far 0xffffe4ad, 0x6d4e

Can't disassemble pvalidate in 16/32-bit mode (AMD: "While this instruction is intended for use in SNP-active guest system software, it is recognized in any operating mode at CPL0.")

F20F01FF pvalidate

R8D/R9D can't be used in 32-bit mode. RX bits should probably be ignored (I haven't tested real HW)

8F2A7810C100000000 bextr r8d, ecx, 0x0
8F287085044820 vpmacssww xmm0, xmm1, xmmword ptr [eax+r9d*2], xmm2

Fails to decode this in 32-bit mode. According to the SDM, V' is ignored in 16/32-bit mode, see SDM vol 2, Table 2-39 (page 77), bottom two rows.

62F17C0010C1 vmovups xmm0, xmm1 ; XED fails
ERROR: BAD_EVEX_V_PRIME Could not decode at offset: 0x0 PC: 0x0: [62F17C0010C1000000000000000000]
62F17C0810C1 vmovups xmm0, xmm1 ; works

imm shouldn't show the reg op (upper 4 bits)

C4E37148C230 vpermil2ps xmm0, xmm1, xmm2, xmm3, 0x30
C4E37149C230 vpermil2pd xmm0, xmm1, xmm2, xmm3, 0x30
@markcharney
Copy link
Contributor

I started to work on this one. I have fixed the 1st and 4th issues in my work area. Thanks.

I believe the SDM may be wrong for the 5th issue (EVEX.V' appears to be guarded in 32b mode). That instruction pattern generates an illegal instruction fault on real hardware. I'm checking with someone who owns the RTL to confirm before submitting a fix request to t he SDM.

@0xd4d
Copy link
Author

0xd4d commented Jul 30, 2020

I believe the SDM may be wrong for the 5th issue (EVEX.V' appears to be guarded in 32b mode). That instruction pattern generates an illegal instruction fault on real hardware.

Wouldn't be the first time the SDM is wrong, unfortunately.

@markcharney
Copy link
Contributor

I try not to bash the SDM. The current owner is a friend of mine and was handed a document with a lot of technical debt. We are constantly working to improve things...

@markcharney
Copy link
Contributor

Fixed the 2nd one too. That was probably 16y old bug.

@markcharney
Copy link
Contributor

I fixed all but the last one now. Thinking about whether it is worth bothering. Those are the only 2 instr with "~4b" imm when there is a register in the upper bits. Is AMD even supporting those instructions going forwards? I assumed they were removed from Zen when XOP instr was removed but don't know for sure.

@0xd4d
Copy link
Author

0xd4d commented Jul 30, 2020

The CPUID feature bit is XOP so they shouldn't be supported by current and future AMD CPUs.

@markcharney
Copy link
Contributor

FWIW, I got a response back from the decoder team. As I suggested above, Table 2-39 is wrong for EVEX.V'. For EVEX.V' (P[19]), the table should say "if 0" in both rows for the non-64b #UD, indicating that bit is guarded. Table 2-39 will be fixed in the next release of the SDM (which happens roughly quarterly). Thank you for bringing that issue to my attention.

markcharney pushed a commit that referenced this issue Nov 3, 2020
   * part of  #233

(cherry picked from commit 0fb6f8655cf67c9b59e0b7cf7048e22d989f9a84)
markcharney pushed a commit that referenced this issue Nov 3, 2020
  * needed to ignore upper 8 regs when in 32b mode.

  * use VGPR32_B and VGPR32_R for correct 32b mode behavior of AMD XOP
    instr.

  * Add&use VGPRy_R and VGPRy_B for correct 32/64b mode behavior of
    AMD XOP.

  * #233

(cherry picked from commit 1dd63ff3cf987057016ca354f10facb206fec102)
markcharney pushed a commit that referenced this issue Nov 3, 2020
   * using eosz instead of just the 64b mode indicator

   * ~16 year old bug...

   * #233

(cherry picked from commit 932bbd537986d804ec96e5ae18f56589fe61555a)
markcharney pushed a commit that referenced this issue Nov 3, 2020
   * #233

(cherry picked from commit 562689f047f2643a9ba042d0b42d244df45778a1)
markcharney pushed a commit that referenced this issue Nov 3, 2020
   * part of  #233

(cherry picked from commit 0fb6f8655cf67c9b59e0b7cf7048e22d989f9a84)
markcharney pushed a commit that referenced this issue Nov 3, 2020
  * needed to ignore upper 8 regs when in 32b mode.

  * use VGPR32_B and VGPR32_R for correct 32b mode behavior of AMD XOP
    instr.

  * Add&use VGPRy_R and VGPRy_B for correct 32/64b mode behavior of
    AMD XOP.

  * #233

(cherry picked from commit 1dd63ff3cf987057016ca354f10facb206fec102)
markcharney pushed a commit that referenced this issue Nov 3, 2020
   * using eosz instead of just the 64b mode indicator

   * ~16 year old bug...

   * #233

(cherry picked from commit 932bbd537986d804ec96e5ae18f56589fe61555a)
markcharney pushed a commit that referenced this issue Nov 3, 2020
   * #233

(cherry picked from commit 562689f047f2643a9ba042d0b42d244df45778a1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant