From: jeremy@goop.org
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org,
Chuck Ebbert <76306.1226@compuserve.com>,
Zachary Amsden <zach@vmware.com>,
Jan Beulich <jbeulich@novell.com>, Andi Kleen <ak@suse.de>
Subject: [PATCH 3/6] Fix places where using %gs changes the usermode ABI.
Date: Mon, 25 Sep 2006 11:45:43 -0700 [thread overview]
Message-ID: <20060925184638.721654730@goop.org> (raw)
In-Reply-To: 20060925184540.601971833@goop.org
[-- Attachment #1: pda/i386-pda-fix-abi.patch --]
[-- Type: text/plain, Size: 3558 bytes --]
There are a few places where the change in struct pt_regs and the use
of %gs affect the userspace ABI. These are primarily debugging
interfaces where thread state can be inspected or extracted.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
---
arch/i386/kernel/process.c | 6 +++---
arch/i386/kernel/ptrace.c | 18 ++++++------------
include/asm-i386/elf.h | 2 +-
include/asm-i386/unwind.h | 1 +
4 files changed, 11 insertions(+), 16 deletions(-)
===================================================================
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -309,8 +309,8 @@ void show_regs(struct pt_regs * regs)
regs->eax,regs->ebx,regs->ecx,regs->edx);
printk("ESI: %08lx EDI: %08lx EBP: %08lx",
regs->esi, regs->edi, regs->ebp);
- printk(" DS: %04x ES: %04x\n",
- 0xffff & regs->xds,0xffff & regs->xes);
+ printk(" DS: %04x ES: %04x GS: %04x\n",
+ 0xffff & regs->xds,0xffff & regs->xes, 0xffff & regs->xgs);
cr0 = read_cr0();
cr2 = read_cr2();
@@ -504,7 +504,7 @@ void dump_thread(struct pt_regs * regs,
dump->regs.ds = regs->xds;
dump->regs.es = regs->xes;
savesegment(fs,dump->regs.fs);
- savesegment(gs,dump->regs.gs);
+ dump->regs.gs = regs->xgs;
dump->regs.orig_eax = regs->orig_eax;
dump->regs.eip = regs->eip;
dump->regs.cs = regs->xcs;
===================================================================
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -94,13 +94,9 @@ static int putreg(struct task_struct *ch
return -EIO;
child->thread.fs = value;
return 0;
- case GS:
- if (value && (value & 3) != 3)
- return -EIO;
- child->thread.gs = value;
- return 0;
case DS:
case ES:
+ case GS:
if (value && (value & 3) != 3)
return -EIO;
value &= 0xffff;
@@ -116,8 +112,8 @@ static int putreg(struct task_struct *ch
value |= get_stack_long(child, EFL_OFFSET) & ~FLAG_MASK;
break;
}
- if (regno > GS*4)
- regno -= 2*4;
+ if (regno > ES*4)
+ regno -= 1*4;
put_stack_long(child, regno - sizeof(struct pt_regs), value);
return 0;
}
@@ -131,18 +127,16 @@ static unsigned long getreg(struct task_
case FS:
retval = child->thread.fs;
break;
- case GS:
- retval = child->thread.gs;
- break;
case DS:
case ES:
+ case GS:
case SS:
case CS:
retval = 0xffff;
/* fall through */
default:
- if (regno > GS*4)
- regno -= 2*4;
+ if (regno > ES*4)
+ regno -= 1*4;
regno = regno - sizeof(struct pt_regs);
retval &= get_stack_long(child, regno);
}
===================================================================
--- a/include/asm-i386/elf.h
+++ b/include/asm-i386/elf.h
@@ -88,7 +88,7 @@ typedef struct user_fxsr_struct elf_fpxr
pr_reg[7] = regs->xds; \
pr_reg[8] = regs->xes; \
savesegment(fs,pr_reg[9]); \
- savesegment(gs,pr_reg[10]); \
+ pr_reg[10] = regs->xgs; \
pr_reg[11] = regs->orig_eax; \
pr_reg[12] = regs->eip; \
pr_reg[13] = regs->xcs; \
===================================================================
--- a/include/asm-i386/unwind.h
+++ b/include/asm-i386/unwind.h
@@ -64,6 +64,7 @@ static inline void arch_unw_init_blocked
info->regs.xss = __KERNEL_DS;
info->regs.xds = __USER_DS;
info->regs.xes = __USER_DS;
+ info->regs.xgs = __KERNEL_PDA;
}
extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
--
next prev parent reply other threads:[~2006-09-25 20:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-25 18:45 [PATCH 0/6] Per-processor private data areas for i386 jeremy
2006-09-25 18:45 ` [PATCH 1/6] Initialize the per-CPU data area jeremy
2006-09-25 20:49 ` Andi Kleen
2006-09-25 20:59 ` Jeremy Fitzhardinge
2006-09-25 21:05 ` Andi Kleen
2006-09-25 21:33 ` Jeremy Fitzhardinge
2006-09-25 18:45 ` [PATCH 2/6] Use %gs as the PDA base-segment in the kernel jeremy
2006-09-25 18:45 ` jeremy [this message]
2006-09-25 18:45 ` [PATCH 4/6] Update sys_vm86 to cope with changed pt_regs and %gs usage jeremy
2006-09-25 18:45 ` [PATCH 5/6] Implement smp_processor_id() with the PDA jeremy
2006-09-25 18:45 ` [PATCH 6/6] Implement "current" " jeremy
2006-09-27 19:46 ` [PATCH 0/6] Per-processor private data areas for i386 Pavel Machek
2006-09-27 20:28 ` Jeremy Fitzhardinge
2006-09-27 20:28 ` Jeremy Fitzhardinge
2006-09-29 0:22 ` Rusty Russell
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=20060925184638.721654730@goop.org \
--to=jeremy@goop.org \
--cc=76306.1226@compuserve.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zach@vmware.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox