ia64/xen-unstable

changeset 6669:fb90dd31c6d7

Extend save/restore interface to cope with domains >4GB by adding a level of indirection.
Signed-off-by: ian@xensource.com
author iap10@firebug.cl.cam.ac.uk
date Wed Sep 07 02:31:24 2005 +0000 (2005-09-07)
parents 8db9c5873b9b
children 77d8b5e40da7
files linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6-xen-sparse/arch/xen/kernel/reboot.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c tools/libxc/xc_linux_save.c xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Tue Sep 06 18:29:53 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Wed Sep 07 02:31:24 2005 +0000
     1.3 @@ -359,7 +359,8 @@ static void __init probe_roms(void)
     1.4  shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
     1.5  EXPORT_SYMBOL(HYPERVISOR_shared_info);
     1.6  
     1.7 -unsigned long *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
     1.8 +unsigned long *phys_to_machine_mapping;
     1.9 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[16];
    1.10  EXPORT_SYMBOL(phys_to_machine_mapping);
    1.11  
    1.12  /* Raw start-of-day parameters from the hypervisor. */
    1.13 @@ -1519,7 +1520,7 @@ static void set_mca_bus(int x) { }
    1.14   */
    1.15  void __init setup_arch(char **cmdline_p)
    1.16  {
    1.17 -	int i, j;
    1.18 +	int i, j, k, fpp;
    1.19  	physdev_op_t op;
    1.20  	unsigned long max_low_pfn;
    1.21  
    1.22 @@ -1669,14 +1670,31 @@ void __init setup_arch(char **cmdline_p)
    1.23  			sizeof(unsigned long))));
    1.24  	}
    1.25  
    1.26 -	pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
    1.27 -	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    1.28 -	{	
    1.29 -	     pfn_to_mfn_frame_list[j] = 
    1.30 -		  virt_to_mfn(&phys_to_machine_mapping[i]);
    1.31 +
    1.32 +	/* 
    1.33 +	 * Initialise the list of the frames that specify the list of 
    1.34 +	 * frames that make up the p2m table. Used by save/restore
    1.35 +	 */
    1.36 +	pfn_to_mfn_frame_list_list = alloc_bootmem_low_pages(PAGE_SIZE);
    1.37 +	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
    1.38 +	  virt_to_mfn(pfn_to_mfn_frame_list_list);
    1.39 +	       
    1.40 +	fpp = PAGE_SIZE/sizeof(unsigned long);
    1.41 +	for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
    1.42 +	{
    1.43 +	    if ( (j % fpp) == 0 )
    1.44 +	    {
    1.45 +	        k++;
    1.46 +		BUG_ON(k>=16);
    1.47 +		pfn_to_mfn_frame_list[k] = alloc_bootmem_low_pages(PAGE_SIZE);
    1.48 +		pfn_to_mfn_frame_list_list[k] = 
    1.49 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
    1.50 +		j=0;
    1.51 +	    }
    1.52 +	    pfn_to_mfn_frame_list[k][j] = 
    1.53 +	        virt_to_mfn(&phys_to_machine_mapping[i]);
    1.54  	}
    1.55 -	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
    1.56 -	     virt_to_mfn(pfn_to_mfn_frame_list);
    1.57 +	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
    1.58  
    1.59  	/*
    1.60  	 * NOTE: at this point the bootmem allocator is fully available.
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Tue Sep 06 18:29:53 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Wed Sep 07 02:31:24 2005 +0000
     2.3 @@ -67,7 +67,7 @@ static int shutting_down = SHUTDOWN_INVA
     2.4  
     2.5  static int __do_suspend(void *ignore)
     2.6  {
     2.7 -    int i, j;
     2.8 +    int i, j, k, fpp;
     2.9  
    2.10  #ifdef CONFIG_XEN_USB_FRONTEND
    2.11      extern void usbif_resume();
    2.12 @@ -81,7 +81,7 @@ static int __do_suspend(void *ignore)
    2.13      extern void time_suspend(void);
    2.14      extern void time_resume(void);
    2.15      extern unsigned long max_pfn;
    2.16 -    extern unsigned long *pfn_to_mfn_frame_list;
    2.17 +    extern unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[];
    2.18  
    2.19  #ifdef CONFIG_SMP
    2.20      extern void smp_suspend(void);
    2.21 @@ -191,14 +191,24 @@ static int __do_suspend(void *ignore)
    2.22      HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
    2.23  
    2.24      memset(empty_zero_page, 0, PAGE_SIZE);
    2.25 -
    2.26 -    for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    2.27 +	     
    2.28 +    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
    2.29 +		virt_to_mfn(pfn_to_mfn_frame_list_list);
    2.30 +  
    2.31 +    fpp = PAGE_SIZE/sizeof(unsigned long);
    2.32 +    for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
    2.33      {
    2.34 -        pfn_to_mfn_frame_list[j] = 
    2.35 -            virt_to_mfn(&phys_to_machine_mapping[i]);
    2.36 +	if ( (j % fpp) == 0 )
    2.37 +	{
    2.38 +	    k++;
    2.39 +	    pfn_to_mfn_frame_list_list[k] = 
    2.40 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
    2.41 +	    j=0;
    2.42 +	}
    2.43 +	pfn_to_mfn_frame_list[k][j] = 
    2.44 +		virt_to_mfn(&phys_to_machine_mapping[i]);
    2.45      }
    2.46 -    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
    2.47 -        virt_to_mfn(pfn_to_mfn_frame_list);
    2.48 +    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
    2.49  
    2.50      gnttab_resume();
    2.51  
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Tue Sep 06 18:29:53 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Wed Sep 07 02:31:24 2005 +0000
     3.3 @@ -76,7 +76,8 @@ EXPORT_SYMBOL(HYPERVISOR_shared_info);
     3.4  /* Allows setting of maximum possible memory size  */
     3.5  unsigned long xen_override_max_pfn;
     3.6  
     3.7 -unsigned long *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
     3.8 +unsigned long *phys_to_machine_mapping;
     3.9 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[512];
    3.10  
    3.11  EXPORT_SYMBOL(phys_to_machine_mapping);
    3.12  
    3.13 @@ -730,7 +731,7 @@ void __init setup_arch(char **cmdline_p)
    3.14  #endif
    3.15  #ifdef CONFIG_XEN
    3.16  	{
    3.17 -		int i, j;
    3.18 +		int i, j, k, fpp;
    3.19  		/* Make sure we have a large enough P->M table. */
    3.20  		if (end_pfn > xen_start_info->nr_pages) {
    3.21  			phys_to_machine_mapping = alloc_bootmem(
    3.22 @@ -746,11 +747,35 @@ void __init setup_arch(char **cmdline_p)
    3.23  						sizeof(unsigned long))));
    3.24  		}
    3.25  
    3.26 -		pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE);
    3.27 +		/* 
    3.28 +		 * Initialise the list of the frames that specify the list of 
    3.29 +		 * frames that make up the p2m table. Used by save/restore
    3.30 +		 */
    3.31 +		pfn_to_mfn_frame_list_list = alloc_bootmem(PAGE_SIZE);
    3.32 +		HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
    3.33 +		  virt_to_mfn(pfn_to_mfn_frame_list_list);
    3.34 +	       
    3.35 +		fpp = PAGE_SIZE/sizeof(unsigned long);
    3.36 +		for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
    3.37 +		{
    3.38 +			if ( (j % fpp) == 0 )
    3.39 +			{
    3.40 +				k++;
    3.41 +				BUG_ON(k>=fpp);
    3.42 +				pfn_to_mfn_frame_list[k] = alloc_bootmem(PAGE_SIZE);
    3.43 +				pfn_to_mfn_frame_list_list[k] = 
    3.44 +					virt_to_mfn(pfn_to_mfn_frame_list[k]);
    3.45 +				j=0;
    3.46 +			}
    3.47 +			pfn_to_mfn_frame_list[k][j] = 
    3.48 +				virt_to_mfn(&phys_to_machine_mapping[i]);
    3.49 +		}
    3.50 +		HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
    3.51 +		
    3.52 +		
    3.53  
    3.54 -		for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    3.55 -			pfn_to_mfn_frame_list[j] =
    3.56 -				virt_to_mfn(&phys_to_machine_mapping[i]);
    3.57 +
    3.58 +
    3.59  	}
    3.60  #endif
    3.61  
     4.1 --- a/tools/libxc/xc_linux_save.c	Tue Sep 06 18:29:53 2005 +0000
     4.2 +++ b/tools/libxc/xc_linux_save.c	Wed Sep 07 02:31:24 2005 +0000
     4.3 @@ -419,6 +419,7 @@ int xc_linux_save(int xc_handle, int io_
     4.4      unsigned long page[1024];
     4.5  
     4.6      /* A copy of the pfn-to-mfn table frame list. */
     4.7 +    unsigned long *live_pfn_to_mfn_frame_list_list = NULL;
     4.8      unsigned long *live_pfn_to_mfn_frame_list = NULL;
     4.9      unsigned long pfn_to_mfn_frame_list[1024];
    4.10  
    4.11 @@ -506,11 +507,20 @@ int xc_linux_save(int xc_handle, int io_
    4.12          goto out;
    4.13      }
    4.14  
    4.15 -    /* the pfn_to_mfn_frame_list fits in a single page */
    4.16 +    live_pfn_to_mfn_frame_list_list = xc_map_foreign_range(xc_handle, dom,
    4.17 +                                        PAGE_SIZE, PROT_READ,
    4.18 +                                        live_shinfo->arch.pfn_to_mfn_frame_list_list);
    4.19 +
    4.20 +    if (!live_pfn_to_mfn_frame_list_list){
    4.21 +        ERR("Couldn't map pfn_to_mfn_frame_list_list");
    4.22 +        goto out;
    4.23 +    }
    4.24 +
    4.25      live_pfn_to_mfn_frame_list = 
    4.26 -        xc_map_foreign_range(xc_handle, dom, 
    4.27 -                              PAGE_SIZE, PROT_READ, 
    4.28 -                              live_shinfo->arch.pfn_to_mfn_frame_list );
    4.29 +	xc_map_foreign_batch(xc_handle, dom, 
    4.30 +			     PROT_READ,
    4.31 +			     live_pfn_to_mfn_frame_list_list,
    4.32 +			     (nr_pfns+(1024*1024)-1)/(1024*1024) );
    4.33  
    4.34      if (!live_pfn_to_mfn_frame_list){
    4.35          ERR("Couldn't map pfn_to_mfn_frame_list");
     5.1 --- a/xen/include/public/arch-x86_32.h	Tue Sep 06 18:29:53 2005 +0000
     5.2 +++ b/xen/include/public/arch-x86_32.h	Wed Sep 07 02:31:24 2005 +0000
     5.3 @@ -128,8 +128,11 @@ typedef struct vcpu_guest_context {
     5.4  } vcpu_guest_context_t;
     5.5  
     5.6  typedef struct arch_shared_info {
     5.7 -    /* MFN of a table of MFNs that make up p2m table */
     5.8 -    u64 pfn_to_mfn_frame_list;
     5.9 +    unsigned long max_pfn;                  /* max pfn that appears in table */
    5.10 +    unsigned long pfn_to_mfn_frame_list_list; 
    5.11 +                                            /* frame containing list of mfns
    5.12 +					       containing list of mfns 
    5.13 +					       containing the p2m table. */
    5.14  } arch_shared_info_t;
    5.15  
    5.16  #endif
     6.1 --- a/xen/include/public/arch-x86_64.h	Tue Sep 06 18:29:53 2005 +0000
     6.2 +++ b/xen/include/public/arch-x86_64.h	Wed Sep 07 02:31:24 2005 +0000
     6.3 @@ -186,8 +186,11 @@ typedef struct vcpu_guest_context {
     6.4  } vcpu_guest_context_t;
     6.5  
     6.6  typedef struct arch_shared_info {
     6.7 -    /* MFN of a table of MFNs that make up p2m table */
     6.8 -    u64 pfn_to_mfn_frame_list;
     6.9 +    unsigned long max_pfn;                  /* max pfn that appears in table */
    6.10 +    unsigned long pfn_to_mfn_frame_list_list; 
    6.11 +                                            /* frame containing list of mfns
    6.12 +					       containing list of mfns 
    6.13 +					       containing the p2m table. */
    6.14  } arch_shared_info_t;
    6.15  
    6.16  #endif /* !__ASSEMBLY__ */