Skip to contentSkip to conversation

arm64/sme: Always initialise TPIDR2 storage

PATCH In review Mark Brown 2 participants 3 messages Jul 1, 2022 arm64

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 arm64/sme: Always initialise TPIDR2 storage

Ensure that the value stored for TPIDR2 is always initialised, even if we don't support it, in order to defend against the possibility that we might look at the value and do something with it.

---
 arch/arm64/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/process.c +2 -0
index 944d782d581b..da1c65a7092c 100644
@@ -376,6 +376,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
 		*task_user_tls(p) = read_sysreg(tpidr_el0);
 		if (system_supports_tpidr2())
 			p->thread.tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0);
+		else
+			p->thread.tpidr2_el0 = 0;
 
 		if (stack_start) {
 			if (is_compat_thread(task_thread_info(p)))
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw
Quoted 14 lines · Mark Brown

Ensure that the value stored for TPIDR2 is always initialised, even if we don't support it, in order to defend against the possibility that we might look at the value and do something with it.

---
 arch/arm64/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/process.c +0 -0
index 944d782d581b..da1c65a7092c 100644

arch/arm64/kernel/process.c int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) · line 380

Quoted 5 lines
arch/arm64/kernel/process.c +2 -0
@@ -376,6 +376,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
 		*task_user_tls(p) = read_sysreg(tpidr_el0);
 		if (system_supports_tpidr2())
 			p->thread.tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0);
+		else
+			p->thread.tpidr2_el0 = 0;

Why is this needed? If !system_supports_tpidr2(), then we'll just copy the tpidr2_el0 field from the parent. Given that INIT_THREAD defines this to be zero, then it looks like it should all work out.

What am I missing?

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#2 lore raw
Quoted 10 lines · Will Deacon

arch/arm64/kernel/process.c int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) · line 380

Quoted 2 lines · Mark Brown
arch/arm64/kernel/process.c +2 -0
+		else
+			p->thread.tpidr2_el0 = 0;

Why is this needed? If !system_supports_tpidr2(), then we'll just copy the tpidr2_el0 field from the parent. Given that INIT_THREAD defines this to be zero, then it looks like it should all work out.

What am I missing?

It should be redundant, I just had to check harder than I liked that there wasn't a path where we could get it wrong.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel