Skip to content

Commit

Permalink
x86_64: add asm::rdmsr() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Sep 13, 2024
1 parent d279670 commit 1eb9209
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions oro-arch-x86_64/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,22 @@ pub fn strong_memory_barrier() {
asm!("mfence", options(nostack, preserves_flags),);
}
}

/// Reads the value of an MSR
#[inline(always)]
#[must_use]
pub fn rdmsr(msr: u32) -> u64 {
let val_a: u32;
let val_d: u32;
unsafe {
asm!(
"rdmsr",
in("ecx") msr,
out("eax") val_a,
out("edx") val_d,
options(nostack, preserves_flags)
);
}

(u64::from(val_d) << 32) | u64::from(val_a)
}

0 comments on commit 1eb9209

Please sign in to comment.