aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/alpha_ksyms.c1
-rw-r--r--arch/alpha/kernel/pci-noop.c1
-rw-r--r--arch/alpha/kernel/process.c29
-rw-r--r--arch/alpha/kernel/ptrace.c47
-rw-r--r--arch/alpha/kernel/smp.c2
-rw-r--r--arch/alpha/mm/init.c1
-rw-r--r--arch/arm/common/rtctime.c1
-rw-r--r--arch/arm/kernel/apm.c1
-rw-r--r--arch/arm/kernel/process.c13
-rw-r--r--arch/arm/kernel/ptrace.c37
-rw-r--r--arch/arm/kernel/smp.c4
-rw-r--r--arch/arm/kernel/traps.c4
-rw-r--r--arch/arm/plat-omap/dma.c2
-rw-r--r--arch/arm26/kernel/armksyms.c1
-rw-r--r--arch/arm26/kernel/process.c5
-rw-r--r--arch/arm26/kernel/ptrace.c29
-rw-r--r--arch/arm26/kernel/traps.c8
-rw-r--r--arch/cris/arch-v10/drivers/ds1302.c1
-rw-r--r--arch/cris/arch-v10/drivers/pcf8563.c1
-rw-r--r--arch/cris/arch-v10/kernel/process.c4
-rw-r--r--arch/cris/arch-v10/kernel/ptrace.c4
-rw-r--r--arch/cris/arch-v32/kernel/process.c6
-rw-r--r--arch/cris/arch-v32/kernel/ptrace.c6
-rw-r--r--arch/cris/arch-v32/kernel/smp.c4
-rw-r--r--arch/cris/arch-v32/mm/tlb.c4
-rw-r--r--arch/cris/kernel/crisksyms.c2
-rw-r--r--arch/cris/kernel/process.c28
-rw-r--r--arch/frv/Kconfig4
-rw-r--r--arch/frv/boot/Makefile4
-rw-r--r--arch/frv/kernel/frv_ksyms.c2
-rw-r--r--arch/frv/kernel/process.c26
-rw-r--r--arch/h8300/kernel/gpio.c4
-rw-r--r--arch/h8300/kernel/h8300_ksyms.c7
-rw-r--r--arch/h8300/kernel/process.c30
-rw-r--r--arch/h8300/mm/memory.c13
-rw-r--r--arch/h8300/platform/h8300h/ptrace_h8300h.c12
-rw-r--r--arch/h8300/platform/h8s/ints.c4
-rw-r--r--arch/h8300/platform/h8s/ints_h8s.c4
-rw-r--r--arch/i386/Kconfig50
-rw-r--r--arch/i386/Makefile10
-rw-r--r--arch/i386/boot/Makefile4
-rw-r--r--arch/i386/boot/install.sh14
-rw-r--r--arch/i386/boot/video.S5
-rw-r--r--arch/i386/kernel/Makefile1
-rw-r--r--arch/i386/kernel/acpi/boot.c2
-rw-r--r--arch/i386/kernel/apic.c129
-rw-r--r--arch/i386/kernel/apm.c1
-rw-r--r--arch/i386/kernel/cpu/amd.c7
-rw-r--r--arch/i386/kernel/cpu/common.c17
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h25
-rw-r--r--arch/i386/kernel/cpu/intel.c5
-rw-r--r--arch/i386/kernel/cpu/mtrr/if.c1
-rw-r--r--arch/i386/kernel/cpu/proc.c27
-rw-r--r--arch/i386/kernel/crash.c50
-rw-r--r--arch/i386/kernel/crash_dump.c74
-rw-r--r--arch/i386/kernel/dmi_scan.c16
-rw-r--r--arch/i386/kernel/io_apic.c2
-rw-r--r--arch/i386/kernel/ioport.c1
-rw-r--r--arch/i386/kernel/kprobes.c23
-rw-r--r--arch/i386/kernel/microcode.c5
-rw-r--r--arch/i386/kernel/process.c26
-rw-r--r--arch/i386/kernel/reboot.c7
-rw-r--r--arch/i386/kernel/setup.c6
-rw-r--r--arch/i386/kernel/smpboot.c4
-rw-r--r--arch/i386/kernel/time.c6
-rw-r--r--arch/i386/kernel/traps.c61
-rw-r--r--arch/i386/kernel/vm86.c3
-rw-r--r--arch/i386/mm/pageattr.c2
-rw-r--r--arch/ia64/Makefile3
-rw-r--r--arch/ia64/hp/sim/simserial.c1
-rw-r--r--arch/ia64/ia32/Makefile4
-rw-r--r--arch/ia64/ia32/elfcore32.h3
-rw-r--r--arch/ia64/ia32/ia32_entry.S2
-rw-r--r--arch/ia64/ia32/ia32_ioctl.c45
-rw-r--r--arch/ia64/ia32/ia32_signal.c4
-rw-r--r--arch/ia64/ia32/ia32_support.c4
-rw-r--r--arch/ia64/ia32/sys_ia32.c41
-rw-r--r--arch/ia64/kernel/kprobes.c11
-rw-r--r--arch/ia64/kernel/mca.c4
-rw-r--r--arch/ia64/kernel/perfmon.c33
-rw-r--r--arch/ia64/kernel/process.c12
-rw-r--r--arch/ia64/kernel/ptrace.c24
-rw-r--r--arch/ia64/kernel/salinfo.c1
-rw-r--r--arch/ia64/kernel/setup.c18
-rw-r--r--arch/ia64/kernel/signal.c10
-rw-r--r--arch/ia64/kernel/sys_ia64.c2
-rw-r--r--arch/ia64/sn/kernel/tiocx.c1
-rw-r--r--arch/m32r/Kconfig4
-rw-r--r--arch/m32r/kernel/m32r_ksyms.c3
-rw-r--r--arch/m32r/kernel/process.c13
-rw-r--r--arch/m32r/kernel/ptrace.c25
-rw-r--r--arch/m32r/kernel/smpboot.c2
-rw-r--r--arch/m68k/amiga/amiints.c46
-rw-r--r--arch/m68k/amiga/amisound.c2
-rw-r--r--arch/m68k/amiga/cia.c8
-rw-r--r--arch/m68k/amiga/config.c27
-rw-r--r--arch/m68k/apollo/config.c3
-rw-r--r--arch/m68k/atari/config.c9
-rw-r--r--arch/m68k/bvme6000/rtc.c7
-rw-r--r--arch/m68k/hp300/config.c3
-rw-r--r--arch/m68k/kernel/asm-offsets.c2
-rw-r--r--arch/m68k/kernel/head.S2
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c2
-rw-r--r--arch/m68k/kernel/process.c7
-rw-r--r--arch/m68k/kernel/setup.c19
-rw-r--r--arch/m68k/kernel/signal.c62
-rw-r--r--arch/m68k/kernel/sys_m68k.c40
-rw-r--r--arch/m68k/kernel/traps.c38
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds1
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds3
-rw-r--r--arch/m68k/lib/checksum.c2
-rw-r--r--arch/m68k/mac/config.c3
-rw-r--r--arch/m68k/mac/iop.c4
-rw-r--r--arch/m68k/mac/misc.c326
-rw-r--r--arch/m68k/math-emu/multi_arith.h2
-rw-r--r--arch/m68k/mm/kmap.c12
-rw-r--r--arch/m68k/mvme16x/rtc.c7
-rw-r--r--arch/m68k/q40/config.c5
-rw-r--r--arch/m68k/sun3/config.c3
-rw-r--r--arch/m68k/sun3x/config.c4
-rw-r--r--arch/m68knommu/Makefile1
-rw-r--r--arch/m68knommu/kernel/m68k_ksyms.c2
-rw-r--r--arch/m68knommu/kernel/process.c51
-rw-r--r--arch/m68knommu/kernel/ptrace.c2
-rw-r--r--arch/m68knommu/kernel/signal.c8
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S2
-rw-r--r--arch/mips/Kconfig10
-rw-r--r--arch/mips/Makefile1
-rw-r--r--arch/mips/configs/bigsur_defconfig1
-rw-r--r--arch/mips/configs/cobalt_defconfig1
-rw-r--r--arch/mips/configs/ddb5476_defconfig1
-rw-r--r--arch/mips/configs/ddb5477_defconfig1
-rw-r--r--arch/mips/configs/ev64120_defconfig1
-rw-r--r--arch/mips/configs/ev96100_defconfig1
-rw-r--r--arch/mips/configs/ip22_defconfig1
-rw-r--r--arch/mips/configs/ip27_defconfig1
-rw-r--r--arch/mips/configs/ip32_defconfig1
-rw-r--r--arch/mips/configs/it8172_defconfig1
-rw-r--r--arch/mips/configs/ivr_defconfig1
-rw-r--r--arch/mips/configs/jaguar-atx_defconfig1
-rw-r--r--arch/mips/configs/lasat200_defconfig1
-rw-r--r--arch/mips/configs/malta_defconfig10
-rw-r--r--arch/mips/configs/ocelot_3_defconfig1
-rw-r--r--arch/mips/configs/ocelot_c_defconfig1
-rw-r--r--arch/mips/configs/ocelot_defconfig1
-rw-r--r--arch/mips/configs/ocelot_g_defconfig1
-rw-r--r--arch/mips/configs/pnx8550-v2pci_defconfig1
-rw-r--r--arch/mips/configs/rbhma4500_defconfig1
-rw-r--r--arch/mips/configs/rm200_defconfig1
-rw-r--r--arch/mips/configs/sb1250-swarm_defconfig1
-rw-r--r--arch/mips/configs/yosemite_defconfig1
-rw-r--r--arch/mips/defconfig1
-rw-r--r--arch/mips/kernel/Makefile3
-rw-r--r--arch/mips/kernel/cpu-probe.c39
-rw-r--r--arch/mips/kernel/ioctl32.c50
-rw-r--r--arch/mips/kernel/process.c12
-rw-r--r--arch/mips/kernel/ptrace.c22
-rw-r--r--arch/mips/kernel/ptrace32.c18
-rw-r--r--arch/mips/kernel/signal32.c2
-rw-r--r--arch/mips/kernel/smp_mt.c7
-rw-r--r--arch/mips/kernel/syscall.c3
-rw-r--r--arch/mips/kernel/sysirix.c1
-rw-r--r--arch/mips/kernel/time.c32
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/vpe.c8
-rw-r--r--arch/mips/lib/iomap.c2
-rw-r--r--arch/mips/math-emu/dp_fint.c2
-rw-r--r--arch/mips/math-emu/dp_flong.c2
-rw-r--r--arch/mips/math-emu/sp_fint.c2
-rw-r--r--arch/mips/math-emu/sp_flong.c2
-rw-r--r--arch/mips/mips-boards/generic/time.c33
-rw-r--r--arch/mips/mm/c-r4k.c4
-rw-r--r--arch/mips/oprofile/common.c3
-rw-r--r--arch/mips/oprofile/op_impl.h4
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c22
-rw-r--r--arch/mips/pci/fixup-capcella.c2
-rw-r--r--arch/mips/pci/fixup-mpc30x.c2
-rw-r--r--arch/mips/pci/fixup-tb0219.c2
-rw-r--r--arch/mips/pci/fixup-tb0226.c2
-rw-r--r--arch/mips/pci/fixup-tb0287.c2
-rw-r--r--arch/mips/pci/ops-vr41xx.c2
-rw-r--r--arch/mips/pci/pci-vr41xx.c2
-rw-r--r--arch/mips/pci/pci-vr41xx.h2
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-smp.c4
-rw-r--r--arch/mips/sibyte/cfe/smp.c2
-rw-r--r--arch/mips/vr41xx/casio-e55/setup.c2
-rw-r--r--arch/mips/vr41xx/common/bcu.c4
-rw-r--r--arch/mips/vr41xx/common/cmu.c4
-rw-r--r--arch/mips/vr41xx/common/icu.c4
-rw-r--r--arch/mips/vr41xx/common/init.c2
-rw-r--r--arch/mips/vr41xx/common/int-handler.S2
-rw-r--r--arch/mips/vr41xx/common/irq.c2
-rw-r--r--arch/mips/vr41xx/common/pmu.c2
-rw-r--r--arch/mips/vr41xx/common/type.c2
-rw-r--r--arch/mips/vr41xx/common/vrc4173.c2
-rw-r--r--arch/mips/vr41xx/ibm-workpad/setup.c2
-rw-r--r--arch/parisc/hpux/sys_hpux.c1
-rw-r--r--arch/parisc/kernel/Makefile3
-rw-r--r--arch/parisc/kernel/cache.c20
-rw-r--r--arch/parisc/kernel/drivers.c13
-rw-r--r--arch/parisc/kernel/firmware.c2
-rw-r--r--arch/parisc/kernel/hardware.c1
-rw-r--r--arch/parisc/kernel/inventory.c6
-rw-r--r--arch/parisc/kernel/ioctl32.c60
-rw-r--r--arch/parisc/kernel/pci-dma.c6
-rw-r--r--arch/parisc/kernel/pdc_chassis.c13
-rw-r--r--arch/parisc/kernel/perf.c7
-rw-r--r--arch/parisc/kernel/process.c8
-rw-r--r--arch/parisc/kernel/processor.c8
-rw-r--r--arch/parisc/kernel/setup.c10
-rw-r--r--arch/parisc/kernel/smp.c18
-rw-r--r--arch/parisc/kernel/time.c4
-rw-r--r--arch/parisc/kernel/topology.c3
-rw-r--r--arch/parisc/kernel/unaligned.c2
-rw-r--r--arch/parisc/kernel/unwind.c2
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S15
-rw-r--r--arch/parisc/mm/init.c29
-rw-r--r--arch/parisc/mm/ioremap.c100
-rw-r--r--arch/powerpc/Kconfig84
-rw-r--r--arch/powerpc/Kconfig.debug42
-rw-r--r--arch/powerpc/Makefile6
-rw-r--r--arch/powerpc/boot/.gitignore20
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/powerpc/configs/ppc64_defconfig4
-rw-r--r--arch/powerpc/kernel/Makefile15
-rw-r--r--arch/powerpc/kernel/crash.c2
-rw-r--r--arch/powerpc/kernel/crash_dump.c2
-rw-r--r--arch/powerpc/kernel/ioctl32.c45
-rw-r--r--arch/powerpc/kernel/kprobes.c27
-rw-r--r--arch/powerpc/kernel/machine_kexec.c6
-rw-r--r--arch/powerpc/kernel/pci_64.c10
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c1
-rw-r--r--arch/powerpc/kernel/process.c22
-rw-r--r--arch/powerpc/kernel/prom.c28
-rw-r--r--arch/powerpc/kernel/prom_init.c8
-rw-r--r--arch/powerpc/kernel/ptrace-common.h4
-rw-r--r--arch/powerpc/kernel/rtas.c13
-rw-r--r--arch/powerpc/kernel/rtas_pci.c2
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c62
-rw-r--r--arch/powerpc/kernel/signal_32.c21
-rw-r--r--arch/powerpc/kernel/signal_64.c20
-rw-r--r--arch/powerpc/kernel/smp.c6
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c56
-rw-r--r--arch/powerpc/kernel/systbl.S8
-rw-r--r--arch/powerpc/kernel/udbg.c25
-rw-r--r--arch/powerpc/kernel/udbg_16550.c2
-rw-r--r--arch/powerpc/kernel/vdso32/.gitignore1
-rw-r--r--arch/powerpc/kernel/vdso64/.gitignore1
-rw-r--r--arch/powerpc/mm/pgtable_64.c2
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig26
-rw-r--r--arch/powerpc/platforms/83xx/Makefile4
-rw-r--r--arch/powerpc/platforms/Makefile1
-rw-r--r--arch/powerpc/platforms/cell/pervasive.c2
-rw-r--r--arch/powerpc/platforms/cell/setup.c2
-rw-r--r--arch/powerpc/platforms/cell/smp.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c34
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig18
-rw-r--r--arch/powerpc/platforms/iseries/Makefile4
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c2
-rw-r--r--arch/powerpc/platforms/iseries/iommu.h35
-rw-r--r--arch/powerpc/platforms/iseries/irq.c19
-rw-r--r--arch/powerpc/platforms/iseries/lpardata.c5
-rw-r--r--arch/powerpc/platforms/iseries/lpevents.c12
-rw-r--r--arch/powerpc/platforms/iseries/mf.c16
-rw-r--r--arch/powerpc/platforms/iseries/pci.c1
-rw-r--r--arch/powerpc/platforms/iseries/setup.c37
-rw-r--r--arch/powerpc/platforms/iseries/vio.c2
-rw-r--r--arch/powerpc/platforms/iseries/viopath.c12
-rw-r--r--arch/powerpc/platforms/maple/setup.c3
-rw-r--r--arch/powerpc/platforms/powermac/setup.c2
-rw-r--r--arch/powerpc/platforms/powermac/udbg_scc.c2
-rw-r--r--arch/powerpc/platforms/pseries/Makefile2
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c490
-rw-r--r--arch/powerpc/platforms/pseries/eeh_cache.c316
-rw-r--r--arch/powerpc/platforms/pseries/eeh_driver.c376
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c39
-rw-r--r--arch/powerpc/platforms/pseries/hvcserver.c4
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c2
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c4
-rw-r--r--arch/powerpc/platforms/pseries/setup.c2
-rw-r--r--arch/powerpc/platforms/pseries/smp.c6
-rw-r--r--arch/powerpc/platforms/pseries/xics.c2
-rw-r--r--arch/powerpc/sysdev/Makefile2
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c1
-rw-r--r--arch/powerpc/xmon/xmon.c14
-rw-r--r--arch/ppc/4xx_io/serial_sicc.c1
-rw-r--r--arch/ppc/Kconfig4
-rw-r--r--arch/ppc/Makefile3
-rw-r--r--arch/ppc/amiga/amiints.c40
-rw-r--r--arch/ppc/amiga/cia.c8
-rw-r--r--arch/ppc/amiga/config.c24
-rw-r--r--arch/ppc/kernel/Makefile1
-rw-r--r--arch/ppc/kernel/machine_kexec.c6
-rw-r--r--arch/ppc/kernel/ppc_htab.c1
-rw-r--r--arch/ppc/kernel/process.c851
-rw-r--r--arch/ppc/kernel/smp.c4
-rw-r--r--arch/ppc/platforms/apus_setup.c30
-rw-r--r--arch/ppc/xmon/xmon.c2
-rw-r--r--arch/s390/Kconfig5
-rw-r--r--arch/s390/kernel/Makefile3
-rw-r--r--arch/s390/kernel/binfmt_elf32.c2
-rw-r--r--arch/s390/kernel/compat_ioctl.c81
-rw-r--r--arch/s390/kernel/compat_linux.c33
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/crash.c2
-rw-r--r--arch/s390/kernel/process.c33
-rw-r--r--arch/s390/kernel/ptrace.c26
-rw-r--r--arch/s390/kernel/s390_ksyms.c1
-rw-r--r--arch/s390/kernel/smp.c2
-rw-r--r--arch/s390/kernel/time.c2
-rw-r--r--arch/s390/kernel/traps.c6
-rw-r--r--arch/sh/kernel/process.c66
-rw-r--r--arch/sh/kernel/ptrace.c14
-rw-r--r--arch/sh/kernel/sh_ksyms.c2
-rw-r--r--arch/sh/kernel/smp.c2
-rw-r--r--arch/sh64/Kconfig4
-rw-r--r--arch/sh64/kernel/process.c24
-rw-r--r--arch/sh64/kernel/sh_ksyms.c2
-rw-r--r--arch/sh64/lib/dbg.c2
-rw-r--r--arch/sparc/kernel/process.c12
-rw-r--r--arch/sparc/kernel/ptrace.c4
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c2
-rw-r--r--arch/sparc/kernel/sun4d_smp.c2
-rw-r--r--arch/sparc/kernel/sun4m_smp.c2
-rw-r--r--arch/sparc/kernel/sys_sunos.c1
-rw-r--r--arch/sparc/kernel/traps.c4
-rw-r--r--arch/sparc64/Kconfig2
-rw-r--r--arch/sparc64/kernel/Makefile4
-rw-r--r--arch/sparc64/kernel/binfmt_aout32.c2
-rw-r--r--arch/sparc64/kernel/ioctl32.c39
-rw-r--r--arch/sparc64/kernel/kprobes.c18
-rw-r--r--arch/sparc64/kernel/process.c10
-rw-r--r--arch/sparc64/kernel/ptrace.c46
-rw-r--r--arch/sparc64/kernel/setup.c2
-rw-r--r--arch/sparc64/kernel/smp.c2
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c2
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c37
-rw-r--r--arch/sparc64/kernel/sys_sunos32.c1
-rw-r--r--arch/sparc64/kernel/systbls.S4
-rw-r--r--arch/sparc64/kernel/traps.c4
-rw-r--r--arch/sparc64/solaris/fs.c1
-rw-r--r--arch/um/Kconfig8
-rw-r--r--arch/um/Makefile23
-rw-r--r--arch/um/drivers/chan_kern.c6
-rw-r--r--arch/um/drivers/mconsole_kern.c2
-rw-r--r--arch/um/drivers/ubd_kern.c1
-rw-r--r--arch/um/include/sysdep-i386/kernel-offsets.h (renamed from arch/um/sys-i386/kernel-offsets.c)5
-rw-r--r--arch/um/include/sysdep-x86_64/kernel-offsets.h (renamed from arch/um/sys-x86_64/kernel-offsets.c)2
-rw-r--r--arch/um/kernel/asm-offsets.c2
-rw-r--r--arch/um/kernel/process_kern.c2
-rw-r--r--arch/um/kernel/skas/process.c4
-rw-r--r--arch/um/kernel/skas/process_kern.c4
-rw-r--r--arch/um/kernel/time.c7
-rw-r--r--arch/um/kernel/tt/exec_kern.c2
-rw-r--r--arch/um/kernel/tt/process_kern.c8
-rw-r--r--arch/um/kernel/um_arch.c4
-rw-r--r--arch/v850/kernel/process.c26
-rw-r--r--arch/v850/kernel/ptrace.c2
-rw-r--r--arch/v850/kernel/v850_ksyms.c2
-rw-r--r--arch/x86_64/Kconfig76
-rw-r--r--arch/x86_64/Makefile12
-rw-r--r--arch/x86_64/boot/Makefile2
-rw-r--r--arch/x86_64/boot/install.sh40
-rw-r--r--arch/x86_64/defconfig116
-rw-r--r--arch/x86_64/ia32/Makefile4
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c7
-rw-r--r--arch/x86_64/ia32/ia32_ioctl.c79
-rw-r--r--arch/x86_64/ia32/ia32_signal.c26
-rw-r--r--arch/x86_64/ia32/ia32entry.S40
-rw-r--r--arch/x86_64/ia32/ptrace32.c15
-rw-r--r--arch/x86_64/ia32/sys_ia32.c19
-rw-r--r--arch/x86_64/ia32/vsyscall-sigreturn.S1
-rw-r--r--arch/x86_64/ia32/vsyscall-syscall.S1
-rw-r--r--arch/x86_64/ia32/vsyscall-sysenter.S1
-rw-r--r--arch/x86_64/kernel/Makefile9
-rw-r--r--arch/x86_64/kernel/aperture.c3
-rw-r--r--arch/x86_64/kernel/apic.c193
-rw-r--r--arch/x86_64/kernel/asm-offsets.c5
-rw-r--r--arch/x86_64/kernel/crash.c156
-rw-r--r--arch/x86_64/kernel/crash_dump.c47
-rw-r--r--arch/x86_64/kernel/e820.c21
-rw-r--r--arch/x86_64/kernel/early_printk.c4
-rw-r--r--arch/x86_64/kernel/entry.S44
-rw-r--r--arch/x86_64/kernel/genapic_cluster.c5
-rw-r--r--arch/x86_64/kernel/genapic_flat.c10
-rw-r--r--arch/x86_64/kernel/head.S14
-rw-r--r--arch/x86_64/kernel/head64.c5
-rw-r--r--arch/x86_64/kernel/i387.c2
-rw-r--r--arch/x86_64/kernel/i8259.c5
-rw-r--r--arch/x86_64/kernel/io_apic.c167
-rw-r--r--arch/x86_64/kernel/ioport.c1
-rw-r--r--arch/x86_64/kernel/irq.c6
-rw-r--r--arch/x86_64/kernel/kprobes.c16
-rw-r--r--arch/x86_64/kernel/mce.c35
-rw-r--r--arch/x86_64/kernel/mce_amd.c6
-rw-r--r--arch/x86_64/kernel/mce_intel.c6
-rw-r--r--arch/x86_64/kernel/nmi.c8
-rw-r--r--arch/x86_64/kernel/pci-dma.c286
-rw-r--r--arch/x86_64/kernel/pci-gart.c413
-rw-r--r--arch/x86_64/kernel/pci-nommu.c145
-rw-r--r--arch/x86_64/kernel/pci-swiotlb.c42
-rw-r--r--arch/x86_64/kernel/process.c82
-rw-r--r--arch/x86_64/kernel/ptrace.c19
-rw-r--r--arch/x86_64/kernel/reboot.c10
-rw-r--r--arch/x86_64/kernel/setup.c110
-rw-r--r--arch/x86_64/kernel/setup64.c46
-rw-r--r--arch/x86_64/kernel/smp.c7
-rw-r--r--arch/x86_64/kernel/smpboot.c61
-rw-r--r--arch/x86_64/kernel/suspend.c2
-rw-r--r--arch/x86_64/kernel/time.c119
-rw-r--r--arch/x86_64/kernel/trampoline.S11
-rw-r--r--arch/x86_64/kernel/traps.c164
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S4
-rw-r--r--arch/x86_64/kernel/vsmp.c45
-rw-r--r--arch/x86_64/kernel/vsyscall.c14
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c33
-rw-r--r--arch/x86_64/lib/copy_user.S244
-rw-r--r--arch/x86_64/lib/delay.c2
-rw-r--r--arch/x86_64/lib/usercopy.c12
-rw-r--r--arch/x86_64/mm/fault.c54
-rw-r--r--arch/x86_64/mm/init.c29
-rw-r--r--arch/x86_64/mm/numa.c75
-rw-r--r--arch/x86_64/mm/srat.c67
-rw-r--r--arch/x86_64/pci/Makefile-BUS22
-rw-r--r--arch/xtensa/Kconfig4
-rw-r--r--arch/xtensa/kernel/process.c4
-rw-r--r--arch/xtensa/kernel/ptrace.c12
433 files changed, 4605 insertions, 5035 deletions
diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c
index f3e98f837784..1898ea79d0e2 100644
--- a/arch/alpha/kernel/alpha_ksyms.c
+++ b/arch/alpha/kernel/alpha_ksyms.c
@@ -40,7 +40,6 @@
40#include <asm/unistd.h> 40#include <asm/unistd.h>
41 41
42extern struct hwrpb_struct *hwrpb; 42extern struct hwrpb_struct *hwrpb;
43extern void dump_thread(struct pt_regs *, struct user *);
44extern spinlock_t rtc_lock; 43extern spinlock_t rtc_lock;
45 44
46/* these are C runtime functions with special calling conventions: */ 45/* these are C runtime functions with special calling conventions: */
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 9903e3a79102..fff5cf93e816 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -7,6 +7,7 @@
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/capability.h>
10#include <linux/mm.h> 11#include <linux/mm.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index abb739b88ed1..9924fd07743a 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -276,7 +276,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
276{ 276{
277 extern void ret_from_fork(void); 277 extern void ret_from_fork(void);
278 278
279 struct thread_info *childti = p->thread_info; 279 struct thread_info *childti = task_thread_info(p);
280 struct pt_regs * childregs; 280 struct pt_regs * childregs;
281 struct switch_stack * childstack, *stack; 281 struct switch_stack * childstack, *stack;
282 unsigned long stack_offset, settls; 282 unsigned long stack_offset, settls;
@@ -285,7 +285,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
285 if (!(regs->ps & 8)) 285 if (!(regs->ps & 8))
286 stack_offset = (PAGE_SIZE-1) & (unsigned long) regs; 286 stack_offset = (PAGE_SIZE-1) & (unsigned long) regs;
287 childregs = (struct pt_regs *) 287 childregs = (struct pt_regs *)
288 (stack_offset + PAGE_SIZE + (long) childti); 288 (stack_offset + PAGE_SIZE + task_stack_page(p));
289 289
290 *childregs = *regs; 290 *childregs = *regs;
291 settls = regs->r20; 291 settls = regs->r20;
@@ -428,30 +428,15 @@ dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt, struct thread_info *ti)
428int 428int
429dump_elf_task(elf_greg_t *dest, struct task_struct *task) 429dump_elf_task(elf_greg_t *dest, struct task_struct *task)
430{ 430{
431 struct thread_info *ti; 431 dump_elf_thread(dest, task_pt_regs(task), task_thread_info(task));
432 struct pt_regs *pt;
433
434 ti = task->thread_info;
435 pt = (struct pt_regs *)((unsigned long)ti + 2*PAGE_SIZE) - 1;
436
437 dump_elf_thread(dest, pt, ti);
438
439 return 1; 432 return 1;
440} 433}
441 434
442int 435int
443dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task) 436dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
444{ 437{
445 struct thread_info *ti; 438 struct switch_stack *sw = (struct switch_stack *)task_pt_regs(task) - 1;
446 struct pt_regs *pt;
447 struct switch_stack *sw;
448
449 ti = task->thread_info;
450 pt = (struct pt_regs *)((unsigned long)ti + 2*PAGE_SIZE) - 1;
451 sw = (struct switch_stack *)pt - 1;
452
453 memcpy(dest, sw->fp, 32 * 8); 439 memcpy(dest, sw->fp, 32 * 8);
454
455 return 1; 440 return 1;
456} 441}
457 442
@@ -492,8 +477,8 @@ out:
492unsigned long 477unsigned long
493thread_saved_pc(task_t *t) 478thread_saved_pc(task_t *t)
494{ 479{
495 unsigned long base = (unsigned long)t->thread_info; 480 unsigned long base = (unsigned long)task_stack_page(t);
496 unsigned long fp, sp = t->thread_info->pcb.ksp; 481 unsigned long fp, sp = task_thread_info(t)->pcb.ksp;
497 482
498 if (sp > base && sp+6*8 < base + 16*1024) { 483 if (sp > base && sp+6*8 < base + 16*1024) {
499 fp = ((unsigned long*)sp)[6]; 484 fp = ((unsigned long*)sp)[6];
@@ -523,7 +508,7 @@ get_wchan(struct task_struct *p)
523 508
524 pc = thread_saved_pc(p); 509 pc = thread_saved_pc(p);
525 if (in_sched_functions(pc)) { 510 if (in_sched_functions(pc)) {
526 schedule_frame = ((unsigned long *)p->thread_info->pcb.ksp)[6]; 511 schedule_frame = ((unsigned long *)task_thread_info(p)->pcb.ksp)[6];
527 return ((unsigned long *)schedule_frame)[12]; 512 return ((unsigned long *)schedule_frame)[12];
528 } 513 }
529 return pc; 514 return pc;
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index 9969d212e94d..0cd060598f9a 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -72,6 +72,13 @@ enum {
72 REG_R0 = 0, REG_F0 = 32, REG_FPCR = 63, REG_PC = 64 72 REG_R0 = 0, REG_F0 = 32, REG_FPCR = 63, REG_PC = 64
73}; 73};
74 74
75#define PT_REG(reg) \
76 (PAGE_SIZE*2 - sizeof(struct pt_regs) + offsetof(struct pt_regs, reg))
77
78#define SW_REG(reg) \
79 (PAGE_SIZE*2 - sizeof(struct pt_regs) - sizeof(struct switch_stack) \
80 + offsetof(struct switch_stack, reg))
81
75static int regoff[] = { 82static int regoff[] = {
76 PT_REG( r0), PT_REG( r1), PT_REG( r2), PT_REG( r3), 83 PT_REG( r0), PT_REG( r1), PT_REG( r2), PT_REG( r3),
77 PT_REG( r4), PT_REG( r5), PT_REG( r6), PT_REG( r7), 84 PT_REG( r4), PT_REG( r5), PT_REG( r6), PT_REG( r7),
@@ -103,14 +110,14 @@ get_reg_addr(struct task_struct * task, unsigned long regno)
103 unsigned long *addr; 110 unsigned long *addr;
104 111
105 if (regno == 30) { 112 if (regno == 30) {
106 addr = &task->thread_info->pcb.usp; 113 addr = &task_thread_info(task)->pcb.usp;
107 } else if (regno == 65) { 114 } else if (regno == 65) {
108 addr = &task->thread_info->pcb.unique; 115 addr = &task_thread_info(task)->pcb.unique;
109 } else if (regno == 31 || regno > 65) { 116 } else if (regno == 31 || regno > 65) {
110 zero = 0; 117 zero = 0;
111 addr = &zero; 118 addr = &zero;
112 } else { 119 } else {
113 addr = (void *)task->thread_info + regoff[regno]; 120 addr = task_stack_page(task) + regoff[regno];
114 } 121 }
115 return addr; 122 return addr;
116} 123}
@@ -125,7 +132,7 @@ get_reg(struct task_struct * task, unsigned long regno)
125 if (regno == 63) { 132 if (regno == 63) {
126 unsigned long fpcr = *get_reg_addr(task, regno); 133 unsigned long fpcr = *get_reg_addr(task, regno);
127 unsigned long swcr 134 unsigned long swcr
128 = task->thread_info->ieee_state & IEEE_SW_MASK; 135 = task_thread_info(task)->ieee_state & IEEE_SW_MASK;
129 swcr = swcr_update_status(swcr, fpcr); 136 swcr = swcr_update_status(swcr, fpcr);
130 return fpcr | swcr; 137 return fpcr | swcr;
131 } 138 }
@@ -139,8 +146,8 @@ static int
139put_reg(struct task_struct *task, unsigned long regno, unsigned long data) 146put_reg(struct task_struct *task, unsigned long regno, unsigned long data)
140{ 147{
141 if (regno == 63) { 148 if (regno == 63) {
142 task->thread_info->ieee_state 149 task_thread_info(task)->ieee_state
143 = ((task->thread_info->ieee_state & ~IEEE_SW_MASK) 150 = ((task_thread_info(task)->ieee_state & ~IEEE_SW_MASK)
144 | (data & IEEE_SW_MASK)); 151 | (data & IEEE_SW_MASK));
145 data = (data & FPCR_DYN_MASK) | ieee_swcr_to_fpcr(data); 152 data = (data & FPCR_DYN_MASK) | ieee_swcr_to_fpcr(data);
146 } 153 }
@@ -188,35 +195,35 @@ ptrace_set_bpt(struct task_struct * child)
188 * branch (emulation can be tricky for fp branches). 195 * branch (emulation can be tricky for fp branches).
189 */ 196 */
190 displ = ((s32)(insn << 11)) >> 9; 197 displ = ((s32)(insn << 11)) >> 9;
191 child->thread_info->bpt_addr[nsaved++] = pc + 4; 198 task_thread_info(child)->bpt_addr[nsaved++] = pc + 4;
192 if (displ) /* guard against unoptimized code */ 199 if (displ) /* guard against unoptimized code */
193 child->thread_info->bpt_addr[nsaved++] 200 task_thread_info(child)->bpt_addr[nsaved++]
194 = pc + 4 + displ; 201 = pc + 4 + displ;
195 DBG(DBG_BPT, ("execing branch\n")); 202 DBG(DBG_BPT, ("execing branch\n"));
196 } else if (op_code == 0x1a) { 203 } else if (op_code == 0x1a) {
197 reg_b = (insn >> 16) & 0x1f; 204 reg_b = (insn >> 16) & 0x1f;
198 child->thread_info->bpt_addr[nsaved++] = get_reg(child, reg_b); 205 task_thread_info(child)->bpt_addr[nsaved++] = get_reg(child, reg_b);
199 DBG(DBG_BPT, ("execing jump\n")); 206 DBG(DBG_BPT, ("execing jump\n"));
200 } else { 207 } else {
201 child->thread_info->bpt_addr[nsaved++] = pc + 4; 208 task_thread_info(child)->bpt_addr[nsaved++] = pc + 4;
202 DBG(DBG_BPT, ("execing normal insn\n")); 209 DBG(DBG_BPT, ("execing normal insn\n"));
203 } 210 }
204 211
205 /* install breakpoints: */ 212 /* install breakpoints: */
206 for (i = 0; i < nsaved; ++i) { 213 for (i = 0; i < nsaved; ++i) {
207 res = read_int(child, child->thread_info->bpt_addr[i], 214 res = read_int(child, task_thread_info(child)->bpt_addr[i],
208 (int *) &insn); 215 (int *) &insn);
209 if (res < 0) 216 if (res < 0)
210 return res; 217 return res;
211 child->thread_info->bpt_insn[i] = insn; 218 task_thread_info(child)->bpt_insn[i] = insn;
212 DBG(DBG_BPT, (" -> next_pc=%lx\n", 219 DBG(DBG_BPT, (" -> next_pc=%lx\n",
213 child->thread_info->bpt_addr[i])); 220 task_thread_info(child)->bpt_addr[i]));
214 res = write_int(child, child->thread_info->bpt_addr[i], 221 res = write_int(child, task_thread_info(child)->bpt_addr[i],
215 BREAKINST); 222 BREAKINST);
216 if (res < 0) 223 if (res < 0)
217 return res; 224 return res;
218 } 225 }
219 child->thread_info->bpt_nsaved = nsaved; 226 task_thread_info(child)->bpt_nsaved = nsaved;
220 return 0; 227 return 0;
221} 228}
222 229
@@ -227,9 +234,9 @@ ptrace_set_bpt(struct task_struct * child)
227int 234int
228ptrace_cancel_bpt(struct task_struct * child) 235ptrace_cancel_bpt(struct task_struct * child)
229{ 236{
230 int i, nsaved = child->thread_info->bpt_nsaved; 237 int i, nsaved = task_thread_info(child)->bpt_nsaved;
231 238
232 child->thread_info->bpt_nsaved = 0; 239 task_thread_info(child)->bpt_nsaved = 0;
233 240
234 if (nsaved > 2) { 241 if (nsaved > 2) {
235 printk("ptrace_cancel_bpt: bogus nsaved: %d!\n", nsaved); 242 printk("ptrace_cancel_bpt: bogus nsaved: %d!\n", nsaved);
@@ -237,8 +244,8 @@ ptrace_cancel_bpt(struct task_struct * child)
237 } 244 }
238 245
239 for (i = 0; i < nsaved; ++i) { 246 for (i = 0; i < nsaved; ++i) {
240 write_int(child, child->thread_info->bpt_addr[i], 247 write_int(child, task_thread_info(child)->bpt_addr[i],
241 child->thread_info->bpt_insn[i]); 248 task_thread_info(child)->bpt_insn[i]);
242 } 249 }
243 return (nsaved != 0); 250 return (nsaved != 0);
244} 251}
@@ -355,7 +362,7 @@ do_sys_ptrace(long request, long pid, long addr, long data,
355 if (!valid_signal(data)) 362 if (!valid_signal(data))
356 break; 363 break;
357 /* Mark single stepping. */ 364 /* Mark single stepping. */
358 child->thread_info->bpt_nsaved = -1; 365 task_thread_info(child)->bpt_nsaved = -1;
359 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 366 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
360 child->exit_code = data; 367 child->exit_code = data;
361 wake_up_process(child); 368 wake_up_process(child);
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index da0be3465791..4b873527ce1c 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -302,7 +302,7 @@ secondary_cpu_start(int cpuid, struct task_struct *idle)
302 + hwrpb->processor_offset 302 + hwrpb->processor_offset
303 + cpuid * hwrpb->processor_size); 303 + cpuid * hwrpb->processor_size);
304 hwpcb = (struct pcb_struct *) cpu->hwpcb; 304 hwpcb = (struct pcb_struct *) cpu->hwpcb;
305 ipcb = &idle->thread_info->pcb; 305 ipcb = &task_thread_info(idle)->pcb;
306 306
307 /* Initialize the CPU's HWPCB to something just good enough for 307 /* Initialize the CPU's HWPCB to something just good enough for
308 us to get started. Immediately after starting, we'll swpctx 308 us to get started. Immediately after starting, we'll swpctx
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 90752f6d8867..486d7945583d 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -7,6 +7,7 @@
7/* 2.3.x zone allocator, 1999 Andrea Arcangeli <andrea@suse.de> */ 7/* 2.3.x zone allocator, 1999 Andrea Arcangeli <andrea@suse.de> */
8 8
9#include <linux/config.h> 9#include <linux/config.h>
10#include <linux/pagemap.h>
10#include <linux/signal.h> 11#include <linux/signal.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
index 00f6278f42b8..48b1e19b131f 100644
--- a/arch/arm/common/rtctime.c
+++ b/arch/arm/common/rtctime.c
@@ -17,6 +17,7 @@
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/miscdevice.h> 18#include <linux/miscdevice.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/capability.h>
20#include <linux/device.h> 21#include <linux/device.h>
21#include <linux/mutex.h> 22#include <linux/mutex.h>
22 23
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index b9df1b782bb1..766b6c05c6db 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -18,6 +18,7 @@
18#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/apm_bios.h> 20#include <linux/apm_bios.h>
21#include <linux/capability.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/pm.h> 23#include <linux/pm.h>
23#include <linux/device.h> 24#include <linux/device.h>
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 54a21bdcba5c..4b4e4cf79c80 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -342,10 +342,10 @@ void flush_thread(void)
342void release_thread(struct task_struct *dead_task) 342void release_thread(struct task_struct *dead_task)
343{ 343{
344#if defined(CONFIG_VFP) 344#if defined(CONFIG_VFP)
345 vfp_release_thread(&dead_task->thread_info->vfpstate); 345 vfp_release_thread(&task_thread_info(dead_task)->vfpstate);
346#endif 346#endif
347#if defined(CONFIG_IWMMXT) 347#if defined(CONFIG_IWMMXT)
348 iwmmxt_task_release(dead_task->thread_info); 348 iwmmxt_task_release(task_thread_info(dead_task));
349#endif 349#endif
350} 350}
351 351
@@ -355,10 +355,9 @@ int
355copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, 355copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
356 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs) 356 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs)
357{ 357{
358 struct thread_info *thread = p->thread_info; 358 struct thread_info *thread = task_thread_info(p);
359 struct pt_regs *childregs; 359 struct pt_regs *childregs = task_pt_regs(p);
360 360
361 childregs = (void *)thread + THREAD_START_SP - sizeof(*regs);
362 *childregs = *regs; 361 *childregs = *regs;
363 childregs->ARM_r0 = 0; 362 childregs->ARM_r0 = 0;
364 childregs->ARM_sp = stack_start; 363 childregs->ARM_sp = stack_start;
@@ -460,8 +459,8 @@ unsigned long get_wchan(struct task_struct *p)
460 if (!p || p == current || p->state == TASK_RUNNING) 459 if (!p || p == current || p->state == TASK_RUNNING)
461 return 0; 460 return 0;
462 461
463 stack_start = (unsigned long)(p->thread_info + 1); 462 stack_start = (unsigned long)end_of_stack(p);
464 stack_end = ((unsigned long)p->thread_info) + THREAD_SIZE; 463 stack_end = (unsigned long)task_stack_page(p) + THREAD_SIZE;
465 464
466 fp = thread_saved_fp(p); 465 fp = thread_saved_fp(p);
467 do { 466 do {
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 2b84f78d7b0f..e591f72bcdeb 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -55,23 +55,6 @@
55#endif 55#endif
56 56
57/* 57/*
58 * Get the address of the live pt_regs for the specified task.
59 * These are saved onto the top kernel stack when the process
60 * is not running.
61 *
62 * Note: if a user thread is execve'd from kernel space, the
63 * kernel stack will not be empty on entry to the kernel, so
64 * ptracing these tasks will fail.
65 */
66static inline struct pt_regs *
67get_user_regs(struct task_struct *task)
68{
69 return (struct pt_regs *)
70 ((unsigned long)task->thread_info + THREAD_SIZE -
71 8 - sizeof(struct pt_regs));
72}
73
74/*
75 * this routine will get a word off of the processes privileged stack. 58 * this routine will get a word off of the processes privileged stack.
76 * the offset is how far from the base addr as stored in the THREAD. 59 * the offset is how far from the base addr as stored in the THREAD.
77 * this routine assumes that all the privileged stacks are in our 60 * this routine assumes that all the privileged stacks are in our
@@ -79,7 +62,7 @@ get_user_regs(struct task_struct *task)
79 */ 62 */
80static inline long get_user_reg(struct task_struct *task, int offset) 63static inline long get_user_reg(struct task_struct *task, int offset)
81{ 64{
82 return get_user_regs(task)->uregs[offset]; 65 return task_pt_regs(task)->uregs[offset];
83} 66}
84 67
85/* 68/*
@@ -91,7 +74,7 @@ static inline long get_user_reg(struct task_struct *task, int offset)
91static inline int 74static inline int
92put_user_reg(struct task_struct *task, int offset, long data) 75put_user_reg(struct task_struct *task, int offset, long data)
93{ 76{
94 struct pt_regs newregs, *regs = get_user_regs(task); 77 struct pt_regs newregs, *regs = task_pt_regs(task);
95 int ret = -EINVAL; 78 int ret = -EINVAL;
96 79
97 newregs = *regs; 80 newregs = *regs;
@@ -421,7 +404,7 @@ void ptrace_set_bpt(struct task_struct *child)
421 u32 insn; 404 u32 insn;
422 int res; 405 int res;
423 406
424 regs = get_user_regs(child); 407 regs = task_pt_regs(child);
425 pc = instruction_pointer(regs); 408 pc = instruction_pointer(regs);
426 409
427 if (thumb_mode(regs)) { 410 if (thumb_mode(regs)) {
@@ -572,7 +555,7 @@ static int ptrace_write_user(struct task_struct *tsk, unsigned long off,
572 */ 555 */
573static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 556static int ptrace_getregs(struct task_struct *tsk, void __user *uregs)
574{ 557{
575 struct pt_regs *regs = get_user_regs(tsk); 558 struct pt_regs *regs = task_pt_regs(tsk);
576 559
577 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 560 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
578} 561}
@@ -587,7 +570,7 @@ static int ptrace_setregs(struct task_struct *tsk, void __user *uregs)
587 570
588 ret = -EFAULT; 571 ret = -EFAULT;
589 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 572 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) {
590 struct pt_regs *regs = get_user_regs(tsk); 573 struct pt_regs *regs = task_pt_regs(tsk);
591 574
592 ret = -EINVAL; 575 ret = -EINVAL;
593 if (valid_user_regs(&newregs)) { 576 if (valid_user_regs(&newregs)) {
@@ -604,7 +587,7 @@ static int ptrace_setregs(struct task_struct *tsk, void __user *uregs)
604 */ 587 */
605static int ptrace_getfpregs(struct task_struct *tsk, void __user *ufp) 588static int ptrace_getfpregs(struct task_struct *tsk, void __user *ufp)
606{ 589{
607 return copy_to_user(ufp, &tsk->thread_info->fpstate, 590 return copy_to_user(ufp, &task_thread_info(tsk)->fpstate,
608 sizeof(struct user_fp)) ? -EFAULT : 0; 591 sizeof(struct user_fp)) ? -EFAULT : 0;
609} 592}
610 593
@@ -613,7 +596,7 @@ static int ptrace_getfpregs(struct task_struct *tsk, void __user *ufp)
613 */ 596 */
614static int ptrace_setfpregs(struct task_struct *tsk, void __user *ufp) 597static int ptrace_setfpregs(struct task_struct *tsk, void __user *ufp)
615{ 598{
616 struct thread_info *thread = tsk->thread_info; 599 struct thread_info *thread = task_thread_info(tsk);
617 thread->used_cp[1] = thread->used_cp[2] = 1; 600 thread->used_cp[1] = thread->used_cp[2] = 1;
618 return copy_from_user(&thread->fpstate, ufp, 601 return copy_from_user(&thread->fpstate, ufp,
619 sizeof(struct user_fp)) ? -EFAULT : 0; 602 sizeof(struct user_fp)) ? -EFAULT : 0;
@@ -626,7 +609,7 @@ static int ptrace_setfpregs(struct task_struct *tsk, void __user *ufp)
626 */ 609 */
627static int ptrace_getwmmxregs(struct task_struct *tsk, void __user *ufp) 610static int ptrace_getwmmxregs(struct task_struct *tsk, void __user *ufp)
628{ 611{
629 struct thread_info *thread = tsk->thread_info; 612 struct thread_info *thread = task_thread_info(tsk);
630 void *ptr = &thread->fpstate; 613 void *ptr = &thread->fpstate;
631 614
632 if (!test_ti_thread_flag(thread, TIF_USING_IWMMXT)) 615 if (!test_ti_thread_flag(thread, TIF_USING_IWMMXT))
@@ -643,7 +626,7 @@ static int ptrace_getwmmxregs(struct task_struct *tsk, void __user *ufp)
643 */ 626 */
644static int ptrace_setwmmxregs(struct task_struct *tsk, void __user *ufp) 627static int ptrace_setwmmxregs(struct task_struct *tsk, void __user *ufp)
645{ 628{
646 struct thread_info *thread = tsk->thread_info; 629 struct thread_info *thread = task_thread_info(tsk);
647 void *ptr = &thread->fpstate; 630 void *ptr = &thread->fpstate;
648 631
649 if (!test_ti_thread_flag(thread, TIF_USING_IWMMXT)) 632 if (!test_ti_thread_flag(thread, TIF_USING_IWMMXT))
@@ -779,7 +762,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
779#endif 762#endif
780 763
781 case PTRACE_GET_THREAD_AREA: 764 case PTRACE_GET_THREAD_AREA:
782 ret = put_user(child->thread_info->tp_value, 765 ret = put_user(task_thread_info(child)->tp_value,
783 (unsigned long __user *) data); 766 (unsigned long __user *) data);
784 break; 767 break;
785 768
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 373c0959bc2f..7338948bd7d3 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -114,7 +114,7 @@ int __cpuinit __cpu_up(unsigned int cpu)
114 * We need to tell the secondary core where to find 114 * We need to tell the secondary core where to find
115 * its stack and the page tables. 115 * its stack and the page tables.
116 */ 116 */
117 secondary_data.stack = (void *)idle->thread_info + THREAD_START_SP; 117 secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
118 secondary_data.pgdir = virt_to_phys(pgd); 118 secondary_data.pgdir = virt_to_phys(pgd);
119 wmb(); 119 wmb();
120 120
@@ -245,7 +245,7 @@ void __cpuexit cpu_die(void)
245 __asm__("mov sp, %0\n" 245 __asm__("mov sp, %0\n"
246 " b secondary_start_kernel" 246 " b secondary_start_kernel"
247 : 247 :
248 : "r" ((void *)current->thread_info + THREAD_SIZE - 8)); 248 : "r" (task_stack_page(current) + THREAD_SIZE - 8));
249} 249}
250#endif /* CONFIG_HOTPLUG_CPU */ 250#endif /* CONFIG_HOTPLUG_CPU */
251 251
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index c9fe6f5f7ee3..93cfd3ffcc72 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -164,7 +164,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
164 } else if (verify_stack(fp)) { 164 } else if (verify_stack(fp)) {
165 printk("invalid frame pointer 0x%08x", fp); 165 printk("invalid frame pointer 0x%08x", fp);
166 ok = 0; 166 ok = 0;
167 } else if (fp < (unsigned long)(tsk->thread_info + 1)) 167 } else if (fp < (unsigned long)end_of_stack(tsk))
168 printk("frame pointer underflow"); 168 printk("frame pointer underflow");
169 printk("\n"); 169 printk("\n");
170 170
@@ -210,7 +210,7 @@ static void __die(const char *str, int err, struct thread_info *thread, struct p
210 210
211 if (!user_mode(regs) || in_interrupt()) { 211 if (!user_mode(regs) || in_interrupt()) {
212 dump_mem("Stack: ", regs->ARM_sp, 212 dump_mem("Stack: ", regs->ARM_sp,
213 THREAD_SIZE + (unsigned long)tsk->thread_info); 213 THREAD_SIZE + (unsigned long)task_stack_page(tsk));
214 dump_backtrace(regs, tsk); 214 dump_backtrace(regs, tsk);
215 dump_instr(regs); 215 dump_instr(regs);
216 } 216 }
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index f5cc21ad0956..a4e5ac77f6df 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -64,7 +64,7 @@ static int dma_chan_count;
64static spinlock_t dma_chan_lock; 64static spinlock_t dma_chan_lock;
65static struct omap_dma_lch dma_chan[OMAP_LOGICAL_DMA_CH_COUNT]; 65static struct omap_dma_lch dma_chan[OMAP_LOGICAL_DMA_CH_COUNT];
66 66
67const static u8 omap1_dma_irq[OMAP_LOGICAL_DMA_CH_COUNT] = { 67static const u8 omap1_dma_irq[OMAP_LOGICAL_DMA_CH_COUNT] = {
68 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3, 68 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3,
69 INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7, 69 INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7,
70 INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10, 70 INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10,
diff --git a/arch/arm26/kernel/armksyms.c b/arch/arm26/kernel/armksyms.c
index 35514b398e2e..811a6376c624 100644
--- a/arch/arm26/kernel/armksyms.c
+++ b/arch/arm26/kernel/armksyms.c
@@ -35,7 +35,6 @@
35#include <asm/checksum.h> 35#include <asm/checksum.h>
36#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37 37
38extern void dump_thread(struct pt_regs *, struct user *);
39extern int dump_fpu(struct pt_regs *, struct user_fp_struct *); 38extern int dump_fpu(struct pt_regs *, struct user_fp_struct *);
40extern void inswb(unsigned int port, void *to, int len); 39extern void inswb(unsigned int port, void *to, int len);
41extern void outswb(unsigned int port, const void *to, int len); 40extern void outswb(unsigned int port, const void *to, int len);
diff --git a/arch/arm26/kernel/process.c b/arch/arm26/kernel/process.c
index 15833a0057dd..386305659171 100644
--- a/arch/arm26/kernel/process.c
+++ b/arch/arm26/kernel/process.c
@@ -277,10 +277,9 @@ int
277copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, 277copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
278 unsigned long unused, struct task_struct *p, struct pt_regs *regs) 278 unsigned long unused, struct task_struct *p, struct pt_regs *regs)
279{ 279{
280 struct thread_info *thread = p->thread_info; 280 struct thread_info *thread = task_thread_info(p);
281 struct pt_regs *childregs; 281 struct pt_regs *childregs = task_pt_regs(p);
282 282
283 childregs = __get_user_regs(thread);
284 *childregs = *regs; 283 *childregs = *regs;
285 childregs->ARM_r0 = 0; 284 childregs->ARM_r0 = 0;
286 childregs->ARM_sp = stack_start; 285 childregs->ARM_sp = stack_start;
diff --git a/arch/arm26/kernel/ptrace.c b/arch/arm26/kernel/ptrace.c
index 4e6b7356a722..3c3371d4683e 100644
--- a/arch/arm26/kernel/ptrace.c
+++ b/arch/arm26/kernel/ptrace.c
@@ -40,21 +40,6 @@
40#define BREAKINST_ARM 0xef9f0001 40#define BREAKINST_ARM 0xef9f0001
41 41
42/* 42/*
43 * Get the address of the live pt_regs for the specified task.
44 * These are saved onto the top kernel stack when the process
45 * is not running.
46 *
47 * Note: if a user thread is execve'd from kernel space, the
48 * kernel stack will not be empty on entry to the kernel, so
49 * ptracing these tasks will fail.
50 */
51static inline struct pt_regs *
52get_user_regs(struct task_struct *task)
53{
54 return __get_user_regs(task->thread_info);
55}
56
57/*
58 * this routine will get a word off of the processes privileged stack. 43 * this routine will get a word off of the processes privileged stack.
59 * the offset is how far from the base addr as stored in the THREAD. 44 * the offset is how far from the base addr as stored in the THREAD.
60 * this routine assumes that all the privileged stacks are in our 45 * this routine assumes that all the privileged stacks are in our
@@ -62,7 +47,7 @@ get_user_regs(struct task_struct *task)
62 */ 47 */
63static inline long get_user_reg(struct task_struct *task, int offset) 48static inline long get_user_reg(struct task_struct *task, int offset)
64{ 49{
65 return get_user_regs(task)->uregs[offset]; 50 return task_pt_regs(task)->uregs[offset];
66} 51}
67 52
68/* 53/*
@@ -74,7 +59,7 @@ static inline long get_user_reg(struct task_struct *task, int offset)
74static inline int 59static inline int
75put_user_reg(struct task_struct *task, int offset, long data) 60put_user_reg(struct task_struct *task, int offset, long data)
76{ 61{
77 struct pt_regs newregs, *regs = get_user_regs(task); 62 struct pt_regs newregs, *regs = task_pt_regs(task);
78 int ret = -EINVAL; 63 int ret = -EINVAL;
79 64
80 newregs = *regs; 65 newregs = *regs;
@@ -377,7 +362,7 @@ void ptrace_set_bpt(struct task_struct *child)
377 u32 insn; 362 u32 insn;
378 int res; 363 int res;
379 364
380 regs = get_user_regs(child); 365 regs = task_pt_regs(child);
381 pc = instruction_pointer(regs); 366 pc = instruction_pointer(regs);
382 367
383 res = read_instr(child, pc, &insn); 368 res = read_instr(child, pc, &insn);
@@ -500,7 +485,7 @@ static int ptrace_write_user(struct task_struct *tsk, unsigned long off,
500 */ 485 */
501static int ptrace_getregs(struct task_struct *tsk, void *uregs) 486static int ptrace_getregs(struct task_struct *tsk, void *uregs)
502{ 487{
503 struct pt_regs *regs = get_user_regs(tsk); 488 struct pt_regs *regs = task_pt_regs(tsk);
504 489
505 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 490 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
506} 491}
@@ -515,7 +500,7 @@ static int ptrace_setregs(struct task_struct *tsk, void *uregs)
515 500
516 ret = -EFAULT; 501 ret = -EFAULT;
517 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 502 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) {
518 struct pt_regs *regs = get_user_regs(tsk); 503 struct pt_regs *regs = task_pt_regs(tsk);
519 504
520 ret = -EINVAL; 505 ret = -EINVAL;
521 if (valid_user_regs(&newregs)) { 506 if (valid_user_regs(&newregs)) {
@@ -532,7 +517,7 @@ static int ptrace_setregs(struct task_struct *tsk, void *uregs)
532 */ 517 */
533static int ptrace_getfpregs(struct task_struct *tsk, void *ufp) 518static int ptrace_getfpregs(struct task_struct *tsk, void *ufp)
534{ 519{
535 return copy_to_user(ufp, &tsk->thread_info->fpstate, 520 return copy_to_user(ufp, &task_thread_info(tsk)->fpstate,
536 sizeof(struct user_fp)) ? -EFAULT : 0; 521 sizeof(struct user_fp)) ? -EFAULT : 0;
537} 522}
538 523
@@ -542,7 +527,7 @@ static int ptrace_getfpregs(struct task_struct *tsk, void *ufp)
542static int ptrace_setfpregs(struct task_struct *tsk, void *ufp) 527static int ptrace_setfpregs(struct task_struct *tsk, void *ufp)
543{ 528{
544 set_stopped_child_used_math(tsk); 529 set_stopped_child_used_math(tsk);
545 return copy_from_user(&tsk->thread_info->fpstate, ufp, 530 return copy_from_user(&task_threas_info(tsk)->fpstate, ufp,
546 sizeof(struct user_fp)) ? -EFAULT : 0; 531 sizeof(struct user_fp)) ? -EFAULT : 0;
547} 532}
548 533
diff --git a/arch/arm26/kernel/traps.c b/arch/arm26/kernel/traps.c
index f64f59022392..5847ea5d7747 100644
--- a/arch/arm26/kernel/traps.c
+++ b/arch/arm26/kernel/traps.c
@@ -132,7 +132,7 @@ static void dump_instr(struct pt_regs *regs)
132 132
133/*static*/ void __dump_stack(struct task_struct *tsk, unsigned long sp) 133/*static*/ void __dump_stack(struct task_struct *tsk, unsigned long sp)
134{ 134{
135 dump_mem("Stack: ", sp, 8192+(unsigned long)tsk->thread_info); 135 dump_mem("Stack: ", sp, 8192+(unsigned long)task_stack_page(tsk));
136} 136}
137 137
138void dump_stack(void) 138void dump_stack(void)
@@ -158,7 +158,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
158 } else if (verify_stack(fp)) { 158 } else if (verify_stack(fp)) {
159 printk("invalid frame pointer 0x%08x", fp); 159 printk("invalid frame pointer 0x%08x", fp);
160 ok = 0; 160 ok = 0;
161 } else if (fp < (unsigned long)(tsk->thread_info + 1)) 161 } else if (fp < (unsigned long)end_of_stack(tsk))
162 printk("frame pointer underflow"); 162 printk("frame pointer underflow");
163 printk("\n"); 163 printk("\n");
164 164
@@ -168,7 +168,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
168 168
169/* FIXME - this is probably wrong.. */ 169/* FIXME - this is probably wrong.. */
170void show_stack(struct task_struct *task, unsigned long *sp) { 170void show_stack(struct task_struct *task, unsigned long *sp) {
171 dump_mem("Stack: ", (unsigned long)sp, 8192+(unsigned long)task->thread_info); 171 dump_mem("Stack: ", (unsigned long)sp, 8192+(unsigned long)task_stack_page(task));
172} 172}
173 173
174DEFINE_SPINLOCK(die_lock); 174DEFINE_SPINLOCK(die_lock);
@@ -187,7 +187,7 @@ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
187 printk("CPU: %d\n", smp_processor_id()); 187 printk("CPU: %d\n", smp_processor_id());
188 show_regs(regs); 188 show_regs(regs);
189 printk("Process %s (pid: %d, stack limit = 0x%p)\n", 189 printk("Process %s (pid: %d, stack limit = 0x%p)\n",
190 current->comm, current->pid, tsk->thread_info + 1); 190 current->comm, current->pid, end_of_stack(tsk));
191 191
192 if (!user_mode(regs) || in_interrupt()) { 192 if (!user_mode(regs) || in_interrupt()) {
193 __dump_stack(tsk, (unsigned long)(regs + 1)); 193 __dump_stack(tsk, (unsigned long)(regs + 1));
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 10795f67f687..b100f26497c4 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -148,6 +148,7 @@
148#include <linux/miscdevice.h> 148#include <linux/miscdevice.h>
149#include <linux/delay.h> 149#include <linux/delay.h>
150#include <linux/bcd.h> 150#include <linux/bcd.h>
151#include <linux/capability.h>
151 152
152#include <asm/uaccess.h> 153#include <asm/uaccess.h>
153#include <asm/system.h> 154#include <asm/system.h>
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index f2c55742e90c..af517c210383 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -28,6 +28,7 @@
28#include <linux/ioctl.h> 28#include <linux/ioctl.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/bcd.h> 30#include <linux/bcd.h>
31#include <linux/capability.h>
31 32
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33#include <asm/system.h> 34#include <asm/system.h>
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c
index 69e28b4057e8..0a675ce9e099 100644
--- a/arch/cris/arch-v10/kernel/process.c
+++ b/arch/cris/arch-v10/kernel/process.c
@@ -79,7 +79,7 @@ void hard_reset_now (void)
79 */ 79 */
80unsigned long thread_saved_pc(struct task_struct *t) 80unsigned long thread_saved_pc(struct task_struct *t)
81{ 81{
82 return (unsigned long)user_regs(t->thread_info)->irp; 82 return task_pt_regs(t)->irp;
83} 83}
84 84
85static void kernel_thread_helper(void* dummy, int (*fn)(void *), void * arg) 85static void kernel_thread_helper(void* dummy, int (*fn)(void *), void * arg)
@@ -128,7 +128,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
128 * remember that the task_struct doubles as the kernel stack for the task 128 * remember that the task_struct doubles as the kernel stack for the task
129 */ 129 */
130 130
131 childregs = user_regs(p->thread_info); 131 childregs = task_pt_regs(p);
132 132
133 *childregs = *regs; /* struct copy of pt_regs */ 133 *childregs = *regs; /* struct copy of pt_regs */
134 134
diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
index 6cbd34a27b90..f214f74f264e 100644
--- a/arch/cris/arch-v10/kernel/ptrace.c
+++ b/arch/cris/arch-v10/kernel/ptrace.c
@@ -37,7 +37,7 @@ inline long get_reg(struct task_struct *task, unsigned int regno)
37 if (regno == PT_USP) 37 if (regno == PT_USP)
38 return task->thread.usp; 38 return task->thread.usp;
39 else if (regno < PT_MAX) 39 else if (regno < PT_MAX)
40 return ((unsigned long *)user_regs(task->thread_info))[regno]; 40 return ((unsigned long *)task_pt_regs(task))[regno];
41 else 41 else
42 return 0; 42 return 0;
43} 43}
@@ -51,7 +51,7 @@ inline int put_reg(struct task_struct *task, unsigned int regno,
51 if (regno == PT_USP) 51 if (regno == PT_USP)
52 task->thread.usp = data; 52 task->thread.usp = data;
53 else if (regno < PT_MAX) 53 else if (regno < PT_MAX)
54 ((unsigned long *)user_regs(task->thread_info))[regno] = data; 54 ((unsigned long *)task_pt_regs(task))[regno] = data;
55 else 55 else
56 return -1; 56 return -1;
57 return 0; 57 return 0;
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index 882be42114f7..843513102d3c 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -96,7 +96,7 @@ hard_reset_now(void)
96 */ 96 */
97unsigned long thread_saved_pc(struct task_struct *t) 97unsigned long thread_saved_pc(struct task_struct *t)
98{ 98{
99 return (unsigned long)user_regs(t->thread_info)->erp; 99 return task_pt_regs(t)->erp;
100} 100}
101 101
102static void 102static void
@@ -148,7 +148,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
148 * fix it up. Note: the task_struct doubles as the kernel stack for the 148 * fix it up. Note: the task_struct doubles as the kernel stack for the
149 * task. 149 * task.
150 */ 150 */
151 childregs = user_regs(p->thread_info); 151 childregs = task_pt_regs(p);
152 *childregs = *regs; /* Struct copy of pt_regs. */ 152 *childregs = *regs; /* Struct copy of pt_regs. */
153 p->set_child_tid = p->clear_child_tid = NULL; 153 p->set_child_tid = p->clear_child_tid = NULL;
154 childregs->r10 = 0; /* Child returns 0 after a fork/clone. */ 154 childregs->r10 = 0; /* Child returns 0 after a fork/clone. */
@@ -157,7 +157,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
157 * The TLS is in $mof beacuse it is the 5th argument to sys_clone. 157 * The TLS is in $mof beacuse it is the 5th argument to sys_clone.
158 */ 158 */
159 if (p->mm && (clone_flags & CLONE_SETTLS)) { 159 if (p->mm && (clone_flags & CLONE_SETTLS)) {
160 p->thread_info->tls = regs->mof; 160 task_thread_info(p)->tls = regs->mof;
161 } 161 }
162 162
163 /* Put the switch stack right below the pt_regs. */ 163 /* Put the switch stack right below the pt_regs. */
diff --git a/arch/cris/arch-v32/kernel/ptrace.c b/arch/cris/arch-v32/kernel/ptrace.c
index 5528b83a622b..82cf2e3624a4 100644
--- a/arch/cris/arch-v32/kernel/ptrace.c
+++ b/arch/cris/arch-v32/kernel/ptrace.c
@@ -46,7 +46,7 @@ long get_reg(struct task_struct *task, unsigned int regno)
46 unsigned long ret; 46 unsigned long ret;
47 47
48 if (regno <= PT_EDA) 48 if (regno <= PT_EDA)
49 ret = ((unsigned long *)user_regs(task->thread_info))[regno]; 49 ret = ((unsigned long *)task_pt_regs(task))[regno];
50 else if (regno == PT_USP) 50 else if (regno == PT_USP)
51 ret = task->thread.usp; 51 ret = task->thread.usp;
52 else if (regno == PT_PPC) 52 else if (regno == PT_PPC)
@@ -65,13 +65,13 @@ long get_reg(struct task_struct *task, unsigned int regno)
65int put_reg(struct task_struct *task, unsigned int regno, unsigned long data) 65int put_reg(struct task_struct *task, unsigned int regno, unsigned long data)
66{ 66{
67 if (regno <= PT_EDA) 67 if (regno <= PT_EDA)
68 ((unsigned long *)user_regs(task->thread_info))[regno] = data; 68 ((unsigned long *)task_pt_regs(task))[regno] = data;
69 else if (regno == PT_USP) 69 else if (regno == PT_USP)
70 task->thread.usp = data; 70 task->thread.usp = data;
71 else if (regno == PT_PPC) { 71 else if (regno == PT_PPC) {
72 /* Write pseudo-PC to ERP only if changed. */ 72 /* Write pseudo-PC to ERP only if changed. */
73 if (data != get_pseudo_pc(task)) 73 if (data != get_pseudo_pc(task))
74 ((unsigned long *)user_regs(task->thread_info))[PT_ERP] = data; 74 task_pt_regs(task)->erp = data;
75 } else if (regno <= PT_MAX) 75 } else if (regno <= PT_MAX)
76 return put_debugreg(task->pid, regno, data); 76 return put_debugreg(task->pid, regno, data);
77 else 77 else
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 13867f4fad16..da40d19a151e 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -113,10 +113,10 @@ smp_boot_one_cpu(int cpuid)
113 if (IS_ERR(idle)) 113 if (IS_ERR(idle))
114 panic("SMP: fork failed for CPU:%d", cpuid); 114 panic("SMP: fork failed for CPU:%d", cpuid);
115 115
116 idle->thread_info->cpu = cpuid; 116 task_thread_info(idle)->cpu = cpuid;
117 117
118 /* Information to the CPU that is about to boot */ 118 /* Information to the CPU that is about to boot */
119 smp_init_current_idle_thread = idle->thread_info; 119 smp_init_current_idle_thread = task_thread_info(idle);
120 cpu_now_booting = cpuid; 120 cpu_now_booting = cpuid;
121 121
122 /* Wait for CPU to come online */ 122 /* Wait for CPU to come online */
diff --git a/arch/cris/arch-v32/mm/tlb.c b/arch/cris/arch-v32/mm/tlb.c
index b08a28bb58ab..9d75d7692303 100644
--- a/arch/cris/arch-v32/mm/tlb.c
+++ b/arch/cris/arch-v32/mm/tlb.c
@@ -198,9 +198,9 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
198 per_cpu(current_pgd, cpu) = next->pgd; 198 per_cpu(current_pgd, cpu) = next->pgd;
199 199
200 /* Switch context in the MMU. */ 200 /* Switch context in the MMU. */
201 if (tsk && tsk->thread_info) 201 if (tsk && task_thread_info(tsk))
202 { 202 {
203 SPEC_REG_WR(SPEC_REG_PID, next->context.page_id | tsk->thread_info->tls); 203 SPEC_REG_WR(SPEC_REG_PID, next->context.page_id | task_thread_info(tsk)->tls);
204 } 204 }
205 else 205 else
206 { 206 {
diff --git a/arch/cris/kernel/crisksyms.c b/arch/cris/kernel/crisksyms.c
index 85833d704ebb..de39725da920 100644
--- a/arch/cris/kernel/crisksyms.c
+++ b/arch/cris/kernel/crisksyms.c
@@ -21,7 +21,6 @@
21#include <asm/pgtable.h> 21#include <asm/pgtable.h>
22#include <asm/fasttimer.h> 22#include <asm/fasttimer.h>
23 23
24extern void dump_thread(struct pt_regs *, struct user *);
25extern unsigned long get_cmos_time(void); 24extern unsigned long get_cmos_time(void);
26extern void __Udiv(void); 25extern void __Udiv(void);
27extern void __Umod(void); 26extern void __Umod(void);
@@ -33,7 +32,6 @@ extern void __lshrdi3(void);
33extern void iounmap(volatile void * __iomem); 32extern void iounmap(volatile void * __iomem);
34 33
35/* Platform dependent support */ 34/* Platform dependent support */
36EXPORT_SYMBOL(dump_thread);
37EXPORT_SYMBOL(kernel_thread); 35EXPORT_SYMBOL(kernel_thread);
38EXPORT_SYMBOL(get_cmos_time); 36EXPORT_SYMBOL(get_cmos_time);
39EXPORT_SYMBOL(loops_per_usec); 37EXPORT_SYMBOL(loops_per_usec);
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 7c80afb10460..4ab3e87115b6 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -257,34 +257,6 @@ void flush_thread(void)
257{ 257{
258} 258}
259 259
260/*
261 * fill in the user structure for a core dump..
262 */
263void dump_thread(struct pt_regs * regs, struct user * dump)
264{
265#if 0
266 int i;
267
268 /* changed the size calculations - should hopefully work better. lbt */
269 dump->magic = CMAGIC;
270 dump->start_code = 0;
271 dump->start_stack = regs->esp & ~(PAGE_SIZE - 1);
272 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
273 dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
274 dump->u_dsize -= dump->u_tsize;
275 dump->u_ssize = 0;
276 for (i = 0; i < 8; i++)
277 dump->u_debugreg[i] = current->debugreg[i];
278
279 if (dump->start_stack < TASK_SIZE)
280 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
281
282 dump->regs = *regs;
283
284 dump->u_fpvalid = dump_fpu (regs, &dump->i387);
285#endif
286}
287
288/* Fill in the fpu structure for a core dump. */ 260/* Fill in the fpu structure for a core dump. */
289int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu) 261int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
290{ 262{
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 61261b78ced7..60a617aff8ba 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -6,10 +6,6 @@ config FRV
6 bool 6 bool
7 default y 7 default y
8 8
9config UID16
10 bool
11 default y
12
13config RWSEM_GENERIC_SPINLOCK 9config RWSEM_GENERIC_SPINLOCK
14 bool 10 bool
15 default y 11 default y
diff --git a/arch/frv/boot/Makefile b/arch/frv/boot/Makefile
index d75e0d771366..5dfc93fd945a 100644
--- a/arch/frv/boot/Makefile
+++ b/arch/frv/boot/Makefile
@@ -57,10 +57,10 @@ initrd:
57# installation 57# installation
58# 58#
59install: $(CONFIGURE) Image 59install: $(CONFIGURE) Image
60 sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" 60 sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"
61 61
62zinstall: $(CONFIGURE) zImage 62zinstall: $(CONFIGURE) zImage
63 sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" 63 sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"
64 64
65# 65#
66# miscellany 66# miscellany
diff --git a/arch/frv/kernel/frv_ksyms.c b/arch/frv/kernel/frv_ksyms.c
index 5f118c89d091..0f1c6cbc4f50 100644
--- a/arch/frv/kernel/frv_ksyms.c
+++ b/arch/frv/kernel/frv_ksyms.c
@@ -18,7 +18,6 @@
18#include <asm/hardirq.h> 18#include <asm/hardirq.h>
19#include <asm/cacheflush.h> 19#include <asm/cacheflush.h>
20 20
21extern void dump_thread(struct pt_regs *, struct user *);
22extern long __memcpy_user(void *dst, const void *src, size_t count); 21extern long __memcpy_user(void *dst, const void *src, size_t count);
23extern long __memset_user(void *dst, const void *src, size_t count); 22extern long __memset_user(void *dst, const void *src, size_t count);
24 23
@@ -27,7 +26,6 @@ extern long __memset_user(void *dst, const void *src, size_t count);
27EXPORT_SYMBOL(__ioremap); 26EXPORT_SYMBOL(__ioremap);
28EXPORT_SYMBOL(iounmap); 27EXPORT_SYMBOL(iounmap);
29 28
30EXPORT_SYMBOL(dump_thread);
31EXPORT_SYMBOL(strnlen); 29EXPORT_SYMBOL(strnlen);
32EXPORT_SYMBOL(strrchr); 30EXPORT_SYMBOL(strrchr);
33EXPORT_SYMBOL(strstr); 31EXPORT_SYMBOL(strstr);
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 54a452136f00..0fff8a61ef2a 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -204,7 +204,7 @@ int copy_thread(int nr, unsigned long clone_flags,
204 204
205 regs0 = __kernel_frame0_ptr; 205 regs0 = __kernel_frame0_ptr;
206 childregs0 = (struct pt_regs *) 206 childregs0 = (struct pt_regs *)
207 ((unsigned long) p->thread_info + THREAD_SIZE - USER_CONTEXT_SIZE); 207 (task_stack_page(p) + THREAD_SIZE - USER_CONTEXT_SIZE);
208 childregs = childregs0; 208 childregs = childregs0;
209 209
210 /* set up the userspace frame (the only place that the USP is stored) */ 210 /* set up the userspace frame (the only place that the USP is stored) */
@@ -220,7 +220,7 @@ int copy_thread(int nr, unsigned long clone_flags,
220 *childregs = *regs; 220 *childregs = *regs;
221 childregs->sp = (unsigned long) childregs0; 221 childregs->sp = (unsigned long) childregs0;
222 childregs->next_frame = childregs0; 222 childregs->next_frame = childregs0;
223 childregs->gr15 = (unsigned long) p->thread_info; 223 childregs->gr15 = (unsigned long) task_thread_info(p);
224 childregs->gr29 = (unsigned long) p; 224 childregs->gr29 = (unsigned long) p;
225 } 225 }
226 226
@@ -244,28 +244,6 @@ int copy_thread(int nr, unsigned long clone_flags,
244} /* end copy_thread() */ 244} /* end copy_thread() */
245 245
246/* 246/*
247 * fill in the user structure for a core dump..
248 */
249void dump_thread(struct pt_regs *regs, struct user *dump)
250{
251#if 0
252 /* changed the size calculations - should hopefully work better. lbt */
253 dump->magic = CMAGIC;
254 dump->start_code = 0;
255 dump->start_stack = user_stack(regs) & ~(PAGE_SIZE - 1);
256 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
257 dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
258 dump->u_dsize -= dump->u_tsize;
259 dump->u_ssize = 0;
260
261 if (dump->start_stack < TASK_SIZE)
262 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
263
264 dump->regs = *(struct user_context *) regs;
265#endif
266}
267
268/*
269 * sys_execve() executes a new program. 247 * sys_execve() executes a new program.
270 */ 248 */
271asmlinkage int sys_execve(char *name, char **argv, char **envp) 249asmlinkage int sys_execve(char *name, char **argv, char **envp)
diff --git a/arch/h8300/kernel/gpio.c b/arch/h8300/kernel/gpio.c
index 795682b873e2..d195568ca8a2 100644
--- a/arch/h8300/kernel/gpio.c
+++ b/arch/h8300/kernel/gpio.c
@@ -122,7 +122,7 @@ int h8300_get_gpio_dir(int port_bit)
122static char *port_status(int portno) 122static char *port_status(int portno)
123{ 123{
124 static char result[10]; 124 static char result[10];
125 const static char io[2]={'I','O'}; 125 static const char io[2]={'I','O'};
126 char *rp; 126 char *rp;
127 int c; 127 int c;
128 unsigned char used,ddr; 128 unsigned char used,ddr;
@@ -143,7 +143,7 @@ static int gpio_proc_read(char *buf, char **start, off_t offset,
143 int len, int *unused_i, void *unused_v) 143 int len, int *unused_i, void *unused_v)
144{ 144{
145 int c,outlen; 145 int c,outlen;
146 const static char port_name[]="123456789ABCDEFGH"; 146 static const char port_name[]="123456789ABCDEFGH";
147 outlen = 0; 147 outlen = 0;
148 for (c = 0; c < MAX_PORT; c++) { 148 for (c = 0; c < MAX_PORT; c++) {
149 if (ddrs[c] == NULL) 149 if (ddrs[c] == NULL)
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c
index 5a630233112f..5cc76efaf7aa 100644
--- a/arch/h8300/kernel/h8300_ksyms.c
+++ b/arch/h8300/kernel/h8300_ksyms.c
@@ -22,11 +22,8 @@
22//asmlinkage long long __lshrdi3 (long long, int); 22//asmlinkage long long __lshrdi3 (long long, int);
23extern char h8300_debug_device[]; 23extern char h8300_debug_device[];
24 24
25extern void dump_thread(struct pt_regs *, struct user *);
26
27/* platform dependent support */ 25/* platform dependent support */
28 26
29EXPORT_SYMBOL(dump_thread);
30EXPORT_SYMBOL(strnlen); 27EXPORT_SYMBOL(strnlen);
31EXPORT_SYMBOL(strrchr); 28EXPORT_SYMBOL(strrchr);
32EXPORT_SYMBOL(strstr); 29EXPORT_SYMBOL(strstr);
@@ -103,10 +100,6 @@ EXPORT_SYMBOL(__udivsi3);
103EXPORT_SYMBOL(__umoddi3); 100EXPORT_SYMBOL(__umoddi3);
104EXPORT_SYMBOL(__umodsi3); 101EXPORT_SYMBOL(__umodsi3);
105 102
106#ifdef MAGIC_ROM_PTR
107EXPORT_SYMBOL(is_in_rom);
108#endif
109
110EXPORT_SYMBOL(h8300_reserved_gpio); 103EXPORT_SYMBOL(h8300_reserved_gpio);
111EXPORT_SYMBOL(h8300_free_gpio); 104EXPORT_SYMBOL(h8300_free_gpio);
112EXPORT_SYMBOL(h8300_set_gpio_dir); 105EXPORT_SYMBOL(h8300_set_gpio_dir);
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index fe21adf3e75e..ed79ae20e88d 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -195,7 +195,7 @@ int copy_thread(int nr, unsigned long clone_flags,
195{ 195{
196 struct pt_regs * childregs; 196 struct pt_regs * childregs;
197 197
198 childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1; 198 childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
199 199
200 *childregs = *regs; 200 *childregs = *regs;
201 childregs->retpc = (unsigned long) ret_from_fork; 201 childregs->retpc = (unsigned long) ret_from_fork;
@@ -208,34 +208,6 @@ int copy_thread(int nr, unsigned long clone_flags,
208} 208}
209 209
210/* 210/*
211 * fill in the user structure for a core dump..
212 */
213void dump_thread(struct pt_regs * regs, struct user * dump)
214{
215/* changed the size calculations - should hopefully work better. lbt */
216 dump->magic = CMAGIC;
217 dump->start_code = 0;
218 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
219 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
220 dump->u_dsize = ((unsigned long) (current->mm->brk +
221 (PAGE_SIZE-1))) >> PAGE_SHIFT;
222 dump->u_dsize -= dump->u_tsize;
223 dump->u_ssize = 0;
224
225 dump->u_ar0 = (struct user_regs_struct *)(((int)(&dump->regs)) -((int)(dump)));
226 dump->regs.er0 = regs->er0;
227 dump->regs.er1 = regs->er1;
228 dump->regs.er2 = regs->er2;
229 dump->regs.er3 = regs->er3;
230 dump->regs.er4 = regs->er4;
231 dump->regs.er5 = regs->er5;
232 dump->regs.er6 = regs->er6;
233 dump->regs.orig_er0 = regs->orig_er0;
234 dump->regs.ccr = regs->ccr;
235 dump->regs.pc = regs->pc;
236}
237
238/*
239 * sys_execve() executes a new program. 211 * sys_execve() executes a new program.
240 */ 212 */
241asmlinkage int sys_execve(char *name, char **argv, char **envp,int dummy,...) 213asmlinkage int sys_execve(char *name, char **argv, char **envp,int dummy,...)
diff --git a/arch/h8300/mm/memory.c b/arch/h8300/mm/memory.c
index f4ddece3216f..81eace93f867 100644
--- a/arch/h8300/mm/memory.c
+++ b/arch/h8300/mm/memory.c
@@ -55,16 +55,3 @@ unsigned long kernel_map(unsigned long paddr, unsigned long size,
55 return paddr; 55 return paddr;
56} 56}
57 57
58#ifdef MAGIC_ROM_PTR
59
60int is_in_rom(unsigned long addr)
61{
62 /* Anything not in operational RAM is returned as in rom! */
63 if (addr < _ramstart || addr >= _ramend)
64 return 1;
65 else
66 return 0;
67}
68
69#endif
70
diff --git a/arch/h8300/platform/h8300h/ptrace_h8300h.c b/arch/h8300/platform/h8300h/ptrace_h8300h.c
index 6ac93c05a1ae..746b1ae672a1 100644
--- a/arch/h8300/platform/h8300h/ptrace_h8300h.c
+++ b/arch/h8300/platform/h8300h/ptrace_h8300h.c
@@ -98,7 +98,7 @@ struct optable {
98 .type = jmp, \ 98 .type = jmp, \
99 } 99 }
100 100
101const static struct optable optable_0[] = { 101static const struct optable optable_0[] = {
102 OPTABLE(0x00,0xff, 1,none), /* 0x00 */ 102 OPTABLE(0x00,0xff, 1,none), /* 0x00 */
103 OPTABLE(0x01,0xff,-1,none), /* 0x01 */ 103 OPTABLE(0x01,0xff,-1,none), /* 0x01 */
104 OPTABLE(0x02,0xfe, 1,none), /* 0x02-0x03 */ 104 OPTABLE(0x02,0xfe, 1,none), /* 0x02-0x03 */
@@ -131,31 +131,31 @@ const static struct optable optable_0[] = {
131 OPTABLE(0x80,0x80, 1,none), /* 0x80-0xff */ 131 OPTABLE(0x80,0x80, 1,none), /* 0x80-0xff */
132}; 132};
133 133
134const static struct optable optable_1[] = { 134static const struct optable optable_1[] = {
135 OPTABLE(0x00,0xff,-3,none), /* 0x0100 */ 135 OPTABLE(0x00,0xff,-3,none), /* 0x0100 */
136 OPTABLE(0x40,0xf0,-3,none), /* 0x0140-0x14f */ 136 OPTABLE(0x40,0xf0,-3,none), /* 0x0140-0x14f */
137 OPTABLE(0x80,0xf0, 1,none), /* 0x0180-0x018f */ 137 OPTABLE(0x80,0xf0, 1,none), /* 0x0180-0x018f */
138 OPTABLE(0xc0,0xc0, 2,none), /* 0x01c0-0x01ff */ 138 OPTABLE(0xc0,0xc0, 2,none), /* 0x01c0-0x01ff */
139}; 139};
140 140
141const static struct optable optable_2[] = { 141static const struct optable optable_2[] = {
142 OPTABLE(0x00,0x20, 2,none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */ 142 OPTABLE(0x00,0x20, 2,none), /* 0x6a0?/0x6a8?/0x6b0?/0x6b8? */
143 OPTABLE(0x20,0x20, 3,none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */ 143 OPTABLE(0x20,0x20, 3,none), /* 0x6a2?/0x6aa?/0x6b2?/0x6ba? */
144}; 144};
145 145
146const static struct optable optable_3[] = { 146static const struct optable optable_3[] = {
147 OPTABLE(0x69,0xfb, 2,none), /* 0x010069/0x01006d/014069/0x01406d */ 147 OPTABLE(0x69,0xfb, 2,none), /* 0x010069/0x01006d/014069/0x01406d */
148 OPTABLE(0x6b,0xff,-4,none), /* 0x01006b/0x01406b */ 148 OPTABLE(0x6b,0xff,-4,none), /* 0x01006b/0x01406b */
149 OPTABLE(0x6f,0xff, 3,none), /* 0x01006f/0x01406f */ 149 OPTABLE(0x6f,0xff, 3,none), /* 0x01006f/0x01406f */
150 OPTABLE(0x78,0xff, 5,none), /* 0x010078/0x014078 */ 150 OPTABLE(0x78,0xff, 5,none), /* 0x010078/0x014078 */
151}; 151};
152 152
153const static struct optable optable_4[] = { 153static const struct optable optable_4[] = {
154 OPTABLE(0x00,0x78, 3,none), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */ 154 OPTABLE(0x00,0x78, 3,none), /* 0x0100690?/0x01006d0?/0140690/0x01406d0?/0x0100698?/0x01006d8?/0140698?/0x01406d8? */
155 OPTABLE(0x20,0x78, 4,none), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */ 155 OPTABLE(0x20,0x78, 4,none), /* 0x0100692?/0x01006d2?/0140692/0x01406d2?/0x010069a?/0x01006da?/014069a?/0x01406da? */
156}; 156};
157 157
158const static struct optables_list { 158static const struct optables_list {
159 const struct optable *ptr; 159 const struct optable *ptr;
160 int size; 160 int size;
161} optables[] = { 161} optables[] = {
diff --git a/arch/h8300/platform/h8s/ints.c b/arch/h8300/platform/h8s/ints.c
index 5441cdd12a39..f6ed663bdde0 100644
--- a/arch/h8300/platform/h8s/ints.c
+++ b/arch/h8300/platform/h8s/ints.c
@@ -52,7 +52,7 @@ struct irq_pins {
52 unsigned char bit_no; 52 unsigned char bit_no;
53}; 53};
54/* ISTR = 0 */ 54/* ISTR = 0 */
55const static struct irq_pins irq_assign_table0[16]={ 55static const struct irq_pins irq_assign_table0[16]={
56 {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1}, 56 {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1},
57 {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3}, 57 {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3},
58 {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5}, 58 {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5},
@@ -63,7 +63,7 @@ const static struct irq_pins irq_assign_table0[16]={
63 {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, 63 {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2},
64}; 64};
65/* ISTR = 1 */ 65/* ISTR = 1 */
66const static struct irq_pins irq_assign_table1[16]={ 66static const struct irq_pins irq_assign_table1[16]={
67 {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1}, 67 {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1},
68 {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3}, 68 {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3},
69 {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5}, 69 {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5},
diff --git a/arch/h8300/platform/h8s/ints_h8s.c b/arch/h8300/platform/h8s/ints_h8s.c
index f53de493e3e8..8268dfd12f1f 100644
--- a/arch/h8300/platform/h8s/ints_h8s.c
+++ b/arch/h8300/platform/h8s/ints_h8s.c
@@ -42,7 +42,7 @@ struct irq_pins {
42 unsigned char bit_no; 42 unsigned char bit_no;
43} __attribute__((aligned(1),packed)); 43} __attribute__((aligned(1),packed));
44/* ISTR = 0 */ 44/* ISTR = 0 */
45const static struct irq_pins irq_assign_table0[16]={ 45static const struct irq_pins irq_assign_table0[16]={
46 {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1}, 46 {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1},
47 {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3}, 47 {H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3},
48 {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5}, 48 {H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5},
@@ -53,7 +53,7 @@ const static struct irq_pins irq_assign_table0[16]={
53 {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2}, 53 {H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2},
54}; 54};
55/* ISTR = 1 */ 55/* ISTR = 1 */
56const static struct irq_pins irq_assign_table1[16]={ 56static const struct irq_pins irq_assign_table1[16]={
57 {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1}, 57 {H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1},
58 {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3}, 58 {H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3},
59 {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5}, 59 {H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5},
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index d849c6870e3a..d5d0df7f04fc 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -41,8 +41,21 @@ config ARCH_MAY_HAVE_PC_FDC
41 bool 41 bool
42 default y 42 default y
43 43
44config DMI
45 bool
46 default y
47
44source "init/Kconfig" 48source "init/Kconfig"
45 49
50config DOUBLEFAULT
51 default y
52 bool "Enable doublefault exception handler" if EMBEDDED
53 help
54 This option allows trapping of rare doublefault exceptions that
55 would otherwise cause a system to silently reboot. Disabling this
56 option saves about 4k and might cause you much additional grey
57 hair.
58
46menu "Processor type and features" 59menu "Processor type and features"
47 60
48choice 61choice
@@ -645,17 +658,6 @@ config SECCOMP
645 658
646source kernel/Kconfig.hz 659source kernel/Kconfig.hz
647 660
648config PHYSICAL_START
649 hex "Physical address where the kernel is loaded" if EMBEDDED
650 default "0x100000"
651 help
652 This gives the physical address where the kernel is loaded.
653 Primarily used in the case of kexec on panic where the
654 fail safe kernel needs to run at a different address than
655 the panic-ed kernel.
656
657 Don't change this unless you know what you are doing.
658
659config KEXEC 661config KEXEC
660 bool "kexec system call (EXPERIMENTAL)" 662 bool "kexec system call (EXPERIMENTAL)"
661 depends on EXPERIMENTAL 663 depends on EXPERIMENTAL
@@ -675,11 +677,31 @@ config KEXEC
675 677
676config CRASH_DUMP 678config CRASH_DUMP
677 bool "kernel crash dumps (EXPERIMENTAL)" 679 bool "kernel crash dumps (EXPERIMENTAL)"
678 depends on EMBEDDED
679 depends on EXPERIMENTAL 680 depends on EXPERIMENTAL
680 depends on HIGHMEM 681 depends on HIGHMEM
681 help 682 help
682 Generate crash dump after being started by kexec. 683 Generate crash dump after being started by kexec.
684
685config PHYSICAL_START
686 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
687
688 default "0x1000000" if CRASH_DUMP
689 default "0x100000"
690 help
691 This gives the physical address where the kernel is loaded. Normally
692 for regular kernels this value is 0x100000 (1MB). But in the case
693 of kexec on panic the fail safe kernel needs to run at a different
694 address than the panic-ed kernel. This option is used to set the load
695 address for kernels used to capture crash dump on being kexec'ed
696 after panic. The default value for crash dump kernels is
697 0x1000000 (16MB). This can also be set based on the "X" value as
698 specified in the "crashkernel=YM@XM" command line boot parameter
699 passed to the panic-ed kernel. Typically this parameter is set as
700 crashkernel=64M@16M. Please take a look at
701 Documentation/kdump/kdump.txt for more details about crash dumps.
702
703 Don't change this unless you know what you are doing.
704
683endmenu 705endmenu
684 706
685 707
@@ -1051,3 +1073,7 @@ config X86_TRAMPOLINE
1051 bool 1073 bool
1052 depends on X86_SMP || (X86_VOYAGER && SMP) 1074 depends on X86_SMP || (X86_VOYAGER && SMP)
1053 default y 1075 default y
1076
1077config KTIME_SCALAR
1078 bool
1079 default y
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index b84119f9cc63..d3c0409d201c 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -37,7 +37,10 @@ CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
37# CPU-specific tuning. Anything which can be shared with UML should go here. 37# CPU-specific tuning. Anything which can be shared with UML should go here.
38include $(srctree)/arch/i386/Makefile.cpu 38include $(srctree)/arch/i386/Makefile.cpu
39 39
40cflags-$(CONFIG_REGPARM) += -mregparm=3 40# -mregparm=3 works ok on gcc-3.0 and later
41#
42cflags-$(CONFIG_REGPARM) += $(shell if [ $(call cc-version) -ge 0300 ] ; then \
43 echo "-mregparm=3"; fi ;)
41 44
42# Disable unit-at-a-time mode, it makes gcc use a lot more stack 45# Disable unit-at-a-time mode, it makes gcc use a lot more stack
43# due to the lack of sharing of stacklots. 46# due to the lack of sharing of stacklots.
@@ -100,7 +103,7 @@ AFLAGS += $(mflags-y)
100boot := arch/i386/boot 103boot := arch/i386/boot
101 104
102.PHONY: zImage bzImage compressed zlilo bzlilo \ 105.PHONY: zImage bzImage compressed zlilo bzlilo \
103 zdisk bzdisk fdimage fdimage144 fdimage288 install kernel_install 106 zdisk bzdisk fdimage fdimage144 fdimage288 install
104 107
105all: bzImage 108all: bzImage
106 109
@@ -122,8 +125,7 @@ zdisk bzdisk: vmlinux
122fdimage fdimage144 fdimage288: vmlinux 125fdimage fdimage144 fdimage288: vmlinux
123 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ 126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@
124 127
125install: vmlinux 128install:
126install kernel_install:
127 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install 129 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
128 130
129archclean: 131archclean:
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index 1e71382d413a..f136752563b1 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -100,5 +100,5 @@ zlilo: $(BOOTIMAGE)
100 cp System.map $(INSTALL_PATH)/ 100 cp System.map $(INSTALL_PATH)/
101 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi 101 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
102 102
103install: $(BOOTIMAGE) 103install:
104 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" 104 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
diff --git a/arch/i386/boot/install.sh b/arch/i386/boot/install.sh
index f17b40dfc0f4..5e44c736eea8 100644
--- a/arch/i386/boot/install.sh
+++ b/arch/i386/boot/install.sh
@@ -19,6 +19,20 @@
19# $4 - default install path (blank if root directory) 19# $4 - default install path (blank if root directory)
20# 20#
21 21
22verify () {
23 if [ ! -f "$1" ]; then
24 echo "" 1>&2
25 echo " *** Missing file: $1" 1>&2
26 echo ' *** You need to run "make" before "make install".' 1>&2
27 echo "" 1>&2
28 exit 1
29 fi
30}
31
32# Make sure the files actually exist
33verify "$2"
34verify "$3"
35
22# User may have a custom install script 36# User may have a custom install script
23 37
24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi 38if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
index 92f669470142..2ac40c8244c4 100644
--- a/arch/i386/boot/video.S
+++ b/arch/i386/boot/video.S
@@ -97,7 +97,6 @@
97#define PARAM_VESAPM_OFF 0x30 97#define PARAM_VESAPM_OFF 0x30
98#define PARAM_LFB_PAGES 0x32 98#define PARAM_LFB_PAGES 0x32
99#define PARAM_VESA_ATTRIB 0x34 99#define PARAM_VESA_ATTRIB 0x34
100#define PARAM_CAPABILITIES 0x36
101 100
102/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */ 101/* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
103#ifdef CONFIG_VIDEO_RETAIN 102#ifdef CONFIG_VIDEO_RETAIN
@@ -234,10 +233,6 @@ mopar_gr:
234 movw 18(%di), %ax 233 movw 18(%di), %ax
235 movl %eax, %fs:(PARAM_LFB_SIZE) 234 movl %eax, %fs:(PARAM_LFB_SIZE)
236 235
237# store mode capabilities
238 movl 10(%di), %eax
239 movl %eax, %fs:(PARAM_CAPABILITIES)
240
241# switching the DAC to 8-bit is for <= 8 bpp only 236# switching the DAC to 8-bit is for <= 8 bpp only
242 movw %fs:(PARAM_LFB_DEPTH), %ax 237 movw %fs:(PARAM_LFB_DEPTH), %ax
243 cmpw $8, %ax 238 cmpw $8, %ax
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index be1880bb75b4..60c3f76dfca4 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o
25obj-$(CONFIG_X86_IO_APIC) += io_apic.o 25obj-$(CONFIG_X86_IO_APIC) += io_apic.o
26obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups.o 26obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups.o
27obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o 27obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
28obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
28obj-$(CONFIG_X86_NUMAQ) += numaq.o 29obj-$(CONFIG_X86_NUMAQ) += numaq.o
29obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o 30obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o
30obj-$(CONFIG_KPROBES) += kprobes.o 31obj-$(CONFIG_KPROBES) += kprobes.o
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 447fa9e33ffb..2111529dea77 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -108,7 +108,7 @@ char *__acpi_map_table(unsigned long phys_addr, unsigned long size)
108 if (!phys_addr || !size) 108 if (!phys_addr || !size)
109 return NULL; 109 return NULL;
110 110
111 if (phys_addr < (end_pfn_map << PAGE_SHIFT)) 111 if (phys_addr+size <= (end_pfn_map << PAGE_SHIFT) + PAGE_SIZE)
112 return __va(phys_addr); 112 return __va(phys_addr);
113 113
114 return NULL; 114 return NULL;
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index d8f94e78de8a..acd3f1e34ca6 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -26,6 +26,7 @@
26#include <linux/kernel_stat.h> 26#include <linux/kernel_stat.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/cpu.h> 28#include <linux/cpu.h>
29#include <linux/module.h>
29 30
30#include <asm/atomic.h> 31#include <asm/atomic.h>
31#include <asm/smp.h> 32#include <asm/smp.h>
@@ -37,10 +38,17 @@
37#include <asm/i8253.h> 38#include <asm/i8253.h>
38 39
39#include <mach_apic.h> 40#include <mach_apic.h>
41#include <mach_ipi.h>
40 42
41#include "io_ports.h" 43#include "io_ports.h"
42 44
43/* 45/*
46 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
47 * IPIs in place of local APIC timers
48 */
49static cpumask_t timer_bcast_ipi;
50
51/*
44 * Knob to control our willingness to enable the local APIC. 52 * Knob to control our willingness to enable the local APIC.
45 */ 53 */
46int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */ 54int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */
@@ -92,10 +100,6 @@ void __init apic_intr_init(void)
92/* Using APIC to generate smp_local_timer_interrupt? */ 100/* Using APIC to generate smp_local_timer_interrupt? */
93int using_apic_timer = 0; 101int using_apic_timer = 0;
94 102
95static DEFINE_PER_CPU(int, prof_multiplier) = 1;
96static DEFINE_PER_CPU(int, prof_old_multiplier) = 1;
97static DEFINE_PER_CPU(int, prof_counter) = 1;
98
99static int enabled_via_apicbase; 103static int enabled_via_apicbase;
100 104
101void enable_NMI_through_LVT0 (void * dummy) 105void enable_NMI_through_LVT0 (void * dummy)
@@ -935,11 +939,16 @@ void (*wait_timer_tick)(void) __devinitdata = wait_8254_wraparound;
935static void __setup_APIC_LVTT(unsigned int clocks) 939static void __setup_APIC_LVTT(unsigned int clocks)
936{ 940{
937 unsigned int lvtt_value, tmp_value, ver; 941 unsigned int lvtt_value, tmp_value, ver;
942 int cpu = smp_processor_id();
938 943
939 ver = GET_APIC_VERSION(apic_read(APIC_LVR)); 944 ver = GET_APIC_VERSION(apic_read(APIC_LVR));
940 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR; 945 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
941 if (!APIC_INTEGRATED(ver)) 946 if (!APIC_INTEGRATED(ver))
942 lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV); 947 lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);
948
949 if (cpu_isset(cpu, timer_bcast_ipi))
950 lvtt_value |= APIC_LVT_MASKED;
951
943 apic_write_around(APIC_LVTT, lvtt_value); 952 apic_write_around(APIC_LVTT, lvtt_value);
944 953
945 /* 954 /*
@@ -1072,7 +1081,7 @@ void __devinit setup_secondary_APIC_clock(void)
1072 setup_APIC_timer(calibration_result); 1081 setup_APIC_timer(calibration_result);
1073} 1082}
1074 1083
1075void __devinit disable_APIC_timer(void) 1084void disable_APIC_timer(void)
1076{ 1085{
1077 if (using_apic_timer) { 1086 if (using_apic_timer) {
1078 unsigned long v; 1087 unsigned long v;
@@ -1084,7 +1093,10 @@ void __devinit disable_APIC_timer(void)
1084 1093
1085void enable_APIC_timer(void) 1094void enable_APIC_timer(void)
1086{ 1095{
1087 if (using_apic_timer) { 1096 int cpu = smp_processor_id();
1097
1098 if (using_apic_timer &&
1099 !cpu_isset(cpu, timer_bcast_ipi)) {
1088 unsigned long v; 1100 unsigned long v;
1089 1101
1090 v = apic_read(APIC_LVTT); 1102 v = apic_read(APIC_LVTT);
@@ -1092,33 +1104,31 @@ void enable_APIC_timer(void)
1092 } 1104 }
1093} 1105}
1094 1106
1095/* 1107void switch_APIC_timer_to_ipi(void *cpumask)
1096 * the frequency of the profiling timer can be changed
1097 * by writing a multiplier value into /proc/profile.
1098 */
1099int setup_profiling_timer(unsigned int multiplier)
1100{ 1108{
1101 int i; 1109 cpumask_t mask = *(cpumask_t *)cpumask;
1110 int cpu = smp_processor_id();
1102 1111
1103 /* 1112 if (cpu_isset(cpu, mask) &&
1104 * Sanity check. [at least 500 APIC cycles should be 1113 !cpu_isset(cpu, timer_bcast_ipi)) {
1105 * between APIC interrupts as a rule of thumb, to avoid 1114 disable_APIC_timer();
1106 * irqs flooding us] 1115 cpu_set(cpu, timer_bcast_ipi);
1107 */ 1116 }
1108 if ( (!multiplier) || (calibration_result/multiplier < 500)) 1117}
1109 return -EINVAL; 1118EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
1110
1111 /*
1112 * Set the new multiplier for each CPU. CPUs don't start using the
1113 * new values until the next timer interrupt in which they do process
1114 * accounting. At that time they also adjust their APIC timers
1115 * accordingly.
1116 */
1117 for (i = 0; i < NR_CPUS; ++i)
1118 per_cpu(prof_multiplier, i) = multiplier;
1119 1119
1120 return 0; 1120void switch_ipi_to_APIC_timer(void *cpumask)
1121{
1122 cpumask_t mask = *(cpumask_t *)cpumask;
1123 int cpu = smp_processor_id();
1124
1125 if (cpu_isset(cpu, mask) &&
1126 cpu_isset(cpu, timer_bcast_ipi)) {
1127 cpu_clear(cpu, timer_bcast_ipi);
1128 enable_APIC_timer();
1129 }
1121} 1130}
1131EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
1122 1132
1123#undef APIC_DIVISOR 1133#undef APIC_DIVISOR
1124 1134
@@ -1134,32 +1144,10 @@ int setup_profiling_timer(unsigned int multiplier)
1134 1144
1135inline void smp_local_timer_interrupt(struct pt_regs * regs) 1145inline void smp_local_timer_interrupt(struct pt_regs * regs)
1136{ 1146{
1137 int cpu = smp_processor_id();
1138
1139 profile_tick(CPU_PROFILING, regs); 1147 profile_tick(CPU_PROFILING, regs);
1140 if (--per_cpu(prof_counter, cpu) <= 0) {
1141 /*
1142 * The multiplier may have changed since the last time we got
1143 * to this point as a result of the user writing to
1144 * /proc/profile. In this case we need to adjust the APIC
1145 * timer accordingly.
1146 *
1147 * Interrupts are already masked off at this point.
1148 */
1149 per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
1150 if (per_cpu(prof_counter, cpu) !=
1151 per_cpu(prof_old_multiplier, cpu)) {
1152 __setup_APIC_LVTT(
1153 calibration_result/
1154 per_cpu(prof_counter, cpu));
1155 per_cpu(prof_old_multiplier, cpu) =
1156 per_cpu(prof_counter, cpu);
1157 }
1158
1159#ifdef CONFIG_SMP 1148#ifdef CONFIG_SMP
1160 update_process_times(user_mode_vm(regs)); 1149 update_process_times(user_mode_vm(regs));
1161#endif 1150#endif
1162 }
1163 1151
1164 /* 1152 /*
1165 * We take the 'long' return path, and there every subsystem 1153 * We take the 'long' return path, and there every subsystem
@@ -1206,6 +1194,43 @@ fastcall void smp_apic_timer_interrupt(struct pt_regs *regs)
1206 irq_exit(); 1194 irq_exit();
1207} 1195}
1208 1196
1197#ifndef CONFIG_SMP
1198static void up_apic_timer_interrupt_call(struct pt_regs *regs)
1199{
1200 int cpu = smp_processor_id();
1201
1202 /*
1203 * the NMI deadlock-detector uses this.
1204 */
1205 per_cpu(irq_stat, cpu).apic_timer_irqs++;
1206
1207 smp_local_timer_interrupt(regs);
1208}
1209#endif
1210
1211void smp_send_timer_broadcast_ipi(struct pt_regs *regs)
1212{
1213 cpumask_t mask;
1214
1215 cpus_and(mask, cpu_online_map, timer_bcast_ipi);
1216 if (!cpus_empty(mask)) {
1217#ifdef CONFIG_SMP
1218 send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
1219#else
1220 /*
1221 * We can directly call the apic timer interrupt handler
1222 * in UP case. Minus all irq related functions
1223 */
1224 up_apic_timer_interrupt_call(regs);
1225#endif
1226 }
1227}
1228
1229int setup_profiling_timer(unsigned int multiplier)
1230{
1231 return -EINVAL;
1232}
1233
1209/* 1234/*
1210 * This interrupt should _never_ happen with our APIC/SMP architecture 1235 * This interrupt should _never_ happen with our APIC/SMP architecture
1211 */ 1236 */
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 9d8827156e54..05312a8abb8b 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -219,6 +219,7 @@
219#include <linux/sched.h> 219#include <linux/sched.h>
220#include <linux/pm.h> 220#include <linux/pm.h>
221#include <linux/pm_legacy.h> 221#include <linux/pm_legacy.h>
222#include <linux/capability.h>
222#include <linux/device.h> 223#include <linux/device.h>
223#include <linux/kernel.h> 224#include <linux/kernel.h>
224#include <linux/smp.h> 225#include <linux/smp.h>
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index e7697e077f6b..333578a4e91a 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -216,6 +216,12 @@ static void __init init_amd(struct cpuinfo_x86 *c)
216 c->x86_max_cores = 1; 216 c->x86_max_cores = 1;
217 } 217 }
218 218
219 if (cpuid_eax(0x80000000) >= 0x80000007) {
220 c->x86_power = cpuid_edx(0x80000007);
221 if (c->x86_power & (1<<8))
222 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
223 }
224
219#ifdef CONFIG_X86_HT 225#ifdef CONFIG_X86_HT
220 /* 226 /*
221 * On a AMD dual core setup the lower bits of the APIC id 227 * On a AMD dual core setup the lower bits of the APIC id
@@ -233,6 +239,7 @@ static void __init init_amd(struct cpuinfo_x86 *c)
233 cpu, c->x86_max_cores, cpu_core_id[cpu]); 239 cpu, c->x86_max_cores, cpu_core_id[cpu]);
234 } 240 }
235#endif 241#endif
242
236} 243}
237 244
238static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) 245static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 170400879f44..15aee26ec2b6 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -204,7 +204,10 @@ static int __devinit have_cpuid_p(void)
204 204
205/* Do minimum CPU detection early. 205/* Do minimum CPU detection early.
206 Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment. 206 Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
207 The others are not touched to avoid unwanted side effects. */ 207 The others are not touched to avoid unwanted side effects.
208
209 WARNING: this function is only called on the BP. Don't add code here
210 that is supposed to run on all CPUs. */
208static void __init early_cpu_detect(void) 211static void __init early_cpu_detect(void)
209{ 212{
210 struct cpuinfo_x86 *c = &boot_cpu_data; 213 struct cpuinfo_x86 *c = &boot_cpu_data;
@@ -236,12 +239,6 @@ static void __init early_cpu_detect(void)
236 if (cap0 & (1<<19)) 239 if (cap0 & (1<<19))
237 c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8; 240 c->x86_cache_alignment = ((misc >> 8) & 0xff) * 8;
238 } 241 }
239
240 early_intel_workaround(c);
241
242#ifdef CONFIG_X86_HT
243 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
244#endif
245} 242}
246 243
247void __devinit generic_identify(struct cpuinfo_x86 * c) 244void __devinit generic_identify(struct cpuinfo_x86 * c)
@@ -289,6 +286,12 @@ void __devinit generic_identify(struct cpuinfo_x86 * c)
289 get_model_name(c); /* Default name */ 286 get_model_name(c); /* Default name */
290 } 287 }
291 } 288 }
289
290 early_intel_workaround(c);
291
292#ifdef CONFIG_X86_HT
293 phys_proc_id[smp_processor_id()] = (cpuid_ebx(1) >> 24) & 0xff;
294#endif
292} 295}
293 296
294static void __devinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 297static void __devinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 871366b83b3f..7975e79d5fa4 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -40,8 +40,6 @@
40#include <linux/acpi.h> 40#include <linux/acpi.h>
41#include <acpi/processor.h> 41#include <acpi/processor.h>
42 42
43#include "speedstep-est-common.h"
44
45#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg) 43#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
46 44
47MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski"); 45MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
@@ -367,6 +365,7 @@ acpi_cpufreq_cpu_init (
367 unsigned int cpu = policy->cpu; 365 unsigned int cpu = policy->cpu;
368 struct cpufreq_acpi_io *data; 366 struct cpufreq_acpi_io *data;
369 unsigned int result = 0; 367 unsigned int result = 0;
368 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
370 369
371 union acpi_object arg0 = {ACPI_TYPE_BUFFER}; 370 union acpi_object arg0 = {ACPI_TYPE_BUFFER};
372 u32 arg0_buf[3]; 371 u32 arg0_buf[3];
@@ -390,7 +389,7 @@ acpi_cpufreq_cpu_init (
390 if (result) 389 if (result)
391 goto err_free; 390 goto err_free;
392 391
393 if (is_const_loops_cpu(cpu)) { 392 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
394 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS; 393 acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
395 } 394 }
396 395
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index edb9873e27e3..9a826cde4fd1 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -35,8 +35,6 @@
35#include <asm/processor.h> 35#include <asm/processor.h>
36#include <asm/cpufeature.h> 36#include <asm/cpufeature.h>
37 37
38#include "speedstep-est-common.h"
39
40#define PFX "speedstep-centrino: " 38#define PFX "speedstep-centrino: "
41#define MAINTAINER "Jeremy Fitzhardinge <jeremy@goop.org>" 39#define MAINTAINER "Jeremy Fitzhardinge <jeremy@goop.org>"
42 40
@@ -493,12 +491,13 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
493 unsigned l, h; 491 unsigned l, h;
494 int ret; 492 int ret;
495 int i; 493 int i;
494 struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
496 495
497 /* Only Intel makes Enhanced Speedstep-capable CPUs */ 496 /* Only Intel makes Enhanced Speedstep-capable CPUs */
498 if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST)) 497 if (cpu->x86_vendor != X86_VENDOR_INTEL || !cpu_has(cpu, X86_FEATURE_EST))
499 return -ENODEV; 498 return -ENODEV;
500 499
501 if (is_const_loops_cpu(policy->cpu)) { 500 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
502 centrino_driver.flags |= CPUFREQ_CONST_LOOPS; 501 centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
503 } 502 }
504 503
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h b/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h
deleted file mode 100644
index 5ce995c9d866..000000000000
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-est-common.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Routines common for drivers handling Enhanced Speedstep Technology
3 * Copyright (C) 2004 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
4 *
5 * Licensed under the terms of the GNU GPL License version 2 -- see
6 * COPYING for details.
7 */
8
9static inline int is_const_loops_cpu(unsigned int cpu)
10{
11 struct cpuinfo_x86 *c = cpu_data + cpu;
12
13 if (c->x86_vendor != X86_VENDOR_INTEL || !cpu_has(c, X86_FEATURE_EST))
14 return 0;
15
16 /*
17 * on P-4s, the TSC runs with constant frequency independent of cpu freq
18 * when we use EST
19 */
20 if (c->x86 == 0xf)
21 return 1;
22
23 return 0;
24}
25
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 5e2da704f0fa..8c0120186b9f 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -183,10 +183,13 @@ static void __devinit init_intel(struct cpuinfo_x86 *c)
183 } 183 }
184#endif 184#endif
185 185
186 if (c->x86 == 15) 186 if (c->x86 == 15)
187 set_bit(X86_FEATURE_P4, c->x86_capability); 187 set_bit(X86_FEATURE_P4, c->x86_capability);
188 if (c->x86 == 6) 188 if (c->x86 == 6)
189 set_bit(X86_FEATURE_P3, c->x86_capability); 189 set_bit(X86_FEATURE_P3, c->x86_capability);
190 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
191 (c->x86 == 0x6 && c->x86_model >= 0x0e))
192 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
190} 193}
191 194
192 195
diff --git a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
index cf39e205d33c..5ac051bb9d55 100644
--- a/arch/i386/kernel/cpu/mtrr/if.c
+++ b/arch/i386/kernel/cpu/mtrr/if.c
@@ -1,5 +1,6 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/proc_fs.h> 2#include <linux/proc_fs.h>
3#include <linux/capability.h>
3#include <linux/ctype.h> 4#include <linux/ctype.h>
4#include <linux/module.h> 5#include <linux/module.h>
5#include <linux/seq_file.h> 6#include <linux/seq_file.h>
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 6d91b274589c..89a85af33d28 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -29,7 +29,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
29 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 29 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
30 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL, 30 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
31 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL, 31 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
32 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow", 32 NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
33 33
34 /* Transmeta-defined */ 34 /* Transmeta-defined */
35 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL, 35 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
@@ -40,7 +40,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
40 /* Other (Linux-defined) */ 40 /* Other (Linux-defined) */
41 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr", 41 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
42 NULL, NULL, NULL, NULL, 42 NULL, NULL, NULL, NULL,
43 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 43 "constant_tsc", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 44 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
46 46
@@ -57,11 +57,21 @@ static int show_cpuinfo(struct seq_file *m, void *v)
57 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 57 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
58 58
59 /* AMD-defined (#2) */ 59 /* AMD-defined (#2) */
60 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL, 60 "lahf_lm", "cmp_legacy", "svm", NULL, "cr8legacy", NULL, NULL, NULL,
61 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 61 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
62 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 62 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
63 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 63 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
64 }; 64 };
65 static char *x86_power_flags[] = {
66 "ts", /* temperature sensor */
67 "fid", /* frequency id control */
68 "vid", /* voltage id control */
69 "ttp", /* thermal trip */
70 "tm",
71 "stc",
72 NULL,
73 /* nothing */ /* constant_tsc - moved to flags */
74 };
65 struct cpuinfo_x86 *c = v; 75 struct cpuinfo_x86 *c = v;
66 int i, n = c - cpu_data; 76 int i, n = c - cpu_data;
67 int fpu_exception; 77 int fpu_exception;
@@ -131,6 +141,17 @@ static int show_cpuinfo(struct seq_file *m, void *v)
131 x86_cap_flags[i] != NULL ) 141 x86_cap_flags[i] != NULL )
132 seq_printf(m, " %s", x86_cap_flags[i]); 142 seq_printf(m, " %s", x86_cap_flags[i]);
133 143
144 for (i = 0; i < 32; i++)
145 if (c->x86_power & (1 << i)) {
146 if (i < ARRAY_SIZE(x86_power_flags) &&
147 x86_power_flags[i])
148 seq_printf(m, "%s%s",
149 x86_power_flags[i][0]?" ":"",
150 x86_power_flags[i]);
151 else
152 seq_printf(m, " [%d]", i);
153 }
154
134 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n", 155 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
135 c->loops_per_jiffy/(500000/HZ), 156 c->loops_per_jiffy/(500000/HZ),
136 (c->loops_per_jiffy/(5000/HZ)) % 100); 157 (c->loops_per_jiffy/(5000/HZ)) % 100);
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 0248e084017c..d49dbe8dc96b 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -25,7 +25,6 @@
25#include <mach_ipi.h> 25#include <mach_ipi.h>
26 26
27 27
28note_buf_t crash_notes[NR_CPUS];
29/* This keeps a track of which one is crashing cpu. */ 28/* This keeps a track of which one is crashing cpu. */
30static int crashing_cpu; 29static int crashing_cpu;
31 30
@@ -72,7 +71,9 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
72 * squirrelled away. ELF notes happen to provide 71 * squirrelled away. ELF notes happen to provide
73 * all of that that no need to invent something new. 72 * all of that that no need to invent something new.
74 */ 73 */
75 buf = &crash_notes[cpu][0]; 74 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
75 if (!buf)
76 return;
76 memset(&prstatus, 0, sizeof(prstatus)); 77 memset(&prstatus, 0, sizeof(prstatus));
77 prstatus.pr_pid = current->pid; 78 prstatus.pr_pid = current->pid;
78 elf_core_copy_regs(&prstatus.pr_reg, regs); 79 elf_core_copy_regs(&prstatus.pr_reg, regs);
@@ -81,51 +82,12 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
81 final_note(buf); 82 final_note(buf);
82} 83}
83 84
84static void crash_get_current_regs(struct pt_regs *regs) 85static void crash_save_self(struct pt_regs *regs)
85{
86 __asm__ __volatile__("movl %%ebx,%0" : "=m"(regs->ebx));
87 __asm__ __volatile__("movl %%ecx,%0" : "=m"(regs->ecx));
88 __asm__ __volatile__("movl %%edx,%0" : "=m"(regs->edx));
89 __asm__ __volatile__("movl %%esi,%0" : "=m"(regs->esi));
90 __asm__ __volatile__("movl %%edi,%0" : "=m"(regs->edi));
91 __asm__ __volatile__("movl %%ebp,%0" : "=m"(regs->ebp));
92 __asm__ __volatile__("movl %%eax,%0" : "=m"(regs->eax));
93 __asm__ __volatile__("movl %%esp,%0" : "=m"(regs->esp));
94 __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(regs->xss));
95 __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(regs->xcs));
96 __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(regs->xds));
97 __asm__ __volatile__("movw %%es, %%ax;" :"=a"(regs->xes));
98 __asm__ __volatile__("pushfl; popl %0" :"=m"(regs->eflags));
99
100 regs->eip = (unsigned long)current_text_addr();
101}
102
103/* CPU does not save ss and esp on stack if execution is already
104 * running in kernel mode at the time of NMI occurrence. This code
105 * fixes it.
106 */
107static void crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs)
108{
109 memcpy(newregs, oldregs, sizeof(*newregs));
110 newregs->esp = (unsigned long)&(oldregs->esp);
111 __asm__ __volatile__("xorl %eax, %eax;");
112 __asm__ __volatile__ ("movw %%ss, %%ax;" :"=a"(newregs->xss));
113}
114
115/* We may have saved_regs from where the error came from
116 * or it is NULL if via a direct panic().
117 */
118static void crash_save_self(struct pt_regs *saved_regs)
119{ 86{
120 struct pt_regs regs;
121 int cpu; 87 int cpu;
122 88
123 cpu = smp_processor_id(); 89 cpu = smp_processor_id();
124 if (saved_regs) 90 crash_save_this_cpu(regs, cpu);
125 crash_setup_regs(&regs, saved_regs);
126 else
127 crash_get_current_regs(&regs);
128 crash_save_this_cpu(&regs, cpu);
129} 91}
130 92
131#ifdef CONFIG_SMP 93#ifdef CONFIG_SMP
@@ -144,7 +106,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
144 local_irq_disable(); 106 local_irq_disable();
145 107
146 if (!user_mode(regs)) { 108 if (!user_mode(regs)) {
147 crash_setup_regs(&fixed_regs, regs); 109 crash_fixup_ss_esp(&fixed_regs, regs);
148 regs = &fixed_regs; 110 regs = &fixed_regs;
149 } 111 }
150 crash_save_this_cpu(regs, cpu); 112 crash_save_this_cpu(regs, cpu);
diff --git a/arch/i386/kernel/crash_dump.c b/arch/i386/kernel/crash_dump.c
new file mode 100644
index 000000000000..3f532df488bc
--- /dev/null
+++ b/arch/i386/kernel/crash_dump.c
@@ -0,0 +1,74 @@
1/*
2 * kernel/crash_dump.c - Memory preserving reboot related code.
3 *
4 * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
5 * Copyright (C) IBM Corporation, 2004. All rights reserved
6 */
7
8#include <linux/errno.h>
9#include <linux/highmem.h>
10#include <linux/crash_dump.h>
11
12#include <asm/uaccess.h>
13
14static void *kdump_buf_page;
15
16/**
17 * copy_oldmem_page - copy one page from "oldmem"
18 * @pfn: page frame number to be copied
19 * @buf: target memory address for the copy; this can be in kernel address
20 * space or user address space (see @userbuf)
21 * @csize: number of bytes to copy
22 * @offset: offset in bytes into the page (based on pfn) to begin the copy
23 * @userbuf: if set, @buf is in user address space, use copy_to_user(),
24 * otherwise @buf is in kernel address space, use memcpy().
25 *
26 * Copy a page from "oldmem". For this page, there is no pte mapped
27 * in the current kernel. We stitch up a pte, similar to kmap_atomic.
28 *
29 * Calling copy_to_user() in atomic context is not desirable. Hence first
30 * copying the data to a pre-allocated kernel page and then copying to user
31 * space in non-atomic context.
32 */
33ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
34 size_t csize, unsigned long offset, int userbuf)
35{
36 void *vaddr;
37
38 if (!csize)
39 return 0;
40
41 vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
42
43 if (!userbuf) {
44 memcpy(buf, (vaddr + offset), csize);
45 kunmap_atomic(vaddr, KM_PTE0);
46 } else {
47 if (!kdump_buf_page) {
48 printk(KERN_WARNING "Kdump: Kdump buffer page not"
49 " allocated\n");
50 return -EFAULT;
51 }
52 copy_page(kdump_buf_page, vaddr);
53 kunmap_atomic(vaddr, KM_PTE0);
54 if (copy_to_user(buf, (kdump_buf_page + offset), csize))
55 return -EFAULT;
56 }
57
58 return csize;
59}
60
61static int __init kdump_buf_page_init(void)
62{
63 int ret = 0;
64
65 kdump_buf_page = kmalloc(PAGE_SIZE, GFP_KERNEL);
66 if (!kdump_buf_page) {
67 printk(KERN_WARNING "Kdump: Failed to allocate kdump buffer"
68 " page\n");
69 ret = -ENOMEM;
70 }
71
72 return ret;
73}
74arch_initcall(kdump_buf_page_init);
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 58516e2ac172..6a93d75db431 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -4,7 +4,7 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/dmi.h> 5#include <linux/dmi.h>
6#include <linux/bootmem.h> 6#include <linux/bootmem.h>
7 7#include <linux/slab.h>
8 8
9static char * __init dmi_string(struct dmi_header *dm, u8 s) 9static char * __init dmi_string(struct dmi_header *dm, u8 s)
10{ 10{
@@ -19,7 +19,7 @@ static char * __init dmi_string(struct dmi_header *dm, u8 s)
19 } 19 }
20 20
21 if (*bp != 0) { 21 if (*bp != 0) {
22 str = alloc_bootmem(strlen(bp) + 1); 22 str = dmi_alloc(strlen(bp) + 1);
23 if (str != NULL) 23 if (str != NULL)
24 strcpy(str, bp); 24 strcpy(str, bp);
25 else 25 else
@@ -40,7 +40,7 @@ static int __init dmi_table(u32 base, int len, int num,
40 u8 *buf, *data; 40 u8 *buf, *data;
41 int i = 0; 41 int i = 0;
42 42
43 buf = bt_ioremap(base, len); 43 buf = dmi_ioremap(base, len);
44 if (buf == NULL) 44 if (buf == NULL)
45 return -1; 45 return -1;
46 46
@@ -65,7 +65,7 @@ static int __init dmi_table(u32 base, int len, int num,
65 data += 2; 65 data += 2;
66 i++; 66 i++;
67 } 67 }
68 bt_iounmap(buf, len); 68 dmi_iounmap(buf, len);
69 return 0; 69 return 0;
70} 70}
71 71
@@ -112,7 +112,7 @@ static void __init dmi_save_devices(struct dmi_header *dm)
112 if ((*d & 0x80) == 0) 112 if ((*d & 0x80) == 0)
113 continue; 113 continue;
114 114
115 dev = alloc_bootmem(sizeof(*dev)); 115 dev = dmi_alloc(sizeof(*dev));
116 if (!dev) { 116 if (!dev) {
117 printk(KERN_ERR "dmi_save_devices: out of memory.\n"); 117 printk(KERN_ERR "dmi_save_devices: out of memory.\n");
118 break; 118 break;
@@ -131,7 +131,7 @@ static void __init dmi_save_ipmi_device(struct dmi_header *dm)
131 struct dmi_device *dev; 131 struct dmi_device *dev;
132 void * data; 132 void * data;
133 133
134 data = alloc_bootmem(dm->length); 134 data = dmi_alloc(dm->length);
135 if (data == NULL) { 135 if (data == NULL) {
136 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n"); 136 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
137 return; 137 return;
@@ -139,7 +139,7 @@ static void __init dmi_save_ipmi_device(struct dmi_header *dm)
139 139
140 memcpy(data, dm, dm->length); 140 memcpy(data, dm, dm->length);
141 141
142 dev = alloc_bootmem(sizeof(*dev)); 142 dev = dmi_alloc(sizeof(*dev));
143 if (!dev) { 143 if (!dev) {
144 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n"); 144 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
145 return; 145 return;
@@ -221,7 +221,7 @@ void __init dmi_scan_machine(void)
221 } 221 }
222 } 222 }
223 223
224out: printk(KERN_INFO "DMI not present.\n"); 224out: printk(KERN_INFO "DMI not present or invalid.\n");
225} 225}
226 226
227 227
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 7554f8fd874a..f2dd218d88cb 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -1649,7 +1649,7 @@ static void __init enable_IO_APIC(void)
1649 for(apic = 0; apic < nr_ioapics; apic++) { 1649 for(apic = 0; apic < nr_ioapics; apic++) {
1650 int pin; 1650 int pin;
1651 /* See if any of the pins is in ExtINT mode */ 1651 /* See if any of the pins is in ExtINT mode */
1652 for(pin = 0; pin < nr_ioapic_registers[i]; pin++) { 1652 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
1653 struct IO_APIC_route_entry entry; 1653 struct IO_APIC_route_entry entry;
1654 spin_lock_irqsave(&ioapic_lock, flags); 1654 spin_lock_irqsave(&ioapic_lock, flags);
1655 *(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin); 1655 *(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
diff --git a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c
index b59a34dbe262..79026f026b85 100644
--- a/arch/i386/kernel/ioport.c
+++ b/arch/i386/kernel/ioport.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/capability.h>
10#include <linux/errno.h> 11#include <linux/errno.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/ioport.h> 13#include <linux/ioport.h>
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 19edcd526ba4..6483eeb1a4e8 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -58,13 +58,9 @@ static inline int is_IF_modifier(kprobe_opcode_t opcode)
58 58
59int __kprobes arch_prepare_kprobe(struct kprobe *p) 59int __kprobes arch_prepare_kprobe(struct kprobe *p)
60{ 60{
61 return 0;
62}
63
64void __kprobes arch_copy_kprobe(struct kprobe *p)
65{
66 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 61 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
67 p->opcode = *p->addr; 62 p->opcode = *p->addr;
63 return 0;
68} 64}
69 65
70void __kprobes arch_arm_kprobe(struct kprobe *p) 66void __kprobes arch_arm_kprobe(struct kprobe *p)
@@ -81,10 +77,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
81 (unsigned long) p->addr + sizeof(kprobe_opcode_t)); 77 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
82} 78}
83 79
84void __kprobes arch_remove_kprobe(struct kprobe *p)
85{
86}
87
88static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) 80static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
89{ 81{
90 kcb->prev_kprobe.kp = kprobe_running(); 82 kcb->prev_kprobe.kp = kprobe_running();
@@ -196,6 +188,19 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
196 kcb->kprobe_status = KPROBE_REENTER; 188 kcb->kprobe_status = KPROBE_REENTER;
197 return 1; 189 return 1;
198 } else { 190 } else {
191 if (regs->eflags & VM_MASK) {
192 /* We are in virtual-8086 mode. Return 0 */
193 goto no_kprobe;
194 }
195 if (*addr != BREAKPOINT_INSTRUCTION) {
196 /* The breakpoint instruction was removed by
197 * another cpu right after we hit, no further
198 * handling of this interrupt is appropriate
199 */
200 regs->eip -= sizeof(kprobe_opcode_t);
201 ret = 1;
202 goto no_kprobe;
203 }
199 p = __get_cpu_var(current_kprobe); 204 p = __get_cpu_var(current_kprobe);
200 if (p->break_handler && p->break_handler(p, regs)) { 205 if (p->break_handler && p->break_handler(p, regs)) {
201 goto ss_probe; 206 goto ss_probe;
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 165f13158c60..d3fdf0057d82 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -70,6 +70,7 @@
70 */ 70 */
71 71
72//#define DEBUG /* pr_debug */ 72//#define DEBUG /* pr_debug */
73#include <linux/capability.h>
73#include <linux/kernel.h> 74#include <linux/kernel.h>
74#include <linux/init.h> 75#include <linux/init.h>
75#include <linux/sched.h> 76#include <linux/sched.h>
@@ -165,7 +166,7 @@ static void collect_cpu_info (void *unused)
165 166
166 wrmsr(MSR_IA32_UCODE_REV, 0, 0); 167 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
167 /* see notes above for revision 1.07. Apparent chip bug */ 168 /* see notes above for revision 1.07. Apparent chip bug */
168 serialize_cpu(); 169 sync_core();
169 /* get the current revision from MSR 0x8B */ 170 /* get the current revision from MSR 0x8B */
170 rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev); 171 rdmsr(MSR_IA32_UCODE_REV, val[0], uci->rev);
171 pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n", 172 pr_debug("microcode: collect_cpu_info : sig=0x%x, pf=0x%x, rev=0x%x\n",
@@ -379,7 +380,7 @@ static void do_update_one (void * unused)
379 wrmsr(MSR_IA32_UCODE_REV, 0, 0); 380 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
380 381
381 /* see notes above for revision 1.07. Apparent chip bug */ 382 /* see notes above for revision 1.07. Apparent chip bug */
382 serialize_cpu(); 383 sync_core();
383 384
384 /* get the current revision from MSR 0x8B */ 385 /* get the current revision from MSR 0x8B */
385 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); 386 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 035928f3f6c1..2185377fdde1 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -424,18 +424,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
424 struct task_struct *tsk; 424 struct task_struct *tsk;
425 int err; 425 int err;
426 426
427 childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1; 427 childregs = task_pt_regs(p);
428 /*
429 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
430 * This is necessary to guarantee that the entire "struct pt_regs"
431 * is accessable even if the CPU haven't stored the SS/ESP registers
432 * on the stack (interrupt gate does not save these registers
433 * when switching to the same priv ring).
434 * Therefore beware: accessing the xss/esp fields of the
435 * "struct pt_regs" is possible, but they may contain the
436 * completely wrong values.
437 */
438 childregs = (struct pt_regs *) ((unsigned long) childregs - 8);
439 *childregs = *regs; 428 *childregs = *regs;
440 childregs->eax = 0; 429 childregs->eax = 0;
441 childregs->esp = esp; 430 childregs->esp = esp;
@@ -540,12 +529,7 @@ EXPORT_SYMBOL(dump_thread);
540 */ 529 */
541int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) 530int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
542{ 531{
543 struct pt_regs ptregs; 532 struct pt_regs ptregs = *task_pt_regs(tsk);
544
545 ptregs = *(struct pt_regs *)
546 ((unsigned long)tsk->thread_info +
547 /* see comments in copy_thread() about -8 */
548 THREAD_SIZE - sizeof(ptregs) - 8);
549 ptregs.xcs &= 0xffff; 533 ptregs.xcs &= 0xffff;
550 ptregs.xds &= 0xffff; 534 ptregs.xds &= 0xffff;
551 ptregs.xes &= 0xffff; 535 ptregs.xes &= 0xffff;
@@ -601,8 +585,8 @@ static inline void disable_tsc(struct task_struct *prev_p,
601 * gcc should eliminate the ->thread_info dereference if 585 * gcc should eliminate the ->thread_info dereference if
602 * has_secure_computing returns 0 at compile time (SECCOMP=n). 586 * has_secure_computing returns 0 at compile time (SECCOMP=n).
603 */ 587 */
604 prev = prev_p->thread_info; 588 prev = task_thread_info(prev_p);
605 next = next_p->thread_info; 589 next = task_thread_info(next_p);
606 590
607 if (has_secure_computing(prev) || has_secure_computing(next)) { 591 if (has_secure_computing(prev) || has_secure_computing(next)) {
608 /* slow path here */ 592 /* slow path here */
@@ -787,7 +771,7 @@ unsigned long get_wchan(struct task_struct *p)
787 int count = 0; 771 int count = 0;
788 if (!p || p == current || p->state == TASK_RUNNING) 772 if (!p || p == current || p->state == TASK_RUNNING)
789 return 0; 773 return 0;
790 stack_page = (unsigned long)p->thread_info; 774 stack_page = (unsigned long)task_stack_page(p);
791 esp = p->thread.esp; 775 esp = p->thread.esp;
792 if (!stack_page || esp < stack_page || esp > top_esp+stack_page) 776 if (!stack_page || esp < stack_page || esp > top_esp+stack_page)
793 return 0; 777 return 0;
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 2fa5803a759d..d207242976d3 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -12,6 +12,7 @@
12#include <linux/efi.h> 12#include <linux/efi.h>
13#include <linux/dmi.h> 13#include <linux/dmi.h>
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/pm.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/apic.h> 17#include <asm/apic.h>
17#include <asm/desc.h> 18#include <asm/desc.h>
@@ -355,10 +356,10 @@ void machine_halt(void)
355 356
356void machine_power_off(void) 357void machine_power_off(void)
357{ 358{
358 machine_shutdown(); 359 if (pm_power_off) {
359 360 machine_shutdown();
360 if (pm_power_off)
361 pm_power_off(); 361 pm_power_off();
362 }
362} 363}
363 364
364 365
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 27c956db0461..51e513b4f72d 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -45,6 +45,7 @@
45#include <linux/nodemask.h> 45#include <linux/nodemask.h>
46#include <linux/kexec.h> 46#include <linux/kexec.h>
47#include <linux/crash_dump.h> 47#include <linux/crash_dump.h>
48#include <linux/dmi.h>
48 49
49#include <video/edid.h> 50#include <video/edid.h>
50 51
@@ -146,7 +147,6 @@ EXPORT_SYMBOL(ist_info);
146struct e820map e820; 147struct e820map e820;
147 148
148extern void early_cpu_init(void); 149extern void early_cpu_init(void);
149extern void dmi_scan_machine(void);
150extern void generic_apic_probe(char *); 150extern void generic_apic_probe(char *);
151extern int root_mountflags; 151extern int root_mountflags;
152 152
@@ -898,7 +898,7 @@ static void __init parse_cmdline_early (char ** cmdline_p)
898 } 898 }
899 } 899 }
900#endif 900#endif
901#ifdef CONFIG_CRASH_DUMP 901#ifdef CONFIG_PROC_VMCORE
902 /* elfcorehdr= specifies the location of elf core header 902 /* elfcorehdr= specifies the location of elf core header
903 * stored by the crashed kernel. 903 * stored by the crashed kernel.
904 */ 904 */
@@ -1584,7 +1584,7 @@ void __init setup_arch(char **cmdline_p)
1584 if (s) { 1584 if (s) {
1585 extern void setup_early_printk(char *); 1585 extern void setup_early_printk(char *);
1586 1586
1587 setup_early_printk(s); 1587 setup_early_printk(strchr(s, '=') + 1);
1588 printk("early console enabled\n"); 1588 printk("early console enabled\n");
1589 } 1589 }
1590 } 1590 }
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index b3c2e2c26743..255adb498268 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -875,8 +875,7 @@ static inline struct task_struct * alloc_idle_task(int cpu)
875 /* initialize thread_struct. we really want to avoid destroy 875 /* initialize thread_struct. we really want to avoid destroy
876 * idle tread 876 * idle tread
877 */ 877 */
878 idle->thread.esp = (unsigned long)(((struct pt_regs *) 878 idle->thread.esp = (unsigned long)task_pt_regs(idle);
879 (THREAD_SIZE + (unsigned long) idle->thread_info)) - 1);
880 init_idle(idle, cpu); 879 init_idle(idle, cpu);
881 return idle; 880 return idle;
882 } 881 }
@@ -1096,6 +1095,7 @@ static void smp_tune_scheduling (void)
1096 cachesize = 16; /* Pentiums, 2x8kB cache */ 1095 cachesize = 16; /* Pentiums, 2x8kB cache */
1097 bandwidth = 100; 1096 bandwidth = 100;
1098 } 1097 }
1098 max_cache_size = cachesize * 1024;
1099 } 1099 }
1100} 1100}
1101 1101
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 41c5b2dc6200..a14d594bfbeb 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -302,6 +302,12 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
302 do_timer_interrupt(irq, regs); 302 do_timer_interrupt(irq, regs);
303 303
304 write_sequnlock(&xtime_lock); 304 write_sequnlock(&xtime_lock);
305
306#ifdef CONFIG_X86_LOCAL_APIC
307 if (using_apic_timer)
308 smp_send_timer_broadcast_ipi(regs);
309#endif
310
305 return IRQ_HANDLED; 311 return IRQ_HANDLED;
306} 312}
307 313
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 53ad954e3ba4..b9f0030a2ebb 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -120,7 +120,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
120#ifdef CONFIG_FRAME_POINTER 120#ifdef CONFIG_FRAME_POINTER
121 while (valid_stack_ptr(tinfo, (void *)ebp)) { 121 while (valid_stack_ptr(tinfo, (void *)ebp)) {
122 addr = *(unsigned long *)(ebp + 4); 122 addr = *(unsigned long *)(ebp + 4);
123 printk(" [<%08lx>] ", addr); 123 printk(KERN_EMERG " [<%08lx>] ", addr);
124 print_symbol("%s", addr); 124 print_symbol("%s", addr);
125 printk("\n"); 125 printk("\n");
126 ebp = *(unsigned long *)ebp; 126 ebp = *(unsigned long *)ebp;
@@ -129,7 +129,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
129 while (valid_stack_ptr(tinfo, stack)) { 129 while (valid_stack_ptr(tinfo, stack)) {
130 addr = *stack++; 130 addr = *stack++;
131 if (__kernel_text_address(addr)) { 131 if (__kernel_text_address(addr)) {
132 printk(" [<%08lx>]", addr); 132 printk(KERN_EMERG " [<%08lx>]", addr);
133 print_symbol(" %s", addr); 133 print_symbol(" %s", addr);
134 printk("\n"); 134 printk("\n");
135 } 135 }
@@ -161,7 +161,7 @@ void show_trace(struct task_struct *task, unsigned long * stack)
161 stack = (unsigned long*)context->previous_esp; 161 stack = (unsigned long*)context->previous_esp;
162 if (!stack) 162 if (!stack)
163 break; 163 break;
164 printk(" =======================\n"); 164 printk(KERN_EMERG " =======================\n");
165 } 165 }
166} 166}
167 167
@@ -178,14 +178,15 @@ void show_stack(struct task_struct *task, unsigned long *esp)
178 } 178 }
179 179
180 stack = esp; 180 stack = esp;
181 printk(KERN_EMERG);
181 for(i = 0; i < kstack_depth_to_print; i++) { 182 for(i = 0; i < kstack_depth_to_print; i++) {
182 if (kstack_end(stack)) 183 if (kstack_end(stack))
183 break; 184 break;
184 if (i && ((i % 8) == 0)) 185 if (i && ((i % 8) == 0))
185 printk("\n "); 186 printk("\n" KERN_EMERG " ");
186 printk("%08lx ", *stack++); 187 printk("%08lx ", *stack++);
187 } 188 }
188 printk("\nCall Trace:\n"); 189 printk("\n" KERN_EMERG "Call Trace:\n");
189 show_trace(task, esp); 190 show_trace(task, esp);
190} 191}
191 192
@@ -216,18 +217,18 @@ void show_registers(struct pt_regs *regs)
216 ss = regs->xss & 0xffff; 217 ss = regs->xss & 0xffff;
217 } 218 }
218 print_modules(); 219 print_modules();
219 printk("CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\nEFLAGS: %08lx" 220 printk(KERN_EMERG "CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\n"
220 " (%s) \n", 221 "EFLAGS: %08lx (%s) \n",
221 smp_processor_id(), 0xffff & regs->xcs, regs->eip, 222 smp_processor_id(), 0xffff & regs->xcs, regs->eip,
222 print_tainted(), regs->eflags, system_utsname.release); 223 print_tainted(), regs->eflags, system_utsname.release);
223 print_symbol("EIP is at %s\n", regs->eip); 224 print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip);
224 printk("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n", 225 printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
225 regs->eax, regs->ebx, regs->ecx, regs->edx); 226 regs->eax, regs->ebx, regs->ecx, regs->edx);
226 printk("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n", 227 printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
227 regs->esi, regs->edi, regs->ebp, esp); 228 regs->esi, regs->edi, regs->ebp, esp);
228 printk("ds: %04x es: %04x ss: %04x\n", 229 printk(KERN_EMERG "ds: %04x es: %04x ss: %04x\n",
229 regs->xds & 0xffff, regs->xes & 0xffff, ss); 230 regs->xds & 0xffff, regs->xes & 0xffff, ss);
230 printk("Process %s (pid: %d, threadinfo=%p task=%p)", 231 printk(KERN_EMERG "Process %s (pid: %d, threadinfo=%p task=%p)",
231 current->comm, current->pid, current_thread_info(), current); 232 current->comm, current->pid, current_thread_info(), current);
232 /* 233 /*
233 * When in-kernel, we also print out the stack and code at the 234 * When in-kernel, we also print out the stack and code at the
@@ -236,10 +237,10 @@ void show_registers(struct pt_regs *regs)
236 if (in_kernel) { 237 if (in_kernel) {
237 u8 __user *eip; 238 u8 __user *eip;
238 239
239 printk("\nStack: "); 240 printk("\n" KERN_EMERG "Stack: ");
240 show_stack(NULL, (unsigned long*)esp); 241 show_stack(NULL, (unsigned long*)esp);
241 242
242 printk("Code: "); 243 printk(KERN_EMERG "Code: ");
243 244
244 eip = (u8 __user *)regs->eip - 43; 245 eip = (u8 __user *)regs->eip - 43;
245 for (i = 0; i < 64; i++, eip++) { 246 for (i = 0; i < 64; i++, eip++) {
@@ -280,15 +281,15 @@ static void handle_BUG(struct pt_regs *regs)
280 (unsigned long)file < PAGE_OFFSET || __get_user(c, file)) 281 (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
281 file = "<bad filename>"; 282 file = "<bad filename>";
282 283
283 printk("------------[ cut here ]------------\n"); 284 printk(KERN_EMERG "------------[ cut here ]------------\n");
284 printk(KERN_ALERT "kernel BUG at %s:%d!\n", file, line); 285 printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line);
285 286
286no_bug: 287no_bug:
287 return; 288 return;
288 289
289 /* Here we know it was a BUG but file-n-line is unavailable */ 290 /* Here we know it was a BUG but file-n-line is unavailable */
290bug: 291bug:
291 printk("Kernel BUG\n"); 292 printk(KERN_EMERG "Kernel BUG\n");
292} 293}
293 294
294/* This is gone through when something in the kernel 295/* This is gone through when something in the kernel
@@ -321,16 +322,20 @@ void die(const char * str, struct pt_regs * regs, long err)
321 if (++die.lock_owner_depth < 3) { 322 if (++die.lock_owner_depth < 3) {
322 int nl = 0; 323 int nl = 0;
323 handle_BUG(regs); 324 handle_BUG(regs);
324 printk(KERN_ALERT "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter); 325 printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
325#ifdef CONFIG_PREEMPT 326#ifdef CONFIG_PREEMPT
326 printk("PREEMPT "); 327 printk(KERN_EMERG "PREEMPT ");
327 nl = 1; 328 nl = 1;
328#endif 329#endif
329#ifdef CONFIG_SMP 330#ifdef CONFIG_SMP
331 if (!nl)
332 printk(KERN_EMERG);
330 printk("SMP "); 333 printk("SMP ");
331 nl = 1; 334 nl = 1;
332#endif 335#endif
333#ifdef CONFIG_DEBUG_PAGEALLOC 336#ifdef CONFIG_DEBUG_PAGEALLOC
337 if (!nl)
338 printk(KERN_EMERG);
334 printk("DEBUG_PAGEALLOC"); 339 printk("DEBUG_PAGEALLOC");
335 nl = 1; 340 nl = 1;
336#endif 341#endif
@@ -339,7 +344,7 @@ void die(const char * str, struct pt_regs * regs, long err)
339 notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); 344 notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
340 show_registers(regs); 345 show_registers(regs);
341 } else 346 } else
342 printk(KERN_ERR "Recursive die() failure, output suppressed\n"); 347 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
343 348
344 bust_spinlocks(0); 349 bust_spinlocks(0);
345 die.lock_owner = -1; 350 die.lock_owner = -1;
@@ -527,8 +532,10 @@ gp_in_kernel:
527 532
528static void mem_parity_error(unsigned char reason, struct pt_regs * regs) 533static void mem_parity_error(unsigned char reason, struct pt_regs * regs)
529{ 534{
530 printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); 535 printk(KERN_EMERG "Uhhuh. NMI received. Dazed and confused, but trying "
531 printk("You probably have a hardware problem with your RAM chips\n"); 536 "to continue\n");
537 printk(KERN_EMERG "You probably have a hardware problem with your RAM "
538 "chips\n");
532 539
533 /* Clear and disable the memory parity error line. */ 540 /* Clear and disable the memory parity error line. */
534 clear_mem_error(reason); 541 clear_mem_error(reason);
@@ -538,7 +545,7 @@ static void io_check_error(unsigned char reason, struct pt_regs * regs)
538{ 545{
539 unsigned long i; 546 unsigned long i;
540 547
541 printk("NMI: IOCK error (debug interrupt?)\n"); 548 printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
542 show_registers(regs); 549 show_registers(regs);
543 550
544 /* Re-enable the IOCK line, wait for a few seconds */ 551 /* Re-enable the IOCK line, wait for a few seconds */
@@ -580,11 +587,11 @@ void die_nmi (struct pt_regs *regs, const char *msg)
580 * to get a message out. 587 * to get a message out.
581 */ 588 */
582 bust_spinlocks(1); 589 bust_spinlocks(1);
583 printk(msg); 590 printk(KERN_EMERG "%s", msg);
584 printk(" on CPU%d, eip %08lx, registers:\n", 591 printk(" on CPU%d, eip %08lx, registers:\n",
585 smp_processor_id(), regs->eip); 592 smp_processor_id(), regs->eip);
586 show_registers(regs); 593 show_registers(regs);
587 printk("console shuts up ...\n"); 594 printk(KERN_EMERG "console shuts up ...\n");
588 console_silent(); 595 console_silent();
589 spin_unlock(&nmi_print_lock); 596 spin_unlock(&nmi_print_lock);
590 bust_spinlocks(0); 597 bust_spinlocks(0);
@@ -990,8 +997,8 @@ asmlinkage void math_state_restore(struct pt_regs regs)
990 997
991asmlinkage void math_emulate(long arg) 998asmlinkage void math_emulate(long arg)
992{ 999{
993 printk("math-emulation not enabled and no coprocessor found.\n"); 1000 printk(KERN_EMERG "math-emulation not enabled and no coprocessor found.\n");
994 printk("killing %s.\n",current->comm); 1001 printk(KERN_EMERG "killing %s.\n",current->comm);
995 force_sig(SIGFPE,current); 1002 force_sig(SIGFPE,current);
996 schedule(); 1003 schedule();
997} 1004}
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index fc1993564f98..0c90ae54ddfa 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -30,6 +30,7 @@
30 * 30 *
31 */ 31 */
32 32
33#include <linux/capability.h>
33#include <linux/config.h> 34#include <linux/config.h>
34#include <linux/errno.h> 35#include <linux/errno.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
@@ -310,7 +311,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
310 "movl %1,%%ebp\n\t" 311 "movl %1,%%ebp\n\t"
311 "jmp resume_userspace" 312 "jmp resume_userspace"
312 : /* no outputs */ 313 : /* no outputs */
313 :"r" (&info->regs), "r" (tsk->thread_info) : "ax"); 314 :"r" (&info->regs), "r" (task_thread_info(tsk)) : "ax");
314 /* we never return here */ 315 /* we never return here */
315} 316}
316 317
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index e8a53552b13d..d0cadb33b54c 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -224,7 +224,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
224 return; 224 return;
225 if (!enable) 225 if (!enable)
226 mutex_debug_check_no_locks_freed(page_address(page), 226 mutex_debug_check_no_locks_freed(page_address(page),
227 page_address(page+numpages)); 227 numpages * PAGE_SIZE);
228 228
229 /* the return value is ignored - the calls cannot fail, 229 /* the return value is ignored - the calls cannot fail,
230 * large pages are disabled at boot time. 230 * large pages are disabled at boot time.
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 57b047c27e46..f722e1a25948 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -25,7 +25,6 @@ cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \
25 -falign-functions=32 -frename-registers -fno-optimize-sibling-calls 25 -falign-functions=32 -frename-registers -fno-optimize-sibling-calls
26CFLAGS_KERNEL := -mconstant-gp 26CFLAGS_KERNEL := -mconstant-gp
27 27
28GCC_VERSION := $(call cc-version)
29GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") 28GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)")
30CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") 29CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)")
31 30
@@ -37,7 +36,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
37 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz) 36 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz)
38endif 37endif
39 38
40ifeq ($(GCC_VERSION),0304) 39ifeq ($(call cc-version),0304)
41 cflags-$(CONFIG_ITANIUM) += -mtune=merced 40 cflags-$(CONFIG_ITANIUM) += -mtune=merced
42 cflags-$(CONFIG_MCKINLEY) += -mtune=mckinley 41 cflags-$(CONFIG_MCKINLEY) += -mtune=mckinley
43endif 42endif
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 19ee635eeb70..a346e1833bf2 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -26,6 +26,7 @@
26#include <linux/fcntl.h> 26#include <linux/fcntl.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/capability.h>
29#include <linux/console.h> 30#include <linux/console.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/serial.h> 32#include <linux/serial.h>
diff --git a/arch/ia64/ia32/Makefile b/arch/ia64/ia32/Makefile
index 2ed90da81166..61cb60affd95 100644
--- a/arch/ia64/ia32/Makefile
+++ b/arch/ia64/ia32/Makefile
@@ -2,11 +2,9 @@
2# Makefile for the ia32 kernel emulation subsystem. 2# Makefile for the ia32 kernel emulation subsystem.
3# 3#
4 4
5obj-y := ia32_entry.o sys_ia32.o ia32_ioctl.o ia32_signal.o \ 5obj-y := ia32_entry.o sys_ia32.o ia32_signal.o \
6 ia32_support.o ia32_traps.o binfmt_elf32.o ia32_ldt.o 6 ia32_support.o ia32_traps.o binfmt_elf32.o ia32_ldt.o
7 7
8CFLAGS_ia32_ioctl.o += -Ifs/
9
10# Don't let GCC uses f16-f31 so that save_ia32_fpstate_live() and 8# Don't let GCC uses f16-f31 so that save_ia32_fpstate_live() and
11# restore_ia32_fpstate_live() can be sure the live register contain user-level state. 9# restore_ia32_fpstate_live() can be sure the live register contain user-level state.
12CFLAGS_ia32_signal.o += -mfixed-range=f16-f31 10CFLAGS_ia32_signal.o += -mfixed-range=f16-f31
diff --git a/arch/ia64/ia32/elfcore32.h b/arch/ia64/ia32/elfcore32.h
index b73b8b6b10c1..a47f63b204fb 100644
--- a/arch/ia64/ia32/elfcore32.h
+++ b/arch/ia64/ia32/elfcore32.h
@@ -95,8 +95,7 @@ static inline void elf_core_copy_regs(elf_gregset_t *elfregs,
95static inline int elf_core_copy_task_regs(struct task_struct *t, 95static inline int elf_core_copy_task_regs(struct task_struct *t,
96 elf_gregset_t* elfregs) 96 elf_gregset_t* elfregs)
97{ 97{
98 struct pt_regs *pp = ia64_task_regs(t); 98 ELF_CORE_COPY_REGS((*elfregs), task_pt_regs(t));
99 ELF_CORE_COPY_REGS((*elfregs), pp);
100 return 1; 99 return 1;
101} 100}
102 101
diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S
index 494fad6bf376..95fe04400f6b 100644
--- a/arch/ia64/ia32/ia32_entry.S
+++ b/arch/ia64/ia32/ia32_entry.S
@@ -469,7 +469,7 @@ ia32_syscall_table:
469 data8 sys32_epoll_wait 469 data8 sys32_epoll_wait
470 data8 sys_remap_file_pages 470 data8 sys_remap_file_pages
471 data8 sys_set_tid_address 471 data8 sys_set_tid_address
472 data8 sys32_timer_create 472 data8 compat_sys_timer_create
473 data8 compat_sys_timer_settime /* 260 */ 473 data8 compat_sys_timer_settime /* 260 */
474 data8 compat_sys_timer_gettime 474 data8 compat_sys_timer_gettime
475 data8 sys_timer_getoverrun 475 data8 sys_timer_getoverrun
diff --git a/arch/ia64/ia32/ia32_ioctl.c b/arch/ia64/ia32/ia32_ioctl.c
deleted file mode 100644
index 88739394f6df..000000000000
--- a/arch/ia64/ia32/ia32_ioctl.c
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * IA32 Architecture-specific ioctl shim code
3 *
4 * Copyright (C) 2000 VA Linux Co
5 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
6 * Copyright (C) 2001-2003 Hewlett-Packard Co
7 * David Mosberger-Tang <davidm@hpl.hp.com>
8 */
9
10#include <linux/signal.h> /* argh, msdos_fs.h isn't self-contained... */
11#include <linux/syscalls.h>
12#include "ia32priv.h"
13
14#define INCLUDES
15#include "compat_ioctl.c"
16
17#define IOCTL_NR(a) ((a) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT))
18
19#define DO_IOCTL(fd, cmd, arg) ({ \
20 int _ret; \
21 mm_segment_t _old_fs = get_fs(); \
22 \
23 set_fs(KERNEL_DS); \
24 _ret = sys_ioctl(fd, cmd, (unsigned long)arg); \
25 set_fs(_old_fs); \
26 _ret; \
27})
28
29#define CODE
30#include "compat_ioctl.c"
31
32#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
33#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
34#define IOCTL_TABLE_START \
35 struct ioctl_trans ioctl_start[] = {
36#define IOCTL_TABLE_END \
37 };
38
39IOCTL_TABLE_START
40#define DECLARES
41#include "compat_ioctl.c"
42#include <linux/compat_ioctl.h>
43IOCTL_TABLE_END
44
45int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/ia64/ia32/ia32_signal.c b/arch/ia64/ia32/ia32_signal.c
index aa891c9bc9b6..5856510210fa 100644
--- a/arch/ia64/ia32/ia32_signal.c
+++ b/arch/ia64/ia32/ia32_signal.c
@@ -255,7 +255,7 @@ save_ia32_fpstate_live (struct _fpstate_ia32 __user *save)
255 */ 255 */
256 fp_tos = (fsr>>11)&0x7; 256 fp_tos = (fsr>>11)&0x7;
257 fr8_st_map = (8-fp_tos)&0x7; 257 fr8_st_map = (8-fp_tos)&0x7;
258 ptp = ia64_task_regs(tsk); 258 ptp = task_pt_regs(tsk);
259 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15); 259 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
260 ia64f2ia32f(fpregp, &ptp->f8); 260 ia64f2ia32f(fpregp, &ptp->f8);
261 copy_to_user(&save->_st[(0+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32)); 261 copy_to_user(&save->_st[(0+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
@@ -389,7 +389,7 @@ restore_ia32_fpstate_live (struct _fpstate_ia32 __user *save)
389 fr8_st_map = (8-fp_tos)&0x7; 389 fr8_st_map = (8-fp_tos)&0x7;
390 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15); 390 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
391 391
392 ptp = ia64_task_regs(tsk); 392 ptp = task_pt_regs(tsk);
393 copy_from_user(fpregp, &save->_st[(0+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32)); 393 copy_from_user(fpregp, &save->_st[(0+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
394 ia32f2ia64f(&ptp->f8, fpregp); 394 ia32f2ia64f(&ptp->f8, fpregp);
395 copy_from_user(fpregp, &save->_st[(1+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32)); 395 copy_from_user(fpregp, &save->_st[(1+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
diff --git a/arch/ia64/ia32/ia32_support.c b/arch/ia64/ia32/ia32_support.c
index 4f630043b3ae..c187743965a0 100644
--- a/arch/ia64/ia32/ia32_support.c
+++ b/arch/ia64/ia32/ia32_support.c
@@ -58,7 +58,7 @@ load_desc (u16 selector)
58void 58void
59ia32_load_segment_descriptors (struct task_struct *task) 59ia32_load_segment_descriptors (struct task_struct *task)
60{ 60{
61 struct pt_regs *regs = ia64_task_regs(task); 61 struct pt_regs *regs = task_pt_regs(task);
62 62
63 /* Setup the segment descriptors */ 63 /* Setup the segment descriptors */
64 regs->r24 = load_desc(regs->r16 >> 16); /* ESD */ 64 regs->r24 = load_desc(regs->r16 >> 16); /* ESD */
@@ -113,7 +113,7 @@ void
113ia32_load_state (struct task_struct *t) 113ia32_load_state (struct task_struct *t)
114{ 114{
115 unsigned long eflag, fsr, fcr, fir, fdr, tssd; 115 unsigned long eflag, fsr, fcr, fir, fdr, tssd;
116 struct pt_regs *regs = ia64_task_regs(t); 116 struct pt_regs *regs = task_pt_regs(t);
117 117
118 eflag = t->thread.eflag; 118 eflag = t->thread.eflag;
119 fsr = t->thread.fsr; 119 fsr = t->thread.fsr;
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 9f8e8d558873..3945d378bd7e 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -48,6 +48,7 @@
48#include <linux/ptrace.h> 48#include <linux/ptrace.h>
49#include <linux/stat.h> 49#include <linux/stat.h>
50#include <linux/ipc.h> 50#include <linux/ipc.h>
51#include <linux/capability.h>
51#include <linux/compat.h> 52#include <linux/compat.h>
52#include <linux/vfs.h> 53#include <linux/vfs.h>
53#include <linux/mman.h> 54#include <linux/mman.h>
@@ -1481,7 +1482,7 @@ getreg (struct task_struct *child, int regno)
1481{ 1482{
1482 struct pt_regs *child_regs; 1483 struct pt_regs *child_regs;
1483 1484
1484 child_regs = ia64_task_regs(child); 1485 child_regs = task_pt_regs(child);
1485 switch (regno / sizeof(int)) { 1486 switch (regno / sizeof(int)) {
1486 case PT_EBX: return child_regs->r11; 1487 case PT_EBX: return child_regs->r11;
1487 case PT_ECX: return child_regs->r9; 1488 case PT_ECX: return child_regs->r9;
@@ -1509,7 +1510,7 @@ putreg (struct task_struct *child, int regno, unsigned int value)
1509{ 1510{
1510 struct pt_regs *child_regs; 1511 struct pt_regs *child_regs;
1511 1512
1512 child_regs = ia64_task_regs(child); 1513 child_regs = task_pt_regs(child);
1513 switch (regno / sizeof(int)) { 1514 switch (regno / sizeof(int)) {
1514 case PT_EBX: child_regs->r11 = value; break; 1515 case PT_EBX: child_regs->r11 = value; break;
1515 case PT_ECX: child_regs->r9 = value; break; 1516 case PT_ECX: child_regs->r9 = value; break;
@@ -1625,7 +1626,7 @@ save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user
1625 * Stack frames start with 16-bytes of temp space 1626 * Stack frames start with 16-bytes of temp space
1626 */ 1627 */
1627 swp = (struct switch_stack *)(tsk->thread.ksp + 16); 1628 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1628 ptp = ia64_task_regs(tsk); 1629 ptp = task_pt_regs(tsk);
1629 tos = (tsk->thread.fsr >> 11) & 7; 1630 tos = (tsk->thread.fsr >> 11) & 7;
1630 for (i = 0; i < 8; i++) 1631 for (i = 0; i < 8; i++)
1631 put_fpreg(i, &save->st_space[i], ptp, swp, tos); 1632 put_fpreg(i, &save->st_space[i], ptp, swp, tos);
@@ -1658,7 +1659,7 @@ restore_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __us
1658 * Stack frames start with 16-bytes of temp space 1659 * Stack frames start with 16-bytes of temp space
1659 */ 1660 */
1660 swp = (struct switch_stack *)(tsk->thread.ksp + 16); 1661 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1661 ptp = ia64_task_regs(tsk); 1662 ptp = task_pt_regs(tsk);
1662 tos = (tsk->thread.fsr >> 11) & 7; 1663 tos = (tsk->thread.fsr >> 11) & 7;
1663 for (i = 0; i < 8; i++) 1664 for (i = 0; i < 8; i++)
1664 get_fpreg(i, &save->st_space[i], ptp, swp, tos); 1665 get_fpreg(i, &save->st_space[i], ptp, swp, tos);
@@ -1689,7 +1690,7 @@ save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user
1689 * Stack frames start with 16-bytes of temp space 1690 * Stack frames start with 16-bytes of temp space
1690 */ 1691 */
1691 swp = (struct switch_stack *)(tsk->thread.ksp + 16); 1692 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1692 ptp = ia64_task_regs(tsk); 1693 ptp = task_pt_regs(tsk);
1693 tos = (tsk->thread.fsr >> 11) & 7; 1694 tos = (tsk->thread.fsr >> 11) & 7;
1694 for (i = 0; i < 8; i++) 1695 for (i = 0; i < 8; i++)
1695 put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos); 1696 put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
@@ -1733,7 +1734,7 @@ restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __u
1733 * Stack frames start with 16-bytes of temp space 1734 * Stack frames start with 16-bytes of temp space
1734 */ 1735 */
1735 swp = (struct switch_stack *)(tsk->thread.ksp + 16); 1736 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1736 ptp = ia64_task_regs(tsk); 1737 ptp = task_pt_regs(tsk);
1737 tos = (tsk->thread.fsr >> 11) & 7; 1738 tos = (tsk->thread.fsr >> 11) & 7;
1738 for (i = 0; i < 8; i++) 1739 for (i = 0; i < 8; i++)
1739 get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos); 1740 get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
@@ -2553,34 +2554,6 @@ sys32_get_thread_area (struct ia32_user_desc __user *u_info)
2553 return 0; 2554 return 0;
2554} 2555}
2555 2556
2556asmlinkage long
2557sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id)
2558{
2559 struct sigevent se;
2560 mm_segment_t oldfs;
2561 timer_t t;
2562 long err;
2563
2564 if (se32 == NULL)
2565 return sys_timer_create(clock, NULL, timer_id);
2566
2567 if (get_compat_sigevent(&se, se32))
2568 return -EFAULT;
2569
2570 if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
2571 return -EFAULT;
2572
2573 oldfs = get_fs();
2574 set_fs(KERNEL_DS);
2575 err = sys_timer_create(clock, (struct sigevent __user *) &se, (timer_t __user *) &t);
2576 set_fs(oldfs);
2577
2578 if (!err)
2579 err = __put_user (t, timer_id);
2580
2581 return err;
2582}
2583
2584long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, 2557long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
2585 __u32 len_low, __u32 len_high, int advice) 2558 __u32 len_low, __u32 len_high, int advice)
2586{ 2559{
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 89a70400c4f6..346fedf9ea47 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -467,10 +467,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
467 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t)); 467 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
468} 468}
469 469
470void __kprobes arch_remove_kprobe(struct kprobe *p)
471{
472}
473
474/* 470/*
475 * We are resuming execution after a single step fault, so the pt_regs 471 * We are resuming execution after a single step fault, so the pt_regs
476 * structure reflects the register state after we executed the instruction 472 * structure reflects the register state after we executed the instruction
@@ -642,6 +638,13 @@ static int __kprobes pre_kprobes_handler(struct die_args *args)
642 if (p->break_handler && p->break_handler(p, regs)) { 638 if (p->break_handler && p->break_handler(p, regs)) {
643 goto ss_probe; 639 goto ss_probe;
644 } 640 }
641 } else if (!is_ia64_break_inst(regs)) {
642 /* The breakpoint instruction was removed by
643 * another cpu right after we hit, no further
644 * handling of this interrupt is appropriate
645 */
646 ret = 1;
647 goto no_kprobe;
645 } else { 648 } else {
646 /* Not our break */ 649 /* Not our break */
647 goto no_kprobe; 650 goto no_kprobe;
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 355af15287c7..ee7eec9ee576 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -766,7 +766,7 @@ ia64_mca_modify_original_stack(struct pt_regs *regs,
766 l = strlen(previous_current->comm); 766 l = strlen(previous_current->comm);
767 snprintf(comm, sizeof(comm), "%s %*s %d", 767 snprintf(comm, sizeof(comm), "%s %*s %d",
768 current->comm, l, previous_current->comm, 768 current->comm, l, previous_current->comm,
769 previous_current->thread_info->cpu); 769 task_thread_info(previous_current)->cpu);
770 } 770 }
771 memcpy(current->comm, comm, sizeof(current->comm)); 771 memcpy(current->comm, comm, sizeof(current->comm));
772 772
@@ -1423,7 +1423,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,
1423 struct task_struct *p = (struct task_struct *)((char *)mca_data + offset); 1423 struct task_struct *p = (struct task_struct *)((char *)mca_data + offset);
1424 struct thread_info *ti; 1424 struct thread_info *ti;
1425 memset(p, 0, KERNEL_STACK_SIZE); 1425 memset(p, 0, KERNEL_STACK_SIZE);
1426 ti = (struct thread_info *)((char *)p + IA64_TASK_SIZE); 1426 ti = task_thread_info(p);
1427 ti->flags = _TIF_MCA_INIT; 1427 ti->flags = _TIF_MCA_INIT;
1428 ti->preempt_count = 1; 1428 ti->preempt_count = 1;
1429 ti->task = p; 1429 ti->task = p;
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 410d4804fa6e..bd87cb6b7a81 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -38,6 +38,7 @@
38#include <linux/pagemap.h> 38#include <linux/pagemap.h>
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/bitops.h> 40#include <linux/bitops.h>
41#include <linux/capability.h>
41#include <linux/rcupdate.h> 42#include <linux/rcupdate.h>
42 43
43#include <asm/errno.h> 44#include <asm/errno.h>
@@ -1709,7 +1710,7 @@ static void
1709pfm_syswide_force_stop(void *info) 1710pfm_syswide_force_stop(void *info)
1710{ 1711{
1711 pfm_context_t *ctx = (pfm_context_t *)info; 1712 pfm_context_t *ctx = (pfm_context_t *)info;
1712 struct pt_regs *regs = ia64_task_regs(current); 1713 struct pt_regs *regs = task_pt_regs(current);
1713 struct task_struct *owner; 1714 struct task_struct *owner;
1714 unsigned long flags; 1715 unsigned long flags;
1715 int ret; 1716 int ret;
@@ -1814,7 +1815,7 @@ pfm_flush(struct file *filp)
1814 is_system = ctx->ctx_fl_system; 1815 is_system = ctx->ctx_fl_system;
1815 1816
1816 task = PFM_CTX_TASK(ctx); 1817 task = PFM_CTX_TASK(ctx);
1817 regs = ia64_task_regs(task); 1818 regs = task_pt_regs(task);
1818 1819
1819 DPRINT(("ctx_state=%d is_current=%d\n", 1820 DPRINT(("ctx_state=%d is_current=%d\n",
1820 state, 1821 state,
@@ -1944,7 +1945,7 @@ pfm_close(struct inode *inode, struct file *filp)
1944 is_system = ctx->ctx_fl_system; 1945 is_system = ctx->ctx_fl_system;
1945 1946
1946 task = PFM_CTX_TASK(ctx); 1947 task = PFM_CTX_TASK(ctx);
1947 regs = ia64_task_regs(task); 1948 regs = task_pt_regs(task);
1948 1949
1949 DPRINT(("ctx_state=%d is_current=%d\n", 1950 DPRINT(("ctx_state=%d is_current=%d\n",
1950 state, 1951 state,
@@ -4051,7 +4052,7 @@ pfm_stop(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4051 */ 4052 */
4052 ia64_psr(regs)->up = 0; 4053 ia64_psr(regs)->up = 0;
4053 } else { 4054 } else {
4054 tregs = ia64_task_regs(task); 4055 tregs = task_pt_regs(task);
4055 4056
4056 /* 4057 /*
4057 * stop monitoring at the user level 4058 * stop monitoring at the user level
@@ -4133,7 +4134,7 @@ pfm_start(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4133 ia64_psr(regs)->up = 1; 4134 ia64_psr(regs)->up = 1;
4134 4135
4135 } else { 4136 } else {
4136 tregs = ia64_task_regs(ctx->ctx_task); 4137 tregs = task_pt_regs(ctx->ctx_task);
4137 4138
4138 /* 4139 /*
4139 * start monitoring at the kernel level the next 4140 * start monitoring at the kernel level the next
@@ -4403,7 +4404,7 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4403 /* 4404 /*
4404 * when not current, task MUST be stopped, so this is safe 4405 * when not current, task MUST be stopped, so this is safe
4405 */ 4406 */
4406 regs = ia64_task_regs(task); 4407 regs = task_pt_regs(task);
4407 4408
4408 /* force a full reload */ 4409 /* force a full reload */
4409 ctx->ctx_last_activation = PFM_INVALID_ACTIVATION; 4410 ctx->ctx_last_activation = PFM_INVALID_ACTIVATION;
@@ -4529,7 +4530,7 @@ pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg
4529 /* 4530 /*
4530 * per-task mode 4531 * per-task mode
4531 */ 4532 */
4532 tregs = task == current ? regs : ia64_task_regs(task); 4533 tregs = task == current ? regs : task_pt_regs(task);
4533 4534
4534 if (task == current) { 4535 if (task == current) {
4535 /* 4536 /*
@@ -4592,7 +4593,7 @@ pfm_exit_thread(struct task_struct *task)
4592{ 4593{
4593 pfm_context_t *ctx; 4594 pfm_context_t *ctx;
4594 unsigned long flags; 4595 unsigned long flags;
4595 struct pt_regs *regs = ia64_task_regs(task); 4596 struct pt_regs *regs = task_pt_regs(task);
4596 int ret, state; 4597 int ret, state;
4597 int free_ok = 0; 4598 int free_ok = 0;
4598 4599
@@ -4925,7 +4926,7 @@ restart_args:
4925 if (unlikely(ret)) goto abort_locked; 4926 if (unlikely(ret)) goto abort_locked;
4926 4927
4927skip_fd: 4928skip_fd:
4928 ret = (*func)(ctx, args_k, count, ia64_task_regs(current)); 4929 ret = (*func)(ctx, args_k, count, task_pt_regs(current));
4929 4930
4930 call_made = 1; 4931 call_made = 1;
4931 4932
@@ -5049,7 +5050,7 @@ pfm_handle_work(void)
5049 5050
5050 pfm_clear_task_notify(); 5051 pfm_clear_task_notify();
5051 5052
5052 regs = ia64_task_regs(current); 5053 regs = task_pt_regs(current);
5053 5054
5054 /* 5055 /*
5055 * extract reason for being here and clear 5056 * extract reason for being here and clear
@@ -5793,7 +5794,7 @@ pfm_syst_wide_update_task(struct task_struct *task, unsigned long info, int is_c
5793 * on every CPU, so we can rely on the pid to identify the idle task. 5794 * on every CPU, so we can rely on the pid to identify the idle task.
5794 */ 5795 */
5795 if ((info & PFM_CPUINFO_EXCL_IDLE) == 0 || task->pid) { 5796 if ((info & PFM_CPUINFO_EXCL_IDLE) == 0 || task->pid) {
5796 regs = ia64_task_regs(task); 5797 regs = task_pt_regs(task);
5797 ia64_psr(regs)->pp = is_ctxswin ? dcr_pp : 0; 5798 ia64_psr(regs)->pp = is_ctxswin ? dcr_pp : 0;
5798 return; 5799 return;
5799 } 5800 }
@@ -5876,7 +5877,7 @@ pfm_save_regs(struct task_struct *task)
5876 flags = pfm_protect_ctx_ctxsw(ctx); 5877 flags = pfm_protect_ctx_ctxsw(ctx);
5877 5878
5878 if (ctx->ctx_state == PFM_CTX_ZOMBIE) { 5879 if (ctx->ctx_state == PFM_CTX_ZOMBIE) {
5879 struct pt_regs *regs = ia64_task_regs(task); 5880 struct pt_regs *regs = task_pt_regs(task);
5880 5881
5881 pfm_clear_psr_up(); 5882 pfm_clear_psr_up();
5882 5883
@@ -6076,7 +6077,7 @@ pfm_load_regs (struct task_struct *task)
6076 BUG_ON(psr & IA64_PSR_I); 6077 BUG_ON(psr & IA64_PSR_I);
6077 6078
6078 if (unlikely(ctx->ctx_state == PFM_CTX_ZOMBIE)) { 6079 if (unlikely(ctx->ctx_state == PFM_CTX_ZOMBIE)) {
6079 struct pt_regs *regs = ia64_task_regs(task); 6080 struct pt_regs *regs = task_pt_regs(task);
6080 6081
6081 BUG_ON(ctx->ctx_smpl_hdr); 6082 BUG_ON(ctx->ctx_smpl_hdr);
6082 6083
@@ -6445,7 +6446,7 @@ pfm_alt_save_pmu_state(void *data)
6445{ 6446{
6446 struct pt_regs *regs; 6447 struct pt_regs *regs;
6447 6448
6448 regs = ia64_task_regs(current); 6449 regs = task_pt_regs(current);
6449 6450
6450 DPRINT(("called\n")); 6451 DPRINT(("called\n"));
6451 6452
@@ -6471,7 +6472,7 @@ pfm_alt_restore_pmu_state(void *data)
6471{ 6472{
6472 struct pt_regs *regs; 6473 struct pt_regs *regs;
6473 6474
6474 regs = ia64_task_regs(current); 6475 regs = task_pt_regs(current);
6475 6476
6476 DPRINT(("called\n")); 6477 DPRINT(("called\n"));
6477 6478
@@ -6753,7 +6754,7 @@ dump_pmu_state(const char *from)
6753 local_irq_save(flags); 6754 local_irq_save(flags);
6754 6755
6755 this_cpu = smp_processor_id(); 6756 this_cpu = smp_processor_id();
6756 regs = ia64_task_regs(current); 6757 regs = task_pt_regs(current);
6757 info = PFM_CPUINFO_GET(); 6758 info = PFM_CPUINFO_GET();
6758 dcr = ia64_getreg(_IA64_REG_CR_DCR); 6759 dcr = ia64_getreg(_IA64_REG_CR_DCR);
6759 6760
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index e9904c74d2ba..309d59658e5f 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -328,7 +328,7 @@ ia64_save_extra (struct task_struct *task)
328#endif 328#endif
329 329
330#ifdef CONFIG_IA32_SUPPORT 330#ifdef CONFIG_IA32_SUPPORT
331 if (IS_IA32_PROCESS(ia64_task_regs(task))) 331 if (IS_IA32_PROCESS(task_pt_regs(task)))
332 ia32_save_state(task); 332 ia32_save_state(task);
333#endif 333#endif
334} 334}
@@ -353,7 +353,7 @@ ia64_load_extra (struct task_struct *task)
353#endif 353#endif
354 354
355#ifdef CONFIG_IA32_SUPPORT 355#ifdef CONFIG_IA32_SUPPORT
356 if (IS_IA32_PROCESS(ia64_task_regs(task))) 356 if (IS_IA32_PROCESS(task_pt_regs(task)))
357 ia32_load_state(task); 357 ia32_load_state(task);
358#endif 358#endif
359} 359}
@@ -488,7 +488,7 @@ copy_thread (int nr, unsigned long clone_flags,
488 * If we're cloning an IA32 task then save the IA32 extra 488 * If we're cloning an IA32 task then save the IA32 extra
489 * state from the current task to the new task 489 * state from the current task to the new task
490 */ 490 */
491 if (IS_IA32_PROCESS(ia64_task_regs(current))) { 491 if (IS_IA32_PROCESS(task_pt_regs(current))) {
492 ia32_save_state(p); 492 ia32_save_state(p);
493 if (clone_flags & CLONE_SETTLS) 493 if (clone_flags & CLONE_SETTLS)
494 retval = ia32_clone_tls(p, child_ptregs); 494 retval = ia32_clone_tls(p, child_ptregs);
@@ -701,7 +701,7 @@ int
701kernel_thread_helper (int (*fn)(void *), void *arg) 701kernel_thread_helper (int (*fn)(void *), void *arg)
702{ 702{
703#ifdef CONFIG_IA32_SUPPORT 703#ifdef CONFIG_IA32_SUPPORT
704 if (IS_IA32_PROCESS(ia64_task_regs(current))) { 704 if (IS_IA32_PROCESS(task_pt_regs(current))) {
705 /* A kernel thread is always a 64-bit process. */ 705 /* A kernel thread is always a 64-bit process. */
706 current->thread.map_base = DEFAULT_MAP_BASE; 706 current->thread.map_base = DEFAULT_MAP_BASE;
707 current->thread.task_size = DEFAULT_TASK_SIZE; 707 current->thread.task_size = DEFAULT_TASK_SIZE;
@@ -722,7 +722,7 @@ flush_thread (void)
722 current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID); 722 current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID);
723 ia64_drop_fpu(current); 723 ia64_drop_fpu(current);
724#ifdef CONFIG_IA32_SUPPORT 724#ifdef CONFIG_IA32_SUPPORT
725 if (IS_IA32_PROCESS(ia64_task_regs(current))) { 725 if (IS_IA32_PROCESS(task_pt_regs(current))) {
726 ia32_drop_partial_page_list(current); 726 ia32_drop_partial_page_list(current);
727 current->thread.task_size = IA32_PAGE_OFFSET; 727 current->thread.task_size = IA32_PAGE_OFFSET;
728 set_fs(USER_DS); 728 set_fs(USER_DS);
@@ -755,7 +755,7 @@ exit_thread (void)
755 if (current->thread.flags & IA64_THREAD_DBG_VALID) 755 if (current->thread.flags & IA64_THREAD_DBG_VALID)
756 pfm_release_debug_registers(current); 756 pfm_release_debug_registers(current);
757#endif 757#endif
758 if (IS_IA32_PROCESS(ia64_task_regs(current))) 758 if (IS_IA32_PROCESS(task_pt_regs(current)))
759 ia32_drop_partial_page_list(current); 759 ia32_drop_partial_page_list(current);
760} 760}
761 761
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 8d88eeea02d1..eaed14aac6aa 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -254,7 +254,7 @@ get_rnat (struct task_struct *task, struct switch_stack *sw,
254 long num_regs, nbits; 254 long num_regs, nbits;
255 struct pt_regs *pt; 255 struct pt_regs *pt;
256 256
257 pt = ia64_task_regs(task); 257 pt = task_pt_regs(task);
258 kbsp = (unsigned long *) sw->ar_bspstore; 258 kbsp = (unsigned long *) sw->ar_bspstore;
259 ubspstore = (unsigned long *) pt->ar_bspstore; 259 ubspstore = (unsigned long *) pt->ar_bspstore;
260 260
@@ -314,7 +314,7 @@ put_rnat (struct task_struct *task, struct switch_stack *sw,
314 struct pt_regs *pt; 314 struct pt_regs *pt;
315 unsigned long cfm, *urbs_kargs; 315 unsigned long cfm, *urbs_kargs;
316 316
317 pt = ia64_task_regs(task); 317 pt = task_pt_regs(task);
318 kbsp = (unsigned long *) sw->ar_bspstore; 318 kbsp = (unsigned long *) sw->ar_bspstore;
319 ubspstore = (unsigned long *) pt->ar_bspstore; 319 ubspstore = (unsigned long *) pt->ar_bspstore;
320 320
@@ -407,7 +407,7 @@ ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
407 407
408 urbs_end = (long *) user_rbs_end; 408 urbs_end = (long *) user_rbs_end;
409 laddr = (unsigned long *) addr; 409 laddr = (unsigned long *) addr;
410 child_regs = ia64_task_regs(child); 410 child_regs = task_pt_regs(child);
411 bspstore = (unsigned long *) child_regs->ar_bspstore; 411 bspstore = (unsigned long *) child_regs->ar_bspstore;
412 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8; 412 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
413 if (on_kernel_rbs(addr, (unsigned long) bspstore, 413 if (on_kernel_rbs(addr, (unsigned long) bspstore,
@@ -467,7 +467,7 @@ ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
467 struct pt_regs *child_regs; 467 struct pt_regs *child_regs;
468 468
469 laddr = (unsigned long *) addr; 469 laddr = (unsigned long *) addr;
470 child_regs = ia64_task_regs(child); 470 child_regs = task_pt_regs(child);
471 bspstore = (unsigned long *) child_regs->ar_bspstore; 471 bspstore = (unsigned long *) child_regs->ar_bspstore;
472 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8; 472 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
473 if (on_kernel_rbs(addr, (unsigned long) bspstore, 473 if (on_kernel_rbs(addr, (unsigned long) bspstore,
@@ -567,7 +567,7 @@ thread_matches (struct task_struct *thread, unsigned long addr)
567 */ 567 */
568 return 0; 568 return 0;
569 569
570 thread_regs = ia64_task_regs(thread); 570 thread_regs = task_pt_regs(thread);
571 thread_rbs_end = ia64_get_user_rbs_end(thread, thread_regs, NULL); 571 thread_rbs_end = ia64_get_user_rbs_end(thread, thread_regs, NULL);
572 if (!on_kernel_rbs(addr, thread_regs->ar_bspstore, thread_rbs_end)) 572 if (!on_kernel_rbs(addr, thread_regs->ar_bspstore, thread_rbs_end))
573 return 0; 573 return 0;
@@ -627,7 +627,7 @@ find_thread_for_addr (struct task_struct *child, unsigned long addr)
627inline void 627inline void
628ia64_flush_fph (struct task_struct *task) 628ia64_flush_fph (struct task_struct *task)
629{ 629{
630 struct ia64_psr *psr = ia64_psr(ia64_task_regs(task)); 630 struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
631 631
632 /* 632 /*
633 * Prevent migrating this task while 633 * Prevent migrating this task while
@@ -653,7 +653,7 @@ ia64_flush_fph (struct task_struct *task)
653void 653void
654ia64_sync_fph (struct task_struct *task) 654ia64_sync_fph (struct task_struct *task)
655{ 655{
656 struct ia64_psr *psr = ia64_psr(ia64_task_regs(task)); 656 struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
657 657
658 ia64_flush_fph(task); 658 ia64_flush_fph(task);
659 if (!(task->thread.flags & IA64_THREAD_FPH_VALID)) { 659 if (!(task->thread.flags & IA64_THREAD_FPH_VALID)) {
@@ -794,7 +794,7 @@ access_uarea (struct task_struct *child, unsigned long addr,
794 + offsetof(struct pt_regs, reg))) 794 + offsetof(struct pt_regs, reg)))
795 795
796 796
797 pt = ia64_task_regs(child); 797 pt = task_pt_regs(child);
798 sw = (struct switch_stack *) (child->thread.ksp + 16); 798 sw = (struct switch_stack *) (child->thread.ksp + 16);
799 799
800 if ((addr & 0x7) != 0) { 800 if ((addr & 0x7) != 0) {
@@ -1120,7 +1120,7 @@ ptrace_getregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
1120 if (!access_ok(VERIFY_WRITE, ppr, sizeof(struct pt_all_user_regs))) 1120 if (!access_ok(VERIFY_WRITE, ppr, sizeof(struct pt_all_user_regs)))
1121 return -EIO; 1121 return -EIO;
1122 1122
1123 pt = ia64_task_regs(child); 1123 pt = task_pt_regs(child);
1124 sw = (struct switch_stack *) (child->thread.ksp + 16); 1124 sw = (struct switch_stack *) (child->thread.ksp + 16);
1125 unw_init_from_blocked_task(&info, child); 1125 unw_init_from_blocked_task(&info, child);
1126 if (unw_unwind_to_user(&info) < 0) { 1126 if (unw_unwind_to_user(&info) < 0) {
@@ -1265,7 +1265,7 @@ ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
1265 if (!access_ok(VERIFY_READ, ppr, sizeof(struct pt_all_user_regs))) 1265 if (!access_ok(VERIFY_READ, ppr, sizeof(struct pt_all_user_regs)))
1266 return -EIO; 1266 return -EIO;
1267 1267
1268 pt = ia64_task_regs(child); 1268 pt = task_pt_regs(child);
1269 sw = (struct switch_stack *) (child->thread.ksp + 16); 1269 sw = (struct switch_stack *) (child->thread.ksp + 16);
1270 unw_init_from_blocked_task(&info, child); 1270 unw_init_from_blocked_task(&info, child);
1271 if (unw_unwind_to_user(&info) < 0) { 1271 if (unw_unwind_to_user(&info) < 0) {
@@ -1403,7 +1403,7 @@ ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
1403void 1403void
1404ptrace_disable (struct task_struct *child) 1404ptrace_disable (struct task_struct *child)
1405{ 1405{
1406 struct ia64_psr *child_psr = ia64_psr(ia64_task_regs(child)); 1406 struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
1407 1407
1408 /* make sure the single step/taken-branch trap bits are not set: */ 1408 /* make sure the single step/taken-branch trap bits are not set: */
1409 child_psr->ss = 0; 1409 child_psr->ss = 0;
@@ -1456,7 +1456,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
1456 if (ret < 0) 1456 if (ret < 0)
1457 goto out_tsk; 1457 goto out_tsk;
1458 1458
1459 pt = ia64_task_regs(child); 1459 pt = task_pt_regs(child);
1460 sw = (struct switch_stack *) (child->thread.ksp + 16); 1460 sw = (struct switch_stack *) (child->thread.ksp + 16);
1461 1461
1462 switch (request) { 1462 switch (request) {
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 1461dc660b43..a87a162a3086 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -29,6 +29,7 @@
29 * Replace some NR_CPUS by cpus_online, for hotplug cpu. 29 * Replace some NR_CPUS by cpus_online, for hotplug cpu.
30 */ 30 */
31 31
32#include <linux/capability.h>
32#include <linux/types.h> 33#include <linux/types.h>
33#include <linux/proc_fs.h> 34#include <linux/proc_fs.h>
34#include <linux/module.h> 35#include <linux/module.h>
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index c33305d8e5eb..c0766575a3a2 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -60,6 +60,7 @@
60#include <asm/smp.h> 60#include <asm/smp.h>
61#include <asm/system.h> 61#include <asm/system.h>
62#include <asm/unistd.h> 62#include <asm/unistd.h>
63#include <asm/system.h>
63 64
64#if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE) 65#if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
65# error "struct cpuinfo_ia64 too big!" 66# error "struct cpuinfo_ia64 too big!"
@@ -695,6 +696,7 @@ static void
695get_max_cacheline_size (void) 696get_max_cacheline_size (void)
696{ 697{
697 unsigned long line_size, max = 1; 698 unsigned long line_size, max = 1;
699 unsigned int cache_size = 0;
698 u64 l, levels, unique_caches; 700 u64 l, levels, unique_caches;
699 pal_cache_config_info_t cci; 701 pal_cache_config_info_t cci;
700 s64 status; 702 s64 status;
@@ -724,6 +726,8 @@ get_max_cacheline_size (void)
724 line_size = 1 << cci.pcci_line_size; 726 line_size = 1 << cci.pcci_line_size;
725 if (line_size > max) 727 if (line_size > max)
726 max = line_size; 728 max = line_size;
729 if (cache_size < cci.pcci_cache_size)
730 cache_size = cci.pcci_cache_size;
727 if (!cci.pcci_unified) { 731 if (!cci.pcci_unified) {
728 status = ia64_pal_cache_config_info(l, 732 status = ia64_pal_cache_config_info(l,
729 /* cache_type (instruction)= */ 1, 733 /* cache_type (instruction)= */ 1,
@@ -740,6 +744,9 @@ get_max_cacheline_size (void)
740 ia64_i_cache_stride_shift = cci.pcci_stride; 744 ia64_i_cache_stride_shift = cci.pcci_stride;
741 } 745 }
742 out: 746 out:
747#ifdef CONFIG_SMP
748 max_cache_size = max(max_cache_size, cache_size);
749#endif
743 if (max > ia64_max_cacheline_size) 750 if (max > ia64_max_cacheline_size)
744 ia64_max_cacheline_size = max; 751 ia64_max_cacheline_size = max;
745} 752}
@@ -794,7 +801,7 @@ cpu_init (void)
794#endif 801#endif
795 802
796 /* Clear the stack memory reserved for pt_regs: */ 803 /* Clear the stack memory reserved for pt_regs: */
797 memset(ia64_task_regs(current), 0, sizeof(struct pt_regs)); 804 memset(task_pt_regs(current), 0, sizeof(struct pt_regs));
798 805
799 ia64_set_kr(IA64_KR_FPU_OWNER, 0); 806 ia64_set_kr(IA64_KR_FPU_OWNER, 0);
800 807
@@ -870,6 +877,15 @@ cpu_init (void)
870 pm_idle = default_idle; 877 pm_idle = default_idle;
871} 878}
872 879
880/*
881 * On SMP systems, when the scheduler does migration-cost autodetection,
882 * it needs a way to flush as much of the CPU's caches as possible.
883 */
884void sched_cacheflush(void)
885{
886 ia64_sal_cache_flush(3);
887}
888
873void 889void
874check_bugs (void) 890check_bugs (void)
875{ 891{
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index 58ce07efc56e..463f6bb44d07 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -655,11 +655,11 @@ set_sigdelayed(pid_t pid, int signo, int code, void __user *addr)
655 655
656 if (!t) 656 if (!t)
657 return; 657 return;
658 t->thread_info->sigdelayed.signo = signo; 658 task_thread_info(t)->sigdelayed.signo = signo;
659 t->thread_info->sigdelayed.code = code; 659 task_thread_info(t)->sigdelayed.code = code;
660 t->thread_info->sigdelayed.addr = addr; 660 task_thread_info(t)->sigdelayed.addr = addr;
661 t->thread_info->sigdelayed.start_time = start_time; 661 task_thread_info(t)->sigdelayed.start_time = start_time;
662 t->thread_info->sigdelayed.pid = pid; 662 task_thread_info(t)->sigdelayed.pid = pid;
663 wmb(); 663 wmb();
664 set_tsk_thread_flag(t, TIF_SIGDELAYED); 664 set_tsk_thread_flag(t, TIF_SIGDELAYED);
665 } 665 }
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
index f2dbcd1db0d4..c7b943f10199 100644
--- a/arch/ia64/kernel/sys_ia64.c
+++ b/arch/ia64/kernel/sys_ia64.c
@@ -151,7 +151,7 @@ out:
151asmlinkage long 151asmlinkage long
152sys_pipe (void) 152sys_pipe (void)
153{ 153{
154 struct pt_regs *regs = ia64_task_regs(current); 154 struct pt_regs *regs = task_pt_regs(current);
155 int fd[2]; 155 int fd[2];
156 int retval; 156 int retval;
157 157
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index 768c21deb2e5..493fb3f38dc3 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -11,6 +11,7 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/capability.h>
14#include <linux/device.h> 15#include <linux/device.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
16#include <asm/system.h> 17#include <asm/system.h>
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index fae67bbb52f6..a3dcc3fab4b7 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -12,10 +12,6 @@ config M32R
12config SBUS 12config SBUS
13 bool 13 bool
14 14
15config UID16
16 bool
17 default n
18
19config GENERIC_ISA_DMA 15config GENERIC_ISA_DMA
20 bool 16 bool
21 default y 17 default y
diff --git a/arch/m32r/kernel/m32r_ksyms.c b/arch/m32r/kernel/m32r_ksyms.c
index e5ec134d81d9..dbc8a392105f 100644
--- a/arch/m32r/kernel/m32r_ksyms.c
+++ b/arch/m32r/kernel/m32r_ksyms.c
@@ -18,8 +18,6 @@
18#include <asm/irq.h> 18#include <asm/irq.h>
19#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
20 20
21extern void dump_thread(struct pt_regs *, struct user *);
22
23#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE) 21#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
24extern struct drive_info_struct drive_info; 22extern struct drive_info_struct drive_info;
25EXPORT_SYMBOL(drive_info); 23EXPORT_SYMBOL(drive_info);
@@ -27,7 +25,6 @@ EXPORT_SYMBOL(drive_info);
27 25
28/* platform dependent support */ 26/* platform dependent support */
29EXPORT_SYMBOL(boot_cpu_data); 27EXPORT_SYMBOL(boot_cpu_data);
30EXPORT_SYMBOL(dump_thread);
31EXPORT_SYMBOL(dump_fpu); 28EXPORT_SYMBOL(dump_fpu);
32EXPORT_SYMBOL(__ioremap); 29EXPORT_SYMBOL(__ioremap);
33EXPORT_SYMBOL(iounmap); 30EXPORT_SYMBOL(iounmap);
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index 3bf55d92933f..5dfc7ea45cf7 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -242,13 +242,10 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
242int copy_thread(int nr, unsigned long clone_flags, unsigned long spu, 242int copy_thread(int nr, unsigned long clone_flags, unsigned long spu,
243 unsigned long unused, struct task_struct *tsk, struct pt_regs *regs) 243 unsigned long unused, struct task_struct *tsk, struct pt_regs *regs)
244{ 244{
245 struct pt_regs *childregs; 245 struct pt_regs *childregs = task_pt_regs(tsk);
246 unsigned long sp = (unsigned long)tsk->thread_info + THREAD_SIZE;
247 extern void ret_from_fork(void); 246 extern void ret_from_fork(void);
248 247
249 /* Copy registers */ 248 /* Copy registers */
250 sp -= sizeof (struct pt_regs);
251 childregs = (struct pt_regs *)sp;
252 *childregs = *regs; 249 *childregs = *regs;
253 250
254 childregs->spu = spu; 251 childregs->spu = spu;
@@ -261,14 +258,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long spu,
261} 258}
262 259
263/* 260/*
264 * fill in the user structure for a core dump..
265 */
266void dump_thread(struct pt_regs * regs, struct user * dump)
267{
268 /* M32R_FIXME */
269}
270
271/*
272 * Capture the user space registers if the task is not running (in user space) 261 * Capture the user space registers if the task is not running (in user space)
273 */ 262 */
274int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) 263int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index 9b75caaf5cec..340a3bf59b88 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -35,23 +35,6 @@
35#include <asm/mmu_context.h> 35#include <asm/mmu_context.h>
36 36
37/* 37/*
38 * Get the address of the live pt_regs for the specified task.
39 * These are saved onto the top kernel stack when the process
40 * is not running.
41 *
42 * Note: if a user thread is execve'd from kernel space, the
43 * kernel stack will not be empty on entry to the kernel, so
44 * ptracing these tasks will fail.
45 */
46static inline struct pt_regs *
47get_user_regs(struct task_struct *task)
48{
49 return (struct pt_regs *)
50 ((unsigned long)task->thread_info + THREAD_SIZE
51 - sizeof(struct pt_regs));
52}
53
54/*
55 * This routine will get a word off of the process kernel stack. 38 * This routine will get a word off of the process kernel stack.
56 */ 39 */
57static inline unsigned long int 40static inline unsigned long int
@@ -59,7 +42,7 @@ get_stack_long(struct task_struct *task, int offset)
59{ 42{
60 unsigned long *stack; 43 unsigned long *stack;
61 44
62 stack = (unsigned long *)get_user_regs(task); 45 stack = (unsigned long *)task_pt_regs(task);
63 46
64 return stack[offset]; 47 return stack[offset];
65} 48}
@@ -72,7 +55,7 @@ put_stack_long(struct task_struct *task, int offset, unsigned long data)
72{ 55{
73 unsigned long *stack; 56 unsigned long *stack;
74 57
75 stack = (unsigned long *)get_user_regs(task); 58 stack = (unsigned long *)task_pt_regs(task);
76 stack[offset] = data; 59 stack[offset] = data;
77 60
78 return 0; 61 return 0;
@@ -208,7 +191,7 @@ static int ptrace_write_user(struct task_struct *tsk, unsigned long off,
208 */ 191 */
209static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 192static int ptrace_getregs(struct task_struct *tsk, void __user *uregs)
210{ 193{
211 struct pt_regs *regs = get_user_regs(tsk); 194 struct pt_regs *regs = task_pt_regs(tsk);
212 195
213 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 196 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
214} 197}
@@ -223,7 +206,7 @@ static int ptrace_setregs(struct task_struct *tsk, void __user *uregs)
223 206
224 ret = -EFAULT; 207 ret = -EFAULT;
225 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 208 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) {
226 struct pt_regs *regs = get_user_regs(tsk); 209 struct pt_regs *regs = task_pt_regs(tsk);
227 *regs = newregs; 210 *regs = newregs;
228 ret = 0; 211 ret = 0;
229 } 212 }
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index b90c54169fa5..d7ec16e7fb25 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -286,7 +286,7 @@ static void __init do_boot_cpu(int phys_id)
286 /* So we see what's up */ 286 /* So we see what's up */
287 printk("Booting processor %d/%d\n", phys_id, cpu_id); 287 printk("Booting processor %d/%d\n", phys_id, cpu_id);
288 stack_start.spi = (void *)idle->thread.sp; 288 stack_start.spi = (void *)idle->thread.sp;
289 idle->thread_info->cpu = cpu_id; 289 task_thread_info(idle)->cpu = cpu_id;
290 290
291 /* 291 /*
292 * Send Startup IPI 292 * Send Startup IPI
diff --git a/arch/m68k/amiga/amiints.c b/arch/m68k/amiga/amiints.c
index d9edf2d1a492..b0aa61bf8700 100644
--- a/arch/m68k/amiga/amiints.c
+++ b/arch/m68k/amiga/amiints.c
@@ -126,9 +126,9 @@ void __init amiga_init_IRQ(void)
126 gayle.inten = GAYLE_IRQ_IDE; 126 gayle.inten = GAYLE_IRQ_IDE;
127 127
128 /* turn off all interrupts and enable the master interrupt bit */ 128 /* turn off all interrupts and enable the master interrupt bit */
129 custom.intena = 0x7fff; 129 amiga_custom.intena = 0x7fff;
130 custom.intreq = 0x7fff; 130 amiga_custom.intreq = 0x7fff;
131 custom.intena = IF_SETCLR | IF_INTEN; 131 amiga_custom.intena = IF_SETCLR | IF_INTEN;
132 132
133 cia_init_IRQ(&ciaa_base); 133 cia_init_IRQ(&ciaa_base);
134 cia_init_IRQ(&ciab_base); 134 cia_init_IRQ(&ciab_base);
@@ -245,7 +245,7 @@ int amiga_request_irq(unsigned int irq,
245 245
246 /* enable the interrupt */ 246 /* enable the interrupt */
247 if (irq < IRQ_AMIGA_PORTS && !ami_ablecount[irq]) 247 if (irq < IRQ_AMIGA_PORTS && !ami_ablecount[irq])
248 custom.intena = IF_SETCLR | amiga_intena_vals[irq]; 248 amiga_custom.intena = IF_SETCLR | amiga_intena_vals[irq];
249 249
250 return error; 250 return error;
251} 251}
@@ -274,7 +274,7 @@ void amiga_free_irq(unsigned int irq, void *dev_id)
274 amiga_delete_irq(&ami_irq_list[irq], dev_id); 274 amiga_delete_irq(&ami_irq_list[irq], dev_id);
275 /* if server list empty, disable the interrupt */ 275 /* if server list empty, disable the interrupt */
276 if (!ami_irq_list[irq] && irq < IRQ_AMIGA_PORTS) 276 if (!ami_irq_list[irq] && irq < IRQ_AMIGA_PORTS)
277 custom.intena = amiga_intena_vals[irq]; 277 amiga_custom.intena = amiga_intena_vals[irq];
278 } else { 278 } else {
279 if (ami_irq_list[irq]->dev_id != dev_id) 279 if (ami_irq_list[irq]->dev_id != dev_id)
280 printk("%s: removing probably wrong IRQ %d from %s\n", 280 printk("%s: removing probably wrong IRQ %d from %s\n",
@@ -283,7 +283,7 @@ void amiga_free_irq(unsigned int irq, void *dev_id)
283 ami_irq_list[irq]->flags = 0; 283 ami_irq_list[irq]->flags = 0;
284 ami_irq_list[irq]->dev_id = NULL; 284 ami_irq_list[irq]->dev_id = NULL;
285 ami_irq_list[irq]->devname = NULL; 285 ami_irq_list[irq]->devname = NULL;
286 custom.intena = amiga_intena_vals[irq]; 286 amiga_custom.intena = amiga_intena_vals[irq];
287 } 287 }
288} 288}
289 289
@@ -327,7 +327,7 @@ void amiga_enable_irq(unsigned int irq)
327 } 327 }
328 328
329 /* enable the interrupt */ 329 /* enable the interrupt */
330 custom.intena = IF_SETCLR | amiga_intena_vals[irq]; 330 amiga_custom.intena = IF_SETCLR | amiga_intena_vals[irq];
331} 331}
332 332
333void amiga_disable_irq(unsigned int irq) 333void amiga_disable_irq(unsigned int irq)
@@ -358,7 +358,7 @@ void amiga_disable_irq(unsigned int irq)
358 } 358 }
359 359
360 /* disable the interrupt */ 360 /* disable the interrupt */
361 custom.intena = amiga_intena_vals[irq]; 361 amiga_custom.intena = amiga_intena_vals[irq];
362} 362}
363 363
364inline void amiga_do_irq(int irq, struct pt_regs *fp) 364inline void amiga_do_irq(int irq, struct pt_regs *fp)
@@ -373,7 +373,7 @@ void amiga_do_irq_list(int irq, struct pt_regs *fp)
373 373
374 kstat_cpu(0).irqs[SYS_IRQS + irq]++; 374 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
375 375
376 custom.intreq = amiga_intena_vals[irq]; 376 amiga_custom.intreq = amiga_intena_vals[irq];
377 377
378 for (node = ami_irq_list[irq]; node; node = node->next) 378 for (node = ami_irq_list[irq]; node; node = node->next)
379 node->handler(irq, node->dev_id, fp); 379 node->handler(irq, node->dev_id, fp);
@@ -385,23 +385,23 @@ void amiga_do_irq_list(int irq, struct pt_regs *fp)
385 385
386static irqreturn_t ami_int1(int irq, void *dev_id, struct pt_regs *fp) 386static irqreturn_t ami_int1(int irq, void *dev_id, struct pt_regs *fp)
387{ 387{
388 unsigned short ints = custom.intreqr & custom.intenar; 388 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
389 389
390 /* if serial transmit buffer empty, interrupt */ 390 /* if serial transmit buffer empty, interrupt */
391 if (ints & IF_TBE) { 391 if (ints & IF_TBE) {
392 custom.intreq = IF_TBE; 392 amiga_custom.intreq = IF_TBE;
393 amiga_do_irq(IRQ_AMIGA_TBE, fp); 393 amiga_do_irq(IRQ_AMIGA_TBE, fp);
394 } 394 }
395 395
396 /* if floppy disk transfer complete, interrupt */ 396 /* if floppy disk transfer complete, interrupt */
397 if (ints & IF_DSKBLK) { 397 if (ints & IF_DSKBLK) {
398 custom.intreq = IF_DSKBLK; 398 amiga_custom.intreq = IF_DSKBLK;
399 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp); 399 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp);
400 } 400 }
401 401
402 /* if software interrupt set, interrupt */ 402 /* if software interrupt set, interrupt */
403 if (ints & IF_SOFT) { 403 if (ints & IF_SOFT) {
404 custom.intreq = IF_SOFT; 404 amiga_custom.intreq = IF_SOFT;
405 amiga_do_irq(IRQ_AMIGA_SOFT, fp); 405 amiga_do_irq(IRQ_AMIGA_SOFT, fp);
406 } 406 }
407 return IRQ_HANDLED; 407 return IRQ_HANDLED;
@@ -409,17 +409,17 @@ static irqreturn_t ami_int1(int irq, void *dev_id, struct pt_regs *fp)
409 409
410static irqreturn_t ami_int3(int irq, void *dev_id, struct pt_regs *fp) 410static irqreturn_t ami_int3(int irq, void *dev_id, struct pt_regs *fp)
411{ 411{
412 unsigned short ints = custom.intreqr & custom.intenar; 412 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
413 413
414 /* if a blitter interrupt */ 414 /* if a blitter interrupt */
415 if (ints & IF_BLIT) { 415 if (ints & IF_BLIT) {
416 custom.intreq = IF_BLIT; 416 amiga_custom.intreq = IF_BLIT;
417 amiga_do_irq(IRQ_AMIGA_BLIT, fp); 417 amiga_do_irq(IRQ_AMIGA_BLIT, fp);
418 } 418 }
419 419
420 /* if a copper interrupt */ 420 /* if a copper interrupt */
421 if (ints & IF_COPER) { 421 if (ints & IF_COPER) {
422 custom.intreq = IF_COPER; 422 amiga_custom.intreq = IF_COPER;
423 amiga_do_irq(IRQ_AMIGA_COPPER, fp); 423 amiga_do_irq(IRQ_AMIGA_COPPER, fp);
424 } 424 }
425 425
@@ -431,29 +431,29 @@ static irqreturn_t ami_int3(int irq, void *dev_id, struct pt_regs *fp)
431 431
432static irqreturn_t ami_int4(int irq, void *dev_id, struct pt_regs *fp) 432static irqreturn_t ami_int4(int irq, void *dev_id, struct pt_regs *fp)
433{ 433{
434 unsigned short ints = custom.intreqr & custom.intenar; 434 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
435 435
436 /* if audio 0 interrupt */ 436 /* if audio 0 interrupt */
437 if (ints & IF_AUD0) { 437 if (ints & IF_AUD0) {
438 custom.intreq = IF_AUD0; 438 amiga_custom.intreq = IF_AUD0;
439 amiga_do_irq(IRQ_AMIGA_AUD0, fp); 439 amiga_do_irq(IRQ_AMIGA_AUD0, fp);
440 } 440 }
441 441
442 /* if audio 1 interrupt */ 442 /* if audio 1 interrupt */
443 if (ints & IF_AUD1) { 443 if (ints & IF_AUD1) {
444 custom.intreq = IF_AUD1; 444 amiga_custom.intreq = IF_AUD1;
445 amiga_do_irq(IRQ_AMIGA_AUD1, fp); 445 amiga_do_irq(IRQ_AMIGA_AUD1, fp);
446 } 446 }
447 447
448 /* if audio 2 interrupt */ 448 /* if audio 2 interrupt */
449 if (ints & IF_AUD2) { 449 if (ints & IF_AUD2) {
450 custom.intreq = IF_AUD2; 450 amiga_custom.intreq = IF_AUD2;
451 amiga_do_irq(IRQ_AMIGA_AUD2, fp); 451 amiga_do_irq(IRQ_AMIGA_AUD2, fp);
452 } 452 }
453 453
454 /* if audio 3 interrupt */ 454 /* if audio 3 interrupt */
455 if (ints & IF_AUD3) { 455 if (ints & IF_AUD3) {
456 custom.intreq = IF_AUD3; 456 amiga_custom.intreq = IF_AUD3;
457 amiga_do_irq(IRQ_AMIGA_AUD3, fp); 457 amiga_do_irq(IRQ_AMIGA_AUD3, fp);
458 } 458 }
459 return IRQ_HANDLED; 459 return IRQ_HANDLED;
@@ -461,7 +461,7 @@ static irqreturn_t ami_int4(int irq, void *dev_id, struct pt_regs *fp)
461 461
462static irqreturn_t ami_int5(int irq, void *dev_id, struct pt_regs *fp) 462static irqreturn_t ami_int5(int irq, void *dev_id, struct pt_regs *fp)
463{ 463{
464 unsigned short ints = custom.intreqr & custom.intenar; 464 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
465 465
466 /* if serial receive buffer full interrupt */ 466 /* if serial receive buffer full interrupt */
467 if (ints & IF_RBF) { 467 if (ints & IF_RBF) {
@@ -471,7 +471,7 @@ static irqreturn_t ami_int5(int irq, void *dev_id, struct pt_regs *fp)
471 471
472 /* if a disk sync interrupt */ 472 /* if a disk sync interrupt */
473 if (ints & IF_DSKSYN) { 473 if (ints & IF_DSKSYN) {
474 custom.intreq = IF_DSKSYN; 474 amiga_custom.intreq = IF_DSKSYN;
475 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp); 475 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp);
476 } 476 }
477 return IRQ_HANDLED; 477 return IRQ_HANDLED;
diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c
index bd5d134e9f12..ae94db5d93b2 100644
--- a/arch/m68k/amiga/amisound.c
+++ b/arch/m68k/amiga/amisound.c
@@ -24,6 +24,8 @@ static const signed char sine_data[] = {
24}; 24};
25#define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0])) 25#define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0]))
26 26
27#define custom amiga_custom
28
27 /* 29 /*
28 * The minimum period for audio may be modified by the frame buffer 30 * The minimum period for audio may be modified by the frame buffer
29 * device since it depends on htotal (for OCS/ECS/AGA) 31 * device since it depends on htotal (for OCS/ECS/AGA)
diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c
index 7d55682615e3..9476eb9440f5 100644
--- a/arch/m68k/amiga/cia.c
+++ b/arch/m68k/amiga/cia.c
@@ -60,7 +60,7 @@ unsigned char cia_set_irq(struct ciabase *base, unsigned char mask)
60 else 60 else
61 base->icr_data &= ~mask; 61 base->icr_data &= ~mask;
62 if (base->icr_data & base->icr_mask) 62 if (base->icr_data & base->icr_mask)
63 custom.intreq = IF_SETCLR | base->int_mask; 63 amiga_custom.intreq = IF_SETCLR | base->int_mask;
64 return old & base->icr_mask; 64 return old & base->icr_mask;
65} 65}
66 66
@@ -89,7 +89,7 @@ unsigned char cia_able_irq(struct ciabase *base, unsigned char mask)
89 } 89 }
90 } 90 }
91 if (base->icr_data & base->icr_mask) 91 if (base->icr_data & base->icr_mask)
92 custom.intreq = IF_SETCLR | base->int_mask; 92 amiga_custom.intreq = IF_SETCLR | base->int_mask;
93 return old; 93 return old;
94} 94}
95 95
@@ -133,7 +133,7 @@ static irqreturn_t cia_handler(int irq, void *dev_id, struct pt_regs *fp)
133 mach_irq = base->cia_irq; 133 mach_irq = base->cia_irq;
134 irq = SYS_IRQS + mach_irq; 134 irq = SYS_IRQS + mach_irq;
135 ints = cia_set_irq(base, CIA_ICR_ALL); 135 ints = cia_set_irq(base, CIA_ICR_ALL);
136 custom.intreq = base->int_mask; 136 amiga_custom.intreq = base->int_mask;
137 for (i = 0; i < CIA_IRQS; i++, irq++, mach_irq++) { 137 for (i = 0; i < CIA_IRQS; i++, irq++, mach_irq++) {
138 if (ints & 1) { 138 if (ints & 1) {
139 kstat_cpu(0).irqs[irq]++; 139 kstat_cpu(0).irqs[irq]++;
@@ -162,7 +162,7 @@ void __init cia_init_IRQ(struct ciabase *base)
162 /* install CIA handler */ 162 /* install CIA handler */
163 request_irq(base->handler_irq, cia_handler, 0, base->name, base); 163 request_irq(base->handler_irq, cia_handler, 0, base->name, base);
164 164
165 custom.intena = IF_SETCLR | base->int_mask; 165 amiga_custom.intena = IF_SETCLR | base->int_mask;
166} 166}
167 167
168int cia_get_irq_list(struct ciabase *base, struct seq_file *p) 168int cia_get_irq_list(struct ciabase *base, struct seq_file *p)
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 4775e18a78f0..12e3706fe02c 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -105,9 +105,6 @@ static int a2000_hwclk (int, struct rtc_time *);
105static int amiga_set_clock_mmss (unsigned long); 105static int amiga_set_clock_mmss (unsigned long);
106static unsigned int amiga_get_ss (void); 106static unsigned int amiga_get_ss (void);
107extern void amiga_mksound( unsigned int count, unsigned int ticks ); 107extern void amiga_mksound( unsigned int count, unsigned int ticks );
108#ifdef CONFIG_AMIGA_FLOPPY
109extern void amiga_floppy_setup(char *, int *);
110#endif
111static void amiga_reset (void); 108static void amiga_reset (void);
112extern void amiga_init_sound(void); 109extern void amiga_init_sound(void);
113static void amiga_savekmsg_init(void); 110static void amiga_savekmsg_init(void);
@@ -290,7 +287,7 @@ static void __init amiga_identify(void)
290 case CS_OCS: 287 case CS_OCS:
291 case CS_ECS: 288 case CS_ECS:
292 case CS_AGA: 289 case CS_AGA:
293 switch (custom.deniseid & 0xf) { 290 switch (amiga_custom.deniseid & 0xf) {
294 case 0x0c: 291 case 0x0c:
295 AMIGAHW_SET(DENISE_HR); 292 AMIGAHW_SET(DENISE_HR);
296 break; 293 break;
@@ -303,7 +300,7 @@ static void __init amiga_identify(void)
303 AMIGAHW_SET(DENISE); 300 AMIGAHW_SET(DENISE);
304 break; 301 break;
305 } 302 }
306 switch ((custom.vposr>>8) & 0x7f) { 303 switch ((amiga_custom.vposr>>8) & 0x7f) {
307 case 0x00: 304 case 0x00:
308 AMIGAHW_SET(AGNUS_PAL); 305 AMIGAHW_SET(AGNUS_PAL);
309 break; 306 break;
@@ -427,13 +424,7 @@ void __init config_amiga(void)
427 424
428 mach_set_clock_mmss = amiga_set_clock_mmss; 425 mach_set_clock_mmss = amiga_set_clock_mmss;
429 mach_get_ss = amiga_get_ss; 426 mach_get_ss = amiga_get_ss;
430#ifdef CONFIG_AMIGA_FLOPPY
431 mach_floppy_setup = amiga_floppy_setup;
432#endif
433 mach_reset = amiga_reset; 427 mach_reset = amiga_reset;
434#ifdef CONFIG_DUMMY_CONSOLE
435 conswitchp = &dummy_con;
436#endif
437#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 428#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
438 mach_beep = amiga_mksound; 429 mach_beep = amiga_mksound;
439#endif 430#endif
@@ -447,9 +438,9 @@ void __init config_amiga(void)
447 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ 438 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
448 439
449 /* clear all DMA bits */ 440 /* clear all DMA bits */
450 custom.dmacon = DMAF_ALL; 441 amiga_custom.dmacon = DMAF_ALL;
451 /* ensure that the DMA master bit is set */ 442 /* ensure that the DMA master bit is set */
452 custom.dmacon = DMAF_SETCLR | DMAF_MASTER; 443 amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
453 444
454 /* don't use Z2 RAM as system memory on Z3 capable machines */ 445 /* don't use Z2 RAM as system memory on Z3 capable machines */
455 if (AMIGAHW_PRESENT(ZORRO3)) { 446 if (AMIGAHW_PRESENT(ZORRO3)) {
@@ -830,8 +821,8 @@ static void amiga_savekmsg_init(void)
830 821
831static void amiga_serial_putc(char c) 822static void amiga_serial_putc(char c)
832{ 823{
833 custom.serdat = (unsigned char)c | 0x100; 824 amiga_custom.serdat = (unsigned char)c | 0x100;
834 while (!(custom.serdatr & 0x2000)) 825 while (!(amiga_custom.serdatr & 0x2000))
835 ; 826 ;
836} 827}
837 828
@@ -855,11 +846,11 @@ int amiga_serial_console_wait_key(struct console *co)
855{ 846{
856 int ch; 847 int ch;
857 848
858 while (!(custom.intreqr & IF_RBF)) 849 while (!(amiga_custom.intreqr & IF_RBF))
859 barrier(); 850 barrier();
860 ch = custom.serdatr & 0xff; 851 ch = amiga_custom.serdatr & 0xff;
861 /* clear the interrupt, so that another character can be read */ 852 /* clear the interrupt, so that another character can be read */
862 custom.intreq = IF_RBF; 853 amiga_custom.intreq = IF_RBF;
863 return ch; 854 return ch;
864} 855}
865 856
diff --git a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c
index 264929471253..d401962d9b25 100644
--- a/arch/m68k/apollo/config.c
+++ b/arch/m68k/apollo/config.c
@@ -176,9 +176,6 @@ void config_apollo(void) {
176 mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */ 176 mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
177 mach_process_int = dn_process_int; 177 mach_process_int = dn_process_int;
178 mach_reset = dn_dummy_reset; /* */ 178 mach_reset = dn_dummy_reset; /* */
179#ifdef CONFIG_DUMMY_CONSOLE
180 conswitchp = &dummy_con;
181#endif
182#ifdef CONFIG_HEARTBEAT 179#ifdef CONFIG_HEARTBEAT
183 mach_heartbeat = dn_heartbeat; 180 mach_heartbeat = dn_heartbeat;
184#endif 181#endif
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 9261d2deeaf5..1012b08e5522 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -52,9 +52,6 @@ int atari_rtc_year_offset;
52 52
53/* local function prototypes */ 53/* local function prototypes */
54static void atari_reset( void ); 54static void atari_reset( void );
55#ifdef CONFIG_ATARI_FLOPPY
56extern void atari_floppy_setup(char *, int *);
57#endif
58static void atari_get_model(char *model); 55static void atari_get_model(char *model);
59static int atari_get_hardware_list(char *buffer); 56static int atari_get_hardware_list(char *buffer);
60 57
@@ -244,12 +241,6 @@ void __init config_atari(void)
244 mach_get_irq_list = show_atari_interrupts; 241 mach_get_irq_list = show_atari_interrupts;
245 mach_gettimeoffset = atari_gettimeoffset; 242 mach_gettimeoffset = atari_gettimeoffset;
246 mach_reset = atari_reset; 243 mach_reset = atari_reset;
247#ifdef CONFIG_ATARI_FLOPPY
248 mach_floppy_setup = atari_floppy_setup;
249#endif
250#ifdef CONFIG_DUMMY_CONSOLE
251 conswitchp = &dummy_con;
252#endif
253 mach_max_dma_address = 0xffffff; 244 mach_max_dma_address = 0xffffff;
254#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 245#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
255 mach_beep = atari_mksound; 246 mach_beep = atari_mksound;
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index eb63ca6ed94c..703cbc6dc9cc 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -11,6 +11,7 @@
11#include <linux/miscdevice.h> 11#include <linux/miscdevice.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/ioport.h> 13#include <linux/ioport.h>
14#include <linux/capability.h>
14#include <linux/fcntl.h> 15#include <linux/fcntl.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/poll.h> 17#include <linux/poll.h>
@@ -46,6 +47,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
46 unsigned char msr; 47 unsigned char msr;
47 unsigned long flags; 48 unsigned long flags;
48 struct rtc_time wtime; 49 struct rtc_time wtime;
50 void __user *argp = (void __user *)arg;
49 51
50 switch (cmd) { 52 switch (cmd) {
51 case RTC_RD_TIME: /* Read the time/date from RTC */ 53 case RTC_RD_TIME: /* Read the time/date from RTC */
@@ -68,7 +70,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
68 } while (wtime.tm_sec != BCD2BIN(rtc->bcd_sec)); 70 } while (wtime.tm_sec != BCD2BIN(rtc->bcd_sec));
69 rtc->msr = msr; 71 rtc->msr = msr;
70 local_irq_restore(flags); 72 local_irq_restore(flags);
71 return copy_to_user((void *)arg, &wtime, sizeof wtime) ? 73 return copy_to_user(argp, &wtime, sizeof wtime) ?
72 -EFAULT : 0; 74 -EFAULT : 0;
73 } 75 }
74 case RTC_SET_TIME: /* Set the RTC */ 76 case RTC_SET_TIME: /* Set the RTC */
@@ -80,8 +82,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
80 if (!capable(CAP_SYS_ADMIN)) 82 if (!capable(CAP_SYS_ADMIN))
81 return -EACCES; 83 return -EACCES;
82 84
83 if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, 85 if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time)))
84 sizeof(struct rtc_time)))
85 return -EFAULT; 86 return -EFAULT;
86 87
87 yrs = rtc_tm.tm_year; 88 yrs = rtc_tm.tm_year;
diff --git a/arch/m68k/hp300/config.c b/arch/m68k/hp300/config.c
index a0b854f3f94a..6d129eef370f 100644
--- a/arch/m68k/hp300/config.c
+++ b/arch/m68k/hp300/config.c
@@ -261,9 +261,6 @@ void __init config_hp300(void)
261#ifdef CONFIG_HEARTBEAT 261#ifdef CONFIG_HEARTBEAT
262 mach_heartbeat = hp300_pulse; 262 mach_heartbeat = hp300_pulse;
263#endif 263#endif
264#ifdef CONFIG_DUMMY_CONSOLE
265 conswitchp = &dummy_con;
266#endif
267 mach_max_dma_address = 0xffffffff; 264 mach_max_dma_address = 0xffffffff;
268 265
269 if (hp300_model >= HP_330 && hp300_model <= HP_433S && hp300_model != HP_350) { 266 if (hp300_model >= HP_330 && hp300_model <= HP_433S && hp300_model != HP_350) {
diff --git a/arch/m68k/kernel/asm-offsets.c b/arch/m68k/kernel/asm-offsets.c
index c787c5ba9513..246a8820c223 100644
--- a/arch/m68k/kernel/asm-offsets.c
+++ b/arch/m68k/kernel/asm-offsets.c
@@ -92,7 +92,7 @@ int main(void)
92 DEFINE(TRAP_TRACE, TRAP_TRACE); 92 DEFINE(TRAP_TRACE, TRAP_TRACE);
93 93
94 /* offsets into the custom struct */ 94 /* offsets into the custom struct */
95 DEFINE(CUSTOMBASE, &custom); 95 DEFINE(CUSTOMBASE, &amiga_custom);
96 DEFINE(C_INTENAR, offsetof(struct CUSTOM, intenar)); 96 DEFINE(C_INTENAR, offsetof(struct CUSTOM, intenar));
97 DEFINE(C_INTREQR, offsetof(struct CUSTOM, intreqr)); 97 DEFINE(C_INTREQR, offsetof(struct CUSTOM, intreqr));
98 DEFINE(C_INTENA, offsetof(struct CUSTOM, intena)); 98 DEFINE(C_INTENA, offsetof(struct CUSTOM, intena));
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index d4336d846df1..70002c146eed 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -273,8 +273,10 @@
273 * Macintosh console support 273 * Macintosh console support
274 */ 274 */
275 275
276#ifdef CONFIG_FRAMEBUFFER_CONSOLE
276#define CONSOLE 277#define CONSOLE
277#define CONSOLE_PENGUIN 278#define CONSOLE_PENGUIN
279#endif
278 280
279/* 281/*
280 * Macintosh serial debug support; outputs boot info to the printer 282 * Macintosh serial debug support; outputs boot info to the printer
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index 73e2f5e168dd..3d7f2000b714 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -23,8 +23,6 @@ asmlinkage long long __lshrdi3 (long long, int);
23asmlinkage long long __muldi3 (long long, long long); 23asmlinkage long long __muldi3 (long long, long long);
24extern char m68k_debug_device[]; 24extern char m68k_debug_device[];
25 25
26extern void dump_thread(struct pt_regs *, struct user *);
27
28/* platform dependent support */ 26/* platform dependent support */
29 27
30EXPORT_SYMBOL(m68k_machtype); 28EXPORT_SYMBOL(m68k_machtype);
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 13d109328a42..3f9cb55d0356 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -238,10 +238,9 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
238{ 238{
239 struct pt_regs * childregs; 239 struct pt_regs * childregs;
240 struct switch_stack * childstack, *stack; 240 struct switch_stack * childstack, *stack;
241 unsigned long stack_offset, *retp; 241 unsigned long *retp;
242 242
243 stack_offset = THREAD_SIZE - sizeof(struct pt_regs); 243 childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1;
244 childregs = (struct pt_regs *) ((unsigned long) (p->thread_info) + stack_offset);
245 244
246 *childregs = *regs; 245 *childregs = *regs;
247 childregs->d0 = 0; 246 childregs->d0 = 0;
@@ -386,7 +385,7 @@ unsigned long get_wchan(struct task_struct *p)
386 if (!p || p == current || p->state == TASK_RUNNING) 385 if (!p || p == current || p->state == TASK_RUNNING)
387 return 0; 386 return 0;
388 387
389 stack_page = (unsigned long)(p->thread_info); 388 stack_page = (unsigned long)task_stack_page(p);
390 fp = ((struct switch_stack *)p->thread.ksp)->a6; 389 fp = ((struct switch_stack *)p->thread.ksp)->a6;
391 do { 390 do {
392 if (fp < stack_page+sizeof(struct thread_info) || 391 if (fp < stack_page+sizeof(struct thread_info) ||
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index d6ca99242e5a..750d5b3c971f 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -84,9 +84,6 @@ void (*mach_reset)( void );
84void (*mach_halt)( void ); 84void (*mach_halt)( void );
85void (*mach_power_off)( void ); 85void (*mach_power_off)( void );
86long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */ 86long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
87#if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
88void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
89#endif
90#ifdef CONFIG_HEARTBEAT 87#ifdef CONFIG_HEARTBEAT
91void (*mach_heartbeat) (int); 88void (*mach_heartbeat) (int);
92EXPORT_SYMBOL(mach_heartbeat); 89EXPORT_SYMBOL(mach_heartbeat);
@@ -100,6 +97,8 @@ void (*mach_beep)(unsigned int, unsigned int);
100#if defined(CONFIG_ISA) && defined(MULTI_ISA) 97#if defined(CONFIG_ISA) && defined(MULTI_ISA)
101int isa_type; 98int isa_type;
102int isa_sex; 99int isa_sex;
100EXPORT_SYMBOL(isa_type);
101EXPORT_SYMBOL(isa_sex);
103#endif 102#endif
104 103
105extern int amiga_parse_bootinfo(const struct bi_record *); 104extern int amiga_parse_bootinfo(const struct bi_record *);
@@ -280,6 +279,10 @@ void __init setup_arch(char **cmdline_p)
280 } 279 }
281 } 280 }
282 281
282#ifdef CONFIG_DUMMY_CONSOLE
283 conswitchp = &dummy_con;
284#endif
285
283 switch (m68k_machtype) { 286 switch (m68k_machtype) {
284#ifdef CONFIG_AMIGA 287#ifdef CONFIG_AMIGA
285 case MACH_AMIGA: 288 case MACH_AMIGA:
@@ -521,16 +524,6 @@ int get_hardware_list(char *buffer)
521 return(len); 524 return(len);
522} 525}
523 526
524
525#if defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
526void __init floppy_setup(char *str, int *ints)
527{
528 if (mach_floppy_setup)
529 mach_floppy_setup (str, ints);
530}
531
532#endif
533
534void check_bugs(void) 527void check_bugs(void)
535{ 528{
536#ifndef CONFIG_M68KFPU_EMU 529#ifndef CONFIG_M68KFPU_EMU
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
index 9c636a4c238d..866917bfa028 100644
--- a/arch/m68k/kernel/signal.c
+++ b/arch/m68k/kernel/signal.c
@@ -96,7 +96,7 @@ asmlinkage int do_sigsuspend(struct pt_regs *regs)
96asmlinkage int 96asmlinkage int
97do_rt_sigsuspend(struct pt_regs *regs) 97do_rt_sigsuspend(struct pt_regs *regs)
98{ 98{
99 sigset_t *unewset = (sigset_t *)regs->d1; 99 sigset_t __user *unewset = (sigset_t __user *)regs->d1;
100 size_t sigsetsize = (size_t)regs->d2; 100 size_t sigsetsize = (size_t)regs->d2;
101 sigset_t saveset, newset; 101 sigset_t saveset, newset;
102 102
@@ -122,8 +122,8 @@ do_rt_sigsuspend(struct pt_regs *regs)
122} 122}
123 123
124asmlinkage int 124asmlinkage int
125sys_sigaction(int sig, const struct old_sigaction *act, 125sys_sigaction(int sig, const struct old_sigaction __user *act,
126 struct old_sigaction *oact) 126 struct old_sigaction __user *oact)
127{ 127{
128 struct k_sigaction new_ka, old_ka; 128 struct k_sigaction new_ka, old_ka;
129 int ret; 129 int ret;
@@ -154,7 +154,7 @@ sys_sigaction(int sig, const struct old_sigaction *act,
154} 154}
155 155
156asmlinkage int 156asmlinkage int
157sys_sigaltstack(const stack_t *uss, stack_t *uoss) 157sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
158{ 158{
159 return do_sigaltstack(uss, uoss, rdusp()); 159 return do_sigaltstack(uss, uoss, rdusp());
160} 160}
@@ -169,10 +169,10 @@ sys_sigaltstack(const stack_t *uss, stack_t *uoss)
169 169
170struct sigframe 170struct sigframe
171{ 171{
172 char *pretcode; 172 char __user *pretcode;
173 int sig; 173 int sig;
174 int code; 174 int code;
175 struct sigcontext *psc; 175 struct sigcontext __user *psc;
176 char retcode[8]; 176 char retcode[8];
177 unsigned long extramask[_NSIG_WORDS-1]; 177 unsigned long extramask[_NSIG_WORDS-1];
178 struct sigcontext sc; 178 struct sigcontext sc;
@@ -180,10 +180,10 @@ struct sigframe
180 180
181struct rt_sigframe 181struct rt_sigframe
182{ 182{
183 char *pretcode; 183 char __user *pretcode;
184 int sig; 184 int sig;
185 struct siginfo *pinfo; 185 struct siginfo __user *pinfo;
186 void *puc; 186 void __user *puc;
187 char retcode[8]; 187 char retcode[8];
188 struct siginfo info; 188 struct siginfo info;
189 struct ucontext uc; 189 struct ucontext uc;
@@ -248,7 +248,7 @@ out:
248#define uc_formatvec uc_filler[FPCONTEXT_SIZE/4] 248#define uc_formatvec uc_filler[FPCONTEXT_SIZE/4]
249#define uc_extra uc_filler[FPCONTEXT_SIZE/4+1] 249#define uc_extra uc_filler[FPCONTEXT_SIZE/4+1]
250 250
251static inline int rt_restore_fpu_state(struct ucontext *uc) 251static inline int rt_restore_fpu_state(struct ucontext __user *uc)
252{ 252{
253 unsigned char fpstate[FPCONTEXT_SIZE]; 253 unsigned char fpstate[FPCONTEXT_SIZE];
254 int context_size = CPU_IS_060 ? 8 : 0; 254 int context_size = CPU_IS_060 ? 8 : 0;
@@ -267,7 +267,7 @@ static inline int rt_restore_fpu_state(struct ucontext *uc)
267 return 0; 267 return 0;
268 } 268 }
269 269
270 if (__get_user(*(long *)fpstate, (long *)&uc->uc_fpstate)) 270 if (__get_user(*(long *)fpstate, (long __user *)&uc->uc_fpstate))
271 goto out; 271 goto out;
272 if (CPU_IS_060 ? fpstate[2] : fpstate[0]) { 272 if (CPU_IS_060 ? fpstate[2] : fpstate[0]) {
273 if (!CPU_IS_060) 273 if (!CPU_IS_060)
@@ -306,7 +306,7 @@ static inline int rt_restore_fpu_state(struct ucontext *uc)
306 "m" (*fpregs.f_fpcntl)); 306 "m" (*fpregs.f_fpcntl));
307 } 307 }
308 if (context_size && 308 if (context_size &&
309 __copy_from_user(fpstate + 4, (long *)&uc->uc_fpstate + 1, 309 __copy_from_user(fpstate + 4, (long __user *)&uc->uc_fpstate + 1,
310 context_size)) 310 context_size))
311 goto out; 311 goto out;
312 __asm__ volatile (".chip 68k/68881\n\t" 312 __asm__ volatile (".chip 68k/68881\n\t"
@@ -319,7 +319,7 @@ out:
319} 319}
320 320
321static inline int 321static inline int
322restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp, 322restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *usc, void __user *fp,
323 int *pd0) 323 int *pd0)
324{ 324{
325 int fsize, formatvec; 325 int fsize, formatvec;
@@ -404,10 +404,10 @@ badframe:
404 404
405static inline int 405static inline int
406rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw, 406rt_restore_ucontext(struct pt_regs *regs, struct switch_stack *sw,
407 struct ucontext *uc, int *pd0) 407 struct ucontext __user *uc, int *pd0)
408{ 408{
409 int fsize, temp; 409 int fsize, temp;
410 greg_t *gregs = uc->uc_mcontext.gregs; 410 greg_t __user *gregs = uc->uc_mcontext.gregs;
411 unsigned long usp; 411 unsigned long usp;
412 int err; 412 int err;
413 413
@@ -506,7 +506,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
506 struct switch_stack *sw = (struct switch_stack *) &__unused; 506 struct switch_stack *sw = (struct switch_stack *) &__unused;
507 struct pt_regs *regs = (struct pt_regs *) (sw + 1); 507 struct pt_regs *regs = (struct pt_regs *) (sw + 1);
508 unsigned long usp = rdusp(); 508 unsigned long usp = rdusp();
509 struct sigframe *frame = (struct sigframe *)(usp - 4); 509 struct sigframe __user *frame = (struct sigframe __user *)(usp - 4);
510 sigset_t set; 510 sigset_t set;
511 int d0; 511 int d0;
512 512
@@ -536,7 +536,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
536 struct switch_stack *sw = (struct switch_stack *) &__unused; 536 struct switch_stack *sw = (struct switch_stack *) &__unused;
537 struct pt_regs *regs = (struct pt_regs *) (sw + 1); 537 struct pt_regs *regs = (struct pt_regs *) (sw + 1);
538 unsigned long usp = rdusp(); 538 unsigned long usp = rdusp();
539 struct rt_sigframe *frame = (struct rt_sigframe *)(usp - 4); 539 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(usp - 4);
540 sigset_t set; 540 sigset_t set;
541 int d0; 541 int d0;
542 542
@@ -596,7 +596,7 @@ static inline void save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)
596 } 596 }
597} 597}
598 598
599static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs) 599static inline int rt_save_fpu_state(struct ucontext __user *uc, struct pt_regs *regs)
600{ 600{
601 unsigned char fpstate[FPCONTEXT_SIZE]; 601 unsigned char fpstate[FPCONTEXT_SIZE];
602 int context_size = CPU_IS_060 ? 8 : 0; 602 int context_size = CPU_IS_060 ? 8 : 0;
@@ -617,7 +617,7 @@ static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
617 ".chip 68k" 617 ".chip 68k"
618 : : "m" (*fpstate) : "memory"); 618 : : "m" (*fpstate) : "memory");
619 619
620 err |= __put_user(*(long *)fpstate, (long *)&uc->uc_fpstate); 620 err |= __put_user(*(long *)fpstate, (long __user *)&uc->uc_fpstate);
621 if (CPU_IS_060 ? fpstate[2] : fpstate[0]) { 621 if (CPU_IS_060 ? fpstate[2] : fpstate[0]) {
622 fpregset_t fpregs; 622 fpregset_t fpregs;
623 if (!CPU_IS_060) 623 if (!CPU_IS_060)
@@ -642,7 +642,7 @@ static inline int rt_save_fpu_state(struct ucontext *uc, struct pt_regs *regs)
642 sizeof(fpregs)); 642 sizeof(fpregs));
643 } 643 }
644 if (context_size) 644 if (context_size)
645 err |= copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4, 645 err |= copy_to_user((long __user *)&uc->uc_fpstate + 1, fpstate + 4,
646 context_size); 646 context_size);
647 return err; 647 return err;
648} 648}
@@ -662,10 +662,10 @@ static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
662 save_fpu_state(sc, regs); 662 save_fpu_state(sc, regs);
663} 663}
664 664
665static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs) 665static inline int rt_setup_ucontext(struct ucontext __user *uc, struct pt_regs *regs)
666{ 666{
667 struct switch_stack *sw = (struct switch_stack *)regs - 1; 667 struct switch_stack *sw = (struct switch_stack *)regs - 1;
668 greg_t *gregs = uc->uc_mcontext.gregs; 668 greg_t __user *gregs = uc->uc_mcontext.gregs;
669 int err = 0; 669 int err = 0;
670 670
671 err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version); 671 err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);
@@ -753,7 +753,7 @@ static inline void push_cache (unsigned long vaddr)
753 } 753 }
754} 754}
755 755
756static inline void * 756static inline void __user *
757get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) 757get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
758{ 758{
759 unsigned long usp; 759 unsigned long usp;
@@ -766,13 +766,13 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
766 if (!on_sig_stack(usp)) 766 if (!on_sig_stack(usp))
767 usp = current->sas_ss_sp + current->sas_ss_size; 767 usp = current->sas_ss_sp + current->sas_ss_size;
768 } 768 }
769 return (void *)((usp - frame_size) & -8UL); 769 return (void __user *)((usp - frame_size) & -8UL);
770} 770}
771 771
772static void setup_frame (int sig, struct k_sigaction *ka, 772static void setup_frame (int sig, struct k_sigaction *ka,
773 sigset_t *set, struct pt_regs *regs) 773 sigset_t *set, struct pt_regs *regs)
774{ 774{
775 struct sigframe *frame; 775 struct sigframe __user *frame;
776 int fsize = frame_extra_sizes[regs->format]; 776 int fsize = frame_extra_sizes[regs->format];
777 struct sigcontext context; 777 struct sigcontext context;
778 int err = 0; 778 int err = 0;
@@ -813,7 +813,7 @@ static void setup_frame (int sig, struct k_sigaction *ka,
813 err |= __put_user(frame->retcode, &frame->pretcode); 813 err |= __put_user(frame->retcode, &frame->pretcode);
814 /* moveq #,d0; trap #0 */ 814 /* moveq #,d0; trap #0 */
815 err |= __put_user(0x70004e40 + (__NR_sigreturn << 16), 815 err |= __put_user(0x70004e40 + (__NR_sigreturn << 16),
816 (long *)(frame->retcode)); 816 (long __user *)(frame->retcode));
817 817
818 if (err) 818 if (err)
819 goto give_sigsegv; 819 goto give_sigsegv;
@@ -849,7 +849,7 @@ give_sigsegv:
849static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, 849static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
850 sigset_t *set, struct pt_regs *regs) 850 sigset_t *set, struct pt_regs *regs)
851{ 851{
852 struct rt_sigframe *frame; 852 struct rt_sigframe __user *frame;
853 int fsize = frame_extra_sizes[regs->format]; 853 int fsize = frame_extra_sizes[regs->format];
854 int err = 0; 854 int err = 0;
855 855
@@ -880,8 +880,8 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
880 880
881 /* Create the ucontext. */ 881 /* Create the ucontext. */
882 err |= __put_user(0, &frame->uc.uc_flags); 882 err |= __put_user(0, &frame->uc.uc_flags);
883 err |= __put_user(0, &frame->uc.uc_link); 883 err |= __put_user(NULL, &frame->uc.uc_link);
884 err |= __put_user((void *)current->sas_ss_sp, 884 err |= __put_user((void __user *)current->sas_ss_sp,
885 &frame->uc.uc_stack.ss_sp); 885 &frame->uc.uc_stack.ss_sp);
886 err |= __put_user(sas_ss_flags(rdusp()), 886 err |= __put_user(sas_ss_flags(rdusp()),
887 &frame->uc.uc_stack.ss_flags); 887 &frame->uc.uc_stack.ss_flags);
@@ -893,8 +893,8 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
893 err |= __put_user(frame->retcode, &frame->pretcode); 893 err |= __put_user(frame->retcode, &frame->pretcode);
894 /* moveq #,d0; notb d0; trap #0 */ 894 /* moveq #,d0; notb d0; trap #0 */
895 err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16), 895 err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16),
896 (long *)(frame->retcode + 0)); 896 (long __user *)(frame->retcode + 0));
897 err |= __put_user(0x4e40, (short *)(frame->retcode + 4)); 897 err |= __put_user(0x4e40, (short __user *)(frame->retcode + 4));
898 898
899 if (err) 899 if (err)
900 goto give_sigsegv; 900 goto give_sigsegv;
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 2ed7b783f654..143c552d38f3 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -6,6 +6,7 @@
6 * platform. 6 * platform.
7 */ 7 */
8 8
9#include <linux/capability.h>
9#include <linux/errno.h> 10#include <linux/errno.h>
10#include <linux/sched.h> 11#include <linux/sched.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
@@ -31,7 +32,7 @@
31 * sys_pipe() is the normal C calling standard for creating 32 * sys_pipe() is the normal C calling standard for creating
32 * a pipe. It's not the way unix traditionally does this, though. 33 * a pipe. It's not the way unix traditionally does this, though.
33 */ 34 */
34asmlinkage int sys_pipe(unsigned long * fildes) 35asmlinkage int sys_pipe(unsigned long __user * fildes)
35{ 36{
36 int fd[2]; 37 int fd[2];
37 int error; 38 int error;
@@ -93,7 +94,7 @@ struct mmap_arg_struct {
93 unsigned long offset; 94 unsigned long offset;
94}; 95};
95 96
96asmlinkage int old_mmap(struct mmap_arg_struct *arg) 97asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
97{ 98{
98 struct mmap_arg_struct a; 99 struct mmap_arg_struct a;
99 int error = -EFAULT; 100 int error = -EFAULT;
@@ -159,11 +160,11 @@ out:
159 160
160struct sel_arg_struct { 161struct sel_arg_struct {
161 unsigned long n; 162 unsigned long n;
162 fd_set *inp, *outp, *exp; 163 fd_set __user *inp, *outp, *exp;
163 struct timeval *tvp; 164 struct timeval __user *tvp;
164}; 165};
165 166
166asmlinkage int old_select(struct sel_arg_struct *arg) 167asmlinkage int old_select(struct sel_arg_struct __user *arg)
167{ 168{
168 struct sel_arg_struct a; 169 struct sel_arg_struct a;
169 170
@@ -179,7 +180,7 @@ asmlinkage int old_select(struct sel_arg_struct *arg)
179 * This is really horribly ugly. 180 * This is really horribly ugly.
180 */ 181 */
181asmlinkage int sys_ipc (uint call, int first, int second, 182asmlinkage int sys_ipc (uint call, int first, int second,
182 int third, void *ptr, long fifth) 183 int third, void __user *ptr, long fifth)
183{ 184{
184 int version, ret; 185 int version, ret;
185 186
@@ -189,14 +190,14 @@ asmlinkage int sys_ipc (uint call, int first, int second,
189 if (call <= SEMCTL) 190 if (call <= SEMCTL)
190 switch (call) { 191 switch (call) {
191 case SEMOP: 192 case SEMOP:
192 return sys_semop (first, (struct sembuf *)ptr, second); 193 return sys_semop (first, ptr, second);
193 case SEMGET: 194 case SEMGET:
194 return sys_semget (first, second, third); 195 return sys_semget (first, second, third);
195 case SEMCTL: { 196 case SEMCTL: {
196 union semun fourth; 197 union semun fourth;
197 if (!ptr) 198 if (!ptr)
198 return -EINVAL; 199 return -EINVAL;
199 if (get_user(fourth.__pad, (void **) ptr)) 200 if (get_user(fourth.__pad, (void __user *__user *) ptr))
200 return -EFAULT; 201 return -EFAULT;
201 return sys_semctl (first, second, third, fourth); 202 return sys_semctl (first, second, third, fourth);
202 } 203 }
@@ -206,31 +207,26 @@ asmlinkage int sys_ipc (uint call, int first, int second,
206 if (call <= MSGCTL) 207 if (call <= MSGCTL)
207 switch (call) { 208 switch (call) {
208 case MSGSND: 209 case MSGSND:
209 return sys_msgsnd (first, (struct msgbuf *) ptr, 210 return sys_msgsnd (first, ptr, second, third);
210 second, third);
211 case MSGRCV: 211 case MSGRCV:
212 switch (version) { 212 switch (version) {
213 case 0: { 213 case 0: {
214 struct ipc_kludge tmp; 214 struct ipc_kludge tmp;
215 if (!ptr) 215 if (!ptr)
216 return -EINVAL; 216 return -EINVAL;
217 if (copy_from_user (&tmp, 217 if (copy_from_user (&tmp, ptr, sizeof (tmp)))
218 (struct ipc_kludge *)ptr,
219 sizeof (tmp)))
220 return -EFAULT; 218 return -EFAULT;
221 return sys_msgrcv (first, tmp.msgp, second, 219 return sys_msgrcv (first, tmp.msgp, second,
222 tmp.msgtyp, third); 220 tmp.msgtyp, third);
223 } 221 }
224 default: 222 default:
225 return sys_msgrcv (first, 223 return sys_msgrcv (first, ptr,
226 (struct msgbuf *) ptr,
227 second, fifth, third); 224 second, fifth, third);
228 } 225 }
229 case MSGGET: 226 case MSGGET:
230 return sys_msgget ((key_t) first, second); 227 return sys_msgget ((key_t) first, second);
231 case MSGCTL: 228 case MSGCTL:
232 return sys_msgctl (first, second, 229 return sys_msgctl (first, second, ptr);
233 (struct msqid_ds *) ptr);
234 default: 230 default:
235 return -ENOSYS; 231 return -ENOSYS;
236 } 232 }
@@ -240,20 +236,18 @@ asmlinkage int sys_ipc (uint call, int first, int second,
240 switch (version) { 236 switch (version) {
241 default: { 237 default: {
242 ulong raddr; 238 ulong raddr;
243 ret = do_shmat (first, (char *) ptr, 239 ret = do_shmat (first, ptr, second, &raddr);
244 second, &raddr);
245 if (ret) 240 if (ret)
246 return ret; 241 return ret;
247 return put_user (raddr, (ulong *) third); 242 return put_user (raddr, (ulong __user *) third);
248 } 243 }
249 } 244 }
250 case SHMDT: 245 case SHMDT:
251 return sys_shmdt ((char *)ptr); 246 return sys_shmdt (ptr);
252 case SHMGET: 247 case SHMGET:
253 return sys_shmget (first, second, third); 248 return sys_shmget (first, second, third);
254 case SHMCTL: 249 case SHMCTL:
255 return sys_shmctl (first, second, 250 return sys_shmctl (first, second, ptr);
256 (struct shmid_ds *) ptr);
257 default: 251 default:
258 return -ENOSYS; 252 return -ENOSYS;
259 } 253 }
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c
index deb36e8b04a2..cdf58fbb3e73 100644
--- a/arch/m68k/kernel/traps.c
+++ b/arch/m68k/kernel/traps.c
@@ -169,25 +169,25 @@ void __init trap_init (void)
169 169
170 if (CPU_IS_060 && !FPU_IS_EMU) { 170 if (CPU_IS_060 && !FPU_IS_EMU) {
171 /* set up IFPSP entry points */ 171 /* set up IFPSP entry points */
172 asmlinkage void snan_vec(void) asm ("_060_fpsp_snan"); 172 asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan");
173 asmlinkage void operr_vec(void) asm ("_060_fpsp_operr"); 173 asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr");
174 asmlinkage void ovfl_vec(void) asm ("_060_fpsp_ovfl"); 174 asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl");
175 asmlinkage void unfl_vec(void) asm ("_060_fpsp_unfl"); 175 asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl");
176 asmlinkage void dz_vec(void) asm ("_060_fpsp_dz"); 176 asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz");
177 asmlinkage void inex_vec(void) asm ("_060_fpsp_inex"); 177 asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex");
178 asmlinkage void fline_vec(void) asm ("_060_fpsp_fline"); 178 asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline");
179 asmlinkage void unsupp_vec(void) asm ("_060_fpsp_unsupp"); 179 asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp");
180 asmlinkage void effadd_vec(void) asm ("_060_fpsp_effadd"); 180 asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd");
181 181
182 vectors[VEC_FPNAN] = snan_vec; 182 vectors[VEC_FPNAN] = snan_vec6;
183 vectors[VEC_FPOE] = operr_vec; 183 vectors[VEC_FPOE] = operr_vec6;
184 vectors[VEC_FPOVER] = ovfl_vec; 184 vectors[VEC_FPOVER] = ovfl_vec6;
185 vectors[VEC_FPUNDER] = unfl_vec; 185 vectors[VEC_FPUNDER] = unfl_vec6;
186 vectors[VEC_FPDIVZ] = dz_vec; 186 vectors[VEC_FPDIVZ] = dz_vec6;
187 vectors[VEC_FPIR] = inex_vec; 187 vectors[VEC_FPIR] = inex_vec6;
188 vectors[VEC_LINE11] = fline_vec; 188 vectors[VEC_LINE11] = fline_vec6;
189 vectors[VEC_FPUNSUP] = unsupp_vec; 189 vectors[VEC_FPUNSUP] = unsupp_vec6;
190 vectors[VEC_UNIMPEA] = effadd_vec; 190 vectors[VEC_UNIMPEA] = effadd_vec6;
191 } 191 }
192 192
193 /* if running on an amiga, make the NMI interrupt do nothing */ 193 /* if running on an amiga, make the NMI interrupt do nothing */
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index e58654f3f8dd..69d1d3d30c78 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -13,6 +13,7 @@ SECTIONS
13 .text : { 13 .text : {
14 *(.text) 14 *(.text)
15 SCHED_TEXT 15 SCHED_TEXT
16 LOCK_TEXT
16 *(.fixup) 17 *(.fixup)
17 *(.gnu.warning) 18 *(.gnu.warning)
18 } :text = 0x4e75 19 } :text = 0x4e75
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index cc37e8d3c1e2..65cc39c24185 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -14,6 +14,7 @@ SECTIONS
14 *(.head) 14 *(.head)
15 *(.text) 15 *(.text)
16 SCHED_TEXT 16 SCHED_TEXT
17 LOCK_TEXT
17 *(.fixup) 18 *(.fixup)
18 *(.gnu.warning) 19 *(.gnu.warning)
19 } :text = 0x4e75 20 } :text = 0x4e75
@@ -66,7 +67,7 @@ __init_begin = .;
66 __initramfs_end = .; 67 __initramfs_end = .;
67 . = ALIGN(8192); 68 . = ALIGN(8192);
68 __init_end = .; 69 __init_end = .;
69 .init.task : { *(init_task) } 70 .data.init.task : { *(.data.init_task) }
70 71
71 72
72 .bss : { *(.bss) } /* BSS */ 73 .bss : { *(.bss) } /* BSS */
diff --git a/arch/m68k/lib/checksum.c b/arch/m68k/lib/checksum.c
index 4a5c5445c610..cb13c6e3ccae 100644
--- a/arch/m68k/lib/checksum.c
+++ b/arch/m68k/lib/checksum.c
@@ -134,7 +134,7 @@ EXPORT_SYMBOL(csum_partial);
134 */ 134 */
135 135
136unsigned int 136unsigned int
137csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 137csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst,
138 int len, int sum, int *csum_err) 138 int len, int sum, int *csum_err)
139{ 139{
140 /* 140 /*
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index cd19cbb213e8..14f8d3f4e195 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -212,9 +212,6 @@ void __init config_mac(void)
212 mach_reset = mac_reset; 212 mach_reset = mac_reset;
213 mach_halt = mac_poweroff; 213 mach_halt = mac_poweroff;
214 mach_power_off = mac_poweroff; 214 mach_power_off = mac_poweroff;
215#ifdef CONFIG_DUMMY_CONSOLE
216 conswitchp = &dummy_con;
217#endif
218 mach_max_dma_address = 0xffffffff; 215 mach_max_dma_address = 0xffffffff;
219#if 0 216#if 0
220 mach_debug_init = mac_debug_init; 217 mach_debug_init = mac_debug_init;
diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c
index d889ba80ccdc..9179a3798407 100644
--- a/arch/m68k/mac/iop.c
+++ b/arch/m68k/mac/iop.c
@@ -293,8 +293,8 @@ void __init iop_init(void)
293 } 293 }
294 294
295 for (i = 0 ; i < NUM_IOP_CHAN ; i++) { 295 for (i = 0 ; i < NUM_IOP_CHAN ; i++) {
296 iop_send_queue[IOP_NUM_SCC][i] = 0; 296 iop_send_queue[IOP_NUM_SCC][i] = NULL;
297 iop_send_queue[IOP_NUM_ISM][i] = 0; 297 iop_send_queue[IOP_NUM_ISM][i] = NULL;
298 iop_listeners[IOP_NUM_SCC][i].devname = NULL; 298 iop_listeners[IOP_NUM_SCC][i].devname = NULL;
299 iop_listeners[IOP_NUM_SCC][i].handler = NULL; 299 iop_listeners[IOP_NUM_SCC][i].handler = NULL;
300 iop_listeners[IOP_NUM_ISM][i].devname = NULL; 300 iop_listeners[IOP_NUM_ISM][i].devname = NULL;
diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index 5b80d7cd954a..bbb0c3b95e9c 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -39,72 +39,163 @@
39extern struct mac_booter_data mac_bi_data; 39extern struct mac_booter_data mac_bi_data;
40static void (*rom_reset)(void); 40static void (*rom_reset)(void);
41 41
42#ifdef CONFIG_ADB 42#ifdef CONFIG_ADB_CUDA
43/* 43static long cuda_read_time(void)
44 * Return the current time as the number of seconds since January 1, 1904.
45 */
46
47static long adb_read_time(void)
48{ 44{
49 volatile struct adb_request req; 45 struct adb_request req;
50 long time; 46 long time;
51 47
52 adb_request((struct adb_request *) &req, NULL, 48 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
53 ADBREQ_RAW|ADBREQ_SYNC, 49 return 0;
54 2, CUDA_PACKET, CUDA_GET_TIME); 50 while (!req.complete)
51 cuda_poll();
55 52
56 time = (req.reply[3] << 24) | (req.reply[4] << 16) 53 time = (req.reply[3] << 24) | (req.reply[4] << 16)
57 | (req.reply[5] << 8) | req.reply[6]; 54 | (req.reply[5] << 8) | req.reply[6];
58 return time - RTC_OFFSET; 55 return time - RTC_OFFSET;
59} 56}
60 57
61/* 58static void cuda_write_time(long data)
62 * Set the current system time 59{
63 */ 60 struct adb_request req;
61 data += RTC_OFFSET;
62 if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
63 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
64 (data >> 8) & 0xFF, data & 0xFF) < 0)
65 return;
66 while (!req.complete)
67 cuda_poll();
68}
64 69
65static void adb_write_time(long data) 70static __u8 cuda_read_pram(int offset)
66{ 71{
67 volatile struct adb_request req; 72 struct adb_request req;
73 if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
74 (offset >> 8) & 0xFF, offset & 0xFF) < 0)
75 return 0;
76 while (!req.complete)
77 cuda_poll();
78 return req.reply[3];
79}
68 80
69 data += RTC_OFFSET; 81static void cuda_write_pram(int offset, __u8 data)
82{
83 struct adb_request req;
84 if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
85 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
86 return;
87 while (!req.complete)
88 cuda_poll();
89}
90#else
91#define cuda_read_time() 0
92#define cuda_write_time(n)
93#define cuda_read_pram NULL
94#define cuda_write_pram NULL
95#endif
96
97#ifdef CONFIG_ADB_PMU68K
98static long pmu_read_time(void)
99{
100 struct adb_request req;
101 long time;
102
103 if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0)
104 return 0;
105 while (!req.complete)
106 pmu_poll();
70 107
71 adb_request((struct adb_request *) &req, NULL, 108 time = (req.reply[0] << 24) | (req.reply[1] << 16)
72 ADBREQ_RAW|ADBREQ_SYNC, 109 | (req.reply[2] << 8) | req.reply[3];
73 6, CUDA_PACKET, CUDA_SET_TIME, 110 return time - RTC_OFFSET;
111}
112
113static void pmu_write_time(long data)
114{
115 struct adb_request req;
116 data += RTC_OFFSET;
117 if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
74 (data >> 24) & 0xFF, (data >> 16) & 0xFF, 118 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
75 (data >> 8) & 0xFF, data & 0xFF); 119 (data >> 8) & 0xFF, data & 0xFF) < 0)
120 return;
121 while (!req.complete)
122 pmu_poll();
76} 123}
77 124
78/* 125static __u8 pmu_read_pram(int offset)
79 * Get a byte from the NVRAM 126{
80 */ 127 struct adb_request req;
128 if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
129 (offset >> 8) & 0xFF, offset & 0xFF) < 0)
130 return 0;
131 while (!req.complete)
132 pmu_poll();
133 return req.reply[3];
134}
81 135
82static __u8 adb_read_pram(int offset) 136static void pmu_write_pram(int offset, __u8 data)
83{ 137{
84 volatile struct adb_request req; 138 struct adb_request req;
139 if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
140 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
141 return;
142 while (!req.complete)
143 pmu_poll();
144}
145#else
146#define pmu_read_time() 0
147#define pmu_write_time(n)
148#define pmu_read_pram NULL
149#define pmu_write_pram NULL
150#endif
85 151
86 adb_request((struct adb_request *) &req, NULL, 152#ifdef CONFIG_ADB_MACIISI
87 ADBREQ_RAW|ADBREQ_SYNC, 153extern int maciisi_request(struct adb_request *req,
88 4, CUDA_PACKET, CUDA_GET_PRAM, 154 void (*done)(struct adb_request *), int nbytes, ...);
89 (offset >> 8) & 0xFF, offset & 0xFF); 155
90 return req.reply[3]; 156static long maciisi_read_time(void)
157{
158 struct adb_request req;
159 long time;
160
161 if (maciisi_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME))
162 return 0;
163
164 time = (req.reply[3] << 24) | (req.reply[4] << 16)
165 | (req.reply[5] << 8) | req.reply[6];
166 return time - RTC_OFFSET;
91} 167}
92 168
93/* 169static void maciisi_write_time(long data)
94 * Write a byte to the NVRAM 170{
95 */ 171 struct adb_request req;
172 data += RTC_OFFSET;
173 maciisi_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
174 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
175 (data >> 8) & 0xFF, data & 0xFF);
176}
96 177
97static void adb_write_pram(int offset, __u8 data) 178static __u8 maciisi_read_pram(int offset)
98{ 179{
99 volatile struct adb_request req; 180 struct adb_request req;
181 if (maciisi_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
182 (offset >> 8) & 0xFF, offset & 0xFF))
183 return 0;
184 return req.reply[3];
185}
100 186
101 adb_request((struct adb_request *) &req, NULL, 187static void maciisi_write_pram(int offset, __u8 data)
102 ADBREQ_RAW|ADBREQ_SYNC, 188{
103 5, CUDA_PACKET, CUDA_SET_PRAM, 189 struct adb_request req;
104 (offset >> 8) & 0xFF, offset & 0xFF, 190 maciisi_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
105 data); 191 (offset >> 8) & 0xFF, offset & 0xFF, data);
106} 192}
107#endif /* CONFIG_ADB */ 193#else
194#define maciisi_read_time() 0
195#define maciisi_write_time(n)
196#define maciisi_read_pram NULL
197#define maciisi_write_pram NULL
198#endif
108 199
109/* 200/*
110 * VIA PRAM/RTC access routines 201 * VIA PRAM/RTC access routines
@@ -305,42 +396,55 @@ static void oss_shutdown(void)
305 396
306static void cuda_restart(void) 397static void cuda_restart(void)
307{ 398{
308 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 399 struct adb_request req;
309 2, CUDA_PACKET, CUDA_RESET_SYSTEM); 400 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM) < 0)
401 return;
402 while (!req.complete)
403 cuda_poll();
310} 404}
311 405
312static void cuda_shutdown(void) 406static void cuda_shutdown(void)
313{ 407{
314 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 408 struct adb_request req;
315 2, CUDA_PACKET, CUDA_POWERDOWN); 409 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN) < 0)
410 return;
411 while (!req.complete)
412 cuda_poll();
316} 413}
317 414
318#endif /* CONFIG_ADB_CUDA */ 415#endif /* CONFIG_ADB_CUDA */
319 416
320#ifdef CONFIG_ADB_PMU 417#ifdef CONFIG_ADB_PMU68K
321 418
322void pmu_restart(void) 419void pmu_restart(void)
323{ 420{
324 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 421 struct adb_request req;
325 3, PMU_PACKET, PMU_SET_INTR_MASK, 422 if (pmu_request(&req, NULL,
326 PMU_INT_ADB|PMU_INT_TICK); 423 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
327 424 return;
328 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 425 while (!req.complete)
329 2, PMU_PACKET, PMU_RESET); 426 pmu_poll();
427 if (pmu_request(&req, NULL, 1, PMU_RESET) < 0)
428 return;
429 while (!req.complete)
430 pmu_poll();
330} 431}
331 432
332void pmu_shutdown(void) 433void pmu_shutdown(void)
333{ 434{
334 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 435 struct adb_request req;
335 3, PMU_PACKET, PMU_SET_INTR_MASK, 436 if (pmu_request(&req, NULL,
336 PMU_INT_ADB|PMU_INT_TICK); 437 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
337 438 return;
338 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 439 while (!req.complete)
339 6, PMU_PACKET, PMU_SHUTDOWN, 440 pmu_poll();
340 'M', 'A', 'T', 'T'); 441 if (pmu_request(&req, NULL, 5, PMU_SHUTDOWN, 'M', 'A', 'T', 'T') < 0)
442 return;
443 while (!req.complete)
444 pmu_poll();
341} 445}
342 446
343#endif /* CONFIG_ADB_PMU */ 447#endif
344 448
345/* 449/*
346 *------------------------------------------------------------------- 450 *-------------------------------------------------------------------
@@ -351,21 +455,22 @@ void pmu_shutdown(void)
351 455
352void mac_pram_read(int offset, __u8 *buffer, int len) 456void mac_pram_read(int offset, __u8 *buffer, int len)
353{ 457{
354 __u8 (*func)(int) = NULL; 458 __u8 (*func)(int);
355 int i; 459 int i;
356 460
357 if (macintosh_config->adb_type == MAC_ADB_IISI || 461 switch(macintosh_config->adb_type) {
358 macintosh_config->adb_type == MAC_ADB_PB1 || 462 case MAC_ADB_IISI:
359 macintosh_config->adb_type == MAC_ADB_PB2 || 463 func = maciisi_read_pram; break;
360 macintosh_config->adb_type == MAC_ADB_CUDA) { 464 case MAC_ADB_PB1:
361#ifdef CONFIG_ADB 465 case MAC_ADB_PB2:
362 func = adb_read_pram; 466 func = pmu_read_pram; break;
363#else 467 case MAC_ADB_CUDA:
364 return; 468 func = cuda_read_pram; break;
365#endif 469 default:
366 } else {
367 func = via_read_pram; 470 func = via_read_pram;
368 } 471 }
472 if (!func)
473 return;
369 for (i = 0 ; i < len ; i++) { 474 for (i = 0 ; i < len ; i++) {
370 buffer[i] = (*func)(offset++); 475 buffer[i] = (*func)(offset++);
371 } 476 }
@@ -373,21 +478,22 @@ void mac_pram_read(int offset, __u8 *buffer, int len)
373 478
374void mac_pram_write(int offset, __u8 *buffer, int len) 479void mac_pram_write(int offset, __u8 *buffer, int len)
375{ 480{
376 void (*func)(int, __u8) = NULL; 481 void (*func)(int, __u8);
377 int i; 482 int i;
378 483
379 if (macintosh_config->adb_type == MAC_ADB_IISI || 484 switch(macintosh_config->adb_type) {
380 macintosh_config->adb_type == MAC_ADB_PB1 || 485 case MAC_ADB_IISI:
381 macintosh_config->adb_type == MAC_ADB_PB2 || 486 func = maciisi_write_pram; break;
382 macintosh_config->adb_type == MAC_ADB_CUDA) { 487 case MAC_ADB_PB1:
383#ifdef CONFIG_ADB 488 case MAC_ADB_PB2:
384 func = adb_write_pram; 489 func = pmu_write_pram; break;
385#else 490 case MAC_ADB_CUDA:
386 return; 491 func = cuda_write_pram; break;
387#endif 492 default:
388 } else {
389 func = via_write_pram; 493 func = via_write_pram;
390 } 494 }
495 if (!func)
496 return;
391 for (i = 0 ; i < len ; i++) { 497 for (i = 0 ; i < len ; i++) {
392 (*func)(offset++, buffer[i]); 498 (*func)(offset++, buffer[i]);
393 } 499 }
@@ -408,7 +514,7 @@ void mac_poweroff(void)
408 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) { 514 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) {
409 cuda_shutdown(); 515 cuda_shutdown();
410#endif 516#endif
411#ifdef CONFIG_ADB_PMU 517#ifdef CONFIG_ADB_PMU68K
412 } else if (macintosh_config->adb_type == MAC_ADB_PB1 518 } else if (macintosh_config->adb_type == MAC_ADB_PB1
413 || macintosh_config->adb_type == MAC_ADB_PB2) { 519 || macintosh_config->adb_type == MAC_ADB_PB2) {
414 pmu_shutdown(); 520 pmu_shutdown();
@@ -448,7 +554,7 @@ void mac_reset(void)
448 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) { 554 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) {
449 cuda_restart(); 555 cuda_restart();
450#endif 556#endif
451#ifdef CONFIG_ADB_PMU 557#ifdef CONFIG_ADB_PMU68K
452 } else if (macintosh_config->adb_type == MAC_ADB_PB1 558 } else if (macintosh_config->adb_type == MAC_ADB_PB1
453 || macintosh_config->adb_type == MAC_ADB_PB2) { 559 || macintosh_config->adb_type == MAC_ADB_PB2) {
454 pmu_restart(); 560 pmu_restart();
@@ -466,12 +572,13 @@ void mac_reset(void)
466 /* make a 1-to-1 mapping, using the transparent tran. reg. */ 572 /* make a 1-to-1 mapping, using the transparent tran. reg. */
467 unsigned long virt = (unsigned long) mac_reset; 573 unsigned long virt = (unsigned long) mac_reset;
468 unsigned long phys = virt_to_phys(mac_reset); 574 unsigned long phys = virt_to_phys(mac_reset);
575 unsigned long addr = (phys&0xFF000000)|0x8777;
469 unsigned long offset = phys-virt; 576 unsigned long offset = phys-virt;
470 local_irq_disable(); /* lets not screw this up, ok? */ 577 local_irq_disable(); /* lets not screw this up, ok? */
471 __asm__ __volatile__(".chip 68030\n\t" 578 __asm__ __volatile__(".chip 68030\n\t"
472 "pmove %0,%/tt0\n\t" 579 "pmove %0,%/tt0\n\t"
473 ".chip 68k" 580 ".chip 68k"
474 : : "m" ((phys&0xFF000000)|0x8777)); 581 : : "m" (addr));
475 /* Now jump to physical address so we can disable MMU */ 582 /* Now jump to physical address so we can disable MMU */
476 __asm__ __volatile__( 583 __asm__ __volatile__(
477 ".chip 68030\n\t" 584 ".chip 68030\n\t"
@@ -588,20 +695,22 @@ int mac_hwclk(int op, struct rtc_time *t)
588 unsigned long now; 695 unsigned long now;
589 696
590 if (!op) { /* read */ 697 if (!op) { /* read */
591 if (macintosh_config->adb_type == MAC_ADB_II) { 698 switch (macintosh_config->adb_type) {
699 case MAC_ADB_II:
700 case MAC_ADB_IOP:
592 now = via_read_time(); 701 now = via_read_time();
593 } else 702 break;
594#ifdef CONFIG_ADB 703 case MAC_ADB_IISI:
595 if ((macintosh_config->adb_type == MAC_ADB_IISI) || 704 now = maciisi_read_time();
596 (macintosh_config->adb_type == MAC_ADB_PB1) || 705 break;
597 (macintosh_config->adb_type == MAC_ADB_PB2) || 706 case MAC_ADB_PB1:
598 (macintosh_config->adb_type == MAC_ADB_CUDA)) { 707 case MAC_ADB_PB2:
599 now = adb_read_time(); 708 now = pmu_read_time();
600 } else 709 break;
601#endif 710 case MAC_ADB_CUDA:
602 if (macintosh_config->adb_type == MAC_ADB_IOP) { 711 now = cuda_read_time();
603 now = via_read_time(); 712 break;
604 } else { 713 default:
605 now = 0; 714 now = 0;
606 } 715 }
607 716
@@ -619,15 +728,20 @@ int mac_hwclk(int op, struct rtc_time *t)
619 now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 728 now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
620 t->tm_hour, t->tm_min, t->tm_sec); 729 t->tm_hour, t->tm_min, t->tm_sec);
621 730
622 if (macintosh_config->adb_type == MAC_ADB_II) { 731 switch (macintosh_config->adb_type) {
623 via_write_time(now); 732 case MAC_ADB_II:
624 } else if ((macintosh_config->adb_type == MAC_ADB_IISI) || 733 case MAC_ADB_IOP:
625 (macintosh_config->adb_type == MAC_ADB_PB1) ||
626 (macintosh_config->adb_type == MAC_ADB_PB2) ||
627 (macintosh_config->adb_type == MAC_ADB_CUDA)) {
628 adb_write_time(now);
629 } else if (macintosh_config->adb_type == MAC_ADB_IOP) {
630 via_write_time(now); 734 via_write_time(now);
735 break;
736 case MAC_ADB_CUDA:
737 cuda_write_time(now);
738 break;
739 case MAC_ADB_PB1:
740 case MAC_ADB_PB2:
741 pmu_write_time(now);
742 break;
743 case MAC_ADB_IISI:
744 maciisi_write_time(now);
631 } 745 }
632#endif 746#endif
633 } 747 }
diff --git a/arch/m68k/math-emu/multi_arith.h b/arch/m68k/math-emu/multi_arith.h
index 02251e5afd89..4ad0ca918e2e 100644
--- a/arch/m68k/math-emu/multi_arith.h
+++ b/arch/m68k/math-emu/multi_arith.h
@@ -366,7 +366,7 @@ static inline void fp_submant(struct fp_ext *dest, struct fp_ext *src1,
366 366
367#define fp_mul64(desth, destl, src1, src2) ({ \ 367#define fp_mul64(desth, destl, src1, src2) ({ \
368 asm ("mulu.l %2,%1:%0" : "=d" (destl), "=d" (desth) \ 368 asm ("mulu.l %2,%1:%0" : "=d" (destl), "=d" (desth) \
369 : "g" (src1), "0" (src2)); \ 369 : "dm" (src1), "0" (src2)); \
370}) 370})
371#define fp_div64(quot, rem, srch, srcl, div) \ 371#define fp_div64(quot, rem, srch, srcl, div) \
372 asm ("divu.l %2,%1:%0" : "=d" (quot), "=d" (rem) \ 372 asm ("divu.l %2,%1:%0" : "=d" (quot), "=d" (rem) \
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index fe2383e36b06..85ad19a0ac79 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -102,7 +102,7 @@ static inline void free_io_area(void *addr)
102 */ 102 */
103/* Rewritten by Andreas Schwab to remove all races. */ 103/* Rewritten by Andreas Schwab to remove all races. */
104 104
105void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag) 105void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
106{ 106{
107 struct vm_struct *area; 107 struct vm_struct *area;
108 unsigned long virtaddr, retaddr; 108 unsigned long virtaddr, retaddr;
@@ -121,7 +121,7 @@ void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
121 if (MACH_IS_AMIGA) { 121 if (MACH_IS_AMIGA) {
122 if ((physaddr >= 0x40000000) && (physaddr + size < 0x60000000) 122 if ((physaddr >= 0x40000000) && (physaddr + size < 0x60000000)
123 && (cacheflag == IOMAP_NOCACHE_SER)) 123 && (cacheflag == IOMAP_NOCACHE_SER))
124 return (void *)physaddr; 124 return (void __iomem *)physaddr;
125 } 125 }
126#endif 126#endif
127 127
@@ -218,21 +218,21 @@ void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
218#endif 218#endif
219 flush_tlb_all(); 219 flush_tlb_all();
220 220
221 return (void *)retaddr; 221 return (void __iomem *)retaddr;
222} 222}
223 223
224/* 224/*
225 * Unmap a ioremap()ed region again 225 * Unmap a ioremap()ed region again
226 */ 226 */
227void iounmap(void *addr) 227void iounmap(void __iomem *addr)
228{ 228{
229#ifdef CONFIG_AMIGA 229#ifdef CONFIG_AMIGA
230 if ((!MACH_IS_AMIGA) || 230 if ((!MACH_IS_AMIGA) ||
231 (((unsigned long)addr < 0x40000000) || 231 (((unsigned long)addr < 0x40000000) ||
232 ((unsigned long)addr > 0x60000000))) 232 ((unsigned long)addr > 0x60000000)))
233 free_io_area(addr); 233 free_io_area((__force void *)addr);
234#else 234#else
235 free_io_area(addr); 235 free_io_area((__force void *)addr);
236#endif 236#endif
237} 237}
238 238
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 7977eae50af2..a69fe3048edc 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -11,6 +11,7 @@
11#include <linux/miscdevice.h> 11#include <linux/miscdevice.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/ioport.h> 13#include <linux/ioport.h>
14#include <linux/capability.h>
14#include <linux/fcntl.h> 15#include <linux/fcntl.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/poll.h> 17#include <linux/poll.h>
@@ -44,6 +45,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
44 volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; 45 volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE;
45 unsigned long flags; 46 unsigned long flags;
46 struct rtc_time wtime; 47 struct rtc_time wtime;
48 void __user *argp = (void __user *)arg;
47 49
48 switch (cmd) { 50 switch (cmd) {
49 case RTC_RD_TIME: /* Read the time/date from RTC */ 51 case RTC_RD_TIME: /* Read the time/date from RTC */
@@ -63,7 +65,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
63 wtime.tm_wday = BCD2BIN(rtc->bcd_dow)-1; 65 wtime.tm_wday = BCD2BIN(rtc->bcd_dow)-1;
64 rtc->ctrl = 0; 66 rtc->ctrl = 0;
65 local_irq_restore(flags); 67 local_irq_restore(flags);
66 return copy_to_user((void *)arg, &wtime, sizeof wtime) ? 68 return copy_to_user(argp, &wtime, sizeof wtime) ?
67 -EFAULT : 0; 69 -EFAULT : 0;
68 } 70 }
69 case RTC_SET_TIME: /* Set the RTC */ 71 case RTC_SET_TIME: /* Set the RTC */
@@ -75,8 +77,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
75 if (!capable(CAP_SYS_ADMIN)) 77 if (!capable(CAP_SYS_ADMIN))
76 return -EACCES; 78 return -EACCES;
77 79
78 if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, 80 if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time)))
79 sizeof(struct rtc_time)))
80 return -EFAULT; 81 return -EFAULT;
81 82
82 yrs = rtc_tm.tm_year; 83 yrs = rtc_tm.tm_year;
diff --git a/arch/m68k/q40/config.c b/arch/m68k/q40/config.c
index 02b626bae4ae..5e0f9b04d45e 100644
--- a/arch/m68k/q40/config.c
+++ b/arch/m68k/q40/config.c
@@ -36,8 +36,6 @@
36#include <asm/machdep.h> 36#include <asm/machdep.h>
37#include <asm/q40_master.h> 37#include <asm/q40_master.h>
38 38
39extern void floppy_setup(char *str, int *ints);
40
41extern irqreturn_t q40_process_int (int level, struct pt_regs *regs); 39extern irqreturn_t q40_process_int (int level, struct pt_regs *regs);
42extern irqreturn_t (*q40_default_handler[]) (int, void *, struct pt_regs *); /* added just for debugging */ 40extern irqreturn_t (*q40_default_handler[]) (int, void *, struct pt_regs *); /* added just for debugging */
43extern void q40_init_IRQ (void); 41extern void q40_init_IRQ (void);
@@ -194,9 +192,6 @@ void __init config_q40(void)
194 mach_heartbeat = q40_heartbeat; 192 mach_heartbeat = q40_heartbeat;
195#endif 193#endif
196 mach_halt = q40_halt; 194 mach_halt = q40_halt;
197#ifdef CONFIG_DUMMY_CONSOLE
198 conswitchp = &dummy_con;
199#endif
200 195
201 /* disable a few things that SMSQ might have left enabled */ 196 /* disable a few things that SMSQ might have left enabled */
202 q40_disable_irqs(); 197 q40_disable_irqs();
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index 77d05bcc3221..f1ca0dfbaa67 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -160,9 +160,6 @@ void __init config_sun3(void)
160 mach_hwclk = sun3_hwclk; 160 mach_hwclk = sun3_hwclk;
161 mach_halt = sun3_halt; 161 mach_halt = sun3_halt;
162 mach_get_hardware_list = sun3_get_hardware_list; 162 mach_get_hardware_list = sun3_get_hardware_list;
163#if defined(CONFIG_DUMMY_CONSOLE)
164 conswitchp = &dummy_con;
165#endif
166 163
167 memory_start = ((((int)&_end) + 0x2000) & ~0x1fff); 164 memory_start = ((((int)&_end) + 0x2000) & ~0x1fff);
168// PROM seems to want the last couple of physical pages. --m 165// PROM seems to want the last couple of physical pages. --m
diff --git a/arch/m68k/sun3x/config.c b/arch/m68k/sun3x/config.c
index 0ef547f5494d..0920f5d33606 100644
--- a/arch/m68k/sun3x/config.c
+++ b/arch/m68k/sun3x/config.c
@@ -71,10 +71,6 @@ void __init config_sun3x(void)
71 mach_get_model = sun3_get_model; 71 mach_get_model = sun3_get_model;
72 mach_get_hardware_list = sun3x_get_hardware_list; 72 mach_get_hardware_list = sun3x_get_hardware_list;
73 73
74#ifdef CONFIG_DUMMY_CONSOLE
75 conswitchp = &dummy_con;
76#endif
77
78 sun3_intreg = (unsigned char *)SUN3X_INTREG; 74 sun3_intreg = (unsigned char *)SUN3X_INTREG;
79 75
80 /* only the serial console is known to work anyway... */ 76 /* only the serial console is known to work anyway... */
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index b6b5c14e55fd..6f880cbff1c8 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -99,7 +99,6 @@ cflags-$(CONFIG_M68360) := -m68332
99AFLAGS += $(cflags-y) 99AFLAGS += $(cflags-y)
100 100
101CFLAGS += $(cflags-y) 101CFLAGS += $(cflags-y)
102CFLAGS += -O1 -g
103CFLAGS += -D__linux__ 102CFLAGS += -D__linux__
104CFLAGS += -DUTS_SYSNAME=\"uClinux\" 103CFLAGS += -DUTS_SYSNAME=\"uClinux\"
105 104
diff --git a/arch/m68knommu/kernel/m68k_ksyms.c b/arch/m68knommu/kernel/m68k_ksyms.c
index b2c62eeb3bab..eddb8d3e130a 100644
--- a/arch/m68knommu/kernel/m68k_ksyms.c
+++ b/arch/m68knommu/kernel/m68k_ksyms.c
@@ -18,7 +18,6 @@
18#include <asm/checksum.h> 18#include <asm/checksum.h>
19#include <asm/current.h> 19#include <asm/current.h>
20 20
21extern void dump_thread(struct pt_regs *, struct user *);
22extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); 21extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
23 22
24/* platform dependent support */ 23/* platform dependent support */
@@ -26,7 +25,6 @@ extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
26EXPORT_SYMBOL(__ioremap); 25EXPORT_SYMBOL(__ioremap);
27EXPORT_SYMBOL(iounmap); 26EXPORT_SYMBOL(iounmap);
28EXPORT_SYMBOL(dump_fpu); 27EXPORT_SYMBOL(dump_fpu);
29EXPORT_SYMBOL(dump_thread);
30EXPORT_SYMBOL(strnlen); 28EXPORT_SYMBOL(strnlen);
31EXPORT_SYMBOL(strrchr); 29EXPORT_SYMBOL(strrchr);
32EXPORT_SYMBOL(strstr); 30EXPORT_SYMBOL(strstr);
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 82e7ec888806..99bf43824795 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -198,10 +198,9 @@ int copy_thread(int nr, unsigned long clone_flags,
198{ 198{
199 struct pt_regs * childregs; 199 struct pt_regs * childregs;
200 struct switch_stack * childstack, *stack; 200 struct switch_stack * childstack, *stack;
201 unsigned long stack_offset, *retp; 201 unsigned long *retp;
202 202
203 stack_offset = THREAD_SIZE - sizeof(struct pt_regs); 203 childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1;
204 childregs = (struct pt_regs *) ((unsigned long) p->thread_info + stack_offset);
205 204
206 *childregs = *regs; 205 *childregs = *regs;
207 childregs->d0 = 0; 206 childregs->d0 = 0;
@@ -276,52 +275,6 @@ int dump_fpu(struct pt_regs *regs, struct user_m68kfp_struct *fpu)
276} 275}
277 276
278/* 277/*
279 * fill in the user structure for a core dump..
280 */
281void dump_thread(struct pt_regs * regs, struct user * dump)
282{
283 struct switch_stack *sw;
284
285 /* changed the size calculations - should hopefully work better. lbt */
286 dump->magic = CMAGIC;
287 dump->start_code = 0;
288 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
289 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
290 dump->u_dsize = ((unsigned long) (current->mm->brk +
291 (PAGE_SIZE-1))) >> PAGE_SHIFT;
292 dump->u_dsize -= dump->u_tsize;
293 dump->u_ssize = 0;
294
295 if (dump->start_stack < TASK_SIZE)
296 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
297
298 dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
299 sw = ((struct switch_stack *)regs) - 1;
300 dump->regs.d1 = regs->d1;
301 dump->regs.d2 = regs->d2;
302 dump->regs.d3 = regs->d3;
303 dump->regs.d4 = regs->d4;
304 dump->regs.d5 = regs->d5;
305 dump->regs.d6 = sw->d6;
306 dump->regs.d7 = sw->d7;
307 dump->regs.a0 = regs->a0;
308 dump->regs.a1 = regs->a1;
309 dump->regs.a2 = regs->a2;
310 dump->regs.a3 = sw->a3;
311 dump->regs.a4 = sw->a4;
312 dump->regs.a5 = sw->a5;
313 dump->regs.a6 = sw->a6;
314 dump->regs.d0 = regs->d0;
315 dump->regs.orig_d0 = regs->orig_d0;
316 dump->regs.stkadj = regs->stkadj;
317 dump->regs.sr = regs->sr;
318 dump->regs.pc = regs->pc;
319 dump->regs.fmtvec = (regs->format << 12) | regs->vector;
320 /* dump floating point stuff */
321 dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
322}
323
324/*
325 * Generic dumping code. Used for panic and debug. 278 * Generic dumping code. Used for panic and debug.
326 */ 279 */
327void dump(struct pt_regs *fp) 280void dump(struct pt_regs *fp)
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index 262ab8c72e5f..382ca5797b97 100644
--- a/arch/m68knommu/kernel/ptrace.c
+++ b/arch/m68knommu/kernel/ptrace.c
@@ -101,7 +101,7 @@ void ptrace_disable(struct task_struct *child)
101 put_reg(child, PT_SR, tmp); 101 put_reg(child, PT_SR, tmp);
102} 102}
103 103
104long arch_ptrace(truct task_struct *child, long request, long addr, long data) 104long arch_ptrace(struct task_struct *child, long request, long addr, long data)
105{ 105{
106 int ret; 106 int ret;
107 107
diff --git a/arch/m68knommu/kernel/signal.c b/arch/m68knommu/kernel/signal.c
index 43a2726c0d0a..e1b3aa39e270 100644
--- a/arch/m68knommu/kernel/signal.c
+++ b/arch/m68knommu/kernel/signal.c
@@ -285,6 +285,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
285 regs->d1 = context.sc_d1; 285 regs->d1 = context.sc_d1;
286 regs->a0 = context.sc_a0; 286 regs->a0 = context.sc_a0;
287 regs->a1 = context.sc_a1; 287 regs->a1 = context.sc_a1;
288 ((struct switch_stack *)regs - 1)->a5 = context.sc_a5;
288 regs->sr = (regs->sr & 0xff00) | (context.sc_sr & 0xff); 289 regs->sr = (regs->sr & 0xff00) | (context.sc_sr & 0xff);
289 regs->pc = context.sc_pc; 290 regs->pc = context.sc_pc;
290 regs->orig_d0 = -1; /* disable syscall checks */ 291 regs->orig_d0 = -1; /* disable syscall checks */
@@ -498,6 +499,7 @@ static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
498 sc->sc_d1 = regs->d1; 499 sc->sc_d1 = regs->d1;
499 sc->sc_a0 = regs->a0; 500 sc->sc_a0 = regs->a0;
500 sc->sc_a1 = regs->a1; 501 sc->sc_a1 = regs->a1;
502 sc->sc_a5 = ((struct switch_stack *)regs - 1)->a5;
501 sc->sc_sr = regs->sr; 503 sc->sc_sr = regs->sr;
502 sc->sc_pc = regs->pc; 504 sc->sc_pc = regs->pc;
503 sc->sc_formatvec = regs->format << 12 | regs->vector; 505 sc->sc_formatvec = regs->format << 12 | regs->vector;
@@ -597,6 +599,9 @@ static void setup_frame (int sig, struct k_sigaction *ka,
597 /* Set up registers for signal handler */ 599 /* Set up registers for signal handler */
598 wrusp ((unsigned long) frame); 600 wrusp ((unsigned long) frame);
599 regs->pc = (unsigned long) ka->sa.sa_handler; 601 regs->pc = (unsigned long) ka->sa.sa_handler;
602 ((struct switch_stack *)regs - 1)->a5 = current->mm->start_data;
603 regs->format = 0x4; /*set format byte to make stack appear modulo 4
604 which it will be when doing the rte */
600 605
601adjust_stack: 606adjust_stack:
602 /* Prepare to skip over the extra stuff in the exception frame. */ 607 /* Prepare to skip over the extra stuff in the exception frame. */
@@ -664,6 +669,9 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
664 /* Set up registers for signal handler */ 669 /* Set up registers for signal handler */
665 wrusp ((unsigned long) frame); 670 wrusp ((unsigned long) frame);
666 regs->pc = (unsigned long) ka->sa.sa_handler; 671 regs->pc = (unsigned long) ka->sa.sa_handler;
672 ((struct switch_stack *)regs - 1)->a5 = current->mm->start_data;
673 regs->format = 0x4; /*set format byte to make stack appear modulo 4
674 which it will be when doing the rte */
667 675
668adjust_stack: 676adjust_stack:
669 /* Prepare to skip over the extra stuff in the exception frame. */ 677 /* Prepare to skip over the extra stuff in the exception frame. */
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 0eab92ca4b97..ac9de2661c0b 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -129,7 +129,7 @@
129 */ 129 */
130#if defined(CONFIG_M5208EVB) 130#if defined(CONFIG_M5208EVB)
131#define RAM_START 0x40020000 131#define RAM_START 0x40020000
132#define RAM_LENGTH 0x01e00000 132#define RAM_LENGTH 0x01fe0000
133#endif 133#endif
134 134
135/* 135/*
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index b50be449d3f5..c3e852e9953e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1471,7 +1471,7 @@ config SB1_PASS_2_1_WORKAROUNDS
1471 1471
1472config 64BIT_PHYS_ADDR 1472config 64BIT_PHYS_ADDR
1473 bool "Support for 64-bit physical address space" 1473 bool "Support for 64-bit physical address space"
1474 depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_RM9000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32_R1 || CPU_MIPS64_R1) && 32BIT 1474 depends on (CPU_R4X00 || CPU_R5000 || CPU_RM7000 || CPU_RM9000 || CPU_R10000 || CPU_SB1 || CPU_MIPS32 || CPU_MIPS64) && 32BIT
1475 1475
1476config CPU_ADVANCED 1476config CPU_ADVANCED
1477 bool "Override CPU Options" 1477 bool "Override CPU Options"
@@ -1492,14 +1492,6 @@ config CPU_HAS_LLSC
1492 for better performance, N if you don't know. You must say Y here 1492 for better performance, N if you don't know. You must say Y here
1493 for multiprocessor machines. 1493 for multiprocessor machines.
1494 1494
1495config CPU_HAS_LLDSCD
1496 bool "lld/scd Instructions available" if CPU_ADVANCED
1497 default y if !CPU_ADVANCED && !CPU_R3000 && !CPU_VR41XX && !CPU_TX39XX && !CPU_MIPS32_R1
1498 help
1499 Say Y here if your CPU has the lld and scd instructions, the 64-bit
1500 equivalents of ll and sc. Say Y here for better performance, N if
1501 you don't know. You must say Y here for multiprocessor machines.
1502
1503config CPU_HAS_WB 1495config CPU_HAS_WB
1504 bool "Writeback Buffer available" if CPU_ADVANCED 1496 bool "Writeback Buffer available" if CPU_ADVANCED
1505 default y if !CPU_ADVANCED && CPU_R3000 && MACH_DECSTATION 1497 default y if !CPU_ADVANCED && CPU_R3000 && MACH_DECSTATION
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index e14ba5e01a36..2a9f2ef27b29 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -93,7 +93,6 @@ endif
93# 93#
94cflags-y += -I $(TOPDIR)/include/asm/gcc 94cflags-y += -I $(TOPDIR)/include/asm/gcc
95cflags-y += -G 0 -mno-abicalls -fno-pic -pipe 95cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
96cflags-y += $(call cc-option, -finline-limit=100000)
97LDFLAGS_vmlinux += -G 0 -static -n -nostdlib 96LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
98MODFLAGS += -mlong-calls 97MODFLAGS += -mlong-calls
99 98
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index 069f9d14983e..6fd353779813 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -130,7 +130,6 @@ CONFIG_PAGE_SIZE_4KB=y
130# CONFIG_SIBYTE_DMA_PAGEOPS is not set 130# CONFIG_SIBYTE_DMA_PAGEOPS is not set
131# CONFIG_MIPS_MT is not set 131# CONFIG_MIPS_MT is not set
132CONFIG_CPU_HAS_LLSC=y 132CONFIG_CPU_HAS_LLSC=y
133CONFIG_CPU_HAS_LLDSCD=y
134CONFIG_CPU_HAS_SYNC=y 133CONFIG_CPU_HAS_SYNC=y
135CONFIG_GENERIC_HARDIRQS=y 134CONFIG_GENERIC_HARDIRQS=y
136CONFIG_GENERIC_IRQ_PROBE=y 135CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index 216f4023a81b..1d3ee18ea8bb 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_defconfig
@@ -115,7 +115,6 @@ CONFIG_PAGE_SIZE_4KB=y
115# CONFIG_MIPS_MT is not set 115# CONFIG_MIPS_MT is not set
116# CONFIG_CPU_ADVANCED is not set 116# CONFIG_CPU_ADVANCED is not set
117CONFIG_CPU_HAS_LLSC=y 117CONFIG_CPU_HAS_LLSC=y
118CONFIG_CPU_HAS_LLDSCD=y
119CONFIG_CPU_HAS_SYNC=y 118CONFIG_CPU_HAS_SYNC=y
120CONFIG_GENERIC_HARDIRQS=y 119CONFIG_GENERIC_HARDIRQS=y
121CONFIG_GENERIC_IRQ_PROBE=y 120CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ddb5476_defconfig b/arch/mips/configs/ddb5476_defconfig
index bea00a9e9269..a81e2de6947f 100644
--- a/arch/mips/configs/ddb5476_defconfig
+++ b/arch/mips/configs/ddb5476_defconfig
@@ -116,7 +116,6 @@ CONFIG_PAGE_SIZE_4KB=y
116# CONFIG_MIPS_MT is not set 116# CONFIG_MIPS_MT is not set
117# CONFIG_CPU_ADVANCED is not set 117# CONFIG_CPU_ADVANCED is not set
118CONFIG_CPU_HAS_LLSC=y 118CONFIG_CPU_HAS_LLSC=y
119CONFIG_CPU_HAS_LLDSCD=y
120CONFIG_CPU_HAS_SYNC=y 119CONFIG_CPU_HAS_SYNC=y
121CONFIG_GENERIC_HARDIRQS=y 120CONFIG_GENERIC_HARDIRQS=y
122CONFIG_GENERIC_IRQ_PROBE=y 121CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ddb5477_defconfig b/arch/mips/configs/ddb5477_defconfig
index 61f7171ca7ed..f1c27c2fb033 100644
--- a/arch/mips/configs/ddb5477_defconfig
+++ b/arch/mips/configs/ddb5477_defconfig
@@ -116,7 +116,6 @@ CONFIG_PAGE_SIZE_4KB=y
116# CONFIG_MIPS_MT is not set 116# CONFIG_MIPS_MT is not set
117# CONFIG_CPU_ADVANCED is not set 117# CONFIG_CPU_ADVANCED is not set
118CONFIG_CPU_HAS_LLSC=y 118CONFIG_CPU_HAS_LLSC=y
119CONFIG_CPU_HAS_LLDSCD=y
120CONFIG_CPU_HAS_SYNC=y 119CONFIG_CPU_HAS_SYNC=y
121CONFIG_GENERIC_HARDIRQS=y 120CONFIG_GENERIC_HARDIRQS=y
122CONFIG_GENERIC_IRQ_PROBE=y 121CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ev64120_defconfig b/arch/mips/configs/ev64120_defconfig
index 14e3815f11e6..aa24d85ea94d 100644
--- a/arch/mips/configs/ev64120_defconfig
+++ b/arch/mips/configs/ev64120_defconfig
@@ -118,7 +118,6 @@ CONFIG_PAGE_SIZE_4KB=y
118# CONFIG_64BIT_PHYS_ADDR is not set 118# CONFIG_64BIT_PHYS_ADDR is not set
119# CONFIG_CPU_ADVANCED is not set 119# CONFIG_CPU_ADVANCED is not set
120CONFIG_CPU_HAS_LLSC=y 120CONFIG_CPU_HAS_LLSC=y
121CONFIG_CPU_HAS_LLDSCD=y
122CONFIG_CPU_HAS_SYNC=y 121CONFIG_CPU_HAS_SYNC=y
123CONFIG_GENERIC_HARDIRQS=y 122CONFIG_GENERIC_HARDIRQS=y
124CONFIG_GENERIC_IRQ_PROBE=y 123CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ev96100_defconfig b/arch/mips/configs/ev96100_defconfig
index 510819581d8a..eeed0e5ad260 100644
--- a/arch/mips/configs/ev96100_defconfig
+++ b/arch/mips/configs/ev96100_defconfig
@@ -121,7 +121,6 @@ CONFIG_CPU_HAS_PREFETCH=y
121# CONFIG_64BIT_PHYS_ADDR is not set 121# CONFIG_64BIT_PHYS_ADDR is not set
122# CONFIG_CPU_ADVANCED is not set 122# CONFIG_CPU_ADVANCED is not set
123CONFIG_CPU_HAS_LLSC=y 123CONFIG_CPU_HAS_LLSC=y
124CONFIG_CPU_HAS_LLDSCD=y
125CONFIG_CPU_HAS_SYNC=y 124CONFIG_CPU_HAS_SYNC=y
126CONFIG_GENERIC_HARDIRQS=y 125CONFIG_GENERIC_HARDIRQS=y
127CONFIG_GENERIC_IRQ_PROBE=y 126CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index 67979e3e606e..e56351abf87a 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -123,7 +123,6 @@ CONFIG_IP22_CPU_SCACHE=y
123# CONFIG_64BIT_PHYS_ADDR is not set 123# CONFIG_64BIT_PHYS_ADDR is not set
124# CONFIG_CPU_ADVANCED is not set 124# CONFIG_CPU_ADVANCED is not set
125CONFIG_CPU_HAS_LLSC=y 125CONFIG_CPU_HAS_LLSC=y
126CONFIG_CPU_HAS_LLDSCD=y
127CONFIG_CPU_HAS_SYNC=y 126CONFIG_CPU_HAS_SYNC=y
128CONFIG_GENERIC_HARDIRQS=y 127CONFIG_GENERIC_HARDIRQS=y
129CONFIG_GENERIC_IRQ_PROBE=y 128CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index 03af44d1d846..e17d3adff021 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -119,7 +119,6 @@ CONFIG_PAGE_SIZE_4KB=y
119CONFIG_CPU_HAS_PREFETCH=y 119CONFIG_CPU_HAS_PREFETCH=y
120# CONFIG_MIPS_MT is not set 120# CONFIG_MIPS_MT is not set
121CONFIG_CPU_HAS_LLSC=y 121CONFIG_CPU_HAS_LLSC=y
122CONFIG_CPU_HAS_LLDSCD=y
123CONFIG_CPU_HAS_SYNC=y 122CONFIG_CPU_HAS_SYNC=y
124CONFIG_GENERIC_HARDIRQS=y 123CONFIG_GENERIC_HARDIRQS=y
125CONFIG_GENERIC_IRQ_PROBE=y 124CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index cba2a49cceb1..967e7acd8e1f 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -121,7 +121,6 @@ CONFIG_R5000_CPU_SCACHE=y
121CONFIG_RM7000_CPU_SCACHE=y 121CONFIG_RM7000_CPU_SCACHE=y
122# CONFIG_MIPS_MT is not set 122# CONFIG_MIPS_MT is not set
123CONFIG_CPU_HAS_LLSC=y 123CONFIG_CPU_HAS_LLSC=y
124CONFIG_CPU_HAS_LLDSCD=y
125CONFIG_CPU_HAS_SYNC=y 124CONFIG_CPU_HAS_SYNC=y
126CONFIG_GENERIC_HARDIRQS=y 125CONFIG_GENERIC_HARDIRQS=y
127CONFIG_GENERIC_IRQ_PROBE=y 126CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/it8172_defconfig b/arch/mips/configs/it8172_defconfig
index e7ee1679af90..b5fa9639db6f 100644
--- a/arch/mips/configs/it8172_defconfig
+++ b/arch/mips/configs/it8172_defconfig
@@ -117,7 +117,6 @@ CONFIG_PAGE_SIZE_4KB=y
117# CONFIG_MIPS_MT is not set 117# CONFIG_MIPS_MT is not set
118# CONFIG_CPU_ADVANCED is not set 118# CONFIG_CPU_ADVANCED is not set
119CONFIG_CPU_HAS_LLSC=y 119CONFIG_CPU_HAS_LLSC=y
120CONFIG_CPU_HAS_LLDSCD=y
121CONFIG_CPU_HAS_SYNC=y 120CONFIG_CPU_HAS_SYNC=y
122CONFIG_GENERIC_HARDIRQS=y 121CONFIG_GENERIC_HARDIRQS=y
123CONFIG_GENERIC_IRQ_PROBE=y 122CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ivr_defconfig b/arch/mips/configs/ivr_defconfig
index 138c8a60a4dc..71386938d47f 100644
--- a/arch/mips/configs/ivr_defconfig
+++ b/arch/mips/configs/ivr_defconfig
@@ -114,7 +114,6 @@ CONFIG_PAGE_SIZE_4KB=y
114# CONFIG_MIPS_MT is not set 114# CONFIG_MIPS_MT is not set
115# CONFIG_CPU_ADVANCED is not set 115# CONFIG_CPU_ADVANCED is not set
116CONFIG_CPU_HAS_LLSC=y 116CONFIG_CPU_HAS_LLSC=y
117CONFIG_CPU_HAS_LLDSCD=y
118CONFIG_CPU_HAS_SYNC=y 117CONFIG_CPU_HAS_SYNC=y
119CONFIG_GENERIC_HARDIRQS=y 118CONFIG_GENERIC_HARDIRQS=y
120CONFIG_GENERIC_IRQ_PROBE=y 119CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/jaguar-atx_defconfig b/arch/mips/configs/jaguar-atx_defconfig
index 6238e0d6a430..14fb46886708 100644
--- a/arch/mips/configs/jaguar-atx_defconfig
+++ b/arch/mips/configs/jaguar-atx_defconfig
@@ -124,7 +124,6 @@ CONFIG_CPU_HAS_PREFETCH=y
124# CONFIG_64BIT_PHYS_ADDR is not set 124# CONFIG_64BIT_PHYS_ADDR is not set
125# CONFIG_CPU_ADVANCED is not set 125# CONFIG_CPU_ADVANCED is not set
126CONFIG_CPU_HAS_LLSC=y 126CONFIG_CPU_HAS_LLSC=y
127CONFIG_CPU_HAS_LLDSCD=y
128CONFIG_CPU_HAS_SYNC=y 127CONFIG_CPU_HAS_SYNC=y
129CONFIG_GENERIC_HARDIRQS=y 128CONFIG_GENERIC_HARDIRQS=y
130CONFIG_GENERIC_IRQ_PROBE=y 129CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/lasat200_defconfig b/arch/mips/configs/lasat200_defconfig
index a7ad99b12fe5..6c5df76d48d9 100644
--- a/arch/mips/configs/lasat200_defconfig
+++ b/arch/mips/configs/lasat200_defconfig
@@ -121,7 +121,6 @@ CONFIG_R5000_CPU_SCACHE=y
121# CONFIG_64BIT_PHYS_ADDR is not set 121# CONFIG_64BIT_PHYS_ADDR is not set
122# CONFIG_CPU_ADVANCED is not set 122# CONFIG_CPU_ADVANCED is not set
123CONFIG_CPU_HAS_LLSC=y 123CONFIG_CPU_HAS_LLSC=y
124CONFIG_CPU_HAS_LLDSCD=y
125CONFIG_CPU_HAS_SYNC=y 124CONFIG_CPU_HAS_SYNC=y
126CONFIG_GENERIC_HARDIRQS=y 125CONFIG_GENERIC_HARDIRQS=y
127CONFIG_GENERIC_IRQ_PROBE=y 126CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index d1c44216f1c1..da0677a03c1d 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.15-rc2 3# Linux kernel version: 2.6.15-rc5
4# Thu Nov 24 01:06:35 2005 4# Fri Dec 23 02:21:03 2005
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -87,8 +87,8 @@ CONFIG_HAVE_STD_PC_SERIAL_PORT=y
87# 87#
88# CPU selection 88# CPU selection
89# 89#
90CONFIG_CPU_MIPS32_R1=y 90# CONFIG_CPU_MIPS32_R1 is not set
91# CONFIG_CPU_MIPS32_R2 is not set 91CONFIG_CPU_MIPS32_R2=y
92# CONFIG_CPU_MIPS64_R1 is not set 92# CONFIG_CPU_MIPS64_R1 is not set
93# CONFIG_CPU_MIPS64_R2 is not set 93# CONFIG_CPU_MIPS64_R2 is not set
94# CONFIG_CPU_R3000 is not set 94# CONFIG_CPU_R3000 is not set
@@ -112,7 +112,7 @@ CONFIG_SYS_HAS_CPU_MIPS64_R1=y
112CONFIG_SYS_HAS_CPU_NEVADA=y 112CONFIG_SYS_HAS_CPU_NEVADA=y
113CONFIG_SYS_HAS_CPU_RM7000=y 113CONFIG_SYS_HAS_CPU_RM7000=y
114CONFIG_CPU_MIPS32=y 114CONFIG_CPU_MIPS32=y
115CONFIG_CPU_MIPSR1=y 115CONFIG_CPU_MIPSR2=y
116CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 116CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
117CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y 117CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
118CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 118CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
diff --git a/arch/mips/configs/ocelot_3_defconfig b/arch/mips/configs/ocelot_3_defconfig
index 9081ea5a9dbd..7ad8718c1b69 100644
--- a/arch/mips/configs/ocelot_3_defconfig
+++ b/arch/mips/configs/ocelot_3_defconfig
@@ -122,7 +122,6 @@ CONFIG_CPU_HAS_PREFETCH=y
122# CONFIG_64BIT_PHYS_ADDR is not set 122# CONFIG_64BIT_PHYS_ADDR is not set
123# CONFIG_CPU_ADVANCED is not set 123# CONFIG_CPU_ADVANCED is not set
124CONFIG_CPU_HAS_LLSC=y 124CONFIG_CPU_HAS_LLSC=y
125CONFIG_CPU_HAS_LLDSCD=y
126CONFIG_CPU_HAS_SYNC=y 125CONFIG_CPU_HAS_SYNC=y
127CONFIG_GENERIC_HARDIRQS=y 126CONFIG_GENERIC_HARDIRQS=y
128CONFIG_GENERIC_IRQ_PROBE=y 127CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ocelot_c_defconfig b/arch/mips/configs/ocelot_c_defconfig
index 570fc4d18166..e8d6bb3551a2 100644
--- a/arch/mips/configs/ocelot_c_defconfig
+++ b/arch/mips/configs/ocelot_c_defconfig
@@ -118,7 +118,6 @@ CONFIG_RM7000_CPU_SCACHE=y
118CONFIG_CPU_HAS_PREFETCH=y 118CONFIG_CPU_HAS_PREFETCH=y
119# CONFIG_MIPS_MT is not set 119# CONFIG_MIPS_MT is not set
120CONFIG_CPU_HAS_LLSC=y 120CONFIG_CPU_HAS_LLSC=y
121CONFIG_CPU_HAS_LLDSCD=y
122CONFIG_CPU_HAS_SYNC=y 121CONFIG_CPU_HAS_SYNC=y
123CONFIG_GENERIC_HARDIRQS=y 122CONFIG_GENERIC_HARDIRQS=y
124CONFIG_GENERIC_IRQ_PROBE=y 123CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ocelot_defconfig b/arch/mips/configs/ocelot_defconfig
index 6634ab24715c..f3787b68bdd1 100644
--- a/arch/mips/configs/ocelot_defconfig
+++ b/arch/mips/configs/ocelot_defconfig
@@ -123,7 +123,6 @@ CONFIG_CPU_HAS_PREFETCH=y
123# CONFIG_64BIT_PHYS_ADDR is not set 123# CONFIG_64BIT_PHYS_ADDR is not set
124# CONFIG_CPU_ADVANCED is not set 124# CONFIG_CPU_ADVANCED is not set
125CONFIG_CPU_HAS_LLSC=y 125CONFIG_CPU_HAS_LLSC=y
126CONFIG_CPU_HAS_LLDSCD=y
127CONFIG_CPU_HAS_SYNC=y 126CONFIG_CPU_HAS_SYNC=y
128CONFIG_GENERIC_HARDIRQS=y 127CONFIG_GENERIC_HARDIRQS=y
129CONFIG_GENERIC_IRQ_PROBE=y 128CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/ocelot_g_defconfig
index 4c396e1e2f0a..b6126ad4d06d 100644
--- a/arch/mips/configs/ocelot_g_defconfig
+++ b/arch/mips/configs/ocelot_g_defconfig
@@ -121,7 +121,6 @@ CONFIG_RM7000_CPU_SCACHE=y
121CONFIG_CPU_HAS_PREFETCH=y 121CONFIG_CPU_HAS_PREFETCH=y
122# CONFIG_MIPS_MT is not set 122# CONFIG_MIPS_MT is not set
123CONFIG_CPU_HAS_LLSC=y 123CONFIG_CPU_HAS_LLSC=y
124CONFIG_CPU_HAS_LLDSCD=y
125CONFIG_CPU_HAS_SYNC=y 124CONFIG_CPU_HAS_SYNC=y
126CONFIG_GENERIC_HARDIRQS=y 125CONFIG_GENERIC_HARDIRQS=y
127CONFIG_GENERIC_IRQ_PROBE=y 126CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/pnx8550-v2pci_defconfig b/arch/mips/configs/pnx8550-v2pci_defconfig
index d9a0d2fdba4f..4c650e708133 100644
--- a/arch/mips/configs/pnx8550-v2pci_defconfig
+++ b/arch/mips/configs/pnx8550-v2pci_defconfig
@@ -116,7 +116,6 @@ CONFIG_CPU_HAS_PREFETCH=y
116# CONFIG_64BIT_PHYS_ADDR is not set 116# CONFIG_64BIT_PHYS_ADDR is not set
117CONFIG_CPU_ADVANCED=y 117CONFIG_CPU_ADVANCED=y
118CONFIG_CPU_HAS_LLSC=y 118CONFIG_CPU_HAS_LLSC=y
119# CONFIG_CPU_HAS_LLDSCD is not set
120# CONFIG_CPU_HAS_WB is not set 119# CONFIG_CPU_HAS_WB is not set
121CONFIG_CPU_HAS_SYNC=y 120CONFIG_CPU_HAS_SYNC=y
122CONFIG_GENERIC_HARDIRQS=y 121CONFIG_GENERIC_HARDIRQS=y
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbhma4500_defconfig
index 1cc145023584..9aaa43024aec 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbhma4500_defconfig
@@ -124,7 +124,6 @@ CONFIG_PAGE_SIZE_4KB=y
124# CONFIG_MIPS_MT is not set 124# CONFIG_MIPS_MT is not set
125CONFIG_CPU_ADVANCED=y 125CONFIG_CPU_ADVANCED=y
126CONFIG_CPU_HAS_LLSC=y 126CONFIG_CPU_HAS_LLSC=y
127CONFIG_CPU_HAS_LLDSCD=y
128CONFIG_CPU_HAS_WB=y 127CONFIG_CPU_HAS_WB=y
129CONFIG_CPU_HAS_SYNC=y 128CONFIG_CPU_HAS_SYNC=y
130CONFIG_GENERIC_HARDIRQS=y 129CONFIG_GENERIC_HARDIRQS=y
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index 30975b305ae5..abf61095931e 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -124,7 +124,6 @@ CONFIG_PAGE_SIZE_4KB=y
124# CONFIG_64BIT_PHYS_ADDR is not set 124# CONFIG_64BIT_PHYS_ADDR is not set
125# CONFIG_CPU_ADVANCED is not set 125# CONFIG_CPU_ADVANCED is not set
126CONFIG_CPU_HAS_LLSC=y 126CONFIG_CPU_HAS_LLSC=y
127CONFIG_CPU_HAS_LLDSCD=y
128CONFIG_CPU_HAS_SYNC=y 127CONFIG_CPU_HAS_SYNC=y
129CONFIG_GENERIC_HARDIRQS=y 128CONFIG_GENERIC_HARDIRQS=y
130CONFIG_GENERIC_IRQ_PROBE=y 129CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
index 63f1be18e9bf..52048c906079 100644
--- a/arch/mips/configs/sb1250-swarm_defconfig
+++ b/arch/mips/configs/sb1250-swarm_defconfig
@@ -133,7 +133,6 @@ CONFIG_CPU_HAS_PREFETCH=y
133# CONFIG_MIPS_MT is not set 133# CONFIG_MIPS_MT is not set
134CONFIG_SB1_PASS_1_WORKAROUNDS=y 134CONFIG_SB1_PASS_1_WORKAROUNDS=y
135CONFIG_CPU_HAS_LLSC=y 135CONFIG_CPU_HAS_LLSC=y
136CONFIG_CPU_HAS_LLDSCD=y
137CONFIG_CPU_HAS_SYNC=y 136CONFIG_CPU_HAS_SYNC=y
138CONFIG_GENERIC_HARDIRQS=y 137CONFIG_GENERIC_HARDIRQS=y
139CONFIG_GENERIC_IRQ_PROBE=y 138CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
index d51d5d16297c..468c2e443d71 100644
--- a/arch/mips/configs/yosemite_defconfig
+++ b/arch/mips/configs/yosemite_defconfig
@@ -118,7 +118,6 @@ CONFIG_CPU_HAS_PREFETCH=y
118# CONFIG_64BIT_PHYS_ADDR is not set 118# CONFIG_64BIT_PHYS_ADDR is not set
119# CONFIG_CPU_ADVANCED is not set 119# CONFIG_CPU_ADVANCED is not set
120CONFIG_CPU_HAS_LLSC=y 120CONFIG_CPU_HAS_LLSC=y
121CONFIG_CPU_HAS_LLDSCD=y
122CONFIG_CPU_HAS_SYNC=y 121CONFIG_CPU_HAS_SYNC=y
123CONFIG_GENERIC_HARDIRQS=y 122CONFIG_GENERIC_HARDIRQS=y
124CONFIG_GENERIC_IRQ_PROBE=y 123CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/defconfig b/arch/mips/defconfig
index 2a1b844da43f..4f125e9e8e0b 100644
--- a/arch/mips/defconfig
+++ b/arch/mips/defconfig
@@ -123,7 +123,6 @@ CONFIG_IP22_CPU_SCACHE=y
123# CONFIG_64BIT_PHYS_ADDR is not set 123# CONFIG_64BIT_PHYS_ADDR is not set
124# CONFIG_CPU_ADVANCED is not set 124# CONFIG_CPU_ADVANCED is not set
125CONFIG_CPU_HAS_LLSC=y 125CONFIG_CPU_HAS_LLSC=y
126CONFIG_CPU_HAS_LLDSCD=y
127CONFIG_CPU_HAS_SYNC=y 126CONFIG_CPU_HAS_SYNC=y
128CONFIG_GENERIC_HARDIRQS=y 127CONFIG_GENERIC_HARDIRQS=y
129CONFIG_GENERIC_IRQ_PROBE=y 128CONFIG_GENERIC_IRQ_PROBE=y
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 72f2126ad19d..f36c4f20ee8a 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -50,7 +50,7 @@ obj-$(CONFIG_MIPS_BOARDS_GEN) += irq-msc01.o
50obj-$(CONFIG_32BIT) += scall32-o32.o 50obj-$(CONFIG_32BIT) += scall32-o32.o
51obj-$(CONFIG_64BIT) += scall64-64.o 51obj-$(CONFIG_64BIT) += scall64-64.o
52obj-$(CONFIG_BINFMT_IRIX) += binfmt_irix.o 52obj-$(CONFIG_BINFMT_IRIX) += binfmt_irix.o
53obj-$(CONFIG_MIPS32_COMPAT) += ioctl32.o linux32.o signal32.o 53obj-$(CONFIG_MIPS32_COMPAT) += linux32.o signal32.o
54obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o 54obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o
55obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o ptrace32.o 55obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o ptrace32.o
56 56
@@ -60,6 +60,5 @@ obj-$(CONFIG_PROC_FS) += proc.o
60obj-$(CONFIG_64BIT) += cpu-bugs64.o 60obj-$(CONFIG_64BIT) += cpu-bugs64.o
61 61
62CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 62CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
63CFLAGS_ioctl32.o += -Ifs/
64 63
65EXTRA_AFLAGS := $(CFLAGS) 64EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 5e1b08b00a33..fac48ad27b34 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -435,6 +435,9 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
435 } 435 }
436} 436}
437 437
438static char unknown_isa[] __initdata = KERN_ERR \
439 "Unsupported ISA type, c0.config0: %d.";
440
438static inline unsigned int decode_config0(struct cpuinfo_mips *c) 441static inline unsigned int decode_config0(struct cpuinfo_mips *c)
439{ 442{
440 unsigned int config0; 443 unsigned int config0;
@@ -447,16 +450,37 @@ static inline unsigned int decode_config0(struct cpuinfo_mips *c)
447 isa = (config0 & MIPS_CONF_AT) >> 13; 450 isa = (config0 & MIPS_CONF_AT) >> 13;
448 switch (isa) { 451 switch (isa) {
449 case 0: 452 case 0:
450 c->isa_level = MIPS_CPU_ISA_M32; 453 switch ((config0 >> 10) & 7) {
454 case 0:
455 c->isa_level = MIPS_CPU_ISA_M32R1;
456 break;
457 case 1:
458 c->isa_level = MIPS_CPU_ISA_M32R2;
459 break;
460 default:
461 goto unknown;
462 }
451 break; 463 break;
452 case 2: 464 case 2:
453 c->isa_level = MIPS_CPU_ISA_M64; 465 switch ((config0 >> 10) & 7) {
466 case 0:
467 c->isa_level = MIPS_CPU_ISA_M64R1;
468 break;
469 case 1:
470 c->isa_level = MIPS_CPU_ISA_M64R2;
471 break;
472 default:
473 goto unknown;
474 }
454 break; 475 break;
455 default: 476 default:
456 panic("Unsupported ISA type, cp0.config0.at: %d.", isa); 477 goto unknown;
457 } 478 }
458 479
459 return config0 & MIPS_CONF_M; 480 return config0 & MIPS_CONF_M;
481
482unknown:
483 panic(unknown_isa, config0);
460} 484}
461 485
462static inline unsigned int decode_config1(struct cpuinfo_mips *c) 486static inline unsigned int decode_config1(struct cpuinfo_mips *c)
@@ -568,7 +592,6 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c)
568 break; 592 break;
569 case PRID_IMP_34K: 593 case PRID_IMP_34K:
570 c->cputype = CPU_34K; 594 c->cputype = CPU_34K;
571 c->isa_level = MIPS_CPU_ISA_M32;
572 break; 595 break;
573 } 596 }
574} 597}
@@ -647,7 +670,7 @@ static inline void cpu_probe_philips(struct cpuinfo_mips *c)
647 switch (c->processor_id & 0xff00) { 670 switch (c->processor_id & 0xff00) {
648 case PRID_IMP_PR4450: 671 case PRID_IMP_PR4450:
649 c->cputype = CPU_PR4450; 672 c->cputype = CPU_PR4450;
650 c->isa_level = MIPS_CPU_ISA_M32; 673 c->isa_level = MIPS_CPU_ISA_M32R1;
651 break; 674 break;
652 default: 675 default:
653 panic("Unknown Philips Core!"); /* REVISIT: die? */ 676 panic("Unknown Philips Core!"); /* REVISIT: die? */
@@ -690,8 +713,10 @@ __init void cpu_probe(void)
690 if (c->options & MIPS_CPU_FPU) { 713 if (c->options & MIPS_CPU_FPU) {
691 c->fpu_id = cpu_get_fpu_id(); 714 c->fpu_id = cpu_get_fpu_id();
692 715
693 if (c->isa_level == MIPS_CPU_ISA_M32 || 716 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
694 c->isa_level == MIPS_CPU_ISA_M64) { 717 c->isa_level == MIPS_CPU_ISA_M32R2 ||
718 c->isa_level == MIPS_CPU_ISA_M64R1 ||
719 c->isa_level == MIPS_CPU_ISA_M64R2) {
695 if (c->fpu_id & MIPS_FPIR_3D) 720 if (c->fpu_id & MIPS_FPIR_3D)
696 c->ases |= MIPS_ASE_MIPS3D; 721 c->ases |= MIPS_ASE_MIPS3D;
697 } 722 }
diff --git a/arch/mips/kernel/ioctl32.c b/arch/mips/kernel/ioctl32.c
deleted file mode 100644
index 9ea1fc748864..000000000000
--- a/arch/mips/kernel/ioctl32.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 2000 Silicon Graphics, Inc.
5 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
6 * Copyright (C) 2000, 2004 Ralf Baechle
7 * Copyright (C) 2002, 2003 Maciej W. Rozycki
8 */
9#define INCLUDES
10#include "compat_ioctl.c"
11
12#include <linux/config.h>
13#include <linux/types.h>
14#include <linux/compat.h>
15#include <linux/ioctl32.h>
16#include <linux/syscalls.h>
17
18#ifdef CONFIG_SIBYTE_TBPROF
19#include <asm/sibyte/trace_prof.h>
20#endif
21
22#define A(__x) ((unsigned long)(__x))
23
24long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
25
26#define CODE
27#include "compat_ioctl.c"
28
29#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
30#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
31#define IOCTL_TABLE_START \
32 struct ioctl_trans ioctl_start[] = {
33#define IOCTL_TABLE_END \
34 };
35
36IOCTL_TABLE_START
37
38#include <linux/compat_ioctl.h>
39#define DECLARES
40#include "compat_ioctl.c"
41
42/*HANDLE_IOCTL(RTC_IRQP_READ, w_long)
43COMPATIBLE_IOCTL(RTC_IRQP_SET)
44HANDLE_IOCTL(RTC_EPOCH_READ, w_long)
45COMPATIBLE_IOCTL(RTC_EPOCH_SET)
46*/
47
48IOCTL_TABLE_END
49
50int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index dd725779d91f..fa98f10d0132 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -140,12 +140,12 @@ void flush_thread(void)
140int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, 140int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
141 unsigned long unused, struct task_struct *p, struct pt_regs *regs) 141 unsigned long unused, struct task_struct *p, struct pt_regs *regs)
142{ 142{
143 struct thread_info *ti = p->thread_info; 143 struct thread_info *ti = task_thread_info(p);
144 struct pt_regs *childregs; 144 struct pt_regs *childregs;
145 long childksp; 145 long childksp;
146 p->set_child_tid = p->clear_child_tid = NULL; 146 p->set_child_tid = p->clear_child_tid = NULL;
147 147
148 childksp = (unsigned long)ti + THREAD_SIZE - 32; 148 childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
149 149
150 preempt_disable(); 150 preempt_disable();
151 151
@@ -205,7 +205,7 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
205 return 1; 205 return 1;
206} 206}
207 207
208void dump_regs(elf_greg_t *gp, struct pt_regs *regs) 208void elf_dump_regs(elf_greg_t *gp, struct pt_regs *regs)
209{ 209{
210 int i; 210 int i;
211 211
@@ -229,9 +229,7 @@ void dump_regs(elf_greg_t *gp, struct pt_regs *regs)
229 229
230int dump_task_regs (struct task_struct *tsk, elf_gregset_t *regs) 230int dump_task_regs (struct task_struct *tsk, elf_gregset_t *regs)
231{ 231{
232 struct thread_info *ti = tsk->thread_info; 232 elf_dump_regs(*regs, task_pt_regs(tsk));
233 long ksp = (unsigned long)ti + THREAD_SIZE - 32;
234 dump_regs(&(*regs)[0], (struct pt_regs *) ksp - 1);
235 return 1; 233 return 1;
236} 234}
237 235
@@ -409,7 +407,7 @@ unsigned long get_wchan(struct task_struct *p)
409 if (!p || p == current || p->state == TASK_RUNNING) 407 if (!p || p == current || p->state == TASK_RUNNING)
410 return 0; 408 return 0;
411 409
412 stack_page = (unsigned long)p->thread_info; 410 stack_page = (unsigned long)task_stack_page(p);
413 if (!stack_page || !mips_frame_info_initialized) 411 if (!stack_page || !mips_frame_info_initialized)
414 return 0; 412 return 0;
415 413
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 510da5fda567..f838b36cc765 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -64,8 +64,7 @@ int ptrace_getregs (struct task_struct *child, __s64 __user *data)
64 if (!access_ok(VERIFY_WRITE, data, 38 * 8)) 64 if (!access_ok(VERIFY_WRITE, data, 38 * 8))
65 return -EIO; 65 return -EIO;
66 66
67 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 67 regs = task_pt_regs(child);
68 THREAD_SIZE - 32 - sizeof(struct pt_regs));
69 68
70 for (i = 0; i < 32; i++) 69 for (i = 0; i < 32; i++)
71 __put_user (regs->regs[i], data + i); 70 __put_user (regs->regs[i], data + i);
@@ -92,8 +91,7 @@ int ptrace_setregs (struct task_struct *child, __s64 __user *data)
92 if (!access_ok(VERIFY_READ, data, 38 * 8)) 91 if (!access_ok(VERIFY_READ, data, 38 * 8))
93 return -EIO; 92 return -EIO;
94 93
95 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 94 regs = task_pt_regs(child);
96 THREAD_SIZE - 32 - sizeof(struct pt_regs));
97 95
98 for (i = 0; i < 32; i++) 96 for (i = 0; i < 32; i++)
99 __get_user (regs->regs[i], data + i); 97 __get_user (regs->regs[i], data + i);
@@ -198,8 +196,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
198 struct pt_regs *regs; 196 struct pt_regs *regs;
199 unsigned long tmp = 0; 197 unsigned long tmp = 0;
200 198
201 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 199 regs = task_pt_regs(child);
202 THREAD_SIZE - 32 - sizeof(struct pt_regs));
203 ret = 0; /* Default return value. */ 200 ret = 0; /* Default return value. */
204 201
205 switch (addr) { 202 switch (addr) {
@@ -280,12 +277,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
280 ret = -EIO; 277 ret = -EIO;
281 goto out; 278 goto out;
282 } 279 }
283 if (child->thread.dsp.used_dsp) { 280 dregs = __get_dsp_regs(child);
284 dregs = __get_dsp_regs(child); 281 tmp = (unsigned long) (dregs[addr - DSP_BASE]);
285 tmp = (unsigned long) (dregs[addr - DSP_BASE]);
286 } else {
287 tmp = -1; /* DSP registers yet used */
288 }
289 break; 282 break;
290 } 283 }
291 case DSP_CONTROL: 284 case DSP_CONTROL:
@@ -318,8 +311,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
318 case PTRACE_POKEUSR: { 311 case PTRACE_POKEUSR: {
319 struct pt_regs *regs; 312 struct pt_regs *regs;
320 ret = 0; 313 ret = 0;
321 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 314 regs = task_pt_regs(child);
322 THREAD_SIZE - 32 - sizeof(struct pt_regs));
323 315
324 switch (addr) { 316 switch (addr) {
325 case 0 ... 31: 317 case 0 ... 31:
@@ -446,7 +438,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
446 break; 438 break;
447 439
448 case PTRACE_GET_THREAD_AREA: 440 case PTRACE_GET_THREAD_AREA:
449 ret = put_user(child->thread_info->tp_value, 441 ret = put_user(task_thread_info(child)->tp_value,
450 (unsigned long __user *) data); 442 (unsigned long __user *) data);
451 break; 443 break;
452 444
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index 7e55457a491f..0c82b25d8c6d 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -126,8 +126,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
126 struct pt_regs *regs; 126 struct pt_regs *regs;
127 unsigned int tmp; 127 unsigned int tmp;
128 128
129 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 129 regs = task_pt_regs(child);
130 THREAD_SIZE - 32 - sizeof(struct pt_regs));
131 ret = 0; /* Default return value. */ 130 ret = 0; /* Default return value. */
132 131
133 switch (addr) { 132 switch (addr) {
@@ -201,12 +200,8 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
201 ret = -EIO; 200 ret = -EIO;
202 goto out_tsk; 201 goto out_tsk;
203 } 202 }
204 if (child->thread.dsp.used_dsp) { 203 dspreg_t *dregs = __get_dsp_regs(child);
205 dspreg_t *dregs = __get_dsp_regs(child); 204 tmp = (unsigned long) (dregs[addr - DSP_BASE]);
206 tmp = (unsigned long) (dregs[addr - DSP_BASE]);
207 } else {
208 tmp = -1; /* DSP registers yet used */
209 }
210 break; 205 break;
211 case DSP_CONTROL: 206 case DSP_CONTROL:
212 if (!cpu_has_dsp) { 207 if (!cpu_has_dsp) {
@@ -263,8 +258,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
263 case PTRACE_POKEUSR: { 258 case PTRACE_POKEUSR: {
264 struct pt_regs *regs; 259 struct pt_regs *regs;
265 ret = 0; 260 ret = 0;
266 regs = (struct pt_regs *) ((unsigned long) child->thread_info + 261 regs = task_pt_regs(child);
267 THREAD_SIZE - 32 - sizeof(struct pt_regs));
268 262
269 switch (addr) { 263 switch (addr) {
270 case 0 ... 31: 264 case 0 ... 31:
@@ -381,7 +375,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
381 break; 375 break;
382 376
383 case PTRACE_GET_THREAD_AREA: 377 case PTRACE_GET_THREAD_AREA:
384 ret = put_user(child->thread_info->tp_value, 378 ret = put_user(task_thread_info(child)->tp_value,
385 (unsigned int __user *) (unsigned long) data); 379 (unsigned int __user *) (unsigned long) data);
386 break; 380 break;
387 381
@@ -395,7 +389,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
395 break; 389 break;
396 390
397 case PTRACE_GET_THREAD_AREA_3264: 391 case PTRACE_GET_THREAD_AREA_3264:
398 ret = put_user(child->thread_info->tp_value, 392 ret = put_user(task_thread_info(child)->tp_value,
399 (unsigned long __user *) (unsigned long) data); 393 (unsigned long __user *) (unsigned long) data);
400 break; 394 break;
401 395
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index c856dbc52abb..98b185bbc947 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -588,7 +588,7 @@ static inline int setup_sigcontext32(struct pt_regs *regs,
588 err |= __put_user(regs->hi, &sc->sc_mdhi); 588 err |= __put_user(regs->hi, &sc->sc_mdhi);
589 err |= __put_user(regs->lo, &sc->sc_mdlo); 589 err |= __put_user(regs->lo, &sc->sc_mdlo);
590 if (cpu_has_dsp) { 590 if (cpu_has_dsp) {
591 err |= __put_user(rddsp(DSP_MASK), &sc->sc_hi1); 591 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
592 err |= __put_user(mfhi1(), &sc->sc_hi1); 592 err |= __put_user(mfhi1(), &sc->sc_hi1);
593 err |= __put_user(mflo1(), &sc->sc_lo1); 593 err |= __put_user(mflo1(), &sc->sc_lo1);
594 err |= __put_user(mfhi2(), &sc->sc_hi2); 594 err |= __put_user(mfhi2(), &sc->sc_hi2);
diff --git a/arch/mips/kernel/smp_mt.c b/arch/mips/kernel/smp_mt.c
index d429544ba4bc..794a1c3de2a4 100644
--- a/arch/mips/kernel/smp_mt.c
+++ b/arch/mips/kernel/smp_mt.c
@@ -287,6 +287,7 @@ void prom_prepare_cpus(unsigned int max_cpus)
287 */ 287 */
288void prom_boot_secondary(int cpu, struct task_struct *idle) 288void prom_boot_secondary(int cpu, struct task_struct *idle)
289{ 289{
290 struct thread_info *gp = task_thread_info(idle);
290 dvpe(); 291 dvpe();
291 set_c0_mvpcontrol(MVPCONTROL_VPC); 292 set_c0_mvpcontrol(MVPCONTROL_VPC);
292 293
@@ -307,11 +308,9 @@ void prom_boot_secondary(int cpu, struct task_struct *idle)
307 write_tc_gpr_sp( __KSTK_TOS(idle)); 308 write_tc_gpr_sp( __KSTK_TOS(idle));
308 309
309 /* global pointer */ 310 /* global pointer */
310 write_tc_gpr_gp((unsigned long)idle->thread_info); 311 write_tc_gpr_gp((unsigned long)gp);
311 312
312 flush_icache_range((unsigned long)idle->thread_info, 313 flush_icache_range((unsigned long)gp, (unsigned long)(gp + 1));
313 (unsigned long)idle->thread_info +
314 sizeof(struct thread_info));
315 314
316 /* finally out of configuration and into chaos */ 315 /* finally out of configuration and into chaos */
317 clear_c0_mvpcontrol(MVPCONTROL_VPC); 316 clear_c0_mvpcontrol(MVPCONTROL_VPC);
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index ee98eeb65e85..332358430ff5 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/a.out.h> 11#include <linux/a.out.h>
12#include <linux/capability.h>
12#include <linux/errno.h> 13#include <linux/errno.h>
13#include <linux/linkage.h> 14#include <linux/linkage.h>
14#include <linux/mm.h> 15#include <linux/mm.h>
@@ -262,7 +263,7 @@ asmlinkage int sys_olduname(struct oldold_utsname * name)
262 263
263void sys_set_thread_area(unsigned long addr) 264void sys_set_thread_area(unsigned long addr)
264{ 265{
265 struct thread_info *ti = current->thread_info; 266 struct thread_info *ti = task_thread_info(current);
266 267
267 ti->tp_value = addr; 268 ti->tp_value = addr;
268 269
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index 52924f8ce23c..0fc3730a294f 100644
--- a/arch/mips/kernel/sysirix.c
+++ b/arch/mips/kernel/sysirix.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/binfmts.h> 10#include <linux/binfmts.h>
11#include <linux/capability.h>
11#include <linux/highuid.h> 12#include <linux/highuid.h>
12#include <linux/pagemap.h> 13#include <linux/pagemap.h>
13#include <linux/mm.h> 14#include <linux/mm.h>
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 787ed541d442..7050b4ffffcd 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -507,14 +507,38 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
507 return IRQ_HANDLED; 507 return IRQ_HANDLED;
508} 508}
509 509
510int null_perf_irq(struct pt_regs *regs)
511{
512 return 0;
513}
514
515int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
516
517EXPORT_SYMBOL(null_perf_irq);
518EXPORT_SYMBOL(perf_irq);
519
510asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs) 520asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs)
511{ 521{
522 int r2 = cpu_has_mips_r2;
523
512 irq_enter(); 524 irq_enter();
513 kstat_this_cpu.irqs[irq]++; 525 kstat_this_cpu.irqs[irq]++;
514 526
527 /*
528 * Suckage alert:
529 * Before R2 of the architecture there was no way to see if a
530 * performance counter interrupt was pending, so we have to run the
531 * performance counter interrupt handler anyway.
532 */
533 if (!r2 || (read_c0_cause() & (1 << 26)))
534 if (perf_irq(regs))
535 goto out;
536
515 /* we keep interrupt disabled all the time */ 537 /* we keep interrupt disabled all the time */
516 timer_interrupt(irq, NULL, regs); 538 if (!r2 || (read_c0_cause() & (1 << 30)))
539 timer_interrupt(irq, NULL, regs);
517 540
541out:
518 irq_exit(); 542 irq_exit();
519} 543}
520 544
@@ -628,9 +652,9 @@ void __init time_init(void)
628 mips_hpt_init = c0_hpt_init; 652 mips_hpt_init = c0_hpt_init;
629 } 653 }
630 654
631 if ((current_cpu_data.isa_level == MIPS_CPU_ISA_M32) || 655 if (cpu_has_mips32r1 || cpu_has_mips32r2 ||
632 (current_cpu_data.isa_level == MIPS_CPU_ISA_I) || 656 (current_cpu_data.isa_level == MIPS_CPU_ISA_I) ||
633 (current_cpu_data.isa_level == MIPS_CPU_ISA_II)) 657 (current_cpu_data.isa_level == MIPS_CPU_ISA_II))
634 /* 658 /*
635 * We need to calibrate the counter but we don't have 659 * We need to calibrate the counter but we don't have
636 * 64-bit division. 660 * 64-bit division.
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 7058893d5ad2..59a187956de0 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -519,7 +519,7 @@ static inline int simulate_llsc(struct pt_regs *regs)
519 */ 519 */
520static inline int simulate_rdhwr(struct pt_regs *regs) 520static inline int simulate_rdhwr(struct pt_regs *regs)
521{ 521{
522 struct thread_info *ti = current->thread_info; 522 struct thread_info *ti = task_thread_info(current);
523 unsigned int opcode; 523 unsigned int opcode;
524 524
525 if (unlikely(get_insn_opcode(regs, &opcode))) 525 if (unlikely(get_insn_opcode(regs, &opcode)))
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 9c89eebc356f..ae83b755cf4a 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -99,9 +99,9 @@ struct vpe {
99 99
100 /* elfloader stuff */ 100 /* elfloader stuff */
101 void *load_addr; 101 void *load_addr;
102 u32 len; 102 unsigned long len;
103 char *pbuffer; 103 char *pbuffer;
104 u32 plen; 104 unsigned long plen;
105 105
106 unsigned long __start; 106 unsigned long __start;
107 107
@@ -253,11 +253,11 @@ void dump_mtregs(void)
253} 253}
254 254
255/* Find some VPE program space */ 255/* Find some VPE program space */
256static void *alloc_progmem(u32 len) 256static void *alloc_progmem(unsigned long len)
257{ 257{
258#ifdef CONFIG_MIPS_VPE_LOADER_TOM 258#ifdef CONFIG_MIPS_VPE_LOADER_TOM
259 /* this means you must tell linux to use less memory than you physically have */ 259 /* this means you must tell linux to use less memory than you physically have */
260 return (void *)((max_pfn * PAGE_SIZE) + KSEG0); 260 return pfn_to_kaddr(max_pfn);
261#else 261#else
262 // simple grab some mem for now 262 // simple grab some mem for now
263 return kmalloc(len, GFP_KERNEL); 263 return kmalloc(len, GFP_KERNEL);
diff --git a/arch/mips/lib/iomap.c b/arch/mips/lib/iomap.c
index b5d5fa833762..7e2ced715cfb 100644
--- a/arch/mips/lib/iomap.c
+++ b/arch/mips/lib/iomap.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * This code is based on lib/iomap.c, by Linus Torvalds. 4 * This code is based on lib/iomap.c, by Linus Torvalds.
5 * 5 *
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/math-emu/dp_fint.c b/arch/mips/math-emu/dp_fint.c
index 0065deaee24b..a1962eb460f8 100644
--- a/arch/mips/math-emu/dp_fint.c
+++ b/arch/mips/math-emu/dp_fint.c
@@ -33,8 +33,6 @@ ieee754dp ieee754dp_fint(int x)
33 33
34 CLEARCX; 34 CLEARCX;
35 35
36 xc = ( 0 ? xc : xc );
37
38 if (x == 0) 36 if (x == 0)
39 return ieee754dp_zero(0); 37 return ieee754dp_zero(0);
40 if (x == 1 || x == -1) 38 if (x == 1 || x == -1)
diff --git a/arch/mips/math-emu/dp_flong.c b/arch/mips/math-emu/dp_flong.c
index cb105b1dd860..eae90a866aa1 100644
--- a/arch/mips/math-emu/dp_flong.c
+++ b/arch/mips/math-emu/dp_flong.c
@@ -33,8 +33,6 @@ ieee754dp ieee754dp_flong(s64 x)
33 33
34 CLEARCX; 34 CLEARCX;
35 35
36 xc = ( 0 ? xc : xc );
37
38 if (x == 0) 36 if (x == 0)
39 return ieee754dp_zero(0); 37 return ieee754dp_zero(0);
40 if (x == 1 || x == -1) 38 if (x == 1 || x == -1)
diff --git a/arch/mips/math-emu/sp_fint.c b/arch/mips/math-emu/sp_fint.c
index 42d9ed4b9a94..7aac13afb09a 100644
--- a/arch/mips/math-emu/sp_fint.c
+++ b/arch/mips/math-emu/sp_fint.c
@@ -33,8 +33,6 @@ ieee754sp ieee754sp_fint(int x)
33 33
34 CLEARCX; 34 CLEARCX;
35 35
36 xc = ( 0 ? xc : xc );
37
38 if (x == 0) 36 if (x == 0)
39 return ieee754sp_zero(0); 37 return ieee754sp_zero(0);
40 if (x == 1 || x == -1) 38 if (x == 1 || x == -1)
diff --git a/arch/mips/math-emu/sp_flong.c b/arch/mips/math-emu/sp_flong.c
index 1e26795ccecb..3d6c1d11c178 100644
--- a/arch/mips/math-emu/sp_flong.c
+++ b/arch/mips/math-emu/sp_flong.c
@@ -33,8 +33,6 @@ ieee754sp ieee754sp_flong(s64 x)
33 33
34 CLEARCX; 34 CLEARCX;
35 35
36 xc = ( 0 ? xc : xc );
37
38 if (x == 0) 36 if (x == 0)
39 return ieee754sp_zero(0); 37 return ieee754sp_zero(0);
40 if (x == 1 || x == -1) 38 if (x == 1 || x == -1)
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 72a12d931cba..93f3bf2c2b22 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -75,20 +75,31 @@ static void mips_timer_dispatch (struct pt_regs *regs)
75 do_IRQ (mips_cpu_timer_irq, regs); 75 do_IRQ (mips_cpu_timer_irq, regs);
76} 76}
77 77
78extern int null_perf_irq(struct pt_regs *regs);
79
80extern int (*perf_irq)(struct pt_regs *regs);
81
78irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 82irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
79{ 83{
80#ifdef CONFIG_SMP 84 int r2 = cpu_has_mips_r2;
81 int cpu = smp_processor_id(); 85 int cpu = smp_processor_id();
82 86
83 if (cpu == 0) { 87 if (cpu == 0) {
84 /* 88 /*
85 * CPU 0 handles the global timer interrupt job and process accounting 89 * CPU 0 handles the global timer interrupt job and process
86 * resets count/compare registers to trigger next timer int. 90 * accounting resets count/compare registers to trigger next
91 * timer int.
87 */ 92 */
88 (void) timer_interrupt(irq, dev_id, regs); 93 if (!r2 || (read_c0_cause() & (1 << 26)))
94 if (perf_irq(regs))
95 goto out;
96
97 /* we keep interrupt disabled all the time */
98 if (!r2 || (read_c0_cause() & (1 << 30)))
99 timer_interrupt(irq, NULL, regs);
100
89 scroll_display_message(); 101 scroll_display_message();
90 } 102 } else {
91 else {
92 /* Everyone else needs to reset the timer int here as 103 /* Everyone else needs to reset the timer int here as
93 ll_local_timer_interrupt doesn't */ 104 ll_local_timer_interrupt doesn't */
94 /* 105 /*
@@ -103,16 +114,8 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
103 local_timer_interrupt (irq, dev_id, regs); 114 local_timer_interrupt (irq, dev_id, regs);
104 } 115 }
105 116
117out:
106 return IRQ_HANDLED; 118 return IRQ_HANDLED;
107#else
108 irqreturn_t r;
109
110 r = timer_interrupt(irq, dev_id, regs);
111
112 scroll_display_message();
113
114 return r;
115#endif
116} 119}
117 120
118/* 121/*
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 38223b44d962..422b55fab07a 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -1183,8 +1183,8 @@ static void __init setup_scache(void)
1183 if (!sc_present) 1183 if (!sc_present)
1184 return; 1184 return;
1185 1185
1186 if ((c->isa_level == MIPS_CPU_ISA_M32 || 1186 if ((c->isa_level == MIPS_CPU_ISA_M32R1 ||
1187 c->isa_level == MIPS_CPU_ISA_M64) && 1187 c->isa_level == MIPS_CPU_ISA_M64R1) &&
1188 !(c->scache.flags & MIPS_CACHE_NOT_PRESENT)) 1188 !(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
1189 panic("Dunno how to handle MIPS32 / MIPS64 second level cache"); 1189 panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
1190 1190
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index dd2cc42f1b6d..53f9889b30ed 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -75,7 +75,10 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
75 int res; 75 int res;
76 76
77 switch (current_cpu_data.cputype) { 77 switch (current_cpu_data.cputype) {
78 case CPU_5KC:
79 case CPU_20KC:
78 case CPU_24K: 80 case CPU_24K:
81 case CPU_25KF:
79 lmodel = &op_model_mipsxx; 82 lmodel = &op_model_mipsxx;
80 break; 83 break;
81 84
diff --git a/arch/mips/oprofile/op_impl.h b/arch/mips/oprofile/op_impl.h
index f0121557047d..5cfce7d87a4d 100644
--- a/arch/mips/oprofile/op_impl.h
+++ b/arch/mips/oprofile/op_impl.h
@@ -12,8 +12,8 @@
12 12
13struct pt_regs; 13struct pt_regs;
14 14
15extern void null_perf_irq(struct pt_regs *regs); 15extern int null_perf_irq(struct pt_regs *regs);
16extern void (*perf_irq)(struct pt_regs *regs); 16extern int (*perf_irq)(struct pt_regs *regs);
17 17
18/* Per-counter configuration as set via oprofilefs. */ 18/* Per-counter configuration as set via oprofilefs. */
19struct op_counter_config { 19struct op_counter_config {
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index d36b64dfcb2f..1d1eee407faf 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -114,11 +114,12 @@ static void mipsxx_cpu_stop(void *args)
114 } 114 }
115} 115}
116 116
117static void mipsxx_perfcount_handler(struct pt_regs *regs) 117static int mipsxx_perfcount_handler(struct pt_regs *regs)
118{ 118{
119 unsigned int counters = op_model_mipsxx.num_counters; 119 unsigned int counters = op_model_mipsxx.num_counters;
120 unsigned int control; 120 unsigned int control;
121 unsigned int counter; 121 unsigned int counter;
122 int handled = 0;
122 123
123 switch (counters) { 124 switch (counters) {
124#define HANDLE_COUNTER(n) \ 125#define HANDLE_COUNTER(n) \
@@ -129,12 +130,15 @@ static void mipsxx_perfcount_handler(struct pt_regs *regs)
129 (counter & M_COUNTER_OVERFLOW)) { \ 130 (counter & M_COUNTER_OVERFLOW)) { \
130 oprofile_add_sample(regs, n); \ 131 oprofile_add_sample(regs, n); \
131 write_c0_perfcntr ## n(reg.counter[n]); \ 132 write_c0_perfcntr ## n(reg.counter[n]); \
133 handled = 1; \
132 } 134 }
133 HANDLE_COUNTER(3) 135 HANDLE_COUNTER(3)
134 HANDLE_COUNTER(2) 136 HANDLE_COUNTER(2)
135 HANDLE_COUNTER(1) 137 HANDLE_COUNTER(1)
136 HANDLE_COUNTER(0) 138 HANDLE_COUNTER(0)
137 } 139 }
140
141 return handled;
138} 142}
139 143
140#define M_CONFIG1_PC (1 << 4) 144#define M_CONFIG1_PC (1 << 4)
@@ -176,17 +180,31 @@ static int __init mipsxx_init(void)
176 int counters; 180 int counters;
177 181
178 counters = n_counters(); 182 counters = n_counters();
179 if (counters == 0) 183 if (counters == 0) {
184 printk(KERN_ERR "Oprofile: CPU has no performance counters\n");
180 return -ENODEV; 185 return -ENODEV;
186 }
181 187
182 reset_counters(counters); 188 reset_counters(counters);
183 189
184 op_model_mipsxx.num_counters = counters; 190 op_model_mipsxx.num_counters = counters;
185 switch (current_cpu_data.cputype) { 191 switch (current_cpu_data.cputype) {
192 case CPU_20KC:
193 op_model_mipsxx.cpu_type = "mips/20K";
194 break;
195
186 case CPU_24K: 196 case CPU_24K:
187 op_model_mipsxx.cpu_type = "mips/24K"; 197 op_model_mipsxx.cpu_type = "mips/24K";
188 break; 198 break;
189 199
200 case CPU_25KF:
201 op_model_mipsxx.cpu_type = "mips/25K";
202 break;
203
204 case CPU_5KC:
205 op_model_mipsxx.cpu_type = "mips/5K";
206 break;
207
190 default: 208 default:
191 printk(KERN_ERR "Profiling unsupported for this CPU\n"); 209 printk(KERN_ERR "Profiling unsupported for this CPU\n");
192 210
diff --git a/arch/mips/pci/fixup-capcella.c b/arch/mips/pci/fixup-capcella.c
index f2fc82c1c7c5..1e530751936c 100644
--- a/arch/mips/pci/fixup-capcella.c
+++ b/arch/mips/pci/fixup-capcella.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-cappcela.c, The ZAO Networks Capcella specific PCI fixups. 2 * fixup-cappcela.c, The ZAO Networks Capcella specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002,2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002,2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-mpc30x.c b/arch/mips/pci/fixup-mpc30x.c
index 4975846da75a..b67ddaa47122 100644
--- a/arch/mips/pci/fixup-mpc30x.c
+++ b/arch/mips/pci/fixup-mpc30x.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-mpc30x.c, The Victor MP-C303/304 specific PCI fixups. 2 * fixup-mpc30x.c, The Victor MP-C303/304 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002,2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002,2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0219.c b/arch/mips/pci/fixup-tb0219.c
index bc55b06e1904..734f2b71e164 100644
--- a/arch/mips/pci/fixup-tb0219.c
+++ b/arch/mips/pci/fixup-tb0219.c
@@ -2,7 +2,7 @@
2 * fixup-tb0219.c, The TANBAC TB0219 specific PCI fixups. 2 * fixup-tb0219.c, The TANBAC TB0219 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp> 4 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp>
5 * Copyright (C) 2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 5 * Copyright (C) 2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0226.c b/arch/mips/pci/fixup-tb0226.c
index b5d42b12de10..c9e7cb4361a1 100644
--- a/arch/mips/pci/fixup-tb0226.c
+++ b/arch/mips/pci/fixup-tb0226.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups. 2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0287.c b/arch/mips/pci/fixup-tb0287.c
index 8436d7f1fdb2..fbe6bcb28199 100644
--- a/arch/mips/pci/fixup-tb0287.c
+++ b/arch/mips/pci/fixup-tb0287.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups. 2 * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/ops-vr41xx.c b/arch/mips/pci/ops-vr41xx.c
index 430429b22ae1..900c6b32576c 100644
--- a/arch/mips/pci/ops-vr41xx.c
+++ b/arch/mips/pci/ops-vr41xx.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/pci-vr41xx.c b/arch/mips/pci/pci-vr41xx.c
index 91df4da7ddb9..9885fa403603 100644
--- a/arch/mips/pci/pci-vr41xx.c
+++ b/arch/mips/pci/pci-vr41xx.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/mips/pci/pci-vr41xx.h b/arch/mips/pci/pci-vr41xx.h
index e087ec55641d..8a35e32b8376 100644
--- a/arch/mips/pci/pci-vr41xx.h
+++ b/arch/mips/pci/pci-vr41xx.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002 MontaVista Software Inc. 4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index 0527170d6adb..f17f575f58f0 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -93,8 +93,8 @@ void __init prom_prepare_cpus(unsigned int max_cpus)
93 */ 93 */
94void prom_boot_secondary(int cpu, struct task_struct *idle) 94void prom_boot_secondary(int cpu, struct task_struct *idle)
95{ 95{
96 unsigned long gp = (unsigned long) idle->thread_info; 96 unsigned long gp = (unsigned long) task_thread_info(idle);
97 unsigned long sp = gp + THREAD_SIZE - 32; 97 unsigned long sp = __KSTK_TOP(idle);
98 98
99 secondary_sp = sp; 99 secondary_sp = sp;
100 secondary_gp = gp; 100 secondary_gp = gp;
diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c
index 3a8291b7d26d..dbef3f6b5650 100644
--- a/arch/mips/sgi-ip27/ip27-smp.c
+++ b/arch/mips/sgi-ip27/ip27-smp.c
@@ -168,8 +168,8 @@ void __init prom_prepare_cpus(unsigned int max_cpus)
168 */ 168 */
169void __init prom_boot_secondary(int cpu, struct task_struct *idle) 169void __init prom_boot_secondary(int cpu, struct task_struct *idle)
170{ 170{
171 unsigned long gp = (unsigned long) idle->thread_info; 171 unsigned long gp = (unsigned long)task_thread_info(idle);
172 unsigned long sp = gp + THREAD_SIZE - 32; 172 unsigned long sp = __KSTK_TOS(idle);
173 173
174 LAUNCH_SLAVE(cputonasid(cpu),cputoslice(cpu), 174 LAUNCH_SLAVE(cputonasid(cpu),cputoslice(cpu),
175 (launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap), 175 (launch_proc_t)MAPPED_KERN_RW_TO_K0(smp_bootstrap),
diff --git a/arch/mips/sibyte/cfe/smp.c b/arch/mips/sibyte/cfe/smp.c
index e8485124b8fc..4477af3d8074 100644
--- a/arch/mips/sibyte/cfe/smp.c
+++ b/arch/mips/sibyte/cfe/smp.c
@@ -60,7 +60,7 @@ void prom_boot_secondary(int cpu, struct task_struct *idle)
60 60
61 retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap, 61 retval = cfe_cpu_start(cpu_logical_map(cpu), &smp_bootstrap,
62 __KSTK_TOS(idle), 62 __KSTK_TOS(idle),
63 (unsigned long)idle->thread_info, 0); 63 (unsigned long)task_thread_info(idle), 0);
64 if (retval != 0) 64 if (retval != 0)
65 printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval); 65 printk("cfe_start_cpu(%i) returned %i\n" , cpu, retval);
66} 66}
diff --git a/arch/mips/vr41xx/casio-e55/setup.c b/arch/mips/vr41xx/casio-e55/setup.c
index d29201acc4f3..814900915c28 100644
--- a/arch/mips/vr41xx/casio-e55/setup.c
+++ b/arch/mips/vr41xx/casio-e55/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * setup.c, Setup for the CASIO CASSIOPEIA E-11/15/55/65. 2 * setup.c, Setup for the CASIO CASSIOPEIA E-11/15/55/65.
3 * 3 *
4 * Copyright (C) 2002-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/bcu.c b/arch/mips/vr41xx/common/bcu.c
index cdfa4273a1c5..de0c1b35f11c 100644
--- a/arch/mips/vr41xx/common/bcu.c
+++ b/arch/mips/vr41xx/common/bcu.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002 MontaVista Software Inc. 4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
6 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
29 * - Added support for NEC VR4133. 29 * - Added support for NEC VR4133.
30 */ 30 */
31#include <linux/kernel.h> 31#include <linux/kernel.h>
diff --git a/arch/mips/vr41xx/common/cmu.c b/arch/mips/vr41xx/common/cmu.c
index d758e432961b..657c5133c933 100644
--- a/arch/mips/vr41xx/common/cmu.c
+++ b/arch/mips/vr41xx/common/cmu.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc. 4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copuright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copuright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
29 * - Added support for NEC VR4133. 29 * - Added support for NEC VR4133.
30 */ 30 */
31#include <linux/init.h> 31#include <linux/init.h>
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 0b73c5ab3c0c..07ae19cf0c29 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc. 4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
29 * - Coped with INTASSIGN of NEC VR4133. 29 * - Coped with INTASSIGN of NEC VR4133.
30 */ 30 */
31#include <linux/errno.h> 31#include <linux/errno.h>
diff --git a/arch/mips/vr41xx/common/init.c b/arch/mips/vr41xx/common/init.c
index 578f6496ffd4..707bd0933eed 100644
--- a/arch/mips/vr41xx/common/init.c
+++ b/arch/mips/vr41xx/common/init.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * init.c, Common initialization routines for NEC VR4100 series. 2 * init.c, Common initialization routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/int-handler.S b/arch/mips/vr41xx/common/int-handler.S
index 272c13aee4fd..2b6043f16d09 100644
--- a/arch/mips/vr41xx/common/int-handler.S
+++ b/arch/mips/vr41xx/common/int-handler.S
@@ -35,7 +35,7 @@
35 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 35 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
36 * - New creation, NEC VR4100 series are supported. 36 * - New creation, NEC VR4100 series are supported.
37 * 37 *
38 * Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 38 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
39 * - Coped with INTASSIGN of NEC VR4133. 39 * - Coped with INTASSIGN of NEC VR4133.
40 */ 40 */
41#include <asm/asm.h> 41#include <asm/asm.h>
diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
index 43b214d39438..61aa264275ff 100644
--- a/arch/mips/vr41xx/common/irq.c
+++ b/arch/mips/vr41xx/common/irq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Interrupt handing routines for NEC VR4100 series. 2 * Interrupt handing routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/pmu.c b/arch/mips/vr41xx/common/pmu.c
index 53166f3598b2..02bf4f7d06ba 100644
--- a/arch/mips/vr41xx/common/pmu.c
+++ b/arch/mips/vr41xx/common/pmu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * pmu.c, Power Management Unit routines for NEC VR4100 series. 2 * pmu.c, Power Management Unit routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/type.c b/arch/mips/vr41xx/common/type.c
index bcb5f71b5026..e0c1ac5e988e 100644
--- a/arch/mips/vr41xx/common/type.c
+++ b/arch/mips/vr41xx/common/type.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * type.c, System type for NEC VR4100 series. 2 * type.c, System type for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/vrc4173.c b/arch/mips/vr41xx/common/vrc4173.c
index cc52e75e14e7..3e31f8193d21 100644
--- a/arch/mips/vr41xx/common/vrc4173.c
+++ b/arch/mips/vr41xx/common/vrc4173.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
6 * Copyright (C) 2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org) 7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/mips/vr41xx/ibm-workpad/setup.c b/arch/mips/vr41xx/ibm-workpad/setup.c
index e4b34ad6ea61..50fe8af4c52c 100644
--- a/arch/mips/vr41xx/ibm-workpad/setup.c
+++ b/arch/mips/vr41xx/ibm-workpad/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * setup.c, Setup for the IBM WorkPad z50. 2 * setup.c, Setup for the IBM WorkPad z50.
3 * 3 *
4 * Copyright (C) 2002-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index a64fd48fbfb5..29b4d61898f2 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -22,6 +22,7 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#include <linux/capability.h>
25#include <linux/file.h> 26#include <linux/file.h>
26#include <linux/fs.h> 27#include <linux/fs.h>
27#include <linux/namei.h> 28#include <linux/namei.h>
diff --git a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
index 171f9c239f60..27827bc3717e 100644
--- a/arch/parisc/kernel/Makefile
+++ b/arch/parisc/kernel/Makefile
@@ -6,7 +6,6 @@ extra-y := init_task.o head.o vmlinux.lds
6 6
7AFLAGS_entry.o := -traditional 7AFLAGS_entry.o := -traditional
8AFLAGS_pacache.o := -traditional 8AFLAGS_pacache.o := -traditional
9CFLAGS_ioctl32.o := -Ifs/
10 9
11obj-y := cache.o pacache.o setup.o traps.o time.o irq.o \ 10obj-y := cache.o pacache.o setup.o traps.o time.o irq.o \
12 pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \ 11 pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
@@ -19,6 +18,6 @@ obj-$(CONFIG_SMP) += smp.o
19obj-$(CONFIG_PA11) += pci-dma.o 18obj-$(CONFIG_PA11) += pci-dma.o
20obj-$(CONFIG_PCI) += pci.o 19obj-$(CONFIG_PCI) += pci.o
21obj-$(CONFIG_MODULES) += module.o 20obj-$(CONFIG_MODULES) += module.o
22obj-$(CONFIG_64BIT) += binfmt_elf32.o sys_parisc32.o ioctl32.o signal32.o 21obj-$(CONFIG_64BIT) += binfmt_elf32.o sys_parisc32.o signal32.o
23# only supported for PCX-W/U in 64-bit mode at the moment 22# only supported for PCX-W/U in 64-bit mode at the moment
24obj-$(CONFIG_64BIT) += perf.o perf_asm.o 23obj-$(CONFIG_64BIT) += perf.o perf_asm.o
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index a065349aee37..d8a4ca021aac 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -29,9 +29,9 @@
29#include <asm/processor.h> 29#include <asm/processor.h>
30#include <asm/sections.h> 30#include <asm/sections.h>
31 31
32int split_tlb; 32int split_tlb __read_mostly;
33int dcache_stride; 33int dcache_stride __read_mostly;
34int icache_stride; 34int icache_stride __read_mostly;
35EXPORT_SYMBOL(dcache_stride); 35EXPORT_SYMBOL(dcache_stride);
36 36
37 37
@@ -45,29 +45,29 @@ DEFINE_SPINLOCK(pa_tlb_lock);
45EXPORT_SYMBOL(pa_tlb_lock); 45EXPORT_SYMBOL(pa_tlb_lock);
46#endif 46#endif
47 47
48struct pdc_cache_info cache_info; 48struct pdc_cache_info cache_info __read_mostly;
49#ifndef CONFIG_PA20 49#ifndef CONFIG_PA20
50static struct pdc_btlb_info btlb_info; 50static struct pdc_btlb_info btlb_info __read_mostly;
51#endif 51#endif
52 52
53#ifdef CONFIG_SMP 53#ifdef CONFIG_SMP
54void 54void
55flush_data_cache(void) 55flush_data_cache(void)
56{ 56{
57 on_each_cpu((void (*)(void *))flush_data_cache_local, NULL, 1, 1); 57 on_each_cpu(flush_data_cache_local, NULL, 1, 1);
58} 58}
59void 59void
60flush_instruction_cache(void) 60flush_instruction_cache(void)
61{ 61{
62 on_each_cpu((void (*)(void *))flush_instruction_cache_local, NULL, 1, 1); 62 on_each_cpu(flush_instruction_cache_local, NULL, 1, 1);
63} 63}
64#endif 64#endif
65 65
66void 66void
67flush_cache_all_local(void) 67flush_cache_all_local(void)
68{ 68{
69 flush_instruction_cache_local(); 69 flush_instruction_cache_local(NULL);
70 flush_data_cache_local(); 70 flush_data_cache_local(NULL);
71} 71}
72EXPORT_SYMBOL(flush_cache_all_local); 72EXPORT_SYMBOL(flush_cache_all_local);
73 73
@@ -332,7 +332,7 @@ void clear_user_page_asm(void *page, unsigned long vaddr)
332} 332}
333 333
334#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ 334#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */
335int parisc_cache_flush_threshold = FLUSH_THRESHOLD; 335int parisc_cache_flush_threshold __read_mostly = FLUSH_THRESHOLD;
336 336
337void parisc_setup_cache_timing(void) 337void parisc_setup_cache_timing(void)
338{ 338{
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index d016d672ec2b..1eaa0d37f677 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -39,7 +39,7 @@
39#include <asm/parisc-device.h> 39#include <asm/parisc-device.h>
40 40
41/* See comments in include/asm-parisc/pci.h */ 41/* See comments in include/asm-parisc/pci.h */
42struct hppa_dma_ops *hppa_dma_ops; 42struct hppa_dma_ops *hppa_dma_ops __read_mostly;
43EXPORT_SYMBOL(hppa_dma_ops); 43EXPORT_SYMBOL(hppa_dma_ops);
44 44
45static struct device root = { 45static struct device root = {
@@ -515,8 +515,13 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
515 (iodc_data[5] << 8) | iodc_data[6]; 515 (iodc_data[5] << 8) | iodc_data[6];
516 dev->hpa.name = parisc_pathname(dev); 516 dev->hpa.name = parisc_pathname(dev);
517 dev->hpa.start = hpa; 517 dev->hpa.start = hpa;
518 if (hpa == 0xf4000000 || hpa == 0xf6000000 || 518 /* This is awkward. The STI spec says that gfx devices may occupy
519 hpa == 0xf8000000 || hpa == 0xfa000000) { 519 * 32MB or 64MB. Unfortunately, we don't know how to tell whether
520 * it's the former or the latter. Assumptions either way can hurt us.
521 */
522 if (hpa == 0xf4000000 || hpa == 0xf8000000) {
523 dev->hpa.end = hpa + 0x03ffffff;
524 } else if (hpa == 0xf6000000 || hpa == 0xfa000000) {
520 dev->hpa.end = hpa + 0x01ffffff; 525 dev->hpa.end = hpa + 0x01ffffff;
521 } else { 526 } else {
522 dev->hpa.end = hpa + 0xfff; 527 dev->hpa.end = hpa + 0xfff;
@@ -834,7 +839,7 @@ static void print_parisc_device(struct parisc_device *dev)
834 839
835 if (dev->num_addrs) { 840 if (dev->num_addrs) {
836 int k; 841 int k;
837 printk(", additional addresses: "); 842 printk(", additional addresses: ");
838 for (k = 0; k < dev->num_addrs; k++) 843 for (k = 0; k < dev->num_addrs; k++)
839 printk("0x%lx ", dev->addr[k]); 844 printk("0x%lx ", dev->addr[k]);
840 } 845 }
diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c
index 553f8fe03224..2dc06b8e1817 100644
--- a/arch/parisc/kernel/firmware.c
+++ b/arch/parisc/kernel/firmware.c
@@ -80,7 +80,7 @@ static unsigned long pdc_result2[32] __attribute__ ((aligned (8)));
80 80
81/* Firmware needs to be initially set to narrow to determine the 81/* Firmware needs to be initially set to narrow to determine the
82 * actual firmware width. */ 82 * actual firmware width. */
83int parisc_narrow_firmware = 1; 83int parisc_narrow_firmware __read_mostly = 1;
84#endif 84#endif
85 85
86/* On most currently-supported platforms, IODC I/O calls are 32-bit calls 86/* On most currently-supported platforms, IODC I/O calls are 32-bit calls
diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c
index 2071b5bba15c..3058bffd8a2c 100644
--- a/arch/parisc/kernel/hardware.c
+++ b/arch/parisc/kernel/hardware.c
@@ -551,6 +551,7 @@ static struct hp_hardware hp_hardware_list[] __initdata = {
551 {HPHW_BCPORT, 0x804, 0x0000C, 0x10, "REO I/O BC Merced Port"}, 551 {HPHW_BCPORT, 0x804, 0x0000C, 0x10, "REO I/O BC Merced Port"},
552 {HPHW_BCPORT, 0x782, 0x0000C, 0x00, "REO I/O BC Ropes Port"}, 552 {HPHW_BCPORT, 0x782, 0x0000C, 0x00, "REO I/O BC Ropes Port"},
553 {HPHW_BCPORT, 0x784, 0x0000C, 0x00, "Pluto I/O BC Ropes Port"}, 553 {HPHW_BCPORT, 0x784, 0x0000C, 0x00, "Pluto I/O BC Ropes Port"},
554 {HPHW_BRIDGE, 0x05D, 0x0000A, 0x00, "SummitHawk Dino PCI Bridge"},
554 {HPHW_BRIDGE, 0x680, 0x0000A, 0x00, "Dino PCI Bridge"}, 555 {HPHW_BRIDGE, 0x680, 0x0000A, 0x00, "Dino PCI Bridge"},
555 {HPHW_BRIDGE, 0x682, 0x0000A, 0x00, "Cujo PCI Bridge"}, 556 {HPHW_BRIDGE, 0x682, 0x0000A, 0x00, "Cujo PCI Bridge"},
556 {HPHW_BRIDGE, 0x782, 0x0000A, 0x00, "Elroy PCI Bridge"}, 557 {HPHW_BRIDGE, 0x782, 0x0000A, 0x00, "Elroy PCI Bridge"},
diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c
index 8f563871e83c..4e847ba53180 100644
--- a/arch/parisc/kernel/inventory.c
+++ b/arch/parisc/kernel/inventory.c
@@ -38,7 +38,7 @@
38*/ 38*/
39#undef DEBUG_PAT 39#undef DEBUG_PAT
40 40
41int pdc_type = PDC_TYPE_ILLEGAL; 41int pdc_type __read_mostly = PDC_TYPE_ILLEGAL;
42 42
43void __init setup_pdc(void) 43void __init setup_pdc(void)
44{ 44{
@@ -120,8 +120,8 @@ set_pmem_entry(physmem_range_t *pmem_ptr, unsigned long start,
120 * pdc info is bad in this case). 120 * pdc info is bad in this case).
121 */ 121 */
122 122
123 if ( ((start & (PAGE_SIZE - 1)) != 0) 123 if (unlikely( ((start & (PAGE_SIZE - 1)) != 0)
124 || ((pages4k & ((1UL << PDC_PAGE_ADJ_SHIFT) - 1)) != 0) ) { 124 || ((pages4k & ((1UL << PDC_PAGE_ADJ_SHIFT) - 1)) != 0) )) {
125 125
126 panic("Memory range doesn't align with page size!\n"); 126 panic("Memory range doesn't align with page size!\n");
127 } 127 }
diff --git a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
deleted file mode 100644
index 4eada1bb27f0..000000000000
--- a/arch/parisc/kernel/ioctl32.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/* $Id: ioctl32.c,v 1.5 2002/10/18 00:21:43 varenet Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 *
7 * These routines maintain argument size conversion between 32bit and 64bit
8 * ioctls.
9 */
10
11#include <linux/syscalls.h>
12
13#define INCLUDES
14#include "compat_ioctl.c"
15
16#include <asm/perf.h>
17#include <asm/ioctls.h>
18
19#define CODE
20#include "compat_ioctl.c"
21
22#define HANDLE_IOCTL(cmd, handler) { cmd, (ioctl_trans_handler_t)handler, NULL },
23#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd, sys_ioctl)
24
25#define IOCTL_TABLE_START struct ioctl_trans ioctl_start[] = {
26#define IOCTL_TABLE_END };
27
28IOCTL_TABLE_START
29#include <linux/compat_ioctl.h>
30
31#define DECLARES
32#include "compat_ioctl.c"
33
34/* And these ioctls need translation */
35HANDLE_IOCTL(SIOCGPPPSTATS, dev_ifsioc)
36HANDLE_IOCTL(SIOCGPPPCSTATS, dev_ifsioc)
37HANDLE_IOCTL(SIOCGPPPVER, dev_ifsioc)
38
39#if defined(CONFIG_GEN_RTC)
40COMPATIBLE_IOCTL(RTC_AIE_ON)
41COMPATIBLE_IOCTL(RTC_AIE_OFF)
42COMPATIBLE_IOCTL(RTC_UIE_ON)
43COMPATIBLE_IOCTL(RTC_UIE_OFF)
44COMPATIBLE_IOCTL(RTC_PIE_ON)
45COMPATIBLE_IOCTL(RTC_PIE_OFF)
46COMPATIBLE_IOCTL(RTC_WIE_ON)
47COMPATIBLE_IOCTL(RTC_WIE_OFF)
48COMPATIBLE_IOCTL(RTC_ALM_SET) /* struct rtc_time only has ints */
49COMPATIBLE_IOCTL(RTC_ALM_READ) /* struct rtc_time only has ints */
50COMPATIBLE_IOCTL(RTC_RD_TIME) /* struct rtc_time only has ints */
51COMPATIBLE_IOCTL(RTC_SET_TIME) /* struct rtc_time only has ints */
52HANDLE_IOCTL(RTC_IRQP_READ, w_long)
53COMPATIBLE_IOCTL(RTC_IRQP_SET)
54HANDLE_IOCTL(RTC_EPOCH_READ, w_long)
55COMPATIBLE_IOCTL(RTC_EPOCH_SET)
56#endif
57
58IOCTL_TABLE_END
59
60int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index f94a02ef3d95..a6caf1073085 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -33,10 +33,10 @@
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <asm/tlbflush.h> /* for purge_tlb_*() macros */ 34#include <asm/tlbflush.h> /* for purge_tlb_*() macros */
35 35
36static struct proc_dir_entry * proc_gsc_root = NULL; 36static struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
37static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length); 37static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length);
38static unsigned long pcxl_used_bytes = 0; 38static unsigned long pcxl_used_bytes __read_mostly = 0;
39static unsigned long pcxl_used_pages = 0; 39static unsigned long pcxl_used_pages __read_mostly = 0;
40 40
41extern unsigned long pcxl_dma_start; /* Start of pcxl dma mapping area */ 41extern unsigned long pcxl_dma_start; /* Start of pcxl dma mapping area */
42static spinlock_t pcxl_res_lock; 42static spinlock_t pcxl_res_lock;
diff --git a/arch/parisc/kernel/pdc_chassis.c b/arch/parisc/kernel/pdc_chassis.c
index 52004ae28d20..2a01fe1bdc98 100644
--- a/arch/parisc/kernel/pdc_chassis.c
+++ b/arch/parisc/kernel/pdc_chassis.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/reboot.h> 31#include <linux/reboot.h>
32#include <linux/notifier.h> 32#include <linux/notifier.h>
33#include <linux/cache.h>
33 34
34#include <asm/pdc_chassis.h> 35#include <asm/pdc_chassis.h>
35#include <asm/processor.h> 36#include <asm/processor.h>
@@ -38,8 +39,8 @@
38 39
39 40
40#ifdef CONFIG_PDC_CHASSIS 41#ifdef CONFIG_PDC_CHASSIS
41static int pdc_chassis_old = 0; 42static int pdc_chassis_old __read_mostly = 0;
42static unsigned int pdc_chassis_enabled = 1; 43static unsigned int pdc_chassis_enabled __read_mostly = 1;
43 44
44 45
45/** 46/**
@@ -132,7 +133,7 @@ void __init parisc_pdc_chassis_init(void)
132{ 133{
133#ifdef CONFIG_PDC_CHASSIS 134#ifdef CONFIG_PDC_CHASSIS
134 int handle = 0; 135 int handle = 0;
135 if (pdc_chassis_enabled) { 136 if (likely(pdc_chassis_enabled)) {
136 DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__); 137 DPRINTK(KERN_DEBUG "%s: parisc_pdc_chassis_init()\n", __FILE__);
137 138
138 /* Let see if we have something to handle... */ 139 /* Let see if we have something to handle... */
@@ -142,7 +143,7 @@ void __init parisc_pdc_chassis_init(void)
142 printk(KERN_INFO "Enabling PDC_PAT chassis codes support.\n"); 143 printk(KERN_INFO "Enabling PDC_PAT chassis codes support.\n");
143 handle = 1; 144 handle = 1;
144 } 145 }
145 else if (pdc_chassis_old) { 146 else if (unlikely(pdc_chassis_old)) {
146 printk(KERN_INFO "Enabling old style chassis LED panel support.\n"); 147 printk(KERN_INFO "Enabling old style chassis LED panel support.\n");
147 handle = 1; 148 handle = 1;
148 } 149 }
@@ -178,7 +179,7 @@ int pdc_chassis_send_status(int message)
178 /* Maybe we should do that in an other way ? */ 179 /* Maybe we should do that in an other way ? */
179 int retval = 0; 180 int retval = 0;
180#ifdef CONFIG_PDC_CHASSIS 181#ifdef CONFIG_PDC_CHASSIS
181 if (pdc_chassis_enabled) { 182 if (likely(pdc_chassis_enabled)) {
182 183
183 DPRINTK(KERN_DEBUG "%s: pdc_chassis_send_status(%d)\n", __FILE__, message); 184 DPRINTK(KERN_DEBUG "%s: pdc_chassis_send_status(%d)\n", __FILE__, message);
184 185
@@ -214,7 +215,7 @@ int pdc_chassis_send_status(int message)
214 } 215 }
215 } else retval = -1; 216 } else retval = -1;
216#else 217#else
217 if (pdc_chassis_old) { 218 if (unlikely(pdc_chassis_old)) {
218 switch (message) { 219 switch (message) {
219 case PDC_CHASSIS_DIRECT_BSTART: 220 case PDC_CHASSIS_DIRECT_BSTART:
220 case PDC_CHASSIS_DIRECT_BCOMPLETE: 221 case PDC_CHASSIS_DIRECT_BCOMPLETE:
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index f6fec62b6a2f..11d406cd0b3e 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -42,6 +42,7 @@
42 * on every box. 42 * on every box.
43 */ 43 */
44 44
45#include <linux/capability.h>
45#include <linux/init.h> 46#include <linux/init.h>
46#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
47#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
@@ -66,10 +67,10 @@ struct rdr_tbl_ent {
66 uint8_t write_control; 67 uint8_t write_control;
67}; 68};
68 69
69static int perf_processor_interface = UNKNOWN_INTF; 70static int perf_processor_interface __read_mostly = UNKNOWN_INTF;
70static int perf_enabled = 0; 71static int perf_enabled __read_mostly = 0;
71static spinlock_t perf_lock; 72static spinlock_t perf_lock;
72struct parisc_device *cpu_device = NULL; 73struct parisc_device *cpu_device __read_mostly = NULL;
73 74
74/* RDRs to write for PCX-W */ 75/* RDRs to write for PCX-W */
75static int perf_rdrs_W[] = 76static int perf_rdrs_W[] =
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index fee4f1f09adc..5da41677e70b 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -54,7 +54,7 @@
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/unwind.h> 55#include <asm/unwind.h>
56 56
57static int hlt_counter; 57static int hlt_counter __read_mostly;
58 58
59/* 59/*
60 * Power off function, if any 60 * Power off function, if any
@@ -295,7 +295,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
295 struct task_struct * p, struct pt_regs * pregs) 295 struct task_struct * p, struct pt_regs * pregs)
296{ 296{
297 struct pt_regs * cregs = &(p->thread.regs); 297 struct pt_regs * cregs = &(p->thread.regs);
298 struct thread_info *ti = p->thread_info; 298 void *stack = task_stack_page(p);
299 299
300 /* We have to use void * instead of a function pointer, because 300 /* We have to use void * instead of a function pointer, because
301 * function pointers aren't a pointer to the function on 64-bit. 301 * function pointers aren't a pointer to the function on 64-bit.
@@ -322,7 +322,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
322 */ 322 */
323 if (usp == 1) { 323 if (usp == 1) {
324 /* kernel thread */ 324 /* kernel thread */
325 cregs->ksp = (((unsigned long)(ti)) + THREAD_SZ_ALGN); 325 cregs->ksp = (unsigned long)stack + THREAD_SZ_ALGN;
326 /* Must exit via ret_from_kernel_thread in order 326 /* Must exit via ret_from_kernel_thread in order
327 * to call schedule_tail() 327 * to call schedule_tail()
328 */ 328 */
@@ -344,7 +344,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
344 */ 344 */
345 345
346 /* Use same stack depth as parent */ 346 /* Use same stack depth as parent */
347 cregs->ksp = ((unsigned long)(ti)) 347 cregs->ksp = (unsigned long)stack
348 + (pregs->gr[21] & (THREAD_SIZE - 1)); 348 + (pregs->gr[21] & (THREAD_SIZE - 1));
349 cregs->gr[30] = usp; 349 cregs->gr[30] = usp;
350 if (p->personality == PER_HPUX) { 350 if (p->personality == PER_HPUX) {
diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
index 4f5bbcf1f5a4..6df9f62cecb5 100644
--- a/arch/parisc/kernel/processor.c
+++ b/arch/parisc/kernel/processor.c
@@ -44,10 +44,10 @@
44#include <asm/irq.h> /* for struct irq_region */ 44#include <asm/irq.h> /* for struct irq_region */
45#include <asm/parisc-device.h> 45#include <asm/parisc-device.h>
46 46
47struct system_cpuinfo_parisc boot_cpu_data; 47struct system_cpuinfo_parisc boot_cpu_data __read_mostly;
48EXPORT_SYMBOL(boot_cpu_data); 48EXPORT_SYMBOL(boot_cpu_data);
49 49
50struct cpuinfo_parisc cpu_data[NR_CPUS]; 50struct cpuinfo_parisc cpu_data[NR_CPUS] __read_mostly;
51 51
52/* 52/*
53** PARISC CPU driver - claim "device" and initialize CPU data structures. 53** PARISC CPU driver - claim "device" and initialize CPU data structures.
@@ -378,12 +378,12 @@ show_cpuinfo (struct seq_file *m, void *v)
378 return 0; 378 return 0;
379} 379}
380 380
381static struct parisc_device_id processor_tbl[] = { 381static struct parisc_device_id processor_tbl[] __read_mostly = {
382 { HPHW_NPROC, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, SVERSION_ANY_ID }, 382 { HPHW_NPROC, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, SVERSION_ANY_ID },
383 { 0, } 383 { 0, }
384}; 384};
385 385
386static struct parisc_driver cpu_driver = { 386static struct parisc_driver cpu_driver __read_mostly = {
387 .name = "CPU", 387 .name = "CPU",
388 .id_table = processor_tbl, 388 .id_table = processor_tbl,
389 .probe = processor_probe 389 .probe = processor_probe
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 73e9c34b0948..4a36ec3f6ac1 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -46,15 +46,15 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/setup.h> 47#include <asm/setup.h>
48 48
49char command_line[COMMAND_LINE_SIZE]; 49char command_line[COMMAND_LINE_SIZE] __read_mostly;
50 50
51/* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */ 51/* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
52struct proc_dir_entry * proc_runway_root = NULL; 52struct proc_dir_entry * proc_runway_root __read_mostly = NULL;
53struct proc_dir_entry * proc_gsc_root = NULL; 53struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
54struct proc_dir_entry * proc_mckinley_root = NULL; 54struct proc_dir_entry * proc_mckinley_root __read_mostly = NULL;
55 55
56#if !defined(CONFIG_PA20) && (defined(CONFIG_IOMMU_CCIO) || defined(CONFIG_IOMMU_SBA)) 56#if !defined(CONFIG_PA20) && (defined(CONFIG_IOMMU_CCIO) || defined(CONFIG_IOMMU_SBA))
57int parisc_bus_is_phys = 1; /* Assume no IOMMU is present */ 57int parisc_bus_is_phys __read_mostly = 1; /* Assume no IOMMU is present */
58EXPORT_SYMBOL(parisc_bus_is_phys); 58EXPORT_SYMBOL(parisc_bus_is_phys);
59#endif 59#endif
60 60
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index ce89da0f654d..25564b7ca6bb 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -39,7 +39,7 @@
39#include <asm/atomic.h> 39#include <asm/atomic.h>
40#include <asm/current.h> 40#include <asm/current.h>
41#include <asm/delay.h> 41#include <asm/delay.h>
42#include <asm/pgalloc.h> /* for flush_tlb_all() proto/macro */ 42#include <asm/tlbflush.h>
43 43
44#include <asm/io.h> 44#include <asm/io.h>
45#include <asm/irq.h> /* for CPU_IRQ_REGION and friends */ 45#include <asm/irq.h> /* for CPU_IRQ_REGION and friends */
@@ -58,9 +58,9 @@ DEFINE_SPINLOCK(smp_lock);
58 58
59volatile struct task_struct *smp_init_current_idle_task; 59volatile struct task_struct *smp_init_current_idle_task;
60 60
61static volatile int cpu_now_booting = 0; /* track which CPU is booting */ 61static volatile int cpu_now_booting __read_mostly = 0; /* track which CPU is booting */
62 62
63static int parisc_max_cpus = 1; 63static int parisc_max_cpus __read_mostly = 1;
64 64
65/* online cpus are ones that we've managed to bring up completely 65/* online cpus are ones that we've managed to bring up completely
66 * possible cpus are all valid cpu 66 * possible cpus are all valid cpu
@@ -71,8 +71,8 @@ static int parisc_max_cpus = 1;
71 * empty in the beginning. 71 * empty in the beginning.
72 */ 72 */
73 73
74cpumask_t cpu_online_map = CPU_MASK_NONE; /* Bitmap of online CPUs */ 74cpumask_t cpu_online_map __read_mostly = CPU_MASK_NONE; /* Bitmap of online CPUs */
75cpumask_t cpu_possible_map = CPU_MASK_ALL; /* Bitmap of Present CPUs */ 75cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL; /* Bitmap of Present CPUs */
76 76
77EXPORT_SYMBOL(cpu_online_map); 77EXPORT_SYMBOL(cpu_online_map);
78EXPORT_SYMBOL(cpu_possible_map); 78EXPORT_SYMBOL(cpu_possible_map);
@@ -406,12 +406,10 @@ EXPORT_SYMBOL(smp_call_function);
406 * as we want to ensure all TLB's flushed before proceeding. 406 * as we want to ensure all TLB's flushed before proceeding.
407 */ 407 */
408 408
409extern void flush_tlb_all_local(void);
410
411void 409void
412smp_flush_tlb_all(void) 410smp_flush_tlb_all(void)
413{ 411{
414 on_each_cpu((void (*)(void *))flush_tlb_all_local, NULL, 1, 1); 412 on_each_cpu(flush_tlb_all_local, NULL, 1, 1);
415} 413}
416 414
417 415
@@ -487,7 +485,7 @@ void __init smp_callin(void)
487#endif 485#endif
488 486
489 flush_cache_all_local(); /* start with known state */ 487 flush_cache_all_local(); /* start with known state */
490 flush_tlb_all_local(); 488 flush_tlb_all_local(NULL);
491 489
492 local_irq_enable(); /* Interrupts have been off until now */ 490 local_irq_enable(); /* Interrupts have been off until now */
493 491
@@ -519,7 +517,7 @@ int __init smp_boot_one_cpu(int cpuid)
519 if (IS_ERR(idle)) 517 if (IS_ERR(idle))
520 panic("SMP: fork failed for CPU:%d", cpuid); 518 panic("SMP: fork failed for CPU:%d", cpuid);
521 519
522 idle->thread_info->cpu = cpuid; 520 task_thread_info(idle)->cpu = cpuid;
523 521
524 /* Let _start know what logical CPU we're booting 522 /* Let _start know what logical CPU we're booting
525 ** (offset into init_tasks[],cpu_data[]) 523 ** (offset into init_tasks[],cpu_data[])
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index cded25680787..594930bc4bcf 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -36,8 +36,8 @@
36/* xtime and wall_jiffies keep wall-clock time */ 36/* xtime and wall_jiffies keep wall-clock time */
37extern unsigned long wall_jiffies; 37extern unsigned long wall_jiffies;
38 38
39static long clocktick; /* timer cycles per tick */ 39static long clocktick __read_mostly; /* timer cycles per tick */
40static long halftick; 40static long halftick __read_mostly;
41 41
42#ifdef CONFIG_SMP 42#ifdef CONFIG_SMP
43extern void smp_do_timer(struct pt_regs *regs); 43extern void smp_do_timer(struct pt_regs *regs);
diff --git a/arch/parisc/kernel/topology.c b/arch/parisc/kernel/topology.c
index ac2a40681414..3ba040050e4c 100644
--- a/arch/parisc/kernel/topology.c
+++ b/arch/parisc/kernel/topology.c
@@ -20,8 +20,9 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/cache.h>
23 24
24static struct cpu cpu_devices[NR_CPUS]; 25static struct cpu cpu_devices[NR_CPUS] __read_mostly;
25 26
26static int __init topology_init(void) 27static int __init topology_init(void)
27{ 28{
diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c
index eaae8a021f9f..de0a1b21cb40 100644
--- a/arch/parisc/kernel/unaligned.c
+++ b/arch/parisc/kernel/unaligned.c
@@ -122,7 +122,7 @@
122#define ERR_NOTHANDLED -1 122#define ERR_NOTHANDLED -1
123#define ERR_PAGEFAULT -2 123#define ERR_PAGEFAULT -2
124 124
125int unaligned_enabled = 1; 125int unaligned_enabled __read_mostly = 1;
126 126
127void die_if_kernel (char *str, struct pt_regs *regs, long err); 127void die_if_kernel (char *str, struct pt_regs *regs, long err);
128 128
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
index db141108412e..cc1c1afc3187 100644
--- a/arch/parisc/kernel/unwind.c
+++ b/arch/parisc/kernel/unwind.c
@@ -35,7 +35,7 @@ static spinlock_t unwind_lock;
35 * we can call unwind_init as early in the bootup process as 35 * we can call unwind_init as early in the bootup process as
36 * possible (before the slab allocator is initialized) 36 * possible (before the slab allocator is initialized)
37 */ 37 */
38static struct unwind_table kernel_unwind_table; 38static struct unwind_table kernel_unwind_table __read_mostly;
39static LIST_HEAD(unwind_tables); 39static LIST_HEAD(unwind_tables);
40 40
41static inline const struct unwind_table_entry * 41static inline const struct unwind_table_entry *
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index e5fac3e08c7a..6d6436a6b624 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -68,7 +68,7 @@ SECTIONS
68 RODATA 68 RODATA
69 69
70 /* writeable */ 70 /* writeable */
71 . = ALIGN(4096); /* Make sure this is paged aligned so 71 . = ALIGN(4096); /* Make sure this is page aligned so
72 that we can properly leave these 72 that we can properly leave these
73 as writable */ 73 as writable */
74 data_start = .; 74 data_start = .;
@@ -105,6 +105,10 @@ SECTIONS
105 . = ALIGN(16); 105 . = ALIGN(16);
106 .data.lock_aligned : { *(.data.lock_aligned) } 106 .data.lock_aligned : { *(.data.lock_aligned) }
107 107
108 /* rarely changed data like cpu maps */
109 . = ALIGN(16);
110 .data.read_mostly : { *(.data.read_mostly) }
111
108 _edata = .; /* End of data section */ 112 _edata = .; /* End of data section */
109 113
110 . = ALIGN(16384); /* init_task */ 114 . = ALIGN(16384); /* init_task */
@@ -194,14 +198,7 @@ SECTIONS
194#endif 198#endif
195 } 199 }
196 200
197 /* Stabs debugging sections. */ 201 STABS_DEBUG
198 .stab 0 : { *(.stab) }
199 .stabstr 0 : { *(.stabstr) }
200 .stab.excl 0 : { *(.stab.excl) }
201 .stab.exclstr 0 : { *(.stab.exclstr) }
202 .stab.index 0 : { *(.stab.index) }
203 .stab.indexstr 0 : { *(.stab.indexstr) }
204 .comment 0 : { *(.comment) }
205 .note 0 : { *(.note) } 202 .note 0 : { *(.note) }
206 203
207} 204}
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 29b998e430e6..720287d46e55 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -36,9 +36,9 @@ extern char _end; /* end of BSS, defined by linker */
36extern char __init_begin, __init_end; 36extern char __init_begin, __init_end;
37 37
38#ifdef CONFIG_DISCONTIGMEM 38#ifdef CONFIG_DISCONTIGMEM
39struct node_map_data node_data[MAX_NUMNODES]; 39struct node_map_data node_data[MAX_NUMNODES] __read_mostly;
40bootmem_data_t bmem_data[MAX_NUMNODES]; 40bootmem_data_t bmem_data[MAX_NUMNODES] __read_mostly;
41unsigned char pfnnid_map[PFNNID_MAP_MAX]; 41unsigned char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;
42#endif 42#endif
43 43
44static struct resource data_resource = { 44static struct resource data_resource = {
@@ -58,14 +58,14 @@ static struct resource pdcdata_resource = {
58 .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 58 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
59}; 59};
60 60
61static struct resource sysram_resources[MAX_PHYSMEM_RANGES]; 61static struct resource sysram_resources[MAX_PHYSMEM_RANGES] __read_mostly;
62 62
63/* The following array is initialized from the firmware specific 63/* The following array is initialized from the firmware specific
64 * information retrieved in kernel/inventory.c. 64 * information retrieved in kernel/inventory.c.
65 */ 65 */
66 66
67physmem_range_t pmem_ranges[MAX_PHYSMEM_RANGES]; 67physmem_range_t pmem_ranges[MAX_PHYSMEM_RANGES] __read_mostly;
68int npmem_ranges; 68int npmem_ranges __read_mostly;
69 69
70#ifdef __LP64__ 70#ifdef __LP64__
71#define MAX_MEM (~0UL) 71#define MAX_MEM (~0UL)
@@ -73,7 +73,7 @@ int npmem_ranges;
73#define MAX_MEM (3584U*1024U*1024U) 73#define MAX_MEM (3584U*1024U*1024U)
74#endif /* !__LP64__ */ 74#endif /* !__LP64__ */
75 75
76static unsigned long mem_limit = MAX_MEM; 76static unsigned long mem_limit __read_mostly = MAX_MEM;
77 77
78static void __init mem_limit_func(void) 78static void __init mem_limit_func(void)
79{ 79{
@@ -300,6 +300,13 @@ static void __init setup_bootmem(void)
300 max_pfn = start_pfn + npages; 300 max_pfn = start_pfn + npages;
301 } 301 }
302 302
303 /* IOMMU is always used to access "high mem" on those boxes
304 * that can support enough mem that a PCI device couldn't
305 * directly DMA to any physical addresses.
306 * ISA DMA support will need to revisit this.
307 */
308 max_low_pfn = max_pfn;
309
303 if ((bootmap_pfn - bootmap_start_pfn) != bootmap_pages) { 310 if ((bootmap_pfn - bootmap_start_pfn) != bootmap_pages) {
304 printk(KERN_WARNING "WARNING! bootmap sizing is messed up!\n"); 311 printk(KERN_WARNING "WARNING! bootmap sizing is messed up!\n");
305 BUG(); 312 BUG();
@@ -431,11 +438,11 @@ void free_initmem(void)
431#define SET_MAP_OFFSET(x) ((void *)(((unsigned long)(x) + VM_MAP_OFFSET) \ 438#define SET_MAP_OFFSET(x) ((void *)(((unsigned long)(x) + VM_MAP_OFFSET) \
432 & ~(VM_MAP_OFFSET-1))) 439 & ~(VM_MAP_OFFSET-1)))
433 440
434void *vmalloc_start; 441void *vmalloc_start __read_mostly;
435EXPORT_SYMBOL(vmalloc_start); 442EXPORT_SYMBOL(vmalloc_start);
436 443
437#ifdef CONFIG_PA11 444#ifdef CONFIG_PA11
438unsigned long pcxl_dma_start; 445unsigned long pcxl_dma_start __read_mostly;
439#endif 446#endif
440 447
441void __init mem_init(void) 448void __init mem_init(void)
@@ -475,7 +482,7 @@ int do_check_pgt_cache(int low, int high)
475 return 0; 482 return 0;
476} 483}
477 484
478unsigned long *empty_zero_page; 485unsigned long *empty_zero_page __read_mostly;
479 486
480void show_mem(void) 487void show_mem(void)
481{ 488{
@@ -998,7 +1005,7 @@ void flush_tlb_all(void)
998void flush_tlb_all(void) 1005void flush_tlb_all(void)
999{ 1006{
1000 spin_lock(&sid_lock); 1007 spin_lock(&sid_lock);
1001 flush_tlb_all_local(); 1008 flush_tlb_all_local(NULL);
1002 recycle_sids(); 1009 recycle_sids();
1003 spin_unlock(&sid_lock); 1010 spin_unlock(&sid_lock);
1004} 1011}
diff --git a/arch/parisc/mm/ioremap.c b/arch/parisc/mm/ioremap.c
index 5c7a1b3b9326..edd9a9559cba 100644
--- a/arch/parisc/mm/ioremap.c
+++ b/arch/parisc/mm/ioremap.c
@@ -1,12 +1,9 @@
1/* 1/*
2 * arch/parisc/mm/ioremap.c 2 * arch/parisc/mm/ioremap.c
3 * 3 *
4 * Re-map IO memory to kernel address space so that we can access it.
5 * This is needed for high PCI addresses that aren't mapped in the
6 * 640k-1MB IO memory area on PC's
7 *
8 * (C) Copyright 1995 1996 Linus Torvalds 4 * (C) Copyright 1995 1996 Linus Torvalds
9 * (C) Copyright 2001 Helge Deller <deller@gmx.de> 5 * (C) Copyright 2001 Helge Deller <deller@gmx.de>
6 * (C) Copyright 2005 Kyle McMartin <kyle@parisc-linux.org>
10 */ 7 */
11 8
12#include <linux/vmalloc.h> 9#include <linux/vmalloc.h>
@@ -14,81 +11,107 @@
14#include <linux/module.h> 11#include <linux/module.h>
15#include <asm/io.h> 12#include <asm/io.h>
16#include <asm/pgalloc.h> 13#include <asm/pgalloc.h>
14#include <asm/tlbflush.h>
15#include <asm/cacheflush.h>
17 16
18static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, 17static inline void
19 unsigned long phys_addr, unsigned long flags) 18remap_area_pte(pte_t *pte, unsigned long address, unsigned long size,
19 unsigned long phys_addr, unsigned long flags)
20{ 20{
21 unsigned long end; 21 unsigned long end, pfn;
22 pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY |
23 _PAGE_ACCESSED | flags);
22 24
23 address &= ~PMD_MASK; 25 address &= ~PMD_MASK;
26
24 end = address + size; 27 end = address + size;
25 if (end > PMD_SIZE) 28 if (end > PMD_SIZE)
26 end = PMD_SIZE; 29 end = PMD_SIZE;
27 if (address >= end) 30
28 BUG(); 31 BUG_ON(address >= end);
32
33 pfn = phys_addr >> PAGE_SHIFT;
29 do { 34 do {
30 if (!pte_none(*pte)) { 35 BUG_ON(!pte_none(*pte));
31 printk(KERN_ERR "remap_area_pte: page already exists\n"); 36
32 BUG(); 37 set_pte(pte, pfn_pte(pfn, pgprot));
33 } 38
34 set_pte(pte, mk_pte_phys(phys_addr, __pgprot(_PAGE_PRESENT | _PAGE_RW |
35 _PAGE_DIRTY | _PAGE_ACCESSED | flags)));
36 address += PAGE_SIZE; 39 address += PAGE_SIZE;
37 phys_addr += PAGE_SIZE; 40 pfn++;
38 pte++; 41 pte++;
39 } while (address && (address < end)); 42 } while (address && (address < end));
40} 43}
41 44
42static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size, 45static inline int
43 unsigned long phys_addr, unsigned long flags) 46remap_area_pmd(pmd_t *pmd, unsigned long address, unsigned long size,
47 unsigned long phys_addr, unsigned long flags)
44{ 48{
45 unsigned long end; 49 unsigned long end;
46 50
47 address &= ~PGDIR_MASK; 51 address &= ~PGDIR_MASK;
52
48 end = address + size; 53 end = address + size;
49 if (end > PGDIR_SIZE) 54 if (end > PGDIR_SIZE)
50 end = PGDIR_SIZE; 55 end = PGDIR_SIZE;
56
57 BUG_ON(address >= end);
58
51 phys_addr -= address; 59 phys_addr -= address;
52 if (address >= end)
53 BUG();
54 do { 60 do {
55 pte_t * pte = pte_alloc_kernel(pmd, address); 61 pte_t *pte = pte_alloc_kernel(pmd, address);
56 if (!pte) 62 if (!pte)
57 return -ENOMEM; 63 return -ENOMEM;
58 remap_area_pte(pte, address, end - address, address + phys_addr, flags); 64
65 remap_area_pte(pte, address, end - address,
66 address + phys_addr, flags);
67
59 address = (address + PMD_SIZE) & PMD_MASK; 68 address = (address + PMD_SIZE) & PMD_MASK;
60 pmd++; 69 pmd++;
61 } while (address && (address < end)); 70 } while (address && (address < end));
71
62 return 0; 72 return 0;
63} 73}
64 74
65#if (USE_HPPA_IOREMAP) 75#if USE_HPPA_IOREMAP
66static int remap_area_pages(unsigned long address, unsigned long phys_addr, 76static int
67 unsigned long size, unsigned long flags) 77remap_area_pages(unsigned long address, unsigned long phys_addr,
78 unsigned long size, unsigned long flags)
68{ 79{
69 int error; 80 pgd_t *dir;
70 pgd_t * dir; 81 int error = 0;
71 unsigned long end = address + size; 82 unsigned long end = address + size;
72 83
84 BUG_ON(address >= end);
85
73 phys_addr -= address; 86 phys_addr -= address;
74 dir = pgd_offset(&init_mm, address); 87 dir = pgd_offset_k(address);
88
75 flush_cache_all(); 89 flush_cache_all();
76 if (address >= end) 90
77 BUG();
78 do { 91 do {
92 pud_t *pud;
79 pmd_t *pmd; 93 pmd_t *pmd;
80 pmd = pmd_alloc(&init_mm, dir, address); 94
81 error = -ENOMEM; 95 error = -ENOMEM;
96 pud = pud_alloc(&init_mm, dir, address);
97 if (!pud)
98 break;
99
100 pmd = pmd_alloc(&init_mm, pud, address);
82 if (!pmd) 101 if (!pmd)
83 break; 102 break;
103
84 if (remap_area_pmd(pmd, address, end - address, 104 if (remap_area_pmd(pmd, address, end - address,
85 phys_addr + address, flags)) 105 phys_addr + address, flags))
86 break; 106 break;
107
87 error = 0; 108 error = 0;
88 address = (address + PGDIR_SIZE) & PGDIR_MASK; 109 address = (address + PGDIR_SIZE) & PGDIR_MASK;
89 dir++; 110 dir++;
90 } while (address && (address < end)); 111 } while (address && (address < end));
112
91 flush_tlb_all(); 113 flush_tlb_all();
114
92 return error; 115 return error;
93} 116}
94#endif /* USE_HPPA_IOREMAP */ 117#endif /* USE_HPPA_IOREMAP */
@@ -123,8 +146,7 @@ EXPORT_SYMBOL(__raw_bad_addr);
123 146
124/* 147/*
125 * Remap an arbitrary physical address space into the kernel virtual 148 * Remap an arbitrary physical address space into the kernel virtual
126 * address space. Needed when the kernel wants to access high addresses 149 * address space.
127 * directly.
128 * 150 *
129 * NOTE! We need to allow non-page-aligned mappings too: we will obviously 151 * NOTE! We need to allow non-page-aligned mappings too: we will obviously
130 * have to convert them into an offset in a page-aligned mapping, but the 152 * have to convert them into an offset in a page-aligned mapping, but the
@@ -148,8 +170,8 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
148#endif 170#endif
149 171
150#else 172#else
151 void * addr; 173 void *addr;
152 struct vm_struct * area; 174 struct vm_struct *area;
153 unsigned long offset, last_addr; 175 unsigned long offset, last_addr;
154 176
155 /* Don't allow wraparound or zero size */ 177 /* Don't allow wraparound or zero size */
@@ -167,9 +189,11 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
167 t_addr = __va(phys_addr); 189 t_addr = __va(phys_addr);
168 t_end = t_addr + (size - 1); 190 t_end = t_addr + (size - 1);
169 191
170 for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++) 192 for (page = virt_to_page(t_addr);
193 page <= virt_to_page(t_end); page++) {
171 if(!PageReserved(page)) 194 if(!PageReserved(page))
172 return NULL; 195 return NULL;
196 }
173 } 197 }
174 198
175 /* 199 /*
@@ -185,11 +209,13 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
185 area = get_vm_area(size, VM_IOREMAP); 209 area = get_vm_area(size, VM_IOREMAP);
186 if (!area) 210 if (!area)
187 return NULL; 211 return NULL;
212
188 addr = area->addr; 213 addr = area->addr;
189 if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) { 214 if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
190 vfree(addr); 215 vfree(addr);
191 return NULL; 216 return NULL;
192 } 217 }
218
193 return (void __iomem *) (offset + (char *)addr); 219 return (void __iomem *) (offset + (char *)addr);
194#endif 220#endif
195} 221}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 28004f002ec9..01feed0e2a15 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -71,15 +71,39 @@ config ARCH_MAY_HAVE_PC_FDC
71 bool 71 bool
72 default y 72 default y
73 73
74config PPC_OF
75 def_bool y
76
77config PPC_UDBG_16550
78 bool
79 default n
80
81config CRASH_DUMP
82 bool "kernel crash dumps (EXPERIMENTAL)"
83 depends on PPC_MULTIPLATFORM
84 depends on EXPERIMENTAL
85 help
86 Build a kernel suitable for use as a kdump capture kernel.
87 The kernel will be linked at a different address than normal, and
88 so can only be used for Kdump.
89
90 Don't change this unless you know what you are doing.
91
92config GENERIC_TBSYNC
93 bool
94 default y if PPC32 && SMP
95 default n
96
74menu "Processor support" 97menu "Processor support"
75choice 98choice
76 prompt "Processor Type" 99 prompt "Processor Type"
77 depends on PPC32 100 depends on PPC32
78 default 6xx 101 default 6xx
79 102
80config 6xx 103config CLASSIC32
81 bool "6xx/7xx/74xx" 104 bool "6xx/7xx/74xx"
82 select PPC_FPU 105 select PPC_FPU
106 select 6xx
83 help 107 help
84 There are four families of PowerPC chips supported. The more common 108 There are four families of PowerPC chips supported. The more common
85 types (601, 603, 604, 740, 750, 7400), the Motorola embedded 109 types (601, 603, 604, 740, 750, 7400), the Motorola embedded
@@ -93,12 +117,20 @@ config 6xx
93 117
94config PPC_52xx 118config PPC_52xx
95 bool "Freescale 52xx" 119 bool "Freescale 52xx"
120 select 6xx
121 select PPC_FPU
96 122
97config PPC_82xx 123config PPC_82xx
98 bool "Freescale 82xx" 124 bool "Freescale 82xx"
125 select 6xx
126 select PPC_FPU
99 127
100config PPC_83xx 128config PPC_83xx
101 bool "Freescale 83xx" 129 bool "Freescale 83xx"
130 select 6xx
131 select FSL_SOC
132 select 83xx
133 select PPC_FPU
102 134
103config 40x 135config 40x
104 bool "AMCC 40x" 136 bool "AMCC 40x"
@@ -134,6 +166,13 @@ config POWER4
134 depends on PPC64 166 depends on PPC64
135 def_bool y 167 def_bool y
136 168
169config 6xx
170 bool
171
172# this is temp to handle compat with arch=ppc
173config 83xx
174 bool
175
137config PPC_FPU 176config PPC_FPU
138 bool 177 bool
139 default y if PPC64 178 default y if PPC64
@@ -166,7 +205,7 @@ config PHYS_64BIT
166 205
167config ALTIVEC 206config ALTIVEC
168 bool "AltiVec Support" 207 bool "AltiVec Support"
169 depends on 6xx || POWER4 208 depends on CLASSIC32 || POWER4
170 ---help--- 209 ---help---
171 This option enables kernel support for the Altivec extensions to the 210 This option enables kernel support for the Altivec extensions to the
172 PowerPC processor. The kernel currently supports saving and restoring 211 PowerPC processor. The kernel currently supports saving and restoring
@@ -239,7 +278,7 @@ endmenu
239source "init/Kconfig" 278source "init/Kconfig"
240 279
241menu "Platform support" 280menu "Platform support"
242 depends on PPC64 || 6xx 281 depends on PPC64 || CLASSIC32
243 282
244choice 283choice
245 prompt "Machine type" 284 prompt "Machine type"
@@ -275,6 +314,7 @@ config PPC_PSERIES
275 select PPC_I8259 314 select PPC_I8259
276 select PPC_RTAS 315 select PPC_RTAS
277 select RTAS_ERROR_LOGGING 316 select RTAS_ERROR_LOGGING
317 select PPC_UDBG_16550
278 default y 318 default y
279 319
280config PPC_CHRP 320config PPC_CHRP
@@ -284,6 +324,7 @@ config PPC_CHRP
284 select PPC_INDIRECT_PCI 324 select PPC_INDIRECT_PCI
285 select PPC_RTAS 325 select PPC_RTAS
286 select PPC_MPC106 326 select PPC_MPC106
327 select PPC_UDBG_16550
287 default y 328 default y
288 329
289config PPC_PMAC 330config PPC_PMAC
@@ -306,6 +347,7 @@ config PPC_PREP
306 depends on PPC_MULTIPLATFORM && PPC32 && BROKEN 347 depends on PPC_MULTIPLATFORM && PPC32 && BROKEN
307 select PPC_I8259 348 select PPC_I8259
308 select PPC_INDIRECT_PCI 349 select PPC_INDIRECT_PCI
350 select PPC_UDBG_16550
309 default y 351 default y
310 352
311config PPC_MAPLE 353config PPC_MAPLE
@@ -314,6 +356,7 @@ config PPC_MAPLE
314 select U3_DART 356 select U3_DART
315 select MPIC_BROKEN_U3 357 select MPIC_BROKEN_U3
316 select GENERIC_TBSYNC 358 select GENERIC_TBSYNC
359 select PPC_UDBG_16550
317 default n 360 default n
318 help 361 help
319 This option enables support for the Maple 970FX Evaluation Board. 362 This option enables support for the Maple 970FX Evaluation Board.
@@ -324,9 +367,7 @@ config PPC_CELL
324 depends on PPC_MULTIPLATFORM && PPC64 367 depends on PPC_MULTIPLATFORM && PPC64
325 select PPC_RTAS 368 select PPC_RTAS
326 select MMIO_NVRAM 369 select MMIO_NVRAM
327 370 select PPC_UDBG_16550
328config PPC_OF
329 def_bool y
330 371
331config XICS 372config XICS
332 depends on PPC_PSERIES 373 depends on PPC_PSERIES
@@ -375,17 +416,6 @@ config CELL_IIC
375 bool 416 bool
376 default y 417 default y
377 418
378config CRASH_DUMP
379 bool "kernel crash dumps (EXPERIMENTAL)"
380 depends on PPC_MULTIPLATFORM
381 depends on EXPERIMENTAL
382 help
383 Build a kernel suitable for use as a kdump capture kernel.
384 The kernel will be linked at a different address than normal, and
385 so can only be used for Kdump.
386
387 Don't change this unless you know what you are doing.
388
389config IBMVIO 419config IBMVIO
390 depends on PPC_PSERIES || PPC_ISERIES 420 depends on PPC_PSERIES || PPC_ISERIES
391 bool 421 bool
@@ -401,11 +431,6 @@ config PPC_MPC106
401 bool 431 bool
402 default n 432 default n
403 433
404config GENERIC_TBSYNC
405 bool
406 default y if CONFIG_PPC32 && CONFIG_SMP
407 default n
408
409source "drivers/cpufreq/Kconfig" 434source "drivers/cpufreq/Kconfig"
410 435
411config CPU_FREQ_PMAC 436config CPU_FREQ_PMAC
@@ -486,6 +511,7 @@ endmenu
486 511
487source arch/powerpc/platforms/embedded6xx/Kconfig 512source arch/powerpc/platforms/embedded6xx/Kconfig
488source arch/powerpc/platforms/4xx/Kconfig 513source arch/powerpc/platforms/4xx/Kconfig
514source arch/powerpc/platforms/83xx/Kconfig
489source arch/powerpc/platforms/85xx/Kconfig 515source arch/powerpc/platforms/85xx/Kconfig
490source arch/powerpc/platforms/8xx/Kconfig 516source arch/powerpc/platforms/8xx/Kconfig
491source arch/powerpc/platforms/cell/Kconfig 517source arch/powerpc/platforms/cell/Kconfig
@@ -709,7 +735,7 @@ config PPC_I8259
709config PPC_INDIRECT_PCI 735config PPC_INDIRECT_PCI
710 bool 736 bool
711 depends on PCI 737 depends on PCI
712 default y if 40x || 44x || 85xx || 83xx 738 default y if 40x || 44x || 85xx
713 default n 739 default n
714 740
715config EISA 741config EISA
@@ -718,13 +744,16 @@ config EISA
718config SBUS 744config SBUS
719 bool 745 bool
720 746
747config FSL_SOC
748 bool
749
721# Yes MCA RS/6000s exist but Linux-PPC does not currently support any 750# Yes MCA RS/6000s exist but Linux-PPC does not currently support any
722config MCA 751config MCA
723 bool 752 bool
724 753
725config PCI 754config PCI
726 bool "PCI support" if 40x || CPM2 || 83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) 755 bool "PCI support" if 40x || CPM2 || PPC_83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
727 default y if !40x && !CPM2 && !8xx && !APUS && !83xx && !85xx 756 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !85xx
728 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS 757 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
729 default PCI_QSPAN if !4xx && !CPM2 && 8xx 758 default PCI_QSPAN if !4xx && !CPM2 && 8xx
730 help 759 help
@@ -737,11 +766,6 @@ config PCI_DOMAINS
737 bool 766 bool
738 default PCI 767 default PCI
739 768
740config MPC83xx_PCI2
741 bool " Supprt for 2nd PCI host controller"
742 depends on PCI && MPC834x
743 default y if MPC834x_SYS
744
745config PCI_QSPAN 769config PCI_QSPAN
746 bool "QSpan PCI" 770 bool "QSpan PCI"
747 depends on !4xx && !CPM2 && 8xx 771 depends on !4xx && !CPM2 && 8xx
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 30a30bf559ea..9254806f7032 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -115,4 +115,46 @@ config PPC_OCP
115 depends on IBM_OCP || XILINX_OCP 115 depends on IBM_OCP || XILINX_OCP
116 default y 116 default y
117 117
118choice
119 prompt "Early debugging (dangerous)"
120 bool
121 optional
122 help
123 Enable early debugging. Careful, if you enable debugging for the
124 wrong type of machine your kernel _will not boot_.
125
126config PPC_EARLY_DEBUG_LPAR
127 bool "LPAR HV Console"
128 depends on PPC_PSERIES
129 help
130 Select this to enable early debugging for a machine with a HVC
131 console on vterm 0.
132
133config PPC_EARLY_DEBUG_G5
134 bool "Apple G5"
135 depends on PPC_PMAC64
136 help
137 Select this to enable early debugging for Apple G5 machines.
138
139config PPC_EARLY_DEBUG_RTAS
140 bool "RTAS Panel"
141 depends on PPC_RTAS
142 help
143 Select this to enable early debugging via the RTAS panel.
144
145config PPC_EARLY_DEBUG_MAPLE
146 bool "Maple real mode"
147 depends on PPC_MAPLE
148 help
149 Select this to enable early debugging for Maple.
150
151config PPC_EARLY_DEBUG_ISERIES
152 bool "iSeries HV Console"
153 depends on PPC_ISERIES
154 help
155 Select this to enable early debugging for legacy iSeries. You need
156 to hit "Ctrl-x Ctrl-x" to see the messages on the console.
157
158endchoice
159
118endmenu 160endmenu
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 5f80e58e5cb3..d3654a264ef7 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -76,8 +76,7 @@ LINUXINCLUDE += $(LINUXINCLUDE-y)
76CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__ 76CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__
77 77
78ifeq ($(CONFIG_PPC64),y) 78ifeq ($(CONFIG_PPC64),y)
79GCC_VERSION := $(call cc-version) 79GCC_BROKEN_VEC := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)
80GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi)
81 80
82ifeq ($(CONFIG_POWER4_ONLY),y) 81ifeq ($(CONFIG_POWER4_ONLY),y)
83ifeq ($(CONFIG_ALTIVEC),y) 82ifeq ($(CONFIG_ALTIVEC),y)
@@ -189,10 +188,9 @@ TOUT := .tmp_gas_check
189# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec 188# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec
190# instructions. 189# instructions.
191# gcc-3.4 and binutils-2.14 are a fatal combination. 190# gcc-3.4 and binutils-2.14 are a fatal combination.
192GCC_VERSION := $(call cc-version)
193 191
194checkbin: 192checkbin:
195 @if test "$(GCC_VERSION)" = "0304" ; then \ 193 @if test "$(call cc-version)" = "0304" ; then \
196 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ 194 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
197 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ 195 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
198 echo 'correctly with gcc-3.4 and your version of binutils.'; \ 196 echo 'correctly with gcc-3.4 and your version of binutils.'; \
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
new file mode 100644
index 000000000000..45c9ad23526e
--- /dev/null
+++ b/arch/powerpc/boot/.gitignore
@@ -0,0 +1,20 @@
1addnote
2infblock.c
3infblock.h
4infcodes.c
5infcodes.h
6inffast.c
7inffast.h
8inflate.c
9inftrees.c
10inftrees.h
11infutil.c
12infutil.h
13kernel-vmlinux.strip.c
14kernel-vmlinux.strip.gz
15uImage
16zImage
17zImage.vmode
18zconf.h
19zlib.h
20zutil.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 22726aefc8ea..b53d677f6742 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -176,4 +176,4 @@ $(obj)/uImage: $(obj)/vmlinux.gz
176install: $(CONFIGURE) $(BOOTIMAGE) 176install: $(CONFIGURE) $(BOOTIMAGE)
177 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)" 177 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
178 178
179clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip) 179clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 509399eab6f5..0b2b55a79c3c 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -861,7 +861,7 @@ CONFIG_SERIAL_CORE=y
861CONFIG_SERIAL_CORE_CONSOLE=y 861CONFIG_SERIAL_CORE_CONSOLE=y
862# CONFIG_SERIAL_PMACZILOG is not set 862# CONFIG_SERIAL_PMACZILOG is not set
863CONFIG_SERIAL_ICOM=m 863CONFIG_SERIAL_ICOM=m
864CONFIG_SERIAL_JSM=m 864# CONFIG_SERIAL_JSM is not set
865CONFIG_UNIX98_PTYS=y 865CONFIG_UNIX98_PTYS=y
866CONFIG_LEGACY_PTYS=y 866CONFIG_LEGACY_PTYS=y
867CONFIG_LEGACY_PTY_COUNT=256 867CONFIG_LEGACY_PTY_COUNT=256
@@ -878,7 +878,7 @@ CONFIG_HVCS=m
878# 878#
879# CONFIG_WATCHDOG is not set 879# CONFIG_WATCHDOG is not set
880# CONFIG_RTC is not set 880# CONFIG_RTC is not set
881# CONFIG_GEN_RTC is not set 881CONFIG_GEN_RTC=y
882# CONFIG_DTLK is not set 882# CONFIG_DTLK is not set
883# CONFIG_R3964 is not set 883# CONFIG_R3964 is not set
884# CONFIG_APPLICOM is not set 884# CONFIG_APPLICOM is not set
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 6e03b595b6c8..a94699d8dc52 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -4,7 +4,6 @@
4 4
5ifeq ($(CONFIG_PPC64),y) 5ifeq ($(CONFIG_PPC64),y)
6EXTRA_CFLAGS += -mno-minimal-toc 6EXTRA_CFLAGS += -mno-minimal-toc
7CFLAGS_ioctl32.o += -Ifs/
8endif 7endif
9ifeq ($(CONFIG_PPC32),y) 8ifeq ($(CONFIG_PPC32),y)
10CFLAGS_prom_init.o += -fPIC 9CFLAGS_prom_init.o += -fPIC
@@ -12,11 +11,12 @@ CFLAGS_btext.o += -fPIC
12endif 11endif
13 12
14obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ 13obj-y := semaphore.o cputable.o ptrace.o syscalls.o \
15 irq.o align.o signal_32.o pmc.o vdso.o 14 irq.o align.o signal_32.o pmc.o vdso.o \
15 init_task.o process.o
16obj-y += vdso32/ 16obj-y += vdso32/
17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ 17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \
18 signal_64.o ptrace32.o systbl.o \ 18 signal_64.o ptrace32.o systbl.o \
19 paca.o ioctl32.o cpu_setup_power4.o \ 19 paca.o cpu_setup_power4.o \
20 firmware.o sysfs.o idle_64.o 20 firmware.o sysfs.o idle_64.o
21obj-$(CONFIG_PPC64) += vdso64/ 21obj-$(CONFIG_PPC64) += vdso64/
22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o 22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o
@@ -45,8 +45,7 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
45extra-$(CONFIG_8xx) := head_8xx.o 45extra-$(CONFIG_8xx) := head_8xx.o
46extra-y += vmlinux.lds 46extra-y += vmlinux.lds
47 47
48obj-y += process.o init_task.o time.o \ 48obj-y += time.o prom.o traps.o setup-common.o udbg.o
49 prom.o traps.o setup-common.o udbg.o
50obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o systbl.o 49obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o systbl.o
51obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o 50obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o
52obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o 51obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
@@ -55,16 +54,16 @@ obj-$(CONFIG_BOOTX_TEXT) += btext.o
55obj-$(CONFIG_6xx) += idle_6xx.o 54obj-$(CONFIG_6xx) += idle_6xx.o
56obj-$(CONFIG_SMP) += smp.o 55obj-$(CONFIG_SMP) += smp.o
57obj-$(CONFIG_KPROBES) += kprobes.o 56obj-$(CONFIG_KPROBES) += kprobes.o
58obj-$(CONFIG_SERIAL_8250) += legacy_serial.o udbg_16550.o 57obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
59module-$(CONFIG_PPC64) += module_64.o 58module-$(CONFIG_PPC64) += module_64.o
60obj-$(CONFIG_MODULES) += $(module-y) 59obj-$(CONFIG_MODULES) += $(module-y)
61 60
62pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o pci_iommu.o \ 61pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o pci_iommu.o \
63 pci_direct_iommu.o iomap.o 62 pci_direct_iommu.o iomap.o
64obj-$(CONFIG_PCI) += $(pci64-y) 63obj-$(CONFIG_PCI) += $(pci64-y)
65kexec-$(CONFIG_PPC64) := machine_kexec_64.o 64kexec-$(CONFIG_PPC64) := machine_kexec_64.o crash.o
66kexec-$(CONFIG_PPC32) := machine_kexec_32.o 65kexec-$(CONFIG_PPC32) := machine_kexec_32.o
67obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o $(kexec-y) 66obj-$(CONFIG_KEXEC) += machine_kexec.o $(kexec-y)
68 67
69ifeq ($(CONFIG_PPC_ISERIES),y) 68ifeq ($(CONFIG_PPC_ISERIES),y)
70$(obj)/head_64.o: $(obj)/lparmap.s 69$(obj)/head_64.o: $(obj)/lparmap.s
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 4681155121ef..5f248e3fdf82 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -18,7 +18,6 @@
18#include <linux/kexec.h> 18#include <linux/kexec.h>
19#include <linux/bootmem.h> 19#include <linux/bootmem.h>
20#include <linux/crash_dump.h> 20#include <linux/crash_dump.h>
21#include <linux/irq.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/elf.h> 22#include <linux/elf.h>
24#include <linux/elfcore.h> 23#include <linux/elfcore.h>
@@ -30,6 +29,7 @@
30#include <asm/kdump.h> 29#include <asm/kdump.h>
31#include <asm/lmb.h> 30#include <asm/lmb.h>
32#include <asm/firmware.h> 31#include <asm/firmware.h>
32#include <asm/smp.h>
33 33
34#ifdef DEBUG 34#ifdef DEBUG
35#include <asm/udbg.h> 35#include <asm/udbg.h>
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 87effa3f21a7..211d72653ea6 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -55,6 +55,7 @@ void __init kdump_setup(void)
55 DBG(" <- kdump_setup()\n"); 55 DBG(" <- kdump_setup()\n");
56} 56}
57 57
58#ifdef CONFIG_PROC_VMCORE
58static int __init parse_elfcorehdr(char *p) 59static int __init parse_elfcorehdr(char *p)
59{ 60{
60 if (p) 61 if (p)
@@ -63,6 +64,7 @@ static int __init parse_elfcorehdr(char *p)
63 return 0; 64 return 0;
64} 65}
65__setup("elfcorehdr=", parse_elfcorehdr); 66__setup("elfcorehdr=", parse_elfcorehdr);
67#endif
66 68
67static int __init parse_savemaxmem(char *p) 69static int __init parse_savemaxmem(char *p)
68{ 70{
diff --git a/arch/powerpc/kernel/ioctl32.c b/arch/powerpc/kernel/ioctl32.c
deleted file mode 100644
index 0fa3d27fef01..000000000000
--- a/arch/powerpc/kernel/ioctl32.c
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Based on sparc64 ioctl32.c by:
5 *
6 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
7 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
8 *
9 * ppc64 changes:
10 *
11 * Copyright (C) 2000 Ken Aaker (kdaaker@rchland.vnet.ibm.com)
12 * Copyright (C) 2001 Anton Blanchard (antonb@au.ibm.com)
13 *
14 * These routines maintain argument size conversion between 32bit and 64bit
15 * ioctls.
16 *
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
21 */
22
23#define INCLUDES
24#include "compat_ioctl.c"
25#include <linux/syscalls.h>
26
27#define CODE
28#include "compat_ioctl.c"
29
30#define HANDLE_IOCTL(cmd,handler) { cmd, (ioctl_trans_handler_t)handler, NULL },
31#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
32
33#define IOCTL_TABLE_START \
34 struct ioctl_trans ioctl_start[] = {
35#define IOCTL_TABLE_END \
36 };
37
38IOCTL_TABLE_START
39#include <linux/compat_ioctl.h>
40#define DECLARES
41#include "compat_ioctl.c"
42
43IOCTL_TABLE_END
44
45int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 5368f9c2e6bf..cfab48566db1 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -35,7 +35,6 @@
35#include <asm/kdebug.h> 35#include <asm/kdebug.h>
36#include <asm/sstep.h> 36#include <asm/sstep.h>
37 37
38static DECLARE_MUTEX(kprobe_mutex);
39DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 38DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
40DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 39DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
41 40
@@ -54,19 +53,17 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
54 53
55 /* insn must be on a special executable page on ppc64 */ 54 /* insn must be on a special executable page on ppc64 */
56 if (!ret) { 55 if (!ret) {
57 down(&kprobe_mutex);
58 p->ainsn.insn = get_insn_slot(); 56 p->ainsn.insn = get_insn_slot();
59 up(&kprobe_mutex);
60 if (!p->ainsn.insn) 57 if (!p->ainsn.insn)
61 ret = -ENOMEM; 58 ret = -ENOMEM;
62 } 59 }
63 return ret;
64}
65 60
66void __kprobes arch_copy_kprobe(struct kprobe *p) 61 if (!ret) {
67{ 62 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
68 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 63 p->opcode = *p->addr;
69 p->opcode = *p->addr; 64 }
65
66 return ret;
70} 67}
71 68
72void __kprobes arch_arm_kprobe(struct kprobe *p) 69void __kprobes arch_arm_kprobe(struct kprobe *p)
@@ -182,6 +179,18 @@ static inline int kprobe_handler(struct pt_regs *regs)
182 kcb->kprobe_status = KPROBE_REENTER; 179 kcb->kprobe_status = KPROBE_REENTER;
183 return 1; 180 return 1;
184 } else { 181 } else {
182 if (*addr != BREAKPOINT_INSTRUCTION) {
183 /* If trap variant, then it belongs not to us */
184 kprobe_opcode_t cur_insn = *addr;
185 if (is_trap(cur_insn))
186 goto no_kprobe;
187 /* The breakpoint instruction was removed by
188 * another cpu right after we hit, no further
189 * handling of this interrupt is appropriate
190 */
191 ret = 1;
192 goto no_kprobe;
193 }
185 p = __get_cpu_var(current_kprobe); 194 p = __get_cpu_var(current_kprobe);
186 if (p->break_handler && p->break_handler(p, regs)) { 195 if (p->break_handler && p->break_handler(p, regs)) {
187 goto ss_probe; 196 goto ss_probe;
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index a91e40c9ae45..a81ca1b841ec 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -14,12 +14,6 @@
14#include <linux/threads.h> 14#include <linux/threads.h>
15#include <asm/machdep.h> 15#include <asm/machdep.h>
16 16
17/*
18 * Provide a dummy crash_notes definition until crash dump is implemented.
19 * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
20 */
21note_buf_t crash_notes[NR_CPUS];
22
23void machine_crash_shutdown(struct pt_regs *regs) 17void machine_crash_shutdown(struct pt_regs *regs)
24{ 18{
25 if (ppc_md.machine_crash_shutdown) 19 if (ppc_md.machine_crash_shutdown)
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index fc60a773af7d..c367520bc1c3 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -53,6 +53,7 @@ EXPORT_SYMBOL(io_page_mask);
53#ifdef CONFIG_PPC_MULTIPLATFORM 53#ifdef CONFIG_PPC_MULTIPLATFORM
54static void fixup_resource(struct resource *res, struct pci_dev *dev); 54static void fixup_resource(struct resource *res, struct pci_dev *dev);
55static void do_bus_setup(struct pci_bus *bus); 55static void do_bus_setup(struct pci_bus *bus);
56static void phbs_remap_io(void);
56#endif 57#endif
57 58
58/* pci_io_base -- the base address from which io bars are offsets. 59/* pci_io_base -- the base address from which io bars are offsets.
@@ -251,6 +252,7 @@ void pcibios_free_controller(struct pci_controller *phb)
251 kfree(phb); 252 kfree(phb);
252} 253}
253 254
255#ifndef CONFIG_PPC_ISERIES
254void __devinit pcibios_claim_one_bus(struct pci_bus *b) 256void __devinit pcibios_claim_one_bus(struct pci_bus *b)
255{ 257{
256 struct pci_dev *dev; 258 struct pci_dev *dev;
@@ -271,8 +273,10 @@ void __devinit pcibios_claim_one_bus(struct pci_bus *b)
271 list_for_each_entry(child_bus, &b->children, node) 273 list_for_each_entry(child_bus, &b->children, node)
272 pcibios_claim_one_bus(child_bus); 274 pcibios_claim_one_bus(child_bus);
273} 275}
276#ifdef CONFIG_HOTPLUG
277EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
278#endif
274 279
275#ifndef CONFIG_PPC_ISERIES
276static void __init pcibios_claim_of_setup(void) 280static void __init pcibios_claim_of_setup(void)
277{ 281{
278 struct pci_bus *b; 282 struct pci_bus *b;
@@ -381,7 +385,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
381 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0); 385 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
382 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0); 386 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
383 387
384 dev->cfg_size = 256; /*pci_cfg_space_size(dev);*/ 388 dev->cfg_size = pci_cfg_space_size(dev);
385 389
386 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), 390 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
387 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); 391 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
@@ -1215,7 +1219,7 @@ int remap_bus_range(struct pci_bus *bus)
1215} 1219}
1216EXPORT_SYMBOL(remap_bus_range); 1220EXPORT_SYMBOL(remap_bus_range);
1217 1221
1218void phbs_remap_io(void) 1222static void phbs_remap_io(void)
1219{ 1223{
1220 struct pci_controller *hose, *tmp; 1224 struct pci_controller *hose, *tmp;
1221 1225
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index b2758148a0de..16d9a904f3cb 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -244,7 +244,6 @@ EXPORT_SYMBOL(set_context);
244extern long mol_trampoline; 244extern long mol_trampoline;
245EXPORT_SYMBOL(mol_trampoline); /* For MOL */ 245EXPORT_SYMBOL(mol_trampoline); /* For MOL */
246EXPORT_SYMBOL(flush_hash_pages); /* For MOL */ 246EXPORT_SYMBOL(flush_hash_pages); /* For MOL */
247EXPORT_SYMBOL_GPL(__handle_mm_fault); /* For MOL */
248#ifdef CONFIG_SMP 247#ifdef CONFIG_SMP
249extern int mmu_hash_lock; 248extern int mmu_hash_lock;
250EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */ 249EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 105d5609ff57..57703994a063 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -201,13 +201,13 @@ int dump_spe(struct pt_regs *regs, elf_vrregset_t *evrregs)
201} 201}
202#endif /* CONFIG_SPE */ 202#endif /* CONFIG_SPE */
203 203
204#ifndef CONFIG_SMP
204/* 205/*
205 * If we are doing lazy switching of CPU state (FP, altivec or SPE), 206 * If we are doing lazy switching of CPU state (FP, altivec or SPE),
206 * and the current task has some state, discard it. 207 * and the current task has some state, discard it.
207 */ 208 */
208static inline void discard_lazy_cpu_state(void) 209void discard_lazy_cpu_state(void)
209{ 210{
210#ifndef CONFIG_SMP
211 preempt_disable(); 211 preempt_disable();
212 if (last_task_used_math == current) 212 if (last_task_used_math == current)
213 last_task_used_math = NULL; 213 last_task_used_math = NULL;
@@ -220,9 +220,10 @@ static inline void discard_lazy_cpu_state(void)
220 last_task_used_spe = NULL; 220 last_task_used_spe = NULL;
221#endif 221#endif
222 preempt_enable(); 222 preempt_enable();
223#endif /* CONFIG_SMP */
224} 223}
224#endif /* CONFIG_SMP */
225 225
226#ifdef CONFIG_PPC_MERGE /* XXX for now */
226int set_dabr(unsigned long dabr) 227int set_dabr(unsigned long dabr)
227{ 228{
228 if (ppc_md.set_dabr) 229 if (ppc_md.set_dabr)
@@ -231,6 +232,7 @@ int set_dabr(unsigned long dabr)
231 mtspr(SPRN_DABR, dabr); 232 mtspr(SPRN_DABR, dabr);
232 return 0; 233 return 0;
233} 234}
235#endif
234 236
235#ifdef CONFIG_PPC64 237#ifdef CONFIG_PPC64
236DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array); 238DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
@@ -424,7 +426,7 @@ void show_regs(struct pt_regs * regs)
424 if (trap == 0x300 || trap == 0x600) 426 if (trap == 0x300 || trap == 0x600)
425 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr); 427 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
426 printk("TASK = %p[%d] '%s' THREAD: %p", 428 printk("TASK = %p[%d] '%s' THREAD: %p",
427 current, current->pid, current->comm, current->thread_info); 429 current, current->pid, current->comm, task_thread_info(current));
428 430
429#ifdef CONFIG_SMP 431#ifdef CONFIG_SMP
430 printk(" CPU: %d", smp_processor_id()); 432 printk(" CPU: %d", smp_processor_id());
@@ -503,7 +505,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
503{ 505{
504 struct pt_regs *childregs, *kregs; 506 struct pt_regs *childregs, *kregs;
505 extern void ret_from_fork(void); 507 extern void ret_from_fork(void);
506 unsigned long sp = (unsigned long)p->thread_info + THREAD_SIZE; 508 unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
507 509
508 CHECK_FULL_REGS(regs); 510 CHECK_FULL_REGS(regs);
509 /* Copy registers */ 511 /* Copy registers */
@@ -516,7 +518,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
516#ifdef CONFIG_PPC32 518#ifdef CONFIG_PPC32
517 childregs->gpr[2] = (unsigned long) p; 519 childregs->gpr[2] = (unsigned long) p;
518#else 520#else
519 clear_ti_thread_flag(p->thread_info, TIF_32BIT); 521 clear_tsk_thread_flag(p, TIF_32BIT);
520#endif 522#endif
521 p->thread.regs = NULL; /* no user register state */ 523 p->thread.regs = NULL; /* no user register state */
522 } else { 524 } else {
@@ -588,10 +590,8 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
588 * set. Do it now. 590 * set. Do it now.
589 */ 591 */
590 if (!current->thread.regs) { 592 if (!current->thread.regs) {
591 unsigned long childregs = (unsigned long)current->thread_info + 593 struct pt_regs *regs = task_stack_page(current) + THREAD_SIZE;
592 THREAD_SIZE; 594 current->thread.regs = regs - 1;
593 childregs -= sizeof(struct pt_regs);
594 current->thread.regs = (struct pt_regs *)childregs;
595 } 595 }
596 596
597 memset(regs->gpr, 0, sizeof(regs->gpr)); 597 memset(regs->gpr, 0, sizeof(regs->gpr));
@@ -767,7 +767,7 @@ out:
767static int validate_sp(unsigned long sp, struct task_struct *p, 767static int validate_sp(unsigned long sp, struct task_struct *p,
768 unsigned long nbytes) 768 unsigned long nbytes)
769{ 769{
770 unsigned long stack_page = (unsigned long)p->thread_info; 770 unsigned long stack_page = (unsigned long)task_stack_page(p);
771 771
772 if (sp >= stack_page + sizeof(struct thread_struct) 772 if (sp >= stack_page + sizeof(struct thread_struct)
773 && sp <= stack_page + THREAD_SIZE - nbytes) 773 && sp <= stack_page + THREAD_SIZE - nbytes)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 34ab0daec3a7..02e2115323e4 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1100,17 +1100,37 @@ static int __init early_init_dt_scan_memory(unsigned long node,
1100 1100
1101static void __init early_reserve_mem(void) 1101static void __init early_reserve_mem(void)
1102{ 1102{
1103 unsigned long base, size; 1103 u64 base, size;
1104 unsigned long *reserve_map; 1104 u64 *reserve_map;
1105 1105
1106 reserve_map = (unsigned long *)(((unsigned long)initial_boot_params) + 1106 reserve_map = (u64 *)(((unsigned long)initial_boot_params) +
1107 initial_boot_params->off_mem_rsvmap); 1107 initial_boot_params->off_mem_rsvmap);
1108#ifdef CONFIG_PPC32
1109 /*
1110 * Handle the case where we might be booting from an old kexec
1111 * image that setup the mem_rsvmap as pairs of 32-bit values
1112 */
1113 if (*reserve_map > 0xffffffffull) {
1114 u32 base_32, size_32;
1115 u32 *reserve_map_32 = (u32 *)reserve_map;
1116
1117 while (1) {
1118 base_32 = *(reserve_map_32++);
1119 size_32 = *(reserve_map_32++);
1120 if (size_32 == 0)
1121 break;
1122 DBG("reserving: %lx -> %lx\n", base_32, size_32);
1123 lmb_reserve(base_32, size_32);
1124 }
1125 return;
1126 }
1127#endif
1108 while (1) { 1128 while (1) {
1109 base = *(reserve_map++); 1129 base = *(reserve_map++);
1110 size = *(reserve_map++); 1130 size = *(reserve_map++);
1111 if (size == 0) 1131 if (size == 0)
1112 break; 1132 break;
1113 DBG("reserving: %lx -> %lx\n", base, size); 1133 DBG("reserving: %llx -> %llx\n", base, size);
1114 lmb_reserve(base, size); 1134 lmb_reserve(base, size);
1115 } 1135 }
1116 1136
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index e381f2fc121c..d963a12ec640 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -137,8 +137,8 @@ struct prom_t {
137}; 137};
138 138
139struct mem_map_entry { 139struct mem_map_entry {
140 unsigned long base; 140 u64 base;
141 unsigned long size; 141 u64 size;
142}; 142};
143 143
144typedef u32 cell_t; 144typedef u32 cell_t;
@@ -897,9 +897,9 @@ static unsigned long __init prom_next_cell(int s, cell_t **cellp)
897 * If problems seem to show up, it would be a good start to track 897 * If problems seem to show up, it would be a good start to track
898 * them down. 898 * them down.
899 */ 899 */
900static void reserve_mem(unsigned long base, unsigned long size) 900static void reserve_mem(u64 base, u64 size)
901{ 901{
902 unsigned long top = base + size; 902 u64 top = base + size;
903 unsigned long cnt = RELOC(mem_reserve_cnt); 903 unsigned long cnt = RELOC(mem_reserve_cnt);
904 904
905 if (size == 0) 905 if (size == 0)
diff --git a/arch/powerpc/kernel/ptrace-common.h b/arch/powerpc/kernel/ptrace-common.h
index b1babb729673..5ccbdbe0d5c9 100644
--- a/arch/powerpc/kernel/ptrace-common.h
+++ b/arch/powerpc/kernel/ptrace-common.h
@@ -62,7 +62,7 @@ static inline void set_single_step(struct task_struct *task)
62 struct pt_regs *regs = task->thread.regs; 62 struct pt_regs *regs = task->thread.regs;
63 if (regs != NULL) 63 if (regs != NULL)
64 regs->msr |= MSR_SE; 64 regs->msr |= MSR_SE;
65 set_ti_thread_flag(task->thread_info, TIF_SINGLESTEP); 65 set_tsk_thread_flag(task, TIF_SINGLESTEP);
66} 66}
67 67
68static inline void clear_single_step(struct task_struct *task) 68static inline void clear_single_step(struct task_struct *task)
@@ -70,7 +70,7 @@ static inline void clear_single_step(struct task_struct *task)
70 struct pt_regs *regs = task->thread.regs; 70 struct pt_regs *regs = task->thread.regs;
71 if (regs != NULL) 71 if (regs != NULL)
72 regs->msr &= ~MSR_SE; 72 regs->msr &= ~MSR_SE;
73 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP); 73 clear_tsk_thread_flag(task, TIF_SINGLESTEP);
74} 74}
75 75
76#ifdef CONFIG_ALTIVEC 76#ifdef CONFIG_ALTIVEC
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index ae2e2a31a705..4b9cfe4637b1 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -17,6 +17,7 @@
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/capability.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21 22
22#include <asm/prom.h> 23#include <asm/prom.h>
@@ -29,6 +30,7 @@
29#include <asm/delay.h> 30#include <asm/delay.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/lmb.h> 32#include <asm/lmb.h>
33#include <asm/udbg.h>
32 34
33struct rtas_t rtas = { 35struct rtas_t rtas = {
34 .lock = SPIN_LOCK_UNLOCKED 36 .lock = SPIN_LOCK_UNLOCKED
@@ -52,7 +54,7 @@ EXPORT_SYMBOL(rtas_flash_term_hook);
52 * are designed only for very early low-level debugging, which 54 * are designed only for very early low-level debugging, which
53 * is why the token is hard-coded to 10. 55 * is why the token is hard-coded to 10.
54 */ 56 */
55void call_rtas_display_status(unsigned char c) 57static void call_rtas_display_status(char c)
56{ 58{
57 struct rtas_args *args = &rtas.args; 59 struct rtas_args *args = &rtas.args;
58 unsigned long s; 60 unsigned long s;
@@ -65,14 +67,14 @@ void call_rtas_display_status(unsigned char c)
65 args->nargs = 1; 67 args->nargs = 1;
66 args->nret = 1; 68 args->nret = 1;
67 args->rets = (rtas_arg_t *)&(args->args[1]); 69 args->rets = (rtas_arg_t *)&(args->args[1]);
68 args->args[0] = (int)c; 70 args->args[0] = (unsigned char)c;
69 71
70 enter_rtas(__pa(args)); 72 enter_rtas(__pa(args));
71 73
72 spin_unlock_irqrestore(&rtas.lock, s); 74 spin_unlock_irqrestore(&rtas.lock, s);
73} 75}
74 76
75void call_rtas_display_status_delay(unsigned char c) 77static void call_rtas_display_status_delay(char c)
76{ 78{
77 static int pending_newline = 0; /* did last write end with unprinted newline? */ 79 static int pending_newline = 0; /* did last write end with unprinted newline? */
78 static int width = 16; 80 static int width = 16;
@@ -96,6 +98,11 @@ void call_rtas_display_status_delay(unsigned char c)
96 } 98 }
97} 99}
98 100
101void __init udbg_init_rtas(void)
102{
103 udbg_putc = call_rtas_display_status_delay;
104}
105
99void rtas_progress(char *s, unsigned short hex) 106void rtas_progress(char *s, unsigned short hex)
100{ 107{
101 struct device_node *root; 108 struct device_node *root;
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 45b8109951fe..5579f6559912 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -72,7 +72,7 @@ static int of_device_available(struct device_node * dn)
72 return 0; 72 return 0;
73} 73}
74 74
75static int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val) 75int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
76{ 76{
77 int returnval = -1; 77 int returnval = -1;
78 unsigned long buid, addr; 78 unsigned long buid, addr;
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e5d285adb496..db72a92943bf 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -299,9 +299,7 @@ void __init setup_arch(char **cmdline_p)
299 if (ppc_md.init_early) 299 if (ppc_md.init_early)
300 ppc_md.init_early(); 300 ppc_md.init_early();
301 301
302#ifdef CONFIG_SERIAL_8250
303 find_legacy_serial_ports(); 302 find_legacy_serial_ports();
304#endif
305 finish_device_tree(); 303 finish_device_tree();
306 304
307 smp_setup_cpu_maps(); 305 smp_setup_cpu_maps();
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 81567e931260..e29b275e09e0 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -33,6 +33,7 @@
33#include <linux/unistd.h> 33#include <linux/unistd.h>
34#include <linux/serial.h> 34#include <linux/serial.h>
35#include <linux/serial_8250.h> 35#include <linux/serial_8250.h>
36#include <linux/bootmem.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/kdump.h> 38#include <asm/kdump.h>
38#include <asm/prom.h> 39#include <asm/prom.h>
@@ -70,33 +71,6 @@
70#define DBG(fmt...) 71#define DBG(fmt...)
71#endif 72#endif
72 73
73/*
74 * Here are some early debugging facilities. You can enable one
75 * but your kernel will not boot on anything else if you do so
76 */
77
78/* This one is for use on LPAR machines that support an HVC console
79 * on vterm 0
80 */
81extern void udbg_init_debug_lpar(void);
82/* This one is for use on Apple G5 machines
83 */
84extern void udbg_init_pmac_realmode(void);
85/* That's RTAS panel debug */
86extern void call_rtas_display_status_delay(unsigned char c);
87/* Here's maple real mode debug */
88extern void udbg_init_maple_realmode(void);
89
90#define EARLY_DEBUG_INIT() do {} while(0)
91
92#if 0
93#define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
94#define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
95#define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
96#define EARLY_DEBUG_INIT() \
97 do { udbg_putc = call_rtas_display_status_delay; } while(0)
98#endif
99
100int have_of = 1; 74int have_of = 1;
101int boot_cpuid = 0; 75int boot_cpuid = 0;
102int boot_cpuid_phys = 0; 76int boot_cpuid_phys = 0;
@@ -237,11 +211,8 @@ void __init early_setup(unsigned long dt_ptr)
237 struct paca_struct *lpaca = get_paca(); 211 struct paca_struct *lpaca = get_paca();
238 static struct machdep_calls **mach; 212 static struct machdep_calls **mach;
239 213
240 /* 214 /* Enable early debugging if any specified (see udbg.h) */
241 * Enable early debugging if any specified (see top of 215 udbg_early_init();
242 * this file)
243 */
244 EARLY_DEBUG_INIT();
245 216
246 DBG(" -> early_setup()\n"); 217 DBG(" -> early_setup()\n");
247 218
@@ -472,9 +443,7 @@ void __init setup_system(void)
472 * hash table management for us, thus ioremap works. We do that early 443 * hash table management for us, thus ioremap works. We do that early
473 * so that further code can be debugged 444 * so that further code can be debugged
474 */ 445 */
475#ifdef CONFIG_SERIAL_8250
476 find_legacy_serial_ports(); 446 find_legacy_serial_ports();
477#endif
478 447
479 /* 448 /*
480 * "Finish" the device-tree, that is do the actual parsing of 449 * "Finish" the device-tree, that is do the actual parsing of
@@ -686,3 +655,28 @@ void cpu_die(void)
686 if (ppc_md.cpu_die) 655 if (ppc_md.cpu_die)
687 ppc_md.cpu_die(); 656 ppc_md.cpu_die();
688} 657}
658
659#ifdef CONFIG_SMP
660void __init setup_per_cpu_areas(void)
661{
662 int i;
663 unsigned long size;
664 char *ptr;
665
666 /* Copy section for each CPU (we discard the original) */
667 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
668#ifdef CONFIG_MODULES
669 if (size < PERCPU_ENOUGH_ROOM)
670 size = PERCPU_ENOUGH_ROOM;
671#endif
672
673 for_each_cpu(i) {
674 ptr = alloc_bootmem_node(NODE_DATA(cpu_to_node(i)), size);
675 if (!ptr)
676 panic("Cannot allocate cpu data for CPU %d\n", i);
677
678 paca[i].data_offset = ptr - __per_cpu_start;
679 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
680 }
681}
682#endif
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index d3f0b6d452fb..177bba78fb0b 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -497,6 +497,15 @@ static long restore_user_regs(struct pt_regs *regs,
497 if (err) 497 if (err)
498 return 1; 498 return 1;
499 499
500 /*
501 * Do this before updating the thread state in
502 * current->thread.fpr/vr/evr. That way, if we get preempted
503 * and another task grabs the FPU/Altivec/SPE, it won't be
504 * tempted to save the current CPU state into the thread_struct
505 * and corrupt what we are writing there.
506 */
507 discard_lazy_cpu_state();
508
500 /* force the process to reload the FP registers from 509 /* force the process to reload the FP registers from
501 current->thread when it next does FP instructions */ 510 current->thread when it next does FP instructions */
502 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1); 511 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
@@ -538,18 +547,6 @@ static long restore_user_regs(struct pt_regs *regs,
538 return 1; 547 return 1;
539#endif /* CONFIG_SPE */ 548#endif /* CONFIG_SPE */
540 549
541#ifndef CONFIG_SMP
542 preempt_disable();
543 if (last_task_used_math == current)
544 last_task_used_math = NULL;
545 if (last_task_used_altivec == current)
546 last_task_used_altivec = NULL;
547#ifdef CONFIG_SPE
548 if (last_task_used_spe == current)
549 last_task_used_spe = NULL;
550#endif
551 preempt_enable();
552#endif
553 return 0; 550 return 0;
554} 551}
555 552
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 5462bef898f6..7b9d999e2115 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -207,10 +207,20 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
207 207
208 if (!sig) 208 if (!sig)
209 regs->gpr[13] = save_r13; 209 regs->gpr[13] = save_r13;
210 err |= __copy_from_user(&current->thread.fpr, &sc->fp_regs, FP_REGS_SIZE);
211 if (set != NULL) 210 if (set != NULL)
212 err |= __get_user(set->sig[0], &sc->oldmask); 211 err |= __get_user(set->sig[0], &sc->oldmask);
213 212
213 /*
214 * Do this before updating the thread state in
215 * current->thread.fpr/vr. That way, if we get preempted
216 * and another task grabs the FPU/Altivec, it won't be
217 * tempted to save the current CPU state into the thread_struct
218 * and corrupt what we are writing there.
219 */
220 discard_lazy_cpu_state();
221
222 err |= __copy_from_user(&current->thread.fpr, &sc->fp_regs, FP_REGS_SIZE);
223
214#ifdef CONFIG_ALTIVEC 224#ifdef CONFIG_ALTIVEC
215 err |= __get_user(v_regs, &sc->v_regs); 225 err |= __get_user(v_regs, &sc->v_regs);
216 err |= __get_user(msr, &sc->gp_regs[PT_MSR]); 226 err |= __get_user(msr, &sc->gp_regs[PT_MSR]);
@@ -229,14 +239,6 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
229 current->thread.vrsave = 0; 239 current->thread.vrsave = 0;
230#endif /* CONFIG_ALTIVEC */ 240#endif /* CONFIG_ALTIVEC */
231 241
232#ifndef CONFIG_SMP
233 preempt_disable();
234 if (last_task_used_math == current)
235 last_task_used_math = NULL;
236 if (last_task_used_altivec == current)
237 last_task_used_altivec = NULL;
238 preempt_enable();
239#endif
240 /* Force reload of FP/VEC */ 242 /* Force reload of FP/VEC */
241 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1 | MSR_VEC); 243 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1 | MSR_VEC);
242 244
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index d381ec90b759..c8458c531b25 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -338,8 +338,8 @@ static void __init smp_create_idle(unsigned int cpu)
338#ifdef CONFIG_PPC64 338#ifdef CONFIG_PPC64
339 paca[cpu].__current = p; 339 paca[cpu].__current = p;
340#endif 340#endif
341 current_set[cpu] = p->thread_info; 341 current_set[cpu] = task_thread_info(p);
342 p->thread_info->cpu = cpu; 342 task_thread_info(p)->cpu = cpu;
343} 343}
344 344
345void __init smp_prepare_cpus(unsigned int max_cpus) 345void __init smp_prepare_cpus(unsigned int max_cpus)
@@ -375,7 +375,7 @@ void __devinit smp_prepare_boot_cpu(void)
375#ifdef CONFIG_PPC64 375#ifdef CONFIG_PPC64
376 paca[boot_cpuid].__current = current; 376 paca[boot_cpuid].__current = current;
377#endif 377#endif
378 current_set[boot_cpuid] = current->thread_info; 378 current_set[boot_cpuid] = task_thread_info(current);
379} 379}
380 380
381#ifdef CONFIG_HOTPLUG_CPU 381#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 9c921d1c4084..475249dc2350 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -552,30 +552,6 @@ asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec
552 return ret; 552 return ret;
553} 553}
554 554
555asmlinkage int compat_sys_pciconfig_read(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf)
556{
557 return sys_pciconfig_read((unsigned long) bus,
558 (unsigned long) dfn,
559 (unsigned long) off,
560 (unsigned long) len,
561 compat_ptr(ubuf));
562}
563
564asmlinkage int compat_sys_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubuf)
565{
566 return sys_pciconfig_write((unsigned long) bus,
567 (unsigned long) dfn,
568 (unsigned long) off,
569 (unsigned long) len,
570 compat_ptr(ubuf));
571}
572
573asmlinkage int compat_sys_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn)
574{
575 return sys_pciconfig_iobase(which, in_bus, in_devfn);
576}
577
578
579/* Note: it is necessary to treat mode as an unsigned int, 555/* Note: it is necessary to treat mode as an unsigned int,
580 * with the corresponding cast to a signed int to insure that the 556 * with the corresponding cast to a signed int to insure that the
581 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) 557 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
@@ -956,38 +932,6 @@ long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
956 advice); 932 advice);
957} 933}
958 934
959long ppc32_timer_create(clockid_t clock,
960 struct compat_sigevent __user *ev32,
961 timer_t __user *timer_id)
962{
963 sigevent_t event;
964 timer_t t;
965 long err;
966 mm_segment_t savefs;
967
968 if (ev32 == NULL)
969 return sys_timer_create(clock, NULL, timer_id);
970
971 if (get_compat_sigevent(&event, ev32))
972 return -EFAULT;
973
974 if (!access_ok(VERIFY_WRITE, timer_id, sizeof(timer_t)))
975 return -EFAULT;
976
977 savefs = get_fs();
978 set_fs(KERNEL_DS);
979 /* The __user pointer casts are valid due to the set_fs() */
980 err = sys_timer_create(clock,
981 (sigevent_t __user *) &event,
982 (timer_t __user *) &t);
983 set_fs(savefs);
984
985 if (err == 0)
986 err = __put_user(t, timer_id);
987
988 return err;
989}
990
991asmlinkage long compat_sys_add_key(const char __user *_type, 935asmlinkage long compat_sys_add_key(const char __user *_type,
992 const char __user *_description, 936 const char __user *_description,
993 const void __user *_payload, 937 const void __user *_payload,
diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
index 65463a1076e8..68013179a503 100644
--- a/arch/powerpc/kernel/systbl.S
+++ b/arch/powerpc/kernel/systbl.S
@@ -239,9 +239,9 @@ SYS32ONLY(ftruncate64)
239SYSX(sys_ni_syscall,sys_stat64,sys_stat64) 239SYSX(sys_ni_syscall,sys_stat64,sys_stat64)
240SYSX(sys_ni_syscall,sys_lstat64,sys_lstat64) 240SYSX(sys_ni_syscall,sys_lstat64,sys_lstat64)
241SYSX(sys_ni_syscall,sys_fstat64,sys_fstat64) 241SYSX(sys_ni_syscall,sys_fstat64,sys_fstat64)
242COMPAT_SYS(pciconfig_read) 242SYSCALL(pciconfig_read)
243COMPAT_SYS(pciconfig_write) 243SYSCALL(pciconfig_write)
244COMPAT_SYS(pciconfig_iobase) 244SYSCALL(pciconfig_iobase)
245SYSCALL(ni_syscall) 245SYSCALL(ni_syscall)
246SYSCALL(getdents64) 246SYSCALL(getdents64)
247SYSCALL(pivot_root) 247SYSCALL(pivot_root)
@@ -281,7 +281,7 @@ SYSCALL(epoll_create)
281SYSCALL(epoll_ctl) 281SYSCALL(epoll_ctl)
282SYSCALL(epoll_wait) 282SYSCALL(epoll_wait)
283SYSCALL(remap_file_pages) 283SYSCALL(remap_file_pages)
284SYSX(sys_timer_create,ppc32_timer_create,sys_timer_create) 284SYSX(sys_timer_create,compat_sys_timer_create,sys_timer_create)
285COMPAT_SYS(timer_settime) 285COMPAT_SYS(timer_settime)
286COMPAT_SYS(timer_gettime) 286COMPAT_SYS(timer_gettime)
287SYSCALL(timer_getoverrun) 287SYSCALL(timer_getoverrun)
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 558c1ceb2b93..3774e80094f5 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -15,11 +15,36 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/console.h> 16#include <linux/console.h>
17#include <asm/processor.h> 17#include <asm/processor.h>
18#include <asm/udbg.h>
18 19
19void (*udbg_putc)(char c); 20void (*udbg_putc)(char c);
20int (*udbg_getc)(void); 21int (*udbg_getc)(void);
21int (*udbg_getc_poll)(void); 22int (*udbg_getc_poll)(void);
22 23
24/*
25 * Early debugging facilities. You can enable _one_ of these via .config,
26 * if you do so your kernel _will not boot_ on anything else. Be careful.
27 */
28void __init udbg_early_init(void)
29{
30#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR)
31 /* For LPAR machines that have an HVC console on vterm 0 */
32 udbg_init_debug_lpar();
33#elif defined(CONFIG_PPC_EARLY_DEBUG_G5)
34 /* For use on Apple G5 machines */
35 udbg_init_pmac_realmode();
36#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS)
37 /* RTAS panel debug */
38 udbg_init_rtas();
39#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE)
40 /* Maple real mode debug */
41 udbg_init_maple_realmode();
42#elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
43 /* For iSeries - hit Ctrl-x Ctrl-x to see the output */
44 udbg_init_iseries();
45#endif
46}
47
23/* udbg library, used by xmon et al */ 48/* udbg library, used by xmon et al */
24void udbg_puts(const char *s) 49void udbg_puts(const char *s)
25{ 50{
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 7541bf44d2da..2da65a9c93f6 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -155,7 +155,7 @@ void udbg_maple_real_putc(unsigned char c)
155 } 155 }
156} 156}
157 157
158void udbg_init_maple_realmode(void) 158void __init udbg_init_maple_realmode(void)
159{ 159{
160 udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8; 160 udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8;
161 161
diff --git a/arch/powerpc/kernel/vdso32/.gitignore b/arch/powerpc/kernel/vdso32/.gitignore
new file mode 100644
index 000000000000..e45fba9d0ced
--- /dev/null
+++ b/arch/powerpc/kernel/vdso32/.gitignore
@@ -0,0 +1 @@
vdso32.lds
diff --git a/arch/powerpc/kernel/vdso64/.gitignore b/arch/powerpc/kernel/vdso64/.gitignore
new file mode 100644
index 000000000000..3fd18cf9fec2
--- /dev/null
+++ b/arch/powerpc/kernel/vdso64/.gitignore
@@ -0,0 +1 @@
vdso64.lds
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 2ffca63602c5..7b278d83739e 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -174,7 +174,7 @@ void __iomem * __ioremap(unsigned long addr, unsigned long size,
174 pa = addr & PAGE_MASK; 174 pa = addr & PAGE_MASK;
175 size = PAGE_ALIGN(addr + size) - pa; 175 size = PAGE_ALIGN(addr + size) - pa;
176 176
177 if (size == 0) 177 if ((size == 0) || (pa == 0))
178 return NULL; 178 return NULL;
179 179
180 if (mem_init_done) { 180 if (mem_init_done) {
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
new file mode 100644
index 000000000000..b20812d460e6
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -0,0 +1,26 @@
1menu "Platform support"
2 depends on PPC_83xx
3
4choice
5 prompt "Machine Type"
6 default MPC834x_SYS
7
8config MPC834x_SYS
9 bool "Freescale MPC834x SYS"
10 help
11 This option enables support for the MPC 834x SYS evaluation board.
12
13 Be aware that PCI buses can only function when SYS board is plugged
14 into the PIB (Platform IO Board) board from Freescale which provide
15 3 PCI slots. The PIBs PCI initialization is the bootloader's
16 responsiblilty.
17
18endchoice
19
20config MPC834x
21 bool
22 select PPC_UDBG_16550
23 select PPC_INDIRECT_PCI
24 default y if MPC834x_SYS
25
26endmenu
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
new file mode 100644
index 000000000000..9d8b28ef3343
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -0,0 +1,4 @@
1#
2# Makefile for the PowerPC 83xx linux kernel.
3#
4obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o pci.o
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 8836b3a00668..04073fd987ec 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -7,6 +7,7 @@ endif
7endif 7endif
8obj-$(CONFIG_PPC_CHRP) += chrp/ 8obj-$(CONFIG_PPC_CHRP) += chrp/
9obj-$(CONFIG_4xx) += 4xx/ 9obj-$(CONFIG_4xx) += 4xx/
10obj-$(CONFIG_PPC_83xx) += 83xx/
10obj-$(CONFIG_85xx) += 85xx/ 11obj-$(CONFIG_85xx) += 85xx/
11obj-$(CONFIG_PPC_PSERIES) += pseries/ 12obj-$(CONFIG_PPC_PSERIES) += pseries/
12obj-$(CONFIG_PPC_ISERIES) += iseries/ 13obj-$(CONFIG_PPC_ISERIES) += iseries/
diff --git a/arch/powerpc/platforms/cell/pervasive.c b/arch/powerpc/platforms/cell/pervasive.c
index 85152544c153..e0e051c675dd 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -142,7 +142,7 @@ static void cbe_idle(void)
142 } 142 }
143} 143}
144 144
145int cbe_system_reset_exception(struct pt_regs *regs) 145static int cbe_system_reset_exception(struct pt_regs *regs)
146{ 146{
147 switch (regs->msr & SRR1_WAKEMASK) { 147 switch (regs->msr & SRR1_WAKEMASK) {
148 case SRR1_WAKEEE: 148 case SRR1_WAKEEE:
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 18e25e65c04b..b33a4443f5a9 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -57,7 +57,7 @@
57#define DBG(fmt...) 57#define DBG(fmt...)
58#endif 58#endif
59 59
60void cell_show_cpuinfo(struct seq_file *m) 60static void cell_show_cpuinfo(struct seq_file *m)
61{ 61{
62 struct device_node *root; 62 struct device_node *root;
63 const char *model = ""; 63 const char *model = "";
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index de96eadf419d..bdf6c5fe58c0 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -86,7 +86,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
86 pcpu = get_hard_smp_processor_id(lcpu); 86 pcpu = get_hard_smp_processor_id(lcpu);
87 87
88 /* Fixup atomic count: it exited inside IRQ handler. */ 88 /* Fixup atomic count: it exited inside IRQ handler. */
89 paca[lcpu].__current->thread_info->preempt_count = 0; 89 task_thread_info(paca[lcpu].__current)->preempt_count = 0;
90 90
91 /* 91 /*
92 * If the RTAS start-cpu token does not exist then presume the 92 * If the RTAS start-cpu token does not exist then presume the
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index d2ba358c6e38..b3962c3a0348 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -138,7 +138,7 @@ static void spufs_prune_dir(struct dentry *dir)
138{ 138{
139 struct dentry *dentry, *tmp; 139 struct dentry *dentry, *tmp;
140 mutex_lock(&dir->d_inode->i_mutex); 140 mutex_lock(&dir->d_inode->i_mutex);
141 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) { 141 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
142 spin_lock(&dcache_lock); 142 spin_lock(&dcache_lock);
143 spin_lock(&dentry->d_lock); 143 spin_lock(&dentry->d_lock);
144 if (!(d_unhashed(dentry)) && dentry->d_inode) { 144 if (!(d_unhashed(dentry)) && dentry->d_inode) {
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 1061c12b2edb..212db28531fa 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -169,11 +169,33 @@ static inline void save_mfc_cntl(struct spu_state *csa, struct spu *spu)
169 struct spu_priv2 __iomem *priv2 = spu->priv2; 169 struct spu_priv2 __iomem *priv2 = spu->priv2;
170 170
171 /* Save, Step 8: 171 /* Save, Step 8:
172 * Read and save MFC_CNTL[Ss]. 172 * Suspend DMA and save MFC_CNTL.
173 */ 173 */
174 if (csa) { 174 switch (in_be64(&priv2->mfc_control_RW) &
175 csa->priv2.mfc_control_RW = in_be64(&priv2->mfc_control_RW) & 175 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) {
176 MFC_CNTL_SUSPEND_DMA_STATUS_MASK; 176 case MFC_CNTL_SUSPEND_IN_PROGRESS:
177 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
178 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
179 MFC_CNTL_SUSPEND_COMPLETE);
180 /* fall through */
181 case MFC_CNTL_SUSPEND_COMPLETE:
182 if (csa) {
183 csa->priv2.mfc_control_RW =
184 in_be64(&priv2->mfc_control_RW) |
185 MFC_CNTL_SUSPEND_DMA_QUEUE;
186 }
187 break;
188 case MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION:
189 out_be64(&priv2->mfc_control_RW, MFC_CNTL_SUSPEND_DMA_QUEUE);
190 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
191 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
192 MFC_CNTL_SUSPEND_COMPLETE);
193 if (csa) {
194 csa->priv2.mfc_control_RW =
195 in_be64(&priv2->mfc_control_RW) &
196 ~MFC_CNTL_SUSPEND_DMA_QUEUE;
197 }
198 break;
177 } 199 }
178} 200}
179 201
@@ -237,6 +259,8 @@ static inline void save_mfc_decr(struct spu_state *csa, struct spu *spu)
237 eieio(); 259 eieio();
238 csa->spu_chnldata_RW[7] = in_be64(&priv2->spu_chnldata_RW); 260 csa->spu_chnldata_RW[7] = in_be64(&priv2->spu_chnldata_RW);
239 eieio(); 261 eieio();
262 } else {
263 csa->priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING;
240 } 264 }
241} 265}
242 266
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index d549aa7ebea6..e6565a949ddc 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -29,7 +29,9 @@
29 * value of the spu_status register after the SPU has stopped. 29 * value of the spu_status register after the SPU has stopped.
30 * 30 *
31 */ 31 */
32long do_spu_run(struct file *filp, __u32 __user *unpc, __u32 __user *ustatus) 32static long do_spu_run(struct file *filp,
33 __u32 __user *unpc,
34 __u32 __user *ustatus)
33{ 35{
34 long ret; 36 long ret;
35 struct spufs_inode_info *i; 37 struct spufs_inode_info *i;
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 81250090f98d..4fdbc9ae876b 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -144,16 +144,6 @@ config LITE5200
144 much but it's only been tested on this board version. I think this 144 much but it's only been tested on this board version. I think this
145 board is also known as IceCube. 145 board is also known as IceCube.
146 146
147config MPC834x_SYS
148 bool "Freescale MPC834x SYS"
149 help
150 This option enables support for the MPC 834x SYS evaluation board.
151
152 Be aware that PCI buses can only function when SYS board is plugged
153 into the PIB (Platform IO Board) board from Freescale which provide
154 3 PCI slots. The PIBs PCI initialization is the bootloader's
155 responsiblilty.
156
157config EV64360 147config EV64360
158 bool "Marvell-EV64360BP" 148 bool "Marvell-EV64360BP"
159 help 149 help
@@ -192,14 +182,6 @@ config 8272
192 The MPC8272 CPM has a different internal dpram setup than other CPM2 182 The MPC8272 CPM has a different internal dpram setup than other CPM2
193 devices 183 devices
194 184
195config 83xx
196 bool
197 default y if MPC834x_SYS
198
199config MPC834x
200 bool
201 default y if MPC834x_SYS
202
203config CPM2 185config CPM2
204 bool 186 bool
205 depends on 8260 || MPC8560 || MPC8555 187 depends on 8260 || MPC8560 || MPC8555
diff --git a/arch/powerpc/platforms/iseries/Makefile b/arch/powerpc/platforms/iseries/Makefile
index 127b465308be..ce8c0b943fa0 100644
--- a/arch/powerpc/platforms/iseries/Makefile
+++ b/arch/powerpc/platforms/iseries/Makefile
@@ -1,8 +1,8 @@
1EXTRA_CFLAGS += -mno-minimal-toc 1EXTRA_CFLAGS += -mno-minimal-toc
2 2
3obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o mf.o lpevents.o \ 3obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o mf.o lpevents.o \
4 hvcall.o proc.o htab.o iommu.o misc.o 4 hvcall.o proc.o htab.o iommu.o misc.o irq.o
5obj-$(CONFIG_PCI) += pci.o irq.o vpdinfo.o 5obj-$(CONFIG_PCI) += pci.o vpdinfo.o
6obj-$(CONFIG_IBMVIO) += vio.o 6obj-$(CONFIG_IBMVIO) += vio.o
7obj-$(CONFIG_SMP) += smp.o 7obj-$(CONFIG_SMP) += smp.o
8obj-$(CONFIG_VIOPATH) += viopath.o 8obj-$(CONFIG_VIOPATH) += viopath.o
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index 2b54eeb2c899..bea0b703f409 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -34,6 +34,8 @@
34#include <asm/pci-bridge.h> 34#include <asm/pci-bridge.h>
35#include <asm/iseries/hv_call_xm.h> 35#include <asm/iseries/hv_call_xm.h>
36 36
37#include "iommu.h"
38
37extern struct list_head iSeries_Global_Device_List; 39extern struct list_head iSeries_Global_Device_List;
38 40
39 41
diff --git a/arch/powerpc/platforms/iseries/iommu.h b/arch/powerpc/platforms/iseries/iommu.h
new file mode 100644
index 000000000000..cb5658fbe657
--- /dev/null
+++ b/arch/powerpc/platforms/iseries/iommu.h
@@ -0,0 +1,35 @@
1#ifndef _PLATFORMS_ISERIES_IOMMU_H
2#define _PLATFORMS_ISERIES_IOMMU_H
3
4/*
5 * Copyright (C) 2005 Stephen Rothwell, IBM Corporation
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:
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
22 */
23
24struct device_node;
25struct iommu_table;
26
27/* Creates table for an individual device node */
28extern void iommu_devnode_init_iSeries(struct device_node *dn);
29
30/* Get table parameters from HV */
31extern void iommu_table_getparms_iSeries(unsigned long busno,
32 unsigned char slotno, unsigned char virtbus,
33 struct iommu_table *tbl);
34
35#endif /* _PLATFORMS_ISERIES_IOMMU_H */
diff --git a/arch/powerpc/platforms/iseries/irq.c b/arch/powerpc/platforms/iseries/irq.c
index 42e978e4897a..83442ea77476 100644
--- a/arch/powerpc/platforms/iseries/irq.c
+++ b/arch/powerpc/platforms/iseries/irq.c
@@ -48,6 +48,8 @@
48extern void iSeries_smp_message_recv(struct pt_regs *); 48extern void iSeries_smp_message_recv(struct pt_regs *);
49#endif 49#endif
50 50
51#ifdef CONFIG_PCI
52
51enum pci_event_type { 53enum pci_event_type {
52 pe_bus_created = 0, /* PHB has been created */ 54 pe_bus_created = 0, /* PHB has been created */
53 pe_bus_error = 1, /* PHB has failed */ 55 pe_bus_error = 1, /* PHB has failed */
@@ -147,20 +149,11 @@ static void int_received(struct pci_event *event, struct pt_regs *regs)
147static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs) 149static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs)
148{ 150{
149 if (event && (event->xType == HvLpEvent_Type_PciIo)) { 151 if (event && (event->xType == HvLpEvent_Type_PciIo)) {
150 switch (event->xFlags.xFunction) { 152 if (hvlpevent_is_int(event))
151 case HvLpEvent_Function_Int:
152 int_received((struct pci_event *)event, regs); 153 int_received((struct pci_event *)event, regs);
153 break; 154 else
154 case HvLpEvent_Function_Ack:
155 printk(KERN_ERR 155 printk(KERN_ERR
156 "pci_event_handler: unexpected ack received\n"); 156 "pci_event_handler: unexpected ack received\n");
157 break;
158 default:
159 printk(KERN_ERR
160 "pci_event_handler: unexpected event function %d\n",
161 (int)event->xFlags.xFunction);
162 break;
163 }
164 } else if (event) 157 } else if (event)
165 printk(KERN_ERR 158 printk(KERN_ERR
166 "pci_event_handler: Unrecognized PCI event type 0x%x\n", 159 "pci_event_handler: Unrecognized PCI event type 0x%x\n",
@@ -334,6 +327,8 @@ int __init iSeries_allocate_IRQ(HvBusNumber bus,
334 return virtirq; 327 return virtirq;
335} 328}
336 329
330#endif /* CONFIG_PCI */
331
337/* 332/*
338 * Get the next pending IRQ. 333 * Get the next pending IRQ.
339 */ 334 */
@@ -353,6 +348,7 @@ int iSeries_get_irq(struct pt_regs *regs)
353 if (hvlpevent_is_pending()) 348 if (hvlpevent_is_pending())
354 process_hvlpevents(regs); 349 process_hvlpevents(regs);
355 350
351#ifdef CONFIG_PCI
356 if (num_pending_irqs) { 352 if (num_pending_irqs) {
357 spin_lock(&pending_irqs_lock); 353 spin_lock(&pending_irqs_lock);
358 for (irq = 0; irq < NR_IRQS; irq++) { 354 for (irq = 0; irq < NR_IRQS; irq++) {
@@ -366,6 +362,7 @@ int iSeries_get_irq(struct pt_regs *regs)
366 if (irq >= NR_IRQS) 362 if (irq >= NR_IRQS)
367 irq = -2; 363 irq = -2;
368 } 364 }
365#endif
369 366
370 return irq; 367 return irq;
371} 368}
diff --git a/arch/powerpc/platforms/iseries/lpardata.c b/arch/powerpc/platforms/iseries/lpardata.c
index ea72385aaf0a..438e2dba63b5 100644
--- a/arch/powerpc/platforms/iseries/lpardata.c
+++ b/arch/powerpc/platforms/iseries/lpardata.c
@@ -93,10 +93,7 @@ struct ItLpNaca itLpNaca = {
93 .xPirEnvironMode = 0, /* Piranha stuff */ 93 .xPirEnvironMode = 0, /* Piranha stuff */
94 .xPirConsoleMode = 0, 94 .xPirConsoleMode = 0,
95 .xPirDasdMode = 0, 95 .xPirDasdMode = 0,
96 .xLparInstalled = 0, 96 .flags = 0,
97 .xSysPartitioned = 0,
98 .xHwSyncedTBs = 0,
99 .xIntProcUtilHmt = 0,
100 .xSpVpdFormat = 0, 97 .xSpVpdFormat = 0,
101 .xIntProcRatio = 0, 98 .xIntProcRatio = 0,
102 .xPlicVrmIndex = 0, /* VRM index of PLIC */ 99 .xPlicVrmIndex = 0, /* VRM index of PLIC */
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index e9fb98bf895f..0b885300d1d1 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -53,7 +53,7 @@ static struct HvLpEvent * get_next_hvlpevent(void)
53 struct HvLpEvent * event; 53 struct HvLpEvent * event;
54 event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; 54 event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
55 55
56 if (event->xFlags.xValid) { 56 if (hvlpevent_is_valid(event)) {
57 /* rmb() needed only for weakly consistent machines (regatta) */ 57 /* rmb() needed only for weakly consistent machines (regatta) */
58 rmb(); 58 rmb();
59 /* Set pointer to next potential event */ 59 /* Set pointer to next potential event */
@@ -84,7 +84,7 @@ int hvlpevent_is_pending(void)
84 84
85 next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; 85 next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr;
86 86
87 return next_event->xFlags.xValid | 87 return hvlpevent_is_valid(next_event) ||
88 hvlpevent_queue.xPlicOverflowIntPending; 88 hvlpevent_queue.xPlicOverflowIntPending;
89} 89}
90 90
@@ -101,18 +101,18 @@ static void hvlpevent_clear_valid(struct HvLpEvent * event)
101 switch (extra) { 101 switch (extra) {
102 case 3: 102 case 3:
103 tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign); 103 tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign);
104 tmp->xFlags.xValid = 0; 104 hvlpevent_invalidate(tmp);
105 case 2: 105 case 2:
106 tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign); 106 tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign);
107 tmp->xFlags.xValid = 0; 107 hvlpevent_invalidate(tmp);
108 case 1: 108 case 1:
109 tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign); 109 tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign);
110 tmp->xFlags.xValid = 0; 110 hvlpevent_invalidate(tmp);
111 } 111 }
112 112
113 mb(); 113 mb();
114 114
115 event->xFlags.xValid = 0; 115 hvlpevent_invalidate(event);
116} 116}
117 117
118void process_hvlpevents(struct pt_regs *regs) 118void process_hvlpevents(struct pt_regs *regs)
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index 49e7e4b85847..a41d8b78c0cd 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -251,10 +251,7 @@ static struct pending_event *new_pending_event(void)
251 } 251 }
252 memset(ev, 0, sizeof(struct pending_event)); 252 memset(ev, 0, sizeof(struct pending_event));
253 hev = &ev->event.hp_lp_event; 253 hev = &ev->event.hp_lp_event;
254 hev->xFlags.xValid = 1; 254 hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DO_ACK | HV_LP_EVENT_INT;
255 hev->xFlags.xAckType = HvLpEvent_AckType_ImmediateAck;
256 hev->xFlags.xAckInd = HvLpEvent_AckInd_DoAck;
257 hev->xFlags.xFunction = HvLpEvent_Function_Int;
258 hev->xType = HvLpEvent_Type_MachineFac; 255 hev->xType = HvLpEvent_Type_MachineFac;
259 hev->xSourceLp = HvLpConfig_getLpIndex(); 256 hev->xSourceLp = HvLpConfig_getLpIndex();
260 hev->xTargetLp = primary_lp; 257 hev->xTargetLp = primary_lp;
@@ -518,17 +515,10 @@ static void handle_ack(struct io_mf_lp_event *event)
518static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs) 515static void hv_handler(struct HvLpEvent *event, struct pt_regs *regs)
519{ 516{
520 if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) { 517 if ((event != NULL) && (event->xType == HvLpEvent_Type_MachineFac)) {
521 switch(event->xFlags.xFunction) { 518 if (hvlpevent_is_ack(event))
522 case HvLpEvent_Function_Ack:
523 handle_ack((struct io_mf_lp_event *)event); 519 handle_ack((struct io_mf_lp_event *)event);
524 break; 520 else
525 case HvLpEvent_Function_Int:
526 handle_int((struct io_mf_lp_event *)event); 521 handle_int((struct io_mf_lp_event *)event);
527 break;
528 default:
529 printk(KERN_ERR "mf.c: non ack/int event received\n");
530 break;
531 }
532 } else 522 } else
533 printk(KERN_ERR "mf.c: alien event received\n"); 523 printk(KERN_ERR "mf.c: alien event received\n");
534} 524}
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index dafc518fbb83..a19833b880e4 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -43,6 +43,7 @@
43#include "irq.h" 43#include "irq.h"
44#include "pci.h" 44#include "pci.h"
45#include "call_pci.h" 45#include "call_pci.h"
46#include "iommu.h"
46 47
47extern unsigned long io_page_mask; 48extern unsigned long io_page_mask;
48 49
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index ad5ef80500ce..c6bbe5c25107 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -52,6 +52,7 @@
52#include <asm/iseries/mf.h> 52#include <asm/iseries/mf.h>
53#include <asm/iseries/hv_lp_event.h> 53#include <asm/iseries/hv_lp_event.h>
54#include <asm/iseries/lpar_map.h> 54#include <asm/iseries/lpar_map.h>
55#include <asm/udbg.h>
55 56
56#include "naca.h" 57#include "naca.h"
57#include "setup.h" 58#include "setup.h"
@@ -62,10 +63,8 @@
62#include "call_sm.h" 63#include "call_sm.h"
63#include "call_hpt.h" 64#include "call_hpt.h"
64 65
65extern void hvlog(char *fmt, ...);
66
67#ifdef DEBUG 66#ifdef DEBUG
68#define DBG(fmt...) hvlog(fmt) 67#define DBG(fmt...) udbg_printf(fmt)
69#else 68#else
70#define DBG(fmt...) 69#define DBG(fmt...)
71#endif 70#endif
@@ -474,14 +473,6 @@ static unsigned long __init build_iSeries_Memory_Map(void)
474 printk("HPT absolute addr = %016lx, size = %dK\n", 473 printk("HPT absolute addr = %016lx, size = %dK\n",
475 chunk_to_addr(hptFirstChunk), hptSizeChunks * 256); 474 chunk_to_addr(hptFirstChunk), hptSizeChunks * 256);
476 475
477 ppc64_pft_size = __ilog2(hptSizePages * HW_PAGE_SIZE);
478
479 /*
480 * The actual hashed page table is in the hypervisor,
481 * we have no direct access
482 */
483 htab_address = NULL;
484
485 /* 476 /*
486 * Determine if absolute memory has any 477 * Determine if absolute memory has any
487 * holes so that we can interpret the 478 * holes so that we can interpret the
@@ -861,6 +852,11 @@ void dt_prop_u64_list(struct iseries_flat_dt *dt, char *name, u64 *data, int n)
861 dt_prop(dt, name, (char *)data, sizeof(u64) * n); 852 dt_prop(dt, name, (char *)data, sizeof(u64) * n);
862} 853}
863 854
855void dt_prop_u32_list(struct iseries_flat_dt *dt, char *name, u32 *data, int n)
856{
857 dt_prop(dt, name, (char *)data, sizeof(u32) * n);
858}
859
864void dt_prop_empty(struct iseries_flat_dt *dt, char *name) 860void dt_prop_empty(struct iseries_flat_dt *dt, char *name)
865{ 861{
866 dt_prop(dt, name, NULL, 0); 862 dt_prop(dt, name, NULL, 0);
@@ -872,6 +868,7 @@ void dt_cpus(struct iseries_flat_dt *dt)
872 unsigned char *p; 868 unsigned char *p;
873 unsigned int i, index; 869 unsigned int i, index;
874 struct IoHriProcessorVpd *d; 870 struct IoHriProcessorVpd *d;
871 u32 pft_size[2];
875 872
876 /* yuck */ 873 /* yuck */
877 snprintf(buf, 32, "PowerPC,%s", cur_cpu_spec->cpu_name); 874 snprintf(buf, 32, "PowerPC,%s", cur_cpu_spec->cpu_name);
@@ -882,6 +879,9 @@ void dt_cpus(struct iseries_flat_dt *dt)
882 dt_prop_u32(dt, "#address-cells", 1); 879 dt_prop_u32(dt, "#address-cells", 1);
883 dt_prop_u32(dt, "#size-cells", 0); 880 dt_prop_u32(dt, "#size-cells", 0);
884 881
882 pft_size[0] = 0; /* NUMA CEC cookie, 0 for non NUMA */
883 pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
884
885 for (i = 0; i < NR_CPUS; i++) { 885 for (i = 0; i < NR_CPUS; i++) {
886 if (paca[i].lppaca.dyn_proc_status >= 2) 886 if (paca[i].lppaca.dyn_proc_status >= 2)
887 continue; 887 continue;
@@ -908,6 +908,8 @@ void dt_cpus(struct iseries_flat_dt *dt)
908 908
909 dt_prop_u32(dt, "reg", i); 909 dt_prop_u32(dt, "reg", i);
910 910
911 dt_prop_u32_list(dt, "ibm,pft-size", pft_size, 2);
912
911 dt_end_node(dt); 913 dt_end_node(dt);
912 } 914 }
913 915
@@ -984,3 +986,16 @@ static int __init early_parsemem(char *p)
984 return 0; 986 return 0;
985} 987}
986early_param("mem", early_parsemem); 988early_param("mem", early_parsemem);
989
990static void hvputc(char c)
991{
992 if (c == '\n')
993 hvputc('\r');
994
995 HvCall_writeLogBuffer(&c, 1);
996}
997
998void __init udbg_init_iseries(void)
999{
1000 udbg_putc = hvputc;
1001}
diff --git a/arch/powerpc/platforms/iseries/vio.c b/arch/powerpc/platforms/iseries/vio.c
index 384360ee06ec..ad36ab0639f0 100644
--- a/arch/powerpc/platforms/iseries/vio.c
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -22,6 +22,8 @@
22#include <asm/iseries/hv_lp_config.h> 22#include <asm/iseries/hv_lp_config.h>
23#include <asm/iseries/hv_call_xm.h> 23#include <asm/iseries/hv_call_xm.h>
24 24
25#include "iommu.h"
26
25struct device *iSeries_vio_dev = &vio_bus_device.dev; 27struct device *iSeries_vio_dev = &vio_bus_device.dev;
26EXPORT_SYMBOL(iSeries_vio_dev); 28EXPORT_SYMBOL(iSeries_vio_dev);
27 29
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index 842672695598..622a30149b48 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -270,7 +270,7 @@ static void handleMonitorEvent(struct HvLpEvent *event)
270 * First see if this is just a normal monitor message from the 270 * First see if this is just a normal monitor message from the
271 * other partition 271 * other partition
272 */ 272 */
273 if (event->xFlags.xFunction == HvLpEvent_Function_Int) { 273 if (hvlpevent_is_int(event)) {
274 remoteLp = event->xSourceLp; 274 remoteLp = event->xSourceLp;
275 if (!viopathStatus[remoteLp].isActive) 275 if (!viopathStatus[remoteLp].isActive)
276 sendMonMsg(remoteLp); 276 sendMonMsg(remoteLp);
@@ -331,13 +331,12 @@ static void handleConfig(struct HvLpEvent *event)
331{ 331{
332 if (!event) 332 if (!event)
333 return; 333 return;
334 if (event->xFlags.xFunction == HvLpEvent_Function_Int) { 334 if (hvlpevent_is_int(event)) {
335 printk(VIOPATH_KERN_WARN 335 printk(VIOPATH_KERN_WARN
336 "unexpected config request from partition %d", 336 "unexpected config request from partition %d",
337 event->xSourceLp); 337 event->xSourceLp);
338 338
339 if ((event->xFlags.xFunction == HvLpEvent_Function_Int) && 339 if (hvlpevent_need_ack(event)) {
340 (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
341 event->xRc = HvLpEvent_Rc_InvalidSubtype; 340 event->xRc = HvLpEvent_Rc_InvalidSubtype;
342 HvCallEvent_ackLpEvent(event); 341 HvCallEvent_ackLpEvent(event);
343 } 342 }
@@ -377,7 +376,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
377 int subtype = (event->xSubtype & VIOMAJOR_SUBTYPE_MASK) 376 int subtype = (event->xSubtype & VIOMAJOR_SUBTYPE_MASK)
378 >> VIOMAJOR_SUBTYPE_SHIFT; 377 >> VIOMAJOR_SUBTYPE_SHIFT;
379 378
380 if (event->xFlags.xFunction == HvLpEvent_Function_Int) { 379 if (hvlpevent_is_int(event)) {
381 remoteLp = event->xSourceLp; 380 remoteLp = event->xSourceLp;
382 /* 381 /*
383 * The isActive is checked because if the hosting partition 382 * The isActive is checked because if the hosting partition
@@ -436,8 +435,7 @@ static void vio_handleEvent(struct HvLpEvent *event, struct pt_regs *regs)
436 "unexpected virtual io event subtype %d from partition %d\n", 435 "unexpected virtual io event subtype %d from partition %d\n",
437 event->xSubtype, remoteLp); 436 event->xSubtype, remoteLp);
438 /* No handler. Ack if necessary */ 437 /* No handler. Ack if necessary */
439 if ((event->xFlags.xFunction == HvLpEvent_Function_Int) && 438 if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
440 (event->xFlags.xAckInd == HvLpEvent_AckInd_DoAck)) {
441 event->xRc = HvLpEvent_Rc_InvalidSubtype; 439 event->xRc = HvLpEvent_Rc_InvalidSubtype;
442 HvCallEvent_ackLpEvent(event); 440 HvCallEvent_ackLpEvent(event);
443 } 441 }
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index dd73e38bfb7d..a1cb4d236720 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -71,9 +71,6 @@
71#define DBG(fmt...) 71#define DBG(fmt...)
72#endif 72#endif
73 73
74extern void generic_find_legacy_serial_ports(u64 *physport,
75 unsigned int *default_speed);
76
77static void maple_restart(char *cmd) 74static void maple_restart(char *cmd)
78{ 75{
79 unsigned int maple_nvram_base; 76 unsigned int maple_nvram_base;
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 3b1a9d4fcbc6..89c4c3636161 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -278,7 +278,7 @@ static void __init l2cr_init(void)
278} 278}
279#endif 279#endif
280 280
281void __init pmac_setup_arch(void) 281static void __init pmac_setup_arch(void)
282{ 282{
283 struct device_node *cpu, *ic; 283 struct device_node *cpu, *ic;
284 int *fp; 284 int *fp;
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index e87d53acfb61..c4352a8db644 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -153,7 +153,7 @@ static void udbg_real_scc_putc(char c)
153 udbg_real_scc_putc('\r'); 153 udbg_real_scc_putc('\r');
154} 154}
155 155
156void udbg_init_pmac_realmode(void) 156void __init udbg_init_pmac_realmode(void)
157{ 157{
158 sccc = (volatile u8 __iomem *)0x80013020ul; 158 sccc = (volatile u8 __iomem *)0x80013020ul;
159 sccd = (volatile u8 __iomem *)0x80013030ul; 159 sccd = (volatile u8 __iomem *)0x80013030ul;
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 6accdd155505..61616d144072 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -4,7 +4,7 @@ obj-$(CONFIG_SMP) += smp.o
4obj-$(CONFIG_IBMVIO) += vio.o 4obj-$(CONFIG_IBMVIO) += vio.o
5obj-$(CONFIG_XICS) += xics.o 5obj-$(CONFIG_XICS) += xics.o
6obj-$(CONFIG_SCANLOG) += scanlog.o 6obj-$(CONFIG_SCANLOG) += scanlog.o
7obj-$(CONFIG_EEH) += eeh.o eeh_event.o 7obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o
8 8
9obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o 9obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
10obj-$(CONFIG_HVCS) += hvcserver.o 10obj-$(CONFIG_HVCS) += hvcserver.o
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 7fbfd16d72b7..83578313ee7e 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -76,15 +76,14 @@
76 */ 76 */
77#define EEH_MAX_FAILS 100000 77#define EEH_MAX_FAILS 100000
78 78
79/* Misc forward declaraions */
80static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn);
81
82/* RTAS tokens */ 79/* RTAS tokens */
83static int ibm_set_eeh_option; 80static int ibm_set_eeh_option;
84static int ibm_set_slot_reset; 81static int ibm_set_slot_reset;
85static int ibm_read_slot_reset_state; 82static int ibm_read_slot_reset_state;
86static int ibm_read_slot_reset_state2; 83static int ibm_read_slot_reset_state2;
87static int ibm_slot_error_detail; 84static int ibm_slot_error_detail;
85static int ibm_get_config_addr_info;
86static int ibm_configure_bridge;
88 87
89int eeh_subsystem_enabled; 88int eeh_subsystem_enabled;
90EXPORT_SYMBOL(eeh_subsystem_enabled); 89EXPORT_SYMBOL(eeh_subsystem_enabled);
@@ -98,308 +97,23 @@ static DEFINE_SPINLOCK(slot_errbuf_lock);
98static int eeh_error_buf_size; 97static int eeh_error_buf_size;
99 98
100/* System monitoring statistics */ 99/* System monitoring statistics */
101static DEFINE_PER_CPU(unsigned long, no_device); 100static unsigned long no_device;
102static DEFINE_PER_CPU(unsigned long, no_dn); 101static unsigned long no_dn;
103static DEFINE_PER_CPU(unsigned long, no_cfg_addr); 102static unsigned long no_cfg_addr;
104static DEFINE_PER_CPU(unsigned long, ignored_check); 103static unsigned long ignored_check;
105static DEFINE_PER_CPU(unsigned long, total_mmio_ffs); 104static unsigned long total_mmio_ffs;
106static DEFINE_PER_CPU(unsigned long, false_positives); 105static unsigned long false_positives;
107static DEFINE_PER_CPU(unsigned long, ignored_failures); 106static unsigned long ignored_failures;
108static DEFINE_PER_CPU(unsigned long, slot_resets); 107static unsigned long slot_resets;
109
110/**
111 * The pci address cache subsystem. This subsystem places
112 * PCI device address resources into a red-black tree, sorted
113 * according to the address range, so that given only an i/o
114 * address, the corresponding PCI device can be **quickly**
115 * found. It is safe to perform an address lookup in an interrupt
116 * context; this ability is an important feature.
117 *
118 * Currently, the only customer of this code is the EEH subsystem;
119 * thus, this code has been somewhat tailored to suit EEH better.
120 * In particular, the cache does *not* hold the addresses of devices
121 * for which EEH is not enabled.
122 *
123 * (Implementation Note: The RB tree seems to be better/faster
124 * than any hash algo I could think of for this problem, even
125 * with the penalty of slow pointer chases for d-cache misses).
126 */
127struct pci_io_addr_range
128{
129 struct rb_node rb_node;
130 unsigned long addr_lo;
131 unsigned long addr_hi;
132 struct pci_dev *pcidev;
133 unsigned int flags;
134};
135
136static struct pci_io_addr_cache
137{
138 struct rb_root rb_root;
139 spinlock_t piar_lock;
140} pci_io_addr_cache_root;
141
142static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr)
143{
144 struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node;
145
146 while (n) {
147 struct pci_io_addr_range *piar;
148 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
149
150 if (addr < piar->addr_lo) {
151 n = n->rb_left;
152 } else {
153 if (addr > piar->addr_hi) {
154 n = n->rb_right;
155 } else {
156 pci_dev_get(piar->pcidev);
157 return piar->pcidev;
158 }
159 }
160 }
161
162 return NULL;
163}
164
165/**
166 * pci_get_device_by_addr - Get device, given only address
167 * @addr: mmio (PIO) phys address or i/o port number
168 *
169 * Given an mmio phys address, or a port number, find a pci device
170 * that implements this address. Be sure to pci_dev_put the device
171 * when finished. I/O port numbers are assumed to be offset
172 * from zero (that is, they do *not* have pci_io_addr added in).
173 * It is safe to call this function within an interrupt.
174 */
175static struct pci_dev *pci_get_device_by_addr(unsigned long addr)
176{
177 struct pci_dev *dev;
178 unsigned long flags;
179
180 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
181 dev = __pci_get_device_by_addr(addr);
182 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
183 return dev;
184}
185
186#ifdef DEBUG
187/*
188 * Handy-dandy debug print routine, does nothing more
189 * than print out the contents of our addr cache.
190 */
191static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
192{
193 struct rb_node *n;
194 int cnt = 0;
195
196 n = rb_first(&cache->rb_root);
197 while (n) {
198 struct pci_io_addr_range *piar;
199 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
200 printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n",
201 (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
202 piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev));
203 cnt++;
204 n = rb_next(n);
205 }
206}
207#endif
208
209/* Insert address range into the rb tree. */
210static struct pci_io_addr_range *
211pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
212 unsigned long ahi, unsigned int flags)
213{
214 struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node;
215 struct rb_node *parent = NULL;
216 struct pci_io_addr_range *piar;
217
218 /* Walk tree, find a place to insert into tree */
219 while (*p) {
220 parent = *p;
221 piar = rb_entry(parent, struct pci_io_addr_range, rb_node);
222 if (ahi < piar->addr_lo) {
223 p = &parent->rb_left;
224 } else if (alo > piar->addr_hi) {
225 p = &parent->rb_right;
226 } else {
227 if (dev != piar->pcidev ||
228 alo != piar->addr_lo || ahi != piar->addr_hi) {
229 printk(KERN_WARNING "PIAR: overlapping address range\n");
230 }
231 return piar;
232 }
233 }
234 piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC);
235 if (!piar)
236 return NULL;
237
238 piar->addr_lo = alo;
239 piar->addr_hi = ahi;
240 piar->pcidev = dev;
241 piar->flags = flags;
242
243#ifdef DEBUG
244 printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n",
245 alo, ahi, pci_name (dev));
246#endif
247
248 rb_link_node(&piar->rb_node, parent, p);
249 rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root);
250
251 return piar;
252}
253
254static void __pci_addr_cache_insert_device(struct pci_dev *dev)
255{
256 struct device_node *dn;
257 struct pci_dn *pdn;
258 int i;
259 int inserted = 0;
260
261 dn = pci_device_to_OF_node(dev);
262 if (!dn) {
263 printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev));
264 return;
265 }
266
267 /* Skip any devices for which EEH is not enabled. */
268 pdn = PCI_DN(dn);
269 if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
270 pdn->eeh_mode & EEH_MODE_NOCHECK) {
271#ifdef DEBUG
272 printk(KERN_INFO "PCI: skip building address cache for=%s - %s\n",
273 pci_name(dev), pdn->node->full_name);
274#endif
275 return;
276 }
277
278 /* The cache holds a reference to the device... */
279 pci_dev_get(dev);
280
281 /* Walk resources on this device, poke them into the tree */
282 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
283 unsigned long start = pci_resource_start(dev,i);
284 unsigned long end = pci_resource_end(dev,i);
285 unsigned int flags = pci_resource_flags(dev,i);
286
287 /* We are interested only bus addresses, not dma or other stuff */
288 if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM)))
289 continue;
290 if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
291 continue;
292 pci_addr_cache_insert(dev, start, end, flags);
293 inserted = 1;
294 }
295
296 /* If there was nothing to add, the cache has no reference... */
297 if (!inserted)
298 pci_dev_put(dev);
299}
300
301/**
302 * pci_addr_cache_insert_device - Add a device to the address cache
303 * @dev: PCI device whose I/O addresses we are interested in.
304 *
305 * In order to support the fast lookup of devices based on addresses,
306 * we maintain a cache of devices that can be quickly searched.
307 * This routine adds a device to that cache.
308 */
309static void pci_addr_cache_insert_device(struct pci_dev *dev)
310{
311 unsigned long flags;
312
313 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
314 __pci_addr_cache_insert_device(dev);
315 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
316}
317
318static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
319{
320 struct rb_node *n;
321 int removed = 0;
322
323restart:
324 n = rb_first(&pci_io_addr_cache_root.rb_root);
325 while (n) {
326 struct pci_io_addr_range *piar;
327 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
328
329 if (piar->pcidev == dev) {
330 rb_erase(n, &pci_io_addr_cache_root.rb_root);
331 removed = 1;
332 kfree(piar);
333 goto restart;
334 }
335 n = rb_next(n);
336 }
337
338 /* The cache no longer holds its reference to this device... */
339 if (removed)
340 pci_dev_put(dev);
341}
342
343/**
344 * pci_addr_cache_remove_device - remove pci device from addr cache
345 * @dev: device to remove
346 *
347 * Remove a device from the addr-cache tree.
348 * This is potentially expensive, since it will walk
349 * the tree multiple times (once per resource).
350 * But so what; device removal doesn't need to be that fast.
351 */
352static void pci_addr_cache_remove_device(struct pci_dev *dev)
353{
354 unsigned long flags;
355
356 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
357 __pci_addr_cache_remove_device(dev);
358 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
359}
360
361/**
362 * pci_addr_cache_build - Build a cache of I/O addresses
363 *
364 * Build a cache of pci i/o addresses. This cache will be used to
365 * find the pci device that corresponds to a given address.
366 * This routine scans all pci busses to build the cache.
367 * Must be run late in boot process, after the pci controllers
368 * have been scaned for devices (after all device resources are known).
369 */
370void __init pci_addr_cache_build(void)
371{
372 struct device_node *dn;
373 struct pci_dev *dev = NULL;
374
375 if (!eeh_subsystem_enabled)
376 return;
377
378 spin_lock_init(&pci_io_addr_cache_root.piar_lock);
379
380 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
381 /* Ignore PCI bridges ( XXX why ??) */
382 if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) {
383 continue;
384 }
385 pci_addr_cache_insert_device(dev);
386
387 /* Save the BAR's; firmware doesn't restore these after EEH reset */
388 dn = pci_device_to_OF_node(dev);
389 eeh_save_bars(dev, PCI_DN(dn));
390 }
391 108
392#ifdef DEBUG 109#define IS_BRIDGE(class_code) (((class_code)<<16) == PCI_BASE_CLASS_BRIDGE)
393 /* Verify tree built up above, echo back the list of addrs. */
394 pci_addr_cache_print(&pci_io_addr_cache_root);
395#endif
396}
397 110
398/* --------------------------------------------------------------- */ 111/* --------------------------------------------------------------- */
399/* Above lies the PCI Address Cache. Below lies the EEH event infrastructure */ 112/* Below lies the EEH event infrastructure */
400 113
401void eeh_slot_error_detail (struct pci_dn *pdn, int severity) 114void eeh_slot_error_detail (struct pci_dn *pdn, int severity)
402{ 115{
116 int config_addr;
403 unsigned long flags; 117 unsigned long flags;
404 int rc; 118 int rc;
405 119
@@ -407,8 +121,13 @@ void eeh_slot_error_detail (struct pci_dn *pdn, int severity)
407 spin_lock_irqsave(&slot_errbuf_lock, flags); 121 spin_lock_irqsave(&slot_errbuf_lock, flags);
408 memset(slot_errbuf, 0, eeh_error_buf_size); 122 memset(slot_errbuf, 0, eeh_error_buf_size);
409 123
124 /* Use PE configuration address, if present */
125 config_addr = pdn->eeh_config_addr;
126 if (pdn->eeh_pe_config_addr)
127 config_addr = pdn->eeh_pe_config_addr;
128
410 rc = rtas_call(ibm_slot_error_detail, 129 rc = rtas_call(ibm_slot_error_detail,
411 8, 1, NULL, pdn->eeh_config_addr, 130 8, 1, NULL, config_addr,
412 BUID_HI(pdn->phb->buid), 131 BUID_HI(pdn->phb->buid),
413 BUID_LO(pdn->phb->buid), NULL, 0, 132 BUID_LO(pdn->phb->buid), NULL, 0,
414 virt_to_phys(slot_errbuf), 133 virt_to_phys(slot_errbuf),
@@ -428,6 +147,7 @@ void eeh_slot_error_detail (struct pci_dn *pdn, int severity)
428static int read_slot_reset_state(struct pci_dn *pdn, int rets[]) 147static int read_slot_reset_state(struct pci_dn *pdn, int rets[])
429{ 148{
430 int token, outputs; 149 int token, outputs;
150 int config_addr;
431 151
432 if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { 152 if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) {
433 token = ibm_read_slot_reset_state2; 153 token = ibm_read_slot_reset_state2;
@@ -438,7 +158,12 @@ static int read_slot_reset_state(struct pci_dn *pdn, int rets[])
438 outputs = 3; 158 outputs = 3;
439 } 159 }
440 160
441 return rtas_call(token, 3, outputs, rets, pdn->eeh_config_addr, 161 /* Use PE configuration address, if present */
162 config_addr = pdn->eeh_config_addr;
163 if (pdn->eeh_pe_config_addr)
164 config_addr = pdn->eeh_pe_config_addr;
165
166 return rtas_call(token, 3, outputs, rets, config_addr,
442 BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid)); 167 BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid));
443} 168}
444 169
@@ -462,7 +187,7 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
462/** 187/**
463 * Return the "partitionable endpoint" (pe) under which this device lies 188 * Return the "partitionable endpoint" (pe) under which this device lies
464 */ 189 */
465static struct device_node * find_device_pe(struct device_node *dn) 190struct device_node * find_device_pe(struct device_node *dn)
466{ 191{
467 while ((dn->parent) && PCI_DN(dn->parent) && 192 while ((dn->parent) && PCI_DN(dn->parent) &&
468 (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) { 193 (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) {
@@ -483,8 +208,14 @@ static void __eeh_mark_slot (struct device_node *dn, int mode_flag)
483{ 208{
484 while (dn) { 209 while (dn) {
485 if (PCI_DN(dn)) { 210 if (PCI_DN(dn)) {
211 /* Mark the pci device driver too */
212 struct pci_dev *dev = PCI_DN(dn)->pcidev;
213
486 PCI_DN(dn)->eeh_mode |= mode_flag; 214 PCI_DN(dn)->eeh_mode |= mode_flag;
487 215
216 if (dev && dev->driver)
217 dev->error_state = pci_channel_io_frozen;
218
488 if (dn->child) 219 if (dn->child)
489 __eeh_mark_slot (dn->child, mode_flag); 220 __eeh_mark_slot (dn->child, mode_flag);
490 } 221 }
@@ -495,6 +226,11 @@ static void __eeh_mark_slot (struct device_node *dn, int mode_flag)
495void eeh_mark_slot (struct device_node *dn, int mode_flag) 226void eeh_mark_slot (struct device_node *dn, int mode_flag)
496{ 227{
497 dn = find_device_pe (dn); 228 dn = find_device_pe (dn);
229
230 /* Back up one, since config addrs might be shared */
231 if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr)
232 dn = dn->parent;
233
498 PCI_DN(dn)->eeh_mode |= mode_flag; 234 PCI_DN(dn)->eeh_mode |= mode_flag;
499 __eeh_mark_slot (dn->child, mode_flag); 235 __eeh_mark_slot (dn->child, mode_flag);
500} 236}
@@ -516,7 +252,13 @@ void eeh_clear_slot (struct device_node *dn, int mode_flag)
516{ 252{
517 unsigned long flags; 253 unsigned long flags;
518 spin_lock_irqsave(&confirm_error_lock, flags); 254 spin_lock_irqsave(&confirm_error_lock, flags);
255
519 dn = find_device_pe (dn); 256 dn = find_device_pe (dn);
257
258 /* Back up one, since config addrs might be shared */
259 if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr)
260 dn = dn->parent;
261
520 PCI_DN(dn)->eeh_mode &= ~mode_flag; 262 PCI_DN(dn)->eeh_mode &= ~mode_flag;
521 PCI_DN(dn)->eeh_check_count = 0; 263 PCI_DN(dn)->eeh_check_count = 0;
522 __eeh_clear_slot (dn->child, mode_flag); 264 __eeh_clear_slot (dn->child, mode_flag);
@@ -544,15 +286,16 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
544 int rets[3]; 286 int rets[3];
545 unsigned long flags; 287 unsigned long flags;
546 struct pci_dn *pdn; 288 struct pci_dn *pdn;
289 enum pci_channel_state state;
547 int rc = 0; 290 int rc = 0;
548 291
549 __get_cpu_var(total_mmio_ffs)++; 292 total_mmio_ffs++;
550 293
551 if (!eeh_subsystem_enabled) 294 if (!eeh_subsystem_enabled)
552 return 0; 295 return 0;
553 296
554 if (!dn) { 297 if (!dn) {
555 __get_cpu_var(no_dn)++; 298 no_dn++;
556 return 0; 299 return 0;
557 } 300 }
558 pdn = PCI_DN(dn); 301 pdn = PCI_DN(dn);
@@ -560,7 +303,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
560 /* Access to IO BARs might get this far and still not want checking. */ 303 /* Access to IO BARs might get this far and still not want checking. */
561 if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || 304 if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
562 pdn->eeh_mode & EEH_MODE_NOCHECK) { 305 pdn->eeh_mode & EEH_MODE_NOCHECK) {
563 __get_cpu_var(ignored_check)++; 306 ignored_check++;
564#ifdef DEBUG 307#ifdef DEBUG
565 printk ("EEH:ignored check (%x) for %s %s\n", 308 printk ("EEH:ignored check (%x) for %s %s\n",
566 pdn->eeh_mode, pci_name (dev), dn->full_name); 309 pdn->eeh_mode, pci_name (dev), dn->full_name);
@@ -568,8 +311,8 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
568 return 0; 311 return 0;
569 } 312 }
570 313
571 if (!pdn->eeh_config_addr) { 314 if (!pdn->eeh_config_addr && !pdn->eeh_pe_config_addr) {
572 __get_cpu_var(no_cfg_addr)++; 315 no_cfg_addr++;
573 return 0; 316 return 0;
574 } 317 }
575 318
@@ -611,7 +354,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
611 if (ret != 0) { 354 if (ret != 0) {
612 printk(KERN_WARNING "EEH: read_slot_reset_state() failed; rc=%d dn=%s\n", 355 printk(KERN_WARNING "EEH: read_slot_reset_state() failed; rc=%d dn=%s\n",
613 ret, dn->full_name); 356 ret, dn->full_name);
614 __get_cpu_var(false_positives)++; 357 false_positives++;
615 rc = 0; 358 rc = 0;
616 goto dn_unlock; 359 goto dn_unlock;
617 } 360 }
@@ -620,14 +363,14 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
620 if (rets[1] != 1) { 363 if (rets[1] != 1) {
621 printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n", 364 printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n",
622 ret, dn->full_name); 365 ret, dn->full_name);
623 __get_cpu_var(false_positives)++; 366 false_positives++;
624 rc = 0; 367 rc = 0;
625 goto dn_unlock; 368 goto dn_unlock;
626 } 369 }
627 370
628 /* If not the kind of error we know about, punt. */ 371 /* If not the kind of error we know about, punt. */
629 if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) { 372 if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) {
630 __get_cpu_var(false_positives)++; 373 false_positives++;
631 rc = 0; 374 rc = 0;
632 goto dn_unlock; 375 goto dn_unlock;
633 } 376 }
@@ -635,12 +378,12 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
635 /* Note that config-io to empty slots may fail; 378 /* Note that config-io to empty slots may fail;
636 * we recognize empty because they don't have children. */ 379 * we recognize empty because they don't have children. */
637 if ((rets[0] == 5) && (dn->child == NULL)) { 380 if ((rets[0] == 5) && (dn->child == NULL)) {
638 __get_cpu_var(false_positives)++; 381 false_positives++;
639 rc = 0; 382 rc = 0;
640 goto dn_unlock; 383 goto dn_unlock;
641 } 384 }
642 385
643 __get_cpu_var(slot_resets)++; 386 slot_resets++;
644 387
645 /* Avoid repeated reports of this failure, including problems 388 /* Avoid repeated reports of this failure, including problems
646 * with other functions on this device, and functions under 389 * with other functions on this device, and functions under
@@ -648,8 +391,13 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
648 eeh_mark_slot (dn, EEH_MODE_ISOLATED); 391 eeh_mark_slot (dn, EEH_MODE_ISOLATED);
649 spin_unlock_irqrestore(&confirm_error_lock, flags); 392 spin_unlock_irqrestore(&confirm_error_lock, flags);
650 393
651 eeh_send_failure_event (dn, dev, rets[0], rets[2]); 394 state = pci_channel_io_normal;
652 395 if ((rets[0] == 2) || (rets[0] == 4))
396 state = pci_channel_io_frozen;
397 if (rets[0] == 5)
398 state = pci_channel_io_perm_failure;
399 eeh_send_failure_event (dn, dev, state, rets[2]);
400
653 /* Most EEH events are due to device driver bugs. Having 401 /* Most EEH events are due to device driver bugs. Having
654 * a stack trace will help the device-driver authors figure 402 * a stack trace will help the device-driver authors figure
655 * out what happened. So print that out. */ 403 * out what happened. So print that out. */
@@ -685,7 +433,7 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
685 addr = eeh_token_to_phys((unsigned long __force) token); 433 addr = eeh_token_to_phys((unsigned long __force) token);
686 dev = pci_get_device_by_addr(addr); 434 dev = pci_get_device_by_addr(addr);
687 if (!dev) { 435 if (!dev) {
688 __get_cpu_var(no_device)++; 436 no_device++;
689 return val; 437 return val;
690 } 438 }
691 439
@@ -716,11 +464,16 @@ eeh_slot_availability(struct pci_dn *pdn)
716 if (rc) return rc; 464 if (rc) return rc;
717 465
718 if (rets[1] == 0) return -1; /* EEH is not supported */ 466 if (rets[1] == 0) return -1; /* EEH is not supported */
719 if (rets[0] == 0) return 0; /* Oll Korrect */ 467 if (rets[0] == 0) return 0; /* Oll Korrect */
720 if (rets[0] == 5) { 468 if (rets[0] == 5) {
721 if (rets[2] == 0) return -1; /* permanently unavailable */ 469 if (rets[2] == 0) return -1; /* permanently unavailable */
722 return rets[2]; /* number of millisecs to wait */ 470 return rets[2]; /* number of millisecs to wait */
723 } 471 }
472 if (rets[0] == 1)
473 return 250;
474
475 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n",
476 rc, rets[0], rets[1], rets[2]);
724 return -1; 477 return -1;
725} 478}
726 479
@@ -737,6 +490,7 @@ eeh_slot_availability(struct pci_dn *pdn)
737static void 490static void
738rtas_pci_slot_reset(struct pci_dn *pdn, int state) 491rtas_pci_slot_reset(struct pci_dn *pdn, int state)
739{ 492{
493 int config_addr;
740 int rc; 494 int rc;
741 495
742 BUG_ON (pdn==NULL); 496 BUG_ON (pdn==NULL);
@@ -747,8 +501,13 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state)
747 return; 501 return;
748 } 502 }
749 503
504 /* Use PE configuration address, if present */
505 config_addr = pdn->eeh_config_addr;
506 if (pdn->eeh_pe_config_addr)
507 config_addr = pdn->eeh_pe_config_addr;
508
750 rc = rtas_call(ibm_set_slot_reset,4,1, NULL, 509 rc = rtas_call(ibm_set_slot_reset,4,1, NULL,
751 pdn->eeh_config_addr, 510 config_addr,
752 BUID_HI(pdn->phb->buid), 511 BUID_HI(pdn->phb->buid),
753 BUID_LO(pdn->phb->buid), 512 BUID_LO(pdn->phb->buid),
754 state); 513 state);
@@ -761,9 +520,11 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state)
761 520
762/** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second 521/** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
763 * dn -- device node to be reset. 522 * dn -- device node to be reset.
523 *
524 * Return 0 if success, else a non-zero value.
764 */ 525 */
765 526
766void 527int
767rtas_set_slot_reset(struct pci_dn *pdn) 528rtas_set_slot_reset(struct pci_dn *pdn)
768{ 529{
769 int i, rc; 530 int i, rc;
@@ -793,10 +554,21 @@ rtas_set_slot_reset(struct pci_dn *pdn)
793 * ready to be used; if not, wait for recovery. */ 554 * ready to be used; if not, wait for recovery. */
794 for (i=0; i<10; i++) { 555 for (i=0; i<10; i++) {
795 rc = eeh_slot_availability (pdn); 556 rc = eeh_slot_availability (pdn);
796 if (rc <= 0) break; 557 if (rc < 0)
558 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n", rc, pdn->node->full_name);
559 if (rc == 0)
560 return 0;
561 if (rc < 0)
562 return -1;
797 563
798 msleep (rc+100); 564 msleep (rc+100);
799 } 565 }
566
567 rc = eeh_slot_availability (pdn);
568 if (rc)
569 printk (KERN_ERR "EEH: timeout resetting slot %s\n", pdn->node->full_name);
570
571 return rc;
800} 572}
801 573
802/* ------------------------------------------------------- */ 574/* ------------------------------------------------------- */
@@ -851,7 +623,7 @@ void eeh_restore_bars(struct pci_dn *pdn)
851 if (!pdn) 623 if (!pdn)
852 return; 624 return;
853 625
854 if (! pdn->eeh_is_bridge) 626 if ((pdn->eeh_mode & EEH_MODE_SUPPORTED) && !IS_BRIDGE(pdn->class_code))
855 __restore_bars (pdn); 627 __restore_bars (pdn);
856 628
857 dn = pdn->node->child; 629 dn = pdn->node->child;
@@ -869,30 +641,30 @@ void eeh_restore_bars(struct pci_dn *pdn)
869 * PCI devices are added individuallly; but, for the restore, 641 * PCI devices are added individuallly; but, for the restore,
870 * an entire slot is reset at a time. 642 * an entire slot is reset at a time.
871 */ 643 */
872static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn) 644static void eeh_save_bars(struct pci_dn *pdn)
873{ 645{
874 int i; 646 int i;
875 647
876 if (!pdev || !pdn ) 648 if (!pdn )
877 return; 649 return;
878 650
879 for (i = 0; i < 16; i++) 651 for (i = 0; i < 16; i++)
880 pci_read_config_dword(pdev, i * 4, &pdn->config_space[i]); 652 rtas_read_config(pdn, i * 4, 4, &pdn->config_space[i]);
881
882 if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
883 pdn->eeh_is_bridge = 1;
884} 653}
885 654
886void 655void
887rtas_configure_bridge(struct pci_dn *pdn) 656rtas_configure_bridge(struct pci_dn *pdn)
888{ 657{
889 int token = rtas_token ("ibm,configure-bridge"); 658 int config_addr;
890 int rc; 659 int rc;
891 660
892 if (token == RTAS_UNKNOWN_SERVICE) 661 /* Use PE configuration address, if present */
893 return; 662 config_addr = pdn->eeh_config_addr;
894 rc = rtas_call(token,3,1, NULL, 663 if (pdn->eeh_pe_config_addr)
895 pdn->eeh_config_addr, 664 config_addr = pdn->eeh_pe_config_addr;
665
666 rc = rtas_call(ibm_configure_bridge,3,1, NULL,
667 config_addr,
896 BUID_HI(pdn->phb->buid), 668 BUID_HI(pdn->phb->buid),
897 BUID_LO(pdn->phb->buid)); 669 BUID_LO(pdn->phb->buid));
898 if (rc) { 670 if (rc) {
@@ -927,6 +699,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
927 int enable; 699 int enable;
928 struct pci_dn *pdn = PCI_DN(dn); 700 struct pci_dn *pdn = PCI_DN(dn);
929 701
702 pdn->class_code = 0;
930 pdn->eeh_mode = 0; 703 pdn->eeh_mode = 0;
931 pdn->eeh_check_count = 0; 704 pdn->eeh_check_count = 0;
932 pdn->eeh_freeze_count = 0; 705 pdn->eeh_freeze_count = 0;
@@ -943,6 +716,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
943 pdn->eeh_mode |= EEH_MODE_NOCHECK; 716 pdn->eeh_mode |= EEH_MODE_NOCHECK;
944 return NULL; 717 return NULL;
945 } 718 }
719 pdn->class_code = *class_code;
946 720
947 /* 721 /*
948 * Now decide if we are going to "Disable" EEH checking 722 * Now decide if we are going to "Disable" EEH checking
@@ -953,8 +727,10 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
953 * But there are a few cases like display devices that make sense. 727 * But there are a few cases like display devices that make sense.
954 */ 728 */
955 enable = 1; /* i.e. we will do checking */ 729 enable = 1; /* i.e. we will do checking */
730#if 0
956 if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY) 731 if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
957 enable = 0; 732 enable = 0;
733#endif
958 734
959 if (!enable) 735 if (!enable)
960 pdn->eeh_mode |= EEH_MODE_NOCHECK; 736 pdn->eeh_mode |= EEH_MODE_NOCHECK;
@@ -973,8 +749,22 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
973 eeh_subsystem_enabled = 1; 749 eeh_subsystem_enabled = 1;
974 pdn->eeh_mode |= EEH_MODE_SUPPORTED; 750 pdn->eeh_mode |= EEH_MODE_SUPPORTED;
975 pdn->eeh_config_addr = regs[0]; 751 pdn->eeh_config_addr = regs[0];
752
753 /* If the newer, better, ibm,get-config-addr-info is supported,
754 * then use that instead. */
755 pdn->eeh_pe_config_addr = 0;
756 if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
757 unsigned int rets[2];
758 ret = rtas_call (ibm_get_config_addr_info, 4, 2, rets,
759 pdn->eeh_config_addr,
760 info->buid_hi, info->buid_lo,
761 0);
762 if (ret == 0)
763 pdn->eeh_pe_config_addr = rets[0];
764 }
976#ifdef DEBUG 765#ifdef DEBUG
977 printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name); 766 printk(KERN_DEBUG "EEH: %s: eeh enabled, config=%x pe_config=%x\n",
767 dn->full_name, pdn->eeh_config_addr, pdn->eeh_pe_config_addr);
978#endif 768#endif
979 } else { 769 } else {
980 770
@@ -993,6 +783,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
993 dn->full_name); 783 dn->full_name);
994 } 784 }
995 785
786 eeh_save_bars(pdn);
996 return NULL; 787 return NULL;
997} 788}
998 789
@@ -1026,6 +817,8 @@ void __init eeh_init(void)
1026 ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2"); 817 ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2");
1027 ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state"); 818 ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
1028 ibm_slot_error_detail = rtas_token("ibm,slot-error-detail"); 819 ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
820 ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info");
821 ibm_configure_bridge = rtas_token ("ibm,configure-bridge");
1029 822
1030 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE) 823 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
1031 return; 824 return;
@@ -1080,12 +873,10 @@ void eeh_add_device_early(struct device_node *dn)
1080 if (!dn || !PCI_DN(dn)) 873 if (!dn || !PCI_DN(dn))
1081 return; 874 return;
1082 phb = PCI_DN(dn)->phb; 875 phb = PCI_DN(dn)->phb;
1083 if (NULL == phb || 0 == phb->buid) { 876
1084 printk(KERN_WARNING "EEH: Expected buid but found none for %s\n", 877 /* USB Bus children of PCI devices will not have BUID's */
1085 dn->full_name); 878 if (NULL == phb || 0 == phb->buid)
1086 dump_stack();
1087 return; 879 return;
1088 }
1089 880
1090 info.buid_hi = BUID_HI(phb->buid); 881 info.buid_hi = BUID_HI(phb->buid);
1091 info.buid_lo = BUID_LO(phb->buid); 882 info.buid_lo = BUID_LO(phb->buid);
@@ -1127,7 +918,6 @@ void eeh_add_device_late(struct pci_dev *dev)
1127 pdn->pcidev = dev; 918 pdn->pcidev = dev;
1128 919
1129 pci_addr_cache_insert_device (dev); 920 pci_addr_cache_insert_device (dev);
1130 eeh_save_bars(dev, pdn);
1131} 921}
1132EXPORT_SYMBOL_GPL(eeh_add_device_late); 922EXPORT_SYMBOL_GPL(eeh_add_device_late);
1133 923
@@ -1175,25 +965,9 @@ EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
1175 965
1176static int proc_eeh_show(struct seq_file *m, void *v) 966static int proc_eeh_show(struct seq_file *m, void *v)
1177{ 967{
1178 unsigned int cpu;
1179 unsigned long ffs = 0, positives = 0, failures = 0;
1180 unsigned long resets = 0;
1181 unsigned long no_dev = 0, no_dn = 0, no_cfg = 0, no_check = 0;
1182
1183 for_each_cpu(cpu) {
1184 ffs += per_cpu(total_mmio_ffs, cpu);
1185 positives += per_cpu(false_positives, cpu);
1186 failures += per_cpu(ignored_failures, cpu);
1187 resets += per_cpu(slot_resets, cpu);
1188 no_dev += per_cpu(no_device, cpu);
1189 no_dn += per_cpu(no_dn, cpu);
1190 no_cfg += per_cpu(no_cfg_addr, cpu);
1191 no_check += per_cpu(ignored_check, cpu);
1192 }
1193
1194 if (0 == eeh_subsystem_enabled) { 968 if (0 == eeh_subsystem_enabled) {
1195 seq_printf(m, "EEH Subsystem is globally disabled\n"); 969 seq_printf(m, "EEH Subsystem is globally disabled\n");
1196 seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs); 970 seq_printf(m, "eeh_total_mmio_ffs=%ld\n", total_mmio_ffs);
1197 } else { 971 } else {
1198 seq_printf(m, "EEH Subsystem is enabled\n"); 972 seq_printf(m, "EEH Subsystem is enabled\n");
1199 seq_printf(m, 973 seq_printf(m,
@@ -1205,8 +979,10 @@ static int proc_eeh_show(struct seq_file *m, void *v)
1205 "eeh_false_positives=%ld\n" 979 "eeh_false_positives=%ld\n"
1206 "eeh_ignored_failures=%ld\n" 980 "eeh_ignored_failures=%ld\n"
1207 "eeh_slot_resets=%ld\n", 981 "eeh_slot_resets=%ld\n",
1208 no_dev, no_dn, no_cfg, no_check, 982 no_device, no_dn, no_cfg_addr,
1209 ffs, positives, failures, resets); 983 ignored_check, total_mmio_ffs,
984 false_positives, ignored_failures,
985 slot_resets);
1210 } 986 }
1211 987
1212 return 0; 988 return 0;
diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c
new file mode 100644
index 000000000000..d4a402c5866c
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/eeh_cache.c
@@ -0,0 +1,316 @@
1/*
2 * eeh_cache.c
3 * PCI address cache; allows the lookup of PCI devices based on I/O address
4 *
5 * Copyright (C) 2004 Linas Vepstas <linas@austin.ibm.com> IBM Corporation
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
22#include <linux/list.h>
23#include <linux/pci.h>
24#include <linux/rbtree.h>
25#include <linux/spinlock.h>
26#include <asm/atomic.h>
27#include <asm/pci-bridge.h>
28#include <asm/ppc-pci.h>
29
30#undef DEBUG
31
32/**
33 * The pci address cache subsystem. This subsystem places
34 * PCI device address resources into a red-black tree, sorted
35 * according to the address range, so that given only an i/o
36 * address, the corresponding PCI device can be **quickly**
37 * found. It is safe to perform an address lookup in an interrupt
38 * context; this ability is an important feature.
39 *
40 * Currently, the only customer of this code is the EEH subsystem;
41 * thus, this code has been somewhat tailored to suit EEH better.
42 * In particular, the cache does *not* hold the addresses of devices
43 * for which EEH is not enabled.
44 *
45 * (Implementation Note: The RB tree seems to be better/faster
46 * than any hash algo I could think of for this problem, even
47 * with the penalty of slow pointer chases for d-cache misses).
48 */
49struct pci_io_addr_range
50{
51 struct rb_node rb_node;
52 unsigned long addr_lo;
53 unsigned long addr_hi;
54 struct pci_dev *pcidev;
55 unsigned int flags;
56};
57
58static struct pci_io_addr_cache
59{
60 struct rb_root rb_root;
61 spinlock_t piar_lock;
62} pci_io_addr_cache_root;
63
64static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr)
65{
66 struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node;
67
68 while (n) {
69 struct pci_io_addr_range *piar;
70 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
71
72 if (addr < piar->addr_lo) {
73 n = n->rb_left;
74 } else {
75 if (addr > piar->addr_hi) {
76 n = n->rb_right;
77 } else {
78 pci_dev_get(piar->pcidev);
79 return piar->pcidev;
80 }
81 }
82 }
83
84 return NULL;
85}
86
87/**
88 * pci_get_device_by_addr - Get device, given only address
89 * @addr: mmio (PIO) phys address or i/o port number
90 *
91 * Given an mmio phys address, or a port number, find a pci device
92 * that implements this address. Be sure to pci_dev_put the device
93 * when finished. I/O port numbers are assumed to be offset
94 * from zero (that is, they do *not* have pci_io_addr added in).
95 * It is safe to call this function within an interrupt.
96 */
97struct pci_dev *pci_get_device_by_addr(unsigned long addr)
98{
99 struct pci_dev *dev;
100 unsigned long flags;
101
102 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
103 dev = __pci_get_device_by_addr(addr);
104 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
105 return dev;
106}
107
108#ifdef DEBUG
109/*
110 * Handy-dandy debug print routine, does nothing more
111 * than print out the contents of our addr cache.
112 */
113static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
114{
115 struct rb_node *n;
116 int cnt = 0;
117
118 n = rb_first(&cache->rb_root);
119 while (n) {
120 struct pci_io_addr_range *piar;
121 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
122 printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n",
123 (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
124 piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev));
125 cnt++;
126 n = rb_next(n);
127 }
128}
129#endif
130
131/* Insert address range into the rb tree. */
132static struct pci_io_addr_range *
133pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
134 unsigned long ahi, unsigned int flags)
135{
136 struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node;
137 struct rb_node *parent = NULL;
138 struct pci_io_addr_range *piar;
139
140 /* Walk tree, find a place to insert into tree */
141 while (*p) {
142 parent = *p;
143 piar = rb_entry(parent, struct pci_io_addr_range, rb_node);
144 if (ahi < piar->addr_lo) {
145 p = &parent->rb_left;
146 } else if (alo > piar->addr_hi) {
147 p = &parent->rb_right;
148 } else {
149 if (dev != piar->pcidev ||
150 alo != piar->addr_lo || ahi != piar->addr_hi) {
151 printk(KERN_WARNING "PIAR: overlapping address range\n");
152 }
153 return piar;
154 }
155 }
156 piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC);
157 if (!piar)
158 return NULL;
159
160 piar->addr_lo = alo;
161 piar->addr_hi = ahi;
162 piar->pcidev = dev;
163 piar->flags = flags;
164
165#ifdef DEBUG
166 printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n",
167 alo, ahi, pci_name (dev));
168#endif
169
170 rb_link_node(&piar->rb_node, parent, p);
171 rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root);
172
173 return piar;
174}
175
176static void __pci_addr_cache_insert_device(struct pci_dev *dev)
177{
178 struct device_node *dn;
179 struct pci_dn *pdn;
180 int i;
181 int inserted = 0;
182
183 dn = pci_device_to_OF_node(dev);
184 if (!dn) {
185 printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev));
186 return;
187 }
188
189 /* Skip any devices for which EEH is not enabled. */
190 pdn = PCI_DN(dn);
191 if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
192 pdn->eeh_mode & EEH_MODE_NOCHECK) {
193#ifdef DEBUG
194 printk(KERN_INFO "PCI: skip building address cache for=%s - %s\n",
195 pci_name(dev), pdn->node->full_name);
196#endif
197 return;
198 }
199
200 /* The cache holds a reference to the device... */
201 pci_dev_get(dev);
202
203 /* Walk resources on this device, poke them into the tree */
204 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
205 unsigned long start = pci_resource_start(dev,i);
206 unsigned long end = pci_resource_end(dev,i);
207 unsigned int flags = pci_resource_flags(dev,i);
208
209 /* We are interested only bus addresses, not dma or other stuff */
210 if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM)))
211 continue;
212 if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
213 continue;
214 pci_addr_cache_insert(dev, start, end, flags);
215 inserted = 1;
216 }
217
218 /* If there was nothing to add, the cache has no reference... */
219 if (!inserted)
220 pci_dev_put(dev);
221}
222
223/**
224 * pci_addr_cache_insert_device - Add a device to the address cache
225 * @dev: PCI device whose I/O addresses we are interested in.
226 *
227 * In order to support the fast lookup of devices based on addresses,
228 * we maintain a cache of devices that can be quickly searched.
229 * This routine adds a device to that cache.
230 */
231void pci_addr_cache_insert_device(struct pci_dev *dev)
232{
233 unsigned long flags;
234
235 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
236 __pci_addr_cache_insert_device(dev);
237 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
238}
239
240static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
241{
242 struct rb_node *n;
243 int removed = 0;
244
245restart:
246 n = rb_first(&pci_io_addr_cache_root.rb_root);
247 while (n) {
248 struct pci_io_addr_range *piar;
249 piar = rb_entry(n, struct pci_io_addr_range, rb_node);
250
251 if (piar->pcidev == dev) {
252 rb_erase(n, &pci_io_addr_cache_root.rb_root);
253 removed = 1;
254 kfree(piar);
255 goto restart;
256 }
257 n = rb_next(n);
258 }
259
260 /* The cache no longer holds its reference to this device... */
261 if (removed)
262 pci_dev_put(dev);
263}
264
265/**
266 * pci_addr_cache_remove_device - remove pci device from addr cache
267 * @dev: device to remove
268 *
269 * Remove a device from the addr-cache tree.
270 * This is potentially expensive, since it will walk
271 * the tree multiple times (once per resource).
272 * But so what; device removal doesn't need to be that fast.
273 */
274void pci_addr_cache_remove_device(struct pci_dev *dev)
275{
276 unsigned long flags;
277
278 spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
279 __pci_addr_cache_remove_device(dev);
280 spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
281}
282
283/**
284 * pci_addr_cache_build - Build a cache of I/O addresses
285 *
286 * Build a cache of pci i/o addresses. This cache will be used to
287 * find the pci device that corresponds to a given address.
288 * This routine scans all pci busses to build the cache.
289 * Must be run late in boot process, after the pci controllers
290 * have been scaned for devices (after all device resources are known).
291 */
292void __init pci_addr_cache_build(void)
293{
294 struct device_node *dn;
295 struct pci_dev *dev = NULL;
296
297 spin_lock_init(&pci_io_addr_cache_root.piar_lock);
298
299 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
300 /* Ignore PCI bridges */
301 if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
302 continue;
303
304 pci_addr_cache_insert_device(dev);
305
306 dn = pci_device_to_OF_node(dev);
307 pci_dev_get (dev); /* matching put is in eeh_remove_device() */
308 PCI_DN(dn)->pcidev = dev;
309 }
310
311#ifdef DEBUG
312 /* Verify tree built up above, echo back the list of addrs. */
313 pci_addr_cache_print(&pci_io_addr_cache_root);
314#endif
315}
316
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c
new file mode 100644
index 000000000000..6373372932ba
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/eeh_driver.c
@@ -0,0 +1,376 @@
1/*
2 * PCI Error Recovery Driver for RPA-compliant PPC64 platform.
3 * Copyright (C) 2004, 2005 Linas Vepstas <linas@linas.org>
4 *
5 * All rights reserved.
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 (at
10 * your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
15 * NON INFRINGEMENT. See the GNU General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Send feedback to <linas@us.ibm.com>
23 *
24 */
25#include <linux/delay.h>
26#include <linux/irq.h>
27#include <linux/interrupt.h>
28#include <linux/notifier.h>
29#include <linux/pci.h>
30#include <asm/eeh.h>
31#include <asm/eeh_event.h>
32#include <asm/ppc-pci.h>
33#include <asm/pci-bridge.h>
34#include <asm/prom.h>
35#include <asm/rtas.h>
36
37
38static inline const char * pcid_name (struct pci_dev *pdev)
39{
40 if (pdev->dev.driver)
41 return pdev->dev.driver->name;
42 return "";
43}
44
45#ifdef DEBUG
46static void print_device_node_tree (struct pci_dn *pdn, int dent)
47{
48 int i;
49 if (!pdn) return;
50 for (i=0;i<dent; i++)
51 printk(" ");
52 printk("dn=%s mode=%x \tcfg_addr=%x pe_addr=%x \tfull=%s\n",
53 pdn->node->name, pdn->eeh_mode, pdn->eeh_config_addr,
54 pdn->eeh_pe_config_addr, pdn->node->full_name);
55 dent += 3;
56 struct device_node *pc = pdn->node->child;
57 while (pc) {
58 print_device_node_tree(PCI_DN(pc), dent);
59 pc = pc->sibling;
60 }
61}
62#endif
63
64/**
65 * irq_in_use - return true if this irq is being used
66 */
67static int irq_in_use(unsigned int irq)
68{
69 int rc = 0;
70 unsigned long flags;
71 struct irq_desc *desc = irq_desc + irq;
72
73 spin_lock_irqsave(&desc->lock, flags);
74 if (desc->action)
75 rc = 1;
76 spin_unlock_irqrestore(&desc->lock, flags);
77 return rc;
78}
79
80/* ------------------------------------------------------- */
81/** eeh_report_error - report an EEH error to each device,
82 * collect up and merge the device responses.
83 */
84
85static void eeh_report_error(struct pci_dev *dev, void *userdata)
86{
87 enum pci_ers_result rc, *res = userdata;
88 struct pci_driver *driver = dev->driver;
89
90 dev->error_state = pci_channel_io_frozen;
91
92 if (!driver)
93 return;
94
95 if (irq_in_use (dev->irq)) {
96 struct device_node *dn = pci_device_to_OF_node(dev);
97 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED;
98 disable_irq_nosync(dev->irq);
99 }
100 if (!driver->err_handler)
101 return;
102 if (!driver->err_handler->error_detected)
103 return;
104
105 rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen);
106 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
107 if (*res == PCI_ERS_RESULT_NEED_RESET) return;
108 if (*res == PCI_ERS_RESULT_DISCONNECT &&
109 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
110}
111
112/** eeh_report_reset -- tell this device that the pci slot
113 * has been reset.
114 */
115
116static void eeh_report_reset(struct pci_dev *dev, void *userdata)
117{
118 struct pci_driver *driver = dev->driver;
119 struct device_node *dn = pci_device_to_OF_node(dev);
120
121 if (!driver)
122 return;
123
124 if ((PCI_DN(dn)->eeh_mode) & EEH_MODE_IRQ_DISABLED) {
125 PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED;
126 enable_irq(dev->irq);
127 }
128 if (!driver->err_handler)
129 return;
130 if (!driver->err_handler->slot_reset)
131 return;
132
133 driver->err_handler->slot_reset(dev);
134}
135
136static void eeh_report_resume(struct pci_dev *dev, void *userdata)
137{
138 struct pci_driver *driver = dev->driver;
139
140 dev->error_state = pci_channel_io_normal;
141
142 if (!driver)
143 return;
144 if (!driver->err_handler)
145 return;
146 if (!driver->err_handler->resume)
147 return;
148
149 driver->err_handler->resume(dev);
150}
151
152static void eeh_report_failure(struct pci_dev *dev, void *userdata)
153{
154 struct pci_driver *driver = dev->driver;
155
156 dev->error_state = pci_channel_io_perm_failure;
157
158 if (!driver)
159 return;
160
161 if (irq_in_use (dev->irq)) {
162 struct device_node *dn = pci_device_to_OF_node(dev);
163 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED;
164 disable_irq_nosync(dev->irq);
165 }
166 if (!driver->err_handler)
167 return;
168 if (!driver->err_handler->error_detected)
169 return;
170 driver->err_handler->error_detected(dev, pci_channel_io_perm_failure);
171}
172
173/* ------------------------------------------------------- */
174/**
175 * handle_eeh_events -- reset a PCI device after hard lockup.
176 *
177 * pSeries systems will isolate a PCI slot if the PCI-Host
178 * bridge detects address or data parity errors, DMA's
179 * occuring to wild addresses (which usually happen due to
180 * bugs in device drivers or in PCI adapter firmware).
181 * Slot isolations also occur if #SERR, #PERR or other misc
182 * PCI-related errors are detected.
183 *
184 * Recovery process consists of unplugging the device driver
185 * (which generated hotplug events to userspace), then issuing
186 * a PCI #RST to the device, then reconfiguring the PCI config
187 * space for all bridges & devices under this slot, and then
188 * finally restarting the device drivers (which cause a second
189 * set of hotplug events to go out to userspace).
190 */
191
192/**
193 * eeh_reset_device() -- perform actual reset of a pci slot
194 * Args: bus: pointer to the pci bus structure corresponding
195 * to the isolated slot. A non-null value will
196 * cause all devices under the bus to be removed
197 * and then re-added.
198 * pe_dn: pointer to a "Partionable Endpoint" device node.
199 * This is the top-level structure on which pci
200 * bus resets can be performed.
201 */
202
203static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus)
204{
205 int rc;
206 if (bus)
207 pcibios_remove_pci_devices(bus);
208
209 /* Reset the pci controller. (Asserts RST#; resets config space).
210 * Reconfigure bridges and devices. Don't try to bring the system
211 * up if the reset failed for some reason. */
212 rc = rtas_set_slot_reset(pe_dn);
213 if (rc)
214 return rc;
215
216 /* New-style config addrs might be shared across multiple devices,
217 * Walk over all functions on this device */
218 if (pe_dn->eeh_pe_config_addr) {
219 struct device_node *pe = pe_dn->node;
220 pe = pe->parent->child;
221 while (pe) {
222 struct pci_dn *ppe = PCI_DN(pe);
223 if (pe_dn->eeh_pe_config_addr == ppe->eeh_pe_config_addr) {
224 rtas_configure_bridge(ppe);
225 eeh_restore_bars(ppe);
226 }
227 pe = pe->sibling;
228 }
229 } else {
230 rtas_configure_bridge(pe_dn);
231 eeh_restore_bars(pe_dn);
232 }
233
234 /* Give the system 5 seconds to finish running the user-space
235 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
236 * this is a hack, but if we don't do this, and try to bring
237 * the device up before the scripts have taken it down,
238 * potentially weird things happen.
239 */
240 if (bus) {
241 ssleep (5);
242 pcibios_add_pci_devices(bus);
243 }
244
245 return 0;
246}
247
248/* The longest amount of time to wait for a pci device
249 * to come back on line, in seconds.
250 */
251#define MAX_WAIT_FOR_RECOVERY 15
252
253void handle_eeh_events (struct eeh_event *event)
254{
255 struct device_node *frozen_dn;
256 struct pci_dn *frozen_pdn;
257 struct pci_bus *frozen_bus;
258 int rc = 0;
259 enum pci_ers_result result = PCI_ERS_RESULT_NONE;
260
261 frozen_dn = find_device_pe(event->dn);
262 frozen_bus = pcibios_find_pci_bus(frozen_dn);
263
264 if (!frozen_dn) {
265 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint for %s\n",
266 pci_name(event->dev));
267 return;
268 }
269
270 /* There are two different styles for coming up with the PE.
271 * In the old style, it was the highest EEH-capable device
272 * which was always an EADS pci bridge. In the new style,
273 * there might not be any EADS bridges, and even when there are,
274 * the firmware marks them as "EEH incapable". So another
275 * two-step is needed to find the pci bus.. */
276 if (!frozen_bus)
277 frozen_bus = pcibios_find_pci_bus (frozen_dn->parent);
278
279 if (!frozen_bus) {
280 printk(KERN_ERR "EEH: Cannot find PCI bus for %s\n",
281 frozen_dn->full_name);
282 return;
283 }
284
285#if 0
286 /* We may get "permanent failure" messages on empty slots.
287 * These are false alarms. Empty slots have no child dn. */
288 if ((event->state == pci_channel_io_perm_failure) && (frozen_device == NULL))
289 return;
290#endif
291
292 frozen_pdn = PCI_DN(frozen_dn);
293 frozen_pdn->eeh_freeze_count++;
294
295 if (frozen_pdn->eeh_freeze_count > EEH_MAX_ALLOWED_FREEZES)
296 goto hard_fail;
297
298 /* If the reset state is a '5' and the time to reset is 0 (infinity)
299 * or is more then 15 seconds, then mark this as a permanent failure.
300 */
301 if ((event->state == pci_channel_io_perm_failure) &&
302 ((event->time_unavail <= 0) ||
303 (event->time_unavail > MAX_WAIT_FOR_RECOVERY*1000)))
304 goto hard_fail;
305
306 eeh_slot_error_detail(frozen_pdn, 1 /* Temporary Error */);
307 printk(KERN_WARNING
308 "EEH: This PCI device has failed %d times since last reboot: %s - %s\n",
309 frozen_pdn->eeh_freeze_count,
310 pci_name (frozen_pdn->pcidev),
311 pcid_name(frozen_pdn->pcidev));
312
313 /* Walk the various device drivers attached to this slot through
314 * a reset sequence, giving each an opportunity to do what it needs
315 * to accomplish the reset. Each child gets a report of the
316 * status ... if any child can't handle the reset, then the entire
317 * slot is dlpar removed and added.
318 */
319 pci_walk_bus(frozen_bus, eeh_report_error, &result);
320
321 /* If all device drivers were EEH-unaware, then shut
322 * down all of the device drivers, and hope they
323 * go down willingly, without panicing the system.
324 */
325 if (result == PCI_ERS_RESULT_NONE) {
326 rc = eeh_reset_device(frozen_pdn, frozen_bus);
327 if (rc)
328 goto hard_fail;
329 }
330
331 /* If any device called out for a reset, then reset the slot */
332 if (result == PCI_ERS_RESULT_NEED_RESET) {
333 rc = eeh_reset_device(frozen_pdn, NULL);
334 if (rc)
335 goto hard_fail;
336 pci_walk_bus(frozen_bus, eeh_report_reset, 0);
337 }
338
339 /* If all devices reported they can proceed, the re-enable PIO */
340 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
341 /* XXX Not supported; we brute-force reset the device */
342 rc = eeh_reset_device(frozen_pdn, NULL);
343 if (rc)
344 goto hard_fail;
345 pci_walk_bus(frozen_bus, eeh_report_reset, 0);
346 }
347
348 /* Tell all device drivers that they can resume operations */
349 pci_walk_bus(frozen_bus, eeh_report_resume, 0);
350
351 return;
352
353hard_fail:
354 /*
355 * About 90% of all real-life EEH failures in the field
356 * are due to poorly seated PCI cards. Only 10% or so are
357 * due to actual, failed cards.
358 */
359 printk(KERN_ERR
360 "EEH: PCI device %s - %s has failed %d times \n"
361 "and has been permanently disabled. Please try reseating\n"
362 "this device or replacing it.\n",
363 pci_name (frozen_pdn->pcidev),
364 pcid_name(frozen_pdn->pcidev),
365 frozen_pdn->eeh_freeze_count);
366
367 eeh_slot_error_detail(frozen_pdn, 2 /* Permanent Error */);
368
369 /* Notify all devices that they're about to go down. */
370 pci_walk_bus(frozen_bus, eeh_report_failure, 0);
371
372 /* Shut down the device drivers for good. */
373 pcibios_remove_pci_devices(frozen_bus);
374}
375
376/* ---------- end of file ---------- */
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 92497333c2b6..9a9961f27480 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -21,6 +21,7 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <asm/eeh_event.h> 23#include <asm/eeh_event.h>
24#include <asm/ppc-pci.h>
24 25
25/** Overview: 26/** Overview:
26 * EEH error states may be detected within exception handlers; 27 * EEH error states may be detected within exception handlers;
@@ -37,31 +38,6 @@ static void eeh_thread_launcher(void *);
37DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); 38DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL);
38 39
39/** 40/**
40 * eeh_panic - call panic() for an eeh event that cannot be handled.
41 * The philosophy of this routine is that it is better to panic and
42 * halt the OS than it is to risk possible data corruption by
43 * oblivious device drivers that don't know better.
44 *
45 * @dev pci device that had an eeh event
46 * @reset_state current reset state of the device slot
47 */
48static void eeh_panic(struct pci_dev *dev, int reset_state)
49{
50 /*
51 * Since the panic_on_oops sysctl is used to halt the system
52 * in light of potential corruption, we can use it here.
53 */
54 if (panic_on_oops) {
55 panic("EEH: MMIO failure (%d) on device:%s\n", reset_state,
56 pci_name(dev));
57 }
58 else {
59 printk(KERN_INFO "EEH: Ignored MMIO failure (%d) on device:%s\n",
60 reset_state, pci_name(dev));
61 }
62}
63
64/**
65 * eeh_event_handler - dispatch EEH events. The detection of a frozen 41 * eeh_event_handler - dispatch EEH events. The detection of a frozen
66 * slot can occur inside an interrupt, where it can be hard to do 42 * slot can occur inside an interrupt, where it can be hard to do
67 * anything about it. The goal of this routine is to pull these 43 * anything about it. The goal of this routine is to pull these
@@ -82,10 +58,16 @@ static int eeh_event_handler(void * dummy)
82 58
83 spin_lock_irqsave(&eeh_eventlist_lock, flags); 59 spin_lock_irqsave(&eeh_eventlist_lock, flags);
84 event = NULL; 60 event = NULL;
61
62 /* Unqueue the event, get ready to process. */
85 if (!list_empty(&eeh_eventlist)) { 63 if (!list_empty(&eeh_eventlist)) {
86 event = list_entry(eeh_eventlist.next, struct eeh_event, list); 64 event = list_entry(eeh_eventlist.next, struct eeh_event, list);
87 list_del(&event->list); 65 list_del(&event->list);
88 } 66 }
67
68 if (event)
69 eeh_mark_slot(event->dn, EEH_MODE_RECOVERING);
70
89 spin_unlock_irqrestore(&eeh_eventlist_lock, flags); 71 spin_unlock_irqrestore(&eeh_eventlist_lock, flags);
90 if (event == NULL) 72 if (event == NULL)
91 break; 73 break;
@@ -93,8 +75,11 @@ static int eeh_event_handler(void * dummy)
93 printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", 75 printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n",
94 pci_name(event->dev)); 76 pci_name(event->dev));
95 77
96 eeh_panic (event->dev, event->state); 78 handle_eeh_events(event);
79
80 eeh_clear_slot(event->dn, EEH_MODE_RECOVERING);
97 81
82 pci_dev_put(event->dev);
98 kfree(event); 83 kfree(event);
99 } 84 }
100 85
@@ -122,7 +107,7 @@ static void eeh_thread_launcher(void *dummy)
122 */ 107 */
123int eeh_send_failure_event (struct device_node *dn, 108int eeh_send_failure_event (struct device_node *dn,
124 struct pci_dev *dev, 109 struct pci_dev *dev,
125 int state, 110 enum pci_channel_state state,
126 int time_unavail) 111 int time_unavail)
127{ 112{
128 unsigned long flags; 113 unsigned long flags;
diff --git a/arch/powerpc/platforms/pseries/hvcserver.c b/arch/powerpc/platforms/pseries/hvcserver.c
index 4d584172055a..22bfb5c89db9 100644
--- a/arch/powerpc/platforms/pseries/hvcserver.c
+++ b/arch/powerpc/platforms/pseries/hvcserver.c
@@ -40,7 +40,7 @@ MODULE_VERSION(HVCS_ARCH_VERSION);
40 * functions aren't performance sensitive, so this conversion isn't an 40 * functions aren't performance sensitive, so this conversion isn't an
41 * issue. 41 * issue.
42 */ 42 */
43int hvcs_convert(long to_convert) 43static int hvcs_convert(long to_convert)
44{ 44{
45 switch (to_convert) { 45 switch (to_convert) {
46 case H_Success: 46 case H_Success:
@@ -91,7 +91,7 @@ int hvcs_free_partner_info(struct list_head *head)
91EXPORT_SYMBOL(hvcs_free_partner_info); 91EXPORT_SYMBOL(hvcs_free_partner_info);
92 92
93/* Helper function for hvcs_get_partner_info */ 93/* Helper function for hvcs_get_partner_info */
94int hvcs_next_partner(uint32_t unit_address, 94static int hvcs_next_partner(uint32_t unit_address,
95 unsigned long last_p_partition_ID, 95 unsigned long last_p_partition_ID,
96 unsigned long last_p_unit_address, unsigned long *pi_buff) 96 unsigned long last_p_unit_address, unsigned long *pi_buff)
97 97
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 169f9148789c..48cfbfc43f99 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -51,8 +51,6 @@
51 51
52#define DBG(fmt...) 52#define DBG(fmt...)
53 53
54extern int is_python(struct device_node *);
55
56static void tce_build_pSeries(struct iommu_table *tbl, long index, 54static void tce_build_pSeries(struct iommu_table *tbl, long index,
57 long npages, unsigned long uaddr, 55 long npages, unsigned long uaddr,
58 enum dma_data_direction direction) 56 enum dma_data_direction direction)
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index 2edc947f7c44..50643496eb63 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -192,7 +192,7 @@ struct file_operations scanlog_fops = {
192 .release = scanlog_release, 192 .release = scanlog_release,
193}; 193};
194 194
195int __init scanlog_init(void) 195static int __init scanlog_init(void)
196{ 196{
197 struct proc_dir_entry *ent; 197 struct proc_dir_entry *ent;
198 198
@@ -222,7 +222,7 @@ int __init scanlog_init(void)
222 return 0; 222 return 0;
223} 223}
224 224
225void __exit scanlog_cleanup(void) 225static void __exit scanlog_cleanup(void)
226{ 226{
227 if (proc_ppc64_scan_log_dump) { 227 if (proc_ppc64_scan_log_dump) {
228 kfree(proc_ppc64_scan_log_dump->data); 228 kfree(proc_ppc64_scan_log_dump->data);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 8903cf63236a..68b7f086d63d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -86,7 +86,7 @@ static void pseries_dedicated_idle(void);
86 86
87struct mpic *pSeries_mpic; 87struct mpic *pSeries_mpic;
88 88
89void pSeries_show_cpuinfo(struct seq_file *m) 89static void pSeries_show_cpuinfo(struct seq_file *m)
90{ 90{
91 struct device_node *root; 91 struct device_node *root;
92 const char *model = ""; 92 const char *model = "";
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 25181c594d73..8e6b1ed1396e 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -93,7 +93,7 @@ static int query_cpu_stopped(unsigned int pcpu)
93 return cpu_status; 93 return cpu_status;
94} 94}
95 95
96int pSeries_cpu_disable(void) 96static int pSeries_cpu_disable(void)
97{ 97{
98 int cpu = smp_processor_id(); 98 int cpu = smp_processor_id();
99 99
@@ -109,7 +109,7 @@ int pSeries_cpu_disable(void)
109 return 0; 109 return 0;
110} 110}
111 111
112void pSeries_cpu_die(unsigned int cpu) 112static void pSeries_cpu_die(unsigned int cpu)
113{ 113{
114 int tries; 114 int tries;
115 int cpu_status; 115 int cpu_status;
@@ -282,7 +282,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
282 pcpu = get_hard_smp_processor_id(lcpu); 282 pcpu = get_hard_smp_processor_id(lcpu);
283 283
284 /* Fixup atomic count: it exited inside IRQ handler. */ 284 /* Fixup atomic count: it exited inside IRQ handler. */
285 paca[lcpu].__current->thread_info->preempt_count = 0; 285 task_thread_info(paca[lcpu].__current)->preempt_count = 0;
286 286
287 /* 287 /*
288 * If the RTAS start-cpu token does not exist then presume the 288 * If the RTAS start-cpu token does not exist then presume the
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index 0c0cfa32eb58..fd823c7c9ac8 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -381,7 +381,7 @@ int xics_get_irq(struct pt_regs *regs)
381 381
382#ifdef CONFIG_SMP 382#ifdef CONFIG_SMP
383 383
384irqreturn_t xics_ipi_action(int irq, void *dev_id, struct pt_regs *regs) 384static irqreturn_t xics_ipi_action(int irq, void *dev_id, struct pt_regs *regs)
385{ 385{
386 int cpu = smp_processor_id(); 386 int cpu = smp_processor_id();
387 387
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 14b9abde2d27..0ae841347a09 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -6,4 +6,4 @@ obj-$(CONFIG_BOOKE) += dcr.o
6obj-$(CONFIG_40x) += dcr.o 6obj-$(CONFIG_40x) += dcr.o
7obj-$(CONFIG_U3_DART) += dart_iommu.o 7obj-$(CONFIG_U3_DART) += dart_iommu.o
8obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o 8obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
9obj-$(CONFIG_83xx) += ipic.o 9obj-$(CONFIG_PPC_83xx) += ipic.o
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index e00b46b9514e..977de9db8754 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -139,7 +139,6 @@ static void dart_build(struct iommu_table *tbl, long index,
139 139
140 *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK); 140 *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK);
141 141
142 rpn++;
143 uaddr += DART_PAGE_SIZE; 142 uaddr += DART_PAGE_SIZE;
144 } 143 }
145 144
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 22612ed5379c..7d02fa2a8990 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -311,7 +311,7 @@ static void release_output_lock(void)
311} 311}
312#endif 312#endif
313 313
314int xmon_core(struct pt_regs *regs, int fromipi) 314static int xmon_core(struct pt_regs *regs, int fromipi)
315{ 315{
316 int cmd = 0; 316 int cmd = 0;
317 unsigned long msr; 317 unsigned long msr;
@@ -528,7 +528,7 @@ xmon_irq(int irq, void *d, struct pt_regs *regs)
528 return IRQ_HANDLED; 528 return IRQ_HANDLED;
529} 529}
530 530
531int xmon_bpt(struct pt_regs *regs) 531static int xmon_bpt(struct pt_regs *regs)
532{ 532{
533 struct bpt *bp; 533 struct bpt *bp;
534 unsigned long offset; 534 unsigned long offset;
@@ -554,7 +554,7 @@ int xmon_bpt(struct pt_regs *regs)
554 return 1; 554 return 1;
555} 555}
556 556
557int xmon_sstep(struct pt_regs *regs) 557static int xmon_sstep(struct pt_regs *regs)
558{ 558{
559 if (user_mode(regs)) 559 if (user_mode(regs))
560 return 0; 560 return 0;
@@ -562,7 +562,7 @@ int xmon_sstep(struct pt_regs *regs)
562 return 1; 562 return 1;
563} 563}
564 564
565int xmon_dabr_match(struct pt_regs *regs) 565static int xmon_dabr_match(struct pt_regs *regs)
566{ 566{
567 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF)) 567 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF))
568 return 0; 568 return 0;
@@ -572,7 +572,7 @@ int xmon_dabr_match(struct pt_regs *regs)
572 return 1; 572 return 1;
573} 573}
574 574
575int xmon_iabr_match(struct pt_regs *regs) 575static int xmon_iabr_match(struct pt_regs *regs)
576{ 576{
577 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF)) 577 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF))
578 return 0; 578 return 0;
@@ -582,7 +582,7 @@ int xmon_iabr_match(struct pt_regs *regs)
582 return 1; 582 return 1;
583} 583}
584 584
585int xmon_ipi(struct pt_regs *regs) 585static int xmon_ipi(struct pt_regs *regs)
586{ 586{
587#ifdef CONFIG_SMP 587#ifdef CONFIG_SMP
588 if (in_xmon && !cpu_isset(smp_processor_id(), cpus_in_xmon)) 588 if (in_xmon && !cpu_isset(smp_processor_id(), cpus_in_xmon))
@@ -591,7 +591,7 @@ int xmon_ipi(struct pt_regs *regs)
591 return 0; 591 return 0;
592} 592}
593 593
594int xmon_fault_handler(struct pt_regs *regs) 594static int xmon_fault_handler(struct pt_regs *regs)
595{ 595{
596 struct bpt *bp; 596 struct bpt *bp;
597 unsigned long offset; 597 unsigned long offset;
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index 84d96b857e4a..ebc4db8fcc63 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -47,6 +47,7 @@
47#include <linux/mm.h> 47#include <linux/mm.h>
48#include <linux/slab.h> 48#include <linux/slab.h>
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/capability.h>
50#include <linux/circ_buf.h> 51#include <linux/circ_buf.h>
51#include <linux/serial.h> 52#include <linux/serial.h>
52#include <linux/console.h> 53#include <linux/console.h>
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index e396f4591d59..d65810108bc3 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -743,6 +743,10 @@ config MPC834x
743 bool 743 bool
744 default y if MPC834x_SYS 744 default y if MPC834x_SYS
745 745
746config PPC_83xx
747 bool
748 default y if 83xx
749
746config CPM1 750config CPM1
747 bool 751 bool
748 depends on 8xx 752 depends on 8xx
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index e719a4933af1..98e940beeb3b 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -128,10 +128,9 @@ TOUT := .tmp_gas_check
128# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec 128# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec
129# instructions. 129# instructions.
130# gcc-3.4 and binutils-2.14 are a fatal combination. 130# gcc-3.4 and binutils-2.14 are a fatal combination.
131GCC_VERSION := $(call cc-version)
132 131
133checkbin: 132checkbin:
134 @if test "$(GCC_VERSION)" = "0304" ; then \ 133 @if test "$(call cc-version)" = "0304" ; then \
135 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ 134 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
136 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ 135 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
137 echo 'correctly with gcc-3.4 and your version of binutils.'; \ 136 echo 'correctly with gcc-3.4 and your version of binutils.'; \
diff --git a/arch/ppc/amiga/amiints.c b/arch/ppc/amiga/amiints.c
index 91195e2ce38d..5f35cf3986f7 100644
--- a/arch/ppc/amiga/amiints.c
+++ b/arch/ppc/amiga/amiints.c
@@ -96,8 +96,8 @@ void amiga_init_IRQ(void)
96 gayle.inten = GAYLE_IRQ_IDE; 96 gayle.inten = GAYLE_IRQ_IDE;
97 97
98 /* turn off all interrupts... */ 98 /* turn off all interrupts... */
99 custom.intena = 0x7fff; 99 amiga_custom.intena = 0x7fff;
100 custom.intreq = 0x7fff; 100 amiga_custom.intreq = 0x7fff;
101 101
102#ifdef CONFIG_APUS 102#ifdef CONFIG_APUS
103 /* Clear any inter-CPU interrupt requests. Circumvents bug in 103 /* Clear any inter-CPU interrupt requests. Circumvents bug in
@@ -110,7 +110,7 @@ void amiga_init_IRQ(void)
110 APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_IPLMASK); 110 APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_IPLMASK);
111#endif 111#endif
112 /* ... and enable the master interrupt bit */ 112 /* ... and enable the master interrupt bit */
113 custom.intena = IF_SETCLR | IF_INTEN; 113 amiga_custom.intena = IF_SETCLR | IF_INTEN;
114 114
115 cia_init_IRQ(&ciaa_base); 115 cia_init_IRQ(&ciaa_base);
116 cia_init_IRQ(&ciab_base); 116 cia_init_IRQ(&ciab_base);
@@ -151,7 +151,7 @@ void amiga_enable_irq(unsigned int irq)
151 } 151 }
152 152
153 /* enable the interrupt */ 153 /* enable the interrupt */
154 custom.intena = IF_SETCLR | ami_intena_vals[irq]; 154 amiga_custom.intena = IF_SETCLR | ami_intena_vals[irq];
155} 155}
156 156
157void amiga_disable_irq(unsigned int irq) 157void amiga_disable_irq(unsigned int irq)
@@ -177,7 +177,7 @@ void amiga_disable_irq(unsigned int irq)
177 } 177 }
178 178
179 /* disable the interrupt */ 179 /* disable the interrupt */
180 custom.intena = ami_intena_vals[irq]; 180 amiga_custom.intena = ami_intena_vals[irq];
181} 181}
182 182
183inline void amiga_do_irq(int irq, struct pt_regs *fp) 183inline void amiga_do_irq(int irq, struct pt_regs *fp)
@@ -196,7 +196,7 @@ void amiga_do_irq_list(int irq, struct pt_regs *fp)
196 196
197 kstat_cpu(0).irqs[irq]++; 197 kstat_cpu(0).irqs[irq]++;
198 198
199 custom.intreq = ami_intena_vals[irq]; 199 amiga_custom.intreq = ami_intena_vals[irq];
200 200
201 for (action = desc->action; action; action = action->next) 201 for (action = desc->action; action; action = action->next)
202 action->handler(irq, action->dev_id, fp); 202 action->handler(irq, action->dev_id, fp);
@@ -208,40 +208,40 @@ void amiga_do_irq_list(int irq, struct pt_regs *fp)
208 208
209static void ami_int1(int irq, void *dev_id, struct pt_regs *fp) 209static void ami_int1(int irq, void *dev_id, struct pt_regs *fp)
210{ 210{
211 unsigned short ints = custom.intreqr & custom.intenar; 211 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
212 212
213 /* if serial transmit buffer empty, interrupt */ 213 /* if serial transmit buffer empty, interrupt */
214 if (ints & IF_TBE) { 214 if (ints & IF_TBE) {
215 custom.intreq = IF_TBE; 215 amiga_custom.intreq = IF_TBE;
216 amiga_do_irq(IRQ_AMIGA_TBE, fp); 216 amiga_do_irq(IRQ_AMIGA_TBE, fp);
217 } 217 }
218 218
219 /* if floppy disk transfer complete, interrupt */ 219 /* if floppy disk transfer complete, interrupt */
220 if (ints & IF_DSKBLK) { 220 if (ints & IF_DSKBLK) {
221 custom.intreq = IF_DSKBLK; 221 amiga_custom.intreq = IF_DSKBLK;
222 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp); 222 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp);
223 } 223 }
224 224
225 /* if software interrupt set, interrupt */ 225 /* if software interrupt set, interrupt */
226 if (ints & IF_SOFT) { 226 if (ints & IF_SOFT) {
227 custom.intreq = IF_SOFT; 227 amiga_custom.intreq = IF_SOFT;
228 amiga_do_irq(IRQ_AMIGA_SOFT, fp); 228 amiga_do_irq(IRQ_AMIGA_SOFT, fp);
229 } 229 }
230} 230}
231 231
232static void ami_int3(int irq, void *dev_id, struct pt_regs *fp) 232static void ami_int3(int irq, void *dev_id, struct pt_regs *fp)
233{ 233{
234 unsigned short ints = custom.intreqr & custom.intenar; 234 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
235 235
236 /* if a blitter interrupt */ 236 /* if a blitter interrupt */
237 if (ints & IF_BLIT) { 237 if (ints & IF_BLIT) {
238 custom.intreq = IF_BLIT; 238 amiga_custom.intreq = IF_BLIT;
239 amiga_do_irq(IRQ_AMIGA_BLIT, fp); 239 amiga_do_irq(IRQ_AMIGA_BLIT, fp);
240 } 240 }
241 241
242 /* if a copper interrupt */ 242 /* if a copper interrupt */
243 if (ints & IF_COPER) { 243 if (ints & IF_COPER) {
244 custom.intreq = IF_COPER; 244 amiga_custom.intreq = IF_COPER;
245 amiga_do_irq(IRQ_AMIGA_COPPER, fp); 245 amiga_do_irq(IRQ_AMIGA_COPPER, fp);
246 } 246 }
247 247
@@ -252,36 +252,36 @@ static void ami_int3(int irq, void *dev_id, struct pt_regs *fp)
252 252
253static void ami_int4(int irq, void *dev_id, struct pt_regs *fp) 253static void ami_int4(int irq, void *dev_id, struct pt_regs *fp)
254{ 254{
255 unsigned short ints = custom.intreqr & custom.intenar; 255 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
256 256
257 /* if audio 0 interrupt */ 257 /* if audio 0 interrupt */
258 if (ints & IF_AUD0) { 258 if (ints & IF_AUD0) {
259 custom.intreq = IF_AUD0; 259 amiga_custom.intreq = IF_AUD0;
260 amiga_do_irq(IRQ_AMIGA_AUD0, fp); 260 amiga_do_irq(IRQ_AMIGA_AUD0, fp);
261 } 261 }
262 262
263 /* if audio 1 interrupt */ 263 /* if audio 1 interrupt */
264 if (ints & IF_AUD1) { 264 if (ints & IF_AUD1) {
265 custom.intreq = IF_AUD1; 265 amiga_custom.intreq = IF_AUD1;
266 amiga_do_irq(IRQ_AMIGA_AUD1, fp); 266 amiga_do_irq(IRQ_AMIGA_AUD1, fp);
267 } 267 }
268 268
269 /* if audio 2 interrupt */ 269 /* if audio 2 interrupt */
270 if (ints & IF_AUD2) { 270 if (ints & IF_AUD2) {
271 custom.intreq = IF_AUD2; 271 amiga_custom.intreq = IF_AUD2;
272 amiga_do_irq(IRQ_AMIGA_AUD2, fp); 272 amiga_do_irq(IRQ_AMIGA_AUD2, fp);
273 } 273 }
274 274
275 /* if audio 3 interrupt */ 275 /* if audio 3 interrupt */
276 if (ints & IF_AUD3) { 276 if (ints & IF_AUD3) {
277 custom.intreq = IF_AUD3; 277 amiga_custom.intreq = IF_AUD3;
278 amiga_do_irq(IRQ_AMIGA_AUD3, fp); 278 amiga_do_irq(IRQ_AMIGA_AUD3, fp);
279 } 279 }
280} 280}
281 281
282static void ami_int5(int irq, void *dev_id, struct pt_regs *fp) 282static void ami_int5(int irq, void *dev_id, struct pt_regs *fp)
283{ 283{
284 unsigned short ints = custom.intreqr & custom.intenar; 284 unsigned short ints = amiga_custom.intreqr & amiga_custom.intenar;
285 285
286 /* if serial receive buffer full interrupt */ 286 /* if serial receive buffer full interrupt */
287 if (ints & IF_RBF) { 287 if (ints & IF_RBF) {
@@ -291,7 +291,7 @@ static void ami_int5(int irq, void *dev_id, struct pt_regs *fp)
291 291
292 /* if a disk sync interrupt */ 292 /* if a disk sync interrupt */
293 if (ints & IF_DSKSYN) { 293 if (ints & IF_DSKSYN) {
294 custom.intreq = IF_DSKSYN; 294 amiga_custom.intreq = IF_DSKSYN;
295 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp); 295 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp);
296 } 296 }
297} 297}
diff --git a/arch/ppc/amiga/cia.c b/arch/ppc/amiga/cia.c
index ad961465b6cb..4431c58f611a 100644
--- a/arch/ppc/amiga/cia.c
+++ b/arch/ppc/amiga/cia.c
@@ -66,7 +66,7 @@ static unsigned char cia_set_irq_private(struct ciabase *base,
66 else 66 else
67 base->icr_data &= ~mask; 67 base->icr_data &= ~mask;
68 if (base->icr_data & base->icr_mask) 68 if (base->icr_data & base->icr_mask)
69 custom.intreq = IF_SETCLR | base->int_mask; 69 amiga_custom.intreq = IF_SETCLR | base->int_mask;
70 return old & base->icr_mask; 70 return old & base->icr_mask;
71} 71}
72 72
@@ -114,7 +114,7 @@ static unsigned char cia_able_irq_private(struct ciabase *base,
114 base->icr_mask &= CIA_ICR_ALL; 114 base->icr_mask &= CIA_ICR_ALL;
115 115
116 if (base->icr_data & base->icr_mask) 116 if (base->icr_data & base->icr_mask)
117 custom.intreq = IF_SETCLR | base->int_mask; 117 amiga_custom.intreq = IF_SETCLR | base->int_mask;
118 return old; 118 return old;
119} 119}
120 120
@@ -145,7 +145,7 @@ static void cia_handler(int irq, void *dev_id, struct pt_regs *fp)
145 irq = base->cia_irq; 145 irq = base->cia_irq;
146 desc = irq_desc + irq; 146 desc = irq_desc + irq;
147 ints = cia_set_irq_private(base, CIA_ICR_ALL); 147 ints = cia_set_irq_private(base, CIA_ICR_ALL);
148 custom.intreq = base->int_mask; 148 amiga_custom.intreq = base->int_mask;
149 for (i = 0; i < CIA_IRQS; i++, irq++) { 149 for (i = 0; i < CIA_IRQS; i++, irq++) {
150 if (ints & 1) { 150 if (ints & 1) {
151 kstat_cpu(0).irqs[irq]++; 151 kstat_cpu(0).irqs[irq]++;
@@ -174,5 +174,5 @@ void __init cia_init_IRQ(struct ciabase *base)
174 action->name = base->name; 174 action->name = base->name;
175 setup_irq(base->handler_irq, &amiga_sys_irqaction[base->handler_irq-IRQ_AMIGA_AUTO]); 175 setup_irq(base->handler_irq, &amiga_sys_irqaction[base->handler_irq-IRQ_AMIGA_AUTO]);
176 176
177 custom.intena = IF_SETCLR | base->int_mask; 177 amiga_custom.intena = IF_SETCLR | base->int_mask;
178} 178}
diff --git a/arch/ppc/amiga/config.c b/arch/ppc/amiga/config.c
index af881d7454dd..60e2da1c92c0 100644
--- a/arch/ppc/amiga/config.c
+++ b/arch/ppc/amiga/config.c
@@ -90,9 +90,6 @@ static void a3000_gettod (int *, int *, int *, int *, int *, int *);
90static void a2000_gettod (int *, int *, int *, int *, int *, int *); 90static void a2000_gettod (int *, int *, int *, int *, int *, int *);
91static int amiga_hwclk (int, struct hwclk_time *); 91static int amiga_hwclk (int, struct hwclk_time *);
92static int amiga_set_clock_mmss (unsigned long); 92static int amiga_set_clock_mmss (unsigned long);
93#ifdef CONFIG_AMIGA_FLOPPY
94extern void amiga_floppy_setup(char *, int *);
95#endif
96static void amiga_reset (void); 93static void amiga_reset (void);
97extern void amiga_init_sound(void); 94extern void amiga_init_sound(void);
98static void amiga_savekmsg_init(void); 95static void amiga_savekmsg_init(void);
@@ -281,7 +278,7 @@ static void __init amiga_identify(void)
281 case CS_OCS: 278 case CS_OCS:
282 case CS_ECS: 279 case CS_ECS:
283 case CS_AGA: 280 case CS_AGA:
284 switch (custom.deniseid & 0xf) { 281 switch (amiga_custom.deniseid & 0xf) {
285 case 0x0c: 282 case 0x0c:
286 AMIGAHW_SET(DENISE_HR); 283 AMIGAHW_SET(DENISE_HR);
287 break; 284 break;
@@ -294,7 +291,7 @@ static void __init amiga_identify(void)
294 AMIGAHW_SET(DENISE); 291 AMIGAHW_SET(DENISE);
295 break; 292 break;
296 } 293 }
297 switch ((custom.vposr>>8) & 0x7f) { 294 switch ((amiga_custom.vposr>>8) & 0x7f) {
298 case 0x00: 295 case 0x00:
299 AMIGAHW_SET(AGNUS_PAL); 296 AMIGAHW_SET(AGNUS_PAL);
300 break; 297 break;
@@ -419,9 +416,6 @@ void __init config_amiga(void)
419 416
420 mach_hwclk = amiga_hwclk; 417 mach_hwclk = amiga_hwclk;
421 mach_set_clock_mmss = amiga_set_clock_mmss; 418 mach_set_clock_mmss = amiga_set_clock_mmss;
422#ifdef CONFIG_AMIGA_FLOPPY
423 mach_floppy_setup = amiga_floppy_setup;
424#endif
425 mach_reset = amiga_reset; 419 mach_reset = amiga_reset;
426#ifdef CONFIG_HEARTBEAT 420#ifdef CONFIG_HEARTBEAT
427 mach_heartbeat = amiga_heartbeat; 421 mach_heartbeat = amiga_heartbeat;
@@ -432,9 +426,9 @@ void __init config_amiga(void)
432 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */ 426 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
433 427
434 /* clear all DMA bits */ 428 /* clear all DMA bits */
435 custom.dmacon = DMAF_ALL; 429 amiga_custom.dmacon = DMAF_ALL;
436 /* ensure that the DMA master bit is set */ 430 /* ensure that the DMA master bit is set */
437 custom.dmacon = DMAF_SETCLR | DMAF_MASTER; 431 amiga_custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
438 432
439 /* request all RAM */ 433 /* request all RAM */
440 for (i = 0; i < m68k_num_memory; i++) { 434 for (i = 0; i < m68k_num_memory; i++) {
@@ -753,9 +747,9 @@ static void amiga_savekmsg_init(void)
753 747
754static void amiga_serial_putc(char c) 748static void amiga_serial_putc(char c)
755{ 749{
756 custom.serdat = (unsigned char)c | 0x100; 750 amiga_custom.serdat = (unsigned char)c | 0x100;
757 mb(); 751 mb();
758 while (!(custom.serdatr & 0x2000)) 752 while (!(amiga_custom.serdatr & 0x2000))
759 ; 753 ;
760} 754}
761 755
@@ -785,11 +779,11 @@ int amiga_serial_console_wait_key(struct console *co)
785{ 779{
786 int ch; 780 int ch;
787 781
788 while (!(custom.intreqr & IF_RBF)) 782 while (!(amiga_custom.intreqr & IF_RBF))
789 barrier(); 783 barrier();
790 ch = custom.serdatr & 0xff; 784 ch = amiga_custom.serdatr & 0xff;
791 /* clear the interrupt, so that another character can be read */ 785 /* clear the interrupt, so that another character can be read */
792 custom.intreq = IF_RBF; 786 amiga_custom.intreq = IF_RBF;
793 return ch; 787 return ch;
794} 788}
795 789
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index e6c1d615bb86..ca0201300868 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -13,7 +13,6 @@ extra-$(CONFIG_POWER4) += idle_power4.o
13extra-y += vmlinux.lds 13extra-y += vmlinux.lds
14 14
15obj-y := entry.o traps.o idle.o time.o misc.o \ 15obj-y := entry.o traps.o idle.o time.o misc.o \
16 process.o \
17 setup.o \ 16 setup.o \
18 ppc_htab.o 17 ppc_htab.o
19obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o 18obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o
diff --git a/arch/ppc/kernel/machine_kexec.c b/arch/ppc/kernel/machine_kexec.c
index a882b0dbe8de..84d65a87191e 100644
--- a/arch/ppc/kernel/machine_kexec.c
+++ b/arch/ppc/kernel/machine_kexec.c
@@ -28,12 +28,6 @@ typedef NORET_TYPE void (*relocate_new_kernel_t)(
28const extern unsigned char relocate_new_kernel[]; 28const extern unsigned char relocate_new_kernel[];
29const extern unsigned int relocate_new_kernel_size; 29const extern unsigned int relocate_new_kernel_size;
30 30
31/*
32 * Provide a dummy crash_notes definition while crash dump arrives to ppc.
33 * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
34 */
35note_buf_t crash_notes[NR_CPUS];
36
37void machine_shutdown(void) 31void machine_shutdown(void)
38{ 32{
39 if (ppc_md.machine_shutdown) 33 if (ppc_md.machine_shutdown)
diff --git a/arch/ppc/kernel/ppc_htab.c b/arch/ppc/kernel/ppc_htab.c
index ca810025993f..2f5c7650274f 100644
--- a/arch/ppc/kernel/ppc_htab.c
+++ b/arch/ppc/kernel/ppc_htab.c
@@ -16,6 +16,7 @@
16#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
17#include <linux/stat.h> 17#include <linux/stat.h>
18#include <linux/sysctl.h> 18#include <linux/sysctl.h>
19#include <linux/capability.h>
19#include <linux/ctype.h> 20#include <linux/ctype.h>
20#include <linux/threads.h> 21#include <linux/threads.h>
21#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
diff --git a/arch/ppc/kernel/process.c b/arch/ppc/kernel/process.c
deleted file mode 100644
index 25cbdc8d2941..000000000000
--- a/arch/ppc/kernel/process.c
+++ /dev/null
@@ -1,851 +0,0 @@
1/*
2 * arch/ppc/kernel/process.c
3 *
4 * Derived from "arch/i386/kernel/process.c"
5 * Copyright (C) 1995 Linus Torvalds
6 *
7 * Updated and modified by Cort Dougan (cort@cs.nmt.edu) and
8 * Paul Mackerras (paulus@cs.anu.edu.au)
9 *
10 * PowerPC version
11 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 *
18 */
19
20#include <linux/config.h>
21#include <linux/errno.h>
22#include <linux/sched.h>
23#include <linux/kernel.h>
24#include <linux/mm.h>
25#include <linux/smp.h>
26#include <linux/smp_lock.h>
27#include <linux/stddef.h>
28#include <linux/unistd.h>
29#include <linux/ptrace.h>
30#include <linux/slab.h>
31#include <linux/user.h>
32#include <linux/elf.h>
33#include <linux/init.h>
34#include <linux/prctl.h>
35#include <linux/init_task.h>
36#include <linux/module.h>
37#include <linux/kallsyms.h>
38#include <linux/mqueue.h>
39#include <linux/hardirq.h>
40
41#include <asm/pgtable.h>
42#include <asm/uaccess.h>
43#include <asm/system.h>
44#include <asm/io.h>
45#include <asm/processor.h>
46#include <asm/mmu.h>
47#include <asm/prom.h>
48
49extern unsigned long _get_SP(void);
50
51struct task_struct *last_task_used_math = NULL;
52struct task_struct *last_task_used_altivec = NULL;
53struct task_struct *last_task_used_spe = NULL;
54
55static struct fs_struct init_fs = INIT_FS;
56static struct files_struct init_files = INIT_FILES;
57static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
58static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
59struct mm_struct init_mm = INIT_MM(init_mm);
60EXPORT_SYMBOL(init_mm);
61
62/* this is 8kB-aligned so we can get to the thread_info struct
63 at the base of it from the stack pointer with 1 integer instruction. */
64union thread_union init_thread_union
65 __attribute__((__section__(".data.init_task"))) =
66{ INIT_THREAD_INFO(init_task) };
67
68/* initial task structure */
69struct task_struct init_task = INIT_TASK(init_task);
70EXPORT_SYMBOL(init_task);
71
72/* only used to get secondary processor up */
73struct task_struct *current_set[NR_CPUS] = {&init_task, };
74
75#undef SHOW_TASK_SWITCHES
76#undef CHECK_STACK
77
78#if defined(CHECK_STACK)
79unsigned long
80kernel_stack_top(struct task_struct *tsk)
81{
82 return ((unsigned long)tsk) + sizeof(union task_union);
83}
84
85unsigned long
86task_top(struct task_struct *tsk)
87{
88 return ((unsigned long)tsk) + sizeof(struct thread_info);
89}
90
91/* check to make sure the kernel stack is healthy */
92int check_stack(struct task_struct *tsk)
93{
94 unsigned long stack_top = kernel_stack_top(tsk);
95 unsigned long tsk_top = task_top(tsk);
96 int ret = 0;
97
98#if 0
99 /* check thread magic */
100 if ( tsk->thread.magic != THREAD_MAGIC )
101 {
102 ret |= 1;
103 printk("thread.magic bad: %08x\n", tsk->thread.magic);
104 }
105#endif
106
107 if ( !tsk )
108 printk("check_stack(): tsk bad tsk %p\n",tsk);
109
110 /* check if stored ksp is bad */
111 if ( (tsk->thread.ksp > stack_top) || (tsk->thread.ksp < tsk_top) )
112 {
113 printk("stack out of bounds: %s/%d\n"
114 " tsk_top %08lx ksp %08lx stack_top %08lx\n",
115 tsk->comm,tsk->pid,
116 tsk_top, tsk->thread.ksp, stack_top);
117 ret |= 2;
118 }
119
120 /* check if stack ptr RIGHT NOW is bad */
121 if ( (tsk == current) && ((_get_SP() > stack_top ) || (_get_SP() < tsk_top)) )
122 {
123 printk("current stack ptr out of bounds: %s/%d\n"
124 " tsk_top %08lx sp %08lx stack_top %08lx\n",
125 current->comm,current->pid,
126 tsk_top, _get_SP(), stack_top);
127 ret |= 4;
128 }
129
130#if 0
131 /* check amount of free stack */
132 for ( i = (unsigned long *)task_top(tsk) ; i < kernel_stack_top(tsk) ; i++ )
133 {
134 if ( !i )
135 printk("check_stack(): i = %p\n", i);
136 if ( *i != 0 )
137 {
138 /* only notify if it's less than 900 bytes */
139 if ( (i - (unsigned long *)task_top(tsk)) < 900 )
140 printk("%d bytes free on stack\n",
141 i - task_top(tsk));
142 break;
143 }
144 }
145#endif
146
147 if (ret)
148 {
149 panic("bad kernel stack");
150 }
151 return(ret);
152}
153#endif /* defined(CHECK_STACK) */
154
155/*
156 * Make sure the floating-point register state in the
157 * the thread_struct is up to date for task tsk.
158 */
159void flush_fp_to_thread(struct task_struct *tsk)
160{
161 if (tsk->thread.regs) {
162 /*
163 * We need to disable preemption here because if we didn't,
164 * another process could get scheduled after the regs->msr
165 * test but before we have finished saving the FP registers
166 * to the thread_struct. That process could take over the
167 * FPU, and then when we get scheduled again we would store
168 * bogus values for the remaining FP registers.
169 */
170 preempt_disable();
171 if (tsk->thread.regs->msr & MSR_FP) {
172#ifdef CONFIG_SMP
173 /*
174 * This should only ever be called for current or
175 * for a stopped child process. Since we save away
176 * the FP register state on context switch on SMP,
177 * there is something wrong if a stopped child appears
178 * to still have its FP state in the CPU registers.
179 */
180 BUG_ON(tsk != current);
181#endif
182 giveup_fpu(current);
183 }
184 preempt_enable();
185 }
186}
187
188void enable_kernel_fp(void)
189{
190 WARN_ON(preemptible());
191
192#ifdef CONFIG_SMP
193 if (current->thread.regs && (current->thread.regs->msr & MSR_FP))
194 giveup_fpu(current);
195 else
196 giveup_fpu(NULL); /* just enables FP for kernel */
197#else
198 giveup_fpu(last_task_used_math);
199#endif /* CONFIG_SMP */
200}
201EXPORT_SYMBOL(enable_kernel_fp);
202
203int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
204{
205 preempt_disable();
206 if (tsk->thread.regs && (tsk->thread.regs->msr & MSR_FP))
207 giveup_fpu(tsk);
208 preempt_enable();
209 memcpy(fpregs, &tsk->thread.fpr[0], sizeof(*fpregs));
210 return 1;
211}
212
213#ifdef CONFIG_ALTIVEC
214void enable_kernel_altivec(void)
215{
216 WARN_ON(preemptible());
217
218#ifdef CONFIG_SMP
219 if (current->thread.regs && (current->thread.regs->msr & MSR_VEC))
220 giveup_altivec(current);
221 else
222 giveup_altivec(NULL); /* just enable AltiVec for kernel - force */
223#else
224 giveup_altivec(last_task_used_altivec);
225#endif /* __SMP __ */
226}
227EXPORT_SYMBOL(enable_kernel_altivec);
228
229/*
230 * Make sure the VMX/Altivec register state in the
231 * the thread_struct is up to date for task tsk.
232 */
233void flush_altivec_to_thread(struct task_struct *tsk)
234{
235 if (tsk->thread.regs) {
236 preempt_disable();
237 if (tsk->thread.regs->msr & MSR_VEC) {
238#ifdef CONFIG_SMP
239 BUG_ON(tsk != current);
240#endif
241 giveup_altivec(current);
242 }
243 preempt_enable();
244 }
245}
246
247int dump_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
248{
249 if (regs->msr & MSR_VEC)
250 giveup_altivec(current);
251 memcpy(vrregs, &current->thread.vr[0], sizeof(*vrregs));
252 return 1;
253}
254#endif /* CONFIG_ALTIVEC */
255
256#ifdef CONFIG_SPE
257void
258enable_kernel_spe(void)
259{
260 WARN_ON(preemptible());
261
262#ifdef CONFIG_SMP
263 if (current->thread.regs && (current->thread.regs->msr & MSR_SPE))
264 giveup_spe(current);
265 else
266 giveup_spe(NULL); /* just enable SPE for kernel - force */
267#else
268 giveup_spe(last_task_used_spe);
269#endif /* __SMP __ */
270}
271EXPORT_SYMBOL(enable_kernel_spe);
272
273void flush_spe_to_thread(struct task_struct *tsk)
274{
275 if (tsk->thread.regs) {
276 preempt_disable();
277 if (tsk->thread.regs->msr & MSR_SPE) {
278#ifdef CONFIG_SMP
279 BUG_ON(tsk != current);
280#endif
281 giveup_spe(current);
282 }
283 preempt_enable();
284 }
285}
286
287int dump_spe(struct pt_regs *regs, elf_vrregset_t *evrregs)
288{
289 if (regs->msr & MSR_SPE)
290 giveup_spe(current);
291 /* We copy u32 evr[32] + u64 acc + u32 spefscr -> 35 */
292 memcpy(evrregs, &current->thread.evr[0], sizeof(u32) * 35);
293 return 1;
294}
295#endif /* CONFIG_SPE */
296
297struct task_struct *__switch_to(struct task_struct *prev,
298 struct task_struct *new)
299{
300 struct thread_struct *new_thread, *old_thread;
301 unsigned long s;
302 struct task_struct *last;
303
304 local_irq_save(s);
305#ifdef CHECK_STACK
306 check_stack(prev);
307 check_stack(new);
308#endif
309
310#ifdef CONFIG_SMP
311 /* avoid complexity of lazy save/restore of fpu
312 * by just saving it every time we switch out if
313 * this task used the fpu during the last quantum.
314 *
315 * If it tries to use the fpu again, it'll trap and
316 * reload its fp regs. So we don't have to do a restore
317 * every switch, just a save.
318 * -- Cort
319 */
320 if (prev->thread.regs && (prev->thread.regs->msr & MSR_FP))
321 giveup_fpu(prev);
322#ifdef CONFIG_ALTIVEC
323 /*
324 * If the previous thread used altivec in the last quantum
325 * (thus changing altivec regs) then save them.
326 * We used to check the VRSAVE register but not all apps
327 * set it, so we don't rely on it now (and in fact we need
328 * to save & restore VSCR even if VRSAVE == 0). -- paulus
329 *
330 * On SMP we always save/restore altivec regs just to avoid the
331 * complexity of changing processors.
332 * -- Cort
333 */
334 if ((prev->thread.regs && (prev->thread.regs->msr & MSR_VEC)))
335 giveup_altivec(prev);
336#endif /* CONFIG_ALTIVEC */
337#ifdef CONFIG_SPE
338 /*
339 * If the previous thread used spe in the last quantum
340 * (thus changing spe regs) then save them.
341 *
342 * On SMP we always save/restore spe regs just to avoid the
343 * complexity of changing processors.
344 */
345 if ((prev->thread.regs && (prev->thread.regs->msr & MSR_SPE)))
346 giveup_spe(prev);
347#endif /* CONFIG_SPE */
348#endif /* CONFIG_SMP */
349
350#ifdef CONFIG_ALTIVEC
351 /* Avoid the trap. On smp this this never happens since
352 * we don't set last_task_used_altivec -- Cort
353 */
354 if (new->thread.regs && last_task_used_altivec == new)
355 new->thread.regs->msr |= MSR_VEC;
356#endif
357#ifdef CONFIG_SPE
358 /* Avoid the trap. On smp this this never happens since
359 * we don't set last_task_used_spe
360 */
361 if (new->thread.regs && last_task_used_spe == new)
362 new->thread.regs->msr |= MSR_SPE;
363#endif /* CONFIG_SPE */
364 new_thread = &new->thread;
365 old_thread = &current->thread;
366 last = _switch(old_thread, new_thread);
367 local_irq_restore(s);
368 return last;
369}
370
371void show_regs(struct pt_regs * regs)
372{
373 int i, trap;
374
375 printk("NIP: %08lX LR: %08lX SP: %08lX REGS: %p TRAP: %04lx %s\n",
376 regs->nip, regs->link, regs->gpr[1], regs, regs->trap,
377 print_tainted());
378 printk("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
379 regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
380 regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
381 regs->msr&MSR_IR ? 1 : 0,
382 regs->msr&MSR_DR ? 1 : 0);
383 trap = TRAP(regs);
384 if (trap == 0x300 || trap == 0x600)
385 printk("DAR: %08lX, DSISR: %08lX\n", regs->dar, regs->dsisr);
386 printk("TASK = %p[%d] '%s' THREAD: %p\n",
387 current, current->pid, current->comm, current->thread_info);
388 printk("Last syscall: %ld ", current->thread.last_syscall);
389
390#ifdef CONFIG_SMP
391 printk(" CPU: %d", smp_processor_id());
392#endif /* CONFIG_SMP */
393
394 for (i = 0; i < 32; i++) {
395 long r;
396 if ((i % 8) == 0)
397 printk("\n" KERN_INFO "GPR%02d: ", i);
398 if (__get_user(r, &regs->gpr[i]))
399 break;
400 printk("%08lX ", r);
401 if (i == 12 && !FULL_REGS(regs))
402 break;
403 }
404 printk("\n");
405#ifdef CONFIG_KALLSYMS
406 /*
407 * Lookup NIP late so we have the best change of getting the
408 * above info out without failing
409 */
410 printk("NIP [%08lx] ", regs->nip);
411 print_symbol("%s\n", regs->nip);
412 printk("LR [%08lx] ", regs->link);
413 print_symbol("%s\n", regs->link);
414#endif
415 show_stack(current, (unsigned long *) regs->gpr[1]);
416}
417
418void exit_thread(void)
419{
420 preempt_disable();
421 if (last_task_used_math == current)
422 last_task_used_math = NULL;
423 if (last_task_used_altivec == current)
424 last_task_used_altivec = NULL;
425#ifdef CONFIG_SPE
426 if (last_task_used_spe == current)
427 last_task_used_spe = NULL;
428#endif
429 preempt_enable();
430}
431
432void flush_thread(void)
433{
434 preempt_disable();
435 if (last_task_used_math == current)
436 last_task_used_math = NULL;
437 if (last_task_used_altivec == current)
438 last_task_used_altivec = NULL;
439#ifdef CONFIG_SPE
440 if (last_task_used_spe == current)
441 last_task_used_spe = NULL;
442#endif
443 preempt_enable();
444}
445
446void
447release_thread(struct task_struct *t)
448{
449}
450
451/*
452 * This gets called before we allocate a new thread and copy
453 * the current task into it.
454 */
455void prepare_to_copy(struct task_struct *tsk)
456{
457 struct pt_regs *regs = tsk->thread.regs;
458
459 if (regs == NULL)
460 return;
461 preempt_disable();
462 if (regs->msr & MSR_FP)
463 giveup_fpu(current);
464#ifdef CONFIG_ALTIVEC
465 if (regs->msr & MSR_VEC)
466 giveup_altivec(current);
467#endif /* CONFIG_ALTIVEC */
468#ifdef CONFIG_SPE
469 if (regs->msr & MSR_SPE)
470 giveup_spe(current);
471#endif /* CONFIG_SPE */
472 preempt_enable();
473}
474
475/*
476 * Copy a thread..
477 */
478int
479copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
480 unsigned long unused,
481 struct task_struct *p, struct pt_regs *regs)
482{
483 struct pt_regs *childregs, *kregs;
484 extern void ret_from_fork(void);
485 unsigned long sp = (unsigned long)p->thread_info + THREAD_SIZE;
486 unsigned long childframe;
487
488 CHECK_FULL_REGS(regs);
489 /* Copy registers */
490 sp -= sizeof(struct pt_regs);
491 childregs = (struct pt_regs *) sp;
492 *childregs = *regs;
493 if ((childregs->msr & MSR_PR) == 0) {
494 /* for kernel thread, set `current' and stackptr in new task */
495 childregs->gpr[1] = sp + sizeof(struct pt_regs);
496 childregs->gpr[2] = (unsigned long) p;
497 p->thread.regs = NULL; /* no user register state */
498 } else {
499 childregs->gpr[1] = usp;
500 p->thread.regs = childregs;
501 if (clone_flags & CLONE_SETTLS)
502 childregs->gpr[2] = childregs->gpr[6];
503 }
504 childregs->gpr[3] = 0; /* Result from fork() */
505 sp -= STACK_FRAME_OVERHEAD;
506 childframe = sp;
507
508 /*
509 * The way this works is that at some point in the future
510 * some task will call _switch to switch to the new task.
511 * That will pop off the stack frame created below and start
512 * the new task running at ret_from_fork. The new task will
513 * do some house keeping and then return from the fork or clone
514 * system call, using the stack frame created above.
515 */
516 sp -= sizeof(struct pt_regs);
517 kregs = (struct pt_regs *) sp;
518 sp -= STACK_FRAME_OVERHEAD;
519 p->thread.ksp = sp;
520 kregs->nip = (unsigned long)ret_from_fork;
521
522 p->thread.last_syscall = -1;
523
524 return 0;
525}
526
527/*
528 * Set up a thread for executing a new program
529 */
530void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp)
531{
532 set_fs(USER_DS);
533 memset(regs->gpr, 0, sizeof(regs->gpr));
534 regs->ctr = 0;
535 regs->link = 0;
536 regs->xer = 0;
537 regs->ccr = 0;
538 regs->mq = 0;
539 regs->nip = nip;
540 regs->gpr[1] = sp;
541 regs->msr = MSR_USER;
542 preempt_disable();
543 if (last_task_used_math == current)
544 last_task_used_math = NULL;
545 if (last_task_used_altivec == current)
546 last_task_used_altivec = NULL;
547#ifdef CONFIG_SPE
548 if (last_task_used_spe == current)
549 last_task_used_spe = NULL;
550#endif
551 preempt_enable();
552 memset(current->thread.fpr, 0, sizeof(current->thread.fpr));
553 current->thread.fpscr.val = 0;
554#ifdef CONFIG_ALTIVEC
555 memset(current->thread.vr, 0, sizeof(current->thread.vr));
556 memset(&current->thread.vscr, 0, sizeof(current->thread.vscr));
557 current->thread.vrsave = 0;
558 current->thread.used_vr = 0;
559#endif /* CONFIG_ALTIVEC */
560#ifdef CONFIG_SPE
561 memset(current->thread.evr, 0, sizeof(current->thread.evr));
562 current->thread.acc = 0;
563 current->thread.spefscr = 0;
564 current->thread.used_spe = 0;
565#endif /* CONFIG_SPE */
566}
567
568#define PR_FP_ALL_EXCEPT (PR_FP_EXC_DIV | PR_FP_EXC_OVF | PR_FP_EXC_UND \
569 | PR_FP_EXC_RES | PR_FP_EXC_INV)
570
571int set_fpexc_mode(struct task_struct *tsk, unsigned int val)
572{
573 struct pt_regs *regs = tsk->thread.regs;
574
575 /* This is a bit hairy. If we are an SPE enabled processor
576 * (have embedded fp) we store the IEEE exception enable flags in
577 * fpexc_mode. fpexc_mode is also used for setting FP exception
578 * mode (asyn, precise, disabled) for 'Classic' FP. */
579 if (val & PR_FP_EXC_SW_ENABLE) {
580#ifdef CONFIG_SPE
581 tsk->thread.fpexc_mode = val &
582 (PR_FP_EXC_SW_ENABLE | PR_FP_ALL_EXCEPT);
583#else
584 return -EINVAL;
585#endif
586 } else {
587 /* on a CONFIG_SPE this does not hurt us. The bits that
588 * __pack_fe01 use do not overlap with bits used for
589 * PR_FP_EXC_SW_ENABLE. Additionally, the MSR[FE0,FE1] bits
590 * on CONFIG_SPE implementations are reserved so writing to
591 * them does not change anything */
592 if (val > PR_FP_EXC_PRECISE)
593 return -EINVAL;
594 tsk->thread.fpexc_mode = __pack_fe01(val);
595 if (regs != NULL && (regs->msr & MSR_FP) != 0)
596 regs->msr = (regs->msr & ~(MSR_FE0|MSR_FE1))
597 | tsk->thread.fpexc_mode;
598 }
599 return 0;
600}
601
602int get_fpexc_mode(struct task_struct *tsk, unsigned long adr)
603{
604 unsigned int val;
605
606 if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE)
607#ifdef CONFIG_SPE
608 val = tsk->thread.fpexc_mode;
609#else
610 return -EINVAL;
611#endif
612 else
613 val = __unpack_fe01(tsk->thread.fpexc_mode);
614 return put_user(val, (unsigned int __user *) adr);
615}
616
617int sys_clone(unsigned long clone_flags, unsigned long usp,
618 int __user *parent_tidp, void __user *child_threadptr,
619 int __user *child_tidp, int p6,
620 struct pt_regs *regs)
621{
622 CHECK_FULL_REGS(regs);
623 if (usp == 0)
624 usp = regs->gpr[1]; /* stack pointer for child */
625 return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp);
626}
627
628int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3,
629 unsigned long p4, unsigned long p5, unsigned long p6,
630 struct pt_regs *regs)
631{
632 CHECK_FULL_REGS(regs);
633 return do_fork(SIGCHLD, regs->gpr[1], regs, 0, NULL, NULL);
634}
635
636int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3,
637 unsigned long p4, unsigned long p5, unsigned long p6,
638 struct pt_regs *regs)
639{
640 CHECK_FULL_REGS(regs);
641 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gpr[1],
642 regs, 0, NULL, NULL);
643}
644
645int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
646 unsigned long a3, unsigned long a4, unsigned long a5,
647 struct pt_regs *regs)
648{
649 int error;
650 char * filename;
651
652 filename = getname((char __user *) a0);
653 error = PTR_ERR(filename);
654 if (IS_ERR(filename))
655 goto out;
656 preempt_disable();
657 if (regs->msr & MSR_FP)
658 giveup_fpu(current);
659#ifdef CONFIG_ALTIVEC
660 if (regs->msr & MSR_VEC)
661 giveup_altivec(current);
662#endif /* CONFIG_ALTIVEC */
663#ifdef CONFIG_SPE
664 if (regs->msr & MSR_SPE)
665 giveup_spe(current);
666#endif /* CONFIG_SPE */
667 preempt_enable();
668 error = do_execve(filename, (char __user *__user *) a1,
669 (char __user *__user *) a2, regs);
670 if (error == 0) {
671 task_lock(current);
672 current->ptrace &= ~PT_DTRACE;
673 task_unlock(current);
674 }
675 putname(filename);
676out:
677 return error;
678}
679
680void dump_stack(void)
681{
682 show_stack(current, NULL);
683}
684
685EXPORT_SYMBOL(dump_stack);
686
687void show_stack(struct task_struct *tsk, unsigned long *stack)
688{
689 unsigned long sp, stack_top, prev_sp, ret;
690 int count = 0;
691 unsigned long next_exc = 0;
692 struct pt_regs *regs;
693 extern char ret_from_except, ret_from_except_full, ret_from_syscall;
694
695 sp = (unsigned long) stack;
696 if (tsk == NULL)
697 tsk = current;
698 if (sp == 0) {
699 if (tsk == current)
700 asm("mr %0,1" : "=r" (sp));
701 else
702 sp = tsk->thread.ksp;
703 }
704
705 prev_sp = (unsigned long) (tsk->thread_info + 1);
706 stack_top = (unsigned long) tsk->thread_info + THREAD_SIZE;
707 while (count < 16 && sp > prev_sp && sp < stack_top && (sp & 3) == 0) {
708 if (count == 0) {
709 printk("Call trace:");
710#ifdef CONFIG_KALLSYMS
711 printk("\n");
712#endif
713 } else {
714 if (next_exc) {
715 ret = next_exc;
716 next_exc = 0;
717 } else
718 ret = *(unsigned long *)(sp + 4);
719 printk(" [%08lx] ", ret);
720#ifdef CONFIG_KALLSYMS
721 print_symbol("%s", ret);
722 printk("\n");
723#endif
724 if (ret == (unsigned long) &ret_from_except
725 || ret == (unsigned long) &ret_from_except_full
726 || ret == (unsigned long) &ret_from_syscall) {
727 /* sp + 16 points to an exception frame */
728 regs = (struct pt_regs *) (sp + 16);
729 if (sp + 16 + sizeof(*regs) <= stack_top)
730 next_exc = regs->nip;
731 }
732 }
733 ++count;
734 sp = *(unsigned long *)sp;
735 }
736#ifndef CONFIG_KALLSYMS
737 if (count > 0)
738 printk("\n");
739#endif
740}
741
742#if 0
743/*
744 * Low level print for debugging - Cort
745 */
746int __init ll_printk(const char *fmt, ...)
747{
748 va_list args;
749 char buf[256];
750 int i;
751
752 va_start(args, fmt);
753 i=vsprintf(buf,fmt,args);
754 ll_puts(buf);
755 va_end(args);
756 return i;
757}
758
759int lines = 24, cols = 80;
760int orig_x = 0, orig_y = 0;
761
762void puthex(unsigned long val)
763{
764 unsigned char buf[10];
765 int i;
766 for (i = 7; i >= 0; i--)
767 {
768 buf[i] = "0123456789ABCDEF"[val & 0x0F];
769 val >>= 4;
770 }
771 buf[8] = '\0';
772 prom_print(buf);
773}
774
775void __init ll_puts(const char *s)
776{
777 int x,y;
778 char *vidmem = (char *)/*(_ISA_MEM_BASE + 0xB8000) */0xD00B8000;
779 char c;
780 extern int mem_init_done;
781
782 if ( mem_init_done ) /* assume this means we can printk */
783 {
784 printk(s);
785 return;
786 }
787
788#if 0
789 if ( have_of )
790 {
791 prom_print(s);
792 return;
793 }
794#endif
795
796 /*
797 * can't ll_puts on chrp without openfirmware yet.
798 * vidmem just needs to be setup for it.
799 * -- Cort
800 */
801 if ( _machine != _MACH_prep )
802 return;
803 x = orig_x;
804 y = orig_y;
805
806 while ( ( c = *s++ ) != '\0' ) {
807 if ( c == '\n' ) {
808 x = 0;
809 if ( ++y >= lines ) {
810 /*scroll();*/
811 /*y--;*/
812 y = 0;
813 }
814 } else {
815 vidmem [ ( x + cols * y ) * 2 ] = c;
816 if ( ++x >= cols ) {
817 x = 0;
818 if ( ++y >= lines ) {
819 /*scroll();*/
820 /*y--;*/
821 y = 0;
822 }
823 }
824 }
825 }
826
827 orig_x = x;
828 orig_y = y;
829}
830#endif
831
832unsigned long get_wchan(struct task_struct *p)
833{
834 unsigned long ip, sp;
835 unsigned long stack_page = (unsigned long) p->thread_info;
836 int count = 0;
837 if (!p || p == current || p->state == TASK_RUNNING)
838 return 0;
839 sp = p->thread.ksp;
840 do {
841 sp = *(unsigned long *)sp;
842 if (sp < stack_page || sp >= stack_page + 8188)
843 return 0;
844 if (count > 0) {
845 ip = *(unsigned long *)(sp + 4);
846 if (!in_sched_functions(ip))
847 return ip;
848 }
849 } while (count++ < 16);
850 return 0;
851}
diff --git a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
index becbfa397556..e55cdda6149a 100644
--- a/arch/ppc/kernel/smp.c
+++ b/arch/ppc/kernel/smp.c
@@ -318,7 +318,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
318 p = fork_idle(cpu); 318 p = fork_idle(cpu);
319 if (IS_ERR(p)) 319 if (IS_ERR(p))
320 panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p)); 320 panic("failed fork for CPU %u: %li", cpu, PTR_ERR(p));
321 p->thread_info->cpu = cpu; 321 task_thread_info(p)->cpu = cpu;
322 idle_tasks[cpu] = p; 322 idle_tasks[cpu] = p;
323 } 323 }
324} 324}
@@ -369,7 +369,7 @@ int __cpu_up(unsigned int cpu)
369 char buf[32]; 369 char buf[32];
370 int c; 370 int c;
371 371
372 secondary_ti = idle_tasks[cpu]->thread_info; 372 secondary_ti = task_thread_info(idle_tasks[cpu]);
373 mb(); 373 mb();
374 374
375 /* 375 /*
diff --git a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c
index 2f74fde98ebc..c42c50073da5 100644
--- a/arch/ppc/platforms/apus_setup.c
+++ b/arch/ppc/platforms/apus_setup.c
@@ -55,9 +55,6 @@ int (*mach_hwclk) (int, struct hwclk_time*) = NULL;
55int (*mach_set_clock_mmss) (unsigned long) = NULL; 55int (*mach_set_clock_mmss) (unsigned long) = NULL;
56void (*mach_reset)( void ); 56void (*mach_reset)( void );
57long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */ 57long mach_max_dma_address = 0x00ffffff; /* default set to the lower 16MB */
58#if defined(CONFIG_AMIGA_FLOPPY)
59void (*mach_floppy_setup) (char *, int *) __initdata = NULL;
60#endif
61#ifdef CONFIG_HEARTBEAT 58#ifdef CONFIG_HEARTBEAT
62void (*mach_heartbeat) (int) = NULL; 59void (*mach_heartbeat) (int) = NULL;
63extern void apus_heartbeat (void); 60extern void apus_heartbeat (void);
@@ -76,7 +73,6 @@ struct mem_info m68k_memory[NUM_MEMINFO];/* memory description */
76 73
77struct mem_info ramdisk; 74struct mem_info ramdisk;
78 75
79extern void amiga_floppy_setup(char *, int *);
80extern void config_amiga(void); 76extern void config_amiga(void);
81 77
82static int __60nsram = 0; 78static int __60nsram = 0;
@@ -305,16 +301,6 @@ void kbd_reset_setup(char *str, int *ints)
305{ 301{
306} 302}
307 303
308/*********************************************************** FLOPPY */
309#if defined(CONFIG_AMIGA_FLOPPY)
310__init
311void floppy_setup(char *str, int *ints)
312{
313 if (mach_floppy_setup)
314 mach_floppy_setup (str, ints);
315}
316#endif
317
318/*********************************************************** MEMORY */ 304/*********************************************************** MEMORY */
319#define KMAP_MAX 32 305#define KMAP_MAX 32
320unsigned long kmap_chunks[KMAP_MAX*3]; 306unsigned long kmap_chunks[KMAP_MAX*3];
@@ -574,9 +560,9 @@ static __inline__ void ser_RTSon(void)
574 560
575int __debug_ser_out( unsigned char c ) 561int __debug_ser_out( unsigned char c )
576{ 562{
577 custom.serdat = c | 0x100; 563 amiga_custom.serdat = c | 0x100;
578 mb(); 564 mb();
579 while (!(custom.serdatr & 0x2000)) 565 while (!(amiga_custom.serdatr & 0x2000))
580 barrier(); 566 barrier();
581 return 1; 567 return 1;
582} 568}
@@ -586,11 +572,11 @@ unsigned char __debug_ser_in( void )
586 unsigned char c; 572 unsigned char c;
587 573
588 /* XXX: is that ok?? derived from amiga_ser.c... */ 574 /* XXX: is that ok?? derived from amiga_ser.c... */
589 while( !(custom.intreqr & IF_RBF) ) 575 while( !(amiga_custom.intreqr & IF_RBF) )
590 barrier(); 576 barrier();
591 c = custom.serdatr; 577 c = amiga_custom.serdatr;
592 /* clear the interrupt, so that another character can be read */ 578 /* clear the interrupt, so that another character can be read */
593 custom.intreq = IF_RBF; 579 amiga_custom.intreq = IF_RBF;
594 return c; 580 return c;
595} 581}
596 582
@@ -601,10 +587,10 @@ int __debug_serinit( void )
601 local_irq_save(flags); 587 local_irq_save(flags);
602 588
603 /* turn off Rx and Tx interrupts */ 589 /* turn off Rx and Tx interrupts */
604 custom.intena = IF_RBF | IF_TBE; 590 amiga_custom.intena = IF_RBF | IF_TBE;
605 591
606 /* clear any pending interrupt */ 592 /* clear any pending interrupt */
607 custom.intreq = IF_RBF | IF_TBE; 593 amiga_custom.intreq = IF_RBF | IF_TBE;
608 594
609 local_irq_restore(flags); 595 local_irq_restore(flags);
610 596
@@ -617,7 +603,7 @@ int __debug_serinit( void )
617 603
618#ifdef CONFIG_KGDB 604#ifdef CONFIG_KGDB
619 /* turn Rx interrupts on for GDB */ 605 /* turn Rx interrupts on for GDB */
620 custom.intena = IF_SETCLR | IF_RBF; 606 amiga_custom.intena = IF_SETCLR | IF_RBF;
621 ser_RTSon(); 607 ser_RTSon();
622#endif 608#endif
623 609
diff --git a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
index 2b483b4f1602..9075a7538e26 100644
--- a/arch/ppc/xmon/xmon.c
+++ b/arch/ppc/xmon/xmon.c
@@ -99,7 +99,7 @@ static void remove_bpts(void);
99static void insert_bpts(void); 99static void insert_bpts(void);
100static struct bpt *at_breakpoint(unsigned pc); 100static struct bpt *at_breakpoint(unsigned pc);
101static void bpt_cmds(void); 101static void bpt_cmds(void);
102static void cacheflush(void); 102void cacheflush(void);
103#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
104static void cpu_cmd(void); 104static void cpu_cmd(void);
105#endif /* CONFIG_SMP */ 105#endif /* CONFIG_SMP */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 6fe532d82417..b66602ad7b33 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -27,11 +27,6 @@ config S390
27 bool 27 bool
28 default y 28 default y
29 29
30config UID16
31 bool
32 default y
33 depends on !64BIT
34
35source "init/Kconfig" 30source "init/Kconfig"
36 31
37menu "Base setup" 32menu "Base setup"
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 4865e4b49464..9269b5788fac 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -17,8 +17,7 @@ obj-$(CONFIG_MODULES) += s390_ksyms.o module.o
17obj-$(CONFIG_SMP) += smp.o 17obj-$(CONFIG_SMP) += smp.o
18 18
19obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \ 19obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \
20 compat_ioctl.o compat_wrapper.o \ 20 compat_wrapper.o compat_exec_domain.o
21 compat_exec_domain.o
22obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o 21obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o
23 22
24obj-$(CONFIG_VIRT_TIMER) += vtime.o 23obj-$(CONFIG_VIRT_TIMER) += vtime.o
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
index 03ba5893f17b..1f451c2cb071 100644
--- a/arch/s390/kernel/binfmt_elf32.c
+++ b/arch/s390/kernel/binfmt_elf32.c
@@ -112,7 +112,7 @@ static inline int dump_regs32(struct pt_regs *ptregs, elf_gregset_t *regs)
112 112
113static inline int dump_task_regs32(struct task_struct *tsk, elf_gregset_t *regs) 113static inline int dump_task_regs32(struct task_struct *tsk, elf_gregset_t *regs)
114{ 114{
115 struct pt_regs *ptregs = __KSTK_PTREGS(tsk); 115 struct pt_regs *ptregs = task_pt_regs(tsk);
116 int i; 116 int i;
117 117
118 memcpy(&regs->psw.mask, &ptregs->psw.mask, 4); 118 memcpy(&regs->psw.mask, &ptregs->psw.mask, 4);
diff --git a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
deleted file mode 100644
index 6504c4e69986..000000000000
--- a/arch/s390/kernel/compat_ioctl.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * S390 version
5 * Copyright (C) 2000-2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Gerhard Tonn (ton@de.ibm.com)
7 * Arnd Bergmann (arndb@de.ibm.com)
8 *
9 * Original implementation from 32-bit Sparc compat code which is
10 * Copyright (C) 2000 Silicon Graphics, Inc.
11 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
12 */
13
14#include "compat_linux.h"
15#define INCLUDES
16#define CODE
17#include "../../../fs/compat_ioctl.c"
18#include <asm/dasd.h>
19#include <asm/cmb.h>
20#include <asm/tape390.h>
21#include <asm/ccwdev.h>
22#include "../../../drivers/s390/char/raw3270.h"
23
24static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
25 unsigned long arg, struct file *f)
26{
27 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));
28}
29
30static int do_ioctl32_ulong(unsigned int fd, unsigned int cmd,
31 unsigned long arg, struct file *f)
32{
33 return sys_ioctl(fd, cmd, arg);
34}
35
36#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_pointer)
37#define ULONG_IOCTL(cmd) HANDLE_IOCTL((cmd),(ioctl_trans_handler_t)do_ioctl32_ulong)
38#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
39
40struct ioctl_trans ioctl_start[] = {
41/* architecture independent ioctls */
42#include <linux/compat_ioctl.h>
43#define DECLARES
44#include "../../../fs/compat_ioctl.c"
45
46/* s390 only ioctls */
47COMPATIBLE_IOCTL(DASDAPIVER)
48COMPATIBLE_IOCTL(BIODASDDISABLE)
49COMPATIBLE_IOCTL(BIODASDENABLE)
50COMPATIBLE_IOCTL(BIODASDRSRV)
51COMPATIBLE_IOCTL(BIODASDRLSE)
52COMPATIBLE_IOCTL(BIODASDSLCK)
53COMPATIBLE_IOCTL(BIODASDINFO)
54COMPATIBLE_IOCTL(BIODASDINFO2)
55COMPATIBLE_IOCTL(BIODASDFMT)
56COMPATIBLE_IOCTL(BIODASDPRRST)
57COMPATIBLE_IOCTL(BIODASDQUIESCE)
58COMPATIBLE_IOCTL(BIODASDRESUME)
59COMPATIBLE_IOCTL(BIODASDPRRD)
60COMPATIBLE_IOCTL(BIODASDPSRD)
61COMPATIBLE_IOCTL(BIODASDGATTR)
62COMPATIBLE_IOCTL(BIODASDSATTR)
63COMPATIBLE_IOCTL(BIODASDCMFENABLE)
64COMPATIBLE_IOCTL(BIODASDCMFDISABLE)
65COMPATIBLE_IOCTL(BIODASDREADALLCMB)
66
67COMPATIBLE_IOCTL(TUBICMD)
68COMPATIBLE_IOCTL(TUBOCMD)
69COMPATIBLE_IOCTL(TUBGETI)
70COMPATIBLE_IOCTL(TUBGETO)
71COMPATIBLE_IOCTL(TUBSETMOD)
72COMPATIBLE_IOCTL(TUBGETMOD)
73
74COMPATIBLE_IOCTL(TAPE390_DISPLAY)
75
76/* s390 doesn't need handlers here */
77COMPATIBLE_IOCTL(TIOCGSERIAL)
78COMPATIBLE_IOCTL(TIOCSSERIAL)
79};
80
81int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 41b197a3f3a3..bf9a7a361b34 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -55,6 +55,7 @@
55#include <linux/syscalls.h> 55#include <linux/syscalls.h>
56#include <linux/sysctl.h> 56#include <linux/sysctl.h>
57#include <linux/binfmts.h> 57#include <linux/binfmts.h>
58#include <linux/capability.h>
58#include <linux/compat.h> 59#include <linux/compat.h>
59#include <linux/vfs.h> 60#include <linux/vfs.h>
60#include <linux/ptrace.h> 61#include <linux/ptrace.h>
@@ -1014,38 +1015,6 @@ asmlinkage long sys32_clone(struct pt_regs regs)
1014} 1015}
1015 1016
1016/* 1017/*
1017 * Wrapper function for sys_timer_create.
1018 */
1019extern asmlinkage long
1020sys_timer_create(clockid_t, struct sigevent *, timer_t *);
1021
1022asmlinkage long
1023sys32_timer_create(clockid_t which_clock, struct compat_sigevent *se32,
1024 timer_t *timer_id)
1025{
1026 struct sigevent se;
1027 timer_t ktimer_id;
1028 mm_segment_t old_fs;
1029 long ret;
1030
1031 if (se32 == NULL)
1032 return sys_timer_create(which_clock, NULL, timer_id);
1033
1034 if (get_compat_sigevent(&se, se32))
1035 return -EFAULT;
1036
1037 old_fs = get_fs();
1038 set_fs(KERNEL_DS);
1039 ret = sys_timer_create(which_clock, &se, &ktimer_id);
1040 set_fs(old_fs);
1041
1042 if (!ret)
1043 ret = put_user (ktimer_id, timer_id);
1044
1045 return ret;
1046}
1047
1048/*
1049 * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64. 1018 * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64.
1050 * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE} 1019 * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE}
1051 * because the 31 bit values differ from the 64 bit values. 1020 * because the 31 bit values differ from the 64 bit values.
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 23fe94e58688..cfde1905d07d 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1289,7 +1289,7 @@ sys32_timer_create_wrapper:
1289 lgfr %r2,%r2 # timer_t (int) 1289 lgfr %r2,%r2 # timer_t (int)
1290 llgtr %r3,%r3 # struct compat_sigevent * 1290 llgtr %r3,%r3 # struct compat_sigevent *
1291 llgtr %r4,%r4 # timer_t * 1291 llgtr %r4,%r4 # timer_t *
1292 jg sys32_timer_create 1292 jg compat_sys_timer_create
1293 1293
1294 .globl sys32_timer_settime_wrapper 1294 .globl sys32_timer_settime_wrapper
1295sys32_timer_settime_wrapper: 1295sys32_timer_settime_wrapper:
diff --git a/arch/s390/kernel/crash.c b/arch/s390/kernel/crash.c
index 7bd169c58b0c..926cceeae0fa 100644
--- a/arch/s390/kernel/crash.c
+++ b/arch/s390/kernel/crash.c
@@ -10,8 +10,6 @@
10#include <linux/threads.h> 10#include <linux/threads.h>
11#include <linux/kexec.h> 11#include <linux/kexec.h>
12 12
13note_buf_t crash_notes[NR_CPUS];
14
15void machine_crash_shutdown(struct pt_regs *regs) 13void machine_crash_shutdown(struct pt_regs *regs)
16{ 14{
17} 15}
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index a942bf2d58e9..2ff90a1a1056 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -153,7 +153,7 @@ void show_regs(struct pt_regs *regs)
153{ 153{
154 struct task_struct *tsk = current; 154 struct task_struct *tsk = current;
155 155
156 printk("CPU: %d %s\n", tsk->thread_info->cpu, print_tainted()); 156 printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted());
157 printk("Process %s (pid: %d, task: %p, ksp: %p)\n", 157 printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
158 current->comm, current->pid, (void *) tsk, 158 current->comm, current->pid, (void *) tsk,
159 (void *) tsk->thread.ksp); 159 (void *) tsk->thread.ksp);
@@ -217,8 +217,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long new_stackp,
217 struct pt_regs childregs; 217 struct pt_regs childregs;
218 } *frame; 218 } *frame;
219 219
220 frame = ((struct fake_frame *) 220 frame = container_of(task_pt_regs(p), struct fake_frame, childregs);
221 (THREAD_SIZE + (unsigned long) p->thread_info)) - 1;
222 p->thread.ksp = (unsigned long) frame; 221 p->thread.ksp = (unsigned long) frame;
223 /* Store access registers to kernel stack of new process. */ 222 /* Store access registers to kernel stack of new process. */
224 frame->childregs = *regs; 223 frame->childregs = *regs;
@@ -352,38 +351,16 @@ int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs)
352 return 1; 351 return 1;
353} 352}
354 353
355/*
356 * fill in the user structure for a core dump..
357 */
358void dump_thread(struct pt_regs * regs, struct user * dump)
359{
360
361/* changed the size calculations - should hopefully work better. lbt */
362 dump->magic = CMAGIC;
363 dump->start_code = 0;
364 dump->start_stack = regs->gprs[15] & ~(PAGE_SIZE - 1);
365 dump->u_tsize = current->mm->end_code >> PAGE_SHIFT;
366 dump->u_dsize = (current->mm->brk + PAGE_SIZE - 1) >> PAGE_SHIFT;
367 dump->u_dsize -= dump->u_tsize;
368 dump->u_ssize = 0;
369 if (dump->start_stack < TASK_SIZE)
370 dump->u_ssize = (TASK_SIZE - dump->start_stack) >> PAGE_SHIFT;
371 memcpy(&dump->regs, regs, sizeof(s390_regs));
372 dump_fpu (regs, &dump->regs.fp_regs);
373 dump->regs.per_info = current->thread.per_info;
374}
375
376unsigned long get_wchan(struct task_struct *p) 354unsigned long get_wchan(struct task_struct *p)
377{ 355{
378 struct stack_frame *sf, *low, *high; 356 struct stack_frame *sf, *low, *high;
379 unsigned long return_address; 357 unsigned long return_address;
380 int count; 358 int count;
381 359
382 if (!p || p == current || p->state == TASK_RUNNING || !p->thread_info) 360 if (!p || p == current || p->state == TASK_RUNNING || !task_stack_page(p))
383 return 0; 361 return 0;
384 low = (struct stack_frame *) p->thread_info; 362 low = task_stack_page(p);
385 high = (struct stack_frame *) 363 high = (struct stack_frame *) task_pt_regs(p);
386 ((unsigned long) p->thread_info + THREAD_SIZE) - 1;
387 sf = (struct stack_frame *) (p->thread.ksp & PSW_ADDR_INSN); 364 sf = (struct stack_frame *) (p->thread.ksp & PSW_ADDR_INSN);
388 if (sf <= low || sf > high) 365 if (sf <= low || sf > high)
389 return 0; 366 return 0;
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index cc02232aa96e..37dfe33dab73 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -52,7 +52,7 @@ FixPerRegisters(struct task_struct *task)
52 struct pt_regs *regs; 52 struct pt_regs *regs;
53 per_struct *per_info; 53 per_struct *per_info;
54 54
55 regs = __KSTK_PTREGS(task); 55 regs = task_pt_regs(task);
56 per_info = (per_struct *) &task->thread.per_info; 56 per_info = (per_struct *) &task->thread.per_info;
57 per_info->control_regs.bits.em_instruction_fetch = 57 per_info->control_regs.bits.em_instruction_fetch =
58 per_info->single_step | per_info->instruction_fetch; 58 per_info->single_step | per_info->instruction_fetch;
@@ -150,7 +150,7 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data)
150 /* 150 /*
151 * psw and gprs are stored on the stack 151 * psw and gprs are stored on the stack
152 */ 152 */
153 tmp = *(addr_t *)((addr_t) &__KSTK_PTREGS(child)->psw + addr); 153 tmp = *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr);
154 if (addr == (addr_t) &dummy->regs.psw.mask) 154 if (addr == (addr_t) &dummy->regs.psw.mask)
155 /* Remove per bit from user psw. */ 155 /* Remove per bit from user psw. */
156 tmp &= ~PSW_MASK_PER; 156 tmp &= ~PSW_MASK_PER;
@@ -176,7 +176,7 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data)
176 /* 176 /*
177 * orig_gpr2 is stored on the kernel stack 177 * orig_gpr2 is stored on the kernel stack
178 */ 178 */
179 tmp = (addr_t) __KSTK_PTREGS(child)->orig_gpr2; 179 tmp = (addr_t) task_pt_regs(child)->orig_gpr2;
180 180
181 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) { 181 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
182 /* 182 /*
@@ -243,7 +243,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)
243 high order bit but older gdb's rely on it */ 243 high order bit but older gdb's rely on it */
244 data |= PSW_ADDR_AMODE; 244 data |= PSW_ADDR_AMODE;
245#endif 245#endif
246 *(addr_t *)((addr_t) &__KSTK_PTREGS(child)->psw + addr) = data; 246 *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data;
247 247
248 } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) { 248 } else if (addr < (addr_t) (&dummy->regs.orig_gpr2)) {
249 /* 249 /*
@@ -267,7 +267,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)
267 /* 267 /*
268 * orig_gpr2 is stored on the kernel stack 268 * orig_gpr2 is stored on the kernel stack
269 */ 269 */
270 __KSTK_PTREGS(child)->orig_gpr2 = data; 270 task_pt_regs(child)->orig_gpr2 = data;
271 271
272 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) { 272 } else if (addr < (addr_t) (&dummy->regs.fp_regs + 1)) {
273 /* 273 /*
@@ -393,15 +393,15 @@ peek_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
393 */ 393 */
394 if (addr == (addr_t) &dummy32->regs.psw.mask) { 394 if (addr == (addr_t) &dummy32->regs.psw.mask) {
395 /* Fake a 31 bit psw mask. */ 395 /* Fake a 31 bit psw mask. */
396 tmp = (__u32)(__KSTK_PTREGS(child)->psw.mask >> 32); 396 tmp = (__u32)(task_pt_regs(child)->psw.mask >> 32);
397 tmp = PSW32_MASK_MERGE(PSW32_USER_BITS, tmp); 397 tmp = PSW32_MASK_MERGE(PSW32_USER_BITS, tmp);
398 } else if (addr == (addr_t) &dummy32->regs.psw.addr) { 398 } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
399 /* Fake a 31 bit psw address. */ 399 /* Fake a 31 bit psw address. */
400 tmp = (__u32) __KSTK_PTREGS(child)->psw.addr | 400 tmp = (__u32) task_pt_regs(child)->psw.addr |
401 PSW32_ADDR_AMODE31; 401 PSW32_ADDR_AMODE31;
402 } else { 402 } else {
403 /* gpr 0-15 */ 403 /* gpr 0-15 */
404 tmp = *(__u32 *)((addr_t) &__KSTK_PTREGS(child)->psw + 404 tmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw +
405 addr*2 + 4); 405 addr*2 + 4);
406 } 406 }
407 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { 407 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
@@ -415,7 +415,7 @@ peek_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
415 /* 415 /*
416 * orig_gpr2 is stored on the kernel stack 416 * orig_gpr2 is stored on the kernel stack
417 */ 417 */
418 tmp = *(__u32*)((addr_t) &__KSTK_PTREGS(child)->orig_gpr2 + 4); 418 tmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4);
419 419
420 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { 420 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
421 /* 421 /*
@@ -472,15 +472,15 @@ poke_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
472 if (tmp != PSW32_MASK_MERGE(PSW32_USER_BITS, tmp)) 472 if (tmp != PSW32_MASK_MERGE(PSW32_USER_BITS, tmp))
473 /* Invalid psw mask. */ 473 /* Invalid psw mask. */
474 return -EINVAL; 474 return -EINVAL;
475 __KSTK_PTREGS(child)->psw.mask = 475 task_pt_regs(child)->psw.mask =
476 PSW_MASK_MERGE(PSW_USER32_BITS, (__u64) tmp << 32); 476 PSW_MASK_MERGE(PSW_USER32_BITS, (__u64) tmp << 32);
477 } else if (addr == (addr_t) &dummy32->regs.psw.addr) { 477 } else if (addr == (addr_t) &dummy32->regs.psw.addr) {
478 /* Build a 64 bit psw address from 31 bit address. */ 478 /* Build a 64 bit psw address from 31 bit address. */
479 __KSTK_PTREGS(child)->psw.addr = 479 task_pt_regs(child)->psw.addr =
480 (__u64) tmp & PSW32_ADDR_INSN; 480 (__u64) tmp & PSW32_ADDR_INSN;
481 } else { 481 } else {
482 /* gpr 0-15 */ 482 /* gpr 0-15 */
483 *(__u32*)((addr_t) &__KSTK_PTREGS(child)->psw 483 *(__u32*)((addr_t) &task_pt_regs(child)->psw
484 + addr*2 + 4) = tmp; 484 + addr*2 + 4) = tmp;
485 } 485 }
486 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) { 486 } else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {
@@ -494,7 +494,7 @@ poke_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
494 /* 494 /*
495 * orig_gpr2 is stored on the kernel stack 495 * orig_gpr2 is stored on the kernel stack
496 */ 496 */
497 *(__u32*)((addr_t) &__KSTK_PTREGS(child)->orig_gpr2 + 4) = tmp; 497 *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4) = tmp;
498 498
499 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) { 499 } else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {
500 /* 500 /*
diff --git a/arch/s390/kernel/s390_ksyms.c b/arch/s390/kernel/s390_ksyms.c
index bee654abb6d3..4176c77670c4 100644
--- a/arch/s390/kernel/s390_ksyms.c
+++ b/arch/s390/kernel/s390_ksyms.c
@@ -10,7 +10,6 @@
10#include <linux/smp.h> 10#include <linux/smp.h>
11#include <linux/syscalls.h> 11#include <linux/syscalls.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/ioctl32.h>
14#include <asm/checksum.h> 13#include <asm/checksum.h>
15#include <asm/cpcmd.h> 14#include <asm/cpcmd.h>
16#include <asm/delay.h> 15#include <asm/delay.h>
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index e10f4ca00499..cbfcfd02a43a 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -657,7 +657,7 @@ __cpu_up(unsigned int cpu)
657 idle = current_set[cpu]; 657 idle = current_set[cpu];
658 cpu_lowcore = lowcore_ptr[cpu]; 658 cpu_lowcore = lowcore_ptr[cpu];
659 cpu_lowcore->kernel_stack = (unsigned long) 659 cpu_lowcore->kernel_stack = (unsigned long)
660 idle->thread_info + (THREAD_SIZE); 660 task_stack_page(idle) + (THREAD_SIZE);
661 sf = (struct stack_frame *) (cpu_lowcore->kernel_stack 661 sf = (struct stack_frame *) (cpu_lowcore->kernel_stack
662 - sizeof(struct pt_regs) 662 - sizeof(struct pt_regs)
663 - sizeof(struct stack_frame)); 663 - sizeof(struct stack_frame));
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index c36353e8c140..b0d8ca8e5eeb 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -282,7 +282,7 @@ static inline void start_hz_timer(void)
282{ 282{
283 if (!cpu_isset(smp_processor_id(), nohz_cpu_mask)) 283 if (!cpu_isset(smp_processor_id(), nohz_cpu_mask))
284 return; 284 return;
285 account_ticks(__KSTK_PTREGS(current)); 285 account_ticks(task_pt_regs(current));
286 cpu_clear(smp_processor_id(), nohz_cpu_mask); 286 cpu_clear(smp_processor_id(), nohz_cpu_mask);
287} 287}
288 288
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 95d109968619..5d21e9e6e7b4 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -136,8 +136,8 @@ void show_trace(struct task_struct *task, unsigned long * stack)
136 sp = __show_trace(sp, S390_lowcore.async_stack - ASYNC_SIZE, 136 sp = __show_trace(sp, S390_lowcore.async_stack - ASYNC_SIZE,
137 S390_lowcore.async_stack); 137 S390_lowcore.async_stack);
138 if (task) 138 if (task)
139 __show_trace(sp, (unsigned long) task->thread_info, 139 __show_trace(sp, (unsigned long) task_stack_page(task),
140 (unsigned long) task->thread_info + THREAD_SIZE); 140 (unsigned long) task_stack_page(task) + THREAD_SIZE);
141 else 141 else
142 __show_trace(sp, S390_lowcore.thread_info, 142 __show_trace(sp, S390_lowcore.thread_info,
143 S390_lowcore.thread_info + THREAD_SIZE); 143 S390_lowcore.thread_info + THREAD_SIZE);
@@ -240,7 +240,7 @@ char *task_show_regs(struct task_struct *task, char *buffer)
240{ 240{
241 struct pt_regs *regs; 241 struct pt_regs *regs;
242 242
243 regs = __KSTK_PTREGS(task); 243 regs = task_pt_regs(task);
244 buffer += sprintf(buffer, "task: %p, ksp: %p\n", 244 buffer += sprintf(buffer, "task: %p, ksp: %p\n",
245 task, (void *)task->thread.ksp); 245 task, (void *)task->thread.ksp);
246 buffer += sprintf(buffer, "User PSW : %p %p\n", 246 buffer += sprintf(buffer, "User PSW : %p %p\n",
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index fd4f240b833d..aac15e42d03b 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -191,13 +191,8 @@ void flush_thread(void)
191{ 191{
192#if defined(CONFIG_SH_FPU) 192#if defined(CONFIG_SH_FPU)
193 struct task_struct *tsk = current; 193 struct task_struct *tsk = current;
194 struct pt_regs *regs = (struct pt_regs *)
195 ((unsigned long)tsk->thread_info
196 + THREAD_SIZE - sizeof(struct pt_regs)
197 - sizeof(unsigned long));
198
199 /* Forget lazy FPU state */ 194 /* Forget lazy FPU state */
200 clear_fpu(tsk, regs); 195 clear_fpu(tsk, task_pt_regs(tsk));
201 clear_used_math(); 196 clear_used_math();
202#endif 197#endif
203} 198}
@@ -232,13 +227,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
232{ 227{
233 struct pt_regs ptregs; 228 struct pt_regs ptregs;
234 229
235 ptregs = *(struct pt_regs *) 230 ptregs = *task_pt_regs(tsk);
236 ((unsigned long)tsk->thread_info + THREAD_SIZE
237 - sizeof(struct pt_regs)
238#ifdef CONFIG_SH_DSP
239 - sizeof(struct pt_dspregs)
240#endif
241 - sizeof(unsigned long));
242 elf_core_copy_regs(regs, &ptregs); 231 elf_core_copy_regs(regs, &ptregs);
243 232
244 return 1; 233 return 1;
@@ -252,11 +241,7 @@ dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *fpu)
252#if defined(CONFIG_SH_FPU) 241#if defined(CONFIG_SH_FPU)
253 fpvalid = !!tsk_used_math(tsk); 242 fpvalid = !!tsk_used_math(tsk);
254 if (fpvalid) { 243 if (fpvalid) {
255 struct pt_regs *regs = (struct pt_regs *) 244 unlazy_fpu(tsk, task_pt_regs(tsk));
256 ((unsigned long)tsk->thread_info
257 + THREAD_SIZE - sizeof(struct pt_regs)
258 - sizeof(unsigned long));
259 unlazy_fpu(tsk, regs);
260 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu)); 245 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
261 } 246 }
262#endif 247#endif
@@ -279,18 +264,13 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
279 copy_to_stopped_child_used_math(p); 264 copy_to_stopped_child_used_math(p);
280#endif 265#endif
281 266
282 childregs = ((struct pt_regs *) 267 childregs = task_pt_regs(p);
283 (THREAD_SIZE + (unsigned long) p->thread_info)
284#ifdef CONFIG_SH_DSP
285 - sizeof(struct pt_dspregs)
286#endif
287 - sizeof(unsigned long)) - 1;
288 *childregs = *regs; 268 *childregs = *regs;
289 269
290 if (user_mode(regs)) { 270 if (user_mode(regs)) {
291 childregs->regs[15] = usp; 271 childregs->regs[15] = usp;
292 } else { 272 } else {
293 childregs->regs[15] = (unsigned long)p->thread_info + THREAD_SIZE; 273 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
294 } 274 }
295 if (clone_flags & CLONE_SETTLS) { 275 if (clone_flags & CLONE_SETTLS) {
296 childregs->gbr = childregs->regs[0]; 276 childregs->gbr = childregs->regs[0];
@@ -305,26 +285,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
305 return 0; 285 return 0;
306} 286}
307 287
308/*
309 * fill in the user structure for a core dump..
310 */
311void dump_thread(struct pt_regs * regs, struct user * dump)
312{
313 dump->magic = CMAGIC;
314 dump->start_code = current->mm->start_code;
315 dump->start_data = current->mm->start_data;
316 dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1);
317 dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT;
318 dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT;
319 dump->u_ssize = (current->mm->start_stack - dump->start_stack +
320 PAGE_SIZE - 1) >> PAGE_SHIFT;
321 /* Debug registers will come here. */
322
323 dump->regs = *regs;
324
325 dump->u_fpvalid = dump_fpu(regs, &dump->fpu);
326}
327
328/* Tracing by user break controller. */ 288/* Tracing by user break controller. */
329static void 289static void
330ubc_set_tracing(int asid, unsigned long pc) 290ubc_set_tracing(int asid, unsigned long pc)
@@ -353,11 +313,7 @@ ubc_set_tracing(int asid, unsigned long pc)
353struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next) 313struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next)
354{ 314{
355#if defined(CONFIG_SH_FPU) 315#if defined(CONFIG_SH_FPU)
356 struct pt_regs *regs = (struct pt_regs *) 316 unlazy_fpu(prev, task_pt_regs(prev));
357 ((unsigned long)prev->thread_info
358 + THREAD_SIZE - sizeof(struct pt_regs)
359 - sizeof(unsigned long));
360 unlazy_fpu(prev, regs);
361#endif 317#endif
362 318
363#ifdef CONFIG_PREEMPT 319#ifdef CONFIG_PREEMPT
@@ -366,13 +322,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
366 struct pt_regs *regs; 322 struct pt_regs *regs;
367 323
368 local_irq_save(flags); 324 local_irq_save(flags);
369 regs = (struct pt_regs *) 325 regs = task_pt_regs(prev);
370 ((unsigned long)prev->thread_info
371 + THREAD_SIZE - sizeof(struct pt_regs)
372#ifdef CONFIG_SH_DSP
373 - sizeof(struct pt_dspregs)
374#endif
375 - sizeof(unsigned long));
376 if (user_mode(regs) && regs->regs[15] >= 0xc0000000) { 326 if (user_mode(regs) && regs->regs[15] >= 0xc0000000) {
377 int offset = (int)regs->regs[15]; 327 int offset = (int)regs->regs[15];
378 328
@@ -392,7 +342,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
392 */ 342 */
393 asm volatile("ldc %0, r7_bank" 343 asm volatile("ldc %0, r7_bank"
394 : /* no output */ 344 : /* no output */
395 : "r" (next->thread_info)); 345 : "r" (task_thread_info(next)));
396 346
397#ifdef CONFIG_MMU 347#ifdef CONFIG_MMU
398 /* If no tasks are using the UBC, we're done */ 348 /* If no tasks are using the UBC, we're done */
diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c
index 1a8be06519ec..3887b4f6feb2 100644
--- a/arch/sh/kernel/ptrace.c
+++ b/arch/sh/kernel/ptrace.c
@@ -41,12 +41,7 @@ static inline int get_stack_long(struct task_struct *task, int offset)
41{ 41{
42 unsigned char *stack; 42 unsigned char *stack;
43 43
44 stack = (unsigned char *) 44 stack = (unsigned char *)task_pt_regs(task);
45 task->thread_info + THREAD_SIZE - sizeof(struct pt_regs)
46#ifdef CONFIG_SH_DSP
47 - sizeof(struct pt_dspregs)
48#endif
49 - sizeof(unsigned long);
50 stack += offset; 45 stack += offset;
51 return (*((int *)stack)); 46 return (*((int *)stack));
52} 47}
@@ -59,12 +54,7 @@ static inline int put_stack_long(struct task_struct *task, int offset,
59{ 54{
60 unsigned char *stack; 55 unsigned char *stack;
61 56
62 stack = (unsigned char *) 57 stack = (unsigned char *)task_pt_regs(task);
63 task->thread_info + THREAD_SIZE - sizeof(struct pt_regs)
64#ifdef CONFIG_SH_DSP
65 - sizeof(struct pt_dspregs)
66#endif
67 - sizeof(unsigned long);
68 stack += offset; 58 stack += offset;
69 *(unsigned long *) stack = data; 59 *(unsigned long *) stack = data;
70 return 0; 60 return 0;
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 6954fd62470a..1cf94a618be3 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -21,14 +21,12 @@
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22#include <asm/checksum.h> 22#include <asm/checksum.h>
23 23
24extern void dump_thread(struct pt_regs *, struct user *);
25extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); 24extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
26extern struct hw_interrupt_type no_irq_type; 25extern struct hw_interrupt_type no_irq_type;
27 26
28EXPORT_SYMBOL(sh_mv); 27EXPORT_SYMBOL(sh_mv);
29 28
30/* platform dependent support */ 29/* platform dependent support */
31EXPORT_SYMBOL(dump_thread);
32EXPORT_SYMBOL(dump_fpu); 30EXPORT_SYMBOL(dump_fpu);
33EXPORT_SYMBOL(iounmap); 31EXPORT_SYMBOL(iounmap);
34EXPORT_SYMBOL(enable_irq); 32EXPORT_SYMBOL(enable_irq);
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 59e49b18252c..62c7d1c0ad7b 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -103,7 +103,7 @@ int __cpu_up(unsigned int cpu)
103 if (IS_ERR(tsk)) 103 if (IS_ERR(tsk))
104 panic("Failed forking idle task for cpu %d\n", cpu); 104 panic("Failed forking idle task for cpu %d\n", cpu);
105 105
106 tsk->thread_info->cpu = cpu; 106 task_thread_info(tsk)->cpu = cpu;
107 107
108 cpu_set(cpu, cpu_online_map); 108 cpu_set(cpu, cpu_online_map);
109 109
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index fb35b45dc130..07b172deb872 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -17,10 +17,6 @@ config MMU
17 bool 17 bool
18 default y 18 default y
19 19
20config UID16
21 bool
22 default y
23
24config RWSEM_GENERIC_SPINLOCK 20config RWSEM_GENERIC_SPINLOCK
25 bool 21 bool
26 default y 22 default y
diff --git a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c
index b95d04141855..1da9c61d6823 100644
--- a/arch/sh64/kernel/process.c
+++ b/arch/sh64/kernel/process.c
@@ -744,7 +744,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
744 } 744 }
745#endif 745#endif
746 /* Copy from sh version */ 746 /* Copy from sh version */
747 childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long) p->thread_info )) - 1; 747 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
748 748
749 *childregs = *regs; 749 *childregs = *regs;
750 750
@@ -752,7 +752,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
752 childregs->regs[15] = usp; 752 childregs->regs[15] = usp;
753 p->thread.uregs = childregs; 753 p->thread.uregs = childregs;
754 } else { 754 } else {
755 childregs->regs[15] = (unsigned long)p->thread_info + THREAD_SIZE; 755 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
756 } 756 }
757 757
758 childregs->regs[9] = 0; /* Set return value for child */ 758 childregs->regs[9] = 0; /* Set return value for child */
@@ -775,26 +775,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
775 return 0; 775 return 0;
776} 776}
777 777
778/*
779 * fill in the user structure for a core dump..
780 */
781void dump_thread(struct pt_regs * regs, struct user * dump)
782{
783 dump->magic = CMAGIC;
784 dump->start_code = current->mm->start_code;
785 dump->start_data = current->mm->start_data;
786 dump->start_stack = regs->regs[15] & ~(PAGE_SIZE - 1);
787 dump->u_tsize = (current->mm->end_code - dump->start_code) >> PAGE_SHIFT;
788 dump->u_dsize = (current->mm->brk + (PAGE_SIZE-1) - dump->start_data) >> PAGE_SHIFT;
789 dump->u_ssize = (current->mm->start_stack - dump->start_stack +
790 PAGE_SIZE - 1) >> PAGE_SHIFT;
791 /* Debug registers will come here. */
792
793 dump->regs = *regs;
794
795 dump->u_fpvalid = dump_fpu(regs, &dump->fpu);
796}
797
798asmlinkage int sys_fork(unsigned long r2, unsigned long r3, 778asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
799 unsigned long r4, unsigned long r5, 779 unsigned long r4, unsigned long r5,
800 unsigned long r6, unsigned long r7, 780 unsigned long r6, unsigned long r7,
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c
index 0b5497d70bd3..472b450e61be 100644
--- a/arch/sh64/kernel/sh_ksyms.c
+++ b/arch/sh64/kernel/sh_ksyms.c
@@ -29,7 +29,6 @@
29#include <asm/delay.h> 29#include <asm/delay.h>
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32extern void dump_thread(struct pt_regs *, struct user *);
33extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); 32extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
34 33
35#if 0 34#if 0
@@ -41,7 +40,6 @@ EXPORT_SYMBOL(drive_info);
41#endif 40#endif
42 41
43/* platform dependent support */ 42/* platform dependent support */
44EXPORT_SYMBOL(dump_thread);
45EXPORT_SYMBOL(dump_fpu); 43EXPORT_SYMBOL(dump_fpu);
46EXPORT_SYMBOL(iounmap); 44EXPORT_SYMBOL(iounmap);
47EXPORT_SYMBOL(enable_irq); 45EXPORT_SYMBOL(enable_irq);
diff --git a/arch/sh64/lib/dbg.c b/arch/sh64/lib/dbg.c
index 526fedae6db8..58087331b8a6 100644
--- a/arch/sh64/lib/dbg.c
+++ b/arch/sh64/lib/dbg.c
@@ -174,7 +174,7 @@ void evt_debug(int evt, int ret_addr, int event, int tra, struct pt_regs *regs)
174 struct ring_node *rr; 174 struct ring_node *rr;
175 175
176 pid = current->pid; 176 pid = current->pid;
177 stack_bottom = (unsigned long) current->thread_info; 177 stack_bottom = (unsigned long) task_stack_page(current);
178 asm volatile("ori r15, 0, %0" : "=r" (sp)); 178 asm volatile("ori r15, 0, %0" : "=r" (sp));
179 rr = event_ring + event_ptr; 179 rr = event_ring + event_ptr;
180 rr->evt = evt; 180 rr->evt = evt;
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index ea8647411462..fbb05a452e51 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -302,7 +302,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
302 int count = 0; 302 int count = 0;
303 303
304 if (tsk != NULL) 304 if (tsk != NULL)
305 task_base = (unsigned long) tsk->thread_info; 305 task_base = (unsigned long) task_stack_page(tsk);
306 else 306 else
307 task_base = (unsigned long) current_thread_info(); 307 task_base = (unsigned long) current_thread_info();
308 308
@@ -337,7 +337,7 @@ EXPORT_SYMBOL(dump_stack);
337 */ 337 */
338unsigned long thread_saved_pc(struct task_struct *tsk) 338unsigned long thread_saved_pc(struct task_struct *tsk)
339{ 339{
340 return tsk->thread_info->kpc; 340 return task_thread_info(tsk)->kpc;
341} 341}
342 342
343/* 343/*
@@ -392,7 +392,7 @@ void flush_thread(void)
392 /* We must fixup kregs as well. */ 392 /* We must fixup kregs as well. */
393 /* XXX This was not fixed for ti for a while, worked. Unused? */ 393 /* XXX This was not fixed for ti for a while, worked. Unused? */
394 current->thread.kregs = (struct pt_regs *) 394 current->thread.kregs = (struct pt_regs *)
395 ((char *)current->thread_info + (THREAD_SIZE - TRACEREG_SZ)); 395 (task_stack_page(current) + (THREAD_SIZE - TRACEREG_SZ));
396 } 396 }
397} 397}
398 398
@@ -459,7 +459,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
459 unsigned long unused, 459 unsigned long unused,
460 struct task_struct *p, struct pt_regs *regs) 460 struct task_struct *p, struct pt_regs *regs)
461{ 461{
462 struct thread_info *ti = p->thread_info; 462 struct thread_info *ti = task_thread_info(p);
463 struct pt_regs *childregs; 463 struct pt_regs *childregs;
464 char *new_stack; 464 char *new_stack;
465 465
@@ -482,7 +482,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
482 * V V (stk.fr.) V (pt_regs) { (stk.fr.) } 482 * V V (stk.fr.) V (pt_regs) { (stk.fr.) }
483 * +----- - - - - - ------+===========+============={+==========}+ 483 * +----- - - - - - ------+===========+============={+==========}+
484 */ 484 */
485 new_stack = (char*)ti + THREAD_SIZE; 485 new_stack = task_stack_page(p) + THREAD_SIZE;
486 if (regs->psr & PSR_PS) 486 if (regs->psr & PSR_PS)
487 new_stack -= STACKFRAME_SZ; 487 new_stack -= STACKFRAME_SZ;
488 new_stack -= STACKFRAME_SZ + TRACEREG_SZ; 488 new_stack -= STACKFRAME_SZ + TRACEREG_SZ;
@@ -724,7 +724,7 @@ unsigned long get_wchan(struct task_struct *task)
724 task->state == TASK_RUNNING) 724 task->state == TASK_RUNNING)
725 goto out; 725 goto out;
726 726
727 fp = task->thread_info->ksp + bias; 727 fp = task_thread_info(task)->ksp + bias;
728 do { 728 do {
729 /* Bogus frame pointer? */ 729 /* Bogus frame pointer? */
730 if (fp < (task_base + sizeof(struct thread_info)) || 730 if (fp < (task_base + sizeof(struct thread_info)) ||
diff --git a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
index fc470c0e9dc6..1baf13ed5c3a 100644
--- a/arch/sparc/kernel/ptrace.c
+++ b/arch/sparc/kernel/ptrace.c
@@ -75,7 +75,7 @@ static inline void read_sunos_user(struct pt_regs *regs, unsigned long offset,
75 struct task_struct *tsk, long __user *addr) 75 struct task_struct *tsk, long __user *addr)
76{ 76{
77 struct pt_regs *cregs = tsk->thread.kregs; 77 struct pt_regs *cregs = tsk->thread.kregs;
78 struct thread_info *t = tsk->thread_info; 78 struct thread_info *t = task_thread_info(tsk);
79 int v; 79 int v;
80 80
81 if(offset >= 1024) 81 if(offset >= 1024)
@@ -170,7 +170,7 @@ static inline void write_sunos_user(struct pt_regs *regs, unsigned long offset,
170 struct task_struct *tsk) 170 struct task_struct *tsk)
171{ 171{
172 struct pt_regs *cregs = tsk->thread.kregs; 172 struct pt_regs *cregs = tsk->thread.kregs;
173 struct thread_info *t = tsk->thread_info; 173 struct thread_info *t = task_thread_info(tsk);
174 unsigned long value = regs->u_regs[UREG_I3]; 174 unsigned long value = regs->u_regs[UREG_I3];
175 175
176 if(offset >= 1024) 176 if(offset >= 1024)
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 1c8fd0fd9305..0b0d492c953b 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -82,8 +82,6 @@ extern int __lshrdi3(int, int);
82extern int __muldi3(int, int); 82extern int __muldi3(int, int);
83extern int __divdi3(int, int); 83extern int __divdi3(int, int);
84 84
85extern void dump_thread(struct pt_regs *, struct user *);
86
87/* Private functions with odd calling conventions. */ 85/* Private functions with odd calling conventions. */
88extern void ___atomic24_add(void); 86extern void ___atomic24_add(void);
89extern void ___atomic24_sub(void); 87extern void ___atomic24_sub(void);
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index cc1fc898495c..40d426cce824 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -200,7 +200,7 @@ void __init smp4d_boot_cpus(void)
200 /* Cook up an idler for this guy. */ 200 /* Cook up an idler for this guy. */
201 p = fork_idle(i); 201 p = fork_idle(i);
202 cpucount++; 202 cpucount++;
203 current_set[i] = p->thread_info; 203 current_set[i] = task_thread_info(p);
204 for (no = 0; !cpu_find_by_instance(no, NULL, &mid) 204 for (no = 0; !cpu_find_by_instance(no, NULL, &mid)
205 && mid != i; no++) ; 205 && mid != i; no++) ;
206 206
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index f113422a3727..a21f27d10e55 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -173,7 +173,7 @@ void __init smp4m_boot_cpus(void)
173 /* Cook up an idler for this guy. */ 173 /* Cook up an idler for this guy. */
174 p = fork_idle(i); 174 p = fork_idle(i);
175 cpucount++; 175 cpucount++;
176 current_set[i] = p->thread_info; 176 current_set[i] = task_thread_info(p);
177 /* See trampoline.S for details... */ 177 /* See trampoline.S for details... */
178 entry += ((i-1) * 3); 178 entry += ((i-1) * 3);
179 179
diff --git a/arch/sparc/kernel/sys_sunos.c b/arch/sparc/kernel/sys_sunos.c
index d07ae02101ad..288de276d9ff 100644
--- a/arch/sparc/kernel/sys_sunos.c
+++ b/arch/sparc/kernel/sys_sunos.c
@@ -30,6 +30,7 @@
30#include <linux/stat.h> 30#include <linux/stat.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pagemap.h> 32#include <linux/pagemap.h>
33#include <linux/capability.h>
33#include <linux/errno.h> 34#include <linux/errno.h>
34#include <linux/smp.h> 35#include <linux/smp.h>
35#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
diff --git a/arch/sparc/kernel/traps.c b/arch/sparc/kernel/traps.c
index 3f451ae66482..41d45c298fb2 100644
--- a/arch/sparc/kernel/traps.c
+++ b/arch/sparc/kernel/traps.c
@@ -291,7 +291,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
291#ifndef CONFIG_SMP 291#ifndef CONFIG_SMP
292 if(!fpt) { 292 if(!fpt) {
293#else 293#else
294 if(!(fpt->thread_info->flags & _TIF_USEDFPU)) { 294 if(!(task_thread_info(fpt)->flags & _TIF_USEDFPU)) {
295#endif 295#endif
296 fpsave(&fake_regs[0], &fake_fsr, &fake_queue[0], &fake_depth); 296 fpsave(&fake_regs[0], &fake_fsr, &fake_queue[0], &fake_depth);
297 regs->psr &= ~PSR_EF; 297 regs->psr &= ~PSR_EF;
@@ -334,7 +334,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
334 /* nope, better SIGFPE the offending process... */ 334 /* nope, better SIGFPE the offending process... */
335 335
336#ifdef CONFIG_SMP 336#ifdef CONFIG_SMP
337 fpt->thread_info->flags &= ~_TIF_USEDFPU; 337 task_thread_info(fpt)->flags &= ~_TIF_USEDFPU;
338#endif 338#endif
339 if(psr & PSR_PS) { 339 if(psr & PSR_PS) {
340 /* The first fsr store/load we tried trapped, 340 /* The first fsr store/load we tried trapped,
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index b775ceb4cf98..ab733be9af08 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -179,7 +179,7 @@ config HUGETLB_PAGE_SIZE_512K
179 bool "512K" 179 bool "512K"
180 180
181config HUGETLB_PAGE_SIZE_64K 181config HUGETLB_PAGE_SIZE_64K
182 depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512K 182 depends on !SPARC64_PAGE_SIZE_4MB && !SPARC64_PAGE_SIZE_512KB
183 bool "64K" 183 bool "64K"
184 184
185endchoice 185endchoice
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index 6f00ab8b9d23..83d67eb18895 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -16,7 +16,7 @@ obj-y := process.o setup.o cpu.o idprom.o \
16obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ 16obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \
17 pci_psycho.o pci_sabre.o pci_schizo.o 17 pci_psycho.o pci_sabre.o pci_schizo.o
18obj-$(CONFIG_SMP) += smp.o trampoline.o 18obj-$(CONFIG_SMP) += smp.o trampoline.o
19obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o ioctl32.o 19obj-$(CONFIG_SPARC32_COMPAT) += sys32.o sys_sparc32.o signal32.o
20obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o 20obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o
21obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o 21obj-$(CONFIG_BINFMT_AOUT32) += binfmt_aout32.o
22obj-$(CONFIG_MODULES) += module.o 22obj-$(CONFIG_MODULES) += module.o
@@ -40,5 +40,3 @@ endif
40 40
41head.o: head.S ttable.S itlb_base.S dtlb_base.S dtlb_backend.S dtlb_prot.S \ 41head.o: head.S ttable.S itlb_base.S dtlb_base.S dtlb_backend.S dtlb_prot.S \
42 etrap.S rtrap.S winfixup.S entry.S 42 etrap.S rtrap.S winfixup.S entry.S
43
44CFLAGS_ioctl32.o += -Ifs/
diff --git a/arch/sparc64/kernel/binfmt_aout32.c b/arch/sparc64/kernel/binfmt_aout32.c
index edf52d06b280..202a80c24b6f 100644
--- a/arch/sparc64/kernel/binfmt_aout32.c
+++ b/arch/sparc64/kernel/binfmt_aout32.c
@@ -36,8 +36,6 @@ static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs);
36static int load_aout32_library(struct file*); 36static int load_aout32_library(struct file*);
37static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file); 37static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file);
38 38
39extern void dump_thread(struct pt_regs *, struct user *);
40
41static struct linux_binfmt aout32_format = { 39static struct linux_binfmt aout32_format = {
42 NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump, 40 NULL, THIS_MODULE, load_aout32_binary, load_aout32_library, aout32_core_dump,
43 PAGE_SIZE 41 PAGE_SIZE
diff --git a/arch/sparc64/kernel/ioctl32.c b/arch/sparc64/kernel/ioctl32.c
deleted file mode 100644
index 196b208665a2..000000000000
--- a/arch/sparc64/kernel/ioctl32.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/* $Id: ioctl32.c,v 1.136 2002/01/14 09:49:52 davem Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
7 *
8 * These routines maintain argument size conversion between 32bit and 64bit
9 * ioctls.
10 */
11
12#define INCLUDES
13#include "compat_ioctl.c"
14#include <linux/syscalls.h>
15
16#define CODE
17#include "compat_ioctl.c"
18
19#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
20#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
21#define IOCTL_TABLE_START \
22 struct ioctl_trans ioctl_start[] = {
23#define IOCTL_TABLE_END \
24 };
25
26IOCTL_TABLE_START
27#include <linux/compat_ioctl.h>
28#define DECLARES
29#include "compat_ioctl.c"
30#if 0
31HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl)
32HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl)
33HANDLE_IOCTL(RTC32_EPOCH_READ, do_rtc_ioctl)
34HANDLE_IOCTL(RTC32_EPOCH_SET, do_rtc_ioctl)
35#endif
36/* take care of sizeof(sizeof()) breakage */
37IOCTL_TABLE_END
38
39int ioctl_table_size = ARRAY_SIZE(ioctl_start);
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index a97b0f0727ab..b9a9ce70e55c 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -43,14 +43,10 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
43 43
44int __kprobes arch_prepare_kprobe(struct kprobe *p) 44int __kprobes arch_prepare_kprobe(struct kprobe *p)
45{ 45{
46 return 0;
47}
48
49void __kprobes arch_copy_kprobe(struct kprobe *p)
50{
51 p->ainsn.insn[0] = *p->addr; 46 p->ainsn.insn[0] = *p->addr;
52 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; 47 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
53 p->opcode = *p->addr; 48 p->opcode = *p->addr;
49 return 0;
54} 50}
55 51
56void __kprobes arch_arm_kprobe(struct kprobe *p) 52void __kprobes arch_arm_kprobe(struct kprobe *p)
@@ -65,10 +61,6 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
65 flushi(p->addr); 61 flushi(p->addr);
66} 62}
67 63
68void __kprobes arch_remove_kprobe(struct kprobe *p)
69{
70}
71
72static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb) 64static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
73{ 65{
74 kcb->prev_kprobe.kp = kprobe_running(); 66 kcb->prev_kprobe.kp = kprobe_running();
@@ -143,6 +135,14 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
143 prepare_singlestep(p, regs, kcb); 135 prepare_singlestep(p, regs, kcb);
144 return 1; 136 return 1;
145 } else { 137 } else {
138 if (*(u32 *)addr != BREAKPOINT_INSTRUCTION) {
139 /* The breakpoint instruction was removed by
140 * another cpu right after we hit, no further
141 * handling of this interrupt is appropriate
142 */
143 ret = 1;
144 goto no_kprobe;
145 }
146 p = __get_cpu_var(current_kprobe); 146 p = __get_cpu_var(current_kprobe);
147 if (p->break_handler && p->break_handler(p, regs)) 147 if (p->break_handler && p->break_handler(p, regs))
148 goto ss_probe; 148 goto ss_probe;
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 02f9dec1d459..1dc3650c5cae 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -390,7 +390,7 @@ void show_regs32(struct pt_regs32 *regs)
390 390
391unsigned long thread_saved_pc(struct task_struct *tsk) 391unsigned long thread_saved_pc(struct task_struct *tsk)
392{ 392{
393 struct thread_info *ti = tsk->thread_info; 393 struct thread_info *ti = task_thread_info(tsk);
394 unsigned long ret = 0xdeadbeefUL; 394 unsigned long ret = 0xdeadbeefUL;
395 395
396 if (ti && ti->ksp) { 396 if (ti && ti->ksp) {
@@ -616,11 +616,11 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
616 unsigned long unused, 616 unsigned long unused,
617 struct task_struct *p, struct pt_regs *regs) 617 struct task_struct *p, struct pt_regs *regs)
618{ 618{
619 struct thread_info *t = p->thread_info; 619 struct thread_info *t = task_thread_info(p);
620 char *child_trap_frame; 620 char *child_trap_frame;
621 621
622 /* Calculate offset to stack_frame & pt_regs */ 622 /* Calculate offset to stack_frame & pt_regs */
623 child_trap_frame = ((char *)t) + (THREAD_SIZE - (TRACEREG_SZ+STACKFRAME_SZ)); 623 child_trap_frame = task_stack_page(p) + (THREAD_SIZE - (TRACEREG_SZ+STACKFRAME_SZ));
624 memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); 624 memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ));
625 625
626 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | 626 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) |
@@ -845,9 +845,9 @@ unsigned long get_wchan(struct task_struct *task)
845 task->state == TASK_RUNNING) 845 task->state == TASK_RUNNING)
846 goto out; 846 goto out;
847 847
848 thread_info_base = (unsigned long) task->thread_info; 848 thread_info_base = (unsigned long) task_stack_page(task);
849 bias = STACK_BIAS; 849 bias = STACK_BIAS;
850 fp = task->thread_info->ksp + bias; 850 fp = task_thread_info(task)->ksp + bias;
851 851
852 do { 852 do {
853 /* Bogus frame pointer? */ 853 /* Bogus frame pointer? */
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index 84d3df2264cb..3f9746f856d2 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -296,7 +296,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
296 case PTRACE_GETREGS: { 296 case PTRACE_GETREGS: {
297 struct pt_regs32 __user *pregs = 297 struct pt_regs32 __user *pregs =
298 (struct pt_regs32 __user *) addr; 298 (struct pt_regs32 __user *) addr;
299 struct pt_regs *cregs = child->thread_info->kregs; 299 struct pt_regs *cregs = task_pt_regs(child);
300 int rval; 300 int rval;
301 301
302 if (__put_user(tstate_to_psr(cregs->tstate), (&pregs->psr)) || 302 if (__put_user(tstate_to_psr(cregs->tstate), (&pregs->psr)) ||
@@ -320,11 +320,11 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
320 320
321 case PTRACE_GETREGS64: { 321 case PTRACE_GETREGS64: {
322 struct pt_regs __user *pregs = (struct pt_regs __user *) addr; 322 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
323 struct pt_regs *cregs = child->thread_info->kregs; 323 struct pt_regs *cregs = task_pt_regs(child);
324 unsigned long tpc = cregs->tpc; 324 unsigned long tpc = cregs->tpc;
325 int rval; 325 int rval;
326 326
327 if ((child->thread_info->flags & _TIF_32BIT) != 0) 327 if ((task_thread_info(child)->flags & _TIF_32BIT) != 0)
328 tpc &= 0xffffffff; 328 tpc &= 0xffffffff;
329 if (__put_user(cregs->tstate, (&pregs->tstate)) || 329 if (__put_user(cregs->tstate, (&pregs->tstate)) ||
330 __put_user(tpc, (&pregs->tpc)) || 330 __put_user(tpc, (&pregs->tpc)) ||
@@ -348,7 +348,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
348 case PTRACE_SETREGS: { 348 case PTRACE_SETREGS: {
349 struct pt_regs32 __user *pregs = 349 struct pt_regs32 __user *pregs =
350 (struct pt_regs32 __user *) addr; 350 (struct pt_regs32 __user *) addr;
351 struct pt_regs *cregs = child->thread_info->kregs; 351 struct pt_regs *cregs = task_pt_regs(child);
352 unsigned int psr, pc, npc, y; 352 unsigned int psr, pc, npc, y;
353 int i; 353 int i;
354 354
@@ -381,7 +381,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
381 381
382 case PTRACE_SETREGS64: { 382 case PTRACE_SETREGS64: {
383 struct pt_regs __user *pregs = (struct pt_regs __user *) addr; 383 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
384 struct pt_regs *cregs = child->thread_info->kregs; 384 struct pt_regs *cregs = task_pt_regs(child);
385 unsigned long tstate, tpc, tnpc, y; 385 unsigned long tstate, tpc, tnpc, y;
386 int i; 386 int i;
387 387
@@ -395,7 +395,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
395 pt_error_return(regs, EFAULT); 395 pt_error_return(regs, EFAULT);
396 goto out_tsk; 396 goto out_tsk;
397 } 397 }
398 if ((child->thread_info->flags & _TIF_32BIT) != 0) { 398 if ((task_thread_info(child)->flags & _TIF_32BIT) != 0) {
399 tpc &= 0xffffffff; 399 tpc &= 0xffffffff;
400 tnpc &= 0xffffffff; 400 tnpc &= 0xffffffff;
401 } 401 }
@@ -430,11 +430,11 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
430 } fpq[16]; 430 } fpq[16];
431 }; 431 };
432 struct fps __user *fps = (struct fps __user *) addr; 432 struct fps __user *fps = (struct fps __user *) addr;
433 unsigned long *fpregs = child->thread_info->fpregs; 433 unsigned long *fpregs = task_thread_info(child)->fpregs;
434 434
435 if (copy_to_user(&fps->regs[0], fpregs, 435 if (copy_to_user(&fps->regs[0], fpregs,
436 (32 * sizeof(unsigned int))) || 436 (32 * sizeof(unsigned int))) ||
437 __put_user(child->thread_info->xfsr[0], (&fps->fsr)) || 437 __put_user(task_thread_info(child)->xfsr[0], (&fps->fsr)) ||
438 __put_user(0, (&fps->fpqd)) || 438 __put_user(0, (&fps->fpqd)) ||
439 __put_user(0, (&fps->flags)) || 439 __put_user(0, (&fps->flags)) ||
440 __put_user(0, (&fps->extra)) || 440 __put_user(0, (&fps->extra)) ||
@@ -452,11 +452,11 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
452 unsigned long fsr; 452 unsigned long fsr;
453 }; 453 };
454 struct fps __user *fps = (struct fps __user *) addr; 454 struct fps __user *fps = (struct fps __user *) addr;
455 unsigned long *fpregs = child->thread_info->fpregs; 455 unsigned long *fpregs = task_thread_info(child)->fpregs;
456 456
457 if (copy_to_user(&fps->regs[0], fpregs, 457 if (copy_to_user(&fps->regs[0], fpregs,
458 (64 * sizeof(unsigned int))) || 458 (64 * sizeof(unsigned int))) ||
459 __put_user(child->thread_info->xfsr[0], (&fps->fsr))) { 459 __put_user(task_thread_info(child)->xfsr[0], (&fps->fsr))) {
460 pt_error_return(regs, EFAULT); 460 pt_error_return(regs, EFAULT);
461 goto out_tsk; 461 goto out_tsk;
462 } 462 }
@@ -477,7 +477,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
477 } fpq[16]; 477 } fpq[16];
478 }; 478 };
479 struct fps __user *fps = (struct fps __user *) addr; 479 struct fps __user *fps = (struct fps __user *) addr;
480 unsigned long *fpregs = child->thread_info->fpregs; 480 unsigned long *fpregs = task_thread_info(child)->fpregs;
481 unsigned fsr; 481 unsigned fsr;
482 482
483 if (copy_from_user(fpregs, &fps->regs[0], 483 if (copy_from_user(fpregs, &fps->regs[0],
@@ -486,11 +486,11 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
486 pt_error_return(regs, EFAULT); 486 pt_error_return(regs, EFAULT);
487 goto out_tsk; 487 goto out_tsk;
488 } 488 }
489 child->thread_info->xfsr[0] &= 0xffffffff00000000UL; 489 task_thread_info(child)->xfsr[0] &= 0xffffffff00000000UL;
490 child->thread_info->xfsr[0] |= fsr; 490 task_thread_info(child)->xfsr[0] |= fsr;
491 if (!(child->thread_info->fpsaved[0] & FPRS_FEF)) 491 if (!(task_thread_info(child)->fpsaved[0] & FPRS_FEF))
492 child->thread_info->gsr[0] = 0; 492 task_thread_info(child)->gsr[0] = 0;
493 child->thread_info->fpsaved[0] |= (FPRS_FEF | FPRS_DL); 493 task_thread_info(child)->fpsaved[0] |= (FPRS_FEF | FPRS_DL);
494 pt_succ_return(regs, 0); 494 pt_succ_return(regs, 0);
495 goto out_tsk; 495 goto out_tsk;
496 } 496 }
@@ -501,17 +501,17 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
501 unsigned long fsr; 501 unsigned long fsr;
502 }; 502 };
503 struct fps __user *fps = (struct fps __user *) addr; 503 struct fps __user *fps = (struct fps __user *) addr;
504 unsigned long *fpregs = child->thread_info->fpregs; 504 unsigned long *fpregs = task_thread_info(child)->fpregs;
505 505
506 if (copy_from_user(fpregs, &fps->regs[0], 506 if (copy_from_user(fpregs, &fps->regs[0],
507 (64 * sizeof(unsigned int))) || 507 (64 * sizeof(unsigned int))) ||
508 __get_user(child->thread_info->xfsr[0], (&fps->fsr))) { 508 __get_user(task_thread_info(child)->xfsr[0], (&fps->fsr))) {
509 pt_error_return(regs, EFAULT); 509 pt_error_return(regs, EFAULT);
510 goto out_tsk; 510 goto out_tsk;
511 } 511 }
512 if (!(child->thread_info->fpsaved[0] & FPRS_FEF)) 512 if (!(task_thread_info(child)->fpsaved[0] & FPRS_FEF))
513 child->thread_info->gsr[0] = 0; 513 task_thread_info(child)->gsr[0] = 0;
514 child->thread_info->fpsaved[0] |= (FPRS_FEF | FPRS_DL | FPRS_DU); 514 task_thread_info(child)->fpsaved[0] |= (FPRS_FEF | FPRS_DL | FPRS_DU);
515 pt_succ_return(regs, 0); 515 pt_succ_return(regs, 0);
516 goto out_tsk; 516 goto out_tsk;
517 } 517 }
@@ -562,8 +562,8 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
562#ifdef DEBUG_PTRACE 562#ifdef DEBUG_PTRACE
563 printk("CONT: %s [%d]: set exit_code = %x %lx %lx\n", child->comm, 563 printk("CONT: %s [%d]: set exit_code = %x %lx %lx\n", child->comm,
564 child->pid, child->exit_code, 564 child->pid, child->exit_code,
565 child->thread_info->kregs->tpc, 565 task_pt_regs(child)->tpc,
566 child->thread_info->kregs->tnpc); 566 task_pt_regs(child)->tnpc);
567 567
568#endif 568#endif
569 wake_up_process(child); 569 wake_up_process(child);
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index 48180531562f..250745896aee 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -520,7 +520,7 @@ void __init setup_arch(char **cmdline_p)
520 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0); 520 rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
521#endif 521#endif
522 522
523 init_task.thread_info->kregs = &fake_swapper_regs; 523 task_thread_info(&init_task)->kregs = &fake_swapper_regs;
524 524
525#ifdef CONFIG_IP_PNP 525#ifdef CONFIG_IP_PNP
526 if (!ic_set_manually) { 526 if (!ic_set_manually) {
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 6efc03df51c3..1fb6323e65a4 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -335,7 +335,7 @@ static int __devinit smp_boot_one_cpu(unsigned int cpu)
335 335
336 p = fork_idle(cpu); 336 p = fork_idle(cpu);
337 callin_flag = 0; 337 callin_flag = 0;
338 cpu_new_thread = p->thread_info; 338 cpu_new_thread = task_thread_info(p);
339 cpu_set(cpu, cpu_callout_map); 339 cpu_set(cpu, cpu_callout_map);
340 340
341 cpu_find_by_mid(cpu, &cpu_node); 341 cpu_find_by_mid(cpu, &cpu_node);
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index fb7a5370dbfc..d177d7e5c9d3 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -94,7 +94,6 @@ extern void (*prom_palette)(int);
94 94
95extern int __ashrdi3(int, int); 95extern int __ashrdi3(int, int);
96 96
97extern void dump_thread(struct pt_regs *, struct user *);
98extern int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs); 97extern int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs);
99 98
100extern unsigned long phys_base; 99extern unsigned long phys_base;
@@ -241,7 +240,6 @@ EXPORT_SYMBOL(io_remap_pfn_range);
241EXPORT_SYMBOL(_sigpause_common); 240EXPORT_SYMBOL(_sigpause_common);
242EXPORT_SYMBOL(verify_compat_iovec); 241EXPORT_SYMBOL(verify_compat_iovec);
243 242
244EXPORT_SYMBOL(dump_thread);
245EXPORT_SYMBOL(dump_fpu); 243EXPORT_SYMBOL(dump_fpu);
246EXPORT_SYMBOL(pte_alloc_one_kernel); 244EXPORT_SYMBOL(pte_alloc_one_kernel);
247#ifndef CONFIG_SMP 245#ifndef CONFIG_SMP
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 7f6239ed2521..d4b7a100cb8a 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -11,6 +11,7 @@
11#include <linux/config.h> 11#include <linux/config.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/capability.h>
14#include <linux/fs.h> 15#include <linux/fs.h>
15#include <linux/mm.h> 16#include <linux/mm.h>
16#include <linux/file.h> 17#include <linux/file.h>
@@ -1120,39 +1121,3 @@ long sys32_lookup_dcookie(unsigned long cookie_high,
1120 return sys_lookup_dcookie((cookie_high << 32) | cookie_low, 1121 return sys_lookup_dcookie((cookie_high << 32) | cookie_low,
1121 buf, len); 1122 buf, len);
1122} 1123}
1123
1124extern asmlinkage long
1125sys_timer_create(clockid_t which_clock,
1126 struct sigevent __user *timer_event_spec,
1127 timer_t __user *created_timer_id);
1128
1129long
1130sys32_timer_create(u32 clock, struct compat_sigevent __user *se32,
1131 timer_t __user *timer_id)
1132{
1133 struct sigevent se;
1134 mm_segment_t oldfs;
1135 timer_t t;
1136 long err;
1137
1138 if (se32 == NULL)
1139 return sys_timer_create(clock, NULL, timer_id);
1140
1141 if (get_compat_sigevent(&se, se32))
1142 return -EFAULT;
1143
1144 if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
1145 return -EFAULT;
1146
1147 oldfs = get_fs();
1148 set_fs(KERNEL_DS);
1149 err = sys_timer_create(clock,
1150 (struct sigevent __user *) &se,
1151 (timer_t __user *) &t);
1152 set_fs(oldfs);
1153
1154 if (!err)
1155 err = __put_user (t, timer_id);
1156
1157 return err;
1158}
diff --git a/arch/sparc64/kernel/sys_sunos32.c b/arch/sparc64/kernel/sys_sunos32.c
index bfa4aa68312d..ae5b32f817f0 100644
--- a/arch/sparc64/kernel/sys_sunos32.c
+++ b/arch/sparc64/kernel/sys_sunos32.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/capability.h>
15#include <linux/compat.h> 16#include <linux/compat.h>
16#include <linux/mman.h> 17#include <linux/mman.h>
17#include <linux/mm.h> 18#include <linux/mm.h>
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 53eaf2345fe9..98d24bc00044 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -73,7 +73,7 @@ sys_call_table32:
73/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl 73/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
74 .word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep 74 .word sys_ni_syscall, sys32_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
75/*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun 75/*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
76 .word sys_timer_delete, sys32_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy 76 .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
77/*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink 77/*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
78 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid 78 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
79/*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl 79/*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl
@@ -98,7 +98,7 @@ sys_call_table:
98 .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid 98 .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
99/*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl 99/*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl
100 .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve 100 .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve
101/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_stat64, sys_getpagesize 101/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize
102 .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall 102 .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall
103/*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys64_munmap, sys_mprotect 103/*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys64_munmap, sys_mprotect
104 .word sys_madvise, sys_vhangup, sys_nis_syscall, sys_mincore, sys_getgroups 104 .word sys_madvise, sys_vhangup, sys_nis_syscall, sys_mincore, sys_getgroups
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 5570e7bb22bb..8d44ae5a15e3 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -1808,7 +1808,7 @@ static void user_instruction_dump (unsigned int __user *pc)
1808void show_stack(struct task_struct *tsk, unsigned long *_ksp) 1808void show_stack(struct task_struct *tsk, unsigned long *_ksp)
1809{ 1809{
1810 unsigned long pc, fp, thread_base, ksp; 1810 unsigned long pc, fp, thread_base, ksp;
1811 struct thread_info *tp = tsk->thread_info; 1811 void *tp = task_stack_page(tsk);
1812 struct reg_window *rw; 1812 struct reg_window *rw;
1813 int count = 0; 1813 int count = 0;
1814 1814
@@ -1862,7 +1862,7 @@ static inline int is_kernel_stack(struct task_struct *task,
1862 return 0; 1862 return 0;
1863 } 1863 }
1864 1864
1865 thread_base = (unsigned long) task->thread_info; 1865 thread_base = (unsigned long) task_stack_page(task);
1866 thread_end = thread_base + sizeof(union thread_union); 1866 thread_end = thread_base + sizeof(union thread_union);
1867 if (rw_addr >= thread_base && 1867 if (rw_addr >= thread_base &&
1868 rw_addr < thread_end && 1868 rw_addr < thread_end &&
diff --git a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
index d7c99fa89661..4885ca6cbc77 100644
--- a/arch/sparc64/solaris/fs.c
+++ b/arch/sparc64/solaris/fs.c
@@ -10,6 +10,7 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/capability.h>
13#include <linux/fs.h> 14#include <linux/fs.h>
14#include <linux/namei.h> 15#include <linux/namei.h>
15#include <linux/mm.h> 16#include <linux/mm.h>
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index b4ff2e576021..8ff3bcbce5fc 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -35,12 +35,12 @@ menu "UML-specific options"
35 35
36config MODE_TT 36config MODE_TT
37 bool "Tracing thread support" 37 bool "Tracing thread support"
38 default y 38 default n
39 help 39 help
40 This option controls whether tracing thread support is compiled 40 This option controls whether tracing thread support is compiled
41 into UML. Normally, this should be set to Y. If you intend to 41 into UML. This option is largely obsolete, given that skas0 provides
42 use only skas mode (and the host has the skas patch applied to it), 42 skas security and performance without needing to patch the host.
43 then it is OK to say N here. 43 It is safe to say 'N' here.
44 44
45config STATIC_LINK 45config STATIC_LINK
46 bool "Force a static link" 46 bool "Force a static link"
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 1b12feeba368..322972fd064e 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -189,6 +189,12 @@ define filechk_umlconfig
189 sed 's/ CONFIG/ UML_CONFIG/' 189 sed 's/ CONFIG/ UML_CONFIG/'
190endef 190endef
191 191
192$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
193 $(call filechk,umlconfig)
194
195$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
196 $(CC) $(USER_CFLAGS) -S -o $@ $<
197
192define filechk_gen-asm-offsets 198define filechk_gen-asm-offsets
193 (set -e; \ 199 (set -e; \
194 echo "/*"; \ 200 echo "/*"; \
@@ -202,24 +208,13 @@ define filechk_gen-asm-offsets
202 echo ""; ) 208 echo ""; )
203endef 209endef
204 210
205$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
206 $(call filechk,umlconfig)
207
208$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
209 $(CC) $(USER_CFLAGS) -S -o $@ $<
210
211$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s 211$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s
212 $(call filechk,gen-asm-offsets) 212 $(call filechk,gen-asm-offsets)
213 213
214CLEAN_FILES += $(ARCH_DIR)/user-offsets.s 214CLEAN_FILES += $(ARCH_DIR)/user-offsets.s
215 215
216$(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ 216$(ARCH_DIR)/include/kern_constants.h:
217 archprepare 217 @echo ' SYMLINK $@'
218 $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< 218 $(Q) ln -sf ../../../include/asm-um/asm-offsets.h $@
219
220$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s
221 $(call filechk,gen-asm-offsets)
222
223CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s
224 219
225export SUBARCH USER_CFLAGS OS 220export SUBARCH USER_CFLAGS OS
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index cd13b91b9ff6..ab0d0b170816 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -186,9 +186,6 @@ static void tty_receive_char(struct tty_struct *tty, char ch)
186 } 186 }
187 } 187 }
188 188
189 if((tty->flip.flag_buf_ptr == NULL) ||
190 (tty->flip.char_buf_ptr == NULL))
191 return;
192 tty_insert_flip_char(tty, ch, TTY_NORMAL); 189 tty_insert_flip_char(tty, ch, TTY_NORMAL);
193} 190}
194 191
@@ -653,8 +650,7 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task,
653 chan = list_entry(ele, struct chan, list); 650 chan = list_entry(ele, struct chan, list);
654 if(!chan->input || (chan->ops->read == NULL)) continue; 651 if(!chan->input || (chan->ops->read == NULL)) continue;
655 do { 652 do {
656 if((tty != NULL) && 653 if (tty && !tty_buffer_request_room(tty, 1)) {
657 (tty->flip.count >= TTY_FLIPBUF_SIZE)){
658 schedule_delayed_work(task, 1); 654 schedule_delayed_work(task, 1);
659 goto out; 655 goto out;
660 } 656 }
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index be610125429f..e3d576567172 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -500,7 +500,7 @@ static void console_write(struct console *console, const char *string,
500 500
501static struct console mc_console = { .name = "mc", 501static struct console mc_console = { .name = "mc",
502 .write = console_write, 502 .write = console_write,
503 .flags = CON_PRINTBUFFER | CON_ENABLED, 503 .flags = CON_ENABLED,
504 .index = -1 }; 504 .index = -1 };
505 505
506static int mc_add_console(void) 506static int mc_add_console(void)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 3a93c6f772fa..7696f8d2d89c 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1073,7 +1073,6 @@ static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1073static int ubd_ioctl(struct inode * inode, struct file * file, 1073static int ubd_ioctl(struct inode * inode, struct file * file,
1074 unsigned int cmd, unsigned long arg) 1074 unsigned int cmd, unsigned long arg)
1075{ 1075{
1076 struct hd_geometry __user *loc = (struct hd_geometry __user *) arg;
1077 struct ubd *dev = inode->i_bdev->bd_disk->private_data; 1076 struct ubd *dev = inode->i_bdev->bd_disk->private_data;
1078 struct hd_driveid ubd_id = { 1077 struct hd_driveid ubd_id = {
1079 .cyls = 0, 1078 .cyls = 0,
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/include/sysdep-i386/kernel-offsets.h
index 35db85057506..82f96c574144 100644
--- a/arch/um/sys-i386/kernel-offsets.c
+++ b/arch/um/include/sysdep-i386/kernel-offsets.h
@@ -1,12 +1,9 @@
1#include <linux/config.h>
2#include <linux/stddef.h> 1#include <linux/stddef.h>
3#include <linux/sched.h> 2#include <linux/sched.h>
4#include <linux/time.h>
5#include <linux/elf.h> 3#include <linux/elf.h>
6#include <asm/page.h>
7 4
8#define DEFINE(sym, val) \ 5#define DEFINE(sym, val) \
9 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 6 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
10 7
11#define STR(x) #x 8#define STR(x) #x
12#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : ) 9#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/include/sysdep-x86_64/kernel-offsets.h
index bfcb104b846e..5ce93abd0b54 100644
--- a/arch/um/sys-x86_64/kernel-offsets.c
+++ b/arch/um/include/sysdep-x86_64/kernel-offsets.h
@@ -6,7 +6,7 @@
6#include <asm/page.h> 6#include <asm/page.h>
7 7
8#define DEFINE(sym, val) \ 8#define DEFINE(sym, val) \
9 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 9 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
10 10
11#define DEFINE_STR1(x) #x 11#define DEFINE_STR1(x) #x
12#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : ) 12#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : )
diff --git a/arch/um/kernel/asm-offsets.c b/arch/um/kernel/asm-offsets.c
index c13a64a288f6..91ea538e1612 100644
--- a/arch/um/kernel/asm-offsets.c
+++ b/arch/um/kernel/asm-offsets.c
@@ -1 +1 @@
/* Dummy file to make kbuild happy - unused! */ #include "sysdep/kernel-offsets.h"
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index d2d3f256778c..7f13b85d2656 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -107,7 +107,7 @@ void set_current(void *t)
107{ 107{
108 struct task_struct *task = t; 108 struct task_struct *task = t;
109 109
110 cpu_tasks[task->thread_info->cpu] = ((struct cpu_task) 110 cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task)
111 { external_pid(task), task }); 111 { external_pid(task), task });
112} 112}
113 113
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 9264d4021dfe..3b3955d84407 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -68,7 +68,7 @@ void wait_stub_done(int pid, int sig, char * fname)
68 68
69 if((n < 0) || !WIFSTOPPED(status) || 69 if((n < 0) || !WIFSTOPPED(status) ||
70 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){ 70 (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
71 unsigned long regs[FRAME_SIZE]; 71 unsigned long regs[HOST_FRAME_SIZE];
72 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) 72 if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
73 printk("Failed to get registers from stub, " 73 printk("Failed to get registers from stub, "
74 "errno = %d\n", errno); 74 "errno = %d\n", errno);
@@ -76,7 +76,7 @@ void wait_stub_done(int pid, int sig, char * fname)
76 int i; 76 int i;
77 77
78 printk("Stub registers -\n"); 78 printk("Stub registers -\n");
79 for(i = 0; i < FRAME_SIZE; i++) 79 for(i = 0; i < HOST_FRAME_SIZE; i++)
80 printk("\t%d - %lx\n", i, regs[i]); 80 printk("\t%d - %lx\n", i, regs[i]);
81 } 81 }
82 panic("%s : failed to wait for SIGUSR1/SIGTRAP, " 82 panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 09790ccb161c..dc41c6dc2f34 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -118,7 +118,7 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
118 handler = new_thread_handler; 118 handler = new_thread_handler;
119 } 119 }
120 120
121 new_thread(p->thread_info, &p->thread.mode.skas.switch_buf, 121 new_thread(task_stack_page(p), &p->thread.mode.skas.switch_buf,
122 &p->thread.mode.skas.fork_buf, handler); 122 &p->thread.mode.skas.fork_buf, handler);
123 return(0); 123 return(0);
124} 124}
@@ -185,7 +185,7 @@ int start_uml_skas(void)
185 185
186 init_task.thread.request.u.thread.proc = start_kernel_proc; 186 init_task.thread.request.u.thread.proc = start_kernel_proc;
187 init_task.thread.request.u.thread.arg = NULL; 187 init_task.thread.request.u.thread.arg = NULL;
188 return(start_idle_thread(init_task.thread_info, 188 return(start_idle_thread(task_stack_page(&init_task),
189 &init_task.thread.mode.skas.switch_buf, 189 &init_task.thread.mode.skas.switch_buf,
190 &init_task.thread.mode.skas.fork_buf)); 190 &init_task.thread.mode.skas.fork_buf));
191} 191}
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 11f518a7e156..8fa2ae7f3026 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -99,7 +99,8 @@ void uml_idle_timer(void)
99 set_interval(ITIMER_REAL); 99 set_interval(ITIMER_REAL);
100} 100}
101 101
102extern int do_posix_clock_monotonic_gettime(struct timespec *tp); 102extern void ktime_get_ts(struct timespec *ts);
103#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
103 104
104void time_init(void) 105void time_init(void)
105{ 106{
@@ -114,8 +115,8 @@ void time_init(void)
114 wall_to_monotonic.tv_nsec = -now.tv_nsec; 115 wall_to_monotonic.tv_nsec = -now.tv_nsec;
115} 116}
116 117
117/* Declared in linux/time.h, which can't be included here */ 118/* Defined in linux/ktimer.h, which can't be included here */
118extern void clock_was_set(void); 119#define clock_was_set() do { } while (0)
119 120
120void do_gettimeofday(struct timeval *tv) 121void do_gettimeofday(struct timeval *tv)
121{ 122{
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c
index 136e54c47d37..8f40e4838736 100644
--- a/arch/um/kernel/tt/exec_kern.c
+++ b/arch/um/kernel/tt/exec_kern.c
@@ -39,7 +39,7 @@ void flush_thread_tt(void)
39 do_exit(SIGKILL); 39 do_exit(SIGKILL);
40 } 40 }
41 41
42 new_pid = start_fork_tramp(current->thread_info, stack, 0, exec_tramp); 42 new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp);
43 if(new_pid < 0){ 43 if(new_pid < 0){
44 printk(KERN_ERR 44 printk(KERN_ERR
45 "flush_thread : new thread failed, errno = %d\n", 45 "flush_thread : new thread failed, errno = %d\n",
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index 14d4622a5fb8..62535303aa27 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -36,7 +36,7 @@ void switch_to_tt(void *prev, void *next)
36 from = prev; 36 from = prev;
37 to = next; 37 to = next;
38 38
39 cpu = from->thread_info->cpu; 39 cpu = task_thread_info(from)->cpu;
40 if(cpu == 0) 40 if(cpu == 0)
41 forward_interrupts(to->thread.mode.tt.extern_pid); 41 forward_interrupts(to->thread.mode.tt.extern_pid);
42#ifdef CONFIG_SMP 42#ifdef CONFIG_SMP
@@ -253,7 +253,7 @@ int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
253 253
254 clone_flags &= CLONE_VM; 254 clone_flags &= CLONE_VM;
255 p->thread.temp_stack = stack; 255 p->thread.temp_stack = stack;
256 new_pid = start_fork_tramp(p->thread_info, stack, clone_flags, tramp); 256 new_pid = start_fork_tramp(task_stack_page(p), stack, clone_flags, tramp);
257 if(new_pid < 0){ 257 if(new_pid < 0){
258 printk(KERN_ERR "copy_thread : clone failed - errno = %d\n", 258 printk(KERN_ERR "copy_thread : clone failed - errno = %d\n",
259 -new_pid); 259 -new_pid);
@@ -343,7 +343,7 @@ int do_proc_op(void *t, int proc_id)
343 pid = thread->request.u.exec.pid; 343 pid = thread->request.u.exec.pid;
344 do_exec(thread->mode.tt.extern_pid, pid); 344 do_exec(thread->mode.tt.extern_pid, pid);
345 thread->mode.tt.extern_pid = pid; 345 thread->mode.tt.extern_pid = pid;
346 cpu_tasks[task->thread_info->cpu].pid = pid; 346 cpu_tasks[task_thread_info(task)->cpu].pid = pid;
347 break; 347 break;
348 case OP_FORK: 348 case OP_FORK:
349 attach_process(thread->request.u.fork.pid); 349 attach_process(thread->request.u.fork.pid);
@@ -425,7 +425,7 @@ int start_uml_tt(void)
425 int pages; 425 int pages;
426 426
427 pages = (1 << CONFIG_KERNEL_STACK_ORDER); 427 pages = (1 << CONFIG_KERNEL_STACK_ORDER);
428 sp = (void *) ((unsigned long) init_task.thread_info) + 428 sp = task_stack_page(&init_task) +
429 pages * PAGE_SIZE - sizeof(unsigned long); 429 pages * PAGE_SIZE - sizeof(unsigned long);
430 return(tracer(start_kernel_proc, sp)); 430 return(tracer(start_kernel_proc, sp));
431} 431}
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 73747ac19774..e2d3ca445ef5 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -243,10 +243,6 @@ static int __init mode_tt_setup(char *line, int *add)
243 return(0); 243 return(0);
244} 244}
245 245
246#else
247
248#error Either CONFIG_MODE_TT or CONFIG_MODE_SKAS must be enabled
249
250#endif 246#endif
251#endif 247#endif
252#endif 248#endif
diff --git a/arch/v850/kernel/process.c b/arch/v850/kernel/process.c
index 39cf247cdae4..eb909937958b 100644
--- a/arch/v850/kernel/process.c
+++ b/arch/v850/kernel/process.c
@@ -114,7 +114,7 @@ int copy_thread (int nr, unsigned long clone_flags,
114 struct task_struct *p, struct pt_regs *regs) 114 struct task_struct *p, struct pt_regs *regs)
115{ 115{
116 /* Start pushing stuff from the top of the child's kernel stack. */ 116 /* Start pushing stuff from the top of the child's kernel stack. */
117 unsigned long orig_ksp = (unsigned long)p->thread_info + THREAD_SIZE; 117 unsigned long orig_ksp = task_tos(p);
118 unsigned long ksp = orig_ksp; 118 unsigned long ksp = orig_ksp;
119 /* We push two `state save' stack fames (see entry.S) on the new 119 /* We push two `state save' stack fames (see entry.S) on the new
120 kernel stack: 120 kernel stack:
@@ -164,30 +164,6 @@ int copy_thread (int nr, unsigned long clone_flags,
164} 164}
165 165
166/* 166/*
167 * fill in the user structure for a core dump..
168 */
169void dump_thread (struct pt_regs *regs, struct user *dump)
170{
171#if 0 /* Later. XXX */
172 dump->magic = CMAGIC;
173 dump->start_code = 0;
174 dump->start_stack = regs->gpr[GPR_SP];
175 dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
176 dump->u_dsize = ((unsigned long) (current->mm->brk +
177 (PAGE_SIZE-1))) >> PAGE_SHIFT;
178 dump->u_dsize -= dump->u_tsize;
179 dump->u_ssize = 0;
180
181 if (dump->start_stack < TASK_SIZE)
182 dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;
183
184 dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
185 dump->regs = *regs;
186 dump->u_fpvalid = 0;
187#endif
188}
189
190/*
191 * sys_execve() executes a new program. 167 * sys_execve() executes a new program.
192 */ 168 */
193int sys_execve (char *name, char **argv, char **envp, struct pt_regs *regs) 169int sys_execve (char *name, char **argv, char **envp, struct pt_regs *regs)
diff --git a/arch/v850/kernel/ptrace.c b/arch/v850/kernel/ptrace.c
index 18492d02aaf6..67e057509664 100644
--- a/arch/v850/kernel/ptrace.c
+++ b/arch/v850/kernel/ptrace.c
@@ -58,7 +58,7 @@ static v850_reg_t *reg_save_addr (unsigned reg_offs, struct task_struct *t)
58 regs = thread_saved_regs (t); 58 regs = thread_saved_regs (t);
59 else 59 else
60 /* Register saved during kernel entry (or not available). */ 60 /* Register saved during kernel entry (or not available). */
61 regs = task_regs (t); 61 regs = task_pt_regs (t);
62 62
63 return (v850_reg_t *)((char *)regs + reg_offs); 63 return (v850_reg_t *)((char *)regs + reg_offs);
64} 64}
diff --git a/arch/v850/kernel/v850_ksyms.c b/arch/v850/kernel/v850_ksyms.c
index 0ca64900dd91..8ffc29c1c89d 100644
--- a/arch/v850/kernel/v850_ksyms.c
+++ b/arch/v850/kernel/v850_ksyms.c
@@ -21,8 +21,6 @@ extern void *trap_table;
21EXPORT_SYMBOL (trap_table); 21EXPORT_SYMBOL (trap_table);
22 22
23/* platform dependent support */ 23/* platform dependent support */
24extern void dump_thread (struct pt_regs *, struct user *);
25EXPORT_SYMBOL (dump_thread);
26EXPORT_SYMBOL (kernel_thread); 24EXPORT_SYMBOL (kernel_thread);
27EXPORT_SYMBOL (enable_irq); 25EXPORT_SYMBOL (enable_irq);
28EXPORT_SYMBOL (disable_irq); 26EXPORT_SYMBOL (disable_irq);
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 4f3e925962c3..2efc4be22709 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -69,12 +69,34 @@ config ARCH_MAY_HAVE_PC_FDC
69 bool 69 bool
70 default y 70 default y
71 71
72config DMI
73 bool
74 default y
75
72source "init/Kconfig" 76source "init/Kconfig"
73 77
74 78
75menu "Processor type and features" 79menu "Processor type and features"
76 80
77choice 81choice
82 prompt "Subarchitecture Type"
83 default X86_PC
84
85config X86_PC
86 bool "PC-compatible"
87 help
88 Choose this option if your computer is a standard PC or compatible.
89
90config X86_VSMP
91 bool "Support for ScaleMP vSMP"
92 help
93 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
94 supposed to run on these EM64T-based machines. Only choose this option
95 if you have one of these machines.
96
97endchoice
98
99choice
78 prompt "Processor family" 100 prompt "Processor family"
79 default MK8 101 default MK8
80 102
@@ -347,32 +369,24 @@ config HPET_EMULATE_RTC
347 depends on HPET_TIMER && RTC=y 369 depends on HPET_TIMER && RTC=y
348 370
349config GART_IOMMU 371config GART_IOMMU
350 bool "IOMMU support" 372 bool "K8 GART IOMMU support"
351 default y 373 default y
374 select SWIOTLB
352 depends on PCI 375 depends on PCI
353 help 376 help
354 Support the IOMMU. Needed to run systems with more than 3GB of memory 377 Support the IOMMU. Needed to run systems with more than 3GB of memory
355 properly with 32-bit PCI devices that do not support DAC (Double Address 378 properly with 32-bit PCI devices that do not support DAC (Double Address
356 Cycle). The IOMMU can be turned off at runtime with the iommu=off parameter. 379 Cycle). The IOMMU can be turned off at runtime with the iommu=off parameter.
357 Normally the kernel will take the right choice by itself. 380 Normally the kernel will take the right choice by itself.
358 This option includes a driver for the AMD Opteron/Athlon64 IOMMU 381 This option includes a driver for the AMD Opteron/Athlon64 northbridge IOMMU
359 and a software emulation used on some other systems. 382 and a software emulation used on other systems.
360 If unsure, say Y. 383 If unsure, say Y.
361 384
362# need this always enabled with GART_IOMMU for the VIA workaround 385# need this always enabled with GART_IOMMU for the VIA workaround
363config SWIOTLB 386config SWIOTLB
364 bool
365 depends on GART_IOMMU
366 default y
367
368config DUMMY_IOMMU
369 bool 387 bool
370 depends on !GART_IOMMU && !SWIOTLB
371 default y 388 default y
372 help 389 depends on GART_IOMMU
373 Don't use IOMMU code. This will cause problems when you have more than 4GB
374 of memory and any 32-bit devices. Don't turn on unless you know what you
375 are doing.
376 390
377config X86_MCE 391config X86_MCE
378 bool "Machine check support" if EMBEDDED 392 bool "Machine check support" if EMBEDDED
@@ -399,17 +413,6 @@ config X86_MCE_AMD
399 Additional support for AMD specific MCE features such as 413 Additional support for AMD specific MCE features such as
400 the DRAM Error Threshold. 414 the DRAM Error Threshold.
401 415
402config PHYSICAL_START
403 hex "Physical address where the kernel is loaded" if EMBEDDED
404 default "0x100000"
405 help
406 This gives the physical address where the kernel is loaded.
407 Primarily used in the case of kexec on panic where the
408 fail safe kernel needs to run at a different address than
409 the panic-ed kernel.
410
411 Don't change this unless you know what you are doing.
412
413config KEXEC 416config KEXEC
414 bool "kexec system call (EXPERIMENTAL)" 417 bool "kexec system call (EXPERIMENTAL)"
415 depends on EXPERIMENTAL 418 depends on EXPERIMENTAL
@@ -427,6 +430,31 @@ config KEXEC
427 support. As of this writing the exact hardware interface is 430 support. As of this writing the exact hardware interface is
428 strongly in flux, so no good recommendation can be made. 431 strongly in flux, so no good recommendation can be made.
429 432
433config CRASH_DUMP
434 bool "kernel crash dumps (EXPERIMENTAL)"
435 depends on EXPERIMENTAL
436 help
437 Generate crash dump after being started by kexec.
438
439config PHYSICAL_START
440 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
441 default "0x1000000" if CRASH_DUMP
442 default "0x100000"
443 help
444 This gives the physical address where the kernel is loaded. Normally
445 for regular kernels this value is 0x100000 (1MB). But in the case
446 of kexec on panic the fail safe kernel needs to run at a different
447 address than the panic-ed kernel. This option is used to set the load
448 address for kernels used to capture crash dump on being kexec'ed
449 after panic. The default value for crash dump kernels is
450 0x1000000 (16MB). This can also be set based on the "X" value as
451 specified in the "crashkernel=YM@XM" command line boot parameter
452 passed to the panic-ed kernel. Typically this parameter is set as
453 crashkernel=64M@16M. Please take a look at
454 Documentation/kdump/kdump.txt for more details about crash dumps.
455
456 Don't change this unless you know what you are doing.
457
430config SECCOMP 458config SECCOMP
431 bool "Enable seccomp to safely compute untrusted bytecode" 459 bool "Enable seccomp to safely compute untrusted bytecode"
432 depends on PROC_FS 460 depends on PROC_FS
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index a9cd42e61828..d7fd46479c55 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -31,6 +31,7 @@ cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
31cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) 31cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
32CFLAGS += $(cflags-y) 32CFLAGS += $(cflags-y)
33 33
34CFLAGS += -m64
34CFLAGS += -mno-red-zone 35CFLAGS += -mno-red-zone
35CFLAGS += -mcmodel=kernel 36CFLAGS += -mcmodel=kernel
36CFLAGS += -pipe 37CFLAGS += -pipe
@@ -38,8 +39,10 @@ CFLAGS += -pipe
38# actually it makes the kernel smaller too. 39# actually it makes the kernel smaller too.
39CFLAGS += -fno-reorder-blocks 40CFLAGS += -fno-reorder-blocks
40CFLAGS += -Wno-sign-compare 41CFLAGS += -Wno-sign-compare
41ifneq ($(CONFIG_DEBUG_INFO),y) 42ifneq ($(CONFIG_UNWIND_INFO),y)
42CFLAGS += -fno-asynchronous-unwind-tables 43CFLAGS += -fno-asynchronous-unwind-tables
44endif
45ifneq ($(CONFIG_DEBUG_INFO),y)
43# -fweb shrinks the kernel a bit, but the difference is very small 46# -fweb shrinks the kernel a bit, but the difference is very small
44# it also messes up debugging, so don't use it for now. 47# it also messes up debugging, so don't use it for now.
45#CFLAGS += $(call cc-option,-fweb) 48#CFLAGS += $(call cc-option,-fweb)
@@ -50,6 +53,8 @@ CFLAGS += $(call cc-option,-funit-at-a-time)
50# prevent gcc from generating any FP code by mistake 53# prevent gcc from generating any FP code by mistake
51CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,) 54CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
52 55
56AFLAGS += -m64
57
53head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o 58head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
54 59
55libs-y += arch/x86_64/lib/ 60libs-y += arch/x86_64/lib/
@@ -80,9 +85,12 @@ bzlilo: vmlinux
80bzdisk: vmlinux 85bzdisk: vmlinux
81 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk 86 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk
82 87
83install fdimage fdimage144 fdimage288: vmlinux 88fdimage fdimage144 fdimage288: vmlinux
84 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ 89 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
85 90
91install:
92 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
93
86archclean: 94archclean:
87 $(Q)$(MAKE) $(clean)=$(boot) 95 $(Q)$(MAKE) $(clean)=$(boot)
88 96
diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
index 18c6e915d69b..29f8396ed151 100644
--- a/arch/x86_64/boot/Makefile
+++ b/arch/x86_64/boot/Makefile
@@ -98,5 +98,5 @@ zlilo: $(BOOTIMAGE)
98 cp System.map $(INSTALL_PATH)/ 98 cp System.map $(INSTALL_PATH)/
99 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi 99 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
100 100
101install: $(BOOTIMAGE) 101install:
102 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" 102 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
diff --git a/arch/x86_64/boot/install.sh b/arch/x86_64/boot/install.sh
index 198af15a7758..baaa2369bdb8 100644
--- a/arch/x86_64/boot/install.sh
+++ b/arch/x86_64/boot/install.sh
@@ -1,40 +1,2 @@
1#!/bin/sh 1#!/bin/sh
2# 2. $srctree/arch/i386/boot/install.sh
3# arch/x86_64/boot/install.sh
4#
5# This file is subject to the terms and conditions of the GNU General Public
6# License. See the file "COPYING" in the main directory of this archive
7# for more details.
8#
9# Copyright (C) 1995 by Linus Torvalds
10#
11# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
12#
13# "make install" script for i386 architecture
14#
15# Arguments:
16# $1 - kernel version
17# $2 - kernel image file
18# $3 - kernel map file
19# $4 - default install path (blank if root directory)
20#
21
22# User may have a custom install script
23
24if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
25if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi
26
27# Default install - same as make zlilo
28
29if [ -f $4/vmlinuz ]; then
30 mv $4/vmlinuz $4/vmlinuz.old
31fi
32
33if [ -f $4/System.map ]; then
34 mv $4/System.map $4/System.old
35fi
36
37cat $2 > $4/vmlinuz
38cp $3 $4/System.map
39
40if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 5d56542fb68f..054dcd8a5e9d 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-git7 3# Linux kernel version: 2.6.15-git7
4# Sat Nov 5 15:55:50 2005 4# Wed Jan 11 11:57:36 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -15,6 +15,7 @@ CONFIG_EARLY_PRINTK=y
15CONFIG_GENERIC_ISA_DMA=y 15CONFIG_GENERIC_ISA_DMA=y
16CONFIG_GENERIC_IOMAP=y 16CONFIG_GENERIC_IOMAP=y
17CONFIG_ARCH_MAY_HAVE_PC_FDC=y 17CONFIG_ARCH_MAY_HAVE_PC_FDC=y
18CONFIG_DMI=y
18 19
19# 20#
20# Code maturity level options 21# Code maturity level options
@@ -35,18 +36,21 @@ CONFIG_POSIX_MQUEUE=y
35# CONFIG_BSD_PROCESS_ACCT is not set 36# CONFIG_BSD_PROCESS_ACCT is not set
36CONFIG_SYSCTL=y 37CONFIG_SYSCTL=y
37# CONFIG_AUDIT is not set 38# CONFIG_AUDIT is not set
38CONFIG_HOTPLUG=y
39CONFIG_KOBJECT_UEVENT=y
40CONFIG_IKCONFIG=y 39CONFIG_IKCONFIG=y
41CONFIG_IKCONFIG_PROC=y 40CONFIG_IKCONFIG_PROC=y
42# CONFIG_CPUSETS is not set 41# CONFIG_CPUSETS is not set
43CONFIG_INITRAMFS_SOURCE="" 42CONFIG_INITRAMFS_SOURCE=""
43CONFIG_UID16=y
44CONFIG_VM86=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
44# CONFIG_EMBEDDED is not set 46# CONFIG_EMBEDDED is not set
45CONFIG_KALLSYMS=y 47CONFIG_KALLSYMS=y
46CONFIG_KALLSYMS_ALL=y 48CONFIG_KALLSYMS_ALL=y
47# CONFIG_KALLSYMS_EXTRA_PASS is not set 49# CONFIG_KALLSYMS_EXTRA_PASS is not set
50CONFIG_HOTPLUG=y
48CONFIG_PRINTK=y 51CONFIG_PRINTK=y
49CONFIG_BUG=y 52CONFIG_BUG=y
53CONFIG_ELF_CORE=y
50CONFIG_BASE_FULL=y 54CONFIG_BASE_FULL=y
51CONFIG_FUTEX=y 55CONFIG_FUTEX=y
52CONFIG_EPOLL=y 56CONFIG_EPOLL=y
@@ -55,8 +59,10 @@ CONFIG_CC_ALIGN_FUNCTIONS=0
55CONFIG_CC_ALIGN_LABELS=0 59CONFIG_CC_ALIGN_LABELS=0
56CONFIG_CC_ALIGN_LOOPS=0 60CONFIG_CC_ALIGN_LOOPS=0
57CONFIG_CC_ALIGN_JUMPS=0 61CONFIG_CC_ALIGN_JUMPS=0
62CONFIG_SLAB=y
58# CONFIG_TINY_SHMEM is not set 63# CONFIG_TINY_SHMEM is not set
59CONFIG_BASE_SMALL=0 64CONFIG_BASE_SMALL=0
65# CONFIG_SLOB is not set
60 66
61# 67#
62# Loadable module support 68# Loadable module support
@@ -71,8 +77,28 @@ CONFIG_OBSOLETE_MODPARM=y
71CONFIG_STOP_MACHINE=y 77CONFIG_STOP_MACHINE=y
72 78
73# 79#
80# Block layer
81#
82CONFIG_LBD=y
83
84#
85# IO Schedulers
86#
87CONFIG_IOSCHED_NOOP=y
88# CONFIG_IOSCHED_AS is not set
89CONFIG_IOSCHED_DEADLINE=y
90CONFIG_IOSCHED_CFQ=y
91# CONFIG_DEFAULT_AS is not set
92# CONFIG_DEFAULT_DEADLINE is not set
93CONFIG_DEFAULT_CFQ=y
94# CONFIG_DEFAULT_NOOP is not set
95CONFIG_DEFAULT_IOSCHED="cfq"
96
97#
74# Processor type and features 98# Processor type and features
75# 99#
100CONFIG_X86_PC=y
101# CONFIG_X86_VSMP is not set
76# CONFIG_MK8 is not set 102# CONFIG_MK8 is not set
77# CONFIG_MPSC is not set 103# CONFIG_MPSC is not set
78CONFIG_GENERIC_CPU=y 104CONFIG_GENERIC_CPU=y
@@ -89,14 +115,14 @@ CONFIG_X86_LOCAL_APIC=y
89CONFIG_MTRR=y 115CONFIG_MTRR=y
90CONFIG_SMP=y 116CONFIG_SMP=y
91CONFIG_SCHED_SMT=y 117CONFIG_SCHED_SMT=y
92CONFIG_PREEMPT_NONE=y 118# CONFIG_PREEMPT_NONE is not set
93# CONFIG_PREEMPT_VOLUNTARY is not set 119CONFIG_PREEMPT_VOLUNTARY=y
94# CONFIG_PREEMPT is not set 120# CONFIG_PREEMPT is not set
95CONFIG_PREEMPT_BKL=y 121CONFIG_PREEMPT_BKL=y
96CONFIG_NUMA=y 122CONFIG_NUMA=y
97CONFIG_K8_NUMA=y 123CONFIG_K8_NUMA=y
98CONFIG_X86_64_ACPI_NUMA=y 124CONFIG_X86_64_ACPI_NUMA=y
99# CONFIG_NUMA_EMU is not set 125CONFIG_NUMA_EMU=y
100CONFIG_ARCH_DISCONTIGMEM_ENABLE=y 126CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
101CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y 127CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
102CONFIG_ARCH_SPARSEMEM_ENABLE=y 128CONFIG_ARCH_SPARSEMEM_ENABLE=y
@@ -109,6 +135,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
109CONFIG_NEED_MULTIPLE_NODES=y 135CONFIG_NEED_MULTIPLE_NODES=y
110# CONFIG_SPARSEMEM_STATIC is not set 136# CONFIG_SPARSEMEM_STATIC is not set
111CONFIG_SPLIT_PTLOCK_CPUS=4 137CONFIG_SPLIT_PTLOCK_CPUS=4
138CONFIG_MIGRATION=y
112CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 139CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
113CONFIG_NR_CPUS=32 140CONFIG_NR_CPUS=32
114CONFIG_HOTPLUG_CPU=y 141CONFIG_HOTPLUG_CPU=y
@@ -120,8 +147,9 @@ CONFIG_SWIOTLB=y
120CONFIG_X86_MCE=y 147CONFIG_X86_MCE=y
121CONFIG_X86_MCE_INTEL=y 148CONFIG_X86_MCE_INTEL=y
122CONFIG_X86_MCE_AMD=y 149CONFIG_X86_MCE_AMD=y
123CONFIG_PHYSICAL_START=0x100000
124# CONFIG_KEXEC is not set 150# CONFIG_KEXEC is not set
151# CONFIG_CRASH_DUMP is not set
152CONFIG_PHYSICAL_START=0x100000
125CONFIG_SECCOMP=y 153CONFIG_SECCOMP=y
126# CONFIG_HZ_100 is not set 154# CONFIG_HZ_100 is not set
127CONFIG_HZ_250=y 155CONFIG_HZ_250=y
@@ -136,6 +164,7 @@ CONFIG_GENERIC_PENDING_IRQ=y
136# Power management options 164# Power management options
137# 165#
138CONFIG_PM=y 166CONFIG_PM=y
167# CONFIG_PM_LEGACY is not set
139# CONFIG_PM_DEBUG is not set 168# CONFIG_PM_DEBUG is not set
140CONFIG_SOFTWARE_SUSPEND=y 169CONFIG_SOFTWARE_SUSPEND=y
141CONFIG_PM_STD_PARTITION="" 170CONFIG_PM_STD_PARTITION=""
@@ -152,7 +181,7 @@ CONFIG_ACPI_AC=y
152CONFIG_ACPI_BATTERY=y 181CONFIG_ACPI_BATTERY=y
153CONFIG_ACPI_BUTTON=y 182CONFIG_ACPI_BUTTON=y
154# CONFIG_ACPI_VIDEO is not set 183# CONFIG_ACPI_VIDEO is not set
155CONFIG_ACPI_HOTKEY=m 184# CONFIG_ACPI_HOTKEY is not set
156CONFIG_ACPI_FAN=y 185CONFIG_ACPI_FAN=y
157CONFIG_ACPI_PROCESSOR=y 186CONFIG_ACPI_PROCESSOR=y
158CONFIG_ACPI_HOTPLUG_CPU=y 187CONFIG_ACPI_HOTPLUG_CPU=y
@@ -205,7 +234,7 @@ CONFIG_PCI=y
205CONFIG_PCI_DIRECT=y 234CONFIG_PCI_DIRECT=y
206CONFIG_PCI_MMCONFIG=y 235CONFIG_PCI_MMCONFIG=y
207CONFIG_UNORDERED_IO=y 236CONFIG_UNORDERED_IO=y
208# CONFIG_PCIEPORTBUS is not set 237CONFIG_PCIEPORTBUS=y
209CONFIG_PCI_MSI=y 238CONFIG_PCI_MSI=y
210# CONFIG_PCI_LEGACY_PROC is not set 239# CONFIG_PCI_LEGACY_PROC is not set
211# CONFIG_PCI_DEBUG is not set 240# CONFIG_PCI_DEBUG is not set
@@ -229,7 +258,6 @@ CONFIG_IA32_EMULATION=y
229CONFIG_IA32_AOUT=y 258CONFIG_IA32_AOUT=y
230CONFIG_COMPAT=y 259CONFIG_COMPAT=y
231CONFIG_SYSVIPC_COMPAT=y 260CONFIG_SYSVIPC_COMPAT=y
232CONFIG_UID16=y
233 261
234# 262#
235# Networking 263# Networking
@@ -294,8 +322,11 @@ CONFIG_IPV6=y
294# CONFIG_NET_DIVERT is not set 322# CONFIG_NET_DIVERT is not set
295# CONFIG_ECONET is not set 323# CONFIG_ECONET is not set
296# CONFIG_WAN_ROUTER is not set 324# CONFIG_WAN_ROUTER is not set
325
326#
327# QoS and/or fair queueing
328#
297# CONFIG_NET_SCHED is not set 329# CONFIG_NET_SCHED is not set
298# CONFIG_NET_CLS_ROUTE is not set
299 330
300# 331#
301# Network testing 332# Network testing
@@ -315,7 +346,7 @@ CONFIG_IPV6=y
315# 346#
316CONFIG_STANDALONE=y 347CONFIG_STANDALONE=y
317CONFIG_PREVENT_FIRMWARE_BUILD=y 348CONFIG_PREVENT_FIRMWARE_BUILD=y
318# CONFIG_FW_LOADER is not set 349CONFIG_FW_LOADER=y
319# CONFIG_DEBUG_DRIVER is not set 350# CONFIG_DEBUG_DRIVER is not set
320 351
321# 352#
@@ -356,21 +387,7 @@ CONFIG_BLK_DEV_RAM=y
356CONFIG_BLK_DEV_RAM_COUNT=16 387CONFIG_BLK_DEV_RAM_COUNT=16
357CONFIG_BLK_DEV_RAM_SIZE=4096 388CONFIG_BLK_DEV_RAM_SIZE=4096
358CONFIG_BLK_DEV_INITRD=y 389CONFIG_BLK_DEV_INITRD=y
359CONFIG_LBD=y
360# CONFIG_CDROM_PKTCDVD is not set 390# CONFIG_CDROM_PKTCDVD is not set
361
362#
363# IO Schedulers
364#
365CONFIG_IOSCHED_NOOP=y
366# CONFIG_IOSCHED_AS is not set
367CONFIG_IOSCHED_DEADLINE=y
368CONFIG_IOSCHED_CFQ=y
369# CONFIG_DEFAULT_AS is not set
370CONFIG_DEFAULT_DEADLINE=y
371# CONFIG_DEFAULT_CFQ is not set
372# CONFIG_DEFAULT_NOOP is not set
373CONFIG_DEFAULT_IOSCHED="cfq"
374# CONFIG_ATA_OVER_ETH is not set 391# CONFIG_ATA_OVER_ETH is not set
375 392
376# 393#
@@ -410,7 +427,7 @@ CONFIG_IDEDMA_PCI_AUTO=y
410# CONFIG_BLK_DEV_AEC62XX is not set 427# CONFIG_BLK_DEV_AEC62XX is not set
411# CONFIG_BLK_DEV_ALI15X3 is not set 428# CONFIG_BLK_DEV_ALI15X3 is not set
412CONFIG_BLK_DEV_AMD74XX=y 429CONFIG_BLK_DEV_AMD74XX=y
413# CONFIG_BLK_DEV_ATIIXP is not set 430CONFIG_BLK_DEV_ATIIXP=y
414# CONFIG_BLK_DEV_CMD64X is not set 431# CONFIG_BLK_DEV_CMD64X is not set
415# CONFIG_BLK_DEV_TRIFLEX is not set 432# CONFIG_BLK_DEV_TRIFLEX is not set
416# CONFIG_BLK_DEV_CY82C693 is not set 433# CONFIG_BLK_DEV_CY82C693 is not set
@@ -458,20 +475,21 @@ CONFIG_BLK_DEV_SD=y
458# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 475# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
459# 476#
460# CONFIG_SCSI_MULTI_LUN is not set 477# CONFIG_SCSI_MULTI_LUN is not set
461# CONFIG_SCSI_CONSTANTS is not set 478CONFIG_SCSI_CONSTANTS=y
462# CONFIG_SCSI_LOGGING is not set 479# CONFIG_SCSI_LOGGING is not set
463 480
464# 481#
465# SCSI Transport Attributes 482# SCSI Transport Attributes
466# 483#
467CONFIG_SCSI_SPI_ATTRS=y 484CONFIG_SCSI_SPI_ATTRS=y
468# CONFIG_SCSI_FC_ATTRS is not set 485CONFIG_SCSI_FC_ATTRS=y
469# CONFIG_SCSI_ISCSI_ATTRS is not set 486# CONFIG_SCSI_ISCSI_ATTRS is not set
470# CONFIG_SCSI_SAS_ATTRS is not set 487# CONFIG_SCSI_SAS_ATTRS is not set
471 488
472# 489#
473# SCSI low-level drivers 490# SCSI low-level drivers
474# 491#
492# CONFIG_ISCSI_TCP is not set
475# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 493# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
476# CONFIG_SCSI_3W_9XXX is not set 494# CONFIG_SCSI_3W_9XXX is not set
477# CONFIG_SCSI_ACARD is not set 495# CONFIG_SCSI_ACARD is not set
@@ -485,11 +503,13 @@ CONFIG_AIC79XX_RESET_DELAY_MS=4000
485# CONFIG_AIC79XX_DEBUG_ENABLE is not set 503# CONFIG_AIC79XX_DEBUG_ENABLE is not set
486CONFIG_AIC79XX_DEBUG_MASK=0 504CONFIG_AIC79XX_DEBUG_MASK=0
487# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set 505# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
488# CONFIG_MEGARAID_NEWGEN is not set 506CONFIG_MEGARAID_NEWGEN=y
507CONFIG_MEGARAID_MM=y
508CONFIG_MEGARAID_MAILBOX=y
489# CONFIG_MEGARAID_LEGACY is not set 509# CONFIG_MEGARAID_LEGACY is not set
490# CONFIG_MEGARAID_SAS is not set 510CONFIG_MEGARAID_SAS=y
491CONFIG_SCSI_SATA=y 511CONFIG_SCSI_SATA=y
492# CONFIG_SCSI_SATA_AHCI is not set 512CONFIG_SCSI_SATA_AHCI=y
493# CONFIG_SCSI_SATA_SVW is not set 513# CONFIG_SCSI_SATA_SVW is not set
494CONFIG_SCSI_ATA_PIIX=y 514CONFIG_SCSI_ATA_PIIX=y
495# CONFIG_SCSI_SATA_MV is not set 515# CONFIG_SCSI_SATA_MV is not set
@@ -498,7 +518,7 @@ CONFIG_SCSI_SATA_NV=y
498# CONFIG_SCSI_SATA_QSTOR is not set 518# CONFIG_SCSI_SATA_QSTOR is not set
499# CONFIG_SCSI_SATA_PROMISE is not set 519# CONFIG_SCSI_SATA_PROMISE is not set
500# CONFIG_SCSI_SATA_SX4 is not set 520# CONFIG_SCSI_SATA_SX4 is not set
501# CONFIG_SCSI_SATA_SIL is not set 521CONFIG_SCSI_SATA_SIL=y
502# CONFIG_SCSI_SATA_SIL24 is not set 522# CONFIG_SCSI_SATA_SIL24 is not set
503# CONFIG_SCSI_SATA_SIS is not set 523# CONFIG_SCSI_SATA_SIS is not set
504# CONFIG_SCSI_SATA_ULI is not set 524# CONFIG_SCSI_SATA_ULI is not set
@@ -518,12 +538,7 @@ CONFIG_SCSI_SATA_INTEL_COMBINED=y
518# CONFIG_SCSI_QLOGIC_FC is not set 538# CONFIG_SCSI_QLOGIC_FC is not set
519# CONFIG_SCSI_QLOGIC_1280 is not set 539# CONFIG_SCSI_QLOGIC_1280 is not set
520CONFIG_SCSI_QLA2XXX=y 540CONFIG_SCSI_QLA2XXX=y
521# CONFIG_SCSI_QLA21XX is not set 541# CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE is not set
522# CONFIG_SCSI_QLA22XX is not set
523# CONFIG_SCSI_QLA2300 is not set
524# CONFIG_SCSI_QLA2322 is not set
525# CONFIG_SCSI_QLA6312 is not set
526# CONFIG_SCSI_QLA24XX is not set
527# CONFIG_SCSI_LPFC is not set 542# CONFIG_SCSI_LPFC is not set
528# CONFIG_SCSI_DC395x is not set 543# CONFIG_SCSI_DC395x is not set
529# CONFIG_SCSI_DC390T is not set 544# CONFIG_SCSI_DC390T is not set
@@ -633,6 +648,7 @@ CONFIG_E1000=y
633# CONFIG_R8169 is not set 648# CONFIG_R8169 is not set
634# CONFIG_SIS190 is not set 649# CONFIG_SIS190 is not set
635# CONFIG_SKGE is not set 650# CONFIG_SKGE is not set
651# CONFIG_SKY2 is not set
636# CONFIG_SK98LIN is not set 652# CONFIG_SK98LIN is not set
637# CONFIG_VIA_VELOCITY is not set 653# CONFIG_VIA_VELOCITY is not set
638CONFIG_TIGON3=y 654CONFIG_TIGON3=y
@@ -645,7 +661,6 @@ CONFIG_TIGON3=y
645# CONFIG_IXGB is not set 661# CONFIG_IXGB is not set
646CONFIG_S2IO=m 662CONFIG_S2IO=m
647# CONFIG_S2IO_NAPI is not set 663# CONFIG_S2IO_NAPI is not set
648# CONFIG_2BUFF_MODE is not set
649 664
650# 665#
651# Token Ring devices 666# Token Ring devices
@@ -744,6 +759,7 @@ CONFIG_SERIAL_8250=y
744CONFIG_SERIAL_8250_CONSOLE=y 759CONFIG_SERIAL_8250_CONSOLE=y
745# CONFIG_SERIAL_8250_ACPI is not set 760# CONFIG_SERIAL_8250_ACPI is not set
746CONFIG_SERIAL_8250_NR_UARTS=4 761CONFIG_SERIAL_8250_NR_UARTS=4
762CONFIG_SERIAL_8250_RUNTIME_UARTS=4
747# CONFIG_SERIAL_8250_EXTENDED is not set 763# CONFIG_SERIAL_8250_EXTENDED is not set
748 764
749# 765#
@@ -751,7 +767,6 @@ CONFIG_SERIAL_8250_NR_UARTS=4
751# 767#
752CONFIG_SERIAL_CORE=y 768CONFIG_SERIAL_CORE=y
753CONFIG_SERIAL_CORE_CONSOLE=y 769CONFIG_SERIAL_CORE_CONSOLE=y
754# CONFIG_SERIAL_JSM is not set
755CONFIG_UNIX98_PTYS=y 770CONFIG_UNIX98_PTYS=y
756CONFIG_LEGACY_PTYS=y 771CONFIG_LEGACY_PTYS=y
757CONFIG_LEGACY_PTY_COUNT=256 772CONFIG_LEGACY_PTY_COUNT=256
@@ -817,10 +832,10 @@ CONFIG_AGP_INTEL=y
817# CONFIG_DRM is not set 832# CONFIG_DRM is not set
818# CONFIG_MWAVE is not set 833# CONFIG_MWAVE is not set
819CONFIG_RAW_DRIVER=y 834CONFIG_RAW_DRIVER=y
835CONFIG_MAX_RAW_DEVS=256
820CONFIG_HPET=y 836CONFIG_HPET=y
821# CONFIG_HPET_RTC_IRQ is not set 837# CONFIG_HPET_RTC_IRQ is not set
822CONFIG_HPET_MMAP=y 838CONFIG_HPET_MMAP=y
823CONFIG_MAX_RAW_DEVS=256
824# CONFIG_HANGCHECK_TIMER is not set 839# CONFIG_HANGCHECK_TIMER is not set
825 840
826# 841#
@@ -892,6 +907,7 @@ CONFIG_SOUND=y
892# Open Sound System 907# Open Sound System
893# 908#
894CONFIG_SOUND_PRIME=y 909CONFIG_SOUND_PRIME=y
910CONFIG_OBSOLETE_OSS_DRIVER=y
895# CONFIG_SOUND_BT878 is not set 911# CONFIG_SOUND_BT878 is not set
896# CONFIG_SOUND_CMPCI is not set 912# CONFIG_SOUND_CMPCI is not set
897# CONFIG_SOUND_EMU10K1 is not set 913# CONFIG_SOUND_EMU10K1 is not set
@@ -968,7 +984,8 @@ CONFIG_USB_STORAGE=y
968# CONFIG_USB_STORAGE_SDDR09 is not set 984# CONFIG_USB_STORAGE_SDDR09 is not set
969# CONFIG_USB_STORAGE_SDDR55 is not set 985# CONFIG_USB_STORAGE_SDDR55 is not set
970# CONFIG_USB_STORAGE_JUMPSHOT is not set 986# CONFIG_USB_STORAGE_JUMPSHOT is not set
971# CONFIG_USB_STORAGE_ONETOUCH is not set 987# CONFIG_USB_STORAGE_ALAUDA is not set
988# CONFIG_USB_LIBUSUAL is not set
972 989
973# 990#
974# USB Input Devices 991# USB Input Devices
@@ -988,6 +1005,7 @@ CONFIG_USB_HIDINPUT=y
988# CONFIG_USB_YEALINK is not set 1005# CONFIG_USB_YEALINK is not set
989# CONFIG_USB_XPAD is not set 1006# CONFIG_USB_XPAD is not set
990# CONFIG_USB_ATI_REMOTE is not set 1007# CONFIG_USB_ATI_REMOTE is not set
1008# CONFIG_USB_ATI_REMOTE2 is not set
991# CONFIG_USB_KEYSPAN_REMOTE is not set 1009# CONFIG_USB_KEYSPAN_REMOTE is not set
992# CONFIG_USB_APPLETOUCH is not set 1010# CONFIG_USB_APPLETOUCH is not set
993 1011
@@ -1097,6 +1115,7 @@ CONFIG_REISERFS_FS_POSIX_ACL=y
1097# CONFIG_JFS_FS is not set 1115# CONFIG_JFS_FS is not set
1098CONFIG_FS_POSIX_ACL=y 1116CONFIG_FS_POSIX_ACL=y
1099# CONFIG_XFS_FS is not set 1117# CONFIG_XFS_FS is not set
1118# CONFIG_OCFS2_FS is not set
1100# CONFIG_MINIX_FS is not set 1119# CONFIG_MINIX_FS is not set
1101# CONFIG_ROMFS_FS is not set 1120# CONFIG_ROMFS_FS is not set
1102CONFIG_INOTIFY=y 1121CONFIG_INOTIFY=y
@@ -1135,6 +1154,7 @@ CONFIG_HUGETLBFS=y
1135CONFIG_HUGETLB_PAGE=y 1154CONFIG_HUGETLB_PAGE=y
1136CONFIG_RAMFS=y 1155CONFIG_RAMFS=y
1137CONFIG_RELAYFS_FS=y 1156CONFIG_RELAYFS_FS=y
1157# CONFIG_CONFIGFS_FS is not set
1138 1158
1139# 1159#
1140# Miscellaneous filesystems 1160# Miscellaneous filesystems
@@ -1232,21 +1252,23 @@ CONFIG_NLS_ISO8859_15=y
1232CONFIG_NLS_UTF8=y 1252CONFIG_NLS_UTF8=y
1233 1253
1234# 1254#
1235# Profiling support 1255# Instrumentation Support
1236# 1256#
1237CONFIG_PROFILING=y 1257CONFIG_PROFILING=y
1238CONFIG_OPROFILE=y 1258CONFIG_OPROFILE=y
1259CONFIG_KPROBES=y
1239 1260
1240# 1261#
1241# Kernel hacking 1262# Kernel hacking
1242# 1263#
1243# CONFIG_PRINTK_TIME is not set 1264# CONFIG_PRINTK_TIME is not set
1244CONFIG_DEBUG_KERNEL=y
1245CONFIG_MAGIC_SYSRQ=y 1265CONFIG_MAGIC_SYSRQ=y
1266CONFIG_DEBUG_KERNEL=y
1246CONFIG_LOG_BUF_SHIFT=18 1267CONFIG_LOG_BUF_SHIFT=18
1247CONFIG_DETECT_SOFTLOCKUP=y 1268CONFIG_DETECT_SOFTLOCKUP=y
1248# CONFIG_SCHEDSTATS is not set 1269# CONFIG_SCHEDSTATS is not set
1249# CONFIG_DEBUG_SLAB is not set 1270# CONFIG_DEBUG_SLAB is not set
1271# CONFIG_DEBUG_MUTEXES is not set
1250# CONFIG_DEBUG_SPINLOCK is not set 1272# CONFIG_DEBUG_SPINLOCK is not set
1251# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1273# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1252# CONFIG_DEBUG_KOBJECT is not set 1274# CONFIG_DEBUG_KOBJECT is not set
@@ -1256,8 +1278,8 @@ CONFIG_DEBUG_FS=y
1256# CONFIG_FRAME_POINTER is not set 1278# CONFIG_FRAME_POINTER is not set
1257# CONFIG_RCU_TORTURE_TEST is not set 1279# CONFIG_RCU_TORTURE_TEST is not set
1258CONFIG_INIT_DEBUG=y 1280CONFIG_INIT_DEBUG=y
1281# CONFIG_DEBUG_RODATA is not set
1259# CONFIG_IOMMU_DEBUG is not set 1282# CONFIG_IOMMU_DEBUG is not set
1260CONFIG_KPROBES=y
1261 1283
1262# 1284#
1263# Security options 1285# Security options
diff --git a/arch/x86_64/ia32/Makefile b/arch/x86_64/ia32/Makefile
index f76217d8f579..051608d55920 100644
--- a/arch/x86_64/ia32/Makefile
+++ b/arch/x86_64/ia32/Makefile
@@ -2,8 +2,7 @@
2# Makefile for the ia32 kernel emulation subsystem. 2# Makefile for the ia32 kernel emulation subsystem.
3# 3#
4 4
5obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_ioctl.o \ 5obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o tls32.o \
6 ia32_signal.o tls32.o \
7 ia32_binfmt.o fpu32.o ptrace32.o syscall32.o syscall32_syscall.o 6 ia32_binfmt.o fpu32.o ptrace32.o syscall32.o syscall32_syscall.o
8 7
9sysv-$(CONFIG_SYSVIPC) := ipc32.o 8sysv-$(CONFIG_SYSVIPC) := ipc32.o
@@ -29,4 +28,3 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
29 28
30AFLAGS_vsyscall-sysenter.o = -m32 29AFLAGS_vsyscall-sysenter.o = -m32
31AFLAGS_vsyscall-syscall.o = -m32 30AFLAGS_vsyscall-syscall.o = -m32
32CFLAGS_ia32_ioctl.o += -Ifs/
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 2b760d0d9ce2..029bddab0459 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -197,8 +197,7 @@ static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *re
197 197
198static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 198static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
199{ 199{
200 struct pt_regs *pp = (struct pt_regs *)(t->thread.rsp0); 200 struct pt_regs *pp = task_pt_regs(t);
201 --pp;
202 ELF_CORE_COPY_REGS((*elfregs), pp); 201 ELF_CORE_COPY_REGS((*elfregs), pp);
203 /* fix wrong segments */ 202 /* fix wrong segments */
204 (*elfregs)[7] = t->thread.ds; 203 (*elfregs)[7] = t->thread.ds;
@@ -217,7 +216,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
217 if (!tsk_used_math(tsk)) 216 if (!tsk_used_math(tsk))
218 return 0; 217 return 0;
219 if (!regs) 218 if (!regs)
220 regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; 219 regs = task_pt_regs(tsk);
221 if (tsk == current) 220 if (tsk == current)
222 unlazy_fpu(tsk); 221 unlazy_fpu(tsk);
223 set_fs(KERNEL_DS); 222 set_fs(KERNEL_DS);
@@ -233,7 +232,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
233static inline int 232static inline int
234elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) 233elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
235{ 234{
236 struct pt_regs *regs = ((struct pt_regs *)(t->thread.rsp0))-1; 235 struct pt_regs *regs = task_pt_regs(t);
237 if (!tsk_used_math(t)) 236 if (!tsk_used_math(t))
238 return 0; 237 return 0;
239 if (t == current) 238 if (t == current)
diff --git a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c
deleted file mode 100644
index e335bd0b637d..000000000000
--- a/arch/x86_64/ia32/ia32_ioctl.c
+++ /dev/null
@@ -1,79 +0,0 @@
1/* $Id: ia32_ioctl.c,v 1.25 2002/10/11 07:17:06 ak Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
3 *
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
7 *
8 * These routines maintain argument size conversion between 32bit and 64bit
9 * ioctls.
10 */
11
12#define INCLUDES
13#include <linux/syscalls.h>
14#include "compat_ioctl.c"
15#include <asm/ia32.h>
16
17#define CODE
18#include "compat_ioctl.c"
19
20#define RTC_IRQP_READ32 _IOR('p', 0x0b, unsigned int) /* Read IRQ rate */
21#define RTC_IRQP_SET32 _IOW('p', 0x0c, unsigned int) /* Set IRQ rate */
22#define RTC_EPOCH_READ32 _IOR('p', 0x0d, unsigned) /* Read epoch */
23#define RTC_EPOCH_SET32 _IOW('p', 0x0e, unsigned) /* Set epoch */
24
25static int rtc32_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
26{
27 unsigned long val;
28 mm_segment_t oldfs = get_fs();
29 int ret;
30
31 switch (cmd) {
32 case RTC_IRQP_READ32:
33 set_fs(KERNEL_DS);
34 ret = sys_ioctl(fd, RTC_IRQP_READ, (unsigned long)&val);
35 set_fs(oldfs);
36 if (!ret)
37 ret = put_user(val, (unsigned int __user *) arg);
38 return ret;
39
40 case RTC_IRQP_SET32:
41 cmd = RTC_IRQP_SET;
42 break;
43
44 case RTC_EPOCH_READ32:
45 set_fs(KERNEL_DS);
46 ret = sys_ioctl(fd, RTC_EPOCH_READ, (unsigned long) &val);
47 set_fs(oldfs);
48 if (!ret)
49 ret = put_user(val, (unsigned int __user *) arg);
50 return ret;
51
52 case RTC_EPOCH_SET32:
53 cmd = RTC_EPOCH_SET;
54 break;
55 }
56 return sys_ioctl(fd,cmd,arg);
57}
58
59
60#define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler) },
61#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
62
63struct ioctl_trans ioctl_start[] = {
64#include <linux/compat_ioctl.h>
65#define DECLARES
66#include "compat_ioctl.c"
67
68/* And these ioctls need translation */
69/* realtime device */
70HANDLE_IOCTL(RTC_IRQP_READ, rtc32_ioctl)
71HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl)
72HANDLE_IOCTL(RTC_IRQP_SET32, rtc32_ioctl)
73HANDLE_IOCTL(RTC_EPOCH_READ32, rtc32_ioctl)
74HANDLE_IOCTL(RTC_EPOCH_SET32, rtc32_ioctl)
75/* take care of sizeof(sizeof()) breakage */
76};
77
78int ioctl_table_size = ARRAY_SIZE(ioctl_start);
79
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index 0903cc1faef2..e0a92439f634 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -353,7 +353,6 @@ ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, struct _fpstate_ia32 __
353 struct pt_regs *regs, unsigned int mask) 353 struct pt_regs *regs, unsigned int mask)
354{ 354{
355 int tmp, err = 0; 355 int tmp, err = 0;
356 u32 eflags;
357 356
358 tmp = 0; 357 tmp = 0;
359 __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp)); 358 __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
@@ -378,10 +377,7 @@ ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, struct _fpstate_ia32 __
378 err |= __put_user(current->thread.trap_no, &sc->trapno); 377 err |= __put_user(current->thread.trap_no, &sc->trapno);
379 err |= __put_user(current->thread.error_code, &sc->err); 378 err |= __put_user(current->thread.error_code, &sc->err);
380 err |= __put_user((u32)regs->rip, &sc->eip); 379 err |= __put_user((u32)regs->rip, &sc->eip);
381 eflags = regs->eflags; 380 err |= __put_user((u32)regs->eflags, &sc->eflags);
382 if (current->ptrace & PT_PTRACED)
383 eflags &= ~TF_MASK;
384 err |= __put_user((u32)eflags, &sc->eflags);
385 err |= __put_user((u32)regs->rsp, &sc->esp_at_signal); 381 err |= __put_user((u32)regs->rsp, &sc->esp_at_signal);
386 382
387 tmp = save_i387_ia32(current, fpstate, regs, 0); 383 tmp = save_i387_ia32(current, fpstate, regs, 0);
@@ -505,13 +501,9 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
505 regs->ss = __USER32_DS; 501 regs->ss = __USER32_DS;
506 502
507 set_fs(USER_DS); 503 set_fs(USER_DS);
508 if (regs->eflags & TF_MASK) { 504 regs->eflags &= ~TF_MASK;
509 if (current->ptrace & PT_PTRACED) { 505 if (test_thread_flag(TIF_SINGLESTEP))
510 ptrace_notify(SIGTRAP); 506 ptrace_notify(SIGTRAP);
511 } else {
512 regs->eflags &= ~TF_MASK;
513 }
514 }
515 507
516#if DEBUG_SIG 508#if DEBUG_SIG
517 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", 509 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
@@ -605,13 +597,9 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
605 regs->ss = __USER32_DS; 597 regs->ss = __USER32_DS;
606 598
607 set_fs(USER_DS); 599 set_fs(USER_DS);
608 if (regs->eflags & TF_MASK) { 600 regs->eflags &= ~TF_MASK;
609 if (current->ptrace & PT_PTRACED) { 601 if (test_thread_flag(TIF_SINGLESTEP))
610 ptrace_notify(SIGTRAP); 602 ptrace_notify(SIGTRAP);
611 } else {
612 regs->eflags &= ~TF_MASK;
613 }
614 }
615 603
616#if DEBUG_SIG 604#if DEBUG_SIG
617 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", 605 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 1f0ff5adc80e..58f5bfb52c63 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -35,6 +35,18 @@
35 movq %rax,R8(%rsp) 35 movq %rax,R8(%rsp)
36 .endm 36 .endm
37 37
38 .macro CFI_STARTPROC32 simple
39 CFI_STARTPROC \simple
40 CFI_UNDEFINED r8
41 CFI_UNDEFINED r9
42 CFI_UNDEFINED r10
43 CFI_UNDEFINED r11
44 CFI_UNDEFINED r12
45 CFI_UNDEFINED r13
46 CFI_UNDEFINED r14
47 CFI_UNDEFINED r15
48 .endm
49
38/* 50/*
39 * 32bit SYSENTER instruction entry. 51 * 32bit SYSENTER instruction entry.
40 * 52 *
@@ -55,7 +67,7 @@
55 * with the int 0x80 path. 67 * with the int 0x80 path.
56 */ 68 */
57ENTRY(ia32_sysenter_target) 69ENTRY(ia32_sysenter_target)
58 CFI_STARTPROC simple 70 CFI_STARTPROC32 simple
59 CFI_DEF_CFA rsp,0 71 CFI_DEF_CFA rsp,0
60 CFI_REGISTER rsp,rbp 72 CFI_REGISTER rsp,rbp
61 swapgs 73 swapgs
@@ -92,6 +104,7 @@ ENTRY(ia32_sysenter_target)
92 .quad 1b,ia32_badarg 104 .quad 1b,ia32_badarg
93 .previous 105 .previous
94 GET_THREAD_INFO(%r10) 106 GET_THREAD_INFO(%r10)
107 orl $TS_COMPAT,threadinfo_status(%r10)
95 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10) 108 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
96 CFI_REMEMBER_STATE 109 CFI_REMEMBER_STATE
97 jnz sysenter_tracesys 110 jnz sysenter_tracesys
@@ -105,6 +118,7 @@ sysenter_do_call:
105 cli 118 cli
106 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10) 119 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
107 jnz int_ret_from_sys_call 120 jnz int_ret_from_sys_call
121 andl $~TS_COMPAT,threadinfo_status(%r10)
108 /* clear IF, that popfq doesn't enable interrupts early */ 122 /* clear IF, that popfq doesn't enable interrupts early */
109 andl $~0x200,EFLAGS-R11(%rsp) 123 andl $~0x200,EFLAGS-R11(%rsp)
110 RESTORE_ARGS 1,24,1,1,1,1 124 RESTORE_ARGS 1,24,1,1,1,1
@@ -161,7 +175,7 @@ sysenter_tracesys:
161 * with the int 0x80 path. 175 * with the int 0x80 path.
162 */ 176 */
163ENTRY(ia32_cstar_target) 177ENTRY(ia32_cstar_target)
164 CFI_STARTPROC simple 178 CFI_STARTPROC32 simple
165 CFI_DEF_CFA rsp,0 179 CFI_DEF_CFA rsp,0
166 CFI_REGISTER rip,rcx 180 CFI_REGISTER rip,rcx
167 /*CFI_REGISTER rflags,r11*/ 181 /*CFI_REGISTER rflags,r11*/
@@ -191,6 +205,7 @@ ENTRY(ia32_cstar_target)
191 .quad 1b,ia32_badarg 205 .quad 1b,ia32_badarg
192 .previous 206 .previous
193 GET_THREAD_INFO(%r10) 207 GET_THREAD_INFO(%r10)
208 orl $TS_COMPAT,threadinfo_status(%r10)
194 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10) 209 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
195 CFI_REMEMBER_STATE 210 CFI_REMEMBER_STATE
196 jnz cstar_tracesys 211 jnz cstar_tracesys
@@ -204,6 +219,7 @@ cstar_do_call:
204 cli 219 cli
205 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10) 220 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
206 jnz int_ret_from_sys_call 221 jnz int_ret_from_sys_call
222 andl $~TS_COMPAT,threadinfo_status(%r10)
207 RESTORE_ARGS 1,-ARG_SKIP,1,1,1 223 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
208 movl RIP-ARGOFFSET(%rsp),%ecx 224 movl RIP-ARGOFFSET(%rsp),%ecx
209 CFI_REGISTER rip,rcx 225 CFI_REGISTER rip,rcx
@@ -276,6 +292,7 @@ ENTRY(ia32_syscall)
276 this could be a problem. */ 292 this could be a problem. */
277 SAVE_ARGS 0,0,1 293 SAVE_ARGS 0,0,1
278 GET_THREAD_INFO(%r10) 294 GET_THREAD_INFO(%r10)
295 orl $TS_COMPAT,threadinfo_status(%r10)
279 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10) 296 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
280 jnz ia32_tracesys 297 jnz ia32_tracesys
281ia32_do_syscall: 298ia32_do_syscall:
@@ -318,7 +335,7 @@ quiet_ni_syscall:
318 jmp ia32_ptregs_common 335 jmp ia32_ptregs_common
319 .endm 336 .endm
320 337
321 CFI_STARTPROC 338 CFI_STARTPROC32
322 339
323 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi 340 PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
324 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi 341 PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
@@ -333,8 +350,19 @@ quiet_ni_syscall:
333 350
334ENTRY(ia32_ptregs_common) 351ENTRY(ia32_ptregs_common)
335 popq %r11 352 popq %r11
336 CFI_ADJUST_CFA_OFFSET -8 353 CFI_ENDPROC
337 CFI_REGISTER rip, r11 354 CFI_STARTPROC32 simple
355 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
356 CFI_REL_OFFSET rax,RAX-ARGOFFSET
357 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
358 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
359 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
360 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
361 CFI_REL_OFFSET rip,RIP-ARGOFFSET
362/* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
363/* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
364 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
365/* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
338 SAVE_REST 366 SAVE_REST
339 call *%rax 367 call *%rax
340 RESTORE_REST 368 RESTORE_REST
@@ -608,7 +636,7 @@ ia32_sys_call_table:
608 .quad sys_epoll_wait 636 .quad sys_epoll_wait
609 .quad sys_remap_file_pages 637 .quad sys_remap_file_pages
610 .quad sys_set_tid_address 638 .quad sys_set_tid_address
611 .quad sys32_timer_create 639 .quad compat_sys_timer_create
612 .quad compat_sys_timer_settime /* 260 */ 640 .quad compat_sys_timer_settime /* 260 */
613 .quad compat_sys_timer_gettime 641 .quad compat_sys_timer_gettime
614 .quad sys_timer_getoverrun 642 .quad sys_timer_getoverrun
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 5f4cdfa56901..23a4515a73b4 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -28,9 +28,12 @@
28#include <asm/i387.h> 28#include <asm/i387.h>
29#include <asm/fpu32.h> 29#include <asm/fpu32.h>
30 30
31/* determines which flags the user has access to. */ 31/*
32/* 1 = access 0 = no access */ 32 * Determines which flags the user has access to [1 = access, 0 = no access].
33#define FLAG_MASK 0x44dd5UL 33 * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
34 * Also masks reserved bits (31-22, 15, 5, 3, 1).
35 */
36#define FLAG_MASK 0x54dd5UL
34 37
35#define R32(l,q) \ 38#define R32(l,q) \
36 case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break 39 case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
@@ -38,7 +41,7 @@
38static int putreg32(struct task_struct *child, unsigned regno, u32 val) 41static int putreg32(struct task_struct *child, unsigned regno, u32 val)
39{ 42{
40 int i; 43 int i;
41 __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 44 __u64 *stack = (__u64 *)task_pt_regs(child);
42 45
43 switch (regno) { 46 switch (regno) {
44 case offsetof(struct user32, regs.fs): 47 case offsetof(struct user32, regs.fs):
@@ -134,7 +137,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
134 137
135static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 138static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
136{ 139{
137 __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 140 __u64 *stack = (__u64 *)task_pt_regs(child);
138 141
139 switch (regno) { 142 switch (regno) {
140 case offsetof(struct user32, regs.fs): 143 case offsetof(struct user32, regs.fs):
@@ -235,7 +238,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
235 if (ret < 0) 238 if (ret < 0)
236 goto out; 239 goto out;
237 240
238 childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); 241 childregs = task_pt_regs(child);
239 242
240 switch (request) { 243 switch (request) {
241 case PTRACE_PEEKDATA: 244 case PTRACE_PEEKDATA:
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 5389df610e78..54481af5344a 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -969,25 +969,6 @@ long sys32_kill(int pid, int sig)
969 return sys_kill(pid, sig); 969 return sys_kill(pid, sig);
970} 970}
971 971
972extern asmlinkage long
973sys_timer_create(clockid_t which_clock,
974 struct sigevent __user *timer_event_spec,
975 timer_t __user * created_timer_id);
976
977long
978sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id)
979{
980 struct sigevent __user *p = NULL;
981 if (se32) {
982 struct sigevent se;
983 p = compat_alloc_user_space(sizeof(struct sigevent));
984 if (get_compat_sigevent(&se, se32) ||
985 copy_to_user(p, &se, sizeof(se)))
986 return -EFAULT;
987 }
988 return sys_timer_create(clock, p, timer_id);
989}
990
991long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, 972long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
992 __u32 len_low, __u32 len_high, int advice) 973 __u32 len_low, __u32 len_high, int advice)
993{ 974{
diff --git a/arch/x86_64/ia32/vsyscall-sigreturn.S b/arch/x86_64/ia32/vsyscall-sigreturn.S
index 8b5a4b060bb5..d90321fe9bba 100644
--- a/arch/x86_64/ia32/vsyscall-sigreturn.S
+++ b/arch/x86_64/ia32/vsyscall-sigreturn.S
@@ -7,6 +7,7 @@
7 * by doing ".balign 32" must match in both versions of the page. 7 * by doing ".balign 32" must match in both versions of the page.
8 */ 8 */
9 9
10 .code32
10 .section .text.sigreturn,"ax" 11 .section .text.sigreturn,"ax"
11 .balign 32 12 .balign 32
12 .globl __kernel_sigreturn 13 .globl __kernel_sigreturn
diff --git a/arch/x86_64/ia32/vsyscall-syscall.S b/arch/x86_64/ia32/vsyscall-syscall.S
index b024965bb689..cf9ef678de3e 100644
--- a/arch/x86_64/ia32/vsyscall-syscall.S
+++ b/arch/x86_64/ia32/vsyscall-syscall.S
@@ -6,6 +6,7 @@
6#include <asm/asm-offsets.h> 6#include <asm/asm-offsets.h>
7#include <asm/segment.h> 7#include <asm/segment.h>
8 8
9 .code32
9 .text 10 .text
10 .section .text.vsyscall,"ax" 11 .section .text.vsyscall,"ax"
11 .globl __kernel_vsyscall 12 .globl __kernel_vsyscall
diff --git a/arch/x86_64/ia32/vsyscall-sysenter.S b/arch/x86_64/ia32/vsyscall-sysenter.S
index 71f3de586b56..ae056e553d13 100644
--- a/arch/x86_64/ia32/vsyscall-sysenter.S
+++ b/arch/x86_64/ia32/vsyscall-sysenter.S
@@ -5,6 +5,7 @@
5#include <asm/ia32_unistd.h> 5#include <asm/ia32_unistd.h>
6#include <asm/asm-offsets.h> 6#include <asm/asm-offsets.h>
7 7
8 .code32
8 .text 9 .text
9 .section .text.vsyscall,"ax" 10 .section .text.vsyscall,"ax"
10 .globl __kernel_vsyscall 11 .globl __kernel_vsyscall
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index fe4cbd1c4b2f..72fe60c20d39 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -7,7 +7,8 @@ EXTRA_AFLAGS := -traditional
7obj-y := process.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o entry.o traps.o irq.o \
8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \
9 x8664_ksyms.o i387.o syscall.o vsyscall.o \ 9 x8664_ksyms.o i387.o syscall.o vsyscall.o \
10 setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o 10 setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o \
11 dmi_scan.o pci-dma.o pci-nommu.o
11 12
12obj-$(CONFIG_X86_MCE) += mce.o 13obj-$(CONFIG_X86_MCE) += mce.o
13obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o 14obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o
@@ -22,14 +23,16 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o
22obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o \ 23obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o \
23 genapic.o genapic_cluster.o genapic_flat.o 24 genapic.o genapic_cluster.o genapic_flat.o
24obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o 25obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
26obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
25obj-$(CONFIG_PM) += suspend.o 27obj-$(CONFIG_PM) += suspend.o
26obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o 28obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o
27obj-$(CONFIG_CPU_FREQ) += cpufreq/ 29obj-$(CONFIG_CPU_FREQ) += cpufreq/
28obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 30obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
29obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o 31obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o
30obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o 32obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
31obj-$(CONFIG_KPROBES) += kprobes.o 33obj-$(CONFIG_KPROBES) += kprobes.o
32obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o 34obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o
35obj-$(CONFIG_X86_VSMP) += vsmp.o
33 36
34obj-$(CONFIG_MODULES) += module.o 37obj-$(CONFIG_MODULES) += module.o
35 38
@@ -46,3 +49,5 @@ intel_cacheinfo-y += ../../i386/kernel/cpu/intel_cacheinfo.o
46quirks-y += ../../i386/kernel/quirks.o 49quirks-y += ../../i386/kernel/quirks.o
47i8237-y += ../../i386/kernel/i8237.o 50i8237-y += ../../i386/kernel/i8237.o
48msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o 51msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
52dmi_scan-y += ../../i386/kernel/dmi_scan.o
53
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index c7f4fdd20f05..e4e2b7d01f89 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -23,6 +23,7 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/proto.h> 24#include <asm/proto.h>
25#include <asm/pci-direct.h> 25#include <asm/pci-direct.h>
26#include <asm/dma.h>
26 27
27int iommu_aperture; 28int iommu_aperture;
28int iommu_aperture_disabled __initdata = 0; 29int iommu_aperture_disabled __initdata = 0;
@@ -247,7 +248,7 @@ void __init iommu_hole_init(void)
247 /* Got the aperture from the AGP bridge */ 248 /* Got the aperture from the AGP bridge */
248 } else if (swiotlb && !valid_agp) { 249 } else if (swiotlb && !valid_agp) {
249 /* Do nothing */ 250 /* Do nothing */
250 } else if ((!no_iommu && end_pfn >= 0xffffffff>>PAGE_SHIFT) || 251 } else if ((!no_iommu && end_pfn >= MAX_DMA32_PFN) ||
251 force_iommu || 252 force_iommu ||
252 valid_agp || 253 valid_agp ||
253 fallback_aper_force) { 254 fallback_aper_force) {
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 18691ce4c759..8fdd089fd17e 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
25#include <linux/mc146818rtc.h> 25#include <linux/mc146818rtc.h>
26#include <linux/kernel_stat.h> 26#include <linux/kernel_stat.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/module.h>
28 29
29#include <asm/atomic.h> 30#include <asm/atomic.h>
30#include <asm/smp.h> 31#include <asm/smp.h>
@@ -33,36 +34,36 @@
33#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
34#include <asm/mach_apic.h> 35#include <asm/mach_apic.h>
35#include <asm/nmi.h> 36#include <asm/nmi.h>
37#include <asm/idle.h>
36 38
37int apic_verbosity; 39int apic_verbosity;
38 40
39int disable_apic_timer __initdata; 41int disable_apic_timer __initdata;
40 42
43/*
44 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
45 * IPIs in place of local APIC timers
46 */
47static cpumask_t timer_interrupt_broadcast_ipi_mask;
48
41/* Using APIC to generate smp_local_timer_interrupt? */ 49/* Using APIC to generate smp_local_timer_interrupt? */
42int using_apic_timer = 0; 50int using_apic_timer = 0;
43 51
44static DEFINE_PER_CPU(int, prof_multiplier) = 1;
45static DEFINE_PER_CPU(int, prof_old_multiplier) = 1;
46static DEFINE_PER_CPU(int, prof_counter) = 1;
47
48static void apic_pm_activate(void); 52static void apic_pm_activate(void);
49 53
50void enable_NMI_through_LVT0 (void * dummy) 54void enable_NMI_through_LVT0 (void * dummy)
51{ 55{
52 unsigned int v, ver; 56 unsigned int v;
53 57
54 ver = apic_read(APIC_LVR);
55 ver = GET_APIC_VERSION(ver);
56 v = APIC_DM_NMI; /* unmask and set to NMI */ 58 v = APIC_DM_NMI; /* unmask and set to NMI */
57 apic_write_around(APIC_LVT0, v); 59 apic_write(APIC_LVT0, v);
58} 60}
59 61
60int get_maxlvt(void) 62int get_maxlvt(void)
61{ 63{
62 unsigned int v, ver, maxlvt; 64 unsigned int v, maxlvt;
63 65
64 v = apic_read(APIC_LVR); 66 v = apic_read(APIC_LVR);
65 ver = GET_APIC_VERSION(v);
66 maxlvt = GET_APIC_MAXLVT(v); 67 maxlvt = GET_APIC_MAXLVT(v);
67 return maxlvt; 68 return maxlvt;
68} 69}
@@ -80,33 +81,33 @@ void clear_local_APIC(void)
80 */ 81 */
81 if (maxlvt >= 3) { 82 if (maxlvt >= 3) {
82 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */ 83 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
83 apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED); 84 apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
84 } 85 }
85 /* 86 /*
86 * Careful: we have to set masks only first to deassert 87 * Careful: we have to set masks only first to deassert
87 * any level-triggered sources. 88 * any level-triggered sources.
88 */ 89 */
89 v = apic_read(APIC_LVTT); 90 v = apic_read(APIC_LVTT);
90 apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); 91 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
91 v = apic_read(APIC_LVT0); 92 v = apic_read(APIC_LVT0);
92 apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED); 93 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
93 v = apic_read(APIC_LVT1); 94 v = apic_read(APIC_LVT1);
94 apic_write_around(APIC_LVT1, v | APIC_LVT_MASKED); 95 apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
95 if (maxlvt >= 4) { 96 if (maxlvt >= 4) {
96 v = apic_read(APIC_LVTPC); 97 v = apic_read(APIC_LVTPC);
97 apic_write_around(APIC_LVTPC, v | APIC_LVT_MASKED); 98 apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
98 } 99 }
99 100
100 /* 101 /*
101 * Clean APIC state for other OSs: 102 * Clean APIC state for other OSs:
102 */ 103 */
103 apic_write_around(APIC_LVTT, APIC_LVT_MASKED); 104 apic_write(APIC_LVTT, APIC_LVT_MASKED);
104 apic_write_around(APIC_LVT0, APIC_LVT_MASKED); 105 apic_write(APIC_LVT0, APIC_LVT_MASKED);
105 apic_write_around(APIC_LVT1, APIC_LVT_MASKED); 106 apic_write(APIC_LVT1, APIC_LVT_MASKED);
106 if (maxlvt >= 3) 107 if (maxlvt >= 3)
107 apic_write_around(APIC_LVTERR, APIC_LVT_MASKED); 108 apic_write(APIC_LVTERR, APIC_LVT_MASKED);
108 if (maxlvt >= 4) 109 if (maxlvt >= 4)
109 apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); 110 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
110 v = GET_APIC_VERSION(apic_read(APIC_LVR)); 111 v = GET_APIC_VERSION(apic_read(APIC_LVR));
111 apic_write(APIC_ESR, 0); 112 apic_write(APIC_ESR, 0);
112 apic_read(APIC_ESR); 113 apic_read(APIC_ESR);
@@ -151,7 +152,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
151 value &= ~APIC_VECTOR_MASK; 152 value &= ~APIC_VECTOR_MASK;
152 value |= APIC_SPIV_APIC_ENABLED; 153 value |= APIC_SPIV_APIC_ENABLED;
153 value |= 0xf; 154 value |= 0xf;
154 apic_write_around(APIC_SPIV, value); 155 apic_write(APIC_SPIV, value);
155 156
156 if (!virt_wire_setup) { 157 if (!virt_wire_setup) {
157 /* For LVT0 make it edge triggered, active high, external and enabled */ 158 /* For LVT0 make it edge triggered, active high, external and enabled */
@@ -161,11 +162,11 @@ void disconnect_bsp_APIC(int virt_wire_setup)
161 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED ); 162 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
162 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 163 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
163 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT); 164 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
164 apic_write_around(APIC_LVT0, value); 165 apic_write(APIC_LVT0, value);
165 } 166 }
166 else { 167 else {
167 /* Disable LVT0 */ 168 /* Disable LVT0 */
168 apic_write_around(APIC_LVT0, APIC_LVT_MASKED); 169 apic_write(APIC_LVT0, APIC_LVT_MASKED);
169 } 170 }
170 171
171 /* For LVT1 make it edge triggered, active high, nmi and enabled */ 172 /* For LVT1 make it edge triggered, active high, nmi and enabled */
@@ -176,7 +177,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
176 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED); 177 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
177 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 178 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
178 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI); 179 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
179 apic_write_around(APIC_LVT1, value); 180 apic_write(APIC_LVT1, value);
180 } 181 }
181} 182}
182 183
@@ -192,7 +193,7 @@ void disable_local_APIC(void)
192 */ 193 */
193 value = apic_read(APIC_SPIV); 194 value = apic_read(APIC_SPIV);
194 value &= ~APIC_SPIV_APIC_ENABLED; 195 value &= ~APIC_SPIV_APIC_ENABLED;
195 apic_write_around(APIC_SPIV, value); 196 apic_write(APIC_SPIV, value);
196} 197}
197 198
198/* 199/*
@@ -269,7 +270,7 @@ void __init sync_Arb_IDs(void)
269 apic_wait_icr_idle(); 270 apic_wait_icr_idle();
270 271
271 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n"); 272 apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
272 apic_write_around(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG 273 apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
273 | APIC_DM_INIT); 274 | APIC_DM_INIT);
274} 275}
275 276
@@ -280,7 +281,7 @@ extern void __error_in_apic_c (void);
280 */ 281 */
281void __init init_bsp_APIC(void) 282void __init init_bsp_APIC(void)
282{ 283{
283 unsigned int value, ver; 284 unsigned int value;
284 285
285 /* 286 /*
286 * Don't do the setup now if we have a SMP BIOS as the 287 * Don't do the setup now if we have a SMP BIOS as the
@@ -290,7 +291,6 @@ void __init init_bsp_APIC(void)
290 return; 291 return;
291 292
292 value = apic_read(APIC_LVR); 293 value = apic_read(APIC_LVR);
293 ver = GET_APIC_VERSION(value);
294 294
295 /* 295 /*
296 * Do not trust the local APIC being empty at bootup. 296 * Do not trust the local APIC being empty at bootup.
@@ -305,22 +305,21 @@ void __init init_bsp_APIC(void)
305 value |= APIC_SPIV_APIC_ENABLED; 305 value |= APIC_SPIV_APIC_ENABLED;
306 value |= APIC_SPIV_FOCUS_DISABLED; 306 value |= APIC_SPIV_FOCUS_DISABLED;
307 value |= SPURIOUS_APIC_VECTOR; 307 value |= SPURIOUS_APIC_VECTOR;
308 apic_write_around(APIC_SPIV, value); 308 apic_write(APIC_SPIV, value);
309 309
310 /* 310 /*
311 * Set up the virtual wire mode. 311 * Set up the virtual wire mode.
312 */ 312 */
313 apic_write_around(APIC_LVT0, APIC_DM_EXTINT); 313 apic_write(APIC_LVT0, APIC_DM_EXTINT);
314 value = APIC_DM_NMI; 314 value = APIC_DM_NMI;
315 apic_write_around(APIC_LVT1, value); 315 apic_write(APIC_LVT1, value);
316} 316}
317 317
318void __cpuinit setup_local_APIC (void) 318void __cpuinit setup_local_APIC (void)
319{ 319{
320 unsigned int value, ver, maxlvt; 320 unsigned int value, maxlvt;
321 321
322 value = apic_read(APIC_LVR); 322 value = apic_read(APIC_LVR);
323 ver = GET_APIC_VERSION(value);
324 323
325 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f) 324 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f)
326 __error_in_apic_c(); 325 __error_in_apic_c();
@@ -345,7 +344,7 @@ void __cpuinit setup_local_APIC (void)
345 */ 344 */
346 value = apic_read(APIC_TASKPRI); 345 value = apic_read(APIC_TASKPRI);
347 value &= ~APIC_TPRI_MASK; 346 value &= ~APIC_TPRI_MASK;
348 apic_write_around(APIC_TASKPRI, value); 347 apic_write(APIC_TASKPRI, value);
349 348
350 /* 349 /*
351 * Now that we are all set up, enable the APIC 350 * Now that we are all set up, enable the APIC
@@ -387,7 +386,7 @@ void __cpuinit setup_local_APIC (void)
387 * Set spurious IRQ vector 386 * Set spurious IRQ vector
388 */ 387 */
389 value |= SPURIOUS_APIC_VECTOR; 388 value |= SPURIOUS_APIC_VECTOR;
390 apic_write_around(APIC_SPIV, value); 389 apic_write(APIC_SPIV, value);
391 390
392 /* 391 /*
393 * Set up LVT0, LVT1: 392 * Set up LVT0, LVT1:
@@ -407,7 +406,7 @@ void __cpuinit setup_local_APIC (void)
407 value = APIC_DM_EXTINT | APIC_LVT_MASKED; 406 value = APIC_DM_EXTINT | APIC_LVT_MASKED;
408 apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id()); 407 apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id());
409 } 408 }
410 apic_write_around(APIC_LVT0, value); 409 apic_write(APIC_LVT0, value);
411 410
412 /* 411 /*
413 * only the BP should see the LINT1 NMI signal, obviously. 412 * only the BP should see the LINT1 NMI signal, obviously.
@@ -416,14 +415,14 @@ void __cpuinit setup_local_APIC (void)
416 value = APIC_DM_NMI; 415 value = APIC_DM_NMI;
417 else 416 else
418 value = APIC_DM_NMI | APIC_LVT_MASKED; 417 value = APIC_DM_NMI | APIC_LVT_MASKED;
419 apic_write_around(APIC_LVT1, value); 418 apic_write(APIC_LVT1, value);
420 419
421 { 420 {
422 unsigned oldvalue; 421 unsigned oldvalue;
423 maxlvt = get_maxlvt(); 422 maxlvt = get_maxlvt();
424 oldvalue = apic_read(APIC_ESR); 423 oldvalue = apic_read(APIC_ESR);
425 value = ERROR_APIC_VECTOR; // enables sending errors 424 value = ERROR_APIC_VECTOR; // enables sending errors
426 apic_write_around(APIC_LVTERR, value); 425 apic_write(APIC_LVTERR, value);
427 /* 426 /*
428 * spec says clear errors after enabling vector. 427 * spec says clear errors after enabling vector.
429 */ 428 */
@@ -660,20 +659,25 @@ void __init init_apic_mappings(void)
660static void __setup_APIC_LVTT(unsigned int clocks) 659static void __setup_APIC_LVTT(unsigned int clocks)
661{ 660{
662 unsigned int lvtt_value, tmp_value, ver; 661 unsigned int lvtt_value, tmp_value, ver;
662 int cpu = smp_processor_id();
663 663
664 ver = GET_APIC_VERSION(apic_read(APIC_LVR)); 664 ver = GET_APIC_VERSION(apic_read(APIC_LVR));
665 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR; 665 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
666 apic_write_around(APIC_LVTT, lvtt_value); 666
667 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
668 lvtt_value |= APIC_LVT_MASKED;
669
670 apic_write(APIC_LVTT, lvtt_value);
667 671
668 /* 672 /*
669 * Divide PICLK by 16 673 * Divide PICLK by 16
670 */ 674 */
671 tmp_value = apic_read(APIC_TDCR); 675 tmp_value = apic_read(APIC_TDCR);
672 apic_write_around(APIC_TDCR, (tmp_value 676 apic_write(APIC_TDCR, (tmp_value
673 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE)) 677 & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
674 | APIC_TDR_DIV_16); 678 | APIC_TDR_DIV_16);
675 679
676 apic_write_around(APIC_TMICT, clocks/APIC_DIVISOR); 680 apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
677} 681}
678 682
679static void setup_APIC_timer(unsigned int clocks) 683static void setup_APIC_timer(unsigned int clocks)
@@ -682,12 +686,6 @@ static void setup_APIC_timer(unsigned int clocks)
682 686
683 local_irq_save(flags); 687 local_irq_save(flags);
684 688
685 /* For some reasons this doesn't work on Simics, so fake it for now */
686 if (!strstr(boot_cpu_data.x86_model_id, "Screwdriver")) {
687 __setup_APIC_LVTT(clocks);
688 return;
689 }
690
691 /* wait for irq slice */ 689 /* wait for irq slice */
692 if (vxtime.hpet_address) { 690 if (vxtime.hpet_address) {
693 int trigger = hpet_readl(HPET_T0_CMP); 691 int trigger = hpet_readl(HPET_T0_CMP);
@@ -700,7 +698,7 @@ static void setup_APIC_timer(unsigned int clocks)
700 outb_p(0x00, 0x43); 698 outb_p(0x00, 0x43);
701 c2 = inb_p(0x40); 699 c2 = inb_p(0x40);
702 c2 |= inb_p(0x40) << 8; 700 c2 |= inb_p(0x40) << 8;
703 do { 701 do {
704 c1 = c2; 702 c1 = c2;
705 outb_p(0x00, 0x43); 703 outb_p(0x00, 0x43);
706 c2 = inb_p(0x40); 704 c2 = inb_p(0x40);
@@ -785,52 +783,68 @@ void __cpuinit setup_secondary_APIC_clock(void)
785 local_irq_enable(); 783 local_irq_enable();
786} 784}
787 785
788void __cpuinit disable_APIC_timer(void) 786void disable_APIC_timer(void)
789{ 787{
790 if (using_apic_timer) { 788 if (using_apic_timer) {
791 unsigned long v; 789 unsigned long v;
792 790
793 v = apic_read(APIC_LVTT); 791 v = apic_read(APIC_LVTT);
794 apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); 792 apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
795 } 793 }
796} 794}
797 795
798void enable_APIC_timer(void) 796void enable_APIC_timer(void)
799{ 797{
800 if (using_apic_timer) { 798 int cpu = smp_processor_id();
799
800 if (using_apic_timer &&
801 !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
801 unsigned long v; 802 unsigned long v;
802 803
803 v = apic_read(APIC_LVTT); 804 v = apic_read(APIC_LVTT);
804 apic_write_around(APIC_LVTT, v & ~APIC_LVT_MASKED); 805 apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
805 } 806 }
806} 807}
807 808
808/* 809void switch_APIC_timer_to_ipi(void *cpumask)
809 * the frequency of the profiling timer can be changed
810 * by writing a multiplier value into /proc/profile.
811 */
812int setup_profiling_timer(unsigned int multiplier)
813{ 810{
814 int i; 811 cpumask_t mask = *(cpumask_t *)cpumask;
812 int cpu = smp_processor_id();
815 813
816 /* 814 if (cpu_isset(cpu, mask) &&
817 * Sanity check. [at least 500 APIC cycles should be 815 !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
818 * between APIC interrupts as a rule of thumb, to avoid 816 disable_APIC_timer();
819 * irqs flooding us] 817 cpu_set(cpu, timer_interrupt_broadcast_ipi_mask);
820 */ 818 }
821 if ( (!multiplier) || (calibration_result/multiplier < 500)) 819}
822 return -EINVAL; 820EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
823
824 /*
825 * Set the new multiplier for each CPU. CPUs don't start using the
826 * new values until the next timer interrupt in which they do process
827 * accounting. At that time they also adjust their APIC timers
828 * accordingly.
829 */
830 for (i = 0; i < NR_CPUS; ++i)
831 per_cpu(prof_multiplier, i) = multiplier;
832 821
833 return 0; 822void smp_send_timer_broadcast_ipi(void)
823{
824 cpumask_t mask;
825
826 cpus_and(mask, cpu_online_map, timer_interrupt_broadcast_ipi_mask);
827 if (!cpus_empty(mask)) {
828 send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
829 }
830}
831
832void switch_ipi_to_APIC_timer(void *cpumask)
833{
834 cpumask_t mask = *(cpumask_t *)cpumask;
835 int cpu = smp_processor_id();
836
837 if (cpu_isset(cpu, mask) &&
838 cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
839 cpu_clear(cpu, timer_interrupt_broadcast_ipi_mask);
840 enable_APIC_timer();
841 }
842}
843EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
844
845int setup_profiling_timer(unsigned int multiplier)
846{
847 return -EINVAL;
834} 848}
835 849
836#ifdef CONFIG_X86_MCE_AMD 850#ifdef CONFIG_X86_MCE_AMD
@@ -857,32 +871,10 @@ void setup_threshold_lvt(unsigned long lvt_off)
857 871
858void smp_local_timer_interrupt(struct pt_regs *regs) 872void smp_local_timer_interrupt(struct pt_regs *regs)
859{ 873{
860 int cpu = smp_processor_id();
861
862 profile_tick(CPU_PROFILING, regs); 874 profile_tick(CPU_PROFILING, regs);
863 if (--per_cpu(prof_counter, cpu) <= 0) {
864 /*
865 * The multiplier may have changed since the last time we got
866 * to this point as a result of the user writing to
867 * /proc/profile. In this case we need to adjust the APIC
868 * timer accordingly.
869 *
870 * Interrupts are already masked off at this point.
871 */
872 per_cpu(prof_counter, cpu) = per_cpu(prof_multiplier, cpu);
873 if (per_cpu(prof_counter, cpu) !=
874 per_cpu(prof_old_multiplier, cpu)) {
875 __setup_APIC_LVTT(calibration_result/
876 per_cpu(prof_counter, cpu));
877 per_cpu(prof_old_multiplier, cpu) =
878 per_cpu(prof_counter, cpu);
879 }
880
881#ifdef CONFIG_SMP 875#ifdef CONFIG_SMP
882 update_process_times(user_mode(regs)); 876 update_process_times(user_mode(regs));
883#endif 877#endif
884 }
885
886 /* 878 /*
887 * We take the 'long' return path, and there every subsystem 879 * We take the 'long' return path, and there every subsystem
888 * grabs the appropriate locks (kernel lock/ irq lock). 880 * grabs the appropriate locks (kernel lock/ irq lock).
@@ -920,6 +912,7 @@ void smp_apic_timer_interrupt(struct pt_regs *regs)
920 * Besides, if we don't timer interrupts ignore the global 912 * Besides, if we don't timer interrupts ignore the global
921 * interrupt lock, which is the WrongThing (tm) to do. 913 * interrupt lock, which is the WrongThing (tm) to do.
922 */ 914 */
915 exit_idle();
923 irq_enter(); 916 irq_enter();
924 smp_local_timer_interrupt(regs); 917 smp_local_timer_interrupt(regs);
925 irq_exit(); 918 irq_exit();
@@ -979,6 +972,7 @@ __init int oem_force_hpet_timer(void)
979asmlinkage void smp_spurious_interrupt(void) 972asmlinkage void smp_spurious_interrupt(void)
980{ 973{
981 unsigned int v; 974 unsigned int v;
975 exit_idle();
982 irq_enter(); 976 irq_enter();
983 /* 977 /*
984 * Check if this really is a spurious interrupt and ACK it 978 * Check if this really is a spurious interrupt and ACK it
@@ -1014,6 +1008,7 @@ asmlinkage void smp_error_interrupt(void)
1014{ 1008{
1015 unsigned int v, v1; 1009 unsigned int v, v1;
1016 1010
1011 exit_idle();
1017 irq_enter(); 1012 irq_enter();
1018 /* First tickle the hardware, only then report what went on. -- REW */ 1013 /* First tickle the hardware, only then report what went on. -- REW */
1019 v = apic_read(APIC_ESR); 1014 v = apic_read(APIC_ESR);
@@ -1060,7 +1055,7 @@ int __init APIC_init_uniprocessor (void)
1060 connect_bsp_APIC(); 1055 connect_bsp_APIC();
1061 1056
1062 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id); 1057 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
1063 apic_write_around(APIC_ID, boot_cpu_id); 1058 apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
1064 1059
1065 setup_local_APIC(); 1060 setup_local_APIC();
1066 1061
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
index aaa6d3833517..cfb4f9cebea4 100644
--- a/arch/x86_64/kernel/asm-offsets.c
+++ b/arch/x86_64/kernel/asm-offsets.c
@@ -33,6 +33,7 @@ int main(void)
33 ENTRY(flags); 33 ENTRY(flags);
34 ENTRY(addr_limit); 34 ENTRY(addr_limit);
35 ENTRY(preempt_count); 35 ENTRY(preempt_count);
36 ENTRY(status);
36 BLANK(); 37 BLANK();
37#undef ENTRY 38#undef ENTRY
38#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry)) 39#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
@@ -64,5 +65,9 @@ int main(void)
64 DEFINE(pbe_address, offsetof(struct pbe, address)); 65 DEFINE(pbe_address, offsetof(struct pbe, address));
65 DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); 66 DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
66 DEFINE(pbe_next, offsetof(struct pbe, next)); 67 DEFINE(pbe_next, offsetof(struct pbe, next));
68 BLANK();
69#if DEBUG_STKSZ > EXCEPTION_STKSZ
70 DEFINE(DEBUG_IST, DEBUG_STACK);
71#endif
67 return 0; 72 return 0;
68} 73}
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index 535e04466079..4e6c3b729e39 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -11,19 +11,156 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/irq.h>
14#include <linux/reboot.h> 15#include <linux/reboot.h>
15#include <linux/kexec.h> 16#include <linux/kexec.h>
17#include <linux/delay.h>
18#include <linux/elf.h>
19#include <linux/elfcore.h>
16 20
17#include <asm/processor.h> 21#include <asm/processor.h>
18#include <asm/hardirq.h> 22#include <asm/hardirq.h>
19#include <asm/nmi.h> 23#include <asm/nmi.h>
20#include <asm/hw_irq.h> 24#include <asm/hw_irq.h>
25#include <asm/mach_apic.h>
21 26
22note_buf_t crash_notes[NR_CPUS]; 27/* This keeps a track of which one is crashing cpu. */
28static int crashing_cpu;
29
30static u32 *append_elf_note(u32 *buf, char *name, unsigned type,
31 void *data, size_t data_len)
32{
33 struct elf_note note;
34
35 note.n_namesz = strlen(name) + 1;
36 note.n_descsz = data_len;
37 note.n_type = type;
38 memcpy(buf, &note, sizeof(note));
39 buf += (sizeof(note) +3)/4;
40 memcpy(buf, name, note.n_namesz);
41 buf += (note.n_namesz + 3)/4;
42 memcpy(buf, data, note.n_descsz);
43 buf += (note.n_descsz + 3)/4;
44
45 return buf;
46}
47
48static void final_note(u32 *buf)
49{
50 struct elf_note note;
51
52 note.n_namesz = 0;
53 note.n_descsz = 0;
54 note.n_type = 0;
55 memcpy(buf, &note, sizeof(note));
56}
57
58static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
59{
60 struct elf_prstatus prstatus;
61 u32 *buf;
62
63 if ((cpu < 0) || (cpu >= NR_CPUS))
64 return;
65
66 /* Using ELF notes here is opportunistic.
67 * I need a well defined structure format
68 * for the data I pass, and I need tags
69 * on the data to indicate what information I have
70 * squirrelled away. ELF notes happen to provide
71 * all of that that no need to invent something new.
72 */
73
74 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
75
76 if (!buf)
77 return;
78
79 memset(&prstatus, 0, sizeof(prstatus));
80 prstatus.pr_pid = current->pid;
81 elf_core_copy_regs(&prstatus.pr_reg, regs);
82 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
83 sizeof(prstatus));
84 final_note(buf);
85}
86
87static void crash_save_self(struct pt_regs *regs)
88{
89 int cpu;
90
91 cpu = smp_processor_id();
92 crash_save_this_cpu(regs, cpu);
93}
94
95#ifdef CONFIG_SMP
96static atomic_t waiting_for_crash_ipi;
97
98static int crash_nmi_callback(struct pt_regs *regs, int cpu)
99{
100 /*
101 * Don't do anything if this handler is invoked on crashing cpu.
102 * Otherwise, system will completely hang. Crashing cpu can get
103 * an NMI if system was initially booted with nmi_watchdog parameter.
104 */
105 if (cpu == crashing_cpu)
106 return 1;
107 local_irq_disable();
108
109 crash_save_this_cpu(regs, cpu);
110 disable_local_APIC();
111 atomic_dec(&waiting_for_crash_ipi);
112 /* Assume hlt works */
113 for(;;)
114 asm("hlt");
115
116 return 1;
117}
118
119static void smp_send_nmi_allbutself(void)
120{
121 send_IPI_allbutself(APIC_DM_NMI);
122}
123
124/*
125 * This code is a best effort heuristic to get the
126 * other cpus to stop executing. So races with
127 * cpu hotplug shouldn't matter.
128 */
129
130static void nmi_shootdown_cpus(void)
131{
132 unsigned long msecs;
133
134 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
135 set_nmi_callback(crash_nmi_callback);
136
137 /*
138 * Ensure the new callback function is set before sending
139 * out the NMI
140 */
141 wmb();
142
143 smp_send_nmi_allbutself();
144
145 msecs = 1000; /* Wait at most a second for the other cpus to stop */
146 while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
147 mdelay(1);
148 msecs--;
149 }
150 /* Leave the nmi callback set */
151 disable_local_APIC();
152}
153#else
154static void nmi_shootdown_cpus(void)
155{
156 /* There are no cpus to shootdown */
157}
158#endif
23 159
24void machine_crash_shutdown(struct pt_regs *regs) 160void machine_crash_shutdown(struct pt_regs *regs)
25{ 161{
26 /* This function is only called after the system 162 /*
163 * This function is only called after the system
27 * has paniced or is otherwise in a critical state. 164 * has paniced or is otherwise in a critical state.
28 * The minimum amount of code to allow a kexec'd kernel 165 * The minimum amount of code to allow a kexec'd kernel
29 * to run successfully needs to happen here. 166 * to run successfully needs to happen here.
@@ -31,4 +168,19 @@ void machine_crash_shutdown(struct pt_regs *regs)
31 * In practice this means shooting down the other cpus in 168 * In practice this means shooting down the other cpus in
32 * an SMP system. 169 * an SMP system.
33 */ 170 */
171 /* The kernel is broken so disable interrupts */
172 local_irq_disable();
173
174 /* Make a note of crashing cpu. Will be used in NMI callback.*/
175 crashing_cpu = smp_processor_id();
176 nmi_shootdown_cpus();
177
178 if(cpu_has_apic)
179 disable_local_APIC();
180
181#if defined(CONFIG_X86_IO_APIC)
182 disable_IO_APIC();
183#endif
184
185 crash_save_self(regs);
34} 186}
diff --git a/arch/x86_64/kernel/crash_dump.c b/arch/x86_64/kernel/crash_dump.c
new file mode 100644
index 000000000000..942deac4d43a
--- /dev/null
+++ b/arch/x86_64/kernel/crash_dump.c
@@ -0,0 +1,47 @@
1/*
2 * kernel/crash_dump.c - Memory preserving reboot related code.
3 *
4 * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
5 * Copyright (C) IBM Corporation, 2004. All rights reserved
6 */
7
8#include <linux/errno.h>
9#include <linux/crash_dump.h>
10
11#include <asm/uaccess.h>
12#include <asm/io.h>
13
14/**
15 * copy_oldmem_page - copy one page from "oldmem"
16 * @pfn: page frame number to be copied
17 * @buf: target memory address for the copy; this can be in kernel address
18 * space or user address space (see @userbuf)
19 * @csize: number of bytes to copy
20 * @offset: offset in bytes into the page (based on pfn) to begin the copy
21 * @userbuf: if set, @buf is in user address space, use copy_to_user(),
22 * otherwise @buf is in kernel address space, use memcpy().
23 *
24 * Copy a page from "oldmem". For this page, there is no pte mapped
25 * in the current kernel. We stitch up a pte, similar to kmap_atomic.
26 */
27ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
28 size_t csize, unsigned long offset, int userbuf)
29{
30 void *vaddr;
31
32 if (!csize)
33 return 0;
34
35 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
36
37 if (userbuf) {
38 if (copy_to_user(buf, (vaddr + offset), csize)) {
39 iounmap(vaddr);
40 return -EFAULT;
41 }
42 } else
43 memcpy(buf, (vaddr + offset), csize);
44
45 iounmap(vaddr);
46 return csize;
47}
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 17579a1a174b..293cd71a266a 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -559,6 +559,27 @@ void __init parse_memopt(char *p, char **from)
559 end_user_pfn >>= PAGE_SHIFT; 559 end_user_pfn >>= PAGE_SHIFT;
560} 560}
561 561
562void __init parse_memmapopt(char *p, char **from)
563{
564 unsigned long long start_at, mem_size;
565
566 mem_size = memparse(p, from);
567 p = *from;
568 if (*p == '@') {
569 start_at = memparse(p+1, from);
570 add_memory_region(start_at, mem_size, E820_RAM);
571 } else if (*p == '#') {
572 start_at = memparse(p+1, from);
573 add_memory_region(start_at, mem_size, E820_ACPI);
574 } else if (*p == '$') {
575 start_at = memparse(p+1, from);
576 add_memory_region(start_at, mem_size, E820_RESERVED);
577 } else {
578 end_user_pfn = (mem_size >> PAGE_SHIFT);
579 }
580 p = *from;
581}
582
562unsigned long pci_mem_start = 0xaeedbabe; 583unsigned long pci_mem_start = 0xaeedbabe;
563 584
564/* 585/*
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 9cd968dd0f5a..6dffb498ccd7 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -216,7 +216,7 @@ void early_printk(const char *fmt, ...)
216 va_end(ap); 216 va_end(ap);
217} 217}
218 218
219static int keep_early; 219static int __initdata keep_early;
220 220
221int __init setup_early_printk(char *opt) 221int __init setup_early_printk(char *opt)
222{ 222{
@@ -226,8 +226,6 @@ int __init setup_early_printk(char *opt)
226 if (early_console_initialized) 226 if (early_console_initialized)
227 return -1; 227 return -1;
228 228
229 opt = strchr(opt, '=') + 1;
230
231 strlcpy(buf,opt,sizeof(buf)); 229 strlcpy(buf,opt,sizeof(buf));
232 space = strchr(buf, ' '); 230 space = strchr(buf, ' ');
233 if (space) 231 if (space)
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 9ff42041bb6b..632fc0f59fcc 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -313,6 +313,7 @@ int_with_check:
313 movl threadinfo_flags(%rcx),%edx 313 movl threadinfo_flags(%rcx),%edx
314 andl %edi,%edx 314 andl %edi,%edx
315 jnz int_careful 315 jnz int_careful
316 andl $~TS_COMPAT,threadinfo_status(%rcx)
316 jmp retint_swapgs 317 jmp retint_swapgs
317 318
318 /* Either reschedule or signal or syscall exit tracking needed. */ 319 /* Either reschedule or signal or syscall exit tracking needed. */
@@ -673,7 +674,10 @@ ENTRY(spurious_interrupt)
673 674
674 /* error code is on the stack already */ 675 /* error code is on the stack already */
675 /* handle NMI like exceptions that can happen everywhere */ 676 /* handle NMI like exceptions that can happen everywhere */
676 .macro paranoidentry sym 677#ifndef DEBUG_IST
678# define DEBUG_IST 0
679#endif
680 .macro paranoidentry sym, ist=0
677 SAVE_ALL 681 SAVE_ALL
678 cld 682 cld
679 movl $1,%ebx 683 movl $1,%ebx
@@ -683,10 +687,20 @@ ENTRY(spurious_interrupt)
683 js 1f 687 js 1f
684 swapgs 688 swapgs
685 xorl %ebx,%ebx 689 xorl %ebx,%ebx
6861: movq %rsp,%rdi 6901:
691 .if \ist
692 movq %gs:pda_data_offset, %rbp
693 .endif
694 movq %rsp,%rdi
687 movq ORIG_RAX(%rsp),%rsi 695 movq ORIG_RAX(%rsp),%rsi
688 movq $-1,ORIG_RAX(%rsp) 696 movq $-1,ORIG_RAX(%rsp)
697 .if \ist
698 subq $EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
699 .endif
689 call \sym 700 call \sym
701 .if \ist
702 addq $EXCEPTION_STACK_SIZE, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
703 .endif
690 cli 704 cli
691 .endm 705 .endm
692 706
@@ -754,7 +768,7 @@ error_exit:
754 jnz retint_careful 768 jnz retint_careful
755 swapgs 769 swapgs
756 RESTORE_ARGS 0,8,0 770 RESTORE_ARGS 0,8,0
757 iretq 771 jmp iret_label
758 CFI_ENDPROC 772 CFI_ENDPROC
759 773
760error_kernelspace: 774error_kernelspace:
@@ -904,7 +918,7 @@ KPROBE_ENTRY(debug)
904 INTR_FRAME 918 INTR_FRAME
905 pushq $0 919 pushq $0
906 CFI_ADJUST_CFA_OFFSET 8 920 CFI_ADJUST_CFA_OFFSET 8
907 paranoidentry do_debug 921 paranoidentry do_debug, DEBUG_IST
908 jmp paranoid_exit 922 jmp paranoid_exit
909 CFI_ENDPROC 923 CFI_ENDPROC
910 .previous .text 924 .previous .text
@@ -959,7 +973,12 @@ paranoid_schedule:
959 CFI_ENDPROC 973 CFI_ENDPROC
960 974
961KPROBE_ENTRY(int3) 975KPROBE_ENTRY(int3)
962 zeroentry do_int3 976 INTR_FRAME
977 pushq $0
978 CFI_ADJUST_CFA_OFFSET 8
979 paranoidentry do_int3, DEBUG_IST
980 jmp paranoid_exit
981 CFI_ENDPROC
963 .previous .text 982 .previous .text
964 983
965ENTRY(overflow) 984ENTRY(overflow)
@@ -1021,23 +1040,18 @@ ENTRY(machine_check)
1021 CFI_ENDPROC 1040 CFI_ENDPROC
1022#endif 1041#endif
1023 1042
1024ENTRY(call_debug)
1025 zeroentry do_call_debug
1026
1027ENTRY(call_softirq) 1043ENTRY(call_softirq)
1028 CFI_STARTPROC 1044 CFI_STARTPROC
1029 movq %gs:pda_irqstackptr,%rax 1045 movq %gs:pda_irqstackptr,%rax
1030 pushq %r15 1046 movq %rsp,%rdx
1031 CFI_ADJUST_CFA_OFFSET 8 1047 CFI_DEF_CFA_REGISTER rdx
1032 movq %rsp,%r15
1033 CFI_DEF_CFA_REGISTER r15
1034 incl %gs:pda_irqcount 1048 incl %gs:pda_irqcount
1035 cmove %rax,%rsp 1049 cmove %rax,%rsp
1050 pushq %rdx
1051 /*todo CFI_DEF_CFA_EXPRESSION ...*/
1036 call __do_softirq 1052 call __do_softirq
1037 movq %r15,%rsp 1053 popq %rsp
1038 CFI_DEF_CFA_REGISTER rsp 1054 CFI_DEF_CFA_REGISTER rsp
1039 decl %gs:pda_irqcount 1055 decl %gs:pda_irqcount
1040 popq %r15
1041 CFI_ADJUST_CFA_OFFSET -8
1042 ret 1056 ret
1043 CFI_ENDPROC 1057 CFI_ENDPROC
diff --git a/arch/x86_64/kernel/genapic_cluster.c b/arch/x86_64/kernel/genapic_cluster.c
index a472d62f899a..43fcf62fef0f 100644
--- a/arch/x86_64/kernel/genapic_cluster.c
+++ b/arch/x86_64/kernel/genapic_cluster.c
@@ -72,14 +72,11 @@ static void cluster_send_IPI_mask(cpumask_t mask, int vector)
72static void cluster_send_IPI_allbutself(int vector) 72static void cluster_send_IPI_allbutself(int vector)
73{ 73{
74 cpumask_t mask = cpu_online_map; 74 cpumask_t mask = cpu_online_map;
75 int me = get_cpu(); /* Ensure we are not preempted when we clear */
76 75
77 cpu_clear(me, mask); 76 cpu_clear(smp_processor_id(), mask);
78 77
79 if (!cpus_empty(mask)) 78 if (!cpus_empty(mask))
80 cluster_send_IPI_mask(mask, vector); 79 cluster_send_IPI_mask(mask, vector);
81
82 put_cpu();
83} 80}
84 81
85static void cluster_send_IPI_all(int vector) 82static void cluster_send_IPI_all(int vector)
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
index 9da3edb799ea..1a2ab825be98 100644
--- a/arch/x86_64/kernel/genapic_flat.c
+++ b/arch/x86_64/kernel/genapic_flat.c
@@ -83,12 +83,11 @@ static void flat_send_IPI_allbutself(int vector)
83 __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL); 83 __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
84#else 84#else
85 cpumask_t allbutme = cpu_online_map; 85 cpumask_t allbutme = cpu_online_map;
86 int me = get_cpu(); /* Ensure we are not preempted when we clear */ 86
87 cpu_clear(me, allbutme); 87 cpu_clear(smp_processor_id(), allbutme);
88 88
89 if (!cpus_empty(allbutme)) 89 if (!cpus_empty(allbutme))
90 flat_send_IPI_mask(allbutme, vector); 90 flat_send_IPI_mask(allbutme, vector);
91 put_cpu();
92#endif 91#endif
93} 92}
94 93
@@ -149,10 +148,9 @@ static void physflat_send_IPI_mask(cpumask_t cpumask, int vector)
149static void physflat_send_IPI_allbutself(int vector) 148static void physflat_send_IPI_allbutself(int vector)
150{ 149{
151 cpumask_t allbutme = cpu_online_map; 150 cpumask_t allbutme = cpu_online_map;
152 int me = get_cpu(); 151
153 cpu_clear(me, allbutme); 152 cpu_clear(smp_processor_id(), allbutme);
154 physflat_send_IPI_mask(allbutme, vector); 153 physflat_send_IPI_mask(allbutme, vector);
155 put_cpu();
156} 154}
157 155
158static void physflat_send_IPI_all(int vector) 156static void physflat_send_IPI_all(int vector)
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 15290968e49d..38fc3d5112e7 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -379,14 +379,14 @@ gdt:
379 * Also sysret mandates a special GDT layout 379 * Also sysret mandates a special GDT layout
380 */ 380 */
381 381
382.align L1_CACHE_BYTES 382.align PAGE_SIZE
383 383
384/* The TLS descriptors are currently at a different place compared to i386. 384/* The TLS descriptors are currently at a different place compared to i386.
385 Hopefully nobody expects them at a fixed place (Wine?) */ 385 Hopefully nobody expects them at a fixed place (Wine?) */
386 386
387ENTRY(cpu_gdt_table) 387ENTRY(cpu_gdt_table)
388 .quad 0x0000000000000000 /* NULL descriptor */ 388 .quad 0x0000000000000000 /* NULL descriptor */
389 .quad 0x008f9a000000ffff /* __KERNEL_COMPAT32_CS */ 389 .quad 0x0 /* unused */
390 .quad 0x00af9a000000ffff /* __KERNEL_CS */ 390 .quad 0x00af9a000000ffff /* __KERNEL_CS */
391 .quad 0x00cf92000000ffff /* __KERNEL_DS */ 391 .quad 0x00cf92000000ffff /* __KERNEL_DS */
392 .quad 0x00cffa000000ffff /* __USER32_CS */ 392 .quad 0x00cffa000000ffff /* __USER32_CS */
@@ -396,15 +396,15 @@ ENTRY(cpu_gdt_table)
396 .quad 0,0 /* TSS */ 396 .quad 0,0 /* TSS */
397 .quad 0,0 /* LDT */ 397 .quad 0,0 /* LDT */
398 .quad 0,0,0 /* three TLS descriptors */ 398 .quad 0,0,0 /* three TLS descriptors */
399 .quad 0x00009a000000ffff /* __KERNEL16_CS - 16bit PM for S3 wakeup. */ 399 .quad 0 /* unused */
400 /* base must be patched for real base address. */
401gdt_end: 400gdt_end:
402 /* asm/segment.h:GDT_ENTRIES must match this */ 401 /* asm/segment.h:GDT_ENTRIES must match this */
403 /* This should be a multiple of the cache line size */ 402 /* This should be a multiple of the cache line size */
404 /* GDTs of other CPUs: */ 403 /* GDTs of other CPUs are now dynamically allocated */
405 .fill (GDT_SIZE * NR_CPUS) - (gdt_end - cpu_gdt_table) 404
405 /* zero the remaining page */
406 .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
406 407
407 .align L1_CACHE_BYTES
408ENTRY(idt_table) 408ENTRY(idt_table)
409 .rept 256 409 .rept 256
410 .quad 0 410 .quad 0
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index b675c5add01e..cea20a66c150 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -92,6 +92,9 @@ void __init x86_64_start_kernel(char * real_mode_data)
92 memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t)); 92 memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
93 asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt))); 93 asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
94 94
95 for (i = 0; i < NR_CPUS; i++)
96 cpu_pda(i) = &boot_cpu_pda[i];
97
95 pda_init(0); 98 pda_init(0);
96 copy_bootdata(real_mode_data); 99 copy_bootdata(real_mode_data);
97#ifdef CONFIG_SMP 100#ifdef CONFIG_SMP
@@ -99,7 +102,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
99#endif 102#endif
100 s = strstr(saved_command_line, "earlyprintk="); 103 s = strstr(saved_command_line, "earlyprintk=");
101 if (s != NULL) 104 if (s != NULL)
102 setup_early_printk(s); 105 setup_early_printk(strchr(s, '=') + 1);
103#ifdef CONFIG_NUMA 106#ifdef CONFIG_NUMA
104 s = strstr(saved_command_line, "numa="); 107 s = strstr(saved_command_line, "numa=");
105 if (s != NULL) 108 if (s != NULL)
diff --git a/arch/x86_64/kernel/i387.c b/arch/x86_64/kernel/i387.c
index d9b22b633e39..a5d7e16b928e 100644
--- a/arch/x86_64/kernel/i387.c
+++ b/arch/x86_64/kernel/i387.c
@@ -95,7 +95,7 @@ int save_i387(struct _fpstate __user *buf)
95 if (!used_math()) 95 if (!used_math())
96 return 0; 96 return 0;
97 clear_used_math(); /* trigger finit */ 97 clear_used_math(); /* trigger finit */
98 if (tsk->thread_info->status & TS_USEDFPU) { 98 if (task_thread_info(tsk)->status & TS_USEDFPU) {
99 err = save_i387_checking((struct i387_fxsave_struct __user *)buf); 99 err = save_i387_checking((struct i387_fxsave_struct __user *)buf);
100 if (err) return err; 100 if (err) return err;
101 stts(); 101 stts();
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 6e5101ad3d1a..5ecd34ab8c2b 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -133,7 +133,7 @@ static void end_8259A_irq (unsigned int irq)
133{ 133{
134 if (irq > 256) { 134 if (irq > 256) {
135 char var; 135 char var;
136 printk("return %p stack %p ti %p\n", __builtin_return_address(0), &var, current->thread_info); 136 printk("return %p stack %p ti %p\n", __builtin_return_address(0), &var, task_thread_info(current));
137 137
138 BUG(); 138 BUG();
139 } 139 }
@@ -549,10 +549,9 @@ void __init init_IRQ(void)
549 int vector = FIRST_EXTERNAL_VECTOR + i; 549 int vector = FIRST_EXTERNAL_VECTOR + i;
550 if (i >= NR_IRQS) 550 if (i >= NR_IRQS)
551 break; 551 break;
552 if (vector != IA32_SYSCALL_VECTOR && vector != KDB_VECTOR) { 552 if (vector != IA32_SYSCALL_VECTOR)
553 set_intr_gate(vector, interrupt[i]); 553 set_intr_gate(vector, interrupt[i]);
554 } 554 }
555 }
556 555
557#ifdef CONFIG_SMP 556#ifdef CONFIG_SMP
558 /* 557 /*
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 97154ab058b4..e8cf44ef8778 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -37,6 +37,7 @@
37#include <asm/proto.h> 37#include <asm/proto.h>
38#include <asm/mach_apic.h> 38#include <asm/mach_apic.h>
39#include <asm/acpi.h> 39#include <asm/acpi.h>
40#include <asm/dma.h>
40 41
41#define __apicdebuginit __init 42#define __apicdebuginit __init
42 43
@@ -46,6 +47,9 @@ static int no_timer_check;
46 47
47int disable_timer_pin_1 __initdata; 48int disable_timer_pin_1 __initdata;
48 49
50/* Where if anywhere is the i8259 connect in external int mode */
51static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
52
49static DEFINE_SPINLOCK(ioapic_lock); 53static DEFINE_SPINLOCK(ioapic_lock);
50 54
51/* 55/*
@@ -260,9 +264,6 @@ __setup("apic", enable_ioapic_setup);
260void __init check_ioapic(void) 264void __init check_ioapic(void)
261{ 265{
262 int num,slot,func; 266 int num,slot,func;
263 if (ioapic_force)
264 return;
265
266 /* Poor man's PCI discovery */ 267 /* Poor man's PCI discovery */
267 for (num = 0; num < 32; num++) { 268 for (num = 0; num < 32; num++) {
268 for (slot = 0; slot < 32; slot++) { 269 for (slot = 0; slot < 32; slot++) {
@@ -284,7 +285,7 @@ void __init check_ioapic(void)
284 switch (vendor) { 285 switch (vendor) {
285 case PCI_VENDOR_ID_VIA: 286 case PCI_VENDOR_ID_VIA:
286#ifdef CONFIG_GART_IOMMU 287#ifdef CONFIG_GART_IOMMU
287 if ((end_pfn >= (0xffffffff>>PAGE_SHIFT) || 288 if ((end_pfn > MAX_DMA32_PFN ||
288 force_iommu) && 289 force_iommu) &&
289 !iommu_aperture_allowed) { 290 !iommu_aperture_allowed) {
290 printk(KERN_INFO 291 printk(KERN_INFO
@@ -363,7 +364,7 @@ static int find_irq_entry(int apic, int pin, int type)
363/* 364/*
364 * Find the pin to which IRQ[irq] (ISA) is connected 365 * Find the pin to which IRQ[irq] (ISA) is connected
365 */ 366 */
366static int find_isa_irq_pin(int irq, int type) 367static int __init find_isa_irq_pin(int irq, int type)
367{ 368{
368 int i; 369 int i;
369 370
@@ -381,6 +382,31 @@ static int find_isa_irq_pin(int irq, int type)
381 return -1; 382 return -1;
382} 383}
383 384
385static int __init find_isa_irq_apic(int irq, int type)
386{
387 int i;
388
389 for (i = 0; i < mp_irq_entries; i++) {
390 int lbus = mp_irqs[i].mpc_srcbus;
391
392 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
393 mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
394 mp_bus_id_to_type[lbus] == MP_BUS_MCA) &&
395 (mp_irqs[i].mpc_irqtype == type) &&
396 (mp_irqs[i].mpc_srcbusirq == irq))
397 break;
398 }
399 if (i < mp_irq_entries) {
400 int apic;
401 for(apic = 0; apic < nr_ioapics; apic++) {
402 if (mp_ioapics[apic].mpc_apicid == mp_irqs[i].mpc_dstapic)
403 return apic;
404 }
405 }
406
407 return -1;
408}
409
384/* 410/*
385 * Find a specific PCI IRQ entry. 411 * Find a specific PCI IRQ entry.
386 * Not an __init, possibly needed by modules 412 * Not an __init, possibly needed by modules
@@ -874,7 +900,7 @@ static void __init setup_IO_APIC_irqs(void)
874 * Set up the 8259A-master output pin as broadcast to all 900 * Set up the 8259A-master output pin as broadcast to all
875 * CPUs. 901 * CPUs.
876 */ 902 */
877static void __init setup_ExtINT_IRQ0_pin(unsigned int pin, int vector) 903static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector)
878{ 904{
879 struct IO_APIC_route_entry entry; 905 struct IO_APIC_route_entry entry;
880 unsigned long flags; 906 unsigned long flags;
@@ -884,7 +910,7 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int pin, int vector)
884 disable_8259A_irq(0); 910 disable_8259A_irq(0);
885 911
886 /* mask LVT0 */ 912 /* mask LVT0 */
887 apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); 913 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
888 914
889 /* 915 /*
890 * We use logical delivery to get the timer IRQ 916 * We use logical delivery to get the timer IRQ
@@ -908,8 +934,8 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int pin, int vector)
908 * Add it to the IO-APIC irq-routing table: 934 * Add it to the IO-APIC irq-routing table:
909 */ 935 */
910 spin_lock_irqsave(&ioapic_lock, flags); 936 spin_lock_irqsave(&ioapic_lock, flags);
911 io_apic_write(0, 0x11+2*pin, *(((int *)&entry)+1)); 937 io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
912 io_apic_write(0, 0x10+2*pin, *(((int *)&entry)+0)); 938 io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
913 spin_unlock_irqrestore(&ioapic_lock, flags); 939 spin_unlock_irqrestore(&ioapic_lock, flags);
914 940
915 enable_8259A_irq(0); 941 enable_8259A_irq(0);
@@ -1188,7 +1214,8 @@ void __apicdebuginit print_PIC(void)
1188static void __init enable_IO_APIC(void) 1214static void __init enable_IO_APIC(void)
1189{ 1215{
1190 union IO_APIC_reg_01 reg_01; 1216 union IO_APIC_reg_01 reg_01;
1191 int i; 1217 int i8259_apic, i8259_pin;
1218 int i, apic;
1192 unsigned long flags; 1219 unsigned long flags;
1193 1220
1194 for (i = 0; i < PIN_MAP_SIZE; i++) { 1221 for (i = 0; i < PIN_MAP_SIZE; i++) {
@@ -1202,11 +1229,48 @@ static void __init enable_IO_APIC(void)
1202 /* 1229 /*
1203 * The number of IO-APIC IRQ registers (== #pins): 1230 * The number of IO-APIC IRQ registers (== #pins):
1204 */ 1231 */
1205 for (i = 0; i < nr_ioapics; i++) { 1232 for (apic = 0; apic < nr_ioapics; apic++) {
1206 spin_lock_irqsave(&ioapic_lock, flags); 1233 spin_lock_irqsave(&ioapic_lock, flags);
1207 reg_01.raw = io_apic_read(i, 1); 1234 reg_01.raw = io_apic_read(apic, 1);
1208 spin_unlock_irqrestore(&ioapic_lock, flags); 1235 spin_unlock_irqrestore(&ioapic_lock, flags);
1209 nr_ioapic_registers[i] = reg_01.bits.entries+1; 1236 nr_ioapic_registers[apic] = reg_01.bits.entries+1;
1237 }
1238 for(apic = 0; apic < nr_ioapics; apic++) {
1239 int pin;
1240 /* See if any of the pins is in ExtINT mode */
1241 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
1242 struct IO_APIC_route_entry entry;
1243 spin_lock_irqsave(&ioapic_lock, flags);
1244 *(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
1245 *(((int *)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
1246 spin_unlock_irqrestore(&ioapic_lock, flags);
1247
1248
1249 /* If the interrupt line is enabled and in ExtInt mode
1250 * I have found the pin where the i8259 is connected.
1251 */
1252 if ((entry.mask == 0) && (entry.delivery_mode == dest_ExtINT)) {
1253 ioapic_i8259.apic = apic;
1254 ioapic_i8259.pin = pin;
1255 goto found_i8259;
1256 }
1257 }
1258 }
1259 found_i8259:
1260 /* Look to see what if the MP table has reported the ExtINT */
1261 i8259_pin = find_isa_irq_pin(0, mp_ExtINT);
1262 i8259_apic = find_isa_irq_apic(0, mp_ExtINT);
1263 /* Trust the MP table if nothing is setup in the hardware */
1264 if ((ioapic_i8259.pin == -1) && (i8259_pin >= 0)) {
1265 printk(KERN_WARNING "ExtINT not setup in hardware but reported by MP table\n");
1266 ioapic_i8259.pin = i8259_pin;
1267 ioapic_i8259.apic = i8259_apic;
1268 }
1269 /* Complain if the MP table and the hardware disagree */
1270 if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) &&
1271 (i8259_pin >= 0) && (ioapic_i8259.pin >= 0))
1272 {
1273 printk(KERN_WARNING "ExtINT in hardware and MP table differ\n");
1210 } 1274 }
1211 1275
1212 /* 1276 /*
@@ -1220,7 +1284,6 @@ static void __init enable_IO_APIC(void)
1220 */ 1284 */
1221void disable_IO_APIC(void) 1285void disable_IO_APIC(void)
1222{ 1286{
1223 int pin;
1224 /* 1287 /*
1225 * Clear the IO-APIC before rebooting: 1288 * Clear the IO-APIC before rebooting:
1226 */ 1289 */
@@ -1231,8 +1294,7 @@ void disable_IO_APIC(void)
1231 * Put that IOAPIC in virtual wire mode 1294 * Put that IOAPIC in virtual wire mode
1232 * so legacy interrupts can be delivered. 1295 * so legacy interrupts can be delivered.
1233 */ 1296 */
1234 pin = find_isa_irq_pin(0, mp_ExtINT); 1297 if (ioapic_i8259.pin != -1) {
1235 if (pin != -1) {
1236 struct IO_APIC_route_entry entry; 1298 struct IO_APIC_route_entry entry;
1237 unsigned long flags; 1299 unsigned long flags;
1238 1300
@@ -1243,21 +1305,23 @@ void disable_IO_APIC(void)
1243 entry.polarity = 0; /* High */ 1305 entry.polarity = 0; /* High */
1244 entry.delivery_status = 0; 1306 entry.delivery_status = 0;
1245 entry.dest_mode = 0; /* Physical */ 1307 entry.dest_mode = 0; /* Physical */
1246 entry.delivery_mode = 7; /* ExtInt */ 1308 entry.delivery_mode = dest_ExtINT; /* ExtInt */
1247 entry.vector = 0; 1309 entry.vector = 0;
1248 entry.dest.physical.physical_dest = 0; 1310 entry.dest.physical.physical_dest =
1249 1311 GET_APIC_ID(apic_read(APIC_ID));
1250 1312
1251 /* 1313 /*
1252 * Add it to the IO-APIC irq-routing table: 1314 * Add it to the IO-APIC irq-routing table:
1253 */ 1315 */
1254 spin_lock_irqsave(&ioapic_lock, flags); 1316 spin_lock_irqsave(&ioapic_lock, flags);
1255 io_apic_write(0, 0x11+2*pin, *(((int *)&entry)+1)); 1317 io_apic_write(ioapic_i8259.apic, 0x11+2*ioapic_i8259.pin,
1256 io_apic_write(0, 0x10+2*pin, *(((int *)&entry)+0)); 1318 *(((int *)&entry)+1));
1319 io_apic_write(ioapic_i8259.apic, 0x10+2*ioapic_i8259.pin,
1320 *(((int *)&entry)+0));
1257 spin_unlock_irqrestore(&ioapic_lock, flags); 1321 spin_unlock_irqrestore(&ioapic_lock, flags);
1258 } 1322 }
1259 1323
1260 disconnect_bsp_APIC(pin != -1); 1324 disconnect_bsp_APIC(ioapic_i8259.pin != -1);
1261} 1325}
1262 1326
1263/* 1327/*
@@ -1571,7 +1635,7 @@ static void enable_lapic_irq (unsigned int irq)
1571 unsigned long v; 1635 unsigned long v;
1572 1636
1573 v = apic_read(APIC_LVT0); 1637 v = apic_read(APIC_LVT0);
1574 apic_write_around(APIC_LVT0, v & ~APIC_LVT_MASKED); 1638 apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED);
1575} 1639}
1576 1640
1577static void disable_lapic_irq (unsigned int irq) 1641static void disable_lapic_irq (unsigned int irq)
@@ -1579,7 +1643,7 @@ static void disable_lapic_irq (unsigned int irq)
1579 unsigned long v; 1643 unsigned long v;
1580 1644
1581 v = apic_read(APIC_LVT0); 1645 v = apic_read(APIC_LVT0);
1582 apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED); 1646 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
1583} 1647}
1584 1648
1585static void ack_lapic_irq (unsigned int irq) 1649static void ack_lapic_irq (unsigned int irq)
@@ -1626,20 +1690,21 @@ static void setup_nmi (void)
1626 */ 1690 */
1627static inline void unlock_ExtINT_logic(void) 1691static inline void unlock_ExtINT_logic(void)
1628{ 1692{
1629 int pin, i; 1693 int apic, pin, i;
1630 struct IO_APIC_route_entry entry0, entry1; 1694 struct IO_APIC_route_entry entry0, entry1;
1631 unsigned char save_control, save_freq_select; 1695 unsigned char save_control, save_freq_select;
1632 unsigned long flags; 1696 unsigned long flags;
1633 1697
1634 pin = find_isa_irq_pin(8, mp_INT); 1698 pin = find_isa_irq_pin(8, mp_INT);
1699 apic = find_isa_irq_apic(8, mp_INT);
1635 if (pin == -1) 1700 if (pin == -1)
1636 return; 1701 return;
1637 1702
1638 spin_lock_irqsave(&ioapic_lock, flags); 1703 spin_lock_irqsave(&ioapic_lock, flags);
1639 *(((int *)&entry0) + 1) = io_apic_read(0, 0x11 + 2 * pin); 1704 *(((int *)&entry0) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
1640 *(((int *)&entry0) + 0) = io_apic_read(0, 0x10 + 2 * pin); 1705 *(((int *)&entry0) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
1641 spin_unlock_irqrestore(&ioapic_lock, flags); 1706 spin_unlock_irqrestore(&ioapic_lock, flags);
1642 clear_IO_APIC_pin(0, pin); 1707 clear_IO_APIC_pin(apic, pin);
1643 1708
1644 memset(&entry1, 0, sizeof(entry1)); 1709 memset(&entry1, 0, sizeof(entry1));
1645 1710
@@ -1652,8 +1717,8 @@ static inline void unlock_ExtINT_logic(void)
1652 entry1.vector = 0; 1717 entry1.vector = 0;
1653 1718
1654 spin_lock_irqsave(&ioapic_lock, flags); 1719 spin_lock_irqsave(&ioapic_lock, flags);
1655 io_apic_write(0, 0x11 + 2 * pin, *(((int *)&entry1) + 1)); 1720 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
1656 io_apic_write(0, 0x10 + 2 * pin, *(((int *)&entry1) + 0)); 1721 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
1657 spin_unlock_irqrestore(&ioapic_lock, flags); 1722 spin_unlock_irqrestore(&ioapic_lock, flags);
1658 1723
1659 save_control = CMOS_READ(RTC_CONTROL); 1724 save_control = CMOS_READ(RTC_CONTROL);
@@ -1671,11 +1736,11 @@ static inline void unlock_ExtINT_logic(void)
1671 1736
1672 CMOS_WRITE(save_control, RTC_CONTROL); 1737 CMOS_WRITE(save_control, RTC_CONTROL);
1673 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); 1738 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
1674 clear_IO_APIC_pin(0, pin); 1739 clear_IO_APIC_pin(apic, pin);
1675 1740
1676 spin_lock_irqsave(&ioapic_lock, flags); 1741 spin_lock_irqsave(&ioapic_lock, flags);
1677 io_apic_write(0, 0x11 + 2 * pin, *(((int *)&entry0) + 1)); 1742 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
1678 io_apic_write(0, 0x10 + 2 * pin, *(((int *)&entry0) + 0)); 1743 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
1679 spin_unlock_irqrestore(&ioapic_lock, flags); 1744 spin_unlock_irqrestore(&ioapic_lock, flags);
1680} 1745}
1681 1746
@@ -1687,7 +1752,7 @@ static inline void unlock_ExtINT_logic(void)
1687 */ 1752 */
1688static inline void check_timer(void) 1753static inline void check_timer(void)
1689{ 1754{
1690 int pin1, pin2; 1755 int apic1, pin1, apic2, pin2;
1691 int vector; 1756 int vector;
1692 1757
1693 /* 1758 /*
@@ -1704,14 +1769,17 @@ static inline void check_timer(void)
1704 * the 8259A which implies the virtual wire has to be 1769 * the 8259A which implies the virtual wire has to be
1705 * disabled in the local APIC. 1770 * disabled in the local APIC.
1706 */ 1771 */
1707 apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); 1772 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
1708 init_8259A(1); 1773 init_8259A(1);
1709 enable_8259A_irq(0); 1774 enable_8259A_irq(0);
1710 1775
1711 pin1 = find_isa_irq_pin(0, mp_INT); 1776 pin1 = find_isa_irq_pin(0, mp_INT);
1712 pin2 = find_isa_irq_pin(0, mp_ExtINT); 1777 apic1 = find_isa_irq_apic(0, mp_INT);
1778 pin2 = ioapic_i8259.pin;
1779 apic2 = ioapic_i8259.apic;
1713 1780
1714 apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X pin1=%d pin2=%d\n", vector, pin1, pin2); 1781 apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n",
1782 vector, apic1, pin1, apic2, pin2);
1715 1783
1716 if (pin1 != -1) { 1784 if (pin1 != -1) {
1717 /* 1785 /*
@@ -1729,17 +1797,20 @@ static inline void check_timer(void)
1729 clear_IO_APIC_pin(0, pin1); 1797 clear_IO_APIC_pin(0, pin1);
1730 return; 1798 return;
1731 } 1799 }
1732 clear_IO_APIC_pin(0, pin1); 1800 clear_IO_APIC_pin(apic1, pin1);
1733 apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not connected to IO-APIC\n"); 1801 apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
1802 "connected to IO-APIC\n");
1734 } 1803 }
1735 1804
1736 apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) through the 8259A ... "); 1805 apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) "
1806 "through the 8259A ... ");
1737 if (pin2 != -1) { 1807 if (pin2 != -1) {
1738 apic_printk(APIC_VERBOSE,"\n..... (found pin %d) ...", pin2); 1808 apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
1809 apic2, pin2);
1739 /* 1810 /*
1740 * legacy devices should be connected to IO APIC #0 1811 * legacy devices should be connected to IO APIC #0
1741 */ 1812 */
1742 setup_ExtINT_IRQ0_pin(pin2, vector); 1813 setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
1743 if (timer_irq_works()) { 1814 if (timer_irq_works()) {
1744 printk("works.\n"); 1815 printk("works.\n");
1745 nmi_watchdog_default(); 1816 nmi_watchdog_default();
@@ -1751,7 +1822,7 @@ static inline void check_timer(void)
1751 /* 1822 /*
1752 * Cleanup, just in case ... 1823 * Cleanup, just in case ...
1753 */ 1824 */
1754 clear_IO_APIC_pin(0, pin2); 1825 clear_IO_APIC_pin(apic2, pin2);
1755 } 1826 }
1756 printk(" failed.\n"); 1827 printk(" failed.\n");
1757 1828
@@ -1764,21 +1835,21 @@ static inline void check_timer(void)
1764 1835
1765 disable_8259A_irq(0); 1836 disable_8259A_irq(0);
1766 irq_desc[0].handler = &lapic_irq_type; 1837 irq_desc[0].handler = &lapic_irq_type;
1767 apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */ 1838 apic_write(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */
1768 enable_8259A_irq(0); 1839 enable_8259A_irq(0);
1769 1840
1770 if (timer_irq_works()) { 1841 if (timer_irq_works()) {
1771 apic_printk(APIC_QUIET, " works.\n"); 1842 apic_printk(APIC_QUIET, " works.\n");
1772 return; 1843 return;
1773 } 1844 }
1774 apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector); 1845 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | vector);
1775 apic_printk(APIC_VERBOSE," failed.\n"); 1846 apic_printk(APIC_VERBOSE," failed.\n");
1776 1847
1777 apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as ExtINT IRQ..."); 1848 apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as ExtINT IRQ...");
1778 1849
1779 init_8259A(0); 1850 init_8259A(0);
1780 make_8259A_irq(0); 1851 make_8259A_irq(0);
1781 apic_write_around(APIC_LVT0, APIC_DM_EXTINT); 1852 apic_write(APIC_LVT0, APIC_DM_EXTINT);
1782 1853
1783 unlock_ExtINT_logic(); 1854 unlock_ExtINT_logic();
1784 1855
diff --git a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
index cde0e868efe3..b81614970ecc 100644
--- a/arch/x86_64/kernel/ioport.c
+++ b/arch/x86_64/kernel/ioport.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/capability.h>
10#include <linux/errno.h> 11#include <linux/errno.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/ioport.h> 13#include <linux/ioport.h>
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index d6a04a8320a3..30d2a1e545fe 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <asm/io_apic.h> 19#include <asm/io_apic.h>
20#include <asm/idle.h>
20 21
21atomic_t irq_err_count; 22atomic_t irq_err_count;
22#ifdef CONFIG_X86_IO_APIC 23#ifdef CONFIG_X86_IO_APIC
@@ -69,13 +70,13 @@ skip:
69 seq_printf(p, "NMI: "); 70 seq_printf(p, "NMI: ");
70 for (j = 0; j < NR_CPUS; j++) 71 for (j = 0; j < NR_CPUS; j++)
71 if (cpu_online(j)) 72 if (cpu_online(j))
72 seq_printf(p, "%10u ", cpu_pda[j].__nmi_count); 73 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
73 seq_putc(p, '\n'); 74 seq_putc(p, '\n');
74#ifdef CONFIG_X86_LOCAL_APIC 75#ifdef CONFIG_X86_LOCAL_APIC
75 seq_printf(p, "LOC: "); 76 seq_printf(p, "LOC: ");
76 for (j = 0; j < NR_CPUS; j++) 77 for (j = 0; j < NR_CPUS; j++)
77 if (cpu_online(j)) 78 if (cpu_online(j))
78 seq_printf(p, "%10u ", cpu_pda[j].apic_timer_irqs); 79 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
79 seq_putc(p, '\n'); 80 seq_putc(p, '\n');
80#endif 81#endif
81 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); 82 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
@@ -98,6 +99,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
98 /* high bits used in ret_from_ code */ 99 /* high bits used in ret_from_ code */
99 unsigned irq = regs->orig_rax & 0xff; 100 unsigned irq = regs->orig_rax & 0xff;
100 101
102 exit_idle();
101 irq_enter(); 103 irq_enter();
102 104
103 __do_IRQ(irq, regs); 105 __do_IRQ(irq, regs);
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index afe11f4fbd1d..8b866a8572cf 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -42,8 +42,8 @@
42#include <asm/pgtable.h> 42#include <asm/pgtable.h>
43#include <asm/kdebug.h> 43#include <asm/kdebug.h>
44 44
45static DECLARE_MUTEX(kprobe_mutex);
46void jprobe_return_end(void); 45void jprobe_return_end(void);
46static void __kprobes arch_copy_kprobe(struct kprobe *p);
47 47
48DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 48DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
49DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 49DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -69,12 +69,11 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn)
69int __kprobes arch_prepare_kprobe(struct kprobe *p) 69int __kprobes arch_prepare_kprobe(struct kprobe *p)
70{ 70{
71 /* insn: must be on special executable page on x86_64. */ 71 /* insn: must be on special executable page on x86_64. */
72 down(&kprobe_mutex);
73 p->ainsn.insn = get_insn_slot(); 72 p->ainsn.insn = get_insn_slot();
74 up(&kprobe_mutex);
75 if (!p->ainsn.insn) { 73 if (!p->ainsn.insn) {
76 return -ENOMEM; 74 return -ENOMEM;
77 } 75 }
76 arch_copy_kprobe(p);
78 return 0; 77 return 0;
79} 78}
80 79
@@ -181,7 +180,7 @@ static inline s32 *is_riprel(u8 *insn)
181 return NULL; 180 return NULL;
182} 181}
183 182
184void __kprobes arch_copy_kprobe(struct kprobe *p) 183static void __kprobes arch_copy_kprobe(struct kprobe *p)
185{ 184{
186 s32 *ripdisp; 185 s32 *ripdisp;
187 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE); 186 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
@@ -335,6 +334,15 @@ int __kprobes kprobe_handler(struct pt_regs *regs)
335 return 1; 334 return 1;
336 } 335 }
337 } else { 336 } else {
337 if (*addr != BREAKPOINT_INSTRUCTION) {
338 /* The breakpoint instruction was removed by
339 * another cpu right after we hit, no further
340 * handling of this interrupt is appropriate
341 */
342 regs->rip = (unsigned long)addr;
343 ret = 1;
344 goto no_kprobe;
345 }
338 p = __get_cpu_var(current_kprobe); 346 p = __get_cpu_var(current_kprobe);
339 if (p->break_handler && p->break_handler(p, regs)) { 347 if (p->break_handler && p->break_handler(p, regs)) {
340 goto ss_probe; 348 goto ss_probe;
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 183dc6105429..13a2eada6c95 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -15,6 +15,7 @@
15#include <linux/sysdev.h> 15#include <linux/sysdev.h>
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/capability.h>
18#include <linux/cpu.h> 19#include <linux/cpu.h>
19#include <linux/percpu.h> 20#include <linux/percpu.h>
20#include <linux/ctype.h> 21#include <linux/ctype.h>
@@ -23,9 +24,10 @@
23#include <asm/mce.h> 24#include <asm/mce.h>
24#include <asm/kdebug.h> 25#include <asm/kdebug.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/smp.h>
26 28
27#define MISC_MCELOG_MINOR 227 29#define MISC_MCELOG_MINOR 227
28#define NR_BANKS 5 30#define NR_BANKS 6
29 31
30static int mce_dont_init; 32static int mce_dont_init;
31 33
@@ -91,6 +93,7 @@ void mce_log(struct mce *mce)
91static void print_mce(struct mce *m) 93static void print_mce(struct mce *m)
92{ 94{
93 printk(KERN_EMERG "\n" 95 printk(KERN_EMERG "\n"
96 KERN_EMERG "HARDWARE ERROR\n"
94 KERN_EMERG 97 KERN_EMERG
95 "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n", 98 "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n",
96 m->cpu, m->mcgstatus, m->bank, m->status); 99 m->cpu, m->mcgstatus, m->bank, m->status);
@@ -109,6 +112,9 @@ static void print_mce(struct mce *m)
109 if (m->misc) 112 if (m->misc)
110 printk("MISC %Lx ", m->misc); 113 printk("MISC %Lx ", m->misc);
111 printk("\n"); 114 printk("\n");
115 printk(KERN_EMERG "This is not a software problem!\n");
116 printk(KERN_EMERG
117 "Run through mcelog --ascii to decode and contact your hardware vendor\n");
112} 118}
113 119
114static void mce_panic(char *msg, struct mce *backup, unsigned long start) 120static void mce_panic(char *msg, struct mce *backup, unsigned long start)
@@ -168,12 +174,12 @@ void do_machine_check(struct pt_regs * regs, long error_code)
168 int panicm_found = 0; 174 int panicm_found = 0;
169 175
170 if (regs) 176 if (regs)
171 notify_die(DIE_NMI, "machine check", regs, error_code, 255, SIGKILL); 177 notify_die(DIE_NMI, "machine check", regs, error_code, 18, SIGKILL);
172 if (!banks) 178 if (!banks)
173 return; 179 return;
174 180
175 memset(&m, 0, sizeof(struct mce)); 181 memset(&m, 0, sizeof(struct mce));
176 m.cpu = hard_smp_processor_id(); 182 m.cpu = safe_smp_processor_id();
177 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); 183 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
178 if (!(m.mcgstatus & MCG_STATUS_RIPV)) 184 if (!(m.mcgstatus & MCG_STATUS_RIPV))
179 kill_it = 1; 185 kill_it = 1;
@@ -573,6 +579,10 @@ ACCESSOR(bank1ctl,bank[1],mce_restart())
573ACCESSOR(bank2ctl,bank[2],mce_restart()) 579ACCESSOR(bank2ctl,bank[2],mce_restart())
574ACCESSOR(bank3ctl,bank[3],mce_restart()) 580ACCESSOR(bank3ctl,bank[3],mce_restart())
575ACCESSOR(bank4ctl,bank[4],mce_restart()) 581ACCESSOR(bank4ctl,bank[4],mce_restart())
582ACCESSOR(bank5ctl,bank[5],mce_restart())
583static struct sysdev_attribute * bank_attributes[NR_BANKS] = {
584 &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
585 &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl};
576ACCESSOR(tolerant,tolerant,) 586ACCESSOR(tolerant,tolerant,)
577ACCESSOR(check_interval,check_interval,mce_restart()) 587ACCESSOR(check_interval,check_interval,mce_restart())
578 588
@@ -580,6 +590,7 @@ ACCESSOR(check_interval,check_interval,mce_restart())
580static __cpuinit int mce_create_device(unsigned int cpu) 590static __cpuinit int mce_create_device(unsigned int cpu)
581{ 591{
582 int err; 592 int err;
593 int i;
583 if (!mce_available(&cpu_data[cpu])) 594 if (!mce_available(&cpu_data[cpu]))
584 return -EIO; 595 return -EIO;
585 596
@@ -589,11 +600,9 @@ static __cpuinit int mce_create_device(unsigned int cpu)
589 err = sysdev_register(&per_cpu(device_mce,cpu)); 600 err = sysdev_register(&per_cpu(device_mce,cpu));
590 601
591 if (!err) { 602 if (!err) {
592 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank0ctl); 603 for (i = 0; i < banks; i++)
593 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank1ctl); 604 sysdev_create_file(&per_cpu(device_mce,cpu),
594 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank2ctl); 605 bank_attributes[i]);
595 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank3ctl);
596 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_bank4ctl);
597 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_tolerant); 606 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_tolerant);
598 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_check_interval); 607 sysdev_create_file(&per_cpu(device_mce,cpu), &attr_check_interval);
599 } 608 }
@@ -603,11 +612,11 @@ static __cpuinit int mce_create_device(unsigned int cpu)
603#ifdef CONFIG_HOTPLUG_CPU 612#ifdef CONFIG_HOTPLUG_CPU
604static __cpuinit void mce_remove_device(unsigned int cpu) 613static __cpuinit void mce_remove_device(unsigned int cpu)
605{ 614{
606 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank0ctl); 615 int i;
607 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank1ctl); 616
608 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank2ctl); 617 for (i = 0; i < banks; i++)
609 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank3ctl); 618 sysdev_remove_file(&per_cpu(device_mce,cpu),
610 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_bank4ctl); 619 bank_attributes[i]);
611 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant); 620 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant);
612 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval); 621 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval);
613 sysdev_unregister(&per_cpu(device_mce,cpu)); 622 sysdev_unregister(&per_cpu(device_mce,cpu));
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 1f76175ace02..d3ad7d81266d 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -27,6 +27,7 @@
27#include <asm/mce.h> 27#include <asm/mce.h>
28#include <asm/msr.h> 28#include <asm/msr.h>
29#include <asm/percpu.h> 29#include <asm/percpu.h>
30#include <asm/idle.h>
30 31
31#define PFX "mce_threshold: " 32#define PFX "mce_threshold: "
32#define VERSION "version 1.00.9" 33#define VERSION "version 1.00.9"
@@ -140,6 +141,7 @@ asmlinkage void mce_threshold_interrupt(void)
140 struct mce m; 141 struct mce m;
141 142
142 ack_APIC_irq(); 143 ack_APIC_irq();
144 exit_idle();
143 irq_enter(); 145 irq_enter();
144 146
145 memset(&m, 0, sizeof(m)); 147 memset(&m, 0, sizeof(m));
@@ -318,7 +320,7 @@ static struct kobj_type threshold_ktype = {
318static __cpuinit int threshold_create_bank(unsigned int cpu, int bank) 320static __cpuinit int threshold_create_bank(unsigned int cpu, int bank)
319{ 321{
320 int err = 0; 322 int err = 0;
321 struct threshold_bank *b = 0; 323 struct threshold_bank *b = NULL;
322 324
323#ifdef CONFIG_SMP 325#ifdef CONFIG_SMP
324 if (cpu_core_id[cpu] && shared_bank[bank]) { /* symlink */ 326 if (cpu_core_id[cpu] && shared_bank[bank]) { /* symlink */
@@ -407,7 +409,7 @@ static __cpuinit void threshold_remove_bank(unsigned int cpu, int bank)
407 if (shared_bank[bank] && atomic_read(&b->kobj.kref.refcount) > 2) { 409 if (shared_bank[bank] && atomic_read(&b->kobj.kref.refcount) > 2) {
408 sprintf(name, "bank%i", bank); 410 sprintf(name, "bank%i", bank);
409 sysfs_remove_link(&per_cpu(device_threshold, cpu).kobj, name); 411 sysfs_remove_link(&per_cpu(device_threshold, cpu).kobj, name);
410 per_cpu(threshold_banks, cpu)[bank] = 0; 412 per_cpu(threshold_banks, cpu)[bank] = NULL;
411 } else { 413 } else {
412 kobject_unregister(&b->kobj); 414 kobject_unregister(&b->kobj);
413 kfree(per_cpu(threshold_banks, cpu)[bank]); 415 kfree(per_cpu(threshold_banks, cpu)[bank]);
diff --git a/arch/x86_64/kernel/mce_intel.c b/arch/x86_64/kernel/mce_intel.c
index 0be0a7959814..8f533d2c40cb 100644
--- a/arch/x86_64/kernel/mce_intel.c
+++ b/arch/x86_64/kernel/mce_intel.c
@@ -10,6 +10,7 @@
10#include <asm/msr.h> 10#include <asm/msr.h>
11#include <asm/mce.h> 11#include <asm/mce.h>
12#include <asm/hw_irq.h> 12#include <asm/hw_irq.h>
13#include <asm/idle.h>
13 14
14static DEFINE_PER_CPU(unsigned long, next_check); 15static DEFINE_PER_CPU(unsigned long, next_check);
15 16
@@ -19,6 +20,7 @@ asmlinkage void smp_thermal_interrupt(void)
19 20
20 ack_APIC_irq(); 21 ack_APIC_irq();
21 22
23 exit_idle();
22 irq_enter(); 24 irq_enter();
23 if (time_before(jiffies, __get_cpu_var(next_check))) 25 if (time_before(jiffies, __get_cpu_var(next_check)))
24 goto done; 26 goto done;
@@ -78,7 +80,7 @@ static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
78 80
79 h = THERMAL_APIC_VECTOR; 81 h = THERMAL_APIC_VECTOR;
80 h |= (APIC_DM_FIXED | APIC_LVT_MASKED); 82 h |= (APIC_DM_FIXED | APIC_LVT_MASKED);
81 apic_write_around(APIC_LVTTHMR, h); 83 apic_write(APIC_LVTTHMR, h);
82 84
83 rdmsr(MSR_IA32_THERM_INTERRUPT, l, h); 85 rdmsr(MSR_IA32_THERM_INTERRUPT, l, h);
84 wrmsr(MSR_IA32_THERM_INTERRUPT, l | 0x03, h); 86 wrmsr(MSR_IA32_THERM_INTERRUPT, l | 0x03, h);
@@ -87,7 +89,7 @@ static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
87 wrmsr(MSR_IA32_MISC_ENABLE, l | (1 << 3), h); 89 wrmsr(MSR_IA32_MISC_ENABLE, l | (1 << 3), h);
88 90
89 l = apic_read(APIC_LVTTHMR); 91 l = apic_read(APIC_LVTTHMR);
90 apic_write_around(APIC_LVTTHMR, l & ~APIC_LVT_MASKED); 92 apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
91 printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n", 93 printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
92 cpu, tm2 ? "TM2" : "TM1"); 94 cpu, tm2 ? "TM2" : "TM1");
93 return; 95 return;
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 39d445e16f22..5fae6f0cd994 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -151,23 +151,25 @@ int __init check_nmi_watchdog (void)
151 151
152 printk(KERN_INFO "testing NMI watchdog ... "); 152 printk(KERN_INFO "testing NMI watchdog ... ");
153 153
154#ifdef CONFIG_SMP
154 if (nmi_watchdog == NMI_LOCAL_APIC) 155 if (nmi_watchdog == NMI_LOCAL_APIC)
155 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0); 156 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
157#endif
156 158
157 for (cpu = 0; cpu < NR_CPUS; cpu++) 159 for (cpu = 0; cpu < NR_CPUS; cpu++)
158 counts[cpu] = cpu_pda[cpu].__nmi_count; 160 counts[cpu] = cpu_pda(cpu)->__nmi_count;
159 local_irq_enable(); 161 local_irq_enable();
160 mdelay((10*1000)/nmi_hz); // wait 10 ticks 162 mdelay((10*1000)/nmi_hz); // wait 10 ticks
161 163
162 for (cpu = 0; cpu < NR_CPUS; cpu++) { 164 for (cpu = 0; cpu < NR_CPUS; cpu++) {
163 if (!cpu_online(cpu)) 165 if (!cpu_online(cpu))
164 continue; 166 continue;
165 if (cpu_pda[cpu].__nmi_count - counts[cpu] <= 5) { 167 if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
166 endflag = 1; 168 endflag = 1;
167 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n", 169 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
168 cpu, 170 cpu,
169 counts[cpu], 171 counts[cpu],
170 cpu_pda[cpu].__nmi_count); 172 cpu_pda(cpu)->__nmi_count);
171 nmi_active = 0; 173 nmi_active = 0;
172 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG; 174 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG;
173 nmi_perfctr_msr = 0; 175 nmi_perfctr_msr = 0;
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index cab471cf3edb..2f5d8328e2b9 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -8,53 +8,259 @@
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <asm/io.h> 10#include <asm/io.h>
11#include <asm/proto.h>
11 12
12/* Map a set of buffers described by scatterlist in streaming 13int iommu_merge __read_mostly = 0;
13 * mode for DMA. This is the scatter-gather version of the 14EXPORT_SYMBOL(iommu_merge);
14 * above pci_map_single interface. Here the scatter gather list 15
15 * elements are each tagged with the appropriate dma address 16dma_addr_t bad_dma_address __read_mostly;
16 * and length. They are obtained via sg_dma_{address,length}(SG). 17EXPORT_SYMBOL(bad_dma_address);
17 * 18
18 * NOTE: An implementation may be able to use a smaller number of 19/* This tells the BIO block layer to assume merging. Default to off
19 * DMA address/length pairs than there are SG table elements. 20 because we cannot guarantee merging later. */
20 * (for example via virtual mapping capabilities) 21int iommu_bio_merge __read_mostly = 0;
21 * The routine returns the number of addr/length pairs actually 22EXPORT_SYMBOL(iommu_bio_merge);
22 * used, at most nents. 23
23 * 24int iommu_sac_force __read_mostly = 0;
24 * Device ownership issues as mentioned above for pci_map_single are 25EXPORT_SYMBOL(iommu_sac_force);
25 * the same here. 26
27int no_iommu __read_mostly;
28#ifdef CONFIG_IOMMU_DEBUG
29int panic_on_overflow __read_mostly = 1;
30int force_iommu __read_mostly = 1;
31#else
32int panic_on_overflow __read_mostly = 0;
33int force_iommu __read_mostly= 0;
34#endif
35
36/* Dummy device used for NULL arguments (normally ISA). Better would
37 be probably a smaller DMA mask, but this is bug-to-bug compatible
38 to i386. */
39struct device fallback_dev = {
40 .bus_id = "fallback device",
41 .coherent_dma_mask = 0xffffffff,
42 .dma_mask = &fallback_dev.coherent_dma_mask,
43};
44
45/* Allocate DMA memory on node near device */
46noinline static void *
47dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
48{
49 struct page *page;
50 int node;
51 if (dev->bus == &pci_bus_type)
52 node = pcibus_to_node(to_pci_dev(dev)->bus);
53 else
54 node = numa_node_id();
55 page = alloc_pages_node(node, gfp, order);
56 return page ? page_address(page) : NULL;
57}
58
59/*
60 * Allocate memory for a coherent mapping.
26 */ 61 */
27int dma_map_sg(struct device *hwdev, struct scatterlist *sg, 62void *
28 int nents, int direction) 63dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
64 gfp_t gfp)
29{ 65{
30 int i; 66 void *memory;
31 67 unsigned long dma_mask = 0;
32 BUG_ON(direction == DMA_NONE); 68 u64 bus;
33 for (i = 0; i < nents; i++ ) { 69
34 struct scatterlist *s = &sg[i]; 70 if (!dev)
35 BUG_ON(!s->page); 71 dev = &fallback_dev;
36 s->dma_address = virt_to_bus(page_address(s->page) +s->offset); 72 dma_mask = dev->coherent_dma_mask;
37 s->dma_length = s->length; 73 if (dma_mask == 0)
74 dma_mask = 0xffffffff;
75
76 /* Kludge to make it bug-to-bug compatible with i386. i386
77 uses the normal dma_mask for alloc_coherent. */
78 dma_mask &= *dev->dma_mask;
79
80 /* Why <=? Even when the mask is smaller than 4GB it is often
81 larger than 16MB and in this case we have a chance of
82 finding fitting memory in the next higher zone first. If
83 not retry with true GFP_DMA. -AK */
84 if (dma_mask <= 0xffffffff)
85 gfp |= GFP_DMA32;
86
87 again:
88 memory = dma_alloc_pages(dev, gfp, get_order(size));
89 if (memory == NULL)
90 return NULL;
91
92 {
93 int high, mmu;
94 bus = virt_to_bus(memory);
95 high = (bus + size) >= dma_mask;
96 mmu = high;
97 if (force_iommu && !(gfp & GFP_DMA))
98 mmu = 1;
99 else if (high) {
100 free_pages((unsigned long)memory,
101 get_order(size));
102
103 /* Don't use the 16MB ZONE_DMA unless absolutely
104 needed. It's better to use remapping first. */
105 if (dma_mask < 0xffffffff && !(gfp & GFP_DMA)) {
106 gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
107 goto again;
108 }
109
110 if (dma_ops->alloc_coherent)
111 return dma_ops->alloc_coherent(dev, size,
112 dma_handle, gfp);
113 return NULL;
114 }
115
116 memset(memory, 0, size);
117 if (!mmu) {
118 *dma_handle = virt_to_bus(memory);
119 return memory;
120 }
121 }
122
123 if (dma_ops->alloc_coherent) {
124 free_pages((unsigned long)memory, get_order(size));
125 gfp &= ~(GFP_DMA|GFP_DMA32);
126 return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
127 }
128
129 if (dma_ops->map_simple) {
130 *dma_handle = dma_ops->map_simple(dev, memory,
131 size,
132 PCI_DMA_BIDIRECTIONAL);
133 if (*dma_handle != bad_dma_address)
134 return memory;
38 } 135 }
39 return nents;
40}
41 136
42EXPORT_SYMBOL(dma_map_sg); 137 if (panic_on_overflow)
138 panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
139 free_pages((unsigned long)memory, get_order(size));
140 return NULL;
141}
142EXPORT_SYMBOL(dma_alloc_coherent);
43 143
44/* Unmap a set of streaming mode DMA translations. 144/*
45 * Again, cpu read rules concerning calls here are the same as for 145 * Unmap coherent memory.
46 * pci_unmap_single() above. 146 * The caller must ensure that the device has finished accessing the mapping.
47 */ 147 */
48void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 148void dma_free_coherent(struct device *dev, size_t size,
49 int nents, int dir) 149 void *vaddr, dma_addr_t bus)
150{
151 if (dma_ops->unmap_single)
152 dma_ops->unmap_single(dev, bus, size, 0);
153 free_pages((unsigned long)vaddr, get_order(size));
154}
155EXPORT_SYMBOL(dma_free_coherent);
156
157int dma_supported(struct device *dev, u64 mask)
158{
159 if (dma_ops->dma_supported)
160 return dma_ops->dma_supported(dev, mask);
161
162 /* Copied from i386. Doesn't make much sense, because it will
163 only work for pci_alloc_coherent.
164 The caller just has to use GFP_DMA in this case. */
165 if (mask < 0x00ffffff)
166 return 0;
167
168 /* Tell the device to use SAC when IOMMU force is on. This
169 allows the driver to use cheaper accesses in some cases.
170
171 Problem with this is that if we overflow the IOMMU area and
172 return DAC as fallback address the device may not handle it
173 correctly.
174
175 As a special case some controllers have a 39bit address
176 mode that is as efficient as 32bit (aic79xx). Don't force
177 SAC for these. Assume all masks <= 40 bits are of this
178 type. Normally this doesn't make any difference, but gives
179 more gentle handling of IOMMU overflow. */
180 if (iommu_sac_force && (mask >= 0xffffffffffULL)) {
181 printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
182 return 0;
183 }
184
185 return 1;
186}
187EXPORT_SYMBOL(dma_supported);
188
189int dma_set_mask(struct device *dev, u64 mask)
50{ 190{
51 int i; 191 if (!dev->dma_mask || !dma_supported(dev, mask))
52 for (i = 0; i < nents; i++) { 192 return -EIO;
53 struct scatterlist *s = &sg[i]; 193 *dev->dma_mask = mask;
54 BUG_ON(s->page == NULL); 194 return 0;
55 BUG_ON(s->dma_address == 0);
56 dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
57 }
58} 195}
196EXPORT_SYMBOL(dma_set_mask);
197
198/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
199 [,forcesac][,fullflush][,nomerge][,biomerge]
200 size set size of iommu (in bytes)
201 noagp don't initialize the AGP driver and use full aperture.
202 off don't use the IOMMU
203 leak turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
204 memaper[=order] allocate an own aperture over RAM with size 32MB^order.
205 noforce don't force IOMMU usage. Default.
206 force Force IOMMU.
207 merge Do lazy merging. This may improve performance on some block devices.
208 Implies force (experimental)
209 biomerge Do merging at the BIO layer. This is more efficient than merge,
210 but should be only done with very big IOMMUs. Implies merge,force.
211 nomerge Don't do SG merging.
212 forcesac For SAC mode for masks <40bits (experimental)
213 fullflush Flush IOMMU on each allocation (default)
214 nofullflush Don't use IOMMU fullflush
215 allowed overwrite iommu off workarounds for specific chipsets.
216 soft Use software bounce buffering (default for Intel machines)
217 noaperture Don't touch the aperture for AGP.
218*/
219__init int iommu_setup(char *p)
220{
221 iommu_merge = 1;
59 222
60EXPORT_SYMBOL(dma_unmap_sg); 223 while (*p) {
224 if (!strncmp(p,"off",3))
225 no_iommu = 1;
226 /* gart_parse_options has more force support */
227 if (!strncmp(p,"force",5))
228 force_iommu = 1;
229 if (!strncmp(p,"noforce",7)) {
230 iommu_merge = 0;
231 force_iommu = 0;
232 }
233
234 if (!strncmp(p, "biomerge",8)) {
235 iommu_bio_merge = 4096;
236 iommu_merge = 1;
237 force_iommu = 1;
238 }
239 if (!strncmp(p, "panic",5))
240 panic_on_overflow = 1;
241 if (!strncmp(p, "nopanic",7))
242 panic_on_overflow = 0;
243 if (!strncmp(p, "merge",5)) {
244 iommu_merge = 1;
245 force_iommu = 1;
246 }
247 if (!strncmp(p, "nomerge",7))
248 iommu_merge = 0;
249 if (!strncmp(p, "forcesac",8))
250 iommu_sac_force = 1;
251
252#ifdef CONFIG_SWIOTLB
253 if (!strncmp(p, "soft",4))
254 swiotlb = 1;
255#endif
256
257#ifdef CONFIG_GART_IOMMU
258 gart_parse_options(p);
259#endif
260
261 p += strcspn(p, ",");
262 if (*p == ',')
263 ++p;
264 }
265 return 1;
266}
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 2e28e855ec3c..c37fc7726ba6 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -30,8 +30,8 @@
30#include <asm/proto.h> 30#include <asm/proto.h>
31#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
32#include <asm/kdebug.h> 32#include <asm/kdebug.h>
33 33#include <asm/swiotlb.h>
34dma_addr_t bad_dma_address; 34#include <asm/dma.h>
35 35
36unsigned long iommu_bus_base; /* GART remapping area (physical) */ 36unsigned long iommu_bus_base; /* GART remapping area (physical) */
37static unsigned long iommu_size; /* size of remapping area bytes */ 37static unsigned long iommu_size; /* size of remapping area bytes */
@@ -39,18 +39,6 @@ static unsigned long iommu_pages; /* .. and in pages */
39 39
40u32 *iommu_gatt_base; /* Remapping table */ 40u32 *iommu_gatt_base; /* Remapping table */
41 41
42int no_iommu;
43static int no_agp;
44#ifdef CONFIG_IOMMU_DEBUG
45int panic_on_overflow = 1;
46int force_iommu = 1;
47#else
48int panic_on_overflow = 0;
49int force_iommu = 0;
50#endif
51int iommu_merge = 1;
52int iommu_sac_force = 0;
53
54/* If this is disabled the IOMMU will use an optimized flushing strategy 42/* If this is disabled the IOMMU will use an optimized flushing strategy
55 of only flushing when an mapping is reused. With it true the GART is flushed 43 of only flushing when an mapping is reused. With it true the GART is flushed
56 for every mapping. Problem is that doing the lazy flush seems to trigger 44 for every mapping. Problem is that doing the lazy flush seems to trigger
@@ -58,10 +46,6 @@ int iommu_sac_force = 0;
58 also seen with Qlogic at least). */ 46 also seen with Qlogic at least). */
59int iommu_fullflush = 1; 47int iommu_fullflush = 1;
60 48
61/* This tells the BIO block layer to assume merging. Default to off
62 because we cannot guarantee merging later. */
63int iommu_bio_merge = 0;
64
65#define MAX_NB 8 49#define MAX_NB 8
66 50
67/* Allocation bitmap for the remapping area */ 51/* Allocation bitmap for the remapping area */
@@ -102,16 +86,6 @@ AGPEXTERN __u32 *agp_gatt_table;
102 86
103static unsigned long next_bit; /* protected by iommu_bitmap_lock */ 87static unsigned long next_bit; /* protected by iommu_bitmap_lock */
104static int need_flush; /* global flush state. set for each gart wrap */ 88static int need_flush; /* global flush state. set for each gart wrap */
105static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
106 size_t size, int dir, int do_panic);
107
108/* Dummy device used for NULL arguments (normally ISA). Better would
109 be probably a smaller DMA mask, but this is bug-to-bug compatible to i386. */
110static struct device fallback_dev = {
111 .bus_id = "fallback device",
112 .coherent_dma_mask = 0xffffffff,
113 .dma_mask = &fallback_dev.coherent_dma_mask,
114};
115 89
116static unsigned long alloc_iommu(int size) 90static unsigned long alloc_iommu(int size)
117{ 91{
@@ -185,114 +159,7 @@ static void flush_gart(struct device *dev)
185 spin_unlock_irqrestore(&iommu_bitmap_lock, flags); 159 spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
186} 160}
187 161
188/* Allocate DMA memory on node near device */
189noinline
190static void *dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
191{
192 struct page *page;
193 int node;
194 if (dev->bus == &pci_bus_type)
195 node = pcibus_to_node(to_pci_dev(dev)->bus);
196 else
197 node = numa_node_id();
198 page = alloc_pages_node(node, gfp, order);
199 return page ? page_address(page) : NULL;
200}
201
202/*
203 * Allocate memory for a coherent mapping.
204 */
205void *
206dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
207 gfp_t gfp)
208{
209 void *memory;
210 unsigned long dma_mask = 0;
211 u64 bus;
212 162
213 if (!dev)
214 dev = &fallback_dev;
215 dma_mask = dev->coherent_dma_mask;
216 if (dma_mask == 0)
217 dma_mask = 0xffffffff;
218
219 /* Kludge to make it bug-to-bug compatible with i386. i386
220 uses the normal dma_mask for alloc_coherent. */
221 dma_mask &= *dev->dma_mask;
222
223 /* Why <=? Even when the mask is smaller than 4GB it is often larger
224 than 16MB and in this case we have a chance of finding fitting memory
225 in the next higher zone first. If not retry with true GFP_DMA. -AK */
226 if (dma_mask <= 0xffffffff)
227 gfp |= GFP_DMA32;
228
229 again:
230 memory = dma_alloc_pages(dev, gfp, get_order(size));
231 if (memory == NULL)
232 return NULL;
233
234 {
235 int high, mmu;
236 bus = virt_to_bus(memory);
237 high = (bus + size) >= dma_mask;
238 mmu = high;
239 if (force_iommu && !(gfp & GFP_DMA))
240 mmu = 1;
241 if (no_iommu || dma_mask < 0xffffffffUL) {
242 if (high) {
243 free_pages((unsigned long)memory,
244 get_order(size));
245
246 if (swiotlb) {
247 return
248 swiotlb_alloc_coherent(dev, size,
249 dma_handle,
250 gfp);
251 }
252
253 if (!(gfp & GFP_DMA)) {
254 gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
255 goto again;
256 }
257 return NULL;
258 }
259 mmu = 0;
260 }
261 memset(memory, 0, size);
262 if (!mmu) {
263 *dma_handle = virt_to_bus(memory);
264 return memory;
265 }
266 }
267
268 *dma_handle = dma_map_area(dev, bus, size, PCI_DMA_BIDIRECTIONAL, 0);
269 if (*dma_handle == bad_dma_address)
270 goto error;
271 flush_gart(dev);
272 return memory;
273
274error:
275 if (panic_on_overflow)
276 panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n", size);
277 free_pages((unsigned long)memory, get_order(size));
278 return NULL;
279}
280
281/*
282 * Unmap coherent memory.
283 * The caller must ensure that the device has finished accessing the mapping.
284 */
285void dma_free_coherent(struct device *dev, size_t size,
286 void *vaddr, dma_addr_t bus)
287{
288 if (swiotlb) {
289 swiotlb_free_coherent(dev, size, vaddr, bus);
290 return;
291 }
292
293 dma_unmap_single(dev, bus, size, 0);
294 free_pages((unsigned long)vaddr, get_order(size));
295}
296 163
297#ifdef CONFIG_IOMMU_LEAK 164#ifdef CONFIG_IOMMU_LEAK
298 165
@@ -326,7 +193,7 @@ void dump_leak(void)
326#define CLEAR_LEAK(x) 193#define CLEAR_LEAK(x)
327#endif 194#endif
328 195
329static void iommu_full(struct device *dev, size_t size, int dir, int do_panic) 196static void iommu_full(struct device *dev, size_t size, int dir)
330{ 197{
331 /* 198 /*
332 * Ran out of IOMMU space for this operation. This is very bad. 199 * Ran out of IOMMU space for this operation. This is very bad.
@@ -342,11 +209,11 @@ static void iommu_full(struct device *dev, size_t size, int dir, int do_panic)
342 "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n", 209 "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
343 size, dev->bus_id); 210 size, dev->bus_id);
344 211
345 if (size > PAGE_SIZE*EMERGENCY_PAGES && do_panic) { 212 if (size > PAGE_SIZE*EMERGENCY_PAGES) {
346 if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL) 213 if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
347 panic("PCI-DMA: Memory would be corrupted\n"); 214 panic("PCI-DMA: Memory would be corrupted\n");
348 if (dir == PCI_DMA_TODEVICE || dir == PCI_DMA_BIDIRECTIONAL) 215 if (dir == PCI_DMA_TODEVICE || dir == PCI_DMA_BIDIRECTIONAL)
349 panic("PCI-DMA: Random memory would be DMAed\n"); 216 panic(KERN_ERR "PCI-DMA: Random memory would be DMAed\n");
350 } 217 }
351 218
352#ifdef CONFIG_IOMMU_LEAK 219#ifdef CONFIG_IOMMU_LEAK
@@ -385,8 +252,8 @@ static inline int nonforced_iommu(struct device *dev, unsigned long addr, size_t
385/* Map a single continuous physical area into the IOMMU. 252/* Map a single continuous physical area into the IOMMU.
386 * Caller needs to check if the iommu is needed and flush. 253 * Caller needs to check if the iommu is needed and flush.
387 */ 254 */
388static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem, 255static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
389 size_t size, int dir, int do_panic) 256 size_t size, int dir)
390{ 257{
391 unsigned long npages = to_pages(phys_mem, size); 258 unsigned long npages = to_pages(phys_mem, size);
392 unsigned long iommu_page = alloc_iommu(npages); 259 unsigned long iommu_page = alloc_iommu(npages);
@@ -396,7 +263,7 @@ static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
396 return phys_mem; 263 return phys_mem;
397 if (panic_on_overflow) 264 if (panic_on_overflow)
398 panic("dma_map_area overflow %lu bytes\n", size); 265 panic("dma_map_area overflow %lu bytes\n", size);
399 iommu_full(dev, size, dir, do_panic); 266 iommu_full(dev, size, dir);
400 return bad_dma_address; 267 return bad_dma_address;
401 } 268 }
402 269
@@ -408,15 +275,21 @@ static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
408 return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK); 275 return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK);
409} 276}
410 277
278static dma_addr_t gart_map_simple(struct device *dev, char *buf,
279 size_t size, int dir)
280{
281 dma_addr_t map = dma_map_area(dev, virt_to_bus(buf), size, dir);
282 flush_gart(dev);
283 return map;
284}
285
411/* Map a single area into the IOMMU */ 286/* Map a single area into the IOMMU */
412dma_addr_t dma_map_single(struct device *dev, void *addr, size_t size, int dir) 287dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
413{ 288{
414 unsigned long phys_mem, bus; 289 unsigned long phys_mem, bus;
415 290
416 BUG_ON(dir == DMA_NONE); 291 BUG_ON(dir == DMA_NONE);
417 292
418 if (swiotlb)
419 return swiotlb_map_single(dev,addr,size,dir);
420 if (!dev) 293 if (!dev)
421 dev = &fallback_dev; 294 dev = &fallback_dev;
422 295
@@ -424,10 +297,24 @@ dma_addr_t dma_map_single(struct device *dev, void *addr, size_t size, int dir)
424 if (!need_iommu(dev, phys_mem, size)) 297 if (!need_iommu(dev, phys_mem, size))
425 return phys_mem; 298 return phys_mem;
426 299
427 bus = dma_map_area(dev, phys_mem, size, dir, 1); 300 bus = gart_map_simple(dev, addr, size, dir);
428 flush_gart(dev);
429 return bus; 301 return bus;
430} 302}
303
304/*
305 * Wrapper for pci_unmap_single working with scatterlists.
306 */
307void gart_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
308{
309 int i;
310
311 for (i = 0; i < nents; i++) {
312 struct scatterlist *s = &sg[i];
313 if (!s->dma_length || !s->length)
314 break;
315 dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
316 }
317}
431 318
432/* Fallback for dma_map_sg in case of overflow */ 319/* Fallback for dma_map_sg in case of overflow */
433static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg, 320static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
@@ -443,10 +330,10 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
443 struct scatterlist *s = &sg[i]; 330 struct scatterlist *s = &sg[i];
444 unsigned long addr = page_to_phys(s->page) + s->offset; 331 unsigned long addr = page_to_phys(s->page) + s->offset;
445 if (nonforced_iommu(dev, addr, s->length)) { 332 if (nonforced_iommu(dev, addr, s->length)) {
446 addr = dma_map_area(dev, addr, s->length, dir, 0); 333 addr = dma_map_area(dev, addr, s->length, dir);
447 if (addr == bad_dma_address) { 334 if (addr == bad_dma_address) {
448 if (i > 0) 335 if (i > 0)
449 dma_unmap_sg(dev, sg, i, dir); 336 gart_unmap_sg(dev, sg, i, dir);
450 nents = 0; 337 nents = 0;
451 sg[0].dma_length = 0; 338 sg[0].dma_length = 0;
452 break; 339 break;
@@ -515,7 +402,7 @@ static inline int dma_map_cont(struct scatterlist *sg, int start, int stopat,
515 * DMA map all entries in a scatterlist. 402 * DMA map all entries in a scatterlist.
516 * Merge chunks that have page aligned sizes into a continuous mapping. 403 * Merge chunks that have page aligned sizes into a continuous mapping.
517 */ 404 */
518int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir) 405int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
519{ 406{
520 int i; 407 int i;
521 int out; 408 int out;
@@ -527,8 +414,6 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
527 if (nents == 0) 414 if (nents == 0)
528 return 0; 415 return 0;
529 416
530 if (swiotlb)
531 return swiotlb_map_sg(dev,sg,nents,dir);
532 if (!dev) 417 if (!dev)
533 dev = &fallback_dev; 418 dev = &fallback_dev;
534 419
@@ -571,13 +456,13 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
571 456
572error: 457error:
573 flush_gart(NULL); 458 flush_gart(NULL);
574 dma_unmap_sg(dev, sg, nents, dir); 459 gart_unmap_sg(dev, sg, nents, dir);
575 /* When it was forced try again unforced */ 460 /* When it was forced try again unforced */
576 if (force_iommu) 461 if (force_iommu)
577 return dma_map_sg_nonforce(dev, sg, nents, dir); 462 return dma_map_sg_nonforce(dev, sg, nents, dir);
578 if (panic_on_overflow) 463 if (panic_on_overflow)
579 panic("dma_map_sg: overflow on %lu pages\n", pages); 464 panic("dma_map_sg: overflow on %lu pages\n", pages);
580 iommu_full(dev, pages << PAGE_SHIFT, dir, 0); 465 iommu_full(dev, pages << PAGE_SHIFT, dir);
581 for (i = 0; i < nents; i++) 466 for (i = 0; i < nents; i++)
582 sg[i].dma_address = bad_dma_address; 467 sg[i].dma_address = bad_dma_address;
583 return 0; 468 return 0;
@@ -586,18 +471,13 @@ error:
586/* 471/*
587 * Free a DMA mapping. 472 * Free a DMA mapping.
588 */ 473 */
589void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 474void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
590 size_t size, int direction) 475 size_t size, int direction)
591{ 476{
592 unsigned long iommu_page; 477 unsigned long iommu_page;
593 int npages; 478 int npages;
594 int i; 479 int i;
595 480
596 if (swiotlb) {
597 swiotlb_unmap_single(dev,dma_addr,size,direction);
598 return;
599 }
600
601 if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE || 481 if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE ||
602 dma_addr >= iommu_bus_base + iommu_size) 482 dma_addr >= iommu_bus_base + iommu_size)
603 return; 483 return;
@@ -610,68 +490,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
610 free_iommu(iommu_page, npages); 490 free_iommu(iommu_page, npages);
611} 491}
612 492
613/* 493static int no_agp;
614 * Wrapper for pci_unmap_single working with scatterlists.
615 */
616void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
617{
618 int i;
619 if (swiotlb) {
620 swiotlb_unmap_sg(dev,sg,nents,dir);
621 return;
622 }
623 for (i = 0; i < nents; i++) {
624 struct scatterlist *s = &sg[i];
625 if (!s->dma_length || !s->length)
626 break;
627 dma_unmap_single(dev, s->dma_address, s->dma_length, dir);
628 }
629}
630
631int dma_supported(struct device *dev, u64 mask)
632{
633 /* Copied from i386. Doesn't make much sense, because it will
634 only work for pci_alloc_coherent.
635 The caller just has to use GFP_DMA in this case. */
636 if (mask < 0x00ffffff)
637 return 0;
638
639 /* Tell the device to use SAC when IOMMU force is on.
640 This allows the driver to use cheaper accesses in some cases.
641
642 Problem with this is that if we overflow the IOMMU area
643 and return DAC as fallback address the device may not handle it correctly.
644
645 As a special case some controllers have a 39bit address mode
646 that is as efficient as 32bit (aic79xx). Don't force SAC for these.
647 Assume all masks <= 40 bits are of this type. Normally this doesn't
648 make any difference, but gives more gentle handling of IOMMU overflow. */
649 if (iommu_sac_force && (mask >= 0xffffffffffULL)) {
650 printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
651 return 0;
652 }
653
654 return 1;
655}
656
657int dma_get_cache_alignment(void)
658{
659 return boot_cpu_data.x86_clflush_size;
660}
661
662EXPORT_SYMBOL(dma_unmap_sg);
663EXPORT_SYMBOL(dma_map_sg);
664EXPORT_SYMBOL(dma_map_single);
665EXPORT_SYMBOL(dma_unmap_single);
666EXPORT_SYMBOL(dma_supported);
667EXPORT_SYMBOL(no_iommu);
668EXPORT_SYMBOL(force_iommu);
669EXPORT_SYMBOL(bad_dma_address);
670EXPORT_SYMBOL(iommu_bio_merge);
671EXPORT_SYMBOL(iommu_sac_force);
672EXPORT_SYMBOL(dma_get_cache_alignment);
673EXPORT_SYMBOL(dma_alloc_coherent);
674EXPORT_SYMBOL(dma_free_coherent);
675 494
676static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size) 495static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size)
677{ 496{
@@ -772,12 +591,27 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
772 nommu: 591 nommu:
773 /* Should not happen anymore */ 592 /* Should not happen anymore */
774 printk(KERN_ERR "PCI-DMA: More than 4GB of RAM and no IOMMU\n" 593 printk(KERN_ERR "PCI-DMA: More than 4GB of RAM and no IOMMU\n"
775 KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction."); 594 KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction.\n");
776 return -1; 595 return -1;
777} 596}
778 597
779extern int agp_amd64_init(void); 598extern int agp_amd64_init(void);
780 599
600static struct dma_mapping_ops gart_dma_ops = {
601 .mapping_error = NULL,
602 .map_single = gart_map_single,
603 .map_simple = gart_map_simple,
604 .unmap_single = gart_unmap_single,
605 .sync_single_for_cpu = NULL,
606 .sync_single_for_device = NULL,
607 .sync_single_range_for_cpu = NULL,
608 .sync_single_range_for_device = NULL,
609 .sync_sg_for_cpu = NULL,
610 .sync_sg_for_device = NULL,
611 .map_sg = gart_map_sg,
612 .unmap_sg = gart_unmap_sg,
613};
614
781static int __init pci_iommu_init(void) 615static int __init pci_iommu_init(void)
782{ 616{
783 struct agp_kern_info info; 617 struct agp_kern_info info;
@@ -799,16 +633,15 @@ static int __init pci_iommu_init(void)
799 633
800 if (swiotlb) { 634 if (swiotlb) {
801 no_iommu = 1; 635 no_iommu = 1;
802 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
803 return -1; 636 return -1;
804 } 637 }
805 638
806 if (no_iommu || 639 if (no_iommu ||
807 (!force_iommu && end_pfn < 0xffffffff>>PAGE_SHIFT) || 640 (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
808 !iommu_aperture || 641 !iommu_aperture ||
809 (no_agp && init_k8_gatt(&info) < 0)) { 642 (no_agp && init_k8_gatt(&info) < 0)) {
810 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
811 no_iommu = 1; 643 no_iommu = 1;
644 no_iommu_init();
812 return -1; 645 return -1;
813 } 646 }
814 647
@@ -885,100 +718,50 @@ static int __init pci_iommu_init(void)
885 718
886 flush_gart(NULL); 719 flush_gart(NULL);
887 720
721 printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
722 dma_ops = &gart_dma_ops;
723
888 return 0; 724 return 0;
889} 725}
890 726
891/* Must execute after PCI subsystem */ 727/* Must execute after PCI subsystem */
892fs_initcall(pci_iommu_init); 728fs_initcall(pci_iommu_init);
893 729
894/* iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge] 730void gart_parse_options(char *p)
895 [,forcesac][,fullflush][,nomerge][,biomerge] 731{
896 size set size of iommu (in bytes) 732 int arg;
897 noagp don't initialize the AGP driver and use full aperture. 733
898 off don't use the IOMMU
899 leak turn on simple iommu leak tracing (only when CONFIG_IOMMU_LEAK is on)
900 memaper[=order] allocate an own aperture over RAM with size 32MB^order.
901 noforce don't force IOMMU usage. Default.
902 force Force IOMMU.
903 merge Do lazy merging. This may improve performance on some block devices.
904 Implies force (experimental)
905 biomerge Do merging at the BIO layer. This is more efficient than merge,
906 but should be only done with very big IOMMUs. Implies merge,force.
907 nomerge Don't do SG merging.
908 forcesac For SAC mode for masks <40bits (experimental)
909 fullflush Flush IOMMU on each allocation (default)
910 nofullflush Don't use IOMMU fullflush
911 allowed overwrite iommu off workarounds for specific chipsets.
912 soft Use software bounce buffering (default for Intel machines)
913 noaperture Don't touch the aperture for AGP.
914*/
915__init int iommu_setup(char *p)
916{
917 int arg;
918
919 while (*p) {
920 if (!strncmp(p,"noagp",5))
921 no_agp = 1;
922 if (!strncmp(p,"off",3))
923 no_iommu = 1;
924 if (!strncmp(p,"force",5)) {
925 force_iommu = 1;
926 iommu_aperture_allowed = 1;
927 }
928 if (!strncmp(p,"allowed",7))
929 iommu_aperture_allowed = 1;
930 if (!strncmp(p,"noforce",7)) {
931 iommu_merge = 0;
932 force_iommu = 0;
933 }
934 if (!strncmp(p, "memaper", 7)) {
935 fallback_aper_force = 1;
936 p += 7;
937 if (*p == '=') {
938 ++p;
939 if (get_option(&p, &arg))
940 fallback_aper_order = arg;
941 }
942 }
943 if (!strncmp(p, "biomerge",8)) {
944 iommu_bio_merge = 4096;
945 iommu_merge = 1;
946 force_iommu = 1;
947 }
948 if (!strncmp(p, "panic",5))
949 panic_on_overflow = 1;
950 if (!strncmp(p, "nopanic",7))
951 panic_on_overflow = 0;
952 if (!strncmp(p, "merge",5)) {
953 iommu_merge = 1;
954 force_iommu = 1;
955 }
956 if (!strncmp(p, "nomerge",7))
957 iommu_merge = 0;
958 if (!strncmp(p, "forcesac",8))
959 iommu_sac_force = 1;
960 if (!strncmp(p, "fullflush",8))
961 iommu_fullflush = 1;
962 if (!strncmp(p, "nofullflush",11))
963 iommu_fullflush = 0;
964 if (!strncmp(p, "soft",4))
965 swiotlb = 1;
966 if (!strncmp(p, "noaperture",10))
967 fix_aperture = 0;
968#ifdef CONFIG_IOMMU_LEAK 734#ifdef CONFIG_IOMMU_LEAK
969 if (!strncmp(p,"leak",4)) { 735 if (!strncmp(p,"leak",4)) {
970 leak_trace = 1; 736 leak_trace = 1;
971 p += 4; 737 p += 4;
972 if (*p == '=') ++p; 738 if (*p == '=') ++p;
973 if (isdigit(*p) && get_option(&p, &arg)) 739 if (isdigit(*p) && get_option(&p, &arg))
974 iommu_leak_pages = arg; 740 iommu_leak_pages = arg;
975 } else 741 }
976#endif 742#endif
977 if (isdigit(*p) && get_option(&p, &arg)) 743 if (isdigit(*p) && get_option(&p, &arg))
978 iommu_size = arg; 744 iommu_size = arg;
979 p += strcspn(p, ","); 745 if (!strncmp(p, "fullflush",8))
980 if (*p == ',') 746 iommu_fullflush = 1;
981 ++p; 747 if (!strncmp(p, "nofullflush",11))
982 } 748 iommu_fullflush = 0;
983 return 1; 749 if (!strncmp(p,"noagp",5))
984} 750 no_agp = 1;
751 if (!strncmp(p, "noaperture",10))
752 fix_aperture = 0;
753 /* duplicated from pci-dma.c */
754 if (!strncmp(p,"force",5))
755 iommu_aperture_allowed = 1;
756 if (!strncmp(p,"allowed",7))
757 iommu_aperture_allowed = 1;
758 if (!strncmp(p, "memaper", 7)) {
759 fallback_aper_force = 1;
760 p += 7;
761 if (*p == '=') {
762 ++p;
763 if (get_option(&p, &arg))
764 fallback_aper_order = arg;
765 }
766 }
767}
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index 5a981dca87ff..e41564975195 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -6,89 +6,94 @@
6#include <linux/string.h> 6#include <linux/string.h>
7#include <asm/proto.h> 7#include <asm/proto.h>
8#include <asm/processor.h> 8#include <asm/processor.h>
9#include <asm/dma.h>
9 10
10int iommu_merge = 0; 11static int
11EXPORT_SYMBOL(iommu_merge); 12check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
12
13dma_addr_t bad_dma_address;
14EXPORT_SYMBOL(bad_dma_address);
15
16int iommu_bio_merge = 0;
17EXPORT_SYMBOL(iommu_bio_merge);
18
19int iommu_sac_force = 0;
20EXPORT_SYMBOL(iommu_sac_force);
21
22/*
23 * Dummy IO MMU functions
24 */
25
26void *dma_alloc_coherent(struct device *hwdev, size_t size,
27 dma_addr_t *dma_handle, gfp_t gfp)
28{ 13{
29 void *ret; 14 if (hwdev && bus + size > *hwdev->dma_mask) {
30 u64 mask; 15 printk(KERN_ERR
31 int order = get_order(size); 16 "nommu_%s: overflow %Lx+%lu of device mask %Lx\n",
32 17 name, (long long)bus, size, (long long)*hwdev->dma_mask);
33 if (hwdev) 18 return 0;
34 mask = hwdev->coherent_dma_mask & *hwdev->dma_mask;
35 else
36 mask = 0xffffffff;
37 for (;;) {
38 ret = (void *)__get_free_pages(gfp, order);
39 if (ret == NULL)
40 return NULL;
41 *dma_handle = virt_to_bus(ret);
42 if ((*dma_handle & ~mask) == 0)
43 break;
44 free_pages((unsigned long)ret, order);
45 if (gfp & GFP_DMA)
46 return NULL;
47 gfp |= GFP_DMA;
48 } 19 }
20 return 1;
21}
49 22
50 memset(ret, 0, size); 23static dma_addr_t
51 return ret; 24nommu_map_single(struct device *hwdev, void *ptr, size_t size,
25 int direction)
26{
27 dma_addr_t bus = virt_to_bus(ptr);
28 if (!check_addr("map_single", hwdev, bus, size))
29 return bad_dma_address;
30 return bus;
52} 31}
53EXPORT_SYMBOL(dma_alloc_coherent);
54 32
55void dma_free_coherent(struct device *hwdev, size_t size, 33void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
56 void *vaddr, dma_addr_t dma_handle) 34 int direction)
57{ 35{
58 free_pages((unsigned long)vaddr, get_order(size));
59} 36}
60EXPORT_SYMBOL(dma_free_coherent);
61 37
62int dma_supported(struct device *hwdev, u64 mask) 38/* Map a set of buffers described by scatterlist in streaming
39 * mode for DMA. This is the scatter-gather version of the
40 * above pci_map_single interface. Here the scatter gather list
41 * elements are each tagged with the appropriate dma address
42 * and length. They are obtained via sg_dma_{address,length}(SG).
43 *
44 * NOTE: An implementation may be able to use a smaller number of
45 * DMA address/length pairs than there are SG table elements.
46 * (for example via virtual mapping capabilities)
47 * The routine returns the number of addr/length pairs actually
48 * used, at most nents.
49 *
50 * Device ownership issues as mentioned above for pci_map_single are
51 * the same here.
52 */
53int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
54 int nents, int direction)
63{ 55{
64 /* 56 int i;
65 * we fall back to GFP_DMA when the mask isn't all 1s,
66 * so we can't guarantee allocations that must be
67 * within a tighter range than GFP_DMA..
68 * RED-PEN this won't work for pci_map_single. Caller has to
69 * use GFP_DMA in the first place.
70 */
71 if (mask < 0x00ffffff)
72 return 0;
73 57
74 return 1; 58 BUG_ON(direction == DMA_NONE);
75} 59 for (i = 0; i < nents; i++ ) {
76EXPORT_SYMBOL(dma_supported); 60 struct scatterlist *s = &sg[i];
61 BUG_ON(!s->page);
62 s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
63 if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
64 return 0;
65 s->dma_length = s->length;
66 }
67 return nents;
68}
77 69
78int dma_get_cache_alignment(void) 70/* Unmap a set of streaming mode DMA translations.
71 * Again, cpu read rules concerning calls here are the same as for
72 * pci_unmap_single() above.
73 */
74void nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
75 int nents, int dir)
79{ 76{
80 return boot_cpu_data.x86_clflush_size;
81} 77}
82EXPORT_SYMBOL(dma_get_cache_alignment);
83 78
84static int __init check_ram(void) 79struct dma_mapping_ops nommu_dma_ops = {
85{ 80 .map_single = nommu_map_single,
86 if (end_pfn >= 0xffffffff>>PAGE_SHIFT) { 81 .unmap_single = nommu_unmap_single,
87 printk( 82 .map_sg = nommu_map_sg,
88 KERN_ERR "WARNING more than 4GB of memory but IOMMU not compiled in.\n" 83 .unmap_sg = nommu_unmap_sg,
89 KERN_ERR "WARNING 32bit PCI may malfunction.\n"); 84 .is_phys = 1,
90 } 85};
91 return 0;
92}
93__initcall(check_ram);
94 86
87void __init no_iommu_init(void)
88{
89 if (dma_ops)
90 return;
91 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
92 dma_ops = &nommu_dma_ops;
93 if (end_pfn > MAX_DMA32_PFN) {
94 printk(KERN_ERR
95 "WARNING more than 4GB of memory but IOMMU not compiled in.\n"
96 KERN_ERR "WARNING 32bit PCI may malfunction.\n"
97 KERN_ERR "You might want to enable CONFIG_GART_IOMMU\n");
98 }
99}
diff --git a/arch/x86_64/kernel/pci-swiotlb.c b/arch/x86_64/kernel/pci-swiotlb.c
new file mode 100644
index 000000000000..3569a25ad7fb
--- /dev/null
+++ b/arch/x86_64/kernel/pci-swiotlb.c
@@ -0,0 +1,42 @@
1/* Glue code to lib/swiotlb.c */
2
3#include <linux/pci.h>
4#include <linux/cache.h>
5#include <linux/module.h>
6#include <asm/dma-mapping.h>
7#include <asm/proto.h>
8#include <asm/swiotlb.h>
9#include <asm/dma.h>
10
11int swiotlb __read_mostly;
12EXPORT_SYMBOL(swiotlb);
13
14struct dma_mapping_ops swiotlb_dma_ops = {
15 .mapping_error = swiotlb_dma_mapping_error,
16 .alloc_coherent = swiotlb_alloc_coherent,
17 .free_coherent = swiotlb_free_coherent,
18 .map_single = swiotlb_map_single,
19 .unmap_single = swiotlb_unmap_single,
20 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
21 .sync_single_for_device = swiotlb_sync_single_for_device,
22 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
23 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
24 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
25 .sync_sg_for_device = swiotlb_sync_sg_for_device,
26 .map_sg = swiotlb_map_sg,
27 .unmap_sg = swiotlb_unmap_sg,
28 .dma_supported = NULL,
29};
30
31void pci_swiotlb_init(void)
32{
33 /* don't initialize swiotlb if iommu=off (no_iommu=1) */
34 if (!iommu_aperture && !no_iommu &&
35 (end_pfn > MAX_DMA32_PFN || force_iommu))
36 swiotlb = 1;
37 if (swiotlb) {
38 swiotlb_init();
39 printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
40 dma_ops = &swiotlb_dma_ops;
41 }
42}
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 3060ed97b755..8ded407e4a94 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -36,6 +36,7 @@
36#include <linux/utsname.h> 36#include <linux/utsname.h>
37#include <linux/random.h> 37#include <linux/random.h>
38#include <linux/kprobes.h> 38#include <linux/kprobes.h>
39#include <linux/notifier.h>
39 40
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <asm/pgtable.h> 42#include <asm/pgtable.h>
@@ -50,13 +51,12 @@
50#include <asm/desc.h> 51#include <asm/desc.h>
51#include <asm/proto.h> 52#include <asm/proto.h>
52#include <asm/ia32.h> 53#include <asm/ia32.h>
54#include <asm/idle.h>
53 55
54asmlinkage extern void ret_from_fork(void); 56asmlinkage extern void ret_from_fork(void);
55 57
56unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; 58unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
57 59
58static atomic_t hlt_counter = ATOMIC_INIT(0);
59
60unsigned long boot_option_idle_override = 0; 60unsigned long boot_option_idle_override = 0;
61EXPORT_SYMBOL(boot_option_idle_override); 61EXPORT_SYMBOL(boot_option_idle_override);
62 62
@@ -66,19 +66,49 @@ EXPORT_SYMBOL(boot_option_idle_override);
66void (*pm_idle)(void); 66void (*pm_idle)(void);
67static DEFINE_PER_CPU(unsigned int, cpu_idle_state); 67static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
68 68
69void disable_hlt(void) 69static struct notifier_block *idle_notifier;
70static DEFINE_SPINLOCK(idle_notifier_lock);
71
72void idle_notifier_register(struct notifier_block *n)
73{
74 unsigned long flags;
75 spin_lock_irqsave(&idle_notifier_lock, flags);
76 notifier_chain_register(&idle_notifier, n);
77 spin_unlock_irqrestore(&idle_notifier_lock, flags);
78}
79EXPORT_SYMBOL_GPL(idle_notifier_register);
80
81void idle_notifier_unregister(struct notifier_block *n)
70{ 82{
71 atomic_inc(&hlt_counter); 83 unsigned long flags;
84 spin_lock_irqsave(&idle_notifier_lock, flags);
85 notifier_chain_unregister(&idle_notifier, n);
86 spin_unlock_irqrestore(&idle_notifier_lock, flags);
72} 87}
88EXPORT_SYMBOL(idle_notifier_unregister);
73 89
74EXPORT_SYMBOL(disable_hlt); 90enum idle_state { CPU_IDLE, CPU_NOT_IDLE };
91static DEFINE_PER_CPU(enum idle_state, idle_state) = CPU_NOT_IDLE;
75 92
76void enable_hlt(void) 93void enter_idle(void)
77{ 94{
78 atomic_dec(&hlt_counter); 95 __get_cpu_var(idle_state) = CPU_IDLE;
96 notifier_call_chain(&idle_notifier, IDLE_START, NULL);
79} 97}
80 98
81EXPORT_SYMBOL(enable_hlt); 99static void __exit_idle(void)
100{
101 __get_cpu_var(idle_state) = CPU_NOT_IDLE;
102 notifier_call_chain(&idle_notifier, IDLE_END, NULL);
103}
104
105/* Called from interrupts to signify idle end */
106void exit_idle(void)
107{
108 if (current->pid | read_pda(irqcount))
109 return;
110 __exit_idle();
111}
82 112
83/* 113/*
84 * We use this if we don't have any better 114 * We use this if we don't have any better
@@ -88,21 +118,16 @@ void default_idle(void)
88{ 118{
89 local_irq_enable(); 119 local_irq_enable();
90 120
91 if (!atomic_read(&hlt_counter)) { 121 clear_thread_flag(TIF_POLLING_NRFLAG);
92 clear_thread_flag(TIF_POLLING_NRFLAG); 122 smp_mb__after_clear_bit();
93 smp_mb__after_clear_bit(); 123 while (!need_resched()) {
94 while (!need_resched()) { 124 local_irq_disable();
95 local_irq_disable(); 125 if (!need_resched())
96 if (!need_resched()) 126 safe_halt();
97 safe_halt(); 127 else
98 else 128 local_irq_enable();
99 local_irq_enable();
100 }
101 set_thread_flag(TIF_POLLING_NRFLAG);
102 } else {
103 while (!need_resched())
104 cpu_relax();
105 } 129 }
130 set_thread_flag(TIF_POLLING_NRFLAG);
106} 131}
107 132
108/* 133/*
@@ -201,7 +226,9 @@ void cpu_idle (void)
201 idle = default_idle; 226 idle = default_idle;
202 if (cpu_is_offline(smp_processor_id())) 227 if (cpu_is_offline(smp_processor_id()))
203 play_dead(); 228 play_dead();
229 enter_idle();
204 idle(); 230 idle();
231 __exit_idle();
205 } 232 }
206 233
207 preempt_enable_no_resched(); 234 preempt_enable_no_resched();
@@ -424,7 +451,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp,
424 struct task_struct *me = current; 451 struct task_struct *me = current;
425 452
426 childregs = ((struct pt_regs *) 453 childregs = ((struct pt_regs *)
427 (THREAD_SIZE + (unsigned long) p->thread_info)) - 1; 454 (THREAD_SIZE + task_stack_page(p))) - 1;
428 *childregs = *regs; 455 *childregs = *regs;
429 456
430 childregs->rax = 0; 457 childregs->rax = 0;
@@ -436,7 +463,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp,
436 p->thread.rsp0 = (unsigned long) (childregs+1); 463 p->thread.rsp0 = (unsigned long) (childregs+1);
437 p->thread.userrsp = me->thread.userrsp; 464 p->thread.userrsp = me->thread.userrsp;
438 465
439 set_ti_thread_flag(p->thread_info, TIF_FORK); 466 set_tsk_thread_flag(p, TIF_FORK);
440 467
441 p->thread.fs = me->thread.fs; 468 p->thread.fs = me->thread.fs;
442 p->thread.gs = me->thread.gs; 469 p->thread.gs = me->thread.gs;
@@ -563,7 +590,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
563 write_pda(oldrsp, next->userrsp); 590 write_pda(oldrsp, next->userrsp);
564 write_pda(pcurrent, next_p); 591 write_pda(pcurrent, next_p);
565 write_pda(kernelstack, 592 write_pda(kernelstack,
566 (unsigned long)next_p->thread_info + THREAD_SIZE - PDA_STACKOFFSET); 593 task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
567 594
568 /* 595 /*
569 * Now maybe reload the debug registers 596 * Now maybe reload the debug registers
@@ -677,7 +704,7 @@ unsigned long get_wchan(struct task_struct *p)
677 704
678 if (!p || p == current || p->state==TASK_RUNNING) 705 if (!p || p == current || p->state==TASK_RUNNING)
679 return 0; 706 return 0;
680 stack = (unsigned long)p->thread_info; 707 stack = (unsigned long)task_stack_page(p);
681 if (p->thread.rsp < stack || p->thread.rsp > stack+THREAD_SIZE) 708 if (p->thread.rsp < stack || p->thread.rsp > stack+THREAD_SIZE)
682 return 0; 709 return 0;
683 fp = *(u64 *)(p->thread.rsp); 710 fp = *(u64 *)(p->thread.rsp);
@@ -795,8 +822,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
795{ 822{
796 struct pt_regs *pp, ptregs; 823 struct pt_regs *pp, ptregs;
797 824
798 pp = (struct pt_regs *)(tsk->thread.rsp0); 825 pp = task_pt_regs(tsk);
799 --pp;
800 826
801 ptregs = *pp; 827 ptregs = *pp;
802 ptregs.cs &= 0xffff; 828 ptregs.cs &= 0xffff;
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index a87b6cebe80f..53205622351c 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -36,9 +36,12 @@
36 * in exit.c or in signal.c. 36 * in exit.c or in signal.c.
37 */ 37 */
38 38
39/* determines which flags the user has access to. */ 39/*
40/* 1 = access 0 = no access */ 40 * Determines which flags the user has access to [1 = access, 0 = no access].
41#define FLAG_MASK 0x44dd5UL 41 * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
42 * Also masks reserved bits (63-22, 15, 5, 3, 1).
43 */
44#define FLAG_MASK 0x54dd5UL
42 45
43/* set's the trap flag. */ 46/* set's the trap flag. */
44#define TRAP_FLAG 0x100UL 47#define TRAP_FLAG 0x100UL
@@ -64,12 +67,6 @@ static inline unsigned long get_stack_long(struct task_struct *task, int offset)
64 return (*((unsigned long *)stack)); 67 return (*((unsigned long *)stack));
65} 68}
66 69
67static inline struct pt_regs *get_child_regs(struct task_struct *task)
68{
69 struct pt_regs *regs = (void *)task->thread.rsp0;
70 return regs - 1;
71}
72
73/* 70/*
74 * this routine will put a word on the processes privileged stack. 71 * this routine will put a word on the processes privileged stack.
75 * the offset is how far from the base addr as stored in the TSS. 72 * the offset is how far from the base addr as stored in the TSS.
@@ -167,7 +164,7 @@ static int is_at_popf(struct task_struct *child, struct pt_regs *regs)
167 164
168static void set_singlestep(struct task_struct *child) 165static void set_singlestep(struct task_struct *child)
169{ 166{
170 struct pt_regs *regs = get_child_regs(child); 167 struct pt_regs *regs = task_pt_regs(child);
171 168
172 /* 169 /*
173 * Always set TIF_SINGLESTEP - this guarantees that 170 * Always set TIF_SINGLESTEP - this guarantees that
@@ -205,7 +202,7 @@ static void clear_singlestep(struct task_struct *child)
205 202
206 /* But touch TF only if it was set by us.. */ 203 /* But touch TF only if it was set by us.. */
207 if (child->ptrace & PT_DTRACE) { 204 if (child->ptrace & PT_DTRACE) {
208 struct pt_regs *regs = get_child_regs(child); 205 struct pt_regs *regs = task_pt_regs(child);
209 regs->eflags &= ~TRAP_FLAG; 206 regs->eflags &= ~TRAP_FLAG;
210 child->ptrace &= ~PT_DTRACE; 207 child->ptrace &= ~PT_DTRACE;
211 } 208 }
diff --git a/arch/x86_64/kernel/reboot.c b/arch/x86_64/kernel/reboot.c
index 75235ed2b31b..57117b8beb2b 100644
--- a/arch/x86_64/kernel/reboot.c
+++ b/arch/x86_64/kernel/reboot.c
@@ -6,6 +6,7 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/ctype.h> 7#include <linux/ctype.h>
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/pm.h>
9#include <asm/io.h> 10#include <asm/io.h>
10#include <asm/kdebug.h> 11#include <asm/kdebug.h>
11#include <asm/delay.h> 12#include <asm/delay.h>
@@ -154,10 +155,11 @@ void machine_halt(void)
154 155
155void machine_power_off(void) 156void machine_power_off(void)
156{ 157{
157 if (!reboot_force) { 158 if (pm_power_off) {
158 machine_shutdown(); 159 if (!reboot_force) {
159 } 160 machine_shutdown();
160 if (pm_power_off) 161 }
161 pm_power_off(); 162 pm_power_off();
163 }
162} 164}
163 165
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 64c4534b930c..28895c03cb11 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -35,6 +35,7 @@
35#include <asm/processor.h> 35#include <asm/processor.h>
36#include <linux/console.h> 36#include <linux/console.h>
37#include <linux/seq_file.h> 37#include <linux/seq_file.h>
38#include <linux/crash_dump.h>
38#include <linux/root_dev.h> 39#include <linux/root_dev.h>
39#include <linux/pci.h> 40#include <linux/pci.h>
40#include <linux/acpi.h> 41#include <linux/acpi.h>
@@ -43,6 +44,8 @@
43#include <linux/mmzone.h> 44#include <linux/mmzone.h>
44#include <linux/kexec.h> 45#include <linux/kexec.h>
45#include <linux/cpufreq.h> 46#include <linux/cpufreq.h>
47#include <linux/dmi.h>
48#include <linux/dma-mapping.h>
46 49
47#include <asm/mtrr.h> 50#include <asm/mtrr.h>
48#include <asm/uaccess.h> 51#include <asm/uaccess.h>
@@ -61,7 +64,9 @@
61#include <asm/setup.h> 64#include <asm/setup.h>
62#include <asm/mach_apic.h> 65#include <asm/mach_apic.h>
63#include <asm/numa.h> 66#include <asm/numa.h>
67#include <asm/swiotlb.h>
64#include <asm/sections.h> 68#include <asm/sections.h>
69#include <asm/gart-mapping.h>
65 70
66/* 71/*
67 * Machine setup.. 72 * Machine setup..
@@ -86,11 +91,6 @@ int bootloader_type;
86 91
87unsigned long saved_video_mode; 92unsigned long saved_video_mode;
88 93
89#ifdef CONFIG_SWIOTLB
90int swiotlb;
91EXPORT_SYMBOL(swiotlb);
92#endif
93
94/* 94/*
95 * Setup options 95 * Setup options
96 */ 96 */
@@ -275,10 +275,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
275{ 275{
276 char c = ' ', *to = command_line, *from = COMMAND_LINE; 276 char c = ' ', *to = command_line, *from = COMMAND_LINE;
277 int len = 0; 277 int len = 0;
278 278 int userdef = 0;
279 /* Save unparsed command line copy for /proc/cmdline */
280 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
281 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
282 279
283 for (;;) { 280 for (;;) {
284 if (c != ' ') 281 if (c != ' ')
@@ -346,10 +343,14 @@ static __init void parse_cmdline_early (char ** cmdline_p)
346 !memcmp(from, "disableapic", 11)) 343 !memcmp(from, "disableapic", 11))
347 disable_apic = 1; 344 disable_apic = 1;
348 345
349 if (!memcmp(from, "noapic", 6)) 346 /* Don't confuse with noapictimer */
347 if (!memcmp(from, "noapic", 6) &&
348 (from[6] == ' ' || from[6] == 0))
350 skip_ioapic_setup = 1; 349 skip_ioapic_setup = 1;
351 350
352 if (!memcmp(from, "apic", 4)) { 351 /* Make sure to not confuse with apic= */
352 if (!memcmp(from, "apic", 4) &&
353 (from[4] == ' ' || from[4] == 0)) {
353 skip_ioapic_setup = 0; 354 skip_ioapic_setup = 0;
354 ioapic_force = 1; 355 ioapic_force = 1;
355 } 356 }
@@ -357,16 +358,36 @@ static __init void parse_cmdline_early (char ** cmdline_p)
357 if (!memcmp(from, "mem=", 4)) 358 if (!memcmp(from, "mem=", 4))
358 parse_memopt(from+4, &from); 359 parse_memopt(from+4, &from);
359 360
361 if (!memcmp(from, "memmap=", 7)) {
362 /* exactmap option is for used defined memory */
363 if (!memcmp(from+7, "exactmap", 8)) {
364#ifdef CONFIG_CRASH_DUMP
365 /* If we are doing a crash dump, we
366 * still need to know the real mem
367 * size before original memory map is
368 * reset.
369 */
370 saved_max_pfn = e820_end_of_ram();
371#endif
372 from += 8+7;
373 end_pfn_map = 0;
374 e820.nr_map = 0;
375 userdef = 1;
376 }
377 else {
378 parse_memmapopt(from+7, &from);
379 userdef = 1;
380 }
381 }
382
360#ifdef CONFIG_NUMA 383#ifdef CONFIG_NUMA
361 if (!memcmp(from, "numa=", 5)) 384 if (!memcmp(from, "numa=", 5))
362 numa_setup(from+5); 385 numa_setup(from+5);
363#endif 386#endif
364 387
365#ifdef CONFIG_GART_IOMMU
366 if (!memcmp(from,"iommu=",6)) { 388 if (!memcmp(from,"iommu=",6)) {
367 iommu_setup(from+6); 389 iommu_setup(from+6);
368 } 390 }
369#endif
370 391
371 if (!memcmp(from,"oops=panic", 10)) 392 if (!memcmp(from,"oops=panic", 10))
372 panic_on_oops = 1; 393 panic_on_oops = 1;
@@ -395,6 +416,14 @@ static __init void parse_cmdline_early (char ** cmdline_p)
395 } 416 }
396#endif 417#endif
397 418
419#ifdef CONFIG_PROC_VMCORE
420 /* elfcorehdr= specifies the location of elf core header
421 * stored by the crashed kernel. This option will be passed
422 * by kexec loader to the capture kernel.
423 */
424 else if(!memcmp(from, "elfcorehdr=", 11))
425 elfcorehdr_addr = memparse(from+11, &from);
426#endif
398 next_char: 427 next_char:
399 c = *(from++); 428 c = *(from++);
400 if (!c) 429 if (!c)
@@ -403,6 +432,10 @@ static __init void parse_cmdline_early (char ** cmdline_p)
403 break; 432 break;
404 *(to++) = c; 433 *(to++) = c;
405 } 434 }
435 if (userdef) {
436 printk(KERN_INFO "user-defined physical RAM map:\n");
437 e820_print_map("user");
438 }
406 *to = '\0'; 439 *to = '\0';
407 *cmdline_p = command_line; 440 *cmdline_p = command_line;
408} 441}
@@ -443,6 +476,8 @@ static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
443 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7, 476 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
444}; 477};
445 478
479extern char __vsyscall_0;
480
446/* Replace instructions with better alternatives for this CPU type. 481/* Replace instructions with better alternatives for this CPU type.
447 482
448 This runs before SMP is initialized to avoid SMP problems with 483 This runs before SMP is initialized to avoid SMP problems with
@@ -454,11 +489,17 @@ void apply_alternatives(void *start, void *end)
454 struct alt_instr *a; 489 struct alt_instr *a;
455 int diff, i, k; 490 int diff, i, k;
456 for (a = start; (void *)a < end; a++) { 491 for (a = start; (void *)a < end; a++) {
492 u8 *instr;
493
457 if (!boot_cpu_has(a->cpuid)) 494 if (!boot_cpu_has(a->cpuid))
458 continue; 495 continue;
459 496
460 BUG_ON(a->replacementlen > a->instrlen); 497 BUG_ON(a->replacementlen > a->instrlen);
461 __inline_memcpy(a->instr, a->replacement, a->replacementlen); 498 instr = a->instr;
499 /* vsyscall code is not mapped yet. resolve it manually. */
500 if (instr >= (u8 *)VSYSCALL_START && instr < (u8*)VSYSCALL_END)
501 instr = __va(instr - (u8*)VSYSCALL_START + (u8*)__pa_symbol(&__vsyscall_0));
502 __inline_memcpy(instr, a->replacement, a->replacementlen);
462 diff = a->instrlen - a->replacementlen; 503 diff = a->instrlen - a->replacementlen;
463 504
464 /* Pad the rest with nops */ 505 /* Pad the rest with nops */
@@ -466,7 +507,7 @@ void apply_alternatives(void *start, void *end)
466 k = diff; 507 k = diff;
467 if (k > ASM_NOP_MAX) 508 if (k > ASM_NOP_MAX)
468 k = ASM_NOP_MAX; 509 k = ASM_NOP_MAX;
469 __inline_memcpy(a->instr + i, k8_nops[k], k); 510 __inline_memcpy(instr + i, k8_nops[k], k);
470 } 511 }
471 } 512 }
472} 513}
@@ -670,6 +711,8 @@ void __init setup_arch(char **cmdline_p)
670 acpi_boot_init(); 711 acpi_boot_init();
671#endif 712#endif
672 713
714 init_cpu_to_node();
715
673#ifdef CONFIG_X86_LOCAL_APIC 716#ifdef CONFIG_X86_LOCAL_APIC
674 /* 717 /*
675 * get boot-time SMP configuration: 718 * get boot-time SMP configuration:
@@ -834,7 +877,6 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
834static int __init init_amd(struct cpuinfo_x86 *c) 877static int __init init_amd(struct cpuinfo_x86 *c)
835{ 878{
836 int r; 879 int r;
837 int level;
838 880
839#ifdef CONFIG_SMP 881#ifdef CONFIG_SMP
840 unsigned long value; 882 unsigned long value;
@@ -857,11 +899,6 @@ static int __init init_amd(struct cpuinfo_x86 *c)
857 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */ 899 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
858 clear_bit(0*32+31, &c->x86_capability); 900 clear_bit(0*32+31, &c->x86_capability);
859 901
860 /* C-stepping K8? */
861 level = cpuid_eax(1);
862 if ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
863 set_bit(X86_FEATURE_K8_C, &c->x86_capability);
864
865 r = get_model_name(c); 902 r = get_model_name(c);
866 if (!r) { 903 if (!r) {
867 switch (c->x86) { 904 switch (c->x86) {
@@ -874,6 +911,10 @@ static int __init init_amd(struct cpuinfo_x86 *c)
874 } 911 }
875 display_cacheinfo(c); 912 display_cacheinfo(c);
876 913
914 /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
915 if (c->x86_power & (1<<8))
916 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
917
877 if (c->extended_cpuid_level >= 0x80000008) { 918 if (c->extended_cpuid_level >= 0x80000008) {
878 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1; 919 c->x86_max_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
879 if (c->x86_max_cores & (c->x86_max_cores - 1)) 920 if (c->x86_max_cores & (c->x86_max_cores - 1))
@@ -992,8 +1033,10 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
992 1033
993 if (c->x86 == 15) 1034 if (c->x86 == 15)
994 c->x86_cache_alignment = c->x86_clflush_size * 2; 1035 c->x86_cache_alignment = c->x86_clflush_size * 2;
995 if (c->x86 >= 15) 1036 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
1037 (c->x86 == 0x6 && c->x86_model >= 0x0e))
996 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 1038 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
1039 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
997 c->x86_max_cores = intel_num_cpu_cores(c); 1040 c->x86_max_cores = intel_num_cpu_cores(c);
998 1041
999 srat_detect_node(); 1042 srat_detect_node();
@@ -1192,7 +1235,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1192 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1235 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1193 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL, 1236 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
1194 NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL, 1237 NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
1195 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow", 1238 NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
1196 1239
1197 /* Transmeta-defined */ 1240 /* Transmeta-defined */
1198 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL, 1241 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
@@ -1220,7 +1263,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1220 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1263 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1221 1264
1222 /* AMD-defined (#2) */ 1265 /* AMD-defined (#2) */
1223 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL, 1266 "lahf_lm", "cmp_legacy", "svm", NULL, "cr8_legacy", NULL, NULL, NULL,
1224 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1267 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1225 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1268 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1226 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1269 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -1231,7 +1274,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1231 "vid", /* voltage id control */ 1274 "vid", /* voltage id control */
1232 "ttp", /* thermal trip */ 1275 "ttp", /* thermal trip */
1233 "tm", 1276 "tm",
1234 "stc" 1277 "stc",
1278 NULL,
1279 /* nothing */ /* constant_tsc - moved to flags */
1235 }; 1280 };
1236 1281
1237 1282
@@ -1311,8 +1356,11 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1311 unsigned i; 1356 unsigned i;
1312 for (i = 0; i < 32; i++) 1357 for (i = 0; i < 32; i++)
1313 if (c->x86_power & (1 << i)) { 1358 if (c->x86_power & (1 << i)) {
1314 if (i < ARRAY_SIZE(x86_power_flags)) 1359 if (i < ARRAY_SIZE(x86_power_flags) &&
1315 seq_printf(m, " %s", x86_power_flags[i]); 1360 x86_power_flags[i])
1361 seq_printf(m, "%s%s",
1362 x86_power_flags[i][0]?" ":"",
1363 x86_power_flags[i]);
1316 else 1364 else
1317 seq_printf(m, " [%d]", i); 1365 seq_printf(m, " [%d]", i);
1318 } 1366 }
@@ -1344,3 +1392,11 @@ struct seq_operations cpuinfo_op = {
1344 .stop = c_stop, 1392 .stop = c_stop,
1345 .show = show_cpuinfo, 1393 .show = show_cpuinfo,
1346}; 1394};
1395
1396static int __init run_dmi_scan(void)
1397{
1398 dmi_scan_machine();
1399 return 0;
1400}
1401core_initcall(run_dmi_scan);
1402
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index 06dc354375c3..6eff51e9400c 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -30,7 +30,8 @@ char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
30 30
31cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE; 31cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
32 32
33struct x8664_pda cpu_pda[NR_CPUS] __cacheline_aligned; 33struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
34struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
34 35
35struct desc_ptr idt_descr = { 256 * 16, (unsigned long) idt_table }; 36struct desc_ptr idt_descr = { 256 * 16, (unsigned long) idt_table };
36 37
@@ -110,18 +111,18 @@ void __init setup_per_cpu_areas(void)
110 } 111 }
111 if (!ptr) 112 if (!ptr)
112 panic("Cannot allocate cpu data for CPU %d\n", i); 113 panic("Cannot allocate cpu data for CPU %d\n", i);
113 cpu_pda[i].data_offset = ptr - __per_cpu_start; 114 cpu_pda(i)->data_offset = ptr - __per_cpu_start;
114 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 115 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
115 } 116 }
116} 117}
117 118
118void pda_init(int cpu) 119void pda_init(int cpu)
119{ 120{
120 struct x8664_pda *pda = &cpu_pda[cpu]; 121 struct x8664_pda *pda = cpu_pda(cpu);
121 122
122 /* Setup up data that may be needed in __get_free_pages early */ 123 /* Setup up data that may be needed in __get_free_pages early */
123 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); 124 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
124 wrmsrl(MSR_GS_BASE, cpu_pda + cpu); 125 wrmsrl(MSR_GS_BASE, pda);
125 126
126 pda->cpunumber = cpu; 127 pda->cpunumber = cpu;
127 pda->irqcount = -1; 128 pda->irqcount = -1;
@@ -145,7 +146,7 @@ void pda_init(int cpu)
145 pda->irqstackptr += IRQSTACKSIZE-64; 146 pda->irqstackptr += IRQSTACKSIZE-64;
146} 147}
147 148
148char boot_exception_stacks[N_EXCEPTION_STACKS * EXCEPTION_STKSZ] 149char boot_exception_stacks[(N_EXCEPTION_STACKS - 2) * EXCEPTION_STKSZ + DEBUG_STKSZ]
149__attribute__((section(".bss.page_aligned"))); 150__attribute__((section(".bss.page_aligned")));
150 151
151/* May not be marked __init: used by software suspend */ 152/* May not be marked __init: used by software suspend */
@@ -213,23 +214,14 @@ void __cpuinit cpu_init (void)
213 * Initialize the per-CPU GDT with the boot GDT, 214 * Initialize the per-CPU GDT with the boot GDT,
214 * and set up the GDT descriptor: 215 * and set up the GDT descriptor:
215 */ 216 */
216 if (cpu) { 217 if (cpu)
217 memcpy(cpu_gdt_table[cpu], cpu_gdt_table[0], GDT_SIZE); 218 memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE);
218 }
219 219
220 cpu_gdt_descr[cpu].size = GDT_SIZE; 220 cpu_gdt_descr[cpu].size = GDT_SIZE;
221 cpu_gdt_descr[cpu].address = (unsigned long)cpu_gdt_table[cpu];
222 asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu])); 221 asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu]));
223 asm volatile("lidt %0" :: "m" (idt_descr)); 222 asm volatile("lidt %0" :: "m" (idt_descr));
224 223
225 memcpy(me->thread.tls_array, cpu_gdt_table[cpu], GDT_ENTRY_TLS_ENTRIES * 8); 224 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
226
227 /*
228 * Delete NT
229 */
230
231 asm volatile("pushfq ; popq %%rax ; btr $14,%%rax ; pushq %%rax ; popfq" ::: "eax");
232
233 syscall_init(); 225 syscall_init();
234 226
235 wrmsrl(MSR_FS_BASE, 0); 227 wrmsrl(MSR_FS_BASE, 0);
@@ -243,13 +235,27 @@ void __cpuinit cpu_init (void)
243 */ 235 */
244 for (v = 0; v < N_EXCEPTION_STACKS; v++) { 236 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
245 if (cpu) { 237 if (cpu) {
246 estacks = (char *)__get_free_pages(GFP_ATOMIC, 238 static const unsigned int order[N_EXCEPTION_STACKS] = {
247 EXCEPTION_STACK_ORDER); 239 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
240 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
241 };
242
243 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
248 if (!estacks) 244 if (!estacks)
249 panic("Cannot allocate exception stack %ld %d\n", 245 panic("Cannot allocate exception stack %ld %d\n",
250 v, cpu); 246 v, cpu);
251 } 247 }
252 estacks += EXCEPTION_STKSZ; 248 switch (v + 1) {
249#if DEBUG_STKSZ > EXCEPTION_STKSZ
250 case DEBUG_STACK:
251 cpu_pda[cpu].debugstack = (unsigned long)estacks;
252 estacks += DEBUG_STKSZ;
253 break;
254#endif
255 default:
256 estacks += EXCEPTION_STKSZ;
257 break;
258 }
253 t->ist[v] = (unsigned long)estacks; 259 t->ist[v] = (unsigned long)estacks;
254 } 260 }
255 261
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index cfc3d9dccbd9..19ef012b1f17 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -27,6 +27,7 @@
27#include <asm/mmu_context.h> 27#include <asm/mmu_context.h>
28#include <asm/proto.h> 28#include <asm/proto.h>
29#include <asm/apicdef.h> 29#include <asm/apicdef.h>
30#include <asm/idle.h>
30 31
31/* 32/*
32 * Smarter SMP flushing macros. 33 * Smarter SMP flushing macros.
@@ -280,11 +281,6 @@ void flush_tlb_all(void)
280 on_each_cpu(do_flush_tlb_all, NULL, 1, 1); 281 on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
281} 282}
282 283
283void smp_kdb_stop(void)
284{
285 send_IPI_allbutself(KDB_VECTOR);
286}
287
288/* 284/*
289 * this function sends a 'reschedule' IPI to another CPU. 285 * this function sends a 'reschedule' IPI to another CPU.
290 * it goes straight through and wastes no time serializing 286 * it goes straight through and wastes no time serializing
@@ -512,6 +508,7 @@ asmlinkage void smp_call_function_interrupt(void)
512 /* 508 /*
513 * At this point the info structure may be out of scope unless wait==1 509 * At this point the info structure may be out of scope unless wait==1
514 */ 510 */
511 exit_idle();
515 irq_enter(); 512 irq_enter();
516 (*func)(info); 513 (*func)(info);
517 irq_exit(); 514 irq_exit();
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index ecbd7b83acc1..a28756ef7cef 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -335,7 +335,13 @@ static __cpuinit void sync_tsc(unsigned int master)
335 335
336static void __cpuinit tsc_sync_wait(void) 336static void __cpuinit tsc_sync_wait(void)
337{ 337{
338 if (notscsync || !cpu_has_tsc) 338 /*
339 * When the CPU has synchronized TSCs assume the BIOS
340 * or the hardware already synced. Otherwise we could
341 * mess up a possible perfect synchronization with a
342 * not-quite-perfect algorithm.
343 */
344 if (notscsync || !cpu_has_tsc || !unsynchronized_tsc())
339 return; 345 return;
340 sync_tsc(0); 346 sync_tsc(0);
341} 347}
@@ -646,6 +652,7 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
646 send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY; 652 send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
647 } while (send_status && (timeout++ < 1000)); 653 } while (send_status && (timeout++ < 1000));
648 654
655 mb();
649 atomic_set(&init_deasserted, 1); 656 atomic_set(&init_deasserted, 1);
650 657
651 num_starts = 2; 658 num_starts = 2;
@@ -659,7 +666,6 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
659 666
660 for (j = 1; j <= num_starts; j++) { 667 for (j = 1; j <= num_starts; j++) {
661 Dprintk("Sending STARTUP #%d.\n",j); 668 Dprintk("Sending STARTUP #%d.\n",j);
662 apic_read_around(APIC_SPIV);
663 apic_write(APIC_ESR, 0); 669 apic_write(APIC_ESR, 0);
664 apic_read(APIC_ESR); 670 apic_read(APIC_ESR);
665 Dprintk("After apic_write.\n"); 671 Dprintk("After apic_write.\n");
@@ -698,7 +704,6 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
698 * Due to the Pentium erratum 3AP. 704 * Due to the Pentium erratum 3AP.
699 */ 705 */
700 if (maxlvt > 3) { 706 if (maxlvt > 3) {
701 apic_read_around(APIC_SPIV);
702 apic_write(APIC_ESR, 0); 707 apic_write(APIC_ESR, 0);
703 } 708 }
704 accept_status = (apic_read(APIC_ESR) & 0xEF); 709 accept_status = (apic_read(APIC_ESR) & 0xEF);
@@ -743,11 +748,35 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
743 }; 748 };
744 DECLARE_WORK(work, do_fork_idle, &c_idle); 749 DECLARE_WORK(work, do_fork_idle, &c_idle);
745 750
751 /* allocate memory for gdts of secondary cpus. Hotplug is considered */
752 if (!cpu_gdt_descr[cpu].address &&
753 !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) {
754 printk(KERN_ERR "Failed to allocate GDT for CPU %d\n", cpu);
755 return -1;
756 }
757
758 /* Allocate node local memory for AP pdas */
759 if (cpu_pda(cpu) == &boot_cpu_pda[cpu]) {
760 struct x8664_pda *newpda, *pda;
761 int node = cpu_to_node(cpu);
762 pda = cpu_pda(cpu);
763 newpda = kmalloc_node(sizeof (struct x8664_pda), GFP_ATOMIC,
764 node);
765 if (newpda) {
766 memcpy(newpda, pda, sizeof (struct x8664_pda));
767 cpu_pda(cpu) = newpda;
768 } else
769 printk(KERN_ERR
770 "Could not allocate node local PDA for CPU %d on node %d\n",
771 cpu, node);
772 }
773
774
746 c_idle.idle = get_idle_for_cpu(cpu); 775 c_idle.idle = get_idle_for_cpu(cpu);
747 776
748 if (c_idle.idle) { 777 if (c_idle.idle) {
749 c_idle.idle->thread.rsp = (unsigned long) (((struct pt_regs *) 778 c_idle.idle->thread.rsp = (unsigned long) (((struct pt_regs *)
750 (THREAD_SIZE + (unsigned long) c_idle.idle->thread_info)) - 1); 779 (THREAD_SIZE + task_stack_page(c_idle.idle))) - 1);
751 init_idle(c_idle.idle, cpu); 780 init_idle(c_idle.idle, cpu);
752 goto do_rest; 781 goto do_rest;
753 } 782 }
@@ -778,14 +807,14 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
778 807
779do_rest: 808do_rest:
780 809
781 cpu_pda[cpu].pcurrent = c_idle.idle; 810 cpu_pda(cpu)->pcurrent = c_idle.idle;
782 811
783 start_rip = setup_trampoline(); 812 start_rip = setup_trampoline();
784 813
785 init_rsp = c_idle.idle->thread.rsp; 814 init_rsp = c_idle.idle->thread.rsp;
786 per_cpu(init_tss,cpu).rsp0 = init_rsp; 815 per_cpu(init_tss,cpu).rsp0 = init_rsp;
787 initial_code = start_secondary; 816 initial_code = start_secondary;
788 clear_ti_thread_flag(c_idle.idle->thread_info, TIF_FORK); 817 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
789 818
790 printk(KERN_INFO "Booting processor %d/%d APIC 0x%x\n", cpu, 819 printk(KERN_INFO "Booting processor %d/%d APIC 0x%x\n", cpu,
791 cpus_weight(cpu_present_map), 820 cpus_weight(cpu_present_map),
@@ -811,11 +840,8 @@ do_rest:
811 /* 840 /*
812 * Be paranoid about clearing APIC errors. 841 * Be paranoid about clearing APIC errors.
813 */ 842 */
814 if (APIC_INTEGRATED(apic_version[apicid])) { 843 apic_write(APIC_ESR, 0);
815 apic_read_around(APIC_SPIV); 844 apic_read(APIC_ESR);
816 apic_write(APIC_ESR, 0);
817 apic_read(APIC_ESR);
818 }
819 845
820 /* 846 /*
821 * Status is now clean 847 * Status is now clean
@@ -927,8 +953,8 @@ int additional_cpus __initdata = -1;
927 * 953 *
928 * Three ways to find out the number of additional hotplug CPUs: 954 * Three ways to find out the number of additional hotplug CPUs:
929 * - If the BIOS specified disabled CPUs in ACPI/mptables use that. 955 * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
930 * - otherwise use half of the available CPUs or 2, whatever is more.
931 * - The user can overwrite it with additional_cpus=NUM 956 * - The user can overwrite it with additional_cpus=NUM
957 * - Otherwise don't reserve additional CPUs.
932 * We do this because additional CPUs waste a lot of memory. 958 * We do this because additional CPUs waste a lot of memory.
933 * -AK 959 * -AK
934 */ 960 */
@@ -938,13 +964,10 @@ __init void prefill_possible_map(void)
938 int possible; 964 int possible;
939 965
940 if (additional_cpus == -1) { 966 if (additional_cpus == -1) {
941 if (disabled_cpus > 0) { 967 if (disabled_cpus > 0)
942 additional_cpus = disabled_cpus; 968 additional_cpus = disabled_cpus;
943 } else { 969 else
944 additional_cpus = num_processors / 2; 970 additional_cpus = 0;
945 if (additional_cpus == 0)
946 additional_cpus = 2;
947 }
948 } 971 }
949 possible = num_processors + additional_cpus; 972 possible = num_processors + additional_cpus;
950 if (possible > NR_CPUS) 973 if (possible > NR_CPUS)
@@ -996,7 +1019,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
996 /* 1019 /*
997 * If we couldn't find a local APIC, then get out of here now! 1020 * If we couldn't find a local APIC, then get out of here now!
998 */ 1021 */
999 if (APIC_INTEGRATED(apic_version[boot_cpu_id]) && !cpu_has_apic) { 1022 if (!cpu_has_apic) {
1000 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", 1023 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
1001 boot_cpu_id); 1024 boot_cpu_id);
1002 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n"); 1025 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index fd2bef780882..ecbd34c1093d 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -120,7 +120,7 @@ void fix_processor_context(void)
120 120
121 set_tss_desc(cpu,t); /* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy TSS or some similar stupidity. */ 121 set_tss_desc(cpu,t); /* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy TSS or some similar stupidity. */
122 122
123 cpu_gdt_table[cpu][GDT_ENTRY_TSS].type = 9; 123 cpu_gdt(cpu)[GDT_ENTRY_TSS].type = 9;
124 124
125 syscall_init(); /* This sets MSR_*STAR and related */ 125 syscall_init(); /* This sets MSR_*STAR and related */
126 load_TR_desc(); /* This does ltr */ 126 load_TR_desc(); /* This does ltr */
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 43c9fa0f8d5f..f8c47c688443 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -71,14 +71,6 @@ unsigned long __wall_jiffies __section_wall_jiffies = INITIAL_JIFFIES;
71struct timespec __xtime __section_xtime; 71struct timespec __xtime __section_xtime;
72struct timezone __sys_tz __section_sys_tz; 72struct timezone __sys_tz __section_sys_tz;
73 73
74static inline void rdtscll_sync(unsigned long *tsc)
75{
76#ifdef CONFIG_SMP
77 sync_core();
78#endif
79 rdtscll(*tsc);
80}
81
82/* 74/*
83 * do_gettimeoffset() returns microseconds since last timer interrupt was 75 * do_gettimeoffset() returns microseconds since last timer interrupt was
84 * triggered by hardware. A memory read of HPET is slower than a register read 76 * triggered by hardware. A memory read of HPET is slower than a register read
@@ -93,7 +85,7 @@ static inline unsigned int do_gettimeoffset_tsc(void)
93{ 85{
94 unsigned long t; 86 unsigned long t;
95 unsigned long x; 87 unsigned long x;
96 rdtscll_sync(&t); 88 t = get_cycles_sync();
97 if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */ 89 if (t < vxtime.last_tsc) t = vxtime.last_tsc; /* hack */
98 x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32; 90 x = ((t - vxtime.last_tsc) * vxtime.tsc_quot) >> 32;
99 return x; 91 return x;
@@ -259,8 +251,8 @@ static void set_rtc_mmss(unsigned long nowtime)
259#endif 251#endif
260 252
261 { 253 {
262 BIN_TO_BCD(real_seconds); 254 BIN_TO_BCD(real_seconds);
263 BIN_TO_BCD(real_minutes); 255 BIN_TO_BCD(real_minutes);
264 CMOS_WRITE(real_seconds, RTC_SECONDS); 256 CMOS_WRITE(real_seconds, RTC_SECONDS);
265 CMOS_WRITE(real_minutes, RTC_MINUTES); 257 CMOS_WRITE(real_minutes, RTC_MINUTES);
266 } 258 }
@@ -297,25 +289,21 @@ unsigned long long monotonic_clock(void)
297 last_offset = vxtime.last; 289 last_offset = vxtime.last;
298 base = monotonic_base; 290 base = monotonic_base;
299 this_offset = hpet_readl(HPET_COUNTER); 291 this_offset = hpet_readl(HPET_COUNTER);
300
301 } while (read_seqretry(&xtime_lock, seq)); 292 } while (read_seqretry(&xtime_lock, seq));
302 offset = (this_offset - last_offset); 293 offset = (this_offset - last_offset);
303 offset *=(NSEC_PER_SEC/HZ)/hpet_tick; 294 offset *=(NSEC_PER_SEC/HZ)/hpet_tick;
304 return base + offset; 295 return base + offset;
305 }else{ 296 } else {
306 do { 297 do {
307 seq = read_seqbegin(&xtime_lock); 298 seq = read_seqbegin(&xtime_lock);
308 299
309 last_offset = vxtime.last_tsc; 300 last_offset = vxtime.last_tsc;
310 base = monotonic_base; 301 base = monotonic_base;
311 } while (read_seqretry(&xtime_lock, seq)); 302 } while (read_seqretry(&xtime_lock, seq));
312 sync_core(); 303 this_offset = get_cycles_sync();
313 rdtscll(this_offset);
314 offset = (this_offset - last_offset)*1000/cpu_khz; 304 offset = (this_offset - last_offset)*1000/cpu_khz;
315 return base + offset; 305 return base + offset;
316 } 306 }
317
318
319} 307}
320EXPORT_SYMBOL(monotonic_clock); 308EXPORT_SYMBOL(monotonic_clock);
321 309
@@ -391,7 +379,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
391 delay = LATCH - 1 - delay; 379 delay = LATCH - 1 - delay;
392 } 380 }
393 381
394 rdtscll_sync(&tsc); 382 tsc = get_cycles_sync();
395 383
396 if (vxtime.mode == VXTIME_HPET) { 384 if (vxtime.mode == VXTIME_HPET) {
397 if (offset - vxtime.last > hpet_tick) { 385 if (offset - vxtime.last > hpet_tick) {
@@ -471,6 +459,11 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
471 459
472 write_sequnlock(&xtime_lock); 460 write_sequnlock(&xtime_lock);
473 461
462#ifdef CONFIG_X86_LOCAL_APIC
463 if (using_apic_timer)
464 smp_send_timer_broadcast_ipi();
465#endif
466
474 return IRQ_HANDLED; 467 return IRQ_HANDLED;
475} 468}
476 469
@@ -509,10 +502,10 @@ unsigned long long sched_clock(void)
509 return cycles_2_ns(a); 502 return cycles_2_ns(a);
510} 503}
511 504
512unsigned long get_cmos_time(void) 505static unsigned long get_cmos_time(void)
513{ 506{
514 unsigned int timeout, year, mon, day, hour, min, sec; 507 unsigned int timeout = 1000000, year, mon, day, hour, min, sec;
515 unsigned char last, this; 508 unsigned char uip = 0, this = 0;
516 unsigned long flags; 509 unsigned long flags;
517 510
518/* 511/*
@@ -525,45 +518,41 @@ unsigned long get_cmos_time(void)
525 518
526 spin_lock_irqsave(&rtc_lock, flags); 519 spin_lock_irqsave(&rtc_lock, flags);
527 520
528 timeout = 1000000; 521 while (timeout && (!uip || this)) {
529 last = this = 0; 522 uip |= this;
530
531 while (timeout && last && !this) {
532 last = this;
533 this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP; 523 this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP;
534 timeout--; 524 timeout--;
535 } 525 }
536 526
537/* 527 /*
538 * Here we are safe to assume the registers won't change for a whole second, so 528 * Here we are safe to assume the registers won't change for a whole
539 * we just go ahead and read them. 529 * second, so we just go ahead and read them.
540 */ 530 */
541 531 sec = CMOS_READ(RTC_SECONDS);
542 sec = CMOS_READ(RTC_SECONDS); 532 min = CMOS_READ(RTC_MINUTES);
543 min = CMOS_READ(RTC_MINUTES); 533 hour = CMOS_READ(RTC_HOURS);
544 hour = CMOS_READ(RTC_HOURS); 534 day = CMOS_READ(RTC_DAY_OF_MONTH);
545 day = CMOS_READ(RTC_DAY_OF_MONTH); 535 mon = CMOS_READ(RTC_MONTH);
546 mon = CMOS_READ(RTC_MONTH); 536 year = CMOS_READ(RTC_YEAR);
547 year = CMOS_READ(RTC_YEAR);
548 537
549 spin_unlock_irqrestore(&rtc_lock, flags); 538 spin_unlock_irqrestore(&rtc_lock, flags);
550 539
551/* 540 /*
552 * We know that x86-64 always uses BCD format, no need to check the config 541 * We know that x86-64 always uses BCD format, no need to check the
553 * register. 542 * config register.
554 */ 543 */
555 544
556 BCD_TO_BIN(sec); 545 BCD_TO_BIN(sec);
557 BCD_TO_BIN(min); 546 BCD_TO_BIN(min);
558 BCD_TO_BIN(hour); 547 BCD_TO_BIN(hour);
559 BCD_TO_BIN(day); 548 BCD_TO_BIN(day);
560 BCD_TO_BIN(mon); 549 BCD_TO_BIN(mon);
561 BCD_TO_BIN(year); 550 BCD_TO_BIN(year);
562 551
563/* 552 /*
564 * x86-64 systems only exists since 2002. 553 * x86-64 systems only exists since 2002.
565 * This will work up to Dec 31, 2100 554 * This will work up to Dec 31, 2100
566 */ 555 */
567 year += 2000; 556 year += 2000;
568 557
569 return mktime(year, mon, day, hour, min, sec); 558 return mktime(year, mon, day, hour, min, sec);
@@ -695,8 +684,7 @@ static unsigned int __init hpet_calibrate_tsc(void)
695 do { 684 do {
696 local_irq_disable(); 685 local_irq_disable();
697 hpet_now = hpet_readl(HPET_COUNTER); 686 hpet_now = hpet_readl(HPET_COUNTER);
698 sync_core(); 687 tsc_now = get_cycles_sync();
699 rdtscl(tsc_now);
700 local_irq_restore(flags); 688 local_irq_restore(flags);
701 } while ((tsc_now - tsc_start) < TICK_COUNT && 689 } while ((tsc_now - tsc_start) < TICK_COUNT &&
702 (hpet_now - hpet_start) < TICK_COUNT); 690 (hpet_now - hpet_start) < TICK_COUNT);
@@ -726,11 +714,9 @@ static unsigned int __init pit_calibrate_tsc(void)
726 outb(0xb0, 0x43); 714 outb(0xb0, 0x43);
727 outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42); 715 outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
728 outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42); 716 outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42);
729 rdtscll(start); 717 start = get_cycles_sync();
730 sync_core();
731 while ((inb(0x61) & 0x20) == 0); 718 while ((inb(0x61) & 0x20) == 0);
732 sync_core(); 719 end = get_cycles_sync();
733 rdtscll(end);
734 720
735 spin_unlock_irqrestore(&i8253_lock, flags); 721 spin_unlock_irqrestore(&i8253_lock, flags);
736 722
@@ -744,7 +730,7 @@ static __init int late_hpet_init(void)
744 unsigned int ntimer; 730 unsigned int ntimer;
745 731
746 if (!vxtime.hpet_address) 732 if (!vxtime.hpet_address)
747 return -1; 733 return -1;
748 734
749 memset(&hd, 0, sizeof (hd)); 735 memset(&hd, 0, sizeof (hd));
750 736
@@ -878,8 +864,6 @@ static struct irqaction irq0 = {
878 timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL 864 timer_interrupt, SA_INTERRUPT, CPU_MASK_NONE, "timer", NULL, NULL
879}; 865};
880 866
881extern void __init config_acpi_tables(void);
882
883void __init time_init(void) 867void __init time_init(void)
884{ 868{
885 char *timename; 869 char *timename;
@@ -934,7 +918,7 @@ void __init time_init(void)
934 vxtime.mode = VXTIME_TSC; 918 vxtime.mode = VXTIME_TSC;
935 vxtime.quot = (1000000L << 32) / vxtime_hz; 919 vxtime.quot = (1000000L << 32) / vxtime_hz;
936 vxtime.tsc_quot = (1000L << 32) / cpu_khz; 920 vxtime.tsc_quot = (1000L << 32) / cpu_khz;
937 rdtscll_sync(&vxtime.last_tsc); 921 vxtime.last_tsc = get_cycles_sync();
938 setup_irq(0, &irq0); 922 setup_irq(0, &irq0);
939 923
940 set_cyc2ns_scale(cpu_khz); 924 set_cyc2ns_scale(cpu_khz);
@@ -948,7 +932,7 @@ void __init time_init(void)
948 * Make an educated guess if the TSC is trustworthy and synchronized 932 * Make an educated guess if the TSC is trustworthy and synchronized
949 * over all CPUs. 933 * over all CPUs.
950 */ 934 */
951static __init int unsynchronized_tsc(void) 935__init int unsynchronized_tsc(void)
952{ 936{
953#ifdef CONFIG_SMP 937#ifdef CONFIG_SMP
954 if (oem_force_hpet_timer()) 938 if (oem_force_hpet_timer())
@@ -959,7 +943,7 @@ static __init int unsynchronized_tsc(void)
959 return 0; 943 return 0;
960#endif 944#endif
961 /* Assume multi socket systems are not synchronized */ 945 /* Assume multi socket systems are not synchronized */
962 return num_online_cpus() > 1; 946 return num_present_cpus() > 1;
963} 947}
964 948
965/* 949/*
@@ -999,6 +983,10 @@ __setup("report_lost_ticks", time_setup);
999static long clock_cmos_diff; 983static long clock_cmos_diff;
1000static unsigned long sleep_start; 984static unsigned long sleep_start;
1001 985
986/*
987 * sysfs support for the timer.
988 */
989
1002static int timer_suspend(struct sys_device *dev, pm_message_t state) 990static int timer_suspend(struct sys_device *dev, pm_message_t state)
1003{ 991{
1004 /* 992 /*
@@ -1041,7 +1029,6 @@ static struct sysdev_class timer_sysclass = {
1041 set_kset_name("timer"), 1029 set_kset_name("timer"),
1042}; 1030};
1043 1031
1044
1045/* XXX this driverfs stuff should probably go elsewhere later -john */ 1032/* XXX this driverfs stuff should probably go elsewhere later -john */
1046static struct sys_device device_timer = { 1033static struct sys_device device_timer = {
1047 .id = 0, 1034 .id = 0,
@@ -1283,8 +1270,6 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1283} 1270}
1284#endif 1271#endif
1285 1272
1286
1287
1288static int __init nohpet_setup(char *s) 1273static int __init nohpet_setup(char *s)
1289{ 1274{
1290 nohpet = 1; 1275 nohpet = 1;
@@ -1301,5 +1286,3 @@ static int __init notsc_setup(char *s)
1301} 1286}
1302 1287
1303__setup("notsc", notsc_setup); 1288__setup("notsc", notsc_setup);
1304
1305
diff --git a/arch/x86_64/kernel/trampoline.S b/arch/x86_64/kernel/trampoline.S
index 6d9c9a8e7d0e..23a03eb91fc7 100644
--- a/arch/x86_64/kernel/trampoline.S
+++ b/arch/x86_64/kernel/trampoline.S
@@ -42,8 +42,15 @@ r_base = .
42 movl $0xA5A5A5A5, trampoline_data - r_base 42 movl $0xA5A5A5A5, trampoline_data - r_base
43 # write marker for master knows we're running 43 # write marker for master knows we're running
44 44
45 lidt idt_48 - r_base # load idt with 0, 0 45 /*
46 lgdt gdt_48 - r_base # load gdt with whatever is appropriate 46 * GDT tables in non default location kernel can be beyond 16MB and
47 * lgdt will not be able to load the address as in real mode default
48 * operand size is 16bit. Use lgdtl instead to force operand size
49 * to 32 bit.
50 */
51
52 lidtl idt_48 - r_base # load idt with 0, 0
53 lgdtl gdt_48 - r_base # load gdt with whatever is appropriate
47 54
48 xor %ax, %ax 55 xor %ax, %ax
49 inc %ax # protected mode (PE) bit 56 inc %ax # protected mode (PE) bit
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index bf337f493189..8bb0aeda78b9 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -70,7 +70,6 @@ asmlinkage void reserved(void);
70asmlinkage void alignment_check(void); 70asmlinkage void alignment_check(void);
71asmlinkage void machine_check(void); 71asmlinkage void machine_check(void);
72asmlinkage void spurious_interrupt_bug(void); 72asmlinkage void spurious_interrupt_bug(void);
73asmlinkage void call_debug(void);
74 73
75struct notifier_block *die_chain; 74struct notifier_block *die_chain;
76static DEFINE_SPINLOCK(die_notifier_lock); 75static DEFINE_SPINLOCK(die_notifier_lock);
@@ -121,19 +120,31 @@ int printk_address(unsigned long address)
121static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack, 120static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
122 unsigned *usedp, const char **idp) 121 unsigned *usedp, const char **idp)
123{ 122{
124 static const char ids[N_EXCEPTION_STACKS][8] = { 123 static char ids[][8] = {
125 [DEBUG_STACK - 1] = "#DB", 124 [DEBUG_STACK - 1] = "#DB",
126 [NMI_STACK - 1] = "NMI", 125 [NMI_STACK - 1] = "NMI",
127 [DOUBLEFAULT_STACK - 1] = "#DF", 126 [DOUBLEFAULT_STACK - 1] = "#DF",
128 [STACKFAULT_STACK - 1] = "#SS", 127 [STACKFAULT_STACK - 1] = "#SS",
129 [MCE_STACK - 1] = "#MC", 128 [MCE_STACK - 1] = "#MC",
129#if DEBUG_STKSZ > EXCEPTION_STKSZ
130 [N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
131#endif
130 }; 132 };
131 unsigned k; 133 unsigned k;
132 134
133 for (k = 0; k < N_EXCEPTION_STACKS; k++) { 135 for (k = 0; k < N_EXCEPTION_STACKS; k++) {
134 unsigned long end; 136 unsigned long end;
135 137
136 end = per_cpu(init_tss, cpu).ist[k]; 138 switch (k + 1) {
139#if DEBUG_STKSZ > EXCEPTION_STKSZ
140 case DEBUG_STACK:
141 end = cpu_pda(cpu)->debugstack + DEBUG_STKSZ;
142 break;
143#endif
144 default:
145 end = per_cpu(init_tss, cpu).ist[k];
146 break;
147 }
137 if (stack >= end) 148 if (stack >= end)
138 continue; 149 continue;
139 if (stack >= end - EXCEPTION_STKSZ) { 150 if (stack >= end - EXCEPTION_STKSZ) {
@@ -143,6 +154,22 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
143 *idp = ids[k]; 154 *idp = ids[k];
144 return (unsigned long *)end; 155 return (unsigned long *)end;
145 } 156 }
157#if DEBUG_STKSZ > EXCEPTION_STKSZ
158 if (k == DEBUG_STACK - 1 && stack >= end - DEBUG_STKSZ) {
159 unsigned j = N_EXCEPTION_STACKS - 1;
160
161 do {
162 ++j;
163 end -= EXCEPTION_STKSZ;
164 ids[j][4] = '1' + (j - N_EXCEPTION_STACKS);
165 } while (stack < end - EXCEPTION_STKSZ);
166 if (*usedp & (1U << j))
167 break;
168 *usedp |= 1U << j;
169 *idp = ids[j];
170 return (unsigned long *)end;
171 }
172#endif
146 } 173 }
147 return NULL; 174 return NULL;
148} 175}
@@ -156,9 +183,8 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
156 183
157void show_trace(unsigned long *stack) 184void show_trace(unsigned long *stack)
158{ 185{
159 unsigned long addr;
160 const unsigned cpu = safe_smp_processor_id(); 186 const unsigned cpu = safe_smp_processor_id();
161 unsigned long *irqstack_end = (unsigned long *)cpu_pda[cpu].irqstackptr; 187 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
162 int i; 188 int i;
163 unsigned used = 0; 189 unsigned used = 0;
164 190
@@ -166,8 +192,14 @@ void show_trace(unsigned long *stack)
166 192
167#define HANDLE_STACK(cond) \ 193#define HANDLE_STACK(cond) \
168 do while (cond) { \ 194 do while (cond) { \
169 addr = *stack++; \ 195 unsigned long addr = *stack++; \
170 if (kernel_text_address(addr)) { \ 196 if (kernel_text_address(addr)) { \
197 if (i > 50) { \
198 printk("\n "); \
199 i = 0; \
200 } \
201 else \
202 i += printk(" "); \
171 /* \ 203 /* \
172 * If the address is either in the text segment of the \ 204 * If the address is either in the text segment of the \
173 * kernel, or in the region which contains vmalloc'ed \ 205 * kernel, or in the region which contains vmalloc'ed \
@@ -177,25 +209,19 @@ void show_trace(unsigned long *stack)
177 * out the call path that was taken. \ 209 * out the call path that was taken. \
178 */ \ 210 */ \
179 i += printk_address(addr); \ 211 i += printk_address(addr); \
180 if (i > 50) { \
181 printk("\n "); \
182 i = 0; \
183 } \
184 else \
185 i += printk(" "); \
186 } \ 212 } \
187 } while (0) 213 } while (0)
188 214
189 for(i = 0; ; ) { 215 for(i = 11; ; ) {
190 const char *id; 216 const char *id;
191 unsigned long *estack_end; 217 unsigned long *estack_end;
192 estack_end = in_exception_stack(cpu, (unsigned long)stack, 218 estack_end = in_exception_stack(cpu, (unsigned long)stack,
193 &used, &id); 219 &used, &id);
194 220
195 if (estack_end) { 221 if (estack_end) {
196 i += printk(" <%s> ", id); 222 i += printk(" <%s>", id);
197 HANDLE_STACK (stack < estack_end); 223 HANDLE_STACK (stack < estack_end);
198 i += printk(" <EOE> "); 224 i += printk(" <EOE>");
199 stack = (unsigned long *) estack_end[-2]; 225 stack = (unsigned long *) estack_end[-2];
200 continue; 226 continue;
201 } 227 }
@@ -205,11 +231,11 @@ void show_trace(unsigned long *stack)
205 (IRQSTACKSIZE - 64) / sizeof(*irqstack); 231 (IRQSTACKSIZE - 64) / sizeof(*irqstack);
206 232
207 if (stack >= irqstack && stack < irqstack_end) { 233 if (stack >= irqstack && stack < irqstack_end) {
208 i += printk(" <IRQ> "); 234 i += printk(" <IRQ>");
209 HANDLE_STACK (stack < irqstack_end); 235 HANDLE_STACK (stack < irqstack_end);
210 stack = (unsigned long *) (irqstack_end[-1]); 236 stack = (unsigned long *) (irqstack_end[-1]);
211 irqstack_end = NULL; 237 irqstack_end = NULL;
212 i += printk(" <EOI> "); 238 i += printk(" <EOI>");
213 continue; 239 continue;
214 } 240 }
215 } 241 }
@@ -226,8 +252,8 @@ void show_stack(struct task_struct *tsk, unsigned long * rsp)
226 unsigned long *stack; 252 unsigned long *stack;
227 int i; 253 int i;
228 const int cpu = safe_smp_processor_id(); 254 const int cpu = safe_smp_processor_id();
229 unsigned long *irqstack_end = (unsigned long *) (cpu_pda[cpu].irqstackptr); 255 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
230 unsigned long *irqstack = (unsigned long *) (cpu_pda[cpu].irqstackptr - IRQSTACKSIZE); 256 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
231 257
232 // debugging aid: "show_stack(NULL, NULL);" prints the 258 // debugging aid: "show_stack(NULL, NULL);" prints the
233 // back trace for this cpu. 259 // back trace for this cpu.
@@ -275,14 +301,14 @@ void show_registers(struct pt_regs *regs)
275 int in_kernel = !user_mode(regs); 301 int in_kernel = !user_mode(regs);
276 unsigned long rsp; 302 unsigned long rsp;
277 const int cpu = safe_smp_processor_id(); 303 const int cpu = safe_smp_processor_id();
278 struct task_struct *cur = cpu_pda[cpu].pcurrent; 304 struct task_struct *cur = cpu_pda(cpu)->pcurrent;
279 305
280 rsp = regs->rsp; 306 rsp = regs->rsp;
281 307
282 printk("CPU %d ", cpu); 308 printk("CPU %d ", cpu);
283 __show_regs(regs); 309 __show_regs(regs);
284 printk("Process %s (pid: %d, threadinfo %p, task %p)\n", 310 printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
285 cur->comm, cur->pid, cur->thread_info, cur); 311 cur->comm, cur->pid, task_thread_info(cur), cur);
286 312
287 /* 313 /*
288 * When in-kernel, we also print out the stack and code at the 314 * When in-kernel, we also print out the stack and code at the
@@ -314,20 +340,26 @@ bad:
314void handle_BUG(struct pt_regs *regs) 340void handle_BUG(struct pt_regs *regs)
315{ 341{
316 struct bug_frame f; 342 struct bug_frame f;
317 char tmp; 343 long len;
344 const char *prefix = "";
318 345
319 if (user_mode(regs)) 346 if (user_mode(regs))
320 return; 347 return;
321 if (__copy_from_user(&f, (struct bug_frame *) regs->rip, 348 if (__copy_from_user(&f, (const void __user *) regs->rip,
322 sizeof(struct bug_frame))) 349 sizeof(struct bug_frame)))
323 return; 350 return;
324 if (f.filename >= 0 || 351 if (f.filename >= 0 ||
325 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b) 352 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b)
326 return; 353 return;
327 if (__get_user(tmp, (char *)(long)f.filename)) 354 len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
355 if (len < 0 || len >= PATH_MAX)
328 f.filename = (int)(long)"unmapped filename"; 356 f.filename = (int)(long)"unmapped filename";
357 else if (len > 50) {
358 f.filename += len - 50;
359 prefix = "...";
360 }
329 printk("----------- [cut here ] --------- [please bite here ] ---------\n"); 361 printk("----------- [cut here ] --------- [please bite here ] ---------\n");
330 printk(KERN_ALERT "Kernel BUG at %.50s:%d\n", (char *)(long)f.filename, f.line); 362 printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
331} 363}
332 364
333#ifdef CONFIG_BUG 365#ifdef CONFIG_BUG
@@ -382,7 +414,7 @@ void __die(const char * str, struct pt_regs * regs, long err)
382 printk("DEBUG_PAGEALLOC"); 414 printk("DEBUG_PAGEALLOC");
383#endif 415#endif
384 printk("\n"); 416 printk("\n");
385 notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); 417 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
386 show_registers(regs); 418 show_registers(regs);
387 /* Executive summary in case the oops scrolled away */ 419 /* Executive summary in case the oops scrolled away */
388 printk(KERN_ALERT "RIP "); 420 printk(KERN_ALERT "RIP ");
@@ -399,11 +431,6 @@ void die(const char * str, struct pt_regs * regs, long err)
399 oops_end(flags); 431 oops_end(flags);
400 do_exit(SIGSEGV); 432 do_exit(SIGSEGV);
401} 433}
402static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
403{
404 if (!(regs->eflags & VM_MASK) && (regs->cs == __KERNEL_CS))
405 die(str, regs, err);
406}
407 434
408void die_nmi(char *str, struct pt_regs *regs) 435void die_nmi(char *str, struct pt_regs *regs)
409{ 436{
@@ -426,19 +453,20 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
426 struct pt_regs * regs, long error_code, 453 struct pt_regs * regs, long error_code,
427 siginfo_t *info) 454 siginfo_t *info)
428{ 455{
456 struct task_struct *tsk = current;
457
429 conditional_sti(regs); 458 conditional_sti(regs);
430 459
431 if (user_mode(regs)) { 460 tsk->thread.error_code = error_code;
432 struct task_struct *tsk = current; 461 tsk->thread.trap_no = trapnr;
433 462
463 if (user_mode(regs)) {
434 if (exception_trace && unhandled_signal(tsk, signr)) 464 if (exception_trace && unhandled_signal(tsk, signr))
435 printk(KERN_INFO 465 printk(KERN_INFO
436 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n", 466 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
437 tsk->comm, tsk->pid, str, 467 tsk->comm, tsk->pid, str,
438 regs->rip,regs->rsp,error_code); 468 regs->rip,regs->rsp,error_code);
439 469
440 tsk->thread.error_code = error_code;
441 tsk->thread.trap_no = trapnr;
442 if (info) 470 if (info)
443 force_sig_info(signr, info, tsk); 471 force_sig_info(signr, info, tsk);
444 else 472 else
@@ -485,7 +513,7 @@ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
485DO_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->rip) 513DO_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->rip)
486DO_ERROR( 4, SIGSEGV, "overflow", overflow) 514DO_ERROR( 4, SIGSEGV, "overflow", overflow)
487DO_ERROR( 5, SIGSEGV, "bounds", bounds) 515DO_ERROR( 5, SIGSEGV, "bounds", bounds)
488DO_ERROR_INFO( 6, SIGILL, "invalid operand", invalid_op, ILL_ILLOPN, regs->rip) 516DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->rip)
489DO_ERROR( 7, SIGSEGV, "device not available", device_not_available) 517DO_ERROR( 7, SIGSEGV, "device not available", device_not_available)
490DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) 518DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
491DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS) 519DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
@@ -493,24 +521,41 @@ DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
493DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0) 521DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
494DO_ERROR(18, SIGSEGV, "reserved", reserved) 522DO_ERROR(18, SIGSEGV, "reserved", reserved)
495DO_ERROR(12, SIGBUS, "stack segment", stack_segment) 523DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
496DO_ERROR( 8, SIGSEGV, "double fault", double_fault) 524
525asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
526{
527 static const char str[] = "double fault";
528 struct task_struct *tsk = current;
529
530 /* Return not checked because double check cannot be ignored */
531 notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
532
533 tsk->thread.error_code = error_code;
534 tsk->thread.trap_no = 8;
535
536 /* This is always a kernel trap and never fixable (and thus must
537 never return). */
538 for (;;)
539 die(str, regs, error_code);
540}
497 541
498asmlinkage void __kprobes do_general_protection(struct pt_regs * regs, 542asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
499 long error_code) 543 long error_code)
500{ 544{
545 struct task_struct *tsk = current;
546
501 conditional_sti(regs); 547 conditional_sti(regs);
502 548
503 if (user_mode(regs)) { 549 tsk->thread.error_code = error_code;
504 struct task_struct *tsk = current; 550 tsk->thread.trap_no = 13;
505 551
552 if (user_mode(regs)) {
506 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) 553 if (exception_trace && unhandled_signal(tsk, SIGSEGV))
507 printk(KERN_INFO 554 printk(KERN_INFO
508 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n", 555 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
509 tsk->comm, tsk->pid, 556 tsk->comm, tsk->pid,
510 regs->rip,regs->rsp,error_code); 557 regs->rip,regs->rsp,error_code);
511 558
512 tsk->thread.error_code = error_code;
513 tsk->thread.trap_no = 13;
514 force_sig(SIGSEGV, tsk); 559 force_sig(SIGSEGV, tsk);
515 return; 560 return;
516 } 561 }
@@ -573,7 +618,7 @@ asmlinkage void default_do_nmi(struct pt_regs *regs)
573 reason = get_nmi_reason(); 618 reason = get_nmi_reason();
574 619
575 if (!(reason & 0xc0)) { 620 if (!(reason & 0xc0)) {
576 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 0, SIGINT) 621 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
577 == NOTIFY_STOP) 622 == NOTIFY_STOP)
578 return; 623 return;
579#ifdef CONFIG_X86_LOCAL_APIC 624#ifdef CONFIG_X86_LOCAL_APIC
@@ -589,7 +634,7 @@ asmlinkage void default_do_nmi(struct pt_regs *regs)
589 unknown_nmi_error(reason, regs); 634 unknown_nmi_error(reason, regs);
590 return; 635 return;
591 } 636 }
592 if (notify_die(DIE_NMI, "nmi", regs, reason, 0, SIGINT) == NOTIFY_STOP) 637 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
593 return; 638 return;
594 639
595 /* AK: following checks seem to be broken on modern chipsets. FIXME */ 640 /* AK: following checks seem to be broken on modern chipsets. FIXME */
@@ -600,6 +645,7 @@ asmlinkage void default_do_nmi(struct pt_regs *regs)
600 io_check_error(reason, regs); 645 io_check_error(reason, regs);
601} 646}
602 647
648/* runs on IST stack. */
603asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code) 649asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
604{ 650{
605 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) { 651 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
@@ -620,7 +666,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs)
620 ; 666 ;
621 /* Exception from user space */ 667 /* Exception from user space */
622 else if (user_mode(eregs)) 668 else if (user_mode(eregs))
623 regs = ((struct pt_regs *)current->thread.rsp0) - 1; 669 regs = task_pt_regs(current);
624 /* Exception from kernel and interrupts are enabled. Move to 670 /* Exception from kernel and interrupts are enabled. Move to
625 kernel process stack. */ 671 kernel process stack. */
626 else if (eregs->eflags & X86_EFLAGS_IF) 672 else if (eregs->eflags & X86_EFLAGS_IF)
@@ -684,11 +730,9 @@ asmlinkage void __kprobes do_debug(struct pt_regs * regs,
684 info.si_signo = SIGTRAP; 730 info.si_signo = SIGTRAP;
685 info.si_errno = 0; 731 info.si_errno = 0;
686 info.si_code = TRAP_BRKPT; 732 info.si_code = TRAP_BRKPT;
687 if (!user_mode(regs)) 733 info.si_addr = user_mode(regs) ? (void __user *)regs->rip : NULL;
688 goto clear_dr7; 734 force_sig_info(SIGTRAP, &info, tsk);
689 735
690 info.si_addr = (void __user *)regs->rip;
691 force_sig_info(SIGTRAP, &info, tsk);
692clear_dr7: 736clear_dr7:
693 set_debugreg(0UL, 7); 737 set_debugreg(0UL, 7);
694 return; 738 return;
@@ -698,7 +742,7 @@ clear_TF_reenable:
698 regs->eflags &= ~TF_MASK; 742 regs->eflags &= ~TF_MASK;
699} 743}
700 744
701static int kernel_math_error(struct pt_regs *regs, char *str) 745static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
702{ 746{
703 const struct exception_table_entry *fixup; 747 const struct exception_table_entry *fixup;
704 fixup = search_exception_tables(regs->rip); 748 fixup = search_exception_tables(regs->rip);
@@ -706,8 +750,9 @@ static int kernel_math_error(struct pt_regs *regs, char *str)
706 regs->rip = fixup->fixup; 750 regs->rip = fixup->fixup;
707 return 1; 751 return 1;
708 } 752 }
709 notify_die(DIE_GPF, str, regs, 0, 16, SIGFPE); 753 notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
710 /* Illegal floating point operation in the kernel */ 754 /* Illegal floating point operation in the kernel */
755 current->thread.trap_no = trapnr;
711 die(str, regs, 0); 756 die(str, regs, 0);
712 return 0; 757 return 0;
713} 758}
@@ -726,7 +771,7 @@ asmlinkage void do_coprocessor_error(struct pt_regs *regs)
726 771
727 conditional_sti(regs); 772 conditional_sti(regs);
728 if (!user_mode(regs) && 773 if (!user_mode(regs) &&
729 kernel_math_error(regs, "kernel x87 math error")) 774 kernel_math_error(regs, "kernel x87 math error", 16))
730 return; 775 return;
731 776
732 /* 777 /*
@@ -795,7 +840,7 @@ asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
795 840
796 conditional_sti(regs); 841 conditional_sti(regs);
797 if (!user_mode(regs) && 842 if (!user_mode(regs) &&
798 kernel_math_error(regs, "kernel simd math error")) 843 kernel_math_error(regs, "kernel simd math error", 19))
799 return; 844 return;
800 845
801 /* 846 /*
@@ -867,12 +912,7 @@ asmlinkage void math_state_restore(void)
867 if (!used_math()) 912 if (!used_math())
868 init_fpu(me); 913 init_fpu(me);
869 restore_fpu_checking(&me->thread.i387.fxsave); 914 restore_fpu_checking(&me->thread.i387.fxsave);
870 me->thread_info->status |= TS_USEDFPU; 915 task_thread_info(me)->status |= TS_USEDFPU;
871}
872
873void do_call_debug(struct pt_regs *regs)
874{
875 notify_die(DIE_CALL, "debug call", regs, 0, 255, SIGINT);
876} 916}
877 917
878void __init trap_init(void) 918void __init trap_init(void)
@@ -880,9 +920,9 @@ void __init trap_init(void)
880 set_intr_gate(0,&divide_error); 920 set_intr_gate(0,&divide_error);
881 set_intr_gate_ist(1,&debug,DEBUG_STACK); 921 set_intr_gate_ist(1,&debug,DEBUG_STACK);
882 set_intr_gate_ist(2,&nmi,NMI_STACK); 922 set_intr_gate_ist(2,&nmi,NMI_STACK);
883 set_system_gate(3,&int3); 923 set_system_gate_ist(3,&int3,DEBUG_STACK); /* int3 can be called from all */
884 set_system_gate(4,&overflow); /* int4-5 can be called from all */ 924 set_system_gate(4,&overflow); /* int4 can be called from all */
885 set_system_gate(5,&bounds); 925 set_intr_gate(5,&bounds);
886 set_intr_gate(6,&invalid_op); 926 set_intr_gate(6,&invalid_op);
887 set_intr_gate(7,&device_not_available); 927 set_intr_gate(7,&device_not_available);
888 set_intr_gate_ist(8,&double_fault, DOUBLEFAULT_STACK); 928 set_intr_gate_ist(8,&double_fault, DOUBLEFAULT_STACK);
@@ -904,8 +944,6 @@ void __init trap_init(void)
904 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall); 944 set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
905#endif 945#endif
906 946
907 set_intr_gate(KDB_VECTOR, call_debug);
908
909 /* 947 /*
910 * Should be a barrier for any external CPU state. 948 * Should be a barrier for any external CPU state.
911 */ 949 */
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 58b19215b4b3..b0eed1faf740 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -8,6 +8,8 @@
8#include <asm/page.h> 8#include <asm/page.h>
9#include <linux/config.h> 9#include <linux/config.h>
10 10
11#undef i386 /* in case the preprocessor is a 32bit one */
12
11OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 13OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
12OUTPUT_ARCH(i386:x86-64) 14OUTPUT_ARCH(i386:x86-64)
13ENTRY(phys_startup_64) 15ENTRY(phys_startup_64)
@@ -189,7 +191,7 @@ SECTIONS
189 /* Sections to be discarded */ 191 /* Sections to be discarded */
190 /DISCARD/ : { 192 /DISCARD/ : {
191 *(.exitcall.exit) 193 *(.exitcall.exit)
192#ifndef CONFIG_DEBUG_INFO 194#ifndef CONFIG_UNWIND_INFO
193 *(.eh_frame) 195 *(.eh_frame)
194#endif 196#endif
195 } 197 }
diff --git a/arch/x86_64/kernel/vsmp.c b/arch/x86_64/kernel/vsmp.c
new file mode 100644
index 000000000000..92f70c74965f
--- /dev/null
+++ b/arch/x86_64/kernel/vsmp.c
@@ -0,0 +1,45 @@
1/*
2 * vSMPowered(tm) systems specific initialization
3 * Copyright (C) 2005 ScaleMP Inc.
4 *
5 * Use of this code is subject to the terms and conditions of the
6 * GNU general public license version 2. See "COPYING" or
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 * Ravikiran Thirumalai <kiran@scalemp.com>,
10 * Shai Fultheim <shai@scalemp.com>
11 */
12
13#include <linux/init.h>
14#include <linux/pci_ids.h>
15#include <linux/pci_regs.h>
16#include <asm/pci-direct.h>
17
18static int __init vsmp_init(void)
19{
20 void *address;
21 unsigned int cap, ctl;
22
23 /* Check if we are running on a ScaleMP vSMP box */
24 if ((read_pci_config_16(0, 0x1f, 0, PCI_VENDOR_ID) != PCI_VENDOR_ID_SCALEMP) ||
25 (read_pci_config_16(0, 0x1f, 0, PCI_DEVICE_ID) != PCI_DEVICE_ID_SCALEMP_VSMP_CTL))
26 return 0;
27
28 /* set vSMP magic bits to indicate vSMP capable kernel */
29 address = ioremap(read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0), 8);
30 cap = readl(address);
31 ctl = readl(address + 4);
32 printk("vSMP CTL: capabilities:0x%08x control:0x%08x\n", cap, ctl);
33 if (cap & ctl & (1 << 4)) {
34 /* Turn on vSMP IRQ fastpath handling (see system.h) */
35 ctl &= ~(1 << 4);
36 writel(ctl, address + 4);
37 ctl = readl(address + 4);
38 printk("vSMP CTL: control set to:0x%08x\n", ctl);
39 }
40
41 iounmap(address);
42 return 0;
43}
44
45core_initcall(vsmp_init);
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 70a0bd16085f..9468fb20b0bc 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -35,14 +35,13 @@
35#include <asm/io.h> 35#include <asm/io.h>
36 36
37#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 37#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
38#define force_inline __attribute__((always_inline)) inline
39 38
40int __sysctl_vsyscall __section_sysctl_vsyscall = 1; 39int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
41seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED; 40seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
42 41
43#include <asm/unistd.h> 42#include <asm/unistd.h>
44 43
45static force_inline void timeval_normalize(struct timeval * tv) 44static __always_inline void timeval_normalize(struct timeval * tv)
46{ 45{
47 time_t __sec; 46 time_t __sec;
48 47
@@ -53,7 +52,7 @@ static force_inline void timeval_normalize(struct timeval * tv)
53 } 52 }
54} 53}
55 54
56static force_inline void do_vgettimeofday(struct timeval * tv) 55static __always_inline void do_vgettimeofday(struct timeval * tv)
57{ 56{
58 long sequence, t; 57 long sequence, t;
59 unsigned long sec, usec; 58 unsigned long sec, usec;
@@ -66,8 +65,7 @@ static force_inline void do_vgettimeofday(struct timeval * tv)
66 (__jiffies - __wall_jiffies) * (1000000 / HZ); 65 (__jiffies - __wall_jiffies) * (1000000 / HZ);
67 66
68 if (__vxtime.mode != VXTIME_HPET) { 67 if (__vxtime.mode != VXTIME_HPET) {
69 sync_core(); 68 t = get_cycles_sync();
70 rdtscll(t);
71 if (t < __vxtime.last_tsc) 69 if (t < __vxtime.last_tsc)
72 t = __vxtime.last_tsc; 70 t = __vxtime.last_tsc;
73 usec += ((t - __vxtime.last_tsc) * 71 usec += ((t - __vxtime.last_tsc) *
@@ -84,12 +82,12 @@ static force_inline void do_vgettimeofday(struct timeval * tv)
84} 82}
85 83
86/* RED-PEN may want to readd seq locking, but then the variable should be write-once. */ 84/* RED-PEN may want to readd seq locking, but then the variable should be write-once. */
87static force_inline void do_get_tz(struct timezone * tz) 85static __always_inline void do_get_tz(struct timezone * tz)
88{ 86{
89 *tz = __sys_tz; 87 *tz = __sys_tz;
90} 88}
91 89
92static force_inline int gettimeofday(struct timeval *tv, struct timezone *tz) 90static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
93{ 91{
94 int ret; 92 int ret;
95 asm volatile("vsysc2: syscall" 93 asm volatile("vsysc2: syscall"
@@ -98,7 +96,7 @@ static force_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
98 return ret; 96 return ret;
99} 97}
100 98
101static force_inline long time_syscall(long *t) 99static __always_inline long time_syscall(long *t)
102{ 100{
103 long secs; 101 long secs;
104 asm volatile("vsysc1: syscall" 102 asm volatile("vsysc1: syscall"
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index 4a54221e10bc..b614d54d2ae4 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -13,7 +13,6 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/syscalls.h> 14#include <linux/syscalls.h>
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/ioctl32.h>
17 16
18#include <asm/semaphore.h> 17#include <asm/semaphore.h>
19#include <asm/processor.h> 18#include <asm/processor.h>
@@ -45,22 +44,15 @@ extern struct drive_info_struct drive_info;
45EXPORT_SYMBOL(drive_info); 44EXPORT_SYMBOL(drive_info);
46#endif 45#endif
47 46
48extern unsigned long get_cmos_time(void);
49
50/* platform dependent support */ 47/* platform dependent support */
51EXPORT_SYMBOL(boot_cpu_data); 48EXPORT_SYMBOL(boot_cpu_data);
52//EXPORT_SYMBOL(dump_fpu); 49//EXPORT_SYMBOL(dump_fpu);
53EXPORT_SYMBOL(__ioremap); 50EXPORT_SYMBOL(__ioremap);
54EXPORT_SYMBOL(ioremap_nocache); 51EXPORT_SYMBOL(ioremap_nocache);
55EXPORT_SYMBOL(iounmap); 52EXPORT_SYMBOL(iounmap);
56EXPORT_SYMBOL(enable_irq);
57EXPORT_SYMBOL(disable_irq);
58EXPORT_SYMBOL(disable_irq_nosync);
59EXPORT_SYMBOL(probe_irq_mask);
60EXPORT_SYMBOL(kernel_thread); 53EXPORT_SYMBOL(kernel_thread);
61EXPORT_SYMBOL(pm_idle); 54EXPORT_SYMBOL(pm_idle);
62EXPORT_SYMBOL(pm_power_off); 55EXPORT_SYMBOL(pm_power_off);
63EXPORT_SYMBOL(get_cmos_time);
64 56
65EXPORT_SYMBOL(__down_failed); 57EXPORT_SYMBOL(__down_failed);
66EXPORT_SYMBOL(__down_failed_interruptible); 58EXPORT_SYMBOL(__down_failed_interruptible);
@@ -84,9 +76,6 @@ EXPORT_SYMBOL(__put_user_2);
84EXPORT_SYMBOL(__put_user_4); 76EXPORT_SYMBOL(__put_user_4);
85EXPORT_SYMBOL(__put_user_8); 77EXPORT_SYMBOL(__put_user_8);
86 78
87EXPORT_SYMBOL(strpbrk);
88EXPORT_SYMBOL(strstr);
89
90EXPORT_SYMBOL(strncpy_from_user); 79EXPORT_SYMBOL(strncpy_from_user);
91EXPORT_SYMBOL(__strncpy_from_user); 80EXPORT_SYMBOL(__strncpy_from_user);
92EXPORT_SYMBOL(clear_user); 81EXPORT_SYMBOL(clear_user);
@@ -98,25 +87,18 @@ EXPORT_SYMBOL(copy_in_user);
98EXPORT_SYMBOL(strnlen_user); 87EXPORT_SYMBOL(strnlen_user);
99 88
100#ifdef CONFIG_PCI 89#ifdef CONFIG_PCI
101EXPORT_SYMBOL(pci_alloc_consistent);
102EXPORT_SYMBOL(pci_free_consistent);
103#endif
104
105#ifdef CONFIG_PCI
106EXPORT_SYMBOL(pci_mem_start); 90EXPORT_SYMBOL(pci_mem_start);
107#endif 91#endif
108 92
109EXPORT_SYMBOL(copy_page); 93EXPORT_SYMBOL(copy_page);
110EXPORT_SYMBOL(clear_page); 94EXPORT_SYMBOL(clear_page);
111 95
112EXPORT_SYMBOL(cpu_pda); 96EXPORT_SYMBOL(_cpu_pda);
113#ifdef CONFIG_SMP 97#ifdef CONFIG_SMP
114EXPORT_SYMBOL(cpu_data); 98EXPORT_SYMBOL(cpu_data);
115EXPORT_SYMBOL(cpu_online_map);
116EXPORT_SYMBOL(__write_lock_failed); 99EXPORT_SYMBOL(__write_lock_failed);
117EXPORT_SYMBOL(__read_lock_failed); 100EXPORT_SYMBOL(__read_lock_failed);
118 101
119EXPORT_SYMBOL(synchronize_irq);
120EXPORT_SYMBOL(smp_call_function); 102EXPORT_SYMBOL(smp_call_function);
121EXPORT_SYMBOL(cpu_callout_map); 103EXPORT_SYMBOL(cpu_callout_map);
122#endif 104#endif
@@ -137,30 +119,17 @@ EXPORT_SYMBOL_GPL(unset_nmi_callback);
137#undef memcpy 119#undef memcpy
138#undef memset 120#undef memset
139#undef memmove 121#undef memmove
140#undef memchr
141#undef strlen 122#undef strlen
142#undef strncmp
143#undef strncpy
144#undef strchr
145 123
146extern void * memset(void *,int,__kernel_size_t); 124extern void * memset(void *,int,__kernel_size_t);
147extern size_t strlen(const char *); 125extern size_t strlen(const char *);
148extern void * memmove(void * dest,const void *src,size_t count); 126extern void * memmove(void * dest,const void *src,size_t count);
149extern void *memchr(const void *s, int c, size_t n);
150extern void * memcpy(void *,const void *,__kernel_size_t); 127extern void * memcpy(void *,const void *,__kernel_size_t);
151extern void * __memcpy(void *,const void *,__kernel_size_t); 128extern void * __memcpy(void *,const void *,__kernel_size_t);
152 129
153EXPORT_SYMBOL(memset); 130EXPORT_SYMBOL(memset);
154EXPORT_SYMBOL(strlen); 131EXPORT_SYMBOL(strlen);
155EXPORT_SYMBOL(memmove); 132EXPORT_SYMBOL(memmove);
156EXPORT_SYMBOL(strncmp);
157EXPORT_SYMBOL(strncpy);
158EXPORT_SYMBOL(strchr);
159EXPORT_SYMBOL(strncat);
160EXPORT_SYMBOL(memchr);
161EXPORT_SYMBOL(strrchr);
162EXPORT_SYMBOL(strnlen);
163EXPORT_SYMBOL(memscan);
164EXPORT_SYMBOL(memcpy); 133EXPORT_SYMBOL(memcpy);
165EXPORT_SYMBOL(__memcpy); 134EXPORT_SYMBOL(__memcpy);
166 135
diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
index dfa358b05c89..79422b6559c3 100644
--- a/arch/x86_64/lib/copy_user.S
+++ b/arch/x86_64/lib/copy_user.S
@@ -4,12 +4,9 @@
4 * Functions to copy from and to user space. 4 * Functions to copy from and to user space.
5 */ 5 */
6 6
7#define FIX_ALIGNMENT 1
8
9 #include <asm/current.h> 7 #include <asm/current.h>
10 #include <asm/asm-offsets.h> 8 #include <asm/asm-offsets.h>
11 #include <asm/thread_info.h> 9 #include <asm/thread_info.h>
12 #include <asm/cpufeature.h>
13 10
14/* Standard copy_to_user with segment limit checking */ 11/* Standard copy_to_user with segment limit checking */
15 .globl copy_to_user 12 .globl copy_to_user
@@ -21,23 +18,7 @@ copy_to_user:
21 jc bad_to_user 18 jc bad_to_user
22 cmpq threadinfo_addr_limit(%rax),%rcx 19 cmpq threadinfo_addr_limit(%rax),%rcx
23 jae bad_to_user 20 jae bad_to_user
242: 21 jmp copy_user_generic
25 .byte 0xe9 /* 32bit jump */
26 .long .Lcug-1f
271:
28
29 .section .altinstr_replacement,"ax"
303: .byte 0xe9 /* replacement jmp with 8 bit immediate */
31 .long copy_user_generic_c-1b /* offset */
32 .previous
33 .section .altinstructions,"a"
34 .align 8
35 .quad 2b
36 .quad 3b
37 .byte X86_FEATURE_K8_C
38 .byte 5
39 .byte 5
40 .previous
41 22
42/* Standard copy_from_user with segment limit checking */ 23/* Standard copy_from_user with segment limit checking */
43 .globl copy_from_user 24 .globl copy_from_user
@@ -72,223 +53,44 @@ bad_to_user:
72 * rsi source 53 * rsi source
73 * rdx count 54 * rdx count
74 * 55 *
56 * Only 4GB of copy is supported. This shouldn't be a problem
57 * because the kernel normally only writes from/to page sized chunks
58 * even if user space passed a longer buffer.
59 * And more would be dangerous because both Intel and AMD have
60 * errata with rep movsq > 4GB. If someone feels the need to fix
61 * this please consider this.
62 *
75 * Output: 63 * Output:
76 * eax uncopied bytes or 0 if successful. 64 * eax uncopied bytes or 0 if successful.
77 */ 65 */
78 .globl copy_user_generic
79 .p2align 4
80copy_user_generic:
81 .byte 0x66,0x66,0x90 /* 5 byte nop for replacement jump */
82 .byte 0x66,0x90
831:
84 .section .altinstr_replacement,"ax"
852: .byte 0xe9 /* near jump with 32bit immediate */
86 .long copy_user_generic_c-1b /* offset */
87 .previous
88 .section .altinstructions,"a"
89 .align 8
90 .quad copy_user_generic
91 .quad 2b
92 .byte X86_FEATURE_K8_C
93 .byte 5
94 .byte 5
95 .previous
96.Lcug:
97 pushq %rbx
98 xorl %eax,%eax /*zero for the exception handler */
99
100#ifdef FIX_ALIGNMENT
101 /* check for bad alignment of destination */
102 movl %edi,%ecx
103 andl $7,%ecx
104 jnz .Lbad_alignment
105.Lafter_bad_alignment:
106#endif
107 66
108 movq %rdx,%rcx 67 .globl copy_user_generic
109 68copy_user_generic:
110 movl $64,%ebx
111 shrq $6,%rdx
112 decq %rdx
113 js .Lhandle_tail
114
115 .p2align 4
116.Lloop:
117.Ls1: movq (%rsi),%r11
118.Ls2: movq 1*8(%rsi),%r8
119.Ls3: movq 2*8(%rsi),%r9
120.Ls4: movq 3*8(%rsi),%r10
121.Ld1: movq %r11,(%rdi)
122.Ld2: movq %r8,1*8(%rdi)
123.Ld3: movq %r9,2*8(%rdi)
124.Ld4: movq %r10,3*8(%rdi)
125
126.Ls5: movq 4*8(%rsi),%r11
127.Ls6: movq 5*8(%rsi),%r8
128.Ls7: movq 6*8(%rsi),%r9
129.Ls8: movq 7*8(%rsi),%r10
130.Ld5: movq %r11,4*8(%rdi)
131.Ld6: movq %r8,5*8(%rdi)
132.Ld7: movq %r9,6*8(%rdi)
133.Ld8: movq %r10,7*8(%rdi)
134
135 decq %rdx
136
137 leaq 64(%rsi),%rsi
138 leaq 64(%rdi),%rdi
139
140 jns .Lloop
141
142 .p2align 4
143.Lhandle_tail:
144 movl %ecx,%edx
145 andl $63,%ecx
146 shrl $3,%ecx
147 jz .Lhandle_7
148 movl $8,%ebx
149 .p2align 4
150.Lloop_8:
151.Ls9: movq (%rsi),%r8
152.Ld9: movq %r8,(%rdi)
153 decl %ecx
154 leaq 8(%rdi),%rdi
155 leaq 8(%rsi),%rsi
156 jnz .Lloop_8
157
158.Lhandle_7:
159 movl %edx,%ecx
160 andl $7,%ecx
161 jz .Lende
162 .p2align 4
163.Lloop_1:
164.Ls10: movb (%rsi),%bl
165.Ld10: movb %bl,(%rdi)
166 incq %rdi
167 incq %rsi
168 decl %ecx
169 jnz .Lloop_1
170
171.Lende:
172 popq %rbx
173 ret
174
175#ifdef FIX_ALIGNMENT
176 /* align destination */
177 .p2align 4
178.Lbad_alignment:
179 movl $8,%r9d
180 subl %ecx,%r9d
181 movl %r9d,%ecx
182 cmpq %r9,%rdx
183 jz .Lhandle_7
184 js .Lhandle_7
185.Lalign_1:
186.Ls11: movb (%rsi),%bl
187.Ld11: movb %bl,(%rdi)
188 incq %rsi
189 incq %rdi
190 decl %ecx
191 jnz .Lalign_1
192 subq %r9,%rdx
193 jmp .Lafter_bad_alignment
194#endif
195
196 /* table sorted by exception address */
197 .section __ex_table,"a"
198 .align 8
199 .quad .Ls1,.Ls1e
200 .quad .Ls2,.Ls2e
201 .quad .Ls3,.Ls3e
202 .quad .Ls4,.Ls4e
203 .quad .Ld1,.Ls1e
204 .quad .Ld2,.Ls2e
205 .quad .Ld3,.Ls3e
206 .quad .Ld4,.Ls4e
207 .quad .Ls5,.Ls5e
208 .quad .Ls6,.Ls6e
209 .quad .Ls7,.Ls7e
210 .quad .Ls8,.Ls8e
211 .quad .Ld5,.Ls5e
212 .quad .Ld6,.Ls6e
213 .quad .Ld7,.Ls7e
214 .quad .Ld8,.Ls8e
215 .quad .Ls9,.Le_quad
216 .quad .Ld9,.Le_quad
217 .quad .Ls10,.Le_byte
218 .quad .Ld10,.Le_byte
219#ifdef FIX_ALIGNMENT
220 .quad .Ls11,.Lzero_rest
221 .quad .Ld11,.Lzero_rest
222#endif
223 .quad .Le5,.Le_zero
224 .previous
225
226 /* compute 64-offset for main loop. 8 bytes accuracy with error on the
227 pessimistic side. this is gross. it would be better to fix the
228 interface. */
229 /* eax: zero, ebx: 64 */
230.Ls1e: addl $8,%eax
231.Ls2e: addl $8,%eax
232.Ls3e: addl $8,%eax
233.Ls4e: addl $8,%eax
234.Ls5e: addl $8,%eax
235.Ls6e: addl $8,%eax
236.Ls7e: addl $8,%eax
237.Ls8e: addl $8,%eax
238 addq %rbx,%rdi /* +64 */
239 subq %rax,%rdi /* correct destination with computed offset */
240
241 shlq $6,%rdx /* loop counter * 64 (stride length) */
242 addq %rax,%rdx /* add offset to loopcnt */
243 andl $63,%ecx /* remaining bytes */
244 addq %rcx,%rdx /* add them */
245 jmp .Lzero_rest
246
247 /* exception on quad word loop in tail handling */
248 /* ecx: loopcnt/8, %edx: length, rdi: correct */
249.Le_quad:
250 shll $3,%ecx
251 andl $7,%edx
252 addl %ecx,%edx
253 /* edx: bytes to zero, rdi: dest, eax:zero */
254.Lzero_rest:
255 movq %rdx,%rcx
256.Le_byte:
257 xorl %eax,%eax
258.Le5: rep
259 stosb
260 /* when there is another exception while zeroing the rest just return */
261.Le_zero:
262 movq %rdx,%rax
263 jmp .Lende
264
265 /* C stepping K8 run faster using the string copy instructions.
266 This is also a lot simpler. Use them when possible.
267 Patch in jmps to this code instead of copying it fully
268 to avoid unwanted aliasing in the exception tables. */
269
270 /* rdi destination
271 * rsi source
272 * rdx count
273 *
274 * Output:
275 * eax uncopied bytes or 0 if successfull.
276 */
277copy_user_generic_c:
278 movl %edx,%ecx 69 movl %edx,%ecx
279 shrl $3,%ecx 70 shrl $3,%ecx
280 andl $7,%edx 71 andl $7,%edx
72 jz 5f
2811: rep 731: rep
282 movsq 74 movsq
283 movl %edx,%ecx 75 movl %edx,%ecx
76 xor %eax,%eax
2842: rep 772: rep
285 movsb 78 movsb
2864: movl %ecx,%eax
287 ret 79 ret
80 /* align here? */
815: xorl %eax,%eax
826: rep movsq
83 ret
84
85 .section .fixup,"ax"
2883: lea (%rdx,%rcx,8),%rax 863: lea (%rdx,%rcx,8),%rax
289 ret 87 ret
290 884: movl %ecx,%eax
89 ret
90 .previous
91
291 .section __ex_table,"a" 92 .section __ex_table,"a"
292 .quad 1b,3b 93 .quad 1b,3b
293 .quad 2b,4b 94 .quad 2b,4b
95 .quad 6b,4b
294 .previous 96 .previous
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
index 841bd738a189..03c460cbdd1c 100644
--- a/arch/x86_64/lib/delay.c
+++ b/arch/x86_64/lib/delay.c
@@ -39,7 +39,7 @@ void __delay(unsigned long loops)
39 39
40inline void __const_udelay(unsigned long xloops) 40inline void __const_udelay(unsigned long xloops)
41{ 41{
42 __delay(((xloops * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) * HZ); 42 __delay((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32);
43} 43}
44 44
45void __udelay(unsigned long usecs) 45void __udelay(unsigned long usecs)
diff --git a/arch/x86_64/lib/usercopy.c b/arch/x86_64/lib/usercopy.c
index db8abba1ad81..9bc2c295818e 100644
--- a/arch/x86_64/lib/usercopy.c
+++ b/arch/x86_64/lib/usercopy.c
@@ -109,14 +109,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
109 * Return 0 on exception, a value greater than N if too long 109 * Return 0 on exception, a value greater than N if too long
110 */ 110 */
111 111
112long strnlen_user(const char __user *s, long n) 112long __strnlen_user(const char __user *s, long n)
113{ 113{
114 long res = 0; 114 long res = 0;
115 char c; 115 char c;
116 116
117 if (!access_ok(VERIFY_READ, s, n))
118 return 0;
119
120 while (1) { 117 while (1) {
121 if (res>n) 118 if (res>n)
122 return n+1; 119 return n+1;
@@ -129,6 +126,13 @@ long strnlen_user(const char __user *s, long n)
129 } 126 }
130} 127}
131 128
129long strnlen_user(const char __user *s, long n)
130{
131 if (!access_ok(VERIFY_READ, s, n))
132 return 0;
133 return __strnlen_user(s, n);
134}
135
132long strlen_user(const char __user *s) 136long strlen_user(const char __user *s)
133{ 137{
134 long res = 0; 138 long res = 0;
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 3a63707a698b..26eac194064b 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -35,6 +35,13 @@
35#include <asm-generic/sections.h> 35#include <asm-generic/sections.h>
36#include <asm/kdebug.h> 36#include <asm/kdebug.h>
37 37
38/* Page fault error code bits */
39#define PF_PROT (1<<0) /* or no page found */
40#define PF_WRITE (1<<1)
41#define PF_USER (1<<2)
42#define PF_RSVD (1<<3)
43#define PF_INSTR (1<<4)
44
38void bust_spinlocks(int yes) 45void bust_spinlocks(int yes)
39{ 46{
40 int loglevel_save = console_loglevel; 47 int loglevel_save = console_loglevel;
@@ -68,7 +75,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
68 unsigned char *max_instr; 75 unsigned char *max_instr;
69 76
70 /* If it was a exec fault ignore */ 77 /* If it was a exec fault ignore */
71 if (error_code & (1<<4)) 78 if (error_code & PF_INSTR)
72 return 0; 79 return 0;
73 80
74 instr = (unsigned char *)convert_rip_to_linear(current, regs); 81 instr = (unsigned char *)convert_rip_to_linear(current, regs);
@@ -222,17 +229,22 @@ static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
222 unsigned long error_code) 229 unsigned long error_code)
223{ 230{
224 unsigned long flags = oops_begin(); 231 unsigned long flags = oops_begin();
232 struct task_struct *tsk;
225 233
226 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", 234 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
227 current->comm, address); 235 current->comm, address);
228 dump_pagetable(address); 236 dump_pagetable(address);
237 tsk = current;
238 tsk->thread.cr2 = address;
239 tsk->thread.trap_no = 14;
240 tsk->thread.error_code = error_code;
229 __die("Bad pagetable", regs, error_code); 241 __die("Bad pagetable", regs, error_code);
230 oops_end(flags); 242 oops_end(flags);
231 do_exit(SIGKILL); 243 do_exit(SIGKILL);
232} 244}
233 245
234/* 246/*
235 * Handle a fault on the vmalloc or module mapping area 247 * Handle a fault on the vmalloc area
236 * 248 *
237 * This assumes no large pages in there. 249 * This assumes no large pages in there.
238 */ 250 */
@@ -278,7 +290,6 @@ static int vmalloc_fault(unsigned long address)
278 that. */ 290 that. */
279 if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref)) 291 if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref))
280 BUG(); 292 BUG();
281 __flush_tlb_all();
282 return 0; 293 return 0;
283} 294}
284 295
@@ -289,12 +300,6 @@ int exception_trace = 1;
289 * This routine handles page faults. It determines the address, 300 * This routine handles page faults. It determines the address,
290 * and the problem, and then passes it off to one of the appropriate 301 * and the problem, and then passes it off to one of the appropriate
291 * routines. 302 * routines.
292 *
293 * error_code:
294 * bit 0 == 0 means no page found, 1 means protection fault
295 * bit 1 == 0 means read, 1 means write
296 * bit 2 == 0 means kernel, 1 means user-mode
297 * bit 3 == 1 means fault was an instruction fetch
298 */ 303 */
299asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, 304asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
300 unsigned long error_code) 305 unsigned long error_code)
@@ -337,12 +342,16 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
337 * 342 *
338 * This verifies that the fault happens in kernel space 343 * This verifies that the fault happens in kernel space
339 * (error_code & 4) == 0, and that the fault was not a 344 * (error_code & 4) == 0, and that the fault was not a
340 * protection error (error_code & 1) == 0. 345 * protection error (error_code & 9) == 0.
341 */ 346 */
342 if (unlikely(address >= TASK_SIZE64)) { 347 if (unlikely(address >= TASK_SIZE64)) {
343 if (!(error_code & 5) && 348 /*
344 ((address >= VMALLOC_START && address < VMALLOC_END) || 349 * Don't check for the module range here: its PML4
345 (address >= MODULES_VADDR && address < MODULES_END))) { 350 * is always initialized because it's shared with the main
351 * kernel text. Only vmalloc may need PML4 syncups.
352 */
353 if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
354 ((address >= VMALLOC_START && address < VMALLOC_END))) {
346 if (vmalloc_fault(address) < 0) 355 if (vmalloc_fault(address) < 0)
347 goto bad_area_nosemaphore; 356 goto bad_area_nosemaphore;
348 return; 357 return;
@@ -354,7 +363,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
354 goto bad_area_nosemaphore; 363 goto bad_area_nosemaphore;
355 } 364 }
356 365
357 if (unlikely(error_code & (1 << 3))) 366 if (unlikely(error_code & PF_RSVD))
358 pgtable_bad(address, regs, error_code); 367 pgtable_bad(address, regs, error_code);
359 368
360 /* 369 /*
@@ -381,7 +390,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
381 * thus avoiding the deadlock. 390 * thus avoiding the deadlock.
382 */ 391 */
383 if (!down_read_trylock(&mm->mmap_sem)) { 392 if (!down_read_trylock(&mm->mmap_sem)) {
384 if ((error_code & 4) == 0 && 393 if ((error_code & PF_USER) == 0 &&
385 !search_exception_tables(regs->rip)) 394 !search_exception_tables(regs->rip))
386 goto bad_area_nosemaphore; 395 goto bad_area_nosemaphore;
387 down_read(&mm->mmap_sem); 396 down_read(&mm->mmap_sem);
@@ -408,17 +417,17 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
408good_area: 417good_area:
409 info.si_code = SEGV_ACCERR; 418 info.si_code = SEGV_ACCERR;
410 write = 0; 419 write = 0;
411 switch (error_code & 3) { 420 switch (error_code & (PF_PROT|PF_WRITE)) {
412 default: /* 3: write, present */ 421 default: /* 3: write, present */
413 /* fall through */ 422 /* fall through */
414 case 2: /* write, not present */ 423 case PF_WRITE: /* write, not present */
415 if (!(vma->vm_flags & VM_WRITE)) 424 if (!(vma->vm_flags & VM_WRITE))
416 goto bad_area; 425 goto bad_area;
417 write++; 426 write++;
418 break; 427 break;
419 case 1: /* read, present */ 428 case PF_PROT: /* read, present */
420 goto bad_area; 429 goto bad_area;
421 case 0: /* read, not present */ 430 case 0: /* read, not present */
422 if (!(vma->vm_flags & (VM_READ | VM_EXEC))) 431 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
423 goto bad_area; 432 goto bad_area;
424 } 433 }
@@ -453,7 +462,7 @@ bad_area:
453 462
454bad_area_nosemaphore: 463bad_area_nosemaphore:
455 /* User mode accesses just cause a SIGSEGV */ 464 /* User mode accesses just cause a SIGSEGV */
456 if (error_code & 4) { 465 if (error_code & PF_USER) {
457 if (is_prefetch(regs, address, error_code)) 466 if (is_prefetch(regs, address, error_code))
458 return; 467 return;
459 468
@@ -521,6 +530,9 @@ no_context:
521 printk_address(regs->rip); 530 printk_address(regs->rip);
522 printk("\n"); 531 printk("\n");
523 dump_pagetable(address); 532 dump_pagetable(address);
533 tsk->thread.cr2 = address;
534 tsk->thread.trap_no = 14;
535 tsk->thread.error_code = error_code;
524 __die("Oops", regs, error_code); 536 __die("Oops", regs, error_code);
525 /* Executive summary in case the body of the oops scrolled away */ 537 /* Executive summary in case the body of the oops scrolled away */
526 printk(KERN_EMERG "CR2: %016lx\n", address); 538 printk(KERN_EMERG "CR2: %016lx\n", address);
@@ -546,7 +558,7 @@ do_sigbus:
546 up_read(&mm->mmap_sem); 558 up_read(&mm->mmap_sem);
547 559
548 /* Kernel mode? Handle exceptions or die */ 560 /* Kernel mode? Handle exceptions or die */
549 if (!(error_code & 4)) 561 if (!(error_code & PF_USER))
550 goto no_context; 562 goto no_context;
551 563
552 tsk->thread.cr2 = address; 564 tsk->thread.cr2 = address;
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 1faae5fc1c01..eca60125efc3 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/dma-mapping.h>
26 27
27#include <asm/processor.h> 28#include <asm/processor.h>
28#include <asm/system.h> 29#include <asm/system.h>
@@ -38,11 +39,16 @@
38#include <asm/proto.h> 39#include <asm/proto.h>
39#include <asm/smp.h> 40#include <asm/smp.h>
40#include <asm/sections.h> 41#include <asm/sections.h>
42#include <asm/dma-mapping.h>
43#include <asm/swiotlb.h>
41 44
42#ifndef Dprintk 45#ifndef Dprintk
43#define Dprintk(x...) 46#define Dprintk(x...)
44#endif 47#endif
45 48
49struct dma_mapping_ops* dma_ops;
50EXPORT_SYMBOL(dma_ops);
51
46static unsigned long dma_reserve __initdata; 52static unsigned long dma_reserve __initdata;
47 53
48DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 54DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
@@ -249,14 +255,26 @@ static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned lon
249 255
250static void __init find_early_table_space(unsigned long end) 256static void __init find_early_table_space(unsigned long end)
251{ 257{
252 unsigned long puds, pmds, tables; 258 unsigned long puds, pmds, tables, start;
253 259
254 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT; 260 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
255 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT; 261 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
256 tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) + 262 tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) +
257 round_up(pmds * sizeof(pmd_t), PAGE_SIZE); 263 round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
258 264
259 table_start = find_e820_area(0x8000, __pa_symbol(&_text), tables); 265 /* Put page tables beyond the DMA zones if possible.
266 RED-PEN might be better to spread them out more over
267 memory to avoid hotspots */
268 if (end > MAX_DMA32_PFN<<PAGE_SHIFT)
269 start = MAX_DMA32_PFN << PAGE_SHIFT;
270 else if (end > MAX_DMA_PFN << PAGE_SHIFT)
271 start = MAX_DMA_PFN << PAGE_SHIFT;
272 else
273 start = 0x8000;
274
275 table_start = find_e820_area(start, end, tables);
276 if (table_start == -1)
277 table_start = find_e820_area(0x8000, end, tables);
260 if (table_start == -1UL) 278 if (table_start == -1UL)
261 panic("Cannot find space for the kernel page tables"); 279 panic("Cannot find space for the kernel page tables");
262 280
@@ -423,12 +441,9 @@ void __init mem_init(void)
423 long codesize, reservedpages, datasize, initsize; 441 long codesize, reservedpages, datasize, initsize;
424 442
425#ifdef CONFIG_SWIOTLB 443#ifdef CONFIG_SWIOTLB
426 if (!iommu_aperture && 444 pci_swiotlb_init();
427 (end_pfn >= 0xffffffff>>PAGE_SHIFT || force_iommu))
428 swiotlb = 1;
429 if (swiotlb)
430 swiotlb_init();
431#endif 445#endif
446 no_iommu_init();
432 447
433 /* How many end-of-memory variables you have, grandma! */ 448 /* How many end-of-memory variables you have, grandma! */
434 max_low_pfn = end_pfn; 449 max_low_pfn = end_pfn;
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 15b67d2760cb..6ef9f9a76235 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -46,8 +46,8 @@ int numa_off __initdata;
46 * 0 if memnodmap[] too small (of shift too small) 46 * 0 if memnodmap[] too small (of shift too small)
47 * -1 if node overlap or lost ram (shift too big) 47 * -1 if node overlap or lost ram (shift too big)
48 */ 48 */
49static int __init populate_memnodemap( 49static int __init
50 const struct node *nodes, int numnodes, int shift) 50populate_memnodemap(const struct node *nodes, int numnodes, int shift)
51{ 51{
52 int i; 52 int i;
53 int res = -1; 53 int res = -1;
@@ -81,7 +81,7 @@ int __init compute_hash_shift(struct node *nodes, int numnodes)
81 while (populate_memnodemap(nodes, numnodes, shift + 1) >= 0) 81 while (populate_memnodemap(nodes, numnodes, shift + 1) >= 0)
82 shift++; 82 shift++;
83 83
84 printk(KERN_DEBUG "Using %d for the hash shift.\n", 84 printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n",
85 shift); 85 shift);
86 86
87 if (populate_memnodemap(nodes, numnodes, shift) != 1) { 87 if (populate_memnodemap(nodes, numnodes, shift) != 1) {
@@ -110,7 +110,7 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
110 110
111 start = round_up(start, ZONE_ALIGN); 111 start = round_up(start, ZONE_ALIGN);
112 112
113 printk("Bootmem setup node %d %016lx-%016lx\n", nodeid, start, end); 113 printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid, start, end);
114 114
115 start_pfn = start >> PAGE_SHIFT; 115 start_pfn = start >> PAGE_SHIFT;
116 end_pfn = end >> PAGE_SHIFT; 116 end_pfn = end >> PAGE_SHIFT;
@@ -156,7 +156,7 @@ void __init setup_node_zones(int nodeid)
156 start_pfn = node_start_pfn(nodeid); 156 start_pfn = node_start_pfn(nodeid);
157 end_pfn = node_end_pfn(nodeid); 157 end_pfn = node_end_pfn(nodeid);
158 158
159 Dprintk(KERN_INFO "setting up node %d %lx-%lx\n", 159 Dprintk(KERN_INFO "Setting up node %d %lx-%lx\n",
160 nodeid, start_pfn, end_pfn); 160 nodeid, start_pfn, end_pfn);
161 161
162 size_zones(zones, holes, start_pfn, end_pfn); 162 size_zones(zones, holes, start_pfn, end_pfn);
@@ -200,7 +200,7 @@ static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
200 while ((x << 1) < sz) 200 while ((x << 1) < sz)
201 x <<= 1; 201 x <<= 1;
202 if (x < sz/2) 202 if (x < sz/2)
203 printk("Numa emulation unbalanced. Complain to maintainer\n"); 203 printk(KERN_ERR "Numa emulation unbalanced. Complain to maintainer\n");
204 sz = x; 204 sz = x;
205 } 205 }
206 206
@@ -272,7 +272,7 @@ __cpuinit void numa_add_cpu(int cpu)
272 272
273void __cpuinit numa_set_node(int cpu, int node) 273void __cpuinit numa_set_node(int cpu, int node)
274{ 274{
275 cpu_pda[cpu].nodenumber = node; 275 cpu_pda(cpu)->nodenumber = node;
276 cpu_to_node[cpu] = node; 276 cpu_to_node[cpu] = node;
277} 277}
278 278
@@ -330,8 +330,69 @@ __init int numa_setup(char *opt)
330 return 1; 330 return 1;
331} 331}
332 332
333/*
334 * Setup early cpu_to_node.
335 *
336 * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
337 * and apicid_to_node[] tables have valid entries for a CPU.
338 * This means we skip cpu_to_node[] initialisation for NUMA
339 * emulation and faking node case (when running a kernel compiled
340 * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
341 * is already initialized in a round robin manner at numa_init_array,
342 * prior to this call, and this initialization is good enough
343 * for the fake NUMA cases.
344 */
345void __init init_cpu_to_node(void)
346{
347 int i;
348 for (i = 0; i < NR_CPUS; i++) {
349 u8 apicid = x86_cpu_to_apicid[i];
350 if (apicid == BAD_APICID)
351 continue;
352 if (apicid_to_node[apicid] == NUMA_NO_NODE)
353 continue;
354 cpu_to_node[i] = apicid_to_node[apicid];
355 }
356}
357
333EXPORT_SYMBOL(cpu_to_node); 358EXPORT_SYMBOL(cpu_to_node);
334EXPORT_SYMBOL(node_to_cpumask); 359EXPORT_SYMBOL(node_to_cpumask);
335EXPORT_SYMBOL(memnode_shift); 360EXPORT_SYMBOL(memnode_shift);
336EXPORT_SYMBOL(memnodemap); 361EXPORT_SYMBOL(memnodemap);
337EXPORT_SYMBOL(node_data); 362EXPORT_SYMBOL(node_data);
363
364#ifdef CONFIG_DISCONTIGMEM
365/*
366 * Functions to convert PFNs from/to per node page addresses.
367 * These are out of line because they are quite big.
368 * They could be all tuned by pre caching more state.
369 * Should do that.
370 */
371
372/* Requires pfn_valid(pfn) to be true */
373struct page *pfn_to_page(unsigned long pfn)
374{
375 int nid = phys_to_nid(((unsigned long)(pfn)) << PAGE_SHIFT);
376 return (pfn - node_start_pfn(nid)) + NODE_DATA(nid)->node_mem_map;
377}
378EXPORT_SYMBOL(pfn_to_page);
379
380unsigned long page_to_pfn(struct page *page)
381{
382 return (long)(((page) - page_zone(page)->zone_mem_map) +
383 page_zone(page)->zone_start_pfn);
384}
385EXPORT_SYMBOL(page_to_pfn);
386
387int pfn_valid(unsigned long pfn)
388{
389 unsigned nid;
390 if (pfn >= num_physpages)
391 return 0;
392 nid = pfn_to_nid(pfn);
393 if (nid == 0xff)
394 return 0;
395 return pfn >= node_start_pfn(nid) && (pfn) < node_end_pfn(nid);
396}
397EXPORT_SYMBOL(pfn_valid);
398#endif
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 33340bd1e328..8b7f85608fa8 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -17,21 +17,23 @@
17#include <linux/topology.h> 17#include <linux/topology.h>
18#include <asm/proto.h> 18#include <asm/proto.h>
19#include <asm/numa.h> 19#include <asm/numa.h>
20#include <asm/e820.h>
20 21
21static struct acpi_table_slit *acpi_slit; 22static struct acpi_table_slit *acpi_slit;
22 23
23static nodemask_t nodes_parsed __initdata; 24static nodemask_t nodes_parsed __initdata;
24static nodemask_t nodes_found __initdata; 25static nodemask_t nodes_found __initdata;
25static struct node nodes[MAX_NUMNODES] __initdata; 26static struct node nodes[MAX_NUMNODES] __initdata;
26static __u8 pxm2node[256] = { [0 ... 255] = 0xff }; 27static u8 pxm2node[256] = { [0 ... 255] = 0xff };
27 28
28static int node_to_pxm(int n); 29static int node_to_pxm(int n);
29 30
30int pxm_to_node(int pxm) 31int pxm_to_node(int pxm)
31{ 32{
32 if ((unsigned)pxm >= 256) 33 if ((unsigned)pxm >= 256)
33 return 0; 34 return -1;
34 return pxm2node[pxm]; 35 /* Extend 0xff to (int)-1 */
36 return (signed char)pxm2node[pxm];
35} 37}
36 38
37static __init int setup_node(int pxm) 39static __init int setup_node(int pxm)
@@ -91,9 +93,36 @@ static __init inline int srat_disabled(void)
91 return numa_off || acpi_numa < 0; 93 return numa_off || acpi_numa < 0;
92} 94}
93 95
96/*
97 * A lot of BIOS fill in 10 (= no distance) everywhere. This messes
98 * up the NUMA heuristics which wants the local node to have a smaller
99 * distance than the others.
100 * Do some quick checks here and only use the SLIT if it passes.
101 */
102static __init int slit_valid(struct acpi_table_slit *slit)
103{
104 int i, j;
105 int d = slit->localities;
106 for (i = 0; i < d; i++) {
107 for (j = 0; j < d; j++) {
108 u8 val = slit->entry[d*i + j];
109 if (i == j) {
110 if (val != 10)
111 return 0;
112 } else if (val <= 10)
113 return 0;
114 }
115 }
116 return 1;
117}
118
94/* Callback for SLIT parsing */ 119/* Callback for SLIT parsing */
95void __init acpi_numa_slit_init(struct acpi_table_slit *slit) 120void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
96{ 121{
122 if (!slit_valid(slit)) {
123 printk(KERN_INFO "ACPI: SLIT table looks invalid. Not used.\n");
124 return;
125 }
97 acpi_slit = slit; 126 acpi_slit = slit;
98} 127}
99 128
@@ -168,12 +197,39 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
168 nd->start, nd->end); 197 nd->start, nd->end);
169} 198}
170 199
200/* Sanity check to catch more bad SRATs (they are amazingly common).
201 Make sure the PXMs cover all memory. */
202static int nodes_cover_memory(void)
203{
204 int i;
205 unsigned long pxmram, e820ram;
206
207 pxmram = 0;
208 for_each_node_mask(i, nodes_parsed) {
209 unsigned long s = nodes[i].start >> PAGE_SHIFT;
210 unsigned long e = nodes[i].end >> PAGE_SHIFT;
211 pxmram += e - s;
212 pxmram -= e820_hole_size(s, e);
213 }
214
215 e820ram = end_pfn - e820_hole_size(0, end_pfn);
216 if (pxmram < e820ram) {
217 printk(KERN_ERR
218 "SRAT: PXMs only cover %luMB of your %luMB e820 RAM. Not used.\n",
219 (pxmram << PAGE_SHIFT) >> 20,
220 (e820ram << PAGE_SHIFT) >> 20);
221 return 0;
222 }
223 return 1;
224}
225
171void __init acpi_numa_arch_fixup(void) {} 226void __init acpi_numa_arch_fixup(void) {}
172 227
173/* Use the information discovered above to actually set up the nodes. */ 228/* Use the information discovered above to actually set up the nodes. */
174int __init acpi_scan_nodes(unsigned long start, unsigned long end) 229int __init acpi_scan_nodes(unsigned long start, unsigned long end)
175{ 230{
176 int i; 231 int i;
232
177 if (acpi_numa <= 0) 233 if (acpi_numa <= 0)
178 return -1; 234 return -1;
179 235
@@ -184,6 +240,11 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
184 node_clear(i, nodes_parsed); 240 node_clear(i, nodes_parsed);
185 } 241 }
186 242
243 if (!nodes_cover_memory()) {
244 bad_srat();
245 return -1;
246 }
247
187 memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed)); 248 memnode_shift = compute_hash_shift(nodes, nodes_weight(nodes_parsed));
188 if (memnode_shift < 0) { 249 if (memnode_shift < 0) {
189 printk(KERN_ERR 250 printk(KERN_ERR
diff --git a/arch/x86_64/pci/Makefile-BUS b/arch/x86_64/pci/Makefile-BUS
deleted file mode 100644
index 4f0c05abd408..000000000000
--- a/arch/x86_64/pci/Makefile-BUS
+++ /dev/null
@@ -1,22 +0,0 @@
1#
2# Makefile for X86_64 specific PCI routines
3#
4# Reuse the i386 PCI subsystem
5#
6CFLAGS += -I arch/i386/pci
7
8obj-y := i386.o
9obj-$(CONFIG_PCI_DIRECT)+= direct.o
10obj-y += fixup.o
11obj-$(CONFIG_ACPI) += acpi.o
12obj-y += legacy.o irq.o common.o
13# mmconfig has a 64bit special
14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o
15
16direct-y += ../../i386/pci/direct.o
17acpi-y += ../../i386/pci/acpi.o
18legacy-y += ../../i386/pci/legacy.o
19irq-y += ../../i386/pci/irq.o
20common-y += ../../i386/pci/common.o
21fixup-y += ../../i386/pci/fixup.o
22i386-y += ../../i386/pci/i386.o
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 7e841aa2a4aa..7ee4a14ec3b1 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -18,10 +18,6 @@ config XTENSA
18 with reasonable minimum requirements. The Xtensa Linux project has 18 with reasonable minimum requirements. The Xtensa Linux project has
19 a home page at <http://xtensa.sourceforge.net/>. 19 a home page at <http://xtensa.sourceforge.net/>.
20 20
21config UID16
22 bool
23 default n
24
25config RWSEM_XCHGADD_ALGORITHM 21config RWSEM_XCHGADD_ALGORITHM
26 bool 22 bool
27 default y 23 default y
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index 6a44b54ae817..f1f596644bfc 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -145,7 +145,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
145 int user_mode = user_mode(regs); 145 int user_mode = user_mode(regs);
146 146
147 /* Set up new TSS. */ 147 /* Set up new TSS. */
148 tos = (unsigned long)p->thread_info + THREAD_SIZE; 148 tos = (unsigned long)task_stack_page(p) + THREAD_SIZE;
149 if (user_mode) 149 if (user_mode)
150 childregs = (struct pt_regs*)(tos - PT_USER_SIZE); 150 childregs = (struct pt_regs*)(tos - PT_USER_SIZE);
151 else 151 else
@@ -217,7 +217,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
217unsigned long get_wchan(struct task_struct *p) 217unsigned long get_wchan(struct task_struct *p)
218{ 218{
219 unsigned long sp, pc; 219 unsigned long sp, pc;
220 unsigned long stack_page = (unsigned long) p->thread_info; 220 unsigned long stack_page = (unsigned long) task_stack_page(p);
221 int count = 0; 221 int count = 0;
222 222
223 if (!p || p == current || p->state == TASK_RUNNING) 223 if (!p || p == current || p->state == TASK_RUNNING)
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index ab5c4c65b5c4..4cc85285a70a 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -72,7 +72,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
72 struct pt_regs *regs; 72 struct pt_regs *regs;
73 unsigned long tmp; 73 unsigned long tmp;
74 74
75 regs = xtensa_pt_regs(child); 75 regs = task_pt_regs(child);
76 tmp = 0; /* Default return value. */ 76 tmp = 0; /* Default return value. */
77 77
78 switch(addr) { 78 switch(addr) {
@@ -149,7 +149,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
149 case PTRACE_POKEUSR: 149 case PTRACE_POKEUSR:
150 { 150 {
151 struct pt_regs *regs; 151 struct pt_regs *regs;
152 regs = xtensa_pt_regs(child); 152 regs = task_pt_regs(child);
153 153
154 switch (addr) { 154 switch (addr) {
155 case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1: 155 case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1:
@@ -240,7 +240,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
240 * elf_gregset_t format. */ 240 * elf_gregset_t format. */
241 241
242 xtensa_gregset_t format; 242 xtensa_gregset_t format;
243 struct pt_regs *regs = xtensa_pt_regs(child); 243 struct pt_regs *regs = task_pt_regs(child);
244 244
245 do_copy_regs (&format, regs, child); 245 do_copy_regs (&format, regs, child);
246 246
@@ -257,7 +257,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
257 * values in the elf_gregset_t format. */ 257 * values in the elf_gregset_t format. */
258 258
259 xtensa_gregset_t format; 259 xtensa_gregset_t format;
260 struct pt_regs *regs = xtensa_pt_regs(child); 260 struct pt_regs *regs = task_pt_regs(child);
261 261
262 if (copy_from_user(&format,(void *)data,sizeof(elf_gregset_t))){ 262 if (copy_from_user(&format,(void *)data,sizeof(elf_gregset_t))){
263 ret = -EFAULT; 263 ret = -EFAULT;
@@ -281,7 +281,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
281 * elf_fpregset_t format. */ 281 * elf_fpregset_t format. */
282 282
283 elf_fpregset_t fpregs; 283 elf_fpregset_t fpregs;
284 struct pt_regs *regs = xtensa_pt_regs(child); 284 struct pt_regs *regs = task_pt_regs(child);
285 285
286 do_save_fpregs (&fpregs, regs, child); 286 do_save_fpregs (&fpregs, regs, child);
287 287
@@ -299,7 +299,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
299 * values in the elf_fpregset_t format. 299 * values in the elf_fpregset_t format.
300 */ 300 */
301 elf_fpregset_t fpregs; 301 elf_fpregset_t fpregs;
302 struct pt_regs *regs = xtensa_pt_regs(child); 302 struct pt_regs *regs = task_pt_regs(child);
303 303
304 ret = 0; 304 ret = 0;
305 if (copy_from_user(&fpregs, (void *)data, sizeof(elf_fpregset_t))) { 305 if (copy_from_user(&fpregs, (void *)data, sizeof(elf_fpregset_t))) {