dect
/
linux-2.6
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/arch/mn10300/include/asm
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
..
Kbuild Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
asm-offsets.h kbuild: move asm-offsets.h to include/generated 2009-12-12 13:08:14 +01:00
atomic.h mn10300: use generic atomic.h 2010-05-25 08:07:02 -07:00
auxvec.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
bitops.h mn10300: add cc clobbers to asm statements 2010-01-11 09:34:10 -08:00
bitsperlong.h asm-generic: introduce asm/bitsperlong.h 2009-06-11 21:02:14 +02:00
bug.h MN10300: Stop gcc from generating uninitialised variable warnings after BUG() 2009-04-15 13:55:13 -07:00
bugs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
busctl-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
byteorder.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
cache.h mn10300: set ARCH_KMALLOC_MINALIGN 2010-05-25 08:07:02 -07:00
cacheflush.h block: add helpers to run flush_dcache_page() against a bio and a request's pages 2009-11-26 09:16:19 +01:00
checksum.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
cpu-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
cputime.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
current.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
delay.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
device.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
div64.h mn10300: add cc clobbers to asm statements 2010-01-11 09:34:10 -08:00
dma-mapping.h dma-mapping: mn10300: remove the obsolete and unnecessary DMA API comments 2010-03-12 15:52:42 -08:00
dma.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
dmactl-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
elf.h elf: kill USE_ELF_CORE_DUMP 2009-12-16 07:20:12 -08:00
emergency-restart.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
errno.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
exceptions.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
fb.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
fcntl.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
fpu.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
frame.inc Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
ftrace.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
futex.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
gdb-stub.h misc: remove redundant start_kernel prototypes 2009-09-23 10:05:22 -07:00
hardirq.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
highmem.h kmap_atomic: make kunmap_atomic() harder to misuse 2010-08-09 20:44:54 -07:00
hw_irq.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
intctl-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
io.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
ioctl.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
ioctls.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
ipc.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
ipcbuf.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
irq.h Separate out the proc- and unit-specific header directories from the general 2009-04-10 14:33:48 +01:00
irq_regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
kdebug.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
kmap_types.h kmap_types: make most arches use generic header file 2009-06-16 19:47:51 -07:00
kprobes.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
linkage.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
local.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
local64.h arch: Implement local64_t 2010-06-09 11:12:36 +02:00
mc146818rtc.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
mman.h arch_mmap_check() on mn10300 2009-12-11 06:34:10 -05:00
mmu.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
mmu_context.h cpumask: use mm_cpumask() wrapper: mn10300 2009-09-24 09:34:50 +09:30
module.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
msgbuf.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
mutex.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
nmi.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
page.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
page_offset.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
param.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
pci.h PCI: remove pcibios_scan_all_fns() 2009-09-09 13:29:18 -07:00
percpu.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
pgalloc.h mm: Pass virtual address to [__]p{te,ud,md}_free_tlb() 2009-07-27 12:10:38 -07:00
pgtable.h MM: Pass a PTE pointer to update_mmu_cache() rather than the PTE itself 2010-02-20 16:41:46 +00:00
pio-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
poll.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
posix_types.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
processor.h MN10300: Add utrace/tracehooks support 2009-06-11 09:02:20 -07:00
ptrace.h ptrace: move user_enable_single_step & co prototypes to linux/ptrace.h 2010-03-12 15:52:38 -08:00
reset-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
resource.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
rtc-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
rtc.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
scatterlist.h mn10300: use asm-generic/scatterlist.h 2010-05-27 09:12:55 -07:00
sections.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
sembuf.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
serial-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
serial.h Separate out the proc- and unit-specific header directories from the general 2009-04-10 14:33:48 +01:00
setup.h headers_check fix: mn10300, setup.h 2009-06-14 11:51:12 +05:30
shmbuf.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
shmparam.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
sigcontext.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
siginfo.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
signal.h asm-generic: rename termios.h, signal.h and mman.h 2009-06-11 21:01:52 +02:00
smp.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
socket.h net: Generalize socket rx gap / receive queue overflow cmsg 2009-10-12 13:26:31 -07:00
sockios.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
spinlock.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
stat.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
statfs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
string.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
swab.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
system.h mn10300: add cc clobbers to asm statements 2010-01-11 09:34:10 -08:00
termbits.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
termios.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
thread_info.h add descriptive comment for TIF_MEMDIE task flag declaration. 2010-05-14 11:13:27 +02:00
timer-regs.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
timex.h Separate out the proc- and unit-specific header directories from the general 2009-04-10 14:33:48 +01:00
tlb.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
tlbflush.h mn10300: add cc clobbers to asm statements 2010-01-11 09:34:10 -08:00
topology.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
types.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
uaccess.h mn10300: add cc clobbers to asm statements 2010-01-11 09:34:10 -08:00
ucontext.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
unaligned.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
unistd.h Add generic sys_ipc wrapper 2010-03-12 15:52:32 -08:00
user.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
vga.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00
xor.h Move arch headers from include/asm-mn10300/ to arch/mn10300/include/asm/. 2009-04-10 14:19:03 +01:00