* [dpdk-dev] [PATCH] net/ice/base: fix build error for GCC 4.8.5
@ 2021-10-05 11:57 Aman Singh
2021-10-05 13:57 ` David Marchand
0 siblings, 1 reply; 4+ messages in thread
From: Aman Singh @ 2021-10-05 11:57 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, stable
Code changes done for build issue as reported in Bug 817
error: dereferencing type-punned pointer will break strict-aliasing rules.
added union to avoid pointer dereferencing
Fixes: 39925373a333 ("net/ice/base: add parser execution main loop")
Cc: stable@dpdk.org
Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
---
drivers/net/ice/base/ice_parser_rt.c | 36 +++++++++++++++-------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ice/base/ice_parser_rt.c b/drivers/net/ice/base/ice_parser_rt.c
index 7a44675737..eb35ad0bc0 100644
--- a/drivers/net/ice/base/ice_parser_rt.c
+++ b/drivers/net/ice/base/ice_parser_rt.c
@@ -187,21 +187,23 @@ static u32 _bit_rev_u32(u32 v, int len)
static u32 _hv_bit_sel(struct ice_parser_rt *rt, int start, int len)
{
- u64 d64, msk;
- u8 b[8];
+ u64 msk;
+ union {
+ u64 d64;
+ u8 b[8];
+ } bit_sel;
int i;
int offset = GPR_HB_IDX + start / 16;
- ice_memcpy(b, &rt->gpr[offset], 8, ICE_NONDMA_TO_NONDMA);
+ ice_memcpy(bit_sel.b, &rt->gpr[offset], 8, ICE_NONDMA_TO_NONDMA);
for (i = 0; i < 8; i++)
- b[i] = _bit_rev_u8(b[i]);
+ bit_sel.b[i] = _bit_rev_u8(bit_sel.b[i]);
- d64 = *(u64 *)&b[0];
msk = (1ul << len) - 1;
- return _bit_rev_u32((u32)((d64 >> (start % 16)) & msk), len);
+ return _bit_rev_u32((u32)((bit_sel.d64 >> (start % 16)) & msk), len);
}
static u32 _pk_build(struct ice_parser_rt *rt, struct ice_np_keybuilder *kb)
@@ -444,21 +446,23 @@ static void _po_update(struct ice_parser_rt *rt, struct ice_alu *alu)
static u16 _reg_bit_sel(struct ice_parser_rt *rt, int reg_idx,
int start, int len)
{
- u32 d32, msk;
- u8 b[4];
- u8 v[4];
+ u32 msk;
+ union {
+ u32 d32;
+ u8 b[4];
+ } bit_sel;
- ice_memcpy(b, &rt->gpr[reg_idx + start / 16], 4, ICE_NONDMA_TO_NONDMA);
+ ice_memcpy(bit_sel.b, &rt->gpr[reg_idx + start / 16], 4,
+ ICE_NONDMA_TO_NONDMA);
- v[0] = _bit_rev_u8(b[0]);
- v[1] = _bit_rev_u8(b[1]);
- v[2] = _bit_rev_u8(b[2]);
- v[3] = _bit_rev_u8(b[3]);
+ bit_sel.b[0] = _bit_rev_u8(bit_sel.b[0]);
+ bit_sel.b[1] = _bit_rev_u8(bit_sel.b[1]);
+ bit_sel.b[2] = _bit_rev_u8(bit_sel.b[2]);
+ bit_sel.b[3] = _bit_rev_u8(bit_sel.b[3]);
- d32 = *(u32 *)&v[0];
msk = (1u << len) - 1;
- return _bit_rev_u16((u16)((d32 >> (start % 16)) & msk), len);
+ return _bit_rev_u16((u16)((bit_sel.d32 >> (start % 16)) & msk), len);
}
static void _err_add(struct ice_parser_rt *rt, int idx, bool val)
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ice/base: fix build error for GCC 4.8.5
2021-10-05 11:57 [dpdk-dev] [PATCH] net/ice/base: fix build error for GCC 4.8.5 Aman Singh
@ 2021-10-05 13:57 ` David Marchand
2021-10-05 14:19 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2021-10-05 13:57 UTC (permalink / raw)
To: Aman Singh, Yigit, Ferruh; +Cc: dev, dpdk stable, Qi Zhang
On Tue, Oct 5, 2021 at 2:07 PM Aman Singh <aman.deep.singh@intel.com> wrote:
>
> Code changes done for build issue as reported in Bug 817
> error: dereferencing type-punned pointer will break strict-aliasing rules.
> added union to avoid pointer dereferencing
>
About the title, Ali reproduced the issue with other versions of gcc.
This patch touches base/ code, is Intel ok with this?
Else, we could consider disabling strict aliasing for the base driver, like
$ git grep alias '**/base/meson.build'
drivers/net/fm10k/base/meson.build: '-Wno-strict-aliasing',
'-Wno-format-extra-args',
drivers/net/i40e/base/meson.build: '-Wno-strict-aliasing',
'-Wno-unused-but-set-variable',
drivers/net/qede/base/meson.build: '-Wno-strict-aliasing',
Bugzilla ID: 817
> Fixes: 39925373a333 ("net/ice/base: add parser execution main loop")
No Cc: stable, this is a regression in main.
> Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
Tested-by: David Marchand <david.marchand@redhat.com>
--
David Marchand
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] net/ice/base: fix build error for GCC 4.8.5
2021-10-05 13:57 ` David Marchand
@ 2021-10-05 14:19 ` Ferruh Yigit
2021-10-05 14:50 ` David Marchand
0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2021-10-05 14:19 UTC (permalink / raw)
To: David Marchand, Aman Singh; +Cc: dev, dpdk stable, Qi Zhang, Beilei Xing
On 10/5/2021 2:57 PM, David Marchand wrote:
> On Tue, Oct 5, 2021 at 2:07 PM Aman Singh <aman.deep.singh@intel.com> wrote:
>>
>> Code changes done for build issue as reported in Bug 817
>> error: dereferencing type-punned pointer will break strict-aliasing rules.
>> added union to avoid pointer dereferencing
>>
>
> About the title, Ali reproduced the issue with other versions of gcc.
>
> This patch touches base/ code, is Intel ok with this?
> Else, we could consider disabling strict aliasing for the base driver, like
> $ git grep alias '**/base/meson.build'
> drivers/net/fm10k/base/meson.build: '-Wno-strict-aliasing',
> '-Wno-format-extra-args',
> drivers/net/i40e/base/meson.build: '-Wno-strict-aliasing',
> '-Wno-unused-but-set-variable',
> drivers/net/qede/base/meson.build: '-Wno-strict-aliasing',
>
It has some complications to update the shared code from the DPDK, but for this
case the fix seems simple and valid, so I am for getting the fix and work on to
propagate the fix to the shared code, instead of disable the warning directly.
Mainly Qi and Beilei will be managing the shared code part, if shared code
comes with different solution, we can send an incremental patch to replace
this fix.
Briefly I am for getting the patch, hence:
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
> Bugzilla ID: 817
>
>> Fixes: 39925373a333 ("net/ice/base: add parser execution main loop")
>
> No Cc: stable, this is a regression in main.
>
>> Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
>
> Tested-by: David Marchand <david.marchand@redhat.com>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] net/ice/base: fix build error for GCC 4.8.5
2021-10-05 14:19 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
@ 2021-10-05 14:50 ` David Marchand
0 siblings, 0 replies; 4+ messages in thread
From: David Marchand @ 2021-10-05 14:50 UTC (permalink / raw)
To: Ferruh Yigit, Qi Zhang, Aman Singh, Beilei Xing; +Cc: dev
On Tue, Oct 5, 2021 at 4:24 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> On 10/5/2021 2:57 PM, David Marchand wrote:
> > On Tue, Oct 5, 2021 at 2:07 PM Aman Singh <aman.deep.singh@intel.com> wrote:
> >>
> >> Code changes done for build issue as reported in Bug 817
> >> error: dereferencing type-punned pointer will break strict-aliasing rules.
> >> added union to avoid pointer dereferencing
> >
> > Bugzilla ID: 817
> >> Fixes: 39925373a333 ("net/ice/base: add parser execution main loop")
> >
> >> Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
> > Tested-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-05 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 11:57 [dpdk-dev] [PATCH] net/ice/base: fix build error for GCC 4.8.5 Aman Singh
2021-10-05 13:57 ` David Marchand
2021-10-05 14:19 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2021-10-05 14:50 ` David Marchand
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).