ia64/xen-unstable

changeset 16786:a739d3edc185

[IA64] domheap: Allocate vm buffer before boot allocator

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents af3550f53874
children a1288419288e
files xen/arch/ia64/linux-xen/setup.c xen/arch/ia64/vmx/vmx_init.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/vmx.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/setup.c	Thu Jan 17 12:05:43 2008 -0700
     1.2 +++ b/xen/arch/ia64/linux-xen/setup.c	Thu Jan 17 12:05:43 2008 -0700
     1.3 @@ -561,10 +561,10 @@ late_setup_arch (char **cmdline_p)
     1.4  #endif
     1.5  #ifndef XEN
     1.6  	find_memory();
     1.7 -#endif
     1.8  
     1.9  	/* process SAL system table: */
    1.10  	ia64_sal_init(efi.sal_systab);
    1.11 +#endif
    1.12  
    1.13  #ifdef CONFIG_SMP
    1.14  #ifdef XEN
    1.15 @@ -587,10 +587,6 @@ late_setup_arch (char **cmdline_p)
    1.16  		       smp_num_siblings);
    1.17  #endif
    1.18  
    1.19 -#ifdef XEN
    1.20 -	identify_vmx_feature();
    1.21 -#endif
    1.22 -
    1.23  	cpu_init();	/* initialize the bootstrap CPU */
    1.24  
    1.25  #ifdef CONFIG_ACPI_BOOT
    1.26 @@ -803,12 +799,6 @@ identify_cpu (struct cpuinfo_ia64 *c)
    1.27  	}
    1.28  	c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1));
    1.29  	c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
    1.30 -
    1.31 -#ifdef XEN
    1.32 -	/* If vmx feature is on, do necessary initialization for vmx */
    1.33 -	if (vmx_enabled)
    1.34 -		vmx_init_env();
    1.35 -#endif
    1.36  }
    1.37  
    1.38  void
     2.1 --- a/xen/arch/ia64/vmx/vmx_init.c	Thu Jan 17 12:05:43 2008 -0700
     2.2 +++ b/xen/arch/ia64/vmx/vmx_init.c	Thu Jan 17 12:05:43 2008 -0700
     2.3 @@ -56,7 +56,6 @@
     2.4  
     2.5  /* Global flag to identify whether Intel vmx feature is on */
     2.6  u32 vmx_enabled = 0;
     2.7 -static u32 vm_order;
     2.8  static u64 buffer_size;
     2.9  static u64 vp_env_info;
    2.10  static u64 vm_buffer = 0;	/* Buffer required to bring up VMX feature */
    2.11 @@ -97,8 +96,7 @@ identify_vmx_feature(void)
    2.12  	/* Does xen has ability to decode itself? */
    2.13  	if (!(vp_env_info & VP_OPCODE))
    2.14  		printk("WARNING: no opcode provided from hardware(%lx)!!!\n", vp_env_info);
    2.15 -	vm_order = get_order(buffer_size);
    2.16 -	printk("vm buffer size: %ld, order: %d\n", buffer_size, vm_order);
    2.17 +	printk("vm buffer size: %ld\n", buffer_size);
    2.18  
    2.19  	vmx_enabled = 1;
    2.20  no_vti:
    2.21 @@ -110,16 +108,33 @@ no_vti:
    2.22   * vsa_base is the indicator whether it's first LP to be initialized
    2.23   * for current domain.
    2.24   */ 
    2.25 -void
    2.26 -vmx_init_env(void)
    2.27 +void*
    2.28 +vmx_init_env(void *start, unsigned long end_in_pa)
    2.29  {
    2.30  	u64 status, tmp_base;
    2.31  
    2.32  	if (!vm_buffer) {
    2.33 -		vm_buffer = (unsigned long)alloc_xenheap_pages(vm_order);
    2.34 -		ASSERT(vm_buffer);
    2.35 -		vm_buffer = virt_to_xenva((vm_buffer));
    2.36 -		printk("vm_buffer: 0x%lx\n", vm_buffer);
    2.37 +		/* VM buffer must must be 4K aligned and 
    2.38 +		 * must be pinned by both itr and dtr. */
    2.39 +#define VM_BUFFER_ALIGN		(4 * 1024)
    2.40 +#define VM_BUFFER_ALIGN_UP(x)	(((x) + (VM_BUFFER_ALIGN - 1)) &    \
    2.41 +                                 ~(VM_BUFFER_ALIGN - 1))
    2.42 +		unsigned long s_vm_buffer =
    2.43 +			VM_BUFFER_ALIGN_UP((unsigned long)start);
    2.44 +		unsigned long e_vm_buffer = s_vm_buffer + buffer_size;
    2.45 +		if (__pa(e_vm_buffer) < end_in_pa) {
    2.46 +			init_xenheap_pages(__pa(start), __pa(s_vm_buffer));
    2.47 +			start = (void*)e_vm_buffer;
    2.48 +			vm_buffer = virt_to_xenva(s_vm_buffer);
    2.49 +			printk("vm_buffer: 0x%lx\n", vm_buffer);
    2.50 +		} else {
    2.51 +			printk("Can't allocate vm_buffer "
    2.52 +			       "start 0x%p end_in_pa 0x%lx "
    2.53 +			       "buffer_size 0x%lx\n",
    2.54 +			       start, end_in_pa, buffer_size);
    2.55 +			vmx_enabled = 0;
    2.56 +			return start;
    2.57 +		}
    2.58  	}
    2.59  
    2.60  	status=ia64_pal_vp_init_env(__vsa_base ? VP_INIT_ENV : VP_INIT_ENV_INITALIZE,
    2.61 @@ -129,7 +144,8 @@ vmx_init_env(void)
    2.62  
    2.63  	if (status != PAL_STATUS_SUCCESS) {
    2.64  		printk("ia64_pal_vp_init_env failed.\n");
    2.65 -		return ;
    2.66 +		vmx_enabled = 0;
    2.67 +		return start;
    2.68  	}
    2.69  
    2.70  	if (!__vsa_base)
    2.71 @@ -137,6 +153,7 @@ vmx_init_env(void)
    2.72  	else
    2.73  		ASSERT(tmp_base == __vsa_base);
    2.74  
    2.75 +	return start;
    2.76  }
    2.77  
    2.78  typedef union {
     3.1 --- a/xen/arch/ia64/xen/xensetup.c	Thu Jan 17 12:05:43 2008 -0700
     3.2 +++ b/xen/arch/ia64/xen/xensetup.c	Thu Jan 17 12:05:43 2008 -0700
     3.3 @@ -30,6 +30,7 @@
     3.4  #include <xen/rcupdate.h>
     3.5  #include <xsm/acm/acm_hooks.h>
     3.6  #include <asm/sn/simulator.h>
     3.7 +#include <linux/asm/sal.h>
     3.8  
     3.9  unsigned long xenheap_phys_end, total_pages;
    3.10  
    3.11 @@ -456,6 +457,16 @@ void __init start_kernel(void)
    3.12  
    3.13      trap_init();
    3.14  
    3.15 +    /* process SAL system table */
    3.16 +    /* must be before any pal/sal call */
    3.17 +    ia64_sal_init(efi.sal_systab);
    3.18 +
    3.19 +    /* early_setup_arch() maps PAL code. */
    3.20 +    identify_vmx_feature();
    3.21 +    /* If vmx feature is on, do necessary initialization for vmx */
    3.22 +    if (vmx_enabled)
    3.23 +        xen_heap_start = vmx_init_env(xen_heap_start, xenheap_phys_end);
    3.24 +
    3.25      init_xenheap_pages(__pa(xen_heap_start), xenheap_phys_end);
    3.26      printk("Xen heap: %luMB (%lukB)\n",
    3.27  	(xenheap_phys_end-__pa(xen_heap_start)) >> 20,
     4.1 --- a/xen/include/asm-ia64/vmx.h	Thu Jan 17 12:05:43 2008 -0700
     4.2 +++ b/xen/include/asm-ia64/vmx.h	Thu Jan 17 12:05:43 2008 -0700
     4.3 @@ -29,7 +29,7 @@
     4.4  
     4.5  extern void identify_vmx_feature(void);
     4.6  extern unsigned int vmx_enabled;
     4.7 -extern void vmx_init_env(void);
     4.8 +extern void *vmx_init_env(void *start, unsigned long end_in_pa);
     4.9  extern int vmx_final_setup_guest(struct vcpu *v);
    4.10  extern void vmx_save_state(struct vcpu *v);
    4.11  extern void vmx_load_state(struct vcpu *v);