* [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct
@ 2024-01-05 1:32 Pavan Kumar Linga
2024-01-05 21:13 ` Simon Horman
2024-01-08 15:30 ` [Intel-wired-lan] " Alexander Lobakin
0 siblings, 2 replies; 3+ messages in thread
From: Pavan Kumar Linga @ 2024-01-05 1:32 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, pmenzel, emil.s.tantilov,
Pavan Kumar Linga, kernel test robot
In the arm random config file, kconfig option 'CONFIG_AEABI' is
disabled which results in adding the compiler flag '-mabi=apcs-gnu'.
This causes the compiler to add padding in virtchnl2_ptype
structure to align it to 8 bytes, resulting in the following
size check failure:
include/linux/build_bug.h:78:41: error: static assertion failed: "(6) == sizeof(struct virtchnl2_ptype)"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
drivers/net/ethernet/intel/idpf/virtchnl2.h:26:9: note: in expansion of macro 'static_assert'
26 | static_assert((n) == sizeof(struct X))
| ^~~~~~~~~~~~~
drivers/net/ethernet/intel/idpf/virtchnl2.h:982:1: note: in expansion of macro 'VIRTCHNL2_CHECK_STRUCT_LEN'
982 | VIRTCHNL2_CHECK_STRUCT_LEN(6, virtchnl2_ptype);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
Avoid the compiler padding by using "__packed" structure
attribute for the virtchnl2_ptype struct.
Fixes: 0d7502a9b4a7 ("virtchnl: add virtchnl version 2 ops")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312220250.ufEm8doQ-lkp@intel.com
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
---
v2:
- add the kconfig option causing the compile failure to the commit message
---
drivers/net/ethernet/intel/idpf/virtchnl2.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/idpf/virtchnl2.h b/drivers/net/ethernet/intel/idpf/virtchnl2.h
index 8dc83788972..dd750e6dcd0 100644
--- a/drivers/net/ethernet/intel/idpf/virtchnl2.h
+++ b/drivers/net/ethernet/intel/idpf/virtchnl2.h
@@ -978,7 +978,7 @@ struct virtchnl2_ptype {
u8 proto_id_count;
__le16 pad;
__le16 proto_id[];
-};
+} __packed;
VIRTCHNL2_CHECK_STRUCT_LEN(6, virtchnl2_ptype);
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct
2024-01-05 1:32 [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct Pavan Kumar Linga
@ 2024-01-05 21:13 ` Simon Horman
2024-01-08 15:30 ` [Intel-wired-lan] " Alexander Lobakin
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-01-05 21:13 UTC (permalink / raw)
To: Pavan Kumar Linga
Cc: intel-wired-lan, netdev, przemyslaw.kitszel, pmenzel,
emil.s.tantilov, kernel test robot
On Thu, Jan 04, 2024 at 05:32:32PM -0800, Pavan Kumar Linga wrote:
> In the arm random config file, kconfig option 'CONFIG_AEABI' is
> disabled which results in adding the compiler flag '-mabi=apcs-gnu'.
> This causes the compiler to add padding in virtchnl2_ptype
> structure to align it to 8 bytes, resulting in the following
> size check failure:
>
> include/linux/build_bug.h:78:41: error: static assertion failed: "(6) == sizeof(struct virtchnl2_ptype)"
> 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> | ^~~~~~~~~~~~~~
> include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
> 77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> | ^~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/idpf/virtchnl2.h:26:9: note: in expansion of macro 'static_assert'
> 26 | static_assert((n) == sizeof(struct X))
> | ^~~~~~~~~~~~~
> drivers/net/ethernet/intel/idpf/virtchnl2.h:982:1: note: in expansion of macro 'VIRTCHNL2_CHECK_STRUCT_LEN'
> 982 | VIRTCHNL2_CHECK_STRUCT_LEN(6, virtchnl2_ptype);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Avoid the compiler padding by using "__packed" structure
> attribute for the virtchnl2_ptype struct.
>
> Fixes: 0d7502a9b4a7 ("virtchnl: add virtchnl version 2 ops")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202312220250.ufEm8doQ-lkp@intel.com
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct
2024-01-05 1:32 [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct Pavan Kumar Linga
2024-01-05 21:13 ` Simon Horman
@ 2024-01-08 15:30 ` Alexander Lobakin
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2024-01-08 15:30 UTC (permalink / raw)
To: Pavan Kumar Linga
Cc: intel-wired-lan, pmenzel, netdev, przemyslaw.kitszel,
emil.s.tantilov
From: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Date: Thu, 4 Jan 2024 17:32:32 -0800
> In the arm random config file, kconfig option 'CONFIG_AEABI' is
> disabled which results in adding the compiler flag '-mabi=apcs-gnu'.
> This causes the compiler to add padding in virtchnl2_ptype
> structure to align it to 8 bytes, resulting in the following
> size check failure:
[...]
> diff --git a/drivers/net/ethernet/intel/idpf/virtchnl2.h b/drivers/net/ethernet/intel/idpf/virtchnl2.h
> index 8dc83788972..dd750e6dcd0 100644
> --- a/drivers/net/ethernet/intel/idpf/virtchnl2.h
> +++ b/drivers/net/ethernet/intel/idpf/virtchnl2.h
> @@ -978,7 +978,7 @@ struct virtchnl2_ptype {
> u8 proto_id_count;
> __le16 pad;
> __le16 proto_id[];
> -};
> +} __packed;
Try using `__packed __aligned(sizeof(__le16))`
(or just `__packed __aligned(2)`) here. It may generate more optimized
code than just __packed, as the latter assumes the structure address in
the memory can be `2n + 1`, while it fact it's aligned to 2 bytes.
(another virtchnl2 design fail anyway :D)
> VIRTCHNL2_CHECK_STRUCT_LEN(6, virtchnl2_ptype);
>
> /**
Thanks,
Olek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-08 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-05 1:32 [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct Pavan Kumar Linga
2024-01-05 21:13 ` Simon Horman
2024-01-08 15:30 ` [Intel-wired-lan] " Alexander Lobakin
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).