diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 46 | ||||
-rw-r--r-- | include/linux/magic.h | 1 | ||||
-rw-r--r-- | include/linux/percpu.h | 41 | ||||
-rw-r--r-- | include/linux/sched.h | 16 | ||||
-rw-r--r-- | include/linux/stackprotector.h | 16 |
5 files changed, 63 insertions, 57 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index aa6b9b1b30b5..53e21f36a802 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -430,22 +430,10 @@ | |||
430 | *(.initcall7.init) \ | 430 | *(.initcall7.init) \ |
431 | *(.initcall7s.init) | 431 | *(.initcall7s.init) |
432 | 432 | ||
433 | #define PERCPU_PROLOG(vaddr) \ | ||
434 | VMLINUX_SYMBOL(__per_cpu_load) = .; \ | ||
435 | .data.percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \ | ||
436 | - LOAD_OFFSET) { \ | ||
437 | VMLINUX_SYMBOL(__per_cpu_start) = .; | ||
438 | |||
439 | #define PERCPU_EPILOG(phdr) \ | ||
440 | VMLINUX_SYMBOL(__per_cpu_end) = .; \ | ||
441 | } phdr \ | ||
442 | . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data.percpu); | ||
443 | |||
444 | /** | 433 | /** |
445 | * PERCPU_VADDR_PREALLOC - define output section for percpu area with prealloc | 434 | * PERCPU_VADDR - define output section for percpu area |
446 | * @vaddr: explicit base address (optional) | 435 | * @vaddr: explicit base address (optional) |
447 | * @phdr: destination PHDR (optional) | 436 | * @phdr: destination PHDR (optional) |
448 | * @prealloc: the size of prealloc area | ||
449 | * | 437 | * |
450 | * Macro which expands to output section for percpu area. If @vaddr | 438 | * Macro which expands to output section for percpu area. If @vaddr |
451 | * is not blank, it specifies explicit base address and all percpu | 439 | * is not blank, it specifies explicit base address and all percpu |
@@ -457,39 +445,23 @@ | |||
457 | * section in the linker script will go there too. @phdr should have | 445 | * section in the linker script will go there too. @phdr should have |
458 | * a leading colon. | 446 | * a leading colon. |
459 | * | 447 | * |
460 | * If @prealloc is non-zero, the specified number of bytes will be | ||
461 | * reserved at the start of percpu area. As the prealloc area is | ||
462 | * likely to break alignment, this macro puts areas in increasing | ||
463 | * alignment order. | ||
464 | * | ||
465 | * This macro defines three symbols, __per_cpu_load, __per_cpu_start | 448 | * This macro defines three symbols, __per_cpu_load, __per_cpu_start |
466 | * and __per_cpu_end. The first one is the vaddr of loaded percpu | 449 | * and __per_cpu_end. The first one is the vaddr of loaded percpu |
467 | * init data. __per_cpu_start equals @vaddr and __per_cpu_end is the | 450 | * init data. __per_cpu_start equals @vaddr and __per_cpu_end is the |
468 | * end offset. | 451 | * end offset. |
469 | */ | 452 | */ |
470 | #define PERCPU_VADDR_PREALLOC(vaddr, segment, prealloc) \ | ||
471 | PERCPU_PROLOG(vaddr) \ | ||
472 | . += prealloc; \ | ||
473 | *(.data.percpu) \ | ||
474 | *(.data.percpu.shared_aligned) \ | ||
475 | *(.data.percpu.page_aligned) \ | ||
476 | PERCPU_EPILOG(segment) | ||
477 | |||
478 | /** | ||
479 | * PERCPU_VADDR - define output section for percpu area | ||
480 | * @vaddr: explicit base address (optional) | ||
481 | * @phdr: destination PHDR (optional) | ||
482 | * | ||
483 | * Macro which expands to output section for percpu area. Mostly | ||
484 | * identical to PERCPU_VADDR_PREALLOC(@vaddr, @phdr, 0) other than | ||
485 | * using slighly different layout. | ||
486 | */ | ||
487 | #define PERCPU_VADDR(vaddr, phdr) \ | 453 | #define PERCPU_VADDR(vaddr, phdr) \ |
488 | PERCPU_PROLOG(vaddr) \ | 454 | VMLINUX_SYMBOL(__per_cpu_load) = .; \ |
455 | .data.percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \ | ||
456 | - LOAD_OFFSET) { \ | ||
457 | VMLINUX_SYMBOL(__per_cpu_start) = .; \ | ||
458 | *(.data.percpu.first) \ | ||
489 | *(.data.percpu.page_aligned) \ | 459 | *(.data.percpu.page_aligned) \ |
490 | *(.data.percpu) \ | 460 | *(.data.percpu) \ |
491 | *(.data.percpu.shared_aligned) \ | 461 | *(.data.percpu.shared_aligned) \ |
492 | PERCPU_EPILOG(phdr) | 462 | VMLINUX_SYMBOL(__per_cpu_end) = .; \ |
463 | } phdr \ | ||
464 | . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data.percpu); | ||
493 | 465 | ||
494 | /** | 466 | /** |
495 | * PERCPU - define output section for percpu area, simple version | 467 | * PERCPU - define output section for percpu area, simple version |
diff --git a/include/linux/magic.h b/include/linux/magic.h index 0b4df7eba852..5b4e28bcb788 100644 --- a/include/linux/magic.h +++ b/include/linux/magic.h | |||
@@ -49,4 +49,5 @@ | |||
49 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA | 49 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA |
50 | #define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA | 50 | #define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA |
51 | 51 | ||
52 | #define STACK_END_MAGIC 0x57AC6E9D | ||
52 | #endif /* __LINUX_MAGIC_H__ */ | 53 | #endif /* __LINUX_MAGIC_H__ */ |
diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 9f2a3751873a..0e24202b5a4e 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h | |||
@@ -9,34 +9,39 @@ | |||
9 | #include <asm/percpu.h> | 9 | #include <asm/percpu.h> |
10 | 10 | ||
11 | #ifdef CONFIG_SMP | 11 | #ifdef CONFIG_SMP |
12 | #define DEFINE_PER_CPU(type, name) \ | 12 | #define PER_CPU_BASE_SECTION ".data.percpu" |
13 | __attribute__((__section__(".data.percpu"))) \ | ||
14 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | ||
15 | 13 | ||
16 | #ifdef MODULE | 14 | #ifdef MODULE |
17 | #define SHARED_ALIGNED_SECTION ".data.percpu" | 15 | #define PER_CPU_SHARED_ALIGNED_SECTION "" |
18 | #else | 16 | #else |
19 | #define SHARED_ALIGNED_SECTION ".data.percpu.shared_aligned" | 17 | #define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned" |
20 | #endif | 18 | #endif |
19 | #define PER_CPU_FIRST_SECTION ".first" | ||
21 | 20 | ||
22 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | 21 | #else |
23 | __attribute__((__section__(SHARED_ALIGNED_SECTION))) \ | 22 | |
24 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \ | 23 | #define PER_CPU_BASE_SECTION ".data" |
25 | ____cacheline_aligned_in_smp | 24 | #define PER_CPU_SHARED_ALIGNED_SECTION "" |
25 | #define PER_CPU_FIRST_SECTION "" | ||
26 | |||
27 | #endif | ||
26 | 28 | ||
27 | #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ | 29 | #define DEFINE_PER_CPU_SECTION(type, name, section) \ |
28 | __attribute__((__section__(".data.percpu.page_aligned"))) \ | 30 | __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ |
29 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | 31 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name |
30 | #else | 32 | |
31 | #define DEFINE_PER_CPU(type, name) \ | 33 | #define DEFINE_PER_CPU(type, name) \ |
32 | PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name | 34 | DEFINE_PER_CPU_SECTION(type, name, "") |
33 | 35 | ||
34 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ | 36 | #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ |
35 | DEFINE_PER_CPU(type, name) | 37 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \ |
38 | ____cacheline_aligned_in_smp | ||
36 | 39 | ||
37 | #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ | 40 | #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ |
38 | DEFINE_PER_CPU(type, name) | 41 | DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") |
39 | #endif | 42 | |
43 | #define DEFINE_PER_CPU_FIRST(type, name) \ | ||
44 | DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION) | ||
40 | 45 | ||
41 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) | 46 | #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) |
42 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) | 47 | #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) |
diff --git a/include/linux/sched.h b/include/linux/sched.h index f134a0f7080a..b85b10abf770 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1159,10 +1159,9 @@ struct task_struct { | |||
1159 | pid_t pid; | 1159 | pid_t pid; |
1160 | pid_t tgid; | 1160 | pid_t tgid; |
1161 | 1161 | ||
1162 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
1163 | /* Canary value for the -fstack-protector gcc feature */ | 1162 | /* Canary value for the -fstack-protector gcc feature */ |
1164 | unsigned long stack_canary; | 1163 | unsigned long stack_canary; |
1165 | #endif | 1164 | |
1166 | /* | 1165 | /* |
1167 | * pointers to (original) parent process, youngest child, younger sibling, | 1166 | * pointers to (original) parent process, youngest child, younger sibling, |
1168 | * older sibling, respectively. (p->father can be replaced with | 1167 | * older sibling, respectively. (p->father can be replaced with |
@@ -2069,6 +2068,19 @@ static inline int object_is_on_stack(void *obj) | |||
2069 | 2068 | ||
2070 | extern void thread_info_cache_init(void); | 2069 | extern void thread_info_cache_init(void); |
2071 | 2070 | ||
2071 | #ifdef CONFIG_DEBUG_STACK_USAGE | ||
2072 | static inline unsigned long stack_not_used(struct task_struct *p) | ||
2073 | { | ||
2074 | unsigned long *n = end_of_stack(p); | ||
2075 | |||
2076 | do { /* Skip over canary */ | ||
2077 | n++; | ||
2078 | } while (!*n); | ||
2079 | |||
2080 | return (unsigned long)n - (unsigned long)end_of_stack(p); | ||
2081 | } | ||
2082 | #endif | ||
2083 | |||
2072 | /* set thread flags in other task's structures | 2084 | /* set thread flags in other task's structures |
2073 | * - see asm/thread_info.h for TIF_xxxx flags available | 2085 | * - see asm/thread_info.h for TIF_xxxx flags available |
2074 | */ | 2086 | */ |
diff --git a/include/linux/stackprotector.h b/include/linux/stackprotector.h new file mode 100644 index 000000000000..6f3e54c704c0 --- /dev/null +++ b/include/linux/stackprotector.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _LINUX_STACKPROTECTOR_H | ||
2 | #define _LINUX_STACKPROTECTOR_H 1 | ||
3 | |||
4 | #include <linux/compiler.h> | ||
5 | #include <linux/sched.h> | ||
6 | #include <linux/random.h> | ||
7 | |||
8 | #ifdef CONFIG_CC_STACKPROTECTOR | ||
9 | # include <asm/stackprotector.h> | ||
10 | #else | ||
11 | static inline void boot_init_stack_canary(void) | ||
12 | { | ||
13 | } | ||
14 | #endif | ||
15 | |||
16 | #endif | ||