WSL2-Linux-Kernel/arch/powerpc/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
..
40x_mmu.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
44x_mmu.c powerpc/47x: Base ppc476 support 2010-05-05 09:11:10 -04:00
Makefile powerpc/mm: Split hash MMU specific hugepage code into a new file 2009-10-30 17:20:59 +11:00
dma-noncoherent.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
fault.c powerpc: Invoke oom-killer from page fault 2010-05-06 17:15:58 +10:00
fsl_booke_mmu.c powerpc/fsl-booke: Fix comments in mmu code that mention BATS 2010-07-09 11:28:26 +10:00
gup.c powerpc/mm: Allow more flexible layouts for hugepage pagetables 2009-10-30 17:20:58 +11:00
hash_low_32.S powerpc: Use names rather than numbers for SPRGs (v2) 2009-08-20 10:12:27 +10:00
hash_low_64.S powerpc/mm: Move around testing of _PAGE_PRESENT in hash code 2010-07-23 08:53:23 +10:00
hash_native_64.c powerpc: Convert native_tlbie_lock to raw_spinlock 2010-02-19 14:52:30 +11:00
hash_utils_64.c powerpc/mm: Add some debug output when hash insertion fails 2010-07-23 12:56:56 +10:00
highmem.c kmap_atomic: make kunmap_atomic() harder to misuse 2010-08-09 20:44:54 -07:00
hugetlbpage-hash64.c powerpc/mm: Add some debug output when hash insertion fails 2010-07-23 12:56:56 +10:00
hugetlbpage.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
init_32.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
init_64.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
mem.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
mmap_64.c powerpc: Use helpers for rlimits 2010-01-15 13:20:08 +11:00
mmu_context_hash32.c PPC: Split context init/destroy functions 2010-05-17 12:18:20 +03:00
mmu_context_hash64.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
mmu_context_nohash.c powerpc/47x: Base ppc476 support 2010-05-05 09:11:10 -04:00
mmu_decl.h powerpc/fsl-booke: Move loadcam_entry back to asm code to fix SMP ftrace 2010-05-17 10:56:20 -05:00
numa.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2010-08-05 09:03:46 -07:00
pgtable.c powerpc: Remove all rcu head initializations 2010-07-09 11:28:34 +10:00
pgtable_32.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
pgtable_64.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
ppc_mmu_32.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
slb.c powerpc/pseries: Fix to handle slb resize across migration 2009-09-02 16:19:01 +10:00
slb_low.S powerpc/mm: Fix hang accessing top of vmalloc space 2009-10-14 16:58:36 +11:00
slice.c powerpc: is_hugepage_only_range() must account for both 4kB and 64kB slices 2009-01-16 16:15:16 +11:00
stab.c lmb: rename to memblock 2010-07-14 17:14:00 +10:00
subpage-prot.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
tlb_hash32.c powerpc: Removing dead CONFIG_SMP_750 2010-07-09 11:28:38 +10:00
tlb_hash64.c powerpc: Fix address masking bug in hpte_need_flush() 2010-02-10 13:58:06 +11:00
tlb_low_64e.S fix comment typo leve -> level in powerpc 2010-02-05 12:22:38 +01:00
tlb_nohash.c Merge commit 'gcl/next' into next 2010-08-04 10:26:03 +10:00
tlb_nohash_low.S powerpc/fsl-booke: Move loadcam_entry back to asm code to fix SMP ftrace 2010-05-17 10:56:20 -05:00