linux/arch/arm/mm
Cesar Eduardo Barros 597781f3e5 kmap_atomic: make kunmap_atomic() harder to misuse
kunmap_atomic() is currently at level -4 on Rusty's "Hard To Misuse"
list[1] ("Follow common convention and you'll get it wrong"), except in
some architectures when CONFIG_DEBUG_HIGHMEM is set[2][3].

kunmap() takes a pointer to a struct page; kunmap_atomic(), however, takes
takes a pointer to within the page itself.  This seems to once in a while
trip people up (the convention they are following is the one from
kunmap()).

Make it much harder to misuse, by moving it to level 9 on Rusty's list[4]
("The compiler/linker won't let you get it wrong").  This is done by
refusing to build if the type of its first argument is a pointer to a
struct page.

The real kunmap_atomic() is renamed to kunmap_atomic_notypecheck()
(which is what you would call in case for some strange reason calling it
with a pointer to a struct page is not incorrect in your code).

The previous version of this patch was compile tested on x86-64.

[1] http://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html
[2] In these cases, it is at level 5, "Do it right or it will always
    break at runtime."
[3] At least mips and powerpc look very similar, and sparc also seems to
    share a common ancestor with both; there seems to be quite some
    degree of copy-and-paste coding here. The include/asm/highmem.h file
    for these three archs mention x86 CPUs at its top.
[4] http://ozlabs.org/~rusty/index.cgi/tech/2008-03-30.html
[5] As an aside, could someone tell me why mn10300 uses unsigned long as
    the first parameter of kunmap_atomic() instead of void *?

Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
Cc: Russell King <linux@arm.linux.org.uk> (arch/arm)
Cc: Ralf Baechle <ralf@linux-mips.org> (arch/mips)
Cc: David Howells <dhowells@redhat.com> (arch/frv, arch/mn10300)
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com> (arch/mn10300)
Cc: Kyle McMartin <kyle@mcmartin.ca> (arch/parisc)
Cc: Helge Deller <deller@gmx.de> (arch/parisc)
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> (arch/parisc)
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> (arch/powerpc)
Cc: Paul Mackerras <paulus@samba.org> (arch/powerpc)
Cc: "David S. Miller" <davem@davemloft.net> (arch/sparc)
Cc: Thomas Gleixner <tglx@linutronix.de> (arch/x86)
Cc: Ingo Molnar <mingo@redhat.com> (arch/x86)
Cc: "H. Peter Anvin" <hpa@zytor.com> (arch/x86)
Cc: Arnd Bergmann <arnd@arndb.de> (include/asm-generic)
Cc: Rusty Russell <rusty@rustcorp.com.au> ("Hard To Misuse" list)
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-08-09 20:44:54 -07:00
..
abort-ev4.S
abort-ev4t.S
abort-ev5t.S
abort-ev5tj.S
abort-ev6.S Add core support for ARMv6/v7 big-endian 2009-05-30 14:00:18 +01:00
abort-ev7.S arm: mm: qsd8x50: Fix incorrect permission faults 2010-05-03 11:15:05 -07:00
abort-lv4t.S [ARM] nommu: abort handler fixup for !CPU_CP15_MMU cores. 2006-09-28 20:15:46 +01:00
abort-macro.S
abort-nommu.S [ARM] 5227/1: Add the ENDPROC declarations to the .S files 2008-09-01 12:06:34 +01:00
alignment.c ARM: 6268/1: ARMv6K and ARMv7 use fault statuses 3 and 6 as Access Flag fault 2010-07-27 10:48:41 +01:00
cache-fa.S ARM: dma-mapping: remove dmac_clean_range and dmac_inv_range 2010-02-15 15:22:23 +00:00
cache-feroceon-l2.c [ARM] Kirkwood: small L2 code cleanup 2009-03-28 22:39:30 -04:00
cache-l2x0.c ARM: 6272/1: Convert L2x0 to use the IO relaxed operations 2010-07-29 14:04:36 +01:00
cache-tauros2.c ARM: Add Tauros2 L2 cache controller support 2009-11-27 15:43:21 -05:00
cache-v3.S ARM: dma-mapping: remove dmac_clean_range and dmac_inv_range 2010-02-15 15:22:23 +00:00
cache-v4.S ARM: dma-mapping: remove dmac_clean_range and dmac_inv_range 2010-02-15 15:22:23 +00:00
cache-v4wb.S ARM: dma-mapping: remove dmac_clean_range and dmac_inv_range 2010-02-15 15:22:23 +00:00
cache-v4wt.S ARM: dma-mapping: remove dmac_clean_range and dmac_inv_range 2010-02-15 15:22:23 +00:00
cache-v6.S ARM: 6188/1: Add a config option for the ARM11MPCore DMA cache maintenance workaround 2010-07-01 10:12:31 +01:00
cache-v7.S ARM: 6139/1: ARMv7: Use the Inner Shareable I-cache on MP 2010-05-20 23:52:38 +01:00
cache-xsc3l2.c [ARM] pxa: do not enable L2 after MMU is enabled 2010-01-01 15:50:34 +08:00
context.c ARM: 5905/1: ARM: Global ASID allocation on SMP 2010-02-15 21:39:51 +00:00
copypage-fa.c ARM: Gemini: fix compiler error in copypage-fa.c 2010-04-27 12:45:10 +02:00
copypage-feroceon.c ARM: 6164/1: Add kto and kfrom to input operands list. 2010-06-08 19:42:18 +01:00
copypage-v3.c ARM: Pass VMA to copy_user_highpage() implementations 2009-10-05 15:17:45 +01:00
copypage-v4mc.c ARM: Pass VMA to copy_user_highpage() implementations 2009-10-05 15:17:45 +01:00
copypage-v4wb.c ARM: 6164/1: Add kto and kfrom to input operands list. 2010-06-08 19:42:18 +01:00
copypage-v4wt.c ARM: 6164/1: Add kto and kfrom to input operands list. 2010-06-08 19:42:18 +01:00
copypage-v6.c ARM: 6007/1: fix highmem with VIPT cache and DMA 2010-04-14 11:11:27 +01:00
copypage-xsc3.c ARM: 6164/1: Add kto and kfrom to input operands list. 2010-06-08 19:42:18 +01:00
copypage-xscale.c ARM: Pass VMA to copy_user_highpage() implementations 2009-10-05 15:17:45 +01:00
dma-mapping.c ARM: DMA coherent allocator: align remapped addresses 2010-07-27 10:43:48 +01:00
extable.c [ARM] Convert asm/uaccess.h to linux/uaccess.h 2008-09-06 11:35:55 +01:00
fault-armv.c Merge branch 'devel-stable' into devel 2010-05-17 17:24:04 +01:00
fault.c ARM: 6268/1: ARMv6K and ARMv7 use fault statuses 3 and 6 as Access Flag fault 2010-07-27 10:48:41 +01:00
fault.h [ARM] do_bad_area() always takes current and current->active_mm 2006-09-27 16:13:48 +01:00
flush.c ARM: 6007/1: fix highmem with VIPT cache and DMA 2010-04-14 11:11:27 +01:00
highmem.c kmap_atomic: make kunmap_atomic() harder to misuse 2010-08-09 20:44:54 -07:00
init.c Merge branch 'devel-stable' into devel 2010-07-31 14:20:16 +01:00
iomap.c [ARM] Convert asm/io.h to linux/io.h 2008-09-06 12:10:45 +01:00
ioremap.c ARM: use generic ioremap_page_range() 2010-07-27 10:43:47 +01:00
Kconfig [ARM] tegra: initial tegra support 2010-08-05 14:51:42 -07:00
Makefile ARM: Remove DISCONTIGMEM support 2010-07-16 10:57:35 +01:00
mm.h ARM: Convert platform reservations to use LMB rather than bootmem 2010-07-27 08:48:23 +01:00
mmap.c [ARM] add address randomization to mmap() 2010-06-14 21:22:11 -04:00
mmu.c Merge branch 'misc' into devel 2010-07-31 14:20:02 +01:00
nommu.c ARM: Convert platform reservations to use LMB rather than bootmem 2010-07-27 08:48:23 +01:00
pabort-legacy.S ARM: 5727/1: Pass IFSR register to do_PrefetchAbort() 2009-10-02 22:34:32 +01:00
pabort-v6.S ARM: 5727/1: Pass IFSR register to do_PrefetchAbort() 2009-10-02 22:34:32 +01:00
pabort-v7.S ARM: 5727/1: Pass IFSR register to do_PrefetchAbort() 2009-10-02 22:34:32 +01:00
pgd.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
proc-arm6_7.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm7tdmi.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm9tdmi.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm720.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm740.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm920.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm922.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm925.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm926.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm940.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm946.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm1020.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm1020e.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm1022.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-arm1026.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-fa526.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-feroceon.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-macros.S Merge branch 'devel-stable' into devel 2009-09-12 12:02:26 +01:00
proc-mohawk.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-sa110.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-sa1100.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-syms.c ARM: add size argument to __cpuc_flush_dcache_page 2009-12-14 14:53:22 +00:00
proc-v6.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-v7.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-xsc3.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
proc-xscale.S ARM: Factor out common code from cpu_proc_fin() 2010-07-27 10:48:42 +01:00
tlb-fa.S ARM: Add support for FA526 v2 2009-03-25 13:10:01 +02:00
tlb-v3.S
tlb-v4.S
tlb-v4wb.S
tlb-v4wbi.S
tlb-v6.S arm: Use __INIT macro instead of .text.init. 2009-04-27 19:51:58 -07:00
tlb-v7.S ARM: 6112/1: Use the Inner Shareable I-cache and BTB ops on ARMv7 SMP 2010-05-08 10:44:30 +01:00
vmregion.c ARM: DMA coherent allocator: align remapped addresses 2010-07-27 10:43:48 +01:00
vmregion.h ARM: DMA coherent allocator: align remapped addresses 2010-07-27 10:43:48 +01:00