LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: Access MSR functions in userspace?
       [not found] <200802070059.m170xqHv008164@terminus.zytor.com>
@ 2008-02-07  1:09 ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-02-07  1:09 UTC (permalink / raw)
  To: Hasan Rashid; +Cc: 'Maxim Levitsky', linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Access MSR functions in userspace?
       [not found] <200802070037.m170b4Bb000579@terminus.zytor.com>
@ 2008-02-07  0:48 ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-02-07  0:48 UTC (permalink / raw)
  To: Hasan Rashid; +Cc: 'Maxim Levitsky', linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Access MSR functions in userspace?
  2008-02-06  4:00 ` Maxim Levitsky
@ 2008-02-06  5:59   ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-02-06  5:59 UTC (permalink / raw)
  To: Maxim Levitsky; +Cc: hasan, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Access MSR functions in userspace?
  2008-02-06  3:29 Hasan Rashid
@ 2008-02-06  4:00 ` Maxim Levitsky
  2008-02-06  5:59   ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Maxim Levitsky @ 2008-02-06  4:00 UTC (permalink / raw)
  To: hasan; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Access MSR functions in userspace?
@ 2008-02-06  3:29 Hasan Rashid
  2008-02-06  4:00 ` Maxim Levitsky
  0 siblings, 1 reply; 5+ messages in thread
From: Hasan Rashid @ 2008-02-06  3:29 UTC (permalink / raw)
  To: linux-kernel

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-02-07  1:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200802070059.m170xqHv008164@terminus.zytor.com>
2008-02-07  1:09 ` Access MSR functions in userspace? H. Peter Anvin
     [not found] <200802070037.m170b4Bb000579@terminus.zytor.com>
2008-02-07  0:48 ` H. Peter Anvin
2008-02-06  3:29 Hasan Rashid
2008-02-06  4:00 ` Maxim Levitsky
2008-02-06  5:59   ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).