summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/armv8/cache_v8.c26
-rw-r--r--arch/arm/include/asm/armv8/mmu.h9
2 files changed, 35 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 9b3c37dae82..672ec16d483 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -86,6 +86,32 @@ int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs)
return 0;
}
+
+int mmu_unmap_reserved_mem(const char *name, bool check_nomap)
+{
+ void *fdt = (void *)gd->fdt_blob;
+ char node_path[128];
+ fdt_addr_t addr;
+ fdt_size_t size;
+ int ret;
+
+ snprintf(node_path, sizeof(node_path), "/reserved-memory/%s", name);
+ ret = fdt_path_offset(fdt, node_path);
+ if (ret < 0)
+ return ret;
+
+ if (check_nomap && !fdtdec_get_bool(fdt, ret, "no-map"))
+ return -EINVAL;
+
+ addr = fdtdec_get_addr_size(fdt, ret, "reg", &size);
+ if (addr == FDT_ADDR_T_NONE)
+ return -1;
+
+ mmu_change_region_attr_nobreak(addr, size, PTE_TYPE_FAULT);
+
+ return 0;
+}
+
u64 get_tcr(u64 *pips, u64 *pva_bits)
{
int el = get_effective_el();
diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
index 6e7a3366844..8aa5f9721c4 100644
--- a/arch/arm/include/asm/armv8/mmu.h
+++ b/arch/arm/include/asm/armv8/mmu.h
@@ -207,6 +207,15 @@ void setup_pgtables(void);
*/
int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs);
+/**
+ * mmu_unmap_reserved_mem() - Unmaps a reserved-memory node as PTE_TYPE_FAULT
+ * once MMU is configured by mmu_setup.
+ *
+ * @name: The name of the node under "/reserved-memory/" path
+ * @check_nomap: Check if the node is marked "no-map" before unmapping it
+ */
+int mmu_unmap_reserved_mem(const char *name, bool check_nomap);
+
u64 get_tcr(u64 *pips, u64 *pva_bits);
/**