From: Cyril Bur <cyrilbur@gmail.com>
To: Michael Neuling <mikey@neuling.org>, mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org, Breno Leitao <brenohl@br.ibm.com>,
Gustavo Bueno Romero <gromero@br.ibm.com>
Subject: Re: [PATCH 1/2] powerpc/tm: Fix FP and VMX register corruption
Date: Sat, 13 May 2017 01:26:14 +1000 [thread overview]
Message-ID: <1494602774.21781.3.camel@gmail.com> (raw)
In-Reply-To: <20170508071627.21851-1-mikey@neuling.org>
On Mon, 2017-05-08 at 17:16 +1000, Michael Neuling wrote:
> In this commit:
> commit dc3106690b20305c3df06b42456fe386dd632ac9
> Author: Cyril Bur <cyrilbur@gmail.com>
> powerpc: tm: Always use fp_state and vr_state to store live registers
>
> A section of code was removed that copied the current state to
> checkpointed state. This should not have been removed.
>
-[space]
> When an FP unavailable is taken inside a transaction, we need to abort
> the transaction. This is because at the time of the tbegin, the FP
> state is bogus so the state stored in the checkpointed registers is
> incorrect. To fix this, we treclaim (to get the checkpointed GPRs) and
> then copy the thread_struct FP live state into the checkpointed
> state. We then trecheckpoint so that the FP state is correctly
> restored into the CPU.
>
> The coping of the FP registers from live to checkpointed is what was
> missing.
>
> This simplifies the logic slightly from the original patch.
> tm_reclaim_thread() will now always write the checkpointed FP
> state. Either the checkpointed FP statte will be written as part of
state
> the actual treclaim (in tm.S), or it'll be a copy of the live
> state. Which one we use is based on MSR[FP] from userspace.
>
> Similarly for VMX.
>
> CC: <stable@vger.kernel.org> # 4.9+
> Signed-off-by: Michael Neuling <mikey@neuling.org>
Reviewed-by: cyrilbur@gmail.com
> ---
> arch/powerpc/kernel/process.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index d645da302b..6305353237 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -864,6 +864,25 @@ static void tm_reclaim_thread(struct thread_struct *thr,
> if (!MSR_TM_SUSPENDED(mfmsr()))
> return;
>
> + /*
> + * If we are in a transaction and FP is off then we can't have
> + * used FP inside that transaction. Hence the checkpointed
> + * state is the same as the live state. We need to copy the
> + * live state to the checkpointed state so that when the
> + * transaction is restored, the checkpointed state is correct
> + * and the aborted transaction sees the correct state. We use
-[space]
> + * ckpt_regs.msr here as that's what tm_reclaim will use to
> + * determine if it's going to write the checkpointed state or
> + * not. So either this will write the checkpointed registers,
> + * or reclaim will. Similarly for VMX.
-[space]
> + */
> + if ((thr->ckpt_regs.msr & MSR_FP) == 0)
> + memcpy(&thr->ckfp_state, &thr->fp_state,
> + sizeof(struct thread_fp_state));
> + if ((thr->ckpt_regs.msr & MSR_VEC) == 0)
> + memcpy(&thr->ckvr_state, &thr->vr_state,
> + sizeof(struct thread_vr_state));
> +
> giveup_all(container_of(thr, struct task_struct, thread));
>
> tm_reclaim(thr, thr->ckpt_regs.msr, cause);
next prev parent reply other threads:[~2017-05-12 15:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-08 7:16 [PATCH 1/2] powerpc/tm: Fix FP and VMX register corruption Michael Neuling
2017-05-08 7:16 ` [PATCH 2/2] selftests/powerpc: Test TM and VMX register state Michael Neuling
2017-05-12 15:16 ` Cyril Bur
2017-05-15 9:31 ` Michael Ellerman
2017-05-17 9:34 ` [2/2] " Michael Ellerman
2017-05-12 15:26 ` Cyril Bur [this message]
2017-05-15 9:23 ` [PATCH 1/2] powerpc/tm: Fix FP and VMX register corruption Michael Ellerman
2017-05-17 9:34 ` [1/2] " Michael Ellerman
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=1494602774.21781.3.camel@gmail.com \
--to=cyrilbur@gmail.com \
--cc=brenohl@br.ibm.com \
--cc=gromero@br.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
/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).