]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM64: KVM: MMIO support BE host running LE code
authorVictor Kamensky <victor.kamensky@linaro.org>
Thu, 12 Jun 2014 16:30:08 +0000 (09:30 -0700)
committerChristoffer Dall <christoffer.dall@linaro.org>
Fri, 11 Jul 2014 11:57:41 +0000 (04:57 -0700)
In case of guest CPU running in LE mode and host runs in
BE mode we need byteswap data, so read/write is emulated correctly.

Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/include/asm/kvm_emulate.h

index dd8ecfc3f9952fbf86e5d3dd69012ca9ab9a8385..fdc3e21abd8dddee609c7a5e49c5d6efaa3615ee 100644 (file)
@@ -213,6 +213,17 @@ static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu,
                default:
                        return be64_to_cpu(data);
                }
+       } else {
+               switch (len) {
+               case 1:
+                       return data & 0xff;
+               case 2:
+                       return le16_to_cpu(data & 0xffff);
+               case 4:
+                       return le32_to_cpu(data & 0xffffffff);
+               default:
+                       return le64_to_cpu(data);
+               }
        }
 
        return data;            /* Leave LE untouched */
@@ -233,6 +244,17 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
                default:
                        return cpu_to_be64(data);
                }
+       } else {
+               switch (len) {
+               case 1:
+                       return data & 0xff;
+               case 2:
+                       return cpu_to_le16(data & 0xffff);
+               case 4:
+                       return cpu_to_le32(data & 0xffffffff);
+               default:
+                       return cpu_to_le64(data);
+               }
        }
 
        return data;            /* Leave LE untouched */