From bfb3a5066117205a0adaf39be1089f5ad5080f2d Mon Sep 17 00:00:00 2001 From: Sree24-ui Date: Sun, 11 Oct 2026 20:23:15 +0530 Subject: [PATCH] X86: Correct memory access for FPU and MXCSR stores (#3112) Co-authored-by: Sree24-ui --- arch/X86/X86MappingInsnOp.inc | 28 ++-- tests/details/x86.yaml | 242 ++++++++++++++++++++++++++++++++++ 2 files changed, 256 insertions(+), 14 deletions(-) diff --git a/arch/X86/X86MappingInsnOp.inc b/arch/X86/X86MappingInsnOp.inc index 868638ace..9b54da750 100644 --- a/arch/X86/X86MappingInsnOp.inc +++ b/arch/X86/X86MappingInsnOp.inc @@ -3935,7 +3935,7 @@ { /* X86_FNSTCW16m, X86_INS_FNSTCW: fnstcw */ X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C1 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_FNSTSW16r, X86_INS_FNSTSW: fnstsw */ @@ -4570,17 +4570,17 @@ { /* X86_ISTT_FP16m, X86_INS_FISTTP: fisttp */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ISTT_FP32m, X86_INS_FISTTP: fisttp */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ISTT_FP64m, X86_INS_FISTTP: fisttp */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ISTT_Fp16m32, X86_INS_FISTTP: fisttp */ @@ -4630,22 +4630,22 @@ { /* X86_IST_F16m, X86_INS_FIST: fist */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_IST_F32m, X86_INS_FIST: fist */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_IST_FP16m, X86_INS_FISTP: fistp */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_IST_FP32m, X86_INS_FISTP: fistp */ X86_FPU_FLAGS_RESET_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_IST_FP64m, X86_INS_FISTP: fistp */ @@ -12725,7 +12725,7 @@ { /* X86_STMXCSR, X86_INS_STMXCSR: stmxcsr */ 0, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_STOSB, X86_INS_STOSB: stosb */ @@ -12770,22 +12770,22 @@ { /* X86_ST_F32m, X86_INS_FST: fst */ X86_FPU_FLAGS_MODIFY_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ST_F64m, X86_INS_FST: fst */ X86_FPU_FLAGS_MODIFY_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ST_FP32m, X86_INS_FSTP: fstp */ X86_FPU_FLAGS_MODIFY_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ST_FP64m, X86_INS_FSTP: fstp */ X86_FPU_FLAGS_MODIFY_C1 | X86_FPU_FLAGS_UNDEFINED_C0 | X86_FPU_FLAGS_UNDEFINED_C2 | X86_FPU_FLAGS_UNDEFINED_C3, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_ST_FP80m, X86_INS_FSTP: fstp */ @@ -73620,7 +73620,7 @@ { /* X86_VSTMXCSR, X86_INS_VSTMXCSR: vstmxcsr */ 0, - { CS_AC_READ, 0 } + { CS_AC_WRITE, 0 } }, { /* X86_VSUBPDYrm, X86_INS_VSUBPD: vsubpd */ diff --git a/tests/details/x86.yaml b/tests/details/x86.yaml index ba87baee4..4e78dbfef 100644 --- a/tests/details/x86.yaml +++ b/tests/details/x86.yaml @@ -7552,3 +7552,245 @@ test_cases: size: 4 access: CS_AC_READ regs_read: [ ax, ebx ] + - + input: + bytes: [0xd9, 0x13, 0xdd, 0x13, 0xd9, 0x1b, 0xdd, 0x1b] + arch: "x86" + options: [ CS_OPT_DETAIL, CS_MODE_32 ] + address: 0x1000 + expected: + insns: + - + asm_text: "fst dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "fst qword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 8 + access: CS_AC_WRITE + - + asm_text: "fstp dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "fstp qword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 8 + access: CS_AC_WRITE + - + input: + bytes: [0xdf, 0x13, 0xdb, 0x13, 0xdf, 0x1b, 0xdb, 0x1b, 0xdf, 0x0b, 0xdb, 0x0b, 0xdd, 0x0b] + arch: "x86" + options: [ CS_OPT_DETAIL, CS_MODE_32 ] + address: 0x1000 + expected: + insns: + - + asm_text: "fist word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_WRITE + - + asm_text: "fist dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "fistp word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_WRITE + - + asm_text: "fistp dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "fisttp word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_WRITE + - + asm_text: "fisttp dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "fisttp qword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 8 + access: CS_AC_WRITE + - + input: + bytes: [0xd9, 0x3b, 0x0f, 0xae, 0x1b, 0xc5, 0xf8, 0xae, 0x1b] + arch: "x86" + options: [ CS_OPT_DETAIL, CS_MODE_32 ] + address: 0x1000 + expected: + insns: + - + asm_text: "fnstcw word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_WRITE + - + asm_text: "stmxcsr dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + asm_text: "vstmxcsr dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_WRITE + - + input: + bytes: [0xdb, 0x3b, 0xdf, 0x3b, 0xdd, 0x3b, 0xd9, 0x03, 0xd9, 0x2b, 0x0f, 0xae, 0x13, 0xc5, 0xf8, 0xae, 0x13] + arch: "x86" + options: [ CS_OPT_DETAIL, CS_MODE_32 ] + address: 0x1000 + expected: + insns: + - + asm_text: "fstp xword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 10 + access: CS_AC_WRITE + - + asm_text: "fistp qword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 8 + access: CS_AC_WRITE + - + asm_text: "fnstsw word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_WRITE + - + asm_text: "fld dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_READ + - + asm_text: "fldcw word ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 2 + access: CS_AC_READ + - + asm_text: "ldmxcsr dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_READ + - + asm_text: "vldmxcsr dword ptr [ebx]" + details: + x86: + operands: + - + type: X86_OP_MEM + mem_base: ebx + size: 4 + access: CS_AC_READ