aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2015-12-09 04:11:47 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2015-12-10 05:11:13 -0500
commitdb1231dcdb4dc6cdcbdef0babe641a9162c0dc98 (patch)
tree34250a59e15b1d3e9620a7a9e3083b0a4fa82bce
parent20dbe67062062c2a790832f0d30e73dba45df7c4 (diff)
powerpc: Fix DSCR inheritance over fork()
Two DSCR tests have a hack in them: /* * XXX: Force a context switch out so that DSCR * current value is copied into the thread struct * which is required for the child to inherit the * changed value. */ sleep(1); We should not be working around this in the testcase, it is a kernel bug. Fix it by copying the current DSCR to the child, instead of what we had in the thread struct at last context switch. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c8
-rw-r--r--tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c8
3 files changed, 1 insertions, 17 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9da7b5f0c3a5..6f76f25c3ee8 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1287,7 +1287,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
1287#ifdef CONFIG_PPC64 1287#ifdef CONFIG_PPC64
1288 if (cpu_has_feature(CPU_FTR_DSCR)) { 1288 if (cpu_has_feature(CPU_FTR_DSCR)) {
1289 p->thread.dscr_inherit = current->thread.dscr_inherit; 1289 p->thread.dscr_inherit = current->thread.dscr_inherit;
1290 p->thread.dscr = current->thread.dscr; 1290 p->thread.dscr = mfspr(SPRN_DSCR);
1291 } 1291 }
1292 if (cpu_has_feature(CPU_FTR_HAS_PPR)) 1292 if (cpu_has_feature(CPU_FTR_HAS_PPR))
1293 p->thread.ppr = INIT_PPR; 1293 p->thread.ppr = INIT_PPR;
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
index 8265504de571..08a8b95e3bc1 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
@@ -60,14 +60,6 @@ int dscr_inherit_exec(void)
60 else 60 else
61 set_dscr(dscr); 61 set_dscr(dscr);
62 62
63 /*
64 * XXX: Force a context switch out so that DSCR
65 * current value is copied into the thread struct
66 * which is required for the child to inherit the
67 * changed value.
68 */
69 sleep(1);
70
71 pid = fork(); 63 pid = fork();
72 if (pid == -1) { 64 if (pid == -1) {
73 perror("fork() failed"); 65 perror("fork() failed");
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
index 4e414caf7f40..3e5a6d195e9a 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
@@ -40,14 +40,6 @@ int dscr_inherit(void)
40 else 40 else
41 set_dscr(dscr); 41 set_dscr(dscr);
42 42
43 /*
44 * XXX: Force a context switch out so that DSCR
45 * current value is copied into the thread struct
46 * which is required for the child to inherit the
47 * changed value.
48 */
49 sleep(1);
50
51 pid = fork(); 43 pid = fork();
52 if (pid == -1) { 44 if (pid == -1) {
53 perror("fork() failed"); 45 perror("fork() failed");