public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] net: Mark the ip_udp_hdr struct as packed
@ 2017-07-12 14:34 Maxime Ripard
  2017-07-18 18:10 ` Joe Hershberger
  2017-07-19 18:14 ` Joe Hershberger
  0 siblings, 2 replies; 14+ messages in thread
From: Maxime Ripard @ 2017-07-12 14:34 UTC (permalink / raw)
  To: u-boot

The -mno-unaligned-access flag used on ARM to prevent GCC from generating
unaligned accesses (obviously) will only do so on packed structures.

It seems like gcc 7.1 is a bit stricter than previous gcc versions on this,
and using it lead to data abort for unaligned accesses when generating
network traffic.

Fix this by adding the packed attribute to the ip_udp_hdr structure in
order to let GCC do its job.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 997db9210a8f..7b815afffafa 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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.13.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [U-Boot] [PATCH] net: Mark the ip_udp_hdr struct as packed
@ 2017-07-12 14:34 Maxime Ripard
  2017-07-12 14:37 ` Dr. Philipp Tomsich
  2017-07-21 19:15 ` Siarhei Siamashka
  0 siblings, 2 replies; 14+ messages in thread
From: Maxime Ripard @ 2017-07-12 14:34 UTC (permalink / raw)
  To: u-boot

The -mno-unaligned-access flag used on ARM to prevent GCC from generating
unaligned accesses (obviously) will only do so on packed structures.

It seems like gcc 7.1 is a bit stricter than previous gcc versions on this,
and using it lead to data abort for unaligned accesses when generating
network traffic.

Fix this by adding the packed attribute to the ip_udp_hdr structure in
order to let GCC do its job.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 997db9210a8f..7b815afffafa 100644
--- a/include/net.h
+++ b/include/net.h
@@ -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.13.0

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

end of thread, other threads:[~2017-07-22 13:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-12 14:34 [U-Boot] [PATCH] net: Mark the ip_udp_hdr struct as packed Maxime Ripard
2017-07-18 18:10 ` Joe Hershberger
2017-07-19  7:01   ` Maxime Ripard
2017-07-19 18:13     ` Joe Hershberger
2017-07-19 18:26   ` Jeroen Hofstee
2017-07-21 18:46     ` Siarhei Siamashka
2017-07-22 13:32       ` Jeroen Hofstee
2017-07-19 18:14 ` Joe Hershberger
  -- strict thread matches above, loose matches on Subject: below --
2017-07-12 14:34 Maxime Ripard
2017-07-12 14:37 ` Dr. Philipp Tomsich
2017-07-17  9:29   ` Maxime Ripard
2017-07-18  2:35     ` Tom Rini
2017-07-21 19:15 ` Siarhei Siamashka
2017-07-21 19:37   ` Siarhei Siamashka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox