]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
XXX fix virt_to_pdx and pdx_to_virt
authorWei Liu <wei.liu2@citrix.com>
Mon, 25 Feb 2019 14:49:42 +0000 (14:49 +0000)
committerWei Liu <wei.liu2@citrix.com>
Mon, 25 Feb 2019 15:58:35 +0000 (15:58 +0000)
Now we have pointers coming from vmap region and vmap is lower than
directmap in address space, use vmap start instead.

This makes sure we don't lose high bits when storing the value in
_domain in page_info, since it might be of a smaller type than
unsigned long.

xen/include/asm-x86/mm.h
xen/include/asm-x86/x86_64/page.h

index 661e803e45cd4ba34617c75e7694ffee4d6c08da..e5e479cb7c207ba2875e7e81f021d02def6d5e6c 100644 (file)
@@ -277,6 +277,34 @@ struct page_info
     void *linear;
 };
 
+/*
+ * Note: These are solely for the use by page_{get,set}_owner(), and
+ *       therefore don't need to handle the XEN_VIRT_{START,END} range.
+ *
+ *   XXX liuw: these need fixing, because going from a vmap area
+ *        pointer to pdx is not right. We may have to end up storing
+ *        the pointer directly?
+ */
+#if 0
+#define virt_to_pdx(va)  (((unsigned long)(va) - VMAP_VIRT_START) >> \
+                          PAGE_SHIFT)
+#define pdx_to_virt(pdx) ((void *)(VMAP_VIRT_START + \
+                                   ((unsigned long)(pdx) << PAGE_SHIFT)))
+#endif
+
+static inline __pdx_t virt_to_pdx(void *va)
+{
+    unsigned long ret = ((unsigned long)(va) - VMAP_VIRT_START) >> PAGE_SHIFT;
+    /* Make sure there is no truncation */
+    ASSERT(ret == (__pdx_t)ret);
+    return (__pdx_t)ret;
+}
+
+static inline void *pdx_to_virt(__pdx_t pdx)
+{
+    return (void *)(VMAP_VIRT_START + ((unsigned long)pdx << PAGE_SHIFT));
+}
+
 #undef __pdx_t
 
 static inline void set_page_address(struct page_info *page, void *linear)
index d4a1d48e66bd55f3b2d961d7eec93c27c8a92f62..58ae5c092aef727f011fd3fa077f65ff09ac5f53 100644 (file)
@@ -48,19 +48,6 @@ static inline unsigned long canonicalise_addr(unsigned long addr)
 
 extern unsigned long xen_virt_end;
 
-/*
- * Note: These are solely for the use by page_{get,set}_owner(), and
- *       therefore don't need to handle the XEN_VIRT_{START,END} range.
- *
- *   XXX liuw: these need fixing, because going from a vmap area
- *        pointer to pdx is not right. We may have to end up storing
- *        the pointer directly?
- */
-#define virt_to_pdx(va)  (((unsigned long)(va) - DIRECTMAP_VIRT_START) >> \
-                          PAGE_SHIFT)
-#define pdx_to_virt(pdx) ((void *)(DIRECTMAP_VIRT_START + \
-                                   ((unsigned long)(pdx) << PAGE_SHIFT)))
-
 unsigned long __virt_to_maddr(unsigned long va);
 void *__maddr_to_virt(unsigned long ma);