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

Possible bugs in datafiles and xed code #340

Open
a0rland0 opened this issue Nov 6, 2024 · 5 comments
Open

Possible bugs in datafiles and xed code #340

a0rland0 opened this issue Nov 6, 2024 · 5 comments
Labels
accepted bug upcoming release A fix/support will be available with the upcoming external release

Comments

@a0rland0
Copy link

a0rland0 commented Nov 6, 2024

Hi,
In file "datafiles\xed-addressing-modes-new.txt" (line 483) shouldn't these lines be:

REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b01 | BASE0=Ar21() SEG0=FINAL_DSEG() DISP_WIDTH=8
REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b10 | BASE0=Ar21() SEG0=FINAL_DSEG() DISP_WIDTH=32

instead of:

REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b01 | BASE0=Ar21() SEG0=FINAL_SSEG() DISP_WIDTH=8
REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b10 | BASE0=Ar21() SEG0=FINAL_SSEG() DISP_WIDTH=32

The same logic is applied to Ar13() and Ar29(), so I wonder if this is an error.
Thanks.

@a0rland0
Copy link
Author

a0rland0 commented Dec 3, 2024

Hi,
A few other things that might be wrong too (imo).

  1. In xed-decode.c the function "check_all_regs_match" should be ifdef'd with XED_ATTRIBUTE_NO_REG_MATCH_DEFINED instead of XED_ATTRIBUTE_NO_SRC_DEST_MATCH_DEFINED. This will make the code consistent with function xed_decode_finalize_operand_storage_fields.

  2. NOP5 (and NOP6, etc.) will not work properly in 16-bit mode. A valid NOP using 5 bytes would be 66 0F 1F 44 00 i.e.

{
ICLASS : NOP5
CPL : 3
CATEGORY : WIDENOP
EXTENSION : BASE
ISA_SET : FAT_NOP
PATTERN : 0x0F 0x1F 0x44 0x00 66_prefix mode16
OPERANDS :
PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode32
OPERANDS :
PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode64
OPERANDS :
}

Thanks.

@a0rland0 a0rland0 changed the title Possible bad segment register used with Ar21() Possible bugs in datafiles and xed code Dec 3, 2024
@kkhalail
Copy link

Hi, A few other things that might be wrong too (imo).

  1. In xed-decode.c the function "check_all_regs_match" should be ifdef'd with XED_ATTRIBUTE_NO_REG_MATCH_DEFINED instead of XED_ATTRIBUTE_NO_SRC_DEST_MATCH_DEFINED. This will make the code consistent with function xed_decode_finalize_operand_storage_fields.
  2. NOP5 (and NOP6, etc.) will not work properly in 16-bit mode. A valid NOP using 5 bytes would be 66 0F 1F 44 00 i.e.

{ ICLASS : NOP5 CPL : 3 CATEGORY : WIDENOP EXTENSION : BASE ISA_SET : FAT_NOP PATTERN : 0x0F 0x1F 0x44 0x00 66_prefix mode16 OPERANDS : PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode32 OPERANDS : PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode64 OPERANDS : }

Thanks.

Hi,
your input is greatly appreciated! The first issue has been fixed and will be updated in an upcoming release! Other issues will be under investigation soon.

@marjevan marjevan added accepted upcoming release A fix/support will be available with the upcoming external release labels Dec 23, 2024
@kkhalail
Copy link

Hi, In file "datafiles\xed-addressing-modes-new.txt" (line 483) shouldn't these lines be:

REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b01 | BASE0=Ar21() SEG0=FINAL_DSEG() DISP_WIDTH=8 REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b10 | BASE0=Ar21() SEG0=FINAL_DSEG() DISP_WIDTH=32

instead of:

REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b01 | BASE0=Ar21() SEG0=FINAL_SSEG() DISP_WIDTH=8 REXB4=1 REXB=0 SIBBASE=0b101 MOD=0b10 | BASE0=Ar21() SEG0=FINAL_SSEG() DISP_WIDTH=32

The same logic is applied to Ar13() and Ar29(), so I wonder if this is an error. Thanks.

Thanks for your contribution, time and effort! A fix will be available in an upcoming release.

@kkhalail
Copy link

Hi, A few other things that might be wrong too (imo).

  1. In xed-decode.c the function "check_all_regs_match" should be ifdef'd with XED_ATTRIBUTE_NO_REG_MATCH_DEFINED instead of XED_ATTRIBUTE_NO_SRC_DEST_MATCH_DEFINED. This will make the code consistent with function xed_decode_finalize_operand_storage_fields.
  2. NOP5 (and NOP6, etc.) will not work properly in 16-bit mode. A valid NOP using 5 bytes would be 66 0F 1F 44 00 i.e.

{ ICLASS : NOP5 CPL : 3 CATEGORY : WIDENOP EXTENSION : BASE ISA_SET : FAT_NOP PATTERN : 0x0F 0x1F 0x44 0x00 66_prefix mode16 OPERANDS : PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode32 OPERANDS : PATTERN : 0x0F 0x1F 0x44 0x00 0x00 mode64 OPERANDS : }

Thanks.

Regarding the FAT NOPS issue:
These instructions are known only to the encoder, basically to provide the ability to encode the SDM recommended multi-byte NOPs.
The SDM lists 2-byte NOPs and up to 9-byte NOPs recommended for modes 32 and 64 only. See reference below:
image

So we've decided that encoding of these instructions won't be supported in 16b mode. Nonetheless, I suggest the following unofficial workaround: you can always add a sequence of multiple ignored 66prefixes to the NOP in order to generate multi-byte NOPs in 16bit mode.

@a0rland0
Copy link
Author

Thank you for the fixes and explanations.

@marjevan marjevan added the bug label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug upcoming release A fix/support will be available with the upcoming external release
Projects
None yet
Development

No branches or pull requests

3 participants