direct-io.hg

changeset 9392:695aa28b7cb1

[IA64] Fixed VTI domain destruction

This patch fixed the VTI domain destruction processing.
I tested creation/destruction domU. The "domU" which I tested is
VTI domain and non VTI domain. There was not the memory leak
issue, and VTI domain is not left in a zombie state.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Wed Mar 22 08:57:48 2006 -0700 (2006-03-22)
parents 369bdeb29606
children b2828004f131
files xen/arch/ia64/vmx/vmmu.c xen/arch/ia64/vmx/vmx_init.c xen/arch/ia64/xen/dom0_ops.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	Wed Mar 22 08:53:20 2006 -0700
     1.2 +++ b/xen/arch/ia64/vmx/vmmu.c	Wed Mar 22 08:57:48 2006 -0700
     1.3 @@ -185,6 +185,20 @@ thash_cb_t *init_domain_tlb(struct vcpu 
     1.4      return tlb;
     1.5  }
     1.6  
     1.7 +void free_domain_tlb(struct vcpu *v)
     1.8 +{
     1.9 +    struct page_info *page;
    1.10 +    void *vhptbase;
    1.11 +    thash_cb_t *tlb;
    1.12 +
    1.13 +    if ( v->arch.vtlb ) {
    1.14 +        tlb = v->arch.vtlb;
    1.15 +        vhptbase = (void*)((u64)tlb + sizeof (thash_cb_t)) - VCPU_VHPT_SIZE;
    1.16 +        page = virt_to_page(vhptbase);
    1.17 +        free_domheap_pages(page, VCPU_VHPT_ORDER);
    1.18 +    }
    1.19 +}
    1.20 +
    1.21  /*
    1.22   * Insert guest TLB to machine TLB.
    1.23   *  data:   In TLB format
     2.1 --- a/xen/arch/ia64/vmx/vmx_init.c	Wed Mar 22 08:53:20 2006 -0700
     2.2 +++ b/xen/arch/ia64/vmx/vmx_init.c	Wed Mar 22 08:57:48 2006 -0700
     2.3 @@ -186,6 +186,13 @@ static vpd_t *alloc_vpd(void)
     2.4  	return vpd;
     2.5  }
     2.6  
     2.7 +/* Free vpd to xenheap */
     2.8 +static void
     2.9 +free_vpd(struct vcpu *v)
    2.10 +{
    2.11 +	if ( v->arch.privregs )
    2.12 +		free_xenheap_pages(v->arch.privregs, get_order(VPD_SIZE));
    2.13 +}
    2.14  
    2.15  /*
    2.16   * Create a VP on intialized VMX environment.
    2.17 @@ -261,6 +268,8 @@ vmx_final_setup_guest(struct vcpu *v)
    2.18  {
    2.19  	vpd_t *vpd;
    2.20  
    2.21 +	free_xenheap_pages(v->arch.privregs, get_order(sizeof(mapped_regs_t)));
    2.22 +
    2.23  	vpd = alloc_vpd();
    2.24  	ASSERT(vpd);
    2.25  
    2.26 @@ -290,6 +299,17 @@ vmx_final_setup_guest(struct vcpu *v)
    2.27  	set_bit(ARCH_VMX_INTR_ASSIST, &v->arch.arch_vmx.flags);
    2.28  }
    2.29  
    2.30 +void
    2.31 +vmx_relinquish_vcpu_resources(struct vcpu *v)
    2.32 +{
    2.33 +	vtime_t *vtm = &(v->arch.arch_vmx.vtm);
    2.34 +
    2.35 +	kill_timer(&vtm->vtm_timer);
    2.36 +
    2.37 +	free_domain_tlb(v);
    2.38 +	free_vpd(v);
    2.39 +}
    2.40 +
    2.41  typedef struct io_range {
    2.42  	unsigned long start;
    2.43  	unsigned long size;
     3.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Wed Mar 22 08:53:20 2006 -0700
     3.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Wed Mar 22 08:57:48 2006 -0700
     3.3 @@ -174,8 +174,11 @@ long arch_do_dom0_op(dom0_op_t *op, GUES
     3.4               */
     3.5              if ( (op->u.getmemlist.max_pfns == -1UL) &&
     3.6                   !test_bit(ARCH_VMX_CONTIG_MEM,
     3.7 -                           &d->vcpu[0]->arch.arch_vmx.flags) )
     3.8 -                return vmx_alloc_contig_pages(d) ? (-ENOMEM) : 0;
     3.9 +                           &d->vcpu[0]->arch.arch_vmx.flags) ) {
    3.10 +                ret = (long) vmx_alloc_contig_pages(d);
    3.11 +                put_domain(d);
    3.12 +                return ret ? (-ENOMEM) : 0;
    3.13 +            }
    3.14  
    3.15              for ( i = start_page; i < (start_page + nr_pages); i++ )
    3.16              {
     4.1 --- a/xen/arch/ia64/xen/domain.c	Wed Mar 22 08:53:20 2006 -0700
     4.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Mar 22 08:57:48 2006 -0700
     4.3 @@ -211,8 +211,13 @@ struct vcpu *alloc_vcpu_struct(struct do
     4.4  
     4.5  void free_vcpu_struct(struct vcpu *v)
     4.6  {
     4.7 -	if (v->arch.privregs != NULL)
     4.8 -		free_xenheap_pages(v->arch.privregs, get_order(sizeof(mapped_regs_t)));
     4.9 +	if (VMX_DOMAIN(v))
    4.10 +		vmx_relinquish_vcpu_resources(v);
    4.11 +	else {
    4.12 +		if (v->arch.privregs != NULL)
    4.13 +			free_xenheap_pages(v->arch.privregs, get_order(sizeof(mapped_regs_t)));
    4.14 +	}
    4.15 +
    4.16  	free_xenheap_pages(v, KERNEL_STACK_SIZE_ORDER);
    4.17  }
    4.18  
     5.1 --- a/xen/include/asm-ia64/vmmu.h	Wed Mar 22 08:53:20 2006 -0700
     5.2 +++ b/xen/include/asm-ia64/vmmu.h	Wed Mar 22 08:57:48 2006 -0700
     5.3 @@ -373,6 +373,7 @@ extern void purge_machine_tc_by_domid(do
     5.4  extern void machine_tlb_insert(struct vcpu *d, thash_data_t *tlb);
     5.5  extern ia64_rr vmmu_get_rr(struct vcpu *vcpu, u64 va);
     5.6  extern thash_cb_t *init_domain_tlb(struct vcpu *d);
     5.7 +extern void free_domain_tlb(struct vcpu *v);
     5.8  extern thash_data_t * vsa_thash(PTA vpta, u64 va, u64 vrr, u64 *tag);
     5.9  extern thash_data_t * vhpt_lookup(u64 va);
    5.10  extern void machine_tlb_purge(u64 va, u64 ps);
     6.1 --- a/xen/include/asm-ia64/vmx.h	Wed Mar 22 08:53:20 2006 -0700
     6.2 +++ b/xen/include/asm-ia64/vmx.h	Wed Mar 22 08:57:48 2006 -0700
     6.3 @@ -51,7 +51,9 @@ extern void set_ifa_itir_iha (struct vcp
     6.4  extern void inject_guest_interruption(struct vcpu *vcpu, u64 vec);
     6.5  extern void vmx_intr_assist(struct vcpu *v);
     6.6  extern void set_illegal_op_isr (struct vcpu *vcpu);
     6.7 -extern  void illegal_op (struct vcpu *vcpu);
     6.8 +extern void illegal_op (struct vcpu *vcpu);
     6.9 +extern void vmx_relinquish_vcpu_resources(struct vcpu *v);
    6.10 +
    6.11  static inline vcpu_iodata_t *get_vio(struct domain *d, unsigned long cpu)
    6.12  {
    6.13      return &((shared_iopage_t *)d->arch.vmx_platform.shared_page_va)->vcpu_iodata[cpu];