From: "Andreas Färber" <afaerber@suse.de>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
anton@samba.org
Subject: Re: [Qemu-devel] [PATCH 1/7] virtio: allow byte swapping for vring and config access
Date: Fri, 09 Aug 2013 16:24:27 +0200 [thread overview]
Message-ID: <5204FB9B.9000809@suse.de> (raw)
In-Reply-To: <87li4bnyax.fsf@rustcorp.com.au>
Am 09.08.2013 09:00, schrieb Rusty Russell:
> Andreas Färber <afaerber@suse.de> writes:
>> Am 08.08.2013 15:31, schrieb Anthony Liguori:
>>> Rusty Russell <rusty@rustcorp.com.au> writes:
>>> We have a mechanism to do weak functions via stubs/. I think it would
>>> be better to do cpu_get_byteswap() as a stub function and then overload
>>> it in the ppc64 code.
>>
>> If this as your name indicates is a per-CPU function then it should go
>> into CPUClass. Interesting question is, what is virtio supposed to do if
>> we have two ppc CPUs, one is Big Endian, the other is Little Endian.
>> We'd need to check current_cpu then, which for Xen is always NULL.
>
> Below is the minimal solution, which is sufficient for virtio.
>
> If Anton wants per-cpu endianness for gdb, he'll need something more
> sophisticated.
>
> Feedback welcome!
> Rusty.
>
> Subject: cpu_get_byteswap: function for endian-ambivalent targets.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index a5bb515..ed84267 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -357,4 +357,13 @@ void cpu_reset_interrupt(CPUState *cpu, int mask);
> */
> void cpu_resume(CPUState *cpu);
>
> +/**
> + * cpu_get_byteswap:
> + *
> + * Is (any) CPU running in byteswapped mode: normally false. This
> + * doesn't take a cpu argument, because we don't support heterogeneous
> + * endianness.
> + */
> +bool cpu_get_byteswap(void);
> +
> #endif
> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> index 9b701b4..d4af94a 100644
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -25,3 +25,4 @@ stub-obj-y += vm-stop.o
> stub-obj-y += vmstate.o
> stub-obj-$(CONFIG_WIN32) += fd-register.o
> stub-obj-y += cpus.o
> +stub-obj-y += cpu_byteswap.o
> diff --git a/stubs/cpu_byteswap.c b/stubs/cpu_byteswap.c
> new file mode 100644
> index 0000000..b3b669f
> --- /dev/null
> +++ b/stubs/cpu_byteswap.c
> @@ -0,0 +1,6 @@
> +#include "qom/cpu.h"
> +
> +bool cpu_get_byteswap(void)
> +{
> + return false;
> +}
That is exactly what I asked not to do. first_cpu_get_byteswap() or
virtio_get_byteswap() etc. would be names OK for me. But see below.
>
> Subject: target-ppc: ppc64 targets can be either endian.
>
> In this case, we just query the first cpu.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/target-ppc/misc_helper.c b/target-ppc/misc_helper.c
> index 616aab6..0a508eb 100644
> --- a/target-ppc/misc_helper.c
> +++ b/target-ppc/misc_helper.c
> @@ -116,3 +116,8 @@ void ppc_store_msr(CPUPPCState *env, target_ulong value)
> {
> hreg_store_msr(env, value, 0);
> }
> +
> +bool cpu_get_byteswap(void)
> +{
> + return first_cpu->hflags & (1 << MSR_LE);
> +}
This assumes that first_cpu != NULL, which I pointed out is not the case
for Xen. I'm not aware of a ppc Xen implementation, but it shows that
you should define which endianness (probably little) you want to adopt
in such a case.
You should also urgently update your QEMU since that code will not
build. first_cpu is CPUState since a number of weeks, you would need to
cast to PowerPCCPU *cpu = POWERPC_CPU(first_cpu); in the non-NULL case.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2013-08-09 14:24 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 5:15 [Qemu-devel] [PATCH 0/7] Virtio support for endian-curious guests Rusty Russell
2013-08-08 5:15 ` [Qemu-devel] [PATCH 1/7] virtio: allow byte swapping for vring and config access Rusty Russell
2013-08-08 13:31 ` Anthony Liguori
2013-08-08 14:28 ` Andreas Färber
2013-08-08 15:40 ` Anthony Liguori
2013-08-08 15:45 ` Daniel P. Berrange
2013-08-08 16:07 ` Anthony Liguori
2013-08-08 16:14 ` Peter Maydell
2013-08-08 16:25 ` Anthony Liguori
2013-08-08 16:30 ` Peter Maydell
2013-08-09 2:58 ` Rusty Russell
2013-08-09 4:39 ` Anton Blanchard
2013-08-09 8:05 ` Peter Maydell
2013-08-09 14:16 ` Anthony Liguori
2013-08-08 15:48 ` Peter Maydell
2013-08-08 16:11 ` Anthony Liguori
2013-08-08 16:24 ` Andreas Färber
2013-08-09 7:35 ` Rusty Russell
2013-08-09 7:42 ` Peter Maydell
2013-08-12 7:49 ` Rusty Russell
2013-08-09 7:49 ` Benjamin Herrenschmidt
2013-08-12 0:28 ` Rusty Russell
2013-08-12 0:49 ` Benjamin Herrenschmidt
2013-08-09 15:15 ` Andreas Färber
2013-08-09 0:08 ` Rusty Russell
2013-08-09 7:00 ` Rusty Russell
2013-08-09 14:24 ` Andreas Färber [this message]
2013-08-09 6:40 ` Rusty Russell
2013-08-09 14:10 ` Anthony Liguori
2013-08-11 23:46 ` Rusty Russell
2013-08-08 5:15 ` [Qemu-devel] [PATCH 2/7] target-ppc: ppc64 targets can be either endian Rusty Russell
2013-08-08 5:15 ` [Qemu-devel] [PATCH 3/7] hw/net/virtio-net: use virtio wrappers to access headers Rusty Russell
2013-08-08 13:32 ` Anthony Liguori
2013-08-08 5:15 ` [Qemu-devel] [PATCH 4/7] hw/net/virtio-balloon: use virtio wrappers to access page frame numbers Rusty Russell
2013-08-08 13:32 ` Anthony Liguori
2013-08-08 5:15 ` [Qemu-devel] [PATCH 5/7] hw/block/virtio-blk: use virtio wrappers to access headers Rusty Russell
2013-08-08 9:57 ` Peter Maydell
2013-08-08 13:32 ` Anthony Liguori
2013-08-08 5:15 ` [Qemu-devel] [PATCH 6/7] hw/scsi/virtio-scsi: " Rusty Russell
2013-08-08 13:33 ` Anthony Liguori
2013-08-08 5:15 ` [Qemu-devel] [PATCH 7/7] hw/char/virtio-serial-bus: " Rusty Russell
2013-08-08 13:34 ` Anthony Liguori
2013-08-08 5:15 ` [Qemu-devel] [PATCH 7/7] patch virtio-serial-biendian.patch Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5204FB9B.9000809@suse.de \
--to=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=anton@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--cc=stefano.stabellini@eu.citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.