net: remove superfluous __packed attribute
PATCH 1/1 net: remove superfluous __packed attribute
struct ip_udp_hdr is naturally packed. There is no point in adding a __packed attribute. With the attribute the network stack does not compile using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1288 | sumptr = (ushort *)&(ip->udp_src);
| ^~~~~~~~~~~~~~So let's remove the attribute.
--- include/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net.h +1 -1
@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst;/* UDP destination port */ u16 udp_len;/* Length of UDP packet */ u16 udp_xsum;/* Checksum */ -} __attribute__((packed)); +};#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
--
2.23.0
PATCH 1/1 net: remove superfluous __packed attribute
Quoted 23 lines · Heinrich Schuchardt
struct
ip_udp_hdris naturally packed. There is no point in adding a__packedattribute. With the attribute the network stack does not compile using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]1288 | sumptr = (ushort *)&(ip->udp_src); | ^~~~~~~~~~~~~~So let's remove the attribute.
Signed-off-by Heinrich Schuchardt <[email protected]>--- include/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/net.h +0
-0
include/net.h struct ip_udp_hdr { · line 396
Quoted 8 lines
include/net.h +1
-1@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst;/* UDP destination port */ u16 udp_len;/* Length of UDP packet */ u16 udp_xsum;/* Checksum */ -} __attribute__((packed)); +};#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
This came from:
commit 704f3acfcf55343043bbed01c5fb0a0094a68e8a
Author: Denis Pynkin <[email protected]> Date: Fri Jul 21 19:28:42 2017 +0300
net: Use packed structures for networking
PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled by default for '-O2':
BOOTP broadcast 1
data abort
pc : [<8ff8bb30>] lr : [<00004f1f>]
reloc pc : [<17832b30>] lr : [<878abf1f>]
sp : 8f558bc0 ip : 00000000 fp : 8ffef5a4
r10: 8ffed248 r9 : 8f558ee0 r8 : 8ffef594
r7 : 0000000e r6 : 8ffed700 r5 : 00000000 r4 : 8ffed74e
r3 : 00060101 r2 : 8ffed230 r1 : 8ffed706 r0 : 00000ddd
Flags: nzcv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
Core reason is usage of structures for network headers without packed attribute.
... so adding a few folks to the list and lets see if patchwork picks up this tag:
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191003/221b11fc/attachment.sig>
PATCH 1/1 net: remove superfluous __packed attribute
Quoted 58 lines · Tom Rini
Quoted 23 lines · Heinrich Schuchardt
struct
ip_udp_hdris naturally packed. There is no point in adding a__packedattribute. With the attribute the network stack does not compile using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]1288 | sumptr = (ushort *)&(ip->udp_src); | ^~~~~~~~~~~~~~So let's remove the attribute.
Signed-off-by Heinrich Schuchardt <[email protected]>--- include/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/net.h +0
-0include/net.h struct ip_udp_hdr { · line 396
Quoted 8 lines
include/net.h +1
-1@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst;/* UDP destination port */ u16 udp_len;/* Length of UDP packet */ u16 udp_xsum;/* Checksum */ -} __attribute__((packed)); +};#define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr))#define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE)This came from:
commit704f3acfcf55343043bbed01c5fb0a0094a68e8aAuthor: Denis Pynkin <[email protected]> Date: Fri Jul 21 19:28:42 2017 +0300net: Use packed structures for networking
PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled by default for '-O2':
BOOTP broadcast 1
data abort
pc : [<8ff8bb30>] lr : [<00004f1f>]
reloc pc : [<17832b30>] lr : [<878abf1f>]
sp :8f558bc0ip : 00000000 fp :8ffef5a4
r10:8ffed248r9 :8f558ee0r8 :8ffef594
r7 :0000000er6 :8ffed700r5 : 00000000 r4 :8ffed74e
r3 : 00060101 r2 :8ffed230r1 :8ffed706r0 :00000ddd
Flags: nzcv IRQs off FIQs off ModeSVC_32
Resetting CPU ...Core reason is usage of structures for network headers without packed attribute.
Quoted 8 lines
Reviewed-by Yauheni Kaliuta <[email protected]>Signed-off-by Denis Pynkin <[email protected]>Acked-by Joe Hershberger <[email protected]>... so adding a few folks to the list and lets see if patchwork picks up this tag:
Fixes 704f3acfcf55 ("net: Use packed structures for networking")
Thanks for providing this background.
-fstore-merging is enabled for O2 and Os. But it should not change the program behavior.
The relevant code is in gcc/gimple-ssa-store-merging.c. It has been completely overhauled since GCC 7.1.
I have seen no problems with DHCP, ping and tFTP on arm and arm64 with GCC 9.2.1.
Best regards
Heinrich
Since GCC 7.1 some bugs have been fixed, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86492
PATCH 1/1 net: remove superfluous __packed attribute
Quoted 81 lines · Heinrich Schuchardt
Quoted 60 lines · Tom Rini
Quoted 30 lines · Heinrich Schuchardt
struct
ip_udp_hdris naturally packed. There is no point in adding a__packedattribute. With the attribute the network stack does not compile
using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1288 | sumptr = (ushort *)&(ip->udp_src);
| ^~~~~~~~~~~~~~So let's remove the attribute.
Signed-off-by Heinrich Schuchardt <[email protected]>---
include/net.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)include/net.h +0
-0@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst; /* UDP destination port */ u16 udp_len; /* Length of UDP packet */ u16 udp_xsum; /* Checksum */
include/net.h +1
-1-} __attribute__((packed)); +};Quoted 2 lines
#define IP_UDP_HDR_SIZE (
sizeof(struct ip_udp_hdr)) #define UDP_HDR_SIZE (IP_UDP_HDR_SIZE-IP_HDR_SIZE)This came from:
commit704f3acfcf55343043bbed01c5fb0a0094a68e8a
Author: Denis Pynkin <[email protected]>
Date: Fri Jul 21 19:28:42 2017 +0300net: Use packed structures for networking
PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled by default for '-O2':
BOOTP broadcast 1
data abortpc : [<8ff8bb30>] lr : [<00004f1f>]reloc pc : [<17832b30>] lr : [<
878abf1f>]
sp : 8f558bc0 ip : 00000000 fp :8ffef5a4
r10: 8ffed248 r9 : 8f558ee0 r8 :8ffef594
r7 : 0000000e r6 : 8ffed700 r5 : 00000000 r4 :8ffed74er3 : 00060101 r2 : 8ffed230 r1 : 8ffed706 r0 :00000ddd
Flags: nzcv IRQs off FIQs off ModeSVC_32Resetting CPU ...Core reason is usage of structures for network headers without packed
attribute.Quoted 8 lines
Reviewed-by Yauheni Kaliuta <[email protected]>Signed-off-by Denis Pynkin <[email protected]>Acked-by Joe Hershberger <[email protected]>... so adding a few folks to the list and lets see if patchwork picks up this tag:
Fixes 704f3acfcf55 ("net: Use packed structures for networking")Thanks for providing this background.
-fstore-merging is enabled for O2 and Os. But it should not change the program behavior.
The relevant code is in
gcc/gimple-ssa-store-merging.c. It has been completely overhauled since GCC 7.1.I have seen no problems with DHCP, ping and tFTP on arm and arm64 with GCC 9.2.1.
Quoted 7 lines
Best regards
Heinrich
Since GCC 7.1 some bugs have been fixed, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86492
Hello Joe,
how will we carry on, to get the issue resolved?
Best regards
Heinrich
PATCH 1/1 net: remove superfluous __packed attribute
Quoted 91 lines · Heinrich Schuchardt
Quoted 82 lines · Heinrich Schuchardt
Quoted 61 lines · Tom Rini
Quoted 30 lines · Heinrich Schuchardt
struct
ip_udp_hdris naturally packed. There is no point in adding a__packedattribute. With the attribute the network stack does not compile
using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1288 | sumptr = (ushort *)&(ip->udp_src);
| ^~~~~~~~~~~~~~So let's remove the attribute.
Signed-off-by Heinrich Schuchardt <[email protected]>---
include/net.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)include/net.h +0
-0@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst; /* UDP destination port */ u16 udp_len; /* Length of UDP packet */ u16 udp_xsum; /* Checksum */
include/net.h +1
-1-} __attribute__((packed)); +};Quoted 2 lines
#define IP_UDP_HDR_SIZE (
sizeof(struct ip_udp_hdr)) #define UDP_HDR_SIZE (IP_UDP_HDR_SIZE-IP_HDR_SIZE)This came from:
commit704f3acfcf55343043bbed01c5fb0a0094a68e8a
Author: Denis Pynkin <[email protected]>
Date: Fri Jul 21 19:28:42 2017 +0300net: Use packed structures for networking
PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled
by default for '-O2':BOOTP broadcast 1
data abortpc : [<8ff8bb30>] lr : [<00004f1f>]reloc pc : [<17832b30>] lr : [<
878abf1f>]
sp : 8f558bc0 ip : 00000000 fp :8ffef5a4
r10: 8ffed248 r9 : 8f558ee0 r8 :8ffef594
r7 : 0000000e r6 : 8ffed700 r5 : 00000000 r4 :8ffed74er3 : 00060101 r2 : 8ffed230 r1 : 8ffed706 r0 :00000ddd
Flags: nzcv IRQs off FIQs off ModeSVC_32Resetting CPU ...Core reason is usage of structures for network headers without packed
attribute.Quoted 8 lines
Reviewed-by Yauheni Kaliuta <[email protected]>Signed-off-by Denis Pynkin <[email protected]>Acked-by Joe Hershberger <[email protected]>... so adding a few folks to the list and lets see if patchwork picks up this tag:
Fixes 704f3acfcf55 ("net: Use packed structures for networking")Thanks for providing this background.
-fstore-merging is enabled for O2 and Os. But it should not change the program behavior.
The relevant code is in
gcc/gimple-ssa-store-merging.c. It has been completely overhauled since GCC 7.1.I have seen no problems with DHCP, ping and tFTP on arm and arm64 with GCC 9.2.1.
Quoted 7 lines
Best regards
Heinrich
Since GCC 7.1 some bugs have been fixed, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86492
Quoted 8 lines
Hello Joe,
how will we carry on, to get the issue resolved?
Best regards
Heinrich
_______________________________________________
Hello Tom, hello Joe,
I still cannot build sandbox_defconfig. How will we resolve this issue?
Best regards
Heinrich
PATCH 1/1 net: remove superfluous __packed attribute
Quoted 96 lines · Heinrich Schuchardt
Quoted 95 lines · Heinrich Schuchardt
Quoted 82 lines · Heinrich Schuchardt
Quoted 61 lines · Tom Rini
Quoted 30 lines · Heinrich Schuchardt
struct
ip_udp_hdris naturally packed. There is no point in adding a__packedattribute. With the attribute the network stack does not compile
using GCC 9.2.1:
net/net.c: In function ‘net_process_received_packet’:net/net.c:1288:23: error: taking address of packed member of ‘struct ip_udp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1288 | sumptr = (ushort *)&(ip->udp_src);
| ^~~~~~~~~~~~~~So let's remove the attribute.
Signed-off-by Heinrich Schuchardt <[email protected]>---
include/net.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)include/net.h +0
-0@@ -390,7 +390,7 @@ struct ip_udp_hdr {u16 udp_dst; /* UDP destination port */ u16 udp_len; /* Length of UDP packet */ u16 udp_xsum; /* Checksum */
include/net.h +1
-1-} __attribute__((packed)); +};Quoted 2 lines
#define IP_UDP_HDR_SIZE (
sizeof(struct ip_udp_hdr)) #define UDP_HDR_SIZE (IP_UDP_HDR_SIZE-IP_HDR_SIZE)This came from:
commit704f3acfcf55343043bbed01c5fb0a0094a68e8a
Author: Denis Pynkin <[email protected]>
Date: Fri Jul 21 19:28:42 2017 +0300net: Use packed structures for networking
PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled
by default for '-O2':BOOTP broadcast 1
data abortpc : [<8ff8bb30>] lr : [<00004f1f>]reloc pc : [<17832b30>] lr : [<
878abf1f>]
sp : 8f558bc0 ip : 00000000 fp :8ffef5a4
r10: 8ffed248 r9 : 8f558ee0 r8 :8ffef594
r7 : 0000000e r6 : 8ffed700 r5 : 00000000 r4 :8ffed74er3 : 00060101 r2 : 8ffed230 r1 : 8ffed706 r0 :00000ddd
Flags: nzcv IRQs off FIQs off ModeSVC_32Resetting CPU ...Core reason is usage of structures for network headers without packed
attribute.Quoted 8 lines
Reviewed-by Yauheni Kaliuta <[email protected]>Signed-off-by Denis Pynkin <[email protected]>Acked-by Joe Hershberger <[email protected]>... so adding a few folks to the list and lets see if patchwork picks up this tag:
Fixes 704f3acfcf55 ("net: Use packed structures for networking")Thanks for providing this background.
-fstore-merging is enabled for O2 and Os. But it should not change the program behavior.
The relevant code is in
gcc/gimple-ssa-store-merging.c. It has been completely overhauled since GCC 7.1.I have seen no problems with DHCP, ping and tFTP on arm and arm64 with GCC 9.2.1.
Quoted 7 lines
Best regards
Heinrich
Since GCC 7.1 some bugs have been fixed, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86492Hello Joe,
how will we carry on, to get the issue resolved?
Quoted 8 lines
Quoted 4 lines
Best regards
Heinrich
_______________________________________________Hello Tom, hello Joe,
I still cannot build
sandbox_defconfig. How will we resolve this issue?
We can't drop gcc-7.1 support at this point. Perhaps use an accessor function of some sort?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191104/0ecd5357/attachment.sig>