Skip to content

Commit 638982a

Browse files
pccctmarinas
authored andcommitted
arm64: mte: rename gcr_user_excl to mte_ctrl
We are going to use this field to store more data. To prepare for that, rename it and change the users to rely on the bit position of gcr_user_excl in mte_ctrl. Link: https://linux-review.googlesource.com/id/Ie1fd18e480100655f5d22137f5b22f4f3a9f9e2e Signed-off-by: Peter Collingbourne <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Will Deacon <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 42b6b10 commit 638982a

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

arch/arm64/include/asm/processor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
#define NET_IP_ALIGN 0
1818

19+
#define MTE_CTRL_GCR_USER_EXCL_SHIFT 0
20+
#define MTE_CTRL_GCR_USER_EXCL_MASK 0xffff
21+
1922
#ifndef __ASSEMBLY__
2023

2124
#include <linux/build_bug.h>
@@ -153,7 +156,7 @@ struct thread_struct {
153156
#endif
154157
#endif
155158
#ifdef CONFIG_ARM64_MTE
156-
u64 gcr_user_excl;
159+
u64 mte_ctrl;
157160
#endif
158161
u64 sctlr_user;
159162
};

arch/arm64/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main(void)
5252
DEFINE(THREAD_KEYS_KERNEL, offsetof(struct task_struct, thread.keys_kernel));
5353
#endif
5454
#ifdef CONFIG_ARM64_MTE
55-
DEFINE(THREAD_GCR_EL1_USER, offsetof(struct task_struct, thread.gcr_user_excl));
55+
DEFINE(THREAD_MTE_CTRL, offsetof(struct task_struct, thread.mte_ctrl));
5656
#endif
5757
BLANK();
5858
DEFINE(S_X0, offsetof(struct pt_regs, regs[0]));

arch/arm64/kernel/entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ alternative_else_nop_endif
175175
* the RRND (bit[16]) setting.
176176
*/
177177
mrs_s \tmp2, SYS_GCR_EL1
178-
bfi \tmp2, \tmp, #0, #16
178+
bfxil \tmp2, \tmp, #MTE_CTRL_GCR_USER_EXCL_SHIFT, #16
179179
msr_s SYS_GCR_EL1, \tmp2
180180
#endif
181181
.endm
@@ -198,7 +198,7 @@ alternative_else_nop_endif
198198
alternative_if_not ARM64_MTE
199199
b 1f
200200
alternative_else_nop_endif
201-
ldr \tmp, [\tsk, #THREAD_GCR_EL1_USER]
201+
ldr \tmp, [\tsk, #THREAD_MTE_CTRL]
202202

203203
mte_set_gcr \tmp, \tmp2
204204
1:

arch/arm64/kernel/mte.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void mte_check_tfsr_el1(void)
195195

196196
static void set_gcr_el1_excl(u64 excl)
197197
{
198-
current->thread.gcr_user_excl = excl;
198+
current->thread.mte_ctrl = excl;
199199

200200
/*
201201
* SYS_GCR_EL1 will be set to current->thread.gcr_user_excl value
@@ -260,8 +260,8 @@ void mte_suspend_exit(void)
260260
long set_mte_ctrl(struct task_struct *task, unsigned long arg)
261261
{
262262
u64 sctlr = task->thread.sctlr_user & ~SCTLR_EL1_TCF0_MASK;
263-
u64 gcr_excl = ~((arg & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT) &
264-
SYS_GCR_EL1_EXCL_MASK;
263+
u64 mte_ctrl = (~((arg & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT) &
264+
SYS_GCR_EL1_EXCL_MASK) << MTE_CTRL_GCR_USER_EXCL_SHIFT;
265265

266266
if (!system_supports_mte())
267267
return 0;
@@ -282,10 +282,10 @@ long set_mte_ctrl(struct task_struct *task, unsigned long arg)
282282

283283
if (task != current) {
284284
task->thread.sctlr_user = sctlr;
285-
task->thread.gcr_user_excl = gcr_excl;
285+
task->thread.mte_ctrl = mte_ctrl;
286286
} else {
287287
set_task_sctlr_el1(sctlr);
288-
set_gcr_el1_excl(gcr_excl);
288+
set_gcr_el1_excl(mte_ctrl);
289289
}
290290

291291
return 0;
@@ -294,7 +294,9 @@ long set_mte_ctrl(struct task_struct *task, unsigned long arg)
294294
long get_mte_ctrl(struct task_struct *task)
295295
{
296296
unsigned long ret;
297-
u64 incl = ~task->thread.gcr_user_excl & SYS_GCR_EL1_EXCL_MASK;
297+
u64 mte_ctrl = task->thread.mte_ctrl;
298+
u64 incl = (~mte_ctrl >> MTE_CTRL_GCR_USER_EXCL_SHIFT) &
299+
SYS_GCR_EL1_EXCL_MASK;
298300

299301
if (!system_supports_mte())
300302
return 0;

0 commit comments

Comments
 (0)