All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomas Kouba <tomas@jikos.cz>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH][libxc] xc_translate_foreign_address with additional parameter
Date: Fri, 05 Jan 2007 15:19:12 +0100	[thread overview]
Message-ID: <459E5E60.1060002@jikos.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

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


[-- Attachment #2: xc_translate_foreign_address_cr3.patch --]
[-- Type: text/x-patch, Size: 2831 bytes --]

# HG changeset patch
# User tomas@jikos.cz
# 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);



[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2007-01-05 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-05 14:19 Tomas Kouba [this message]
2007-01-05 14:36 ` [PATCH][libxc] xc_translate_foreign_address with additional parameter Keir Fraser
2007-01-05 16:32   ` Bryan D. Payne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=459E5E60.1060002@jikos.cz \
    --to=tomas@jikos.cz \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.