[cxl-cxl:pending 28/38] drivers/cxl/core/mbox.c:327:5: warning: no previous prototype for function 'cxl_query_cmd'

From: kernel test robot
Date: Fri Aug 13 2021 - 22:51:14 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git pending
head: fa809cc6feedcd2575b63def7135dfaf066266bb
commit: 3ff01745221f15018b58a075e83bdaf807e38d22 [28/38] cxl/mbox: Move mailbox and other non-PCI specific infrastructure to the core
config: s390-randconfig-r013-20210814 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1f7b25ea76a925aca690da28de9d78db7ca99d0c)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git/commit/?id=3ff01745221f15018b58a075e83bdaf807e38d22
git remote add cxl-cxl https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git
git fetch --no-tags cxl-cxl pending
git checkout 3ff01745221f15018b58a075e83bdaf807e38d22
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

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

All warnings (new ones prefixed by >>):

In file included from drivers/cxl/core/mbox.c:3:
In file included from include/linux/io-64-nonatomic-lo-hi.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
^
In file included from drivers/cxl/core/mbox.c:3:
In file included from include/linux/io-64-nonatomic-lo-hi.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
^
In file included from drivers/cxl/core/mbox.c:3:
In file included from include/linux/io-64-nonatomic-lo-hi.h:5:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> drivers/cxl/core/mbox.c:327:5: warning: no previous prototype for function 'cxl_query_cmd' [-Wmissing-prototypes]
int cxl_query_cmd(struct cxl_memdev *cxlmd,
^
drivers/cxl/core/mbox.c:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int cxl_query_cmd(struct cxl_memdev *cxlmd,
^
static
>> drivers/cxl/core/mbox.c:452:5: warning: no previous prototype for function 'cxl_send_cmd' [-Wmissing-prototypes]
int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
^
drivers/cxl/core/mbox.c:452:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
^
static
>> drivers/cxl/core/mbox.c:819:13: warning: no previous prototype for function 'cxl_mbox_init' [-Wmissing-prototypes]
void __init cxl_mbox_init(void)
^
drivers/cxl/core/mbox.c:819:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __init cxl_mbox_init(void)
^
static
>> drivers/cxl/core/mbox.c:829:6: warning: no previous prototype for function 'cxl_mbox_exit' [-Wmissing-prototypes]
void cxl_mbox_exit(void)
^
drivers/cxl/core/mbox.c:829:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void cxl_mbox_exit(void)
^
static
16 warnings generated.


vim +/cxl_query_cmd +327 drivers/cxl/core/mbox.c

326
> 327 int cxl_query_cmd(struct cxl_memdev *cxlmd,
328 struct cxl_mem_query_commands __user *q)
329 {
330 struct device *dev = &cxlmd->dev;
331 struct cxl_mem_command *cmd;
332 u32 n_commands;
333 int j = 0;
334
335 dev_dbg(dev, "Query IOCTL\n");
336
337 if (get_user(n_commands, &q->n_commands))
338 return -EFAULT;
339
340 /* returns the total number if 0 elements are requested. */
341 if (n_commands == 0)
342 return put_user(cxl_cmd_count, &q->n_commands);
343
344 /*
345 * otherwise, return max(n_commands, total commands) cxl_command_info
346 * structures.
347 */
348 cxl_for_each_cmd(cmd) {
349 const struct cxl_command_info *info = &cmd->info;
350
351 if (copy_to_user(&q->commands[j++], info, sizeof(*info)))
352 return -EFAULT;
353
354 if (j == n_commands)
355 break;
356 }
357
358 return 0;
359 }
360
361 /**
362 * handle_mailbox_cmd_from_user() - Dispatch a mailbox command for userspace.
363 * @cxlm: The CXL memory device to communicate with.
364 * @cmd: The validated command.
365 * @in_payload: Pointer to userspace's input payload.
366 * @out_payload: Pointer to userspace's output payload.
367 * @size_out: (Input) Max payload size to copy out.
368 * (Output) Payload size hardware generated.
369 * @retval: Hardware generated return code from the operation.
370 *
371 * Return:
372 * * %0 - Mailbox transaction succeeded. This implies the mailbox
373 * protocol completed successfully not that the operation itself
374 * was successful.
375 * * %-ENOMEM - Couldn't allocate a bounce buffer.
376 * * %-EFAULT - Something happened with copy_to/from_user.
377 * * %-EINTR - Mailbox acquisition interrupted.
378 * * %-EXXX - Transaction level failures.
379 *
380 * Creates the appropriate mailbox command and dispatches it on behalf of a
381 * userspace request. The input and output payloads are copied between
382 * userspace.
383 *
384 * See cxl_send_cmd().
385 */
386 static int handle_mailbox_cmd_from_user(struct cxl_mem *cxlm,
387 const struct cxl_mem_command *cmd,
388 u64 in_payload, u64 out_payload,
389 s32 *size_out, u32 *retval)
390 {
391 struct device *dev = cxlm->dev;
392 struct cxl_mbox_cmd mbox_cmd = {
393 .opcode = cmd->opcode,
394 .size_in = cmd->info.size_in,
395 .size_out = cmd->info.size_out,
396 };
397 int rc;
398
399 if (cmd->info.size_out) {
400 mbox_cmd.payload_out = kvzalloc(cmd->info.size_out, GFP_KERNEL);
401 if (!mbox_cmd.payload_out)
402 return -ENOMEM;
403 }
404
405 if (cmd->info.size_in) {
406 mbox_cmd.payload_in = vmemdup_user(u64_to_user_ptr(in_payload),
407 cmd->info.size_in);
408 if (IS_ERR(mbox_cmd.payload_in)) {
409 kvfree(mbox_cmd.payload_out);
410 return PTR_ERR(mbox_cmd.payload_in);
411 }
412 }
413
414 dev_dbg(dev,
415 "Submitting %s command for user\n"
416 "\topcode: %x\n"
417 "\tsize: %ub\n",
418 cxl_command_names[cmd->info.id].name, mbox_cmd.opcode,
419 cmd->info.size_in);
420
421 dev_WARN_ONCE(dev, cmd->info.id == CXL_MEM_COMMAND_ID_RAW,
422 "raw command path used\n");
423
424 rc = cxlm->mbox_send(cxlm, &mbox_cmd);
425 if (rc)
426 goto out;
427
428 /*
429 * @size_out contains the max size that's allowed to be written back out
430 * to userspace. While the payload may have written more output than
431 * this it will have to be ignored.
432 */
433 if (mbox_cmd.size_out) {
434 dev_WARN_ONCE(dev, mbox_cmd.size_out > *size_out,
435 "Invalid return size\n");
436 if (copy_to_user(u64_to_user_ptr(out_payload),
437 mbox_cmd.payload_out, mbox_cmd.size_out)) {
438 rc = -EFAULT;
439 goto out;
440 }
441 }
442
443 *size_out = mbox_cmd.size_out;
444 *retval = mbox_cmd.return_code;
445
446 out:
447 kvfree(mbox_cmd.payload_in);
448 kvfree(mbox_cmd.payload_out);
449 return rc;
450 }
451
> 452 int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
453 {
454 struct cxl_mem *cxlm = cxlmd->cxlm;
455 struct device *dev = &cxlmd->dev;
456 struct cxl_send_command send;
457 struct cxl_mem_command c;
458 int rc;
459
460 dev_dbg(dev, "Send IOCTL\n");
461
462 if (copy_from_user(&send, s, sizeof(send)))
463 return -EFAULT;
464
465 rc = cxl_validate_cmd_from_user(cxlmd->cxlm, &send, &c);
466 if (rc)
467 return rc;
468
469 /* Prepare to handle a full payload for variable sized output */
470 if (c.info.size_out < 0)
471 c.info.size_out = cxlm->payload_size;
472
473 rc = handle_mailbox_cmd_from_user(cxlm, &c, send.in.payload,
474 send.out.payload, &send.out.size,
475 &send.retval);
476 if (rc)
477 return rc;
478
479 if (copy_to_user(s, &send, sizeof(send)))
480 return -EFAULT;
481
482 return 0;
483 }
484

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

Attachment: .config.gz
Description: application/gzip