Skip to contentSkip to conversation

hw/ufs: Add experimental fault injection properties for recovery testing

PATCH In review Stanley Jhu 2 participants 4 messages Sep 9 – Oct 2

lore
Share & tools
lore
#0 lore raw

v2 cover hw/ufs: Add experimental fault injection properties for recovery testing

This patch series adds experimental fault injection properties (x-hold-tag and x-hold-mode) to the QEMU UFS emulator to facilitate end-to-end testing of host driver error handling, task aborts, and power management recovery.

Based-on: <[email protected]>

Why:
In Linux kernel UFS driver development and regression testing, reproducing hardware edge cases -- such as task abort timeouts, device abort rejects, grace-period command completions in transition, and Start Stop Unit (SSU) power management timeouts -- requires deterministic hardware fault injection. Standard emulated storage completes requests in microseconds, leaving host driver error escalation paths unexercised during automated CI/CD testing.

What:
- Patch 1: Implements core fault injection properties x-hold-tag and x-hold-mode, supporting task abort testing modes ("abort-success", "abort-failed", "in-transition", "timeout") with dynamic QOM setters (realized_set_allowed = true) for live QMP control without rebooting.
- Patch 2: Extends x-hold-mode with "ssu-timeout" mode, intercepting SCSI START_STOP (0x1B) commands to test host driver power management suspend-to-idle and freeze recovery.

Differences from v1:
- Split into a separate series based on the production TMR and MCQ series.
- Split into 2 logical patches: Patch 1 introduces the core fault injection framework for task abort testing (matching the upstream companion Linux kernel patch); Patch 2 extends the framework with ssu-timeout mode for power management recovery testing.

Tested:
- Verified with the companion Linux kernel patch:

- Verified full 5-case fault injection matrix (Abort Success, Abort Reject, In-Transition, Abort Timeout, and Normal I/O) in a single running VM session without reboot via QMP.
- Verified SSU timeout fault injection under rtcwake freeze with 100% data integrity (cmp) on /dev/sda post-recovery.
- Passes ./scripts/checkpatch.pl with 0 errors and 0 warnings.

Stanley Jhu (2):
hw/ufs: Add experimental fault injection properties for task abort
testing
hw/ufs: Add ssu-timeout mode for power management recovery testing

 hw/ufs/trace-events |   3 +
 hw/ufs/ufs-pci.c    |   4 +
 hw/ufs/ufs-sysbus.c |   4 +
 hw/ufs/ufs.c        | 306 ++++++++++++++++++++++++++++++++++++++++++++++++---
 hw/ufs/ufs.h        |  55 ++++++++++
 5 files changed, 357 insertions(+), 15 deletions(-)
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
#1 lore raw

PATCH v2 1/2 hw/ufs: Add experimental fault injection properties for task abort testing

Add experimental properties x-hold-tag and x-hold-mode to ufs-pci and ufs-sysbus devices to facilitate end-to-end testing of host driver error handling, task aborts, and SCSI recovery routines.

When x-hold-tag is set to a specific tag (0..255), the controller holds the matching transfer request until a Task Management Request (TMR) targeting the held request is issued by the host driver. If x-hold-tag=0xfffffffe (UFS_HOLD_TAG_ANY), the controller intercepts the first READ_10/WRITE_10 request with LBA >= 512, avoiding guest boot-time metadata requests. The default value is 0xffffffff (UFS_HOLD_TAG_NONE), which disables fault injection.

The x-hold-mode property controls how the held request and subsequent recovery are resolved:
- "abort-success": TMR ABORT_TASK aborts the held request, clears its state, and returns SUCCESS (COMPL).
- "abort-failed": TMR ABORT_TASK returns TASK_MANAGEMENT_FUNC_FAILED.
- "in-transition": TMR QUERY_TASK / ABORT_TASK completes the held request successfully and returns COMPL (simulating a command completing in transition).
- "timeout": TMR ABORT_TASK does not complete, triggering TMR timeout.

Both properties support runtime modification via QOM (e.g., QMP qom-set), enabling continuous fault injection testing within a single running VM.

Together with the companion Linux kernel patch:
"[PATCH] scsi: ufs: core: Add fault injection for task abort failures"

these changes provide a deterministic testbed for automated CI/CD validation across driver error recovery and emulation layers.

Based-on: <[email protected]>

---
 hw/ufs/trace-events |   3 +
 hw/ufs/ufs-pci.c    |   4 +
 hw/ufs/ufs-sysbus.c |   4 +
 hw/ufs/ufs.c        | 289 +++++++++++++++++++++++++++++++++++++++++---
 hw/ufs/ufs.h        |  54 +++++++++
 5 files changed, 339 insertions(+), 15 deletions(-)
hw/ufs/trace-events +3 -0
index 5e5a54a3fb..a2c8f80811 100644
@@ -16,6 +16,9 @@ ufs_mcq_create_sq(uint8_t sqid, uint8_t cqid, uint64_t addr, uint16_t size) "mcq
 ufs_mcq_create_cq(uint8_t cqid, uint64_t addr, uint16_t size) "mcq create cq cqid %"PRIu8", addr 0x%"PRIx64", size %"PRIu16""
 ufs_write_mcq_op_reg(uint8_t qid, uint32_t offset, uint32_t data) "qid %"PRIu8", offset 0x%"PRIx32", data 0x%"PRIx32""
 ufs_process_tmr(uint8_t func, uint32_t tag, uint8_t resp) "query_func 0x%"PRIx8", task_tag %"PRIu32", tm_resp 0x%"PRIx8""
+ufs_inject_hold_req(uint8_t tag, uint32_t lba) "held command tag %"PRIu8", lba %"PRIu32""
+ufs_set_hold_tag(uint32_t tag) "hold-tag set to 0x%"PRIx32""
+ufs_set_hold_mode(const char *mode) "hold-mode set to %s"
 ufs_hce_reset(void) "HCE 1 -> 0 reset: cancelling BHs, resetting MCQ and request lists"
 
 # error condition
hw/ufs/ufs-pci.c +4 -0
index 8abd7d98e3..fe6c497dc2 100644
@@ -72,6 +72,10 @@ static const Property ufs_pci_props[] = {
                        0x400),
     DEFINE_PROP_UINT32("wb-min-size", UfsPciState, ufs.params.wb_min_size,
                        0x100),
+    DEFINE_PROP_UNSIGNED("x-hold-tag", UfsPciState, ufs.params.x_hold_tag,
+                         UFS_HOLD_TAG_NONE, ufs_prop_hold_tag, uint32_t),
+    DEFINE_PROP("x-hold-mode", UfsPciState, ufs.params.x_hold_mode,
+                ufs_prop_hold_mode, char *),
 };
 
 static const VMStateDescription ufs_pci_vmstate = {
hw/ufs/ufs-sysbus.c +4 -0
index 84de2e95ac..f0e4dfcd71 100644
@@ -45,6 +45,10 @@ static const Property ufs_sysbus_props[] = {
                        0x400),
     DEFINE_PROP_UINT32("wb-min-size", SysbusUfsState, ufs.params.wb_min_size,
                        0x100),
+    DEFINE_PROP_UNSIGNED("x-hold-tag", SysbusUfsState, ufs.params.x_hold_tag,
+                         UFS_HOLD_TAG_NONE, ufs_prop_hold_tag, uint32_t),
+    DEFINE_PROP("x-hold-mode", SysbusUfsState, ufs.params.x_hold_mode,
+                ufs_prop_hold_mode, char *),
 };
 
 static const VMStateDescription ufs_sysbus_vmstate = {
hw/ufs/ufs.c +274 -15

333 lines not on this page · raw message

hw/ufs/ufs.h +54 -0

82 lines not on this page · raw message

Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
#2 lore raw

Re: [PATCH v2 1/2] hw/ufs: Add experimental fault injection properties for task abort testing

Quoted 59 lines

Add experimental properties x-hold-tag and x-hold-mode to ufs-pci and ufs-sysbus devices to facilitate end-to-end testing of host driver error handling, task aborts, and SCSI recovery routines.

When x-hold-tag is set to a specific tag (0..255), the controller holds the matching transfer request until a Task Management Request (TMR) targeting the held request is issued by the host driver. If x-hold-tag=0xfffffffe (UFS_HOLD_TAG_ANY), the controller intercepts the first READ_10/WRITE_10 request with LBA >= 512, avoiding guest boot-time metadata requests. The default value is 0xffffffff (UFS_HOLD_TAG_NONE), which disables fault injection.

The x-hold-mode property controls how the held request and subsequent recovery are resolved:
- "abort-success": TMR ABORT_TASK aborts the held request, clears its state, and returns SUCCESS (COMPL).
- "abort-failed": TMR ABORT_TASK returns TASK_MANAGEMENT_FUNC_FAILED.
- "in-transition": TMR QUERY_TASK / ABORT_TASK completes the held request successfully and returns COMPL (simulating a command completing in transition).
- "timeout": TMR ABORT_TASK does not complete, triggering TMR timeout.

Both properties support runtime modification via QOM (e.g., QMP qom-set), enabling continuous fault injection testing within a single running VM.

Together with the companion Linux kernel patch:
"[PATCH] scsi: ufs: core: Add fault injection for task abort failures"

these changes provide a deterministic testbed for automated CI/CD validation across driver error recovery and emulation layers.

Based-on: <[email protected]>

---
 hw/ufs/trace-events |   3 +
 hw/ufs/ufs-pci.c    |   4 +
 hw/ufs/ufs-sysbus.c |   4 +
 hw/ufs/ufs.c        | 289 +++++++++++++++++++++++++++++++++++++++++---
 hw/ufs/ufs.h        |  54 +++++++++
 5 files changed, 339 insertions(+), 15 deletions(-)
hw/ufs/trace-events +3 -0
index 5e5a54a3fb..a2c8f80811 100644
@@ -16,6 +16,9 @@ ufs_mcq_create_sq(uint8_t sqid, uint8_t cqid, uint64_t addr, uint16_t size) "mcq
 ufs_mcq_create_cq(uint8_t cqid, uint64_t addr, uint16_t size) "mcq create cq cqid %"PRIu8", addr 0x%"PRIx64", size %"PRIu16""
 ufs_write_mcq_op_reg(uint8_t qid, uint32_t offset, uint32_t data) "qid %"PRIu8", offset 0x%"PRIx32", data 0x%"PRIx32""
 ufs_process_tmr(uint8_t func, uint32_t tag, uint8_t resp) "query_func 0x%"PRIx8", task_tag %"PRIu32", tm_resp 0x%"PRIx8""
+ufs_inject_hold_req(uint8_t tag, uint32_t lba) "held command tag %"PRIu8", lba %"PRIu32""
+ufs_set_hold_tag(uint32_t tag) "hold-tag set to 0x%"PRIx32""
+ufs_set_hold_mode(const char *mode) "hold-mode set to %s"
 ufs_hce_reset(void) "HCE 1 -> 0 reset: cancelling BHs, resetting MCQ and request lists"
 
 # error condition
hw/ufs/ufs-pci.c +0 -0
index 8abd7d98e3..fe6c497dc2 100644

hw/ufs/ufs-pci.c static const Property ufs_pci_props[] = { · line 78

Quoted 7 lines
hw/ufs/ufs-pci.c +4 -0
@@ -72,6 +72,10 @@ static const Property ufs_pci_props[] = {
                        0x400),
     DEFINE_PROP_UINT32("wb-min-size", UfsPciState, ufs.params.wb_min_size,
                        0x100),
+    DEFINE_PROP_UNSIGNED("x-hold-tag", UfsPciState, ufs.params.x_hold_tag,
+                         UFS_HOLD_TAG_NONE, ufs_prop_hold_tag, uint32_t),
+    DEFINE_PROP("x-hold-mode", UfsPciState, ufs.params.x_hold_mode,
+                ufs_prop_hold_mode, char *),

Could we use names such as x-fault-inject-tag and x-fault-inject-mode, so their deliberate fault-injection purpose is clear?

Quoted 157 lines
hw/ufs/ufs-pci.c +0 -0
 };
 
 static const VMStateDescription ufs_pci_vmstate = {
hw/ufs/ufs-sysbus.c +4 -0
index 84de2e95ac..f0e4dfcd71 100644
@@ -45,6 +45,10 @@ static const Property ufs_sysbus_props[] = {
                        0x400),
     DEFINE_PROP_UINT32("wb-min-size", SysbusUfsState, ufs.params.wb_min_size,
                        0x100),
+    DEFINE_PROP_UNSIGNED("x-hold-tag", SysbusUfsState, ufs.params.x_hold_tag,
+                         UFS_HOLD_TAG_NONE, ufs_prop_hold_tag, uint32_t),
+    DEFINE_PROP("x-hold-mode", SysbusUfsState, ufs.params.x_hold_mode,
+                ufs_prop_hold_mode, char *),
 };
 
 static const VMStateDescription ufs_sysbus_vmstate = {
hw/ufs/ufs.c +92 -15
index ca5f6f2e96..3bdfe5762e 100644
@@ -15,6 +15,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "scsi/constants.h"
 #include "hw/core/irq.h"
 #include "trace.h"
@@ -816,6 +817,14 @@ static void ufs_hce_reset(UfsHc *u)
         memset(u->mcq_op_reg, 0, sizeof(u->mcq_op_reg));
     }
 
+    if (u->held_req) {
+        u->held_req = NULL;
+        u->active_hold_tag = UFS_HOLD_TAG_NONE;
+        u->params.x_hold_tag = UFS_HOLD_TAG_NONE;
+    } else {
+        u->active_hold_tag = u->params.x_hold_tag;
+    }
+
     u->resetting = false;
 
     /* 5. De-assert IRQ */
@@ -873,27 +882,95 @@ static void ufs_process_tmr(UfsHc *u, uint32_t val)
             task_tag = be32_to_cpu(desc.upiu_req.input_param2);
 
             if (tm_func == UFS_QUERY_TASK) {
-                UfsRequest *req = ufs_find_req_by_tag(u, task_tag);
-
-                if (req) {
-                    tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED;
+                if (u->held_req && task_tag == u->active_hold_tag) {
+                    if (u->hold_mode == UFS_HOLD_IN_TRANSITION) {
+                        UfsRequest *hreq = u->held_req;
+                        u->held_req = NULL;
+                        u->active_hold_tag = UFS_HOLD_TAG_NONE;
+                        u->params.x_hold_tag = UFS_HOLD_TAG_NONE;
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
+                        if (hreq) {
+                            uint16_t data_seg_len =
+                                sizeof(hreq->rsp_upiu.sr.sense_data_len);
+                            hreq->rsp_upiu.sr.sense_data_len = 0;
+                            hreq->rsp_upiu.sr.residual_transfer_count = 0;
+                            ufs_build_upiu_header(hreq,
+                                                  UFS_UPIU_TRANSACTION_RESPONSE,
+                                                  0,
+                                                  UFS_COMMAND_RESULT_SUCCESS,
+                                                  0,
+                                                  data_seg_len);
+                            ufs_complete_req(hreq, UFS_REQUEST_SUCCESS);
+                        }
+                    } else {
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED;
+                    }
                 } else {
-                    tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
+                    UfsRequest *req = ufs_find_req_by_tag(u, task_tag);
+
+                    if (req) {
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED;
+                    } else {
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
+                    }
                 }
             } else if (tm_func == UFS_ABORT_TASK) {
-                UfsRequest *req = ufs_find_req_by_tag(u, task_tag);
-
-                if (req) {
-                    ufs_clear_req(req);
-                    req->state = UFS_REQUEST_IDLE;
-                    if (ufs_mcq_req(req)) {
-                        QTAILQ_INSERT_TAIL(&req->sq->req_list, req, entry);
-                        qemu_bh_schedule(req->sq->bh);
+                if (u->held_req && task_tag == u->active_hold_tag) {
+                    if (u->hold_mode == UFS_HOLD_ABORT_FAILED) {
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_FAILED;
+                    } else if (u->hold_mode == UFS_HOLD_TIMEOUT) {
+                        continue;
+                    } else if (u->hold_mode == UFS_HOLD_IN_TRANSITION) {
+                        UfsRequest *hreq = u->held_req;
+                        u->held_req = NULL;
+                        u->active_hold_tag = UFS_HOLD_TAG_NONE;
+                        u->params.x_hold_tag = UFS_HOLD_TAG_NONE;
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
+                        if (hreq) {
+                            uint16_t data_seg_len =
+                                sizeof(hreq->rsp_upiu.sr.sense_data_len);
+                            hreq->rsp_upiu.sr.sense_data_len = 0;
+                            hreq->rsp_upiu.sr.residual_transfer_count = 0;
+                            ufs_build_upiu_header(hreq,
+                                                  UFS_UPIU_TRANSACTION_RESPONSE,
+                                                  0,
+                                                  UFS_COMMAND_RESULT_SUCCESS,
+                                                  0,
+                                                  data_seg_len);
+                            ufs_complete_req(hreq, UFS_REQUEST_SUCCESS);
+                        }
                     } else {
-                        u->reg.utrldbr &= ~(1 << req->slot);
+                        /* UFS_HOLD_ABORT_SUCCESS or default */
+                        UfsRequest *hreq = u->held_req;
+                        u->held_req = NULL;
+                        ufs_clear_req(hreq);
+                        hreq->state = UFS_REQUEST_IDLE;
+                        if (ufs_mcq_req(hreq)) {
+                            QTAILQ_INSERT_TAIL(&hreq->sq->req_list,
+                                               hreq, entry);
+                            qemu_bh_schedule(hreq->sq->bh);
+                        } else {
+                            u->reg.utrldbr &= ~(1 << hreq->slot);
+                        }
+                        u->active_hold_tag = UFS_HOLD_TAG_NONE;
+                        u->params.x_hold_tag = UFS_HOLD_TAG_NONE;
+                        tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
+                    }
+                } else {
+                    UfsRequest *req = ufs_find_req_by_tag(u, task_tag);
+
+                    if (req) {
+                        ufs_clear_req(req);
+                        req->state = UFS_REQUEST_IDLE;
+                        if (ufs_mcq_req(req)) {
+                            QTAILQ_INSERT_TAIL(&req->sq->req_list, req, entry);
+                            qemu_bh_schedule(req->sq->bh);
+                        } else {
+                            u->reg.utrldbr &= ~(1 << req->slot);
+                        }
                     }
+                    tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
                 }
-                tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_COMPL;
             } else {
                 tm_resp = UFS_UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED;
             }

hw/ufs/ufs.c static void ufs_exec_req(UfsRequest *req) · line 2407

Quoted 4 lines
hw/ufs/ufs.c +1 -0
@@ -2327,6 +2404,42 @@ static void ufs_exec_req(UfsRequest *req)
         return;
     }
 
+    if (unlikely(req->hc->active_hold_tag != UFS_HOLD_TAG_NONE)) {

Could we move this and the other fault-injection paths (TMR, reset, and property updates) behind ufs_fault_inject_*() helpers? This would keep test-only logic out of the normal UFS paths.

Quoted 63 lines
hw/ufs/ufs.c +56 -0
+        if (req->hc->active_hold_tag == UFS_HOLD_TAG_ANY) {
+            if (req->req_upiu.header.trans_type ==
+                UFS_UPIU_TRANSACTION_COMMAND) {
+                uint8_t op = req->req_upiu.sc.cdb[0];
+
+                if (op == READ_10 || op == WRITE_10) {
+                    /*
+                     * In 10-byte SCSI read/write commands (SBC-4), bytes 2..5
+                     * encode the 32-bit Logical Block Address (LBA) in
+                     * big-endian.
+                     */
+                    uint32_t lba = ldl_be_p(&req->req_upiu.sc.cdb[2]);
+
+                    /*
+                     * Only intercept target I/O targeting LBA >=
+                     * UFS_HOLD_MIN_LBA. Skips guest boot-time partition table
+                     * and superblock scanning.
+                     */
+                    if (lba >= UFS_HOLD_MIN_LBA) {
+                        req->hc->active_hold_tag =
+                            req->req_upiu.header.task_tag;
+                        req->hc->held_req = req;
+                        trace_ufs_inject_hold_req(req->req_upiu.header.task_tag,
+                                                  lba);
+                        return;
+                    }
+                }
+            }
+        } else if (req->req_upiu.header.task_tag == req->hc->active_hold_tag) {
+            req->hc->held_req = req;
+            trace_ufs_inject_hold_req(req->req_upiu.header.task_tag, 0);
+            return;
+        }
+    }
+
     switch (req->req_upiu.header.trans_type) {
     case UFS_UPIU_TRANSACTION_NOP_OUT:
         req_result = ufs_exec_nop_cmd(req);
@@ -2947,8 +3060,140 @@ static void ufs_init_hc(UfsHc *u)
 
     timer_init_ms(&u->idle_timer, QEMU_CLOCK_VIRTUAL_RT, ufs_idle_timer_cb, u);
     timer_mod(&u->idle_timer, now + UFS_IDLE_TIMER_TICK);
+
+    u->active_hold_tag = u->params.x_hold_tag;
+    u->held_req = NULL;
+}
+
+static void ufs_prop_get_hold_tag(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    Property *prop = opaque;
+    uint32_t *ptr = object_field_prop_ptr(obj, prop);
+    UfsParams *params = container_of(ptr, UfsParams, x_hold_tag);
+    UfsHc *u = container_of(params, UfsHc, params);
+
+    visit_type_uint32(v, name, &u->active_hold_tag, errp);
+}
+
+static void ufs_prop_set_hold_tag(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    Property *prop = opaque;
+    uint32_t *ptr = object_field_prop_ptr(obj, prop);

hw/ufs/ufs.c static void ufs_init_hc(UfsHc *u) · line 3093

Quoted 10 lines
hw/ufs/ufs.c +10 -0
+    uint32_t val;
+
+    if (!visit_type_uint32(v, name, &val, errp)) {
+        return;
+    }
+
+    *ptr = val;
+    UfsParams *params = container_of(ptr, UfsParams, x_hold_tag);
+    UfsHc *u = container_of(params, UfsHc, params);
+    u->active_hold_tag = val;

Since the tag can be changed at runtime via qom-set, active_hold_tag may be updated while held_req still points to the previous request. A later match would then silently overwrite held_req; is that intentional?

Signature · 1 line
Jeuk Kim <[email protected]>
#3 lore raw

PATCH v2 2/2 hw/ufs: Add ssu-timeout mode for power management recovery testing

In reply to Stanley Jhu

Extend the experimental fault injection property x-hold-mode with a new "ssu-timeout" mode to facilitate automated testing of host driver power management and Start Stop Unit (SSU) recovery handling.

When x-hold-mode="ssu-timeout" is set, the controller intercepts SCSI START_STOP (0x1B) commands sent to the Well-Known LUN (WLUN) and delays their completion without queuing them to the SCSI layer. This triggers the host driver's 10-second SSU command timeout and subsequent power management recovery routines (e.g., during suspend-to-idle or freeze transitions), verifying driver robustness and link restoration paths.

---
 hw/ufs/ufs.c | 21 +++++++++++++++++++--
 hw/ufs/ufs.h |  1 +
 2 files changed, 20 insertions(+), 2 deletions(-)
hw/ufs/ufs.c +19 -2
index 3bdfe5762e..43c4b4bdba 100644
@@ -2410,7 +2410,17 @@ static void ufs_exec_req(UfsRequest *req)
                 UFS_UPIU_TRANSACTION_COMMAND) {
                 uint8_t op = req->req_upiu.sc.cdb[0];
 
-                if (op == READ_10 || op == WRITE_10) {
+                if (req->hc->hold_mode == UFS_HOLD_SSU_TIMEOUT) {
+                    if (op == START_STOP &&
+                        req->req_upiu.header.lun == UFS_UPIU_UFS_DEVICE_WLUN) {
+                        req->hc->active_hold_tag =
+                            req->req_upiu.header.task_tag;
+                        req->hc->held_req = req;
+                        trace_ufs_inject_hold_req(req->req_upiu.header.task_tag,
+                                                  0);
+                        return;
+                    }
+                } else if (op == READ_10 || op == WRITE_10) {
                     /*
                      * In 10-byte SCSI read/write commands (SBC-4), bytes 2..5
                      * encode the 32-bit Logical Block Address (LBA) in
@@ -3129,6 +3139,9 @@ static void ufs_prop_get_hold_mode(Object *obj, Visitor *v, const char *name,
     case UFS_HOLD_TIMEOUT:
         str = "timeout";
         break;
+    case UFS_HOLD_SSU_TIMEOUT:
+        str = "ssu-timeout";
+        break;
     case UFS_HOLD_ABORT_SUCCESS:
     default:
         str = "abort-success";
@@ -3160,6 +3173,8 @@ static void ufs_prop_set_hold_mode(Object *obj, Visitor *v, const char *name,
         mode = UFS_HOLD_IN_TRANSITION;
     } else if (g_strcmp0(str, "timeout") == 0) {
         mode = UFS_HOLD_TIMEOUT;
+    } else if (g_strcmp0(str, "ssu-timeout") == 0) {
+        mode = UFS_HOLD_SSU_TIMEOUT;
     } else {
         error_setg(errp, "invalid x-hold-mode: %s", str);
         g_free(str);
@@ -3187,7 +3202,7 @@ static void ufs_prop_release_hold_mode(Object *obj, const char *name,
 const PropertyInfo ufs_prop_hold_mode = {
     .type = "str",
     .description = "Fault injection mode: abort-success, abort-failed, "
-                   "in-transition, timeout",
+                   "in-transition, timeout, ssu-timeout",
     .get = ufs_prop_get_hold_mode,
     .set = ufs_prop_set_hold_mode,
     .release = ufs_prop_release_hold_mode,
@@ -3212,6 +3227,8 @@ bool ufs_realize(UfsHc *u, DeviceState *dev, AddressSpace *dma_as, Error **errp)
         u->hold_mode = UFS_HOLD_IN_TRANSITION;
     } else if (g_strcmp0(u->params.x_hold_mode, "timeout") == 0) {
         u->hold_mode = UFS_HOLD_TIMEOUT;
+    } else if (g_strcmp0(u->params.x_hold_mode, "ssu-timeout") == 0) {
+        u->hold_mode = UFS_HOLD_SSU_TIMEOUT;
     } else {
         error_setg(errp, "invalid x-hold-mode: %s", u->params.x_hold_mode);
         return false;
hw/ufs/ufs.h +1 -0
index 6edeab9db9..8e7b79a8c9 100644
@@ -109,6 +109,7 @@ typedef enum UfsHoldMode {
     UFS_HOLD_ABORT_FAILED,
     UFS_HOLD_IN_TRANSITION,
     UFS_HOLD_TIMEOUT,
+    UFS_HOLD_SSU_TIMEOUT,
 } UfsHoldMode;
 
 /*
Signature · 1 line
2.55.0.1007.g17ff1f9808-goog