]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0065-bitops-Add-clear-set_bit32-to-linux-bitops.h.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0065-bitops-Add-clear-set_bit32-to-linux-bitops.h.patch
CommitLineData
321d628a
FG
1From 2f76ec868c18486b60f1b76428339a2fa0c2e5d8 Mon Sep 17 00:00:00 2001
2From: Andi Kleen <ak@linux.intel.com>
3Date: Fri, 13 Oct 2017 14:56:41 -0700
e4cdf2a5 4Subject: [PATCH 065/241] bitops: Add clear/set_bit32() to linux/bitops.h
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11Add two simple wrappers around set_bit/clear_bit() that accept
12the common case of an u32 array. This avoids writing
13casts in all callers.
14
15Signed-off-by: Andi Kleen <ak@linux.intel.com>
16Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
17Cc: Linus Torvalds <torvalds@linux-foundation.org>
18Cc: Peter Zijlstra <peterz@infradead.org>
19Link: http://lkml.kernel.org/r/20171013215645.23166-2-andi@firstfloor.org
20Signed-off-by: Ingo Molnar <mingo@kernel.org>
21(cherry picked from commit cbe96375025e14fc76f9ed42ee5225120d7210f8)
22Signed-off-by: Andy Whitcroft <apw@canonical.com>
23Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
24(cherry picked from commit 06d31c11519ca0e8f9b7cab857f442ef44dfc1b2)
25Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
26---
27 include/linux/bitops.h | 26 ++++++++++++++++++++++++++
28 1 file changed, 26 insertions(+)
29
30diff --git a/include/linux/bitops.h b/include/linux/bitops.h
31index 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--
682.14.2
69