]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0065-bitops-Add-clear-set_bit32-to-linux-bitops.h.patch
build: reformat existing patches
[pve-kernel.git] / patches / kernel / 0065-bitops-Add-clear-set_bit32-to-linux-bitops.h.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Andi Kleen <ak@linux.intel.com>
3 Date: Fri, 13 Oct 2017 14:56:41 -0700
4 Subject: [PATCH] bitops: Add clear/set_bit32() to linux/bitops.h
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 Add two simple wrappers around set_bit/clear_bit() that accept
12 the common case of an u32 array. This avoids writing
13 casts in all callers.
14
15 Signed-off-by: Andi Kleen <ak@linux.intel.com>
16 Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
17 Cc: Linus Torvalds <torvalds@linux-foundation.org>
18 Cc: Peter Zijlstra <peterz@infradead.org>
19 Link: http://lkml.kernel.org/r/20171013215645.23166-2-andi@firstfloor.org
20 Signed-off-by: Ingo Molnar <mingo@kernel.org>
21 (cherry picked from commit cbe96375025e14fc76f9ed42ee5225120d7210f8)
22 Signed-off-by: Andy Whitcroft <apw@canonical.com>
23 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
24 (cherry picked from commit 06d31c11519ca0e8f9b7cab857f442ef44dfc1b2)
25 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
26 ---
27 include/linux/bitops.h | 26 ++++++++++++++++++++++++++
28 1 file changed, 26 insertions(+)
29
30 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
31 index a83c822c35c2..eb257a96db6d 100644
32 --- a/include/linux/bitops.h
33 +++ b/include/linux/bitops.h
34 @@ -226,6 +226,32 @@ static inline unsigned long __ffs64(u64 word)
35 return __ffs((unsigned long)word);
36 }
37
38 +/*
39 + * clear_bit32 - Clear a bit in memory for u32 array
40 + * @nr: Bit to clear
41 + * @addr: u32 * address of bitmap
42 + *
43 + * Same as clear_bit, but avoids needing casts for u32 arrays.
44 + */
45 +
46 +static __always_inline void clear_bit32(long nr, volatile u32 *addr)
47 +{
48 + clear_bit(nr, (volatile unsigned long *)addr);
49 +}
50 +
51 +/*
52 + * set_bit32 - Set a bit in memory for u32 array
53 + * @nr: Bit to clear
54 + * @addr: u32 * address of bitmap
55 + *
56 + * Same as set_bit, but avoids needing casts for u32 arrays.
57 + */
58 +
59 +static __always_inline void set_bit32(long nr, volatile u32 *addr)
60 +{
61 + set_bit(nr, (volatile unsigned long *)addr);
62 +}
63 +
64 #ifdef __KERNEL__
65
66 #ifndef set_mask_bits
67 --
68 2.14.2
69