Save/Restore shadow GS too while scheduling tasks

This commit is contained in:
Alex
2023-05-04 22:39:37 +03:00
parent 7abbc51d99
commit 533b945e84
4 changed files with 19 additions and 2 deletions

View File

@ -372,9 +372,22 @@ static int sys_fork(SyscallsFrame *Frame)
strncpy(NewThread->Name, Thread->Name, sizeof(Thread->Name));
NewThread->Info = Thread->Info;
NewThread->ShadowGSBase = Thread->ShadowGSBase;
NewThread->GSBase = Thread->GSBase;
NewThread->FSBase = Thread->FSBase;
TaskManager->Sleep(10); /* Re-schedule */
CriticalSection cs;
static int RetChild = 0;
#if defined(a86)
asmv("int $0x30"); /* This will trigger the IRQ16 instantly so we won't execute the next instruction */
#elif defined(aa64)
asmv("svc #0x30"); /* This will trigger the IRQ16 instantly so we won't execute the next instruction */
#endif
if (RetChild--)
return 0;
RetChild = 1;
NewThread->Registers = Thread->Registers;
debug("Forked thread \"%s\"(%d) from process \"%s\"(%d)", NewThread->Name, NewThread->ID, NewProcess->Name, NewProcess->ID);