Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e43e1b7 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds
Browse files

[PATCH] x86_64: Remove CONFIG_CHECKING and add command line option for pagefault tracing



CONFIG_CHECKING covered some debugging code used in the early times
of the port. But it wasn't even SMP safe for quite some time
and the bugs it checked for seem to be gone.

This patch removes all the code to verify GS at kernel entry. There
haven't been any new bugs in this area for a long time.

Previously it also covered the sysctl for the page fault tracing.
That didn't make much sense because that code was unconditionally
compiled in. I made that a boot option now because it is typically
only useful at boot.

Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ffd10a2b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -193,6 +193,9 @@ Debugging


  kstack=N   Print that many words from the kernel stack in oops dumps.
  kstack=N   Print that many words from the kernel stack in oops dumps.


  pagefaulttrace Dump all page faults. Only useful for extreme debugging
		and will create a lot of output.

Misc
Misc


  noreplacement  Don't replace instructions with more appropiate ones
  noreplacement  Don't replace instructions with more appropiate ones
+0 −9
Original line number Original line Diff line number Diff line
@@ -2,15 +2,6 @@ menu "Kernel hacking"


source "lib/Kconfig.debug"
source "lib/Kconfig.debug"


# !SMP for now because the context switch early causes GPF in segment reloading
# and the GS base checking does the wrong thing then, causing a hang.
config CHECKING
	bool "Additional run-time checks"
	depends on DEBUG_KERNEL && !SMP
	help
	  Enables some internal consistency checks for kernel debugging.
	  You should normally say N.

config INIT_DEBUG
config INIT_DEBUG
	bool "Debug __init statements"
	bool "Debug __init statements"
	depends on DEBUG_KERNEL
	depends on DEBUG_KERNEL
+0 −40
Original line number Original line Diff line number Diff line
@@ -428,19 +428,6 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
{
{
	conditional_sti(regs);
	conditional_sti(regs);


#ifdef CONFIG_CHECKING
       { 
               unsigned long gs; 
               struct x8664_pda *pda = cpu_pda + safe_smp_processor_id(); 
               rdmsrl(MSR_GS_BASE, gs); 
               if (gs != (unsigned long)pda) { 
                       wrmsrl(MSR_GS_BASE, pda); 
                       printk("%s: wrong gs %lx expected %p rip %lx\n", str, gs, pda,
			      regs->rip);
               }
       }
#endif

	if (user_mode(regs)) {
	if (user_mode(regs)) {
		struct task_struct *tsk = current;
		struct task_struct *tsk = current;


@@ -513,20 +500,6 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
{
{
	conditional_sti(regs);
	conditional_sti(regs);


#ifdef CONFIG_CHECKING
       { 
               unsigned long gs; 
               struct x8664_pda *pda = cpu_pda + safe_smp_processor_id(); 
               rdmsrl(MSR_GS_BASE, gs); 
               if (gs != (unsigned long)pda) { 
                       wrmsrl(MSR_GS_BASE, pda); 
		       oops_in_progress++;
                       printk("general protection handler: wrong gs %lx expected %p\n", gs, pda);
		       oops_in_progress--;
               }
       }
#endif

	if (user_mode(regs)) {
	if (user_mode(regs)) {
		struct task_struct *tsk = current;
		struct task_struct *tsk = current;


@@ -665,19 +638,6 @@ asmlinkage void __kprobes do_debug(struct pt_regs * regs,
	struct task_struct *tsk = current;
	struct task_struct *tsk = current;
	siginfo_t info;
	siginfo_t info;


#ifdef CONFIG_CHECKING
       { 
	       /* RED-PEN interaction with debugger - could destroy gs */
               unsigned long gs; 
               struct x8664_pda *pda = cpu_pda + safe_smp_processor_id(); 
               rdmsrl(MSR_GS_BASE, gs); 
               if (gs != (unsigned long)pda) { 
                       wrmsrl(MSR_GS_BASE, pda); 
                       printk("debug handler: wrong gs %lx expected %p\n", gs, pda);
               }
       }
#endif

	get_debugreg(condition, 6);
	get_debugreg(condition, 6);


	if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
	if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
+7 −12
Original line number Original line Diff line number Diff line
@@ -308,18 +308,6 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
	unsigned long flags;
	unsigned long flags;
	siginfo_t info;
	siginfo_t info;


#ifdef CONFIG_CHECKING
	{ 
		unsigned long gs; 
		struct x8664_pda *pda = cpu_pda + stack_smp_processor_id(); 
		rdmsrl(MSR_GS_BASE, gs); 
		if (gs != (unsigned long)pda) { 
			wrmsrl(MSR_GS_BASE, pda); 
			printk("page_fault: wrong gs %lx expected %p\n", gs, pda);
		}
	}
#endif

	/* get the address */
	/* get the address */
	__asm__("movq %%cr2,%0":"=r" (address));
	__asm__("movq %%cr2,%0":"=r" (address));
	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
@@ -571,3 +559,10 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
	force_sig_info(SIGBUS, &info, tsk);
	force_sig_info(SIGBUS, &info, tsk);
	return;
	return;
}
}

static int __init enable_pagefaulttrace(char *str)
{
	page_fault_trace = 1;
	return 0;
}
__setup("pagefaulttrace", enable_pagefaulttrace);
+0 −4
Original line number Original line Diff line number Diff line
@@ -565,10 +565,6 @@ extern int exception_trace, page_fault_trace;
static ctl_table debug_table2[] = {
static ctl_table debug_table2[] = {
	{ 99, "exception-trace", &exception_trace, sizeof(int), 0644, NULL,
	{ 99, "exception-trace", &exception_trace, sizeof(int), 0644, NULL,
	  proc_dointvec },
	  proc_dointvec },
#ifdef CONFIG_CHECKING
	{ 100, "page-fault-trace", &page_fault_trace, sizeof(int), 0644, NULL,
	  proc_dointvec },
#endif
	{ 0, }
	{ 0, }
}; 
};