Skip to content

Commit

Permalink
[RV64_DYNAREC] Force priv opcode flags to be at least defered if safe…
Browse files Browse the repository at this point in the history
…flags=2 ([LA64_DYNREC] too)
  • Loading branch information
ksco committed Jan 24, 2025
1 parent 313e485 commit e303381
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
18 changes: 15 additions & 3 deletions src/dynarec/la64/dynarec_la64_00.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,11 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0x6C:
case 0x6D:
INST_NAME(opcode == 0x6C ? "INSB" : "INSD");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (box64_dynarec_safeflags > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL();
CALL(native_priv, -1);
Expand All @@ -676,7 +680,11 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
case 0x6E:
case 0x6F:
INST_NAME(opcode == 0x6C ? "OUTSB" : "OUTSD");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (box64_dynarec_safeflags > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL();
CALL(native_priv, -1);
Expand Down Expand Up @@ -2325,7 +2333,11 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
break;
case 0xF4:
INST_NAME("HLT");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (box64_dynarec_safeflags > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL();
CALL(native_priv, -1);
Expand Down
6 changes: 5 additions & 1 deletion src/dynarec/la64/dynarec_la64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ uintptr_t dynarec64_0F(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
break;
case 0x0B:
INST_NAME("UD2");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (box64_dynarec_safeflags > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL();
CALL(native_ud, -1);
Expand Down
12 changes: 10 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_00_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ uintptr_t dynarec64_00_1(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0x6C:
case 0x6D:
INST_NAME(opcode == 0x6C ? "INSB" : "INSD");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_priv, -1, 0, 0);
Expand All @@ -297,7 +301,11 @@ uintptr_t dynarec64_00_1(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
case 0x6E:
case 0x6F:
INST_NAME(opcode == 0x6C ? "OUTSB" : "OUTSD");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_priv, -1, 0, 0);
Expand Down
14 changes: 11 additions & 3 deletions src/dynarec/rv64/dynarec_rv64_00_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
jump_to_epilog(dyn, 0, xRIP, ninst);
} else if (u8 == 0x03) {
INST_NAME("INT 3");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(addr);
STORE_XEMU_CALL(x3);
CALL(native_int3, -1, 0, 0);
Expand All @@ -534,8 +538,12 @@ uintptr_t dynarec64_00_3(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int
*ok = 0;
} else {
INST_NAME("INT n");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
GETIP(ip); // priviledged instruction, IP not updated
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip); // priviledged instruction, IP not updated
STORE_XEMU_CALL(x3);
CALL(native_priv, -1, 0, 0);
LOAD_XEMU_CALL();
Expand Down
12 changes: 10 additions & 2 deletions src/dynarec/rv64/dynarec_rv64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni

case 0x09:
INST_NAME("WBINVD");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_ud, -1, 0, 0);
Expand All @@ -143,7 +147,11 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni

case 0x0B:
INST_NAME("UD2");
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
if (BOX64DRENV(dynarec_safeflags) > 1) {
READFLAGS(X_PEND);
} else {
SETFLAGS(X_ALL, SF_SET_NODF, NAT_FLAGS_NOFUSION); // Hack to set flags in "don't care" state
}
GETIP(ip);
STORE_XEMU_CALL(x3);
CALL(native_ud, -1, 0, 0);
Expand Down

0 comments on commit e303381

Please sign in to comment.