From: Dave Martin <Dave.Martin@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Okamoto Takayuki <tokamoto@jp.fujitsu.com>,
kvmarm@lists.cs.columbia.edu,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu.
Date: Fri, 1 Dec 2017 15:19:41 +0000 [thread overview]
Message-ID: <1512141582-17474-3-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1512141582-17474-1-git-send-email-Dave.Martin@arm.com>
There is currently some duplicate logic to associate current's
FPSIMD context with the cpu when loading FPSIMD state into the cpu
regs.
Subsequent patches will update that logic, so in order to ensure it
only needs to be done in one place, this patch factors the relevant
code out into a new function fpsimd_bind_to_cpu().
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/kernel/fpsimd.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 143b3e7..007140b 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -992,6 +992,18 @@ void fpsimd_signal_preserve_current_state(void)
}
/*
+ * Associate current's FPSIMD context with this cpu
+ * Preemption must be disabled when calling this function.
+ */
+static void fpsimd_bind_to_cpu(void)
+{
+ struct fpsimd_state *st = ¤t->thread.fpsimd_state;
+
+ __this_cpu_write(fpsimd_last_state, st);
+ st->cpu = smp_processor_id();
+}
+
+/*
* Load the userland FPSIMD state of 'current' from memory, but only if the
* FPSIMD state already held in the registers is /not/ the most recent FPSIMD
* state of 'current'
@@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void)
local_bh_disable();
if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
- struct fpsimd_state *st = ¤t->thread.fpsimd_state;
-
task_fpsimd_load();
- __this_cpu_write(fpsimd_last_state, st);
- st->cpu = smp_processor_id();
+ fpsimd_bind_to_cpu();
}
local_bh_enable();
@@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
}
task_fpsimd_load();
- if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
- struct fpsimd_state *st = ¤t->thread.fpsimd_state;
-
- __this_cpu_write(fpsimd_last_state, st);
- st->cpu = smp_processor_id();
- }
+ if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE))
+ fpsimd_bind_to_cpu();
local_bh_enable();
}
--
2.1.4
next prev parent reply other threads:[~2017-12-01 15:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 15:19 [PATCH 0/3] arm64: SVE fixes for v4.15-rc1 Dave Martin
2017-12-01 15:19 ` [PATCH 1/3] arm64: KVM: Move CPU ID reg trap setup off the world switch path Dave Martin
2017-12-05 9:09 ` Christoffer Dall
2017-12-05 12:31 ` Dave Martin
2017-12-06 10:53 ` Christoffer Dall
2017-12-06 11:55 ` Dave Martin
2017-12-01 15:19 ` Dave Martin [this message]
2017-12-04 13:46 ` [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu Ard Biesheuvel
2017-12-01 15:19 ` [PATCH 3/3] arm64/sve: KVM: Avoid dereference of dead task during guest entry Dave Martin
2017-12-04 13:53 ` Ard Biesheuvel
2017-12-04 15:36 ` Dave Martin
2017-12-05 9:43 ` Christoffer Dall
2017-12-05 12:40 ` Dave Martin
-- strict thread matches above, loose matches on Subject: below --
2017-12-06 16:45 [PATCH v2 0/3] arm64: SVE fixes for v4.15-rc2 Dave Martin
2017-12-06 16:45 ` [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu Dave Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1512141582-17474-3-git-send-email-Dave.Martin@arm.com \
--to=dave.martin@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=tokamoto@jp.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox