Load an IDT with NULL limit
authorStefan Reinauer <reinauer@chromium.org>
Wed, 1 Jun 2011 21:01:46 +0000 (14:01 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Thu, 13 Oct 2011 18:02:46 +0000 (20:02 +0200)
Load an IDT with NULL limit to prevent the 16bit IDT being used
in protected mode before c_start.S sets up a 32bit IDT when entering
ram stage.

Signed-off-by: Stefan Reinauer <reinauer@google.com>
Change-Id: I8d048c894c863ac4971fcef8f065be6b899e1d3e
Reviewed-on: http://review.coreboot.org/259
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marcj303@gmail.com>
src/cpu/x86/16bit/entry16.inc
src/cpu/x86/16bit/entry16.lds

index 1eb92c82d12bf6bcd15603bbf0f181f8dede4414..9f4c0e38dae639bd5f9a26f0fe0c53429bdb12bb 100644 (file)
@@ -45,7 +45,6 @@ _start:
        xorl    %eax, %eax
        movl    %eax, %cr3    /* Invalidate TLB*/
 
-
        /* Invalidating the cache here seems to be a bad idea on
         * modern processors.  Don't.
         * If we are hyperthreaded or we have multiple cores it is bad,
@@ -55,6 +54,13 @@ _start:
         * entry16.inc.
         */
 
+       /* Load an IDT with NULL limit to prevent the 16bit IDT being used
+        * in protected mode before c_start.S sets up a 32bit IDT when entering
+        * ram stage.
+        */
+       movw $nullidt_offset, %bx
+       lidt %cs:(%bx)
+
        /* Note: gas handles memory addresses in 16 bit code very poorly.
         * In particular it doesn't appear to have a directive allowing you
         * associate a section or even an absolute offset with a segment register.
@@ -118,6 +124,13 @@ gdtptr16:
        .word   gdt_end - gdt -1 /* compute the table limit */
        .long   gdt              /* we know the offset */
 
+.align 4
+.globl nullidt
+nullidt:
+       .word   0       /* limit */
+       .long   0
+       .word   0
+
 .globl _estart
 _estart:
        .code32
index 0580f0e80306bfc861c0a690a50791bd6dee5290..112d429953c691e4b77f8fb6d2295f693b424d0f 100644 (file)
@@ -1 +1,2 @@
        gdtptr16_offset = gdtptr16 & 0xffff;
+       nullidt_offset = nullidt & 0xffff;