From: Andi Kleen <ak@suse.de>
To: jeremy@goop.org, rusty@rustcorp.com.au, patches@x86-64.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] [28/40] i386: Fix UP gdt bugs
Date: Mon, 30 Apr 2007 12:28:02 +0200 (CEST) [thread overview]
Message-ID: <20070430102802.B877C151D2@wotan.suse.de> (raw)
In-Reply-To: <200704301227.598020000@suse.de>
From: Jeremy Fitzhardinge <jeremy@goop.org>
Fixes two problems with the GDT when compiling for uniprocessor:
- There's no percpu segment, so trying to load its selector into %fs fails.
Use a null selector instead.
- The real gdt needs to be loaded at some point. Do it in cpu_init().
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
---
arch/i386/kernel/cpu/common.c | 13 +++++++++++++
arch/i386/kernel/smpboot.c | 12 ------------
include/asm-i386/processor.h | 1 +
include/asm-i386/segment.h | 4 ++++
4 files changed, 18 insertions(+), 12 deletions(-)
===================================================================
Index: linux/arch/i386/kernel/cpu/common.c
===================================================================
--- linux.orig/arch/i386/kernel/cpu/common.c
+++ linux/arch/i386/kernel/cpu/common.c
@@ -638,6 +638,18 @@ struct pt_regs * __devinit idle_regs(str
return regs;
}
+/* Current gdt points %fs at the "master" per-cpu area: after this,
+ * it's on the real one. */
+void switch_to_new_gdt(void)
+{
+ struct Xgt_desc_struct gdt_descr;
+
+ gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
+ gdt_descr.size = GDT_SIZE - 1;
+ load_gdt(&gdt_descr);
+ asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory");
+}
+
/*
* cpu_init() initializes state that is per-CPU. Some data is already
* initialized (naturally) in the bootstrap process, such as the GDT
@@ -668,6 +680,7 @@ void __cpuinit cpu_init(void)
}
load_idt(&idt_descr);
+ switch_to_new_gdt();
/*
* Set up and load the per-CPU TSS and LDT
Index: linux/arch/i386/kernel/smpboot.c
===================================================================
--- linux.orig/arch/i386/kernel/smpboot.c
+++ linux/arch/i386/kernel/smpboot.c
@@ -1177,18 +1177,6 @@ void __init native_smp_prepare_cpus(unsi
smp_boot_cpus(max_cpus);
}
-/* Current gdt points %fs at the "master" per-cpu area: after this,
- * it's on the real one. */
-static inline void switch_to_new_gdt(void)
-{
- struct Xgt_desc_struct gdt_descr;
-
- gdt_descr.address = (long)get_cpu_gdt_table(smp_processor_id());
- gdt_descr.size = GDT_SIZE - 1;
- load_gdt(&gdt_descr);
- asm("mov %0, %%fs" : : "r" (__KERNEL_PERCPU) : "memory");
-}
-
void __init native_smp_prepare_boot_cpu(void)
{
unsigned int cpu = smp_processor_id();
Index: linux/include/asm-i386/processor.h
===================================================================
--- linux.orig/include/asm-i386/processor.h
+++ linux/include/asm-i386/processor.h
@@ -750,6 +750,7 @@ extern void enable_sep_cpu(void);
extern int sysenter_setup(void);
extern void cpu_set_gdt(int);
+extern void switch_to_new_gdt(void);
extern void cpu_init(void);
extern int force_mwait;
Index: linux/include/asm-i386/segment.h
===================================================================
--- linux.orig/include/asm-i386/segment.h
+++ linux/include/asm-i386/segment.h
@@ -75,7 +75,11 @@
#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
+#ifdef CONFIG_SMP
#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
+#else
+#define __KERNEL_PERCPU 0
+#endif
#define GDT_ENTRY_DOUBLEFAULT_TSS 31
next prev parent reply other threads:[~2007-04-30 10:30 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 10:27 [PATCH] [0/40] x86 candidate patches for review V: paravirt patches Andi Kleen
2007-04-30 10:27 ` [PATCH] [1/40] x86_64: update MAINTAINERS Andi Kleen
2007-04-30 10:27 ` [PATCH] [2/40] i386: Remove CONFIG_DEBUG_PARAVIRT Andi Kleen
2007-04-30 10:27 ` [PATCH] [3/40] i386: use paravirt_nop to consistently mark no-op operations Andi Kleen
2007-04-30 10:27 ` [PATCH] [4/40] i386: Add pagetable accessors to pack and unpack pagetable entries Andi Kleen
2007-04-30 10:27 ` [PATCH] [5/40] i386: Hooks to set up initial pagetable Andi Kleen
2007-04-30 10:27 ` [PATCH] [6/40] i386: Allocate a fixmap slot Andi Kleen
2007-04-30 10:27 ` [PATCH] [7/40] i386: Allow paravirt backend to choose kernel PMD sharing Andi Kleen
2007-04-30 10:27 ` [PATCH] [8/40] x86: add hooks to intercept mm creation and destruction Andi Kleen
2007-04-30 10:27 ` [PATCH] [9/40] i386: rename struct paravirt_patch to paravirt_patch_site for clarity Andi Kleen
2007-04-30 10:27 ` [PATCH] [10/40] i386: Use patch site IDs computed from offset in paravirt_ops structure Andi Kleen
2007-04-30 10:27 ` [PATCH] [11/40] i386: Fix patch site clobbers to include return register Andi Kleen
2007-04-30 10:27 ` [PATCH] [12/40] i386: Consistently wrap paravirt ops callsites to make them patchable Andi Kleen
2007-04-30 10:27 ` [PATCH] [13/40] i386: Document asm-i386/paravirt.h Andi Kleen
2007-04-30 10:27 ` [PATCH] [14/40] i386: add common patching machinery Andi Kleen
2007-04-30 10:27 ` [PATCH] [15/40] i386: add flush_tlb_others paravirt_op Andi Kleen
2007-04-30 10:27 ` [PATCH] [16/40] i386: revert map_pt_hook Andi Kleen
2007-04-30 10:27 ` [PATCH] [17/40] i386: add kmap_atomic_pte for mapping highpte pages Andi Kleen
2007-04-30 10:27 ` [PATCH] [18/40] i386: flush lazy mmu updates on kunmap_atomic Andi Kleen
2007-04-30 10:27 ` [PATCH] [19/40] i386: fix paravirt-documentation Andi Kleen
2007-04-30 11:07 ` [patches] " Nigel Cunningham
2007-04-30 15:30 ` Jeremy Fitzhardinge
2007-04-30 15:37 ` Andi Kleen
2007-04-30 10:27 ` [PATCH] [20/40] i386: Clean up paravirt patchable wrappers Andi Kleen
2007-04-30 10:27 ` [PATCH] [21/40] i386: drop unused ptep_get_and_clear Andi Kleen
2007-04-30 10:27 ` [PATCH] [22/40] x86: deflate stack usage in lib/inflate.c Andi Kleen
2007-04-30 10:27 ` [PATCH] [23/40] x86_64: deflate inflate_dynamic too Andi Kleen
2007-04-30 10:27 ` [PATCH] [24/40] i386: Page-align the GDT Andi Kleen
2007-04-30 10:27 ` [PATCH] [25/40] i386: Convert PDA into the percpu section Andi Kleen
2007-04-30 10:28 ` [PATCH] [26/40] i386: cleanups to help using per-cpu variables from asm Andi Kleen
2007-04-30 10:28 ` [PATCH] [27/40] i386: Define per_cpu_offset Andi Kleen
2007-04-30 10:28 ` Andi Kleen [this message]
2007-04-30 10:28 ` [PATCH] [29/40] i386: map enough initial memory to create lowmem mappings Andi Kleen
2007-04-30 10:28 ` [PATCH] [30/40] x86: update for i386 and x86-64 check_bugs Andi Kleen
2007-04-30 10:28 ` [PATCH] [31/40] i386: In compat mode, the return value here was uninitialized Andi Kleen
2007-04-30 10:28 ` [PATCH] [32/40] i386: kRemove a warning about unused variable in !CONFIG_ACPI compilation Andi Kleen
2007-04-30 10:28 ` [PATCH] [33/40] i386: Allow boot-time disable of paravirt_ops patching Andi Kleen
2007-04-30 10:28 ` [PATCH] [34/40] i386: Clean up arch/i386/kernel/cpu/mcheck/p4.c Andi Kleen
2007-04-30 10:28 ` [PATCH] [35/40] i386: Now that the VDSO can be relocated, we can support it in VMI configurations Andi Kleen
2007-04-30 10:28 ` [PATCH] [36/40] i386: Implement vmi_kmap_atomic_pte Andi Kleen
2007-04-30 10:28 ` [PATCH] [37/40] i386: Convert VMI timer to use clock events Andi Kleen
2007-04-30 10:28 ` [PATCH] [38/40] x86: Jeremy Fitzhardinge <jeremy@goop.org> Andi Kleen
2007-04-30 10:28 ` [PATCH] [39/40] i386: Export paravirt_ops for non GPL modules too Andi Kleen
2007-04-30 10:50 ` Christoph Hellwig
2007-04-30 11:00 ` Andi Kleen
2007-04-30 11:15 ` Jan Engelhardt
2007-04-30 11:19 ` Andi Kleen
2007-04-30 12:28 ` Peter Zijlstra
2007-04-30 13:40 ` Andi Kleen
2007-04-30 20:37 ` [PATCH] [39/40] i386: Export paravirt_ops for non GPL modulestoo David Schwartz
2007-04-30 11:04 ` [PATCH] [39/40] i386: Export paravirt_ops for non GPL modules too Jan Engelhardt
2007-04-30 14:55 ` Alan Cox
2007-04-30 16:30 ` Andi Kleen
2007-04-30 21:30 ` Jeremy Fitzhardinge
2007-04-30 10:28 ` [PATCH] [40/40] i386: Clean up ELF note generation Andi Kleen
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=20070430102802.B877C151D2@wotan.suse.de \
--to=ak@suse.de \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@x86-64.org \
--cc=rusty@rustcorp.com.au \
/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