zephyr/include/net
Martin Åberg b9d0414292 net: use UNALIGNED_PUT() to access IP address
This commit allows the net_ipv6_addr_create_iid() argument addr to
have relaxed alignment.

This commit makes the following tests pass on qemu_leon3:
- net.6lo

Details:

sparc-zephyr-elf-gcc 9.2.0 compiles the beginning of
net_ipv6_addr_create_iid(),

  addr->s6_addr[0] = 0xfe;
  addr->s6_addr[1] = 0x8e;
  UNALIGNED_PUT(0, &addr->s6_addr16[1]);
  UNALIGNED_PUT(0, &addr->s6_addr32[1]);

into

  400089d4 <net_ipv6_addr_create_iid>:
  400089d4:       9d e3 bf a0     save  %sp, -96, %sp
  400089d8:       03 3f a0 00     sethi  %hi(0xfe800000), %g1
  400089dc:       c0 2e 20 04     clrb  [ %i0 + 4 ]
  400089e0:       c2 26 00 00     st  %g1, [ %i0 ]
  400089e4:       c0 2e 20 05     clrb  [ %i0 + 5 ]
  400089e8:       c0 2e 20 06     clrb  [ %i0 + 6 ]
  400089ec:       c0 2e 20 07     clrb  [ %i0 + 7 ]

%i0 is the function argument "addr". %g1 is prepared with the value
0xfe800000. The "clrb" instruction sets a single byte in memory to
0 and has no alignment restriction.

We get an unaligned exception on PC 400089e0 when %i0 ("addr") is
not a multiple of 4. The instruction "st" stores the full 32-bit
register %g1 to memory address in %i0. The effective address (%i0)
of the 32-bit register store is required to be naturally aligned by
the architecture.

The compiler assumes that "addr" is aligned according to its type
and has knowledge about the data representation.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 11:44:16 +02:00
..
bt.h net: bt: fix C++ link errors 2020-08-17 10:45:03 +03:00
buf.h net: buf: change avail_count variable to atomic type 2020-10-28 18:45:11 +02:00
can.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
coap_link_format.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
coap.h net: includes: Fix indentation in header files 2020-08-21 13:56:13 -04:00
dhcpv4.h
dns_resolve.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
dns_sd.h net: dns: dns-sd: support dns service discovery 2020-11-09 16:15:02 -08:00
dummy.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
ethernet_mgmt.h net: includes: Fix indentation in header files 2020-08-21 13:56:13 -04:00
ethernet_vlan.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
ethernet.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
gptp.h net: gptp: Allow user to tweak priority1 and priority2 values 2020-09-22 16:45:45 -05:00
hostname.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
http_client.h net: http_client: add missing kernel.h include statement 2020-07-07 16:00:42 -04:00
http_parser_state.h
http_parser_url.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
http_parser.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
ieee802154_mgmt.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
ieee802154_radio.h drivers: ieee802154: cc13xx_cc26xx: sub-ghz support 2020-11-09 10:25:24 +02:00
ieee802154.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
ipv4_autoconf.h
lldp.h net: includes: Fix indentation in header files 2020-08-21 13:56:13 -04:00
lwm2m_path.h net: lwm2m: Add path generation macro 2020-11-10 14:10:44 +02:00
lwm2m.h net: lwm2m: Add path generation macro 2020-11-10 14:10:44 +02:00
mii.h
mqtt.h doc: update Kconfig options to use @option ALIAS 2020-09-15 15:25:01 +02:00
net_config.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
net_conn_mgr.h
net_context.h net: context: add net_context api to check if a port is bound 2020-11-09 16:15:02 -08:00
net_core.h net: Collect net_pkt RX detailed timing stats when passing IP stack 2020-08-07 10:12:51 +03:00
net_event.h net: event: Add start/bound/stop events for DHCPv4 2020-10-03 17:15:15 +03:00
net_if.h net: tc: Remove not used field from net_traffic_class struct 2020-10-02 13:20:17 +03:00
net_ip.h net: use UNALIGNED_PUT() to access IP address 2020-11-17 11:44:16 +02:00
net_l2.h net: Use section foreach macros 2020-07-20 08:32:46 -07:00
net_linkaddr.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
net_mgmt.h net: mgmt: Clarify the net_mgmt API documentation 2020-09-30 16:31:38 +03:00
net_offload.h net: offload: fix k_timeout_t translation in net_offload 2020-10-28 09:30:53 +02:00
net_pkt.h net: pkt: Add net_pkt_is_empty() util function 2020-09-22 11:22:43 +02:00
net_stats.h net: stats: Separate dropped TCP data segments and TCP packets 2020-11-06 09:50:02 -06:00
net_timeout.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
openthread.h openthread: add openthread_api_mutex_try_lock() 2020-10-20 16:39:22 +03:00
ppp.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
promiscuous.h
ptp_time.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
sntp.h net: sntp: Remove deprecated API function 2020-10-01 07:14:08 -05:00
socket_can.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
socket_net_mgmt.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
socket_offload.h
socket_select.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
socket.h net: lib: sockets: added ALPN extension option to TLS 2020-10-22 11:35:43 +03:00
socketutils.h
tftp.h zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
tls_credentials.h
trickle.h net: includes: Fix indentation in header files 2020-08-21 13:56:13 -04:00
udp.h
websocket.h net: websocket: Fix conflict flag 2020-10-06 12:02:06 +03:00
wifi_mgmt.h device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
wifi.h