Skip to contentSkip to conversation

cpu_debug patches 20090613

GIT PULL In review Jaswinder Singh Rajput 4 participants 19 messages Jun 13, 2009 – Jun 15, 2009 x86

lore
Share & tools
lore
#0 lore raw

By adding these patches, cpu_debug will support :

1. Standard Registers
2. Control Registers
3. Debug Registers
4. Descriptor Tables
5. APIC Registers
6. Model specific Register (MSRs)
7. PCI configuration registers (for AMD)
8. Basic cpuinfo
9. CPUID Functions

Please let me know how we can improve it and add more features so it becomes more useful.

For example on AMD 64 Laptop :

1. Standard Registers
---------------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/tss/state
 RAX	: ffffffff81789fe8
 RBX	: 000000000007e000
 RCX	: ffffffff8179437f
 RDX	: 0000000000000000
 RSI	: 0000000000000000
 RDI	: 81798e0000104136
 RBP	: 000000000000001f
 ESP	: 0000000000000000
 R08	: 00000000000932d0
 R09	: 0000000000000000
 R10	: ffffffff8179429a
 R11	: ffffffff81789fa8
 R12	: 00000000afc723ac
 R13	: 00000000018e4f80
 R14	: ffffffff817cee80
 R15	: ffffffff81789f88
 CS	:             0010
 DS	:             0018
 SS	:             0000
 ES	:             0018
 FS	:             0000
 GS	:             0000
 EFLAGS	: 0000000000000000
 EIP	: 0000000000000000

2. Control Registers
--------------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/cr/state
 cr0	: 000000008005003b
 cr2	: 0000000000429040
 cr3	: 0000000001001000
 cr4	: 00000000000006b0
 cr8	: 0000000000000000

3. Debug Registers
------------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/debug/state
 dr0	: 0000000000000000
 dr1	: 0000000000000000
 dr2	: 0000000000000000
 dr3	: 0000000000000000
 dr6	: 00000000ffff0ff0
 dr7	: 0000000000000400

MSR :
000001d9: 00000000_00000000

4. Descriptor Tables
--------------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/dt/state
 IDT	: ffffffff81820fff
 GDT	: ffff88002802607f
 LDT	: ffffffff810b0000
 TR	: 0000000000000040

5. APIC Registers
-----------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/apic/state
 LAPIC	:
 ID		: 00000000
 LVR		: 80050010
 TASKPRI	: 00000000
 ARBPRI		: 00000000
 PROCPRI	: 00000000
 LDR		: 01000000
 DFR		: ffffffff
 SPIV		: 000001ff
 ISR		: 00000000
 ESR		: 00000004
 ICR		: 000208fd
 ICR2		: 02000000
 LVTT		: 000300ef
 LVTTHMR	: 00010000
 LVTPC		: 00000400
 LVT0		: 00010700
 LVT1		: 00000400
 LVTERR		: 000000fe
 TMICT		: ffffffff
 TMCCT		: 8d52660d
 TDCR		: 00000003
 EFEAT		: 00040007
 ECTRL		: 00000000
 EILVT0		: 00010000
 EILVT1		: 00010000
 EILVT2		: 00010000
 EILVT3		: 00010000

MSR :
0000001b: 00000000_fee00900

b. access individual APIC register :

# cat /sys/kernel/debug/x86/cpu/cpu0/apic/APIC_EFEAT/value 
0x40007
# cat /sys/kernel/debug/x86/cpu/cpu0/apic/MSR_1b/value
0xfee00900

6. Model specific Register (MSRs)
---------------------------------

a. access complete state, say performance monitor counter (pmc)

# cat /sys/kernel/debug/x86/cpu/cpu0/pmc/state
 MSR	:
 c0010000: 00000000_00430076
 c0010001: 00000000_3d179f6b
 c0010002: 00000000_7993feae
 c0010003: 00000000_f69637fe
 c0010004: 0000000f_4c47618a
 c0010005: 0000f0db_ffc3e9c3
 c0010006: 0000834f_15f5610e
 c0010007: 00006ade_595d2c95

b. access individual MSR :

# cat /sys/kernel/debug/x86/cpu/cpu0/pmc/MSR_c0010006/value 
0x834f15f5610e

c. write individual MSR :

# echo 2 >  /sys/kernel/debug/x86/cpu/cpu0/pmc/MSR_c0010006/value
# cat /sys/kernel/debug/x86/cpu/cpu0/pmc/MSR_c0010006/value 
0x2

7. PCI configuration registers (for AMD)
----------------------------------------

a. access complete state

PCI configuration regsiters :
function : 0
000 : 13001022
004 : 00100000
008 : 06000040
00c : 00800000
034 : 00000080
040 : 00000000
044 : 00000000
048 : 00000000
04c : 00000000
050 : 00000000
054 : 00000000
058 : 00000000
05c : 00000000
060 : 00000000
064 : 00000000
068 : 012e4820
06c : 00000030
080 : 21010008
084 : 11112020
088 : 1ff50a60
08c : 00000003
090 : 001005b6
094 : 00000000
098 : 00000007
0a0 : 00000000
0a4 : 00000000
0a8 : 00000000
0ac : 00000000
0b0 : 00000000
0b4 : 00000000
0b8 : 00000000
0c0 : 00000000
0c4 : 00000000
0c8 : 00000000
0cc : 00000000
0d0 : 00000000
0d4 : 00000000
0d8 : 00000000
0e0 : 00000000
0e4 : 00000000
0e8 : 00000000
0ec : 00000000
0f0 : 00000000
0f4 : 00000000
0f8 : 00000000
110 : 00000000
114 : 00000000
118 : 00000000
11c : 00000000
120 : 00000000
124 : 00000000
128 : 00000000
12c : 00000000
130 : 000000c1
134 : 00000000
138 : 00000000
13c : 00000000
140 : 00000000
144 : 00000000
148 : 00000000
14c : 00000000
150 : 00070000
164 : 00000000
168 : 00000000
16c : 0074e026
170 : 07c00109
174 : 00000000
178 : 00000000
17c : 00000000
180 : 00000000
184 : 00000000
188 : 00000000
18c : 00000000
1a0 : 00000000
1a4 : 00002824
1d0 : 00000400
1d4 : 00000051

function : 1
000 : 13011022
004 : 00000000
008 : 06000000
00c : 00800000
034 : 00000000
040 : 00000003
044 : 013f0000
048 : 00000000
04c : 00000000
050 : 00000000
054 : 00000000
058 : 00000000
05c : 00000000
060 : 00000000
064 : 00000000
068 : 00000000
06c : 00000000
070 : 00000000
074 : 00000000
078 : 00000000
07c : 00000000
080 : 00000000
084 : 00000000
088 : 00000a03
08c : 00000b00
090 : 00c00003
094 : 00cfff80
098 : 00d00003
09c : 00d21f00
0a0 : 00d22003
0a4 : 00d22f80
0a8 : 00d23003
0ac : 00dfff00
0b0 : 00e00003
0b4 : 00e3ff80
0b8 : 00e40003
0bc : 00ffff00
0c0 : 00000013
0c4 : 00fff000
0c8 : 00000000
0cc : 00000000
0d0 : 00000000
0d4 : 00000000
0d8 : 00000000
0dc : 00000000
0e0 : 00000000
0e4 : 00000000
0e8 : 00000000
0ec : 00000000
0f0 : c0004001
0f4 : 00000000
110 : 00000000
114 : 00000000
120 : 00000000
124 : 00000000
140 : 00000000
144 : 00000000
148 : 00000000
14c : 00000000
150 : 00000000
154 : 00000000
158 : 00000000
15c : 00000000
160 : 00000000
164 : 00000000
168 : 00000000
16c : 00000000
170 : 00000000
174 : 00000000
178 : 00000000
17c : 00000000
180 : e0000011
184 : 00000000

function : 2
000 : 13021022
004 : 00000000
008 : 06000000
00c : 00800000
034 : 00000000
040 : 00000001
044 : 00000101
048 : 00000000
04c : 00000000
050 : 00000000
054 : 00000000
058 : 00000000
05c : 00000000
060 : 00783ee0
064 : 00000000
068 : 00000000
06c : 00000000
070 : 00000000
074 : 00000000
078 : 00000036
07c : 00000000
080 : 00000005
084 : 00000000
088 : 7d7dfb35
08c : 0022173f
090 : 00600020
094 : 7e51806b
098 : 80000013
09c : 0000003a
0a0 : 000000a8
0a4 : 00000000
10c : 00000000
110 : 00000584
114 : 00000000
118 : 1441b4a4
11c : 00402064
140 : 00000001
144 : 00000101
148 : 00000000
14c : 00000000
150 : 00000000
154 : 00000000
158 : 00000000
15c : 00000000
160 : 00783ee0
164 : 00000000
168 : 00000000
16c : 00000000
178 : 00000036
17c : 00000000
180 : 00000005
184 : 00000000
188 : 4d7dfb35
18c : 0022173f
190 : 00600020
194 : 7e51806b
198 : 80000013
19c : 0000003c
1a0 : 00000008
1b0 : 00000000

function : 3
000 : 13031022
004 : 00100000
008 : 06000000
00c : 00800000
034 : 000000f0
040 : 00000100
044 : 0a100040
048 : 00000000
04c : 00000000
050 : 00000000
054 : 00000000
058 : 00000000
05c : 00000000
060 : 00000000
064 : 1a600000
068 : 100000c0
06c : 08000808
070 : 00000000
074 : 30000876
078 : 00000000
07c : 85001101
080 : ff00f300
084 : 80e600ee
088 : 00000000
08c : 00000000
090 : 00000000
094 : 00000000
098 : 00000000
09c : 00000000
0a0 : 800402bc
0a4 : 3b201800
0b0 : 00000000
0d4 : 0005024d
0d8 : 03000025
0dc : 00034240
0e4 : 00000520
0e8 : 00001f81
0f0 : 0010000f
0f4 : 00000000
0f8 : 00000000
0fc : 00200f31
140 : 00000000
144 : 00000000
148 : 00000000
14c : 00000000
150 : 00000000
154 : 00000000
158 : 00000000
15c : 00000000
160 : 00000000
164 : 00000000
168 : 00000000
16c : 00000000
170 : 00000000
174 : 00000000
178 : 00000000
17c : 00000000
180 : 00400002
188 : 1b000438
190 : 00000000
1a0 : 00000000
1cc : 00000000
1e4 : 80000000
1e8 : 00000000
1ec : 00000000
1f0 : 000f0500
1fc : 00000000

function : 4
000 : 13041022
004 : 00000000
008 : 06000000
00c : 00800000
034 : 00000000
080 : 00000000
084 : 00000000
088 : 00000000
08c : 00000000
090 : 00000000
094 : 00000000
098 : 00000000
09c : 00000000
0a0 : 00000000
0a4 : 00000000
0a8 : 00000000
0ac : 00000000
0b0 : 00000000
0b4 : 00000000
0b8 : 00000000
0bc : 00000000
0c0 : 00000000
0c4 : 00000000
0c8 : 00000000
0cc : 00000000
0d0 : 00000000
0d4 : 00000000
0d8 : 00000000
0dc : 00000000
0e0 : 00000000
0e4 : 00000000
0e8 : 00000000
0ec : 00000000
0f0 : 00000000
0f4 : 00000000
0f8 : 00000000
170 : 00000006
174 : 0a3cdfe6
180 : 800000c4
184 : 00006400
188 : 00000000
18c : 00000000
190 : 00000000
194 : 00000000
198 : 00000000
19c : 00000000
1c4 : 00000000
1e0 : 00000000
1e4 : 00000000
1e8 : 00000000
1ec : 00000000
1f0 : 00000000

b. access individual PCI configuration :

# cat /sys/kernel/debug/x86/cpu/cpu0/pci/PCI0_000/value 
0x13001022
# cat /sys/kernel/debug/x86/cpu/cpu0/therm/PCI3_0a4/value 
0x3c001800

8. Basic cpuinfo
----------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/cpuinfo/state 
 CPUINFO	:
 processor		: 0
 family			: 17
 vendor			: 2
 model			: 3
 mask			: 1
 TLB size		: 1024 4K pages
 virtual bits		: 48
 physical bits		: 40
 extended cpuid level	: 8000001a (8000001a)
 cpuid level		: 1
 flags			: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch osvw skinit
 vendor id		: AuthenticAMD
 model id		: AMD Turion(tm) X2 Ultra Dual-Core Mobile ZM-80
 cache size		: 1024 KB
 cache alignment	: 64
 power management	: ts ttp tm stc 100mhzsteps hwpstate
 loops per jiffy	: 2098811
 bogomips		: 4197.62
 max cores		: 2
 apic id		: 0
 intial apic id		: 0
 clflush size		: 64
 cpu cores		: 2
 physical id		: 0
 core id		: 0
 cpu index		: 0
 hyper vendor		: 0

9. CPUID Functions
------------------

a. access complete state

# cat /sys/kernel/debug/x86/cpu/cpu0/cpuid/state
 CPUID	:
              eax       ebx       ecx       edx
 00000000  00000001  68747541  444d4163  69746e65
 00000001  00200f31  00020800  00002001  178bfbff
 80000000  8000001a  68747541  444d4163  69746e65
 80000001  00200f31  20000500  0000131f  ebd3fbff
 80000002  20444d41  69727554  74286e6f  5820296d
 80000003  6c552032  20617274  6c617544  726f432d
 80000004  6f4d2065  656c6962  2d4d5a20  00003038
 80000005  ff08ff08  ff20ff20  40020140  40020140
 80000006  00000000  42004200  04008140  00000000
 80000007  00000000  00000000  00000000  000001f9
 80000008  00003028  00000000  00001001  00000000
 80000009  00000000  00000000  00000000  00000000
 8000000a  00000001  00000040  00000000  0000000e
 8000000b  00000000  00000000  00000000  00000000
 8000000c  00000000  00000000  00000000  00000000
 8000000d  00000000  00000000  00000000  00000000
 8000000e  00000000  00000000  00000000  00000000
 8000000f  00000000  00000000  00000000  00000000
 80000010  00000000  00000000  00000000  00000000
 80000011  00000000  00000000  00000000  00000000
 80000012  00000000  00000000  00000000  00000000
 80000013  00000000  00000000  00000000  00000000
 80000014  00000000  00000000  00000000  00000000
 80000015  00000000  00000000  00000000  00000000
 80000016  00000000  00000000  00000000  00000000
 80000017  00000000  00000000  00000000  00000000
 80000018  00000000  00000000  00000000  00000000
 80000019  00000000  00000000  00000000  00000000
 8000001a  00000000  00000000  00000000  00000000

The following changes since commit 50149b2db7be15514079089d0c4efa4c7a2676bb:
Ingo Molnar (1):
Merge branch 'linus'

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jaswinder/linux-2.6-tip.git master

Jaswinder Singh Rajput (10):
x86: cpu_debug update Kconfig entry
x86: cpu_debug.c remove some not required header files
x86: cpu_debug.c use a WARN_ONCE() instead of a pr_err()
x86: cpu_debug make room to support more categories
x86: cpu_debug update MSR list to support new architectures
x86: cpu_debug make room for more cpu registers
x86: cpu_debug support APIC_register_name with directory structure
x86: cpu_debug display PCI configuration registers for AMD
x86: cpu_debug display cpuid functions
x86: cpu_debug display basic cpuinfo

 arch/x86/Kconfig                 |   12 +-
 arch/x86/include/asm/cpu_debug.h |  125 ++++----
 arch/x86/kernel/cpu/cpu_debug.c  |  681 +++++++++++++++++++++++++++++++++-----
 3 files changed, 666 insertions(+), 152 deletions(-)

Complete diff :

arch/x86/Kconfig +11 -1
index 0c2321d..e5e26b3 100644
@@ -994,9 +994,19 @@ config X86_CPUID
 
 config X86_CPU_DEBUG
 	tristate "/sys/kernel/debug/x86/cpu/* - CPU Debug support"
+	select DEBUG_FS
 	---help---
 	  If you select this option, this will provide various x86 CPUs
-	  information through debugfs.
+	  information through debugfs. Any user can read these file but writing
+	  needs root privilege.
+
+	  Note: 1. If you compile cpu_debug as a module, it will _not_ be loaded
+	  automatically (like usual drivers). You will need to load it manually
+	  (or add it to list of modules loaded during boot).
+
+	  2. You need debugfs, if you want to mount debugfs automatically
+	  append this line in /etc/fstab:
+	  debugfs	/sys/kernel/debug	debugfs	defaults	0 0
 
 choice
 	prompt "High Memory Support"
arch/x86/include/asm/cpu_debug.h +57 -68

148 lines not on this page · raw message

arch/x86/kernel/cpu/cpu_debug.c +598 -83

916 lines not on this page · raw message

#1 lore raw

RFC PATCH 1/10 x86: cpu_debug update Kconfig entry

cpu_debug needs DEBUG_FS.

Explain basic info to use cpu_debug.

---
 arch/x86/Kconfig |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
arch/x86/Kconfig +11 -1
index 0c2321d..e5e26b3 100644
@@ -994,9 +994,19 @@ config X86_CPUID
 
 config X86_CPU_DEBUG
 	tristate "/sys/kernel/debug/x86/cpu/* - CPU Debug support"
+	select DEBUG_FS
 	---help---
 	  If you select this option, this will provide various x86 CPUs
-	  information through debugfs.
+	  information through debugfs. Any user can read these file but writing
+	  needs root privilege.
+
+	  Note: 1. If you compile cpu_debug as a module, it will _not_ be loaded
+	  automatically (like usual drivers). You will need to load it manually
+	  (or add it to list of modules loaded during boot).
+
+	  2. You need debugfs, if you want to mount debugfs automatically
+	  append this line in /etc/fstab:
+	  debugfs	/sys/kernel/debug	debugfs	defaults	0 0
 
 choice
 	prompt "High Memory Support"
Signature · 1 line
1.6.0.6
#2 lore raw

RFC PATCH 2/10 x86: cpu_debug.c remove some not required header files

remove some not required header files

---
 arch/x86/kernel/cpu/cpu_debug.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/cpu_debug.c +0 -5
index 6b2a52d..f7b42d2 100644
@@ -6,16 +6,12 @@
  * For licencing details see kernel-base/COPYING
  */
 
-#include <linux/interrupt.h>
-#include <linux/compiler.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
-#include <linux/kprobes.h>
 #include <linux/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/percpu.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/types.h>
@@ -26,7 +22,6 @@
 #include <asm/cpu_debug.h>
 #include <asm/paravirt.h>
 #include <asm/system.h>
-#include <asm/traps.h>
 #include <asm/apic.h>
 #include <asm/desc.h>
 
Signature · 1 line
1.6.0.6
#3 lore raw

RFC PATCH 3/10 x86: cpu_debug.c use a WARN_ONCE() instead of a pr_err()

Use a WARN_ONCE() instead of a pr_err(). Hitting this is a bug we want to fix.

Also added email address.

---
 arch/x86/kernel/cpu/cpu_debug.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/cpu_debug.c +3 -3
index f7b42d2..3aa3596 100644
@@ -644,8 +644,8 @@ static int cpu_init_cpu(void)
 		pr_info("cpu%d(%d) debug files %d\n",
 			cpu, nr_cpu_ids, per_cpu(cpu_priv_count, cpu));
 		if (per_cpu(cpu_priv_count, cpu) > MAX_CPU_FILES) {
-			pr_err("Register files count %d exceeds limit %d\n",
-				per_cpu(cpu_priv_count, cpu), MAX_CPU_FILES);
+			WARN_ONCE(1, "debug files count %d exceeds limit %d\n",
+				  per_cpu(cpu_priv_count, cpu), MAX_CPU_FILES);
 			per_cpu(cpu_priv_count, cpu) = MAX_CPU_FILES;
 			err = -ENFILE;
 		}
@@ -678,6 +678,6 @@ static void __exit cpu_debug_exit(void)
 module_init(cpu_debug_init);
 module_exit(cpu_debug_exit);
 
-MODULE_AUTHOR("Jaswinder Singh Rajput");
+MODULE_AUTHOR("Jaswinder Singh Rajput <[email protected]>");
 MODULE_DESCRIPTION("CPU Debug module");
 MODULE_LICENSE("GPL");
Signature · 1 line
1.6.0.6
#4 lore raw

RFC PATCH 4/10 x86: cpu_debug make room to support more categories

Earlier cpu_debug categories was stored in bitwise fashion and we reached the limit of 0-31.

So now storing the categories based on count so that we can add more.

---
 arch/x86/include/asm/cpu_debug.h |  102 +++++++++++++-------------------------
 arch/x86/kernel/cpu/cpu_debug.c  |   14 +++---
 2 files changed, 41 insertions(+), 75 deletions(-)
arch/x86/include/asm/cpu_debug.h +34 -68
index d96c1ee..da5c221 100644
@@ -10,84 +10,50 @@
 /* Register flags */
 enum cpu_debug_bit {
 /* Model Specific Registers (MSRs)					*/
-	CPU_MC_BIT,				/* Machine Check	*/
-	CPU_MONITOR_BIT,			/* Monitor		*/
-	CPU_TIME_BIT,				/* Time			*/
-	CPU_PMC_BIT,				/* Performance Monitor	*/
-	CPU_PLATFORM_BIT,			/* Platform		*/
-	CPU_APIC_BIT,				/* APIC			*/
-	CPU_POWERON_BIT,			/* Power-on		*/
-	CPU_CONTROL_BIT,			/* Control		*/
-	CPU_FEATURES_BIT,			/* Features control	*/
-	CPU_LBRANCH_BIT,			/* Last Branch		*/
-	CPU_BIOS_BIT,				/* BIOS			*/
-	CPU_FREQ_BIT,				/* Frequency		*/
-	CPU_MTTR_BIT,				/* MTRR			*/
-	CPU_PERF_BIT,				/* Performance		*/
-	CPU_CACHE_BIT,				/* Cache		*/
-	CPU_SYSENTER_BIT,			/* Sysenter		*/
-	CPU_THERM_BIT,				/* Thermal		*/
-	CPU_MISC_BIT,				/* Miscellaneous	*/
-	CPU_DEBUG_BIT,				/* Debug		*/
-	CPU_PAT_BIT,				/* PAT			*/
-	CPU_VMX_BIT,				/* VMX			*/
-	CPU_CALL_BIT,				/* System Call		*/
-	CPU_BASE_BIT,				/* BASE Address		*/
-	CPU_VER_BIT,				/* Version ID		*/
-	CPU_CONF_BIT,				/* Configuration	*/
-	CPU_SMM_BIT,				/* System mgmt mode	*/
-	CPU_SVM_BIT,				/*Secure Virtual Machine*/
-	CPU_OSVM_BIT,				/* OS-Visible Workaround*/
+	CPU_MC,					/* Machine Check	*/
+	CPU_MONITOR,				/* Monitor		*/
+	CPU_TIME,				/* Time			*/
+	CPU_PMC,				/* Performance Monitor	*/
+	CPU_PLATFORM,				/* Platform		*/
+	CPU_APIC,				/* APIC			*/
+	CPU_POWERON,				/* Power-on		*/
+	CPU_CONTROL,				/* Control		*/
+	CPU_FEATURES,				/* Features control	*/
+	CPU_LBRANCH,				/* Last Branch		*/
+	CPU_BIOS,				/* BIOS			*/
+	CPU_FREQ,				/* Frequency		*/
+	CPU_MTRR,				/* MTRR			*/
+	CPU_PERF,				/* Performance		*/
+	CPU_CACHE,				/* Cache		*/
+	CPU_SYSENTER,				/* Sysenter		*/
+	CPU_THERM,				/* Thermal		*/
+	CPU_MISC,				/* Miscellaneous	*/
+	CPU_DEBUG,				/* Debug		*/
+	CPU_PAT,				/* PAT			*/
+	CPU_VMX,				/* VMX			*/
+	CPU_CALL,				/* System Call		*/
+	CPU_BASE,				/* BASE Address		*/
+	CPU_VER,				/* Version ID		*/
+	CPU_CONF,				/* Configuration	*/
+	CPU_SMM,				/* System mgmt mode	*/
+	CPU_SVM,				/*Secure Virtual Machine*/
+	CPU_OSVM,				/* OS-Visible Workaround*/
 /* Standard Registers							*/
-	CPU_TSS_BIT,				/* Task Stack Segment	*/
-	CPU_CR_BIT,				/* Control Registers	*/
-	CPU_DT_BIT,				/* Descriptor Table	*/
+	CPU_TSS,				/* Task Stack Segment	*/
+	CPU_CR,					/* Control Registers	*/
+	CPU_DT,					/* Descriptor Table	*/
 /* End of Registers flags						*/
-	CPU_REG_ALL_BIT,			/* Select all Registers	*/
+	CPU_REG_MAX,				/* Max Registers flags	*/
 };
 
 #define	CPU_REG_ALL		(~0)		/* Select all Registers	*/
 
-#define	CPU_MC			(1 << CPU_MC_BIT)
-#define	CPU_MONITOR		(1 << CPU_MONITOR_BIT)
-#define	CPU_TIME		(1 << CPU_TIME_BIT)
-#define	CPU_PMC			(1 << CPU_PMC_BIT)
-#define	CPU_PLATFORM		(1 << CPU_PLATFORM_BIT)
-#define	CPU_APIC		(1 << CPU_APIC_BIT)
-#define	CPU_POWERON		(1 << CPU_POWERON_BIT)
-#define	CPU_CONTROL		(1 << CPU_CONTROL_BIT)
-#define	CPU_FEATURES		(1 << CPU_FEATURES_BIT)
-#define	CPU_LBRANCH		(1 << CPU_LBRANCH_BIT)
-#define	CPU_BIOS		(1 << CPU_BIOS_BIT)
-#define	CPU_FREQ		(1 << CPU_FREQ_BIT)
-#define	CPU_MTRR		(1 << CPU_MTTR_BIT)
-#define	CPU_PERF		(1 << CPU_PERF_BIT)
-#define	CPU_CACHE		(1 << CPU_CACHE_BIT)
-#define	CPU_SYSENTER		(1 << CPU_SYSENTER_BIT)
-#define	CPU_THERM		(1 << CPU_THERM_BIT)
-#define	CPU_MISC		(1 << CPU_MISC_BIT)
-#define	CPU_DEBUG		(1 << CPU_DEBUG_BIT)
-#define	CPU_PAT			(1 << CPU_PAT_BIT)
-#define	CPU_VMX			(1 << CPU_VMX_BIT)
-#define	CPU_CALL		(1 << CPU_CALL_BIT)
-#define	CPU_BASE		(1 << CPU_BASE_BIT)
-#define	CPU_VER			(1 << CPU_VER_BIT)
-#define	CPU_CONF		(1 << CPU_CONF_BIT)
-#define	CPU_SMM			(1 << CPU_SMM_BIT)
-#define	CPU_SVM			(1 << CPU_SVM_BIT)
-#define	CPU_OSVM		(1 << CPU_OSVM_BIT)
-#define	CPU_TSS			(1 << CPU_TSS_BIT)
-#define	CPU_CR			(1 << CPU_CR_BIT)
-#define	CPU_DT			(1 << CPU_DT_BIT)
-
 /* Register file flags */
 enum cpu_file_bit {
-	CPU_INDEX_BIT,				/* index		*/
-	CPU_VALUE_BIT,				/* value		*/
+	CPU_INDEX,				/* index		*/
+	CPU_VALUE,				/* value		*/
 };
 
-#define	CPU_FILE_VALUE		(1 << CPU_VALUE_BIT)
-
 #define MAX_CPU_FILES		512
 
 struct cpu_private {
arch/x86/kernel/cpu/cpu_debug.c +7 -7
index 3aa3596..5c45c52 100644
@@ -25,7 +25,7 @@
 #include <asm/apic.h>
 #include <asm/desc.h>
 
-static DEFINE_PER_CPU(struct cpu_cpuX_base, cpu_arr[CPU_REG_ALL_BIT]);
+static DEFINE_PER_CPU(struct cpu_cpuX_base, cpu_arr[CPU_REG_MAX]);
 static DEFINE_PER_CPU(struct cpu_private *, priv_arr[MAX_CPU_FILES]);
 static DEFINE_PER_CPU(int, cpu_priv_count);
 
@@ -399,12 +399,12 @@ static int cpu_seq_show(struct seq_file *seq, void *v)
 		smp_call_function_single(priv->cpu, print_dt, seq, 1);
 		break;
 	case CPU_DEBUG:
-		if (priv->file == CPU_INDEX_BIT)
+		if (priv->file == CPU_INDEX)
 			smp_call_function_single(priv->cpu, print_dr, seq, 1);
 		print_msr(seq, priv->cpu, cpu_base[priv->type].flag);
 		break;
 	case CPU_APIC:
-		if (priv->file == CPU_INDEX_BIT)
+		if (priv->file == CPU_INDEX)
 			smp_call_function_single(priv->cpu, print_apic, seq, 1);
 		print_msr(seq, priv->cpu, cpu_base[priv->type].flag);
 		break;
@@ -482,7 +482,7 @@ static int write_cpu_register(struct cpu_private *priv, const char *buf)
 		return ret;
 
 	/* Supporting only MSRs */
-	if (priv->type < CPU_TSS_BIT)
+	if (priv->type < CPU_TSS)
 		return write_msr(priv, val);
 
 	return ret;
@@ -525,7 +525,7 @@ static int cpu_create_file(unsigned cpu, unsigned type, unsigned reg,
 	struct cpu_private *priv = NULL;
 
 	/* Already intialized */
-	if (file == CPU_INDEX_BIT)
+	if (file == CPU_INDEX)
 		if (per_cpu(cpu_arr[type].init, cpu))
 			return 0;
 
@@ -612,10 +612,10 @@ static int cpu_init_allreg(unsigned cpu, struct dentry *dentry)
 		cpu_dentry = debugfs_create_dir(cpu_base[type].name, dentry);
 		per_cpu(cpu_arr[type].dentry, cpu) = cpu_dentry;
 
-		if (type < CPU_TSS_BIT)
+		if (type < CPU_TSS)
 			err = cpu_init_msr(cpu, type, cpu_dentry);
 		else
-			err = cpu_create_file(cpu, type, 0, CPU_INDEX_BIT,
+			err = cpu_create_file(cpu, type, 0, CPU_INDEX,
 					      cpu_dentry);
 		if (err)
 			return err;
Signature · 1 line
1.6.0.6
#5 lore raw

RFC PATCH 5/10 x86: cpu_debug update MSR list to support new architectures

Added support for Intel Xeon MP 7400 series :

Intel Xeon MP 7400 series falls in Intel Core microarchitecture. Intel Xeon MP 7400 series supports additional:
0x419, 0x107CC-0x107D3 and 0x107D8

Added support for Intel Core i7, Xeon Processor 5500 series (Nehalem)

Added some extra registers for AMD Family 10h Processor

Also fixed some minor range issues.

---
 arch/x86/include/asm/cpu_debug.h |    3 +++
 arch/x86/kernel/cpu/cpu_debug.c  |   36 +++++++++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 9 deletions(-)
arch/x86/include/asm/cpu_debug.h +3 -0
index da5c221..f2adad3 100644
@@ -36,6 +36,9 @@ enum cpu_debug_bit {
 	CPU_VER,				/* Version ID		*/
 	CPU_CONF,				/* Configuration	*/
 	CPU_SMM,				/* System mgmt mode	*/
+	CPU_POWER,				/* Power mgmt		*/
+	CPU_PNAME,				/* Processor name	*/
+	CPU_IBS,				/* IBS			*/
 	CPU_SVM,				/*Secure Virtual Machine*/
 	CPU_OSVM,				/* OS-Visible Workaround*/
 /* Standard Registers							*/
arch/x86/kernel/cpu/cpu_debug.c +27 -9
index 5c45c52..9435da4 100644
@@ -60,6 +60,9 @@ static struct cpu_debug_base cpu_base[] = {
 	{ "ver",	CPU_VER,	0	},
 	{ "conf",	CPU_CONF,	0	},
 	{ "smm",	CPU_SMM,	0	},
+	{ "power",	CPU_POWER,	0	},
+	{ "pname",	CPU_PNAME,	0	},
+	{ "ibs",	CPU_IBS,	0	},
 	{ "svm",	CPU_SVM,	0	},
 	{ "osvm",	CPU_OSVM,	0	},
 	{ "tss",	CPU_TSS,	0	},
@@ -90,6 +93,7 @@ static struct cpu_debug_range cpu_reg_range[] = {
 	{ 0x00000088, 0x0000008A, CPU_CACHE,	},
 	{ 0x0000008B, 0x0000008B, CPU_BIOS,	},
 	{ 0x0000009B, 0x0000009B, CPU_MONITOR,	},
+	{ 0x000000A0, 0x000000A1, CPU_SMM,	},
 	{ 0x000000C1, 0x000000C4, CPU_PMC,	},
 	{ 0x000000CD, 0x000000CD, CPU_FREQ,	},
 	{ 0x000000E7, 0x000000E8, CPU_PERF,	},
@@ -98,40 +102,49 @@ static struct cpu_debug_range cpu_reg_range[] = {
 	{ 0x00000116, 0x0000011E, CPU_CACHE,	},
 	{ 0x00000174, 0x00000176, CPU_SYSENTER,	},
 	{ 0x00000179, 0x0000017B, CPU_MC,	},
+	{ 0x00000180, 0x00000185, CPU_MC,	},
 	{ 0x00000186, 0x00000189, CPU_PMC,	},
 	{ 0x00000198, 0x00000199, CPU_PERF,	},
 	{ 0x0000019A, 0x0000019A, CPU_TIME,	},
 	{ 0x0000019B, 0x0000019D, CPU_THERM,	},
 	{ 0x000001A0, 0x000001A0, CPU_MISC,	},
-	{ 0x000001C9, 0x000001C9, CPU_LBRANCH,	},
+	{ 0x000001A1, 0x000001A1, CPU_PLATFORM,	},
+	{ 0x000001A2, 0x000001A2, CPU_THERM,	},
+	{ 0x000001A6, 0x000001A6, CPU_PMC,	},
+	{ 0x000001AD, 0x000001AD, CPU_FREQ,	},
+	{ 0x000001C8, 0x000001C9, CPU_LBRANCH,	},
 	{ 0x000001D7, 0x000001D8, CPU_LBRANCH,	},
 	{ 0x000001D9, 0x000001D9, CPU_DEBUG,	},
 	{ 0x000001DA, 0x000001E0, CPU_LBRANCH,	},
+	{ 0x000001F2, 0x000001F3, CPU_SMM,	},
 
 	{ 0x00000200, 0x0000020F, CPU_MTRR,	},
 	{ 0x00000250, 0x00000250, CPU_MTRR,	},
 	{ 0x00000258, 0x00000259, CPU_MTRR,	},
 	{ 0x00000268, 0x0000026F, CPU_MTRR,	},
 	{ 0x00000277, 0x00000277, CPU_PAT,	},
+	{ 0x00000280, 0x00000288, CPU_MC,	},
 	{ 0x000002FF, 0x000002FF, CPU_MTRR,	},
 
 	{ 0x00000300, 0x00000311, CPU_PMC,	},
 	{ 0x00000345, 0x00000345, CPU_PMC,	},
 	{ 0x00000360, 0x00000371, CPU_PMC,	},
-	{ 0x0000038D, 0x00000390, CPU_PMC,	},
+	{ 0x0000038D, 0x00000396, CPU_PMC,	},
 	{ 0x000003A0, 0x000003BE, CPU_PMC,	},
 	{ 0x000003C0, 0x000003CD, CPU_PMC,	},
 	{ 0x000003E0, 0x000003E1, CPU_PMC,	},
-	{ 0x000003F0, 0x000003F2, CPU_PMC,	},
+	{ 0x000003F0, 0x000003FD, CPU_PMC,	},
 
-	{ 0x00000400, 0x00000417, CPU_MC,	},
+	{ 0x00000400, 0x00000421, CPU_MC,	},
 	{ 0x00000480, 0x0000048B, CPU_VMX,	},
 
 	{ 0x00000600, 0x00000600, CPU_DEBUG,	},
 	{ 0x00000680, 0x0000068F, CPU_LBRANCH,	},
 	{ 0x000006C0, 0x000006CF, CPU_LBRANCH,	},
 
-	{ 0x000107CC, 0x000107D3, CPU_PMC,	},
+	{ 0x00000800, 0x0000083F, CPU_APIC,	},
+
+	{ 0x000107CC, 0x000107D8, CPU_PMC,	},
 
 	{ 0xC0000080, 0xC0000080, CPU_FEATURES,	},
 	{ 0xC0000081, 0xC0000084, CPU_CALL,	},
@@ -144,18 +157,23 @@ static struct cpu_debug_range cpu_reg_range[] = {
 	{ 0xC0010016, 0xC001001A, CPU_MTRR,	},
 	{ 0xC001001D, 0xC001001D, CPU_MTRR,	},
 	{ 0xC001001F, 0xC001001F, CPU_CONF,	},
-	{ 0xC0010030, 0xC0010035, CPU_BIOS,	},
-	{ 0xC0010044, 0xC0010048, CPU_MC,	},
+	{ 0xC0010022, 0xC0010022, CPU_MC,	},
+	{ 0xC0010030, 0xC0010035, CPU_PNAME,	},
+	{ 0xC0010044, 0xC0010049, CPU_MC,	},
 	{ 0xC0010050, 0xC0010056, CPU_SMM,	},
 	{ 0xC0010058, 0xC0010058, CPU_CONF,	},
 	{ 0xC0010060, 0xC0010060, CPU_CACHE,	},
-	{ 0xC0010061, 0xC0010068, CPU_SMM,	},
-	{ 0xC0010069, 0xC001006B, CPU_SMM,	},
+	{ 0xC0010061, 0xC001006B, CPU_POWER,	},
 	{ 0xC0010070, 0xC0010071, CPU_SMM,	},
+	{ 0xC0010074, 0xC0010074, CPU_TIME,	},
 	{ 0xC0010111, 0xC0010113, CPU_SMM,	},
 	{ 0xC0010114, 0xC0010118, CPU_SVM,	},
 	{ 0xC0010140, 0xC0010141, CPU_OSVM,	},
+
+	{ 0xC0011004, 0xC0011005, CPU_FEATURES,	},
 	{ 0xC0011022, 0xC0011023, CPU_CONF,	},
+	{ 0xC001102A, 0xC001102A, CPU_CONF,	},
+	{ 0xC0011030, 0xC001103A, CPU_IBS,	},
 };
 
 static int is_typeflag_valid(unsigned cpu, unsigned flag)
Signature · 1 line
1.6.0.6
#6 lore raw

RFC PATCH 6/10 x86: cpu_debug make room for more cpu registers

Added Register category flags and define MSR_ for MSRs so that we can add more cpu registers and distguish between them.

using name "state" do describe the state

---
 arch/x86/include/asm/cpu_debug.h |    7 ++++
 arch/x86/kernel/cpu/cpu_debug.c  |   59 ++++++++++++++++++++++----------------
 2 files changed, 41 insertions(+), 25 deletions(-)
arch/x86/include/asm/cpu_debug.h +7 -0
index f2adad3..79710f2 100644
@@ -57,6 +57,12 @@ enum cpu_file_bit {
 	CPU_VALUE,				/* value		*/
 };
 
+/* Register category flags */
+enum cpu_cat_bit {
+	CPU_REG_STD,				/* Standard registers	*/
+	CPU_REG_MSR,				/* MSRs			*/
+};
+
 #define MAX_CPU_FILES		512
 
 struct cpu_private {
@@ -64,6 +70,7 @@ struct cpu_private {
 	unsigned		type;
 	unsigned		reg;
 	unsigned		file;
+	unsigned		cat;
 };
 
 struct cpu_debug_base {
arch/x86/kernel/cpu/cpu_debug.c +34 -25

171 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#7 lore raw

RFC PATCH 7/10 x86: cpu_debug support APIC_register_name with directory structure

Added Register category flags and define APIC_ for APIC registers so that we can distguish between them.

---
 arch/x86/include/asm/cpu_debug.h |    1 +
 arch/x86/kernel/cpu/cpu_debug.c  |  132 +++++++++++++++++++++++++++++---------
 2 files changed, 102 insertions(+), 31 deletions(-)
arch/x86/include/asm/cpu_debug.h +1 -0
index 79710f2..fd20da7 100644
@@ -61,6 +61,7 @@ enum cpu_file_bit {
 enum cpu_cat_bit {
 	CPU_REG_STD,				/* Standard registers	*/
 	CPU_REG_MSR,				/* MSRs			*/
+	CPU_REG_APIC,				/* APIC registers	*/
 };
 
 #define MAX_CPU_FILES		512
arch/x86/kernel/cpu/cpu_debug.c +101 -31

168 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#8 lore raw

RFC PATCH 8/10 x86: cpu_debug display PCI configuration registers for AMD

PCI-defined configuration space PCIX_YYY:

X specifies the function number
YYY specifies the byte address of the configuration register in hex

e.g., PCI3_040 specifies the register at function 3, address 0x40.

AMD processor supports five functions, 0 through 4.

Also updated MAX_CPU_FILES to 768 to handle pci files.

---
 arch/x86/include/asm/cpu_debug.h |   11 ++-
 arch/x86/kernel/cpu/cpu_debug.c  |  280 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 288 insertions(+), 3 deletions(-)
arch/x86/include/asm/cpu_debug.h +10 -1
index fd20da7..dc24338 100644
@@ -41,10 +41,17 @@ enum cpu_debug_bit {
 	CPU_IBS,				/* IBS			*/
 	CPU_SVM,				/*Secure Virtual Machine*/
 	CPU_OSVM,				/* OS-Visible Workaround*/
+	CPU_NB,					/* North Bridge		*/
+	CPU_DRAM,				/* DRAM			*/
+	CPU_MMIO,				/* Memory based IO	*/
+	CPU_DISPLAY,				/* Display/VGA		*/
+	CPU_LINK,				/* HyperTransport	*/
+	CPU_CPUID,				/* CPUID		*/
 /* Standard Registers							*/
 	CPU_TSS,				/* Task Stack Segment	*/
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
+	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
 };
@@ -62,9 +69,11 @@ enum cpu_cat_bit {
 	CPU_REG_STD,				/* Standard registers	*/
 	CPU_REG_MSR,				/* MSRs			*/
 	CPU_REG_APIC,				/* APIC registers	*/
+	CPU_REG_PCI,				/* PCI conf registers	*/
 };
 
-#define MAX_CPU_FILES		512
+#define MAX_CPU_FILES		768		/* Max CPU debug files	*/
+#define MAX_CPU_PCI		5		/* AMD supports func 0-4*/
 
 struct cpu_private {
 	unsigned		cpu;
arch/x86/kernel/cpu/cpu_debug.c +278 -2

342 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#9 lore raw

RFC PATCH 9/10 x86: cpu_debug display cpuid functions

Add support for cpuid standard and extended functions

---
 arch/x86/include/asm/cpu_debug.h |    4 ++-
 arch/x86/kernel/cpu/cpu_debug.c  |   64 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpu_debug.h +3 -1
index dc24338..377f658 100644
@@ -46,11 +46,11 @@ enum cpu_debug_bit {
 	CPU_MMIO,				/* Memory based IO	*/
 	CPU_DISPLAY,				/* Display/VGA		*/
 	CPU_LINK,				/* HyperTransport	*/
-	CPU_CPUID,				/* CPUID		*/
 /* Standard Registers							*/
 	CPU_TSS,				/* Task Stack Segment	*/
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
+	CPU_CPUID,				/* CPUID		*/
 	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
@@ -75,6 +75,8 @@ enum cpu_cat_bit {
 #define MAX_CPU_FILES		768		/* Max CPU debug files	*/
 #define MAX_CPU_PCI		5		/* AMD supports func 0-4*/
 
+#define CPUID_MASK		0xffff0000
+
 struct cpu_private {
 	unsigned		cpu;
 	unsigned		type;
arch/x86/kernel/cpu/cpu_debug.c +61 -3

103 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#10 lore raw

RFC PATCH 10/10 x86: cpu_debug display basic cpuinfo

Add support for display struct cpuinfo_x86

---
 arch/x86/include/asm/cpu_debug.h |    1 +
 arch/x86/kernel/cpu/cpu_debug.c  |   89 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)
arch/x86/include/asm/cpu_debug.h +1 -0
index 377f658..b75758e 100644
@@ -51,6 +51,7 @@ enum cpu_debug_bit {
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
 	CPU_CPUID,				/* CPUID		*/
+	CPU_CPUINFO,				/* struct cpuinfo_x86	*/
 	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
arch/x86/kernel/cpu/cpu_debug.c +89 -0

113 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#11 lore raw

Re: [RFC][PATCH 9/10 -tip] x86: cpu_debug display cpuid functions

In reply to Jaswinder Singh Rajput
Quoted 52 lines · Jaswinder Singh Rajput

Add support for cpuid standard and extended functions

---
 arch/x86/include/asm/cpu_debug.h |    4 ++-
 arch/x86/kernel/cpu/cpu_debug.c  |   64 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpu_debug.h +3 -1
index dc24338..377f658 100644
@@ -46,11 +46,11 @@ enum cpu_debug_bit {
 	CPU_MMIO,				/* Memory based IO	*/
 	CPU_DISPLAY,				/* Display/VGA		*/
 	CPU_LINK,				/* HyperTransport	*/
-	CPU_CPUID,				/* CPUID		*/
 /* Standard Registers							*/
 	CPU_TSS,				/* Task Stack Segment	*/
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
+	CPU_CPUID,				/* CPUID		*/
 	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
@@ -75,6 +75,8 @@ enum cpu_cat_bit {
 #define MAX_CPU_FILES		768		/* Max CPU debug files	*/
 #define MAX_CPU_PCI		5		/* AMD supports func 0-4*/
 
+#define CPUID_MASK		0xffff0000
+
 struct cpu_private {
 	unsigned		cpu;
 	unsigned		type;
arch/x86/kernel/cpu/cpu_debug.c +1 -1
index b4dfddd..f7f702e 100644
@@ -72,10 +72,10 @@ static struct cpu_debug_base cpu_base[] = {
 	{ "mmio",	CPU_MMIO,	0	},
 	{ "display",	CPU_DISPLAY,	0	},
 	{ "link",	CPU_LINK,	0	},
-	{ "cpuid",	CPU_CPUID,	0	},
 	{ "tss",	CPU_TSS,	0	},
 	{ "cr",		CPU_CR,		0	},
 	{ "dt",		CPU_DT,		0	},
+	{ "cpuid",	CPU_CPUID,	0	},
 	{ "pci",	CPU_PCI,	0	},
 	{ "registers",	CPU_REG_ALL,	0	},
 };

arch/x86/kernel/cpu/cpu_debug.c static struct cpu_debug_range cpu_amd_pci4[] = { · line 311

Quoted 9 lines
arch/x86/kernel/cpu/cpu_debug.c +5 -0
@@ -303,6 +303,13 @@ static struct cpu_debug_range cpu_amd_pci4[] = {
 	{ 0x1E0,	0x1F0,	CPU_POWER	},
 };
 
+/* Extended CPUID base address			*/
+static u32 cpu_ext_cpuid[] = {
+	0x80000000,		/* Intel, AMD	*/
+	0x80860000,		/* Transmeta	*/
+	0xC0000000,		/* Centaur	*/
 

VIA/Centaur has both 0xC0000000 and 0x8000000

Mike

Quoted 88 lines
arch/x86/kernel/cpu/cpu_debug.c +2 -0
+};
+
 /* Check validity of cpu debug flag */
 static int is_typeflag_valid(unsigned cpu, unsigned flag)

{

arch/x86/kernel/cpu/cpu_debug.c +53 -2
@@ -518,6 +525,49 @@ static void print_apic(void *arg)
 #endif
 }
 
+/* Get extended CPUID level */
+static u32 get_extended_cpuid(void)
+{
+	u32 i, level;
+
+	for (i = 0; i < ARRAY_SIZE(cpu_ext_cpuid); i++) {
+		level = cpuid_eax(cpu_ext_cpuid[i]);
+		if ((level & CPUID_MASK) == cpu_ext_cpuid[i])
+			return level;
+	}
+
+	return 0;		/* Not found */
+}
+
+static void print_cpuidabcd(struct seq_file *seq, u32 min, u32 max)
+{
+	u32 i, eax, ebx, ecx, edx;
+
+	for (i = min; i <= max; i++) {
+		cpuid(i, &eax, &ebx, &ecx, &edx);
+		seq_printf(seq, " %08x  %08x  %08x  %08x  %08x\n",
+			   i, eax, ebx, ecx, edx);
+	}
+}
+
+static void print_cpuid(void *arg)
+{
+	struct seq_file *seq = arg;
+	u32 level;
+
+	seq_printf(seq, " CPUID\t:\n");
+	seq_printf(seq, "              eax       ebx       ecx       edx\n");
+
+	/* Standard CPUID functions */
+	level = cpuid_eax(0);
+	print_cpuidabcd(seq, 0, level);
+
+	/* Extended CPUID functions */
+	level = get_extended_cpuid();
+	if (level)
+		print_cpuidabcd(seq, (level & CPUID_MASK), level);
+}
+
 static void print_apicval(void *arg)
 {
 	struct seq_file *seq = arg;
@@ -632,6 +682,14 @@ static int cpu_seq_show(struct seq_file *seq, void *v)
 	case CPU_DT:
 		smp_call_function_single(priv->cpu, print_dt, seq, 1);
 		break;
+	case CPU_CPUID:
+		if (priv->file == CPU_INDEX)
+			smp_call_function_single(priv->cpu, print_cpuid,
+						 seq, 1);
+		else
+			smp_call_function_single(priv->cpu, print_pcival,
+						 seq, 1);
+		break;
 	case CPU_PCI:
 		if (priv->file == CPU_INDEX)
 			smp_call_function_single(priv->cpu, print_pci, seq, 1);
@@ -814,7 +872,7 @@ static int cpu_init_regfiles(unsigned cpu, unsigned int type, unsigned reg,
 	unsigned file;
 	int err = 0;
 
-	for (file = 0; file <  ARRAY_SIZE(cpu_file); file++) {
+	for (file = 0; file < ARRAY_SIZE(cpu_file); file++) {
 		err = cpu_create_file(cpu, type, reg, file, cat, dentry);
 		if (err)
 			return err;
@@ -973,7 +1031,7 @@ static int cpu_init_allreg(unsigned cpu, struct dentry *dentry)
 	unsigned type;
 	int err = 0;
 
-	for (type = 0; type <  ARRAY_SIZE(cpu_base) - 1; type++) {
+	for (type = 0; type < ARRAY_SIZE(cpu_base) - 1; type++) {
 		cpu_dentry = debugfs_create_dir(cpu_base[type].name, dentry);
 		per_cpu(cpu_arr[type].dentry, cpu) = cpu_dentry;
 
#12 lore raw

Re: [RFC][PATCH 9/10 -tip] x86: cpu_debug display cpuid functions

Quoted 56 lines · Michael S. Zick
Quoted 55 lines · Jaswinder Singh Rajput

Add support for cpuid standard and extended functions

---
 arch/x86/include/asm/cpu_debug.h |    4 ++-
 arch/x86/kernel/cpu/cpu_debug.c  |   64 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpu_debug.h +3 -1
index dc24338..377f658 100644
@@ -46,11 +46,11 @@ enum cpu_debug_bit {
 	CPU_MMIO,				/* Memory based IO	*/
 	CPU_DISPLAY,				/* Display/VGA		*/
 	CPU_LINK,				/* HyperTransport	*/
-	CPU_CPUID,				/* CPUID		*/
 /* Standard Registers							*/
 	CPU_TSS,				/* Task Stack Segment	*/
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
+	CPU_CPUID,				/* CPUID		*/
 	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
@@ -75,6 +75,8 @@ enum cpu_cat_bit {
 #define MAX_CPU_FILES		768		/* Max CPU debug files	*/
 #define MAX_CPU_PCI		5		/* AMD supports func 0-4*/
 
+#define CPUID_MASK		0xffff0000
+
 struct cpu_private {
 	unsigned		cpu;
 	unsigned		type;
arch/x86/kernel/cpu/cpu_debug.c +1 -1
index b4dfddd..f7f702e 100644
@@ -72,10 +72,10 @@ static struct cpu_debug_base cpu_base[] = {
 	{ "mmio",	CPU_MMIO,	0	},
 	{ "display",	CPU_DISPLAY,	0	},
 	{ "link",	CPU_LINK,	0	},
-	{ "cpuid",	CPU_CPUID,	0	},
 	{ "tss",	CPU_TSS,	0	},
 	{ "cr",		CPU_CR,		0	},
 	{ "dt",		CPU_DT,		0	},
+	{ "cpuid",	CPU_CPUID,	0	},
 	{ "pci",	CPU_PCI,	0	},
 	{ "registers",	CPU_REG_ALL,	0	},
 };
@@ -303,6 +303,13 @@ static struct cpu_debug_range cpu_amd_pci4[] = {
 	{ 0x1E0,	0x1F0,	CPU_POWER	},
 };
 
Quoted 9 lines

arch/x86/kernel/cpu/cpu_debug.c static struct cpu_debug_range cpu_amd_pci4[] = { · line 311

Quoted 6 lines
arch/x86/kernel/cpu/cpu_debug.c +5 -0
+/* Extended CPUID base address			*/
+static u32 cpu_ext_cpuid[] = {
+	0x80000000,		/* Intel, AMD	*/
+	0x80860000,		/* Transmeta	*/
+	0xC0000000,		/* Centaur	*/
 

VIA/Centaur has both 0xC0000000 and 0x8000000

hmm, then this patch will work for multiple extended cpuid levels :

[PATCH 9/10 -tip] x86: cpu_debug display cpuid functions

Add support for cpuid standard and extended functions

---
 arch/x86/include/asm/cpu_debug.h |    4 ++-
 arch/x86/kernel/cpu/cpu_debug.c  |   52 +++++++++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 4 deletions(-)
arch/x86/include/asm/cpu_debug.h +3 -1
index dc24338..377f658 100644
@@ -46,11 +46,11 @@ enum cpu_debug_bit {
 	CPU_MMIO,				/* Memory based IO	*/
 	CPU_DISPLAY,				/* Display/VGA		*/
 	CPU_LINK,				/* HyperTransport	*/
-	CPU_CPUID,				/* CPUID		*/
 /* Standard Registers							*/
 	CPU_TSS,				/* Task Stack Segment	*/
 	CPU_CR,					/* Control Registers	*/
 	CPU_DT,					/* Descriptor Table	*/
+	CPU_CPUID,				/* CPUID		*/
 	CPU_PCI,				/* PCI configuration	*/
 /* End of Registers flags						*/
 	CPU_REG_MAX,				/* Max Registers flags	*/
@@ -75,6 +75,8 @@ enum cpu_cat_bit {
 #define MAX_CPU_FILES		768		/* Max CPU debug files	*/
 #define MAX_CPU_PCI		5		/* AMD supports func 0-4*/
 
+#define CPUID_MASK		0xffff0000
+
 struct cpu_private {
 	unsigned		cpu;
 	unsigned		type;
arch/x86/kernel/cpu/cpu_debug.c +49 -3

91 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#13 lore raw
In reply to Jaswinder Singh Rajput
Quoted 2 lines · Jaswinder Singh Rajput

Please let me know how we can improve it and add more features so it becomes more useful.

I really have to ask, why this is useful at all.

Quoted 1 line

1. Standard Registers

What's the point of printing task_pt_regs(current) ?

We dump info of "cat debug/.../tss". Where is the value of this ? Just because we can ?

Quoted 1 line

2. Control Registers

I can see some value in dumping CR0 and CR4, but the rest is pretty useless

CR2 is the pagefault address, which is uninteresting as there is no context

CR3 is the pagedir, which is pretty uninteresting as well. If we read it on the current CPU we read the pagedir of "cat ..../cr3" and if we read it on some other CPU its completely out of context. We see a pagedir entry and have no information about the context.

CR8 is unused in Linux and always 0

Quoted 1 line

3. Debug Registers

Again, where is the point? These registers are only interesting when we know about the context. This interface just provides the access to random information.

We already have debuggers which use that and they know the context they are operating in.

Quoted 1 line

4. Descriptor Tables

What's the value of pointers to IDT, GDT tables ? The interesting information is in the tables, where IDT is static and uninteresting though GDT table contents can change

Again, LDT and TR are task context dependent values. Where is the information at which context we are looking ?

Quoted 1 line

5. APIC Registers

Dunno, what we gain from that information.

Quoted 1 line

6. Model specific Register (MSRs)

Where is the difference of poking in

/sys/kernel/debug/x86/cpu/cpu0/msr/MSR_c0010006/value

and

rdmsr,wrmsr poking on the same MSR ?

There is no difference at all. The information difference is _ZERO_. The only difference is memory consumption in the kernel and a even more horrible user interface than we have with mrs-tools.

7. PCI configuration registers (for AMD)

What's the value add over lspci ?

Quoted 1 line

8. Basic cpuinfo

Why do we need another incarnation of /proc/cpuinfo ?

Also cpuid provides more useful decoded information than this.

Quoted 1 line

9. CPUID Functions

Again, cpuid can do this already w/o a single line of kernel code.

Can we please get some coherent explanation why we need this in the kernel?

Granted there are about 4 interesting registers where we have no interface yet and where user space tools can not look into, but 99% of the information exposed by this module is either useless or redundant or both.

The worst stuff is the reinvention of exising and _useful_ userspace tools. Just one example:

AMD specific PCI registers

Current solution:

Ask user to run lscpi -vvv and lspci -xxx[x] and provide the output, which is for -vvv very well decoded and for -xxxx the same raw data as we get from cpu_debug (except for the line count)

Single point of failure: lspci is not installed, which is unlikely, but easy to solve and users/bugreporters usually know how to do that. Worst case you have to tell him how to do it.

cpu_debug solution:

Ask user to compile the module, load the module, mount debugfs and provide the output of debug/..... The output is a HEX dump of the PCI configuration space and has no more information than the lscpi -xxxx dump, indeed it has less:

lspci -xxxx tells me at which device it is looking in clear text with a useful description while this tells me:

PCI configuration regsiters :
function : 0
000 : 13001022

So i need to look at the code to see at which pci config space this is looking and what "function 0" is all about. How useful.

Multiple points of failure:
user can not compile the module
user fails to load the module
user fails to mount debugfs

Same applies for cpuid and msr access. This cpu_debug stuff is harder to use and provides the same of mostly less information. What's the gain ?

I'm a full supporter of _useful_ debug interfaces, but this is definitely not what I call useful and useable.

The reinvention of useful tools like lspci, cpuid, rdmsr, wrmsr inside of the kernel with a worse user interface and less information provided is just a waste of time and resources.

Dumping random information out of any context is not helping us to debug problems. There is no value to look at debug registers, context registers and tss->regs without the context of the task we look at.

Can we please stop adding more random features to this?

This needs to be done the other way round. First we need to remove all redundant and useless interfaces from cpu_debug and then think carefully about in which way we want to expose the few really missing interesting things either by extending existing user space tools or by providing context aware and debug relevant interfaces in the kernel.

Thanks,

tglx

#14 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Jaswinder Singh Rajput

Please let me know how we can improve it and add more features so it becomes more useful.

I really have to ask, why this is useful at all.

Currently for X86 I can do :

1. read complete state (dump all registers like for MTRR, APIC)
2. read individual register
3. write to individual register
4. read/write these registers/info with shell through debugfs
5. read these registers/info before getting shell

And I did this for complete X86 CPU registers and info:
1. Standard Registers
2. Control Registers
3. Debug Registers
4. Descriptor Tables
5. APIC Registers
6. Model specific Register (MSRs)
7. PCI configuration registers (for AMD)
8. Basic cpuinfo
9. CPUID Functions

This will be really useful for :
1. developer who is porting/developing the kernel or drivers.
2. User who is reading hardware manual and want to see these value on its CPU

Of course you need a Hardware manual to check address and detail information. I do not want to keep detail for each register.

In X86 many tools are available which can read many registers but not available for many architectures (I CCed some architecture maintainers so that they can also specify issues they face when supporting new CPU/architecture), they can also take advantage of it if we move cpu_debug architecture independent portion outside X86.

I am not against of any tool but some issues about tools are :
1. Not supported for all architectures
2. Do not support latest or upcoming hardware
3. You need to mount filesystem and execute some shell to give commands
4. you need different tools to access different registers

So I want to know how can we can make cpu_debug more useful.

Quoted 4 lines

The reinvention of useful tools like lspci, cpuid, rdmsr, wrmsr inside of the kernel with a worse user interface and less information provided is just a waste of time and resources.

what user interface and information you want ?

Thanks,
--
JSR

#15 lore raw

Jaswinder,

[ I sanitized the cc list to restrict the annoyance to those who have to deal with that. Please stop adding people who are not affected by this. ]

Quoted 17 lines · Jaswinder Singh Rajput
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Jaswinder Singh Rajput

Please let me know how we can improve it and add more features so it becomes more useful.

I really have to ask, why this is useful at all.

Currently for X86 I can do :

1. read complete state (dump all registers like for MTRR, APIC)
2. read individual register
3. write to individual register
4. read/write these registers/info with shell through debugfs
5. read these registers/info before getting shell

Quoted 10 lines

And I did this for complete X86 CPU registers and info:
1. Standard Registers
2. Control Registers
3. Debug Registers
4. Descriptor Tables
5. APIC Registers
6. Model specific Register (MSRs)
7. PCI configuration registers (for AMD)
8. Basic cpuinfo
9. CPUID Functions

I did not ask what it can do. I did ask what's the usefulness of it. Your answer is the same list on which I commented on already in technical detail, but you ignored those comments.

Quoted 2 lines

This will be really useful for :
1. developer who is porting/developing the kernel or drivers.

We can access all this information already with existing tools.

Quoted 2 lines

2. User who is reading hardware manual and want to see these value on its CPU

Same here.

Quoted 2 lines

Of course you need a Hardware manual to check address and detail information. I do not want to keep detail for each register.

That's why anyone with common sense will use lspci, cpuid to get the information in both raw and decoded format.

Quoted 4 lines

In X86 many tools are available which can read many registers but not available for many architectures (I CCed some architecture maintainers so that they can also specify issues they face when supporting new CPU/architecture), they can also take advantage of it if we move

I have ported Linux to a couple of new platforms and the problem you face is that the kernel does not boot at all in the early stage of the boot process.

How does cpu_debug help in that situation ? It does not help at all.

Quoted 1 line

cpu_debug architecture independent portion outside X86.

There is nothing x86 independent in cpu_debug.

Quoted 2 lines

I am not against of any tool but some issues about tools are :
1. Not supported for all architectures

Again cpu_debug can not made generic as it is poking in architecture specific hardware.

Quoted 1 line

2. Do not support latest or upcoming hardware

All these tools show the raw values, which also covers latest hardware.

Quoted 1 line

3. You need to mount filesystem and execute some shell to give commands

Are you saying that the access to your debugfs based cpu_debug information does neither require a mounted file system nor a shell nor commands? It provides the information by telepathy, right?

Quoted 1 line

4. you need different tools to access different registers

Write a wrapper script if that annoys you.

Quoted 1 line

So I want to know how can we can make cpu_debug more useful.

I have not yet seen a single technical argument for what it is useful at all.

So please stop hand waving about what it might do as long as you can not provide a single technical reason why cpu_debug should be in the kernel at all.

Go through the kernel.org bugzilla and show me _one_ single bug which I debugged with the bug reporter, which could have been resolved faster by using cpu_debug. And think careful about it before you provide me that information.

Quoted 6 lines
Quoted 4 lines

The reinvention of useful tools like lspci, cpuid, rdmsr, wrmsr inside of the kernel with a worse user interface and less information provided is just a waste of time and resources.

what user interface and information you want ?

I'm happy to use the existing tools and their user interface. There is no value of having inferior reimplementations of those tools in the kernel.

Thanks,

tglx

#16 lore raw
Quoted 6 lines · Thomas Gleixner

Jaswinder,

[ I sanitized the cc list to restrict the annoyance to those who have to deal with that. Please stop adding people who are not affected by this. ]

I wrote cpu_debug because of past issues I faced working with Hitachi and ARM processor. I just start working on X86 from last few months, I wrote cpu_debug for X86 because currently I have only X86 machine, I am planning to divide cpu_debug into architecture dependent and non-dependent code so that other architectures can also benefit from it.

That's why I CCed other architecture's maintainers.

Quoted 5 lines
Quoted 2 lines

This will be really useful for :
1. developer who is porting/developing the kernel or drivers.

We can access all this information already with existing tools.

Why you are thinking about X86 ?

I worked on embedded processors more than 10 year, I never found any tools, and sometimes we get the first lot of the boards.

Only tool which I used is printk.

Even though the code I used in cpu_debug I wrote that code to support :
1. Performance counters for AMD
2. Support Temperature sensor for AMD 11H

Quoted 6 lines
Quoted 3 lines

Of course you need a Hardware manual to check address and detail information. I do not want to keep detail for each register.

That's why anyone with common sense will use lspci, cpuid to get the information in both raw and decoded format.

These does not make sense if the kernel is not booting and filesystem is not available.
To use the tools I need to build the tools, build filesystem for my processor and load on filesystem.

Quoted 6 lines
Quoted 5 lines

In X86 many tools are available which can read many registers but not available for many architectures (I CCed some architecture maintainers so that they can also specify issues they face when supporting new CPU/architecture), they can also take advantage of it if we move

Quoted 6 lines

I have ported Linux to a couple of new platforms and the problem you face is that the kernel does not boot at all in the early stage of the boot process.

How does cpu_debug help in that situation ? It does not help at all.

I supported functions if you pass seq = NULL then it will print on screen, then you do need any filesystem or debugfs.

Quoted 4 lines
Quoted 1 line

cpu_debug architecture independent portion outside X86.

There is nothing x86 independent in cpu_debug.

There is, I will show you.

Quoted 6 lines
Quoted 2 lines

I am not against of any tool but some issues about tools are :
1. Not supported for all architectures

Again cpu_debug can not made generic as it is poking in architecture specific hardware.

Ok I will show you.

Quoted 4 lines
Quoted 1 line

2. Do not support latest or upcoming hardware

All these tools show the raw values, which also covers latest hardware.

But when I used them they said processor not supported.

Quoted 6 lines
Quoted 1 line

3. You need to mount filesystem and execute some shell to give commands

Are you saying that the access to your debugfs based cpu_debug information does neither require a mounted file system nor a shell nor commands? It provides the information by telepathy, right?

you can call the function, and pass seq as NULL, it will use printk and dump state on screen. I just did this for MSR, I can also support for other registers.

Quoted 4 lines
Quoted 1 line

4. you need different tools to access different registers

Write a wrapper script if that annoys you.

when tools, filesystem and shell is not available where you will run your script ?

Quoted 5 lines
Quoted 1 line

So I want to know how can we can make cpu_debug more useful.

I have not yet seen a single technical argument for what it is useful at all.

Because your eyes are closed, please open it.

Thanks,
--
JSR

#17 lore raw

Jaswinder,

Quoted 8 lines · Jaswinder Singh Rajput
Quoted 5 lines · Thomas Gleixner
Quoted 2 lines

This will be really useful for :
1. developer who is porting/developing the kernel or drivers.

We can access all this information already with existing tools.

Why you are thinking about X86 ?

Because I work on it and that code is in the area which I'm responsible for. And I want useful code in that area, not something which causes a lot of churn for no value at all.

Quoted 2 lines

I worked on embedded processors more than 10 year, I never found any tools, and sometimes we get the first lot of the boards.

I have worked on ARM, MIPS, SH, PPC often enough and I never needed such a tool.

Quoted 1 line

Only tool which I used is printk.

Which is perfectly fine to do low level debugging.

Quoted 3 lines

Even though the code I used in cpu_debug I wrote that code to support :
1. Performance counters for AMD
2. Support Temperature sensor for AMD 11H

And you needed cpu_debug to do this ?

Sorry, I really do not understand that. Ingo and I wrote the inital code of performance counters (both the generic parts and Intel support) in a couple of days w/o feeling the need of cpu_debug even once.

If you need cpu_debug for doing your work, fine. Maintain it somewhere and figure out how many people come along and find it useful. But do not impose this on the x86 code base.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

In X86 many tools are available which can read many registers but not available for many architectures (I CCed some architecture maintainers so that they can also specify issues they face when supporting new CPU/architecture), they can also take advantage of it if we move

Quoted 8 lines
Quoted 6 lines

I have ported Linux to a couple of new platforms and the problem you face is that the kernel does not boot at all in the early stage of the boot process.

How does cpu_debug help in that situation ? It does not help at all.

I supported functions if you pass seq = NULL then it will print on screen, then you do need any filesystem or debugfs.

Fine. And what is triggering the printout of a particular register ?

You need to hack the kernel to call the print functions in cpu_debug, right ?

So where is the value of this? It is ad hoc debugging and there is no gain to replace a printk(THE INFO I NEED) with a call to cpu_debug().

Actually its worse. If I need the information of an APIC register, then I print excaclty this register and not the whole lot of registers, which then will scroll the screen with the important information away.

Also I need information of a register in context with the content of some variables of the code I'm debugging. printk() allows me to add sensible and useful information in a compact format. cpu_debug does not.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

2. Do not support latest or upcoming hardware

All these tools show the raw values, which also covers latest hardware.

But when I used them they said processor not supported.

And why didn't you get the source and fix it? Instead of improving an existing tool you impose a ridicolous amount of useless code on x86.

Quoted 10 lines
Quoted 6 lines
Quoted 1 line

3. You need to mount filesystem and execute some shell to give commands

Are you saying that the access to your debugfs based cpu_debug information does neither require a mounted file system nor a shell nor commands? It provides the information by telepathy, right?

you can call the function, and pass seq as NULL, it will use printk and dump state on screen. I just did this for MSR, I can also support for other registers.

As I said above. There is no gain in doing so. Ad hoc debugging is the same with printk and cpu_debug except that cpu_debug is inferior.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

So I want to know how can we can make cpu_debug more useful.

I have not yet seen a single technical argument for what it is useful at all.

Because your eyes are closed, please open it.

I have my eyes open and I looked at the existing code and the proposed patches in detail. I also looked at your arguments which can be boiled down to:

1) Jaswinder prefers to have cpu_debug_print_whatever() instead of printk(THE INFO I NEED) for ad hoc debugging.

2) Jaswinder cannot work without cpu_debug.

Both are not really convincing technical arguments. cpu_debug has _ZERO_ gain over printk() based debugging and it adds _ZERO_ value with its debugfs based interface.

Thanks,

tglx

#18 lore raw
In reply to Thomas Gleixner
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines · Jaswinder Singh Rajput

Please let me know how we can improve it and add more features so it becomes more useful.

I second almost all of Thomas points. (The more I am wondering why cpu_debug was merged at all.)

IMHO removing the cpuid, msr etc. stuff is the right thing to do.

But hey, I even can provide a "use case" for cpu_debug.

Recently I wanted to check some APIC registers. Instead of rebooting the machine with apic=debug I loaded the module, mounted debugfs and looked at the cpu_debug stuff to experience that ...

The registers that I was interested in were not provided.

So I had to add some code to print some of the regs in the extended APIC register with apic=debug code. When submitting the patch upstream I added the same regs to cpu_debug code. This really good shows another weak point of cpu_debug:

If the kernel has already code for debugging output cpu_debug just reinvents the wheel and does not even try to reuse existing code.

So in the end cpu_debug wasn't useful for me at all.

<snip>

Quoted 11 lines

Dumping random information out of any context is not helping us to debug problems. There is no value to look at debug registers, context registers and tss->regs without the context of the task we look at.

Can we please stop adding more random features to this?

This needs to be done the other way round. First we need to remove all redundant and useless interfaces from cpu_debug and then think carefully about in which way we want to expose the few really missing interesting things either by extending existing user space tools or by providing context aware and debug relevant interfaces in the kernel.

IMHO the cpu_debug feature should be renamed to platform_debug and then already existing kernel debug code could be modified such that it can also be called from this new platform_debug facility. This would allow to check certain things not only when booting Linux with certain debug parameters but also on the fly when mounting the debugfs ...

The registers that come into my mind that would make some kind of sense to provide with that interface are
- APIC stuff
- HPET stuff

Neither MSR, CPUID, CPU regs nor PCI config space stuff should be added. Other facilities/tools exist for those (e.g. x86info, msr-tools, pciutils or Magic SysRq).

... just my two cents.

Regards,

Andreas