[RFC PATCH v4 2/2] ARM64: KVM: set and get of sys registers in BE case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
+
+	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;
+
+	if (copy_to_user(uaddr, val, regsize) != 0)
 		return -EFAULT;
 	return 0;
 }
-- 
1.8.1.4

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux