aboutsummaryrefslogtreecommitdiff
path: root/src/segmentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/segmentation.rs')
-rw-r--r--src/segmentation.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/segmentation.rs b/src/segmentation.rs
index 8757add..4b08b99 100644
--- a/src/segmentation.rs
+++ b/src/segmentation.rs
@@ -568,6 +568,17 @@ pub fn cs() -> SegmentSelector {
SegmentSelector::from_raw(segment)
}
+/// Swap the GS register.
+///
+/// Exchanges the current GS base register value with the value contained
+/// in MSR address IA32_KERNEL_GS_BASE.
+///
+/// # Unsafe
+/// The SWAPGS instruction is a privileged instruction intended for use by system software.
+pub unsafe fn swapgs() {
+ asm!("swapgs" ::: "gs");
+}
+
#[cfg(test)]
mod test {
use super::*;