[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-ia64-devel] PV-on-HVM driver for IPF



Hi all,

  I will post patches of PV-on-HVM for IPF.

  We wrote the patch under this consideration:

   * Expand hvm_op hypercall
     + Introduce HVMOP_setup_shared_info_page
       - A page allocated on HVM-guest OS is swapped original shared_info
         page with this hypercall.
       - In x86 code, original shared_info page is used after pv-on-hvm
         setup with remapping feature in arch depend HYPERVISOR_memory_op.
         But, we can't implement same feature for IPF, thus we select to
         implement with this method.
     + Introduce HVMOP_setup_gnttab_table
       - Pages allocated on HVM-guest OS is swapped original grant_table
         page frames with this hypercall.
       - Same above.
   * Change domain destroy logic
     + arch_domain_destroy() changed
       - considered for swapping shared_info page.
     + grant_table_destroy() changed
       - considered for swapping grant_frame pages.
   * Modify linux-sparse for pv-on-hvm
     + gnttab.c in linux-sparse modified at initialization
     + modify hypervisor.h for pv-on-hvm
   * Modify unmodified_drivers initialization
     + considered the different initialization with x86 code.
     + modify build rule for IPF

  This patch includes:

   * xen-hyper.patch
     - hvm_op hyprecall extension
   * xen-destroy.patch
     - domain destroy logic modification
  * linux.patch
     - linux-sparse modification
  * driver.patch
     - unmodified_drivers modification
  * build.patch
     - unmodified_drivers build rule modification

  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.

Thanks,
- Tsunehisa Doi
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID ee3c9f9b3e9f5b4ddb8999f9fc6ac0413b23f419
# Parent  3e54734e55f39419678afd1ce1a9a96669fa69ef
Expand hvm_op hypercall for PV-on-HVM/IPF

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

diff -r 3e54734e55f3 -r ee3c9f9b3e9f xen/arch/ia64/vmx/vmx_hypercall.c
--- a/xen/arch/ia64/vmx/vmx_hypercall.c Wed Aug 23 13:26:46 2006 -0600
+++ b/xen/arch/ia64/vmx/vmx_hypercall.c Thu Aug 24 20:09:21 2006 +0900
@@ -2,6 +2,7 @@
 /*
  * vmx_hyparcall.c: handling hypercall from domain
  * Copyright (c) 2005, Intel Corporation.
+ * Copyright (c) 2006, Fujitsu Limited.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -17,6 +18,8 @@
  * Place - Suite 330, Boston, MA 02111-1307 USA.
  *
  *  Xuefei Xu (Anthony Xu) (Anthony.xu@xxxxxxxxx)
+ *  Tsunehisa Doi (Doi.Tsunehisa@xxxxxxxxxxxxxx)
+ *  Tomonari Horikoshi (t.horikoshi@xxxxxxxxxxxxxx)
  */
 
 #include <xen/config.h>
@@ -34,6 +37,79 @@
 #include <public/version.h>
 #include <asm/dom_fw.h>
 #include <xen/domain.h>
+#include <xen/compile.h>
+#include <xen/event.h>
+
+static int
+vmx_gnttab_setup_table(unsigned long frame_pa, unsigned long nr_frames)
+{
+    struct domain *d = current->domain;
+    int rc = 0, i;
+    unsigned long o_grant_shared, pgaddr;
+
+    if (nr_frames != NR_GRANT_FRAMES) {
+        return -1;
+    }
+    o_grant_shared = (unsigned long)d->grant_table->shared;
+    d->grant_table->shared = (struct grant_entry *)domain_mpa_to_imva(d, 
frame_pa);
+
+    /* Copy existing grant table shared into new page */
+    if (o_grant_shared) {
+        memcpy((void*)d->grant_table->shared,
+                (void*)o_grant_shared, PAGE_SIZE * nr_frames);
+        /* If original page belongs to xen heap, then relinguish back
+         * to xen heap. Or else, leave to domain itself to decide.
+         */
+        for (i = 0; i < NR_GRANT_FRAMES; i++) {
+            pgaddr = o_grant_shared + PAGE_SIZE * i;
+            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));
+            }
+        }
+    }
+    else {
+        memset(d->grant_table->shared, 0, PAGE_SIZE * nr_frames);
+    }
+    return rc;
+}
+
+static int
+vmx_setup_shared_info_page(unsigned long gpa)
+{
+    VCPU *vcpu = current;
+    struct domain *d = vcpu->domain;
+    unsigned long o_info;
+    struct vcpu *v;
+
+    o_info = (u64)d->shared_info;
+    d->shared_info= (shared_info_t *)domain_mpa_to_imva(d, gpa);
+
+    /* 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];
+        }
+        /* 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(o_info)))) {
+            free_domheap_page(virt_to_page(o_info));
+            free_xenheap_page((void *)o_info);
+        }
+        else {
+            put_page(virt_to_page(o_info));
+        }
+    }
+    else {
+        memset(d->shared_info, 0, PAGE_SIZE);
+    }
+    return 0;
+}
 
 long
 do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)
@@ -78,6 +154,25 @@ 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 3e54734e55f3 -r ee3c9f9b3e9f xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Wed Aug 23 13:26:46 2006 -0600
+++ b/xen/include/public/arch-ia64.h    Thu Aug 24 20:09:21 2006 +0900
@@ -335,6 +335,17 @@ 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 64486d0c30052f603c149a9a62c9552eaaf34bca
# Parent  88304f9671b54b3e78fe111cf2142a1828eb8600
Modify unmodified_drivers build rule for PV-on-HVM/IPF

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

diff -r 88304f9671b5 -r 64486d0c3005 unmodified_drivers/linux-2.6/mkbuildtree
--- a/unmodified_drivers/linux-2.6/mkbuildtree  Thu Aug 24 21:12:27 2006 +0900
+++ b/unmodified_drivers/linux-2.6/mkbuildtree  Thu Aug 24 21:14:32 2006 +0900
@@ -42,6 +42,12 @@ i[34567]86)
        ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
        ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
        ;;
+"ia64")
+       ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
+       ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm
+       ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm
+       ln -sf ${XL}/include/asm-ia64/maddr.h include/asm
+       ;;
 *)
        echo unknown architecture $uname
        exit 1
diff -r 88304f9671b5 -r 64486d0c3005 unmodified_drivers/linux-2.6/overrides.mk
--- a/unmodified_drivers/linux-2.6/overrides.mk Thu Aug 24 21:12:27 2006 +0900
+++ b/unmodified_drivers/linux-2.6/overrides.mk Thu Aug 24 21:14:32 2006 +0900
@@ -4,7 +4,9 @@
 #
 # (i.e. we need the native config for things like -mregparm, but
 # a Xen kernel to find the right headers)
+ifneq ($(ARCH),ia64)
 EXTRA_CFLAGS += -DCONFIG_VMX -DCONFIG_VMX_GUEST -DCONFIG_X86_XEN
+endif
 EXTRA_CFLAGS += -DCONFIG_XEN_SHADOW_MODE -DCONFIG_XEN_SHADOW_TRANSLATE
 EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS
 EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 88304f9671b54b3e78fe111cf2142a1828eb8600
# Parent  6557c022fe1c5b45f5eab7830594e4bef17a4091
Modify unmodified_drivers for PV-on-HVM/IPF

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

diff -r 6557c022fe1c -r 88304f9671b5 
unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Thu Aug 24 
21:07:56 2006 +0900
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Thu Aug 24 
21:12:27 2006 +0900
@@ -54,11 +54,15 @@ static int __init init_xen_info(void)
 static int __init init_xen_info(void)
 {
        unsigned long shared_info_frame;
+       extern void *shared_info_area;
+#ifndef __ia64__
        struct xen_add_to_physmap xatp;
-       extern void *shared_info_area;
-
+#else
+       struct xen_hvm_setup xhs;
+#endif
        setup_xen_features();
 
+#ifndef __ia64__
        shared_info_frame = alloc_xen_mmio(PAGE_SIZE) >> PAGE_SHIFT;
        xatp.domid = DOMID_SELF;
        xatp.idx = 0;
@@ -66,9 +70,17 @@ static int __init init_xen_info(void)
        xatp.gpfn = shared_info_frame;
        if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
                BUG();
-
        shared_info_area =
                ioremap(shared_info_frame << PAGE_SHIFT, PAGE_SIZE);
+#else /* !__ia64__ */
+        shared_info_frame = __get_free_page(GFP_KERNEL);
+        xhs.arg1 = virt_to_phys((void *)shared_info_frame);
+        xhs.arg2 = 0;
+        if (HYPERVISOR_hvm_op(HVMOP_setup_shared_info_page, &xhs))
+                BUG();
+        shared_info_area = (shared_info_t *)shared_info_frame;
+#endif /* !__ia64__ */
+
        if (shared_info_area == NULL)
                panic("can't map shared info\n");
 
@@ -96,6 +108,7 @@ static void __devexit platform_pci_remov
        free_irq(pdev->irq, pdev);
 }
 
+#ifndef __ia64__
 static unsigned long platform_mmio;
 static unsigned long platform_mmio_alloc;
 static unsigned long platform_mmiolen;
@@ -160,6 +173,7 @@ static int get_hypercall_stubs(void)
 
        return 0;
 }
+#endif /* !__ia64__ */
 
 static int __devinit platform_pci_init(struct pci_dev *pdev,
                                       const struct pci_device_id *ent)
@@ -198,13 +212,14 @@ static int __devinit platform_pci_init(s
                return -EBUSY;
        }
 
+#ifndef __ia64__
        platform_mmio = mmio_addr;
        platform_mmiolen = mmio_len;
 
        ret = get_hypercall_stubs();
        if (ret < 0)
                goto out;
-
+#endif /* __ia64__ */
        
        if ((ret = init_xen_info()))
                goto out;
diff -r 6557c022fe1c -r 88304f9671b5 
unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c   Thu Aug 24 
21:07:56 2006 +0900
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c   Thu Aug 24 
21:12:27 2006 +0900
@@ -26,11 +26,13 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
+#ifndef __ia64__
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
        BUG();
 }
 EXPORT_SYMBOL(xen_machphys_update);
+#endif /* __ia64__ */
 
 void balloon_update_driver_allowance(long delta)
 {
@@ -41,3 +43,15 @@ void balloon_release_driver_page(struct 
 {
 }
 EXPORT_SYMBOL(balloon_release_driver_page);
+
+#ifdef __ia64__
+int running_on_xen = 1;
+EXPORT_SYMBOL(running_on_xen);
+
+int ia64_xenmem_reservation_op(unsigned long op,
+                           struct xen_memory_reservation* reservation__)
+{
+        return 0;
+}
+EXPORT_SYMBOL(ia64_xenmem_reservation_op);
+#endif /* __ia64__ */
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 6557c022fe1c5b45f5eab7830594e4bef17a4091
# Parent  622fc5f4ca01ef808b44e368786ac0b1776f9161
Modify linux for PV-on-HVM/IPF

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

diff -r 622fc5f4ca01 -r 6557c022fe1c 
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Thu Aug 24 20:13:03 
2006 +0900
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Thu Aug 24 21:07:56 
2006 +0900
@@ -429,6 +429,7 @@ int gnttab_resume(void)
 int gnttab_resume(void)
 {
        unsigned long frames;
+#ifndef __ia64__
        struct xen_add_to_physmap xatp;
        unsigned int i;
 
@@ -448,13 +449,30 @@ int gnttab_resume(void)
                printk("error to ioremap gnttab share frames\n");
                return -1;
        }
+#else /* !__ia64__ */
+       struct xen_hvm_setup xhs;
+
+       shared = (struct grant_entry *)
+               __get_free_pages(GFP_KERNEL, get_order(PAGE_SIZE * 
NR_GRANT_FRAMES));
+       if (shared == NULL) {
+               printk("error to allocate gnttab share frames\n");
+               return -1;
+       }
+       frames = virt_to_phys((void *)shared);
+       xhs.arg1 = frames;
+       xhs.arg2 = NR_GRANT_FRAMES;
+       if (HYPERVISOR_hvm_op(HVMOP_setup_gnttab_table, &xhs))
+               BUG();
+#endif /* !__ia64__ */
 
        return 0;
 }
 
 int gnttab_suspend(void)
 {
+#ifndef __ia64__
        iounmap(shared);
+#endif /* !__ia64__ */
        return 0;
 }
 
diff -r 622fc5f4ca01 -r 6557c022fe1c 
linux-2.6-xen-sparse/include/asm-ia64/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Thu Aug 24 20:13:03 
2006 +0900
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h Thu Aug 24 21:07:56 
2006 +0900
@@ -315,7 +315,9 @@ static inline void exit_idle(void) {}
 })
 
 #include <linux/err.h>
+#ifdef CONFIG_XEN
 #include <asm/xen/privop.h>
+#endif /* CONFIG_XEN */
 
 #define _hypercall_imm1(type, name, imm, a1)                   \
 ({                                                             \
diff -r 622fc5f4ca01 -r 6557c022fe1c 
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h        Thu Aug 24 
20:13:03 2006 +0900
+++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h        Thu Aug 24 
21:07:56 2006 +0900
@@ -33,15 +33,9 @@
 #ifndef __HYPERVISOR_H__
 #define __HYPERVISOR_H__
 
-#ifndef CONFIG_XEN
-#define is_running_on_xen()                    (0)
-#define HYPERVISOR_ioremap(offset, size)       (offset)
-#else
 extern int running_on_xen;
 #define is_running_on_xen()                    (running_on_xen)
-#endif
 
-#ifdef CONFIG_XEN
 #include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -59,7 +53,11 @@ extern shared_info_t *HYPERVISOR_shared_
 extern shared_info_t *HYPERVISOR_shared_info;
 extern start_info_t *xen_start_info;
 
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 #define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
+#else
+#define is_initial_xendomain() 0
+#endif
 
 void force_evtchn_callback(void);
 
@@ -182,10 +180,19 @@ MULTI_update_va_mapping(
        mcl->result = 0;
 }
 
+static inline void
+MULTI_grant_table_op(multicall_entry_t *mcl, unsigned int cmd,
+                     void *uop, unsigned int count)
+{
+       mcl->op = __HYPERVISOR_grant_table_op;
+       mcl->args[0] = cmd;
+       mcl->args[1] = (unsigned long)uop;
+       mcl->args[2] = count;
+}
+
 // for debug
 asmlinkage int xprintk(const char *fmt, ...);
 #define xprintd(fmt, ...)      xprintk("%s:%d " fmt, __func__, __LINE__, \
                                        ##__VA_ARGS__)
-#endif /* CONFIG_XEN */
 
 #endif /* __HYPERVISOR_H__ */
# HG changeset patch
# User Doi.Tsunehisa@xxxxxxxxxxxxxx
# Node ID 622fc5f4ca01ef808b44e368786ac0b1776f9161
# Parent  ee3c9f9b3e9f5b4ddb8999f9fc6ac0413b23f419
Change destroy for PV-on-HVM/IPF

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

diff -r ee3c9f9b3e9f -r 622fc5f4ca01 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Thu Aug 24 20:09:21 2006 +0900
+++ b/xen/arch/ia64/xen/domain.c        Thu Aug 24 20:13:03 2006 +0900
@@ -390,8 +390,16 @@ 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)
-           free_xenheap_pages(d->shared_info, get_order_from_shift(XSI_SHIFT));
+       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->arch.shadow_bitmap != NULL)
                xfree(d->arch.shadow_bitmap);
 
diff -r ee3c9f9b3e9f -r 622fc5f4ca01 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Thu Aug 24 20:09:21 2006 +0900
+++ b/xen/common/grant_table.c  Thu Aug 24 20:13:03 2006 +0900
@@ -1164,7 +1164,8 @@ grant_table_destroy(
     if ( t == NULL )
         return;
     
-    free_xenheap_pages(t->shared, ORDER_GRANT_FRAMES);
+    if (IS_XEN_HEAP_FRAME(virt_to_page(t->shared)))
+        free_xenheap_pages(t->shared, ORDER_GRANT_FRAMES);
     free_xenheap_page(t->maptrack);
     xfree(t->active);
     xfree(t);
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.