All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/firmware/google/memconsole-coreboot.c:52:14: warning: Shifting signed 32-bit value by 31 bits is undefined behaviour
@ 2021-02-12 12:16 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-02-12 12:16 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Helge Deller <deller@gmx.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   dcc0b49040c70ad827a7f3d58a21b01fdb14e749
commit: 024f5b597564acced9e69305f7a9ef1202186a61 parisc: Add qemu fw_cfg interface
date:   4 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 4 months ago
compiler: hppa-linux-gcc (GCC) 9.3.0

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


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/firmware/google/memconsole-coreboot.c:52:14: warning: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
    if (flags & OVERFLOW) {
                ^

vim +52 drivers/firmware/google/memconsole-coreboot.c

d384d6f43d1ec3 Thierry Escande 2017-03-28  32  
a5061d028594a3 Julius Werner   2017-05-02  33  /*
a5061d028594a3 Julius Werner   2017-05-02  34   * The cbmem_console structure is read again on every access because it may
a5061d028594a3 Julius Werner   2017-05-02  35   * change at any time if runtime firmware logs new messages. This may rarely
a5061d028594a3 Julius Werner   2017-05-02  36   * lead to race conditions where the firmware overwrites the beginning of the
a5061d028594a3 Julius Werner   2017-05-02  37   * ring buffer with more lines after we have already read |cursor|. It should be
a5061d028594a3 Julius Werner   2017-05-02  38   * rare and harmless enough that we don't spend extra effort working around it.
a5061d028594a3 Julius Werner   2017-05-02  39   */
7918cfc46cfad7 Julius Werner   2017-05-02  40  static ssize_t memconsole_coreboot_read(char *buf, loff_t pos, size_t count)
7918cfc46cfad7 Julius Werner   2017-05-02  41  {
a5061d028594a3 Julius Werner   2017-05-02  42  	u32 cursor = cbmem_console->cursor & CURSOR_MASK;
a5061d028594a3 Julius Werner   2017-05-02  43  	u32 flags = cbmem_console->cursor & ~CURSOR_MASK;
40fbb23881291b Julius Werner   2017-05-23  44  	u32 size = cbmem_console_size;
a5061d028594a3 Julius Werner   2017-05-02  45  	struct seg {	/* describes ring buffer segments in logical order */
a5061d028594a3 Julius Werner   2017-05-02  46  		u32 phys;	/* physical offset from start of mem buffer */
a5061d028594a3 Julius Werner   2017-05-02  47  		u32 len;	/* length of segment */
a5061d028594a3 Julius Werner   2017-05-02  48  	} seg[2] = { {0}, {0} };
a5061d028594a3 Julius Werner   2017-05-02  49  	size_t done = 0;
a5061d028594a3 Julius Werner   2017-05-02  50  	int i;
a5061d028594a3 Julius Werner   2017-05-02  51  
a5061d028594a3 Julius Werner   2017-05-02 @52  	if (flags & OVERFLOW) {
a5061d028594a3 Julius Werner   2017-05-02  53  		if (cursor > size)	/* Shouldn't really happen, but... */
a5061d028594a3 Julius Werner   2017-05-02  54  			cursor = 0;
a5061d028594a3 Julius Werner   2017-05-02  55  		seg[0] = (struct seg){.phys = cursor, .len = size - cursor};
a5061d028594a3 Julius Werner   2017-05-02  56  		seg[1] = (struct seg){.phys = 0, .len = cursor};
a5061d028594a3 Julius Werner   2017-05-02  57  	} else {
a5061d028594a3 Julius Werner   2017-05-02  58  		seg[0] = (struct seg){.phys = 0, .len = min(cursor, size)};
a5061d028594a3 Julius Werner   2017-05-02  59  	}
a5061d028594a3 Julius Werner   2017-05-02  60  
a5061d028594a3 Julius Werner   2017-05-02  61  	for (i = 0; i < ARRAY_SIZE(seg) && count > done; i++) {
a5061d028594a3 Julius Werner   2017-05-02  62  		done += memory_read_from_buffer(buf + done, count - done, &pos,
a5061d028594a3 Julius Werner   2017-05-02  63  			cbmem_console->body + seg[i].phys, seg[i].len);
a5061d028594a3 Julius Werner   2017-05-02  64  		pos -= seg[i].len;
a5061d028594a3 Julius Werner   2017-05-02  65  	}
a5061d028594a3 Julius Werner   2017-05-02  66  	return done;
7918cfc46cfad7 Julius Werner   2017-05-02  67  }
7918cfc46cfad7 Julius Werner   2017-05-02  68  

:::::: The code at line 52 was first introduced by commit
:::::: a5061d028594a31dbf70f4554e0b7d83e5ce770f firmware: google: memconsole: Adapt to new coreboot ring buffer format

:::::: TO: Julius Werner <jwerner@chromium.org>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-12 12:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-12 12:16 drivers/firmware/google/memconsole-coreboot.c:52:14: warning: Shifting signed 32-bit value by 31 bits is undefined behaviour kernel test robot

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.