]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
armv8: mmu: Add support of non-identical mapping
authorYork Sun <york.sun@nxp.com>
Fri, 24 Jun 2016 23:46:22 +0000 (16:46 -0700)
committerYork Sun <york.sun@nxp.com>
Fri, 15 Jul 2016 16:01:43 +0000 (09:01 -0700)
Introduce virtual and physical addresses in the mapping table. This change
have no impact on existing boards because they all use idential mapping.

Signed-off-by: York Sun <york.sun@nxp.com>
14 files changed:
arch/arm/cpu/armv8/cache_v8.c
arch/arm/cpu/armv8/s32v234/cpu.c
arch/arm/cpu/armv8/zynqmp/cpu.c
arch/arm/include/asm/armv8/mmu.h
arch/arm/mach-exynos/mmu-arm64.c
arch/arm/mach-meson/board.c
arch/arm/mach-snapdragon/sysmap-apq8016.c
arch/arm/mach-sunxi/board.c
arch/arm/mach-tegra/arm64-mmu.c
arch/arm/mach-uniphier/arm64/mem_map.c
board/armltd/vexpress64/vexpress64.c
board/cavium/thunderx/thunderx.c
board/hisilicon/hikey/hikey.c
board/raspberrypi/rpi/rpi.c

index 8604035e148c40637c235821abc001bd7ba6963a..ac909a15ffaa6974c2c633a2e73bd00a62c6d41d 100644 (file)
@@ -44,7 +44,7 @@ u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
 
        /* Find the largest address we need to support */
        for (i = 0; mem_map[i].size || mem_map[i].attrs; i++)
-               max_addr = max(max_addr, mem_map[i].base + mem_map[i].size);
+               max_addr = max(max_addr, mem_map[i].virt + mem_map[i].size);
 
        /* Calculate the maximum physical (and thus virtual) address */
        if (max_addr > (1ULL << 44)) {
@@ -202,7 +202,8 @@ static void split_block(u64 *pte, int level)
 static void add_map(struct mm_region *map)
 {
        u64 *pte;
-       u64 addr = map->base;
+       u64 virt = map->virt;
+       u64 phys = map->phys;
        u64 size = map->size;
        u64 attrs = map->attrs | PTE_TYPE_BLOCK | PTE_BLOCK_AF;
        u64 blocksize;
@@ -210,37 +211,39 @@ static void add_map(struct mm_region *map)
        u64 *new_table;
 
        while (size) {
-               pte = find_pte(addr, 0);
+               pte = find_pte(virt, 0);
                if (pte && (pte_type(pte) == PTE_TYPE_FAULT)) {
-                       debug("Creating table for addr 0x%llx\n", addr);
+                       debug("Creating table for virt 0x%llx\n", virt);
                        new_table = create_table();
                        set_pte_table(pte, new_table);
                }
 
                for (level = 1; level < 4; level++) {
-                       pte = find_pte(addr, level);
+                       pte = find_pte(virt, level);
                        if (!pte)
                                panic("pte not found\n");
+
                        blocksize = 1ULL << level2shift(level);
-                       debug("Checking if pte fits for addr=%llx size=%llx "
-                             "blocksize=%llx\n", addr, size, blocksize);
-                       if (size >= blocksize && !(addr & (blocksize - 1))) {
+                       debug("Checking if pte fits for virt=%llx size=%llx blocksize=%llx\n",
+                             virt, size, blocksize);
+                       if (size >= blocksize && !(virt & (blocksize - 1))) {
                                /* Page fits, create block PTE */
-                               debug("Setting PTE %p to block addr=%llx\n",
-                                     pte, addr);
-                               *pte = addr | attrs;
-                               addr += blocksize;
+                               debug("Setting PTE %p to block virt=%llx\n",
+                                     pte, virt);
+                               *pte = phys | attrs;
+                               virt += blocksize;
+                               phys += blocksize;
                                size -= blocksize;
                                break;
                        } else if (pte_type(pte) == PTE_TYPE_FAULT) {
                                /* Page doesn't fit, create subpages */
-                               debug("Creating subtable for addr 0x%llx "
-                                     "blksize=%llx\n", addr, blocksize);
+                               debug("Creating subtable for virt 0x%llx blksize=%llx\n",
+                                     virt, blocksize);
                                new_table = create_table();
                                set_pte_table(pte, new_table);
                        } else if (pte_type(pte) == PTE_TYPE_BLOCK) {
-                               debug("Split block into subtable for addr 0x%llx blksize=0x%llx\n",
-                                     addr, blocksize);
+                               debug("Split block into subtable for virt 0x%llx blksize=0x%llx\n",
+                                     virt, blocksize);
                                split_block(pte, level);
                        }
                }
@@ -271,7 +274,7 @@ static int count_required_pts(u64 addr, int level, u64 maxaddr)
 
        for (i = 0; mem_map[i].size || mem_map[i].attrs; i++) {
                struct mm_region *map = &mem_map[i];
-               u64 start = map->base;
+               u64 start = map->virt;
                u64 end = start + map->size;
 
                /* Check if the PTE would overlap with the map */
index dac12a2552fbe132fef39d9a5724c9131d8e1eb1..5c97e0eee43469748daea37d16d49a30e2af08ed 100644 (file)
@@ -32,24 +32,28 @@ u32 cpu_mask(void)
 
 static struct mm_region s32v234_mem_map[] = {
        {
-               .base = S32V234_IRAM_BASE,
+               .virt = S32V234_IRAM_BASE,
+               .phys = S32V234_IRAM_BASE,
                .size = S32V234_IRAM_SIZE,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_OUTER_SHARE
        }, {
-               .base = S32V234_DRAM_BASE1,
+               .virt = S32V234_DRAM_BASE1,
+               .phys = S32V234_DRAM_BASE1,
                .size = S32V234_DRAM_SIZE1,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_OUTER_SHARE
        }, {
-               .base = S32V234_PERIPH_BASE,
+               .virt = S32V234_PERIPH_BASE,
+               .phys = S32V234_PERIPH_BASE,
                .size = S32V234_PERIPH_SIZE,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE
                         /* TODO: Do we need these? */
                         /* | PTE_BLOCK_PXN | PTE_BLOCK_UXN */
        }, {
-               .base = S32V234_DRAM_BASE2,
+               .virt = S32V234_DRAM_BASE2,
+               .phys = S32V234_DRAM_BASE2,
                .size = S32V234_DRAM_SIZE2,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
                         PTE_BLOCK_OUTER_SHARE
index 509f0aa387a645a42d68e70cebaf931548a52f5d..b0f12955a1ffac03ec37f3ccf87ac52d687fee51 100644 (file)
@@ -18,40 +18,47 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct mm_region zynqmp_mem_map[] = {
        {
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0x80000000UL,
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
                .size = 0x70000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0xf8000000UL,
+               .virt = 0xf8000000UL,
+               .phys = 0xf8000000UL,
                .size = 0x07e00000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0xffe00000UL,
+               .virt = 0xffe00000UL,
+               .phys = 0xffe00000UL,
                .size = 0x00200000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0x400000000UL,
+               .virt = 0x400000000UL,
+               .phys = 0x400000000UL,
                .size = 0x200000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0x600000000UL,
+               .virt = 0x600000000UL,
+               .phys = 0x600000000UL,
                .size = 0x800000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0xe00000000UL,
+               .virt = 0xe00000000UL,
+               .phys = 0xe00000000UL,
                .size = 0xf200000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
index b7b47068a3ec77f8d39189b7627f212e66108827..aa0f3c42f63211a4ff906fc51111fe6529a0f577 100644 (file)
@@ -135,7 +135,8 @@ static inline void set_ttbr_tcr_mair(int el, u64 table, u64 tcr, u64 attr)
 }
 
 struct mm_region {
-       u64 base;
+       u64 virt;
+       u64 phys;
        u64 size;
        u64 attrs;
 };
index ba6d99d329d515e855d0c7084350e41add1e42a5..23814222d82d3e2ec4c9e317c555c87998eb98d3 100644 (file)
@@ -13,21 +13,20 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_EXYNOS7420
 static struct mm_region exynos7420_mem_map[] = {
        {
-               .base   = 0x10000000UL,
+               .virt   = 0x10000000UL,
+               .phys   = 0x10000000UL,
                .size   = 0x10000000UL,
                .attrs  = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                                PTE_BLOCK_NON_SHARE |
                                PTE_BLOCK_PXN | PTE_BLOCK_UXN,
        }, {
-               .base   = 0x40000000UL,
+               .virt   = 0x40000000UL,
+               .phys   = 0x40000000UL,
                .size   = 0x80000000UL,
                .attrs  = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                                PTE_BLOCK_INNER_SHARE,
        }, {
                /* List terminator */
-               .base   = 0,
-               .size   = 0,
-               .attrs  = 0,
        },
 };
 
index 64fa3c191ee79b8f95325fd23a20a07d740e267c..1dd53e2313f31b278e52f814f492914758b3def1 100644 (file)
@@ -48,12 +48,14 @@ void reset_cpu(ulong addr)
 
 static struct mm_region gxbb_mem_map[] = {
        {
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0x80000000UL,
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
index ef0db2ab5f42dad002a87728158fc4666a214b9e..580b9c7e6159a7e4f7aa07d893454c22b54835ec 100644 (file)
 
 static struct mm_region apq8016_mem_map[] = {
        {
-               .base = 0x0UL, /* Peripheral block */
+               .virt = 0x0UL, /* Peripheral block */
+               .phys = 0x0UL, /* Peripheral block */
                .size = 0x8000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0x80000000UL, /* DDR */
+               .virt = 0x80000000UL, /* DDR */
+               .phys = 0x80000000UL, /* DDR */
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
index 66e028ec1467d657a1c408f6bd80b9b8dd50cc45..01bfc93cbb8fb95ac099b4ffee711e675dc7b679 100644 (file)
@@ -46,13 +46,15 @@ struct fel_stash fel_stash __attribute__((section(".data")));
 static struct mm_region sunxi_mem_map[] = {
        {
                /* SRAM, MMIO regions */
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x40000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE
        }, {
                /* RAM */
-               .base = 0x40000000UL,
+               .virt = 0x40000000UL,
+               .phys = 0x40000000UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
index 501c4f00c4e03ef9d536eff2e1c1ac0646e2dff6..7b1d258ed84f5f6cedb051107a9811d5111d8a42 100644 (file)
 
 static struct mm_region tegra_mem_map[] = {
        {
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0x80000000UL,
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
                .size = 0xff80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
index 74ef91984ca86eb3b4885ce142853382c89b794e..67bc4f1209b6670b20f34a3f85e2e264aae92d42 100644 (file)
 
 static struct mm_region uniphier_mem_map[] = {
        {
-               .base = 0x00000000,
+               .virt = 0x00000000,
+               .phys = 0x00000000,
                .size = 0x80000000,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        },
        {
-               .base = 0x80000000,
+               .virt = 0x80000000,
+               .phys = 0x80000000,
                .size = 0xc0000000,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
index 973b57969f8f418f6d02a5e41fad08527d1a515f..e34af6c4d932edb93a4db7cc440e74b0edce9abc 100644 (file)
@@ -31,13 +31,15 @@ U_BOOT_DEVICE(vexpress_serials) = {
 
 static struct mm_region vexpress64_mem_map[] = {
        {
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
        }, {
-               .base = 0x80000000UL,
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
                .size = 0xff80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
index 9131a385fd07965d0619740a3f5cf225229482c2..960ca53b021eaf4e7c5490a5f518aca6f843c33f 100644 (file)
@@ -45,16 +45,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct mm_region thunderx_mem_map[] = {
        {
-               .base = 0x000000000000UL,
+               .virt = 0x000000000000UL,
+               .phys = 0x000000000000UL,
                .size = 0x40000000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_NON_SHARE,
        }, {
-               .base = 0x800000000000UL,
+               .virt = 0x800000000000UL,
+               .phys = 0x800000000000UL,
                .size = 0x40000000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE,
        }, {
-               .base = 0x840000000000UL,
+               .virt = 0x840000000000UL,
+               .phys = 0x840000000000UL,
                .size = 0x40000000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE,
index 7abc67874ab0c8e7773ed2eca41ba149c7c4d538..72d6334b5f69c0f17166b4a2ad0a12c811bfd039 100644 (file)
@@ -93,12 +93,14 @@ U_BOOT_DEVICE(hikey_seriala) = {
 
 static struct mm_region hikey_mem_map[] = {
        {
-               .base = 0x0UL,
+               .virt = 0x0UL,
+               .phys = 0x0UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0x80000000UL,
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
                .size = 0x80000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
index c45ddb14aa336c0771ae7f9f70e05f8b8ae422a8..fbfbf6cbbc64282c222a7047ed3c5e609f70b4c3 100644 (file)
@@ -234,12 +234,14 @@ static const struct rpi_model *model;
 #ifdef CONFIG_ARM64
 static struct mm_region bcm2837_mem_map[] = {
        {
-               .base = 0x00000000UL,
+               .virt = 0x00000000UL,
+               .phys = 0x00000000UL,
                .size = 0x3f000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
                         PTE_BLOCK_INNER_SHARE
        }, {
-               .base = 0x3f000000UL,
+               .virt = 0x3f000000UL,
+               .phys = 0x3f000000UL,
                .size = 0x01000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |