* [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload
@ 2023-06-19 9:12 Arnd Bergmann
2023-06-19 9:12 ` [PATCH 2/3] [v2] sfc: fix uninitialized variable use Arnd Bergmann
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Arnd Bergmann @ 2023-06-19 9:12 UTC (permalink / raw)
To: Edward Cree, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman,
Pieter Jansen van Vuuren
Cc: Arnd Bergmann, Jiri Pirko, Alejandro Lucero, netdev,
linux-net-drivers, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The driver now fails to link when CONFIG_INET is disabled, so
add an explicit Kconfig dependency:
ld.lld: error: undefined symbol: ip_route_output_flow
>>> referenced by tc_encap_actions.c
>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.a
ld.lld: error: undefined symbol: ip_send_check
>>> referenced by tc_encap_actions.c
>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
>>> referenced by tc_encap_actions.c
>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
ld.lld: error: undefined symbol: arp_tbl
>>> referenced by tc_encap_actions.c
>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
>>> referenced by tc_encap_actions.c
>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
Fixes: a1e82162af0b8 ("sfc: generate encap headers for TC offload")
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202306151656.yttECVTP-lkp@intel.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: add Fixes and Closes tags
---
drivers/net/ethernet/sfc/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index 4af36ba8906ba..3eb55dcfa8a61 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -50,6 +50,7 @@ config SFC_MCDI_MON
config SFC_SRIOV
bool "Solarflare SFC9100-family SR-IOV support"
depends on SFC && PCI_IOV
+ depends on INET
default y
help
This enables support for the Single Root I/O Virtualization
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] [v2] sfc: fix uninitialized variable use
2023-06-19 9:12 [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Arnd Bergmann
@ 2023-06-19 9:12 ` Arnd Bergmann
2023-06-19 10:06 ` Edward Cree
2023-06-19 9:12 ` [PATCH 3/3] sfc: selftest: fix struct packing Arnd Bergmann
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2023-06-19 9:12 UTC (permalink / raw)
To: Edward Cree, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Pieter Jansen van Vuuren,
Simon Horman
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The new efx_bind_neigh() function contains a broken code path when IPV6 is
disabled:
drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (encap->type & EFX_ENCAP_FLAG_IPV6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here
if (!n) {
^
drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false
if (encap->type & EFX_ENCAP_FLAG_IPV6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning
struct neighbour *n;
^
= NULL
Change it to use the existing error handling path here.
Fixes: 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload")
Suggested-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use 'goto' instead of incorrectly entering another error path
---
drivers/net/ethernet/sfc/tc_encap_actions.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/sfc/tc_encap_actions.c b/drivers/net/ethernet/sfc/tc_encap_actions.c
index aac259528e73e..7e8bcdb222ad1 100644
--- a/drivers/net/ethernet/sfc/tc_encap_actions.c
+++ b/drivers/net/ethernet/sfc/tc_encap_actions.c
@@ -164,6 +164,7 @@ static int efx_bind_neigh(struct efx_nic *efx,
*/
rc = -EOPNOTSUPP;
NL_SET_ERR_MSG_MOD(extack, "No IPv6 support (neigh bind)");
+ goto out_free;
#endif
} else {
rt = ip_route_output_key(net, &flow4);
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-19 9:12 [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Arnd Bergmann
2023-06-19 9:12 ` [PATCH 2/3] [v2] sfc: fix uninitialized variable use Arnd Bergmann
@ 2023-06-19 9:12 ` Arnd Bergmann
2023-06-19 10:25 ` Edward Cree
2023-06-19 10:04 ` [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Edward Cree
2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2023-06-19 9:12 UTC (permalink / raw)
To: Edward Cree, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Three of the sfc drivers define a packed loopback_payload structure with an
ethernet header followed by an IP header. However, the kernel definition
of iphdr specifies that this is 4-byte aligned, causing a W=1 warning:
net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
struct iphdr ip;
As the iphdr packing is not easily changed without breaking other code,
change the three structures to use a local definition instead.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++-
drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++-
drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++-
3 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c
index 6a454ac6f8763..fb7fcd27a33a5 100644
--- a/drivers/net/ethernet/sfc/falcon/selftest.c
+++ b/drivers/net/ethernet/sfc/falcon/selftest.c
@@ -40,7 +40,26 @@
*/
struct ef4_loopback_payload {
struct ethhdr header;
- struct iphdr ip;
+ struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+ __u8 ihl:4,
+ version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+ __u8 version:4,
+ ihl:4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __u8 tos;
+ __be16 tot_len;
+ __be16 id;
+ __be16 frag_off;
+ __u8 ttl;
+ __u8 protocol;
+ __sum16 check;
+ __be32 saddr;
+ __be32 daddr;
+ } __packed ip; /* unaligned struct iphdr */
struct udphdr udp;
__be16 iteration;
char msg[64];
diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c
index 3c5227afd4977..440a57953779c 100644
--- a/drivers/net/ethernet/sfc/selftest.c
+++ b/drivers/net/ethernet/sfc/selftest.c
@@ -43,7 +43,26 @@
*/
struct efx_loopback_payload {
struct ethhdr header;
- struct iphdr ip;
+ struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+ __u8 ihl:4,
+ version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+ __u8 version:4,
+ ihl:4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __u8 tos;
+ __be16 tot_len;
+ __be16 id;
+ __be16 frag_off;
+ __u8 ttl;
+ __u8 protocol;
+ __sum16 check;
+ __be32 saddr;
+ __be32 daddr;
+ } __packed ip; /* unaligned struct iphdr */
struct udphdr udp;
__be16 iteration;
char msg[64];
diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c
index 07715a3d6beab..b8a8b0495f661 100644
--- a/drivers/net/ethernet/sfc/siena/selftest.c
+++ b/drivers/net/ethernet/sfc/siena/selftest.c
@@ -43,7 +43,26 @@
*/
struct efx_loopback_payload {
struct ethhdr header;
- struct iphdr ip;
+ struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+ __u8 ihl:4,
+ version:4;
+#elif defined (__BIG_ENDIAN_BITFIELD)
+ __u8 version:4,
+ ihl:4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __u8 tos;
+ __be16 tot_len;
+ __be16 id;
+ __be16 frag_off;
+ __u8 ttl;
+ __u8 protocol;
+ __sum16 check;
+ __be32 saddr;
+ __be32 daddr;
+ } __packed ip; /* unaligned struct iphdr */
struct udphdr udp;
__be16 iteration;
char msg[64];
--
2.39.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload
2023-06-19 9:12 [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Arnd Bergmann
2023-06-19 9:12 ` [PATCH 2/3] [v2] sfc: fix uninitialized variable use Arnd Bergmann
2023-06-19 9:12 ` [PATCH 3/3] sfc: selftest: fix struct packing Arnd Bergmann
@ 2023-06-19 10:04 ` Edward Cree
2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 11+ messages in thread
From: Edward Cree @ 2023-06-19 10:04 UTC (permalink / raw)
To: Arnd Bergmann, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman,
Pieter Jansen van Vuuren
Cc: Arnd Bergmann, Jiri Pirko, Alejandro Lucero, netdev,
linux-net-drivers, linux-kernel
On 19/06/2023 10:12, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The driver now fails to link when CONFIG_INET is disabled, so
> add an explicit Kconfig dependency:
>
> ld.lld: error: undefined symbol: ip_route_output_flow
>>>> referenced by tc_encap_actions.c
>>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.a
>
> ld.lld: error: undefined symbol: ip_send_check
>>>> referenced by tc_encap_actions.c
>>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
>>>> referenced by tc_encap_actions.c
>>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_gen_encap_header) in archive vmlinux.a
>
> ld.lld: error: undefined symbol: arp_tbl
>>>> referenced by tc_encap_actions.c
>>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
>>>> referenced by tc_encap_actions.c
>>>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_netevent_event) in archive vmlinux.a
>
> Fixes: a1e82162af0b8 ("sfc: generate encap headers for TC offload")
> Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202306151656.yttECVTP-lkp@intel.com/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Additionally
Fixes: 7e5e7d800011 ("sfc: neighbour lookup for TC encap action offload")
The subject line doesn't specify a target tree; this should be for net-next.
> ---
> v2: add Fixes and Closes tags
> ---
> drivers/net/ethernet/sfc/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
> index 4af36ba8906ba..3eb55dcfa8a61 100644
> --- a/drivers/net/ethernet/sfc/Kconfig
> +++ b/drivers/net/ethernet/sfc/Kconfig
> @@ -50,6 +50,7 @@ config SFC_MCDI_MON
> config SFC_SRIOV
> bool "Solarflare SFC9100-family SR-IOV support"
> depends on SFC && PCI_IOV
> + depends on INET
> default y
> help
> This enables support for the Single Root I/O Virtualization
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] [v2] sfc: fix uninitialized variable use
2023-06-19 9:12 ` [PATCH 2/3] [v2] sfc: fix uninitialized variable use Arnd Bergmann
@ 2023-06-19 10:06 ` Edward Cree
0 siblings, 0 replies; 11+ messages in thread
From: Edward Cree @ 2023-06-19 10:06 UTC (permalink / raw)
To: Arnd Bergmann, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Pieter Jansen van Vuuren,
Simon Horman
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
On 19/06/2023 10:12, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The new efx_bind_neigh() function contains a broken code path when IPV6 is
> disabled:
>
> drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> if (encap->type & EFX_ENCAP_FLAG_IPV6) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here
> if (!n) {
> ^
> drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false
> if (encap->type & EFX_ENCAP_FLAG_IPV6) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning
> struct neighbour *n;
> ^
> = NULL
>
> Change it to use the existing error handling path here.
>
> Fixes: 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload")
> Suggested-by: Edward Cree <ecree.xilinx@gmail.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
> ---
> v2: use 'goto' instead of incorrectly entering another error path
> ---
> drivers/net/ethernet/sfc/tc_encap_actions.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/sfc/tc_encap_actions.c b/drivers/net/ethernet/sfc/tc_encap_actions.c
> index aac259528e73e..7e8bcdb222ad1 100644
> --- a/drivers/net/ethernet/sfc/tc_encap_actions.c
> +++ b/drivers/net/ethernet/sfc/tc_encap_actions.c
> @@ -164,6 +164,7 @@ static int efx_bind_neigh(struct efx_nic *efx,
> */
> rc = -EOPNOTSUPP;
> NL_SET_ERR_MSG_MOD(extack, "No IPv6 support (neigh bind)");
> + goto out_free;
> #endif
> } else {
> rt = ip_route_output_key(net, &flow4);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-19 9:12 ` [PATCH 3/3] sfc: selftest: fix struct packing Arnd Bergmann
@ 2023-06-19 10:25 ` Edward Cree
2023-06-19 13:04 ` Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Edward Cree @ 2023-06-19 10:25 UTC (permalink / raw)
To: Arnd Bergmann, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
On 19/06/2023 10:12, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Three of the sfc drivers define a packed loopback_payload structure with an
> ethernet header followed by an IP header. However, the kernel definition
> of iphdr specifies that this is 4-byte aligned, causing a W=1 warning:
>
> net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
> struct iphdr ip;
>
> As the iphdr packing is not easily changed without breaking other code,
> change the three structures to use a local definition instead.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Duplicating the definition isn't the prettiest thing in the world; it'd
do for a quick fix if needed but I assume W=1 warnings aren't blocking
anyone, so maybe defer this one for now and I'll follow up soon with a
rewrite that fixes this more cleanly? My idea is to drop the __packed
from the containing struct, make efx_begin_loopback() copy the layers
separately, and efx_loopback_rx_packet() similarly do something less
direct than casting the packet data to the struct.
But I don't insist on it; if you want this fix in immediately then I'm
okay with that too.
> ---
> drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++-
> drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++-
> drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++-
> 3 files changed, 60 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c
> index 6a454ac6f8763..fb7fcd27a33a5 100644
> --- a/drivers/net/ethernet/sfc/falcon/selftest.c
> +++ b/drivers/net/ethernet/sfc/falcon/selftest.c
> @@ -40,7 +40,26 @@
> */
> struct ef4_loopback_payload {
> struct ethhdr header;
> - struct iphdr ip;
> + struct {
> +#if defined(__LITTLE_ENDIAN_BITFIELD)
> + __u8 ihl:4,
> + version:4;
> +#elif defined (__BIG_ENDIAN_BITFIELD)
> + __u8 version:4,
> + ihl:4;
> +#else
> +#error "Please fix <asm/byteorder.h>"
> +#endif
> + __u8 tos;
> + __be16 tot_len;
> + __be16 id;
> + __be16 frag_off;
> + __u8 ttl;
> + __u8 protocol;
> + __sum16 check;
> + __be32 saddr;
> + __be32 daddr;
> + } __packed ip; /* unaligned struct iphdr */
> struct udphdr udp;
> __be16 iteration;
> char msg[64];
> diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c
> index 3c5227afd4977..440a57953779c 100644
> --- a/drivers/net/ethernet/sfc/selftest.c
> +++ b/drivers/net/ethernet/sfc/selftest.c
> @@ -43,7 +43,26 @@
> */
> struct efx_loopback_payload {
> struct ethhdr header;
> - struct iphdr ip;
> + struct {
> +#if defined(__LITTLE_ENDIAN_BITFIELD)
> + __u8 ihl:4,
> + version:4;
> +#elif defined (__BIG_ENDIAN_BITFIELD)
> + __u8 version:4,
> + ihl:4;
> +#else
> +#error "Please fix <asm/byteorder.h>"
> +#endif
> + __u8 tos;
> + __be16 tot_len;
> + __be16 id;
> + __be16 frag_off;
> + __u8 ttl;
> + __u8 protocol;
> + __sum16 check;
> + __be32 saddr;
> + __be32 daddr;
> + } __packed ip; /* unaligned struct iphdr */
> struct udphdr udp;
> __be16 iteration;
> char msg[64];
> diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c
> index 07715a3d6beab..b8a8b0495f661 100644
> --- a/drivers/net/ethernet/sfc/siena/selftest.c
> +++ b/drivers/net/ethernet/sfc/siena/selftest.c
> @@ -43,7 +43,26 @@
> */
> struct efx_loopback_payload {
> struct ethhdr header;
> - struct iphdr ip;
> + struct {
> +#if defined(__LITTLE_ENDIAN_BITFIELD)
> + __u8 ihl:4,
> + version:4;
> +#elif defined (__BIG_ENDIAN_BITFIELD)
> + __u8 version:4,
> + ihl:4;
> +#else
> +#error "Please fix <asm/byteorder.h>"
> +#endif
> + __u8 tos;
> + __be16 tot_len;
> + __be16 id;
> + __be16 frag_off;
> + __u8 ttl;
> + __u8 protocol;
> + __sum16 check;
> + __be32 saddr;
> + __be32 daddr;
> + } __packed ip; /* unaligned struct iphdr */
> struct udphdr udp;
> __be16 iteration;
> char msg[64];
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-19 10:25 ` Edward Cree
@ 2023-06-19 13:04 ` Arnd Bergmann
2023-06-19 14:55 ` Arnd Bergmann
2023-06-23 10:52 ` David Laight
2 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2023-06-19 13:04 UTC (permalink / raw)
To: Edward Cree, Arnd Bergmann, Martin Habets, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Netdev, linux-net-drivers, linux-kernel
On Mon, Jun 19, 2023, at 12:25, Edward Cree wrote:
> On 19/06/2023 10:12, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> Three of the sfc drivers define a packed loopback_payload structure with an
>> ethernet header followed by an IP header. However, the kernel definition
>> of iphdr specifies that this is 4-byte aligned, causing a W=1 warning:
>>
>> net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
>> struct iphdr ip;
>>
>> As the iphdr packing is not easily changed without breaking other code,
>> change the three structures to use a local definition instead.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Duplicating the definition isn't the prettiest thing in the world; it'd
> do for a quick fix if needed but I assume W=1 warnings aren't blocking
> anyone, so maybe defer this one for now and I'll follow up soon with a
> rewrite that fixes this more cleanly? My idea is to drop the __packed
> from the containing struct, make efx_begin_loopback() copy the layers
> separately, and efx_loopback_rx_packet() similarly do something less
> direct than casting the packet data to the struct.
>
> But I don't insist on it; if you want this fix in immediately then I'm
> okay with that too.
>
>> ---
>> drivers/net/ethernet/sfc/falcon/selftest.c | 21 ++++++++++++++++++++-
>> drivers/net/ethernet/sfc/selftest.c | 21 ++++++++++++++++++++-
>> drivers/net/ethernet/sfc/siena/selftest.c | 21 ++++++++++++++++++++-
>> 3 files changed, 60 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/sfc/falcon/selftest.c b/drivers/net/ethernet/sfc/falcon/selftest.c
>> index 6a454ac6f8763..fb7fcd27a33a5 100644
>> --- a/drivers/net/ethernet/sfc/falcon/selftest.c
>> +++ b/drivers/net/ethernet/sfc/falcon/selftest.c
>> @@ -40,7 +40,26 @@
>> */
>> struct ef4_loopback_payload {
>> struct ethhdr header;
>> - struct iphdr ip;
>> + struct {
>> +#if defined(__LITTLE_ENDIAN_BITFIELD)
>> + __u8 ihl:4,
>> + version:4;
>> +#elif defined (__BIG_ENDIAN_BITFIELD)
>> + __u8 version:4,
>> + ihl:4;
>> +#else
>> +#error "Please fix <asm/byteorder.h>"
>> +#endif
>> + __u8 tos;
>> + __be16 tot_len;
>> + __be16 id;
>> + __be16 frag_off;
>> + __u8 ttl;
>> + __u8 protocol;
>> + __sum16 check;
>> + __be32 saddr;
>> + __be32 daddr;
>> + } __packed ip; /* unaligned struct iphdr */
>> struct udphdr udp;
>> __be16 iteration;
>> char msg[64];
>> diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c
>> index 3c5227afd4977..440a57953779c 100644
>> --- a/drivers/net/ethernet/sfc/selftest.c
>> +++ b/drivers/net/ethernet/sfc/selftest.c
>> @@ -43,7 +43,26 @@
>> */
>> struct efx_loopback_payload {
>> struct ethhdr header;
>> - struct iphdr ip;
>> + struct {
>> +#if defined(__LITTLE_ENDIAN_BITFIELD)
>> + __u8 ihl:4,
>> + version:4;
>> +#elif defined (__BIG_ENDIAN_BITFIELD)
>> + __u8 version:4,
>> + ihl:4;
>> +#else
>> +#error "Please fix <asm/byteorder.h>"
>> +#endif
>> + __u8 tos;
>> + __be16 tot_len;
>> + __be16 id;
>> + __be16 frag_off;
>> + __u8 ttl;
>> + __u8 protocol;
>> + __sum16 check;
>> + __be32 saddr;
>> + __be32 daddr;
>> + } __packed ip; /* unaligned struct iphdr */
>> struct udphdr udp;
>> __be16 iteration;
>> char msg[64];
>> diff --git a/drivers/net/ethernet/sfc/siena/selftest.c b/drivers/net/ethernet/sfc/siena/selftest.c
>> index 07715a3d6beab..b8a8b0495f661 100644
>> --- a/drivers/net/ethernet/sfc/siena/selftest.c
>> +++ b/drivers/net/ethernet/sfc/siena/selftest.c
>> @@ -43,7 +43,26 @@
>> */
>> struct efx_loopback_payload {
>> struct ethhdr header;
>> - struct iphdr ip;
>> + struct {
>> +#if defined(__LITTLE_ENDIAN_BITFIELD)
>> + __u8 ihl:4,
>> + version:4;
>> +#elif defined (__BIG_ENDIAN_BITFIELD)
>> + __u8 version:4,
>> + ihl:4;
>> +#else
>> +#error "Please fix <asm/byteorder.h>"
>> +#endif
>> + __u8 tos;
>> + __be16 tot_len;
>> + __be16 id;
>> + __be16 frag_off;
>> + __u8 ttl;
>> + __u8 protocol;
>> + __sum16 check;
>> + __be32 saddr;
>> + __be32 daddr;
>> + } __packed ip; /* unaligned struct iphdr */
>> struct udphdr udp;
>> __be16 iteration;
>> char msg[64];
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-19 10:25 ` Edward Cree
2023-06-19 13:04 ` Arnd Bergmann
@ 2023-06-19 14:55 ` Arnd Bergmann
2023-06-23 10:52 ` David Laight
2 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2023-06-19 14:55 UTC (permalink / raw)
To: Edward Cree, Arnd Bergmann, Martin Habets, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Netdev, linux-net-drivers, linux-kernel
On Mon, Jun 19, 2023, at 12:25, Edward Cree wrote:
> On 19/06/2023 10:12, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> Three of the sfc drivers define a packed loopback_payload structure with an
>> ethernet header followed by an IP header. However, the kernel definition
>> of iphdr specifies that this is 4-byte aligned, causing a W=1 warning:
>>
>> net/ethernet/sfc/siena/selftest.c:46:15: error: field ip within 'struct efx_loopback_payload' is less aligned than 'struct iphdr' and is usually due to 'struct efx_loopback_payload' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
>> struct iphdr ip;
>>
>> As the iphdr packing is not easily changed without breaking other code,
>> change the three structures to use a local definition instead.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Duplicating the definition isn't the prettiest thing in the world; it'd
> do for a quick fix if needed but I assume W=1 warnings aren't blocking
> anyone, so maybe defer this one for now and I'll follow up soon with a
> rewrite that fixes this more cleanly? My idea is to drop the __packed
> from the containing struct, make efx_begin_loopback() copy the layers
> separately, and efx_loopback_rx_packet() similarly do something less
> direct than casting the packet data to the struct.
>
> But I don't insist on it; if you want this fix in immediately then I'm
> okay with that too.
It's not urgent, if you can come up with a nicer solution, that is
probably better than applying my patch now. I have a patch [1] that
addresses -Wunaligned-access for all x86 and arm randconfig builds,
and this currently affects 23 drivers. Most of the changes don't
have changelog texts yet, and some need a more detailed analysis to
come up with a correct patch. I'd probably aim for linux-6.6 or
later to get them all done, at which point we could move the warning
from W=1 to the default set.
Arnd
[1] https://pastebin.com/g6D9NTS4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload
2023-06-19 9:12 [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Arnd Bergmann
` (2 preceding siblings ...)
2023-06-19 10:04 ` [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Edward Cree
@ 2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-21 3:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: ecree.xilinx, habetsm.xilinx, davem, edumazet, kuba, pabeni,
simon.horman, pieter.jansen-van-vuuren, arnd, jiri,
alejandro.lucero-palau, netdev, linux-net-drivers, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 19 Jun 2023 11:12:09 +0200 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The driver now fails to link when CONFIG_INET is disabled, so
> add an explicit Kconfig dependency:
>
> ld.lld: error: undefined symbol: ip_route_output_flow
> >>> referenced by tc_encap_actions.c
> >>> drivers/net/ethernet/sfc/tc_encap_actions.o:(efx_tc_flower_create_encap_md) in archive vmlinux.a
>
> [...]
Here is the summary with links:
- [1/3,v2] sfc: add CONFIG_INET dependency for TC offload
https://git.kernel.org/netdev/net-next/c/40cba83370c2
- [2/3,v2] sfc: fix uninitialized variable use
https://git.kernel.org/netdev/net-next/c/f61d2d5cf142
- [3/3] sfc: selftest: fix struct packing
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-19 10:25 ` Edward Cree
2023-06-19 13:04 ` Arnd Bergmann
2023-06-19 14:55 ` Arnd Bergmann
@ 2023-06-23 10:52 ` David Laight
2023-06-23 12:57 ` Edward Cree
2 siblings, 1 reply; 11+ messages in thread
From: David Laight @ 2023-06-23 10:52 UTC (permalink / raw)
To: 'Edward Cree',
Arnd Bergmann, Martin Habets, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
...
> Duplicating the definition isn't the prettiest thing in the world; it'd
> do for a quick fix if needed but I assume W=1 warnings aren't blocking
> anyone, so maybe defer this one for now and I'll follow up soon with a
> rewrite that fixes this more cleanly? My idea is to drop the __packed
> from the containing struct, make efx_begin_loopback() copy the layers
> separately, and efx_loopback_rx_packet() similarly do something less
> direct than casting the packet data to the struct.
Maybe you can get away with adding a 16bit pad before the ethernet
header so that the IP header is actually aligned.
(Then fight all the stuff that stops you doing a memcpy()
that runs into a second field of a structure.)
Failing that maybe a single shared copy of the misaligned
IP header.
I also suspect you could just add __packed to the two 32bit
address fields.
That would generate better code on systems that care.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] sfc: selftest: fix struct packing
2023-06-23 10:52 ` David Laight
@ 2023-06-23 12:57 ` Edward Cree
0 siblings, 0 replies; 11+ messages in thread
From: Edward Cree @ 2023-06-23 12:57 UTC (permalink / raw)
To: David Laight, Arnd Bergmann, Martin Habets, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Arnd Bergmann, netdev, linux-net-drivers, linux-kernel
On 23/06/2023 11:52, David Laight wrote:
> Maybe you can get away with adding a 16bit pad before the ethernet
> header so that the IP header is actually aligned.
That's what I ended up doing, because my original idea was
overcomplicated and turned out super ugly.
See https://lore.kernel.org/netdev/6f87fdf5-1844-4633-b4fe-6b247bc6ab49@app.fastmail.com/T/
> (Then fight all the stuff that stops you doing a memcpy()
> that runs into a second field of a structure.)
Yeah, I don't know how you're meant to annotate that stuff.
I guess I'll have to wait until Kees shouts at me and tells
me what to do :S
-ed
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-06-23 12:57 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 9:12 [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Arnd Bergmann
2023-06-19 9:12 ` [PATCH 2/3] [v2] sfc: fix uninitialized variable use Arnd Bergmann
2023-06-19 10:06 ` Edward Cree
2023-06-19 9:12 ` [PATCH 3/3] sfc: selftest: fix struct packing Arnd Bergmann
2023-06-19 10:25 ` Edward Cree
2023-06-19 13:04 ` Arnd Bergmann
2023-06-19 14:55 ` Arnd Bergmann
2023-06-23 10:52 ` David Laight
2023-06-23 12:57 ` Edward Cree
2023-06-19 10:04 ` [PATCH 1/3] [v2] sfc: add CONFIG_INET dependency for TC offload Edward Cree
2023-06-21 3:40 ` patchwork-bot+netdevbpf
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).