aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-03 14:10:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-03 14:10:06 -0500
commit57480b98af696795ab0daff0a6ed572172060a0f (patch)
tree4a4df2ed5431196ba2f085979753367cfa1b98d4
parent2d47b8aac7ba697ffe05f839a3b4c3c628b4e430 (diff)
parenta0615a16f7d0ceb5804d295203c302d496d8ee91 (diff)
Merge tag 'powerpc-4.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "The main change is we're reverting the initial stack protector support we merged this cycle. It turns out to not work on toolchains built with libc support, and fixing it will be need to wait for another release. And the rest are all fairly minor: - Some pasemi machines were not booting due to a missing error check in prom_find_boot_cpu() - In EEH we were checking a pointer rather than the bool it pointed to - The clang build was broken by a BUILD_BUG_ON() we added. - The radix (Power9 only) version of map_kernel_page() was broken if our memory size was a multiple of 2MB, which it generally isn't Thanks to: Darren Stevens, Gavin Shan, Reza Arbab" * tag 'powerpc-4.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/mm: Use the correct pointer when setting a 2MB pte powerpc: Fix build failure with clang due to BUILD_BUG_ON() powerpc: Revert the initial stack protector support powerpc/eeh: Fix wrong flag passed to eeh_unfreeze_pe() powerpc: Add missing error check to prom_find_boot_cpu()
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/include/asm/cpu_has_feature.h2
-rw-r--r--arch/powerpc/include/asm/mmu.h2
-rw-r--r--arch/powerpc/include/asm/stackprotector.h40
-rw-r--r--arch/powerpc/kernel/Makefile4
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/eeh_driver.c2
-rw-r--r--arch/powerpc/kernel/entry_32.S6
-rw-r--r--arch/powerpc/kernel/process.c6
-rw-r--r--arch/powerpc/kernel/prom_init.c3
-rw-r--r--arch/powerpc/mm/pgtable-radix.c4
11 files changed, 11 insertions, 62 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index db8a1ef6bfaf..281f4f1fcd1f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -164,7 +164,6 @@ config PPC
164 select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE 164 select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE
165 select HAVE_ARCH_HARDENED_USERCOPY 165 select HAVE_ARCH_HARDENED_USERCOPY
166 select HAVE_KERNEL_GZIP 166 select HAVE_KERNEL_GZIP
167 select HAVE_CC_STACKPROTECTOR
168 167
169config GENERIC_CSUM 168config GENERIC_CSUM
170 def_bool CPU_LITTLE_ENDIAN 169 def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h
index b312b152461b..6e834caa3720 100644
--- a/arch/powerpc/include/asm/cpu_has_feature.h
+++ b/arch/powerpc/include/asm/cpu_has_feature.h
@@ -23,7 +23,9 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
23{ 23{
24 int i; 24 int i;
25 25
26#ifndef __clang__ /* clang can't cope with this */
26 BUILD_BUG_ON(!__builtin_constant_p(feature)); 27 BUILD_BUG_ON(!__builtin_constant_p(feature));
28#endif
27 29
28#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG 30#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
29 if (!static_key_initialized) { 31 if (!static_key_initialized) {
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index a34c764ca8dd..233a7e8cc8e3 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -160,7 +160,9 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
160{ 160{
161 int i; 161 int i;
162 162
163#ifndef __clang__ /* clang can't cope with this */
163 BUILD_BUG_ON(!__builtin_constant_p(feature)); 164 BUILD_BUG_ON(!__builtin_constant_p(feature));
165#endif
164 166
165#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG 167#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
166 if (!static_key_initialized) { 168 if (!static_key_initialized) {
diff --git a/arch/powerpc/include/asm/stackprotector.h b/arch/powerpc/include/asm/stackprotector.h
deleted file mode 100644
index 6720190eabec..000000000000
--- a/arch/powerpc/include/asm/stackprotector.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * GCC stack protector support.
3 *
4 * Stack protector works by putting predefined pattern at the start of
5 * the stack frame and verifying that it hasn't been overwritten when
6 * returning from the function. The pattern is called stack canary
7 * and gcc expects it to be defined by a global variable called
8 * "__stack_chk_guard" on PPC. This unfortunately means that on SMP
9 * we cannot have a different canary value per task.
10 */
11
12#ifndef _ASM_STACKPROTECTOR_H
13#define _ASM_STACKPROTECTOR_H
14
15#include <linux/random.h>
16#include <linux/version.h>
17#include <asm/reg.h>
18
19extern unsigned long __stack_chk_guard;
20
21/*
22 * Initialize the stackprotector canary value.
23 *
24 * NOTE: this must only be called from functions that never return,
25 * and it must always be inlined.
26 */
27static __always_inline void boot_init_stack_canary(void)
28{
29 unsigned long canary;
30
31 /* Try to get a semi random initial value. */
32 get_random_bytes(&canary, sizeof(canary));
33 canary ^= mftb();
34 canary ^= LINUX_VERSION_CODE;
35
36 current->stack_canary = canary;
37 __stack_chk_guard = current->stack_canary;
38}
39
40#endif /* _ASM_STACKPROTECTOR_H */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 23f8082d7bfa..f4c2b52e58b3 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -19,10 +19,6 @@ CFLAGS_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
19CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) 19CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
20CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) 20CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
21 21
22# -fstack-protector triggers protection checks in this code,
23# but it is being used too early to link to meaningful stack_chk logic.
24CFLAGS_prom_init.o += $(call cc-option, -fno-stack-protector)
25
26ifdef CONFIG_FUNCTION_TRACER 22ifdef CONFIG_FUNCTION_TRACER
27# Do not trace early boot code 23# Do not trace early boot code
28CFLAGS_REMOVE_cputable.o = -mno-sched-epilog $(CC_FLAGS_FTRACE) 24CFLAGS_REMOVE_cputable.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 0601e6a7297c..195a9fc8f81c 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -91,9 +91,6 @@ int main(void)
91 DEFINE(TI_livepatch_sp, offsetof(struct thread_info, livepatch_sp)); 91 DEFINE(TI_livepatch_sp, offsetof(struct thread_info, livepatch_sp));
92#endif 92#endif
93 93
94#ifdef CONFIG_CC_STACKPROTECTOR
95 DEFINE(TSK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
96#endif
97 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 94 DEFINE(KSP, offsetof(struct thread_struct, ksp));
98 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 95 DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
99#ifdef CONFIG_BOOKE 96#ifdef CONFIG_BOOKE
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index d88573bdd090..b94887165a10 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -545,7 +545,7 @@ static void *eeh_pe_detach_dev(void *data, void *userdata)
545static void *__eeh_clear_pe_frozen_state(void *data, void *flag) 545static void *__eeh_clear_pe_frozen_state(void *data, void *flag)
546{ 546{
547 struct eeh_pe *pe = (struct eeh_pe *)data; 547 struct eeh_pe *pe = (struct eeh_pe *)data;
548 bool *clear_sw_state = flag; 548 bool clear_sw_state = *(bool *)flag;
549 int i, rc = 1; 549 int i, rc = 1;
550 550
551 for (i = 0; rc && i < 3; i++) 551 for (i = 0; rc && i < 3; i++)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 5742dbdbee46..3841d749a430 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -674,11 +674,7 @@ BEGIN_FTR_SECTION
674 mtspr SPRN_SPEFSCR,r0 /* restore SPEFSCR reg */ 674 mtspr SPRN_SPEFSCR,r0 /* restore SPEFSCR reg */
675END_FTR_SECTION_IFSET(CPU_FTR_SPE) 675END_FTR_SECTION_IFSET(CPU_FTR_SPE)
676#endif /* CONFIG_SPE */ 676#endif /* CONFIG_SPE */
677#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP) 677
678 lwz r0,TSK_STACK_CANARY(r2)
679 lis r4,__stack_chk_guard@ha
680 stw r0,__stack_chk_guard@l(r4)
681#endif
682 lwz r0,_CCR(r1) 678 lwz r0,_CCR(r1)
683 mtcrf 0xFF,r0 679 mtcrf 0xFF,r0
684 /* r3-r12 are destroyed -- Cort */ 680 /* r3-r12 are destroyed -- Cort */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 04885cec24df..5dd056df0baa 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -64,12 +64,6 @@
64#include <linux/kprobes.h> 64#include <linux/kprobes.h>
65#include <linux/kdebug.h> 65#include <linux/kdebug.h>
66 66
67#ifdef CONFIG_CC_STACKPROTECTOR
68#include <linux/stackprotector.h>
69unsigned long __stack_chk_guard __read_mostly;
70EXPORT_SYMBOL(__stack_chk_guard);
71#endif
72
73/* Transactional Memory debug */ 67/* Transactional Memory debug */
74#ifdef TM_DEBUG_SW 68#ifdef TM_DEBUG_SW
75#define TM_DEBUG(x...) printk(KERN_INFO x) 69#define TM_DEBUG(x...) printk(KERN_INFO x)
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index ec47a939cbdd..ac83eb04a8b8 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2834,6 +2834,9 @@ static void __init prom_find_boot_cpu(void)
2834 2834
2835 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu); 2835 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
2836 2836
2837 if (!PHANDLE_VALID(cpu_pkg))
2838 return;
2839
2837 prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval)); 2840 prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
2838 prom.cpu = be32_to_cpu(rval); 2841 prom.cpu = be32_to_cpu(rval);
2839 2842
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
index cfa53ccc8baf..34f1a0dbc898 100644
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -65,7 +65,7 @@ int radix__map_kernel_page(unsigned long ea, unsigned long pa,
65 if (!pmdp) 65 if (!pmdp)
66 return -ENOMEM; 66 return -ENOMEM;
67 if (map_page_size == PMD_SIZE) { 67 if (map_page_size == PMD_SIZE) {
68 ptep = (pte_t *)pudp; 68 ptep = pmdp_ptep(pmdp);
69 goto set_the_pte; 69 goto set_the_pte;
70 } 70 }
71 ptep = pte_alloc_kernel(pmdp, ea); 71 ptep = pte_alloc_kernel(pmdp, ea);
@@ -90,7 +90,7 @@ int radix__map_kernel_page(unsigned long ea, unsigned long pa,
90 } 90 }
91 pmdp = pmd_offset(pudp, ea); 91 pmdp = pmd_offset(pudp, ea);
92 if (map_page_size == PMD_SIZE) { 92 if (map_page_size == PMD_SIZE) {
93 ptep = (pte_t *)pudp; 93 ptep = pmdp_ptep(pmdp);
94 goto set_the_pte; 94 goto set_the_pte;
95 } 95 }
96 if (!pmd_present(*pmdp)) { 96 if (!pmd_present(*pmdp)) {