linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
@ 2021-07-14 17:55 kernel test robot
  2021-07-14 19:45 ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: kernel test robot @ 2021-07-14 17:55 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: clang-built-linux, kbuild-all, linux-kernel, Thomas Zimmermann,
	Petr Mladek, Andy Shevchenko

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   8096acd7442e613fad0354fc8dfdb2003cceea0b
commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
date:   5 months ago
config: mips-randconfig-r004-20210714 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
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 mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout e927e1e0f0dd3e353d5556503a71484008692c82
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

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

All warnings (new ones prefixed by >>):

>> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           mp->width, mp->height, &mp->pixelformat,
                                                   ^~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                   pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
                                                     ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           &meta->dataformat, meta->buffersize);
                            ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
   3 warnings generated.


vim +303 drivers/media/v4l2-core/v4l2-ioctl.c

   273	
   274	static void v4l_print_format(const void *arg, bool write_only)
   275	{
   276		const struct v4l2_format *p = arg;
   277		const struct v4l2_pix_format *pix;
   278		const struct v4l2_pix_format_mplane *mp;
   279		const struct v4l2_vbi_format *vbi;
   280		const struct v4l2_sliced_vbi_format *sliced;
   281		const struct v4l2_window *win;
   282		const struct v4l2_sdr_format *sdr;
   283		const struct v4l2_meta_format *meta;
   284		u32 planes;
   285		unsigned i;
   286	
   287		pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
   288		switch (p->type) {
   289		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
   290		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
   291			pix = &p->fmt.pix;
   292			pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
   293				pix->width, pix->height, &pix->pixelformat,
   294				prt_names(pix->field, v4l2_field_names),
   295				pix->bytesperline, pix->sizeimage,
   296				pix->colorspace, pix->flags, pix->ycbcr_enc,
   297				pix->quantization, pix->xfer_func);
   298			break;
   299		case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
   300		case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
   301			mp = &p->fmt.pix_mp;
   302			pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
 > 303				mp->width, mp->height, &mp->pixelformat,
   304				prt_names(mp->field, v4l2_field_names),
   305				mp->colorspace, mp->num_planes, mp->flags,
   306				mp->ycbcr_enc, mp->quantization, mp->xfer_func);
   307			planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
   308			for (i = 0; i < planes; i++)
   309				printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
   310						mp->plane_fmt[i].bytesperline,
   311						mp->plane_fmt[i].sizeimage);
   312			break;
   313		case V4L2_BUF_TYPE_VIDEO_OVERLAY:
   314		case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
   315			win = &p->fmt.win;
   316			/* Note: we can't print the clip list here since the clips
   317			 * pointer is a userspace pointer, not a kernelspace
   318			 * pointer. */
   319			pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
   320				win->w.width, win->w.height, win->w.left, win->w.top,
   321				prt_names(win->field, v4l2_field_names),
   322				win->chromakey, win->clipcount, win->clips,
   323				win->bitmap, win->global_alpha);
   324			break;
   325		case V4L2_BUF_TYPE_VBI_CAPTURE:
   326		case V4L2_BUF_TYPE_VBI_OUTPUT:
   327			vbi = &p->fmt.vbi;
   328			pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
   329				vbi->sampling_rate, vbi->offset,
   330				vbi->samples_per_line, &vbi->sample_format,
   331				vbi->start[0], vbi->start[1],
   332				vbi->count[0], vbi->count[1]);
   333			break;
   334		case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
   335		case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
   336			sliced = &p->fmt.sliced;
   337			pr_cont(", service_set=0x%08x, io_size=%d\n",
   338					sliced->service_set, sliced->io_size);
   339			for (i = 0; i < 24; i++)
   340				printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
   341					sliced->service_lines[0][i],
   342					sliced->service_lines[1][i]);
   343			break;
   344		case V4L2_BUF_TYPE_SDR_CAPTURE:
   345		case V4L2_BUF_TYPE_SDR_OUTPUT:
   346			sdr = &p->fmt.sdr;
 > 347			pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
   348			break;
   349		case V4L2_BUF_TYPE_META_CAPTURE:
   350		case V4L2_BUF_TYPE_META_OUTPUT:
   351			meta = &p->fmt.meta;
   352			pr_cont(", dataformat=%p4cc, buffersize=%u\n",
 > 353				&meta->dataformat, meta->buffersize);
   354			break;
   355		}
   356	}
   357	

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

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-07-14 17:55 drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value kernel test robot
@ 2021-07-14 19:45 ` Andy Shevchenko
  2021-07-16 11:41   ` Sakari Ailus
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2021-07-14 19:45 UTC (permalink / raw)
  To: kernel test robot, Nick Desaulniers
  Cc: Sakari Ailus, clang-built-linux, kbuild-all,
	Linux Kernel Mailing List, Thomas Zimmermann, Petr Mladek,
	Andy Shevchenko

+Cc: Nick. Nick, any recommendations on how to fix this in the best
possible way?

On Wed, Jul 14, 2021 at 8:58 PM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   8096acd7442e613fad0354fc8dfdb2003cceea0b
> commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> date:   5 months ago
> config: mips-randconfig-r004-20210714 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
> 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 mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
>                            mp->width, mp->height, &mp->pixelformat,

This seems unsolvable without copying a value.

> >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]

Why is it packed in the first place? Is it used on unaligned addresses
in other structures? But even so, why should it matter?

> >> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
>                            &meta->dataformat, meta->buffersize);

Ditto.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-07-14 19:45 ` Andy Shevchenko
@ 2021-07-16 11:41   ` Sakari Ailus
  2021-07-16 12:12     ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Sakari Ailus @ 2021-07-16 11:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kernel test robot, Nick Desaulniers, clang-built-linux,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek, Andy Shevchenko

Hi Andy,

On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 
> Why is it packed in the first place? Is it used on unaligned addresses
> in other structures? But even so, why should it matter?

It's packed since we wanted to avoid having holes in the structs. There are
other ways to do that but it's ABI dependent and is prone to human errors,
too.

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-07-16 11:41   ` Sakari Ailus
@ 2021-07-16 12:12     ` Andy Shevchenko
  2021-08-19  8:10       ` Sakari Ailus
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2021-07-16 12:12 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: kernel test robot, Nick Desaulniers, clang-built-linux,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek

On Fri, Jul 16, 2021 at 02:41:05PM +0300, Sakari Ailus wrote:
> On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > 
> > Why is it packed in the first place? Is it used on unaligned addresses
> > in other structures? But even so, why should it matter?
> 
> It's packed since we wanted to avoid having holes in the structs. There are
> other ways to do that but it's ABI dependent and is prone to human errors,
> too.

What holes can you think about in the above mention structure?

In case if you are going to extend it you will need anyway changes somewhere
else as well.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-07-16 12:12     ` Andy Shevchenko
@ 2021-08-19  8:10       ` Sakari Ailus
  2021-08-26 13:22         ` Petr Mladek
  0 siblings, 1 reply; 14+ messages in thread
From: Sakari Ailus @ 2021-08-19  8:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kernel test robot, Nick Desaulniers, clang-built-linux,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek

On Fri, Jul 16, 2021 at 03:12:11PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 16, 2021 at 02:41:05PM +0300, Sakari Ailus wrote:
> > On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > 
> > > Why is it packed in the first place? Is it used on unaligned addresses
> > > in other structures? But even so, why should it matter?
> > 
> > It's packed since we wanted to avoid having holes in the structs. There are
> > other ways to do that but it's ABI dependent and is prone to human errors,
> > too.
> 
> What holes can you think about in the above mention structure?

Probably not that one but it has happened in the past that the struct
memory layout has been unintentionally different in different ABIs and that
has not been the intention, but rather a bug. Packing has been added in
newer structs to avoid that.

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-08-19  8:10       ` Sakari Ailus
@ 2021-08-26 13:22         ` Petr Mladek
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Mladek @ 2021-08-26 13:22 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Andy Shevchenko, kernel test robot, Nick Desaulniers,
	clang-built-linux, kbuild-all, Linux Kernel Mailing List,
	Thomas Zimmermann

On Thu 2021-08-19 11:10:53, Sakari Ailus wrote:
> On Fri, Jul 16, 2021 at 03:12:11PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 16, 2021 at 02:41:05PM +0300, Sakari Ailus wrote:
> > > On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > > 

Is there any plan to fix this, please?


> > > > Why is it packed in the first place? Is it used on unaligned addresses
> > > > in other structures? But even so, why should it matter?
> > > 
> > > It's packed since we wanted to avoid having holes in the structs. There are
> > > other ways to do that but it's ABI dependent and is prone to human errors,
> > > too.

> > What holes can you think about in the above mention structure?
> 
> Probably not that one but it has happened in the past that the struct
> memory layout has been unintentionally different in different ABIs and that
> has not been the intention, but rather a bug.

What kind of bugs did the different ABI caused, please? Incompatibly
between 3rd party drivers that were built with different compilers?

I am not familiar with these problems. I wonder if there is a better
solution. I guess that it might be a common problem affecting most
drivers.

Anyway, the non-aligned struct members might create slower code.

> Packing has been added in newer structs to avoid that.

And this smells with cargo-cult programming. People might make all new
structures packed even when it is not really needed.

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
@ 2022-01-17  3:40 kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2022-01-17  3:40 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: llvm, kbuild-all, linux-kernel, Thomas Zimmermann, Petr Mladek,
	Andy Shevchenko

Hi Sakari,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   79e06c4c4950be2abd8ca5d2428a8c915aa62c24
commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
date:   11 months ago
config: mips-randconfig-r002-20220116 (https://download.01.org/0day-ci/archive/20220117/202201171150.wl8T3ge0-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c63a3175c2947e8c1a2d3bbe16a8586600705c54)
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 mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout e927e1e0f0dd3e353d5556503a71484008692c82
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/iio/adc/ drivers/media/v4l2-core/ drivers/usb/gadget/

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

All warnings (new ones prefixed by >>):

>> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           mp->width, mp->height, &mp->pixelformat,
                                                   ^~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                   pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
                                                     ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           &meta->dataformat, meta->buffersize);
                            ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
   3 warnings generated.


vim +303 drivers/media/v4l2-core/v4l2-ioctl.c

   273	
   274	static void v4l_print_format(const void *arg, bool write_only)
   275	{
   276		const struct v4l2_format *p = arg;
   277		const struct v4l2_pix_format *pix;
   278		const struct v4l2_pix_format_mplane *mp;
   279		const struct v4l2_vbi_format *vbi;
   280		const struct v4l2_sliced_vbi_format *sliced;
   281		const struct v4l2_window *win;
   282		const struct v4l2_sdr_format *sdr;
   283		const struct v4l2_meta_format *meta;
   284		u32 planes;
   285		unsigned i;
   286	
   287		pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
   288		switch (p->type) {
   289		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
   290		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
   291			pix = &p->fmt.pix;
   292			pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
   293				pix->width, pix->height, &pix->pixelformat,
   294				prt_names(pix->field, v4l2_field_names),
   295				pix->bytesperline, pix->sizeimage,
   296				pix->colorspace, pix->flags, pix->ycbcr_enc,
   297				pix->quantization, pix->xfer_func);
   298			break;
   299		case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
   300		case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
   301			mp = &p->fmt.pix_mp;
   302			pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
 > 303				mp->width, mp->height, &mp->pixelformat,
   304				prt_names(mp->field, v4l2_field_names),
   305				mp->colorspace, mp->num_planes, mp->flags,
   306				mp->ycbcr_enc, mp->quantization, mp->xfer_func);
   307			planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
   308			for (i = 0; i < planes; i++)
   309				printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
   310						mp->plane_fmt[i].bytesperline,
   311						mp->plane_fmt[i].sizeimage);
   312			break;
   313		case V4L2_BUF_TYPE_VIDEO_OVERLAY:
   314		case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
   315			win = &p->fmt.win;
   316			/* Note: we can't print the clip list here since the clips
   317			 * pointer is a userspace pointer, not a kernelspace
   318			 * pointer. */
   319			pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
   320				win->w.width, win->w.height, win->w.left, win->w.top,
   321				prt_names(win->field, v4l2_field_names),
   322				win->chromakey, win->clipcount, win->clips,
   323				win->bitmap, win->global_alpha);
   324			break;
   325		case V4L2_BUF_TYPE_VBI_CAPTURE:
   326		case V4L2_BUF_TYPE_VBI_OUTPUT:
   327			vbi = &p->fmt.vbi;
   328			pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
   329				vbi->sampling_rate, vbi->offset,
   330				vbi->samples_per_line, &vbi->sample_format,
   331				vbi->start[0], vbi->start[1],
   332				vbi->count[0], vbi->count[1]);
   333			break;
   334		case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
   335		case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
   336			sliced = &p->fmt.sliced;
   337			pr_cont(", service_set=0x%08x, io_size=%d\n",
   338					sliced->service_set, sliced->io_size);
   339			for (i = 0; i < 24; i++)
   340				printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
   341					sliced->service_lines[0][i],
   342					sliced->service_lines[1][i]);
   343			break;
   344		case V4L2_BUF_TYPE_SDR_CAPTURE:
   345		case V4L2_BUF_TYPE_SDR_OUTPUT:
   346			sdr = &p->fmt.sdr;
 > 347			pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
   348			break;
   349		case V4L2_BUF_TYPE_META_CAPTURE:
   350		case V4L2_BUF_TYPE_META_OUTPUT:
   351			meta = &p->fmt.meta;
   352			pr_cont(", dataformat=%p4cc, buffersize=%u\n",
 > 353				&meta->dataformat, meta->buffersize);
   354			break;
   355		}
   356	}
   357	

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2022-01-10 20:49     ` Andy Shevchenko
@ 2022-01-10 21:22       ` Nick Desaulniers
  0 siblings, 0 replies; 14+ messages in thread
From: Nick Desaulniers @ 2022-01-10 21:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kernel test robot, Nick Desaulniers, Sakari Ailus, llvm,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek, Roman Lebedev, Richard Smith

On Mon, Jan 10, 2022 at 12:50 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Mon, Jan 10, 2022 at 11:44:12AM -0800, Nick Desaulniers wrote:
> > On Sun, Jan 9, 2022 at 6:26 AM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > >
> > > +Nick Desaulniers
> > >
> > > Any ideas on how to fix this?
> >
> > Not obviously.
>
> Thanks for looking into this!
>
> > This code probably will trigger a splat when run with
> > UBSan though.
> >
> > I'm curious if the structure needs to be packed for interfacing with
> > hardware or some ABI, or whether we could add an explicit alignment to
> > the member if that would be ok (which may add back some padding)?
>
> Looking into it I think removing packed attribute brings a regression
> immediately on 64-bit platforms since u32 member followed by u8.
>
> > Otherwise, I suspect to actually access this properly we may have
> > macros for performing underaligned loads and stores?  I suspect you'd
> > read potentially unaligned data into an aligned copy, then do
> > operations on that, at which point printing the address of the copy is
> > legal, but perhaps useless.
>
> Current code does this:
>
>         val = *fourcc & ~BIT(31);
>         ...
>         for (i = 0; i < sizeof(*fourcc); i++) {
>         ...
>         strcpy(p, *fourcc & BIT(31) ? " big-endian" : " little-endian");
>         ...
>         p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, sizeof(u32));
>
> If unaligned access is not good it will crash on some architectures AFAIU.
>
> So, it should use get_unaligned() in the first place.

Regardless of your unaligned access patch
(https://lore.kernel.org/lkml/20220110205049.11696-1-andriy.shevchenko@linux.intel.com/),
taking the address of a packed member will still have a warning:
https://godbolt.org/z/8r1rcocPY

So it looks like packing a struct sets the alignment of members to 1,
ie. under-aligning them.  You need to restore the alignment of the
members you plan to take the address of.

ie.

struct w {
  char x, y, z;
} __attribute__((packed));

is equivalent in layout and alignment to:

struct w {
  char __attribute__((aligned(1))) x;
  char __attribute__((aligned(1))) y;
  char __attribute__((aligned(1))) z;
} __attribute__((aligned(1)));

For `struct v4l2_pix_format_mplane` we probably want the trailing
char's to have alignment 1, rather than every member. We can either be
explicit with __aligned(1) on them, or __aligned(4) on the uint
members and retain __packed.

>
> > Perhaps:
> >
> > -       __u32                           pixelformat;
> > +       __u32                           pixelformat __aligned(4);
>
> This looks weird, however I can't immediately see any side effects of it.
> What if the address of the entire structure is unaligned, would we have a
> gap here? In any case I wouldn't go this way.
>
> >         __u32                           field;
> >         __u32                           colorspace;
> >
> > Perhaps we could tighten up this warning in clang; we don't have any
> > holes before this member, so I _wouldn't_ have assumed
> > __attribute__((packed)) would have caused the address of pixelformat
> > member of an instance of struct v4l2_pix_format_mplane to ever be
> > underaligned.
> >
> > > On Sun, Jan 9, 2022 at 3:53 PM kernel test robot <lkp@intel.com> wrote:
> > > >
> > > > Hi Sakari,
> > > >
> > > > FYI, the error/warning still remains.
> > > >
> > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > > head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
> > > > commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> > > > date:   11 months ago
> > > > config: mips-buildonly-randconfig-r002-20220107 (https://download.01.org/0day-ci/archive/20220108/202201081852.uTfBqS4b-lkp@intel.com/config)
> > > > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
> > > > 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 mips cross compiling tool for clang build
> > > >         # apt-get install binutils-mips-linux-gnu
> > > >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
> > > >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > > >         git fetch --no-tags linus master
> > > >         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
> > > >         # save the config file to linux build tree
> > > >         mkdir build_dir
> > > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/media/v4l2-core/ fs/
> > > >
> > > > If you fix the issue, kindly add following tag as appropriate
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > >
> > > > All warnings (new ones prefixed by >>):
> > > >
> > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > >                            mp->width, mp->height, &mp->pixelformat,
> > > >                                                    ^~~~~~~~~~~~~~~
> > > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > > >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> > > >                                    ^~~~~~~~~~~
> > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > >                    pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
> > > >                                                      ^~~~~~~~~~~~~~~~
> > > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > > >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> > > >                                    ^~~~~~~~~~~
> > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > >                            &meta->dataformat, meta->buffersize);
> > > >                             ^~~~~~~~~~~~~~~~
> > > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > > >            printk(KERN_CONT fmt, ##__VA_ARGS__)
>
> --
> With Best Regards,
> Andy Shevchenko
>
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2022-01-10 19:44   ` Nick Desaulniers
@ 2022-01-10 20:49     ` Andy Shevchenko
  2022-01-10 21:22       ` Nick Desaulniers
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2022-01-10 20:49 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: kernel test robot, Nick Desaulniers, Sakari Ailus, llvm,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek, Roman Lebedev, Richard Smith

On Mon, Jan 10, 2022 at 11:44:12AM -0800, Nick Desaulniers wrote:
> On Sun, Jan 9, 2022 at 6:26 AM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > +Nick Desaulniers
> >
> > Any ideas on how to fix this?
> 
> Not obviously.

Thanks for looking into this!

> This code probably will trigger a splat when run with
> UBSan though.
> 
> I'm curious if the structure needs to be packed for interfacing with
> hardware or some ABI, or whether we could add an explicit alignment to
> the member if that would be ok (which may add back some padding)?

Looking into it I think removing packed attribute brings a regression
immediately on 64-bit platforms since u32 member followed by u8.

> Otherwise, I suspect to actually access this properly we may have
> macros for performing underaligned loads and stores?  I suspect you'd
> read potentially unaligned data into an aligned copy, then do
> operations on that, at which point printing the address of the copy is
> legal, but perhaps useless.

Current code does this:

	val = *fourcc & ~BIT(31);
	...
	for (i = 0; i < sizeof(*fourcc); i++) {
	...
	strcpy(p, *fourcc & BIT(31) ? " big-endian" : " little-endian");
	...
	p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, sizeof(u32));

If unaligned access is not good it will crash on some architectures AFAIU.

So, it should use get_unaligned() in the first place.

> Perhaps:
> 
> -       __u32                           pixelformat;
> +       __u32                           pixelformat __aligned(4);

This looks weird, however I can't immediately see any side effects of it.
What if the address of the entire structure is unaligned, would we have a
gap here? In any case I wouldn't go this way.

>         __u32                           field;
>         __u32                           colorspace;
> 
> Perhaps we could tighten up this warning in clang; we don't have any
> holes before this member, so I _wouldn't_ have assumed
> __attribute__((packed)) would have caused the address of pixelformat
> member of an instance of struct v4l2_pix_format_mplane to ever be
> underaligned.
> 
> > On Sun, Jan 9, 2022 at 3:53 PM kernel test robot <lkp@intel.com> wrote:
> > >
> > > Hi Sakari,
> > >
> > > FYI, the error/warning still remains.
> > >
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
> > > commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> > > date:   11 months ago
> > > config: mips-buildonly-randconfig-r002-20220107 (https://download.01.org/0day-ci/archive/20220108/202201081852.uTfBqS4b-lkp@intel.com/config)
> > > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
> > > 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 mips cross compiling tool for clang build
> > >         # apt-get install binutils-mips-linux-gnu
> > >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
> > >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > >         git fetch --no-tags linus master
> > >         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
> > >         # save the config file to linux build tree
> > >         mkdir build_dir
> > >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/media/v4l2-core/ fs/
> > >
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > > >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > >                            mp->width, mp->height, &mp->pixelformat,
> > >                                                    ^~~~~~~~~~~~~~~
> > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> > >                                    ^~~~~~~~~~~
> > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > >                    pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
> > >                                                      ^~~~~~~~~~~~~~~~
> > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> > >                                    ^~~~~~~~~~~
> > > >> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > >                            &meta->dataformat, meta->buffersize);
> > >                             ^~~~~~~~~~~~~~~~
> > >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> > >            printk(KERN_CONT fmt, ##__VA_ARGS__)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2022-01-09 14:26 ` Andy Shevchenko
@ 2022-01-10 19:44   ` Nick Desaulniers
  2022-01-10 20:49     ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Nick Desaulniers @ 2022-01-10 19:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kernel test robot, Nick Desaulniers, Sakari Ailus, llvm,
	kbuild-all, Linux Kernel Mailing List, Thomas Zimmermann,
	Petr Mladek, Andy Shevchenko, Roman Lebedev, Richard Smith

On Sun, Jan 9, 2022 at 6:26 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> +Nick Desaulniers
>
> Any ideas on how to fix this?

Not obviously.  This code probably will trigger a splat when run with
UBSan though.

I'm curious if the structure needs to be packed for interfacing with
hardware or some ABI, or whether we could add an explicit alignment to
the member if that would be ok (which may add back some padding)?
Otherwise, I suspect to actually access this properly we may have
macros for performing underaligned loads and stores?  I suspect you'd
read potentially unaligned data into an aligned copy, then do
operations on that, at which point printing the address of the copy is
legal, but perhaps useless.

Perhaps:

diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index df8b9c486ba1..3bb8d7aaba8a 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -2293,7 +2293,7 @@ struct v4l2_plane_pix_format {
 struct v4l2_pix_format_mplane {
        __u32                           width;
        __u32                           height;
-       __u32                           pixelformat;
+       __u32                           pixelformat __aligned(4);
        __u32                           field;
        __u32                           colorspace;

Perhaps we could tighten up this warning in clang; we don't have any
holes before this member, so I _wouldn't_ have assumed
__attribute__((packed)) would have caused the address of pixelformat
member of an instance of struct v4l2_pix_format_mplane to ever be
underaligned.

>
>
> On Sun, Jan 9, 2022 at 3:53 PM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Sakari,
> >
> > FYI, the error/warning still remains.
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
> > commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> > date:   11 months ago
> > config: mips-buildonly-randconfig-r002-20220107 (https://download.01.org/0day-ci/archive/20220108/202201081852.uTfBqS4b-lkp@intel.com/config)
> > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
> > 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 mips cross compiling tool for clang build
> >         # apt-get install binutils-mips-linux-gnu
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
> >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >         git fetch --no-tags linus master
> >         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
> >         # save the config file to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/media/v4l2-core/ fs/
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
> >                            mp->width, mp->height, &mp->pixelformat,
> >                                                    ^~~~~~~~~~~~~~~
> >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> >                                    ^~~~~~~~~~~
> > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> >                    pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
> >                                                      ^~~~~~~~~~~~~~~~
> >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> >                                    ^~~~~~~~~~~
> > >> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> >                            &meta->dataformat, meta->buffersize);
> >                             ^~~~~~~~~~~~~~~~
> >    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
> >            printk(KERN_CONT fmt, ##__VA_ARGS__)
> >                                    ^~~~~~~~~~~
> >    3 warnings generated.
> >
> >
> > vim +303 drivers/media/v4l2-core/v4l2-ioctl.c
> >
> >    273
> >    274  static void v4l_print_format(const void *arg, bool write_only)
> >    275  {
> >    276          const struct v4l2_format *p = arg;
> >    277          const struct v4l2_pix_format *pix;
> >    278          const struct v4l2_pix_format_mplane *mp;
> >    279          const struct v4l2_vbi_format *vbi;
> >    280          const struct v4l2_sliced_vbi_format *sliced;
> >    281          const struct v4l2_window *win;
> >    282          const struct v4l2_sdr_format *sdr;
> >    283          const struct v4l2_meta_format *meta;
> >    284          u32 planes;
> >    285          unsigned i;
> >    286
> >    287          pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
> >    288          switch (p->type) {
> >    289          case V4L2_BUF_TYPE_VIDEO_CAPTURE:
> >    290          case V4L2_BUF_TYPE_VIDEO_OUTPUT:
> >    291                  pix = &p->fmt.pix;
> >    292                  pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
> >    293                          pix->width, pix->height, &pix->pixelformat,
> >    294                          prt_names(pix->field, v4l2_field_names),
> >    295                          pix->bytesperline, pix->sizeimage,
> >    296                          pix->colorspace, pix->flags, pix->ycbcr_enc,
> >    297                          pix->quantization, pix->xfer_func);
> >    298                  break;
> >    299          case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> >    300          case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> >    301                  mp = &p->fmt.pix_mp;
> >    302                  pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
> >  > 303                          mp->width, mp->height, &mp->pixelformat,
> >    304                          prt_names(mp->field, v4l2_field_names),
> >    305                          mp->colorspace, mp->num_planes, mp->flags,
> >    306                          mp->ycbcr_enc, mp->quantization, mp->xfer_func);
> >    307                  planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
> >    308                  for (i = 0; i < planes; i++)
> >    309                          printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
> >    310                                          mp->plane_fmt[i].bytesperline,
> >    311                                          mp->plane_fmt[i].sizeimage);
> >    312                  break;
> >    313          case V4L2_BUF_TYPE_VIDEO_OVERLAY:
> >    314          case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
> >    315                  win = &p->fmt.win;
> >    316                  /* Note: we can't print the clip list here since the clips
> >    317                   * pointer is a userspace pointer, not a kernelspace
> >    318                   * pointer. */
> >    319                  pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
> >    320                          win->w.width, win->w.height, win->w.left, win->w.top,
> >    321                          prt_names(win->field, v4l2_field_names),
> >    322                          win->chromakey, win->clipcount, win->clips,
> >    323                          win->bitmap, win->global_alpha);
> >    324                  break;
> >    325          case V4L2_BUF_TYPE_VBI_CAPTURE:
> >    326          case V4L2_BUF_TYPE_VBI_OUTPUT:
> >    327                  vbi = &p->fmt.vbi;
> >    328                  pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
> >    329                          vbi->sampling_rate, vbi->offset,
> >    330                          vbi->samples_per_line, &vbi->sample_format,
> >    331                          vbi->start[0], vbi->start[1],
> >    332                          vbi->count[0], vbi->count[1]);
> >    333                  break;
> >    334          case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
> >    335          case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
> >    336                  sliced = &p->fmt.sliced;
> >    337                  pr_cont(", service_set=0x%08x, io_size=%d\n",
> >    338                                  sliced->service_set, sliced->io_size);
> >    339                  for (i = 0; i < 24; i++)
> >    340                          printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
> >    341                                  sliced->service_lines[0][i],
> >    342                                  sliced->service_lines[1][i]);
> >    343                  break;
> >    344          case V4L2_BUF_TYPE_SDR_CAPTURE:
> >    345          case V4L2_BUF_TYPE_SDR_OUTPUT:
> >    346                  sdr = &p->fmt.sdr;
> >  > 347                  pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
> >    348                  break;
> >    349          case V4L2_BUF_TYPE_META_CAPTURE:
> >    350          case V4L2_BUF_TYPE_META_OUTPUT:
> >    351                  meta = &p->fmt.meta;
> >    352                  pr_cont(", dataformat=%p4cc, buffersize=%u\n",
> >  > 353                          &meta->dataformat, meta->buffersize);
> >    354                  break;
> >    355          }
> >    356  }
> >    357
> >
> > ---
> > 0-DAY CI Kernel Test Service, Intel Corporation
> > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2022-01-08 10:33 kernel test robot
@ 2022-01-09 14:26 ` Andy Shevchenko
  2022-01-10 19:44   ` Nick Desaulniers
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2022-01-09 14:26 UTC (permalink / raw)
  To: kernel test robot, Nick Desaulniers
  Cc: Sakari Ailus, llvm, kbuild-all, Linux Kernel Mailing List,
	Thomas Zimmermann, Petr Mladek, Andy Shevchenko

+Nick Desaulniers

Any ideas on how to fix this?


On Sun, Jan 9, 2022 at 3:53 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Sakari,
>
> FYI, the error/warning still remains.
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
> commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> date:   11 months ago
> config: mips-buildonly-randconfig-r002-20220107 (https://download.01.org/0day-ci/archive/20220108/202201081852.uTfBqS4b-lkp@intel.com/config)
> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
> 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 mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/media/v4l2-core/ fs/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
>                            mp->width, mp->height, &mp->pixelformat,
>                                                    ^~~~~~~~~~~~~~~
>    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
>            printk(KERN_CONT fmt, ##__VA_ARGS__)
>                                    ^~~~~~~~~~~
> >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
>                    pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
>                                                      ^~~~~~~~~~~~~~~~
>    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
>            printk(KERN_CONT fmt, ##__VA_ARGS__)
>                                    ^~~~~~~~~~~
> >> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
>                            &meta->dataformat, meta->buffersize);
>                             ^~~~~~~~~~~~~~~~
>    include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
>            printk(KERN_CONT fmt, ##__VA_ARGS__)
>                                    ^~~~~~~~~~~
>    3 warnings generated.
>
>
> vim +303 drivers/media/v4l2-core/v4l2-ioctl.c
>
>    273
>    274  static void v4l_print_format(const void *arg, bool write_only)
>    275  {
>    276          const struct v4l2_format *p = arg;
>    277          const struct v4l2_pix_format *pix;
>    278          const struct v4l2_pix_format_mplane *mp;
>    279          const struct v4l2_vbi_format *vbi;
>    280          const struct v4l2_sliced_vbi_format *sliced;
>    281          const struct v4l2_window *win;
>    282          const struct v4l2_sdr_format *sdr;
>    283          const struct v4l2_meta_format *meta;
>    284          u32 planes;
>    285          unsigned i;
>    286
>    287          pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
>    288          switch (p->type) {
>    289          case V4L2_BUF_TYPE_VIDEO_CAPTURE:
>    290          case V4L2_BUF_TYPE_VIDEO_OUTPUT:
>    291                  pix = &p->fmt.pix;
>    292                  pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
>    293                          pix->width, pix->height, &pix->pixelformat,
>    294                          prt_names(pix->field, v4l2_field_names),
>    295                          pix->bytesperline, pix->sizeimage,
>    296                          pix->colorspace, pix->flags, pix->ycbcr_enc,
>    297                          pix->quantization, pix->xfer_func);
>    298                  break;
>    299          case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
>    300          case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
>    301                  mp = &p->fmt.pix_mp;
>    302                  pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
>  > 303                          mp->width, mp->height, &mp->pixelformat,
>    304                          prt_names(mp->field, v4l2_field_names),
>    305                          mp->colorspace, mp->num_planes, mp->flags,
>    306                          mp->ycbcr_enc, mp->quantization, mp->xfer_func);
>    307                  planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
>    308                  for (i = 0; i < planes; i++)
>    309                          printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
>    310                                          mp->plane_fmt[i].bytesperline,
>    311                                          mp->plane_fmt[i].sizeimage);
>    312                  break;
>    313          case V4L2_BUF_TYPE_VIDEO_OVERLAY:
>    314          case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
>    315                  win = &p->fmt.win;
>    316                  /* Note: we can't print the clip list here since the clips
>    317                   * pointer is a userspace pointer, not a kernelspace
>    318                   * pointer. */
>    319                  pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
>    320                          win->w.width, win->w.height, win->w.left, win->w.top,
>    321                          prt_names(win->field, v4l2_field_names),
>    322                          win->chromakey, win->clipcount, win->clips,
>    323                          win->bitmap, win->global_alpha);
>    324                  break;
>    325          case V4L2_BUF_TYPE_VBI_CAPTURE:
>    326          case V4L2_BUF_TYPE_VBI_OUTPUT:
>    327                  vbi = &p->fmt.vbi;
>    328                  pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
>    329                          vbi->sampling_rate, vbi->offset,
>    330                          vbi->samples_per_line, &vbi->sample_format,
>    331                          vbi->start[0], vbi->start[1],
>    332                          vbi->count[0], vbi->count[1]);
>    333                  break;
>    334          case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
>    335          case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
>    336                  sliced = &p->fmt.sliced;
>    337                  pr_cont(", service_set=0x%08x, io_size=%d\n",
>    338                                  sliced->service_set, sliced->io_size);
>    339                  for (i = 0; i < 24; i++)
>    340                          printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
>    341                                  sliced->service_lines[0][i],
>    342                                  sliced->service_lines[1][i]);
>    343                  break;
>    344          case V4L2_BUF_TYPE_SDR_CAPTURE:
>    345          case V4L2_BUF_TYPE_SDR_OUTPUT:
>    346                  sdr = &p->fmt.sdr;
>  > 347                  pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
>    348                  break;
>    349          case V4L2_BUF_TYPE_META_CAPTURE:
>    350          case V4L2_BUF_TYPE_META_OUTPUT:
>    351                  meta = &p->fmt.meta;
>    352                  pr_cont(", dataformat=%p4cc, buffersize=%u\n",
>  > 353                          &meta->dataformat, meta->buffersize);
>    354                  break;
>    355          }
>    356  }
>    357
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
@ 2022-01-08 10:33 kernel test robot
  2022-01-09 14:26 ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: kernel test robot @ 2022-01-08 10:33 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: llvm, kbuild-all, linux-kernel, Thomas Zimmermann, Petr Mladek,
	Andy Shevchenko

Hi Sakari,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d1587f7bfe9a0f97a75d42ac1489aeda551106bc
commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
date:   11 months ago
config: mips-buildonly-randconfig-r002-20220107 (https://download.01.org/0day-ci/archive/20220108/202201081852.uTfBqS4b-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 32167bfe64a4c5dd4eb3f7a58e24f4cba76f5ac2)
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 mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout e927e1e0f0dd3e353d5556503a71484008692c82
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/hid/ drivers/media/v4l2-core/ fs/

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

All warnings (new ones prefixed by >>):

>> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           mp->width, mp->height, &mp->pixelformat,
                                                   ^~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                   pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
                                                     ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           &meta->dataformat, meta->buffersize);
                            ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
   3 warnings generated.


vim +303 drivers/media/v4l2-core/v4l2-ioctl.c

   273	
   274	static void v4l_print_format(const void *arg, bool write_only)
   275	{
   276		const struct v4l2_format *p = arg;
   277		const struct v4l2_pix_format *pix;
   278		const struct v4l2_pix_format_mplane *mp;
   279		const struct v4l2_vbi_format *vbi;
   280		const struct v4l2_sliced_vbi_format *sliced;
   281		const struct v4l2_window *win;
   282		const struct v4l2_sdr_format *sdr;
   283		const struct v4l2_meta_format *meta;
   284		u32 planes;
   285		unsigned i;
   286	
   287		pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
   288		switch (p->type) {
   289		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
   290		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
   291			pix = &p->fmt.pix;
   292			pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
   293				pix->width, pix->height, &pix->pixelformat,
   294				prt_names(pix->field, v4l2_field_names),
   295				pix->bytesperline, pix->sizeimage,
   296				pix->colorspace, pix->flags, pix->ycbcr_enc,
   297				pix->quantization, pix->xfer_func);
   298			break;
   299		case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
   300		case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
   301			mp = &p->fmt.pix_mp;
   302			pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
 > 303				mp->width, mp->height, &mp->pixelformat,
   304				prt_names(mp->field, v4l2_field_names),
   305				mp->colorspace, mp->num_planes, mp->flags,
   306				mp->ycbcr_enc, mp->quantization, mp->xfer_func);
   307			planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
   308			for (i = 0; i < planes; i++)
   309				printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
   310						mp->plane_fmt[i].bytesperline,
   311						mp->plane_fmt[i].sizeimage);
   312			break;
   313		case V4L2_BUF_TYPE_VIDEO_OVERLAY:
   314		case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
   315			win = &p->fmt.win;
   316			/* Note: we can't print the clip list here since the clips
   317			 * pointer is a userspace pointer, not a kernelspace
   318			 * pointer. */
   319			pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
   320				win->w.width, win->w.height, win->w.left, win->w.top,
   321				prt_names(win->field, v4l2_field_names),
   322				win->chromakey, win->clipcount, win->clips,
   323				win->bitmap, win->global_alpha);
   324			break;
   325		case V4L2_BUF_TYPE_VBI_CAPTURE:
   326		case V4L2_BUF_TYPE_VBI_OUTPUT:
   327			vbi = &p->fmt.vbi;
   328			pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
   329				vbi->sampling_rate, vbi->offset,
   330				vbi->samples_per_line, &vbi->sample_format,
   331				vbi->start[0], vbi->start[1],
   332				vbi->count[0], vbi->count[1]);
   333			break;
   334		case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
   335		case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
   336			sliced = &p->fmt.sliced;
   337			pr_cont(", service_set=0x%08x, io_size=%d\n",
   338					sliced->service_set, sliced->io_size);
   339			for (i = 0; i < 24; i++)
   340				printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
   341					sliced->service_lines[0][i],
   342					sliced->service_lines[1][i]);
   343			break;
   344		case V4L2_BUF_TYPE_SDR_CAPTURE:
   345		case V4L2_BUF_TYPE_SDR_OUTPUT:
   346			sdr = &p->fmt.sdr;
 > 347			pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
   348			break;
   349		case V4L2_BUF_TYPE_META_CAPTURE:
   350		case V4L2_BUF_TYPE_META_OUTPUT:
   351			meta = &p->fmt.meta;
   352			pr_cont(", dataformat=%p4cc, buffersize=%u\n",
 > 353				&meta->dataformat, meta->buffersize);
   354			break;
   355		}
   356	}
   357	

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
  2021-11-04 22:21 kernel test robot
@ 2021-11-05 10:21 ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2021-11-05 10:21 UTC (permalink / raw)
  To: kernel test robot
  Cc: Sakari Ailus, llvm, kbuild-all, Linux Kernel Mailing List,
	Thomas Zimmermann, Petr Mladek, Andy Shevchenko

On Fri, Nov 5, 2021 at 12:24 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   c1e2e0350ce37f633b5ce3ce1cdf4428513fc2a2
> commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
> date:   9 months ago
> config: mips-randconfig-r011-20211101 (attached as .config)
> compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
> 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 mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout e927e1e0f0dd3e353d5556503a71484008692c82
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]

Yeah, I discussed it with Sakari a few months ago. Dunno what is the outcome.
TL;DR: some are easy to fix, i.e. by dropping __packed, the rest needs
more thinking...


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 14+ messages in thread

* drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
@ 2021-11-04 22:21 kernel test robot
  2021-11-05 10:21 ` Andy Shevchenko
  0 siblings, 1 reply; 14+ messages in thread
From: kernel test robot @ 2021-11-04 22:21 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: llvm, kbuild-all, linux-kernel, Thomas Zimmermann, Petr Mladek,
	Andy Shevchenko

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c1e2e0350ce37f633b5ce3ce1cdf4428513fc2a2
commit: e927e1e0f0dd3e353d5556503a71484008692c82 v4l: ioctl: Use %p4cc printk modifier to print FourCC codes
date:   9 months ago
config: mips-randconfig-r011-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
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 mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e927e1e0f0dd3e353d5556503a71484008692c82
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout e927e1e0f0dd3e353d5556503a71484008692c82
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=mips 

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

All warnings (new ones prefixed by >>):

>> drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           mp->width, mp->height, &mp->pixelformat,
                                                   ^~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                   pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
                                                     ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
>> drivers/media/v4l2-core/v4l2-ioctl.c:353:5: warning: taking address of packed member 'dataformat' of class or structure 'v4l2_meta_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
                           &meta->dataformat, meta->buffersize);
                            ^~~~~~~~~~~~~~~~
   include/linux/printk.h:385:26: note: expanded from macro 'pr_cont'
           printk(KERN_CONT fmt, ##__VA_ARGS__)
                                   ^~~~~~~~~~~
   3 warnings generated.


vim +303 drivers/media/v4l2-core/v4l2-ioctl.c

   273	
   274	static void v4l_print_format(const void *arg, bool write_only)
   275	{
   276		const struct v4l2_format *p = arg;
   277		const struct v4l2_pix_format *pix;
   278		const struct v4l2_pix_format_mplane *mp;
   279		const struct v4l2_vbi_format *vbi;
   280		const struct v4l2_sliced_vbi_format *sliced;
   281		const struct v4l2_window *win;
   282		const struct v4l2_sdr_format *sdr;
   283		const struct v4l2_meta_format *meta;
   284		u32 planes;
   285		unsigned i;
   286	
   287		pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
   288		switch (p->type) {
   289		case V4L2_BUF_TYPE_VIDEO_CAPTURE:
   290		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
   291			pix = &p->fmt.pix;
   292			pr_cont(", width=%u, height=%u, pixelformat=%p4cc, field=%s, bytesperline=%u, sizeimage=%u, colorspace=%d, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
   293				pix->width, pix->height, &pix->pixelformat,
   294				prt_names(pix->field, v4l2_field_names),
   295				pix->bytesperline, pix->sizeimage,
   296				pix->colorspace, pix->flags, pix->ycbcr_enc,
   297				pix->quantization, pix->xfer_func);
   298			break;
   299		case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
   300		case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
   301			mp = &p->fmt.pix_mp;
   302			pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n",
 > 303				mp->width, mp->height, &mp->pixelformat,
   304				prt_names(mp->field, v4l2_field_names),
   305				mp->colorspace, mp->num_planes, mp->flags,
   306				mp->ycbcr_enc, mp->quantization, mp->xfer_func);
   307			planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES);
   308			for (i = 0; i < planes; i++)
   309				printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i,
   310						mp->plane_fmt[i].bytesperline,
   311						mp->plane_fmt[i].sizeimage);
   312			break;
   313		case V4L2_BUF_TYPE_VIDEO_OVERLAY:
   314		case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
   315			win = &p->fmt.win;
   316			/* Note: we can't print the clip list here since the clips
   317			 * pointer is a userspace pointer, not a kernelspace
   318			 * pointer. */
   319			pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, chromakey=0x%08x, clipcount=%u, clips=%p, bitmap=%p, global_alpha=0x%02x\n",
   320				win->w.width, win->w.height, win->w.left, win->w.top,
   321				prt_names(win->field, v4l2_field_names),
   322				win->chromakey, win->clipcount, win->clips,
   323				win->bitmap, win->global_alpha);
   324			break;
   325		case V4L2_BUF_TYPE_VBI_CAPTURE:
   326		case V4L2_BUF_TYPE_VBI_OUTPUT:
   327			vbi = &p->fmt.vbi;
   328			pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, sample_format=%p4cc, start=%u,%u, count=%u,%u\n",
   329				vbi->sampling_rate, vbi->offset,
   330				vbi->samples_per_line, &vbi->sample_format,
   331				vbi->start[0], vbi->start[1],
   332				vbi->count[0], vbi->count[1]);
   333			break;
   334		case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
   335		case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
   336			sliced = &p->fmt.sliced;
   337			pr_cont(", service_set=0x%08x, io_size=%d\n",
   338					sliced->service_set, sliced->io_size);
   339			for (i = 0; i < 24; i++)
   340				printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i,
   341					sliced->service_lines[0][i],
   342					sliced->service_lines[1][i]);
   343			break;
   344		case V4L2_BUF_TYPE_SDR_CAPTURE:
   345		case V4L2_BUF_TYPE_SDR_OUTPUT:
   346			sdr = &p->fmt.sdr;
 > 347			pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat);
   348			break;
   349		case V4L2_BUF_TYPE_META_CAPTURE:
   350		case V4L2_BUF_TYPE_META_OUTPUT:
   351			meta = &p->fmt.meta;
   352			pr_cont(", dataformat=%p4cc, buffersize=%u\n",
 > 353				&meta->dataformat, meta->buffersize);
   354			break;
   355		}
   356	}
   357	

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

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-01-17  3:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 17:55 drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value kernel test robot
2021-07-14 19:45 ` Andy Shevchenko
2021-07-16 11:41   ` Sakari Ailus
2021-07-16 12:12     ` Andy Shevchenko
2021-08-19  8:10       ` Sakari Ailus
2021-08-26 13:22         ` Petr Mladek
2021-11-04 22:21 kernel test robot
2021-11-05 10:21 ` Andy Shevchenko
2022-01-08 10:33 kernel test robot
2022-01-09 14:26 ` Andy Shevchenko
2022-01-10 19:44   ` Nick Desaulniers
2022-01-10 20:49     ` Andy Shevchenko
2022-01-10 21:22       ` Nick Desaulniers
2022-01-17  3:40 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).