diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | src/task.rs | 13 | ||||
-rw-r--r-- | src/tlb.rs | 2 |
3 files changed, 13 insertions, 6 deletions
@@ -90,7 +90,7 @@ pub enum Ring { /// Will cause a general protection fault if used outside of ring 0. #[inline(always)] pub unsafe fn halt() { - llvm_asm!("hlt" :::: "volatile"); + asm!("hlt", options(att_syntax, nomem, nostack)); // check if preserves_flags } #[cfg(all(test, feature = "vmtest"))] @@ -117,7 +117,7 @@ mod x86testing { #[inline(always)] pub unsafe fn rdpid() -> u64 { let mut pid: u64; - llvm_asm!("rdpid $0" : "=r"(pid)); + asm!("rdpid {pid}", pid = out(reg) pid, options(att_syntax)); pid } diff --git a/src/task.rs b/src/task.rs index a7b3423..d819e2d 100644 --- a/src/task.rs +++ b/src/task.rs @@ -4,9 +4,14 @@ pub use crate::segmentation; /// Returns the current value of the task register. -pub fn tr() -> segmentation::SegmentSelector { +/// +/// # Safety +/// Needs CPL 0. +pub unsafe fn tr() -> segmentation::SegmentSelector { let segment: u16; - unsafe { llvm_asm!("str $0" : "=r" (segment) ) }; + asm!("str {0:x}", + out(reg) segment, + options(att_syntax, nostack, nomem, preserves_flags)); segmentation::SegmentSelector::from_raw(segment) } @@ -15,5 +20,7 @@ pub fn tr() -> segmentation::SegmentSelector { /// # Safety /// Needs CPL 0. pub unsafe fn load_tr(sel: segmentation::SegmentSelector) { - llvm_asm!("ltr $0" :: "r" (sel.bits())); + asm!("ltr {0:x}", + in(reg) sel.bits(), + options(att_syntax, nostack, nomem, preserves_flags)); } @@ -6,7 +6,7 @@ /// This function is unsafe as it causes a general protection fault (GP) if the current privilege /// level is not 0. pub unsafe fn flush(addr: usize) { - llvm_asm!("invlpg ($0)" :: "r" (addr) : "memory"); + asm!("invlpg ({})", in(reg) addr, options(att_syntax, nostack, preserves_flags)); } /// Invalidate the TLB completely by reloading the CR3 register. |