Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: KVM: MMIO support BE host running LE code

In case of status register E bit is not set (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>

authored by

Victor Kamensky and committed by
Christoffer Dall
27f194fd 1c9f0471

+18 -4
+18 -4
arch/arm/include/asm/kvm_emulate.h
··· 185 185 default: 186 186 return be32_to_cpu(data); 187 187 } 188 + } else { 189 + switch (len) { 190 + case 1: 191 + return data & 0xff; 192 + case 2: 193 + return le16_to_cpu(data & 0xffff); 194 + default: 195 + return le32_to_cpu(data); 196 + } 188 197 } 189 - 190 - return data; /* Leave LE untouched */ 191 198 } 192 199 193 200 static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, ··· 210 203 default: 211 204 return cpu_to_be32(data); 212 205 } 206 + } else { 207 + switch (len) { 208 + case 1: 209 + return data & 0xff; 210 + case 2: 211 + return cpu_to_le16(data & 0xffff); 212 + default: 213 + return cpu_to_le32(data); 214 + } 213 215 } 214 - 215 - return data; /* Leave LE untouched */ 216 216 } 217 217 218 218 #endif /* __ARM_KVM_EMULATE_H__ */