Skip to content

Commit 8c69e7a

Browse files
committed
Merge tag 'x86_alternatives_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 instruction alternatives updates from Borislav Petkov: - Up until now the Fast Short Rep Mov optimizations implied the presence of the ERMS CPUID flag. AMD decoupled them with a BIOS setting so decouple that dependency in the kernel code too - Teach the alternatives machinery to handle relocations - Make debug_alternative accept flags in order to see only that set of patching done one is interested in - Other fixes, cleanups and optimizations to the patching code * tag 'x86_alternatives_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/alternative: PAUSE is not a NOP x86/alternatives: Add cond_resched() to text_poke_bp_batch() x86/nospec: Shorten RESET_CALL_DEPTH x86/alternatives: Add longer 64-bit NOPs x86/alternatives: Fix section mismatch warnings x86/alternative: Optimize returns patching x86/alternative: Complicate optimize_nops() some more x86/alternative: Rewrite optimize_nops() some x86/lib/memmove: Decouple ERMS from FSRM x86/alternative: Support relocations in alternatives x86/alternative: Make debug-alternative selective
2 parents aa35a48 + 2bd4aa9 commit 8c69e7a

6 files changed

Lines changed: 361 additions & 168 deletions

File tree

arch/x86/include/asm/nops.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define BYTES_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00
3535
#define BYTES_NOP8 0x3e,BYTES_NOP7
3636

37+
#define ASM_NOP_MAX 8
38+
3739
#else
3840

3941
/*
@@ -47,6 +49,9 @@
4749
* 6: osp nopl 0x00(%eax,%eax,1)
4850
* 7: nopl 0x00000000(%eax)
4951
* 8: nopl 0x00000000(%eax,%eax,1)
52+
* 9: cs nopl 0x00000000(%eax,%eax,1)
53+
* 10: osp cs nopl 0x00000000(%eax,%eax,1)
54+
* 11: osp osp cs nopl 0x00000000(%eax,%eax,1)
5055
*/
5156
#define BYTES_NOP1 0x90
5257
#define BYTES_NOP2 0x66,BYTES_NOP1
@@ -56,6 +61,15 @@
5661
#define BYTES_NOP6 0x66,BYTES_NOP5
5762
#define BYTES_NOP7 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00
5863
#define BYTES_NOP8 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00
64+
#define BYTES_NOP9 0x2e,BYTES_NOP8
65+
#define BYTES_NOP10 0x66,BYTES_NOP9
66+
#define BYTES_NOP11 0x66,BYTES_NOP10
67+
68+
#define ASM_NOP9 _ASM_BYTES(BYTES_NOP9)
69+
#define ASM_NOP10 _ASM_BYTES(BYTES_NOP10)
70+
#define ASM_NOP11 _ASM_BYTES(BYTES_NOP11)
71+
72+
#define ASM_NOP_MAX 11
5973

6074
#endif /* CONFIG_64BIT */
6175

@@ -68,8 +82,6 @@
6882
#define ASM_NOP7 _ASM_BYTES(BYTES_NOP7)
6983
#define ASM_NOP8 _ASM_BYTES(BYTES_NOP8)
7084

71-
#define ASM_NOP_MAX 8
72-
7385
#ifndef __ASSEMBLY__
7486
extern const unsigned char * const x86_nops[];
7587
#endif

arch/x86/include/asm/nospec-branch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484
movq $-1, PER_CPU_VAR(pcpu_hot + X86_call_depth);
8585

8686
#define RESET_CALL_DEPTH \
87-
mov $0x80, %rax; \
88-
shl $56, %rax; \
87+
xor %eax, %eax; \
88+
bts $63, %rax; \
8989
movq %rax, PER_CPU_VAR(pcpu_hot + X86_call_depth);
9090

9191
#define RESET_CALL_DEPTH_FROM_CALL \
92-
mov $0xfc, %rax; \
92+
movb $0xfc, %al; \
9393
shl $56, %rax; \
9494
movq %rax, PER_CPU_VAR(pcpu_hot + X86_call_depth); \
9595
CALL_THUNKS_DEBUG_INC_CALLS

0 commit comments

Comments
 (0)