From 0f712aa80841eb5c1a86dfabc548fdb240392b5d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 19 Oct 2010 16:12:33 -0700 Subject: [PATCH] [ARM] tegra: Add function to enable protected aperture Change-Id: I699cee3bc9a131259b330655126146f5d1f92043 Signed-off-by: Colin Cross --- arch/arm/mach-tegra/board.h | 2 ++ arch/arm/mach-tegra/common.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h index 120b452bcda9..086ec70c470d 100644 --- a/arch/arm/mach-tegra/board.h +++ b/arch/arm/mach-tegra/board.h @@ -29,6 +29,7 @@ void __init tegra_init_irq(void); void __init tegra_init_clock(void); void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size, unsigned long fb2_size); +void __init tegra_protected_aperture_init(unsigned long aperture); extern unsigned long tegra_bootloader_fb_start; extern unsigned long tegra_bootloader_fb_size; @@ -40,6 +41,7 @@ extern unsigned long tegra_carveout_start; extern unsigned long tegra_carveout_size; extern unsigned long tegra_lp0_vec_start; extern unsigned long tegra_lp0_vec_size; +extern unsigned long tegra_grhost_aperture; extern struct sys_timer tegra_timer; #endif diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c index d212e78a0360..28b1e9ae7396 100644 --- a/arch/arm/mach-tegra/common.c +++ b/arch/arm/mach-tegra/common.c @@ -34,6 +34,8 @@ #include "clock.h" #include "fuse.h" +#define MC_SECURITY_CFG2 0x7c + unsigned long tegra_bootloader_fb_start; unsigned long tegra_bootloader_fb_size; unsigned long tegra_fb_start; @@ -44,6 +46,7 @@ unsigned long tegra_carveout_start; unsigned long tegra_carveout_size; unsigned long tegra_lp0_vec_start; unsigned long tegra_lp0_vec_size; +unsigned long tegra_grhost_aperture; void (*tegra_reset)(char mode, const char *cmd); @@ -124,6 +127,23 @@ static int __init tegra_lp0_vec_arg(char *options) } early_param("lp0_vec", tegra_lp0_vec_arg); +/* + * Tegra has a protected aperture that prevents access by most non-CPU + * memory masters to addresses above the aperture value. Enabling it + * secures the CPU's memory from the GPU, except through the GART. + */ +void __init tegra_protected_aperture_init(unsigned long aperture) +{ +#ifndef CONFIG_NVMAP_ALLOW_SYSMEM + void __iomem *mc_base = IO_ADDRESS(TEGRA_MC_BASE); + pr_info("Enabling Tegra protected aperture at 0x%08lx\n", aperture); + writel(aperture, mc_base + MC_SECURITY_CFG2); +#else + pr_err("Tegra protected aperture disabled because nvmap is using " + "system memory\n"); +#endif +} + void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size, unsigned long fb2_size) { @@ -157,6 +177,15 @@ void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size, else tegra_fb_size = fb_size; + if (tegra_fb_size) + tegra_grhost_aperture = tegra_fb_start; + + if (tegra_fb2_size && tegra_fb2_start < tegra_grhost_aperture) + tegra_grhost_aperture = tegra_fb2_start; + + if (tegra_carveout_size && tegra_carveout_start < tegra_grhost_aperture) + tegra_grhost_aperture = tegra_carveout_start; + /* * TODO: We should copy the bootloader's framebuffer to the framebuffer * allocated above, and then free this one. -- 2.34.1