KVM: arm64: Move guest_owns_fp_regs() to increase its scope
authorFuad Tabba <tabba@google.com>
Tue, 23 Apr 2024 15:05:10 +0000 (16:05 +0100)
committerMarc Zyngier <maz@kernel.org>
Wed, 1 May 2024 15:46:58 +0000 (16:46 +0100)
guest_owns_fp_regs() will be used to check fpsimd state ownership
across kvm/arm64. Therefore, move it to kvm_host.h to widen its
scope.

Moreover, the host state is not per-vcpu anymore, the vcpu
parameter isn't used, so remove it as well.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240423150538.2103045-3-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/switch.c
arch/arm64/kvm/hyp/vhe/switch.c

index 2b63fdfad5b28d96cf9d987f0731784a6f0ca14a..2889e1d8a8c1250585672907549a56888113f117 100644 (file)
@@ -1207,6 +1207,12 @@ DECLARE_KVM_HYP_PER_CPU(struct kvm_host_data, kvm_host_data);
         &this_cpu_ptr_hyp_sym(kvm_host_data)->f)
 #endif
 
+/* Check whether the FP regs are owned by the guest */
+static inline bool guest_owns_fp_regs(void)
+{
+       return *host_data_ptr(fp_owner) == FP_STATE_GUEST_OWNED;
+}
+
 static inline void kvm_init_host_cpu_context(struct kvm_cpu_context *cpu_ctxt)
 {
        /* The host's MPIDR is immutable, so let's set it up at boot time */
index 2629420d0659d9f5ddc7670571a623106e39bb96..38961b6b1a18ed1efc700d147356e535edfb7d01 100644 (file)
@@ -39,12 +39,6 @@ struct kvm_exception_table_entry {
 extern struct kvm_exception_table_entry __start___kvm_ex_table;
 extern struct kvm_exception_table_entry __stop___kvm_ex_table;
 
-/* Check whether the FP regs are owned by the guest */
-static inline bool guest_owns_fp_regs(struct kvm_vcpu *vcpu)
-{
-       return *host_data_ptr(fp_owner) == FP_STATE_GUEST_OWNED;
-}
-
 /* Save the 32-bit only FPSIMD system register state */
 static inline void __fpsimd_save_fpexc32(struct kvm_vcpu *vcpu)
 {
index 1f82d531a4945de77a631a74d9076e760ade633d..1b22654a31809dad911e2879b3e5fced3dc8e130 100644 (file)
@@ -53,7 +53,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
                        val |= CPTR_EL2_TSM;
        }
 
-       if (!guest_owns_fp_regs(vcpu)) {
+       if (!guest_owns_fp_regs()) {
                if (has_hvhe())
                        val &= ~(CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN |
                                 CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN);
index b92f9fe2d50e92a0d416546f3da186448736c967..7286db75b8d68d261725409bb2673522da626aab 100644 (file)
@@ -75,7 +75,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
 
        val |= CPTR_EL2_TAM;
 
-       if (guest_owns_fp_regs(vcpu)) {
+       if (guest_owns_fp_regs()) {
                if (vcpu_has_sve(vcpu))
                        val |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
        } else {