Skip to content

Commit 9697fa3

Browse files
dwmw2KAGA-KOKO
authored andcommitted
x86/retpoline/crypto: Convert crypto assembler indirect jumps
Convert all indirect jumps in crypto assembler code to use non-speculative sequences when CONFIG_RETPOLINE is enabled. Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Arjan van de Ven <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: [email protected] Cc: Rik van Riel <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: [email protected] Cc: Peter Zijlstra <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Kees Cook <[email protected]> Cc: Tim Chen <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Paul Turner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent da28512 commit 9697fa3

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

arch/x86/crypto/aesni-intel_asm.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/linkage.h>
3333
#include <asm/inst.h>
3434
#include <asm/frame.h>
35+
#include <asm/nospec-branch.h>
3536

3637
/*
3738
* The following macros are used to move an (un)aligned 16 byte value to/from
@@ -2884,7 +2885,7 @@ ENTRY(aesni_xts_crypt8)
28842885
pxor INC, STATE4
28852886
movdqu IV, 0x30(OUTP)
28862887

2887-
call *%r11
2888+
CALL_NOSPEC %r11
28882889

28892890
movdqu 0x00(OUTP), INC
28902891
pxor INC, STATE1
@@ -2929,7 +2930,7 @@ ENTRY(aesni_xts_crypt8)
29292930
_aesni_gf128mul_x_ble()
29302931
movups IV, (IVP)
29312932

2932-
call *%r11
2933+
CALL_NOSPEC %r11
29332934

29342935
movdqu 0x40(OUTP), INC
29352936
pxor INC, STATE1

arch/x86/crypto/camellia-aesni-avx-asm_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <linux/linkage.h>
1919
#include <asm/frame.h>
20+
#include <asm/nospec-branch.h>
2021

2122
#define CAMELLIA_TABLE_BYTE_LEN 272
2223

@@ -1227,7 +1228,7 @@ camellia_xts_crypt_16way:
12271228
vpxor 14 * 16(%rax), %xmm15, %xmm14;
12281229
vpxor 15 * 16(%rax), %xmm15, %xmm15;
12291230

1230-
call *%r9;
1231+
CALL_NOSPEC %r9;
12311232

12321233
addq $(16 * 16), %rsp;
12331234

arch/x86/crypto/camellia-aesni-avx2-asm_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/linkage.h>
1414
#include <asm/frame.h>
15+
#include <asm/nospec-branch.h>
1516

1617
#define CAMELLIA_TABLE_BYTE_LEN 272
1718

@@ -1343,7 +1344,7 @@ camellia_xts_crypt_32way:
13431344
vpxor 14 * 32(%rax), %ymm15, %ymm14;
13441345
vpxor 15 * 32(%rax), %ymm15, %ymm15;
13451346

1346-
call *%r9;
1347+
CALL_NOSPEC %r9;
13471348

13481349
addq $(16 * 32), %rsp;
13491350

arch/x86/crypto/crc32c-pcl-intel-asm_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#include <asm/inst.h>
4747
#include <linux/linkage.h>
48+
#include <asm/nospec-branch.h>
4849

4950
## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
5051

@@ -172,7 +173,7 @@ continue_block:
172173
movzxw (bufp, %rax, 2), len
173174
lea crc_array(%rip), bufp
174175
lea (bufp, len, 1), bufp
175-
jmp *bufp
176+
JMP_NOSPEC bufp
176177

177178
################################################################
178179
## 2a) PROCESS FULL BLOCKS:

0 commit comments

Comments
 (0)