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

[Xen-changelog] [xen-unstable] [XEN] Spot incorrect use of lXe_write & Co.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 8a97b4a43a3d3afcec18fb61b2e6b430eec0bb77
# Parent  fe2e013ae5cba1f6b7da72af7fe271a37a2a3dd1
[XEN] Spot incorrect use of lXe_write & Co.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/include/asm-x86/page.h               |   36 ++++++++++++++++++++-----------
 xen/include/asm-x86/x86_32/page-2level.h |    6 ++---
 xen/include/asm-x86/x86_32/page-3level.h |   29 ++++++++++++------------
 xen/include/asm-x86/x86_64/page.h        |    6 ++---
 4 files changed, 45 insertions(+), 32 deletions(-)

diff -r fe2e013ae5cb -r 8a97b4a43a3d xen/include/asm-x86/page.h
--- a/xen/include/asm-x86/page.h        Thu Dec 14 10:32:38 2006 +0000
+++ b/xen/include/asm-x86/page.h        Thu Dec 14 10:49:54 2006 +0000
@@ -26,25 +26,37 @@
 #endif
 
 /* Read a pte atomically from memory. */
-#define l1e_read_atomic(l1ep) l1e_from_intpte(pte_read_atomic(l1ep))
-#define l2e_read_atomic(l2ep) l2e_from_intpte(pte_read_atomic(l2ep))
-#define l3e_read_atomic(l3ep) l3e_from_intpte(pte_read_atomic(l3ep))
-#define l4e_read_atomic(l4ep) l4e_from_intpte(pte_read_atomic(l4ep))
+#define l1e_read_atomic(l1ep) \
+    l1e_from_intpte(pte_read_atomic(&l1e_get_intpte(*(l1ep))))
+#define l2e_read_atomic(l2ep) \
+    l2e_from_intpte(pte_read_atomic(&l2e_get_intpte(*(l2ep))))
+#define l3e_read_atomic(l3ep) \
+    l3e_from_intpte(pte_read_atomic(&l3e_get_intpte(*(l3ep))))
+#define l4e_read_atomic(l4ep) \
+    l4e_from_intpte(pte_read_atomic(&l4e_get_intpte(*(l4ep))))
 
 /* Write a pte atomically to memory. */
-#define l1e_write_atomic(l1ep, l1e) pte_write_atomic(l1ep, l1e_get_intpte(l1e))
-#define l2e_write_atomic(l2ep, l2e) pte_write_atomic(l2ep, l2e_get_intpte(l2e))
-#define l3e_write_atomic(l3ep, l3e) pte_write_atomic(l3ep, l3e_get_intpte(l3e))
-#define l4e_write_atomic(l4ep, l4e) pte_write_atomic(l4ep, l4e_get_intpte(l4e))
+#define l1e_write_atomic(l1ep, l1e) \
+    pte_write_atomic(&l1e_get_intpte(*(l1ep)), l1e_get_intpte(l1e))
+#define l2e_write_atomic(l2ep, l2e) \
+    pte_write_atomic(&l2e_get_intpte(*(l2ep)), l2e_get_intpte(l2e))
+#define l3e_write_atomic(l3ep, l3e) \
+    pte_write_atomic(&l3e_get_intpte(*(l3ep)), l3e_get_intpte(l3e))
+#define l4e_write_atomic(l4ep, l4e) \
+    pte_write_atomic(&l4e_get_intpte(*(l4ep)), l4e_get_intpte(l4e))
 
 /*
  * Write a pte safely but non-atomically to memory.
  * The PTE may become temporarily not-present during the update.
  */
-#define l1e_write(l1ep, l1e) pte_write(l1ep, l1e_get_intpte(l1e))
-#define l2e_write(l2ep, l2e) pte_write(l2ep, l2e_get_intpte(l2e))
-#define l3e_write(l3ep, l3e) pte_write(l3ep, l3e_get_intpte(l3e))
-#define l4e_write(l4ep, l4e) pte_write(l4ep, l4e_get_intpte(l4e))
+#define l1e_write(l1ep, l1e) \
+    pte_write(&l1e_get_intpte(*(l1ep)), l1e_get_intpte(l1e))
+#define l2e_write(l2ep, l2e) \
+    pte_write(&l2e_get_intpte(*(l2ep)), l2e_get_intpte(l2e))
+#define l3e_write(l3ep, l3e) \
+    pte_write(&l3e_get_intpte(*(l3ep)), l3e_get_intpte(l3e))
+#define l4e_write(l4ep, l4e) \
+    pte_write(&l4e_get_intpte(*(l4ep)), l4e_get_intpte(l4e))
 
 /* Get direct integer representation of a pte's contents (intpte_t). */
 #define l1e_get_intpte(x)          ((x).l1)
diff -r fe2e013ae5cb -r 8a97b4a43a3d xen/include/asm-x86/x86_32/page-2level.h
--- a/xen/include/asm-x86/x86_32/page-2level.h  Thu Dec 14 10:32:38 2006 +0000
+++ b/xen/include/asm-x86/x86_32/page-2level.h  Thu Dec 14 10:49:54 2006 +0000
@@ -28,9 +28,9 @@ typedef l2_pgentry_t root_pgentry_t;
 
 #endif /* !__ASSEMBLY__ */
 
-#define pte_read_atomic(ptep)       (*(intpte_t *)(ptep))
-#define pte_write_atomic(ptep, pte) ((*(intpte_t *)(ptep)) = (pte))
-#define pte_write(ptep, pte)        ((*(intpte_t *)(ptep)) = (pte))
+#define pte_read_atomic(ptep)       (*(ptep))
+#define pte_write_atomic(ptep, pte) (*(ptep) = (pte))
+#define pte_write(ptep, pte)        (*(ptep) = (pte))
 
 /* root table */
 #define root_get_pfn              l2e_get_pfn
diff -r fe2e013ae5cb -r 8a97b4a43a3d xen/include/asm-x86/x86_32/page-3level.h
--- a/xen/include/asm-x86/x86_32/page-3level.h  Thu Dec 14 10:32:38 2006 +0000
+++ b/xen/include/asm-x86/x86_32/page-3level.h  Thu Dec 14 10:49:54 2006 +0000
@@ -38,22 +38,23 @@ typedef l3_pgentry_t root_pgentry_t;
 
 #endif /* !__ASSEMBLY__ */
 
-#define pte_read_atomic(ptep) ({                                            \
-    intpte_t __pte = *(intpte_t *)(ptep), __npte;                           \
-    while ( (__npte = cmpxchg((intpte_t *)(ptep), __pte, __pte)) != __pte ) \
-        __pte = __npte;                                                     \
+#define pte_read_atomic(ptep) ({                              \
+    intpte_t __pte = *(ptep), __npte;                         \
+    while ( (__npte = cmpxchg(ptep, __pte, __pte)) != __pte ) \
+        __pte = __npte;                                       \
     __pte; })
-#define pte_write_atomic(ptep, pte) do {                                    \
-    intpte_t __pte = *(intpte_t *)(ptep), __npte;                           \
-    while ( (__npte = cmpxchg((intpte_t *)(ptep), __pte, (pte))) != __pte ) \
-        __pte = __npte;                                                     \
+#define pte_write_atomic(ptep, pte) do {                      \
+    intpte_t __pte = *(ptep), __npte;                         \
+    while ( (__npte = cmpxchg(ptep, __pte, (pte))) != __pte ) \
+        __pte = __npte;                                       \
 } while ( 0 )
-#define pte_write(ptep, pte) do {               \
-    *((u32 *)(ptep)+0) = 0;                     \
-    wmb();                                      \
-    *((u32 *)(ptep)+1) = (pte) >> 32;           \
-    wmb();                                      \
-    *((u32 *)(ptep)+0) = (pte) >>  0;           \
+#define pte_write(ptep, pte) do {                             \
+    u32 *__ptep_words = (u32 *)(ptep);                        \
+    __ptep_words[0] = 0;                                      \
+    wmb();                                                    \
+    __ptep_words[1] = (pte) >> 32;                            \
+    wmb();                                                    \
+    __ptep_words[0] = (pte) >>  0;                            \
 } while ( 0 )
 
 /* root table */
diff -r fe2e013ae5cb -r 8a97b4a43a3d xen/include/asm-x86/x86_64/page.h
--- a/xen/include/asm-x86/x86_64/page.h Thu Dec 14 10:32:38 2006 +0000
+++ b/xen/include/asm-x86/x86_64/page.h Thu Dec 14 10:49:54 2006 +0000
@@ -43,9 +43,9 @@ typedef l4_pgentry_t root_pgentry_t;
 
 #endif /* !__ASSEMBLY__ */
 
-#define pte_read_atomic(ptep)       (*(intpte_t *)(ptep))
-#define pte_write_atomic(ptep, pte) ((*(intpte_t *)(ptep)) = (pte))
-#define pte_write(ptep, pte)        ((*(intpte_t *)(ptep)) = (pte))
+#define pte_read_atomic(ptep)       (*(ptep))
+#define pte_write_atomic(ptep, pte) (*(ptep) = (pte))
+#define pte_write(ptep, pte)        (*(ptep) = (pte))
 
 /* Given a virtual address, get an entry offset into a linear page table. */
 #define l1_linear_offset(_a) (((_a) & VADDR_MASK) >> L1_PAGETABLE_SHIFT)

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


 


Rackspace

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