]> xenbits.xensource.com Git - xen.git/commitdiff
rombios: move the stack to 0x9e000 and protect it with an e820 entry
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jul 2010 08:51:40 +0000 (09:51 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 8 Jul 2010 08:51:40 +0000 (09:51 +0100)
so that we don't corrupt E820_RAM memory with stack ops in S3 wakeup.
It has to move up so the lowest contiguous RAM area is >= 512MiB.

This relies on the previous fix to let DS != SS

Signed-off-by: Paul Durrant <Paul.Durrant@citrix.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
tools/firmware/hvmloader/hvmloader.c
tools/firmware/rombios/rombios.c

index be0c3ffb98faa904194ff09ba2cee8558e6045ad..c6e12ed60c7e475cf249e1780c0fd9ace14688f8 100644 (file)
@@ -576,18 +576,68 @@ static void init_vm86_tss(void)
     printf("vm86 TSS at %08lx\n", virt_to_phys(tss));
 }
 
+static void dump_e820_table(void)
+{
+    struct e820entry *e820 = E820;
+    unsigned int nr = *E820_NR;
+    unsigned int last_end = 0;
+    int i;
+
+    printf("E820 table:\n");
+
+    for ( i = 0; i < nr; i++ )
+    {
+        unsigned int start = e820[i].addr;
+        unsigned int end = e820[i].addr + e820[i].size;
+
+        if ( start < last_end )
+            printf(" OVERLAP!!\n");
+        else if ( start > last_end )
+            printf(" HOLE: %08x - %08x\n", last_end, start);
+
+        printf(" [%02d]: %08x - %08x: ", i, start, end);
+        switch ( e820[i].type )
+        {
+        case E820_RAM:
+            printf("RAM\n");
+            break;
+        case E820_RESERVED:
+            printf("RESERVED\n");
+            break;
+        case E820_ACPI:
+            printf("ACPI\n");
+            break;
+        case E820_NVS:
+            printf("NVS\n");
+            break;
+        default:
+            printf("UNKNOWN (%08x)\n", e820[i].type);
+            break;
+        }
+
+        last_end = end;
+    }
+}
+
 /* Create an E820 table based on memory parameters provided in hvm_info. */
 static void build_e820_table(void)
 {
     struct e820entry *e820 = E820;
     unsigned int nr = 0;
 
-    /* 0x0-0x9FC00: Ordinary RAM. */
-    e820[nr].addr = 0x0;
-    e820[nr].size = 0x9FC00;
+    /* 0x0-0x9E000: Ordinary RAM. */
+    /* (Must be at least 512K to keep Windows happy) */
+    e820[nr].addr = 0x00000;
+    e820[nr].size = 0x9E000;
     e820[nr].type = E820_RAM;
     nr++;
 
+    /* 0x9E000-0x9FC00: Reserved for internal use. */
+    e820[nr].addr = 0x9E000;
+    e820[nr].size = 0x01C00;
+    e820[nr].type = E820_RESERVED;
+    nr++;
+
     /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */
     e820[nr].addr = 0x9FC00;
     e820[nr].size = 0x400;
@@ -739,6 +789,7 @@ int main(void)
                ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1);
 
     build_e820_table();
+    dump_e820_table();
 
     bios_info = (struct bios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
     memset(bios_info, 0, sizeof(*bios_info));
index 3de72cf9d1f76787e143a99e7427e44f30ab02e0..4e0157c80f254c9618ca05581011280847624095 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////
 // $Id: rombios.c,v 1.221 2008/12/07 17:32:29 sshwarts Exp $
-/////////////////////////////////////////////////////////////////////////
+////////////////////////////#/////////////////////////////////////////////
 //
 //  Copyright (C) 2002  MandrakeSoft S.A.
 //
@@ -8862,13 +8862,14 @@ int13_out:
 int18_handler: ;; Boot Failure recovery: try the next device.
 
   ;; Reset SP and SS
-  mov  ax, #0xfffe
+  mov  ax, #0x0ffe
   mov  sp, ax
-  xor  ax, ax
+  mov  ax, #0x9e00
   mov  ss, ax
 
   ;; The first time we do this it will have been set to -1 so 
   ;; we will start from device 0.
+  xor  ax, ax
   mov  ds, ax
   mov  bx, word ptr [0x40E]       ;; EBDA segment
   mov  ds, bx                     ;; Set segment
@@ -8902,9 +8903,9 @@ int19_relocated: ;; Boot function, relocated
   ;; 
   ;; Reset SP and SS
 
-  mov  ax, #0xfffe
+  mov  ax, #0x0ffe
   mov  sp, ax
-  xor  ax, ax
+  mov  ax, #0x9e00
   mov  ss, ax
 
   call _machine_reset
@@ -10839,10 +10840,9 @@ normal_post:
   ; case 0: normal startup
 
   cli
-  mov  ax, #0xfffe
+  mov  ax, #0x0ffe
   mov  sp, ax
-  xor  ax, ax
-  mov  ds, ax
+  mov  ax, #0x9e00
   mov  ss, ax
 
   ;; Save shutdown status