trampoline question

Manfred Spraul (manfreds@colorfullife.com)
Tue, 30 Nov 1999 18:30:18 +0100


This is a multi-part message in MIME format.
--------------31B6492F30143F3C690566D2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I tried to further clean up the i386 trampoline code, and I found 2
weird lines:

1) the decompressor (arch/i386/boot/compressed/head.S) checks if it is
called by the trampoline code.

AFAICS, this can never happen: the decompressor decompresses the kernel
on the first cpu, and then these functions are overwritten.
the "ljmpl KERNEL_CS,0x0100000" in arch/i386/kernel/trampoline.S always
jumps to "startup_32", never to "startup_32" 8)

ie always to the function in in arch/i386/kernel/head.S, never the
function in arch/i386/boot/compressed/head.S.

2) arch/i386/kernel/head.S enables the 4 MB page tables twice:

around line 65, the secondary cpu loads the cr4 value from the primary
cpu, and around line 220 it unconditionally enables 4 MB page tables.

AFAICS, the second asm block is completely superflous.

A patch is attached (tested with lilo and bzImage)

Manfred
--------------31B6492F30143F3C690566D2
Content-Type: text/plain; charset=us-ascii;
name="patch-trampoline"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch-trampoline"

// $Header: /pub/cvs/ms/patches/patch-trampoline,v 1.1 1999/11/30 16:59:38 manfreds Exp $
// Kernel Version:
// VERSION = 2
// PATCHLEVEL = 3
// SUBLEVEL = 29
// EXTRAVERSION =
diff -ur -x traps.c -x Makefile 2.3/arch/i386/kernel/head.S build-2.3/arch/i386/kernel/head.S
--- 2.3/arch/i386/kernel/head.S Fri Nov 12 12:50:32 1999
+++ build-2.3/arch/i386/kernel/head.S Tue Nov 30 17:57:53 1999
@@ -212,17 +212,6 @@
orl $2,%eax # set MP
2: movl %eax,%cr0
call check_x87
-#ifdef __SMP__
- movb ready,%al # First CPU if 0
- orb %al,%al
- jz 4f # First CPU skip this stuff
- movl %cr4,%eax # Turn on 4Mb pages
- orl $16,%eax
- movl %eax,%cr4
- movl %cr3,%eax # Intel specification clarification says
- movl %eax,%cr3 # to do this. Maybe it makes a difference.
- # Who knows ?
-#endif
4:
#ifdef __SMP__
incb ready
diff -ur -x traps.c -x Makefile 2.3/arch/i386/kernel/trampoline.S build-2.3/arch/i386/kernel/trampoline.S
--- 2.3/arch/i386/kernel/trampoline.S Wed May 6 20:42:54 1998
+++ build-2.3/arch/i386/kernel/trampoline.S Tue Nov 30 17:55:34 1999
@@ -55,7 +55,7 @@
jmp flush_instr
flush_instr:
ljmpl $__KERNEL_CS, $0x00100000
- # jump to startup_32
+ # jump to startup_32 in arch/i386/kernel/head.S

idt_48:
.word 0 # idt limit = 0
diff -ur -x traps.c -x Makefile 2.3/arch/i386/boot/compressed/head.S build-2.3/arch/i386/boot/compressed/head.S
--- 2.3/arch/i386/boot/compressed/head.S Sun Mar 29 21:31:16 1998
+++ build-2.3/arch/i386/boot/compressed/head.S Tue Nov 30 17:54:11 1999
@@ -12,10 +12,6 @@
* the page directory. [According to comments etc elsewhere on a compressed
* kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
*
- * In SMP mode we keep this page safe. Really we ought to shuffle things and
- * put the trampoline here. - AC. An SMP trampoline enters with %cx holding
- * the stack base.
- *
* Page 0 is deliberately kept safe, since System Management Mode code in
* laptops may need to access the BIOS data stored there. This is also
* useful for future device drivers that either access the BIOS via VM86
@@ -41,24 +37,6 @@
movl %ax,%es
movl %ax,%fs
movl %ax,%gs
-#ifdef __SMP__
- orw %bx,%bx # What state are we in BX=1 for SMP
- # 0 for boot
- jz 2f # Initial boot
-
-/*
- * We are trampolining an SMP processor
- */
- mov %ax,%ss
- xorl %eax,%eax # Back to 0
- mov %cx,%ax # SP low 16 bits
- movl %eax,%esp
- pushl 0 # Clear NT
- popfl
- ljmp $(__KERNEL_CS), $0x100000 # Into C and sanity
-
-2:
-#endif
lss SYMBOL_NAME(stack_start),%esp
xorl %eax,%eax
1: incl %eax # check that A20 really IS enabled

--------------31B6492F30143F3C690566D2--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/