about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-01-06 10:56:03 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-01-06 10:56:03 +0100
commited87cc1b1ead7129da93a09a6cbdbbf11d2c5e40 (patch)
tree3e7b7f265a9ea1ed6015ca0dad7b126f7f548d6b
parent5d6ff69e8d26026a6f527a6a606b7eb15b5baa60 (diff)
downloadbox64-ed87cc1b1ead7129da93a09a6cbdbbf11d2c5e40.tar.gz
box64-ed87cc1b1ead7129da93a09a6cbdbbf11d2c5e40.zip
[INTERPRETER] Improved 0F 01 opcode ([ARM64_DYNAREC] too)
-rw-r--r--src/dynarec/arm64/dynarec_arm64_0f.c34
-rw-r--r--src/emu/x64run0f.c21
2 files changed, 45 insertions, 10 deletions
diff --git a/src/dynarec/arm64/dynarec_arm64_0f.c b/src/dynarec/arm64/dynarec_arm64_0f.c
index 8a9aeb6c..5a2a35e7 100644
--- a/src/dynarec/arm64/dynarec_arm64_0f.c
+++ b/src/dynarec/arm64/dynarec_arm64_0f.c
@@ -63,17 +63,31 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
     switch(opcode) {

 

         case 0x01:

-            INST_NAME("FAKE xgetbv");

+            // TODO:, /0 is SGDT. While 0F 01 D0 is XGETBV, etc...

             nextop = F8;

-            addr = fakeed(dyn, addr, ninst, nextop);

-            SETFLAGS(X_ALL, SF_SET);    // Hack to set flags in "don't care" state

-            GETIP(ip);

-            STORE_XEMU_CALL(xRIP);

-            CALL(native_ud, -1);

-            LOAD_XEMU_CALL(xRIP);

-            jump_to_epilog(dyn, 0, xRIP, ninst);

-            *need_epilog = 0;

-            *ok = 0;

+            switch(nextop) {

+                case 0xD0:

+                    INST_NAME("FAKE xgetbv");

+                    SETFLAGS(X_ALL, SF_SET);    // Hack to set flags in "don't care" state

+                    GETIP(ip);

+                    STORE_XEMU_CALL(xRIP);

+                    CALL(native_ud, -1);

+                    LOAD_XEMU_CALL(xRIP);

+                    jump_to_epilog(dyn, 0, xRIP, ninst);

+                    *need_epilog = 0;

+                    *ok = 0;

+                    break;

+                default:

+                    switch((nextop>>3)&7) {

+                        case 0: // SGDT

+                            INST_NAME("FAKE sgdt Ed");

+                            addr = fakeed(dyn, addr, ninst, nextop);

+                                // do nothing for now...

+                            break;

+                        default:

+                            DEFAULT;

+                    }

+            }

             break;

 

         case 0x05:

diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c
index 3470c443..2fc24b47 100644
--- a/src/emu/x64run0f.c
+++ b/src/emu/x64run0f.c
@@ -55,6 +55,27 @@ uintptr_t Run0F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
 

     switch(opcode) {

 

+        case 0x01:                      /* XGETBV, SGDT, etc... */

+            // this is a privilege opcode...

+            nextop = F8;

+            GETED(0);

+            switch(nextop) {

+                case 0xD0:

+                #ifndef TEST_INTERPRETER

+                emit_signal(emu, SIGILL, (void*)R_RIP, 0);

+                #endif

+                break;

+                default:

+                    switch((nextop>>3)&7) {

+                        case 0: // SGDT

+                                // do nothing for now...

+                            break;

+                        default:

+                            return 0;

+                    }

+            }

+            break;

+

         case 0x05:                      /* SYSCALL */

             #ifndef TEST_INTERPRETER

             R_RIP = addr;