[PATCH] libfile: fix typos
Signed-off-by: Michael Tretter --- lib/libfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libfile.c b/lib/libfile.c index f6c588d737..3f3ec21fdb 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -242,9 +242,9 @@ EXPORT_SYMBOL(read_file_2); * * This function reads a file to an allocated buffer. * Some TFTP servers do not transfer the size of a file. In this case - * a the file is first read to a temporary file. + * the file is first read to a temporary file. * - * Return: The buffer conataining the file or NULL on failure + * Return: The buffer containing the file or NULL on failure */ void *read_file(const char *filename, size_t *size) { -- 2.20.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v4 2/2] mips: bootm: Cast elf entry into unsigned long
Since elf entry type is now a u64 to accomodate both type of elf files (64 and 32 bits), we need to cast it to the pointer length before casting it to the pointer type. Signed-off-by: Clement Leger --- arch/mips/lib/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index f14540a4c..5bb09cc2d 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -72,7 +72,7 @@ static int do_bootm_elf(struct image_data *data) shutdown_barebox(); - entry = (void *)elf->entry; + entry = (void *) (unsigned long) elf->entry; entry(-2, phys_to_virt((unsigned long)fdt)); -- 2.15.0.276.g89ea799 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH v4 1/2] elf: add 64 bits elf loading support
From: Clement Leger This patch add elf64 loading support to the elf loader. Since elf32 and elf64 uses completely different types, to avoid copying all the code and simply replace elf32 with elf64, use a macro which will return the appropriate field for each type of header. This macro generates getter for elf structures according to the class of the loaded elf. All direct elf struct dereference are then replaced by call to generated functions. This allows to keep a common loader code even if types are different. Tested-by: Oleksij Rempel Signed-off-by: Clement Leger --- Changes in V4: - Fix mips elf entry cast to pointer - Add Tested-by Oleksij Rempel common/elf.c | 45 +++-- include/elf.h | 29 - 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/common/elf.c b/common/elf.c index 8edf38856..4733accb0 100644 --- a/common/elf.c +++ b/common/elf.c @@ -45,29 +45,31 @@ static void elf_release_regions(struct elf_image *elf) static int load_elf_phdr_segment(struct elf_image *elf, void *src, -Elf32_Phdr *phdr) +void *phdr) { - void *dst = (void *)phdr->p_paddr; + void *dst = (void *) elf_phdr_p_paddr(elf, phdr); int ret; + u64 p_filesz = elf_phdr_p_filesz(elf, phdr); + u64 p_memsz = elf_phdr_p_memsz(elf, phdr); /* we care only about PT_LOAD segments */ - if (phdr->p_type != PT_LOAD) + if (elf_phdr_p_type(elf, phdr) != PT_LOAD) return 0; - if (!phdr->p_filesz) + if (!p_filesz) return 0; - pr_debug("Loading phdr to 0x%p (%i bytes)\n", dst, phdr->p_filesz); + pr_debug("Loading phdr to 0x%p (%llu bytes)\n", dst, p_filesz); - ret = elf_request_region(elf, (resource_size_t)dst, phdr->p_filesz); + ret = elf_request_region(elf, (resource_size_t)dst, p_filesz); if (ret) return ret; - memcpy(dst, src, phdr->p_filesz); + memcpy(dst, src, p_filesz); - if (phdr->p_filesz < phdr->p_memsz) - memset(dst + phdr->p_filesz, 0x00, - phdr->p_memsz - phdr->p_filesz); + if (p_filesz < p_memsz) + memset(dst + p_filesz, 0x00, + p_memsz - p_filesz); return 0; } @@ -75,14 +77,13 @@ static int load_elf_phdr_segment(struct elf_image *elf, void *src, static int load_elf_image_phdr(struct elf_image *elf) { void *buf = elf->buf; - Elf32_Ehdr *ehdr = buf; - Elf32_Phdr *phdr = (Elf32_Phdr *)(buf + ehdr->e_phoff); + void *phdr = (void *) (buf + elf_hdr_e_phoff(elf, buf)); int i, ret; - elf->entry = ehdr->e_entry; + elf->entry = elf_hdr_e_entry(elf, buf); - for (i = 0; i < ehdr->e_phnum; ++i) { - void *src = buf + phdr->p_offset; + for (i = 0; i < elf_hdr_e_phnum(elf, buf) ; ++i) { + void *src = buf + elf_phdr_p_offset(elf, phdr); ret = load_elf_phdr_segment(elf, src, phdr); /* in case of error elf_load_image() caller should clean up and @@ -90,22 +91,22 @@ static int load_elf_image_phdr(struct elf_image *elf) if (ret) return ret; - ++phdr; + phdr += elf_size_of_phdr(elf); } return 0; } -static int elf_check_image(void *buf) +static int elf_check_image(struct elf_image *elf) { - Elf32_Ehdr *ehdr = (Elf32_Ehdr *)buf; - - if (strncmp(buf, ELFMAG, SELFMAG)) { + if (strncmp(elf->buf, ELFMAG, SELFMAG)) { pr_err("ELF magic not found.\n"); return -EINVAL; } - if (ehdr->e_type != ET_EXEC) { + elf->class = ((char *) elf->buf)[EI_CLASS]; + + if (elf_hdr_e_type(elf, elf->buf) != ET_EXEC) { pr_err("Non EXEC ELF image.\n"); return -ENOEXEC; } @@ -124,7 +125,7 @@ struct elf_image *elf_load_image(void *buf) elf->buf = buf; - ret = elf_check_image(buf); + ret = elf_check_image(elf); if (ret) return ERR_PTR(ret); diff --git a/include/elf.h b/include/elf.h index 92c8d9c12..633f4992d 100644 --- a/include/elf.h +++ b/include/elf.h @@ -400,11 +400,38 @@ static inline void arch_write_notes(struct file *file) { } struct elf_image { struct list_head list; - unsigned long entry; + u8 class; + u64 entry; void *buf; }; struct elf_image *elf_load_image(void *buf); void elf_release_image(struct elf_image *elf); +#define ELF_GET_FIELD(__s, __field, __type) \ +static inline __type elf_##__s##_##__field(struct elf_image *elf, void *arg) { \ + if (elf->class == ELFCLASS32) \ + return (__type) ((struct elf32_##__s *) arg)->__field; \ + else \ + return (__type) ((struct elf64_##__s *) arg)->__field; \ +}
[PATCH] video/stm: fix return value handling for of_get_display_timings()
of_get_display_timings() returns NULL on failure, not an error pointer. Fixes: 16fd24847d7a ("video: stmfb: Add device tree support") Signed-off-by: Uwe Kleine-König --- drivers/video/stm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/stm.c b/drivers/video/stm.c index 0c190d36ae9f..d4a618fe5091 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -551,9 +551,9 @@ static int stmfb_probe(struct device_d *hw_dev) } modes = of_get_display_timings(display); - if (IS_ERR(modes)) { + if (!modes) { dev_err(hw_dev, "unable to parse display timings\n"); - return PTR_ERR(modes); + return -EINVAL; } fbi.info.modes.modes = modes->modes; -- 2.23.0 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan}
On 9/4/19 8:53 AM, Sascha Hauer wrote: > On Tue, Aug 27, 2019 at 05:09:08PM +0200, Ahmad Fatoum wrote: >> This series adds undefined behavior and address sanitizer support to >> barebox. Both are fully functional on sandbox, where they are also used >> to implement dump_stack() now. >> >> I haven't yet read about how Kernel AddressSanitizer works, so this one >> only works on sandbox via libasan for now. >> >> The undefined behavior sanitizer depends on the compiler instrumenting >> potential pitfalls and then calling the routines in lib/ubsan.c if it >> catches something undefined, so that should readily work on other arches >> as well. I tested it on sandbox and the i.MX6Q so far. >> >> Eventually, it should be possible to enable it for all the non-PBL stuff >> with a single Kconfig option, but for now you need to explicitly add a >> >> UBSAN_SANITIZE_myfile.o := y >> >> in the respective Makefile. Enabling it wholesale doesn't yet work on >> ARM, I suspect it might be due to binary size. >> >> Changes in v2: >> v1 was incomplete and sent our more by mistake, >> so no changelog. > > Applied, thanks Could you swap patch 08 and 09? Patch 08 depends on the KASAN symbol in the Kconfig option of SANDBOX_UNWIND, but this symbol is introduced in patch 09.. > > Sascha > > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan}
On Tue, Aug 27, 2019 at 05:09:08PM +0200, Ahmad Fatoum wrote: > This series adds undefined behavior and address sanitizer support to > barebox. Both are fully functional on sandbox, where they are also used > to implement dump_stack() now. > > I haven't yet read about how Kernel AddressSanitizer works, so this one > only works on sandbox via libasan for now. > > The undefined behavior sanitizer depends on the compiler instrumenting > potential pitfalls and then calling the routines in lib/ubsan.c if it > catches something undefined, so that should readily work on other arches > as well. I tested it on sandbox and the i.MX6Q so far. > > Eventually, it should be possible to enable it for all the non-PBL stuff > with a single Kconfig option, but for now you need to explicitly add a > > UBSAN_SANITIZE_myfile.o := y > > in the respective Makefile. Enabling it wholesale doesn't yet work on > ARM, I suspect it might be due to binary size. > > Changes in v2: > v1 was incomplete and sent our more by mistake, > so no changelog. Applied, thanks Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox