diff mbox series

[iwl-net] idpf: avoid compiler padding in virtchnl2_ptype struct

Message ID 20231227173757.1743001-1-pavan.kumar.linga@intel.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [iwl-net] idpf: avoid compiler padding in virtchnl2_ptype struct | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers fail 3 blamed authors not CCed: madhu.chittim@intel.com sridhar.samudrala@intel.com anthony.l.nguyen@intel.com; 7 maintainers not CCed: edumazet@google.com jesse.brandeburg@intel.com sridhar.samudrala@intel.com pabeni@redhat.com kuba@kernel.org madhu.chittim@intel.com anthony.l.nguyen@intel.com
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pavan Kumar Linga Dec. 27, 2023, 5:37 p.m. UTC
Config option in arm random config file is causing the compiler
to add padding. Avoid it by using "__packed" structure attribute
for 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>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
---
 drivers/net/ethernet/intel/idpf/virtchnl2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Menzel Dec. 27, 2023, 9:45 p.m. UTC | #1
Dear Pavan,


Thank you for yoru patch.

Am 27.12.23 um 18:37 schrieb Pavan Kumar Linga:
> Config option in arm random config file

Sorry, I do not understand this part of the sentence. What Kconfig 
option was selected exactly causing this behavior.

> is causing the compiler
> to add padding. Avoid it by using "__packed" structure attribute
> for virtchnl2_ptype struct.

Did the compiler emit a warning? If so, please paste it.

> 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>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> ---
>   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);
>   
>   /**

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>



Kind regards,

Paul
Pavan Kumar Linga Dec. 28, 2023, 5:39 p.m. UTC | #2
On 12/27/2023 1:45 PM, Paul Menzel wrote:
> Dear Pavan,
> 
> 
> Thank you for yoru patch.
> 
> Am 27.12.23 um 18:37 schrieb Pavan Kumar Linga:
>> Config option in arm random config file
> 
> Sorry, I do not understand this part of the sentence. What Kconfig 
> option was selected exactly causing this behavior.
> 

Apologies as I couldn't find the config option that was causing this. As 
the driver compilation with arm rand config was failing, posted the fix 
first. Will debug further to find the config option that resulted in 
this failure. Thanks for the review.

>> is causing the compiler
>> to add padding. Avoid it by using "__packed" structure attribute
>> for virtchnl2_ptype struct.
> 
> Did the compiler emit a warning? If so, please paste it.
> 

Here is the compiler error and also will update the commit message with 
the error:

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);
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~

Regards,
Pavan

>> 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>
>> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
>> ---
>>   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);
>>   /**
> 
> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
> 
> 
> 
> Kind regards,
> 
> Paul
Pavan Kumar Linga Jan. 4, 2024, 10:15 p.m. UTC | #3
On 12/28/2023 9:39 AM, Linga, Pavan Kumar wrote:
> 
> 
> On 12/27/2023 1:45 PM, Paul Menzel wrote:
>> Dear Pavan,
>>
>>
>> Thank you for yoru patch.
>>
>> Am 27.12.23 um 18:37 schrieb Pavan Kumar Linga:
>>> Config option in arm random config file
>>
>> Sorry, I do not understand this part of the sentence. What Kconfig 
>> option was selected exactly causing this behavior.
>>
>  > Apologies as I couldn't find the config option that was causing this. As
> the driver compilation with arm rand config was failing, posted the fix 
> first. Will debug further to find the config option that resulted in 
> this failure. Thanks for the review.
>

After further debug, found that the arm random config was using OABI 
(old ABI) which was inferred from the compiler option '-mabi=apcs-gnu'. 
kconfig option 'CONFIG_AEABI' is related to this and was disabled by 
default in the config file.

Static assertion check passed when compiled the driver with 
'CONFIG_AEABI' enabled. The check also passed on explicitly changing the 
compiler option to '-mabi=aapcs-linux'. I will update the commit message 
with this info.

Regards,
Pavan

>>> is causing the compiler
>>> to add padding. Avoid it by using "__packed" structure attribute
>>> for virtchnl2_ptype struct.
>>
>> Did the compiler emit a warning? If so, please paste it.
>>
> 
> Here is the compiler error and also will update the commit message with 
> the error:
> 
> 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);
>           | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Regards,
> Pavan
> 
>>> 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>
>>> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
>>> ---
>>>   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);
>>>   /**
>>
>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>>
>>
>>
>> Kind regards,
>>
>> Paul
>
diff mbox series

Patch

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);
 
 /**