From: Alexander Graf Subject: Re: [PATCH v5 6/6] KVM: PPC: Book3S: modify byte loading when guest uses Split Little Endian Date: Thu, 2 Jan 2014 21:26:35 +0100 Message-ID: <53AD15D1-9983-4F8D-B16E-AFFD3478AD40@suse.de> References: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> <1383672128-26795-7-git-send-email-clg@fr.ibm.com> Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Paul Mackerras , kvm-ppc@vger.kernel.org, "kvm@vger.kernel.org mailing list" To: =?iso-8859-1?Q?C=E9dric_Le_Goater?= Return-path: In-Reply-To: <1383672128-26795-7-git-send-email-clg@fr.ibm.com> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 05.11.2013, at 18:22, C=E9dric Le Goater wrote: > 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. SLE can also happen with MMIO. This needs a more global approach I'm af= raid. Alex >=20 > Signed-off-by: C=E9dric Le Goater > --- > arch/powerpc/include/asm/kvm_book3s.h | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) >=20 > diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/inc= lude/asm/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 >=20