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

[Xen-changelog] [xen master] libxc: fix xc_translate_foreign_address()



commit ef78bf31077aae1f60b97ac57b36bc66a17b12dd
Author:     Cristian-Bogdan Sirb <csirb@xxxxxxxxxxxxxxx>
AuthorDate: Wed Apr 5 17:53:53 2017 +0300
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Thu Apr 6 10:37:24 2017 +0100

    libxc: fix xc_translate_foreign_address()
    
    Currently xc_translate_foreign_address() only checks for the PSE bit on
    level 2 entries (that's 2 MB pages on x64 and 32-bit with PAE, and 4 MB
    pages on 32-bit). But the Linux kernel sometimes uses 1 GB pages. This
    patch fixes that, by checking the PSE bit on level 3 entries if the guest
    has 4 translation levels (that means 64-bit guests only).
    
    Signed-off-by: Cristian-Bogdan Sirb <csirb@xxxxxxxxxxxxxxx>
    Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Release-acked-by: Julien Grall <julien.grall@xxxxxxx>
---
 tools/libxc/include/xenctrl.h | 3 +++
 tools/libxc/xc_pagetab.c      | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index e2b4cc1..01f8dfe 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1460,6 +1460,9 @@ int xc_lockprof_query(xc_interface *xch,
 void *xc_memalign(xc_interface *xch, size_t alignment, size_t size);
 
 /**
+ * Avoid using this function, as it does not work for all cases (such
+ * as 4M superpages, or guests using PSE36). Only used for debugging.
+ *
  * Translates a virtual address in the context of a given domain and
  * vcpu returning the GFN containing the address (that is, an MFN for 
  * PV guests, a PFN for HVM guests).  Returns 0 for failure.
diff --git a/tools/libxc/xc_pagetab.c b/tools/libxc/xc_pagetab.c
index 92eebd6..db25c20 100644
--- a/tools/libxc/xc_pagetab.c
+++ b/tools/libxc/xc_pagetab.c
@@ -93,7 +93,7 @@ unsigned long xc_translate_foreign_address(xc_interface *xch, 
uint32_t dom,
             return 0;
         }
         paddr = pte & 0x000ffffffffff000ull;
-        if (level == 2 && (pte & PTE_PSE)) {
+        if ((level == 2 || (level == 3 && pt_levels == 4)) && (pte & PTE_PSE)) 
{
             mask = ((mask ^ ~-mask) >> 1); /* All bits below first set bit */
             return ((paddr & ~mask) | (virt & mask)) >> PAGE_SHIFT;
         }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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