]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Nov 2022 08:10:29 +0000 (09:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Nov 2022 08:10:29 +0000 (09:10 +0100)
added patches:
linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch
linux-const.h-move-ul-macro-to-include-linux-const.h.patch
linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch

queue-4.14/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch [new file with mode: 0644]
queue-4.14/linux-const.h-move-ul-macro-to-include-linux-const.h.patch [new file with mode: 0644]
queue-4.14/linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch [new file with mode: 0644]
queue-4.14/series

diff --git a/queue-4.14/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch b/queue-4.14/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch
new file mode 100644 (file)
index 0000000..1eb2d90
--- /dev/null
@@ -0,0 +1,83 @@
+From foo@baz Tue Nov  8 09:07:39 AM CET 2022
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Tue, 16 Jul 2019 16:26:57 -0700
+Subject: linux/bits.h: make BIT(), GENMASK(), and friends available in assembly
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit 95b980d62d52c4c1768ee719e8db3efe27ef52b2 upstream.
+
+BIT(),  GENMASK(), etc. are useful to define register bits of hardware.
+However, low-level code is often written in assembly, where they are
+not available due to the hard-coded 1UL, 0UL.
+
+In fact, in-kernel headers such as arch/arm64/include/asm/sysreg.h
+use _BITUL() instead of BIT() so that the register bit macros are
+available in assembly.
+
+Using macros in include/uapi/linux/const.h have two reasons:
+
+[1] For use in uapi headers
+  We should use underscore-prefixed variants for user-space.
+
+[2] For use in assembly code
+  Since _BITUL() uses UL(1) instead of 1UL, it can be used as an
+  alternative of BIT().
+
+For [2], it is pretty easy to change BIT() etc. for use in assembly.
+
+This allows to replace _BUTUL() in kernel-space headers with BIT().
+
+Link: http://lkml.kernel.org/r/20190609153941.17249-1-yamada.masahiro@socionext.com
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: Catalin Marinas <catalin.marinas@arm.com>
+Cc: Christian Borntraeger <borntraeger@de.ibm.com>
+Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
+Cc: Vasily Gorbik <gor@linux.ibm.com>
+Cc: Vineet Gupta <vgupta@synopsys.com>
+Cc: Will Deacon <will.deacon@arm.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/linux/bits.h |   17 ++++++++++-------
+ 1 file changed, 10 insertions(+), 7 deletions(-)
+
+--- a/include/linux/bits.h
++++ b/include/linux/bits.h
+@@ -1,13 +1,15 @@
+ /* SPDX-License-Identifier: GPL-2.0 */
+ #ifndef __LINUX_BITS_H
+ #define __LINUX_BITS_H
++
++#include <linux/const.h>
+ #include <asm/bitsperlong.h>
+-#define BIT(nr)                       (1UL << (nr))
+-#define BIT_ULL(nr)           (1ULL << (nr))
+-#define BIT_MASK(nr)          (1UL << ((nr) % BITS_PER_LONG))
++#define BIT(nr)                       (UL(1) << (nr))
++#define BIT_ULL(nr)           (ULL(1) << (nr))
++#define BIT_MASK(nr)          (UL(1) << ((nr) % BITS_PER_LONG))
+ #define BIT_WORD(nr)          ((nr) / BITS_PER_LONG)
+-#define BIT_ULL_MASK(nr)      (1ULL << ((nr) % BITS_PER_LONG_LONG))
++#define BIT_ULL_MASK(nr)      (ULL(1) << ((nr) % BITS_PER_LONG_LONG))
+ #define BIT_ULL_WORD(nr)      ((nr) / BITS_PER_LONG_LONG)
+ #define BITS_PER_BYTE         8
+@@ -17,10 +19,11 @@
+  * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
+  */
+ #define GENMASK(h, l) \
+-      (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
++      (((~UL(0)) - (UL(1) << (l)) + 1) & \
++       (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
+ #define GENMASK_ULL(h, l) \
+-      (((~0ULL) - (1ULL << (l)) + 1) & \
+-       (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
++      (((~ULL(0)) - (ULL(1) << (l)) + 1) & \
++       (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
+ #endif        /* __LINUX_BITS_H */
diff --git a/queue-4.14/linux-const.h-move-ul-macro-to-include-linux-const.h.patch b/queue-4.14/linux-const.h-move-ul-macro-to-include-linux-const.h.patch
new file mode 100644 (file)
index 0000000..109c459
--- /dev/null
@@ -0,0 +1,112 @@
+From foo@baz Tue Nov  8 09:07:39 AM CET 2022
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Tue, 10 Apr 2018 16:36:19 -0700
+Subject: linux/const.h: move UL() macro to include/linux/const.h
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit 2dd8a62c647691161a2346546834262597739872 upstream.
+
+ARM, ARM64 and UniCore32 duplicate the definition of UL():
+
+  #define UL(x) _AC(x, UL)
+
+This is not actually arch-specific, so it will be useful to move it to a
+common header.  Currently, we only have the uapi variant for
+linux/const.h, so I am creating include/linux/const.h.
+
+I also added _UL(), _ULL() and ULL() because _AC() is mostly used in
+the form either _AC(..., UL) or _AC(..., ULL).  I expect they will be
+replaced in follow-up cleanups.  The underscore-prefixed ones should
+be used for exported headers.
+
+Link: http://lkml.kernel.org/r/1519301715-31798-4-git-send-email-yamada.masahiro@socionext.com
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
+Acked-by: Catalin Marinas <catalin.marinas@arm.com>
+Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
+Cc: David Howells <dhowells@redhat.com>
+Cc: Geert Uytterhoeven <geert@linux-m68k.org>
+Cc: Will Deacon <will.deacon@arm.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm/include/asm/memory.h       |    6 ------
+ arch/arm64/include/asm/memory.h     |    6 ------
+ arch/unicore32/include/asm/memory.h |    6 ------
+ include/linux/const.h               |    9 +++++++++
+ include/uapi/linux/const.h          |    3 +++
+ 5 files changed, 12 insertions(+), 18 deletions(-)
+ create mode 100644 include/linux/const.h
+
+--- a/arch/arm/include/asm/memory.h
++++ b/arch/arm/include/asm/memory.h
+@@ -22,12 +22,6 @@
+ #include <mach/memory.h>
+ #endif
+-/*
+- * Allow for constants defined here to be used from assembly code
+- * by prepending the UL suffix only with actual C code compilation.
+- */
+-#define UL(x) _AC(x, UL)
+-
+ /* PAGE_OFFSET - the virtual address of the start of the kernel image */
+ #define PAGE_OFFSET           UL(CONFIG_PAGE_OFFSET)
+--- a/arch/arm64/include/asm/memory.h
++++ b/arch/arm64/include/asm/memory.h
+@@ -29,12 +29,6 @@
+ #include <asm/sizes.h>
+ /*
+- * Allow for constants defined here to be used from assembly code
+- * by prepending the UL suffix only with actual C code compilation.
+- */
+-#define UL(x) _AC(x, UL)
+-
+-/*
+  * Size of the PCI I/O space. This must remain a power of two so that
+  * IO_SPACE_LIMIT acts as a mask for the low bits of I/O addresses.
+  */
+--- a/arch/unicore32/include/asm/memory.h
++++ b/arch/unicore32/include/asm/memory.h
+@@ -20,12 +20,6 @@
+ #include <mach/memory.h>
+ /*
+- * Allow for constants defined here to be used from assembly code
+- * by prepending the UL suffix only with actual C code compilation.
+- */
+-#define UL(x) _AC(x, UL)
+-
+-/*
+  * PAGE_OFFSET - the virtual address of the start of the kernel image
+  * TASK_SIZE - the maximum size of a user space task.
+  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
+--- /dev/null
++++ b/include/linux/const.h
+@@ -0,0 +1,9 @@
++#ifndef _LINUX_CONST_H
++#define _LINUX_CONST_H
++
++#include <uapi/linux/const.h>
++
++#define UL(x)         (_UL(x))
++#define ULL(x)                (_ULL(x))
++
++#endif /* _LINUX_CONST_H */
+--- a/include/uapi/linux/const.h
++++ b/include/uapi/linux/const.h
+@@ -22,6 +22,9 @@
+ #define _AT(T,X)      ((T)(X))
+ #endif
++#define _UL(x)                (_AC(x, UL))
++#define _ULL(x)               (_AC(x, ULL))
++
+ #define _BITUL(x)     (_AC(1,UL) << (x))
+ #define _BITULL(x)    (_AC(1,ULL) << (x))
diff --git a/queue-4.14/linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch b/queue-4.14/linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch
new file mode 100644 (file)
index 0000000..f039c61
--- /dev/null
@@ -0,0 +1,106 @@
+From foo@baz Tue Nov  8 09:07:39 AM CET 2022
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+Date: Tue, 10 Apr 2018 16:36:15 -0700
+Subject: linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI
+
+From: Masahiro Yamada <yamada.masahiro@socionext.com>
+
+commit 2a6cc8a6c0cb44baf7df2f64e5090aaf726002c3 upstream.
+
+Patch series "linux/const.h: cleanups of macros such as UL(), _BITUL(),
+BIT() etc", v3.
+
+ARM, ARM64, UniCore32 define UL() as a shorthand of _AC(..., UL).  More
+architectures may introduce it in the future.
+
+UL() is arch-agnostic, and useful. So let's move it to
+include/linux/const.h
+
+Currently, <asm/memory.h> must be included to use UL().  It pulls in more
+bloats just for defining some bit macros.
+
+I posted V2 one year ago.
+
+The previous posts are:
+https://patchwork.kernel.org/patch/9498273/
+https://patchwork.kernel.org/patch/9498275/
+https://patchwork.kernel.org/patch/9498269/
+https://patchwork.kernel.org/patch/9498271/
+
+At that time, what blocked this series was a comment from
+David Howells:
+  You need to be very careful doing this.  Some userspace stuff
+  depends on the guard macro names on the kernel header files.
+
+(https://patchwork.kernel.org/patch/9498275/)
+
+Looking at the code closer, I noticed this is not a problem.
+
+See the following line.
+https://github.com/torvalds/linux/blob/v4.16-rc2/scripts/headers_install.sh#L40
+
+scripts/headers_install.sh rips off _UAPI prefix from guard macro names.
+
+I ran "make headers_install" and confirmed the result is what I expect.
+
+So, we can prefix the include guard of include/uapi/linux/const.h,
+and add a new include/linux/const.h.
+
+This patch (of 4):
+
+I am going to add include/linux/const.h for the kernel space.
+
+Add _UAPI to the include guard of include/uapi/linux/const.h to
+prepare for that.
+
+Please notice the guard name of the exported one will be kept as-is.
+So, this commit has no impact to the userspace even if some userspace
+stuff depends on the guard macro names.
+
+scripts/headers_install.sh processes exported headers by SED, and
+rips off "_UAPI" from guard macro names.
+
+  #ifndef _UAPI_LINUX_CONST_H
+  #define _UAPI_LINUX_CONST_H
+
+will be turned into
+
+  #ifndef _LINUX_CONST_H
+  #define _LINUX_CONST_H
+
+Link: http://lkml.kernel.org/r/1519301715-31798-2-git-send-email-yamada.masahiro@socionext.com
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: David Howells <dhowells@redhat.com>
+Cc: Will Deacon <will.deacon@arm.com>
+Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
+Cc: Geert Uytterhoeven <geert@linux-m68k.org>
+Cc: Catalin Marinas <catalin.marinas@arm.com>
+Cc: Russell King <rmk+kernel@armlinux.org.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+[nd: resolve trivial conflict due to b732e14e6218b being backported before this]
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/uapi/linux/const.h |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/include/uapi/linux/const.h
++++ b/include/uapi/linux/const.h
+@@ -1,8 +1,8 @@
+ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+ /* const.h: Macros for dealing with constants.  */
+-#ifndef _LINUX_CONST_H
+-#define _LINUX_CONST_H
++#ifndef _UAPI_LINUX_CONST_H
++#define _UAPI_LINUX_CONST_H
+ /* Some constant macros are used in both assembler and
+  * C code.  Therefore we cannot annotate them always with
+@@ -30,4 +30,4 @@
+ #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+-#endif /* !(_LINUX_CONST_H) */
++#endif /* _UAPI_LINUX_CONST_H */
index 08ae8634aca326565641684e0a7dc4d6a710930a..98a4ac2dc88d968dc782bf6b38db082f1e955cd7 100644 (file)
@@ -34,3 +34,6 @@ kvm-x86-mask-off-reserved-bits-in-cpuid.80000008h.patch
 kvm-x86-emulator-em_sysexit-should-update-ctxt-mode.patch
 kvm-x86-emulator-introduce-emulator_recalc_and_set_mode.patch
 kvm-x86-emulator-update-the-emulation-mode-after-cr0-write.patch
+linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch
+linux-const.h-move-ul-macro-to-include-linux-const.h.patch
+linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch