Frediano Ziglio
2012-Aug-07 12:23 UTC
Fix invalidate if memory requested was not bucket aligned
When memory is mapped in qemu_map_cache with lock != 0 a reverse mapping is created pointing to the virtual address of location requested. The cached mapped entry is saved in last_address_vaddr with the memory location of the base virtual address (without bucket offset). However when this entry is invalidated the virtual address saved in the reverse mapping is used. This cause that the mapping is freed but the last_address_vaddr is not reset. Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> --- xen-mapcache.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen-mapcache.c b/xen-mapcache.c index 59ba085..9cd6db3 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -320,10 +320,6 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer) target_phys_addr_t size; int found = 0; - if (mapcache->last_address_vaddr == buffer) { - mapcache->last_address_index = -1; - } - QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { if (reventry->vaddr_req == buffer) { paddr_index = reventry->paddr_index; @@ -342,6 +338,11 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer) QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next); g_free(reventry); + if (mapcache->last_address_index == paddr_index) { + mapcache->last_address_index = -1; + mapcache->last_address_vaddr = NULL; + } + entry = &mapcache->entry[paddr_index % mapcache->nr_buckets]; while (entry && (entry->paddr_index != paddr_index || entry->size != size)) { pentry = entry; -- 1.7.5.4
Stefano Stabellini
2012-Aug-07 12:38 UTC
Re: Fix invalidate if memory requested was not bucket aligned
On Tue, 7 Aug 2012, Frediano Ziglio wrote:> When memory is mapped in qemu_map_cache with lock != 0 a reverse mapping > is created pointing to the virtual address of location requested. > The cached mapped entry is saved in last_address_vaddr with the memory > location of the base virtual address (without bucket offset). > However when this entry is invalidated the virtual address saved in the > reverse mapping is used. This cause that the mapping is freed but the > last_address_vaddr is not reset. > > Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> I''ll add it to my queue.> xen-mapcache.c | 9 +++++---- > 1 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/xen-mapcache.c b/xen-mapcache.c > index 59ba085..9cd6db3 100644 > --- a/xen-mapcache.c > +++ b/xen-mapcache.c > @@ -320,10 +320,6 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer) > target_phys_addr_t size; > int found = 0; > > - if (mapcache->last_address_vaddr == buffer) { > - mapcache->last_address_index = -1; > - } > - > QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { > if (reventry->vaddr_req == buffer) { > paddr_index = reventry->paddr_index; > @@ -342,6 +338,11 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer) > QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next); > g_free(reventry); > > + if (mapcache->last_address_index == paddr_index) { > + mapcache->last_address_index = -1; > + mapcache->last_address_vaddr = NULL; > + } > + > entry = &mapcache->entry[paddr_index % mapcache->nr_buckets]; > while (entry && (entry->paddr_index != paddr_index || entry->size != size)) { > pentry = entry; > -- > 1.7.5.4 > >