From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: Junjie Cao <junjie.cao@intel.com>
Subject: [PULL 7/7] tests/qtest/usb-hcd-xhci: test isoch endpoint type mismatch
Date: Thu, 24 Sep 2026 11:05:58 +0200 [thread overview]
Message-ID: <20260924090558.801845-8-thuth@redhat.com> (raw)
In-Reply-To: <20260924090558.801845-1-thuth@redhat.com>
From: Junjie Cao <junjie.cao@intel.com>
Configure the interrupt IN endpoint of usb-kbd as Isoch IN and queue one
TD. The TD is deferred by a microframe, the kick timer retries it,
usb-kbd NAKs, and a second doorbell retries it again. The TD has to stay
pending both times and the controller has to keep running.
Without the fix QEMU aborts in the timer retry. The endpoint setup is
taken from the reproducer attached to #3886.
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Message-ID: <c1166d1b83db5a507035d6fc27b1b552d4a95b0e.1789968699.git.junjie.cao@intel.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/usb-hcd-xhci-test.c | 35 +++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/tests/qtest/usb-hcd-xhci-test.c b/tests/qtest/usb-hcd-xhci-test.c
index 61eca37b157..2e173af7506 100644
--- a/tests/qtest/usb-hcd-xhci-test.c
+++ b/tests/qtest/usb-hcd-xhci-test.c
@@ -33,6 +33,7 @@
#define USBCMD_RS (1 << 0)
#define USBCMD_HCRST (1 << 1)
#define USBSTS_HCH (1 << 0)
+#define USBSTS_HCE (1 << 12)
#define PORTSC_CCS (1 << 0)
#define PORTSC_PR (1 << 4)
#define PORTSC_PP (1 << 9)
@@ -57,6 +58,7 @@
#define EP_TYPE_ISOCH_OUT 1
#define EP_TYPE_CONTROL 4
+#define EP_TYPE_ISOCH_IN 5
#define XHCI_RING_TRBS 64
#define XHCI_MICROFRAME_NS 125000
@@ -390,6 +392,37 @@ static void test_xhci_isoch_mfindex_32bit(void)
xhci_test_end(&x);
}
+/*
+ * The endpoint type in the endpoint context is whatever the guest says. Tell
+ * the controller that the interrupt endpoint of usb-kbd is isoch. The idle
+ * keyboard NAKs, and the TD has to stay pending when first the kick timer and
+ * then a doorbell retry it.
+ */
+static void test_xhci_isoch_ep_type_mismatch(void)
+{
+ uint64_t ring;
+ XHCITest x;
+
+ if (!xhci_test_supported("usb-kbd")) {
+ return;
+ }
+
+ xhci_test_start(&x, "-device usb-kbd");
+ ring = xhci_configure_ep(&x, 3, EP_TYPE_ISOCH_IN, 0, 8);
+
+ xhci_write_trb(&x, ring, xhci_alloc_page(&x), 8,
+ TRB_TYPE(TR_ISOCH) | TRB_TR_SIA | TRB_TR_IOC | TRB_C);
+ xhci_writel(&x, x.doorbell + 4 * x.slot, 3);
+ qtest_clock_step(x.qts, 2 * XHCI_MICROFRAME_NS);
+ xhci_writel(&x, x.doorbell + 4 * x.slot, 3);
+
+ g_assert_false(xhci_next_event(&x, NULL, NULL));
+ g_assert_cmphex(xhci_readl(&x, x.oper + XHCI_USBSTS) &
+ (USBSTS_HCH | USBSTS_HCE), ==, 0);
+
+ xhci_test_end(&x);
+}
+
int main(int argc, char **argv)
{
int ret;
@@ -406,6 +439,8 @@ int main(int argc, char **argv)
}
qtest_add_func("/xhci/pci/isoch/mfindex-32bit",
test_xhci_isoch_mfindex_32bit);
+ qtest_add_func("/xhci/pci/isoch/ep-type-mismatch",
+ test_xhci_isoch_ep_type_mismatch);
qtest_start("-device nec-usb-xhci,id=xhci"
" -drive id=drive0,if=none,file=null-co://,"
--
2.55.0
next prev parent reply other threads:[~2026-09-24 9:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 9:05 [PULL 0/7] XHCI fixes and drop Haiku VM Thomas Huth
2026-09-24 9:05 ` [PULL 1/7] hw/usb/hcd-xhci: Set reentrancy guard in timer functions (CVE-2026-17588) Thomas Huth
2026-09-24 9:05 ` [PULL 2/7] hw/usb/hcd-xhci: Limit DMA transfers to plain memory Thomas Huth
2026-09-24 9:12 ` Philippe Mathieu-Daudé
2026-09-24 9:21 ` Thomas Huth
2026-09-24 9:05 ` [PULL 3/7] tests/vm: Drop the broken Haiku VM Thomas Huth
2026-09-24 9:05 ` [PULL 4/7] hw/usb/hcd-xhci: fix interval alignment after MFINDEX passes 2^32 Thomas Huth
2026-09-24 9:05 ` [PULL 5/7] hw/usb/hcd-xhci: don't assert on NAK when retrying an isoch transfer Thomas Huth
2026-09-24 9:05 ` [PULL 6/7] tests/qtest/usb-hcd-xhci: test isoch pacing with MFINDEX above 2^32 Thomas Huth
2026-09-24 9:05 ` Thomas Huth [this message]
2026-09-24 15:24 ` [PULL 0/7] XHCI fixes and drop Haiku VM Richard Henderson
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=20260924090558.801845-8-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=junjie.cao@intel.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 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.