mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
64ad946152
misleading/wrong stacktraces and confuse RELIABLE_STACKTRACE and LIVEPATCH as the backtrace misses the function which is being fixed up. - Add Straight Light Speculation mitigation support which uses a new compiler switch -mharden-sls= which sticks an INT3 after a RET or an indirect branch in order to block speculation after them. Reportedly, CPUs do speculate behind such insns. - The usual set of cleanups and improvements -----BEGIN PGP SIGNATURE----- iQIyBAABCgAdFiEEzv7L6UO9uDPlPSfHEsHwGGHeVUoFAmHfKA0ACgkQEsHwGGHe VUqLJg/2I2X2xXr5filJVaK+sQgmvDzk67DKnbxRBW2xcPF+B5sSW5yhe3G5UPW7 SJVdhQ3gHcTiliGGlBf/VE7KXbqxFN0vO4/VFHZm78r43g7OrXTxz6WXXQRJ1n67 U3YwRH3b6cqXZNFMs+X4bJt6qsGJM1kdTTZ2as4aERnaFr5AOAfQvfKbyhxLe/XA 3SakfYISVKCBQ2RkTfpMpwmqlsatGFhTC5IrvuDQ83dDsM7O+Dx1J6Gu3fwjKmie iVzPOjCh+xTpZQp/SIZmt7MzoduZvpSym4YVyHvEnMiexQT4AmyaRthWqrhnEXY/ qOvj8/XIqxmix8EaooGqRIK0Y2ZegxkPckNFzaeC3lsWohwMIGIhNXwHNEeuhNyH yvNGAW9Cq6NeDRgz5MRUXcimYw4P4oQKYLObS1WqFZhNMqm4sNtoEAYpai/lPYfs zUDckgXF2AoPOsSqy3hFAVaGovAgzfDaJVzkt0Lk4kzzjX2WQiNLhmiior460w+K 0l2Iej58IajSp3MkWmFH368Jo8YfUVmkjbbpsmjsBppA08e1xamJB7RmswI/Ezj6 s5re6UioCD+UYdjWx41kgbvYdvIkkZ2RLrktoZd/hqHrOLWEIiwEbyFO2nRFJIAh YjvPkB1p7iNuAeYcP1x9Ft9GNYVIsUlJ+hK86wtFCqy+abV+zQ== =R52z -----END PGP SIGNATURE----- Merge tag 'x86_core_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull x86 core updates from Borislav Petkov: - Get rid of all the .fixup sections because this generates misleading/wrong stacktraces and confuse RELIABLE_STACKTRACE and LIVEPATCH as the backtrace misses the function which is being fixed up. - Add Straight Line Speculation mitigation support which uses a new compiler switch -mharden-sls= which sticks an INT3 after a RET or an indirect branch in order to block speculation after them. Reportedly, CPUs do speculate behind such insns. - The usual set of cleanups and improvements * tag 'x86_core_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (32 commits) x86/entry_32: Fix segment exceptions objtool: Remove .fixup handling x86: Remove .fixup section x86/word-at-a-time: Remove .fixup usage x86/usercopy: Remove .fixup usage x86/usercopy_32: Simplify __copy_user_intel_nocache() x86/sgx: Remove .fixup usage x86/checksum_32: Remove .fixup usage x86/vmx: Remove .fixup usage x86/kvm: Remove .fixup usage x86/segment: Remove .fixup usage x86/fpu: Remove .fixup usage x86/xen: Remove .fixup usage x86/uaccess: Remove .fixup usage x86/futex: Remove .fixup usage x86/msr: Remove .fixup usage x86/extable: Extend extable functionality x86/entry_32: Remove .fixup usage x86/entry_64: Remove .fixup usage x86/copy_mc_64: Remove .fixup usage ...
86 lines
2.0 KiB
C
86 lines
2.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mm.h> /* for handle_mm_fault() */
|
|
#include <linux/ftrace.h>
|
|
#include <asm/asm-offsets.h>
|
|
|
|
extern void my_direct_func(struct vm_area_struct *vma,
|
|
unsigned long address, unsigned int flags);
|
|
|
|
void my_direct_func(struct vm_area_struct *vma,
|
|
unsigned long address, unsigned int flags)
|
|
{
|
|
trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
|
|
vma, address, flags);
|
|
}
|
|
|
|
extern void my_tramp(void *);
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
asm (
|
|
" .pushsection .text, \"ax\", @progbits\n"
|
|
" .type my_tramp, @function\n"
|
|
" .globl my_tramp\n"
|
|
" my_tramp:"
|
|
" pushq %rbp\n"
|
|
" movq %rsp, %rbp\n"
|
|
" pushq %rdi\n"
|
|
" pushq %rsi\n"
|
|
" pushq %rdx\n"
|
|
" call my_direct_func\n"
|
|
" popq %rdx\n"
|
|
" popq %rsi\n"
|
|
" popq %rdi\n"
|
|
" leave\n"
|
|
ASM_RET
|
|
" .size my_tramp, .-my_tramp\n"
|
|
" .popsection\n"
|
|
);
|
|
|
|
#endif /* CONFIG_X86_64 */
|
|
|
|
#ifdef CONFIG_S390
|
|
|
|
asm (
|
|
" .pushsection .text, \"ax\", @progbits\n"
|
|
" .type my_tramp, @function\n"
|
|
" .globl my_tramp\n"
|
|
" my_tramp:"
|
|
" lgr %r1,%r15\n"
|
|
" stmg %r0,%r5,"__stringify(__SF_GPRS)"(%r15)\n"
|
|
" stg %r14,"__stringify(__SF_GPRS+8*8)"(%r15)\n"
|
|
" aghi %r15,"__stringify(-STACK_FRAME_OVERHEAD)"\n"
|
|
" stg %r1,"__stringify(__SF_BACKCHAIN)"(%r15)\n"
|
|
" brasl %r14,my_direct_func\n"
|
|
" aghi %r15,"__stringify(STACK_FRAME_OVERHEAD)"\n"
|
|
" lmg %r0,%r5,"__stringify(__SF_GPRS)"(%r15)\n"
|
|
" lg %r14,"__stringify(__SF_GPRS+8*8)"(%r15)\n"
|
|
" lgr %r1,%r0\n"
|
|
" br %r1\n"
|
|
" .size my_tramp, .-my_tramp\n"
|
|
" .popsection\n"
|
|
);
|
|
|
|
#endif /* CONFIG_S390 */
|
|
|
|
static int __init ftrace_direct_init(void)
|
|
{
|
|
return register_ftrace_direct((unsigned long)handle_mm_fault,
|
|
(unsigned long)my_tramp);
|
|
}
|
|
|
|
static void __exit ftrace_direct_exit(void)
|
|
{
|
|
unregister_ftrace_direct((unsigned long)handle_mm_fault,
|
|
(unsigned long)my_tramp);
|
|
}
|
|
|
|
module_init(ftrace_direct_init);
|
|
module_exit(ftrace_direct_exit);
|
|
|
|
MODULE_AUTHOR("Steven Rostedt");
|
|
MODULE_DESCRIPTION("Another example use case of using register_ftrace_direct()");
|
|
MODULE_LICENSE("GPL");
|