Struct shadow_tsc::Tsc

source ·
#[repr(C)]
pub struct Tsc { pub cyclesPerSecond: u64, }
Expand description

Emulates an x86-64 processor’s timestamp counter, as read by rdtsc and rdtscp.

Fields§

§cyclesPerSecond: u64

Implementations§

source§

impl Tsc

source

pub fn native_cycles_per_second() -> Option<u64>

Returns the host system’s native TSC rate, or None if it couldn’t be found.

WARNING: this is known to fail completely on some supported CPUs (particularly AMD), and can return the wrong value for others. i.e. this needs more work if we need to dependably get the host’s TSC rate. e.g. see https://github.com/shadow/shadow/issues/1519.

source

pub fn new(cycles_per_second: u64) -> Self

source

pub fn emulate_rdtsc( &self, rax: &mut u64, rdx: &mut u64, rip: &mut u64, nanos: u64, )

Updates registers to reflect the result of executing an rdtsc instruction at time nanos.

source

pub fn emulate_rdtscp( &self, rax: &mut u64, rdx: &mut u64, rcx: &mut u64, rip: &mut u64, nanos: u64, )

Updates registers to reflect the result of executing an rdtscp instruction at time nanos.

source

pub unsafe fn ip_is_rdtsc(ip: *const u8) -> bool

Whether ip points to an rdtsc instruction.

§Safety

ip must be a dereferenceable pointer, pointing to the beginning of a valid x86_64 instruction.

source

pub unsafe fn ip_is_rdtscp(ip: *const u8) -> bool

Whether ip points to an rdtscp instruction.

§Safety

ip must be a dereferenceable pointer, pointing to the beginning of a valid x86_64 instruction.

Auto Trait Implementations§

§

impl Freeze for Tsc

§

impl RefUnwindSafe for Tsc

§

impl Send for Tsc

§

impl Sync for Tsc

§

impl Unpin for Tsc

§

impl UnwindSafe for Tsc

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.