From: Paul Mackerras <paulus@samba.org>
To: akpm@osdl.org, torvalds@osdl.org
Cc: anton@samba.org, benh@kernel.crashing.org, linux-kernel@vger.kernel.org
Subject: [PATCH] PPC/PPC64: Fix FP state corruption on UP
Date: Wed, 27 Oct 2004 16:15:21 +1000 [thread overview]
Message-ID: <16767.15609.66891.537673@cargo.ozlabs.ibm.com> (raw)
Unfortunately the patch Ben sent last week to fix a bug in the saving
and restoring of floating-point and altivec context across signal
handlers introduced another bug, which tends to corrupt the FP and
altivec contexts of other tasks. This patch fixes the problem for
both ppc32 and ppc64. Please apply.
Signed-off-by: Paul Mackerras <paulus@samba.org>
diff -urN linux-2.5/arch/ppc/kernel/signal.c test/arch/ppc/kernel/signal.c
--- linux-2.5/arch/ppc/kernel/signal.c 2004-10-20 08:16:36.000000000 +1000
+++ test/arch/ppc/kernel/signal.c 2004-10-27 14:29:48.494955208 +1000
@@ -290,7 +290,7 @@
/* force the process to reload the FP registers from
current->thread when it next does FP instructions */
- regs->msr &= ~MSR_FP;
+ regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
if (__copy_from_user(current->thread.fpr, &sr->mc_fregs,
sizeof(sr->mc_fregs)))
return 1;
@@ -330,9 +330,14 @@
#endif /* CONFIG_SPE */
#ifndef CONFIG_SMP
- last_task_used_math = NULL;
- last_task_used_altivec = NULL;
- last_task_used_spe = NULL;
+ preempt_disable();
+ if (last_task_used_math == current)
+ last_task_used_math = NULL;
+ if (last_task_used_altivec == current)
+ last_task_used_altivec = NULL;
+ if (last_task_used_spe == current)
+ last_task_used_spe = NULL;
+ preempt_enable();
#endif
return 0;
}
diff -urN linux-2.5/arch/ppc64/kernel/signal.c test/arch/ppc64/kernel/signal.c
--- linux-2.5/arch/ppc64/kernel/signal.c 2004-10-20 08:16:36.000000000 +1000
+++ test/arch/ppc64/kernel/signal.c 2004-10-27 14:31:57.301942136 +1000
@@ -224,8 +224,12 @@
#endif /* CONFIG_ALTIVEC */
#ifndef CONFIG_SMP
- last_task_used_math = NULL;
- last_task_used_altivec = NULL;
+ preempt_disable();
+ if (last_task_used_math == current)
+ last_task_used_math = NULL;
+ if (last_task_used_altivec == current)
+ last_task_used_altivec = NULL;
+ preempt_enable();
#endif
/* Force reload of FP/VEC */
regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1 | MSR_VEC);
diff -urN linux-2.5/arch/ppc64/kernel/signal32.c test/arch/ppc64/kernel/signal32.c
--- linux-2.5/arch/ppc64/kernel/signal32.c 2004-10-20 08:16:36.000000000 +1000
+++ test/arch/ppc64/kernel/signal32.c 2004-10-27 14:32:45.086999136 +1000
@@ -235,8 +235,12 @@
#endif /* CONFIG_ALTIVEC */
#ifndef CONFIG_SMP
- last_task_used_math = NULL;
- last_task_used_altivec = NULL;
+ preempt_disable();
+ if (last_task_used_math == current)
+ last_task_used_math = NULL;
+ if (last_task_used_altivec == current)
+ last_task_used_altivec = NULL;
+ preempt_enable();
#endif
return 0;
}
reply other threads:[~2004-10-27 6:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16767.15609.66891.537673@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=akpm@osdl.org \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®