From: David Woodhouse <dwmw2@infradead.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Anthony Perard" <anthony.perard@citrix.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
"Paul Durrant" <paul@xen.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH-for-9.0 04/10] hw/xen: Factor xen_arch_align_ioreq_data() out of handle_ioreq()
Date: Tue, 14 Nov 2023 08:49:25 -0500 [thread overview]
Message-ID: <2b3491da6eacd5f20c950fb339eca20cc8bf845b.camel@infradead.org> (raw)
In-Reply-To: <b7646614-8f5c-4ea6-9ea8-ff81f4a492c9@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3202 bytes --]
On Tue, 2023-11-14 at 08:58 +0100, Philippe Mathieu-Daudé wrote:
> > > Reviewing quickly hw/block/dataplane/xen-block.c, this code doesn't
> > > seem target specific at all IMHO. Otherwise I'd really expect it to
> > > fail compiling. But I don't know much about Xen, so I'll let block &
> > > xen experts to have a look.
> >
> > Where it checks dataplane->protocol and does different things for
> > BLKIF_PROTOCOL_NATIVE/BLKIF_PROTOCOL_X86_32/BLKIF_PROTOCOL_X86_64, the
> > *structures* it uses are intended to be using the correct ABI. I think
> > the structs for BLKIF_PROTOCOL_NATIVE may actually be *different*
> > according to the target, in theory?
>
> OK I see what you mean, blkif_back_rings_t union in hw/block/xen_blkif.h
>
> These structures shouldn't differ between targets, this is the point of
> an ABI :)
Structures like that *shouldn't* differ between targets, but the Xen
struct blkif_request does:
typedef blkif_vdev_t uint16_t;
struct blkif_request {
uint8_t operation; /* BLKIF_OP_??? */
uint8_t nr_segments; /* number of segments */
blkif_vdev_t handle; /* only for read/write requests */
uint64_t id; /* private guest value, echoed in resp */
blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
};
This is why we end up with explicit versions for x86-32 and x86-64,
with the 'id' field aligned explicitly to 4 or 8 bytes. The 'native'
version when we build it in qemu will just use the *host* ABI to decide
how to align it.
> And if they were, they wouldn't compile as target agnostic.
The words "wouldn't compile" gives me fantasies of a compiler that
literally errors out, saying "you can't use that struct in arch-
agnostic code because the padding is different on different
architectures".
It isn't so. You're just a tease.
With the exception of the x86-{32,64} special case, the
BLKIF_PROTOCOL_NATIVE support ends up using the *host* ABI, regardless
of which target it was aimed at.
Which might even be OK; are there any other targets which align
uint64_t to 4 bytes, like i386 does? And certainly isn't *your* problem
anyway.
What I was thinking was that if we *do* need to do something to make
BLKIF_PROTOCOL_NATIVE actually differ between targets, maybe that would
mean we really *do* want to build this code separately for each target
rather than just once?
I suppose *if* we fix it, we can fix it in a way that doesn't require
specific compilation. Like we already did for x86. I literally use
object_dynamic_cast(qdev_get_machine(), "x86-machine") there.
>
> > I think this series makes it look like target-agnostic support *should*
> > work... but it doesn't really?
>
> For testing we have:
>
> aarch64: tests/avocado/boot_xen.py
> x86_64: tests/avocado/kvm_xen_guest.py
>
> No combination with i386 is tested,
> Xen within aarch64 KVM is not tested (not sure it works).
No, there is support in the *kernel* for Xen guests, which hasn't been
added to AArch64 KVM.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
next prev parent reply other threads:[~2023-11-14 13:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 15:58 [PATCH-for-9.0 04/10] hw/xen: Factor xen_arch_align_ioreq_data() out of handle_ioreq() Woodhouse, David
2023-11-13 16:09 ` Philippe Mathieu-Daudé
2023-11-13 17:11 ` David Woodhouse
2023-11-14 7:58 ` Philippe Mathieu-Daudé
2023-11-14 13:49 ` David Woodhouse [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-11-13 15:21 [PATCH-for-9.0 00/10] hw/xen: Have most of Xen files become target-agnostic Philippe Mathieu-Daudé
2023-11-13 15:21 ` [PATCH-for-9.0 04/10] hw/xen: Factor xen_arch_align_ioreq_data() out of handle_ioreq() Philippe Mathieu-Daudé
2023-11-13 17:36 ` David Woodhouse
2023-11-13 18:16 ` Richard Henderson
2023-11-14 7:42 ` Philippe Mathieu-Daudé
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=2b3491da6eacd5f20c950fb339eca20cc8bf845b.camel@infradead.org \
--to=dwmw2@infradead.org \
--cc=alex.bennee@linaro.org \
--cc=anthony.perard@citrix.com \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sstabellini@kernel.org \
--cc=thuth@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).