Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: skip return address of <autogenerated> function wrapper in tr…
…apret before IRET instruction NOTE: this commit will ONLY work for Go 1.17, it is not backwards compatible with Go 1.16. We should probably find a way to handle both (e.g. build tags or a general approach). To give context, an <autogenerated> function wrapper is generated in Go 1.17 for kernel.trapret. Dump of assembler code for function github.com/icexin/eggos/kernel.trapret<autogenerated>: => 0x00000000002bbf60 <+0>: call 0x2b9e40 <github.com/icexin/eggos/kernel.trapret> 0x00000000002bbf65 <+5>: xorps %xmm15,%xmm15 0x00000000002bbf69 <+9>: mov %fs:0xfffffffffffffff8,%r14 0x00000000002bbf72 <+18>: ret In this autogenerated function, a call to the real kernel.trapret is made, which places a return address on the stack. However, the trapret function will use IRET to return, so to handle this case, we skip the return address pushed onto the stack by the autogenerated function by adding 8 (ptr size) to rsp. We should definitely try to find a better way to handle this situation as it seems very fragile and may break in the future if Go changes their autogenerated functions. So, once more, this is mostly to get intuition into the problem domain, it is not meant as a solution that should be merged into eggos.
- Loading branch information