summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-09-01 16:26:25 -0600
committerTom Rini <trini@konsulko.com>2024-09-18 13:01:00 -0600
commite82baf0801f399266781303675b0f66cca2bc51f (patch)
tree90c218d7dc4be72a4d4146f0c1c14a0aef0c2193
parent58f26a17b41ff146e4e9f5564a9da6571585d1a7 (diff)
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>
-rw-r--r--arch/sandbox/cpu/cpu.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 8eb055d6837..3e1c0dd583e 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -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)