Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-17 Thread Bernardo Innocenti
Keith Owens wrote:

 Before using MSR, you must first check that the cpu supports the
 instruction, rd/wrmsr cause an oops on 486 or earlier.  Also using an
 invalid msr number causes an oops, so use rd/wrmsr_safe().

I didn't bother implementing those checks because kdb recovers
nicely from GPF anyway.  It's the valid MSR writes that could
cause unrecoveable problems! :)

-- 
   // Bernardo Innocenti
 \X/  http://www.codewiz.org/
___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel


Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-15 Thread Mitch Bradley

 Also, would it make sense to coordinate the order of the high and low
 dwords with the order they are specified with 'wrmsr'?  
 I don't think it matters which order (lo-hi hi-lo) you use - The AMD
 debuggers use hi:lo, and Mitch uses lo:hi -  as long as you pick one
 and stay consistant, we'll be fine.

   
Actually, Mitch uses hi.lo .  Examples:

ok 1808 .msr
25fff002.10f0.
ok 40ef.c00f. 51010020 msr!


Mitch

___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel


Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-15 Thread Jordan Crouse
On 15/05/07 07:11 -1000, Mitch Bradley wrote:
 
 Also, would it make sense to coordinate the order of the high and low
 dwords with the order they are specified with 'wrmsr'?  
 I don't think it matters which order (lo-hi hi-lo) you use - The AMD
 debuggers use hi:lo, and Mitch uses lo:hi -  as long as you pick one
 and stay consistant, we'll be fine.
 
   
 Actually, Mitch uses hi.lo .  Examples:
 
 ok 1808 .msr
 25fff002.10f0.
 ok 40ef.c00f. 51010020 msr!
 

Oops - OK.  Then the FS2 uses lo:hi.  I couldn't remember which order,
but I remembered that they were opposite.

Jordan

-- 
Jordan Crouse
Senior Linux Engineer
Advanced Micro Devices, Inc.
www.amd.com/embeddedprocessors


___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel


Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-15 Thread Mitch Bradley


Jordan Crouse wrote:
 On 15/05/07 07:11 -1000, Mitch Bradley wrote:
   
 Also, would it make sense to coordinate the order of the high and low
 dwords with the order they are specified with 'wrmsr'?  
 I don't think it matters which order (lo-hi hi-lo) you use - The AMD
 debuggers use hi:lo, and Mitch uses lo:hi -  as long as you pick one
 and stay consistant, we'll be fine.

  
   
 Actually, Mitch uses hi.lo .  Examples:

 ok 1808 .msr
 25fff002.10f0.
 ok 40ef.c00f. 51010020 msr!

 

 Oops - OK.  Then the FS2 uses lo:hi.  I couldn't remember which order,
 but I remembered that they were opposite.
   

The lo:hi format really makes your brain hurt when dealing with numeric 
fields that span the boundary.  The Geode has many such fields.

If it wouldn't be too difficult, it would also be nice to permit 
embedded commas or dots in the number, because counting digits in a 
64-bit number is very difficult without the help of punctuation.


 Jordan

   
___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel


Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-15 Thread Mitch Bradley


Bernardo Innocenti wrote:
 Mitch Bradley wrote:

   
 If it wouldn't be too difficult, it would also be nice to permit 
 embedded commas or dots in the number, because counting digits in a 
 64-bit number is very difficult without the help of punctuation.
 

 It is customary to use _ for this purpose: 0x01234567_89ABCDEF.
   

_ is okay with me.  I don't really care what the delimiter characters 
is, just that it is possible to have one.

 Some people even break it in 16bit words, but it seems overkill
 to me.

   

___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel


Re: kdb: add rdmsr and wrmsr commands for i386

2007-05-15 Thread Bernardo Innocenti
Jordan Crouse wrote:

 Can you break this up with a : between the high dword and the low dword?
 That makes it easier to parse when debugging.

Good idea, but I used _ instead because it's what AMD uses in their
documentation and it looks better with a 0x prefix.

 Also, would it make sense to coordinate the order of the high and low
 dwords with the order they are specified with 'wrmsr'?  

Yeah, I did it as suggested by Mitch.  Here's a thrid
revision of the patch with everything included:

From 1850ca76585306e2484cf5e709434049f1df3c1f Mon Sep 17 00:00:00 2001
From: Bernardo Innocenti [EMAIL PROTECTED]
Date: Tue, 15 May 2007 15:29:48 -0400
Subject: [PATCH] kdb: add rdmsr and wrmsr commands for i386 (take 3)

The syntax is:
  rdmsr addr
  wrmsr addr h l

Signed-off-by: Bernardo Innocenti [EMAIL PROTECTED]
---
 arch/i386/kdb/kdbasupport.c |   47 +++---
 kdb/kdbmain.c   |3 +-
 2 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/arch/i386/kdb/kdbasupport.c b/arch/i386/kdb/kdbasupport.c
index 482b319..7038dfb 100644
--- a/arch/i386/kdb/kdbasupport.c
+++ b/arch/i386/kdb/kdbasupport.c
@@ -223,6 +223,46 @@ kdba_removedbreg(kdb_bp_t *bp)
kdba_putdr7(dr7);
 }
 
+static int
+kdba_rdmsr(int argc, const char **argv)
+{
+   unsigned long addr;
+   uint32_t l, h;
+   int diag;
+
+   if (argc != 1)
+   return KDB_ARGCOUNT;
+
+   if ((diag = kdbgetularg(argv[1], addr)))
+   return diag;
+
+   kdb_printf(msr(0x%lx) = , addr);
+   rdmsr(addr, l, h);
+   kdb_printf(0x%08lx_%08lx\n, h, l);
+
+   return 0;
+}
+
+static int
+kdba_wrmsr(int argc, const char **argv)
+{
+   unsigned long addr;
+   unsigned long l, h;
+   int diag;
+
+   if (argc != 3)
+   return KDB_ARGCOUNT;
+
+   if ((diag = kdbgetularg(argv[1], addr))
+   || (diag = kdbgetularg(argv[2], h))
+   || (diag = kdbgetularg(argv[3], l)))
+   return diag;
+
+   wrmsr(addr, l, h);
+
+   return 0;
+}
+
 
 /*
  * kdba_getregcontents
@@ -474,12 +514,11 @@ kdba_setregcontents(const char *regname,
  * argument is NULL (struct pt_regs).   The alternate register
  * set types supported by this function:
  *
- * d   Debug registers
+ * d   Debug registers
  * c   Control registers
  * u   User registers at most recent entry to kernel
  * for the process currently selected with pid command.
  * Following not yet implemented:
- * m   Model Specific Registers (extra defines register #)
  * r   Memory Type Range Registers (extra defines register)
  */
 
@@ -546,8 +585,6 @@ kdba_dumpregs(struct pt_regs *regs,
   cr[0], cr[1], cr[2], cr[3], cr[4]);
return 0;
}
-   case 'm':
-   break;
case 'r':
break;
default:
@@ -899,6 +936,8 @@ kdba_init(void)
 {
kdb_register(pt_regs, kdba_pt_regs, address, Format struct 
pt_regs, 0);
kdb_register(stackdepth, kdba_stackdepth, [percentage], Print 
processes using = stack percentage, 0);
+   kdb_register(rdmsr, kdba_rdmsr, maddr, Display Model Specific 
Register, 0);
+   kdb_register(wrmsr, kdba_wrmsr, maddr h l, Modify Model 
Specific Register, 0);
 
return;
 }
diff --git a/kdb/kdbmain.c b/kdb/kdbmain.c
index 0b2cb91..88bf14f 100644
--- a/kdb/kdbmain.c
+++ b/kdb/kdbmain.c
@@ -2596,8 +2596,7 @@ kdb_rd(int argc, const char **argv)
  * none.
  * Remarks:
  * Currently doesn't allow modification of control or
- * debug registers, nor does it allow modification
- * of model-specific registers (MSR).
+ * debug registers.
  */
 
 static int
-- 
1.5.0.2

-- 
   // Bernardo Innocenti
 \X/  http://www.codewiz.org/
___
Devel mailing list
Devel@laptop.org
http://mailman.laptop.org/mailman/listinfo/devel