From patchwork Mon May 9 21:41:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 9050161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B43089F1C3 for ; Mon, 9 May 2016 21:44:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDFB82011E for ; Mon, 9 May 2016 21:44:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D433E20114 for ; Mon, 9 May 2016 21:44:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1azsxK-0000KJ-0i; Mon, 09 May 2016 21:43:10 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1azsx2-0008VU-EY for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2016 21:42:54 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u49Lg3bx029796; Mon, 9 May 2016 16:42:03 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u49Lg3E7013274; Mon, 9 May 2016 16:42:03 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Mon, 9 May 2016 16:42:01 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u49Lg1Kd027222; Mon, 9 May 2016 16:42:01 -0500 Received: from localhost (uda0274052.am.dhcp.ti.com [128.247.83.19]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u49Lg1304602; Mon, 9 May 2016 16:42:01 -0500 (CDT) From: Dave Gerlach To: , , Subject: [RFC PATCH 1/3] asm-generic: io: Add exec versions of ioremap Date: Mon, 9 May 2016 16:41:49 -0500 Message-ID: <1462830111-28172-2-git-send-email-d-gerlach@ti.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1462830111-28172-1-git-send-email-d-gerlach@ti.com> References: <1462830111-28172-1-git-send-email-d-gerlach@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160509_144252_813102_E058950B X-CRM114-Status: UNSURE ( 9.46 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -9.0 (---------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nishanth Menon , Russell King , Arnd Bergmann , Dave Gerlach , Tony Lindgren , Greg Kroah-Hartman , Alexandre Belloni , Russ Dill , Shawn Guo Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Russ Dill If code is to be copied into and area (such as SRAM) and run, it needs to be marked as exec. Currently only an ARM version of this exists, but a generic version will be useful for drivers. Signed-off-by: Russ Dill Signed-off-by: Dave Gerlach --- arch/arm/include/asm/io.h | 5 +++++ arch/arm/mm/ioremap.c | 14 ++++++++++++++ arch/arm/mm/nommu.c | 14 ++++++++++++++ include/asm-generic/iomap.h | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 485982084fe9..7d07a02cb7bc 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -399,6 +399,11 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size); #define ioremap_wc ioremap_wc #define ioremap_wt ioremap_wc +void __iomem *ioremap_exec(resource_size_t res_cookie, size_t size); +void __iomem *ioremap_exec_nocache(resource_size_t res_cookie, size_t size); +#define ioremap_exec ioremap_exec +#define ioremap_exec_nocache ioremap_exec_nocache + void iounmap(volatile void __iomem *iomem_cookie); #define iounmap iounmap diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index 66a978d05958..c6eef3c98074 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -400,6 +400,20 @@ EXPORT_SYMBOL(ioremap_wc); * clocks that would affect normal memory for example. Please see * CONFIG_GENERIC_ALLOCATOR for allocating external memory. */ +void __iomem *ioremap_exec(resource_size_t res_cookie, size_t size) +{ + return arch_ioremap_caller(res_cookie, size, MT_MEMORY_RWX, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_exec); + +void __iomem *ioremap_exec_nocache(resource_size_t res_cookie, size_t size) +{ + return arch_ioremap_caller(res_cookie, size, MT_MEMORY_RWX_NONCACHED, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_exec_nocache); + void __iomem * __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached) { diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 1dd10936d68d..1d1d587340e6 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c @@ -380,6 +380,20 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size) } EXPORT_SYMBOL(ioremap_wc); +void __iomem *ioremap_exec(resource_size_t res_cookie, size_t size) +{ + return __arm_ioremap_caller(res_cookie, size, 0, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_exec); + +void __iomem *ioremap_exec_nocache(resource_size_t res_cookie, size_t size) +{ + return __arm_ioremap_caller(res_cookie, size, 0, + __builtin_return_address(0)); +} +EXPORT_SYMBOL(ioremap_exec_nocache); + void __iounmap(volatile void __iomem *addr) { } diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index d8f8622fa044..a789aad509c3 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h @@ -70,6 +70,11 @@ extern void ioport_unmap(void __iomem *); #define ioremap_wt ioremap_nocache #endif +#ifndef ARCH_HAS_IOREMAP_EXEC +#define ioremap_exec ioremap +#define ioremap_exec_nocache ioremap_nocache +#endif + #ifdef CONFIG_PCI /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ struct pci_dev;