Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created April 9, 2014 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaisbetts/10226181 to your computer and use it in GitHub Desktop.
Save anaisbetts/10226181 to your computer and use it in GitHub Desktop.

The fly in this soup is, that switching the segmentation registers is actually far more expensive than changing CR3, so an operating system written this way would be quite slow.

This is why the segment registers are rigged in every modern OS to just be the entire valid address space. In fact, on amd64, CS/SS/DS/ES are all hard-coded to be this value. FS and GS are usually abused to do other tricky things - on Windows NT, FS is used as a pointer to the current thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment