WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] PV-on-HVM for IPF (take 3)

To: xen-ia64-devel <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-ia64-devel] PV-on-HVM for IPF (take 3)
From: DOI Tsunehisa <Doi.Tsunehisa@xxxxxxxxxxxxxx>
Date: Tue, 29 Aug 2006 20:50:47 +0900
Delivery-date: Tue, 29 Aug 2006 05:04:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)
Hi all,

  We have been porting PV-on-HVM feature for ia64 platform.

  I will post patches for PV-on-HVM on ia64 platform. These patches modify
common code for PV-on-HVM on IPF.

  We ported PV-on-HVM for IPF under this consideration:

   * Expand memory_op hypercall
     + Introduce XENMEM_add_to_physmap
       - A virtual space allocated on HVM-guest OS is remapped original
         shared_info and grant_table page with this hypercall.
       - This method is same as x86 method.
   * Reduce hvm_op hypercall
     + Delete functions introduced for old PV-on-HVM on IPF.
   * Revert domain destroy logic
     + revert arch_domain_destroy() for old PV-on-HVM on IPF.
   * Modify unmodified_drivers initialization
     + cut off unused codes for IPF
     + modify build rule for IPF

  These patch include: (ia64 specific code)

   * expand-memory-op.patch
     - introduce XENMEM_add_to_physmap feature for PV-on-HVM on IPF
   * reduce-hvmop.patch
     - reduce hvm_op hypercall for old PV-on-HVM on IPF
   * revert-destroy.patch
     - revert arch_domain_destory() for old PV-on-HVM on IPF

  We have tested that this patch doesn't affect dom0, domVTi without
pv-on-hvm driver attaching, and domVTi using pv-on-hvm driver works
VBD/VNIF on IPF.

Thanks,
- Tsunehisa Doi
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 127e7a6c9f5636aea69d47bdeae0b938ea0d2d88
# Parent  684fdcfb251a443fa885c142b427d253ec033212
Reduce HYPERVISOR_hvmop for IPF

Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@xxxxxxxxxxxxxx>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@xxxxxxxxxxxxxx>

diff -r 684fdcfb251a -r 127e7a6c9f56 xen/arch/ia64/vmx/vmx_hypercall.c
--- a/xen/arch/ia64/vmx/vmx_hypercall.c Mon Aug 28 16:26:37 2006 -0600
+++ b/xen/arch/ia64/vmx/vmx_hypercall.c Tue Aug 29 18:31:43 2006 +0900
@@ -37,91 +37,6 @@
 #include <public/version.h>
 #include <asm/dom_fw.h>
 #include <xen/domain.h>
-#include <xen/compile.h>
-#include <xen/event.h>
-
-static void
-vmx_free_pages(unsigned long pgaddr, int npg)
-{
-    for (; npg > 0; npg--, pgaddr += PAGE_SIZE) {
-        /* If original page belongs to xen heap, then relinguish back
-         * to xen heap. Or else, leave to domain itself to decide.
-         */
-        if (likely(IS_XEN_HEAP_FRAME(virt_to_page(pgaddr)))) {
-            free_domheap_page(virt_to_page(pgaddr));
-            free_xenheap_page((void *)pgaddr);
-        }
-        else {
-            put_page(virt_to_page(pgaddr));
-        }
-    }
-}
-
-static int
-vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames)
-{
-    struct domain *d = current->domain;
-    struct grant_entry *pgaddr;
-    unsigned long o_grant_shared;
-
-    if ((nr_frames != NR_GRANT_FRAMES) || (frame_pa & (PAGE_SIZE - 1))) {
-        return -EINVAL;
-    }
-
-    pgaddr = domain_mpa_to_imva(d, frame_pa);
-    if (pgaddr == NULL) {
-        return -EFAULT;
-    }
-
-    o_grant_shared = (unsigned long)d->grant_table->shared;
-    d->grant_table->shared = pgaddr;
-
-    /* Copy existing grant table into new page */
-    if (o_grant_shared) {
-        memcpy((void *)d->grant_table->shared,
-               (void *)o_grant_shared, PAGE_SIZE * nr_frames);
-        vmx_free_pages(o_grant_shared, nr_frames);
-    }
-    else {
-        memset((void *)d->grant_table->shared, 0, PAGE_SIZE * nr_frames);
-    }
-    return 0;
-}
-
-static int
-vmx_setup_shared_info_page(unsigned long gpa)
-{
-    VCPU *vcpu = current;
-    struct domain *d = vcpu->domain;
-    unsigned long o_info;
-    shared_info_t *pgaddr;
-    struct vcpu *v;
-
-    if (gpa & ~PAGE_MASK) {
-        return -EINVAL;
-    }
-
-    pgaddr = domain_mpa_to_imva(d, gpa);
-    if (pgaddr == NULL) {
-        return -EFAULT;
-    }
-
-    o_info = (u64)d->shared_info;
-    d->shared_info = pgaddr;
-
-    /* Copy existing shared info into new page */
-    if (o_info) {
-        memcpy((void*)d->shared_info, (void*)o_info, PAGE_SIZE);
-        for_each_vcpu(d, v) {
-            v->vcpu_info = &d->shared_info->vcpu_info[v->vcpu_id];
-        }
-        vmx_free_pages(o_info, 1);
-    }
-    else {
-        memset((void *)d->shared_info, 0, PAGE_SIZE);
-    }
-    return 0;
-}
 
 long
 do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
@@ -166,25 +81,6 @@ do_hvm_op(unsigned long op, XEN_GUEST_HA
         break;
     }
 
-    case HVMOP_setup_gnttab_table:
-    case HVMOP_setup_shared_info_page:
-    {
-        struct xen_hvm_setup a;
-
-        if (copy_from_guest(&a, arg, 1))
-            return -EFAULT;
-
-        switch (op) {
-        case HVMOP_setup_gnttab_table:
-            printk("vmx_gnttab_setup_table: frame_pa=%#lx,"
-                            "nr_frame=%ld\n", a.arg1, a.arg2);
-            return vmx_gnttab_setup_table(a.arg1, a.arg2);
-        case HVMOP_setup_shared_info_page:
-            printk("vmx_setup_shared_info_page: gpa=0x%lx\n", a.arg1);
-            return vmx_setup_shared_info_page(a.arg1);
-        }
-    }
-
     default:
         DPRINTK("Bad HVM op %ld.\n", op);
         rc = -ENOSYS;
diff -r 684fdcfb251a -r 127e7a6c9f56 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Mon Aug 28 16:26:37 2006 -0600
+++ b/xen/include/public/arch-ia64.h    Tue Aug 29 18:31:43 2006 +0900
@@ -338,17 +338,6 @@ struct vcpu_guest_context {
 };
 typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
-
-// hvm_op expansion
-#define HVMOP_setup_gnttab_table        2
-#define HVMOP_setup_shared_info_page    3
-
-struct xen_hvm_setup {
-    unsigned long arg1;
-    unsigned long arg2;
-};
-typedef struct xen_hvm_setup xen_hvm_setup_t;
-DEFINE_XEN_GUEST_HANDLE(xen_hvm_setup_t);
 
 // dom0 vp op
 #define __HYPERVISOR_ia64_dom0vp_op     __HYPERVISOR_arch_0
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 62b5720142e6b19420977f139a09a1c8eea63a52
# Parent  127e7a6c9f5636aea69d47bdeae0b938ea0d2d88
Revert arch_domain_destroy for old PV-on-HVM

Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@xxxxxxxxxxxxxx>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@xxxxxxxxxxxxxx>

diff -r 127e7a6c9f56 -r 62b5720142e6 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Aug 29 18:31:43 2006 +0900
+++ b/xen/arch/ia64/xen/domain.c        Tue Aug 29 18:33:29 2006 +0900
@@ -400,16 +400,9 @@ void arch_domain_destroy(struct domain *
 void arch_domain_destroy(struct domain *d)
 {
        BUG_ON(d->arch.mm.pgd != NULL);
-       if (d->shared_info != NULL) {
-               /* If this domain is domVTi, the shared_info page may
-                * be replaced with domheap. Then the shared_info page
-                * frees in relinquish_mm().
-                */
-               if (IS_XEN_HEAP_FRAME(virt_to_page(d->shared_info))) {
-                       free_xenheap_pages(d->shared_info,
-                                          get_order_from_shift(XSI_SHIFT));
-               }
-       }
+       if (d->shared_info != NULL)
+               free_xenheap_pages(d->shared_info,
+                               get_order_from_shift(XSI_SHIFT));
        if (d->arch.shadow_bitmap != NULL)
                xfree(d->arch.shadow_bitmap);
 
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 259aea558618ad79219d838dcb520142a5f04897
# Parent  62b5720142e6b19420977f139a09a1c8eea63a52
Expand memory_op for PV-on-HVM on IPF

Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@xxxxxxxxxxxxxx>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@xxxxxxxxxxxxxx>

diff -r 62b5720142e6 -r 259aea558618 xen/arch/ia64/xen/mm.c
--- a/xen/arch/ia64/xen/mm.c    Tue Aug 29 18:33:29 2006 +0900
+++ b/xen/arch/ia64/xen/mm.c    Tue Aug 29 18:42:04 2006 +0900
@@ -173,6 +173,9 @@
 #include <asm/vcpu.h>
 #include <asm/shadow.h>
 #include <linux/efi.h>
+#include <xen/guest_access.h>
+#include <asm/page.h>
+#include <public/memory.h>
 
 static void domain_page_flush(struct domain* d, unsigned long mpaddr,
                               unsigned long old_mfn, unsigned long new_mfn);
@@ -1752,6 +1755,82 @@ int memory_is_conventional_ram(paddr_t p
     return (efi_mem_type(p) == EFI_CONVENTIONAL_MEMORY);
 }
 
+
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
+{
+    switch (op) {
+    case XENMEM_add_to_physmap:
+    {
+        struct xen_add_to_physmap xatp;
+        unsigned long prev_mfn, mfn = 0, gpfn;
+        struct domain *d;
+
+        if (copy_from_guest(&xatp, arg, 1))
+            return -EFAULT;
+
+        if (xatp.domid == DOMID_SELF) {
+            d = current->domain;
+            get_knownalive_domain(d);
+        }
+        else if (!IS_PRIV(current->domain))
+            return -EPERM;
+        else if ((d = find_domain_by_id(xatp.domid)) == NULL)
+            return -ESRCH;
+
+        /* This hypercall is used for VT-i domain only */
+        if (!VMX_DOMAIN(d->vcpu[0])) {
+            put_domain(d);
+            return -ENOSYS;
+        }
+
+        switch (xatp.space) {
+        case XENMAPSPACE_shared_info:
+            if (xatp.idx == 0)
+                mfn = virt_to_mfn(d->shared_info);
+            break;
+        case XENMAPSPACE_grant_table:
+            if (xatp.idx < NR_GRANT_FRAMES)
+                mfn = virt_to_mfn(d->grant_table->shared) + xatp.idx;
+            break;
+        default:
+            break;
+        }
+
+        LOCK_BIGLOCK(d);
+
+        /* Remove previously mapped page if it was present. */
+        prev_mfn = gmfn_to_mfn(d, xatp.gpfn);
+        if (prev_mfn && mfn_valid(prev_mfn)) {
+            if (IS_XEN_HEAP_FRAME(mfn_to_page(prev_mfn)))
+                /* Xen heap frames are simply unhooked from this phys slot. */
+                guest_physmap_remove_page(d, xatp.gpfn, prev_mfn);
+            else
+                /* Normal domain memory is freed, to avoid leaking memory. */
+                guest_remove_page(d, xatp.gpfn);
+        }
+
+        /* Unmap from old location, if any. */
+        gpfn = get_gpfn_from_mfn(mfn);
+        if (gpfn != INVALID_M2P_ENTRY)
+            guest_physmap_remove_page(d, gpfn, mfn);
+
+        /* Map at new location. */
+        guest_physmap_add_page(d, xatp.gpfn, mfn);
+
+        UNLOCK_BIGLOCK(d);
+        
+        put_domain(d);
+
+        break;
+    }
+
+    default:
+        return -ENOSYS;
+    }
+
+    return 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 62b5720142e6 -r 259aea558618 xen/arch/ia64/xen/vhpt.c
--- a/xen/arch/ia64/xen/vhpt.c  Tue Aug 29 18:33:29 2006 +0900
+++ b/xen/arch/ia64/xen/vhpt.c  Tue Aug 29 18:42:04 2006 +0900
@@ -14,6 +14,7 @@
 #include <asm/page.h>
 #include <asm/vhpt.h>
 #include <asm/vcpu.h>
+#include <asm/vmmu.h>
 
 /* Defined in tlb.c  */
 extern void ia64_global_tlb_purge(UINT64 start, UINT64 end, UINT64 nbits);
@@ -131,15 +132,21 @@ void vhpt_init(void)
 
 void vcpu_flush_vtlb_all(struct vcpu *v)
 {
-       /* First VCPU tlb.  */
-       vcpu_purge_tr_entry(&PSCBX(v,dtlb));
-       vcpu_purge_tr_entry(&PSCBX(v,itlb));
-
-       /* Then VHPT.  */
-       vhpt_flush ();
-
-       /* Then mTLB.  */
-       local_flush_tlb_all ();
+       if (VMX_DOMAIN(v)) {
+               /* Purge vTLB for VT-i domain */
+               thash_purge_all(v);
+       }
+       else {
+               /* First VCPU tlb.  */
+               vcpu_purge_tr_entry(&PSCBX(v,dtlb));
+               vcpu_purge_tr_entry(&PSCBX(v,itlb));
+
+               /* Then VHPT.  */
+               vhpt_flush ();
+
+               /* Then mTLB.  */
+               local_flush_tlb_all ();
+       }
 
        /* We could clear bit in d->domain_dirty_cpumask only if domain d in
           not running on this processor.  There is currently no easy way to
diff -r 62b5720142e6 -r 259aea558618 xen/include/asm-ia64/mm.h
--- a/xen/include/asm-ia64/mm.h Tue Aug 29 18:33:29 2006 +0900
+++ b/xen/include/asm-ia64/mm.h Tue Aug 29 18:42:04 2006 +0900
@@ -495,7 +495,7 @@ extern u64 translate_domain_pte(u64 ptev
     ((gmfn_to_mfn((_d),(gpa)>>PAGE_SHIFT)<<PAGE_SHIFT)|((gpa)&~PAGE_MASK))
 
 /* Arch-specific portion of memory_op hypercall. */
-#define arch_memory_op(op, arg) (-ENOSYS)
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
 
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags);
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>