aboutsummaryrefslogtreecommitdiff
path: root/src/bits64/segmentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bits64/segmentation.rs')
-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 978025f..d246f0f 100644
--- a/src/bits64/segmentation.rs
+++ b/src/bits64/segmentation.rs
@@ -169,3 +169,17 @@ pub unsafe fn rdfsbase() -> u64 {
asm!("rdfsbase $0" : "=r" (fs_base) );
fs_base
}
+
+/// Swap the GS register.
+///
+/// Exchanges the current GS base register value with the value contained
+/// in MSR address IA32_KERNEL_GS_BASE.
+///
+/// The SWAPGS instruction is available only in 64-bit mode.
+///
+/// # Unsafe
+/// The SWAPGS instruction is a privileged instruction intended for use by system software.
+#[cfg(target_arch = "x86_64")]
+pub unsafe fn swapgs() {
+ asm!("swapgs" ::: "gs");
+}