Skip to content

Commit 91e7906

Browse files
pablodelaratkanteck
authored andcommitted
erasure_code: check for size on gf_vect_mul_sse/avx
gf_vect_mul requires length to be multiple of 32 bytes, so this check is added in the SSE/AVX implementations. Signed-off-by: Pablo de Lara <[email protected]>
1 parent 2759771 commit 91e7906

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

erasure_code/gf_vect_mul_avx.asm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
%define arg1 rsi
3939
%define arg2 rdx
4040
%define arg3 rcx
41-
%define arg4 r8
42-
%define arg5 r9
43-
%define tmp r11
4441
%define return rax
4542
%define func(x) x: endbranch
4643
%define FUNC_SAVE
@@ -81,6 +78,7 @@
8178
%define src arg2
8279
%define dest arg3
8380
%define pos return
81+
%define tmp r11
8482

8583

8684
;;; Use Non-temporal load/stor
@@ -113,7 +111,14 @@ section .text
113111
align 16
114112
mk_global gf_vect_mul_avx, function
115113
func(gf_vect_mul_avx)
114+
115+
; Check if length is multiple of 32 bytes
116+
mov tmp, len
117+
and tmp, 0x1f
118+
jnz return_fail
119+
116120
FUNC_SAVE
121+
117122
mov pos, 0
118123
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
119124
vmovdqu xgft_lo, [mul_array] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
@@ -140,14 +145,13 @@ loop32:
140145
XSTR [dest+pos-16], xtmp2b ;Store +16B result
141146
jl loop32
142147

148+
FUNC_RESTORE
143149

144150
return_pass:
145-
FUNC_RESTORE
146-
sub pos, len
151+
xor return, return
147152
ret
148153

149154
return_fail:
150-
FUNC_RESTORE
151155
mov return, 1
152156
ret
153157

erasure_code/gf_vect_mul_sse.asm

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
%define arg1 rsi
3939
%define arg2 rdx
4040
%define arg3 rcx
41-
%define arg4 r8
42-
%define arg5 r9
43-
%define tmp r11
4441
%define return rax
4542
%define func(x) x: endbranch
4643
%define FUNC_SAVE
@@ -81,6 +78,7 @@
8178
%define src arg2
8279
%define dest arg3
8380
%define pos return
81+
%define tmp r11
8482

8583

8684
;;; Use Non-temporal load/stor
@@ -114,7 +112,13 @@ section .text
114112
align 16
115113
mk_global gf_vect_mul_sse, function
116114
func(gf_vect_mul_sse)
115+
; Check if length is multiple of 32 bytes
116+
mov tmp, len
117+
and tmp, 0x1f
118+
jnz return_fail
119+
117120
FUNC_SAVE
121+
118122
mov pos, 0
119123
movdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
120124
movdqu xgft_lo, [mul_array] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
@@ -147,15 +151,14 @@ loop32:
147151
cmp pos, len
148152
jl loop32
149153

154+
FUNC_RESTORE
150155

151156
return_pass:
152-
sub pos, len
153-
FUNC_RESTORE
157+
xor return, return
154158
ret
155159

156160
return_fail:
157161
mov return, 1
158-
FUNC_RESTORE
159162
ret
160163

161164
endproc_frame

0 commit comments

Comments
 (0)