[ARM] tegra: Add function to enable protected aperture
authorColin Cross <ccross@android.com>
Tue, 19 Oct 2010 23:12:33 +0000 (16:12 -0700)
committerColin Cross <ccross@android.com>
Wed, 20 Oct 2010 21:30:17 +0000 (14:30 -0700)
Change-Id: I699cee3bc9a131259b330655126146f5d1f92043
Signed-off-by: Colin Cross <ccross@android.com>
arch/arm/mach-tegra/board.h
arch/arm/mach-tegra/common.c

index 120b452bcda99a5a87e21a13f494abb4bb5e55c7..086ec70c470d8da80f0df99db36e96e2cc506e2d 100644 (file)
@@ -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
index d212e78a0360858d8b6aa119b41c12a7c2031924..28b1e9ae7396d6b042c711fb73b891f4e96cc7d6 100644 (file)
@@ -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.