From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>,
"Andi Kleen" <ak@suse.de>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Vivek Goyal" <vgoyal@in.ibm.com>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
yinghai.lu@sun.com
Subject: [PATCH]x86_64: build and use GDT on copied compressed kernel
Date: Sat, 12 May 2007 22:33:14 -0700 [thread overview]
Message-ID: <86802c440705122233y327756e7te534199f46b2059d@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 28 bytes --]
please check the patch.
YH
[-- Attachment #2: bzImage_x86_64_head_gdt.patch --]
[-- Type: text/x-patch, Size: 2274 bytes --]
[PATCH]x86_64: build and use GDT on copied compressed kernel
Build and use GDT on copied compressed kernel postion, instead of using GDT
in data segment of loaded compressed kernel. Otherwise decompressing
compressed kernel image later in 64bit longmode, will overwrite GDT.
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
diff --git a/arch/x86_64/boot/compressed/head.S b/arch/x86_64/boot/compressed/head.S
index f9d5692..1f5ac7c 100644
--- a/arch/x86_64/boot/compressed/head.S
+++ b/arch/x86_64/boot/compressed/head.S
@@ -94,10 +94,23 @@ startup_32:
* Prepare for entering 64 bit mode
*/
+/*
+ * Build early GDT table on copied compressed kernel image position, So GDT
+ * is not be overwriten when decompressing the compressed kernel.
+ */
+ movw $0x0020, gdt+0x00(%ebx)
+ movw $0x0000, gdt+0x06(%ebx)
+ movl $0x00000000, gdt+0x08(%ebx) /* NULL descriptor */
+ movl $0x00000000, gdt+0x0c(%ebx)
+ movl $0x0000ffff, gdt+0x10(%ebx) /* __KERNEL_CS */
+ movl $0x00af9a00, gdt+0x14(%ebx)
+ movl $0x0000ffff, gdt+0x18(%ebx) /* __KERNEL_DS */
+ movl $0x00cf9200, gdt+0x1c(%ebx)
+
/* Load new GDT with the 64bit segments using 32bit descriptor */
- leal gdt(%ebp), %eax
- movl %eax, gdt+2(%ebp)
- lgdt gdt(%ebp)
+ leal gdt(%ebx), %eax
+ movl %eax, gdt+2(%ebx)
+ lgdt gdt(%ebx)
/* Enable PAE mode */
xorl %eax, %eax
@@ -182,7 +195,7 @@ no_longmode:
* it may change in the future.
*/
.code64
- .org 0x200
+ .org 0x400
ENTRY(startup_64)
/* We come here either from startup_32 or directly from a
* 64bit bootloader. If we come here from a bootloader we depend on
@@ -287,15 +300,6 @@ relocated:
*/
jmp *%rbp
- .data
-gdt:
- .word gdt_end - gdt
- .long gdt
- .word 0
- .quad 0x0000000000000000 /* NULL descriptor */
- .quad 0x00af9a000000ffff /* __KERNEL_CS */
- .quad 0x00cf92000000ffff /* __KERNEL_DS */
-gdt_end:
.bss
/* Stack for uncompression */
.balign 4
diff --git a/arch/x86_64/boot/compressed/vmlinux.lds b/arch/x86_64/boot/compressed/vmlinux.lds
index 94c13e5..6e041ef 100644
--- a/arch/x86_64/boot/compressed/vmlinux.lds
+++ b/arch/x86_64/boot/compressed/vmlinux.lds
@@ -36,6 +36,8 @@ SECTIONS
*(COMMON)
. = ALIGN(8);
_end = . ;
+ gdt = . ;
+ . = . + 8 * 4;
. = ALIGN(4096);
pgtable = . ;
. = . + 4096 * 6;
next reply other threads:[~2007-05-13 5:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-13 5:33 Yinghai Lu [this message]
2007-05-13 5:52 ` Andi Kleen
2007-05-13 6:41 ` Yinghai Lu
2007-05-13 6:09 ` Eric W. Biederman
2007-05-13 6:29 ` Yinghai Lu
2007-05-13 6:48 ` Eric W. Biederman
2007-05-13 6:55 ` Yinghai Lu
2007-05-13 7:06 ` Eric W. Biederman
2007-05-13 7:27 ` Yinghai Lu
2007-05-13 18:01 ` Yinghai Lu
2007-05-13 19:49 ` Eric W. Biederman
2007-05-13 21:06 ` Yinghai Lu
2007-05-13 21:23 ` Eric W. Biederman
2007-05-14 17:26 ` [PATCH] serial: set RTS and DTR if flow is 'r' Yinghai Lu
2007-05-14 17:54 ` Randy Dunlap
2007-05-14 17:57 ` [PATCH] serial: set RTS and DTR if flow is 'r' --- resend Yinghai Lu
2007-05-14 18:10 ` Russell King
2007-05-14 19:04 ` Yinghai Lu
2007-05-14 19:19 ` Russell King
2007-05-14 19:46 ` Yinghai Lu
2007-05-14 19:50 ` Russell King
2007-05-14 20:04 ` Yinghai Lu
2007-05-15 20:48 ` [PATCH] serial: set DTR in uart for kernel serial console Yinghai Lu
2007-05-22 19:31 ` PATCH] serial: convert early_uart to earlycon for 8250 Yinghai Lu
2007-05-28 10:51 ` Russell King
2007-05-28 17:50 ` Yinghai Lu
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=86802c440705122233y327756e7te534199f46b2059d@mail.gmail.com \
--to=yhlu.kernel@gmail.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@in.ibm.com \
--cc=yinghai.lu@sun.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
all inboxes | Powered by JetHome®