- kvm-blkdebug-Add-delay-ns-option.patch [RHEL-121686] - kvm-block-Add-blk_co_start-end_request-and-BDRV_REQ_NO_Q.patch [RHEL-121686] - kvm-block-Add-flags-parameter-to-blk_-_pdiscard.patch [RHEL-121686] - kvm-ide-Minimal-fix-for-deadlock-between-TRIM-and-drain.patch [RHEL-121686] - kvm-ide-Clean-up-ide_trim_co_entry-to-be-idiomatic-corou.patch [RHEL-121686] - kvm-ide-test-Factor-out-wait_dma_completion.patch [RHEL-121686] - kvm-ide-test-Test-reset-during-TRIM.patch [RHEL-121686] - kvm-block-graph-lock-fix-missed-wakeup-in-bdrv_graph_co_.patch [RHEL-186384] - kvm-block-curl-fix-curl-internal-handles-handling.patch [RHEL-186384] - kvm-block-curl.c-Use-explicit-long-constants-in-curl_eas.patch [RHEL-186384] - kvm-block-curl.c-Fix-CURLOPT_VERBOSE-parameter-type.patch [RHEL-186384] - kvm-block-curl-fix-concurrent-completion-handling.patch [RHEL-186384] - kvm-block-curl-free-s-password-in-cleanup-paths.patch [RHEL-186384] - kvm-nvme-Kick-and-check-completions-in-BDS-context.patch [RHEL-186384] - kvm-nvme-Note-in-which-AioContext-some-functions-run.patch [RHEL-186384] - kvm-block-remove-detached-header-option-from-opts-after-.patch [RHEL-186384] - kvm-block-fix-luks-amend-when-run-in-coroutine.patch [RHEL-186384] - kvm-qed-Don-t-try-to-flush-during-incoming-migration.patch [RHEL-186384] - kvm-block-vmdk-fix-OOB-read-in-vmdk_read_extent.patch [RHEL-186384] - kvm-block-throttle-groups-fix-deadlock-with-iolimits-and.patch [RHEL-186384] - kvm-throttle-group-Fix-race-condition-in-throttle_group_.patch [RHEL-186384] - kvm-qemu-img-Fix-amend-option-parse-error-handling.patch [RHEL-186384] - kvm-qemu-img-rebase-don-t-exceed-IO_BUF_SIZE-in-one-oper.patch [RHEL-186384] - kvm-python-backport-drop-Python3.6-workarounds.patch [RHEL-186384] - kvm-python-backport-Remove-deprecated-get_event_loop-cal.patch [RHEL-186384] - kvm-python-backport-avoid-creating-additional-event-loop.patch [RHEL-186384] - kvm-iotests-147-ensure-temporary-sockets-are-closed-befo.patch [RHEL-186384] - kvm-iotests-151-ensure-subprocesses-are-cleaned-up.patch [RHEL-186384] - kvm-tests-qemu-iotest-fix-iotest-024-with-qed-images.patch [RHEL-186384] - kvm-tests-qemu-iotests-Fix-check-for-existing-file-in-_r.patch [RHEL-186384] - kvm-async-access-bottom-half-flags-with-qatomic_read.patch [RHEL-186384] - kvm-block-linux-aio-bound-ioq_submit-recursion-depth.patch [RHEL-186384] - kvm-block-io-fallback-to-bounce-buffer-if-BLKZEROOUT-is-.patch [RHEL-186384] - kvm-file-posix-populate-pwrite_zeroes_alignment.patch [RHEL-186384] - kvm-block-use-pwrite_zeroes_alignment-when-writing-first.patch [RHEL-186384] - kvm-iotests-add-Linux-loop-device-image-creation-test.patch [RHEL-186384] - kvm-virtio-Fix-crash-when-sriov-pf-is-set-for-non-PCI-Ex.patch [RHEL-186384] - kvm-virtio-scsi-pass-the-same-cdb_size-to-virtio_scsi_po.patch [RHEL-186384] - kvm-hw-scsi-avoid-deadlock-upon-TMF-request-cancelling-w.patch [RHEL-186384] - kvm-virtio-blk-fix-zone-report-buffer-out-of-memory-CVE-.patch [RHEL-186384] - kvm-ide-Fix-potential-assertion-failure-on-VM-stop-for-P.patch [RHEL-186384] - kvm-block-Create-DEFAULT_BLOCK_CONF-macro.patch [RHEL-186384] - kvm-block-Add-more-defaults-to-DEFAULT_BLOCK_CONF.patch [RHEL-186384] - kvm-block-mirror-check-range-when-setting-zero-bitmap-fo.patch [RHEL-186384] - kvm-iotests-test-active-mirror-with-unaligned-small-writ.patch [RHEL-186384] - kvm-block-mirror-fix-assertion-failure-upon-duplicate-co.patch [RHEL-186384] - kvm-commit-Drain-nodes-across-all-of-bdrv_commit.patch [RHEL-186384] - kvm-qemu-io-Add-aio_discard-command.patch [RHEL-186384] - kvm-qcow2-Fix-corruption-on-discard-during-write-with-CO.patch [RHEL-186384] - kvm-iotests-046-Test-that-discard-write_zeroes-wait-for-.patch [RHEL-186384] - kvm-qcow2-Fix-data-loss-on-zero-write-with-detect-zeroes.patch [RHEL-186384] - kvm-block-Fix-crash-after-setting-latency-historygram-wi.patch [RHEL-186384] - Resolves: RHEL-121686 (qemu-kvm hung during drain after double pause) - Resolves: RHEL-186384 (virt-storage: Backport stable branch fixes)
182 lines
6.1 KiB
Diff
182 lines
6.1 KiB
Diff
From 1d7ff7d45d25d64fc17087a7efadca12fb9ee4e9 Mon Sep 17 00:00:00 2001
|
|
From: Kevin Wolf <kwolf@redhat.com>
|
|
Date: Tue, 21 Apr 2026 18:11:32 +0200
|
|
Subject: [PATCH 07/52] ide-test: Test reset during TRIM
|
|
|
|
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
RH-MergeRequest: 503: ide: Fix deadlock between TRIM and drain
|
|
RH-Jira: RHEL-121686
|
|
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
|
|
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
RH-Commit: [7/7] ce0ab448a920d91472da7c89080eeafa3d9cf830 (kmwolf/centos-qemu-kvm)
|
|
|
|
This is a regression test for the bug fixed in the previous commits, a
|
|
deadlock between the drain issued by an IDE reset and the TRIM state
|
|
machine.
|
|
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
Message-ID: <20260421161132.99878-8-kwolf@redhat.com>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
(cherry picked from commit 2fa24e9755994f76f08ea2452215eb50f26f4c21)
|
|
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
|
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
---
|
|
tests/qtest/ide-test.c | 95 ++++++++++++++++++++++++++++++++++++++----
|
|
1 file changed, 87 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
|
|
index c6dcb2c074..721e78170b 100644
|
|
--- a/tests/qtest/ide-test.c
|
|
+++ b/tests/qtest/ide-test.c
|
|
@@ -41,8 +41,11 @@
|
|
#define IDE_PCI_FUNC 1
|
|
|
|
#define IDE_BASE 0x1f0
|
|
+#define IDE_BASE2 0x3f6
|
|
#define IDE_PRIMARY_IRQ 14
|
|
|
|
+#define IDE_CTRL_RESET 0x04
|
|
+
|
|
#define ATAPI_BLOCK_SIZE 2048
|
|
|
|
/* How many bytes to receive via ATAPI PIO at one time.
|
|
@@ -99,6 +102,7 @@ enum {
|
|
|
|
CMDF_ABORT = 0x100,
|
|
CMDF_NO_BM = 0x200,
|
|
+ CMDF_NO_WAIT = 0x400,
|
|
};
|
|
|
|
enum {
|
|
@@ -228,21 +232,21 @@ static uint8_t wait_dma_completion(QTestState *qts, QPCIDevice *dev,
|
|
return status;
|
|
}
|
|
|
|
-static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
- int nb_sectors, PrdtEntry *prdt, int prdt_entries,
|
|
- void(*post_exec)(QPCIDevice *dev, QPCIBar ide_bar,
|
|
- uint64_t sector, int nb_sectors))
|
|
+static int send_dma_request_dev(QTestState *qts, QPCIDevice *dev,
|
|
+ QPCIBar bmdma_bar, QPCIBar ide_bar, int cmd,
|
|
+ uint64_t sector, int nb_sectors,
|
|
+ PrdtEntry *prdt, int prdt_entries,
|
|
+ void(*post_exec)(QPCIDevice *dev,
|
|
+ QPCIBar ide_bar,
|
|
+ uint64_t sector,
|
|
+ int nb_sectors))
|
|
{
|
|
- QPCIDevice *dev;
|
|
- QPCIBar bmdma_bar, ide_bar;
|
|
uintptr_t guest_prdt;
|
|
size_t len;
|
|
bool from_dev;
|
|
uint8_t status;
|
|
int flags;
|
|
|
|
- dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
-
|
|
flags = cmd & ~0xff;
|
|
cmd &= 0xff;
|
|
|
|
@@ -308,8 +312,28 @@ static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
qpci_io_writeb(dev, bmdma_bar, bmreg_cmd, 0);
|
|
}
|
|
|
|
+ if (flags & CMDF_NO_WAIT) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
status = wait_dma_completion(qts, dev, bmdma_bar, ide_bar);
|
|
|
|
+ return status;
|
|
+}
|
|
+
|
|
+static int send_dma_request(QTestState *qts, int cmd, uint64_t sector,
|
|
+ int nb_sectors, PrdtEntry *prdt, int prdt_entries,
|
|
+ void(*post_exec)(QPCIDevice *dev, QPCIBar ide_bar,
|
|
+ uint64_t sector, int nb_sectors))
|
|
+{
|
|
+ QPCIDevice *dev;
|
|
+ QPCIBar bmdma_bar, ide_bar;
|
|
+ uint8_t status;
|
|
+
|
|
+ dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
+ status = send_dma_request_dev(qts, dev, bmdma_bar, ide_bar,
|
|
+ cmd, sector, nb_sectors, prdt, prdt_entries,
|
|
+ post_exec);
|
|
free_pci_device(dev);
|
|
|
|
return status;
|
|
@@ -457,6 +481,60 @@ static void test_bmdma_trim(void)
|
|
test_bmdma_teardown(qts);
|
|
}
|
|
|
|
+static void test_bmdma_trim_reset(void)
|
|
+{
|
|
+ QTestState *qts;
|
|
+ QPCIDevice *dev;
|
|
+ QPCIBar bmdma_bar, ide_bar, ide_bar2;
|
|
+ uint8_t status;
|
|
+ const uint64_t trim_range[] = {
|
|
+ trim_range_le(0, 2),
|
|
+ trim_range_le(6, 8),
|
|
+ };
|
|
+ size_t len = 512;
|
|
+ uint8_t *buf;
|
|
+ uintptr_t guest_buf;
|
|
+ PrdtEntry prdt[1];
|
|
+
|
|
+ qts = ide_test_start(
|
|
+ "-blockdev file,filename=%s,node-name=img "
|
|
+ "-blockdev blkdebug,image=img,node-name=dbg,discard=unmap,"
|
|
+ "inject-error.0.event=none,inject-error.0.iotype=discard,"
|
|
+ "inject-error.0.errno=0,inject-error.0.delay-ns=1000000 "
|
|
+ "-device ide-hd,drive=dbg,bus=ide.0",
|
|
+ tmp_path[0]);
|
|
+ qtest_irq_intercept_in(qts, "ioapic");
|
|
+
|
|
+ guest_buf = guest_alloc(&guest_malloc, len);
|
|
+ prdt[0].addr = cpu_to_le32(guest_buf),
|
|
+ prdt[0].size = cpu_to_le32(len | PRDT_EOT),
|
|
+
|
|
+ dev = get_pci_device(qts, &bmdma_bar, &ide_bar);
|
|
+ ide_bar2 = qpci_legacy_iomap(dev, IDE_BASE2);
|
|
+
|
|
+ buf = g_malloc(len);
|
|
+
|
|
+ /* TRIM request with two segments */
|
|
+ *((uint64_t *)buf) = trim_range[0];
|
|
+ *((uint64_t *)buf + 1) = trim_range[1];
|
|
+
|
|
+ qtest_memwrite(qts, guest_buf, buf, 2 * sizeof(uint64_t));
|
|
+
|
|
+ send_dma_request_dev(qts, dev, bmdma_bar, ide_bar, CMD_DSM | CMDF_NO_WAIT, 0, 1, prdt,
|
|
+ ARRAY_SIZE(prdt), NULL);
|
|
+
|
|
+ /* Reset the device while the first segment is in flight */
|
|
+ qpci_io_writeb(dev, ide_bar2, 0, IDE_CTRL_RESET);
|
|
+
|
|
+ status = wait_dma_completion(qts, dev, bmdma_bar, ide_bar);
|
|
+ g_assert_cmphex(status, ==, BM_STS_INTR);
|
|
+ assert_bit_clear(qpci_io_readb(dev, ide_bar, reg_status), DF | ERR);
|
|
+
|
|
+ free_pci_device(dev);
|
|
+ g_free(buf);
|
|
+ test_bmdma_teardown(qts);
|
|
+}
|
|
+
|
|
/*
|
|
* This test is developed according to the Programming Interface for
|
|
* Bus Master IDE Controller (Revision 1.0 5/16/94)
|
|
@@ -1138,6 +1216,7 @@ int main(int argc, char **argv)
|
|
|
|
qtest_add_func("/ide/bmdma/simple_rw", test_bmdma_simple_rw);
|
|
qtest_add_func("/ide/bmdma/trim", test_bmdma_trim);
|
|
+ qtest_add_func("/ide/bmdma/trim_reset", test_bmdma_trim_reset);
|
|
qtest_add_func("/ide/bmdma/various_prdts", test_bmdma_various_prdts);
|
|
qtest_add_func("/ide/bmdma/no_busmaster", test_bmdma_no_busmaster);
|
|
|
|
--
|
|
2.52.0
|
|
|