Skip to content
New issue

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

By clicking “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? Sign in to your account

keccak: guard against misaligned memory accesses on ARM #5724

Merged
merged 1 commit into from Jul 13, 2019

Conversation

Projects
None yet
6 participants
@moneromooo-monero
Copy link
Contributor

commented Jul 2, 2019

No description provided.

for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) {
for (i = 0; i < rsizw; i++) {
uint64_t ina;
memcpy(&ina, &((uint64_t*)in)[i], 8);

This comment has been minimized.

Copy link
@hyc

hyc Jul 3, 2019

Contributor

shouldn't the source pointer be (void *)? otherwise the compiler will still assume uint64_t alignment, no?

This comment has been minimized.

Copy link
@moneromooo-monero

moneromooo-monero Jul 3, 2019

Author Contributor

OK, I also added a better unit test for this. I can't seem to be able to connect to ssh for now, I'll push later when I can.

This comment has been minimized.

Copy link
@txchangecoin-project

txchangecoin-project Jul 10, 2019

Tested and implemented. This will be successful

@moneromooo-monero moneromooo-monero force-pushed the moneromooo-monero:karm branch from 6ea70a9 to 5fe5d63 Jul 3, 2019

@vtnerd
Copy link
Contributor

left a comment

When I've disassembled similar code in the past, GCC / Clang will generate identical code whether its an uint64_t cast/alias or a memcpy when the target platform supports unaligned accesses. When the platform doesn't, they will fall back into the slower copy code (but typically don't call the library memcpy function either).

Instead of carrying two versions - is it worth always doing the memcpy? The penalty will be slightly slower when armv7 (or similar) has an aligned memory access case since it won't branch into the cast/alias version. But it will be less code duplication in our codebase and ASM.

keccak: guard against misaligned memory accesses on ARM
The code generated is exactly the same as the direct access
one on x86_64

@moneromooo-monero moneromooo-monero force-pushed the moneromooo-monero:karm branch from 5fe5d63 to c223832 Jul 4, 2019

@moneromooo-monero

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

It was 100% identical code indeed. I changed it to only use the memcpy version now.

@xiphon

xiphon approved these changes Jul 10, 2019

@luigi1111 luigi1111 merged commit c223832 into monero-project:master Jul 13, 2019

7 of 8 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
buildbot/monero-static-osx-10.11 Build done.
Details
buildbot/monero-static-osx-10.12 Build done.
Details
buildbot/monero-static-osx-10.13 Build done.
Details
buildbot/monero-static-ubuntu-amd64 Build done.
Details
buildbot/monero-static-ubuntu-i686 Build done.
Details
buildbot/monero-static-win32 Build done.
Details
buildbot/monero-static-win64 Build done.
Details

luigi1111 added a commit that referenced this pull request Jul 13, 2019

Merge pull request #5724
c223832 keccak: guard against misaligned memory accesses on ARM (moneromooo-monero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.