All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, Brian Gerst <brgerst@gmail.com>
Subject: [PATCH 08/17] x86-64: Move oldrsp from PDA to per-cpu.
Date: Fri, 16 Jan 2009 09:16:27 -0500	[thread overview]
Message-ID: <1232115396-26367-8-git-send-email-brgerst@gmail.com> (raw)
In-Reply-To: <1232115396-26367-7-git-send-email-brgerst@gmail.com>

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/include/asm/pda.h       |    2 +-
 arch/x86/kernel/asm-offsets_64.c |    2 --
 arch/x86/kernel/entry_64.S       |    8 ++++----
 arch/x86/kernel/process_64.c     |    8 +++++---
 arch/x86/xen/xen-asm_64.S        |    8 ++++----
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/x86/include/asm/pda.h b/arch/x86/include/asm/pda.h
index 4d28ffb..ae23deb 100644
--- a/arch/x86/include/asm/pda.h
+++ b/arch/x86/include/asm/pda.h
@@ -14,7 +14,7 @@ struct x8664_pda {
 	unsigned long unused1;
 	unsigned long unused2;
 	unsigned long unused3;
-	unsigned long oldrsp;		/* 24 user rsp for system call */
+	unsigned long unused4;
 	int irqcount;			/* 32 Irq nesting counter. Starts -1 */
 	unsigned int unused6;		/* 36 was cpunumber */
 #ifdef CONFIG_CC_STACKPROTECTOR
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index cafff5f..6a13983 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -11,7 +11,6 @@
 #include <linux/hardirq.h>
 #include <linux/suspend.h>
 #include <linux/kbuild.h>
-#include <asm/pda.h>
 #include <asm/processor.h>
 #include <asm/segment.h>
 #include <asm/thread_info.h>
@@ -49,7 +48,6 @@ int main(void)
 	BLANK();
 #undef ENTRY
 #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
-	ENTRY(oldrsp); 
 	ENTRY(irqcount);
 	DEFINE(pda_size, sizeof(struct x8664_pda));
 	BLANK();
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8f35796..1331fd2 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -210,7 +210,7 @@ ENTRY(native_usergs_sysret64)
 
 	/* %rsp:at FRAMEEND */
 	.macro FIXUP_TOP_OF_STACK tmp offset=0
-	movq %gs:pda_oldrsp,\tmp
+	movq PER_CPU_VAR(oldrsp),\tmp
 	movq \tmp,RSP+\offset(%rsp)
 	movq $__USER_DS,SS+\offset(%rsp)
 	movq $__USER_CS,CS+\offset(%rsp)
@@ -221,7 +221,7 @@ ENTRY(native_usergs_sysret64)
 
 	.macro RESTORE_TOP_OF_STACK tmp offset=0
 	movq RSP+\offset(%rsp),\tmp
-	movq \tmp,%gs:pda_oldrsp
+	movq \tmp,PER_CPU_VAR(oldrsp)
 	movq EFLAGS+\offset(%rsp),\tmp
 	movq \tmp,R11+\offset(%rsp)
 	.endm
@@ -479,7 +479,7 @@ ENTRY(system_call)
 	 */
 ENTRY(system_call_after_swapgs)
 
-	movq	%rsp,%gs:pda_oldrsp
+	movq	%rsp,PER_CPU_VAR(oldrsp)
 	movq	PER_CPU_VAR(kernelstack),%rsp
 	/*
 	 * No need to follow this irqs off/on section - it's straight
@@ -523,7 +523,7 @@ sysret_check:
 	CFI_REGISTER	rip,rcx
 	RESTORE_ARGS 0,-ARG_SKIP,1
 	/*CFI_REGISTER	rflags,r11*/
-	movq	%gs:pda_oldrsp, %rsp
+	movq	PER_CPU_VAR(oldrsp), %rsp
 	USERGS_SYSRET64
 
 	CFI_RESTORE_STATE
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 2f5bb4d..d4a7391 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -60,6 +60,8 @@ asmlinkage extern void ret_from_fork(void);
 DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
 EXPORT_PER_CPU_SYMBOL(current_task);
 
+DEFINE_PER_CPU(unsigned long, oldrsp);
+
 unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
 
 static ATOMIC_NOTIFIER_HEAD(idle_notifier);
@@ -395,7 +397,7 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
 	load_gs_index(0);
 	regs->ip		= new_ip;
 	regs->sp		= new_sp;
-	write_pda(oldrsp, new_sp);
+	percpu_write(oldrsp, new_sp);
 	regs->cs		= __USER_CS;
 	regs->ss		= __USER_DS;
 	regs->flags		= 0x200;
@@ -616,8 +618,8 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 	/*
 	 * Switch the PDA and FPU contexts.
 	 */
-	prev->usersp = read_pda(oldrsp);
-	write_pda(oldrsp, next->usersp);
+	prev->usersp = percpu_read(oldrsp);
+	percpu_write(oldrsp, next->usersp);
 	percpu_write(current_task, next_p);
 
 	percpu_write(kernelstack,
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index eac2794..16d3bfb 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -195,11 +195,11 @@ RELOC(xen_sysexit, 1b+1)
 ENTRY(xen_sysret64)
 	/* We're already on the usermode stack at this point, but still
 	   with the kernel gs, so we can easily switch back */
-	movq %rsp, %gs:pda_oldrsp
+	movq %rsp, PER_CPU_VAR(oldrsp)
 	movq PER_CPU_VAR(kernelstack),%rsp
 
 	pushq $__USER_DS
-	pushq %gs:pda_oldrsp
+	pushq PER_CPU_VAR(oldrsp)
 	pushq %r11
 	pushq $__USER_CS
 	pushq %rcx
@@ -212,11 +212,11 @@ RELOC(xen_sysret64, 1b+1)
 ENTRY(xen_sysret32)
 	/* We're already on the usermode stack at this point, but still
 	   with the kernel gs, so we can easily switch back */
-	movq %rsp, %gs:pda_oldrsp
+	movq %rsp, PER_CPU_VAR(oldrsp)
 	movq PER_CPU_VAR(kernelstack), %rsp
 
 	pushq $__USER32_DS
-	pushq %gs:pda_oldrsp
+	pushq PER_CPU_VAR(oldrsp)
 	pushq %r11
 	pushq $__USER32_CS
 	pushq %rcx
-- 
1.6.1.rc1


  reply	other threads:[~2009-01-16 14:27 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <73c1f2160901160610l57e31a64j56fe9544bd2fd309@mail.gmail.com>
2009-01-16 14:16 ` [PATCH 01/17] x86-64: Move irq stats from PDA to per-cpu and consolidate with 32-bit Brian Gerst
2009-01-16 14:16   ` [PATCH 02/17] x86-64: Move TLB state " Brian Gerst
2009-01-16 14:16     ` [PATCH 03/17] x86-64: Convert irqstacks to per-cpu Brian Gerst
2009-01-16 14:16       ` [PATCH 04/17] x86-64: Convert exception stacks " Brian Gerst
2009-01-16 14:16         ` [PATCH 05/17] x86-64: Move cpu number from PDA to per-cpu and consolidate with 32-bit Brian Gerst
2009-01-16 14:16           ` [PATCH 06/17] x86-64: Move current task " Brian Gerst
2009-01-16 14:16             ` [PATCH 07/17] x86-64: Move kernelstack from PDA to per-cpu Brian Gerst
2009-01-16 14:16               ` Brian Gerst [this message]
2009-01-16 14:16                 ` [PATCH 09/17] x86-64: Move irqcount " Brian Gerst
2009-01-16 14:16                   ` [PATCH 10/17] x86-64: Move nodenumber " Brian Gerst
2009-01-16 14:16                     ` [PATCH 11/17] x86-64: Move isidle " Brian Gerst
2009-01-16 14:16                       ` [PATCH 12/17] x86-64: Use absolute displacements for per-cpu accesses Brian Gerst
2009-01-16 14:16                         ` [PATCH 13/17] x86-64: Remove pda_init() Brian Gerst
2009-01-16 14:16                           ` [PATCH 14/17] x86-64: Remove load_pda_offset() Brian Gerst
2009-01-16 14:16                             ` [PATCH 15/17] percpu: Refactor percpu.h Brian Gerst
2009-01-16 14:16                               ` [PATCH 16/17] x86-64: Remove the PDA Brian Gerst
2009-01-16 14:16                                 ` [PATCH 17/17] x86-64: Remove pda.h Brian Gerst
2009-01-18  4:54                                   ` Tejun Heo
2009-01-18  4:52                                 ` [PATCH 16/17] x86-64: Remove the PDA Tejun Heo
2009-01-18  7:46                                   ` Brian Gerst
2009-01-18  8:13                                     ` Tejun Heo
2009-01-18  8:41                                       ` Ingo Molnar
2009-01-18  4:32                           ` [PATCH 13/17] x86-64: Remove pda_init() Tejun Heo
2009-01-18  5:20                             ` Brian Gerst
2009-01-18  5:30                               ` Tejun Heo
2009-01-18  4:22                         ` [PATCH 12/17] x86-64: Use absolute displacements for per-cpu accesses Tejun Heo
     [not found]                           ` <73c1f2160901172036m4d7bb4f8i50b6a5185a63e95@mail.gmail.com>
2009-01-18 16:42                             ` Ingo Molnar
2009-01-18 17:38                               ` Ingo Molnar
2009-01-18  5:05           ` [PATCH 05/17] x86-64: Move cpu number from PDA to per-cpu and consolidate with 32-bit Tejun Heo
2009-01-18  5:57             ` Brian Gerst
2009-01-18  5:59               ` Tejun Heo
2009-01-18  6:51                 ` Brian Gerst
2009-01-18  7:14                   ` x86/Voyager Ingo Molnar
2009-01-18 16:41                     ` x86/Voyager James Bottomley
2009-01-18 17:41                       ` x86/Voyager Brian Gerst
2009-01-18 18:04                         ` x86/Voyager James Bottomley
2009-01-18 18:21                           ` x86/Voyager Brian Gerst
2009-01-18 18:17                       ` x86/Voyager Ingo Molnar
2009-01-18 20:11                         ` x86/Voyager James Bottomley
2009-01-18 21:33                           ` x86/Voyager Ingo Molnar
2009-01-18  4:58       ` [PATCH 03/17] x86-64: Convert irqstacks to per-cpu Tejun Heo
2009-01-18  5:05         ` Brian Gerst
2009-01-18  5:08           ` Tejun Heo
2009-01-18  8:36             ` Ingo Molnar
2009-01-18  9:04               ` Tejun Heo
2009-01-18  9:16                 ` Ingo Molnar
2009-01-18  5:01       ` Tejun Heo
2009-01-20 13:15 ` [PATCH 1/6] x86: Clean up gdt_page definition Brian Gerst
2009-01-20 13:15 ` [PATCH 2/6] x86-64: Fix percpu_write with 64-bit constants Brian Gerst
2009-01-20 13:15 ` [PATCH 3/6] x86-32: Set %fs to __KERNEL_PERCPU unconditionally Brian Gerst
2009-01-20 13:15 ` [PATCH 4/6] x86: Merge mmu_context.h Brian Gerst
2009-01-21  1:31   ` Tejun Heo
2009-01-21  8:21   ` Tejun Heo
2009-01-20 13:15 ` [PATCH 5/6] x86: Merge hardirq.h Brian Gerst
2009-01-21  8:19   ` Tejun Heo
2009-01-21  8:50     ` Tejun Heo
2009-01-21 10:14       ` Ingo Molnar
2009-01-21 10:13     ` Ingo Molnar
2009-01-21 11:33       ` Tejun Heo
2009-01-21 14:21         ` Tilman Schmidt
2009-01-20 13:15 ` [PATCH 6/6] x86: Merge irq_regs.h Brian Gerst

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=1232115396-26367-8-git-send-email-brgerst@gmail.com \
    --to=brgerst@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tj@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.