On Wed, Jun 05, 2019 at 09:15:49AM +0200, Auger Eric wrote: > Hi Drew, > > On 5/12/19 10:36 AM, Andrew Jones wrote: > > Move the getting/putting of the fpsimd registers out of > > kvm_arch_get/put_registers() into their own helper functions > > to prepare for alternatively getting/putting SVE registers. > > > > No functional change. > > > > Signed-off-by: Andrew Jones <drjo...@redhat.com> > > --- > > target/arm/kvm64.c | 148 +++++++++++++++++++++++++++------------------ > > 1 file changed, 88 insertions(+), 60 deletions(-) > > > > diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c > > index ba232b27a6d3..61947f3716e1 100644 > > --- a/target/arm/kvm64.c > > +++ b/target/arm/kvm64.c > > @@ -706,13 +706,53 @@ int kvm_arm_cpreg_level(uint64_t regidx) > > #define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ > > KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) > > > > +static int kvm_arch_put_fpsimd(CPUState *cs) > > +{ > > + ARMCPU *cpu = ARM_CPU(cs); > > + CPUARMState *env = &cpu->env; > > + struct kvm_one_reg reg; > > + uint32_t fpr; > > + int i, ret; > > + > > + for (i = 0; i < 32; i++) { > > + uint64_t *q = aa64_vfp_qreg(env, i); > > +#ifdef HOST_WORDS_BIGENDIAN > > + uint64_t fp_val[2] = { q[1], q[0] }; > > + reg.addr = (uintptr_t)fp_val; > > +#else > > + reg.addr = (uintptr_t)q; > > +#endif > > + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); > > + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); > > + if (ret) { > > + return ret; > > + } > > + } > > + > > + reg.addr = (uintptr_t)(&fpr); > > + fpr = vfp_get_fpsr(env); > > + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); > > + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); > > + if (ret) { > > + return ret; > > + } > > + > > + reg.addr = (uintptr_t)(&fpr); > I don't think you need this assignment
You're right, and they weren't in the original code, but I added them in order to be sure that the register get/set blocks were complete units. It's one thing to factor stuff like that out of a loop, but here we had two almost independent blocks so it looked a bit odd. [...] > > Besides > Reviewed-by: Eric Auger <eric.au...@redhat.com> > Thanks, drew