diff options
Diffstat (limited to 'common/memory.c')
-rw-r--r-- | common/memory.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/memory.c b/common/memory.c index 0ae9e7383c..d560d444b0 100644 --- a/common/memory.c +++ b/common/memory.c @@ -15,6 +15,7 @@ #include <asm/sections.h> #include <malloc.h> #include <of.h> +#include <mmu.h> /* * Begin and End of memory area for malloc(), and current "brk" @@ -211,6 +212,31 @@ struct resource *__request_sdram_region(const char *name, unsigned flags, return NULL; } +/* use for secure firmware to inhibit speculation */ +struct resource *reserve_sdram_region(const char *name, resource_size_t start, + resource_size_t size) +{ + struct resource *res; + + res = __request_sdram_region(name, IORESOURCE_BUSY, start, size); + if (IS_ERR(res)) + return ERR_CAST(res); + + if (!IS_ALIGNED(start, PAGE_SIZE)) { + pr_err("%s: %s start is not page aligned\n", __func__, name); + start = ALIGN_DOWN(start, PAGE_SIZE); + } + + if (!IS_ALIGNED(size, PAGE_SIZE)) { + pr_err("%s: %s size is not page aligned\n", __func__, name); + size = ALIGN(size, PAGE_SIZE); + } + + remap_range((void *)start, size, MAP_UNCACHED); + + return res; +} + int release_sdram_region(struct resource *res) { return release_region(res); |