arm64: mte: Restore the GCR_EL1 register after a suspend
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 17 Apr 2020 17:29:35 +0000 (18:29 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 4 Sep 2020 11:46:07 +0000 (12:46 +0100)
The CPU resume/suspend routines only take care of the common system
registers. Restore GCR_EL1 in addition via the __cpu_suspend_exit()
function.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
arch/arm64/include/asm/mte.h
arch/arm64/kernel/mte.c
arch/arm64/kernel/suspend.c

index df2efbc..c93047e 100644 (file)
@@ -22,6 +22,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_exit(void);
 long set_mte_ctrl(unsigned long arg);
 long get_mte_ctrl(void);
 
@@ -42,6 +43,9 @@ static inline void flush_mte_state(void)
 static inline void mte_thread_switch(struct task_struct *next)
 {
 }
+static inline void mte_suspend_exit(void)
+{
+}
 static inline long set_mte_ctrl(unsigned long arg)
 {
        return 0;
index 07798b8..09cf76f 100644 (file)
@@ -116,6 +116,14 @@ void mte_thread_switch(struct task_struct *next)
        update_gcr_el1_excl(next->thread.gcr_user_incl);
 }
 
+void mte_suspend_exit(void)
+{
+       if (!system_supports_mte())
+               return;
+
+       update_gcr_el1_excl(current->thread.gcr_user_incl);
+}
+
 long set_mte_ctrl(unsigned long arg)
 {
        u64 tcf0;
index c1dee90..62c239c 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/daifflags.h>
 #include <asm/debug-monitors.h>
 #include <asm/exec.h>
+#include <asm/mte.h>
 #include <asm/memory.h>
 #include <asm/mmu_context.h>
 #include <asm/smp_plat.h>
@@ -74,6 +75,9 @@ void notrace __cpu_suspend_exit(void)
         */
        if (arm64_get_ssbd_state() == ARM64_SSBD_FORCE_DISABLE)
                arm64_set_ssbd_mitigation(false);
+
+       /* Restore additional MTE-specific configuration */
+       mte_suspend_exit();
 }
 
 /*