Skip to content

Commit bc00530

Browse files
committed
sys: Prefix capability enum values with architecture
Disambiguate the mlk_sys_cap values by architecture: MLK_SYS_CAP_{AVX2,NEON,SHA3,MVE} become MLK_SYS_CAP_{X86_64_AVX2,AARCH64_NEON,AARCH64_SHA3,ARMV81M_MVE}. Generate the ABI checker tests before the macro-typo check in autogen so the renamed values in the generated check files pass validation, and drop the unused MLK_SYS_CAP_DUMMY allowlist entry. Patch AWS-LC accordingly. - Ports pq-code-package/mldsa-native#1208 - Resolves #1320 Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
1 parent e29c390 commit bc00530

60 files changed

Lines changed: 152 additions & 152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev/aarch64_clean/meta.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
MLK_MUST_CHECK_RETURN_VALUE
2929
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
3030
{
31-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
31+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
3232
{
3333
return MLK_NATIVE_FUNC_FALLBACK;
3434
}
@@ -40,7 +40,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
4040
MLK_MUST_CHECK_RETURN_VALUE
4141
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
4242
{
43-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
43+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
4444
{
4545
return MLK_NATIVE_FUNC_FALLBACK;
4646
}
@@ -52,7 +52,7 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
5252
MLK_MUST_CHECK_RETURN_VALUE
5353
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
5454
{
55-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
55+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
5656
{
5757
return MLK_NATIVE_FUNC_FALLBACK;
5858
}
@@ -63,7 +63,7 @@ static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
6363
MLK_MUST_CHECK_RETURN_VALUE
6464
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
6565
{
66-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
66+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
6767
{
6868
return MLK_NATIVE_FUNC_FALLBACK;
6969
}
@@ -75,7 +75,7 @@ MLK_MUST_CHECK_RETURN_VALUE
7575
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
7676
const int16_t y[MLKEM_N])
7777
{
78-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
78+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
7979
{
8080
return MLK_NATIVE_FUNC_FALLBACK;
8181
}
@@ -91,7 +91,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k2_native(
9191
int16_t r[MLKEM_N], const int16_t a[2 * MLKEM_N],
9292
const int16_t b[2 * MLKEM_N], const int16_t b_cache[2 * (MLKEM_N / 2)])
9393
{
94-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
94+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
9595
{
9696
return MLK_NATIVE_FUNC_FALLBACK;
9797
}
@@ -106,7 +106,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k3_native(
106106
int16_t r[MLKEM_N], const int16_t a[3 * MLKEM_N],
107107
const int16_t b[3 * MLKEM_N], const int16_t b_cache[3 * (MLKEM_N / 2)])
108108
{
109-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
109+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
110110
{
111111
return MLK_NATIVE_FUNC_FALLBACK;
112112
}
@@ -121,7 +121,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
121121
int16_t r[MLKEM_N], const int16_t a[4 * MLKEM_N],
122122
const int16_t b[4 * MLKEM_N], const int16_t b_cache[4 * (MLKEM_N / 2)])
123123
{
124-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
124+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
125125
{
126126
return MLK_NATIVE_FUNC_FALLBACK;
127127
}
@@ -134,7 +134,7 @@ MLK_MUST_CHECK_RETURN_VALUE
134134
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
135135
const int16_t a[MLKEM_N])
136136
{
137-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
137+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
138138
{
139139
return MLK_NATIVE_FUNC_FALLBACK;
140140
}
@@ -147,7 +147,7 @@ static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
147147
const uint8_t *buf,
148148
unsigned buflen)
149149
{
150-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) || len != MLKEM_N ||
150+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) || len != MLKEM_N ||
151151
buflen % 24 != 0)
152152
{
153153
return MLK_NATIVE_FUNC_FALLBACK;

dev/aarch64_opt/meta.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
MLK_MUST_CHECK_RETURN_VALUE
2929
static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
3030
{
31-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
31+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
3232
{
3333
return MLK_NATIVE_FUNC_FALLBACK;
3434
}
@@ -40,7 +40,7 @@ static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
4040
MLK_MUST_CHECK_RETURN_VALUE
4141
static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
4242
{
43-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
43+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
4444
{
4545
return MLK_NATIVE_FUNC_FALLBACK;
4646
}
@@ -52,7 +52,7 @@ static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
5252
MLK_MUST_CHECK_RETURN_VALUE
5353
static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
5454
{
55-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
55+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
5656
{
5757
return MLK_NATIVE_FUNC_FALLBACK;
5858
}
@@ -63,7 +63,7 @@ static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
6363
MLK_MUST_CHECK_RETURN_VALUE
6464
static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
6565
{
66-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
66+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
6767
{
6868
return MLK_NATIVE_FUNC_FALLBACK;
6969
}
@@ -75,7 +75,7 @@ MLK_MUST_CHECK_RETURN_VALUE
7575
static MLK_INLINE int mlk_poly_mulcache_compute_native(int16_t x[MLKEM_N / 2],
7676
const int16_t y[MLKEM_N])
7777
{
78-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
78+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
7979
{
8080
return MLK_NATIVE_FUNC_FALLBACK;
8181
}
@@ -91,7 +91,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k2_native(
9191
int16_t r[MLKEM_N], const int16_t a[2 * MLKEM_N],
9292
const int16_t b[2 * MLKEM_N], const int16_t b_cache[2 * (MLKEM_N / 2)])
9393
{
94-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
94+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
9595
{
9696
return MLK_NATIVE_FUNC_FALLBACK;
9797
}
@@ -106,7 +106,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k3_native(
106106
int16_t r[MLKEM_N], const int16_t a[3 * MLKEM_N],
107107
const int16_t b[3 * MLKEM_N], const int16_t b_cache[3 * (MLKEM_N / 2)])
108108
{
109-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
109+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
110110
{
111111
return MLK_NATIVE_FUNC_FALLBACK;
112112
}
@@ -121,7 +121,7 @@ static MLK_INLINE int mlk_polyvec_basemul_acc_montgomery_cached_k4_native(
121121
int16_t r[MLKEM_N], const int16_t a[4 * MLKEM_N],
122122
const int16_t b[4 * MLKEM_N], const int16_t b_cache[4 * (MLKEM_N / 2)])
123123
{
124-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
124+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
125125
{
126126
return MLK_NATIVE_FUNC_FALLBACK;
127127
}
@@ -134,7 +134,7 @@ MLK_MUST_CHECK_RETURN_VALUE
134134
static MLK_INLINE int mlk_poly_tobytes_native(uint8_t r[MLKEM_POLYBYTES],
135135
const int16_t a[MLKEM_N])
136136
{
137-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
137+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
138138
{
139139
return MLK_NATIVE_FUNC_FALLBACK;
140140
}
@@ -147,7 +147,7 @@ static MLK_INLINE int mlk_rej_uniform_native(int16_t *r, unsigned len,
147147
const uint8_t *buf,
148148
unsigned buflen)
149149
{
150-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) || len != MLKEM_N ||
150+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) || len != MLKEM_N ||
151151
buflen % 24 != 0)
152152
{
153153
return MLK_NATIVE_FUNC_FALLBACK;

dev/fips202/aarch64/x1_v84a.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
MLK_MUST_CHECK_RETURN_VALUE
2222
static MLK_INLINE int mlk_keccak_f1600_x1_native(uint64_t *state)
2323
{
24-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) ||
25-
!mlk_sys_check_capability(MLK_SYS_CAP_SHA3))
24+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
25+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
2626
{
2727
return MLK_NATIVE_FUNC_FALLBACK;
2828
}

dev/fips202/aarch64/x2_v84a.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
MLK_MUST_CHECK_RETURN_VALUE
2222
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
2323
{
24-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) ||
25-
!mlk_sys_check_capability(MLK_SYS_CAP_SHA3))
24+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
25+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
2626
{
2727
return MLK_NATIVE_FUNC_FALLBACK;
2828
}

dev/fips202/aarch64/x4_v8a_scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MLK_MUST_CHECK_RETURN_VALUE
1818
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
1919
{
20-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON))
20+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON))
2121
{
2222
return MLK_NATIVE_FUNC_FALLBACK;
2323
}

dev/fips202/aarch64/x4_v8a_v84a_scalar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
MLK_MUST_CHECK_RETURN_VALUE
2222
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
2323
{
24-
if (!mlk_sys_check_capability(MLK_SYS_CAP_NEON) ||
25-
!mlk_sys_check_capability(MLK_SYS_CAP_SHA3))
24+
if (!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_NEON) ||
25+
!mlk_sys_check_capability(MLK_SYS_CAP_AARCH64_SHA3))
2626
{
2727
return MLK_NATIVE_FUNC_FALLBACK;
2828
}

dev/fips202/x86_64/keccak_f1600_x4_avx2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
MLK_MUST_CHECK_RETURN_VALUE
2020
static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
2121
{
22-
if (!mlk_sys_check_capability(MLK_SYS_CAP_AVX2))
22+
if (!mlk_sys_check_capability(MLK_SYS_CAP_X86_64_AVX2))
2323
{
2424
return MLK_NATIVE_FUNC_FALLBACK;
2525
}

0 commit comments

Comments
 (0)