mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Kernel: Fix accidental restore of bogus FPU state after fork
Cloned threads (basically, forked processes) inherit the complete FPU state of their origin thread. There was a bug in the lazy FPU state save/restore mechanism where a cloned thread would believe it had a buffer full of valid FPU state (because the inherited flag said so) but the origin thread had never actually copied any FPU state into it. This patch fixes that by forcing out an FPU state save after doing the initial FPU initialization (FNINIT) in a thread. :^)
This commit is contained in:
parent
40beb4c5c0
commit
44fb71261a
1 changed files with 2 additions and 0 deletions
|
@ -221,6 +221,8 @@ void exception_7_handler(RegisterDump& regs)
|
|||
asm volatile("fxrstor %0" ::"m"(current->fpu_state()));
|
||||
} else {
|
||||
asm volatile("fninit");
|
||||
asm volatile("fxsave %0"
|
||||
: "=m"(g_last_fpu_thread->fpu_state()));
|
||||
current->set_has_used_fpu(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue