Re: [git-pull -tip] x86: msr architecture debug code

Andreas Herrmann
2009-03-05T14:38:01Z

On Thu, Mar 05, 2009 at 07:42:26PM +0530, Jaswinder Singh Rajput wrote:
> On Thu, 2009-03-05 at 14:54 +0100, Andreas Herrmann wrote:
>
> > All nice suggestions but why in-kernel?
> >
>
> In Kernel Space:
>
> We can read/write MSRs and can change the bits and see it effect without
> writing any code.

Sorry, I can't (or maybe I don't like to) follow.

(BTW, you don't even need to write C-code. You can use a one-liner in perl
or python to seek and read any MSR using /dev/cpu/*/msr.)

> And we can also dump these value if something goes wrong in thats
> sections for kernel that's why I am also using printk.

Just some example how to do this today. (I've recently used this for
debugging.) Using a kernel with msr module loaded or built-in plus using
x86info/lsmsr and hpa's msr-tools.

# lsmsr MTRRfix -c 0
MTRRfix64K_00000 = 0x0606060606060606
MTRRfix16K_80000 = 0x0606060606060606
MTRRfix16K_A0000 = 0x0000000000000000
MTRRfix4K_C0000 = 0x0505050505050505
MTRRfix4K_C8000 = 0x0505050505050505
MTRRfix4K_D0000 = 0x0000000000000000
MTRRfix4K_D8000 = 0x0000000000000000
MTRRfix4K_E0000 = 0x0505050500000000
MTRRfix4K_E8000 = 0x0505050505050505
MTRRfix4K_F0000 = 0x0505050505050505
MTRRfix4K_F8000 = 0x0505050505050505
# lsmsr SYS_CFG
SYS_CFG = 0x0000000000160600
# lsmsr SYS_CFG -l -V3
SYS_CFG : 0xc0010010
8-8:SetDirtyEnE
9-9:SetDirtyEnS
10-10:SetDirtyEnO
16-16:ChxToDirtyDis
17-17:SysUcLockEn
18-18:MtrrFixDramEn
19-19:MtrrFixDramModEn
20-20:MtrrVarDramEn
21-21:MtrrTom2En
22-22:Tom2ForceMemTypeWB
# wrmsr -p 0 0xc0010010 0x00000000001e0600
# lsmsr SYS_CFG
SYS_CFG = 0x00000000001e0600
# lsmsr MTRRfix -c 0
MTRRfix64K_00000 = 0x1e1e1e1e1e1e1e1e
MTRRfix16K_80000 = 0x1e1e1e1e1e1e1e1e
MTRRfix16K_A0000 = 0x0000000000000000
MTRRfix4K_C0000 = 0x1515151515151515
MTRRfix4K_C8000 = 0x1515151515151515
MTRRfix4K_D0000 = 0x0000000000000000
MTRRfix4K_D8000 = 0x0000000000000000
MTRRfix4K_E0000 = 0x1515151500000000
MTRRfix4K_E8000 = 0x1515151515151515
MTRRfix4K_F0000 = 0x1515151515151515
MTRRfix4K_F8000 = 0x1515151515151515

IMHO, there is no need to do this in-kernel.

Regards,

Andreas

--
Operating | Advanced Micro Devices GmbH
System | Karl-Hammerschmidt-Str. 34, 85609 Dornach b. München, Germany
Research | Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
(OSRC) | Registergericht München, HRB Nr. 43632