llist: introduce llist_entry_safe()
Subsystems (44)
[email protected]
maintainerPATCH 14/102 llist: introduce llist_entry_safe()
From: Alexander Potapenko <[email protected]>
Subject: llist: introduce llist_entry_safe()
Currently llist_for_each_entry() and llist_for_each_entry_safe() iterate until &pos->member != NULL. But when building the kernel with Clang, the compiler assumes &pos->member cannot be NULL if the member's offset is greater than 0. Therefore the loop condition is always true, and the loops become infinite.
To work around this, introduce llist_entry_safe(), which returns NULL for NULL pointers, and additionally check that pos is not NULL in the list iterators before dereferencing it.
---
include/linux/llist.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
include/linux/llist.h renamed from include/linux/llist.h~llist-introduce-llist_entry_safe +19 -7
@@ -88,6 +88,16 @@ static inline void init_llist_head(struccontainer_of (ptr, type, member)/** +* llist_entry_safe - get the struct of this entry without overflowing +* @ptr: the &struct llist_node pointer. +* @type: the type of the struct this is embedded in. +* @member: the name of the llist_node within the struct. + */ +#define llist_entry_safe (ptr, type, member) \ + container_of_safe(ptr, type, member) + + +/** * llist_for_each - iterate over some deleted entries of a lock-less list * @pos: the &struct llist_node to use as a loop cursor * @node: the first entry of deleted list entries
@@ -120,9 +130,10 @@ static inline void init_llist_head(struc* reverse the order by yourself before traversing. */ #define llist_for_each_entry (pos, node, member) \ - for ((pos) = llist_entry((node), typeof(*(pos)), member); \ - &(pos)->member != NULL; \ - (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) + for ((pos) = llist_entry_safe((node), typeof(*(pos)), member); \ + pos != NULL && &(pos)->member != NULL; \ + (pos) = llist_entry_safe((pos)->member.next, \ + typeof(*(pos)), member))/** * llist_for_each_entry_safe - iterate over some deleted entries of lock-less list of given type
@@ -141,10 +152,11 @@ static inline void init_llist_head(struc* you want to traverse from the oldest to the newest, you must * reverse the order by yourself before traversing. */ -#define llist_for_each_entry_safe (pos, n, node, member) \ - for (pos = llist_entry((node), typeof(*pos), member); \ - &pos->member != NULL && \ - (n = llist_entry(pos->member.next, typeof(*n), member), true); \ +#define llist_for_each_entry_safe (pos, n, node, member) \ + for (pos = llist_entry_safe((node), typeof(*pos), member); \ + pos != NULL && &pos->member != NULL && \ + (n = llist_entry_safe(pos->member.next, typeof(*n), member), \ + true); \ pos = n)/**
_
A message that is not in the archive (sent off-list or not yet received): CA+55aFxr2uZADh--vtLYXjcLjNGO5t4jmTWEVZWbRuaJwiocug@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CA+55aFxQRf+U0z6mrAd5QQLWgB2A_mRjY7g9vpZHCSuyjrdhxQ@mail.gmail.com
[ Coming back to this, because it was annoying me ]
Quoted 2 lines · Linus Torvalds
HOWEVER - and this is really annoying - we'd need to use "-std=gnu99/gnu11"
Hmm.
I just tried it again after a long time, and "-std=gnu99" seems to work fine for me on the kernel these days. The old "compound literal" issues we had at some point seem gone.
Maybe we've cleaned everything up that used to cause problems. Or maybe I just mis-remembered and we should have done this long ago?
If we switched the kernel over from gnu89 to gnu99, we could use a couple of modern C features that are really nice. The main one is variable declarations in loops, which isn't just syntactic sugar: it makes it much easier to reduce the scope of variables naturally, but it also makes it easier to do legible macros for for-loops when you can declare your helper variables inside the for-statement.
The one thing I noticed while doing this was that switching to std=gnu99 results in some funky new warnings. In particular, drm has a number of warnings like this:
drivers/gpu/drm/i915/gt/intel_sseu.c: In function ‘intel_sseu_make_rpcs’:
drivers/gpu/drm/i915/gt/intel_sseu.c:64:10: warning: left shift of
negative value [-Wshift-negative-value]
64 | ~(~0 << (hweight8(ctx_sseu.subslice_mask) / 2));
| ^~and that seems to be because c99 allows ones-complement machines to do odd things with left shifts.
It doesn't make any sensible difference on a two's-complement machine, and it's insane that c99 changed the semantics to be worse for something that will never matter, but there you have it.
Language standards people seemingly still not realizing that undefined behavior is a *bad* thing, not a good thing, and adding it for no good reason? Welcome to the mad-house.
Anyway, that warning is easy enough to shut up. Would people mind testing this patch? Does it cause problems on other architectures? Maybe the drm code could even be made to use unsigned values for their shifts?
Because I'd love to finally be able to do things like that
#define llist_for_each_entry(pos, node, member) \
for (struct llist_node *_lptr = (node); \
(pos) = llist_entry(_lptr, typeof(*(pos)), member), !!_lptr; \
_lptr = (pos)->member.next)and not have that odd "member_address_is_nonnull()" because of how we convert back and forth.
It would also allow us to force the caller to pointlessly have to declare a temporary variable for the loop for the safe versions.
I only tested gnu99 - which is sufficient for the above - and didn't see if gnu11 ends up causing more issues.. And I didn't actually test any of the code modifications that this would allow us to do.
Adding Arnd (because he seems to like compiler updates, and works with compiler warnings ;) and the kbuild people and arch list.
Linus
Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
@@ -397,7 +397,7 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) HOSTCC = gcc HOSTCXX = g++ KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \ - -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ + -fomit-frame-pointer -std=gnu99 $(HOST_LFS_CFLAGS) \ $(HOSTCFLAGS) KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
@@ -459,7 +459,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Wno-format-security \ - -std=gnu89 + -std=gnu99 KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL :=
@@ -699,6 +699,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) +KBUILD_CFLAGS += $(call cc-disable-warning, shift-negative-value) ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE KBUILD_CFLAGS += -O2
Quoted 3 lines · Linus Torvalds
I only tested gnu99 - which is sufficient for the above - and didn't see if gnu11 ends up causing more issues..
I see at least no obvious issues with gnu11, so if this works for other architectures too, we should just switch over.
Linus
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
I only tested gnu99 - which is sufficient for the above - and didn't see if gnu11 ends up causing more issues..
I see at least no obvious issues with gnu11, so if this works for other architectures too, we should just switch over.
It would mean bumping GCC version requirements to 4.7. But no objections on my side.
Signature · 1 line
Kirill A. Shutemov
Quoted 7 lines · Linus Torvalds
[ Coming back to this, because it was annoying me ]
Quoted 2 lines · Linus Torvalds
HOWEVER - and this is really annoying - we'd need to use "-std=gnu99/gnu11"
Quoted 8 lines
Hmm.
I just tried it again after a long time, and "-std=gnu99" seems to work fine for me on the kernel these days. The old "compound literal" issues we had at some point seem gone.
Maybe we've cleaned everything up that used to cause problems. Or maybe I just mis-remembered and we should have done this long ago?
Looks like it was fixed soon after the complain:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
Signature · 1 line
Kirill A. Shutemov
Quoted 4 lines · Kirill A. Shutemov
Looks like it was fixed soon after the complain:
Ahh, so there are gcc versions which essentially do this wrong, and I'm not seeing it because it was fixed.
Ho humm. Considering that this was fixed in gcc five years ago, and we already require gc-4.6, and did that two years ago, maybe we can just raise the requirement a bit further.
BUT.
Quoted 1 line · It's not clear which versions are ok with this. In your next email you said:
It would mean bumping GCC version requirements to 4.7.
which I think would be reasonable, but is it actually ok in 4.7?
The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how to check what that "revision=216440" ends up actually meaning.
I have a git tree of gcc, and in that one 216440 is commit d303aeafa9b, but that seems to imply it only made it into 5.1:
[torvalds@i7 gcc]$ git name-rev --tagsd303aeafa9b46e06cd853696acb6345dff51a6b9
d303aeafa9b46e06cd853696acb6345dff51a6b9 tags/gcc-5_1_0-release~3943
so we'd have to jump forward a _lot_.
That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm not sure we can jump to 5.1.
Although maybe we should be a _lot_ more aggressive about gcc versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22, 2015.
Linus
Quoted 13 lines · Linus Torvalds
Quoted 4 lines · Kirill A. Shutemov
Looks like it was fixed soon after the complain:
Ahh, so there are gcc versions which essentially do this wrong, and I'm not seeing it because it was fixed.
Ho humm. Considering that this was fixed in gcc five years ago, and we already require gc-4.6, and did that two years ago, maybe we can just raise the requirement a bit further.
Quoted 7 lines
BUT.
Quoted 1 line · It's not clear which versions are ok with this. In your next email you said:
It would mean bumping GCC version requirements to 4.7.
which I think would be reasonable, but is it actually ok in 4.7?
I think, not. I don't have 4.7 around, but 4.9.3 has the issue if -std=gnu99 is used.
Quoted 10 lines
The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how to check what that "revision=216440" ends up actually meaning.
I have a git tree of gcc, and in that one 216440 is commit
d303aeafa9b, but that seems to imply it only made it into 5.1:[torvalds@i7 gcc]$ git name-rev --tags
d303aeafa9b46e06cd853696acb6345dff51a6b9
d303aeafa9b46e06cd853696acb6345dff51a6b9tags/gcc-5_1_0-release~3943
Quoted 8 lines
so we'd have to jump forward a _lot_.
That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm not sure we can jump to 5.1.
Although maybe we should be a _lot_ more aggressive about gcc versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22, 2015.
5.4.1 builds kernel fine for me with allmodconfig (minus retpoline which requires compiler support). Both -std=gnu99 and -std=gnu11.
Note that GCC has changed their version scheme. 5.4.1 is bug-fix release of GCC-5.
Signature · 1 line
Kirill A. Shutemov
Quoted 45 lines · Kirill A. Shutemov
Quoted 13 lines · Linus Torvalds
Quoted 4 lines · Kirill A. Shutemov
Looks like it was fixed soon after the complain:
Ahh, so there are gcc versions which essentially do this wrong, and I'm not seeing it because it was fixed.
Ho humm. Considering that this was fixed in gcc five years ago, and we already require gc-4.6, and did that two years ago, maybe we can just raise the requirement a bit further.
Quoted 7 lines
BUT.
Quoted 1 line · It's not clear which versions are ok with this. In your next email you said:
It would mean bumping GCC version requirements to 4.7.
which I think would be reasonable, but is it actually ok in 4.7?
I think, not. I don't have 4.7 around, but 4.9.3 has the issue if -std=gnu99 is used.
Quoted 10 lines
The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how to check what that "revision=216440" ends up actually meaning.
I have a git tree of gcc, and in that one 216440 is commit
d303aeafa9b, but that seems to imply it only made it into 5.1:[torvalds@i7 gcc]$ git name-rev --tags
d303aeafa9b46e06cd853696acb6345dff51a6b9
d303aeafa9b46e06cd853696acb6345dff51a6b9tags/gcc-5_1_0-release~3943Quoted 8 lines
so we'd have to jump forward a _lot_.
That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm not sure we can jump to 5.1.
Although maybe we should be a _lot_ more aggressive about gcc versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22, 2015.
Quoted 5 lines
5.4.1 builds kernel fine for me with allmodconfig (minus retpoline which requires compiler support). Both -std=gnu99 and -std=gnu11.
Note that GCC has changed their version scheme. 5.4.1 is bug-fix release of GCC-5.
I tested -std=gnu99 for ARM
with pre-built Linaro toolchains.
GCC 4.9.4 was NG,
GCC 5.3.1 was OK.
If we increase the minimal GCC version, we might end up with dropping more architecture.
I can no longer get the toolchains for hexagon, unicore32.
https://mirrors.edge.kernel.org/pub/tools/crosstool/
provides hexagon compilers, but only for GCC 4.6.1
Signature · 2 lines
Best Regards Masahiro Yamada
Arnd Bergmann
maintainerQuoted 3 lines · Masahiro Yamada
Quoted 1 line · Kirill A. Shutemov
On Wed, Oct 16, 2019 at 04:29:54PM -0700, Linus Torvalds wrote:
I can no longer get the toolchains for hexagon, unicore32.
Guan Xuetao said in 2018 that he'd try to make a new gcc available, but I don't think anything ever came out of that.
Quoted 2 lines
https://mirrors.edge.kernel.org/pub/tools/crosstool/
provides hexagon compilers, but only for GCC 4.6.1
For all I know, Qualcomm use clang internally to build hexagon kernels, it may be a good idea to try again with clang-9. The last I know about it, clang itself should have all the required patches, but there were still issues with using llvm as a binutils replacement (as and/or ld). Not sure if that has been resolved by now.
Arnd
Quoted 5 lines · Masahiro Yamada
I tested -std=gnu99 for ARM with pre-built Linaro toolchains.
GCC 4.9.4 was NG,
GCC 5.3.1 was OK.
Ok, so the gcc-5.1 cut-off from my gcc git tree conversion looks to be the right one. I wasn't sure how official/complete the git conversion was.
Quoted 2 lines
If we increase the minimal GCC version, we might end up with dropping more architecture.
That I wouldn't worry about. If some architecture can't get a gcc version from the last five years, I think we _should_ drop it.
Historically, the problem has more been distro gcc versions. An unmaintained architecture that has a compiler that is ancient I don't much care about, but if we lose testers that use ancient distros, that loses real coverage.
That's true even if it's just one or two actual users that upgrade kernels - we found a real bug not that long ago because rmk used some ancient Debian install with a new kernel. That's the kind of odd use we want to encourage, and that matters. Hexagon? Not so much.
Although I think rmk actually had a new compiler and cross-built the new kernel, so that likely wasn't the issue in _that_ particular case, but in other cases it might have been.
Linus
Arnd Bergmann
maintainerQuoted 5 lines · Linus Torvalds
Quoted 3 lines · Kirill A. Shutemov
Looks like it was fixed soon after the complain:
Quoted 8 lines
Quoted 1 line
Ahh, so there are gcc versions which essentially do this wrong, and I'm not seeing it because it was fixed.
Ho humm. Considering that this was fixed in gcc five years ago, and we already require gc-4.6, and did that two years ago, maybe we can just raise the requirement a bit further.
If the compound literal extension is now all that's keeping us from moving to gnu99, the alternative would be to change the kernel not to use compound literals.
I think some other gnu99 incompatibilities were fixed by the clang patches, such as marking inline as __gnu_inline, and other problems were avoiding by making gcc-4.5 the minimum.
I've tried it out now, and found that we do use compound literals in some important code, but the number of instances is small enough that we can actually rewrite them all.
Just getting the defconfig (x86-64 and arm32) building with "gcc-4.9 --std=gnu89" takes changes to around 50 files, though at least one driver (i915 gpu) needs significant additional changes beyond this:
Makefile | 2 +- arch/x86/boot/compressed/acpi.c | 4 +- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/include/asm/pgtable_types.h | 59 ++++++++++++---------- arch/x86/include/asm/processor.h | 4 +- arch/x86/include/asm/uaccess.h | 3 +- arch/x86/mm/pat_rbtree.c | 2 +- arch/x86/platform/efi/quirks.c | 9 ++-- block/partitions/efi.c | 4 +- drivers/acpi/numa.c | 2 +- drivers/firmware/efi/efi.c | 4 +- drivers/firmware/efi/libstub/fdt.c | 2 +- drivers/firmware/efi/libstub/tpm.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 +- drivers/input/mouse/elantech.c | 22 ++++---- .../broadcom/brcm80211/brcmfmac/firmware.c | 2 +- drivers/soc/tegra/pmc.c | 8 +-- fs/proc/root.c | 2 +- include/linux/capability.h | 17 ++++--- include/linux/cpumask.h | 8 +-- include/linux/efi.h | 2 +- include/linux/futex.h | 2 +- include/linux/jump_label.h | 4 +- include/linux/nodemask.h | 20 ++++---- include/linux/property.h | 10 ++-- include/linux/rbtree.h | 7 ++- include/linux/rwlock.h | 2 +- include/linux/rwlock_types.h | 4 +- include/linux/sched/signal.h | 2 +- include/linux/spinlock.h | 2 +- include/linux/spinlock_types.h | 4 +- include/linux/uidgid.h | 13 ++++- include/uapi/linux/uuid.h | 8 +-- init/init_task.c | 4 +- kernel/audit.c | 2 +- kernel/capability.c | 2 +- kernel/cred.c | 24 ++++----- kernel/events/uprobes.c | 2 +- kernel/futex.c | 2 +- kernel/power/swap.c | 2 +- kernel/trace/trace_clock.c | 2 +- kernel/umh.c | 4 +- kernel/user.c | 6 +-- mm/backing-dev.c | 2 +- mm/init-mm.c | 2 +- mm/page_alloc.c | 2 +- mm/vmalloc.c | 4 +- net/core/fib_rules.c | 4 +- net/rds/cong.c | 2 +- security/integrity/iint.c | 2 +- security/keys/process_keys.c | 2 +- 51 files changed, 169 insertions(+), 141 deletions(-)
Arnd Bergmann
maintainerRFC PATCH 1/1 allow building with --std=gnu99
Any variable intialized statically to a gnu89 compound literal like
static struct foo x = (struct foo){};
causes a build failure in --std=gnu99 with gcc-4.9 or earlier. Later gcc versions and clang accept it as an extension the same was with --std=gnu89.
Change enough of the kernel to allow building a 'defconfig' kernel on x86 and arm, by turning the compound literals into struct initializers. As many compound literals are defined in macros, that means we now need two versions of them -- one with the cast for use in assignments, and one without the cast as a struct initializer.
A lot of this does make the code uglier, and more changes are needed to fix the rest of the kernel, but this should give an overview of what is still needed.
--- Makefile | 2 +- arch/x86/boot/compressed/acpi.c | 4 +- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/include/asm/pgtable_types.h | 59 +++++++++++-------- arch/x86/include/asm/processor.h | 4 +- arch/x86/include/asm/uaccess.h | 3 +- arch/x86/mm/pat_rbtree.c | 2 +- arch/x86/platform/efi/quirks.c | 9 ++- block/partitions/efi.c | 4 +- drivers/acpi/numa.c | 2 +- drivers/firmware/efi/efi.c | 4 +- drivers/firmware/efi/libstub/fdt.c | 2 +- drivers/firmware/efi/libstub/tpm.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 +- drivers/input/mouse/elantech.c | 22 +++---- .../broadcom/brcm80211/brcmfmac/firmware.c | 2 +- drivers/soc/tegra/pmc.c | 8 +-- fs/proc/root.c | 2 +- include/linux/capability.h | 17 ++++-- include/linux/cpumask.h | 8 +-- include/linux/efi.h | 2 +- include/linux/futex.h | 2 +- include/linux/jump_label.h | 4 +- include/linux/nodemask.h | 20 ++++--- include/linux/property.h | 10 ++-- include/linux/rbtree.h | 7 ++- include/linux/rwlock.h | 2 +- include/linux/rwlock_types.h | 4 +- include/linux/sched/signal.h | 2 +- include/linux/spinlock.h | 2 +- include/linux/spinlock_types.h | 4 +- include/linux/uidgid.h | 13 +++- include/uapi/linux/uuid.h | 8 ++- init/init_task.c | 4 +- kernel/audit.c | 2 +- kernel/capability.c | 2 +- kernel/cred.c | 24 ++++---- kernel/events/uprobes.c | 2 +- kernel/futex.c | 2 +- kernel/power/swap.c | 2 +- kernel/trace/trace_clock.c | 2 +- kernel/umh.c | 4 +- kernel/user.c | 6 +- mm/backing-dev.c | 2 +- mm/init-mm.c | 2 +- mm/page_alloc.c | 2 +- mm/vmalloc.c | 4 +- net/core/fib_rules.c | 4 +- net/rds/cong.c | 2 +- security/integrity/iint.c | 2 +- security/keys/process_keys.c | 2 +- 51 files changed, 169 insertions(+), 141 deletions(-)
Makefile +1 -1
@@ -459,7 +459,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Wno-format-security \ - -std=gnu89 + -std=gnu99 KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL :=
arch/x86/boot/compressed/acpi.c +2 -2
@@ -79,9 +79,9 @@ __efi_get_rsdp_addr(unsigned long config_tables, unsigned int nr_tables, table = tbl->table; } -if (!(efi_guidcmp (guid,ACPI_TABLE_GUID ))) +if (!(efi_guidcmp (guid, (guid_t )ACPI_TABLE_GUID ))) rsdp_addr = table; -else if (!(efi_guidcmp (guid,ACPI_20_TABLE_GUID ))) +else if (!(efi_guidcmp (guid, (guid_t )ACPI_20_TABLE_GUID )))return table; }#endif
arch/x86/entry/vsyscall/vsyscall_64.c +1 -1
@@ -308,7 +308,7 @@ static const struct vm_operations_struct gate_vma_ops = {static struct vm_area_struct gate_vma__ro_after_init = { .vm_start =VSYSCALL_ADDR , .vm_end =VSYSCALL_ADDR +PAGE_SIZE , - .vm_page_prot =PAGE_READONLY_EXEC , + .vm_page_prot = { __PAGE_READONLY_EXEC }, .vm_flags =VM_READ |VM_EXEC , .vm_ops = &gate_vma_ops, };
arch/x86/include/asm/pgtable_types.h +33 -26
77 lines not on this page · raw message
arch/x86/include/asm/processor.h +2 -2
@@ -842,7 +842,7 @@ static inline void spin_lock_prefetch(const void *x) .sp0 = TOP_OF_INIT_STACK, \ .sysenter_cs = __KERNEL_CS, \ .io_bitmap_ptr = NULL, \ - .addr_limit = KERNEL_DS, \ + .addr_limit = {__KERNEL_ADDR_LIMIT}, \ }#define KSTK_ESP (task) (task_pt_regs(task)->sp)
@@ -887,7 +887,7 @@ static inline void spin_lock_prefetch(const void *x)#define STACK_TOP_MAX TASK_SIZE_MAX#define INIT_THREAD { \ - .addr_limit = KERNEL_DS, \ + .addr_limit = {__KERNEL_ADDR_LIMIT}, \ }extern unsigned long KSTK_ESP (struct task_struct *task);
arch/x86/include/asm/uaccess.h +2 -1
@@ -22,7 +22,8 @@#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) }) -#define KERNEL_DS MAKE_MM_SEG(-1UL) +#define __KERNEL_ADDR_LIMIT (-1UL) +#define KERNEL_DS MAKE_MM_SEG(__KERNEL_ADDR_LIMIT)#define USER_DS MAKE_MM_SEG(TASK_SIZE_MAX)#define get_fs () (current->thread.addr_limit)
arch/x86/mm/pat_rbtree.c +1 -1
@@ -34,7 +34,7 @@* memtype_lock protects the rbtree. */ -static struct rb_root memtype_rbroot =RB_ROOT ; +static struct rb_root memtype_rbroot = __RB_ROOT;static int is_node_overlap (struct memtype *node,u64 start,u64 end) {
arch/x86/platform/efi/quirks.c +4 -5
@@ -20,8 +20,7 @@#define EFI_MIN_RESERVE 5120 -#define EFI_DUMMY_GUID \ - EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9) +static guid_t efi_dummy_guid =EFI_GUID (0x4424ac57 ,0xbe4b ,0x47dd ,0x9e ,0x97 ,0xed ,0x50 ,0xf0 ,0x9f ,0x92 ,0xa9 );#define QUARK_CSH_SIGNATURE 0x5f435348/* _CSH */ #define QUARK_SECURITY_HEADER_SIZE 0x400
@@ -107,7 +106,7 @@ early_param("efi_no_storage_paranoia", setup_storage_paranoia);void efi_delete_dummy_variable (void ) { efi.set_variable_nonblocking ((efi_char16_t *)efi_dummy_name, - &EFI_DUMMY_GUID , + &efi_dummy_guid,EFI_VARIABLE_NON_VOLATILE |EFI_VARIABLE_BOOTSERVICE_ACCESS |EFI_VARIABLE_RUNTIME_ACCESS ,0 ,NULL );
@@ -184,7 +183,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,return EFI_OUT_OF_RESOURCES ; status = efi.set_variable((efi_char16_t *)efi_dummy_name, - &EFI_DUMMY_GUID, + &efi_dummy_guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
@@ -545,7 +544,7 @@ int __init efi_reuse_config(u64 tables, int nr_tables) guid = ((efi_config_table_64_t *)p)->guid; -if (!efi_guidcmp (guid,SMBIOS_TABLE_GUID )) +if (!efi_guidcmp (guid, (guid_t )SMBIOS_TABLE_GUID )) ((efi_config_table_64_t *)p)->table = data->smbios; p += sz; }
block/partitions/efi.c +2 -2
@@ -462,7 +462,7 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,static inline int is_pte_valid (const gpt_entry *pte,const u64 lastlba) { -if ((!efi_guidcmp (pte->partition_type_guid,NULL_GUID )) || +if ((!efi_guidcmp (pte->partition_type_guid, (guid_t )NULL_GUID )) ||le64_to_cpu (pte->starting_lba) > lastlba ||le64_to_cpu (pte->ending_lba) > lastlba)return 0 ;
@@ -704,7 +704,7 @@ int efi_partition(struct parsed_partitions *state)put_partition (state, i+1 , start * ssz, size * ssz);/* If this is a RAID volume, tell md */ -if (!efi_guidcmp (ptes[i].partition_type_guid,PARTITION_LINUX_RAID_GUID )) +if (!efi_guidcmp (ptes[i].partition_type_guid, (guid_t )PARTITION_LINUX_RAID_GUID )) state->parts[i +1 ].flags =ADDPART_FLAG_RAID ; info = &state->parts[i +1 ].info;
drivers/acpi/numa.c +1 -1
@@ -18,7 +18,7 @@#include <linux/nodemask.h> #include <linux/topology.h> -static nodemask_t nodes_found_map =NODE_MASK_NONE ; +static nodemask_t nodes_found_map = __NODE_MASK_NONE;/* maps to convert between proximity domain and logical node ID */ static int pxm_to_node_map[MAX_PXM_DOMAINS ]
drivers/firmware/efi/efi.c +2 -2
@@ -57,7 +57,7 @@ struct efi __read_mostly efi = {EXPORT_SYMBOL (efi);struct mm_struct efi_mm = { - .mm_rb =RB_ROOT , + .mm_rb = __RB_ROOT, .mm_users =ATOMIC_INIT (2 ), .mm_count =ATOMIC_INIT (1 ), .mmap_sem =__RWSEM_INITIALIZER (efi_mm.mmap_sem),
@@ -484,7 +484,7 @@ static __init int match_config_table(efi_guid_t *guid,int i;if (table_types) { -for (i =0 ;efi_guidcmp (table_types[i].guid,NULL_GUID ); i++) { +for (i =0 ;efi_guidcmp (table_types[i].guid, (guid_t )NULL_GUID ); i++) {if (!efi_guidcmp (*guid, table_types[i].guid)) { *(table_types[i].ptr) = table;if (table_types[i].name)
drivers/firmware/efi/libstub/fdt.c +1 -1
@@ -365,7 +365,7 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) {void *fdt; - fdt =get_efi_config_table (sys_table,DEVICE_TREE_GUID ); + fdt =get_efi_config_table (sys_table, (guid_t )DEVICE_TREE_GUID );if (!fdt)return NULL ;
drivers/firmware/efi/libstub/tpm.c +1 -1
@@ -141,7 +141,7 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg)* final events structure, and if so how much space they take up */ final_events_table =get_efi_config_table (sys_table_arg, -LINUX_EFI_TPM_FINAL_LOG_GUID ); + (guid_t )LINUX_EFI_TPM_FINAL_LOG_GUID );if (final_events_table && final_events_table->nr_events) {struct tcg_pcr_event2_head *header;int offset;
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1 -1
@@ -61,7 +61,7 @@ struct adreno_rev { };#define ADRENO_REV (core, major, minor, patchid) \ - ((struct adreno_rev){ core, major, minor, patchid }) + { core, major, minor, patchid }struct adreno_gpu_funcs {struct msm_gpu_funcs base;
drivers/input/mouse/elantech.c +11 -11
@@ -1792,36 +1792,36 @@ static int elantech_create_smbus(struct psmouse *psmouse, smbus_board.properties = i2c_props; - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-size-x" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-size-x" , info->x_max +1 ); - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-size-y" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-size-y" , info->y_max +1 ); - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-min-x" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-min-x" , info->x_min); - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-min-y" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-min-y" , info->y_min);if (info->x_res) - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-x-mm" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-x-mm" , (info->x_max +1 ) / info->x_res);if (info->y_res) - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("touchscreen-y-mm" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("touchscreen-y-mm" , (info->y_max +1 ) / info->y_res);if (info->has_trackpoint) - i2c_props[idx++] =PROPERTY_ENTRY_BOOL ("elan,trackpoint" ); + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_BOOL ("elan,trackpoint" );if (info->has_middle_button) - i2c_props[idx++] =PROPERTY_ENTRY_BOOL ("elan,middle-button" ); + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_BOOL ("elan,middle-button" );if (info->x_traces) - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("elan,x_traces" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("elan,x_traces" , info->x_traces);if (info->y_traces) - i2c_props[idx++] =PROPERTY_ENTRY_U32 ("elan,y_traces" , + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_U32 ("elan,y_traces" , info->y_traces);if (elantech_is_buttonpad (info)) - i2c_props[idx++] =PROPERTY_ENTRY_BOOL ("elan,clickpad" ); + i2c_props[idx++] = (struct property_entry )PROPERTY_ENTRY_BOOL ("elan,clickpad" );return psmouse_smbus_init (psmouse, &smbus_board,NULL ,0 , false, leave_breadcrumbs);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +1 -1
@@ -472,7 +472,7 @@ static u8 *brcmf_fw_nvram_from_efi(size_t *data_len_ret)return NULL ;memcpy (&nvram_efivar->var.VariableName, name,sizeof (name)); - nvram_efivar->var.VendorGuid =EFI_GUID (0x74b00bd9 ,0x805a ,0x4d61 , + nvram_efivar->var.VendorGuid = (guid_t )EFI_GUID (0x74b00bd9 ,0x805a ,0x4d61 ,0xb5 ,0x1f ,0x43 ,0x26 ,0x81 ,0x23 ,0xd1 ,0x13 );
drivers/soc/tegra/pmc.c +4 -4
@@ -2378,18 +2378,18 @@ static const u8 tegra124_cpu_powergates[] = { };#define TEGRA_IO_PAD (_id, _dpd, _voltage, _name) \ - ((struct tegra_io_pad_soc) { \ + { \ .id = (_id), \ .dpd = (_dpd), \ .voltage = (_voltage), \ .name = (_name), \ - }) + }#define TEGRA_IO_PIN_DESC (_id, _dpd, _voltage, _name) \ - ((struct pinctrl_pin_desc) { \ + { \ .number = (_id), \ .name = (_name) \ - }) + }#define TEGRA124_IO_PAD_TABLE (_pad) \/* .id .dpd .voltage .name */ \
fs/proc/root.c +1 -1
@@ -294,7 +294,7 @@ struct proc_dir_entry proc_root = { .proc_iops = &proc_root_inode_operations, .proc_fops = &proc_root_operations, .parent = &proc_root, - .subdir = RB_ROOT, + .subdir = __RB_ROOT, .name = "/proc", };
include/linux/capability.h +11 -6
@@ -82,14 +82,19 @@ extern const kernel_cap_t __cap_init_eff_set;#define CAP_LAST_U32 ((_KERNEL_CAPABILITY_U32S) - 1)#define CAP_LAST_U32_VALID_MASK (CAP_TO_MASK(CAP_LAST_CAP + 1) -1) -# define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }}) -# define CAP_FULL_SET ((kernel_cap_t){{ ~0, CAP_LAST_U32_VALID_MASK }}) -# define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \ +# define __CAP_EMPTY_SET {{ 0, 0 }} +# define __CAP_FULL_SET {{ ~0, CAP_LAST_U32_VALID_MASK }} +# define __CAP_FS_SET {{ CAP_FS_MASK_B0 \ | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \ - CAP_FS_MASK_B1 } }) -# define CAP_NFSD_SET ((kernel_cap_t){{ CAP_FS_MASK_B0 \ + CAP_FS_MASK_B1 } } +# define __CAP_NFSD_SET {{ CAP_FS_MASK_B0 \ | CAP_TO_MASK(CAP_SYS_RESOURCE), \ - CAP_FS_MASK_B1 } }) + CAP_FS_MASK_B1 } } + +# define CAP_EMPTY_SET ((kernel_cap_t)__CAP_EMPTY_SET) +# define CAP_FULL_SET ((kernel_cap_t)__CAP_FULL_SET) +# define CAP_FS_SET ((kernel_cap_t)__CAP_FS_SET) +# define CAP_NFSD_SET ((kernel_cap_t)__CAP_NFSD_SET)#endif /* _KERNEL_CAPABILITY_U32S != 2 */
include/linux/cpumask.h +4 -4
@@ -919,24 +919,24 @@ cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)#if NR_CPUS <=BITS_PER_LONG #define CPU_MASK_ALL \ -(cpumask_t) { { \ +{ { \ [BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \ } }#else #define CPU_MASK_ALL \ -(cpumask_t) { { \ +{ { \ [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL, \ [BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS) \ } }#endif /* NR_CPUS > BITS_PER_LONG */ #define CPU_MASK_NONE \ -(cpumask_t) { { \ +{ { \ [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \ } }#define CPU_MASK_CPU0 \ -(cpumask_t) { { \ +{ { \ [0] = 1UL \ } }
include/linux/efi.h +1 -1
@@ -64,7 +64,7 @@ typedef void *efi_handle_t;typedef guid_t efi_guid_t __aligned(__alignof__(u32)) ;#define EFI_GUID (a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ - GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) + __GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)/* * Generic EFI table header
include/linux/futex.h +1 -1
@@ -45,7 +45,7 @@ union futex_key { } both; }; -#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } } +#define FUTEX_KEY_INIT { .both = { .ptr = NULL } }#ifdef CONFIG_FUTEX extern void exit_robust_list (struct task_struct *curr);
include/linux/jump_label.h +2 -2
@@ -351,8 +351,8 @@ struct static_key_false {struct static_key key; }; -#define STATIC_KEY_TRUE_INIT (struct static_key_true) { .key = STATIC_KEY_INIT_TRUE, } -#define STATIC_KEY_FALSE_INIT (struct static_key_false){ .key = STATIC_KEY_INIT_FALSE, } +#define STATIC_KEY_TRUE_INIT { .key = STATIC_KEY_INIT_TRUE, } +#define STATIC_KEY_FALSE_INIT { .key = STATIC_KEY_INIT_FALSE, }#define DEFINE_STATIC_KEY_TRUE (name) \ struct static_key_true name = STATIC_KEY_TRUE_INIT
include/linux/nodemask.h +11 -9
@@ -306,25 +306,27 @@ static inline int __first_unset_node(const nodemask_t *maskp)#if MAX_NUMNODES <=BITS_PER_LONG -#define NODE_MASK_ALL \ -((nodemask_t) { { \ +#define __NODE_MASK_ALL \ +{ { \ [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \ -} }) +} }#else -#define NODE_MASK_ALL \ -((nodemask_t) { { \ +#define __NODE_MASK_ALL \ +{ { \ [0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL, \ [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \ -} }) +} }#endif +#define NODE_MASK_ALL (((nodemask_t)__MODE_MASK_ALL) -#define NODE_MASK_NONE \ -((nodemask_t) { { \ +#define __NODE_MASK_NONE \ +{ { \ [0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL \ -} }) +} } +#define NODE_MASK_NONE ((nodemask_t)__NODE_MASK_NONE)#define nodes_addr (src) ((src).bits)
include/linux/property.h +5 -5
@@ -258,7 +258,7 @@ struct property_entry {*/ #define PROPERTY_ENTRY_INTEGER_ARRAY (_name_, _type_, _Type_, _val_) \ -(struct property_entry) { \ +{ \ .name = _name_, \ .length = ARRAY_SIZE(_val_) * sizeof(_type_), \ .is_array = true, \
@@ -276,7 +276,7 @@ struct property_entry { PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, U64, _val_)#define PROPERTY_ENTRY_STRING_ARRAY (_name_, _val_) \ -(struct property_entry) { \ +{ \ .name = _name_, \ .length = ARRAY_SIZE(_val_) * sizeof(const char *), \ .is_array = true, \
@@ -285,7 +285,7 @@ struct property_entry { }#define PROPERTY_ENTRY_INTEGER (_name_, _type_, _Type_, _val_) \ -(struct property_entry) { \ +{ \ .name = _name_, \ .length = sizeof(_type_), \ .type = DEV_PROP_##_Type_, \
@@ -302,7 +302,7 @@ struct property_entry { PROPERTY_ENTRY_INTEGER(_name_, u64, U64, _val_)#define PROPERTY_ENTRY_STRING (_name_, _val_) \ -(struct property_entry) { \ +{ \ .name = _name_, \ .length = sizeof(const char *), \ .type = DEV_PROP_STRING, \
@@ -310,7 +310,7 @@ struct property_entry { }#define PROPERTY_ENTRY_BOOL (_name_) \ -(struct property_entry) { \ +{ \ .name = _name_, \ }
include/linux/rbtree.h +5 -2
@@ -34,7 +34,9 @@ struct rb_root {#define rb_parent (r) ((struct rb_node *)((r)->__rb_parent_color & ~3)) -#define RB_ROOT (struct rb_root) { NULL, } +#define __RB_ROOT { NULL, } +#define RB_ROOT (struct rb_root) __RB_ROOT +#define DEFINE_RB_ROOT (name) struct rb_root name = __RB_ROOT#define rb_entry (ptr, type, member) container_of(ptr, type, member)#define RB_EMPTY_ROOT (root) (READ_ONCE((root)->rb_node) == NULL)
@@ -127,7 +129,8 @@ struct rb_root_cached {struct rb_node *rb_leftmost; }; -#define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL } +#define __RB_ROOT_CACHED { {NULL, }, NULL } +#define RB_ROOT_CACHED (struct rb_root_cached)__RB_ROOT_CACHED/* Same as rb_first(), but O(1) */ #define rb_first_cached (root) (root)->rb_leftmost
include/linux/rwlock.h +1 -1
@@ -25,7 +25,7 @@ do { \ } while (0)#else # define rwlock_init (lock) \ - do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0) + do { *(lock) = (rwlock_t)__RW_LOCK_UNLOCKED(lock); } while (0)#endif #ifdef CONFIG_DEBUG_SPINLOCK
include/linux/rwlock_types.h +2 -2
@@ -29,14 +29,14 @@ typedef struct {#ifdef CONFIG_DEBUG_SPINLOCK #define __RW_LOCK_UNLOCKED (lockname) \ - (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ + { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ .magic = RWLOCK_MAGIC, \ .owner = SPINLOCK_OWNER_INIT, \ .owner_cpu = -1, \ RW_DEP_MAP_INIT(lockname) }#else #define __RW_LOCK_UNLOCKED (lockname) \ - (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ + { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ RW_DEP_MAP_INIT(lockname) }#endif
include/linux/sched/signal.h +1 -1
@@ -49,7 +49,7 @@ struct task_cputime_atomic { };#define INIT_CPUTIME_ATOMIC \ - (struct task_cputime_atomic) { \ + { \ .utime = ATOMIC64_INIT(0), \ .stime = ATOMIC64_INIT(0), \ .sum_exec_runtime = ATOMIC64_INIT(0), \
include/linux/spinlock.h +1 -1
@@ -103,7 +103,7 @@ do { \#else # define raw_spin_lock_init (lock) \ - do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0) + do { *(lock) = (raw_spinlock_t) __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)#endif #define raw_spin_is_locked (lock) arch_spin_is_locked(&(lock)->raw_lock)
include/linux/spinlock_types.h +2 -2
@@ -54,7 +54,7 @@ typedef struct raw_spinlock { SPIN_DEP_MAP_INIT(lockname) }#define __RAW_SPIN_LOCK_UNLOCKED (lockname) \ - (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname) + __RAW_SPIN_LOCK_INITIALIZER(lockname)#define DEFINE_RAW_SPINLOCK (x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x)
@@ -76,7 +76,7 @@ typedef struct spinlock { { { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } }#define __SPIN_LOCK_UNLOCKED (lockname) \ - (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname) + __SPIN_LOCK_INITIALIZER(lockname)#define DEFINE_SPINLOCK (x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
include/linux/uidgid.h +11 -2
@@ -27,8 +27,11 @@ typedef struct {gid_t val; } kgid_t; -#define KUIDT_INIT (value) (kuid_t){ value } -#define KGIDT_INIT (value) (kgid_t){ value } +#define __KUIDT_INIT (value) { value } +#define __KGIDT_INIT (value) { value } + +#define KUIDT_INIT (value) (kuid_t)__KUIDT_INIT(value) +#define KGIDT_INIT (value) (kgid_t)__KGIDT_INIT(value)#ifdef CONFIG_MULTIUSER static inline uid_t __kuid_val (kuid_t uid)
@@ -52,6 +55,12 @@ static inline gid_t __kgid_val(kgid_t gid) }#endif +#define __GLOBAL_ROOT_UID __KUIDT_INIT(0) +#define __GLOBAL_ROOT_GID __KGIDT_INIT(0) + +#define __INVALID_UID __KUIDT_INIT(-1) +#define __INVALID_GID __KGIDT_INIT(-1) +#define GLOBAL_ROOT_UID KUIDT_INIT(0)#define GLOBAL_ROOT_GID KGIDT_INIT(0)
include/uapi/linux/uuid.h +5 -3
@@ -24,12 +24,14 @@ typedef struct {__u8 b[16 ]; } guid_t; -#define GUID_INIT (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ -((guid_t) \ +#define __GUID_INIT (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ (b) & 0xff, ((b) >> 8) & 0xff, \ (c) & 0xff, ((c) >> 8) & 0xff, \ - (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }} + +#define GUID_INIT (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ + __GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)/* backwards compatibility, don't use in new code */ typedef guid_t uuid_le ;
init/init_task.c +2 -2
@@ -122,7 +122,7 @@ struct task_struct init_task .thread_group = LIST_HEAD_INIT(init_task.thread_group), .thread_node = LIST_HEAD_INIT(init_signals.thread_head),#ifdef CONFIG_AUDIT - .loginuid = INVALID_UID, + .loginuid = __INVALID_UID, .sessionid = AUDIT_SID_UNSET,#endif #ifdef CONFIG_PERF_EVENTS
@@ -144,7 +144,7 @@ struct task_struct init_task .mems_allowed_seq = SEQCNT_ZERO(init_task.mems_allowed_seq),#endif #ifdef CONFIG_RT_MUTEXES - .pi_waiters = RB_ROOT_CACHED, + .pi_waiters = __RB_ROOT_CACHED, .pi_top_task = NULL,#endif INIT_PREV_CPUTIME (init_task)
kernel/audit.c +1 -1
@@ -122,7 +122,7 @@ static u32 audit_backlog_limit = 64;static u32 audit_backlog_wait_time =AUDIT_BACKLOG_WAIT_TIME ;/* The identity of the user shutting down the audit system. */ -kuid_t audit_sig_uid =INVALID_UID ; +kuid_t audit_sig_uid = __INVALID_UID;pid_t audit_sig_pid =-1 ;u32 audit_sig_sid =0 ;
kernel/capability.c +1 -1
@@ -24,7 +24,7 @@* Leveraged for setting/resetting capabilities */ -const kernel_cap_t __cap_empty_set =CAP_EMPTY_SET ; +const kernel_cap_t __cap_empty_set = __CAP_EMPTY_SET;EXPORT_SYMBOL (__cap_empty_set);int file_caps_enabled =1 ;
kernel/cred.c +12 -12
@@ -44,19 +44,19 @@ struct cred init_cred = { .subscribers = ATOMIC_INIT(2), .magic = CRED_MAGIC, #endif - .uid = GLOBAL_ROOT_UID, - .gid = GLOBAL_ROOT_GID, - .suid = GLOBAL_ROOT_UID, - .sgid = GLOBAL_ROOT_GID, - .euid = GLOBAL_ROOT_UID, - .egid = GLOBAL_ROOT_GID, - .fsuid = GLOBAL_ROOT_UID, - .fsgid = GLOBAL_ROOT_GID, + .uid = __GLOBAL_ROOT_UID, + .gid = __GLOBAL_ROOT_GID, + .suid = __GLOBAL_ROOT_UID, + .sgid = __GLOBAL_ROOT_GID, + .euid = __GLOBAL_ROOT_UID, + .egid = __GLOBAL_ROOT_GID, + .fsuid = __GLOBAL_ROOT_UID, + .fsgid = __GLOBAL_ROOT_GID, .securebits = SECUREBITS_DEFAULT, - .cap_inheritable = CAP_EMPTY_SET, - .cap_permitted = CAP_FULL_SET, - .cap_effective = CAP_FULL_SET, - .cap_bset = CAP_FULL_SET, + .cap_inheritable = __CAP_EMPTY_SET, + .cap_permitted = __CAP_FULL_SET, + .cap_effective = __CAP_FULL_SET, + .cap_bset = __CAP_FULL_SET, .user = INIT_USER, .user_ns = &init_user_ns, .group_info = &init_groups,
kernel/events/uprobes.c +1 -1
@@ -33,7 +33,7 @@#define UINSNS_PER_PAGE (PAGE_SIZE/UPROBE_XOL_SLOT_BYTES)#define MAX_UPROBE_XOL_SLOTS UINSNS_PER_PAGE -static struct rb_root uprobes_tree =RB_ROOT ; +static DEFINE_RB_ROOT (uprobes_tree);/* * allows us to skip the uprobe_mmap if there are no uprobe events active * at this time. Probably a fine grained per inode count is better?
kernel/futex.c +1 -1
@@ -817,7 +817,7 @@ static int refill_pi_state_cache(void)/* pi_mutex gets initialized later */ pi_state->owner =NULL ;refcount_set (&pi_state->refcount,1 ); - pi_state->key =FUTEX_KEY_INIT ; + pi_state->key = (union futex_key )FUTEX_KEY_INIT ; current->pi_state_cache = pi_state;
kernel/power/swap.c +1 -1
@@ -125,7 +125,7 @@ struct swsusp_extent {unsigned long end; }; -static struct rb_root swsusp_extents =RB_ROOT ; +static DEFINE_RB_ROOT (swsusp_extents);static int swsusp_extents_insert (unsigned long swap_offset) {
kernel/trace/trace_clock.c +1 -1
@@ -88,7 +88,7 @@ static struct {arch_spinlock_t lock; } trace_clock_struct ____cacheline_aligned_in_smp = { - .lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED, + .lock = __ARCH_SPIN_LOCK_UNLOCKED, }; u64 notrace trace_clock_global(void)
kernel/umh.c +2 -2
@@ -34,8 +34,8 @@#define CAP_BSET (void *)1#define CAP_PI (void *)2 -static kernel_cap_t usermodehelper_bset =CAP_FULL_SET ; -static kernel_cap_t usermodehelper_inheritable =CAP_FULL_SET ; +static kernel_cap_t usermodehelper_bset = __CAP_FULL_SET; +static kernel_cap_t usermodehelper_inheritable = __CAP_FULL_SET;static DEFINE_SPINLOCK (umh_sysctl_lock);static DECLARE_RWSEM (umhelper_sem);static LIST_HEAD (umh_list);
kernel/user.c +3 -3
@@ -56,8 +56,8 @@ struct user_namespace init_user_ns = { }, }, .count = ATOMIC_INIT(3), - .owner = GLOBAL_ROOT_UID, - .group = GLOBAL_ROOT_GID, + .owner = __GLOBAL_ROOT_UID, + .group = __GLOBAL_ROOT_GID, .ns.inum =PROC_USER_INIT_INO , #ifdef CONFIG_USER_NS .ns.ops = &userns_operations,
@@ -101,7 +101,7 @@ struct user_struct root_user = { .processes = ATOMIC_INIT(1), .sigpending = ATOMIC_INIT(0), .locked_shm = 0, - .uid = GLOBAL_ROOT_UID, + .uid = __GLOBAL_ROOT_UID, .ratelimit = RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0), };
mm/backing-dev.c +1 -1
@@ -28,7 +28,7 @@ static struct class *bdi_class;*/ DEFINE_SPINLOCK (bdi_lock);static u64 bdi_id_cursor; -static struct rb_root bdi_tree =RB_ROOT ; +static DEFINE_RB_ROOT (bdi_tree);LIST_HEAD (bdi_list);/* bdi_wq serves all asynchronous writeback tasks */
mm/init-mm.c +1 -1
@@ -26,7 +26,7 @@* and size this cpu_bitmask to NR_CPUS. */ struct mm_struct init_mm = { - .mm_rb =RB_ROOT , + .mm_rb = __RB_ROOT, .pgd = swapper_pg_dir, .mm_users =ATOMIC_INIT (2 ), .mm_count =ATOMIC_INIT (1 ),
mm/page_alloc.c +1 -1
@@ -115,7 +115,7 @@ EXPORT_SYMBOL(latent_entropy);* Array of node states. */ nodemask_t node_states[NR_NODE_STATES ]__read_mostly = { - [N_POSSIBLE ] =NODE_MASK_ALL , + [N_POSSIBLE ] = __NODE_MASK_ALL, [N_ONLINE ] = { { [0 ] =1UL } }, #ifndef CONFIG_NUMA [N_NORMAL_MEMORY] = { { [0] = 1UL } },
mm/vmalloc.c +2 -2
@@ -334,7 +334,7 @@ static DEFINE_SPINLOCK(vmap_area_lock);/* Export for kexec only */ LIST_HEAD (vmap_area_list);static LLIST_HEAD (vmap_purge_list); -static struct rb_root vmap_area_root =RB_ROOT ; +static DEFINE_RB_ROOT (vmap_area_root);static bool vmap_initialized__read_mostly ;/*
@@ -361,7 +361,7 @@ static LIST_HEAD(free_vmap_area_list);* of its sub-tree, right or left. Therefore it is possible to * find a lowest match of free area. */ -static struct rb_root free_vmap_area_root =RB_ROOT ; +static DEFINE_RB_ROOT (free_vmap_area_root);/* * Preload a CPU with one object for "no edge" split case. The
net/core/fib_rules.c +2 -2
@@ -16,8 +16,8 @@#include <net/ip_tunnels.h> static const struct fib_kuid_range fib_kuid_range_unset = { -KUIDT_INIT (0 ), -KUIDT_INIT (~0 ), +__KUIDT_INIT (0 ), +__KUIDT_INIT (~0 ), };bool fib_rule_matchall (const struct fib_rule *rule)
net/rds/cong.c +1 -1
@@ -99,7 +99,7 @@ static DEFINE_RWLOCK(rds_cong_monitor_lock);* lock masks interrupts. */ static DEFINE_SPINLOCK (rds_cong_lock); -static struct rb_root rds_cong_tree =RB_ROOT ; +static DEFINE_RB_ROOT (rds_cong_tree);static struct rds_cong_map *rds_cong_tree_walk (const struct in6_addr *addr,struct rds_cong_map *insert)
security/integrity/iint.c +1 -1
@@ -21,7 +21,7 @@#include <linux/lsm_hooks.h> #include "integrity.h" -static struct rb_root integrity_iint_tree =RB_ROOT ; +static DEFINE_RB_ROOT (integrity_iint_tree);static DEFINE_RWLOCK (integrity_iint_lock);static struct kmem_cache *iint_cache__read_mostly ;
security/keys/process_keys.c +1 -1
@@ -29,7 +29,7 @@ struct key_user root_key_user = { .lock = __SPIN_LOCK_UNLOCKED(root_key_user.lock), .nkeys = ATOMIC_INIT(2), .nikeys = ATOMIC_INIT(2), - .uid = GLOBAL_ROOT_UID, + .uid = __GLOBAL_ROOT_UID, };/*
Signature · 1 line
2.20.0
Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 4 lines · Arnd Bergmann
Change enough of the kernel to allow building a 'defconfig' kernel on x86 and arm, by turning the compound literals into struct initializers.
Ugh. I detest this patch.
Not only is the patch itself fairly ugly, the end result is unmaintainable, since any regular kernel developer will
(a) not use ancient compilers
(b) look at code like this
static struct rb_root memtype_rbroot = __RB_ROOT;
and go "that double underscore is pointless" and fix it. And it will build fine for the developer.
So some of the patch looks like fine cleanups and not bad at all, but some of it really looks like it's going to be long-term annoyance, with duplicate names and unnecessary underscores.
In general the double underscores in contexts where they don't exist from before just look wrong.
Some of the "just remove the cast from the macro define" look good, though. And making users do DEFINE_RB_ROOT() looks fine. It's more the "make users have to use the internal double-underscore versions" where I go "that's wrong".
What distros are still stuck on gcc-4?
Linus
Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 1 line · Linus Torvalds
What distros are still stuck on gcc-4?
According to Distowatch:
- Debian 8.0 Jessie has 4.9.2, EOL 2020-05
- Ubuntu 14.04 LTS Trusty has 4.8.2, EOL 2019-04;
- Fedora 21 has 4.9.2, EOL 2015-12;
- OpenSUSE 42.3 has 4.8.5, EOL 2019-06;
- RHEL 7.7 has 4.8.5, EOL 2024-06;
- RHEL 6.9 has 4.4.7, EOL 2020-11;
- SUSE 12-SP4 has 4.8.6, EOL ?;
- Oracle 7.6 has 4.8.5, EOL ?;
Missed somebody?
Signature · 1 line
Kirill A. Shutemov
Arnd Bergmann
maintainerRe: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 12 lines · Kirill A. Shutemov
Quoted 1 line · Linus Torvalds
What distros are still stuck on gcc-4?
According to Distowatch:
- Debian 8.0 Jessie has 4.9.2, EOL 2020-05
- Ubuntu 14.04 LTS Trusty has 4.8.2, EOL 2019-04;
- Fedora 21 has 4.9.2, EOL 2015-12;
Quoted 7 lines
- OpenSUSE 42.3 has 4.8.5, EOL 2019-06;
- RHEL 7.7 has 4.8.5, EOL 2024-06;
- RHEL 6.9 has 4.4.7, EOL 2020-11;
- SUSE 12-SP4 has 4.8.6, EOL ?;
EOL 2024 as well, extended support 2027
Quoted 3 lines
- Oracle 7.6 has 4.8.5, EOL ?;
Missed somebody?
I started a similar list, the only other one I found was
Slackware 14.1 (no EOL announced): gcc-4.8
For the record, that seems to mean that moving to gcc-4.8 would likely not cause a lot of problems and would let us do some other cleanups, but unfortunately would not help with the compound literals.
Arnd
Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 5 lines · Arnd Bergmann
For the record, that seems to mean that moving to gcc-4.8 would likely not cause a lot of problems and would let us do some other cleanups, but unfortunately would not help with the compound literals.
Yeah, that's certainly less than wonderful.
That said, there's no way in hell we'll support gcc-4 for another 7 years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even relevant any more.
But it does look like we can't just say "gcc-5.1 is ok". Darn.
Linus
Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 7 lines · Linus Torvalds
Quoted 5 lines · Arnd Bergmann
For the record, that seems to mean that moving to gcc-4.8 would likely not cause a lot of problems and would let us do some other cleanups, but unfortunately would not help with the compound literals.
Quoted 7 lines
Yeah, that's certainly less than wonderful.
That said, there's no way in hell we'll support gcc-4 for another 7 years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even relevant any more.
But it does look like we can't just say "gcc-5.1 is ok". Darn.
I don't read the picture the same way. All distributions have at least one major release with GCC >= 5.
The first release with gcc >= 5:
- Debian 9 stretch has 6.3.0, released 2017-06-18;
- Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;
- Fedora 24 has 6.1.1, released 2016-06-21;
- OpenSUSE 15 has 7.4.1, released 2018-05-25;
- RHEL 8.0 has 8.2.1, released 2019-05-06;
- SUSE 15 has 7.3.1, released 2018-06-25;
- Oracle 7.6.4 has 7.6.4, release 2019-07-18;
- Slackware 14.2 has 5.3.0, released 2016-07-01;
Signature · 1 line
Kirill A. Shutemov
Arnd Bergmann
maintainerRe: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 20 lines · Kirill A. Shutemov
Quoted 7 lines · Linus Torvalds
Yeah, that's certainly less than wonderful.
That said, there's no way in hell we'll support gcc-4 for another 7 years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even relevant any more.
But it does look like we can't just say "gcc-5.1 is ok". Darn.
I don't read the picture the same way. All distributions have at least one major release with GCC >= 5.
The first release with gcc >= 5:
- Debian 9 stretch has 6.3.0, released 2017-06-18;
- Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;
- Fedora 24 has 6.1.1, released 2016-06-21;
Quoted 7 lines
- OpenSUSE 15 has 7.4.1, released 2018-05-25;
- RHEL 8.0 has 8.2.1, released 2019-05-06;
- SUSE 15 has 7.3.1, released 2018-06-25;
- Oracle 7.6.4 has 7.6.4, release 2019-07-18;
^^^ Oracle 8
Quoted 2 lines
- Slackware 14.2 has 5.3.0, released 2016-07-01;
For /most/ of these I see no problem, but RHEL 7 / Centos 7 / Oracle 7 and (to a lesser degree) SUSE 12 must have users that want to build new kernels for some reason without a trivial way to install new compilers.
OTOH, I agree that requiring a much more recent compiler has some advantages that may outweigh these troubles. glibc has moved to requiring a 3 (!) year old compiler or newer, which gives them a reasonable time frame to make changes to gcc and then build on requiring these changes.
Arnd
Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
Quoted 28 lines · Arnd Bergmann
Quoted 20 lines · Kirill A. Shutemov
Quoted 7 lines · Linus Torvalds
Yeah, that's certainly less than wonderful.
That said, there's no way in hell we'll support gcc-4 for another 7 years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even relevant any more.
But it does look like we can't just say "gcc-5.1 is ok". Darn.
I don't read the picture the same way. All distributions have at least one major release with GCC >= 5.
The first release with gcc >= 5:
- Debian 9 stretch has 6.3.0, released 2017-06-18;
- Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;
- Fedora 24 has 6.1.1, released 2016-06-21;
Quoted 7 lines
- OpenSUSE 15 has 7.4.1, released 2018-05-25;
- RHEL 8.0 has 8.2.1, released 2019-05-06;
- SUSE 15 has 7.3.1, released 2018-06-25;
- Oracle 7.6.4 has 7.6.4, release 2019-07-18;
Quoted 8 lines
^^^ Oracle 8Quoted 2 lines
- Slackware 14.2 has 5.3.0, released 2016-07-01;
For /most/ of these I see no problem, but RHEL 7 / Centos 7 / Oracle 7 and (to a lesser degree) SUSE 12 must have users that want to build new kernels for some reason without a trivial way to install new compilers.
Isn't crosstool the trivial enough? We can directly suggest using it if compiler is too old.
BTW, we already require much newer compiler for some features. See retpoline.
Signature · 1 line
Kirill A. Shutemov