Skip to content

Fix unaligned access issues in host-network byte I/O on ARM #218

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2017
Merged

Conversation

elprans
Copy link
Member

@elprans elprans commented Oct 27, 2017

Per report in #216 and https://bugs.debian.org/872408, the current
implementation may raise SIGBUS on ARM platforms that do not support
unaligned memory access.

Fix this by using a stack variable and memcpy, which gives the compiler
more opportunity to generate correct code. While at it, implement
hton* and ntoh* in terms of byteswap intrinsics with an open-coded
fallback. This drops the dependency on the platform's implementation,
which might not necessarily be consistently fast.

Smoke-tested locally on cross-compiled armv5tel-softfloat-linux-gnueabi
and armv6j-hardfloat-linux-gnueabi with QEMU TCG.

Fixes: #216.

@elprans elprans requested a review from 1st1 October 27, 2017 21:52
Per report in #216 and https://bugs.debian.org/872408, the current
implementation may raise SIGBUS on ARM platforms that do not support
unaligned memory access.

Fix this by using a stack variable and memcpy, which gives the compiler
more opportunity to generate correct code.  While at it, implement
hton* and ntoh* in terms of byteswap intrinsics with an open-coded
fallback.  This drops the dependency on the platform's implementation,
which might not necessarily be consistently fast.

Smoke-tested locally on cross-compiled armv5tel-softfloat-linux-gnueabi
and armv6j-hardfloat-linux-gnueabi with QEMU TCG.

Fixes: #216.
@elprans elprans merged commit c04576d into master Oct 31, 2017
@elprans elprans deleted the hton branch October 31, 2017 20:38
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants