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][libxc] xc_translate_foreign_address with additional

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH][libxc] xc_translate_foreign_address with additional parameter
From: Tomas Kouba <tomas@xxxxxxxx>
Date: Fri, 05 Jan 2007 15:19:12 +0100
Delivery-date: Fri, 05 Jan 2007 06:19:06 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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: Thunderbird 1.5.0.9 (X11/20061219)
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
<Prev in Thread] Current Thread [Next in Thread>