Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Anton Blanchard and committed by
Michael Ellerman
db1231dc 20dbe670

+1 -17
+1 -1
arch/powerpc/kernel/process.c
··· 1287 1287 #ifdef CONFIG_PPC64 1288 1288 if (cpu_has_feature(CPU_FTR_DSCR)) { 1289 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 1292 if (cpu_has_feature(CPU_FTR_HAS_PPR)) 1293 1293 p->thread.ppr = INIT_PPR;
-8
tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
··· 60 60 else 61 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 63 pid = fork(); 72 64 if (pid == -1) { 73 65 perror("fork() failed");
-8
tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
··· 40 40 else 41 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 43 pid = fork(); 52 44 if (pid == -1) { 53 45 perror("fork() failed");