From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Dmitry Vyukov <dvyukov@google.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Marco Elver <elver@google.com>,
Evgenii Stepanov <eugenis@google.com>,
Branislav Rankov <Branislav.Rankov@arm.com>,
Andrey Konovalov <andreyknvl@google.com>
Subject: Re: [PATCH v13 6/7] arm64: mte: Report async tag faults before suspend
Date: Fri, 12 Feb 2021 12:00:15 +0000 [thread overview]
Message-ID: <20210212120015.GA18281@e121166-lin.cambridge.arm.com> (raw)
In-Reply-To: <20210211153353.29094-7-vincenzo.frascino@arm.com>
On Thu, Feb 11, 2021 at 03:33:52PM +0000, Vincenzo Frascino wrote:
> When MTE async mode is enabled TFSR_EL1 contains the accumulative
> asynchronous tag check faults for EL1 and EL0.
>
> During the suspend/resume operations the firmware might perform some
> operations that could change the state of the register resulting in
> a spurious tag check fault report.
>
> Report asynchronous tag faults before suspend and clear the TFSR_EL1
> register after resume to prevent this to happen.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> arch/arm64/include/asm/mte.h | 4 ++++
> arch/arm64/kernel/mte.c | 20 ++++++++++++++++++++
> arch/arm64/kernel/suspend.c | 3 +++
> 3 files changed, 27 insertions(+)
>
> diff --git a/arch/arm64/include/asm/mte.h b/arch/arm64/include/asm/mte.h
> index 43169b978cd3..33e88a470357 100644
> --- a/arch/arm64/include/asm/mte.h
> +++ b/arch/arm64/include/asm/mte.h
> @@ -41,6 +41,7 @@ void mte_sync_tags(pte_t *ptep, pte_t pte);
> void mte_copy_page_tags(void *kto, const void *kfrom);
> void flush_mte_state(void);
> void mte_thread_switch(struct task_struct *next);
> +void mte_suspend_enter(void);
> void mte_suspend_exit(void);
> long set_mte_ctrl(struct task_struct *task, unsigned long arg);
> long get_mte_ctrl(struct task_struct *task);
> @@ -66,6 +67,9 @@ static inline void flush_mte_state(void)
> static inline void mte_thread_switch(struct task_struct *next)
> {
> }
> +static inline void mte_suspend_enter(void)
> +{
> +}
> static inline void mte_suspend_exit(void)
> {
> }
> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
> index f5aa5bea6dfe..de905102245a 100644
> --- a/arch/arm64/kernel/mte.c
> +++ b/arch/arm64/kernel/mte.c
> @@ -258,12 +258,32 @@ void mte_thread_switch(struct task_struct *next)
> mte_check_tfsr_el1();
> }
>
> +void mte_suspend_enter(void)
> +{
> + if (!system_supports_mte())
> + return;
> +
> + /*
> + * The barriers are required to guarantee that the indirect writes
> + * to TFSR_EL1 are synchronized before we report the state.
> + */
> + dsb(nsh);
> + isb();
> +
> + /* Report SYS_TFSR_EL1 before suspend entry */
> + mte_check_tfsr_el1();
> +}
> +
> void mte_suspend_exit(void)
> {
> if (!system_supports_mte())
> return;
>
> update_gcr_el1_excl(gcr_kernel_excl);
> +
> + /* Clear SYS_TFSR_EL1 after suspend exit */
> + write_sysreg_s(0, SYS_TFSR_EL1);
AFAICS it is not needed, it is done already in __cpu_setup() (that is
called by cpu_resume on return from cpu_suspend() from firmware).
However, I have a question. We are relying on context switch to set
sctlr_el1_tfc0 right ? If that's the case, till the thread resuming from
low power switches context we are running with SCTLR_EL1_TCF0 not
reflecting the actual value.
Just making sure that I understand it correctly, I need to check the
resume from suspend-to-RAM path, it is something that came up with perf
save/restore already in the past.
Lorenzo
> +
> }
>
> long set_mte_ctrl(struct task_struct *task, unsigned long arg)
> diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
> index a67b37a7a47e..25a02926ad88 100644
> --- a/arch/arm64/kernel/suspend.c
> +++ b/arch/arm64/kernel/suspend.c
> @@ -91,6 +91,9 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
> unsigned long flags;
> struct sleep_stack_data state;
>
> + /* Report any MTE async fault before going to suspend */
> + mte_suspend_enter();
> +
> /*
> * From this point debug exceptions are disabled to prevent
> * updates to mdscr register (saved and restored along with
> --
> 2.30.0
>
next prev parent reply other threads:[~2021-02-12 12:03 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 15:33 [PATCH v13 0/7] arm64: ARMv8.5-A: MTE: Add async mode support Vincenzo Frascino
2021-02-11 15:33 ` [PATCH v13 1/7] arm64: mte: Add asynchronous " Vincenzo Frascino
2021-02-12 21:21 ` Andrey Konovalov
2021-02-22 11:14 ` Vincenzo Frascino
2021-02-11 15:33 ` [PATCH v13 2/7] kasan: Add KASAN mode kernel parameter Vincenzo Frascino
2021-02-11 17:50 ` Andrey Konovalov
2021-02-12 11:26 ` Vincenzo Frascino
2021-02-11 15:33 ` [PATCH v13 3/7] kasan: Add report for async mode Vincenzo Frascino
2021-02-11 20:03 ` kernel test robot
2021-02-11 20:13 ` Andrey Konovalov
2021-02-12 11:25 ` Vincenzo Frascino
2021-02-12 14:47 ` Andrey Konovalov
2021-02-11 23:03 ` kernel test robot
2021-02-11 15:33 ` [PATCH v13 4/7] arm64: mte: Enable TCO in functions that can read beyond buffer limits Vincenzo Frascino
2021-02-12 17:21 ` Catalin Marinas
2021-02-22 12:08 ` Vincenzo Frascino
2021-02-22 17:58 ` Catalin Marinas
2021-02-23 10:56 ` Vincenzo Frascino
2021-02-23 12:05 ` Catalin Marinas
2021-02-23 12:22 ` Vincenzo Frascino
2021-02-23 12:49 ` Will Deacon
2021-02-23 13:14 ` Catalin Marinas
2021-02-23 14:25 ` Vincenzo Frascino
2021-02-11 15:33 ` [PATCH v13 5/7] arm64: mte: Enable async tag check fault Vincenzo Frascino
2021-02-11 15:33 ` [PATCH v13 6/7] arm64: mte: Report async tag faults before suspend Vincenzo Frascino
2021-02-12 12:00 ` Lorenzo Pieralisi [this message]
2021-02-12 12:30 ` Lorenzo Pieralisi
2021-02-12 13:05 ` Vincenzo Frascino
2021-02-12 13:19 ` Catalin Marinas
2021-02-12 17:24 ` Catalin Marinas
2021-02-11 15:33 ` [PATCH v13 7/7] kasan: don't run tests in async mode Vincenzo Frascino
2021-02-12 0:49 ` kernel test robot
2021-02-12 17:22 ` Catalin Marinas
2021-02-12 21:44 ` Andrey Konovalov
2021-02-22 11:17 ` Vincenzo Frascino
2021-02-22 13:35 ` Andrey Konovalov
2021-02-11 15:45 ` [PATCH v13 0/7] arm64: ARMv8.5-A: MTE: Add async mode support Vincenzo Frascino
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=20210212120015.GA18281@e121166-lin.cambridge.arm.com \
--to=lorenzo.pieralisi@arm.com \
--cc=Branislav.Rankov@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=aryabinin@virtuozzo.com \
--cc=catalin.marinas@arm.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=will@kernel.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).