linux/arch/arm
Steven Rostedt 17666f02b1 ftrace: nmi safe code modification
Impact: fix crashes that can occur in NMI handlers, if their code is modified

Modifying code is something that needs special care. On SMP boxes,
if code that is being modified is also being executed on another CPU,
that CPU will have undefined results.

The dynamic ftrace uses kstop_machine to make the system act like a
uniprocessor system. But this does not address NMIs, that can still
run on other CPUs.

One approach to handle this is to make all code that are used by NMIs
not be traced. But NMIs can call notifiers that spread throughout the
kernel and this will be very hard to maintain, and the chance of missing
a function is very high.

The approach that this patch takes is to have the NMIs modify the code
if the modification is taking place. The way this works is that just
writing to code executing on another CPU is not harmful if what is
written is the same as what exists.

Two buffers are used: an IP buffer and a "code" buffer.

The steps that the patcher takes are:

 1) Put in the instruction pointer into the IP buffer
    and the new code into the "code" buffer.
 2) Set a flag that says we are modifying code
 3) Wait for any running NMIs to finish.
 4) Write the code
 5) clear the flag.
 6) Wait for any running NMIs to finish.

If an NMI is executed, it will also write the pending code.
Multiple writes are OK, because what is being written is the same.
Then the patcher must wait for all running NMIs to finish before
going to the next line that must be patched.

This is basically the RCU approach to code modification.

Thanks to Ingo Molnar for suggesting the idea, and to Arjan van de Ven
for his guidence on what is safe and what is not.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-10-30 21:30:08 +01:00
..
boot ftrace: rename FTRACE to FUNCTION_TRACER 2008-10-20 18:27:03 +02:00
common [ARM] 5315/1: Fix section mismatch warning (sa1111) 2008-10-21 22:51:46 +01:00
configs Merge branch 'for-rmk' of git://git.android.com/kernel into devel 2008-10-22 19:34:09 +01:00
include/asm ftrace: nmi safe code modification 2008-10-30 21:30:08 +01:00
kernel ftrace: remove mcount set 2008-10-23 16:00:23 +02:00
lib Merge branch 'ptebits' into devel 2008-10-09 21:31:56 +01:00
mach-aaec2000 [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
mach-at91 [ARM] 5316/1: AT91: oops (regression) fix on gpio irq 2008-10-22 19:40:06 +01:00
mach-clps711x [ARM] clps711x: add sparsemem definitions 2008-10-21 23:31:23 +01:00
mach-clps7500 [ARM] mm: enable sparsemem on clps7500 and RiscPC 2008-10-01 17:24:04 +01:00
mach-davinci Merge branch 's3c-move' into devel 2008-10-14 22:24:51 +01:00
mach-ebsa110 [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-ep93xx Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-footbridge Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-h720x Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-imx Merge branch 'for-rmk' of git://pasiphae.extern.pengutronix.de/git/imx/linux-2.6.git 2008-10-09 21:33:03 +01:00
mach-integrator cpufreq: remove policy->governor setting in drivers initialization 2008-10-15 16:42:47 -07:00
mach-iop13xx misc: replace remaining __FUNCTION__ with __func__ 2008-10-20 16:17:42 -07:00
mach-iop32x [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-iop33x [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-ixp4xx [ARM] dmabounce requires ZONE_DMA 2008-10-17 14:00:43 +01:00
mach-ixp23xx Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-ixp2000 genirq: fix name space collisions of nr_irqs in arch/* 2008-10-16 16:53:30 +02:00
mach-kirkwood [ARM] 5321/1: Kirkwood: fix typo in Makefile 2008-10-23 19:58:19 +01:00
mach-ks8695 Merge branches 'machtypes', 'core', 'ep93xx', 'ks8695', 'netdev' and 'sa1100' into devel 2008-10-09 21:31:54 +01:00
mach-l7200 [ARM] Move include/asm-arm/arch-* to arch/arm/*/include/mach 2008-08-07 09:55:48 +01:00
mach-lh7a40x Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-loki Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-11 10:09:45 -07:00
mach-msm [ARM] msm: vreg interface to msm7k pmic 2008-10-22 02:41:00 -07:00
mach-mv78xx0 [ARM] mv78xx0: force link speed/duplex on eth2/eth3 2008-10-19 14:29:05 -04:00
mach-mx2 i.MX2: make SoC devices globally available 2008-09-09 10:19:41 +02:00
mach-mx3 Merge branch 'for-rmk' of git://source.mvista.com/git/linux-davinci-2.6.git 2008-10-09 21:33:05 +01:00
mach-netx Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-ns9xxx Merge branch 'pxa-all' into devel 2008-10-09 21:33:02 +01:00
mach-omap1 Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-16 11:25:32 -07:00
mach-omap2 Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
mach-orion5x [ARM] Orion: activate workaround for 88f6183 SPI clock erratum 2008-10-19 14:29:05 -04:00
mach-pnx4008 [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-pxa Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-23 16:06:49 -07:00
mach-realview [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-rpc [ARM] mm: enable sparsemem on clps7500 and RiscPC 2008-10-01 17:24:04 +01:00
mach-s3c2400 [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-s3c2410 Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2008-10-16 11:25:32 -07:00
mach-s3c2412 Merge branch 's3c-move' into devel 2008-10-14 22:24:51 +01:00
mach-s3c2440 Merge branch 's3c-move' into devel 2008-10-14 22:24:51 +01:00
mach-s3c2442 Merge branch 's3c-move' into devel 2008-10-14 22:24:51 +01:00
mach-s3c2443 Merge branch 'for-rmk-fixes' of git://aeryn.fluff.org.uk/bjdooks/linux 2008-10-17 14:29:03 +01:00
mach-sa1100 ide: remove dead <asm-arm/arch-sa1100/ide.h> 2008-10-17 18:09:15 +02:00
mach-shark [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
mach-versatile Merge branch 's3c-move' into devel 2008-10-14 22:24:51 +01:00
mm [ARM] 5318/1: Swap the PRRR and NMRR values in proc-v7.S 2008-10-22 19:40:21 +01:00
nwfpe [ARM] Convert asm/uaccess.h to linux/uaccess.h 2008-09-06 11:35:55 +01:00
oprofile [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
plat-iop [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
plat-mxc Merge git://git.infradead.org/mtd-2.6 2008-10-20 09:03:12 -07:00
plat-omap Merge git://git.infradead.org/mtd-2.6 2008-10-20 09:03:12 -07:00
plat-orion [ARM] Move include/asm-arm/plat-orion to arch/arm/plat-orion/include/plat 2008-08-09 13:44:58 +02:00
plat-s3c [ARM] S3C24XX: Additional include moves 2008-10-07 23:09:51 +01:00
plat-s3c24xx Merge branch 'for-rmk-fixes' of git://aeryn.fluff.org.uk/bjdooks/linux 2008-10-17 14:29:03 +01:00
tools [ARM] Update mach-types 2008-09-25 10:12:25 +01:00
vfp [ARM] 5227/1: Add the ENDPROC declarations to the .S files 2008-09-01 12:06:34 +01:00
Kconfig Merge commit 'v2.6.28-rc2' into tracing/urgent 2008-10-27 10:50:54 +01:00
Kconfig-nommu [ARM] 4532/1: allow configuration of processor ID 2007-10-12 23:43:02 +01:00
Kconfig.debug [ARM] CONFIG_DEBUG_STACK_USAGE 2008-01-26 14:50:06 +00:00
Makefile [ARM] msm: rename ARCH_MSM7X00A to ARCH_MSM 2008-10-22 02:39:32 -07:00