All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: <linux-kernel@vger.kernel.org>
Subject: [PATCH 17/39] NLKD/i386 - core adjustments
Date: Wed, 09 Nov 2005 15:11:51 +0100	[thread overview]
Message-ID: <437211B6.76F0.0078.0@novell.com> (raw)
In-Reply-To: 43721184.76F0.0078.0@novell.com

[-- Attachment #1: Type: text/plain, Size: 129 bytes --]

The core i386 NLKD adjustments to pre-existing code.

Signed-Off-By: Jan Beulich <jbeulich@novell.com>

(actual patch attached)


[-- Attachment #2: linux-2.6.14-nlkd-i386.patch --]
[-- Type: application/octet-stream, Size: 9090 bytes --]

The core i386 NLKD adjustments to pre-existing code.

Signed-Off-By: Jan Beulich <jbeulich@novell.com>

Index: 2.6.14-nlkd/arch/i386/Kconfig
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/Kconfig	2005-11-04 16:19:32.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/Kconfig	2005-11-04 16:19:32.000000000 +0100
@@ -425,6 +425,11 @@ config X86_CMPXCHG64
 	depends on !M386 && !M486
 	default y
 
+config X86_CMOVE
+	bool
+	depends on !M386 && !M486 && !MCYRIXIII && !M586 && !M586TSC && !M586MMX && !MWINCHIPC6 && !MWINCHIP2 && !MWINCHIP3D && !MGEODEGX1
+	default y
+
 config X86_ALIGNMENT_16
 	bool
 	depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
Index: 2.6.14-nlkd/arch/i386/Kconfig.debug
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/Kconfig.debug	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/Kconfig.debug	2005-11-04 16:19:32.000000000 +0100
@@ -54,7 +54,7 @@ config DEBUG_PAGEALLOC
 
 config 4KSTACKS
 	bool "Use 4Kb for kernel stacks instead of 8Kb"
-	depends on DEBUG_KERNEL
+	depends on DEBUG_KERNEL && !NLKD
 	help
 	  If you say Y here the kernel will use a 4Kb stacksize for the
 	  kernel stack attached to each process/thread. This facilitates
Index: 2.6.14-nlkd/arch/i386/kernel/cpu/common.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/cpu/common.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/cpu/common.c	2005-11-04 16:19:32.000000000 +0100
@@ -7,6 +7,7 @@
 #include <linux/bootmem.h>
 #include <asm/semaphore.h>
 #include <asm/processor.h>
+#include <asm/debugreg.h>
 #include <asm/i387.h>
 #include <asm/msr.h>
 #include <asm/io.h>
Index: 2.6.14-nlkd/arch/i386/kernel/process.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/process.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/process.c	2005-11-04 16:48:57.000000000 +0100
@@ -46,6 +46,7 @@
 #include <asm/io.h>
 #include <asm/ldt.h>
 #include <asm/processor.h>
+#include <asm/debugreg.h>
 #include <asm/i387.h>
 #include <asm/desc.h>
 #ifdef CONFIG_MATH_EMULATION
@@ -393,6 +394,10 @@ void exit_thread(void)
 		tss->io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
 		put_cpu();
 	}
+	if (tsk->thread.debugreg[7]) {
+		enable_debugreg(tsk, 7, 0);
+		tsk->thread.debugreg[7] = 0;
+	}
 }
 
 void flush_thread(void)
@@ -406,6 +411,8 @@ void flush_thread(void)
 	 */
 	kprobe_flush_task(tsk);
 
+ 	if (tsk->thread.debugreg[7])
+		enable_debugreg(tsk, 7, 0);
 	memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
 	memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));	
 	/*
@@ -507,6 +514,12 @@ int copy_thread(int nr, unsigned long cl
 		desc->b = LDT_entry_b(&info);
 	}
 
+	if (tsk->thread.debugreg[7]) {
+		p->thread.debugreg[7] = 0;
+		enable_debugreg(p, 7, tsk->thread.debugreg[7]);
+		p->thread.debugreg[7] = tsk->thread.debugreg[7];
+	}
+
 	err = 0;
  out:
 	if (err && p->thread.io_bitmap_ptr) {
Index: 2.6.14-nlkd/arch/i386/kernel/ptrace.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/ptrace.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/ptrace.c	2005-11-04 16:19:32.000000000 +0100
@@ -493,7 +493,7 @@ asmlinkage int sys_ptrace(long request, 
 			   *
 			   * Note that LENi == 0x10 is defined on x86_64 in long
 			   * mode (i.e. even for 32-bit userspace software, but
-			   * 64-bit kernel), so the x86_64 mask value is 0x5454.
+			   * 64-bit kernel), so the x86_64 mask value is 0x5554.
 			   * See the AMD manual no. 24593 (AMD64 System
 			   * Programming)*/
 
@@ -506,6 +506,11 @@ asmlinkage int sys_ptrace(long request, 
 
 			  addr -= (long) &dummy->u_debugreg;
 			  addr = addr >> 2;
+
+			  if (enable_debugreg(child, addr, data) < 0) {
+				  ret = -EBUSY;
+				  break;
+			  }
 			  child->thread.debugreg[addr] = data;
 			  ret = 0;
 		  }
Index: 2.6.14-nlkd/arch/i386/kernel/signal.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/signal.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/signal.c	2005-11-04 16:19:33.000000000 +0100
@@ -25,6 +25,7 @@
 #include <asm/ucontext.h>
 #include <asm/uaccess.h>
 #include <asm/i387.h>
+#include <asm/debugreg.h>
 #include "sigframe.h"
 
 #define DEBUG_SIG 0
@@ -629,7 +630,7 @@ int fastcall do_signal(struct pt_regs *r
 		 * inside the kernel.
 		 */
 		if (unlikely(current->thread.debugreg[7])) {
-			set_debugreg(current->thread.debugreg[7], 7);
+			restore_debugreg();
 		}
 
 		/* Whee!  Actually deliver the signal.  */
Index: 2.6.14-nlkd/arch/i386/kernel/traps.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/traps.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/traps.c	2005-11-04 17:00:47.000000000 +0100
@@ -774,7 +774,7 @@ fastcall void __kprobes do_debug(struct 
 	 * the signal is delivered.
 	 */
 clear_dr7:
-	set_debugreg(0, 7);
+	disable_debugreg(regs, 7);
 	return;
 
 debug_vm86:
Index: 2.6.14-nlkd/arch/i386/kernel/vmlinux.lds.S
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/kernel/vmlinux.lds.S	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/kernel/vmlinux.lds.S	2005-11-07 11:58:12.000000000 +0100
@@ -82,6 +82,12 @@ SECTIONS
   __setup_start = .;
   .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
   __setup_end = .;
+#ifdef CONFIG_NLKD
+  . = ALIGN(4);
+  __start_nlkd_ext = .;
+  .nlkd.ext : AT(ADDR(.nlkd.ext) - LOAD_OFFSET) { *(.nlkd.ext) }
+  __stop_nlkd_ext = .;
+#endif
   __initcall_start = .;
   .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
 	*(.initcall1.init) 
Index: 2.6.14-nlkd/arch/i386/power/cpu.c
===================================================================
--- 2.6.14-nlkd.orig/arch/i386/power/cpu.c	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/arch/i386/power/cpu.c	2005-11-04 17:05:42.000000000 +0100
@@ -10,6 +10,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/suspend.h>
+#include <asm/debugreg.h>
 
 static struct saved_context saved_context;
 
Index: 2.6.14-nlkd/include/asm-i386/debugreg.h
===================================================================
--- 2.6.14-nlkd.orig/include/asm-i386/debugreg.h	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/include/asm-i386/debugreg.h	2005-11-04 16:19:34.000000000 +0100
@@ -61,4 +61,54 @@
 #define DR_LOCAL_SLOWDOWN (0x100)   /* Local slow the pipeline */
 #define DR_GLOBAL_SLOWDOWN (0x200)  /* Global slow the pipeline */
 
+#ifdef CONFIG_NLKD
+
+# include <linux/nint.h>
+
+struct pt_regs;
+struct task_struct;
+
+# ifdef CONFIG_CDE
+#  define MAYBE_INDIR(x) x
+#  define set_debugreg(val, reg) ((void)(val), (void)(reg))
+# else
+#  define MAYBE_INDIR(x) (*x)
+extern void (*set_debugreg)(uintptr_t value, nuint_t regnum);
+# endif
+
+extern int MAYBE_INDIR(enable_debugreg)(struct task_struct *, nuint_t regnum, uintptr_t value);
+extern int MAYBE_INDIR(disable_debugreg)(struct pt_regs *, nuint_t regnum);
+extern int MAYBE_INDIR(restore_debugreg)(void);
+
+# undef MAYBE_INDIR
+
+#else
+
+# define set_debugreg(value, register)				\
+		__asm__("movl %0,%%db" #register		\
+			: /* no output */			\
+			:"r" (value))
+# define enable_debugreg(task, regnum, value) ({		\
+		(void)(task);					\
+		(void)(regnum);					\
+		(void)(value);					\
+		0;						\
+	})
+# define disable_debugreg(regs, regnum) ({			\
+		(void)(regs);					\
+		(void)(regnum);					\
+		set_debugreg(0, 7);				\
+		0;						\
+	})
+# define restore_debugreg() ({					\
+		set_debugreg(current->thread.debugreg[7], 7);	\
+		0;						\
+	})
+
+#endif /* CONFIG_NLKD */
+
+#define get_debugreg(var, register)				\
+		__asm__("movl %%db" #register ", %0"		\
+			:"=r" (var))
+
 #endif
Index: 2.6.14-nlkd/include/asm-i386/processor.h
===================================================================
--- 2.6.14-nlkd.orig/include/asm-i386/processor.h	2005-11-09 10:39:46.000000000 +0100
+++ 2.6.14-nlkd/include/asm-i386/processor.h	2005-11-07 10:20:43.000000000 +0100
@@ -461,6 +461,7 @@ struct thread_struct {
 
 #define INIT_THREAD  {							\
 	.vm86_info = NULL,						\
+	.esp0 = sizeof(init_stack) + (long)&init_stack,			\
 	.sysenter_cs = __KERNEL_CS,					\
 	.io_bitmap_ptr = NULL,						\
 }
@@ -507,17 +508,6 @@ static inline void load_esp0(struct tss_
 } while (0)
 
 /*
- * These special macros can be used to get or set a debugging register
- */
-#define get_debugreg(var, register)				\
-		__asm__("movl %%db" #register ", %0"		\
-			:"=r" (var))
-#define set_debugreg(value, register)			\
-		__asm__("movl %0,%%db" #register		\
-			: /* no output */			\
-			:"r" (value))
-
-/*
  * Set IOPL bits in EFLAGS from given mask
  */
 static inline void set_iopl_mask(unsigned mask)

  reply	other threads:[~2005-11-09 14:10 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-09 13:54 [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jan Beulich
2005-11-09 13:56 ` [PATCH 1/39] NLKD - an alternative kallsyms approach Jan Beulich
2005-11-09 13:57   ` [PATCH 2/39] NLKD - an alternative early ioremap approach Jan Beulich
2005-11-09 13:58     ` [PATCH 3/39] NLKD - early/late CPU up/down notification Jan Beulich
2005-11-09 13:59       ` [PATCH 4/39] NLKD/i386 " Jan Beulich
2005-11-09 14:01       ` [PATCH 5/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:10         ` Andi Kleen
2005-11-14  8:04           ` [discuss] " Jan Beulich
2005-11-14 12:37             ` Andi Kleen
2005-11-09 14:01       ` [PATCH 6/39] NLKD - early panic notification Jan Beulich
2005-11-09 14:02         ` [PATCH 7/39] NLKD - task create/destroy notification Jan Beulich
2005-11-09 14:03           ` [PATCH 8/39] NLKD - rmmod notification Jan Beulich
2005-11-09 14:04             ` [PATCH 9/39] NLKD - hotkey notification Jan Beulich
2005-11-09 14:05               ` [PATCH 10/39] NLKD - console layout change notification Jan Beulich
2005-11-09 14:06                 ` [PATCH 11/39] NLKD - time adjustment Jan Beulich
2005-11-09 14:06                   ` [PATCH 12/39] NLKD/i386 " Jan Beulich
2005-11-09 19:10                     ` George Anzinger
2005-11-10  8:12                       ` Jan Beulich
2005-11-11  0:17                         ` George Anzinger
2005-11-09 14:08                   ` [PATCH 13/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:13                     ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Jan Beulich
2005-11-09 14:14                       ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Jan Beulich
2005-11-09 14:15                         ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Jan Beulich
2005-11-09 14:16                           ` [PATCH 21/39] NLKD/x86-64 - core adjustments Jan Beulich
2005-11-10 13:24                           ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Andi Kleen
2005-11-10 14:07                             ` Jan Beulich
2005-11-10 13:23                         ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Andi Kleen
2005-11-10 14:25                           ` Jan Beulich
2005-11-10 13:21                       ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Andi Kleen
2005-11-10 14:07                         ` Jan Beulich
2005-11-10 14:25                           ` Andi Kleen
2005-11-10 15:00                             ` Jan Beulich
2005-11-11  3:39                               ` [discuss] " Andi Kleen
2005-11-10 13:19                     ` [PATCH 13/39] NLKD/x86-64 - time adjustment Andi Kleen
2005-11-10 14:23                       ` Jan Beulich
2005-11-11  2:12                         ` Andi Kleen
2005-11-12  9:22                           ` Vojtech Pavlik
2005-11-12 17:21                             ` Andi Kleen
2005-11-12 20:44                               ` Vojtech Pavlik
2005-11-15  0:38                                 ` George Anzinger
2005-11-15  1:05                                   ` [discuss] " Andi Kleen
2005-11-15  7:50                                     ` Vojtech Pavlik
2005-11-15  8:24                                       ` Jan Beulich
2005-11-10 14:43                       ` Vojtech Pavlik
2005-11-09 14:09                   ` [PATCH 14/39] NLKD - kernel trace buffer access Jan Beulich
2005-11-09 14:09                     ` [PATCH 15/39] NLKD - early pseudo-fs Jan Beulich
2005-11-09 14:11                       ` [PATCH 16/39] NLKD - core adjustments Jan Beulich
2005-11-09 14:11                         ` Jan Beulich [this message]
2005-11-09 19:00                           ` [PATCH 17/39] NLKD/i386 " Adrian Bunk
2005-11-10  8:04                             ` Jan Beulich
2005-11-10 10:29                               ` Adrian Bunk
2005-11-10 11:52                                 ` Jan Beulich
2005-11-10 12:36                                   ` Lars Marowsky-Bree
2005-11-09 14:18                         ` [PATCH 22/39] NLKD - core Jan Beulich
2005-11-09 14:19                           ` [PATCH 23/39] NLKD/x86 " Jan Beulich
2005-11-09 14:20                             ` [PATCH 24/39] NLKD/i386 " Jan Beulich
2005-11-09 14:21                             ` [PATCH 25/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:30                               ` Andi Kleen
2005-11-09 14:22                           ` [PATCH 26/39] NLKD - run time library Jan Beulich
2005-11-09 14:23                             ` [PATCH 27/39] NLKD/i386 " Jan Beulich
2005-11-09 14:23                               ` [PATCH 28/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:32                                 ` Andi Kleen
     [not found]                             ` <437214B7.76F0.0078.0@novell.com>
     [not found]                               ` <4372156A.76F0.0078.0@novell.com>
2005-11-09 14:28                                 ` [PATCH 34/39] NLKD/x86 - Console Debug Agent Jan Beulich
     [not found]                                 ` <43721600.76F0.0078.0@novell.com>
2005-11-09 14:30                                   ` [PATCH 38/39] NLKD/i386 - Remote " Jan Beulich
2005-11-09 14:31                                   ` [PATCH 39/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:29                       ` [PATCH 15/39] NLKD - early pseudo-fs Al Viro
2005-11-09 14:37                         ` Jan Beulich
2005-11-09 15:00                           ` Al Viro
2005-11-09 16:00                             ` Jan Beulich
2005-11-10  5:44                     ` [PATCH 14/39] NLKD - kernel trace buffer access Keith Owens
2005-11-10  8:02                       ` Jan Beulich
2005-11-09 18:51                   ` [PATCH 11/39] NLKD - time adjustment George Anzinger
2005-11-09 16:50         ` [PATCH 6/39] NLKD - early panic notification Greg KH
2005-11-09 16:45       ` [PATCH 3/39] NLKD - early/late CPU up/down notification Greg KH
2005-11-09 17:09         ` Jan Beulich
2005-11-09 17:19           ` Greg KH
2005-11-10  7:41             ` Jan Beulich
2005-11-10 20:59               ` Sam Ravnborg
2005-11-11  7:52                 ` Jan Beulich
2005-11-12 20:52                   ` Randy.Dunlap
2005-11-10 23:01               ` Greg KH
2005-11-11 10:06     ` [PATCH 2/39] NLKD - an alternative early ioremap approach Pavel Machek
2005-11-11 10:19       ` Jan Beulich
2005-11-09 16:50   ` [PATCH 1/39] NLKD - an alternative kallsyms approach Randy.Dunlap
2005-11-09 16:57     ` Greg KH
2005-11-09 17:20     ` Jan Beulich
2005-11-09 16:59 ` [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jeff Garzik
2005-11-09 17:06   ` Randy.Dunlap
2005-11-09 17:14     ` Jan Beulich
2005-11-09 17:56       ` Alan Cox
2005-11-09 18:05       ` Greg KH
2005-11-09 18:54       ` Paul Jackson
2005-11-10 12:41       ` Christoph Hellwig
2005-11-13  1:09     ` Andi Kleen
2005-11-13  2:53       ` jmerkey
2005-11-13  3:44         ` Andi Kleen
2005-11-13  3:26           ` Jeff V. Merkey
2005-11-13  3:32             ` Jeff V. Merkey
2005-11-09 17:53   ` Alan Cox
2005-11-09 16:25     ` Jeffrey V. Merkey
2005-11-10 14:48     ` Mark Lord
2005-11-10 15:28       ` Tom Rini
2005-11-10 16:37       ` Alan Cox
2005-11-13  1:11       ` Andi Kleen
     [not found] ` <437214E4.76F0.0078.0@novell.com>
     [not found]   ` <4372153C.76F0.0078.0@novell.com>
2005-11-10 13:33     ` [PATCH 32/39] NLKD/x86-64 - Core Debug Engine Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=437211B6.76F0.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.