- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to use rdmsr to read the MSRs like MSR_RAPL_POWER_UNIT, MSR_PP0_ENERGY_STATUS? etc.
static inline uint64_t rdmsr(uint64_t msr) { uint32_t low, high; asm volatile ( "rdmsr" : "=a"(low), "=d"(high) : "c"(msr) ); return ((uint64_t)high << 32) | low; }
I understand that reading and writing a MSR should not possible from user space and when I run the above function it showed "segmentation fault". So, I would like know if I can create a kernel module in order to enable the rdmsr/wrmsr for the ring 3 ?
Side note: this code source is to enable the rdpmc
https://github.com/softdevteam/user_rdpmc
Thank you for your time.
Regards,
Fadel
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you only need to read the core performance counters, then you can do that with the RDPMC instruction at user level if the system configuration bit CR4.PCE is set.
For Linux systems there is already a kernel device driver interface to allow user-mode programs to request MSR reads or writes. This is implemented in arch/x86/kernel/msr.c in the version of the kernel that I use.
There is also a project that replicates the kernel MSR infrastructure, but adds whitelisting and other security features -- https://github.com/LLNL/msr-safe
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page