Skip to contentSkip to conversation

powerpc: Fix DSCR inheritance over fork()

PATCH Applied Anton Blanchard 2 participants 2 messages Dec 9, 2015 – Dec 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 arch/powerpc/kernel/process.c                                 | 2 +-
 tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c | 8 --------
 tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c      | 8 --------
 3 files changed, 1 insertion(+), 17 deletions(-)
arch/powerpc/kernel/process.c +1 -1
index ec10250..fffc2d2 100644
@@ -1282,7 +1282,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 #ifdef CONFIG_PPC64 
 	if (cpu_has_feature(CPU_FTR_DSCR)) {
 		p->thread.dscr_inherit = current->thread.dscr_inherit;
-		p->thread.dscr = current->thread.dscr;
+		p->thread.dscr = mfspr(SPRN_DSCR);
 	}
 	if (cpu_has_feature(CPU_FTR_HAS_PPR))
 		p->thread.ppr = INIT_PPR;
tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c +0 -8
index 8265504..08a8b95 100644
@@ -60,14 +60,6 @@ int dscr_inherit_exec(void)
 		else
 			set_dscr(dscr);
 
-		/*
-		 * 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);
-
 		pid = fork();
 		if (pid == -1) {
 			perror("fork() failed");
tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c +0 -8
index 4e414ca..3e5a6d1 100644
@@ -40,14 +40,6 @@ int dscr_inherit(void)
 		else
 			set_dscr(dscr);
 
-		/*
-		 * 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);
-
 		pid = fork();
 		if (pid == -1) {
 			perror("fork() failed");
Signature · 1 line
2.5.0
reviewer Applied
#1 lore raw
Quoted 10 lines · Anton Blanchard

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);

Quoted 5 lines

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.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/db1231dcdb4dc6cdcbdef0ba

cheers