* Re: [PATCH] PER_CPU [3/4] - PER_CPU-init_tss
[not found] <200407090154.i691s3ws017104@fire-2.osdl.org>
@ 2004-07-09 2:08 ` Andrew Morton
2004-07-09 2:20 ` Shai Fultheim
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2004-07-09 2:08 UTC (permalink / raw)
To: Shai Fultheim; +Cc: linux-kernel, mort, jes
"Shai Fultheim" <shai@scalex86.org> wrote:
>
> #define INIT_TSS { \
> .esp0 = sizeof(init_stack) + (long)&init_stack, \
> .ss0 = __KERNEL_DS, \
> - .esp1 = sizeof(init_tss[0]) + (long)&init_tss[0], \
> .ss1 = __KERNEL_CS, \
> .ldt = GDT_ENTRY_LDT, \
> .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
Why this change? Is it safe?
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH] PER_CPU [3/4] - PER_CPU-init_tss
2004-07-09 2:08 ` [PATCH] PER_CPU [3/4] - PER_CPU-init_tss Andrew Morton
@ 2004-07-09 2:20 ` Shai Fultheim
0 siblings, 0 replies; 3+ messages in thread
From: Shai Fultheim @ 2004-07-09 2:20 UTC (permalink / raw)
To: 'Andrew Morton'; +Cc: linux-kernel, mort, jes
I don't think you have to worry about this.
Ring 1 is never used by Linux so the ss1 and esp1 are NOT used for their real purpose in the task struct. Instead, data is put
there to be used later for setting up sysenter/sysexit in the 'enable_sep_cpu' (arch/i386/kernel/sysenter.c) function. So, the
initialization is really unimportant.
I suggest you'll 'grep' the kernel for esp1 (I did that). It has no other usage other than (as said) setting up the
sysenter/sysexit.
Let me know if thats helps.
Thanks !
-----------------
Shai Fultheim
Scalex86.org
> -----Original Message-----
> From: Andrew Morton [mailto:akpm@osdl.org]
> Sent: Thursday, July 08, 2004 19:08
> To: Shai Fultheim
> Cc: linux-kernel@vger.kernel.org; mort@wildopensource.com; jes@wildopensource.com
> Subject: Re: [PATCH] PER_CPU [3/4] - PER_CPU-init_tss
>
> "Shai Fultheim" <shai@scalex86.org> wrote:
> >
> > #define INIT_TSS { \
> > .esp0 = sizeof(init_stack) + (long)&init_stack, \
> > .ss0 = __KERNEL_DS, \
> > - .esp1 = sizeof(init_tss[0]) + (long)&init_tss[0], \
> > .ss1 = __KERNEL_CS, \
> > .ldt = GDT_ENTRY_LDT, \
> > .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
>
> Why this change? Is it safe?
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] PER_CPU [3/4] - PER_CPU-init_tss
@ 2004-07-09 1:53 Shai Fultheim
0 siblings, 0 replies; 3+ messages in thread
From: Shai Fultheim @ 2004-07-09 1:53 UTC (permalink / raw)
To: 'Andrew Morton'
Cc: 'Linux Kernel ML', 'Martin Hicks',
'Jes Sorensen'
Andrew,
Please find below one out of collection of patched that move NR_CPU array variables to the per-cpu area. Please consider applying,
any comment will highly appreciated.
1/4. PER_CPU-cpu_tlbstate
2/4. PER_CPU-irq_stat
3/4. PER_CPU-init_tss
4/4. PER_CPU-cpu_gdt_table
PER_CPU-init_tss:
arch/i386/kernel/cpu/common.c | 2 +-
arch/i386/kernel/init_task.c | 7 ++-----
arch/i386/kernel/ioport.c | 2 +-
arch/i386/kernel/process.c | 4 ++--
arch/i386/kernel/sysenter.c | 2 +-
arch/i386/kernel/vm86.c | 4 ++--
arch/i386/power/cpu.c | 2 +-
include/asm-i386/processor.h | 4 ++--
8 files changed, 12 insertions(+), 15 deletions(-)
Signed-off-by: Martin Hicks <mort@wildopensource.com>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
=================================================================================
diff -Nru a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
--- a/arch/i386/kernel/cpu/common.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/cpu/common.c 2004-07-08 14:43:09 -07:00
@@ -501,7 +501,7 @@
void __init cpu_init (void)
{
int cpu = smp_processor_id();
- struct tss_struct * t = init_tss + cpu;
+ struct tss_struct * t = &per_cpu(init_tss, cpu);
struct thread_struct *thread = ¤t->thread;
if (test_and_set_bit(cpu, &cpu_initialized)) {
diff -Nru a/arch/i386/kernel/init_task.c b/arch/i386/kernel/init_task.c
--- a/arch/i386/kernel/init_task.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/init_task.c 2004-07-08 14:43:09 -07:00
@@ -39,10 +39,7 @@
/*
* per-CPU TSS segments. Threads are completely 'soft' on Linux,
- * no more per-task TSS's. The TSS size is kept cacheline-aligned
- * so they are allowed to end up in the .data.cacheline_aligned
- * section. Since TSS's are completely CPU-local, we want them
- * on exact cacheline boundaries, to eliminate cacheline ping-pong.
+ * no more per-task TSS's.
*/
-struct tss_struct init_tss[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = INIT_TSS };
+DEFINE_PER_CPU(struct tss_struct, init_tss) = INIT_TSS;
diff -Nru a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c
--- a/arch/i386/kernel/ioport.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/ioport.c 2004-07-08 14:43:09 -07:00
@@ -83,7 +83,7 @@
* do it in the per-thread copy and in the TSS ...
*/
set_bitmap(t->io_bitmap_ptr, from, num, !turn_on);
- tss = init_tss + get_cpu();
+ tss = &per_cpu(init_tss, get_cpu());
if (tss->io_bitmap_base == IO_BITMAP_OFFSET) { /* already active? */
set_bitmap(tss->io_bitmap, from, num, !turn_on);
} else {
diff -Nru a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
--- a/arch/i386/kernel/process.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/process.c 2004-07-08 14:43:09 -07:00
@@ -298,7 +298,7 @@
/* The process may have allocated an io port bitmap... nuke it. */
if (unlikely(NULL != tsk->thread.io_bitmap_ptr)) {
int cpu = get_cpu();
- struct tss_struct *tss = init_tss + cpu;
+ struct tss_struct *tss = &per_cpu(init_tss, cpu);
kfree(tsk->thread.io_bitmap_ptr);
tsk->thread.io_bitmap_ptr = NULL;
tss->io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
@@ -507,7 +507,7 @@
struct thread_struct *prev = &prev_p->thread,
*next = &next_p->thread;
int cpu = smp_processor_id();
- struct tss_struct *tss = init_tss + cpu;
+ struct tss_struct *tss = &per_cpu(init_tss, cpu);
/* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
diff -Nru a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
--- a/arch/i386/kernel/sysenter.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/sysenter.c 2004-07-08 14:43:09 -07:00
@@ -24,7 +24,7 @@
void enable_sep_cpu(void *info)
{
int cpu = get_cpu();
- struct tss_struct *tss = init_tss + cpu;
+ struct tss_struct *tss = &per_cpu(init_tss, cpu);
tss->ss1 = __KERNEL_CS;
tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss;
diff -Nru a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
--- a/arch/i386/kernel/vm86.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/kernel/vm86.c 2004-07-08 14:43:09 -07:00
@@ -122,7 +122,7 @@
do_exit(SIGSEGV);
}
- tss = init_tss + get_cpu();
+ tss = &per_cpu(init_tss, get_cpu());
current->thread.esp0 = current->thread.saved_esp0;
current->thread.sysenter_cs = __KERNEL_CS;
load_esp0(tss, ¤t->thread);
@@ -301,7 +301,7 @@
asm volatile("movl %%fs,%0":"=m" (tsk->thread.saved_fs));
asm volatile("movl %%gs,%0":"=m" (tsk->thread.saved_gs));
- tss = init_tss + get_cpu();
+ tss = &per_cpu(init_tss, get_cpu());
tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
if (cpu_has_sep)
tsk->thread.sysenter_cs = 0;
diff -Nru a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
--- a/arch/i386/power/cpu.c 2004-07-08 14:43:09 -07:00
+++ b/arch/i386/power/cpu.c 2004-07-08 14:43:09 -07:00
@@ -115,7 +115,7 @@
static void fix_processor_context(void)
{
int cpu = smp_processor_id();
- struct tss_struct * t = init_tss + cpu;
+ struct tss_struct * t = &per_cpu(init_tss, cpu);
set_tss_desc(cpu,t); /* This just modifies memory; should not be necessary. But... This is necessary, because 386
hardware has concept of busy TSS or some similar stupidity. */
cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
diff -Nru a/include/asm-i386/processor.h b/include/asm-i386/processor.h
--- a/include/asm-i386/processor.h 2004-07-08 14:43:09 -07:00
+++ b/include/asm-i386/processor.h 2004-07-08 14:43:09 -07:00
@@ -19,6 +19,7 @@
#include <linux/cache.h>
#include <linux/config.h>
#include <linux/threads.h>
+#include <asm/percpu.h>
/* flag for disabling the tsc */
extern int tsc_disable;
@@ -84,8 +85,8 @@
extern struct cpuinfo_x86 boot_cpu_data;
extern struct cpuinfo_x86 new_cpu_data;
-extern struct tss_struct init_tss[NR_CPUS];
extern struct tss_struct doublefault_tss;
+DECLARE_PER_CPU(struct tss_struct, init_tss);
#ifdef CONFIG_SMP
extern struct cpuinfo_x86 cpu_data[];
@@ -445,7 +446,6 @@
#define INIT_TSS { \
.esp0 = sizeof(init_stack) + (long)&init_stack, \
.ss0 = __KERNEL_DS, \
- .esp1 = sizeof(init_tss[0]) + (long)&init_tss[0], \
.ss1 = __KERNEL_CS, \
.ldt = GDT_ENTRY_LDT, \
.io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
=================================================================================
-----------------
Shai Fultheim
Scalex86.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-07-09 2:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200407090154.i691s3ws017104@fire-2.osdl.org>
2004-07-09 2:08 ` [PATCH] PER_CPU [3/4] - PER_CPU-init_tss Andrew Morton
2004-07-09 2:20 ` Shai Fultheim
2004-07-09 1:53 Shai Fultheim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®