KVM: arm64: Move FPMR into the sysreg array
authorMarc Zyngier <maz@kernel.org>
Tue, 20 Aug 2024 13:17:57 +0000 (14:17 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 27 Aug 2024 06:59:27 +0000 (07:59 +0100)
Just like SVCR, FPMR is currently stored at the wrong location.

Let's move it where it belongs.

Reviewed-by: Mark Brown <broonie@kernel.org>
Tested-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20240820131802.3547589-4-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/fpsimd.c
arch/arm64/kvm/sys_regs.c

index e5cf8af54dd630dce9bd1274f8ebee1c9db10100..021f7a1845f210480233327100c6bfec98845baf 100644 (file)
@@ -448,6 +448,7 @@ enum vcpu_sysreg {
 
        /* FP/SIMD/SVE */
        SVCR,
+       FPMR,
 
        /* 32bit specific registers. */
        DACR32_EL2,     /* Domain Access Control Register */
@@ -667,7 +668,6 @@ struct kvm_vcpu_arch {
        void *sve_state;
        enum fp_type fp_type;
        unsigned int sve_max_vl;
-       u64 fpmr;
 
        /* Stage 2 paging state used by the hardware on next switch */
        struct kvm_s2_mmu *hw_mmu;
index e6425414d301f3362d910edcf82eb01ebfd21a5b..4cb8ad5d69a800404f12d779c90b49e504441ba2 100644 (file)
@@ -135,7 +135,7 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu)
                fp_state.sve_vl = vcpu->arch.sve_max_vl;
                fp_state.sme_state = NULL;
                fp_state.svcr = &__vcpu_sys_reg(vcpu, SVCR);
-               fp_state.fpmr = &vcpu->arch.fpmr;
+               fp_state.fpmr = &__vcpu_sys_reg(vcpu, FPMR);
                fp_state.fp_type = &vcpu->arch.fp_type;
 
                if (vcpu_has_sve(vcpu))
index 2dc6cab43b2f8a7bb5923911fce04a45ede161ec..79d67f19130d129f8485c064f5c240e9d99deda5 100644 (file)
@@ -1678,6 +1678,15 @@ static unsigned int sme_visibility(const struct kvm_vcpu *vcpu,
        return REG_HIDDEN;
 }
 
+static unsigned int fp8_visibility(const struct kvm_vcpu *vcpu,
+                                  const struct sys_reg_desc *rd)
+{
+       if (kvm_has_fpmr(vcpu->kvm))
+               return 0;
+
+       return REG_HIDDEN;
+}
+
 static u64 read_sanitised_id_aa64pfr0_el1(struct kvm_vcpu *vcpu,
                                          const struct sys_reg_desc *rd)
 {
@@ -2545,6 +2554,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
                             CTR_EL0_DminLine_MASK |
                             CTR_EL0_IminLine_MASK),
        { SYS_DESC(SYS_SVCR), undef_access, reset_val, SVCR, 0, .visibility = sme_visibility  },
+       { SYS_DESC(SYS_FPMR), undef_access, reset_val, FPMR, 0, .visibility = fp8_visibility },
 
        { PMU_SYS_REG(PMCR_EL0), .access = access_pmcr, .reset = reset_pmcr,
          .reg = PMCR_EL0, .get_user = get_pmcr, .set_user = set_pmcr },