x86/retpoline: Add SKL retthunk retpolines
Ensure that retpolines do the proper call accounting so that the return accounting works correctly. Specifically; retpolines are used to replace both 'jmp *%reg' and 'call *%reg', however these two cases do not have the same accounting requirements. Therefore split things up and provide two different retpoline arrays for SKL. The 'jmp *%reg' case needs no accounting, the __x86_indirect_jump_thunk_array[] covers this. The retpoline is changed to not use the return thunk; it's a simple call;ret construct. [ strictly speaking it should do: andq $(~0x1f), PER_CPU_VAR(__x86_call_depth) but we can argue this can be covered by the fuzz we already have in the accounting depth (12) vs the RSB depth (16) ] The 'call *%reg' case does need accounting, the __x86_indirect_call_thunk_array[] covers this. Again, this retpoline avoids the use of the return-thunk, in this case to avoid double accounting. Signed-off-by:Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by:
Thomas Gleixner <tglx@linutronix.de> Signed-off-by:
Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220915111147.996634749@infradead.org
Showing
- arch/x86/include/asm/nospec-branch.h 12 additions, 0 deletionsarch/x86/include/asm/nospec-branch.h
- arch/x86/kernel/alternative.c 56 additions, 3 deletionsarch/x86/kernel/alternative.c
- arch/x86/lib/retpoline.S 63 additions, 8 deletionsarch/x86/lib/retpoline.S
- arch/x86/net/bpf_jit_comp.c 4 additions, 1 deletionarch/x86/net/bpf_jit_comp.c
Loading
Please register or sign in to comment