Skip to content

Commit 22d3e0c

Browse files
committed
Merge tag 'kbuild-fixes-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - introduce __diag_* macros and suppress -Wattribute-alias warnings from GCC 8 - fix stack protector test script for x86_64 - fix line number handling in Kconfig - document that '#' starts a comment in Kconfig - handle P_SYMBOL property in dump debugging of Kconfig - correct help message of LD_DEAD_CODE_DATA_ELIMINATION - fix occasional segmentation faults in Kconfig * tag 'kbuild-fixes-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kconfig: loop boundary condition fix kbuild: reword help of LD_DEAD_CODE_DATA_ELIMINATION kconfig: handle P_SYMBOL in print_symbol() kconfig: document Kconfig source file comments kconfig: fix line numbers for if-entries in menu tree stack-protector: Fix test with 32-bit userland and CONFIG_64BIT=y powerpc: Remove -Wattribute-alias pragmas disable -Wattribute-alias warning for SYSCALL_DEFINEx() kbuild: add macro for controlling warnings to linux/compiler.h
2 parents 0fbc4ae + 73d1c58 commit 22d3e0c

File tree

17 files changed

+74
-41
lines changed

17 files changed

+74
-41
lines changed

Documentation/kbuild/kconfig-language.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,12 @@ This sets the config program's title bar if the config program chooses
430430
to use it. It should be placed at the top of the configuration, before any
431431
other statement.
432432

433+
'#' Kconfig source file comment:
434+
435+
An unquoted '#' character anywhere in a source file line indicates
436+
the beginning of a source file comment. The remainder of that line
437+
is a comment.
438+
433439

434440
Kconfig hints
435441
-------------

arch/powerpc/kernel/pci_32.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ pci_bus_to_hose(int bus)
285285
* Note that the returned IO or memory base is a physical address
286286
*/
287287

288-
#pragma GCC diagnostic push
289-
#pragma GCC diagnostic ignored "-Wpragmas"
290-
#pragma GCC diagnostic ignored "-Wattribute-alias"
291288
SYSCALL_DEFINE3(pciconfig_iobase, long, which,
292289
unsigned long, bus, unsigned long, devfn)
293290
{
@@ -313,4 +310,3 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which,
313310

314311
return result;
315312
}
316-
#pragma GCC diagnostic pop

arch/powerpc/kernel/pci_64.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ void pcibios_setup_phb_io_space(struct pci_controller *hose)
203203
#define IOBASE_ISA_IO 3
204204
#define IOBASE_ISA_MEM 4
205205

206-
#pragma GCC diagnostic push
207-
#pragma GCC diagnostic ignored "-Wpragmas"
208-
#pragma GCC diagnostic ignored "-Wattribute-alias"
209206
SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
210207
unsigned long, in_devfn)
211208
{
@@ -259,7 +256,6 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
259256

260257
return -EOPNOTSUPP;
261258
}
262-
#pragma GCC diagnostic pop
263259

264260
#ifdef CONFIG_NUMA
265261
int pcibus_to_node(struct pci_bus *bus)

arch/powerpc/kernel/rtas.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,6 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
10511051
}
10521052

10531053
/* We assume to be passed big endian arguments */
1054-
#pragma GCC diagnostic push
1055-
#pragma GCC diagnostic ignored "-Wpragmas"
1056-
#pragma GCC diagnostic ignored "-Wattribute-alias"
10571054
SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
10581055
{
10591056
struct rtas_args args;
@@ -1140,7 +1137,6 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
11401137

11411138
return 0;
11421139
}
1143-
#pragma GCC diagnostic pop
11441140

11451141
/*
11461142
* Call early during boot, before mem init, to retrieve the RTAS

arch/powerpc/kernel/signal_32.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,6 @@ static int do_setcontext_tm(struct ucontext __user *ucp,
10381038
}
10391039
#endif
10401040

1041-
#pragma GCC diagnostic push
1042-
#pragma GCC diagnostic ignored "-Wpragmas"
1043-
#pragma GCC diagnostic ignored "-Wattribute-alias"
10441041
#ifdef CONFIG_PPC64
10451042
COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
10461043
struct ucontext __user *, new_ctx, int, ctx_size)
@@ -1134,7 +1131,6 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
11341131
set_thread_flag(TIF_RESTOREALL);
11351132
return 0;
11361133
}
1137-
#pragma GCC diagnostic pop
11381134

11391135
#ifdef CONFIG_PPC64
11401136
COMPAT_SYSCALL_DEFINE0(rt_sigreturn)
@@ -1231,9 +1227,6 @@ SYSCALL_DEFINE0(rt_sigreturn)
12311227
return 0;
12321228
}
12331229

1234-
#pragma GCC diagnostic push
1235-
#pragma GCC diagnostic ignored "-Wpragmas"
1236-
#pragma GCC diagnostic ignored "-Wattribute-alias"
12371230
#ifdef CONFIG_PPC32
12381231
SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
12391232
int, ndbg, struct sig_dbg_op __user *, dbg)
@@ -1337,7 +1330,6 @@ SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
13371330
return 0;
13381331
}
13391332
#endif
1340-
#pragma GCC diagnostic pop
13411333

13421334
/*
13431335
* OK, we're invoking a handler

arch/powerpc/kernel/signal_64.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,6 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
625625
/*
626626
* Handle {get,set,swap}_context operations
627627
*/
628-
#pragma GCC diagnostic push
629-
#pragma GCC diagnostic ignored "-Wpragmas"
630-
#pragma GCC diagnostic ignored "-Wattribute-alias"
631628
SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
632629
struct ucontext __user *, new_ctx, long, ctx_size)
633630
{
@@ -693,7 +690,6 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
693690
set_thread_flag(TIF_RESTOREALL);
694691
return 0;
695692
}
696-
#pragma GCC diagnostic pop
697693

698694

699695
/*

arch/powerpc/kernel/syscalls.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ static inline long do_mmap2(unsigned long addr, size_t len,
6262
return ret;
6363
}
6464

65-
#pragma GCC diagnostic push
66-
#pragma GCC diagnostic ignored "-Wpragmas"
67-
#pragma GCC diagnostic ignored "-Wattribute-alias"
6865
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
6966
unsigned long, prot, unsigned long, flags,
7067
unsigned long, fd, unsigned long, pgoff)
@@ -78,7 +75,6 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
7875
{
7976
return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
8077
}
81-
#pragma GCC diagnostic pop
8278

8379
#ifdef CONFIG_PPC32
8480
/*

arch/powerpc/mm/subpage-prot.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr,
186186
* in a 2-bit field won't allow writes to a page that is otherwise
187187
* write-protected.
188188
*/
189-
#pragma GCC diagnostic push
190-
#pragma GCC diagnostic ignored "-Wpragmas"
191-
#pragma GCC diagnostic ignored "-Wattribute-alias"
192189
SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
193190
unsigned long, len, u32 __user *, map)
194191
{
@@ -272,4 +269,3 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
272269
up_write(&mm->mmap_sem);
273270
return err;
274271
}
275-
#pragma GCC diagnostic pop

include/linux/compat.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
*/
7373
#ifndef COMPAT_SYSCALL_DEFINEx
7474
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
75+
__diag_push(); \
76+
__diag_ignore(GCC, 8, "-Wattribute-alias", \
77+
"Type aliasing is used to sanitize syscall arguments");\
7578
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
7679
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
7780
__attribute__((alias(__stringify(__se_compat_sys##name)))); \
@@ -80,8 +83,11 @@
8083
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
8184
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
8285
{ \
83-
return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
86+
long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
87+
__MAP(x,__SC_TEST,__VA_ARGS__); \
88+
return ret; \
8489
} \
90+
__diag_pop(); \
8591
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
8692
#endif /* COMPAT_SYSCALL_DEFINEx */
8793

include/linux/compiler-gcc.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,28 @@
347347
#if GCC_VERSION >= 50100
348348
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
349349
#endif
350+
351+
/*
352+
* Turn individual warnings and errors on and off locally, depending
353+
* on version.
354+
*/
355+
#define __diag_GCC(version, severity, s) \
356+
__diag_GCC_ ## version(__diag_GCC_ ## severity s)
357+
358+
/* Severity used in pragma directives */
359+
#define __diag_GCC_ignore ignored
360+
#define __diag_GCC_warn warning
361+
#define __diag_GCC_error error
362+
363+
/* Compilers before gcc-4.6 do not understand "#pragma GCC diagnostic push" */
364+
#if GCC_VERSION >= 40600
365+
#define __diag_str1(s) #s
366+
#define __diag_str(s) __diag_str1(s)
367+
#define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
368+
#endif
369+
370+
#if GCC_VERSION >= 80000
371+
#define __diag_GCC_8(s) __diag(s)
372+
#else
373+
#define __diag_GCC_8(s)
374+
#endif

0 commit comments

Comments
 (0)