mm: clear MMU mapping for secure os memory [1/1]

PD#SWPL-1631

Problem:
If Cortex A73 accessed memory near secure memory range, an
SError may occur due to prefetch of A73 core.

Solution:
Remove mmu maping of secure memory range.
Note: must add clear-map and set clear range property in DTS

Verify:
W400

Change-Id: I718919c1b4873584eb87e00332622a1626672808
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
This commit is contained in:
tao zeng
2018-11-02 19:10:16 +08:00
committed by Jianxin Pan
parent e47f90d189
commit 93c6afa6bd
5 changed files with 18 additions and 0 deletions

View File

@@ -68,6 +68,7 @@
size = <0x0 0x400000>;
alignment = <0x0 0x400000>;
alloc-ranges = <0x0 0x05000000 0x0 0x400000>;
clear-map;
};
secos_reserved:linux,secos {

View File

@@ -68,6 +68,7 @@
size = <0x0 0x400000>;
alignment = <0x0 0x400000>;
alloc-ranges = <0x0 0x05000000 0x0 0x400000>;
clear-map;
};
secos_reserved:linux,secos {

View File

@@ -67,6 +67,7 @@
size = <0x0 0x400000>;
alignment = <0x0 0x400000>;
alloc-ranges = <0x0 0x05000000 0x0 0x400000>;
clear-map;
};
secos_reserved:linux,secos {

View File

@@ -249,6 +249,7 @@
in_base_func = <0x82000020>;
out_base_func = <0x82000021>;
reserve_mem_size = <0x00300000>;
clear_range = <0x05100000 0x200000>;
};
securitykey {

View File

@@ -26,6 +26,7 @@
#include <linux/platform_device.h>
#include <linux/dma-contiguous.h>
#include <asm/compiler.h>
#include <linux/cma.h>
#include <linux/arm-smccc.h>
#undef pr_fmt
#define pr_fmt(fmt) "secmon: " fmt
@@ -61,6 +62,7 @@ static int secmon_probe(struct platform_device *pdev)
int ret;
int mem_size;
struct page *page;
unsigned int clear[2] = {};
if (!of_property_read_u32(np, "in_base_func", &id))
phy_in_base = get_sharemem_info(id);
@@ -80,6 +82,11 @@ static int secmon_probe(struct platform_device *pdev)
return ret;
}
if (of_property_read_u32_array(np, "clear_range", clear, 2))
pr_info("can't fine clear_range\n");
else
pr_info("clear_range:%x %x\n", clear[0], clear[1]);
page = dma_alloc_from_contiguous(&pdev->dev, mem_size >> PAGE_SHIFT, 0);
if (!page) {
pr_err("alloc page failed, ret:%p\n", page);
@@ -97,6 +104,13 @@ static int secmon_probe(struct platform_device *pdev)
return -ENOMEM;
}
if (clear[0]) {
struct page *page = phys_to_page(clear[0]);
int cnt = clear[1] / PAGE_SIZE;
cma_mmu_op(page, cnt, 0);
}
if (pfn_valid(__phys_to_pfn(phy_out_base)))
sharemem_out_base = (void __iomem *)
__phys_to_virt(phy_out_base);