From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Breno Leitao <leitao@debian.org>, linuxppc-dev@lists.ozlabs.org
Cc: mikey@neuling.org, gromero@linux.vnet.ibm.com
Subject: Re: [PATCH 2/2] powerpc/tm: Avoid SPR flush if TM is disabled
Date: Fri, 11 Jun 2021 09:35:52 +0200 [thread overview]
Message-ID: <72d2aedc-7604-3f46-c5c7-34f11455e8aa@csgroup.eu> (raw)
In-Reply-To: <1538423270-17527-2-git-send-email-leitao@debian.org>
Le 01/10/2018 à 21:47, Breno Leitao a écrit :
> There is a bug in the flush_tmregs_to_thread() function, where it forces
> TM SPRs to be saved to the thread even if the TM facility is disabled.
>
> This bug could be reproduced using a simple test case:
>
> mtspr(SPRN_TEXASR, XX);
> sleep until load_tm == 0
> cause a coredump
> read SPRN_TEXASR in the coredump
>
> In this case, the coredump may contain an invalid SPR, because the
> current code is flushing live SPRs (Used by the last thread with TM
> active) into the current thread, overwriting the latest SPRs (which were
> valid).
>
> This patch checks if TM is enabled for current task before
> saving the SPRs, otherwise, the TM is lazily disabled and the thread
> value is already up-to-date and could be used directly, and saving is
> not required.
If this patch is still applicable, it has to be rebased.
>
> Fixes: cd63f3cf1d5 ("powerpc/tm: Fix saving of TM SPRs in core dump")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> arch/powerpc/kernel/ptrace.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 9667666eb18e..e0a2ee865032 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -138,7 +138,12 @@ static void flush_tmregs_to_thread(struct task_struct *tsk)
>
> if (MSR_TM_SUSPENDED(mfmsr())) {
> tm_reclaim_current(TM_CAUSE_SIGNAL);
> - } else {
> + } else if (tm_enabled(tsk)) {
> + /*
> + * Only flush TM SPRs to the thread if TM was enabled,
> + * otherwise (TM lazily disabled), the thread already
> + * contains the latest SPR value
> + */
> tm_enable();
> tm_save_sprs(&(tsk->thread));
> }
>
next prev parent reply other threads:[~2021-06-11 7:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 19:47 [PATCH 1/2] powerpc/tm: Move tm_enable definition Breno Leitao
2018-10-01 19:47 ` [PATCH 2/2] powerpc/tm: Avoid SPR flush if TM is disabled Breno Leitao
2018-10-02 0:05 ` Michael Neuling
2021-06-11 7:35 ` Christophe Leroy [this message]
2021-06-11 7:32 ` [PATCH 1/2] powerpc/tm: Move tm_enable definition Christophe Leroy
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=72d2aedc-7604-3f46-c5c7-34f11455e8aa@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=gromero@linux.vnet.ibm.com \
--cc=leitao@debian.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.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).