linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]x86_64: build and use GDT on copied compressed kernel
@ 2007-05-13  5:33 Yinghai Lu
  2007-05-13  5:52 ` Andi Kleen
  2007-05-13  6:09 ` Eric W. Biederman
  0 siblings, 2 replies; 26+ messages in thread
From: Yinghai Lu @ 2007-05-13  5:33 UTC (permalink / raw)
  To: Eric W. Biederman, Andi Kleen, Andrew Morton, Vivek Goyal
  Cc: Linux Kernel Mailing List, yinghai.lu

[-- 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;

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2007-05-28 17:50 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-13  5:33 [PATCH]x86_64: build and use GDT on copied compressed kernel Yinghai Lu
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

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).