Skip to contentSkip to conversation

Fix loading binary images that support or require PAE

PATCH RESEND New Bruce Rogers 1 participant 1 message May 9, 2006

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Fix loading binary images that support or require PAE

(Pardon the resend - I was playing with whether i should use a 2 or 3 bit field and left the shift amount 1 off)

Loading of binary images which include a quasi-Multi-boot Spec record is supported by Xen, but currently there not a way
to inform the loader of the PAE requirements/capabilities of the loading image. This patch extends the flags used in the quasi-Multi-boot Spec record to this include information, and to process that information. It also attempts to provide a way to specify that the binary image is a 64 bit kernel, but that was an afterthought in this patch, so there could be things I'm missing there.

- Bruce Rogers

tools/libxc/xg_private.h +2 -2
diff -r fc9ec6fd3400 tools/libxc/xg_private.h
@@ -127,7 +127,7 @@
     errno = __saved_errno;                                      \
 } while (0)
 
-
+enum pae_mode {NON_PAE_KERNEL32, PAE_KERNEL32, PAE_KERNEL64, BIMODAL_KERNEL32};
 struct domain_setup_info
 {
     unsigned long v_start;
@@ -137,7 +137,7 @@
     unsigned long v_kernentry;
 
     unsigned int  load_symtab;
-    unsigned int  pae_kernel;
+    enum pae_mode kernel_pae_mode;
     unsigned long symtab_addr;
     unsigned long symtab_len;
 
tools/libxc/xc_load_elf.c +7 -1
diff -r fc9ec6fd3400 tools/libxc/xc_load_elf.c
@@ -131,7 +131,13 @@
             return -EINVAL;
         }
         if ( (strstr(guestinfo, "PAE=yes") != NULL) )
-            dsi->pae_kernel = 1;
+#if defined(__i386__)
+            dsi->kernel_pae_mode = PAE_KERNEL32;
+#elif defined(__x86_64__)
+            dsi->kernel_pae_mode = PAE_KERNEL64;
+#endif
+        else
+            dsi->kernel_pae_mode = NON_PAE_KERNEL32;
 
         break;
     }
tools/libxc/xc_load_bin.c +8 -0
diff -r fc9ec6fd3400 tools/libxc/xc_load_bin.c
@@ -29,6 +29,9 @@
  *          that memory info should be passed to the image)
  *   bit 2: reserved, must be 0 (the multiboot spec uses this bit to indicate
  *          that the bootloader should pass video mode info to the image)
+ *   bits 14-15: contains the paging and cpu mode requirements of the image
+ *               0 = Non-PAE 32 bit, 1 = PAE 32 bit, 2 = PAE 64 bit, 3 = image
+ *               detects current mode and adapts accordingly
  *   bit 16: reserved, must be 1 (the multiboot spec uses this bit to indicate
  *           that the values in the fields header_addr - entry_addr are
  *           valid)
@@ -92,7 +95,10 @@
 #define XEN_REACTOS_FLAG_ALIGN4K     0x00000001
 #define XEN_REACTOS_FLAG_NEEDMEMINFO 0x00000002
 #define XEN_REACTOS_FLAG_NEEDVIDINFO 0x00000004
+#define XEN_REACTOS_FLAG_PAE_MASK    0x0000C000
 #define XEN_REACTOS_FLAG_ADDRSVALID  0x00010000
+
+#define XEN_REACTOS_FLAG_PAE_SHIFT 14
 
 /* Flags we test for */
 #define FLAGS_MASK     ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K))
@@ -228,6 +234,8 @@
     dsi->v_kernend = dsi->v_end;
     dsi->v_kernentry = image_info->entry_addr;
     dsi->xen_guest_string = "";
+    dsi->kernel_pae_mode = (image_info->flags & XEN_REACTOS_FLAG_PAE_MASK) >>
+                           XEN_REACTOS_FLAG_PAE_SHIFT;
 
     return 0;
 }
tools/libxc/xc_linux_build.c +10 -6
diff -r fc9ec6fd3400 tools/libxc/xc_linux_build.c
@@ -591,11 +591,15 @@
     }
 
     if (strstr(xen_caps, "xen-3.0-x86_32p")) {
-        if (!dsi->pae_kernel) {
+        if (dsi->kernel_pae_mode == BIMODAL_KERNEL32)
+            dsi->kernel_pae_mode = PAE_KERNEL32;
+        else if (dsi->kernel_pae_mode != PAE_KERNEL32) {
             ERROR("Non PAE-kernel on PAE host.");
             return 0;
         }
-    } else if (dsi->pae_kernel) {
+    } else if (dsi->kernel_pae_mode == BIMODAL_KERNEL32)
+        dsi->kernel_pae_mode = NON_PAE_KERNEL32;
+    else if (dsi->kernel_pae_mode != NON_PAE_KERNEL32) {
         ERROR("PAE-kernel on non-PAE host.");
         return 0;
     }
@@ -728,7 +732,7 @@
         if ( (v_end - vstack_end) < (512UL << 10) )
             v_end += 1UL << 22; /* Add extra 4MB to get >= 512kB padding. */
 #if defined(__i386__)
-        if ( dsi.pae_kernel )
+        if ( dsi.kernel_pae_mode == PAE_KERNEL32 )
         {
             /* FIXME: assumes one L2 pgtable @ 0xc0000000 */
             if ( (((v_end - dsi.v_start + ((1<<L2_PAGETABLE_SHIFT_PAE)-1)) >> 
@@ -804,7 +808,7 @@
 
     /* setup page tables */
 #if defined(__i386__)
-    if (dsi.pae_kernel)
+    if (dsi.kernel_pae_mode == PAE_KERNEL32)
         rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
                                  dsi.v_start, v_end,
                                  page_array, vpt_start, vpt_end,
@@ -831,7 +835,7 @@
      */
     if ( !shadow_mode_enabled )
     {
-        if ( dsi.pae_kernel )
+        if ( dsi.kernel_pae_mode == PAE_KERNEL32 )
         {
             if ( pin_table(xc_handle, MMUEXT_PIN_L3_TABLE,
                            ctxt->ctrlreg[3] >> PAGE_SHIFT, dom) )
@@ -965,7 +969,7 @@
     rc = xc_version(xc_handle, XENVER_version, NULL);
     sprintf(start_info->magic, "xen-%i.%i-x86_%d%s",
             rc >> 16, rc & (0xFFFF), (unsigned int)sizeof(long)*8,
-            dsi.pae_kernel ? "p" : "");
+            dsi.kernel_pae_mode == PAE_KERNEL32 ? "p" : "");
     start_info->nr_pages     = nr_pages;
     start_info->shared_info  = guest_shared_info_mfn << PAGE_SHIFT;
     start_info->flags        = flags;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel