Skip to contentSkip to conversation

memory: Correct access mask generation in access_with_adjusted_size

PATCH New Francisco Iglesias 1 participant 1 message Aug 12, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: Correct access mask generation in access_with_adjusted_size

Also consider the requested transaction size when generating the access mask (so that only the requested bytes are returned when those are less than the memory region's minimum access size).

---
 memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
memory.c +1 -1
index 5d8c9a9234..56a2510836 100644
@@ -563,7 +563,7 @@ static MemTxResult access_with_adjusted_size(hwaddr addr,
 
     /* FIXME: support unaligned access? */
     access_size = MAX(MIN(size, access_size_max), access_size_min);
-    access_mask = MAKE_64BIT_MASK(0, access_size * 8);
+    access_mask = MAKE_64BIT_MASK(0, MIN(size, access_size) * 8);
     if (memory_region_big_endian(mr)) {
         for (i = 0; i < size; i += access_size) {
             r |= access_fn(mr, addr + i, value, access_size,
Signature · 1 line
2.11.0