Closed bublover closed 5 years ago
"If you are creating misaligned pointers to structs or double words, then you must use the __packed qualifier in order to ensure that the compiler does not use LDRD and LDM instructions,"
Are we sure we want to add __packed
here? The UDP header itself is 4 bytes aligned (Ethernet frame isn't). We also have slab allocator to align the packet buffer. So, can we just align the packet buffer, if not?
If we need __packed
here, don't we need every other field as well?
LDRD just need word-aligned. Can you share the generated instructions with __packed
? I assume __packed
tells compilers to generate byte access instructions.
Are we sure we want to add
__packed
here? The UDP header itself is 4 bytes aligned (Ethernet frame isn't). We also have slab allocator to align the packet buffer. So, can we just align the packet buffer, if not?If we need
__packed
here, don't we need every other field as well?LDRD just need word-aligned. Can you share the generated instructions with
__packed
? I assume__packed
tells compilers to generate byte access instructions.
Sorry for confusing. "If you are creating misaligned pointers to structs or double words, then you must use the __packed qualifier in order to ensure that the compiler does not use LDRD and LDM instructions,"
__packed will tell comipler not use double word instruction. In this case, ldr is proper. I did not save the zephyr.list.
We also have slab allocator to align the packet buffer.
@jukkar Could you please help make a comment on this?
Please note that the zperf_udp_datagram is just cast to arbitrary memory location of the received net_buf. It might not be aligned to word boundary.
Describe the bug Running zperf test, I always found unaligned memory access fault with CONFIG_SPEED_OPTIMIZATIONS=y.
To Reproduce Steps to reproduce the behavior:
Error from this line 0x2015f38 <udp_received+192> ldrd r3, r2, [r8, #4]
r8 is not 4-byte aligned.
C code:
Expected behavior r8 is 4-byte aligned.
Impact Function not working.
Environment (please complete the following information):
Additional context If CONFIG_SPEED_OPTIMIZATIONS is disabled, nothing can be found.