Hi,
I was writing some code to read the internal temperature sensor of an Intel Core2 Duo processor which requires to read some MSRs.
When I tried to read a MSR with inline assembly code I always ended up getting a "Segmentation fault". Here's the code I used:
Searching google in order to identify the problem I found out that writing and reading MSRs is only possible for the kernel because it needs to executed from within protection ring 0.Code:#define rdmsr(msr,val1,val2) __asm__ __volatile__("rdmsr" : "=a" (val1), "=d" (val2) : "c" (msr))
I understand that writing a MSR shouldn't be possible from userspace, but why does reading a MSR require running in protection ring 0?
BTW: I am using /dev/cpu/*/msr instead now, but I'm curious to know why reading a MSR is such a problem...
Peter