All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning
@ 2022-05-20  5:59 Jakub Kicinski
  2022-05-20 13:06 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-05-20  5:59 UTC (permalink / raw)
  To: davem
  Cc: netdev, edumazet, pabeni, keescook, Jakub Kicinski, nbd, john,
	sean.wang, Mark-MC.Lee, matthias.bgg

GCC 12 gets upset because in mtk_foe_entry_commit_subflow()
this driver allocates a partial structure. The writes are
within bounds.

Silence these warnings for now, our build bot runs GCC 12
so we won't allow any new instances.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: nbd@nbd.name
CC: john@phrozen.org
CC: sean.wang@mediatek.com
CC: Mark-MC.Lee@mediatek.com
CC: matthias.bgg@gmail.com
---
 drivers/net/ethernet/mediatek/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/Makefile b/drivers/net/ethernet/mediatek/Makefile
index 45ba0970504a..611f7b4d4eb8 100644
--- a/drivers/net/ethernet/mediatek/Makefile
+++ b/drivers/net/ethernet/mediatek/Makefile
@@ -11,3 +11,8 @@ mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o
 endif
 obj-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_ops.o
 obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o
+
+# FIXME: temporarily silence -Warray-bounds on non W=1 builds
+ifndef KBUILD_EXTRA_WARN
+CFLAGS_mtk_ppe.o += $(call cc-disable-warning, array-bounds)
+endif
-- 
2.34.3


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

* Re: [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning
  2022-05-20  5:59 [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning Jakub Kicinski
@ 2022-05-20 13:06 ` Andrew Lunn
  2022-05-20 16:43   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2022-05-20 13:06 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, edumazet, pabeni, keescook, nbd, john, sean.wang,
	Mark-MC.Lee, matthias.bgg

On Thu, May 19, 2022 at 10:59:40PM -0700, Jakub Kicinski wrote:
> GCC 12 gets upset because in mtk_foe_entry_commit_subflow()
> this driver allocates a partial structure. The writes are
> within bounds.

I'm wondering if the partial structure is worth it:

struct mtk_flow_entry {
        union {
                struct hlist_node list;
                struct {
                        struct rhash_head l2_node;
                        struct hlist_head l2_flows;
                };
        };
        u8 type;
        s8 wed_index;
        u16 hash;
        union {
                struct mtk_foe_entry data;
                struct {
                        struct mtk_flow_entry *base_flow;
                        struct hlist_node list;
                        struct {} end;
                } l2_data;
        };
        struct rhash_head node;
        unsigned long cookie;
};


It allocates upto l2_data.end

struct rhash contains a single pointer

So this is saving 8 or 16 bytes depending on architecture.

I estimate the structure as a whole is at least 100 bytes on 32bit
systems.

I suppose it might make sense if this makes the allocation go from 129
bytes to <= 128, and the allocater is rounding up to the nearest power
of 2?

	Andrew

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

* Re: [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning
  2022-05-20 13:06 ` Andrew Lunn
@ 2022-05-20 16:43   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-05-20 16:43 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: davem, netdev, edumazet, pabeni, keescook, nbd, john, sean.wang,
	Mark-MC.Lee, matthias.bgg

On Fri, 20 May 2022 15:06:52 +0200 Andrew Lunn wrote:
> On Thu, May 19, 2022 at 10:59:40PM -0700, Jakub Kicinski wrote:
> > GCC 12 gets upset because in mtk_foe_entry_commit_subflow()
> > this driver allocates a partial structure. The writes are
> > within bounds.  
> 
> I'm wondering if the partial structure is worth it:
> 
> struct mtk_flow_entry {
>         union {
>                 struct hlist_node list;
>                 struct {
>                         struct rhash_head l2_node;
>                         struct hlist_head l2_flows;
>                 };
>         };
>         u8 type;
>         s8 wed_index;
>         u16 hash;
>         union {
>                 struct mtk_foe_entry data;
>                 struct {
>                         struct mtk_flow_entry *base_flow;
>                         struct hlist_node list;
>                         struct {} end;
>                 } l2_data;
>         };
>         struct rhash_head node;
>         unsigned long cookie;
> };
> 
> 
> It allocates upto l2_data.end
> 
> struct rhash contains a single pointer
> 
> So this is saving 8 or 16 bytes depending on architecture.
> 
> I estimate the structure as a whole is at least 100 bytes on 32bit
> systems.
> 
> I suppose it might make sense if this makes the allocation go from 129
> bytes to <= 128, and the allocater is rounding up to the nearest power
> of 2?

Good point, I'm not sure what Felix prefers. I think isolating the
necessary fields into a different structure and encapsulating that
into something with the extra two members (or maybe the GROUP_MEMBER
macro thing?) would be another way forward.

I'd still like explicit feedback on the Makefile hack. Is it too ugly?
We could wait for GCC 12 to get its act together was well, but 
I'm guessing Dave and I are not the only people who will upgrade to
Fedora 36 and enter a world of pain...

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

end of thread, other threads:[~2022-05-20 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20  5:59 [PATCH net-next] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning Jakub Kicinski
2022-05-20 13:06 ` Andrew Lunn
2022-05-20 16:43   ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.