aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <gzellweger@vmware.com> 2020-04-03 18:32:09 -0700
committerGravatar Gerd Zellweger <mail@gerdzellweger.com> 2020-04-03 18:33:41 -0700
commit1a34443a5691625f0b6d033b17cb4fc467495b06 (patch)
tree3be08c471d60c4aacb4d48b7b93404414e237331
parent69647f0c20bab4f240682c2f0b07624ec5c78d2f (diff)
downloadrust-x86-1a34443a5691625f0b6d033b17cb4fc467495b06.tar.gz
rust-x86-1a34443a5691625f0b6d033b17cb4fc467495b06.tar.zst
rust-x86-1a34443a5691625f0b6d033b17cb4fc467495b06.zip
Shortcuts to load gs/fs contents.
-rw-r--r--src/bits64/segmentation.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bits64/segmentation.rs b/src/bits64/segmentation.rs
index 6d58a80..cf6ccbd 100644
--- a/src/bits64/segmentation.rs
+++ b/src/bits64/segmentation.rs
@@ -176,6 +176,20 @@ pub unsafe fn rdfsbase() -> u64 {
fs_base
}
+/// "Dereferences" the fs register at offset 0.
+pub unsafe fn fs_deref() -> u64 {
+ let fs: u64;
+ asm!("movq %fs:0x0, $0" : "=r" (fs) );
+ fs
+}
+
+/// "Dereferences" the gs register at offset 0.
+pub unsafe fn gs_deref() -> u64 {
+ let gs: u64;
+ asm!("movq %gs:0x0, $0" : "=r" (gs) );
+ gs
+}
+
/// Swap the GS register.
///
/// Exchanges the current GS base register value with the value contained