powerpc: Fix DSCR inheritance over fork()
authorAnton Blanchard <anton@samba.org>
Wed, 9 Dec 2015 09:11:47 +0000 (20:11 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 10 Dec 2015 10:11:13 +0000 (21:11 +1100)
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>
arch/powerpc/kernel/process.c
tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c

index 9da7b5f0c3a55fa630232e98b61ed3c21698770b..6f76f25c3ee8b5c9acaf6e42cbfe677456ce6c28 100644 (file)
@@ -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;
index 8265504de5717b345336c3c2bc11e444e934b729..08a8b95e3bc185830bc8956c94a659d678f1cc18 100644 (file)
@@ -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");
index 4e414caf7f4016ba9f624f34da5ab1faf38b4719..3e5a6d195e9ab04ca54d22bfcaeb775ddd5e2892 100644 (file)
@@ -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");