1 From 2ad5d52d42810bed95100a3d912679d8864421ec Mon Sep 17 00:00:00 2001
2 From: Helge Deller <deller@gmx.de>
3 Date: Sat, 28 Jan 2017 11:52:02 +0100
4 Subject: parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
6 From: Helge Deller <deller@gmx.de>
8 commit 2ad5d52d42810bed95100a3d912679d8864421ec upstream.
10 In swab.h the "#if BITS_PER_LONG > 32" breaks compiling userspace programs if
11 BITS_PER_LONG is #defined by userspace with the sizeof() compiler builtin.
13 Solve this problem by using __BITS_PER_LONG instead. Since we now
14 #include asm/bitsperlong.h avoid further potential userspace pollution
15 by moving the #define of SHIFT_PER_LONG to bitops.h which is not
16 exported to userspace.
18 This patch unbreaks compiling qemu on hppa/parisc.
20 Signed-off-by: Helge Deller <deller@gmx.de>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 arch/parisc/include/asm/bitops.h | 8 +++++++-
25 arch/parisc/include/uapi/asm/bitsperlong.h | 2 --
26 arch/parisc/include/uapi/asm/swab.h | 5 +++--
27 3 files changed, 10 insertions(+), 5 deletions(-)
29 --- a/arch/parisc/include/asm/bitops.h
30 +++ b/arch/parisc/include/asm/bitops.h
34 #include <linux/compiler.h>
35 -#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */
36 +#include <asm/types.h>
37 #include <asm/byteorder.h>
38 #include <asm/barrier.h>
39 #include <linux/atomic.h>
41 * to include/asm-i386/bitops.h or kerneldoc
44 +#if __BITS_PER_LONG == 64
45 +#define SHIFT_PER_LONG 6
47 +#define SHIFT_PER_LONG 5
50 #define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
53 --- a/arch/parisc/include/uapi/asm/bitsperlong.h
54 +++ b/arch/parisc/include/uapi/asm/bitsperlong.h
58 #define __BITS_PER_LONG 64
59 -#define SHIFT_PER_LONG 6
61 #define __BITS_PER_LONG 32
62 -#define SHIFT_PER_LONG 5
65 #include <asm-generic/bitsperlong.h>
66 --- a/arch/parisc/include/uapi/asm/swab.h
67 +++ b/arch/parisc/include/uapi/asm/swab.h
69 #ifndef _PARISC_SWAB_H
70 #define _PARISC_SWAB_H
72 +#include <asm/bitsperlong.h>
73 #include <linux/types.h>
74 #include <linux/compiler.h>
76 @@ -38,7 +39,7 @@ static inline __attribute_const__ __u32
78 #define __arch_swab32 __arch_swab32
80 -#if BITS_PER_LONG > 32
81 +#if __BITS_PER_LONG > 32
83 ** From "PA-RISC 2.0 Architecture", HP Professional Books.
84 ** See Appendix I page 8 , "Endian Byte Swapping".
85 @@ -61,6 +62,6 @@ static inline __attribute_const__ __u64
88 #define __arch_swab64 __arch_swab64
89 -#endif /* BITS_PER_LONG > 32 */
90 +#endif /* __BITS_PER_LONG > 32 */
92 #endif /* _PARISC_SWAB_H */