From patchwork Fri Mar 26 21:02:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: omar ramirez X-Patchwork-Id: 88580 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2QKkptR020899 for ; Fri, 26 Mar 2010 20:46:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753273Ab0CZUqx (ORCPT ); Fri, 26 Mar 2010 16:46:53 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:57833 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753207Ab0CZUqw (ORCPT ); Fri, 26 Mar 2010 16:46:52 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o2QKkmcR015057 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Mar 2010 15:46:48 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o2QKkl3F003044; Fri, 26 Mar 2010 15:46:47 -0500 (CDT) Received: from Matrix (matrix.am.dhcp.ti.com [128.247.75.166]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o2QKklZ15973; Fri, 26 Mar 2010 15:46:47 -0500 (CDT) Received: by Matrix (Postfix, from userid 1003) id 11BF441061A; Fri, 26 Mar 2010 15:02:28 -0600 (CST) From: Omar Ramirez Luna To: linux-omap Cc: Ameya Palande , Hiroshi Doyu , Felipe Contreras , Nishanth Menon , Omar Ramirez Luna , Hiroshi DOYU Subject: [PATCH 1/2] DSPBRIDGE: add checking 128 byte alignment for dsp cache line size Date: Fri, 26 Mar 2010 15:02:27 -0600 Message-Id: <1269637348-20608-2-git-send-email-omar.ramirez@ti.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <1269637348-20608-1-git-send-email-omar.ramirez@ti.com> References: <1269637348-20608-1-git-send-email-omar.ramirez@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 26 Mar 2010 20:46:55 +0000 (UTC) diff --git a/drivers/dsp/bridge/Kconfig b/drivers/dsp/bridge/Kconfig index a3251c3..a973695 100644 --- a/drivers/dsp/bridge/Kconfig +++ b/drivers/dsp/bridge/Kconfig @@ -38,6 +38,20 @@ config BRIDGE_DEBUG help Say Y to enable Bridge debugging capabilities +config BRIDGE_CACHE_LINE_CHECK + bool "Check buffers to be 128 byte aligned" + depends on MPU_BRIDGE + default n + help + When the DSP processes data, the DSP cache controller loads 128-Byte + chunks (lines) from SDRAM and writes the data back in 128-Byte chunks. + If a DMM buffer does not start and end on a 128-Byte boundary, the data + preceding the start address (SA) from the 128-Byte boundary to the SA + and the data at addresses trailing the end address (EA) from the EA to + the next 128-Byte boundary will be loaded and written back as well. + This can lead to heap corruption. Say Y, to enforce the check for 128 + byte alignment, buffers failing this check will be rejected. + comment "Bridge Notifications" depends on MPU_BRIDGE diff --git a/drivers/dsp/bridge/rmgr/proc.c b/drivers/dsp/bridge/rmgr/proc.c index e100d31..ac141a8 100644 --- a/drivers/dsp/bridge/rmgr/proc.c +++ b/drivers/dsp/bridge/rmgr/proc.c @@ -68,6 +68,8 @@ #define PWR_TIMEOUT 500 /* Sleep/wake timout in msec */ #define EXTEND "_EXT_END" /* Extmem end addr in DSP binary */ +#define DSP_CACHE_LINE 128 + extern char *iva_img; /* ----------------------------------- Globals */ @@ -1067,6 +1069,15 @@ dsp_status proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size, struct proc_object *p_proc_object = (struct proc_object *)hprocessor; struct dmm_map_object *map_obj; +#ifdef CONFIG_BRIDGE_CACHE_LINE_CHECK + if (!IS_ALIGNED((u32)pmpu_addr, DSP_CACHE_LINE) || + !IS_ALIGNED(ul_size, DSP_CACHE_LINE)) { + pr_err("%s: not aligned: 0x%x (%d)\n", __func__, + (u32)pmpu_addr, ul_size); + return -EFAULT; + } +#endif + /* Calculate the page-aligned PA, VA and size */ va_align = PG_ALIGN_LOW((u32) req_addr, PG_SIZE4K); pa_align = PG_ALIGN_LOW((u32) pmpu_addr, PG_SIZE4K);