-
Notifications
You must be signed in to change notification settings - Fork 26
Add Runtime dispatch based on custom CPU capabilities function #607
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
Conversation
6332a01 to
b0ac532
Compare
74996f5 to
3e7a817
Compare
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @willieyz for all your work!
Overall, it looks good, but there are a few points we may want to refine:
- As @mkannwischer mentions, some SHA3 guards in the AArch64 FIPS202 are unnecessary.
- We need documentation in the native backend that the decision whether to fall back or not must not depend on the input data. This is part of the contract between frontend and backend.
- There is a lot of duplicated post-conditions now which we may want to remove.
The next step is going to be to hoist out the C versions to separate functions to unblock the backend unit tests. |
7cd48f2 to
714c943
Compare
mkannwischer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @willieyz. Two small changes and then I think this is good to go.
315c4ef to
ac5ced9
Compare
mkannwischer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @willieyz. This is a great improvement and will enable integrating the x86_64 backend into AWS-LC eventually.
ac5ced9 to
bda2e6b
Compare
…te_bitrev_to_custom) - Change mld_ntt_native() return type from void to int - Add runtime capability checking with fallback support - Implement dispatch logic in mld_poly_ntt() to try native first, fallback to C - Add MLD_NATIVE_FUNC_SUCCESS/FALLBACK return codes - Add mld_sys_check_capability() for system capability detection - Add test configuration for AVX2, static ON/OFF, add to CI test. Signed-off-by: willieyz <willie.zhao@chelpis.com>
…a4_native) Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
The inputs to chknorm are potentially secret. However, it is fine (and unavoidable) to leak if chknorm return 0 or 1 (i.e., if all coeffs are within bound or not). The declassification of that currently happens in sign.c. However, for the run-time dispatch we require to branch depending on whether mld_poly_chknorm_native returns MLD_NATIVE_FUNC_FALLBACK (-1) or not to signal that the platform does not have the required capabilities to run the native code (and we should hence fallback to the C code). This commit adds a declassification of (ret == FALLBACK) which is sufficient to make this code pass the constant time tests. The declassification of the actual value (0/1) remains in sign.c to be consistent with the C implementation. Co-authored-by: Matthias J. Kannwischer <matthias@kannwischer.eu> Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
…native) Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com>
Signed-off-by: willieyz <willie.zhao@chelpis.com> add changes Signed-off-by: willieyz <willie.zhao@chelpis.com>
bda2e6b to
23a88fc
Compare
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @willieyz, this is great. LGTM
This PR made following changes:
CBMC-related changes, including adding the CBMC proof for sys_check_capability, will be added in a separate PR (tracked by issue #723).
Additional changes discovered during PR progress, related with
mld_poly_chknorm:mld_poly_chknormhas been adjusted to properly signal fallback, instead of directly using 0 or -1.This distinction allows the runtime to detect when to fallback to the C implementation.
(ret == FALLBACK)to make this code pass the constant time tests.