public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: <kvm@vger.kernel.org>, <kvm-ppc@vger.kernel.org>,
	<kvmarm@lists.cs.columbia.edu>, <patches@linaro.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	"Alexander Graf" <agraf@suse.de>
Subject: Re: [PATCH v2] KVM: Specify byte order for KVM_EXIT_MMIO
Date: Fri, 24 Jan 2014 17:51:32 -0600	[thread overview]
Message-ID: <1390607492.24905.682.camel@snotra.buserror.net> (raw)
In-Reply-To: <1390606782-14724-1-git-send-email-christoffer.dall@linaro.org>

On Fri, 2014-01-24 at 15:39 -0800, Christoffer Dall wrote:
> The KVM API documentation is not clear about the semantics of the data
> field on the mmio struct on the kvm_run struct.
> 
> This has become problematic when supporting ARM guests on big-endian
> host systems with guests of both endianness types, because it is unclear
> how the data should be exported to user space.
> 
> This should not break with existing implementations as all supported
> existing implementations of known user space applications (QEMU and
> kvmtools for virtio) only support default endianness of the
> architectures on the host side.
> 
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
> Changes [v1 - v2]:
>  - s/host kernel should/host user space should/
> 
>  Documentation/virtual/kvm/api.txt | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 366bf4b..6dbd68c 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -2565,6 +2565,11 @@ executed a memory-mapped I/O instruction which could not be satisfied
>  by kvm.  The 'data' member contains the written data if 'is_write' is
>  true, and should be filled by application code otherwise.
>  
> +The 'data' member byte order is host kernel native endianness, regardless of
> +the endianness of the guest, and represents the the value as it would go on the
> +bus in real hardware.  The host user space should always be able to do:
> +<type> val = *((<type> *)mmio.data).

Host userspace should be able to do that with what results?  It would
only produce a directly usable value if host endianness is the same as
the emulated device's endianness.

I'm not sure that "host kernel native endianness" is an accurate way of
describing what currently happens.  Regardless of host or guest
endianness, the guest should be swapping the value as necessary to
ensure that the value that goes on the (real or emulated) bus is the
same.

Plus, if it were really "as it would go on the bus" the value wouldn't
necessarily be left justified within data[], depending on how the bus 
works.

How about a wording like this:

  The 'data' member contains, in its first 'len' bytes, the value as it
  would appear if the guest had accessed memory rather than I/O.        

-Scott

  reply	other threads:[~2014-01-24 23:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 23:39 [PATCH v2] KVM: Specify byte order for KVM_EXIT_MMIO Christoffer Dall
2014-01-24 23:51 ` Scott Wood [this message]
2014-01-25  0:05   ` Victor Kamensky
2014-01-25  0:24   ` Peter Maydell
2014-01-25  1:56     ` Christoffer Dall
2014-01-25  2:04       ` Scott Wood
2014-01-25  2:16         ` Alexander Graf
2014-01-25  1:58     ` Scott Wood
2014-01-25  2:15       ` Alexander Graf
2014-01-25  2:34         ` Christoffer Dall
2014-01-25  9:13           ` Alexander Graf
2014-01-25  2:37         ` Victor Kamensky
2014-01-25  9:20           ` Alexander Graf
2014-01-25 15:36             ` Victor Kamensky
2014-01-25 16:12               ` Alexander Graf
2014-01-25 16:23         ` Peter Maydell
2014-01-25 18:31           ` Christoffer Dall
2014-01-26  3:46             ` Victor Kamensky
2014-01-26  5:43               ` Victor Kamensky
2014-01-27  7:52                 ` Alexander Graf
2014-01-27  9:42                   ` Peter Maydell
2014-01-27  7:41               ` Alexander Graf
2014-01-28  1:59         ` Scott Wood
2014-01-28  8:55           ` Peter Maydell

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=1390607492.24905.682.camel@snotra.buserror.net \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=christoffer.dall@linaro.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.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