gz / rust-x86

Rust library to use x86 (amd64) specific functionality and registers.

Home Page:https://docs.rs/x86

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segmentation fault.

cedws opened this issue · comments

The following code is causing a segmentation fault.

unsafe { wrmsr(0x150, 0x80000011ecc00000); }
    Finished dev [unoptimized + debuginfo] target(s) in 0.47 secs
     Running `target/debug/x86test`
Segmentation fault (core dumped)

Hi, Can you explain in more detail what exactly you're trying to do? What is x86test and at what privilege level does it run?

From the output it looks like you're trying to write an msr in CPL3 (user-space). That's not directly possible with this crate as it implements the (kernel mode) wrmsr instruction for writing to an MSR in the kernel.
If you want to modify MSRs on Linux in user-space, have a look at http://man7.org/linux/man-pages/man4/msr.4.html

@gz x86test is just a project for testing out this crate, it runs in userspace like you said. I'm looking to be able to write to MSR registers. Something like the wrmsr utility from msr-tools, but I want to do it programatically rather than call a binary. Thanks for letting me know that it won't work in this way.