Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Dave Gerlach <d-gerlach@ti.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Russell King <linux@arm.linux.org.uk>,
	Dan Williams <dan.j.williams@intel.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shawn Guo <shawnguo@kernel.org>, Tony Lindgren <tony@atomide.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Nishanth Menon <nm@ti.com>, Dave Gerlach <d-gerlach@ti.com>
Subject: [PATCH 1/3] ARM: memremap: implement arch_memremap_exec/exec_nocache
Date: Thu, 27 Oct 2016 13:56:10 -0500	[thread overview]
Message-ID: <20161027185612.22362-2-d-gerlach@ti.com> (raw)
In-Reply-To: <20161027185612.22362-1-d-gerlach@ti.com>

Introduce arch_memremap_exec and arch_memremap_exec_nocache for ARM to
allow mapping of memory as executable. Some platforms have a requirement
to map on-chip memory, such as SRAM, to hold and run code that cannot be
executed in DRAM, such as low-level PM code or code to reconfigure the
DRAM controller itself.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
 arch/arm/include/asm/io.h |  5 +++++
 arch/arm/mm/ioremap.c     | 16 ++++++++++++++++
 arch/arm/mm/nommu.c       | 12 ++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 021692c64de3..67476a5add20 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -411,6 +411,11 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size);
 void iounmap(volatile void __iomem *iomem_cookie);
 #define iounmap iounmap
 
+void *arch_memremap_exec(phys_addr_t phys_addr, size_t size);
+void *arch_memremap_exec_nocache(phys_addr_t phys_addr, size_t size);
+#define arch_memremap_exec arch_memremap_exec
+#define arch_memremap_exec_nocache arch_memremap_exec_nocache
+
 void *arch_memremap_wb(phys_addr_t phys_addr, size_t size);
 #define arch_memremap_wb arch_memremap_wb
 
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index ff0eed23ddf1..5c22a7a0b349 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -419,6 +419,22 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
 			__builtin_return_address(0));
 }
 
+void *arch_memremap_exec(phys_addr_t phys_addr, size_t size)
+{
+	return (__force void *)arch_ioremap_caller(phys_addr, size,
+						   MT_MEMORY_RWX,
+						   __builtin_return_address(0));
+}
+EXPORT_SYMBOL(arch_memremap_exec);
+
+void *arch_memremap_exec_nocache(phys_addr_t phys_addr, size_t size)
+{
+	return (__force void *)arch_ioremap_caller(phys_addr, size,
+						   MT_MEMORY_RWX_NONCACHED,
+						   __builtin_return_address(0));
+}
+EXPORT_SYMBOL(arch_memremap_exec_nocache);
+
 void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 {
 	return (__force void *)arch_ioremap_caller(phys_addr, size,
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 2740967727e2..038922133ec4 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -390,6 +390,18 @@ void *arch_memremap_wb(phys_addr_t phys_addr, size_t size)
 	return (void *)phys_addr;
 }
 
+void *arch_memremap_exec(phys_addr_t phys_addr, size_t size)
+{
+	return (void *)phys_addr;
+}
+EXPORT_SYMBOL(arch_memremap_exec);
+
+void *arch_memremap_exec_nocache(phys_addr_t phys_addr, size_t size)
+{
+	return (void *)phys_addr;
+}
+EXPORT_SYMBOL(arch_memremap_exec_nocache);
+
 void __iounmap(volatile void __iomem *addr)
 {
 }
-- 
2.9.3

  reply	other threads:[~2016-10-27 18:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 18:56 [PATCH 0/3] Add memremap executable mapping and extend drivers/misc/sram.c Dave Gerlach
2016-10-27 18:56 ` Dave Gerlach [this message]
2016-10-27 18:56 ` [PATCH 2/3] memremap: add MEMREMAP_EXEC and MEMREMAP_EXEC_NOCACHE flags Dave Gerlach
2016-10-27 18:56 ` [PATCH 3/3] misc: SRAM: Add option to map SRAM to allow code execution Dave Gerlach
2016-11-05  2:47 ` [PATCH 0/3] Add memremap executable mapping and extend drivers/misc/sram.c Alexandre Belloni
2016-11-07 11:04 ` Russell King - ARM Linux
2016-11-07 17:43   ` Tony Lindgren
2016-11-07 21:34     ` Dave Gerlach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161027185612.22362-2-d-gerlach@ti.com \
    --to=d-gerlach@ti.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nm@ti.com \
    --cc=shawnguo@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox