From: H. Peter Anvin on
On 11/17/2009 09:25 AM, Lennart Sorensen wrote:
> On Tue, Nov 17, 2009 at 11:48:47AM -0500, Valdis.Kletnieks(a)vt.edu wrote:
>> Umm... 'modprobe msr'?
>>
>> (Recently I had what *looked* like an xorg server bug, turned out to be a
>> missing CONFIG_INPUT_EVDEV.. Whoops. ;)
>
> I did. Makes no difference. If I unload it I get the same error.
>
> # modinfo msr
> filename: /lib/modules/2.6.26-2-gx1/kernel/arch/x86/kernel/msr.ko
> author: H. Peter Anvin <hpa(a)zytor.com>
> description: x86 generic MSR driver
> license: GPL
> vermagic: 2.6.26-2-gx1 mod_unload GEODEGX1
> depends:
>
> # lsmod |grep msr
> msr 2692 0
>
> I don't get it.
>

Does /dev/cpu/*/msr exist?

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lennart Sorensen on
On Tue, Nov 17, 2009 at 09:33:02AM -0800, H. Peter Anvin wrote:
> On 11/17/2009 09:25 AM, Lennart Sorensen wrote:
> > On Tue, Nov 17, 2009 at 11:48:47AM -0500, Valdis.Kletnieks(a)vt.edu wrote:
> >> Umm... 'modprobe msr'?
> >>
> >> (Recently I had what *looked* like an xorg server bug, turned out to be a
> >> missing CONFIG_INPUT_EVDEV.. Whoops. ;)
> >
> > I did. Makes no difference. If I unload it I get the same error.
> >
> > # modinfo msr
> > filename: /lib/modules/2.6.26-2-gx1/kernel/arch/x86/kernel/msr.ko
> > author: H. Peter Anvin <hpa(a)zytor.com>
> > description: x86 generic MSR driver
> > license: GPL
> > vermagic: 2.6.26-2-gx1 mod_unload GEODEGX1
> > depends:
> >
> > # lsmod |grep msr
> > msr 2692 0
> >
> > I don't get it.
> >
>
> Does /dev/cpu/*/msr exist?

I ran MAKEDEV cpu in /dev, but to make sure...

# ls -l /dev/cpu/*/msr
crw------- 1 root root 202, 0 Nov 16 12:28 /dev/cpu/0/msr
crw------- 1 root root 202, 1 Nov 16 12:28 /dev/cpu/1/msr
crw------- 1 root root 202, 2 Nov 16 12:28 /dev/cpu/2/msr
crw------- 1 root root 202, 3 Nov 16 12:28 /dev/cpu/3/msr

Looks OK too.

# strace ./rdmsr -x 0x00001810
execve("./rdmsr", ["./rdmsr", "-x", "0x00001810"], [/* 13 vars */]) = 0
uname({sys="Linux", node="ruggedrouter", ...}) = 0
brk(0) = 0x8106000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f23000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f22000
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=14975, ...}) = 0
mmap2(NULL, 14975, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f1e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240O\1"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1245488, ...}) = 0
mmap2(NULL, 1251484, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7dec000
mmap2(0xb7f14000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x128) = 0xb7f14000
mmap2(0xb7f1b000, 10396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f1b000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7deb000
mprotect(0xb7f14000, 20480, PROT_READ) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7deb6c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb7f1e000, 14975) = 0
open("/dev/cpu/0/msr", O_RDONLY|O_LARGEFILE) = 3
pread64(3, 0xbf83ac00, 8, 6160) = -1 EIO (Input/output error)
write(2, "rdmsr: CPU 0 cannot read MSR 0x0"..., 40rdmsr: CPU 0 cannot read MSR 0x00001810
) = 40
exit_group(4) = ?
Process 15044 detached

--
Len Sorensen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lennart Sorensen on
On Tue, Nov 17, 2009 at 01:33:57PM -0500, Lennart Sorensen wrote:
> # strace ./rdmsr -x 0x00001810
> execve("./rdmsr", ["./rdmsr", "-x", "0x00001810"], [/* 13 vars */]) = 0
> uname({sys="Linux", node="ruggedrouter", ...}) = 0
> brk(0) = 0x8106000
> access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f23000
> access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f22000
> open("/etc/ld.so.cache", O_RDONLY) = 3
> fstat64(3, {st_mode=S_IFREG|0644, st_size=14975, ...}) = 0
> mmap2(NULL, 14975, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f1e000
> close(3) = 0
> access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
> open("/lib/tls/libc.so.6", O_RDONLY) = 3
> read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240O\1"..., 512) = 512
> fstat64(3, {st_mode=S_IFREG|0644, st_size=1245488, ...}) = 0
> mmap2(NULL, 1251484, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7dec000
> mmap2(0xb7f14000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x128) = 0xb7f14000
> mmap2(0xb7f1b000, 10396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f1b000
> close(3) = 0
> mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7deb000
> mprotect(0xb7f14000, 20480, PROT_READ) = 0
> set_thread_area({entry_number:-1 -> 6, base_addr:0xb7deb6c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
> munmap(0xb7f1e000, 14975) = 0
> open("/dev/cpu/0/msr", O_RDONLY|O_LARGEFILE) = 3
> pread64(3, 0xbf83ac00, 8, 6160) = -1 EIO (Input/output error)
> write(2, "rdmsr: CPU 0 cannot read MSR 0x0"..., 40rdmsr: CPU 0 cannot read MSR 0x00001810
> ) = 40
> exit_group(4) = ?
> Process 15044 detached

OK, I added a bit of debuging print statements to msr.c and I find that
calling rdmsr 0x1810 returns error 0xfffffff2 (-14 that is).

It seems to end up calling:

static inline unsigned long long native_read_msr_safe(unsigned int msr,
int *err)
{
DECLARE_ARGS(val, low, high);

asm volatile("2: rdmsr ; xor %0,%0\n"
"1:\n\t"
".section .fixup,\"ax\"\n\t"
"3: mov %3,%0 ; jmp 1b\n\t"
".previous\n\t"
_ASM_EXTABLE(2b, 3b)
: "=r" (*err), EAX_EDX_RET(val, low, high)
: "c" (msr), "i" (-EFAULT));
return EAX_EDX_VAL(val, low, high);
}

That unfortunately is too low level for me to make sense of.

--
Len Sorensen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: H. Peter Anvin on
On 11/18/2009 12:21 PM, Lennart Sorensen wrote:
>
> OK, I added a bit of debuging print statements to msr.c and I find that
> calling rdmsr 0x1810 returns error 0xfffffff2 (-14 that is).
>

What this means is the RDMSR instruction traps -- the CPU doesn't
recognize this as a valid MSR.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lennart Sorensen on
On Wed, Nov 18, 2009 at 12:59:36PM -0800, H. Peter Anvin wrote:
> On 11/18/2009 12:21 PM, Lennart Sorensen wrote:
> >
> > OK, I added a bit of debuging print statements to msr.c and I find that
> > calling rdmsr 0x1810 returns error 0xfffffff2 (-14 that is).
> >
>
> What this means is the RDMSR instruction traps -- the CPU doesn't
> recognize this as a valid MSR.

Strange how it says that for every value I have tried so far. Makes me
wonder if there is a register somewhere that disables MSR support.
I did find a lockout value but I can't read that one either (which says
it is always readable).

--
Len Sorensen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/