Fix loading binary images that support or require PAE
PATCH 1/1 Fix loading binary images that support or require PAE
(This patch supersedes the last patch sent by me, as this one includes fixes for issues encountered beyond the initial fix
for passing PAE capabilities from a binary image.)
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.
Comments welcome. If no issues, please apply.
- Bruce Rogers
tools/libxc/xg_private.h +2 -2
@@ -127,7 +127,7 @@ do { 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 @@ struct domain_setup_infounsigned 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
@@ -132,7 +132,13 @@ static int parseelfimage(const char *imareturn -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 +10 -1
@@ -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,10 +95,14 @@ struct xen_bin_image_table#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)) +#define FLAGS_MASK ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K) & \ + (~ XEN_REACTOS_FLAG_PAE_MASK))#define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID static struct xen_bin_image_table *
@@ -228,6 +235,8 @@ static int parsebinimage(const char *ima 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 +20 -8
@@ -328,6 +328,13 @@ static int setup_pg_tables_pae(int xc_ha } vl1e++; } + +/* Xen requires an entry mapping 0xC0000000 region */ +if ((vl3tab[3 ] & _PAGE_PRESENT) ==0 ) + { +alloc_pt (l2tab, vl2tab, pl2tab); + vl3tab[3 ] = l2tab |L3_PROT ; + }munmap (vl1tab,PAGE_SIZE );munmap (vl2tab,PAGE_SIZE );
@@ -591,11 +598,15 @@ static int compat_check(int xc_handle, s }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,11 +739,12 @@ static int setup_guest(int xc_handle,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 */ +/* Add 1 more page if 0xC0000000 region not otherwise reached */ if ( (((v_end - dsi.v_start + ((1 <<L2_PAGETABLE_SHIFT_PAE )-1 )) >> -L2_PAGETABLE_SHIFT_PAE ) +2 ) <= nr_pt_pages ) +L2_PAGETABLE_SHIFT_PAE ) +2 + (v_end <=0xC0000000 )) + <= nr_pt_pages )break ; }else
@@ -804,7 +816,7 @@ static int setup_guest(int xc_handle,/* 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 +843,7 @@ static int setup_guest(int xc_handle,*/ 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 +977,7 @@ static int setup_guest(int xc_handle, 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