[PATCH v4 14/23] sandbox: Unmap old tags
Simon Glass
sjg at chromium.org
Mon Sep 2 00:26:25 CEST 2024
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 at chromium.org>
---
(no changes since v1)
arch/sandbox/cpu/cpu.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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)
--
2.34.1
More information about the U-Boot
mailing list