From: Michael Neuling <mikey@neuling.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Neuling <mikey@neuling.org>,
linuxppc-dev@lists.ozlabs.org, Matt Evans <matt@ozlabs.org>
Subject: [PATCH 11/17] powerpc: Assembler routines for FP/VSX/VMX unavailable during a transaction
Date: Fri, 18 Jan 2013 16:48:31 +1100 [thread overview]
Message-ID: <1358488117-17363-12-git-send-email-mikey@neuling.org> (raw)
In-Reply-To: <1358488117-17363-1-git-send-email-mikey@neuling.org>
We do lazy FP but not lazy TM (ie. userspace starts with MSR TM=1 FP=0). Hence
if userspace does an FP instruction during a transaction, we'll take an
fp unavailable exception.
This adds functions needed to handle this case. We have to inject the current
FP state into the checkpoint so that the hardware can decide what to do with
the transaction. We can't inject only the FP so we have to do a full treclaim
and recheckpoint to inject just the FP state. This will cause the transaction
to be marked as aborted by the hardware.
This just add the routines needed to do this for FP, VMX and VSX. It doesn't
hook them into the rest of the code yet.
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
arch/powerpc/kernel/traps.c | 95 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index dda0517..311770d 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -58,6 +58,7 @@
#include <asm/rio.h>
#include <asm/fadump.h>
#include <asm/switch_to.h>
+#include <asm/tm.h>
#include <asm/debug.h>
#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
@@ -1192,6 +1193,100 @@ void tm_unavailable_exception(struct pt_regs *regs)
die("Unexpected TM unavailable exception", regs, SIGABRT);
}
+#ifdef CONFIG_TRANSACTIONAL_MEM
+
+extern void do_load_up_fpu(struct pt_regs *regs);
+
+void fp_unavailable_tm(struct pt_regs *regs)
+{
+ /* Note: This does not handle any kind of FP laziness. */
+
+ /* We restore the interrupt state now */
+ if (!arch_irq_disabled_regs(regs))
+ local_irq_enable();
+
+ TM_DEBUG("FP Unavailable trap whilst transactional at 0x%lx, MSR=%lx\n",
+ regs->nip, regs->msr);
+ tm_enable();
+
+ /* We can only have got here if the task started using FP after
+ * beginning the transaction. So, the transactional regs are just a
+ * copy of the checkpointed ones. But, we still need to recheckpoint
+ * as we're enabling FP for the process; it will return, abort the
+ * transaction, and probably retry but now with FP enabled. So the
+ * checkpointed FP registers need to be loaded.
+ */
+ tm_reclaim(¤t->thread, current->thread.regs->msr,
+ TM_CAUSE_FAC_UNAV);
+ /* Reclaim didn't save out any FPRs to transact_fprs. */
+
+ /* Enable FP for the task: */
+ regs->msr |= (MSR_FP | current->thread.fpexc_mode);
+
+ /* This loads and recheckpoints the FP registers from
+ * thread.fpr[]. They will remain in registers after the
+ * checkpoint so we don't need to reload them after.
+ */
+ tm_recheckpoint(¤t->thread, regs->msr);
+}
+
+#ifdef CONFIG_ALTIVEC
+extern void do_load_up_altivec(struct pt_regs *regs);
+
+void altivec_unavailable_tm(struct pt_regs *regs)
+{
+ /* See the comments in fp_unavailable_tm(). This function operates
+ * the same way.
+ */
+
+ /* We restore the interrupt state now */
+ if (!arch_irq_disabled_regs(regs))
+ local_irq_enable();
+
+ TM_DEBUG("Vector Unavailable trap whilst transactional at 0x%lx,"
+ "MSR=%lx\n",
+ regs->nip, regs->msr);
+ tm_enable();
+ tm_reclaim(¤t->thread, current->thread.regs->msr,
+ TM_CAUSE_FAC_UNAV);
+ regs->msr |= MSR_VEC;
+ tm_recheckpoint(¤t->thread, regs->msr);
+ current->thread.used_vr = 1;
+}
+#endif
+
+#ifdef CONFIG_VSX
+void vsx_unavailable_tm(struct pt_regs *regs)
+{
+ /* See the comments in fp_unavailable_tm(). This works similarly,
+ * though we're loading both FP and VEC registers in here.
+ *
+ * If FP isn't in use, load FP regs. If VEC isn't in use, load VEC
+ * regs. Either way, set MSR_VSX.
+ */
+
+ /* We restore the interrupt state now */
+ if (!arch_irq_disabled_regs(regs))
+ local_irq_enable();
+
+ TM_DEBUG("VSX Unavailable trap whilst transactional at 0x%lx,"
+ "MSR=%lx\n",
+ regs->nip, regs->msr);
+
+ tm_enable();
+ /* This reclaims FP and/or VR regs if they're already enabled */
+ tm_reclaim(¤t->thread, current->thread.regs->msr,
+ TM_CAUSE_FAC_UNAV);
+
+ regs->msr |= MSR_VEC | MSR_FP | current->thread.fpexc_mode |
+ MSR_VSX;
+ /* This loads & recheckpoints FP and VRs. */
+ tm_recheckpoint(¤t->thread, regs->msr);
+ current->thread.used_vsr = 1;
+}
+#endif
+#endif /* CONFIG_TRANSACTIONAL_MEM */
+
void performance_monitor_exception(struct pt_regs *regs)
{
__get_cpu_var(irq_stat).pmu_irqs++;
--
1.7.10.4
next prev parent reply other threads:[~2013-01-18 5:48 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 2:47 [PATCH 00/16] powerpc: Hardware transactional memory support for POWER8 Michael Neuling
2012-11-27 2:47 ` [PATCH 01/16] powerpc: Add new CPU feature bit for transactional memory Michael Neuling
2012-11-27 2:47 ` [PATCH 02/16] powerpc: Add new instructions " Michael Neuling
2012-11-27 2:47 ` [PATCH 03/16] powerpc: Add additional state needed for transactional memory to thread struct Michael Neuling
2012-11-27 2:47 ` [PATCH 04/16] powerpc: New macros for transactional memory support Michael Neuling
2012-11-27 2:47 ` [PATCH 05/16] powerpc: Register defines for various transactional memory registers Michael Neuling
2012-11-27 2:47 ` [PATCH 06/16] powerpc: Add transactional memory paca scratch register to show_regs Michael Neuling
2012-11-27 2:47 ` [PATCH 07/16] powerpc: Add helper functions for transactional memory context switching Michael Neuling
2012-11-27 2:48 ` [PATCH 08/16] powerpc: Add FP/VSX and VMX register load functions for transactional memory Michael Neuling
2012-11-27 2:48 ` [PATCH 09/16] powerpc: Add reclaim and recheckpoint functions for context switching transactional memory processes Michael Neuling
2012-11-27 2:48 ` [PATCH 10/16] powerpc: Add transactional memory unavaliable execption handler Michael Neuling
2012-11-27 2:48 ` [PATCH 11/16] powerpc: Assembler routines for FP/VSX/VMX unavailable during a transaction Michael Neuling
2012-11-27 2:48 ` [PATCH 12/16] powerpc: Hook in new transactional memory code Michael Neuling
2012-11-27 2:48 ` [PATCH 13/16] powerpc: Add transactional memory to POWER8 cpu features Michael Neuling
2012-11-27 2:48 ` [PATCH 14/16] powerpc: Add config option for transactional memory Michael Neuling
2012-11-27 2:48 ` [PATCH 15/16] powerpc: Add transactional memory to pseries and ppc64 defconfigs Michael Neuling
2012-11-27 2:48 ` [PATCH 16/16] powerpc: Documentation for transactional memory on powerpc Michael Neuling
2013-01-18 5:48 ` [PATCH 00/17] powerpc: Hardware transactional memory support for POWER8 Michael Neuling
2013-01-18 5:48 ` [PATCH 01/17] powerpc: Add new CPU feature bit for transactional memory Michael Neuling
2013-01-18 5:48 ` [PATCH 02/17] powerpc: Add new instructions " Michael Neuling
2013-01-18 5:48 ` [PATCH 03/17] powerpc: Add additional state needed for transactional memory to thread struct Michael Neuling
2013-01-18 5:48 ` [PATCH 04/17] powerpc: New macros for transactional memory support Michael Neuling
2013-01-18 5:48 ` [PATCH 05/17] powerpc: Register defines for various transactional memory registers Michael Neuling
2013-01-18 5:48 ` [PATCH 06/17] powerpc: Add transactional memory paca scratch register to show_regs Michael Neuling
2013-01-18 5:48 ` [PATCH 07/17] powerpc: Add helper functions for transactional memory context switching Michael Neuling
2013-01-18 5:48 ` [PATCH 08/17] powerpc: Add FP/VSX and VMX register load functions for transactional memory Michael Neuling
2013-01-18 5:48 ` [PATCH 09/17] powerpc: Add reclaim and recheckpoint functions for context switching transactional memory processes Michael Neuling
2013-01-18 5:48 ` [PATCH 10/17] powerpc: Add transactional memory unavaliable execption handler Michael Neuling
2013-01-18 5:48 ` Michael Neuling [this message]
2013-01-18 5:48 ` [PATCH 12/17] powerpc: Hook in new transactional memory code Michael Neuling
2013-01-18 5:48 ` [PATCH 13/17] powerpc: Add new transactional memory state to the signal context Michael Neuling
2013-01-18 5:48 ` [PATCH 14/17] powerpc: Add transactional memory to POWER8 cpu features Michael Neuling
2013-01-18 5:48 ` [PATCH 15/17] powerpc: Add config option for transactional memory Michael Neuling
2013-01-18 5:48 ` [PATCH 16/17] powerpc: Add transactional memory to pseries and ppc64 defconfigs Michael Neuling
2013-01-18 5:48 ` [PATCH 17/17] powerpc: Documentation for transactional memory on powerpc Michael Neuling
2013-02-13 4:31 ` [PATCH 00/17] powerpc: Hardware transactional memory support for POWER8 Michael Neuling
2013-02-13 4:31 ` [PATCH 01/17] powerpc: Add new CPU feature bit for transactional memory Michael Neuling
2013-02-13 4:31 ` [PATCH 02/17] powerpc: Add new instructions " Michael Neuling
2013-02-13 4:31 ` [PATCH 03/17] powerpc: Add additional state needed for transactional memory to thread struct Michael Neuling
2013-02-13 4:31 ` [PATCH 04/17] powerpc: New macros for transactional memory support Michael Neuling
2013-02-13 4:31 ` [PATCH 05/17] powerpc: Register defines for various transactional memory registers Michael Neuling
2013-02-13 4:31 ` [PATCH 06/17] powerpc: Add transactional memory paca scratch register to show_regs Michael Neuling
2013-02-13 13:52 ` Kumar Gala
2013-02-14 1:53 ` Michael Neuling
2013-02-13 4:31 ` [PATCH 07/17] powerpc: Add helper functions for transactional memory context switching Michael Neuling
2013-02-13 4:31 ` [PATCH 08/17] powerpc: Add FP/VSX and VMX register load functions for transactional memory Michael Neuling
2013-02-13 13:54 ` Kumar Gala
2013-02-14 1:53 ` Michael Neuling
2013-02-13 4:31 ` [PATCH 09/17] powerpc: Add reclaim and recheckpoint functions for context switching transactional memory processes Michael Neuling
2013-02-13 4:31 ` [PATCH 10/17] powerpc: Add transactional memory unavaliable execption handler Michael Neuling
2013-02-13 4:31 ` [PATCH 11/17] powerpc: Routines for FP/VSX/VMX unavailable during a transaction Michael Neuling
2013-02-13 4:31 ` [PATCH 12/17] powerpc: Hook in new transactional memory code Michael Neuling
2013-02-13 4:31 ` [PATCH 13/17] powerpc: Add new transactional memory state to the signal context Michael Neuling
2013-02-13 4:31 ` [PATCH 14/17] powerpc: Add transactional memory to POWER8 cpu features Michael Neuling
2013-02-13 4:31 ` [PATCH 15/17] powerpc: Add config option for transactional memory Michael Neuling
2013-02-13 14:02 ` Kumar Gala
2013-02-14 1:52 ` Michael Neuling
2013-02-13 4:31 ` [PATCH 16/17] powerpc: Add transactional memory to pseries and ppc64 defconfigs Michael Neuling
2013-02-13 4:31 ` [PATCH 17/17] powerpc: Documentation for transactional memory on powerpc Michael Neuling
2013-02-14 2:21 ` [PATCH 00/17] powerpc: Hardware transactional memory support for POWER8 Michael Neuling
2013-02-14 2:21 ` [PATCH 01/17] powerpc: Add new CPU feature bit for transactional memory Michael Neuling
2013-02-14 2:21 ` [PATCH 02/17] powerpc: Add new instructions " Michael Neuling
2013-02-14 2:21 ` [PATCH 03/17] powerpc: Add additional state needed for transactional memory to thread struct Michael Neuling
2013-02-14 2:21 ` [PATCH 04/17] powerpc: New macros for transactional memory support Michael Neuling
2013-02-14 2:21 ` [PATCH 05/17] powerpc: Register defines for various transactional memory registers Michael Neuling
2013-02-14 2:21 ` [PATCH 06/17] powerpc: Add transactional memory paca scratch register to show_regs Michael Neuling
2013-02-14 2:21 ` [PATCH 07/17] powerpc: Add helper functions for transactional memory context switching Michael Neuling
2013-02-14 2:21 ` [PATCH 08/17] powerpc: Add FP/VSX and VMX register load functions for transactional memory Michael Neuling
2013-02-14 2:21 ` [PATCH 09/17] powerpc: Add reclaim and recheckpoint functions for context switching transactional memory processes Michael Neuling
2013-02-14 2:21 ` [PATCH 10/17] powerpc: Add transactional memory unavaliable execption handler Michael Neuling
2013-02-14 2:21 ` [PATCH 11/17] powerpc: Routines for FP/VSX/VMX unavailable during a transaction Michael Neuling
2013-02-14 2:21 ` [PATCH 12/17] powerpc: Hook in new transactional memory code Michael Neuling
2013-02-14 2:21 ` [PATCH 13/17] powerpc: Add new transactional memory state to the signal context Michael Neuling
2013-02-14 2:21 ` [PATCH 14/17] powerpc: Add transactional memory to POWER8 cpu features Michael Neuling
2013-02-14 2:21 ` [PATCH 15/17] powerpc: Add config option for transactional memory Michael Neuling
2013-02-14 2:21 ` [PATCH 16/17] powerpc: Add transactional memory to pseries and ppc64 defconfigs Michael Neuling
2013-02-14 2:21 ` [PATCH 17/17] powerpc: Documentation for transactional memory on powerpc Michael Neuling
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=1358488117-17363-12-git-send-email-mikey@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=matt@ozlabs.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;
as well as URLs for NNTP newsgroup(s).