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-devel

[Xen-devel] [PATCH][4/6] Add to virtual device operations

To: Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH][4/6] Add to virtual device operations
From: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Date: Mon, 05 Sep 2005 18:41:10 +0800
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 05 Sep 2005 10:42:37 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510
Add two virtual device operations:
1.set the callback irq for event channel
2.setup the hypercall paramerter share page.

Signed-off-by: Ke Yu <ke.yu@xxxxxxxxx>
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>


diff -r 287d36b46fa3 xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        Tue Aug 30 20:36:49 2005
+++ b/xen/arch/x86/vmx.c        Fri Sep  2 22:46:13 2005
@@ -1752,6 +1803,81 @@
     asm volatile("movq %0,%%cr2": :"r" (d->arch.arch_vmx.cpu_cr2));
 #endif
 }
+
+
+/* map hypercall parameter share page address in monitor pagetable
+ * map guest virtual address <-->  hypervisor virtual address
+ * the hypervisor virtual address should below HYPERVISOR_VIRT_START,
+ * so that share page can be treated as a guest page
+ */
+int map_param_share_page(unsigned long gva, unsigned long hva){
+
+    unsigned long mfn;
+    l2_pgentry_t *mpl2e; /* monitor page table l2 */
+    l1_pgentry_t *mpl1e; /* monitor page table l1 */
+    struct pfn_info *l1_mfn_info;
+    unsigned long l1_mfn;
+    struct vcpu* v = current;
+    struct domain *d = v->domain;
+
+    mfn = __gpfn_to_mfn(d, gva >> PAGE_SHIFT);
+    mpl2e = current->arch.monitor_vtable;
+    if ( mpl2e[l2_table_offset(hva)].l2 ){
+        printk("map of hva 0x%lx already exists\n",hva);
+        return -1;
+    }
+
+    /* alloc l1 page table */
+    d->max_pages++;
+    l1_mfn_info = alloc_domheap_page(d);
+    if (!l1_mfn_info){
+        printk("alloc_domheap_page failed\n");
+        return -1;
+    }
+    l1_mfn = page_to_pfn(l1_mfn_info);
+    printk("map_param_share_page: alloc page at 0x%lx\n", l1_mfn);
+
+    /* set l2 page table entry */
+    mpl2e[l2_table_offset(hva)] =
+        l2e_from_pfn (l1_mfn, __PAGE_HYPERVISOR);
+    printk("map_param_share_page: set l2 page table entry\n");
+
+    /* set l1 page table */
+    mpl1e = (l1_pgentry_t *)map_domain_page(l1_mfn);
+    memset(mpl1e, 0, PAGE_SIZE);
+    mpl1e[l1_table_offset(hva)] =
+        l1e_from_pfn(mfn, __PAGE_HYPERVISOR);
+    unmap_domain_page(mpl1e);
+    printk("map_param_share_page: set l1 page table entry\n");
+
+    return 0;
+}
+
+asmlinkage unsigned long do_virtual_device_op(unsigned long op,
+                                              unsigned long arg1,
+                                              unsigned arg2)
+{
+    switch (op)
+    {
+        case SET_CALLBACK_IRQ:
+        {
+            if(arg1)
+                current->domain->arch.vmx_platform.callback_irq = arg1;
+            else
+                current->domain->arch.vmx_platform.callback_irq = 0;
+            return 0;
+        }
+         case SET_SHARE_PARAM_MAP:
+        {
+            int rc = map_param_share_page(arg1, arg2);
+            DPRINTK("SET_SHAER_PARAM_MAP: gva=%lx\n",arg1);
+            return rc;
+        }
+
+    }
+    return 0L;
+}
+#endif /* CONFIG_VMX */

 #ifdef TRACE_BUFFER
 asmlinkage void trace_vmentry (void)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH][4/6] Add to virtual device operations, Xiaofeng Ling <=