diff options
| -rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 25fd9733d5df..e75424b6314c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
| @@ -176,8 +176,7 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) | |||
| 176 | /** | 176 | /** |
| 177 | * rproc_load_segments() - load firmware segments to memory | 177 | * rproc_load_segments() - load firmware segments to memory |
| 178 | * @rproc: remote processor which will be booted using these fw segments | 178 | * @rproc: remote processor which will be booted using these fw segments |
| 179 | * @elf_data: the content of the ELF firmware image | 179 | * @fw: the ELF firmware image |
| 180 | * @len: firmware size (in bytes) | ||
| 181 | * | 180 | * |
| 182 | * This function loads the firmware segments to memory, where the remote | 181 | * This function loads the firmware segments to memory, where the remote |
| 183 | * processor expects them. | 182 | * processor expects them. |
| @@ -199,12 +198,13 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) | |||
| 199 | * supported, though. | 198 | * supported, though. |
| 200 | */ | 199 | */ |
| 201 | static int | 200 | static int |
| 202 | rproc_load_segments(struct rproc *rproc, const u8 *elf_data, size_t len) | 201 | rproc_load_segments(struct rproc *rproc, const struct firmware *fw) |
| 203 | { | 202 | { |
| 204 | struct device *dev = &rproc->dev; | 203 | struct device *dev = &rproc->dev; |
| 205 | struct elf32_hdr *ehdr; | 204 | struct elf32_hdr *ehdr; |
| 206 | struct elf32_phdr *phdr; | 205 | struct elf32_phdr *phdr; |
| 207 | int i, ret = 0; | 206 | int i, ret = 0; |
| 207 | const u8 *elf_data = fw->data; | ||
| 208 | 208 | ||
| 209 | ehdr = (struct elf32_hdr *)elf_data; | 209 | ehdr = (struct elf32_hdr *)elf_data; |
| 210 | phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff); | 210 | phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff); |
| @@ -230,9 +230,9 @@ rproc_load_segments(struct rproc *rproc, const u8 *elf_data, size_t len) | |||
| 230 | break; | 230 | break; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | if (offset + filesz > len) { | 233 | if (offset + filesz > fw->size) { |
| 234 | dev_err(dev, "truncated fw: need 0x%x avail 0x%x\n", | 234 | dev_err(dev, "truncated fw: need 0x%x avail 0x%x\n", |
| 235 | offset + filesz, len); | 235 | offset + filesz, fw->size); |
| 236 | ret = -EINVAL; | 236 | ret = -EINVAL; |
| 237 | break; | 237 | break; |
| 238 | } | 238 | } |
| @@ -819,8 +819,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct resource_table *table, int l | |||
| 819 | /** | 819 | /** |
| 820 | * rproc_find_rsc_table() - find the resource table | 820 | * rproc_find_rsc_table() - find the resource table |
| 821 | * @rproc: the rproc handle | 821 | * @rproc: the rproc handle |
| 822 | * @elf_data: the content of the ELF firmware image | 822 | * @fw: the ELF firmware image |
| 823 | * @len: firmware size (in bytes) | ||
| 824 | * @tablesz: place holder for providing back the table size | 823 | * @tablesz: place holder for providing back the table size |
| 825 | * | 824 | * |
| 826 | * This function finds the resource table inside the remote processor's | 825 | * This function finds the resource table inside the remote processor's |
| @@ -833,7 +832,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct resource_table *table, int l | |||
| 833 | * (and @tablesz isn't set). | 832 | * (and @tablesz isn't set). |
| 834 | */ | 833 | */ |
| 835 | static struct resource_table * | 834 | static struct resource_table * |
| 836 | rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len, | 835 | rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw, |
| 837 | int *tablesz) | 836 | int *tablesz) |
| 838 | { | 837 | { |
| 839 | struct elf32_hdr *ehdr; | 838 | struct elf32_hdr *ehdr; |
| @@ -842,6 +841,7 @@ rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len, | |||
| 842 | struct device *dev = &rproc->dev; | 841 | struct device *dev = &rproc->dev; |
| 843 | struct resource_table *table = NULL; | 842 | struct resource_table *table = NULL; |
| 844 | int i; | 843 | int i; |
| 844 | const u8 *elf_data = fw->data; | ||
| 845 | 845 | ||
| 846 | ehdr = (struct elf32_hdr *)elf_data; | 846 | ehdr = (struct elf32_hdr *)elf_data; |
| 847 | shdr = (struct elf32_shdr *)(elf_data + ehdr->e_shoff); | 847 | shdr = (struct elf32_shdr *)(elf_data + ehdr->e_shoff); |
| @@ -858,7 +858,7 @@ rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len, | |||
| 858 | table = (struct resource_table *)(elf_data + offset); | 858 | table = (struct resource_table *)(elf_data + offset); |
| 859 | 859 | ||
| 860 | /* make sure we have the entire table */ | 860 | /* make sure we have the entire table */ |
| 861 | if (offset + size > len) { | 861 | if (offset + size > fw->size) { |
| 862 | dev_err(dev, "resource table truncated\n"); | 862 | dev_err(dev, "resource table truncated\n"); |
| 863 | return NULL; | 863 | return NULL; |
| 864 | } | 864 | } |
| @@ -1035,7 +1035,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) | |||
| 1035 | rproc->bootaddr = ehdr->e_entry; | 1035 | rproc->bootaddr = ehdr->e_entry; |
| 1036 | 1036 | ||
| 1037 | /* look for the resource table */ | 1037 | /* look for the resource table */ |
| 1038 | table = rproc_find_rsc_table(rproc, fw->data, fw->size, &tablesz); | 1038 | table = rproc_find_rsc_table(rproc, fw, &tablesz); |
| 1039 | if (!table) | 1039 | if (!table) |
| 1040 | goto clean_up; | 1040 | goto clean_up; |
| 1041 | 1041 | ||
| @@ -1047,7 +1047,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) | |||
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| 1049 | /* load the ELF segments to memory */ | 1049 | /* load the ELF segments to memory */ |
| 1050 | ret = rproc_load_segments(rproc, fw->data, fw->size); | 1050 | ret = rproc_load_segments(rproc, fw); |
| 1051 | if (ret) { | 1051 | if (ret) { |
| 1052 | dev_err(dev, "Failed to load program segments: %d\n", ret); | 1052 | dev_err(dev, "Failed to load program segments: %d\n", ret); |
| 1053 | goto clean_up; | 1053 | goto clean_up; |
| @@ -1090,7 +1090,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) | |||
| 1090 | goto out; | 1090 | goto out; |
| 1091 | 1091 | ||
| 1092 | /* look for the resource table */ | 1092 | /* look for the resource table */ |
| 1093 | table = rproc_find_rsc_table(rproc, fw->data, fw->size, &tablesz); | 1093 | table = rproc_find_rsc_table(rproc, fw, &tablesz); |
| 1094 | if (!table) | 1094 | if (!table) |
| 1095 | goto out; | 1095 | goto out; |
| 1096 | 1096 | ||
