Commit 12325f09 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390: cleanup and add sanity checks to control register macros

- turn some macros into functions
- merge two almost identical versions for 32/64 bit
- add BUILD_BUG_ON() check to make sure the passed in array is large enough
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 6aa2677a
...@@ -8,69 +8,59 @@ ...@@ -8,69 +8,59 @@
#define __ASM_CTL_REG_H #define __ASM_CTL_REG_H
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
# define __CTL_LOAD "lctlg"
# define __CTL_STORE "stctg"
#else
# define __CTL_LOAD "lctl"
# define __CTL_STORE "stctl"
#endif
#define __ctl_load(array, low, high) ({ \ #define __ctl_load(array, low, high) { \
typedef struct { char _[sizeof(array)]; } addrtype; \ typedef struct { char _[sizeof(array)]; } addrtype; \
\
BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
asm volatile( \ asm volatile( \
" lctlg %1,%2,%0\n" \ __CTL_LOAD " %1,%2,%0\n" \
: : "Q" (*(addrtype *)(&array)), \ : : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high));\
"i" (low), "i" (high)); \ }
})
#define __ctl_store(array, low, high) ({ \ #define __ctl_store(array, low, high) { \
typedef struct { char _[sizeof(array)]; } addrtype; \ typedef struct { char _[sizeof(array)]; } addrtype; \
\
BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
asm volatile( \ asm volatile( \
" stctg %1,%2,%0\n" \ __CTL_STORE " %1,%2,%0\n" \
: "=Q" (*(addrtype *)(&array)) \ : "=Q" (*(addrtype *)(&array)) \
: "i" (low), "i" (high)); \ : "i" (low), "i" (high)); \
}) }
#else /* CONFIG_64BIT */
#define __ctl_load(array, low, high) ({ \ static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
typedef struct { char _[sizeof(array)]; } addrtype; \ {
asm volatile( \ unsigned long reg;
" lctl %1,%2,%0\n" \
: : "Q" (*(addrtype *)(&array)), \
"i" (low), "i" (high)); \
})
#define __ctl_store(array, low, high) ({ \ __ctl_store(reg, cr, cr);
typedef struct { char _[sizeof(array)]; } addrtype; \ reg |= 1UL << bit;
asm volatile( \ __ctl_load(reg, cr, cr);
" stctl %1,%2,%0\n" \ }
: "=Q" (*(addrtype *)(&array)) \
: "i" (low), "i" (high)); \
})
#endif /* CONFIG_64BIT */ static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
{
unsigned long reg;
#define __ctl_set_bit(cr, bit) ({ \ __ctl_store(reg, cr, cr);
unsigned long __dummy; \ reg &= ~(1UL << bit);
__ctl_store(__dummy, cr, cr); \ __ctl_load(reg, cr, cr);
__dummy |= 1UL << (bit); \ }
__ctl_load(__dummy, cr, cr); \
})
#define __ctl_clear_bit(cr, bit) ({ \ void smp_ctl_set_bit(int cr, int bit);
unsigned long __dummy; \ void smp_ctl_clear_bit(int cr, int bit);
__ctl_store(__dummy, cr, cr); \
__dummy &= ~(1UL << (bit)); \
__ctl_load(__dummy, cr, cr); \
})
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
# define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
extern void smp_ctl_set_bit(int cr, int bit); # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
extern void smp_ctl_clear_bit(int cr, int bit);
#define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
#define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
#else #else
# define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
#define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit) # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
#define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit) #endif
#endif /* CONFIG_SMP */
#endif /* __ASM_CTL_REG_H */ #endif /* __ASM_CTL_REG_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment