From: Greg Kroah-Hartman Date: Tue, 8 Nov 2022 08:10:29 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.9.333~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=408a5128f31ca53d5189ac7b44ddf56caecc1e12;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches 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 --- 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 index 00000000000..1eb2d90eb4a --- /dev/null +++ b/queue-4.14/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch @@ -0,0 +1,83 @@ +From foo@baz Tue Nov 8 09:07:39 AM CET 2022 +From: Masahiro Yamada +Date: Tue, 16 Jul 2019 16:26:57 -0700 +Subject: linux/bits.h: make BIT(), GENMASK(), and friends available in assembly + +From: Masahiro Yamada + +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 +Cc: Catalin Marinas +Cc: Christian Borntraeger +Cc: Heiko Carstens +Cc: Vasily Gorbik +Cc: Vineet Gupta +Cc: Will Deacon +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman +--- + 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 + #include + +-#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 index 00000000000..109c459b3b5 --- /dev/null +++ b/queue-4.14/linux-const.h-move-ul-macro-to-include-linux-const.h.patch @@ -0,0 +1,112 @@ +From foo@baz Tue Nov 8 09:07:39 AM CET 2022 +From: Masahiro Yamada +Date: Tue, 10 Apr 2018 16:36:19 -0700 +Subject: linux/const.h: move UL() macro to include/linux/const.h + +From: Masahiro Yamada + +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 +Acked-by: Guan Xuetao +Acked-by: Catalin Marinas +Acked-by: Russell King +Cc: David Howells +Cc: Geert Uytterhoeven +Cc: Will Deacon +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman +--- + 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 + #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 + + /* +- * 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 + + /* +- * 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 ++ ++#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 index 00000000000..f039c619774 --- /dev/null +++ b/queue-4.14/linux-const.h-prefix-include-guard-of-uapi-linux-const.h-with-_uapi.patch @@ -0,0 +1,106 @@ +From foo@baz Tue Nov 8 09:07:39 AM CET 2022 +From: Masahiro Yamada +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 + +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, 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 +Cc: David Howells +Cc: Will Deacon +Cc: Guan Xuetao +Cc: Geert Uytterhoeven +Cc: Catalin Marinas +Cc: Russell King +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +[nd: resolve trivial conflict due to b732e14e6218b being backported before this] +Signed-off-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman +--- + 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 */ diff --git a/queue-4.14/series b/queue-4.14/series index 08ae8634aca..98a4ac2dc88 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -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