All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH 1/2] remoteproc: elf: support platform specific memory hook
Date: Wed, 29 Jul 2020 00:51:02 +0800	[thread overview]
Message-ID: <202007290035.Tb4gocUu%lkp@intel.com> (raw)
In-Reply-To: <1595928673-26306-1-git-send-email-peng.fan@nxp.com>

[-- Attachment #1: Type: text/plain, Size: 8441 bytes --]

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on linus/master v5.8-rc7 next-20200728]
[cannot apply to xlnx/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/peng-fan-nxp-com/remoteproc-elf-support-platform-specific-memory-hook/20200728-173920
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: i386-randconfig-s001-20200728 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-94-geb6779f6-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/remoteproc/remoteproc_elf_loader.c: In function 'rproc_elf_memcpy':
>> drivers/remoteproc/remoteproc_elf_loader.c:137:51: error: macro "memcpy" passed 4 arguments, but takes just 3
     137 |  return rproc->ops->memcpy(rproc, dest, src, count);
         |                                                   ^
   In file included from arch/x86/include/asm/string.h:3,
                    from include/linux/string.h:20,
                    from arch/x86/include/asm/page_32.h:35,
                    from arch/x86/include/asm/page.h:14,
                    from arch/x86/include/asm/thread_info.h:12,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from drivers/remoteproc/remoteproc_elf_loader.c:20:
   arch/x86/include/asm/string_32.h:182: note: macro "memcpy" defined here
     182 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
         | 
   drivers/remoteproc/remoteproc_elf_loader.c: In function 'rproc_elf_memset':
>> drivers/remoteproc/remoteproc_elf_loader.c:145:46: error: macro "memset" passed 4 arguments, but takes just 3
     145 |  return rproc->ops->memset(rproc, s, c, count);
         |                                              ^
   In file included from arch/x86/include/asm/string.h:3,
                    from include/linux/string.h:20,
                    from arch/x86/include/asm/page_32.h:35,
                    from arch/x86/include/asm/page.h:14,
                    from arch/x86/include/asm/thread_info.h:12,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from drivers/remoteproc/remoteproc_elf_loader.c:20:
   arch/x86/include/asm/string_32.h:228: note: macro "memset" defined here
     228 | #define memset(s, c, count) __builtin_memset(s, c, count)
         | 

sparse warnings: (new ones prefixed by >>)

>> drivers/remoteproc/remoteproc_elf_loader.c:137:28: sparse: sparse: macro "memcpy" passed 4 arguments, but takes just 3
>> drivers/remoteproc/remoteproc_elf_loader.c:145:28: sparse: sparse: macro "memset" passed 4 arguments, but takes just 3

vim +/memcpy +137 drivers/remoteproc/remoteproc_elf_loader.c

    19	
  > 20	#include <linux/module.h>
    21	#include <linux/firmware.h>
    22	#include <linux/remoteproc.h>
    23	#include <linux/elf.h>
    24	
    25	#include "remoteproc_internal.h"
    26	#include "remoteproc_elf_helpers.h"
    27	
    28	/**
    29	 * rproc_elf_sanity_check() - Sanity Check for ELF32/ELF64 firmware image
    30	 * @rproc: the remote processor handle
    31	 * @fw: the ELF firmware image
    32	 *
    33	 * Make sure this fw image is sane (ie a correct ELF32/ELF64 file).
    34	 */
    35	int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw)
    36	{
    37		const char *name = rproc->firmware;
    38		struct device *dev = &rproc->dev;
    39		/*
    40		 * Elf files are beginning with the same structure. Thus, to simplify
    41		 * header parsing, we can use the elf32_hdr one for both elf64 and
    42		 * elf32.
    43		 */
    44		struct elf32_hdr *ehdr;
    45		u32 elf_shdr_get_size;
    46		u64 phoff, shoff;
    47		char class;
    48		u16 phnum;
    49	
    50		if (!fw) {
    51			dev_err(dev, "failed to load %s\n", name);
    52			return -EINVAL;
    53		}
    54	
    55		if (fw->size < sizeof(struct elf32_hdr)) {
    56			dev_err(dev, "Image is too small\n");
    57			return -EINVAL;
    58		}
    59	
    60		ehdr = (struct elf32_hdr *)fw->data;
    61	
    62		if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) {
    63			dev_err(dev, "Image is corrupted (bad magic)\n");
    64			return -EINVAL;
    65		}
    66	
    67		class = ehdr->e_ident[EI_CLASS];
    68		if (class != ELFCLASS32 && class != ELFCLASS64) {
    69			dev_err(dev, "Unsupported class: %d\n", class);
    70			return -EINVAL;
    71		}
    72	
    73		if (class == ELFCLASS64 && fw->size < sizeof(struct elf64_hdr)) {
    74			dev_err(dev, "elf64 header is too small\n");
    75			return -EINVAL;
    76		}
    77	
    78		/* We assume the firmware has the same endianness as the host */
    79	# ifdef __LITTLE_ENDIAN
    80		if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
    81	# else /* BIG ENDIAN */
    82		if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) {
    83	# endif
    84			dev_err(dev, "Unsupported firmware endianness\n");
    85			return -EINVAL;
    86		}
    87	
    88		phoff = elf_hdr_get_e_phoff(class, fw->data);
    89		shoff = elf_hdr_get_e_shoff(class, fw->data);
    90		phnum =  elf_hdr_get_e_phnum(class, fw->data);
    91		elf_shdr_get_size = elf_size_of_shdr(class);
    92	
    93		if (fw->size < shoff + elf_shdr_get_size) {
    94			dev_err(dev, "Image is too small\n");
    95			return -EINVAL;
    96		}
    97	
    98		if (phnum == 0) {
    99			dev_err(dev, "No loadable segments\n");
   100			return -EINVAL;
   101		}
   102	
   103		if (phoff > fw->size) {
   104			dev_err(dev, "Firmware size is too small\n");
   105			return -EINVAL;
   106		}
   107	
   108		dev_dbg(dev, "Firmware is an elf%d file\n",
   109			class == ELFCLASS32 ? 32 : 64);
   110	
   111		return 0;
   112	}
   113	EXPORT_SYMBOL(rproc_elf_sanity_check);
   114	
   115	/**
   116	 * rproc_elf_get_boot_addr() - Get rproc's boot address.
   117	 * @rproc: the remote processor handle
   118	 * @fw: the ELF firmware image
   119	 *
   120	 * This function returns the entry point address of the ELF
   121	 * image.
   122	 *
   123	 * Note that the boot address is not a configurable property of all remote
   124	 * processors. Some will always boot at a specific hard-coded address.
   125	 */
   126	u64 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
   127	{
   128		return elf_hdr_get_e_entry(fw_elf_get_class(fw), fw->data);
   129	}
   130	EXPORT_SYMBOL(rproc_elf_get_boot_addr);
   131	
   132	static void *rproc_elf_memcpy(struct rproc *rproc, void *dest, const void *src, size_t count)
   133	{
   134		if (!rproc->ops->memcpy)
   135			return memcpy(dest, src, count);
   136	
 > 137		return rproc->ops->memcpy(rproc, dest, src, count);
   138	}
   139	
   140	static void *rproc_elf_memset(struct rproc *rproc, void *s, int c, size_t count)
   141	{
   142		if (!rproc->ops->memset)
   143			return memset(s, c, count);
   144	
 > 145		return rproc->ops->memset(rproc, s, c, count);
   146	}
   147	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33288 bytes --]

  parent reply	other threads:[~2020-07-28 16:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28  9:31 [PATCH 1/2] remoteproc: elf: support platform specific memory hook peng.fan
2020-07-28  9:31 ` peng.fan
2020-07-28  9:31 ` [PATCH 2/2] remoteproc: imx_rproc: add elf memory hooks peng.fan
2020-07-28  9:31   ` peng.fan
2020-07-28 20:25   ` kernel test robot
2020-08-01  4:37   ` Oleksij Rempel
2020-08-01  4:37     ` Oleksij Rempel
2020-08-11 22:46   ` Mathieu Poirier
2020-08-11 22:46     ` Mathieu Poirier
2020-07-28 16:51 ` kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-07-28  9:29 [PATCH 1/2] remoteproc: elf: support platform specific memory hook peng.fan
2020-07-28  9:29 ` peng.fan

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=202007290035.Tb4gocUu%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.