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>
This commit is contained in:
parent
1c9f04717c
commit
27f194fd36
1 changed files with 18 additions and 4 deletions
|
@ -185,9 +185,16 @@ static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu,
|
||||||
default:
|
default:
|
||||||
return be32_to_cpu(data);
|
return be32_to_cpu(data);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch (len) {
|
||||||
|
case 1:
|
||||||
|
return data & 0xff;
|
||||||
|
case 2:
|
||||||
|
return le16_to_cpu(data & 0xffff);
|
||||||
|
default:
|
||||||
|
return le32_to_cpu(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data; /* Leave LE untouched */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
|
static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
|
||||||
|
@ -203,9 +210,16 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
|
||||||
default:
|
default:
|
||||||
return cpu_to_be32(data);
|
return cpu_to_be32(data);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch (len) {
|
||||||
|
case 1:
|
||||||
|
return data & 0xff;
|
||||||
|
case 2:
|
||||||
|
return cpu_to_le16(data & 0xffff);
|
||||||
|
default:
|
||||||
|
return cpu_to_le32(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data; /* Leave LE untouched */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __ARM_KVM_EMULATE_H__ */
|
#endif /* __ARM_KVM_EMULATE_H__ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue