linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtchnl: Add missing padding to virtchnl_proto_hdrs
@ 2021-05-19 19:43 Geert Uytterhoeven
  2021-05-19 22:16 ` Jesse Brandeburg
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2021-05-19 19:43 UTC (permalink / raw)
  To: Qi Zhang, Jesse Brandeburg, Tony Nguyen, Yahui Cao, Beilei Xing,
	Simei Su, Jeff Guo, David S . Miller, Jakub Kicinski
  Cc: intel-wired-lan, netdev, linux-kernel, Geert Uytterhoeven,
	kernel test robot

On m68k (Coldfire M547x):

      CC      drivers/net/ethernet/intel/i40e/i40e_main.o
    In file included from drivers/net/ethernet/intel/i40e/i40e_prototype.h:9,
		     from drivers/net/ethernet/intel/i40e/i40e.h:41,
		     from drivers/net/ethernet/intel/i40e/i40e_main.c:12:
    include/linux/avf/virtchnl.h:153:36: warning: division by zero [-Wdiv-by-zero]
      153 |  { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
	  |                                    ^
    include/linux/avf/virtchnl.h:844:1: note: in expansion of macro ‘VIRTCHNL_CHECK_STRUCT_LEN’
      844 | VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
	  | ^~~~~~~~~~~~~~~~~~~~~~~~~
    include/linux/avf/virtchnl.h:844:33: error: enumerator value for ‘virtchnl_static_assert_virtchnl_proto_hdrs’ is not an integer constant
      844 | VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
	  |                                 ^~~~~~~~~~~~~~~~~~~

On m68k, integers are aligned on addresses that are multiples of two,
not four, bytes.  Hence the size of a structure containing integers may
not be divisible by 4.

Fix this by adding explicit padding.

Fixes: 1f7ea1cd6a374842 ("ice: Enable FDIR Configure for AVF")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
 include/linux/avf/virtchnl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/avf/virtchnl.h b/include/linux/avf/virtchnl.h
index 565deea6ffe88b99..8612f8fc86c1db21 100644
--- a/include/linux/avf/virtchnl.h
+++ b/include/linux/avf/virtchnl.h
@@ -830,6 +830,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
+	u8 pad[3];
 	/**
 	 * specify where protocol header start from.
 	 * 0 - from the outer layer
-- 
2.25.1


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

* Re: [PATCH] virtchnl: Add missing padding to virtchnl_proto_hdrs
  2021-05-19 19:43 [PATCH] virtchnl: Add missing padding to virtchnl_proto_hdrs Geert Uytterhoeven
@ 2021-05-19 22:16 ` Jesse Brandeburg
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Brandeburg @ 2021-05-19 22:16 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Qi Zhang, Tony Nguyen, Yahui Cao, Beilei Xing, Simei Su,
	Jeff Guo, David S . Miller, Jakub Kicinski, intel-wired-lan,
	netdev, linux-kernel, kernel test robot

Geert Uytterhoeven wrote:

> On m68k (Coldfire M547x):
> 
>       CC      drivers/net/ethernet/intel/i40e/i40e_main.o
>     In file included from drivers/net/ethernet/intel/i40e/i40e_prototype.h:9,
> 		     from drivers/net/ethernet/intel/i40e/i40e.h:41,
> 		     from drivers/net/ethernet/intel/i40e/i40e_main.c:12:
>     include/linux/avf/virtchnl.h:153:36: warning: division by zero [-Wdiv-by-zero]
>       153 |  { virtchnl_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) }
> 	  |                                    ^
>     include/linux/avf/virtchnl.h:844:1: note: in expansion of macro ‘VIRTCHNL_CHECK_STRUCT_LEN’
>       844 | VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
> 	  | ^~~~~~~~~~~~~~~~~~~~~~~~~
>     include/linux/avf/virtchnl.h:844:33: error: enumerator value for ‘virtchnl_static_assert_virtchnl_proto_hdrs’ is not an integer constant
>       844 | VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
> 	  |                                 ^~~~~~~~~~~~~~~~~~~
> 
> On m68k, integers are aligned on addresses that are multiples of two,
> not four, bytes.  Hence the size of a structure containing integers may
> not be divisible by 4.
> 
> Fix this by adding explicit padding.

Thanks Geert, I checked and x86_64 adds this padding anyway, so doesn't
result in any functional changes AFAICS. In any case, this is more
correct for a structure that is part of an API (no implicit padding!)

BTW. the patch subject is a little wrong, should have been
[PATCH net]

But I think Tony can take care of that when sending to netdev list,
unless you want to send a v2.
 
> Fixes: 1f7ea1cd6a374842 ("ice: Enable FDIR Configure for AVF")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Compile-tested only.

Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>

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

end of thread, other threads:[~2021-05-19 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 19:43 [PATCH] virtchnl: Add missing padding to virtchnl_proto_hdrs Geert Uytterhoeven
2021-05-19 22:16 ` Jesse Brandeburg

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).