tegra132: move page tables to trustzone region

In order to access secure device register space the cpu
needs to have the page tables marked as secure memory. In
addition the page tables need to live within secure memory
otherwise the accesses default to non-secure.

Therefore move the page tables to the trustzone region. Remove
the TTB_* config options as well as removing the TTB reservations
from coreboot's resource list.

BUG=chrome-os-partner:31355
BUG=chrome-os-partner:31356
BRANCH=None
CQ-DEPEND=CL:213140
TEST=Built and booted into kernel.

Change-Id: I1fc8dda932c36935f8523792bc1147f6b0743d11
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 1522a83bb57e33749843d5b3ea5545ded97a3953
Original-Change-Id: Ia4b9d07ef35500726ec5b289e059208b9f46d025
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/213141
Reviewed-on: http://review.coreboot.org/8994
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Aaron Durbin 2014-08-19 11:17:56 -05:00 committed by Patrick Georgi
parent dbe7085be6
commit 9edf38ef1f
3 changed files with 16 additions and 17 deletions

View File

@ -77,14 +77,6 @@ config RAMSTAGE_STACK_BOTTOM
hex hex
default 0x8001c000 default 0x8001c000
config TTB_BUFFER
hex
default 0x80020000
config TTB_SIZE
hex
default 0x110000
config CBFS_CACHE_ADDRESS config CBFS_CACHE_ADDRESS
hex "memory address to put CBFS cache data" hex "memory address to put CBFS cache data"
default 0x40006000 default 0x40006000

View File

@ -47,8 +47,11 @@ static void print_memranges(struct memranges *mmap_ranges)
static void tegra132_memrange_init(struct memranges *map) static void tegra132_memrange_init(struct memranges *map)
{ {
uint64_t start,end; uint64_t start,end;
const unsigned long devmem = MA_DEV | MA_NS | MA_RW; const unsigned long devmem = MA_DEV | MA_S | MA_RW;
const unsigned long cachedmem = MA_MEM | MA_NS | MA_RW; const unsigned long cachedmem = MA_MEM | MA_NS | MA_RW;
const unsigned long secure_mem = MA_MEM | MA_S | MA_RW;
uintptr_t tz_base_mib;
size_t tz_size_mib;
memranges_init_empty(map); memranges_init_empty(map);
@ -66,6 +69,10 @@ static void tegra132_memrange_init(struct memranges *map)
/* SRAM */ /* SRAM */
memranges_insert(map, TEGRA_SRAM_BASE, TEGRA_SRAM_SIZE, cachedmem); memranges_insert(map, TEGRA_SRAM_BASE, TEGRA_SRAM_SIZE, cachedmem);
/* Add TZ carveout. */
carveout_range(CARVEOUT_TZ, &tz_base_mib, &tz_size_mib);
memranges_insert(map, tz_base_mib * MiB, tz_size_mib * MiB, secure_mem);
} }
void __attribute__((weak)) mainboard_add_memory_ranges(struct memranges *map) void __attribute__((weak)) mainboard_add_memory_ranges(struct memranges *map)
@ -75,13 +82,17 @@ void __attribute__((weak)) mainboard_add_memory_ranges(struct memranges *map)
void tegra132_mmu_init(void) void tegra132_mmu_init(void)
{ {
uint64_t *ttb_buffer = (uint64_t*)CONFIG_TTB_BUFFER; uintptr_t tz_base_mib;
uint64_t ttb_size = (uint64_t)CONFIG_TTB_SIZE; size_t tz_size_mib;
struct memranges *map = &t132_mmap_ranges; struct memranges *map = &t132_mmap_ranges;
tegra132_memrange_init(map); tegra132_memrange_init(map);
mainboard_add_memory_ranges(map); mainboard_add_memory_ranges(map);
print_memranges(map); print_memranges(map);
mmu_init(map,ttb_buffer,ttb_size); /* Place page tables at the base of the trust zone region. */
mmu_enable((uint64_t)ttb_buffer); carveout_range(CARVEOUT_TZ, &tz_base_mib, &tz_size_mib);
tz_base_mib *= MiB;
tz_size_mib *= MiB;
mmu_init(map, (void *)tz_base_mib, tz_size_mib);
mmu_enable(tz_base_mib);
} }

View File

@ -40,10 +40,6 @@ static void soc_read_resources(device_t dev)
reserved_ram_resource(dev, index++, begin * KiB, size * KiB); reserved_ram_resource(dev, index++, begin * KiB, size * KiB);
} }
reserved_ram_resource(dev, index++, CONFIG_TTB_BUFFER / KiB,
CONFIG_TTB_SIZE / KiB);
/* /*
* TODO: Frame buffer needs to handled as a carveout from the below_4G * TODO: Frame buffer needs to handled as a carveout from the below_4G
* uintptr_t framebuffer_begin = framebuffer_attributes(&framebuffer_size); * uintptr_t framebuffer_begin = framebuffer_attributes(&framebuffer_size);