From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Oliver Upton <oupton@google.com>, Will Deacon <will@kernel.org>,
Fuad Tabba <tabba@google.com>,
Quentin Perret <qperret@google.com>,
Mark Brown <broonie@kernel.org>,
Reiji Watanabe <reijiw@google.com>,
kernel-team@android.com
Subject: [PATCH v2 19/19] KVM: arm64: Move the handling of !FP outside of the fast path
Date: Fri, 10 Jun 2022 10:28:38 +0100 [thread overview]
Message-ID: <20220610092838.1205755-20-maz@kernel.org> (raw)
In-Reply-To: <20220610092838.1205755-1-maz@kernel.org>
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>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/kvm/arm.c | 6 ++++++
arch/arm64/kvm/fpsimd.c | 8 ++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 8b9da9d30485..a9dd7ec38f38 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -328,6 +328,12 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO;
+ /*
+ * Default value for the FP state, will be overloaded at load
+ * time if we support FP (pretty likely)
+ */
+ vcpu->arch.fp_state = FP_STATE_FREE;
+
/* Set up the timer */
kvm_timer_vcpu_init(vcpu);
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;
}
--
2.34.1
next prev parent reply other threads:[~2022-06-10 9:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 9:28 [PATCH v2 00/19] KVM/arm64: Refactoring the vcpu flags Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 01/19] KVM: arm64: Always start with clearing SVE flag on load Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 02/19] KVM: arm64: Always start with clearing SME " Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 03/19] KVM: arm64: Drop FP_FOREIGN_STATE from the hypervisor code Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 04/19] KVM: arm64: Move FP state ownership from flag to a tristate Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 05/19] KVM: arm64: Add helpers to manipulate vcpu flags among a set Marc Zyngier
2022-06-10 13:05 ` Fuad Tabba
2022-06-11 18:37 ` Reiji Watanabe
2022-06-12 8:59 ` Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 06/19] KVM: arm64: Add three sets of flags to the vcpu state Marc Zyngier
2022-06-11 18:41 ` Reiji Watanabe
2022-06-10 9:28 ` [PATCH v2 07/19] KVM: arm64: Move vcpu configuration flags into their own set Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 08/19] KVM: arm64: Move vcpu PC/Exception flags to the input flag set Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 09/19] KVM: arm64: Move vcpu debug/SPE/TRBE " Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 10/19] KVM: arm64: Move vcpu SVE/SME flags to the state " Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 11/19] KVM: arm64: Move vcpu ON_UNSUPPORTED_CPU flag " Marc Zyngier
2022-06-15 13:14 ` Alexandru Elisei
2022-06-15 13:23 ` Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 12/19] KVM: arm64: Move vcpu WFIT " Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 13/19] KVM: arm64: Kill unused vcpu flags field Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 14/19] KVM: arm64: Convert vcpu sysregs_loaded_on_cpu to a state flag Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 15/19] KVM: arm64: Warn when PENDING_EXCEPTION and INCREMENT_PC are set together Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 16/19] KVM: arm64: Add build-time sanity checks for flags Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 17/19] KVM: arm64: Reduce the size of the vcpu flag members Marc Zyngier
2022-06-10 9:28 ` [PATCH v2 18/19] KVM: arm64: Document why pause cannot be turned into a flag Marc Zyngier
2022-06-10 9:28 ` Marc Zyngier [this message]
2022-06-14 4:15 ` [PATCH v2 19/19] KVM: arm64: Move the handling of !FP outside of the fast path Reiji Watanabe
2022-06-29 9:58 ` [PATCH v2 00/19] KVM/arm64: Refactoring the vcpu flags Marc Zyngier
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=20220610092838.1205755-20-maz@kernel.org \
--to=maz@kernel.org \
--cc=alexandru.elisei@arm.com \
--cc=broonie@kernel.org \
--cc=james.morse@arm.com \
--cc=kernel-team@android.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oupton@google.com \
--cc=qperret@google.com \
--cc=reijiw@google.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
/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