Skip to contentSkip to conversation

ufs queue

GIT PULL Jeuk Kim 1 participant 3 messages Jul 8, 2024

lore
Share & tools
lore

Jeuk Kim

author
#0 lore raw

From: Jeuk Kim <[email protected]>

The following changes since commit b9ee1387e0cf0fba5a73a610d31cb9cead457dc0:

Merge tag 'sdmmc-20240706' of https://github.com/philmd/qemu into staging (2024-07-07 10:34:52 -0700)

are available in the Git repository at:

https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240708

for you to fetch changes up to 6db492596dd9204e8fe341b2396472271cf15023:

hw/ufs: Fix mcq register range determination logic (2024-07-08 10:25:20 +0900)

----------------------------------------------------------------
hw/ufs:
- Fix invalid address access in ufs_is_mcq_reg()

----------------------------------------------------------------
Jeuk Kim (1):
hw/ufs: Fix mcq register range determination logic

 hw/ufs/ufs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
author
#1 lore raw

[PULL 1/1] hw/ufs: Fix mcq register range determination logic

From: Jeuk Kim <[email protected]>

The function ufs_is_mcq_reg() only evaluated the range of the mcq_op_reg offset, which is defined as a constant. Therefore, it was possible for ufs_is_mcq_reg() to return true despite ufs device is configured to not support the mcq. This could cause ufs_mmio_read()/ufs_mmio_write() to result in a segmentation fault due to accessing an invalid address. So fix it.

Fixes 5c079578d2e4 ("hw/ufs: Add support MCQ of UFSHCI 4.0")

Message-Id: <6dcb63036f3b35c833de752d1472d08bf4a9c289.1719996804.git.jeuk20.kim@samsung.com>

---
 hw/ufs/ufs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
hw/ufs/ufs.c +7 -1
index 683fff5840..cf0edd281c 100644
@@ -57,7 +57,13 @@ static inline uint64_t ufs_reg_size(UfsHc *u)
 
 static inline bool ufs_is_mcq_reg(UfsHc *u, uint64_t addr, unsigned size)
 {
-    uint64_t mcq_reg_addr = ufs_mcq_reg_addr(u, 0);
+    uint64_t mcq_reg_addr;
+
+    if (!u->params.mcq) {
+        return false;
+    }
+
+    mcq_reg_addr = ufs_mcq_reg_addr(u, 0);
     return (addr >= mcq_reg_addr &&
             addr + size <= mcq_reg_addr + sizeof(u->mcq_reg));
 }
Signature · 1 line
2.34.1
author
#2 lore raw
In reply to Jeuk Kim

I'm so sorry. I forgot to add something to the patch, I'll add it and resend it to you. Sorry again.

Quoted 24 lines · Jeuk Kim

From: Jeuk Kim <[email protected]>

The following changes since commit b9ee1387e0cf0fba5a73a610d31cb9cead457dc0:

   Merge tag 'sdmmc-20240706' of https://github.com/philmd/qemu into staging (2024-07-07 10:34:52 -0700)

are available in the Git repository at:

   https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240708

for you to fetch changes up to 6db492596dd9204e8fe341b2396472271cf15023:

hw/ufs: Fix mcq register range determination logic (2024-07-08 10:25:20 +0900)

----------------------------------------------------------------
hw/ufs:
- Fix invalid address access in ufs_is_mcq_reg()

----------------------------------------------------------------
Jeuk Kim (1):
hw/ufs: Fix mcq register range determination logic

  hw/ufs/ufs.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)