Implement G23 Extended Cauchy construction for AES RAID mode
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-08-21 19:40:48 +02:00
parent a831853092
commit 48bed76dd1
20 changed files with 5716 additions and 5639 deletions

View file

@ -9,7 +9,7 @@
/*
* GEN3 (triple parity with Cauchy matrix) SSSE3 implementation
*/
static __always_inline void raid_gen3_ssse3_gen(int nd, size_t size, void **vv, int generator)
static __always_inline void raid_gen3_ssse3_gen(int nd, size_t size, void **vv, int g23)
{
uint8_t **v = (uint8_t **)vv;
uint8_t *p;
@ -58,14 +58,14 @@ static __always_inline void raid_gen3_ssse3_gen(int nd, size_t size, void **vv,
for (d = l - 1; d > 0; --d) {
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("pxor %xmm5,%xmm5");
asm volatile ("pcmpgtb %xmm1,%xmm5");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm3,%xmm5");
asm volatile ("pxor %xmm5,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm4,%xmm0");
@ -87,14 +87,14 @@ static __always_inline void raid_gen3_ssse3_gen(int nd, size_t size, void **vv,
/* first disk with all coefficients at 1 */
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("pxor %xmm5,%xmm5");
asm volatile ("pcmpgtb %xmm1,%xmm5");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm3,%xmm5");
asm volatile ("pxor %xmm5,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm4,%xmm0");
@ -111,12 +111,12 @@ static __always_inline void raid_gen3_ssse3_gen(int nd, size_t size, void **vv,
void raid_gen3_ssse3_raid(int nd, size_t size, void **vv)
{
raid_gen3_ssse3_gen(nd, size, vv, 2);
raid_gen3_ssse3_gen(nd, size, vv, 0);
}
void raid_gen3_ssse3_aes(int nd, size_t size, void **vv)
{
raid_gen3_ssse3_gen(nd, size, vv, 3);
raid_gen3_ssse3_gen(nd, size, vv, 1);
}
#ifdef CONFIG_X86_64
@ -125,7 +125,7 @@ void raid_gen3_ssse3_aes(int nd, size_t size, void **vv)
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **vv, int generator)
static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **vv, int g23)
{
uint8_t **v = (uint8_t **)vv;
uint8_t *p;
@ -191,7 +191,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm7" : : "m" (raid_gfcauchypshufb[d][1][0][0]));
asm volatile ("movdqa %0,%%xmm15" : : "m" (raid_gfcauchypshufb[d][1][1][0]));
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -205,7 +205,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm3,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -241,7 +241,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm7" : : "m" (raid_gfcauchypshufb[d - 1][1][0][0]));
asm volatile ("movdqa %0,%%xmm15" : : "m" (raid_gfcauchypshufb[d - 1][1][1][0]));
if (generator == 3) {
if (g23 && raid_g23_x3(d - 1)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -255,7 +255,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm3,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d - 1)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -290,7 +290,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[1][i]));
asm volatile ("movdqa %0,%%xmm12" : : "m" (v[1][i + 16]));
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -304,7 +304,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm3,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -341,7 +341,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i]));
asm volatile ("movdqa %0,%%xmm12" : : "m" (v[0][i + 16]));
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -355,7 +355,7 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm3,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -380,19 +380,19 @@ static __always_inline void raid_gen3_ssse3ext_gen(int nd, size_t size, void **v
void raid_gen3_ssse3ext_raid(int nd, size_t size, void **vv)
{
raid_gen3_ssse3ext_gen(nd, size, vv, 2);
raid_gen3_ssse3ext_gen(nd, size, vv, 0);
}
void raid_gen3_ssse3ext_aes(int nd, size_t size, void **vv)
{
raid_gen3_ssse3ext_gen(nd, size, vv, 3);
raid_gen3_ssse3ext_gen(nd, size, vv, 1);
}
#endif
/*
* GEN4 (quad parity with Cauchy matrix) SSSE3 implementation
*/
static __always_inline void raid_gen4_ssse3_gen(int nd, size_t size, void **vv, int generator)
static __always_inline void raid_gen4_ssse3_gen(int nd, size_t size, void **vv, int g23)
{
uint8_t **v = (uint8_t **)vv;
uint8_t *p;
@ -448,14 +448,14 @@ static __always_inline void raid_gen4_ssse3_gen(int nd, size_t size, void **vv,
asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("pxor %xmm5,%xmm5");
asm volatile ("pcmpgtb %xmm1,%xmm5");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm7,%xmm5");
asm volatile ("pxor %xmm5,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
@ -487,14 +487,14 @@ static __always_inline void raid_gen4_ssse3_gen(int nd, size_t size, void **vv,
asm volatile ("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("pxor %xmm5,%xmm5");
asm volatile ("pcmpgtb %xmm1,%xmm5");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm7,%xmm5");
asm volatile ("pxor %xmm5,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm4,%xmm0");
@ -513,12 +513,12 @@ static __always_inline void raid_gen4_ssse3_gen(int nd, size_t size, void **vv,
void raid_gen4_ssse3_raid(int nd, size_t size, void **vv)
{
raid_gen4_ssse3_gen(nd, size, vv, 2);
raid_gen4_ssse3_gen(nd, size, vv, 0);
}
void raid_gen4_ssse3_aes(int nd, size_t size, void **vv)
{
raid_gen4_ssse3_gen(nd, size, vv, 3);
raid_gen4_ssse3_gen(nd, size, vv, 1);
}
#ifdef CONFIG_X86_64
@ -527,7 +527,7 @@ void raid_gen4_ssse3_aes(int nd, size_t size, void **vv)
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **vv, int generator)
static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **vv, int g23)
{
uint8_t **v = (uint8_t **)vv;
uint8_t *p;
@ -602,7 +602,7 @@ static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[d][i]));
asm volatile ("movdqa %0,%%xmm12" : : "m" (v[d][i + 16]));
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -616,7 +616,7 @@ static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm7,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -668,7 +668,7 @@ static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("movdqa %0,%%xmm4" : : "m" (v[0][i]));
asm volatile ("movdqa %0,%%xmm12" : : "m" (v[0][i + 16]));
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("movdqa %xmm1,%xmm6");
asm volatile ("movdqa %xmm9,%xmm14");
}
@ -682,7 +682,7 @@ static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **v
asm volatile ("pand %xmm7,%xmm13");
asm volatile ("pxor %xmm5,%xmm1");
asm volatile ("pxor %xmm13,%xmm9");
if (generator == 3) {
if (g23 && raid_g23_x3(d)) {
asm volatile ("pxor %xmm6,%xmm1");
asm volatile ("pxor %xmm14,%xmm9");
}
@ -711,12 +711,12 @@ static __always_inline void raid_gen4_ssse3ext_gen(int nd, size_t size, void **v
void raid_gen4_ssse3ext_raid(int nd, size_t size, void **vv)
{
raid_gen4_ssse3ext_gen(nd, size, vv, 2);
raid_gen4_ssse3ext_gen(nd, size, vv, 0);
}
void raid_gen4_ssse3ext_aes(int nd, size_t size, void **vv)
{
raid_gen4_ssse3ext_gen(nd, size, vv, 3);
raid_gen4_ssse3ext_gen(nd, size, vv, 1);
}
#endif
@ -859,7 +859,7 @@ void raid_gen5_ssse3_raid(int nd, size_t size, void **vv)
/*
* GENX SSSE3ext implementation
*/
static __always_inline void raid_genX_ssse3ext(int nd, size_t size, void **vv, int np, int generator)
static __always_inline void raid_genX_ssse3ext(int nd, size_t size, void **vv, int np, int g23)
{
uint8_t **v = (uint8_t **)vv;
uint8_t *p;
@ -941,14 +941,14 @@ static __always_inline void raid_genX_ssse3ext(int nd, size_t size, void **vv, i
for (d = l - 1; d > 0; --d) {
asm volatile ("movdqa %0,%%xmm10" : : "m" (v[d][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm12");
asm volatile ("pxor %xmm11,%xmm11");
asm volatile ("pcmpgtb %xmm1,%xmm11");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm14,%xmm11");
asm volatile ("pxor %xmm11,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm12,%xmm1");
asm volatile ("pxor %xmm10,%xmm0");
@ -999,14 +999,14 @@ static __always_inline void raid_genX_ssse3ext(int nd, size_t size, void **vv, i
/* first disk with all coefficients at 1 */
asm volatile ("movdqa %0,%%xmm10" : : "m" (v[0][i]));
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("movdqa %xmm1,%xmm12");
asm volatile ("pxor %xmm11,%xmm11");
asm volatile ("pcmpgtb %xmm1,%xmm11");
asm volatile ("paddb %xmm1,%xmm1");
asm volatile ("pand %xmm14,%xmm11");
asm volatile ("pxor %xmm11,%xmm1");
if (generator == 3)
if (g23 && raid_g23_x3(d))
asm volatile ("pxor %xmm12,%xmm1");
asm volatile ("pxor %xmm10,%xmm0");
@ -1042,12 +1042,12 @@ static __always_inline void raid_genX_ssse3ext(int nd, size_t size, void **vv, i
*/
void raid_gen5_ssse3ext_raid(int nd, size_t size, void **vv)
{
raid_genX_ssse3ext(nd, size, vv, 5, 2);
raid_genX_ssse3ext(nd, size, vv, 5, 0);
}
void raid_gen5_ssse3ext_aes(int nd, size_t size, void **vv)
{
raid_genX_ssse3ext(nd, size, vv, 5, 3);
raid_genX_ssse3ext(nd, size, vv, 5, 1);
}
#endif
@ -1215,12 +1215,12 @@ void raid_gen6_ssse3_raid(int nd, size_t size, void **vv)
*/
void raid_gen6_ssse3ext_raid(int nd, size_t size, void **vv)
{
raid_genX_ssse3ext(nd, size, vv, 6, 2);
raid_genX_ssse3ext(nd, size, vv, 6, 0);
}
void raid_gen6_ssse3ext_aes(int nd, size_t size, void **vv)
{
raid_genX_ssse3ext(nd, size, vv, 6, 3);
raid_genX_ssse3ext(nd, size, vv, 6, 1);
}
#endif