Received: from eggs.gnu.org ([2001:4830:134:3::10]:54573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5Fxk-0002mC-QA for qemu-devel@nongnu.org; Mon, 20 Jan 2014 09:36:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5Fxf-0003jQ-RU for qemu-devel@nongnu.org; Mon, 20 Jan 2014 09:36:28 -0500 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) From: Alexander Graf In-Reply-To: <20140117135211.27377.91848.stgit@bahia.local> Date: Mon, 20 Jan 2014 15:36:18 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <8C430F28-4F8F-4666-B990-440CACD95DB8@suse.de> References: <20131211155716.8373.27979.stgit@bahia.local> <20140117135211.27377.91848.stgit@bahia.local> Subject: Re: [Qemu-devel] [PATCH] target-ppc: ppc64 target's virtio can be either endian. (v3) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Rusty Russell , qemu-ppc , QEMU Developers On 17.01.2014, at 14:52, Greg Kurz wrote: > We base it on the OS endian, as reflected by the endianness of the > interrupt vectors (handled through the ILE bit in the LPCR register). >=20 > This patch implements virtio_get_byteswap() over LPCR. >=20 > Using first_cpu to fetch the registers from KVM may look arbitrary > and awkward, but it is okay because KVM sets/unsets the ILE bit on > all CPUs. >=20 > Changes in v3: > - dropped the explicit calls to kvm_[get|put]_one_reg as LPCR is > now properly handled by the generic SPR code. > Changes in v2: > - call cpu_synchronize_state() instead of kvm_arch_get_registers(). >=20 > Suggested-by: Benjamin Herrenschmidt > Signed-off-by: Rusty Russell > Signed-off-by: Greg Kurz > Reviewed-by: Alexander Graf > --- > target-ppc/misc_helper.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/target-ppc/misc_helper.c b/target-ppc/misc_helper.c > index 616aab6..e8fc8a3 100644 > --- a/target-ppc/misc_helper.c > +++ b/target-ppc/misc_helper.c > @@ -20,6 +20,8 @@ > #include "helper.h" >=20 > #include "helper_regs.h" > +#include "hw/virtio/virtio.h" > +#include "sysemu/kvm.h" >=20 > = /*************************************************************************= ****/ > /* SPR accesses */ > @@ -116,3 +118,13 @@ void ppc_store_msr(CPUPPCState *env, target_ulong = value) > { > hreg_store_msr(env, value, 0); > } > + > +bool virtio_get_byteswap(void) > +{ > + PowerPCCPU *cp =3D POWERPC_CPU(first_cpu); > + CPUPPCState *env =3D &cp->env; > + > + cpu_synchronize_state(first_cpu); LPCR_ILE only gets modified by QEMU, so you can even get rid of the = synchronize call :). Either way, this can only go in after the generic virtio byteswap = mechanics are merged. Alex > + > + return env->spr[SPR_LPCR] & LPCR_ILE; > +} >=20