Patchwork [v5,4/6] KVM: PPC: Book3S: modify kvmppc_need_byteswap() for little endian host

login
register
mail settings
Submitter Cédric Le Goater
Date Nov. 5, 2013, 5:22 p.m.
Message ID <1383672128-26795-5-git-send-email-clg@fr.ibm.com>
Download mbox | patch
Permalink /patch/288593/
State New
Headers show

Comments

Cédric Le Goater - Nov. 5, 2013, 5:22 p.m.
If the host is in little endian order, there is no need to byte-swap
in little endian guests.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 arch/powerpc/include/asm/kvm_book3s.h |    4 ++++
 1 file changed, 4 insertions(+)
Alexander Graf - Jan. 2, 2014, 8:25 p.m.
On 05.11.2013, at 18:22, Cédric Le Goater <clg@fr.ibm.com> wrote:

> If the host is in little endian order, there is no need to byte-swap
> in little endian guests.
> 
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
> arch/powerpc/include/asm/kvm_book3s.h |    4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
> index ac06434..6974aa0 100644
> --- a/arch/powerpc/include/asm/kvm_book3s.h
> +++ b/arch/powerpc/include/asm/kvm_book3s.h
> @@ -272,7 +272,11 @@ static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
> 
> static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
> {
> +#ifdef __LITTLE_ENDIAN__
> +	return !(vcpu->arch.shared->msr & MSR_LE);
> +#else
> 	return vcpu->arch.shared->msr & MSR_LE;
> +#endif
> }
> 
> static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu)

... and suddenly is_bigendian() becomes true for little endian guests on little endian hosts?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index ac06434..6974aa0 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -272,7 +272,11 @@  static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
 
 static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
 {
+#ifdef __LITTLE_ENDIAN__
+	return !(vcpu->arch.shared->msr & MSR_LE);
+#else
 	return vcpu->arch.shared->msr & MSR_LE;
+#endif
 }
 
 static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu)