diff options
author | 2019-06-07 14:03:31 -0700 | |
---|---|---|
committer | 2019-06-07 14:03:31 -0700 | |
commit | ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf (patch) | |
tree | d5b702310fd98c7ab7aa70a635e6b21c30a40a55 /src/bits64/segmentation.rs | |
parent | 29dc869cb6c35d35beca1207b92c601b606740b0 (diff) | |
download | rust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.tar.gz rust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.tar.zst rust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.zip |
Move swapgs to 64-bit only code.
Diffstat (limited to 'src/bits64/segmentation.rs')
-rw-r--r-- | src/bits64/segmentation.rs | 14 |
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"); +} |