Skip to content

Commit

Permalink
[INTERP] Fixed overflow checking for convertion opcodes (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco authored Oct 29, 2024
1 parent 2aff423 commit 8807b1a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/emu/x64run660f.c
Original file line number Diff line number Diff line change
Expand Up @@ -2389,11 +2389,11 @@ uintptr_t Run660F(x64emu_t *emu, rex_t rex, uintptr_t addr)
nextop = F8;
GETEX(0);
GETGX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GX->sd[0] = 0x80000000;
else
GX->sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>(double)0x7fffffff)
GX->sd[1] = 0x80000000;
else
GX->sd[1] = EX->d[1];
Expand Down
8 changes: 4 additions & 4 deletions src/emu/x64runavx660f.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,21 +1714,21 @@ uintptr_t RunAVX_660F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGX;
GETGY;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GX->sd[0] = 0x80000000;
else
GX->sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>(double)0x7fffffff)
GX->sd[1] = 0x80000000;
else
GX->sd[1] = EX->d[1];
if(vex.l) {
GETEY;
if(isnan(EY->d[0]) || isinf(EY->d[0]) || EY->d[0]>0x7fffffff)
if(isnan(EY->d[0]) || isinf(EY->d[0]) || EY->d[0]>(double)0x7fffffff)
GX->sd[2] = 0x80000000;
else
GX->sd[2] = EY->d[0];
if(isnan(EY->d[1]) || isinf(EY->d[1]) || EY->d[1]>0x7fffffff)
if(isnan(EY->d[1]) || isinf(EY->d[1]) || EY->d[1]>(double)0x7fffffff)
GX->sd[3] = 0x80000000;
else
GX->sd[3] = EY->d[1];
Expand Down
8 changes: 4 additions & 4 deletions src/emu/x64runavxf20f.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->d[0];
else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->d[0];
Expand All @@ -136,7 +136,7 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w) {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand All @@ -158,7 +158,7 @@ uintptr_t RunAVX_F20F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
break;
}
} else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand Down
6 changes: 3 additions & 3 deletions src/emu/x64runavxf30f.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if (rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->f[0];
} else {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffff)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->f[0];
Expand All @@ -159,7 +159,7 @@ uintptr_t RunAVX_F30F(x64emu_t *emu, vex_t vex, uintptr_t addr, int *step)
GETEX(0);
GETGD;
if(rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand Down
8 changes: 4 additions & 4 deletions src/emu/x64runf20f.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
_GETEX(0);
GETGD;
if(rex.w)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->d[0];
else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->d[0];
Expand All @@ -110,7 +110,7 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
_GETEX(0);
GETGD;
if(rex.w) {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffffffffffffLL)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>=(double)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand All @@ -132,7 +132,7 @@ uintptr_t RunF20F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
break;
}
} else {
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>(double)0x7fffffff)
GD->dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand Down
6 changes: 3 additions & 3 deletions src/emu/x64runf30f.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ uintptr_t RunF30F(x64emu_t *emu, rex_t rex, uintptr_t addr)
GETEX(0);
GETGD;
if (rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
GD->sq[0] = EX->f[0];
} else {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffff)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffff)
GD->dword[0] = 0x80000000;
else
GD->sdword[0] = EX->f[0];
Expand All @@ -121,7 +121,7 @@ uintptr_t RunF30F(x64emu_t *emu, rex_t rex, uintptr_t addr)
GETEX(0);
GETGD;
if(rex.w) {
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>(float)0x7fffffffffffffffLL)
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>=(float)0x7fffffffffffffffLL)
GD->q[0] = 0x8000000000000000LL;
else
switch(emu->mxcsr.f.MXCSR_RC) {
Expand Down

0 comments on commit 8807b1a

Please sign in to comment.