-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LibOS] Rewire RIP of to-save and to-restore contexts for VM PALs
Previously, the LibOS logic had two places that assumed ring-3 environment and did not account for the need to execute `sysret`/`iretq`: - Preparing sigframes for the application signal handler; the interrupted app context is saved in the sigframe. - Performing `rt_sigreturn()` syscall after the application signal handler is done; the app context is restored from the previously-saved sigframe. In case of VM-based PALs, where LibOS runs in ring-0 and app runs in ring-3, there are wrappers around syscall enter/exit, see `syscall_asm` and `sysret_asm`/`sigreturn_asm` in vm-common/kernel_events.S file. These wrappers rewire the context RIP: upon syscall entry, `syscall_asm` saves the app context RIP into a TCB-local variable and sets RIP to the address of the `sysret_asm`/`sigreturn_asm` routine, and upon syscall exit, `sysret_asm`/`sigreturn_asm` restores app context RIP from the TCB-local variable. This wrapper rewiring was not accounted for in the LibOS logic, meaning that the LibOS would prepare the sigframe with RIP not of the app context but of the `sysret_asm`/`sigreturn_asm` routine. Similarly, the LibOS would restore not the app context's RIP but the RIP of `sysret_asm`/`sigreturn_asm`. This commit adds VM PAL-specific RIP fixups to the LibOS logic. Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
- Loading branch information
Showing
5 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters