about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-07-15 11:03:06 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-07-15 11:03:06 +0200
commit35119f8db219ad8b20ccd3f6952fd7164194c600 (patch)
treee502aefe606dd59405b7f18b4a080a787f6c3afc /src/emu
parentc95af7c81bd06f4fe241f8c71ffa8ef66e6b5b71 (diff)
downloadbox64-35119f8db219ad8b20ccd3f6952fd7164194c600.tar.gz
box64-35119f8db219ad8b20ccd3f6952fd7164194c600.zip
Handling HLT / CLI / STI has privileged instruction (and so trigger a GPF)
Diffstat (limited to 'src/emu')
-rwxr-xr-xsrc/emu/x64run.c15
-rwxr-xr-xsrc/emu/x64run_private.c5
2 files changed, 16 insertions, 4 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 92a0dc11..782ed520 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -1253,8 +1253,9 @@ x64emurun:
             break;
 
         case 0xF4:                      /* HLT */
-            // this is a privilege opcode... should an error be called instead?
-            sched_yield();
+            // this is a privilege opcode...
+            --R_RIP;
+            emit_signal(emu, SIGSEGV, (void*)R_RIP, 0);
             STEP;
             break;
         case 0xF5:                      /* CMC */
@@ -1370,10 +1371,16 @@ x64emurun:
             SET_FLAG(F_CF);
             break;
         case 0xFA:                      /* CLI */
-            CLEAR_FLAG(F_IF);   //not really handled...
+            // this is a privilege opcode...
+            --R_RIP;
+            emit_signal(emu, SIGSEGV, (void*)R_RIP, 0);
+            STEP;
             break;
         case 0xFB:                      /* STI */
-            SET_FLAG(F_IF);
+            // this is a privilege opcode...
+            --R_RIP;
+            emit_signal(emu, SIGSEGV, (void*)R_RIP, 0);
+            STEP;
             break;
         case 0xFC:                      /* CLD */
             CLEAR_FLAG(F_DF);
diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index ef697968..20d2c870 100755
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -1000,6 +1000,11 @@ void PrintTrace(x64emu_t* emu, uintptr_t ip, int dynarec)
         }
 #endif
         printf_log(LOG_NONE, "%s", DumpCPURegs(emu, ip));
+        if(R_RIP==0) {
+            printf_log(LOG_NONE, "Running at NULL address\n");
+            pthread_mutex_unlock(&my_context->mutex_trace);
+            return;
+        }
         if(PK(0)==0xcc && PK(1)=='S' && PK(2)=='C') {
             uint64_t a = *(uint64_t*)(ip+3);
             if(a==0) {