Skip to content

Commit af7b121

Browse files
authored
Merge pull request #1106 from pq-code-package/issue_1009
tests: Add `--aarch64-fips202-backend` choosing arm fips202 backend
2 parents bcd852d + 460d2b0 commit af7b121

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.github/actions/functest/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ inputs:
4949
stack:
5050
description: Determine whether to run stack analysis or not
5151
default: "false"
52+
extra_args:
53+
description: Additional arguments to pass to the tests script
54+
default: ""
5255
runs:
5356
using: composite
5457
steps:
@@ -96,7 +99,7 @@ runs:
9699
shell: ${{ env.SHELL }}
97100
run: |
98101
make clean
99-
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} -v
102+
./scripts/tests all ${{ inputs.check_namespace == 'true' && '--check-namespace' || ''}} --exec-wrapper="${{ inputs.exec_wrapper }}" --cross-prefix="${{ inputs.cross_prefix }}" --cflags="${{ inputs.cflags }}" --opt=${{ inputs.opt }} --${{ env.FUNC }} --${{ env.KAT }} --${{ env.ACVP }} --${{ env.EXAMPLES }} --${{ env.STACK }} -v ${{ inputs.extra_args }}
100103
- name: Post ${{ env.MODE }} Tests
101104
shell: ${{ env.SHELL }}
102105
if: success() || failure()

.github/actions/multi-functest/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ inputs:
4646
stack:
4747
description: Determine whether to run stack analysis or not
4848
default: "false"
49+
extra_args:
50+
description: Additional arguments to pass to the tests script
51+
default: ""
4952
runs:
5053
using: composite
5154
steps:
@@ -66,6 +69,7 @@ runs:
6669
examples: ${{ inputs.examples }}
6770
check_namespace: ${{ inputs.check_namespace }}
6871
stack: ${{ inputs.stack }}
72+
extra_args: ${{ inputs.extra_args }}
6973
- name: Cross x86_64 Tests
7074
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-x86_64') && (success() || failure()) }}
7175
uses: ./.github/actions/functest
@@ -85,6 +89,7 @@ runs:
8589
examples: ${{ inputs.examples }}
8690
check_namespace: ${{ inputs.check_namespace }}
8791
stack: ${{ inputs.stack }}
92+
extra_args: ${{ inputs.extra_args }}
8893
- name: Cross aarch64 Tests
8994
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-aarch64') && (success() || failure()) }}
9095
uses: ./.github/actions/functest
@@ -104,6 +109,7 @@ runs:
104109
examples: ${{ inputs.examples }}
105110
check_namespace: ${{ inputs.check_namespace }}
106111
stack: ${{ inputs.stack }}
112+
extra_args: ${{ inputs.extra_args }}
107113
- name: Cross ppc64le Tests
108114
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-ppc64le') && (success() || failure()) }}
109115
uses: ./.github/actions/functest
@@ -123,6 +129,7 @@ runs:
123129
examples: ${{ inputs.examples }}
124130
check_namespace: ${{ inputs.check_namespace }}
125131
stack: ${{ inputs.stack }}
132+
extra_args: ${{ inputs.extra_args }}
126133
- name: Cross aarch64_be Tests
127134
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-aarch64_be') && (success() || failure()) }}
128135
uses: ./.github/actions/functest
@@ -142,6 +149,7 @@ runs:
142149
examples: ${{ inputs.examples }}
143150
check_namespace: ${{ inputs.check_namespace }}
144151
stack: ${{ inputs.stack }}
152+
extra_args: ${{ inputs.extra_args }}
145153
- name: Cross riscv64 Tests
146154
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv64') && (success() || failure()) }}
147155
uses: ./.github/actions/functest
@@ -161,6 +169,7 @@ runs:
161169
examples: ${{ inputs.examples }}
162170
check_namespace: ${{ inputs.check_namespace }}
163171
stack: ${{ inputs.stack }}
172+
extra_args: ${{ inputs.extra_args }}
164173
- name: Cross riscv32 Tests
165174
if: ${{ (inputs.compile_mode == 'all' || inputs.compile_mode == 'cross-riscv32') && (success() || failure()) }}
166175
uses: ./.github/actions/functest
@@ -180,3 +189,4 @@ runs:
180189
examples: ${{ inputs.examples }}
181190
check_namespace: ${{ inputs.check_namespace }}
182191
stack: ${{ inputs.stack }}
192+
extra_args: ${{ inputs.extra_args }}

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ jobs:
169169
compile_mode: 'native'
170170
opt: 'opt'
171171
examples: 'false'
172-
cflags: "-DMLKEM_DEBUG -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -DMLK_FORCE_AARCH64 -DMLK_CONFIG_FIPS202_BACKEND_FILE=\\\\\\\"fips202/native/aarch64/${{ matrix.backend }}.h\\\\\\\""
172+
cflags: "-DMLKEM_DEBUG -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all"
173173
check_namespace: 'false'
174+
extra_args: "--fips202-aarch64-backend ${{ matrix.backend }}"
174175
compiler_tests:
175176
name: Compiler tests (${{ matrix.compiler.name }}, ${{ matrix.target.name }}, ${{ matrix.cflags }})
176177
strategy:

scripts/tests

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,18 @@ class Tests:
422422
if test_type.is_example() and self.args.cross_prefix != "":
423423
cflags += " -static"
424424

425+
# Add FIPS202 backend selection if specified and this is an OPT build
426+
if self.args.fips202_aarch64_backend != "auto" and opt is True:
427+
# Make sure we're forcing AArch64 architecture
428+
if not " -DMLK_FORCE_AARCH64" in cflags:
429+
cflags += " -DMLK_FORCE_AARCH64"
430+
431+
# Enable native backend for FIPS202
432+
cflags += " -DMLK_CONFIG_USE_NATIVE_BACKEND_FIPS202"
433+
434+
# Specify the backend file
435+
cflags += f' -DMLK_CONFIG_FIPS202_BACKEND_FILE=\\"fips202/native/aarch64/{self.args.fips202_aarch64_backend}.h\\"'
436+
425437
env_update = {}
426438
if cflags != "":
427439
env_update["CFLAGS"] = cflags
@@ -933,6 +945,21 @@ def cli():
933945
default="ALL",
934946
)
935947

948+
common_parser.add_argument(
949+
"--fips202-aarch64-backend",
950+
help="Select FIPS202 AArch64 backend",
951+
choices=[
952+
"auto",
953+
"x1_scalar",
954+
"x1_v84a",
955+
"x2_v84a",
956+
"x4_v8a_scalar",
957+
"x4_v8a_v84a_scalar",
958+
],
959+
default="auto",
960+
type=str,
961+
)
962+
936963
# --run / --no-run
937964
run_group = common_parser.add_mutually_exclusive_group()
938965
run_group.add_argument(

0 commit comments

Comments
 (0)