Skip to content

Commit a03d7d6

Browse files
alex-pentagridMichael Tokarev
authored andcommitted
xen: mapcache: Fix finding matching entry
If we have request without lock and hit unlocked or invalid entry during the search, we remap it immediately, even if we have matching entry in next entries in bucket. This leads to duplication of mappings of the same size, and to possibility of selecting the wrong element during invalidation and underflow it's entry->lock counter Signed-off-by: Aleksandr Partanen <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Reviewed-by: Edgar E. Iglesias <[email protected]> Signed-off-by: Edgar E. Iglesias <[email protected]> (cherry picked from commit a4b20f7) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 827be9d commit a03d7d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hw/xen/xen-mapcache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ static uint8_t *xen_map_cache_unlocked(MapCache *mc,
376376

377377
entry = &mc->entry[address_index % mc->nr_buckets];
378378

379-
while (entry && (lock || entry->lock) && entry->vaddr_base &&
380-
(entry->paddr_index != address_index || entry->size != cache_size ||
379+
while (entry && (!entry->vaddr_base ||
380+
entry->paddr_index != address_index || entry->size != cache_size ||
381381
!test_bits(address_offset >> XC_PAGE_SHIFT,
382382
test_bit_size >> XC_PAGE_SHIFT,
383383
entry->valid_mapping))) {
384-
if (!free_entry && !entry->lock) {
384+
if (!free_entry && (!entry->lock || !entry->vaddr_base)) {
385385
free_entry = entry;
386386
free_pentry = pentry;
387387
}

0 commit comments

Comments
 (0)