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

[Xen-devel] [PATCH][libxc] xc_translate_foreign_address with additional parameter


  • To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: Tomas Kouba <tomas@xxxxxxxx>
  • Date: Fri, 05 Jan 2007 15:19:12 +0100
  • Delivery-date: Fri, 05 Jan 2007 06:19:06 -0800
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Hi,

I think it would be handy(*) to have additional function
xc_translate_foreign_address_cr3 that does the same as
xc_translate_foreign_address but with explicit cr3 register.
The actual xc_translate_foreign_address takes its cr3 from
vcpu context.

This is my first patch/post so please excuse me if I misfollowed
some procedure.

(*) handy for xenaccess library

--
Tomas Kouba

# HG changeset patch
# User tomas@xxxxxxxx
# Date 1168005525 -3600
# Node ID cde6908125f925d15a5a6680730fdd9f1bd0b850
# Parent  d04ff58bbe18b40807c1f4fe0c29843333573f05
Added xc_translate_foreign_address_cr3 so the translation can be done with
custom page tables.

diff -r d04ff58bbe18 -r cde6908125f9 tools/libxc/xc_pagetab.c
--- a/tools/libxc/xc_pagetab.c  Fri Jan 05 10:40:19 2007 +0000
+++ b/tools/libxc/xc_pagetab.c  Fri Jan 05 14:58:45 2007 +0100
@@ -50,6 +50,21 @@ unsigned long xc_translate_foreign_addre
 {
     vcpu_guest_context_t ctx;
     unsigned long long cr3;
+
+    if (xc_vcpu_getcontext(xc_handle, dom, vcpu, &ctx) != 0) {
+        DPRINTF("failed to retreive vcpu context\n");
+        return 0;
+    }
+    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.ctrlreg[3])) << PAGE_SHIFT;
+
+    return xc_translate_foreign_address_cr3(xc_handle, dom, vcpu, virt, cr3);
+}
+
+
+unsigned long xc_translate_foreign_address_cr3(int xc_handle, uint32_t dom,
+                                           int vcpu, unsigned long long virt,
+                                           unsigned long long cr3)
+{
     void *pd, *pt, *pdppage = NULL, *pdp, *pml = NULL;
     unsigned long long pde, pte, pdpe, pmle;
     unsigned long mfn = 0;
@@ -73,12 +88,6 @@ unsigned long xc_translate_foreign_addre
 #elif defined (__x86_64__)
 #define pt_levels 4
 #endif
-
-    if (xc_vcpu_getcontext(xc_handle, dom, vcpu, &ctx) != 0) {
-        DPRINTF("failed to retreive vcpu context\n");
-        goto out;
-    }
-    cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.ctrlreg[3])) << PAGE_SHIFT;

     /* Page Map Level 4 */

diff -r d04ff58bbe18 -r cde6908125f9 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Jan 05 10:40:19 2007 +0000
+++ b/tools/libxc/xenctrl.h     Fri Jan 05 14:58:45 2007 +0100
@@ -513,6 +513,21 @@ unsigned long xc_translate_foreign_addre
 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
                                            int vcpu, unsigned long long virt);

+/**
+ * Translates a virtual address in the context of a given domain and
+ * memory management tables. Returns the machine page frame number of the 
associated
+ * page.
+ *
+ * @parm xc_handle a handle on an open hypervisor interface
+ * @parm dom the domain to perform the translation in
+ * @parm vcpu the vcpu to perform the translation on
+ * @parm virt the virtual address to translate
+ * @parm cr3 pointer to MM tables (identifies userland process)
+ */
+unsigned long xc_translate_foreign_address_cr3(int xc_handle, uint32_t dom,
+                                           int vcpu, unsigned long long virt,
+                                           unsigned long long cr3);
+
 int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
                     unsigned long max_pfns);


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

 


Rackspace

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