aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <mail@gerdzellweger.com> 2019-06-07 14:03:31 -0700
committerGravatar Gerd Zellweger <mail@gerdzellweger.com> 2019-06-07 14:03:31 -0700
commitebf98fbaaa8d0a3ce3a700c64667b18edf962eaf (patch)
treed5b702310fd98c7ab7aa70a635e6b21c30a40a55
parent29dc869cb6c35d35beca1207b92c601b606740b0 (diff)
downloadrust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.tar.gz
rust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.tar.zst
rust-x86-ebf98fbaaa8d0a3ce3a700c64667b18edf962eaf.zip
Move swapgs to 64-bit only code.
-rw-r--r--src/bits64/segmentation.rs14
-rw-r--r--src/msr.rs3
-rw-r--r--src/segmentation.rs11
3 files changed, 14 insertions, 14 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");
+}
diff --git a/src/msr.rs b/src/msr.rs
index f2824b1..301b11f 100644
--- a/src/msr.rs
+++ b/src/msr.rs
@@ -3178,9 +3178,6 @@ pub const IA32_FS_BASE: u32 = 0xc0000100;
/// Map of BASE Address of GS (R/W) See Table 35-2.
pub const IA32_GS_BASE: u32 = 0xc0000101;
-/// If CPUID.80000001.EDX.\[bit 29\] = 1
-pub const IA32_KERNEL_GS_BASE: u32 = 0xc0000102;
-
/// Swap Target of BASE Address of GS (R/W) See Table 35-2.
pub const IA32_KERNEL_GSBASE: u32 = 0xc0000102;
diff --git a/src/segmentation.rs b/src/segmentation.rs
index 4b08b99..8757add 100644
--- a/src/segmentation.rs
+++ b/src/segmentation.rs
@@ -568,17 +568,6 @@ 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::*;