* [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes
@ 2011-12-14 11:48 Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 1/7] remoteproc: do not require an iommu Ohad Ben-Cohen
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
Two fixes from Mark (required for controlling non-IOMMU and non-Virtio
remote processors via remoteproc), two fixes which were reported by
Stephen Boyd, and three other trivial cleanups.
Mark Grosen (2):
remoteproc: do not require an iommu
remoteproc: avoid registering a virtio device if not supported
Ohad Ben-Cohen (5):
remoteproc: remove unused resource type
remoteproc/omap: utilize module_platform_driver
remoteproc: look for truncated firmware images
remoteproc: add Kconfig menu
rpmsg: add Kconfig menu
drivers/remoteproc/Kconfig | 4 +++
drivers/remoteproc/omap_remoteproc.c | 13 +----------
drivers/remoteproc/remoteproc_core.c | 41 +++++++++++++++++++++++++++------
drivers/rpmsg/Kconfig | 4 +++
include/linux/remoteproc.h | 1 -
5 files changed, 42 insertions(+), 21 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/7] remoteproc: do not require an iommu
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 2/7] remoteproc: avoid registering a virtio device if not supported Ohad Ben-Cohen
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Grosen <mgrosen@ti.com>
Not all remote processors employ an IOMMU, so do not error out
on !iommu_present().
Note: we currently still use iommu_present() to tell whether we need
to configure an IOMMU or not. That works for simple cases, but will
easily fail with more complicated ones (e.g. where an IOMMU exists,
but not all remote processors use it). When those use cases show up,
we will solve them by introducing something like remoteproc hw
capabilities.
[ohad at wizery.com: write commit log]
Signed-off-by: Mark Grosen <mgrosen@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/remoteproc/remoteproc_core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ad93d7d..0d9a955 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -105,8 +105,8 @@ static int rproc_enable_iommu(struct rproc *rproc)
* that will be set by the remoteproc driver.
*/
if (!iommu_present(dev->bus)) {
- dev_err(dev, "iommu not found\n");
- return -ENODEV;
+ dev_dbg(dev, "iommu not found\n");
+ return 0;
}
domain = iommu_domain_alloc(dev->bus);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/7] remoteproc: avoid registering a virtio device if not supported
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 1/7] remoteproc: do not require an iommu Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 3/7] remoteproc: remove unused resource type Ohad Ben-Cohen
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Grosen <mgrosen@ti.com>
Let remoteproc know when the firmware doesn't support any virtio
functionality, so registering a virtio device can be avoided.
This is needed for remote processors that doesn't require any
virtio-based communications, but are still controlled via remoteproc.
[ohad at wizery.com: write commit log]
Signed-off-by: Mark Grosen <mgrosen@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/remoteproc/remoteproc_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 0d9a955..080c056 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -695,7 +695,7 @@ static int
rproc_handle_virtio_rsc(struct rproc *rproc, struct fw_resource *rsc, int len)
{
struct device *dev = rproc->dev;
- int ret = 0;
+ int ret = -ENODEV;
for (; len >= sizeof(*rsc); rsc++, len -= sizeof(*rsc))
if (rsc->type == RSC_VIRTIO_DEV) {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] remoteproc: remove unused resource type
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 1/7] remoteproc: do not require an iommu Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 2/7] remoteproc: avoid registering a virtio device if not supported Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 4/7] remoteproc/omap: utilize module_platform_driver Ohad Ben-Cohen
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
RSC_VIRTIO_CFG isn't being used, so remove it.
Originally it was introduced to overcome a resource table limitation
that prevented describing a virtio device in a single resource table
entry.
The plan though is to describe resource table entries in a TLV fashion,
where each entry will consume the amount of space it requires,
so the original limitation is anyway temporary.
Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
include/linux/remoteproc.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 1edbfde..b52f784 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -122,7 +122,6 @@ enum fw_resource_type {
RSC_TRACE = 2,
RSC_VRING = 3,
RSC_VIRTIO_DEV = 4,
- RSC_VIRTIO_CFG = 5,
};
/**
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] remoteproc/omap: utilize module_platform_driver
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
` (2 preceding siblings ...)
2011-12-14 11:48 ` [PATCH 3/7] remoteproc: remove unused resource type Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 5/7] remoteproc: look for truncated firmware images Ohad Ben-Cohen
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
Ditch some boilerplate code by employing the module_platform_driver
helper.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/remoteproc/omap_remoteproc.c | 13 +------------
1 files changed, 1 insertions(+), 12 deletions(-)
diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c
index b49ecbb..aa3ce52 100644
--- a/drivers/remoteproc/omap_remoteproc.c
+++ b/drivers/remoteproc/omap_remoteproc.c
@@ -232,18 +232,7 @@ static struct platform_driver omap_rproc_driver = {
},
};
-/* most of the below will go when module_platform_driver is merged */
-static int __init omap_rproc_init(void)
-{
- return platform_driver_register(&omap_rproc_driver);
-}
-module_init(omap_rproc_init);
-
-static void __exit omap_rproc_exit(void)
-{
- platform_driver_unregister(&omap_rproc_driver);
-}
-module_exit(omap_rproc_exit);
+module_platform_driver(omap_rproc_driver);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("OMAP Remote Processor control driver");
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] remoteproc: look for truncated firmware images
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
` (3 preceding siblings ...)
2011-12-14 11:48 ` [PATCH 4/7] remoteproc/omap: utilize module_platform_driver Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 6/7] remoteproc: add Kconfig menu Ohad Ben-Cohen
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
Make sure firmware isn't truncated before accessing its data.
Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/remoteproc/remoteproc_core.c | 35 +++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 080c056..f2354ce 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -191,6 +191,7 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
* rproc_load_segments() - load firmware segments to memory
* @rproc: remote processor which will be booted using these fw segments
* @elf_data: the content of the ELF firmware image
+ * @len: firmware size (in bytes)
*
* This function loads the firmware segments to memory, where the remote
* processor expects them.
@@ -211,7 +212,8 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
* directly allocate memory for every segment/resource. This is not yet
* supported, though.
*/
-static int rproc_load_segments(struct rproc *rproc, const u8 *elf_data)
+static int
+rproc_load_segments(struct rproc *rproc, const u8 *elf_data, size_t len)
{
struct device *dev = rproc->dev;
struct elf32_hdr *ehdr;
@@ -226,6 +228,7 @@ static int rproc_load_segments(struct rproc *rproc, const u8 *elf_data)
u32 da = phdr->p_paddr;
u32 memsz = phdr->p_memsz;
u32 filesz = phdr->p_filesz;
+ u32 offset = phdr->p_offset;
void *ptr;
if (phdr->p_type != PT_LOAD)
@@ -241,6 +244,13 @@ static int rproc_load_segments(struct rproc *rproc, const u8 *elf_data)
break;
}
+ if (offset + filesz > len) {
+ dev_err(dev, "truncated fw: need 0x%x avail 0x%x\n",
+ offset + filesz, len);
+ ret = -EINVAL;
+ break;
+ }
+
/* grab the kernel address for this device address */
ptr = rproc_da_to_va(rproc, da, memsz);
if (!ptr) {
@@ -712,6 +722,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct fw_resource *rsc, int len)
* rproc_handle_resources() - find and handle the resource table
* @rproc: the rproc handle
* @elf_data: the content of the ELF firmware image
+ * @len: firmware size (in bytes)
* @handler: function that should be used to handle the resource table
*
* This function finds the resource table inside the remote processor's
@@ -725,7 +736,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct fw_resource *rsc, int len)
* processors that don't need a resource table.
*/
static int rproc_handle_resources(struct rproc *rproc, const u8 *elf_data,
- rproc_handle_resources_t handler)
+ size_t len, rproc_handle_resources_t handler)
{
struct elf32_hdr *ehdr;
@@ -743,6 +754,13 @@ static int rproc_handle_resources(struct rproc *rproc, const u8 *elf_data,
struct fw_resource *table = (struct fw_resource *)
(elf_data + shdr->sh_offset);
+ if (shdr->sh_offset + shdr->sh_size > len) {
+ dev_err(rproc->dev,
+ "truncated fw: need 0x%x avail 0x%x\n",
+ shdr->sh_offset + shdr->sh_size, len);
+ ret = -EINVAL;
+ }
+
ret = handler(rproc, table, shdr->sh_size);
break;
@@ -833,6 +851,11 @@ static int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
ehdr = (struct elf32_hdr *)fw->data;
+ if (fw->size < ehdr->e_shoff + sizeof(struct elf32_shdr)) {
+ dev_err(dev, "Image is too small\n");
+ return -EINVAL;
+ }
+
if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) {
dev_err(dev, "Image is corrupted (bad magic)\n");
return -EINVAL;
@@ -887,14 +910,15 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
rproc->bootaddr = ehdr->e_entry;
/* handle fw resources which are required to boot rproc */
- ret = rproc_handle_resources(rproc, fw->data, rproc_handle_boot_rsc);
+ ret = rproc_handle_resources(rproc, fw->data, fw->size,
+ rproc_handle_boot_rsc);
if (ret) {
dev_err(dev, "Failed to process resources: %d\n", ret);
goto clean_up;
}
/* load the ELF segments to memory */
- ret = rproc_load_segments(rproc, fw->data);
+ ret = rproc_load_segments(rproc, fw->data, fw->size);
if (ret) {
dev_err(dev, "Failed to load program segments: %d\n", ret);
goto clean_up;
@@ -937,7 +961,8 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
goto out;
/* does the fw supports any virtio devices ? */
- ret = rproc_handle_resources(rproc, fw->data, rproc_handle_virtio_rsc);
+ ret = rproc_handle_resources(rproc, fw->data, fw->size,
+ rproc_handle_virtio_rsc);
if (ret) {
dev_info(dev, "No fw virtio device was found\n");
goto out;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] remoteproc: add Kconfig menu
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
` (4 preceding siblings ...)
2011-12-14 11:48 ` [PATCH 5/7] remoteproc: look for truncated firmware images Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 7/7] rpmsg: " Ohad Ben-Cohen
2011-12-21 11:29 ` [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
Add a dedicated Kconfig menu for the remoteproc drivers, so they
don't show up in the main driver menu.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/remoteproc/Kconfig | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 396c97a..00fb72f 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -1,3 +1,5 @@
+menu "Remoteproc drivers"
+
# REMOTEPROC gets selected by whoever wants it
config REMOTEPROC
tristate
@@ -22,3 +24,5 @@ config OMAP_REMOTEPROC
It's safe to say n here if you're not interested in multimedia
offloading or just want a bare minimum kernel.
+
+endmenu
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] rpmsg: add Kconfig menu
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
` (5 preceding siblings ...)
2011-12-14 11:48 ` [PATCH 6/7] remoteproc: add Kconfig menu Ohad Ben-Cohen
@ 2011-12-14 11:48 ` Ohad Ben-Cohen
2011-12-21 11:29 ` [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-14 11:48 UTC (permalink / raw)
To: linux-arm-kernel
Add a dedicated Kconfig menu for the rpmsg drivers, so they
don't show up in the main driver menu.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
drivers/rpmsg/Kconfig | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index 811fede..98aca55 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -1,5 +1,9 @@
+menu "Rpmsg drivers"
+
# RPMSG always gets selected by whoever wants it
config RPMSG
tristate
select VIRTIO
select VIRTIO_RING
+
+endmenu
--
1.7.5.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
` (6 preceding siblings ...)
2011-12-14 11:48 ` [PATCH 7/7] rpmsg: " Ohad Ben-Cohen
@ 2011-12-21 11:29 ` Ohad Ben-Cohen
7 siblings, 0 replies; 9+ messages in thread
From: Ohad Ben-Cohen @ 2011-12-21 11:29 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Dec 14, 2011 at 1:48 PM, Ohad Ben-Cohen <ohad@wizery.com> wrote:
> Two fixes from Mark (required for controlling non-IOMMU and non-Virtio
> remote processors via remoteproc), two fixes which were reported by
> Stephen Boyd, and three other trivial cleanups.
Applied and pushed to 'for-next'.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-12-21 11:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-14 11:48 [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 1/7] remoteproc: do not require an iommu Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 2/7] remoteproc: avoid registering a virtio device if not supported Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 3/7] remoteproc: remove unused resource type Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 4/7] remoteproc/omap: utilize module_platform_driver Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 5/7] remoteproc: look for truncated firmware images Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 6/7] remoteproc: add Kconfig menu Ohad Ben-Cohen
2011-12-14 11:48 ` [PATCH 7/7] rpmsg: " Ohad Ben-Cohen
2011-12-21 11:29 ` [PATCH 0/7] remoteproc/rpmsg: a few trivial fixes Ohad Ben-Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).