From: Yi Liu <yi.l.liu@intel.com>
To: David Woodhouse <dwmw2@infradead.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>, Le Tan <tamlokveer@gmail.com>,
kib <kib@freebsd.org>, <jhb@freebsd.org>
Cc: "Clément Mathieu--Drif" <clement.mathieu--drif@eviden.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v2] intel_iommu: Allow both Status Write and Interrupt Flag in QI wait
Date: Mon, 14 Jul 2025 22:28:09 +0800 [thread overview]
Message-ID: <9ce8b7e6-ad15-4d2e-a430-3896eccc7519@intel.com> (raw)
In-Reply-To: <0122cbabc0adcc3cf878f5fd7834d8f258c7a2f2.camel@infradead.org>
Hi David,
On 2025/7/14 16:00, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> FreeBSD does both, and this appears to be perfectly valid. The VT-d
> spec even talks about the ordering (the status write should be done
> first, unsurprisingly).
interesting. Have you tried setting both flags on baremetal and the hw
gives you both the status code and an interrupt?
> We certainly shouldn't assert() and abort QEMU if the guest asks for
> both.
>
> Fixes: ed7b8fbcfb88 ("intel-iommu: add supports for queued invalidation interface")
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/3028
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
> v2:
> • Only generate the interrupt once.
> • Spaces around bitwise OR.
>
> This stops QEMU crashing, but I still can't get FreeBSD to boot and use
> CPUs with APIC ID > 255 using *either* Intel or AMD IOMMU with
> interrupt remapping, or the native 15-bit APIC ID enlightenment.
> cf. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288122
>
>
> hw/i386/intel_iommu.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index 69d72ad35c..851c4656c5 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -2822,6 +2822,7 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
> {
> uint64_t mask[4] = {VTD_INV_DESC_WAIT_RSVD_LO, VTD_INV_DESC_WAIT_RSVD_HI,
> VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE};
> + bool ret = true;
>
> if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false,
> __func__, "wait")) {
> @@ -2833,8 +2834,6 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
> uint32_t status_data = (uint32_t)(inv_desc->lo >>
> VTD_INV_DESC_WAIT_DATA_SHIFT);
>
> - assert(!(inv_desc->lo & VTD_INV_DESC_WAIT_IF));
> -
> /* FIXME: need to be masked with HAW? */
> dma_addr_t status_addr = inv_desc->hi;
> trace_vtd_inv_desc_wait_sw(status_addr, status_data);
> @@ -2843,18 +2842,22 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
> &status_data, sizeof(status_data),
> MEMTXATTRS_UNSPECIFIED)) {
> trace_vtd_inv_desc_wait_write_fail(inv_desc->hi, inv_desc->lo);
> - return false;
> + ret = false;
> }
> - } else if (inv_desc->lo & VTD_INV_DESC_WAIT_IF) {
> + }
> +
> + if (inv_desc->lo & VTD_INV_DESC_WAIT_IF) {
> /* Interrupt flag */
> vtd_generate_completion_event(s);
> - } else {
> + }
> +
> + if (!(inv_desc->lo & (VTD_INV_DESC_WAIT_IF | VTD_INV_DESC_WAIT_SW))) {
> error_report_once("%s: invalid wait desc: hi=%"PRIx64", lo=%"PRIx64
> " (unknown type)", __func__, inv_desc->hi,
> inv_desc->lo);
> return false;
> }
I think this "if branch" can be moved just after the inv_desc non-zero
reserved bit checking. Hence you don't need a ret at all. :) btw. I'm
also asking if VT-d spec allows it or not. So let's wait for a while..
> - return true;
> + return ret;
> }
>
> static bool vtd_process_context_cache_desc(IntelIOMMUState *s,
--
Regards,
Yi Liu
next prev parent reply other threads:[~2025-07-14 15:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 8:00 [PATCH v2] intel_iommu: Allow both Status Write and Interrupt Flag in QI wait David Woodhouse
2025-07-14 14:28 ` Yi Liu [this message]
2025-07-14 16:41 ` David Woodhouse
2025-07-14 21:22 ` Konstantin Belousov via
2025-07-15 6:11 ` CLEMENT MATHIEU--DRIF
2025-07-15 8:27 ` David Woodhouse
2025-07-15 12:27 ` CLEMENT MATHIEU--DRIF
2025-07-16 4:01 ` Yi Liu
2025-07-16 4:05 ` Konstantin Belousov
2025-07-16 9:23 ` Yi Liu
2025-07-16 9:36 ` Konstantin Belousov via
2025-07-15 12:35 ` Yi Liu
2025-07-15 13:59 ` CLEMENT MATHIEU--DRIF
2025-07-22 12:04 ` David Woodhouse
2025-08-01 15:09 ` Liu, Yi L
2025-08-02 5:38 ` Michael Tokarev
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=9ce8b7e6-ad15-4d2e-a430-3896eccc7519@intel.com \
--to=yi.l.liu@intel.com \
--cc=clement.mathieu--drif@eviden.com \
--cc=dwmw2@infradead.org \
--cc=eduardo@habkost.net \
--cc=jasowang@redhat.com \
--cc=jhb@freebsd.org \
--cc=kib@freebsd.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=tamlokveer@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 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.