-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure GDT. Add sysenter support #290
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for doing this cleanup! The comments in segment.h are especially helpful, I think!
Can you please rebase your branch, as some of the depending commits got merged?
ca0212e
to
9dbf6c3
Compare
b60cec7
to
9f8e9c2
Compare
This allows us to use syscall from inline asm without clobbering all callee-clobbered registers. Saving/restoring all registers also prevents "leaking" kernel register values into userland. Signed-off-by: Johannes Wikner <[email protected]>
The GDT entries needed to be re-organized to support sysexit. While doing so, better document why they exist in the first place, and their particular order. Rename __KERN_{CS,DS}16 -> __RMODE_{CS,DS}16 to clearly indicate that these entries only exist in the real mode GDT. Omit entries that are unused in i386 or unused for a particular gdt. Signed-off-by: Johannes Wikner <[email protected]>
user_cs should point to USER_CS32 so that correct %cs and %ss are set upon sysret and sysretq. This fixes a subtle bug which where branches using %cs (e.g., intra-mode iret) would crash after a syscall. Signed-off-by: Johannes Wikner <[email protected]>
Introduces the necessary MSRs, and sets them to handle sysenter and sysexits. Add macro to choose approriate instruction depending on build. When adding compatibility mode support, we need to use either sysexit or sysexitq depending on what usermode is executing. Same for sysret and sysretq. Signed-off-by: Johannes Wikner <[email protected]>
To give usermode the option to choose sysenter instead of syscall, we expose syscall_mode(enum syscall_mode), which is by default using syscall. Signed-off-by: Johannes Wikner <[email protected]>
From usermode's perspective it works the same as syscall. Signed-off-by: Johannes Wikner <[email protected]> Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, Johannes!
Based on #284. Request for comments on this.
In particular the GDT bit that had to be reworked a bit. Also, whether and how we should give the option to use sysenter instead of syscall.