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

bn_mul.h: require at least ARMv6 to enable the ARM DSP code #2777

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Aug 5, 2019

Fix the build on ARMv5TE in ARM mode. The assembly code in bn_mul.h uses DSP instructions that are not available on this particular architecture, so set the conditional compilation directives to exclude them.

Fix originally contributed in #2169 by @aurel32. I rebased to current development to facilitate testing and added a changelog entry and a non-regression test.

Needs backport to 2.16: #2778. The offending code is not present in 2.7.

aurel32 and others added 3 commits August 3, 2019 14:18
Commit 16b1bd8 "bn_mul.h: add ARM DSP optimized MULADDC code"
added some ARM DSP instructions that was assumed to always be available
when __ARM_FEATURE_DSP is defined to 1. Unfortunately it appears that
the ARMv5TE architecture (GCC flag -march=armv5te) supports the DSP
instructions, but only in Thumb mode and not in ARM mode, despite
defining __ARM_FEATURE_DSP in both cases.

This patch fixes the build issue by requiring at least ARMv6 in addition
to the DSP feature.
Non-regression test for
"bn_mul.h: require at least ARMv6 to enable the ARM DSP code"
@gilles-peskine-arm gilles-peskine-arm added bug CLA valid needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. component-crypto Crypto primitives and low-level interfaces labels Aug 5, 2019
Without any -O option, the default is -O0, and then the assembly code
is not used, so this would not be a non-regression test for the
assembly code that doesn't build.
@k-stachowiak k-stachowiak self-requested a review August 8, 2019 14:29
@gilles-peskine-arm gilles-peskine-arm force-pushed the bn_mul-arm-dsp-fix-development branch from be0a059 to 8a52af9 Compare August 8, 2019 16:17
@jainvikas8 jainvikas8 self-requested a review August 8, 2019 16:20
@jainvikas8
Copy link
Contributor

jainvikas8 commented Aug 8, 2019

There was a bug in the non-regression test which was fixed in 8a52af9, which was to do with compiler optimization flag not set. The test was passing with the fix - 5daa34f, which shouldn't be the case

Further, on the investigation, there were a couple of non-regression tests which were not using the optimization flags, but I strongly think this be0a059 needs to be raised as new PR.

I'm happy for this PR to be merged.

jainvikas8
jainvikas8 previously approved these changes Aug 8, 2019
AndrzejKurek
AndrzejKurek previously approved these changes Aug 9, 2019
k-stachowiak
k-stachowiak previously approved these changes Aug 9, 2019
Copy link
Contributor

@k-stachowiak k-stachowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good. I verified locally, that the bug is present without the introduced changes, and that they actually fix it.
I made a minor comment regarding the test's name.

tests/scripts/all.sh Outdated Show resolved Hide resolved
Call the component xxx_arm5vte, because that's what it does. Explain
"armel", and more generally why this component exists, in a comment.
Copy link
Contributor

@k-stachowiak k-stachowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gilles-peskine-arm for addressing my comment.

@gilles-peskine-arm gilles-peskine-arm removed the needs-backports Backports are missing or are pending review and approval. label Aug 13, 2019
@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Aug 13, 2019
@gilles-peskine-arm gilles-peskine-arm merged commit 2c897d7 into Mbed-TLS:development Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-crypto Crypto primitives and low-level interfaces
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants