mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Some gate handlers may invoke Go runtime code that clobbers the XMM registers that could be in use by the code that triggered the gate handler. One case where this happens is when a growing a slice and the new location for the slice data resides in a RO page with a CoW flag. In this scenario, runtime.growslice will invoke runtime.memmove which may take a code path that uses XMM registers for copying data around. During the copy, a page fault occurs and the kernel page fault handler will detect the CoW flag, allocate a new frame and copy the original data to the new frame before resuming execution. As the page copy is performed using the built-in copy function this will cause the XMM registers to be clobbered. To prevent this from happening, the asm gate code that gets executed when an exception occurs will now preserve the XMM regs on the stack before invoking the registered exception handler. In addition, for Go 1.9+ the gate code will also temporarily disable use of AVX instructions by runtime.memmove by setting runtime.useAVXmemmove to 0. This is required so the gate does not need to also preserve any AVX registers.
8.3 KiB
8.3 KiB