Skip to contentSkip to conversation

x86_64: ifdef out struct thread_struct::ip

PATCH In review Alexey Dobriyan 4 participants 6 messages May 3, 2009 – May 11, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86_64: ifdef out struct thread_struct::ip

struct thread_struct::ip isn't used on x86_64, struct pt_regs::ip is used instead.

kgdb should be reading 0 always, but I can't check it.

---
 arch/x86/include/asm/processor.h |    2 ++
 arch/x86/kernel/kgdb.c           |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/include/asm/processor.h +2 -0
index a6732ff..a9ba743 100644
@@ -427,7 +427,9 @@ struct thread_struct {
 	unsigned short		fsindex;
 	unsigned short		gsindex;
 #endif
+#ifdef CONFIG_X86_32
 	unsigned long		ip;
+#endif
 #ifdef CONFIG_X86_64
 	unsigned long		fs;
 #endif
arch/x86/kernel/kgdb.c +1 -1
index eedfaeb..d07706f 100644
@@ -141,7 +141,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
 	gdb_regs32[GDB_PS]	= *(unsigned long *)(p->thread.sp + 8);
 	gdb_regs32[GDB_CS]	= __KERNEL_CS;
 	gdb_regs32[GDB_SS]	= __KERNEL_DS;
-	gdb_regs[GDB_PC]	= p->thread.ip;
+	gdb_regs[GDB_PC]	= 0;
 	gdb_regs[GDB_R8]	= 0;
 	gdb_regs[GDB_R9]	= 0;
 	gdb_regs[GDB_R10]	= 0;
#1 lore raw

[tip:x86/asm] x86, 64-bit: ifdef out struct thread_struct::ip

Commit-ID:  0c23590f00f85467b318ad0c20c36796a5bd4c60
Gitweb:     http://git.kernel.org/tip/0c23590f00f85467b318ad0c20c36796a5bd4c60
Author:     Alexey Dobriyan <[email protected]>
AuthorDate: Mon, 4 May 2009 03:30:15 +0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 11 May 2009 16:23:54 +0200

x86, 64-bit: ifdef out struct thread_struct::ip

struct thread_struct::ip isn't used on x86_64, struct pt_regs::ip is used instead.

kgdb should be reading 0 always, but I can't check it.

[ Impact: (potentially) reduce thread_struct size on 64-bit ]

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/processor.h |    2 ++
 arch/x86/kernel/kgdb.c           |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/include/asm/processor.h +2 -0
index a6732ff..a9ba743 100644
@@ -427,7 +427,9 @@ struct thread_struct {
 	unsigned short		fsindex;
 	unsigned short		gsindex;
 #endif
+#ifdef CONFIG_X86_32
 	unsigned long		ip;
+#endif
 #ifdef CONFIG_X86_64
 	unsigned long		fs;
 #endif
arch/x86/kernel/kgdb.c +1 -1
index eedfaeb..d07706f 100644
@@ -141,7 +141,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
 	gdb_regs32[GDB_PS]	= *(unsigned long *)(p->thread.sp + 8);
 	gdb_regs32[GDB_CS]	= __KERNEL_CS;
 	gdb_regs32[GDB_SS]	= __KERNEL_DS;
-	gdb_regs[GDB_PC]	= p->thread.ip;
+	gdb_regs[GDB_PC]	= 0;
 	gdb_regs[GDB_R8]	= 0;
 	gdb_regs[GDB_R9]	= 0;
 	gdb_regs[GDB_R10]	= 0;
#2 lore raw

Re: [tip:x86/asm] x86, 64-bit: ifdef out struct thread_struct::ip

arch/x86/include/asm/processor.h struct thread_struct { · line 435

Quoted 6 lines · tip-bot for Alexey Dobriyan
arch/x86/include/asm/processor.h +2 -0
+#ifdef CONFIG_X86_32
 	unsigned long		ip;
+#endif
 #ifdef CONFIG_X86_64
 	unsigned long		fs;
 #endif

What happened to the good old concept of #if #else #endif?

#3 lore raw

Re: [tip:x86/asm] x86, 64-bit: ifdef out struct thread_struct::ip

Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · tip-bot for Alexey Dobriyan

+#ifdef CONFIG_X86_32
      unsigned long           ip;
+#endif
 #ifdef CONFIG_X86_64
      unsigned long           fs;
 #endif

What happened to the good old concept of #if #else #endif?

#else suggests alternative which is not the case. ->ip and ->fs can be in different parts of thread_struct.

#4 lore raw

Re: [tip:x86/asm] x86, 64-bit: ifdef out struct thread_struct::ip

Quoted 11 lines · Alexey Dobriyan
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · tip-bot for Alexey Dobriyan

+#ifdef CONFIG_X86_32
      unsigned long           ip;
+#endif
 #ifdef CONFIG_X86_64
      unsigned long           fs;
 #endif

What happened to the good old concept of #if #else #endif?

Quoted 2 lines

#else suggests alternative which is not the case. ->ip and ->fs can be in different parts of thread_struct.

the arch/x86/Kconfig file certainly suggests that those are
mutually-exclusive alternatives:

...
# Select 32 or 64 bit
config 64BIT

        bool "64-bit kernel" if ARCH = "x86"
        default ARCH = "x86_64"
        ---help---
          Say yes to build a 64-bit kernel - formerly known as x86_64
          Say no to build a 32-bit kernel - formerly known as i386

config X86_32

        def_bool !64BIT

config X86_64
def_bool 64BIT
...

unless there's something weird going on underneath.

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Linked In:                             http://www.linkedin.com/in/rpjday
Twitter:                                       http://twitter.com/rpjday

========================================================================

#5 lore raw

Re: [tip:x86/asm] x86, 64-bit: ifdef out struct thread_struct::ip

In reply to Alexey Dobriyan
Quoted 11 lines · Alexey Dobriyan
Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · tip-bot for Alexey Dobriyan

+#ifdef CONFIG_X86_32
      unsigned long           ip;
+#endif
 #ifdef CONFIG_X86_64
      unsigned long           fs;
 #endif

What happened to the good old concept of #if #else #endif?

Quoted 2 lines

#else suggests alternative which is not the case. ->ip and ->fs can be in different parts of thread_struct.

Yes, it's cleaner to have them separate. #if / #else / #endif would be shorter by one line, and it would be thicker by a big confusion
factor: "why is fs the alternative on 64-bit of 32-bit's ip??"

They could also move apart later on, if structure packing constraints call for it.

Ingo