direct-io.hg

changeset 11443:af50fb41612c

[IA64] Expand memory_op for PV-on-HVM on IPF

Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Fri Sep 01 08:46:02 2006 -0600 (2006-09-01)
parents 586c5fe8cf3e
children 2f3db1a38b11
files xen/arch/ia64/xen/mm.c xen/arch/ia64/xen/vhpt.c
line diff
     1.1 --- a/xen/arch/ia64/xen/mm.c	Tue Aug 29 09:08:29 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/mm.c	Fri Sep 01 08:46:02 2006 -0600
     1.3 @@ -173,6 +173,9 @@
     1.4  #include <asm/vcpu.h>
     1.5  #include <asm/shadow.h>
     1.6  #include <linux/efi.h>
     1.7 +#include <xen/guest_access.h>
     1.8 +#include <asm/page.h>
     1.9 +#include <public/memory.h>
    1.10  
    1.11  static void domain_page_flush(struct domain* d, unsigned long mpaddr,
    1.12                                unsigned long old_mfn, unsigned long new_mfn);
    1.13 @@ -1752,6 +1755,83 @@ int memory_is_conventional_ram(paddr_t p
    1.14      return (efi_mem_type(p) == EFI_CONVENTIONAL_MEMORY);
    1.15  }
    1.16  
    1.17 +
    1.18 +long
    1.19 +arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
    1.20 +{
    1.21 +    switch (op) {
    1.22 +    case XENMEM_add_to_physmap:
    1.23 +    {
    1.24 +        struct xen_add_to_physmap xatp;
    1.25 +        unsigned long prev_mfn, mfn = 0, gpfn;
    1.26 +        struct domain *d;
    1.27 +
    1.28 +        if (copy_from_guest(&xatp, arg, 1))
    1.29 +            return -EFAULT;
    1.30 +
    1.31 +        if (xatp.domid == DOMID_SELF) {
    1.32 +            d = current->domain;
    1.33 +            get_knownalive_domain(d);
    1.34 +        }
    1.35 +        else if (!IS_PRIV(current->domain))
    1.36 +            return -EPERM;
    1.37 +        else if ((d = find_domain_by_id(xatp.domid)) == NULL)
    1.38 +            return -ESRCH;
    1.39 +
    1.40 +        /* This hypercall is used for VT-i domain only */
    1.41 +        if (!VMX_DOMAIN(d->vcpu[0])) {
    1.42 +            put_domain(d);
    1.43 +            return -ENOSYS;
    1.44 +        }
    1.45 +
    1.46 +        switch (xatp.space) {
    1.47 +        case XENMAPSPACE_shared_info:
    1.48 +            if (xatp.idx == 0)
    1.49 +                mfn = virt_to_mfn(d->shared_info);
    1.50 +            break;
    1.51 +        case XENMAPSPACE_grant_table:
    1.52 +            if (xatp.idx < NR_GRANT_FRAMES)
    1.53 +                mfn = virt_to_mfn(d->grant_table->shared) + xatp.idx;
    1.54 +            break;
    1.55 +        default:
    1.56 +            break;
    1.57 +        }
    1.58 +
    1.59 +        LOCK_BIGLOCK(d);
    1.60 +
    1.61 +        /* Remove previously mapped page if it was present. */
    1.62 +        prev_mfn = gmfn_to_mfn(d, xatp.gpfn);
    1.63 +        if (prev_mfn && mfn_valid(prev_mfn)) {
    1.64 +            if (IS_XEN_HEAP_FRAME(mfn_to_page(prev_mfn)))
    1.65 +                /* Xen heap frames are simply unhooked from this phys slot. */
    1.66 +                guest_physmap_remove_page(d, xatp.gpfn, prev_mfn);
    1.67 +            else
    1.68 +                /* Normal domain memory is freed, to avoid leaking memory. */
    1.69 +                guest_remove_page(d, xatp.gpfn);
    1.70 +        }
    1.71 +
    1.72 +        /* Unmap from old location, if any. */
    1.73 +        gpfn = get_gpfn_from_mfn(mfn);
    1.74 +        if (gpfn != INVALID_M2P_ENTRY)
    1.75 +            guest_physmap_remove_page(d, gpfn, mfn);
    1.76 +
    1.77 +        /* Map at new location. */
    1.78 +        guest_physmap_add_page(d, xatp.gpfn, mfn);
    1.79 +
    1.80 +        UNLOCK_BIGLOCK(d);
    1.81 +        
    1.82 +        put_domain(d);
    1.83 +
    1.84 +        break;
    1.85 +    }
    1.86 +
    1.87 +    default:
    1.88 +        return -ENOSYS;
    1.89 +    }
    1.90 +
    1.91 +    return 0;
    1.92 +}
    1.93 +
    1.94  /*
    1.95   * Local variables:
    1.96   * mode: C
     2.1 --- a/xen/arch/ia64/xen/vhpt.c	Tue Aug 29 09:08:29 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/vhpt.c	Fri Sep 01 08:46:02 2006 -0600
     2.3 @@ -14,6 +14,7 @@
     2.4  #include <asm/page.h>
     2.5  #include <asm/vhpt.h>
     2.6  #include <asm/vcpu.h>
     2.7 +#include <asm/vmmu.h>
     2.8  
     2.9  /* Defined in tlb.c  */
    2.10  extern void ia64_global_tlb_purge(UINT64 start, UINT64 end, UINT64 nbits);
    2.11 @@ -131,15 +132,25 @@ void vhpt_init(void)
    2.12  
    2.13  void vcpu_flush_vtlb_all(struct vcpu *v)
    2.14  {
    2.15 -	/* First VCPU tlb.  */
    2.16 -	vcpu_purge_tr_entry(&PSCBX(v,dtlb));
    2.17 -	vcpu_purge_tr_entry(&PSCBX(v,itlb));
    2.18 +	if (VMX_DOMAIN(v)) {
    2.19 +		/* This code may be call for remapping shared_info and
    2.20 +		   grant_table share page from guest_physmap_remove_page()
    2.21 +		   in arch_memory_op() XENMEM_add_to_physmap to realize
    2.22 +		   PV-on-HVM feature. */
    2.23 +		/* Purge vTLB for VT-i domain */
    2.24 +		thash_purge_all(v);
    2.25 +	}
    2.26 +	else {
    2.27 +		/* First VCPU tlb.  */
    2.28 +		vcpu_purge_tr_entry(&PSCBX(v,dtlb));
    2.29 +		vcpu_purge_tr_entry(&PSCBX(v,itlb));
    2.30  
    2.31 -	/* Then VHPT.  */
    2.32 -	vhpt_flush ();
    2.33 +		/* Then VHPT.  */
    2.34 +		vhpt_flush();
    2.35  
    2.36 -	/* Then mTLB.  */
    2.37 -	local_flush_tlb_all ();
    2.38 +		/* Then mTLB.  */
    2.39 +		local_flush_tlb_all();
    2.40 +	}
    2.41  
    2.42  	/* We could clear bit in d->domain_dirty_cpumask only if domain d in
    2.43  	   not running on this processor.  There is currently no easy way to