From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPs7-0001HR-Sd for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvPrz-0003iA-0d for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:42:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53880 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvPry-0003i4-On for qemu-devel@nongnu.org; Fri, 13 Jun 2014 07:42:06 -0400 Message-ID: <539AE38C.2060906@suse.de> Date: Fri, 13 Jun 2014 13:42:04 +0200 From: Alexander Graf MIME-Version: 1.0 References: <20140613111703.22108.14322.stgit@bahia.local> <20140613112201.22108.52075.stgit@bahia.local> In-Reply-To: <20140613112201.22108.52075.stgit@bahia.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v8 10/20] cpu: introduce CPUClass::virtio_is_big_endian() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Juan Quintela , Rusty Russell , "Michael S. Tsirkin" , aneesh.kumar@linux.vnet.ibm.com, Anthony Liguori , Amit Shah , Paolo Bonzini , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= On 13.06.14 13:22, Greg Kurz wrote: > If we want to support targets that can change endianness (modern PPC and > ARM for the moment), we need to add a per-CPU class method to be called > from the virtio code. The virtio_ prefix in the name is a hint for people > to avoid misusage (aka. anywhere but from the virtio code). > > The default behaviour is to return the compile-time default target > endianness. > > Suggested-by: Peter Maydell > Signed-off-by: Greg Kurz > --- > include/qom/cpu.h | 10 ++++++++++ > qom/cpu.c | 6 ++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index 4b352a2..30e8fe3 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -116,6 +116,7 @@ typedef struct CPUClass { > CPUUnassignedAccess do_unassigned_access; > void (*do_unaligned_access)(CPUState *cpu, vaddr addr, > int is_write, int is_user, uintptr_t retaddr); > + bool (*virtio_is_big_endian)(CPUState *cpu); > int (*memory_rw_debug)(CPUState *cpu, vaddr addr, > uint8_t *buf, int len, bool is_write); > void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, > @@ -548,6 +549,15 @@ void cpu_interrupt(CPUState *cpu, int mask); > > #endif /* USER_ONLY */ > > +#ifndef CONFIG_USER_ONLY > +static inline bool cpu_virtio_is_big_endian(CPUState *cpu) > +{ > + CPUClass *cc = CPU_GET_CLASS(cpu); > + > + return cc->virtio_is_big_endian(cpu); > +} > +#endif > + Why? Just do this from virtio code directly. Alex