Skip to content

Add additional instructions required by AES-XTS on x86_64 #215

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

Merged
merged 4 commits into from
Apr 18, 2025

Conversation

pennyannn
Copy link
Collaborator

@pennyannn pennyannn commented Mar 28, 2025

Description of changes:

This PR adds additional SSE/SSE2 instructions that are used in AES-XTS on x86_64, including multi-byte NOP, PADDD,PADDQ,PAND,PCMPGTD, PSHUFD,PSRAD, and PXOR.

They are tested through hand-written tests. The tests could be removed once the AES-XTS assembly program is integrated into s2n-bignum.

In addition, this PR updates the allowed_asm file.

Notes:
The multi-byte NOP appeared in the assembled binary because of the .align directive. These .align directives are used for making sure program instructions are aligned properly (https://stackoverflow.com/questions/18113995/performance-optimisations-of-x86-64-assembly-alignment-and-branch-prediction). These .align directives are assembled into multi-byte NOPs to pad up the space. In this PR we add multi-byte NOP that supports from 2-bytes to 9-bytes. However, these multi-byte NOP can be really wild. See https://stackoverflow.com/questions/27714524/x86-multi-byte-nop-and-instruction-prefix, where it points out that Intel can have 11-byte NOP with redundant prefixes. 10-byte and up NOP requires changes to data structures and will be done in another PR.
XORPS is subject to constant-time uncertainty because it is not part of the DOIT list. Removed and will be submitted through another PR (#225).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pennyannn pennyannn force-pushed the yppe/other-xts-x86 branch from 8761129 to c51f8b3 Compare March 28, 2025 21:23
@pennyannn pennyannn changed the title Add additional instructions required by AES-XTS on x86 Add additional instructions required by AES-XTS on x86_64 Mar 28, 2025
@pennyannn pennyannn force-pushed the yppe/other-xts-x86 branch 5 times, most recently from 0e84a1b to 6b879e5 Compare April 4, 2025 20:57
@pennyannn pennyannn force-pushed the yppe/other-xts-x86 branch from 6b879e5 to 22d7cc9 Compare April 8, 2025 18:25
@pennyannn pennyannn marked this pull request as ready for review April 8, 2025 18:29
@aqjune-aws aqjune-aws self-requested a review April 8, 2025 21:06
@pennyannn pennyannn force-pushed the yppe/other-xts-x86 branch 5 times, most recently from 74fab47 to 2643849 Compare April 14, 2025 18:18
@pennyannn pennyannn force-pushed the yppe/other-xts-x86 branch from 2643849 to 9af7d7b Compare April 17, 2025 16:35
Copy link
Collaborator

@aqjune-aws aqjune-aws left a comment

Choose a reason for hiding this comment

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

Thanks for separating XORPS from this PR..!
I checked that the implementation is consistent with the descriptions of the instructions in x86 docs, and cosimulator did not found inconsistencies for the newly added instruction patterns.
I added a small patch that uses simdN/usimdN to simplify the formal semantics. Also, added EXPAND_SIMD_RULE which makes the structure of x86 semantics for SIMD analogous to that of Arm side.

@aqjune-aws aqjune-aws merged commit 99a7bfc into awslabs:main Apr 18, 2025
6 checks passed
@pennyannn pennyannn deleted the yppe/other-xts-x86 branch April 18, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants