On 28/05/14 07:08, Victor Kamensky wrote: > This patch addresses issue of reading and writing V8 sys registers in > BE case. Since only register size function deals with is 8 bytes, > existing code works in both little and big endian cases. > Removed comment about little endian. Note that register > size should be always 8 bytes. > > Signed-off-by: Victor Kamensky <victor.kamensky@xxxxxxxxxx> > --- > arch/arm64/kvm/sys_regs.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 0324458..a13e7e7 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -776,18 +776,27 @@ static struct sys_reg_desc invariant_sys_regs[] = { > NULL, get_ctr_el0 }, > }; > > -static int reg_from_user(void *val, const void __user *uaddr, u64 id) > +static int reg_from_user(u64 *val, const void __user *uaddr, u64 id) > { > - /* This Just Works because we are little endian. */ > - if (copy_from_user(val, uaddr, KVM_REG_SIZE(id)) != 0) > + unsigned long regsize = KVM_REG_SIZE(id); > + > + if(regsize != 8) > + return -ENOENT; Looks we already have such a check on the size in kvm_arm_sys_reg_set_reg. Why do we need it here? > + > + if (copy_from_user(val, uaddr, regsize) != 0) > return -EFAULT; > + > return 0; > } > > -static int reg_to_user(void __user *uaddr, const void *val, u64 id) > +static int reg_to_user(void __user *uaddr, const u64 *val, u64 id) > { > - /* This Just Works because we are little endian. */ > - if (copy_to_user(uaddr, val, KVM_REG_SIZE(id)) != 0) > + unsigned long regsize = KVM_REG_SIZE(id); > + > + if(regsize != 8) > + return -ENOENT; Same question wrt kvm_arm_sys_reg_get_reg. > + if (copy_to_user(uaddr, val, regsize) != 0) > return -EFAULT; > return 0; > } > -- Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm