ia64/xen-unstable

changeset 13467:9576f09c9eff

[IA64] Avoid dom0 insufficient memory panic when creating guests

When there is not enough memory to create a domain,
we need not panic domain0. Just prevent it from creating.

Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
author awilliam@xenbuild2.aw
date Tue Jan 23 09:08:03 2007 -0700 (2007-01-23)
parents b3c79bad5de0
children 8bfc6e85eeba
files xen/arch/ia64/vmx/vmmu.c xen/arch/ia64/vmx/vmx_init.c xen/arch/ia64/xen/domain.c xen/include/asm-ia64/vmmu.h xen/include/asm-ia64/vmx.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmmu.c	Tue Jan 23 08:48:39 2007 -0700
     1.2 +++ b/xen/arch/ia64/vmx/vmmu.c	Tue Jan 23 09:08:03 2007 -0700
     1.3 @@ -129,13 +129,15 @@ purge_machine_tc_by_domid(domid_t domid)
     1.4  #endif
     1.5  }
     1.6  
     1.7 -static void init_domain_vhpt(struct vcpu *v)
     1.8 +static int init_domain_vhpt(struct vcpu *v)
     1.9  {
    1.10      struct page_info *page;
    1.11      void * vbase;
    1.12      page = alloc_domheap_pages (NULL, VCPU_VHPT_ORDER, 0);
    1.13      if ( page == NULL ) {
    1.14 -        panic_domain(vcpu_regs(v),"No enough contiguous memory for init_domain_vhpt\n");
    1.15 +        printk("No enough contiguous memory for init_domain_vhpt\n");
    1.16 +
    1.17 +        return -1;
    1.18      }
    1.19      vbase = page_to_virt(page);
    1.20      memset(vbase, 0, VCPU_VHPT_SIZE);
    1.21 @@ -147,18 +149,36 @@ static void init_domain_vhpt(struct vcpu
    1.22      VHPT(v,cch_sz) = VCPU_VHPT_SIZE - VHPT(v,hash_sz);
    1.23      thash_init(&(v->arch.vhpt),VCPU_VHPT_SHIFT-1);
    1.24      v->arch.arch_vmx.mpta = v->arch.vhpt.pta.val;
    1.25 +
    1.26 +    return 0;
    1.27  }
    1.28  
    1.29  
    1.30 +static void free_domain_vhpt(struct vcpu *v)
    1.31 +{
    1.32 +    struct page_info *page;
    1.33  
    1.34 -void init_domain_tlb(struct vcpu *v)
    1.35 +    if (v->arch.vhpt.hash) {
    1.36 +        page = virt_to_page(v->arch.vhpt.hash);
    1.37 +        free_domheap_pages(page, VCPU_VHPT_ORDER);
    1.38 +    }
    1.39 +
    1.40 +    return;
    1.41 +}
    1.42 +
    1.43 +int init_domain_tlb(struct vcpu *v)
    1.44  {
    1.45      struct page_info *page;
    1.46      void * vbase;
    1.47 -    init_domain_vhpt(v);
    1.48 +
    1.49 +    if (init_domain_vhpt(v) != 0)
    1.50 +        return -1;
    1.51 +
    1.52      page = alloc_domheap_pages (NULL, VCPU_VTLB_ORDER, 0);
    1.53      if ( page == NULL ) {
    1.54 -        panic_domain(vcpu_regs(v),"No enough contiguous memory for init_domain_tlb\n");
    1.55 +        printk("No enough contiguous memory for init_domain_tlb\n");
    1.56 +        free_domain_vhpt(v);
    1.57 +        return -1;
    1.58      }
    1.59      vbase = page_to_virt(page);
    1.60      memset(vbase, 0, VCPU_VTLB_SIZE);
    1.61 @@ -169,8 +189,11 @@ void init_domain_tlb(struct vcpu *v)
    1.62      VTLB(v,cch_buf) = (void *)((u64)vbase + VTLB(v,hash_sz));
    1.63      VTLB(v,cch_sz) = VCPU_VTLB_SIZE - VTLB(v,hash_sz);
    1.64      thash_init(&(v->arch.vtlb),VCPU_VTLB_SHIFT-1);
    1.65 +    
    1.66 +    return 0;
    1.67  }
    1.68  
    1.69 +
    1.70  void free_domain_tlb(struct vcpu *v)
    1.71  {
    1.72      struct page_info *page;
    1.73 @@ -179,10 +202,8 @@ void free_domain_tlb(struct vcpu *v)
    1.74          page = virt_to_page(v->arch.vtlb.hash);
    1.75          free_domheap_pages(page, VCPU_VTLB_ORDER);
    1.76      }
    1.77 -    if ( v->arch.vhpt.hash) {
    1.78 -        page = virt_to_page(v->arch.vhpt.hash);
    1.79 -        free_domheap_pages(page, VCPU_VHPT_ORDER);
    1.80 -    }
    1.81 +
    1.82 +    free_domain_vhpt(v);
    1.83  }
    1.84  
    1.85  /*
     2.1 --- a/xen/arch/ia64/vmx/vmx_init.c	Tue Jan 23 08:48:39 2007 -0700
     2.2 +++ b/xen/arch/ia64/vmx/vmx_init.c	Tue Jan 23 09:08:03 2007 -0700
     2.3 @@ -290,7 +290,7 @@ static void vmx_release_assist_channel(s
     2.4   * Initialize VMX envirenment for guest. Only the 1st vp/vcpu
     2.5   * is registered here.
     2.6   */
     2.7 -void
     2.8 +int
     2.9  vmx_final_setup_guest(struct vcpu *v)
    2.10  {
    2.11  	vpd_t *vpd;
    2.12 @@ -305,7 +305,8 @@ vmx_final_setup_guest(struct vcpu *v)
    2.13  	 * to this solution. Maybe it can be deferred until we know created
    2.14  	 * one as vmx domain */
    2.15  #ifndef HASH_VHPT
    2.16 -	init_domain_tlb(v);
    2.17 +	if (init_domain_tlb(v) != 0)
    2.18 +		return -1;
    2.19  #endif
    2.20  	vmx_create_event_channels(v);
    2.21  
    2.22 @@ -322,6 +323,8 @@ vmx_final_setup_guest(struct vcpu *v)
    2.23  
    2.24  	/* Set up guest 's indicator for VTi domain*/
    2.25  	set_bit(ARCH_VMX_DOMAIN, &v->arch.arch_vmx.flags);
    2.26 +
    2.27 +	return 0;
    2.28  }
    2.29  
    2.30  void
     3.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jan 23 08:48:39 2007 -0700
     3.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Jan 23 09:08:03 2007 -0700
     3.3 @@ -585,9 +585,11 @@ int arch_set_info_guest(struct vcpu *v, 
     3.4  	if (test_bit(_VCPUF_initialised, &v->vcpu_flags))
     3.5  		return 0;
     3.6  
     3.7 -	if (d->arch.is_vti)
     3.8 -		vmx_final_setup_guest(v);
     3.9 -	else {
    3.10 +	if (d->arch.is_vti) {
    3.11 +		rc = vmx_final_setup_guest(v);
    3.12 +		if (rc != 0)
    3.13 +			return rc;
    3.14 +	} else {
    3.15  		rc = vcpu_late_initialise(v);
    3.16  		if (rc != 0)
    3.17  			return rc;
     4.1 --- a/xen/include/asm-ia64/vmmu.h	Tue Jan 23 08:48:39 2007 -0700
     4.2 +++ b/xen/include/asm-ia64/vmmu.h	Tue Jan 23 09:08:03 2007 -0700
     4.3 @@ -295,7 +295,7 @@ extern u64 machine_thash(PTA pta, u64 va
     4.4  extern void purge_machine_tc_by_domid(domid_t domid);
     4.5  extern void machine_tlb_insert(struct vcpu *d, thash_data_t *tlb);
     4.6  extern ia64_rr vmmu_get_rr(struct vcpu *vcpu, u64 va);
     4.7 -extern void init_domain_tlb(struct vcpu *d);
     4.8 +extern int init_domain_tlb(struct vcpu *d);
     4.9  extern void free_domain_tlb(struct vcpu *v);
    4.10  extern thash_data_t * vsa_thash(PTA vpta, u64 va, u64 vrr, u64 *tag);
    4.11  extern thash_data_t * vhpt_lookup(u64 va);
     5.1 --- a/xen/include/asm-ia64/vmx.h	Tue Jan 23 08:48:39 2007 -0700
     5.2 +++ b/xen/include/asm-ia64/vmx.h	Tue Jan 23 09:08:03 2007 -0700
     5.3 @@ -31,7 +31,7 @@
     5.4  extern void identify_vmx_feature(void);
     5.5  extern unsigned int vmx_enabled;
     5.6  extern void vmx_init_env(void);
     5.7 -extern void vmx_final_setup_guest(struct vcpu *v);
     5.8 +extern int vmx_final_setup_guest(struct vcpu *v);
     5.9  extern void vmx_save_state(struct vcpu *v);
    5.10  extern void vmx_load_state(struct vcpu *v);
    5.11  extern void vmx_setup_platform(struct domain *d);