public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH v2] hw/ufs: Ensure DBC of PRDT uses only lower 18 bits
@ 2026-01-19  7:27 Jeuk Kim
  0 siblings, 0 replies; only message in thread
From: Jeuk Kim @ 2026-01-19  7:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: jeuk20.kim, qemu-block, j-young.choi, Jeuk Kim

From: Jeuk Kim <jeuk20.kim@gmail.com>

The UFS spec defines the PRDT data byte count as an 18-bit field. This
commit masks the value to the lower 18 bits to prevent incorrect
transfer lengths and ensure compliance.

Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>

---
v2
  - Fix PRDT DBC masking endianness
---
 hw/ufs/ufs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c
index cab42ae7b6..d3f08f2ba9 100644
--- a/hw/ufs/ufs.c
+++ b/hw/ufs/ufs.c
@@ -224,7 +224,8 @@ static MemTxResult ufs_dma_read_prdt(UfsRequest *req)
 
     for (uint16_t i = 0; i < prdt_len; ++i) {
         hwaddr data_dma_addr = le64_to_cpu(prd_entries[i].addr);
-        uint32_t data_byte_count = le32_to_cpu(prd_entries[i].size) + 1;
+        uint32_t data_byte_count =
+            (le32_to_cpu(prd_entries[i].size) & 0x3ffff) + 1;
         qemu_sglist_add(req->sg, data_dma_addr, data_byte_count);
         req->data_len += data_byte_count;
     }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-19  7:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19  7:27 [PATCH v2] hw/ufs: Ensure DBC of PRDT uses only lower 18 bits Jeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox