From: Peter Maydell <peter.maydell@linaro.org>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] virtio_tswaps() vs virtio_ld/st_p()
Date: Mon, 19 Jan 2015 11:45:39 +0000 [thread overview]
Message-ID: <CAFEAcA-r0S5-rtovfyG9h+TPUFbnnawVSY74K-rso49TwFs_7g@mail.gmail.com> (raw)
In-Reply-To: <CAJSP0QU9YbTaXGbJRcx8qCdqF0yBdWj276KkhGVN1WV37bRTNQ@mail.gmail.com>
On 19 January 2015 at 11:35, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> What is the difference between the virtio_tswaps() and
> virtio_ld/st_p() families of functions?
virtio_ld/st*_p() perform a load or store from memory pointed
to by the (host) pointer argument.
virtio_tswap16 &c take a value, swap it as appropriate and
return a value.
virtio_tswap16s &c do an in-place byteswap on the value pointed
to by the host pointer argument.
(The tswap*/tswap*s pairs are a mirror of the equivalent families
of functions bswap16/bswap16s provided by bswap.h.)
The most important distinction here is that the ld/st functions
will handle possibly unaligned accesses, whereas the tswap
functions will not. The former are intended for "fish this value
out from some guest RAM" and the latter for "we have a structure
we've copied from guest RAM already via memcpy and want to swizzle
the entries in it".
-- PMM
next prev parent reply other threads:[~2015-01-19 11:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 11:35 [Qemu-devel] virtio_tswaps() vs virtio_ld/st_p() Stefan Hajnoczi
2015-01-19 11:45 ` Peter Maydell [this message]
2015-01-19 12:49 ` Greg Kurz
2015-01-19 12:53 ` Peter Maydell
2015-01-19 13:01 ` Paolo Bonzini
2015-01-19 13:10 ` Stefan Hajnoczi
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=CAFEAcA-r0S5-rtovfyG9h+TPUFbnnawVSY74K-rso49TwFs_7g@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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 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).