sandbox: Unmap old tags
So far unmapping has not been implemented. This means that if one test maps a pointer to an address with map_sysmem(), then a second test can use that same pointer, by mapping the address back to a pointer with map_to_sysmem(). This is not really desirable, even if it doesn't cause any problems at the moment. Implement unmapping, to clean this up. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -185,12 +185,28 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
|
||||
|
||||
void unmap_physmem(const void *ptr, unsigned long flags)
|
||||
{
|
||||
struct sandbox_mapmem_entry *mentry;
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (map_dev) {
|
||||
pci_unmap_physmem(ptr, map_len, map_dev);
|
||||
map_dev = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If it is in emulated RAM, we didn't create a tag, so nothing to do */
|
||||
if (is_in_sandbox_mem(ptr))
|
||||
return;
|
||||
|
||||
mentry = find_tag(ptr);
|
||||
if (mentry) {
|
||||
list_del(&mentry->sibling_node);
|
||||
log_debug("Removed map from %p to %lx\n", ptr,
|
||||
(ulong)mentry->tag);
|
||||
free(mentry);
|
||||
} else {
|
||||
log_warning("Address not mapped: %p\n", ptr);
|
||||
}
|
||||
}
|
||||
|
||||
phys_addr_t map_to_sysmem(const void *ptr)
|
||||
|
Reference in New Issue
Block a user