From: Thomas Huth <thuth@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Peter Xu <peterx@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org,
"Daniel P . Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH] hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry
Date: Wed, 2 Aug 2023 15:35:10 +0200 [thread overview]
Message-ID: <bf39003f-b7a6-582f-8c99-6395f482ea1a@redhat.com> (raw)
In-Reply-To: <20230802092837.153689-1-thuth@redhat.com>
On 02/08/2023 11.28, Thomas Huth wrote:
> The code already tries to do some endianness handling here, but
> currently fails badly:
> - While it already swaps the data when logging errors / tracing, it fails
> to byteswap the value before e.g. accessing entry->irte.present
> - entry->irte.source_id is swapped with le32_to_cpu(), though this is
> a 16-bit value
> - The whole union is apparently supposed to be swapped via the 64-bit
> data[2] array, but the struct is a mixture between 32 bit values
> (the first 8 bytes) and 64 bit values (the second 8 bytes), so this
> cannot work as expected.
>
> Fix it by converting the struct to two proper 64-bit bitfields, and
> by swapping the values only once for everybody right after reading
> the data from memory.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> Note: There are more endianness issues in the code, I haven't figured
> out all of them yet, Linux fails to boot in the guest when I use
> this device on a s390x host. But I wanted to publish this patch
> now already since this should also fix the "issue" with the Clang
> ms_struct packing that we recently discussed on the mailing list.
I just found the all remaining issues (I hope). I can now run a Linux guest
with -device intel-iommu and it works without crashing now. I'll send out
the patches shorty, after cleaning them up a little bit.
Thomas
next prev parent reply other threads:[~2023-08-02 13:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 9:28 [PATCH] hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry Thomas Huth
2023-08-02 13:35 ` Thomas Huth [this message]
2023-08-02 14:02 ` Peter Xu
2023-08-02 14:14 ` Thomas Huth
2023-08-02 15:12 ` Peter Xu
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=bf39003f-b7a6-582f-8c99-6395f482ea1a@redhat.com \
--to=thuth@redhat.com \
--cc=berrange@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@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;
as well as URLs for NNTP newsgroup(s).