ia64/xen-unstable

changeset 13019:8a97b4a43a3d

[XEN] Spot incorrect use of lXe_write & Co.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Thu Dec 14 10:49:54 2006 +0000 (2006-12-14)
parents fe2e013ae5cb
children 35c724302bdd
files xen/include/asm-x86/page.h xen/include/asm-x86/x86_32/page-2level.h xen/include/asm-x86/x86_32/page-3level.h xen/include/asm-x86/x86_64/page.h
line diff
     1.1 --- a/xen/include/asm-x86/page.h	Thu Dec 14 10:32:38 2006 +0000
     1.2 +++ b/xen/include/asm-x86/page.h	Thu Dec 14 10:49:54 2006 +0000
     1.3 @@ -26,25 +26,37 @@
     1.4  #endif
     1.5  
     1.6  /* Read a pte atomically from memory. */
     1.7 -#define l1e_read_atomic(l1ep) l1e_from_intpte(pte_read_atomic(l1ep))
     1.8 -#define l2e_read_atomic(l2ep) l2e_from_intpte(pte_read_atomic(l2ep))
     1.9 -#define l3e_read_atomic(l3ep) l3e_from_intpte(pte_read_atomic(l3ep))
    1.10 -#define l4e_read_atomic(l4ep) l4e_from_intpte(pte_read_atomic(l4ep))
    1.11 +#define l1e_read_atomic(l1ep) \
    1.12 +    l1e_from_intpte(pte_read_atomic(&l1e_get_intpte(*(l1ep))))
    1.13 +#define l2e_read_atomic(l2ep) \
    1.14 +    l2e_from_intpte(pte_read_atomic(&l2e_get_intpte(*(l2ep))))
    1.15 +#define l3e_read_atomic(l3ep) \
    1.16 +    l3e_from_intpte(pte_read_atomic(&l3e_get_intpte(*(l3ep))))
    1.17 +#define l4e_read_atomic(l4ep) \
    1.18 +    l4e_from_intpte(pte_read_atomic(&l4e_get_intpte(*(l4ep))))
    1.19  
    1.20  /* Write a pte atomically to memory. */
    1.21 -#define l1e_write_atomic(l1ep, l1e) pte_write_atomic(l1ep, l1e_get_intpte(l1e))
    1.22 -#define l2e_write_atomic(l2ep, l2e) pte_write_atomic(l2ep, l2e_get_intpte(l2e))
    1.23 -#define l3e_write_atomic(l3ep, l3e) pte_write_atomic(l3ep, l3e_get_intpte(l3e))
    1.24 -#define l4e_write_atomic(l4ep, l4e) pte_write_atomic(l4ep, l4e_get_intpte(l4e))
    1.25 +#define l1e_write_atomic(l1ep, l1e) \
    1.26 +    pte_write_atomic(&l1e_get_intpte(*(l1ep)), l1e_get_intpte(l1e))
    1.27 +#define l2e_write_atomic(l2ep, l2e) \
    1.28 +    pte_write_atomic(&l2e_get_intpte(*(l2ep)), l2e_get_intpte(l2e))
    1.29 +#define l3e_write_atomic(l3ep, l3e) \
    1.30 +    pte_write_atomic(&l3e_get_intpte(*(l3ep)), l3e_get_intpte(l3e))
    1.31 +#define l4e_write_atomic(l4ep, l4e) \
    1.32 +    pte_write_atomic(&l4e_get_intpte(*(l4ep)), l4e_get_intpte(l4e))
    1.33  
    1.34  /*
    1.35   * Write a pte safely but non-atomically to memory.
    1.36   * The PTE may become temporarily not-present during the update.
    1.37   */
    1.38 -#define l1e_write(l1ep, l1e) pte_write(l1ep, l1e_get_intpte(l1e))
    1.39 -#define l2e_write(l2ep, l2e) pte_write(l2ep, l2e_get_intpte(l2e))
    1.40 -#define l3e_write(l3ep, l3e) pte_write(l3ep, l3e_get_intpte(l3e))
    1.41 -#define l4e_write(l4ep, l4e) pte_write(l4ep, l4e_get_intpte(l4e))
    1.42 +#define l1e_write(l1ep, l1e) \
    1.43 +    pte_write(&l1e_get_intpte(*(l1ep)), l1e_get_intpte(l1e))
    1.44 +#define l2e_write(l2ep, l2e) \
    1.45 +    pte_write(&l2e_get_intpte(*(l2ep)), l2e_get_intpte(l2e))
    1.46 +#define l3e_write(l3ep, l3e) \
    1.47 +    pte_write(&l3e_get_intpte(*(l3ep)), l3e_get_intpte(l3e))
    1.48 +#define l4e_write(l4ep, l4e) \
    1.49 +    pte_write(&l4e_get_intpte(*(l4ep)), l4e_get_intpte(l4e))
    1.50  
    1.51  /* Get direct integer representation of a pte's contents (intpte_t). */
    1.52  #define l1e_get_intpte(x)          ((x).l1)
     2.1 --- a/xen/include/asm-x86/x86_32/page-2level.h	Thu Dec 14 10:32:38 2006 +0000
     2.2 +++ b/xen/include/asm-x86/x86_32/page-2level.h	Thu Dec 14 10:49:54 2006 +0000
     2.3 @@ -28,9 +28,9 @@ typedef l2_pgentry_t root_pgentry_t;
     2.4  
     2.5  #endif /* !__ASSEMBLY__ */
     2.6  
     2.7 -#define pte_read_atomic(ptep)       (*(intpte_t *)(ptep))
     2.8 -#define pte_write_atomic(ptep, pte) ((*(intpte_t *)(ptep)) = (pte))
     2.9 -#define pte_write(ptep, pte)        ((*(intpte_t *)(ptep)) = (pte))
    2.10 +#define pte_read_atomic(ptep)       (*(ptep))
    2.11 +#define pte_write_atomic(ptep, pte) (*(ptep) = (pte))
    2.12 +#define pte_write(ptep, pte)        (*(ptep) = (pte))
    2.13  
    2.14  /* root table */
    2.15  #define root_get_pfn              l2e_get_pfn
     3.1 --- a/xen/include/asm-x86/x86_32/page-3level.h	Thu Dec 14 10:32:38 2006 +0000
     3.2 +++ b/xen/include/asm-x86/x86_32/page-3level.h	Thu Dec 14 10:49:54 2006 +0000
     3.3 @@ -38,22 +38,23 @@ typedef l3_pgentry_t root_pgentry_t;
     3.4  
     3.5  #endif /* !__ASSEMBLY__ */
     3.6  
     3.7 -#define pte_read_atomic(ptep) ({                                            \
     3.8 -    intpte_t __pte = *(intpte_t *)(ptep), __npte;                           \
     3.9 -    while ( (__npte = cmpxchg((intpte_t *)(ptep), __pte, __pte)) != __pte ) \
    3.10 -        __pte = __npte;                                                     \
    3.11 +#define pte_read_atomic(ptep) ({                              \
    3.12 +    intpte_t __pte = *(ptep), __npte;                         \
    3.13 +    while ( (__npte = cmpxchg(ptep, __pte, __pte)) != __pte ) \
    3.14 +        __pte = __npte;                                       \
    3.15      __pte; })
    3.16 -#define pte_write_atomic(ptep, pte) do {                                    \
    3.17 -    intpte_t __pte = *(intpte_t *)(ptep), __npte;                           \
    3.18 -    while ( (__npte = cmpxchg((intpte_t *)(ptep), __pte, (pte))) != __pte ) \
    3.19 -        __pte = __npte;                                                     \
    3.20 +#define pte_write_atomic(ptep, pte) do {                      \
    3.21 +    intpte_t __pte = *(ptep), __npte;                         \
    3.22 +    while ( (__npte = cmpxchg(ptep, __pte, (pte))) != __pte ) \
    3.23 +        __pte = __npte;                                       \
    3.24  } while ( 0 )
    3.25 -#define pte_write(ptep, pte) do {               \
    3.26 -    *((u32 *)(ptep)+0) = 0;                     \
    3.27 -    wmb();                                      \
    3.28 -    *((u32 *)(ptep)+1) = (pte) >> 32;           \
    3.29 -    wmb();                                      \
    3.30 -    *((u32 *)(ptep)+0) = (pte) >>  0;           \
    3.31 +#define pte_write(ptep, pte) do {                             \
    3.32 +    u32 *__ptep_words = (u32 *)(ptep);                        \
    3.33 +    __ptep_words[0] = 0;                                      \
    3.34 +    wmb();                                                    \
    3.35 +    __ptep_words[1] = (pte) >> 32;                            \
    3.36 +    wmb();                                                    \
    3.37 +    __ptep_words[0] = (pte) >>  0;                            \
    3.38  } while ( 0 )
    3.39  
    3.40  /* root table */
     4.1 --- a/xen/include/asm-x86/x86_64/page.h	Thu Dec 14 10:32:38 2006 +0000
     4.2 +++ b/xen/include/asm-x86/x86_64/page.h	Thu Dec 14 10:49:54 2006 +0000
     4.3 @@ -43,9 +43,9 @@ typedef l4_pgentry_t root_pgentry_t;
     4.4  
     4.5  #endif /* !__ASSEMBLY__ */
     4.6  
     4.7 -#define pte_read_atomic(ptep)       (*(intpte_t *)(ptep))
     4.8 -#define pte_write_atomic(ptep, pte) ((*(intpte_t *)(ptep)) = (pte))
     4.9 -#define pte_write(ptep, pte)        ((*(intpte_t *)(ptep)) = (pte))
    4.10 +#define pte_read_atomic(ptep)       (*(ptep))
    4.11 +#define pte_write_atomic(ptep, pte) (*(ptep) = (pte))
    4.12 +#define pte_write(ptep, pte)        (*(ptep) = (pte))
    4.13  
    4.14  /* Given a virtual address, get an entry offset into a linear page table. */
    4.15  #define l1_linear_offset(_a) (((_a) & VADDR_MASK) >> L1_PAGETABLE_SHIFT)