From: Greg Kroah-Hartman Date: Tue, 8 Nov 2022 08:10:53 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.9.333~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=123442e589dc960cb8ece6513cddc236f68a0922;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch --- diff --git a/queue-4.19/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch b/queue-4.19/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch new file mode 100644 index 00000000000..e5f21bd79ae --- /dev/null +++ b/queue-4.19/linux-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch @@ -0,0 +1,83 @@ +From 95b980d62d52c4c1768ee719e8db3efe27ef52b2 Mon Sep 17 00:00:00 2001 +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 +Cc: 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.19/series b/queue-4.19/series index 48bf69056ba..91ac7b06f43 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -44,3 +44,4 @@ 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-bits.h-make-bit-genmask-and-friends-available-in-assembly.patch