]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.46/parisc-don-t-use-bits_per_long-in-userspace-exported-swab.h-header.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.46 / parisc-don-t-use-bits_per_long-in-userspace-exported-swab.h-header.patch
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
5
6 From: Helge Deller <deller@gmx.de>
7
8 commit 2ad5d52d42810bed95100a3d912679d8864421ec upstream.
9
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.
12
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.
17
18 This patch unbreaks compiling qemu on hppa/parisc.
19
20 Signed-off-by: Helge Deller <deller@gmx.de>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
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(-)
28
29 --- a/arch/parisc/include/asm/bitops.h
30 +++ b/arch/parisc/include/asm/bitops.h
31 @@ -6,7 +6,7 @@
32 #endif
33
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>
40 @@ -17,6 +17,12 @@
41 * to include/asm-i386/bitops.h or kerneldoc
42 */
43
44 +#if __BITS_PER_LONG == 64
45 +#define SHIFT_PER_LONG 6
46 +#else
47 +#define SHIFT_PER_LONG 5
48 +#endif
49 +
50 #define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
51
52
53 --- a/arch/parisc/include/uapi/asm/bitsperlong.h
54 +++ b/arch/parisc/include/uapi/asm/bitsperlong.h
55 @@ -3,10 +3,8 @@
56
57 #if defined(__LP64__)
58 #define __BITS_PER_LONG 64
59 -#define SHIFT_PER_LONG 6
60 #else
61 #define __BITS_PER_LONG 32
62 -#define SHIFT_PER_LONG 5
63 #endif
64
65 #include <asm-generic/bitsperlong.h>
66 --- a/arch/parisc/include/uapi/asm/swab.h
67 +++ b/arch/parisc/include/uapi/asm/swab.h
68 @@ -1,6 +1,7 @@
69 #ifndef _PARISC_SWAB_H
70 #define _PARISC_SWAB_H
71
72 +#include <asm/bitsperlong.h>
73 #include <linux/types.h>
74 #include <linux/compiler.h>
75
76 @@ -38,7 +39,7 @@ static inline __attribute_const__ __u32
77 }
78 #define __arch_swab32 __arch_swab32
79
80 -#if BITS_PER_LONG > 32
81 +#if __BITS_PER_LONG > 32
82 /*
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
86 return x;
87 }
88 #define __arch_swab64 __arch_swab64
89 -#endif /* BITS_PER_LONG > 32 */
90 +#endif /* __BITS_PER_LONG > 32 */
91
92 #endif /* _PARISC_SWAB_H */