From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cedric Le Goater Subject: Re: [PATCH v5 2/6] KVM: PPC: Book3S: add helper routines to detect endian Date: Wed, 08 Jan 2014 18:22:28 +0100 Message-ID: <52CD8954.4040209@fr.ibm.com> References: <1383672128-26795-1-git-send-email-clg@fr.ibm.com> <1383672128-26795-3-git-send-email-clg@fr.ibm.com> <4A7ABBCC-2B37-4367-A19E-FF25CE741B0A@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 e06smtp15.uk.ibm.com ([195.75.94.111]:42010 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755363AbaAHRWh (ORCPT ); Wed, 8 Jan 2014 12:22:37 -0500 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Jan 2014 17:22:35 -0000 In-Reply-To: <4A7ABBCC-2B37-4367-A19E-FF25CE741B0A@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: Hi Alex, On 01/02/2014 09:05 PM, Alexander Graf wrote: >=20 > On 05.11.2013, at 18:22, C=E9dric Le Goater wrote: >=20 >> They will be used to decide whether to byte-swap or not. When Little >> Endian host kernels come, these routines will need to be changed >> accordingly. >> >> Signed-off-by: C=E9dric Le Goater >> --- >> arch/powerpc/include/asm/kvm_book3s.h | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/in= clude/asm/kvm_book3s.h >> index d11c089..22ec875 100644 >> --- a/arch/powerpc/include/asm/kvm_book3s.h >> +++ b/arch/powerpc/include/asm/kvm_book3s.h >> @@ -270,6 +270,16 @@ static inline ulong kvmppc_get_pc(struct kvm_vc= pu *vcpu) >> return vcpu->arch.pc; >> } >> >> +static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu) >> +{ >> + return vcpu->arch.shared->msr & MSR_LE; >> +} >> + >> +static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu) >> +{ >> + return !kvmppc_need_byteswap(vcpu); >=20 > This is logically reversed. kvmppc_need_byteswap should check kvmppc_= is_bigendian(),=20 > not the other way around. >=20 =20 I think we should get rid of kvmppc_is_bigendian().=20 As you noted in a subsequent email, it ends up returning true when run=20 for "little endian guests on little endian hosts", which is awkward and= =20 the way it is used in kvmppc_handle_load() and kvmppc_handle_store() can be improved. I will give it a try taking into account the other comments you made.=20 C.