Message ID | 20210914215429.745849-1-pcc@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] arm64: add an MTE support check to the top of mte_thread_switch() | expand |
On Tue, Sep 14, 2021 at 02:54:28PM -0700, Peter Collingbourne wrote: > This lets us avoid doing unnecessary work on hardware that does > not support MTE, and will allow us to freely use MTE instructions > in the code called by mte_thread_switch(). > > Signed-off-by: Peter Collingbourne <pcc@google.com> > Link: https://linux-review.googlesource.com/id/I02fd000d1ef2c86c7d2952a7f099b254ec227a5d > --- > arch/arm64/kernel/mte.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > index 9d314a3bad3b..8fc2d90eeb00 100644 > --- a/arch/arm64/kernel/mte.c > +++ b/arch/arm64/kernel/mte.c > @@ -199,6 +199,9 @@ void mte_thread_init_user(void) > > void mte_thread_switch(struct task_struct *next) > { > + if (!system_supports_mte()) > + return; > + > mte_update_sctlr_user(next); Ah, good point. While you are at this, could you please remove the system_supports_mte() check from mte_check_tfsr_el1() and add it to mte_check_tfsr_entry/exit? On the exit path, we unnecessarily do a dsb+isb even when MTE is not present. I guess we could also skip the tfsr_el1 check if !system_uses_mte_async_mode() (well, I'd need to page in which TFSR bits are set for uaccess). Thanks.
On Wed, Sep 15, 2021 at 10:59 AM Catalin Marinas <catalin.marinas@arm.com> wrote: > > On Tue, Sep 14, 2021 at 02:54:28PM -0700, Peter Collingbourne wrote: > > This lets us avoid doing unnecessary work on hardware that does > > not support MTE, and will allow us to freely use MTE instructions > > in the code called by mte_thread_switch(). > > > > Signed-off-by: Peter Collingbourne <pcc@google.com> > > Link: https://linux-review.googlesource.com/id/I02fd000d1ef2c86c7d2952a7f099b254ec227a5d > > --- > > arch/arm64/kernel/mte.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c > > index 9d314a3bad3b..8fc2d90eeb00 100644 > > --- a/arch/arm64/kernel/mte.c > > +++ b/arch/arm64/kernel/mte.c > > @@ -199,6 +199,9 @@ void mte_thread_init_user(void) > > > > void mte_thread_switch(struct task_struct *next) > > { > > + if (!system_supports_mte()) > > + return; > > + > > mte_update_sctlr_user(next); > > Ah, good point. While you are at this, could you please remove the > system_supports_mte() check from mte_check_tfsr_el1() and add it to > mte_check_tfsr_entry/exit? On the exit path, we unnecessarily do a > dsb+isb even when MTE is not present. Thanks for the suggestion. Done in v3. Peter
diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c index 9d314a3bad3b..8fc2d90eeb00 100644 --- a/arch/arm64/kernel/mte.c +++ b/arch/arm64/kernel/mte.c @@ -199,6 +199,9 @@ void mte_thread_init_user(void) void mte_thread_switch(struct task_struct *next) { + if (!system_supports_mte()) + return; + mte_update_sctlr_user(next); /*
This lets us avoid doing unnecessary work on hardware that does not support MTE, and will allow us to freely use MTE instructions in the code called by mte_thread_switch(). Signed-off-by: Peter Collingbourne <pcc@google.com> Link: https://linux-review.googlesource.com/id/I02fd000d1ef2c86c7d2952a7f099b254ec227a5d --- arch/arm64/kernel/mte.c | 3 +++ 1 file changed, 3 insertions(+)