|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.4] xen: arm: bitops take unsigned int
commit 5d756ee2a056a0a7ecac9ecd86f0974e7fc26070
Author: Ian Campbell <ian.campbell@xxxxxxxxxx>
AuthorDate: Thu May 8 16:13:55 2014 +0100
Commit: Ian Campbell <ijc@xxxxxxxxxxxxxx>
CommitDate: Fri May 23 10:08:50 2014 +0100
xen: arm: bitops take unsigned int
Xen bitmaps can be 4 rather than 8 byte aligned, so use the appropriate
type.
Otherwise the compiler can generate unaligned 8 byte accesses and cause
traps.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
(cherry picked from commit cd338e967c598bf747b03dcfd9d8d45dc40bac1a)
---
xen/include/asm-arm/bitops.h | 37 +++++++++++++++++++------------------
1 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h
index 0a7caee..25f96c8 100644
--- a/xen/include/asm-arm/bitops.h
+++ b/xen/include/asm-arm/bitops.h
@@ -18,13 +18,14 @@
#define __set_bit(n,p) set_bit(n,p)
#define __clear_bit(n,p) clear_bit(n,p)
+#define BITS_PER_WORD 32
#define BIT(nr) (1UL << (nr))
-#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_WORD))
+#define BIT_WORD(nr) ((nr) / BITS_PER_WORD)
#define BITS_PER_BYTE 8
-#define ADDR (*(volatile long *) addr)
-#define CONST_ADDR (*(const volatile long *) addr)
+#define ADDR (*(volatile int *) addr)
+#define CONST_ADDR (*(const volatile int *) addr)
#if defined(CONFIG_ARM_32)
# include <asm/arm32/bitops.h>
@@ -45,10 +46,10 @@
*/
static inline int __test_and_set_bit(int nr, volatile void *addr)
{
- unsigned long mask = BIT_MASK(nr);
- volatile unsigned long *p =
- ((volatile unsigned long *)addr) + BIT_WORD(nr);
- unsigned long old = *p;
+ unsigned int mask = BIT_MASK(nr);
+ volatile unsigned int *p =
+ ((volatile unsigned int *)addr) + BIT_WORD(nr);
+ unsigned int old = *p;
*p = old | mask;
return (old & mask) != 0;
@@ -65,10 +66,10 @@ static inline int __test_and_set_bit(int nr, volatile void
*addr)
*/
static inline int __test_and_clear_bit(int nr, volatile void *addr)
{
- unsigned long mask = BIT_MASK(nr);
- volatile unsigned long *p =
- ((volatile unsigned long *)addr) + BIT_WORD(nr);
- unsigned long old = *p;
+ unsigned int mask = BIT_MASK(nr);
+ volatile unsigned int *p =
+ ((volatile unsigned int *)addr) + BIT_WORD(nr);
+ unsigned int old = *p;
*p = old & ~mask;
return (old & mask) != 0;
@@ -78,10 +79,10 @@ static inline int __test_and_clear_bit(int nr, volatile
void *addr)
static inline int __test_and_change_bit(int nr,
volatile void *addr)
{
- unsigned long mask = BIT_MASK(nr);
- volatile unsigned long *p =
- ((volatile unsigned long *)addr) + BIT_WORD(nr);
- unsigned long old = *p;
+ unsigned int mask = BIT_MASK(nr);
+ volatile unsigned int *p =
+ ((volatile unsigned int *)addr) + BIT_WORD(nr);
+ unsigned int old = *p;
*p = old ^ mask;
return (old & mask) != 0;
@@ -94,8 +95,8 @@ static inline int __test_and_change_bit(int nr,
*/
static inline int test_bit(int nr, const volatile void *addr)
{
- const volatile unsigned long *p = (const volatile unsigned long *)addr;
- return 1UL & (p[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+ const volatile unsigned int *p = (const volatile unsigned int *)addr;
+ return 1UL & (p[BIT_WORD(nr)] >> (nr & (BITS_PER_WORD-1)));
}
static inline int constant_fls(int x)
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.4
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |