Skip to contentSkip to conversation

Allow setting up to 8 bytes with the generic loader

PATCH Applied Petr Tesarik 3 participants 4 messages Jan 20, 2022 – Jan 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow setting up to 8 bytes with the generic loader

The documentation for the generic loader says that "the maximum size of the data is 8 bytes". However, attempts to set data-len=8 trigger the following assertion failure:

../hw/core/generic-loader.c:59: generic_loader_reset: Assertion `s->data_len < sizeof(s->data)' failed.

The type of s->data is uint64_t (i.e. 8 bytes long), so I believe this assert should use <= instead of <.

Fixes e481a1f63c93 ("generic-loader: Add a generic loader")
---
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -1
index 9a24ffb880..504ed7ca72 100644
@@ -56,7 +56,7 @@ static void generic_loader_reset(void *opaque)
     }
 
     if (s->data_len) {
-        assert(s->data_len < sizeof(s->data));
+        assert(s->data_len <= sizeof(s->data));
         dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len,
                          MEMTXATTRS_UNSPECIFIED);
     }
Signature · 1 line
2.31.1
Reviewed-by Philippe Mathieu-Daudé on v1 1/1
#1 lore raw
Quoted 6 lines · Petr Tesarik

The documentation for the generic loader says that "the maximum size of the data is 8 bytes". However, attempts to set data-len=8 trigger the following assertion failure:

../hw/core/generic-loader.c:59: generic_loader_reset: Assertion `s->data_len < sizeof(s->data)' failed.

Quoted 8 lines

The type of s->data is uint64_t (i.e. 8 bytes long), so I believe this assert should use <= instead of <.

Fixes e481a1f63c93 ("generic-loader: Add a generic loader")
---
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Petr Tesarik
Quoted 5 lines · Petr Tesarik

The documentation for the generic loader says that "the maximum size of the data is 8 bytes". However, attempts to set data-len=8 trigger the following assertion failure:

Quoted 7 lines

../hw/core/generic-loader.c:59: generic_loader_reset: Assertion `s->data_len < sizeof(s->data)' failed.

The type of s->data is uint64_t (i.e. 8 bytes long), so I believe this assert should use <= instead of <.

Fixes e481a1f63c93 ("generic-loader: Add a generic loader")

Alistair

Quoted 21 lines
---
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -2
index 9a24ffb880..504ed7ca72 100644
@@ -56,7 +56,7 @@ static void generic_loader_reset(void *opaque)
     }
 
     if (s->data_len) {
-        assert(s->data_len < sizeof(s->data));
+        assert(s->data_len <= sizeof(s->data));
         dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len,
                          MEMTXATTRS_UNSPECIFIED);
     }
--

2.31.1

#3 lore raw
In reply to Petr Tesarik
Quoted 5 lines · Petr Tesarik

The documentation for the generic loader says that "the maximum size of the data is 8 bytes". However, attempts to set data-len=8 trigger the following assertion failure:

Quoted 7 lines

../hw/core/generic-loader.c:59: generic_loader_reset: Assertion `s->data_len < sizeof(s->data)' failed.

The type of s->data is uint64_t (i.e. 8 bytes long), so I believe this assert should use <= instead of <.

Fixes e481a1f63c93 ("generic-loader: Add a generic loader")

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 21 lines
---
 hw/core/generic-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -2
index 9a24ffb880..504ed7ca72 100644
@@ -56,7 +56,7 @@ static void generic_loader_reset(void *opaque)
     }
 
     if (s->data_len) {
-        assert(s->data_len < sizeof(s->data));
+        assert(s->data_len <= sizeof(s->data));
         dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len,
                          MEMTXATTRS_UNSPECIFIED);
     }
--

2.31.1