aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/dontdiff1
-rw-r--r--Documentation/feature-removal-schedule.txt8
-rw-r--r--Documentation/sysctl/kernel.txt20
-rw-r--r--Documentation/tty.txt2
-rw-r--r--MAINTAINERS12
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/Kconfig4
-rw-r--r--arch/alpha/defconfig2
-rw-r--r--arch/alpha/mm/numa.c16
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/boot/install.sh4
-rw-r--r--arch/arm26/Kconfig2
-rw-r--r--arch/arm26/boot/install.sh4
-rw-r--r--arch/cris/Kconfig2
-rw-r--r--arch/frv/Kconfig2
-rw-r--r--arch/h8300/Kconfig.cpu3
-rw-r--r--arch/h8300/platform/h8300h/ptrace_h8300h.c4
-rw-r--r--arch/i386/Kconfig40
-rw-r--r--arch/i386/Makefile7
-rw-r--r--arch/i386/boot/install.sh4
-rw-r--r--arch/i386/kernel/apic.c2
-rw-r--r--arch/i386/kernel/cpu/common.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c23
-rw-r--r--arch/i386/kernel/cpu/proc.c2
-rw-r--r--arch/i386/kernel/i386_ksyms.c160
-rw-r--r--arch/i386/kernel/i387.c3
-rw-r--r--arch/i386/kernel/io_apic.c13
-rw-r--r--arch/i386/kernel/kprobes.c176
-rw-r--r--arch/i386/kernel/mpparse.c31
-rw-r--r--arch/i386/kernel/nmi.c24
-rw-r--r--arch/i386/kernel/pci-dma.c3
-rw-r--r--arch/i386/kernel/process.c36
-rw-r--r--arch/i386/kernel/ptrace.c2
-rw-r--r--arch/i386/kernel/reboot.c5
-rw-r--r--arch/i386/kernel/setup.c28
-rw-r--r--arch/i386/kernel/signal.c31
-rw-r--r--arch/i386/kernel/smp.c3
-rw-r--r--arch/i386/kernel/smpboot.c14
-rw-r--r--arch/i386/kernel/time.c6
-rw-r--r--arch/i386/kernel/timers/common.c12
-rw-r--r--arch/i386/kernel/timers/timer.c9
-rw-r--r--arch/i386/kernel/timers/timer_hpet.c3
-rw-r--r--arch/i386/kernel/timers/timer_pm.c1
-rw-r--r--arch/i386/kernel/timers/timer_tsc.c8
-rw-r--r--arch/i386/kernel/traps.c21
-rw-r--r--arch/i386/lib/dec_and_lock.c2
-rw-r--r--arch/i386/lib/delay.c6
-rw-r--r--arch/i386/lib/mmx.c5
-rw-r--r--arch/i386/lib/usercopy.c8
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c2
-rw-r--r--arch/i386/mm/Makefile2
-rw-r--r--arch/i386/mm/discontig.c127
-rw-r--r--arch/i386/mm/highmem.c6
-rw-r--r--arch/i386/mm/init.c21
-rw-r--r--arch/i386/mm/ioremap.c5
-rw-r--r--arch/i386/mm/pgtable.c10
-rw-r--r--arch/i386/oprofile/backtrace.c2
-rw-r--r--arch/i386/pci/irq.c22
-rw-r--r--arch/i386/pci/pcbios.c4
-rw-r--r--arch/i386/power/cpu.c14
-rw-r--r--arch/ia64/Kconfig6
-rw-r--r--arch/ia64/Kconfig.debug11
-rw-r--r--arch/ia64/configs/sn2_defconfig2
-rw-r--r--arch/ia64/defconfig2
-rw-r--r--arch/ia64/ia32/ia32priv.h2
-rw-r--r--arch/ia64/kernel/Makefile1
-rw-r--r--arch/ia64/kernel/jprobes.S61
-rw-r--r--arch/ia64/kernel/kprobes.c601
-rw-r--r--arch/ia64/kernel/traps.c33
-rw-r--r--arch/ia64/mm/discontig.c9
-rw-r--r--arch/ia64/mm/fault.c8
-rw-r--r--arch/m32r/Kconfig4
-rw-r--r--arch/m32r/mm/init.c4
-rw-r--r--arch/m68k/Kconfig2
-rw-r--r--arch/m68knommu/Kconfig2
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/configs/ip27_defconfig2
-rw-r--r--arch/mips/sgi-ip27/ip27-memory.c5
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/parisc/mm/init.c2
-rw-r--r--arch/ppc/Kconfig2
-rw-r--r--arch/ppc/boot/simple/misc.c2
-rw-r--r--arch/ppc/boot/simple/mpc10x_memory.c2
-rw-r--r--arch/ppc64/Kconfig42
-rw-r--r--arch/ppc64/boot/install.sh4
-rw-r--r--arch/ppc64/configs/pSeries_defconfig2
-rw-r--r--arch/ppc64/defconfig2
-rw-r--r--arch/ppc64/kernel/kprobes.c61
-rw-r--r--arch/ppc64/kernel/setup.c1
-rw-r--r--arch/ppc64/mm/Makefile2
-rw-r--r--arch/ppc64/mm/init.c22
-rw-r--r--arch/ppc64/mm/numa.c3
-rw-r--r--arch/s390/Kconfig2
-rw-r--r--arch/s390/boot/install.sh4
-rw-r--r--arch/s390/kernel/compat_linux.h2
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh64/Kconfig2
-rw-r--r--arch/sparc/Kconfig18
-rw-r--r--arch/sparc64/Kconfig2
-rw-r--r--arch/sparc64/kernel/kprobes.c83
-rw-r--r--arch/sparc64/kernel/signal32.c2
-rw-r--r--arch/um/Kconfig1
-rw-r--r--arch/um/kernel/process_kern.c8
-rw-r--r--arch/v850/Kconfig2
-rw-r--r--arch/x86_64/Kconfig25
-rw-r--r--arch/x86_64/boot/install.sh4
-rw-r--r--arch/x86_64/ia32/ia32_signal.c15
-rw-r--r--arch/x86_64/kernel/aperture.c4
-rw-r--r--arch/x86_64/kernel/early_printk.c13
-rw-r--r--arch/x86_64/kernel/head64.c2
-rw-r--r--arch/x86_64/kernel/i8259.c15
-rw-r--r--arch/x86_64/kernel/kprobes.c190
-rw-r--r--arch/x86_64/kernel/mpparse.c25
-rw-r--r--arch/x86_64/kernel/process.c16
-rw-r--r--arch/x86_64/kernel/setup.c33
-rw-r--r--arch/x86_64/kernel/signal.c30
-rw-r--r--arch/x86_64/kernel/time.c42
-rw-r--r--arch/x86_64/kernel/traps.c22
-rw-r--r--arch/x86_64/lib/delay.c7
-rw-r--r--arch/x86_64/mm/Makefile2
-rw-r--r--arch/x86_64/mm/fault.c4
-rw-r--r--arch/x86_64/mm/init.c9
-rw-r--r--arch/x86_64/mm/ioremap.c2
-rw-r--r--arch/x86_64/mm/numa.c8
-rw-r--r--arch/x86_64/pci/k8-bus.c16
-rw-r--r--crypto/tcrypt.c580
-rw-r--r--crypto/tcrypt.h449
-rw-r--r--drivers/base/bus.c5
-rw-r--r--drivers/block/as-iosched.c8
-rw-r--r--drivers/block/deadline-iosched.c8
-rw-r--r--drivers/block/genhd.c25
-rw-r--r--drivers/block/ioctl.c74
-rw-r--r--drivers/block/ll_rw_blk.c111
-rw-r--r--drivers/block/loop.c81
-rw-r--r--drivers/block/pktcdvd.c36
-rw-r--r--drivers/bluetooth/hci_ldisc.c2
-rw-r--r--drivers/char/amiserial.c18
-rw-r--r--drivers/char/n_hdlc.c2
-rw-r--r--drivers/char/n_r3964.c2
-rw-r--r--drivers/char/tty_io.c37
-rw-r--r--drivers/firmware/pcdp.c11
-rw-r--r--drivers/firmware/pcdp.h2
-rw-r--r--drivers/ide/ide-cd.c89
-rw-r--r--drivers/ide/ide-disk.c3
-rw-r--r--drivers/ide/ide-floppy.c6
-rw-r--r--drivers/ide/ide-probe.c8
-rw-r--r--drivers/input/serio/serport.c2
-rw-r--r--drivers/md/dm-ioctl.c14
-rw-r--r--drivers/net/appletalk/ltpc.c6
-rw-r--r--drivers/net/e1000/e1000_main.c1
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/hamradio/mkiss.c2
-rw-r--r--drivers/net/irda/irtty-sir.c2
-rw-r--r--drivers/net/ppp_async.c2
-rw-r--r--drivers/net/ppp_synctty.c2
-rw-r--r--drivers/net/slip.c2
-rw-r--r--drivers/net/wan/x25_asy.c2
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/parport/parport_pc.c4
-rw-r--r--drivers/parport/parport_serial.c5
-rw-r--r--drivers/parport/probe.c18
-rw-r--r--drivers/pcmcia/cs.c11
-rw-r--r--drivers/pcmcia/ti113x.h167
-rw-r--r--drivers/pcmcia/yenta_socket.c60
-rw-r--r--drivers/scsi/dpt_i2o.c17
-rw-r--r--drivers/serial/sn_console.c1
-rw-r--r--drivers/usb/core/inode.c13
-rw-r--r--drivers/usb/input/hid-core.c4
-rw-r--r--drivers/usb/media/pwc/pwc-uncompress.c11
-rw-r--r--fs/block_dev.c5
-rw-r--r--fs/buffer.c57
-rw-r--r--fs/char_dev.c13
-rw-r--r--fs/debugfs/inode.c12
-rw-r--r--fs/dquot.c16
-rw-r--r--fs/eventpoll.c195
-rw-r--r--fs/exec.c23
-rw-r--r--fs/ext2/acl.c12
-rw-r--r--fs/ext2/acl.h2
-rw-r--r--fs/ext3/acl.c12
-rw-r--r--fs/ext3/acl.h2
-rw-r--r--fs/ext3/namei.c12
-rw-r--r--fs/ext3/super.c18
-rw-r--r--fs/file_table.c57
-rw-r--r--fs/fs-writeback.c64
-rw-r--r--fs/inode.c16
-rw-r--r--fs/jfs/acl.c11
-rw-r--r--fs/jfs/jfs_acl.h2
-rw-r--r--fs/jfs/super.c1
-rw-r--r--fs/jfs/xattr.c7
-rw-r--r--fs/namei.c20
-rw-r--r--fs/nfs/direct.c5
-rw-r--r--fs/nfsd/vfs.c9
-rw-r--r--fs/open.c41
-rw-r--r--fs/proc/base.c6
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/quota.c60
-rw-r--r--fs/read_write.c20
-rw-r--r--fs/reiserfs/super.c21
-rw-r--r--fs/reiserfs/xattr_acl.c26
-rw-r--r--fs/super.c83
-rw-r--r--fs/sysfs/dir.c5
-rw-r--r--fs/sysfs/file.c5
-rw-r--r--fs/sysfs/group.c4
-rw-r--r--fs/sysfs/inode.c10
-rw-r--r--fs/sysfs/sysfs.h1
-rw-r--r--include/asm-alpha/mmzone.h3
-rw-r--r--include/asm-arm/thread_info.h2
-rw-r--r--include/asm-arm26/thread_info.h2
-rw-r--r--include/asm-cris/thread_info.h2
-rw-r--r--include/asm-frv/thread_info.h2
-rw-r--r--include/asm-generic/percpu.h2
-rw-r--r--include/asm-generic/topology.h9
-rw-r--r--include/asm-h8300/thread_info.h2
-rw-r--r--include/asm-i386/checksum.h2
-rw-r--r--include/asm-i386/genapic.h1
-rw-r--r--include/asm-i386/kprobes.h3
-rw-r--r--include/asm-i386/mach-bigsmp/mach_apic.h2
-rw-r--r--include/asm-i386/mach-default/mach_apic.h2
-rw-r--r--include/asm-i386/mach-es7000/mach_apic.h2
-rw-r--r--include/asm-i386/mach-generic/mach_apic.h1
-rw-r--r--include/asm-i386/mach-numaq/mach_apic.h2
-rw-r--r--include/asm-i386/mach-summit/mach_apic.h2
-rw-r--r--include/asm-i386/mach-visws/mach_apic.h2
-rw-r--r--include/asm-i386/mmzone.h93
-rw-r--r--include/asm-i386/page.h6
-rw-r--r--include/asm-i386/param.h4
-rw-r--r--include/asm-i386/pgtable.h4
-rw-r--r--include/asm-i386/processor.h14
-rw-r--r--include/asm-i386/ptrace.h3
-rw-r--r--include/asm-i386/sparsemem.h31
-rw-r--r--include/asm-i386/thread_info.h2
-rw-r--r--include/asm-i386/timer.h2
-rw-r--r--include/asm-i386/timex.h5
-rw-r--r--include/asm-i386/topology.h8
-rw-r--r--include/asm-ia64/break.h2
-rw-r--r--include/asm-ia64/compat.h1
-rw-r--r--include/asm-ia64/fcntl.h2
-rw-r--r--include/asm-ia64/kdebug.h61
-rw-r--r--include/asm-ia64/kprobes.h116
-rw-r--r--include/asm-ia64/param.h2
-rw-r--r--include/asm-ia64/percpu.h2
-rw-r--r--include/asm-ia64/thread_info.h2
-rw-r--r--include/asm-m32r/mmzone.h3
-rw-r--r--include/asm-m32r/thread_info.h2
-rw-r--r--include/asm-m32r/topology.h44
-rw-r--r--include/asm-m68k/thread_info.h2
-rw-r--r--include/asm-m68knommu/thread_info.h2
-rw-r--r--include/asm-mips/compat.h1
-rw-r--r--include/asm-mips/thread_info.h2
-rw-r--r--include/asm-parisc/compat.h2
-rw-r--r--include/asm-parisc/mmzone.h3
-rw-r--r--include/asm-parisc/thread_info.h2
-rw-r--r--include/asm-ppc/thread_info.h3
-rw-r--r--include/asm-ppc64/compat.h1
-rw-r--r--include/asm-ppc64/mmzone.h44
-rw-r--r--include/asm-ppc64/page.h3
-rw-r--r--include/asm-ppc64/ppc32.h2
-rw-r--r--include/asm-ppc64/sparsemem.h16
-rw-r--r--include/asm-ppc64/thread_info.h2
-rw-r--r--include/asm-ppc64/topology.h4
-rw-r--r--include/asm-s390/thread_info.h2
-rw-r--r--include/asm-sh/thread_info.h2
-rw-r--r--include/asm-sh64/thread_info.h2
-rw-r--r--include/asm-sparc/thread_info.h4
-rw-r--r--include/asm-sparc64/compat.h1
-rw-r--r--include/asm-sparc64/thread_info.h2
-rw-r--r--include/asm-um/thread_info.h2
-rw-r--r--include/asm-v850/thread_info.h3
-rw-r--r--include/asm-x86_64/bitops.h2
-rw-r--r--include/asm-x86_64/ia32.h2
-rw-r--r--include/asm-x86_64/io.h5
-rw-r--r--include/asm-x86_64/kprobes.h3
-rw-r--r--include/asm-x86_64/mmzone.h20
-rw-r--r--include/asm-x86_64/msr.h5
-rw-r--r--include/asm-x86_64/page.h4
-rw-r--r--include/asm-x86_64/param.h6
-rw-r--r--include/asm-x86_64/percpu.h2
-rw-r--r--include/asm-x86_64/processor.h8
-rw-r--r--include/asm-x86_64/ptrace.h1
-rw-r--r--include/asm-x86_64/sparsemem.h26
-rw-r--r--include/asm-x86_64/thread_info.h2
-rw-r--r--include/asm-x86_64/timex.h3
-rw-r--r--include/asm-x86_64/topology.h18
-rw-r--r--include/linux/binfmts.h5
-rw-r--r--include/linux/blkdev.h10
-rw-r--r--include/linux/bootmem.h9
-rw-r--r--include/linux/fcntl.h4
-rw-r--r--include/linux/fs.h3
-rw-r--r--include/linux/genhd.h3
-rw-r--r--include/linux/ide.h2
-rw-r--r--include/linux/kprobes.h100
-rw-r--r--include/linux/loop.h2
-rw-r--r--include/linux/mempool.h11
-rw-r--r--include/linux/mm.h119
-rw-r--r--include/linux/mmzone.h171
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/linux/netfilter_ipv4/ipt_CLUSTERIP.h3
-rw-r--r--include/linux/netpoll.h34
-rw-r--r--include/linux/numa.h2
-rw-r--r--include/linux/pktcdvd.h2
-rw-r--r--include/linux/posix_acl_xattr.h11
-rw-r--r--include/linux/quotaops.h3
-rw-r--r--include/linux/reiserfs_acl.h1
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/linux/string.h2
-rw-r--r--include/linux/sysctl.h1
-rw-r--r--include/linux/timer.h34
-rw-r--r--include/linux/tty.h1
-rw-r--r--include/linux/wait.h16
-rw-r--r--include/linux/x25.h12
-rw-r--r--include/net/x25.h9
-rw-r--r--include/pcmcia/ss.h8
-rw-r--r--include/sound/core.h3
-rw-r--r--init/calibrate.c94
-rw-r--r--ipc/sem.c9
-rw-r--r--kernel/Kconfig.hz46
-rw-r--r--kernel/cpuset.c8
-rw-r--r--kernel/exit.c16
-rw-r--r--kernel/kprobes.c288
-rw-r--r--kernel/posix-timers.c34
-rw-r--r--kernel/printk.c12
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/signal.c1
-rw-r--r--kernel/sys.c108
-rw-r--r--kernel/sysctl.c9
-rw-r--r--kernel/timer.c351
-rw-r--r--mm/Kconfig91
-rw-r--r--mm/Makefile1
-rw-r--r--mm/bootmem.c9
-rw-r--r--mm/filemap.c6
-rw-r--r--mm/madvise.c1
-rw-r--r--mm/memory.c2
-rw-r--r--mm/mempool.c20
-rw-r--r--mm/page_alloc.c62
-rw-r--r--mm/slab.c24
-rw-r--r--mm/sparse.c137
-rw-r--r--net/appletalk/aarp.c7
-rw-r--r--net/bridge/netfilter/ebtables.c21
-rw-r--r--net/core/neighbour.c3
-rw-r--r--net/core/netpoll.c80
-rw-r--r--net/core/sysctl_net_core.c15
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c2
-rw-r--r--net/ipv4/route.c8
-rw-r--r--net/ipv6/addrconf.c3
-rw-r--r--net/socket.c3
-rw-r--r--net/sunrpc/svcauth_unix.c11
-rw-r--r--net/x25/af_x25.c110
-rw-r--r--net/x25/x25_facilities.c34
-rw-r--r--net/x25/x25_subr.c41
-rw-r--r--scripts/Makefile.build4
-rw-r--r--scripts/kconfig/gconf.glade10
-rw-r--r--security/commoncap.c2
-rw-r--r--security/dummy.c2
-rw-r--r--sound/core/info.c3
-rw-r--r--sound/core/info_oss.c3
-rw-r--r--sound/core/memory.c41
-rw-r--r--sound/core/oss/mixer_oss.c3
-rw-r--r--sound/core/oss/pcm_oss.c3
-rw-r--r--sound/core/sound.c2
-rw-r--r--sound/core/timer.c3
-rw-r--r--sound/isa/gus/gus_mem.c7
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/synth/emux/emux.c3
364 files changed, 5858 insertions, 2441 deletions
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 9a33bb94f74f..d4fda25db868 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -111,6 +111,7 @@ mkdep
111mktables 111mktables
112modpost 112modpost
113modversions.h* 113modversions.h*
114offset.h
114offsets.h 115offsets.h
115oui.c* 116oui.c*
116parse.c* 117parse.c*
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 26414bc87c65..e67c90d4ee17 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -66,6 +66,14 @@ Who: Paul E. McKenney <paulmck@us.ibm.com>
66 66
67--------------------------- 67---------------------------
68 68
69What: remove verify_area()
70When: July 2006
71Files: Various uaccess.h headers.
72Why: Deprecated and redundant. access_ok() should be used instead.
73Who: Jesper Juhl <juhl-lkml@dif.dk>
74
75---------------------------
76
69What: IEEE1394 Audio and Music Data Transmission Protocol driver, 77What: IEEE1394 Audio and Music Data Transmission Protocol driver,
70 Connection Management Procedures driver 78 Connection Management Procedures driver
71When: November 2005 79When: November 2005
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 35159176997b..9f11d36a8c10 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -49,6 +49,7 @@ show up in /proc/sys/kernel:
49- shmmax [ sysv ipc ] 49- shmmax [ sysv ipc ]
50- shmmni 50- shmmni
51- stop-a [ SPARC only ] 51- stop-a [ SPARC only ]
52- suid_dumpable
52- sysrq ==> Documentation/sysrq.txt 53- sysrq ==> Documentation/sysrq.txt
53- tainted 54- tainted
54- threads-max 55- threads-max
@@ -300,6 +301,25 @@ kernel. This value defaults to SHMMAX.
300 301
301============================================================== 302==============================================================
302 303
304suid_dumpable:
305
306This value can be used to query and set the core dump mode for setuid
307or otherwise protected/tainted binaries. The modes are
308
3090 - (default) - traditional behaviour. Any process which has changed
310 privilege levels or is execute only will not be dumped
3111 - (debug) - all processes dump core when possible. The core dump is
312 owned by the current user and no security is applied. This is
313 intended for system debugging situations only. Ptrace is unchecked.
3142 - (suidsafe) - any binary which normally would not be dumped is dumped
315 readable by root only. This allows the end user to remove
316 such a dump but not access it directly. For security reasons
317 core dumps in this mode will not overwrite one another or
318 other files. This mode is appropriate when adminstrators are
319 attempting to debug problems in a normal environment.
320
321==============================================================
322
303tainted: 323tainted:
304 324
305Non-zero if the kernel has been tainted. Numeric values, which 325Non-zero if the kernel has been tainted. Numeric values, which
diff --git a/Documentation/tty.txt b/Documentation/tty.txt
index 3958cf746dde..8ff7bc2a0811 100644
--- a/Documentation/tty.txt
+++ b/Documentation/tty.txt
@@ -22,7 +22,7 @@ copy of the structure. You must not re-register over the top of the line
22discipline even with the same data or your computer again will be eaten by 22discipline even with the same data or your computer again will be eaten by
23demons. 23demons.
24 24
25In order to remove a line discipline call tty_register_ldisc passing NULL. 25In order to remove a line discipline call tty_unregister_ldisc().
26In ancient times this always worked. In modern times the function will 26In ancient times this always worked. In modern times the function will
27return -EBUSY if the ldisc is currently in use. Since the ldisc referencing 27return -EBUSY if the ldisc is currently in use. Since the ldisc referencing
28code manages the module counts this should not usually be a concern. 28code manages the module counts this should not usually be a concern.
diff --git a/MAINTAINERS b/MAINTAINERS
index 5eaa6807cdb7..651af5012c98 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -304,7 +304,7 @@ S: Maintained
304ARM/PT DIGITAL BOARD PORT 304ARM/PT DIGITAL BOARD PORT
305P: Stefan Eletzhofer 305P: Stefan Eletzhofer
306M: stefan.eletzhofer@eletztrick.de 306M: stefan.eletzhofer@eletztrick.de
307L: linux-arm-kernel@lists.arm.linux.org.uk 307L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
308W: http://www.arm.linux.org.uk/ 308W: http://www.arm.linux.org.uk/
309S: Maintained 309S: Maintained
310 310
@@ -317,21 +317,21 @@ S: Maintained
317ARM/STRONGARM110 PORT 317ARM/STRONGARM110 PORT
318P: Russell King 318P: Russell King
319M: rmk@arm.linux.org.uk 319M: rmk@arm.linux.org.uk
320L: linux-arm-kernel@lists.arm.linux.org.uk 320L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
321W: http://www.arm.linux.org.uk/ 321W: http://www.arm.linux.org.uk/
322S: Maintained 322S: Maintained
323 323
324ARM/S3C2410 ARM ARCHITECTURE 324ARM/S3C2410 ARM ARCHITECTURE
325P: Ben Dooks 325P: Ben Dooks
326M: ben-s3c2410@fluff.org 326M: ben-s3c2410@fluff.org
327L: linux-arm-kernel@lists.arm.linux.org.uk 327L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
328W: http://www.fluff.org/ben/linux/ 328W: http://www.fluff.org/ben/linux/
329S: Maintained 329S: Maintained
330 330
331ARM/S3C2440 ARM ARCHITECTURE 331ARM/S3C2440 ARM ARCHITECTURE
332P: Ben Dooks 332P: Ben Dooks
333M: ben-s3c2440@fluff.org 333M: ben-s3c2440@fluff.org
334L: linux-arm-kernel@lists.arm.linux.org.uk 334L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
335W: http://www.fluff.org/ben/linux/ 335W: http://www.fluff.org/ben/linux/
336S: Maintained 336S: Maintained
337 337
@@ -1860,7 +1860,7 @@ S: Maintained
1860PXA2xx SUPPORT 1860PXA2xx SUPPORT
1861P: Nicolas Pitre 1861P: Nicolas Pitre
1862M: nico@cam.org 1862M: nico@cam.org
1863L: linux-arm-kernel@lists.arm.linux.org.uk 1863L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
1864S: Maintained 1864S: Maintained
1865 1865
1866QLOGIC QLA2XXX FC-SCSI DRIVER 1866QLOGIC QLA2XXX FC-SCSI DRIVER
@@ -2162,7 +2162,7 @@ SHARP LH SUPPORT (LH7952X & LH7A40X)
2162P: Marc Singer 2162P: Marc Singer
2163M: elf@buici.com 2163M: elf@buici.com
2164W: http://projects.buici.com/arm 2164W: http://projects.buici.com/arm
2165L: linux-arm-kernel@lists.arm.linux.org.uk 2165L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
2166S: Maintained 2166S: Maintained
2167 2167
2168SPARC (sparc32): 2168SPARC (sparc32):
diff --git a/Makefile b/Makefile
index 0d1e74d50067..fad349724e99 100644
--- a/Makefile
+++ b/Makefile
@@ -518,7 +518,7 @@ CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
518CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps) 518CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
519 519
520ifdef CONFIG_FRAME_POINTER 520ifdef CONFIG_FRAME_POINTER
521CFLAGS += -fno-omit-frame-pointer 521CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
522else 522else
523CFLAGS += -fomit-frame-pointer 523CFLAGS += -fomit-frame-pointer
524endif 524endif
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index f7c96635d3b4..c5739d6309df 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -509,7 +509,7 @@ config NR_CPUS
509 depends on SMP 509 depends on SMP
510 default "64" 510 default "64"
511 511
512config DISCONTIGMEM 512config ARCH_DISCONTIGMEM_ENABLE
513 bool "Discontiguous Memory Support (EXPERIMENTAL)" 513 bool "Discontiguous Memory Support (EXPERIMENTAL)"
514 depends on EXPERIMENTAL 514 depends on EXPERIMENTAL
515 help 515 help
@@ -518,6 +518,8 @@ config DISCONTIGMEM
518 or have huge holes in the physical address space for other reasons. 518 or have huge holes in the physical address space for other reasons.
519 See <file:Documentation/vm/numa> for more. 519 See <file:Documentation/vm/numa> for more.
520 520
521source "mm/Kconfig"
522
521config NUMA 523config NUMA
522 bool "NUMA Support (EXPERIMENTAL)" 524 bool "NUMA Support (EXPERIMENTAL)"
523 depends on DISCONTIGMEM 525 depends on DISCONTIGMEM
diff --git a/arch/alpha/defconfig b/arch/alpha/defconfig
index 5e39b7a7c8f4..6da9c3dbde44 100644
--- a/arch/alpha/defconfig
+++ b/arch/alpha/defconfig
@@ -96,7 +96,7 @@ CONFIG_ALPHA_CORE_AGP=y
96CONFIG_ALPHA_BROKEN_IRQ_MASK=y 96CONFIG_ALPHA_BROKEN_IRQ_MASK=y
97CONFIG_EISA=y 97CONFIG_EISA=y
98# CONFIG_SMP is not set 98# CONFIG_SMP is not set
99# CONFIG_DISCONTIGMEM is not set 99# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
100CONFIG_VERBOSE_MCHECK=y 100CONFIG_VERBOSE_MCHECK=y
101CONFIG_VERBOSE_MCHECK_ON=1 101CONFIG_VERBOSE_MCHECK_ON=1
102CONFIG_PCI_LEGACY_PROC=y 102CONFIG_PCI_LEGACY_PROC=y
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index ba81c4422aaf..c7481d59b6df 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -327,8 +327,6 @@ void __init mem_init(void)
327 extern char _text, _etext, _data, _edata; 327 extern char _text, _etext, _data, _edata;
328 extern char __init_begin, __init_end; 328 extern char __init_begin, __init_end;
329 unsigned long nid, i; 329 unsigned long nid, i;
330 struct page * lmem_map;
331
332 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); 330 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
333 331
334 reservedpages = 0; 332 reservedpages = 0;
@@ -338,10 +336,10 @@ void __init mem_init(void)
338 */ 336 */
339 totalram_pages += free_all_bootmem_node(NODE_DATA(nid)); 337 totalram_pages += free_all_bootmem_node(NODE_DATA(nid));
340 338
341 lmem_map = node_mem_map(nid);
342 pfn = NODE_DATA(nid)->node_start_pfn; 339 pfn = NODE_DATA(nid)->node_start_pfn;
343 for (i = 0; i < node_spanned_pages(nid); i++, pfn++) 340 for (i = 0; i < node_spanned_pages(nid); i++, pfn++)
344 if (page_is_ram(pfn) && PageReserved(lmem_map+i)) 341 if (page_is_ram(pfn) &&
342 PageReserved(nid_page_nr(nid, i)))
345 reservedpages++; 343 reservedpages++;
346 } 344 }
347 345
@@ -373,18 +371,18 @@ show_mem(void)
373 show_free_areas(); 371 show_free_areas();
374 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 372 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
375 for_each_online_node(nid) { 373 for_each_online_node(nid) {
376 struct page * lmem_map = node_mem_map(nid);
377 i = node_spanned_pages(nid); 374 i = node_spanned_pages(nid);
378 while (i-- > 0) { 375 while (i-- > 0) {
376 struct page *page = nid_page_nr(nid, i);
379 total++; 377 total++;
380 if (PageReserved(lmem_map+i)) 378 if (PageReserved(page))
381 reserved++; 379 reserved++;
382 else if (PageSwapCache(lmem_map+i)) 380 else if (PageSwapCache(page))
383 cached++; 381 cached++;
384 else if (!page_count(lmem_map+i)) 382 else if (!page_count(page))
385 free++; 383 free++;
386 else 384 else
387 shared += page_count(lmem_map + i) - 1; 385 shared += page_count(page) - 1;
388 } 386 }
389 } 387 }
390 printk("%ld pages of RAM\n",total); 388 printk("%ld pages of RAM\n",total);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ee8a9ad7bbd9..07ba77c19f6c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -346,7 +346,7 @@ config PREEMPT
346 Say Y here if you are building a kernel for a desktop, embedded 346 Say Y here if you are building a kernel for a desktop, embedded
347 or real-time system. Say N if you are unsure. 347 or real-time system. Say N if you are unsure.
348 348
349config DISCONTIGMEM 349config ARCH_DISCONTIGMEM_ENABLE
350 bool 350 bool
351 default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM) 351 default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM)
352 help 352 help
@@ -355,6 +355,8 @@ config DISCONTIGMEM
355 or have huge holes in the physical address space for other reasons. 355 or have huge holes in the physical address space for other reasons.
356 See <file:Documentation/vm/numa> for more. 356 See <file:Documentation/vm/numa> for more.
357 357
358source "mm/Kconfig"
359
358config LEDS 360config LEDS
359 bool "Timer and CPU usage LEDs" 361 bool "Timer and CPU usage LEDs"
360 depends on ARCH_CDB89712 || ARCH_CO285 || ARCH_EBSA110 || \ 362 depends on ARCH_CDB89712 || ARCH_CO285 || ARCH_EBSA110 || \
diff --git a/arch/arm/boot/install.sh b/arch/arm/boot/install.sh
index 935bb27369e9..9f9bed207345 100644
--- a/arch/arm/boot/install.sh
+++ b/arch/arm/boot/install.sh
@@ -21,8 +21,8 @@
21# 21#
22 22
23# User may have a custom install script 23# User may have a custom install script
24if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi 24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
25if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi 25if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
26 26
27if [ "$(basename $2)" = "zImage" ]; then 27if [ "$(basename $2)" = "zImage" ]; then
28# Compressed install 28# Compressed install
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index 6caed90661fc..dc0c1936969b 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -179,6 +179,8 @@ config CMDLINE
179 time by entering them here. As a minimum, you should specify the 179 time by entering them here. As a minimum, you should specify the
180 memory size and the root device (e.g., mem=64M root=/dev/nfs). 180 memory size and the root device (e.g., mem=64M root=/dev/nfs).
181 181
182source "mm/Kconfig"
183
182endmenu 184endmenu
183 185
184source "drivers/base/Kconfig" 186source "drivers/base/Kconfig"
diff --git a/arch/arm26/boot/install.sh b/arch/arm26/boot/install.sh
index c628328dd9ec..8a8399b26cf7 100644
--- a/arch/arm26/boot/install.sh
+++ b/arch/arm26/boot/install.sh
@@ -23,8 +23,8 @@
23 23
24# User may have a custom install script 24# User may have a custom install script
25 25
26if [ -x /sbin/installkernel ]; then 26if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then
27 exec /sbin/installkernel "$@" 27 exec /sbin/${CROSS_COMPILE}installkernel "$@"
28fi 28fi
29 29
30if [ "$2" = "zImage" ]; then 30if [ "$2" = "zImage" ]; then
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 4332ca348d51..f848e3761491 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -74,6 +74,8 @@ config PREEMPT
74 Say Y here if you are building a kernel for a desktop, embedded 74 Say Y here if you are building a kernel for a desktop, embedded
75 or real-time system. Say N if you are unsure. 75 or real-time system. Say N if you are unsure.
76 76
77source mm/Kconfig
78
77endmenu 79endmenu
78 80
79menu "Hardware setup" 81menu "Hardware setup"
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 2b19372767eb..c93f95146cc2 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -74,6 +74,8 @@ config HIGHPTE
74 with a lot of RAM, this can be wasteful of precious low memory. 74 with a lot of RAM, this can be wasteful of precious low memory.
75 Setting this option will put user-space page tables in high memory. 75 Setting this option will put user-space page tables in high memory.
76 76
77source "mm/Kconfig"
78
77choice 79choice
78 prompt "uClinux kernel load address" 80 prompt "uClinux kernel load address"
79 depends on !MMU 81 depends on !MMU
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu
index d9dd62a565a9..a380167a13cf 100644
--- a/arch/h8300/Kconfig.cpu
+++ b/arch/h8300/Kconfig.cpu
@@ -180,4 +180,7 @@ config CPU_H8S
180config PREEMPT 180config PREEMPT
181 bool "Preemptible Kernel" 181 bool "Preemptible Kernel"
182 default n 182 default n
183
184source "mm/Kconfig"
185
183endmenu 186endmenu
diff --git a/arch/h8300/platform/h8300h/ptrace_h8300h.c b/arch/h8300/platform/h8300h/ptrace_h8300h.c
index 18e51a7167d3..6ac93c05a1ae 100644
--- a/arch/h8300/platform/h8300h/ptrace_h8300h.c
+++ b/arch/h8300/platform/h8300h/ptrace_h8300h.c
@@ -245,12 +245,12 @@ static unsigned short *getnextpc(struct task_struct *child, unsigned short *pc)
245 addr = h8300_get_reg(child, regno-1+PT_ER1); 245 addr = h8300_get_reg(child, regno-1+PT_ER1);
246 return (unsigned short *)addr; 246 return (unsigned short *)addr;
247 case relb: 247 case relb:
248 if ((inst = 0x55) || isbranch(child,inst & 0x0f)) 248 if (inst == 0x55 || isbranch(child,inst & 0x0f))
249 pc = (unsigned short *)((unsigned long)pc + 249 pc = (unsigned short *)((unsigned long)pc +
250 ((signed char)(*fetch_p))); 250 ((signed char)(*fetch_p)));
251 return pc+1; /* skip myself */ 251 return pc+1; /* skip myself */
252 case relw: 252 case relw:
253 if ((inst = 0x5c) || isbranch(child,(*fetch_p & 0xf0) >> 4)) 253 if (inst == 0x5c || isbranch(child,(*fetch_p & 0xf0) >> 4))
254 pc = (unsigned short *)((unsigned long)pc + 254 pc = (unsigned short *)((unsigned long)pc +
255 ((signed short)(*(pc+1)))); 255 ((signed short)(*(pc+1))));
256 return pc+2; /* skip myself */ 256 return pc+2; /* skip myself */
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index dfd904f6883b..d4ae5f9ceae6 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -68,7 +68,6 @@ config X86_VOYAGER
68 68
69config X86_NUMAQ 69config X86_NUMAQ
70 bool "NUMAQ (IBM/Sequent)" 70 bool "NUMAQ (IBM/Sequent)"
71 select DISCONTIGMEM
72 select NUMA 71 select NUMA
73 help 72 help
74 This option is used for getting Linux to run on a (IBM/Sequent) NUMA 73 This option is used for getting Linux to run on a (IBM/Sequent) NUMA
@@ -783,25 +782,48 @@ comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support"
783comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI" 782comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
784 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI) 783 depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI)
785 784
786config DISCONTIGMEM
787 bool
788 depends on NUMA
789 default y
790
791config HAVE_ARCH_BOOTMEM_NODE 785config HAVE_ARCH_BOOTMEM_NODE
792 bool 786 bool
793 depends on NUMA 787 depends on NUMA
794 default y 788 default y
795 789
796config HAVE_MEMORY_PRESENT 790config ARCH_HAVE_MEMORY_PRESENT
797 bool 791 bool
798 depends on DISCONTIGMEM 792 depends on DISCONTIGMEM
799 default y 793 default y
800 794
801config NEED_NODE_MEMMAP_SIZE 795config NEED_NODE_MEMMAP_SIZE
802 bool 796 bool
803 depends on DISCONTIGMEM 797 depends on DISCONTIGMEM || SPARSEMEM
798 default y
799
800config HAVE_ARCH_ALLOC_REMAP
801 bool
802 depends on NUMA
803 default y
804
805config ARCH_DISCONTIGMEM_ENABLE
806 def_bool y
807 depends on NUMA
808
809config ARCH_DISCONTIGMEM_DEFAULT
810 def_bool y
811 depends on NUMA
812
813config ARCH_SPARSEMEM_ENABLE
814 def_bool y
815 depends on NUMA
816
817config ARCH_SELECT_MEMORY_MODEL
818 def_bool y
819 depends on ARCH_SPARSEMEM_ENABLE
820
821source "mm/Kconfig"
822
823config HAVE_ARCH_EARLY_PFN_TO_NID
824 bool
804 default y 825 default y
826 depends on NUMA
805 827
806config HIGHPTE 828config HIGHPTE
807 bool "Allocate 3rd-level pagetables from highmem" 829 bool "Allocate 3rd-level pagetables from highmem"
@@ -939,6 +961,8 @@ config SECCOMP
939 961
940 If unsure, say Y. Only embedded should say N here. 962 If unsure, say Y. Only embedded should say N here.
941 963
964source kernel/Kconfig.hz
965
942endmenu 966endmenu
943 967
944 968
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 1c36ca332a96..bf7c9ba709f3 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -17,6 +17,13 @@
17# 20050320 Kianusch Sayah Karadji <kianusch@sk-tech.net> 17# 20050320 Kianusch Sayah Karadji <kianusch@sk-tech.net>
18# Added support for GEODE CPU 18# Added support for GEODE CPU
19 19
20HAS_BIARCH := $(call cc-option-yn, -m32)
21ifeq ($(HAS_BIARCH),y)
22AS := $(AS) --32
23LD := $(LD) -m elf_i386
24CC := $(CC) -m32
25endif
26
20LDFLAGS := -m elf_i386 27LDFLAGS := -m elf_i386
21OBJCOPYFLAGS := -O binary -R .note -R .comment -S 28OBJCOPYFLAGS := -O binary -R .note -R .comment -S
22LDFLAGS_vmlinux := 29LDFLAGS_vmlinux :=
diff --git a/arch/i386/boot/install.sh b/arch/i386/boot/install.sh
index 90f2452b3b9e..f17b40dfc0f4 100644
--- a/arch/i386/boot/install.sh
+++ b/arch/i386/boot/install.sh
@@ -21,8 +21,8 @@
21 21
22# User may have a custom install script 22# User may have a custom install script
23 23
24if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi 24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
25if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi 25if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
26 26
27# Default install - same as make zlilo 27# Default install - same as make zlilo
28 28
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index d509836b70c3..8d993fa71754 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -1133,7 +1133,7 @@ inline void smp_local_timer_interrupt(struct pt_regs * regs)
1133 } 1133 }
1134 1134
1135#ifdef CONFIG_SMP 1135#ifdef CONFIG_SMP
1136 update_process_times(user_mode(regs)); 1136 update_process_times(user_mode_vm(regs));
1137#endif 1137#endif
1138 } 1138 }
1139 1139
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index d199e525680a..b9954248d0aa 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -635,7 +635,7 @@ void __init cpu_init (void)
635 635
636 /* Clear all 6 debug registers: */ 636 /* Clear all 6 debug registers: */
637 637
638#define CD(register) __asm__("movl %0,%%db" #register ::"r"(0) ); 638#define CD(register) set_debugreg(0, register)
639 639
640 CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7); 640 CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
641 641
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index e1c2042b9b7e..d66b09e0c820 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -375,6 +375,19 @@ int mtrr_add_page(unsigned long base, unsigned long size,
375 return error; 375 return error;
376} 376}
377 377
378static int mtrr_check(unsigned long base, unsigned long size)
379{
380 if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
381 printk(KERN_WARNING
382 "mtrr: size and base must be multiples of 4 kiB\n");
383 printk(KERN_DEBUG
384 "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
385 dump_stack();
386 return -1;
387 }
388 return 0;
389}
390
378/** 391/**
379 * mtrr_add - Add a memory type region 392 * mtrr_add - Add a memory type region
380 * @base: Physical base address of region 393 * @base: Physical base address of region
@@ -415,11 +428,8 @@ int
415mtrr_add(unsigned long base, unsigned long size, unsigned int type, 428mtrr_add(unsigned long base, unsigned long size, unsigned int type,
416 char increment) 429 char increment)
417{ 430{
418 if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { 431 if (mtrr_check(base, size))
419 printk(KERN_WARNING "mtrr: size and base must be multiples of 4 kiB\n");
420 printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
421 return -EINVAL; 432 return -EINVAL;
422 }
423 return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, 433 return mtrr_add_page(base >> PAGE_SHIFT, size >> PAGE_SHIFT, type,
424 increment); 434 increment);
425} 435}
@@ -511,11 +521,8 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
511int 521int
512mtrr_del(int reg, unsigned long base, unsigned long size) 522mtrr_del(int reg, unsigned long base, unsigned long size)
513{ 523{
514 if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { 524 if (mtrr_check(base, size))
515 printk(KERN_INFO "mtrr: size and base must be multiples of 4 kiB\n");
516 printk(KERN_DEBUG "mtrr: size: 0x%lx base: 0x%lx\n", size, base);
517 return -EINVAL; 525 return -EINVAL;
518 }
519 return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); 526 return mtrr_del_page(reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT);
520} 527}
521 528
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 7323c19f354e..8bd77d948a84 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -86,7 +86,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
86 seq_printf(m, "stepping\t: unknown\n"); 86 seq_printf(m, "stepping\t: unknown\n");
87 87
88 if ( cpu_has(c, X86_FEATURE_TSC) ) { 88 if ( cpu_has(c, X86_FEATURE_TSC) ) {
89 seq_printf(m, "cpu MHz\t\t: %lu.%03lu\n", 89 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
90 cpu_khz / 1000, (cpu_khz % 1000)); 90 cpu_khz / 1000, (cpu_khz % 1000));
91 } 91 }
92 92
diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
index 903190a4b3ff..180f070d03cb 100644
--- a/arch/i386/kernel/i386_ksyms.c
+++ b/arch/i386/kernel/i386_ksyms.c
@@ -1,97 +1,17 @@
1#include <linux/config.h> 1#include <linux/config.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/smp.h>
4#include <linux/user.h>
5#include <linux/elfcore.h>
6#include <linux/mca.h>
7#include <linux/sched.h>
8#include <linux/in6.h>
9#include <linux/interrupt.h>
10#include <linux/smp_lock.h>
11#include <linux/pm.h>
12#include <linux/pci.h>
13#include <linux/apm_bios.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/tty.h>
17#include <linux/highmem.h>
18#include <linux/time.h>
19
20#include <asm/semaphore.h>
21#include <asm/processor.h>
22#include <asm/i387.h>
23#include <asm/uaccess.h>
24#include <asm/checksum.h> 3#include <asm/checksum.h>
25#include <asm/io.h>
26#include <asm/delay.h>
27#include <asm/irq.h>
28#include <asm/mmx.h>
29#include <asm/desc.h> 4#include <asm/desc.h>
30#include <asm/pgtable.h>
31#include <asm/tlbflush.h>
32#include <asm/nmi.h>
33#include <asm/ist.h>
34#include <asm/kdebug.h>
35
36extern void dump_thread(struct pt_regs *, struct user *);
37extern spinlock_t rtc_lock;
38 5
39/* This is definitely a GPL-only symbol */ 6/* This is definitely a GPL-only symbol */
40EXPORT_SYMBOL_GPL(cpu_gdt_table); 7EXPORT_SYMBOL_GPL(cpu_gdt_table);
41 8
42#if defined(CONFIG_APM_MODULE)
43extern void machine_real_restart(unsigned char *, int);
44EXPORT_SYMBOL(machine_real_restart);
45extern void default_idle(void);
46EXPORT_SYMBOL(default_idle);
47#endif
48
49#ifdef CONFIG_SMP
50extern void FASTCALL( __write_lock_failed(rwlock_t *rw));
51extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
52#endif
53
54#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
55extern struct drive_info_struct drive_info;
56EXPORT_SYMBOL(drive_info);
57#endif
58
59extern unsigned long cpu_khz;
60extern unsigned long get_cmos_time(void);
61
62/* platform dependent support */
63EXPORT_SYMBOL(boot_cpu_data);
64#ifdef CONFIG_DISCONTIGMEM
65EXPORT_SYMBOL(node_data);
66EXPORT_SYMBOL(physnode_map);
67#endif
68#ifdef CONFIG_X86_NUMAQ
69EXPORT_SYMBOL(xquad_portio);
70#endif
71EXPORT_SYMBOL(dump_thread);
72EXPORT_SYMBOL(dump_fpu);
73EXPORT_SYMBOL_GPL(kernel_fpu_begin);
74EXPORT_SYMBOL(__ioremap);
75EXPORT_SYMBOL(ioremap_nocache);
76EXPORT_SYMBOL(iounmap);
77EXPORT_SYMBOL(kernel_thread);
78EXPORT_SYMBOL(pm_idle);
79EXPORT_SYMBOL(pm_power_off);
80EXPORT_SYMBOL(get_cmos_time);
81EXPORT_SYMBOL(cpu_khz);
82EXPORT_SYMBOL(apm_info);
83
84EXPORT_SYMBOL(__down_failed); 9EXPORT_SYMBOL(__down_failed);
85EXPORT_SYMBOL(__down_failed_interruptible); 10EXPORT_SYMBOL(__down_failed_interruptible);
86EXPORT_SYMBOL(__down_failed_trylock); 11EXPORT_SYMBOL(__down_failed_trylock);
87EXPORT_SYMBOL(__up_wakeup); 12EXPORT_SYMBOL(__up_wakeup);
88/* Networking helper routines. */ 13/* Networking helper routines. */
89EXPORT_SYMBOL(csum_partial_copy_generic); 14EXPORT_SYMBOL(csum_partial_copy_generic);
90/* Delay loops */
91EXPORT_SYMBOL(__ndelay);
92EXPORT_SYMBOL(__udelay);
93EXPORT_SYMBOL(__delay);
94EXPORT_SYMBOL(__const_udelay);
95 15
96EXPORT_SYMBOL(__get_user_1); 16EXPORT_SYMBOL(__get_user_1);
97EXPORT_SYMBOL(__get_user_2); 17EXPORT_SYMBOL(__get_user_2);
@@ -105,87 +25,11 @@ EXPORT_SYMBOL(__put_user_8);
105EXPORT_SYMBOL(strpbrk); 25EXPORT_SYMBOL(strpbrk);
106EXPORT_SYMBOL(strstr); 26EXPORT_SYMBOL(strstr);
107 27
108EXPORT_SYMBOL(strncpy_from_user);
109EXPORT_SYMBOL(__strncpy_from_user);
110EXPORT_SYMBOL(clear_user);
111EXPORT_SYMBOL(__clear_user);
112EXPORT_SYMBOL(__copy_from_user_ll);
113EXPORT_SYMBOL(__copy_to_user_ll);
114EXPORT_SYMBOL(strnlen_user);
115
116EXPORT_SYMBOL(dma_alloc_coherent);
117EXPORT_SYMBOL(dma_free_coherent);
118
119#ifdef CONFIG_PCI
120EXPORT_SYMBOL(pci_mem_start);
121#endif
122
123#ifdef CONFIG_PCI_BIOS
124EXPORT_SYMBOL(pcibios_set_irq_routing);
125EXPORT_SYMBOL(pcibios_get_irq_routing_table);
126#endif
127
128#ifdef CONFIG_X86_USE_3DNOW
129EXPORT_SYMBOL(_mmx_memcpy);
130EXPORT_SYMBOL(mmx_clear_page);
131EXPORT_SYMBOL(mmx_copy_page);
132#endif
133
134#ifdef CONFIG_X86_HT
135EXPORT_SYMBOL(smp_num_siblings);
136EXPORT_SYMBOL(cpu_sibling_map);
137#endif
138
139#ifdef CONFIG_SMP 28#ifdef CONFIG_SMP
140EXPORT_SYMBOL(cpu_data); 29extern void FASTCALL( __write_lock_failed(rwlock_t *rw));
141EXPORT_SYMBOL(cpu_online_map); 30extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
142EXPORT_SYMBOL(cpu_callout_map);
143EXPORT_SYMBOL(__write_lock_failed); 31EXPORT_SYMBOL(__write_lock_failed);
144EXPORT_SYMBOL(__read_lock_failed); 32EXPORT_SYMBOL(__read_lock_failed);
145
146/* Global SMP stuff */
147EXPORT_SYMBOL(smp_call_function);
148
149/* TLB flushing */
150EXPORT_SYMBOL(flush_tlb_page);
151#endif
152
153#ifdef CONFIG_X86_IO_APIC
154EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
155#endif
156
157#ifdef CONFIG_MCA
158EXPORT_SYMBOL(machine_id);
159#endif
160
161#ifdef CONFIG_VT
162EXPORT_SYMBOL(screen_info);
163#endif
164
165EXPORT_SYMBOL(get_wchan);
166
167EXPORT_SYMBOL(rtc_lock);
168
169EXPORT_SYMBOL_GPL(set_nmi_callback);
170EXPORT_SYMBOL_GPL(unset_nmi_callback);
171
172EXPORT_SYMBOL(register_die_notifier);
173#ifdef CONFIG_HAVE_DEC_LOCK
174EXPORT_SYMBOL(_atomic_dec_and_lock);
175#endif
176
177EXPORT_SYMBOL(__PAGE_KERNEL);
178
179#ifdef CONFIG_HIGHMEM
180EXPORT_SYMBOL(kmap);
181EXPORT_SYMBOL(kunmap);
182EXPORT_SYMBOL(kmap_atomic);
183EXPORT_SYMBOL(kunmap_atomic);
184EXPORT_SYMBOL(kmap_atomic_to_page);
185#endif
186
187#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
188EXPORT_SYMBOL(ist_info);
189#endif 33#endif
190 34
191EXPORT_SYMBOL(csum_partial); 35EXPORT_SYMBOL(csum_partial);
diff --git a/arch/i386/kernel/i387.c b/arch/i386/kernel/i387.c
index c55e037f08f7..b817168d9c62 100644
--- a/arch/i386/kernel/i387.c
+++ b/arch/i386/kernel/i387.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/config.h> 11#include <linux/config.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/module.h>
13#include <asm/processor.h> 14#include <asm/processor.h>
14#include <asm/i387.h> 15#include <asm/i387.h>
15#include <asm/math_emu.h> 16#include <asm/math_emu.h>
@@ -79,6 +80,7 @@ void kernel_fpu_begin(void)
79 } 80 }
80 clts(); 81 clts();
81} 82}
83EXPORT_SYMBOL_GPL(kernel_fpu_begin);
82 84
83void restore_fpu( struct task_struct *tsk ) 85void restore_fpu( struct task_struct *tsk )
84{ 86{
@@ -526,6 +528,7 @@ int dump_fpu( struct pt_regs *regs, struct user_i387_struct *fpu )
526 528
527 return fpvalid; 529 return fpvalid;
528} 530}
531EXPORT_SYMBOL(dump_fpu);
529 532
530int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu) 533int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu)
531{ 534{
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 7a324e8b86f9..08540bc4ba3e 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -31,7 +31,7 @@
31#include <linux/mc146818rtc.h> 31#include <linux/mc146818rtc.h>
32#include <linux/compiler.h> 32#include <linux/compiler.h>
33#include <linux/acpi.h> 33#include <linux/acpi.h>
34 34#include <linux/module.h>
35#include <linux/sysdev.h> 35#include <linux/sysdev.h>
36#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/smp.h> 37#include <asm/smp.h>
@@ -812,6 +812,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
812 } 812 }
813 return best_guess; 813 return best_guess;
814} 814}
815EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
815 816
816/* 817/*
817 * This function currently is only a helper for the i386 smp boot process where 818 * This function currently is only a helper for the i386 smp boot process where
@@ -1659,6 +1660,12 @@ static void __init setup_ioapic_ids_from_mpc(void)
1659 unsigned long flags; 1660 unsigned long flags;
1660 1661
1661 /* 1662 /*
1663 * Don't check I/O APIC IDs for xAPIC systems. They have
1664 * no meaning without the serial APIC bus.
1665 */
1666 if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86 < 15))
1667 return;
1668 /*
1662 * This is broken; anything with a real cpu count has to 1669 * This is broken; anything with a real cpu count has to
1663 * circumvent this idiocy regardless. 1670 * circumvent this idiocy regardless.
1664 */ 1671 */
@@ -1684,10 +1691,6 @@ static void __init setup_ioapic_ids_from_mpc(void)
1684 mp_ioapics[apic].mpc_apicid = reg_00.bits.ID; 1691 mp_ioapics[apic].mpc_apicid = reg_00.bits.ID;
1685 } 1692 }
1686 1693
1687 /* Don't check I/O APIC IDs for some xAPIC systems. They have
1688 * no meaning without the serial APIC bus. */
1689 if (NO_IOAPIC_CHECK)
1690 continue;
1691 /* 1694 /*
1692 * Sanity check, is the ID really free? Every APIC in a 1695 * Sanity check, is the ID really free? Every APIC in a
1693 * system must have a unique ID or we get lots of nice 1696 * system must have a unique ID or we get lots of nice
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 59ff9b455069..3762f6b35ab2 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -23,6 +23,9 @@
23 * Rusty Russell). 23 * Rusty Russell).
24 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes 24 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
25 * interface to access function arguments. 25 * interface to access function arguments.
26 * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston
27 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
28 * <prasanna@in.ibm.com> added function-return probes.
26 */ 29 */
27 30
28#include <linux/config.h> 31#include <linux/config.h>
@@ -30,15 +33,14 @@
30#include <linux/ptrace.h> 33#include <linux/ptrace.h>
31#include <linux/spinlock.h> 34#include <linux/spinlock.h>
32#include <linux/preempt.h> 35#include <linux/preempt.h>
36#include <asm/cacheflush.h>
33#include <asm/kdebug.h> 37#include <asm/kdebug.h>
34#include <asm/desc.h> 38#include <asm/desc.h>
35 39
36/* kprobe_status settings */
37#define KPROBE_HIT_ACTIVE 0x00000001
38#define KPROBE_HIT_SS 0x00000002
39
40static struct kprobe *current_kprobe; 40static struct kprobe *current_kprobe;
41static unsigned long kprobe_status, kprobe_old_eflags, kprobe_saved_eflags; 41static unsigned long kprobe_status, kprobe_old_eflags, kprobe_saved_eflags;
42static struct kprobe *kprobe_prev;
43static unsigned long kprobe_status_prev, kprobe_old_eflags_prev, kprobe_saved_eflags_prev;
42static struct pt_regs jprobe_saved_regs; 44static struct pt_regs jprobe_saved_regs;
43static long *jprobe_saved_esp; 45static long *jprobe_saved_esp;
44/* copy of the kernel stack at the probe fire time */ 46/* copy of the kernel stack at the probe fire time */
@@ -68,16 +70,50 @@ int arch_prepare_kprobe(struct kprobe *p)
68void arch_copy_kprobe(struct kprobe *p) 70void arch_copy_kprobe(struct kprobe *p)
69{ 71{
70 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 72 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
73 p->opcode = *p->addr;
71} 74}
72 75
73void arch_remove_kprobe(struct kprobe *p) 76void arch_arm_kprobe(struct kprobe *p)
74{ 77{
78 *p->addr = BREAKPOINT_INSTRUCTION;
79 flush_icache_range((unsigned long) p->addr,
80 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
75} 81}
76 82
77static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs) 83void arch_disarm_kprobe(struct kprobe *p)
78{ 84{
79 *p->addr = p->opcode; 85 *p->addr = p->opcode;
80 regs->eip = (unsigned long)p->addr; 86 flush_icache_range((unsigned long) p->addr,
87 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
88}
89
90void arch_remove_kprobe(struct kprobe *p)
91{
92}
93
94static inline void save_previous_kprobe(void)
95{
96 kprobe_prev = current_kprobe;
97 kprobe_status_prev = kprobe_status;
98 kprobe_old_eflags_prev = kprobe_old_eflags;
99 kprobe_saved_eflags_prev = kprobe_saved_eflags;
100}
101
102static inline void restore_previous_kprobe(void)
103{
104 current_kprobe = kprobe_prev;
105 kprobe_status = kprobe_status_prev;
106 kprobe_old_eflags = kprobe_old_eflags_prev;
107 kprobe_saved_eflags = kprobe_saved_eflags_prev;
108}
109
110static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs)
111{
112 current_kprobe = p;
113 kprobe_saved_eflags = kprobe_old_eflags
114 = (regs->eflags & (TF_MASK | IF_MASK));
115 if (is_IF_modifier(p->opcode))
116 kprobe_saved_eflags &= ~IF_MASK;
81} 117}
82 118
83static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 119static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
@@ -91,6 +127,50 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
91 regs->eip = (unsigned long)&p->ainsn.insn; 127 regs->eip = (unsigned long)&p->ainsn.insn;
92} 128}
93 129
130struct task_struct *arch_get_kprobe_task(void *ptr)
131{
132 return ((struct thread_info *) (((unsigned long) ptr) &
133 (~(THREAD_SIZE -1))))->task;
134}
135
136void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs)
137{
138 unsigned long *sara = (unsigned long *)&regs->esp;
139 struct kretprobe_instance *ri;
140 static void *orig_ret_addr;
141
142 /*
143 * Save the return address when the return probe hits
144 * the first time, and use it to populate the (krprobe
145 * instance)->ret_addr for subsequent return probes at
146 * the same addrress since stack address would have
147 * the kretprobe_trampoline by then.
148 */
149 if (((void*) *sara) != kretprobe_trampoline)
150 orig_ret_addr = (void*) *sara;
151
152 if ((ri = get_free_rp_inst(rp)) != NULL) {
153 ri->rp = rp;
154 ri->stack_addr = sara;
155 ri->ret_addr = orig_ret_addr;
156 add_rp_inst(ri);
157 /* Replace the return addr with trampoline addr */
158 *sara = (unsigned long) &kretprobe_trampoline;
159 } else {
160 rp->nmissed++;
161 }
162}
163
164void arch_kprobe_flush_task(struct task_struct *tk)
165{
166 struct kretprobe_instance *ri;
167 while ((ri = get_rp_inst_tsk(tk)) != NULL) {
168 *((unsigned long *)(ri->stack_addr)) =
169 (unsigned long) ri->ret_addr;
170 recycle_rp_inst(ri);
171 }
172}
173
94/* 174/*
95 * Interrupts are disabled on entry as trap3 is an interrupt gate and they 175 * Interrupts are disabled on entry as trap3 is an interrupt gate and they
96 * remain disabled thorough out this function. 176 * remain disabled thorough out this function.
@@ -127,8 +207,18 @@ static int kprobe_handler(struct pt_regs *regs)
127 unlock_kprobes(); 207 unlock_kprobes();
128 goto no_kprobe; 208 goto no_kprobe;
129 } 209 }
130 disarm_kprobe(p, regs); 210 /* We have reentered the kprobe_handler(), since
131 ret = 1; 211 * another probe was hit while within the handler.
212 * We here save the original kprobes variables and
213 * just single step on the instruction of the new probe
214 * without calling any user handlers.
215 */
216 save_previous_kprobe();
217 set_current_kprobe(p, regs);
218 p->nmissed++;
219 prepare_singlestep(p, regs);
220 kprobe_status = KPROBE_REENTER;
221 return 1;
132 } else { 222 } else {
133 p = current_kprobe; 223 p = current_kprobe;
134 if (p->break_handler && p->break_handler(p, regs)) { 224 if (p->break_handler && p->break_handler(p, regs)) {
@@ -163,11 +253,7 @@ static int kprobe_handler(struct pt_regs *regs)
163 } 253 }
164 254
165 kprobe_status = KPROBE_HIT_ACTIVE; 255 kprobe_status = KPROBE_HIT_ACTIVE;
166 current_kprobe = p; 256 set_current_kprobe(p, regs);
167 kprobe_saved_eflags = kprobe_old_eflags
168 = (regs->eflags & (TF_MASK | IF_MASK));
169 if (is_IF_modifier(p->opcode))
170 kprobe_saved_eflags &= ~IF_MASK;
171 257
172 if (p->pre_handler && p->pre_handler(p, regs)) 258 if (p->pre_handler && p->pre_handler(p, regs))
173 /* handler has already set things up, so skip ss setup */ 259 /* handler has already set things up, so skip ss setup */
@@ -184,6 +270,55 @@ no_kprobe:
184} 270}
185 271
186/* 272/*
273 * For function-return probes, init_kprobes() establishes a probepoint
274 * here. When a retprobed function returns, this probe is hit and
275 * trampoline_probe_handler() runs, calling the kretprobe's handler.
276 */
277 void kretprobe_trampoline_holder(void)
278 {
279 asm volatile ( ".global kretprobe_trampoline\n"
280 "kretprobe_trampoline: \n"
281 "nop\n");
282 }
283
284/*
285 * Called when we hit the probe point at kretprobe_trampoline
286 */
287int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
288{
289 struct task_struct *tsk;
290 struct kretprobe_instance *ri;
291 struct hlist_head *head;
292 struct hlist_node *node;
293 unsigned long *sara = ((unsigned long *) &regs->esp) - 1;
294
295 tsk = arch_get_kprobe_task(sara);
296 head = kretprobe_inst_table_head(tsk);
297
298 hlist_for_each_entry(ri, node, head, hlist) {
299 if (ri->stack_addr == sara && ri->rp) {
300 if (ri->rp->handler)
301 ri->rp->handler(ri, regs);
302 }
303 }
304 return 0;
305}
306
307void trampoline_post_handler(struct kprobe *p, struct pt_regs *regs,
308 unsigned long flags)
309{
310 struct kretprobe_instance *ri;
311 /* RA already popped */
312 unsigned long *sara = ((unsigned long *)&regs->esp) - 1;
313
314 while ((ri = get_rp_inst(sara))) {
315 regs->eip = (unsigned long)ri->ret_addr;
316 recycle_rp_inst(ri);
317 }
318 regs->eflags &= ~TF_MASK;
319}
320
321/*
187 * Called after single-stepping. p->addr is the address of the 322 * Called after single-stepping. p->addr is the address of the
188 * instruction whose first byte has been replaced by the "int 3" 323 * instruction whose first byte has been replaced by the "int 3"
189 * instruction. To avoid the SMP problems that can occur when we 324 * instruction. To avoid the SMP problems that can occur when we
@@ -263,13 +398,22 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
263 if (!kprobe_running()) 398 if (!kprobe_running())
264 return 0; 399 return 0;
265 400
266 if (current_kprobe->post_handler) 401 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
402 kprobe_status = KPROBE_HIT_SSDONE;
267 current_kprobe->post_handler(current_kprobe, regs, 0); 403 current_kprobe->post_handler(current_kprobe, regs, 0);
404 }
268 405
269 resume_execution(current_kprobe, regs); 406 if (current_kprobe->post_handler != trampoline_post_handler)
407 resume_execution(current_kprobe, regs);
270 regs->eflags |= kprobe_saved_eflags; 408 regs->eflags |= kprobe_saved_eflags;
271 409
410 /*Restore back the original saved kprobes variables and continue. */
411 if (kprobe_status == KPROBE_REENTER) {
412 restore_previous_kprobe();
413 goto out;
414 }
272 unlock_kprobes(); 415 unlock_kprobes();
416out:
273 preempt_enable_no_resched(); 417 preempt_enable_no_resched();
274 418
275 /* 419 /*
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index 1347ab4939e7..383a11600d2c 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -914,7 +914,10 @@ void __init mp_register_ioapic (
914 mp_ioapics[idx].mpc_apicaddr = address; 914 mp_ioapics[idx].mpc_apicaddr = address;
915 915
916 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); 916 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
917 mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id); 917 if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15))
918 mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id);
919 else
920 mp_ioapics[idx].mpc_apicid = id;
918 mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx); 921 mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
919 922
920 /* 923 /*
@@ -1055,11 +1058,20 @@ void __init mp_config_acpi_legacy_irqs (void)
1055 } 1058 }
1056} 1059}
1057 1060
1061#define MAX_GSI_NUM 4096
1062
1058int mp_register_gsi (u32 gsi, int edge_level, int active_high_low) 1063int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1059{ 1064{
1060 int ioapic = -1; 1065 int ioapic = -1;
1061 int ioapic_pin = 0; 1066 int ioapic_pin = 0;
1062 int idx, bit = 0; 1067 int idx, bit = 0;
1068 static int pci_irq = 16;
1069 /*
1070 * Mapping between Global System Interrups, which
1071 * represent all possible interrupts, and IRQs
1072 * assigned to actual devices.
1073 */
1074 static int gsi_to_irq[MAX_GSI_NUM];
1063 1075
1064#ifdef CONFIG_ACPI_BUS 1076#ifdef CONFIG_ACPI_BUS
1065 /* Don't set up the ACPI SCI because it's already set up */ 1077 /* Don't set up the ACPI SCI because it's already set up */
@@ -1094,11 +1106,26 @@ int mp_register_gsi (u32 gsi, int edge_level, int active_high_low)
1094 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) { 1106 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
1095 Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n", 1107 Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
1096 mp_ioapic_routing[ioapic].apic_id, ioapic_pin); 1108 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
1097 return gsi; 1109 return gsi_to_irq[gsi];
1098 } 1110 }
1099 1111
1100 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit); 1112 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
1101 1113
1114 if (edge_level) {
1115 /*
1116 * For PCI devices assign IRQs in order, avoiding gaps
1117 * due to unused I/O APIC pins.
1118 */
1119 int irq = gsi;
1120 if (gsi < MAX_GSI_NUM) {
1121 gsi = pci_irq++;
1122 gsi_to_irq[irq] = gsi;
1123 } else {
1124 printk(KERN_ERR "GSI %u is too high\n", gsi);
1125 return gsi;
1126 }
1127 }
1128
1102 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 1129 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
1103 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1, 1130 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1,
1104 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1); 1131 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1);
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 2c0ee9c2d020..da6c46d667cb 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -28,8 +28,7 @@
28#include <linux/sysctl.h> 28#include <linux/sysctl.h>
29 29
30#include <asm/smp.h> 30#include <asm/smp.h>
31#include <asm/mtrr.h> 31#include <asm/div64.h>
32#include <asm/mpspec.h>
33#include <asm/nmi.h> 32#include <asm/nmi.h>
34 33
35#include "mach_traps.h" 34#include "mach_traps.h"
@@ -324,6 +323,16 @@ static void clear_msr_range(unsigned int base, unsigned int n)
324 wrmsr(base+i, 0, 0); 323 wrmsr(base+i, 0, 0);
325} 324}
326 325
326static inline void write_watchdog_counter(const char *descr)
327{
328 u64 count = (u64)cpu_khz * 1000;
329
330 do_div(count, nmi_hz);
331 if(descr)
332 Dprintk("setting %s to -0x%08Lx\n", descr, count);
333 wrmsrl(nmi_perfctr_msr, 0 - count);
334}
335
327static void setup_k7_watchdog(void) 336static void setup_k7_watchdog(void)
328{ 337{
329 unsigned int evntsel; 338 unsigned int evntsel;
@@ -339,8 +348,7 @@ static void setup_k7_watchdog(void)
339 | K7_NMI_EVENT; 348 | K7_NMI_EVENT;
340 349
341 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 350 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
342 Dprintk("setting K7_PERFCTR0 to %08lx\n", -(cpu_khz/nmi_hz*1000)); 351 write_watchdog_counter("K7_PERFCTR0");
343 wrmsr(MSR_K7_PERFCTR0, -(cpu_khz/nmi_hz*1000), -1);
344 apic_write(APIC_LVTPC, APIC_DM_NMI); 352 apic_write(APIC_LVTPC, APIC_DM_NMI);
345 evntsel |= K7_EVNTSEL_ENABLE; 353 evntsel |= K7_EVNTSEL_ENABLE;
346 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 354 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0);
@@ -361,8 +369,7 @@ static void setup_p6_watchdog(void)
361 | P6_NMI_EVENT; 369 | P6_NMI_EVENT;
362 370
363 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0); 371 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0);
364 Dprintk("setting P6_PERFCTR0 to %08lx\n", -(cpu_khz/nmi_hz*1000)); 372 write_watchdog_counter("P6_PERFCTR0");
365 wrmsr(MSR_P6_PERFCTR0, -(cpu_khz/nmi_hz*1000), 0);
366 apic_write(APIC_LVTPC, APIC_DM_NMI); 373 apic_write(APIC_LVTPC, APIC_DM_NMI);
367 evntsel |= P6_EVNTSEL0_ENABLE; 374 evntsel |= P6_EVNTSEL0_ENABLE;
368 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0); 375 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0);
@@ -402,8 +409,7 @@ static int setup_p4_watchdog(void)
402 409
403 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0); 410 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0);
404 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0); 411 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0);
405 Dprintk("setting P4_IQ_COUNTER0 to 0x%08lx\n", -(cpu_khz/nmi_hz*1000)); 412 write_watchdog_counter("P4_IQ_COUNTER0");
406 wrmsr(MSR_P4_IQ_COUNTER0, -(cpu_khz/nmi_hz*1000), -1);
407 apic_write(APIC_LVTPC, APIC_DM_NMI); 413 apic_write(APIC_LVTPC, APIC_DM_NMI);
408 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 414 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
409 return 1; 415 return 1;
@@ -518,7 +524,7 @@ void nmi_watchdog_tick (struct pt_regs * regs)
518 * other P6 variant */ 524 * other P6 variant */
519 apic_write(APIC_LVTPC, APIC_DM_NMI); 525 apic_write(APIC_LVTPC, APIC_DM_NMI);
520 } 526 }
521 wrmsr(nmi_perfctr_msr, -(cpu_khz/nmi_hz*1000), -1); 527 write_watchdog_counter(NULL);
522 } 528 }
523} 529}
524 530
diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
index 4de2e03c7b45..1e51427cc9eb 100644
--- a/arch/i386/kernel/pci-dma.c
+++ b/arch/i386/kernel/pci-dma.c
@@ -11,6 +11,7 @@
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/module.h>
14#include <asm/io.h> 15#include <asm/io.h>
15 16
16struct dma_coherent_mem { 17struct dma_coherent_mem {
@@ -54,6 +55,7 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
54 } 55 }
55 return ret; 56 return ret;
56} 57}
58EXPORT_SYMBOL(dma_alloc_coherent);
57 59
58void dma_free_coherent(struct device *dev, size_t size, 60void dma_free_coherent(struct device *dev, size_t size,
59 void *vaddr, dma_addr_t dma_handle) 61 void *vaddr, dma_addr_t dma_handle)
@@ -68,6 +70,7 @@ void dma_free_coherent(struct device *dev, size_t size,
68 } else 70 } else
69 free_pages((unsigned long)vaddr, order); 71 free_pages((unsigned long)vaddr, order);
70} 72}
73EXPORT_SYMBOL(dma_free_coherent);
71 74
72int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, 75int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
73 dma_addr_t device_addr, size_t size, int flags) 76 dma_addr_t device_addr, size_t size, int flags)
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 96e3ea6b17c7..aea2ce1145df 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -37,6 +37,7 @@
37#include <linux/kallsyms.h> 37#include <linux/kallsyms.h>
38#include <linux/ptrace.h> 38#include <linux/ptrace.h>
39#include <linux/random.h> 39#include <linux/random.h>
40#include <linux/kprobes.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -73,6 +74,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
73 * Powermanagement idle function, if any.. 74 * Powermanagement idle function, if any..
74 */ 75 */
75void (*pm_idle)(void); 76void (*pm_idle)(void);
77EXPORT_SYMBOL(pm_idle);
76static DEFINE_PER_CPU(unsigned int, cpu_idle_state); 78static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
77 79
78void disable_hlt(void) 80void disable_hlt(void)
@@ -105,6 +107,9 @@ void default_idle(void)
105 cpu_relax(); 107 cpu_relax();
106 } 108 }
107} 109}
110#ifdef CONFIG_APM_MODULE
111EXPORT_SYMBOL(default_idle);
112#endif
108 113
109/* 114/*
110 * On SMP it's slightly faster (but much more power-consuming!) 115 * On SMP it's slightly faster (but much more power-consuming!)
@@ -262,7 +267,7 @@ void show_regs(struct pt_regs * regs)
262 printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id()); 267 printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
263 print_symbol("EIP is at %s\n", regs->eip); 268 print_symbol("EIP is at %s\n", regs->eip);
264 269
265 if (regs->xcs & 3) 270 if (user_mode(regs))
266 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp); 271 printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
267 printk(" EFLAGS: %08lx %s (%s)\n", 272 printk(" EFLAGS: %08lx %s (%s)\n",
268 regs->eflags, print_tainted(), system_utsname.release); 273 regs->eflags, print_tainted(), system_utsname.release);
@@ -325,6 +330,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
325 /* Ok, create the new process.. */ 330 /* Ok, create the new process.. */
326 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL); 331 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
327} 332}
333EXPORT_SYMBOL(kernel_thread);
328 334
329/* 335/*
330 * Free current thread data structures etc.. 336 * Free current thread data structures etc..
@@ -334,6 +340,13 @@ void exit_thread(void)
334 struct task_struct *tsk = current; 340 struct task_struct *tsk = current;
335 struct thread_struct *t = &tsk->thread; 341 struct thread_struct *t = &tsk->thread;
336 342
343 /*
344 * Remove function-return probe instances associated with this task
345 * and put them back on the free list. Do not insert an exit probe for
346 * this function, it will be disabled by kprobe_flush_task if you do.
347 */
348 kprobe_flush_task(tsk);
349
337 /* The process may have allocated an io port bitmap... nuke it. */ 350 /* The process may have allocated an io port bitmap... nuke it. */
338 if (unlikely(NULL != t->io_bitmap_ptr)) { 351 if (unlikely(NULL != t->io_bitmap_ptr)) {
339 int cpu = get_cpu(); 352 int cpu = get_cpu();
@@ -357,6 +370,13 @@ void flush_thread(void)
357{ 370{
358 struct task_struct *tsk = current; 371 struct task_struct *tsk = current;
359 372
373 /*
374 * Remove function-return probe instances associated with this task
375 * and put them back on the free list. Do not insert an exit probe for
376 * this function, it will be disabled by kprobe_flush_task if you do.
377 */
378 kprobe_flush_task(tsk);
379
360 memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8); 380 memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
361 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array)); 381 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
362 /* 382 /*
@@ -508,6 +528,7 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
508 528
509 dump->u_fpvalid = dump_fpu (regs, &dump->i387); 529 dump->u_fpvalid = dump_fpu (regs, &dump->i387);
510} 530}
531EXPORT_SYMBOL(dump_thread);
511 532
512/* 533/*
513 * Capture the user space registers if the task is not running (in user space) 534 * Capture the user space registers if the task is not running (in user space)
@@ -627,13 +648,13 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
627 * Now maybe reload the debug registers 648 * Now maybe reload the debug registers
628 */ 649 */
629 if (unlikely(next->debugreg[7])) { 650 if (unlikely(next->debugreg[7])) {
630 loaddebug(next, 0); 651 set_debugreg(current->thread.debugreg[0], 0);
631 loaddebug(next, 1); 652 set_debugreg(current->thread.debugreg[1], 1);
632 loaddebug(next, 2); 653 set_debugreg(current->thread.debugreg[2], 2);
633 loaddebug(next, 3); 654 set_debugreg(current->thread.debugreg[3], 3);
634 /* no 4 and 5 */ 655 /* no 4 and 5 */
635 loaddebug(next, 6); 656 set_debugreg(current->thread.debugreg[6], 6);
636 loaddebug(next, 7); 657 set_debugreg(current->thread.debugreg[7], 7);
637 } 658 }
638 659
639 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) 660 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr))
@@ -731,6 +752,7 @@ unsigned long get_wchan(struct task_struct *p)
731 } while (count++ < 16); 752 } while (count++ < 16);
732 return 0; 753 return 0;
733} 754}
755EXPORT_SYMBOL(get_wchan);
734 756
735/* 757/*
736 * sys_alloc_thread_area: get a yet unused TLS descriptor index. 758 * sys_alloc_thread_area: get a yet unused TLS descriptor index.
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index e34f651fa13c..0da59b42843c 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -668,7 +668,7 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
668 info.si_code = TRAP_BRKPT; 668 info.si_code = TRAP_BRKPT;
669 669
670 /* User-mode eip? */ 670 /* User-mode eip? */
671 info.si_addr = user_mode(regs) ? (void __user *) regs->eip : NULL; 671 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->eip : NULL;
672 672
673 /* Send us the fakey SIGTRAP */ 673 /* Send us the fakey SIGTRAP */
674 force_sig_info(SIGTRAP, &info, tsk); 674 force_sig_info(SIGTRAP, &info, tsk);
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 6dc27eb70ee7..db912209a8d3 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -2,6 +2,7 @@
2 * linux/arch/i386/kernel/reboot.c 2 * linux/arch/i386/kernel/reboot.c
3 */ 3 */
4 4
5#include <linux/config.h>
5#include <linux/mm.h> 6#include <linux/mm.h>
6#include <linux/module.h> 7#include <linux/module.h>
7#include <linux/delay.h> 8#include <linux/delay.h>
@@ -19,6 +20,7 @@
19 * Power off function, if any 20 * Power off function, if any
20 */ 21 */
21void (*pm_power_off)(void); 22void (*pm_power_off)(void);
23EXPORT_SYMBOL(pm_power_off);
22 24
23static int reboot_mode; 25static int reboot_mode;
24static int reboot_thru_bios; 26static int reboot_thru_bios;
@@ -295,6 +297,9 @@ void machine_real_restart(unsigned char *code, int length)
295 : 297 :
296 : "i" ((void *) (0x1000 - sizeof (real_mode_switch) - 100))); 298 : "i" ((void *) (0x1000 - sizeof (real_mode_switch) - 100)));
297} 299}
300#ifdef CONFIG_APM_MODULE
301EXPORT_SYMBOL(machine_real_restart);
302#endif
298 303
299void machine_restart(char * __unused) 304void machine_restart(char * __unused)
300{ 305{
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 2bfbddebdbf8..30406fd0b64c 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -23,8 +23,10 @@
23 * This file handles the architecture-dependent parts of initialization 23 * This file handles the architecture-dependent parts of initialization
24 */ 24 */
25 25
26#include <linux/config.h>
26#include <linux/sched.h> 27#include <linux/sched.h>
27#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/mmzone.h>
28#include <linux/tty.h> 30#include <linux/tty.h>
29#include <linux/ioport.h> 31#include <linux/ioport.h>
30#include <linux/acpi.h> 32#include <linux/acpi.h>
@@ -73,6 +75,7 @@ EXPORT_SYMBOL(efi_enabled);
73struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; 75struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
74/* common cpu data for all cpus */ 76/* common cpu data for all cpus */
75struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; 77struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
78EXPORT_SYMBOL(boot_cpu_data);
76 79
77unsigned long mmu_cr4_features; 80unsigned long mmu_cr4_features;
78 81
@@ -90,12 +93,18 @@ extern acpi_interrupt_flags acpi_sci_flags;
90 93
91/* for MCA, but anyone else can use it if they want */ 94/* for MCA, but anyone else can use it if they want */
92unsigned int machine_id; 95unsigned int machine_id;
96#ifdef CONFIG_MCA
97EXPORT_SYMBOL(machine_id);
98#endif
93unsigned int machine_submodel_id; 99unsigned int machine_submodel_id;
94unsigned int BIOS_revision; 100unsigned int BIOS_revision;
95unsigned int mca_pentium_flag; 101unsigned int mca_pentium_flag;
96 102
97/* For PCI or other memory-mapped resources */ 103/* For PCI or other memory-mapped resources */
98unsigned long pci_mem_start = 0x10000000; 104unsigned long pci_mem_start = 0x10000000;
105#ifdef CONFIG_PCI
106EXPORT_SYMBOL(pci_mem_start);
107#endif
99 108
100/* Boot loader ID as an integer, for the benefit of proc_dointvec */ 109/* Boot loader ID as an integer, for the benefit of proc_dointvec */
101int bootloader_type; 110int bootloader_type;
@@ -107,14 +116,26 @@ static unsigned int highmem_pages = -1;
107 * Setup options 116 * Setup options
108 */ 117 */
109struct drive_info_struct { char dummy[32]; } drive_info; 118struct drive_info_struct { char dummy[32]; } drive_info;
119#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
120 defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
121EXPORT_SYMBOL(drive_info);
122#endif
110struct screen_info screen_info; 123struct screen_info screen_info;
124#ifdef CONFIG_VT
125EXPORT_SYMBOL(screen_info);
126#endif
111struct apm_info apm_info; 127struct apm_info apm_info;
128EXPORT_SYMBOL(apm_info);
112struct sys_desc_table_struct { 129struct sys_desc_table_struct {
113 unsigned short length; 130 unsigned short length;
114 unsigned char table[0]; 131 unsigned char table[0];
115}; 132};
116struct edid_info edid_info; 133struct edid_info edid_info;
117struct ist_info ist_info; 134struct ist_info ist_info;
135#if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
136 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
137EXPORT_SYMBOL(ist_info);
138#endif
118struct e820map e820; 139struct e820map e820;
119 140
120extern void early_cpu_init(void); 141extern void early_cpu_init(void);
@@ -1022,7 +1043,7 @@ static void __init reserve_ebda_region(void)
1022 reserve_bootmem(addr, PAGE_SIZE); 1043 reserve_bootmem(addr, PAGE_SIZE);
1023} 1044}
1024 1045
1025#ifndef CONFIG_DISCONTIGMEM 1046#ifndef CONFIG_NEED_MULTIPLE_NODES
1026void __init setup_bootmem_allocator(void); 1047void __init setup_bootmem_allocator(void);
1027static unsigned long __init setup_memory(void) 1048static unsigned long __init setup_memory(void)
1028{ 1049{
@@ -1072,9 +1093,9 @@ void __init zone_sizes_init(void)
1072 free_area_init(zones_size); 1093 free_area_init(zones_size);
1073} 1094}
1074#else 1095#else
1075extern unsigned long setup_memory(void); 1096extern unsigned long __init setup_memory(void);
1076extern void zone_sizes_init(void); 1097extern void zone_sizes_init(void);
1077#endif /* !CONFIG_DISCONTIGMEM */ 1098#endif /* !CONFIG_NEED_MULTIPLE_NODES */
1078 1099
1079void __init setup_bootmem_allocator(void) 1100void __init setup_bootmem_allocator(void)
1080{ 1101{
@@ -1475,6 +1496,7 @@ void __init setup_arch(char **cmdline_p)
1475#endif 1496#endif
1476 paging_init(); 1497 paging_init();
1477 remapped_pgdat_init(); 1498 remapped_pgdat_init();
1499 sparse_init();
1478 zone_sizes_init(); 1500 zone_sizes_init();
1479 1501
1480 /* 1502 /*
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index ea46d028af08..b9b8f4e20fad 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -346,8 +346,8 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
346extern void __user __kernel_sigreturn; 346extern void __user __kernel_sigreturn;
347extern void __user __kernel_rt_sigreturn; 347extern void __user __kernel_rt_sigreturn;
348 348
349static void setup_frame(int sig, struct k_sigaction *ka, 349static int setup_frame(int sig, struct k_sigaction *ka,
350 sigset_t *set, struct pt_regs * regs) 350 sigset_t *set, struct pt_regs * regs)
351{ 351{
352 void __user *restorer; 352 void __user *restorer;
353 struct sigframe __user *frame; 353 struct sigframe __user *frame;
@@ -429,13 +429,14 @@ static void setup_frame(int sig, struct k_sigaction *ka,
429 current->comm, current->pid, frame, regs->eip, frame->pretcode); 429 current->comm, current->pid, frame, regs->eip, frame->pretcode);
430#endif 430#endif
431 431
432 return; 432 return 1;
433 433
434give_sigsegv: 434give_sigsegv:
435 force_sigsegv(sig, current); 435 force_sigsegv(sig, current);
436 return 0;
436} 437}
437 438
438static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 439static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
439 sigset_t *set, struct pt_regs * regs) 440 sigset_t *set, struct pt_regs * regs)
440{ 441{
441 void __user *restorer; 442 void __user *restorer;
@@ -522,20 +523,23 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
522 current->comm, current->pid, frame, regs->eip, frame->pretcode); 523 current->comm, current->pid, frame, regs->eip, frame->pretcode);
523#endif 524#endif
524 525
525 return; 526 return 1;
526 527
527give_sigsegv: 528give_sigsegv:
528 force_sigsegv(sig, current); 529 force_sigsegv(sig, current);
530 return 0;
529} 531}
530 532
531/* 533/*
532 * OK, we're invoking a handler 534 * OK, we're invoking a handler
533 */ 535 */
534 536
535static void 537static int
536handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 538handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
537 sigset_t *oldset, struct pt_regs * regs) 539 sigset_t *oldset, struct pt_regs * regs)
538{ 540{
541 int ret;
542
539 /* Are we from a system call? */ 543 /* Are we from a system call? */
540 if (regs->orig_eax >= 0) { 544 if (regs->orig_eax >= 0) {
541 /* If so, check system call restarting.. */ 545 /* If so, check system call restarting.. */
@@ -569,17 +573,19 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
569 573
570 /* Set up the stack frame */ 574 /* Set up the stack frame */
571 if (ka->sa.sa_flags & SA_SIGINFO) 575 if (ka->sa.sa_flags & SA_SIGINFO)
572 setup_rt_frame(sig, ka, info, oldset, regs); 576 ret = setup_rt_frame(sig, ka, info, oldset, regs);
573 else 577 else
574 setup_frame(sig, ka, oldset, regs); 578 ret = setup_frame(sig, ka, oldset, regs);
575 579
576 if (!(ka->sa.sa_flags & SA_NODEFER)) { 580 if (ret && !(ka->sa.sa_flags & SA_NODEFER)) {
577 spin_lock_irq(&current->sighand->siglock); 581 spin_lock_irq(&current->sighand->siglock);
578 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask); 582 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
579 sigaddset(&current->blocked,sig); 583 sigaddset(&current->blocked,sig);
580 recalc_sigpending(); 584 recalc_sigpending();
581 spin_unlock_irq(&current->sighand->siglock); 585 spin_unlock_irq(&current->sighand->siglock);
582 } 586 }
587
588 return ret;
583} 589}
584 590
585/* 591/*
@@ -599,7 +605,7 @@ int fastcall do_signal(struct pt_regs *regs, sigset_t *oldset)
599 * kernel mode. Just return without doing anything 605 * kernel mode. Just return without doing anything
600 * if so. 606 * if so.
601 */ 607 */
602 if ((regs->xcs & 3) != 3) 608 if (!user_mode(regs))
603 return 1; 609 return 1;
604 610
605 if (current->flags & PF_FREEZE) { 611 if (current->flags & PF_FREEZE) {
@@ -618,12 +624,11 @@ int fastcall do_signal(struct pt_regs *regs, sigset_t *oldset)
618 * inside the kernel. 624 * inside the kernel.
619 */ 625 */
620 if (unlikely(current->thread.debugreg[7])) { 626 if (unlikely(current->thread.debugreg[7])) {
621 loaddebug(&current->thread, 7); 627 set_debugreg(current->thread.debugreg[7], 7);
622 } 628 }
623 629
624 /* Whee! Actually deliver the signal. */ 630 /* Whee! Actually deliver the signal. */
625 handle_signal(signr, &info, &ka, oldset, regs); 631 return handle_signal(signr, &info, &ka, oldset, regs);
626 return 1;
627 } 632 }
628 633
629 no_signal: 634 no_signal:
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 6223c33ac91c..68be7d0c7238 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -19,6 +19,7 @@
19#include <linux/mc146818rtc.h> 19#include <linux/mc146818rtc.h>
20#include <linux/cache.h> 20#include <linux/cache.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/module.h>
22 23
23#include <asm/mtrr.h> 24#include <asm/mtrr.h>
24#include <asm/tlbflush.h> 25#include <asm/tlbflush.h>
@@ -452,6 +453,7 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
452 453
453 preempt_enable(); 454 preempt_enable();
454} 455}
456EXPORT_SYMBOL(flush_tlb_page);
455 457
456static void do_flush_tlb_all(void* info) 458static void do_flush_tlb_all(void* info)
457{ 459{
@@ -547,6 +549,7 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
547 549
548 return 0; 550 return 0;
549} 551}
552EXPORT_SYMBOL(smp_call_function);
550 553
551static void stop_this_cpu (void * dummy) 554static void stop_this_cpu (void * dummy)
552{ 555{
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index bc1bb6919e6a..c20d96d5c15c 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -60,6 +60,9 @@ static int __initdata smp_b_stepping;
60 60
61/* Number of siblings per CPU package */ 61/* Number of siblings per CPU package */
62int smp_num_siblings = 1; 62int smp_num_siblings = 1;
63#ifdef CONFIG_X86_HT
64EXPORT_SYMBOL(smp_num_siblings);
65#endif
63int phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */ 66int phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */
64EXPORT_SYMBOL(phys_proc_id); 67EXPORT_SYMBOL(phys_proc_id);
65int cpu_core_id[NR_CPUS]; /* Core ID of each logical CPU */ 68int cpu_core_id[NR_CPUS]; /* Core ID of each logical CPU */
@@ -67,13 +70,16 @@ EXPORT_SYMBOL(cpu_core_id);
67 70
68/* bitmap of online cpus */ 71/* bitmap of online cpus */
69cpumask_t cpu_online_map; 72cpumask_t cpu_online_map;
73EXPORT_SYMBOL(cpu_online_map);
70 74
71cpumask_t cpu_callin_map; 75cpumask_t cpu_callin_map;
72cpumask_t cpu_callout_map; 76cpumask_t cpu_callout_map;
77EXPORT_SYMBOL(cpu_callout_map);
73static cpumask_t smp_commenced_mask; 78static cpumask_t smp_commenced_mask;
74 79
75/* Per CPU bogomips and other parameters */ 80/* Per CPU bogomips and other parameters */
76struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; 81struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
82EXPORT_SYMBOL(cpu_data);
77 83
78u8 x86_cpu_to_apicid[NR_CPUS] = 84u8 x86_cpu_to_apicid[NR_CPUS] =
79 { [0 ... NR_CPUS-1] = 0xff }; 85 { [0 ... NR_CPUS-1] = 0xff };
@@ -199,7 +205,7 @@ static void __init synchronize_tsc_bp (void)
199 unsigned long long t0; 205 unsigned long long t0;
200 unsigned long long sum, avg; 206 unsigned long long sum, avg;
201 long long delta; 207 long long delta;
202 unsigned long one_usec; 208 unsigned int one_usec;
203 int buggy = 0; 209 int buggy = 0;
204 210
205 printk(KERN_INFO "checking TSC synchronization across %u CPUs: ", num_booting_cpus()); 211 printk(KERN_INFO "checking TSC synchronization across %u CPUs: ", num_booting_cpus());
@@ -885,8 +891,14 @@ static void smp_tune_scheduling (void)
885static int boot_cpu_logical_apicid; 891static int boot_cpu_logical_apicid;
886/* Where the IO area was mapped on multiquad, always 0 otherwise */ 892/* Where the IO area was mapped on multiquad, always 0 otherwise */
887void *xquad_portio; 893void *xquad_portio;
894#ifdef CONFIG_X86_NUMAQ
895EXPORT_SYMBOL(xquad_portio);
896#endif
888 897
889cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; 898cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
899#ifdef CONFIG_X86_HT
900EXPORT_SYMBOL(cpu_sibling_map);
901#endif
890cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; 902cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
891EXPORT_SYMBOL(cpu_core_map); 903EXPORT_SYMBOL(cpu_core_map);
892 904
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index a0dcb7c87c30..e68d9fdb0759 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -77,11 +77,13 @@ u64 jiffies_64 = INITIAL_JIFFIES;
77 77
78EXPORT_SYMBOL(jiffies_64); 78EXPORT_SYMBOL(jiffies_64);
79 79
80unsigned long cpu_khz; /* Detected as we calibrate the TSC */ 80unsigned int cpu_khz; /* Detected as we calibrate the TSC */
81EXPORT_SYMBOL(cpu_khz);
81 82
82extern unsigned long wall_jiffies; 83extern unsigned long wall_jiffies;
83 84
84DEFINE_SPINLOCK(rtc_lock); 85DEFINE_SPINLOCK(rtc_lock);
86EXPORT_SYMBOL(rtc_lock);
85 87
86DEFINE_SPINLOCK(i8253_lock); 88DEFINE_SPINLOCK(i8253_lock);
87EXPORT_SYMBOL(i8253_lock); 89EXPORT_SYMBOL(i8253_lock);
@@ -324,6 +326,8 @@ unsigned long get_cmos_time(void)
324 326
325 return retval; 327 return retval;
326} 328}
329EXPORT_SYMBOL(get_cmos_time);
330
327static void sync_cmos_clock(unsigned long dummy); 331static void sync_cmos_clock(unsigned long dummy);
328 332
329static struct timer_list sync_cmos_timer = 333static struct timer_list sync_cmos_timer =
diff --git a/arch/i386/kernel/timers/common.c b/arch/i386/kernel/timers/common.c
index 8e201219f525..37353bd31803 100644
--- a/arch/i386/kernel/timers/common.c
+++ b/arch/i386/kernel/timers/common.c
@@ -139,6 +139,15 @@ bad_calibration:
139} 139}
140#endif 140#endif
141 141
142
143unsigned long read_timer_tsc(void)
144{
145 unsigned long retval;
146 rdtscl(retval);
147 return retval;
148}
149
150
142/* calculate cpu_khz */ 151/* calculate cpu_khz */
143void init_cpu_khz(void) 152void init_cpu_khz(void)
144{ 153{
@@ -154,7 +163,8 @@ void init_cpu_khz(void)
154 :"=a" (cpu_khz), "=d" (edx) 163 :"=a" (cpu_khz), "=d" (edx)
155 :"r" (tsc_quotient), 164 :"r" (tsc_quotient),
156 "0" (eax), "1" (edx)); 165 "0" (eax), "1" (edx));
157 printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); 166 printk("Detected %u.%03u MHz processor.\n",
167 cpu_khz / 1000, cpu_khz % 1000);
158 } 168 }
159 } 169 }
160 } 170 }
diff --git a/arch/i386/kernel/timers/timer.c b/arch/i386/kernel/timers/timer.c
index a3d6a288088b..7e39ed8e33f8 100644
--- a/arch/i386/kernel/timers/timer.c
+++ b/arch/i386/kernel/timers/timer.c
@@ -64,3 +64,12 @@ struct timer_opts* __init select_timer(void)
64 panic("select_timer: Cannot find a suitable timer\n"); 64 panic("select_timer: Cannot find a suitable timer\n");
65 return NULL; 65 return NULL;
66} 66}
67
68int read_current_timer(unsigned long *timer_val)
69{
70 if (cur_timer->read_timer) {
71 *timer_val = cur_timer->read_timer();
72 return 0;
73 }
74 return -1;
75}
diff --git a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
index f778f471a09a..d766e0963ac1 100644
--- a/arch/i386/kernel/timers/timer_hpet.c
+++ b/arch/i386/kernel/timers/timer_hpet.c
@@ -158,7 +158,7 @@ static int __init init_hpet(char* override)
158 { unsigned long eax=0, edx=1000; 158 { unsigned long eax=0, edx=1000;
159 ASM_DIV64_REG(cpu_khz, edx, tsc_quotient, 159 ASM_DIV64_REG(cpu_khz, edx, tsc_quotient,
160 eax, edx); 160 eax, edx);
161 printk("Detected %lu.%03lu MHz processor.\n", 161 printk("Detected %u.%03u MHz processor.\n",
162 cpu_khz / 1000, cpu_khz % 1000); 162 cpu_khz / 1000, cpu_khz % 1000);
163 } 163 }
164 set_cyc2ns_scale(cpu_khz/1000); 164 set_cyc2ns_scale(cpu_khz/1000);
@@ -186,6 +186,7 @@ static struct timer_opts timer_hpet = {
186 .get_offset = get_offset_hpet, 186 .get_offset = get_offset_hpet,
187 .monotonic_clock = monotonic_clock_hpet, 187 .monotonic_clock = monotonic_clock_hpet,
188 .delay = delay_hpet, 188 .delay = delay_hpet,
189 .read_timer = read_timer_tsc,
189}; 190};
190 191
191struct init_timer_opts __initdata timer_hpet_init = { 192struct init_timer_opts __initdata timer_hpet_init = {
diff --git a/arch/i386/kernel/timers/timer_pm.c b/arch/i386/kernel/timers/timer_pm.c
index d77f22030fe6..4ef20e663498 100644
--- a/arch/i386/kernel/timers/timer_pm.c
+++ b/arch/i386/kernel/timers/timer_pm.c
@@ -246,6 +246,7 @@ static struct timer_opts timer_pmtmr = {
246 .get_offset = get_offset_pmtmr, 246 .get_offset = get_offset_pmtmr,
247 .monotonic_clock = monotonic_clock_pmtmr, 247 .monotonic_clock = monotonic_clock_pmtmr,
248 .delay = delay_pmtmr, 248 .delay = delay_pmtmr,
249 .read_timer = read_timer_tsc,
249}; 250};
250 251
251struct init_timer_opts __initdata timer_pmtmr_init = { 252struct init_timer_opts __initdata timer_pmtmr_init = {
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
index 180444d87824..54c36b182021 100644
--- a/arch/i386/kernel/timers/timer_tsc.c
+++ b/arch/i386/kernel/timers/timer_tsc.c
@@ -256,7 +256,7 @@ static unsigned long loops_per_jiffy_ref = 0;
256 256
257#ifndef CONFIG_SMP 257#ifndef CONFIG_SMP
258static unsigned long fast_gettimeoffset_ref = 0; 258static unsigned long fast_gettimeoffset_ref = 0;
259static unsigned long cpu_khz_ref = 0; 259static unsigned int cpu_khz_ref = 0;
260#endif 260#endif
261 261
262static int 262static int
@@ -323,7 +323,7 @@ static inline void cpufreq_delayed_get(void) { return; }
323int recalibrate_cpu_khz(void) 323int recalibrate_cpu_khz(void)
324{ 324{
325#ifndef CONFIG_SMP 325#ifndef CONFIG_SMP
326 unsigned long cpu_khz_old = cpu_khz; 326 unsigned int cpu_khz_old = cpu_khz;
327 327
328 if (cpu_has_tsc) { 328 if (cpu_has_tsc) {
329 init_cpu_khz(); 329 init_cpu_khz();
@@ -534,7 +534,8 @@ static int __init init_tsc(char* override)
534 :"=a" (cpu_khz), "=d" (edx) 534 :"=a" (cpu_khz), "=d" (edx)
535 :"r" (tsc_quotient), 535 :"r" (tsc_quotient),
536 "0" (eax), "1" (edx)); 536 "0" (eax), "1" (edx));
537 printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); 537 printk("Detected %u.%03u MHz processor.\n",
538 cpu_khz / 1000, cpu_khz % 1000);
538 } 539 }
539 set_cyc2ns_scale(cpu_khz/1000); 540 set_cyc2ns_scale(cpu_khz/1000);
540 return 0; 541 return 0;
@@ -572,6 +573,7 @@ static struct timer_opts timer_tsc = {
572 .get_offset = get_offset_tsc, 573 .get_offset = get_offset_tsc,
573 .monotonic_clock = monotonic_clock_tsc, 574 .monotonic_clock = monotonic_clock_tsc,
574 .delay = delay_tsc, 575 .delay = delay_tsc,
576 .read_timer = read_timer_tsc,
575}; 577};
576 578
577struct init_timer_opts __initdata timer_tsc_init = { 579struct init_timer_opts __initdata timer_tsc_init = {
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 83c579e82a81..e4d4e2162c7a 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -104,6 +104,7 @@ int register_die_notifier(struct notifier_block *nb)
104 spin_unlock_irqrestore(&die_notifier_lock, flags); 104 spin_unlock_irqrestore(&die_notifier_lock, flags);
105 return err; 105 return err;
106} 106}
107EXPORT_SYMBOL(register_die_notifier);
107 108
108static inline int valid_stack_ptr(struct thread_info *tinfo, void *p) 109static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
109{ 110{
@@ -209,7 +210,7 @@ void show_registers(struct pt_regs *regs)
209 210
210 esp = (unsigned long) (&regs->esp); 211 esp = (unsigned long) (&regs->esp);
211 ss = __KERNEL_DS; 212 ss = __KERNEL_DS;
212 if (regs->xcs & 3) { 213 if (user_mode(regs)) {
213 in_kernel = 0; 214 in_kernel = 0;
214 esp = regs->esp; 215 esp = regs->esp;
215 ss = regs->xss & 0xffff; 216 ss = regs->xss & 0xffff;
@@ -265,7 +266,7 @@ static void handle_BUG(struct pt_regs *regs)
265 char c; 266 char c;
266 unsigned long eip; 267 unsigned long eip;
267 268
268 if (regs->xcs & 3) 269 if (user_mode(regs))
269 goto no_bug; /* Not in kernel */ 270 goto no_bug; /* Not in kernel */
270 271
271 eip = regs->eip; 272 eip = regs->eip;
@@ -353,7 +354,7 @@ void die(const char * str, struct pt_regs * regs, long err)
353 354
354static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err) 355static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
355{ 356{
356 if (!(regs->eflags & VM_MASK) && !(3 & regs->xcs)) 357 if (!user_mode_vm(regs))
357 die(str, regs, err); 358 die(str, regs, err);
358} 359}
359 360
@@ -366,7 +367,7 @@ static void do_trap(int trapnr, int signr, char *str, int vm86,
366 goto trap_signal; 367 goto trap_signal;
367 } 368 }
368 369
369 if (!(regs->xcs & 3)) 370 if (!user_mode(regs))
370 goto kernel_trap; 371 goto kernel_trap;
371 372
372 trap_signal: { 373 trap_signal: {
@@ -488,7 +489,7 @@ fastcall void do_general_protection(struct pt_regs * regs, long error_code)
488 if (regs->eflags & VM_MASK) 489 if (regs->eflags & VM_MASK)
489 goto gp_in_vm86; 490 goto gp_in_vm86;
490 491
491 if (!(regs->xcs & 3)) 492 if (!user_mode(regs))
492 goto gp_in_kernel; 493 goto gp_in_kernel;
493 494
494 current->thread.error_code = error_code; 495 current->thread.error_code = error_code;
@@ -636,11 +637,13 @@ void set_nmi_callback(nmi_callback_t callback)
636{ 637{
637 nmi_callback = callback; 638 nmi_callback = callback;
638} 639}
640EXPORT_SYMBOL_GPL(set_nmi_callback);
639 641
640void unset_nmi_callback(void) 642void unset_nmi_callback(void)
641{ 643{
642 nmi_callback = dummy_nmi_callback; 644 nmi_callback = dummy_nmi_callback;
643} 645}
646EXPORT_SYMBOL_GPL(unset_nmi_callback);
644 647
645#ifdef CONFIG_KPROBES 648#ifdef CONFIG_KPROBES
646fastcall void do_int3(struct pt_regs *regs, long error_code) 649fastcall void do_int3(struct pt_regs *regs, long error_code)
@@ -682,7 +685,7 @@ fastcall void do_debug(struct pt_regs * regs, long error_code)
682 unsigned int condition; 685 unsigned int condition;
683 struct task_struct *tsk = current; 686 struct task_struct *tsk = current;
684 687
685 __asm__ __volatile__("movl %%db6,%0" : "=r" (condition)); 688 get_debugreg(condition, 6);
686 689
687 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code, 690 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
688 SIGTRAP) == NOTIFY_STOP) 691 SIGTRAP) == NOTIFY_STOP)
@@ -713,7 +716,7 @@ fastcall void do_debug(struct pt_regs * regs, long error_code)
713 * check for kernel mode by just checking the CPL 716 * check for kernel mode by just checking the CPL
714 * of CS. 717 * of CS.
715 */ 718 */
716 if ((regs->xcs & 3) == 0) 719 if (!user_mode(regs))
717 goto clear_TF_reenable; 720 goto clear_TF_reenable;
718 } 721 }
719 722
@@ -724,9 +727,7 @@ fastcall void do_debug(struct pt_regs * regs, long error_code)
724 * the signal is delivered. 727 * the signal is delivered.
725 */ 728 */
726clear_dr7: 729clear_dr7:
727 __asm__("movl %0,%%db7" 730 set_debugreg(0, 7);
728 : /* no output */
729 : "r" (0));
730 return; 731 return;
731 732
732debug_vm86: 733debug_vm86:
diff --git a/arch/i386/lib/dec_and_lock.c b/arch/i386/lib/dec_and_lock.c
index ab43394dc775..8b81b2524fa6 100644
--- a/arch/i386/lib/dec_and_lock.c
+++ b/arch/i386/lib/dec_and_lock.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/spinlock.h> 10#include <linux/spinlock.h>
11#include <linux/module.h>
11#include <asm/atomic.h> 12#include <asm/atomic.h>
12 13
13int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) 14int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
@@ -38,3 +39,4 @@ slow_path:
38 spin_unlock(lock); 39 spin_unlock(lock);
39 return 0; 40 return 0;
40} 41}
42EXPORT_SYMBOL(_atomic_dec_and_lock);
diff --git a/arch/i386/lib/delay.c b/arch/i386/lib/delay.c
index eb0cdfe9280f..c49a6acbee56 100644
--- a/arch/i386/lib/delay.c
+++ b/arch/i386/lib/delay.c
@@ -13,6 +13,7 @@
13#include <linux/config.h> 13#include <linux/config.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/module.h>
16#include <asm/processor.h> 17#include <asm/processor.h>
17#include <asm/delay.h> 18#include <asm/delay.h>
18#include <asm/timer.h> 19#include <asm/timer.h>
@@ -47,3 +48,8 @@ void __ndelay(unsigned long nsecs)
47{ 48{
48 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */ 49 __const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
49} 50}
51
52EXPORT_SYMBOL(__delay);
53EXPORT_SYMBOL(__const_udelay);
54EXPORT_SYMBOL(__udelay);
55EXPORT_SYMBOL(__ndelay);
diff --git a/arch/i386/lib/mmx.c b/arch/i386/lib/mmx.c
index 01f8b1a2cc84..2afda94dffd3 100644
--- a/arch/i386/lib/mmx.c
+++ b/arch/i386/lib/mmx.c
@@ -3,6 +3,7 @@
3#include <linux/string.h> 3#include <linux/string.h>
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/hardirq.h> 5#include <linux/hardirq.h>
6#include <linux/module.h>
6 7
7#include <asm/i387.h> 8#include <asm/i387.h>
8 9
@@ -397,3 +398,7 @@ void mmx_copy_page(void *to, void *from)
397 else 398 else
398 fast_copy_page(to, from); 399 fast_copy_page(to, from);
399} 400}
401
402EXPORT_SYMBOL(_mmx_memcpy);
403EXPORT_SYMBOL(mmx_clear_page);
404EXPORT_SYMBOL(mmx_copy_page);
diff --git a/arch/i386/lib/usercopy.c b/arch/i386/lib/usercopy.c
index 51aa2bbb0269..4cf981d70f45 100644
--- a/arch/i386/lib/usercopy.c
+++ b/arch/i386/lib/usercopy.c
@@ -84,6 +84,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count)
84 __do_strncpy_from_user(dst, src, count, res); 84 __do_strncpy_from_user(dst, src, count, res);
85 return res; 85 return res;
86} 86}
87EXPORT_SYMBOL(__strncpy_from_user);
87 88
88/** 89/**
89 * strncpy_from_user: - Copy a NUL terminated string from userspace. 90 * strncpy_from_user: - Copy a NUL terminated string from userspace.
@@ -111,7 +112,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
111 __do_strncpy_from_user(dst, src, count, res); 112 __do_strncpy_from_user(dst, src, count, res);
112 return res; 113 return res;
113} 114}
114 115EXPORT_SYMBOL(strncpy_from_user);
115 116
116/* 117/*
117 * Zero Userspace 118 * Zero Userspace
@@ -157,6 +158,7 @@ clear_user(void __user *to, unsigned long n)
157 __do_clear_user(to, n); 158 __do_clear_user(to, n);
158 return n; 159 return n;
159} 160}
161EXPORT_SYMBOL(clear_user);
160 162
161/** 163/**
162 * __clear_user: - Zero a block of memory in user space, with less checking. 164 * __clear_user: - Zero a block of memory in user space, with less checking.
@@ -175,6 +177,7 @@ __clear_user(void __user *to, unsigned long n)
175 __do_clear_user(to, n); 177 __do_clear_user(to, n);
176 return n; 178 return n;
177} 179}
180EXPORT_SYMBOL(__clear_user);
178 181
179/** 182/**
180 * strlen_user: - Get the size of a string in user space. 183 * strlen_user: - Get the size of a string in user space.
@@ -218,6 +221,7 @@ long strnlen_user(const char __user *s, long n)
218 :"cc"); 221 :"cc");
219 return res & mask; 222 return res & mask;
220} 223}
224EXPORT_SYMBOL(strnlen_user);
221 225
222#ifdef CONFIG_X86_INTEL_USERCOPY 226#ifdef CONFIG_X86_INTEL_USERCOPY
223static unsigned long 227static unsigned long
@@ -570,6 +574,7 @@ survive:
570 n = __copy_user_intel(to, from, n); 574 n = __copy_user_intel(to, from, n);
571 return n; 575 return n;
572} 576}
577EXPORT_SYMBOL(__copy_to_user_ll);
573 578
574unsigned long 579unsigned long
575__copy_from_user_ll(void *to, const void __user *from, unsigned long n) 580__copy_from_user_ll(void *to, const void __user *from, unsigned long n)
@@ -581,6 +586,7 @@ __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
581 n = __copy_user_zeroing_intel(to, from, n); 586 n = __copy_user_zeroing_intel(to, from, n);
582 return n; 587 return n;
583} 588}
589EXPORT_SYMBOL(__copy_from_user_ll);
584 590
585/** 591/**
586 * copy_to_user: - Copy a block of data into user space. 592 * copy_to_user: - Copy a block of data into user space.
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index a6e0ddd65bd0..8c8527593da0 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -1288,7 +1288,7 @@ smp_local_timer_interrupt(struct pt_regs * regs)
1288 per_cpu(prof_counter, cpu); 1288 per_cpu(prof_counter, cpu);
1289 } 1289 }
1290 1290
1291 update_process_times(user_mode(regs)); 1291 update_process_times(user_mode_vm(regs));
1292 } 1292 }
1293 1293
1294 if( ((1<<cpu) & voyager_extended_vic_processors) == 0) 1294 if( ((1<<cpu) & voyager_extended_vic_processors) == 0)
diff --git a/arch/i386/mm/Makefile b/arch/i386/mm/Makefile
index fc3272506846..80908b5aa60f 100644
--- a/arch/i386/mm/Makefile
+++ b/arch/i386/mm/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-y := init.o pgtable.o fault.o ioremap.o extable.o pageattr.o mmap.o 5obj-y := init.o pgtable.o fault.o ioremap.o extable.o pageattr.o mmap.o
6 6
7obj-$(CONFIG_DISCONTIGMEM) += discontig.o 7obj-$(CONFIG_NUMA) += discontig.o
8obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 8obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
9obj-$(CONFIG_HIGHMEM) += highmem.o 9obj-$(CONFIG_HIGHMEM) += highmem.o
10obj-$(CONFIG_BOOT_IOREMAP) += boot_ioremap.o 10obj-$(CONFIG_BOOT_IOREMAP) += boot_ioremap.o
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
index 1726b4096b10..f429c871e845 100644
--- a/arch/i386/mm/discontig.c
+++ b/arch/i386/mm/discontig.c
@@ -29,12 +29,14 @@
29#include <linux/highmem.h> 29#include <linux/highmem.h>
30#include <linux/initrd.h> 30#include <linux/initrd.h>
31#include <linux/nodemask.h> 31#include <linux/nodemask.h>
32#include <linux/module.h>
32#include <asm/e820.h> 33#include <asm/e820.h>
33#include <asm/setup.h> 34#include <asm/setup.h>
34#include <asm/mmzone.h> 35#include <asm/mmzone.h>
35#include <bios_ebda.h> 36#include <bios_ebda.h>
36 37
37struct pglist_data *node_data[MAX_NUMNODES]; 38struct pglist_data *node_data[MAX_NUMNODES];
39EXPORT_SYMBOL(node_data);
38bootmem_data_t node0_bdata; 40bootmem_data_t node0_bdata;
39 41
40/* 42/*
@@ -42,12 +44,16 @@ bootmem_data_t node0_bdata;
42 * populated the following initialisation. 44 * populated the following initialisation.
43 * 45 *
44 * 1) node_online_map - the map of all nodes configured (online) in the system 46 * 1) node_online_map - the map of all nodes configured (online) in the system
45 * 2) physnode_map - the mapping between a pfn and owning node 47 * 2) node_start_pfn - the starting page frame number for a node
46 * 3) node_start_pfn - the starting page frame number for a node
47 * 3) node_end_pfn - the ending page fram number for a node 48 * 3) node_end_pfn - the ending page fram number for a node
48 */ 49 */
50unsigned long node_start_pfn[MAX_NUMNODES];
51unsigned long node_end_pfn[MAX_NUMNODES];
52
49 53
54#ifdef CONFIG_DISCONTIGMEM
50/* 55/*
56 * 4) physnode_map - the mapping between a pfn and owning node
51 * physnode_map keeps track of the physical memory layout of a generic 57 * physnode_map keeps track of the physical memory layout of a generic
52 * numa node on a 256Mb break (each element of the array will 58 * numa node on a 256Mb break (each element of the array will
53 * represent 256Mb of memory and will be marked by the node id. so, 59 * represent 256Mb of memory and will be marked by the node id. so,
@@ -59,6 +65,7 @@ bootmem_data_t node0_bdata;
59 * physnode_map[8- ] = -1; 65 * physnode_map[8- ] = -1;
60 */ 66 */
61s8 physnode_map[MAX_ELEMENTS] = { [0 ... (MAX_ELEMENTS - 1)] = -1}; 67s8 physnode_map[MAX_ELEMENTS] = { [0 ... (MAX_ELEMENTS - 1)] = -1};
68EXPORT_SYMBOL(physnode_map);
62 69
63void memory_present(int nid, unsigned long start, unsigned long end) 70void memory_present(int nid, unsigned long start, unsigned long end)
64{ 71{
@@ -85,9 +92,7 @@ unsigned long node_memmap_size_bytes(int nid, unsigned long start_pfn,
85 92
86 return (nr_pages + 1) * sizeof(struct page); 93 return (nr_pages + 1) * sizeof(struct page);
87} 94}
88 95#endif
89unsigned long node_start_pfn[MAX_NUMNODES];
90unsigned long node_end_pfn[MAX_NUMNODES];
91 96
92extern unsigned long find_max_low_pfn(void); 97extern unsigned long find_max_low_pfn(void);
93extern void find_max_pfn(void); 98extern void find_max_pfn(void);
@@ -108,6 +113,9 @@ unsigned long node_remap_offset[MAX_NUMNODES];
108void *node_remap_start_vaddr[MAX_NUMNODES]; 113void *node_remap_start_vaddr[MAX_NUMNODES];
109void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags); 114void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
110 115
116void *node_remap_end_vaddr[MAX_NUMNODES];
117void *node_remap_alloc_vaddr[MAX_NUMNODES];
118
111/* 119/*
112 * FLAT - support for basic PC memory model with discontig enabled, essentially 120 * FLAT - support for basic PC memory model with discontig enabled, essentially
113 * a single node with all available processors in it with a flat 121 * a single node with all available processors in it with a flat
@@ -146,6 +154,21 @@ static void __init find_max_pfn_node(int nid)
146 BUG(); 154 BUG();
147} 155}
148 156
157/* Find the owning node for a pfn. */
158int early_pfn_to_nid(unsigned long pfn)
159{
160 int nid;
161
162 for_each_node(nid) {
163 if (node_end_pfn[nid] == 0)
164 break;
165 if (node_start_pfn[nid] <= pfn && node_end_pfn[nid] >= pfn)
166 return nid;
167 }
168
169 return 0;
170}
171
149/* 172/*
150 * Allocate memory for the pg_data_t for this node via a crude pre-bootmem 173 * Allocate memory for the pg_data_t for this node via a crude pre-bootmem
151 * method. For node zero take this from the bottom of memory, for 174 * method. For node zero take this from the bottom of memory, for
@@ -163,6 +186,21 @@ static void __init allocate_pgdat(int nid)
163 } 186 }
164} 187}
165 188
189void *alloc_remap(int nid, unsigned long size)
190{
191 void *allocation = node_remap_alloc_vaddr[nid];
192
193 size = ALIGN(size, L1_CACHE_BYTES);
194
195 if (!allocation || (allocation + size) >= node_remap_end_vaddr[nid])
196 return 0;
197
198 node_remap_alloc_vaddr[nid] += size;
199 memset(allocation, 0, size);
200
201 return allocation;
202}
203
166void __init remap_numa_kva(void) 204void __init remap_numa_kva(void)
167{ 205{
168 void *vaddr; 206 void *vaddr;
@@ -170,8 +208,6 @@ void __init remap_numa_kva(void)
170 int node; 208 int node;
171 209
172 for_each_online_node(node) { 210 for_each_online_node(node) {
173 if (node == 0)
174 continue;
175 for (pfn=0; pfn < node_remap_size[node]; pfn += PTRS_PER_PTE) { 211 for (pfn=0; pfn < node_remap_size[node]; pfn += PTRS_PER_PTE) {
176 vaddr = node_remap_start_vaddr[node]+(pfn<<PAGE_SHIFT); 212 vaddr = node_remap_start_vaddr[node]+(pfn<<PAGE_SHIFT);
177 set_pmd_pfn((ulong) vaddr, 213 set_pmd_pfn((ulong) vaddr,
@@ -185,13 +221,9 @@ static unsigned long calculate_numa_remap_pages(void)
185{ 221{
186 int nid; 222 int nid;
187 unsigned long size, reserve_pages = 0; 223 unsigned long size, reserve_pages = 0;
224 unsigned long pfn;
188 225
189 for_each_online_node(nid) { 226 for_each_online_node(nid) {
190 if (nid == 0)
191 continue;
192 if (!node_remap_size[nid])
193 continue;
194
195 /* 227 /*
196 * The acpi/srat node info can show hot-add memroy zones 228 * The acpi/srat node info can show hot-add memroy zones
197 * where memory could be added but not currently present. 229 * where memory could be added but not currently present.
@@ -208,11 +240,24 @@ static unsigned long calculate_numa_remap_pages(void)
208 size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES; 240 size = (size + LARGE_PAGE_BYTES - 1) / LARGE_PAGE_BYTES;
209 /* now the roundup is correct, convert to PAGE_SIZE pages */ 241 /* now the roundup is correct, convert to PAGE_SIZE pages */
210 size = size * PTRS_PER_PTE; 242 size = size * PTRS_PER_PTE;
243
244 /*
245 * Validate the region we are allocating only contains valid
246 * pages.
247 */
248 for (pfn = node_end_pfn[nid] - size;
249 pfn < node_end_pfn[nid]; pfn++)
250 if (!page_is_ram(pfn))
251 break;
252
253 if (pfn != node_end_pfn[nid])
254 size = 0;
255
211 printk("Reserving %ld pages of KVA for lmem_map of node %d\n", 256 printk("Reserving %ld pages of KVA for lmem_map of node %d\n",
212 size, nid); 257 size, nid);
213 node_remap_size[nid] = size; 258 node_remap_size[nid] = size;
214 reserve_pages += size;
215 node_remap_offset[nid] = reserve_pages; 259 node_remap_offset[nid] = reserve_pages;
260 reserve_pages += size;
216 printk("Shrinking node %d from %ld pages to %ld pages\n", 261 printk("Shrinking node %d from %ld pages to %ld pages\n",
217 nid, node_end_pfn[nid], node_end_pfn[nid] - size); 262 nid, node_end_pfn[nid], node_end_pfn[nid] - size);
218 node_end_pfn[nid] -= size; 263 node_end_pfn[nid] -= size;
@@ -265,12 +310,18 @@ unsigned long __init setup_memory(void)
265 (ulong) pfn_to_kaddr(max_low_pfn)); 310 (ulong) pfn_to_kaddr(max_low_pfn));
266 for_each_online_node(nid) { 311 for_each_online_node(nid) {
267 node_remap_start_vaddr[nid] = pfn_to_kaddr( 312 node_remap_start_vaddr[nid] = pfn_to_kaddr(
268 (highstart_pfn + reserve_pages) - node_remap_offset[nid]); 313 highstart_pfn + node_remap_offset[nid]);
314 /* Init the node remap allocator */
315 node_remap_end_vaddr[nid] = node_remap_start_vaddr[nid] +
316 (node_remap_size[nid] * PAGE_SIZE);
317 node_remap_alloc_vaddr[nid] = node_remap_start_vaddr[nid] +
318 ALIGN(sizeof(pg_data_t), PAGE_SIZE);
319
269 allocate_pgdat(nid); 320 allocate_pgdat(nid);
270 printk ("node %d will remap to vaddr %08lx - %08lx\n", nid, 321 printk ("node %d will remap to vaddr %08lx - %08lx\n", nid,
271 (ulong) node_remap_start_vaddr[nid], 322 (ulong) node_remap_start_vaddr[nid],
272 (ulong) pfn_to_kaddr(highstart_pfn + reserve_pages 323 (ulong) pfn_to_kaddr(highstart_pfn
273 - node_remap_offset[nid] + node_remap_size[nid])); 324 + node_remap_offset[nid] + node_remap_size[nid]));
274 } 325 }
275 printk("High memory starts at vaddr %08lx\n", 326 printk("High memory starts at vaddr %08lx\n",
276 (ulong) pfn_to_kaddr(highstart_pfn)); 327 (ulong) pfn_to_kaddr(highstart_pfn));
@@ -333,23 +384,9 @@ void __init zone_sizes_init(void)
333 } 384 }
334 385
335 zholes_size = get_zholes_size(nid); 386 zholes_size = get_zholes_size(nid);
336 /* 387
337 * We let the lmem_map for node 0 be allocated from the 388 free_area_init_node(nid, NODE_DATA(nid), zones_size, start,
338 * normal bootmem allocator, but other nodes come from the 389 zholes_size);
339 * remapped KVA area - mbligh
340 */
341 if (!nid)
342 free_area_init_node(nid, NODE_DATA(nid),
343 zones_size, start, zholes_size);
344 else {
345 unsigned long lmem_map;
346 lmem_map = (unsigned long)node_remap_start_vaddr[nid];
347 lmem_map += sizeof(pg_data_t) + PAGE_SIZE - 1;
348 lmem_map &= PAGE_MASK;
349 NODE_DATA(nid)->node_mem_map = (struct page *)lmem_map;
350 free_area_init_node(nid, NODE_DATA(nid), zones_size,
351 start, zholes_size);
352 }
353 } 390 }
354 return; 391 return;
355} 392}
@@ -358,24 +395,26 @@ void __init set_highmem_pages_init(int bad_ppro)
358{ 395{
359#ifdef CONFIG_HIGHMEM 396#ifdef CONFIG_HIGHMEM
360 struct zone *zone; 397 struct zone *zone;
398 struct page *page;
361 399
362 for_each_zone(zone) { 400 for_each_zone(zone) {
363 unsigned long node_pfn, node_high_size, zone_start_pfn; 401 unsigned long node_pfn, zone_start_pfn, zone_end_pfn;
364 struct page * zone_mem_map; 402
365
366 if (!is_highmem(zone)) 403 if (!is_highmem(zone))
367 continue; 404 continue;
368 405
369 printk("Initializing %s for node %d\n", zone->name,
370 zone->zone_pgdat->node_id);
371
372 node_high_size = zone->spanned_pages;
373 zone_mem_map = zone->zone_mem_map;
374 zone_start_pfn = zone->zone_start_pfn; 406 zone_start_pfn = zone->zone_start_pfn;
407 zone_end_pfn = zone_start_pfn + zone->spanned_pages;
408
409 printk("Initializing %s for node %d (%08lx:%08lx)\n",
410 zone->name, zone->zone_pgdat->node_id,
411 zone_start_pfn, zone_end_pfn);
375 412
376 for (node_pfn = 0; node_pfn < node_high_size; node_pfn++) { 413 for (node_pfn = zone_start_pfn; node_pfn < zone_end_pfn; node_pfn++) {
377 one_highpage_init((struct page *)(zone_mem_map + node_pfn), 414 if (!pfn_valid(node_pfn))
378 zone_start_pfn + node_pfn, bad_ppro); 415 continue;
416 page = pfn_to_page(node_pfn);
417 one_highpage_init(page, node_pfn, bad_ppro);
379 } 418 }
380 } 419 }
381 totalram_pages += totalhigh_pages; 420 totalram_pages += totalhigh_pages;
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c
index fc4c4cad4e98..4b7aaf99d7ea 100644
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -1,4 +1,5 @@
1#include <linux/highmem.h> 1#include <linux/highmem.h>
2#include <linux/module.h>
2 3
3void *kmap(struct page *page) 4void *kmap(struct page *page)
4{ 5{
@@ -87,3 +88,8 @@ struct page *kmap_atomic_to_page(void *ptr)
87 return pte_page(*pte); 88 return pte_page(*pte);
88} 89}
89 90
91EXPORT_SYMBOL(kmap);
92EXPORT_SYMBOL(kunmap);
93EXPORT_SYMBOL(kmap_atomic);
94EXPORT_SYMBOL(kunmap_atomic);
95EXPORT_SYMBOL(kmap_atomic_to_page);
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 8766c771bb45..3672e2ef51ae 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -191,7 +191,7 @@ static inline int page_kills_ppro(unsigned long pagenr)
191 191
192extern int is_available_memory(efi_memory_desc_t *); 192extern int is_available_memory(efi_memory_desc_t *);
193 193
194static inline int page_is_ram(unsigned long pagenr) 194int page_is_ram(unsigned long pagenr)
195{ 195{
196 int i; 196 int i;
197 unsigned long addr, end; 197 unsigned long addr, end;
@@ -276,7 +276,9 @@ void __init one_highpage_init(struct page *page, int pfn, int bad_ppro)
276 SetPageReserved(page); 276 SetPageReserved(page);
277} 277}
278 278
279#ifndef CONFIG_DISCONTIGMEM 279#ifdef CONFIG_NUMA
280extern void set_highmem_pages_init(int);
281#else
280static void __init set_highmem_pages_init(int bad_ppro) 282static void __init set_highmem_pages_init(int bad_ppro)
281{ 283{
282 int pfn; 284 int pfn;
@@ -284,9 +286,7 @@ static void __init set_highmem_pages_init(int bad_ppro)
284 one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro); 286 one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro);
285 totalram_pages += totalhigh_pages; 287 totalram_pages += totalhigh_pages;
286} 288}
287#else 289#endif /* CONFIG_FLATMEM */
288extern void set_highmem_pages_init(int);
289#endif /* !CONFIG_DISCONTIGMEM */
290 290
291#else 291#else
292#define kmap_init() do { } while (0) 292#define kmap_init() do { } while (0)
@@ -295,12 +295,13 @@ extern void set_highmem_pages_init(int);
295#endif /* CONFIG_HIGHMEM */ 295#endif /* CONFIG_HIGHMEM */
296 296
297unsigned long long __PAGE_KERNEL = _PAGE_KERNEL; 297unsigned long long __PAGE_KERNEL = _PAGE_KERNEL;
298EXPORT_SYMBOL(__PAGE_KERNEL);
298unsigned long long __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC; 299unsigned long long __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC;
299 300
300#ifndef CONFIG_DISCONTIGMEM 301#ifdef CONFIG_NUMA
301#define remap_numa_kva() do {} while (0)
302#else
303extern void __init remap_numa_kva(void); 302extern void __init remap_numa_kva(void);
303#else
304#define remap_numa_kva() do {} while (0)
304#endif 305#endif
305 306
306static void __init pagetable_init (void) 307static void __init pagetable_init (void)
@@ -525,7 +526,7 @@ static void __init set_max_mapnr_init(void)
525#else 526#else
526 num_physpages = max_low_pfn; 527 num_physpages = max_low_pfn;
527#endif 528#endif
528#ifndef CONFIG_DISCONTIGMEM 529#ifdef CONFIG_FLATMEM
529 max_mapnr = num_physpages; 530 max_mapnr = num_physpages;
530#endif 531#endif
531} 532}
@@ -539,7 +540,7 @@ void __init mem_init(void)
539 int tmp; 540 int tmp;
540 int bad_ppro; 541 int bad_ppro;
541 542
542#ifndef CONFIG_DISCONTIGMEM 543#ifdef CONFIG_FLATMEM
543 if (!mem_map) 544 if (!mem_map)
544 BUG(); 545 BUG();
545#endif 546#endif
diff --git a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c
index ab542792b27b..d393eefc7052 100644
--- a/arch/i386/mm/ioremap.c
+++ b/arch/i386/mm/ioremap.c
@@ -11,6 +11,7 @@
11#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/module.h>
14#include <asm/io.h> 15#include <asm/io.h>
15#include <asm/fixmap.h> 16#include <asm/fixmap.h>
16#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
@@ -165,7 +166,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
165 } 166 }
166 return (void __iomem *) (offset + (char __iomem *)addr); 167 return (void __iomem *) (offset + (char __iomem *)addr);
167} 168}
168 169EXPORT_SYMBOL(__ioremap);
169 170
170/** 171/**
171 * ioremap_nocache - map bus memory into CPU space 172 * ioremap_nocache - map bus memory into CPU space
@@ -222,6 +223,7 @@ void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
222 223
223 return p; 224 return p;
224} 225}
226EXPORT_SYMBOL(ioremap_nocache);
225 227
226void iounmap(volatile void __iomem *addr) 228void iounmap(volatile void __iomem *addr)
227{ 229{
@@ -255,6 +257,7 @@ out_unlock:
255 write_unlock(&vmlist_lock); 257 write_unlock(&vmlist_lock);
256 kfree(p); 258 kfree(p);
257} 259}
260EXPORT_SYMBOL(iounmap);
258 261
259void __init *bt_ioremap(unsigned long phys_addr, unsigned long size) 262void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
260{ 263{
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index dd81479ff88a..270c59f099a4 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -30,13 +30,14 @@ void show_mem(void)
30 struct page *page; 30 struct page *page;
31 pg_data_t *pgdat; 31 pg_data_t *pgdat;
32 unsigned long i; 32 unsigned long i;
33 struct page_state ps;
33 34
34 printk("Mem-info:\n"); 35 printk("Mem-info:\n");
35 show_free_areas(); 36 show_free_areas();
36 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 37 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
37 for_each_pgdat(pgdat) { 38 for_each_pgdat(pgdat) {
38 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 39 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
39 page = pgdat->node_mem_map + i; 40 page = pgdat_page_nr(pgdat, i);
40 total++; 41 total++;
41 if (PageHighMem(page)) 42 if (PageHighMem(page))
42 highmem++; 43 highmem++;
@@ -53,6 +54,13 @@ void show_mem(void)
53 printk("%d reserved pages\n",reserved); 54 printk("%d reserved pages\n",reserved);
54 printk("%d pages shared\n",shared); 55 printk("%d pages shared\n",shared);
55 printk("%d pages swap cached\n",cached); 56 printk("%d pages swap cached\n",cached);
57
58 get_page_state(&ps);
59 printk("%lu pages dirty\n", ps.nr_dirty);
60 printk("%lu pages writeback\n", ps.nr_writeback);
61 printk("%lu pages mapped\n", ps.nr_mapped);
62 printk("%lu pages slab\n", ps.nr_slab);
63 printk("%lu pages pagetables\n", ps.nr_page_table_pages);
56} 64}
57 65
58/* 66/*
diff --git a/arch/i386/oprofile/backtrace.c b/arch/i386/oprofile/backtrace.c
index 52d72e074f7f..65dfd2edb671 100644
--- a/arch/i386/oprofile/backtrace.c
+++ b/arch/i386/oprofile/backtrace.c
@@ -91,7 +91,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
91 head = (struct frame_head *)regs->ebp; 91 head = (struct frame_head *)regs->ebp;
92#endif 92#endif
93 93
94 if (!user_mode(regs)) { 94 if (!user_mode_vm(regs)) {
95 while (depth-- && valid_kernel_stack(head, regs)) 95 while (depth-- && valid_kernel_stack(head, regs))
96 head = dump_backtrace(head); 96 head = dump_backtrace(head);
97 return; 97 return;
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index da21b1d07c15..83458f81e661 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -227,6 +227,24 @@ static int pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, i
227} 227}
228 228
229/* 229/*
230 * The VIA pirq rules are nibble-based, like ALI,
231 * but without the ugly irq number munging.
232 * However, for 82C586, nibble map is different .
233 */
234static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
235{
236 static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
237 return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
238}
239
240static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
241{
242 static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
243 write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
244 return 1;
245}
246
247/*
230 * ITE 8330G pirq rules are nibble-based 248 * ITE 8330G pirq rules are nibble-based
231 * FIXME: pirqmap may be { 1, 0, 3, 2 }, 249 * FIXME: pirqmap may be { 1, 0, 3, 2 },
232 * 2+3 are both mapped to irq 9 on my system 250 * 2+3 are both mapped to irq 9 on my system
@@ -512,6 +530,10 @@ static __init int via_router_probe(struct irq_router *r, struct pci_dev *router,
512 switch(device) 530 switch(device)
513 { 531 {
514 case PCI_DEVICE_ID_VIA_82C586_0: 532 case PCI_DEVICE_ID_VIA_82C586_0:
533 r->name = "VIA";
534 r->get = pirq_via586_get;
535 r->set = pirq_via586_set;
536 return 1;
515 case PCI_DEVICE_ID_VIA_82C596: 537 case PCI_DEVICE_ID_VIA_82C596:
516 case PCI_DEVICE_ID_VIA_82C686: 538 case PCI_DEVICE_ID_VIA_82C686:
517 case PCI_DEVICE_ID_VIA_8231: 539 case PCI_DEVICE_ID_VIA_8231:
diff --git a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c
index 141421b673b0..b9d65f0bc2d1 100644
--- a/arch/i386/pci/pcbios.c
+++ b/arch/i386/pci/pcbios.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/module.h>
7#include "pci.h" 8#include "pci.h"
8#include "pci-functions.h" 9#include "pci-functions.h"
9 10
@@ -456,7 +457,7 @@ struct irq_routing_table * __devinit pcibios_get_irq_routing_table(void)
456 free_page(page); 457 free_page(page);
457 return rt; 458 return rt;
458} 459}
459 460EXPORT_SYMBOL(pcibios_get_irq_routing_table);
460 461
461int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq) 462int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
462{ 463{
@@ -473,6 +474,7 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
473 "S" (&pci_indirect)); 474 "S" (&pci_indirect));
474 return !(ret & 0xff00); 475 return !(ret & 0xff00);
475} 476}
477EXPORT_SYMBOL(pcibios_set_irq_routing);
476 478
477static int __init pci_pcbios_init(void) 479static int __init pci_pcbios_init(void)
478{ 480{
diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
index cf337c673d92..6f521cf19a13 100644
--- a/arch/i386/power/cpu.c
+++ b/arch/i386/power/cpu.c
@@ -94,13 +94,13 @@ static void fix_processor_context(void)
94 * Now maybe reload the debug registers 94 * Now maybe reload the debug registers
95 */ 95 */
96 if (current->thread.debugreg[7]){ 96 if (current->thread.debugreg[7]){
97 loaddebug(&current->thread, 0); 97 set_debugreg(current->thread.debugreg[0], 0);
98 loaddebug(&current->thread, 1); 98 set_debugreg(current->thread.debugreg[1], 1);
99 loaddebug(&current->thread, 2); 99 set_debugreg(current->thread.debugreg[2], 2);
100 loaddebug(&current->thread, 3); 100 set_debugreg(current->thread.debugreg[3], 3);
101 /* no 4 and 5 */ 101 /* no 4 and 5 */
102 loaddebug(&current->thread, 6); 102 set_debugreg(current->thread.debugreg[6], 6);
103 loaddebug(&current->thread, 7); 103 set_debugreg(current->thread.debugreg[7], 7);
104 } 104 }
105 105
106} 106}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index ce4dfa8b834d..01b78e7f992e 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -161,6 +161,8 @@ config IA64_PAGE_SIZE_64KB
161 161
162endchoice 162endchoice
163 163
164source kernel/Kconfig.hz
165
164config IA64_BRL_EMU 166config IA64_BRL_EMU
165 bool 167 bool
166 depends on ITANIUM 168 depends on ITANIUM
@@ -197,7 +199,7 @@ config HOLES_IN_ZONE
197 bool 199 bool
198 default y if VIRTUAL_MEM_MAP 200 default y if VIRTUAL_MEM_MAP
199 201
200config DISCONTIGMEM 202config ARCH_DISCONTIGMEM_ENABLE
201 bool "Discontiguous memory support" 203 bool "Discontiguous memory support"
202 depends on (IA64_DIG || IA64_SGI_SN2 || IA64_GENERIC || IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB) && NUMA && VIRTUAL_MEM_MAP 204 depends on (IA64_DIG || IA64_SGI_SN2 || IA64_GENERIC || IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB) && NUMA && VIRTUAL_MEM_MAP
203 default y if (IA64_SGI_SN2 || IA64_GENERIC) && NUMA 205 default y if (IA64_SGI_SN2 || IA64_GENERIC) && NUMA
@@ -300,6 +302,8 @@ config PREEMPT
300 Say Y here if you are building a kernel for a desktop, embedded 302 Say Y here if you are building a kernel for a desktop, embedded
301 or real-time system. Say N if you are unsure. 303 or real-time system. Say N if you are unsure.
302 304
305source "mm/Kconfig"
306
303config HAVE_DEC_LOCK 307config HAVE_DEC_LOCK
304 bool 308 bool
305 depends on (SMP || PREEMPT) 309 depends on (SMP || PREEMPT)
diff --git a/arch/ia64/Kconfig.debug b/arch/ia64/Kconfig.debug
index de9d507ba0fd..fda67ac993d7 100644
--- a/arch/ia64/Kconfig.debug
+++ b/arch/ia64/Kconfig.debug
@@ -2,6 +2,17 @@ menu "Kernel hacking"
2 2
3source "lib/Kconfig.debug" 3source "lib/Kconfig.debug"
4 4
5config KPROBES
6 bool "Kprobes"
7 depends on DEBUG_KERNEL
8 help
9 Kprobes allows you to trap at almost any kernel address and
10 execute a callback function. register_kprobe() establishes
11 a probepoint and specifies the callback. Kprobes is useful
12 for kernel debugging, non-intrusive instrumentation and testing.
13 If in doubt, say "N".
14
15
5choice 16choice
6 prompt "Physical memory granularity" 17 prompt "Physical memory granularity"
7 default IA64_GRANULE_64MB 18 default IA64_GRANULE_64MB
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index a01bb02d074d..487d2e36b0a6 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -78,7 +78,7 @@ CONFIG_IA64_L1_CACHE_SHIFT=7
78CONFIG_NUMA=y 78CONFIG_NUMA=y
79CONFIG_VIRTUAL_MEM_MAP=y 79CONFIG_VIRTUAL_MEM_MAP=y
80CONFIG_HOLES_IN_ZONE=y 80CONFIG_HOLES_IN_ZONE=y
81CONFIG_DISCONTIGMEM=y 81CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
82# CONFIG_IA64_CYCLONE is not set 82# CONFIG_IA64_CYCLONE is not set
83CONFIG_IOSAPIC=y 83CONFIG_IOSAPIC=y
84CONFIG_IA64_SGI_SN_SIM=y 84CONFIG_IA64_SGI_SN_SIM=y
diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig
index 7be8096e0561..8444add76380 100644
--- a/arch/ia64/defconfig
+++ b/arch/ia64/defconfig
@@ -84,7 +84,7 @@ CONFIG_IA64_L1_CACHE_SHIFT=7
84CONFIG_NUMA=y 84CONFIG_NUMA=y
85CONFIG_VIRTUAL_MEM_MAP=y 85CONFIG_VIRTUAL_MEM_MAP=y
86CONFIG_HOLES_IN_ZONE=y 86CONFIG_HOLES_IN_ZONE=y
87CONFIG_DISCONTIGMEM=y 87CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
88CONFIG_IA64_CYCLONE=y 88CONFIG_IA64_CYCLONE=y
89CONFIG_IOSAPIC=y 89CONFIG_IOSAPIC=y
90CONFIG_FORCE_MAX_ZONEORDER=18 90CONFIG_FORCE_MAX_ZONEORDER=18
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index b2de948bdaea..e3e9290e3ff2 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -241,7 +241,7 @@ typedef struct compat_siginfo {
241 241
242 /* POSIX.1b timers */ 242 /* POSIX.1b timers */
243 struct { 243 struct {
244 timer_t _tid; /* timer id */ 244 compat_timer_t _tid; /* timer id */
245 int _overrun; /* overrun count */ 245 int _overrun; /* overrun count */
246 char _pad[sizeof(unsigned int) - sizeof(int)]; 246 char _pad[sizeof(unsigned int) - sizeof(int)];
247 compat_sigval_t _sigval; /* same as below */ 247 compat_sigval_t _sigval; /* same as below */
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index 4c73d8ba2e3d..b2e2f6509eb0 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o domain.o
20obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o 20obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o
21obj-$(CONFIG_IA64_CYCLONE) += cyclone.o 21obj-$(CONFIG_IA64_CYCLONE) += cyclone.o
22obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o 22obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o
23obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o
23obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o 24obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
24mca_recovery-y += mca_drv.o mca_drv_asm.o 25mca_recovery-y += mca_drv.o mca_drv_asm.o
25 26
diff --git a/arch/ia64/kernel/jprobes.S b/arch/ia64/kernel/jprobes.S
new file mode 100644
index 000000000000..b7fa3ccd2b0f
--- /dev/null
+++ b/arch/ia64/kernel/jprobes.S
@@ -0,0 +1,61 @@
1/*
2 * Jprobe specific operations
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) Intel Corporation, 2005
19 *
20 * 2005-May Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy
21 * <anil.s.keshavamurthy@intel.com> initial implementation
22 *
23 * Jprobes (a.k.a. "jump probes" which is built on-top of kprobes) allow a
24 * probe to be inserted into the beginning of a function call. The fundamental
25 * difference between a jprobe and a kprobe is the jprobe handler is executed
26 * in the same context as the target function, while the kprobe handlers
27 * are executed in interrupt context.
28 *
29 * For jprobes we initially gain control by placing a break point in the
30 * first instruction of the targeted function. When we catch that specific
31 * break, we:
32 * * set the return address to our jprobe_inst_return() function
33 * * jump to the jprobe handler function
34 *
35 * Since we fixed up the return address, the jprobe handler will return to our
36 * jprobe_inst_return() function, giving us control again. At this point we
37 * are back in the parents frame marker, so we do yet another call to our
38 * jprobe_break() function to fix up the frame marker as it would normally
39 * exist in the target function.
40 *
41 * Our jprobe_return function then transfers control back to kprobes.c by
42 * executing a break instruction using one of our reserved numbers. When we
43 * catch that break in kprobes.c, we continue like we do for a normal kprobe
44 * by single stepping the emulated instruction, and then returning execution
45 * to the correct location.
46 */
47#include <asm/asmmacro.h>
48
49 /*
50 * void jprobe_break(void)
51 */
52ENTRY(jprobe_break)
53 break.m 0x80300
54END(jprobe_break)
55
56 /*
57 * void jprobe_inst_return(void)
58 */
59GLOBAL_ENTRY(jprobe_inst_return)
60 br.call.sptk.many b0=jprobe_break
61END(jprobe_inst_return)
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
new file mode 100644
index 000000000000..5978823d5c63
--- /dev/null
+++ b/arch/ia64/kernel/kprobes.c
@@ -0,0 +1,601 @@
1/*
2 * Kernel Probes (KProbes)
3 * arch/ia64/kernel/kprobes.c
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * Copyright (C) IBM Corporation, 2002, 2004
20 * Copyright (C) Intel Corporation, 2005
21 *
22 * 2005-Apr Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy
23 * <anil.s.keshavamurthy@intel.com> adapted from i386
24 */
25
26#include <linux/config.h>
27#include <linux/kprobes.h>
28#include <linux/ptrace.h>
29#include <linux/spinlock.h>
30#include <linux/string.h>
31#include <linux/slab.h>
32#include <linux/preempt.h>
33#include <linux/moduleloader.h>
34
35#include <asm/pgtable.h>
36#include <asm/kdebug.h>
37
38extern void jprobe_inst_return(void);
39
40/* kprobe_status settings */
41#define KPROBE_HIT_ACTIVE 0x00000001
42#define KPROBE_HIT_SS 0x00000002
43
44static struct kprobe *current_kprobe, *kprobe_prev;
45static unsigned long kprobe_status, kprobe_status_prev;
46static struct pt_regs jprobe_saved_regs;
47
48enum instruction_type {A, I, M, F, B, L, X, u};
49static enum instruction_type bundle_encoding[32][3] = {
50 { M, I, I }, /* 00 */
51 { M, I, I }, /* 01 */
52 { M, I, I }, /* 02 */
53 { M, I, I }, /* 03 */
54 { M, L, X }, /* 04 */
55 { M, L, X }, /* 05 */
56 { u, u, u }, /* 06 */
57 { u, u, u }, /* 07 */
58 { M, M, I }, /* 08 */
59 { M, M, I }, /* 09 */
60 { M, M, I }, /* 0A */
61 { M, M, I }, /* 0B */
62 { M, F, I }, /* 0C */
63 { M, F, I }, /* 0D */
64 { M, M, F }, /* 0E */
65 { M, M, F }, /* 0F */
66 { M, I, B }, /* 10 */
67 { M, I, B }, /* 11 */
68 { M, B, B }, /* 12 */
69 { M, B, B }, /* 13 */
70 { u, u, u }, /* 14 */
71 { u, u, u }, /* 15 */
72 { B, B, B }, /* 16 */
73 { B, B, B }, /* 17 */
74 { M, M, B }, /* 18 */
75 { M, M, B }, /* 19 */
76 { u, u, u }, /* 1A */
77 { u, u, u }, /* 1B */
78 { M, F, B }, /* 1C */
79 { M, F, B }, /* 1D */
80 { u, u, u }, /* 1E */
81 { u, u, u }, /* 1F */
82};
83
84/*
85 * In this function we check to see if the instruction
86 * is IP relative instruction and update the kprobe
87 * inst flag accordingly
88 */
89static void update_kprobe_inst_flag(uint template, uint slot, uint major_opcode,
90 unsigned long kprobe_inst, struct kprobe *p)
91{
92 p->ainsn.inst_flag = 0;
93 p->ainsn.target_br_reg = 0;
94
95 if (bundle_encoding[template][slot] == B) {
96 switch (major_opcode) {
97 case INDIRECT_CALL_OPCODE:
98 p->ainsn.inst_flag |= INST_FLAG_FIX_BRANCH_REG;
99 p->ainsn.target_br_reg = ((kprobe_inst >> 6) & 0x7);
100 break;
101 case IP_RELATIVE_PREDICT_OPCODE:
102 case IP_RELATIVE_BRANCH_OPCODE:
103 p->ainsn.inst_flag |= INST_FLAG_FIX_RELATIVE_IP_ADDR;
104 break;
105 case IP_RELATIVE_CALL_OPCODE:
106 p->ainsn.inst_flag |= INST_FLAG_FIX_RELATIVE_IP_ADDR;
107 p->ainsn.inst_flag |= INST_FLAG_FIX_BRANCH_REG;
108 p->ainsn.target_br_reg = ((kprobe_inst >> 6) & 0x7);
109 break;
110 }
111 } else if (bundle_encoding[template][slot] == X) {
112 switch (major_opcode) {
113 case LONG_CALL_OPCODE:
114 p->ainsn.inst_flag |= INST_FLAG_FIX_BRANCH_REG;
115 p->ainsn.target_br_reg = ((kprobe_inst >> 6) & 0x7);
116 break;
117 }
118 }
119 return;
120}
121
122/*
123 * In this function we check to see if the instruction
124 * on which we are inserting kprobe is supported.
125 * Returns 0 if supported
126 * Returns -EINVAL if unsupported
127 */
128static int unsupported_inst(uint template, uint slot, uint major_opcode,
129 unsigned long kprobe_inst, struct kprobe *p)
130{
131 unsigned long addr = (unsigned long)p->addr;
132
133 if (bundle_encoding[template][slot] == I) {
134 switch (major_opcode) {
135 case 0x0: //I_UNIT_MISC_OPCODE:
136 /*
137 * Check for Integer speculation instruction
138 * - Bit 33-35 to be equal to 0x1
139 */
140 if (((kprobe_inst >> 33) & 0x7) == 1) {
141 printk(KERN_WARNING
142 "Kprobes on speculation inst at <0x%lx> not supported\n",
143 addr);
144 return -EINVAL;
145 }
146
147 /*
148 * IP relative mov instruction
149 * - Bit 27-35 to be equal to 0x30
150 */
151 if (((kprobe_inst >> 27) & 0x1FF) == 0x30) {
152 printk(KERN_WARNING
153 "Kprobes on \"mov r1=ip\" at <0x%lx> not supported\n",
154 addr);
155 return -EINVAL;
156
157 }
158 }
159 }
160 return 0;
161}
162
163
164/*
165 * In this function we check to see if the instruction
166 * (qp) cmpx.crel.ctype p1,p2=r2,r3
167 * on which we are inserting kprobe is cmp instruction
168 * with ctype as unc.
169 */
170static uint is_cmp_ctype_unc_inst(uint template, uint slot, uint major_opcode,
171unsigned long kprobe_inst)
172{
173 cmp_inst_t cmp_inst;
174 uint ctype_unc = 0;
175
176 if (!((bundle_encoding[template][slot] == I) ||
177 (bundle_encoding[template][slot] == M)))
178 goto out;
179
180 if (!((major_opcode == 0xC) || (major_opcode == 0xD) ||
181 (major_opcode == 0xE)))
182 goto out;
183
184 cmp_inst.l = kprobe_inst;
185 if ((cmp_inst.f.x2 == 0) || (cmp_inst.f.x2 == 1)) {
186 /* Integere compare - Register Register (A6 type)*/
187 if ((cmp_inst.f.tb == 0) && (cmp_inst.f.ta == 0)
188 &&(cmp_inst.f.c == 1))
189 ctype_unc = 1;
190 } else if ((cmp_inst.f.x2 == 2)||(cmp_inst.f.x2 == 3)) {
191 /* Integere compare - Immediate Register (A8 type)*/
192 if ((cmp_inst.f.ta == 0) &&(cmp_inst.f.c == 1))
193 ctype_unc = 1;
194 }
195out:
196 return ctype_unc;
197}
198
199/*
200 * In this function we override the bundle with
201 * the break instruction at the given slot.
202 */
203static void prepare_break_inst(uint template, uint slot, uint major_opcode,
204 unsigned long kprobe_inst, struct kprobe *p)
205{
206 unsigned long break_inst = BREAK_INST;
207 bundle_t *bundle = &p->ainsn.insn.bundle;
208
209 /*
210 * Copy the original kprobe_inst qualifying predicate(qp)
211 * to the break instruction iff !is_cmp_ctype_unc_inst
212 * because for cmp instruction with ctype equal to unc,
213 * which is a special instruction always needs to be
214 * executed regradless of qp
215 */
216 if (!is_cmp_ctype_unc_inst(template, slot, major_opcode, kprobe_inst))
217 break_inst |= (0x3f & kprobe_inst);
218
219 switch (slot) {
220 case 0:
221 bundle->quad0.slot0 = break_inst;
222 break;
223 case 1:
224 bundle->quad0.slot1_p0 = break_inst;
225 bundle->quad1.slot1_p1 = break_inst >> (64-46);
226 break;
227 case 2:
228 bundle->quad1.slot2 = break_inst;
229 break;
230 }
231
232 /*
233 * Update the instruction flag, so that we can
234 * emulate the instruction properly after we
235 * single step on original instruction
236 */
237 update_kprobe_inst_flag(template, slot, major_opcode, kprobe_inst, p);
238}
239
240static inline void get_kprobe_inst(bundle_t *bundle, uint slot,
241 unsigned long *kprobe_inst, uint *major_opcode)
242{
243 unsigned long kprobe_inst_p0, kprobe_inst_p1;
244 unsigned int template;
245
246 template = bundle->quad0.template;
247
248 switch (slot) {
249 case 0:
250 *major_opcode = (bundle->quad0.slot0 >> SLOT0_OPCODE_SHIFT);
251 *kprobe_inst = bundle->quad0.slot0;
252 break;
253 case 1:
254 *major_opcode = (bundle->quad1.slot1_p1 >> SLOT1_p1_OPCODE_SHIFT);
255 kprobe_inst_p0 = bundle->quad0.slot1_p0;
256 kprobe_inst_p1 = bundle->quad1.slot1_p1;
257 *kprobe_inst = kprobe_inst_p0 | (kprobe_inst_p1 << (64-46));
258 break;
259 case 2:
260 *major_opcode = (bundle->quad1.slot2 >> SLOT2_OPCODE_SHIFT);
261 *kprobe_inst = bundle->quad1.slot2;
262 break;
263 }
264}
265
266static int valid_kprobe_addr(int template, int slot, unsigned long addr)
267{
268 if ((slot > 2) || ((bundle_encoding[template][1] == L) && slot > 1)) {
269 printk(KERN_WARNING "Attempting to insert unaligned kprobe at 0x%lx\n",
270 addr);
271 return -EINVAL;
272 }
273 return 0;
274}
275
276static inline void save_previous_kprobe(void)
277{
278 kprobe_prev = current_kprobe;
279 kprobe_status_prev = kprobe_status;
280}
281
282static inline void restore_previous_kprobe(void)
283{
284 current_kprobe = kprobe_prev;
285 kprobe_status = kprobe_status_prev;
286}
287
288static inline void set_current_kprobe(struct kprobe *p)
289{
290 current_kprobe = p;
291}
292
293int arch_prepare_kprobe(struct kprobe *p)
294{
295 unsigned long addr = (unsigned long) p->addr;
296 unsigned long *kprobe_addr = (unsigned long *)(addr & ~0xFULL);
297 unsigned long kprobe_inst=0;
298 unsigned int slot = addr & 0xf, template, major_opcode = 0;
299 bundle_t *bundle = &p->ainsn.insn.bundle;
300
301 memcpy(&p->opcode.bundle, kprobe_addr, sizeof(bundle_t));
302 memcpy(&p->ainsn.insn.bundle, kprobe_addr, sizeof(bundle_t));
303
304 template = bundle->quad0.template;
305
306 if(valid_kprobe_addr(template, slot, addr))
307 return -EINVAL;
308
309 /* Move to slot 2, if bundle is MLX type and kprobe slot is 1 */
310 if (slot == 1 && bundle_encoding[template][1] == L)
311 slot++;
312
313 /* Get kprobe_inst and major_opcode from the bundle */
314 get_kprobe_inst(bundle, slot, &kprobe_inst, &major_opcode);
315
316 if (unsupported_inst(template, slot, major_opcode, kprobe_inst, p))
317 return -EINVAL;
318
319 prepare_break_inst(template, slot, major_opcode, kprobe_inst, p);
320
321 return 0;
322}
323
324void arch_arm_kprobe(struct kprobe *p)
325{
326 unsigned long addr = (unsigned long)p->addr;
327 unsigned long arm_addr = addr & ~0xFULL;
328
329 memcpy((char *)arm_addr, &p->ainsn.insn.bundle, sizeof(bundle_t));
330 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
331}
332
333void arch_disarm_kprobe(struct kprobe *p)
334{
335 unsigned long addr = (unsigned long)p->addr;
336 unsigned long arm_addr = addr & ~0xFULL;
337
338 /* p->opcode contains the original unaltered bundle */
339 memcpy((char *) arm_addr, (char *) &p->opcode.bundle, sizeof(bundle_t));
340 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
341}
342
343void arch_remove_kprobe(struct kprobe *p)
344{
345}
346
347/*
348 * We are resuming execution after a single step fault, so the pt_regs
349 * structure reflects the register state after we executed the instruction
350 * located in the kprobe (p->ainsn.insn.bundle). We still need to adjust
351 * the ip to point back to the original stack address. To set the IP address
352 * to original stack address, handle the case where we need to fixup the
353 * relative IP address and/or fixup branch register.
354 */
355static void resume_execution(struct kprobe *p, struct pt_regs *regs)
356{
357 unsigned long bundle_addr = ((unsigned long) (&p->opcode.bundle)) & ~0xFULL;
358 unsigned long resume_addr = (unsigned long)p->addr & ~0xFULL;
359 unsigned long template;
360 int slot = ((unsigned long)p->addr & 0xf);
361
362 template = p->opcode.bundle.quad0.template;
363
364 if (slot == 1 && bundle_encoding[template][1] == L)
365 slot = 2;
366
367 if (p->ainsn.inst_flag) {
368
369 if (p->ainsn.inst_flag & INST_FLAG_FIX_RELATIVE_IP_ADDR) {
370 /* Fix relative IP address */
371 regs->cr_iip = (regs->cr_iip - bundle_addr) + resume_addr;
372 }
373
374 if (p->ainsn.inst_flag & INST_FLAG_FIX_BRANCH_REG) {
375 /*
376 * Fix target branch register, software convention is
377 * to use either b0 or b6 or b7, so just checking
378 * only those registers
379 */
380 switch (p->ainsn.target_br_reg) {
381 case 0:
382 if ((regs->b0 == bundle_addr) ||
383 (regs->b0 == bundle_addr + 0x10)) {
384 regs->b0 = (regs->b0 - bundle_addr) +
385 resume_addr;
386 }
387 break;
388 case 6:
389 if ((regs->b6 == bundle_addr) ||
390 (regs->b6 == bundle_addr + 0x10)) {
391 regs->b6 = (regs->b6 - bundle_addr) +
392 resume_addr;
393 }
394 break;
395 case 7:
396 if ((regs->b7 == bundle_addr) ||
397 (regs->b7 == bundle_addr + 0x10)) {
398 regs->b7 = (regs->b7 - bundle_addr) +
399 resume_addr;
400 }
401 break;
402 } /* end switch */
403 }
404 goto turn_ss_off;
405 }
406
407 if (slot == 2) {
408 if (regs->cr_iip == bundle_addr + 0x10) {
409 regs->cr_iip = resume_addr + 0x10;
410 }
411 } else {
412 if (regs->cr_iip == bundle_addr) {
413 regs->cr_iip = resume_addr;
414 }
415 }
416
417turn_ss_off:
418 /* Turn off Single Step bit */
419 ia64_psr(regs)->ss = 0;
420}
421
422static void prepare_ss(struct kprobe *p, struct pt_regs *regs)
423{
424 unsigned long bundle_addr = (unsigned long) &p->opcode.bundle;
425 unsigned long slot = (unsigned long)p->addr & 0xf;
426
427 /* Update instruction pointer (IIP) and slot number (IPSR.ri) */
428 regs->cr_iip = bundle_addr & ~0xFULL;
429
430 if (slot > 2)
431 slot = 0;
432
433 ia64_psr(regs)->ri = slot;
434
435 /* turn on single stepping */
436 ia64_psr(regs)->ss = 1;
437}
438
439static int pre_kprobes_handler(struct die_args *args)
440{
441 struct kprobe *p;
442 int ret = 0;
443 struct pt_regs *regs = args->regs;
444 kprobe_opcode_t *addr = (kprobe_opcode_t *)instruction_pointer(regs);
445
446 preempt_disable();
447
448 /* Handle recursion cases */
449 if (kprobe_running()) {
450 p = get_kprobe(addr);
451 if (p) {
452 if (kprobe_status == KPROBE_HIT_SS) {
453 unlock_kprobes();
454 goto no_kprobe;
455 }
456 /* We have reentered the pre_kprobe_handler(), since
457 * another probe was hit while within the handler.
458 * We here save the original kprobes variables and
459 * just single step on the instruction of the new probe
460 * without calling any user handlers.
461 */
462 save_previous_kprobe();
463 set_current_kprobe(p);
464 p->nmissed++;
465 prepare_ss(p, regs);
466 kprobe_status = KPROBE_REENTER;
467 return 1;
468 } else if (args->err == __IA64_BREAK_JPROBE) {
469 /*
470 * jprobe instrumented function just completed
471 */
472 p = current_kprobe;
473 if (p->break_handler && p->break_handler(p, regs)) {
474 goto ss_probe;
475 }
476 } else {
477 /* Not our break */
478 goto no_kprobe;
479 }
480 }
481
482 lock_kprobes();
483 p = get_kprobe(addr);
484 if (!p) {
485 unlock_kprobes();
486 goto no_kprobe;
487 }
488
489 kprobe_status = KPROBE_HIT_ACTIVE;
490 set_current_kprobe(p);
491
492 if (p->pre_handler && p->pre_handler(p, regs))
493 /*
494 * Our pre-handler is specifically requesting that we just
495 * do a return. This is handling the case where the
496 * pre-handler is really our special jprobe pre-handler.
497 */
498 return 1;
499
500ss_probe:
501 prepare_ss(p, regs);
502 kprobe_status = KPROBE_HIT_SS;
503 return 1;
504
505no_kprobe:
506 preempt_enable_no_resched();
507 return ret;
508}
509
510static int post_kprobes_handler(struct pt_regs *regs)
511{
512 if (!kprobe_running())
513 return 0;
514
515 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
516 kprobe_status = KPROBE_HIT_SSDONE;
517 current_kprobe->post_handler(current_kprobe, regs, 0);
518 }
519
520 resume_execution(current_kprobe, regs);
521
522 /*Restore back the original saved kprobes variables and continue. */
523 if (kprobe_status == KPROBE_REENTER) {
524 restore_previous_kprobe();
525 goto out;
526 }
527
528 unlock_kprobes();
529
530out:
531 preempt_enable_no_resched();
532 return 1;
533}
534
535static int kprobes_fault_handler(struct pt_regs *regs, int trapnr)
536{
537 if (!kprobe_running())
538 return 0;
539
540 if (current_kprobe->fault_handler &&
541 current_kprobe->fault_handler(current_kprobe, regs, trapnr))
542 return 1;
543
544 if (kprobe_status & KPROBE_HIT_SS) {
545 resume_execution(current_kprobe, regs);
546 unlock_kprobes();
547 preempt_enable_no_resched();
548 }
549
550 return 0;
551}
552
553int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val,
554 void *data)
555{
556 struct die_args *args = (struct die_args *)data;
557 switch(val) {
558 case DIE_BREAK:
559 if (pre_kprobes_handler(args))
560 return NOTIFY_STOP;
561 break;
562 case DIE_SS:
563 if (post_kprobes_handler(args->regs))
564 return NOTIFY_STOP;
565 break;
566 case DIE_PAGE_FAULT:
567 if (kprobes_fault_handler(args->regs, args->trapnr))
568 return NOTIFY_STOP;
569 default:
570 break;
571 }
572 return NOTIFY_DONE;
573}
574
575int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
576{
577 struct jprobe *jp = container_of(p, struct jprobe, kp);
578 unsigned long addr = ((struct fnptr *)(jp->entry))->ip;
579
580 /* save architectural state */
581 jprobe_saved_regs = *regs;
582
583 /* after rfi, execute the jprobe instrumented function */
584 regs->cr_iip = addr & ~0xFULL;
585 ia64_psr(regs)->ri = addr & 0xf;
586 regs->r1 = ((struct fnptr *)(jp->entry))->gp;
587
588 /*
589 * fix the return address to our jprobe_inst_return() function
590 * in the jprobes.S file
591 */
592 regs->b0 = ((struct fnptr *)(jprobe_inst_return))->ip;
593
594 return 1;
595}
596
597int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
598{
599 *regs = jprobe_saved_regs;
600 return 1;
601}
diff --git a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c
index 1861173bd4f6..e7e520d90f03 100644
--- a/arch/ia64/kernel/traps.c
+++ b/arch/ia64/kernel/traps.c
@@ -21,12 +21,26 @@
21#include <asm/intrinsics.h> 21#include <asm/intrinsics.h>
22#include <asm/processor.h> 22#include <asm/processor.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/kdebug.h>
24 25
25extern spinlock_t timerlist_lock; 26extern spinlock_t timerlist_lock;
26 27
27fpswa_interface_t *fpswa_interface; 28fpswa_interface_t *fpswa_interface;
28EXPORT_SYMBOL(fpswa_interface); 29EXPORT_SYMBOL(fpswa_interface);
29 30
31struct notifier_block *ia64die_chain;
32static DEFINE_SPINLOCK(die_notifier_lock);
33
34int register_die_notifier(struct notifier_block *nb)
35{
36 int err = 0;
37 unsigned long flags;
38 spin_lock_irqsave(&die_notifier_lock, flags);
39 err = notifier_chain_register(&ia64die_chain, nb);
40 spin_unlock_irqrestore(&die_notifier_lock, flags);
41 return err;
42}
43
30void __init 44void __init
31trap_init (void) 45trap_init (void)
32{ 46{
@@ -137,6 +151,10 @@ ia64_bad_break (unsigned long break_num, struct pt_regs *regs)
137 151
138 switch (break_num) { 152 switch (break_num) {
139 case 0: /* unknown error (used by GCC for __builtin_abort()) */ 153 case 0: /* unknown error (used by GCC for __builtin_abort()) */
154 if (notify_die(DIE_BREAK, "break 0", regs, break_num, TRAP_BRKPT, SIGTRAP)
155 == NOTIFY_STOP) {
156 return;
157 }
140 die_if_kernel("bugcheck!", regs, break_num); 158 die_if_kernel("bugcheck!", regs, break_num);
141 sig = SIGILL; code = ILL_ILLOPC; 159 sig = SIGILL; code = ILL_ILLOPC;
142 break; 160 break;
@@ -189,6 +207,15 @@ ia64_bad_break (unsigned long break_num, struct pt_regs *regs)
189 sig = SIGILL; code = __ILL_BNDMOD; 207 sig = SIGILL; code = __ILL_BNDMOD;
190 break; 208 break;
191 209
210 case 0x80200:
211 case 0x80300:
212 if (notify_die(DIE_BREAK, "kprobe", regs, break_num, TRAP_BRKPT, SIGTRAP)
213 == NOTIFY_STOP) {
214 return;
215 }
216 sig = SIGTRAP; code = TRAP_BRKPT;
217 break;
218
192 default: 219 default:
193 if (break_num < 0x40000 || break_num > 0x100000) 220 if (break_num < 0x40000 || break_num > 0x100000)
194 die_if_kernel("Bad break", regs, break_num); 221 die_if_kernel("Bad break", regs, break_num);
@@ -548,7 +575,11 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
548#endif 575#endif
549 break; 576 break;
550 case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break; 577 case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break;
551 case 36: siginfo.si_code = TRAP_TRACE; ifa = 0; break; 578 case 36:
579 if (notify_die(DIE_SS, "ss", &regs, vector,
580 vector, SIGTRAP) == NOTIFY_STOP)
581 return;
582 siginfo.si_code = TRAP_TRACE; ifa = 0; break;
552 } 583 }
553 siginfo.si_signo = SIGTRAP; 584 siginfo.si_signo = SIGTRAP;
554 siginfo.si_errno = 0; 585 siginfo.si_errno = 0;
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index c00710929390..f3fd528ead3b 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -560,14 +560,15 @@ void show_mem(void)
560 int shared = 0, cached = 0, reserved = 0; 560 int shared = 0, cached = 0, reserved = 0;
561 printk("Node ID: %d\n", pgdat->node_id); 561 printk("Node ID: %d\n", pgdat->node_id);
562 for(i = 0; i < pgdat->node_spanned_pages; i++) { 562 for(i = 0; i < pgdat->node_spanned_pages; i++) {
563 struct page *page = pgdat_page_nr(pgdat, i);
563 if (!ia64_pfn_valid(pgdat->node_start_pfn+i)) 564 if (!ia64_pfn_valid(pgdat->node_start_pfn+i))
564 continue; 565 continue;
565 if (PageReserved(pgdat->node_mem_map+i)) 566 if (PageReserved(page))
566 reserved++; 567 reserved++;
567 else if (PageSwapCache(pgdat->node_mem_map+i)) 568 else if (PageSwapCache(page))
568 cached++; 569 cached++;
569 else if (page_count(pgdat->node_mem_map+i)) 570 else if (page_count(page))
570 shared += page_count(pgdat->node_mem_map+i)-1; 571 shared += page_count(page)-1;
571 } 572 }
572 total_present += present; 573 total_present += present;
573 total_reserved += reserved; 574 total_reserved += reserved;
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 4174ec999dde..ff62551eb3a1 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -14,6 +14,7 @@
14#include <asm/processor.h> 14#include <asm/processor.h>
15#include <asm/system.h> 15#include <asm/system.h>
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/kdebug.h>
17 18
18extern void die (char *, struct pt_regs *, long); 19extern void die (char *, struct pt_regs *, long);
19 20
@@ -102,6 +103,13 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
102 goto bad_area_no_up; 103 goto bad_area_no_up;
103#endif 104#endif
104 105
106 /*
107 * This is to handle the kprobes on user space access instructions
108 */
109 if (notify_die(DIE_PAGE_FAULT, "page fault", regs, code, TRAP_BRKPT,
110 SIGSEGV) == NOTIFY_STOP)
111 return;
112
105 down_read(&mm->mmap_sem); 113 down_read(&mm->mmap_sem);
106 114
107 vma = find_vma_prev(mm, address, &prev_vma); 115 vma = find_vma_prev(mm, address, &prev_vma);
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 64c133344afe..42ca8a39798d 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -172,11 +172,13 @@ config NOHIGHMEM
172 bool 172 bool
173 default y 173 default y
174 174
175config DISCONTIGMEM 175config ARCH_DISCONTIGMEM_ENABLE
176 bool "Internal RAM Support" 176 bool "Internal RAM Support"
177 depends on CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP 177 depends on CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP
178 default y 178 default y
179 179
180source "mm/Kconfig"
181
180config IRAM_START 182config IRAM_START
181 hex "Internal memory start address (hex)" 183 hex "Internal memory start address (hex)"
182 default "00f00000" 184 default "00f00000"
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index bc423d838fb8..d9a40b1fe8ba 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -49,7 +49,7 @@ void show_mem(void)
49 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); 49 printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
50 for_each_pgdat(pgdat) { 50 for_each_pgdat(pgdat) {
51 for (i = 0; i < pgdat->node_spanned_pages; ++i) { 51 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
52 page = pgdat->node_mem_map + i; 52 page = pgdat_page_nr(pgdat, i);
53 total++; 53 total++;
54 if (PageHighMem(page)) 54 if (PageHighMem(page))
55 highmem++; 55 highmem++;
@@ -152,7 +152,7 @@ int __init reservedpages_count(void)
152 reservedpages = 0; 152 reservedpages = 0;
153 for_each_online_node(nid) 153 for_each_online_node(nid)
154 for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++) 154 for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
155 if (PageReserved(NODE_DATA(nid)->node_mem_map + i)) 155 if (PageReserved(nid_page_nr(nid, i)))
156 reservedpages++; 156 reservedpages++;
157 157
158 return reservedpages; 158 return reservedpages;
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index d0713c7d9f0a..691a2469ff36 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -357,6 +357,8 @@ config 060_WRITETHROUGH
357 is hardwired on. The 53c710 SCSI driver is known to suffer from 357 is hardwired on. The 53c710 SCSI driver is known to suffer from
358 this problem. 358 this problem.
359 359
360source "mm/Kconfig"
361
360endmenu 362endmenu
361 363
362menu "General setup" 364menu "General setup"
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index e729bd280623..dbfcdc8e6087 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -532,6 +532,8 @@ config ROMKERNEL
532 532
533endchoice 533endchoice
534 534
535source "mm/Kconfig"
536
535endmenu 537endmenu
536 538
537config ISA_DMA_API 539config ISA_DMA_API
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ab9944693f1f..94f5a8eb2c22 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -492,7 +492,7 @@ config SGI_SN0_N_MODE
492 which allows for more memory. Your system is most probably 492 which allows for more memory. Your system is most probably
493 running in M-Mode, so you should say N here. 493 running in M-Mode, so you should say N here.
494 494
495config DISCONTIGMEM 495config ARCH_DISCONTIGMEM_ENABLE
496 bool 496 bool
497 default y if SGI_IP27 497 default y if SGI_IP27
498 help 498 help
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index 13472292d0ec..b5bab3a42fc4 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -82,7 +82,7 @@ CONFIG_STOP_MACHINE=y
82# CONFIG_SGI_IP22 is not set 82# CONFIG_SGI_IP22 is not set
83CONFIG_SGI_IP27=y 83CONFIG_SGI_IP27=y
84# CONFIG_SGI_SN0_N_MODE is not set 84# CONFIG_SGI_SN0_N_MODE is not set
85CONFIG_DISCONTIGMEM=y 85CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
86CONFIG_NUMA=y 86CONFIG_NUMA=y
87# CONFIG_MAPPED_KERNEL is not set 87# CONFIG_MAPPED_KERNEL is not set
88# CONFIG_REPLICATE_KTEXT is not set 88# CONFIG_REPLICATE_KTEXT is not set
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 0a44a98d7adc..a160d04f7dbe 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -549,9 +549,8 @@ void __init mem_init(void)
549 */ 549 */
550 numslots = node_getlastslot(node); 550 numslots = node_getlastslot(node);
551 for (slot = 1; slot <= numslots; slot++) { 551 for (slot = 1; slot <= numslots; slot++) {
552 p = NODE_DATA(node)->node_mem_map + 552 p = nid_page_nr(node, slot_getbasepfn(node, slot) -
553 (slot_getbasepfn(node, slot) - 553 slot_getbasepfn(node, 0));
554 slot_getbasepfn(node, 0));
555 554
556 /* 555 /*
557 * Free valid memory in current slot. 556 * Free valid memory in current slot.
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index e7e7c56fc212..ce327c799b44 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -148,7 +148,7 @@ config HOTPLUG_CPU
148 default y if SMP 148 default y if SMP
149 select HOTPLUG 149 select HOTPLUG
150 150
151config DISCONTIGMEM 151config ARCH_DISCONTIGMEM_ENABLE
152 bool "Discontiguous memory support (EXPERIMENTAL)" 152 bool "Discontiguous memory support (EXPERIMENTAL)"
153 depends on EXPERIMENTAL 153 depends on EXPERIMENTAL
154 help 154 help
@@ -157,6 +157,8 @@ config DISCONTIGMEM
157 or have huge holes in the physical address space for other reasons. 157 or have huge holes in the physical address space for other reasons.
158 See <file:Documentation/vm/numa> for more. 158 See <file:Documentation/vm/numa> for more.
159 159
160source "mm/Kconfig"
161
160config PREEMPT 162config PREEMPT
161 bool 163 bool
162# bool "Preemptible Kernel" 164# bool "Preemptible Kernel"
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index cac37589e35c..2886ad70db48 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -506,7 +506,7 @@ void show_mem(void)
506 for (j = node_start_pfn(i); j < node_end_pfn(i); j++) { 506 for (j = node_start_pfn(i); j < node_end_pfn(i); j++) {
507 struct page *p; 507 struct page *p;
508 508
509 p = node_mem_map(i) + j - node_start_pfn(i); 509 p = nid_page_nr(i, j) - node_start_pfn(i);
510 510
511 total++; 511 total++;
512 if (PageReserved(p)) 512 if (PageReserved(p))
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 10162b187bcf..848f43970a4b 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -905,6 +905,8 @@ config PREEMPT
905config HIGHMEM 905config HIGHMEM
906 bool "High memory support" 906 bool "High memory support"
907 907
908source "mm/Kconfig"
909
908source "fs/Kconfig.binfmt" 910source "fs/Kconfig.binfmt"
909 911
910config PROC_DEVICETREE 912config PROC_DEVICETREE
diff --git a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
index ab0f9902cb67..e02de5b467a4 100644
--- a/arch/ppc/boot/simple/misc.c
+++ b/arch/ppc/boot/simple/misc.c
@@ -222,7 +222,7 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum)
222 puts("\n"); 222 puts("\n");
223 223
224 puts("Uncompressing Linux..."); 224 puts("Uncompressing Linux...");
225 gunzip(0x0, 0x400000, zimage_start, &zimage_size); 225 gunzip(NULL, 0x400000, zimage_start, &zimage_size);
226 puts("done.\n"); 226 puts("done.\n");
227 227
228 /* get the bi_rec address */ 228 /* get the bi_rec address */
diff --git a/arch/ppc/boot/simple/mpc10x_memory.c b/arch/ppc/boot/simple/mpc10x_memory.c
index 977daedc14c0..20d92a34ceb8 100644
--- a/arch/ppc/boot/simple/mpc10x_memory.c
+++ b/arch/ppc/boot/simple/mpc10x_memory.c
@@ -33,7 +33,7 @@
33 33
34#define MPC10X_PCI_OP(rw, size, type, op, mask) \ 34#define MPC10X_PCI_OP(rw, size, type, op, mask) \
35static void \ 35static void \
36mpc10x_##rw##_config_##size(unsigned int *cfg_addr, \ 36mpc10x_##rw##_config_##size(unsigned int __iomem *cfg_addr, \
37 unsigned int *cfg_data, int devfn, int offset, \ 37 unsigned int *cfg_data, int devfn, int offset, \
38 type val) \ 38 type val) \
39{ \ 39{ \
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index bae56ec76ea7..cb27068bfcd4 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -217,13 +217,49 @@ config HMT
217 This option enables hardware multithreading on RS64 cpus. 217 This option enables hardware multithreading on RS64 cpus.
218 pSeries systems p620 and p660 have such a cpu type. 218 pSeries systems p620 and p660 have such a cpu type.
219 219
220config DISCONTIGMEM 220config ARCH_SELECT_MEMORY_MODEL
221 bool "Discontiguous Memory Support" 221 def_bool y
222
223config ARCH_FLATMEM_ENABLE
224 def_bool y
225 depends on !NUMA
226
227config ARCH_DISCONTIGMEM_ENABLE
228 def_bool y
222 depends on SMP && PPC_PSERIES 229 depends on SMP && PPC_PSERIES
223 230
231config ARCH_DISCONTIGMEM_DEFAULT
232 def_bool y
233 depends on ARCH_DISCONTIGMEM_ENABLE
234
235config ARCH_FLATMEM_ENABLE
236 def_bool y
237
238config ARCH_SPARSEMEM_ENABLE
239 def_bool y
240 depends on ARCH_DISCONTIGMEM_ENABLE
241
242source "mm/Kconfig"
243
244config HAVE_ARCH_EARLY_PFN_TO_NID
245 def_bool y
246 depends on NEED_MULTIPLE_NODES
247
248# Some NUMA nodes have memory ranges that span
249# other nodes. Even though a pfn is valid and
250# between a node's start and end pfns, it may not
251# reside on that node.
252#
253# This is a relatively temporary hack that should
254# be able to go away when sparsemem is fully in
255# place
256config NODES_SPAN_OTHER_NODES
257 def_bool y
258 depends on NEED_MULTIPLE_NODES
259
224config NUMA 260config NUMA
225 bool "NUMA support" 261 bool "NUMA support"
226 depends on DISCONTIGMEM 262 default y if DISCONTIGMEM || SPARSEMEM
227 263
228config SCHED_SMT 264config SCHED_SMT
229 bool "SMT (Hyperthreading) scheduler support" 265 bool "SMT (Hyperthreading) scheduler support"
diff --git a/arch/ppc64/boot/install.sh b/arch/ppc64/boot/install.sh
index 955c5681db6c..cb2d6626b555 100644
--- a/arch/ppc64/boot/install.sh
+++ b/arch/ppc64/boot/install.sh
@@ -22,8 +22,8 @@
22 22
23# User may have a custom install script 23# User may have a custom install script
24 24
25if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi 25if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
26if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi 26if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
27 27
28# Default install 28# Default install
29 29
diff --git a/arch/ppc64/configs/pSeries_defconfig b/arch/ppc64/configs/pSeries_defconfig
index 3eb5ef25d3a3..d0db8b5966c0 100644
--- a/arch/ppc64/configs/pSeries_defconfig
+++ b/arch/ppc64/configs/pSeries_defconfig
@@ -88,7 +88,7 @@ CONFIG_IBMVIO=y
88CONFIG_IOMMU_VMERGE=y 88CONFIG_IOMMU_VMERGE=y
89CONFIG_SMP=y 89CONFIG_SMP=y
90CONFIG_NR_CPUS=128 90CONFIG_NR_CPUS=128
91CONFIG_DISCONTIGMEM=y 91CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
92CONFIG_NUMA=y 92CONFIG_NUMA=y
93CONFIG_SCHED_SMT=y 93CONFIG_SCHED_SMT=y
94# CONFIG_PREEMPT is not set 94# CONFIG_PREEMPT is not set
diff --git a/arch/ppc64/defconfig b/arch/ppc64/defconfig
index 2f31bf3046f9..b8e2066dde77 100644
--- a/arch/ppc64/defconfig
+++ b/arch/ppc64/defconfig
@@ -89,7 +89,7 @@ CONFIG_BOOTX_TEXT=y
89CONFIG_IOMMU_VMERGE=y 89CONFIG_IOMMU_VMERGE=y
90CONFIG_SMP=y 90CONFIG_SMP=y
91CONFIG_NR_CPUS=32 91CONFIG_NR_CPUS=32
92CONFIG_DISCONTIGMEM=y 92CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
93# CONFIG_NUMA is not set 93# CONFIG_NUMA is not set
94# CONFIG_SCHED_SMT is not set 94# CONFIG_SCHED_SMT is not set
95# CONFIG_PREEMPT is not set 95# CONFIG_PREEMPT is not set
diff --git a/arch/ppc64/kernel/kprobes.c b/arch/ppc64/kernel/kprobes.c
index e950a2058a19..782ce3efa2c1 100644
--- a/arch/ppc64/kernel/kprobes.c
+++ b/arch/ppc64/kernel/kprobes.c
@@ -32,15 +32,14 @@
32#include <linux/ptrace.h> 32#include <linux/ptrace.h>
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/preempt.h> 34#include <linux/preempt.h>
35#include <asm/cacheflush.h>
35#include <asm/kdebug.h> 36#include <asm/kdebug.h>
36#include <asm/sstep.h> 37#include <asm/sstep.h>
37 38
38/* kprobe_status settings */
39#define KPROBE_HIT_ACTIVE 0x00000001
40#define KPROBE_HIT_SS 0x00000002
41
42static struct kprobe *current_kprobe; 39static struct kprobe *current_kprobe;
43static unsigned long kprobe_status, kprobe_saved_msr; 40static unsigned long kprobe_status, kprobe_saved_msr;
41static struct kprobe *kprobe_prev;
42static unsigned long kprobe_status_prev, kprobe_saved_msr_prev;
44static struct pt_regs jprobe_saved_regs; 43static struct pt_regs jprobe_saved_regs;
45 44
46int arch_prepare_kprobe(struct kprobe *p) 45int arch_prepare_kprobe(struct kprobe *p)
@@ -61,16 +60,25 @@ int arch_prepare_kprobe(struct kprobe *p)
61void arch_copy_kprobe(struct kprobe *p) 60void arch_copy_kprobe(struct kprobe *p)
62{ 61{
63 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 62 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
63 p->opcode = *p->addr;
64} 64}
65 65
66void arch_remove_kprobe(struct kprobe *p) 66void arch_arm_kprobe(struct kprobe *p)
67{ 67{
68 *p->addr = BREAKPOINT_INSTRUCTION;
69 flush_icache_range((unsigned long) p->addr,
70 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
68} 71}
69 72
70static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs) 73void arch_disarm_kprobe(struct kprobe *p)
71{ 74{
72 *p->addr = p->opcode; 75 *p->addr = p->opcode;
73 regs->nip = (unsigned long)p->addr; 76 flush_icache_range((unsigned long) p->addr,
77 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
78}
79
80void arch_remove_kprobe(struct kprobe *p)
81{
74} 82}
75 83
76static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 84static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
@@ -83,6 +91,20 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
83 regs->nip = (unsigned long)&p->ainsn.insn; 91 regs->nip = (unsigned long)&p->ainsn.insn;
84} 92}
85 93
94static inline void save_previous_kprobe(void)
95{
96 kprobe_prev = current_kprobe;
97 kprobe_status_prev = kprobe_status;
98 kprobe_saved_msr_prev = kprobe_saved_msr;
99}
100
101static inline void restore_previous_kprobe(void)
102{
103 current_kprobe = kprobe_prev;
104 kprobe_status = kprobe_status_prev;
105 kprobe_saved_msr = kprobe_saved_msr_prev;
106}
107
86static inline int kprobe_handler(struct pt_regs *regs) 108static inline int kprobe_handler(struct pt_regs *regs)
87{ 109{
88 struct kprobe *p; 110 struct kprobe *p;
@@ -101,8 +123,19 @@ static inline int kprobe_handler(struct pt_regs *regs)
101 unlock_kprobes(); 123 unlock_kprobes();
102 goto no_kprobe; 124 goto no_kprobe;
103 } 125 }
104 disarm_kprobe(p, regs); 126 /* We have reentered the kprobe_handler(), since
105 ret = 1; 127 * another probe was hit while within the handler.
128 * We here save the original kprobes variables and
129 * just single step on the instruction of the new probe
130 * without calling any user handlers.
131 */
132 save_previous_kprobe();
133 current_kprobe = p;
134 kprobe_saved_msr = regs->msr;
135 p->nmissed++;
136 prepare_singlestep(p, regs);
137 kprobe_status = KPROBE_REENTER;
138 return 1;
106 } else { 139 } else {
107 p = current_kprobe; 140 p = current_kprobe;
108 if (p->break_handler && p->break_handler(p, regs)) { 141 if (p->break_handler && p->break_handler(p, regs)) {
@@ -184,13 +217,21 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
184 if (!kprobe_running()) 217 if (!kprobe_running())
185 return 0; 218 return 0;
186 219
187 if (current_kprobe->post_handler) 220 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
221 kprobe_status = KPROBE_HIT_SSDONE;
188 current_kprobe->post_handler(current_kprobe, regs, 0); 222 current_kprobe->post_handler(current_kprobe, regs, 0);
223 }
189 224
190 resume_execution(current_kprobe, regs); 225 resume_execution(current_kprobe, regs);
191 regs->msr |= kprobe_saved_msr; 226 regs->msr |= kprobe_saved_msr;
192 227
228 /*Restore back the original saved kprobes variables and continue. */
229 if (kprobe_status == KPROBE_REENTER) {
230 restore_previous_kprobe();
231 goto out;
232 }
193 unlock_kprobes(); 233 unlock_kprobes();
234out:
194 preempt_enable_no_resched(); 235 preempt_enable_no_resched();
195 236
196 /* 237 /*
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index 7d060ddb5e93..0a47a5ef428d 100644
--- a/arch/ppc64/kernel/setup.c
+++ b/arch/ppc64/kernel/setup.c
@@ -1074,6 +1074,7 @@ void __init setup_arch(char **cmdline_p)
1074 1074
1075 /* set up the bootmem stuff with available memory */ 1075 /* set up the bootmem stuff with available memory */
1076 do_init_bootmem(); 1076 do_init_bootmem();
1077 sparse_init();
1077 1078
1078 /* initialize the syscall map in systemcfg */ 1079 /* initialize the syscall map in systemcfg */
1079 setup_syscall_map(); 1080 setup_syscall_map();
diff --git a/arch/ppc64/mm/Makefile b/arch/ppc64/mm/Makefile
index ac522d57b2a7..3695d00d347f 100644
--- a/arch/ppc64/mm/Makefile
+++ b/arch/ppc64/mm/Makefile
@@ -6,6 +6,6 @@ EXTRA_CFLAGS += -mno-minimal-toc
6 6
7obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o \ 7obj-y := fault.o init.o imalloc.o hash_utils.o hash_low.o tlb.o \
8 slb_low.o slb.o stab.o mmap.o 8 slb_low.o slb.o stab.o mmap.o
9obj-$(CONFIG_DISCONTIGMEM) += numa.o 9obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
11obj-$(CONFIG_PPC_MULTIPLATFORM) += hash_native.o 11obj-$(CONFIG_PPC_MULTIPLATFORM) += hash_native.o
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index 6fa1e6490b57..b50b3a446dbe 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -98,7 +98,7 @@ void show_mem(void)
98 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 98 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
99 for_each_pgdat(pgdat) { 99 for_each_pgdat(pgdat) {
100 for (i = 0; i < pgdat->node_spanned_pages; i++) { 100 for (i = 0; i < pgdat->node_spanned_pages; i++) {
101 page = pgdat->node_mem_map + i; 101 page = pgdat_page_nr(pgdat, i);
102 total++; 102 total++;
103 if (PageReserved(page)) 103 if (PageReserved(page))
104 reserved++; 104 reserved++;
@@ -531,7 +531,7 @@ EXPORT_SYMBOL(page_is_ram);
531 * Initialize the bootmem system and give it all the memory we 531 * Initialize the bootmem system and give it all the memory we
532 * have available. 532 * have available.
533 */ 533 */
534#ifndef CONFIG_DISCONTIGMEM 534#ifndef CONFIG_NEED_MULTIPLE_NODES
535void __init do_init_bootmem(void) 535void __init do_init_bootmem(void)
536{ 536{
537 unsigned long i; 537 unsigned long i;
@@ -553,12 +553,20 @@ void __init do_init_bootmem(void)
553 553
554 max_pfn = max_low_pfn; 554 max_pfn = max_low_pfn;
555 555
556 /* add all physical memory to the bootmem map. Also find the first */ 556 /* Add all physical memory to the bootmem map, mark each area
557 * present.
558 */
557 for (i=0; i < lmb.memory.cnt; i++) { 559 for (i=0; i < lmb.memory.cnt; i++) {
558 unsigned long physbase, size; 560 unsigned long physbase, size;
561 unsigned long start_pfn, end_pfn;
559 562
560 physbase = lmb.memory.region[i].physbase; 563 physbase = lmb.memory.region[i].physbase;
561 size = lmb.memory.region[i].size; 564 size = lmb.memory.region[i].size;
565
566 start_pfn = physbase >> PAGE_SHIFT;
567 end_pfn = start_pfn + (size >> PAGE_SHIFT);
568 memory_present(0, start_pfn, end_pfn);
569
562 free_bootmem(physbase, size); 570 free_bootmem(physbase, size);
563 } 571 }
564 572
@@ -597,7 +605,7 @@ void __init paging_init(void)
597 free_area_init_node(0, NODE_DATA(0), zones_size, 605 free_area_init_node(0, NODE_DATA(0), zones_size,
598 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size); 606 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
599} 607}
600#endif /* CONFIG_DISCONTIGMEM */ 608#endif /* ! CONFIG_NEED_MULTIPLE_NODES */
601 609
602static struct kcore_list kcore_vmem; 610static struct kcore_list kcore_vmem;
603 611
@@ -628,7 +636,7 @@ module_init(setup_kcore);
628 636
629void __init mem_init(void) 637void __init mem_init(void)
630{ 638{
631#ifdef CONFIG_DISCONTIGMEM 639#ifdef CONFIG_NEED_MULTIPLE_NODES
632 int nid; 640 int nid;
633#endif 641#endif
634 pg_data_t *pgdat; 642 pg_data_t *pgdat;
@@ -639,7 +647,7 @@ void __init mem_init(void)
639 num_physpages = max_low_pfn; /* RAM is assumed contiguous */ 647 num_physpages = max_low_pfn; /* RAM is assumed contiguous */
640 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); 648 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
641 649
642#ifdef CONFIG_DISCONTIGMEM 650#ifdef CONFIG_NEED_MULTIPLE_NODES
643 for_each_online_node(nid) { 651 for_each_online_node(nid) {
644 if (NODE_DATA(nid)->node_spanned_pages != 0) { 652 if (NODE_DATA(nid)->node_spanned_pages != 0) {
645 printk("freeing bootmem node %x\n", nid); 653 printk("freeing bootmem node %x\n", nid);
@@ -654,7 +662,7 @@ void __init mem_init(void)
654 662
655 for_each_pgdat(pgdat) { 663 for_each_pgdat(pgdat) {
656 for (i = 0; i < pgdat->node_spanned_pages; i++) { 664 for (i = 0; i < pgdat->node_spanned_pages; i++) {
657 page = pgdat->node_mem_map + i; 665 page = pgdat_page_nr(pgdat, i);
658 if (PageReserved(page)) 666 if (PageReserved(page))
659 reservedpages++; 667 reservedpages++;
660 } 668 }
diff --git a/arch/ppc64/mm/numa.c b/arch/ppc64/mm/numa.c
index ea862ec643d3..cafd91aef289 100644
--- a/arch/ppc64/mm/numa.c
+++ b/arch/ppc64/mm/numa.c
@@ -440,6 +440,8 @@ new_range:
440 for (i = start ; i < (start+size); i += MEMORY_INCREMENT) 440 for (i = start ; i < (start+size); i += MEMORY_INCREMENT)
441 numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] = 441 numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] =
442 numa_domain; 442 numa_domain;
443 memory_present(numa_domain, start >> PAGE_SHIFT,
444 (start + size) >> PAGE_SHIFT);
443 445
444 if (--ranges) 446 if (--ranges)
445 goto new_range; 447 goto new_range;
@@ -481,6 +483,7 @@ static void __init setup_nonnuma(void)
481 483
482 for (i = 0 ; i < top_of_ram; i += MEMORY_INCREMENT) 484 for (i = 0 ; i < top_of_ram; i += MEMORY_INCREMENT)
483 numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] = 0; 485 numa_memory_lookup_table[i >> MEMORY_INCREMENT_SHIFT] = 0;
486 memory_present(0, 0, init_node_data[0].node_end_pfn);
484} 487}
485 488
486static void __init dump_numa_topology(void) 489static void __init dump_numa_topology(void)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index ab79af84699a..32696c1d9280 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -226,6 +226,8 @@ config WARN_STACK_SIZE
226 This allows you to specify the maximum frame size a function may 226 This allows you to specify the maximum frame size a function may
227 have without the compiler complaining about it. 227 have without the compiler complaining about it.
228 228
229source "mm/Kconfig"
230
229comment "I/O subsystem configuration" 231comment "I/O subsystem configuration"
230 232
231config MACHCHK_WARNING 233config MACHCHK_WARNING
diff --git a/arch/s390/boot/install.sh b/arch/s390/boot/install.sh
index 278a8139cb18..d4026f62cb06 100644
--- a/arch/s390/boot/install.sh
+++ b/arch/s390/boot/install.sh
@@ -21,8 +21,8 @@
21 21
22# User may have a custom install script 22# User may have a custom install script
23 23
24if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi 24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
25if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi 25if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
26 26
27# Default install - same as make zlilo 27# Default install - same as make zlilo
28 28
diff --git a/arch/s390/kernel/compat_linux.h b/arch/s390/kernel/compat_linux.h
index bf33dcfec7db..3898f66d0b2f 100644
--- a/arch/s390/kernel/compat_linux.h
+++ b/arch/s390/kernel/compat_linux.h
@@ -45,7 +45,7 @@ typedef struct compat_siginfo {
45 45
46 /* POSIX.1b timers */ 46 /* POSIX.1b timers */
47 struct { 47 struct {
48 timer_t _tid; /* timer id */ 48 compat_timer_t _tid; /* timer id */
49 int _overrun; /* overrun count */ 49 int _overrun; /* overrun count */
50 compat_sigval_t _sigval; /* same as below */ 50 compat_sigval_t _sigval; /* same as below */
51 int _sys_private; /* not to be passed to user */ 51 int _sys_private; /* not to be passed to user */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 3468d5127223..a7c8bfc11604 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -486,7 +486,7 @@ config CPU_SUBTYPE_ST40
486 depends on CPU_SUBTYPE_ST40STB1 || CPU_SUBTYPE_ST40GX1 486 depends on CPU_SUBTYPE_ST40STB1 || CPU_SUBTYPE_ST40GX1
487 default y 487 default y
488 488
489config DISCONTIGMEM 489config ARCH_DISCONTIGMEM_ENABLE
490 bool 490 bool
491 depends on SH_HP690 491 depends on SH_HP690
492 default y 492 default y
@@ -496,6 +496,8 @@ config DISCONTIGMEM
496 or have huge holes in the physical address space for other reasons. 496 or have huge holes in the physical address space for other reasons.
497 See <file:Documentation/vm/numa> for more. 497 See <file:Documentation/vm/numa> for more.
498 498
499source "mm/Kconfig"
500
499config ZERO_PAGE_OFFSET 501config ZERO_PAGE_OFFSET
500 hex "Zero page offset" 502 hex "Zero page offset"
501 default "0x00001000" if !(SH_MPC1211 || SH_SH03) 503 default "0x00001000" if !(SH_MPC1211 || SH_SH03)
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index 76eb81fba45e..708e59736a4d 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -217,6 +217,8 @@ config PREEMPT
217 bool "Preemptible Kernel (EXPERIMENTAL)" 217 bool "Preemptible Kernel (EXPERIMENTAL)"
218 depends on EXPERIMENTAL 218 depends on EXPERIMENTAL
219 219
220source "mm/Kconfig"
221
220endmenu 222endmenu
221 223
222menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)" 224menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 237f922520fd..262e13d086fe 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -264,7 +264,11 @@ config SUNOS_EMUL
264 want to run SunOS binaries on an Ultra you must also say Y to 264 want to run SunOS binaries on an Ultra you must also say Y to
265 "Kernel support for 32-bit a.out binaries" above. 265 "Kernel support for 32-bit a.out binaries" above.
266 266
267source "drivers/parport/Kconfig" 267source "mm/Kconfig"
268
269endmenu
270
271source "drivers/Kconfig"
268 272
269config PRINTER 273config PRINTER
270 tristate "Parallel printer support" 274 tristate "Parallel printer support"
@@ -291,6 +295,8 @@ config PRINTER
291 If you have more than 8 printers, you need to increase the LP_NO 295 If you have more than 8 printers, you need to increase the LP_NO
292 macro in lp.c and the PARPORT_MAX macro in parport.h. 296 macro in lp.c and the PARPORT_MAX macro in parport.h.
293 297
298source "mm/Kconfig"
299
294endmenu 300endmenu
295 301
296source "drivers/base/Kconfig" 302source "drivers/base/Kconfig"
@@ -372,18 +378,8 @@ config UNIX98_PTY_COUNT
372 378
373endmenu 379endmenu
374 380
375source "drivers/input/Kconfig"
376
377source "fs/Kconfig" 381source "fs/Kconfig"
378 382
379source "sound/Kconfig"
380
381source "drivers/usb/Kconfig"
382
383source "drivers/infiniband/Kconfig"
384
385source "drivers/char/watchdog/Kconfig"
386
387source "arch/sparc/Kconfig.debug" 383source "arch/sparc/Kconfig.debug"
388 384
389source "security/Kconfig" 385source "security/Kconfig"
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index a72fd15d5ea8..e2b050eb3b96 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -484,6 +484,8 @@ config CMDLINE
484 484
485 NOTE: This option WILL override the PROM bootargs setting! 485 NOTE: This option WILL override the PROM bootargs setting!
486 486
487source "mm/Kconfig"
488
487endmenu 489endmenu
488 490
489source "drivers/base/Kconfig" 491source "drivers/base/Kconfig"
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index 7066d7ba667a..bdac631cf011 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -6,7 +6,6 @@
6#include <linux/config.h> 6#include <linux/config.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/kprobes.h> 8#include <linux/kprobes.h>
9
10#include <asm/kdebug.h> 9#include <asm/kdebug.h>
11#include <asm/signal.h> 10#include <asm/signal.h>
12 11
@@ -47,25 +46,59 @@ void arch_copy_kprobe(struct kprobe *p)
47{ 46{
48 p->ainsn.insn[0] = *p->addr; 47 p->ainsn.insn[0] = *p->addr;
49 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; 48 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
49 p->opcode = *p->addr;
50} 50}
51 51
52void arch_remove_kprobe(struct kprobe *p) 52void arch_arm_kprobe(struct kprobe *p)
53{ 53{
54 *p->addr = BREAKPOINT_INSTRUCTION;
55 flushi(p->addr);
54} 56}
55 57
56/* kprobe_status settings */ 58void arch_disarm_kprobe(struct kprobe *p)
57#define KPROBE_HIT_ACTIVE 0x00000001 59{
58#define KPROBE_HIT_SS 0x00000002 60 *p->addr = p->opcode;
61 flushi(p->addr);
62}
63
64void arch_remove_kprobe(struct kprobe *p)
65{
66}
59 67
60static struct kprobe *current_kprobe; 68static struct kprobe *current_kprobe;
61static unsigned long current_kprobe_orig_tnpc; 69static unsigned long current_kprobe_orig_tnpc;
62static unsigned long current_kprobe_orig_tstate_pil; 70static unsigned long current_kprobe_orig_tstate_pil;
63static unsigned int kprobe_status; 71static unsigned int kprobe_status;
72static struct kprobe *kprobe_prev;
73static unsigned long kprobe_orig_tnpc_prev;
74static unsigned long kprobe_orig_tstate_pil_prev;
75static unsigned int kprobe_status_prev;
64 76
65static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 77static inline void save_previous_kprobe(void)
78{
79 kprobe_status_prev = kprobe_status;
80 kprobe_orig_tnpc_prev = current_kprobe_orig_tnpc;
81 kprobe_orig_tstate_pil_prev = current_kprobe_orig_tstate_pil;
82 kprobe_prev = current_kprobe;
83}
84
85static inline void restore_previous_kprobe(void)
86{
87 kprobe_status = kprobe_status_prev;
88 current_kprobe_orig_tnpc = kprobe_orig_tnpc_prev;
89 current_kprobe_orig_tstate_pil = kprobe_orig_tstate_pil_prev;
90 current_kprobe = kprobe_prev;
91}
92
93static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs)
66{ 94{
67 current_kprobe_orig_tnpc = regs->tnpc; 95 current_kprobe_orig_tnpc = regs->tnpc;
68 current_kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL); 96 current_kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL);
97 current_kprobe = p;
98}
99
100static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
101{
69 regs->tstate |= TSTATE_PIL; 102 regs->tstate |= TSTATE_PIL;
70 103
71 /*single step inline, if it a breakpoint instruction*/ 104 /*single step inline, if it a breakpoint instruction*/
@@ -78,17 +111,6 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
78 } 111 }
79} 112}
80 113
81static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
82{
83 *p->addr = p->opcode;
84 flushi(p->addr);
85
86 regs->tpc = (unsigned long) p->addr;
87 regs->tnpc = current_kprobe_orig_tnpc;
88 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
89 current_kprobe_orig_tstate_pil);
90}
91
92static int kprobe_handler(struct pt_regs *regs) 114static int kprobe_handler(struct pt_regs *regs)
93{ 115{
94 struct kprobe *p; 116 struct kprobe *p;
@@ -109,8 +131,18 @@ static int kprobe_handler(struct pt_regs *regs)
109 unlock_kprobes(); 131 unlock_kprobes();
110 goto no_kprobe; 132 goto no_kprobe;
111 } 133 }
112 disarm_kprobe(p, regs); 134 /* We have reentered the kprobe_handler(), since
113 ret = 1; 135 * another probe was hit while within the handler.
136 * We here save the original kprobes variables and
137 * just single step on the instruction of the new probe
138 * without calling any user handlers.
139 */
140 save_previous_kprobe();
141 set_current_kprobe(p, regs);
142 p->nmissed++;
143 kprobe_status = KPROBE_REENTER;
144 prepare_singlestep(p, regs);
145 return 1;
114 } else { 146 } else {
115 p = current_kprobe; 147 p = current_kprobe;
116 if (p->break_handler && p->break_handler(p, regs)) 148 if (p->break_handler && p->break_handler(p, regs))
@@ -138,8 +170,8 @@ static int kprobe_handler(struct pt_regs *regs)
138 goto no_kprobe; 170 goto no_kprobe;
139 } 171 }
140 172
173 set_current_kprobe(p, regs);
141 kprobe_status = KPROBE_HIT_ACTIVE; 174 kprobe_status = KPROBE_HIT_ACTIVE;
142 current_kprobe = p;
143 if (p->pre_handler && p->pre_handler(p, regs)) 175 if (p->pre_handler && p->pre_handler(p, regs))
144 return 1; 176 return 1;
145 177
@@ -245,12 +277,20 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
245 if (!kprobe_running()) 277 if (!kprobe_running())
246 return 0; 278 return 0;
247 279
248 if (current_kprobe->post_handler) 280 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
281 kprobe_status = KPROBE_HIT_SSDONE;
249 current_kprobe->post_handler(current_kprobe, regs, 0); 282 current_kprobe->post_handler(current_kprobe, regs, 0);
283 }
250 284
251 resume_execution(current_kprobe, regs); 285 resume_execution(current_kprobe, regs);
252 286
287 /*Restore back the original saved kprobes variables and continue. */
288 if (kprobe_status == KPROBE_REENTER) {
289 restore_previous_kprobe();
290 goto out;
291 }
253 unlock_kprobes(); 292 unlock_kprobes();
293out:
254 preempt_enable_no_resched(); 294 preempt_enable_no_resched();
255 295
256 return 1; 296 return 1;
@@ -392,3 +432,4 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
392 } 432 }
393 return 0; 433 return 0;
394} 434}
435
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index 9a375e975cff..f28428f4170e 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -102,7 +102,7 @@ typedef struct compat_siginfo{
102 102
103 /* POSIX.1b timers */ 103 /* POSIX.1b timers */
104 struct { 104 struct {
105 timer_t _tid; /* timer id */ 105 compat_timer_t _tid; /* timer id */
106 int _overrun; /* overrun count */ 106 int _overrun; /* overrun count */
107 compat_sigval_t _sigval; /* same as below */ 107 compat_sigval_t _sigval; /* same as below */
108 int _sys_private; /* not to be passed to user */ 108 int _sys_private; /* not to be passed to user */
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index b8e952c88fd1..9469e77303e6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -74,6 +74,7 @@ config MODE_SKAS
74 option will shrink the UML binary slightly. 74 option will shrink the UML binary slightly.
75 75
76source "arch/um/Kconfig_arch" 76source "arch/um/Kconfig_arch"
77source "mm/Kconfig"
77 78
78config LD_SCRIPT_STATIC 79config LD_SCRIPT_STATIC
79 bool 80 bool
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index 804c6bbdf67c..157584ae4792 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -8,6 +8,7 @@
8#include "linux/kernel.h" 8#include "linux/kernel.h"
9#include "linux/sched.h" 9#include "linux/sched.h"
10#include "linux/interrupt.h" 10#include "linux/interrupt.h"
11#include "linux/string.h"
11#include "linux/mm.h" 12#include "linux/mm.h"
12#include "linux/slab.h" 13#include "linux/slab.h"
13#include "linux/utsname.h" 14#include "linux/utsname.h"
@@ -322,12 +323,7 @@ void do_uml_exitcalls(void)
322 323
323char *uml_strdup(char *string) 324char *uml_strdup(char *string)
324{ 325{
325 char *new; 326 return kstrdup(string, GFP_KERNEL);
326
327 new = kmalloc(strlen(string) + 1, GFP_KERNEL);
328 if(new == NULL) return(NULL);
329 strcpy(new, string);
330 return(new);
331} 327}
332 328
333int copy_to_user_proc(void __user *to, void *from, int size) 329int copy_to_user_proc(void __user *to, void *from, int size)
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig
index 90cd4baa75ee..27febd6ffa80 100644
--- a/arch/v850/Kconfig
+++ b/arch/v850/Kconfig
@@ -218,6 +218,8 @@ menu "Processor type and features"
218 a lot of RAM, and you need to able to allocate very large 218 a lot of RAM, and you need to able to allocate very large
219 contiguous chunks. If unsure, say N. 219 contiguous chunks. If unsure, say N.
220 220
221source "mm/Kconfig"
222
221endmenu 223endmenu
222 224
223 225
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 289f448ac89c..db259757dc8a 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -265,7 +265,7 @@ config NUMA_EMU
265 into virtual nodes when booted with "numa=fake=N", where N is the 265 into virtual nodes when booted with "numa=fake=N", where N is the
266 number of nodes. This is only useful for debugging. 266 number of nodes. This is only useful for debugging.
267 267
268config DISCONTIGMEM 268config ARCH_DISCONTIGMEM_ENABLE
269 bool 269 bool
270 depends on NUMA 270 depends on NUMA
271 default y 271 default y
@@ -274,6 +274,27 @@ config NUMA
274 bool 274 bool
275 default n 275 default n
276 276
277config ARCH_DISCONTIGMEM_ENABLE
278 def_bool y
279 depends on NUMA
280
281config ARCH_DISCONTIGMEM_DEFAULT
282 def_bool y
283 depends on NUMA
284
285config ARCH_SPARSEMEM_ENABLE
286 def_bool y
287 depends on NUMA
288
289config ARCH_FLATMEM_ENABLE
290 def_bool y
291 depends on !NUMA
292
293source "mm/Kconfig"
294
295config HAVE_ARCH_EARLY_PFN_TO_NID
296 def_bool y
297
277config HAVE_DEC_LOCK 298config HAVE_DEC_LOCK
278 bool 299 bool
279 depends on SMP 300 depends on SMP
@@ -381,6 +402,8 @@ config SECCOMP
381 402
382 If unsure, say Y. Only embedded should say N here. 403 If unsure, say Y. Only embedded should say N here.
383 404
405source kernel/Kconfig.hz
406
384endmenu 407endmenu
385 408
386# 409#
diff --git a/arch/x86_64/boot/install.sh b/arch/x86_64/boot/install.sh
index 90f2452b3b9e..f17b40dfc0f4 100644
--- a/arch/x86_64/boot/install.sh
+++ b/arch/x86_64/boot/install.sh
@@ -21,8 +21,8 @@
21 21
22# User may have a custom install script 22# User may have a custom install script
23 23
24if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi 24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
25if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi 25if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
26 26
27# Default install - same as make zlilo 27# Default install - same as make zlilo
28 28
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index fbd09b5126ce..66e2821533db 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -428,8 +428,8 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
428 return (void __user *)((rsp - frame_size) & -8UL); 428 return (void __user *)((rsp - frame_size) & -8UL);
429} 429}
430 430
431void ia32_setup_frame(int sig, struct k_sigaction *ka, 431int ia32_setup_frame(int sig, struct k_sigaction *ka,
432 compat_sigset_t *set, struct pt_regs * regs) 432 compat_sigset_t *set, struct pt_regs * regs)
433{ 433{
434 struct sigframe __user *frame; 434 struct sigframe __user *frame;
435 int err = 0; 435 int err = 0;
@@ -514,14 +514,15 @@ void ia32_setup_frame(int sig, struct k_sigaction *ka,
514 current->comm, current->pid, frame, regs->rip, frame->pretcode); 514 current->comm, current->pid, frame, regs->rip, frame->pretcode);
515#endif 515#endif
516 516
517 return; 517 return 1;
518 518
519give_sigsegv: 519give_sigsegv:
520 force_sigsegv(sig, current); 520 force_sigsegv(sig, current);
521 return 0;
521} 522}
522 523
523void ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 524int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
524 compat_sigset_t *set, struct pt_regs * regs) 525 compat_sigset_t *set, struct pt_regs * regs)
525{ 526{
526 struct rt_sigframe __user *frame; 527 struct rt_sigframe __user *frame;
527 int err = 0; 528 int err = 0;
@@ -613,9 +614,9 @@ void ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
613 current->comm, current->pid, frame, regs->rip, frame->pretcode); 614 current->comm, current->pid, frame, regs->rip, frame->pretcode);
614#endif 615#endif
615 616
616 return; 617 return 1;
617 618
618give_sigsegv: 619give_sigsegv:
619 force_sigsegv(sig, current); 620 force_sigsegv(sig, current);
621 return 0;
620} 622}
621
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index 504e63474993..c9a6b812e926 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -40,11 +40,7 @@ int fix_aperture __initdata = 1;
40 40
41static u32 __init allocate_aperture(void) 41static u32 __init allocate_aperture(void)
42{ 42{
43#ifdef CONFIG_DISCONTIGMEM
44 pg_data_t *nd0 = NODE_DATA(0); 43 pg_data_t *nd0 = NODE_DATA(0);
45#else
46 pg_data_t *nd0 = &contig_page_data;
47#endif
48 u32 aper_size; 44 u32 aper_size;
49 void *p; 45 void *p;
50 46
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index e3a19e8ebbf8..9631c747c5e3 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -2,20 +2,24 @@
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/tty.h>
5#include <asm/io.h> 6#include <asm/io.h>
6#include <asm/processor.h> 7#include <asm/processor.h>
7 8
8/* Simple VGA output */ 9/* Simple VGA output */
9 10
10#ifdef __i386__ 11#ifdef __i386__
12#include <asm/setup.h>
11#define VGABASE (__ISA_IO_base + 0xb8000) 13#define VGABASE (__ISA_IO_base + 0xb8000)
12#else 14#else
15#include <asm/bootsetup.h>
13#define VGABASE ((void __iomem *)0xffffffff800b8000UL) 16#define VGABASE ((void __iomem *)0xffffffff800b8000UL)
14#endif 17#endif
15 18
16#define MAX_YPOS 25 19#define MAX_YPOS max_ypos
17#define MAX_XPOS 80 20#define MAX_XPOS max_xpos
18 21
22static int max_ypos = 25, max_xpos = 80;
19static int current_ypos = 1, current_xpos = 0; 23static int current_ypos = 1, current_xpos = 0;
20 24
21static void early_vga_write(struct console *con, const char *str, unsigned n) 25static void early_vga_write(struct console *con, const char *str, unsigned n)
@@ -196,7 +200,10 @@ int __init setup_early_printk(char *opt)
196 } else if (!strncmp(buf, "ttyS", 4)) { 200 } else if (!strncmp(buf, "ttyS", 4)) {
197 early_serial_init(buf); 201 early_serial_init(buf);
198 early_console = &early_serial_console; 202 early_console = &early_serial_console;
199 } else if (!strncmp(buf, "vga", 3)) { 203 } else if (!strncmp(buf, "vga", 3)
204 && SCREEN_INFO.orig_video_isVGA == 1) {
205 max_xpos = SCREEN_INFO.orig_video_cols;
206 max_ypos = SCREEN_INFO.orig_video_lines;
200 early_console = &early_vga_console; 207 early_console = &early_vga_console;
201 } 208 }
202 early_console_initialized = 1; 209 early_console_initialized = 1;
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index 0f8c78dcd38c..cf6ab147a2a5 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -94,7 +94,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
94 s = strstr(saved_command_line, "earlyprintk="); 94 s = strstr(saved_command_line, "earlyprintk=");
95 if (s != NULL) 95 if (s != NULL)
96 setup_early_printk(s); 96 setup_early_printk(s);
97#ifdef CONFIG_DISCONTIGMEM 97#ifdef CONFIG_NUMA
98 s = strstr(saved_command_line, "numa="); 98 s = strstr(saved_command_line, "numa=");
99 if (s != NULL) 99 if (s != NULL)
100 numa_setup(s+5); 100 numa_setup(s+5);
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 7873d9ba8814..19eafa0aa95c 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -157,14 +157,13 @@ static unsigned int startup_8259A_irq(unsigned int irq)
157} 157}
158 158
159static struct hw_interrupt_type i8259A_irq_type = { 159static struct hw_interrupt_type i8259A_irq_type = {
160 "XT-PIC", 160 .typename = "XT-PIC",
161 startup_8259A_irq, 161 .startup = startup_8259A_irq,
162 shutdown_8259A_irq, 162 .shutdown = shutdown_8259A_irq,
163 enable_8259A_irq, 163 .enable = enable_8259A_irq,
164 disable_8259A_irq, 164 .disable = disable_8259A_irq,
165 mask_and_ack_8259A, 165 .ack = mask_and_ack_8259A,
166 end_8259A_irq, 166 .end = end_8259A_irq,
167 NULL
168}; 167};
169 168
170/* 169/*
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index f77f8a0ff187..4e680f87a75f 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -27,6 +27,8 @@
27 * <prasanna@in.ibm.com> adapted for x86_64 27 * <prasanna@in.ibm.com> adapted for x86_64
28 * 2005-Mar Roland McGrath <roland@redhat.com> 28 * 2005-Mar Roland McGrath <roland@redhat.com>
29 * Fixed to handle %rip-relative addressing mode correctly. 29 * Fixed to handle %rip-relative addressing mode correctly.
30 * 2005-May Rusty Lynch <rusty.lynch@intel.com>
31 * Added function return probes functionality
30 */ 32 */
31 33
32#include <linux/config.h> 34#include <linux/config.h>
@@ -37,18 +39,16 @@
37#include <linux/slab.h> 39#include <linux/slab.h>
38#include <linux/preempt.h> 40#include <linux/preempt.h>
39#include <linux/moduleloader.h> 41#include <linux/moduleloader.h>
40 42#include <asm/cacheflush.h>
41#include <asm/pgtable.h> 43#include <asm/pgtable.h>
42#include <asm/kdebug.h> 44#include <asm/kdebug.h>
43 45
44static DECLARE_MUTEX(kprobe_mutex); 46static DECLARE_MUTEX(kprobe_mutex);
45 47
46/* kprobe_status settings */
47#define KPROBE_HIT_ACTIVE 0x00000001
48#define KPROBE_HIT_SS 0x00000002
49
50static struct kprobe *current_kprobe; 48static struct kprobe *current_kprobe;
51static unsigned long kprobe_status, kprobe_old_rflags, kprobe_saved_rflags; 49static unsigned long kprobe_status, kprobe_old_rflags, kprobe_saved_rflags;
50static struct kprobe *kprobe_prev;
51static unsigned long kprobe_status_prev, kprobe_old_rflags_prev, kprobe_saved_rflags_prev;
52static struct pt_regs jprobe_saved_regs; 52static struct pt_regs jprobe_saved_regs;
53static long *jprobe_saved_rsp; 53static long *jprobe_saved_rsp;
54static kprobe_opcode_t *get_insn_slot(void); 54static kprobe_opcode_t *get_insn_slot(void);
@@ -214,6 +214,21 @@ void arch_copy_kprobe(struct kprobe *p)
214 BUG_ON((s64) (s32) disp != disp); /* Sanity check. */ 214 BUG_ON((s64) (s32) disp != disp); /* Sanity check. */
215 *ripdisp = disp; 215 *ripdisp = disp;
216 } 216 }
217 p->opcode = *p->addr;
218}
219
220void arch_arm_kprobe(struct kprobe *p)
221{
222 *p->addr = BREAKPOINT_INSTRUCTION;
223 flush_icache_range((unsigned long) p->addr,
224 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
225}
226
227void arch_disarm_kprobe(struct kprobe *p)
228{
229 *p->addr = p->opcode;
230 flush_icache_range((unsigned long) p->addr,
231 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
217} 232}
218 233
219void arch_remove_kprobe(struct kprobe *p) 234void arch_remove_kprobe(struct kprobe *p)
@@ -223,10 +238,29 @@ void arch_remove_kprobe(struct kprobe *p)
223 down(&kprobe_mutex); 238 down(&kprobe_mutex);
224} 239}
225 240
226static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs) 241static inline void save_previous_kprobe(void)
227{ 242{
228 *p->addr = p->opcode; 243 kprobe_prev = current_kprobe;
229 regs->rip = (unsigned long)p->addr; 244 kprobe_status_prev = kprobe_status;
245 kprobe_old_rflags_prev = kprobe_old_rflags;
246 kprobe_saved_rflags_prev = kprobe_saved_rflags;
247}
248
249static inline void restore_previous_kprobe(void)
250{
251 current_kprobe = kprobe_prev;
252 kprobe_status = kprobe_status_prev;
253 kprobe_old_rflags = kprobe_old_rflags_prev;
254 kprobe_saved_rflags = kprobe_saved_rflags_prev;
255}
256
257static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs)
258{
259 current_kprobe = p;
260 kprobe_saved_rflags = kprobe_old_rflags
261 = (regs->eflags & (TF_MASK | IF_MASK));
262 if (is_IF_modifier(p->ainsn.insn))
263 kprobe_saved_rflags &= ~IF_MASK;
230} 264}
231 265
232static void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 266static void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
@@ -240,6 +274,50 @@ static void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
240 regs->rip = (unsigned long)p->ainsn.insn; 274 regs->rip = (unsigned long)p->ainsn.insn;
241} 275}
242 276
277struct task_struct *arch_get_kprobe_task(void *ptr)
278{
279 return ((struct thread_info *) (((unsigned long) ptr) &
280 (~(THREAD_SIZE -1))))->task;
281}
282
283void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs)
284{
285 unsigned long *sara = (unsigned long *)regs->rsp;
286 struct kretprobe_instance *ri;
287 static void *orig_ret_addr;
288
289 /*
290 * Save the return address when the return probe hits
291 * the first time, and use it to populate the (krprobe
292 * instance)->ret_addr for subsequent return probes at
293 * the same addrress since stack address would have
294 * the kretprobe_trampoline by then.
295 */
296 if (((void*) *sara) != kretprobe_trampoline)
297 orig_ret_addr = (void*) *sara;
298
299 if ((ri = get_free_rp_inst(rp)) != NULL) {
300 ri->rp = rp;
301 ri->stack_addr = sara;
302 ri->ret_addr = orig_ret_addr;
303 add_rp_inst(ri);
304 /* Replace the return addr with trampoline addr */
305 *sara = (unsigned long) &kretprobe_trampoline;
306 } else {
307 rp->nmissed++;
308 }
309}
310
311void arch_kprobe_flush_task(struct task_struct *tk)
312{
313 struct kretprobe_instance *ri;
314 while ((ri = get_rp_inst_tsk(tk)) != NULL) {
315 *((unsigned long *)(ri->stack_addr)) =
316 (unsigned long) ri->ret_addr;
317 recycle_rp_inst(ri);
318 }
319}
320
243/* 321/*
244 * Interrupts are disabled on entry as trap3 is an interrupt gate and they 322 * Interrupts are disabled on entry as trap3 is an interrupt gate and they
245 * remain disabled thorough out this function. 323 * remain disabled thorough out this function.
@@ -264,9 +342,30 @@ int kprobe_handler(struct pt_regs *regs)
264 regs->eflags |= kprobe_saved_rflags; 342 regs->eflags |= kprobe_saved_rflags;
265 unlock_kprobes(); 343 unlock_kprobes();
266 goto no_kprobe; 344 goto no_kprobe;
345 } else if (kprobe_status == KPROBE_HIT_SSDONE) {
346 /* TODO: Provide re-entrancy from
347 * post_kprobes_handler() and avoid exception
348 * stack corruption while single-stepping on
349 * the instruction of the new probe.
350 */
351 arch_disarm_kprobe(p);
352 regs->rip = (unsigned long)p->addr;
353 ret = 1;
354 } else {
355 /* We have reentered the kprobe_handler(), since
356 * another probe was hit while within the
357 * handler. We here save the original kprobe
358 * variables and just single step on instruction
359 * of the new probe without calling any user
360 * handlers.
361 */
362 save_previous_kprobe();
363 set_current_kprobe(p, regs);
364 p->nmissed++;
365 prepare_singlestep(p, regs);
366 kprobe_status = KPROBE_REENTER;
367 return 1;
267 } 368 }
268 disarm_kprobe(p, regs);
269 ret = 1;
270 } else { 369 } else {
271 p = current_kprobe; 370 p = current_kprobe;
272 if (p->break_handler && p->break_handler(p, regs)) { 371 if (p->break_handler && p->break_handler(p, regs)) {
@@ -296,11 +395,7 @@ int kprobe_handler(struct pt_regs *regs)
296 } 395 }
297 396
298 kprobe_status = KPROBE_HIT_ACTIVE; 397 kprobe_status = KPROBE_HIT_ACTIVE;
299 current_kprobe = p; 398 set_current_kprobe(p, regs);
300 kprobe_saved_rflags = kprobe_old_rflags
301 = (regs->eflags & (TF_MASK | IF_MASK));
302 if (is_IF_modifier(p->ainsn.insn))
303 kprobe_saved_rflags &= ~IF_MASK;
304 399
305 if (p->pre_handler && p->pre_handler(p, regs)) 400 if (p->pre_handler && p->pre_handler(p, regs))
306 /* handler has already set things up, so skip ss setup */ 401 /* handler has already set things up, so skip ss setup */
@@ -317,6 +412,55 @@ no_kprobe:
317} 412}
318 413
319/* 414/*
415 * For function-return probes, init_kprobes() establishes a probepoint
416 * here. When a retprobed function returns, this probe is hit and
417 * trampoline_probe_handler() runs, calling the kretprobe's handler.
418 */
419 void kretprobe_trampoline_holder(void)
420 {
421 asm volatile ( ".global kretprobe_trampoline\n"
422 "kretprobe_trampoline: \n"
423 "nop\n");
424 }
425
426/*
427 * Called when we hit the probe point at kretprobe_trampoline
428 */
429int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
430{
431 struct task_struct *tsk;
432 struct kretprobe_instance *ri;
433 struct hlist_head *head;
434 struct hlist_node *node;
435 unsigned long *sara = (unsigned long *)regs->rsp - 1;
436
437 tsk = arch_get_kprobe_task(sara);
438 head = kretprobe_inst_table_head(tsk);
439
440 hlist_for_each_entry(ri, node, head, hlist) {
441 if (ri->stack_addr == sara && ri->rp) {
442 if (ri->rp->handler)
443 ri->rp->handler(ri, regs);
444 }
445 }
446 return 0;
447}
448
449void trampoline_post_handler(struct kprobe *p, struct pt_regs *regs,
450 unsigned long flags)
451{
452 struct kretprobe_instance *ri;
453 /* RA already popped */
454 unsigned long *sara = ((unsigned long *)regs->rsp) - 1;
455
456 while ((ri = get_rp_inst(sara))) {
457 regs->rip = (unsigned long)ri->ret_addr;
458 recycle_rp_inst(ri);
459 }
460 regs->eflags &= ~TF_MASK;
461}
462
463/*
320 * Called after single-stepping. p->addr is the address of the 464 * Called after single-stepping. p->addr is the address of the
321 * instruction whose first byte has been replaced by the "int 3" 465 * instruction whose first byte has been replaced by the "int 3"
322 * instruction. To avoid the SMP problems that can occur when we 466 * instruction. To avoid the SMP problems that can occur when we
@@ -401,13 +545,23 @@ int post_kprobe_handler(struct pt_regs *regs)
401 if (!kprobe_running()) 545 if (!kprobe_running())
402 return 0; 546 return 0;
403 547
404 if (current_kprobe->post_handler) 548 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) {
549 kprobe_status = KPROBE_HIT_SSDONE;
405 current_kprobe->post_handler(current_kprobe, regs, 0); 550 current_kprobe->post_handler(current_kprobe, regs, 0);
551 }
406 552
407 resume_execution(current_kprobe, regs); 553 if (current_kprobe->post_handler != trampoline_post_handler)
554 resume_execution(current_kprobe, regs);
408 regs->eflags |= kprobe_saved_rflags; 555 regs->eflags |= kprobe_saved_rflags;
409 556
410 unlock_kprobes(); 557 /* Restore the original saved kprobes variables and continue. */
558 if (kprobe_status == KPROBE_REENTER) {
559 restore_previous_kprobe();
560 goto out;
561 } else {
562 unlock_kprobes();
563 }
564out:
411 preempt_enable_no_resched(); 565 preempt_enable_no_resched();
412 566
413 /* 567 /*
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 61a63be6b294..9c5aa2a790c7 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -23,6 +23,7 @@
23#include <linux/kernel_stat.h> 23#include <linux/kernel_stat.h>
24#include <linux/mc146818rtc.h> 24#include <linux/mc146818rtc.h>
25#include <linux/acpi.h> 25#include <linux/acpi.h>
26#include <linux/module.h>
26 27
27#include <asm/smp.h> 28#include <asm/smp.h>
28#include <asm/mtrr.h> 29#include <asm/mtrr.h>
@@ -45,7 +46,8 @@ int acpi_found_madt;
45int apic_version [MAX_APICS]; 46int apic_version [MAX_APICS];
46unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; 47unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
47int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; 48int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
48cpumask_t pci_bus_to_cpumask [256] = { [0 ... 255] = CPU_MASK_ALL }; 49unsigned char pci_bus_to_node [256];
50EXPORT_SYMBOL(pci_bus_to_node);
49 51
50static int mp_current_pci_id = 0; 52static int mp_current_pci_id = 0;
51/* I/O APIC entries */ 53/* I/O APIC entries */
@@ -904,11 +906,20 @@ void __init mp_config_acpi_legacy_irqs (void)
904 return; 906 return;
905} 907}
906 908
909#define MAX_GSI_NUM 4096
910
907int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) 911int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
908{ 912{
909 int ioapic = -1; 913 int ioapic = -1;
910 int ioapic_pin = 0; 914 int ioapic_pin = 0;
911 int idx, bit = 0; 915 int idx, bit = 0;
916 static int pci_irq = 16;
917 /*
918 * Mapping between Global System Interrupts, which
919 * represent all possible interrupts, to the IRQs
920 * assigned to actual devices.
921 */
922 static int gsi_to_irq[MAX_GSI_NUM];
912 923
913 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) 924 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
914 return gsi; 925 return gsi;
@@ -943,11 +954,21 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low)
943 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) { 954 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
944 Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n", 955 Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
945 mp_ioapic_routing[ioapic].apic_id, ioapic_pin); 956 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
946 return gsi; 957 return gsi_to_irq[gsi];
947 } 958 }
948 959
949 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit); 960 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
950 961
962 if (edge_level) {
963 /*
964 * For PCI devices assign IRQs in order, avoiding gaps
965 * due to unused I/O APIC pins.
966 */
967 int irq = gsi;
968 gsi = pci_irq++;
969 gsi_to_irq[irq] = gsi;
970 }
971
951 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi, 972 io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
952 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1, 973 edge_level == ACPI_EDGE_SENSITIVE ? 0 : 1,
953 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1); 974 active_high_low == ACPI_ACTIVE_HIGH ? 0 : 1);
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index dce8bab4306c..e59d1f9d6163 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -34,6 +34,7 @@
34#include <linux/ptrace.h> 34#include <linux/ptrace.h>
35#include <linux/utsname.h> 35#include <linux/utsname.h>
36#include <linux/random.h> 36#include <linux/random.h>
37#include <linux/kprobes.h>
37 38
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39#include <asm/pgtable.h> 40#include <asm/pgtable.h>
@@ -293,6 +294,14 @@ void exit_thread(void)
293{ 294{
294 struct task_struct *me = current; 295 struct task_struct *me = current;
295 struct thread_struct *t = &me->thread; 296 struct thread_struct *t = &me->thread;
297
298 /*
299 * Remove function-return probe instances associated with this task
300 * and put them back on the free list. Do not insert an exit probe for
301 * this function, it will be disabled by kprobe_flush_task if you do.
302 */
303 kprobe_flush_task(me);
304
296 if (me->thread.io_bitmap_ptr) { 305 if (me->thread.io_bitmap_ptr) {
297 struct tss_struct *tss = &per_cpu(init_tss, get_cpu()); 306 struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
298 307
@@ -312,6 +321,13 @@ void flush_thread(void)
312 struct task_struct *tsk = current; 321 struct task_struct *tsk = current;
313 struct thread_info *t = current_thread_info(); 322 struct thread_info *t = current_thread_info();
314 323
324 /*
325 * Remove function-return probe instances associated with this task
326 * and put them back on the free list. Do not insert an exit probe for
327 * this function, it will be disabled by kprobe_flush_task if you do.
328 */
329 kprobe_flush_task(tsk);
330
315 if (t->flags & _TIF_ABI_PENDING) 331 if (t->flags & _TIF_ABI_PENDING)
316 t->flags ^= (_TIF_ABI_PENDING | _TIF_IA32); 332 t->flags ^= (_TIF_ABI_PENDING | _TIF_IA32);
317 333
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 99f038ede23c..000015dd5a8b 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -40,6 +40,8 @@
40#include <linux/acpi.h> 40#include <linux/acpi.h>
41#include <linux/kallsyms.h> 41#include <linux/kallsyms.h>
42#include <linux/edd.h> 42#include <linux/edd.h>
43#include <linux/mmzone.h>
44
43#include <asm/mtrr.h> 45#include <asm/mtrr.h>
44#include <asm/uaccess.h> 46#include <asm/uaccess.h>
45#include <asm/system.h> 47#include <asm/system.h>
@@ -348,7 +350,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
348 if (!memcmp(from, "mem=", 4)) 350 if (!memcmp(from, "mem=", 4))
349 parse_memopt(from+4, &from); 351 parse_memopt(from+4, &from);
350 352
351#ifdef CONFIG_DISCONTIGMEM 353#ifdef CONFIG_NUMA
352 if (!memcmp(from, "numa=", 5)) 354 if (!memcmp(from, "numa=", 5))
353 numa_setup(from+5); 355 numa_setup(from+5);
354#endif 356#endif
@@ -377,17 +379,20 @@ static __init void parse_cmdline_early (char ** cmdline_p)
377 *cmdline_p = command_line; 379 *cmdline_p = command_line;
378} 380}
379 381
380#ifndef CONFIG_DISCONTIGMEM 382#ifndef CONFIG_NUMA
381static void __init contig_initmem_init(void) 383static void __init
384contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
382{ 385{
383 unsigned long bootmap_size, bootmap; 386 unsigned long bootmap_size, bootmap;
384 bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT; 387
385 bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size); 388 memory_present(0, start_pfn, end_pfn);
386 if (bootmap == -1L) 389 bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
387 panic("Cannot find bootmem map of size %ld\n",bootmap_size); 390 bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
388 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn); 391 if (bootmap == -1L)
389 e820_bootmem_free(&contig_page_data, 0, end_pfn << PAGE_SHIFT); 392 panic("Cannot find bootmem map of size %ld\n",bootmap_size);
390 reserve_bootmem(bootmap, bootmap_size); 393 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
394 e820_bootmem_free(NODE_DATA(0), 0, end_pfn << PAGE_SHIFT);
395 reserve_bootmem(bootmap, bootmap_size);
391} 396}
392#endif 397#endif
393 398
@@ -554,10 +559,10 @@ void __init setup_arch(char **cmdline_p)
554 acpi_numa_init(); 559 acpi_numa_init();
555#endif 560#endif
556 561
557#ifdef CONFIG_DISCONTIGMEM 562#ifdef CONFIG_NUMA
558 numa_initmem_init(0, end_pfn); 563 numa_initmem_init(0, end_pfn);
559#else 564#else
560 contig_initmem_init(); 565 contig_initmem_init(0, end_pfn);
561#endif 566#endif
562 567
563 /* Reserve direct mapping */ 568 /* Reserve direct mapping */
@@ -618,6 +623,8 @@ void __init setup_arch(char **cmdline_p)
618 } 623 }
619 } 624 }
620#endif 625#endif
626
627 sparse_init();
621 paging_init(); 628 paging_init();
622 629
623 check_ioapic(); 630 check_ioapic();
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 429c0269dc4e..98b7ba95d581 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -34,9 +34,9 @@
34 34
35#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 35#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
36 36
37void ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 37int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
38 sigset_t *set, struct pt_regs * regs); 38 sigset_t *set, struct pt_regs * regs);
39void ia32_setup_frame(int sig, struct k_sigaction *ka, 39int ia32_setup_frame(int sig, struct k_sigaction *ka,
40 sigset_t *set, struct pt_regs * regs); 40 sigset_t *set, struct pt_regs * regs);
41 41
42asmlinkage long 42asmlinkage long
@@ -238,7 +238,7 @@ get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size)
238 return (void __user *)round_down(rsp - size, 16); 238 return (void __user *)round_down(rsp - size, 16);
239} 239}
240 240
241static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 241static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
242 sigset_t *set, struct pt_regs * regs) 242 sigset_t *set, struct pt_regs * regs)
243{ 243{
244 struct rt_sigframe __user *frame; 244 struct rt_sigframe __user *frame;
@@ -327,20 +327,23 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
327 current->comm, current->pid, frame, regs->rip, frame->pretcode); 327 current->comm, current->pid, frame, regs->rip, frame->pretcode);
328#endif 328#endif
329 329
330 return; 330 return 1;
331 331
332give_sigsegv: 332give_sigsegv:
333 force_sigsegv(sig, current); 333 force_sigsegv(sig, current);
334 return 0;
334} 335}
335 336
336/* 337/*
337 * OK, we're invoking a handler 338 * OK, we're invoking a handler
338 */ 339 */
339 340
340static void 341static int
341handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 342handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
342 sigset_t *oldset, struct pt_regs *regs) 343 sigset_t *oldset, struct pt_regs *regs)
343{ 344{
345 int ret;
346
344#ifdef DEBUG_SIG 347#ifdef DEBUG_SIG
345 printk("handle_signal pid:%d sig:%lu rip:%lx rsp:%lx regs=%p\n", 348 printk("handle_signal pid:%d sig:%lu rip:%lx rsp:%lx regs=%p\n",
346 current->pid, sig, 349 current->pid, sig,
@@ -384,20 +387,22 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
384#ifdef CONFIG_IA32_EMULATION 387#ifdef CONFIG_IA32_EMULATION
385 if (test_thread_flag(TIF_IA32)) { 388 if (test_thread_flag(TIF_IA32)) {
386 if (ka->sa.sa_flags & SA_SIGINFO) 389 if (ka->sa.sa_flags & SA_SIGINFO)
387 ia32_setup_rt_frame(sig, ka, info, oldset, regs); 390 ret = ia32_setup_rt_frame(sig, ka, info, oldset, regs);
388 else 391 else
389 ia32_setup_frame(sig, ka, oldset, regs); 392 ret = ia32_setup_frame(sig, ka, oldset, regs);
390 } else 393 } else
391#endif 394#endif
392 setup_rt_frame(sig, ka, info, oldset, regs); 395 ret = setup_rt_frame(sig, ka, info, oldset, regs);
393 396
394 if (!(ka->sa.sa_flags & SA_NODEFER)) { 397 if (ret && !(ka->sa.sa_flags & SA_NODEFER)) {
395 spin_lock_irq(&current->sighand->siglock); 398 spin_lock_irq(&current->sighand->siglock);
396 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask); 399 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
397 sigaddset(&current->blocked,sig); 400 sigaddset(&current->blocked,sig);
398 recalc_sigpending(); 401 recalc_sigpending();
399 spin_unlock_irq(&current->sighand->siglock); 402 spin_unlock_irq(&current->sighand->siglock);
400 } 403 }
404
405 return ret;
401} 406}
402 407
403/* 408/*
@@ -417,7 +422,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
417 * kernel mode. Just return without doing anything 422 * kernel mode. Just return without doing anything
418 * if so. 423 * if so.
419 */ 424 */
420 if ((regs->cs & 3) != 3) 425 if (!user_mode(regs))
421 return 1; 426 return 1;
422 427
423 if (try_to_freeze(0)) 428 if (try_to_freeze(0))
@@ -434,11 +439,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
434 * inside the kernel. 439 * inside the kernel.
435 */ 440 */
436 if (current->thread.debugreg7) 441 if (current->thread.debugreg7)
437 asm volatile("movq %0,%%db7" : : "r" (current->thread.debugreg7)); 442 set_debugreg(current->thread.debugreg7, 7);
438 443
439 /* Whee! Actually deliver the signal. */ 444 /* Whee! Actually deliver the signal. */
440 handle_signal(signr, &info, &ka, oldset, regs); 445 return handle_signal(signr, &info, &ka, oldset, regs);
441 return 1;
442 } 446 }
443 447
444 no_signal: 448 no_signal:
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index fb8c809b4cd9..66bf6ddeb0c3 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -64,6 +64,7 @@ static int notsc __initdata = 0;
64unsigned int cpu_khz; /* TSC clocks / usec, not used here */ 64unsigned int cpu_khz; /* TSC clocks / usec, not used here */
65static unsigned long hpet_period; /* fsecs / HPET clock */ 65static unsigned long hpet_period; /* fsecs / HPET clock */
66unsigned long hpet_tick; /* HPET clocks / interrupt */ 66unsigned long hpet_tick; /* HPET clocks / interrupt */
67static int hpet_use_timer;
67unsigned long vxtime_hz = PIT_TICK_RATE; 68unsigned long vxtime_hz = PIT_TICK_RATE;
68int report_lost_ticks; /* command line option */ 69int report_lost_ticks; /* command line option */
69unsigned long long monotonic_base; 70unsigned long long monotonic_base;
@@ -105,7 +106,9 @@ static inline unsigned int do_gettimeoffset_tsc(void)
105 106
106static inline unsigned int do_gettimeoffset_hpet(void) 107static inline unsigned int do_gettimeoffset_hpet(void)
107{ 108{
108 return ((hpet_readl(HPET_COUNTER) - vxtime.last) * vxtime.quot) >> 32; 109 /* cap counter read to one tick to avoid inconsistencies */
110 unsigned long counter = hpet_readl(HPET_COUNTER) - vxtime.last;
111 return (min(counter,hpet_tick) * vxtime.quot) >> 32;
109} 112}
110 113
111unsigned int (*do_gettimeoffset)(void) = do_gettimeoffset_tsc; 114unsigned int (*do_gettimeoffset)(void) = do_gettimeoffset_tsc;
@@ -301,7 +304,7 @@ unsigned long long monotonic_clock(void)
301 304
302 last_offset = vxtime.last; 305 last_offset = vxtime.last;
303 base = monotonic_base; 306 base = monotonic_base;
304 this_offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 307 this_offset = hpet_readl(HPET_COUNTER);
305 308
306 } while (read_seqretry(&xtime_lock, seq)); 309 } while (read_seqretry(&xtime_lock, seq));
307 offset = (this_offset - last_offset); 310 offset = (this_offset - last_offset);
@@ -377,7 +380,14 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
377 380
378 write_seqlock(&xtime_lock); 381 write_seqlock(&xtime_lock);
379 382
380 if (vxtime.hpet_address) { 383 if (vxtime.hpet_address)
384 offset = hpet_readl(HPET_COUNTER);
385
386 if (hpet_use_timer) {
387 /* if we're using the hpet timer functionality,
388 * we can more accurately know the counter value
389 * when the timer interrupt occured.
390 */
381 offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 391 offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
382 delay = hpet_readl(HPET_COUNTER) - offset; 392 delay = hpet_readl(HPET_COUNTER) - offset;
383 } else { 393 } else {
@@ -803,17 +813,18 @@ static int hpet_timer_stop_set_go(unsigned long tick)
803 * Set up timer 0, as periodic with first interrupt to happen at hpet_tick, 813 * Set up timer 0, as periodic with first interrupt to happen at hpet_tick,
804 * and period also hpet_tick. 814 * and period also hpet_tick.
805 */ 815 */
806 816 if (hpet_use_timer) {
807 hpet_writel(HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL | 817 hpet_writel(HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
808 HPET_TN_32BIT, HPET_T0_CFG); 818 HPET_TN_32BIT, HPET_T0_CFG);
809 hpet_writel(hpet_tick, HPET_T0_CMP); 819 hpet_writel(hpet_tick, HPET_T0_CMP);
810 hpet_writel(hpet_tick, HPET_T0_CMP); /* AK: why twice? */ 820 hpet_writel(hpet_tick, HPET_T0_CMP); /* AK: why twice? */
811 821 cfg |= HPET_CFG_LEGACY;
822 }
812/* 823/*
813 * Go! 824 * Go!
814 */ 825 */
815 826
816 cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY; 827 cfg |= HPET_CFG_ENABLE;
817 hpet_writel(cfg, HPET_CFG); 828 hpet_writel(cfg, HPET_CFG);
818 829
819 return 0; 830 return 0;
@@ -834,8 +845,7 @@ static int hpet_init(void)
834 845
835 id = hpet_readl(HPET_ID); 846 id = hpet_readl(HPET_ID);
836 847
837 if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER) || 848 if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER))
838 !(id & HPET_ID_LEGSUP))
839 return -1; 849 return -1;
840 850
841 hpet_period = hpet_readl(HPET_PERIOD); 851 hpet_period = hpet_readl(HPET_PERIOD);
@@ -845,6 +855,8 @@ static int hpet_init(void)
845 hpet_tick = (1000000000L * (USEC_PER_SEC / HZ) + hpet_period / 2) / 855 hpet_tick = (1000000000L * (USEC_PER_SEC / HZ) + hpet_period / 2) /
846 hpet_period; 856 hpet_period;
847 857
858 hpet_use_timer = (id & HPET_ID_LEGSUP);
859
848 return hpet_timer_stop_set_go(hpet_tick); 860 return hpet_timer_stop_set_go(hpet_tick);
849} 861}
850 862
@@ -901,9 +913,11 @@ void __init time_init(void)
901 set_normalized_timespec(&wall_to_monotonic, 913 set_normalized_timespec(&wall_to_monotonic,
902 -xtime.tv_sec, -xtime.tv_nsec); 914 -xtime.tv_sec, -xtime.tv_nsec);
903 915
904 if (!hpet_init()) { 916 if (!hpet_init())
905 vxtime_hz = (1000000000000000L + hpet_period / 2) / 917 vxtime_hz = (1000000000000000L + hpet_period / 2) /
906 hpet_period; 918 hpet_period;
919
920 if (hpet_use_timer) {
907 cpu_khz = hpet_calibrate_tsc(); 921 cpu_khz = hpet_calibrate_tsc();
908 timename = "HPET"; 922 timename = "HPET";
909#ifdef CONFIG_X86_PM_TIMER 923#ifdef CONFIG_X86_PM_TIMER
@@ -968,7 +982,7 @@ void __init time_init_gtod(void)
968 if (unsynchronized_tsc()) 982 if (unsynchronized_tsc())
969 notsc = 1; 983 notsc = 1;
970 if (vxtime.hpet_address && notsc) { 984 if (vxtime.hpet_address && notsc) {
971 timetype = "HPET"; 985 timetype = hpet_use_timer ? "HPET" : "PIT/HPET";
972 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick; 986 vxtime.last = hpet_readl(HPET_T0_CMP) - hpet_tick;
973 vxtime.mode = VXTIME_HPET; 987 vxtime.mode = VXTIME_HPET;
974 do_gettimeoffset = do_gettimeoffset_hpet; 988 do_gettimeoffset = do_gettimeoffset_hpet;
@@ -983,7 +997,7 @@ void __init time_init_gtod(void)
983 printk(KERN_INFO "Disabling vsyscall due to use of PM timer\n"); 997 printk(KERN_INFO "Disabling vsyscall due to use of PM timer\n");
984#endif 998#endif
985 } else { 999 } else {
986 timetype = vxtime.hpet_address ? "HPET/TSC" : "PIT/TSC"; 1000 timetype = hpet_use_timer ? "HPET/TSC" : "PIT/TSC";
987 vxtime.mode = VXTIME_TSC; 1001 vxtime.mode = VXTIME_TSC;
988 } 1002 }
989 1003
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 3dfec8fdabcd..121646fc43f6 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -274,7 +274,7 @@ EXPORT_SYMBOL(dump_stack);
274void show_registers(struct pt_regs *regs) 274void show_registers(struct pt_regs *regs)
275{ 275{
276 int i; 276 int i;
277 int in_kernel = (regs->cs & 3) == 0; 277 int in_kernel = !user_mode(regs);
278 unsigned long rsp; 278 unsigned long rsp;
279 const int cpu = safe_smp_processor_id(); 279 const int cpu = safe_smp_processor_id();
280 struct task_struct *cur = cpu_pda[cpu].pcurrent; 280 struct task_struct *cur = cpu_pda[cpu].pcurrent;
@@ -318,7 +318,7 @@ void handle_BUG(struct pt_regs *regs)
318 struct bug_frame f; 318 struct bug_frame f;
319 char tmp; 319 char tmp;
320 320
321 if (regs->cs & 3) 321 if (user_mode(regs))
322 return; 322 return;
323 if (__copy_from_user(&f, (struct bug_frame *) regs->rip, 323 if (__copy_from_user(&f, (struct bug_frame *) regs->rip,
324 sizeof(struct bug_frame))) 324 sizeof(struct bug_frame)))
@@ -437,7 +437,7 @@ static void do_trap(int trapnr, int signr, char *str,
437 } 437 }
438#endif 438#endif
439 439
440 if ((regs->cs & 3) != 0) { 440 if (user_mode(regs)) {
441 struct task_struct *tsk = current; 441 struct task_struct *tsk = current;
442 442
443 if (exception_trace && unhandled_signal(tsk, signr)) 443 if (exception_trace && unhandled_signal(tsk, signr))
@@ -522,7 +522,7 @@ asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
522 } 522 }
523#endif 523#endif
524 524
525 if ((regs->cs & 3)!=0) { 525 if (user_mode(regs)) {
526 struct task_struct *tsk = current; 526 struct task_struct *tsk = current;
527 527
528 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) 528 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
@@ -638,7 +638,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs)
638 if (eregs == (struct pt_regs *)eregs->rsp) 638 if (eregs == (struct pt_regs *)eregs->rsp)
639 ; 639 ;
640 /* Exception from user space */ 640 /* Exception from user space */
641 else if (eregs->cs & 3) 641 else if (user_mode(eregs))
642 regs = ((struct pt_regs *)current->thread.rsp0) - 1; 642 regs = ((struct pt_regs *)current->thread.rsp0) - 1;
643 /* Exception from kernel and interrupts are enabled. Move to 643 /* Exception from kernel and interrupts are enabled. Move to
644 kernel process stack. */ 644 kernel process stack. */
@@ -669,7 +669,7 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code)
669 } 669 }
670#endif 670#endif
671 671
672 asm("movq %%db6,%0" : "=r" (condition)); 672 get_debugreg(condition, 6);
673 673
674 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code, 674 if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
675 SIGTRAP) == NOTIFY_STOP) 675 SIGTRAP) == NOTIFY_STOP)
@@ -697,7 +697,7 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code)
697 * allowing programs to debug themselves without the ptrace() 697 * allowing programs to debug themselves without the ptrace()
698 * interface. 698 * interface.
699 */ 699 */
700 if ((regs->cs & 3) == 0) 700 if (!user_mode(regs))
701 goto clear_TF_reenable; 701 goto clear_TF_reenable;
702 /* 702 /*
703 * Was the TF flag set by a debugger? If so, clear it now, 703 * Was the TF flag set by a debugger? If so, clear it now,
@@ -715,13 +715,13 @@ asmlinkage void do_debug(struct pt_regs * regs, unsigned long error_code)
715 info.si_signo = SIGTRAP; 715 info.si_signo = SIGTRAP;
716 info.si_errno = 0; 716 info.si_errno = 0;
717 info.si_code = TRAP_BRKPT; 717 info.si_code = TRAP_BRKPT;
718 if ((regs->cs & 3) == 0) 718 if (!user_mode(regs))
719 goto clear_dr7; 719 goto clear_dr7;
720 720
721 info.si_addr = (void __user *)regs->rip; 721 info.si_addr = (void __user *)regs->rip;
722 force_sig_info(SIGTRAP, &info, tsk); 722 force_sig_info(SIGTRAP, &info, tsk);
723clear_dr7: 723clear_dr7:
724 asm volatile("movq %0,%%db7"::"r"(0UL)); 724 set_debugreg(0UL, 7);
725 return; 725 return;
726 726
727clear_TF_reenable: 727clear_TF_reenable:
@@ -756,7 +756,7 @@ asmlinkage void do_coprocessor_error(struct pt_regs *regs)
756 unsigned short cwd, swd; 756 unsigned short cwd, swd;
757 757
758 conditional_sti(regs); 758 conditional_sti(regs);
759 if ((regs->cs & 3) == 0 && 759 if (!user_mode(regs) &&
760 kernel_math_error(regs, "kernel x87 math error")) 760 kernel_math_error(regs, "kernel x87 math error"))
761 return; 761 return;
762 762
@@ -822,7 +822,7 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
822 unsigned short mxcsr; 822 unsigned short mxcsr;
823 823
824 conditional_sti(regs); 824 conditional_sti(regs);
825 if ((regs->cs & 3) == 0 && 825 if (!user_mode(regs) &&
826 kernel_math_error(regs, "kernel simd math error")) 826 kernel_math_error(regs, "kernel simd math error"))
827 return; 827 return;
828 828
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
index aed61a668a1b..33a873a3c223 100644
--- a/arch/x86_64/lib/delay.c
+++ b/arch/x86_64/lib/delay.c
@@ -12,6 +12,7 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <asm/delay.h> 14#include <asm/delay.h>
15#include <asm/msr.h>
15 16
16#ifdef CONFIG_SMP 17#ifdef CONFIG_SMP
17#include <asm/smp.h> 18#include <asm/smp.h>
@@ -19,6 +20,12 @@
19 20
20int x86_udelay_tsc = 0; /* Delay via TSC */ 21int x86_udelay_tsc = 0; /* Delay via TSC */
21 22
23int read_current_timer(unsigned long *timer_value)
24{
25 rdtscll(*timer_value);
26 return 0;
27}
28
22void __delay(unsigned long loops) 29void __delay(unsigned long loops)
23{ 30{
24 unsigned bclock, now; 31 unsigned bclock, now;
diff --git a/arch/x86_64/mm/Makefile b/arch/x86_64/mm/Makefile
index 66c354ad80ca..1d232a87f113 100644
--- a/arch/x86_64/mm/Makefile
+++ b/arch/x86_64/mm/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-y := init.o fault.o ioremap.o extable.o pageattr.o 5obj-y := init.o fault.o ioremap.o extable.o pageattr.o
6obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 6obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
7obj-$(CONFIG_DISCONTIGMEM) += numa.o 7obj-$(CONFIG_NUMA) += numa.o
8obj-$(CONFIG_K8_NUMA) += k8topology.o 8obj-$(CONFIG_K8_NUMA) += k8topology.o
9obj-$(CONFIG_ACPI_NUMA) += srat.o 9obj-$(CONFIG_ACPI_NUMA) += srat.o
10 10
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 57d3ab15a5c7..2f187986f940 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -74,7 +74,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
74 instr = (unsigned char *)convert_rip_to_linear(current, regs); 74 instr = (unsigned char *)convert_rip_to_linear(current, regs);
75 max_instr = instr + 15; 75 max_instr = instr + 15;
76 76
77 if ((regs->cs & 3) != 0 && instr >= (unsigned char *)TASK_SIZE) 77 if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE)
78 return 0; 78 return 0;
79 79
80 while (scan_more && instr < max_instr) { 80 while (scan_more && instr < max_instr) {
@@ -106,7 +106,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
106 /* Could check the LDT for lm, but for now it's good 106 /* Could check the LDT for lm, but for now it's good
107 enough to assume that long mode only uses well known 107 enough to assume that long mode only uses well known
108 segments or kernel. */ 108 segments or kernel. */
109 scan_more = ((regs->cs & 3) == 0) || (regs->cs == __USER_CS); 109 scan_more = (!user_mode(regs)) || (regs->cs == __USER_CS);
110 break; 110 break;
111 111
112 case 0x60: 112 case 0x60:
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index dbe53b4c7e66..72e4b364ed73 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -318,7 +318,7 @@ void zap_low_mappings(void)
318 flush_tlb_all(); 318 flush_tlb_all();
319} 319}
320 320
321#ifndef CONFIG_DISCONTIGMEM 321#ifndef CONFIG_NUMA
322void __init paging_init(void) 322void __init paging_init(void)
323{ 323{
324 { 324 {
@@ -427,13 +427,16 @@ void __init mem_init(void)
427 reservedpages = 0; 427 reservedpages = 0;
428 428
429 /* this will put all low memory onto the freelists */ 429 /* this will put all low memory onto the freelists */
430#ifdef CONFIG_DISCONTIGMEM 430#ifdef CONFIG_NUMA
431 totalram_pages += numa_free_all_bootmem(); 431 totalram_pages += numa_free_all_bootmem();
432 tmp = 0; 432 tmp = 0;
433 /* should count reserved pages here for all nodes */ 433 /* should count reserved pages here for all nodes */
434#else 434#else
435
436#ifdef CONFIG_FLATMEM
435 max_mapnr = end_pfn; 437 max_mapnr = end_pfn;
436 if (!mem_map) BUG(); 438 if (!mem_map) BUG();
439#endif
437 440
438 totalram_pages += free_all_bootmem(); 441 totalram_pages += free_all_bootmem();
439 442
@@ -515,7 +518,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
515void __init reserve_bootmem_generic(unsigned long phys, unsigned len) 518void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
516{ 519{
517 /* Should check here against the e820 map to avoid double free */ 520 /* Should check here against the e820 map to avoid double free */
518#ifdef CONFIG_DISCONTIGMEM 521#ifdef CONFIG_NUMA
519 int nid = phys_to_nid(phys); 522 int nid = phys_to_nid(phys);
520 reserve_bootmem_node(NODE_DATA(nid), phys, len); 523 reserve_bootmem_node(NODE_DATA(nid), phys, len);
521#else 524#else
diff --git a/arch/x86_64/mm/ioremap.c b/arch/x86_64/mm/ioremap.c
index 58aac23760ef..6972df480d2b 100644
--- a/arch/x86_64/mm/ioremap.c
+++ b/arch/x86_64/mm/ioremap.c
@@ -178,7 +178,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
178 if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS) 178 if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
179 return (__force void __iomem *)phys_to_virt(phys_addr); 179 return (__force void __iomem *)phys_to_virt(phys_addr);
180 180
181#ifndef CONFIG_DISCONTIGMEM 181#ifdef CONFIG_FLATMEM
182 /* 182 /*
183 * Don't allow anybody to remap normal RAM that we're using.. 183 * Don't allow anybody to remap normal RAM that we're using..
184 */ 184 */
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index fd9f25d7a6c4..84cde796ecb1 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -66,6 +66,13 @@ int __init compute_hash_shift(struct node *nodes, int numnodes)
66 return -1; 66 return -1;
67} 67}
68 68
69#ifdef CONFIG_SPARSEMEM
70int early_pfn_to_nid(unsigned long pfn)
71{
72 return phys_to_nid(pfn << PAGE_SHIFT);
73}
74#endif
75
69/* Initialize bootmem allocator for a node */ 76/* Initialize bootmem allocator for a node */
70void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long end) 77void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
71{ 78{
@@ -80,6 +87,7 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
80 start_pfn = start >> PAGE_SHIFT; 87 start_pfn = start >> PAGE_SHIFT;
81 end_pfn = end >> PAGE_SHIFT; 88 end_pfn = end >> PAGE_SHIFT;
82 89
90 memory_present(nodeid, start_pfn, end_pfn);
83 nodedata_phys = find_e820_area(start, end, pgdat_size); 91 nodedata_phys = find_e820_area(start, end, pgdat_size);
84 if (nodedata_phys == -1L) 92 if (nodedata_phys == -1L)
85 panic("Cannot find memory pgdat in node %d\n", nodeid); 93 panic("Cannot find memory pgdat in node %d\n", nodeid);
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c
index 62349c78db57..7e7d0c2a0025 100644
--- a/arch/x86_64/pci/k8-bus.c
+++ b/arch/x86_64/pci/k8-bus.c
@@ -53,25 +53,11 @@ fill_mp_bus_to_cpumask(void)
53 for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); 53 for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
54 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); 54 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
55 j++) 55 j++)
56 pci_bus_to_cpumask[j] = 56 pci_bus_to_node[j] = NODE_ID(nid);
57 node_to_cpumask(NODE_ID(nid));
58 } 57 }
59 } 58 }
60 } 59 }
61 60
62 /* quick sanity check */
63 printed = 0;
64 for (i = 0; i < 256; i++) {
65 if (cpus_empty(pci_bus_to_cpumask[i])) {
66 pci_bus_to_cpumask[i] = CPU_MASK_ALL;
67 if (printed)
68 continue;
69 printk(KERN_ERR
70 "k8-bus.c: some busses have empty cpu mask\n");
71 printed = 1;
72 }
73 }
74
75 return 0; 61 return 0;
76} 62}
77 63
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 92b0352c8e92..bd7524cfff33 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Quick & dirty crypto testing module. 2 * Quick & dirty crypto testing module.
3 * 3 *
4 * This will only exist until we have a better testing mechanism 4 * This will only exist until we have a better testing mechanism
@@ -9,11 +9,12 @@
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free 11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option) 12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version. 13 * any later version.
14 * 14 *
15 * 14 - 09 - 2003 15 * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>)
16 * Rewritten by Kartikey Mahendra Bhatt 16 * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt
17 *
17 */ 18 */
18 19
19#include <linux/init.h> 20#include <linux/init.h>
@@ -25,12 +26,15 @@
25#include <linux/crypto.h> 26#include <linux/crypto.h>
26#include <linux/highmem.h> 27#include <linux/highmem.h>
27#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/jiffies.h>
30#include <linux/timex.h>
31#include <linux/interrupt.h>
28#include "tcrypt.h" 32#include "tcrypt.h"
29 33
30/* 34/*
31 * Need to kmalloc() memory for testing kmap(). 35 * Need to kmalloc() memory for testing kmap().
32 */ 36 */
33#define TVMEMSIZE 4096 37#define TVMEMSIZE 16384
34#define XBUFSIZE 32768 38#define XBUFSIZE 32768
35 39
36/* 40/*
@@ -55,19 +59,23 @@
55 59
56static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 }; 60static unsigned int IDX[8] = { IDX1, IDX2, IDX3, IDX4, IDX5, IDX6, IDX7, IDX8 };
57 61
62/*
63 * Used by test_cipher_speed()
64 */
65static unsigned int sec;
66
58static int mode; 67static int mode;
59static char *xbuf; 68static char *xbuf;
60static char *tvmem; 69static char *tvmem;
61 70
62static char *check[] = { 71static char *check[] = {
63 "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", 72 "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
64 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 73 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6",
65 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 74 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
66 "khazad", "wp512", "wp384", "wp256", "tnepres", NULL 75 "khazad", "wp512", "wp384", "wp256", "tnepres", NULL
67}; 76};
68 77
69static void 78static void hexdump(unsigned char *buf, unsigned int len)
70hexdump(unsigned char *buf, unsigned int len)
71{ 79{
72 while (len--) 80 while (len--)
73 printk("%02x", *buf++); 81 printk("%02x", *buf++);
@@ -75,29 +83,29 @@ hexdump(unsigned char *buf, unsigned int len)
75 printk("\n"); 83 printk("\n");
76} 84}
77 85
78static void 86static void test_hash(char *algo, struct hash_testvec *template,
79test_hash (char * algo, struct hash_testvec * template, unsigned int tcount) 87 unsigned int tcount)
80{ 88{
81 char *p; 89 char *p;
82 unsigned int i, j, k, temp; 90 unsigned int i, j, k, temp;
83 struct scatterlist sg[8]; 91 struct scatterlist sg[8];
84 char result[64]; 92 char result[64];
85 struct crypto_tfm *tfm; 93 struct crypto_tfm *tfm;
86 struct hash_testvec *hash_tv; 94 struct hash_testvec *hash_tv;
87 unsigned int tsize; 95 unsigned int tsize;
88 96
89 printk("\ntesting %s\n", algo); 97 printk("\ntesting %s\n", algo);
90 98
91 tsize = sizeof (struct hash_testvec); 99 tsize = sizeof(struct hash_testvec);
92 tsize *= tcount; 100 tsize *= tcount;
93 101
94 if (tsize > TVMEMSIZE) { 102 if (tsize > TVMEMSIZE) {
95 printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE); 103 printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE);
96 return; 104 return;
97 } 105 }
98 106
99 memcpy(tvmem, template, tsize); 107 memcpy(tvmem, template, tsize);
100 hash_tv = (void *) tvmem; 108 hash_tv = (void *)tvmem;
101 tfm = crypto_alloc_tfm(algo, 0); 109 tfm = crypto_alloc_tfm(algo, 0);
102 if (tfm == NULL) { 110 if (tfm == NULL) {
103 printk("failed to load transform for %s\n", algo); 111 printk("failed to load transform for %s\n", algo);
@@ -105,70 +113,71 @@ test_hash (char * algo, struct hash_testvec * template, unsigned int tcount)
105 } 113 }
106 114
107 for (i = 0; i < tcount; i++) { 115 for (i = 0; i < tcount; i++) {
108 printk ("test %u:\n", i + 1); 116 printk("test %u:\n", i + 1);
109 memset (result, 0, 64); 117 memset(result, 0, 64);
110 118
111 p = hash_tv[i].plaintext; 119 p = hash_tv[i].plaintext;
112 sg[0].page = virt_to_page (p); 120 sg[0].page = virt_to_page(p);
113 sg[0].offset = offset_in_page (p); 121 sg[0].offset = offset_in_page(p);
114 sg[0].length = hash_tv[i].psize; 122 sg[0].length = hash_tv[i].psize;
115 123
116 crypto_digest_init (tfm); 124 crypto_digest_init(tfm);
117 if (tfm->crt_u.digest.dit_setkey) { 125 if (tfm->crt_u.digest.dit_setkey) {
118 crypto_digest_setkey (tfm, hash_tv[i].key, 126 crypto_digest_setkey(tfm, hash_tv[i].key,
119 hash_tv[i].ksize); 127 hash_tv[i].ksize);
120 } 128 }
121 crypto_digest_update (tfm, sg, 1); 129 crypto_digest_update(tfm, sg, 1);
122 crypto_digest_final (tfm, result); 130 crypto_digest_final(tfm, result);
123 131
124 hexdump (result, crypto_tfm_alg_digestsize (tfm)); 132 hexdump(result, crypto_tfm_alg_digestsize(tfm));
125 printk("%s\n", 133 printk("%s\n",
126 memcmp(result, hash_tv[i].digest, 134 memcmp(result, hash_tv[i].digest,
127 crypto_tfm_alg_digestsize(tfm)) ? "fail" : 135 crypto_tfm_alg_digestsize(tfm)) ?
128 "pass"); 136 "fail" : "pass");
129 } 137 }
130 138
131 printk ("testing %s across pages\n", algo); 139 printk("testing %s across pages\n", algo);
132 140
133 /* setup the dummy buffer first */ 141 /* setup the dummy buffer first */
134 memset(xbuf, 0, XBUFSIZE); 142 memset(xbuf, 0, XBUFSIZE);
135 143
136 j = 0; 144 j = 0;
137 for (i = 0; i < tcount; i++) { 145 for (i = 0; i < tcount; i++) {
138 if (hash_tv[i].np) { 146 if (hash_tv[i].np) {
139 j++; 147 j++;
140 printk ("test %u:\n", j); 148 printk("test %u:\n", j);
141 memset (result, 0, 64); 149 memset(result, 0, 64);
142 150
143 temp = 0; 151 temp = 0;
144 for (k = 0; k < hash_tv[i].np; k++) { 152 for (k = 0; k < hash_tv[i].np; k++) {
145 memcpy (&xbuf[IDX[k]], hash_tv[i].plaintext + temp, 153 memcpy(&xbuf[IDX[k]],
146 hash_tv[i].tap[k]); 154 hash_tv[i].plaintext + temp,
155 hash_tv[i].tap[k]);
147 temp += hash_tv[i].tap[k]; 156 temp += hash_tv[i].tap[k];
148 p = &xbuf[IDX[k]]; 157 p = &xbuf[IDX[k]];
149 sg[k].page = virt_to_page (p); 158 sg[k].page = virt_to_page(p);
150 sg[k].offset = offset_in_page (p); 159 sg[k].offset = offset_in_page(p);
151 sg[k].length = hash_tv[i].tap[k]; 160 sg[k].length = hash_tv[i].tap[k];
152 } 161 }
153 162
154 crypto_digest_digest (tfm, sg, hash_tv[i].np, result); 163 crypto_digest_digest(tfm, sg, hash_tv[i].np, result);
155 164
156 hexdump (result, crypto_tfm_alg_digestsize (tfm)); 165 hexdump(result, crypto_tfm_alg_digestsize(tfm));
157 printk("%s\n", 166 printk("%s\n",
158 memcmp(result, hash_tv[i].digest, 167 memcmp(result, hash_tv[i].digest,
159 crypto_tfm_alg_digestsize(tfm)) ? "fail" : 168 crypto_tfm_alg_digestsize(tfm)) ?
160 "pass"); 169 "fail" : "pass");
161 } 170 }
162 } 171 }
163 172
164 crypto_free_tfm (tfm); 173 crypto_free_tfm(tfm);
165} 174}
166 175
167 176
168#ifdef CONFIG_CRYPTO_HMAC 177#ifdef CONFIG_CRYPTO_HMAC
169 178
170static void 179static void test_hmac(char *algo, struct hmac_testvec *template,
171test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount) 180 unsigned int tcount)
172{ 181{
173 char *p; 182 char *p;
174 unsigned int i, j, k, temp; 183 unsigned int i, j, k, temp;
@@ -185,8 +194,8 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
185 } 194 }
186 195
187 printk("\ntesting hmac_%s\n", algo); 196 printk("\ntesting hmac_%s\n", algo);
188 197
189 tsize = sizeof (struct hmac_testvec); 198 tsize = sizeof(struct hmac_testvec);
190 tsize *= tcount; 199 tsize *= tcount;
191 if (tsize > TVMEMSIZE) { 200 if (tsize > TVMEMSIZE) {
192 printk("template (%u) too big for tvmem (%u)\n", tsize, 201 printk("template (%u) too big for tvmem (%u)\n", tsize,
@@ -195,7 +204,7 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
195 } 204 }
196 205
197 memcpy(tvmem, template, tsize); 206 memcpy(tvmem, template, tsize);
198 hmac_tv = (void *) tvmem; 207 hmac_tv = (void *)tvmem;
199 208
200 for (i = 0; i < tcount; i++) { 209 for (i = 0; i < tcount; i++) {
201 printk("test %u:\n", i + 1); 210 printk("test %u:\n", i + 1);
@@ -219,34 +228,35 @@ test_hmac(char *algo, struct hmac_testvec * template, unsigned int tcount)
219 printk("\ntesting hmac_%s across pages\n", algo); 228 printk("\ntesting hmac_%s across pages\n", algo);
220 229
221 memset(xbuf, 0, XBUFSIZE); 230 memset(xbuf, 0, XBUFSIZE);
222 231
223 j = 0; 232 j = 0;
224 for (i = 0; i < tcount; i++) { 233 for (i = 0; i < tcount; i++) {
225 if (hmac_tv[i].np) { 234 if (hmac_tv[i].np) {
226 j++; 235 j++;
227 printk ("test %u:\n",j); 236 printk("test %u:\n",j);
228 memset (result, 0, 64); 237 memset(result, 0, 64);
229 238
230 temp = 0; 239 temp = 0;
231 klen = hmac_tv[i].ksize; 240 klen = hmac_tv[i].ksize;
232 for (k = 0; k < hmac_tv[i].np; k++) { 241 for (k = 0; k < hmac_tv[i].np; k++) {
233 memcpy (&xbuf[IDX[k]], hmac_tv[i].plaintext + temp, 242 memcpy(&xbuf[IDX[k]],
234 hmac_tv[i].tap[k]); 243 hmac_tv[i].plaintext + temp,
244 hmac_tv[i].tap[k]);
235 temp += hmac_tv[i].tap[k]; 245 temp += hmac_tv[i].tap[k];
236 p = &xbuf[IDX[k]]; 246 p = &xbuf[IDX[k]];
237 sg[k].page = virt_to_page (p); 247 sg[k].page = virt_to_page(p);
238 sg[k].offset = offset_in_page (p); 248 sg[k].offset = offset_in_page(p);
239 sg[k].length = hmac_tv[i].tap[k]; 249 sg[k].length = hmac_tv[i].tap[k];
240 } 250 }
241 251
242 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg, hmac_tv[i].np, 252 crypto_hmac(tfm, hmac_tv[i].key, &klen, sg,
243 result); 253 hmac_tv[i].np, result);
244 hexdump(result, crypto_tfm_alg_digestsize(tfm)); 254 hexdump(result, crypto_tfm_alg_digestsize(tfm));
245 255
246 printk("%s\n", 256 printk("%s\n",
247 memcmp(result, hmac_tv[i].digest, 257 memcmp(result, hmac_tv[i].digest,
248 crypto_tfm_alg_digestsize(tfm)) ? "fail" : 258 crypto_tfm_alg_digestsize(tfm)) ?
249 "pass"); 259 "fail" : "pass");
250 } 260 }
251 } 261 }
252out: 262out:
@@ -255,8 +265,8 @@ out:
255 265
256#endif /* CONFIG_CRYPTO_HMAC */ 266#endif /* CONFIG_CRYPTO_HMAC */
257 267
258static void 268static void test_cipher(char *algo, int mode, int enc,
259test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, unsigned int tcount) 269 struct cipher_testvec *template, unsigned int tcount)
260{ 270{
261 unsigned int ret, i, j, k, temp; 271 unsigned int ret, i, j, k, temp;
262 unsigned int tsize; 272 unsigned int tsize;
@@ -265,22 +275,22 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
265 char *key; 275 char *key;
266 struct cipher_testvec *cipher_tv; 276 struct cipher_testvec *cipher_tv;
267 struct scatterlist sg[8]; 277 struct scatterlist sg[8];
268 char e[11], m[4]; 278 const char *e, *m;
269 279
270 if (enc == ENCRYPT) 280 if (enc == ENCRYPT)
271 strncpy(e, "encryption", 11); 281 e = "encryption";
272 else 282 else
273 strncpy(e, "decryption", 11); 283 e = "decryption";
274 if (mode == MODE_ECB) 284 if (mode == MODE_ECB)
275 strncpy(m, "ECB", 4); 285 m = "ECB";
276 else 286 else
277 strncpy(m, "CBC", 4); 287 m = "CBC";
278 288
279 printk("\ntesting %s %s %s \n", algo, m, e); 289 printk("\ntesting %s %s %s\n", algo, m, e);
280 290
281 tsize = sizeof (struct cipher_testvec); 291 tsize = sizeof (struct cipher_testvec);
282 tsize *= tcount; 292 tsize *= tcount;
283 293
284 if (tsize > TVMEMSIZE) { 294 if (tsize > TVMEMSIZE) {
285 printk("template (%u) too big for tvmem (%u)\n", tsize, 295 printk("template (%u) too big for tvmem (%u)\n", tsize,
286 TVMEMSIZE); 296 TVMEMSIZE);
@@ -288,112 +298,113 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
288 } 298 }
289 299
290 memcpy(tvmem, template, tsize); 300 memcpy(tvmem, template, tsize);
291 cipher_tv = (void *) tvmem; 301 cipher_tv = (void *)tvmem;
302
303 if (mode)
304 tfm = crypto_alloc_tfm(algo, 0);
305 else
306 tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);
292 307
293 if (mode)
294 tfm = crypto_alloc_tfm (algo, 0);
295 else
296 tfm = crypto_alloc_tfm (algo, CRYPTO_TFM_MODE_CBC);
297
298 if (tfm == NULL) { 308 if (tfm == NULL) {
299 printk("failed to load transform for %s %s\n", algo, m); 309 printk("failed to load transform for %s %s\n", algo, m);
300 return; 310 return;
301 } 311 }
302 312
303 j = 0; 313 j = 0;
304 for (i = 0; i < tcount; i++) { 314 for (i = 0; i < tcount; i++) {
305 if (!(cipher_tv[i].np)) { 315 if (!(cipher_tv[i].np)) {
306 j++; 316 j++;
307 printk("test %u (%d bit key):\n", 317 printk("test %u (%d bit key):\n",
308 j, cipher_tv[i].klen * 8); 318 j, cipher_tv[i].klen * 8);
309 319
310 tfm->crt_flags = 0; 320 tfm->crt_flags = 0;
311 if (cipher_tv[i].wk) 321 if (cipher_tv[i].wk)
312 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; 322 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
313 key = cipher_tv[i].key; 323 key = cipher_tv[i].key;
314 324
315 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); 325 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
316 if (ret) { 326 if (ret) {
317 printk("setkey() failed flags=%x\n", tfm->crt_flags); 327 printk("setkey() failed flags=%x\n", tfm->crt_flags);
318 328
319 if (!cipher_tv[i].fail) 329 if (!cipher_tv[i].fail)
320 goto out; 330 goto out;
321 } 331 }
322 332
323 p = cipher_tv[i].input; 333 p = cipher_tv[i].input;
324 sg[0].page = virt_to_page(p); 334 sg[0].page = virt_to_page(p);
325 sg[0].offset = offset_in_page(p); 335 sg[0].offset = offset_in_page(p);
326 sg[0].length = cipher_tv[i].ilen; 336 sg[0].length = cipher_tv[i].ilen;
327 337
328 if (!mode) { 338 if (!mode) {
329 crypto_cipher_set_iv(tfm, cipher_tv[i].iv, 339 crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
330 crypto_tfm_alg_ivsize (tfm)); 340 crypto_tfm_alg_ivsize(tfm));
331 } 341 }
332 342
333 if (enc) 343 if (enc)
334 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); 344 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
335 else 345 else
336 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); 346 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
337 347
338 348
339 if (ret) { 349 if (ret) {
340 printk("%s () failed flags=%x\n", e, tfm->crt_flags); 350 printk("%s () failed flags=%x\n", e, tfm->crt_flags);
341 goto out; 351 goto out;
342 } 352 }
343 353
344 q = kmap(sg[0].page) + sg[0].offset; 354 q = kmap(sg[0].page) + sg[0].offset;
345 hexdump(q, cipher_tv[i].rlen); 355 hexdump(q, cipher_tv[i].rlen);
346 356
347 printk("%s\n", 357 printk("%s\n",
348 memcmp(q, cipher_tv[i].result, cipher_tv[i].rlen) ? "fail" : 358 memcmp(q, cipher_tv[i].result,
349 "pass"); 359 cipher_tv[i].rlen) ? "fail" : "pass");
350 } 360 }
351 } 361 }
352 362
353 printk("\ntesting %s %s %s across pages (chunking) \n", algo, m, e); 363 printk("\ntesting %s %s %s across pages (chunking)\n", algo, m, e);
354 memset(xbuf, 0, XBUFSIZE); 364 memset(xbuf, 0, XBUFSIZE);
355 365
356 j = 0; 366 j = 0;
357 for (i = 0; i < tcount; i++) { 367 for (i = 0; i < tcount; i++) {
358 if (cipher_tv[i].np) { 368 if (cipher_tv[i].np) {
359 j++; 369 j++;
360 printk("test %u (%d bit key):\n", 370 printk("test %u (%d bit key):\n",
361 j, cipher_tv[i].klen * 8); 371 j, cipher_tv[i].klen * 8);
362 372
363 tfm->crt_flags = 0; 373 tfm->crt_flags = 0;
364 if (cipher_tv[i].wk) 374 if (cipher_tv[i].wk)
365 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY; 375 tfm->crt_flags |= CRYPTO_TFM_REQ_WEAK_KEY;
366 key = cipher_tv[i].key; 376 key = cipher_tv[i].key;
367 377
368 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen); 378 ret = crypto_cipher_setkey(tfm, key, cipher_tv[i].klen);
369 if (ret) { 379 if (ret) {
370 printk("setkey() failed flags=%x\n", tfm->crt_flags); 380 printk("setkey() failed flags=%x\n", tfm->crt_flags);
371 381
372 if (!cipher_tv[i].fail) 382 if (!cipher_tv[i].fail)
373 goto out; 383 goto out;
374 } 384 }
375 385
376 temp = 0; 386 temp = 0;
377 for (k = 0; k < cipher_tv[i].np; k++) { 387 for (k = 0; k < cipher_tv[i].np; k++) {
378 memcpy (&xbuf[IDX[k]], cipher_tv[i].input + temp, 388 memcpy(&xbuf[IDX[k]],
379 cipher_tv[i].tap[k]); 389 cipher_tv[i].input + temp,
390 cipher_tv[i].tap[k]);
380 temp += cipher_tv[i].tap[k]; 391 temp += cipher_tv[i].tap[k];
381 p = &xbuf[IDX[k]]; 392 p = &xbuf[IDX[k]];
382 sg[k].page = virt_to_page (p); 393 sg[k].page = virt_to_page(p);
383 sg[k].offset = offset_in_page (p); 394 sg[k].offset = offset_in_page(p);
384 sg[k].length = cipher_tv[i].tap[k]; 395 sg[k].length = cipher_tv[i].tap[k];
385 } 396 }
386 397
387 if (!mode) { 398 if (!mode) {
388 crypto_cipher_set_iv(tfm, cipher_tv[i].iv, 399 crypto_cipher_set_iv(tfm, cipher_tv[i].iv,
389 crypto_tfm_alg_ivsize (tfm)); 400 crypto_tfm_alg_ivsize(tfm));
390 } 401 }
391 402
392 if (enc) 403 if (enc)
393 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen); 404 ret = crypto_cipher_encrypt(tfm, sg, sg, cipher_tv[i].ilen);
394 else 405 else
395 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen); 406 ret = crypto_cipher_decrypt(tfm, sg, sg, cipher_tv[i].ilen);
396 407
397 if (ret) { 408 if (ret) {
398 printk("%s () failed flags=%x\n", e, tfm->crt_flags); 409 printk("%s () failed flags=%x\n", e, tfm->crt_flags);
399 goto out; 410 goto out;
@@ -404,9 +415,9 @@ test_cipher(char * algo, int mode, int enc, struct cipher_testvec * template, un
404 printk("page %u\n", k); 415 printk("page %u\n", k);
405 q = kmap(sg[k].page) + sg[k].offset; 416 q = kmap(sg[k].page) + sg[k].offset;
406 hexdump(q, cipher_tv[i].tap[k]); 417 hexdump(q, cipher_tv[i].tap[k]);
407 printk("%s\n", 418 printk("%s\n",
408 memcmp(q, cipher_tv[i].result + temp, 419 memcmp(q, cipher_tv[i].result + temp,
409 cipher_tv[i].tap[k]) ? "fail" : 420 cipher_tv[i].tap[k]) ? "fail" :
410 "pass"); 421 "pass");
411 temp += cipher_tv[i].tap[k]; 422 temp += cipher_tv[i].tap[k];
412 } 423 }
@@ -417,8 +428,169 @@ out:
417 crypto_free_tfm(tfm); 428 crypto_free_tfm(tfm);
418} 429}
419 430
420static void 431static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
421test_deflate(void) 432 int blen, int sec)
433{
434 struct scatterlist sg[8];
435 unsigned long start, end;
436 int bcount;
437 int ret;
438
439 sg[0].page = virt_to_page(p);
440 sg[0].offset = offset_in_page(p);
441 sg[0].length = blen;
442
443 for (start = jiffies, end = start + sec * HZ, bcount = 0;
444 time_before(jiffies, end); bcount++) {
445 if (enc)
446 ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
447 else
448 ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
449
450 if (ret)
451 return ret;
452 }
453
454 printk("%d operations in %d seconds (%ld bytes)\n",
455 bcount, sec, (long)bcount * blen);
456 return 0;
457}
458
459static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p,
460 int blen)
461{
462 struct scatterlist sg[8];
463 unsigned long cycles = 0;
464 int ret = 0;
465 int i;
466
467 sg[0].page = virt_to_page(p);
468 sg[0].offset = offset_in_page(p);
469 sg[0].length = blen;
470
471 local_bh_disable();
472 local_irq_disable();
473
474 /* Warm-up run. */
475 for (i = 0; i < 4; i++) {
476 if (enc)
477 ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
478 else
479 ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
480
481 if (ret)
482 goto out;
483 }
484
485 /* The real thing. */
486 for (i = 0; i < 8; i++) {
487 cycles_t start, end;
488
489 start = get_cycles();
490 if (enc)
491 ret = crypto_cipher_encrypt(tfm, sg, sg, blen);
492 else
493 ret = crypto_cipher_decrypt(tfm, sg, sg, blen);
494 end = get_cycles();
495
496 if (ret)
497 goto out;
498
499 cycles += end - start;
500 }
501
502out:
503 local_irq_enable();
504 local_bh_enable();
505
506 if (ret == 0)
507 printk("1 operation in %lu cycles (%d bytes)\n",
508 (cycles + 4) / 8, blen);
509
510 return ret;
511}
512
513static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec,
514 struct cipher_testvec *template,
515 unsigned int tcount, struct cipher_speed *speed)
516{
517 unsigned int ret, i, j, iv_len;
518 unsigned char *key, *p, iv[128];
519 struct crypto_tfm *tfm;
520 const char *e, *m;
521
522 if (enc == ENCRYPT)
523 e = "encryption";
524 else
525 e = "decryption";
526 if (mode == MODE_ECB)
527 m = "ECB";
528 else
529 m = "CBC";
530
531 printk("\ntesting speed of %s %s %s\n", algo, m, e);
532
533 if (mode)
534 tfm = crypto_alloc_tfm(algo, 0);
535 else
536 tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);
537
538 if (tfm == NULL) {
539 printk("failed to load transform for %s %s\n", algo, m);
540 return;
541 }
542
543 for (i = 0; speed[i].klen != 0; i++) {
544 if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) {
545 printk("template (%u) too big for tvmem (%u)\n",
546 speed[i].blen + speed[i].klen, TVMEMSIZE);
547 goto out;
548 }
549
550 printk("test %u (%d bit key, %d byte blocks): ", i,
551 speed[i].klen * 8, speed[i].blen);
552
553 memset(tvmem, 0xff, speed[i].klen + speed[i].blen);
554
555 /* set key, plain text and IV */
556 key = (unsigned char *)tvmem;
557 for (j = 0; j < tcount; j++) {
558 if (template[j].klen == speed[i].klen) {
559 key = template[j].key;
560 break;
561 }
562 }
563 p = (unsigned char *)tvmem + speed[i].klen;
564
565 ret = crypto_cipher_setkey(tfm, key, speed[i].klen);
566 if (ret) {
567 printk("setkey() failed flags=%x\n", tfm->crt_flags);
568 goto out;
569 }
570
571 if (!mode) {
572 iv_len = crypto_tfm_alg_ivsize(tfm);
573 memset(&iv, 0xff, iv_len);
574 crypto_cipher_set_iv(tfm, iv, iv_len);
575 }
576
577 if (sec)
578 ret = test_cipher_jiffies(tfm, enc, p, speed[i].blen,
579 sec);
580 else
581 ret = test_cipher_cycles(tfm, enc, p, speed[i].blen);
582
583 if (ret) {
584 printk("%s() failed flags=%x\n", e, tfm->crt_flags);
585 break;
586 }
587 }
588
589out:
590 crypto_free_tfm(tfm);
591}
592
593static void test_deflate(void)
422{ 594{
423 unsigned int i; 595 unsigned int i;
424 char result[COMP_BUF_SIZE]; 596 char result[COMP_BUF_SIZE];
@@ -436,7 +608,7 @@ test_deflate(void)
436 } 608 }
437 609
438 memcpy(tvmem, deflate_comp_tv_template, tsize); 610 memcpy(tvmem, deflate_comp_tv_template, tsize);
439 tv = (void *) tvmem; 611 tv = (void *)tvmem;
440 612
441 tfm = crypto_alloc_tfm("deflate", 0); 613 tfm = crypto_alloc_tfm("deflate", 0);
442 if (tfm == NULL) { 614 if (tfm == NULL) {
@@ -446,7 +618,7 @@ test_deflate(void)
446 618
447 for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) { 619 for (i = 0; i < DEFLATE_COMP_TEST_VECTORS; i++) {
448 int ilen, ret, dlen = COMP_BUF_SIZE; 620 int ilen, ret, dlen = COMP_BUF_SIZE;
449 621
450 printk("test %u:\n", i + 1); 622 printk("test %u:\n", i + 1);
451 memset(result, 0, sizeof (result)); 623 memset(result, 0, sizeof (result));
452 624
@@ -473,11 +645,11 @@ test_deflate(void)
473 } 645 }
474 646
475 memcpy(tvmem, deflate_decomp_tv_template, tsize); 647 memcpy(tvmem, deflate_decomp_tv_template, tsize);
476 tv = (void *) tvmem; 648 tv = (void *)tvmem;
477 649
478 for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) { 650 for (i = 0; i < DEFLATE_DECOMP_TEST_VECTORS; i++) {
479 int ilen, ret, dlen = COMP_BUF_SIZE; 651 int ilen, ret, dlen = COMP_BUF_SIZE;
480 652
481 printk("test %u:\n", i + 1); 653 printk("test %u:\n", i + 1);
482 memset(result, 0, sizeof (result)); 654 memset(result, 0, sizeof (result));
483 655
@@ -497,8 +669,7 @@ out:
497 crypto_free_tfm(tfm); 669 crypto_free_tfm(tfm);
498} 670}
499 671
500static void 672static void test_crc32c(void)
501test_crc32c(void)
502{ 673{
503#define NUMVEC 6 674#define NUMVEC 6
504#define VECSIZE 40 675#define VECSIZE 40
@@ -511,7 +682,7 @@ test_crc32c(void)
511 0xd579c862, 0xba979ad0, 0x2b29d913 682 0xd579c862, 0xba979ad0, 0x2b29d913
512 }; 683 };
513 static u32 tot_vec_results = 0x24c5d375; 684 static u32 tot_vec_results = 0x24c5d375;
514 685
515 struct scatterlist sg[NUMVEC]; 686 struct scatterlist sg[NUMVEC];
516 struct crypto_tfm *tfm; 687 struct crypto_tfm *tfm;
517 char *fmtdata = "testing crc32c initialized to %08x: %s\n"; 688 char *fmtdata = "testing crc32c initialized to %08x: %s\n";
@@ -525,18 +696,18 @@ test_crc32c(void)
525 printk("failed to load transform for crc32c\n"); 696 printk("failed to load transform for crc32c\n");
526 return; 697 return;
527 } 698 }
528 699
529 crypto_digest_init(tfm); 700 crypto_digest_init(tfm);
530 crypto_digest_final(tfm, (u8*)&crc); 701 crypto_digest_final(tfm, (u8*)&crc);
531 printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR"); 702 printk(fmtdata, crc, (crc == 0) ? "pass" : "ERROR");
532 703
533 /* 704 /*
534 * stuff test_vec with known values, simple incrementing 705 * stuff test_vec with known values, simple incrementing
535 * byte values. 706 * byte values.
536 */ 707 */
537 b = 0; 708 b = 0;
538 for (i = 0; i < NUMVEC; i++) { 709 for (i = 0; i < NUMVEC; i++) {
539 for (j = 0; j < VECSIZE; j++) 710 for (j = 0; j < VECSIZE; j++)
540 test_vec[i][j] = ++b; 711 test_vec[i][j] = ++b;
541 sg[i].page = virt_to_page(test_vec[i]); 712 sg[i].page = virt_to_page(test_vec[i]);
542 sg[i].offset = offset_in_page(test_vec[i]); 713 sg[i].offset = offset_in_page(test_vec[i]);
@@ -548,11 +719,11 @@ test_crc32c(void)
548 crypto_digest_final(tfm, (u8*)&crc); 719 crypto_digest_final(tfm, (u8*)&crc);
549 printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ? 720 printk("testing crc32c setkey returns %08x : %s\n", crc, (crc == (SEEDTESTVAL ^ ~(u32)0)) ?
550 "pass" : "ERROR"); 721 "pass" : "ERROR");
551 722
552 printk("testing crc32c using update/final:\n"); 723 printk("testing crc32c using update/final:\n");
553 724
554 pass = 1; /* assume all is well */ 725 pass = 1; /* assume all is well */
555 726
556 for (i = 0; i < NUMVEC; i++) { 727 for (i = 0; i < NUMVEC; i++) {
557 seed = ~(u32)0; 728 seed = ~(u32)0;
558 (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32)); 729 (void)crypto_digest_setkey(tfm, (const u8*)&seed, sizeof(u32));
@@ -591,66 +762,64 @@ test_crc32c(void)
591 printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results); 762 printk(" %08x:BAD, wanted %08x\n", crc, tot_vec_results);
592 pass = 0; 763 pass = 0;
593 } 764 }
594 765
595 printk("\n%s\n", pass ? "pass" : "ERROR"); 766 printk("\n%s\n", pass ? "pass" : "ERROR");
596 767
597 crypto_free_tfm(tfm); 768 crypto_free_tfm(tfm);
598 printk("crc32c test complete\n"); 769 printk("crc32c test complete\n");
599} 770}
600 771
601static void 772static void test_available(void)
602test_available(void)
603{ 773{
604 char **name = check; 774 char **name = check;
605 775
606 while (*name) { 776 while (*name) {
607 printk("alg %s ", *name); 777 printk("alg %s ", *name);
608 printk((crypto_alg_available(*name, 0)) ? 778 printk((crypto_alg_available(*name, 0)) ?
609 "found\n" : "not found\n"); 779 "found\n" : "not found\n");
610 name++; 780 name++;
611 } 781 }
612} 782}
613 783
614static void 784static void do_test(void)
615do_test(void)
616{ 785{
617 switch (mode) { 786 switch (mode) {
618 787
619 case 0: 788 case 0:
620 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS); 789 test_hash("md5", md5_tv_template, MD5_TEST_VECTORS);
621 790
622 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS); 791 test_hash("sha1", sha1_tv_template, SHA1_TEST_VECTORS);
623 792
624 //DES 793 //DES
625 test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS); 794 test_cipher ("des", MODE_ECB, ENCRYPT, des_enc_tv_template, DES_ENC_TEST_VECTORS);
626 test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS); 795 test_cipher ("des", MODE_ECB, DECRYPT, des_dec_tv_template, DES_DEC_TEST_VECTORS);
627 test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS); 796 test_cipher ("des", MODE_CBC, ENCRYPT, des_cbc_enc_tv_template, DES_CBC_ENC_TEST_VECTORS);
628 test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS); 797 test_cipher ("des", MODE_CBC, DECRYPT, des_cbc_dec_tv_template, DES_CBC_DEC_TEST_VECTORS);
629 798
630 //DES3_EDE 799 //DES3_EDE
631 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); 800 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
632 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 801 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
633 802
634 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 803 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
635 804
636 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 805 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
637 806
638 //BLOWFISH 807 //BLOWFISH
639 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); 808 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
640 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); 809 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
641 test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS); 810 test_cipher ("blowfish", MODE_CBC, ENCRYPT, bf_cbc_enc_tv_template, BF_CBC_ENC_TEST_VECTORS);
642 test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS); 811 test_cipher ("blowfish", MODE_CBC, DECRYPT, bf_cbc_dec_tv_template, BF_CBC_DEC_TEST_VECTORS);
643 812
644 //TWOFISH 813 //TWOFISH
645 test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS); 814 test_cipher ("twofish", MODE_ECB, ENCRYPT, tf_enc_tv_template, TF_ENC_TEST_VECTORS);
646 test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS); 815 test_cipher ("twofish", MODE_ECB, DECRYPT, tf_dec_tv_template, TF_DEC_TEST_VECTORS);
647 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); 816 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
648 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); 817 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
649 818
650 //SERPENT 819 //SERPENT
651 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); 820 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
652 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); 821 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
653 822
654 //TNEPRES 823 //TNEPRES
655 test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS); 824 test_cipher ("tnepres", MODE_ECB, ENCRYPT, tnepres_enc_tv_template, TNEPRES_ENC_TEST_VECTORS);
656 test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS); 825 test_cipher ("tnepres", MODE_ECB, DECRYPT, tnepres_dec_tv_template, TNEPRES_DEC_TEST_VECTORS);
@@ -662,7 +831,7 @@ do_test(void)
662 //CAST5 831 //CAST5
663 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS); 832 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS);
664 test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS); 833 test_cipher ("cast5", MODE_ECB, DECRYPT, cast5_dec_tv_template, CAST5_DEC_TEST_VECTORS);
665 834
666 //CAST6 835 //CAST6
667 test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS); 836 test_cipher ("cast6", MODE_ECB, ENCRYPT, cast6_enc_tv_template, CAST6_ENC_TEST_VECTORS);
668 test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS); 837 test_cipher ("cast6", MODE_ECB, DECRYPT, cast6_dec_tv_template, CAST6_DEC_TEST_VECTORS);
@@ -702,9 +871,9 @@ do_test(void)
702 test_crc32c(); 871 test_crc32c();
703#ifdef CONFIG_CRYPTO_HMAC 872#ifdef CONFIG_CRYPTO_HMAC
704 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); 873 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
705 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 874 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
706 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); 875 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
707#endif 876#endif
708 877
709 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); 878 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
710 break; 879 break;
@@ -726,17 +895,17 @@ do_test(void)
726 895
727 case 4: 896 case 4:
728 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS); 897 test_cipher ("des3_ede", MODE_ECB, ENCRYPT, des3_ede_enc_tv_template, DES3_EDE_ENC_TEST_VECTORS);
729 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS); 898 test_cipher ("des3_ede", MODE_ECB, DECRYPT, des3_ede_dec_tv_template, DES3_EDE_DEC_TEST_VECTORS);
730 break; 899 break;
731 900
732 case 5: 901 case 5:
733 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 902 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
734 break; 903 break;
735 904
736 case 6: 905 case 6:
737 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 906 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
738 break; 907 break;
739 908
740 case 7: 909 case 7:
741 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS); 910 test_cipher ("blowfish", MODE_ECB, ENCRYPT, bf_enc_tv_template, BF_ENC_TEST_VECTORS);
742 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS); 911 test_cipher ("blowfish", MODE_ECB, DECRYPT, bf_dec_tv_template, BF_DEC_TEST_VECTORS);
@@ -750,7 +919,7 @@ do_test(void)
750 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS); 919 test_cipher ("twofish", MODE_CBC, ENCRYPT, tf_cbc_enc_tv_template, TF_CBC_ENC_TEST_VECTORS);
751 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS); 920 test_cipher ("twofish", MODE_CBC, DECRYPT, tf_cbc_dec_tv_template, TF_CBC_DEC_TEST_VECTORS);
752 break; 921 break;
753 922
754 case 9: 923 case 9:
755 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS); 924 test_cipher ("serpent", MODE_ECB, ENCRYPT, serpent_enc_tv_template, SERPENT_ENC_TEST_VECTORS);
756 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS); 925 test_cipher ("serpent", MODE_ECB, DECRYPT, serpent_dec_tv_template, SERPENT_DEC_TEST_VECTORS);
@@ -758,13 +927,13 @@ do_test(void)
758 927
759 case 10: 928 case 10:
760 test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); 929 test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS);
761 test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); 930 test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS);
762 break; 931 break;
763 932
764 case 11: 933 case 11:
765 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS); 934 test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
766 break; 935 break;
767 936
768 case 12: 937 case 12:
769 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS); 938 test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
770 break; 939 break;
@@ -852,21 +1021,84 @@ do_test(void)
852 case 100: 1021 case 100:
853 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS); 1022 test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
854 break; 1023 break;
855 1024
856 case 101: 1025 case 101:
857 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS); 1026 test_hmac("sha1", hmac_sha1_tv_template, HMAC_SHA1_TEST_VECTORS);
858 break; 1027 break;
859 1028
860 case 102: 1029 case 102:
861 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS); 1030 test_hmac("sha256", hmac_sha256_tv_template, HMAC_SHA256_TEST_VECTORS);
862 break; 1031 break;
863 1032
864#endif 1033#endif
865 1034
1035 case 200:
1036 test_cipher_speed("aes", MODE_ECB, ENCRYPT, sec, NULL, 0,
1037 aes_speed_template);
1038 test_cipher_speed("aes", MODE_ECB, DECRYPT, sec, NULL, 0,
1039 aes_speed_template);
1040 test_cipher_speed("aes", MODE_CBC, ENCRYPT, sec, NULL, 0,
1041 aes_speed_template);
1042 test_cipher_speed("aes", MODE_CBC, DECRYPT, sec, NULL, 0,
1043 aes_speed_template);
1044 break;
1045
1046 case 201:
1047 test_cipher_speed("des3_ede", MODE_ECB, ENCRYPT, sec,
1048 des3_ede_enc_tv_template,
1049 DES3_EDE_ENC_TEST_VECTORS,
1050 des3_ede_speed_template);
1051 test_cipher_speed("des3_ede", MODE_ECB, DECRYPT, sec,
1052 des3_ede_dec_tv_template,
1053 DES3_EDE_DEC_TEST_VECTORS,
1054 des3_ede_speed_template);
1055 test_cipher_speed("des3_ede", MODE_CBC, ENCRYPT, sec,
1056 des3_ede_enc_tv_template,
1057 DES3_EDE_ENC_TEST_VECTORS,
1058 des3_ede_speed_template);
1059 test_cipher_speed("des3_ede", MODE_CBC, DECRYPT, sec,
1060 des3_ede_dec_tv_template,
1061 DES3_EDE_DEC_TEST_VECTORS,
1062 des3_ede_speed_template);
1063 break;
1064
1065 case 202:
1066 test_cipher_speed("twofish", MODE_ECB, ENCRYPT, sec, NULL, 0,
1067 twofish_speed_template);
1068 test_cipher_speed("twofish", MODE_ECB, DECRYPT, sec, NULL, 0,
1069 twofish_speed_template);
1070 test_cipher_speed("twofish", MODE_CBC, ENCRYPT, sec, NULL, 0,
1071 twofish_speed_template);
1072 test_cipher_speed("twofish", MODE_CBC, DECRYPT, sec, NULL, 0,
1073 twofish_speed_template);
1074 break;
1075
1076 case 203:
1077 test_cipher_speed("blowfish", MODE_ECB, ENCRYPT, sec, NULL, 0,
1078 blowfish_speed_template);
1079 test_cipher_speed("blowfish", MODE_ECB, DECRYPT, sec, NULL, 0,
1080 blowfish_speed_template);
1081 test_cipher_speed("blowfish", MODE_CBC, ENCRYPT, sec, NULL, 0,
1082 blowfish_speed_template);
1083 test_cipher_speed("blowfish", MODE_CBC, DECRYPT, sec, NULL, 0,
1084 blowfish_speed_template);
1085 break;
1086
1087 case 204:
1088 test_cipher_speed("des", MODE_ECB, ENCRYPT, sec, NULL, 0,
1089 des_speed_template);
1090 test_cipher_speed("des", MODE_ECB, DECRYPT, sec, NULL, 0,
1091 des_speed_template);
1092 test_cipher_speed("des", MODE_CBC, ENCRYPT, sec, NULL, 0,
1093 des_speed_template);
1094 test_cipher_speed("des", MODE_CBC, DECRYPT, sec, NULL, 0,
1095 des_speed_template);
1096 break;
1097
866 case 1000: 1098 case 1000:
867 test_available(); 1099 test_available();
868 break; 1100 break;
869 1101
870 default: 1102 default:
871 /* useful for debugging */ 1103 /* useful for debugging */
872 printk("not testing anything\n"); 1104 printk("not testing anything\n");
@@ -874,8 +1106,7 @@ do_test(void)
874 } 1106 }
875} 1107}
876 1108
877static int __init 1109static int __init init(void)
878init(void)
879{ 1110{
880 tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL); 1111 tvmem = kmalloc(TVMEMSIZE, GFP_KERNEL);
881 if (tvmem == NULL) 1112 if (tvmem == NULL)
@@ -904,6 +1135,9 @@ module_init(init);
904module_exit(fini); 1135module_exit(fini);
905 1136
906module_param(mode, int, 0); 1137module_param(mode, int, 0);
1138module_param(sec, uint, 0);
1139MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
1140 "(defaults to zero which uses CPU cycles instead)");
907 1141
908MODULE_LICENSE("GPL"); 1142MODULE_LICENSE("GPL");
909MODULE_DESCRIPTION("Quick & dirty crypto testing module"); 1143MODULE_DESCRIPTION("Quick & dirty crypto testing module");
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index a3097afae593..c01a0ce9b40a 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -9,10 +9,11 @@
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free 11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option) 12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version. 13 * any later version.
14 * 14 *
15 * 14 - 09 - 2003 Changes by Kartikey Mahendra Bhatt 15 * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net>
16 * 2003-09-14 Changes by Kartikey Mahendra Bhatt
16 * 17 *
17 */ 18 */
18#ifndef _CRYPTO_TCRYPT_H 19#ifndef _CRYPTO_TCRYPT_H
@@ -29,19 +30,19 @@ struct hash_testvec {
29 unsigned char psize; 30 unsigned char psize;
30 char digest[MAX_DIGEST_SIZE]; 31 char digest[MAX_DIGEST_SIZE];
31 unsigned char np; 32 unsigned char np;
32 unsigned char tap[MAX_TAP]; 33 unsigned char tap[MAX_TAP];
33 char key[128]; /* only used with keyed hash algorithms */ 34 char key[128]; /* only used with keyed hash algorithms */
34 unsigned char ksize; 35 unsigned char ksize;
35}; 36};
36 37
37struct hmac_testvec { 38struct hmac_testvec {
38 char key[128]; 39 char key[128];
39 unsigned char ksize; 40 unsigned char ksize;
40 char plaintext[128]; 41 char plaintext[128];
41 unsigned char psize; 42 unsigned char psize;
42 char digest[MAX_DIGEST_SIZE]; 43 char digest[MAX_DIGEST_SIZE];
43 unsigned char np; 44 unsigned char np;
44 unsigned char tap[MAX_TAP]; 45 unsigned char tap[MAX_TAP];
45}; 46};
46 47
47struct cipher_testvec { 48struct cipher_testvec {
@@ -55,7 +56,12 @@ struct cipher_testvec {
55 char result[48]; 56 char result[48];
56 unsigned char rlen; 57 unsigned char rlen;
57 int np; 58 int np;
58 unsigned char tap[MAX_TAP]; 59 unsigned char tap[MAX_TAP];
60};
61
62struct cipher_speed {
63 unsigned char klen;
64 unsigned int blen;
59}; 65};
60 66
61/* 67/*
@@ -155,7 +161,7 @@ static struct hash_testvec md5_tv_template[] = {
155#define SHA1_TEST_VECTORS 2 161#define SHA1_TEST_VECTORS 2
156 162
157static struct hash_testvec sha1_tv_template[] = { 163static struct hash_testvec sha1_tv_template[] = {
158 { 164 {
159 .plaintext = "abc", 165 .plaintext = "abc",
160 .psize = 3, 166 .psize = 3,
161 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 167 .digest = { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e,
@@ -175,8 +181,8 @@ static struct hash_testvec sha1_tv_template[] = {
175 */ 181 */
176#define SHA256_TEST_VECTORS 2 182#define SHA256_TEST_VECTORS 2
177 183
178static struct hash_testvec sha256_tv_template[] = { 184static struct hash_testvec sha256_tv_template[] = {
179 { 185 {
180 .plaintext = "abc", 186 .plaintext = "abc",
181 .psize = 3, 187 .psize = 3,
182 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 188 .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
@@ -201,7 +207,7 @@ static struct hash_testvec sha256_tv_template[] = {
201#define SHA384_TEST_VECTORS 4 207#define SHA384_TEST_VECTORS 4
202 208
203static struct hash_testvec sha384_tv_template[] = { 209static struct hash_testvec sha384_tv_template[] = {
204 { 210 {
205 .plaintext= "abc", 211 .plaintext= "abc",
206 .psize = 3, 212 .psize = 3,
207 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, 213 .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
@@ -221,7 +227,7 @@ static struct hash_testvec sha384_tv_template[] = {
221 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b}, 227 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b},
222 }, { 228 }, {
223 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" 229 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
224 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 230 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
225 .psize = 112, 231 .psize = 112,
226 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 232 .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
227 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 233 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
@@ -250,7 +256,7 @@ static struct hash_testvec sha384_tv_template[] = {
250#define SHA512_TEST_VECTORS 4 256#define SHA512_TEST_VECTORS 4
251 257
252static struct hash_testvec sha512_tv_template[] = { 258static struct hash_testvec sha512_tv_template[] = {
253 { 259 {
254 .plaintext = "abc", 260 .plaintext = "abc",
255 .psize = 3, 261 .psize = 3,
256 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 262 .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
@@ -303,14 +309,14 @@ static struct hash_testvec sha512_tv_template[] = {
303 309
304 310
305/* 311/*
306 * WHIRLPOOL test vectors from Whirlpool package 312 * WHIRLPOOL test vectors from Whirlpool package
307 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE 313 * by Vincent Rijmen and Paulo S. L. M. Barreto as part of the NESSIE
308 * submission 314 * submission
309 */ 315 */
310#define WP512_TEST_VECTORS 8 316#define WP512_TEST_VECTORS 8
311 317
312static struct hash_testvec wp512_tv_template[] = { 318static struct hash_testvec wp512_tv_template[] = {
313 { 319 {
314 .plaintext = "", 320 .plaintext = "",
315 .psize = 0, 321 .psize = 0,
316 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, 322 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
@@ -348,13 +354,13 @@ static struct hash_testvec wp512_tv_template[] = {
348 }, { 354 }, {
349 .plaintext = "message digest", 355 .plaintext = "message digest",
350 .psize = 14, 356 .psize = 14,
351 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 357 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
352 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 358 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
353 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 359 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
354 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 360 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
355 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 361 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
356 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6, 362 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6,
357 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33, 363 0x92, 0xED, 0x92, 0x00, 0x52, 0x83, 0x8F, 0x33,
358 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E }, 364 0x62, 0xE8, 0x6D, 0xBD, 0x37, 0xA8, 0x90, 0x3E },
359 }, { 365 }, {
360 .plaintext = "abcdefghijklmnopqrstuvwxyz", 366 .plaintext = "abcdefghijklmnopqrstuvwxyz",
@@ -394,7 +400,7 @@ static struct hash_testvec wp512_tv_template[] = {
394 }, { 400 }, {
395 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 401 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
396 .psize = 32, 402 .psize = 32,
397 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 403 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
398 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 404 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
399 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 405 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
400 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69, 406 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
@@ -408,7 +414,7 @@ static struct hash_testvec wp512_tv_template[] = {
408#define WP384_TEST_VECTORS 8 414#define WP384_TEST_VECTORS 8
409 415
410static struct hash_testvec wp384_tv_template[] = { 416static struct hash_testvec wp384_tv_template[] = {
411 { 417 {
412 .plaintext = "", 418 .plaintext = "",
413 .psize = 0, 419 .psize = 0,
414 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, 420 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
@@ -440,11 +446,11 @@ static struct hash_testvec wp384_tv_template[] = {
440 }, { 446 }, {
441 .plaintext = "message digest", 447 .plaintext = "message digest",
442 .psize = 14, 448 .psize = 14,
443 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 449 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
444 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 450 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
445 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 451 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
446 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B, 452 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B,
447 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1, 453 0x84, 0x21, 0x55, 0x76, 0x59, 0xEF, 0x55, 0xC1,
448 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 }, 454 0x06, 0xB4, 0xB5, 0x2A, 0xC5, 0xA4, 0xAA, 0xA6 },
449 }, { 455 }, {
450 .plaintext = "abcdefghijklmnopqrstuvwxyz", 456 .plaintext = "abcdefghijklmnopqrstuvwxyz",
@@ -478,7 +484,7 @@ static struct hash_testvec wp384_tv_template[] = {
478 }, { 484 }, {
479 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 485 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
480 .psize = 32, 486 .psize = 32,
481 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 487 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
482 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 488 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
483 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 489 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
484 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69, 490 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69,
@@ -490,7 +496,7 @@ static struct hash_testvec wp384_tv_template[] = {
490#define WP256_TEST_VECTORS 8 496#define WP256_TEST_VECTORS 8
491 497
492static struct hash_testvec wp256_tv_template[] = { 498static struct hash_testvec wp256_tv_template[] = {
493 { 499 {
494 .plaintext = "", 500 .plaintext = "",
495 .psize = 0, 501 .psize = 0,
496 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66, 502 .digest = { 0x19, 0xFA, 0x61, 0xD7, 0x55, 0x22, 0xA4, 0x66,
@@ -516,9 +522,9 @@ static struct hash_testvec wp256_tv_template[] = {
516 }, { 522 }, {
517 .plaintext = "message digest", 523 .plaintext = "message digest",
518 .psize = 14, 524 .psize = 14,
519 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6, 525 .digest = { 0x37, 0x8C, 0x84, 0xA4, 0x12, 0x6E, 0x2D, 0xC6,
520 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC, 526 0xE5, 0x6D, 0xCC, 0x74, 0x58, 0x37, 0x7A, 0xAC,
521 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C, 527 0x83, 0x8D, 0x00, 0x03, 0x22, 0x30, 0xF5, 0x3C,
522 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B }, 528 0xE1, 0xF5, 0x70, 0x0C, 0x0F, 0xFB, 0x4D, 0x3B },
523 }, { 529 }, {
524 .plaintext = "abcdefghijklmnopqrstuvwxyz", 530 .plaintext = "abcdefghijklmnopqrstuvwxyz",
@@ -546,7 +552,7 @@ static struct hash_testvec wp256_tv_template[] = {
546 }, { 552 }, {
547 .plaintext = "abcdbcdecdefdefgefghfghighijhijk", 553 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
548 .psize = 32, 554 .psize = 32,
549 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61, 555 .digest = { 0x2A, 0x98, 0x7E, 0xA4, 0x0F, 0x91, 0x70, 0x61,
550 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48, 556 0xF5, 0xD6, 0xF0, 0xA0, 0xE4, 0x64, 0x4F, 0x48,
551 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62, 557 0x8A, 0x7A, 0x5A, 0x52, 0xDE, 0xEE, 0x65, 0x62,
552 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 }, 558 0x07, 0xC5, 0x62, 0xF9, 0x88, 0xE9, 0x5C, 0x69 },
@@ -554,7 +560,7 @@ static struct hash_testvec wp256_tv_template[] = {
554}; 560};
555 561
556/* 562/*
557 * TIGER test vectors from Tiger website 563 * TIGER test vectors from Tiger website
558 */ 564 */
559#define TGR192_TEST_VECTORS 6 565#define TGR192_TEST_VECTORS 6
560 566
@@ -693,7 +699,7 @@ static struct hash_testvec tgr128_tv_template[] = {
693#define HMAC_MD5_TEST_VECTORS 7 699#define HMAC_MD5_TEST_VECTORS 7
694 700
695static struct hmac_testvec hmac_md5_tv_template[] = 701static struct hmac_testvec hmac_md5_tv_template[] =
696{ 702{
697 { 703 {
698 .key = { [0 ... 15] = 0x0b }, 704 .key = { [0 ... 15] = 0x0b },
699 .ksize = 16, 705 .ksize = 16,
@@ -756,7 +762,7 @@ static struct hmac_testvec hmac_md5_tv_template[] =
756 */ 762 */
757#define HMAC_SHA1_TEST_VECTORS 7 763#define HMAC_SHA1_TEST_VECTORS 7
758 764
759static struct hmac_testvec hmac_sha1_tv_template[] = { 765static struct hmac_testvec hmac_sha1_tv_template[] = {
760 { 766 {
761 .key = { [0 ... 19] = 0x0b }, 767 .key = { [0 ... 19] = 0x0b },
762 .ksize = 20, 768 .ksize = 20,
@@ -766,11 +772,11 @@ static struct hmac_testvec hmac_sha1_tv_template[] = {
766 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1, 772 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, 0xf1,
767 0x46, 0xbe }, 773 0x46, 0xbe },
768 }, { 774 }, {
769 .key = { 'J', 'e', 'f', 'e' }, 775 .key = { 'J', 'e', 'f', 'e' },
770 .ksize = 4, 776 .ksize = 4,
771 .plaintext = "what do ya want for nothing?", 777 .plaintext = "what do ya want for nothing?",
772 .psize = 28, 778 .psize = 28,
773 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74, 779 .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, 0xd2, 0x74,
774 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 }, 780 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, 0x25, 0x9a, 0x7c, 0x79 },
775 .np = 2, 781 .np = 2,
776 .tap = { 14, 14 } 782 .tap = { 14, 14 }
@@ -779,30 +785,30 @@ static struct hmac_testvec hmac_sha1_tv_template[] = {
779 .ksize = 20, 785 .ksize = 20,
780 .plaintext = { [0 ... 49] = 0xdd }, 786 .plaintext = { [0 ... 49] = 0xdd },
781 .psize = 50, 787 .psize = 50,
782 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3, 788 .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, 0x91, 0xa3,
783 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 }, 789 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, 0x63, 0xf1, 0x75, 0xd3 },
784 }, { 790 }, {
785 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 791 .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
786 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 792 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
787 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 }, 793 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 },
788 .ksize = 25, 794 .ksize = 25,
789 .plaintext = { [0 ... 49] = 0xcd }, 795 .plaintext = { [0 ... 49] = 0xcd },
790 .psize = 50, 796 .psize = 50,
791 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84, 797 .digest = { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, 0xbc, 0x84,
792 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda }, 798 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, 0x2d, 0x72, 0x35, 0xda },
793 }, { 799 }, {
794 .key = { [0 ... 19] = 0x0c }, 800 .key = { [0 ... 19] = 0x0c },
795 .ksize = 20, 801 .ksize = 20,
796 .plaintext = "Test With Truncation", 802 .plaintext = "Test With Truncation",
797 .psize = 20, 803 .psize = 20,
798 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2, 804 .digest = { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
799 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 }, 805 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, 0x4a, 0x9a, 0x5a, 0x04 },
800 }, { 806 }, {
801 .key = { [0 ... 79] = 0xaa }, 807 .key = { [0 ... 79] = 0xaa },
802 .ksize = 80, 808 .ksize = 80,
803 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First", 809 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
804 .psize = 54, 810 .psize = 54,
805 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70, 811 .digest = { 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e, 0x95, 0x70,
806 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 }, 812 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55, 0xed, 0x40, 0x21, 0x12 },
807 }, { 813 }, {
808 .key = { [0 ... 79] = 0xaa }, 814 .key = { [0 ... 79] = 0xaa },
@@ -810,7 +816,7 @@ static struct hmac_testvec hmac_sha1_tv_template[] = {
810 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One " 816 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
811 "Block-Size Data", 817 "Block-Size Data",
812 .psize = 73, 818 .psize = 73,
813 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b, 819 .digest = { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, 0x6d, 0x6b,
814 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 }, 820 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91 },
815 }, 821 },
816}; 822};
@@ -1011,7 +1017,7 @@ static struct cipher_testvec des_enc_tv_template[] = {
1011 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b }, 1017 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1012 .rlen = 32, 1018 .rlen = 32,
1013 .np = 3, 1019 .np = 3,
1014 .tap = { 14, 10, 8 } 1020 .tap = { 14, 10, 8 }
1015 }, { 1021 }, {
1016 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1022 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1017 .klen = 8, 1023 .klen = 8,
@@ -1024,7 +1030,7 @@ static struct cipher_testvec des_enc_tv_template[] = {
1024 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 }, 1030 0xb4, 0x99, 0x26, 0xf7, 0x1f, 0xe1, 0xd4, 0x90 },
1025 .rlen = 24, 1031 .rlen = 24,
1026 .np = 4, 1032 .np = 4,
1027 .tap = { 2, 1, 3, 18 } 1033 .tap = { 2, 1, 3, 18 }
1028 }, { 1034 }, {
1029 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1035 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1030 .klen = 8, 1036 .klen = 8,
@@ -1035,7 +1041,7 @@ static struct cipher_testvec des_enc_tv_template[] = {
1035 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b }, 1041 0xf7, 0x9c, 0x89, 0x2a, 0x33, 0x8f, 0x4a, 0x8b },
1036 .rlen = 16, 1042 .rlen = 16,
1037 .np = 5, 1043 .np = 5,
1038 .tap = { 2, 2, 2, 2, 8 } 1044 .tap = { 2, 2, 2, 2, 8 }
1039 }, { 1045 }, {
1040 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1046 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1041 .klen = 8, 1047 .klen = 8,
@@ -1044,7 +1050,7 @@ static struct cipher_testvec des_enc_tv_template[] = {
1044 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d }, 1050 .result = { 0xc9, 0x57, 0x44, 0x25, 0x6a, 0x5e, 0xd3, 0x1d },
1045 .rlen = 8, 1051 .rlen = 8,
1046 .np = 8, 1052 .np = 8,
1047 .tap = { 1, 1, 1, 1, 1, 1, 1, 1 } 1053 .tap = { 1, 1, 1, 1, 1, 1, 1, 1 }
1048 }, 1054 },
1049}; 1055};
1050 1056
@@ -1057,7 +1063,7 @@ static struct cipher_testvec des_dec_tv_template[] = {
1057 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 }, 1063 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xe7 },
1058 .rlen = 8, 1064 .rlen = 8,
1059 }, { /* Sbox test from NBS */ 1065 }, { /* Sbox test from NBS */
1060 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 }, 1066 .key = { 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57 },
1061 .klen = 8, 1067 .klen = 8,
1062 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b }, 1068 .input = { 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b },
1063 .ilen = 8, 1069 .ilen = 8,
@@ -1092,19 +1098,19 @@ static struct cipher_testvec des_cbc_enc_tv_template[] = {
1092 { /* From OpenSSL */ 1098 { /* From OpenSSL */
1093 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 1099 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1094 .klen = 8, 1100 .klen = 8,
1095 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1101 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1096 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1102 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1097 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1103 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1098 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1104 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1099 .ilen = 24, 1105 .ilen = 24,
1100 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1106 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1101 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1107 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1102 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1108 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1103 .rlen = 24, 1109 .rlen = 24,
1104 }, { /* FIPS Pub 81 */ 1110 }, { /* FIPS Pub 81 */
1105 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1111 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1106 .klen = 8, 1112 .klen = 8,
1107 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }, 1113 .iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef },
1108 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 }, 1114 .input = { 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74 },
1109 .ilen = 8, 1115 .ilen = 8,
1110 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c }, 1116 .result = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
@@ -1117,7 +1123,7 @@ static struct cipher_testvec des_cbc_enc_tv_template[] = {
1117 .ilen = 8, 1123 .ilen = 8,
1118 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1124 .result = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1119 .rlen = 8, 1125 .rlen = 8,
1120 }, { 1126 }, {
1121 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1127 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1122 .klen = 8, 1128 .klen = 8,
1123 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1129 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
@@ -1125,18 +1131,18 @@ static struct cipher_testvec des_cbc_enc_tv_template[] = {
1125 .ilen = 8, 1131 .ilen = 8,
1126 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1132 .result = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1127 .rlen = 8, 1133 .rlen = 8,
1128 }, { /* Copy of openssl vector for chunk testing */ 1134 }, { /* Copy of openssl vector for chunk testing */
1129 /* From OpenSSL */ 1135 /* From OpenSSL */
1130 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 1136 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef},
1131 .klen = 8, 1137 .klen = 8,
1132 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, 1138 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10},
1133 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1139 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1134 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1140 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1135 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1141 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1136 .ilen = 24, 1142 .ilen = 24,
1137 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4, 1143 .result = { 0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
1138 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb, 1144 0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
1139 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 }, 1145 0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68 },
1140 .rlen = 24, 1146 .rlen = 24,
1141 .np = 2, 1147 .np = 2,
1142 .tap = { 13, 11 } 1148 .tap = { 13, 11 }
@@ -1155,24 +1161,24 @@ static struct cipher_testvec des_cbc_dec_tv_template[] = {
1155 }, { 1161 }, {
1156 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1162 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1157 .klen = 8, 1163 .klen = 8,
1158 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c }, 1164 .iv = { 0xe5, 0xc7, 0xcd, 0xde, 0x87, 0x2b, 0xf2, 0x7c },
1159 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1165 .input = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1160 .ilen = 8, 1166 .ilen = 8,
1161 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 }, 1167 .result = { 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20 },
1162 .rlen = 8, 1168 .rlen = 8,
1163 }, { 1169 }, {
1164 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1170 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1165 .klen = 8, 1171 .klen = 8,
1166 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1172 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1167 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1173 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1168 .ilen = 8, 1174 .ilen = 8,
1169 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 }, 1175 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1170 .rlen = 8, 1176 .rlen = 8,
1171 }, { /* Copy of above, for chunk testing */ 1177 }, { /* Copy of above, for chunk testing */
1172 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1178 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1173 .klen = 8, 1179 .klen = 8,
1174 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f }, 1180 .iv = { 0x43, 0xe9, 0x34, 0x00, 0x8c, 0x38, 0x9c, 0x0f },
1175 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 }, 1181 .input = { 0x68, 0x37, 0x88, 0x49, 0x9a, 0x7c, 0x05, 0xf6 },
1176 .ilen = 8, 1182 .ilen = 8,
1177 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 }, 1183 .result = { 0x66, 0x6f, 0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20 },
1178 .rlen = 8, 1184 .rlen = 8,
@@ -1276,7 +1282,7 @@ static struct cipher_testvec bf_enc_tv_template[] = {
1276 .ilen = 8, 1282 .ilen = 8,
1277 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 }, 1283 .result = { 0xe8, 0x7a, 0x24, 0x4e, 0x2c, 0xc8, 0x5e, 0x82 },
1278 .rlen = 8, 1284 .rlen = 8,
1279 }, { /* Vary the keylength... */ 1285 }, { /* Vary the keylength... */
1280 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1286 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1281 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f }, 1287 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1282 .klen = 16, 1288 .klen = 16,
@@ -1297,9 +1303,9 @@ static struct cipher_testvec bf_enc_tv_template[] = {
1297 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1303 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1298 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f, 1304 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1299 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1305 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1300 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1306 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1301 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1307 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1302 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1308 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1303 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 1309 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1304 .klen = 56, 1310 .klen = 56,
1305 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1311 .input = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
@@ -1331,7 +1337,7 @@ static struct cipher_testvec bf_dec_tv_template[] = {
1331 .ilen = 8, 1337 .ilen = 8,
1332 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1338 .result = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1333 .rlen = 8, 1339 .rlen = 8,
1334 }, { /* Vary the keylength... */ 1340 }, { /* Vary the keylength... */
1335 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1341 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1336 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f }, 1342 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f },
1337 .klen = 16, 1343 .klen = 16,
@@ -1352,9 +1358,9 @@ static struct cipher_testvec bf_dec_tv_template[] = {
1352 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 1358 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
1353 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f, 1359 0x78, 0x69, 0x5a, 0x4b, 0x3c, 0x2d, 0x1e, 0x0f,
1354 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1360 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1355 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, 1361 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f,
1356 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, 1362 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76,
1357 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e, 1363 0x1f, 0x1f, 0x1f, 0x1f, 0x0e, 0x0e, 0x0e, 0x0e,
1358 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, 1364 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1359 .klen = 56, 1365 .klen = 56,
1360 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 }, 1366 .input = { 0xc0, 0x45, 0x04, 0x01, 0x2e, 0x4e, 0x1f, 0x53 },
@@ -1369,7 +1375,7 @@ static struct cipher_testvec bf_cbc_enc_tv_template[] = {
1369 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 1375 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1370 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 }, 1376 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1371 .klen = 16, 1377 .klen = 16,
1372 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1378 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1373 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 1379 .input = { 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
1374 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 1380 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
1375 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 1381 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
@@ -1388,7 +1394,7 @@ static struct cipher_testvec bf_cbc_dec_tv_template[] = {
1388 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 1394 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
1389 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 }, 1395 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
1390 .klen = 16, 1396 .klen = 16,
1391 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 }, 1397 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
1392 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6, 1398 .input = { 0x6b, 0x77, 0xb4, 0xd6, 0x30, 0x06, 0xde, 0xe6,
1393 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93, 1399 0x05, 0xb1, 0x56, 0xe2, 0x74, 0x03, 0x97, 0x93,
1394 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9, 1400 0x58, 0xde, 0xb9, 0xe7, 0x15, 0x46, 0x16, 0xd9,
@@ -1490,7 +1496,7 @@ static struct cipher_testvec tf_cbc_enc_tv_template[] = {
1490 .key = { [0 ... 15] = 0x00 }, 1496 .key = { [0 ... 15] = 0x00 },
1491 .klen = 16, 1497 .klen = 16,
1492 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 1498 .iv = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1493 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1499 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1494 .input = { [0 ... 15] = 0x00 }, 1500 .input = { [0 ... 15] = 0x00 },
1495 .ilen = 16, 1501 .ilen = 16,
1496 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e, 1502 .result = { 0xd4, 0x91, 0xdb, 0x16, 0xe7, 0xb1, 0xc3, 0x9e,
@@ -1528,7 +1534,7 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1528 .klen = 16, 1534 .klen = 16,
1529 .iv = { [0 ... 15] = 0x00 }, 1535 .iv = { [0 ... 15] = 0x00 },
1530 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 1536 .input = { 0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32,
1531 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a }, 1537 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a },
1532 .ilen = 16, 1538 .ilen = 16,
1533 .result = { [0 ... 15] = 0x00 }, 1539 .result = { [0 ... 15] = 0x00 },
1534 .rlen = 16, 1540 .rlen = 16,
@@ -1578,8 +1584,7 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = {
1578#define TNEPRES_ENC_TEST_VECTORS 4 1584#define TNEPRES_ENC_TEST_VECTORS 4
1579#define TNEPRES_DEC_TEST_VECTORS 4 1585#define TNEPRES_DEC_TEST_VECTORS 4
1580 1586
1581static struct cipher_testvec serpent_enc_tv_template[] = 1587static struct cipher_testvec serpent_enc_tv_template[] = {
1582{
1583 { 1588 {
1584 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1589 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1585 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1590 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
@@ -1620,8 +1625,7 @@ static struct cipher_testvec serpent_enc_tv_template[] =
1620 }, 1625 },
1621}; 1626};
1622 1627
1623static struct cipher_testvec tnepres_enc_tv_template[] = 1628static struct cipher_testvec tnepres_enc_tv_template[] = {
1624{
1625 { /* KeySize=128, PT=0, I=1 */ 1629 { /* KeySize=128, PT=0, I=1 */
1626 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1630 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1631 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -1629,7 +1633,7 @@ static struct cipher_testvec tnepres_enc_tv_template[] =
1629 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1633 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1630 .klen = 16, 1634 .klen = 16,
1631 .ilen = 16, 1635 .ilen = 16,
1632 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05, 1636 .result = { 0x49, 0xaf, 0xbf, 0xad, 0x9d, 0x5a, 0x34, 0x05,
1633 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd }, 1637 0x2c, 0xd8, 0xff, 0xa5, 0x98, 0x6b, 0xd2, 0xdd },
1634 .rlen = 16, 1638 .rlen = 16,
1635 }, { /* KeySize=192, PT=0, I=1 */ 1639 }, { /* KeySize=192, PT=0, I=1 */
@@ -1640,7 +1644,7 @@ static struct cipher_testvec tnepres_enc_tv_template[] =
1640 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1644 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1645 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1642 .ilen = 16, 1646 .ilen = 16,
1643 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68, 1647 .result = { 0xe7, 0x8e, 0x54, 0x02, 0xc7, 0x19, 0x55, 0x68,
1644 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 }, 1648 0xac, 0x36, 0x78, 0xf7, 0xa3, 0xf6, 0x0c, 0x66 },
1645 .rlen = 16, 1649 .rlen = 16,
1646 }, { /* KeySize=256, PT=0, I=1 */ 1650 }, { /* KeySize=256, PT=0, I=1 */
@@ -1652,7 +1656,7 @@ static struct cipher_testvec tnepres_enc_tv_template[] =
1652 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1656 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 1657 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
1654 .ilen = 16, 1658 .ilen = 16,
1655 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb, 1659 .result = { 0xab, 0xed, 0x96, 0xe7, 0x66, 0xbf, 0x28, 0xcb,
1656 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 }, 1660 0xc0, 0xeb, 0xd2, 0x1a, 0x82, 0xef, 0x08, 0x19 },
1657 .rlen = 16, 1661 .rlen = 16,
1658 }, { /* KeySize=256, I=257 */ 1662 }, { /* KeySize=256, I=257 */
@@ -1664,15 +1668,14 @@ static struct cipher_testvec tnepres_enc_tv_template[] =
1664 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 1668 .input = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
1665 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }, 1669 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 },
1666 .ilen = 16, 1670 .ilen = 16,
1667 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b, 1671 .result = { 0x5c, 0xe7, 0x1c, 0x70, 0xd2, 0x88, 0x2e, 0x5b,
1668 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde }, 1672 0xb8, 0x32, 0xe4, 0x33, 0xf8, 0x9f, 0x26, 0xde },
1669 .rlen = 16, 1673 .rlen = 16,
1670 }, 1674 },
1671}; 1675};
1672 1676
1673 1677
1674static struct cipher_testvec serpent_dec_tv_template[] = 1678static struct cipher_testvec serpent_dec_tv_template[] = {
1675{
1676 { 1679 {
1677 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47, 1680 .input = { 0x12, 0x07, 0xfc, 0xce, 0x9b, 0xd0, 0xd6, 0x47,
1678 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 }, 1681 0x6a, 0xe9, 0x8f, 0xbe, 0xd1, 0x43, 0xa0, 0xe2 },
@@ -1713,8 +1716,7 @@ static struct cipher_testvec serpent_dec_tv_template[] =
1713 }, 1716 },
1714}; 1717};
1715 1718
1716static struct cipher_testvec tnepres_dec_tv_template[] = 1719static struct cipher_testvec tnepres_dec_tv_template[] = {
1717{
1718 { 1720 {
1719 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97, 1721 .input = { 0x41, 0xcc, 0x6b, 0x31, 0x59, 0x31, 0x45, 0x97,
1720 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 }, 1722 0x6d, 0x6f, 0xbb, 0x38, 0x4b, 0x37, 0x21, 0x28 },
@@ -1726,7 +1728,7 @@ static struct cipher_testvec tnepres_dec_tv_template[] =
1726 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1728 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1727 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1729 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1728 .klen = 16, 1730 .klen = 16,
1729 .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47, 1731 .input = { 0xea, 0xf4, 0xd7, 0xfc, 0xd8, 0x01, 0x34, 0x47,
1730 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e }, 1732 0x81, 0x45, 0x0b, 0xfa, 0x0c, 0xd6, 0xad, 0x6e },
1731 .ilen = 16, 1733 .ilen = 16,
1732 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1734 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -1738,7 +1740,7 @@ static struct cipher_testvec tnepres_dec_tv_template[] =
1738 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 1740 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1739 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, 1741 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1740 .klen = 32, 1742 .klen = 32,
1741 .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49, 1743 .input = { 0x64, 0xa9, 0x1a, 0x37, 0xed, 0x9f, 0xe7, 0x49,
1742 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee }, 1744 0xa8, 0x4e, 0x76, 0xd6, 0xf5, 0x0d, 0x78, 0xee },
1743 .ilen = 16, 1745 .ilen = 16,
1744 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1746 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -1747,7 +1749,7 @@ static struct cipher_testvec tnepres_dec_tv_template[] =
1747 }, { /* KeySize=128, I=121 */ 1749 }, { /* KeySize=128, I=121 */
1748 .key = { [15] = 0x80 }, 1750 .key = { [15] = 0x80 },
1749 .klen = 16, 1751 .klen = 16,
1750 .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06, 1752 .input = { 0x3d, 0xda, 0xbf, 0xc0, 0x06, 0xda, 0xab, 0x06,
1751 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 }, 1753 0x46, 0x2a, 0xf4, 0xef, 0x81, 0x54, 0x4e, 0x26 },
1752 .ilen = 16, 1754 .ilen = 16,
1753 .result = { [0 ... 15] = 0x00 }, 1755 .result = { [0 ... 15] = 0x00 },
@@ -1760,58 +1762,56 @@ static struct cipher_testvec tnepres_dec_tv_template[] =
1760#define CAST6_ENC_TEST_VECTORS 3 1762#define CAST6_ENC_TEST_VECTORS 3
1761#define CAST6_DEC_TEST_VECTORS 3 1763#define CAST6_DEC_TEST_VECTORS 3
1762 1764
1763static struct cipher_testvec cast6_enc_tv_template[] = 1765static struct cipher_testvec cast6_enc_tv_template[] = {
1764{
1765 { 1766 {
1766 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1767 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1767 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d }, 1768 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1768 .klen = 16, 1769 .klen = 16,
1769 .input = { [0 ... 15] = 0x00 }, 1770 .input = { [0 ... 15] = 0x00 },
1770 .ilen = 16, 1771 .ilen = 16,
1771 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1772 .result = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
1772 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b }, 1773 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1773 .rlen = 16, 1774 .rlen = 16,
1774 }, { 1775 }, {
1775 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1776 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1776 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1777 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1777 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 }, 1778 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1778 .klen = 24, 1779 .klen = 24,
1779 .input = { [0 ... 15] = 0x00 }, 1780 .input = { [0 ... 15] = 0x00 },
1780 .ilen = 16, 1781 .ilen = 16,
1781 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1782 .result = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
1782 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 }, 1783 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1783 .rlen = 16, 1784 .rlen = 16,
1784 }, { 1785 }, {
1785 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1786 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1786 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1787 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1787 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46, 1788 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
1788 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1789 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
1789 .klen = 32, 1790 .klen = 32,
1790 .input = { [0 ... 15] = 0x00 }, 1791 .input = { [0 ... 15] = 0x00 },
1791 .ilen = 16, 1792 .ilen = 16,
1792 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1793 .result = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
1793 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa }, 1794 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1794 .rlen = 16, 1795 .rlen = 16,
1795 }, 1796 },
1796}; 1797};
1797 1798
1798static struct cipher_testvec cast6_dec_tv_template[] = 1799static struct cipher_testvec cast6_dec_tv_template[] = {
1799{
1800 { 1800 {
1801 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1801 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1802 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d }, 1802 0x0a, 0xf7, 0x56, 0x47, 0xf2, 0x9f, 0x61, 0x5d },
1803 .klen = 16, 1803 .klen = 16,
1804 .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20, 1804 .input = { 0xc8, 0x42, 0xa0, 0x89, 0x72, 0xb4, 0x3d, 0x20,
1805 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b }, 1805 0x83, 0x6c, 0x91, 0xd1, 0xb7, 0x53, 0x0f, 0x6b },
1806 .ilen = 16, 1806 .ilen = 16,
1807 .result = { [0 ... 15] = 0x00 }, 1807 .result = { [0 ... 15] = 0x00 },
1808 .rlen = 16, 1808 .rlen = 16,
1809 }, { 1809 }, {
1810 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1810 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1811 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1811 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1812 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 }, 1812 0xba, 0xc7, 0x7a, 0x77, 0x17, 0x94, 0x28, 0x63 },
1813 .klen = 24, 1813 .klen = 24,
1814 .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb, 1814 .input = { 0x1b, 0x38, 0x6c, 0x02, 0x10, 0xdc, 0xad, 0xcb,
1815 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 }, 1815 0xdd, 0x0e, 0x41, 0xaa, 0x08, 0xa7, 0xa7, 0xe8 },
1816 .ilen = 16, 1816 .ilen = 16,
1817 .result = { [0 ... 15] = 0x00 }, 1817 .result = { [0 ... 15] = 0x00 },
@@ -1820,9 +1820,9 @@ static struct cipher_testvec cast6_dec_tv_template[] =
1820 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c, 1820 .key = { 0x23, 0x42, 0xbb, 0x9e, 0xfa, 0x38, 0x54, 0x2c,
1821 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98, 1821 0xbe, 0xd0, 0xac, 0x83, 0x94, 0x0a, 0xc2, 0x98,
1822 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46, 1822 0x8d, 0x7c, 0x47, 0xce, 0x26, 0x49, 0x08, 0x46,
1823 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 }, 1823 0x1c, 0xc1, 0xb5, 0x13, 0x7a, 0xe6, 0xb6, 0x04 },
1824 .klen = 32, 1824 .klen = 32,
1825 .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9, 1825 .input = { 0x4f, 0x6a, 0x20, 0x38, 0x28, 0x68, 0x97, 0xb9,
1826 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa }, 1826 0xc9, 0x87, 0x01, 0x36, 0x55, 0x33, 0x17, 0xfa },
1827 .ilen = 16, 1827 .ilen = 16,
1828 .result = { [0 ... 15] = 0x00 }, 1828 .result = { [0 ... 15] = 0x00 },
@@ -1837,9 +1837,9 @@ static struct cipher_testvec cast6_dec_tv_template[] =
1837#define AES_ENC_TEST_VECTORS 3 1837#define AES_ENC_TEST_VECTORS 3
1838#define AES_DEC_TEST_VECTORS 3 1838#define AES_DEC_TEST_VECTORS 3
1839 1839
1840static struct cipher_testvec aes_enc_tv_template[] = { 1840static struct cipher_testvec aes_enc_tv_template[] = {
1841 { /* From FIPS-197 */ 1841 { /* From FIPS-197 */
1842 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1842 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1843 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1843 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1844 .klen = 16, 1844 .klen = 16,
1845 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1845 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
@@ -1853,7 +1853,7 @@ static struct cipher_testvec aes_enc_tv_template[] = {
1853 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 1853 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1854 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, 1854 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
1855 .klen = 24, 1855 .klen = 24,
1856 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1856 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1857 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1857 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1858 .ilen = 16, 1858 .ilen = 16,
1859 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 1859 .result = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
@@ -1865,7 +1865,7 @@ static struct cipher_testvec aes_enc_tv_template[] = {
1865 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 1865 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
1866 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, 1866 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
1867 .klen = 32, 1867 .klen = 32,
1868 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1868 .input = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1869 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1869 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1870 .ilen = 16, 1870 .ilen = 16,
1871 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 1871 .result = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
@@ -1874,9 +1874,9 @@ static struct cipher_testvec aes_enc_tv_template[] = {
1874 }, 1874 },
1875}; 1875};
1876 1876
1877static struct cipher_testvec aes_dec_tv_template[] = { 1877static struct cipher_testvec aes_dec_tv_template[] = {
1878 { /* From FIPS-197 */ 1878 { /* From FIPS-197 */
1879 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1879 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, 1880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
1881 .klen = 16, 1881 .klen = 16,
1882 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 1882 .input = { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
@@ -1893,8 +1893,8 @@ static struct cipher_testvec aes_dec_tv_template[] = {
1893 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 1893 .input = { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
1894 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 }, 1894 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 },
1895 .ilen = 16, 1895 .ilen = 16,
1896 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1896 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1897 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1897 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1898 .rlen = 16, 1898 .rlen = 16,
1899 }, { 1899 }, {
1900 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 1900 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -1905,7 +1905,7 @@ static struct cipher_testvec aes_dec_tv_template[] = {
1905 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 1905 .input = { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
1906 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 }, 1906 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 },
1907 .ilen = 16, 1907 .ilen = 16,
1908 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 1908 .result = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
1909 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, 1909 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
1910 .rlen = 16, 1910 .rlen = 16,
1911 }, 1911 },
@@ -1915,8 +1915,7 @@ static struct cipher_testvec aes_dec_tv_template[] = {
1915#define CAST5_ENC_TEST_VECTORS 3 1915#define CAST5_ENC_TEST_VECTORS 3
1916#define CAST5_DEC_TEST_VECTORS 3 1916#define CAST5_DEC_TEST_VECTORS 3
1917 1917
1918static struct cipher_testvec cast5_enc_tv_template[] = 1918static struct cipher_testvec cast5_enc_tv_template[] = {
1919{
1920 { 1919 {
1921 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 1920 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1922 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a }, 1921 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
@@ -1943,8 +1942,7 @@ static struct cipher_testvec cast5_enc_tv_template[] =
1943 }, 1942 },
1944}; 1943};
1945 1944
1946static struct cipher_testvec cast5_dec_tv_template[] = 1945static struct cipher_testvec cast5_dec_tv_template[] = {
1947{
1948 { 1946 {
1949 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78, 1947 .key = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
1950 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a }, 1948 0x23, 0x45, 0x67, 0x89, 0x34, 0x56, 0x78, 0x9a },
@@ -1971,14 +1969,13 @@ static struct cipher_testvec cast5_dec_tv_template[] =
1971 }, 1969 },
1972}; 1970};
1973 1971
1974/* 1972/*
1975 * ARC4 test vectors from OpenSSL 1973 * ARC4 test vectors from OpenSSL
1976 */ 1974 */
1977#define ARC4_ENC_TEST_VECTORS 7 1975#define ARC4_ENC_TEST_VECTORS 7
1978#define ARC4_DEC_TEST_VECTORS 7 1976#define ARC4_DEC_TEST_VECTORS 7
1979 1977
1980static struct cipher_testvec arc4_enc_tv_template[] = 1978static struct cipher_testvec arc4_enc_tv_template[] = {
1981{
1982 { 1979 {
1983 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 1980 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
1984 .klen = 8, 1981 .klen = 8,
@@ -2044,8 +2041,7 @@ static struct cipher_testvec arc4_enc_tv_template[] =
2044 }, 2041 },
2045}; 2042};
2046 2043
2047static struct cipher_testvec arc4_dec_tv_template[] = 2044static struct cipher_testvec arc4_dec_tv_template[] = {
2048{
2049 { 2045 {
2050 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }, 2046 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef },
2051 .klen = 8, 2047 .klen = 8,
@@ -2111,14 +2107,13 @@ static struct cipher_testvec arc4_dec_tv_template[] =
2111 }, 2107 },
2112}; 2108};
2113 2109
2114/* 2110/*
2115 * TEA test vectors 2111 * TEA test vectors
2116 */ 2112 */
2117#define TEA_ENC_TEST_VECTORS 4 2113#define TEA_ENC_TEST_VECTORS 4
2118#define TEA_DEC_TEST_VECTORS 4 2114#define TEA_DEC_TEST_VECTORS 4
2119 2115
2120static struct cipher_testvec tea_enc_tv_template[] = 2116static struct cipher_testvec tea_enc_tv_template[] = {
2121{
2122 { 2117 {
2123 .key = { [0 ... 15] = 0x00 }, 2118 .key = { [0 ... 15] = 0x00 },
2124 .klen = 16, 2119 .klen = 16,
@@ -2138,31 +2133,30 @@ static struct cipher_testvec tea_enc_tv_template[] =
2138 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2133 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2139 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2134 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2140 .klen = 16, 2135 .klen = 16,
2141 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2136 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2142 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2137 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2143 .ilen = 16, 2138 .ilen = 16,
2144 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e, 2139 .result = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
2145 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 }, 2140 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2146 .rlen = 16, 2141 .rlen = 16,
2147 }, { 2142 }, {
2148 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2143 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2149 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2144 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2150 .klen = 16, 2145 .klen = 16,
2151 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2146 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2152 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2147 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2153 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2148 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2154 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2149 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2155 .ilen = 32, 2150 .ilen = 32,
2156 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47, 2151 .result = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2157 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2152 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2158 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2153 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2159 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 }, 2154 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2160 .rlen = 32, 2155 .rlen = 32,
2161 } 2156 }
2162}; 2157};
2163 2158
2164static struct cipher_testvec tea_dec_tv_template[] = 2159static struct cipher_testvec tea_dec_tv_template[] = {
2165{
2166 { 2160 {
2167 .key = { [0 ... 15] = 0x00 }, 2161 .key = { [0 ... 15] = 0x00 },
2168 .klen = 16, 2162 .klen = 16,
@@ -2183,9 +2177,9 @@ static struct cipher_testvec tea_dec_tv_template[] =
2183 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2177 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2184 .klen = 16, 2178 .klen = 16,
2185 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e, 2179 .input = { 0xbe, 0x7a, 0xbb, 0x81, 0x95, 0x2d, 0x1f, 0x1e,
2186 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 }, 2180 0xdd, 0x89, 0xa1, 0x25, 0x04, 0x21, 0xdf, 0x95 },
2187 .ilen = 16, 2181 .ilen = 16,
2188 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2182 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2189 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2183 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2190 .rlen = 16, 2184 .rlen = 16,
2191 }, { 2185 }, {
@@ -2193,26 +2187,25 @@ static struct cipher_testvec tea_dec_tv_template[] =
2193 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2187 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2194 .klen = 16, 2188 .klen = 16,
2195 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47, 2189 .input = { 0xe0, 0x4d, 0x5d, 0x3c, 0xb7, 0x8c, 0x36, 0x47,
2196 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8, 2190 0x94, 0x18, 0x95, 0x91, 0xa9, 0xfc, 0x49, 0xf8,
2197 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a, 2191 0x44, 0xd1, 0x2d, 0xc2, 0x99, 0xb8, 0x08, 0x2a,
2198 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 }, 2192 0x07, 0x89, 0x73, 0xc2, 0x45, 0x92, 0xc6, 0x90 },
2199 .ilen = 32, 2193 .ilen = 32,
2200 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2194 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2201 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2195 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2202 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2196 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2203 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2197 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2204 .rlen = 32, 2198 .rlen = 32,
2205 } 2199 }
2206}; 2200};
2207 2201
2208/* 2202/*
2209 * XTEA test vectors 2203 * XTEA test vectors
2210 */ 2204 */
2211#define XTEA_ENC_TEST_VECTORS 4 2205#define XTEA_ENC_TEST_VECTORS 4
2212#define XTEA_DEC_TEST_VECTORS 4 2206#define XTEA_DEC_TEST_VECTORS 4
2213 2207
2214static struct cipher_testvec xtea_enc_tv_template[] = 2208static struct cipher_testvec xtea_enc_tv_template[] = {
2215{
2216 { 2209 {
2217 .key = { [0 ... 15] = 0x00 }, 2210 .key = { [0 ... 15] = 0x00 },
2218 .klen = 16, 2211 .klen = 16,
@@ -2232,31 +2225,30 @@ static struct cipher_testvec xtea_enc_tv_template[] =
2232 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2225 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2233 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2226 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2234 .klen = 16, 2227 .klen = 16,
2235 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2228 .input = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2236 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2229 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2237 .ilen = 16, 2230 .ilen = 16,
2238 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2231 .result = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2239 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, 2232 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2240 .rlen = 16, 2233 .rlen = 16,
2241 }, { 2234 }, {
2242 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2235 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2243 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2236 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2244 .klen = 16, 2237 .klen = 16,
2245 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2238 .input = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2246 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2239 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2247 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2240 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2248 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2241 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2249 .ilen = 32, 2242 .ilen = 32,
2250 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2243 .result = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2251 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2244 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2252 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2245 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2253 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, 2246 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2254 .rlen = 32, 2247 .rlen = 32,
2255 } 2248 }
2256}; 2249};
2257 2250
2258static struct cipher_testvec xtea_dec_tv_template[] = 2251static struct cipher_testvec xtea_dec_tv_template[] = {
2259{
2260 { 2252 {
2261 .key = { [0 ... 15] = 0x00 }, 2253 .key = { [0 ... 15] = 0x00 },
2262 .klen = 16, 2254 .klen = 16,
@@ -2276,24 +2268,24 @@ static struct cipher_testvec xtea_dec_tv_template[] =
2276 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25, 2268 .key = { 0x09, 0x65, 0x43, 0x11, 0x66, 0x44, 0x39, 0x25,
2277 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e }, 2269 0x51, 0x3a, 0x16, 0x10, 0x0a, 0x08, 0x12, 0x6e },
2278 .klen = 16, 2270 .klen = 16,
2279 .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea, 2271 .input = { 0xe2, 0x04, 0xdb, 0xf2, 0x89, 0x85, 0x9e, 0xea,
2280 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c }, 2272 0x61, 0x35, 0xaa, 0xed, 0xb5, 0xcb, 0x71, 0x2c },
2281 .ilen = 16, 2273 .ilen = 16,
2282 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74, 2274 .result = { 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x5f, 0x74,
2283 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 }, 2275 0x65, 0x73, 0x74, 0x5f, 0x76, 0x65, 0x63, 0x74 },
2284 .rlen = 16, 2276 .rlen = 16,
2285 }, { 2277 }, {
2286 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c, 2278 .key = { 0x4d, 0x76, 0x32, 0x17, 0x05, 0x3f, 0x75, 0x2c,
2287 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f }, 2279 0x5d, 0x04, 0x16, 0x36, 0x15, 0x72, 0x63, 0x2f },
2288 .klen = 16, 2280 .klen = 16,
2289 .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1, 2281 .input = { 0x0b, 0x03, 0xcd, 0x8a, 0xbe, 0x95, 0xfd, 0xb1,
2290 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4, 2282 0xc1, 0x44, 0x91, 0x0b, 0xa5, 0xc9, 0x1b, 0xb4,
2291 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f, 2283 0xa9, 0xda, 0x1e, 0x9e, 0xb1, 0x3e, 0x2a, 0x8f,
2292 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 }, 2284 0xea, 0xa5, 0x6a, 0x85, 0xd1, 0xf4, 0xa8, 0xa5 },
2293 .ilen = 32, 2285 .ilen = 32,
2294 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67, 2286 .result = { 0x54, 0x65, 0x61, 0x20, 0x69, 0x73, 0x20, 0x67,
2295 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 2287 0x6f, 0x6f, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20,
2296 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72, 2288 0x79, 0x6f, 0x75, 0x21, 0x21, 0x21, 0x20, 0x72,
2297 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 }, 2289 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x21, 0x21, 0x21 },
2298 .rlen = 32, 2290 .rlen = 32,
2299 } 2291 }
@@ -2305,9 +2297,9 @@ static struct cipher_testvec xtea_dec_tv_template[] =
2305#define KHAZAD_ENC_TEST_VECTORS 5 2297#define KHAZAD_ENC_TEST_VECTORS 5
2306#define KHAZAD_DEC_TEST_VECTORS 5 2298#define KHAZAD_DEC_TEST_VECTORS 5
2307 2299
2308static struct cipher_testvec khazad_enc_tv_template[] = { 2300static struct cipher_testvec khazad_enc_tv_template[] = {
2309 { 2301 {
2310 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2302 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2303 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2312 .klen = 16, 2304 .klen = 16,
2313 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2305 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -2351,9 +2343,9 @@ static struct cipher_testvec khazad_enc_tv_template[] = {
2351 }, 2343 },
2352}; 2344};
2353 2345
2354static struct cipher_testvec khazad_dec_tv_template[] = { 2346static struct cipher_testvec khazad_dec_tv_template[] = {
2355 { 2347 {
2356 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2348 .key = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2358 .klen = 16, 2350 .klen = 16,
2359 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f }, 2351 .input = { 0X49, 0Xa4, 0Xce, 0X32, 0Xac, 0X19, 0X0e, 0X3f },
@@ -2697,8 +2689,7 @@ static struct comp_testvec deflate_decomp_tv_template[] = {
2697 */ 2689 */
2698#define MICHAEL_MIC_TEST_VECTORS 6 2690#define MICHAEL_MIC_TEST_VECTORS 6
2699 2691
2700static struct hash_testvec michael_mic_tv_template[] = 2692static struct hash_testvec michael_mic_tv_template[] = {
2701{
2702 { 2693 {
2703 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 2694 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
2704 .ksize = 8, 2695 .ksize = 8,
@@ -2743,4 +2734,88 @@ static struct hash_testvec michael_mic_tv_template[] =
2743 } 2734 }
2744}; 2735};
2745 2736
2737/*
2738 * Cipher speed tests
2739 */
2740static struct cipher_speed aes_speed_template[] = {
2741 { .klen = 16, .blen = 16, },
2742 { .klen = 16, .blen = 64, },
2743 { .klen = 16, .blen = 256, },
2744 { .klen = 16, .blen = 1024, },
2745 { .klen = 16, .blen = 8192, },
2746 { .klen = 24, .blen = 16, },
2747 { .klen = 24, .blen = 64, },
2748 { .klen = 24, .blen = 256, },
2749 { .klen = 24, .blen = 1024, },
2750 { .klen = 24, .blen = 8192, },
2751 { .klen = 32, .blen = 16, },
2752 { .klen = 32, .blen = 64, },
2753 { .klen = 32, .blen = 256, },
2754 { .klen = 32, .blen = 1024, },
2755 { .klen = 32, .blen = 8192, },
2756
2757 /* End marker */
2758 { .klen = 0, .blen = 0, }
2759};
2760
2761static struct cipher_speed des3_ede_speed_template[] = {
2762 { .klen = 24, .blen = 16, },
2763 { .klen = 24, .blen = 64, },
2764 { .klen = 24, .blen = 256, },
2765 { .klen = 24, .blen = 1024, },
2766 { .klen = 24, .blen = 8192, },
2767
2768 /* End marker */
2769 { .klen = 0, .blen = 0, }
2770};
2771
2772static struct cipher_speed twofish_speed_template[] = {
2773 { .klen = 16, .blen = 16, },
2774 { .klen = 16, .blen = 64, },
2775 { .klen = 16, .blen = 256, },
2776 { .klen = 16, .blen = 1024, },
2777 { .klen = 16, .blen = 8192, },
2778 { .klen = 24, .blen = 16, },
2779 { .klen = 24, .blen = 64, },
2780 { .klen = 24, .blen = 256, },
2781 { .klen = 24, .blen = 1024, },
2782 { .klen = 24, .blen = 8192, },
2783 { .klen = 32, .blen = 16, },
2784 { .klen = 32, .blen = 64, },
2785 { .klen = 32, .blen = 256, },
2786 { .klen = 32, .blen = 1024, },
2787 { .klen = 32, .blen = 8192, },
2788
2789 /* End marker */
2790 { .klen = 0, .blen = 0, }
2791};
2792
2793static struct cipher_speed blowfish_speed_template[] = {
2794 /* Don't support blowfish keys > 256 bit in this test */
2795 { .klen = 8, .blen = 16, },
2796 { .klen = 8, .blen = 64, },
2797 { .klen = 8, .blen = 256, },
2798 { .klen = 8, .blen = 1024, },
2799 { .klen = 8, .blen = 8192, },
2800 { .klen = 32, .blen = 16, },
2801 { .klen = 32, .blen = 64, },
2802 { .klen = 32, .blen = 256, },
2803 { .klen = 32, .blen = 1024, },
2804 { .klen = 32, .blen = 8192, },
2805
2806 /* End marker */
2807 { .klen = 0, .blen = 0, }
2808};
2809
2810static struct cipher_speed des_speed_template[] = {
2811 { .klen = 8, .blen = 16, },
2812 { .klen = 8, .blen = 64, },
2813 { .klen = 8, .blen = 256, },
2814 { .klen = 8, .blen = 1024, },
2815 { .klen = 8, .blen = 8192, },
2816
2817 /* End marker */
2818 { .klen = 0, .blen = 0, }
2819};
2820
2746#endif /* _CRYPTO_TCRYPT_H */ 2821#endif /* _CRYPTO_TCRYPT_H */
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 43722af90bdd..c3fac7fd555e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -270,10 +270,9 @@ int bus_add_device(struct device * dev)
270 270
271 if (bus) { 271 if (bus) {
272 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); 272 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
273 error = device_attach(dev); 273 device_attach(dev);
274 klist_add_tail(&bus->klist_devices, &dev->knode_bus); 274 klist_add_tail(&bus->klist_devices, &dev->knode_bus);
275 if (error >= 0) 275 error = device_add_attrs(bus, dev);
276 error = device_add_attrs(bus, dev);
277 if (!error) { 276 if (!error) {
278 sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); 277 sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
279 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus"); 278 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
diff --git a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
index 638db06de2be..3410b4d294b9 100644
--- a/drivers/block/as-iosched.c
+++ b/drivers/block/as-iosched.c
@@ -1871,20 +1871,22 @@ static int as_init_queue(request_queue_t *q, elevator_t *e)
1871 if (!arq_pool) 1871 if (!arq_pool)
1872 return -ENOMEM; 1872 return -ENOMEM;
1873 1873
1874 ad = kmalloc(sizeof(*ad), GFP_KERNEL); 1874 ad = kmalloc_node(sizeof(*ad), GFP_KERNEL, q->node);
1875 if (!ad) 1875 if (!ad)
1876 return -ENOMEM; 1876 return -ENOMEM;
1877 memset(ad, 0, sizeof(*ad)); 1877 memset(ad, 0, sizeof(*ad));
1878 1878
1879 ad->q = q; /* Identify what queue the data belongs to */ 1879 ad->q = q; /* Identify what queue the data belongs to */
1880 1880
1881 ad->hash = kmalloc(sizeof(struct list_head)*AS_HASH_ENTRIES,GFP_KERNEL); 1881 ad->hash = kmalloc_node(sizeof(struct list_head)*AS_HASH_ENTRIES,
1882 GFP_KERNEL, q->node);
1882 if (!ad->hash) { 1883 if (!ad->hash) {
1883 kfree(ad); 1884 kfree(ad);
1884 return -ENOMEM; 1885 return -ENOMEM;
1885 } 1886 }
1886 1887
1887 ad->arq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, arq_pool); 1888 ad->arq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
1889 mempool_free_slab, arq_pool, q->node);
1888 if (!ad->arq_pool) { 1890 if (!ad->arq_pool) {
1889 kfree(ad->hash); 1891 kfree(ad->hash);
1890 kfree(ad); 1892 kfree(ad);
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
index 7f79f3dd0165..4bc2fea73273 100644
--- a/drivers/block/deadline-iosched.c
+++ b/drivers/block/deadline-iosched.c
@@ -711,18 +711,20 @@ static int deadline_init_queue(request_queue_t *q, elevator_t *e)
711 if (!drq_pool) 711 if (!drq_pool)
712 return -ENOMEM; 712 return -ENOMEM;
713 713
714 dd = kmalloc(sizeof(*dd), GFP_KERNEL); 714 dd = kmalloc_node(sizeof(*dd), GFP_KERNEL, q->node);
715 if (!dd) 715 if (!dd)
716 return -ENOMEM; 716 return -ENOMEM;
717 memset(dd, 0, sizeof(*dd)); 717 memset(dd, 0, sizeof(*dd));
718 718
719 dd->hash = kmalloc(sizeof(struct list_head)*DL_HASH_ENTRIES,GFP_KERNEL); 719 dd->hash = kmalloc_node(sizeof(struct list_head)*DL_HASH_ENTRIES,
720 GFP_KERNEL, q->node);
720 if (!dd->hash) { 721 if (!dd->hash) {
721 kfree(dd); 722 kfree(dd);
722 return -ENOMEM; 723 return -ENOMEM;
723 } 724 }
724 725
725 dd->drq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, drq_pool); 726 dd->drq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
727 mempool_free_slab, drq_pool, q->node);
726 if (!dd->drq_pool) { 728 if (!dd->drq_pool) {
727 kfree(dd->hash); 729 kfree(dd->hash);
728 kfree(dd); 730 kfree(dd);
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index 53f7d846b747..47fd3659a061 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -40,7 +40,7 @@ static inline int major_to_index(int major)
40 40
41#ifdef CONFIG_PROC_FS 41#ifdef CONFIG_PROC_FS
42/* get block device names in somewhat random order */ 42/* get block device names in somewhat random order */
43int get_blkdev_list(char *p) 43int get_blkdev_list(char *p, int used)
44{ 44{
45 struct blk_major_name *n; 45 struct blk_major_name *n;
46 int i, len; 46 int i, len;
@@ -49,10 +49,18 @@ int get_blkdev_list(char *p)
49 49
50 down(&block_subsys_sem); 50 down(&block_subsys_sem);
51 for (i = 0; i < ARRAY_SIZE(major_names); i++) { 51 for (i = 0; i < ARRAY_SIZE(major_names); i++) {
52 for (n = major_names[i]; n; n = n->next) 52 for (n = major_names[i]; n; n = n->next) {
53 /*
54 * If the curent string plus the 5 extra characters
55 * in the line would run us off the page, then we're done
56 */
57 if ((len + used + strlen(n->name) + 5) >= PAGE_SIZE)
58 goto page_full;
53 len += sprintf(p+len, "%3d %s\n", 59 len += sprintf(p+len, "%3d %s\n",
54 n->major, n->name); 60 n->major, n->name);
61 }
55 } 62 }
63page_full:
56 up(&block_subsys_sem); 64 up(&block_subsys_sem);
57 65
58 return len; 66 return len;
@@ -582,10 +590,16 @@ struct seq_operations diskstats_op = {
582 .show = diskstats_show 590 .show = diskstats_show
583}; 591};
584 592
585
586struct gendisk *alloc_disk(int minors) 593struct gendisk *alloc_disk(int minors)
587{ 594{
588 struct gendisk *disk = kmalloc(sizeof(struct gendisk), GFP_KERNEL); 595 return alloc_disk_node(minors, -1);
596}
597
598struct gendisk *alloc_disk_node(int minors, int node_id)
599{
600 struct gendisk *disk;
601
602 disk = kmalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
589 if (disk) { 603 if (disk) {
590 memset(disk, 0, sizeof(struct gendisk)); 604 memset(disk, 0, sizeof(struct gendisk));
591 if (!init_disk_stats(disk)) { 605 if (!init_disk_stats(disk)) {
@@ -594,7 +608,7 @@ struct gendisk *alloc_disk(int minors)
594 } 608 }
595 if (minors > 1) { 609 if (minors > 1) {
596 int size = (minors - 1) * sizeof(struct hd_struct *); 610 int size = (minors - 1) * sizeof(struct hd_struct *);
597 disk->part = kmalloc(size, GFP_KERNEL); 611 disk->part = kmalloc_node(size, GFP_KERNEL, node_id);
598 if (!disk->part) { 612 if (!disk->part) {
599 kfree(disk); 613 kfree(disk);
600 return NULL; 614 return NULL;
@@ -610,6 +624,7 @@ struct gendisk *alloc_disk(int minors)
610} 624}
611 625
612EXPORT_SYMBOL(alloc_disk); 626EXPORT_SYMBOL(alloc_disk);
627EXPORT_SYMBOL(alloc_disk_node);
613 628
614struct kobject *get_disk(struct gendisk *disk) 629struct kobject *get_disk(struct gendisk *disk)
615{ 630{
diff --git a/drivers/block/ioctl.c b/drivers/block/ioctl.c
index 6d7bcc9da9e7..6e278474f9a8 100644
--- a/drivers/block/ioctl.c
+++ b/drivers/block/ioctl.c
@@ -133,11 +133,9 @@ static int put_u64(unsigned long arg, u64 val)
133 return put_user(val, (u64 __user *)arg); 133 return put_user(val, (u64 __user *)arg);
134} 134}
135 135
136int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, 136static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
137 unsigned long arg) 137 unsigned cmd, unsigned long arg)
138{ 138{
139 struct block_device *bdev = inode->i_bdev;
140 struct gendisk *disk = bdev->bd_disk;
141 struct backing_dev_info *bdi; 139 struct backing_dev_info *bdi;
142 int ret, n; 140 int ret, n;
143 141
@@ -190,36 +188,72 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
190 return put_ulong(arg, bdev->bd_inode->i_size >> 9); 188 return put_ulong(arg, bdev->bd_inode->i_size >> 9);
191 case BLKGETSIZE64: 189 case BLKGETSIZE64:
192 return put_u64(arg, bdev->bd_inode->i_size); 190 return put_u64(arg, bdev->bd_inode->i_size);
191 }
192 return -ENOIOCTLCMD;
193}
194
195static int blkdev_driver_ioctl(struct inode *inode, struct file *file,
196 struct gendisk *disk, unsigned cmd, unsigned long arg)
197{
198 int ret;
199 if (disk->fops->unlocked_ioctl)
200 return disk->fops->unlocked_ioctl(file, cmd, arg);
201
202 if (disk->fops->ioctl) {
203 lock_kernel();
204 ret = disk->fops->ioctl(inode, file, cmd, arg);
205 unlock_kernel();
206 return ret;
207 }
208
209 return -ENOTTY;
210}
211
212int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
213 unsigned long arg)
214{
215 struct block_device *bdev = inode->i_bdev;
216 struct gendisk *disk = bdev->bd_disk;
217 int ret, n;
218
219 switch(cmd) {
193 case BLKFLSBUF: 220 case BLKFLSBUF:
194 if (!capable(CAP_SYS_ADMIN)) 221 if (!capable(CAP_SYS_ADMIN))
195 return -EACCES; 222 return -EACCES;
196 if (disk->fops->ioctl) { 223
197 ret = disk->fops->ioctl(inode, file, cmd, arg); 224 ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
198 /* -EINVAL to handle old uncorrected drivers */ 225 /* -EINVAL to handle old uncorrected drivers */
199 if (ret != -EINVAL && ret != -ENOTTY) 226 if (ret != -EINVAL && ret != -ENOTTY)
200 return ret; 227 return ret;
201 } 228
229 lock_kernel();
202 fsync_bdev(bdev); 230 fsync_bdev(bdev);
203 invalidate_bdev(bdev, 0); 231 invalidate_bdev(bdev, 0);
232 unlock_kernel();
204 return 0; 233 return 0;
234
205 case BLKROSET: 235 case BLKROSET:
206 if (disk->fops->ioctl) { 236 ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
207 ret = disk->fops->ioctl(inode, file, cmd, arg); 237 /* -EINVAL to handle old uncorrected drivers */
208 /* -EINVAL to handle old uncorrected drivers */ 238 if (ret != -EINVAL && ret != -ENOTTY)
209 if (ret != -EINVAL && ret != -ENOTTY) 239 return ret;
210 return ret;
211 }
212 if (!capable(CAP_SYS_ADMIN)) 240 if (!capable(CAP_SYS_ADMIN))
213 return -EACCES; 241 return -EACCES;
214 if (get_user(n, (int __user *)(arg))) 242 if (get_user(n, (int __user *)(arg)))
215 return -EFAULT; 243 return -EFAULT;
244 lock_kernel();
216 set_device_ro(bdev, n); 245 set_device_ro(bdev, n);
246 unlock_kernel();
217 return 0; 247 return 0;
218 default:
219 if (disk->fops->ioctl)
220 return disk->fops->ioctl(inode, file, cmd, arg);
221 } 248 }
222 return -ENOTTY; 249
250 lock_kernel();
251 ret = blkdev_locked_ioctl(file, bdev, cmd, arg);
252 unlock_kernel();
253 if (ret != -ENOIOCTLCMD)
254 return ret;
255
256 return blkdev_driver_ioctl(inode, file, disk, cmd, arg);
223} 257}
224 258
225/* Most of the generic ioctls are handled in the normal fallback path. 259/* Most of the generic ioctls are handled in the normal fallback path.
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
index 81fe3a0c1fe7..fd94ea27d594 100644
--- a/drivers/block/ll_rw_blk.c
+++ b/drivers/block/ll_rw_blk.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/swap.h> 29#include <linux/swap.h>
30#include <linux/writeback.h> 30#include <linux/writeback.h>
31#include <linux/blkdev.h>
31 32
32/* 33/*
33 * for max sense size 34 * for max sense size
@@ -716,7 +717,7 @@ struct request *blk_queue_find_tag(request_queue_t *q, int tag)
716{ 717{
717 struct blk_queue_tag *bqt = q->queue_tags; 718 struct blk_queue_tag *bqt = q->queue_tags;
718 719
719 if (unlikely(bqt == NULL || tag >= bqt->real_max_depth)) 720 if (unlikely(bqt == NULL || tag >= bqt->max_depth))
720 return NULL; 721 return NULL;
721 722
722 return bqt->tag_index[tag]; 723 return bqt->tag_index[tag];
@@ -774,9 +775,9 @@ EXPORT_SYMBOL(blk_queue_free_tags);
774static int 775static int
775init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth) 776init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
776{ 777{
777 int bits, i;
778 struct request **tag_index; 778 struct request **tag_index;
779 unsigned long *tag_map; 779 unsigned long *tag_map;
780 int nr_ulongs;
780 781
781 if (depth > q->nr_requests * 2) { 782 if (depth > q->nr_requests * 2) {
782 depth = q->nr_requests * 2; 783 depth = q->nr_requests * 2;
@@ -788,24 +789,17 @@ init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
788 if (!tag_index) 789 if (!tag_index)
789 goto fail; 790 goto fail;
790 791
791 bits = (depth / BLK_TAGS_PER_LONG) + 1; 792 nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
792 tag_map = kmalloc(bits * sizeof(unsigned long), GFP_ATOMIC); 793 tag_map = kmalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
793 if (!tag_map) 794 if (!tag_map)
794 goto fail; 795 goto fail;
795 796
796 memset(tag_index, 0, depth * sizeof(struct request *)); 797 memset(tag_index, 0, depth * sizeof(struct request *));
797 memset(tag_map, 0, bits * sizeof(unsigned long)); 798 memset(tag_map, 0, nr_ulongs * sizeof(unsigned long));
798 tags->max_depth = depth; 799 tags->max_depth = depth;
799 tags->real_max_depth = bits * BITS_PER_LONG;
800 tags->tag_index = tag_index; 800 tags->tag_index = tag_index;
801 tags->tag_map = tag_map; 801 tags->tag_map = tag_map;
802 802
803 /*
804 * set the upper bits if the depth isn't a multiple of the word size
805 */
806 for (i = depth; i < bits * BLK_TAGS_PER_LONG; i++)
807 __set_bit(i, tag_map);
808
809 return 0; 803 return 0;
810fail: 804fail:
811 kfree(tag_index); 805 kfree(tag_index);
@@ -870,32 +864,24 @@ int blk_queue_resize_tags(request_queue_t *q, int new_depth)
870 struct blk_queue_tag *bqt = q->queue_tags; 864 struct blk_queue_tag *bqt = q->queue_tags;
871 struct request **tag_index; 865 struct request **tag_index;
872 unsigned long *tag_map; 866 unsigned long *tag_map;
873 int bits, max_depth; 867 int max_depth, nr_ulongs;
874 868
875 if (!bqt) 869 if (!bqt)
876 return -ENXIO; 870 return -ENXIO;
877 871
878 /* 872 /*
879 * don't bother sizing down
880 */
881 if (new_depth <= bqt->real_max_depth) {
882 bqt->max_depth = new_depth;
883 return 0;
884 }
885
886 /*
887 * save the old state info, so we can copy it back 873 * save the old state info, so we can copy it back
888 */ 874 */
889 tag_index = bqt->tag_index; 875 tag_index = bqt->tag_index;
890 tag_map = bqt->tag_map; 876 tag_map = bqt->tag_map;
891 max_depth = bqt->real_max_depth; 877 max_depth = bqt->max_depth;
892 878
893 if (init_tag_map(q, bqt, new_depth)) 879 if (init_tag_map(q, bqt, new_depth))
894 return -ENOMEM; 880 return -ENOMEM;
895 881
896 memcpy(bqt->tag_index, tag_index, max_depth * sizeof(struct request *)); 882 memcpy(bqt->tag_index, tag_index, max_depth * sizeof(struct request *));
897 bits = max_depth / BLK_TAGS_PER_LONG; 883 nr_ulongs = ALIGN(max_depth, BITS_PER_LONG) / BITS_PER_LONG;
898 memcpy(bqt->tag_map, tag_map, bits * sizeof(unsigned long)); 884 memcpy(bqt->tag_map, tag_map, nr_ulongs * sizeof(unsigned long));
899 885
900 kfree(tag_index); 886 kfree(tag_index);
901 kfree(tag_map); 887 kfree(tag_map);
@@ -925,11 +911,16 @@ void blk_queue_end_tag(request_queue_t *q, struct request *rq)
925 911
926 BUG_ON(tag == -1); 912 BUG_ON(tag == -1);
927 913
928 if (unlikely(tag >= bqt->real_max_depth)) 914 if (unlikely(tag >= bqt->max_depth))
915 /*
916 * This can happen after tag depth has been reduced.
917 * FIXME: how about a warning or info message here?
918 */
929 return; 919 return;
930 920
931 if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) { 921 if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) {
932 printk("attempt to clear non-busy tag (%d)\n", tag); 922 printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
923 __FUNCTION__, tag);
933 return; 924 return;
934 } 925 }
935 926
@@ -938,7 +929,8 @@ void blk_queue_end_tag(request_queue_t *q, struct request *rq)
938 rq->tag = -1; 929 rq->tag = -1;
939 930
940 if (unlikely(bqt->tag_index[tag] == NULL)) 931 if (unlikely(bqt->tag_index[tag] == NULL))
941 printk("tag %d is missing\n", tag); 932 printk(KERN_ERR "%s: tag %d is missing\n",
933 __FUNCTION__, tag);
942 934
943 bqt->tag_index[tag] = NULL; 935 bqt->tag_index[tag] = NULL;
944 bqt->busy--; 936 bqt->busy--;
@@ -967,24 +959,20 @@ EXPORT_SYMBOL(blk_queue_end_tag);
967int blk_queue_start_tag(request_queue_t *q, struct request *rq) 959int blk_queue_start_tag(request_queue_t *q, struct request *rq)
968{ 960{
969 struct blk_queue_tag *bqt = q->queue_tags; 961 struct blk_queue_tag *bqt = q->queue_tags;
970 unsigned long *map = bqt->tag_map; 962 int tag;
971 int tag = 0;
972 963
973 if (unlikely((rq->flags & REQ_QUEUED))) { 964 if (unlikely((rq->flags & REQ_QUEUED))) {
974 printk(KERN_ERR 965 printk(KERN_ERR
975 "request %p for device [%s] already tagged %d", 966 "%s: request %p for device [%s] already tagged %d",
976 rq, rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag); 967 __FUNCTION__, rq,
968 rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag);
977 BUG(); 969 BUG();
978 } 970 }
979 971
980 for (map = bqt->tag_map; *map == -1UL; map++) { 972 tag = find_first_zero_bit(bqt->tag_map, bqt->max_depth);
981 tag += BLK_TAGS_PER_LONG; 973 if (tag >= bqt->max_depth)
982 974 return 1;
983 if (tag >= bqt->max_depth)
984 return 1;
985 }
986 975
987 tag += ffz(*map);
988 __set_bit(tag, bqt->tag_map); 976 __set_bit(tag, bqt->tag_map);
989 977
990 rq->flags |= REQ_QUEUED; 978 rq->flags |= REQ_QUEUED;
@@ -1020,7 +1008,8 @@ void blk_queue_invalidate_tags(request_queue_t *q)
1020 rq = list_entry_rq(tmp); 1008 rq = list_entry_rq(tmp);
1021 1009
1022 if (rq->tag == -1) { 1010 if (rq->tag == -1) {
1023 printk("bad tag found on list\n"); 1011 printk(KERN_ERR
1012 "%s: bad tag found on list\n", __FUNCTION__);
1024 list_del_init(&rq->queuelist); 1013 list_del_init(&rq->queuelist);
1025 rq->flags &= ~REQ_QUEUED; 1014 rq->flags &= ~REQ_QUEUED;
1026 } else 1015 } else
@@ -1450,7 +1439,7 @@ EXPORT_SYMBOL(blk_remove_plug);
1450 */ 1439 */
1451void __generic_unplug_device(request_queue_t *q) 1440void __generic_unplug_device(request_queue_t *q)
1452{ 1441{
1453 if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags)) 1442 if (unlikely(test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags)))
1454 return; 1443 return;
1455 1444
1456 if (!blk_remove_plug(q)) 1445 if (!blk_remove_plug(q))
@@ -1645,7 +1634,8 @@ static int blk_init_free_list(request_queue_t *q)
1645 init_waitqueue_head(&rl->wait[WRITE]); 1634 init_waitqueue_head(&rl->wait[WRITE]);
1646 init_waitqueue_head(&rl->drain); 1635 init_waitqueue_head(&rl->drain);
1647 1636
1648 rl->rq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, request_cachep); 1637 rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
1638 mempool_free_slab, request_cachep, q->node);
1649 1639
1650 if (!rl->rq_pool) 1640 if (!rl->rq_pool)
1651 return -ENOMEM; 1641 return -ENOMEM;
@@ -1657,8 +1647,15 @@ static int __make_request(request_queue_t *, struct bio *);
1657 1647
1658request_queue_t *blk_alloc_queue(int gfp_mask) 1648request_queue_t *blk_alloc_queue(int gfp_mask)
1659{ 1649{
1660 request_queue_t *q = kmem_cache_alloc(requestq_cachep, gfp_mask); 1650 return blk_alloc_queue_node(gfp_mask, -1);
1651}
1652EXPORT_SYMBOL(blk_alloc_queue);
1653
1654request_queue_t *blk_alloc_queue_node(int gfp_mask, int node_id)
1655{
1656 request_queue_t *q;
1661 1657
1658 q = kmem_cache_alloc_node(requestq_cachep, gfp_mask, node_id);
1662 if (!q) 1659 if (!q)
1663 return NULL; 1660 return NULL;
1664 1661
@@ -1671,8 +1668,7 @@ request_queue_t *blk_alloc_queue(int gfp_mask)
1671 1668
1672 return q; 1669 return q;
1673} 1670}
1674 1671EXPORT_SYMBOL(blk_alloc_queue_node);
1675EXPORT_SYMBOL(blk_alloc_queue);
1676 1672
1677/** 1673/**
1678 * blk_init_queue - prepare a request queue for use with a block device 1674 * blk_init_queue - prepare a request queue for use with a block device
@@ -1705,13 +1701,22 @@ EXPORT_SYMBOL(blk_alloc_queue);
1705 * blk_init_queue() must be paired with a blk_cleanup_queue() call 1701 * blk_init_queue() must be paired with a blk_cleanup_queue() call
1706 * when the block device is deactivated (such as at module unload). 1702 * when the block device is deactivated (such as at module unload).
1707 **/ 1703 **/
1704
1708request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) 1705request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
1709{ 1706{
1710 request_queue_t *q = blk_alloc_queue(GFP_KERNEL); 1707 return blk_init_queue_node(rfn, lock, -1);
1708}
1709EXPORT_SYMBOL(blk_init_queue);
1710
1711request_queue_t *
1712blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
1713{
1714 request_queue_t *q = blk_alloc_queue_node(GFP_KERNEL, node_id);
1711 1715
1712 if (!q) 1716 if (!q)
1713 return NULL; 1717 return NULL;
1714 1718
1719 q->node = node_id;
1715 if (blk_init_free_list(q)) 1720 if (blk_init_free_list(q))
1716 goto out_init; 1721 goto out_init;
1717 1722
@@ -1754,12 +1759,11 @@ out_init:
1754 kmem_cache_free(requestq_cachep, q); 1759 kmem_cache_free(requestq_cachep, q);
1755 return NULL; 1760 return NULL;
1756} 1761}
1757 1762EXPORT_SYMBOL(blk_init_queue_node);
1758EXPORT_SYMBOL(blk_init_queue);
1759 1763
1760int blk_get_queue(request_queue_t *q) 1764int blk_get_queue(request_queue_t *q)
1761{ 1765{
1762 if (!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) { 1766 if (likely(!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
1763 atomic_inc(&q->refcnt); 1767 atomic_inc(&q->refcnt);
1764 return 0; 1768 return 0;
1765 } 1769 }
@@ -1838,7 +1842,6 @@ static void __freed_request(request_queue_t *q, int rw)
1838 clear_queue_congested(q, rw); 1842 clear_queue_congested(q, rw);
1839 1843
1840 if (rl->count[rw] + 1 <= q->nr_requests) { 1844 if (rl->count[rw] + 1 <= q->nr_requests) {
1841 smp_mb();
1842 if (waitqueue_active(&rl->wait[rw])) 1845 if (waitqueue_active(&rl->wait[rw]))
1843 wake_up(&rl->wait[rw]); 1846 wake_up(&rl->wait[rw]);
1844 1847
@@ -1966,7 +1969,6 @@ static struct request *get_request_wait(request_queue_t *q, int rw)
1966 DEFINE_WAIT(wait); 1969 DEFINE_WAIT(wait);
1967 struct request *rq; 1970 struct request *rq;
1968 1971
1969 generic_unplug_device(q);
1970 do { 1972 do {
1971 struct request_list *rl = &q->rq; 1973 struct request_list *rl = &q->rq;
1972 1974
@@ -1978,6 +1980,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw)
1978 if (!rq) { 1980 if (!rq) {
1979 struct io_context *ioc; 1981 struct io_context *ioc;
1980 1982
1983 generic_unplug_device(q);
1981 io_schedule(); 1984 io_schedule();
1982 1985
1983 /* 1986 /*
@@ -2581,7 +2584,7 @@ static int __make_request(request_queue_t *q, struct bio *bio)
2581 spin_lock_prefetch(q->queue_lock); 2584 spin_lock_prefetch(q->queue_lock);
2582 2585
2583 barrier = bio_barrier(bio); 2586 barrier = bio_barrier(bio);
2584 if (barrier && (q->ordered == QUEUE_ORDERED_NONE)) { 2587 if (unlikely(barrier) && (q->ordered == QUEUE_ORDERED_NONE)) {
2585 err = -EOPNOTSUPP; 2588 err = -EOPNOTSUPP;
2586 goto end_io; 2589 goto end_io;
2587 } 2590 }
@@ -2682,7 +2685,7 @@ get_rq:
2682 /* 2685 /*
2683 * REQ_BARRIER implies no merging, but lets make it explicit 2686 * REQ_BARRIER implies no merging, but lets make it explicit
2684 */ 2687 */
2685 if (barrier) 2688 if (unlikely(barrier))
2686 req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE); 2689 req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
2687 2690
2688 req->errors = 0; 2691 req->errors = 0;
@@ -2806,7 +2809,7 @@ static inline void block_wait_queue_running(request_queue_t *q)
2806{ 2809{
2807 DEFINE_WAIT(wait); 2810 DEFINE_WAIT(wait);
2808 2811
2809 while (test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)) { 2812 while (unlikely(test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags))) {
2810 struct request_list *rl = &q->rq; 2813 struct request_list *rl = &q->rq;
2811 2814
2812 prepare_to_wait_exclusive(&rl->drain, &wait, 2815 prepare_to_wait_exclusive(&rl->drain, &wait,
@@ -2915,7 +2918,7 @@ end_io:
2915 goto end_io; 2918 goto end_io;
2916 } 2919 }
2917 2920
2918 if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) 2921 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
2919 goto end_io; 2922 goto end_io;
2920 2923
2921 block_wait_queue_running(q); 2924 block_wait_queue_running(q);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6f011d0d8e97..b35e08876dd4 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -472,17 +472,11 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
472 */ 472 */
473static void loop_add_bio(struct loop_device *lo, struct bio *bio) 473static void loop_add_bio(struct loop_device *lo, struct bio *bio)
474{ 474{
475 unsigned long flags;
476
477 spin_lock_irqsave(&lo->lo_lock, flags);
478 if (lo->lo_biotail) { 475 if (lo->lo_biotail) {
479 lo->lo_biotail->bi_next = bio; 476 lo->lo_biotail->bi_next = bio;
480 lo->lo_biotail = bio; 477 lo->lo_biotail = bio;
481 } else 478 } else
482 lo->lo_bio = lo->lo_biotail = bio; 479 lo->lo_bio = lo->lo_biotail = bio;
483 spin_unlock_irqrestore(&lo->lo_lock, flags);
484
485 up(&lo->lo_bh_mutex);
486} 480}
487 481
488/* 482/*
@@ -492,14 +486,12 @@ static struct bio *loop_get_bio(struct loop_device *lo)
492{ 486{
493 struct bio *bio; 487 struct bio *bio;
494 488
495 spin_lock_irq(&lo->lo_lock);
496 if ((bio = lo->lo_bio)) { 489 if ((bio = lo->lo_bio)) {
497 if (bio == lo->lo_biotail) 490 if (bio == lo->lo_biotail)
498 lo->lo_biotail = NULL; 491 lo->lo_biotail = NULL;
499 lo->lo_bio = bio->bi_next; 492 lo->lo_bio = bio->bi_next;
500 bio->bi_next = NULL; 493 bio->bi_next = NULL;
501 } 494 }
502 spin_unlock_irq(&lo->lo_lock);
503 495
504 return bio; 496 return bio;
505} 497}
@@ -509,35 +501,28 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio)
509 struct loop_device *lo = q->queuedata; 501 struct loop_device *lo = q->queuedata;
510 int rw = bio_rw(old_bio); 502 int rw = bio_rw(old_bio);
511 503
512 if (!lo) 504 if (rw == READA)
513 goto out; 505 rw = READ;
506
507 BUG_ON(!lo || (rw != READ && rw != WRITE));
514 508
515 spin_lock_irq(&lo->lo_lock); 509 spin_lock_irq(&lo->lo_lock);
516 if (lo->lo_state != Lo_bound) 510 if (lo->lo_state != Lo_bound)
517 goto inactive; 511 goto out;
518 atomic_inc(&lo->lo_pending); 512 if (unlikely(rw == WRITE && (lo->lo_flags & LO_FLAGS_READ_ONLY)))
519 spin_unlock_irq(&lo->lo_lock); 513 goto out;
520 514 lo->lo_pending++;
521 if (rw == WRITE) {
522 if (lo->lo_flags & LO_FLAGS_READ_ONLY)
523 goto err;
524 } else if (rw == READA) {
525 rw = READ;
526 } else if (rw != READ) {
527 printk(KERN_ERR "loop: unknown command (%x)\n", rw);
528 goto err;
529 }
530 loop_add_bio(lo, old_bio); 515 loop_add_bio(lo, old_bio);
516 spin_unlock_irq(&lo->lo_lock);
517 up(&lo->lo_bh_mutex);
531 return 0; 518 return 0;
532err: 519
533 if (atomic_dec_and_test(&lo->lo_pending))
534 up(&lo->lo_bh_mutex);
535out: 520out:
521 if (lo->lo_pending == 0)
522 up(&lo->lo_bh_mutex);
523 spin_unlock_irq(&lo->lo_lock);
536 bio_io_error(old_bio, old_bio->bi_size); 524 bio_io_error(old_bio, old_bio->bi_size);
537 return 0; 525 return 0;
538inactive:
539 spin_unlock_irq(&lo->lo_lock);
540 goto out;
541} 526}
542 527
543/* 528/*
@@ -560,13 +545,11 @@ static void do_loop_switch(struct loop_device *, struct switch_request *);
560 545
561static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio) 546static inline void loop_handle_bio(struct loop_device *lo, struct bio *bio)
562{ 547{
563 int ret;
564
565 if (unlikely(!bio->bi_bdev)) { 548 if (unlikely(!bio->bi_bdev)) {
566 do_loop_switch(lo, bio->bi_private); 549 do_loop_switch(lo, bio->bi_private);
567 bio_put(bio); 550 bio_put(bio);
568 } else { 551 } else {
569 ret = do_bio_filebacked(lo, bio); 552 int ret = do_bio_filebacked(lo, bio);
570 bio_endio(bio, bio->bi_size, ret); 553 bio_endio(bio, bio->bi_size, ret);
571 } 554 }
572} 555}
@@ -594,7 +577,7 @@ static int loop_thread(void *data)
594 set_user_nice(current, -20); 577 set_user_nice(current, -20);
595 578
596 lo->lo_state = Lo_bound; 579 lo->lo_state = Lo_bound;
597 atomic_inc(&lo->lo_pending); 580 lo->lo_pending = 1;
598 581
599 /* 582 /*
600 * up sem, we are running 583 * up sem, we are running
@@ -602,26 +585,37 @@ static int loop_thread(void *data)
602 up(&lo->lo_sem); 585 up(&lo->lo_sem);
603 586
604 for (;;) { 587 for (;;) {
605 down_interruptible(&lo->lo_bh_mutex); 588 int pending;
589
606 /* 590 /*
607 * could be upped because of tear-down, not because of 591 * interruptible just to not contribute to load avg
608 * pending work
609 */ 592 */
610 if (!atomic_read(&lo->lo_pending)) 593 if (down_interruptible(&lo->lo_bh_mutex))
594 continue;
595
596 spin_lock_irq(&lo->lo_lock);
597
598 /*
599 * could be upped because of tear-down, not pending work
600 */
601 if (unlikely(!lo->lo_pending)) {
602 spin_unlock_irq(&lo->lo_lock);
611 break; 603 break;
604 }
612 605
613 bio = loop_get_bio(lo); 606 bio = loop_get_bio(lo);
614 if (!bio) { 607 lo->lo_pending--;
615 printk("loop: missing bio\n"); 608 pending = lo->lo_pending;
616 continue; 609 spin_unlock_irq(&lo->lo_lock);
617 } 610
611 BUG_ON(!bio);
618 loop_handle_bio(lo, bio); 612 loop_handle_bio(lo, bio);
619 613
620 /* 614 /*
621 * upped both for pending work and tear-down, lo_pending 615 * upped both for pending work and tear-down, lo_pending
622 * will hit zero then 616 * will hit zero then
623 */ 617 */
624 if (atomic_dec_and_test(&lo->lo_pending)) 618 if (unlikely(!pending))
625 break; 619 break;
626 } 620 }
627 621
@@ -900,7 +894,8 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
900 894
901 spin_lock_irq(&lo->lo_lock); 895 spin_lock_irq(&lo->lo_lock);
902 lo->lo_state = Lo_rundown; 896 lo->lo_state = Lo_rundown;
903 if (atomic_dec_and_test(&lo->lo_pending)) 897 lo->lo_pending--;
898 if (!lo->lo_pending)
904 up(&lo->lo_bh_mutex); 899 up(&lo->lo_bh_mutex);
905 spin_unlock_irq(&lo->lo_lock); 900 spin_unlock_irq(&lo->lo_lock);
906 901
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index bc56770bcc90..7f3d78de265c 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -467,14 +467,12 @@ static int pkt_set_speed(struct pktcdvd_device *pd, unsigned write_speed, unsign
467 * Queue a bio for processing by the low-level CD device. Must be called 467 * Queue a bio for processing by the low-level CD device. Must be called
468 * from process context. 468 * from process context.
469 */ 469 */
470static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio, int high_prio_read) 470static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio)
471{ 471{
472 spin_lock(&pd->iosched.lock); 472 spin_lock(&pd->iosched.lock);
473 if (bio_data_dir(bio) == READ) { 473 if (bio_data_dir(bio) == READ) {
474 pkt_add_list_last(bio, &pd->iosched.read_queue, 474 pkt_add_list_last(bio, &pd->iosched.read_queue,
475 &pd->iosched.read_queue_tail); 475 &pd->iosched.read_queue_tail);
476 if (high_prio_read)
477 pd->iosched.high_prio_read = 1;
478 } else { 476 } else {
479 pkt_add_list_last(bio, &pd->iosched.write_queue, 477 pkt_add_list_last(bio, &pd->iosched.write_queue,
480 &pd->iosched.write_queue_tail); 478 &pd->iosched.write_queue_tail);
@@ -490,15 +488,16 @@ static void pkt_queue_bio(struct pktcdvd_device *pd, struct bio *bio, int high_p
490 * requirements for CDRW drives: 488 * requirements for CDRW drives:
491 * - A cache flush command must be inserted before a read request if the 489 * - A cache flush command must be inserted before a read request if the
492 * previous request was a write. 490 * previous request was a write.
493 * - Switching between reading and writing is slow, so don't it more often 491 * - Switching between reading and writing is slow, so don't do it more often
494 * than necessary. 492 * than necessary.
493 * - Optimize for throughput at the expense of latency. This means that streaming
494 * writes will never be interrupted by a read, but if the drive has to seek
495 * before the next write, switch to reading instead if there are any pending
496 * read requests.
495 * - Set the read speed according to current usage pattern. When only reading 497 * - Set the read speed according to current usage pattern. When only reading
496 * from the device, it's best to use the highest possible read speed, but 498 * from the device, it's best to use the highest possible read speed, but
497 * when switching often between reading and writing, it's better to have the 499 * when switching often between reading and writing, it's better to have the
498 * same read and write speeds. 500 * same read and write speeds.
499 * - Reads originating from user space should have higher priority than reads
500 * originating from pkt_gather_data, because some process is usually waiting
501 * on reads of the first kind.
502 */ 501 */
503static void pkt_iosched_process_queue(struct pktcdvd_device *pd) 502static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
504{ 503{
@@ -512,21 +511,24 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
512 511
513 for (;;) { 512 for (;;) {
514 struct bio *bio; 513 struct bio *bio;
515 int reads_queued, writes_queued, high_prio_read; 514 int reads_queued, writes_queued;
516 515
517 spin_lock(&pd->iosched.lock); 516 spin_lock(&pd->iosched.lock);
518 reads_queued = (pd->iosched.read_queue != NULL); 517 reads_queued = (pd->iosched.read_queue != NULL);
519 writes_queued = (pd->iosched.write_queue != NULL); 518 writes_queued = (pd->iosched.write_queue != NULL);
520 if (!reads_queued)
521 pd->iosched.high_prio_read = 0;
522 high_prio_read = pd->iosched.high_prio_read;
523 spin_unlock(&pd->iosched.lock); 519 spin_unlock(&pd->iosched.lock);
524 520
525 if (!reads_queued && !writes_queued) 521 if (!reads_queued && !writes_queued)
526 break; 522 break;
527 523
528 if (pd->iosched.writing) { 524 if (pd->iosched.writing) {
529 if (high_prio_read || (!writes_queued && reads_queued)) { 525 int need_write_seek = 1;
526 spin_lock(&pd->iosched.lock);
527 bio = pd->iosched.write_queue;
528 spin_unlock(&pd->iosched.lock);
529 if (bio && (bio->bi_sector == pd->iosched.last_write))
530 need_write_seek = 0;
531 if (need_write_seek && reads_queued) {
530 if (atomic_read(&pd->cdrw.pending_bios) > 0) { 532 if (atomic_read(&pd->cdrw.pending_bios) > 0) {
531 VPRINTK("pktcdvd: write, waiting\n"); 533 VPRINTK("pktcdvd: write, waiting\n");
532 break; 534 break;
@@ -559,8 +561,10 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
559 561
560 if (bio_data_dir(bio) == READ) 562 if (bio_data_dir(bio) == READ)
561 pd->iosched.successive_reads += bio->bi_size >> 10; 563 pd->iosched.successive_reads += bio->bi_size >> 10;
562 else 564 else {
563 pd->iosched.successive_reads = 0; 565 pd->iosched.successive_reads = 0;
566 pd->iosched.last_write = bio->bi_sector + bio_sectors(bio);
567 }
564 if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) { 568 if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) {
565 if (pd->read_speed == pd->write_speed) { 569 if (pd->read_speed == pd->write_speed) {
566 pd->read_speed = MAX_SPEED; 570 pd->read_speed = MAX_SPEED;
@@ -765,7 +769,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt)
765 769
766 atomic_inc(&pkt->io_wait); 770 atomic_inc(&pkt->io_wait);
767 bio->bi_rw = READ; 771 bio->bi_rw = READ;
768 pkt_queue_bio(pd, bio, 0); 772 pkt_queue_bio(pd, bio);
769 frames_read++; 773 frames_read++;
770 } 774 }
771 775
@@ -1062,7 +1066,7 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt)
1062 1066
1063 atomic_set(&pkt->io_wait, 1); 1067 atomic_set(&pkt->io_wait, 1);
1064 pkt->w_bio->bi_rw = WRITE; 1068 pkt->w_bio->bi_rw = WRITE;
1065 pkt_queue_bio(pd, pkt->w_bio, 0); 1069 pkt_queue_bio(pd, pkt->w_bio);
1066} 1070}
1067 1071
1068static void pkt_finish_packet(struct packet_data *pkt, int uptodate) 1072static void pkt_finish_packet(struct packet_data *pkt, int uptodate)
@@ -2120,7 +2124,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
2120 cloned_bio->bi_private = psd; 2124 cloned_bio->bi_private = psd;
2121 cloned_bio->bi_end_io = pkt_end_io_read_cloned; 2125 cloned_bio->bi_end_io = pkt_end_io_read_cloned;
2122 pd->stats.secs_r += bio->bi_size >> 9; 2126 pd->stats.secs_r += bio->bi_size >> 9;
2123 pkt_queue_bio(pd, cloned_bio, 1); 2127 pkt_queue_bio(pd, cloned_bio);
2124 return 0; 2128 return 0;
2125 } 2129 }
2126 2130
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 9075bbb56ad4..f766bc22c6bb 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -576,7 +576,7 @@ static void __exit hci_uart_exit(void)
576#endif 576#endif
577 577
578 /* Release tty registration of line discipline */ 578 /* Release tty registration of line discipline */
579 if ((err = tty_register_ldisc(N_HCI, NULL))) 579 if ((err = tty_unregister_ldisc(N_HCI)))
580 BT_ERR("Can't unregister HCI line discipline (%d)", err); 580 BT_ERR("Can't unregister HCI line discipline (%d)", err);
581} 581}
582 582
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 1dc4259213a6..777bc499bbbd 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -861,13 +861,18 @@ static void change_speed(struct async_struct *info,
861 861
862static void rs_put_char(struct tty_struct *tty, unsigned char ch) 862static void rs_put_char(struct tty_struct *tty, unsigned char ch)
863{ 863{
864 struct async_struct *info = (struct async_struct *)tty->driver_data; 864 struct async_struct *info;
865 unsigned long flags; 865 unsigned long flags;
866 866
867 if (!tty)
868 return;
869
870 info = tty->driver_data;
871
867 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 872 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
868 return; 873 return;
869 874
870 if (!tty || !info->xmit.buf) 875 if (!info->xmit.buf)
871 return; 876 return;
872 877
873 local_irq_save(flags); 878 local_irq_save(flags);
@@ -910,13 +915,18 @@ static void rs_flush_chars(struct tty_struct *tty)
910static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) 915static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count)
911{ 916{
912 int c, ret = 0; 917 int c, ret = 0;
913 struct async_struct *info = (struct async_struct *)tty->driver_data; 918 struct async_struct *info;
914 unsigned long flags; 919 unsigned long flags;
915 920
921 if (!tty)
922 return 0;
923
924 info = tty->driver_data;
925
916 if (serial_paranoia_check(info, tty->name, "rs_write")) 926 if (serial_paranoia_check(info, tty->name, "rs_write"))
917 return 0; 927 return 0;
918 928
919 if (!tty || !info->xmit.buf || !tmp_buf) 929 if (!info->xmit.buf || !tmp_buf)
920 return 0; 930 return 0;
921 931
922 local_save_flags(flags); 932 local_save_flags(flags);
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index b3dbff1cf967..5079beda69b5 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -960,7 +960,7 @@ static char hdlc_unregister_fail[] __exitdata =
960static void __exit n_hdlc_exit(void) 960static void __exit n_hdlc_exit(void)
961{ 961{
962 /* Release tty registration of line discipline */ 962 /* Release tty registration of line discipline */
963 int status = tty_register_ldisc(N_HDLC, NULL); 963 int status = tty_unregister_ldisc(N_HDLC);
964 964
965 if (status) 965 if (status)
966 printk(hdlc_unregister_fail, status); 966 printk(hdlc_unregister_fail, status);
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index 3883073ab48f..2291a87e8ada 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -200,7 +200,7 @@ static void __exit r3964_exit(void)
200 200
201 TRACE_M ("cleanup_module()"); 201 TRACE_M ("cleanup_module()");
202 202
203 status=tty_register_ldisc(N_R3964, NULL); 203 status=tty_unregister_ldisc(N_R3964);
204 204
205 if(status!=0) 205 if(status!=0)
206 { 206 {
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 31831030f73f..cc4b43bad703 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -251,7 +251,7 @@ static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
251 251
252static DEFINE_SPINLOCK(tty_ldisc_lock); 252static DEFINE_SPINLOCK(tty_ldisc_lock);
253static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); 253static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
254static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */ 254static struct tty_ldisc tty_ldiscs[NR_LDISCS]; /* line disc dispatch table */
255 255
256int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc) 256int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc)
257{ 257{
@@ -262,24 +262,35 @@ int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc)
262 return -EINVAL; 262 return -EINVAL;
263 263
264 spin_lock_irqsave(&tty_ldisc_lock, flags); 264 spin_lock_irqsave(&tty_ldisc_lock, flags);
265 if (new_ldisc) { 265 tty_ldiscs[disc] = *new_ldisc;
266 tty_ldiscs[disc] = *new_ldisc; 266 tty_ldiscs[disc].num = disc;
267 tty_ldiscs[disc].num = disc; 267 tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
268 tty_ldiscs[disc].flags |= LDISC_FLAG_DEFINED; 268 tty_ldiscs[disc].refcount = 0;
269 tty_ldiscs[disc].refcount = 0;
270 } else {
271 if(tty_ldiscs[disc].refcount)
272 ret = -EBUSY;
273 else
274 tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
275 }
276 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 269 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
277 270
278 return ret; 271 return ret;
279} 272}
280
281EXPORT_SYMBOL(tty_register_ldisc); 273EXPORT_SYMBOL(tty_register_ldisc);
282 274
275int tty_unregister_ldisc(int disc)
276{
277 unsigned long flags;
278 int ret = 0;
279
280 if (disc < N_TTY || disc >= NR_LDISCS)
281 return -EINVAL;
282
283 spin_lock_irqsave(&tty_ldisc_lock, flags);
284 if (tty_ldiscs[disc].refcount)
285 ret = -EBUSY;
286 else
287 tty_ldiscs[disc].flags &= ~LDISC_FLAG_DEFINED;
288 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
289
290 return ret;
291}
292EXPORT_SYMBOL(tty_unregister_ldisc);
293
283struct tty_ldisc *tty_ldisc_get(int disc) 294struct tty_ldisc *tty_ldisc_get(int disc)
284{ 295{
285 unsigned long flags; 296 unsigned long flags;
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c
index df1b721154d2..839b44a7e08b 100644
--- a/drivers/firmware/pcdp.c
+++ b/drivers/firmware/pcdp.c
@@ -23,12 +23,15 @@ setup_serial_console(struct pcdp_uart *uart)
23{ 23{
24#ifdef CONFIG_SERIAL_8250_CONSOLE 24#ifdef CONFIG_SERIAL_8250_CONSOLE
25 int mmio; 25 int mmio;
26 static char options[64]; 26 static char options[64], *p = options;
27 27
28 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY); 28 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
29 snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d", 29 p += sprintf(p, "console=uart,%s,0x%lx",
30 mmio ? "mmio" : "io", uart->addr.address, uart->baud, 30 mmio ? "mmio" : "io", uart->addr.address);
31 uart->bits ? uart->bits : 8); 31 if (uart->baud)
32 p += sprintf(p, ",%lu", uart->baud);
33 if (uart->bits)
34 p += sprintf(p, "n%d", uart->bits);
32 35
33 return early_serial_console_init(options); 36 return early_serial_console_init(options);
34#else 37#else
diff --git a/drivers/firmware/pcdp.h b/drivers/firmware/pcdp.h
index 863bb6f768c3..1dc7c88b7b4d 100644
--- a/drivers/firmware/pcdp.h
+++ b/drivers/firmware/pcdp.h
@@ -2,7 +2,7 @@
2 * Definitions for PCDP-defined console devices 2 * Definitions for PCDP-defined console devices
3 * 3 *
4 * v1.0a: http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf 4 * v1.0a: http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf
5 * v2.0: http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf 5 * v2.0: http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
6 * 6 *
7 * (c) Copyright 2002, 2004 Hewlett-Packard Development Company, L.P. 7 * (c) Copyright 2002, 2004 Hewlett-Packard Development Company, L.P.
8 * Khalid Aziz <khalid.aziz@hp.com> 8 * Khalid Aziz <khalid.aziz@hp.com>
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 39f3e9101ed4..0a31cfda08a0 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2657,16 +2657,63 @@ int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
2657} 2657}
2658 2658
2659static 2659static
2660int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap)
2661{
2662 struct cdrom_info *info = drive->driver_data;
2663 struct cdrom_device_info *cdi = &info->devinfo;
2664 struct packet_command cgc;
2665 int stat, attempts = 3, size = sizeof(*cap);
2666
2667 /*
2668 * ACER50 (and others?) require the full spec length mode sense
2669 * page capabilities size, but older drives break.
2670 */
2671 if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") ||
2672 !strcmp(drive->id->model, "WPI CDS-32X")))
2673 size -= sizeof(cap->pad);
2674
2675 init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN);
2676 do { /* we seem to get stat=0x01,err=0x00 the first time (??) */
2677 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0);
2678 if (!stat)
2679 break;
2680 } while (--attempts);
2681 return stat;
2682}
2683
2684static
2685void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page *cap)
2686{
2687 /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */
2688 if (!drive->id->model[0] &&
2689 !strncmp(drive->id->fw_rev, "241N", 4)) {
2690 CDROM_STATE_FLAGS(drive)->current_speed =
2691 (((unsigned int)cap->curspeed) + (176/2)) / 176;
2692 CDROM_CONFIG_FLAGS(drive)->max_speed =
2693 (((unsigned int)cap->maxspeed) + (176/2)) / 176;
2694 } else {
2695 CDROM_STATE_FLAGS(drive)->current_speed =
2696 (ntohs(cap->curspeed) + (176/2)) / 176;
2697 CDROM_CONFIG_FLAGS(drive)->max_speed =
2698 (ntohs(cap->maxspeed) + (176/2)) / 176;
2699 }
2700}
2701
2702static
2660int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) 2703int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
2661{ 2704{
2662 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2705 ide_drive_t *drive = (ide_drive_t*) cdi->handle;
2663 struct request_sense sense; 2706 struct request_sense sense;
2707 struct atapi_capabilities_page cap;
2664 int stat; 2708 int stat;
2665 2709
2666 if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) 2710 if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0)
2667 return stat; 2711 return stat;
2668 2712
2669 cdi->speed = CDROM_STATE_FLAGS(drive)->current_speed; 2713 if (!ide_cdrom_get_capabilities(drive, &cap)) {
2714 ide_cdrom_update_speed(drive, &cap);
2715 cdi->speed = CDROM_STATE_FLAGS(drive)->current_speed;
2716 }
2670 return 0; 2717 return 0;
2671} 2718}
2672 2719
@@ -2869,31 +2916,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
2869} 2916}
2870 2917
2871static 2918static
2872int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap)
2873{
2874 struct cdrom_info *info = drive->driver_data;
2875 struct cdrom_device_info *cdi = &info->devinfo;
2876 struct packet_command cgc;
2877 int stat, attempts = 3, size = sizeof(*cap);
2878
2879 /*
2880 * ACER50 (and others?) require the full spec length mode sense
2881 * page capabilities size, but older drives break.
2882 */
2883 if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") ||
2884 !strcmp(drive->id->model, "WPI CDS-32X")))
2885 size -= sizeof(cap->pad);
2886
2887 init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN);
2888 do { /* we seem to get stat=0x01,err=0x00 the first time (??) */
2889 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0);
2890 if (!stat)
2891 break;
2892 } while (--attempts);
2893 return stat;
2894}
2895
2896static
2897int ide_cdrom_probe_capabilities (ide_drive_t *drive) 2919int ide_cdrom_probe_capabilities (ide_drive_t *drive)
2898{ 2920{
2899 struct cdrom_info *info = drive->driver_data; 2921 struct cdrom_info *info = drive->driver_data;
@@ -2978,20 +3000,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
2978 } 3000 }
2979 } 3001 }
2980 3002
2981 /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ 3003 ide_cdrom_update_speed(drive, &cap);
2982 if (!drive->id->model[0] &&
2983 !strncmp(drive->id->fw_rev, "241N", 4)) {
2984 CDROM_STATE_FLAGS(drive)->current_speed =
2985 (((unsigned int)cap.curspeed) + (176/2)) / 176;
2986 CDROM_CONFIG_FLAGS(drive)->max_speed =
2987 (((unsigned int)cap.maxspeed) + (176/2)) / 176;
2988 } else {
2989 CDROM_STATE_FLAGS(drive)->current_speed =
2990 (ntohs(cap.curspeed) + (176/2)) / 176;
2991 CDROM_CONFIG_FLAGS(drive)->max_speed =
2992 (ntohs(cap.maxspeed) + (176/2)) / 176;
2993 }
2994
2995 /* don't print speed if the drive reported 0. 3004 /* don't print speed if the drive reported 0.
2996 */ 3005 */
2997 printk(KERN_INFO "%s: ATAPI", drive->name); 3006 printk(KERN_INFO "%s: ATAPI", drive->name);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3302cd8eab4c..d6f934886b04 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1215,7 +1215,8 @@ static int ide_disk_probe(struct device *dev)
1215 if (!idkp) 1215 if (!idkp)
1216 goto failed; 1216 goto failed;
1217 1217
1218 g = alloc_disk(1 << PARTN_BITS); 1218 g = alloc_disk_node(1 << PARTN_BITS,
1219 pcibus_to_node(drive->hwif->pci_dev->bus));
1219 if (!g) 1220 if (!g)
1220 goto out_free_idkp; 1221 goto out_free_idkp;
1221 1222
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index c949e98df4b6..9eab6426148e 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -661,10 +661,12 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
661 661
662 idefloppy_do_end_request(drive, 1, done >> 9); 662 idefloppy_do_end_request(drive, 1, done >> 9);
663 663
664#if IDEFLOPPY_DEBUG_BUGS
664 if (bcount) { 665 if (bcount) {
665 printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount); 666 printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount);
666 idefloppy_write_zeros(drive, bcount); 667 idefloppy_write_zeros(drive, bcount);
667 } 668 }
669#endif
668} 670}
669 671
670static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) 672static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
@@ -1048,6 +1050,9 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
1048 atapi_bcount_t bcount; 1050 atapi_bcount_t bcount;
1049 ide_handler_t *pkt_xfer_routine; 1051 ide_handler_t *pkt_xfer_routine;
1050 1052
1053#if 0 /* Accessing floppy->pc is not valid here, the previous pc may be gone
1054 and have lived on another thread's stack; that stack may have become
1055 unmapped meanwhile (CONFIG_DEBUG_PAGEALLOC). */
1051#if IDEFLOPPY_DEBUG_BUGS 1056#if IDEFLOPPY_DEBUG_BUGS
1052 if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD && 1057 if (floppy->pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD &&
1053 pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) { 1058 pc->c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
@@ -1055,6 +1060,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
1055 "Two request sense in serial were issued\n"); 1060 "Two request sense in serial were issued\n");
1056 } 1061 }
1057#endif /* IDEFLOPPY_DEBUG_BUGS */ 1062#endif /* IDEFLOPPY_DEBUG_BUGS */
1063#endif
1058 1064
1059 if (floppy->failed_pc == NULL && 1065 if (floppy->failed_pc == NULL &&
1060 pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD) 1066 pc->c[0] != IDEFLOPPY_REQUEST_SENSE_CMD)
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 5d876f53c697..7df85af75371 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -977,8 +977,9 @@ static int ide_init_queue(ide_drive_t *drive)
977 * limits and LBA48 we could raise it but as yet 977 * limits and LBA48 we could raise it but as yet
978 * do not. 978 * do not.
979 */ 979 */
980 980
981 q = blk_init_queue(do_ide_request, &ide_lock); 981 q = blk_init_queue_node(do_ide_request, &ide_lock,
982 pcibus_to_node(drive->hwif->pci_dev->bus));
982 if (!q) 983 if (!q)
983 return 1; 984 return 1;
984 985
@@ -1095,7 +1096,8 @@ static int init_irq (ide_hwif_t *hwif)
1095 hwgroup->hwif->next = hwif; 1096 hwgroup->hwif->next = hwif;
1096 spin_unlock_irq(&ide_lock); 1097 spin_unlock_irq(&ide_lock);
1097 } else { 1098 } else {
1098 hwgroup = kmalloc(sizeof(ide_hwgroup_t),GFP_KERNEL); 1099 hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
1100 pcibus_to_node(hwif->drives[0].hwif->pci_dev->bus));
1099 if (!hwgroup) 1101 if (!hwgroup)
1100 goto out_up; 1102 goto out_up;
1101 1103
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index f6b85222ba3d..79ca38469159 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -257,7 +257,7 @@ static int __init serport_init(void)
257 257
258static void __exit serport_exit(void) 258static void __exit serport_exit(void)
259{ 259{
260 tty_register_ldisc(N_MOUSE, NULL); 260 tty_unregister_ldisc(N_MOUSE);
261} 261}
262 262
263module_init(serport_init); 263module_init(serport_init);
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index ee3c869d9701..200a0688f717 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -122,14 +122,6 @@ static struct hash_cell *__get_uuid_cell(const char *str)
122/*----------------------------------------------------------------- 122/*-----------------------------------------------------------------
123 * Inserting, removing and renaming a device. 123 * Inserting, removing and renaming a device.
124 *---------------------------------------------------------------*/ 124 *---------------------------------------------------------------*/
125static inline char *kstrdup(const char *str)
126{
127 char *r = kmalloc(strlen(str) + 1, GFP_KERNEL);
128 if (r)
129 strcpy(r, str);
130 return r;
131}
132
133static struct hash_cell *alloc_cell(const char *name, const char *uuid, 125static struct hash_cell *alloc_cell(const char *name, const char *uuid,
134 struct mapped_device *md) 126 struct mapped_device *md)
135{ 127{
@@ -139,7 +131,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid,
139 if (!hc) 131 if (!hc)
140 return NULL; 132 return NULL;
141 133
142 hc->name = kstrdup(name); 134 hc->name = kstrdup(name, GFP_KERNEL);
143 if (!hc->name) { 135 if (!hc->name) {
144 kfree(hc); 136 kfree(hc);
145 return NULL; 137 return NULL;
@@ -149,7 +141,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid,
149 hc->uuid = NULL; 141 hc->uuid = NULL;
150 142
151 else { 143 else {
152 hc->uuid = kstrdup(uuid); 144 hc->uuid = kstrdup(uuid, GFP_KERNEL);
153 if (!hc->uuid) { 145 if (!hc->uuid) {
154 kfree(hc->name); 146 kfree(hc->name);
155 kfree(hc); 147 kfree(hc);
@@ -273,7 +265,7 @@ static int dm_hash_rename(const char *old, const char *new)
273 /* 265 /*
274 * duplicate new. 266 * duplicate new.
275 */ 267 */
276 new_name = kstrdup(new); 268 new_name = kstrdup(new, GFP_KERNEL);
277 if (!new_name) 269 if (!new_name)
278 return -ENOMEM; 270 return -ENOMEM;
279 271
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index db4f369637b6..d5666c37cb0d 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1109,8 +1109,7 @@ struct net_device * __init ltpc_probe(void)
1109 inb_p(io+1); 1109 inb_p(io+1);
1110 inb_p(io+3); 1110 inb_p(io+3);
1111 1111
1112 set_current_state(TASK_UNINTERRUPTIBLE); 1112 msleep(20);
1113 schedule_timeout(2*HZ/100);
1114 1113
1115 inb_p(io+0); 1114 inb_p(io+0);
1116 inb_p(io+2); 1115 inb_p(io+2);
@@ -1120,8 +1119,7 @@ struct net_device * __init ltpc_probe(void)
1120 inb_p(io+5); /* enable dma */ 1119 inb_p(io+5); /* enable dma */
1121 inb_p(io+6); /* tri-state interrupt line */ 1120 inb_p(io+6); /* tri-state interrupt line */
1122 1121
1123 set_current_state(TASK_UNINTERRUPTIBLE); 1122 ssleep(1);
1124 schedule_timeout(HZ);
1125 1123
1126 /* now, figure out which dma channel we're using, unless it's 1124 /* now, figure out which dma channel we're using, unless it's
1127 already been specified */ 1125 already been specified */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 325495b8b60c..137226d98d47 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2307,6 +2307,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2307 tso = e1000_tso(adapter, skb); 2307 tso = e1000_tso(adapter, skb);
2308 if (tso < 0) { 2308 if (tso < 0) {
2309 dev_kfree_skb_any(skb); 2309 dev_kfree_skb_any(skb);
2310 spin_unlock_irqrestore(&adapter->tx_lock, flags);
2310 return NETDEV_TX_OK; 2311 return NETDEV_TX_OK;
2311 } 2312 }
2312 2313
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 89454915b857..e44f8e9055ef 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -848,7 +848,7 @@ static void __exit sixpack_exit_driver(void)
848{ 848{
849 int ret; 849 int ret;
850 850
851 if ((ret = tty_register_ldisc(N_6PACK, NULL))) 851 if ((ret = tty_unregister_ldisc(N_6PACK)))
852 printk(msg_unregfail, ret); 852 printk(msg_unregfail, ret);
853} 853}
854 854
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 62790511098f..3035422f5ad8 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -934,7 +934,7 @@ static void __exit mkiss_exit_driver(void)
934 kfree(ax25_ctrls); 934 kfree(ax25_ctrls);
935 ax25_ctrls = NULL; 935 ax25_ctrls = NULL;
936 936
937 if ((i = tty_register_ldisc(N_AX25, NULL))) 937 if ((i = tty_unregister_ldisc(N_AX25)))
938 printk(KERN_ERR "mkiss: can't unregister line discipline (err = %d)\n", i); 938 printk(KERN_ERR "mkiss: can't unregister line discipline (err = %d)\n", i);
939} 939}
940 940
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 7d23aa375908..b8d112348ba4 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -626,7 +626,7 @@ static void __exit irtty_sir_cleanup(void)
626{ 626{
627 int err; 627 int err;
628 628
629 if ((err = tty_register_ldisc(N_IRDA, NULL))) { 629 if ((err = tty_unregister_ldisc(N_IRDA))) {
630 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n", 630 IRDA_ERROR("%s(), can't unregister line discipline (err = %d)\n",
631 __FUNCTION__, err); 631 __FUNCTION__, err);
632 } 632 }
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 33b9d79b1aad..5e48b9ab3045 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -1025,7 +1025,7 @@ static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
1025 1025
1026static void __exit ppp_async_cleanup(void) 1026static void __exit ppp_async_cleanup(void)
1027{ 1027{
1028 if (tty_register_ldisc(N_PPP, NULL) != 0) 1028 if (tty_unregister_ldisc(N_PPP) != 0)
1029 printk(KERN_ERR "failed to unregister PPP line discipline\n"); 1029 printk(KERN_ERR "failed to unregister PPP line discipline\n");
1030} 1030}
1031 1031
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 7d0150b4c629..fd9f50180355 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -793,7 +793,7 @@ err:
793static void __exit 793static void __exit
794ppp_sync_cleanup(void) 794ppp_sync_cleanup(void)
795{ 795{
796 if (tty_register_ldisc(N_SYNC_PPP, NULL) != 0) 796 if (tty_unregister_ldisc(N_SYNC_PPP) != 0)
797 printk(KERN_ERR "failed to unregister Sync PPP line discipline\n"); 797 printk(KERN_ERR "failed to unregister Sync PPP line discipline\n");
798} 798}
799 799
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 8f7841c0374d..19112712daf0 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -1430,7 +1430,7 @@ static void __exit slip_exit(void)
1430 kfree(slip_devs); 1430 kfree(slip_devs);
1431 slip_devs = NULL; 1431 slip_devs = NULL;
1432 1432
1433 if ((i = tty_register_ldisc(N_SLIP, NULL))) 1433 if ((i = tty_unregister_ldisc(N_SLIP)))
1434 { 1434 {
1435 printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i); 1435 printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i);
1436 } 1436 }
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 1c540d825551..bdf672c48182 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -829,7 +829,7 @@ static void __exit exit_x25_asy(void)
829 } 829 }
830 830
831 kfree(x25_asy_devs); 831 kfree(x25_asy_devs);
832 tty_register_ldisc(N_X25, NULL); 832 tty_unregister_ldisc(N_X25);
833} 833}
834 834
835module_init(init_x25_asy); 835module_init(init_x25_asy);
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index ec8cf29ffced..6c42b573a95a 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -2828,7 +2828,7 @@ static void __exit strip_exit_driver(void)
2828 /* Unregister with the /proc/net file here. */ 2828 /* Unregister with the /proc/net file here. */
2829 proc_net_remove("strip"); 2829 proc_net_remove("strip");
2830 2830
2831 if ((i = tty_register_ldisc(N_STRIP, NULL))) 2831 if ((i = tty_unregister_ldisc(N_STRIP)))
2832 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i); 2832 printk(KERN_ERR "STRIP: can't unregister line discipline (err = %d)\n", i);
2833 2833
2834 printk(signoff); 2834 printk(signoff);
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index e7f3bcb79000..80edfa3abd29 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -2751,7 +2751,6 @@ enum parport_pc_pci_cards {
2751 netmos_9755, 2751 netmos_9755,
2752 netmos_9805, 2752 netmos_9805,
2753 netmos_9815, 2753 netmos_9815,
2754 netmos_9855,
2755}; 2754};
2756 2755
2757 2756
@@ -2826,7 +2825,6 @@ static struct parport_pc_pci {
2826 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */ 2825 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */
2827 /* netmos_9805 */ { 1, { { 0, -1 }, } }, /* untested */ 2826 /* netmos_9805 */ { 1, { { 0, -1 }, } }, /* untested */
2828 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */ 2827 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */
2829 /* netmos_9855 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */
2830}; 2828};
2831 2829
2832static struct pci_device_id parport_pc_pci_tbl[] = { 2830static struct pci_device_id parport_pc_pci_tbl[] = {
@@ -2907,8 +2905,6 @@ static struct pci_device_id parport_pc_pci_tbl[] = {
2907 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 }, 2905 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 },
2908 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815, 2906 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815,
2909 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 }, 2907 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 },
2910 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
2911 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 },
2912 { 0, } /* terminate list */ 2908 { 0, } /* terminate list */
2913}; 2909};
2914MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl); 2910MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl);
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 6715a17b5d0f..00498e2f1205 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -34,6 +34,7 @@ enum parport_pc_pci_cards {
34 titan_110l = 0, 34 titan_110l = 0,
35 titan_210l, 35 titan_210l,
36 netmos_9xx5_combo, 36 netmos_9xx5_combo,
37 netmos_9855,
37 avlab_1s1p, 38 avlab_1s1p,
38 avlab_1s1p_650, 39 avlab_1s1p_650,
39 avlab_1s1p_850, 40 avlab_1s1p_850,
@@ -87,6 +88,7 @@ static struct parport_pc_pci cards[] __devinitdata = {
87 /* titan_110l */ { 1, { { 3, -1 }, } }, 88 /* titan_110l */ { 1, { { 3, -1 }, } },
88 /* titan_210l */ { 1, { { 3, -1 }, } }, 89 /* titan_210l */ { 1, { { 3, -1 }, } },
89 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init }, 90 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init },
91 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init },
90 /* avlab_1s1p */ { 1, { { 1, 2}, } }, 92 /* avlab_1s1p */ { 1, { { 1, 2}, } },
91 /* avlab_1s1p_650 */ { 1, { { 1, 2}, } }, 93 /* avlab_1s1p_650 */ { 1, { { 1, 2}, } },
92 /* avlab_1s1p_850 */ { 1, { { 1, 2}, } }, 94 /* avlab_1s1p_850 */ { 1, { { 1, 2}, } },
@@ -120,7 +122,7 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
120 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9845, 122 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9845,
121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo }, 123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo },
122 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855, 124 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
123 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9xx5_combo }, 125 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 },
124 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 126 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
125 { 0x14db, 0x2110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p}, 127 { 0x14db, 0x2110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p},
126 { 0x14db, 0x2111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_650}, 128 { 0x14db, 0x2111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_650},
@@ -207,6 +209,7 @@ static struct pci_board_no_ids pci_boards[] __devinitdata = {
207/* titan_110l */ { SPCI_FL_BASE1 | SPCI_FL_BASE_TABLE, 1, 921600 }, 209/* titan_110l */ { SPCI_FL_BASE1 | SPCI_FL_BASE_TABLE, 1, 921600 },
208/* titan_210l */ { SPCI_FL_BASE1 | SPCI_FL_BASE_TABLE, 2, 921600 }, 210/* titan_210l */ { SPCI_FL_BASE1 | SPCI_FL_BASE_TABLE, 2, 921600 },
209/* netmos_9xx5_combo */ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200, 0, 0, netmos_serial_init }, 211/* netmos_9xx5_combo */ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200, 0, 0, netmos_serial_init },
212/* netmos_9855 */ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 1, 115200, 0, 0, netmos_serial_init },
210/* avlab_1s1p (n/t) */ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 }, 213/* avlab_1s1p (n/t) */ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 },
211/* avlab_1s1p_650 (nt)*/{ SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 }, 214/* avlab_1s1p_650 (nt)*/{ SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 },
212/* avlab_1s1p_850 (nt)*/{ SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 }, 215/* avlab_1s1p_850 (nt)*/{ SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 },
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index c94963145e17..6e6f42d01e64 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -48,14 +48,6 @@ static void pretty_print(struct parport *port, int device)
48 printk("\n"); 48 printk("\n");
49} 49}
50 50
51static char *strdup(char *str)
52{
53 int n = strlen(str)+1;
54 char *s = kmalloc(n, GFP_KERNEL);
55 if (!s) return NULL;
56 return strcpy(s, str);
57}
58
59static void parse_data(struct parport *port, int device, char *str) 51static void parse_data(struct parport *port, int device, char *str)
60{ 52{
61 char *txt = kmalloc(strlen(str)+1, GFP_KERNEL); 53 char *txt = kmalloc(strlen(str)+1, GFP_KERNEL);
@@ -88,16 +80,16 @@ static void parse_data(struct parport *port, int device, char *str)
88 if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) { 80 if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) {
89 if (info->mfr) 81 if (info->mfr)
90 kfree (info->mfr); 82 kfree (info->mfr);
91 info->mfr = strdup(sep); 83 info->mfr = kstrdup(sep, GFP_KERNEL);
92 } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) { 84 } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) {
93 if (info->model) 85 if (info->model)
94 kfree (info->model); 86 kfree (info->model);
95 info->model = strdup(sep); 87 info->model = kstrdup(sep, GFP_KERNEL);
96 } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) { 88 } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) {
97 int i; 89 int i;
98 if (info->class_name) 90 if (info->class_name)
99 kfree (info->class_name); 91 kfree (info->class_name);
100 info->class_name = strdup(sep); 92 info->class_name = kstrdup(sep, GFP_KERNEL);
101 for (u = sep; *u; u++) 93 for (u = sep; *u; u++)
102 *u = toupper(*u); 94 *u = toupper(*u);
103 for (i = 0; classes[i].token; i++) { 95 for (i = 0; classes[i].token; i++) {
@@ -112,7 +104,7 @@ static void parse_data(struct parport *port, int device, char *str)
112 !strcmp(p, "COMMAND SET")) { 104 !strcmp(p, "COMMAND SET")) {
113 if (info->cmdset) 105 if (info->cmdset)
114 kfree (info->cmdset); 106 kfree (info->cmdset);
115 info->cmdset = strdup(sep); 107 info->cmdset = kstrdup(sep, GFP_KERNEL);
116 /* if it speaks printer language, it's 108 /* if it speaks printer language, it's
117 probably a printer */ 109 probably a printer */
118 if (strstr(sep, "PJL") || strstr(sep, "PCL")) 110 if (strstr(sep, "PJL") || strstr(sep, "PCL"))
@@ -120,7 +112,7 @@ static void parse_data(struct parport *port, int device, char *str)
120 } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) { 112 } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) {
121 if (info->description) 113 if (info->description)
122 kfree (info->description); 114 kfree (info->description);
123 info->description = strdup(sep); 115 info->description = kstrdup(sep, GFP_KERNEL);
124 } 116 }
125 } 117 }
126 rock_on: 118 rock_on:
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 03fc885db1c5..d136b3c8fac9 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -508,6 +508,10 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
508 cs_err(skt, "unsupported voltage key.\n"); 508 cs_err(skt, "unsupported voltage key.\n");
509 return CS_BAD_TYPE; 509 return CS_BAD_TYPE;
510 } 510 }
511
512 if (skt->power_hook)
513 skt->power_hook(skt, HOOK_POWER_PRE);
514
511 skt->socket.flags = 0; 515 skt->socket.flags = 0;
512 skt->ops->set_socket(skt, &skt->socket); 516 skt->ops->set_socket(skt, &skt->socket);
513 517
@@ -522,7 +526,12 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
522 return CS_BAD_TYPE; 526 return CS_BAD_TYPE;
523 } 527 }
524 528
525 return socket_reset(skt); 529 status = socket_reset(skt);
530
531 if (skt->power_hook)
532 skt->power_hook(skt, HOOK_POWER_POST);
533
534 return status;
526} 535}
527 536
528/* 537/*
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index a8a1d104524a..c7ba99871aca 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -611,6 +611,170 @@ out:
611 } 611 }
612} 612}
613 613
614
615/* Returns true value if the second slot of a two-slot controller is empty */
616static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
617{
618 struct pci_dev *func;
619 struct yenta_socket *slot2;
620 int devfn;
621 unsigned int state;
622 int ret = 1;
623
624 /* catch the two-slot controllers */
625 switch (socket->dev->device) {
626 case PCI_DEVICE_ID_TI_1220:
627 case PCI_DEVICE_ID_TI_1221:
628 case PCI_DEVICE_ID_TI_1225:
629 case PCI_DEVICE_ID_TI_1251A:
630 case PCI_DEVICE_ID_TI_1251B:
631 case PCI_DEVICE_ID_TI_1420:
632 case PCI_DEVICE_ID_TI_1450:
633 case PCI_DEVICE_ID_TI_1451A:
634 case PCI_DEVICE_ID_TI_1520:
635 case PCI_DEVICE_ID_TI_1620:
636 case PCI_DEVICE_ID_TI_4520:
637 case PCI_DEVICE_ID_TI_4450:
638 case PCI_DEVICE_ID_TI_4451:
639 /*
640 * there are way more, but they need to be added in yenta_socket.c
641 * and pci_ids.h first anyway.
642 */
643 break;
644
645 /* single-slot controllers have the 2nd slot empty always :) */
646 default:
647 return 1;
648 }
649
650 /* get other slot */
651 devfn = socket->dev->devfn & ~0x07;
652 func = pci_get_slot(socket->dev->bus,
653 (socket->dev->devfn & 0x07) ? devfn : devfn | 0x01);
654 if (!func)
655 return 1;
656
657 slot2 = pci_get_drvdata(func);
658 if (!slot2)
659 goto out;
660
661 /* check state */
662 yenta_get_status(&socket->socket, &state);
663 if (state & SS_DETECT) {
664 ret = 0;
665 goto out;
666 }
667
668out:
669 pci_dev_put(func);
670 return ret;
671}
672
673/*
674 * TI specifiy parts for the power hook.
675 *
676 * some TI's with some CB's produces interrupt storm on power on. it has been
677 * seen with atheros wlan cards on TI1225 and TI1410. solution is simply to
678 * disable any CB interrupts during this time.
679 */
680static int ti12xx_power_hook(struct pcmcia_socket *sock, int operation)
681{
682 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
683 u32 mfunc, devctl, sysctl;
684 u8 gpio3;
685
686 /* only POWER_PRE and POWER_POST are interesting */
687 if ((operation != HOOK_POWER_PRE) && (operation != HOOK_POWER_POST))
688 return 0;
689
690 devctl = config_readb(socket, TI113X_DEVICE_CONTROL);
691 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
692 mfunc = config_readl(socket, TI122X_MFUNC);
693
694 /*
695 * all serial/tied: only disable when modparm set. always doing it
696 * would mean a regression for working setups 'cos it disables the
697 * interrupts for both both slots on 2-slot controllers
698 * (and users of single slot controllers where it's save have to
699 * live with setting the modparm, most don't have to anyway)
700 */
701 if (((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) &&
702 (pwr_irqs_off || ti12xx_2nd_slot_empty(socket))) {
703 switch (socket->dev->device) {
704 case PCI_DEVICE_ID_TI_1250:
705 case PCI_DEVICE_ID_TI_1251A:
706 case PCI_DEVICE_ID_TI_1251B:
707 case PCI_DEVICE_ID_TI_1450:
708 case PCI_DEVICE_ID_TI_1451A:
709 case PCI_DEVICE_ID_TI_4450:
710 case PCI_DEVICE_ID_TI_4451:
711 /* these chips have no IRQSER setting in MFUNC3 */
712 break;
713
714 default:
715 if (operation == HOOK_POWER_PRE)
716 mfunc = (mfunc & ~TI122X_MFUNC3_MASK);
717 else
718 mfunc = (mfunc & ~TI122X_MFUNC3_MASK) | TI122X_MFUNC3_IRQSER;
719 }
720
721 return 0;
722 }
723
724 /* do the job differently for func0/1 */
725 if ((PCI_FUNC(socket->dev->devfn) == 0) ||
726 ((sysctl & TI122X_SCR_INTRTIE) &&
727 (pwr_irqs_off || ti12xx_2nd_slot_empty(socket)))) {
728 /* some bridges are different */
729 switch (socket->dev->device) {
730 case PCI_DEVICE_ID_TI_1250:
731 case PCI_DEVICE_ID_TI_1251A:
732 case PCI_DEVICE_ID_TI_1251B:
733 case PCI_DEVICE_ID_TI_1450:
734 /* those oldies use gpio3 for INTA */
735 gpio3 = config_readb(socket, TI1250_GPIO3_CONTROL);
736 if (operation == HOOK_POWER_PRE)
737 gpio3 = (gpio3 & ~TI1250_GPIO_MODE_MASK) | 0x40;
738 else
739 gpio3 &= ~TI1250_GPIO_MODE_MASK;
740 config_writeb(socket, TI1250_GPIO3_CONTROL, gpio3);
741 break;
742
743 default:
744 /* all new bridges are the same */
745 if (operation == HOOK_POWER_PRE)
746 mfunc &= ~TI122X_MFUNC0_MASK;
747 else
748 mfunc |= TI122X_MFUNC0_INTA;
749 config_writel(socket, TI122X_MFUNC, mfunc);
750 }
751 } else {
752 switch (socket->dev->device) {
753 case PCI_DEVICE_ID_TI_1251A:
754 case PCI_DEVICE_ID_TI_1251B:
755 case PCI_DEVICE_ID_TI_1450:
756 /* those have INTA elsewhere and INTB in MFUNC0 */
757 if (operation == HOOK_POWER_PRE)
758 mfunc &= ~TI122X_MFUNC0_MASK;
759 else
760 mfunc |= TI125X_MFUNC0_INTB;
761 config_writel(socket, TI122X_MFUNC, mfunc);
762
763 break;
764
765 default:
766 /* all new bridges are the same */
767 if (operation == HOOK_POWER_PRE)
768 mfunc &= ~TI122X_MFUNC1_MASK;
769 else
770 mfunc |= TI122X_MFUNC1_INTB;
771 config_writel(socket, TI122X_MFUNC, mfunc);
772 }
773 }
774
775 return 0;
776}
777
614static int ti12xx_override(struct yenta_socket *socket) 778static int ti12xx_override(struct yenta_socket *socket)
615{ 779{
616 u32 val, val_orig; 780 u32 val, val_orig;
@@ -654,6 +818,9 @@ static int ti12xx_override(struct yenta_socket *socket)
654 else 818 else
655 ti12xx_irqroute_func1(socket); 819 ti12xx_irqroute_func1(socket);
656 820
821 /* install power hook */
822 socket->socket.power_hook = ti12xx_power_hook;
823
657 return ti_override(socket); 824 return ti_override(socket);
658} 825}
659 826
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 6404d97a12eb..bee05362fd24 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -32,6 +32,14 @@ static int disable_clkrun;
32module_param(disable_clkrun, bool, 0444); 32module_param(disable_clkrun, bool, 0444);
33MODULE_PARM_DESC(disable_clkrun, "If PC card doesn't function properly, please try this option"); 33MODULE_PARM_DESC(disable_clkrun, "If PC card doesn't function properly, please try this option");
34 34
35static int isa_probe = 1;
36module_param(isa_probe, bool, 0444);
37MODULE_PARM_DESC(isa_probe, "If set ISA interrupts are probed (default). Set to N to disable probing");
38
39static int pwr_irqs_off;
40module_param(pwr_irqs_off, bool, 0644);
41MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!");
42
35#if 0 43#if 0
36#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args) 44#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args)
37#else 45#else
@@ -150,15 +158,16 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
150 158
151 val = (state & CB_3VCARD) ? SS_3VCARD : 0; 159 val = (state & CB_3VCARD) ? SS_3VCARD : 0;
152 val |= (state & CB_XVCARD) ? SS_XVCARD : 0; 160 val |= (state & CB_XVCARD) ? SS_XVCARD : 0;
153 val |= (state & (CB_CDETECT1 | CB_CDETECT2 | CB_5VCARD | CB_3VCARD 161 val |= (state & (CB_5VCARD | CB_3VCARD | CB_XVCARD | CB_YVCARD)) ? 0 : SS_PENDING;
154 | CB_XVCARD | CB_YVCARD)) ? 0 : SS_PENDING; 162 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? SS_PENDING : 0;
163
155 164
156 if (state & CB_CBCARD) { 165 if (state & CB_CBCARD) {
157 val |= SS_CARDBUS; 166 val |= SS_CARDBUS;
158 val |= (state & CB_CARDSTS) ? SS_STSCHG : 0; 167 val |= (state & CB_CARDSTS) ? SS_STSCHG : 0;
159 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; 168 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
160 val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; 169 val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
161 } else { 170 } else if (state & CB_16BITCARD) {
162 u8 status = exca_readb(socket, I365_STATUS); 171 u8 status = exca_readb(socket, I365_STATUS);
163 val |= ((status & I365_CS_DETECT) == I365_CS_DETECT) ? SS_DETECT : 0; 172 val |= ((status & I365_CS_DETECT) == I365_CS_DETECT) ? SS_DETECT : 0;
164 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { 173 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
@@ -405,11 +414,13 @@ static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *
405} 414}
406 415
407 416
408static unsigned int yenta_events(struct yenta_socket *socket) 417
418static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
409{ 419{
420 unsigned int events;
421 struct yenta_socket *socket = (struct yenta_socket *) dev_id;
410 u8 csc; 422 u8 csc;
411 u32 cb_event; 423 u32 cb_event;
412 unsigned int events;
413 424
414 /* Clear interrupt status for the event */ 425 /* Clear interrupt status for the event */
415 cb_event = cb_readl(socket, CB_SOCKET_EVENT); 426 cb_event = cb_readl(socket, CB_SOCKET_EVENT);
@@ -426,20 +437,13 @@ static unsigned int yenta_events(struct yenta_socket *socket)
426 events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0; 437 events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0;
427 events |= (csc & I365_CSC_READY) ? SS_READY : 0; 438 events |= (csc & I365_CSC_READY) ? SS_READY : 0;
428 } 439 }
429 return events;
430}
431
432
433static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
434{
435 unsigned int events;
436 struct yenta_socket *socket = (struct yenta_socket *) dev_id;
437 440
438 events = yenta_events(socket); 441 if (events)
439 if (events) {
440 pcmcia_parse_events(&socket->socket, events); 442 pcmcia_parse_events(&socket->socket, events);
443
444 if (cb_event || csc)
441 return IRQ_HANDLED; 445 return IRQ_HANDLED;
442 } 446
443 return IRQ_NONE; 447 return IRQ_NONE;
444} 448}
445 449
@@ -470,11 +474,22 @@ static void yenta_clear_maps(struct yenta_socket *socket)
470 } 474 }
471} 475}
472 476
477/* redoes voltage interrogation if required */
478static void yenta_interrogate(struct yenta_socket *socket)
479{
480 u32 state;
481
482 state = cb_readl(socket, CB_SOCKET_STATE);
483 if (!(state & (CB_5VCARD | CB_3VCARD | CB_XVCARD | CB_YVCARD)) ||
484 (state & (CB_CDETECT1 | CB_CDETECT2 | CB_NOTACARD | CB_BADVCCREQ)) ||
485 ((state & (CB_16BITCARD | CB_CBCARD)) == (CB_16BITCARD | CB_CBCARD)))
486 cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
487}
488
473/* Called at resume and initialization events */ 489/* Called at resume and initialization events */
474static int yenta_sock_init(struct pcmcia_socket *sock) 490static int yenta_sock_init(struct pcmcia_socket *sock)
475{ 491{
476 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 492 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
477 u32 state;
478 u16 bridge; 493 u16 bridge;
479 494
480 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR; 495 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
@@ -486,10 +501,7 @@ static int yenta_sock_init(struct pcmcia_socket *sock)
486 exca_writeb(socket, I365_GENCTL, 0x00); 501 exca_writeb(socket, I365_GENCTL, 0x00);
487 502
488 /* Redo card voltage interrogation */ 503 /* Redo card voltage interrogation */
489 state = cb_readl(socket, CB_SOCKET_STATE); 504 yenta_interrogate(socket);
490 if (!(state & (CB_CDETECT1 | CB_CDETECT2 | CB_5VCARD |
491 CB_3VCARD | CB_XVCARD | CB_YVCARD)))
492 cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
493 505
494 yenta_clear_maps(socket); 506 yenta_clear_maps(socket);
495 507
@@ -856,7 +868,10 @@ static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_i
856 socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS; 868 socket->socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD | SS_CAP_CARDBUS;
857 socket->socket.map_size = 0x1000; 869 socket->socket.map_size = 0x1000;
858 socket->socket.pci_irq = socket->cb_irq; 870 socket->socket.pci_irq = socket->cb_irq;
859 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask); 871 if (isa_probe)
872 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
873 else
874 socket->socket.irq_mask = 0;
860 socket->socket.cb_dev = socket->dev; 875 socket->socket.cb_dev = socket->dev;
861 876
862 printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n", 877 printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n",
@@ -996,6 +1011,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
996 } 1011 }
997 1012
998 /* Figure out what the dang thing can do for the PCMCIA layer... */ 1013 /* Figure out what the dang thing can do for the PCMCIA layer... */
1014 yenta_interrogate(socket);
999 yenta_get_socket_capabilities(socket, isa_interrupts); 1015 yenta_get_socket_capabilities(socket, isa_interrupts);
1000 printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); 1016 printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
1001 1017
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 9cc0015b717d..a699c30b2662 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1126,11 +1126,11 @@ static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout)
1126 struct adpt_i2o_post_wait_data *p1, *p2; 1126 struct adpt_i2o_post_wait_data *p1, *p2;
1127 struct adpt_i2o_post_wait_data *wait_data = 1127 struct adpt_i2o_post_wait_data *wait_data =
1128 kmalloc(sizeof(struct adpt_i2o_post_wait_data),GFP_KERNEL); 1128 kmalloc(sizeof(struct adpt_i2o_post_wait_data),GFP_KERNEL);
1129 adpt_wait_queue_t wait; 1129 DECLARE_WAITQUEUE(wait, current);
1130 1130
1131 if(!wait_data){ 1131 if (!wait_data)
1132 return -ENOMEM; 1132 return -ENOMEM;
1133 } 1133
1134 /* 1134 /*
1135 * The spin locking is needed to keep anyone from playing 1135 * The spin locking is needed to keep anyone from playing
1136 * with the queue pointers and id while we do the same 1136 * with the queue pointers and id while we do the same
@@ -1148,12 +1148,7 @@ static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout)
1148 wait_data->wq = &adpt_wq_i2o_post; 1148 wait_data->wq = &adpt_wq_i2o_post;
1149 wait_data->status = -ETIMEDOUT; 1149 wait_data->status = -ETIMEDOUT;
1150 1150
1151 // this code is taken from kernel/sched.c:interruptible_sleep_on_timeout 1151 add_wait_queue(&adpt_wq_i2o_post, &wait);
1152 wait.task = current;
1153 init_waitqueue_entry(&wait, current);
1154 spin_lock_irqsave(&adpt_wq_i2o_post.lock, flags);
1155 __add_wait_queue(&adpt_wq_i2o_post, &wait);
1156 spin_unlock(&adpt_wq_i2o_post.lock);
1157 1152
1158 msg[2] |= 0x80000000 | ((u32)wait_data->id); 1153 msg[2] |= 0x80000000 | ((u32)wait_data->id);
1159 timeout *= HZ; 1154 timeout *= HZ;
@@ -1175,9 +1170,7 @@ static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout)
1175 if(pHba->host) 1170 if(pHba->host)
1176 spin_lock_irq(pHba->host->host_lock); 1171 spin_lock_irq(pHba->host->host_lock);
1177 } 1172 }
1178 spin_lock_irq(&adpt_wq_i2o_post.lock); 1173 remove_wait_queue(&adpt_wq_i2o_post, &wait);
1179 __remove_wait_queue(&adpt_wq_i2o_post, &wait);
1180 spin_unlock_irqrestore(&adpt_wq_i2o_post.lock, flags);
1181 1174
1182 if(status == -ETIMEDOUT){ 1175 if(status == -ETIMEDOUT){
1183 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit); 1176 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit);
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index fee6418e84c4..840815fde49b 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -572,6 +572,7 @@ static void sn_transmit_chars(struct sn_cons_port *port, int raw)
572 572
573 if (uart_circ_empty(xmit) || uart_tx_stopped(&port->sc_port)) { 573 if (uart_circ_empty(xmit) || uart_tx_stopped(&port->sc_port)) {
574 /* Nothing to do. */ 574 /* Nothing to do. */
575 ia64_sn_console_intr_disable(SAL_CONSOLE_INTR_XMIT);
575 return; 576 return;
576 } 577 }
577 578
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index f9f9561c6bad..c3e3a95d3804 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -453,17 +453,6 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
453 return 0; 453 return 0;
454} 454}
455 455
456static struct dentry * get_dentry(struct dentry *parent, const char *name)
457{
458 struct qstr qstr;
459
460 qstr.name = name;
461 qstr.len = strlen(name);
462 qstr.hash = full_name_hash(name,qstr.len);
463 return lookup_hash(&qstr,parent);
464}
465
466
467/* 456/*
468 * fs_create_by_name - create a file, given a name 457 * fs_create_by_name - create a file, given a name
469 * @name: name of file 458 * @name: name of file
@@ -496,7 +485,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
496 485
497 *dentry = NULL; 486 *dentry = NULL;
498 down(&parent->d_inode->i_sem); 487 down(&parent->d_inode->i_sem);
499 *dentry = get_dentry (parent, name); 488 *dentry = lookup_one_len(name, parent, strlen(name));
500 if (!IS_ERR(dentry)) { 489 if (!IS_ERR(dentry)) {
501 if ((mode & S_IFMT) == S_IFDIR) 490 if ((mode & S_IFMT) == S_IFDIR)
502 error = usbfs_mkdir (parent->d_inode, *dentry, mode); 491 error = usbfs_mkdir (parent->d_inode, *dentry, mode);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 2d8bd9dcc6ed..740dec1f521d 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1762,7 +1762,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
1762 intf->altsetting->desc.bInterfaceNumber); 1762 intf->altsetting->desc.bInterfaceNumber);
1763 1763
1764 if (!(hid = usb_hid_configure(intf))) 1764 if (!(hid = usb_hid_configure(intf)))
1765 return -EIO; 1765 return -ENODEV;
1766 1766
1767 hid_init_reports(hid); 1767 hid_init_reports(hid);
1768 hid_dump_device(hid); 1768 hid_dump_device(hid);
@@ -1777,7 +1777,7 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
1777 if (!hid->claimed) { 1777 if (!hid->claimed) {
1778 printk ("HID device not claimed by input or hiddev\n"); 1778 printk ("HID device not claimed by input or hiddev\n");
1779 hid_disconnect(intf); 1779 hid_disconnect(intf);
1780 return -EIO; 1780 return -ENODEV;
1781 } 1781 }
1782 1782
1783 printk(KERN_INFO); 1783 printk(KERN_INFO);
diff --git a/drivers/usb/media/pwc/pwc-uncompress.c b/drivers/usb/media/pwc/pwc-uncompress.c
index bc3b1635eab0..ef4204eab6c4 100644
--- a/drivers/usb/media/pwc/pwc-uncompress.c
+++ b/drivers/usb/media/pwc/pwc-uncompress.c
@@ -118,9 +118,9 @@ int pwc_decompress(struct pwc_device *pdev)
118 return -ENXIO; /* No such device or address: missing decompressor */ 118 return -ENXIO; /* No such device or address: missing decompressor */
119 } 119 }
120 120
121#if 0
121 switch (pdev->type) 122 switch (pdev->type)
122 { 123 {
123#if 0
124 case 675: 124 case 675:
125 case 680: 125 case 680:
126 case 690: 126 case 690:
@@ -128,18 +128,17 @@ int pwc_decompress(struct pwc_device *pdev)
128 case 730: 128 case 730:
129 case 740: 129 case 740:
130 case 750: 130 case 750:
131 pwc_dec23_decompress(&pdev->image, &pdev->view, &pdev->offset, 131 pwc_dec23_decompress(&pdev->image, &pdev->view,
132 yuv, image, 132 &pdev->offset, yuv, image, flags,
133 flags,
134 pdev->decompress_data, pdev->vbandlength); 133 pdev->decompress_data, pdev->vbandlength);
135 break; 134 break;
136 case 645: 135 case 645:
137 case 646: 136 case 646:
138 /* TODO & FIXME */ 137 /* TODO & FIXME */
139#endif 138 return -ENXIO; /* Missing decompressor */
140 return -ENXIO; /* No such device or address: missing decompressor */
141 break; 139 break;
142 } 140 }
141#endif
143 } 142 }
144 return 0; 143 return 0;
145} 144}
diff --git a/fs/block_dev.c b/fs/block_dev.c
index c0cbd1bc1a02..e0df94c37b7e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -777,8 +777,7 @@ static ssize_t blkdev_file_aio_write(struct kiocb *iocb, const char __user *buf,
777 return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); 777 return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
778} 778}
779 779
780static int block_ioctl(struct inode *inode, struct file *file, unsigned cmd, 780static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
781 unsigned long arg)
782{ 781{
783 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg); 782 return blkdev_ioctl(file->f_mapping->host, file, cmd, arg);
784} 783}
@@ -803,7 +802,7 @@ struct file_operations def_blk_fops = {
803 .aio_write = blkdev_file_aio_write, 802 .aio_write = blkdev_file_aio_write,
804 .mmap = generic_file_mmap, 803 .mmap = generic_file_mmap,
805 .fsync = block_fsync, 804 .fsync = block_fsync,
806 .ioctl = block_ioctl, 805 .unlocked_ioctl = block_ioctl,
807#ifdef CONFIG_COMPAT 806#ifdef CONFIG_COMPAT
808 .compat_ioctl = compat_blkdev_ioctl, 807 .compat_ioctl = compat_blkdev_ioctl,
809#endif 808#endif
diff --git a/fs/buffer.c b/fs/buffer.c
index 0befa724ab98..13e5938a64f6 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -331,7 +331,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
331 return ret; 331 return ret;
332} 332}
333 333
334asmlinkage long sys_fsync(unsigned int fd) 334static long do_fsync(unsigned int fd, int datasync)
335{ 335{
336 struct file * file; 336 struct file * file;
337 struct address_space *mapping; 337 struct address_space *mapping;
@@ -342,14 +342,14 @@ asmlinkage long sys_fsync(unsigned int fd)
342 if (!file) 342 if (!file)
343 goto out; 343 goto out;
344 344
345 mapping = file->f_mapping;
346
347 ret = -EINVAL; 345 ret = -EINVAL;
348 if (!file->f_op || !file->f_op->fsync) { 346 if (!file->f_op || !file->f_op->fsync) {
349 /* Why? We can still call filemap_fdatawrite */ 347 /* Why? We can still call filemap_fdatawrite */
350 goto out_putf; 348 goto out_putf;
351 } 349 }
352 350
351 mapping = file->f_mapping;
352
353 current->flags |= PF_SYNCWRITE; 353 current->flags |= PF_SYNCWRITE;
354 ret = filemap_fdatawrite(mapping); 354 ret = filemap_fdatawrite(mapping);
355 355
@@ -358,7 +358,7 @@ asmlinkage long sys_fsync(unsigned int fd)
358 * which could cause livelocks in fsync_buffers_list 358 * which could cause livelocks in fsync_buffers_list
359 */ 359 */
360 down(&mapping->host->i_sem); 360 down(&mapping->host->i_sem);
361 err = file->f_op->fsync(file, file->f_dentry, 0); 361 err = file->f_op->fsync(file, file->f_dentry, datasync);
362 if (!ret) 362 if (!ret)
363 ret = err; 363 ret = err;
364 up(&mapping->host->i_sem); 364 up(&mapping->host->i_sem);
@@ -373,39 +373,14 @@ out:
373 return ret; 373 return ret;
374} 374}
375 375
376asmlinkage long sys_fdatasync(unsigned int fd) 376asmlinkage long sys_fsync(unsigned int fd)
377{ 377{
378 struct file * file; 378 return do_fsync(fd, 0);
379 struct address_space *mapping; 379}
380 int ret, err;
381
382 ret = -EBADF;
383 file = fget(fd);
384 if (!file)
385 goto out;
386
387 ret = -EINVAL;
388 if (!file->f_op || !file->f_op->fsync)
389 goto out_putf;
390
391 mapping = file->f_mapping;
392
393 current->flags |= PF_SYNCWRITE;
394 ret = filemap_fdatawrite(mapping);
395 down(&mapping->host->i_sem);
396 err = file->f_op->fsync(file, file->f_dentry, 1);
397 if (!ret)
398 ret = err;
399 up(&mapping->host->i_sem);
400 err = filemap_fdatawait(mapping);
401 if (!ret)
402 ret = err;
403 current->flags &= ~PF_SYNCWRITE;
404 380
405out_putf: 381asmlinkage long sys_fdatasync(unsigned int fd)
406 fput(file); 382{
407out: 383 return do_fsync(fd, 1);
408 return ret;
409} 384}
410 385
411/* 386/*
@@ -1951,7 +1926,6 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1951 if (err) 1926 if (err)
1952 break; 1927 break;
1953 if (buffer_new(bh)) { 1928 if (buffer_new(bh)) {
1954 clear_buffer_new(bh);
1955 unmap_underlying_metadata(bh->b_bdev, 1929 unmap_underlying_metadata(bh->b_bdev,
1956 bh->b_blocknr); 1930 bh->b_blocknr);
1957 if (PageUptodate(page)) { 1931 if (PageUptodate(page)) {
@@ -1993,9 +1967,14 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1993 if (!buffer_uptodate(*wait_bh)) 1967 if (!buffer_uptodate(*wait_bh))
1994 err = -EIO; 1968 err = -EIO;
1995 } 1969 }
1996 if (!err) 1970 if (!err) {
1997 return err; 1971 bh = head;
1998 1972 do {
1973 if (buffer_new(bh))
1974 clear_buffer_new(bh);
1975 } while ((bh = bh->b_this_page) != head);
1976 return 0;
1977 }
1999 /* Error case: */ 1978 /* Error case: */
2000 /* 1979 /*
2001 * Zero out any newly allocated blocks to avoid exposing stale 1980 * Zero out any newly allocated blocks to avoid exposing stale
diff --git a/fs/char_dev.c b/fs/char_dev.c
index c1e3537909fc..e82aac9cc2f5 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -56,10 +56,21 @@ int get_chrdev_list(char *page)
56 56
57 down(&chrdevs_lock); 57 down(&chrdevs_lock);
58 for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) { 58 for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) {
59 for (cd = chrdevs[i]; cd; cd = cd->next) 59 for (cd = chrdevs[i]; cd; cd = cd->next) {
60 /*
61 * if the current name, plus the 5 extra characters
62 * in the device line for this entry
63 * would run us off the page, we're done
64 */
65 if ((len+strlen(cd->name) + 5) >= PAGE_SIZE)
66 goto page_full;
67
68
60 len += sprintf(page+len, "%3d %s\n", 69 len += sprintf(page+len, "%3d %s\n",
61 cd->major, cd->name); 70 cd->major, cd->name);
71 }
62 } 72 }
73page_full:
63 up(&chrdevs_lock); 74 up(&chrdevs_lock);
64 75
65 return len; 76 return len;
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index b529786699e7..a86ac4aeaedb 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -110,16 +110,6 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent)
110 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files); 110 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
111} 111}
112 112
113static struct dentry * get_dentry(struct dentry *parent, const char *name)
114{
115 struct qstr qstr;
116
117 qstr.name = name;
118 qstr.len = strlen(name);
119 qstr.hash = full_name_hash(name,qstr.len);
120 return lookup_hash(&qstr,parent);
121}
122
123static struct super_block *debug_get_sb(struct file_system_type *fs_type, 113static struct super_block *debug_get_sb(struct file_system_type *fs_type,
124 int flags, const char *dev_name, 114 int flags, const char *dev_name,
125 void *data) 115 void *data)
@@ -157,7 +147,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
157 147
158 *dentry = NULL; 148 *dentry = NULL;
159 down(&parent->d_inode->i_sem); 149 down(&parent->d_inode->i_sem);
160 *dentry = get_dentry (parent, name); 150 *dentry = lookup_one_len(name, parent, strlen(name));
161 if (!IS_ERR(dentry)) { 151 if (!IS_ERR(dentry)) {
162 if ((mode & S_IFMT) == S_IFDIR) 152 if ((mode & S_IFMT) == S_IFDIR)
163 error = debugfs_mkdir(parent->d_inode, *dentry, mode); 153 error = debugfs_mkdir(parent->d_inode, *dentry, mode);
diff --git a/fs/dquot.c b/fs/dquot.c
index 3995ce7907cc..37212b039a4a 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1519,14 +1519,22 @@ out_path:
1519 * This function is used when filesystem needs to initialize quotas 1519 * This function is used when filesystem needs to initialize quotas
1520 * during mount time. 1520 * during mount time.
1521 */ 1521 */
1522int vfs_quota_on_mount(int type, int format_id, struct dentry *dentry) 1522int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
1523 int format_id, int type)
1523{ 1524{
1525 struct dentry *dentry;
1524 int error; 1526 int error;
1525 1527
1528 dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name));
1529 if (IS_ERR(dentry))
1530 return PTR_ERR(dentry);
1531
1526 error = security_quota_on(dentry); 1532 error = security_quota_on(dentry);
1527 if (error) 1533 if (!error)
1528 return error; 1534 error = vfs_quota_on_inode(dentry->d_inode, type, format_id);
1529 return vfs_quota_on_inode(dentry->d_inode, type, format_id); 1535
1536 dput(dentry);
1537 return error;
1530} 1538}
1531 1539
1532/* Generic routine for getting common part of quota structure */ 1540/* Generic routine for getting common part of quota structure */
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 9900e333655a..6ab1dd0ca904 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -101,57 +101,6 @@
101/* Maximum number of poll wake up nests we are allowing */ 101/* Maximum number of poll wake up nests we are allowing */
102#define EP_MAX_POLLWAKE_NESTS 4 102#define EP_MAX_POLLWAKE_NESTS 4
103 103
104/* Macro to allocate a "struct epitem" from the slab cache */
105#define EPI_MEM_ALLOC() (struct epitem *) kmem_cache_alloc(epi_cache, SLAB_KERNEL)
106
107/* Macro to free a "struct epitem" to the slab cache */
108#define EPI_MEM_FREE(p) kmem_cache_free(epi_cache, p)
109
110/* Macro to allocate a "struct eppoll_entry" from the slab cache */
111#define PWQ_MEM_ALLOC() (struct eppoll_entry *) kmem_cache_alloc(pwq_cache, SLAB_KERNEL)
112
113/* Macro to free a "struct eppoll_entry" to the slab cache */
114#define PWQ_MEM_FREE(p) kmem_cache_free(pwq_cache, p)
115
116/* Fast test to see if the file is an evenpoll file */
117#define IS_FILE_EPOLL(f) ((f)->f_op == &eventpoll_fops)
118
119/* Setup the structure that is used as key for the rb-tree */
120#define EP_SET_FFD(p, f, d) do { (p)->file = (f); (p)->fd = (d); } while (0)
121
122/* Compare rb-tree keys */
123#define EP_CMP_FFD(p1, p2) ((p1)->file > (p2)->file ? +1: \
124 ((p1)->file < (p2)->file ? -1: (p1)->fd - (p2)->fd))
125
126/* Special initialization for the rb-tree node to detect linkage */
127#define EP_RB_INITNODE(n) (n)->rb_parent = (n)
128
129/* Removes a node from the rb-tree and marks it for a fast is-linked check */
130#define EP_RB_ERASE(n, r) do { rb_erase(n, r); (n)->rb_parent = (n); } while (0)
131
132/* Fast check to verify that the item is linked to the main rb-tree */
133#define EP_RB_LINKED(n) ((n)->rb_parent != (n))
134
135/*
136 * Remove the item from the list and perform its initialization.
137 * This is useful for us because we can test if the item is linked
138 * using "EP_IS_LINKED(p)".
139 */
140#define EP_LIST_DEL(p) do { list_del(p); INIT_LIST_HEAD(p); } while (0)
141
142/* Tells us if the item is currently linked */
143#define EP_IS_LINKED(p) (!list_empty(p))
144
145/* Get the "struct epitem" from a wait queue pointer */
146#define EP_ITEM_FROM_WAIT(p) ((struct epitem *) container_of(p, struct eppoll_entry, wait)->base)
147
148/* Get the "struct epitem" from an epoll queue wrapper */
149#define EP_ITEM_FROM_EPQUEUE(p) (container_of(p, struct ep_pqueue, pt)->epi)
150
151/* Tells if the epoll_ctl(2) operation needs an event copy from userspace */
152#define EP_OP_HASH_EVENT(op) ((op) != EPOLL_CTL_DEL)
153
154
155struct epoll_filefd { 104struct epoll_filefd {
156 struct file *file; 105 struct file *file;
157 int fd; 106 int fd;
@@ -357,6 +306,82 @@ static struct dentry_operations eventpollfs_dentry_operations = {
357 306
358 307
359 308
309/* Fast test to see if the file is an evenpoll file */
310static inline int is_file_epoll(struct file *f)
311{
312 return f->f_op == &eventpoll_fops;
313}
314
315/* Setup the structure that is used as key for the rb-tree */
316static inline void ep_set_ffd(struct epoll_filefd *ffd,
317 struct file *file, int fd)
318{
319 ffd->file = file;
320 ffd->fd = fd;
321}
322
323/* Compare rb-tree keys */
324static inline int ep_cmp_ffd(struct epoll_filefd *p1,
325 struct epoll_filefd *p2)
326{
327 return (p1->file > p2->file ? +1:
328 (p1->file < p2->file ? -1 : p1->fd - p2->fd));
329}
330
331/* Special initialization for the rb-tree node to detect linkage */
332static inline void ep_rb_initnode(struct rb_node *n)
333{
334 n->rb_parent = n;
335}
336
337/* Removes a node from the rb-tree and marks it for a fast is-linked check */
338static inline void ep_rb_erase(struct rb_node *n, struct rb_root *r)
339{
340 rb_erase(n, r);
341 n->rb_parent = n;
342}
343
344/* Fast check to verify that the item is linked to the main rb-tree */
345static inline int ep_rb_linked(struct rb_node *n)
346{
347 return n->rb_parent != n;
348}
349
350/*
351 * Remove the item from the list and perform its initialization.
352 * This is useful for us because we can test if the item is linked
353 * using "ep_is_linked(p)".
354 */
355static inline void ep_list_del(struct list_head *p)
356{
357 list_del(p);
358 INIT_LIST_HEAD(p);
359}
360
361/* Tells us if the item is currently linked */
362static inline int ep_is_linked(struct list_head *p)
363{
364 return !list_empty(p);
365}
366
367/* Get the "struct epitem" from a wait queue pointer */
368static inline struct epitem * ep_item_from_wait(wait_queue_t *p)
369{
370 return container_of(p, struct eppoll_entry, wait)->base;
371}
372
373/* Get the "struct epitem" from an epoll queue wrapper */
374static inline struct epitem * ep_item_from_epqueue(poll_table *p)
375{
376 return container_of(p, struct ep_pqueue, pt)->epi;
377}
378
379/* Tells if the epoll_ctl(2) operation needs an event copy from userspace */
380static inline int ep_op_hash_event(int op)
381{
382 return op != EPOLL_CTL_DEL;
383}
384
360/* Initialize the poll safe wake up structure */ 385/* Initialize the poll safe wake up structure */
361static void ep_poll_safewake_init(struct poll_safewake *psw) 386static void ep_poll_safewake_init(struct poll_safewake *psw)
362{ 387{
@@ -456,7 +481,7 @@ void eventpoll_release_file(struct file *file)
456 epi = list_entry(lsthead->next, struct epitem, fllink); 481 epi = list_entry(lsthead->next, struct epitem, fllink);
457 482
458 ep = epi->ep; 483 ep = epi->ep;
459 EP_LIST_DEL(&epi->fllink); 484 ep_list_del(&epi->fllink);
460 down_write(&ep->sem); 485 down_write(&ep->sem);
461 ep_remove(ep, epi); 486 ep_remove(ep, epi);
462 up_write(&ep->sem); 487 up_write(&ep->sem);
@@ -534,7 +559,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
534 current, epfd, op, fd, event)); 559 current, epfd, op, fd, event));
535 560
536 error = -EFAULT; 561 error = -EFAULT;
537 if (EP_OP_HASH_EVENT(op) && 562 if (ep_op_hash_event(op) &&
538 copy_from_user(&epds, event, sizeof(struct epoll_event))) 563 copy_from_user(&epds, event, sizeof(struct epoll_event)))
539 goto eexit_1; 564 goto eexit_1;
540 565
@@ -560,7 +585,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
560 * adding an epoll file descriptor inside itself. 585 * adding an epoll file descriptor inside itself.
561 */ 586 */
562 error = -EINVAL; 587 error = -EINVAL;
563 if (file == tfile || !IS_FILE_EPOLL(file)) 588 if (file == tfile || !is_file_epoll(file))
564 goto eexit_3; 589 goto eexit_3;
565 590
566 /* 591 /*
@@ -656,7 +681,7 @@ asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
656 * the user passed to us _is_ an eventpoll file. 681 * the user passed to us _is_ an eventpoll file.
657 */ 682 */
658 error = -EINVAL; 683 error = -EINVAL;
659 if (!IS_FILE_EPOLL(file)) 684 if (!is_file_epoll(file))
660 goto eexit_2; 685 goto eexit_2;
661 686
662 /* 687 /*
@@ -831,11 +856,11 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd)
831 struct epitem *epi, *epir = NULL; 856 struct epitem *epi, *epir = NULL;
832 struct epoll_filefd ffd; 857 struct epoll_filefd ffd;
833 858
834 EP_SET_FFD(&ffd, file, fd); 859 ep_set_ffd(&ffd, file, fd);
835 read_lock_irqsave(&ep->lock, flags); 860 read_lock_irqsave(&ep->lock, flags);
836 for (rbp = ep->rbr.rb_node; rbp; ) { 861 for (rbp = ep->rbr.rb_node; rbp; ) {
837 epi = rb_entry(rbp, struct epitem, rbn); 862 epi = rb_entry(rbp, struct epitem, rbn);
838 kcmp = EP_CMP_FFD(&ffd, &epi->ffd); 863 kcmp = ep_cmp_ffd(&ffd, &epi->ffd);
839 if (kcmp > 0) 864 if (kcmp > 0)
840 rbp = rbp->rb_right; 865 rbp = rbp->rb_right;
841 else if (kcmp < 0) 866 else if (kcmp < 0)
@@ -875,7 +900,7 @@ static void ep_release_epitem(struct epitem *epi)
875{ 900{
876 901
877 if (atomic_dec_and_test(&epi->usecnt)) 902 if (atomic_dec_and_test(&epi->usecnt))
878 EPI_MEM_FREE(epi); 903 kmem_cache_free(epi_cache, epi);
879} 904}
880 905
881 906
@@ -886,10 +911,10 @@ static void ep_release_epitem(struct epitem *epi)
886static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, 911static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
887 poll_table *pt) 912 poll_table *pt)
888{ 913{
889 struct epitem *epi = EP_ITEM_FROM_EPQUEUE(pt); 914 struct epitem *epi = ep_item_from_epqueue(pt);
890 struct eppoll_entry *pwq; 915 struct eppoll_entry *pwq;
891 916
892 if (epi->nwait >= 0 && (pwq = PWQ_MEM_ALLOC())) { 917 if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, SLAB_KERNEL))) {
893 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback); 918 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
894 pwq->whead = whead; 919 pwq->whead = whead;
895 pwq->base = epi; 920 pwq->base = epi;
@@ -912,7 +937,7 @@ static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
912 while (*p) { 937 while (*p) {
913 parent = *p; 938 parent = *p;
914 epic = rb_entry(parent, struct epitem, rbn); 939 epic = rb_entry(parent, struct epitem, rbn);
915 kcmp = EP_CMP_FFD(&epi->ffd, &epic->ffd); 940 kcmp = ep_cmp_ffd(&epi->ffd, &epic->ffd);
916 if (kcmp > 0) 941 if (kcmp > 0)
917 p = &parent->rb_right; 942 p = &parent->rb_right;
918 else 943 else
@@ -932,17 +957,17 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
932 struct ep_pqueue epq; 957 struct ep_pqueue epq;
933 958
934 error = -ENOMEM; 959 error = -ENOMEM;
935 if (!(epi = EPI_MEM_ALLOC())) 960 if (!(epi = kmem_cache_alloc(epi_cache, SLAB_KERNEL)))
936 goto eexit_1; 961 goto eexit_1;
937 962
938 /* Item initialization follow here ... */ 963 /* Item initialization follow here ... */
939 EP_RB_INITNODE(&epi->rbn); 964 ep_rb_initnode(&epi->rbn);
940 INIT_LIST_HEAD(&epi->rdllink); 965 INIT_LIST_HEAD(&epi->rdllink);
941 INIT_LIST_HEAD(&epi->fllink); 966 INIT_LIST_HEAD(&epi->fllink);
942 INIT_LIST_HEAD(&epi->txlink); 967 INIT_LIST_HEAD(&epi->txlink);
943 INIT_LIST_HEAD(&epi->pwqlist); 968 INIT_LIST_HEAD(&epi->pwqlist);
944 epi->ep = ep; 969 epi->ep = ep;
945 EP_SET_FFD(&epi->ffd, tfile, fd); 970 ep_set_ffd(&epi->ffd, tfile, fd);
946 epi->event = *event; 971 epi->event = *event;
947 atomic_set(&epi->usecnt, 1); 972 atomic_set(&epi->usecnt, 1);
948 epi->nwait = 0; 973 epi->nwait = 0;
@@ -978,7 +1003,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
978 ep_rbtree_insert(ep, epi); 1003 ep_rbtree_insert(ep, epi);
979 1004
980 /* If the file is already "ready" we drop it inside the ready list */ 1005 /* If the file is already "ready" we drop it inside the ready list */
981 if ((revents & event->events) && !EP_IS_LINKED(&epi->rdllink)) { 1006 if ((revents & event->events) && !ep_is_linked(&epi->rdllink)) {
982 list_add_tail(&epi->rdllink, &ep->rdllist); 1007 list_add_tail(&epi->rdllink, &ep->rdllist);
983 1008
984 /* Notify waiting tasks that events are available */ 1009 /* Notify waiting tasks that events are available */
@@ -1007,11 +1032,11 @@ eexit_2:
1007 * allocated wait queue. 1032 * allocated wait queue.
1008 */ 1033 */
1009 write_lock_irqsave(&ep->lock, flags); 1034 write_lock_irqsave(&ep->lock, flags);
1010 if (EP_IS_LINKED(&epi->rdllink)) 1035 if (ep_is_linked(&epi->rdllink))
1011 EP_LIST_DEL(&epi->rdllink); 1036 ep_list_del(&epi->rdllink);
1012 write_unlock_irqrestore(&ep->lock, flags); 1037 write_unlock_irqrestore(&ep->lock, flags);
1013 1038
1014 EPI_MEM_FREE(epi); 1039 kmem_cache_free(epi_cache, epi);
1015eexit_1: 1040eexit_1:
1016 return error; 1041 return error;
1017} 1042}
@@ -1050,14 +1075,14 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
1050 * If the item is not linked to the hash it means that it's on its 1075 * If the item is not linked to the hash it means that it's on its
1051 * way toward the removal. Do nothing in this case. 1076 * way toward the removal. Do nothing in this case.
1052 */ 1077 */
1053 if (EP_RB_LINKED(&epi->rbn)) { 1078 if (ep_rb_linked(&epi->rbn)) {
1054 /* 1079 /*
1055 * If the item is "hot" and it is not registered inside the ready 1080 * If the item is "hot" and it is not registered inside the ready
1056 * list, push it inside. If the item is not "hot" and it is currently 1081 * list, push it inside. If the item is not "hot" and it is currently
1057 * registered inside the ready list, unlink it. 1082 * registered inside the ready list, unlink it.
1058 */ 1083 */
1059 if (revents & event->events) { 1084 if (revents & event->events) {
1060 if (!EP_IS_LINKED(&epi->rdllink)) { 1085 if (!ep_is_linked(&epi->rdllink)) {
1061 list_add_tail(&epi->rdllink, &ep->rdllist); 1086 list_add_tail(&epi->rdllink, &ep->rdllist);
1062 1087
1063 /* Notify waiting tasks that events are available */ 1088 /* Notify waiting tasks that events are available */
@@ -1097,9 +1122,9 @@ static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
1097 while (!list_empty(lsthead)) { 1122 while (!list_empty(lsthead)) {
1098 pwq = list_entry(lsthead->next, struct eppoll_entry, llink); 1123 pwq = list_entry(lsthead->next, struct eppoll_entry, llink);
1099 1124
1100 EP_LIST_DEL(&pwq->llink); 1125 ep_list_del(&pwq->llink);
1101 remove_wait_queue(pwq->whead, &pwq->wait); 1126 remove_wait_queue(pwq->whead, &pwq->wait);
1102 PWQ_MEM_FREE(pwq); 1127 kmem_cache_free(pwq_cache, pwq);
1103 } 1128 }
1104 } 1129 }
1105} 1130}
@@ -1118,7 +1143,7 @@ static int ep_unlink(struct eventpoll *ep, struct epitem *epi)
1118 * The check protect us from doing a double unlink ( crash ). 1143 * The check protect us from doing a double unlink ( crash ).
1119 */ 1144 */
1120 error = -ENOENT; 1145 error = -ENOENT;
1121 if (!EP_RB_LINKED(&epi->rbn)) 1146 if (!ep_rb_linked(&epi->rbn))
1122 goto eexit_1; 1147 goto eexit_1;
1123 1148
1124 /* 1149 /*
@@ -1133,14 +1158,14 @@ static int ep_unlink(struct eventpoll *ep, struct epitem *epi)
1133 * This operation togheter with the above check closes the door to 1158 * This operation togheter with the above check closes the door to
1134 * double unlinks. 1159 * double unlinks.
1135 */ 1160 */
1136 EP_RB_ERASE(&epi->rbn, &ep->rbr); 1161 ep_rb_erase(&epi->rbn, &ep->rbr);
1137 1162
1138 /* 1163 /*
1139 * If the item we are going to remove is inside the ready file descriptors 1164 * If the item we are going to remove is inside the ready file descriptors
1140 * we want to remove it from this list to avoid stale events. 1165 * we want to remove it from this list to avoid stale events.
1141 */ 1166 */
1142 if (EP_IS_LINKED(&epi->rdllink)) 1167 if (ep_is_linked(&epi->rdllink))
1143 EP_LIST_DEL(&epi->rdllink); 1168 ep_list_del(&epi->rdllink);
1144 1169
1145 error = 0; 1170 error = 0;
1146eexit_1: 1171eexit_1:
@@ -1174,8 +1199,8 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
1174 1199
1175 /* Remove the current item from the list of epoll hooks */ 1200 /* Remove the current item from the list of epoll hooks */
1176 spin_lock(&file->f_ep_lock); 1201 spin_lock(&file->f_ep_lock);
1177 if (EP_IS_LINKED(&epi->fllink)) 1202 if (ep_is_linked(&epi->fllink))
1178 EP_LIST_DEL(&epi->fllink); 1203 ep_list_del(&epi->fllink);
1179 spin_unlock(&file->f_ep_lock); 1204 spin_unlock(&file->f_ep_lock);
1180 1205
1181 /* We need to acquire the write IRQ lock before calling ep_unlink() */ 1206 /* We need to acquire the write IRQ lock before calling ep_unlink() */
@@ -1210,7 +1235,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
1210{ 1235{
1211 int pwake = 0; 1236 int pwake = 0;
1212 unsigned long flags; 1237 unsigned long flags;
1213 struct epitem *epi = EP_ITEM_FROM_WAIT(wait); 1238 struct epitem *epi = ep_item_from_wait(wait);
1214 struct eventpoll *ep = epi->ep; 1239 struct eventpoll *ep = epi->ep;
1215 1240
1216 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: poll_callback(%p) epi=%p ep=%p\n", 1241 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: poll_callback(%p) epi=%p ep=%p\n",
@@ -1228,7 +1253,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
1228 goto is_disabled; 1253 goto is_disabled;
1229 1254
1230 /* If this file is already in the ready list we exit soon */ 1255 /* If this file is already in the ready list we exit soon */
1231 if (EP_IS_LINKED(&epi->rdllink)) 1256 if (ep_is_linked(&epi->rdllink))
1232 goto is_linked; 1257 goto is_linked;
1233 1258
1234 list_add_tail(&epi->rdllink, &ep->rdllist); 1259 list_add_tail(&epi->rdllink, &ep->rdllist);
@@ -1307,7 +1332,7 @@ static int ep_collect_ready_items(struct eventpoll *ep, struct list_head *txlist
1307 lnk = lnk->next; 1332 lnk = lnk->next;
1308 1333
1309 /* If this file is already in the ready list we exit soon */ 1334 /* If this file is already in the ready list we exit soon */
1310 if (!EP_IS_LINKED(&epi->txlink)) { 1335 if (!ep_is_linked(&epi->txlink)) {
1311 /* 1336 /*
1312 * This is initialized in this way so that the default 1337 * This is initialized in this way so that the default
1313 * behaviour of the reinjecting code will be to push back 1338 * behaviour of the reinjecting code will be to push back
@@ -1322,7 +1347,7 @@ static int ep_collect_ready_items(struct eventpoll *ep, struct list_head *txlist
1322 /* 1347 /*
1323 * Unlink the item from the ready list. 1348 * Unlink the item from the ready list.
1324 */ 1349 */
1325 EP_LIST_DEL(&epi->rdllink); 1350 ep_list_del(&epi->rdllink);
1326 } 1351 }
1327 } 1352 }
1328 1353
@@ -1401,7 +1426,7 @@ static void ep_reinject_items(struct eventpoll *ep, struct list_head *txlist)
1401 epi = list_entry(txlist->next, struct epitem, txlink); 1426 epi = list_entry(txlist->next, struct epitem, txlink);
1402 1427
1403 /* Unlink the current item from the transfer list */ 1428 /* Unlink the current item from the transfer list */
1404 EP_LIST_DEL(&epi->txlink); 1429 ep_list_del(&epi->txlink);
1405 1430
1406 /* 1431 /*
1407 * If the item is no more linked to the interest set, we don't 1432 * If the item is no more linked to the interest set, we don't
@@ -1410,8 +1435,8 @@ static void ep_reinject_items(struct eventpoll *ep, struct list_head *txlist)
1410 * item is set to have an Edge Triggered behaviour, we don't have 1435 * item is set to have an Edge Triggered behaviour, we don't have
1411 * to push it back either. 1436 * to push it back either.
1412 */ 1437 */
1413 if (EP_RB_LINKED(&epi->rbn) && !(epi->event.events & EPOLLET) && 1438 if (ep_rb_linked(&epi->rbn) && !(epi->event.events & EPOLLET) &&
1414 (epi->revents & epi->event.events) && !EP_IS_LINKED(&epi->rdllink)) { 1439 (epi->revents & epi->event.events) && !ep_is_linked(&epi->rdllink)) {
1415 list_add_tail(&epi->rdllink, &ep->rdllist); 1440 list_add_tail(&epi->rdllink, &ep->rdllist);
1416 ricnt++; 1441 ricnt++;
1417 } 1442 }
diff --git a/fs/exec.c b/fs/exec.c
index 3a4b35a14c0d..48871917d363 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -58,6 +58,9 @@
58 58
59int core_uses_pid; 59int core_uses_pid;
60char core_pattern[65] = "core"; 60char core_pattern[65] = "core";
61int suid_dumpable = 0;
62
63EXPORT_SYMBOL(suid_dumpable);
61/* The maximal length of core_pattern is also specified in sysctl.c */ 64/* The maximal length of core_pattern is also specified in sysctl.c */
62 65
63static struct linux_binfmt *formats; 66static struct linux_binfmt *formats;
@@ -864,6 +867,9 @@ int flush_old_exec(struct linux_binprm * bprm)
864 867
865 if (current->euid == current->uid && current->egid == current->gid) 868 if (current->euid == current->uid && current->egid == current->gid)
866 current->mm->dumpable = 1; 869 current->mm->dumpable = 1;
870 else
871 current->mm->dumpable = suid_dumpable;
872
867 name = bprm->filename; 873 name = bprm->filename;
868 874
869 /* Copies the binary name from after last slash */ 875 /* Copies the binary name from after last slash */
@@ -884,7 +890,7 @@ int flush_old_exec(struct linux_binprm * bprm)
884 permission(bprm->file->f_dentry->d_inode,MAY_READ, NULL) || 890 permission(bprm->file->f_dentry->d_inode,MAY_READ, NULL) ||
885 (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) { 891 (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) {
886 suid_keys(current); 892 suid_keys(current);
887 current->mm->dumpable = 0; 893 current->mm->dumpable = suid_dumpable;
888 } 894 }
889 895
890 /* An exec changes our domain. We are no longer part of the thread 896 /* An exec changes our domain. We are no longer part of the thread
@@ -1432,6 +1438,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1432 struct inode * inode; 1438 struct inode * inode;
1433 struct file * file; 1439 struct file * file;
1434 int retval = 0; 1440 int retval = 0;
1441 int fsuid = current->fsuid;
1442 int flag = 0;
1435 1443
1436 binfmt = current->binfmt; 1444 binfmt = current->binfmt;
1437 if (!binfmt || !binfmt->core_dump) 1445 if (!binfmt || !binfmt->core_dump)
@@ -1441,6 +1449,16 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1441 up_write(&mm->mmap_sem); 1449 up_write(&mm->mmap_sem);
1442 goto fail; 1450 goto fail;
1443 } 1451 }
1452
1453 /*
1454 * We cannot trust fsuid as being the "true" uid of the
1455 * process nor do we know its entire history. We only know it
1456 * was tainted so we dump it as root in mode 2.
1457 */
1458 if (mm->dumpable == 2) { /* Setuid core dump mode */
1459 flag = O_EXCL; /* Stop rewrite attacks */
1460 current->fsuid = 0; /* Dump root private */
1461 }
1444 mm->dumpable = 0; 1462 mm->dumpable = 0;
1445 init_completion(&mm->core_done); 1463 init_completion(&mm->core_done);
1446 spin_lock_irq(&current->sighand->siglock); 1464 spin_lock_irq(&current->sighand->siglock);
@@ -1466,7 +1484,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1466 lock_kernel(); 1484 lock_kernel();
1467 format_corename(corename, core_pattern, signr); 1485 format_corename(corename, core_pattern, signr);
1468 unlock_kernel(); 1486 unlock_kernel();
1469 file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600); 1487 file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, 0600);
1470 if (IS_ERR(file)) 1488 if (IS_ERR(file))
1471 goto fail_unlock; 1489 goto fail_unlock;
1472 inode = file->f_dentry->d_inode; 1490 inode = file->f_dentry->d_inode;
@@ -1491,6 +1509,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1491close_fail: 1509close_fail:
1492 filp_close(file, NULL); 1510 filp_close(file, NULL);
1493fail_unlock: 1511fail_unlock:
1512 current->fsuid = fsuid;
1494 complete_all(&mm->core_done); 1513 complete_all(&mm->core_done);
1495fail: 1514fail:
1496 return retval; 1515 return retval;
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 25f4a64fd6bc..213148c36ebe 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -396,12 +396,12 @@ static size_t
396ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, 396ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
397 const char *name, size_t name_len) 397 const char *name, size_t name_len)
398{ 398{
399 const size_t size = sizeof(XATTR_NAME_ACL_ACCESS); 399 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
400 400
401 if (!test_opt(inode->i_sb, POSIX_ACL)) 401 if (!test_opt(inode->i_sb, POSIX_ACL))
402 return 0; 402 return 0;
403 if (list && size <= list_size) 403 if (list && size <= list_size)
404 memcpy(list, XATTR_NAME_ACL_ACCESS, size); 404 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
405 return size; 405 return size;
406} 406}
407 407
@@ -409,12 +409,12 @@ static size_t
409ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, 409ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
410 const char *name, size_t name_len) 410 const char *name, size_t name_len)
411{ 411{
412 const size_t size = sizeof(XATTR_NAME_ACL_DEFAULT); 412 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
413 413
414 if (!test_opt(inode->i_sb, POSIX_ACL)) 414 if (!test_opt(inode->i_sb, POSIX_ACL))
415 return 0; 415 return 0;
416 if (list && size <= list_size) 416 if (list && size <= list_size)
417 memcpy(list, XATTR_NAME_ACL_DEFAULT, size); 417 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
418 return size; 418 return size;
419} 419}
420 420
@@ -506,14 +506,14 @@ ext2_xattr_set_acl_default(struct inode *inode, const char *name,
506} 506}
507 507
508struct xattr_handler ext2_xattr_acl_access_handler = { 508struct xattr_handler ext2_xattr_acl_access_handler = {
509 .prefix = XATTR_NAME_ACL_ACCESS, 509 .prefix = POSIX_ACL_XATTR_ACCESS,
510 .list = ext2_xattr_list_acl_access, 510 .list = ext2_xattr_list_acl_access,
511 .get = ext2_xattr_get_acl_access, 511 .get = ext2_xattr_get_acl_access,
512 .set = ext2_xattr_set_acl_access, 512 .set = ext2_xattr_set_acl_access,
513}; 513};
514 514
515struct xattr_handler ext2_xattr_acl_default_handler = { 515struct xattr_handler ext2_xattr_acl_default_handler = {
516 .prefix = XATTR_NAME_ACL_DEFAULT, 516 .prefix = POSIX_ACL_XATTR_DEFAULT,
517 .list = ext2_xattr_list_acl_default, 517 .list = ext2_xattr_list_acl_default,
518 .get = ext2_xattr_get_acl_default, 518 .get = ext2_xattr_get_acl_default,
519 .set = ext2_xattr_set_acl_default, 519 .set = ext2_xattr_set_acl_default,
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index fed96ae81a7d..0bde85bafe38 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -4,7 +4,7 @@
4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> 4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/ 5*/
6 6
7#include <linux/xattr_acl.h> 7#include <linux/posix_acl_xattr.h>
8 8
9#define EXT2_ACL_VERSION 0x0001 9#define EXT2_ACL_VERSION 0x0001
10 10
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 638c13a26c03..133f5aa581bb 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -417,12 +417,12 @@ static size_t
417ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, 417ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
418 const char *name, size_t name_len) 418 const char *name, size_t name_len)
419{ 419{
420 const size_t size = sizeof(XATTR_NAME_ACL_ACCESS); 420 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
421 421
422 if (!test_opt(inode->i_sb, POSIX_ACL)) 422 if (!test_opt(inode->i_sb, POSIX_ACL))
423 return 0; 423 return 0;
424 if (list && size <= list_len) 424 if (list && size <= list_len)
425 memcpy(list, XATTR_NAME_ACL_ACCESS, size); 425 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
426 return size; 426 return size;
427} 427}
428 428
@@ -430,12 +430,12 @@ static size_t
430ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, 430ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
431 const char *name, size_t name_len) 431 const char *name, size_t name_len)
432{ 432{
433 const size_t size = sizeof(XATTR_NAME_ACL_DEFAULT); 433 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
434 434
435 if (!test_opt(inode->i_sb, POSIX_ACL)) 435 if (!test_opt(inode->i_sb, POSIX_ACL))
436 return 0; 436 return 0;
437 if (list && size <= list_len) 437 if (list && size <= list_len)
438 memcpy(list, XATTR_NAME_ACL_DEFAULT, size); 438 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
439 return size; 439 return size;
440} 440}
441 441
@@ -535,14 +535,14 @@ ext3_xattr_set_acl_default(struct inode *inode, const char *name,
535} 535}
536 536
537struct xattr_handler ext3_xattr_acl_access_handler = { 537struct xattr_handler ext3_xattr_acl_access_handler = {
538 .prefix = XATTR_NAME_ACL_ACCESS, 538 .prefix = POSIX_ACL_XATTR_ACCESS,
539 .list = ext3_xattr_list_acl_access, 539 .list = ext3_xattr_list_acl_access,
540 .get = ext3_xattr_get_acl_access, 540 .get = ext3_xattr_get_acl_access,
541 .set = ext3_xattr_set_acl_access, 541 .set = ext3_xattr_set_acl_access,
542}; 542};
543 543
544struct xattr_handler ext3_xattr_acl_default_handler = { 544struct xattr_handler ext3_xattr_acl_default_handler = {
545 .prefix = XATTR_NAME_ACL_DEFAULT, 545 .prefix = POSIX_ACL_XATTR_DEFAULT,
546 .list = ext3_xattr_list_acl_default, 546 .list = ext3_xattr_list_acl_default,
547 .get = ext3_xattr_get_acl_default, 547 .get = ext3_xattr_get_acl_default,
548 .set = ext3_xattr_set_acl_default, 548 .set = ext3_xattr_set_acl_default,
diff --git a/fs/ext3/acl.h b/fs/ext3/acl.h
index 98af0c0d0ba9..92d50b53a933 100644
--- a/fs/ext3/acl.h
+++ b/fs/ext3/acl.h
@@ -4,7 +4,7 @@
4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> 4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/ 5*/
6 6
7#include <linux/xattr_acl.h> 7#include <linux/posix_acl_xattr.h>
8 8
9#define EXT3_ACL_VERSION 0x0001 9#define EXT3_ACL_VERSION 0x0001
10 10
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 79742d824a0a..60e44e6dd7a6 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -932,8 +932,16 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
932 struct inode *dir = dentry->d_parent->d_inode; 932 struct inode *dir = dentry->d_parent->d_inode;
933 933
934 sb = dir->i_sb; 934 sb = dir->i_sb;
935 if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err))) 935 /* NFS may look up ".." - look at dx_root directory block */
936 return NULL; 936 if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){
937 if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err)))
938 return NULL;
939 } else {
940 frame = frames;
941 frame->bh = NULL; /* for dx_release() */
942 frame->at = (struct dx_entry *)frames; /* hack for zero entry*/
943 dx_set_block(frame->at, 0); /* dx_root block is 0 */
944 }
937 hash = hinfo.hash; 945 hash = hinfo.hash;
938 do { 946 do {
939 block = dx_get_block(frame->at); 947 block = dx_get_block(frame->at);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 981ccb233ef5..9630fbfdc24a 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2348,22 +2348,8 @@ static int ext3_write_info(struct super_block *sb, int type)
2348 */ 2348 */
2349static int ext3_quota_on_mount(struct super_block *sb, int type) 2349static int ext3_quota_on_mount(struct super_block *sb, int type)
2350{ 2350{
2351 int err; 2351 return vfs_quota_on_mount(sb, EXT3_SB(sb)->s_qf_names[type],
2352 struct dentry *dentry; 2352 EXT3_SB(sb)->s_jquota_fmt, type);
2353 struct qstr name = { .name = EXT3_SB(sb)->s_qf_names[type],
2354 .hash = 0,
2355 .len = strlen(EXT3_SB(sb)->s_qf_names[type])};
2356
2357 dentry = lookup_hash(&name, sb->s_root);
2358 if (IS_ERR(dentry))
2359 return PTR_ERR(dentry);
2360 err = vfs_quota_on_mount(type, EXT3_SB(sb)->s_jquota_fmt, dentry);
2361 /* Now invalidate and put the dentry - quota got its own reference
2362 * to inode and dentry has at least wrong hash so we had better
2363 * throw it away */
2364 d_invalidate(dentry);
2365 dput(dentry);
2366 return err;
2367} 2353}
2368 2354
2369/* 2355/*
diff --git a/fs/file_table.c b/fs/file_table.c
index 03d83cb686b1..fa7849fae134 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -63,42 +63,45 @@ static inline void file_free(struct file *f)
63 */ 63 */
64struct file *get_empty_filp(void) 64struct file *get_empty_filp(void)
65{ 65{
66static int old_max; 66 static int old_max;
67 struct file * f; 67 struct file * f;
68 68
69 /* 69 /*
70 * Privileged users can go above max_files 70 * Privileged users can go above max_files
71 */ 71 */
72 if (files_stat.nr_files < files_stat.max_files || 72 if (files_stat.nr_files >= files_stat.max_files &&
73 capable(CAP_SYS_ADMIN)) { 73 !capable(CAP_SYS_ADMIN))
74 f = kmem_cache_alloc(filp_cachep, GFP_KERNEL); 74 goto over;
75 if (f) { 75
76 memset(f, 0, sizeof(*f)); 76 f = kmem_cache_alloc(filp_cachep, GFP_KERNEL);
77 if (security_file_alloc(f)) { 77 if (f == NULL)
78 file_free(f); 78 goto fail;
79 goto fail; 79
80 } 80 memset(f, 0, sizeof(*f));
81 eventpoll_init_file(f); 81 if (security_file_alloc(f))
82 atomic_set(&f->f_count, 1); 82 goto fail_sec;
83 f->f_uid = current->fsuid; 83
84 f->f_gid = current->fsgid; 84 eventpoll_init_file(f);
85 rwlock_init(&f->f_owner.lock); 85 atomic_set(&f->f_count, 1);
86 /* f->f_version: 0 */ 86 f->f_uid = current->fsuid;
87 INIT_LIST_HEAD(&f->f_list); 87 f->f_gid = current->fsgid;
88 f->f_maxcount = INT_MAX; 88 rwlock_init(&f->f_owner.lock);
89 return f; 89 /* f->f_version: 0 */
90 } 90 INIT_LIST_HEAD(&f->f_list);
91 } 91 f->f_maxcount = INT_MAX;
92 92 return f;
93
94over:
93 /* Ran out of filps - report that */ 95 /* Ran out of filps - report that */
94 if (files_stat.max_files >= old_max) { 96 if (files_stat.nr_files > old_max) {
95 printk(KERN_INFO "VFS: file-max limit %d reached\n", 97 printk(KERN_INFO "VFS: file-max limit %d reached\n",
96 files_stat.max_files); 98 files_stat.max_files);
97 old_max = files_stat.max_files; 99 old_max = files_stat.nr_files;
98 } else {
99 /* Big problems... */
100 printk(KERN_WARNING "VFS: filp allocation failed\n");
101 } 100 }
101 goto fail;
102
103fail_sec:
104 file_free(f);
102fail: 105fail:
103 return NULL; 106 return NULL;
104} 107}
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 8e050fa58218..e94ab398b717 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -485,32 +485,6 @@ static void set_sb_syncing(int val)
485 spin_unlock(&sb_lock); 485 spin_unlock(&sb_lock);
486} 486}
487 487
488/*
489 * Find a superblock with inodes that need to be synced
490 */
491static struct super_block *get_super_to_sync(void)
492{
493 struct super_block *sb;
494restart:
495 spin_lock(&sb_lock);
496 sb = sb_entry(super_blocks.prev);
497 for (; sb != sb_entry(&super_blocks); sb = sb_entry(sb->s_list.prev)) {
498 if (sb->s_syncing)
499 continue;
500 sb->s_syncing = 1;
501 sb->s_count++;
502 spin_unlock(&sb_lock);
503 down_read(&sb->s_umount);
504 if (!sb->s_root) {
505 drop_super(sb);
506 goto restart;
507 }
508 return sb;
509 }
510 spin_unlock(&sb_lock);
511 return NULL;
512}
513
514/** 488/**
515 * sync_inodes - writes all inodes to disk 489 * sync_inodes - writes all inodes to disk
516 * @wait: wait for completion 490 * @wait: wait for completion
@@ -530,23 +504,39 @@ restart:
530 * outstanding dirty inodes, the writeback goes block-at-a-time within the 504 * outstanding dirty inodes, the writeback goes block-at-a-time within the
531 * filesystem's write_inode(). This is extremely slow. 505 * filesystem's write_inode(). This is extremely slow.
532 */ 506 */
533void sync_inodes(int wait) 507static void __sync_inodes(int wait)
534{ 508{
535 struct super_block *sb; 509 struct super_block *sb;
536 510
537 set_sb_syncing(0); 511 spin_lock(&sb_lock);
538 while ((sb = get_super_to_sync()) != NULL) { 512restart:
539 sync_inodes_sb(sb, 0); 513 list_for_each_entry(sb, &super_blocks, s_list) {
540 sync_blockdev(sb->s_bdev); 514 if (sb->s_syncing)
541 drop_super(sb); 515 continue;
516 sb->s_syncing = 1;
517 sb->s_count++;
518 spin_unlock(&sb_lock);
519 down_read(&sb->s_umount);
520 if (sb->s_root) {
521 sync_inodes_sb(sb, wait);
522 sync_blockdev(sb->s_bdev);
523 }
524 up_read(&sb->s_umount);
525 spin_lock(&sb_lock);
526 if (__put_super_and_need_restart(sb))
527 goto restart;
542 } 528 }
529 spin_unlock(&sb_lock);
530}
531
532void sync_inodes(int wait)
533{
534 set_sb_syncing(0);
535 __sync_inodes(0);
536
543 if (wait) { 537 if (wait) {
544 set_sb_syncing(0); 538 set_sb_syncing(0);
545 while ((sb = get_super_to_sync()) != NULL) { 539 __sync_inodes(1);
546 sync_inodes_sb(sb, 1);
547 sync_blockdev(sb->s_bdev);
548 drop_super(sb);
549 }
550 } 540 }
551} 541}
552 542
diff --git a/fs/inode.c b/fs/inode.c
index 801fe7f36280..1f9a3a2b89bc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -500,7 +500,7 @@ repeat:
500 continue; 500 continue;
501 if (!test(inode, data)) 501 if (!test(inode, data))
502 continue; 502 continue;
503 if (inode->i_state & (I_FREEING|I_CLEAR)) { 503 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) {
504 __wait_on_freeing_inode(inode); 504 __wait_on_freeing_inode(inode);
505 goto repeat; 505 goto repeat;
506 } 506 }
@@ -525,7 +525,7 @@ repeat:
525 continue; 525 continue;
526 if (inode->i_sb != sb) 526 if (inode->i_sb != sb)
527 continue; 527 continue;
528 if (inode->i_state & (I_FREEING|I_CLEAR)) { 528 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) {
529 __wait_on_freeing_inode(inode); 529 __wait_on_freeing_inode(inode);
530 goto repeat; 530 goto repeat;
531 } 531 }
@@ -727,7 +727,7 @@ EXPORT_SYMBOL(iunique);
727struct inode *igrab(struct inode *inode) 727struct inode *igrab(struct inode *inode)
728{ 728{
729 spin_lock(&inode_lock); 729 spin_lock(&inode_lock);
730 if (!(inode->i_state & I_FREEING)) 730 if (!(inode->i_state & (I_FREEING|I_WILL_FREE)))
731 __iget(inode); 731 __iget(inode);
732 else 732 else
733 /* 733 /*
@@ -1024,17 +1024,21 @@ static void generic_forget_inode(struct inode *inode)
1024 if (!(inode->i_state & (I_DIRTY|I_LOCK))) 1024 if (!(inode->i_state & (I_DIRTY|I_LOCK)))
1025 list_move(&inode->i_list, &inode_unused); 1025 list_move(&inode->i_list, &inode_unused);
1026 inodes_stat.nr_unused++; 1026 inodes_stat.nr_unused++;
1027 spin_unlock(&inode_lock); 1027 if (!sb || (sb->s_flags & MS_ACTIVE)) {
1028 if (!sb || (sb->s_flags & MS_ACTIVE)) 1028 spin_unlock(&inode_lock);
1029 return; 1029 return;
1030 }
1031 inode->i_state |= I_WILL_FREE;
1032 spin_unlock(&inode_lock);
1030 write_inode_now(inode, 1); 1033 write_inode_now(inode, 1);
1031 spin_lock(&inode_lock); 1034 spin_lock(&inode_lock);
1035 inode->i_state &= ~I_WILL_FREE;
1032 inodes_stat.nr_unused--; 1036 inodes_stat.nr_unused--;
1033 hlist_del_init(&inode->i_hash); 1037 hlist_del_init(&inode->i_hash);
1034 } 1038 }
1035 list_del_init(&inode->i_list); 1039 list_del_init(&inode->i_list);
1036 list_del_init(&inode->i_sb_list); 1040 list_del_init(&inode->i_sb_list);
1037 inode->i_state|=I_FREEING; 1041 inode->i_state |= I_FREEING;
1038 inodes_stat.nr_inodes--; 1042 inodes_stat.nr_inodes--;
1039 spin_unlock(&inode_lock); 1043 spin_unlock(&inode_lock);
1040 if (inode->i_data.nrpages) 1044 if (inode->i_data.nrpages)
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 30a2bf9eeda5..e892dab40c26 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -21,6 +21,7 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/quotaops.h> 23#include <linux/quotaops.h>
24#include <linux/posix_acl_xattr.h>
24#include "jfs_incore.h" 25#include "jfs_incore.h"
25#include "jfs_xattr.h" 26#include "jfs_xattr.h"
26#include "jfs_acl.h" 27#include "jfs_acl.h"
@@ -36,11 +37,11 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type)
36 37
37 switch(type) { 38 switch(type) {
38 case ACL_TYPE_ACCESS: 39 case ACL_TYPE_ACCESS:
39 ea_name = XATTR_NAME_ACL_ACCESS; 40 ea_name = POSIX_ACL_XATTR_ACCESS;
40 p_acl = &ji->i_acl; 41 p_acl = &ji->i_acl;
41 break; 42 break;
42 case ACL_TYPE_DEFAULT: 43 case ACL_TYPE_DEFAULT:
43 ea_name = XATTR_NAME_ACL_DEFAULT; 44 ea_name = POSIX_ACL_XATTR_DEFAULT;
44 p_acl = &ji->i_default_acl; 45 p_acl = &ji->i_default_acl;
45 break; 46 break;
46 default: 47 default:
@@ -88,11 +89,11 @@ static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
88 89
89 switch(type) { 90 switch(type) {
90 case ACL_TYPE_ACCESS: 91 case ACL_TYPE_ACCESS:
91 ea_name = XATTR_NAME_ACL_ACCESS; 92 ea_name = POSIX_ACL_XATTR_ACCESS;
92 p_acl = &ji->i_acl; 93 p_acl = &ji->i_acl;
93 break; 94 break;
94 case ACL_TYPE_DEFAULT: 95 case ACL_TYPE_DEFAULT:
95 ea_name = XATTR_NAME_ACL_DEFAULT; 96 ea_name = POSIX_ACL_XATTR_DEFAULT;
96 p_acl = &ji->i_default_acl; 97 p_acl = &ji->i_default_acl;
97 if (!S_ISDIR(inode->i_mode)) 98 if (!S_ISDIR(inode->i_mode))
98 return acl ? -EACCES : 0; 99 return acl ? -EACCES : 0;
@@ -101,7 +102,7 @@ static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
101 return -EINVAL; 102 return -EINVAL;
102 } 103 }
103 if (acl) { 104 if (acl) {
104 size = xattr_acl_size(acl->a_count); 105 size = posix_acl_xattr_size(acl->a_count);
105 value = kmalloc(size, GFP_KERNEL); 106 value = kmalloc(size, GFP_KERNEL);
106 if (!value) 107 if (!value)
107 return -ENOMEM; 108 return -ENOMEM;
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
index d2ae430adecf..a3acd3eec059 100644
--- a/fs/jfs/jfs_acl.h
+++ b/fs/jfs/jfs_acl.h
@@ -20,8 +20,6 @@
20 20
21#ifdef CONFIG_JFS_POSIX_ACL 21#ifdef CONFIG_JFS_POSIX_ACL
22 22
23#include <linux/xattr_acl.h>
24
25int jfs_permission(struct inode *, int, struct nameidata *); 23int jfs_permission(struct inode *, int, struct nameidata *);
26int jfs_init_acl(struct inode *, struct inode *); 24int jfs_init_acl(struct inode *, struct inode *);
27int jfs_setattr(struct dentry *, struct iattr *); 25int jfs_setattr(struct dentry *, struct iattr *);
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 810a3653d8b3..ee32211288ce 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -24,6 +24,7 @@
24#include <linux/completion.h> 24#include <linux/completion.h>
25#include <linux/vfs.h> 25#include <linux/vfs.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/posix_acl.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28 29
29#include "jfs_incore.h" 30#include "jfs_incore.h"
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 6016373701a3..ee438d429d45 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/xattr.h> 21#include <linux/xattr.h>
22#include <linux/posix_acl_xattr.h>
22#include <linux/quotaops.h> 23#include <linux/quotaops.h>
23#include "jfs_incore.h" 24#include "jfs_incore.h"
24#include "jfs_superblock.h" 25#include "jfs_superblock.h"
@@ -718,9 +719,9 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
718 return -EPERM; 719 return -EPERM;
719 720
720 /* 721 /*
721 * XATTR_NAME_ACL_ACCESS is tied to i_mode 722 * POSIX_ACL_XATTR_ACCESS is tied to i_mode
722 */ 723 */
723 if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0) { 724 if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) {
724 acl = posix_acl_from_xattr(value, value_len); 725 acl = posix_acl_from_xattr(value, value_len);
725 if (IS_ERR(acl)) { 726 if (IS_ERR(acl)) {
726 rc = PTR_ERR(acl); 727 rc = PTR_ERR(acl);
@@ -750,7 +751,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
750 JFS_IP(inode)->i_acl = JFS_ACL_NOT_CACHED; 751 JFS_IP(inode)->i_acl = JFS_ACL_NOT_CACHED;
751 752
752 return 0; 753 return 0;
753 } else if (strcmp(name, XATTR_NAME_ACL_DEFAULT) == 0) { 754 } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
754 acl = posix_acl_from_xattr(value, value_len); 755 acl = posix_acl_from_xattr(value, value_len);
755 if (IS_ERR(acl)) { 756 if (IS_ERR(acl)) {
756 rc = PTR_ERR(acl); 757 rc = PTR_ERR(acl);
diff --git a/fs/namei.c b/fs/namei.c
index a7f7f44119b3..fa8df81ce8ca 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1577,19 +1577,35 @@ do_link:
1577 * 1577 *
1578 * Simple function to lookup and return a dentry and create it 1578 * Simple function to lookup and return a dentry and create it
1579 * if it doesn't exist. Is SMP-safe. 1579 * if it doesn't exist. Is SMP-safe.
1580 *
1581 * Returns with nd->dentry->d_inode->i_sem locked.
1580 */ 1582 */
1581struct dentry *lookup_create(struct nameidata *nd, int is_dir) 1583struct dentry *lookup_create(struct nameidata *nd, int is_dir)
1582{ 1584{
1583 struct dentry *dentry; 1585 struct dentry *dentry = ERR_PTR(-EEXIST);
1584 1586
1585 down(&nd->dentry->d_inode->i_sem); 1587 down(&nd->dentry->d_inode->i_sem);
1586 dentry = ERR_PTR(-EEXIST); 1588 /*
1589 * Yucky last component or no last component at all?
1590 * (foo/., foo/.., /////)
1591 */
1587 if (nd->last_type != LAST_NORM) 1592 if (nd->last_type != LAST_NORM)
1588 goto fail; 1593 goto fail;
1589 nd->flags &= ~LOOKUP_PARENT; 1594 nd->flags &= ~LOOKUP_PARENT;
1595
1596 /*
1597 * Do the final lookup.
1598 */
1590 dentry = lookup_hash(&nd->last, nd->dentry); 1599 dentry = lookup_hash(&nd->last, nd->dentry);
1591 if (IS_ERR(dentry)) 1600 if (IS_ERR(dentry))
1592 goto fail; 1601 goto fail;
1602
1603 /*
1604 * Special case - lookup gave negative, but... we had foo/bar/
1605 * From the vfs_mknod() POV we just have a negative dentry -
1606 * all is fine. Let's be bastards - you had / on the end, you've
1607 * been asking for (non-existent) directory. -ENOENT for you.
1608 */
1593 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode) 1609 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
1594 goto enoent; 1610 goto enoent;
1595 return dentry; 1611 return dentry;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index d6a30c844de3..6537f2c4ae44 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -751,11 +751,6 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count,
751 retval = -EFAULT; 751 retval = -EFAULT;
752 if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len)) 752 if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len))
753 goto out; 753 goto out;
754 if (file->f_error) {
755 retval = file->f_error;
756 file->f_error = 0;
757 goto out;
758 }
759 retval = -EFBIG; 754 retval = -EFBIG;
760 if (limit != RLIM_INFINITY) { 755 if (limit != RLIM_INFINITY) {
761 if (pos >= limit) { 756 if (pos >= limit) {
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ae3940dc85cc..de340ffd33c3 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -50,7 +50,6 @@
50#include <linux/posix_acl.h> 50#include <linux/posix_acl.h>
51#ifdef CONFIG_NFSD_V4 51#ifdef CONFIG_NFSD_V4
52#include <linux/posix_acl_xattr.h> 52#include <linux/posix_acl_xattr.h>
53#include <linux/xattr_acl.h>
54#include <linux/xattr.h> 53#include <linux/xattr.h>
55#include <linux/nfs4.h> 54#include <linux/nfs4.h>
56#include <linux/nfs4_acl.h> 55#include <linux/nfs4_acl.h>
@@ -425,13 +424,13 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
425 goto out_nfserr; 424 goto out_nfserr;
426 425
427 if (pacl) { 426 if (pacl) {
428 error = set_nfsv4_acl_one(dentry, pacl, XATTR_NAME_ACL_ACCESS); 427 error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
429 if (error < 0) 428 if (error < 0)
430 goto out_nfserr; 429 goto out_nfserr;
431 } 430 }
432 431
433 if (dpacl) { 432 if (dpacl) {
434 error = set_nfsv4_acl_one(dentry, dpacl, XATTR_NAME_ACL_DEFAULT); 433 error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
435 if (error < 0) 434 if (error < 0)
436 goto out_nfserr; 435 goto out_nfserr;
437 } 436 }
@@ -498,7 +497,7 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, struct nfs4_ac
498 struct posix_acl *pacl = NULL, *dpacl = NULL; 497 struct posix_acl *pacl = NULL, *dpacl = NULL;
499 unsigned int flags = 0; 498 unsigned int flags = 0;
500 499
501 pacl = _get_posix_acl(dentry, XATTR_NAME_ACL_ACCESS); 500 pacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_ACCESS);
502 if (IS_ERR(pacl) && PTR_ERR(pacl) == -ENODATA) 501 if (IS_ERR(pacl) && PTR_ERR(pacl) == -ENODATA)
503 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 502 pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
504 if (IS_ERR(pacl)) { 503 if (IS_ERR(pacl)) {
@@ -508,7 +507,7 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, struct nfs4_ac
508 } 507 }
509 508
510 if (S_ISDIR(inode->i_mode)) { 509 if (S_ISDIR(inode->i_mode)) {
511 dpacl = _get_posix_acl(dentry, XATTR_NAME_ACL_DEFAULT); 510 dpacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_DEFAULT);
512 if (IS_ERR(dpacl) && PTR_ERR(dpacl) == -ENODATA) 511 if (IS_ERR(dpacl) && PTR_ERR(dpacl) == -ENODATA)
513 dpacl = NULL; 512 dpacl = NULL;
514 else if (IS_ERR(dpacl)) { 513 else if (IS_ERR(dpacl)) {
diff --git a/fs/open.c b/fs/open.c
index 963bd81a44c8..8ec63f735918 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -21,6 +21,7 @@
21#include <linux/vfs.h> 21#include <linux/vfs.h>
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/personality.h>
24#include <linux/pagemap.h> 25#include <linux/pagemap.h>
25#include <linux/syscalls.h> 26#include <linux/syscalls.h>
26 27
@@ -933,31 +934,27 @@ EXPORT_SYMBOL(fd_install);
933asmlinkage long sys_open(const char __user * filename, int flags, int mode) 934asmlinkage long sys_open(const char __user * filename, int flags, int mode)
934{ 935{
935 char * tmp; 936 char * tmp;
936 int fd, error; 937 int fd;
938
939 if (force_o_largefile())
940 flags |= O_LARGEFILE;
937 941
938#if BITS_PER_LONG != 32
939 flags |= O_LARGEFILE;
940#endif
941 tmp = getname(filename); 942 tmp = getname(filename);
942 fd = PTR_ERR(tmp); 943 fd = PTR_ERR(tmp);
943 if (!IS_ERR(tmp)) { 944 if (!IS_ERR(tmp)) {
944 fd = get_unused_fd(); 945 fd = get_unused_fd();
945 if (fd >= 0) { 946 if (fd >= 0) {
946 struct file *f = filp_open(tmp, flags, mode); 947 struct file *f = filp_open(tmp, flags, mode);
947 error = PTR_ERR(f); 948 if (IS_ERR(f)) {
948 if (IS_ERR(f)) 949 put_unused_fd(fd);
949 goto out_error; 950 fd = PTR_ERR(f);
950 fd_install(fd, f); 951 } else {
952 fd_install(fd, f);
953 }
951 } 954 }
952out:
953 putname(tmp); 955 putname(tmp);
954 } 956 }
955 return fd; 957 return fd;
956
957out_error:
958 put_unused_fd(fd);
959 fd = error;
960 goto out;
961} 958}
962EXPORT_SYMBOL_GPL(sys_open); 959EXPORT_SYMBOL_GPL(sys_open);
963 960
@@ -980,23 +977,15 @@ asmlinkage long sys_creat(const char __user * pathname, int mode)
980 */ 977 */
981int filp_close(struct file *filp, fl_owner_t id) 978int filp_close(struct file *filp, fl_owner_t id)
982{ 979{
983 int retval; 980 int retval = 0;
984
985 /* Report and clear outstanding errors */
986 retval = filp->f_error;
987 if (retval)
988 filp->f_error = 0;
989 981
990 if (!file_count(filp)) { 982 if (!file_count(filp)) {
991 printk(KERN_ERR "VFS: Close: file count is 0\n"); 983 printk(KERN_ERR "VFS: Close: file count is 0\n");
992 return retval; 984 return 0;
993 } 985 }
994 986
995 if (filp->f_op && filp->f_op->flush) { 987 if (filp->f_op && filp->f_op->flush)
996 int err = filp->f_op->flush(filp); 988 retval = filp->f_op->flush(filp);
997 if (!retval)
998 retval = err;
999 }
1000 989
1001 dnotify_flush(filp, id); 990 dnotify_flush(filp, id);
1002 locks_remove_posix(filp, id); 991 locks_remove_posix(filp, id);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index e31903aadd96..ace151fa4878 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -314,7 +314,7 @@ static int may_ptrace_attach(struct task_struct *task)
314 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) 314 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE))
315 goto out; 315 goto out;
316 rmb(); 316 rmb();
317 if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) 317 if (task->mm->dumpable != 1 && !capable(CAP_SYS_PTRACE))
318 goto out; 318 goto out;
319 if (security_ptrace(current, task)) 319 if (security_ptrace(current, task))
320 goto out; 320 goto out;
@@ -1113,7 +1113,9 @@ static int task_dumpable(struct task_struct *task)
1113 if (mm) 1113 if (mm)
1114 dumpable = mm->dumpable; 1114 dumpable = mm->dumpable;
1115 task_unlock(task); 1115 task_unlock(task);
1116 return dumpable; 1116 if(dumpable == 1)
1117 return 1;
1118 return 0;
1117} 1119}
1118 1120
1119 1121
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 63a9fbf1ac51..94b570ad037d 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -451,7 +451,7 @@ static int devices_read_proc(char *page, char **start, off_t off,
451 int count, int *eof, void *data) 451 int count, int *eof, void *data)
452{ 452{
453 int len = get_chrdev_list(page); 453 int len = get_chrdev_list(page);
454 len += get_blkdev_list(page+len); 454 len += get_blkdev_list(page+len, len);
455 return proc_calc_metrics(page, start, off, count, eof, len); 455 return proc_calc_metrics(page, start, off, count, eof, len);
456} 456}
457 457
diff --git a/fs/quota.c b/fs/quota.c
index 3f0333a51a23..f5d1cff55196 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -149,36 +149,6 @@ static int check_quotactl_valid(struct super_block *sb, int type, int cmd, qid_t
149 return error; 149 return error;
150} 150}
151 151
152static struct super_block *get_super_to_sync(int type)
153{
154 struct list_head *head;
155 int cnt, dirty;
156
157restart:
158 spin_lock(&sb_lock);
159 list_for_each(head, &super_blocks) {
160 struct super_block *sb = list_entry(head, struct super_block, s_list);
161
162 /* This test just improves performance so it needn't be reliable... */
163 for (cnt = 0, dirty = 0; cnt < MAXQUOTAS; cnt++)
164 if ((type == cnt || type == -1) && sb_has_quota_enabled(sb, cnt)
165 && info_any_dirty(&sb_dqopt(sb)->info[cnt]))
166 dirty = 1;
167 if (!dirty)
168 continue;
169 sb->s_count++;
170 spin_unlock(&sb_lock);
171 down_read(&sb->s_umount);
172 if (!sb->s_root) {
173 drop_super(sb);
174 goto restart;
175 }
176 return sb;
177 }
178 spin_unlock(&sb_lock);
179 return NULL;
180}
181
182static void quota_sync_sb(struct super_block *sb, int type) 152static void quota_sync_sb(struct super_block *sb, int type)
183{ 153{
184 int cnt; 154 int cnt;
@@ -219,17 +189,35 @@ static void quota_sync_sb(struct super_block *sb, int type)
219 189
220void sync_dquots(struct super_block *sb, int type) 190void sync_dquots(struct super_block *sb, int type)
221{ 191{
192 int cnt, dirty;
193
222 if (sb) { 194 if (sb) {
223 if (sb->s_qcop->quota_sync) 195 if (sb->s_qcop->quota_sync)
224 quota_sync_sb(sb, type); 196 quota_sync_sb(sb, type);
197 return;
225 } 198 }
226 else { 199
227 while ((sb = get_super_to_sync(type)) != NULL) { 200 spin_lock(&sb_lock);
228 if (sb->s_qcop->quota_sync) 201restart:
229 quota_sync_sb(sb, type); 202 list_for_each_entry(sb, &super_blocks, s_list) {
230 drop_super(sb); 203 /* This test just improves performance so it needn't be reliable... */
231 } 204 for (cnt = 0, dirty = 0; cnt < MAXQUOTAS; cnt++)
205 if ((type == cnt || type == -1) && sb_has_quota_enabled(sb, cnt)
206 && info_any_dirty(&sb_dqopt(sb)->info[cnt]))
207 dirty = 1;
208 if (!dirty)
209 continue;
210 sb->s_count++;
211 spin_unlock(&sb_lock);
212 down_read(&sb->s_umount);
213 if (sb->s_root && sb->s_qcop->quota_sync)
214 quota_sync_sb(sb, type);
215 up_read(&sb->s_umount);
216 spin_lock(&sb_lock);
217 if (__put_super_and_need_restart(sb))
218 goto restart;
232 } 219 }
220 spin_unlock(&sb_lock);
233} 221}
234 222
235/* Copy parameters and call proper function */ 223/* Copy parameters and call proper function */
diff --git a/fs/read_write.c b/fs/read_write.c
index c4c2bee373ed..9292f5fa4d62 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -203,6 +203,16 @@ Einval:
203 return -EINVAL; 203 return -EINVAL;
204} 204}
205 205
206static void wait_on_retry_sync_kiocb(struct kiocb *iocb)
207{
208 set_current_state(TASK_UNINTERRUPTIBLE);
209 if (!kiocbIsKicked(iocb))
210 schedule();
211 else
212 kiocbClearKicked(iocb);
213 __set_current_state(TASK_RUNNING);
214}
215
206ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) 216ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
207{ 217{
208 struct kiocb kiocb; 218 struct kiocb kiocb;
@@ -210,7 +220,10 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
210 220
211 init_sync_kiocb(&kiocb, filp); 221 init_sync_kiocb(&kiocb, filp);
212 kiocb.ki_pos = *ppos; 222 kiocb.ki_pos = *ppos;
213 ret = filp->f_op->aio_read(&kiocb, buf, len, kiocb.ki_pos); 223 while (-EIOCBRETRY ==
224 (ret = filp->f_op->aio_read(&kiocb, buf, len, kiocb.ki_pos)))
225 wait_on_retry_sync_kiocb(&kiocb);
226
214 if (-EIOCBQUEUED == ret) 227 if (-EIOCBQUEUED == ret)
215 ret = wait_on_sync_kiocb(&kiocb); 228 ret = wait_on_sync_kiocb(&kiocb);
216 *ppos = kiocb.ki_pos; 229 *ppos = kiocb.ki_pos;
@@ -258,7 +271,10 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
258 271
259 init_sync_kiocb(&kiocb, filp); 272 init_sync_kiocb(&kiocb, filp);
260 kiocb.ki_pos = *ppos; 273 kiocb.ki_pos = *ppos;
261 ret = filp->f_op->aio_write(&kiocb, buf, len, kiocb.ki_pos); 274 while (-EIOCBRETRY ==
275 (ret = filp->f_op->aio_write(&kiocb, buf, len, kiocb.ki_pos)))
276 wait_on_retry_sync_kiocb(&kiocb);
277
262 if (-EIOCBQUEUED == ret) 278 if (-EIOCBQUEUED == ret)
263 ret = wait_on_sync_kiocb(&kiocb); 279 ret = wait_on_sync_kiocb(&kiocb);
264 *ppos = kiocb.ki_pos; 280 *ppos = kiocb.ki_pos;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index b35b87744983..aae0779ed5b4 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1932,27 +1932,12 @@ static int reiserfs_write_info(struct super_block *sb, int type)
1932} 1932}
1933 1933
1934/* 1934/*
1935 * Turn on quotas during mount time - we need to find 1935 * Turn on quotas during mount time - we need to find the quota file and such...
1936 * the quota file and such...
1937 */ 1936 */
1938static int reiserfs_quota_on_mount(struct super_block *sb, int type) 1937static int reiserfs_quota_on_mount(struct super_block *sb, int type)
1939{ 1938{
1940 int err; 1939 return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
1941 struct dentry *dentry; 1940 REISERFS_SB(sb)->s_jquota_fmt, type);
1942 struct qstr name = { .name = REISERFS_SB(sb)->s_qf_names[type],
1943 .hash = 0,
1944 .len = strlen(REISERFS_SB(sb)->s_qf_names[type])};
1945
1946 dentry = lookup_hash(&name, sb->s_root);
1947 if (IS_ERR(dentry))
1948 return PTR_ERR(dentry);
1949 err = vfs_quota_on_mount(type, REISERFS_SB(sb)->s_jquota_fmt, dentry);
1950 /* Now invalidate and put the dentry - quota got its own reference
1951 * to inode and dentry has at least wrong hash so we had better
1952 * throw it away */
1953 d_invalidate(dentry);
1954 dput(dentry);
1955 return err;
1956} 1941}
1957 1942
1958/* 1943/*
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index e302071903a1..c312881c5f53 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -4,7 +4,7 @@
4#include <linux/errno.h> 4#include <linux/errno.h>
5#include <linux/pagemap.h> 5#include <linux/pagemap.h>
6#include <linux/xattr.h> 6#include <linux/xattr.h>
7#include <linux/xattr_acl.h> 7#include <linux/posix_acl_xattr.h>
8#include <linux/reiserfs_xattr.h> 8#include <linux/reiserfs_xattr.h>
9#include <linux/reiserfs_acl.h> 9#include <linux/reiserfs_acl.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
@@ -192,11 +192,11 @@ reiserfs_get_acl(struct inode *inode, int type)
192 192
193 switch (type) { 193 switch (type) {
194 case ACL_TYPE_ACCESS: 194 case ACL_TYPE_ACCESS:
195 name = XATTR_NAME_ACL_ACCESS; 195 name = POSIX_ACL_XATTR_ACCESS;
196 p_acl = &reiserfs_i->i_acl_access; 196 p_acl = &reiserfs_i->i_acl_access;
197 break; 197 break;
198 case ACL_TYPE_DEFAULT: 198 case ACL_TYPE_DEFAULT:
199 name = XATTR_NAME_ACL_DEFAULT; 199 name = POSIX_ACL_XATTR_DEFAULT;
200 p_acl = &reiserfs_i->i_acl_default; 200 p_acl = &reiserfs_i->i_acl_default;
201 break; 201 break;
202 default: 202 default:
@@ -260,7 +260,7 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
260 260
261 switch (type) { 261 switch (type) {
262 case ACL_TYPE_ACCESS: 262 case ACL_TYPE_ACCESS:
263 name = XATTR_NAME_ACL_ACCESS; 263 name = POSIX_ACL_XATTR_ACCESS;
264 p_acl = &reiserfs_i->i_acl_access; 264 p_acl = &reiserfs_i->i_acl_access;
265 if (acl) { 265 if (acl) {
266 mode_t mode = inode->i_mode; 266 mode_t mode = inode->i_mode;
@@ -275,7 +275,7 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
275 } 275 }
276 break; 276 break;
277 case ACL_TYPE_DEFAULT: 277 case ACL_TYPE_DEFAULT:
278 name = XATTR_NAME_ACL_DEFAULT; 278 name = POSIX_ACL_XATTR_DEFAULT;
279 p_acl = &reiserfs_i->i_acl_default; 279 p_acl = &reiserfs_i->i_acl_default;
280 if (!S_ISDIR (inode->i_mode)) 280 if (!S_ISDIR (inode->i_mode))
281 return acl ? -EACCES : 0; 281 return acl ? -EACCES : 0;
@@ -468,7 +468,7 @@ static int
468posix_acl_access_get(struct inode *inode, const char *name, 468posix_acl_access_get(struct inode *inode, const char *name,
469 void *buffer, size_t size) 469 void *buffer, size_t size)
470{ 470{
471 if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1) 471 if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
472 return -EINVAL; 472 return -EINVAL;
473 return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 473 return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
474} 474}
@@ -477,7 +477,7 @@ static int
477posix_acl_access_set(struct inode *inode, const char *name, 477posix_acl_access_set(struct inode *inode, const char *name,
478 const void *value, size_t size, int flags) 478 const void *value, size_t size, int flags)
479{ 479{
480 if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1) 480 if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
481 return -EINVAL; 481 return -EINVAL;
482 return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 482 return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
483} 483}
@@ -487,7 +487,7 @@ posix_acl_access_del (struct inode *inode, const char *name)
487{ 487{
488 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); 488 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
489 struct posix_acl **acl = &reiserfs_i->i_acl_access; 489 struct posix_acl **acl = &reiserfs_i->i_acl_access;
490 if (strlen(name) != sizeof(XATTR_NAME_ACL_ACCESS)-1) 490 if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
491 return -EINVAL; 491 return -EINVAL;
492 if (!IS_ERR (*acl) && *acl) { 492 if (!IS_ERR (*acl) && *acl) {
493 posix_acl_release (*acl); 493 posix_acl_release (*acl);
@@ -510,7 +510,7 @@ posix_acl_access_list (struct inode *inode, const char *name, int namelen, char
510} 510}
511 511
512struct reiserfs_xattr_handler posix_acl_access_handler = { 512struct reiserfs_xattr_handler posix_acl_access_handler = {
513 .prefix = XATTR_NAME_ACL_ACCESS, 513 .prefix = POSIX_ACL_XATTR_ACCESS,
514 .get = posix_acl_access_get, 514 .get = posix_acl_access_get,
515 .set = posix_acl_access_set, 515 .set = posix_acl_access_set,
516 .del = posix_acl_access_del, 516 .del = posix_acl_access_del,
@@ -521,7 +521,7 @@ static int
521posix_acl_default_get (struct inode *inode, const char *name, 521posix_acl_default_get (struct inode *inode, const char *name,
522 void *buffer, size_t size) 522 void *buffer, size_t size)
523{ 523{
524 if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1) 524 if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
525 return -EINVAL; 525 return -EINVAL;
526 return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 526 return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
527} 527}
@@ -530,7 +530,7 @@ static int
530posix_acl_default_set(struct inode *inode, const char *name, 530posix_acl_default_set(struct inode *inode, const char *name,
531 const void *value, size_t size, int flags) 531 const void *value, size_t size, int flags)
532{ 532{
533 if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1) 533 if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
534 return -EINVAL; 534 return -EINVAL;
535 return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 535 return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
536} 536}
@@ -540,7 +540,7 @@ posix_acl_default_del (struct inode *inode, const char *name)
540{ 540{
541 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); 541 struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
542 struct posix_acl **acl = &reiserfs_i->i_acl_default; 542 struct posix_acl **acl = &reiserfs_i->i_acl_default;
543 if (strlen(name) != sizeof(XATTR_NAME_ACL_DEFAULT)-1) 543 if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
544 return -EINVAL; 544 return -EINVAL;
545 if (!IS_ERR (*acl) && *acl) { 545 if (!IS_ERR (*acl) && *acl) {
546 posix_acl_release (*acl); 546 posix_acl_release (*acl);
@@ -563,7 +563,7 @@ posix_acl_default_list (struct inode *inode, const char *name, int namelen, char
563} 563}
564 564
565struct reiserfs_xattr_handler posix_acl_default_handler = { 565struct reiserfs_xattr_handler posix_acl_default_handler = {
566 .prefix = XATTR_NAME_ACL_DEFAULT, 566 .prefix = POSIX_ACL_XATTR_DEFAULT,
567 .get = posix_acl_default_get, 567 .get = posix_acl_default_get,
568 .set = posix_acl_default_set, 568 .set = posix_acl_default_set,
569 .del = posix_acl_default_del, 569 .del = posix_acl_default_del,
diff --git a/fs/super.c b/fs/super.c
index 573bcc81bb82..25bc1ec6bc5d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -341,20 +341,22 @@ static inline void write_super(struct super_block *sb)
341 */ 341 */
342void sync_supers(void) 342void sync_supers(void)
343{ 343{
344 struct super_block * sb; 344 struct super_block *sb;
345restart: 345
346 spin_lock(&sb_lock); 346 spin_lock(&sb_lock);
347 sb = sb_entry(super_blocks.next); 347restart:
348 while (sb != sb_entry(&super_blocks)) 348 list_for_each_entry(sb, &super_blocks, s_list) {
349 if (sb->s_dirt) { 349 if (sb->s_dirt) {
350 sb->s_count++; 350 sb->s_count++;
351 spin_unlock(&sb_lock); 351 spin_unlock(&sb_lock);
352 down_read(&sb->s_umount); 352 down_read(&sb->s_umount);
353 write_super(sb); 353 write_super(sb);
354 drop_super(sb); 354 up_read(&sb->s_umount);
355 goto restart; 355 spin_lock(&sb_lock);
356 } else 356 if (__put_super_and_need_restart(sb))
357 sb = sb_entry(sb->s_list.next); 357 goto restart;
358 }
359 }
358 spin_unlock(&sb_lock); 360 spin_unlock(&sb_lock);
359} 361}
360 362
@@ -381,20 +383,16 @@ void sync_filesystems(int wait)
381 383
382 down(&mutex); /* Could be down_interruptible */ 384 down(&mutex); /* Could be down_interruptible */
383 spin_lock(&sb_lock); 385 spin_lock(&sb_lock);
384 for (sb = sb_entry(super_blocks.next); sb != sb_entry(&super_blocks); 386 list_for_each_entry(sb, &super_blocks, s_list) {
385 sb = sb_entry(sb->s_list.next)) {
386 if (!sb->s_op->sync_fs) 387 if (!sb->s_op->sync_fs)
387 continue; 388 continue;
388 if (sb->s_flags & MS_RDONLY) 389 if (sb->s_flags & MS_RDONLY)
389 continue; 390 continue;
390 sb->s_need_sync_fs = 1; 391 sb->s_need_sync_fs = 1;
391 } 392 }
392 spin_unlock(&sb_lock);
393 393
394restart: 394restart:
395 spin_lock(&sb_lock); 395 list_for_each_entry(sb, &super_blocks, s_list) {
396 for (sb = sb_entry(super_blocks.next); sb != sb_entry(&super_blocks);
397 sb = sb_entry(sb->s_list.next)) {
398 if (!sb->s_need_sync_fs) 396 if (!sb->s_need_sync_fs)
399 continue; 397 continue;
400 sb->s_need_sync_fs = 0; 398 sb->s_need_sync_fs = 0;
@@ -405,8 +403,11 @@ restart:
405 down_read(&sb->s_umount); 403 down_read(&sb->s_umount);
406 if (sb->s_root && (wait || sb->s_dirt)) 404 if (sb->s_root && (wait || sb->s_dirt))
407 sb->s_op->sync_fs(sb, wait); 405 sb->s_op->sync_fs(sb, wait);
408 drop_super(sb); 406 up_read(&sb->s_umount);
409 goto restart; 407 /* restart only when sb is no longer on the list */
408 spin_lock(&sb_lock);
409 if (__put_super_and_need_restart(sb))
410 goto restart;
410 } 411 }
411 spin_unlock(&sb_lock); 412 spin_unlock(&sb_lock);
412 up(&mutex); 413 up(&mutex);
@@ -422,21 +423,25 @@ restart:
422 423
423struct super_block * get_super(struct block_device *bdev) 424struct super_block * get_super(struct block_device *bdev)
424{ 425{
425 struct list_head *p; 426 struct super_block *sb;
427
426 if (!bdev) 428 if (!bdev)
427 return NULL; 429 return NULL;
428rescan: 430
429 spin_lock(&sb_lock); 431 spin_lock(&sb_lock);
430 list_for_each(p, &super_blocks) { 432rescan:
431 struct super_block *s = sb_entry(p); 433 list_for_each_entry(sb, &super_blocks, s_list) {
432 if (s->s_bdev == bdev) { 434 if (sb->s_bdev == bdev) {
433 s->s_count++; 435 sb->s_count++;
434 spin_unlock(&sb_lock); 436 spin_unlock(&sb_lock);
435 down_read(&s->s_umount); 437 down_read(&sb->s_umount);
436 if (s->s_root) 438 if (sb->s_root)
437 return s; 439 return sb;
438 drop_super(s); 440 up_read(&sb->s_umount);
439 goto rescan; 441 /* restart only when sb is no longer on the list */
442 spin_lock(&sb_lock);
443 if (__put_super_and_need_restart(sb))
444 goto rescan;
440 } 445 }
441 } 446 }
442 spin_unlock(&sb_lock); 447 spin_unlock(&sb_lock);
@@ -447,20 +452,22 @@ EXPORT_SYMBOL(get_super);
447 452
448struct super_block * user_get_super(dev_t dev) 453struct super_block * user_get_super(dev_t dev)
449{ 454{
450 struct list_head *p; 455 struct super_block *sb;
451 456
452rescan:
453 spin_lock(&sb_lock); 457 spin_lock(&sb_lock);
454 list_for_each(p, &super_blocks) { 458rescan:
455 struct super_block *s = sb_entry(p); 459 list_for_each_entry(sb, &super_blocks, s_list) {
456 if (s->s_dev == dev) { 460 if (sb->s_dev == dev) {
457 s->s_count++; 461 sb->s_count++;
458 spin_unlock(&sb_lock); 462 spin_unlock(&sb_lock);
459 down_read(&s->s_umount); 463 down_read(&sb->s_umount);
460 if (s->s_root) 464 if (sb->s_root)
461 return s; 465 return sb;
462 drop_super(s); 466 up_read(&sb->s_umount);
463 goto rescan; 467 /* restart only when sb is no longer on the list */
468 spin_lock(&sb_lock);
469 if (__put_super_and_need_restart(sb))
470 goto rescan;
464 } 471 }
465 } 472 }
466 spin_unlock(&sb_lock); 473 spin_unlock(&sb_lock);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 37d7a6875d86..59734ba1ee60 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -8,6 +8,7 @@
8#include <linux/mount.h> 8#include <linux/mount.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kobject.h> 10#include <linux/kobject.h>
11#include <linux/namei.h>
11#include "sysfs.h" 12#include "sysfs.h"
12 13
13DECLARE_RWSEM(sysfs_rename_sem); 14DECLARE_RWSEM(sysfs_rename_sem);
@@ -99,7 +100,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
99 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; 100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
100 101
101 down(&p->d_inode->i_sem); 102 down(&p->d_inode->i_sem);
102 *d = sysfs_get_dentry(p,n); 103 *d = lookup_one_len(n, p, strlen(n));
103 if (!IS_ERR(*d)) { 104 if (!IS_ERR(*d)) {
104 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR); 105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
105 if (!error) { 106 if (!error) {
@@ -315,7 +316,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
315 316
316 down(&parent->d_inode->i_sem); 317 down(&parent->d_inode->i_sem);
317 318
318 new_dentry = sysfs_get_dentry(parent, new_name); 319 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
319 if (!IS_ERR(new_dentry)) { 320 if (!IS_ERR(new_dentry)) {
320 if (!new_dentry->d_inode) { 321 if (!new_dentry->d_inode) {
321 error = kobject_set_name(kobj, "%s", new_name); 322 error = kobject_set_name(kobj, "%s", new_name);
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 849aac115460..e9cfa39f4099 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -5,6 +5,7 @@
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/dnotify.h> 6#include <linux/dnotify.h>
7#include <linux/kobject.h> 7#include <linux/kobject.h>
8#include <linux/namei.h>
8#include <asm/uaccess.h> 9#include <asm/uaccess.h>
9#include <asm/semaphore.h> 10#include <asm/semaphore.h>
10 11
@@ -400,7 +401,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
400 int res = -ENOENT; 401 int res = -ENOENT;
401 402
402 down(&dir->d_inode->i_sem); 403 down(&dir->d_inode->i_sem);
403 victim = sysfs_get_dentry(dir, attr->name); 404 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
404 if (!IS_ERR(victim)) { 405 if (!IS_ERR(victim)) {
405 /* make sure dentry is really there */ 406 /* make sure dentry is really there */
406 if (victim->d_inode && 407 if (victim->d_inode &&
@@ -443,7 +444,7 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
443 int res = -ENOENT; 444 int res = -ENOENT;
444 445
445 down(&dir->d_inode->i_sem); 446 down(&dir->d_inode->i_sem);
446 victim = sysfs_get_dentry(dir, attr->name); 447 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
447 if (!IS_ERR(victim)) { 448 if (!IS_ERR(victim)) {
448 if (victim->d_inode && 449 if (victim->d_inode &&
449 (victim->d_parent->d_inode == dir->d_inode)) { 450 (victim->d_parent->d_inode == dir->d_inode)) {
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index f11ac5ea7021..122145b0895c 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -11,6 +11,7 @@
11#include <linux/kobject.h> 11#include <linux/kobject.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/dcache.h> 13#include <linux/dcache.h>
14#include <linux/namei.h>
14#include <linux/err.h> 15#include <linux/err.h>
15#include "sysfs.h" 16#include "sysfs.h"
16 17
@@ -68,7 +69,8 @@ void sysfs_remove_group(struct kobject * kobj,
68 struct dentry * dir; 69 struct dentry * dir;
69 70
70 if (grp->name) 71 if (grp->name)
71 dir = sysfs_get_dentry(kobj->dentry,grp->name); 72 dir = lookup_one_len(grp->name, kobj->dentry,
73 strlen(grp->name));
72 else 74 else
73 dir = dget(kobj->dentry); 75 dir = dget(kobj->dentry);
74 76
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 565cac1d4200..8de13bafaa76 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -166,16 +166,6 @@ int sysfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *))
166 return error; 166 return error;
167} 167}
168 168
169struct dentry * sysfs_get_dentry(struct dentry * parent, const char * name)
170{
171 struct qstr qstr;
172
173 qstr.name = name;
174 qstr.len = strlen(name);
175 qstr.hash = full_name_hash(name,qstr.len);
176 return lookup_hash(&qstr,parent);
177}
178
179/* 169/*
180 * Get the name for corresponding element represented by the given sysfs_dirent 170 * Get the name for corresponding element represented by the given sysfs_dirent
181 */ 171 */
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 29da6f5f07c8..3f8953e0e5d0 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -7,7 +7,6 @@ extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
7 7
8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, 8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
9 umode_t, int); 9 umode_t, int);
10extern struct dentry * sysfs_get_dentry(struct dentry *, const char *);
11 10
12extern int sysfs_add_file(struct dentry *, const struct attribute *, int); 11extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
13extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); 12extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
diff --git a/include/asm-alpha/mmzone.h b/include/asm-alpha/mmzone.h
index 726c150dcbe4..a011ef4cf3d3 100644
--- a/include/asm-alpha/mmzone.h
+++ b/include/asm-alpha/mmzone.h
@@ -57,7 +57,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
57 * Given a kernel address, find the home node of the underlying memory. 57 * Given a kernel address, find the home node of the underlying memory.
58 */ 58 */
59#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr)) 59#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
60#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
61#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 60#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
62 61
63#define local_mapnr(kvaddr) \ 62#define local_mapnr(kvaddr) \
@@ -108,7 +107,7 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
108#define pfn_to_page(pfn) \ 107#define pfn_to_page(pfn) \
109({ \ 108({ \
110 unsigned long kaddr = (unsigned long)__va((pfn) << PAGE_SHIFT); \ 109 unsigned long kaddr = (unsigned long)__va((pfn) << PAGE_SHIFT); \
111 (node_mem_map(kvaddr_to_nid(kaddr)) + local_mapnr(kaddr)); \ 110 (NODE_DATA(kvaddr_to_nid(kaddr))->node_mem_map + local_mapnr(kaddr)); \
112}) 111})
113 112
114#define page_to_pfn(page) \ 113#define page_to_pfn(page) \
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index 66c585c50cf9..8252a4cd860f 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -49,7 +49,7 @@ struct cpu_context_save {
49 */ 49 */
50struct thread_info { 50struct thread_info {
51 unsigned long flags; /* low level flags */ 51 unsigned long flags; /* low level flags */
52 __s32 preempt_count; /* 0 => preemptable, <0 => bug */ 52 int preempt_count; /* 0 => preemptable, <0 => bug */
53 mm_segment_t addr_limit; /* address limit */ 53 mm_segment_t addr_limit; /* address limit */
54 struct task_struct *task; /* main task structure */ 54 struct task_struct *task; /* main task structure */
55 struct exec_domain *exec_domain; /* execution domain */ 55 struct exec_domain *exec_domain; /* execution domain */
diff --git a/include/asm-arm26/thread_info.h b/include/asm-arm26/thread_info.h
index 50f41b50268a..aff3e5699c64 100644
--- a/include/asm-arm26/thread_info.h
+++ b/include/asm-arm26/thread_info.h
@@ -44,7 +44,7 @@ struct cpu_context_save {
44 */ 44 */
45struct thread_info { 45struct thread_info {
46 unsigned long flags; /* low level flags */ 46 unsigned long flags; /* low level flags */
47 __s32 preempt_count; /* 0 => preemptable, <0 => bug */ 47 int preempt_count; /* 0 => preemptable, <0 => bug */
48 mm_segment_t addr_limit; /* address limit */ 48 mm_segment_t addr_limit; /* address limit */
49 struct task_struct *task; /* main task structure */ 49 struct task_struct *task; /* main task structure */
50 struct exec_domain *exec_domain; /* execution domain */ 50 struct exec_domain *exec_domain; /* execution domain */
diff --git a/include/asm-cris/thread_info.h b/include/asm-cris/thread_info.h
index 53193feb0826..5ba4b7865cc5 100644
--- a/include/asm-cris/thread_info.h
+++ b/include/asm-cris/thread_info.h
@@ -31,7 +31,7 @@ struct thread_info {
31 struct exec_domain *exec_domain; /* execution domain */ 31 struct exec_domain *exec_domain; /* execution domain */
32 unsigned long flags; /* low level flags */ 32 unsigned long flags; /* low level flags */
33 __u32 cpu; /* current CPU */ 33 __u32 cpu; /* current CPU */
34 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 34 int preempt_count; /* 0 => preemptable, <0 => BUG */
35 35
36 mm_segment_t addr_limit; /* thread address space: 36 mm_segment_t addr_limit; /* thread address space:
37 0-0xBFFFFFFF for user-thead 37 0-0xBFFFFFFF for user-thead
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
index b80a97f50af6..c8cba7836f0d 100644
--- a/include/asm-frv/thread_info.h
+++ b/include/asm-frv/thread_info.h
@@ -33,7 +33,7 @@ struct thread_info {
33 unsigned long flags; /* low level flags */ 33 unsigned long flags; /* low level flags */
34 unsigned long status; /* thread-synchronous flags */ 34 unsigned long status; /* thread-synchronous flags */
35 __u32 cpu; /* current CPU */ 35 __u32 cpu; /* current CPU */
36 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 36 int preempt_count; /* 0 => preemptable, <0 => BUG */
37 37
38 mm_segment_t addr_limit; /* thread address space: 38 mm_segment_t addr_limit; /* thread address space:
39 0-0xBFFFFFFF for user-thead 39 0-0xBFFFFFFF for user-thead
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 3b709b84934f..9044aeb37828 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -29,7 +29,7 @@ do { \
29#define DEFINE_PER_CPU(type, name) \ 29#define DEFINE_PER_CPU(type, name) \
30 __typeof__(type) per_cpu__##name 30 __typeof__(type) per_cpu__##name
31 31
32#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var)) 32#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
33#define __get_cpu_var(var) per_cpu__##var 33#define __get_cpu_var(var) per_cpu__##var
34 34
35#endif /* SMP */ 35#endif /* SMP */
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h
index ec96e8b0f190..5d9d70cd17fc 100644
--- a/include/asm-generic/topology.h
+++ b/include/asm-generic/topology.h
@@ -41,8 +41,15 @@
41#ifndef node_to_first_cpu 41#ifndef node_to_first_cpu
42#define node_to_first_cpu(node) (0) 42#define node_to_first_cpu(node) (0)
43#endif 43#endif
44#ifndef pcibus_to_node
45#define pcibus_to_node(node) (-1)
46#endif
47
44#ifndef pcibus_to_cpumask 48#ifndef pcibus_to_cpumask
45#define pcibus_to_cpumask(bus) (cpu_online_map) 49#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
50 CPU_MASK_ALL : \
51 node_to_cpumask(pcibus_to_node(bus)) \
52 )
46#endif 53#endif
47 54
48#endif /* _ASM_GENERIC_TOPOLOGY_H */ 55#endif /* _ASM_GENERIC_TOPOLOGY_H */
diff --git a/include/asm-h8300/thread_info.h b/include/asm-h8300/thread_info.h
index b07c9344776f..bfcc755c3bb1 100644
--- a/include/asm-h8300/thread_info.h
+++ b/include/asm-h8300/thread_info.h
@@ -23,7 +23,7 @@ struct thread_info {
23 struct exec_domain *exec_domain; /* execution domain */ 23 struct exec_domain *exec_domain; /* execution domain */
24 unsigned long flags; /* low level flags */ 24 unsigned long flags; /* low level flags */
25 int cpu; /* cpu we're on */ 25 int cpu; /* cpu we're on */
26 int preempt_count; /* 0 => preemptable, <0 => BUG*/ 26 int preempt_count; /* 0 => preemptable, <0 => BUG */
27 struct restart_block restart_block; 27 struct restart_block restart_block;
28}; 28};
29 29
diff --git a/include/asm-i386/checksum.h b/include/asm-i386/checksum.h
index 641342002bcd..f949e44c2a35 100644
--- a/include/asm-i386/checksum.h
+++ b/include/asm-i386/checksum.h
@@ -3,6 +3,8 @@
3 3
4#include <linux/in6.h> 4#include <linux/in6.h>
5 5
6#include <asm/uaccess.h>
7
6/* 8/*
7 * computes the checksum of a memory block at buff, length len, 9 * computes the checksum of a memory block at buff, length len,
8 * and adds in "sum" (32-bit) 10 * and adds in "sum" (32-bit)
diff --git a/include/asm-i386/genapic.h b/include/asm-i386/genapic.h
index fc813b2e8274..b3783a32abee 100644
--- a/include/asm-i386/genapic.h
+++ b/include/asm-i386/genapic.h
@@ -78,7 +78,6 @@ struct genapic {
78 .int_delivery_mode = INT_DELIVERY_MODE, \ 78 .int_delivery_mode = INT_DELIVERY_MODE, \
79 .int_dest_mode = INT_DEST_MODE, \ 79 .int_dest_mode = INT_DEST_MODE, \
80 .no_balance_irq = NO_BALANCE_IRQ, \ 80 .no_balance_irq = NO_BALANCE_IRQ, \
81 .no_ioapic_check = NO_IOAPIC_CHECK, \
82 .ESR_DISABLE = esr_disable, \ 81 .ESR_DISABLE = esr_disable, \
83 .apic_destination_logical = APIC_DEST_LOGICAL, \ 82 .apic_destination_logical = APIC_DEST_LOGICAL, \
84 APICFUNC(apic_id_registered), \ 83 APICFUNC(apic_id_registered), \
diff --git a/include/asm-i386/kprobes.h b/include/asm-i386/kprobes.h
index 4092f68d123a..8b6d3a90cd78 100644
--- a/include/asm-i386/kprobes.h
+++ b/include/asm-i386/kprobes.h
@@ -39,6 +39,9 @@ typedef u8 kprobe_opcode_t;
39 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) 39 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
40 40
41#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry 41#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
42#define ARCH_SUPPORTS_KRETPROBES
43
44void kretprobe_trampoline(void);
42 45
43/* Architecture specific copy of original instruction*/ 46/* Architecture specific copy of original instruction*/
44struct arch_specific_insn { 47struct arch_specific_insn {
diff --git a/include/asm-i386/mach-bigsmp/mach_apic.h b/include/asm-i386/mach-bigsmp/mach_apic.h
index 2339868270ef..ba936d4daedb 100644
--- a/include/asm-i386/mach-bigsmp/mach_apic.h
+++ b/include/asm-i386/mach-bigsmp/mach_apic.h
@@ -14,8 +14,6 @@
14#define NO_BALANCE_IRQ (1) 14#define NO_BALANCE_IRQ (1)
15#define esr_disable (1) 15#define esr_disable (1)
16 16
17#define NO_IOAPIC_CHECK (0)
18
19static inline int apic_id_registered(void) 17static inline int apic_id_registered(void)
20{ 18{
21 return (1); 19 return (1);
diff --git a/include/asm-i386/mach-default/mach_apic.h b/include/asm-i386/mach-default/mach_apic.h
index 627f1cd084ba..3ef6292db780 100644
--- a/include/asm-i386/mach-default/mach_apic.h
+++ b/include/asm-i386/mach-default/mach_apic.h
@@ -19,8 +19,6 @@ static inline cpumask_t target_cpus(void)
19#define NO_BALANCE_IRQ (0) 19#define NO_BALANCE_IRQ (0)
20#define esr_disable (0) 20#define esr_disable (0)
21 21
22#define NO_IOAPIC_CHECK (0)
23
24#define INT_DELIVERY_MODE dest_LowestPrio 22#define INT_DELIVERY_MODE dest_LowestPrio
25#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ 23#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
26 24
diff --git a/include/asm-i386/mach-es7000/mach_apic.h b/include/asm-i386/mach-es7000/mach_apic.h
index ceab2c464b13..b5f3f0d0b2bc 100644
--- a/include/asm-i386/mach-es7000/mach_apic.h
+++ b/include/asm-i386/mach-es7000/mach_apic.h
@@ -38,8 +38,6 @@ static inline cpumask_t target_cpus(void)
38#define WAKE_SECONDARY_VIA_INIT 38#define WAKE_SECONDARY_VIA_INIT
39#endif 39#endif
40 40
41#define NO_IOAPIC_CHECK (1)
42
43static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) 41static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
44{ 42{
45 return 0; 43 return 0;
diff --git a/include/asm-i386/mach-generic/mach_apic.h b/include/asm-i386/mach-generic/mach_apic.h
index ab36d02ebede..b13767a4e934 100644
--- a/include/asm-i386/mach-generic/mach_apic.h
+++ b/include/asm-i386/mach-generic/mach_apic.h
@@ -5,7 +5,6 @@
5 5
6#define esr_disable (genapic->ESR_DISABLE) 6#define esr_disable (genapic->ESR_DISABLE)
7#define NO_BALANCE_IRQ (genapic->no_balance_irq) 7#define NO_BALANCE_IRQ (genapic->no_balance_irq)
8#define NO_IOAPIC_CHECK (genapic->no_ioapic_check)
9#define INT_DELIVERY_MODE (genapic->int_delivery_mode) 8#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
10#define INT_DEST_MODE (genapic->int_dest_mode) 9#define INT_DEST_MODE (genapic->int_dest_mode)
11#undef APIC_DEST_LOGICAL 10#undef APIC_DEST_LOGICAL
diff --git a/include/asm-i386/mach-numaq/mach_apic.h b/include/asm-i386/mach-numaq/mach_apic.h
index e1a04494764a..9d158095da82 100644
--- a/include/asm-i386/mach-numaq/mach_apic.h
+++ b/include/asm-i386/mach-numaq/mach_apic.h
@@ -17,8 +17,6 @@ static inline cpumask_t target_cpus(void)
17#define NO_BALANCE_IRQ (1) 17#define NO_BALANCE_IRQ (1)
18#define esr_disable (1) 18#define esr_disable (1)
19 19
20#define NO_IOAPIC_CHECK (0)
21
22#define INT_DELIVERY_MODE dest_LowestPrio 20#define INT_DELIVERY_MODE dest_LowestPrio
23#define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */ 21#define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */
24 22
diff --git a/include/asm-i386/mach-summit/mach_apic.h b/include/asm-i386/mach-summit/mach_apic.h
index 74e9cbc8c01b..3d6d12937e1f 100644
--- a/include/asm-i386/mach-summit/mach_apic.h
+++ b/include/asm-i386/mach-summit/mach_apic.h
@@ -7,8 +7,6 @@
7#define esr_disable (1) 7#define esr_disable (1)
8#define NO_BALANCE_IRQ (0) 8#define NO_BALANCE_IRQ (0)
9 9
10#define NO_IOAPIC_CHECK (1) /* Don't check I/O APIC ID for xAPIC */
11
12/* In clustered mode, the high nibble of APIC ID is a cluster number. 10/* In clustered mode, the high nibble of APIC ID is a cluster number.
13 * The low nibble is a 4-bit bitmap. */ 11 * The low nibble is a 4-bit bitmap. */
14#define XAPIC_DEST_CPUS_SHIFT 4 12#define XAPIC_DEST_CPUS_SHIFT 4
diff --git a/include/asm-i386/mach-visws/mach_apic.h b/include/asm-i386/mach-visws/mach_apic.h
index 4e6cdfb8b091..de438c7147a8 100644
--- a/include/asm-i386/mach-visws/mach_apic.h
+++ b/include/asm-i386/mach-visws/mach_apic.h
@@ -9,8 +9,6 @@
9#define no_balance_irq (0) 9#define no_balance_irq (0)
10#define esr_disable (0) 10#define esr_disable (0)
11 11
12#define NO_IOAPIC_CHECK (0)
13
14#define INT_DELIVERY_MODE dest_LowestPrio 12#define INT_DELIVERY_MODE dest_LowestPrio
15#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ 13#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
16 14
diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
index 13830ae67cac..33ce5d37e894 100644
--- a/include/asm-i386/mmzone.h
+++ b/include/asm-i386/mmzone.h
@@ -8,7 +8,9 @@
8 8
9#include <asm/smp.h> 9#include <asm/smp.h>
10 10
11#ifdef CONFIG_DISCONTIGMEM 11#if CONFIG_NUMA
12extern struct pglist_data *node_data[];
13#define NODE_DATA(nid) (node_data[nid])
12 14
13#ifdef CONFIG_NUMA 15#ifdef CONFIG_NUMA
14 #ifdef CONFIG_X86_NUMAQ 16 #ifdef CONFIG_X86_NUMAQ
@@ -21,8 +23,28 @@
21 #define get_zholes_size(n) (0) 23 #define get_zholes_size(n) (0)
22#endif /* CONFIG_NUMA */ 24#endif /* CONFIG_NUMA */
23 25
24extern struct pglist_data *node_data[]; 26extern int get_memcfg_numa_flat(void );
25#define NODE_DATA(nid) (node_data[nid]) 27/*
28 * This allows any one NUMA architecture to be compiled
29 * for, and still fall back to the flat function if it
30 * fails.
31 */
32static inline void get_memcfg_numa(void)
33{
34#ifdef CONFIG_X86_NUMAQ
35 if (get_memcfg_numaq())
36 return;
37#elif CONFIG_ACPI_SRAT
38 if (get_memcfg_from_srat())
39 return;
40#endif
41
42 get_memcfg_numa_flat();
43}
44
45#endif /* CONFIG_NUMA */
46
47#ifdef CONFIG_DISCONTIGMEM
26 48
27/* 49/*
28 * generic node memory support, the following assumptions apply: 50 * generic node memory support, the following assumptions apply:
@@ -48,26 +70,6 @@ static inline int pfn_to_nid(unsigned long pfn)
48#endif 70#endif
49} 71}
50 72
51/*
52 * Following are macros that are specific to this numa platform.
53 */
54#define reserve_bootmem(addr, size) \
55 reserve_bootmem_node(NODE_DATA(0), (addr), (size))
56#define alloc_bootmem(x) \
57 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
58#define alloc_bootmem_low(x) \
59 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
60#define alloc_bootmem_pages(x) \
61 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
62#define alloc_bootmem_low_pages(x) \
63 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
64#define alloc_bootmem_node(ignore, x) \
65 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
66#define alloc_bootmem_pages_node(ignore, x) \
67 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
68#define alloc_bootmem_low_pages_node(ignore, x) \
69 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
70
71#define node_localnr(pfn, nid) ((pfn) - node_data[nid]->node_start_pfn) 73#define node_localnr(pfn, nid) ((pfn) - node_data[nid]->node_start_pfn)
72 74
73/* 75/*
@@ -79,7 +81,6 @@ static inline int pfn_to_nid(unsigned long pfn)
79 */ 81 */
80#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT) 82#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
81 83
82#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
83#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 84#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
84#define node_end_pfn(nid) \ 85#define node_end_pfn(nid) \
85({ \ 86({ \
@@ -100,7 +101,7 @@ static inline int pfn_to_nid(unsigned long pfn)
100({ \ 101({ \
101 unsigned long __pfn = pfn; \ 102 unsigned long __pfn = pfn; \
102 int __node = pfn_to_nid(__pfn); \ 103 int __node = pfn_to_nid(__pfn); \
103 &node_mem_map(__node)[node_localnr(__pfn,__node)]; \ 104 &NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
104}) 105})
105 106
106#define page_to_pfn(pg) \ 107#define page_to_pfn(pg) \
@@ -122,26 +123,34 @@ static inline int pfn_valid(int pfn)
122 return (pfn < node_end_pfn(nid)); 123 return (pfn < node_end_pfn(nid));
123 return 0; 124 return 0;
124} 125}
125#endif 126#endif /* CONFIG_X86_NUMAQ */
127
128#endif /* CONFIG_DISCONTIGMEM */
129
130#ifdef CONFIG_NEED_MULTIPLE_NODES
126 131
127extern int get_memcfg_numa_flat(void );
128/* 132/*
129 * This allows any one NUMA architecture to be compiled 133 * Following are macros that are specific to this numa platform.
130 * for, and still fall back to the flat function if it
131 * fails.
132 */ 134 */
133static inline void get_memcfg_numa(void) 135#define reserve_bootmem(addr, size) \
134{ 136 reserve_bootmem_node(NODE_DATA(0), (addr), (size))
135#ifdef CONFIG_X86_NUMAQ 137#define alloc_bootmem(x) \
136 if (get_memcfg_numaq()) 138 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
137 return; 139#define alloc_bootmem_low(x) \
138#elif CONFIG_ACPI_SRAT 140 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
139 if (get_memcfg_from_srat()) 141#define alloc_bootmem_pages(x) \
140 return; 142 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
141#endif 143#define alloc_bootmem_low_pages(x) \
144 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
145#define alloc_bootmem_node(ignore, x) \
146 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
147#define alloc_bootmem_pages_node(ignore, x) \
148 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
149#define alloc_bootmem_low_pages_node(ignore, x) \
150 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
142 151
143 get_memcfg_numa_flat(); 152#endif /* CONFIG_NEED_MULTIPLE_NODES */
144} 153
154extern int early_pfn_to_nid(unsigned long pfn);
145 155
146#endif /* CONFIG_DISCONTIGMEM */
147#endif /* _ASM_MMZONE_H_ */ 156#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index 41400d342d44..dea8f8e6d86e 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -120,6 +120,8 @@ static __inline__ int get_order(unsigned long size)
120 120
121extern int sysctl_legacy_va_layout; 121extern int sysctl_legacy_va_layout;
122 122
123extern int page_is_ram(unsigned long pagenr);
124
123#endif /* __ASSEMBLY__ */ 125#endif /* __ASSEMBLY__ */
124 126
125#ifdef __ASSEMBLY__ 127#ifdef __ASSEMBLY__
@@ -135,11 +137,11 @@ extern int sysctl_legacy_va_layout;
135#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) 137#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
136#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 138#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
137#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 139#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
138#ifndef CONFIG_DISCONTIGMEM 140#ifdef CONFIG_FLATMEM
139#define pfn_to_page(pfn) (mem_map + (pfn)) 141#define pfn_to_page(pfn) (mem_map + (pfn))
140#define page_to_pfn(page) ((unsigned long)((page) - mem_map)) 142#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
141#define pfn_valid(pfn) ((pfn) < max_mapnr) 143#define pfn_valid(pfn) ((pfn) < max_mapnr)
142#endif /* !CONFIG_DISCONTIGMEM */ 144#endif /* CONFIG_FLATMEM */
143#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 145#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
144 146
145#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 147#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
diff --git a/include/asm-i386/param.h b/include/asm-i386/param.h
index b6440526e42a..fa02e67ea86b 100644
--- a/include/asm-i386/param.h
+++ b/include/asm-i386/param.h
@@ -1,8 +1,10 @@
1#include <linux/config.h>
2
1#ifndef _ASMi386_PARAM_H 3#ifndef _ASMi386_PARAM_H
2#define _ASMi386_PARAM_H 4#define _ASMi386_PARAM_H
3 5
4#ifdef __KERNEL__ 6#ifdef __KERNEL__
5# define HZ 1000 /* Internal kernel timer frequency */ 7# define HZ CONFIG_HZ /* Internal kernel timer frequency */
6# define USER_HZ 100 /* .. some user interfaces are in "ticks" */ 8# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
7# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 9# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
8#endif 10#endif
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index e9efe148fdf7..77c6497f416e 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -398,9 +398,9 @@ extern void noexec_setup(const char *str);
398 398
399#endif /* !__ASSEMBLY__ */ 399#endif /* !__ASSEMBLY__ */
400 400
401#ifndef CONFIG_DISCONTIGMEM 401#ifdef CONFIG_FLATMEM
402#define kern_addr_valid(addr) (1) 402#define kern_addr_valid(addr) (1)
403#endif /* !CONFIG_DISCONTIGMEM */ 403#endif /* CONFIG_FLATMEM */
404 404
405#define io_remap_page_range(vma, vaddr, paddr, size, prot) \ 405#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
406 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot) 406 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 359bb0151742..c76c50e96225 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -501,12 +501,16 @@ static inline void load_esp0(struct tss_struct *tss, struct thread_struct *threa
501} while (0) 501} while (0)
502 502
503/* 503/*
504 * This special macro can be used to load a debugging register 504 * These special macros can be used to get or set a debugging register
505 */ 505 */
506#define loaddebug(thread,register) \ 506#define get_debugreg(var, register) \
507 __asm__("movl %0,%%db" #register \ 507 __asm__("movl %%db" #register ", %0" \
508 : /* no output */ \ 508 :"=r" (var))
509 :"r" ((thread)->debugreg[register])) 509#define set_debugreg(value, register) \
510 __asm__("movl %0,%%db" #register \
511 : /* no output */ \
512 :"r" (value))
513
510 514
511/* Forward declaration, a strange C thing */ 515/* Forward declaration, a strange C thing */
512struct task_struct; 516struct task_struct;
diff --git a/include/asm-i386/ptrace.h b/include/asm-i386/ptrace.h
index 8618914b3521..eef9f93870d4 100644
--- a/include/asm-i386/ptrace.h
+++ b/include/asm-i386/ptrace.h
@@ -57,7 +57,8 @@ struct pt_regs {
57#ifdef __KERNEL__ 57#ifdef __KERNEL__
58struct task_struct; 58struct task_struct;
59extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); 59extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
60#define user_mode(regs) ((VM_MASK & (regs)->eflags) || (3 & (regs)->xcs)) 60#define user_mode(regs) (3 & (regs)->xcs)
61#define user_mode_vm(regs) ((VM_MASK & (regs)->eflags) || user_mode(regs))
61#define instruction_pointer(regs) ((regs)->eip) 62#define instruction_pointer(regs) ((regs)->eip)
62#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER) 63#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER)
63extern unsigned long profile_pc(struct pt_regs *regs); 64extern unsigned long profile_pc(struct pt_regs *regs);
diff --git a/include/asm-i386/sparsemem.h b/include/asm-i386/sparsemem.h
new file mode 100644
index 000000000000..cfeed990585f
--- /dev/null
+++ b/include/asm-i386/sparsemem.h
@@ -0,0 +1,31 @@
1#ifndef _I386_SPARSEMEM_H
2#define _I386_SPARSEMEM_H
3#ifdef CONFIG_SPARSEMEM
4
5/*
6 * generic non-linear memory support:
7 *
8 * 1) we will not split memory into more chunks than will fit into the
9 * flags field of the struct page
10 */
11
12/*
13 * SECTION_SIZE_BITS 2^N: how big each section will be
14 * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
15 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
16 */
17#ifdef CONFIG_X86_PAE
18#define SECTION_SIZE_BITS 30
19#define MAX_PHYSADDR_BITS 36
20#define MAX_PHYSMEM_BITS 36
21#else
22#define SECTION_SIZE_BITS 26
23#define MAX_PHYSADDR_BITS 32
24#define MAX_PHYSMEM_BITS 32
25#endif
26
27/* XXX: FIXME -- wli */
28#define kern_addr_valid(kaddr) (0)
29
30#endif /* CONFIG_SPARSEMEM */
31#endif /* _I386_SPARSEMEM_H */
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index 2cd57271801d..95add81237ea 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -31,7 +31,7 @@ struct thread_info {
31 unsigned long flags; /* low level flags */ 31 unsigned long flags; /* low level flags */
32 unsigned long status; /* thread-synchronous flags */ 32 unsigned long status; /* thread-synchronous flags */
33 __u32 cpu; /* current CPU */ 33 __u32 cpu; /* current CPU */
34 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 34 int preempt_count; /* 0 => preemptable, <0 => BUG */
35 35
36 36
37 mm_segment_t addr_limit; /* thread address space: 37 mm_segment_t addr_limit; /* thread address space:
diff --git a/include/asm-i386/timer.h b/include/asm-i386/timer.h
index c34709849839..dcf1e07db08a 100644
--- a/include/asm-i386/timer.h
+++ b/include/asm-i386/timer.h
@@ -22,6 +22,7 @@ struct timer_opts {
22 unsigned long (*get_offset)(void); 22 unsigned long (*get_offset)(void);
23 unsigned long long (*monotonic_clock)(void); 23 unsigned long long (*monotonic_clock)(void);
24 void (*delay)(unsigned long); 24 void (*delay)(unsigned long);
25 unsigned long (*read_timer)(void);
25}; 26};
26 27
27struct init_timer_opts { 28struct init_timer_opts {
@@ -52,6 +53,7 @@ extern struct init_timer_opts timer_cyclone_init;
52#endif 53#endif
53 54
54extern unsigned long calibrate_tsc(void); 55extern unsigned long calibrate_tsc(void);
56extern unsigned long read_timer_tsc(void);
55extern void init_cpu_khz(void); 57extern void init_cpu_khz(void);
56extern int recalibrate_cpu_khz(void); 58extern int recalibrate_cpu_khz(void);
57#ifdef CONFIG_HPET_TIMER 59#ifdef CONFIG_HPET_TIMER
diff --git a/include/asm-i386/timex.h b/include/asm-i386/timex.h
index b41e484c3445..292b5a68f627 100644
--- a/include/asm-i386/timex.h
+++ b/include/asm-i386/timex.h
@@ -47,6 +47,9 @@ static inline cycles_t get_cycles (void)
47 return ret; 47 return ret;
48} 48}
49 49
50extern unsigned long cpu_khz; 50extern unsigned int cpu_khz;
51
52extern int read_current_timer(unsigned long *timer_value);
53#define ARCH_HAS_READ_CURRENT_TIMER 1
51 54
52#endif 55#endif
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h
index 98f9e6850cba..6d0f67507b21 100644
--- a/include/asm-i386/topology.h
+++ b/include/asm-i386/topology.h
@@ -60,12 +60,8 @@ static inline int node_to_first_cpu(int node)
60 return first_cpu(mask); 60 return first_cpu(mask);
61} 61}
62 62
63/* Returns the number of the node containing PCI bus number 'busnr' */ 63#define pcibus_to_node(bus) mp_bus_id_to_node[(bus)->number]
64static inline cpumask_t __pcibus_to_cpumask(int busnr) 64#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))
65{
66 return node_to_cpumask(mp_bus_id_to_node[busnr]);
67}
68#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number)
69 65
70/* sched_domains SD_NODE_INIT for NUMAQ machines */ 66/* sched_domains SD_NODE_INIT for NUMAQ machines */
71#define SD_NODE_INIT (struct sched_domain) { \ 67#define SD_NODE_INIT (struct sched_domain) { \
diff --git a/include/asm-ia64/break.h b/include/asm-ia64/break.h
index 97c7b2d79600..8167828edc4b 100644
--- a/include/asm-ia64/break.h
+++ b/include/asm-ia64/break.h
@@ -12,6 +12,8 @@
12 * OS-specific debug break numbers: 12 * OS-specific debug break numbers:
13 */ 13 */
14#define __IA64_BREAK_KDB 0x80100 14#define __IA64_BREAK_KDB 0x80100
15#define __IA64_BREAK_KPROBE 0x80200
16#define __IA64_BREAK_JPROBE 0x80300
15 17
16/* 18/*
17 * OS-specific break numbers: 19 * OS-specific break numbers:
diff --git a/include/asm-ia64/compat.h b/include/asm-ia64/compat.h
index cc0ff0a4bdd0..0c05e5bad8a0 100644
--- a/include/asm-ia64/compat.h
+++ b/include/asm-ia64/compat.h
@@ -27,6 +27,7 @@ typedef u16 compat_ipc_pid_t;
27typedef s32 compat_daddr_t; 27typedef s32 compat_daddr_t;
28typedef u32 compat_caddr_t; 28typedef u32 compat_caddr_t;
29typedef __kernel_fsid_t compat_fsid_t; 29typedef __kernel_fsid_t compat_fsid_t;
30typedef s32 compat_timer_t;
30 31
31typedef s32 compat_int_t; 32typedef s32 compat_int_t;
32typedef s32 compat_long_t; 33typedef s32 compat_long_t;
diff --git a/include/asm-ia64/fcntl.h b/include/asm-ia64/fcntl.h
index d193981bb1d8..c9f8d835d0cc 100644
--- a/include/asm-ia64/fcntl.h
+++ b/include/asm-ia64/fcntl.h
@@ -81,4 +81,6 @@ struct flock {
81 81
82#define F_LINUX_SPECIFIC_BASE 1024 82#define F_LINUX_SPECIFIC_BASE 1024
83 83
84#define force_o_largefile() ( ! (current->personality & PER_LINUX32) )
85
84#endif /* _ASM_IA64_FCNTL_H */ 86#endif /* _ASM_IA64_FCNTL_H */
diff --git a/include/asm-ia64/kdebug.h b/include/asm-ia64/kdebug.h
new file mode 100644
index 000000000000..4d376e1663f7
--- /dev/null
+++ b/include/asm-ia64/kdebug.h
@@ -0,0 +1,61 @@
1#ifndef _IA64_KDEBUG_H
2#define _IA64_KDEBUG_H 1
3/*
4 * include/asm-ia64/kdebug.h
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 * Copyright (C) Intel Corporation, 2005
21 *
22 * 2005-Apr Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy
23 * <anil.s.keshavamurthy@intel.com> adopted from
24 * include/asm-x86_64/kdebug.h
25 */
26#include <linux/notifier.h>
27
28struct pt_regs;
29
30struct die_args {
31 struct pt_regs *regs;
32 const char *str;
33 long err;
34 int trapnr;
35 int signr;
36};
37
38int register_die_notifier(struct notifier_block *nb);
39extern struct notifier_block *ia64die_chain;
40
41enum die_val {
42 DIE_BREAK = 1,
43 DIE_SS,
44 DIE_PAGE_FAULT,
45};
46
47static inline int notify_die(enum die_val val, char *str, struct pt_regs *regs,
48 long err, int trap, int sig)
49{
50 struct die_args args = {
51 .regs = regs,
52 .str = str,
53 .err = err,
54 .trapnr = trap,
55 .signr = sig
56 };
57
58 return notifier_call_chain(&ia64die_chain, val, &args);
59}
60
61#endif
diff --git a/include/asm-ia64/kprobes.h b/include/asm-ia64/kprobes.h
new file mode 100644
index 000000000000..7b700035e36d
--- /dev/null
+++ b/include/asm-ia64/kprobes.h
@@ -0,0 +1,116 @@
1#ifndef _ASM_KPROBES_H
2#define _ASM_KPROBES_H
3/*
4 * Kernel Probes (KProbes)
5 * include/asm-ia64/kprobes.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright (C) IBM Corporation, 2002, 2004
22 * Copyright (C) Intel Corporation, 2005
23 *
24 * 2005-Apr Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy
25 * <anil.s.keshavamurthy@intel.com> adapted from i386
26 */
27#include <linux/types.h>
28#include <linux/ptrace.h>
29#include <asm/break.h>
30
31#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6)
32
33typedef union cmp_inst {
34 struct {
35 unsigned long long qp : 6;
36 unsigned long long p1 : 6;
37 unsigned long long c : 1;
38 unsigned long long r2 : 7;
39 unsigned long long r3 : 7;
40 unsigned long long p2 : 6;
41 unsigned long long ta : 1;
42 unsigned long long x2 : 2;
43 unsigned long long tb : 1;
44 unsigned long long opcode : 4;
45 unsigned long long reserved : 23;
46 }f;
47 unsigned long long l;
48} cmp_inst_t;
49
50struct kprobe;
51
52typedef struct _bundle {
53 struct {
54 unsigned long long template : 5;
55 unsigned long long slot0 : 41;
56 unsigned long long slot1_p0 : 64-46;
57 } quad0;
58 struct {
59 unsigned long long slot1_p1 : 41 - (64-46);
60 unsigned long long slot2 : 41;
61 } quad1;
62} __attribute__((__aligned__(16))) bundle_t;
63
64#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
65
66#define SLOT0_OPCODE_SHIFT (37)
67#define SLOT1_p1_OPCODE_SHIFT (37 - (64-46))
68#define SLOT2_OPCODE_SHIFT (37)
69
70#define INDIRECT_CALL_OPCODE (1)
71#define IP_RELATIVE_CALL_OPCODE (5)
72#define IP_RELATIVE_BRANCH_OPCODE (4)
73#define IP_RELATIVE_PREDICT_OPCODE (7)
74#define LONG_BRANCH_OPCODE (0xC)
75#define LONG_CALL_OPCODE (0xD)
76
77typedef struct kprobe_opcode {
78 bundle_t bundle;
79} kprobe_opcode_t;
80
81struct fnptr {
82 unsigned long ip;
83 unsigned long gp;
84};
85
86/* Architecture specific copy of original instruction*/
87struct arch_specific_insn {
88 /* copy of the instruction to be emulated */
89 kprobe_opcode_t insn;
90 #define INST_FLAG_FIX_RELATIVE_IP_ADDR 1
91 #define INST_FLAG_FIX_BRANCH_REG 2
92 unsigned long inst_flag;
93 unsigned short target_br_reg;
94};
95
96/* ia64 does not need this */
97static inline void jprobe_return(void)
98{
99}
100
101/* ia64 does not need this */
102static inline void arch_copy_kprobe(struct kprobe *p)
103{
104}
105
106#ifdef CONFIG_KPROBES
107extern int kprobe_exceptions_notify(struct notifier_block *self,
108 unsigned long val, void *data);
109#else /* !CONFIG_KPROBES */
110static inline int kprobe_exceptions_notify(struct notifier_block *self,
111 unsigned long val, void *data)
112{
113 return 0;
114}
115#endif
116#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-ia64/param.h b/include/asm-ia64/param.h
index 6c6b679b7a9e..5e1e0d2d7baf 100644
--- a/include/asm-ia64/param.h
+++ b/include/asm-ia64/param.h
@@ -27,7 +27,7 @@
27 */ 27 */
28# define HZ 32 28# define HZ 32
29# else 29# else
30# define HZ 1024 30# define HZ CONFIG_HZ
31# endif 31# endif
32# define USER_HZ HZ 32# define USER_HZ HZ
33# define CLOCKS_PER_SEC HZ /* frequency at which times() counts */ 33# define CLOCKS_PER_SEC HZ /* frequency at which times() counts */
diff --git a/include/asm-ia64/percpu.h b/include/asm-ia64/percpu.h
index 1e87f19dad56..2b14dee29ce7 100644
--- a/include/asm-ia64/percpu.h
+++ b/include/asm-ia64/percpu.h
@@ -50,7 +50,7 @@ extern void *per_cpu_init(void);
50 50
51#else /* ! SMP */ 51#else /* ! SMP */
52 52
53#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var)) 53#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
54#define __get_cpu_var(var) per_cpu__##var 54#define __get_cpu_var(var) per_cpu__##var
55#define per_cpu_init() (__phys_per_cpu_start) 55#define per_cpu_init() (__phys_per_cpu_start)
56 56
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 8d5b7e77028c..7dc8951708a3 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -25,7 +25,7 @@ struct thread_info {
25 __u32 flags; /* thread_info flags (see TIF_*) */ 25 __u32 flags; /* thread_info flags (see TIF_*) */
26 __u32 cpu; /* current CPU */ 26 __u32 cpu; /* current CPU */
27 mm_segment_t addr_limit; /* user-level address space limit */ 27 mm_segment_t addr_limit; /* user-level address space limit */
28 __s32 preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */ 28 int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
29 struct restart_block restart_block; 29 struct restart_block restart_block;
30 struct { 30 struct {
31 int signo; 31 int signo;
diff --git a/include/asm-m32r/mmzone.h b/include/asm-m32r/mmzone.h
index ebf0228fec42..d58878ec899e 100644
--- a/include/asm-m32r/mmzone.h
+++ b/include/asm-m32r/mmzone.h
@@ -14,7 +14,6 @@ extern struct pglist_data *node_data[];
14#define NODE_DATA(nid) (node_data[nid]) 14#define NODE_DATA(nid) (node_data[nid])
15 15
16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) 16#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
17#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
18#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 17#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
19#define node_end_pfn(nid) \ 18#define node_end_pfn(nid) \
20({ \ 19({ \
@@ -32,7 +31,7 @@ extern struct pglist_data *node_data[];
32({ \ 31({ \
33 unsigned long __pfn = pfn; \ 32 unsigned long __pfn = pfn; \
34 int __node = pfn_to_nid(__pfn); \ 33 int __node = pfn_to_nid(__pfn); \
35 &node_mem_map(__node)[node_localnr(__pfn,__node)]; \ 34 &NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
36}) 35})
37 36
38#define page_to_pfn(pg) \ 37#define page_to_pfn(pg) \
diff --git a/include/asm-m32r/thread_info.h b/include/asm-m32r/thread_info.h
index 9f3a0fcf6e2b..7a6be7727a92 100644
--- a/include/asm-m32r/thread_info.h
+++ b/include/asm-m32r/thread_info.h
@@ -28,7 +28,7 @@ struct thread_info {
28 unsigned long flags; /* low level flags */ 28 unsigned long flags; /* low level flags */
29 unsigned long status; /* thread-synchronous flags */ 29 unsigned long status; /* thread-synchronous flags */
30 __u32 cpu; /* current CPU */ 30 __u32 cpu; /* current CPU */
31 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 31 int preempt_count; /* 0 => preemptable, <0 => BUG */
32 32
33 mm_segment_t addr_limit; /* thread address space: 33 mm_segment_t addr_limit; /* thread address space:
34 0-0xBFFFFFFF for user-thread 34 0-0xBFFFFFFF for user-thread
diff --git a/include/asm-m32r/topology.h b/include/asm-m32r/topology.h
index 299a89d91bde..d607eb32bd7e 100644
--- a/include/asm-m32r/topology.h
+++ b/include/asm-m32r/topology.h
@@ -1,48 +1,6 @@
1/*
2 * linux/include/asm-generic/topology.h
3 *
4 * Written by: Matthew Dobson, IBM Corporation
5 *
6 * Copyright (C) 2002, IBM Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <colpatch@us.ibm.com>
26 */
27#ifndef _ASM_M32R_TOPOLOGY_H 1#ifndef _ASM_M32R_TOPOLOGY_H
28#define _ASM_M32R_TOPOLOGY_H 2#define _ASM_M32R_TOPOLOGY_H
29 3
30/* Other architectures wishing to use this simple topology API should fill 4#include <asm-generic/topology.h>
31 in the below functions as appropriate in their own <asm/topology.h> file. */
32
33#define cpu_to_node(cpu) (0)
34
35#ifndef parent_node
36#define parent_node(node) (0)
37#endif
38#ifndef node_to_cpumask
39#define node_to_cpumask(node) (cpu_online_map)
40#endif
41#ifndef node_to_first_cpu
42#define node_to_first_cpu(node) (0)
43#endif
44#ifndef pcibus_to_cpumask
45#define pcibus_to_cpumask(bus) (cpu_online_map)
46#endif
47 5
48#endif /* _ASM_M32R_TOPOLOGY_H */ 6#endif /* _ASM_M32R_TOPOLOGY_H */
diff --git a/include/asm-m68k/thread_info.h b/include/asm-m68k/thread_info.h
index 5f58939c59db..2aed24f6fd2e 100644
--- a/include/asm-m68k/thread_info.h
+++ b/include/asm-m68k/thread_info.h
@@ -8,7 +8,7 @@
8struct thread_info { 8struct thread_info {
9 struct task_struct *task; /* main task structure */ 9 struct task_struct *task; /* main task structure */
10 struct exec_domain *exec_domain; /* execution domain */ 10 struct exec_domain *exec_domain; /* execution domain */
11 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 11 int preempt_count; /* 0 => preemptable, <0 => BUG */
12 __u32 cpu; /* should always be 0 on m68k */ 12 __u32 cpu; /* should always be 0 on m68k */
13 struct restart_block restart_block; 13 struct restart_block restart_block;
14 14
diff --git a/include/asm-m68knommu/thread_info.h b/include/asm-m68knommu/thread_info.h
index c8153b7c1f5c..7b9a3fa3af5d 100644
--- a/include/asm-m68knommu/thread_info.h
+++ b/include/asm-m68knommu/thread_info.h
@@ -36,7 +36,7 @@ struct thread_info {
36 struct exec_domain *exec_domain; /* execution domain */ 36 struct exec_domain *exec_domain; /* execution domain */
37 unsigned long flags; /* low level flags */ 37 unsigned long flags; /* low level flags */
38 int cpu; /* cpu we're on */ 38 int cpu; /* cpu we're on */
39 int preempt_count; /* 0 => preemptable, <0 => BUG*/ 39 int preempt_count; /* 0 => preemptable, <0 => BUG */
40 struct restart_block restart_block; 40 struct restart_block restart_block;
41}; 41};
42 42
diff --git a/include/asm-mips/compat.h b/include/asm-mips/compat.h
index dce92079e7fc..d78002afb1e1 100644
--- a/include/asm-mips/compat.h
+++ b/include/asm-mips/compat.h
@@ -29,6 +29,7 @@ typedef s32 compat_caddr_t;
29typedef struct { 29typedef struct {
30 s32 val[2]; 30 s32 val[2];
31} compat_fsid_t; 31} compat_fsid_t;
32typedef s32 compat_timer_t;
32 33
33typedef s32 compat_int_t; 34typedef s32 compat_int_t;
34typedef s32 compat_long_t; 35typedef s32 compat_long_t;
diff --git a/include/asm-mips/thread_info.h b/include/asm-mips/thread_info.h
index 768900305e2f..42fcd6f2c206 100644
--- a/include/asm-mips/thread_info.h
+++ b/include/asm-mips/thread_info.h
@@ -27,7 +27,7 @@ struct thread_info {
27 struct exec_domain *exec_domain; /* execution domain */ 27 struct exec_domain *exec_domain; /* execution domain */
28 unsigned long flags; /* low level flags */ 28 unsigned long flags; /* low level flags */
29 __u32 cpu; /* current CPU */ 29 __u32 cpu; /* current CPU */
30 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 30 int preempt_count; /* 0 => preemptable, <0 => BUG */
31 31
32 mm_segment_t addr_limit; /* thread address space: 32 mm_segment_t addr_limit; /* thread address space:
33 0-0xBFFFFFFF for user-thead 33 0-0xBFFFFFFF for user-thead
diff --git a/include/asm-parisc/compat.h b/include/asm-parisc/compat.h
index ca0eac647a05..7630d1ad2391 100644
--- a/include/asm-parisc/compat.h
+++ b/include/asm-parisc/compat.h
@@ -24,7 +24,7 @@ typedef u16 compat_nlink_t;
24typedef u16 compat_ipc_pid_t; 24typedef u16 compat_ipc_pid_t;
25typedef s32 compat_daddr_t; 25typedef s32 compat_daddr_t;
26typedef u32 compat_caddr_t; 26typedef u32 compat_caddr_t;
27typedef u32 compat_timer_t; 27typedef s32 compat_timer_t;
28 28
29typedef s32 compat_int_t; 29typedef s32 compat_int_t;
30typedef s32 compat_long_t; 30typedef s32 compat_long_t;
diff --git a/include/asm-parisc/mmzone.h b/include/asm-parisc/mmzone.h
index 928bf50c4693..595d3dce120a 100644
--- a/include/asm-parisc/mmzone.h
+++ b/include/asm-parisc/mmzone.h
@@ -19,7 +19,6 @@ extern struct node_map_data node_data[];
19 */ 19 */
20#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT) 20#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
21 21
22#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
23#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 22#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
24#define node_end_pfn(nid) \ 23#define node_end_pfn(nid) \
25({ \ 24({ \
@@ -38,7 +37,7 @@ extern struct node_map_data node_data[];
38({ \ 37({ \
39 unsigned long __pfn = (pfn); \ 38 unsigned long __pfn = (pfn); \
40 int __node = pfn_to_nid(__pfn); \ 39 int __node = pfn_to_nid(__pfn); \
41 &node_mem_map(__node)[node_localnr(__pfn,__node)]; \ 40 &NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)]; \
42}) 41})
43 42
44#define page_to_pfn(pg) \ 43#define page_to_pfn(pg) \
diff --git a/include/asm-parisc/thread_info.h b/include/asm-parisc/thread_info.h
index fe9b7f8ae4c6..57bbb76cb6c1 100644
--- a/include/asm-parisc/thread_info.h
+++ b/include/asm-parisc/thread_info.h
@@ -12,7 +12,7 @@ struct thread_info {
12 unsigned long flags; /* thread_info flags (see TIF_*) */ 12 unsigned long flags; /* thread_info flags (see TIF_*) */
13 mm_segment_t addr_limit; /* user-level address space limit */ 13 mm_segment_t addr_limit; /* user-level address space limit */
14 __u32 cpu; /* current CPU */ 14 __u32 cpu; /* current CPU */
15 __s32 preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */ 15 int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
16 struct restart_block restart_block; 16 struct restart_block restart_block;
17}; 17};
18 18
diff --git a/include/asm-ppc/thread_info.h b/include/asm-ppc/thread_info.h
index e3b5284a6f91..27903db42efc 100644
--- a/include/asm-ppc/thread_info.h
+++ b/include/asm-ppc/thread_info.h
@@ -20,7 +20,8 @@ struct thread_info {
20 unsigned long flags; /* low level flags */ 20 unsigned long flags; /* low level flags */
21 unsigned long local_flags; /* non-racy flags */ 21 unsigned long local_flags; /* non-racy flags */
22 int cpu; /* cpu we're on */ 22 int cpu; /* cpu we're on */
23 int preempt_count; 23 int preempt_count; /* 0 => preemptable,
24 <0 => BUG */
24 struct restart_block restart_block; 25 struct restart_block restart_block;
25}; 26};
26 27
diff --git a/include/asm-ppc64/compat.h b/include/asm-ppc64/compat.h
index 09c28d28ce6c..12414f5fc666 100644
--- a/include/asm-ppc64/compat.h
+++ b/include/asm-ppc64/compat.h
@@ -26,6 +26,7 @@ typedef s32 compat_daddr_t;
26typedef u32 compat_caddr_t; 26typedef u32 compat_caddr_t;
27typedef __kernel_fsid_t compat_fsid_t; 27typedef __kernel_fsid_t compat_fsid_t;
28typedef s32 compat_key_t; 28typedef s32 compat_key_t;
29typedef s32 compat_timer_t;
29 30
30typedef s32 compat_int_t; 31typedef s32 compat_int_t;
31typedef s32 compat_long_t; 32typedef s32 compat_long_t;
diff --git a/include/asm-ppc64/mmzone.h b/include/asm-ppc64/mmzone.h
index 0619a41a3c9d..ed473f4b0152 100644
--- a/include/asm-ppc64/mmzone.h
+++ b/include/asm-ppc64/mmzone.h
@@ -10,9 +10,20 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <asm/smp.h> 11#include <asm/smp.h>
12 12
13#ifdef CONFIG_DISCONTIGMEM 13/* generic non-linear memory support:
14 *
15 * 1) we will not split memory into more chunks than will fit into the
16 * flags field of the struct page
17 */
18
19
20#ifdef CONFIG_NEED_MULTIPLE_NODES
14 21
15extern struct pglist_data *node_data[]; 22extern struct pglist_data *node_data[];
23/*
24 * Return a pointer to the node data for node n.
25 */
26#define NODE_DATA(nid) (node_data[nid])
16 27
17/* 28/*
18 * Following are specific to this numa platform. 29 * Following are specific to this numa platform.
@@ -47,36 +58,32 @@ static inline int pa_to_nid(unsigned long pa)
47 return nid; 58 return nid;
48} 59}
49 60
50#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
51
52/*
53 * Return a pointer to the node data for node n.
54 */
55#define NODE_DATA(nid) (node_data[nid])
56
57#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) 61#define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
58 62
59/* 63/*
60 * Following are macros that each numa implmentation must define. 64 * Following are macros that each numa implmentation must define.
61 */ 65 */
62 66
63/*
64 * Given a kernel address, find the home node of the underlying memory.
65 */
66#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
67
68#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
69#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 67#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
70#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) 68#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
71 69
72#define local_mapnr(kvaddr) \ 70#define local_mapnr(kvaddr) \
73 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) 71 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr))
74 72
73#ifdef CONFIG_DISCONTIGMEM
74
75/*
76 * Given a kernel address, find the home node of the underlying memory.
77 */
78#define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
79
80#define pfn_to_nid(pfn) pa_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
81
75/* Written this way to avoid evaluating arguments twice */ 82/* Written this way to avoid evaluating arguments twice */
76#define discontigmem_pfn_to_page(pfn) \ 83#define discontigmem_pfn_to_page(pfn) \
77({ \ 84({ \
78 unsigned long __tmp = pfn; \ 85 unsigned long __tmp = pfn; \
79 (node_mem_map(pfn_to_nid(__tmp)) + \ 86 (NODE_DATA(pfn_to_nid(__tmp))->node_mem_map + \
80 node_localnr(__tmp, pfn_to_nid(__tmp))); \ 87 node_localnr(__tmp, pfn_to_nid(__tmp))); \
81}) 88})
82 89
@@ -91,4 +98,11 @@ static inline int pa_to_nid(unsigned long pa)
91#define discontigmem_pfn_valid(pfn) ((pfn) < num_physpages) 98#define discontigmem_pfn_valid(pfn) ((pfn) < num_physpages)
92 99
93#endif /* CONFIG_DISCONTIGMEM */ 100#endif /* CONFIG_DISCONTIGMEM */
101
102#endif /* CONFIG_NEED_MULTIPLE_NODES */
103
104#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
105#define early_pfn_to_nid(pfn) pa_to_nid(((unsigned long)pfn) << PAGE_SHIFT)
106#endif
107
94#endif /* _ASM_MMZONE_H_ */ 108#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h
index 257d87eb7c34..a5893a305a09 100644
--- a/include/asm-ppc64/page.h
+++ b/include/asm-ppc64/page.h
@@ -217,7 +217,8 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */
217#define page_to_pfn(page) discontigmem_page_to_pfn(page) 217#define page_to_pfn(page) discontigmem_page_to_pfn(page)
218#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn) 218#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
219#define pfn_valid(pfn) discontigmem_pfn_valid(pfn) 219#define pfn_valid(pfn) discontigmem_pfn_valid(pfn)
220#else 220#endif
221#ifdef CONFIG_FLATMEM
221#define pfn_to_page(pfn) (mem_map + (pfn)) 222#define pfn_to_page(pfn) (mem_map + (pfn))
222#define page_to_pfn(page) ((unsigned long)((page) - mem_map)) 223#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
223#define pfn_valid(pfn) ((pfn) < max_mapnr) 224#define pfn_valid(pfn) ((pfn) < max_mapnr)
diff --git a/include/asm-ppc64/ppc32.h b/include/asm-ppc64/ppc32.h
index 1d0404897550..6b44a8caf395 100644
--- a/include/asm-ppc64/ppc32.h
+++ b/include/asm-ppc64/ppc32.h
@@ -32,7 +32,7 @@ typedef struct compat_siginfo {
32 32
33 /* POSIX.1b timers */ 33 /* POSIX.1b timers */
34 struct { 34 struct {
35 timer_t _tid; /* timer id */ 35 compat_timer_t _tid; /* timer id */
36 int _overrun; /* overrun count */ 36 int _overrun; /* overrun count */
37 compat_sigval_t _sigval; /* same as below */ 37 compat_sigval_t _sigval; /* same as below */
38 int _sys_private; /* not to be passed to user */ 38 int _sys_private; /* not to be passed to user */
diff --git a/include/asm-ppc64/sparsemem.h b/include/asm-ppc64/sparsemem.h
new file mode 100644
index 000000000000..c5bd47e57f17
--- /dev/null
+++ b/include/asm-ppc64/sparsemem.h
@@ -0,0 +1,16 @@
1#ifndef _ASM_PPC64_SPARSEMEM_H
2#define _ASM_PPC64_SPARSEMEM_H 1
3
4#ifdef CONFIG_SPARSEMEM
5/*
6 * SECTION_SIZE_BITS 2^N: how big each section will be
7 * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
8 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
9 */
10#define SECTION_SIZE_BITS 24
11#define MAX_PHYSADDR_BITS 38
12#define MAX_PHYSMEM_BITS 36
13
14#endif /* CONFIG_SPARSEMEM */
15
16#endif /* _ASM_PPC64_SPARSEMEM_H */
diff --git a/include/asm-ppc64/thread_info.h b/include/asm-ppc64/thread_info.h
index 48b7900e90ec..0494df6fca74 100644
--- a/include/asm-ppc64/thread_info.h
+++ b/include/asm-ppc64/thread_info.h
@@ -24,7 +24,7 @@ struct thread_info {
24 struct task_struct *task; /* main task structure */ 24 struct task_struct *task; /* main task structure */
25 struct exec_domain *exec_domain; /* execution domain */ 25 struct exec_domain *exec_domain; /* execution domain */
26 int cpu; /* cpu we're on */ 26 int cpu; /* cpu we're on */
27 int preempt_count; 27 int preempt_count; /* 0 => preemptable, <0 => BUG */
28 struct restart_block restart_block; 28 struct restart_block restart_block;
29 /* set by force_successful_syscall_return */ 29 /* set by force_successful_syscall_return */
30 unsigned char syscall_noerror; 30 unsigned char syscall_noerror;
diff --git a/include/asm-ppc64/topology.h b/include/asm-ppc64/topology.h
index d58d9dd79998..fcdcfd26a26b 100644
--- a/include/asm-ppc64/topology.h
+++ b/include/asm-ppc64/topology.h
@@ -59,10 +59,8 @@ static inline int node_to_first_cpu(int node)
59 .nr_balance_failed = 0, \ 59 .nr_balance_failed = 0, \
60} 60}
61 61
62#else /* !CONFIG_NUMA */ 62#endif /* CONFIG_NUMA */
63 63
64#include <asm-generic/topology.h> 64#include <asm-generic/topology.h>
65 65
66#endif /* CONFIG_NUMA */
67
68#endif /* _ASM_PPC64_TOPOLOGY_H */ 66#endif /* _ASM_PPC64_TOPOLOGY_H */
diff --git a/include/asm-s390/thread_info.h b/include/asm-s390/thread_info.h
index aade85c53a63..fe101d41e849 100644
--- a/include/asm-s390/thread_info.h
+++ b/include/asm-s390/thread_info.h
@@ -50,7 +50,7 @@ struct thread_info {
50 struct exec_domain *exec_domain; /* execution domain */ 50 struct exec_domain *exec_domain; /* execution domain */
51 unsigned long flags; /* low level flags */ 51 unsigned long flags; /* low level flags */
52 unsigned int cpu; /* current CPU */ 52 unsigned int cpu; /* current CPU */
53 unsigned int preempt_count; /* 0 => preemptable */ 53 int preempt_count; /* 0 => preemptable, <0 => BUG */
54 struct restart_block restart_block; 54 struct restart_block restart_block;
55}; 55};
56 56
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 4bbbd9f3c37e..46080cefaff8 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -20,7 +20,7 @@ struct thread_info {
20 struct exec_domain *exec_domain; /* execution domain */ 20 struct exec_domain *exec_domain; /* execution domain */
21 __u32 flags; /* low level flags */ 21 __u32 flags; /* low level flags */
22 __u32 cpu; 22 __u32 cpu;
23 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 23 int preempt_count; /* 0 => preemptable, <0 => BUG */
24 struct restart_block restart_block; 24 struct restart_block restart_block;
25 __u8 supervisor_stack[0]; 25 __u8 supervisor_stack[0];
26}; 26};
diff --git a/include/asm-sh64/thread_info.h b/include/asm-sh64/thread_info.h
index 8a32d6bd0b79..10f024c6a2e3 100644
--- a/include/asm-sh64/thread_info.h
+++ b/include/asm-sh64/thread_info.h
@@ -22,7 +22,7 @@ struct thread_info {
22 struct exec_domain *exec_domain; /* execution domain */ 22 struct exec_domain *exec_domain; /* execution domain */
23 unsigned long flags; /* low level flags */ 23 unsigned long flags; /* low level flags */
24 /* Put the 4 32-bit fields together to make asm offsetting easier. */ 24 /* Put the 4 32-bit fields together to make asm offsetting easier. */
25 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 25 int preempt_count; /* 0 => preemptable, <0 => BUG */
26 __u16 cpu; 26 __u16 cpu;
27 27
28 mm_segment_t addr_limit; 28 mm_segment_t addr_limit;
diff --git a/include/asm-sparc/thread_info.h b/include/asm-sparc/thread_info.h
index 104f03c55416..ff6ccb3d24c6 100644
--- a/include/asm-sparc/thread_info.h
+++ b/include/asm-sparc/thread_info.h
@@ -30,9 +30,9 @@ struct thread_info {
30 struct task_struct *task; /* main task structure */ 30 struct task_struct *task; /* main task structure */
31 struct exec_domain *exec_domain; /* execution domain */ 31 struct exec_domain *exec_domain; /* execution domain */
32 unsigned long flags; /* low level flags */ 32 unsigned long flags; /* low level flags */
33
34 int cpu; /* cpu we're on */ 33 int cpu; /* cpu we're on */
35 int preempt_count; 34 int preempt_count; /* 0 => preemptable,
35 <0 => BUG */
36 int softirq_count; 36 int softirq_count;
37 int hardirq_count; 37 int hardirq_count;
38 38
diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
index 22f58055b8ab..b59122dd176d 100644
--- a/include/asm-sparc64/compat.h
+++ b/include/asm-sparc64/compat.h
@@ -25,6 +25,7 @@ typedef s32 compat_daddr_t;
25typedef u32 compat_caddr_t; 25typedef u32 compat_caddr_t;
26typedef __kernel_fsid_t compat_fsid_t; 26typedef __kernel_fsid_t compat_fsid_t;
27typedef s32 compat_key_t; 27typedef s32 compat_key_t;
28typedef s32 compat_timer_t;
28 29
29typedef s32 compat_int_t; 30typedef s32 compat_int_t;
30typedef s32 compat_long_t; 31typedef s32 compat_long_t;
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
index 517caaba1c87..0cd652956929 100644
--- a/include/asm-sparc64/thread_info.h
+++ b/include/asm-sparc64/thread_info.h
@@ -46,7 +46,7 @@ struct thread_info {
46 unsigned long fault_address; 46 unsigned long fault_address;
47 struct pt_regs *kregs; 47 struct pt_regs *kregs;
48 struct exec_domain *exec_domain; 48 struct exec_domain *exec_domain;
49 int preempt_count; 49 int preempt_count; /* 0 => preemptable, <0 => BUG */
50 int __pad; 50 int __pad;
51 51
52 unsigned long *utraps; 52 unsigned long *utraps;
diff --git a/include/asm-um/thread_info.h b/include/asm-um/thread_info.h
index 1feaaf148ef1..97267f059ef5 100644
--- a/include/asm-um/thread_info.h
+++ b/include/asm-um/thread_info.h
@@ -17,7 +17,7 @@ struct thread_info {
17 struct exec_domain *exec_domain; /* execution domain */ 17 struct exec_domain *exec_domain; /* execution domain */
18 unsigned long flags; /* low level flags */ 18 unsigned long flags; /* low level flags */
19 __u32 cpu; /* current CPU */ 19 __u32 cpu; /* current CPU */
20 __s32 preempt_count; /* 0 => preemptable, 20 int preempt_count; /* 0 => preemptable,
21 <0 => BUG */ 21 <0 => BUG */
22 mm_segment_t addr_limit; /* thread address space: 22 mm_segment_t addr_limit; /* thread address space:
23 0-0xBFFFFFFF for user 23 0-0xBFFFFFFF for user
diff --git a/include/asm-v850/thread_info.h b/include/asm-v850/thread_info.h
index e2ef44593752..e4cfad94a553 100644
--- a/include/asm-v850/thread_info.h
+++ b/include/asm-v850/thread_info.h
@@ -30,7 +30,8 @@ struct thread_info {
30 struct exec_domain *exec_domain; /* execution domain */ 30 struct exec_domain *exec_domain; /* execution domain */
31 unsigned long flags; /* low level flags */ 31 unsigned long flags; /* low level flags */
32 int cpu; /* cpu we're on */ 32 int cpu; /* cpu we're on */
33 int preempt_count; 33 int preempt_count; /* 0 => preemptable,
34 <0 => BUG */
34 struct restart_block restart_block; 35 struct restart_block restart_block;
35}; 36};
36 37
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
index 5dd7727c756b..a31bb99be53f 100644
--- a/include/asm-x86_64/bitops.h
+++ b/include/asm-x86_64/bitops.h
@@ -411,8 +411,6 @@ static __inline__ int ffs(int x)
411/* find last set bit */ 411/* find last set bit */
412#define fls(x) generic_fls(x) 412#define fls(x) generic_fls(x)
413 413
414#define ARCH_HAS_ATOMIC_UNSIGNED 1
415
416#endif /* __KERNEL__ */ 414#endif /* __KERNEL__ */
417 415
418#endif /* _X86_64_BITOPS_H */ 416#endif /* _X86_64_BITOPS_H */
diff --git a/include/asm-x86_64/ia32.h b/include/asm-x86_64/ia32.h
index c0a7717923ed..6efa00fe4e7b 100644
--- a/include/asm-x86_64/ia32.h
+++ b/include/asm-x86_64/ia32.h
@@ -94,7 +94,7 @@ typedef struct compat_siginfo{
94 94
95 /* POSIX.1b timers */ 95 /* POSIX.1b timers */
96 struct { 96 struct {
97 int _tid; /* timer id */ 97 compat_timer_t _tid; /* timer id */
98 int _overrun; /* overrun count */ 98 int _overrun; /* overrun count */
99 compat_sigval_t _sigval; /* same as below */ 99 compat_sigval_t _sigval; /* same as below */
100 int _sys_private; /* not to be passed to user */ 100 int _sys_private; /* not to be passed to user */
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 94202703fae2..37fc3f149a5a 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -124,12 +124,7 @@ extern inline void * phys_to_virt(unsigned long address)
124/* 124/*
125 * Change "struct page" to physical address. 125 * Change "struct page" to physical address.
126 */ 126 */
127#ifdef CONFIG_DISCONTIGMEM
128#include <asm/mmzone.h>
129#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 127#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
130#else
131#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
132#endif
133 128
134#include <asm-generic/iomap.h> 129#include <asm-generic/iomap.h>
135 130
diff --git a/include/asm-x86_64/kprobes.h b/include/asm-x86_64/kprobes.h
index bfea52d516f8..6d6d883fdf6d 100644
--- a/include/asm-x86_64/kprobes.h
+++ b/include/asm-x86_64/kprobes.h
@@ -38,6 +38,9 @@ typedef u8 kprobe_opcode_t;
38 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) 38 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
39 39
40#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry 40#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
41#define ARCH_SUPPORTS_KRETPROBES
42
43void kretprobe_trampoline(void);
41 44
42/* Architecture specific copy of original instruction*/ 45/* Architecture specific copy of original instruction*/
43struct arch_specific_insn { 46struct arch_specific_insn {
diff --git a/include/asm-x86_64/mmzone.h b/include/asm-x86_64/mmzone.h
index d95b7c240831..768413751b34 100644
--- a/include/asm-x86_64/mmzone.h
+++ b/include/asm-x86_64/mmzone.h
@@ -6,7 +6,7 @@
6 6
7#include <linux/config.h> 7#include <linux/config.h>
8 8
9#ifdef CONFIG_DISCONTIGMEM 9#ifdef CONFIG_NUMA
10 10
11#define VIRTUAL_BUG_ON(x) 11#define VIRTUAL_BUG_ON(x)
12 12
@@ -30,27 +30,23 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
30 return nid; 30 return nid;
31} 31}
32 32
33#define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
34
35#define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
36#define NODE_DATA(nid) (node_data[nid]) 33#define NODE_DATA(nid) (node_data[nid])
37 34
38#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
39
40#define node_mem_map(nid) (NODE_DATA(nid)->node_mem_map)
41#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 35#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
42#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ 36#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
43 NODE_DATA(nid)->node_spanned_pages) 37 NODE_DATA(nid)->node_spanned_pages)
44 38
45#define local_mapnr(kvaddr) \ 39#ifdef CONFIG_DISCONTIGMEM
46 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) ) 40
41#define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
42#define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
47 43
48/* AK: this currently doesn't deal with invalid addresses. We'll see 44/* AK: this currently doesn't deal with invalid addresses. We'll see
49 if the 2.5 kernel doesn't pass them 45 if the 2.5 kernel doesn't pass them
50 (2.4 used to). */ 46 (2.4 used to). */
51#define pfn_to_page(pfn) ({ \ 47#define pfn_to_page(pfn) ({ \
52 int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT); \ 48 int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT); \
53 ((pfn) - node_start_pfn(nid)) + node_mem_map(nid); \ 49 ((pfn) - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map; \
54}) 50})
55 51
56#define page_to_pfn(page) \ 52#define page_to_pfn(page) \
@@ -60,4 +56,8 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
60 ({ u8 nid__ = pfn_to_nid(pfn); \ 56 ({ u8 nid__ = pfn_to_nid(pfn); \
61 nid__ != 0xff && (pfn) >= node_start_pfn(nid__) && (pfn) <= node_end_pfn(nid__); })) 57 nid__ != 0xff && (pfn) >= node_start_pfn(nid__) && (pfn) <= node_end_pfn(nid__); }))
62#endif 58#endif
59
60#define local_mapnr(kvaddr) \
61 ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) )
62#endif
63#endif 63#endif
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 513e52c71821..bc700232728d 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -57,11 +57,6 @@
57 (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ 57 (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
58} while(0) 58} while(0)
59 59
60#define rdpmc(counter,low,high) \
61 __asm__ __volatile__("rdpmc" \
62 : "=a" (low), "=d" (high) \
63 : "c" (counter))
64
65#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) 60#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
66 61
67#define rdpmc(counter,low,high) \ 62#define rdpmc(counter,low,high) \
diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
index 9ce338c3a71e..60130f4ca986 100644
--- a/include/asm-x86_64/page.h
+++ b/include/asm-x86_64/page.h
@@ -119,7 +119,9 @@ extern __inline__ int get_order(unsigned long size)
119 __pa(v); }) 119 __pa(v); })
120 120
121#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 121#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
122#ifndef CONFIG_DISCONTIGMEM 122#define __boot_va(x) __va(x)
123#define __boot_pa(x) __pa(x)
124#ifdef CONFIG_FLATMEM
123#define pfn_to_page(pfn) (mem_map + (pfn)) 125#define pfn_to_page(pfn) (mem_map + (pfn))
124#define page_to_pfn(page) ((unsigned long)((page) - mem_map)) 126#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
125#define pfn_valid(pfn) ((pfn) < max_mapnr) 127#define pfn_valid(pfn) ((pfn) < max_mapnr)
diff --git a/include/asm-x86_64/param.h b/include/asm-x86_64/param.h
index b707f0568c9e..40b11937180d 100644
--- a/include/asm-x86_64/param.h
+++ b/include/asm-x86_64/param.h
@@ -1,9 +1,11 @@
1#include <linux/config.h>
2
1#ifndef _ASMx86_64_PARAM_H 3#ifndef _ASMx86_64_PARAM_H
2#define _ASMx86_64_PARAM_H 4#define _ASMx86_64_PARAM_H
3 5
4#ifdef __KERNEL__ 6#ifdef __KERNEL__
5# define HZ 1000 /* Internal kernel timer frequency */ 7# define HZ CONFIG_HZ /* Internal kernel timer frequency */
6# define USER_HZ 100 /* .. some user interfaces are in "ticks */ 8# define USER_HZ 100 /* .. some user interfaces are in "ticks */
7#define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 9#define CLOCKS_PER_SEC (USER_HZ) /* like times() */
8#endif 10#endif
9 11
diff --git a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
index 415d73f3c8ef..9c71855736fb 100644
--- a/include/asm-x86_64/percpu.h
+++ b/include/asm-x86_64/percpu.h
@@ -39,7 +39,7 @@ extern void setup_per_cpu_areas(void);
39#define DEFINE_PER_CPU(type, name) \ 39#define DEFINE_PER_CPU(type, name) \
40 __typeof__(type) per_cpu__##name 40 __typeof__(type) per_cpu__##name
41 41
42#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var)) 42#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
43#define __get_cpu_var(var) per_cpu__##var 43#define __get_cpu_var(var) per_cpu__##var
44 44
45#endif /* SMP */ 45#endif /* SMP */
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index 8b55f139968f..106f666517bb 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -280,6 +280,14 @@ struct thread_struct {
280 set_fs(USER_DS); \ 280 set_fs(USER_DS); \
281} while(0) 281} while(0)
282 282
283#define get_debugreg(var, register) \
284 __asm__("movq %%db" #register ", %0" \
285 :"=r" (var))
286#define set_debugreg(value, register) \
287 __asm__("movq %0,%%db" #register \
288 : /* no output */ \
289 :"r" (value))
290
283struct task_struct; 291struct task_struct;
284struct mm_struct; 292struct mm_struct;
285 293
diff --git a/include/asm-x86_64/ptrace.h b/include/asm-x86_64/ptrace.h
index 5bbc8d3141c8..ca6f15ff61d4 100644
--- a/include/asm-x86_64/ptrace.h
+++ b/include/asm-x86_64/ptrace.h
@@ -82,6 +82,7 @@ struct pt_regs {
82 82
83#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 83#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
84#define user_mode(regs) (!!((regs)->cs & 3)) 84#define user_mode(regs) (!!((regs)->cs & 3))
85#define user_mode_vm(regs) user_mode(regs)
85#define instruction_pointer(regs) ((regs)->rip) 86#define instruction_pointer(regs) ((regs)->rip)
86extern unsigned long profile_pc(struct pt_regs *regs); 87extern unsigned long profile_pc(struct pt_regs *regs);
87void signal_fault(struct pt_regs *regs, void __user *frame, char *where); 88void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
diff --git a/include/asm-x86_64/sparsemem.h b/include/asm-x86_64/sparsemem.h
new file mode 100644
index 000000000000..dabb16714a71
--- /dev/null
+++ b/include/asm-x86_64/sparsemem.h
@@ -0,0 +1,26 @@
1#ifndef _ASM_X86_64_SPARSEMEM_H
2#define _ASM_X86_64_SPARSEMEM_H 1
3
4#ifdef CONFIG_SPARSEMEM
5
6/*
7 * generic non-linear memory support:
8 *
9 * 1) we will not split memory into more chunks than will fit into the flags
10 * field of the struct page
11 *
12 * SECTION_SIZE_BITS 2^n: size of each section
13 * MAX_PHYSADDR_BITS 2^n: max size of physical address space
14 * MAX_PHYSMEM_BITS 2^n: how much memory we can have in that space
15 *
16 */
17
18#define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */
19#define MAX_PHYSADDR_BITS 40
20#define MAX_PHYSMEM_BITS 40
21
22extern int early_pfn_to_nid(unsigned long pfn);
23
24#endif /* CONFIG_SPARSEMEM */
25
26#endif /* _ASM_X86_64_SPARSEMEM_H */
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index f4b3b249639c..08eb6e4f3737 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -29,7 +29,7 @@ struct thread_info {
29 __u32 flags; /* low level flags */ 29 __u32 flags; /* low level flags */
30 __u32 status; /* thread synchronous flags */ 30 __u32 status; /* thread synchronous flags */
31 __u32 cpu; /* current CPU */ 31 __u32 cpu; /* current CPU */
32 int preempt_count; 32 int preempt_count; /* 0 => preemptable, <0 => BUG */
33 33
34 mm_segment_t addr_limit; 34 mm_segment_t addr_limit;
35 struct restart_block restart_block; 35 struct restart_block restart_block;
diff --git a/include/asm-x86_64/timex.h b/include/asm-x86_64/timex.h
index 34f31a18f90b..24ecf6a637cb 100644
--- a/include/asm-x86_64/timex.h
+++ b/include/asm-x86_64/timex.h
@@ -26,6 +26,9 @@ static inline cycles_t get_cycles (void)
26 26
27extern unsigned int cpu_khz; 27extern unsigned int cpu_khz;
28 28
29extern int read_current_timer(unsigned long *timer_value);
30#define ARCH_HAS_READ_CURRENT_TIMER 1
31
29extern struct vxtime_data vxtime; 32extern struct vxtime_data vxtime;
30 33
31#endif 34#endif
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
index 67f24e0ea819..8f77e9f6bc23 100644
--- a/include/asm-x86_64/topology.h
+++ b/include/asm-x86_64/topology.h
@@ -3,7 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_DISCONTIGMEM 6#ifdef CONFIG_NUMA
7 7
8#include <asm/mpspec.h> 8#include <asm/mpspec.h>
9#include <asm/bitops.h> 9#include <asm/bitops.h>
@@ -13,8 +13,8 @@
13extern cpumask_t cpu_online_map; 13extern cpumask_t cpu_online_map;
14 14
15extern unsigned char cpu_to_node[]; 15extern unsigned char cpu_to_node[];
16extern unsigned char pci_bus_to_node[];
16extern cpumask_t node_to_cpumask[]; 17extern cpumask_t node_to_cpumask[];
17extern cpumask_t pci_bus_to_cpumask[];
18 18
19#ifdef CONFIG_ACPI_NUMA 19#ifdef CONFIG_ACPI_NUMA
20extern int __node_distance(int, int); 20extern int __node_distance(int, int);
@@ -26,18 +26,9 @@ extern int __node_distance(int, int);
26#define parent_node(node) (node) 26#define parent_node(node) (node)
27#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node])) 27#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node]))
28#define node_to_cpumask(node) (node_to_cpumask[node]) 28#define node_to_cpumask(node) (node_to_cpumask[node])
29#define pcibus_to_node(bus) pci_bus_to_node[(bus)->number]
30#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus));
29 31
30static inline cpumask_t __pcibus_to_cpumask(int bus)
31{
32 cpumask_t busmask = pci_bus_to_cpumask[bus];
33 cpumask_t online = cpu_online_map;
34 cpumask_t res;
35 cpus_and(res, busmask, online);
36 return res;
37}
38#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number)
39
40#ifdef CONFIG_NUMA
41/* sched_domains SD_NODE_INIT for x86_64 machines */ 32/* sched_domains SD_NODE_INIT for x86_64 machines */
42#define SD_NODE_INIT (struct sched_domain) { \ 33#define SD_NODE_INIT (struct sched_domain) { \
43 .span = CPU_MASK_NONE, \ 34 .span = CPU_MASK_NONE, \
@@ -59,7 +50,6 @@ static inline cpumask_t __pcibus_to_cpumask(int bus)
59 .balance_interval = 1, \ 50 .balance_interval = 1, \
60 .nr_balance_failed = 0, \ 51 .nr_balance_failed = 0, \
61} 52}
62#endif
63 53
64#endif 54#endif
65 55
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 7e736e201c46..c1e82c514443 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -69,6 +69,11 @@ extern void remove_arg_zero(struct linux_binprm *);
69extern int search_binary_handler(struct linux_binprm *,struct pt_regs *); 69extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
70extern int flush_old_exec(struct linux_binprm * bprm); 70extern int flush_old_exec(struct linux_binprm * bprm);
71 71
72extern int suid_dumpable;
73#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
74#define SUID_DUMP_USER 1 /* Dump as user of process */
75#define SUID_DUMP_ROOT 2 /* Dump as root */
76
72/* Stack area protections */ 77/* Stack area protections */
73#define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */ 78#define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
74#define EXSTACK_DISABLE_X 1 /* Disable executable stacks */ 79#define EXSTACK_DISABLE_X 1 /* Disable executable stacks */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4a99b76c5a33..60272141ff19 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -285,16 +285,12 @@ enum blk_queue_state {
285 Queue_up, 285 Queue_up,
286}; 286};
287 287
288#define BLK_TAGS_PER_LONG (sizeof(unsigned long) * 8)
289#define BLK_TAGS_MASK (BLK_TAGS_PER_LONG - 1)
290
291struct blk_queue_tag { 288struct blk_queue_tag {
292 struct request **tag_index; /* map of busy tags */ 289 struct request **tag_index; /* map of busy tags */
293 unsigned long *tag_map; /* bit map of free/busy tags */ 290 unsigned long *tag_map; /* bit map of free/busy tags */
294 struct list_head busy_list; /* fifo list of busy tags */ 291 struct list_head busy_list; /* fifo list of busy tags */
295 int busy; /* current depth */ 292 int busy; /* current depth */
296 int max_depth; /* what we will send to device */ 293 int max_depth; /* what we will send to device */
297 int real_max_depth; /* what the array can hold */
298 atomic_t refcnt; /* map can be shared */ 294 atomic_t refcnt; /* map can be shared */
299}; 295};
300 296
@@ -396,6 +392,7 @@ struct request_queue
396 */ 392 */
397 unsigned int sg_timeout; 393 unsigned int sg_timeout;
398 unsigned int sg_reserved_size; 394 unsigned int sg_reserved_size;
395 int node;
399 396
400 struct list_head drain_list; 397 struct list_head drain_list;
401 398
@@ -615,6 +612,8 @@ static inline void blkdev_dequeue_request(struct request *req)
615/* 612/*
616 * Access functions for manipulating queue properties 613 * Access functions for manipulating queue properties
617 */ 614 */
615extern request_queue_t *blk_init_queue_node(request_fn_proc *rfn,
616 spinlock_t *lock, int node_id);
618extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); 617extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *);
619extern void blk_cleanup_queue(request_queue_t *); 618extern void blk_cleanup_queue(request_queue_t *);
620extern void blk_queue_make_request(request_queue_t *, make_request_fn *); 619extern void blk_queue_make_request(request_queue_t *, make_request_fn *);
@@ -646,7 +645,8 @@ extern void blk_wait_queue_drained(request_queue_t *, int);
646extern void blk_finish_queue_drain(request_queue_t *); 645extern void blk_finish_queue_drain(request_queue_t *);
647 646
648int blk_get_queue(request_queue_t *); 647int blk_get_queue(request_queue_t *);
649request_queue_t *blk_alloc_queue(int); 648request_queue_t *blk_alloc_queue(int gfp_mask);
649request_queue_t *blk_alloc_queue_node(int,int);
650#define blk_put_queue(q) blk_cleanup_queue((q)) 650#define blk_put_queue(q) blk_cleanup_queue((q))
651 651
652/* 652/*
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 0dd8ca1a3d5a..500f451ce0c0 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -67,6 +67,15 @@ extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size,
67 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0) 67 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
68#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ 68#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
69 69
70#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
71extern void *alloc_remap(int nid, unsigned long size);
72#else
73static inline void *alloc_remap(int nid, unsigned long size)
74{
75 return NULL;
76}
77#endif
78
70extern unsigned long __initdata nr_kernel_pages; 79extern unsigned long __initdata nr_kernel_pages;
71extern unsigned long __initdata nr_all_pages; 80extern unsigned long __initdata nr_all_pages;
72 81
diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h
index 704fb76b6334..8a7c82151de9 100644
--- a/include/linux/fcntl.h
+++ b/include/linux/fcntl.h
@@ -25,6 +25,10 @@
25 25
26#ifdef __KERNEL__ 26#ifdef __KERNEL__
27 27
28#ifndef force_o_largefile
29#define force_o_largefile() (BITS_PER_LONG != 32)
30#endif
31
28#if BITS_PER_LONG == 32 32#if BITS_PER_LONG == 32
29#define IS_GETLK32(cmd) ((cmd) == F_GETLK) 33#define IS_GETLK32(cmd) ((cmd) == F_GETLK)
30#define IS_SETLK32(cmd) ((cmd) == F_SETLK) 34#define IS_SETLK32(cmd) ((cmd) == F_SETLK)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e5a8db00df29..517bf4966bf5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -581,7 +581,6 @@ struct file {
581 atomic_t f_count; 581 atomic_t f_count;
582 unsigned int f_flags; 582 unsigned int f_flags;
583 mode_t f_mode; 583 mode_t f_mode;
584 int f_error;
585 loff_t f_pos; 584 loff_t f_pos;
586 struct fown_struct f_owner; 585 struct fown_struct f_owner;
587 unsigned int f_uid, f_gid; 586 unsigned int f_uid, f_gid;
@@ -884,6 +883,7 @@ struct block_device_operations {
884 int (*open) (struct inode *, struct file *); 883 int (*open) (struct inode *, struct file *);
885 int (*release) (struct inode *, struct file *); 884 int (*release) (struct inode *, struct file *);
886 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long); 885 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
886 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
887 long (*compat_ioctl) (struct file *, unsigned, unsigned long); 887 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
888 int (*media_changed) (struct gendisk *); 888 int (*media_changed) (struct gendisk *);
889 int (*revalidate_disk) (struct gendisk *); 889 int (*revalidate_disk) (struct gendisk *);
@@ -1025,6 +1025,7 @@ struct super_operations {
1025#define I_FREEING 16 1025#define I_FREEING 16
1026#define I_CLEAR 32 1026#define I_CLEAR 32
1027#define I_NEW 64 1027#define I_NEW 64
1028#define I_WILL_FREE 128
1028 1029
1029#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1030#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1030 1031
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 47dedaf971d6..01796c41c951 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -224,7 +224,7 @@ static inline void free_disk_stats(struct gendisk *disk)
224extern void disk_round_stats(struct gendisk *disk); 224extern void disk_round_stats(struct gendisk *disk);
225 225
226/* drivers/block/genhd.c */ 226/* drivers/block/genhd.c */
227extern int get_blkdev_list(char *); 227extern int get_blkdev_list(char *, int);
228extern void add_disk(struct gendisk *disk); 228extern void add_disk(struct gendisk *disk);
229extern void del_gendisk(struct gendisk *gp); 229extern void del_gendisk(struct gendisk *gp);
230extern void unlink_gendisk(struct gendisk *gp); 230extern void unlink_gendisk(struct gendisk *gp);
@@ -403,6 +403,7 @@ extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
403extern void add_partition(struct gendisk *, int, sector_t, sector_t); 403extern void add_partition(struct gendisk *, int, sector_t, sector_t);
404extern void delete_partition(struct gendisk *, int); 404extern void delete_partition(struct gendisk *, int);
405 405
406extern struct gendisk *alloc_disk_node(int minors, int node_id);
406extern struct gendisk *alloc_disk(int minors); 407extern struct gendisk *alloc_disk(int minors);
407extern struct kobject *get_disk(struct gendisk *disk); 408extern struct kobject *get_disk(struct gendisk *disk);
408extern void put_disk(struct gendisk *disk); 409extern void put_disk(struct gendisk *disk);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 336d6e509f59..92129078d4f3 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -917,7 +917,7 @@ typedef struct hwif_s {
917 unsigned dma; 917 unsigned dma;
918 918
919 void (*led_act)(void *data, int rw); 919 void (*led_act)(void *data, int rw);
920} ide_hwif_t; 920} ____cacheline_maxaligned_in_smp ide_hwif_t;
921 921
922/* 922/*
923 * internal ide interrupt handler type 923 * internal ide interrupt handler type
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 99ddba5a4e00..5e1a7b0d7b3f 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -25,27 +25,45 @@
25 * Rusty Russell). 25 * Rusty Russell).
26 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes 26 * 2004-July Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
27 * interface to access function arguments. 27 * interface to access function arguments.
28 * 2005-May Hien Nguyen <hien@us.ibm.com> and Jim Keniston
29 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
30 * <prasanna@in.ibm.com> added function-return probes.
28 */ 31 */
29#include <linux/config.h> 32#include <linux/config.h>
30#include <linux/list.h> 33#include <linux/list.h>
31#include <linux/notifier.h> 34#include <linux/notifier.h>
32#include <linux/smp.h> 35#include <linux/smp.h>
36
33#include <asm/kprobes.h> 37#include <asm/kprobes.h>
34 38
39/* kprobe_status settings */
40#define KPROBE_HIT_ACTIVE 0x00000001
41#define KPROBE_HIT_SS 0x00000002
42#define KPROBE_REENTER 0x00000004
43#define KPROBE_HIT_SSDONE 0x00000008
44
35struct kprobe; 45struct kprobe;
36struct pt_regs; 46struct pt_regs;
47struct kretprobe;
48struct kretprobe_instance;
37typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *); 49typedef int (*kprobe_pre_handler_t) (struct kprobe *, struct pt_regs *);
38typedef int (*kprobe_break_handler_t) (struct kprobe *, struct pt_regs *); 50typedef int (*kprobe_break_handler_t) (struct kprobe *, struct pt_regs *);
39typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *, 51typedef void (*kprobe_post_handler_t) (struct kprobe *, struct pt_regs *,
40 unsigned long flags); 52 unsigned long flags);
41typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *, 53typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *,
42 int trapnr); 54 int trapnr);
55typedef int (*kretprobe_handler_t) (struct kretprobe_instance *,
56 struct pt_regs *);
57
43struct kprobe { 58struct kprobe {
44 struct hlist_node hlist; 59 struct hlist_node hlist;
45 60
46 /* list of kprobes for multi-handler support */ 61 /* list of kprobes for multi-handler support */
47 struct list_head list; 62 struct list_head list;
48 63
64 /*count the number of times this probe was temporarily disarmed */
65 unsigned long nmissed;
66
49 /* location of the probe point */ 67 /* location of the probe point */
50 kprobe_opcode_t *addr; 68 kprobe_opcode_t *addr;
51 69
@@ -85,6 +103,62 @@ struct jprobe {
85 kprobe_opcode_t *entry; /* probe handling code to jump to */ 103 kprobe_opcode_t *entry; /* probe handling code to jump to */
86}; 104};
87 105
106#ifdef ARCH_SUPPORTS_KRETPROBES
107extern int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs);
108extern void trampoline_post_handler(struct kprobe *p, struct pt_regs *regs,
109 unsigned long flags);
110extern struct task_struct *arch_get_kprobe_task(void *ptr);
111extern void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs);
112extern void arch_kprobe_flush_task(struct task_struct *tk);
113#else /* ARCH_SUPPORTS_KRETPROBES */
114static inline void kretprobe_trampoline(void)
115{
116}
117static inline int trampoline_probe_handler(struct kprobe *p,
118 struct pt_regs *regs)
119{
120 return 0;
121}
122static inline void trampoline_post_handler(struct kprobe *p,
123 struct pt_regs *regs, unsigned long flags)
124{
125}
126static inline void arch_prepare_kretprobe(struct kretprobe *rp,
127 struct pt_regs *regs)
128{
129}
130static inline void arch_kprobe_flush_task(struct task_struct *tk)
131{
132}
133#define arch_get_kprobe_task(ptr) ((struct task_struct *)NULL)
134#endif /* ARCH_SUPPORTS_KRETPROBES */
135/*
136 * Function-return probe -
137 * Note:
138 * User needs to provide a handler function, and initialize maxactive.
139 * maxactive - The maximum number of instances of the probed function that
140 * can be active concurrently.
141 * nmissed - tracks the number of times the probed function's return was
142 * ignored, due to maxactive being too low.
143 *
144 */
145struct kretprobe {
146 struct kprobe kp;
147 kretprobe_handler_t handler;
148 int maxactive;
149 int nmissed;
150 struct hlist_head free_instances;
151 struct hlist_head used_instances;
152};
153
154struct kretprobe_instance {
155 struct hlist_node uflist; /* either on free list or used list */
156 struct hlist_node hlist;
157 struct kretprobe *rp;
158 void *ret_addr;
159 void *stack_addr;
160};
161
88#ifdef CONFIG_KPROBES 162#ifdef CONFIG_KPROBES
89/* Locks kprobe: irq must be disabled */ 163/* Locks kprobe: irq must be disabled */
90void lock_kprobes(void); 164void lock_kprobes(void);
@@ -99,11 +173,14 @@ static inline int kprobe_running(void)
99 173
100extern int arch_prepare_kprobe(struct kprobe *p); 174extern int arch_prepare_kprobe(struct kprobe *p);
101extern void arch_copy_kprobe(struct kprobe *p); 175extern void arch_copy_kprobe(struct kprobe *p);
176extern void arch_arm_kprobe(struct kprobe *p);
177extern void arch_disarm_kprobe(struct kprobe *p);
102extern void arch_remove_kprobe(struct kprobe *p); 178extern void arch_remove_kprobe(struct kprobe *p);
103extern void show_registers(struct pt_regs *regs); 179extern void show_registers(struct pt_regs *regs);
104 180
105/* Get the kprobe at this addr (if any). Must have called lock_kprobes */ 181/* Get the kprobe at this addr (if any). Must have called lock_kprobes */
106struct kprobe *get_kprobe(void *addr); 182struct kprobe *get_kprobe(void *addr);
183struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);
107 184
108int register_kprobe(struct kprobe *p); 185int register_kprobe(struct kprobe *p);
109void unregister_kprobe(struct kprobe *p); 186void unregister_kprobe(struct kprobe *p);
@@ -113,7 +190,16 @@ int register_jprobe(struct jprobe *p);
113void unregister_jprobe(struct jprobe *p); 190void unregister_jprobe(struct jprobe *p);
114void jprobe_return(void); 191void jprobe_return(void);
115 192
116#else 193int register_kretprobe(struct kretprobe *rp);
194void unregister_kretprobe(struct kretprobe *rp);
195
196struct kretprobe_instance *get_free_rp_inst(struct kretprobe *rp);
197struct kretprobe_instance *get_rp_inst(void *sara);
198struct kretprobe_instance *get_rp_inst_tsk(struct task_struct *tk);
199void add_rp_inst(struct kretprobe_instance *ri);
200void kprobe_flush_task(struct task_struct *tk);
201void recycle_rp_inst(struct kretprobe_instance *ri);
202#else /* CONFIG_KPROBES */
117static inline int kprobe_running(void) 203static inline int kprobe_running(void)
118{ 204{
119 return 0; 205 return 0;
@@ -135,5 +221,15 @@ static inline void unregister_jprobe(struct jprobe *p)
135static inline void jprobe_return(void) 221static inline void jprobe_return(void)
136{ 222{
137} 223}
138#endif 224static inline int register_kretprobe(struct kretprobe *rp)
225{
226 return -ENOSYS;
227}
228static inline void unregister_kretprobe(struct kretprobe *rp)
229{
230}
231static inline void kprobe_flush_task(struct task_struct *tk)
232{
233}
234#endif /* CONFIG_KPROBES */
139#endif /* _LINUX_KPROBES_H */ 235#endif /* _LINUX_KPROBES_H */
diff --git a/include/linux/loop.h b/include/linux/loop.h
index 8220d9c9da00..53fa51595443 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -61,7 +61,7 @@ struct loop_device {
61 struct semaphore lo_sem; 61 struct semaphore lo_sem;
62 struct semaphore lo_ctl_mutex; 62 struct semaphore lo_ctl_mutex;
63 struct semaphore lo_bh_mutex; 63 struct semaphore lo_bh_mutex;
64 atomic_t lo_pending; 64 int lo_pending;
65 65
66 request_queue_t *lo_queue; 66 request_queue_t *lo_queue;
67}; 67};
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
index 4a36edf1c974..796220ce47cc 100644
--- a/include/linux/mempool.h
+++ b/include/linux/mempool.h
@@ -20,9 +20,14 @@ typedef struct mempool_s {
20 mempool_free_t *free; 20 mempool_free_t *free;
21 wait_queue_head_t wait; 21 wait_queue_head_t wait;
22} mempool_t; 22} mempool_t;
23extern mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, 23
24 mempool_free_t *free_fn, void *pool_data); 24extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
25extern int mempool_resize(mempool_t *pool, int new_min_nr, unsigned int __nocast gfp_mask); 25 mempool_free_t *free_fn, void *pool_data);
26extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
27 mempool_free_t *free_fn, void *pool_data, int nid);
28
29extern int mempool_resize(mempool_t *pool, int new_min_nr,
30 unsigned int __nocast gfp_mask);
26extern void mempool_destroy(mempool_t *pool); 31extern void mempool_destroy(mempool_t *pool);
27extern void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask); 32extern void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask);
28extern void mempool_free(void *element, mempool_t *pool); 33extern void mempool_free(void *element, mempool_t *pool);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1813b162b0a8..6eb7f48317f8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -395,19 +395,81 @@ static inline void put_page(struct page *page)
395/* 395/*
396 * The zone field is never updated after free_area_init_core() 396 * The zone field is never updated after free_area_init_core()
397 * sets it, so none of the operations on it need to be atomic. 397 * sets it, so none of the operations on it need to be atomic.
398 * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total,
399 * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits.
400 */ 398 */
401#define NODEZONE_SHIFT (sizeof(page_flags_t)*8 - MAX_NODES_SHIFT - MAX_ZONES_SHIFT) 399
402#define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone) 400
401/*
402 * page->flags layout:
403 *
404 * There are three possibilities for how page->flags get
405 * laid out. The first is for the normal case, without
406 * sparsemem. The second is for sparsemem when there is
407 * plenty of space for node and section. The last is when
408 * we have run out of space and have to fall back to an
409 * alternate (slower) way of determining the node.
410 *
411 * No sparsemem: | NODE | ZONE | ... | FLAGS |
412 * with space for node: | SECTION | NODE | ZONE | ... | FLAGS |
413 * no space for node: | SECTION | ZONE | ... | FLAGS |
414 */
415#ifdef CONFIG_SPARSEMEM
416#define SECTIONS_WIDTH SECTIONS_SHIFT
417#else
418#define SECTIONS_WIDTH 0
419#endif
420
421#define ZONES_WIDTH ZONES_SHIFT
422
423#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= FLAGS_RESERVED
424#define NODES_WIDTH NODES_SHIFT
425#else
426#define NODES_WIDTH 0
427#endif
428
429/* Page flags: | [SECTION] | [NODE] | ZONE | ... | FLAGS | */
430#define SECTIONS_PGOFF ((sizeof(page_flags_t)*8) - SECTIONS_WIDTH)
431#define NODES_PGOFF (SECTIONS_PGOFF - NODES_WIDTH)
432#define ZONES_PGOFF (NODES_PGOFF - ZONES_WIDTH)
433
434/*
435 * We are going to use the flags for the page to node mapping if its in
436 * there. This includes the case where there is no node, so it is implicit.
437 */
438#define FLAGS_HAS_NODE (NODES_WIDTH > 0 || NODES_SHIFT == 0)
439
440#ifndef PFN_SECTION_SHIFT
441#define PFN_SECTION_SHIFT 0
442#endif
443
444/*
445 * Define the bit shifts to access each section. For non-existant
446 * sections we define the shift as 0; that plus a 0 mask ensures
447 * the compiler will optimise away reference to them.
448 */
449#define SECTIONS_PGSHIFT (SECTIONS_PGOFF * (SECTIONS_WIDTH != 0))
450#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0))
451#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0))
452
453/* NODE:ZONE or SECTION:ZONE is used to lookup the zone from a page. */
454#if FLAGS_HAS_NODE
455#define ZONETABLE_SHIFT (NODES_SHIFT + ZONES_SHIFT)
456#else
457#define ZONETABLE_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT)
458#endif
459#define ZONETABLE_PGSHIFT ZONES_PGSHIFT
460
461#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
462#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
463#endif
464
465#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1)
466#define NODES_MASK ((1UL << NODES_WIDTH) - 1)
467#define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1)
468#define ZONETABLE_MASK ((1UL << ZONETABLE_SHIFT) - 1)
403 469
404static inline unsigned long page_zonenum(struct page *page) 470static inline unsigned long page_zonenum(struct page *page)
405{ 471{
406 return (page->flags >> NODEZONE_SHIFT) & (~(~0UL << ZONES_SHIFT)); 472 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
407}
408static inline unsigned long page_to_nid(struct page *page)
409{
410 return (page->flags >> (NODEZONE_SHIFT + ZONES_SHIFT));
411} 473}
412 474
413struct zone; 475struct zone;
@@ -415,13 +477,44 @@ extern struct zone *zone_table[];
415 477
416static inline struct zone *page_zone(struct page *page) 478static inline struct zone *page_zone(struct page *page)
417{ 479{
418 return zone_table[page->flags >> NODEZONE_SHIFT]; 480 return zone_table[(page->flags >> ZONETABLE_PGSHIFT) &
481 ZONETABLE_MASK];
482}
483
484static inline unsigned long page_to_nid(struct page *page)
485{
486 if (FLAGS_HAS_NODE)
487 return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
488 else
489 return page_zone(page)->zone_pgdat->node_id;
490}
491static inline unsigned long page_to_section(struct page *page)
492{
493 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
494}
495
496static inline void set_page_zone(struct page *page, unsigned long zone)
497{
498 page->flags &= ~(ZONES_MASK << ZONES_PGSHIFT);
499 page->flags |= (zone & ZONES_MASK) << ZONES_PGSHIFT;
500}
501static inline void set_page_node(struct page *page, unsigned long node)
502{
503 page->flags &= ~(NODES_MASK << NODES_PGSHIFT);
504 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT;
505}
506static inline void set_page_section(struct page *page, unsigned long section)
507{
508 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
509 page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
419} 510}
420 511
421static inline void set_page_zone(struct page *page, unsigned long nodezone_num) 512static inline void set_page_links(struct page *page, unsigned long zone,
513 unsigned long node, unsigned long pfn)
422{ 514{
423 page->flags &= ~(~0UL << NODEZONE_SHIFT); 515 set_page_zone(page, zone);
424 page->flags |= nodezone_num << NODEZONE_SHIFT; 516 set_page_node(page, node);
517 set_page_section(page, pfn_to_section_nr(pfn));
425} 518}
426 519
427#ifndef CONFIG_DISCONTIGMEM 520#ifndef CONFIG_DISCONTIGMEM
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 4733d35d8223..6c90461ed99f 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -269,7 +269,9 @@ typedef struct pglist_data {
269 struct zone node_zones[MAX_NR_ZONES]; 269 struct zone node_zones[MAX_NR_ZONES];
270 struct zonelist node_zonelists[GFP_ZONETYPES]; 270 struct zonelist node_zonelists[GFP_ZONETYPES];
271 int nr_zones; 271 int nr_zones;
272#ifdef CONFIG_FLAT_NODE_MEM_MAP
272 struct page *node_mem_map; 273 struct page *node_mem_map;
274#endif
273 struct bootmem_data *bdata; 275 struct bootmem_data *bdata;
274 unsigned long node_start_pfn; 276 unsigned long node_start_pfn;
275 unsigned long node_present_pages; /* total number of physical pages */ 277 unsigned long node_present_pages; /* total number of physical pages */
@@ -284,6 +286,12 @@ typedef struct pglist_data {
284 286
285#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages) 287#define node_present_pages(nid) (NODE_DATA(nid)->node_present_pages)
286#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages) 288#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
289#ifdef CONFIG_FLAT_NODE_MEM_MAP
290#define pgdat_page_nr(pgdat, pagenr) ((pgdat)->node_mem_map + (pagenr))
291#else
292#define pgdat_page_nr(pgdat, pagenr) pfn_to_page((pgdat)->node_start_pfn + (pagenr))
293#endif
294#define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))
287 295
288extern struct pglist_data *pgdat_list; 296extern struct pglist_data *pgdat_list;
289 297
@@ -400,7 +408,7 @@ int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *,
400/* Returns the number of the current Node. */ 408/* Returns the number of the current Node. */
401#define numa_node_id() (cpu_to_node(raw_smp_processor_id())) 409#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))
402 410
403#ifndef CONFIG_DISCONTIGMEM 411#ifndef CONFIG_NEED_MULTIPLE_NODES
404 412
405extern struct pglist_data contig_page_data; 413extern struct pglist_data contig_page_data;
406#define NODE_DATA(nid) (&contig_page_data) 414#define NODE_DATA(nid) (&contig_page_data)
@@ -408,36 +416,177 @@ extern struct pglist_data contig_page_data;
408#define MAX_NODES_SHIFT 1 416#define MAX_NODES_SHIFT 1
409#define pfn_to_nid(pfn) (0) 417#define pfn_to_nid(pfn) (0)
410 418
411#else /* CONFIG_DISCONTIGMEM */ 419#else /* CONFIG_NEED_MULTIPLE_NODES */
412 420
413#include <asm/mmzone.h> 421#include <asm/mmzone.h>
414 422
423#endif /* !CONFIG_NEED_MULTIPLE_NODES */
424
425#ifdef CONFIG_SPARSEMEM
426#include <asm/sparsemem.h>
427#endif
428
415#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED) 429#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED)
416/* 430/*
417 * with 32 bit page->flags field, we reserve 8 bits for node/zone info. 431 * with 32 bit page->flags field, we reserve 8 bits for node/zone info.
418 * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. 432 * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
419 */ 433 */
420#define MAX_NODES_SHIFT 6 434#define FLAGS_RESERVED 8
435
421#elif BITS_PER_LONG == 64 436#elif BITS_PER_LONG == 64
422/* 437/*
423 * with 64 bit flags field, there's plenty of room. 438 * with 64 bit flags field, there's plenty of room.
424 */ 439 */
425#define MAX_NODES_SHIFT 10 440#define FLAGS_RESERVED 32
441
442#else
443
444#error BITS_PER_LONG not defined
445
446#endif
447
448#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
449#define early_pfn_to_nid(nid) (0UL)
426#endif 450#endif
427 451
428#endif /* !CONFIG_DISCONTIGMEM */ 452#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
453#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
454
455#ifdef CONFIG_SPARSEMEM
456
457/*
458 * SECTION_SHIFT #bits space required to store a section #
459 *
460 * PA_SECTION_SHIFT physical address to/from section number
461 * PFN_SECTION_SHIFT pfn to/from section number
462 */
463#define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
464
465#define PA_SECTION_SHIFT (SECTION_SIZE_BITS)
466#define PFN_SECTION_SHIFT (SECTION_SIZE_BITS - PAGE_SHIFT)
467
468#define NR_MEM_SECTIONS (1UL << SECTIONS_SHIFT)
429 469
430#if NODES_SHIFT > MAX_NODES_SHIFT 470#define PAGES_PER_SECTION (1UL << PFN_SECTION_SHIFT)
431#error NODES_SHIFT > MAX_NODES_SHIFT 471#define PAGE_SECTION_MASK (~(PAGES_PER_SECTION-1))
472
473#if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
474#error Allocator MAX_ORDER exceeds SECTION_SIZE
432#endif 475#endif
433 476
434/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */ 477struct page;
435#define MAX_ZONES_SHIFT 2 478struct mem_section {
479 /*
480 * This is, logically, a pointer to an array of struct
481 * pages. However, it is stored with some other magic.
482 * (see sparse.c::sparse_init_one_section())
483 *
484 * Making it a UL at least makes someone do a cast
485 * before using it wrong.
486 */
487 unsigned long section_mem_map;
488};
489
490extern struct mem_section mem_section[NR_MEM_SECTIONS];
436 491
437#if ZONES_SHIFT > MAX_ZONES_SHIFT 492static inline struct mem_section *__nr_to_section(unsigned long nr)
438#error ZONES_SHIFT > MAX_ZONES_SHIFT 493{
494 return &mem_section[nr];
495}
496
497/*
498 * We use the lower bits of the mem_map pointer to store
499 * a little bit of information. There should be at least
500 * 3 bits here due to 32-bit alignment.
501 */
502#define SECTION_MARKED_PRESENT (1UL<<0)
503#define SECTION_HAS_MEM_MAP (1UL<<1)
504#define SECTION_MAP_LAST_BIT (1UL<<2)
505#define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
506
507static inline struct page *__section_mem_map_addr(struct mem_section *section)
508{
509 unsigned long map = section->section_mem_map;
510 map &= SECTION_MAP_MASK;
511 return (struct page *)map;
512}
513
514static inline int valid_section(struct mem_section *section)
515{
516 return (section->section_mem_map & SECTION_MARKED_PRESENT);
517}
518
519static inline int section_has_mem_map(struct mem_section *section)
520{
521 return (section->section_mem_map & SECTION_HAS_MEM_MAP);
522}
523
524static inline int valid_section_nr(unsigned long nr)
525{
526 return valid_section(__nr_to_section(nr));
527}
528
529/*
530 * Given a kernel address, find the home node of the underlying memory.
531 */
532#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
533
534static inline struct mem_section *__pfn_to_section(unsigned long pfn)
535{
536 return __nr_to_section(pfn_to_section_nr(pfn));
537}
538
539#define pfn_to_page(pfn) \
540({ \
541 unsigned long __pfn = (pfn); \
542 __section_mem_map_addr(__pfn_to_section(__pfn)) + __pfn; \
543})
544#define page_to_pfn(page) \
545({ \
546 page - __section_mem_map_addr(__nr_to_section( \
547 page_to_section(page))); \
548})
549
550static inline int pfn_valid(unsigned long pfn)
551{
552 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
553 return 0;
554 return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
555}
556
557/*
558 * These are _only_ used during initialisation, therefore they
559 * can use __initdata ... They could have names to indicate
560 * this restriction.
561 */
562#ifdef CONFIG_NUMA
563#define pfn_to_nid early_pfn_to_nid
564#endif
565
566#define pfn_to_pgdat(pfn) \
567({ \
568 NODE_DATA(pfn_to_nid(pfn)); \
569})
570
571#define early_pfn_valid(pfn) pfn_valid(pfn)
572void sparse_init(void);
573#else
574#define sparse_init() do {} while (0)
575#endif /* CONFIG_SPARSEMEM */
576
577#ifdef CONFIG_NODES_SPAN_OTHER_NODES
578#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid))
579#else
580#define early_pfn_in_nid(pfn, nid) (1)
581#endif
582
583#ifndef early_pfn_valid
584#define early_pfn_valid(pfn) (1)
439#endif 585#endif
440 586
587void memory_present(int nid, unsigned long start, unsigned long end);
588unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
589
441#endif /* !__ASSEMBLY__ */ 590#endif /* !__ASSEMBLY__ */
442#endif /* __KERNEL__ */ 591#endif /* __KERNEL__ */
443#endif /* _LINUX_MMZONE_H */ 592#endif /* _LINUX_MMZONE_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ba5d1236aa17..d89816ad642f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -41,7 +41,7 @@
41struct divert_blk; 41struct divert_blk;
42struct vlan_group; 42struct vlan_group;
43struct ethtool_ops; 43struct ethtool_ops;
44struct netpoll; 44struct netpoll_info;
45 /* source back-compat hooks */ 45 /* source back-compat hooks */
46#define SET_ETHTOOL_OPS(netdev,ops) \ 46#define SET_ETHTOOL_OPS(netdev,ops) \
47 ( (netdev)->ethtool_ops = (ops) ) 47 ( (netdev)->ethtool_ops = (ops) )
@@ -468,7 +468,7 @@ struct net_device
468 unsigned char *haddr); 468 unsigned char *haddr);
469 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); 469 int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
470#ifdef CONFIG_NETPOLL 470#ifdef CONFIG_NETPOLL
471 struct netpoll *np; 471 struct netpoll_info *npinfo;
472#endif 472#endif
473#ifdef CONFIG_NET_POLL_CONTROLLER 473#ifdef CONFIG_NET_POLL_CONTROLLER
474 void (*poll_controller)(struct net_device *dev); 474 void (*poll_controller)(struct net_device *dev);
@@ -925,10 +925,6 @@ extern int skb_checksum_help(struct sk_buff *skb, int inward);
925extern void net_enable_timestamp(void); 925extern void net_enable_timestamp(void);
926extern void net_disable_timestamp(void); 926extern void net_disable_timestamp(void);
927 927
928#ifdef CONFIG_SYSCTL
929extern char *net_sysctl_strdup(const char *s);
930#endif
931
932#endif /* __KERNEL__ */ 928#endif /* __KERNEL__ */
933 929
934#endif /* _LINUX_DEV_H */ 930#endif /* _LINUX_DEV_H */
diff --git a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
index baa83e757156..d9bceedfb3dc 100644
--- a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
+++ b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
@@ -18,7 +18,6 @@ struct clusterip_config;
18struct ipt_clusterip_tgt_info { 18struct ipt_clusterip_tgt_info {
19 19
20 u_int32_t flags; 20 u_int32_t flags;
21 struct clusterip_config *config;
22 21
23 /* only relevant for new ones */ 22 /* only relevant for new ones */
24 u_int8_t clustermac[6]; 23 u_int8_t clustermac[6];
@@ -27,6 +26,8 @@ struct ipt_clusterip_tgt_info {
27 u_int16_t local_nodes[CLUSTERIP_MAX_NODES]; 26 u_int16_t local_nodes[CLUSTERIP_MAX_NODES];
28 enum clusterip_hashmode hash_mode; 27 enum clusterip_hashmode hash_mode;
29 u_int32_t hash_initval; 28 u_int32_t hash_initval;
29
30 struct clusterip_config *config;
30}; 31};
31 32
32#endif /*_IPT_CLUSTERIP_H_target*/ 33#endif /*_IPT_CLUSTERIP_H_target*/
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index c0d8b90c5202..bcd0ac33f592 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -16,14 +16,19 @@ struct netpoll;
16struct netpoll { 16struct netpoll {
17 struct net_device *dev; 17 struct net_device *dev;
18 char dev_name[16], *name; 18 char dev_name[16], *name;
19 int rx_flags;
20 void (*rx_hook)(struct netpoll *, int, char *, int); 19 void (*rx_hook)(struct netpoll *, int, char *, int);
21 void (*drop)(struct sk_buff *skb); 20 void (*drop)(struct sk_buff *skb);
22 u32 local_ip, remote_ip; 21 u32 local_ip, remote_ip;
23 u16 local_port, remote_port; 22 u16 local_port, remote_port;
24 unsigned char local_mac[6], remote_mac[6]; 23 unsigned char local_mac[6], remote_mac[6];
24};
25
26struct netpoll_info {
25 spinlock_t poll_lock; 27 spinlock_t poll_lock;
26 int poll_owner; 28 int poll_owner;
29 int rx_flags;
30 spinlock_t rx_lock;
31 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
27}; 32};
28 33
29void netpoll_poll(struct netpoll *np); 34void netpoll_poll(struct netpoll *np);
@@ -39,22 +44,35 @@ void netpoll_queue(struct sk_buff *skb);
39#ifdef CONFIG_NETPOLL 44#ifdef CONFIG_NETPOLL
40static inline int netpoll_rx(struct sk_buff *skb) 45static inline int netpoll_rx(struct sk_buff *skb)
41{ 46{
42 return skb->dev->np && skb->dev->np->rx_flags && __netpoll_rx(skb); 47 struct netpoll_info *npinfo = skb->dev->npinfo;
48 unsigned long flags;
49 int ret = 0;
50
51 if (!npinfo || (!npinfo->rx_np && !npinfo->rx_flags))
52 return 0;
53
54 spin_lock_irqsave(&npinfo->rx_lock, flags);
55 /* check rx_flags again with the lock held */
56 if (npinfo->rx_flags && __netpoll_rx(skb))
57 ret = 1;
58 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
59
60 return ret;
43} 61}
44 62
45static inline void netpoll_poll_lock(struct net_device *dev) 63static inline void netpoll_poll_lock(struct net_device *dev)
46{ 64{
47 if (dev->np) { 65 if (dev->npinfo) {
48 spin_lock(&dev->np->poll_lock); 66 spin_lock(&dev->npinfo->poll_lock);
49 dev->np->poll_owner = smp_processor_id(); 67 dev->npinfo->poll_owner = smp_processor_id();
50 } 68 }
51} 69}
52 70
53static inline void netpoll_poll_unlock(struct net_device *dev) 71static inline void netpoll_poll_unlock(struct net_device *dev)
54{ 72{
55 if (dev->np) { 73 if (dev->npinfo) {
56 spin_unlock(&dev->np->poll_lock); 74 dev->npinfo->poll_owner = -1;
57 dev->np->poll_owner = -1; 75 spin_unlock(&dev->npinfo->poll_lock);
58 } 76 }
59} 77}
60 78
diff --git a/include/linux/numa.h b/include/linux/numa.h
index bd0c8c4e9a95..f0c539bd3cfc 100644
--- a/include/linux/numa.h
+++ b/include/linux/numa.h
@@ -3,7 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_DISCONTIGMEM 6#ifndef CONFIG_FLATMEM
7#include <asm/numnodes.h> 7#include <asm/numnodes.h>
8#endif 8#endif
9 9
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
index 4e2d2a942ecb..4b32bce9a289 100644
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -159,7 +159,7 @@ struct packet_iosched
159 struct bio *read_queue_tail; 159 struct bio *read_queue_tail;
160 struct bio *write_queue; 160 struct bio *write_queue;
161 struct bio *write_queue_tail; 161 struct bio *write_queue_tail;
162 int high_prio_read; /* An important read request has been queued */ 162 sector_t last_write; /* The sector where the last write ended */
163 int successive_reads; 163 int successive_reads;
164}; 164};
165 165
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
index 5efd0a6dad94..6e53c34035cd 100644
--- a/include/linux/posix_acl_xattr.h
+++ b/include/linux/posix_acl_xattr.h
@@ -23,13 +23,13 @@
23#define ACL_UNDEFINED_ID (-1) 23#define ACL_UNDEFINED_ID (-1)
24 24
25typedef struct { 25typedef struct {
26 __u16 e_tag; 26 __le16 e_tag;
27 __u16 e_perm; 27 __le16 e_perm;
28 __u32 e_id; 28 __le32 e_id;
29} posix_acl_xattr_entry; 29} posix_acl_xattr_entry;
30 30
31typedef struct { 31typedef struct {
32 __u32 a_version; 32 __le32 a_version;
33 posix_acl_xattr_entry a_entries[0]; 33 posix_acl_xattr_entry a_entries[0];
34} posix_acl_xattr_header; 34} posix_acl_xattr_header;
35 35
@@ -52,4 +52,7 @@ posix_acl_xattr_count(size_t size)
52 return size / sizeof(posix_acl_xattr_entry); 52 return size / sizeof(posix_acl_xattr_entry);
53} 53}
54 54
55struct posix_acl *posix_acl_from_xattr(const void *value, size_t size);
56int posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size);
57
55#endif /* _POSIX_ACL_XATTR_H */ 58#endif /* _POSIX_ACL_XATTR_H */
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index e57baa85e744..d211507ab246 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -39,7 +39,8 @@ extern int dquot_commit_info(struct super_block *sb, int type);
39extern int dquot_mark_dquot_dirty(struct dquot *dquot); 39extern int dquot_mark_dquot_dirty(struct dquot *dquot);
40 40
41extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path); 41extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path);
42extern int vfs_quota_on_mount(int type, int format_id, struct dentry *dentry); 42extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
43 int format_id, int type);
43extern int vfs_quota_off(struct super_block *sb, int type); 44extern int vfs_quota_off(struct super_block *sb, int type);
44#define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, type) 45#define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, type)
45extern int vfs_quota_sync(struct super_block *sb, int type); 46extern int vfs_quota_sync(struct super_block *sb, int type);
diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h
index 2aef9c3f5ce8..0760507a545b 100644
--- a/include/linux/reiserfs_acl.h
+++ b/include/linux/reiserfs_acl.h
@@ -1,6 +1,5 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/posix_acl.h> 2#include <linux/posix_acl.h>
3#include <linux/xattr_acl.h>
4 3
5#define REISERFS_ACL_VERSION 0x0001 4#define REISERFS_ACL_VERSION 0x0001
6 5
diff --git a/include/linux/sched.h b/include/linux/sched.h
index b58afd97a180..901742f92389 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -246,7 +246,7 @@ struct mm_struct {
246 246
247 unsigned long saved_auxv[42]; /* for /proc/PID/auxv */ 247 unsigned long saved_auxv[42]; /* for /proc/PID/auxv */
248 248
249 unsigned dumpable:1; 249 unsigned dumpable:2;
250 cpumask_t cpu_vm_mask; 250 cpumask_t cpu_vm_mask;
251 251
252 /* Architecture-specific MM context */ 252 /* Architecture-specific MM context */
diff --git a/include/linux/string.h b/include/linux/string.h
index b9fc59469956..93994c613095 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -88,6 +88,8 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
88extern void * memchr(const void *,int,__kernel_size_t); 88extern void * memchr(const void *,int,__kernel_size_t);
89#endif 89#endif
90 90
91extern char *kstrdup(const char *s, int gfp);
92
91#ifdef __cplusplus 93#ifdef __cplusplus
92} 94}
93#endif 95#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index a17745c80a91..614e939c78a4 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -136,6 +136,7 @@ enum
136 KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */ 136 KERN_UNKNOWN_NMI_PANIC=66, /* int: unknown nmi panic flag */
137 KERN_BOOTLOADER_TYPE=67, /* int: boot loader type */ 137 KERN_BOOTLOADER_TYPE=67, /* int: boot loader type */
138 KERN_RANDOMIZE=68, /* int: randomize virtual address space */ 138 KERN_RANDOMIZE=68, /* int: randomize virtual address space */
139 KERN_SETUID_DUMPABLE=69, /* int: behaviour of dumps for setuid core */
139}; 140};
140 141
141 142
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 90db1cc62ddd..221f81ac2002 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -6,45 +6,33 @@
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/stddef.h> 7#include <linux/stddef.h>
8 8
9struct tvec_t_base_s; 9struct timer_base_s;
10 10
11struct timer_list { 11struct timer_list {
12 struct list_head entry; 12 struct list_head entry;
13 unsigned long expires; 13 unsigned long expires;
14 14
15 spinlock_t lock;
16 unsigned long magic; 15 unsigned long magic;
17 16
18 void (*function)(unsigned long); 17 void (*function)(unsigned long);
19 unsigned long data; 18 unsigned long data;
20 19
21 struct tvec_t_base_s *base; 20 struct timer_base_s *base;
22}; 21};
23 22
24#define TIMER_MAGIC 0x4b87ad6e 23#define TIMER_MAGIC 0x4b87ad6e
25 24
25extern struct timer_base_s __init_timer_base;
26
26#define TIMER_INITIALIZER(_function, _expires, _data) { \ 27#define TIMER_INITIALIZER(_function, _expires, _data) { \
27 .function = (_function), \ 28 .function = (_function), \
28 .expires = (_expires), \ 29 .expires = (_expires), \
29 .data = (_data), \ 30 .data = (_data), \
30 .base = NULL, \ 31 .base = &__init_timer_base, \
31 .magic = TIMER_MAGIC, \ 32 .magic = TIMER_MAGIC, \
32 .lock = SPIN_LOCK_UNLOCKED, \
33 } 33 }
34 34
35/*** 35void fastcall init_timer(struct timer_list * timer);
36 * init_timer - initialize a timer.
37 * @timer: the timer to be initialized
38 *
39 * init_timer() must be done to a timer prior calling *any* of the
40 * other timer functions.
41 */
42static inline void init_timer(struct timer_list * timer)
43{
44 timer->base = NULL;
45 timer->magic = TIMER_MAGIC;
46 spin_lock_init(&timer->lock);
47}
48 36
49/*** 37/***
50 * timer_pending - is a timer pending? 38 * timer_pending - is a timer pending?
@@ -58,7 +46,7 @@ static inline void init_timer(struct timer_list * timer)
58 */ 46 */
59static inline int timer_pending(const struct timer_list * timer) 47static inline int timer_pending(const struct timer_list * timer)
60{ 48{
61 return timer->base != NULL; 49 return timer->entry.next != NULL;
62} 50}
63 51
64extern void add_timer_on(struct timer_list *timer, int cpu); 52extern void add_timer_on(struct timer_list *timer, int cpu);
@@ -88,13 +76,15 @@ static inline void add_timer(struct timer_list * timer)
88} 76}
89 77
90#ifdef CONFIG_SMP 78#ifdef CONFIG_SMP
79 extern int try_to_del_timer_sync(struct timer_list *timer);
91 extern int del_timer_sync(struct timer_list *timer); 80 extern int del_timer_sync(struct timer_list *timer);
92 extern int del_singleshot_timer_sync(struct timer_list *timer);
93#else 81#else
94# define del_timer_sync(t) del_timer(t) 82# define try_to_del_timer_sync(t) del_timer(t)
95# define del_singleshot_timer_sync(t) del_timer(t) 83# define del_timer_sync(t) del_timer(t)
96#endif 84#endif
97 85
86#define del_singleshot_timer_sync(t) del_timer_sync(t)
87
98extern void init_timers(void); 88extern void init_timers(void);
99extern void run_local_timers(void); 89extern void run_local_timers(void);
100extern void it_real_fn(unsigned long); 90extern void it_real_fn(unsigned long);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 1b76106272d3..59ff42c629ec 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -345,6 +345,7 @@ extern int tty_check_change(struct tty_struct * tty);
345extern void stop_tty(struct tty_struct * tty); 345extern void stop_tty(struct tty_struct * tty);
346extern void start_tty(struct tty_struct * tty); 346extern void start_tty(struct tty_struct * tty);
347extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); 347extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
348extern int tty_unregister_ldisc(int disc);
348extern int tty_register_driver(struct tty_driver *driver); 349extern int tty_register_driver(struct tty_driver *driver);
349extern int tty_unregister_driver(struct tty_driver *driver); 350extern int tty_unregister_driver(struct tty_driver *driver);
350extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev); 351extern void tty_register_device(struct tty_driver *driver, unsigned index, struct device *dev);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index c9486c3efb4a..d38c9fecdc36 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -33,7 +33,7 @@ int default_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key
33struct __wait_queue { 33struct __wait_queue {
34 unsigned int flags; 34 unsigned int flags;
35#define WQ_FLAG_EXCLUSIVE 0x01 35#define WQ_FLAG_EXCLUSIVE 0x01
36 struct task_struct * task; 36 void *private;
37 wait_queue_func_t func; 37 wait_queue_func_t func;
38 struct list_head task_list; 38 struct list_head task_list;
39}; 39};
@@ -60,7 +60,7 @@ typedef struct __wait_queue_head wait_queue_head_t;
60 */ 60 */
61 61
62#define __WAITQUEUE_INITIALIZER(name, tsk) { \ 62#define __WAITQUEUE_INITIALIZER(name, tsk) { \
63 .task = tsk, \ 63 .private = tsk, \
64 .func = default_wake_function, \ 64 .func = default_wake_function, \
65 .task_list = { NULL, NULL } } 65 .task_list = { NULL, NULL } }
66 66
@@ -86,7 +86,7 @@ static inline void init_waitqueue_head(wait_queue_head_t *q)
86static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p) 86static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
87{ 87{
88 q->flags = 0; 88 q->flags = 0;
89 q->task = p; 89 q->private = p;
90 q->func = default_wake_function; 90 q->func = default_wake_function;
91} 91}
92 92
@@ -94,7 +94,7 @@ static inline void init_waitqueue_func_entry(wait_queue_t *q,
94 wait_queue_func_t func) 94 wait_queue_func_t func)
95{ 95{
96 q->flags = 0; 96 q->flags = 0;
97 q->task = NULL; 97 q->private = NULL;
98 q->func = func; 98 q->func = func;
99} 99}
100 100
@@ -110,7 +110,7 @@ static inline int waitqueue_active(wait_queue_head_t *q)
110 * aio specifies a wait queue entry with an async notification 110 * aio specifies a wait queue entry with an async notification
111 * callback routine, not associated with any task. 111 * callback routine, not associated with any task.
112 */ 112 */
113#define is_sync_wait(wait) (!(wait) || ((wait)->task)) 113#define is_sync_wait(wait) (!(wait) || ((wait)->private))
114 114
115extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)); 115extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
116extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait)); 116extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
@@ -384,7 +384,7 @@ int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
384 384
385#define DEFINE_WAIT(name) \ 385#define DEFINE_WAIT(name) \
386 wait_queue_t name = { \ 386 wait_queue_t name = { \
387 .task = current, \ 387 .private = current, \
388 .func = autoremove_wake_function, \ 388 .func = autoremove_wake_function, \
389 .task_list = LIST_HEAD_INIT((name).task_list), \ 389 .task_list = LIST_HEAD_INIT((name).task_list), \
390 } 390 }
@@ -393,7 +393,7 @@ int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
393 struct wait_bit_queue name = { \ 393 struct wait_bit_queue name = { \
394 .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \ 394 .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \
395 .wait = { \ 395 .wait = { \
396 .task = current, \ 396 .private = current, \
397 .func = wake_bit_function, \ 397 .func = wake_bit_function, \
398 .task_list = \ 398 .task_list = \
399 LIST_HEAD_INIT((name).wait.task_list), \ 399 LIST_HEAD_INIT((name).wait.task_list), \
@@ -402,7 +402,7 @@ int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
402 402
403#define init_wait(wait) \ 403#define init_wait(wait) \
404 do { \ 404 do { \
405 (wait)->task = current; \ 405 (wait)->private = current; \
406 (wait)->func = autoremove_wake_function; \ 406 (wait)->func = autoremove_wake_function; \
407 INIT_LIST_HEAD(&(wait)->task_list); \ 407 INIT_LIST_HEAD(&(wait)->task_list); \
408 } while (0) 408 } while (0)
diff --git a/include/linux/x25.h b/include/linux/x25.h
index 7531cfed5885..16d44931afa0 100644
--- a/include/linux/x25.h
+++ b/include/linux/x25.h
@@ -4,6 +4,8 @@
4 * History 4 * History
5 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 5 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
6 * negotiation. 6 * negotiation.
7 * apr/02/05 Shaun Pereira Selective sub address matching with
8 * call user data
7 */ 9 */
8 10
9#ifndef X25_KERNEL_H 11#ifndef X25_KERNEL_H
@@ -16,6 +18,9 @@
16#define SIOCX25GCALLUSERDATA (SIOCPROTOPRIVATE + 4) 18#define SIOCX25GCALLUSERDATA (SIOCPROTOPRIVATE + 4)
17#define SIOCX25SCALLUSERDATA (SIOCPROTOPRIVATE + 5) 19#define SIOCX25SCALLUSERDATA (SIOCPROTOPRIVATE + 5)
18#define SIOCX25GCAUSEDIAG (SIOCPROTOPRIVATE + 6) 20#define SIOCX25GCAUSEDIAG (SIOCPROTOPRIVATE + 6)
21#define SIOCX25SCUDMATCHLEN (SIOCPROTOPRIVATE + 7)
22#define SIOCX25CALLACCPTAPPRV (SIOCPROTOPRIVATE + 8)
23#define SIOCX25SENDCALLACCPT (SIOCPROTOPRIVATE + 9)
19 24
20/* 25/*
21 * Values for {get,set}sockopt. 26 * Values for {get,set}sockopt.
@@ -109,4 +114,11 @@ struct x25_causediag {
109 unsigned char diagnostic; 114 unsigned char diagnostic;
110}; 115};
111 116
117/*
118 * Further optional call user data match length selection
119 */
120struct x25_subaddr {
121 unsigned int cudmatchlength;
122};
123
112#endif 124#endif
diff --git a/include/net/x25.h b/include/net/x25.h
index 7a1ba5bbb868..8b39b98876e8 100644
--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -79,6 +79,8 @@ enum {
79#define X25_DEFAULT_PACKET_SIZE X25_PS128 /* Default Packet Size */ 79#define X25_DEFAULT_PACKET_SIZE X25_PS128 /* Default Packet Size */
80#define X25_DEFAULT_THROUGHPUT 0x0A /* Deafult Throughput */ 80#define X25_DEFAULT_THROUGHPUT 0x0A /* Deafult Throughput */
81#define X25_DEFAULT_REVERSE 0x00 /* Default Reverse Charging */ 81#define X25_DEFAULT_REVERSE 0x00 /* Default Reverse Charging */
82#define X25_DENY_ACCPT_APPRV 0x01 /* Default value */
83#define X25_ALLOW_ACCPT_APPRV 0x00 /* Control enabled */
82 84
83#define X25_SMODULUS 8 85#define X25_SMODULUS 8
84#define X25_EMODULUS 128 86#define X25_EMODULUS 128
@@ -94,7 +96,7 @@ enum {
94#define X25_FAC_CLASS_C 0x80 96#define X25_FAC_CLASS_C 0x80
95#define X25_FAC_CLASS_D 0xC0 97#define X25_FAC_CLASS_D 0xC0
96 98
97#define X25_FAC_REVERSE 0x01 99#define X25_FAC_REVERSE 0x01 /* also fast select */
98#define X25_FAC_THROUGHPUT 0x02 100#define X25_FAC_THROUGHPUT 0x02
99#define X25_FAC_PACKET_SIZE 0x42 101#define X25_FAC_PACKET_SIZE 0x42
100#define X25_FAC_WINDOW_SIZE 0x43 102#define X25_FAC_WINDOW_SIZE 0x43
@@ -134,8 +136,8 @@ struct x25_sock {
134 struct sock sk; 136 struct sock sk;
135 struct x25_address source_addr, dest_addr; 137 struct x25_address source_addr, dest_addr;
136 struct x25_neigh *neighbour; 138 struct x25_neigh *neighbour;
137 unsigned int lci; 139 unsigned int lci, cudmatchlength;
138 unsigned char state, condition, qbitincl, intflag; 140 unsigned char state, condition, qbitincl, intflag, accptapprv;
139 unsigned short vs, vr, va, vl; 141 unsigned short vs, vr, va, vl;
140 unsigned long t2, t21, t22, t23; 142 unsigned long t2, t21, t22, t23;
141 unsigned short fraglen; 143 unsigned short fraglen;
@@ -242,7 +244,6 @@ extern int x25_validate_nr(struct sock *, unsigned short);
242extern void x25_write_internal(struct sock *, int); 244extern void x25_write_internal(struct sock *, int);
243extern int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, int *); 245extern int x25_decode(struct sock *, struct sk_buff *, int *, int *, int *, int *, int *);
244extern void x25_disconnect(struct sock *, int, unsigned char, unsigned char); 246extern void x25_disconnect(struct sock *, int, unsigned char, unsigned char);
245extern int x25_check_calluserdata(struct x25_calluserdata *,struct x25_calluserdata *);
246 247
247/* x25_timer.c */ 248/* x25_timer.c */
248extern void x25_start_heartbeat(struct sock *); 249extern void x25_start_heartbeat(struct sock *);
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 6d3413a56708..67b867f31fe4 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -77,6 +77,11 @@ extern socket_state_t dead_socket;
77/* Use this just for bridge windows */ 77/* Use this just for bridge windows */
78#define MAP_IOSPACE 0x20 78#define MAP_IOSPACE 0x20
79 79
80/* power hook operations */
81#define HOOK_POWER_PRE 0x01
82#define HOOK_POWER_POST 0x02
83
84
80typedef struct pccard_io_map { 85typedef struct pccard_io_map {
81 u_char map; 86 u_char map;
82 u_char flags; 87 u_char flags;
@@ -222,6 +227,9 @@ struct pcmcia_socket {
222 /* Zoom video behaviour is so chip specific its not worth adding 227 /* Zoom video behaviour is so chip specific its not worth adding
223 this to _ops */ 228 this to _ops */
224 void (*zoom_video)(struct pcmcia_socket *, int); 229 void (*zoom_video)(struct pcmcia_socket *, int);
230
231 /* so is power hook */
232 int (*power_hook)(struct pcmcia_socket *sock, int operation);
225 233
226 /* state thread */ 234 /* state thread */
227 struct semaphore skt_sem; /* protects socket h/w state */ 235 struct semaphore skt_sem; /* protects socket h/w state */
diff --git a/include/sound/core.h b/include/sound/core.h
index 9117c23e3a01..f8c4ef0aa352 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -292,6 +292,7 @@ void *snd_hidden_kcalloc(size_t n, size_t size, int flags);
292void snd_hidden_kfree(const void *obj); 292void snd_hidden_kfree(const void *obj);
293void *snd_hidden_vmalloc(unsigned long size); 293void *snd_hidden_vmalloc(unsigned long size);
294void snd_hidden_vfree(void *obj); 294void snd_hidden_vfree(void *obj);
295char *snd_hidden_kstrdup(const char *s, int flags);
295#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) 296#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
296#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) 297#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
297#define kfree(obj) snd_hidden_kfree(obj) 298#define kfree(obj) snd_hidden_kfree(obj)
@@ -301,6 +302,7 @@ void snd_hidden_vfree(void *obj);
301#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size) 302#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
302#define kfree_nocheck(obj) snd_wrapper_kfree(obj) 303#define kfree_nocheck(obj) snd_wrapper_kfree(obj)
303#define vfree_nocheck(obj) snd_wrapper_vfree(obj) 304#define vfree_nocheck(obj) snd_wrapper_vfree(obj)
305#define kstrdup(s, flags) snd_hidden_kstrdup(s, flags)
304#else 306#else
305#define snd_memory_init() /*NOP*/ 307#define snd_memory_init() /*NOP*/
306#define snd_memory_done() /*NOP*/ 308#define snd_memory_done() /*NOP*/
@@ -311,7 +313,6 @@ void snd_hidden_vfree(void *obj);
311#define kfree_nocheck(obj) kfree(obj) 313#define kfree_nocheck(obj) kfree(obj)
312#define vfree_nocheck(obj) vfree(obj) 314#define vfree_nocheck(obj) vfree(obj)
313#endif 315#endif
314char *snd_kmalloc_strdup(const char *string, int flags);
315int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); 316int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
316int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); 317int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
317 318
diff --git a/init/calibrate.c b/init/calibrate.c
index c698e04a3dbe..d206c7548fe6 100644
--- a/init/calibrate.c
+++ b/init/calibrate.c
@@ -8,6 +8,8 @@
8#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/init.h> 9#include <linux/init.h>
10 10
11#include <asm/timex.h>
12
11static unsigned long preset_lpj; 13static unsigned long preset_lpj;
12static int __init lpj_setup(char *str) 14static int __init lpj_setup(char *str)
13{ 15{
@@ -17,6 +19,92 @@ static int __init lpj_setup(char *str)
17 19
18__setup("lpj=", lpj_setup); 20__setup("lpj=", lpj_setup);
19 21
22#ifdef ARCH_HAS_READ_CURRENT_TIMER
23
24/* This routine uses the read_current_timer() routine and gets the
25 * loops per jiffy directly, instead of guessing it using delay().
26 * Also, this code tries to handle non-maskable asynchronous events
27 * (like SMIs)
28 */
29#define DELAY_CALIBRATION_TICKS ((HZ < 100) ? 1 : (HZ/100))
30#define MAX_DIRECT_CALIBRATION_RETRIES 5
31
32static unsigned long __devinit calibrate_delay_direct(void)
33{
34 unsigned long pre_start, start, post_start;
35 unsigned long pre_end, end, post_end;
36 unsigned long start_jiffies;
37 unsigned long tsc_rate_min, tsc_rate_max;
38 unsigned long good_tsc_sum = 0;
39 unsigned long good_tsc_count = 0;
40 int i;
41
42 if (read_current_timer(&pre_start) < 0 )
43 return 0;
44
45 /*
46 * A simple loop like
47 * while ( jiffies < start_jiffies+1)
48 * start = read_current_timer();
49 * will not do. As we don't really know whether jiffy switch
50 * happened first or timer_value was read first. And some asynchronous
51 * event can happen between these two events introducing errors in lpj.
52 *
53 * So, we do
54 * 1. pre_start <- When we are sure that jiffy switch hasn't happened
55 * 2. check jiffy switch
56 * 3. start <- timer value before or after jiffy switch
57 * 4. post_start <- When we are sure that jiffy switch has happened
58 *
59 * Note, we don't know anything about order of 2 and 3.
60 * Now, by looking at post_start and pre_start difference, we can
61 * check whether any asynchronous event happened or not
62 */
63
64 for (i = 0; i < MAX_DIRECT_CALIBRATION_RETRIES; i++) {
65 pre_start = 0;
66 read_current_timer(&start);
67 start_jiffies = jiffies;
68 while (jiffies <= (start_jiffies + 1)) {
69 pre_start = start;
70 read_current_timer(&start);
71 }
72 read_current_timer(&post_start);
73
74 pre_end = 0;
75 end = post_start;
76 while (jiffies <=
77 (start_jiffies + 1 + DELAY_CALIBRATION_TICKS)) {
78 pre_end = end;
79 read_current_timer(&end);
80 }
81 read_current_timer(&post_end);
82
83 tsc_rate_max = (post_end - pre_start) / DELAY_CALIBRATION_TICKS;
84 tsc_rate_min = (pre_end - post_start) / DELAY_CALIBRATION_TICKS;
85
86 /*
87 * If the upper limit and lower limit of the tsc_rate is
88 * >= 12.5% apart, redo calibration.
89 */
90 if (pre_start != 0 && pre_end != 0 &&
91 (tsc_rate_max - tsc_rate_min) < (tsc_rate_max >> 3)) {
92 good_tsc_count++;
93 good_tsc_sum += tsc_rate_max;
94 }
95 }
96
97 if (good_tsc_count)
98 return (good_tsc_sum/good_tsc_count);
99
100 printk(KERN_WARNING "calibrate_delay_direct() failed to get a good "
101 "estimate for loops_per_jiffy.\nProbably due to long platform interrupts. Consider using \"lpj=\" boot option.\n");
102 return 0;
103}
104#else
105static unsigned long __devinit calibrate_delay_direct(void) {return 0;}
106#endif
107
20/* 108/*
21 * This is the number of bits of precision for the loops_per_jiffy. Each 109 * This is the number of bits of precision for the loops_per_jiffy. Each
22 * bit takes on average 1.5/HZ seconds. This (like the original) is a little 110 * bit takes on average 1.5/HZ seconds. This (like the original) is a little
@@ -35,6 +123,12 @@ void __devinit calibrate_delay(void)
35 "%lu.%02lu BogoMIPS preset\n", 123 "%lu.%02lu BogoMIPS preset\n",
36 loops_per_jiffy/(500000/HZ), 124 loops_per_jiffy/(500000/HZ),
37 (loops_per_jiffy/(5000/HZ)) % 100); 125 (loops_per_jiffy/(5000/HZ)) % 100);
126 } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) {
127 printk("Calibrating delay using timer specific routine.. ");
128 printk("%lu.%02lu BogoMIPS (lpj=%lu)\n",
129 loops_per_jiffy/(500000/HZ),
130 (loops_per_jiffy/(5000/HZ)) % 100,
131 loops_per_jiffy);
38 } else { 132 } else {
39 loops_per_jiffy = (1<<12); 133 loops_per_jiffy = (1<<12);
40 134
diff --git a/ipc/sem.c b/ipc/sem.c
index 5ad7ac0ed60d..7e8a25c82ef3 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1054,7 +1054,7 @@ asmlinkage long sys_semtimedop(int semid, struct sembuf __user *tsops,
1054 struct sembuf fast_sops[SEMOPM_FAST]; 1054 struct sembuf fast_sops[SEMOPM_FAST];
1055 struct sembuf* sops = fast_sops, *sop; 1055 struct sembuf* sops = fast_sops, *sop;
1056 struct sem_undo *un; 1056 struct sem_undo *un;
1057 int undos = 0, decrease = 0, alter = 0, max; 1057 int undos = 0, alter = 0, max;
1058 struct sem_queue queue; 1058 struct sem_queue queue;
1059 unsigned long jiffies_left = 0; 1059 unsigned long jiffies_left = 0;
1060 1060
@@ -1089,13 +1089,10 @@ asmlinkage long sys_semtimedop(int semid, struct sembuf __user *tsops,
1089 if (sop->sem_num >= max) 1089 if (sop->sem_num >= max)
1090 max = sop->sem_num; 1090 max = sop->sem_num;
1091 if (sop->sem_flg & SEM_UNDO) 1091 if (sop->sem_flg & SEM_UNDO)
1092 undos++; 1092 undos = 1;
1093 if (sop->sem_op < 0) 1093 if (sop->sem_op != 0)
1094 decrease = 1;
1095 if (sop->sem_op > 0)
1096 alter = 1; 1094 alter = 1;
1097 } 1095 }
1098 alter |= decrease;
1099 1096
1100retry_undos: 1097retry_undos:
1101 if (undos) { 1098 if (undos) {
diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
new file mode 100644
index 000000000000..248e1c396f8b
--- /dev/null
+++ b/kernel/Kconfig.hz
@@ -0,0 +1,46 @@
1#
2# Timer Interrupt Frequency Configuration
3#
4
5choice
6 prompt "Timer frequency"
7 default HZ_250
8 help
9 Allows the configuration of the timer frequency. It is customary
10 to have the timer interrupt run at 1000 HZ but 100 HZ may be more
11 beneficial for servers and NUMA systems that do not need to have
12 a fast response for user interaction and that may experience bus
13 contention and cacheline bounces as a result of timer interrupts.
14 Note that the timer interrupt occurs on each processor in an SMP
15 environment leading to NR_CPUS * HZ number of timer interrupts
16 per second.
17
18
19 config HZ_100
20 bool "100 HZ"
21 help
22 100 HZ is a typical choice for servers, SMP and NUMA systems
23 with lots of processors that may show reduced performance if
24 too many timer interrupts are occurring.
25
26 config HZ_250
27 bool "250 HZ"
28 help
29 250 HZ is a good compromise choice allowing server performance
30 while also showing good interactive responsiveness even
31 on SMP and NUMA systems.
32
33 config HZ_1000
34 bool "1000 HZ"
35 help
36 1000 HZ is the preferred choice for desktop systems and other
37 systems requiring fast interactive responses to events.
38
39endchoice
40
41config HZ
42 int
43 default 100 if HZ_100
44 default 250 if HZ_250
45 default 1000 if HZ_1000
46
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 00e8f2575512..79dd929f4084 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -228,13 +228,7 @@ static struct dentry_operations cpuset_dops = {
228 228
229static struct dentry *cpuset_get_dentry(struct dentry *parent, const char *name) 229static struct dentry *cpuset_get_dentry(struct dentry *parent, const char *name)
230{ 230{
231 struct qstr qstr; 231 struct dentry *d = lookup_one_len(name, parent, strlen(name));
232 struct dentry *d;
233
234 qstr.name = name;
235 qstr.len = strlen(name);
236 qstr.hash = full_name_hash(name, qstr.len);
237 d = lookup_hash(&qstr, parent);
238 if (!IS_ERR(d)) 232 if (!IS_ERR(d))
239 d->d_op = &cpuset_dops; 233 d->d_op = &cpuset_dops;
240 return d; 234 return d;
diff --git a/kernel/exit.c b/kernel/exit.c
index 2ef2ad540201..3ebcd60a19c6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -72,6 +72,11 @@ repeat:
72 BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children)); 72 BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children));
73 __exit_signal(p); 73 __exit_signal(p);
74 __exit_sighand(p); 74 __exit_sighand(p);
75 /*
76 * Note that the fastpath in sys_times depends on __exit_signal having
77 * updated the counters before a task is removed from the tasklist of
78 * the process by __unhash_process.
79 */
75 __unhash_process(p); 80 __unhash_process(p);
76 81
77 /* 82 /*
@@ -793,6 +798,17 @@ fastcall NORET_TYPE void do_exit(long code)
793 ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP); 798 ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
794 } 799 }
795 800
801 /*
802 * We're taking recursive faults here in do_exit. Safest is to just
803 * leave this task alone and wait for reboot.
804 */
805 if (unlikely(tsk->flags & PF_EXITING)) {
806 printk(KERN_ALERT
807 "Fixing recursive fault but reboot is needed!\n");
808 set_current_state(TASK_UNINTERRUPTIBLE);
809 schedule();
810 }
811
796 tsk->flags |= PF_EXITING; 812 tsk->flags |= PF_EXITING;
797 813
798 /* 814 /*
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 037142b72a49..334f37472c56 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -27,6 +27,9 @@
27 * interface to access function arguments. 27 * interface to access function arguments.
28 * 2004-Sep Prasanna S Panchamukhi <prasanna@in.ibm.com> Changed Kprobes 28 * 2004-Sep Prasanna S Panchamukhi <prasanna@in.ibm.com> Changed Kprobes
29 * exceptions notifier to be first on the priority list. 29 * exceptions notifier to be first on the priority list.
30 * 2005-May Hien Nguyen <hien@us.ibm.com>, Jim Keniston
31 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
32 * <prasanna@in.ibm.com> added function-return probes.
30 */ 33 */
31#include <linux/kprobes.h> 34#include <linux/kprobes.h>
32#include <linux/spinlock.h> 35#include <linux/spinlock.h>
@@ -41,6 +44,7 @@
41#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) 44#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
42 45
43static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE]; 46static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
47static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
44 48
45unsigned int kprobe_cpu = NR_CPUS; 49unsigned int kprobe_cpu = NR_CPUS;
46static DEFINE_SPINLOCK(kprobe_lock); 50static DEFINE_SPINLOCK(kprobe_lock);
@@ -78,22 +82,23 @@ struct kprobe *get_kprobe(void *addr)
78 * Aggregate handlers for multiple kprobes support - these handlers 82 * Aggregate handlers for multiple kprobes support - these handlers
79 * take care of invoking the individual kprobe handlers on p->list 83 * take care of invoking the individual kprobe handlers on p->list
80 */ 84 */
81int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs) 85static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
82{ 86{
83 struct kprobe *kp; 87 struct kprobe *kp;
84 88
85 list_for_each_entry(kp, &p->list, list) { 89 list_for_each_entry(kp, &p->list, list) {
86 if (kp->pre_handler) { 90 if (kp->pre_handler) {
87 curr_kprobe = kp; 91 curr_kprobe = kp;
88 kp->pre_handler(kp, regs); 92 if (kp->pre_handler(kp, regs))
89 curr_kprobe = NULL; 93 return 1;
90 } 94 }
95 curr_kprobe = NULL;
91 } 96 }
92 return 0; 97 return 0;
93} 98}
94 99
95void aggr_post_handler(struct kprobe *p, struct pt_regs *regs, 100static void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
96 unsigned long flags) 101 unsigned long flags)
97{ 102{
98 struct kprobe *kp; 103 struct kprobe *kp;
99 104
@@ -107,7 +112,8 @@ void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
107 return; 112 return;
108} 113}
109 114
110int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, int trapnr) 115static int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs,
116 int trapnr)
111{ 117{
112 /* 118 /*
113 * if we faulted "during" the execution of a user specified 119 * if we faulted "during" the execution of a user specified
@@ -120,19 +126,191 @@ int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, int trapnr)
120 return 0; 126 return 0;
121} 127}
122 128
129static int aggr_break_handler(struct kprobe *p, struct pt_regs *regs)
130{
131 struct kprobe *kp = curr_kprobe;
132 if (curr_kprobe && kp->break_handler) {
133 if (kp->break_handler(kp, regs)) {
134 curr_kprobe = NULL;
135 return 1;
136 }
137 }
138 curr_kprobe = NULL;
139 return 0;
140}
141
142struct kprobe trampoline_p = {
143 .addr = (kprobe_opcode_t *) &kretprobe_trampoline,
144 .pre_handler = trampoline_probe_handler,
145 .post_handler = trampoline_post_handler
146};
147
148struct kretprobe_instance *get_free_rp_inst(struct kretprobe *rp)
149{
150 struct hlist_node *node;
151 struct kretprobe_instance *ri;
152 hlist_for_each_entry(ri, node, &rp->free_instances, uflist)
153 return ri;
154 return NULL;
155}
156
157static struct kretprobe_instance *get_used_rp_inst(struct kretprobe *rp)
158{
159 struct hlist_node *node;
160 struct kretprobe_instance *ri;
161 hlist_for_each_entry(ri, node, &rp->used_instances, uflist)
162 return ri;
163 return NULL;
164}
165
166struct kretprobe_instance *get_rp_inst(void *sara)
167{
168 struct hlist_head *head;
169 struct hlist_node *node;
170 struct task_struct *tsk;
171 struct kretprobe_instance *ri;
172
173 tsk = arch_get_kprobe_task(sara);
174 head = &kretprobe_inst_table[hash_ptr(tsk, KPROBE_HASH_BITS)];
175 hlist_for_each_entry(ri, node, head, hlist) {
176 if (ri->stack_addr == sara)
177 return ri;
178 }
179 return NULL;
180}
181
182void add_rp_inst(struct kretprobe_instance *ri)
183{
184 struct task_struct *tsk;
185 /*
186 * Remove rp inst off the free list -
187 * Add it back when probed function returns
188 */
189 hlist_del(&ri->uflist);
190 tsk = arch_get_kprobe_task(ri->stack_addr);
191 /* Add rp inst onto table */
192 INIT_HLIST_NODE(&ri->hlist);
193 hlist_add_head(&ri->hlist,
194 &kretprobe_inst_table[hash_ptr(tsk, KPROBE_HASH_BITS)]);
195
196 /* Also add this rp inst to the used list. */
197 INIT_HLIST_NODE(&ri->uflist);
198 hlist_add_head(&ri->uflist, &ri->rp->used_instances);
199}
200
201void recycle_rp_inst(struct kretprobe_instance *ri)
202{
203 /* remove rp inst off the rprobe_inst_table */
204 hlist_del(&ri->hlist);
205 if (ri->rp) {
206 /* remove rp inst off the used list */
207 hlist_del(&ri->uflist);
208 /* put rp inst back onto the free list */
209 INIT_HLIST_NODE(&ri->uflist);
210 hlist_add_head(&ri->uflist, &ri->rp->free_instances);
211 } else
212 /* Unregistering */
213 kfree(ri);
214}
215
216struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk)
217{
218 return &kretprobe_inst_table[hash_ptr(tsk, KPROBE_HASH_BITS)];
219}
220
221struct kretprobe_instance *get_rp_inst_tsk(struct task_struct *tk)
222{
223 struct task_struct *tsk;
224 struct hlist_head *head;
225 struct hlist_node *node;
226 struct kretprobe_instance *ri;
227
228 head = &kretprobe_inst_table[hash_ptr(tk, KPROBE_HASH_BITS)];
229
230 hlist_for_each_entry(ri, node, head, hlist) {
231 tsk = arch_get_kprobe_task(ri->stack_addr);
232 if (tsk == tk)
233 return ri;
234 }
235 return NULL;
236}
237
238/*
239 * This function is called from do_exit or do_execv when task tk's stack is
240 * about to be recycled. Recycle any function-return probe instances
241 * associated with this task. These represent probed functions that have
242 * been called but may never return.
243 */
244void kprobe_flush_task(struct task_struct *tk)
245{
246 unsigned long flags = 0;
247 spin_lock_irqsave(&kprobe_lock, flags);
248 arch_kprobe_flush_task(tk);
249 spin_unlock_irqrestore(&kprobe_lock, flags);
250}
251
252/*
253 * This kprobe pre_handler is registered with every kretprobe. When probe
254 * hits it will set up the return probe.
255 */
256static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
257{
258 struct kretprobe *rp = container_of(p, struct kretprobe, kp);
259
260 /*TODO: consider to only swap the RA after the last pre_handler fired */
261 arch_prepare_kretprobe(rp, regs);
262 return 0;
263}
264
265static inline void free_rp_inst(struct kretprobe *rp)
266{
267 struct kretprobe_instance *ri;
268 while ((ri = get_free_rp_inst(rp)) != NULL) {
269 hlist_del(&ri->uflist);
270 kfree(ri);
271 }
272}
273
274/*
275 * Keep all fields in the kprobe consistent
276 */
277static inline void copy_kprobe(struct kprobe *old_p, struct kprobe *p)
278{
279 memcpy(&p->opcode, &old_p->opcode, sizeof(kprobe_opcode_t));
280 memcpy(&p->ainsn, &old_p->ainsn, sizeof(struct arch_specific_insn));
281}
282
283/*
284* Add the new probe to old_p->list. Fail if this is the
285* second jprobe at the address - two jprobes can't coexist
286*/
287static int add_new_kprobe(struct kprobe *old_p, struct kprobe *p)
288{
289 struct kprobe *kp;
290
291 if (p->break_handler) {
292 list_for_each_entry(kp, &old_p->list, list) {
293 if (kp->break_handler)
294 return -EEXIST;
295 }
296 list_add_tail(&p->list, &old_p->list);
297 } else
298 list_add(&p->list, &old_p->list);
299 return 0;
300}
301
123/* 302/*
124 * Fill in the required fields of the "manager kprobe". Replace the 303 * Fill in the required fields of the "manager kprobe". Replace the
125 * earlier kprobe in the hlist with the manager kprobe 304 * earlier kprobe in the hlist with the manager kprobe
126 */ 305 */
127static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p) 306static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
128{ 307{
308 copy_kprobe(p, ap);
129 ap->addr = p->addr; 309 ap->addr = p->addr;
130 ap->opcode = p->opcode;
131 memcpy(&ap->ainsn, &p->ainsn, sizeof(struct arch_specific_insn));
132
133 ap->pre_handler = aggr_pre_handler; 310 ap->pre_handler = aggr_pre_handler;
134 ap->post_handler = aggr_post_handler; 311 ap->post_handler = aggr_post_handler;
135 ap->fault_handler = aggr_fault_handler; 312 ap->fault_handler = aggr_fault_handler;
313 ap->break_handler = aggr_break_handler;
136 314
137 INIT_LIST_HEAD(&ap->list); 315 INIT_LIST_HEAD(&ap->list);
138 list_add(&p->list, &ap->list); 316 list_add(&p->list, &ap->list);
@@ -153,16 +331,16 @@ static int register_aggr_kprobe(struct kprobe *old_p, struct kprobe *p)
153 int ret = 0; 331 int ret = 0;
154 struct kprobe *ap; 332 struct kprobe *ap;
155 333
156 if (old_p->break_handler || p->break_handler) { 334 if (old_p->pre_handler == aggr_pre_handler) {
157 ret = -EEXIST; /* kprobe and jprobe can't (yet) coexist */ 335 copy_kprobe(old_p, p);
158 } else if (old_p->pre_handler == aggr_pre_handler) { 336 ret = add_new_kprobe(old_p, p);
159 list_add(&p->list, &old_p->list);
160 } else { 337 } else {
161 ap = kcalloc(1, sizeof(struct kprobe), GFP_ATOMIC); 338 ap = kcalloc(1, sizeof(struct kprobe), GFP_ATOMIC);
162 if (!ap) 339 if (!ap)
163 return -ENOMEM; 340 return -ENOMEM;
164 add_aggr_kprobe(ap, old_p); 341 add_aggr_kprobe(ap, old_p);
165 list_add(&p->list, &ap->list); 342 copy_kprobe(ap, p);
343 ret = add_new_kprobe(ap, p);
166 } 344 }
167 return ret; 345 return ret;
168} 346}
@@ -170,10 +348,8 @@ static int register_aggr_kprobe(struct kprobe *old_p, struct kprobe *p)
170/* kprobe removal house-keeping routines */ 348/* kprobe removal house-keeping routines */
171static inline void cleanup_kprobe(struct kprobe *p, unsigned long flags) 349static inline void cleanup_kprobe(struct kprobe *p, unsigned long flags)
172{ 350{
173 *p->addr = p->opcode; 351 arch_disarm_kprobe(p);
174 hlist_del(&p->hlist); 352 hlist_del(&p->hlist);
175 flush_icache_range((unsigned long) p->addr,
176 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
177 spin_unlock_irqrestore(&kprobe_lock, flags); 353 spin_unlock_irqrestore(&kprobe_lock, flags);
178 arch_remove_kprobe(p); 354 arch_remove_kprobe(p);
179} 355}
@@ -200,6 +376,7 @@ int register_kprobe(struct kprobe *p)
200 } 376 }
201 spin_lock_irqsave(&kprobe_lock, flags); 377 spin_lock_irqsave(&kprobe_lock, flags);
202 old_p = get_kprobe(p->addr); 378 old_p = get_kprobe(p->addr);
379 p->nmissed = 0;
203 if (old_p) { 380 if (old_p) {
204 ret = register_aggr_kprobe(old_p, p); 381 ret = register_aggr_kprobe(old_p, p);
205 goto out; 382 goto out;
@@ -210,10 +387,8 @@ int register_kprobe(struct kprobe *p)
210 hlist_add_head(&p->hlist, 387 hlist_add_head(&p->hlist,
211 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); 388 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
212 389
213 p->opcode = *p->addr; 390 arch_arm_kprobe(p);
214 *p->addr = BREAKPOINT_INSTRUCTION; 391
215 flush_icache_range((unsigned long) p->addr,
216 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
217out: 392out:
218 spin_unlock_irqrestore(&kprobe_lock, flags); 393 spin_unlock_irqrestore(&kprobe_lock, flags);
219rm_kprobe: 394rm_kprobe:
@@ -257,16 +432,82 @@ void unregister_jprobe(struct jprobe *jp)
257 unregister_kprobe(&jp->kp); 432 unregister_kprobe(&jp->kp);
258} 433}
259 434
435#ifdef ARCH_SUPPORTS_KRETPROBES
436
437int register_kretprobe(struct kretprobe *rp)
438{
439 int ret = 0;
440 struct kretprobe_instance *inst;
441 int i;
442
443 rp->kp.pre_handler = pre_handler_kretprobe;
444
445 /* Pre-allocate memory for max kretprobe instances */
446 if (rp->maxactive <= 0) {
447#ifdef CONFIG_PREEMPT
448 rp->maxactive = max(10, 2 * NR_CPUS);
449#else
450 rp->maxactive = NR_CPUS;
451#endif
452 }
453 INIT_HLIST_HEAD(&rp->used_instances);
454 INIT_HLIST_HEAD(&rp->free_instances);
455 for (i = 0; i < rp->maxactive; i++) {
456 inst = kmalloc(sizeof(struct kretprobe_instance), GFP_KERNEL);
457 if (inst == NULL) {
458 free_rp_inst(rp);
459 return -ENOMEM;
460 }
461 INIT_HLIST_NODE(&inst->uflist);
462 hlist_add_head(&inst->uflist, &rp->free_instances);
463 }
464
465 rp->nmissed = 0;
466 /* Establish function entry probe point */
467 if ((ret = register_kprobe(&rp->kp)) != 0)
468 free_rp_inst(rp);
469 return ret;
470}
471
472#else /* ARCH_SUPPORTS_KRETPROBES */
473
474int register_kretprobe(struct kretprobe *rp)
475{
476 return -ENOSYS;
477}
478
479#endif /* ARCH_SUPPORTS_KRETPROBES */
480
481void unregister_kretprobe(struct kretprobe *rp)
482{
483 unsigned long flags;
484 struct kretprobe_instance *ri;
485
486 unregister_kprobe(&rp->kp);
487 /* No race here */
488 spin_lock_irqsave(&kprobe_lock, flags);
489 free_rp_inst(rp);
490 while ((ri = get_used_rp_inst(rp)) != NULL) {
491 ri->rp = NULL;
492 hlist_del(&ri->uflist);
493 }
494 spin_unlock_irqrestore(&kprobe_lock, flags);
495}
496
260static int __init init_kprobes(void) 497static int __init init_kprobes(void)
261{ 498{
262 int i, err = 0; 499 int i, err = 0;
263 500
264 /* FIXME allocate the probe table, currently defined statically */ 501 /* FIXME allocate the probe table, currently defined statically */
265 /* initialize all list heads */ 502 /* initialize all list heads */
266 for (i = 0; i < KPROBE_TABLE_SIZE; i++) 503 for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
267 INIT_HLIST_HEAD(&kprobe_table[i]); 504 INIT_HLIST_HEAD(&kprobe_table[i]);
505 INIT_HLIST_HEAD(&kretprobe_inst_table[i]);
506 }
268 507
269 err = register_die_notifier(&kprobe_exceptions_nb); 508 err = register_die_notifier(&kprobe_exceptions_nb);
509 /* Register the trampoline probe for return probe */
510 register_kprobe(&trampoline_p);
270 return err; 511 return err;
271} 512}
272 513
@@ -277,3 +518,6 @@ EXPORT_SYMBOL_GPL(unregister_kprobe);
277EXPORT_SYMBOL_GPL(register_jprobe); 518EXPORT_SYMBOL_GPL(register_jprobe);
278EXPORT_SYMBOL_GPL(unregister_jprobe); 519EXPORT_SYMBOL_GPL(unregister_jprobe);
279EXPORT_SYMBOL_GPL(jprobe_return); 520EXPORT_SYMBOL_GPL(jprobe_return);
521EXPORT_SYMBOL_GPL(register_kretprobe);
522EXPORT_SYMBOL_GPL(unregister_kretprobe);
523
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index cabb63fc9e16..5b7b4736d82b 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -89,23 +89,6 @@ static struct idr posix_timers_id;
89static DEFINE_SPINLOCK(idr_lock); 89static DEFINE_SPINLOCK(idr_lock);
90 90
91/* 91/*
92 * Just because the timer is not in the timer list does NOT mean it is
93 * inactive. It could be in the "fire" routine getting a new expire time.
94 */
95#define TIMER_INACTIVE 1
96
97#ifdef CONFIG_SMP
98# define timer_active(tmr) \
99 ((tmr)->it.real.timer.entry.prev != (void *)TIMER_INACTIVE)
100# define set_timer_inactive(tmr) \
101 do { \
102 (tmr)->it.real.timer.entry.prev = (void *)TIMER_INACTIVE; \
103 } while (0)
104#else
105# define timer_active(tmr) BARFY // error to use outside of SMP
106# define set_timer_inactive(tmr) do { } while (0)
107#endif
108/*
109 * we assume that the new SIGEV_THREAD_ID shares no bits with the other 92 * we assume that the new SIGEV_THREAD_ID shares no bits with the other
110 * SIGEV values. Here we put out an error if this assumption fails. 93 * SIGEV values. Here we put out an error if this assumption fails.
111 */ 94 */
@@ -226,7 +209,6 @@ static inline int common_timer_create(struct k_itimer *new_timer)
226 init_timer(&new_timer->it.real.timer); 209 init_timer(&new_timer->it.real.timer);
227 new_timer->it.real.timer.data = (unsigned long) new_timer; 210 new_timer->it.real.timer.data = (unsigned long) new_timer;
228 new_timer->it.real.timer.function = posix_timer_fn; 211 new_timer->it.real.timer.function = posix_timer_fn;
229 set_timer_inactive(new_timer);
230 return 0; 212 return 0;
231} 213}
232 214
@@ -480,7 +462,6 @@ static void posix_timer_fn(unsigned long __data)
480 int do_notify = 1; 462 int do_notify = 1;
481 463
482 spin_lock_irqsave(&timr->it_lock, flags); 464 spin_lock_irqsave(&timr->it_lock, flags);
483 set_timer_inactive(timr);
484 if (!list_empty(&timr->it.real.abs_timer_entry)) { 465 if (!list_empty(&timr->it.real.abs_timer_entry)) {
485 spin_lock(&abs_list.lock); 466 spin_lock(&abs_list.lock);
486 do { 467 do {
@@ -983,8 +964,8 @@ common_timer_set(struct k_itimer *timr, int flags,
983 * careful here. If smp we could be in the "fire" routine which will 964 * careful here. If smp we could be in the "fire" routine which will
984 * be spinning as we hold the lock. But this is ONLY an SMP issue. 965 * be spinning as we hold the lock. But this is ONLY an SMP issue.
985 */ 966 */
967 if (try_to_del_timer_sync(&timr->it.real.timer) < 0) {
986#ifdef CONFIG_SMP 968#ifdef CONFIG_SMP
987 if (timer_active(timr) && !del_timer(&timr->it.real.timer))
988 /* 969 /*
989 * It can only be active if on an other cpu. Since 970 * It can only be active if on an other cpu. Since
990 * we have cleared the interval stuff above, it should 971 * we have cleared the interval stuff above, it should
@@ -994,11 +975,9 @@ common_timer_set(struct k_itimer *timr, int flags,
994 * a "retry" exit status. 975 * a "retry" exit status.
995 */ 976 */
996 return TIMER_RETRY; 977 return TIMER_RETRY;
997
998 set_timer_inactive(timr);
999#else
1000 del_timer(&timr->it.real.timer);
1001#endif 978#endif
979 }
980
1002 remove_from_abslist(timr); 981 remove_from_abslist(timr);
1003 982
1004 timr->it_requeue_pending = (timr->it_requeue_pending + 2) & 983 timr->it_requeue_pending = (timr->it_requeue_pending + 2) &
@@ -1083,8 +1062,9 @@ retry:
1083static inline int common_timer_del(struct k_itimer *timer) 1062static inline int common_timer_del(struct k_itimer *timer)
1084{ 1063{
1085 timer->it.real.incr = 0; 1064 timer->it.real.incr = 0;
1065
1066 if (try_to_del_timer_sync(&timer->it.real.timer) < 0) {
1086#ifdef CONFIG_SMP 1067#ifdef CONFIG_SMP
1087 if (timer_active(timer) && !del_timer(&timer->it.real.timer))
1088 /* 1068 /*
1089 * It can only be active if on an other cpu. Since 1069 * It can only be active if on an other cpu. Since
1090 * we have cleared the interval stuff above, it should 1070 * we have cleared the interval stuff above, it should
@@ -1094,9 +1074,9 @@ static inline int common_timer_del(struct k_itimer *timer)
1094 * a "retry" exit status. 1074 * a "retry" exit status.
1095 */ 1075 */
1096 return TIMER_RETRY; 1076 return TIMER_RETRY;
1097#else
1098 del_timer(&timer->it.real.timer);
1099#endif 1077#endif
1078 }
1079
1100 remove_from_abslist(timer); 1080 remove_from_abslist(timer);
1101 1081
1102 return 0; 1082 return 0;
diff --git a/kernel/printk.c b/kernel/printk.c
index 01b58d7d17ff..3a442bfb8bee 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -876,8 +876,10 @@ void register_console(struct console * console)
876 break; 876 break;
877 console->flags |= CON_ENABLED; 877 console->flags |= CON_ENABLED;
878 console->index = console_cmdline[i].index; 878 console->index = console_cmdline[i].index;
879 if (i == preferred_console) 879 if (i == selected_console) {
880 console->flags |= CON_CONSDEV; 880 console->flags |= CON_CONSDEV;
881 preferred_console = selected_console;
882 }
881 break; 883 break;
882 } 884 }
883 885
@@ -897,6 +899,8 @@ void register_console(struct console * console)
897 if ((console->flags & CON_CONSDEV) || console_drivers == NULL) { 899 if ((console->flags & CON_CONSDEV) || console_drivers == NULL) {
898 console->next = console_drivers; 900 console->next = console_drivers;
899 console_drivers = console; 901 console_drivers = console;
902 if (console->next)
903 console->next->flags &= ~CON_CONSDEV;
900 } else { 904 } else {
901 console->next = console_drivers->next; 905 console->next = console_drivers->next;
902 console_drivers->next = console; 906 console_drivers->next = console;
@@ -937,10 +941,14 @@ int unregister_console(struct console * console)
937 /* If last console is removed, we re-enable picking the first 941 /* If last console is removed, we re-enable picking the first
938 * one that gets registered. Without that, pmac early boot console 942 * one that gets registered. Without that, pmac early boot console
939 * would prevent fbcon from taking over. 943 * would prevent fbcon from taking over.
944 *
945 * If this isn't the last console and it has CON_CONSDEV set, we
946 * need to set it on the next preferred console.
940 */ 947 */
941 if (console_drivers == NULL) 948 if (console_drivers == NULL)
942 preferred_console = selected_console; 949 preferred_console = selected_console;
943 950 else if (console->flags & CON_CONSDEV)
951 console_drivers->flags |= CON_CONSDEV;
944 952
945 release_console_sem(); 953 release_console_sem();
946 return res; 954 return res;
diff --git a/kernel/sched.c b/kernel/sched.c
index deca041fc364..76080d142e3d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2576,7 +2576,7 @@ void fastcall add_preempt_count(int val)
2576 /* 2576 /*
2577 * Underflow? 2577 * Underflow?
2578 */ 2578 */
2579 BUG_ON(((int)preempt_count() < 0)); 2579 BUG_ON((preempt_count() < 0));
2580 preempt_count() += val; 2580 preempt_count() += val;
2581 /* 2581 /*
2582 * Spinlock count overflowing soon? 2582 * Spinlock count overflowing soon?
@@ -2869,7 +2869,7 @@ need_resched:
2869 2869
2870int default_wake_function(wait_queue_t *curr, unsigned mode, int sync, void *key) 2870int default_wake_function(wait_queue_t *curr, unsigned mode, int sync, void *key)
2871{ 2871{
2872 task_t *p = curr->task; 2872 task_t *p = curr->private;
2873 return try_to_wake_up(p, mode, sync); 2873 return try_to_wake_up(p, mode, sync);
2874} 2874}
2875 2875
diff --git a/kernel/signal.c b/kernel/signal.c
index c89821b69ae3..d1258729a5f9 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -213,6 +213,7 @@ static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
213fastcall void recalc_sigpending_tsk(struct task_struct *t) 213fastcall void recalc_sigpending_tsk(struct task_struct *t)
214{ 214{
215 if (t->signal->group_stop_count > 0 || 215 if (t->signal->group_stop_count > 0 ||
216 (t->flags & PF_FREEZE) ||
216 PENDING(&t->pending, &t->blocked) || 217 PENDING(&t->pending, &t->blocked) ||
217 PENDING(&t->signal->shared_pending, &t->blocked)) 218 PENDING(&t->signal->shared_pending, &t->blocked))
218 set_tsk_thread_flag(t, TIF_SIGPENDING); 219 set_tsk_thread_flag(t, TIF_SIGPENDING);
diff --git a/kernel/sys.c b/kernel/sys.c
index f006632c2ba7..5a9d6b075016 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -525,7 +525,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
525 } 525 }
526 if (new_egid != old_egid) 526 if (new_egid != old_egid)
527 { 527 {
528 current->mm->dumpable = 0; 528 current->mm->dumpable = suid_dumpable;
529 smp_wmb(); 529 smp_wmb();
530 } 530 }
531 if (rgid != (gid_t) -1 || 531 if (rgid != (gid_t) -1 ||
@@ -556,7 +556,7 @@ asmlinkage long sys_setgid(gid_t gid)
556 { 556 {
557 if(old_egid != gid) 557 if(old_egid != gid)
558 { 558 {
559 current->mm->dumpable=0; 559 current->mm->dumpable = suid_dumpable;
560 smp_wmb(); 560 smp_wmb();
561 } 561 }
562 current->gid = current->egid = current->sgid = current->fsgid = gid; 562 current->gid = current->egid = current->sgid = current->fsgid = gid;
@@ -565,7 +565,7 @@ asmlinkage long sys_setgid(gid_t gid)
565 { 565 {
566 if(old_egid != gid) 566 if(old_egid != gid)
567 { 567 {
568 current->mm->dumpable=0; 568 current->mm->dumpable = suid_dumpable;
569 smp_wmb(); 569 smp_wmb();
570 } 570 }
571 current->egid = current->fsgid = gid; 571 current->egid = current->fsgid = gid;
@@ -596,7 +596,7 @@ static int set_user(uid_t new_ruid, int dumpclear)
596 596
597 if(dumpclear) 597 if(dumpclear)
598 { 598 {
599 current->mm->dumpable = 0; 599 current->mm->dumpable = suid_dumpable;
600 smp_wmb(); 600 smp_wmb();
601 } 601 }
602 current->uid = new_ruid; 602 current->uid = new_ruid;
@@ -653,7 +653,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
653 653
654 if (new_euid != old_euid) 654 if (new_euid != old_euid)
655 { 655 {
656 current->mm->dumpable=0; 656 current->mm->dumpable = suid_dumpable;
657 smp_wmb(); 657 smp_wmb();
658 } 658 }
659 current->fsuid = current->euid = new_euid; 659 current->fsuid = current->euid = new_euid;
@@ -703,7 +703,7 @@ asmlinkage long sys_setuid(uid_t uid)
703 703
704 if (old_euid != uid) 704 if (old_euid != uid)
705 { 705 {
706 current->mm->dumpable = 0; 706 current->mm->dumpable = suid_dumpable;
707 smp_wmb(); 707 smp_wmb();
708 } 708 }
709 current->fsuid = current->euid = uid; 709 current->fsuid = current->euid = uid;
@@ -748,7 +748,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
748 if (euid != (uid_t) -1) { 748 if (euid != (uid_t) -1) {
749 if (euid != current->euid) 749 if (euid != current->euid)
750 { 750 {
751 current->mm->dumpable = 0; 751 current->mm->dumpable = suid_dumpable;
752 smp_wmb(); 752 smp_wmb();
753 } 753 }
754 current->euid = euid; 754 current->euid = euid;
@@ -798,7 +798,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
798 if (egid != (gid_t) -1) { 798 if (egid != (gid_t) -1) {
799 if (egid != current->egid) 799 if (egid != current->egid)
800 { 800 {
801 current->mm->dumpable = 0; 801 current->mm->dumpable = suid_dumpable;
802 smp_wmb(); 802 smp_wmb();
803 } 803 }
804 current->egid = egid; 804 current->egid = egid;
@@ -845,7 +845,7 @@ asmlinkage long sys_setfsuid(uid_t uid)
845 { 845 {
846 if (uid != old_fsuid) 846 if (uid != old_fsuid)
847 { 847 {
848 current->mm->dumpable = 0; 848 current->mm->dumpable = suid_dumpable;
849 smp_wmb(); 849 smp_wmb();
850 } 850 }
851 current->fsuid = uid; 851 current->fsuid = uid;
@@ -875,7 +875,7 @@ asmlinkage long sys_setfsgid(gid_t gid)
875 { 875 {
876 if (gid != old_fsgid) 876 if (gid != old_fsgid)
877 { 877 {
878 current->mm->dumpable = 0; 878 current->mm->dumpable = suid_dumpable;
879 smp_wmb(); 879 smp_wmb();
880 } 880 }
881 current->fsgid = gid; 881 current->fsgid = gid;
@@ -894,35 +894,69 @@ asmlinkage long sys_times(struct tms __user * tbuf)
894 */ 894 */
895 if (tbuf) { 895 if (tbuf) {
896 struct tms tmp; 896 struct tms tmp;
897 struct task_struct *tsk = current;
898 struct task_struct *t;
899 cputime_t utime, stime, cutime, cstime; 897 cputime_t utime, stime, cutime, cstime;
900 898
901 read_lock(&tasklist_lock); 899#ifdef CONFIG_SMP
902 utime = tsk->signal->utime; 900 if (thread_group_empty(current)) {
903 stime = tsk->signal->stime; 901 /*
904 t = tsk; 902 * Single thread case without the use of any locks.
905 do { 903 *
906 utime = cputime_add(utime, t->utime); 904 * We may race with release_task if two threads are
907 stime = cputime_add(stime, t->stime); 905 * executing. However, release task first adds up the
908 t = next_thread(t); 906 * counters (__exit_signal) before removing the task
909 } while (t != tsk); 907 * from the process tasklist (__unhash_process).
910 908 * __exit_signal also acquires and releases the
911 /* 909 * siglock which results in the proper memory ordering
912 * While we have tasklist_lock read-locked, no dying thread 910 * so that the list modifications are always visible
913 * can be updating current->signal->[us]time. Instead, 911 * after the counters have been updated.
914 * we got their counts included in the live thread loop. 912 *
915 * However, another thread can come in right now and 913 * If the counters have been updated by the second thread
916 * do a wait call that updates current->signal->c[us]time. 914 * but the thread has not yet been removed from the list
917 * To make sure we always see that pair updated atomically, 915 * then the other branch will be executing which will
918 * we take the siglock around fetching them. 916 * block on tasklist_lock until the exit handling of the
919 */ 917 * other task is finished.
920 spin_lock_irq(&tsk->sighand->siglock); 918 *
921 cutime = tsk->signal->cutime; 919 * This also implies that the sighand->siglock cannot
922 cstime = tsk->signal->cstime; 920 * be held by another processor. So we can also
923 spin_unlock_irq(&tsk->sighand->siglock); 921 * skip acquiring that lock.
924 read_unlock(&tasklist_lock); 922 */
923 utime = cputime_add(current->signal->utime, current->utime);
924 stime = cputime_add(current->signal->utime, current->stime);
925 cutime = current->signal->cutime;
926 cstime = current->signal->cstime;
927 } else
928#endif
929 {
930
931 /* Process with multiple threads */
932 struct task_struct *tsk = current;
933 struct task_struct *t;
925 934
935 read_lock(&tasklist_lock);
936 utime = tsk->signal->utime;
937 stime = tsk->signal->stime;
938 t = tsk;
939 do {
940 utime = cputime_add(utime, t->utime);
941 stime = cputime_add(stime, t->stime);
942 t = next_thread(t);
943 } while (t != tsk);
944
945 /*
946 * While we have tasklist_lock read-locked, no dying thread
947 * can be updating current->signal->[us]time. Instead,
948 * we got their counts included in the live thread loop.
949 * However, another thread can come in right now and
950 * do a wait call that updates current->signal->c[us]time.
951 * To make sure we always see that pair updated atomically,
952 * we take the siglock around fetching them.
953 */
954 spin_lock_irq(&tsk->sighand->siglock);
955 cutime = tsk->signal->cutime;
956 cstime = tsk->signal->cstime;
957 spin_unlock_irq(&tsk->sighand->siglock);
958 read_unlock(&tasklist_lock);
959 }
926 tmp.tms_utime = cputime_to_clock_t(utime); 960 tmp.tms_utime = cputime_to_clock_t(utime);
927 tmp.tms_stime = cputime_to_clock_t(stime); 961 tmp.tms_stime = cputime_to_clock_t(stime);
928 tmp.tms_cutime = cputime_to_clock_t(cutime); 962 tmp.tms_cutime = cputime_to_clock_t(cutime);
@@ -1652,7 +1686,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
1652 error = 1; 1686 error = 1;
1653 break; 1687 break;
1654 case PR_SET_DUMPABLE: 1688 case PR_SET_DUMPABLE:
1655 if (arg2 != 0 && arg2 != 1) { 1689 if (arg2 < 0 || arg2 > 2) {
1656 error = -EINVAL; 1690 error = -EINVAL;
1657 break; 1691 break;
1658 } 1692 }
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 701d12c63068..24a4d12d5aa9 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -58,6 +58,7 @@ extern int sysctl_overcommit_ratio;
58extern int max_threads; 58extern int max_threads;
59extern int sysrq_enabled; 59extern int sysrq_enabled;
60extern int core_uses_pid; 60extern int core_uses_pid;
61extern int suid_dumpable;
61extern char core_pattern[]; 62extern char core_pattern[];
62extern int cad_pid; 63extern int cad_pid;
63extern int pid_max; 64extern int pid_max;
@@ -950,6 +951,14 @@ static ctl_table fs_table[] = {
950 .proc_handler = &proc_dointvec, 951 .proc_handler = &proc_dointvec,
951 }, 952 },
952#endif 953#endif
954 {
955 .ctl_name = KERN_SETUID_DUMPABLE,
956 .procname = "suid_dumpable",
957 .data = &suid_dumpable,
958 .maxlen = sizeof(int),
959 .mode = 0644,
960 .proc_handler = &proc_dointvec,
961 },
953 { .ctl_name = 0 } 962 { .ctl_name = 0 }
954}; 963};
955 964
diff --git a/kernel/timer.c b/kernel/timer.c
index 207aa4f0aa10..51ff917c9590 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -57,6 +57,11 @@ static void time_interpolator_update(long delta_nsec);
57#define TVN_MASK (TVN_SIZE - 1) 57#define TVN_MASK (TVN_SIZE - 1)
58#define TVR_MASK (TVR_SIZE - 1) 58#define TVR_MASK (TVR_SIZE - 1)
59 59
60struct timer_base_s {
61 spinlock_t lock;
62 struct timer_list *running_timer;
63};
64
60typedef struct tvec_s { 65typedef struct tvec_s {
61 struct list_head vec[TVN_SIZE]; 66 struct list_head vec[TVN_SIZE];
62} tvec_t; 67} tvec_t;
@@ -66,9 +71,8 @@ typedef struct tvec_root_s {
66} tvec_root_t; 71} tvec_root_t;
67 72
68struct tvec_t_base_s { 73struct tvec_t_base_s {
69 spinlock_t lock; 74 struct timer_base_s t_base;
70 unsigned long timer_jiffies; 75 unsigned long timer_jiffies;
71 struct timer_list *running_timer;
72 tvec_root_t tv1; 76 tvec_root_t tv1;
73 tvec_t tv2; 77 tvec_t tv2;
74 tvec_t tv3; 78 tvec_t tv3;
@@ -77,18 +81,16 @@ struct tvec_t_base_s {
77} ____cacheline_aligned_in_smp; 81} ____cacheline_aligned_in_smp;
78 82
79typedef struct tvec_t_base_s tvec_base_t; 83typedef struct tvec_t_base_s tvec_base_t;
84static DEFINE_PER_CPU(tvec_base_t, tvec_bases);
80 85
81static inline void set_running_timer(tvec_base_t *base, 86static inline void set_running_timer(tvec_base_t *base,
82 struct timer_list *timer) 87 struct timer_list *timer)
83{ 88{
84#ifdef CONFIG_SMP 89#ifdef CONFIG_SMP
85 base->running_timer = timer; 90 base->t_base.running_timer = timer;
86#endif 91#endif
87} 92}
88 93
89/* Fake initialization */
90static DEFINE_PER_CPU(tvec_base_t, tvec_bases) = { SPIN_LOCK_UNLOCKED };
91
92static void check_timer_failed(struct timer_list *timer) 94static void check_timer_failed(struct timer_list *timer)
93{ 95{
94 static int whine_count; 96 static int whine_count;
@@ -103,7 +105,6 @@ static void check_timer_failed(struct timer_list *timer)
103 /* 105 /*
104 * Now fix it up 106 * Now fix it up
105 */ 107 */
106 spin_lock_init(&timer->lock);
107 timer->magic = TIMER_MAGIC; 108 timer->magic = TIMER_MAGIC;
108} 109}
109 110
@@ -156,65 +157,113 @@ static void internal_add_timer(tvec_base_t *base, struct timer_list *timer)
156 list_add_tail(&timer->entry, vec); 157 list_add_tail(&timer->entry, vec);
157} 158}
158 159
160typedef struct timer_base_s timer_base_t;
161/*
162 * Used by TIMER_INITIALIZER, we can't use per_cpu(tvec_bases)
163 * at compile time, and we need timer->base to lock the timer.
164 */
165timer_base_t __init_timer_base
166 ____cacheline_aligned_in_smp = { .lock = SPIN_LOCK_UNLOCKED };
167EXPORT_SYMBOL(__init_timer_base);
168
169/***
170 * init_timer - initialize a timer.
171 * @timer: the timer to be initialized
172 *
173 * init_timer() must be done to a timer prior calling *any* of the
174 * other timer functions.
175 */
176void fastcall init_timer(struct timer_list *timer)
177{
178 timer->entry.next = NULL;
179 timer->base = &per_cpu(tvec_bases, raw_smp_processor_id()).t_base;
180 timer->magic = TIMER_MAGIC;
181}
182EXPORT_SYMBOL(init_timer);
183
184static inline void detach_timer(struct timer_list *timer,
185 int clear_pending)
186{
187 struct list_head *entry = &timer->entry;
188
189 __list_del(entry->prev, entry->next);
190 if (clear_pending)
191 entry->next = NULL;
192 entry->prev = LIST_POISON2;
193}
194
195/*
196 * We are using hashed locking: holding per_cpu(tvec_bases).t_base.lock
197 * means that all timers which are tied to this base via timer->base are
198 * locked, and the base itself is locked too.
199 *
200 * So __run_timers/migrate_timers can safely modify all timers which could
201 * be found on ->tvX lists.
202 *
203 * When the timer's base is locked, and the timer removed from list, it is
204 * possible to set timer->base = NULL and drop the lock: the timer remains
205 * locked.
206 */
207static timer_base_t *lock_timer_base(struct timer_list *timer,
208 unsigned long *flags)
209{
210 timer_base_t *base;
211
212 for (;;) {
213 base = timer->base;
214 if (likely(base != NULL)) {
215 spin_lock_irqsave(&base->lock, *flags);
216 if (likely(base == timer->base))
217 return base;
218 /* The timer has migrated to another CPU */
219 spin_unlock_irqrestore(&base->lock, *flags);
220 }
221 cpu_relax();
222 }
223}
224
159int __mod_timer(struct timer_list *timer, unsigned long expires) 225int __mod_timer(struct timer_list *timer, unsigned long expires)
160{ 226{
161 tvec_base_t *old_base, *new_base; 227 timer_base_t *base;
228 tvec_base_t *new_base;
162 unsigned long flags; 229 unsigned long flags;
163 int ret = 0; 230 int ret = 0;
164 231
165 BUG_ON(!timer->function); 232 BUG_ON(!timer->function);
166
167 check_timer(timer); 233 check_timer(timer);
168 234
169 spin_lock_irqsave(&timer->lock, flags); 235 base = lock_timer_base(timer, &flags);
236
237 if (timer_pending(timer)) {
238 detach_timer(timer, 0);
239 ret = 1;
240 }
241
170 new_base = &__get_cpu_var(tvec_bases); 242 new_base = &__get_cpu_var(tvec_bases);
171repeat:
172 old_base = timer->base;
173 243
174 /* 244 if (base != &new_base->t_base) {
175 * Prevent deadlocks via ordering by old_base < new_base.
176 */
177 if (old_base && (new_base != old_base)) {
178 if (old_base < new_base) {
179 spin_lock(&new_base->lock);
180 spin_lock(&old_base->lock);
181 } else {
182 spin_lock(&old_base->lock);
183 spin_lock(&new_base->lock);
184 }
185 /* 245 /*
186 * The timer base might have been cancelled while we were 246 * We are trying to schedule the timer on the local CPU.
187 * trying to take the lock(s): 247 * However we can't change timer's base while it is running,
248 * otherwise del_timer_sync() can't detect that the timer's
249 * handler yet has not finished. This also guarantees that
250 * the timer is serialized wrt itself.
188 */ 251 */
189 if (timer->base != old_base) { 252 if (unlikely(base->running_timer == timer)) {
190 spin_unlock(&new_base->lock); 253 /* The timer remains on a former base */
191 spin_unlock(&old_base->lock); 254 new_base = container_of(base, tvec_base_t, t_base);
192 goto repeat; 255 } else {
193 } 256 /* See the comment in lock_timer_base() */
194 } else { 257 timer->base = NULL;
195 spin_lock(&new_base->lock); 258 spin_unlock(&base->lock);
196 if (timer->base != old_base) { 259 spin_lock(&new_base->t_base.lock);
197 spin_unlock(&new_base->lock); 260 timer->base = &new_base->t_base;
198 goto repeat;
199 } 261 }
200 } 262 }
201 263
202 /*
203 * Delete the previous timeout (if there was any), and install
204 * the new one:
205 */
206 if (old_base) {
207 list_del(&timer->entry);
208 ret = 1;
209 }
210 timer->expires = expires; 264 timer->expires = expires;
211 internal_add_timer(new_base, timer); 265 internal_add_timer(new_base, timer);
212 timer->base = new_base; 266 spin_unlock_irqrestore(&new_base->t_base.lock, flags);
213
214 if (old_base && (new_base != old_base))
215 spin_unlock(&old_base->lock);
216 spin_unlock(&new_base->lock);
217 spin_unlock_irqrestore(&timer->lock, flags);
218 267
219 return ret; 268 return ret;
220} 269}
@@ -232,15 +281,15 @@ void add_timer_on(struct timer_list *timer, int cpu)
232{ 281{
233 tvec_base_t *base = &per_cpu(tvec_bases, cpu); 282 tvec_base_t *base = &per_cpu(tvec_bases, cpu);
234 unsigned long flags; 283 unsigned long flags;
235 284
236 BUG_ON(timer_pending(timer) || !timer->function); 285 BUG_ON(timer_pending(timer) || !timer->function);
237 286
238 check_timer(timer); 287 check_timer(timer);
239 288
240 spin_lock_irqsave(&base->lock, flags); 289 spin_lock_irqsave(&base->t_base.lock, flags);
290 timer->base = &base->t_base;
241 internal_add_timer(base, timer); 291 internal_add_timer(base, timer);
242 timer->base = base; 292 spin_unlock_irqrestore(&base->t_base.lock, flags);
243 spin_unlock_irqrestore(&base->lock, flags);
244} 293}
245 294
246 295
@@ -295,109 +344,84 @@ EXPORT_SYMBOL(mod_timer);
295 */ 344 */
296int del_timer(struct timer_list *timer) 345int del_timer(struct timer_list *timer)
297{ 346{
347 timer_base_t *base;
298 unsigned long flags; 348 unsigned long flags;
299 tvec_base_t *base; 349 int ret = 0;
300 350
301 check_timer(timer); 351 check_timer(timer);
302 352
303repeat: 353 if (timer_pending(timer)) {
304 base = timer->base; 354 base = lock_timer_base(timer, &flags);
305 if (!base) 355 if (timer_pending(timer)) {
306 return 0; 356 detach_timer(timer, 1);
307 spin_lock_irqsave(&base->lock, flags); 357 ret = 1;
308 if (base != timer->base) { 358 }
309 spin_unlock_irqrestore(&base->lock, flags); 359 spin_unlock_irqrestore(&base->lock, flags);
310 goto repeat;
311 } 360 }
312 list_del(&timer->entry);
313 /* Need to make sure that anybody who sees a NULL base also sees the list ops */
314 smp_wmb();
315 timer->base = NULL;
316 spin_unlock_irqrestore(&base->lock, flags);
317 361
318 return 1; 362 return ret;
319} 363}
320 364
321EXPORT_SYMBOL(del_timer); 365EXPORT_SYMBOL(del_timer);
322 366
323#ifdef CONFIG_SMP 367#ifdef CONFIG_SMP
324/*** 368/*
325 * del_timer_sync - deactivate a timer and wait for the handler to finish. 369 * This function tries to deactivate a timer. Upon successful (ret >= 0)
326 * @timer: the timer to be deactivated 370 * exit the timer is not queued and the handler is not running on any CPU.
327 *
328 * This function only differs from del_timer() on SMP: besides deactivating
329 * the timer it also makes sure the handler has finished executing on other
330 * CPUs.
331 *
332 * Synchronization rules: callers must prevent restarting of the timer,
333 * otherwise this function is meaningless. It must not be called from
334 * interrupt contexts. The caller must not hold locks which would prevent
335 * completion of the timer's handler. Upon exit the timer is not queued and
336 * the handler is not running on any CPU.
337 *
338 * The function returns whether it has deactivated a pending timer or not.
339 * 371 *
340 * del_timer_sync() is slow and complicated because it copes with timer 372 * It must not be called from interrupt contexts.
341 * handlers which re-arm the timer (periodic timers). If the timer handler
342 * is known to not do this (a single shot timer) then use
343 * del_singleshot_timer_sync() instead.
344 */ 373 */
345int del_timer_sync(struct timer_list *timer) 374int try_to_del_timer_sync(struct timer_list *timer)
346{ 375{
347 tvec_base_t *base; 376 timer_base_t *base;
348 int i, ret = 0; 377 unsigned long flags;
378 int ret = -1;
349 379
350 check_timer(timer); 380 base = lock_timer_base(timer, &flags);
351 381
352del_again: 382 if (base->running_timer == timer)
353 ret += del_timer(timer); 383 goto out;
354 384
355 for_each_online_cpu(i) { 385 ret = 0;
356 base = &per_cpu(tvec_bases, i); 386 if (timer_pending(timer)) {
357 if (base->running_timer == timer) { 387 detach_timer(timer, 1);
358 while (base->running_timer == timer) { 388 ret = 1;
359 cpu_relax();
360 preempt_check_resched();
361 }
362 break;
363 }
364 } 389 }
365 smp_rmb(); 390out:
366 if (timer_pending(timer)) 391 spin_unlock_irqrestore(&base->lock, flags);
367 goto del_again;
368 392
369 return ret; 393 return ret;
370} 394}
371EXPORT_SYMBOL(del_timer_sync);
372 395
373/*** 396/***
374 * del_singleshot_timer_sync - deactivate a non-recursive timer 397 * del_timer_sync - deactivate a timer and wait for the handler to finish.
375 * @timer: the timer to be deactivated 398 * @timer: the timer to be deactivated
376 * 399 *
377 * This function is an optimization of del_timer_sync for the case where the 400 * This function only differs from del_timer() on SMP: besides deactivating
378 * caller can guarantee the timer does not reschedule itself in its timer 401 * the timer it also makes sure the handler has finished executing on other
379 * function. 402 * CPUs.
380 * 403 *
381 * Synchronization rules: callers must prevent restarting of the timer, 404 * Synchronization rules: callers must prevent restarting of the timer,
382 * otherwise this function is meaningless. It must not be called from 405 * otherwise this function is meaningless. It must not be called from
383 * interrupt contexts. The caller must not hold locks which wold prevent 406 * interrupt contexts. The caller must not hold locks which would prevent
384 * completion of the timer's handler. Upon exit the timer is not queued and 407 * completion of the timer's handler. The timer's handler must not call
385 * the handler is not running on any CPU. 408 * add_timer_on(). Upon exit the timer is not queued and the handler is
409 * not running on any CPU.
386 * 410 *
387 * The function returns whether it has deactivated a pending timer or not. 411 * The function returns whether it has deactivated a pending timer or not.
388 */ 412 */
389int del_singleshot_timer_sync(struct timer_list *timer) 413int del_timer_sync(struct timer_list *timer)
390{ 414{
391 int ret = del_timer(timer); 415 check_timer(timer);
392 416
393 if (!ret) { 417 for (;;) {
394 ret = del_timer_sync(timer); 418 int ret = try_to_del_timer_sync(timer);
395 BUG_ON(ret); 419 if (ret >= 0)
420 return ret;
396 } 421 }
397
398 return ret;
399} 422}
400EXPORT_SYMBOL(del_singleshot_timer_sync); 423
424EXPORT_SYMBOL(del_timer_sync);
401#endif 425#endif
402 426
403static int cascade(tvec_base_t *base, tvec_t *tv, int index) 427static int cascade(tvec_base_t *base, tvec_t *tv, int index)
@@ -415,7 +439,7 @@ static int cascade(tvec_base_t *base, tvec_t *tv, int index)
415 struct timer_list *tmp; 439 struct timer_list *tmp;
416 440
417 tmp = list_entry(curr, struct timer_list, entry); 441 tmp = list_entry(curr, struct timer_list, entry);
418 BUG_ON(tmp->base != base); 442 BUG_ON(tmp->base != &base->t_base);
419 curr = curr->next; 443 curr = curr->next;
420 internal_add_timer(base, tmp); 444 internal_add_timer(base, tmp);
421 } 445 }
@@ -437,7 +461,7 @@ static inline void __run_timers(tvec_base_t *base)
437{ 461{
438 struct timer_list *timer; 462 struct timer_list *timer;
439 463
440 spin_lock_irq(&base->lock); 464 spin_lock_irq(&base->t_base.lock);
441 while (time_after_eq(jiffies, base->timer_jiffies)) { 465 while (time_after_eq(jiffies, base->timer_jiffies)) {
442 struct list_head work_list = LIST_HEAD_INIT(work_list); 466 struct list_head work_list = LIST_HEAD_INIT(work_list);
443 struct list_head *head = &work_list; 467 struct list_head *head = &work_list;
@@ -453,8 +477,7 @@ static inline void __run_timers(tvec_base_t *base)
453 cascade(base, &base->tv5, INDEX(3)); 477 cascade(base, &base->tv5, INDEX(3));
454 ++base->timer_jiffies; 478 ++base->timer_jiffies;
455 list_splice_init(base->tv1.vec + index, &work_list); 479 list_splice_init(base->tv1.vec + index, &work_list);
456repeat: 480 while (!list_empty(head)) {
457 if (!list_empty(head)) {
458 void (*fn)(unsigned long); 481 void (*fn)(unsigned long);
459 unsigned long data; 482 unsigned long data;
460 483
@@ -462,25 +485,26 @@ repeat:
462 fn = timer->function; 485 fn = timer->function;
463 data = timer->data; 486 data = timer->data;
464 487
465 list_del(&timer->entry);
466 set_running_timer(base, timer); 488 set_running_timer(base, timer);
467 smp_wmb(); 489 detach_timer(timer, 1);
468 timer->base = NULL; 490 spin_unlock_irq(&base->t_base.lock);
469 spin_unlock_irq(&base->lock);
470 { 491 {
471 u32 preempt_count = preempt_count(); 492 int preempt_count = preempt_count();
472 fn(data); 493 fn(data);
473 if (preempt_count != preempt_count()) { 494 if (preempt_count != preempt_count()) {
474 printk("huh, entered %p with %08x, exited with %08x?\n", fn, preempt_count, preempt_count()); 495 printk(KERN_WARNING "huh, entered %p "
496 "with preempt_count %08x, exited"
497 " with %08x?\n",
498 fn, preempt_count,
499 preempt_count());
475 BUG(); 500 BUG();
476 } 501 }
477 } 502 }
478 spin_lock_irq(&base->lock); 503 spin_lock_irq(&base->t_base.lock);
479 goto repeat;
480 } 504 }
481 } 505 }
482 set_running_timer(base, NULL); 506 set_running_timer(base, NULL);
483 spin_unlock_irq(&base->lock); 507 spin_unlock_irq(&base->t_base.lock);
484} 508}
485 509
486#ifdef CONFIG_NO_IDLE_HZ 510#ifdef CONFIG_NO_IDLE_HZ
@@ -499,7 +523,7 @@ unsigned long next_timer_interrupt(void)
499 int i, j; 523 int i, j;
500 524
501 base = &__get_cpu_var(tvec_bases); 525 base = &__get_cpu_var(tvec_bases);
502 spin_lock(&base->lock); 526 spin_lock(&base->t_base.lock);
503 expires = base->timer_jiffies + (LONG_MAX >> 1); 527 expires = base->timer_jiffies + (LONG_MAX >> 1);
504 list = 0; 528 list = 0;
505 529
@@ -547,7 +571,7 @@ found:
547 expires = nte->expires; 571 expires = nte->expires;
548 } 572 }
549 } 573 }
550 spin_unlock(&base->lock); 574 spin_unlock(&base->t_base.lock);
551 return expires; 575 return expires;
552} 576}
553#endif 577#endif
@@ -1286,9 +1310,9 @@ static void __devinit init_timers_cpu(int cpu)
1286{ 1310{
1287 int j; 1311 int j;
1288 tvec_base_t *base; 1312 tvec_base_t *base;
1289 1313
1290 base = &per_cpu(tvec_bases, cpu); 1314 base = &per_cpu(tvec_bases, cpu);
1291 spin_lock_init(&base->lock); 1315 spin_lock_init(&base->t_base.lock);
1292 for (j = 0; j < TVN_SIZE; j++) { 1316 for (j = 0; j < TVN_SIZE; j++) {
1293 INIT_LIST_HEAD(base->tv5.vec + j); 1317 INIT_LIST_HEAD(base->tv5.vec + j);
1294 INIT_LIST_HEAD(base->tv4.vec + j); 1318 INIT_LIST_HEAD(base->tv4.vec + j);
@@ -1302,22 +1326,16 @@ static void __devinit init_timers_cpu(int cpu)
1302} 1326}
1303 1327
1304#ifdef CONFIG_HOTPLUG_CPU 1328#ifdef CONFIG_HOTPLUG_CPU
1305static int migrate_timer_list(tvec_base_t *new_base, struct list_head *head) 1329static void migrate_timer_list(tvec_base_t *new_base, struct list_head *head)
1306{ 1330{
1307 struct timer_list *timer; 1331 struct timer_list *timer;
1308 1332
1309 while (!list_empty(head)) { 1333 while (!list_empty(head)) {
1310 timer = list_entry(head->next, struct timer_list, entry); 1334 timer = list_entry(head->next, struct timer_list, entry);
1311 /* We're locking backwards from __mod_timer order here, 1335 detach_timer(timer, 0);
1312 beware deadlock. */ 1336 timer->base = &new_base->t_base;
1313 if (!spin_trylock(&timer->lock))
1314 return 0;
1315 list_del(&timer->entry);
1316 internal_add_timer(new_base, timer); 1337 internal_add_timer(new_base, timer);
1317 timer->base = new_base;
1318 spin_unlock(&timer->lock);
1319 } 1338 }
1320 return 1;
1321} 1339}
1322 1340
1323static void __devinit migrate_timers(int cpu) 1341static void __devinit migrate_timers(int cpu)
@@ -1331,39 +1349,24 @@ static void __devinit migrate_timers(int cpu)
1331 new_base = &get_cpu_var(tvec_bases); 1349 new_base = &get_cpu_var(tvec_bases);
1332 1350
1333 local_irq_disable(); 1351 local_irq_disable();
1334again: 1352 spin_lock(&new_base->t_base.lock);
1335 /* Prevent deadlocks via ordering by old_base < new_base. */ 1353 spin_lock(&old_base->t_base.lock);
1336 if (old_base < new_base) {
1337 spin_lock(&new_base->lock);
1338 spin_lock(&old_base->lock);
1339 } else {
1340 spin_lock(&old_base->lock);
1341 spin_lock(&new_base->lock);
1342 }
1343 1354
1344 if (old_base->running_timer) 1355 if (old_base->t_base.running_timer)
1345 BUG(); 1356 BUG();
1346 for (i = 0; i < TVR_SIZE; i++) 1357 for (i = 0; i < TVR_SIZE; i++)
1347 if (!migrate_timer_list(new_base, old_base->tv1.vec + i)) 1358 migrate_timer_list(new_base, old_base->tv1.vec + i);
1348 goto unlock_again; 1359 for (i = 0; i < TVN_SIZE; i++) {
1349 for (i = 0; i < TVN_SIZE; i++) 1360 migrate_timer_list(new_base, old_base->tv2.vec + i);
1350 if (!migrate_timer_list(new_base, old_base->tv2.vec + i) 1361 migrate_timer_list(new_base, old_base->tv3.vec + i);
1351 || !migrate_timer_list(new_base, old_base->tv3.vec + i) 1362 migrate_timer_list(new_base, old_base->tv4.vec + i);
1352 || !migrate_timer_list(new_base, old_base->tv4.vec + i) 1363 migrate_timer_list(new_base, old_base->tv5.vec + i);
1353 || !migrate_timer_list(new_base, old_base->tv5.vec + i)) 1364 }
1354 goto unlock_again; 1365
1355 spin_unlock(&old_base->lock); 1366 spin_unlock(&old_base->t_base.lock);
1356 spin_unlock(&new_base->lock); 1367 spin_unlock(&new_base->t_base.lock);
1357 local_irq_enable(); 1368 local_irq_enable();
1358 put_cpu_var(tvec_bases); 1369 put_cpu_var(tvec_bases);
1359 return;
1360
1361unlock_again:
1362 /* Avoid deadlock with __mod_timer, by backing off. */
1363 spin_unlock(&old_base->lock);
1364 spin_unlock(&new_base->lock);
1365 cpu_relax();
1366 goto again;
1367} 1370}
1368#endif /* CONFIG_HOTPLUG_CPU */ 1371#endif /* CONFIG_HOTPLUG_CPU */
1369 1372
diff --git a/mm/Kconfig b/mm/Kconfig
new file mode 100644
index 000000000000..cd379936cac6
--- /dev/null
+++ b/mm/Kconfig
@@ -0,0 +1,91 @@
1config SELECT_MEMORY_MODEL
2 def_bool y
3 depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL
4
5choice
6 prompt "Memory model"
7 depends on SELECT_MEMORY_MODEL
8 default DISCONTIGMEM_MANUAL if ARCH_DISCONTIGMEM_DEFAULT
9 default SPARSEMEM_MANUAL if ARCH_SPARSEMEM_DEFAULT
10 default FLATMEM_MANUAL
11
12config FLATMEM_MANUAL
13 bool "Flat Memory"
14 depends on !ARCH_DISCONTIGMEM_ENABLE || ARCH_FLATMEM_ENABLE
15 help
16 This option allows you to change some of the ways that
17 Linux manages its memory internally. Most users will
18 only have one option here: FLATMEM. This is normal
19 and a correct option.
20
21 Some users of more advanced features like NUMA and
22 memory hotplug may have different options here.
23 DISCONTIGMEM is an more mature, better tested system,
24 but is incompatible with memory hotplug and may suffer
25 decreased performance over SPARSEMEM. If unsure between
26 "Sparse Memory" and "Discontiguous Memory", choose
27 "Discontiguous Memory".
28
29 If unsure, choose this option (Flat Memory) over any other.
30
31config DISCONTIGMEM_MANUAL
32 bool "Discontigious Memory"
33 depends on ARCH_DISCONTIGMEM_ENABLE
34 help
35 This option provides enhanced support for discontiguous
36 memory systems, over FLATMEM. These systems have holes
37 in their physical address spaces, and this option provides
38 more efficient handling of these holes. However, the vast
39 majority of hardware has quite flat address spaces, and
40 can have degraded performance from extra overhead that
41 this option imposes.
42
43 Many NUMA configurations will have this as the only option.
44
45 If unsure, choose "Flat Memory" over this option.
46
47config SPARSEMEM_MANUAL
48 bool "Sparse Memory"
49 depends on ARCH_SPARSEMEM_ENABLE
50 help
51 This will be the only option for some systems, including
52 memory hotplug systems. This is normal.
53
54 For many other systems, this will be an alternative to
55 "Discontigious Memory". This option provides some potential
56 performance benefits, along with decreased code complexity,
57 but it is newer, and more experimental.
58
59 If unsure, choose "Discontiguous Memory" or "Flat Memory"
60 over this option.
61
62endchoice
63
64config DISCONTIGMEM
65 def_bool y
66 depends on (!SELECT_MEMORY_MODEL && ARCH_DISCONTIGMEM_ENABLE) || DISCONTIGMEM_MANUAL
67
68config SPARSEMEM
69 def_bool y
70 depends on SPARSEMEM_MANUAL
71
72config FLATMEM
73 def_bool y
74 depends on (!DISCONTIGMEM && !SPARSEMEM) || FLATMEM_MANUAL
75
76config FLAT_NODE_MEM_MAP
77 def_bool y
78 depends on !SPARSEMEM
79
80#
81# Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's
82# to represent different areas of memory. This variable allows
83# those dependencies to exist individually.
84#
85config NEED_MULTIPLE_NODES
86 def_bool y
87 depends on DISCONTIGMEM || NUMA
88
89config HAVE_MEMORY_PRESENT
90 def_bool y
91 depends on ARCH_HAVE_MEMORY_PRESENT || SPARSEMEM
diff --git a/mm/Makefile b/mm/Makefile
index 097408064f6a..8f70ffd763c8 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -15,6 +15,7 @@ obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
15obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o 15obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o
16obj-$(CONFIG_HUGETLBFS) += hugetlb.o 16obj-$(CONFIG_HUGETLBFS) += hugetlb.o
17obj-$(CONFIG_NUMA) += mempolicy.o 17obj-$(CONFIG_NUMA) += mempolicy.o
18obj-$(CONFIG_SPARSEMEM) += sparse.o
18obj-$(CONFIG_SHMEM) += shmem.o 19obj-$(CONFIG_SHMEM) += shmem.o
19obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o 20obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o
20 21
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 260e703850d8..f82f7aebbee3 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -256,6 +256,7 @@ found:
256static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) 256static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
257{ 257{
258 struct page *page; 258 struct page *page;
259 unsigned long pfn;
259 bootmem_data_t *bdata = pgdat->bdata; 260 bootmem_data_t *bdata = pgdat->bdata;
260 unsigned long i, count, total = 0; 261 unsigned long i, count, total = 0;
261 unsigned long idx; 262 unsigned long idx;
@@ -266,7 +267,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
266 267
267 count = 0; 268 count = 0;
268 /* first extant page of the node */ 269 /* first extant page of the node */
269 page = virt_to_page(phys_to_virt(bdata->node_boot_start)); 270 pfn = bdata->node_boot_start >> PAGE_SHIFT;
270 idx = bdata->node_low_pfn - (bdata->node_boot_start >> PAGE_SHIFT); 271 idx = bdata->node_low_pfn - (bdata->node_boot_start >> PAGE_SHIFT);
271 map = bdata->node_bootmem_map; 272 map = bdata->node_bootmem_map;
272 /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */ 273 /* Check physaddr is O(LOG2(BITS_PER_LONG)) page aligned */
@@ -275,9 +276,11 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
275 gofast = 1; 276 gofast = 1;
276 for (i = 0; i < idx; ) { 277 for (i = 0; i < idx; ) {
277 unsigned long v = ~map[i / BITS_PER_LONG]; 278 unsigned long v = ~map[i / BITS_PER_LONG];
279
278 if (gofast && v == ~0UL) { 280 if (gofast && v == ~0UL) {
279 int j, order; 281 int j, order;
280 282
283 page = pfn_to_page(pfn);
281 count += BITS_PER_LONG; 284 count += BITS_PER_LONG;
282 __ClearPageReserved(page); 285 __ClearPageReserved(page);
283 order = ffs(BITS_PER_LONG) - 1; 286 order = ffs(BITS_PER_LONG) - 1;
@@ -292,6 +295,8 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
292 page += BITS_PER_LONG; 295 page += BITS_PER_LONG;
293 } else if (v) { 296 } else if (v) {
294 unsigned long m; 297 unsigned long m;
298
299 page = pfn_to_page(pfn);
295 for (m = 1; m && i < idx; m<<=1, page++, i++) { 300 for (m = 1; m && i < idx; m<<=1, page++, i++) {
296 if (v & m) { 301 if (v & m) {
297 count++; 302 count++;
@@ -302,8 +307,8 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat)
302 } 307 }
303 } else { 308 } else {
304 i+=BITS_PER_LONG; 309 i+=BITS_PER_LONG;
305 page += BITS_PER_LONG;
306 } 310 }
311 pfn += BITS_PER_LONG;
307 } 312 }
308 total += count; 313 total += count;
309 314
diff --git a/mm/filemap.c b/mm/filemap.c
index 4a2fee2cb62b..a3598b542a31 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1827,12 +1827,6 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
1827 if (unlikely(*pos < 0)) 1827 if (unlikely(*pos < 0))
1828 return -EINVAL; 1828 return -EINVAL;
1829 1829
1830 if (unlikely(file->f_error)) {
1831 int err = file->f_error;
1832 file->f_error = 0;
1833 return err;
1834 }
1835
1836 if (!isblk) { 1830 if (!isblk) {
1837 /* FIXME: this is for backwards compatibility with 2.4 */ 1831 /* FIXME: this is for backwards compatibility with 2.4 */
1838 if (file->f_flags & O_APPEND) 1832 if (file->f_flags & O_APPEND)
diff --git a/mm/madvise.c b/mm/madvise.c
index e3108054733c..54a5d3bc55d5 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -65,7 +65,6 @@ static long madvise_behavior(struct vm_area_struct * vma,
65 /* 65 /*
66 * vm_flags is protected by the mmap_sem held in write mode. 66 * vm_flags is protected by the mmap_sem held in write mode.
67 */ 67 */
68 VM_ClearReadHint(vma);
69 vma->vm_flags = new_flags; 68 vma->vm_flags = new_flags;
70 69
71out: 70out:
diff --git a/mm/memory.c b/mm/memory.c
index da91b7bf9986..30975ef48722 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -58,7 +58,7 @@
58#include <linux/swapops.h> 58#include <linux/swapops.h>
59#include <linux/elf.h> 59#include <linux/elf.h>
60 60
61#ifndef CONFIG_DISCONTIGMEM 61#ifndef CONFIG_NEED_MULTIPLE_NODES
62/* use the per-pgdat data instead for discontigmem - mbligh */ 62/* use the per-pgdat data instead for discontigmem - mbligh */
63unsigned long max_mapnr; 63unsigned long max_mapnr;
64struct page *mem_map; 64struct page *mem_map;
diff --git a/mm/mempool.c b/mm/mempool.c
index c9f3d4620428..9a72f7d918fa 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -51,16 +51,23 @@ static void free_pool(mempool_t *pool)
51 * functions might sleep - as long as the mempool_alloc function is not called 51 * functions might sleep - as long as the mempool_alloc function is not called
52 * from IRQ contexts. 52 * from IRQ contexts.
53 */ 53 */
54mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, 54mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
55 mempool_free_t *free_fn, void *pool_data) 55 mempool_free_t *free_fn, void *pool_data)
56{ 56{
57 mempool_t *pool; 57 return mempool_create_node(min_nr,alloc_fn,free_fn, pool_data,-1);
58}
59EXPORT_SYMBOL(mempool_create);
58 60
59 pool = kmalloc(sizeof(*pool), GFP_KERNEL); 61mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
62 mempool_free_t *free_fn, void *pool_data, int node_id)
63{
64 mempool_t *pool;
65 pool = kmalloc_node(sizeof(*pool), GFP_KERNEL, node_id);
60 if (!pool) 66 if (!pool)
61 return NULL; 67 return NULL;
62 memset(pool, 0, sizeof(*pool)); 68 memset(pool, 0, sizeof(*pool));
63 pool->elements = kmalloc(min_nr * sizeof(void *), GFP_KERNEL); 69 pool->elements = kmalloc_node(min_nr * sizeof(void *),
70 GFP_KERNEL, node_id);
64 if (!pool->elements) { 71 if (!pool->elements) {
65 kfree(pool); 72 kfree(pool);
66 return NULL; 73 return NULL;
@@ -87,7 +94,7 @@ mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
87 } 94 }
88 return pool; 95 return pool;
89} 96}
90EXPORT_SYMBOL(mempool_create); 97EXPORT_SYMBOL(mempool_create_node);
91 98
92/** 99/**
93 * mempool_resize - resize an existing memory pool 100 * mempool_resize - resize an existing memory pool
@@ -197,7 +204,7 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
197{ 204{
198 void *element; 205 void *element;
199 unsigned long flags; 206 unsigned long flags;
200 DEFINE_WAIT(wait); 207 wait_queue_t wait;
201 int gfp_temp; 208 int gfp_temp;
202 209
203 might_sleep_if(gfp_mask & __GFP_WAIT); 210 might_sleep_if(gfp_mask & __GFP_WAIT);
@@ -228,6 +235,7 @@ repeat_alloc:
228 235
229 /* Now start performing page reclaim */ 236 /* Now start performing page reclaim */
230 gfp_temp = gfp_mask; 237 gfp_temp = gfp_mask;
238 init_wait(&wait);
231 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE); 239 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
232 smp_mb(); 240 smp_mb();
233 if (!pool->curr_nr) 241 if (!pool->curr_nr)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 206920796f5f..7ee675ad101e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(nr_swap_pages);
68 * Used by page_zone() to look up the address of the struct zone whose 68 * Used by page_zone() to look up the address of the struct zone whose
69 * id is encoded in the upper bits of page->flags 69 * id is encoded in the upper bits of page->flags
70 */ 70 */
71struct zone *zone_table[1 << (ZONES_SHIFT + NODES_SHIFT)]; 71struct zone *zone_table[1 << ZONETABLE_SHIFT];
72EXPORT_SYMBOL(zone_table); 72EXPORT_SYMBOL(zone_table);
73 73
74static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; 74static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" };
@@ -1649,11 +1649,17 @@ static void __init calculate_zone_totalpages(struct pglist_data *pgdat,
1649void __init memmap_init_zone(unsigned long size, int nid, unsigned long zone, 1649void __init memmap_init_zone(unsigned long size, int nid, unsigned long zone,
1650 unsigned long start_pfn) 1650 unsigned long start_pfn)
1651{ 1651{
1652 struct page *start = pfn_to_page(start_pfn);
1653 struct page *page; 1652 struct page *page;
1653 unsigned long end_pfn = start_pfn + size;
1654 unsigned long pfn;
1654 1655
1655 for (page = start; page < (start + size); page++) { 1656 for (pfn = start_pfn; pfn < end_pfn; pfn++, page++) {
1656 set_page_zone(page, NODEZONE(nid, zone)); 1657 if (!early_pfn_valid(pfn))
1658 continue;
1659 if (!early_pfn_in_nid(pfn, nid))
1660 continue;
1661 page = pfn_to_page(pfn);
1662 set_page_links(page, zone, nid, pfn);
1657 set_page_count(page, 0); 1663 set_page_count(page, 0);
1658 reset_page_mapcount(page); 1664 reset_page_mapcount(page);
1659 SetPageReserved(page); 1665 SetPageReserved(page);
@@ -1677,6 +1683,20 @@ void zone_init_free_lists(struct pglist_data *pgdat, struct zone *zone,
1677 } 1683 }
1678} 1684}
1679 1685
1686#define ZONETABLE_INDEX(x, zone_nr) ((x << ZONES_SHIFT) | zone_nr)
1687void zonetable_add(struct zone *zone, int nid, int zid, unsigned long pfn,
1688 unsigned long size)
1689{
1690 unsigned long snum = pfn_to_section_nr(pfn);
1691 unsigned long end = pfn_to_section_nr(pfn + size);
1692
1693 if (FLAGS_HAS_NODE)
1694 zone_table[ZONETABLE_INDEX(nid, zid)] = zone;
1695 else
1696 for (; snum <= end; snum++)
1697 zone_table[ZONETABLE_INDEX(snum, zid)] = zone;
1698}
1699
1680#ifndef __HAVE_ARCH_MEMMAP_INIT 1700#ifndef __HAVE_ARCH_MEMMAP_INIT
1681#define memmap_init(size, nid, zone, start_pfn) \ 1701#define memmap_init(size, nid, zone, start_pfn) \
1682 memmap_init_zone((size), (nid), (zone), (start_pfn)) 1702 memmap_init_zone((size), (nid), (zone), (start_pfn))
@@ -1742,10 +1762,17 @@ inline void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
1742 * with interrupts disabled. 1762 * with interrupts disabled.
1743 * 1763 *
1744 * Some NUMA counter updates may also be caught by the boot pagesets. 1764 * Some NUMA counter updates may also be caught by the boot pagesets.
1745 * These will be discarded when bootup is complete. 1765 *
1766 * The boot_pagesets must be kept even after bootup is complete for
1767 * unused processors and/or zones. They do play a role for bootstrapping
1768 * hotplugged processors.
1769 *
1770 * zoneinfo_show() and maybe other functions do
1771 * not check if the processor is online before following the pageset pointer.
1772 * Other parts of the kernel may not check if the zone is available.
1746 */ 1773 */
1747static struct per_cpu_pageset 1774static struct per_cpu_pageset
1748 boot_pageset[NR_CPUS] __initdata; 1775 boot_pageset[NR_CPUS];
1749 1776
1750/* 1777/*
1751 * Dynamically allocate memory for the 1778 * Dynamically allocate memory for the
@@ -1854,7 +1881,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1854 unsigned long size, realsize; 1881 unsigned long size, realsize;
1855 unsigned long batch; 1882 unsigned long batch;
1856 1883
1857 zone_table[NODEZONE(nid, j)] = zone;
1858 realsize = size = zones_size[j]; 1884 realsize = size = zones_size[j];
1859 if (zholes_size) 1885 if (zholes_size)
1860 realsize -= zholes_size[j]; 1886 realsize -= zholes_size[j];
@@ -1920,6 +1946,8 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1920 1946
1921 memmap_init(size, nid, j, zone_start_pfn); 1947 memmap_init(size, nid, j, zone_start_pfn);
1922 1948
1949 zonetable_add(zone, nid, j, zone_start_pfn, size);
1950
1923 zone_start_pfn += size; 1951 zone_start_pfn += size;
1924 1952
1925 zone_init_free_lists(pgdat, zone, zone->spanned_pages); 1953 zone_init_free_lists(pgdat, zone, zone->spanned_pages);
@@ -1928,24 +1956,30 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1928 1956
1929static void __init alloc_node_mem_map(struct pglist_data *pgdat) 1957static void __init alloc_node_mem_map(struct pglist_data *pgdat)
1930{ 1958{
1931 unsigned long size;
1932
1933 /* Skip empty nodes */ 1959 /* Skip empty nodes */
1934 if (!pgdat->node_spanned_pages) 1960 if (!pgdat->node_spanned_pages)
1935 return; 1961 return;
1936 1962
1963#ifdef CONFIG_FLAT_NODE_MEM_MAP
1937 /* ia64 gets its own node_mem_map, before this, without bootmem */ 1964 /* ia64 gets its own node_mem_map, before this, without bootmem */
1938 if (!pgdat->node_mem_map) { 1965 if (!pgdat->node_mem_map) {
1966 unsigned long size;
1967 struct page *map;
1968
1939 size = (pgdat->node_spanned_pages + 1) * sizeof(struct page); 1969 size = (pgdat->node_spanned_pages + 1) * sizeof(struct page);
1940 pgdat->node_mem_map = alloc_bootmem_node(pgdat, size); 1970 map = alloc_remap(pgdat->node_id, size);
1971 if (!map)
1972 map = alloc_bootmem_node(pgdat, size);
1973 pgdat->node_mem_map = map;
1941 } 1974 }
1942#ifndef CONFIG_DISCONTIGMEM 1975#ifdef CONFIG_FLATMEM
1943 /* 1976 /*
1944 * With no DISCONTIG, the global mem_map is just set as node 0's 1977 * With no DISCONTIG, the global mem_map is just set as node 0's
1945 */ 1978 */
1946 if (pgdat == NODE_DATA(0)) 1979 if (pgdat == NODE_DATA(0))
1947 mem_map = NODE_DATA(0)->node_mem_map; 1980 mem_map = NODE_DATA(0)->node_mem_map;
1948#endif 1981#endif
1982#endif /* CONFIG_FLAT_NODE_MEM_MAP */
1949} 1983}
1950 1984
1951void __init free_area_init_node(int nid, struct pglist_data *pgdat, 1985void __init free_area_init_node(int nid, struct pglist_data *pgdat,
@@ -1961,18 +1995,18 @@ void __init free_area_init_node(int nid, struct pglist_data *pgdat,
1961 free_area_init_core(pgdat, zones_size, zholes_size); 1995 free_area_init_core(pgdat, zones_size, zholes_size);
1962} 1996}
1963 1997
1964#ifndef CONFIG_DISCONTIGMEM 1998#ifndef CONFIG_NEED_MULTIPLE_NODES
1965static bootmem_data_t contig_bootmem_data; 1999static bootmem_data_t contig_bootmem_data;
1966struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data }; 2000struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data };
1967 2001
1968EXPORT_SYMBOL(contig_page_data); 2002EXPORT_SYMBOL(contig_page_data);
2003#endif
1969 2004
1970void __init free_area_init(unsigned long *zones_size) 2005void __init free_area_init(unsigned long *zones_size)
1971{ 2006{
1972 free_area_init_node(0, &contig_page_data, zones_size, 2007 free_area_init_node(0, NODE_DATA(0), zones_size,
1973 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL); 2008 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
1974} 2009}
1975#endif
1976 2010
1977#ifdef CONFIG_PROC_FS 2011#ifdef CONFIG_PROC_FS
1978 2012
diff --git a/mm/slab.c b/mm/slab.c
index 93cbbbb39f42..122d031baab2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -92,6 +92,7 @@
92#include <linux/sysctl.h> 92#include <linux/sysctl.h>
93#include <linux/module.h> 93#include <linux/module.h>
94#include <linux/rcupdate.h> 94#include <linux/rcupdate.h>
95#include <linux/string.h>
95 96
96#include <asm/uaccess.h> 97#include <asm/uaccess.h>
97#include <asm/cacheflush.h> 98#include <asm/cacheflush.h>
@@ -3082,3 +3083,26 @@ unsigned int ksize(const void *objp)
3082 3083
3083 return size; 3084 return size;
3084} 3085}
3086
3087
3088/*
3089 * kstrdup - allocate space for and copy an existing string
3090 *
3091 * @s: the string to duplicate
3092 * @gfp: the GFP mask used in the kmalloc() call when allocating memory
3093 */
3094char *kstrdup(const char *s, int gfp)
3095{
3096 size_t len;
3097 char *buf;
3098
3099 if (!s)
3100 return NULL;
3101
3102 len = strlen(s) + 1;
3103 buf = kmalloc(len, gfp);
3104 if (buf)
3105 memcpy(buf, s, len);
3106 return buf;
3107}
3108EXPORT_SYMBOL(kstrdup);
diff --git a/mm/sparse.c b/mm/sparse.c
new file mode 100644
index 000000000000..b54e304df4a7
--- /dev/null
+++ b/mm/sparse.c
@@ -0,0 +1,137 @@
1/*
2 * sparse memory mappings.
3 */
4#include <linux/config.h>
5#include <linux/mm.h>
6#include <linux/mmzone.h>
7#include <linux/bootmem.h>
8#include <linux/module.h>
9#include <asm/dma.h>
10
11/*
12 * Permanent SPARSEMEM data:
13 *
14 * 1) mem_section - memory sections, mem_map's for valid memory
15 */
16struct mem_section mem_section[NR_MEM_SECTIONS];
17EXPORT_SYMBOL(mem_section);
18
19/* Record a memory area against a node. */
20void memory_present(int nid, unsigned long start, unsigned long end)
21{
22 unsigned long pfn;
23
24 start &= PAGE_SECTION_MASK;
25 for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) {
26 unsigned long section = pfn_to_section_nr(pfn);
27 if (!mem_section[section].section_mem_map)
28 mem_section[section].section_mem_map = SECTION_MARKED_PRESENT;
29 }
30}
31
32/*
33 * Only used by the i386 NUMA architecures, but relatively
34 * generic code.
35 */
36unsigned long __init node_memmap_size_bytes(int nid, unsigned long start_pfn,
37 unsigned long end_pfn)
38{
39 unsigned long pfn;
40 unsigned long nr_pages = 0;
41
42 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
43 if (nid != early_pfn_to_nid(pfn))
44 continue;
45
46 if (pfn_valid(pfn))
47 nr_pages += PAGES_PER_SECTION;
48 }
49
50 return nr_pages * sizeof(struct page);
51}
52
53/*
54 * Subtle, we encode the real pfn into the mem_map such that
55 * the identity pfn - section_mem_map will return the actual
56 * physical page frame number.
57 */
58static unsigned long sparse_encode_mem_map(struct page *mem_map, unsigned long pnum)
59{
60 return (unsigned long)(mem_map - (section_nr_to_pfn(pnum)));
61}
62
63/*
64 * We need this if we ever free the mem_maps. While not implemented yet,
65 * this function is included for parity with its sibling.
66 */
67static __attribute((unused))
68struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum)
69{
70 return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum);
71}
72
73static int sparse_init_one_section(struct mem_section *ms,
74 unsigned long pnum, struct page *mem_map)
75{
76 if (!valid_section(ms))
77 return -EINVAL;
78
79 ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum);
80
81 return 1;
82}
83
84static struct page *sparse_early_mem_map_alloc(unsigned long pnum)
85{
86 struct page *map;
87 int nid = early_pfn_to_nid(section_nr_to_pfn(pnum));
88
89 map = alloc_remap(nid, sizeof(struct page) * PAGES_PER_SECTION);
90 if (map)
91 return map;
92
93 map = alloc_bootmem_node(NODE_DATA(nid),
94 sizeof(struct page) * PAGES_PER_SECTION);
95 if (map)
96 return map;
97
98 printk(KERN_WARNING "%s: allocation failed\n", __FUNCTION__);
99 mem_section[pnum].section_mem_map = 0;
100 return NULL;
101}
102
103/*
104 * Allocate the accumulated non-linear sections, allocate a mem_map
105 * for each and record the physical to section mapping.
106 */
107void sparse_init(void)
108{
109 unsigned long pnum;
110 struct page *map;
111
112 for (pnum = 0; pnum < NR_MEM_SECTIONS; pnum++) {
113 if (!valid_section_nr(pnum))
114 continue;
115
116 map = sparse_early_mem_map_alloc(pnum);
117 if (map)
118 sparse_init_one_section(&mem_section[pnum], pnum, map);
119 }
120}
121
122/*
123 * returns the number of sections whose mem_maps were properly
124 * set. If this is <=0, then that means that the passed-in
125 * map was not consumed and must be freed.
126 */
127int sparse_add_one_section(unsigned long start_pfn, int nr_pages, struct page *map)
128{
129 struct mem_section *ms = __pfn_to_section(start_pfn);
130
131 if (ms->section_mem_map & SECTION_MARKED_PRESENT)
132 return -EEXIST;
133
134 ms->section_mem_map |= SECTION_MARKED_PRESENT;
135
136 return sparse_init_one_section(ms, pfn_to_section_nr(start_pfn), map);
137}
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 10d040461021..c34614ea5fce 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -35,6 +35,7 @@
35#include <net/datalink.h> 35#include <net/datalink.h>
36#include <net/psnap.h> 36#include <net/psnap.h>
37#include <linux/atalk.h> 37#include <linux/atalk.h>
38#include <linux/delay.h>
38#include <linux/init.h> 39#include <linux/init.h>
39#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
40#include <linux/seq_file.h> 41#include <linux/seq_file.h>
@@ -462,8 +463,7 @@ void aarp_probe_network(struct atalk_iface *atif)
462 aarp_send_probe(atif->dev, &atif->address); 463 aarp_send_probe(atif->dev, &atif->address);
463 464
464 /* Defer 1/10th */ 465 /* Defer 1/10th */
465 current->state = TASK_INTERRUPTIBLE; 466 msleep(100);
466 schedule_timeout(HZ / 10);
467 467
468 if (atif->status & ATIF_PROBE_FAIL) 468 if (atif->status & ATIF_PROBE_FAIL)
469 break; 469 break;
@@ -510,9 +510,8 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct atalk_addr *sa)
510 aarp_send_probe(atif->dev, sa); 510 aarp_send_probe(atif->dev, sa);
511 511
512 /* Defer 1/10th */ 512 /* Defer 1/10th */
513 current->state = TASK_INTERRUPTIBLE;
514 write_unlock_bh(&aarp_lock); 513 write_unlock_bh(&aarp_lock);
515 schedule_timeout(HZ / 10); 514 msleep(100);
516 write_lock_bh(&aarp_lock); 515 write_lock_bh(&aarp_lock);
517 516
518 if (entry->status & ATIF_PROBE_FAIL) 517 if (entry->status & ATIF_PROBE_FAIL)
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 18ebc664769b..c4540144f0f4 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -859,8 +859,7 @@ static int translate_table(struct ebt_replace *repl,
859 if (repl->valid_hooks & (1 << i)) 859 if (repl->valid_hooks & (1 << i))
860 if (check_chainloops(newinfo->hook_entry[i], 860 if (check_chainloops(newinfo->hook_entry[i],
861 cl_s, udc_cnt, i, newinfo->entries)) { 861 cl_s, udc_cnt, i, newinfo->entries)) {
862 if (cl_s) 862 vfree(cl_s);
863 vfree(cl_s);
864 return -EINVAL; 863 return -EINVAL;
865 } 864 }
866 865
@@ -883,8 +882,7 @@ static int translate_table(struct ebt_replace *repl,
883 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 882 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
884 ebt_cleanup_entry, &i); 883 ebt_cleanup_entry, &i);
885 } 884 }
886 if (cl_s) 885 vfree(cl_s);
887 vfree(cl_s);
888 return ret; 886 return ret;
889} 887}
890 888
@@ -1030,8 +1028,7 @@ static int do_replace(void __user *user, unsigned int len)
1030 } 1028 }
1031 vfree(table); 1029 vfree(table);
1032 1030
1033 if (counterstmp) 1031 vfree(counterstmp);
1034 vfree(counterstmp);
1035 return ret; 1032 return ret;
1036 1033
1037free_unlock: 1034free_unlock:
@@ -1040,8 +1037,7 @@ free_iterate:
1040 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 1037 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
1041 ebt_cleanup_entry, NULL); 1038 ebt_cleanup_entry, NULL);
1042free_counterstmp: 1039free_counterstmp:
1043 if (counterstmp) 1040 vfree(counterstmp);
1044 vfree(counterstmp);
1045 /* can be initialized in translate_table() */ 1041 /* can be initialized in translate_table() */
1046 if (newinfo->chainstack) { 1042 if (newinfo->chainstack) {
1047 for (i = 0; i < num_possible_cpus(); i++) 1043 for (i = 0; i < num_possible_cpus(); i++)
@@ -1049,11 +1045,9 @@ free_counterstmp:
1049 vfree(newinfo->chainstack); 1045 vfree(newinfo->chainstack);
1050 } 1046 }
1051free_entries: 1047free_entries:
1052 if (newinfo->entries) 1048 vfree(newinfo->entries);
1053 vfree(newinfo->entries);
1054free_newinfo: 1049free_newinfo:
1055 if (newinfo) 1050 vfree(newinfo);
1056 vfree(newinfo);
1057 return ret; 1051 return ret;
1058} 1052}
1059 1053
@@ -1213,8 +1207,7 @@ void ebt_unregister_table(struct ebt_table *table)
1213 down(&ebt_mutex); 1207 down(&ebt_mutex);
1214 LIST_DELETE(&ebt_tables, table); 1208 LIST_DELETE(&ebt_tables, table);
1215 up(&ebt_mutex); 1209 up(&ebt_mutex);
1216 if (table->private->entries) 1210 vfree(table->private->entries);
1217 vfree(table->private->entries);
1218 if (table->private->chainstack) { 1211 if (table->private->chainstack) {
1219 for (i = 0; i < num_possible_cpus(); i++) 1212 for (i = 0; i < num_possible_cpus(); i++)
1220 vfree(table->private->chainstack[i]); 1213 vfree(table->private->chainstack[i]);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index f6bdcad47da6..851eb927ed97 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -32,6 +32,7 @@
32#include <net/sock.h> 32#include <net/sock.h>
33#include <linux/rtnetlink.h> 33#include <linux/rtnetlink.h>
34#include <linux/random.h> 34#include <linux/random.h>
35#include <linux/string.h>
35 36
36#define NEIGH_DEBUG 1 37#define NEIGH_DEBUG 1
37 38
@@ -2592,7 +2593,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
2592 t->neigh_vars[17].extra1 = dev; 2593 t->neigh_vars[17].extra1 = dev;
2593 } 2594 }
2594 2595
2595 dev_name = net_sysctl_strdup(dev_name_source); 2596 dev_name = kstrdup(dev_name_source, GFP_KERNEL);
2596 if (!dev_name) { 2597 if (!dev_name) {
2597 err = -ENOBUFS; 2598 err = -ENOBUFS;
2598 goto free; 2599 goto free;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index a119696d5521..c327c9edadc5 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -130,19 +130,20 @@ static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
130 */ 130 */
131static void poll_napi(struct netpoll *np) 131static void poll_napi(struct netpoll *np)
132{ 132{
133 struct netpoll_info *npinfo = np->dev->npinfo;
133 int budget = 16; 134 int budget = 16;
134 135
135 if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) && 136 if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) &&
136 np->poll_owner != smp_processor_id() && 137 npinfo->poll_owner != smp_processor_id() &&
137 spin_trylock(&np->poll_lock)) { 138 spin_trylock(&npinfo->poll_lock)) {
138 np->rx_flags |= NETPOLL_RX_DROP; 139 npinfo->rx_flags |= NETPOLL_RX_DROP;
139 atomic_inc(&trapped); 140 atomic_inc(&trapped);
140 141
141 np->dev->poll(np->dev, &budget); 142 np->dev->poll(np->dev, &budget);
142 143
143 atomic_dec(&trapped); 144 atomic_dec(&trapped);
144 np->rx_flags &= ~NETPOLL_RX_DROP; 145 npinfo->rx_flags &= ~NETPOLL_RX_DROP;
145 spin_unlock(&np->poll_lock); 146 spin_unlock(&npinfo->poll_lock);
146 } 147 }
147} 148}
148 149
@@ -245,6 +246,7 @@ repeat:
245static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 246static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
246{ 247{
247 int status; 248 int status;
249 struct netpoll_info *npinfo;
248 250
249repeat: 251repeat:
250 if(!np || !np->dev || !netif_running(np->dev)) { 252 if(!np || !np->dev || !netif_running(np->dev)) {
@@ -253,8 +255,9 @@ repeat:
253 } 255 }
254 256
255 /* avoid recursion */ 257 /* avoid recursion */
256 if(np->poll_owner == smp_processor_id() || 258 npinfo = np->dev->npinfo;
257 np->dev->xmit_lock_owner == smp_processor_id()) { 259 if (npinfo->poll_owner == smp_processor_id() ||
260 np->dev->xmit_lock_owner == smp_processor_id()) {
258 if (np->drop) 261 if (np->drop)
259 np->drop(skb); 262 np->drop(skb);
260 else 263 else
@@ -341,14 +344,22 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
341 344
342static void arp_reply(struct sk_buff *skb) 345static void arp_reply(struct sk_buff *skb)
343{ 346{
347 struct netpoll_info *npinfo = skb->dev->npinfo;
344 struct arphdr *arp; 348 struct arphdr *arp;
345 unsigned char *arp_ptr; 349 unsigned char *arp_ptr;
346 int size, type = ARPOP_REPLY, ptype = ETH_P_ARP; 350 int size, type = ARPOP_REPLY, ptype = ETH_P_ARP;
347 u32 sip, tip; 351 u32 sip, tip;
352 unsigned long flags;
348 struct sk_buff *send_skb; 353 struct sk_buff *send_skb;
349 struct netpoll *np = skb->dev->np; 354 struct netpoll *np = NULL;
355
356 spin_lock_irqsave(&npinfo->rx_lock, flags);
357 if (npinfo->rx_np && npinfo->rx_np->dev == skb->dev)
358 np = npinfo->rx_np;
359 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
350 360
351 if (!np) return; 361 if (!np)
362 return;
352 363
353 /* No arp on this interface */ 364 /* No arp on this interface */
354 if (skb->dev->flags & IFF_NOARP) 365 if (skb->dev->flags & IFF_NOARP)
@@ -429,9 +440,9 @@ int __netpoll_rx(struct sk_buff *skb)
429 int proto, len, ulen; 440 int proto, len, ulen;
430 struct iphdr *iph; 441 struct iphdr *iph;
431 struct udphdr *uh; 442 struct udphdr *uh;
432 struct netpoll *np = skb->dev->np; 443 struct netpoll *np = skb->dev->npinfo->rx_np;
433 444
434 if (!np->rx_hook) 445 if (!np)
435 goto out; 446 goto out;
436 if (skb->dev->type != ARPHRD_ETHER) 447 if (skb->dev->type != ARPHRD_ETHER)
437 goto out; 448 goto out;
@@ -611,9 +622,8 @@ int netpoll_setup(struct netpoll *np)
611{ 622{
612 struct net_device *ndev = NULL; 623 struct net_device *ndev = NULL;
613 struct in_device *in_dev; 624 struct in_device *in_dev;
614 625 struct netpoll_info *npinfo;
615 np->poll_lock = SPIN_LOCK_UNLOCKED; 626 unsigned long flags;
616 np->poll_owner = -1;
617 627
618 if (np->dev_name) 628 if (np->dev_name)
619 ndev = dev_get_by_name(np->dev_name); 629 ndev = dev_get_by_name(np->dev_name);
@@ -624,7 +634,17 @@ int netpoll_setup(struct netpoll *np)
624 } 634 }
625 635
626 np->dev = ndev; 636 np->dev = ndev;
627 ndev->np = np; 637 if (!ndev->npinfo) {
638 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
639 if (!npinfo)
640 goto release;
641
642 npinfo->rx_np = NULL;
643 npinfo->poll_lock = SPIN_LOCK_UNLOCKED;
644 npinfo->poll_owner = -1;
645 npinfo->rx_lock = SPIN_LOCK_UNLOCKED;
646 } else
647 npinfo = ndev->npinfo;
628 648
629 if (!ndev->poll_controller) { 649 if (!ndev->poll_controller) {
630 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", 650 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
@@ -692,13 +712,20 @@ int netpoll_setup(struct netpoll *np)
692 np->name, HIPQUAD(np->local_ip)); 712 np->name, HIPQUAD(np->local_ip));
693 } 713 }
694 714
695 if(np->rx_hook) 715 if (np->rx_hook) {
696 np->rx_flags = NETPOLL_RX_ENABLED; 716 spin_lock_irqsave(&npinfo->rx_lock, flags);
717 npinfo->rx_flags |= NETPOLL_RX_ENABLED;
718 npinfo->rx_np = np;
719 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
720 }
721 /* last thing to do is link it to the net device structure */
722 ndev->npinfo = npinfo;
697 723
698 return 0; 724 return 0;
699 725
700 release: 726 release:
701 ndev->np = NULL; 727 if (!ndev->npinfo)
728 kfree(npinfo);
702 np->dev = NULL; 729 np->dev = NULL;
703 dev_put(ndev); 730 dev_put(ndev);
704 return -1; 731 return -1;
@@ -706,9 +733,20 @@ int netpoll_setup(struct netpoll *np)
706 733
707void netpoll_cleanup(struct netpoll *np) 734void netpoll_cleanup(struct netpoll *np)
708{ 735{
709 if (np->dev) 736 struct netpoll_info *npinfo;
710 np->dev->np = NULL; 737 unsigned long flags;
711 dev_put(np->dev); 738
739 if (np->dev) {
740 npinfo = np->dev->npinfo;
741 if (npinfo && npinfo->rx_np == np) {
742 spin_lock_irqsave(&npinfo->rx_lock, flags);
743 npinfo->rx_np = NULL;
744 npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
745 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
746 }
747 dev_put(np->dev);
748 }
749
712 np->dev = NULL; 750 np->dev = NULL;
713} 751}
714 752
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index c8be646cb191..880a88815211 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -35,19 +35,6 @@ extern int sysctl_somaxconn;
35extern char sysctl_divert_version[]; 35extern char sysctl_divert_version[];
36#endif /* CONFIG_NET_DIVERT */ 36#endif /* CONFIG_NET_DIVERT */
37 37
38/*
39 * This strdup() is used for creating copies of network
40 * device names to be handed over to sysctl.
41 */
42
43char *net_sysctl_strdup(const char *s)
44{
45 char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
46 if (rv)
47 strcpy(rv, s);
48 return rv;
49}
50
51ctl_table core_table[] = { 38ctl_table core_table[] = {
52#ifdef CONFIG_NET 39#ifdef CONFIG_NET
53 { 40 {
@@ -177,6 +164,4 @@ ctl_table core_table[] = {
177 { .ctl_name = 0 } 164 { .ctl_name = 0 }
178}; 165};
179 166
180EXPORT_SYMBOL(net_sysctl_strdup);
181
182#endif 167#endif
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 650dcb12d9a1..d8a10e3dd77d 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1471,7 +1471,7 @@ static void devinet_sysctl_register(struct in_device *in_dev,
1471 * by sysctl and we wouldn't want anyone to change it under our feet 1471 * by sysctl and we wouldn't want anyone to change it under our feet
1472 * (see SIOCSIFNAME). 1472 * (see SIOCSIFNAME).
1473 */ 1473 */
1474 dev_name = net_sysctl_strdup(dev_name); 1474 dev_name = kstrdup(dev_name, GFP_KERNEL);
1475 if (!dev_name) 1475 if (!dev_name)
1476 goto free; 1476 goto free;
1477 1477
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index dc4362b57cfa..9cde8c61f525 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -339,7 +339,7 @@ target(struct sk_buff **pskb,
339 * error messages (RELATED) and information requests (see below) */ 339 * error messages (RELATED) and information requests (see below) */
340 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP 340 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP
341 && (ctinfo == IP_CT_RELATED 341 && (ctinfo == IP_CT_RELATED
342 || ctinfo == IP_CT_IS_REPLY+IP_CT_IS_REPLY)) 342 || ctinfo == IP_CT_RELATED+IP_CT_IS_REPLY))
343 return IPT_CONTINUE; 343 return IPT_CONTINUE;
344 344
345 /* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO, 345 /* ip_conntrack_icmp guarantees us that we only have ICMP_ECHO,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index f4d53c919869..80cf633d9f4a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1767,7 +1767,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
1767 struct in_device *in_dev, 1767 struct in_device *in_dev,
1768 u32 daddr, u32 saddr, u32 tos) 1768 u32 daddr, u32 saddr, u32 tos)
1769{ 1769{
1770 struct rtable* rth; 1770 struct rtable* rth = NULL;
1771 int err; 1771 int err;
1772 unsigned hash; 1772 unsigned hash;
1773 1773
@@ -1794,7 +1794,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1794 u32 daddr, u32 saddr, u32 tos) 1794 u32 daddr, u32 saddr, u32 tos)
1795{ 1795{
1796#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 1796#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
1797 struct rtable* rth; 1797 struct rtable* rth = NULL;
1798 unsigned char hop, hopcount, lasthop; 1798 unsigned char hop, hopcount, lasthop;
1799 int err = -EINVAL; 1799 int err = -EINVAL;
1800 unsigned int hash; 1800 unsigned int hash;
@@ -2239,7 +2239,7 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
2239 struct net_device *dev_out, 2239 struct net_device *dev_out,
2240 unsigned flags) 2240 unsigned flags)
2241{ 2241{
2242 struct rtable *rth; 2242 struct rtable *rth = NULL;
2243 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); 2243 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
2244 unsigned hash; 2244 unsigned hash;
2245 if (err == 0) { 2245 if (err == 0) {
@@ -2267,7 +2267,7 @@ static inline int ip_mkroute_output(struct rtable** rp,
2267 unsigned char hop; 2267 unsigned char hop;
2268 unsigned hash; 2268 unsigned hash;
2269 int err = -EINVAL; 2269 int err = -EINVAL;
2270 struct rtable *rth; 2270 struct rtable *rth = NULL;
2271 2271
2272 if (res->fi && res->fi->fib_nhs > 1) { 2272 if (res->fi && res->fi->fib_nhs > 1) {
2273 unsigned char hopcount = res->fi->fib_nhs; 2273 unsigned char hopcount = res->fi->fib_nhs;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 14f5c53235fe..a54d4ef3fd35 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -57,6 +57,7 @@
57#endif 57#endif
58#include <linux/delay.h> 58#include <linux/delay.h>
59#include <linux/notifier.h> 59#include <linux/notifier.h>
60#include <linux/string.h>
60 61
61#include <net/sock.h> 62#include <net/sock.h>
62#include <net/snmp.h> 63#include <net/snmp.h>
@@ -3437,7 +3438,7 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf
3437 * by sysctl and we wouldn't want anyone to change it under our feet 3438 * by sysctl and we wouldn't want anyone to change it under our feet
3438 * (see SIOCSIFNAME). 3439 * (see SIOCSIFNAME).
3439 */ 3440 */
3440 dev_name = net_sysctl_strdup(dev_name); 3441 dev_name = kstrdup(dev_name, GFP_KERNEL);
3441 if (!dev_name) 3442 if (!dev_name)
3442 goto free; 3443 goto free;
3443 3444
diff --git a/net/socket.c b/net/socket.c
index 38729af09461..6f2a17881972 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -383,9 +383,8 @@ int sock_map_fd(struct socket *sock)
383 goto out; 383 goto out;
384 } 384 }
385 385
386 sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino); 386 this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
387 this.name = name; 387 this.name = name;
388 this.len = strlen(name);
389 this.hash = SOCK_INODE(sock)->i_ino; 388 this.hash = SOCK_INODE(sock)->i_ino;
390 389
391 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this); 390 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 2b99b4028d31..d6baf6fdf8a9 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -8,6 +8,7 @@
8#include <linux/err.h> 8#include <linux/err.h>
9#include <linux/seq_file.h> 9#include <linux/seq_file.h>
10#include <linux/hash.h> 10#include <linux/hash.h>
11#include <linux/string.h>
11 12
12#define RPCDBG_FACILITY RPCDBG_AUTH 13#define RPCDBG_FACILITY RPCDBG_AUTH
13 14
@@ -20,14 +21,6 @@
20 */ 21 */
21 22
22 23
23static char *strdup(char *s)
24{
25 char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
26 if (rv)
27 strcpy(rv, s);
28 return rv;
29}
30
31struct unix_domain { 24struct unix_domain {
32 struct auth_domain h; 25 struct auth_domain h;
33 int addr_changes; 26 int addr_changes;
@@ -55,7 +48,7 @@ struct auth_domain *unix_domain_find(char *name)
55 if (new == NULL) 48 if (new == NULL)
56 return NULL; 49 return NULL;
57 cache_init(&new->h.h); 50 cache_init(&new->h.h);
58 new->h.name = strdup(name); 51 new->h.name = kstrdup(name, GFP_KERNEL);
59 new->h.flavour = RPC_AUTH_UNIX; 52 new->h.flavour = RPC_AUTH_UNIX;
60 new->addr_changes = 0; 53 new->addr_changes = 0;
61 new->h.h.expiry_time = NEVER; 54 new->h.h.expiry_time = NEVER;
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 2a24b243b841..04bec047fa9a 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -29,6 +29,10 @@
29 * 2000-11-14 Henner Eisen Closing datalink from NETDEV_GOING_DOWN 29 * 2000-11-14 Henner Eisen Closing datalink from NETDEV_GOING_DOWN
30 * 2002-10-06 Arnaldo C. Melo Get rid of cli/sti, move proc stuff to 30 * 2002-10-06 Arnaldo C. Melo Get rid of cli/sti, move proc stuff to
31 * x25_proc.c, using seq_file 31 * x25_proc.c, using seq_file
32 * 2005-04-02 Shaun Pereira Selective sub address matching
33 * with call user data
34 * 2005-04-15 Shaun Pereira Fast select with no restriction on
35 * response
32 */ 36 */
33 37
34#include <linux/config.h> 38#include <linux/config.h>
@@ -219,7 +223,8 @@ static void x25_insert_socket(struct sock *sk)
219 * Note: if a listening socket has cud set it must only get calls 223 * Note: if a listening socket has cud set it must only get calls
220 * with matching cud. 224 * with matching cud.
221 */ 225 */
222static struct sock *x25_find_listener(struct x25_address *addr, struct x25_calluserdata *calluserdata) 226static struct sock *x25_find_listener(struct x25_address *addr,
227 struct sk_buff *skb)
223{ 228{
224 struct sock *s; 229 struct sock *s;
225 struct sock *next_best; 230 struct sock *next_best;
@@ -230,22 +235,23 @@ static struct sock *x25_find_listener(struct x25_address *addr, struct x25_callu
230 235
231 sk_for_each(s, node, &x25_list) 236 sk_for_each(s, node, &x25_list)
232 if ((!strcmp(addr->x25_addr, 237 if ((!strcmp(addr->x25_addr,
233 x25_sk(s)->source_addr.x25_addr) || 238 x25_sk(s)->source_addr.x25_addr) ||
234 !strcmp(addr->x25_addr, 239 !strcmp(addr->x25_addr,
235 null_x25_address.x25_addr)) && 240 null_x25_address.x25_addr)) &&
236 s->sk_state == TCP_LISTEN) { 241 s->sk_state == TCP_LISTEN) {
237
238 /* 242 /*
239 * Found a listening socket, now check the incoming 243 * Found a listening socket, now check the incoming
240 * call user data vs this sockets call user data 244 * call user data vs this sockets call user data
241 */ 245 */
242 if (x25_check_calluserdata(&x25_sk(s)->calluserdata, calluserdata)) { 246 if(skb->len > 0 && x25_sk(s)->cudmatchlength > 0) {
243 sock_hold(s); 247 if((memcmp(x25_sk(s)->calluserdata.cuddata,
244 goto found; 248 skb->data,
245 } 249 x25_sk(s)->cudmatchlength)) == 0) {
246 if (x25_sk(s)->calluserdata.cudlength == 0) { 250 sock_hold(s);
251 goto found;
252 }
253 } else
247 next_best = s; 254 next_best = s;
248 }
249 } 255 }
250 if (next_best) { 256 if (next_best) {
251 s = next_best; 257 s = next_best;
@@ -497,6 +503,9 @@ static int x25_create(struct socket *sock, int protocol)
497 x25->t23 = sysctl_x25_clear_request_timeout; 503 x25->t23 = sysctl_x25_clear_request_timeout;
498 x25->t2 = sysctl_x25_ack_holdback_timeout; 504 x25->t2 = sysctl_x25_ack_holdback_timeout;
499 x25->state = X25_STATE_0; 505 x25->state = X25_STATE_0;
506 x25->cudmatchlength = 0;
507 x25->accptapprv = X25_DENY_ACCPT_APPRV; /* normally no cud */
508 /* on call accept */
500 509
501 x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE; 510 x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE;
502 x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; 511 x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE;
@@ -545,6 +554,8 @@ static struct sock *x25_make_new(struct sock *osk)
545 x25->t2 = ox25->t2; 554 x25->t2 = ox25->t2;
546 x25->facilities = ox25->facilities; 555 x25->facilities = ox25->facilities;
547 x25->qbitincl = ox25->qbitincl; 556 x25->qbitincl = ox25->qbitincl;
557 x25->cudmatchlength = ox25->cudmatchlength;
558 x25->accptapprv = ox25->accptapprv;
548 559
549 x25_init_timers(sk); 560 x25_init_timers(sk);
550out: 561out:
@@ -822,7 +833,6 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
822 struct x25_sock *makex25; 833 struct x25_sock *makex25;
823 struct x25_address source_addr, dest_addr; 834 struct x25_address source_addr, dest_addr;
824 struct x25_facilities facilities; 835 struct x25_facilities facilities;
825 struct x25_calluserdata calluserdata;
826 int len, rc; 836 int len, rc;
827 837
828 /* 838 /*
@@ -845,19 +855,10 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
845 skb_pull(skb,len); 855 skb_pull(skb,len);
846 856
847 /* 857 /*
848 * Incoming Call User Data.
849 */
850 if (skb->len >= 0) {
851 memcpy(calluserdata.cuddata, skb->data, skb->len);
852 calluserdata.cudlength = skb->len;
853 }
854
855 skb_push(skb,len);
856
857 /*
858 * Find a listener for the particular address/cud pair. 858 * Find a listener for the particular address/cud pair.
859 */ 859 */
860 sk = x25_find_listener(&source_addr,&calluserdata); 860 sk = x25_find_listener(&source_addr,skb);
861 skb_push(skb,len);
861 862
862 /* 863 /*
863 * We can't accept the Call Request. 864 * We can't accept the Call Request.
@@ -900,11 +901,23 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
900 makex25->neighbour = nb; 901 makex25->neighbour = nb;
901 makex25->facilities = facilities; 902 makex25->facilities = facilities;
902 makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask; 903 makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask;
903 makex25->calluserdata = calluserdata; 904 /* ensure no reverse facil on accept */
904 905 makex25->vc_facil_mask &= ~X25_MASK_REVERSE;
905 x25_write_internal(make, X25_CALL_ACCEPTED); 906 makex25->cudmatchlength = x25_sk(sk)->cudmatchlength;
907
908 /* Normally all calls are accepted immediatly */
909 if(makex25->accptapprv & X25_DENY_ACCPT_APPRV) {
910 x25_write_internal(make, X25_CALL_ACCEPTED);
911 makex25->state = X25_STATE_3;
912 }
906 913
907 makex25->state = X25_STATE_3; 914 /*
915 * Incoming Call User Data.
916 */
917 if (skb->len >= 0) {
918 memcpy(makex25->calluserdata.cuddata, skb->data, skb->len);
919 makex25->calluserdata.cudlength = skb->len;
920 }
908 921
909 sk->sk_ack_backlog++; 922 sk->sk_ack_backlog++;
910 923
@@ -1288,7 +1301,8 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1288 if (facilities.throughput < 0x03 || 1301 if (facilities.throughput < 0x03 ||
1289 facilities.throughput > 0xDD) 1302 facilities.throughput > 0xDD)
1290 break; 1303 break;
1291 if (facilities.reverse && facilities.reverse != 1) 1304 if (facilities.reverse &&
1305 (facilities.reverse | 0x81)!= 0x81)
1292 break; 1306 break;
1293 x25->facilities = facilities; 1307 x25->facilities = facilities;
1294 rc = 0; 1308 rc = 0;
@@ -1325,6 +1339,44 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1325 break; 1339 break;
1326 } 1340 }
1327 1341
1342 case SIOCX25SCUDMATCHLEN: {
1343 struct x25_subaddr sub_addr;
1344 rc = -EINVAL;
1345 if(sk->sk_state != TCP_CLOSE)
1346 break;
1347 rc = -EFAULT;
1348 if (copy_from_user(&sub_addr, argp,
1349 sizeof(sub_addr)))
1350 break;
1351 rc = -EINVAL;
1352 if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN)
1353 break;
1354 x25->cudmatchlength = sub_addr.cudmatchlength;
1355 rc = 0;
1356 break;
1357 }
1358
1359 case SIOCX25CALLACCPTAPPRV: {
1360 rc = -EINVAL;
1361 if (sk->sk_state != TCP_CLOSE)
1362 break;
1363 x25->accptapprv = X25_ALLOW_ACCPT_APPRV;
1364 rc = 0;
1365 break;
1366 }
1367
1368 case SIOCX25SENDCALLACCPT: {
1369 rc = -EINVAL;
1370 if (sk->sk_state != TCP_ESTABLISHED)
1371 break;
1372 if (x25->accptapprv) /* must call accptapprv above */
1373 break;
1374 x25_write_internal(sk, X25_CALL_ACCEPTED);
1375 x25->state = X25_STATE_3;
1376 rc = 0;
1377 break;
1378 }
1379
1328 default: 1380 default:
1329 rc = dev_ioctl(cmd, argp); 1381 rc = dev_ioctl(cmd, argp);
1330 break; 1382 break;
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c
index a21bdb95f9a8..54278b962f4c 100644
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -17,6 +17,8 @@
17 * X.25 001 Split from x25_subr.c 17 * X.25 001 Split from x25_subr.c
18 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 18 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
19 * negotiation. 19 * negotiation.
20 * apr/14/05 Shaun Pereira - Allow fast select with no restriction
21 * on response.
20 */ 22 */
21 23
22#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -43,9 +45,31 @@ int x25_parse_facilities(struct sk_buff *skb,
43 case X25_FAC_CLASS_A: 45 case X25_FAC_CLASS_A:
44 switch (*p) { 46 switch (*p) {
45 case X25_FAC_REVERSE: 47 case X25_FAC_REVERSE:
46 facilities->reverse = p[1] & 0x01; 48 if((p[1] & 0x81) == 0x81) {
47 *vc_fac_mask |= X25_MASK_REVERSE; 49 facilities->reverse = p[1] & 0x81;
48 break; 50 *vc_fac_mask |= X25_MASK_REVERSE;
51 break;
52 }
53
54 if((p[1] & 0x01) == 0x01) {
55 facilities->reverse = p[1] & 0x01;
56 *vc_fac_mask |= X25_MASK_REVERSE;
57 break;
58 }
59
60 if((p[1] & 0x80) == 0x80) {
61 facilities->reverse = p[1] & 0x80;
62 *vc_fac_mask |= X25_MASK_REVERSE;
63 break;
64 }
65
66 if(p[1] == 0x00) {
67 facilities->reverse
68 = X25_DEFAULT_REVERSE;
69 *vc_fac_mask |= X25_MASK_REVERSE;
70 break;
71 }
72
49 case X25_FAC_THROUGHPUT: 73 case X25_FAC_THROUGHPUT:
50 facilities->throughput = p[1]; 74 facilities->throughput = p[1];
51 *vc_fac_mask |= X25_MASK_THROUGHPUT; 75 *vc_fac_mask |= X25_MASK_THROUGHPUT;
@@ -122,7 +146,7 @@ int x25_create_facilities(unsigned char *buffer,
122 146
123 if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) { 147 if (facilities->reverse && (facil_mask & X25_MASK_REVERSE)) {
124 *p++ = X25_FAC_REVERSE; 148 *p++ = X25_FAC_REVERSE;
125 *p++ = !!facilities->reverse; 149 *p++ = facilities->reverse;
126 } 150 }
127 151
128 if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) { 152 if (facilities->throughput && (facil_mask & X25_MASK_THROUGHPUT)) {
@@ -171,7 +195,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
171 /* 195 /*
172 * They want reverse charging, we won't accept it. 196 * They want reverse charging, we won't accept it.
173 */ 197 */
174 if (theirs.reverse && ours->reverse) { 198 if ((theirs.reverse & 0x01 ) && (ours->reverse & 0x01)) {
175 SOCK_DEBUG(sk, "X.25: rejecting reverse charging request"); 199 SOCK_DEBUG(sk, "X.25: rejecting reverse charging request");
176 return -1; 200 return -1;
177 } 201 }
diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c
index 183fea3bba67..7fd872ad0c20 100644
--- a/net/x25/x25_subr.c
+++ b/net/x25/x25_subr.c
@@ -19,6 +19,8 @@
19 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities 19 * mar/20/00 Daniela Squassoni Disabling/enabling of facilities
20 * negotiation. 20 * negotiation.
21 * jun/24/01 Arnaldo C. Melo use skb_queue_purge, cleanups 21 * jun/24/01 Arnaldo C. Melo use skb_queue_purge, cleanups
22 * apr/04/15 Shaun Pereira Fast select with no
23 * restriction on response.
22 */ 24 */
23 25
24#include <linux/kernel.h> 26#include <linux/kernel.h>
@@ -127,8 +129,12 @@ void x25_write_internal(struct sock *sk, int frametype)
127 len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + 129 len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN +
128 X25_MAX_CUD_LEN; 130 X25_MAX_CUD_LEN;
129 break; 131 break;
130 case X25_CALL_ACCEPTED: 132 case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */
131 len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; 133 if(x25->facilities.reverse & 0x80) {
134 len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN;
135 } else {
136 len += 1 + X25_MAX_FAC_LEN;
137 }
132 break; 138 break;
133 case X25_CLEAR_REQUEST: 139 case X25_CLEAR_REQUEST:
134 case X25_RESET_REQUEST: 140 case X25_RESET_REQUEST:
@@ -203,9 +209,16 @@ void x25_write_internal(struct sock *sk, int frametype)
203 x25->vc_facil_mask); 209 x25->vc_facil_mask);
204 dptr = skb_put(skb, len); 210 dptr = skb_put(skb, len);
205 memcpy(dptr, facilities, len); 211 memcpy(dptr, facilities, len);
206 dptr = skb_put(skb, x25->calluserdata.cudlength); 212
207 memcpy(dptr, x25->calluserdata.cuddata, 213 /* fast select with no restriction on response
208 x25->calluserdata.cudlength); 214 allows call user data. Userland must
215 ensure it is ours and not theirs */
216 if(x25->facilities.reverse & 0x80) {
217 dptr = skb_put(skb,
218 x25->calluserdata.cudlength);
219 memcpy(dptr, x25->calluserdata.cuddata,
220 x25->calluserdata.cudlength);
221 }
209 x25->calluserdata.cudlength = 0; 222 x25->calluserdata.cudlength = 0;
210 break; 223 break;
211 224
@@ -354,21 +367,3 @@ void x25_check_rbuf(struct sock *sk)
354 } 367 }
355} 368}
356 369
357/*
358 * Compare 2 calluserdata structures, used to find correct listening sockets
359 * when call user data is used.
360 */
361int x25_check_calluserdata(struct x25_calluserdata *ours, struct x25_calluserdata *theirs)
362{
363 int i;
364 if (ours->cudlength != theirs->cudlength)
365 return 0;
366
367 for (i=0;i<ours->cudlength;i++) {
368 if (ours->cuddata[i] != theirs->cuddata[i]) {
369 return 0;
370 }
371 }
372 return 1;
373}
374
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 352d531ee3c1..76ba6be3dfc9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -176,10 +176,10 @@ endif
176define rule_cc_o_c 176define rule_cc_o_c
177 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ 177 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \
178 $(cmd_checksrc) \ 178 $(cmd_checksrc) \
179 $(if $($(quiet)cmd_cc_o_c),echo ' $($(quiet)cmd_cc_o_c)';) \ 179 $(if $($(quiet)cmd_cc_o_c),echo ' $(subst ','\'',$($(quiet)cmd_cc_o_c))';) \
180 $(cmd_cc_o_c); \ 180 $(cmd_cc_o_c); \
181 $(cmd_modversions) \ 181 $(cmd_modversions) \
182 scripts/basic/fixdep $(depfile) $@ '$(cmd_cc_o_c)' > $(@D)/.$(@F).tmp; \ 182 scripts/basic/fixdep $(depfile) $@ '$(subst ','\'',$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \
183 rm -f $(depfile); \ 183 rm -f $(depfile); \
184 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 184 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
185endef 185endef
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index 1e1736d81ee9..ace4706ab251 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -432,8 +432,8 @@
432 <child> 432 <child>
433 <widget class="GtkScrolledWindow" id="scrolledwindow1"> 433 <widget class="GtkScrolledWindow" id="scrolledwindow1">
434 <property name="visible">True</property> 434 <property name="visible">True</property>
435 <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> 435 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
436 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> 436 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
437 <property name="shadow_type">GTK_SHADOW_IN</property> 437 <property name="shadow_type">GTK_SHADOW_IN</property>
438 <property name="window_placement">GTK_CORNER_TOP_LEFT</property> 438 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
439 439
@@ -466,8 +466,8 @@
466 <child> 466 <child>
467 <widget class="GtkScrolledWindow" id="scrolledwindow2"> 467 <widget class="GtkScrolledWindow" id="scrolledwindow2">
468 <property name="visible">True</property> 468 <property name="visible">True</property>
469 <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> 469 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
470 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> 470 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
471 <property name="shadow_type">GTK_SHADOW_IN</property> 471 <property name="shadow_type">GTK_SHADOW_IN</property>
472 <property name="window_placement">GTK_CORNER_TOP_LEFT</property> 472 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
473 473
@@ -496,7 +496,7 @@
496 <widget class="GtkScrolledWindow" id="scrolledwindow3"> 496 <widget class="GtkScrolledWindow" id="scrolledwindow3">
497 <property name="visible">True</property> 497 <property name="visible">True</property>
498 <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> 498 <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
499 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> 499 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
500 <property name="shadow_type">GTK_SHADOW_IN</property> 500 <property name="shadow_type">GTK_SHADOW_IN</property>
501 <property name="window_placement">GTK_CORNER_TOP_LEFT</property> 501 <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
502 502
diff --git a/security/commoncap.c b/security/commoncap.c
index 849b8c338ee8..04c12f58d656 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -149,7 +149,7 @@ void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
149 149
150 if (bprm->e_uid != current->uid || bprm->e_gid != current->gid || 150 if (bprm->e_uid != current->uid || bprm->e_gid != current->gid ||
151 !cap_issubset (new_permitted, current->cap_permitted)) { 151 !cap_issubset (new_permitted, current->cap_permitted)) {
152 current->mm->dumpable = 0; 152 current->mm->dumpable = suid_dumpable;
153 153
154 if (unsafe & ~LSM_UNSAFE_PTRACE_CAP) { 154 if (unsafe & ~LSM_UNSAFE_PTRACE_CAP) {
155 if (!capable(CAP_SETUID)) { 155 if (!capable(CAP_SETUID)) {
diff --git a/security/dummy.c b/security/dummy.c
index b32eff146547..6ff887586479 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -130,7 +130,7 @@ static void dummy_bprm_free_security (struct linux_binprm *bprm)
130static void dummy_bprm_apply_creds (struct linux_binprm *bprm, int unsafe) 130static void dummy_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
131{ 131{
132 if (bprm->e_uid != current->uid || bprm->e_gid != current->gid) { 132 if (bprm->e_uid != current->uid || bprm->e_gid != current->gid) {
133 current->mm->dumpable = 0; 133 current->mm->dumpable = suid_dumpable;
134 134
135 if ((unsafe & ~LSM_UNSAFE_PTRACE_CAP) && !capable(CAP_SETUID)) { 135 if ((unsafe & ~LSM_UNSAFE_PTRACE_CAP) && !capable(CAP_SETUID)) {
136 bprm->e_uid = current->uid; 136 bprm->e_uid = current->uid;
diff --git a/sound/core/info.c b/sound/core/info.c
index 31faffe01cb0..5e122bbe7c92 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -24,6 +24,7 @@
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
25#include <linux/time.h> 25#include <linux/time.h>
26#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
27#include <linux/string.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/minors.h> 29#include <sound/minors.h>
29#include <sound/info.h> 30#include <sound/info.h>
@@ -754,7 +755,7 @@ static snd_info_entry_t *snd_info_create_entry(const char *name)
754 entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); 755 entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
755 if (entry == NULL) 756 if (entry == NULL)
756 return NULL; 757 return NULL;
757 entry->name = snd_kmalloc_strdup(name, GFP_KERNEL); 758 entry->name = kstrdup(name, GFP_KERNEL);
758 if (entry->name == NULL) { 759 if (entry->name == NULL) {
759 kfree(entry); 760 kfree(entry);
760 return NULL; 761 return NULL;
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c
index f9e4ce443454..12107968d402 100644
--- a/sound/core/info_oss.c
+++ b/sound/core/info_oss.c
@@ -22,6 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/time.h> 24#include <linux/time.h>
25#include <linux/string.h>
25#include <sound/core.h> 26#include <sound/core.h>
26#include <sound/minors.h> 27#include <sound/minors.h>
27#include <sound/info.h> 28#include <sound/info.h>
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int num, char *string)
51 x = NULL; 52 x = NULL;
52 } 53 }
53 } else { 54 } else {
54 x = snd_kmalloc_strdup(string, GFP_KERNEL); 55 x = kstrdup(string, GFP_KERNEL);
55 if (x == NULL) { 56 if (x == NULL) {
56 up(&strings); 57 up(&strings);
57 return -ENOMEM; 58 return -ENOMEM;
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 20860fec9364..c1fb28e84330 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -184,6 +184,20 @@ void snd_hidden_vfree(void *obj)
184 snd_wrapper_vfree(obj); 184 snd_wrapper_vfree(obj);
185} 185}
186 186
187char *snd_hidden_kstrdup(const char *s, int flags)
188{
189 int len;
190 char *buf;
191
192 if (!s) return NULL;
193
194 len = strlen(s) + 1;
195 buf = _snd_kmalloc(len, flags);
196 if (buf)
197 memcpy(buf, s, len);
198 return buf;
199}
200
187static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) 201static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
188{ 202{
189 snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); 203 snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
@@ -214,36 +228,9 @@ int __exit snd_memory_info_done(void)
214 return 0; 228 return 0;
215} 229}
216 230
217#else
218
219#define _snd_kmalloc kmalloc
220
221#endif /* CONFIG_SND_DEBUG_MEMORY */ 231#endif /* CONFIG_SND_DEBUG_MEMORY */
222 232
223/** 233/**
224 * snd_kmalloc_strdup - copy the string
225 * @string: the original string
226 * @flags: allocation conditions, GFP_XXX
227 *
228 * Allocates a memory chunk via kmalloc() and copies the string to it.
229 *
230 * Returns the pointer, or NULL if no enoguh memory.
231 */
232char *snd_kmalloc_strdup(const char *string, int flags)
233{
234 size_t len;
235 char *ptr;
236
237 if (!string)
238 return NULL;
239 len = strlen(string) + 1;
240 ptr = _snd_kmalloc(len, flags);
241 if (ptr)
242 memcpy(ptr, string, len);
243 return ptr;
244}
245
246/**
247 * copy_to_user_fromio - copy data from mmio-space to user-space 234 * copy_to_user_fromio - copy data from mmio-space to user-space
248 * @dst: the destination pointer on user-space 235 * @dst: the destination pointer on user-space
249 * @src: the source pointer on mmio 236 * @src: the source pointer on mmio
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 98ed9a9f0da6..98fc0766f885 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -24,6 +24,7 @@
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/string.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/minors.h> 29#include <sound/minors.h>
29#include <sound/control.h> 30#include <sound/control.h>
@@ -1137,7 +1138,7 @@ static void snd_mixer_oss_proc_write(snd_info_entry_t *entry,
1137 goto __unlock; 1138 goto __unlock;
1138 } 1139 }
1139 tbl->oss_id = ch; 1140 tbl->oss_id = ch;
1140 tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL); 1141 tbl->name = kstrdup(str, GFP_KERNEL);
1141 if (! tbl->name) { 1142 if (! tbl->name) {
1142 kfree(tbl); 1143 kfree(tbl);
1143 goto __unlock; 1144 goto __unlock;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index cab30977e7c0..de7444c586f9 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -33,6 +33,7 @@
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/string.h>
36#include <sound/core.h> 37#include <sound/core.h>
37#include <sound/minors.h> 38#include <sound/minors.h>
38#include <sound/pcm.h> 39#include <sound/pcm.h>
@@ -2360,7 +2361,7 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry,
2360 for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next); 2361 for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
2361 setup1->next = setup; 2362 setup1->next = setup;
2362 } 2363 }
2363 template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL); 2364 template.task_name = kstrdup(task_name, GFP_KERNEL);
2364 } else { 2365 } else {
2365 buffer->error = -ENOMEM; 2366 buffer->error = -ENOMEM;
2366 } 2367 }
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 0815fadeb3ec..7612884f530b 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -399,8 +399,8 @@ EXPORT_SYMBOL(snd_hidden_kcalloc);
399EXPORT_SYMBOL(snd_hidden_kfree); 399EXPORT_SYMBOL(snd_hidden_kfree);
400EXPORT_SYMBOL(snd_hidden_vmalloc); 400EXPORT_SYMBOL(snd_hidden_vmalloc);
401EXPORT_SYMBOL(snd_hidden_vfree); 401EXPORT_SYMBOL(snd_hidden_vfree);
402EXPORT_SYMBOL(snd_hidden_kstrdup);
402#endif 403#endif
403EXPORT_SYMBOL(snd_kmalloc_strdup);
404EXPORT_SYMBOL(copy_to_user_fromio); 404EXPORT_SYMBOL(copy_to_user_fromio);
405EXPORT_SYMBOL(copy_from_user_toio); 405EXPORT_SYMBOL(copy_from_user_toio);
406 /* init.c */ 406 /* init.c */
diff --git a/sound/core/timer.c b/sound/core/timer.c
index b498e5482d77..cfaccd415b3b 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -26,6 +26,7 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/string.h>
29#include <sound/core.h> 30#include <sound/core.h>
30#include <sound/timer.h> 31#include <sound/timer.h>
31#include <sound/control.h> 32#include <sound/control.h>
@@ -100,7 +101,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti
100 timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); 101 timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
101 if (timeri == NULL) 102 if (timeri == NULL)
102 return NULL; 103 return NULL;
103 timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL); 104 timeri->owner = kstrdup(owner, GFP_KERNEL);
104 if (! timeri->owner) { 105 if (! timeri->owner) {
105 kfree(timeri); 106 kfree(timeri);
106 return NULL; 107 return NULL;
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index 609838e8ef67..5eb766dd564b 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -21,6 +21,7 @@
21 21
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/string.h>
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/gus.h> 26#include <sound/gus.h>
26#include <sound/info.h> 27#include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner,
213 if (share_id != NULL) 214 if (share_id != NULL)
214 memcpy(&block.share_id, share_id, sizeof(block.share_id)); 215 memcpy(&block.share_id, share_id, sizeof(block.share_id));
215 block.owner = owner; 216 block.owner = owner;
216 block.name = snd_kmalloc_strdup(name, GFP_KERNEL); 217 block.name = kstrdup(name, GFP_KERNEL);
217 nblock = snd_gf1_mem_xalloc(alloc, &block); 218 nblock = snd_gf1_mem_xalloc(alloc, &block);
218 snd_gf1_mem_lock(alloc, 1); 219 snd_gf1_mem_lock(alloc, 1);
219 return nblock; 220 return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gus)
253 if (gus->gf1.enh_mode) { 254 if (gus->gf1.enh_mode) {
254 block.ptr = 0; 255 block.ptr = 0;
255 block.size = 1024; 256 block.size = 1024;
256 block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL); 257 block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
257 if (snd_gf1_mem_xalloc(alloc, &block) == NULL) 258 if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
258 return -ENOMEM; 259 return -ENOMEM;
259 } 260 }
260 block.ptr = gus->gf1.default_voice_address; 261 block.ptr = gus->gf1.default_voice_address;
261 block.size = 4; 262 block.size = 4;
262 block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL); 263 block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
263 if (snd_gf1_mem_xalloc(alloc, &block) == NULL) 264 if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
264 return -ENOMEM; 265 return -ENOMEM;
265#ifdef CONFIG_SND_DEBUG 266#ifdef CONFIG_SND_DEBUG
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 9edd558d6bd3..bab89843d850 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1781,7 +1781,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
1781 1781
1782 knew = &spec->kctl_alloc[spec->num_kctl_used]; 1782 knew = &spec->kctl_alloc[spec->num_kctl_used];
1783 *knew = alc880_control_templates[type]; 1783 *knew = alc880_control_templates[type];
1784 knew->name = snd_kmalloc_strdup(name, GFP_KERNEL); 1784 knew->name = kstrdup(name, GFP_KERNEL);
1785 if (! knew->name) 1785 if (! knew->name)
1786 return -ENOMEM; 1786 return -ENOMEM;
1787 knew->private_value = val; 1787 knew->private_value = val;
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index 16f3b461627a..60d0b2c66698 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -22,6 +22,7 @@
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/string.h>
25#include <sound/core.h> 26#include <sound/core.h>
26#include <sound/emux_synth.h> 27#include <sound/emux_synth.h>
27#include <linux/init.h> 28#include <linux/init.h>
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
76 snd_assert(name != NULL, return -EINVAL); 77 snd_assert(name != NULL, return -EINVAL);
77 78
78 emu->card = card; 79 emu->card = card;
79 emu->name = snd_kmalloc_strdup(name, GFP_KERNEL); 80 emu->name = kstrdup(name, GFP_KERNEL);
80 emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL); 81 emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
81 if (emu->voices == NULL) 82 if (emu->voices == NULL)
82 return -ENOMEM; 83 return -ENOMEM;