Peter Maydell <peter.maydell@xxxxxxxxxx> writes: > On 11 September 2012 07:10, Rusty Russell <rusty.russell@xxxxxxxxxx> wrote: >> We use space #18 for floating point regs. > > Userspace ABI looks fine to me. > >> +static unsigned int num_vfp_regs(void) >> +{ >> + /* FP regs, FPEXC, FPSCR, FPINST, FPINST2, MVFR0, MVFR1, FPSID. */ >> + return num_fp_regs() + 7; >> +} >> + >> +static int copy_vfp_regids(u64 __user *uindices) >> +{ >> + unsigned int i; >> + const u64 u32reg = KVM_REG_ARM | KVM_REG_SIZE_U32 | KVM_REG_ARM_VFP; >> + const u64 u64reg = KVM_REG_ARM | KVM_REG_SIZE_U64 | KVM_REG_ARM_VFP; >> + >> + for (i = 0; i < num_fp_regs(); i++) { >> + if (put_user((u64reg | KVM_REG_ARM_VFP_ID_BASE_REG) + i, >> + uindices)) >> + return -EFAULT; >> + uindices++; >> + } >> + >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_FPEXC, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_FPSCR, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_FPINST, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_FPINST2, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_MVFR0, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_MVFR1, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + if (put_user(u32reg | KVM_REG_ARM_VFP_ID_FPSID, uindices)) >> + return -EFAULT; >> + uindices++, i++; >> + >> + return i; >> +} > > If you had an array: > static const int vfp_sysregs[] = { KVM_REG_ARM_VFP_ID_FPEXC, > KVM_REG_ARM_VFP_ID_FPSCR, etc etc etc }; > > then you could get rid of the hardcoded 7 in num_vfp_regs() > and have a loop in copy_vfp_regids() rather than the repeated > put_user() stanzas. That seems to me like it would be slightly > cleaner-looking code. Agreed. This was OK with 4 regs (as I started with), not so much now. Thanks, Rusty. _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm