WSL2-Linux-Kernel/arch/x86/kernel
Steven Rostedt 732f3ca7d4 ftrace: use only 5 byte nops for x86
Mathieu Desnoyers revealed a bug in the original code. The nop that is
used to relpace the mcount caller can be a two part nop. This runs the
risk where a process can be preempted after executing the first nop, but
before the second part of the nop.

The ftrace code calls kstop_machine to keep multiple CPUs from executing
code that is being modified, but it does not protect against a task preempting
in the middle of a two part nop.

If the above preemption happens and the tracer is enabled, after the
kstop_machine runs, all those nops will be calls to the trace function.
If the preempted process that was preempted between the two nops is executed
again, it will execute half of the call to the trace function, and this
might crash the system.

This patch instead uses what both the latest Intel and AMD spec suggests.
That is the P6_NOP5 sequence of "0x0f 0x1f 0x44 0x00 0x00".

Note, some older CPUs and QEMU might fault on this nop, so this nop
is executed with fault handling first. If it detects a fault, it will then
use the code "0x66 0x66 0x66 0x66 0x90". If that faults, it will then
default to a simple "jmp 1f; .byte 0x00 0x00 0x00; 1:". The jmp is
not optimal but will do if the first two can not be executed.

TODO: Examine the cpuid to determine the nop to use.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-10-14 10:35:01 +02:00
..
acpi Merge branch 'linus' into x86/quirks 2008-10-12 12:43:21 +02:00
cpu ftrace: mark lapic_wd_event() notrace 2008-10-14 10:34:36 +02:00
.gitignore arch/x86/kernel/.gitignore: Added vmlinux.lds to .gitignore file because it shouldn't be tracked. 2008-07-10 10:13:51 -07:00
Makefile traps: x86: finalize unification of traps.c 2008-10-13 10:33:29 +02:00
alternative.c x86: improve UP kernel when CPU-hotplug and SMP is enabled 2008-10-13 10:33:46 +02:00
amd_iommu.c Merge branches 'core/iommu', 'x86/amd-iommu' and 'x86/iommu' into x86-v28-for-linus-phase3-B 2008-10-10 19:47:12 +02:00
amd_iommu_init.c x86, amd-iommu: propagate PCI device enabling error 2008-10-12 15:24:53 +02:00
aperture_64.c x86, debug printouts: IOMMU setup failures should not be KERN_ERR 2008-09-30 10:25:28 +02:00
apic_32.c Merge branch 'linus' into oprofile-v2 2008-10-13 11:05:51 +02:00
apic_64.c Merge branch 'linus' into oprofile-v2 2008-10-13 11:05:51 +02:00
apm_32.c Merge branches 'x86/alternatives', 'x86/cleanups', 'x86/commandline', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/exports', 'x86/fpu', 'x86/gart', 'x86/idle', 'x86/mm', 'x86/mtrr', 'x86/nmi-watchdog', 'x86/oprofile', 'x86/paravirt', 'x86/reboot', 'x86/sparse-fixes', 'x86/tsc', 'x86/urgent' and 'x86/vmalloc' into x86-v28-for-linus-phase1 2008-10-06 18:17:07 +02:00
asm-offsets.c
asm-offsets_32.c x86/paravirt: split sysret and sysexit 2008-07-08 13:13:15 +02:00
asm-offsets_64.c x86: consolidate header guards 2008-07-22 21:53:53 +02:00
audit_64.c
bios_uv.c x86: coding style fixes to arch/x86/kernel/bios_uv.c 2008-08-15 16:53:24 +02:00
bootflag.c x86: coding style cleanup for kernel/bootflag.c 2008-01-30 13:32:31 +01:00
cpuid.c Merge branch 'x86/urgent' into x86/cleanups 2008-08-25 22:45:37 -07:00
crash.c x86: allow machine_crash_shutdown to be replaced 2008-04-27 12:00:29 +03:00
crash_dump_32.c
crash_dump_64.c Merge branches 'x86/alternatives', 'x86/cleanups', 'x86/commandline', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/exports', 'x86/fpu', 'x86/gart', 'x86/idle', 'x86/mm', 'x86/mtrr', 'x86/nmi-watchdog', 'x86/oprofile', 'x86/paravirt', 'x86/reboot', 'x86/sparse-fixes', 'x86/tsc', 'x86/urgent' and 'x86/vmalloc' into x86-v28-for-linus-phase1 2008-10-06 18:17:07 +02:00
doublefault_32.c x86: fix virt_addr_valid() with CONFIG_DEBUG_VIRTUAL=y, v2 2008-10-13 10:33:15 +02:00
ds.c x86: ds.c ptrace.c integer as NULL pointer sparse fixes 2008-09-24 09:57:47 +02:00
dumpstack_32.c dumpstack: x86: various small unification steps 2008-10-13 10:33:45 +02:00
dumpstack_64.c dumpstack: x86: various small unification steps, fix 2008-10-13 10:33:49 +02:00
e820.c Merge commit 'v2.6.27-rc6' into x86/unify-cpu-detect 2008-09-10 14:00:45 +02:00
early-quirks.c Merge branch 'linus' into x86/quirks 2008-10-12 12:43:21 +02:00
early_printk.c warnings: fix arch/x86/kernel/early_printk.c 2008-10-12 15:19:36 +02:00
efi.c x86: trivial printk fix in efi.c 2008-10-03 10:18:30 +02:00
efi_32.c x86: fix i486 suspend to disk CR4 oops 2008-08-18 08:50:19 +02:00
efi_64.c x86: add flags parameter to reserve_bootmem_generic() 2008-07-08 11:49:49 +02:00
efi_stub_32.S
efi_stub_64.S x86: EFI runtime service support 2008-01-30 13:31:19 +01:00
entry_32.S ftrace: x86 mcount stub 2008-10-14 10:34:58 +02:00
entry_64.S ftrace: x86 mcount stub 2008-10-14 10:34:58 +02:00
es7000_32.c x86: check dsdt before find oem table for es7000, v2 2008-10-13 10:21:07 +02:00
ftrace.c ftrace: use only 5 byte nops for x86 2008-10-14 10:35:01 +02:00
genapic_64.c GRU Driver: export is_uv_system(), zap_page_range() & follow_page() 2008-07-30 09:41:48 -07:00
genapic_flat_64.c Merge branch 'linus' into x86/x2apic 2008-07-25 13:08:16 +02:00
genx2apic_cluster.c Merge branch 'x86/x2apic' into x86/core 2008-09-05 09:21:21 +02:00
genx2apic_phys.c Merge branch 'x86/x2apic' into x86/core 2008-09-05 09:21:21 +02:00
genx2apic_uv_x.c x86, UV: new UV genapic functions for x2apic 2008-10-13 10:22:53 +02:00
geode_32.c x86, geode: add a VSA2 ID for General Software 2008-06-19 14:19:03 +02:00
head.c x86: print out EBDA/lowmem address 2008-10-13 10:21:10 +02:00
head32.c x86: extract common part of head32.c and head64.c into head.c 2008-06-05 15:10:02 +02:00
head64.c x86_64: be less annoying on boot, v2 2008-09-29 10:04:53 +02:00
head_32.S x86, cpa: rename PTE attribute macros for kernel direct mapping in early boot 2008-10-10 19:29:11 +02:00
head_64.S x86, cpa: rename PTE attribute macros for kernel direct mapping in early boot 2008-10-10 19:29:11 +02:00
hpet.c Merge commit 'v2.6.27-rc6' into timers/hpet 2008-09-14 18:24:00 +02:00
i386_ksyms_32.c ftrace: store mcount address in rec->ip 2008-06-23 22:10:56 +02:00
i387.c x86: xsave: set FP, SSE bits in the xsave header in the user sigcontext 2008-10-07 14:36:08 -07:00
i8237.c
i8253.c x86: cleanup div_sc() usage 2008-04-26 17:35:47 +02:00
i8259.c x64, x2apic/intr-remap: 8259 specific mask/unmask routines 2008-07-12 08:44:55 +02:00
init_task.c [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
io_apic_32.c Merge branch 'x86/cpu' into x86/x2apic 2008-08-23 17:46:59 +02:00
io_apic_64.c warnings: fix arch/x86/kernel/io_apic_64.c 2008-10-12 15:22:22 +02:00
io_delay.c x86: add io delay quirk for Presario F700 2008-09-03 16:42:51 -07:00
ioport.c x86: Introducing asm/syscalls.h 2008-07-22 14:35:57 +02:00
ipi.c X86_SMP: ipi.c declare functions before they get used 2008-07-25 11:57:46 +05:30
irq_32.c x86: capitalize function call interrupts consistently 2008-09-04 10:51:36 -07:00
irq_64.c x86: capitalize function call interrupts consistently 2008-09-04 10:51:36 -07:00
irqinit_32.c x86: apic interrupts - move assignments to irqinit_32.c, v2 2008-08-11 16:43:09 +02:00
irqinit_64.c x86: cleanup, remove extra ifdef 2008-10-13 10:22:44 +02:00
k8.c x86, gart: add detection of AMD family 0x11 northbridges 2008-09-05 19:11:44 +02:00
kdebugfs.c arch/x86/kernel/kdebugfs.c: introduce missing kfree 2008-09-10 14:03:49 +02:00
kgdb.c kgdb, x86: Avoid invoking kgdb_nmicallback twice per NMI 2008-10-06 13:50:59 -05:00
kprobes.c kprobes: improve kretprobe scalability with hashed locking 2008-07-25 10:53:30 -07:00
kvm.c x86, paravirt_ops: use unsigned long instead of u32 for alloc_p*() pfn args 2008-08-22 05:34:44 +02:00
kvmclock.c x86: KVM guest: make kvm_smp_prepare_boot_cpu() static 2008-07-20 12:42:37 +03:00
ldt.c Merge branch 'linus' into x86/xen 2008-10-12 12:37:32 +02:00
machine_kexec_32.c kexec jump: fix for ftrace 2008-08-15 08:35:43 -07:00
machine_kexec_64.c kexec jump 2008-07-26 12:00:04 -07:00
mca_32.c x86: coding style fixes to arch/x86/kernel/mca_32.c 2008-04-17 17:40:49 +02:00
mfgpt_32.c x86, geode-mfgpt: check IRQ before using MFGPT as clocksource 2008-08-15 17:12:32 +02:00
microcode_amd.c x86, microcode_amd: cleanup, mark request_microcode_user() as unsupported 2008-09-24 10:32:37 +02:00
microcode_core.c x86/microcode: fix sleeping function called from invalid context at kernel/mutex.c 2008-10-02 17:52:33 +02:00
microcode_intel.c x86: moved microcode.c to microcode_intel.c 2008-09-23 12:21:42 +02:00
mmconf-fam10h_64.c x86: mmconf: fix section mismatch warning 2008-08-18 07:49:06 +02:00
module_32.c
module_64.c PAGE_ALIGN(): correctly handle 64-bit values on 32-bit architectures 2008-07-24 10:47:21 -07:00
mpparse.c Merge branch 'x86/apic' into x86-v28-for-linus-phase4-B 2008-10-11 20:17:36 +02:00
msr.c x86: msr: correct return value on partial operations 2008-08-25 17:46:12 -07:00
nmi.c x86, NMI watchdog: setup before enabling NMI watchdog 2008-09-22 19:48:19 +02:00
numaq_32.c Merge branch 'x86/apic' into x86-v28-for-linus-phase4-B 2008-10-11 20:17:36 +02:00
olpc.c x86, olpc: fix endian bug in openfirmware workaround 2008-09-24 10:29:04 +02:00
paravirt-spinlocks.c x86: export pv_lock_ops non-GPL 2008-08-22 15:43:17 +02:00
paravirt.c Merge branch 'linus' into x86/xen 2008-10-12 12:37:32 +02:00
paravirt_patch_32.c x86: coding style fixes to arch/x86/kernel/paravirt_patch_32.c 2008-08-15 16:53:25 +02:00
paravirt_patch_64.c x86/paravirt: add sysret/sysexit pvops for returning to 32-bit compatibility userspace 2008-07-08 13:15:52 +02:00
pci-calgary_64.c iommu: export iommu_area_reserve helper function 2008-09-22 16:47:50 +02:00
pci-dma.c Merge branches 'core/iommu', 'x86/amd-iommu' and 'x86/iommu' into x86-v28-for-linus-phase3-B 2008-10-10 19:47:12 +02:00
pci-gart_64.c Merge branches 'core/iommu', 'x86/amd-iommu' and 'x86/iommu' into x86-v28-for-linus-phase3-B 2008-10-10 19:47:12 +02:00
pci-nommu.c x86: export pci-nommu's alloc_coherent 2008-09-25 11:02:25 +02:00
pci-swiotlb_64.c dma-mapping: add the device argument to dma_mapping_error() 2008-07-26 12:00:03 -07:00
pcspeaker.c x86: use platform_device_register_simple() 2008-09-22 12:58:36 +02:00
pmtimer_64.c x86: move pmtmr related declarations 2008-01-30 13:30:18 +01:00
probe_roms_32.c x86: seperate probe_roms into another file 2008-07-08 12:50:05 +02:00
process.c Merge branch 'x86/unify-cpu-detect' into x86-v28-for-linus-phase4-D 2008-10-11 20:23:20 +02:00
process_32.c x86: __show_registers() and __show_regs() API unification 2008-10-13 10:33:04 +02:00
process_64.c x86: __show_registers() and __show_regs() API unification 2008-10-13 10:33:04 +02:00
ptrace.c Merge branches 'x86/xen', 'x86/build', 'x86/microcode', 'x86/mm-debug-v2', 'x86/memory-corruption-check', 'x86/early-printk', 'x86/xsave', 'x86/ptrace-v2', 'x86/quirks', 'x86/setup', 'x86/spinlocks' and 'x86/signal' into x86/core-v2 2008-10-12 15:50:02 +02:00
pvclock.c x86: Add structs and functions for paravirt clocksource 2008-06-24 21:02:31 +03:00
quirks.c x86: hpet: modify IXP400 quirk to enable interrupts 2008-09-05 18:59:41 +02:00
reboot.c x86: default to reboot via ACPI 2008-08-25 12:31:32 +02:00
reboot_fixups_32.c x86: constify data in reboot.c 2008-05-25 08:58:30 +02:00
relocate_kernel_32.S kexec jump: check code size in control page 2008-08-15 08:35:42 -07:00
relocate_kernel_64.S x86: relocate_kernel - use predefined macroses for page attributes 2008-04-17 17:41:29 +02:00
rtc.c provide rtc_cmos platform device 2008-06-12 18:05:42 -07:00
scx200_32.c x86: fix sparse warning in kernel/scx200_32.c 2008-01-31 22:05:45 +01:00
setup.c x86, uv: add early detection of UV system types 2008-10-13 10:21:51 +02:00
setup_percpu.c Merge commit 'v2.6.27-rc7' into x86/debug 2008-09-22 13:08:57 +02:00
sigframe.h Merge branch 'x86/unify-cpu-detect' into x86-v28-for-linus-phase4-D 2008-10-11 20:23:20 +02:00
signal_32.c Merge branch 'x86/unify-cpu-detect' into x86-v28-for-linus-phase4-D 2008-10-11 20:23:20 +02:00
signal_64.c Merge branch 'x86/unify-cpu-detect' into x86-v28-for-linus-phase4-D 2008-10-11 20:23:20 +02:00
smp.c x86: add cpu hotplug hooks into smp_ops 2008-08-25 10:59:18 +02:00
smpboot.c x86: remove additional_cpus 2008-10-13 10:33:48 +02:00
smpcommon.c x86: change init_gdt to update the gdt via write_gdt, rather than a direct write. 2008-08-15 19:16:05 +02:00
stacktrace.c stacktrace: fix modular build, export print_stack_trace and save_stack_trace 2008-06-30 09:20:55 +02:00
step.c x86 ptrace: user-sets-TF nits 2008-07-16 12:15:17 -07:00
summit_32.c x86: mach_summit to summit 2008-07-26 16:31:35 +02:00
sys_i386_32.c x86: Introducing asm/syscalls.h 2008-07-22 14:35:57 +02:00
sys_x86_64.c Merge branches 'x86/alternatives', 'x86/cleanups', 'x86/commandline', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/exports', 'x86/fpu', 'x86/gart', 'x86/idle', 'x86/mm', 'x86/mtrr', 'x86/nmi-watchdog', 'x86/oprofile', 'x86/paravirt', 'x86/reboot', 'x86/sparse-fixes', 'x86/tsc', 'x86/urgent' and 'x86/vmalloc' into x86-v28-for-linus-phase1 2008-10-06 18:17:07 +02:00
syscall_64.c x86: consolidate header guards 2008-07-22 21:53:53 +02:00
syscall_table_32.S flag parameters add-on: remove epoll_create size param 2008-07-24 10:47:29 -07:00
tce_64.c
test_nx.c x86: Explicitly include required header files. 2008-04-17 17:41:15 +02:00
test_rodata.c x86: include proper prototypes for rodata_test 2008-02-14 23:30:20 +01:00
time_32.c x86: wrap MCA_bus test around an ifdef 2008-10-13 10:21:47 +02:00
time_64.c x86: move vgetcpu mode probing to cpu detection 2008-10-13 10:21:49 +02:00
tlb_32.c x86: build fix for !CONFIG_SMP 2008-09-05 17:44:08 +02:00
tlb_64.c Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
tlb_uv.c x86, SGI UV: hardcode the TLB flush interrupt system vector 2008-08-20 12:36:03 +02:00
tls.c x86: Introducing asm/syscalls.h 2008-07-22 14:35:57 +02:00
tls.h x86: x86 user_regset TLS 2008-01-30 13:31:52 +01:00
topology.c x86: fix section mismatch warning in topology.c:arch_register_cpu 2008-02-19 16:18:30 +01:00
trampoline.c x86: extend e820 ealy_res support 32bit 2008-05-25 10:55:11 +02:00
trampoline_32.S x86: trampoline_32.S - switch to .cpuinit.data 2008-04-26 17:35:47 +02:00
trampoline_64.S x86: move suspend wakeup code to C 2008-04-17 17:41:37 +02:00
traps.c dumpstack: x86: move die_nmi to dumpstack_32.c 2008-10-13 10:33:39 +02:00
tsc.c Merge branches 'x86/alternatives', 'x86/cleanups', 'x86/commandline', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/exports', 'x86/fpu', 'x86/gart', 'x86/idle', 'x86/mm', 'x86/mtrr', 'x86/nmi-watchdog', 'x86/oprofile', 'x86/paravirt', 'x86/reboot', 'x86/sparse-fixes', 'x86/tsc', 'x86/urgent' and 'x86/vmalloc' into x86-v28-for-linus-phase1 2008-10-06 18:17:07 +02:00
tsc_sync.c x86: use WARN() in arch/x86/kernel 2008-08-21 10:01:52 +02:00
verify_cpu_64.S
visws_quirks.c Merge branch 'linus' into x86/cleanups 2008-08-20 11:52:15 +02:00
vm86_32.c x86: Introducing asm/syscalls.h 2008-07-22 14:35:57 +02:00
vmi_32.c Merge branch 'x86/apic' into x86-v28-for-linus-phase4-B 2008-10-11 20:17:36 +02:00
vmiclock_32.c x86: rename paravirtualized TSC functions 2008-07-09 07:43:28 +02:00
vmlinux.lds.S
vmlinux_32.lds.S Merge commit '63cc8c75156462d4b42cbdd76c293b7eee7ddbfe': 2008-09-05 09:24:30 +02:00
vmlinux_64.lds.S x86: fix early panic on amd64 due to typo in supported CPU section 2008-10-12 11:19:27 +02:00
vsmp_64.c x86: fix 27-rc crash on vsmp due to paravirt during module load 2008-09-23 10:31:26 +02:00
vsyscall_64.c Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
x8664_ksyms_64.c Merge branch 'auto-ftrace-next' into tracing/for-linus 2008-07-14 16:11:52 +02:00
xsave.c x86, fpu: check __clear_user() return value 2008-10-12 15:17:39 +02:00