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] linux/x86: utilize lookup_address() for virt_to_ptep

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux/x86: utilize lookup_address() for virt_to_ptep()
From: "Jan Beulich" <jbeulich@xxxxxxxxxx>
Date: Thu, 15 May 2008 13:54:19 +0100
Delivery-date: Thu, 15 May 2008 05:54:29 -0700
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
As usual, written and tested on 2.6.25.2 and made apply to the 2.6.18
tree without further testing.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: head-2008-05-08/arch/x86_64/mm/pageattr-xen.c
===================================================================
--- head-2008-05-08.orig/arch/x86_64/mm/pageattr-xen.c  2008-05-15 
13:44:37.000000000 +0200
+++ head-2008-05-08/arch/x86_64/mm/pageattr-xen.c       2008-05-15 
14:44:59.000000000 +0200
@@ -276,7 +276,7 @@
 }
 #endif /* CONFIG_XEN */
 
-static inline pte_t *lookup_address(unsigned long address) 
+pte_t *lookup_address(unsigned long address) 
 { 
        pgd_t *pgd = pgd_offset_k(address);
        pud_t *pud;
Index: head-2008-05-08/include/asm-i386/mach-xen/asm/pgtable.h
===================================================================
--- head-2008-05-08.orig/include/asm-i386/mach-xen/asm/pgtable.h        
2008-05-15 13:44:37.000000000 +0200
+++ head-2008-05-08/include/asm-i386/mach-xen/asm/pgtable.h     2008-05-15 
13:38:59.000000000 +0200
@@ -477,19 +477,16 @@ void make_page_writable(void *va, unsign
 void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
 void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
 
-#define virt_to_ptep(__va)                                             \
-({                                                                     \
-       pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));             \
-       pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));        \
-       pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));        \
-       pte_offset_kernel(__pmd, (unsigned long)(__va));                \
-})
-
-#define arbitrary_virt_to_machine(__va)                                        
\
-({                                                                     \
-       maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
-       m | ((unsigned long)(__va) & (PAGE_SIZE-1));                    \
-})
+#define virt_to_ptep(va)                                               \
+({                                                                     \
+       pte_t *__ptep = lookup_address((unsigned long)(va));            \
+       BUG_ON(!__ptep || !pte_present(*__ptep));                       \
+       __ptep;                                                         \
+})
+
+#define arbitrary_virt_to_machine(va)                                  \
+       (((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)            \
+        | ((unsigned long)(va) & (PAGE_SIZE - 1)))
 
 #endif /* !__ASSEMBLY__ */
 
Index: head-2008-05-08/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
--- head-2008-05-08.orig/include/asm-x86_64/mach-xen/asm/pgtable.h      
2008-05-15 13:44:37.000000000 +0200
+++ head-2008-05-08/include/asm-x86_64/mach-xen/asm/pgtable.h   2008-05-15 
13:38:29.000000000 +0200
@@ -18,19 +18,18 @@
 
 extern void xen_init_pt(void);
 
-#define virt_to_ptep(__va)                                             \
-({                                                                     \
-       pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));             \
-       pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));        \
-       pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));        \
-       pte_offset_kernel(__pmd, (unsigned long)(__va));                \
-})
-
-#define arbitrary_virt_to_machine(__va)                                        
\
-({                                                                     \
-       maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
-       m | ((unsigned long)(__va) & (PAGE_SIZE-1));                    \
-})
+extern pte_t *lookup_address(unsigned long address);
+
+#define virt_to_ptep(va)                                               \
+({                                                                     \
+       pte_t *__ptep = lookup_address((unsigned long)(va));            \
+       BUG_ON(!__ptep || !pte_present(*__ptep));                       \
+       __ptep;                                                         \
+})
+
+#define arbitrary_virt_to_machine(va)                                  \
+       (((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)            \
+        | ((unsigned long)(va) & (PAGE_SIZE - 1)))
 #endif
 
 extern pud_t level3_kernel_pgt[512];




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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux/x86: utilize lookup_address() for virt_to_ptep(), Jan Beulich <=