From: Rusty Russell <rusty@rustcorp.com.au>
To: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Zachary Amsden <zach@vmware.com>,
Jeremy Fitzhardinge <jeremy@xensource.com>,
Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Andi Kleen <ak@suse.de>
Subject: [PATCH 5/8] Cleanup GDT access
Date: Tue, 06 Mar 2007 23:58:29 +1100 [thread overview]
Message-ID: <1173185909.4644.36.camel@localhost.localdomain> (raw)
In-Reply-To: <1173185827.4644.34.camel@localhost.localdomain>
Now we have an explicit per-cpu GDT variable, we don't need to keep
the descriptors around to use them to find the GDT. Also remove the
cpu_pda() accessor: it's just a per-cpu variable.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
diff -r e9d5b8e6f5ee arch/i386/kernel/cpu/common.c
--- a/arch/i386/kernel/cpu/common.c Tue Mar 06 16:20:48 2007 +1100
+++ b/arch/i386/kernel/cpu/common.c Tue Mar 06 17:04:37 2007 +1100
@@ -22,11 +22,8 @@
#include "cpu.h"
-DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
-EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
-
DEFINE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]);
-
+EXPORT_PER_CPU_SYMBOL_GPL(cpu_gdt);
DEFINE_PER_CPU(struct i386_pda, _cpu_pda);
EXPORT_PER_CPU_SYMBOL(_cpu_pda);
@@ -631,14 +628,11 @@ static inline void set_kernel_fs(void)
will soon come up. */
__cpuinit void init_gdt(int cpu, struct task_struct *idle)
{
- struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
struct desc_struct *gdt = per_cpu(cpu_gdt, cpu);
struct i386_pda *pda = &per_cpu(_cpu_pda, cpu);
+ /* Based on boot_gdt_table: set PDA so it can be used immediately */
memcpy(gdt, boot_gdt_table, GDT_SIZE);
- cpu_gdt_descr->address = (unsigned long)gdt;
- cpu_gdt_descr->size = GDT_SIZE - 1;
-
pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
(u32 *)&gdt[GDT_ENTRY_PDA].b,
(unsigned long)pda, sizeof(*pda) - 1,
@@ -653,9 +647,12 @@ __cpuinit void init_gdt(int cpu, struct
/* Move this CPU from boot_gdt_table & boot_pda to this cpu's proper one. */
void __cpuinit cpu_set_gdt(int cpu)
{
- struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
-
- load_gdt(cpu_gdt_descr);
+ struct Xgt_desc_struct gdt_descr;
+
+ gdt_descr.address = (unsigned long)per_cpu(cpu_gdt, cpu);
+ gdt_descr.size = GDT_SIZE - 1;
+
+ load_gdt(&gdt_descr);
set_kernel_fs();
}
diff -r e9d5b8e6f5ee arch/i386/kernel/efi.c
--- a/arch/i386/kernel/efi.c Tue Mar 06 16:20:48 2007 +1100
+++ b/arch/i386/kernel/efi.c Tue Mar 06 17:05:41 2007 +1100
@@ -69,12 +69,10 @@ static void efi_call_phys_prelog(void) _
{
unsigned long cr4;
unsigned long temp;
- struct Xgt_desc_struct *cpu_gdt_descr;
+ struct Xgt_desc_struct gdt_descr;
spin_lock(&efi_rt_lock);
local_irq_save(efi_rt_eflags);
-
- cpu_gdt_descr = &per_cpu(cpu_gdt_descr, 0);
/*
* If I don't have PSE, I should just duplicate two entries in page
@@ -105,17 +103,19 @@ static void efi_call_phys_prelog(void) _
*/
local_flush_tlb();
- cpu_gdt_descr->address = __pa(cpu_gdt_descr->address);
- load_gdt(cpu_gdt_descr);
+ gdt_descr.address = __pa(get_cpu_gdt_table(0));
+ gdt_descr.size = GDT_SIZE - 1;
+ load_gdt(&gdt_descr);
}
static void efi_call_phys_epilog(void) __releases(efi_rt_lock)
{
unsigned long cr4;
- struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, 0);
-
- cpu_gdt_descr->address = (unsigned long)__va(cpu_gdt_descr->address);
- load_gdt(cpu_gdt_descr);
+ struct Xgt_desc_struct gdt_descr;
+
+ gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
+ gdt_descr.size = GDT_SIZE - 1;
+ load_gdt(&gdt_descr);
cr4 = read_cr4();
diff -r e9d5b8e6f5ee arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S Tue Mar 06 16:20:48 2007 +1100
+++ b/arch/i386/kernel/entry.S Tue Mar 06 17:04:37 2007 +1100
@@ -561,8 +561,7 @@ END(syscall_badsys)
#define FIXUP_ESPFIX_STACK \
/* since we are on a wrong stack, we cant make it a C code :( */ \
movl %fs:PDA_cpu, %ebx; \
- PER_CPU(cpu_gdt_descr, %ebx); \
- movl GDS_address(%ebx), %ebx; \
+ PER_CPU(cpu_gdt, %ebx); \
GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
addl %esp, %eax; \
pushl $__KERNEL_DS; \
diff -r e9d5b8e6f5ee arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c Tue Mar 06 16:20:48 2007 +1100
+++ b/arch/i386/kernel/traps.c Tue Mar 06 17:04:37 2007 +1100
@@ -1018,9 +1018,7 @@ fastcall unsigned long patch_espfix_desc
fastcall unsigned long patch_espfix_desc(unsigned long uesp,
unsigned long kesp)
{
- int cpu = smp_processor_id();
- struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
- struct desc_struct *gdt = (struct desc_struct *)cpu_gdt_descr->address;
+ struct desc_struct *gdt = __get_cpu_var(cpu_gdt);
unsigned long base = (kesp - uesp) & -THREAD_SIZE;
unsigned long new_kesp = kesp - base;
unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
diff -r e9d5b8e6f5ee include/asm-i386/desc.h
--- a/include/asm-i386/desc.h Tue Mar 06 16:20:48 2007 +1100
+++ b/include/asm-i386/desc.h Tue Mar 06 17:04:37 2007 +1100
@@ -13,6 +13,7 @@
#include <asm/mmu.h>
extern struct desc_struct boot_gdt_table[GDT_ENTRIES];
+DECLARE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]);
struct Xgt_desc_struct {
unsigned short size;
@@ -21,13 +22,9 @@ struct Xgt_desc_struct {
} __attribute__ ((packed));
extern struct Xgt_desc_struct idt_descr;
-DECLARE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
-DECLARE_PER_CPU(struct desc_struct, cpu_gdt[GDT_ENTRIES]);
-extern struct Xgt_desc_struct early_gdt_descr;
-
static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
{
- return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
+ return per_cpu(cpu_gdt, cpu);
}
extern struct desc_struct idt_table[];
@@ -102,13 +99,12 @@ static inline fastcall void native_set_l
if (likely(entries == 0))
__asm__ __volatile__("lldt %w0"::"q" (0));
else {
- unsigned cpu = smp_processor_id();
__u32 a, b;
pack_descriptor(&a, &b, (unsigned long)addr,
entries * sizeof(struct desc_struct) - 1,
DESCTYPE_LDT, 0);
- write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
+ write_gdt_entry(__get_cpu_var(cpu_gdt), GDT_ENTRY_LDT, a, b);
__asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
}
}
diff -r e9d5b8e6f5ee include/asm-i386/pda.h
--- a/include/asm-i386/pda.h Tue Mar 06 16:20:48 2007 +1100
+++ b/include/asm-i386/pda.h Tue Mar 06 17:04:26 2007 +1100
@@ -20,8 +20,6 @@ struct i386_pda
};
DECLARE_PER_CPU(struct i386_pda, _cpu_pda);
-
-#define cpu_pda(i) (&per_cpu(_cpu_pda, (i)))
#define pda_offset(field) offsetof(struct i386_pda, field)
next prev parent reply other threads:[~2007-03-06 12:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 12:39 [PATCH 0/8] x86 boot, pda and gdt cleanups Rusty Russell
2007-03-06 12:53 ` [PATCH 1/8] Remove cpu_gdt_table: use boot_gdt_table until migration to per-cpu Rusty Russell
2007-03-06 12:54 ` [PATCH 2/8] Remove NR_CPUS from asm-generic/percpu.h Rusty Russell
2007-03-06 12:55 ` [PATCH 3/8] Use per-cpu variables for GDT, PDA Rusty Russell
2007-03-06 12:57 ` [PATCH 4/8] Cleanup setup_pda Rusty Russell
2007-03-06 12:58 ` Rusty Russell [this message]
2007-03-06 13:00 ` [PATCH 6/8] Allow per-cpu variables to be page-aligned Rusty Russell
2007-03-06 13:01 ` [PATCH 7/8] Page-align the GDT Rusty Russell
2007-03-06 13:03 ` [PATCH 8/8] Convert PDA into the percpu section Rusty Russell
2007-03-06 13:10 ` Ingo Molnar
2007-03-07 0:12 ` Rusty Russell
2007-03-07 0:35 ` Jeremy Fitzhardinge
2007-03-06 18:28 ` Jeremy Fitzhardinge
2007-03-06 19:34 ` Andi Kleen
2007-03-06 18:37 ` Jeremy Fitzhardinge
2007-03-07 0:33 ` Rusty Russell
2007-03-07 11:55 ` Rusty Russell
2007-03-13 17:15 ` Jeremy Fitzhardinge
2007-03-14 2:27 ` Rusty Russell
2007-03-06 13:15 ` [PATCH 6/8] Allow per-cpu variables to be page-aligned Ingo Molnar
2007-03-07 0:16 ` Rusty Russell
2007-03-07 0:44 ` H. Peter Anvin
2007-03-06 18:17 ` Jeremy Fitzhardinge
2007-03-07 0:29 ` Rusty Russell
2007-03-06 18:16 ` [PATCH 5/8] Cleanup GDT access Jeremy Fitzhardinge
2007-03-06 18:14 ` [PATCH 3/8] Use per-cpu variables for GDT, PDA Jeremy Fitzhardinge
2007-03-06 13:21 ` [PATCH 2/8] Remove NR_CPUS from asm-generic/percpu.h Ingo Molnar
2007-03-06 13:20 ` [PATCH 1/8] Remove cpu_gdt_table: use boot_gdt_table until migration to per-cpu Ingo Molnar
2007-03-06 13:26 ` Ingo Molnar
2007-03-07 0:22 ` Rusty Russell
2007-03-13 20:48 ` [PATCH 0/8] x86 boot, pda and gdt cleanups Jeremy Fitzhardinge
2007-03-14 2:25 ` Rusty Russell
2007-03-14 4:39 ` Jeremy Fitzhardinge
2007-03-14 6:54 ` Rusty Russell
2007-03-14 23:55 ` Rusty Russell
2007-03-15 1:57 ` Jeremy Fitzhardinge
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=1173185909.4644.36.camel@localhost.localdomain \
--to=rusty@rustcorp.com.au \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=jeremy@xensource.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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;
as well as URLs for NNTP newsgroup(s).