Skip to content

Commit

Permalink
powerpc: Fix DSCR inheritance over fork()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
antonblanchard authored and mpe committed Dec 10, 2015
1 parent 20dbe67 commit db1231d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,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;
Expand Down
8 changes: 0 additions & 8 deletions tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 0 additions & 8 deletions tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit db1231d

Please sign in to comment.