Switch to the context of the kernel process in vm86_interrupt.
authorcoderain <coderain@sdf.org>
Sat, 8 Sep 2018 18:05:13 +0000 (20:05 +0200)
committercoderain <coderain@sdf.org>
Sat, 8 Sep 2018 18:05:13 +0000 (20:05 +0200)
kernel/src/vm86.c

index af28186a63312b7311e0f8060cdc1f816768b1fa..3f2c014f81c79ef9c0cb8cae6de9df8c6e26475f 100644 (file)
@@ -327,8 +327,8 @@ void vm86_handler(registers_ext_vm86_t *regs)
                 results->esi = regs->esi;
                 results->edi = regs->edi;
 
-                exception_return(*stack_regs);
-                ASSERT(FALSE);
+                memcpy(regs, stack_regs, sizeof(registers_t));
+                return;
             }
 
             regs->eip = peekw(regs->ss, regs->esp3);
@@ -449,6 +449,8 @@ dword_t vm86_interrupt(byte_t number, vm86_registers_t *regs)
     critical_t critical;
     enter_critical(&critical);
 
+    process_t *old_process = switch_process(kernel_process);
+
     dword_t ret = map_memory_internal(NULL, NULL, 0x100000, PAGE_PRESENT | PAGE_WRITABLE | PAGE_USERMODE);
     if (ret != ERR_SUCCESS) return ret;
 
@@ -468,6 +470,7 @@ dword_t vm86_interrupt(byte_t number, vm86_registers_t *regs)
     vm86_start(*regs, regs);
 
     unmap_memory_internal(NULL, 0x100000);
+    switch_process(old_process);
     leave_critical(&critical);
     return ERR_SUCCESS;
 }