Skip to content

Commit 59f4406

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: mte: fix restoration of GCR_EL1 from suspend
Since commit: bad1e1c ("arm64: mte: switch GCR_EL1 in kernel entry and exit") we saved/restored the user GCR_EL1 value at exception boundaries, and update_gcr_el1_excl() is no longer used for this. However it is used to restore the kernel's GCR_EL1 value when returning from a suspend state. Thus, the comment is misleading (and an ISB is necessary). When restoring the kernel's GCR value, we need an ISB to ensure this is used by subsequent instructions. We don't necessarily get an ISB by other means (e.g. if the kernel is built without support for pointer authentication). As __cpu_setup() initialised GCR_EL1.Exclude to 0xffff, until a context synchronization event, allocation tag 0 may be used rather than the desired set of tags. This patch drops the misleading comment, adds the missing ISB, and for clarity folds update_gcr_el1_excl() into its only user. Fixes: bad1e1c ("arm64: mte: switch GCR_EL1 in kernel entry and exit") Signed-off-by: Mark Rutland <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 295cf15 commit 59f4406

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

arch/arm64/kernel/mte.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,6 @@ void mte_check_tfsr_el1(void)
193193
}
194194
#endif
195195

196-
static void update_gcr_el1_excl(u64 excl)
197-
{
198-
199-
/*
200-
* Note that the mask controlled by the user via prctl() is an
201-
* include while GCR_EL1 accepts an exclude mask.
202-
* No need for ISB since this only affects EL0 currently, implicit
203-
* with ERET.
204-
*/
205-
sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, excl);
206-
}
207-
208196
static void set_gcr_el1_excl(u64 excl)
209197
{
210198
current->thread.gcr_user_excl = excl;
@@ -265,7 +253,8 @@ void mte_suspend_exit(void)
265253
if (!system_supports_mte())
266254
return;
267255

268-
update_gcr_el1_excl(gcr_kernel_excl);
256+
sysreg_clear_set_s(SYS_GCR_EL1, SYS_GCR_EL1_EXCL_MASK, gcr_kernel_excl);
257+
isb();
269258
}
270259

271260
long set_mte_ctrl(struct task_struct *task, unsigned long arg)

0 commit comments

Comments
 (0)