From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqmCR-0004rG-Pl for qemu-devel@nongnu.org; Wed, 11 Dec 2013 10:59:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqmCK-0002Uh-BO for qemu-devel@nongnu.org; Wed, 11 Dec 2013 10:59:47 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:37286) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqmCK-0002US-2O for qemu-devel@nongnu.org; Wed, 11 Dec 2013 10:59:40 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Dec 2013 15:59:38 -0000 From: Greg Kurz Date: Wed, 11 Dec 2013 16:59:33 +0100 Message-ID: <20131211155716.8373.27979.stgit@bahia.local> In-Reply-To: <39557095-94C5-4E6E-8DE5-62C4A6C79F58@suse.de> References: <39557095-94C5-4E6E-8DE5-62C4A6C79F58@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH V2] target-ppc: ppc64 target's virtio can be either endian. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: rusty@rustcorp.com.au, qemu-ppc@nongnu.org, agraf@suse.de 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). This patch does two things: - make LPCR a KVM register - implement virtio_get_byteswap() over LPCR 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. Changes in v2: - call cpu_synchronize_state() instead of kvm_arch_get_registers(). Suggested-by: Benjamin Herrenschmidt Signed-off-by: Rusty Russell Signed-off-by: Greg Kurz --- Alex, If you are interested, I can resend the whole virtio+endian serie or setup a git tree for you to pull from. -- Greg target-ppc/kvm.c | 4 ++++ target-ppc/misc_helper.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 10d0cd9..b450a22 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -869,6 +869,8 @@ int kvm_arch_put_registers(CPUState *cs, int level) DPRINTF("Warning: Unable to set VPA information to KVM\n"); } } + + kvm_put_one_spr(cs, KVM_REG_PPC_LPCR, SPR_LPCR); #endif /* TARGET_PPC64 */ } @@ -1091,6 +1093,8 @@ int kvm_arch_get_registers(CPUState *cs) DPRINTF("Warning: Unable to get VPA information from KVM\n"); } } + + kvm_get_one_spr(cs, KVM_REG_PPC_LPCR, SPR_LPCR); #endif } 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" #include "helper_regs.h" +#include "hw/virtio/virtio.h" +#include "sysemu/kvm.h" /*****************************************************************************/ /* 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 = POWERPC_CPU(first_cpu); + CPUPPCState *env = &cp->env; + + cpu_synchronize_state(first_cpu); + + return env->spr[SPR_LPCR] & LPCR_ILE; +}