[Intel-wired-lan] [PATCH iwl-net v2] idpf: avoid compiler padding in virtchnl2_ptype struct
Alexander Lobakin
aleksander.lobakin at intel.com
Mon Jan 8 15:30:27 UTC 2024
From: Pavan Kumar Linga <pavan.kumar.linga at 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
More information about the Intel-wired-lan
mailing list