Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > fc11cd6e1c513a17304da94a5390f3cd > files > 3938

kernel-2.6.18-194.11.1.el5.src.rpm

From: Neil Horman <nhorman@redhat.com>
Date: Tue, 26 Feb 2008 15:24:54 -0500
Subject: [x86] fix relocate_kernel to not overwrite pgd
Message-id: 20080226202454.GA31874@hmsendeavour.rdu.redhat.com
O-Subject: [RHEL 5.2 PATCH] fix relocate_kernel to not overwrite pgd in i386
Bugzilla: 346431

Hey-
	Backport of upstream commit 3566561bfadffcb5dbc85d576be80c0dbf2cccc9.
It modifies the relocate_kernel assembly code so that we don't overwrite the pgd
when booting a pivot kernel.  This can of course lead to other bad behavior
(hangs, resets, etc) if other processors are executing while the pgd is
overwritten (normally valid pointers will point to different data, or no real
memory, etc).  Fixes bz 346431.

Regards
Neil

Acked-by: Dave Anderson <anderson@redhat.com>

diff --git a/arch/i386/kernel/relocate_kernel.S b/arch/i386/kernel/relocate_kernel.S
index b2c23b6..f151d6f 100644
--- a/arch/i386/kernel/relocate_kernel.S
+++ b/arch/i386/kernel/relocate_kernel.S
@@ -154,45 +154,14 @@ relocate_new_kernel:
 	movl	PTR(PA_PGD)(%ebp), %eax
 	movl	%eax, %cr3
 
-	/* setup idt */
-	movl	%edi, %eax
-	addl	$(idt_48 - relocate_kernel), %eax
-	lidtl	(%eax)
-
-	/* setup gdt */
-	movl	%edi, %eax
-	addl	$(gdt - relocate_kernel), %eax
-	movl	%edi, %esi
-	addl	$((gdt_48 - relocate_kernel) + 2), %esi
-	movl	%eax, (%esi)
-
-	movl	%edi, %eax
-	addl	$(gdt_48 - relocate_kernel), %eax
-	lgdtl	(%eax)
-
-	/* setup data segment registers */
-	mov	$(gdt_ds - gdt), %eax
-	mov	%eax, %ds
-	mov	%eax, %es
-	mov	%eax, %fs
-	mov	%eax, %gs
-	mov	%eax, %ss
-
 	/* setup a new stack at the end of the physical control page */
 	lea	4096(%edi), %esp
 
-	/* load new code segment and jump to identity mapped page */
-	movl	%edi, %esi
-	xorl	%eax, %eax
-	pushl	%eax
-	pushl	%esi
-	pushl	%eax
-	movl	$(gdt_cs - gdt), %eax
-	pushl	%eax
-	movl	%edi, %eax
-	addl	$(identity_mapped - relocate_kernel),%eax
-	pushl	%eax
-	iretl
+	/* jump to identity mapped page */
+	movl    %edi, %eax
+	addl    $(identity_mapped - relocate_kernel), %eax
+	pushl   %eax
+	ret
 
 identity_mapped:
 	/* store the start address on the stack */
@@ -281,20 +250,3 @@ identity_mapped:
 	xorl    %edi, %edi
 	xorl    %ebp, %ebp
 	ret
-
-	.align	16
-gdt:
-	.quad	0x0000000000000000	/* NULL descriptor */
-gdt_cs:
-	.quad	0x00cf9a000000ffff	/* kernel 4GB code at 0x00000000 */
-gdt_ds:
-	.quad	0x00cf92000000ffff	/* kernel 4GB data at 0x00000000 */
-gdt_end:
-
-gdt_48:
-	.word	gdt_end - gdt - 1	/* limit */
-	.long	0			/* base - filled in by code above */
-
-idt_48:
-	.word	0			/* limit */
-	.long	0			/* base */