[RFC PATCH 04/10] arm64/sve: Factor out clearing of tasks' SVE regs
Dave Martin
Dave.Martin at arm.com
Thu Jan 12 03:26:03 PST 2017
The patch factors out the code that clears a task's SVE regs on
exec(), so that we can reuse it in subsequent patches.
Signed-off-by: Dave Martin <Dave.Martin at arm.com>
---
arch/arm64/kernel/fpsimd.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index ab2bb62..54d7ed0 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -260,6 +260,19 @@ void fpsimd_thread_switch(struct task_struct *next)
}
}
+static void clear_sve_regs(struct task_struct *task)
+{
+ BUG_ON(task == current && preemptible());
+
+ BUG_ON((char *)__task_sve_state(task) < (char *)task);
+ BUG_ON(arch_task_struct_size <
+ ((char *)__task_sve_state(task) - (char *)task));
+
+ memset(__task_sve_state(task), 0,
+ arch_task_struct_size -
+ ((char *)__task_sve_state(task) - (char *)task));
+}
+
void fpsimd_flush_thread(void)
{
if (!system_supports_fpsimd())
@@ -272,13 +285,7 @@ void fpsimd_flush_thread(void)
memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
if (IS_ENABLED(CONFIG_ARM64_SVE) && (elf_hwcap & HWCAP_SVE)) {
- BUG_ON((char *)__task_sve_state(current) < (char *)current);
- BUG_ON(arch_task_struct_size <
- ((char *)__task_sve_state(current) - (char *)current));
-
- memset(__task_sve_state(current), 0,
- arch_task_struct_size -
- ((char *)__task_sve_state(current) - (char *)current));
+ clear_sve_regs(current);
/*
* User tasks must have a valid vector length set, but tasks
--
2.1.4
More information about the linux-arm-kernel
mailing list