From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 05 Nov 2013 17:22:08 +0000 Subject: [PATCH v5 6/6] KVM: PPC: Book3S: modify byte loading when guest uses Split Little Endian Message-Id: <1383672128-26795-7-git-send-email-clg@fr.ibm.com> List-Id: References: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> In-Reply-To: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: agraf@suse.de, paulus@samba.org Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Instruction and data storage accesses are done in opposite order when the Split Little Endian mode is used. This patch modifies the kvmppc_ld32() routine to reverse the byteswap when the guest is in SLE mode. Signed-off-by: C=C3=A9dric Le Goater --- arch/powerpc/include/asm/kvm_book3s.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/a= sm/kvm_book3s.h index 6974aa0..eac8808 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h @@ -288,10 +288,22 @@ static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, = ulong *eaddr, u32 *ptr, bool data) { int ret; + bool byteswap; =20 ret =3D kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data); =20 - if (kvmppc_need_byteswap(vcpu)) + byteswap =3D kvmppc_need_byteswap(vcpu); + + /* When in Split Little Endian (SLE) mode, instruction and + * data storage accesses are done in opposite order. If the + * guest is using this mode, we need to reverse the byteswap + * for data accesses only. Instructions accesses are left + * unchanged. + */ + if (data && (vcpu->arch.shared->msr & MSR_SLE)) + byteswap =3D !byteswap; + + if (byteswap) *ptr =3D swab32(*ptr); =20 return ret; --=20 1.7.10.4