From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cedric Le Goater Subject: Re: [PATCH v3 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests Date: Tue, 08 Oct 2013 18:10:59 +0200 Message-ID: <52542E93.9040209@fr.ibm.com> References: <52541F96.6030304@fr.ibm.com> <1381246272-29284-1-git-send-email-clg@fr.ibm.com> <723860B3-F578-4B4C-9364-7CE003E2D70D@suse.de> Mime-Version: 1.0 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: Alexander Graf Return-path: Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:33727 "EHLO e06smtp12.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755531Ab3JHQLL (ORCPT ); Tue, 8 Oct 2013 12:11:11 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Oct 2013 17:11:09 +0100 In-Reply-To: <723860B3-F578-4B4C-9364-7CE003E2D70D@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On 10/08/2013 05:36 PM, Alexander Graf wrote: >=20 > On 08.10.2013, at 17:31, C=E9dric Le Goater wrote: >=20 >> MMIO emulation reads the last instruction executed by the guest >> and then emulates. If the guest is running in Little Endian mode, >> the instruction needs to be byte-swapped before being emulated. >> >> This patch stores the last instruction in the endian order of the >> host, primarily doing a byte-swap if needed. The common code >> which fetches 'last_inst' uses a helper routine kvmppc_need_byteswap= (). >> and the exit paths for the Book3S PV and HR guests use their own >> version in assembly. >> >> Finally, the meaning of the 'is_bigendian' argument of the >> routines kvmppc_handle_load() of kvmppc_handle_store() is >> slightly changed to represent an eventual reverse operation. This >> is used in conjunction with kvmppc_is_bigendian() to determine if >> the instruction being emulated should be byte-swapped. >> >> Signed-off-by: C=E9dric Le Goater >> --- >> >> Changes in v3: >> >> - moved kvmppc_need_byteswap() in kvmppc_ld32. It previously was in >> kvmppc_ld_inst(). (Alexander Graf) >> >> Changes in v2: >> >> - replaced rldicl. by andi. to test the MSR_LE bit in the guest >> exit paths. (Paul Mackerras) >> >> - moved the byte swapping logic to kvmppc_handle_load() and=20 >> kvmppc_handle_load() by changing the is_bigendian parameter >> meaning. (Paul Mackerras) >> >> arch/powerpc/include/asm/kvm_book3s.h | 9 ++++++++- >> arch/powerpc/include/asm/kvm_ppc.h | 10 +++++----- >> arch/powerpc/kvm/book3s_hv_rmhandlers.S | 11 +++++++++++ >> arch/powerpc/kvm/book3s_segment.S | 10 ++++++++++ >> arch/powerpc/kvm/emulate.c | 1 - >> arch/powerpc/kvm/powerpc.c | 16 ++++++++++++---- >> 6 files changed, 46 insertions(+), 11 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/in= clude/asm/kvm_book3s.h >> index 4ee6c66..9403042 100644 >> --- a/arch/powerpc/include/asm/kvm_book3s.h >> +++ b/arch/powerpc/include/asm/kvm_book3s.h >> @@ -283,7 +283,14 @@ static inline bool kvmppc_is_bigendian(struct k= vm_vcpu *vcpu) >> static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr, >> u32 *ptr, bool data) >> { >> - return kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data); >> + int ret; >> + >> + ret =3D kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data); >> + >> + if (kvmppc_need_byteswap(vcpu)) >> + *ptr =3D swab32(*ptr); >> + >> + return ret; >> } >> >> static inline int kvmppc_ld_inst(struct kvm_vcpu *vcpu, ulong *eaddr= , >=20 > ... at which point this helper is pretty useless ;). ok. This sounds like a request for a v4 ... :) C.