From 02cbe6a2980e97144a90547b505b47a0f3b37e60 Mon Sep 17 00:00:00 2001 From: Andrei Vlad LUTAS Date: Tue, 27 Feb 2024 09:45:05 +0200 Subject: [PATCH] https://github.com/bitdefender/bddisasm/issues/87 - added missing `R` access for the `rIP` operand for `SYSCALL` instructions; added missing `SCS`, `rCX` and `rDX` operands for `SYSEXIT` instruction. --- bddisasm/include/bdx86_instructions.h | 7 +++++-- bddisasm_test/x86/basic/branch_32.result | 3 +++ bddisasm_test/x86/basic/branch_64.result | 5 ++++- bddisasm_test/x86/special/invalid_32_skip.result | 2 +- bddisasm_test/x86/special/only_64.result | 2 +- bddisasm_test/x86/special/regressions_32.result | 2 +- bindings/pybddisasm/setup.py | 2 +- inc/bddisasm_version.h | 2 +- isagenerator/instructions/table_legacy_1.dat | 4 ++-- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bddisasm/include/bdx86_instructions.h b/bddisasm/include/bdx86_instructions.h index b5b0fb1..671b964 100644 --- a/bddisasm/include/bdx86_instructions.h +++ b/bddisasm/include/bdx86_instructions.h @@ -72478,7 +72478,7 @@ const ND_IDBE gInstructions[4075] = OP(ND_OPT_rCX, ND_OPS_q, ND_OPF_OPDEF, ND_OPA_W, 0, 0), OP(ND_OPT_rR11, ND_OPS_q, ND_OPF_OPDEF, ND_OPA_W, 0, 0), OP(ND_OPT_CS, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_W, 0, 0), - OP(ND_OPT_rIP, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_W, 0, 0), + OP(ND_OPT_rIP, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_RW, 0, 0), OP(ND_OPT_F, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_RW, 0, 0), OP(ND_OPT_SSP, ND_OPS_yf, ND_OPF_OPDEF, ND_OPA_RW, 0, 0), }, @@ -72527,7 +72527,7 @@ const ND_IDBE gInstructions[4075] = .ValidPrefixes = 0, .ValidModes = ND_MOD_R0|ND_MOD_PROT|ND_MOD_COMPAT|ND_MOD_LONG|ND_MOD_VMXR|ND_MOD_VMXN|ND_MOD_VMXR_SEAM|ND_MOD_VMXN_SEAM|ND_MOD_VMX_OFF|ND_MOD_SMM|ND_MOD_SMM_OFF|ND_MOD_SGX_OFF|ND_MOD_TSX|ND_MOD_TSX_OFF, .ValidDecorators = 0, - .OpsCount = ND_OPS_CNT(0, 5), + .OpsCount = ND_OPS_CNT(0, 8), .TupleType = 0, .ExcType = 0, .FpuFlags = 0, @@ -72545,6 +72545,9 @@ const ND_IDBE gInstructions[4075] = OP(ND_OPT_CS, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_W, 0, 0), OP(ND_OPT_rIP, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_W, 0, 0), OP(ND_OPT_SSP, ND_OPS_yf, ND_OPF_OPDEF, ND_OPA_W, 0, 0), + OP(ND_OPT_SCS, ND_OPS_q, ND_OPF_OPDEF, ND_OPA_R, 0, 0), + OP(ND_OPT_rCX, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_R, 0, 0), + OP(ND_OPT_rDX, ND_OPS_v, ND_OPF_OPDEF, ND_OPA_R, 0, 0), }, }, diff --git a/bddisasm_test/x86/basic/branch_32.result b/bddisasm_test/x86/basic/branch_32.result index c084456..dd26aff 100644 --- a/bddisasm_test/x86/basic/branch_32.result +++ b/bddisasm_test/x86/basic/branch_32.result @@ -827,4 +827,7 @@ Operand: 2, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 1, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: IP, RegSize: 4, RegId: 0, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: SSP, RegSize: 4, RegId: 0, RegCount: 1 + Operand: 5, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000174, RegCount: 1 + Operand: 6, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 + Operand: 7, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 diff --git a/bddisasm_test/x86/basic/branch_64.result b/bddisasm_test/x86/basic/branch_64.result index a8be11f..088a059 100644 --- a/bddisasm_test/x86/basic/branch_64.result +++ b/bddisasm_test/x86/basic/branch_64.result @@ -586,7 +586,7 @@ Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 Operand: 6, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Segment, RegSize: 8, RegId: 1, RegCount: 1 - Operand: 7, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: IP, RegSize: 8, RegId: 0, RegCount: 1 + Operand: 7, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: IP, RegSize: 8, RegId: 0, RegCount: 1 Operand: 8, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1 Operand: 9, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: SSP, RegSize: 8, RegId: 0, RegCount: 1 @@ -608,4 +608,7 @@ Operand: 2, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Segment, RegSize: 8, RegId: 1, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: IP, RegSize: 8, RegId: 0, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: SSP, RegSize: 8, RegId: 0, RegCount: 1 + Operand: 5, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000174, RegCount: 1 + Operand: 6, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 + Operand: 7, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 2, RegCount: 1 diff --git a/bddisasm_test/x86/special/invalid_32_skip.result b/bddisasm_test/x86/special/invalid_32_skip.result index 59cfc55..6a5ede1 100644 --- a/bddisasm_test/x86/special/invalid_32_skip.result +++ b/bddisasm_test/x86/special/invalid_32_skip.result @@ -21,7 +21,7 @@ Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 Operand: 6, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 7, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: IP, RegSize: 4, RegId: 0, RegCount: 1 + Operand: 7, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: IP, RegSize: 4, RegId: 0, RegCount: 1 Operand: 8, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Flags, RegSize: 4, RegId: 0, RegCount: 1 Operand: 9, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: SSP, RegSize: 4, RegId: 0, RegCount: 1 diff --git a/bddisasm_test/x86/special/only_64.result b/bddisasm_test/x86/special/only_64.result index 0f60743..4e20f2e 100644 --- a/bddisasm_test/x86/special/only_64.result +++ b/bddisasm_test/x86/special/only_64.result @@ -80,7 +80,7 @@ Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 Operand: 6, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Segment, RegSize: 8, RegId: 1, RegCount: 1 - Operand: 7, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: IP, RegSize: 8, RegId: 0, RegCount: 1 + Operand: 7, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: IP, RegSize: 8, RegId: 0, RegCount: 1 Operand: 8, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1 Operand: 9, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: SSP, RegSize: 8, RegId: 0, RegCount: 1 diff --git a/bddisasm_test/x86/special/regressions_32.result b/bddisasm_test/x86/special/regressions_32.result index 0e51ca5..1babbfd 100644 --- a/bddisasm_test/x86/special/regressions_32.result +++ b/bddisasm_test/x86/special/regressions_32.result @@ -102,7 +102,7 @@ Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 Operand: 6, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 7, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: IP, RegSize: 4, RegId: 0, RegCount: 1 + Operand: 7, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: IP, RegSize: 4, RegId: 0, RegCount: 1 Operand: 8, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Flags, RegSize: 4, RegId: 0, RegCount: 1 Operand: 9, Acc: RW, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: SSP, RegSize: 4, RegId: 0, RegCount: 1 diff --git a/bindings/pybddisasm/setup.py b/bindings/pybddisasm/setup.py index 6e48974..f07cafa 100644 --- a/bindings/pybddisasm/setup.py +++ b/bindings/pybddisasm/setup.py @@ -12,7 +12,7 @@ from setuptools import find_packages, setup, Command, Extension, Distribution from codecs import open VERSION = (0, 3, 0) -LIBRARY_VERSION = (2, 1, 1) +LIBRARY_VERSION = (2, 1, 2) DIR_INCLUDE = '../../inc' here = os.path.abspath(os.path.dirname(__file__)) diff --git a/inc/bddisasm_version.h b/inc/bddisasm_version.h index b3832b2..9c02624 100644 --- a/inc/bddisasm_version.h +++ b/inc/bddisasm_version.h @@ -7,7 +7,7 @@ #define DISASM_VERSION_MAJOR 2 #define DISASM_VERSION_MINOR 1 -#define DISASM_VERSION_REVISION 1 +#define DISASM_VERSION_REVISION 2 #define SHEMU_VERSION_MAJOR DISASM_VERSION_MAJOR #define SHEMU_VERSION_MINOR DISASM_VERSION_MINOR diff --git a/isagenerator/instructions/table_legacy_1.dat b/isagenerator/instructions/table_legacy_1.dat index fb527af..65be382 100644 --- a/isagenerator/instructions/table_legacy_1.dat +++ b/isagenerator/instructions/table_legacy_1.dat @@ -92,7 +92,7 @@ LAR ; Gv,Rz ; Fv ; 0x0F 0x02 /r:r LSL ; Gv,Mw ; Fv ; 0x0F 0x03 /r:mem ; s:I286PROT, t:SYSTEM, w:RW|R|W, f:ZF=m, m:NOREAL LSL ; Gv,Rz ; Fv ; 0x0F 0x03 /r:reg ; s:I286PROT, t:SYSTEM, w:RW|R|W, f:ZF=m, m:NOREAL #LOADALL ; ; BANK ; 0x0F 0x05 ; s:I486REAL, t:UNDOC, w:R -SYSCALL ; ; STAR,LSTAR,FMASK,SS,RCX,R11,CS,rIP,Fv,SSP ; 0x0F 0x05 ; s:AMD, t:SYSCALL, w:R|R|R|W|W|W|W|W|RW|RW, a:F64|CETT, i:FSC, m:NOSGX +SYSCALL ; ; STAR,LSTAR,FMASK,SS,RCX,R11,CS,rIP,Fv,SSP ; 0x0F 0x05 ; s:AMD, t:SYSCALL, w:R|R|R|W|W|W|W|RW|RW|RW, a:F64|CETT, i:FSC, m:NOSGX CLTS ; ; CR0 ; 0x0F 0x06 ; s:I286REAL, t:SYSTEM, w:W, m:KERNEL|NOV86 #LOADALLD ; ; BANK ; 0x0F 0x07 ; s:I486REAL, t:UNDOC, w:R SYSRET ; ; STAR,SS,rCX,R11,CS,rIP,Fv,SSP ; 0x0F 0x07 ; s:AMD, t:SYSRET, w:R|W|R|R|W|W|W|W, i:FSC, m:KERNEL @@ -290,7 +290,7 @@ RDTSC ; ; EAX,EDX,TSC ; 0x0F 0x31 RDMSR ; ; EAX,EDX,ECX,MSR ; 0x0F 0x32 ; s:PENTIUMREAL, t:SYSTEM, w:W|W|R|R, m:KERNEL|NOV86, i:MSR, a:NOREX2 RDPMC ; ; EAX,EDX,ECX,MSR ; 0x0F 0x33 ; s:RDPMC, t:SYSTEM, w:W|W|R|R, m:NOSGX, a:NOREX2 SYSENTER ; ; SCS,SESP,SEIP,SS,sSP,CS,rIP,Fv,SSP ; 0x0F 0x34 ; s:PPRO, t:SYSCALL, w:R|R|R|W|W|W|W|W|RW, a:CETT|NOREX2, i:SEP, f:IF=0, m:NOREAL|NOSGX -SYSEXIT ; ; SS,sSP,CS,rIP,SSP ; 0x0F 0x35 ; s:PPRO, t:SYSRET, w:W|W|W|W|W|W, a:F64|NOREX2, i:SEP, m:KERNEL|NOREAL +SYSEXIT ; ; SS,sSP,CS,rIP,SSP,SCS,rCX,rDX ; 0x0F 0x35 ; s:PPRO, t:SYSRET, w:W|W|W|W|W|R|R|R, a:F64|NOREX2, i:SEP, m:KERNEL|NOREAL GETSEC ; ; EAX,EBX ; NP 0x0F 0x37 ; s:SMX, t:SYSTEM, w:RCW|R, m:KERNEL|NOREAL|NOSGX, a:NOREX2 # 0x40 - 0x4F