diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-02-18 17:40:03 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-18 10:40:03 +0100 |
| commit | fb4662cb28f16c09542aca9e9a2dd50100f74879 (patch) | |
| tree | e73ef52a011805aec64d7f781eb3d53fc8d724f6 /src | |
| parent | 32a747979ad0ca0bba3aa97819daa63d1a5981ee (diff) | |
| download | box64-fb4662cb28f16c09542aca9e9a2dd50100f74879.tar.gz box64-fb4662cb28f16c09542aca9e9a2dd50100f74879.zip | |
[RV64_DYNAREC] Small changes to SET_DFNONE to make it safer ([LA64_DYNAREC] too) (#2382)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dynarec/la64/dynarec_la64_00.c | 6 | ||||
| -rw-r--r-- | src/dynarec/la64/dynarec_la64_helper.h | 8 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_00_3.c | 2 | ||||
| -rw-r--r-- | src/dynarec/rv64/dynarec_rv64_helper.h | 8 |
4 files changed, 14 insertions, 10 deletions
diff --git a/src/dynarec/la64/dynarec_la64_00.c b/src/dynarec/la64/dynarec_la64_00.c index 2b6c65ee..95e9b805 100644 --- a/src/dynarec/la64/dynarec_la64_00.c +++ b/src/dynarec/la64/dynarec_la64_00.c @@ -2684,7 +2684,7 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_NOFUSION); // TODO: handle zero divisor if (!rex.w) { - SET_DFNONE() + SET_DFNONE(); GETSED(0); SLLI_D(x3, xRDX, 32); ZEROUP2(x2, xRAX); @@ -2698,7 +2698,7 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni && dyn->insts[ninst - 1].x64.addr && *(uint8_t*)(dyn->insts[ninst - 1].x64.addr) == 0x48 && *(uint8_t*)(dyn->insts[ninst - 1].x64.addr + 1) == 0x99) { - SET_DFNONE() + SET_DFNONE(); GETED(0); DIV_D(x2, xRAX, ed); MOD_D(xRDX, xRAX, ed); @@ -2721,7 +2721,7 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni DIV_D(x2, xRAX, ed); MOD_D(xRDX, xRAX, ed); MV(xRAX, x2); - SET_DFNONE() + SET_DFNONE(); } } break; diff --git a/src/dynarec/la64/dynarec_la64_helper.h b/src/dynarec/la64/dynarec_la64_helper.h index 98be10b3..4199aef1 100644 --- a/src/dynarec/la64/dynarec_la64_helper.h +++ b/src/dynarec/la64/dynarec_la64_helper.h @@ -617,12 +617,14 @@ #define SET_DFNONE() \ do { \ - dyn->f.dfnone_here = 1; \ if (!dyn->f.dfnone) { \ ST_W(xZR, xEmu, offsetof(x64emu_t, df)); \ + } \ + if (!dyn->insts[ninst].x64.may_set) { \ + dyn->f.dfnone_here = 1; \ dyn->f.dfnone = 1; \ } \ - } while (0); + } while (0) #define SET_DF(S, N) \ if ((N) != d_none) { \ @@ -778,7 +780,7 @@ #define UFLAG_RES(A) \ if (dyn->insts[ninst].x64.gen_flags) { SDxw(A, xEmu, offsetof(x64emu_t, res)); } #define UFLAG_DF(r, A) \ - if (dyn->insts[ninst].x64.gen_flags) { SET_DF(r, A) } + if (dyn->insts[ninst].x64.gen_flags) { SET_DF(r, A); } #define UFLAG_IF if (dyn->insts[ninst].x64.gen_flags) #ifndef DEFAULT #define DEFAULT \ diff --git a/src/dynarec/rv64/dynarec_rv64_00_3.c b/src/dynarec/rv64/dynarec_rv64_00_3.c index ff8d67b9..b5181488 100644 --- a/src/dynarec/rv64/dynarec_rv64_00_3.c +++ b/src/dynarec/rv64/dynarec_rv64_00_3.c @@ -1385,7 +1385,7 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int INST_NAME("IDIV Ed"); SKIPTEST(x1); SETFLAGS(X_ALL, SF_SET, NAT_FLAGS_NOFUSION); - SET_DFNONE() + SET_DFNONE(); if (!rex.w) { GETSED(0); if (BOX64ENV(dynarec_div0)) { diff --git a/src/dynarec/rv64/dynarec_rv64_helper.h b/src/dynarec/rv64/dynarec_rv64_helper.h index 21f07db5..d02e7c71 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.h +++ b/src/dynarec/rv64/dynarec_rv64_helper.h @@ -860,12 +860,14 @@ #define SET_DFNONE() \ do { \ - dyn->f.dfnone_here = 1; \ if (!dyn->f.dfnone) { \ SW(xZR, xEmu, offsetof(x64emu_t, df)); \ + } \ + if (!dyn->insts[ninst].x64.may_set) { \ + dyn->f.dfnone_here = 1; \ dyn->f.dfnone = 1; \ } \ - } while (0); + } while (0) #define SET_DF(S, N) \ if ((N) != d_none) { \ @@ -1092,7 +1094,7 @@ #define UFLAG_RES(A) \ if (dyn->insts[ninst].x64.gen_flags) { SDxw(A, xEmu, offsetof(x64emu_t, res)); } #define UFLAG_DF(r, A) \ - if (dyn->insts[ninst].x64.gen_flags) { SET_DF(r, A) } + if (dyn->insts[ninst].x64.gen_flags) { SET_DF(r, A); } #define UFLAG_IF if (dyn->insts[ninst].x64.gen_flags) #ifndef DEFAULT #define DEFAULT \ |