From: ebiederm@xmission.com (Eric W. Biederman)
To: Andi Kleen <ak@suse.de>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
linux-kernel@vger.kernel.org,
virtualization <virtualization@lists.linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 11/12] i386: Move setup_idt from head.S to head32.c
Date: Mon, 30 Apr 2007 10:33:52 -0600 [thread overview]
Message-ID: <m11wi14ya7.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <m1647d4ybr.fsf_-_@ebiederm.dsl.xmission.com> (Eric W. Biederman's message of "Mon, 30 Apr 2007 10:32:56 -0600")
This slightly delays when we setup the idt. But by doing it in C
things are noticeably simpler.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
arch/i386/kernel/head.S | 68 +++-----------------------------------------
arch/i386/kernel/head32.c | 26 +++++++++++++++++
2 files changed, 31 insertions(+), 63 deletions(-)
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index 22ddb3f..0ee615b 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -197,19 +197,6 @@ ENTRY(startup_32_smp)
pushl $0
popfl
-#ifdef CONFIG_SMP
- cmpb $0, ready
- jz 1f /* Initial CPU cleans BSS */
- jmp checkCPUtype
-1:
-#endif /* CONFIG_SMP */
-
-/*
- * start system 32-bit setup. We need to re-do some of the things done
- * in 16-bit mode for the "real" operations.
- */
- call setup_idt
-
checkCPUtype:
movl $-1,X86_CPUID # -1 for no CPUID initially
@@ -274,7 +261,6 @@ is386: movl $2,%ecx # set MP
call check_x87
lgdt early_gdt_descr
- lidt idt_descr
ljmp $(__KERNEL_CS),$1f
1: movl $(__KERNEL_DS),%eax # reload all the segment registers
movl %eax,%ss # after changing gdt.
@@ -321,65 +307,21 @@ check_x87:
.byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */
ret
-/*
- * setup_idt
- *
- * sets up a idt with 256 entries pointing to
- * ignore_int, interrupt gates. It doesn't actually load
- * idt - that can be done only after paging has been enabled
- * and the kernel moved to PAGE_OFFSET. Interrupts
- * are enabled elsewhere, when we can be relatively
- * sure everything is ok.
- *
- * Warning: %esi is live across this function.
- */
-setup_idt:
- lea ignore_int,%edx
- movl $(__KERNEL_CS << 16),%eax
- movw %dx,%ax /* selector = 0x0010 = cs */
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
-
- lea idt_table,%edi
- mov $256,%ecx
-rp_sidt:
- movl %eax,(%edi)
- movl %edx,4(%edi)
- addl $8,%edi
- dec %ecx
- jne rp_sidt
-
-.macro set_early_handler handler,trapno
- lea \handler,%edx
- movl $(__KERNEL_CS << 16),%eax
- movw %dx,%ax
- movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
- lea idt_table,%edi
- movl %eax,8*\trapno(%edi)
- movl %edx,8*\trapno+4(%edi)
-.endm
-
- set_early_handler handler=early_divide_err,trapno=0
- set_early_handler handler=early_illegal_opcode,trapno=6
- set_early_handler handler=early_protection_fault,trapno=13
- set_early_handler handler=early_page_fault,trapno=14
-
- ret
-
-early_divide_err:
+ENTRY(early_divide_err)
xor %edx,%edx
pushl $0 /* fake errcode */
jmp early_fault
-early_illegal_opcode:
+ENTRY(early_illegal_opcode)
movl $6,%edx
pushl $0 /* fake errcode */
jmp early_fault
-early_protection_fault:
+ENTRY(early_protection_fault)
movl $13,%edx
jmp early_fault
-early_page_fault:
+ENTRY(early_page_fault)
movl $14,%edx
jmp early_fault
@@ -408,7 +350,7 @@ hlt_loop:
/* This is the default interrupt "handler" :-) */
ALIGN
-ignore_int:
+ENTRY(ignore_int)
cld
#ifdef CONFIG_PRINTK
pushl %eax
diff --git a/arch/i386/kernel/head32.c b/arch/i386/kernel/head32.c
index 3db0590..d2f85d5 100644
--- a/arch/i386/kernel/head32.c
+++ b/arch/i386/kernel/head32.c
@@ -7,8 +7,34 @@
#include <linux/init.h>
#include <linux/start_kernel.h>
+#include <asm/desc.h>
+
+extern void ignore_int(void);
+extern void early_divide_err(void);
+extern void early_illegal_opcode(void);
+extern void early_protection_fault(void);
+extern void early_page_fault(void);
+
+/*
+ * setup_idt
+ *
+ * sets up a idt with 256 entries pointing to ignore_int. Interrupts
+ * are enabled elsewhere, when we can be relatively sure everything is ok.
+ */
+static void __init setup_idt(void)
+{
+ int i;
+ for (i = 0; i < IDT_ENTRIES; i++)
+ set_intr_gate(i, ignore_int);
+ set_intr_gate(0, early_divide_err);
+ set_intr_gate(6, early_illegal_opcode);
+ set_intr_gate(13, early_protection_fault);
+ set_intr_gate(14, early_page_fault);
+ load_idt(&idt_descr);
+}
void __init i386_start_kernel(void)
{
+ setup_idt();
start_kernel();
}
--
1.5.1.1.181.g2de0
next prev parent reply other threads:[~2007-04-30 16:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m1d51l6f1y.fsf@ebiederm.dsl.xmission.com>
2007-04-30 15:48 ` [PATCH 01/12] x86_64: Allow fixmaps to be used with the initial page table Eric W. Biederman
[not found] ` <m18xc96eyq.fsf@ebiederm.dsl.xmission.com>
2007-04-30 15:49 ` [PATCH 02/12] i386 head.S: Remove unnecessary use of %ebx as the boot cpu flag Eric W. Biederman
[not found] ` <m14pmx6ewk.fsf_-_@ebiederm.dsl.xmission.com>
2007-04-30 15:51 ` [PATCH 03/12] i386 head.S: Always run the full set of paging state Eric W. Biederman
[not found] ` <m1zm4p509a.fsf_-_@ebiederm.dsl.xmission.com>
2007-04-30 15:57 ` [PATCH 04/12] i386 voyager: Use modern techniques to setup and teardown low identiy mappings Eric W. Biederman
2007-04-30 16:03 ` [PATCH 05/12] i386: During page table initialization always set the leaf page table entries Eric W. Biederman
[not found] ` <m1r6q14zow.fsf_-_@ebiederm.dsl.xmission.com>
2007-04-30 16:09 ` [PATCH 06/12] i386: Minimum cpu detection cleanups Eric W. Biederman
2007-04-30 16:10 ` [PATCH 07/12] i386: Add missing !X86_PAE dependincy to the 2G/2G split Eric W. Biederman
2007-04-30 16:15 ` [PATCH 08/12] i386: Convert the boot time page tables to the kernels native format Eric W. Biederman
2007-04-30 16:26 ` Andi Kleen
2007-04-30 16:32 ` [PATCH 09/12] i386/x86_64: EHCI usb debug port early printk support Eric W. Biederman
2007-04-30 16:32 ` [PATCH 10/12] i386: Introduce head32.c Eric W. Biederman
2007-04-30 16:33 ` Eric W. Biederman [this message]
2007-04-30 16:35 ` [PATCH 12/12] i386: remove cpuid checking in head.S Eric W. Biederman
2007-04-30 17:56 ` [PATCH 09/12] i386/x86_64: EHCI usb debug port early printk support Andi Kleen
[not found] ` <20070430175607.GD25929@bingen.suse.de>
2007-04-30 20:54 ` Eric W. Biederman
[not found] ` <200704301826.57920.ak@suse.de>
2007-04-30 16:42 ` [PATCH 08/12] i386: Convert the boot time page tables to the kernels native format Eric W. Biederman
2007-04-30 16:16 ` [PATCH 07/12] i386: Add missing !X86_PAE dependincy to the 2G/2G split H. Peter Anvin
2007-04-30 16:39 ` Eric W. Biederman
2007-04-30 16:13 ` [PATCH 06/12] i386: Minimum cpu detection cleanups H. Peter Anvin
2007-04-30 16:34 ` [PATCH 05/12] i386: During page table initialization always set the leaf page table entries Jeremy Fitzhardinge
2007-04-30 17:06 ` [PATCH 04/12] i386 voyager: Use modern techniques to setup and teardown low identiy mappings James Bottomley
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=m11wi14ya7.fsf_-_@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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 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).