Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / i386 / kernel / head.S
index f7867f4..3debc2e 100644 (file)
 #include <asm/desc.h>
 #include <asm/cache.h>
 #include <asm/thread_info.h>
-#include <asm/asm_offsets.h>
+#include <asm/asm-offsets.h>
 #include <asm/setup.h>
 
 /*
  * References to members of the new_cpu_data structure.
  */
 
-#define CPU_PARAMS     new_cpu_data
-#define X86            CPU_PARAMS+0
-#define X86_VENDOR     CPU_PARAMS+1
-#define X86_MODEL      CPU_PARAMS+2
-#define X86_MASK       CPU_PARAMS+3
-#define X86_HARD_MATH  CPU_PARAMS+6
-#define X86_CPUID      CPU_PARAMS+8
-#define X86_CAPABILITY CPU_PARAMS+12
-#define X86_VENDOR_ID  CPU_PARAMS+36   /* offset dependent on NCAPINTS */
+#define X86            new_cpu_data+CPUINFO_x86
+#define X86_VENDOR     new_cpu_data+CPUINFO_x86_vendor
+#define X86_MODEL      new_cpu_data+CPUINFO_x86_model
+#define X86_MASK       new_cpu_data+CPUINFO_x86_mask
+#define X86_HARD_MATH  new_cpu_data+CPUINFO_hard_math
+#define X86_CPUID      new_cpu_data+CPUINFO_cpuid_level
+#define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability
+#define X86_VENDOR_ID  new_cpu_data+CPUINFO_x86_vendor_id
 
 /*
  * This is how much memory *in addition to the memory covered up to
@@ -78,6 +77,32 @@ ENTRY(startup_32)
        subl %edi,%ecx
        shrl $2,%ecx
        rep ; stosl
+/*
+ * Copy bootup parameters out of the way.
+ * Note: %esi still has the pointer to the real-mode data.
+ * With the kexec as boot loader, parameter segment might be loaded beyond
+ * kernel image and might not even be addressable by early boot page tables.
+ * (kexec on panic case). Hence copy out the parameters before initializing
+ * page tables.
+ */
+       movl $(boot_params - __PAGE_OFFSET),%edi
+       movl $(PARAM_SIZE/4),%ecx
+       cld
+       rep
+       movsl
+       movl boot_params - __PAGE_OFFSET + NEW_CL_POINTER,%esi
+       andl %esi,%esi
+       jnz 2f                  # New command line protocol
+       cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
+       jne 1f
+       movzwl OLD_CL_OFFSET,%esi
+       addl $(OLD_CL_BASE_ADDR),%esi
+2:
+       movl $(saved_command_line - __PAGE_OFFSET),%edi
+       movl $(COMMAND_LINE_SIZE/4),%ecx
+       rep
+       movsl
+1:
 
 /*
  * Initialize page tables.  This creates a PDE and a set of page
@@ -129,9 +154,6 @@ ENTRY(startup_32_smp)
        movl %eax,%fs
        movl %eax,%gs
 
-       xorl %ebx,%ebx
-       incl %ebx                               /* This is a secondary processor (AP) */
-
 /*
  *     New page tables may be in 4Mbyte page mode and may
  *     be using the global pages. 
@@ -149,11 +171,38 @@ ENTRY(startup_32_smp)
 #define cr4_bits mmu_cr4_features-__PAGE_OFFSET
        movl cr4_bits,%edx
        andl %edx,%edx
-       jz 3f
+       jz 6f
        movl %cr4,%eax          # Turn on paging options (PSE,PAE,..)
        orl %edx,%eax
        movl %eax,%cr4
 
+       btl $5, %eax            # check if PAE is enabled
+       jnc 6f
+
+       /* Check if extended functions are implemented */
+       movl $0x80000000, %eax
+       cpuid
+       cmpl $0x80000000, %eax
+       jbe 6f
+       mov $0x80000001, %eax
+       cpuid
+       /* Execute Disable bit supported? */
+       btl $20, %edx
+       jnc 6f
+
+       /* Setup EFER (Extended Feature Enable Register) */
+       movl $0xc0000080, %ecx
+       rdmsr
+
+       btsl $11, %eax
+       /* Make changes effective */
+       wrmsr
+
+6:
+       /* This is a secondary processor (AP) */
+       xorl %ebx,%ebx
+       incl %ebx
+
 3:
 #endif /* CONFIG_SMP */
 
@@ -191,28 +240,6 @@ ENTRY(startup_32_smp)
  */
        call setup_idt
 
-/*
- * Copy bootup parameters out of the way.
- * Note: %esi still has the pointer to the real-mode data.
- */
-       movl $boot_params,%edi
-       movl $(PARAM_SIZE/4),%ecx
-       cld
-       rep
-       movsl
-       movl boot_params+NEW_CL_POINTER,%esi
-       andl %esi,%esi
-       jnz 2f                  # New command line protocol
-       cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
-       jne 1f
-       movzwl OLD_CL_OFFSET,%esi
-       addl $(OLD_CL_BASE_ADDR),%esi
-2:
-       movl $saved_command_line,%edi
-       movl $(COMMAND_LINE_SIZE/4),%ecx
-       rep
-       movsl
-1:
 checkCPUtype:
 
        movl $-1,X86_CPUID              #  -1 for no CPUID initially
@@ -276,7 +303,6 @@ is386:      movl $2,%ecx            # set MP
        movl %eax,%cr0
 
        call check_x87
-       incb ready
        lgdt cpu_gdt_descr
        lidt idt_descr
        ljmp $(__KERNEL_CS),$1f
@@ -293,8 +319,9 @@ is386:      movl $2,%ecx            # set MP
        lldt %ax
        cld                     # gcc2 wants the direction flag cleared at all times
 #ifdef CONFIG_SMP
-       movb ready, %cl 
-       cmpb $1,%cl
+       movb ready, %cl
+       movb $1, ready
+       cmpb $0,%cl
        je 1f                   # the first CPU calls start_kernel
                                # all other CPUs call initialize_secondary
        call initialize_secondary
@@ -357,6 +384,7 @@ rp_sidt:
        ALIGN
 ignore_int:
        cld
+#ifdef CONFIG_PRINTK
        pushl %eax
        pushl %ecx
        pushl %edx
@@ -370,13 +398,18 @@ ignore_int:
        pushl 32(%esp)
        pushl 40(%esp)
        pushl $int_msg
+#ifdef CONFIG_EARLY_PRINTK
+       call early_printk
+#else
        call printk
+#endif
        addl $(5*4),%esp
        popl %ds
        popl %es
        popl %edx
        popl %ecx
        popl %eax
+#endif
        iret
 
 /*
@@ -417,7 +450,6 @@ int_msg:
 
 .globl boot_gdt_descr
 .globl idt_descr
-.globl cpu_gdt_descr
 
        ALIGN
 # early boot GDT descriptor (must use 1:1 address mapping)
@@ -437,8 +469,6 @@ cpu_gdt_descr:
        .word GDT_ENTRIES*8-1
        .long cpu_gdt_table
 
-       .fill NR_CPUS-1,8,0             # space for the other GDT descriptors
-
 /*
  * The boot_gdt_table must mirror the equivalent in setup.S and is
  * used only for booting.
@@ -452,7 +482,7 @@ ENTRY(boot_gdt_table)
 /*
  * The Global Descriptor Table contains 28 quadwords, per-CPU.
  */
-       .align PAGE_SIZE_asm
+       .align L1_CACHE_BYTES
 ENTRY(cpu_gdt_table)
        .quad 0x0000000000000000        /* NULL descriptor */
        .quad 0x0000000000000000        /* 0x0b reserved */
@@ -475,27 +505,29 @@ ENTRY(cpu_gdt_table)
        .quad 0x0000000000000000        /* 0x80 TSS descriptor */
        .quad 0x0000000000000000        /* 0x88 LDT descriptor */
 
-       /* Segments used for calling PnP BIOS */
-       .quad 0x00c09a0000000000        /* 0x90 32-bit code */
-       .quad 0x00809a0000000000        /* 0x98 16-bit code */
-       .quad 0x0080920000000000        /* 0xa0 16-bit data */
-       .quad 0x0080920000000000        /* 0xa8 16-bit data */
-       .quad 0x0080920000000000        /* 0xb0 16-bit data */
+       /*
+        * Segments used for calling PnP BIOS have byte granularity.
+        * They code segments and data segments have fixed 64k limits,
+        * the transfer segment sizes are set at run time.
+        */
+       .quad 0x00409a000000ffff        /* 0x90 32-bit code */
+       .quad 0x00009a000000ffff        /* 0x98 16-bit code */
+       .quad 0x000092000000ffff        /* 0xa0 16-bit data */
+       .quad 0x0000920000000000        /* 0xa8 16-bit data */
+       .quad 0x0000920000000000        /* 0xb0 16-bit data */
+
        /*
         * The APM segments have byte granularity and their bases
-        * and limits are set at run time.
+        * are set at run time.  All have 64k limits.
         */
-       .quad 0x00409a0000000000        /* 0xb8 APM CS    code */
-       .quad 0x00009a0000000000        /* 0xc0 APM CS 16 code (16 bit) */
-       .quad 0x0040920000000000        /* 0xc8 APM DS    data */
+       .quad 0x00409a000000ffff        /* 0xb8 APM CS    code */
+       .quad 0x00009a000000ffff        /* 0xc0 APM CS 16 code (16 bit) */
+       .quad 0x004092000000ffff        /* 0xc8 APM DS    data */
 
-       .quad 0x0000000000000000        /* 0xd0 - unused */
+       .quad 0x0000920000000000        /* 0xd0 - ESPFIX 16-bit SS */
        .quad 0x0000000000000000        /* 0xd8 - unused */
        .quad 0x0000000000000000        /* 0xe0 - unused */
        .quad 0x0000000000000000        /* 0xe8 - unused */
        .quad 0x0000000000000000        /* 0xf0 - unused */
        .quad 0x0000000000000000        /* 0xf8 - GDT entry 31: double-fault TSS */
 
-#ifdef CONFIG_SMP
-       .fill (NR_CPUS-1)*GDT_ENTRIES,8,0 /* other CPU's GDT */
-#endif