Is there a way to use RDMSR and WRMSR in userspace? I only need to write
to one register, writing a module with a userspace piece to handle that
seems like an over kill.
TIA!
--
Regards, Hasan R.
On Wednesday, 6 February 2008 05:29:47 Hasan Rashid wrote:
> Is there a way to use RDMSR and WRMSR in userspace? I only need to write
> to one register, writing a module with a userspace piece to handle that
> seems like an over kill.
>
> TIA!
Fortunately linux have /dev/cpu/*/msr
Take look at $LINUX_SOURCES/arch/x86/kernel/msr.c to learn how to use it.
Best regards,
Maxim Levitsky
Maxim Levitsky wrote:
> On Wednesday, 6 February 2008 05:29:47 Hasan Rashid wrote:
>> Is there a way to use RDMSR and WRMSR in userspace? I only need to write
>> to one register, writing a module with a userspace piece to handle that
>> seems like an over kill.
>>
>> TIA!
>
>
> Fortunately linux have /dev/cpu/*/msr
> Take look at $LINUX_SOURCES/arch/x86/kernel/msr.c to learn how to use it.
>
You might also find these useful:
http://www.kernel.org/pub/linux/utils/cpu/msr-tools/msr-tools-1.1.2.tar.bz2
-hpa
Hasan Rashid wrote:
> Maxim, HPA,
>
> I loaded the module msr.o and when I try to use wrmsr or rdmsr from the msr
> tools I get rdmsr: open: No such device. It seems like device doesn't
> register upon module load. I have created the devices on the system using
> mknod. Meaning /dev/cpu/msr is there and I changed the appropriate path in
> the msr.c(module) and wrmsr.c (utlity) file.
>
> What would prompt this error message?
>
/dev/cpu/msr is bogus. It should be /dev/cpu/0/msr etc.
Sounds like your version of udev might be out of date, or you're using
an old kernel which doesn't communicate /dev/cpu/* to udev properly.
Revert your hacks and, if you have to create the nodes manually, use the
MAKEDEV script included with the msr-tools.
-hpa
Hasan Rashid wrote:
> I am using kernel 2.4.32. Inside msr.c it is trying to register cpu/msr as
> shown here.
>
> int __init msr_init(void)
> {
> if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
> printk(KERN_ERR "msr: unable to get major %d for msr\n",
> MSR_MAJOR);
> return -EBUSY;
> }
>
> return 0;
> }
>
> I did use the MAKEDEV script with the tools but since the msr module isn't
> trying to register at any of those locations, they don't work.
Nonsense. All that matters is major:minor.
> There is only one processor on my board, I am going to register device under
> cpu/0/msr and see if that solves the issue.
It's irrelevant where it "registers" (on your kernel it only affects
/proc/devices, nothing else, unless you're using devfs, in which case,
well, don't.) The MAKEDEV script with the tools creates the appropriate
device entries.
-hpa