summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/fpsimd.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2022-06-08 14:22:31 +0100
committerMarc Zyngier <maz@kernel.org>2022-06-29 10:23:56 +0100
commitb4da91879e98bdd5998ee84f47f02426ac50a729 (patch)
tree06d85dbc61bb0a5d0cbe0046ac5540cacc55410d /arch/arm64/kvm/fpsimd.c
parent0fa4a3137e943cd6acab386ff26cd8d5e94e9559 (diff)
downloadlinux-stable-b4da91879e98bdd5998ee84f47f02426ac50a729.tar.gz
linux-stable-b4da91879e98bdd5998ee84f47f02426ac50a729.tar.bz2
linux-stable-b4da91879e98bdd5998ee84f47f02426ac50a729.zip
KVM: arm64: Move the handling of !FP outside of the fast path
We currently start by assuming that the host owns the FP unit at load time, then check again whether this is the case as we are about to run. Only at this point do we account for the fact that there is a (vanishingly small) chance that we're running on a system without a FPSIMD unit (yes, this is madness). We can actually move this FPSIMD check as early as load-time, and drop the check at run time. No intended change in behaviour. Suggested-by: Reiji Watanabe <reijiw@google.com> Reviewed-by: Reiji Watanabe <reijiw@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org>
Diffstat (limited to 'arch/arm64/kvm/fpsimd.c')
-rw-r--r--arch/arm64/kvm/fpsimd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
index 557a96f8e06a..ec8e4494873d 100644
--- a/arch/arm64/kvm/fpsimd.c
+++ b/arch/arm64/kvm/fpsimd.c
@@ -77,6 +77,9 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
BUG_ON(!current->mm);
BUG_ON(test_thread_flag(TIF_SVE));
+ if (!system_supports_fpsimd())
+ return;
+
vcpu->arch.fp_state = FP_STATE_HOST_OWNED;
vcpu_clear_flag(vcpu, HOST_SVE_ENABLED);
@@ -110,13 +113,10 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
* FP while we were preemptible (such as off the back of an interrupt),
* then neither the host nor the guest own the FP hardware (and it was the
* responsibility of the code that used FP to save the existing state).
- *
- * Note that not supporting FP is basically the same thing as far as the
- * hypervisor is concerned (nothing to save).
*/
void kvm_arch_vcpu_ctxflush_fp(struct kvm_vcpu *vcpu)
{
- if (!system_supports_fpsimd() || test_thread_flag(TIF_FOREIGN_FPSTATE))
+ if (test_thread_flag(TIF_FOREIGN_FPSTATE))
vcpu->arch.fp_state = FP_STATE_FREE;
}