- patches.kernel.org/patch-2.6.24-rc2: Official patch.
authorJeff Mahoney <jeffm@suse.de>
Wed, 7 Nov 2007 15:20:46 +0000 (15:20 +0000)
committerJeff Mahoney <jeffm@suse.de>
Wed, 7 Nov 2007 15:20:46 +0000 (15:20 +0000)
suse-commit: 027ffe2e870bd53a920b3c88f2e5e065ce3068a8

428 files changed:
.gitignore
Documentation/x86_64/mm.txt
arch/i386/boot/.gitignore [deleted file]
arch/i386/boot/compressed/.gitignore [deleted file]
arch/i386/boot/compressed/vmlinux.lds [deleted file]
arch/i386/boot/tools/.gitignore [deleted file]
arch/i386/kernel/.gitignore [deleted file]
arch/i386/math-emu/version.h [deleted file]
arch/ia64/scripts/check-segrel.lds
arch/powerpc/boot/.gitignore
arch/powerpc/kernel/vdso32/.gitignore
arch/powerpc/kernel/vdso64/.gitignore
arch/ppc/.gitignore
arch/um/Kconfig
arch/um/Kconfig.char
arch/um/Kconfig.debug
arch/um/Kconfig.i386
arch/um/Kconfig.net
arch/um/Kconfig.x86_64
arch/um/Makefile
arch/um/Makefile-i386
arch/um/Makefile-os-Linux
arch/um/Makefile-x86_64
arch/um/defconfig
arch/um/drivers/Makefile
arch/um/drivers/chan_kern.c
arch/um/drivers/chan_user.c
arch/um/drivers/cow_user.c
arch/um/drivers/daemon.h
arch/um/drivers/daemon_kern.c
arch/um/drivers/daemon_user.c
arch/um/drivers/fd.c
arch/um/drivers/harddog_kern.c
arch/um/drivers/harddog_user.c
arch/um/drivers/hostaudio_kern.c
arch/um/drivers/line.c
arch/um/drivers/mcast.h
arch/um/drivers/mcast_kern.c
arch/um/drivers/mcast_user.c
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mconsole_user.c
arch/um/drivers/mmapper_kern.c
arch/um/drivers/net_kern.c
arch/um/drivers/net_user.c
arch/um/drivers/null.c
arch/um/drivers/pcap_kern.c
arch/um/drivers/pcap_user.c
arch/um/drivers/port_kern.c
arch/um/drivers/port_user.c
arch/um/drivers/pty.c
arch/um/drivers/slip_kern.c
arch/um/drivers/slip_user.c
arch/um/drivers/slirp_kern.c
arch/um/drivers/slirp_user.c
arch/um/drivers/stderr_console.c
arch/um/drivers/tty.c
arch/um/drivers/ubd_kern.c
arch/um/drivers/vde.h [new file with mode: 0644]
arch/um/drivers/vde_kern.c [new file with mode: 0644]
arch/um/drivers/vde_user.c [new file with mode: 0644]
arch/um/drivers/xterm.c
arch/um/include/arch.h
arch/um/include/as-layout.h
arch/um/include/choose-mode.h [deleted file]
arch/um/include/common-offsets.h
arch/um/include/irq_user.h
arch/um/include/kern_util.h
arch/um/include/mconsole.h
arch/um/include/mem.h
arch/um/include/mode.h [deleted file]
arch/um/include/mode_kern.h [deleted file]
arch/um/include/net_kern.h
arch/um/include/net_user.h
arch/um/include/os.h
arch/um/include/registers.h
arch/um/include/skas/mmu-skas.h [deleted file]
arch/um/include/skas/mode-skas.h
arch/um/include/skas/mode_kern_skas.h [deleted file]
arch/um/include/skas/skas.h
arch/um/include/skas/uaccess-skas.h [deleted file]
arch/um/include/sysdep-i386/kernel-offsets.h
arch/um/include/sysdep-i386/ptrace.h
arch/um/include/sysdep-i386/sigcontext.h
arch/um/include/sysdep-i386/stub.h
arch/um/include/sysdep-i386/thread.h [deleted file]
arch/um/include/sysdep-x86_64/ptrace.h
arch/um/include/sysdep-x86_64/sigcontext.h
arch/um/include/sysdep-x86_64/stub.h
arch/um/include/sysdep-x86_64/thread.h [deleted file]
arch/um/include/task.h
arch/um/include/tlb.h
arch/um/include/tt/debug.h [deleted file]
arch/um/include/tt/mmu-tt.h [deleted file]
arch/um/include/tt/mode-tt.h [deleted file]
arch/um/include/tt/mode_kern_tt.h [deleted file]
arch/um/include/tt/tt.h [deleted file]
arch/um/include/tt/uaccess-tt.h [deleted file]
arch/um/include/um_mmu.h
arch/um/include/um_uaccess.h
arch/um/include/uml_uaccess.h [deleted file]
arch/um/include/user.h
arch/um/kernel/Makefile
arch/um/kernel/dyn.lds.S
arch/um/kernel/exec.c
arch/um/kernel/gmon_syms.c
arch/um/kernel/init_task.c
arch/um/kernel/irq.c
arch/um/kernel/ksyms.c
arch/um/kernel/mem.c
arch/um/kernel/physmem.c
arch/um/kernel/process.c
arch/um/kernel/ptrace.c
arch/um/kernel/reboot.c
arch/um/kernel/signal.c
arch/um/kernel/skas/Makefile
arch/um/kernel/skas/clone.c
arch/um/kernel/skas/exec.c [deleted file]
arch/um/kernel/skas/mem.c [deleted file]
arch/um/kernel/skas/mmu.c
arch/um/kernel/skas/process.c
arch/um/kernel/skas/syscall.c
arch/um/kernel/skas/tlb.c [deleted file]
arch/um/kernel/skas/uaccess.c
arch/um/kernel/smp.c
arch/um/kernel/syscall.c
arch/um/kernel/time.c
arch/um/kernel/tlb.c
arch/um/kernel/trap.c
arch/um/kernel/tt/Makefile [deleted file]
arch/um/kernel/tt/exec_kern.c [deleted file]
arch/um/kernel/tt/exec_user.c [deleted file]
arch/um/kernel/tt/gdb.c [deleted file]
arch/um/kernel/tt/gdb_kern.c [deleted file]
arch/um/kernel/tt/include/mode-tt.h [deleted file]
arch/um/kernel/tt/ksyms.c [deleted file]
arch/um/kernel/tt/mem.c [deleted file]
arch/um/kernel/tt/mem_user.c [deleted file]
arch/um/kernel/tt/process_kern.c [deleted file]
arch/um/kernel/tt/ptproxy/Makefile [deleted file]
arch/um/kernel/tt/ptproxy/proxy.c [deleted file]
arch/um/kernel/tt/ptproxy/ptproxy.h [deleted file]
arch/um/kernel/tt/ptproxy/ptrace.c [deleted file]
arch/um/kernel/tt/ptproxy/sysdep.c [deleted file]
arch/um/kernel/tt/ptproxy/sysdep.h [deleted file]
arch/um/kernel/tt/ptproxy/wait.c [deleted file]
arch/um/kernel/tt/ptproxy/wait.h [deleted file]
arch/um/kernel/tt/syscall_kern.c [deleted file]
arch/um/kernel/tt/syscall_user.c [deleted file]
arch/um/kernel/tt/tlb.c [deleted file]
arch/um/kernel/tt/tracer.c [deleted file]
arch/um/kernel/tt/trap_user.c [deleted file]
arch/um/kernel/tt/uaccess.c [deleted file]
arch/um/kernel/tt/uaccess_user.c [deleted file]
arch/um/kernel/uaccess.c
arch/um/kernel/um_arch.c
arch/um/kernel/uml.lds.S
arch/um/os-Linux/Makefile
arch/um/os-Linux/aio.c
arch/um/os-Linux/drivers/etap.h
arch/um/os-Linux/drivers/ethertap_kern.c
arch/um/os-Linux/drivers/ethertap_user.c
arch/um/os-Linux/drivers/tuntap.h
arch/um/os-Linux/drivers/tuntap_kern.c
arch/um/os-Linux/drivers/tuntap_user.c
arch/um/os-Linux/file.c
arch/um/os-Linux/helper.c
arch/um/os-Linux/irq.c
arch/um/os-Linux/main.c
arch/um/os-Linux/mem.c
arch/um/os-Linux/process.c
arch/um/os-Linux/registers.c [new file with mode: 0644]
arch/um/os-Linux/signal.c
arch/um/os-Linux/skas/mem.c
arch/um/os-Linux/skas/process.c
arch/um/os-Linux/skas/trap.c
arch/um/os-Linux/start_up.c
arch/um/os-Linux/sys-i386/Makefile
arch/um/os-Linux/sys-i386/registers.c
arch/um/os-Linux/sys-x86_64/Makefile
arch/um/os-Linux/sys-x86_64/registers.c
arch/um/os-Linux/time.c
arch/um/os-Linux/tls.c
arch/um/os-Linux/trap.c
arch/um/os-Linux/tt.c [deleted file]
arch/um/os-Linux/uaccess.c
arch/um/os-Linux/umid.c
arch/um/os-Linux/util.c
arch/um/scripts/Makefile.rules
arch/um/sys-i386/Makefile
arch/um/sys-i386/bug.c
arch/um/sys-i386/bugs.c
arch/um/sys-i386/fault.c
arch/um/sys-i386/ldt.c
arch/um/sys-i386/ptrace.c
arch/um/sys-i386/ptrace_user.c
arch/um/sys-i386/sigcontext.c [deleted file]
arch/um/sys-i386/signal.c
arch/um/sys-i386/stub.S
arch/um/sys-i386/stub_segv.c
arch/um/sys-i386/sys_call_table.S
arch/um/sys-i386/syscalls.c
arch/um/sys-i386/tls.c
arch/um/sys-i386/unmap.c [deleted file]
arch/um/sys-i386/user-offsets.c
arch/um/sys-ppc/Makefile
arch/um/sys-x86_64/Makefile
arch/um/sys-x86_64/bug.c
arch/um/sys-x86_64/bugs.c
arch/um/sys-x86_64/fault.c
arch/um/sys-x86_64/ptrace.c
arch/um/sys-x86_64/sigcontext.c [deleted file]
arch/um/sys-x86_64/signal.c
arch/um/sys-x86_64/stub.S
arch/um/sys-x86_64/stub_segv.c
arch/um/sys-x86_64/syscall_table.c
arch/um/sys-x86_64/syscalls.c
arch/um/sys-x86_64/sysrq.c
arch/um/sys-x86_64/tls.c
arch/um/sys-x86_64/unmap.c [deleted file]
arch/um/sys-x86_64/user-offsets.c
arch/x86/boot/.gitignore [new file with mode: 0644]
arch/x86/boot/compressed/.gitignore [new file with mode: 0644]
arch/x86/boot/tools/.gitignore [new file with mode: 0644]
arch/x86/ia32/vsyscall.lds [new file with mode: 0644]
arch/x86/kernel/.gitignore [new file with mode: 0644]
arch/x86/math-emu/version.h [new file with mode: 0644]
arch/x86/vdso/.gitignore [new file with mode: 0644]
arch/x86_64/Kconfig [deleted file]
arch/x86_64/Kconfig.debug [deleted file]
arch/x86_64/Makefile [deleted file]
arch/x86_64/boot/.gitignore [deleted file]
arch/x86_64/boot/Makefile [deleted file]
arch/x86_64/boot/compressed/Makefile [deleted file]
arch/x86_64/boot/compressed/head.S [deleted file]
arch/x86_64/boot/compressed/misc.c [deleted file]
arch/x86_64/boot/compressed/vmlinux.lds [deleted file]
arch/x86_64/boot/compressed/vmlinux.scr [deleted file]
arch/x86_64/boot/tools/.gitignore [deleted file]
arch/x86_64/crypto/Makefile [deleted file]
arch/x86_64/crypto/aes-x86_64-asm.S [deleted file]
arch/x86_64/crypto/aes.c [deleted file]
arch/x86_64/crypto/twofish-x86_64-asm.S [deleted file]
arch/x86_64/crypto/twofish.c [deleted file]
arch/x86_64/defconfig [deleted file]
arch/x86_64/ia32/Makefile [deleted file]
arch/x86_64/ia32/audit.c [deleted file]
arch/x86_64/ia32/fpu32.c [deleted file]
arch/x86_64/ia32/ia32_aout.c [deleted file]
arch/x86_64/ia32/ia32_binfmt.c [deleted file]
arch/x86_64/ia32/ia32_signal.c [deleted file]
arch/x86_64/ia32/ia32entry.S [deleted file]
arch/x86_64/ia32/ipc32.c [deleted file]
arch/x86_64/ia32/mmap32.c [deleted file]
arch/x86_64/ia32/ptrace32.c [deleted file]
arch/x86_64/ia32/sys_ia32.c [deleted file]
arch/x86_64/ia32/syscall32.c [deleted file]
arch/x86_64/ia32/syscall32_syscall.S [deleted file]
arch/x86_64/ia32/tls32.c [deleted file]
arch/x86_64/ia32/vsyscall-sigreturn.S [deleted file]
arch/x86_64/ia32/vsyscall-syscall.S [deleted file]
arch/x86_64/ia32/vsyscall-sysenter.S [deleted file]
arch/x86_64/ia32/vsyscall.lds [deleted file]
arch/x86_64/kernel/Makefile [deleted file]
arch/x86_64/kernel/acpi/Makefile [deleted file]
arch/x86_64/kernel/acpi/sleep.c [deleted file]
arch/x86_64/kernel/acpi/wakeup.S [deleted file]
arch/x86_64/kernel/aperture.c [deleted file]
arch/x86_64/kernel/apic.c [deleted file]
arch/x86_64/kernel/asm-offsets.c [deleted file]
arch/x86_64/kernel/audit.c [deleted file]
arch/x86_64/kernel/bugs.c [deleted file]
arch/x86_64/kernel/cpufreq/Kconfig [deleted file]
arch/x86_64/kernel/cpufreq/Makefile [deleted file]
arch/x86_64/kernel/crash.c [deleted file]
arch/x86_64/kernel/crash_dump.c [deleted file]
arch/x86_64/kernel/e820.c [deleted file]
arch/x86_64/kernel/early-quirks.c [deleted file]
arch/x86_64/kernel/early_printk.c [deleted file]
arch/x86_64/kernel/entry.S [deleted file]
arch/x86_64/kernel/genapic.c [deleted file]
arch/x86_64/kernel/genapic_flat.c [deleted file]
arch/x86_64/kernel/head.S [deleted file]
arch/x86_64/kernel/head64.c [deleted file]
arch/x86_64/kernel/hpet.c [deleted file]
arch/x86_64/kernel/i387.c [deleted file]
arch/x86_64/kernel/i8259.c [deleted file]
arch/x86_64/kernel/init_task.c [deleted file]
arch/x86_64/kernel/io_apic.c [deleted file]
arch/x86_64/kernel/ioport.c [deleted file]
arch/x86_64/kernel/irq.c [deleted file]
arch/x86_64/kernel/k8.c [deleted file]
arch/x86_64/kernel/kprobes.c [deleted file]
arch/x86_64/kernel/ldt.c [deleted file]
arch/x86_64/kernel/machine_kexec.c [deleted file]
arch/x86_64/kernel/mce.c [deleted file]
arch/x86_64/kernel/mce_amd.c [deleted file]
arch/x86_64/kernel/mce_intel.c [deleted file]
arch/x86_64/kernel/module.c [deleted file]
arch/x86_64/kernel/mpparse.c [deleted file]
arch/x86_64/kernel/nmi.c [deleted file]
arch/x86_64/kernel/pci-calgary.c [deleted file]
arch/x86_64/kernel/pci-dma.c [deleted file]
arch/x86_64/kernel/pci-gart.c [deleted file]
arch/x86_64/kernel/pci-nommu.c [deleted file]
arch/x86_64/kernel/pci-swiotlb.c [deleted file]
arch/x86_64/kernel/pmtimer.c [deleted file]
arch/x86_64/kernel/process.c [deleted file]
arch/x86_64/kernel/ptrace.c [deleted file]
arch/x86_64/kernel/reboot.c [deleted file]
arch/x86_64/kernel/relocate_kernel.S [deleted file]
arch/x86_64/kernel/setup.c [deleted file]
arch/x86_64/kernel/setup64.c [deleted file]
arch/x86_64/kernel/signal.c [deleted file]
arch/x86_64/kernel/smp.c [deleted file]
arch/x86_64/kernel/smpboot.c [deleted file]
arch/x86_64/kernel/stacktrace.c [deleted file]
arch/x86_64/kernel/suspend.c [deleted file]
arch/x86_64/kernel/suspend_asm.S [deleted file]
arch/x86_64/kernel/sys_x86_64.c [deleted file]
arch/x86_64/kernel/syscall.c [deleted file]
arch/x86_64/kernel/tce.c [deleted file]
arch/x86_64/kernel/time.c [deleted file]
arch/x86_64/kernel/trampoline.S [deleted file]
arch/x86_64/kernel/traps.c [deleted file]
arch/x86_64/kernel/tsc.c [deleted file]
arch/x86_64/kernel/tsc_sync.c [deleted file]
arch/x86_64/kernel/verify_cpu.S [deleted file]
arch/x86_64/kernel/vmlinux.lds.S [deleted file]
arch/x86_64/kernel/vsmp.c [deleted file]
arch/x86_64/kernel/vsyscall.c [deleted file]
arch/x86_64/kernel/x8664_ksyms.c [deleted file]
arch/x86_64/lib/Makefile [deleted file]
arch/x86_64/lib/bitops.c [deleted file]
arch/x86_64/lib/bitstr.c [deleted file]
arch/x86_64/lib/clear_page.S [deleted file]
arch/x86_64/lib/copy_page.S [deleted file]
arch/x86_64/lib/copy_user.S [deleted file]
arch/x86_64/lib/copy_user_nocache.S [deleted file]
arch/x86_64/lib/csum-copy.S [deleted file]
arch/x86_64/lib/csum-partial.c [deleted file]
arch/x86_64/lib/csum-wrappers.c [deleted file]
arch/x86_64/lib/delay.c [deleted file]
arch/x86_64/lib/getuser.S [deleted file]
arch/x86_64/lib/io.c [deleted file]
arch/x86_64/lib/iomap_copy.S [deleted file]
arch/x86_64/lib/memcpy.S [deleted file]
arch/x86_64/lib/memmove.c [deleted file]
arch/x86_64/lib/memset.S [deleted file]
arch/x86_64/lib/msr-on-cpu.c [deleted file]
arch/x86_64/lib/putuser.S [deleted file]
arch/x86_64/lib/rwlock.S [deleted file]
arch/x86_64/lib/thunk.S [deleted file]
arch/x86_64/lib/usercopy.c [deleted file]
arch/x86_64/mm/Makefile [deleted file]
arch/x86_64/mm/extable.c [deleted file]
arch/x86_64/mm/fault.c [deleted file]
arch/x86_64/mm/init.c [deleted file]
arch/x86_64/mm/ioremap.c [deleted file]
arch/x86_64/mm/k8topology.c [deleted file]
arch/x86_64/mm/mmap.c [deleted file]
arch/x86_64/mm/numa.c [deleted file]
arch/x86_64/mm/pageattr.c [deleted file]
arch/x86_64/mm/srat.c [deleted file]
arch/x86_64/oprofile/Kconfig [deleted file]
arch/x86_64/oprofile/Makefile [deleted file]
arch/x86_64/pci/Makefile [deleted file]
arch/x86_64/pci/k8-bus.c [deleted file]
arch/x86_64/pci/mmconfig.c [deleted file]
arch/x86_64/vdso/.gitignore [deleted file]
arch/x86_64/vdso/Makefile [deleted file]
arch/x86_64/vdso/vclock_gettime.c [deleted file]
arch/x86_64/vdso/vdso-note.S [deleted file]
arch/x86_64/vdso/vdso-start.S [deleted file]
arch/x86_64/vdso/vdso.S [deleted file]
arch/x86_64/vdso/vdso.lds.S [deleted file]
arch/x86_64/vdso/vextern.h [deleted file]
arch/x86_64/vdso/vgetcpu.c [deleted file]
arch/x86_64/vdso/vma.c [deleted file]
arch/x86_64/vdso/voffset.h [deleted file]
arch/x86_64/vdso/vvar.c [deleted file]
drivers/net/cxgb3/version.h
drivers/s390/char/defkeymap.c
drivers/scsi/aic7xxx/aic7xxx_osm.c
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
drivers/scsi/aic7xxx/aic7xxx_pci.c
drivers/scsi/aic7xxx_old.c
drivers/tc/.gitignore [deleted file]
include/asm-um/a.out.h
include/asm-um/alternative-asm.h [new file with mode: 0644]
include/asm-um/alternative-asm.i [deleted file]
include/asm-um/bitops.h
include/asm-um/elf-i386.h
include/asm-um/elf-x86_64.h
include/asm-um/frame.h [new file with mode: 0644]
include/asm-um/frame.i [deleted file]
include/asm-um/ipc.h [deleted file]
include/asm-um/ldt.h
include/asm-um/mmu_context.h
include/asm-um/page.h
include/asm-um/pgalloc.h
include/asm-um/pgtable-3level.h
include/asm-um/processor-generic.h
include/asm-um/processor-x86_64.h
include/asm-um/ptrace-generic.h
include/asm-um/ptrace-i386.h
include/asm-um/ptrace-x86_64.h
include/asm-um/smp.h
include/asm-um/tlbflush.h
include/asm-um/uaccess.h
include/asm-um/unistd.h
include/sound/version.h
scripts/genksyms/Makefile
scripts/genksyms/keywords.c_shipped
scripts/genksyms/keywords.gperf
scripts/genksyms/lex.c_shipped
scripts/genksyms/parse.c_shipped
scripts/genksyms/parse.h_shipped
scripts/genksyms/parse.y
scripts/kconfig/Makefile
scripts/kconfig/check.sh [new file with mode: 0644]
scripts/kconfig/lex.zconf.c_shipped
scripts/kconfig/mconf.c
scripts/kconfig/qconf.cc
scripts/kconfig/util.c
scripts/kconfig/zconf.gperf
scripts/kconfig/zconf.hash.c_shipped
scripts/kconfig/zconf.tab.c_shipped
scripts/kconfig/zconf.y

index 27c3e83..8d14531 100644 (file)
@@ -12,6 +12,7 @@
 *.s
 *.ko
 *.so
+*.so.dbg
 *.mod.c
 *.i
 *.lst
@@ -26,6 +27,7 @@ vmlinux*
 !vmlinux.lds.S
 System.map
 Module.symvers
+!.gitignore
 
 #
 # Generated include files
index f42798e..b89b6d2 100644 (file)
@@ -9,6 +9,7 @@ ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole
 ffff810000000000 - ffffc0ffffffffff (=46 bits) direct mapping of all phys. memory
 ffffc10000000000 - ffffc1ffffffffff (=40 bits) hole
 ffffc20000000000 - ffffe1ffffffffff (=45 bits) vmalloc/ioremap space
+ffffe20000000000 - ffffe2ffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffff82800000 (=40 MB)   kernel text mapping, from phys 0
 ... unused hole ...
diff --git a/arch/i386/boot/.gitignore b/arch/i386/boot/.gitignore
deleted file mode 100644 (file)
index 1846514..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-bootsect
-bzImage
-setup
-setup.bin
-setup.elf
diff --git a/arch/i386/boot/compressed/.gitignore b/arch/i386/boot/compressed/.gitignore
deleted file mode 100644 (file)
index be0ed06..0000000
+++ /dev/null
@@ -1 +0,0 @@
-relocs
diff --git a/arch/i386/boot/compressed/vmlinux.lds b/arch/i386/boot/compressed/vmlinux.lds
deleted file mode 100644 (file)
index cc4854f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(startup_32)
-SECTIONS
-{
-        /* Be careful parts of head.S assume startup_32 is at
-         * address 0.
-        */
-       . =  0  ;
-       .text.head : {
-               _head = . ;
-               *(.text.head)
-               _ehead = . ;
-       }
-       .data.compressed : {
-               *(.data.compressed)
-       }
-       .text : {
-               _text = .;      /* Text */
-               *(.text)
-               *(.text.*)
-               _etext = . ;
-       }
-       .rodata : {
-               _rodata = . ;
-               *(.rodata)       /* read-only data */
-               *(.rodata.*)
-               _erodata = . ;
-       }
-       .data : {
-               _data = . ;
-               *(.data)
-               *(.data.*)
-               _edata = . ;
-       }
-       .bss : {
-               _bss = . ;
-               *(.bss)
-               *(.bss.*)
-               *(COMMON)
-               _end = . ;
-       }
-}
diff --git a/arch/i386/boot/tools/.gitignore b/arch/i386/boot/tools/.gitignore
deleted file mode 100644 (file)
index 378eac2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/arch/i386/kernel/.gitignore b/arch/i386/kernel/.gitignore
deleted file mode 100644 (file)
index 40836ad..0000000
+++ /dev/null
@@ -1 +0,0 @@
-vsyscall.lds
diff --git a/arch/i386/math-emu/version.h b/arch/i386/math-emu/version.h
deleted file mode 100644 (file)
index a0d73a1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*---------------------------------------------------------------------------+
- |  version.h                                                                |
- |                                                                           |
- |                                                                           |
- | Copyright (C) 1992,1993,1994,1996,1997,1999                               |
- |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
- |                  E-mail   billm@melbpc.org.au                             |
- |                                                                           |
- |                                                                           |
- +---------------------------------------------------------------------------*/
-
-#define FPU_VERSION "wm-FPU-emu version 2.01"
index 1c2f13e..85a0d54 100644 (file)
@@ -1,6 +1,7 @@
 SECTIONS {
        . = SIZEOF_HEADERS;
        .rodata : { *(.rodata) } :ro
+       .note : { *(.note*) }
        . = 0xa0000;
        .data : { *(.data) } :dat
        /DISCARD/ : { *(*) }
index eec7af7..65f4118 100644 (file)
@@ -18,14 +18,15 @@ kernel-vmlinux.strip.c
 kernel-vmlinux.strip.gz
 mktree
 uImage
-cuImage
-cuImage.bin.gz
-cuImage.elf
+cuImage.*
+treeImage.*
 zImage
+zImage.bin.*
 zImage.chrp
 zImage.coff
 zImage.coff.lds
-zImage.lds
+zImage.ep*
+zImage.*lds
 zImage.miboot
 zImage.pmac
 zImage.pseries
index a1a869c..1e79a0a 100644 (file)
@@ -1 +1 @@
-include
+/include
index e6ff302..dd1689b 100644 (file)
@@ -3,7 +3,7 @@ config DEFCONFIG_LIST
        option defconfig_list
        default "arch/$ARCH/defconfig"
 
-# UML uses the generic IRQ sugsystem
+# UML uses the generic IRQ subsystem
 config GENERIC_HARDIRQS
        bool
        default y
@@ -55,6 +55,14 @@ config GENERIC_BUG
        default y
        depends on BUG
 
+config GENERIC_TIME
+       bool
+       default y
+
+config GENERIC_CLOCKEVENTS
+       bool
+       default y
+
 # Used in kernel/irq/manage.c and include/linux/irq.h
 config IRQ_RELEASE_METHOD
        bool
@@ -62,63 +70,25 @@ config IRQ_RELEASE_METHOD
 
 menu "UML-specific options"
 
-config MODE_TT
-       bool "Tracing thread support (DEPRECATED)"
-       default n
-       depends on BROKEN
-       help
-       This option controls whether tracing thread support is compiled
-       into UML. This option is largely obsolete, given that skas0 provides
-       skas security and performance without needing to patch the host.
-       It is safe to say 'N' here; saying 'Y' may cause additional problems
-       with the resulting binary even if you run UML in SKAS mode, and running
-       in TT mode is strongly *NOT RECOMMENDED*.
-
 config STATIC_LINK
        bool "Force a static link"
        default n
-       depends on !MODE_TT
        help
-       If CONFIG_MODE_TT is disabled, then this option gives you the ability
-       to force a static link of UML.  Normally, if only skas mode is built
-       in to UML, it will be linked as a shared binary.  This is inconvenient
-       for use in a chroot jail.  So, if you intend to run UML inside a
-       chroot, and you disable CONFIG_MODE_TT, you probably want to say Y
-       here.
-       Additionally, this option enables using higher memory spaces (up to
-       2.75G) for UML - disabling CONFIG_MODE_TT and enabling this option leads
-       to best results for this.
-
-config KERNEL_HALF_GIGS
-       int "Kernel address space size (in .5G units)"
-       default "1"
-       depends on MODE_TT
-       help
-        This determines the amount of address space that UML will allocate for
-        its own, measured in half Gigabyte units.  The default is 1.
-        Change this only if you need to boot UML with an unusually large amount
-        of physical memory.
-
-config MODE_SKAS
-       bool "Separate Kernel Address Space support" if MODE_TT
-       default y
-       help
-       This option controls whether skas (separate kernel address space)
-       support is compiled in.
-       Unless you have specific needs to use TT mode (which applies almost only
-       to developers), you should say Y here.
-       SKAS mode will make use of the SKAS3 patch if it is applied on the host
-       (and your UML will run in SKAS3 mode), but if no SKAS patch is applied
-       on the host it will run in SKAS0 mode, which is anyway faster than TT
-       mode.
+         This option gives you the ability to force a static link of UML.
+         Normally, UML is linked as a shared binary.  This is inconvenient for
+         use in a chroot jail.  So, if you intend to run UML inside a chroot,
+         you probably want to say Y here.
+         Additionally, this option enables using higher memory spaces (up to
+         2.75G) for UML.
 
 source "arch/um/Kconfig.arch"
 source "mm/Kconfig"
+source "kernel/time/Kconfig"
 
 config LD_SCRIPT_STATIC
        bool
        default y
-       depends on MODE_TT || STATIC_LINK
+       depends on STATIC_LINK
 
 config LD_SCRIPT_DYN
        bool
@@ -128,18 +98,18 @@ config LD_SCRIPT_DYN
 config NET
        bool "Networking support"
        help
-       Unless you really know what you are doing, you should say Y here.
-       The reason is that some programs need kernel networking support even
-       when running on a stand-alone machine that isn't connected to any
-       other computer. If you are upgrading from an older kernel, you
-       should consider updating your networking tools too because changes
-       in the kernel and the tools often go hand in hand. The tools are
-       contained in the package net-tools, the location and version number
-       of which are given in <file:Documentation/Changes>.
+         Unless you really know what you are doing, you should say Y here.
+         The reason is that some programs need kernel networking support even
+         when running on a stand-alone machine that isn't connected to any
+         other computer. If you are upgrading from an older kernel, you
+         should consider updating your networking tools too because changes
+         in the kernel and the tools often go hand in hand. The tools are
+         contained in the package net-tools, the location and version number
+         of which are given in <file:Documentation/Changes>.
 
-       For a general introduction to Linux networking, it is highly
-       recommended to read the NET-HOWTO, available from
-       <http://www.tldp.org/docs.html#howto>.
+         For a general introduction to Linux networking, it is highly
+         recommended to read the NET-HOWTO, available from
+         <http://www.tldp.org/docs.html#howto>.
 
 
 source "fs/Kconfig.binfmt"
@@ -147,99 +117,99 @@ source "fs/Kconfig.binfmt"
 config HOSTFS
        tristate "Host filesystem"
        help
-        While the User-Mode Linux port uses its own root file system for
-        booting and normal file access, this module lets the UML user
-        access files stored on the host.  It does not require any
-        network connection between the Host and UML.  An example use of
-        this might be:
+          While the User-Mode Linux port uses its own root file system for
+          booting and normal file access, this module lets the UML user
+          access files stored on the host.  It does not require any
+          network connection between the Host and UML.  An example use of
+          this might be:
 
-        mount none /tmp/fromhost -t hostfs -o /tmp/umlshare
+          mount none /tmp/fromhost -t hostfs -o /tmp/umlshare
 
-        where /tmp/fromhost is an empty directory inside UML and
-        /tmp/umlshare is a directory on the host with files the UML user
-        wishes to access.
+          where /tmp/fromhost is an empty directory inside UML and
+          /tmp/umlshare is a directory on the host with files the UML user
+          wishes to access.
 
-        For more information, see
-        <http://user-mode-linux.sourceforge.net/hostfs.html>.
+          For more information, see
+          <http://user-mode-linux.sourceforge.net/hostfs.html>.
 
-        If you'd like to be able to work with files stored on the host,
-        say Y or M here; otherwise say N.
+          If you'd like to be able to work with files stored on the host,
+          say Y or M here; otherwise say N.
 
 config HPPFS
        tristate "HoneyPot ProcFS (EXPERIMENTAL)"
        depends on EXPERIMENTAL
        help
-       hppfs (HoneyPot ProcFS) is a filesystem which allows UML /proc
-       entries to be overridden, removed, or fabricated from the host.
-       Its purpose is to allow a UML to appear to be a physical machine
-       by removing or changing anything in /proc which gives away the
-       identity of a UML.
+         hppfs (HoneyPot ProcFS) is a filesystem which allows UML /proc
+         entries to be overridden, removed, or fabricated from the host.
+         Its purpose is to allow a UML to appear to be a physical machine
+         by removing or changing anything in /proc which gives away the
+         identity of a UML.
 
-       See <http://user-mode-linux.sf.net/hppfs.html> for more information.
+         See <http://user-mode-linux.sf.net/hppfs.html> for more information.
 
-       You only need this if you are setting up a UML honeypot.  Otherwise,
-       it is safe to say 'N' here.
+         You only need this if you are setting up a UML honeypot.  Otherwise,
+         it is safe to say 'N' here.
 
 config MCONSOLE
        bool "Management console"
        default y
        help
-        The user mode linux management console is a low-level interface to
-        the kernel, somewhat like the i386 SysRq interface.  Since there is
-        a full-blown operating system running under every user mode linux
-        instance, there is much greater flexibility possible than with the
-        SysRq mechanism.
+          The user mode linux management console is a low-level interface to
+          the kernel, somewhat like the i386 SysRq interface.  Since there is
+          a full-blown operating system running under every user mode linux
+          instance, there is much greater flexibility possible than with the
+          SysRq mechanism.
 
-        If you answer 'Y' to this option, to use this feature, you need the
-        mconsole client (called uml_mconsole) which is present in CVS in
-        2.4.5-9um and later (path /tools/mconsole), and is also in the
-        distribution RPM package in 2.4.6 and later.
+          If you answer 'Y' to this option, to use this feature, you need the
+          mconsole client (called uml_mconsole) which is present in CVS in
+          2.4.5-9um and later (path /tools/mconsole), and is also in the
+          distribution RPM package in 2.4.6 and later.
 
-        It is safe to say 'Y' here.
+          It is safe to say 'Y' here.
 
 config MAGIC_SYSRQ
        bool "Magic SysRq key"
        depends on MCONSOLE
-       ---help---
-       If you say Y here, you will have some control over the system even
-       if the system crashes for example during kernel debugging (e.g., you
-       will be able to flush the buffer cache to disk, reboot the system
-       immediately or dump some status information). A key for each of the
-       possible requests is provided.
+       help
+         If you say Y here, you will have some control over the system even
+         if the system crashes for example during kernel debugging (e.g., you
+         will be able to flush the buffer cache to disk, reboot the system
+         immediately or dump some status information). A key for each of the
+         possible requests is provided.
 
-       This is the feature normally accomplished by pressing a key
-       while holding SysRq (Alt+PrintScreen).
+         This is the feature normally accomplished by pressing a key
+         while holding SysRq (Alt+PrintScreen).
 
-       On UML, this is accomplished by sending a "sysrq" command with
-       mconsole, followed by the letter for the requested command.
+         On UML, this is accomplished by sending a "sysrq" command with
+         mconsole, followed by the letter for the requested command.
 
-       The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
-       unless you really know what this hack does.
+         The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
+         unless you really know what this hack does.
 
 config SMP
        bool "Symmetric multi-processing support (EXPERIMENTAL)"
        default n
        #SMP_BROKEN is for x86_64.
-       depends on MODE_TT && EXPERIMENTAL && (!SMP_BROKEN || (BROKEN && SMP_BROKEN))
+       depends on EXPERIMENTAL && (!SMP_BROKEN || (BROKEN && SMP_BROKEN))
        help
-       This option enables UML SMP support.
-       It is NOT related to having a real SMP box. Not directly, at least.
+         This option enables UML SMP support.
+         It is NOT related to having a real SMP box. Not directly, at least.
 
-       UML implements virtual SMP by allowing as many processes to run
-       simultaneously on the host as there are virtual processors configured.
+         UML implements virtual SMP by allowing as many processes to run
+         simultaneously on the host as there are virtual processors configured.
 
-       Obviously, if the host is a uniprocessor, those processes will
-       timeshare, but, inside UML, will appear to be running simultaneously.
-       If the host is a multiprocessor, then UML processes may run
-       simultaneously, depending on the host scheduler.
+         Obviously, if the host is a uniprocessor, those processes will
+         timeshare, but, inside UML, will appear to be running simultaneously.
+         If the host is a multiprocessor, then UML processes may run
+         simultaneously, depending on the host scheduler.
 
-       This, however, is supported only in TT mode. So, if you use the SKAS
-       patch on your host, switching to TT mode and enabling SMP usually gives
-       you worse performances.
-       Also, since the support for SMP has been under-developed, there could
-       be some bugs being exposed by enabling SMP.
+         This, however, is supported only in TT mode. So, if you use the SKAS
+         patch on your host, switching to TT mode and enabling SMP usually
+         gives you worse performances.
+         Also, since the support for SMP has been under-developed, there could
+         be some bugs being exposed by enabling SMP.
 
-       If you don't know what to do, say N.
+         If you don't know what to do, say N.
 
 config NR_CPUS
        int "Maximum number of CPUs (2-32)"
@@ -251,29 +221,24 @@ config NEST_LEVEL
        int "Nesting level"
        default "0"
        help
-        This is set to the number of layers of UMLs that this UML will be run
-        in.  Normally, this is zero, meaning that it will run directly on the
-        host.  Setting it to one will build a UML that can run inside a UML
-        that is running on the host.  Generally, if you intend this UML to run
-        inside another UML, set CONFIG_NEST_LEVEL to one more than the host
-        UML.
-
-        Note that if the hosting UML has its CONFIG_KERNEL_HALF_GIGS set to
-        greater than one, then the guest UML should have its CONFIG_NEST_LEVEL
-        set to the host's CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS.
-        Only change this if you are running nested UMLs.
+          This is set to the number of layers of UMLs that this UML will be run
+          in.  Normally, this is zero, meaning that it will run directly on the
+          host.  Setting it to one will build a UML that can run inside a UML
+          that is running on the host.  Generally, if you intend this UML to run
+          inside another UML, set CONFIG_NEST_LEVEL to one more than the host
+          UML.
 
 config HIGHMEM
        bool "Highmem support (EXPERIMENTAL)"
        depends on !64BIT && EXPERIMENTAL
        default n
        help
-       This was used to allow UML to run with big amounts of memory.
-       Currently it is unstable, so if unsure say N.
+         This was used to allow UML to run with big amounts of memory.
+         Currently it is unstable, so if unsure say N.
 
-       To use big amounts of memory, it is recommended to disable TT mode (i.e.
-       CONFIG_MODE_TT) and enable static linking (i.e. CONFIG_STATIC_LINK) -
-       this should allow the guest to use up to 2.75G of memory.
+         To use big amounts of memory, it is recommended enable static
+         linking (i.e. CONFIG_STATIC_LINK) - this should allow the
+         guest to use up to 2.75G of memory.
 
 config KERNEL_STACK_ORDER
        int "Kernel stack size order"
@@ -281,20 +246,9 @@ config KERNEL_STACK_ORDER
        range 1 10 if 64BIT
        default 0 if !64BIT
        help
-       This option determines the size of UML kernel stacks.  They will
-       be 1 << order pages.  The default is OK unless you're running Valgrind
-       on UML, in which case, set this to 3.
-
-config UML_REAL_TIME_CLOCK
-       bool "Real-time Clock"
-       default y
-       help
-       This option makes UML time deltas match wall clock deltas.  This should
-       normally be enabled.  The exception would be if you are debugging with
-       UML and spend long times with UML stopped at a breakpoint.  In this
-       case, when UML is restarted, it will call the timer enough times to make
-       up for the time spent at the breakpoint.  This could result in a
-       noticeable lag.  If this is a problem, then disable this option.
+         This option determines the size of UML kernel stacks.  They will
+         be 1 << order pages.  The default is OK unless you're running Valgrind
+         on UML, in which case, set this to 3.
 
 endmenu
 
@@ -335,4 +289,6 @@ config INPUT
        bool
        default n
 
+source "kernel/Kconfig.instrumentation"
+
 source "arch/um/Kconfig.debug"
index a5b079d..9a78d35 100644 (file)
@@ -5,7 +5,7 @@ config STDERR_CONSOLE
        bool "stderr console"
        default y
        help
-       console driver which dumps all printk messages to stderr.
+         console driver which dumps all printk messages to stderr.
 
 config STDIO_CONSOLE
        bool
@@ -14,60 +14,58 @@ config STDIO_CONSOLE
 config SSL
        bool "Virtual serial line"
        help
-        The User-Mode Linux environment allows you to create virtual serial
-        lines on the UML that are usually made to show up on the host as
-        ttys or ptys.
+          The User-Mode Linux environment allows you to create virtual serial
+          lines on the UML that are usually made to show up on the host as
+          ttys or ptys.
 
-        See <http://user-mode-linux.sourceforge.net/input.html> for more
-        information and command line examples of how to use this facility.
+          See <http://user-mode-linux.sourceforge.net/input.html> for more
+          information and command line examples of how to use this facility.
 
-        Unless you have a specific reason for disabling this, say Y.
+          Unless you have a specific reason for disabling this, say Y.
 
 config NULL_CHAN
        bool "null channel support"
        help
-        This option enables support for attaching UML consoles and serial
-        lines to a device similar to /dev/null.  Data written to it disappears
-        and there is never any data to be read.
+          This option enables support for attaching UML consoles and serial
+          lines to a device similar to /dev/null.  Data written to it disappears
+          and there is never any data to be read.
 
 config PORT_CHAN
        bool "port channel support"
        help
-        This option enables support for attaching UML consoles and serial
-        lines to host portals.  They may be accessed with 'telnet <host>
-        <port number>'.  Any number of consoles and serial lines may be
-        attached to a single portal, although what UML device you get when
-        you telnet to that portal will be unpredictable.
-        It is safe to say 'Y' here.
+          This option enables support for attaching UML consoles and serial
+          lines to host portals.  They may be accessed with 'telnet <host>
+          <port number>'.  Any number of consoles and serial lines may be
+          attached to a single portal, although what UML device you get when
+          you telnet to that portal will be unpredictable.
+          It is safe to say 'Y' here.
 
 config PTY_CHAN
        bool "pty channel support"
        help
-        This option enables support for attaching UML consoles and serial
-        lines to host pseudo-terminals.  Access to both traditional
-        pseudo-terminals (/dev/pty*) and pts pseudo-terminals are controlled
-        with this option.  The assignment of UML devices to host devices
-        will be announced in the kernel message log.
-        It is safe to say 'Y' here.
+          This option enables support for attaching UML consoles and serial
+          lines to host pseudo-terminals.  Access to both traditional
+          pseudo-terminals (/dev/pty*) and pts pseudo-terminals are controlled
+          with this option.  The assignment of UML devices to host devices
+          will be announced in the kernel message log.
+          It is safe to say 'Y' here.
 
 config TTY_CHAN
        bool "tty channel support"
        help
-        This option enables support for attaching UML consoles and serial
-        lines to host terminals.  Access to both virtual consoles
-        (/dev/tty*) and the slave side of pseudo-terminals (/dev/ttyp* and
-        /dev/pts/*) are controlled by this option.
-        It is safe to say 'Y' here.
+          This option enables support for attaching UML consoles and serial
+          lines to host terminals.  Access to both virtual consoles
+          (/dev/tty*) and the slave side of pseudo-terminals (/dev/ttyp* and
+          /dev/pts/*) are controlled by this option.
+          It is safe to say 'Y' here.
 
 config XTERM_CHAN
        bool "xterm channel support"
        help
-        This option enables support for attaching UML consoles and serial
-        lines to xterms.  Each UML device so assigned will be brought up in
-        its own xterm.
-        If you disable this option, then CONFIG_PT_PROXY will be disabled as
-        well, since UML's gdb currently requires an xterm.
-        It is safe to say 'Y' here.
+          This option enables support for attaching UML consoles and serial
+          lines to xterms.  Each UML device so assigned will be brought up in
+          its own xterm.
+          It is safe to say 'Y' here.
 
 config NOCONFIG_CHAN
        bool
@@ -77,39 +75,39 @@ config CON_ZERO_CHAN
        string "Default main console channel initialization"
        default "fd:0,fd:1"
        help
-        This is the string describing the channel to which the main console
-        will be attached by default.  This value can be overridden from the
-        command line.  The default value is "fd:0,fd:1", which attaches the
-        main console to stdin and stdout.
-        It is safe to leave this unchanged.
+          This is the string describing the channel to which the main console
+          will be attached by default.  This value can be overridden from the
+          command line.  The default value is "fd:0,fd:1", which attaches the
+          main console to stdin and stdout.
+          It is safe to leave this unchanged.
 
 config CON_CHAN
        string "Default console channel initialization"
        default "xterm"
        help
-        This is the string describing the channel to which all consoles
-        except the main console will be attached by default.  This value can
-        be overridden from the command line.  The default value is "xterm",
-        which brings them up in xterms.
-        It is safe to leave this unchanged, although you may wish to change
-        this if you expect the UML that you build to be run in environments
-        which don't have X or xterm available.
+          This is the string describing the channel to which all consoles
+          except the main console will be attached by default.  This value can
+          be overridden from the command line.  The default value is "xterm",
+          which brings them up in xterms.
+          It is safe to leave this unchanged, although you may wish to change
+          this if you expect the UML that you build to be run in environments
+          which don't have X or xterm available.
 
 config SSL_CHAN
        string "Default serial line channel initialization"
        default "pty"
        help
-        This is the string describing the channel to which the serial lines
-        will be attached by default.  This value can be overridden from the
-        command line.  The default value is "pty", which attaches them to
-        traditional pseudo-terminals.
-        It is safe to leave this unchanged, although you may wish to change
-        this if you expect the UML that you build to be run in environments
-        which don't have a set of /dev/pty* devices.
+          This is the string describing the channel to which the serial lines
+          will be attached by default.  This value can be overridden from the
+          command line.  The default value is "pty", which attaches them to
+          traditional pseudo-terminals.
+          It is safe to leave this unchanged, although you may wish to change
+          this if you expect the UML that you build to be run in environments
+          which don't have a set of /dev/pty* devices.
 
 config UNIX98_PTYS
        bool "Unix98 PTY support"
-       ---help---
+       help
          A pseudo terminal (PTY) is a software device consisting of two
          halves: a master and a slave. The slave device behaves identical to
          a physical terminal; the master device is used by a process to
@@ -132,7 +130,7 @@ config UNIX98_PTYS
 config LEGACY_PTYS
        bool "Legacy (BSD) PTY support"
        default y
-       ---help---
+       help
          A pseudo terminal (PTY) is a software device consisting of two
          halves: a master and a slave. The slave device behaves identical to
          a physical terminal; the master device is used by a process to
@@ -170,7 +168,7 @@ config LEGACY_PTY_COUNT
        int "Maximum number of legacy PTY in use"
        depends on LEGACY_PTYS
        default "256"
-       ---help---
+       help
          The maximum number of legacy PTYs that can be used at any one time.
          The default is 256, and should be more than enough.  Embedded
          systems may want to reduce this to save memory.
@@ -196,10 +194,10 @@ config UML_WATCHDOG
 config UML_SOUND
        tristate "Sound support"
        help
-        This option enables UML sound support.  If enabled, it will pull in
-        soundcore and the UML hostaudio relay, which acts as a intermediary
-        between the host's dsp and mixer devices and the UML sound system.
-        It is safe to say 'Y' here.
+          This option enables UML sound support.  If enabled, it will pull in
+          soundcore and the UML hostaudio relay, which acts as a intermediary
+          between the host's dsp and mixer devices and the UML sound system.
+          It is safe to say 'Y' here.
 
 config SOUND
        tristate
@@ -217,22 +215,21 @@ config HW_RANDOM
 config UML_RANDOM
        tristate "Hardware random number generator"
        help
-       This option enables UML's "hardware" random number generator.  It
-       attaches itself to the host's /dev/random, supplying as much entropy
-       as the host has, rather than the small amount the UML gets from its
-       own drivers.  It registers itself as a standard hardware random number
-       generator, major 10, minor 183, and the canonical device name is
-       /dev/hwrng.
-       The way to make use of this is to install the rng-tools package
-       (check your distro, or download from
-       http://sourceforge.net/projects/gkernel/).  rngd periodically reads
-       /dev/hwrng and injects the entropy into /dev/random.
+         This option enables UML's "hardware" random number generator.  It
+         attaches itself to the host's /dev/random, supplying as much entropy
+         as the host has, rather than the small amount the UML gets from its
+         own drivers.  It registers itself as a standard hardware random number
+         generator, major 10, minor 183, and the canonical device name is
+         /dev/hwrng.
+         The way to make use of this is to install the rng-tools package
+         (check your distro, or download from
+         http://sourceforge.net/projects/gkernel/).  rngd periodically reads
+         /dev/hwrng and injects the entropy into /dev/random.
 
 config MMAPPER
        tristate "iomem emulation driver"
        help
-       This driver allows a host file to be used as emulated IO memory inside
-       UML.
+         This driver allows a host file to be used as emulated IO memory inside
+         UML.
 
 endmenu
-
index c86f5eb..1f6462f 100644 (file)
@@ -2,50 +2,31 @@ menu "Kernel hacking"
 
 source "lib/Kconfig.debug"
 
-config CMDLINE_ON_HOST
-       bool "Show command line arguments on the host in TT mode"
-       depends on MODE_TT
-       default !DEBUG_INFO
-       help
-       This controls whether arguments in guest processes should be shown on
-       the host's ps output.
-       Enabling this option hinders debugging on some recent GDB versions
-       (because GDB gets "confused" when we do an execvp()). So probably you
-       should disable it.
-
-config PT_PROXY
-       bool "Enable ptrace proxy"
-       depends on XTERM_CHAN && DEBUG_INFO && MODE_TT
-       help
-       This option enables a debugging interface which allows gdb to debug
-       the kernel without needing to actually attach to kernel threads.
-       If you want to do kernel debugging, say Y here; otherwise say N.
-
 config GPROF
        bool "Enable gprof support"
-       depends on DEBUG_INFO && MODE_SKAS && !MODE_TT
+       depends on DEBUG_INFO
        help
-        This allows profiling of a User-Mode Linux kernel with the gprof
-        utility.
+         This allows profiling of a User-Mode Linux kernel with the gprof
+         utility.
 
-        See <http://user-mode-linux.sourceforge.net/gprof.html> for more
-        details.
+         See <http://user-mode-linux.sourceforge.net/gprof.html> for more
+         details.
 
-        If you're involved in UML kernel development and want to use gprof,
-        say Y.  If you're unsure, say N.
+         If you're involved in UML kernel development and want to use gprof,
+         say Y.  If you're unsure, say N.
 
 config GCOV
        bool "Enable gcov support"
-       depends on DEBUG_INFO && MODE_SKAS
+       depends on DEBUG_INFO
        help
-        This option allows developers to retrieve coverage data from a UML
-        session.
+         This option allows developers to retrieve coverage data from a UML
+         session.
 
-        See <http://user-mode-linux.sourceforge.net/gprof.html> for more
-        details.
+         See <http://user-mode-linux.sourceforge.net/gprof.html> for more
+         details.
 
-        If you're involved in UML kernel development and want to use gcov,
-        say Y.  If you're unsure, say N.
+         If you're involved in UML kernel development and want to use gcov,
+         say Y.  If you're unsure, say N.
 
 config DEBUG_STACK_USAGE
        bool "Stack utilization instrumentation"
index d6cffb2..e0ac74e 100644 (file)
@@ -1,6 +1,6 @@
 menu "Host processor type and features"
 
-source "arch/i386/Kconfig.cpu"
+source "arch/x86/Kconfig.cpu"
 
 endmenu
 
@@ -65,20 +65,6 @@ config 3_LEVEL_PGTABLES
        However, this it experimental on 32-bit architectures, so if unsure say
        N (on x86-64 it's automatically enabled, instead, as it's safe there).
 
-config STUB_CODE
-       hex
-       default 0xbfffe000 if !HOST_VMSPLIT_2G
-       default 0x7fffe000 if HOST_VMSPLIT_2G
-
-config STUB_DATA
-       hex
-       default 0xbffff000 if !HOST_VMSPLIT_2G
-       default 0x7ffff000 if HOST_VMSPLIT_2G
-
-config STUB_START
-       hex
-       default STUB_CODE
-
 config ARCH_HAS_SC_SIGNALS
        bool
        default y
index 14a04eb..66e5002 100644 (file)
@@ -108,6 +108,28 @@ config UML_NET_DAEMON
         more than one without conflict.  If you don't need UML networking,
         say N.
 
+config UML_NET_VDE
+       bool "VDE transport"
+       depends on UML_NET
+       help
+       This User-Mode Linux network transport allows one or more running
+       UMLs on a single host to communicate with each other and also
+       with the rest of the world using Virtual Distributed Ethernet,
+       an improved fork of uml_switch.
+
+       You must have libvdeplug installed in order to build the vde
+       transport into UML.
+
+       To use this form of networking, you will need to run vde_switch
+       on the host.
+
+       For more information, see <http://wiki.virtualsquare.org/>
+       That site has a good overview of what VDE is and also examples
+       of the UML command line to use to enable VDE networking.
+
+       If you need UML networking with VDE,
+       say Y.
+
 config UML_NET_MCAST
        bool "Multicast transport"
        depends on UML_NET
index f60e9e5..d632e9a 100644 (file)
@@ -17,24 +17,12 @@ config SEMAPHORE_SLEEPERS
 
 config TOP_ADDR
        hex
-       default 0x80000000
+       default 0x7fc0000000
 
 config 3_LEVEL_PGTABLES
        bool
        default y
 
-config STUB_CODE
-       hex
-       default 0x7fbfffe000
-
-config STUB_DATA
-       hex
-       default 0x7fbffff000
-
-config STUB_START
-       hex
-       default STUB_CODE
-
 config ARCH_HAS_SC_SIGNALS
        bool
        default n
index 989224f..768a5d1 100644 (file)
@@ -2,7 +2,7 @@
 # This file is included by the global makefile so that you can add your own
 # architecture-specific flags and dependencies.
 #
-# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 # Licensed under the GPL
 #
 
@@ -31,18 +31,9 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
        $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
 
-um-modes-$(CONFIG_MODE_TT) += tt
-um-modes-$(CONFIG_MODE_SKAS) += skas
+MODE_INCLUDE   += -I$(srctree)/$(ARCH_DIR)/include/skas
 
-MODE_INCLUDE   += $(foreach mode,$(um-modes-y),\
-                  -I$(srctree)/$(ARCH_DIR)/include/$(mode))
-
-MAKEFILES-INCL += $(foreach mode,$(um-modes-y),\
-                  $(srctree)/$(ARCH_DIR)/Makefile-$(mode))
-
-ifneq ($(MAKEFILES-INCL),)
-  include $(MAKEFILES-INCL)
-endif
+include $(srctree)/$(ARCH_DIR)/Makefile-skas
 
 ARCH_INCLUDE   := -I$(ARCH_DIR)/include
 ifneq ($(KBUILD_SRC),)
@@ -58,14 +49,15 @@ SYS_DIR             := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 #
 # These apply to USER_CFLAGS to.
 
-CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"   \
+KBUILD_CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"    \
        $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap      \
-       -Din6addr_loopback=kernel_in6addr_loopback
+       -Din6addr_loopback=kernel_in6addr_loopback \
+       -Din6addr_any=kernel_in6addr_any
 
-AFLAGS += $(ARCH_INCLUDE)
+KBUILD_AFLAGS += $(ARCH_INCLUDE)
 
 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
-       $(patsubst -I%,,$(CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
+       $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
        -D_FILE_OFFSET_BITS=64
 
 include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
@@ -75,22 +67,24 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
 
 # -Derrno=kernel_errno - This turns all kernel references to errno into
 # kernel_errno to separate them from the libc errno.  This allows -fno-common
-# in CFLAGS.  Otherwise, it would cause ld to complain about the two different
+# in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
 # errnos.
 # These apply to kernelspace only.
+#
+# strip leading and trailing whitespace to make the USER_CFLAGS removal of these
+# defines more robust
 
-KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
-       -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
-CFLAGS += $(KERNEL_DEFINES)
-CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
+KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
+                        -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
+KBUILD_CFLAGS += $(KERNEL_DEFINES)
+KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
 
 # These are needed for clean and mrproper, since in that case .config is not
 # included; the values here are meaningless
 
 CONFIG_NEST_LEVEL ?= 0
-CONFIG_KERNEL_HALF_GIGS ?= 0
 
-SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
+SIZE = ($(CONFIG_NEST_LEVEL) * 0x20000000)
 
 PHONY += linux
 
@@ -123,7 +117,6 @@ CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,)
        $(call cc-option, -fno-stack-protector,) \
        $(call cc-option, -fno-stack-protector-all,)
 
-CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT
 CONFIG_KERNEL_STACK_ORDER ?= 2
 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
 
@@ -131,13 +124,10 @@ ifndef START
   START = $(shell echo $$[ $(TOP_ADDR) - $(SIZE) ] )
 endif
 
-CPPFLAGS_vmlinux.lds = -U$(SUBARCH) \
-       -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
-       -DELF_FORMAT="$(ELF_FORMAT)" $(CPP_MODE-y) \
-       -DKERNEL_STACK_SIZE=$(STACK_SIZE) \
-       -DUNMAP_PATH=arch/um/sys-$(SUBARCH)/unmap.o
+CPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
+       -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE)
 
-#The wrappers will select whether using "malloc" or the kernel allocator.
+# The wrappers will select whether using "malloc" or the kernel allocator.
 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
 
 CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS)
@@ -150,8 +140,8 @@ define cmd_vmlinux__
        FORCE ,$^) ; rm -f linux
 endef
 
-#When cleaning we don't include .config, so we don't include
-#TT or skas makefiles and don't clean skas_ptregs.h.
+# When cleaning we don't include .config, so we don't include
+# TT or skas makefiles and don't clean skas_ptregs.h.
 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
        $(ARCH_DIR)/include/user_constants.h \
        $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch
@@ -176,9 +166,9 @@ include/asm-um/arch:
        @echo '  SYMLINK $@'
 ifneq ($(KBUILD_SRC),)
        $(Q)mkdir -p $(objtree)/include/asm-um
-       $(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch
+       $(Q)ln -fsn $(srctree)/include/asm-$(HEADER_ARCH) include/asm-um/arch
 else
-       $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
+       $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(HEADER_ARCH) arch
 endif
 
 $(objtree)/$(ARCH_DIR)/include:
@@ -232,4 +222,4 @@ $(ARCH_DIR)/include/kern_constants.h: $(objtree)/$(ARCH_DIR)/include
        @echo '  SYMLINK $@'
        $(Q)ln -sf ../../../include/asm-um/asm-offsets.h $@
 
-export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS
+export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH
index c9f1c5b..6729011 100644 (file)
@@ -1,22 +1,20 @@
-core-y += arch/um/sys-i386/ arch/i386/crypto/
+core-y += arch/um/sys-i386/ arch/x86/crypto/
 
 TOP_ADDR := $(CONFIG_TOP_ADDR)
 
-ifeq ($(CONFIG_MODE_SKAS),y)
-  ifneq ($(CONFIG_MODE_TT),y)
-     START := 0x8048000
-  endif
-endif
+START := 0x8048000
 
 LDFLAGS                        += -m elf_i386
 ELF_ARCH               := $(SUBARCH)
 ELF_FORMAT             := elf32-$(SUBARCH)
 OBJCOPYFLAGS           := -O binary -R .note -R .comment -S
+HEADER_ARCH            := x86
+CHECKFLAGS     += -D__i386__
 
 ifeq ("$(origin SUBARCH)", "command line")
 ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
-CFLAGS                 += $(call cc-option,-m32)
-AFLAGS                 += $(call cc-option,-m32)
+KBUILD_CFLAGS          += $(call cc-option,-m32)
+KBUILD_AFLAGS          += $(call cc-option,-m32)
 LINK-y                 += $(call cc-option,-m32)
 UML_OBJCOPYFLAGS       += -F $(ELF_FORMAT)
 
@@ -24,10 +22,13 @@ export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
 endif
 endif
 
-ARCH_KERNEL_DEFINES += -U__$(SUBARCH)__ -U$(SUBARCH)
+KBUILD_CFLAGS          += -DCONFIG_X86_32
+KBUILD_AFLAGS          += -DCONFIG_X86_32
+CONFIG_X86_32          := y
+export CONFIG_X86_32
 
 # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
-include $(srctree)/arch/i386/Makefile.cpu
+include $(srctree)/arch/x86/Makefile_32.cpu
 
 # prevent gcc from keeping the stack 16 byte aligned. Taken from i386.
 cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
@@ -36,4 +37,4 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
 # an unresolved reference.
 cflags-y += -ffreestanding
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
index 0c0f9a1..5285948 100644 (file)
@@ -5,4 +5,4 @@
 
 # To get a definition of F_SETSIG
 USER_CFLAGS += -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
-CFLAGS += -D_LARGEFILE64_SOURCE
+KBUILD_CFLAGS += -D_LARGEFILE64_SOURCE
index 69ecea6..8ed362f 100644 (file)
@@ -1,23 +1,21 @@
 # Copyright 2003 - 2004 Pathscale, Inc
 # Released under the GPL
 
-core-y += arch/um/sys-x86_64/ arch/x86_64/crypto/
+core-y += arch/um/sys-x86_64/ arch/x86/crypto/
 START := 0x60000000
 
 _extra_flags_ = -fno-builtin -m64
 
-#We #undef __x86_64__ for kernelspace, not for userspace where
-#it's needed for headers to work!
-ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__
-CFLAGS += $(_extra_flags_)
+KBUILD_CFLAGS += $(_extra_flags_)
 
-CHECKFLAGS  += -m64
-AFLAGS += -m64
+CHECKFLAGS  += -m64 -D__x86_64__
+KBUILD_AFLAGS += -m64
 LDFLAGS += -m elf_x86_64
-CPPFLAGS += -m64
+KBUILD_CPPFLAGS += -m64
 
 ELF_ARCH := i386:x86-64
 ELF_FORMAT := elf64-x86-64
+HEADER_ARCH := x86
 
 # Not on all 64-bit distros /lib is a symlink to /lib64. PLD is an example.
 
index 1e0f677..f609ede 100644 (file)
@@ -12,9 +12,7 @@ CONFIG_IRQ_RELEASE_METHOD=y
 #
 # UML-specific options
 #
-# CONFIG_MODE_TT is not set
 # CONFIG_STATIC_LINK is not set
-CONFIG_MODE_SKAS=y
 
 #
 # Host processor type and features
@@ -61,9 +59,6 @@ CONFIG_SEMAPHORE_SLEEPERS=y
 # CONFIG_HOST_2G_2G is not set
 CONFIG_TOP_ADDR=0xc0000000
 # CONFIG_3_LEVEL_PGTABLES is not set
-CONFIG_STUB_CODE=0xbfffe000
-CONFIG_STUB_DATA=0xbffff000
-CONFIG_STUB_START=0xbfffe000
 CONFIG_ARCH_HAS_SC_SIGNALS=y
 CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA=y
 CONFIG_GENERIC_HWEIGHT=y
@@ -75,6 +70,9 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_LD_SCRIPT_DYN=y
 CONFIG_NET=y
 CONFIG_BINFMT_ELF=y
@@ -82,11 +80,10 @@ CONFIG_BINFMT_MISC=m
 # CONFIG_HOSTFS is not set
 # CONFIG_HPPFS is not set
 CONFIG_MCONSOLE=y
-# CONFIG_MAGIC_SYSRQ is not set
+CONFIG_MAGIC_SYSRQ=y
 CONFIG_NEST_LEVEL=0
 # CONFIG_HIGHMEM is not set
 CONFIG_KERNEL_STACK_ORDER=0
-CONFIG_UML_REAL_TIME_CLOCK=y
 
 #
 # Code maturity level options
index de17d4c..d283e7b 100644 (file)
@@ -17,12 +17,18 @@ ubd-objs := ubd_kern.o ubd_user.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
 
-LDFLAGS_pcap.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libpcap.a)
+LDFLAGS_pcap.o := -r $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
 
-targets := pcap_kern.o pcap_user.o
+LDFLAGS_vde.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libvdeplug.a)
+
+targets := pcap_kern.o pcap_user.o vde_kern.o vde_user.o
 
 $(obj)/pcap.o: $(obj)/pcap_kern.o $(obj)/pcap_user.o
        $(LD) -r -dp -o $@ $^ $(LDFLAGS) $(LDFLAGS_pcap.o)
+
+$(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o
+       $(LD) -r -dp -o $@ $^ $(LDFLAGS) $(LDFLAGS_vde.o)
+
 #XXX: The call below does not work because the flags are added before the
 # object name, so nothing from the library gets linked.
 #$(call if_changed,ld)
@@ -37,6 +43,7 @@ obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o
 obj-$(CONFIG_UML_NET_SLIP) += slip.o slip_common.o
 obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o
 obj-$(CONFIG_UML_NET_DAEMON) += daemon.o 
+obj-$(CONFIG_UML_NET_VDE) += vde.o
 obj-$(CONFIG_UML_NET_MCAST) += mcast.o 
 obj-$(CONFIG_UML_NET_PCAP) += pcap.o
 obj-$(CONFIG_UML_NET) += net.o 
@@ -54,6 +61,6 @@ obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o
 obj-$(CONFIG_UML_RANDOM) += random.o
 
 # pcap_user.o must be added explicitly.
-USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o
+USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o vde_user.o
 
 include arch/um/scripts/Makefile.rules
index 629b00e..db3082b 100644 (file)
@@ -1,28 +1,19 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
-#include <linux/string.h>
 #include <linux/tty_flip.h>
-#include <asm/irq.h>
 #include "chan_kern.h"
-#include "kern.h"
-#include "irq_user.h"
-#include "sigio.h"
-#include "line.h"
 #include "os.h"
 
 #ifdef CONFIG_NOCONFIG_CHAN
 static void *not_configged_init(char *str, int device,
                                const struct chan_opts *opts)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return NULL;
 }
@@ -30,34 +21,34 @@ static void *not_configged_init(char *str, int device,
 static int not_configged_open(int input, int output, int primary, void *data,
                              char **dev_out)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return -ENODEV;
 }
 
 static void not_configged_close(int fd, void *data)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
 }
 
 static int not_configged_read(int fd, char *c_out, void *data)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
 
 static int not_configged_write(int fd, const char *buf, int len, void *data)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
 
 static int not_configged_console_write(int fd, const char *buf, int len)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return -EIO;
 }
@@ -65,14 +56,14 @@ static int not_configged_console_write(int fd, const char *buf, int len)
 static int not_configged_window_size(int fd, void *data, unsigned short *rows,
                                     unsigned short *cols)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
        return -ENODEV;
 }
 
 static void not_configged_free(void *data)
 {
-       printk("Using a channel type which is configured out of "
+       printk(KERN_ERR "Using a channel type which is configured out of "
               "UML\n");
 }
 
@@ -89,64 +80,17 @@ static const struct chan_ops not_configged_ops = {
 };
 #endif /* CONFIG_NOCONFIG_CHAN */
 
-void generic_close(int fd, void *unused)
-{
-       os_close_file(fd);
-}
-
-int generic_read(int fd, char *c_out, void *unused)
-{
-       int n;
-
-       n = os_read_file(fd, c_out, sizeof(*c_out));
-
-       if(n == -EAGAIN)
-               return 0;
-       else if(n == 0)
-               return -EIO;
-       return n;
-}
-
-/* XXX Trivial wrapper around os_write_file */
-
-int generic_write(int fd, const char *buf, int n, void *unused)
-{
-       return os_write_file(fd, buf, n);
-}
-
-int generic_window_size(int fd, void *unused, unsigned short *rows_out,
-                       unsigned short *cols_out)
-{
-       int rows, cols;
-       int ret;
-
-       ret = os_window_size(fd, &rows, &cols);
-       if(ret < 0)
-               return ret;
-
-       ret = ((*rows_out != rows) || (*cols_out != cols));
-
-       *rows_out = rows;
-       *cols_out = cols;
-
-       return ret;
-}
-
-void generic_free(void *data)
-{
-       kfree(data);
-}
-
 static void tty_receive_char(struct tty_struct *tty, char ch)
 {
-       if(tty == NULL) return;
+       if (tty == NULL)
+               return;
 
-       if(I_IXON(tty) && !I_IXOFF(tty) && !tty->raw) {
-               if(ch == STOP_CHAR(tty)){
+       if (I_IXON(tty) && !I_IXOFF(tty) && !tty->raw) {
+               if (ch == STOP_CHAR(tty)) {
                        stop_tty(tty);
                        return;
                }
-               else if(ch == START_CHAR(tty)){
+               else if (ch == START_CHAR(tty)) {
                        start_tty(tty);
                        return;
                }
@@ -159,14 +103,14 @@ static int open_one_chan(struct chan *chan)
 {
        int fd, err;
 
-       if(chan->opened)
+       if (chan->opened)
                return 0;
 
-       if(chan->ops->open == NULL)
+       if (chan->ops->open == NULL)
                fd = 0;
        else fd = (*chan->ops->open)(chan->input, chan->output, chan->primary,
                                     chan->data, &chan->dev);
-       if(fd < 0)
+       if (fd < 0)
                return fd;
 
        err = os_set_fd_block(fd, 0);
@@ -187,10 +131,10 @@ int open_chan(struct list_head *chans)
        struct chan *chan;
        int ret, err = 0;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
                ret = open_one_chan(chan);
-               if(chan->primary)
+               if (chan->primary)
                        err = ret;
        }
        return err;
@@ -201,9 +145,9 @@ void chan_enable_winch(struct list_head *chans, struct tty_struct *tty)
        struct list_head *ele;
        struct chan *chan;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(chan->primary && chan->output && chan->ops->winch){
+               if (chan->primary && chan->output && chan->ops->winch) {
                        register_winch(chan->fd, tty);
                        return;
                }
@@ -216,7 +160,7 @@ int enable_chan(struct line *line)
        struct chan *chan;
        int err;
 
-       list_for_each(ele, &line->chan_list){
+       list_for_each(ele, &line->chan_list) {
                chan = list_entry(ele, struct chan, list);
                err = open_one_chan(chan);
                if (err) {
@@ -226,7 +170,7 @@ int enable_chan(struct line *line)
                        continue;
                }
 
-               if(chan->enabled)
+               if (chan->enabled)
                        continue;
                err = line_setup_irq(chan->fd, chan->input, chan->output, line,
                                     chan);
@@ -263,12 +207,12 @@ void free_irqs(void)
        list_splice_init(&irqs_to_free, &list);
        spin_unlock_irqrestore(&irqs_to_free_lock, flags);
 
-       list_for_each(ele, &list){
+       list_for_each(ele, &list) {
                chan = list_entry(ele, struct chan, free_list);
 
-               if(chan->input)
+               if (chan->input)
                        free_irq(chan->line->driver->read_irq, chan);
-               if(chan->output)
+               if (chan->output)
                        free_irq(chan->line->driver->write_irq, chan);
                chan->enabled = 0;
        }
@@ -278,22 +222,22 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
 {
        unsigned long flags;
 
-       if(!chan->opened)
+       if (!chan->opened)
                return;
 
-       if(delay_free_irq){
+       if (delay_free_irq) {
                spin_lock_irqsave(&irqs_to_free_lock, flags);
                list_add(&chan->free_list, &irqs_to_free);
                spin_unlock_irqrestore(&irqs_to_free_lock, flags);
        }
        else {
-               if(chan->input)
+               if (chan->input)
                        free_irq(chan->line->driver->read_irq, chan);
-               if(chan->output)
+               if (chan->output)
                        free_irq(chan->line->driver->write_irq, chan);
                chan->enabled = 0;
        }
-       if(chan->ops->close != NULL)
+       if (chan->ops->close != NULL)
                (*chan->ops->close)(chan->fd, chan->data);
 
        chan->opened = 0;
@@ -322,7 +266,7 @@ void deactivate_chan(struct list_head *chans, int irq)
        list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
 
-               if(chan->enabled && chan->input)
+               if (chan->enabled && chan->input)
                        deactivate_fd(chan->fd, irq);
        }
 }
@@ -335,7 +279,7 @@ void reactivate_chan(struct list_head *chans, int irq)
        list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
 
-               if(chan->enabled && chan->input)
+               if (chan->enabled && chan->input)
                        reactivate_fd(chan->fd, irq);
        }
 }
@@ -347,10 +291,14 @@ int write_chan(struct list_head *chans, const char *buf, int len,
        struct chan *chan = NULL;
        int n, ret = 0;
 
+       if (len == 0)
+               return 0;
+
        list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
                if (!chan->output || (chan->ops->write == NULL))
                        continue;
+
                n = chan->ops->write(chan->fd, buf, len, chan->data);
                if (chan->primary) {
                        ret = n;
@@ -367,12 +315,14 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
        struct chan *chan;
        int n, ret = 0;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(!chan->output || (chan->ops->console_write == NULL))
+               if (!chan->output || (chan->ops->console_write == NULL))
                        continue;
+
                n = chan->ops->console_write(chan->fd, buf, len);
-               if(chan->primary) ret = n;
+               if (chan->primary)
+                       ret = n;
        }
        return ret;
 }
@@ -382,10 +332,11 @@ int console_open_chan(struct line *line, struct console *co)
        int err;
 
        err = open_chan(&line->chan_list);
-       if(err)
+       if (err)
                return err;
 
-       printk("Console initialized on /dev/%s%d\n", co->name, co->index);
+       printk(KERN_INFO "Console initialized on /dev/%s%d\n", co->name,
+              co->index);
        return 0;
 }
 
@@ -395,10 +346,10 @@ int chan_window_size(struct list_head *chans, unsigned short *rows_out,
        struct list_head *ele;
        struct chan *chan;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(chan->primary){
-                       if(chan->ops->window_size == NULL)
+               if (chan->primary) {
+                       if (chan->ops->window_size == NULL)
                                return 0;
                        return chan->ops->window_size(chan->fd, chan->data,
                                                      rows_out, cols_out);
@@ -413,10 +364,11 @@ static void free_one_chan(struct chan *chan, int delay_free_irq)
 
        close_one_chan(chan, delay_free_irq);
 
-       if(chan->ops->free != NULL)
+       if (chan->ops->free != NULL)
                (*chan->ops->free)(chan->data);
 
-       if(chan->primary && chan->output) ignore_sigio_fd(chan->fd);
+       if (chan->primary && chan->output)
+               ignore_sigio_fd(chan->fd);
        kfree(chan);
 }
 
@@ -425,7 +377,7 @@ static void free_chan(struct list_head *chans, int delay_free_irq)
        struct list_head *ele, *next;
        struct chan *chan;
 
-       list_for_each_safe(ele, next, chans){
+       list_for_each_safe(ele, next, chans) {
                chan = list_entry(ele, struct chan, list);
                free_one_chan(chan, delay_free_irq);
        }
@@ -436,14 +388,14 @@ static int one_chan_config_string(struct chan *chan, char *str, int size,
 {
        int n = 0;
 
-       if(chan == NULL){
+       if (chan == NULL) {
                CONFIG_CHUNK(str, size, n, "none", 1);
                return n;
        }
 
        CONFIG_CHUNK(str, size, n, chan->ops->type, 0);
 
-       if(chan->dev == NULL){
+       if (chan->dev == NULL) {
                CONFIG_CHUNK(str, size, n, "", 1);
                return n;
        }
@@ -463,7 +415,7 @@ static int chan_pair_config_string(struct chan *in, struct chan *out,
        str += n;
        size -= n;
 
-       if(in == out){
+       if (in == out) {
                CONFIG_CHUNK(str, size, n, "", 1);
                return n;
        }
@@ -483,13 +435,13 @@ int chan_config_string(struct list_head *chans, char *str, int size,
        struct list_head *ele;
        struct chan *chan, *in = NULL, *out = NULL;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(!chan->primary)
+               if (!chan->primary)
                        continue;
-               if(chan->input)
+               if (chan->input)
                        in = chan;
-               if(chan->output)
+               if (chan->output)
                        out = chan;
        }
 
@@ -548,27 +500,27 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
 
        ops = NULL;
        data = NULL;
-       for(i = 0; i < ARRAY_SIZE(chan_table); i++){
+       for(i = 0; i < ARRAY_SIZE(chan_table); i++) {
                entry = &chan_table[i];
-               if(!strncmp(str, entry->key, strlen(entry->key))){
+               if (!strncmp(str, entry->key, strlen(entry->key))) {
                        ops = entry->ops;
                        str += strlen(entry->key);
                        break;
                }
        }
-       if(ops == NULL){
+       if (ops == NULL) {
                *error_out = "No match for configured backends";
                return NULL;
        }
 
        data = (*ops->init)(str, device, opts);
-       if(data == NULL){
+       if (data == NULL) {
                *error_out = "Configuration failed";
                return NULL;
        }
 
        chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
-       if(chan == NULL){
+       if (chan == NULL) {
                *error_out = "Memory allocation failed";
                return NULL;
        }
@@ -594,26 +546,26 @@ int parse_chan_pair(char *str, struct line *line, int device,
        struct chan *new, *chan;
        char *in, *out;
 
-       if(!list_empty(chans)){
+       if (!list_empty(chans)) {
                chan = list_entry(chans->next, struct chan, list);
                free_chan(chans, 0);
                INIT_LIST_HEAD(chans);
        }
 
        out = strchr(str, ',');
-       if(out != NULL){
+       if (out != NULL) {
                in = str;
                *out = '\0';
                out++;
                new = parse_chan(line, in, device, opts, error_out);
-               if(new == NULL)
+               if (new == NULL)
                        return -1;
 
                new->input = 1;
                list_add(&new->list, chans);
 
                new = parse_chan(line, out, device, opts, error_out);
-               if(new == NULL)
+               if (new == NULL)
                        return -1;
 
                list_add(&new->list, chans);
@@ -621,7 +573,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
        }
        else {
                new = parse_chan(line, str, device, opts, error_out);
-               if(new == NULL)
+               if (new == NULL)
                        return -1;
 
                list_add(&new->list, chans);
@@ -636,9 +588,9 @@ int chan_out_fd(struct list_head *chans)
        struct list_head *ele;
        struct chan *chan;
 
-       list_for_each(ele, chans){
+       list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(chan->primary && chan->output)
+               if (chan->primary && chan->output)
                        return chan->fd;
        }
        return -1;
@@ -652,23 +604,25 @@ void chan_interrupt(struct list_head *chans, struct delayed_work *task,
        int err;
        char c;
 
-       list_for_each_safe(ele, next, chans){
+       list_for_each_safe(ele, next, chans) {
                chan = list_entry(ele, struct chan, list);
-               if(!chan->input || (chan->ops->read == NULL)) continue;
+               if (!chan->input || (chan->ops->read == NULL))
+                       continue;
                do {
                        if (tty && !tty_buffer_request_room(tty, 1)) {
                                schedule_delayed_work(task, 1);
                                goto out;
                        }
                        err = chan->ops->read(chan->fd, &c, chan->data);
-                       if(err > 0)
+                       if (err > 0)
                                tty_receive_char(tty, c);
-               } while(err > 0);
+               } while (err > 0);
 
-               if(err == 0) reactivate_fd(chan->fd, irq);
-               if(err == -EIO){
-                       if(chan->primary){
-                               if(tty != NULL)
+               if (err == 0)
+                       reactivate_fd(chan->fd, irq);
+               if (err == -EIO) {
+                       if (chan->primary) {
+                               if (tty != NULL)
                                        tty_hangup(tty);
                                close_chan(chans, 1);
                                return;
@@ -677,5 +631,6 @@ void chan_interrupt(struct list_head *chans, struct delayed_work *task,
                }
        }
  out:
-       if(tty) tty_flip_buffer_push(tty);
+       if (tty)
+               tty_flip_buffer_push(tty);
 }
index 4d438f3..b88e93b 100644 (file)
-/* 
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
-#include <unistd.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <errno.h>
-#include <termios.h>
-#include <string.h>
-#include <signal.h>
 #include <sched.h>
-#include <sys/stat.h>
+#include <signal.h>
+#include <termios.h>
 #include <sys/ioctl.h>
-#include <sys/socket.h>
-#include "kern_util.h"
 #include "chan_user.h"
-#include "user.h"
 #include "os.h"
-#include "choose-mode.h"
-#include "mode.h"
+#include "um_malloc.h"
+#include "user.h"
+
+void generic_close(int fd, void *unused)
+{
+       close(fd);
+}
+
+int generic_read(int fd, char *c_out, void *unused)
+{
+       int n;
+
+       n = read(fd, c_out, sizeof(*c_out));
+       if (n > 0)
+               return n;
+       else if (errno == EAGAIN)
+               return 0;
+       else if (n == 0)
+               return -EIO;
+       return -errno;
+}
+
+/* XXX Trivial wrapper around write */
+
+int generic_write(int fd, const char *buf, int n, void *unused)
+{
+       int err;
+
+       err = write(fd, buf, n);
+       if (err > 0)
+               return err;
+       else if (errno == EAGAIN)
+               return 0;
+       else if (err == 0)
+               return -EIO;
+       return -errno;
+}
+
+int generic_window_size(int fd, void *unused, unsigned short *rows_out,
+                       unsigned short *cols_out)
+{
+       struct winsize size;
+       int ret;
+
+       if (ioctl(fd, TIOCGWINSZ, &size) < 0)
+               return -errno;
+
+       ret = ((*rows_out != size.ws_row) || (*cols_out != size.ws_col));
+
+       *rows_out = size.ws_row;
+       *cols_out = size.ws_col;
+
+       return ret;
+}
+
+void generic_free(void *data)
+{
+       kfree(data);
+}
 
 int generic_console_write(int fd, const char *buf, int n)
 {
        struct termios save, new;
        int err;
 
-       if(isatty(fd)){
+       if (isatty(fd)) {
                CATCH_EINTR(err = tcgetattr(fd, &save));
                if (err)
                        goto error;
                new = save;
-               /* The terminal becomes a bit less raw, to handle \n also as
+               /*
+                * The terminal becomes a bit less raw, to handle \n also as
                 * "Carriage Return", not only as "New Line". Otherwise, the new
-                * line won't start at the first column.*/
+                * line won't start at the first column.
+                */
                new.c_oflag |= OPOST;
                CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
                if (err)
                        goto error;
        }
        err = generic_write(fd, buf, n, NULL);
-       /* Restore raw mode, in any case; we *must* ignore any error apart
-        * EINTR, except for debug.*/
-       if(isatty(fd))
+       /*
+        * Restore raw mode, in any case; we *must* ignore any error apart
+        * EINTR, except for debug.
+        */
+       if (isatty(fd))
                CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
-       return(err);
+       return err;
 error:
-       return(-errno);
+       return -errno;
 }
 
 /*
@@ -82,62 +138,73 @@ static int winch_thread(void *arg)
        struct winch_data *data = arg;
        sigset_t sigs;
        int pty_fd, pipe_fd;
-       int count, err;
+       int count;
        char c = 1;
 
        pty_fd = data->pty_fd;
        pipe_fd = data->pipe_fd;
-       count = os_write_file(pipe_fd, &c, sizeof(c));
-       if(count != sizeof(c))
-               printk("winch_thread : failed to write synchronization "
-                      "byte, err = %d\n", -count);
+       count = write(pipe_fd, &c, sizeof(c));
+       if (count != sizeof(c))
+               printk(UM_KERN_ERR "winch_thread : failed to write "
+                      "synchronization byte, err = %d\n", -count);
 
-       /* We are not using SIG_IGN on purpose, so don't fix it as I thought to
+       /*
+        * We are not using SIG_IGN on purpose, so don't fix it as I thought to
         * do! If using SIG_IGN, the sigsuspend() call below would not stop on
-        * SIGWINCH. */
+        * SIGWINCH.
+        */
 
        signal(SIGWINCH, winch_handler);
        sigfillset(&sigs);
        /* Block all signals possible. */
-       if(sigprocmask(SIG_SETMASK, &sigs, NULL) < 0){
-               printk("winch_thread : sigprocmask failed, errno = %d\n", 
-                      errno);
+       if (sigprocmask(SIG_SETMASK, &sigs, NULL) < 0) {
+               printk(UM_KERN_ERR "winch_thread : sigprocmask failed, "
+                      "errno = %d\n", errno);
                exit(1);
        }
        /* In sigsuspend(), block anything else than SIGWINCH. */
        sigdelset(&sigs, SIGWINCH);
 
-       if(setsid() < 0){
-               printk("winch_thread : setsid failed, errno = %d\n", errno);
+       if (setsid() < 0) {
+               printk(UM_KERN_ERR "winch_thread : setsid failed, errno = %d\n",
+                      errno);
+               exit(1);
+       }
+
+       if (ioctl(pty_fd, TIOCSCTTY, 0) < 0) {
+               printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on "
+                      "fd %d err = %d\n", pty_fd, errno);
                exit(1);
        }
 
-       err = os_new_tty_pgrp(pty_fd, os_getpid());
-       if(err < 0){
-               printk("winch_thread : new_tty_pgrp failed on fd %d, "
-                      "err = %d\n", pty_fd, -err);
+       if (tcsetpgrp(pty_fd, os_getpid()) < 0) {
+               printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on "
+                      "fd %d err = %d\n", pty_fd, errno);
                exit(1);
        }
 
-       /* These are synchronization calls between various UML threads on the
+       /*
+        * These are synchronization calls between various UML threads on the
         * host - since they are not different kernel threads, we cannot use
         * kernel semaphores. We don't use SysV semaphores because they are
-        * persistent. */
-       count = os_read_file(pipe_fd, &c, sizeof(c));
-       if(count != sizeof(c))
-               printk("winch_thread : failed to read synchronization byte, "
-                      "err = %d\n", -count);
-
-       while(1){
-               /* This will be interrupted by SIGWINCH only, since
+        * persistent.
+        */
+       count = read(pipe_fd, &c, sizeof(c));
+       if (count != sizeof(c))
+               printk(UM_KERN_ERR "winch_thread : failed to read "
+                      "synchronization byte, err = %d\n", errno);
+
+       while(1) {
+               /*
+                * This will be interrupted by SIGWINCH only, since
                 * other signals are blocked.
                 */
                sigsuspend(&sigs);
 
-               count = os_write_file(pipe_fd, &c, sizeof(c));
-               if(count != sizeof(c))
-                       printk("winch_thread : write failed, err = %d\n",
-                              -count);
+               count = write(pipe_fd, &c, sizeof(c));
+               if (count != sizeof(c))
+                       printk(UM_KERN_ERR "winch_thread : write failed, "
+                              "err = %d\n", errno);
        }
 }
 
@@ -149,44 +216,49 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out,
        char c;
 
        err = os_pipe(fds, 1, 1);
-       if(err < 0){
-               printk("winch_tramp : os_pipe failed, err = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "winch_tramp : os_pipe failed, err = %d\n",
+                      -err);
                goto out;
        }
 
        data = ((struct winch_data) { .pty_fd           = fd,
                                      .pipe_fd          = fds[1] } );
-       /* CLONE_FILES so this thread doesn't hold open files which are open
+       /*
+        * CLONE_FILES so this thread doesn't hold open files which are open
         * now, but later closed in a different thread.  This is a
         * problem with /dev/net/tun, which if held open by this
         * thread, prevents the TUN/TAP device from being reused.
         */
        err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
-       if(err < 0){
-               printk("fork of winch_thread failed - errno = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n",
+                      -err);
                goto out_close;
        }
 
        *fd_out = fds[0];
-       n = os_read_file(fds[0], &c, sizeof(c));
-       if(n != sizeof(c)){
-               printk("winch_tramp : failed to read synchronization byte\n");
-               printk("read failed, err = %d\n", -n);
-               printk("fd %d will not support SIGWINCH\n", fd);
-                err = -EINVAL;
+       n = read(fds[0], &c, sizeof(c));
+       if (n != sizeof(c)) {
+               printk(UM_KERN_ERR "winch_tramp : failed to read "
+                      "synchronization byte\n");
+               printk(UM_KERN_ERR "read failed, err = %d\n", errno);
+               printk(UM_KERN_ERR "fd %d will not support SIGWINCH\n", fd);
+               err = -EINVAL;
                goto out_close;
        }
 
        if (os_set_fd_block(*fd_out, 0)) {
-               printk("winch_tramp: failed to set thread_fd non-blocking.\n");
+               printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd "
+                      "non-blocking.\n");
                goto out_close;
        }
 
        return err;
 
  out_close:
-       os_close_file(fds[1]);
-       os_close_file(fds[0]);
+       close(fds[1]);
+       close(fds[0]);
  out:
        return err;
 }
@@ -197,21 +269,20 @@ void register_winch(int fd, struct tty_struct *tty)
        int pid, thread, count, thread_fd = -1;
        char c = 1;
 
-       if(!isatty(fd))
+       if (!isatty(fd))
                return;
 
        pid = tcgetpgrp(fd);
-       if (!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, tty) &&
-           (pid == -1)) {
+       if (!is_skas_winch(pid, fd, tty) && (pid == -1)) {
                thread = winch_tramp(fd, tty, &thread_fd, &stack);
                if (thread < 0)
                        return;
 
                register_winch_irq(thread_fd, fd, thread, tty, stack);
 
-               count = os_write_file(thread_fd, &c, sizeof(c));
-               if(count != sizeof(c))
-                       printk("register_winch : failed to write "
-                              "synchronization byte, err = %d\n", -count);
+               count = write(thread_fd, &c, sizeof(c));
+               if (count != sizeof(c))
+                       printk(UM_KERN_ERR "register_winch : failed to write "
+                              "synchronization byte, err = %d\n", errno);
        }
 }
index 0ec4052..93f227a 100644 (file)
@@ -1,17 +1,18 @@
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-/* _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
+ * Licensed under the GPL
+ */
+
+/*
+ * _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines
  * that.
  */
 #include <unistd.h>
 #include <byteswap.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/user.h>
-
-#include "os.h"
-
+#include <errno.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <asm/types.h>
 #include "cow.h"
 #include "cow_sys.h"
 
@@ -28,7 +29,8 @@ struct cow_header_v1 {
        __s32 sectorsize;
 } __attribute__((packed));
 
-/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
+/*
+ * Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
  * case other systems have different values for MAXPATHLEN.
  *
  * The same must hold for V2 - we want file format compatibility, not anything
@@ -46,7 +48,8 @@ struct cow_header_v2 {
        __s32 sectorsize;
 } __attribute__((packed));
 
-/* Changes from V2 -
+/*
+ * Changes from V2 -
  *     PATH_LEN_V3 as described above
  *     Explicitly specify field bit lengths for systems with different
  *             lengths for the usual C types.  Not sure whether char or
@@ -70,7 +73,8 @@ struct cow_header_v2 {
  *     Fixed (finally!) the rounding bug
  */
 
-/* Until Dec2005, __attribute__((packed)) was left out from the below
+/*
+ * Until Dec2005, __attribute__((packed)) was left out from the below
  * definition, leading on 64-bit systems to 4 bytes of padding after mtime, to
  * align size to 8-byte alignment.  This shifted all fields above (no padding
  * was present on 32-bit, no other padding was added).
@@ -122,7 +126,7 @@ void cow_sizes(int version, __u64 size, int sectorsize, int align,
               int bitmap_offset, unsigned long *bitmap_len_out,
               int *data_offset_out)
 {
-       if(version < 3){
+       if (version < 3) {
                *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
 
                *data_offset_out = bitmap_offset + *bitmap_len_out;
@@ -144,46 +148,46 @@ static int absolutize(char *to, int size, char *from)
        char save_cwd[256], *slash;
        int remaining;
 
-       if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
+       if (getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
                cow_printf("absolutize : unable to get cwd - errno = %d\n",
                           errno);
-               return(-1);
+               return -1;
        }
        slash = strrchr(from, '/');
-       if(slash != NULL){
+       if (slash != NULL) {
                *slash = '\0';
-               if(chdir(from)){
+               if (chdir(from)) {
                        *slash = '/';
                        cow_printf("absolutize : Can't cd to '%s' - "
                                   "errno = %d\n", from, errno);
-                       return(-1);
+                       return -1;
                }
                *slash = '/';
-               if(getcwd(to, size) == NULL){
+               if (getcwd(to, size) == NULL) {
                        cow_printf("absolutize : unable to get cwd of '%s' - "
                               "errno = %d\n", from, errno);
-                       return(-1);
+                       return -1;
                }
                remaining = size - strlen(to);
-               if(strlen(slash) + 1 > remaining){
+               if (strlen(slash) + 1 > remaining) {
                        cow_printf("absolutize : unable to fit '%s' into %d "
                               "chars\n", from, size);
-                       return(-1);
+                       return -1;
                }
                strcat(to, slash);
        }
        else {
-               if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
+               if (strlen(save_cwd) + 1 + strlen(from) + 1 > size) {
                        cow_printf("absolutize : unable to fit '%s' into %d "
                               "chars\n", from, size);
-                       return(-1);
+                       return -1;
                }
                strcpy(to, save_cwd);
                strcat(to, "/");
                strcat(to, from);
        }
        chdir(save_cwd);
-       return(0);
+       return 0;
 }
 
 int write_cow_header(char *cow_file, int fd, char *backing_file,
@@ -194,22 +198,23 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
        int err;
 
        err = cow_seek_file(fd, 0);
-       if(err < 0){
+       if (err < 0) {
                cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
                goto out;
        }
 
        err = -ENOMEM;
        header = cow_malloc(sizeof(*header));
-       if(header == NULL){
-               cow_printf("write_cow_header - failed to allocate COW V3 header\n");
+       if (header == NULL) {
+               cow_printf("write_cow_header - failed to allocate COW V3 "
+                          "header\n");
                goto out;
        }
        header->magic = htonl(COW_MAGIC);
        header->version = htonl(COW_VERSION);
 
        err = -EINVAL;
-       if(strlen(backing_file) > sizeof(header->backing_file) - 1){
+       if (strlen(backing_file) > sizeof(header->backing_file) - 1) {
                /* Below, %zd is for a size_t value */
                cow_printf("Backing file name \"%s\" is too long - names are "
                           "limited to %zd characters\n", backing_file,
@@ -217,12 +222,12 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
                goto out_free;
        }
 
-       if(absolutize(header->backing_file, sizeof(header->backing_file),
+       if (absolutize(header->backing_file, sizeof(header->backing_file),
                      backing_file))
                goto out_free;
 
        err = os_file_modtime(header->backing_file, &modtime);
-       if(err < 0){
+       if (err < 0) {
                cow_printf("write_cow_header - backing file '%s' mtime "
                           "request failed, err = %d\n", header->backing_file,
                           -err);
@@ -230,7 +235,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
        }
 
        err = cow_file_size(header->backing_file, size);
-       if(err < 0){
+       if (err < 0) {
                cow_printf("write_cow_header - couldn't get size of "
                           "backing file '%s', err = %d\n",
                           header->backing_file, -err);
@@ -244,7 +249,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
        header->cow_format = COW_BITMAP;
 
        err = cow_write_file(fd, header, sizeof(*header));
-       if(err != sizeof(*header)){
+       if (err != sizeof(*header)) {
                cow_printf("write_cow_header - write of header to "
                           "new COW file '%s' failed, err = %d\n", cow_file,
                           -err);
@@ -254,14 +259,14 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
  out_free:
        cow_free(header);
  out:
-       return(err);
+       return err;
 }
 
 int file_reader(__u64 offset, char *buf, int len, void *arg)
 {
        int fd = *((int *) arg);
 
-       return(pread(fd, buf, len, offset));
+       return pread(fd, buf, len, offset);
 }
 
 /* XXX Need to sanity-check the values read from the header */
@@ -278,31 +283,29 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
        unsigned long version, magic;
 
        header = cow_malloc(sizeof(*header));
-       if(header == NULL){
+       if (header == NULL) {
                cow_printf("read_cow_header - Failed to allocate header\n");
-               return(-ENOMEM);
+               return -ENOMEM;
        }
        err = -EINVAL;
        n = (*reader)(0, (char *) header, sizeof(*header), arg);
-       if(n < offsetof(typeof(header->v1), backing_file)){
+       if (n < offsetof(typeof(header->v1), backing_file)) {
                cow_printf("read_cow_header - short header\n");
                goto out;
        }
 
        magic = header->v1.magic;
-       if(magic == COW_MAGIC) {
+       if (magic == COW_MAGIC)
                version = header->v1.version;
-       }
-       else if(magic == ntohl(COW_MAGIC)){
+       else if (magic == ntohl(COW_MAGIC))
                version = ntohl(header->v1.version);
-       }
        /* No error printed because the non-COW case comes through here */
        else goto out;
 
        *version_out = version;
 
-       if(version == 1){
-               if(n < sizeof(header->v1)){
+       if (version == 1) {
+               if (n < sizeof(header->v1)) {
                        cow_printf("read_cow_header - failed to read V1 "
                                   "header\n");
                        goto out;
@@ -314,8 +317,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
                *align_out = *sectorsize_out;
                file = header->v1.backing_file;
        }
-       else if(version == 2){
-               if(n < sizeof(header->v2)){
+       else if (version == 2) {
+               if (n < sizeof(header->v2)) {
                        cow_printf("read_cow_header - failed to read V2 "
                                   "header\n");
                        goto out;
@@ -328,8 +331,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
                file = header->v2.backing_file;
        }
        /* This is very subtle - see above at union cow_header definition */
-       else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){
-               if(n < sizeof(header->v3)){
+       else if (version == 3 && (*((int*)header->v3.backing_file) != 0)) {
+               if (n < sizeof(header->v3)) {
                        cow_printf("read_cow_header - failed to read V3 "
                                   "header\n");
                        goto out;
@@ -345,17 +348,18 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
                *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
                file = header->v3.backing_file;
        }
-       else if(version == 3){
+       else if (version == 3) {
                cow_printf("read_cow_header - broken V3 file with"
                           " 64-bit layout - recovering content.\n");
 
-               if(n < sizeof(header->v3_b)){
+               if (n < sizeof(header->v3_b)) {
                        cow_printf("read_cow_header - failed to read V3 "
                                   "header\n");
                        goto out;
                }
 
-               /* this was used until Dec2005 - 64bits are needed to represent
+               /*
+                * this was used until Dec2005 - 64bits are needed to represent
                 * 2038+. I.e. we can safely do this truncating cast.
                 *
                 * Additionally, we must use ntohl() instead of ntohll(), since
@@ -381,7 +385,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
        }
        err = -ENOMEM;
        *backing_file_out = cow_strdup(file);
-       if(*backing_file_out == NULL){
+       if (*backing_file_out == NULL) {
                cow_printf("read_cow_header - failed to allocate backing "
                           "file\n");
                goto out;
@@ -389,7 +393,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
        err = 0;
  out:
        cow_free(header);
-       return(err);
+       return err;
 }
 
 int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
@@ -402,7 +406,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
 
        err = write_cow_header(cow_file, fd, backing_file, sectorsize,
                               alignment, &size);
-       if(err)
+       if (err)
                goto out;
 
        *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
@@ -411,17 +415,18 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
 
        offset = *data_offset_out + size - sizeof(zero);
        err = cow_seek_file(fd, offset);
-       if(err < 0){
+       if (err < 0) {
                cow_printf("cow bitmap lseek failed : err = %d\n", -err);
                goto out;
        }
 
-       /* does not really matter how much we write it is just to set EOF
+       /*
+        * does not really matter how much we write it is just to set EOF
         * this also sets the entire COW bitmap
         * to zero without having to allocate it
         */
        err = cow_write_file(fd, &zero, sizeof(zero));
-       if(err != sizeof(zero)){
+       if (err != sizeof(zero)) {
                cow_printf("Write of bitmap to new COW file '%s' failed, "
                           "err = %d\n", cow_file, -err);
                if (err >= 0)
@@ -429,15 +434,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
                goto out;
        }
 
-       return(0);
-
+       return 0;
  out:
-       return(err);
+       return err;
 }
-
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 3bc3cf6..6e0e891 100644 (file)
@@ -1,8 +1,11 @@
-/* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
+#ifndef __DAEMON_H__
+#define __DAEMON_H__
+
 #include "net_user.h"
 
 #define SWITCH_VERSION 3
@@ -20,16 +23,7 @@ struct daemon_data {
 
 extern const struct net_user_info daemon_user_info;
 
-extern int daemon_user_write(int fd, void *buf, int len, 
+extern int daemon_user_write(int fd, void *buf, int len,
                             struct daemon_data *pri);
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#endif
index adeece1..d53ff52 100644 (file)
@@ -1,16 +1,14 @@
 /*
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright (C) 2001 by various other people who didn't put their name here.
  * Licensed under the GPL.
  */
 
-#include "linux/kernel.h"
 #include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/etherdevice.h"
+#include <linux/netdevice.h>
 #include "net_kern.h"
-#include "net_user.h"
 #include "daemon.h"
 
 struct daemon_init {
@@ -36,25 +34,21 @@ static void daemon_init(struct net_device *dev, void *data)
        dpri->data_addr = NULL;
        dpri->local_addr = NULL;
 
-       printk("daemon backend (uml_switch version %d) - %s:%s", 
+       printk("daemon backend (uml_switch version %d) - %s:%s",
               SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
        printk("\n");
 }
 
-static int daemon_read(int fd, struct sk_buff **skb, 
-                      struct uml_net_private *lp)
+static int daemon_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
-       if(*skb == NULL) return(-ENOMEM);
-       return(net_recvfrom(fd, skb_mac_header(*skb),
-                           (*skb)->dev->mtu + ETH_HEADER_OTHER));
+       return net_recvfrom(fd, skb_mac_header(skb),
+                           skb->dev->mtu + ETH_HEADER_OTHER);
 }
 
-static int daemon_write(int fd, struct sk_buff **skb,
-                       struct uml_net_private *lp)
+static int daemon_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(daemon_user_write(fd, (*skb)->data, (*skb)->len, 
-                                (struct daemon_data *) &lp->user));
+       return daemon_user_write(fd, skb->data, skb->len,
+                                (struct daemon_data *) &lp->user);
 }
 
 static const struct net_kern_info daemon_kern_info = {
@@ -72,14 +66,14 @@ static int daemon_setup(char *str, char **mac_out, void *data)
        *init = ((struct daemon_init)
                { .sock_type            = "unix",
                  .ctl_sock             = "/tmp/uml.ctl" });
-       
+
        remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock,
                               NULL);
-       if(remain != NULL)
+       if (remain != NULL)
                printk(KERN_WARNING "daemon_setup : Ignoring data socket "
                       "specification\n");
-       
-       return(1);
+
+       return 1;
 }
 
 static struct transport daemon_transport = {
index 8d2008f..f23c109 100644 (file)
@@ -1,24 +1,23 @@
 /*
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
  * Licensed under the GPL.
  */
 
-#include <errno.h>
-#include <unistd.h>
 #include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/un.h>
 #include <sys/time.h>
-#include "net_user.h"
+#include <sys/un.h>
 #include "daemon.h"
-#include "kern_util.h"
-#include "user.h"
+#include "net_user.h"
 #include "os.h"
 #include "um_malloc.h"
-
-#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
+#include "user.h"
 
 enum request_type { REQ_NEW_CONTROL };
 
@@ -36,8 +35,9 @@ static struct sockaddr_un *new_addr(void *name, int len)
        struct sockaddr_un *sun;
 
        sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
-       if(sun == NULL){
-               printk("new_addr: allocation of sockaddr_un failed\n");
+       if (sun == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
+                      "failed\n");
                return NULL;
        }
        sun->sun_family = AF_UNIX;
@@ -54,38 +54,39 @@ static int connect_to_switch(struct daemon_data *pri)
        int fd, n, err;
 
        pri->control = socket(AF_UNIX, SOCK_STREAM, 0);
-       if(pri->control < 0){
+       if (pri->control < 0) {
                err = -errno;
-               printk("daemon_open : control socket failed, errno = %d\n", 
-                      -err);
+               printk(UM_KERN_ERR "daemon_open : control socket failed, "
+                      "errno = %d\n", -err);
                return err;
        }
 
-       if(connect(pri->control, (struct sockaddr *) ctl_addr, 
-                  sizeof(*ctl_addr)) < 0){
+       if (connect(pri->control, (struct sockaddr *) ctl_addr,
+                  sizeof(*ctl_addr)) < 0) {
                err = -errno;
-               printk("daemon_open : control connect failed, errno = %d\n",
-                      -err);
+               printk(UM_KERN_ERR "daemon_open : control connect failed, "
+                      "errno = %d\n", -err);
                goto out;
        }
 
        fd = socket(AF_UNIX, SOCK_DGRAM, 0);
-       if(fd < 0){
+       if (fd < 0) {
                err = -errno;
-               printk("daemon_open : data socket failed, errno = %d\n",
-                      -err);
+               printk(UM_KERN_ERR "daemon_open : data socket failed, "
+                      "errno = %d\n", -err);
                goto out;
        }
-       if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){
+       if (bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0) {
                err = -errno;
-               printk("daemon_open : data bind failed, errno = %d\n",
-                      -err);
+               printk(UM_KERN_ERR "daemon_open : data bind failed, "
+                      "errno = %d\n", -err);
                goto out_close;
        }
 
        sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
-       if(sun == NULL){
-               printk("new_addr: allocation of sockaddr_un failed\n");
+       if (sun == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
+                      "failed\n");
                err = -ENOMEM;
                goto out_close;
        }
@@ -94,18 +95,18 @@ static int connect_to_switch(struct daemon_data *pri)
        req.version = SWITCH_VERSION;
        req.type = REQ_NEW_CONTROL;
        req.sock = *local_addr;
-       n = os_write_file(pri->control, &req, sizeof(req));
-       if(n != sizeof(req)){
-               printk("daemon_open : control setup request failed, err = %d\n",
-                      -n);
+       n = write(pri->control, &req, sizeof(req));
+       if (n != sizeof(req)) {
+               printk(UM_KERN_ERR "daemon_open : control setup request "
+                      "failed, err = %d\n", -errno);
                err = -ENOTCONN;
                goto out_free;
        }
 
-       n = os_read_file(pri->control, sun, sizeof(*sun));
-       if(n != sizeof(*sun)){
-               printk("daemon_open : read of data socket failed, err = %d\n",
-                      -n);
+       n = read(pri->control, sun, sizeof(*sun));
+       if (n != sizeof(*sun)) {
+               printk(UM_KERN_ERR "daemon_open : read of data socket failed, "
+                      "err = %d\n", -errno);
                err = -ENOTCONN;
                goto out_free;
        }
@@ -116,9 +117,9 @@ static int connect_to_switch(struct daemon_data *pri)
  out_free:
        kfree(sun);
  out_close:
-       os_close_file(fd);
+       close(fd);
  out:
-       os_close_file(pri->control);
+       close(pri->control);
        return err;
 }
 
@@ -132,8 +133,8 @@ static int daemon_user_init(void *data, void *dev)
                int usecs;
        } name;
 
-       if(!strcmp(pri->sock_type, "unix"))
-               pri->ctl_addr = new_addr(pri->ctl_sock, 
+       if (!strcmp(pri->sock_type, "unix"))
+               pri->ctl_addr = new_addr(pri->ctl_sock,
                                         strlen(pri->ctl_sock) + 1);
        name.zero = 0;
        name.pid = os_getpid();
@@ -142,7 +143,7 @@ static int daemon_user_init(void *data, void *dev)
        pri->local_addr = new_addr(&name, sizeof(name));
        pri->dev = dev;
        pri->fd = connect_to_switch(pri);
-       if(pri->fd < 0){
+       if (pri->fd < 0) {
                kfree(pri->local_addr);
                pri->local_addr = NULL;
                return pri->fd;
@@ -161,9 +162,9 @@ static void daemon_remove(void *data)
 {
        struct daemon_data *pri = data;
 
-       os_close_file(pri->fd);
+       close(pri->fd);
        pri->fd = -1;
-       os_close_file(pri->control);
+       close(pri->control);
        pri->control = -1;
 
        kfree(pri->data_addr);
@@ -181,18 +182,13 @@ int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri)
        return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
-static int daemon_set_mtu(int mtu, void *data)
-{
-       return mtu;
-}
-
 const struct net_user_info daemon_user_info = {
        .init           = daemon_user_init,
        .open           = daemon_open,
        .close          = NULL,
        .remove         = daemon_remove,
-       .set_mtu        = daemon_set_mtu,
        .add_address    = NULL,
        .delete_address = NULL,
-       .max_packet     = MAX_PACKET - ETH_HEADER_OTHER
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_OTHER,
 };
index 39c01ff..0a2bb5b 100644 (file)
@@ -1,17 +1,18 @@
-/* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <termios.h>
 #include <errno.h>
-#include "user.h"
+#include <termios.h>
 #include "chan_user.h"
+#include "kern_constants.h"
 #include "os.h"
 #include "um_malloc.h"
+#include "user.h"
 
 struct fd_chan {
        int fd;
@@ -26,22 +27,26 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
        char *end;
        int n;
 
-       if(*str != ':'){
-               printk("fd_init : channel type 'fd' must specify a file "
-                      "descriptor\n");
-               return(NULL);
+       if (*str != ':') {
+               printk(UM_KERN_ERR "fd_init : channel type 'fd' must specify a "
+                      "file descriptor\n");
+               return NULL;
        }
        str++;
        n = strtoul(str, &end, 0);
-       if((*end != '\0') || (end == str)){
-               printk("fd_init : couldn't parse file descriptor '%s'\n", str);
-               return(NULL);
+       if ((*end != '\0') || (end == str)) {
+               printk(UM_KERN_ERR "fd_init : couldn't parse file descriptor "
+                      "'%s'\n", str);
+               return NULL;
        }
+
        data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
-       if(data == NULL) return(NULL);
+       if (data == NULL)
+               return NULL;
+
        *data = ((struct fd_chan) { .fd         = n,
                                    .raw        = opts->raw });
-       return(data);
+       return data;
 }
 
 static int fd_open(int input, int output, int primary, void *d, char **dev_out)
@@ -49,18 +54,18 @@ static int fd_open(int input, int output, int primary, void *d, char **dev_out)
        struct fd_chan *data = d;
        int err;
 
-       if(data->raw && isatty(data->fd)){
+       if (data->raw && isatty(data->fd)) {
                CATCH_EINTR(err = tcgetattr(data->fd, &data->tt));
-               if(err)
-                       return(err);
+               if (err)
+                       return err;
 
                err = raw(data->fd);
-               if(err)
-                       return(err);
+               if (err)
+                       return err;
        }
        sprintf(data->str, "%d", data->fd);
        *dev_out = data->str;
-       return(data->fd);
+       return data->fd;
 }
 
 static void fd_close(int fd, void *d)
@@ -68,13 +73,14 @@ static void fd_close(int fd, void *d)
        struct fd_chan *data = d;
        int err;
 
-       if(data->raw && isatty(fd)){
-               CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &data->tt));
-               if(err)
-                       printk("Failed to restore terminal state - "
-                              "errno = %d\n", -err);
-               data->raw = 0;
-       }
+       if (!data->raw || !isatty(fd))
+               return;
+
+       CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &data->tt));
+       if (err)
+               printk(UM_KERN_ERR "Failed to restore terminal state - "
+                      "errno = %d\n", -err);
+       data->raw = 0;
 }
 
 const struct chan_ops fd_ops = {
@@ -89,14 +95,3 @@ const struct chan_ops fd_ops = {
        .free           = generic_free,
        .winch          = 1,
 };
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 5560168..a9ad4bd 100644 (file)
@@ -69,7 +69,7 @@ static int harddog_open(struct inode *inode, struct file *file)
        spin_lock(&lock);
        if(timer_alive)
                goto err;
-#ifdef CONFIG_HARDDOG_NOWAYOUT
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
        __module_get(THIS_MODULE);
 #endif
 
index 1171790..b56f8e0 100644 (file)
@@ -1,16 +1,13 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-#include "user.h"
-#include "mconsole.h"
 #include "os.h"
-#include "choose-mode.h"
-#include "mode.h"
+#include "user.h"
 
 struct dog_data {
        int stdin;
@@ -25,10 +22,10 @@ static void pre_exec(void *d)
        dup2(data->stdin, 0);
        dup2(data->stdout, 1);
        dup2(data->stdout, 2);
-       os_close_file(data->stdin);
-       os_close_file(data->stdout);
-       os_close_file(data->close_me[0]);
-       os_close_file(data->close_me[1]);
+       close(data->stdin);
+       close(data->stdout);
+       close(data->close_me[0]);
+       close(data->close_me[1]);
 }
 
 int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
@@ -42,13 +39,13 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        char **args = NULL;
 
        err = os_pipe(in_fds, 1, 0);
-       if(err < 0){
+       if (err < 0) {
                printk("harddog_open - os_pipe failed, err = %d\n", -err);
                goto out;
        }
 
        err = os_pipe(out_fds, 1, 0);
-       if(err < 0){
+       if (err < 0) {
                printk("harddog_open - os_pipe failed, err = %d\n", -err);
                goto out_close_in;
        }
@@ -58,37 +55,37 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        data.close_me[0] = out_fds[1];
        data.close_me[1] = in_fds[0];
 
-       if(sock != NULL){
+       if (sock != NULL) {
                mconsole_args[2] = sock;
                args = mconsole_args;
        }
        else {
                /* XXX The os_getpid() is not SMP correct */
-               sprintf(pid_buf, "%d", CHOOSE_MODE(tracing_pid, os_getpid()));
+               sprintf(pid_buf, "%d", os_getpid());
                args = pid_args;
        }
 
        pid = run_helper(pre_exec, &data, args);
 
-       os_close_file(out_fds[0]);
-       os_close_file(in_fds[1]);
+       close(out_fds[0]);
+       close(in_fds[1]);
 
-       if(pid < 0){
+       if (pid < 0) {
                err = -pid;
                printk("harddog_open - run_helper failed, errno = %d\n", -err);
                goto out_close_out;
        }
 
-       n = os_read_file(in_fds[0], &c, sizeof(c));
-       if(n == 0){
+       n = read(in_fds[0], &c, sizeof(c));
+       if (n == 0) {
                printk("harddog_open - EOF on watchdog pipe\n");
                helper_wait(pid);
                err = -EIO;
                goto out_close_out;
        }
-       else if(n < 0){
+       else if (n < 0) {
                printk("harddog_open - read of watchdog pipe failed, "
-                      "err = %d\n", -n);
+                      "err = %d\n", errno);
                helper_wait(pid);
                err = n;
                goto out_close_out;
@@ -98,19 +95,19 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
        return 0;
 
  out_close_in:
-       os_close_file(in_fds[0]);
-       os_close_file(in_fds[1]);
+       close(in_fds[0]);
+       close(in_fds[1]);
  out_close_out:
-       os_close_file(out_fds[0]);
-       os_close_file(out_fds[1]);
+       close(out_fds[0]);
+       close(out_fds[1]);
  out:
        return err;
 }
 
 void stop_watchdog(int in_fd, int out_fd)
 {
-       os_close_file(in_fd);
-       os_close_file(out_fd);
+       close(in_fd);
+       close(out_fd);
 }
 
 int ping_watchdog(int fd)
@@ -118,10 +115,11 @@ int ping_watchdog(int fd)
        int n;
        char c = '\n';
 
-       n = os_write_file(fd, &c, sizeof(c));
-       if(n != sizeof(c)){
-               printk("ping_watchdog - write failed, err = %d\n", -n);
-               if(n < 0)
+       n = write(fd, &c, sizeof(c));
+       if (n != sizeof(c)) {
+               printk("ping_watchdog - write failed, ret = %d, err = %d\n",
+                      n, errno);
+               if (n < 0)
                        return n;
                return -EIO;
        }
index 10e08a8..ff1b22b 100644 (file)
@@ -1,16 +1,14 @@
-/* 
- * Copyright (C) 2002 Steve Schmidtke 
+/*
+ * Copyright (C) 2002 Steve Schmidtke
  * Licensed under the GPL
  */
 
+#include "linux/fs.h"
 #include "linux/module.h"
-#include "linux/init.h"
 #include "linux/slab.h"
-#include "linux/fs.h"
 #include "linux/sound.h"
 #include "linux/soundcard.h"
 #include "asm/uaccess.h"
-#include "kern_util.h"
 #include "init.h"
 #include "os.h"
 
@@ -25,7 +23,8 @@ struct hostmixer_state {
 #define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
 #define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
 
-/* Changed either at boot time or module load time.  At boot, this is
+/*
+ * Changed either at boot time or module load time.  At boot, this is
  * single-threaded; at module load, multiple modules would each have
  * their own copy of these variables.
  */
@@ -44,7 +43,7 @@ static char *mixer = HOSTAUDIO_DEV_MIXER;
 static int set_dsp(char *name, int *add)
 {
        dsp = name;
-       return(0);
+       return 0;
 }
 
 __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
@@ -52,7 +51,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
 static int set_mixer(char *name, int *add)
 {
        mixer = name;
-       return(0);
+       return 0;
 }
 
 __uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
@@ -77,23 +76,23 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
        int err;
 
 #ifdef DEBUG
-       printk("hostaudio: read called, count = %d\n", count);
+       printk(KERN_DEBUG "hostaudio: read called, count = %d\n", count);
 #endif
 
        kbuf = kmalloc(count, GFP_KERNEL);
-       if(kbuf == NULL)
-               return(-ENOMEM);
+       if (kbuf == NULL)
+               return -ENOMEM;
 
        err = os_read_file(state->fd, kbuf, count);
-       if(err < 0)
+       if (err < 0)
                goto out;
 
-       if(copy_to_user(buffer, kbuf, err))
+       if (copy_to_user(buffer, kbuf, err))
                err = -EFAULT;
 
 out:
        kfree(kbuf);
-       return(err);
+       return err;
 }
 
 static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
@@ -104,40 +103,40 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
        int err;
 
 #ifdef DEBUG
-       printk("hostaudio: write called, count = %d\n", count);
+       printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
 #endif
 
        kbuf = kmalloc(count, GFP_KERNEL);
-       if(kbuf == NULL)
-               return(-ENOMEM);
+       if (kbuf == NULL)
+               return -ENOMEM;
 
        err = -EFAULT;
-       if(copy_from_user(kbuf, buffer, count))
+       if (copy_from_user(kbuf, buffer, count))
                goto out;
 
        err = os_write_file(state->fd, kbuf, count);
-       if(err < 0)
+       if (err < 0)
                goto out;
        *ppos += err;
 
  out:
        kfree(kbuf);
-       return(err);
+       return err;
 }
 
-static unsigned int hostaudio_poll(struct file *file, 
+static unsigned int hostaudio_poll(struct file *file,
                                   struct poll_table_struct *wait)
 {
        unsigned int mask = 0;
 
 #ifdef DEBUG
-       printk("hostaudio: poll called (unimplemented)\n");
+       printk(KERN_DEBUG "hostaudio: poll called (unimplemented)\n");
 #endif
 
-       return(mask);
+       return mask;
 }
 
-static int hostaudio_ioctl(struct inode *inode, struct file *file, 
+static int hostaudio_ioctl(struct inode *inode, struct file *file,
                           unsigned int cmd, unsigned long arg)
 {
        struct hostaudio_state *state = file->private_data;
@@ -145,7 +144,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
        int err;
 
 #ifdef DEBUG
-       printk("hostaudio: ioctl called, cmd = %u\n", cmd);
+       printk(KERN_DEBUG "hostaudio: ioctl called, cmd = %u\n", cmd);
 #endif
        switch(cmd){
        case SNDCTL_DSP_SPEED:
@@ -154,8 +153,8 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
        case SNDCTL_DSP_CHANNELS:
        case SNDCTL_DSP_SUBDIVIDE:
        case SNDCTL_DSP_SETFRAGMENT:
-               if(get_user(data, (int __user *) arg))
-                       return(-EFAULT);
+               if (get_user(data, (int __user *) arg))
+                       return EFAULT;
                break;
        default:
                break;
@@ -170,14 +169,14 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
        case SNDCTL_DSP_CHANNELS:
        case SNDCTL_DSP_SUBDIVIDE:
        case SNDCTL_DSP_SETFRAGMENT:
-               if(put_user(data, (int __user *) arg))
-                       return(-EFAULT);
+               if (put_user(data, (int __user *) arg))
+                       return -EFAULT;
                break;
        default:
                break;
        }
 
-       return(err);
+       return err;
 }
 
 static int hostaudio_open(struct inode *inode, struct file *file)
@@ -187,24 +186,26 @@ static int hostaudio_open(struct inode *inode, struct file *file)
        int ret;
 
 #ifdef DEBUG
-       printk("hostaudio: open called (host: %s)\n", dsp);
+       printk(KERN_DEBUG "hostaudio: open called (host: %s)\n", dsp);
 #endif
 
        state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
-       if(state == NULL)
-               return(-ENOMEM);
+       if (state == NULL)
+               return -ENOMEM;
 
-       if(file->f_mode & FMODE_READ) r = 1;
-       if(file->f_mode & FMODE_WRITE) w = 1;
+       if (file->f_mode & FMODE_READ)
+               r = 1;
+       if (file->f_mode & FMODE_WRITE)
+               w = 1;
 
        ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-       if(ret < 0){
+       if (ret < 0) {
                kfree(state);
-               return(ret);
+               return ret;
        }
        state->fd = ret;
        file->private_data = state;
-       return(0);
+       return 0;
 }
 
 static int hostaudio_release(struct inode *inode, struct file *file)
@@ -212,26 +213,26 @@ static int hostaudio_release(struct inode *inode, struct file *file)
        struct hostaudio_state *state = file->private_data;
 
 #ifdef DEBUG
-       printk("hostaudio: release called\n");
+       printk(KERN_DEBUG "hostaudio: release called\n");
 #endif
        os_close_file(state->fd);
        kfree(state);
 
-       return(0);
+       return 0;
 }
 
 /* /dev/mixer file operations */
 
-static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file, 
+static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
                                  unsigned int cmd, unsigned long arg)
 {
        struct hostmixer_state *state = file->private_data;
 
 #ifdef DEBUG
-       printk("hostmixer: ioctl called\n");
+       printk(KERN_DEBUG "hostmixer: ioctl called\n");
 #endif
 
-       return(os_ioctl_generic(state->fd, cmd, arg));
+       return os_ioctl_generic(state->fd, cmd, arg);
 }
 
 static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
@@ -241,26 +242,29 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
        int ret;
 
 #ifdef DEBUG
-       printk("hostmixer: open called (host: %s)\n", mixer);
+       printk(KERN_DEBUG "hostmixer: open called (host: %s)\n", mixer);
 #endif
 
        state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
-       if(state == NULL) return(-ENOMEM);
+       if (state == NULL)
+               return -ENOMEM;
 
-       if(file->f_mode & FMODE_READ) r = 1;
-       if(file->f_mode & FMODE_WRITE) w = 1;
+       if (file->f_mode & FMODE_READ)
+               r = 1;
+       if (file->f_mode & FMODE_WRITE)
+               w = 1;
 
        ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
-        
-       if(ret < 0){
-               printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
-                      dsp, -ret);
+
+       if (ret < 0) {
+               printk(KERN_ERR "hostaudio_open_mixdev failed to open '%s', "
+                      "err = %d\n", dsp, -ret);
                kfree(state);
-               return(ret);
+               return ret;
        }
 
        file->private_data = state;
-       return(0);
+       return 0;
 }
 
 static int hostmixer_release(struct inode *inode, struct file *file)
@@ -268,13 +272,13 @@ static int hostmixer_release(struct inode *inode, struct file *file)
        struct hostmixer_state *state = file->private_data;
 
 #ifdef DEBUG
-       printk("hostmixer: release called\n");
+       printk(KERN_DEBUG "hostmixer: release called\n");
 #endif
 
        os_close_file(state->fd);
        kfree(state);
 
-       return(0);
+       return 0;
 }
 
 /* kernel module operations */
@@ -314,13 +318,13 @@ static int __init hostaudio_init_module(void)
               dsp, mixer);
 
        module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
-       if(module_data.dev_audio < 0){
+       if (module_data.dev_audio < 0) {
                printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
                return -ENODEV;
        }
 
        module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
-       if(module_data.dev_mixer < 0){
+       if (module_data.dev_mixer < 0) {
                printk(KERN_ERR "hostmixer: couldn't register mixer "
                       "device!\n");
                unregister_sound_dsp(module_data.dev_audio);
index 3e0b68e..83bf15a 100644 (file)
@@ -1,22 +1,14 @@
 /*
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "linux/sched.h"
-#include "linux/slab.h"
-#include "linux/list.h"
+#include "linux/irqreturn.h"
 #include "linux/kd.h"
-#include "linux/interrupt.h"
-#include "asm/uaccess.h"
 #include "chan_kern.h"
+#include "irq_kern.h"
 #include "irq_user.h"
-#include "line.h"
-#include "kern.h"
-#include "kern_util.h"
 #include "os.h"
-#include "irq_kern.h"
 
 #define LINE_BUFSIZE 4096
 
@@ -35,14 +27,15 @@ static void line_timer_cb(struct work_struct *work)
 {
        struct line *line = container_of(work, struct line, task.work);
 
-       if(!line->throttled)
+       if (!line->throttled)
                chan_interrupt(&line->chan_list, &line->task, line->tty,
                               line->driver->read_irq);
 }
 
-/* Returns the free space inside the ring buffer of this line.
+/*
+ * Returns the free space inside the ring buffer of this line.
  *
- * Should be called while holding line->lock (this does not modify datas).
+ * Should be called while holding line->lock (this does not modify data).
  */
 static int write_room(struct line *line)
 {
@@ -107,11 +100,12 @@ static int buffer_data(struct line *line, const char *buf, int len)
 {
        int end, room;
 
-       if(line->buffer == NULL){
+       if (line->buffer == NULL) {
                line->buffer = kmalloc(LINE_BUFSIZE, GFP_ATOMIC);
                if (line->buffer == NULL) {
-                       printk("buffer_data - atomic allocation failed\n");
-                       return(0);
+                       printk(KERN_ERR "buffer_data - atomic allocation "
+                              "failed\n");
+                       return 0;
                }
                line->head = line->buffer;
                line->tail = line->buffer;
@@ -122,7 +116,7 @@ static int buffer_data(struct line *line, const char *buf, int len)
 
        end = line->buffer + LINE_BUFSIZE - line->tail;
 
-       if (len < end){
+       if (len < end) {
                memcpy(line->tail, buf, len);
                line->tail += len;
        }
@@ -162,8 +156,10 @@ static int flush_buffer(struct line *line)
                if (n < 0)
                        return n;
                if (n == count) {
-                       /* We have flushed from ->head to buffer end, now we
-                        * must flush only from the beginning to ->tail.*/
+                       /*
+                        * We have flushed from ->head to buffer end, now we
+                        * must flush only from the beginning to ->tail.
+                        */
                        line->head = line->buffer;
                } else {
                        line->head += n;
@@ -175,7 +171,7 @@ static int flush_buffer(struct line *line)
        n = write_chan(&line->chan_list, line->head, count,
                       line->driver->write_irq);
 
-       if(n < 0)
+       if (n < 0)
                return n;
 
        line->head += n;
@@ -189,19 +185,18 @@ void line_flush_buffer(struct tty_struct *tty)
        int err;
 
        /*XXX: copied from line_write, verify if it is correct!*/
-       if(tty->stopped)
+       if (tty->stopped)
                return;
 
        spin_lock_irqsave(&line->lock, flags);
        err = flush_buffer(line);
-       /*if (err == 1)
-               err = 0;*/
        spin_unlock_irqrestore(&line->lock, flags);
-       //return err;
 }
 
-/* We map both ->flush_chars and ->put_char (which go in pair) onto ->flush_buffer
- * and ->write. Hope it's not that bad.*/
+/*
+ * We map both ->flush_chars and ->put_char (which go in pair) onto
+ * ->flush_buffer and ->write. Hope it's not that bad.
+ */
 void line_flush_chars(struct tty_struct *tty)
 {
        line_flush_buffer(tty);
@@ -216,18 +211,15 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
 {
        struct line *line = tty->driver_data;
        unsigned long flags;
-       int n, err, ret = 0;
+       int n, ret = 0;
 
-       if(tty->stopped)
+       if (tty->stopped)
                return 0;
 
        spin_lock_irqsave(&line->lock, flags);
-       if (line->head != line->tail) {
+       if (line->head != line->tail)
                ret = buffer_data(line, buf, len);
-               err = flush_buffer(line);
-               if (err <= 0 && (err != -EAGAIN || !ret))
-                       ret = err;
-       } else {
+       else {
                n = write_chan(&line->chan_list, buf, len,
                               line->driver->write_irq);
                if (n < 0) {
@@ -257,17 +249,17 @@ static const struct {
 } tty_ioctls[] = {
        /* don't print these, they flood the log ... */
        { TCGETS,      NULL,       "TCGETS"      },
-        { TCSETS,      NULL,       "TCSETS"      },
-        { TCSETSW,     NULL,       "TCSETSW"     },
-        { TCFLSH,      NULL,       "TCFLSH"      },
-        { TCSBRK,      NULL,       "TCSBRK"      },
+       { TCSETS,      NULL,       "TCSETS"      },
+       { TCSETSW,     NULL,       "TCSETSW"     },
+       { TCFLSH,      NULL,       "TCFLSH"      },
+       { TCSBRK,      NULL,       "TCSBRK"      },
 
        /* general tty stuff */
-        { TCSETSF,     KERN_DEBUG, "TCSETSF"     },
-        { TCGETA,      KERN_DEBUG, "TCGETA"      },
-        { TIOCMGET,    KERN_DEBUG, "TIOCMGET"    },
-        { TCSBRKP,     KERN_DEBUG, "TCSBRKP"     },
-        { TIOCMSET,    KERN_DEBUG, "TIOCMSET"    },
+       { TCSETSF,     KERN_DEBUG, "TCSETSF"     },
+       { TCGETA,      KERN_DEBUG, "TCGETA"      },
+       { TIOCMGET,    KERN_DEBUG, "TIOCMGET"    },
+       { TCSBRKP,     KERN_DEBUG, "TCSBRKP"     },
+       { TIOCMSET,    KERN_DEBUG, "TIOCMSET"    },
 
        /* linux-specific ones */
        { TIOCLINUX,   KERN_INFO,  "TIOCLINUX"   },
@@ -324,12 +316,7 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
                for (i = 0; i < ARRAY_SIZE(tty_ioctls); i++)
                        if (cmd == tty_ioctls[i].cmd)
                                break;
-               if (i < ARRAY_SIZE(tty_ioctls)) {
-                       if (NULL != tty_ioctls[i].level)
-                               printk("%s%s: %s: ioctl %s called\n",
-                                      tty_ioctls[i].level, __FUNCTION__,
-                                      tty->name, tty_ioctls[i].name);
-               } else {
+               if (i == ARRAY_SIZE(tty_ioctls)) {
                        printk(KERN_ERR "%s: %s: unknown ioctl: 0x%x\n",
                               __FUNCTION__, tty->name, cmd);
                }
@@ -355,11 +342,12 @@ void line_unthrottle(struct tty_struct *tty)
        chan_interrupt(&line->chan_list, &line->task, tty,
                       line->driver->read_irq);
 
-       /* Maybe there is enough stuff pending that calling the interrupt
+       /*
+        * Maybe there is enough stuff pending that calling the interrupt
         * throttles us again.  In this case, line->throttled will be 1
         * again and we shouldn't turn the interrupt back on.
         */
-       if(!line->throttled)
+       if (!line->throttled)
                reactivate_chan(&line->chan_list, line->driver->read_irq);
 }
 
@@ -370,27 +358,30 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
        struct tty_struct *tty = line->tty;
        int err;
 
-       /* Interrupts are disabled here because we registered the interrupt with
-        * IRQF_DISABLED (see line_setup_irq).*/
+       /*
+        * Interrupts are disabled here because we registered the interrupt with
+        * IRQF_DISABLED (see line_setup_irq).
+        */
 
        spin_lock(&line->lock);
        err = flush_buffer(line);
        if (err == 0) {
                return IRQ_NONE;
-       } else if(err < 0) {
+       } else if (err < 0) {
                line->head = line->buffer;
                line->tail = line->buffer;
        }
        spin_unlock(&line->lock);
 
-       if(tty == NULL)
+       if (tty == NULL)
                return IRQ_NONE;
 
        if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
           (tty->ldisc.write_wakeup != NULL))
                (tty->ldisc.write_wakeup)(tty);
 
-       /* BLOCKING mode
+       /*
+        * BLOCKING mode
         * In blocking mode, everything sleeps on tty->write_wait.
         * Sleeping in the console driver would break non-blocking
         * writes.
@@ -420,7 +411,8 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
        return err;
 }
 
-/* Normally, a driver like this can rely mostly on the tty layer
+/*
+ * Normally, a driver like this can rely mostly on the tty layer
  * locking, particularly when it comes to the driver structure.
  * However, in this case, mconsole requests can come in "from the
  * side", and race with opens and closes.
@@ -442,11 +434,11 @@ int line_open(struct line *lines, struct tty_struct *tty)
        int err = -ENODEV;
 
        spin_lock(&line->count_lock);
-       if(!line->valid)
+       if (!line->valid)
                goto out_unlock;
 
        err = 0;
-       if(tty->count > 1)
+       if (tty->count > 1)
                goto out_unlock;
 
        spin_unlock(&line->count_lock);
@@ -460,7 +452,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
 
        INIT_DELAYED_WORK(&line->task, line_timer_cb);
 
-       if(!line->sigio){
+       if (!line->sigio) {
                chan_enable_winch(&line->chan_list, tty);
                line->sigio = 1;
        }
@@ -481,20 +473,21 @@ void line_close(struct tty_struct *tty, struct file * filp)
 {
        struct line *line = tty->driver_data;
 
-       /* If line_open fails (and tty->driver_data is never set),
+       /*
+        * If line_open fails (and tty->driver_data is never set),
         * tty_open will call line_close.  So just return in this case.
         */
-       if(line == NULL)
+       if (line == NULL)
                return;
 
        /* We ignore the error anyway! */
        flush_buffer(line);
 
        spin_lock(&line->count_lock);
-       if(!line->valid)
+       if (!line->valid)
                goto out_unlock;
 
-       if(tty->count > 1)
+       if (tty->count > 1)
                goto out_unlock;
 
        spin_unlock(&line->count_lock);
@@ -502,10 +495,10 @@ void line_close(struct tty_struct *tty, struct file * filp)
        line->tty = NULL;
        tty->driver_data = NULL;
 
-       if(line->sigio){
+       if (line->sigio) {
                unregister_winch(tty);
                line->sigio = 0;
-        }
+       }
 
        return;
 
@@ -529,12 +522,12 @@ static int setup_one_line(struct line *lines, int n, char *init, int init_prio,
 
        spin_lock(&line->count_lock);
 
-       if(line->tty != NULL){
+       if (line->tty != NULL) {
                *error_out = "Device is already open";
                goto out;
        }
 
-       if (line->init_pri <= init_prio){
+       if (line->init_pri <= init_prio) {
                line->init_pri = init_prio;
                if (!strcmp(init, "none"))
                        line->valid = 0;
@@ -549,7 +542,8 @@ out:
        return err;
 }
 
-/* Common setup code for both startup command line and mconsole initialization.
+/*
+ * Common setup code for both startup command line and mconsole initialization.
  * @lines contains the array (of size @num) to modify;
  * @init is the setup string;
  * @error_out is an error string in the case of failure;
@@ -561,14 +555,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
        int i, n, err;
        char *end;
 
-       if(*init == '=') {
-               /* We said con=/ssl= instead of con#=, so we are configuring all
-                * consoles at once.*/
+       if (*init == '=') {
+               /*
+                * We said con=/ssl= instead of con#=, so we are configuring all
+                * consoles at once.
+                */
                n = -1;
        }
        else {
                n = simple_strtoul(init, &end, 0);
-               if(*end != '='){
+               if (*end != '=') {
                        *error_out = "Couldn't parse device number";
                        return -EINVAL;
                }
@@ -580,16 +576,16 @@ int line_setup(struct line *lines, unsigned int num, char *init,
                *error_out = "Device number out of range";
                return -EINVAL;
        }
-       else if (n >= 0){
+       else if (n >= 0) {
                err = setup_one_line(lines, n, init, INIT_ONE, error_out);
-               if(err)
+               if (err)
                        return err;
        }
        else {
-               for(i = 0; i < num; i++){
+               for(i = 0; i < num; i++) {
                        err = setup_one_line(lines, i, init, INIT_ALL,
                                             error_out);
-                       if(err)
+                       if (err)
                                return err;
                }
        }
@@ -603,18 +599,18 @@ int line_config(struct line *lines, unsigned int num, char *str,
        char *new;
        int n;
 
-       if(*str == '='){
+       if (*str == '=') {
                *error_out = "Can't configure all devices from mconsole";
                return -EINVAL;
        }
 
        new = kstrdup(str, GFP_KERNEL);
-       if(new == NULL){
+       if (new == NULL) {
                *error_out = "Failed to allocate memory";
                return -ENOMEM;
        }
        n = line_setup(lines, num, new, error_out);
-       if(n < 0)
+       if (n < 0)
                return n;
 
        line = &lines[n];
@@ -629,12 +625,12 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
        int dev, n = 0;
 
        dev = simple_strtoul(name, &end, 0);
-       if((*end != '\0') || (end == name)){
+       if ((*end != '\0') || (end == name)) {
                *error_out = "line_get_config failed to parse device number";
                return 0;
        }
 
-       if((dev < 0) || (dev >= num)){
+       if ((dev < 0) || (dev >= num)) {
                *error_out = "device number out of range";
                return 0;
        }
@@ -642,9 +638,9 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
        line = &lines[dev];
 
        spin_lock(&line->count_lock);
-       if(!line->valid)
+       if (!line->valid)
                CONFIG_CHUNK(str, size, n, "none", 1);
-       else if(line->tty == NULL)
+       else if (line->tty == NULL)
                CONFIG_CHUNK(str, size, n, line->init_str, 1);
        else n = chan_config_string(&line->chan_list, str, size, error_out);
        spin_unlock(&line->count_lock);
@@ -655,16 +651,16 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
 int line_id(char **str, int *start_out, int *end_out)
 {
        char *end;
-        int n;
+       int n;
 
        n = simple_strtoul(*str, &end, 0);
-       if((*end != '\0') || (end == *str))
-                return -1;
+       if ((*end != '\0') || (end == *str))
+               return -1;
 
-        *str = end;
-        *start_out = n;
-        *end_out = n;
-        return n;
+       *str = end;
+       *start_out = n;
+       *end_out = n;
+       return n;
 }
 
 int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
@@ -674,7 +670,7 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
 
        sprintf(config, "%d=none", n);
        err = line_setup(lines, num, config, error_out);
-       if(err >= 0)
+       if (err >= 0)
                err = 0;
        return err;
 }
@@ -700,14 +696,14 @@ struct tty_driver *register_lines(struct line_driver *line_driver,
        tty_set_operations(driver, ops);
 
        if (tty_register_driver(driver)) {
-               printk("%s: can't register %s driver\n",
-                      __FUNCTION__,line_driver->name);
+               printk(KERN_ERR "register_lines : can't register %s driver\n",
+                      line_driver->name);
                put_tty_driver(driver);
                return NULL;
        }
 
-       for(i = 0; i < nlines; i++){
-               if(!lines[i].valid)
+       for(i = 0; i < nlines; i++) {
+               if (!lines[i].valid)
                        tty_unregister_device(driver, i);
        }
 
@@ -724,20 +720,20 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
        char *error;
        int i;
 
-       for(i = 0; i < nlines; i++){
+       for(i = 0; i < nlines; i++) {
                line = &lines[i];
                INIT_LIST_HEAD(&line->chan_list);
 
-               if(line->init_str == NULL)
+               if (line->init_str == NULL)
                        continue;
 
                line->init_str = kstrdup(line->init_str, GFP_KERNEL);
-               if(line->init_str == NULL)
-                       printk("lines_init - kstrdup returned NULL\n");
+               if (line->init_str == NULL)
+                       printk(KERN_ERR "lines_init - kstrdup returned NULL\n");
 
-               if(parse_chan_pair(line->init_str, line, i, opts, &error)){
-                       printk("parse_chan_pair failed for device %d : %s\n",
-                              i, error);
+               if (parse_chan_pair(line->init_str, line, i, opts, &error)) {
+                       printk(KERN_ERR "parse_chan_pair failed for "
+                              "device %d : %s\n", i, error);
                        line->valid = 0;
                }
        }
@@ -775,14 +771,14 @@ static irqreturn_t winch_interrupt(int irq, void *data)
        int err;
        char c;
 
-       if(winch->fd != -1){
+       if (winch->fd != -1) {
                err = generic_read(winch->fd, &c, NULL);
-               if(err < 0){
-                       if(err != -EAGAIN){
-                               printk("winch_interrupt : read failed, "
-                                      "errno = %d\n", -err);
-                               printk("fd %d is losing SIGWINCH support\n",
-                                      winch->tty_fd);
+               if (err < 0) {
+                       if (err != -EAGAIN) {
+                               printk(KERN_ERR "winch_interrupt : "
+                                      "read failed, errno = %d\n", -err);
+                               printk(KERN_ERR "fd %d is losing SIGWINCH "
+                                      "support\n", winch->tty_fd);
                                free_winch(winch, 0);
                                return IRQ_HANDLED;
                        }
@@ -797,7 +793,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
                kill_pgrp(tty->pgrp, SIGWINCH, 1);
        }
  out:
-       if(winch->fd != -1)
+       if (winch->fd != -1)
                reactivate_fd(winch->fd, WINCH_IRQ);
        return IRQ_HANDLED;
 }
@@ -809,7 +805,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
 
        winch = kmalloc(sizeof(*winch), GFP_KERNEL);
        if (winch == NULL) {
-               printk("register_winch_irq - kmalloc failed\n");
+               printk(KERN_ERR "register_winch_irq - kmalloc failed\n");
                goto cleanup;
        }
 
@@ -823,7 +819,8 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
        if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
                           IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
                           "winch", winch) < 0) {
-               printk("register_winch_irq - failed to register IRQ\n");
+               printk(KERN_ERR "register_winch_irq - failed to register "
+                      "IRQ\n");
                goto out_free;
        }
 
@@ -849,13 +846,13 @@ static void unregister_winch(struct tty_struct *tty)
 
        spin_lock(&winch_handler_lock);
 
-       list_for_each(ele, &winch_handlers){
+       list_for_each(ele, &winch_handlers) {
                winch = list_entry(ele, struct winch, list);
-                if(winch->tty == tty){
+               if (winch->tty == tty) {
                        free_winch(winch, 1);
                        break;
-                }
-        }
+               }
+       }
        spin_unlock(&winch_handler_lock);
 }
 
@@ -866,7 +863,7 @@ static void winch_cleanup(void)
 
        spin_lock(&winch_handler_lock);
 
-       list_for_each_safe(ele, next, &winch_handlers){
+       list_for_each_safe(ele, next, &winch_handlers) {
                winch = list_entry(ele, struct winch, list);
                free_winch(winch, 1);
        }
@@ -881,13 +878,13 @@ char *add_xterm_umid(char *base)
        int len;
 
        umid = get_umid();
-       if(*umid == '\0')
+       if (*umid == '\0')
                return base;
 
        len = strlen(base) + strlen(" ()") + strlen(umid) + 1;
        title = kmalloc(len, GFP_KERNEL);
-       if(title == NULL){
-               printk("Failed to allocate buffer for xterm title\n");
+       if (title == NULL) {
+               printk(KERN_ERR "Failed to allocate buffer for xterm title\n");
                return base;
        }
 
index bc56af9..6fa282e 100644 (file)
@@ -1,8 +1,11 @@
 /* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
+#ifndef __DRIVERS_MCAST_H
+#define __DRIVERS_MCAST_H
+
 #include "net_user.h"
 
 struct mcast_data {
@@ -18,13 +21,4 @@ extern const struct net_user_info mcast_user_info;
 extern int mcast_user_write(int fd, void *buf, int len, 
                            struct mcast_data *pri);
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#endif
index e6b8e0d..822092f 100644 (file)
@@ -1,24 +1,20 @@
 /*
  * user-mode-linux networking multicast transport
  * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  *
  * based on the existing uml-networking code, which is
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
  *
  * Licensed under the GPL.
  */
 
-#include "linux/kernel.h"
 #include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/etherdevice.h"
-#include "linux/in.h"
-#include "linux/inet.h"
-#include "net_kern.h"
-#include "net_user.h"
+#include <linux/netdevice.h>
 #include "mcast.h"
+#include "net_kern.h"
 
 struct mcast_init {
        char *addr;
@@ -39,26 +35,20 @@ static void mcast_init(struct net_device *dev, void *data)
        dpri->ttl = init->ttl;
        dpri->dev = dev;
 
-       printk("mcast backend ");
-       printk("multicast address: %s:%u, TTL:%u ",
+       printk("mcast backend multicast address: %s:%u, TTL:%u\n",
               dpri->addr, dpri->port, dpri->ttl);
-
-       printk("\n");
 }
 
-static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
+static int mcast_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
-       if(*skb == NULL) return(-ENOMEM);
-       return(net_recvfrom(fd, skb_mac_header(*skb),
-                           (*skb)->dev->mtu + ETH_HEADER_OTHER));
+       return net_recvfrom(fd, skb_mac_header(skb),
+                           skb->dev->mtu + ETH_HEADER_OTHER);
 }
 
-static int mcast_write(int fd, struct sk_buff **skb,
-                       struct uml_net_private *lp)
+static int mcast_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return mcast_user_write(fd, (*skb)->data, (*skb)->len, 
-                                (struct mcast_data *) &lp->user);
+       return mcast_user_write(fd, skb->data, skb->len,
+                               (struct mcast_data *) &lp->user);
 }
 
 static const struct net_kern_info mcast_kern_info = {
@@ -81,34 +71,34 @@ int mcast_setup(char *str, char **mac_out, void *data)
 
        remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str,
                               NULL);
-       if(remain != NULL){
+       if (remain != NULL) {
                printk(KERN_ERR "mcast_setup - Extra garbage on "
                       "specification : '%s'\n", remain);
-               return(0);
+               return 0;
        }
-       
-       if(port_str != NULL){
+
+       if (port_str != NULL) {
                init->port = simple_strtoul(port_str, &last, 10);
-               if((*last != '\0') || (last == port_str)){
-                       printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", 
+               if ((*last != '\0') || (last == port_str)) {
+                       printk(KERN_ERR "mcast_setup - Bad port : '%s'\n",
                               port_str);
-                       return(0);
+                       return 0;
                }
        }
 
-       if(ttl_str != NULL){
+       if (ttl_str != NULL) {
                init->ttl = simple_strtoul(ttl_str, &last, 10);
-               if((*last != '\0') || (last == ttl_str)){
-                       printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", 
+               if ((*last != '\0') || (last == ttl_str)) {
+                       printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n",
                               ttl_str);
-                       return(0);
+                       return 0;
                }
        }
 
        printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr,
               init->port, init->ttl);
 
-       return(1);
+       return 1;
 }
 
 static struct transport mcast_transport = {
index 236a3df..5f647d7 100644 (file)
@@ -1,9 +1,10 @@
 /*
  * user-mode-linux networking multicast transport
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
  *
  * based on the existing uml-networking code, which is
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
  *
  *
  */
 
-#include <errno.h>
 #include <unistd.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/time.h>
+#include <errno.h>
 #include <netinet/in.h>
-#include "net_user.h"
 #include "mcast.h"
-#include "kern_util.h"
-#include "user.h"
-#include "os.h"
+#include "net_user.h"
 #include "um_malloc.h"
-
-#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
+#include "user.h"
 
 static struct sockaddr_in *new_addr(char *addr, unsigned short port)
 {
        struct sockaddr_in *sin;
 
        sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
-       if(sin == NULL){
-               printk("new_addr: allocation of sockaddr_in failed\n");
+       if (sin == NULL) {
+               printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
+                      "failed\n");
                return NULL;
        }
        sin->sin_family = AF_INET;
@@ -71,17 +66,17 @@ static int mcast_open(void *data)
 
        fd = socket(AF_INET, SOCK_DGRAM, 0);
 
-       if (fd < 0){
+       if (fd < 0) {
                err = -errno;
-               printk("mcast_open : data socket failed, errno = %d\n", 
-                      errno);
+               printk(UM_KERN_ERR "mcast_open : data socket failed, "
+                      "errno = %d\n", errno);
                goto out;
        }
 
        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
                err = -errno;
-               printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
-                       errno);
+               printk(UM_KERN_ERR "mcast_open: SO_REUSEADDR failed, "
+                      "errno = %d\n", errno);
                goto out_close;
        }
 
@@ -89,45 +84,46 @@ static int mcast_open(void *data)
        if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl,
                       sizeof(pri->ttl)) < 0) {
                err = -errno;
-               printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
-                       errno);
+               printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_TTL failed, "
+                      "error = %d\n", errno);
                goto out_close;
        }
 
        /* set LOOP, so data does get fed back to local sockets */
        if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
                err = -errno;
-               printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
-                       errno);
+               printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_LOOP failed, "
+                      "error = %d\n", errno);
                goto out_close;
        }
 
        /* bind socket to mcast address */
        if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
                err = -errno;
-               printk("mcast_open : data bind failed, errno = %d\n", errno);
+               printk(UM_KERN_ERR "mcast_open : data bind failed, "
+                      "errno = %d\n", errno);
                goto out_close;
        }
 
        /* subscribe to the multicast group */
        mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr;
        mreq.imr_interface.s_addr = 0;
-       if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, 
+       if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP,
                       &mreq, sizeof(mreq)) < 0) {
                err = -errno;
-               printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n",
-                       errno);
-               printk("There appears not to be a multicast-capable network "
-                      "interface on the host.\n");
-               printk("eth0 should be configured in order to use the "
-                      "multicast transport.\n");
+               printk(UM_KERN_ERR "mcast_open: IP_ADD_MEMBERSHIP failed, "
+                      "error = %d\n", errno);
+               printk(UM_KERN_ERR "There appears not to be a multicast-"
+                      "capable network interface on the host.\n");
+               printk(UM_KERN_ERR "eth0 should be configured in order to use "
+                      "the multicast transport.\n");
                goto out_close;
        }
 
        return fd;
 
  out_close:
-       os_close_file(fd);
+       close(fd);
  out:
        return err;
 }
@@ -142,11 +138,11 @@ static void mcast_close(int fd, void *data)
        mreq.imr_interface.s_addr = 0;
        if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP,
                       &mreq, sizeof(mreq)) < 0) {
-               printk("mcast_open: IP_DROP_MEMBERSHIP failed, error = %d\n",
-                       errno);
+               printk(UM_KERN_ERR "mcast_open: IP_DROP_MEMBERSHIP failed, "
+                      "error = %d\n", errno);
        }
 
-       os_close_file(fd);
+       close(fd);
 }
 
 int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)
@@ -156,18 +152,13 @@ int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri)
        return net_sendto(fd, buf, len, data_addr, sizeof(*data_addr));
 }
 
-static int mcast_set_mtu(int mtu, void *data)
-{
-       return mtu;
-}
-
 const struct net_user_info mcast_user_info = {
        .init           = mcast_user_init,
        .open           = mcast_open,
        .close          = mcast_close,
        .remove         = mcast_remove,
-       .set_mtu        = mcast_set_mtu,
        .add_address    = NULL,
        .delete_address = NULL,
-       .max_packet     = MAX_PACKET - ETH_HEADER_OTHER
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_OTHER,
 };
index d870905..0f3c7d1 100644 (file)
@@ -1,44 +1,35 @@
 /*
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
- * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "linux/slab.h"
-#include "linux/init.h"
-#include "linux/notifier.h"
-#include "linux/reboot.h"
-#include "linux/utsname.h"
+#include "linux/console.h"
 #include "linux/ctype.h"
 #include "linux/interrupt.h"
-#include "linux/sysrq.h"
-#include "linux/workqueue.h"
+#include "linux/list.h"
+#include "linux/mm.h"
 #include "linux/module.h"
-#include "linux/file.h"
-#include "linux/fs.h"
-#include "linux/namei.h"
+#include "linux/notifier.h"
+#include "linux/reboot.h"
 #include "linux/proc_fs.h"
+#include "linux/slab.h"
 #include "linux/syscalls.h"
-#include "linux/list.h"
-#include "linux/mm.h"
-#include "linux/console.h"
-#include "asm/irq.h"
+#include "linux/utsname.h"
+#include "linux/workqueue.h"
 #include "asm/uaccess.h"
+#include "init.h"
+#include "irq_kern.h"
+#include "irq_user.h"
 #include "kern_util.h"
-#include "kern.h"
 #include "mconsole.h"
 #include "mconsole_kern.h"
-#include "irq_user.h"
-#include "init.h"
 #include "os.h"
-#include "irq_kern.h"
-#include "choose-mode.h"
 
 static int do_unlink_socket(struct notifier_block *notifier,
                            unsigned long what, void *data)
 {
-       return(mconsole_unlink_socket());
+       return mconsole_unlink_socket();
 }
 
 
@@ -59,10 +50,9 @@ static void mc_work_proc(struct work_struct *unused)
        struct mconsole_entry *req;
        unsigned long flags;
 
-       while(!list_empty(&mc_requests)){
+       while (!list_empty(&mc_requests)) {
                local_irq_save(flags);
-               req = list_entry(mc_requests.next, struct mconsole_entry,
-                                list);
+               req = list_entry(mc_requests.next, struct mconsole_entry, list);
                list_del(&req->list);
                local_irq_restore(flags);
                req->request.cmd->handler(&req->request);
@@ -80,12 +70,12 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
        static struct mc_request req;   /* that's OK */
 
        fd = (long) dev_id;
-       while (mconsole_get_request(fd, &req)){
-               if(req.cmd->context == MCONSOLE_INTR)
+       while (mconsole_get_request(fd, &req)) {
+               if (req.cmd->context == MCONSOLE_INTR)
                        (*req.cmd->handler)(&req);
                else {
                        new = kmalloc(sizeof(*new), GFP_NOWAIT);
-                       if(new == NULL)
+                       if (new == NULL)
                                mconsole_reply(&req, "Out of memory", 1, 0);
                        else {
                                new->request = req;
@@ -94,10 +84,10 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
                        }
                }
        }
-       if(!list_empty(&mc_requests))
+       if (!list_empty(&mc_requests))
                schedule_work(&mconsole_work);
        reactivate_fd(fd, MCONSOLE_IRQ);
-       return(IRQ_HANDLED);
+       return IRQ_HANDLED;
 }
 
 void mconsole_version(struct mc_request *req)
@@ -105,8 +95,8 @@ void mconsole_version(struct mc_request *req)
        char version[256];
 
        sprintf(version, "%s %s %s %s %s", utsname()->sysname,
-               utsname()->nodename, utsname()->release,
-               utsname()->version, utsname()->machine);
+               utsname()->nodename, utsname()->release, utsname()->version,
+               utsname()->machine);
        mconsole_reply(req, version, 0, 0);
 }
 
@@ -118,7 +108,7 @@ void mconsole_log(struct mc_request *req)
        ptr += strlen("log ");
 
        len = req->len - (ptr - req->request.data);
-       printk("%.*s", len, ptr);
+       printk(KERN_WARNING "%.*s", len, ptr);
        mconsole_reply(req, "", 0, 0);
 }
 
@@ -137,17 +127,17 @@ void mconsole_proc(struct mc_request *req)
        char *ptr = req->request.data, *buf;
 
        ptr += strlen("proc");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr)) ptr++;
 
        proc = get_fs_type("proc");
-       if(proc == NULL){
+       if (proc == NULL) {
                mconsole_reply(req, "procfs not registered", 1, 0);
                goto out;
        }
 
        super = (*proc->get_sb)(proc, 0, NULL, NULL);
        put_filesystem(proc);
-       if(super == NULL){
+       if (super == NULL) {
                mconsole_reply(req, "Failed to get procfs superblock", 1, 0);
                goto out;
        }
@@ -162,29 +152,29 @@ void mconsole_proc(struct mc_request *req)
         * if commenting out these two calls + the below read cycle. To
         * make UML crash again, it was enough to readd either one.*/
        err = link_path_walk(ptr, &nd);
-       if(err){
+       if (err) {
                mconsole_reply(req, "Failed to look up file", 1, 0);
                goto out_kill;
        }
 
        file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
-       if(IS_ERR(file)){
+       if (IS_ERR(file)) {
                mconsole_reply(req, "Failed to open file", 1, 0);
                goto out_kill;
        }
        /*END*/
 
        buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-       if(buf == NULL){
+       if (buf == NULL) {
                mconsole_reply(req, "Failed to allocate buffer", 1, 0);
                goto out_fput;
        }
 
-       if((file->f_op != NULL) && (file->f_op->read != NULL)){
+       if ((file->f_op != NULL) && (file->f_op->read != NULL)) {
                do {
                        n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1,
                                                &file->f_pos);
-                       if(n >= 0){
+                       if (n >= 0) {
                                buf[n] = '\0';
                                mconsole_reply(req, buf, 0, (n > 0));
                        }
@@ -193,7 +183,7 @@ void mconsole_proc(struct mc_request *req)
                                               1, 0);
                                goto out_free;
                        }
-               } while(n > 0);
+               } while (n > 0);
        }
        else mconsole_reply(req, "", 0, 0);
 
@@ -217,18 +207,19 @@ void mconsole_proc(struct mc_request *req)
        char *ptr = req->request.data;
 
        ptr += strlen("proc");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr))
+               ptr++;
        snprintf(path, sizeof(path), "/proc/%s", ptr);
 
        fd = sys_open(path, 0, 0);
        if (fd < 0) {
                mconsole_reply(req, "Failed to open file", 1, 0);
-               printk("open %s: %d\n",path,fd);
+               printk(KERN_ERR "open %s: %d\n",path,fd);
                goto out;
        }
 
        buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-       if(buf == NULL){
+       if (buf == NULL) {
                mconsole_reply(req, "Failed to allocate buffer", 1, 0);
                goto out_close;
        }
@@ -239,7 +230,7 @@ void mconsole_proc(struct mc_request *req)
                        mconsole_reply(req, "Read of file failed", 1, 0);
                        goto out_free;
                }
-               /*Begin the file content on his own line.*/
+               /* Begin the file content on his own line. */
                if (first_chunk) {
                        mconsole_reply(req, "\n", 0, 1);
                        first_chunk = 0;
@@ -351,12 +342,12 @@ static struct mc_device *mconsole_find_dev(char *name)
        struct list_head *ele;
        struct mc_device *dev;
 
-       list_for_each(ele, &mconsole_devices){
+       list_for_each(ele, &mconsole_devices) {
                dev = list_entry(ele, struct mc_device, list);
-               if(!strncmp(name, dev->name, strlen(dev->name)))
-                       return(dev);
+               if (!strncmp(name, dev->name, strlen(dev->name)))
+                       return dev;
        }
-       return(NULL);
+       return NULL;
 }
 
 #define UNPLUGGED_PER_PAGE \
@@ -378,15 +369,15 @@ static int mem_config(char *str, char **error_out)
        int err = -EINVAL, i, add;
        char *ret;
 
-       if(str[0] != '='){
+       if (str[0] != '=') {
                *error_out = "Expected '=' after 'mem'";
                goto out;
        }
 
        str++;
-       if(str[0] == '-')
+       if (str[0] == '-')
                add = 0;
-       else if(str[0] == '+'){
+       else if (str[0] == '+') {
                add = 1;
        }
        else {
@@ -396,7 +387,7 @@ static int mem_config(char *str, char **error_out)
 
        str++;
        diff = memparse(str, &ret);
-       if(*ret != '\0'){
+       if (*ret != '\0') {
                *error_out = "Failed to parse memory increment";
                goto out;
        }
@@ -404,17 +395,17 @@ static int mem_config(char *str, char **error_out)
        diff /= PAGE_SIZE;
 
        down(&plug_mem_mutex);
-       for(i = 0; i < diff; i++){
+       for (i = 0; i < diff; i++) {
                struct unplugged_pages *unplugged;
                void *addr;
 
-               if(add){
-                       if(list_empty(&unplugged_pages))
+               if (add) {
+                       if (list_empty(&unplugged_pages))
                                break;
 
                        unplugged = list_entry(unplugged_pages.next,
                                               struct unplugged_pages, list);
-                       if(unplug_index > 0)
+                       if (unplug_index > 0)
                                addr = unplugged->pages[--unplug_index];
                        else {
                                list_del(&unplugged->list);
@@ -429,11 +420,11 @@ static int mem_config(char *str, char **error_out)
                        struct page *page;
 
                        page = alloc_page(GFP_ATOMIC);
-                       if(page == NULL)
+                       if (page == NULL)
                                break;
 
                        unplugged = page_address(page);
-                       if(unplug_index == UNPLUGGED_PER_PAGE){
+                       if (unplug_index == UNPLUGGED_PER_PAGE) {
                                list_add(&unplugged->list, &unplugged_pages);
                                unplug_index = 0;
                        }
@@ -445,9 +436,9 @@ static int mem_config(char *str, char **error_out)
                                                       struct unplugged_pages,
                                                       list);
                                err = os_drop_memory(addr, PAGE_SIZE);
-                               if(err){
-                                       printk("Failed to release memory - "
-                                              "errno = %d\n", err);
+                               if (err) {
+                                       printk(KERN_ERR "Failed to release "
+                                              "memory - errno = %d\n", err);
                                        *error_out = "Failed to release memory";
                                        goto out_unlock;
                                }
@@ -501,10 +492,10 @@ static struct mc_device mem_mc = {
 
 static int __init mem_mc_init(void)
 {
-       if(can_drop_memory())
+       if (can_drop_memory())
                mconsole_register_dev(&mem_mc);
-       else printk("Can't release memory to the host - memory hotplug won't "
-                   "be supported\n");
+       else printk(KERN_ERR "Can't release memory to the host - memory "
+                   "hotplug won't be supported\n");
        return 0;
 }
 
@@ -519,7 +510,7 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
        char default_buf[CONFIG_BUF_SIZE], *error, *buf;
        int n, size;
 
-       if(get_config == NULL){
+       if (get_config == NULL) {
                mconsole_reply(req, "No get_config routine defined", 1, 0);
                return;
        }
@@ -528,30 +519,30 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
        size = ARRAY_SIZE(default_buf);
        buf = default_buf;
 
-       while(1){
+       while (1) {
                n = (*get_config)(name, buf, size, &error);
-               if(error != NULL){
+               if (error != NULL) {
                        mconsole_reply(req, error, 1, 0);
                        goto out;
                }
 
-               if(n <= size){
+               if (n <= size) {
                        mconsole_reply(req, buf, 0, 0);
                        goto out;
                }
 
-               if(buf != default_buf)
+               if (buf != default_buf)
                        kfree(buf);
 
                size = n;
                buf = kmalloc(size, GFP_KERNEL);
-               if(buf == NULL){
+               if (buf == NULL) {
                        mconsole_reply(req, "Failed to allocate buffer", 1, 0);
                        return;
                }
        }
  out:
-       if(buf != default_buf)
+       if (buf != default_buf)
                kfree(buf);
 }
 
@@ -562,19 +553,20 @@ void mconsole_config(struct mc_request *req)
        int err;
 
        ptr += strlen("config");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr))
+               ptr++;
        dev = mconsole_find_dev(ptr);
-       if(dev == NULL){
+       if (dev == NULL) {
                mconsole_reply(req, "Bad configuration option", 1, 0);
                return;
        }
 
        name = &ptr[strlen(dev->name)];
        ptr = name;
-       while((*ptr != '=') && (*ptr != '\0'))
+       while ((*ptr != '=') && (*ptr != '\0'))
                ptr++;
 
-       if(*ptr == '='){
+       if (*ptr == '=') {
                err = (*dev->config)(name, &error_string);
                mconsole_reply(req, error_string, err, 0);
        }
@@ -589,9 +581,9 @@ void mconsole_remove(struct mc_request *req)
        int err, start, end, n;
 
        ptr += strlen("remove");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr)) ptr++;
        dev = mconsole_find_dev(ptr);
-       if(dev == NULL){
+       if (dev == NULL) {
                mconsole_reply(req, "Bad remove option", 1, 0);
                return;
        }
@@ -600,11 +592,11 @@ void mconsole_remove(struct mc_request *req)
 
        err = 1;
        n = (*dev->id)(&ptr, &start, &end);
-       if(n < 0){
+       if (n < 0) {
                err_msg = "Couldn't parse device number";
                goto out;
        }
-       else if((n < start) || (n > end)){
+       else if ((n < start) || (n > end)) {
                sprintf(error, "Invalid device number - must be between "
                        "%d and %d", start, end);
                err_msg = error;
@@ -613,16 +605,16 @@ void mconsole_remove(struct mc_request *req)
 
        err_msg = NULL;
        err = (*dev->remove)(n, &err_msg);
-       switch(err){
+       switch(err) {
        case 0:
                err_msg = "";
                break;
        case -ENODEV:
-               if(err_msg == NULL)
+               if (err_msg == NULL)
                        err_msg = "Device doesn't exist";
                break;
        case -EBUSY:
-               if(err_msg == NULL)
+               if (err_msg == NULL)
                        err_msg = "Device is currently open";
                break;
        default:
@@ -640,35 +632,28 @@ struct mconsole_output {
 static DEFINE_SPINLOCK(client_lock);
 static LIST_HEAD(clients);
 static char console_buf[MCONSOLE_MAX_DATA];
-static int console_index = 0;
 
 static void console_write(struct console *console, const char *string,
-                         unsigned len)
+                         unsigned int len)
 {
        struct list_head *ele;
        int n;
 
-       if(list_empty(&clients))
+       if (list_empty(&clients))
                return;
 
-       while(1){
-               n = min((size_t) len, ARRAY_SIZE(console_buf) - console_index);
-               strncpy(&console_buf[console_index], string, n);
-               console_index += n;
+       while (len > 0) {
+               n = min((size_t) len, ARRAY_SIZE(console_buf));
+               strncpy(console_buf, string, n);
                string += n;
                len -= n;
-               if(len == 0)
-                       return;
 
-               list_for_each(ele, &clients){
+               list_for_each(ele, &clients) {
                        struct mconsole_output *entry;
 
                        entry = list_entry(ele, struct mconsole_output, list);
-                       mconsole_reply_len(entry->req, console_buf,
-                                          console_index, 0, 1);
+                       mconsole_reply_len(entry->req, console_buf, n, 0, 1);
                }
-
-               console_index = 0;
        }
 }
 
@@ -698,8 +683,7 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
 
        (*proc)(arg);
 
-       mconsole_reply_len(req, console_buf, console_index, 0, 0);
-       console_index = 0;
+       mconsole_reply_len(req, "", 0, 0, 0);
 
        spin_lock_irqsave(&client_lock, flags);
        list_del(&entry.list);
@@ -707,6 +691,9 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
 }
 
 #ifdef CONFIG_MAGIC_SYSRQ
+
+#include <linux/sysrq.h>
+
 static void sysrq_proc(void *arg)
 {
        char *op = arg;
@@ -718,12 +705,13 @@ void mconsole_sysrq(struct mc_request *req)
        char *ptr = req->request.data;
 
        ptr += strlen("sysrq");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr)) ptr++;
 
-       /* With 'b', the system will shut down without a chance to reply,
+       /*
+        * With 'b', the system will shut down without a chance to reply,
         * so in this case, we reply first.
         */
-       if(*ptr == 'b')
+       if (*ptr == 'b')
                mconsole_reply(req, "", 0, 0);
 
        with_console(req, sysrq_proc, ptr);
@@ -735,8 +723,6 @@ void mconsole_sysrq(struct mc_request *req)
 }
 #endif
 
-#ifdef CONFIG_MODE_SKAS
-
 static void stack_proc(void *arg)
 {
        struct task_struct *from = current, *to = arg;
@@ -745,29 +731,34 @@ static void stack_proc(void *arg)
        switch_to(from, to, from);
 }
 
-/* Mconsole stack trace
+/*
+ * Mconsole stack trace
  *  Added by Allan Graves, Jeff Dike
  *  Dumps a stacks registers to the linux console.
  *  Usage stack <pid>.
  */
-static void do_stack_trace(struct mc_request *req)
+void mconsole_stack(struct mc_request *req)
 {
        char *ptr = req->request.data;
        int pid_requested= -1;
        struct task_struct *from = NULL;
        struct task_struct *to = NULL;
 
-       /* Would be nice:
+       /*
+        * Would be nice:
         * 1) Send showregs output to mconsole.
         * 2) Add a way to stack dump all pids.
         */
 
        ptr += strlen("stack");
-       while(isspace(*ptr)) ptr++;
+       while (isspace(*ptr))
+               ptr++;
 
-       /* Should really check for multiple pids or reject bad args here */
+       /*
+        * Should really check for multiple pids or reject bad args here
+        */
        /* What do the arguments in mconsole_reply mean? */
-       if(sscanf(ptr, "%d", &pid_requested) == 0){
+       if (sscanf(ptr, "%d", &pid_requested) == 0) {
                mconsole_reply(req, "Please specify a pid", 1, 0);
                return;
        }
@@ -775,25 +766,15 @@ static void do_stack_trace(struct mc_request *req)
        from = current;
 
        to = find_task_by_pid(pid_requested);
-       if((to == NULL) || (pid_requested == 0)) {
+       if ((to == NULL) || (pid_requested == 0)) {
                mconsole_reply(req, "Couldn't find that pid", 1, 0);
                return;
        }
        with_console(req, stack_proc, to);
 }
-#endif /* CONFIG_MODE_SKAS */
 
-void mconsole_stack(struct mc_request *req)
-{
-       /* This command doesn't work in TT mode, so let's check and then
-        * get out of here
-        */
-       CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode",
-                                  1, 0),
-                   do_stack_trace(req));
-}
-
-/* Changed by mconsole_setup, which is __setup, and called before SMP is
+/*
+ * Changed by mconsole_setup, which is __setup, and called before SMP is
  * active.
  */
 static char *notify_socket = NULL;
@@ -805,13 +786,14 @@ static int __init mconsole_init(void)
        int err;
        char file[256];
 
-       if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
+       if (umid_file_name("mconsole", file, sizeof(file)))
+               return -1;
        snprintf(mconsole_socket_name, sizeof(file), "%s", file);
 
        sock = os_create_unix_socket(file, sizeof(file), 1);
-       if (sock < 0){
-               printk("Failed to initialize management console\n");
-               return(1);
+       if (sock < 0) {
+               printk(KERN_ERR "Failed to initialize management console\n");
+               return 1;
        }
 
        register_reboot_notifier(&reboot_notifier);
@@ -819,14 +801,14 @@ static int __init mconsole_init(void)
        err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
                             IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
                             "mconsole", (void *)sock);
-       if (err){
-               printk("Failed to get IRQ for management console\n");
-               return(1);
+       if (err) {
+               printk(KERN_ERR "Failed to get IRQ for management console\n");
+               return 1;
        }
 
-       if(notify_socket != NULL){
+       if (notify_socket != NULL) {
                notify_socket = kstrdup(notify_socket, GFP_KERNEL);
-               if(notify_socket != NULL)
+               if (notify_socket != NULL)
                        mconsole_notify(notify_socket, MCONSOLE_SOCKET,
                                        mconsole_socket_name,
                                        strlen(mconsole_socket_name) + 1);
@@ -834,9 +816,9 @@ static int __init mconsole_init(void)
                            "string\n");
        }
 
-       printk("mconsole (version %d) initialized on %s\n",
+       printk(KERN_INFO "mconsole (version %d) initialized on %s\n",
               MCONSOLE_VERSION, mconsole_socket_name);
-       return(0);
+       return 0;
 }
 
 __initcall(mconsole_init);
@@ -847,10 +829,10 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer,
        char *buf;
 
        buf = kmalloc(count + 1, GFP_KERNEL);
-       if(buf == NULL)
-               return(-ENOMEM);
+       if (buf == NULL)
+               return -ENOMEM;
 
-       if(copy_from_user(buf, buffer, count)){
+       if (copy_from_user(buf, buffer, count)) {
                count = -EFAULT;
                goto out;
        }
@@ -860,24 +842,26 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer,
        mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
  out:
        kfree(buf);
-       return(count);
+       return count;
 }
 
 static int create_proc_mconsole(void)
 {
        struct proc_dir_entry *ent;
 
-       if(notify_socket == NULL) return(0);
+       if (notify_socket == NULL)
+               return 0;
 
        ent = create_proc_entry("mconsole", S_IFREG | 0200, NULL);
-       if(ent == NULL){
-               printk(KERN_INFO "create_proc_mconsole : create_proc_entry failed\n");
-               return(0);
+       if (ent == NULL) {
+               printk(KERN_INFO "create_proc_mconsole : create_proc_entry "
+                      "failed\n");
+               return 0;
        }
 
        ent->read_proc = NULL;
        ent->write_proc = write_proc_mconsole;
-       return(0);
+       return 0;
 }
 
 static DEFINE_SPINLOCK(notify_spinlock);
@@ -894,19 +878,19 @@ void unlock_notify(void)
 
 __initcall(create_proc_mconsole);
 
-#define NOTIFY "=notify:"
+#define NOTIFY "notify:"
 
 static int mconsole_setup(char *str)
 {
-       if(!strncmp(str, NOTIFY, strlen(NOTIFY))){
+       if (!strncmp(str, NOTIFY, strlen(NOTIFY))) {
                str += strlen(NOTIFY);
                notify_socket = str;
        }
        else printk(KERN_ERR "mconsole_setup : Unknown option - '%s'\n", str);
-       return(1);
+       return 1;
 }
 
-__setup("mconsole", mconsole_setup);
+__setup("mconsole=", mconsole_setup);
 
 __uml_help(mconsole_setup,
 "mconsole=notify:<socket>\n"
@@ -921,11 +905,12 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1,
 {
        char *message = ptr;
 
-       if(notify_socket == NULL) return(0);
+       if (notify_socket == NULL)
+               return 0;
 
        mconsole_notify(notify_socket, MCONSOLE_PANIC, message,
                        strlen(message) + 1);
-       return(0);
+       return 0;
 }
 
 static struct notifier_block panic_exit_notifier = {
@@ -938,14 +923,14 @@ static int add_notifier(void)
 {
        atomic_notifier_chain_register(&panic_notifier_list,
                        &panic_exit_notifier);
-       return(0);
+       return 0;
 }
 
 __initcall(add_notifier);
 
 char *mconsole_notify_socket(void)
 {
-       return(notify_socket);
+       return notify_socket;
 }
 
 EXPORT_SYMBOL(mconsole_notify_socket);
index f31e715..430c024 100644 (file)
@@ -1,25 +1,22 @@
 /*
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
- * Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <errno.h>
-#include <signal.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <sys/uio.h>
 #include <sys/un.h>
-#include <unistd.h>
-#include "user.h"
-#include "sysdep/ptrace.h"
+#include "kern_constants.h"
 #include "mconsole.h"
-#include "os.h"
+#include "user.h"
 
 static struct mconsole_command commands[] = {
-       /* With uts namespaces, uts information becomes process-specific, so
+       /*
+        * With uts namespaces, uts information becomes process-specific, so
         * we need a process context.  If we try handling this in interrupt
         * context, we may hit an exiting process without a valid uts
         * namespace.
@@ -36,7 +33,7 @@ static struct mconsole_command commands[] = {
        { "go", mconsole_go, MCONSOLE_INTR },
        { "log", mconsole_log, MCONSOLE_INTR },
        { "proc", mconsole_proc, MCONSOLE_PROC },
-        { "stack", mconsole_stack, MCONSOLE_INTR },
+       { "stack", mconsole_stack, MCONSOLE_INTR },
 };
 
 /* Initialized in mconsole_init, which is an initcall */
@@ -44,21 +41,21 @@ char mconsole_socket_name[256];
 
 int mconsole_reply_v0(struct mc_request *req, char *reply)
 {
-        struct iovec iov;
-        struct msghdr msg;
+       struct iovec iov;
+       struct msghdr msg;
 
-        iov.iov_base = reply;
-        iov.iov_len = strlen(reply);
+       iov.iov_base = reply;
+       iov.iov_len = strlen(reply);
 
-        msg.msg_name = &(req->origin);
-        msg.msg_namelen = req->originlen;
-        msg.msg_iov = &iov;
-        msg.msg_iovlen = 1;
-        msg.msg_control = NULL;
-        msg.msg_controllen = 0;
-        msg.msg_flags = 0;
+       msg.msg_name = &(req->origin);
+       msg.msg_namelen = req->originlen;
+       msg.msg_iov = &iov;
+       msg.msg_iovlen = 1;
+       msg.msg_control = NULL;
+       msg.msg_controllen = 0;
+       msg.msg_flags = 0;
 
-        return sendmsg(req->originating_fd, &msg, 0);
+       return sendmsg(req->originating_fd, &msg, 0);
 }
 
 static struct mconsole_command *mconsole_parse(struct mc_request *req)
@@ -66,10 +63,10 @@ static struct mconsole_command *mconsole_parse(struct mc_request *req)
        struct mconsole_command *cmd;
        int i;
 
-       for(i = 0; i < ARRAY_SIZE(commands); i++){
+       for (i = 0; i < ARRAY_SIZE(commands); i++) {
                cmd = &commands[i];
-               if(!strncmp(req->request.data, cmd->command, 
-                           strlen(cmd->command))){
+               if (!strncmp(req->request.data, cmd->command,
+                           strlen(cmd->command))) {
                        return cmd;
                }
        }
@@ -94,9 +91,9 @@ int mconsole_get_request(int fd, struct mc_request *req)
 
        req->originating_fd = fd;
 
-       if(req->request.magic != MCONSOLE_MAGIC){
+       if (req->request.magic != MCONSOLE_MAGIC) {
                /* Unversioned request */
-               len = MIN(sizeof(req->request.data) - 1, 
+               len = MIN(sizeof(req->request.data) - 1,
                          strlen((char *) &req->request));
                memmove(req->request.data, &req->request, len);
                req->request.data[len] = '\0';
@@ -107,32 +104,33 @@ int mconsole_get_request(int fd, struct mc_request *req)
 
                mconsole_reply_v0(req, "ERR Version 0 mconsole clients are "
                                  "not supported by this driver");
-               return(0);
+               return 0;
        }
 
-       if(req->request.len >= MCONSOLE_MAX_DATA){
+       if (req->request.len >= MCONSOLE_MAX_DATA) {
                mconsole_reply(req, "Request too large", 1, 0);
-               return(0);
+               return 0;
        }
-       if(req->request.version != MCONSOLE_VERSION){
-               mconsole_reply(req, "This driver only supports version " 
-                               STRING(MCONSOLE_VERSION) " clients", 1, 0);
+       if (req->request.version != MCONSOLE_VERSION) {
+               mconsole_reply(req, "This driver only supports version "
+                              STRING(MCONSOLE_VERSION) " clients", 1, 0);
        }
-       
+
        req->request.data[req->request.len] = '\0';
        req->cmd = mconsole_parse(req);
-       if(req->cmd == NULL){
+       if (req->cmd == NULL) {
                mconsole_reply(req, "Unknown command", 1, 0);
-               return(0);
+               return 0;
        }
 
-       return(1);
+       return 1;
 }
 
 int mconsole_reply_len(struct mc_request *req, const char *str, int total,
                       int err, int more)
 {
-       /* XXX This is a stack consumption problem.  It'd be nice to
+       /*
+        * XXX This is a stack consumption problem.  It'd be nice to
         * make it global and serialize access to it, but there are a
         * ton of callers to this function.
         */
@@ -147,7 +145,7 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total,
 
                len = MIN(total, MCONSOLE_MAX_DATA - 1);
 
-               if(len == total) reply.more = more;
+               if (len == total) reply.more = more;
                else reply.more = 1;
 
                memcpy(reply.data, str, len);
@@ -161,9 +159,10 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total,
                n = sendto(req->originating_fd, &reply, len, 0,
                           (struct sockaddr *) req->origin, req->originlen);
 
-               if(n < 0) return(-errno);
-       } while(total > 0);
-       return(0);
+               if (n < 0)
+                       return -errno;
+       } while (total > 0);
+       return 0;
 }
 
 int mconsole_reply(struct mc_request *req, const char *str, int err, int more)
@@ -187,18 +186,18 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
        int n, err = 0;
 
        lock_notify();
-       if(notify_sock < 0){
+       if (notify_sock < 0) {
                notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0);
-               if(notify_sock < 0){
+               if (notify_sock < 0) {
                        err = -errno;
-                       printk("mconsole_notify - socket failed, errno = %d\n",
-                              err);
+                       printk(UM_KERN_ERR "mconsole_notify - socket failed, "
+                              "errno = %d\n", errno);
                }
        }
        unlock_notify();
-       
-       if(err)
-               return(err);
+
+       if (err)
+               return err;
 
        target.sun_family = AF_UNIX;
        strcpy(target.sun_path, sock_name);
@@ -212,22 +211,12 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
 
        err = 0;
        len = sizeof(packet) + packet.len - sizeof(packet.data);
-       n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, 
+       n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target,
                   sizeof(target));
-       if(n < 0){
+       if (n < 0) {
                err = -errno;
-               printk("mconsole_notify - sendto failed, errno = %d\n", errno);
+               printk(UM_KERN_ERR "mconsole_notify - sendto failed, "
+                      "errno = %d\n", errno);
        }
-       return(err);
+       return err;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 867666a..67b2f55 100644 (file)
@@ -9,27 +9,29 @@
  *
  */
 
-#include <linux/init.h> 
-#include <linux/module.h>
-#include <linux/mm.h> 
+#include <linux/stddef.h>
+#include <linux/types.h>
 #include <linux/fs.h>
+#include <linux/init.h>
 #include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/mm.h>
 #include <asm/uaccess.h>
 #include "mem_user.h"
+
 /* These are set in mmapper_init, which is called at boot time */
 static unsigned long mmapper_size;
-static unsigned long p_buf = 0;
-static char *v_buf = NULL;
+static unsigned long p_buf;
+static char *v_buf;
 
-static ssize_t
-mmapper_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
+                           loff_t *ppos)
 {
        return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
 }
 
-static ssize_t
-mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t mmapper_write(struct file *file, const char __user *buf,
+                            size_t count, loff_t *ppos)
 {
        if (*ppos > mmapper_size)
                return -EINVAL;
@@ -39,48 +41,46 @@ mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *p
 
        if (copy_from_user(&v_buf[*ppos], buf, count))
                return -EFAULT;
-       
+
        return count;
 }
 
-static int 
-mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-        unsigned long arg)
+static int mmapper_ioctl(struct inode *inode, struct file *file,
+                        unsigned int cmd, unsigned long arg)
 {
-       return(-ENOIOCTLCMD);
+       return -ENOIOCTLCMD;
 }
 
-static int 
-mmapper_mmap(struct file *file, struct vm_area_struct * vma)
+static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
 {
        int ret = -EINVAL;
        int size;
 
        if (vma->vm_pgoff != 0)
                goto out;
-       
+
        size = vma->vm_end - vma->vm_start;
-       if(size > mmapper_size) return(-EFAULT);
+       if (size > mmapper_size)
+               return -EFAULT;
 
-       /* XXX A comment above remap_pfn_range says it should only be
+       /*
+        * XXX A comment above remap_pfn_range says it should only be
         * called when the mm semaphore is held
         */
        if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
-                            vma->vm_page_prot))
+                           vma->vm_page_prot))
                goto out;
        ret = 0;
 out:
        return ret;
 }
 
-static int
-mmapper_open(struct inode *inode, struct file *file)
+static int mmapper_open(struct inode *inode, struct file *file)
 {
        return 0;
 }
 
-static int 
-mmapper_release(struct inode *inode, struct file *file)
+static int mmapper_release(struct inode *inode, struct file *file)
 {
        return 0;
 }
@@ -95,7 +95,9 @@ static const struct file_operations mmapper_fops = {
        .release        = mmapper_release,
 };
 
-/* No locking needed - only used (and modified) by below initcall and exitcall. */
+/*
+ * No locking needed - only used (and modified) by below initcall and exitcall.
+ */
 static struct miscdevice mmapper_dev = {
        .minor          = MISC_DYNAMIC_MINOR,
        .name           = "mmapper",
@@ -109,13 +111,13 @@ static int __init mmapper_init(void)
        printk(KERN_INFO "Mapper v0.1\n");
 
        v_buf = (char *) find_iomem("mmapper", &mmapper_size);
-       if(mmapper_size == 0){
+       if (mmapper_size == 0) {
                printk(KERN_ERR "mmapper_init - find_iomem failed\n");
                goto out;
        }
 
        err = misc_register(&mmapper_dev);
-       if(err){
+       if (err) {
                printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
                       err);
                goto out;
@@ -136,9 +138,3 @@ module_exit(mmapper_exit);
 
 MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
 MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index d35d0c1..8c01fa8 100644 (file)
@@ -1,33 +1,28 @@
 /*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
  * Licensed under the GPL.
  */
 
-#include "linux/kernel.h"
-#include "linux/netdevice.h"
-#include "linux/rtnetlink.h"
-#include "linux/skbuff.h"
-#include "linux/socket.h"
-#include "linux/spinlock.h"
-#include "linux/module.h"
-#include "linux/init.h"
-#include "linux/etherdevice.h"
-#include "linux/list.h"
-#include "linux/inetdevice.h"
-#include "linux/ctype.h"
-#include "linux/bootmem.h"
-#include "linux/ethtool.h"
-#include "linux/platform_device.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-#include "net_kern.h"
-#include "net_user.h"
-#include "mconsole_kern.h"
+#include <linux/bootmem.h>
+#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
+#include <linux/inetdevice.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/rtnetlink.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
 #include "init.h"
-#include "irq_user.h"
 #include "irq_kern.h"
+#include "irq_user.h"
+#include "mconsole_kern.h"
+#include "net_kern.h"
+#include "net_user.h"
 
 static inline void set_ether_mac(struct net_device *dev, unsigned char *addr)
 {
@@ -39,6 +34,46 @@ static inline void set_ether_mac(struct net_device *dev, unsigned char *addr)
 static DEFINE_SPINLOCK(opened_lock);
 static LIST_HEAD(opened);
 
+/*
+ * The drop_skb is used when we can't allocate an skb.  The
+ * packet is read into drop_skb in order to get the data off the
+ * connection to the host.
+ * It is reallocated whenever a maximum packet size is seen which is
+ * larger than any seen before.  update_drop_skb is called from
+ * eth_configure when a new interface is added.
+ */
+static DEFINE_SPINLOCK(drop_lock);
+static struct sk_buff *drop_skb;
+static int drop_max;
+
+static int update_drop_skb(int max)
+{
+       struct sk_buff *new;
+       unsigned long flags;
+       int err = 0;
+
+       spin_lock_irqsave(&drop_lock, flags);
+
+       if (max <= drop_max)
+               goto out;
+
+       err = -ENOMEM;
+       new = dev_alloc_skb(max);
+       if (new == NULL)
+               goto out;
+
+       skb_put(new, max);
+
+       kfree_skb(drop_skb);
+       drop_skb = new;
+       drop_max = max;
+       err = 0;
+out:
+       spin_unlock_irqrestore(&drop_lock, flags);
+
+       return err;
+}
+
 static int uml_net_rx(struct net_device *dev)
 {
        struct uml_net_private *lp = dev->priv;
@@ -46,16 +81,19 @@ static int uml_net_rx(struct net_device *dev)
        struct sk_buff *skb;
 
        /* If we can't allocate memory, try again next round. */
-       skb = dev_alloc_skb(dev->mtu);
+       skb = dev_alloc_skb(lp->max_packet);
        if (skb == NULL) {
+               drop_skb->dev = dev;
+               /* Read a packet into drop_skb and don't do anything with it. */
+               (*lp->read)(lp->fd, drop_skb, lp);
                lp->stats.rx_dropped++;
                return 0;
        }
 
        skb->dev = dev;
-       skb_put(skb, dev->mtu);
+       skb_put(skb, lp->max_packet);
        skb_reset_mac_header(skb);
-       pkt_len = (*lp->read)(lp->fd, &skb, lp);
+       pkt_len = (*lp->read)(lp->fd, skb, lp);
 
        if (pkt_len > 0) {
                skb_trim(skb, pkt_len);
@@ -84,12 +122,12 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
        struct uml_net_private *lp = dev->priv;
        int err;
 
-       if(!netif_running(dev))
-               return(IRQ_NONE);
+       if (!netif_running(dev))
+               return IRQ_NONE;
 
        spin_lock(&lp->lock);
-       while((err = uml_net_rx(dev)) > 0) ;
-       if(err < 0) {
+       while ((err = uml_net_rx(dev)) > 0) ;
+       if (err < 0) {
                printk(KERN_ERR
                       "Device '%s' read returned %d, shutting it down\n",
                       dev->name, err);
@@ -115,20 +153,20 @@ static int uml_net_open(struct net_device *dev)
        struct uml_net_private *lp = dev->priv;
        int err;
 
-       if(lp->fd >= 0){
+       if (lp->fd >= 0) {
                err = -ENXIO;
                goto out;
        }
 
        lp->fd = (*lp->open)(&lp->user);
-       if(lp->fd < 0){
+       if (lp->fd < 0) {
                err = lp->fd;
                goto out;
        }
 
        err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt,
                             IRQF_DISABLED | IRQF_SHARED, dev->name, dev);
-       if(err != 0){
+       if (err != 0) {
                printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err);
                err = -ENETUNREACH;
                goto out_close;
@@ -141,7 +179,7 @@ static int uml_net_open(struct net_device *dev)
         * is full when we get here.  In this case, new data is never queued,
         * SIGIOs never arrive, and the net never works.
         */
-       while((err = uml_net_rx(dev)) > 0) ;
+       while ((err = uml_net_rx(dev)) > 0) ;
 
        spin_lock(&opened_lock);
        list_add(&lp->list, &opened);
@@ -149,7 +187,7 @@ static int uml_net_open(struct net_device *dev)
 
        return 0;
 out_close:
-       if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
+       if (lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
        lp->fd = -1;
 out:
        return err;
@@ -162,7 +200,7 @@ static int uml_net_close(struct net_device *dev)
        netif_stop_queue(dev);
 
        free_irq(dev->irq, dev);
-       if(lp->close != NULL)
+       if (lp->close != NULL)
                (*lp->close)(lp->fd, &lp->user);
        lp->fd = -1;
 
@@ -183,9 +221,9 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        spin_lock_irqsave(&lp->lock, flags);
 
-       len = (*lp->write)(lp->fd, &skb, lp);
+       len = (*lp->write)(lp->fd, skb, lp);
 
-       if(len == skb->len) {
+       if (len == skb->len) {
                lp->stats.tx_packets++;
                lp->stats.tx_bytes += skb->len;
                dev->trans_start = jiffies;
@@ -194,7 +232,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
                /* this is normally done in the interrupt when tx finishes */
                netif_wake_queue(dev);
        }
-       else if(len == 0){
+       else if (len == 0) {
                netif_start_queue(dev);
                lp->stats.tx_dropped++;
        }
@@ -218,8 +256,10 @@ static struct net_device_stats *uml_net_get_stats(struct net_device *dev)
 
 static void uml_net_set_multicast_list(struct net_device *dev)
 {
-       if (dev->flags & IFF_PROMISC) return;
-       else if (dev->mc_count) dev->flags |= IFF_ALLMULTI;
+       if (dev->flags & IFF_PROMISC)
+               return;
+       else if (dev->mc_count)
+               dev->flags |= IFF_ALLMULTI;
        else dev->flags &= ~IFF_ALLMULTI;
 }
 
@@ -243,22 +283,9 @@ static int uml_net_set_mac(struct net_device *dev, void *addr)
 
 static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
 {
-       struct uml_net_private *lp = dev->priv;
-       int err = 0;
-
-       spin_lock_irq(&lp->lock);
-
-       new_mtu = (*lp->set_mtu)(new_mtu, &lp->user);
-       if(new_mtu < 0){
-               err = new_mtu;
-               goto out;
-       }
-
        dev->mtu = new_mtu;
 
- out:
-       spin_unlock_irq(&lp->lock);
-       return err;
+       return 0;
 }
 
 static void uml_net_get_drvinfo(struct net_device *dev,
@@ -288,13 +315,13 @@ static void setup_etheraddr(char *str, unsigned char *addr, char *name)
        char *end;
        int i;
 
-       if(str == NULL)
+       if (str == NULL)
                goto random;
 
-       for(i=0;i<6;i++){
+       for (i = 0;i < 6; i++) {
                addr[i] = simple_strtoul(str, &end, 16);
-               if((end == str) ||
-                  ((*end != ':') && (*end != ',') && (*end != '\0'))){
+               if ((end == str) ||
+                  ((*end != ':') && (*end != ',') && (*end != '\0'))) {
                        printk(KERN_ERR
                               "setup_etheraddr: failed to parse '%s' "
                               "as an ethernet address\n", str);
@@ -349,7 +376,7 @@ static void net_device_release(struct device *dev)
        struct net_device *netdev = device->dev;
        struct uml_net_private *lp = netdev->priv;
 
-       if(lp->remove != NULL)
+       if (lp->remove != NULL)
                (*lp->remove)(&lp->user);
        list_del(&device->list);
        kfree(device);
@@ -413,7 +440,7 @@ static void eth_configure(int n, void *init, char *mac,
        device->pdev.name = DRIVER_NAME;
        device->pdev.dev.release = net_device_release;
        device->pdev.dev.driver_data = device;
-       if(platform_device_register(&device->pdev))
+       if (platform_device_register(&device->pdev))
                goto out_free_netdev;
        SET_NETDEV_DEV(dev,&device->pdev.dev);
 
@@ -430,6 +457,7 @@ static void eth_configure(int n, void *init, char *mac,
                  .dev                  = dev,
                  .fd                   = -1,
                  .mac                  = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
+                 .max_packet           = transport->user->max_packet,
                  .protocol             = transport->kern->protocol,
                  .open                 = transport->user->open,
                  .close                = transport->user->close,
@@ -437,8 +465,7 @@ static void eth_configure(int n, void *init, char *mac,
                  .read                 = transport->kern->read,
                  .write                = transport->kern->write,
                  .add_address          = transport->user->add_address,
-                 .delete_address       = transport->user->delete_address,
-                 .set_mtu              = transport->user->set_mtu });
+                 .delete_address       = transport->user->delete_address });
 
        init_timer(&lp->tl);
        spin_lock_init(&lp->lock);
@@ -450,7 +477,7 @@ static void eth_configure(int n, void *init, char *mac,
                goto out_unregister;
 
        set_ether_mac(dev, device->mac);
-       dev->mtu = transport->user->max_packet;
+       dev->mtu = transport->user->mtu;
        dev->open = uml_net_open;
        dev->hard_start_xmit = uml_net_start_xmit;
        dev->stop = uml_net_close;
@@ -463,6 +490,10 @@ static void eth_configure(int n, void *init, char *mac,
        dev->watchdog_timeo = (HZ >> 1);
        dev->irq = UM_ETH_IRQ;
 
+       err = update_drop_skb(lp->max_packet);
+       if (err)
+               goto out_undo_user_init;
+
        rtnl_lock();
        err = register_netdevice(dev);
        rtnl_unlock();
@@ -493,9 +524,9 @@ static struct uml_net *find_device(int n)
        struct list_head *ele;
 
        spin_lock(&devices_lock);
-       list_for_each(ele, &devices){
+       list_for_each(ele, &devices) {
                device = list_entry(ele, struct uml_net, list);
-               if(device->index == n)
+               if (device->index == n)
                        goto out;
        }
        device = NULL;
@@ -511,19 +542,19 @@ static int eth_parse(char *str, int *index_out, char **str_out,
        int n, err = -EINVAL;;
 
        n = simple_strtoul(str, &end, 0);
-       if(end == str){
+       if (end == str) {
                *error_out = "Bad device number";
                return err;
        }
 
        str = end;
-       if(*str != '='){
+       if (*str != '=') {
                *error_out = "Expected '=' after device number";
                return err;
        }
 
        str++;
-       if(find_device(n)){
+       if (find_device(n)) {
                *error_out = "Device already configured";
                return err;
        }
@@ -551,20 +582,20 @@ static int check_transport(struct transport *transport, char *eth, int n,
        int len;
 
        len = strlen(transport->name);
-       if(strncmp(eth, transport->name, len))
+       if (strncmp(eth, transport->name, len))
                return 0;
 
        eth += len;
-       if(*eth == ',')
+       if (*eth == ',')
                eth++;
-       else if(*eth != '\0')
+       else if (*eth != '\0')
                return 0;
 
        *init_out = kmalloc(transport->setup_size, GFP_KERNEL);
-       if(*init_out == NULL)
+       if (*init_out == NULL)
                return 1;
 
-       if(!transport->setup(eth, mac_out, *init_out)){
+       if (!transport->setup(eth, mac_out, *init_out)) {
                kfree(*init_out);
                *init_out = NULL;
        }
@@ -584,13 +615,13 @@ void register_transport(struct transport *new)
        list_add(&new->list, &transports);
        spin_unlock(&transports_lock);
 
-       list_for_each_safe(ele, next, &eth_cmd_line){
+       list_for_each_safe(ele, next, &eth_cmd_line) {
                eth = list_entry(ele, struct eth_init, list);
                match = check_transport(new, eth->init, eth->index, &init,
                                        &mac);
-               if(!match)
+               if (!match)
                        continue;
-               else if(init != NULL){
+               else if (init != NULL) {
                        eth_configure(eth->index, init, mac, new);
                        kfree(init);
                }
@@ -607,11 +638,11 @@ static int eth_setup_common(char *str, int index)
        int found = 0;
 
        spin_lock(&transports_lock);
-       list_for_each(ele, &transports){
+       list_for_each(ele, &transports) {
                transport = list_entry(ele, struct transport, list);
-               if(!check_transport(transport, str, index, &init, &mac))
+               if (!check_transport(transport, str, index, &init, &mac))
                        continue;
-               if(init != NULL){
+               if (init != NULL) {
                        eth_configure(index, init, mac, transport);
                        kfree(init);
                }
@@ -630,15 +661,15 @@ static int __init eth_setup(char *str)
        int n, err;
 
        err = eth_parse(str, &n, &str, &error);
-       if(err){
+       if (err) {
                printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n",
                       str, error);
                return 1;
        }
 
        new = alloc_bootmem(sizeof(*new));
-       if (new == NULL){
-               printk("eth_init : alloc_bootmem failed\n");
+       if (new == NULL) {
+               printk(KERN_ERR "eth_init : alloc_bootmem failed\n");
                return 1;
        }
 
@@ -661,36 +692,36 @@ static int net_config(char *str, char **error_out)
        int n, err;
 
        err = eth_parse(str, &n, &str, error_out);
-       if(err)
+       if (err)
                return err;
 
        /* This string is broken up and the pieces used by the underlying
         * driver.  So, it is freed only if eth_setup_common fails.
         */
        str = kstrdup(str, GFP_KERNEL);
-       if(str == NULL){
+       if (str == NULL) {
                *error_out = "net_config failed to strdup string";
                return -ENOMEM;
        }
        err = !eth_setup_common(str, n);
-       if(err)
+       if (err)
                kfree(str);
-       return(err);
+       return err;
 }
 
 static int net_id(char **str, int *start_out, int *end_out)
 {
-        char *end;
-        int n;
+       char *end;
+       int n;
 
        n = simple_strtoul(*str, &end, 0);
-       if((*end != '\0') || (end == *str))
+       if ((*end != '\0') || (end == *str))
                return -1;
 
-        *start_out = n;
-        *end_out = n;
-        *str = end;
-        return n;
+       *start_out = n;
+       *end_out = n;
+       *str = end;
+       return n;
 }
 
 static int net_remove(int n, char **error_out)
@@ -700,12 +731,12 @@ static int net_remove(int n, char **error_out)
        struct uml_net_private *lp;
 
        device = find_device(n);
-       if(device == NULL)
+       if (device == NULL)
                return -ENODEV;
 
        dev = device->dev;
        lp = dev->priv;
-       if(lp->fd > 0)
+       if (lp->fd > 0)
                return -EBUSY;
        unregister_netdev(dev);
        platform_device_unregister(&device->pdev);
@@ -731,13 +762,13 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
        void (*proc)(unsigned char *, unsigned char *, void *);
        unsigned char addr_buf[4], netmask_buf[4];
 
-       if(dev->open != uml_net_open)
+       if (dev->open != uml_net_open)
                return NOTIFY_DONE;
 
        lp = dev->priv;
 
        proc = NULL;
-       switch (event){
+       switch (event) {
        case NETDEV_UP:
                proc = lp->add_address;
                break;
@@ -745,7 +776,7 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
                proc = lp->delete_address;
                break;
        }
-       if(proc != NULL){
+       if (proc != NULL) {
                memcpy(addr_buf, &ifa->ifa_address, sizeof(addr_buf));
                memcpy(netmask_buf, &ifa->ifa_mask, sizeof(netmask_buf));
                (*proc)(addr_buf, netmask_buf, &lp->user);
@@ -773,13 +804,13 @@ static int uml_net_init(void)
         * addresses which have already been set up get handled properly.
         */
        spin_lock(&opened_lock);
-       list_for_each(ele, &opened){
+       list_for_each(ele, &opened) {
                lp = list_entry(ele, struct uml_net_private, list);
                ip = lp->dev->ip_ptr;
-               if(ip == NULL)
+               if (ip == NULL)
                        continue;
                in = ip->ifa_list;
-               while(in != NULL){
+               while (in != NULL) {
                        uml_inetaddr_event(NULL, NETDEV_UP, in);
                        in = in->ifa_next;
                }
@@ -797,12 +828,12 @@ static void close_devices(void)
        struct uml_net_private *lp;
 
        spin_lock(&opened_lock);
-       list_for_each(ele, &opened){
+       list_for_each(ele, &opened) {
                lp = list_entry(ele, struct uml_net_private, list);
                free_irq(lp->dev->irq, lp->dev);
-               if((lp->close != NULL) && (lp->fd >= 0))
+               if ((lp->close != NULL) && (lp->fd >= 0))
                        (*lp->close)(lp->fd, &lp->user);
-               if(lp->remove != NULL)
+               if (lp->remove != NULL)
                        (*lp->remove)(&lp->user);
        }
        spin_unlock(&opened_lock);
@@ -810,19 +841,6 @@ static void close_devices(void)
 
 __uml_exitcall(close_devices);
 
-struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra)
-{
-       if((skb != NULL) && (skb_tailroom(skb) < extra)){
-               struct sk_buff *skb2;
-
-               skb2 = skb_copy_expand(skb, 0, extra, GFP_ATOMIC);
-               dev_kfree_skb(skb);
-               skb = skb2;
-       }
-       if(skb != NULL) skb_put(skb, extra);
-       return(skb);
-}
-
 void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *,
                                        void *),
                    void *arg)
@@ -832,9 +850,9 @@ void iter_addresses(void *d, void (*cb)(unsigned char *, unsigned char *,
        struct in_ifaddr *in;
        unsigned char address[4], netmask[4];
 
-       if(ip == NULL) return;
+       if (ip == NULL) return;
        in = ip->ifa_list;
-       while(in != NULL){
+       while (in != NULL) {
                memcpy(address, &in->ifa_address, sizeof(address));
                memcpy(netmask, &in->ifa_mask, sizeof(netmask));
                (*cb)(address, netmask, arg);
@@ -849,15 +867,15 @@ int dev_netmask(void *d, void *m)
        struct in_ifaddr *in;
        __be32 *mask_out = m;
 
-       if(ip == NULL)
-               return(1);
+       if (ip == NULL)
+               return 1;
 
        in = ip->ifa_list;
-       if(in == NULL)
-               return(1);
+       if (in == NULL)
+               return 1;
 
        *mask_out = in->ifa_mask;
-       return(0);
+       return 0;
 }
 
 void *get_output_buffer(int *len_out)
@@ -865,7 +883,7 @@ void *get_output_buffer(int *len_out)
        void *ret;
 
        ret = (void *) __get_free_pages(GFP_KERNEL, 0);
-       if(ret) *len_out = PAGE_SIZE;
+       if (ret) *len_out = PAGE_SIZE;
        else *len_out = 0;
        return ret;
 }
@@ -881,16 +899,16 @@ int tap_setup_common(char *str, char *type, char **dev_name, char **mac_out,
        char *remain;
 
        remain = split_if_spec(str, dev_name, mac_out, gate_addr, NULL);
-       if(remain != NULL){
-               printk("tap_setup_common - Extra garbage on specification : "
-                      "'%s'\n", remain);
-               return(1);
+       if (remain != NULL) {
+               printk(KERN_ERR "tap_setup_common - Extra garbage on "
+                      "specification : '%s'\n", remain);
+               return 1;
        }
 
-       return(0);
+       return 0;
 }
 
 unsigned short eth_protocol(struct sk_buff *skb)
 {
-       return(eth_type_trans(skb, skb->dev));
+       return eth_type_trans(skb, skb->dev);
 }
index da946e3..90d7f2e 100644 (file)
@@ -1,34 +1,32 @@
-/* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stddef.h>
-#include <stdarg.h>
-#include <unistd.h>
 #include <stdio.h>
+#include <unistd.h>
+#include <stdarg.h>
 #include <errno.h>
-#include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
-#include <sys/time.h>
-#include "user.h"
-#include "kern_util.h"
 #include "net_user.h"
+#include "kern_constants.h"
 #include "os.h"
 #include "um_malloc.h"
-#include "kern_constants.h"
+#include "user.h"
 
 int tap_open_common(void *dev, char *gate_addr)
 {
        int tap_addr[4];
 
-       if(gate_addr == NULL)
+       if (gate_addr == NULL)
                return 0;
-       if(sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], 
-                 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4){
-               printk("Invalid tap IP address - '%s'\n", gate_addr);
+       if (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
+                 &tap_addr[1], &tap_addr[2], &tap_addr[3]) != 4) {
+               printk(UM_KERN_ERR "Invalid tap IP address - '%s'\n",
+                      gate_addr);
                return -EINVAL;
        }
        return 0;
@@ -38,15 +36,15 @@ void tap_check_ips(char *gate_addr, unsigned char *eth_addr)
 {
        int tap_addr[4];
 
-       if((gate_addr != NULL) && 
-          (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0], 
-                  &tap_addr[1], &tap_addr[2], &tap_addr[3]) == 4) &&
-          (eth_addr[0] == tap_addr[0]) && 
-          (eth_addr[1] == tap_addr[1]) && 
-          (eth_addr[2] == tap_addr[2]) && 
-          (eth_addr[3] == tap_addr[3])){
-               printk("The tap IP address and the UML eth IP address"
-                      " must be different\n");
+       if ((gate_addr != NULL) &&
+           (sscanf(gate_addr, "%d.%d.%d.%d", &tap_addr[0],
+                   &tap_addr[1], &tap_addr[2], &tap_addr[3]) == 4) &&
+           (eth_addr[0] == tap_addr[0]) &&
+           (eth_addr[1] == tap_addr[1]) &&
+           (eth_addr[2] == tap_addr[2]) &&
+           (eth_addr[3] == tap_addr[3])) {
+               printk(UM_KERN_ERR "The tap IP address and the UML eth IP "
+                      "address must be different\n");
        }
 }
 
@@ -57,24 +55,28 @@ void read_output(int fd, char *output, int len)
        char c;
        char *str;
 
-       if(output == NULL){
+       if (output == NULL) {
                output = &c;
                len = sizeof(c);
        }
-               
+
        *output = '\0';
-       ret = os_read_file(fd, &remain, sizeof(remain));
+       ret = read(fd, &remain, sizeof(remain));
 
        if (ret != sizeof(remain)) {
+               if (ret < 0)
+                       ret = -errno;
                expected = sizeof(remain);
                str = "length";
                goto err;
        }
 
-       while(remain != 0){
+       while (remain != 0) {
                expected = (remain < len) ? remain : len;
-               ret = os_read_file(fd, output, expected);
+               ret = read(fd, output, expected);
                if (ret != expected) {
+                       if (ret < 0)
+                               ret = -errno;
                        str = "data";
                        goto err;
                }
@@ -85,20 +87,22 @@ void read_output(int fd, char *output, int len)
 
 err:
        if (ret < 0)
-               printk("read_output - read of %s failed, errno = %d\n", str, -ret);
+               printk(UM_KERN_ERR "read_output - read of %s failed, "
+                      "errno = %d\n", str, -ret);
        else
-               printk("read_output - read of %s failed, read only %d of %d bytes\n", str, ret, expected);
+               printk(UM_KERN_ERR "read_output - read of %s failed, read only "
+                      "%d of %d bytes\n", str, ret, expected);
 }
 
 int net_read(int fd, void *buf, int len)
 {
        int n;
 
-       n = os_read_file(fd,  buf,  len);
+       n = read(fd,  buf,  len);
 
-       if(n == -EAGAIN)
+       if ((n < 0) && (errno == EAGAIN))
                return 0;
-       else if(n == 0)
+       else if (n == 0)
                return -ENOTCONN;
        return n;
 }
@@ -108,12 +112,12 @@ int net_recvfrom(int fd, void *buf, int len)
        int n;
 
        CATCH_EINTR(n = recvfrom(fd,  buf,  len, 0, NULL, NULL));
-       if(n < 0){
-               if(errno == EAGAIN)
+       if (n < 0) {
+               if (errno == EAGAIN)
                        return 0;
                return -errno;
        }
-       else if(n == 0)
+       else if (n == 0)
                return -ENOTCONN;
        return n;
 }
@@ -122,11 +126,11 @@ int net_write(int fd, void *buf, int len)
 {
        int n;
 
-       n = os_write_file(fd, buf, len);
+       n = write(fd, buf, len);
 
-       if(n == -EAGAIN)
+       if ((n < 0) && (errno == EAGAIN))
                return 0;
-       else if(n == 0)
+       else if (n == 0)
                return -ENOTCONN;
        return n;
 }
@@ -136,12 +140,12 @@ int net_send(int fd, void *buf, int len)
        int n;
 
        CATCH_EINTR(n = send(fd, buf, len, 0));
-       if(n < 0){
-               if(errno == EAGAIN)
+       if (n < 0) {
+               if (errno == EAGAIN)
                        return 0;
                return -errno;
        }
-       else if(n == 0)
+       else if (n == 0)
                return -ENOTCONN;
        return n;
 }
@@ -152,12 +156,12 @@ int net_sendto(int fd, void *buf, int len, void *to, int sock_len)
 
        CATCH_EINTR(n = sendto(fd, buf, len, 0, (struct sockaddr *) to,
                               sock_len));
-       if(n < 0){
-               if(errno == EAGAIN)
+       if (n < 0) {
+               if (errno == EAGAIN)
                        return 0;
                return -errno;
        }
-       else if(n == 0)
+       else if (n == 0)
                return -ENOTCONN;
        return n;
 }
@@ -171,7 +175,7 @@ static void change_pre_exec(void *arg)
 {
        struct change_pre_exec_data *data = arg;
 
-       os_close_file(data->close_me);
+       close(data->close_me);
        dup2(data->stdout, 1);
 }
 
@@ -181,8 +185,9 @@ static int change_tramp(char **argv, char *output, int output_len)
        struct change_pre_exec_data pe_data;
 
        err = os_pipe(fds, 1, 0);
-       if(err < 0){
-               printk("change_tramp - pipe failed, err = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "change_tramp - pipe failed, err = %d\n",
+                      -err);
                return err;
        }
        pe_data.close_me = fds[0];
@@ -192,8 +197,8 @@ static int change_tramp(char **argv, char *output, int output_len)
        if (pid > 0)    /* Avoid hang as we won't get data in failure case. */
                read_output(fds[0], output, output_len);
 
-       os_close_file(fds[0]);
-       os_close_file(fds[1]);
+       close(fds[0]);
+       close(fds[1]);
 
        if (pid > 0)
                CATCH_EINTR(err = waitpid(pid, NULL, 0));
@@ -206,25 +211,26 @@ static void change(char *dev, char *what, unsigned char *addr,
        char addr_buf[sizeof("255.255.255.255\0")];
        char netmask_buf[sizeof("255.255.255.255\0")];
        char version[sizeof("nnnnn\0")];
-       char *argv[] = { "uml_net", version, what, dev, addr_buf, 
+       char *argv[] = { "uml_net", version, what, dev, addr_buf,
                         netmask_buf, NULL };
        char *output;
        int output_len, pid;
 
        sprintf(version, "%d", UML_NET_VERSION);
        sprintf(addr_buf, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
-       sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1], 
+       sprintf(netmask_buf, "%d.%d.%d.%d", netmask[0], netmask[1],
                netmask[2], netmask[3]);
 
        output_len = UM_KERN_PAGE_SIZE;
        output = kmalloc(output_len, UM_GFP_KERNEL);
-       if(output == NULL)
-               printk("change : failed to allocate output buffer\n");
+       if (output == NULL)
+               printk(UM_KERN_ERR "change : failed to allocate output "
+                      "buffer\n");
 
        pid = change_tramp(argv, output, output_len);
-       if(pid < 0) return;
+       if (pid < 0) return;
 
-       if(output != NULL){
+       if (output != NULL) {
                printk("%s", output);
                kfree(output);
        }
@@ -246,13 +252,13 @@ char *split_if_spec(char *str, ...)
        va_list ap;
 
        va_start(ap, str);
-       while((arg = va_arg(ap, char **)) != NULL){
-               if(*str == '\0')
+       while ((arg = va_arg(ap, char **)) != NULL) {
+               if (*str == '\0')
                        return NULL;
                end = strchr(str, ',');
-               if(end != str)
+               if (end != str)
                        *arg = str;
-               if(end == NULL)
+               if (end == NULL)
                        return NULL;
                *end++ = '\0';
                str = end;
index 9016c68..2b45a14 100644 (file)
@@ -1,31 +1,36 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
-#include <stdlib.h>
+#include <stddef.h>
 #include <errno.h>
+#include <fcntl.h>
 #include "chan_user.h"
 #include "os.h"
 
-/* This address is used only as a unique identifer */
+/* This address is used only as a unique identifier */
 static int null_chan;
 
 static void *null_init(char *str, int device, const struct chan_opts *opts)
 {
-       return(&null_chan);
+       return &null_chan;
 }
 
 static int null_open(int input, int output, int primary, void *d,
                     char **dev_out)
 {
+       int fd;
+
        *dev_out = NULL;
-       return(os_open_file(DEV_NULL, of_rdwr(OPENFLAGS()), 0));
+
+       fd = open(DEV_NULL, O_RDWR);
+       return (fd < 0) ? -errno : fd;
 }
 
 static int null_read(int fd, char *c_out, void *unused)
 {
-       return(-ENODEV);
+       return -ENODEV;
 }
 
 static void null_free(void *data)
@@ -44,14 +49,3 @@ const struct chan_ops null_ops = {
        .free           = null_free,
        .winch          = 0,
 };
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index c329931..3a750dd 100644 (file)
@@ -1,13 +1,11 @@
 /*
- * Copyright (C) 2002 Jeff Dike <jdike@karaya.com>
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL.
  */
 
 #include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/etherdevice.h"
+#include <linux/netdevice.h>
 #include "net_kern.h"
-#include "net_user.h"
 #include "pcap_user.h"
 
 struct pcap_init {
@@ -33,19 +31,14 @@ void pcap_init(struct net_device *dev, void *data)
        printk("pcap backend, host interface %s\n", ppri->host_if);
 }
 
-static int pcap_read(int fd, struct sk_buff **skb,
-                      struct uml_net_private *lp)
+static int pcap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
-       if(*skb == NULL)
-               return -ENOMEM;
-
-       return pcap_user_read(fd, skb_mac_header(*skb),
-                             (*skb)->dev->mtu + ETH_HEADER_OTHER,
+       return pcap_user_read(fd, skb_mac_header(skb),
+                             skb->dev->mtu + ETH_HEADER_OTHER,
                              (struct pcap_data *) &lp->user);
 }
 
-static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
+static int pcap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
        return -EPERM;
 }
@@ -71,28 +64,29 @@ int pcap_setup(char *str, char **mac_out, void *data)
 
        remain = split_if_spec(str, &host_if, &init->filter,
                               &options[0], &options[1], mac_out, NULL);
-       if(remain != NULL){
+       if (remain != NULL) {
                printk(KERN_ERR "pcap_setup - Extra garbage on "
                       "specification : '%s'\n", remain);
                return 0;
        }
 
-       if(host_if != NULL)
+       if (host_if != NULL)
                init->host_if = host_if;
 
-       for(i = 0; i < ARRAY_SIZE(options); i++){
-               if(options[i] == NULL)
+       for (i = 0; i < ARRAY_SIZE(options); i++) {
+               if (options[i] == NULL)
                        continue;
-               if(!strcmp(options[i], "promisc"))
+               if (!strcmp(options[i], "promisc"))
                        init->promisc = 1;
-               else if(!strcmp(options[i], "nopromisc"))
+               else if (!strcmp(options[i], "nopromisc"))
                        init->promisc = 0;
-               else if(!strcmp(options[i], "optimize"))
+               else if (!strcmp(options[i], "optimize"))
                        init->optimize = 1;
-               else if(!strcmp(options[i], "nooptimize"))
+               else if (!strcmp(options[i], "nooptimize"))
                        init->optimize = 0;
                else {
-                       printk("pcap_setup : bad option - '%s'\n", options[i]);
+                       printk(KERN_ERR "pcap_setup : bad option - '%s'\n",
+                              options[i]);
                        return 0;
                }
        }
index 1316456..e980935 100644 (file)
@@ -1,21 +1,17 @@
 /*
- * Copyright (C) 2002 Jeff Dike <jdike@karaya.com>
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL.
  */
 
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #include <pcap.h>
+#include <string.h>
 #include <asm/types.h>
 #include "net_user.h"
 #include "pcap_user.h"
-#include "user.h"
-#include "um_malloc.h"
 #include "kern_constants.h"
-
-#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)
+#include "um_malloc.h"
+#include "user.h"
 
 #define PCAP_FD(p) (*(int *)(p))
 
@@ -25,8 +21,9 @@ static int pcap_user_init(void *data, void *dev)
        pcap_t *p;
        char errors[PCAP_ERRBUF_SIZE];
 
-       p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors);
-       if(p == NULL){
+       p = pcap_open_live(pri->host_if, ETH_MAX_PACKET + ETH_HEADER_OTHER,
+                          pri->promisc, 0, errors);
+       if (p == NULL) {
                printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - "
                       "'%s'\n", errors);
                return -EINVAL;
@@ -43,50 +40,55 @@ static int pcap_open(void *data)
        __u32 netmask;
        int err;
 
-       if(pri->pcap == NULL)
+       if (pri->pcap == NULL)
                return -ENODEV;
 
-       if(pri->filter != NULL){
+       if (pri->filter != NULL) {
                err = dev_netmask(pri->dev, &netmask);
-               if(err < 0){
+               if (err < 0) {
                        printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n");
                        return -EIO;
                }
 
-               pri->compiled = kmalloc(sizeof(struct bpf_program), UM_GFP_KERNEL);
-               if(pri->compiled == NULL){
+               pri->compiled = kmalloc(sizeof(struct bpf_program),
+                                       UM_GFP_KERNEL);
+               if (pri->compiled == NULL) {
                        printk(UM_KERN_ERR "pcap_open : kmalloc failed\n");
                        return -ENOMEM;
                }
 
-               err = pcap_compile(pri->pcap, 
-                                  (struct bpf_program *) pri->compiled, 
+               err = pcap_compile(pri->pcap,
+                                  (struct bpf_program *) pri->compiled,
                                   pri->filter, pri->optimize, netmask);
-               if(err < 0){
+               if (err < 0) {
                        printk(UM_KERN_ERR "pcap_open : pcap_compile failed - "
                               "'%s'\n", pcap_geterr(pri->pcap));
-                       return -EIO;
+                       goto out;
                }
 
                err = pcap_setfilter(pri->pcap, pri->compiled);
-               if(err < 0){
+               if (err < 0) {
                        printk(UM_KERN_ERR "pcap_open : pcap_setfilter "
                               "failed - '%s'\n", pcap_geterr(pri->pcap));
-                       return -EIO;
+                       goto out;
                }
        }
 
        return PCAP_FD(pri->pcap);
+
+ out:
+       kfree(pri->compiled);
+       return -EIO;
 }
 
 static void pcap_remove(void *data)
 {
        struct pcap_data *pri = data;
 
-       if(pri->compiled != NULL)
+       if (pri->compiled != NULL)
                pcap_freecode(pri->compiled);
 
-       if(pri->pcap != NULL)
+       if (pri->pcap != NULL)
                pcap_close(pri->pcap);
 }
 
@@ -95,7 +97,7 @@ struct pcap_handler_data {
        int len;
 };
 
-static void handler(u_char *data, const struct pcap_pkthdr *header, 
+static void handler(u_char *data, const struct pcap_pkthdr *header,
                    const u_char *packet)
 {
        int len;
@@ -115,12 +117,12 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
        int n;
 
        n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata);
-       if(n < 0){
+       if (n < 0) {
                printk(UM_KERN_ERR "pcap_dispatch failed - %s\n",
                       pcap_geterr(pri->pcap));
                return -EIO;
        }
-       else if(n == 0) 
+       else if (n == 0)
                return 0;
        return hdata.len;
 }
@@ -130,8 +132,8 @@ const struct net_user_info pcap_user_info = {
        .open           = pcap_open,
        .close          = NULL,
        .remove         = pcap_remove,
-       .set_mtu        = NULL,
        .add_address    = NULL,
        .delete_address = NULL,
-       .max_packet     = MAX_PACKET - ETH_HEADER_OTHER
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_OTHER,
 };
index 1c8efd9..330543b 100644 (file)
@@ -1,24 +1,16 @@
 /*
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
-#include "linux/list.h"
-#include "linux/sched.h"
-#include "linux/slab.h"
+#include "linux/completion.h"
 #include "linux/interrupt.h"
-#include "linux/spinlock.h"
-#include "linux/errno.h"
+#include "linux/list.h"
 #include "asm/atomic.h"
-#include "asm/semaphore.h"
-#include "asm/errno.h"
-#include "kern_util.h"
-#include "kern.h"
-#include "irq_user.h"
-#include "irq_kern.h"
-#include "port.h"
 #include "init.h"
+#include "irq_kern.h"
 #include "os.h"
+#include "port.h"
 
 struct port_list {
        struct list_head list;
@@ -53,8 +45,8 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
        int fd;
 
        fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
-       if(fd < 0){
-               if(fd == -EAGAIN)
+       if (fd < 0) {
+               if (fd == -EAGAIN)
                        return IRQ_NONE;
 
                printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
@@ -81,18 +73,18 @@ static irqreturn_t pipe_interrupt(int irq, void *data)
 static int port_accept(struct port_list *port)
 {
        struct connection *conn;
-       int fd, socket[2], pid, ret = 0;
+       int fd, socket[2], pid;
 
        fd = port_connection(port->fd, socket, &pid);
-       if(fd < 0){
-               if(fd != -EAGAIN)
+       if (fd < 0) {
+               if (fd != -EAGAIN)
                        printk(KERN_ERR "port_accept : port_connection "
                               "returned %d\n", -fd);
                goto out;
        }
 
        conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
-       if(conn == NULL){
+       if (conn == NULL) {
                printk(KERN_ERR "port_accept : failed to allocate "
                       "connection\n");
                goto out_close;
@@ -104,17 +96,17 @@ static int port_accept(struct port_list *port)
                  .telnetd_pid  = pid,
                  .port         = port });
 
-       if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
+       if (um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
                          IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
-                         "telnetd", conn)){
+                         "telnetd", conn)) {
                printk(KERN_ERR "port_accept : failed to get IRQ for "
                       "telnetd\n");
                goto out_free;
        }
 
-       if(atomic_read(&port->wait_count) == 0){
+       if (atomic_read(&port->wait_count) == 0) {
                os_write_file(fd, NO_WAITER_MSG, sizeof(NO_WAITER_MSG));
-               printk("No one waiting for port\n");
+               printk(KERN_ERR "No one waiting for port\n");
        }
        list_add(&conn->list, &port->pending);
        return 1;
@@ -123,28 +115,29 @@ static int port_accept(struct port_list *port)
        kfree(conn);
  out_close:
        os_close_file(fd);
-       if(pid != -1)
-               os_kill_process(pid, 1);
+       os_kill_process(pid, 1);
  out:
-       return ret;
+       return 0;
 }
 
 static DECLARE_MUTEX(ports_sem);
 static LIST_HEAD(ports);
 
-void port_work_proc(struct work_struct *unused)
+static void port_work_proc(struct work_struct *unused)
 {
        struct port_list *port;
        struct list_head *ele;
        unsigned long flags;
 
        local_irq_save(flags);
-       list_for_each(ele, &ports){
+       list_for_each(ele, &ports) {
                port = list_entry(ele, struct port_list, list);
-               if(!port->has_connection)
+               if (!port->has_connection)
                        continue;
+
                reactivate_fd(port->fd, ACCEPT_IRQ);
-               while(port_accept(port)) ;
+               while (port_accept(port))
+                       ;
                port->has_connection = 0;
        }
        local_irq_restore(flags);
@@ -169,25 +162,27 @@ void *port_data(int port_num)
        int fd;
 
        down(&ports_sem);
-       list_for_each(ele, &ports){
+       list_for_each(ele, &ports) {
                port = list_entry(ele, struct port_list, list);
-               if(port->port == port_num) goto found;
+               if (port->port == port_num)
+                       goto found;
        }
        port = kmalloc(sizeof(struct port_list), GFP_KERNEL);
-       if(port == NULL){
+       if (port == NULL) {
                printk(KERN_ERR "Allocation of port list failed\n");
                goto out;
        }
 
        fd = port_listen_fd(port_num);
-       if(fd < 0){
+       if (fd < 0) {
                printk(KERN_ERR "binding to port %d failed, errno = %d\n",
                       port_num, -fd);
                goto out_free;
        }
-       if(um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
+
+       if (um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
                          IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
-                         "port", port)){
+                         "port", port)) {
                printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
                goto out_close;
        }
@@ -206,7 +201,7 @@ void *port_data(int port_num)
 
  found:
        dev = kmalloc(sizeof(struct port_dev), GFP_KERNEL);
-       if(dev == NULL){
+       if (dev == NULL) {
                printk(KERN_ERR "Allocation of port device entry failed\n");
                goto out;
        }
@@ -216,10 +211,10 @@ void *port_data(int port_num)
                                    .telnetd_pid        = -1 });
        goto out;
 
- out_free:
-       kfree(port);
  out_close:
        os_close_file(fd);
+ out_free:
+       kfree(port);
  out:
        up(&ports_sem);
        return dev;
@@ -233,9 +228,9 @@ int port_wait(void *data)
        int fd;
 
        atomic_inc(&port->wait_count);
-       while(1){
+       while (1) {
                fd = -ERESTARTSYS;
-               if(wait_for_completion_interruptible(&port->done))
+               if (wait_for_completion_interruptible(&port->done))
                        goto out;
 
                spin_lock(&port->lock);
@@ -258,7 +253,8 @@ int port_wait(void *data)
                 */
                free_irq(TELNETD_IRQ, conn);
 
-               if(conn->fd >= 0) break;
+               if (conn->fd >= 0)
+                       break;
                os_close_file(conn->fd);
                kfree(conn);
        }
@@ -276,9 +272,9 @@ void port_remove_dev(void *d)
 {
        struct port_dev *dev = d;
 
-       if(dev->helper_pid != -1)
+       if (dev->helper_pid != -1)
                os_kill_process(dev->helper_pid, 0);
-       if(dev->telnetd_pid != -1)
+       if (dev->telnetd_pid != -1)
                os_kill_process(dev->telnetd_pid, 1);
        dev->helper_pid = -1;
        dev->telnetd_pid = -1;
@@ -297,7 +293,7 @@ static void free_port(void)
        struct list_head *ele;
        struct port_list *port;
 
-       list_for_each(ele, &ports){
+       list_for_each(ele, &ports) {
                port = list_entry(ele, struct port_list, list);
                free_irq_by_fd(port->fd);
                os_close_file(port->fd);
index c799b00..addd759 100644 (file)
@@ -1,24 +1,20 @@
 /*
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
 #include <stdio.h>
-#include <stddef.h>
 #include <stdlib.h>
-#include <string.h>
 #include <errno.h>
-#include <unistd.h>
 #include <termios.h>
-#include <sys/socket.h>
-#include <sys/un.h>
+#include <unistd.h>
 #include <netinet/in.h>
-#include "kern_util.h"
-#include "user.h"
 #include "chan_user.h"
-#include "port.h"
+#include "kern_constants.h"
 #include "os.h"
+#include "port.h"
 #include "um_malloc.h"
+#include "user.h"
 
 struct port_chan {
        int raw;
@@ -34,24 +30,25 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
        char *end;
        int port;
 
-       if(*str != ':'){
-               printk("port_init : channel type 'port' must specify a "
-                      "port number\n");
+       if (*str != ':') {
+               printk(UM_KERN_ERR "port_init : channel type 'port' must "
+                      "specify a port number\n");
                return NULL;
        }
        str++;
        port = strtoul(str, &end, 0);
-       if((*end != '\0') || (end == str)){
-               printk("port_init : couldn't parse port '%s'\n", str);
+       if ((*end != '\0') || (end == str)) {
+               printk(UM_KERN_ERR "port_init : couldn't parse port '%s'\n",
+                      str);
                return NULL;
        }
 
        kern_data = port_data(port);
-       if(kern_data == NULL)
+       if (kern_data == NULL)
                return NULL;
 
        data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
-       if(data == NULL)
+       if (data == NULL)
                goto err;
 
        *data = ((struct port_chan) { .raw              = opts->raw,
@@ -79,13 +76,13 @@ static int port_open(int input, int output, int primary, void *d,
        int fd, err;
 
        fd = port_wait(data->kernel_data);
-       if((fd >= 0) && data->raw){
+       if ((fd >= 0) && data->raw) {
                CATCH_EINTR(err = tcgetattr(fd, &data->tt));
-               if(err)
+               if (err)
                        return err;
 
                err = raw(fd);
-               if(err)
+               if (err)
                        return err;
        }
        *dev_out = data->dev;
@@ -119,11 +116,11 @@ int port_listen_fd(int port)
        int fd, err, arg;
 
        fd = socket(PF_INET, SOCK_STREAM, 0);
-       if(fd == -1)
+       if (fd == -1)
                return -errno;
 
        arg = 1;
-       if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){
+       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0) {
                err = -errno;
                goto out;
        }
@@ -131,23 +128,23 @@ int port_listen_fd(int port)
        addr.sin_family = AF_INET;
        addr.sin_port = htons(port);
        addr.sin_addr.s_addr = htonl(INADDR_ANY);
-       if(bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0){
+       if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                err = -errno;
                goto out;
        }
 
-       if(listen(fd, 1) < 0){
+       if (listen(fd, 1) < 0) {
                err = -errno;
                goto out;
        }
 
        err = os_set_fd_block(fd, 0);
-       if(err < 0)
+       if (err < 0)
                goto out;
 
        return fd;
  out:
-       os_close_file(fd);
+       close(fd);
        return err;
 }
 
@@ -163,10 +160,10 @@ void port_pre_exec(void *arg)
        dup2(data->sock_fd, 0);
        dup2(data->sock_fd, 1);
        dup2(data->sock_fd, 2);
-       os_close_file(data->sock_fd);
+       close(data->sock_fd);
        dup2(data->pipe_fd, 3);
-       os_shutdown_socket(3, 1, 0);
-       os_close_file(data->pipe_fd);
+       shutdown(3, SHUT_RD);
+       close(data->pipe_fd);
 }
 
 int port_connection(int fd, int *socket, int *pid_out)
@@ -176,12 +173,12 @@ int port_connection(int fd, int *socket, int *pid_out)
                         "/usr/lib/uml/port-helper", NULL };
        struct port_pre_exec_data data;
 
-       new = os_accept_connection(fd);
-       if(new < 0)
-               return new;
+       new = accept(fd, NULL, 0);
+       if (new < 0)
+               return -errno;
 
        err = os_pipe(socket, 0, 0);
-       if(err < 0)
+       if (err < 0)
                goto out_close;
 
        data = ((struct port_pre_exec_data)
@@ -189,18 +186,18 @@ int port_connection(int fd, int *socket, int *pid_out)
                  .pipe_fd              = socket[1] });
 
        err = run_helper(port_pre_exec, &data, argv);
-       if(err < 0)
+       if (err < 0)
                goto out_shutdown;
 
        *pid_out = err;
        return new;
 
  out_shutdown:
-       os_shutdown_socket(socket[0], 1, 1);
-       os_close_file(socket[0]);
-       os_shutdown_socket(socket[1], 1, 1);
-       os_close_file(socket[1]);
+       shutdown(socket[0], SHUT_RDWR);
+       close(socket[0]);
+       shutdown(socket[1], SHUT_RDWR);
+       close(socket[1]);
  out_close:
-       os_close_file(new);
+       close(new);
        return err;
 }
index 1e3fd61..49c79dd 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
@@ -6,16 +6,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <string.h>
 #include <termios.h>
 #include <sys/stat.h>
 #include "chan_user.h"
-#include "os.h"
-#include "user.h"
 #include "kern_constants.h"
+#include "os.h"
 #include "um_malloc.h"
+#include "user.h"
 
 struct pty_chan {
        void (*announce)(char *dev_name, int dev);
@@ -33,7 +33,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts)
        if (data == NULL)
                return NULL;
 
-       *data = ((struct pty_chan) { .announce          = opts->announce, 
+       *data = ((struct pty_chan) { .announce          = opts->announce,
                                     .dev               = device,
                                     .raw               = opts->raw });
        return data;
@@ -56,11 +56,11 @@ static int pts_open(int input, int output, int primary, void *d,
        if (data->raw) {
                CATCH_EINTR(err = tcgetattr(fd, &data->tt));
                if (err)
-                       return err;
+                       goto out_close;
 
                err = raw(fd);
                if (err)
-                       return err;
+                       goto out_close;
        }
 
        dev = ptsname(fd);
@@ -71,6 +71,10 @@ static int pts_open(int input, int output, int primary, void *d,
                (*data->announce)(dev, data->dev);
 
        return fd;
+
+out_close:
+       close(fd);
+       return err;
 }
 
 static int getmaster(char *line)
@@ -97,7 +101,7 @@ static int getmaster(char *line)
                                *tp = 't';
                                err = access(line, R_OK | W_OK);
                                *tp = 'p';
-                               if(!err)
+                               if (!err)
                                        return master;
                                close(master);
                        }
@@ -119,12 +123,14 @@ static int pty_open(int input, int output, int primary, void *d,
        if (fd < 0)
                return fd;
 
-       if(data->raw){
+       if (data->raw) {
                err = raw(fd);
-               if (err)
+               if (err) {
+                       close(fd);
                        return err;
+               }
        }
-       
+
        if (data->announce)
                (*data->announce)(dev, data->dev);
 
index 125c44f..6b4a0f9 100644 (file)
@@ -1,11 +1,12 @@
-#include "linux/kernel.h"
-#include "linux/stddef.h"
-#include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/if_arp.h"
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL.
+ */
+
+#include <linux/if_arp.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
 #include "net_kern.h"
-#include "net_user.h"
-#include "kern.h"
 #include "slip.h"
 
 struct slip_init {
@@ -30,10 +31,8 @@ void slip_init(struct net_device *dev, void *data)
        slip_proto_init(&spri->slip);
 
        dev->init = NULL;
-       dev->header_cache_update = NULL;
-       dev->hard_header_cache = NULL;
-       dev->hard_header = NULL;
        dev->hard_header_len = 0;
+       dev->header_ops = NULL;
        dev->addr_len = 0;
        dev->type = ARPHRD_SLIP;
        dev->tx_queue_len = 256;
@@ -43,21 +42,19 @@ void slip_init(struct net_device *dev, void *data)
 
 static unsigned short slip_protocol(struct sk_buff *skbuff)
 {
-       return(htons(ETH_P_IP));
+       return htons(ETH_P_IP);
 }
 
-static int slip_read(int fd, struct sk_buff **skb, 
-                      struct uml_net_private *lp)
+static int slip_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(slip_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu,
-                             (struct slip_data *) &lp->user));
+       return slip_user_read(fd, skb_mac_header(skb), skb->dev->mtu,
+                             (struct slip_data *) &lp->user);
 }
 
-static int slip_write(int fd, struct sk_buff **skb,
-                     struct uml_net_private *lp)
+static int slip_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(slip_user_write(fd, (*skb)->data, (*skb)->len, 
-                              (struct slip_data *) &lp->user));
+       return slip_user_write(fd, skb->data, skb->len,
+                              (struct slip_data *) &lp->user);
 }
 
 const struct net_kern_info slip_kern_info = {
@@ -71,12 +68,11 @@ static int slip_setup(char *str, char **mac_out, void *data)
 {
        struct slip_init *init = data;
 
-       *init = ((struct slip_init)
-               { .gate_addr            = NULL });
+       *init = ((struct slip_init) { .gate_addr = NULL });
 
-       if(str[0] != '\0') 
+       if (str[0] != '\0')
                init->gate_addr = str;
-       return(1);
+       return 1;
 }
 
 static struct transport slip_transport = {
index c0b73c2..5f06204 100644 (file)
@@ -1,21 +1,22 @@
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL.
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <stddef.h>
-#include <sched.h>
-#include <string.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <string.h>
 #include <sys/termios.h>
 #include <sys/wait.h>
-#include <sys/signal.h>
-#include "kern_util.h"
-#include "user.h"
+#include "kern_constants.h"
 #include "net_user.h"
-#include "slip.h"
-#include "slip_common.h"
 #include "os.h"
+#include "slip.h"
 #include "um_malloc.h"
-#include "kern_constants.h"
+#include "user.h"
 
 static int slip_user_init(void *data, void *dev)
 {
@@ -31,8 +32,9 @@ static int set_up_tty(int fd)
        struct termios tios;
 
        if (tcgetattr(fd, &tios) < 0) {
-               printk("could not get initial terminal attributes\n");
-               return(-1);
+               printk(UM_KERN_ERR "could not get initial terminal "
+                      "attributes\n");
+               return -1;
        }
 
        tios.c_cflag = CS8 | CREAD | HUPCL | CLOCAL;
@@ -48,10 +50,10 @@ static int set_up_tty(int fd)
        cfsetispeed(&tios, B38400);
 
        if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) {
-               printk("failed to set terminal attributes\n");
-               return(-1);
+               printk(UM_KERN_ERR "failed to set terminal attributes\n");
+               return -1;
        }
-       return(0);
+       return 0;
 }
 
 struct slip_pre_exec_data {
@@ -64,9 +66,11 @@ static void slip_pre_exec(void *arg)
 {
        struct slip_pre_exec_data *data = arg;
 
-       if(data->stdin >= 0) dup2(data->stdin, 0);
+       if (data->stdin >= 0)
+               dup2(data->stdin, 0);
        dup2(data->stdout, 1);
-       if(data->close_me >= 0) os_close_file(data->close_me);
+       if (data->close_me >= 0)
+               close(data->close_me);
 }
 
 static int slip_tramp(char **argv, int fd)
@@ -76,8 +80,9 @@ static int slip_tramp(char **argv, int fd)
        int status, pid, fds[2], err, output_len;
 
        err = os_pipe(fds, 1, 0);
-       if(err < 0){
-               printk("slip_tramp : pipe failed, err = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "slip_tramp : pipe failed, err = %d\n",
+                      -err);
                goto out;
        }
 
@@ -86,41 +91,42 @@ static int slip_tramp(char **argv, int fd)
        pe_data.stdout = fds[1];
        pe_data.close_me = fds[0];
        err = run_helper(slip_pre_exec, &pe_data, argv);
-       if(err < 0)
+       if (err < 0)
                goto out_close;
        pid = err;
 
        output_len = UM_KERN_PAGE_SIZE;
        output = kmalloc(output_len, UM_GFP_KERNEL);
-       if(output == NULL){
-               printk("slip_tramp : failed to allocate output buffer\n");
+       if (output == NULL) {
+               printk(UM_KERN_ERR "slip_tramp : failed to allocate output "
+                      "buffer\n");
                os_kill_process(pid, 1);
                err = -ENOMEM;
                goto out_free;
        }
 
-       os_close_file(fds[1]);
+       close(fds[1]);
        read_output(fds[0], output, output_len);
        printk("%s", output);
 
        CATCH_EINTR(err = waitpid(pid, &status, 0));
-       if(err < 0)
+       if (err < 0)
                err = errno;
-       else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
-               printk("'%s' didn't exit with status 0\n", argv[0]);
+       else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
+               printk(UM_KERN_ERR "'%s' didn't exit with status 0\n", argv[0]);
                err = -EINVAL;
        }
        else err = 0;
 
-       os_close_file(fds[0]);
+       close(fds[0]);
 
 out_free:
        kfree(output);
        return err;
 
 out_close:
-       os_close_file(fds[0]);
-       os_close_file(fds[1]);
+       close(fds[0]);
+       close(fds[1]);
 out:
        return err;
 }
@@ -130,60 +136,64 @@ static int slip_open(void *data)
        struct slip_data *pri = data;
        char version_buf[sizeof("nnnnn\0")];
        char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
-       char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf, 
+       char *argv[] = { "uml_net", version_buf, "slip", "up", gate_buf,
                         NULL };
        int sfd, mfd, err;
 
        err = get_pty();
-       if(err < 0){
-               printk("slip-open : Failed to open pty, err = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "slip-open : Failed to open pty, err = %d\n",
+                      -err);
                goto out;
        }
        mfd = err;
 
-       err = os_open_file(ptsname(mfd), of_rdwr(OPENFLAGS()), 0);
-       if(err < 0){
-               printk("Couldn't open tty for slip line, err = %d\n", -err);
+       err = open(ptsname(mfd), O_RDWR, 0);
+       if (err < 0) {
+               printk(UM_KERN_ERR "Couldn't open tty for slip line, "
+                      "err = %d\n", -err);
                goto out_close;
        }
        sfd = err;
 
-       if(set_up_tty(sfd))
+       if (set_up_tty(sfd))
                goto out_close2;
 
        pri->slave = sfd;
        pri->slip.pos = 0;
        pri->slip.esc = 0;
-       if(pri->gate_addr != NULL){
+       if (pri->gate_addr != NULL) {
                sprintf(version_buf, "%d", UML_NET_VERSION);
                strcpy(gate_buf, pri->gate_addr);
 
                err = slip_tramp(argv, sfd);
 
-               if(err < 0){
-                       printk("slip_tramp failed - err = %d\n", -err);
+               if (err < 0) {
+                       printk(UM_KERN_ERR "slip_tramp failed - err = %d\n",
+                              -err);
                        goto out_close2;
                }
                err = os_get_ifname(pri->slave, pri->name);
-               if(err < 0){
-                       printk("get_ifname failed, err = %d\n", -err);
+               if (err < 0) {
+                       printk(UM_KERN_ERR "get_ifname failed, err = %d\n",
+                              -err);
                        goto out_close2;
                }
                iter_addresses(pri->dev, open_addr, pri->name);
        }
        else {
                err = os_set_slip(sfd);
-               if(err < 0){
-                       printk("Failed to set slip discipline encapsulation - "
-                              "err = %d\n", -err);
+               if (err < 0) {
+                       printk(UM_KERN_ERR "Failed to set slip discipline "
+                              "encapsulation - err = %d\n", -err);
                        goto out_close2;
                }
        }
-       return(mfd);
+       return mfd;
 out_close2:
-       os_close_file(sfd);
+       close(sfd);
 out_close:
-       os_close_file(mfd);
+       close(mfd);
 out:
        return err;
 }
@@ -192,21 +202,21 @@ static void slip_close(int fd, void *data)
 {
        struct slip_data *pri = data;
        char version_buf[sizeof("nnnnn\0")];
-       char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name, 
+       char *argv[] = { "uml_net", version_buf, "slip", "down", pri->name,
                         NULL };
        int err;
 
-       if(pri->gate_addr != NULL)
+       if (pri->gate_addr != NULL)
                iter_addresses(pri->dev, close_addr, pri->name);
 
        sprintf(version_buf, "%d", UML_NET_VERSION);
 
        err = slip_tramp(argv, pri->slave);
 
-       if(err != 0)
-               printk("slip_tramp failed - errno = %d\n", -err);
-       os_close_file(fd);
-       os_close_file(pri->slave);
+       if (err != 0)
+               printk(UM_KERN_ERR "slip_tramp failed - errno = %d\n", -err);
+       close(fd);
+       close(pri->slave);
        pri->slave = -1;
 }
 
@@ -220,17 +230,13 @@ int slip_user_write(int fd, void *buf, int len, struct slip_data *pri)
        return slip_proto_write(fd, buf, len, &pri->slip);
 }
 
-static int slip_set_mtu(int mtu, void *data)
-{
-       return(mtu);
-}
-
 static void slip_add_addr(unsigned char *addr, unsigned char *netmask,
                          void *data)
 {
        struct slip_data *pri = data;
 
-       if(pri->slave < 0) return;
+       if (pri->slave < 0)
+               return;
        open_addr(addr, netmask, pri->name);
 }
 
@@ -239,7 +245,8 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
 {
        struct slip_data *pri = data;
 
-       if(pri->slave < 0) return;
+       if (pri->slave < 0)
+               return;
        close_addr(addr, netmask, pri->name);
 }
 
@@ -248,8 +255,8 @@ const struct net_user_info slip_user_info = {
        .open           = slip_open,
        .close          = slip_close,
        .remove         = NULL,
-       .set_mtu        = slip_set_mtu,
        .add_address    = slip_add_addr,
        .delete_address = slip_del_addr,
-       .max_packet     = BUF_SIZE
+       .mtu            = BUF_SIZE,
+       .max_packet     = BUF_SIZE,
 };
index 0a0324a..d987af2 100644 (file)
@@ -1,11 +1,14 @@
-#include "linux/kernel.h"
-#include "linux/stddef.h"
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL.
+ */
+
+#include <linux/if_arp.h>
 #include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/if_arp.h"
+#include <linux/netdevice.h>
+#include <linux/string.h>
 #include "net_kern.h"
 #include "net_user.h"
-#include "kern.h"
 #include "slirp.h"
 
 struct slirp_init {
@@ -31,37 +34,32 @@ void slirp_init(struct net_device *dev, void *data)
 
        dev->init = NULL;
        dev->hard_header_len = 0;
-       dev->header_cache_update = NULL;
-       dev->hard_header_cache = NULL;
-       dev->hard_header = NULL;
+       dev->header_ops = NULL;
        dev->addr_len = 0;
        dev->type = ARPHRD_SLIP;
        dev->tx_queue_len = 256;
        dev->flags = IFF_NOARP;
        printk("SLIRP backend - command line:");
-       for(i=0;spri->argw.argv[i]!=NULL;i++) {
+       for (i = 0; spri->argw.argv[i] != NULL; i++)
                printk(" '%s'",spri->argw.argv[i]);
-       }
        printk("\n");
 }
 
 static unsigned short slirp_protocol(struct sk_buff *skbuff)
 {
-       return(htons(ETH_P_IP));
+       return htons(ETH_P_IP);
 }
 
-static int slirp_read(int fd, struct sk_buff **skb, 
-                      struct uml_net_private *lp)
+static int slirp_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(slirp_user_read(fd, skb_mac_header(*skb), (*skb)->dev->mtu,
-                             (struct slirp_data *) &lp->user));
+       return slirp_user_read(fd, skb_mac_header(skb), skb->dev->mtu,
+                              (struct slirp_data *) &lp->user);
 }
 
-static int slirp_write(int fd, struct sk_buff **skb,
-                     struct uml_net_private *lp)
+static int slirp_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(slirp_user_write(fd, (*skb)->data, (*skb)->len, 
-                              (struct slirp_data *) &lp->user));
+       return slirp_user_write(fd, skb->data, skb->len,
+                               (struct slirp_data *) &lp->user);
 }
 
 const struct net_kern_info slirp_kern_info = {
@@ -76,31 +74,32 @@ static int slirp_setup(char *str, char **mac_out, void *data)
        struct slirp_init *init = data;
        int i=0;
 
-       *init = ((struct slirp_init)
-               { .argw = { { "slirp", NULL  } } });
+       *init = ((struct slirp_init) { .argw = { { "slirp", NULL  } } });
 
        str = split_if_spec(str, mac_out, NULL);
 
-       if(str == NULL) { /* no command line given after MAC addr */
-               return(1);
-       }
+       if (str == NULL) /* no command line given after MAC addr */
+               return 1;
 
        do {
-               if(i>=SLIRP_MAX_ARGS-1) {
-                       printk("slirp_setup: truncating slirp arguments\n");
+               if (i >= SLIRP_MAX_ARGS - 1) {
+                       printk(KERN_WARNING "slirp_setup: truncating slirp "
+                              "arguments\n");
                        break;
                }
                init->argw.argv[i++] = str;
                while(*str && *str!=',') {
-                       if(*str=='_') *str=' ';
+                       if (*str == '_')
+                               *str=' ';
                        str++;
                }
-               if(*str!=',')
+               if (*str != ',')
                        break;
-               *str++='\0';
-       } while(1);
-       init->argw.argv[i]=NULL;
-       return(1);
+               *str++ = '\0';
+       } while (1);
+
+       init->argw.argv[i] = NULL;
+       return 1;
 }
 
 static struct transport slirp_transport = {
index 0e462f6..1865089 100644 (file)
@@ -1,18 +1,17 @@
-#include <stdio.h>
-#include <stdlib.h>
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL.
+ */
+
 #include <unistd.h>
-#include <stddef.h>
-#include <sched.h>
-#include <string.h>
 #include <errno.h>
+#include <string.h>
 #include <sys/wait.h>
-#include <sys/signal.h>
-#include "kern_util.h"
-#include "user.h"
+#include "kern_constants.h"
 #include "net_user.h"
-#include "slirp.h"
-#include "slip_common.h"
 #include "os.h"
+#include "slirp.h"
+#include "user.h"
 
 static int slirp_user_init(void *data, void *dev)
 {
@@ -31,8 +30,10 @@ static void slirp_pre_exec(void *arg)
 {
        struct slirp_pre_exec_data *data = arg;
 
-       if(data->stdin != -1) dup2(data->stdin, 0);
-       if(data->stdout != -1) dup2(data->stdout, 1);
+       if (data->stdin != -1)
+               dup2(data->stdin, 0);
+       if (data->stdout != -1)
+               dup2(data->stdout, 1);
 }
 
 static int slirp_tramp(char **argv, int fd)
@@ -44,7 +45,7 @@ static int slirp_tramp(char **argv, int fd)
        pe_data.stdout = fd;
        pid = run_helper(slirp_pre_exec, &pe_data, argv);
 
-       return(pid);
+       return pid;
 }
 
 static int slirp_open(void *data)
@@ -53,12 +54,12 @@ static int slirp_open(void *data)
        int fds[2], pid, err;
 
        err = os_pipe(fds, 1, 1);
-       if(err)
-               return(err);
+       if (err)
+               return err;
 
        err = slirp_tramp(pri->argw.argv, fds[1]);
-       if(err < 0){
-               printk("slirp_tramp failed - errno = %d\n", -err);
+       if (err < 0) {
+               printk(UM_KERN_ERR "slirp_tramp failed - errno = %d\n", -err);
                goto out;
        }
        pid = err;
@@ -68,10 +69,10 @@ static int slirp_open(void *data)
        pri->slip.esc = 0;
        pri->pid = err;
 
-       return(fds[0]);
+       return fds[0];
 out:
-       os_close_file(fds[0]);
-       os_close_file(fds[1]);
+       close(fds[0]);
+       close(fds[1]);
        return err;
 }
 
@@ -80,31 +81,33 @@ static void slirp_close(int fd, void *data)
        struct slirp_data *pri = data;
        int status,err;
 
-       os_close_file(fd);
-       os_close_file(pri->slave);
+       close(fd);
+       close(pri->slave);
 
        pri->slave = -1;
 
-       if(pri->pid<1) {
-               printk("slirp_close: no child process to shut down\n");
+       if (pri->pid<1) {
+               printk(UM_KERN_ERR "slirp_close: no child process to shut "
+                      "down\n");
                return;
        }
 
 #if 0
-       if(kill(pri->pid, SIGHUP)<0) {
-               printk("slirp_close: sending hangup to %d failed (%d)\n",
-                       pri->pid, errno);
+       if (kill(pri->pid, SIGHUP)<0) {
+               printk(UM_KERN_ERR "slirp_close: sending hangup to %d failed "
+                      "(%d)\n", pri->pid, errno);
        }
 #endif
 
        CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
-       if(err < 0) {
-               printk("slirp_close: waitpid returned %d\n", errno);
+       if (err < 0) {
+               printk(UM_KERN_ERR "slirp_close: waitpid returned %d\n", errno);
                return;
        }
 
-       if(err == 0) {
-               printk("slirp_close: process %d has not exited\n", pri->pid);
+       if (err == 0) {
+               printk(UM_KERN_ERR "slirp_close: process %d has not exited\n",
+                      pri->pid);
                return;
        }
 
@@ -121,18 +124,13 @@ int slirp_user_write(int fd, void *buf, int len, struct slirp_data *pri)
        return slip_proto_write(fd, buf, len, &pri->slip);
 }
 
-static int slirp_set_mtu(int mtu, void *data)
-{
-       return(mtu);
-}
-
 const struct net_user_info slirp_user_info = {
        .init           = slirp_user_init,
        .open           = slirp_open,
        .close          = slirp_close,
        .remove         = NULL,
-       .set_mtu        = slirp_set_mtu,
        .add_address    = NULL,
        .delete_address = NULL,
-       .max_packet     = BUF_SIZE
+       .mtu            = BUF_SIZE,
+       .max_packet     = BUF_SIZE,
 };
index 4739dd5..d07a97f 100644 (file)
@@ -8,7 +8,7 @@
 /* trivial console driver -- simply dump everything to stderr                    */
 
 /*
- * Don't register by default -- as this registeres very early in the
+ * Don't register by default -- as this registers very early in the
  * boot process it becomes the default console.
  *
  * Initialized at init time.
index a9f87e1..c930fed 100644 (file)
@@ -1,16 +1,16 @@
 /*
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
-#include <stdio.h>
-#include <termios.h>
 #include <errno.h>
-#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
 #include "chan_user.h"
-#include "user.h"
+#include "kern_constants.h"
 #include "os.h"
 #include "um_malloc.h"
+#include "user.h"
 
 struct tty_chan {
        char *dev;
@@ -22,15 +22,15 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts)
 {
        struct tty_chan *data;
 
-       if(*str != ':'){
-               printk("tty_init : channel type 'tty' must specify "
+       if (*str != ':') {
+               printk(UM_KERN_ERR "tty_init : channel type 'tty' must specify "
                       "a device\n");
                return NULL;
        }
        str++;
 
        data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
-       if(data == NULL)
+       if (data == NULL)
                return NULL;
        *data = ((struct tty_chan) { .dev       = str,
                                     .raw       = opts->raw });
@@ -42,19 +42,26 @@ static int tty_open(int input, int output, int primary, void *d,
                    char **dev_out)
 {
        struct tty_chan *data = d;
-       int fd, err;
+       int fd, err, mode = 0;
+
+       if (input && output)
+               mode = O_RDWR;
+       else if (input)
+               mode = O_RDONLY;
+       else if (output)
+               mode = O_WRONLY;
 
-       fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0);
-       if(fd < 0)
-               return fd;
+       fd = open(data->dev, mode);
+       if (fd < 0)
+               return -errno;
 
-       if(data->raw){
+       if (data->raw) {
                CATCH_EINTR(err = tcgetattr(fd, &data->tt));
-               if(err)
+               if (err)
                        return err;
 
                err = raw(fd);
-               if(err)
+               if (err)
                        return err;
        }
 
index 0eabe73..7e6cdde 100644 (file)
@@ -35,6 +35,7 @@
 #include "linux/genhd.h"
 #include "linux/spinlock.h"
 #include "linux/platform_device.h"
+#include "linux/scatterlist.h"
 #include "asm/segment.h"
 #include "asm/uaccess.h"
 #include "asm/irq.h"
@@ -615,7 +616,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
                blk_queue_max_sectors(ubd_dev->queue, 8 * sizeof(long));
 
                err = -ENOMEM;
-               ubd_dev->cow.bitmap = (void *) vmalloc(ubd_dev->cow.bitmap_len);
+               ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len);
                if(ubd_dev->cow.bitmap == NULL){
                        printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
                        goto error;
@@ -704,6 +705,7 @@ static int ubd_add(int n, char **error_out)
        ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
 
        INIT_LIST_HEAD(&ubd_dev->restart);
+       sg_init_table(ubd_dev->sg, MAX_SG);
 
        err = -ENOMEM;
        ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock);
@@ -1115,7 +1117,7 @@ static void do_ubd_request(struct request_queue *q)
                        }
                        prepare_request(req, io_req,
                                        (unsigned long long) req->sector << 9,
-                                       sg->offset, sg->length, sg->page);
+                                       sg->offset, sg->length, sg_page(sg));
 
                        last_sectors = sg->length >> 9;
                        n = os_write_file(thread_fd, &io_req,
diff --git a/arch/um/drivers/vde.h b/arch/um/drivers/vde.h
new file mode 100644 (file)
index 0000000..fc3a059
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
+ * Licensed under the GPL.
+ */
+
+#ifndef __UM_VDE_H__
+#define __UM_VDE_H__
+
+struct vde_data {
+       char *vde_switch;
+       char *descr;
+       void *args;
+       void *conn;
+       void *dev;
+};
+
+struct vde_init {
+       char *vde_switch;
+       char *descr;
+       int port;
+       char *group;
+       int mode;
+};
+
+extern const struct net_user_info vde_user_info;
+
+extern void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init);
+
+extern int vde_user_read(void *conn, void *buf, int len);
+extern int vde_user_write(void *conn, void *buf, int len);
+
+#endif
diff --git a/arch/um/drivers/vde_kern.c b/arch/um/drivers/vde_kern.c
new file mode 100644 (file)
index 0000000..add7e72
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
+ * Licensed under the GPL.
+ *
+ * Transport usage:
+ *  ethN=vde,<vde_switch>,<mac addr>,<port>,<group>,<mode>,<description>
+ *
+ */
+
+#include "linux/init.h"
+#include <linux/netdevice.h>
+#include "net_kern.h"
+#include "net_user.h"
+#include "vde.h"
+
+static void vde_init(struct net_device *dev, void *data)
+{
+       struct vde_init *init = data;
+       struct uml_net_private *pri;
+       struct vde_data *vpri;
+
+       pri = dev->priv;
+       vpri = (struct vde_data *) pri->user;
+
+       vpri->vde_switch = init->vde_switch;
+       vpri->descr = init->descr ? init->descr : "UML vde_transport";
+       vpri->args = NULL;
+       vpri->conn = NULL;
+       vpri->dev = dev;
+
+       printk("vde backend - %s, ", vpri->vde_switch ?
+              vpri->vde_switch : "(default socket)");
+
+       vde_init_libstuff(vpri, init);
+
+       printk("\n");
+}
+
+static int vde_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
+{
+       struct vde_data *pri = (struct vde_data *) &lp->user;
+
+       if (pri->conn != NULL)
+               return vde_user_read(pri->conn, skb_mac_header(skb),
+                                    skb->dev->mtu + ETH_HEADER_OTHER);
+
+       printk(KERN_ERR "vde_read - we have no VDECONN to read from");
+       return -EBADF;
+}
+
+static int vde_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
+{
+       struct vde_data *pri = (struct vde_data *) &lp->user;
+
+       if (pri->conn != NULL)
+               return vde_user_write((void *)pri->conn, skb->data,
+                                     skb->len);
+
+       printk(KERN_ERR "vde_write - we have no VDECONN to write to");
+       return -EBADF;
+}
+
+static const struct net_kern_info vde_kern_info = {
+       .init                   = vde_init,
+       .protocol               = eth_protocol,
+       .read                   = vde_read,
+       .write                  = vde_write,
+};
+
+static int vde_setup(char *str, char **mac_out, void *data)
+{
+       struct vde_init *init = data;
+       char *remain, *port_str = NULL, *mode_str = NULL, *last;
+
+       *init = ((struct vde_init)
+               { .vde_switch           = NULL,
+                 .descr                = NULL,
+                 .port                 = 0,
+                 .group                = NULL,
+                 .mode                 = 0 });
+
+       remain = split_if_spec(str, &init->vde_switch, mac_out, &port_str,
+                               &init->group, &mode_str, &init->descr, NULL);
+
+       if (remain != NULL)
+               printk(KERN_WARNING "vde_setup - Ignoring extra data :"
+                      "'%s'\n", remain);
+
+       if (port_str != NULL) {
+               init->port = simple_strtoul(port_str, &last, 10);
+               if ((*last != '\0') || (last == port_str)) {
+                       printk(KERN_ERR "vde_setup - Bad port : '%s'\n",
+                                               port_str);
+                       return 0;
+               }
+       }
+
+       if (mode_str != NULL) {
+               init->mode = simple_strtoul(mode_str, &last, 8);
+               if ((*last != '\0') || (last == mode_str)) {
+                       printk(KERN_ERR "vde_setup - Bad mode : '%s'\n",
+                                               mode_str);
+                       return 0;
+               }
+       }
+
+       printk(KERN_INFO "Configured vde device: %s\n", init->vde_switch ?
+              init->vde_switch : "(default socket)");
+
+       return 1;
+}
+
+static struct transport vde_transport = {
+       .list           = LIST_HEAD_INIT(vde_transport.list),
+       .name           = "vde",
+       .setup          = vde_setup,
+       .user           = &vde_user_info,
+       .kern           = &vde_kern_info,
+       .private_size   = sizeof(struct vde_data),
+       .setup_size     = sizeof(struct vde_init),
+};
+
+static int register_vde(void)
+{
+       register_transport(&vde_transport);
+       return 0;
+}
+
+late_initcall(register_vde);
diff --git a/arch/um/drivers/vde_user.c b/arch/um/drivers/vde_user.c
new file mode 100644 (file)
index 0000000..d9941fe
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2007 Luca Bigliardi (shammash@artha.org).
+ * Licensed under the GPL.
+ */
+
+#include <stddef.h>
+#include <errno.h>
+#include <libvdeplug.h>
+#include "kern_constants.h"
+#include "net_user.h"
+#include "um_malloc.h"
+#include "user.h"
+#include "vde.h"
+
+static int vde_user_init(void *data, void *dev)
+{
+       struct vde_data *pri = data;
+       VDECONN *conn = NULL;
+       int err = -EINVAL;
+
+       pri->dev = dev;
+
+       conn = vde_open(pri->vde_switch, pri->descr, pri->args);
+
+       if (conn == NULL) {
+               err = -errno;
+               printk(UM_KERN_ERR "vde_user_init: vde_open failed, "
+                      "errno = %d\n", errno);
+               return err;
+       }
+
+       printk(UM_KERN_INFO "vde backend - connection opened\n");
+
+       pri->conn = conn;
+
+       return 0;
+}
+
+static int vde_user_open(void *data)
+{
+       struct vde_data *pri = data;
+
+       if (pri->conn != NULL)
+               return vde_datafd(pri->conn);
+
+       printk(UM_KERN_WARNING "vde_open - we have no VDECONN to open");
+       return -EINVAL;
+}
+
+static void vde_remove(void *data)
+{
+       struct vde_data *pri = data;
+
+       if (pri->conn != NULL) {
+               printk(UM_KERN_INFO "vde backend - closing connection\n");
+               vde_close(pri->conn);
+               pri->conn = NULL;
+               kfree(pri->args);
+               pri->args = NULL;
+               return;
+       }
+
+       printk(UM_KERN_WARNING "vde_remove - we have no VDECONN to remove");
+}
+
+const struct net_user_info vde_user_info = {
+       .init           = vde_user_init,
+       .open           = vde_user_open,
+       .close          = NULL,
+       .remove         = vde_remove,
+       .add_address    = NULL,
+       .delete_address = NULL,
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_OTHER,
+};
+
+void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init)
+{
+       struct vde_open_args *args;
+
+       vpri->args = kmalloc(sizeof(struct vde_open_args), UM_GFP_KERNEL);
+       if (vpri->args == NULL) {
+               printk(UM_KERN_ERR "vde_init_libstuff - vde_open_args"
+                      "allocation failed");
+               return;
+       }
+
+       args = vpri->args;
+
+       args->port = init->port;
+       args->group = init->group;
+       args->mode = init->mode ? init->mode : 0700;
+
+       args->port ?  printk(UM_KERN_INFO "port %d", args->port) :
+               printk(UM_KERN_INFO "undefined port");
+}
+
+int vde_user_read(void *conn, void *buf, int len)
+{
+       VDECONN *vconn = conn;
+       int rv;
+
+       if (vconn == NULL)
+               return 0;
+
+       rv = vde_recv(vconn, buf, len, 0);
+       if (rv < 0) {
+               if (errno == EAGAIN)
+                       return 0;
+               return -errno;
+       }
+       else if (rv == 0)
+               return -ENOTCONN;
+
+       return rv;
+}
+
+int vde_user_write(void *conn, void *buf, int len)
+{
+       VDECONN *vconn = conn;
+
+       if (vconn == NULL)
+               return 0;
+
+       return vde_send(vconn, buf, len, 0);
+}
+
index fd817e5..8a1c18a 100644 (file)
@@ -1,20 +1,21 @@
-/* 
+/*
  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdlib.h>
+#include <stddef.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <string.h>
 #include <errno.h>
+#include <string.h>
 #include <termios.h>
 #include "chan_user.h"
+#include "kern_constants.h"
 #include "os.h"
-#include "init.h"
+#include "um_malloc.h"
 #include "user.h"
 #include "xterm.h"
-#include "kern_constants.h"
 
 struct xterm_chan {
        int pid;
@@ -29,7 +30,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts)
 {
        struct xterm_chan *data;
 
-       data = malloc(sizeof(*data));
+       data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
        if (data == NULL)
                return NULL;
        *data = ((struct xterm_chan) { .pid             = -1,
@@ -95,8 +96,10 @@ static int xterm_open(int input, int output, int primary, void *d,
        if (access(argv[4], X_OK) < 0)
                argv[4] = "port-helper";
 
-       /* Check that DISPLAY is set, this doesn't guarantee the xterm
-        * will work but w/o it we can be pretty sure it won't. */
+       /*
+        * Check that DISPLAY is set, this doesn't guarantee the xterm
+        * will work but w/o it we can be pretty sure it won't.
+        */
        if (getenv("DISPLAY") == NULL) {
                printk(UM_KERN_ERR "xterm_open: $DISPLAY not set.\n");
                return -ENODEV;
@@ -195,7 +198,7 @@ static int xterm_open(int input, int output, int primary, void *d,
 static void xterm_close(int fd, void *d)
 {
        struct xterm_chan *data = d;
-       
+
        if (data->pid != -1)
                os_kill_process(data->pid, 1);
        data->pid = -1;
@@ -207,11 +210,6 @@ static void xterm_close(int fd, void *d)
        os_close_file(fd);
 }
 
-static void xterm_free(void *d)
-{
-       free(d);
-}
-
 const struct chan_ops xterm_ops = {
        .type           = "xterm",
        .init           = xterm_init,
@@ -221,6 +219,6 @@ const struct chan_ops xterm_ops = {
        .write          = generic_write,
        .console_write  = generic_console_write,
        .window_size    = generic_window_size,
-       .free           = xterm_free,
+       .free           = generic_free,
        .winch          = 1,
 };
index 10ad52d..49c601f 100644 (file)
@@ -9,7 +9,7 @@
 #include "sysdep/ptrace.h"
 
 extern void arch_check_bugs(void);
-extern int arch_fixup(unsigned long address, union uml_pt_regs *regs);
-extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
+extern int arch_fixup(unsigned long address, struct uml_pt_regs *regs);
+extern int arch_handle_signal(int sig, struct uml_pt_regs *regs);
 
 #endif
index fccf187..a5cdf95 100644 (file)
@@ -6,6 +6,28 @@
 #ifndef __START_H__
 #define __START_H__
 
+#include "uml-config.h"
+#include "kern_constants.h"
+
+/*
+ * Assembly doesn't want any casting, but C does, so define these
+ * without casts here, and define new symbols with casts inside the C
+ * section.
+ */
+#define ASM_STUB_CODE (UML_CONFIG_TOP_ADDR - 2 * UM_KERN_PAGE_SIZE)
+#define ASM_STUB_DATA (UML_CONFIG_TOP_ADDR - UM_KERN_PAGE_SIZE)
+#define ASM_STUB_START ASM_STUB_CODE
+
+/*
+ * This file is included by the assembly stubs, which just want the
+ * definitions above.
+ */
+#ifndef __ASSEMBLY__
+
+#define STUB_CODE ((unsigned long) ASM_STUB_CODE)
+#define STUB_DATA ((unsigned long) ASM_STUB_DATA)
+#define STUB_START ((unsigned long) ASM_STUB_START)
+
 #include "sysdep/ptrace.h"
 
 struct cpu_task {
@@ -28,8 +50,9 @@ extern unsigned long _unprotected_end;
 extern unsigned long brk_start;
 
 extern int linux_main(int argc, char **argv);
-extern void set_cmdline(char *cmd);
 
-extern void (*sig_info[])(int, union uml_pt_regs *);
+extern void (*sig_info[])(int, struct uml_pt_regs *);
+
+#endif
 
 #endif
diff --git a/arch/um/include/choose-mode.h b/arch/um/include/choose-mode.h
deleted file mode 100644 (file)
index b87b36a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __CHOOSE_MODE_H__
-#define __CHOOSE_MODE_H__
-
-#include "uml-config.h"
-
-#if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS)
-#define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas))
-
-extern int mode_tt;
-static inline void *__choose_mode(void *tt, void *skas) {
-       return mode_tt ? tt : skas;
-}
-
-#define __CHOOSE_MODE(tt, skas) (*( (typeof(tt) *) __choose_mode(&(tt), &(skas))))
-
-#elif defined(UML_CONFIG_MODE_SKAS)
-#define CHOOSE_MODE(tt, skas) (skas)
-
-#elif defined(UML_CONFIG_MODE_TT)
-#define CHOOSE_MODE(tt, skas) (tt)
-
-#else
-#error CONFIG_MODE_SKAS and CONFIG_MODE_TT are both disabled
-#endif
-
-#define CHOOSE_MODE_PROC(tt, skas, args...) \
-       CHOOSE_MODE(tt(args), skas(args))
-
-#ifndef __CHOOSE_MODE
-#define __CHOOSE_MODE(tt, skas) CHOOSE_MODE(tt, skas)
-#endif
-
-#endif
index 6eee343..0edab69 100644 (file)
@@ -1,15 +1,13 @@
 /* for use by sys-$SUBARCH/kernel-offsets.c */
 
 DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
-#ifdef CONFIG_MODE_TT
-OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
-#endif
 
 OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
 OFFSET(HOST_TASK_PID, task_struct, pid);
 
 DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
 DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK);
+DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT);
 DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
 
 DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
@@ -34,3 +32,9 @@ DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC);
 DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
 
 DEFINE(UM_THREAD_SIZE, THREAD_SIZE);
+
+DEFINE(UM_HZ, HZ);
+
+DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC);
+DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
+DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);
index 15d311b..884a9c1 100644 (file)
@@ -1,12 +1,12 @@
 /*
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __IRQ_USER_H__
 #define __IRQ_USER_H__
 
-#include "uml-config.h"
+#include "sysdep/ptrace.h"
 
 struct irq_fd {
        struct irq_fd *next;
@@ -21,7 +21,7 @@ struct irq_fd {
 
 enum { IRQ_READ, IRQ_WRITE };
 
-extern void sigio_handler(int sig, union uml_pt_regs *regs);
+extern void sigio_handler(int sig, struct uml_pt_regs *regs);
 extern int activate_fd(int irq, int fd, int type, void *dev_id);
 extern void free_irq_by_irq_and_dev(unsigned int irq, void *dev_id);
 extern void free_irq_by_fd(int fd);
@@ -30,8 +30,4 @@ extern void deactivate_fd(int fd, int irqnum);
 extern int deactivate_all_fds(void);
 extern int activate_ipi(int fd, int pid);
 
-#ifdef CONFIG_MODE_TT
-extern void forward_interrupts(int pid);
-#endif
-
 #endif
index 6c2be26..74ce8e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -8,9 +8,8 @@
 
 #include "sysdep/ptrace.h"
 #include "sysdep/faultinfo.h"
-#include "uml-config.h"
 
-typedef void (*kern_hndl)(int, union uml_pt_regs *);
+typedef void (*kern_hndl)(int, struct uml_pt_regs *);
 
 struct kern_handlers {
        kern_hndl relay_signal;
@@ -34,9 +33,6 @@ extern int nsyscalls;
        UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1)
 
 extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg);
-#ifdef UML_CONFIG_MODE_TT
-extern unsigned long stack_sp(unsigned long page);
-#endif
 extern int kernel_thread_proc(void *data);
 extern void syscall_segv(int sig);
 extern int current_pid(void);
@@ -44,7 +40,7 @@ extern unsigned long alloc_stack(int order, int atomic);
 extern int do_signal(void);
 extern int is_stack_fault(unsigned long sp);
 extern unsigned long segv(struct faultinfo fi, unsigned long ip,
-                         int is_user, union uml_pt_regs *regs);
+                         int is_user, struct uml_pt_regs *regs);
 extern int handle_page_fault(unsigned long address, unsigned long ip,
                             int is_write, int is_user, int *code_out);
 extern void syscall_ready(void);
@@ -57,7 +53,7 @@ extern int need_finish_fork(void);
 extern void free_stack(unsigned long stack, int order);
 extern void add_input_request(int op, void (*proc)(int), void *arg);
 extern char *current_cmd(void);
-extern void timer_handler(int sig, union uml_pt_regs *regs);
+extern void timer_handler(int sig, struct uml_pt_regs *regs);
 extern int set_signals(int enable);
 extern int pid_to_processor_id(int pid);
 extern void deliver_signals(void *t);
@@ -67,9 +63,8 @@ extern void finish_fork(void);
 extern void paging_init(void);
 extern void init_flush_vm(void);
 extern void *syscall_sp(void *t);
-extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
-extern int hz(void);
-extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
+extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
+extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
 extern void interrupt_end(void);
 extern void initial_thread_cb(void (*proc)(void *), void *arg);
 extern int debugger_signal(int status, int pid);
@@ -79,10 +74,9 @@ extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
 extern int init_parent_proxy(int pid);
 extern int singlestepping(void *t);
 extern void check_stack_overflow(void *ptr);
-extern void relay_signal(int sig, union uml_pt_regs *regs);
+extern void relay_signal(int sig, struct uml_pt_regs *regs);
 extern int user_context(unsigned long sp);
-extern void timer_irq(union uml_pt_regs *regs);
-extern void unprotect_stack(unsigned long stack);
+extern void timer_irq(struct uml_pt_regs *regs);
 extern void do_uml_exitcalls(void);
 extern int attach_debugger(int idle_pid, int pid, int stop);
 extern int config_gdb(char *str);
@@ -113,11 +107,9 @@ extern void time_init_kern(void);
 
 /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
 extern int __cant_sleep(void);
-extern void sigio_handler(int sig, union uml_pt_regs *regs);
-
-extern void copy_sc(union uml_pt_regs *regs, void *from);
-
+extern void sigio_handler(int sig, struct uml_pt_regs *regs);
+extern void copy_sc(struct uml_pt_regs *regs, void *from);
 extern unsigned long to_irq_stack(unsigned long *mask_out);
 unsigned long from_irq_stack(int nested);
-
+extern int start_uml(void);
 #endif
index b282839..c139ae1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -63,7 +63,7 @@ struct mc_request
 
        struct mconsole_request request;
        struct mconsole_command *cmd;
-       union uml_pt_regs regs;
+       struct uml_pt_regs regs;
 };
 
 extern char mconsole_socket_name[];
@@ -96,14 +96,3 @@ extern void lock_notify(void);
 extern void unlock_notify(void);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index e8ff0d8..5cd40e9 100644 (file)
@@ -1,18 +1,12 @@
 /* 
- * Copyright (C) 2002, 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __MEM_H__
 #define __MEM_H__
 
-#include "linux/types.h"
-
-extern int phys_mapping(unsigned long phys, __u64 *offset_out);
-extern int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w);
-extern int is_remapped(void *virt);
-extern int physmem_remove_mapping(void *virt);
-extern void physmem_forget_descriptor(int fd);
+extern int phys_mapping(unsigned long phys, unsigned long long *offset_out);
 
 extern unsigned long uml_physmem;
 static inline unsigned long to_phys(void *virt)
@@ -26,14 +20,3 @@ static inline void *to_virt(unsigned long phys)
 }
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/mode.h b/arch/um/include/mode.h
deleted file mode 100644 (file)
index 786cf56..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_H__
-#define __MODE_H__
-
-#include "uml-config.h"
-
-#ifdef UML_CONFIG_MODE_TT
-#include "mode-tt.h"
-#endif
-
-#ifdef UML_CONFIG_MODE_SKAS
-#include "mode-skas.h"
-#endif
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/mode_kern.h b/arch/um/include/mode_kern.h
deleted file mode 100644 (file)
index 88e5e77..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_KERN_H__
-#define __MODE_KERN_H__
-
-#ifdef CONFIG_MODE_TT
-#include "mode_kern_tt.h"
-#endif
-
-#ifdef CONFIG_MODE_SKAS
-#include "mode_kern_skas.h"
-#endif
-
-#endif
index 9237056..d843c79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -30,24 +30,24 @@ struct uml_net_private {
        struct work_struct work;
        int fd;
        unsigned char mac[ETH_ALEN];
+       int max_packet;
        unsigned short (*protocol)(struct sk_buff *);
        int (*open)(void *);
        void (*close)(int, void *);
        void (*remove)(void *);
-       int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
-       int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
+       int (*read)(int, struct sk_buff *skb, struct uml_net_private *);
+       int (*write)(int, struct sk_buff *skb, struct uml_net_private *);
 
        void (*add_address)(unsigned char *, unsigned char *, void *);
        void (*delete_address)(unsigned char *, unsigned char *, void *);
-       int (*set_mtu)(int mtu, void *);
        char user[0];
 };
 
 struct net_kern_info {
        void (*init)(struct net_device *, void *);
        unsigned short (*protocol)(struct sk_buff *);
-       int (*read)(int, struct sk_buff **skb, struct uml_net_private *);
-       int (*write)(int, struct sk_buff **skb, struct uml_net_private *);
+       int (*read)(int, struct sk_buff *skb, struct uml_net_private *);
+       int (*write)(int, struct sk_buff *skb, struct uml_net_private *);
 };
 
 struct transport {
@@ -62,7 +62,6 @@ struct transport {
 
 extern struct net_device *ether_init(int);
 extern unsigned short ether_protocol(struct sk_buff *);
-extern struct sk_buff *ether_adjust_skb(struct sk_buff *skb, int extra);
 extern int tap_setup_common(char *str, char *type, char **dev_name,
                            char **mac_out, char **gate_addr);
 extern void register_transport(struct transport *new);
index cfe7c50..63bee15 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -18,10 +18,10 @@ struct net_user_info {
        int (*open)(void *);
        void (*close)(int, void *);
        void (*remove)(void *);
-       int (*set_mtu)(int mtu, void *);
        void (*add_address)(unsigned char *, unsigned char *, void *);
        void (*delete_address)(unsigned char *, unsigned char *, void *);
        int max_packet;
+       int mtu;
 };
 
 extern void ether_user_init(void *data, void *dev);
index 930b261..fbf0a87 100644 (file)
@@ -1,20 +1,18 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __OS_H__
 #define __OS_H__
 
-#include "uml-config.h"
-#include "asm/types.h"
-#include "../os/include/file.h"
-#include "sysdep/ptrace.h"
-#include "kern_util.h"
-#include "skas/mm_id.h"
+#include <stdarg.h>
 #include "irq_user.h"
+#include "kern_util.h"
+#include "longjmp.h"
+#include "mm_id.h"
 #include "sysdep/tls.h"
-#include "sysdep/archsetjmp.h"
+#include "../os/include/file.h"
 
 #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
 
@@ -130,18 +128,15 @@ static inline struct openflags of_cloexec(struct openflags flags)
 extern int os_stat_file(const char *file_name, struct uml_stat *buf);
 extern int os_stat_fd(const int fd, struct uml_stat *buf);
 extern int os_access(const char *file, int mode);
-extern void os_print_error(int error, const char* str);
 extern int os_get_exec_close(int fd, int *close_on_exec);
-extern int os_set_exec_close(int fd, int close_on_exec);
+extern int os_set_exec_close(int fd);
 extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
-extern int os_window_size(int fd, int *rows, int *cols);
-extern int os_new_tty_pgrp(int fd, int pid);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
 extern int os_set_owner(int fd, int pid);
 extern int os_mode_fd(int fd, int mode);
 
-extern int os_seek_file(int fd, __u64 offset);
+extern int os_seek_file(int fd, unsigned long long offset);
 extern int os_open_file(char *file, struct openflags flags, int mode);
 extern int os_read_file(int fd, void *buf, int len);
 extern int os_write_file(int fd, const void *buf, int count);
@@ -179,11 +174,7 @@ extern void check_host_supports_tls(int *supports_tls, int *tls_min);
 
 /* Make sure they are clear when running in TT mode. Required by
  * SEGV_MAYBE_FIXABLE */
-#ifdef UML_CONFIG_MODE_SKAS
 #define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0)
-#else
-#define clear_can_do_skas() do {} while (0)
-#endif
 
 /* mem.c */
 extern int create_mem_file(unsigned long long len);
@@ -194,20 +185,13 @@ extern int os_process_parent(int pid);
 extern void os_stop_process(int pid);
 extern void os_kill_process(int pid, int reap_child);
 extern void os_kill_ptraced_process(int pid, int reap_child);
-#ifdef UML_CONFIG_MODE_TT
-extern void os_usr1_process(int pid);
-#endif
 extern long os_ptrace_ldt(long pid, long addr, long data);
 
 extern int os_getpid(void);
 extern int os_getpgrp(void);
 
-#ifdef UML_CONFIG_MODE_TT
-extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
-extern void stop(void);
-#endif
 extern void init_new_thread_signals(void);
-extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
+extern int run_kernel_thread(int (*fn)(void *), void *arg, jmp_buf **jmp_ptr);
 
 extern int os_map_memory(void *virt, int fd, unsigned long long off,
                         unsigned long len, int r, int w, int x);
@@ -218,21 +202,9 @@ extern int os_drop_memory(void *addr, int length);
 extern int can_drop_memory(void);
 extern void os_flush_stdout(void);
 
-/* tt.c
- * for tt mode only (will be deleted in future...)
- */
-extern void forward_ipi(int fd, int pid);
-extern void kill_child_dead(int pid);
-extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
-extern int protect_memory(unsigned long addr, unsigned long len,
-                         int r, int w, int x, int must_succeed);
-extern void forward_pending_sigio(int target);
-extern int start_fork_tramp(void *arg, unsigned long temp_stack,
-                           int clone_flags, int (*tramp)(void *));
-
 /* uaccess.c */
 extern unsigned long __do_user_copy(void *to, const void *from, int n,
-                                   void **fault_addr, void **fault_catcher,
+                                   void **fault_addr, jmp_buf **fault_catcher,
                                    void (*op)(void *to, const void *from,
                                               int n), int *faulted_out);
 
@@ -255,6 +227,7 @@ extern int set_umid(char *name);
 extern char *get_umid(void);
 
 /* signal.c */
+extern void timer_init(void);
 extern void set_sigstack(void *sig_stack, int size);
 extern void remove_sigstack(void);
 extern void set_handler(int sig, void (*handler)(int), int flags, ...);
@@ -266,7 +239,6 @@ extern int set_signals(int enable);
 
 /* trap.c */
 extern void os_fill_handlinfo(struct kern_handlers h);
-extern void do_longjmp(void *p, int val);
 
 /* util.c */
 extern void stack_protections(unsigned long address);
@@ -277,17 +249,12 @@ extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
 extern void os_dump_core(void);
 
 /* time.c */
-#define BILLION (1000 * 1000 * 1000)
-
-extern void switch_timers(int to_real);
-extern void idle_sleep(int secs);
-extern int set_interval(int is_virtual);
-#ifdef CONFIG_MODE_TT
-extern void enable_timer(void);
-#endif
-extern void disable_timer(void);
+extern void idle_sleep(unsigned long long nsecs);
+extern int set_interval(void);
+extern int timer_one_shot(int ticks);
+extern long long disable_timer(void);
 extern void uml_idle_timer(void);
-extern unsigned long long os_nsecs(void);
+extern long long os_nsecs(void);
 
 /* skas/mem.c */
 extern long run_syscall_stub(struct mm_id * mm_idp,
@@ -308,7 +275,9 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
 extern int is_skas_winch(int pid, int fd, void *data);
 extern int start_userspace(unsigned long stub_stack);
 extern int copy_context_skas0(unsigned long stack, int pid);
-extern void userspace(union uml_pt_regs *regs);
+extern void save_registers(int pid, struct uml_pt_regs *regs);
+extern void restore_registers(int pid, struct uml_pt_regs *regs);
+extern void userspace(struct uml_pt_regs *regs);
 extern void map_stub_pages(int fd, unsigned long code,
                           unsigned long data, unsigned long stack);
 extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
index f845b36..0e27406 100644 (file)
@@ -9,13 +9,15 @@
 #include "sysdep/ptrace.h"
 #include "sysdep/archsetjmp.h"
 
-extern void init_thread_registers(union uml_pt_regs *to);
+extern void init_thread_registers(struct uml_pt_regs *to);
 extern int save_fp_registers(int pid, unsigned long *fp_regs);
 extern int restore_fp_registers(int pid, unsigned long *fp_regs);
-extern void save_registers(int pid, union uml_pt_regs *regs);
-extern void restore_registers(int pid, union uml_pt_regs *regs);
+extern int save_fpx_registers(int pid, unsigned long *fp_regs);
+extern int restore_fpx_registers(int pid, unsigned long *fp_regs);
+extern void save_registers(int pid, struct uml_pt_regs *regs);
+extern void restore_registers(int pid, struct uml_pt_regs *regs);
 extern void init_registers(int pid);
-extern void get_safe_registers(unsigned long * regs, unsigned long * fp_regs);
+extern void get_safe_registers(unsigned long *regs);
 extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
 
 #endif
diff --git a/arch/um/include/skas/mmu-skas.h b/arch/um/include/skas/mmu-skas.h
deleted file mode 100644 (file)
index b26986c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_MMU_H
-#define __SKAS_MMU_H
-
-#include "mm_id.h"
-#include "asm/ldt.h"
-
-struct mmu_context_skas {
-       struct mm_id id;
-       unsigned long last_page_table;
-#ifdef CONFIG_3_LEVEL_PGTABLES
-       unsigned long last_pmd;
-#endif
-       uml_ldt_t ldt;
-};
-
-extern void switch_mm_skas(struct mm_id * mm_idp);
-
-#endif
index 8bc6916..e065feb 100644 (file)
@@ -1,18 +1,11 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
 
 #ifndef __MODE_SKAS_H__
 #define __MODE_SKAS_H__
 
-#include <sysdep/ptrace.h>
-
-extern unsigned long exec_regs[];
-extern unsigned long exec_fp_regs[];
-extern unsigned long exec_fpx_regs[];
-extern int have_fpx_regs;
-
 extern void kill_off_processes_skas(void);
 
 #endif
diff --git a/arch/um/include/skas/mode_kern_skas.h b/arch/um/include/skas/mode_kern_skas.h
deleted file mode 100644 (file)
index 8ee6285..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_MODE_KERN_H__
-#define __SKAS_MODE_KERN_H__
-
-#include "linux/sched.h"
-#include "asm/page.h"
-#include "asm/ptrace.h"
-
-extern void flush_thread_skas(void);
-extern void switch_to_skas(void *prev, void *next);
-extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
-                             unsigned long esp);
-extern int copy_thread_skas(int nr, unsigned long clone_flags,
-                           unsigned long sp, unsigned long stack_top,
-                           struct task_struct *p, struct pt_regs *regs);
-extern void release_thread_skas(struct task_struct *task);
-extern void init_idle_skas(void);
-extern void flush_tlb_kernel_range_skas(unsigned long start,
-                                       unsigned long end);
-extern void flush_tlb_kernel_vm_skas(void);
-extern void __flush_tlb_one_skas(unsigned long addr);
-extern void flush_tlb_range_skas(struct vm_area_struct *vma,
-                                unsigned long start, unsigned long end);
-extern void flush_tlb_mm_skas(struct mm_struct *mm);
-extern void force_flush_all_skas(void);
-extern long execute_syscall_skas(void *r);
-extern void before_mem_skas(unsigned long unused);
-extern unsigned long set_task_sizes_skas(unsigned long *task_size_out);
-extern int start_uml_skas(void);
-extern int external_pid_skas(struct task_struct *task);
-extern int thread_pid_skas(struct task_struct *task);
-extern void flush_tlb_page_skas(struct vm_area_struct *vma,
-                               unsigned long address);
-
-#define kmem_end_skas (host_task_size - 1024 * 1024)
-
-#endif
index e88926b..b073f8a 100644 (file)
@@ -1,12 +1,11 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __SKAS_H
 #define __SKAS_H
 
-#include "mm_id.h"
 #include "sysdep/ptrace.h"
 
 extern int userspace_pid[];
@@ -15,7 +14,7 @@ extern int skas_needs_stub;
 
 extern int user_thread(unsigned long stack, int flags);
 extern void new_thread_handler(void);
-extern void handle_syscall(union uml_pt_regs *regs);
+extern void handle_syscall(struct uml_pt_regs *regs);
 extern int new_mm(unsigned long stack);
 extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
 extern long execute_syscall_skas(void *r);
diff --git a/arch/um/include/skas/uaccess-skas.h b/arch/um/include/skas/uaccess-skas.h
deleted file mode 100644 (file)
index 224a75f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __SKAS_UACCESS_H
-#define __SKAS_UACCESS_H
-
-#include "asm/errno.h"
-
-/* No SKAS-specific checking. */
-#define access_ok_skas(type, addr, size) 0
-
-extern int copy_from_user_skas(void *to, const void __user *from, int n);
-extern int copy_to_user_skas(void __user *to, const void *from, int n);
-extern int strncpy_from_user_skas(char *dst, const char __user *src, int count);
-extern int __clear_user_skas(void __user *mem, int len);
-extern int clear_user_skas(void __user *mem, int len);
-extern int strnlen_user_skas(const void __user *str, int len);
-
-#endif
index 97ec9d8..5868526 100644 (file)
@@ -17,6 +17,5 @@
 
 void foo(void)
 {
-       OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
 #include <common-offsets.h>
 }
index 52b398b..11c0896 100644 (file)
@@ -1,5 +1,5 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,17 +9,11 @@
 #include "uml-config.h"
 #include "user_constants.h"
 #include "sysdep/faultinfo.h"
-#include "choose-mode.h"
 
 #define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
 #define MAX_REG_OFFSET (UM_FRAME_SIZE)
 
-#ifdef UML_CONFIG_PT_PROXY
-extern void update_debugregs(int seq);
-#else
 static inline void update_debugregs(int seq) {}
-#endif
-
 
 /* syscall emulation path in ptrace */
 
@@ -31,12 +25,6 @@ void set_using_sysemu(int value);
 int get_using_sysemu(void);
 extern int sysemu_supported;
 
-#ifdef UML_CONFIG_MODE_TT
-#include "sysdep/sc.h"
-#endif
-
-#ifdef UML_CONFIG_MODE_SKAS
-
 #include "skas_ptregs.h"
 
 #define REGS_IP(r) ((r)[HOST_IP])
@@ -60,70 +48,36 @@ extern int sysemu_supported;
 
 #define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
 
-#endif
 #ifndef PTRACE_SYSEMU_SINGLESTEP
 #define PTRACE_SYSEMU_SINGLESTEP 32
 #endif
 
-union uml_pt_regs {
-#ifdef UML_CONFIG_MODE_TT
-       struct tt_regs {
-               long syscall;
-               void *sc;
-                struct faultinfo faultinfo;
-       } tt;
-#endif
-#ifdef UML_CONFIG_MODE_SKAS
-       struct skas_regs {
-               unsigned long regs[MAX_REG_NR];
-               unsigned long fp[HOST_FP_SIZE];
-               unsigned long xfp[HOST_XFP_SIZE];
-                struct faultinfo faultinfo;
-               long syscall;
-               int is_user;
-       } skas;
-#endif
+struct uml_pt_regs {
+       unsigned long gp[MAX_REG_NR];
+       struct faultinfo faultinfo;
+       long syscall;
+       int is_user;
 };
 
 #define EMPTY_UML_PT_REGS { }
 
-extern int mode_tt;
-
-#define UPT_SC(r) ((r)->tt.sc)
-#define UPT_IP(r) \
-       __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
-#define UPT_SP(r) \
-       __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
-#define UPT_EFLAGS(r) \
-       __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
-#define UPT_EAX(r) \
-       __CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs))
-#define UPT_EBX(r) \
-       __CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs))
-#define UPT_ECX(r) \
-       __CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs))
-#define UPT_EDX(r) \
-       __CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs))
-#define UPT_ESI(r) \
-       __CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs))
-#define UPT_EDI(r) \
-       __CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs))
-#define UPT_EBP(r) \
-       __CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs))
-#define UPT_ORIG_EAX(r) \
-       __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
-#define UPT_CS(r) \
-       __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
-#define UPT_SS(r) \
-       __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
-#define UPT_DS(r) \
-       __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
-#define UPT_ES(r) \
-       __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
-#define UPT_FS(r) \
-       __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
-#define UPT_GS(r) \
-       __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
+#define UPT_IP(r) REGS_IP((r)->gp)
+#define UPT_SP(r) REGS_SP((r)->gp)
+#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
+#define UPT_EAX(r) REGS_EAX((r)->gp)
+#define UPT_EBX(r) REGS_EBX((r)->gp)
+#define UPT_ECX(r) REGS_ECX((r)->gp)
+#define UPT_EDX(r) REGS_EDX((r)->gp)
+#define UPT_ESI(r) REGS_ESI((r)->gp)
+#define UPT_EDI(r) REGS_EDI((r)->gp)
+#define UPT_EBP(r) REGS_EBP((r)->gp)
+#define UPT_ORIG_EAX(r) ((r)->syscall)
+#define UPT_CS(r) REGS_CS((r)->gp)
+#define UPT_SS(r) REGS_SS((r)->gp)
+#define UPT_DS(r) REGS_DS((r)->gp)
+#define UPT_ES(r) REGS_ES((r)->gp)
+#define UPT_FS(r) REGS_FS((r)->gp)
+#define UPT_GS(r) REGS_GS((r)->gp)
 
 #define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
 #define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
@@ -134,20 +88,19 @@ extern int mode_tt;
 
 extern int user_context(unsigned long sp);
 
-#define UPT_IS_USER(r) \
-       CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
+#define UPT_IS_USER(r) ((r)->is_user)
 
 struct syscall_args {
        unsigned long args[6];
 };
 
 #define SYSCALL_ARGS(r) ((struct syscall_args) \
-                        { .args = { UPT_SYSCALL_ARG1(r), \
-                                    UPT_SYSCALL_ARG2(r), \
-                                   UPT_SYSCALL_ARG3(r), \
-                                    UPT_SYSCALL_ARG4(r), \
-                                   UPT_SYSCALL_ARG5(r), \
-                                    UPT_SYSCALL_ARG6(r) } } )
+                        { .args = { UPT_SYSCALL_ARG1(r),       \
+                                    UPT_SYSCALL_ARG2(r),       \
+                                    UPT_SYSCALL_ARG3(r),       \
+                                    UPT_SYSCALL_ARG4(r),       \
+                                    UPT_SYSCALL_ARG5(r),       \
+                                    UPT_SYSCALL_ARG6(r) } } )
 
 #define UPT_REG(regs, reg) \
        ({      unsigned long val; \
@@ -175,7 +128,6 @@ struct syscall_args {
                } \
                val; \
        })
-       
 
 #define UPT_SET(regs, reg, val) \
        do { \
@@ -204,29 +156,16 @@ struct syscall_args {
        } while (0)
 
 #define UPT_SET_SYSCALL_RETURN(r, res) \
-       CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
-                    REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
+       REGS_SET_SYSCALL_RETURN((r)->regs, (res))
 
-#define UPT_RESTART_SYSCALL(r) \
-       CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
-                   REGS_RESTART_SYSCALL((r)->skas.regs))
+#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
 
 #define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
 #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
 #define UPT_SYSCALL_RET(r) UPT_EAX(r)
 
-#define UPT_FAULTINFO(r) \
-        CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
+#define UPT_FAULTINFO(r) (&(r)->faultinfo)
 
-#endif
+extern void arch_init_registers(int pid);
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#endif
index 23fd264..67e7712 100644 (file)
@@ -1,19 +1,15 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __SYS_SIGCONTEXT_I386_H
 #define __SYS_SIGCONTEXT_I386_H
 
-#include "uml-config.h"
-#include <sysdep/sc.h>
+#include "sysdep/sc.h"
 
 #define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
 
-#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
-#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
-
 #define GET_FAULTINFO_FROM_SC(fi,sc) \
        { \
                (fi).cr2 = SC_CR2(sc); \
                (fi).trap_no = SC_TRAPNO(sc); \
        }
 
-/* ptrace expects that, at the start of a system call, %eax contains
- * -ENOSYS, so this makes it so.
- */
-#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
-
 /* This is Page Fault */
 #define SEGV_IS_FIXABLE(fi)    ((fi)->trap_no == 14)
 
 /* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
-#ifdef UML_CONFIG_MODE_SKAS
 #define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo)
-#else
-#define SEGV_MAYBE_FIXABLE(fi) 0
-#endif
-
-extern unsigned long *sc_sigmask(void *sc_ptr);
-extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
 
 #endif
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 4fffae7..8c097b8 100644 (file)
@@ -9,7 +9,7 @@
 #include <sys/mman.h>
 #include <asm/ptrace.h>
 #include <asm/unistd.h>
-#include <asm/page.h>
+#include "as-layout.h"
 #include "stub-data.h"
 #include "kern_constants.h"
 #include "uml-config.h"
@@ -19,7 +19,7 @@ extern void stub_clone_handler(void);
 
 #define STUB_SYSCALL_RET EAX
 #define STUB_MMAP_NR __NR_mmap2
-#define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
+#define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT)
 
 static inline long stub_syscall0(long syscall)
 {
@@ -90,12 +90,12 @@ static inline void remap_stack(int fd, unsigned long offset)
 {
        __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
                          "movl %7, %%ebx ; movl %%eax, (%%ebx)"
-                         : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA), 
-                           "c" (UM_KERN_PAGE_SIZE), 
+                         : : "g" (STUB_MMAP_NR), "b" (STUB_DATA),
+                           "c" (UM_KERN_PAGE_SIZE),
                            "d" (PROT_READ | PROT_WRITE),
-                           "S" (MAP_FIXED | MAP_SHARED), "D" (fd), 
-                           "a" (offset), 
-                           "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err) 
+                           "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
+                           "a" (offset),
+                           "i" (&((struct stub_data *) STUB_DATA)->err)
                          : "memory");
 }
 
diff --git a/arch/um/include/sysdep-i386/thread.h b/arch/um/include/sysdep-i386/thread.h
deleted file mode 100644 (file)
index 243fed4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __UM_THREAD_H
-#define __UM_THREAD_H
-
-#include <kern_constants.h>
-
-#define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS]))
-#ifdef UML_CONFIG_MODE_TT
-#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
-#endif
-
-#endif
index 62403bd..9ea44d1 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2003 PathScale, Inc.
+ * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  *
  * Licensed under the GPL
  */
 #define MAX_REG_OFFSET (UM_FRAME_SIZE)
 #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
 
-#ifdef UML_CONFIG_MODE_TT
-#include "sysdep/sc.h"
-#endif
-
-#ifdef UML_CONFIG_MODE_SKAS
 #include "skas_ptregs.h"
 
 #define REGS_IP(r) ((r)[HOST_IP])
 
 #define REGS_ERR(r) ((r)->fault_type)
 
-#endif
-
-#include "choose-mode.h"
-
-/* XXX */
-union uml_pt_regs {
-#ifdef UML_CONFIG_MODE_TT
-       struct tt_regs {
-               long syscall;
-               unsigned long orig_rax;
-               void *sc;
-                struct faultinfo faultinfo;
-       } tt;
-#endif
-#ifdef UML_CONFIG_MODE_SKAS
-       struct skas_regs {
-               unsigned long regs[MAX_REG_NR];
-               unsigned long fp[HOST_FP_SIZE];
-                struct faultinfo faultinfo;
-               long syscall;
-               int is_user;
-       } skas;
-#endif
+struct uml_pt_regs {
+       unsigned long gp[MAX_REG_NR];
+       struct faultinfo faultinfo;
+       long syscall;
+       int is_user;
 };
 
 #define EMPTY_UML_PT_REGS { }
 
-/* XXX */
-extern int mode_tt;
-
-#define UPT_RBX(r) __CHOOSE_MODE(SC_RBX(UPT_SC(r)), REGS_RBX((r)->skas.regs))
-#define UPT_RCX(r) __CHOOSE_MODE(SC_RCX(UPT_SC(r)), REGS_RCX((r)->skas.regs))
-#define UPT_RDX(r) __CHOOSE_MODE(SC_RDX(UPT_SC(r)), REGS_RDX((r)->skas.regs))
-#define UPT_RSI(r) __CHOOSE_MODE(SC_RSI(UPT_SC(r)), REGS_RSI((r)->skas.regs))
-#define UPT_RDI(r) __CHOOSE_MODE(SC_RDI(UPT_SC(r)), REGS_RDI((r)->skas.regs))
-#define UPT_RBP(r) __CHOOSE_MODE(SC_RBP(UPT_SC(r)), REGS_RBP((r)->skas.regs))
-#define UPT_RAX(r) __CHOOSE_MODE(SC_RAX(UPT_SC(r)), REGS_RAX((r)->skas.regs))
-#define UPT_R8(r) __CHOOSE_MODE(SC_R8(UPT_SC(r)), REGS_R8((r)->skas.regs))
-#define UPT_R9(r) __CHOOSE_MODE(SC_R9(UPT_SC(r)), REGS_R9((r)->skas.regs))
-#define UPT_R10(r) __CHOOSE_MODE(SC_R10(UPT_SC(r)), REGS_R10((r)->skas.regs))
-#define UPT_R11(r) __CHOOSE_MODE(SC_R11(UPT_SC(r)), REGS_R11((r)->skas.regs))
-#define UPT_R12(r) __CHOOSE_MODE(SC_R12(UPT_SC(r)), REGS_R12((r)->skas.regs))
-#define UPT_R13(r) __CHOOSE_MODE(SC_R13(UPT_SC(r)), REGS_R13((r)->skas.regs))
-#define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs))
-#define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs))
-#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
-#define UPT_FS_BASE(r) \
-       __CHOOSE_MODE(SC_FS_BASE(UPT_SC(r)), REGS_FS_BASE((r)->skas.regs))
-#define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
-#define UPT_GS_BASE(r) \
-       __CHOOSE_MODE(SC_GS_BASE(UPT_SC(r)), REGS_GS_BASE((r)->skas.regs))
-#define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
-#define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
-#define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
-#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
-#define UPT_SS(r) __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
-#define UPT_ORIG_RAX(r) \
-       __CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs))
-
-#define UPT_IP(r) __CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
-#define UPT_SP(r) __CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
-
-#define UPT_EFLAGS(r) \
-       __CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
-#define UPT_SC(r) ((r)->tt.sc)
-#define UPT_SYSCALL_NR(r) __CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
+#define UPT_RBX(r) REGS_RBX((r)->gp)
+#define UPT_RCX(r) REGS_RCX((r)->gp)
+#define UPT_RDX(r) REGS_RDX((r)->gp)
+#define UPT_RSI(r) REGS_RSI((r)->gp)
+#define UPT_RDI(r) REGS_RDI((r)->gp)
+#define UPT_RBP(r) REGS_RBP((r)->gp)
+#define UPT_RAX(r) REGS_RAX((r)->gp)
+#define UPT_R8(r) REGS_R8((r)->gp)
+#define UPT_R9(r) REGS_R9((r)->gp)
+#define UPT_R10(r) REGS_R10((r)->gp)
+#define UPT_R11(r) REGS_R11((r)->gp)
+#define UPT_R12(r) REGS_R12((r)->gp)
+#define UPT_R13(r) REGS_R13((r)->gp)
+#define UPT_R14(r) REGS_R14((r)->gp)
+#define UPT_R15(r) REGS_R15((r)->gp)
+#define UPT_CS(r) REGS_CS((r)->gp)
+#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
+#define UPT_FS(r) REGS_FS((r)->gp)
+#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
+#define UPT_GS(r) REGS_GS((r)->gp)
+#define UPT_DS(r) REGS_DS((r)->gp)
+#define UPT_ES(r) REGS_ES((r)->gp)
+#define UPT_CS(r) REGS_CS((r)->gp)
+#define UPT_SS(r) REGS_SS((r)->gp)
+#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
+
+#define UPT_IP(r) REGS_IP((r)->gp)
+#define UPT_SP(r) REGS_SP((r)->gp)
+
+#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
+#define UPT_SYSCALL_NR(r) ((r)->syscall)
 #define UPT_SYSCALL_RET(r) UPT_RAX(r)
 
 extern int user_context(unsigned long sp);
 
-#define UPT_IS_USER(r) \
-       CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
+#define UPT_IS_USER(r) ((r)->is_user)
 
 #define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
 #define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
@@ -173,101 +142,99 @@ struct syscall_args {
 };
 
 #define SYSCALL_ARGS(r) ((struct syscall_args) \
-                        { .args = { UPT_SYSCALL_ARG1(r), \
-                                    UPT_SYSCALL_ARG2(r), \
-                                   UPT_SYSCALL_ARG3(r), \
-                                    UPT_SYSCALL_ARG4(r), \
-                                   UPT_SYSCALL_ARG5(r), \
-                                    UPT_SYSCALL_ARG6(r) } } )
+                        { .args = { UPT_SYSCALL_ARG1(r),        \
+                                    UPT_SYSCALL_ARG2(r),        \
+                                    UPT_SYSCALL_ARG3(r),        \
+                                    UPT_SYSCALL_ARG4(r),        \
+                                    UPT_SYSCALL_ARG5(r),        \
+                                    UPT_SYSCALL_ARG6(r) } } )
 
 #define UPT_REG(regs, reg) \
-        ({      unsigned long val; \
-                switch(reg){ \
-               case R8: val = UPT_R8(regs); break; \
-               case R9: val = UPT_R9(regs); break; \
-               case R10: val = UPT_R10(regs); break; \
-               case R11: val = UPT_R11(regs); break; \
-               case R12: val = UPT_R12(regs); break; \
-               case R13: val = UPT_R13(regs); break; \
-               case R14: val = UPT_R14(regs); break; \
-               case R15: val = UPT_R15(regs); break; \
-                case RIP: val = UPT_IP(regs); break; \
-                case RSP: val = UPT_SP(regs); break; \
-                case RAX: val = UPT_RAX(regs); break; \
-                case RBX: val = UPT_RBX(regs); break; \
-                case RCX: val = UPT_RCX(regs); break; \
-                case RDX: val = UPT_RDX(regs); break; \
-                case RSI: val = UPT_RSI(regs); break; \
-                case RDI: val = UPT_RDI(regs); break; \
-                case RBP: val = UPT_RBP(regs); break; \
-                case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
-                case CS: val = UPT_CS(regs); break; \
-                case SS: val = UPT_SS(regs); break; \
-               case FS_BASE: val = UPT_FS_BASE(regs); break; \
-                case GS_BASE: val = UPT_GS_BASE(regs); break; \
-                case DS: val = UPT_DS(regs); break; \
-                case ES: val = UPT_ES(regs); break; \
-                case FS : val = UPT_FS (regs); break; \
-               case GS: val = UPT_GS(regs); break;         \
-                case EFLAGS: val = UPT_EFLAGS(regs); break; \
-                default :  \
-                        panic("Bad register in UPT_REG : %d\n", reg);  \
-                        val = -1; \
-                } \
-                val; \
-        })
+       ({      unsigned long val;              \
+               switch(reg){                                            \
+               case R8: val = UPT_R8(regs); break;                     \
+               case R9: val = UPT_R9(regs); break;                     \
+               case R10: val = UPT_R10(regs); break;                   \
+               case R11: val = UPT_R11(regs); break;                   \
+               case R12: val = UPT_R12(regs); break;                   \
+               case R13: val = UPT_R13(regs); break;                   \
+               case R14: val = UPT_R14(regs); break;                   \
+               case R15: val = UPT_R15(regs); break;                   \
+               case RIP: val = UPT_IP(regs); break;                    \
+               case RSP: val = UPT_SP(regs); break;                    \
+               case RAX: val = UPT_RAX(regs); break;                   \
+               case RBX: val = UPT_RBX(regs); break;                   \
+               case RCX: val = UPT_RCX(regs); break;                   \
+               case RDX: val = UPT_RDX(regs); break;                   \
+               case RSI: val = UPT_RSI(regs); break;                   \
+               case RDI: val = UPT_RDI(regs); break;                   \
+               case RBP: val = UPT_RBP(regs); break;                   \
+               case ORIG_RAX: val = UPT_ORIG_RAX(regs); break;         \
+               case CS: val = UPT_CS(regs); break;                     \
+               case SS: val = UPT_SS(regs); break;                     \
+               case FS_BASE: val = UPT_FS_BASE(regs); break;           \
+               case GS_BASE: val = UPT_GS_BASE(regs); break;           \
+               case DS: val = UPT_DS(regs); break;                     \
+               case ES: val = UPT_ES(regs); break;                     \
+               case FS : val = UPT_FS (regs); break;                   \
+               case GS: val = UPT_GS(regs); break;                     \
+               case EFLAGS: val = UPT_EFLAGS(regs); break;             \
+               default :                                               \
+                       panic("Bad register in UPT_REG : %d\n", reg);   \
+                       val = -1;                                       \
+               }                                                       \
+               val;                                                    \
+       })
 
 
 #define UPT_SET(regs, reg, val) \
-        ({      unsigned long __upt_val = val; \
-                switch(reg){ \
-                case R8: UPT_R8(regs) = __upt_val; break; \
-                case R9: UPT_R9(regs) = __upt_val; break; \
-                case R10: UPT_R10(regs) = __upt_val; break; \
-                case R11: UPT_R11(regs) = __upt_val; break; \
-                case R12: UPT_R12(regs) = __upt_val; break; \
-                case R13: UPT_R13(regs) = __upt_val; break; \
-                case R14: UPT_R14(regs) = __upt_val; break; \
-                case R15: UPT_R15(regs) = __upt_val; break; \
-                case RIP: UPT_IP(regs) = __upt_val; break; \
-                case RSP: UPT_SP(regs) = __upt_val; break; \
-                case RAX: UPT_RAX(regs) = __upt_val; break; \
-                case RBX: UPT_RBX(regs) = __upt_val; break; \
-                case RCX: UPT_RCX(regs) = __upt_val; break; \
-                case RDX: UPT_RDX(regs) = __upt_val; break; \
-                case RSI: UPT_RSI(regs) = __upt_val; break; \
-                case RDI: UPT_RDI(regs) = __upt_val; break; \
-                case RBP: UPT_RBP(regs) = __upt_val; break; \
-                case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
-                case CS: UPT_CS(regs) = __upt_val; break; \
-                case SS: UPT_SS(regs) = __upt_val; break; \
-                case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \
-                case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \
-                case DS: UPT_DS(regs) = __upt_val; break; \
-                case ES: UPT_ES(regs) = __upt_val; break; \
-                case FS: UPT_FS(regs) = __upt_val; break; \
-                case GS: UPT_GS(regs) = __upt_val; break; \
-                case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
-                default :  \
-                        panic("Bad register in UPT_SET : %d\n", reg);  \
-                       break; \
-                } \
-                __upt_val; \
-        })
+       ({      unsigned long __upt_val = val;  \
+               switch(reg){                                            \
+               case R8: UPT_R8(regs) = __upt_val; break;               \
+               case R9: UPT_R9(regs) = __upt_val; break;               \
+               case R10: UPT_R10(regs) = __upt_val; break;             \
+               case R11: UPT_R11(regs) = __upt_val; break;             \
+               case R12: UPT_R12(regs) = __upt_val; break;             \
+               case R13: UPT_R13(regs) = __upt_val; break;             \
+               case R14: UPT_R14(regs) = __upt_val; break;             \
+               case R15: UPT_R15(regs) = __upt_val; break;             \
+               case RIP: UPT_IP(regs) = __upt_val; break;              \
+               case RSP: UPT_SP(regs) = __upt_val; break;              \
+               case RAX: UPT_RAX(regs) = __upt_val; break;             \
+               case RBX: UPT_RBX(regs) = __upt_val; break;             \
+               case RCX: UPT_RCX(regs) = __upt_val; break;             \
+               case RDX: UPT_RDX(regs) = __upt_val; break;             \
+               case RSI: UPT_RSI(regs) = __upt_val; break;             \
+               case RDI: UPT_RDI(regs) = __upt_val; break;             \
+               case RBP: UPT_RBP(regs) = __upt_val; break;             \
+               case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break;   \
+               case CS: UPT_CS(regs) = __upt_val; break;               \
+               case SS: UPT_SS(regs) = __upt_val; break;               \
+               case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break;     \
+               case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break;     \
+               case DS: UPT_DS(regs) = __upt_val; break;               \
+               case ES: UPT_ES(regs) = __upt_val; break;               \
+               case FS: UPT_FS(regs) = __upt_val; break;               \
+               case GS: UPT_GS(regs) = __upt_val; break;               \
+               case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break;       \
+               default :                                               \
+                       panic("Bad register in UPT_SET : %d\n", reg);   \
+                       break;                                          \
+               }                                                       \
+               __upt_val;                                              \
+       })
 
 #define UPT_SET_SYSCALL_RETURN(r, res) \
-       CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
-                    REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
+       REGS_SET_SYSCALL_RETURN((r)->regs, (res))
+
+#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
 
-#define UPT_RESTART_SYSCALL(r) \
-       CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
-                   REGS_RESTART_SYSCALL((r)->skas.regs))
+#define UPT_SEGV_IS_FIXABLE(r) REGS_SEGV_IS_FIXABLE(&r->skas)
 
-#define UPT_SEGV_IS_FIXABLE(r) \
-       CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
-                    REGS_SEGV_IS_FIXABLE(&r->skas))
+#define UPT_FAULTINFO(r) (&(r)->faultinfo)
 
-#define UPT_FAULTINFO(r) \
-        CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
+static inline void arch_init_registers(int pid)
+{
+}
 
 #endif
index 4107323..0155133 100644 (file)
 
 #define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
 
-#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
-#define SC_SET_SYSCALL_RETURN(sc, result) SC_RAX(sc) = (result)
-
-#define SC_FAULT_ADDR(sc) SC_CR2(sc)
-#define SC_FAULT_TYPE(sc) SC_ERR(sc)
-
-#define GET_FAULTINFO_FROM_SC(fi,sc) \
+#define GET_FAULTINFO_FROM_SC(fi, sc) \
        { \
                (fi).cr2 = SC_CR2(sc); \
                (fi).error_code = SC_ERR(sc); \
                (fi).trap_no = SC_TRAPNO(sc); \
        }
 
-/* ptrace expects that, at the start of a system call, %eax contains
- * -ENOSYS, so this makes it so.
- */
-
-#define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
-
 /* This is Page Fault */
 #define SEGV_IS_FIXABLE(fi)    ((fi)->trap_no == 14)
 
 /* No broken SKAS API, which doesn't pass trap_no, here. */
 #define SEGV_MAYBE_FIXABLE(fi) 0
 
-extern unsigned long *sc_sigmask(void *sc_ptr);
-
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
-
index 92e989f..655f9c2 100644 (file)
@@ -9,6 +9,7 @@
 #include <sys/mman.h>
 #include <asm/unistd.h>
 #include <sysdep/ptrace_user.h>
+#include "as-layout.h"
 #include "stub-data.h"
 #include "kern_constants.h"
 #include "uml-config.h"
@@ -94,13 +95,13 @@ static inline void remap_stack(long fd, unsigned long offset)
 {
        __asm__ volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
                          "movq %6, %%r9; " __syscall "; movq %7, %%rbx ; "
-                         "movq %%rax, (%%rbx)": 
-                         : "a" (STUB_MMAP_NR), "D" (UML_CONFIG_STUB_DATA), 
-                           "S" (UM_KERN_PAGE_SIZE), 
-                           "d" (PROT_READ | PROT_WRITE), 
-                            "g" (MAP_FIXED | MAP_SHARED), "g" (fd), 
+                         "movq %%rax, (%%rbx)":
+                         : "a" (STUB_MMAP_NR), "D" (STUB_DATA),
+                           "S" (UM_KERN_PAGE_SIZE),
+                           "d" (PROT_READ | PROT_WRITE),
+                            "g" (MAP_FIXED | MAP_SHARED), "g" (fd),
                            "g" (offset),
-                           "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
+                           "i" (&((struct stub_data *) STUB_DATA)->err)
                          : __syscall_clobber, "r10", "r8", "r9" );
 }
 
diff --git a/arch/um/include/sysdep-x86_64/thread.h b/arch/um/include/sysdep-x86_64/thread.h
deleted file mode 100644 (file)
index cbef3e1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __UM_THREAD_H
-#define __UM_THREAD_H
-
-#include <kern_constants.h>
-
-#ifdef UML_CONFIG_MODE_TT
-#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
-#endif
-
-#endif
index 6375ba7..3fe726b 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <kern_constants.h>
 
-#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
+#define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
 #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
 
 #endif
index bcd1a4a..ecd2265 100644 (file)
@@ -8,34 +8,7 @@
 
 #include "um_mmu.h"
 
-struct host_vm_op {
-       enum { NONE, MMAP, MUNMAP, MPROTECT } type;
-       union {
-               struct {
-                       unsigned long addr;
-                       unsigned long len;
-                       unsigned int prot;
-                       int fd;
-                       __u64 offset;
-               } mmap;
-               struct {
-                       unsigned long addr;
-                       unsigned long len;
-               } munmap;
-               struct {
-                       unsigned long addr;
-                       unsigned long len;
-                       unsigned int prot;
-               } mprotect;
-       } u;
-};
-
 extern void force_flush_all(void);
-extern void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
-                             unsigned long end_addr, int force,
-                            int (*do_ops)(union mm_context *,
-                                          struct host_vm_op *, int, int,
-                                          void **));
 extern int flush_tlb_kernel_range_common(unsigned long start,
                                         unsigned long end);
 
diff --git a/arch/um/include/tt/debug.h b/arch/um/include/tt/debug.h
deleted file mode 100644 (file)
index 9778fa8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2000, 2001, 2002  Jeff Dike (jdike@karaya.com) and
- * Lars Brinkhoff.
- * Licensed under the GPL
- */
-
-#ifndef __UML_TT_DEBUG_H
-#define __UML_TT_DEBUG_H
-
-extern int debugger_proxy(int status, pid_t pid);
-extern void child_proxy(pid_t pid, int status);
-extern void init_proxy (pid_t pid, int waiting, int status);
-extern int start_debugger(char *prog, int startup, int stop, int *debugger_fd);
-extern void fake_child_exit(void);
-extern int gdb_config(char *str);
-extern int gdb_remove(int unused);
-
-#endif
diff --git a/arch/um/include/tt/mmu-tt.h b/arch/um/include/tt/mmu-tt.h
deleted file mode 100644 (file)
index 572a78b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_MMU_H
-#define __TT_MMU_H
-
-struct mmu_context_tt {
-};
-
-#endif
diff --git a/arch/um/include/tt/mode-tt.h b/arch/um/include/tt/mode-tt.h
deleted file mode 100644 (file)
index 2823cd5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_TT_H__
-#define __MODE_TT_H__
-
-#include "sysdep/ptrace.h"
-
-enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
-
-extern int tracing_pid;
-
-extern int tracer(int (*init_proc)(void *), void *sp);
-extern void sig_handler_common_tt(int sig, void *sc);
-extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
-extern void reboot_tt(void);
-extern void halt_tt(void);
-extern int is_tracer_winch(int pid, int fd, void *data);
-extern void kill_off_processes_tt(void);
-
-#endif
diff --git a/arch/um/include/tt/mode_kern_tt.h b/arch/um/include/tt/mode_kern_tt.h
deleted file mode 100644 (file)
index a4fc630..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_MODE_KERN_H__
-#define __TT_MODE_KERN_H__
-
-#include "linux/sched.h"
-#include "asm/page.h"
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-
-extern void switch_to_tt(void *prev, void *next);
-extern void flush_thread_tt(void);
-extern void start_thread_tt(struct pt_regs *regs, unsigned long eip,
-                          unsigned long esp);
-extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
-                         unsigned long stack_top, struct task_struct *p,
-                         struct pt_regs *regs);
-extern void release_thread_tt(struct task_struct *task);
-extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
-extern void init_idle_tt(void);
-extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
-extern void flush_tlb_kernel_vm_tt(void);
-extern void __flush_tlb_one_tt(unsigned long addr);
-extern void flush_tlb_range_tt(struct vm_area_struct *vma,
-                              unsigned long start, unsigned long end);
-extern void flush_tlb_mm_tt(struct mm_struct *mm);
-extern void force_flush_all_tt(void);
-extern long execute_syscall_tt(void *r);
-extern void before_mem_tt(unsigned long brk_start);
-extern unsigned long set_task_sizes_tt(unsigned long *task_size_out);
-extern int start_uml_tt(void);
-extern int external_pid_tt(struct task_struct *task);
-extern int thread_pid_tt(struct task_struct *task);
-
-#define kmem_end_tt (host_task_size - ABOVE_KMEM)
-
-#endif
diff --git a/arch/um/include/tt/tt.h b/arch/um/include/tt/tt.h
deleted file mode 100644 (file)
index acb8356..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_H__
-#define __TT_H__
-
-#include "sysdep/ptrace.h"
-
-extern int gdb_pid;
-extern int debug;
-extern int debug_stop;
-extern int debug_trace;
-
-extern int honeypot;
-
-extern int fork_tramp(void *sig_stack);
-extern int do_proc_op(void *t, int proc_id);
-extern int tracer(int (*init_proc)(void *), void *sp);
-extern void attach_process(int pid);
-extern void tracer_panic(char *format, ...)
-       __attribute__ ((format (printf, 1, 2)));
-extern void set_init_pid(int pid);
-extern int set_user_mode(void *task);
-extern void set_tracing(void *t, int tracing);
-extern int is_tracing(void *task);
-extern void syscall_handler(int sig, union uml_pt_regs *regs);
-extern void exit_kernel(int pid, void *task);
-extern void do_syscall(void *task, int pid, int local_using_sysemu);
-extern void do_sigtrap(void *task);
-extern int is_valid_pid(int pid);
-extern void remap_data(void *segment_start, void *segment_end, int w);
-extern long execute_syscall_tt(void *r);
-
-#endif
-
diff --git a/arch/um/include/tt/uaccess-tt.h b/arch/um/include/tt/uaccess-tt.h
deleted file mode 100644 (file)
index 13a64f6..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#ifndef __TT_UACCESS_H
-#define __TT_UACCESS_H
-
-#include "linux/string.h"
-#include "linux/sched.h"
-#include "asm/processor.h"
-#include "asm/errno.h"
-#include "asm/current.h"
-#include "asm/a.out.h"
-#include "uml_uaccess.h"
-
-#define ABOVE_KMEM (16 * 1024 * 1024)
-
-extern unsigned long end_vm;
-extern unsigned long uml_physmem;
-
-#define is_stack(addr, size) \
-       (((unsigned long) (addr) < STACK_TOP) && \
-        ((unsigned long) (addr) >= STACK_TOP - ABOVE_KMEM) && \
-        (((unsigned long) (addr) + (size)) <= STACK_TOP))
-
-#define access_ok_tt(type, addr, size) \
-       (is_stack(addr, size))
-
-extern int __do_copy_from_user(void *to, const void *from, int n,
-                              void **fault_addr, void **fault_catcher);
-extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
-                                 void **fault_addr, void **fault_catcher);
-extern int __do_clear_user(void *mem, size_t len, void **fault_addr,
-                          void **fault_catcher);
-extern int __do_strnlen_user(const char *str, unsigned long n,
-                            void **fault_addr, void **fault_catcher);
-
-extern int copy_from_user_tt(void *to, const void __user *from, int n);
-extern int copy_to_user_tt(void __user *to, const void *from, int n);
-extern int strncpy_from_user_tt(char *dst, const char __user *src, int count);
-extern int __clear_user_tt(void __user *mem, int len);
-extern int clear_user_tt(void __user *mem, int len);
-extern int strnlen_user_tt(const void __user *str, int len);
-
-#endif
index 0fa6432..8855d8d 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -7,34 +7,22 @@
 #define __ARCH_UM_MMU_H
 
 #include "uml-config.h"
-#include "choose-mode.h"
+#include "mm_id.h"
+#include "asm/ldt.h"
 
-#ifdef UML_CONFIG_MODE_TT
-#include "mmu-tt.h"
+typedef struct mm_context {
+       struct mm_id id;
+       unsigned long last_page_table;
+#ifdef CONFIG_3_LEVEL_PGTABLES
+       unsigned long last_pmd;
 #endif
+       struct uml_ldt ldt;
+} mm_context_t;
 
-#ifdef UML_CONFIG_MODE_SKAS
-#include "mmu-skas.h"
-#endif
+extern void __switch_mm(struct mm_id * mm_idp);
 
-typedef union mm_context {
-#ifdef UML_CONFIG_MODE_TT
-       struct mmu_context_tt tt;
-#endif
-#ifdef UML_CONFIG_MODE_SKAS
-       struct mmu_context_skas skas;
-#endif
-} mm_context_t;
+/* Avoid tangled inclusion with asm/ldt.h */
+extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm);
+extern void free_ldt(struct mm_context *mm);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 5126a99..fdfc06b 100644 (file)
@@ -1,26 +1,16 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #ifndef __ARCH_UM_UACCESS_H
 #define __ARCH_UM_UACCESS_H
 
-#include "choose-mode.h"
-
-#ifdef CONFIG_MODE_TT
-#include "uaccess-tt.h"
-#endif
-
-#ifdef CONFIG_MODE_SKAS
-#include "uaccess-skas.h"
-#endif
-
 #include "asm/fixmap.h"
 
 #define __under_task_size(addr, size) \
        (((unsigned long) (addr) < TASK_SIZE) && \
-         (((unsigned long) (addr) + (size)) < TASK_SIZE))
+        (((unsigned long) (addr) + (size)) < TASK_SIZE))
 
 #define __access_ok_vsyscall(type, addr, size) \
         ((type == VERIFY_READ) && \
        (__addr_range_nowrap(addr, size) && \
         (__under_task_size(addr, size) || \
          __access_ok_vsyscall(type, addr, size) || \
-         segment_eq(get_fs(), KERNEL_DS) || \
-         CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)))
+         segment_eq(get_fs(), KERNEL_DS)))
 
-static inline int copy_from_user(void *to, const void __user *from, int n)
-{
-       return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to,
-                               from, n));
-}
+extern int copy_from_user(void *to, const void __user *from, int n);
+extern int copy_to_user(void __user *to, const void *from, int n);
 
-static inline int copy_to_user(void __user *to, const void *from, int n)
-{
-       return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to, 
-                               from, n));
-}
+extern int __do_copy_to_user(void *to, const void *from, int n,
+                            void **fault_addr, jmp_buf **fault_catcher);
+extern void __do_copy(void *to, const void *from, int n);
 
 /*
  * strncpy_from_user: - Copy a NUL terminated string from userspace.
@@ -69,11 +53,7 @@ static inline int copy_to_user(void __user *to, const void *from, int n)
  * and returns @count.
  */
 
-static inline int strncpy_from_user(char *dst, const char __user *src, int count)
-{
-       return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas,
-                               dst, src, count));
-}
+extern int strncpy_from_user(char *dst, const char __user *src, int count);
 
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
@@ -86,10 +66,7 @@ static inline int strncpy_from_user(char *dst, const char __user *src, int count
  * Returns number of bytes that could not be cleared.
  * On success, this will be zero.
  */
-static inline int __clear_user(void *mem, int len)
-{
-       return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len));
-}
+extern int __clear_user(void __user *mem, int len);
 
 /*
  * clear_user: - Zero a block of memory in user space.
@@ -101,10 +78,7 @@ static inline int __clear_user(void *mem, int len)
  * Returns number of bytes that could not be cleared.
  * On success, this will be zero.
  */
-static inline int clear_user(void __user *mem, int len)
-{
-       return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len));
-}
+extern int clear_user(void __user *mem, int len);
 
 /*
  * strlen_user: - Get the size of a string in user space.
@@ -117,20 +91,6 @@ static inline int clear_user(void __user *mem, int len)
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-static inline int strnlen_user(const void __user *str, long len)
-{
-       return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len));
-}
+extern int strnlen_user(const void __user *str, int len);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/include/uml_uaccess.h b/arch/um/include/uml_uaccess.h
deleted file mode 100644 (file)
index c0df11d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __UML_UACCESS_H__
-#define __UML_UACCESS_H__
-
-extern int __do_copy_to_user(void *to, const void *from, int n,
-                            void **fault_addr, void **fault_catcher);
-void __do_copy(void *to, const void *from, int n);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index d380e6d..99033ff 100644 (file)
  */
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
-/*
- * This will provide the size_t definition in both kernel and userspace builds
- */
+/* This is to get size_t */
+#ifdef __KERNEL__
 #include <linux/types.h>
+#else
+#include <stddef.h>
+#endif
 
 extern void panic(const char *fmt, ...)
        __attribute__ ((format (printf, 1, 2)));
index c5cf4a0..499e5e9 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux,intel}.com)
 # Licensed under the GPL
 #
 
@@ -9,15 +9,12 @@ clean-files :=
 obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
        physmem.o process.o ptrace.o reboot.o sigio.o \
        signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \
-       um_arch.o umid.o
+       um_arch.o umid.o skas/
 
 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)    += gprof_syms.o
 obj-$(CONFIG_GCOV)     += gmon_syms.o
 
-obj-$(CONFIG_MODE_TT) += tt/
-obj-$(CONFIG_MODE_SKAS) += skas/
-
 USER_OBJS := config.o
 
 include arch/um/scripts/Makefile.rules
index 4185090..3866f49 100644 (file)
@@ -10,8 +10,6 @@ SECTIONS
   PROVIDE (__executable_start = START);
   . = START + SIZEOF_HEADERS;
   .interp         : { *(.interp) }
-  /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start
-   * is remapped.*/
   __binary_start = .;
   . = ALIGN(4096);             /* Init code and data */
   _text = .;
index ce6828f..8196450 100644 (file)
@@ -1,35 +1,44 @@
 /*
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/slab.h"
+#include "linux/stddef.h"
+#include "linux/fs.h"
 #include "linux/smp_lock.h"
 #include "linux/ptrace.h"
-#include "linux/fs.h"
-#include "asm/ptrace.h"
-#include "asm/pgtable.h"
-#include "asm/tlbflush.h"
+#include "linux/sched.h"
+#include "asm/current.h"
+#include "asm/processor.h"
 #include "asm/uaccess.h"
-#include "kern_util.h"
 #include "as-layout.h"
 #include "mem_user.h"
-#include "kern.h"
-#include "irq_user.h"
-#include "tlb.h"
+#include "skas.h"
 #include "os.h"
-#include "choose-mode.h"
-#include "mode_kern.h"
 
 void flush_thread(void)
 {
+       void *data = NULL;
+       unsigned long end = proc_mm ? task_size : STUB_START;
+       int ret;
+
        arch_flush_thread(&current->thread.arch);
-       CHOOSE_MODE(flush_thread_tt(), flush_thread_skas());
+
+       ret = unmap(&current->mm->context.id, 0, end, 1, &data);
+       if (ret) {
+               printk(KERN_ERR "flush_thread - clearing address space failed, "
+                      "err = %d\n", ret);
+               force_sig(SIGKILL, current);
+       }
+
+       __switch_mm(&current->mm->context.id);
 }
 
 void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
 {
-       CHOOSE_MODE_PROC(start_thread_tt, start_thread_skas, regs, eip, esp);
+       set_fs(USER_DS);
+       PT_REGS_IP(regs) = eip;
+       PT_REGS_SP(regs) = esp;
 }
 
 #ifdef CONFIG_TTY_LOG
@@ -39,7 +48,7 @@ extern void log_exec(char **argv, void *tty);
 static long execve1(char *file, char __user * __user *argv,
                    char __user *__user *env)
 {
-        long error;
+       long error;
 #ifdef CONFIG_TTY_LOG
        struct tty_struct *tty;
 
@@ -49,17 +58,16 @@ static long execve1(char *file, char __user * __user *argv,
                log_exec(argv, tty);
        mutex_unlock(&tty_mutex);
 #endif
-        error = do_execve(file, argv, env, &current->thread.regs);
-        if (error == 0){
+       error = do_execve(file, argv, env, &current->thread.regs);
+       if (error == 0) {
                task_lock(current);
-                current->ptrace &= ~PT_DTRACE;
+               current->ptrace &= ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
                SUBARCH_EXECVE1(&current->thread.regs.regs);
 #endif
                task_unlock(current);
-                set_cmdline(current_cmd());
-        }
-        return(error);
+       }
+       return error;
 }
 
 long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
@@ -67,9 +75,9 @@ long um_execve(char *file, char __user *__user *argv, char __user *__user *env)
        long err;
 
        err = execve1(file, argv, env);
-       if(!err)
-               do_longjmp(current->thread.exec_buf, 1);
-       return(err);
+       if (!err)
+               UML_LONGJMP(current->thread.exec_buf, 1);
+       return err;
 }
 
 long sys_execve(char __user *file, char __user *__user *argv,
@@ -86,5 +94,5 @@ long sys_execve(char __user *file, char __user *__user *argv,
        putname(filename);
  out:
        unlock_kernel();
-       return(error);
+       return error;
 }
index 13aa115..734f873 100644 (file)
@@ -12,8 +12,8 @@ EXPORT_SYMBOL(__bb_init_func);
  * versions in libgcov.
  *
  * Since SuSE backported the fix, we cannot handle it depending on GCC version.
- * So, unconditinally export it. But also give it a weak declaration, which will
- * be overriden by any other one.
+ * So, unconditionally export it. But also give it a weak declaration, which will
+ * be overridden by any other one.
  */
 
 extern void __gcov_init(void *) __attribute__((weak));
index cba516e..dcfceca 100644 (file)
@@ -3,16 +3,12 @@
  * Licensed under the GPL
  */
 
-#include "linux/mm.h"
-#include "linux/fs.h"
-#include "linux/module.h"
 #include "linux/sched.h"
 #include "linux/init_task.h"
+#include "linux/fs.h"
+#include "linux/module.h"
 #include "linux/mqueue.h"
 #include "asm/uaccess.h"
-#include "asm/pgtable.h"
-#include "mem_user.h"
-#include "os.h"
 
 static struct fs_struct init_fs = INIT_FS;
 struct mm_struct init_mm = INIT_MM(init_mm);
@@ -46,8 +42,3 @@ union thread_union init_thread_union
 union thread_union cpu0_irqstack
        __attribute__((__section__(".data.init_irqstack"))) =
                { INIT_THREAD_INFO(init_task) };
-
-void unprotect_stack(unsigned long stack)
-{
-       os_protect_memory((void *) stack, THREAD_SIZE, 1, 1, 0);
-}
index cf0dd9c..70c2d62 100644 (file)
@@ -1,37 +1,19 @@
 /*
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  * Derived (i.e. mostly copied) from arch/i386/kernel/irq.c:
  *     Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  */
 
-#include "linux/kernel.h"
-#include "linux/module.h"
-#include "linux/smp.h"
-#include "linux/kernel_stat.h"
+#include "linux/cpumask.h"
+#include "linux/hardirq.h"
 #include "linux/interrupt.h"
-#include "linux/random.h"
-#include "linux/slab.h"
-#include "linux/file.h"
-#include "linux/proc_fs.h"
-#include "linux/init.h"
+#include "linux/kernel_stat.h"
+#include "linux/module.h"
 #include "linux/seq_file.h"
-#include "linux/profile.h"
-#include "linux/hardirq.h"
-#include "asm/irq.h"
-#include "asm/hw_irq.h"
-#include "asm/atomic.h"
-#include "asm/signal.h"
-#include "asm/system.h"
-#include "asm/errno.h"
-#include "asm/uaccess.h"
+#include "as-layout.h"
 #include "kern_util.h"
-#include "irq_user.h"
-#include "irq_kern.h"
 #include "os.h"
-#include "sigio.h"
-#include "misc_constants.h"
-#include "as-layout.h"
 
 /*
  * Generic, controller-independent functions:
@@ -71,9 +53,8 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_putc(p, '\n');
 skip:
                spin_unlock_irqrestore(&irq_desc[i].lock, flags);
-       } else if (i == NR_IRQS) {
+       } else if (i == NR_IRQS)
                seq_putc(p, '\n');
-       }
 
        return 0;
 }
@@ -91,7 +72,7 @@ static struct irq_fd **last_irq_ptr = &active_fds;
 
 extern void free_irqs(void);
 
-void sigio_handler(int sig, union uml_pt_regs *regs)
+void sigio_handler(int sig, struct uml_pt_regs *regs)
 {
        struct irq_fd *irq_fd;
        int n;
@@ -102,11 +83,13 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
        while (1) {
                n = os_waiting_for_events(active_fds);
                if (n <= 0) {
-                       if(n == -EINTR) continue;
+                       if (n == -EINTR)
+                               continue;
                        else break;
                }
 
-               for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
+               for (irq_fd = active_fds; irq_fd != NULL;
+                    irq_fd = irq_fd->next) {
                        if (irq_fd->current_events != 0) {
                                irq_fd->current_events = 0;
                                do_IRQ(irq_fd->irq, regs);
@@ -138,8 +121,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
 
        if (type == IRQ_READ)
                events = UM_POLLIN | UM_POLLPRI;
-       else
-               events = UM_POLLOUT;
+       else events = UM_POLLOUT;
        *new_fd = ((struct irq_fd) { .next              = NULL,
                                     .id                = dev_id,
                                     .fd                = fd,
@@ -153,9 +135,10 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
        spin_lock_irqsave(&irq_lock, flags);
        for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
                if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
-                       printk("Registering fd %d twice\n", fd);
-                       printk("Irqs : %d, %d\n", irq_fd->irq, irq);
-                       printk("Ids : 0x%p, 0x%p\n", irq_fd->id, dev_id);
+                       printk(KERN_ERR "Registering fd %d twice\n", fd);
+                       printk(KERN_ERR "Irqs : %d, %d\n", irq_fd->irq, irq);
+                       printk(KERN_ERR "Ids : 0x%p, 0x%p\n", irq_fd->id,
+                              dev_id);
                        goto out_unlock;
                }
        }
@@ -171,7 +154,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                if (n == 0)
                        break;
 
-               /* n > 0
+               /*
+                * n > 0
                 * It means we couldn't put new pollfd to current pollfds
                 * and tmp_fds is NULL or too small for new pollfds array.
                 * Needed size is equal to n as minimum.
@@ -197,7 +181,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
 
        spin_unlock_irqrestore(&irq_lock, flags);
 
-       /* This calls activate_fd, so it has to be outside the critical
+       /*
+        * This calls activate_fd, so it has to be outside the critical
         * section.
         */
        maybe_sigio_broken(fd, (type == IRQ_READ));
@@ -264,13 +249,14 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
                i++;
        }
        if (irq == NULL) {
-               printk("find_irq_by_fd doesn't have descriptor %d\n", fd);
+               printk(KERN_ERR "find_irq_by_fd doesn't have descriptor %d\n",
+                      fd);
                goto out;
        }
        fdi = os_get_pollfd(i);
        if ((fdi != -1) && (fdi != fd)) {
-               printk("find_irq_by_fd - mismatch between active_fds and "
-                      "pollfds, fd %d vs %d, need %d\n", irq->fd,
+               printk(KERN_ERR "find_irq_by_fd - mismatch between active_fds "
+                      "and pollfds, fd %d vs %d, need %d\n", irq->fd,
                       fdi, fd);
                irq = NULL;
                goto out;
@@ -306,7 +292,7 @@ void deactivate_fd(int fd, int irqnum)
 
        spin_lock_irqsave(&irq_lock, flags);
        irq = find_irq_by_fd(fd, irqnum, &i);
-       if(irq == NULL){
+       if (irq == NULL) {
                spin_unlock_irqrestore(&irq_lock, flags);
                return;
        }
@@ -339,36 +325,12 @@ int deactivate_all_fds(void)
        return 0;
 }
 
-#ifdef CONFIG_MODE_TT
-void forward_interrupts(int pid)
-{
-       struct irq_fd *irq;
-       unsigned long flags;
-       int err;
-
-       spin_lock_irqsave(&irq_lock, flags);
-       for (irq = active_fds; irq != NULL; irq = irq->next) {
-               err = os_set_owner(irq->fd, pid);
-               if (err < 0) {
-                       /* XXX Just remove the irq rather than
-                        * print out an infinite stream of these
-                        */
-                       printk("Failed to forward %d to pid %d, err = %d\n",
-                              irq->fd, pid, -err);
-               }
-
-               irq->pid = pid;
-       }
-       spin_unlock_irqrestore(&irq_lock, flags);
-}
-#endif
-
 /*
- * do_IRQ handles all normal device IRQ's (the special
+ * do_IRQ handles all normal device IRQs (the special
  * SMP cross-CPU interrupts have their own specific
  * handlers).
  */
-unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
+unsigned int do_IRQ(int irq, struct uml_pt_regs *regs)
 {
        struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)regs);
        irq_enter();
@@ -396,8 +358,10 @@ int um_request_irq(unsigned int irq, int fd, int type,
 EXPORT_SYMBOL(um_request_irq);
 EXPORT_SYMBOL(reactivate_fd);
 
-/* hw_interrupt_type must define (startup || enable) &&
- * (shutdown || disable) && end */
+/*
+ * hw_interrupt_type must define (startup || enable) &&
+ * (shutdown || disable) && end
+ */
 static void dummy(unsigned int irq)
 {
 }
@@ -446,7 +410,8 @@ int init_aio_irq(int irq, char *name, irq_handler_t handler)
 
        err = os_pipe(fds, 1, 1);
        if (err) {
-               printk("init_aio_irq - os_pipe failed, err = %d\n", -err);
+               printk(KERN_ERR "init_aio_irq - os_pipe failed, err = %d\n",
+                      -err);
                goto out;
        }
 
@@ -454,7 +419,8 @@ int init_aio_irq(int irq, char *name, irq_handler_t handler)
                             IRQF_DISABLED | IRQF_SAMPLE_RANDOM, name,
                             (void *) (long) fds[0]);
        if (err) {
-               printk("init_aio_irq - : um_request_irq failed, err = %d\n",
+               printk(KERN_ERR "init_aio_irq - : um_request_irq failed, "
+                      "err = %d\n",
                       err);
                goto out_close;
        }
@@ -525,8 +491,9 @@ unsigned long to_irq_stack(unsigned long *mask_out)
        int nested;
 
        mask = xchg(&pending_mask, *mask_out);
-       if(mask != 0){
-               /* If any interrupts come in at this point, we want to
+       if (mask != 0) {
+               /*
+                * If any interrupts come in at this point, we want to
                 * make sure that their bits aren't lost by our
                 * putting our bit in.  So, this loop accumulates bits
                 * until xchg returns the same value that we put in.
@@ -538,13 +505,13 @@ unsigned long to_irq_stack(unsigned long *mask_out)
                do {
                        old |= mask;
                        mask = xchg(&pending_mask, old);
-               } while(mask != old);
+               } while (mask != old);
                return 1;
        }
 
        ti = current_thread_info();
        nested = (ti->real_thread != NULL);
-       if(!nested){
+       if (!nested) {
                struct task_struct *task;
                struct thread_info *tti;
 
index 7b3e53f..1b388b4 100644 (file)
@@ -1,22 +1,15 @@
 /* 
- * Copyright (C) 2001 - 2004 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include "linux/module.h"
-#include "linux/string.h"
-#include "linux/smp_lock.h"
-#include "linux/spinlock.h"
-#include "linux/highmem.h"
-#include "asm/current.h"
-#include "asm/processor.h"
-#include "asm/unistd.h"
-#include "asm/pgalloc.h"
-#include "asm/pgtable.h"
-#include "asm/page.h"
+#include "linux/syscalls.h"
+#include "asm/a.out.h"
 #include "asm/tlbflush.h"
-#include "kern_util.h"
+#include "asm/uaccess.h"
 #include "as-layout.h"
+#include "kern_util.h"
 #include "mem_user.h"
 #include "os.h"
 
@@ -34,30 +27,19 @@ EXPORT_SYMBOL(get_kmem_end);
 EXPORT_SYMBOL(high_physmem);
 EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(um_virt_to_phys);
-EXPORT_SYMBOL(mode_tt);
 EXPORT_SYMBOL(handle_page_fault);
 EXPORT_SYMBOL(find_iomem);
 
-#ifdef CONFIG_MODE_TT
-EXPORT_SYMBOL(stop);
-EXPORT_SYMBOL(strncpy_from_user_tt);
-EXPORT_SYMBOL(copy_from_user_tt);
-EXPORT_SYMBOL(copy_to_user_tt);
-#endif
-
-#ifdef CONFIG_MODE_SKAS
-EXPORT_SYMBOL(strnlen_user_skas);
-EXPORT_SYMBOL(strncpy_from_user_skas);
-EXPORT_SYMBOL(copy_to_user_skas);
-EXPORT_SYMBOL(copy_from_user_skas);
-EXPORT_SYMBOL(clear_user_skas);
-#endif
+EXPORT_SYMBOL(strnlen_user);
+EXPORT_SYMBOL(strncpy_from_user);
+EXPORT_SYMBOL(copy_to_user);
+EXPORT_SYMBOL(copy_from_user);
+EXPORT_SYMBOL(clear_user);
 EXPORT_SYMBOL(uml_strdup);
 
 EXPORT_SYMBOL(os_stat_fd);
 EXPORT_SYMBOL(os_stat_file);
 EXPORT_SYMBOL(os_access);
-EXPORT_SYMBOL(os_print_error);
 EXPORT_SYMBOL(os_get_exec_close);
 EXPORT_SYMBOL(os_set_exec_close);
 EXPORT_SYMBOL(os_getpid);
@@ -85,9 +67,6 @@ EXPORT_SYMBOL(run_helper);
 EXPORT_SYMBOL(start_thread);
 EXPORT_SYMBOL(dump_thread);
 
-EXPORT_SYMBOL(do_gettimeofday);
-EXPORT_SYMBOL(do_settimeofday);
-
 #ifdef CONFIG_SMP
 
 /* required for SMP */
index d2b11f2..59822de 100644 (file)
@@ -17,7 +17,7 @@
 #include "as-layout.h"
 #include "kern.h"
 #include "mem_user.h"
-#include "uml_uaccess.h"
+#include "um_uaccess.h"
 #include "os.h"
 #include "linux/types.h"
 #include "linux/string.h"
@@ -165,7 +165,7 @@ static void __init kmap_init(void)
        kmap_prot = PAGE_KERNEL;
 }
 
-static void init_highmem(void)
+static void __init init_highmem(void)
 {
        pgd_t *pgd;
        pud_t *pud;
index 5ee7e85..e66432f 100644 (file)
@@ -1,25 +1,17 @@
 /*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/mm.h"
-#include "linux/rbtree.h"
-#include "linux/slab.h"
-#include "linux/vmalloc.h"
 #include "linux/bootmem.h"
-#include "linux/module.h"
+#include "linux/mm.h"
 #include "linux/pfn.h"
-#include "asm/types.h"
-#include "asm/pgtable.h"
-#include "kern_util.h"
+#include "asm/page.h"
 #include "as-layout.h"
-#include "mode_kern.h"
-#include "mem.h"
+#include "init.h"
+#include "kern.h"
 #include "mem_user.h"
 #include "os.h"
-#include "kern.h"
-#include "init.h"
 
 static int physmem_fd = -1;
 
@@ -49,10 +41,10 @@ int __init init_maps(unsigned long physmem, unsigned long iomem,
        total_len = phys_len + iomem_len + highmem_len;
 
        map = alloc_bootmem_low_pages(total_len);
-       if(map == NULL)
+       if (map == NULL)
                return -ENOMEM;
 
-       for(i = 0; i < total_pages; i++){
+       for (i = 0; i < total_pages; i++) {
                p = &map[i];
                memset(p, 0, sizeof(struct page));
                SetPageReserved(p);
@@ -68,8 +60,8 @@ static unsigned long kmem_top = 0;
 
 unsigned long get_kmem_end(void)
 {
-       if(kmem_top == 0)
-               kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
+       if (kmem_top == 0)
+               kmem_top = host_task_size - 1024 * 1024;
        return kmem_top;
 }
 
@@ -81,9 +73,9 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
 
        fd = phys_mapping(phys, &offset);
        err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
-       if(err) {
-               if(err == -ENOMEM)
-                       printk("try increasing the host's "
+       if (err) {
+               if (err == -ENOMEM)
+                       printk(KERN_ERR "try increasing the host's "
                               "/proc/sys/vm/max_map_count to <physical "
                               "memory size>/4096\n");
                panic("map_memory(0x%lx, %d, 0x%llx, %ld, %d, %d, %d) failed, "
@@ -105,13 +97,16 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
 
        offset = uml_reserved - uml_physmem;
        err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
-                           len - offset, 1, 1, 0);
-       if(err < 0){
-               os_print_error(err, "Mapping memory");
+                           len - offset, 1, 1, 1);
+       if (err < 0) {
+               printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
+                      "failed - errno = %d\n", len - offset,
+                      (void *) uml_reserved, err);
                exit(1);
        }
 
-       /* Special kludge - This page will be mapped in to userspace processes
+       /*
+        * Special kludge - This page will be mapped in to userspace processes
         * from physmem_fd, so it needs to be written out there.
         */
        os_seek_file(physmem_fd, __pa(&__syscall_stub_start));
@@ -122,20 +117,20 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
                     len - bootmap_size - reserve);
 }
 
-int phys_mapping(unsigned long phys, __u64 *offset_out)
+int phys_mapping(unsigned long phys, unsigned long long *offset_out)
 {
        int fd = -1;
 
-       if(phys < physmem_size){
+       if (phys < physmem_size) {
                fd = physmem_fd;
                *offset_out = phys;
        }
-       else if(phys < __pa(end_iomem)){
+       else if (phys < __pa(end_iomem)) {
                struct iomem_region *region = iomem_regions;
 
-               while(region != NULL){
-                       if((phys >= region->phys) &&
-                          (phys < region->phys + region->size)){
+               while (region != NULL) {
+                       if ((phys >= region->phys) &&
+                           (phys < region->phys + region->size)) {
                                fd = region->fd;
                                *offset_out = phys - region->phys;
                                break;
@@ -143,7 +138,7 @@ int phys_mapping(unsigned long phys, __u64 *offset_out)
                        region = region->next;
                }
        }
-       else if(phys < __pa(end_iomem) + highmem){
+       else if (phys < __pa(end_iomem) + highmem) {
                fd = physmem_fd;
                *offset_out = phys - iomem_size;
        }
@@ -188,8 +183,8 @@ unsigned long find_iomem(char *driver, unsigned long *len_out)
 {
        struct iomem_region *region = iomem_regions;
 
-       while(region != NULL){
-               if(!strcmp(region->driver, driver)){
+       while (region != NULL) {
+               if (!strcmp(region->driver, driver)) {
                        *len_out = region->size;
                        return region->virt;
                }
@@ -206,12 +201,12 @@ int setup_iomem(void)
        unsigned long iomem_start = high_physmem + PAGE_SIZE;
        int err;
 
-       while(region != NULL){
+       while (region != NULL) {
                err = os_map_memory((void *) iomem_start, region->fd, 0,
                                    region->size, 1, 1, 0);
-               if(err)
-                       printk("Mapping iomem region for driver '%s' failed, "
-                              "errno = %d\n", region->driver, -err);
+               if (err)
+                       printk(KERN_ERR "Mapping iomem region for driver '%s' "
+                              "failed, errno = %d\n", region->driver, -err);
                else {
                        region->virt = iomem_start;
                        region->phys = __pa(region->virt);
index bfa52f2..0eae00b 100644 (file)
@@ -1,53 +1,30 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright 2003 PathScale, Inc.
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "linux/sched.h"
-#include "linux/interrupt.h"
-#include "linux/string.h"
+#include "linux/stddef.h"
+#include "linux/err.h"
+#include "linux/hardirq.h"
 #include "linux/mm.h"
-#include "linux/slab.h"
-#include "linux/utsname.h"
-#include "linux/fs.h"
-#include "linux/utime.h"
-#include "linux/smp_lock.h"
-#include "linux/module.h"
-#include "linux/init.h"
-#include "linux/capability.h"
-#include "linux/vmalloc.h"
-#include "linux/spinlock.h"
+#include "linux/personality.h"
 #include "linux/proc_fs.h"
 #include "linux/ptrace.h"
 #include "linux/random.h"
-#include "linux/personality.h"
-#include "asm/unistd.h"
-#include "asm/mman.h"
-#include "asm/segment.h"
-#include "asm/stat.h"
+#include "linux/sched.h"
+#include "linux/tick.h"
+#include "linux/threads.h"
 #include "asm/pgtable.h"
-#include "asm/processor.h"
-#include "asm/tlbflush.h"
 #include "asm/uaccess.h"
-#include "asm/user.h"
-#include "kern_util.h"
 #include "as-layout.h"
-#include "kern.h"
-#include "signal_kern.h"
-#include "init.h"
-#include "irq_user.h"
-#include "mem_user.h"
-#include "tlb.h"
-#include "frame_kern.h"
-#include "sigcontext.h"
+#include "kern_util.h"
 #include "os.h"
-#include "mode.h"
-#include "mode_kern.h"
-#include "choose-mode.h"
+#include "skas.h"
+#include "tlb.h"
 
-/* This is a per-cpu array.  A processor only modifies its entry and it only
+/*
+ * This is a per-cpu array.  A processor only modifies its entry and it only
  * cares about its entry, so it's OK if another processor is modifying its
  * entry.
  */
@@ -55,15 +32,16 @@ struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
 
 static inline int external_pid(struct task_struct *task)
 {
-       return CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task);
+       /* FIXME: Need to look up userspace_pid by cpu */
+       return userspace_pid[0];
 }
 
 int pid_to_processor_id(int pid)
 {
        int i;
 
-       for(i = 0; i < ncpus; i++){
-               if(cpu_tasks[i].pid == pid)
+       for(i = 0; i < ncpus; i++) {
+               if (cpu_tasks[i].pid == pid)
                        return i;
        }
        return -1;
@@ -82,9 +60,9 @@ unsigned long alloc_stack(int order, int atomic)
        if (atomic)
                flags = GFP_ATOMIC;
        page = __get_free_pages(flags, order);
-       if(page == 0)
+       if (page == 0)
                return 0;
-       stack_protections(page);
+
        return page;
 }
 
@@ -105,6 +83,8 @@ static inline void set_current(struct task_struct *task)
                { external_pid(task), task });
 }
 
+extern void arch_switch_to(struct task_struct *from, struct task_struct *to);
+
 void *_switch_to(void *prev, void *next, void *last)
 {
        struct task_struct *from = prev;
@@ -114,9 +94,14 @@ void *_switch_to(void *prev, void *next, void *last)
        set_current(to);
 
        do {
-               current->thread.saved_task = NULL ;
-               CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next);
-               if(current->thread.saved_task)
+               current->thread.saved_task = NULL;
+
+               switch_threads(&from->thread.switch_buf,
+                              &to->thread.switch_buf);
+
+               arch_switch_to(current->thread.prev_sched, current);
+
+               if (current->thread.saved_task)
                        show_regs(&(current->thread.regs));
                next= current->thread.saved_task;
                prev= current;
@@ -128,20 +113,14 @@ void *_switch_to(void *prev, void *next, void *last)
 
 void interrupt_end(void)
 {
-       if(need_resched())
+       if (need_resched())
                schedule();
-       if(test_tsk_thread_flag(current, TIF_SIGPENDING))
+       if (test_tsk_thread_flag(current, TIF_SIGPENDING))
                do_signal();
 }
 
-void release_thread(struct task_struct *task)
-{
-       CHOOSE_MODE(release_thread_tt(task), release_thread_skas(task));
-}
-
 void exit_thread(void)
 {
-       unprotect_stack((unsigned long) current_thread);
 }
 
 void *get_current(void)
@@ -149,28 +128,99 @@ void *get_current(void)
        return current;
 }
 
+extern void schedule_tail(struct task_struct *prev);
+
+/*
+ * This is called magically, by its address being stuffed in a jmp_buf
+ * and being longjmp-d to.
+ */
+void new_thread_handler(void)
+{
+       int (*fn)(void *), n;
+       void *arg;
+
+       if (current->thread.prev_sched != NULL)
+               schedule_tail(current->thread.prev_sched);
+       current->thread.prev_sched = NULL;
+
+       fn = current->thread.request.u.thread.proc;
+       arg = current->thread.request.u.thread.arg;
+
+       /*
+        * The return value is 1 if the kernel thread execs a process,
+        * 0 if it just exits
+        */
+       n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
+       if (n == 1) {
+               /* Handle any immediate reschedules or signals */
+               interrupt_end();
+               userspace(&current->thread.regs.regs);
+       }
+       else do_exit(0);
+}
+
+/* Called magically, see new_thread_handler above */
+void fork_handler(void)
+{
+       force_flush_all();
+       if (current->thread.prev_sched == NULL)
+               panic("blech");
+
+       schedule_tail(current->thread.prev_sched);
+
+       /*
+        * XXX: if interrupt_end() calls schedule, this call to
+        * arch_switch_to isn't needed. We could want to apply this to
+        * improve performance. -bb
+        */
+       arch_switch_to(current->thread.prev_sched, current);
+
+       current->thread.prev_sched = NULL;
+
+       /* Handle any immediate reschedules or signals */
+       interrupt_end();
+
+       userspace(&current->thread.regs.regs);
+}
+
 int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
                unsigned long stack_top, struct task_struct * p,
                struct pt_regs *regs)
 {
-       int ret;
+       void (*handler)(void);
+       int ret = 0;
 
        p->thread = (struct thread_struct) INIT_THREAD;
-       ret = CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr,
-                               clone_flags, sp, stack_top, p, regs);
 
-       if (ret || !current->thread.forking)
-               goto out;
+       if (current->thread.forking) {
+               memcpy(&p->thread.regs.regs, &regs->regs,
+                      sizeof(p->thread.regs.regs));
+               REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.gp, 0);
+               if (sp != 0)
+                       REGS_SP(p->thread.regs.regs.gp) = sp;
 
-       clear_flushed_tls(p);
+               handler = fork_handler;
 
-       /*
-        * Set a new TLS for the child thread?
-        */
-       if (clone_flags & CLONE_SETTLS)
-               ret = arch_copy_tls(p);
+               arch_copy_thread(&current->thread.arch, &p->thread.arch);
+       }
+       else {
+               init_thread_registers(&p->thread.regs.regs);
+               p->thread.request.u.thread = current->thread.request.u.thread;
+               handler = new_thread_handler;
+       }
+
+       new_thread(task_stack_page(p), &p->thread.switch_buf, handler);
+
+       if (current->thread.forking) {
+               clear_flushed_tls(p);
+
+               /*
+                * Set a new TLS for the child thread?
+                */
+               if (clone_flags & CLONE_SETTLS)
+                       ret = arch_copy_tls(p);
+       }
 
-out:
        return ret;
 }
 
@@ -179,39 +229,35 @@ void initial_thread_cb(void (*proc)(void *), void *arg)
        int save_kmalloc_ok = kmalloc_ok;
 
        kmalloc_ok = 0;
-       CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc,
-                        arg);
+       initial_thread_cb_skas(proc, arg);
        kmalloc_ok = save_kmalloc_ok;
 }
 
-#ifdef CONFIG_MODE_TT
-unsigned long stack_sp(unsigned long page)
-{
-       return page + PAGE_SIZE - sizeof(void *);
-}
-#endif
-
 void default_idle(void)
 {
-       CHOOSE_MODE(uml_idle_timer(), (void) 0);
+       unsigned long long nsecs;
 
-       while(1){
+       while(1) {
                /* endless idle loop with no priority at all */
 
                /*
                 * although we are an idle CPU, we do not want to
                 * get into the scheduler unnecessarily.
                 */
-               if(need_resched())
+               if (need_resched())
                        schedule();
 
-               idle_sleep(10);
+               tick_nohz_stop_sched_tick();
+               nsecs = disable_timer();
+               idle_sleep(nsecs);
+               tick_nohz_restart_sched_tick();
        }
 }
 
 void cpu_idle(void)
 {
-       CHOOSE_MODE(init_idle_tt(), init_idle_skas());
+       cpu_tasks[current_thread->cpu].pid = os_getpid();
+       default_idle();
 }
 
 void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
@@ -223,26 +269,26 @@ void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
        pte_t *pte;
        pte_t ptent;
 
-       if(task->mm == NULL)
+       if (task->mm == NULL)
                return ERR_PTR(-EINVAL);
        pgd = pgd_offset(task->mm, addr);
-       if(!pgd_present(*pgd))
+       if (!pgd_present(*pgd))
                return ERR_PTR(-EINVAL);
 
        pud = pud_offset(pgd, addr);
-       if(!pud_present(*pud))
+       if (!pud_present(*pud))
                return ERR_PTR(-EINVAL);
 
        pmd = pmd_offset(pud, addr);
-       if(!pmd_present(*pmd))
+       if (!pmd_present(*pmd))
                return ERR_PTR(-EINVAL);
 
        pte = pte_offset_kernel(pmd, addr);
        ptent = *pte;
-       if(!pte_present(ptent))
+       if (!pte_present(ptent))
                return ERR_PTR(-EINVAL);
 
-       if(pte_out != NULL)
+       if (pte_out != NULL)
                *pte_out = ptent;
        return (void *) (pte_val(ptent) & PAGE_MASK) + (addr & ~PAGE_MASK);
 }
@@ -315,7 +361,7 @@ int smp_sigio_handler(void)
 #ifdef CONFIG_SMP
        int cpu = current_thread->cpu;
        IPI_handler(cpu);
-       if(cpu != 0)
+       if (cpu != 0)
                return 1;
 #endif
        return 0;
@@ -343,7 +389,8 @@ int get_using_sysemu(void)
 
 static int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data)
 {
-       if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size) /*No overflow*/
+       if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size)
+               /* No overflow */
                *eof = 1;
 
        return strlen(buf);
@@ -358,7 +405,8 @@ static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned
 
        if (tmp[0] >= '0' && tmp[0] <= '2')
                set_using_sysemu(tmp[0] - '0');
-       return count; /*We use the first char, but pretend to write everything*/
+       /* We use the first char, but pretend to write everything */
+       return count;
 }
 
 int __init make_proc_sysemu(void)
@@ -388,10 +436,10 @@ int singlestepping(void * t)
        struct task_struct *task = t ? t : current;
 
        if ( ! (task->ptrace & PT_DTRACE) )
-               return(0);
+               return 0;
 
        if (task->thread.singlestep_syscall)
-               return(1);
+               return 1;
 
        return 2;
 }
index 6916c88..47b57b4 100644 (file)
@@ -1,35 +1,27 @@
-/* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "linux/errno.h"
-#include "linux/smp_lock.h"
-#include "linux/security.h"
-#include "linux/ptrace.h"
 #include "linux/audit.h"
+#include "linux/ptrace.h"
+#include "linux/sched.h"
+#include "asm/uaccess.h"
 #ifdef CONFIG_PROC_MM
-#include "linux/proc_mm.h"
+#include "proc_mm.h"
 #endif
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
 #include "skas_ptrace.h"
-#include "sysdep/ptrace.h"
-#include "os.h"
 
 static inline void set_singlestepping(struct task_struct *child, int on)
 {
-        if (on)
-                child->ptrace |= PT_DTRACE;
-        else
-                child->ptrace &= ~PT_DTRACE;
-        child->thread.singlestep_syscall = 0;
+       if (on)
+               child->ptrace |= PT_DTRACE;
+       else
+               child->ptrace &= ~PT_DTRACE;
+       child->thread.singlestep_syscall = 0;
 
 #ifdef SUBARCH_SET_SINGLESTEPPING
-        SUBARCH_SET_SINGLESTEPPING(child, on);
+       SUBARCH_SET_SINGLESTEPPING(child, on);
 #endif
 }
 
@@ -37,8 +29,8 @@ static inline void set_singlestepping(struct task_struct *child, int on)
  * Called by kernel/ptrace.c when detaching..
  */
 void ptrace_disable(struct task_struct *child)
-{ 
-        set_singlestepping(child,0);
+{
+       set_singlestepping(child,0);
 }
 
 extern int peek_user(struct task_struct * child, long addr, long data);
@@ -50,40 +42,40 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        unsigned long __user *p = (void __user *)(unsigned long)data;
 
        switch (request) {
-               /* when I and D space are separate, these will need to be fixed. */
-       case PTRACE_PEEKTEXT: /* read word at location addr. */ 
+       /* read word at location addr. */
+       case PTRACE_PEEKTEXT:
        case PTRACE_PEEKDATA:
                ret = generic_ptrace_peekdata(child, addr, data);
                break;
 
        /* read the word at location addr in the USER area. */
-        case PTRACE_PEEKUSR:
-                ret = peek_user(child, addr, data);
-                break;
+       case PTRACE_PEEKUSR:
+               ret = peek_user(child, addr, data);
+               break;
 
-       /* when I and D space are separate, this will have to be fixed. */
-       case PTRACE_POKETEXT: /* write the word at location addr. */
+       /* write the word at location addr. */
+       case PTRACE_POKETEXT:
        case PTRACE_POKEDATA:
                ret = generic_ptrace_pokedata(child, addr, data);
                break;
 
-       case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
-                ret = poke_user(child, addr, data);
-                break;
+       /* write the word at location addr in the USER area */
+       case PTRACE_POKEUSR:
+               ret = poke_user(child, addr, data);
+               break;
 
-       case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
-       case PTRACE_CONT: { /* restart after signal. */
+       /* continue and stop at next (return from) syscall */
+       case PTRACE_SYSCALL:
+       /* restart after signal. */
+       case PTRACE_CONT: {
                ret = -EIO;
                if (!valid_signal(data))
                        break;
 
-                set_singlestepping(child, 0);
-               if (request == PTRACE_SYSCALL) {
+               set_singlestepping(child, 0);
+               if (request == PTRACE_SYSCALL)
                        set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               }
-               else {
-                       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               }
+               else clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
                child->exit_code = data;
                wake_up_process(child);
                ret = 0;
@@ -91,8 +83,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        }
 
 /*
- * make the child exit.  Best I can do is send it a sigkill. 
- * perhaps it should be put in the status that it wants to 
+ * make the child exit.  Best I can do is send it a sigkill.
+ * perhaps it should be put in the status that it wants to
  * exit.
  */
        case PTRACE_KILL: {
@@ -100,7 +92,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                if (child->exit_state == EXIT_ZOMBIE)   /* already dead */
                        break;
 
-                set_singlestepping(child, 0);
+               set_singlestepping(child, 0);
                child->exit_code = SIGKILL;
                wake_up_process(child);
                break;
@@ -111,7 +103,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                if (!valid_signal(data))
                        break;
                clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-                set_singlestepping(child, 1);
+               set_singlestepping(child, 1);
                child->exit_code = data;
                /* give it a chance to run. */
                wake_up_process(child);
@@ -119,11 +111,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                break;
        }
 
-       case PTRACE_DETACH:
-               /* detach a process that was attached. */
-               ret = ptrace_detach(child, data);
-               break;
-
 #ifdef PTRACE_GETREGS
        case PTRACE_GETREGS: { /* Get all gp regs from the child. */
                if (!access_ok(VERIFY_WRITE, p, MAX_REG_OFFSET)) {
@@ -156,22 +143,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 #endif
 #ifdef PTRACE_GETFPREGS
        case PTRACE_GETFPREGS: /* Get the child FPU state. */
-               ret = get_fpregs(data, child);
+               ret = get_fpregs((struct user_i387_struct __user *) data,
+                                child);
                break;
 #endif
 #ifdef PTRACE_SETFPREGS
        case PTRACE_SETFPREGS: /* Set the child FPU state. */
-               ret = set_fpregs(data, child);
-               break;
-#endif
-#ifdef PTRACE_GETFPXREGS
-       case PTRACE_GETFPXREGS: /* Get the child FPU state. */
-               ret = get_fpxregs(data, child);
-               break;
-#endif
-#ifdef PTRACE_SETFPXREGS
-       case PTRACE_SETFPXREGS: /* Set the child FPU state. */
-               ret = set_fpxregs(data, child);
+               ret = set_fpregs((struct user_i387_struct __user *) data,
+                                child);
                break;
 #endif
        case PTRACE_GET_THREAD_AREA:
@@ -185,14 +164,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                break;
 
        case PTRACE_FAULTINFO: {
-               /* Take the info from thread->arch->faultinfo,
+               /*
+                * Take the info from thread->arch->faultinfo,
                 * but transfer max. sizeof(struct ptrace_faultinfo).
                 * On i386, ptrace_faultinfo is smaller!
                 */
                ret = copy_to_user(p, &child->thread.arch.faultinfo,
                                   sizeof(struct ptrace_faultinfo));
-               if(ret)
-                       break;
                break;
        }
 
@@ -200,12 +178,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        case PTRACE_LDT: {
                struct ptrace_ldt ldt;
 
-               if(copy_from_user(&ldt, p, sizeof(ldt))){
+               if (copy_from_user(&ldt, p, sizeof(ldt))) {
                        ret = -EIO;
                        break;
                }
 
-               /* This one is confusing, so just punt and return -EIO for 
+               /*
+                * This one is confusing, so just punt and return -EIO for
                 * now
                 */
                ret = -EIO;
@@ -217,7 +196,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                struct mm_struct *old = child->mm;
                struct mm_struct *new = proc_mm_get_mm(data);
 
-               if(IS_ERR(new)){
+               if (IS_ERR(new)) {
                        ret = PTR_ERR(new);
                        break;
                }
@@ -231,20 +210,22 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        }
 #endif
 #ifdef PTRACE_ARCH_PRCTL
-        case PTRACE_ARCH_PRCTL:
-                /* XXX Calls ptrace on the host - needs some SMP thinking */
-                ret = arch_prctl_skas(child, data, (void *) addr);
-                break;
+       case PTRACE_ARCH_PRCTL:
+               /* XXX Calls ptrace on the host - needs some SMP thinking */
+               ret = arch_prctl(child, data, (void *) addr);
+               break;
 #endif
        default:
                ret = ptrace_request(child, request, addr, data);
+               if (ret == -EIO)
+                       ret = subarch_ptrace(child, request, addr, data);
                break;
        }
 
        return ret;
 }
 
-void send_sigtrap(struct task_struct *tsk, union uml_pt_regs *regs,
+void send_sigtrap(struct task_struct *tsk, struct uml_pt_regs *regs,
                  int error_code)
 {
        struct siginfo info;
@@ -256,14 +237,15 @@ void send_sigtrap(struct task_struct *tsk, union uml_pt_regs *regs,
        /* User-mode eip? */
        info.si_addr = UPT_IS_USER(regs) ? (void __user *) UPT_IP(regs) : NULL;
 
-       /* Send us the fakey SIGTRAP */
+       /* Send us the fake SIGTRAP */
        force_sig_info(SIGTRAP, &info, tsk);
 }
 
-/* XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
+/*
+ * XXX Check PT_DTRACE vs TIF_SINGLESTEP for singlestepping check and
  * PT_PTRACED vs TIF_SYSCALL_TRACE for syscall tracing check
  */
-void syscall_trace(union uml_pt_regs *regs, int entryexit)
+void syscall_trace(struct uml_pt_regs *regs, int entryexit)
 {
        int is_singlestep = (current->ptrace & PT_DTRACE) && entryexit;
        int tracesysgood;
@@ -277,7 +259,7 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)
                                            UPT_SYSCALL_ARG3(regs),
                                            UPT_SYSCALL_ARG4(regs));
                else audit_syscall_exit(AUDITSC_RESULT(UPT_SYSCALL_RET(regs)),
-                                        UPT_SYSCALL_RET(regs));
+                                       UPT_SYSCALL_RET(regs));
        }
 
        /* Fake a debug trap */
@@ -290,15 +272,18 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)
        if (!(current->ptrace & PT_PTRACED))
                return;
 
-       /* the 0x80 provides a way for the tracing parent to distinguish
-          between a syscall stop and SIGTRAP delivery */
+       /*
+        * the 0x80 provides a way for the tracing parent to distinguish
+        * between a syscall stop and SIGTRAP delivery
+        */
        tracesysgood = (current->ptrace & PT_TRACESYSGOOD);
        ptrace_notify(SIGTRAP | (tracesysgood ? 0x80 : 0));
 
        if (entryexit) /* force do_signal() --> is_syscall() */
                set_thread_flag(TIF_SIGPENDING);
 
-       /* this isn't the same as continuing with a signal, but it will do
+       /*
+        * this isn't the same as continuing with a signal, but it will do
         * for normal use.  strace only continues with a signal if the
         * stopping signal is not SIGTRAP.  -brl
         */
index 7e4305a..04cebcf 100644 (file)
@@ -1,60 +1,53 @@
 /* 
- * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/module.h"
 #include "linux/sched.h"
-#include "asm/smp.h"
-#include "kern_util.h"
-#include "kern.h"
 #include "os.h"
-#include "mode.h"
-#include "choose-mode.h"
+#include "skas.h"
 
 void (*pm_power_off)(void);
 
-#ifdef CONFIG_SMP
-static void kill_idlers(int me)
-{
-#ifdef CONFIG_MODE_TT
-       struct task_struct *p;
-       int i;
-
-       for(i = 0; i < ARRAY_SIZE(idle_threads); i++){
-               p = idle_threads[i];
-               if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
-                       os_kill_process(p->thread.mode.tt.extern_pid, 0);
-       }
-#endif
-}
-#endif
-
 static void kill_off_processes(void)
 {
-       CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
-#ifdef CONFIG_SMP
-       kill_idlers(os_getpid());
-#endif
+       if(proc_mm)
+               /*
+                * FIXME: need to loop over userspace_pids
+                */
+               os_kill_ptraced_process(userspace_pid[0], 1);
+       else {
+               struct task_struct *p;
+               int pid, me;
+
+               me = os_getpid();
+               for_each_process(p){
+                       if(p->mm == NULL)
+                               continue;
+
+                       pid = p->mm->context.id.u.pid;
+                       os_kill_ptraced_process(pid, 1);
+               }
+       }
 }
 
 void uml_cleanup(void)
 {
-        kmalloc_ok = 0;
+       kmalloc_ok = 0;
        do_uml_exitcalls();
        kill_off_processes();
 }
 
 void machine_restart(char * __unused)
 {
-        uml_cleanup();
-       CHOOSE_MODE(reboot_tt(), reboot_skas());
+       uml_cleanup();
+       reboot_skas();
 }
 
 void machine_power_off(void)
 {
-        uml_cleanup();
-       CHOOSE_MODE(halt_tt(), halt_skas());
+       uml_cleanup();
+       halt_skas();
 }
 
 void machine_halt(void)
index c4020c3..19cb977 100644 (file)
@@ -1,29 +1,17 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/stddef.h"
-#include "linux/sys.h"
-#include "linux/sched.h"
-#include "linux/wait.h"
-#include "linux/kernel.h"
-#include "linux/smp_lock.h"
 #include "linux/module.h"
-#include "linux/slab.h"
-#include "linux/tty.h"
-#include "linux/binfmts.h"
 #include "linux/ptrace.h"
+#include "linux/sched.h"
+#include "asm/siginfo.h"
 #include "asm/signal.h"
-#include "asm/uaccess.h"
 #include "asm/unistd.h"
-#include "asm/ucontext.h"
-#include "kern_util.h"
-#include "signal_kern.h"
-#include "kern.h"
 #include "frame_kern.h"
+#include "kern_util.h"
 #include "sigcontext.h"
-#include "mode.h"
 
 EXPORT_SYMBOL(block_signals);
 EXPORT_SYMBOL(unblock_signals);
@@ -46,9 +34,9 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
        current_thread_info()->restart_block.fn = do_no_restart_syscall;
 
        /* Did we come from a system call? */
-       if(PT_REGS_SYSCALL_NR(regs) >= 0){
+       if (PT_REGS_SYSCALL_NR(regs) >= 0) {
                /* If so, check system call restarting.. */
-               switch(PT_REGS_SYSCALL_RET(regs)){
+               switch(PT_REGS_SYSCALL_RET(regs)) {
                case -ERESTART_RESTARTBLOCK:
                case -ERESTARTNOHAND:
                        PT_REGS_SYSCALL_RET(regs) = -EINTR;
@@ -68,17 +56,17 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
        }
 
        sp = PT_REGS_SP(regs);
-       if((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
+       if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
                sp = current->sas_ss_sp + current->sas_ss_size;
 
 #ifdef CONFIG_ARCH_HAS_SC_SIGNALS
-       if(!(ka->sa.sa_flags & SA_SIGINFO))
+       if (!(ka->sa.sa_flags & SA_SIGINFO))
                err = setup_signal_stack_sc(sp, signr, ka, regs, oldset);
        else
 #endif
                err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset);
 
-       if(err){
+       if (err) {
                spin_lock_irq(&current->sighand->siglock);
                current->blocked = *oldset;
                recalc_sigpending();
@@ -88,7 +76,7 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
                spin_lock_irq(&current->sighand->siglock);
                sigorsets(&current->blocked, &current->blocked,
                          &ka->sa.sa_mask);
-                if(!(ka->sa.sa_flags & SA_NODEFER))
+               if (!(ka->sa.sa_flags & SA_NODEFER))
                        sigaddset(&current->blocked, signr);
                recalc_sigpending();
                spin_unlock_irq(&current->sighand->siglock);
@@ -109,14 +97,16 @@ static int kern_do_signal(struct pt_regs *regs)
        else
                oldset = &current->blocked;
 
-       while((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0){
+       while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
                handled_sig = 1;
                /* Whee!  Actually deliver the signal.  */
-               if(!handle_signal(regs, sig, &ka_copy, &info, oldset)){
-                       /* a signal was successfully delivered; the saved
+               if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) {
+                       /*
+                        * a signal was successfully delivered; the saved
                         * sigmask will have been stored in the signal frame,
                         * and will be restored by sigreturn, so we can simply
-                        * clear the TIF_RESTORE_SIGMASK flag */
+                        * clear the TIF_RESTORE_SIGMASK flag
+                        */
                        if (test_thread_flag(TIF_RESTORE_SIGMASK))
                                clear_thread_flag(TIF_RESTORE_SIGMASK);
                        break;
@@ -124,9 +114,9 @@ static int kern_do_signal(struct pt_regs *regs)
        }
 
        /* Did we come from a system call? */
-       if(!handled_sig && (PT_REGS_SYSCALL_NR(regs) >= 0)){
+       if (!handled_sig && (PT_REGS_SYSCALL_NR(regs) >= 0)) {
                /* Restart the system call - no handlers present */
-               switch(PT_REGS_SYSCALL_RET(regs)){
+               switch(PT_REGS_SYSCALL_RET(regs)) {
                case -ERESTARTNOHAND:
                case -ERESTARTSYS:
                case -ERESTARTNOINTR:
@@ -137,22 +127,25 @@ static int kern_do_signal(struct pt_regs *regs)
                        PT_REGS_ORIG_SYSCALL(regs) = __NR_restart_syscall;
                        PT_REGS_RESTART_SYSCALL(regs);
                        break;
-               }
+               }
        }
 
-       /* This closes a way to execute a system call on the host.  If
+       /*
+        * This closes a way to execute a system call on the host.  If
         * you set a breakpoint on a system call instruction and singlestep
         * from it, the tracing thread used to PTRACE_SINGLESTEP the process
         * rather than PTRACE_SYSCALL it, allowing the system call to execute
         * on the host.  The tracing thread will check this flag and
         * PTRACE_SYSCALL if necessary.
         */
-       if(current->ptrace & PT_DTRACE)
+       if (current->ptrace & PT_DTRACE)
                current->thread.singlestep_syscall =
                        is_syscall(PT_REGS_IP(&current->thread.regs));
 
-       /* if there's no signal to deliver, we just put the saved sigmask
-        * back */
+       /*
+        * if there's no signal to deliver, we just put the saved sigmask
+        * back
+        */
        if (!handled_sig && test_thread_flag(TIF_RESTORE_SIGMASK)) {
                clear_thread_flag(TIF_RESTORE_SIGMASK);
                sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
index 3e3fa7e..0b76d88 100644 (file)
@@ -1,9 +1,9 @@
 #
-# Copyright (C) 2002 - 2004 Jeff Dike (jdike@addtoit.com)
+# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 # Licensed under the GPL
 #
 
-obj-y := clone.o exec.o mem.o mmu.o process.o syscall.o tlb.o uaccess.o
+obj-y := clone.o mmu.o process.o syscall.o uaccess.o
 
 # clone.o is in the stub, so it can't be built with profiling
 # GCC hardened also auto-enables -fpic, but we need %ebx so it can't work ->
index 47b812b..d119f4f 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/time.h>
 #include <asm/unistd.h>
 #include <asm/page.h>
+#include "as-layout.h"
 #include "ptrace_user.h"
 #include "skas.h"
 #include "stub-data.h"
 void __attribute__ ((__section__ (".__syscall_stub")))
 stub_clone_handler(void)
 {
-       struct stub_data *data = (struct stub_data *) UML_CONFIG_STUB_DATA;
+       struct stub_data *data = (struct stub_data *) STUB_DATA;
        long err;
 
        err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
-                           UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE / 2 -
-                           sizeof(void *));
+                           STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *));
        if(err != 0)
                goto out;
 
diff --git a/arch/um/kernel/skas/exec.c b/arch/um/kernel/skas/exec.c
deleted file mode 100644 (file)
index 580eb64..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/kernel.h"
-#include "asm/current.h"
-#include "asm/page.h"
-#include "asm/signal.h"
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "asm/mmu_context.h"
-#include "tlb.h"
-#include "skas.h"
-#include "um_mmu.h"
-#include "os.h"
-
-void flush_thread_skas(void)
-{
-       void *data = NULL;
-       unsigned long end = proc_mm ? task_size : CONFIG_STUB_START;
-       int ret;
-
-       ret = unmap(&current->mm->context.skas.id, 0, end, 1, &data);
-       if(ret){
-               printk("flush_thread_skas - clearing address space failed, "
-                      "err = %d\n", ret);
-               force_sig(SIGKILL, current);
-       }
-
-       switch_mm_skas(&current->mm->context.skas.id);
-}
-
-void start_thread_skas(struct pt_regs *regs, unsigned long eip,
-                      unsigned long esp)
-{
-       set_fs(USER_DS);
-       PT_REGS_IP(regs) = eip;
-       PT_REGS_SP(regs) = esp;
-}
diff --git a/arch/um/kernel/skas/mem.c b/arch/um/kernel/skas/mem.c
deleted file mode 100644 (file)
index 7c18dfc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/mm.h"
-#include "asm/pgtable.h"
-#include "mem_user.h"
-#include "skas.h"
-
-unsigned long set_task_sizes_skas(unsigned long *task_size_out)
-{
-       /* Round up to the nearest 4M */
-       unsigned long host_task_size = ROUND_4M((unsigned long)
-                                               &host_task_size);
-
-       if (!skas_needs_stub)
-               *task_size_out = host_task_size;
-       else *task_size_out = CONFIG_STUB_START & PGDIR_MASK;
-
-       return host_task_size;
-}
index 2c6d090..f859ec3 100644 (file)
@@ -1,20 +1,13 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/list.h"
-#include "linux/spinlock.h"
-#include "linux/slab.h"
-#include "linux/errno.h"
 #include "linux/mm.h"
-#include "asm/current.h"
-#include "asm/segment.h"
-#include "asm/mmu.h"
+#include "linux/sched.h"
 #include "asm/pgalloc.h"
 #include "asm/pgtable.h"
-#include "asm/ldt.h"
+#include "as-layout.h"
 #include "os.h"
 #include "skas.h"
 
@@ -41,10 +34,11 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
        if (!pte)
                goto out_pte;
 
-       /* There's an interaction between the skas0 stub pages, stack
+       /*
+        * There's an interaction between the skas0 stub pages, stack
         * randomization, and the BUG at the end of exit_mmap.  exit_mmap
-         * checks that the number of page tables freed is the same as had
-         * been allocated.  If the stack is on the last page table page,
+        * checks that the number of page tables freed is the same as had
+        * been allocated.  If the stack is on the last page table page,
         * then the stack pte page will be freed, and if not, it won't.  To
         * avoid having to know where the stack is, or if the process mapped
         * something at the top of its address space for some other reason,
@@ -54,76 +48,77 @@ static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
         * destroy_context_skas.
         */
 
-        mm->context.skas.last_page_table = pmd_page_vaddr(*pmd);
+       mm->context.last_page_table = pmd_page_vaddr(*pmd);
 #ifdef CONFIG_3_LEVEL_PGTABLES
-        mm->context.skas.last_pmd = (unsigned long) __va(pud_val(*pud));
+       mm->context.last_pmd = (unsigned long) __va(pud_val(*pud));
 #endif
 
        *pte = mk_pte(virt_to_page(kernel), __pgprot(_PAGE_PRESENT));
        *pte = pte_mkread(*pte);
-       return(0);
+       return 0;
 
  out_pmd:
        pud_free(pud);
  out_pte:
        pmd_free(pmd);
  out:
-       return(-ENOMEM);
+       return -ENOMEM;
 }
 
-int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
+int init_new_context(struct task_struct *task, struct mm_struct *mm)
 {
-       struct mmu_context_skas *from_mm = NULL;
-       struct mmu_context_skas *to_mm = &mm->context.skas;
+       struct mm_context *from_mm = NULL;
+       struct mm_context *to_mm = &mm->context;
        unsigned long stack = 0;
        int ret = -ENOMEM;
 
-       if(skas_needs_stub){
+       if (skas_needs_stub) {
                stack = get_zeroed_page(GFP_KERNEL);
-               if(stack == 0)
+               if (stack == 0)
                        goto out;
 
-               /* This zeros the entry that pgd_alloc didn't, needed since
+               /*
+                * This zeros the entry that pgd_alloc didn't, needed since
                 * we are about to reinitialize it, and want mm.nr_ptes to
                 * be accurate.
                 */
                mm->pgd[USER_PTRS_PER_PGD] = __pgd(0);
 
-               ret = init_stub_pte(mm, CONFIG_STUB_CODE,
+               ret = init_stub_pte(mm, STUB_CODE,
                                    (unsigned long) &__syscall_stub_start);
-               if(ret)
+               if (ret)
                        goto out_free;
 
-               ret = init_stub_pte(mm, CONFIG_STUB_DATA, stack);
-               if(ret)
+               ret = init_stub_pte(mm, STUB_DATA, stack);
+               if (ret)
                        goto out_free;
 
                mm->nr_ptes--;
        }
 
        to_mm->id.stack = stack;
-       if(current->mm != NULL && current->mm != &init_mm)
-               from_mm = &current->mm->context.skas;
+       if (current->mm != NULL && current->mm != &init_mm)
+               from_mm = &current->mm->context;
 
-       if(proc_mm){
+       if (proc_mm) {
                ret = new_mm(stack);
-               if(ret < 0){
-                       printk("init_new_context_skas - new_mm failed, "
-                              "errno = %d\n", ret);
+               if (ret < 0) {
+                       printk(KERN_ERR "init_new_context_skas - "
+                              "new_mm failed, errno = %d\n", ret);
                        goto out_free;
                }
                to_mm->id.u.mm_fd = ret;
        }
        else {
-               if(from_mm)
+               if (from_mm)
                        to_mm->id.u.pid = copy_context_skas0(stack,
                                                             from_mm->id.u.pid);
                else to_mm->id.u.pid = start_userspace(stack);
        }
 
        ret = init_new_ldt(to_mm, from_mm);
-       if(ret < 0){
-               printk("init_new_context_skas - init_ldt"
+       if (ret < 0) {
+               printk(KERN_ERR "init_new_context_skas - init_ldt"
                       " failed, errno = %d\n", ret);
                goto out_free;
        }
@@ -131,22 +126,22 @@ int init_new_context_skas(struct task_struct *task, struct mm_struct *mm)
        return 0;
 
  out_free:
-       if(to_mm->id.stack != 0)
+       if (to_mm->id.stack != 0)
                free_page(to_mm->id.stack);
  out:
        return ret;
 }
 
-void destroy_context_skas(struct mm_struct *mm)
+void destroy_context(struct mm_struct *mm)
 {
-       struct mmu_context_skas *mmu = &mm->context.skas;
+       struct mm_context *mmu = &mm->context;
 
-       if(proc_mm)
+       if (proc_mm)
                os_close_file(mmu->id.u.mm_fd);
        else
                os_kill_ptraced_process(mmu->id.u.pid, 1);
 
-       if(!proc_mm || !ptrace_faultinfo){
+       if (!proc_mm || !ptrace_faultinfo) {
                free_page(mmu->id.stack);
                pte_lock_deinit(virt_to_page(mmu->last_page_table));
                pte_free_kernel((pte_t *) mmu->last_page_table);
@@ -155,4 +150,6 @@ void destroy_context_skas(struct mm_struct *mm)
                pmd_free((pmd_t *) mmu->last_pmd);
 #endif
        }
+
+       free_ldt(mmu);
 }
index 48051a9..fce389c 100644 (file)
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/slab.h"
-#include "linux/ptrace.h"
-#include "linux/proc_fs.h"
-#include "linux/file.h"
-#include "linux/errno.h"
 #include "linux/init.h"
-#include "asm/uaccess.h"
-#include "asm/atomic.h"
-#include "kern_util.h"
+#include "linux/sched.h"
 #include "as-layout.h"
-#include "skas.h"
 #include "os.h"
-#include "tlb.h"
-#include "kern.h"
-#include "mode.h"
-#include "registers.h"
-
-void switch_to_skas(void *prev, void *next)
-{
-       struct task_struct *from, *to;
-
-       from = prev;
-       to = next;
-
-       /* XXX need to check runqueues[cpu].idle */
-       if(current->pid == 0)
-               switch_timers(0);
-
-       switch_threads(&from->thread.mode.skas.switch_buf,
-                      &to->thread.mode.skas.switch_buf);
-
-       arch_switch_to_skas(current->thread.prev_sched, current);
-
-       if(current->pid == 0)
-               switch_timers(1);
-}
-
-extern void schedule_tail(struct task_struct *prev);
-
-/* This is called magically, by its address being stuffed in a jmp_buf
- * and being longjmp-d to.
- */
-void new_thread_handler(void)
-{
-       int (*fn)(void *), n;
-       void *arg;
-
-       if(current->thread.prev_sched != NULL)
-               schedule_tail(current->thread.prev_sched);
-       current->thread.prev_sched = NULL;
-
-       fn = current->thread.request.u.thread.proc;
-       arg = current->thread.request.u.thread.arg;
-
-       /* The return value is 1 if the kernel thread execs a process,
-        * 0 if it just exits
-        */
-       n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
-       if(n == 1){
-               /* Handle any immediate reschedules or signals */
-               interrupt_end();
-               userspace(&current->thread.regs.regs);
-       }
-       else do_exit(0);
-}
-
-void release_thread_skas(struct task_struct *task)
-{
-}
-
-/* Called magically, see new_thread_handler above */
-void fork_handler(void)
-{
-       force_flush_all();
-       if(current->thread.prev_sched == NULL)
-               panic("blech");
-
-       schedule_tail(current->thread.prev_sched);
-
-       /* XXX: if interrupt_end() calls schedule, this call to
-        * arch_switch_to_skas isn't needed. We could want to apply this to
-        * improve performance. -bb */
-       arch_switch_to_skas(current->thread.prev_sched, current);
-
-       current->thread.prev_sched = NULL;
-
-/* Handle any immediate reschedules or signals */
-       interrupt_end();
-
-       userspace(&current->thread.regs.regs);
-}
-
-int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
-                    unsigned long stack_top, struct task_struct * p,
-                    struct pt_regs *regs)
-{
-       void (*handler)(void);
-
-       if(current->thread.forking){
-               memcpy(&p->thread.regs.regs.skas, &regs->regs.skas,
-                      sizeof(p->thread.regs.regs.skas));
-               REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
-               if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
-
-               handler = fork_handler;
-
-               arch_copy_thread(&current->thread.arch, &p->thread.arch);
-       }
-       else {
-               init_thread_registers(&p->thread.regs.regs);
-               p->thread.request.u.thread = current->thread.request.u.thread;
-               handler = new_thread_handler;
-       }
-
-       new_thread(task_stack_page(p), &p->thread.mode.skas.switch_buf,
-                  handler);
-       return(0);
-}
+#include "skas.h"
 
 int new_mm(unsigned long stack)
 {
        int fd;
 
        fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
-       if(fd < 0)
-               return(fd);
+       if (fd < 0)
+               return fd;
 
-       if(skas_needs_stub)
-               map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);
+       if (skas_needs_stub)
+               map_stub_pages(fd, STUB_CODE, STUB_DATA, stack);
 
-       return(fd);
-}
-
-void init_idle_skas(void)
-{
-       cpu_tasks[current_thread->cpu].pid = os_getpid();
-       default_idle();
+       return fd;
 }
 
 extern void start_kernel(void);
@@ -158,67 +38,32 @@ static int __init start_kernel_proc(void *unused)
        cpu_online_map = cpumask_of_cpu(0);
 #endif
        start_kernel();
-       return(0);
+       return 0;
 }
 
 extern int userspace_pid[];
 
 extern char cpu0_irqstack[];
 
-int __init start_uml_skas(void)
+int __init start_uml(void)
 {
        stack_protections((unsigned long) &cpu0_irqstack);
        set_sigstack(cpu0_irqstack, THREAD_SIZE);
-       if(proc_mm)
+       if (proc_mm)
                userspace_pid[0] = start_userspace(0);
 
        init_new_thread_signals();
 
        init_task.thread.request.u.thread.proc = start_kernel_proc;
        init_task.thread.request.u.thread.arg = NULL;
-       return(start_idle_thread(task_stack_page(&init_task),
-                                &init_task.thread.mode.skas.switch_buf));
-}
-
-int external_pid_skas(struct task_struct *task)
-{
-       /* FIXME: Need to look up userspace_pid by cpu */
-       return(userspace_pid[0]);
-}
-
-int thread_pid_skas(struct task_struct *task)
-{
-       /* FIXME: Need to look up userspace_pid by cpu */
-       return(userspace_pid[0]);
-}
-
-void kill_off_processes_skas(void)
-{
-       if(proc_mm)
-               /*
-                * FIXME: need to loop over userspace_pids in
-                * kill_off_processes_skas
-                */
-               os_kill_ptraced_process(userspace_pid[0], 1);
-       else {
-               struct task_struct *p;
-               int pid, me;
-
-               me = os_getpid();
-               for_each_process(p){
-                       if(p->mm == NULL)
-                               continue;
-
-                       pid = p->mm->context.skas.id.u.pid;
-                       os_kill_ptraced_process(pid, 1);
-               }
-       }
+       return start_idle_thread(task_stack_page(&init_task),
+                                &init_task.thread.switch_buf);
 }
 
 unsigned long current_stub_stack(void)
 {
-       if(current->mm == NULL)
-               return(0);
+       if (current->mm == NULL)
+               return 0;
 
-       return(current->mm->context.skas.id.stack);
+       return current->mm->context.id.stack;
 }
index 0ae4eea..50b476f 100644 (file)
@@ -1,19 +1,15 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sys.h"
+#include "linux/kernel.h"
 #include "linux/ptrace.h"
-#include "asm/errno.h"
-#include "asm/unistd.h"
-#include "asm/ptrace.h"
-#include "asm/current.h"
-#include "sysdep/syscalls.h"
 #include "kern_util.h"
-#include "syscall.h"
+#include "sysdep/ptrace.h"
+#include "sysdep/syscalls.h"
 
-void handle_syscall(union uml_pt_regs *r)
+void handle_syscall(struct uml_pt_regs *r)
 {
        struct pt_regs *regs = container_of(r, struct pt_regs, regs);
        long result;
@@ -24,7 +20,8 @@ void handle_syscall(union uml_pt_regs *r)
        current->thread.nsyscalls++;
        nsyscalls++;
 
-       /* This should go in the declaration of syscall, but when I do that,
+       /*
+        * This should go in the declaration of syscall, but when I do that,
         * strace -f -c bash -c 'ls ; ls' breaks, sometimes not tracing
         * children at all, sometimes hanging when bash doesn't see the first
         * ls exit.
@@ -33,11 +30,11 @@ void handle_syscall(union uml_pt_regs *r)
         * in case it's a compiler bug.
         */
        syscall = UPT_SYSCALL_NR(r);
-       if((syscall >= NR_syscalls) || (syscall < 0))
+       if ((syscall >= NR_syscalls) || (syscall < 0))
                result = -ENOSYS;
        else result = EXECUTE_SYSCALL(syscall, regs);
 
-       REGS_SET_SYSCALL_RETURN(r->skas.regs, result);
+       REGS_SET_SYSCALL_RETURN(r->gp, result);
 
        syscall_trace(r, 1);
 }
diff --git a/arch/um/kernel/skas/tlb.c b/arch/um/kernel/skas/tlb.c
deleted file mode 100644 (file)
index c0f0693..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Copyright 2003 PathScale, Inc.
- * Licensed under the GPL
- */
-
-#include "linux/stddef.h"
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "asm/page.h"
-#include "asm/pgtable.h"
-#include "asm/mmu.h"
-#include "mem_user.h"
-#include "mem.h"
-#include "skas.h"
-#include "os.h"
-#include "tlb.h"
-
-static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
-                 int finished, void **flush)
-{
-       struct host_vm_op *op;
-        int i, ret = 0;
-
-        for(i = 0; i <= last && !ret; i++){
-               op = &ops[i];
-               switch(op->type){
-               case MMAP:
-                       ret = map(&mmu->skas.id, op->u.mmap.addr,
-                                 op->u.mmap.len, op->u.mmap.prot,
-                                 op->u.mmap.fd, op->u.mmap.offset, finished,
-                                 flush);
-                       break;
-               case MUNMAP:
-                       ret = unmap(&mmu->skas.id, op->u.munmap.addr,
-                                   op->u.munmap.len, finished, flush);
-                       break;
-               case MPROTECT:
-                       ret = protect(&mmu->skas.id, op->u.mprotect.addr,
-                                     op->u.mprotect.len, op->u.mprotect.prot,
-                                     finished, flush);
-                       break;
-               default:
-                       printk("Unknown op type %d in do_ops\n", op->type);
-                       break;
-               }
-       }
-
-       return ret;
-}
-
-extern int proc_mm;
-
-static void fix_range(struct mm_struct *mm, unsigned long start_addr,
-                     unsigned long end_addr, int force)
-{
-        if(!proc_mm && (end_addr > CONFIG_STUB_START))
-                end_addr = CONFIG_STUB_START;
-
-        fix_range_common(mm, start_addr, end_addr, force, do_ops);
-}
-
-void __flush_tlb_one_skas(unsigned long addr)
-{
-        flush_tlb_kernel_range_common(addr, addr + PAGE_SIZE);
-}
-
-void flush_tlb_range_skas(struct vm_area_struct *vma, unsigned long start, 
-                    unsigned long end)
-{
-        if(vma->vm_mm == NULL)
-                flush_tlb_kernel_range_common(start, end);
-        else fix_range(vma->vm_mm, start, end, 0);
-}
-
-void flush_tlb_mm_skas(struct mm_struct *mm)
-{
-       unsigned long end;
-
-       /* Don't bother flushing if this address space is about to be
-         * destroyed.
-         */
-        if(atomic_read(&mm->mm_users) == 0)
-                return;
-
-       end = proc_mm ? task_size : CONFIG_STUB_START;
-        fix_range(mm, 0, end, 0);
-}
-
-void force_flush_all_skas(void)
-{
-       struct mm_struct *mm = current->mm;
-       struct vm_area_struct *vma = mm->mmap;
-
-       while(vma != NULL) {
-               fix_range(mm, vma->vm_start, vma->vm_end, 1);
-               vma = vma->vm_next;
-       }
-}
-
-void flush_tlb_page_skas(struct vm_area_struct *vma, unsigned long address)
-{
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
-       struct mm_struct *mm = vma->vm_mm;
-       void *flush = NULL;
-       int r, w, x, prot, err = 0;
-       struct mm_id *mm_id;
-
-       pgd = pgd_offset(mm, address);
-       if(!pgd_present(*pgd))
-               goto kill;
-
-       pud = pud_offset(pgd, address);
-       if(!pud_present(*pud))
-               goto kill;
-
-       pmd = pmd_offset(pud, address);
-       if(!pmd_present(*pmd))
-               goto kill;
-
-       pte = pte_offset_kernel(pmd, address);
-
-       r = pte_read(*pte);
-       w = pte_write(*pte);
-       x = pte_exec(*pte);
-       if (!pte_young(*pte)) {
-               r = 0;
-               w = 0;
-       } else if (!pte_dirty(*pte)) {
-               w = 0;
-       }
-
-       mm_id = &mm->context.skas.id;
-       prot = ((r ? UM_PROT_READ : 0) | (w ? UM_PROT_WRITE : 0) |
-               (x ? UM_PROT_EXEC : 0));
-       if(pte_newpage(*pte)){
-               if(pte_present(*pte)){
-                       unsigned long long offset;
-                       int fd;
-
-                       fd = phys_mapping(pte_val(*pte) & PAGE_MASK, &offset);
-                       err = map(mm_id, address, PAGE_SIZE, prot, fd, offset,
-                                 1, &flush);
-               }
-               else err = unmap(mm_id, address, PAGE_SIZE, 1, &flush);
-       }
-       else if(pte_newprot(*pte))
-               err = protect(mm_id, address, PAGE_SIZE, prot, 1, &flush);
-
-       if(err)
-               goto kill;
-
-       *pte = pte_mkuptodate(*pte);
-
-       return;
-
-kill:
-       printk("Failed to flush page for address 0x%lx\n", address);
-       force_sig(SIGKILL, current);
-}
-
index 8912cec..1d8b119 100644 (file)
@@ -1,18 +1,14 @@
 /*
- * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/compiler.h"
-#include "linux/stddef.h"
-#include "linux/kernel.h"
-#include "linux/string.h"
-#include "linux/fs.h"
-#include "linux/hardirq.h"
+#include "linux/err.h"
 #include "linux/highmem.h"
+#include "linux/mm.h"
+#include "asm/current.h"
 #include "asm/page.h"
 #include "asm/pgtable.h"
-#include "asm/uaccess.h"
 #include "kern_util.h"
 #include "os.h"
 
@@ -27,16 +23,16 @@ static unsigned long maybe_map(unsigned long virt, int is_write)
        void *phys = um_virt_to_phys(current, virt, &pte);
        int dummy_code;
 
-       if(IS_ERR(phys) || (is_write && !pte_write(pte))){
+       if (IS_ERR(phys) || (is_write && !pte_write(pte))) {
                err = handle_page_fault(virt, 0, is_write, 1, &dummy_code);
-               if(err)
-                       return(-1UL);
+               if (err)
+                       return -1UL;
                phys = um_virt_to_phys(current, virt, NULL);
        }
-        if(IS_ERR(phys))
-                phys = (void *) -1;
+       if (IS_ERR(phys))
+               phys = (void *) -1;
 
-       return((unsigned long) phys);
+       return (unsigned long) phys;
 }
 
 static int do_op_one_page(unsigned long addr, int len, int is_write,
@@ -46,17 +42,18 @@ static int do_op_one_page(unsigned long addr, int len, int is_write,
        int n;
 
        addr = maybe_map(addr, is_write);
-       if(addr == -1UL)
-               return(-1);
+       if (addr == -1UL)
+               return -1;
 
        page = phys_to_page(addr);
-       addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) + (addr & ~PAGE_MASK);
+       addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) +
+               (addr & ~PAGE_MASK);
 
        n = (*op)(addr, len, arg);
 
        kunmap_atomic(page, KM_UML_USERCOPY);
 
-       return(n);
+       return n;
 }
 
 static void do_buffer_op(void *jmpbuf, void *arg_ptr)
@@ -81,21 +78,21 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr)
 
        current->thread.fault_catcher = jmpbuf;
        n = do_op_one_page(addr, size, is_write, op, arg);
-       if(n != 0){
+       if (n != 0) {
                *res = (n < 0 ? remain : 0);
                goto out;
        }
 
        addr += size;
        remain -= size;
-       if(remain == 0){
+       if (remain == 0) {
                *res = 0;
                goto out;
        }
 
-       while(addr < ((addr + remain) & PAGE_MASK)){
+       while(addr < ((addr + remain) & PAGE_MASK)) {
                n = do_op_one_page(addr, PAGE_SIZE, is_write, op, arg);
-               if(n != 0){
+               if (n != 0) {
                        *res = (n < 0 ? remain : 0);
                        goto out;
                }
@@ -103,13 +100,13 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr)
                addr += PAGE_SIZE;
                remain -= PAGE_SIZE;
        }
-       if(remain == 0){
+       if (remain == 0) {
                *res = 0;
                goto out;
        }
 
        n = do_op_one_page(addr, remain, is_write, op, arg);
-       if(n != 0)
+       if (n != 0)
                *res = (n < 0 ? remain : 0);
        else *res = 0;
  out:
@@ -124,10 +121,10 @@ static int buffer_op(unsigned long addr, int len, int is_write,
 
        faulted = setjmp_wrapper(do_buffer_op, addr, len, is_write, op, arg,
                                 &res);
-       if(!faulted)
-               return(res);
+       if (!faulted)
+               return res;
 
-       return(addr + len - (unsigned long) current->thread.fault_addr);
+       return addr + len - (unsigned long) current->thread.fault_addr;
 }
 
 static int copy_chunk_from_user(unsigned long from, int len, void *arg)
@@ -136,19 +133,19 @@ static int copy_chunk_from_user(unsigned long from, int len, void *arg)
 
        memcpy((void *) to, (void *) from, len);
        *to_ptr += len;
-       return(0);
+       return 0;
 }
 
-int copy_from_user_skas(void *to, const void __user *from, int n)
+int copy_from_user(void *to, const void __user *from, int n)
 {
-       if(segment_eq(get_fs(), KERNEL_DS)){
+       if (segment_eq(get_fs(), KERNEL_DS)) {
                memcpy(to, (__force void*)from, n);
-               return(0);
+               return 0;
        }
 
-       return(access_ok(VERIFY_READ, from, n) ?
+       return access_ok(VERIFY_READ, from, n) ?
               buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
-              n);
+              n;
 }
 
 static int copy_chunk_to_user(unsigned long to, int len, void *arg)
@@ -157,19 +154,19 @@ static int copy_chunk_to_user(unsigned long to, int len, void *arg)
 
        memcpy((void *) to, (void *) from, len);
        *from_ptr += len;
-       return(0);
+       return 0;
 }
 
-int copy_to_user_skas(void __user *to, const void *from, int n)
+int copy_to_user(void __user *to, const void *from, int n)
 {
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               memcpy((__force void*)to, from, n);
-               return(0);
+       if (segment_eq(get_fs(), KERNEL_DS)) {
+               memcpy((__force void *) to, from, n);
+               return 0;
        }
 
-       return(access_ok(VERIFY_WRITE, to, n) ?
+       return access_ok(VERIFY_WRITE, to, n) ?
               buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
-              n);
+              n;
 }
 
 static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
@@ -181,51 +178,51 @@ static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
        n = strnlen(to, len);
        *to_ptr += n;
 
-       if(n < len)
-               return(1);
-       return(0);
+       if (n < len)
+               return 1;
+       return 0;
 }
 
-int strncpy_from_user_skas(char *dst, const char __user *src, int count)
+int strncpy_from_user(char *dst, const char __user *src, int count)
 {
        int n;
        char *ptr = dst;
 
-       if(segment_eq(get_fs(), KERNEL_DS)){
-               strncpy(dst, (__force void*)src, count);
-               return(strnlen(dst, count));
+       if (segment_eq(get_fs(), KERNEL_DS)) {
+               strncpy(dst, (__force void *) src, count);
+               return strnlen(dst, count);
        }
 
-       if(!access_ok(VERIFY_READ, src, 1))
-               return(-EFAULT);
+       if (!access_ok(VERIFY_READ, src, 1))
+               return -EFAULT;
 
        n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
                      &ptr);
-       if(n != 0)
-               return(-EFAULT);
-       return(strnlen(dst, count));
+       if (n != 0)
+               return -EFAULT;
+       return strnlen(dst, count);
 }
 
 static int clear_chunk(unsigned long addr, int len, void *unused)
 {
        memset((void *) addr, 0, len);
-       return(0);
+       return 0;
 }
 
-int __clear_user_skas(void __user *mem, int len)
+int __clear_user(void __user *mem, int len)
 {
-       return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL));
+       return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
 }
 
-int clear_user_skas(void __user *mem, int len)
+int clear_user(void __user *mem, int len)
 {
-       if(segment_eq(get_fs(), KERNEL_DS)){
+       if (segment_eq(get_fs(), KERNEL_DS)) {
                memset((__force void*)mem, 0, len);
-               return(0);
+               return 0;
        }
 
-       return(access_ok(VERIFY_WRITE, mem, len) ?
-              buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len);
+       return access_ok(VERIFY_WRITE, mem, len) ?
+              buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len;
 }
 
 static int strnlen_chunk(unsigned long str, int len, void *arg)
@@ -235,31 +232,20 @@ static int strnlen_chunk(unsigned long str, int len, void *arg)
        n = strnlen((void *) str, len);
        *len_ptr += n;
 
-       if(n < len)
-               return(1);
-       return(0);
+       if (n < len)
+               return 1;
+       return 0;
 }
 
-int strnlen_user_skas(const void __user *str, int len)
+int strnlen_user(const void __user *str, int len)
 {
        int count = 0, n;
 
-       if(segment_eq(get_fs(), KERNEL_DS))
-               return(strnlen((__force char*)str, len) + 1);
+       if (segment_eq(get_fs(), KERNEL_DS))
+               return strnlen((__force char*)str, len) + 1;
 
        n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
-       if(n == 0)
-               return(count + 1);
-       return(-EFAULT);
+       if (n == 0)
+               return count + 1;
+       return -EFAULT;
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index e6a7778..36d89cf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -56,12 +56,12 @@ void smp_send_stop(void)
        int i;
 
        printk(KERN_INFO "Stopping all CPUs...");
-       for(i = 0; i < num_online_cpus(); i++){
-               if(i == current_thread->cpu)
+       for (i = 0; i < num_online_cpus(); i++) {
+               if (i == current_thread->cpu)
                        continue;
                os_write_file(cpu_data[i].ipi_pipe[1], "S", 1);
        }
-       printk("done\n");
+       printk(KERN_INFO "done\n");
 }
 
 static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
@@ -72,7 +72,7 @@ static int idle_proc(void *cpup)
        int cpu = (int) cpup, err;
 
        err = os_pipe(cpu_data[cpu].ipi_pipe, 1, 1);
-       if(err < 0)
+       if (err < 0)
                panic("CPU#%d failed to create IPI pipe, err = %d", cpu, -err);
 
        os_set_fd_async(cpu_data[cpu].ipi_pipe[0],
@@ -80,7 +80,7 @@ static int idle_proc(void *cpup)
 
        wmb();
        if (cpu_test_and_set(cpu, cpu_callin_map)) {
-               printk("huh, CPU#%d already present??\n", cpu);
+               printk(KERN_ERR "huh, CPU#%d already present??\n", cpu);
                BUG();
        }
 
@@ -95,12 +95,11 @@ static int idle_proc(void *cpup)
 static struct task_struct *idle_thread(int cpu)
 {
        struct task_struct *new_task;
-       unsigned char c;
 
        current->thread.request.u.thread.proc = idle_proc;
        current->thread.request.u.thread.arg = (void *) cpu;
        new_task = fork_idle(cpu);
-       if(IS_ERR(new_task))
+       if (IS_ERR(new_task))
                panic("copy_process failed in idle_thread, error = %ld",
                      PTR_ERR(new_task));
 
@@ -108,9 +107,7 @@ static struct task_struct *idle_thread(int cpu)
                          { .pid =      new_task->thread.mode.tt.extern_pid,
                            .task =     new_task } );
        idle_threads[cpu] = new_task;
-       CHOOSE_MODE(os_write_file(new_task->thread.mode.tt.switch_pipe[1], &c,
-                                 sizeof(c)),
-                   ({ panic("skas mode doesn't support SMP"); }));
+       panic("skas mode doesn't support SMP");
        return new_task;
 }
 
@@ -129,14 +126,14 @@ void smp_prepare_cpus(unsigned int maxcpus)
        cpu_set(me, cpu_callin_map);
 
        err = os_pipe(cpu_data[me].ipi_pipe, 1, 1);
-       if(err < 0)
+       if (err < 0)
                panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
 
        os_set_fd_async(cpu_data[me].ipi_pipe[0],
                     current->thread.mode.tt.extern_pid);
 
-       for(cpu = 1; cpu < ncpus; cpu++){
-               printk("Booting processor %d...\n", cpu);
+       for (cpu = 1; cpu < ncpus; cpu++) {
+               printk(KERN_INFO "Booting processor %d...\n", cpu);
 
                idle = idle_thread(cpu);
 
@@ -147,8 +144,8 @@ void smp_prepare_cpus(unsigned int maxcpus)
                        cpu_relax();
 
                if (cpu_isset(cpu, cpu_callin_map))
-                       printk("done\n");
-               else printk("failed\n");
+                       printk(KERN_INFO "done\n");
+               else printk(KERN_INFO "failed\n");
        }
 }
 
@@ -190,13 +187,14 @@ void IPI_handler(int cpu)
                        break;
 
                case 'S':
-                       printk("CPU#%d stopping\n", cpu);
-                       while(1)
+                       printk(KERN_INFO "CPU#%d stopping\n", cpu);
+                       while (1)
                                pause();
                        break;
 
                default:
-                       printk("CPU#%d received unknown IPI [%c]!\n", cpu, c);
+                       printk(KERN_ERR "CPU#%d received unknown IPI [%c]!\n",
+                              cpu, c);
                        break;
                }
        }
index 7b3b673..b9d92b2 100644 (file)
@@ -1,27 +1,17 @@
 /*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
 #include "linux/file.h"
-#include "linux/smp_lock.h"
-#include "linux/mm.h"
 #include "linux/fs.h"
+#include "linux/mm.h"
+#include "linux/sched.h"
 #include "linux/utsname.h"
-#include "linux/msg.h"
-#include "linux/shm.h"
-#include "linux/sys.h"
-#include "linux/syscalls.h"
-#include "linux/unistd.h"
-#include "linux/slab.h"
-#include "linux/utime.h"
+#include "asm/current.h"
 #include "asm/mman.h"
 #include "asm/uaccess.h"
-#include "kern_util.h"
-#include "sysdep/syscalls.h"
-#include "mode_kern.h"
-#include "choose-mode.h"
+#include "asm/unistd.h"
 
 /*  Unlocked, I don't care if this is a bit off */
 int nsyscalls = 0;
@@ -34,7 +24,7 @@ long sys_fork(void)
        ret = do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs),
                      &current->thread.regs, 0, NULL, NULL);
        current->thread.forking = 0;
-       return(ret);
+       return ret;
 }
 
 long sys_vfork(void)
@@ -46,7 +36,7 @@ long sys_vfork(void)
                      UPT_SP(&current->thread.regs.regs),
                      &current->thread.regs, 0, NULL, NULL);
        current->thread.forking = 0;
-       return(ret);
+       return ret;
 }
 
 /* common code for old and new mmaps */
@@ -92,15 +82,15 @@ long old_mmap(unsigned long addr, unsigned long len,
  */
 long sys_pipe(unsigned long __user * fildes)
 {
-        int fd[2];
-        long error;
+       int fd[2];
+       long error;
 
-        error = do_pipe(fd);
-        if (!error) {
+       error = do_pipe(fd);
+       if (!error) {
                if (copy_to_user(fildes, fd, sizeof(fd)))
-                        error = -EFAULT;
-        }
-        return error;
+                       error = -EFAULT;
+       }
+       return error;
 }
 
 
@@ -124,7 +114,7 @@ long sys_olduname(struct oldold_utsname __user * name)
        if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
                return -EFAULT;
 
-       down_read(&uts_sem);
+       down_read(&uts_sem);
 
        error = __copy_to_user(&name->sysname, &utsname()->sysname,
                               __OLD_UTS_LEN);
index 259c49d..1ac746a 100644 (file)
 /*
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "linux/module.h"
-#include "linux/unistd.h"
-#include "linux/stddef.h"
-#include "linux/spinlock.h"
-#include "linux/time.h"
-#include "linux/sched.h"
+#include "linux/clockchips.h"
 #include "linux/interrupt.h"
-#include "linux/init.h"
-#include "linux/delay.h"
-#include "linux/hrtimer.h"
+#include "linux/jiffies.h"
+#include "linux/threads.h"
 #include "asm/irq.h"
 #include "asm/param.h"
-#include "asm/current.h"
 #include "kern_util.h"
-#include "mode.h"
 #include "os.h"
 
-int hz(void)
-{
-       return(HZ);
-}
-
 /*
  * Scheduler clock - returns current time in nanosec units.
  */
 unsigned long long sched_clock(void)
 {
-       return (unsigned long long)jiffies_64 * (1000000000 / HZ);
+       return (unsigned long long)jiffies_64 * (NSEC_PER_SEC / HZ);
 }
 
-#ifdef CONFIG_UML_REAL_TIME_CLOCK
-static unsigned long long prev_nsecs[NR_CPUS];
-static long long delta[NR_CPUS];               /* Deviation per interval */
-#endif
+void timer_handler(int sig, struct uml_pt_regs *regs)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       do_IRQ(TIMER_IRQ, regs);
+       local_irq_restore(flags);
+}
 
-void timer_irq(union uml_pt_regs *regs)
+static void itimer_set_mode(enum clock_event_mode mode,
+                           struct clock_event_device *evt)
 {
-       unsigned long long ticks = 0;
-#ifdef CONFIG_UML_REAL_TIME_CLOCK
-       int c = cpu();
-       if(prev_nsecs[c]){
-               /* We've had 1 tick */
-               unsigned long long nsecs = os_nsecs();
-
-               delta[c] += nsecs - prev_nsecs[c];
-               prev_nsecs[c] = nsecs;
-
-               /* Protect against the host clock being set backwards */
-               if(delta[c] < 0)
-                       delta[c] = 0;
-
-               ticks += (delta[c] * HZ) / BILLION;
-               delta[c] -= (ticks * BILLION) / HZ;
-       }
-       else prev_nsecs[c] = os_nsecs();
-#else
-       ticks = 1;
-#endif
-       while(ticks > 0){
-               do_IRQ(TIMER_IRQ, regs);
-               ticks--;
+       switch(mode) {
+       case CLOCK_EVT_MODE_PERIODIC:
+               set_interval();
+               break;
+
+       case CLOCK_EVT_MODE_SHUTDOWN:
+       case CLOCK_EVT_MODE_UNUSED:
+       case CLOCK_EVT_MODE_ONESHOT:
+               disable_timer();
+               break;
+
+       case CLOCK_EVT_MODE_RESUME:
+               break;
        }
 }
 
-/* Protects local_offset */
-static DEFINE_SPINLOCK(timer_spinlock);
-static unsigned long long local_offset = 0;
-
-static inline unsigned long long get_time(void)
+static int itimer_next_event(unsigned long delta,
+                            struct clock_event_device *evt)
 {
-       unsigned long long nsecs;
-       unsigned long flags;
-
-       spin_lock_irqsave(&timer_spinlock, flags);
-       nsecs = os_nsecs();
-       nsecs += local_offset;
-       spin_unlock_irqrestore(&timer_spinlock, flags);
-
-       return nsecs;
+       return timer_one_shot(delta + 1);
 }
 
-irqreturn_t um_timer(int irq, void *dev)
+static struct clock_event_device itimer_clockevent = {
+       .name           = "itimer",
+       .rating         = 250,
+       .cpumask        = CPU_MASK_ALL,
+       .features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+       .set_mode       = itimer_set_mode,
+       .set_next_event = itimer_next_event,
+       .shift          = 32,
+       .irq            = 0,
+};
+
+static irqreturn_t um_timer(int irq, void *dev)
 {
-       unsigned long long nsecs;
-       unsigned long flags;
-
-       write_seqlock_irqsave(&xtime_lock, flags);
-
-       do_timer(1);
-
-#ifdef CONFIG_UML_REAL_TIME_CLOCK
-       nsecs = get_time();
-#else
-       nsecs = (unsigned long long) xtime.tv_sec * BILLION + xtime.tv_nsec +
-               BILLION / HZ;
-#endif
-       xtime.tv_sec = nsecs / NSEC_PER_SEC;
-       xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
-
-       write_sequnlock_irqrestore(&xtime_lock, flags);
+       (*itimer_clockevent.event_handler)(&itimer_clockevent);
 
        return IRQ_HANDLED;
 }
 
-static void register_timer(void)
+static cycle_t itimer_read(void)
+{
+       return os_nsecs();
+}
+
+static struct clocksource itimer_clocksource = {
+       .name           = "itimer",
+       .rating         = 300,
+       .read           = itimer_read,
+       .mask           = CLOCKSOURCE_MASK(64),
+       .mult           = 1,
+       .shift          = 0,
+       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+static void __init setup_itimer(void)
 {
        int err;
 
        err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL);
-       if(err != 0)
+       if (err != 0)
                printk(KERN_ERR "register_timer : request_irq failed - "
                       "errno = %d\n", -err);
 
-       err = set_interval(1);
-       if(err != 0)
-               printk(KERN_ERR "register_timer : set_interval failed - "
-                      "errno = %d\n", -err);
+       itimer_clockevent.mult = div_sc(HZ, NSEC_PER_SEC, 32);
+       itimer_clockevent.max_delta_ns =
+               clockevent_delta2ns(60 * HZ, &itimer_clockevent);
+       itimer_clockevent.min_delta_ns =
+               clockevent_delta2ns(1, &itimer_clockevent);
+       err = clocksource_register(&itimer_clocksource);
+       if (err) {
+               printk(KERN_ERR "clocksource_register returned %d\n", err);
+               return;
+       }
+       clockevents_register_device(&itimer_clockevent);
 }
 
 extern void (*late_time_init)(void);
 
-void time_init(void)
+void __init time_init(void)
 {
        long long nsecs;
 
-       nsecs = os_nsecs();
-       set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION,
-                               -nsecs % BILLION);
-       set_normalized_timespec(&xtime, nsecs / BILLION, nsecs % BILLION);
-       late_time_init = register_timer;
-}
-
-void do_gettimeofday(struct timeval *tv)
-{
-#ifdef CONFIG_UML_REAL_TIME_CLOCK
-       unsigned long long nsecs = get_time();
-#else
-       unsigned long long nsecs = (unsigned long long) xtime.tv_sec * BILLION +
-               xtime.tv_nsec;
-#endif
-       tv->tv_sec = nsecs / NSEC_PER_SEC;
-       /* Careful about calculations here - this was originally done as
-        * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC
-        * which gave bogus (> 1000000) values.  Dunno why, suspect gcc
-        * (4.0.0) miscompiled it, or there's a subtle 64/32-bit conversion
-        * problem that I missed.
-        */
-       nsecs -= tv->tv_sec * NSEC_PER_SEC;
-       tv->tv_usec = (unsigned long) nsecs / NSEC_PER_USEC;
-}
-
-static inline void set_time(unsigned long long nsecs)
-{
-       unsigned long long now;
-       unsigned long flags;
-
-       spin_lock_irqsave(&timer_spinlock, flags);
-       now = os_nsecs();
-       local_offset = nsecs - now;
-       spin_unlock_irqrestore(&timer_spinlock, flags);
-
-       clock_was_set();
-}
-
-int do_settimeofday(struct timespec *tv)
-{
-       set_time((unsigned long long) tv->tv_sec * NSEC_PER_SEC + tv->tv_nsec);
-
-       return 0;
-}
+       timer_init();
 
-void timer_handler(int sig, union uml_pt_regs *regs)
-{
-       if(current_thread->cpu == 0)
-               timer_irq(regs);
-       local_irq_disable();
-       irq_enter();
-       update_process_times(CHOOSE_MODE(
-                            (UPT_SC(regs) && user_context(UPT_SP(regs))),
-                            (regs)->skas.is_user));
-       irq_exit();
-       local_irq_enable();
+       nsecs = os_nsecs();
+       set_normalized_timespec(&wall_to_monotonic, -nsecs / NSEC_PER_SEC,
+                               -nsecs % NSEC_PER_SEC);
+       set_normalized_timespec(&xtime, nsecs / NSEC_PER_SEC,
+                               nsecs % NSEC_PER_SEC);
+       late_time_init = setup_itimer;
 }
index 8a8d528..f4a0e40 100644 (file)
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include "linux/mm.h"
-#include "asm/page.h"
-#include "asm/pgalloc.h"
 #include "asm/pgtable.h"
 #include "asm/tlbflush.h"
-#include "choose-mode.h"
-#include "mode_kern.h"
 #include "as-layout.h"
-#include "tlb.h"
-#include "mem.h"
 #include "mem_user.h"
 #include "os.h"
+#include "skas.h"
+#include "tlb.h"
+
+struct host_vm_change {
+       struct host_vm_op {
+               enum { NONE, MMAP, MUNMAP, MPROTECT } type;
+               union {
+                       struct {
+                               unsigned long addr;
+                               unsigned long len;
+                               unsigned int prot;
+                               int fd;
+                               __u64 offset;
+                       } mmap;
+                       struct {
+                               unsigned long addr;
+                               unsigned long len;
+                       } munmap;
+                       struct {
+                               unsigned long addr;
+                               unsigned long len;
+                               unsigned int prot;
+                       } mprotect;
+               } u;
+       } ops[1];
+       int index;
+       struct mm_id *id;
+       void *data;
+       int force;
+};
+
+#define INIT_HVC(mm, force) \
+       ((struct host_vm_change) \
+        { .ops         = { { .type = NONE } }, \
+          .id          = &mm->context.id, \
+                  .data        = NULL, \
+          .index       = 0, \
+          .force       = force })
+
+static int do_ops(struct host_vm_change *hvc, int end,
+                 int finished)
+{
+       struct host_vm_op *op;
+       int i, ret = 0;
+
+       for (i = 0; i < end && !ret; i++) {
+               op = &hvc->ops[i];
+               switch(op->type) {
+               case MMAP:
+                       ret = map(hvc->id, op->u.mmap.addr, op->u.mmap.len,
+                                 op->u.mmap.prot, op->u.mmap.fd,
+                                 op->u.mmap.offset, finished, &hvc->data);
+                       break;
+               case MUNMAP:
+                       ret = unmap(hvc->id, op->u.munmap.addr,
+                                   op->u.munmap.len, finished, &hvc->data);
+                       break;
+               case MPROTECT:
+                       ret = protect(hvc->id, op->u.mprotect.addr,
+                                     op->u.mprotect.len, op->u.mprotect.prot,
+                                     finished, &hvc->data);
+                       break;
+               default:
+                       printk(KERN_ERR "Unknown op type %d in do_ops\n",
+                              op->type);
+                       break;
+               }
+       }
+
+       return ret;
+}
 
 static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
-                   unsigned int prot, struct host_vm_op *ops, int *index,
-                   int last_filled, union mm_context *mmu, void **flush,
-                   int (*do_ops)(union mm_context *, struct host_vm_op *,
-                                 int, int, void **))
+                   unsigned int prot, struct host_vm_change *hvc)
 {
        __u64 offset;
        struct host_vm_op *last;
        int fd, ret = 0;
 
        fd = phys_mapping(phys, &offset);
-       if(*index != -1){
-               last = &ops[*index];
-               if((last->type == MMAP) &&
+       if (hvc->index != 0) {
+               last = &hvc->ops[hvc->index - 1];
+               if ((last->type == MMAP) &&
                   (last->u.mmap.addr + last->u.mmap.len == virt) &&
                   (last->u.mmap.prot == prot) && (last->u.mmap.fd == fd) &&
-                  (last->u.mmap.offset + last->u.mmap.len == offset)){
+                  (last->u.mmap.offset + last->u.mmap.len == offset)) {
                        last->u.mmap.len += len;
                        return 0;
                }
        }
 
-       if(*index == last_filled){
-               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
-               *index = -1;
+       if (hvc->index == ARRAY_SIZE(hvc->ops)) {
+               ret = do_ops(hvc, ARRAY_SIZE(hvc->ops), 0);
+               hvc->index = 0;
        }
 
-       ops[++*index] = ((struct host_vm_op) { .type    = MMAP,
-                                               .u = { .mmap = {
-                                                      .addr    = virt,
-                                                      .len     = len,
-                                                      .prot    = prot,
-                                                      .fd      = fd,
-                                                      .offset  = offset }
+       hvc->ops[hvc->index++] = ((struct host_vm_op)
+                                 { .type       = MMAP,
+                                   .u = { .mmap = { .addr      = virt,
+                                                    .len       = len,
+                                                    .prot      = prot,
+                                                    .fd        = fd,
+                                                    .offset    = offset }
                           } });
        return ret;
 }
 
 static int add_munmap(unsigned long addr, unsigned long len,
-                     struct host_vm_op *ops, int *index, int last_filled,
-                     union mm_context *mmu, void **flush,
-                     int (*do_ops)(union mm_context *, struct host_vm_op *,
-                                   int, int, void **))
+                     struct host_vm_change *hvc)
 {
        struct host_vm_op *last;
        int ret = 0;
 
-       if(*index != -1){
-               last = &ops[*index];
-               if((last->type == MUNMAP) &&
-                  (last->u.munmap.addr + last->u.mmap.len == addr)){
+       if (hvc->index != 0) {
+               last = &hvc->ops[hvc->index - 1];
+               if ((last->type == MUNMAP) &&
+                  (last->u.munmap.addr + last->u.mmap.len == addr)) {
                        last->u.munmap.len += len;
                        return 0;
                }
        }
 
-       if(*index == last_filled){
-               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
-               *index = -1;
+       if (hvc->index == ARRAY_SIZE(hvc->ops)) {
+               ret = do_ops(hvc, ARRAY_SIZE(hvc->ops), 0);
+               hvc->index = 0;
        }
 
-       ops[++*index] = ((struct host_vm_op) { .type    = MUNMAP,
-                                              .u = { .munmap = {
-                                                       .addr   = addr,
-                                                       .len    = len } } });
+       hvc->ops[hvc->index++] = ((struct host_vm_op)
+                                 { .type       = MUNMAP,
+                                   .u = { .munmap = { .addr    = addr,
+                                                      .len     = len } } });
        return ret;
 }
 
 static int add_mprotect(unsigned long addr, unsigned long len,
-                       unsigned int prot, struct host_vm_op *ops, int *index,
-                       int last_filled, union mm_context *mmu, void **flush,
-                       int (*do_ops)(union mm_context *, struct host_vm_op *,
-                                     int, int, void **))
+                       unsigned int prot, struct host_vm_change *hvc)
 {
        struct host_vm_op *last;
        int ret = 0;
 
-       if(*index != -1){
-               last = &ops[*index];
-               if((last->type == MPROTECT) &&
+       if (hvc->index != 0) {
+               last = &hvc->ops[hvc->index - 1];
+               if ((last->type == MPROTECT) &&
                   (last->u.mprotect.addr + last->u.mprotect.len == addr) &&
-                  (last->u.mprotect.prot == prot)){
+                  (last->u.mprotect.prot == prot)) {
                        last->u.mprotect.len += len;
                        return 0;
                }
        }
 
-       if(*index == last_filled){
-               ret = (*do_ops)(mmu, ops, last_filled, 0, flush);
-               *index = -1;
+       if (hvc->index == ARRAY_SIZE(hvc->ops)) {
+               ret = do_ops(hvc, ARRAY_SIZE(hvc->ops), 0);
+               hvc->index = 0;
        }
 
-       ops[++*index] = ((struct host_vm_op) { .type    = MPROTECT,
-                                              .u = { .mprotect = {
-                                                      .addr    = addr,
-                                                      .len     = len,
-                                                      .prot    = prot } } });
+       hvc->ops[hvc->index++] = ((struct host_vm_op)
+                                 { .type       = MPROTECT,
+                                   .u = { .mprotect = { .addr  = addr,
+                                                        .len   = len,
+                                                        .prot  = prot } } });
        return ret;
 }
 
 #define ADD_ROUND(n, inc) (((n) + (inc)) & ~((inc) - 1))
 
 static inline int update_pte_range(pmd_t *pmd, unsigned long addr,
-                                  unsigned long end, struct host_vm_op *ops,
-                                  int last_op, int *op_index, int force,
-                                  union mm_context *mmu, void **flush,
-                                  int (*do_ops)(union mm_context *,
-                                                struct host_vm_op *, int, int,
-                                                void **))
+                                  unsigned long end,
+                                  struct host_vm_change *hvc)
 {
        pte_t *pte;
        int r, w, x, prot, ret = 0;
@@ -142,29 +194,22 @@ static inline int update_pte_range(pmd_t *pmd, unsigned long addr,
                }
                prot = ((r ? UM_PROT_READ : 0) | (w ? UM_PROT_WRITE : 0) |
                        (x ? UM_PROT_EXEC : 0));
-               if(force || pte_newpage(*pte)){
-                       if(pte_present(*pte))
+               if (hvc->force || pte_newpage(*pte)) {
+                       if (pte_present(*pte))
                                ret = add_mmap(addr, pte_val(*pte) & PAGE_MASK,
-                                              PAGE_SIZE, prot, ops, op_index,
-                                              last_op, mmu, flush, do_ops);
-                       else ret = add_munmap(addr, PAGE_SIZE, ops, op_index,
-                                             last_op, mmu, flush, do_ops);
+                                              PAGE_SIZE, prot, hvc);
+                       else ret = add_munmap(addr, PAGE_SIZE, hvc);
                }
-               else if(pte_newprot(*pte))
-                       ret = add_mprotect(addr, PAGE_SIZE, prot, ops, op_index,
-                                          last_op, mmu, flush, do_ops);
+               else if (pte_newprot(*pte))
+                       ret = add_mprotect(addr, PAGE_SIZE, prot, hvc);
                *pte = pte_mkuptodate(*pte);
        } while (pte++, addr += PAGE_SIZE, ((addr != end) && !ret));
        return ret;
 }
 
 static inline int update_pmd_range(pud_t *pud, unsigned long addr,
-                                  unsigned long end, struct host_vm_op *ops,
-                                  int last_op, int *op_index, int force,
-                                  union mm_context *mmu, void **flush,
-                                  int (*do_ops)(union mm_context *,
-                                                struct host_vm_op *, int, int,
-                                                void **))
+                                  unsigned long end,
+                                  struct host_vm_change *hvc)
 {
        pmd_t *pmd;
        unsigned long next;
@@ -173,28 +218,20 @@ static inline int update_pmd_range(pud_t *pud, unsigned long addr,
        pmd = pmd_offset(pud, addr);
        do {
                next = pmd_addr_end(addr, end);
-               if(!pmd_present(*pmd)){
-                       if(force || pmd_newpage(*pmd)){
-                               ret = add_munmap(addr, next - addr, ops,
-                                                op_index, last_op, mmu,
-                                                flush, do_ops);
+               if (!pmd_present(*pmd)) {
+                       if (hvc->force || pmd_newpage(*pmd)) {
+                               ret = add_munmap(addr, next - addr, hvc);
                                pmd_mkuptodate(*pmd);
                        }
                }
-               else ret = update_pte_range(pmd, addr, next, ops, last_op,
-                                           op_index, force, mmu, flush,
-                                           do_ops);
+               else ret = update_pte_range(pmd, addr, next, hvc);
        } while (pmd++, addr = next, ((addr != end) && !ret));
        return ret;
 }
 
 static inline int update_pud_range(pgd_t *pgd, unsigned long addr,
-                                  unsigned long end, struct host_vm_op *ops,
-                                  int last_op, int *op_index, int force,
-                                  union mm_context *mmu, void **flush,
-                                  int (*do_ops)(union mm_context *,
-                                                struct host_vm_op *, int, int,
-                                                void **))
+                                  unsigned long end,
+                                  struct host_vm_change *hvc)
 {
        pud_t *pud;
        unsigned long next;
@@ -203,56 +240,45 @@ static inline int update_pud_range(pgd_t *pgd, unsigned long addr,
        pud = pud_offset(pgd, addr);
        do {
                next = pud_addr_end(addr, end);
-               if(!pud_present(*pud)){
-                       if(force || pud_newpage(*pud)){
-                               ret = add_munmap(addr, next - addr, ops,
-                                                op_index, last_op, mmu,
-                                                flush, do_ops);
+               if (!pud_present(*pud)) {
+                       if (hvc->force || pud_newpage(*pud)) {
+                               ret = add_munmap(addr, next - addr, hvc);
                                pud_mkuptodate(*pud);
                        }
                }
-               else ret = update_pmd_range(pud, addr, next, ops, last_op,
-                                           op_index, force, mmu, flush,
-                                           do_ops);
+               else ret = update_pmd_range(pud, addr, next, hvc);
        } while (pud++, addr = next, ((addr != end) && !ret));
        return ret;
 }
 
 void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
-                     unsigned long end_addr, int force,
-                     int (*do_ops)(union mm_context *, struct host_vm_op *,
-                                   int, int, void **))
+                     unsigned long end_addr, int force)
 {
        pgd_t *pgd;
-       union mm_context *mmu = &mm->context;
-       struct host_vm_op ops[1];
+       struct host_vm_change hvc;
        unsigned long addr = start_addr, next;
-       int ret = 0, last_op = ARRAY_SIZE(ops) - 1, op_index = -1;
-       void *flush = NULL;
+       int ret = 0;
 
-       ops[0].type = NONE;
+       hvc = INIT_HVC(mm, force);
        pgd = pgd_offset(mm, addr);
        do {
                next = pgd_addr_end(addr, end_addr);
-               if(!pgd_present(*pgd)){
-                       if (force || pgd_newpage(*pgd)){
-                               ret = add_munmap(addr, next - addr, ops,
-                                                &op_index, last_op, mmu,
-                                                &flush, do_ops);
+               if (!pgd_present(*pgd)) {
+                       if (force || pgd_newpage(*pgd)) {
+                               ret = add_munmap(addr, next - addr, &hvc);
                                pgd_mkuptodate(*pgd);
                        }
                }
-               else ret = update_pud_range(pgd, addr, next, ops, last_op,
-                                           &op_index, force, mmu, &flush,
-                                           do_ops);
+               else ret = update_pud_range(pgd, addr, next, &hvc);
        } while (pgd++, addr = next, ((addr != end_addr) && !ret));
 
-       if(!ret)
-               ret = (*do_ops)(mmu, ops, op_index, 1, &flush);
+       if (!ret)
+               ret = do_ops(&hvc, hvc.index, 1);
 
        /* This is not an else because ret is modified above */
-       if(ret) {
-               printk("fix_range_common: failed, killing current process\n");
+       if (ret) {
+               printk(KERN_ERR "fix_range_common: failed, killing current "
+                      "process\n");
                force_sig(SIGKILL, current);
        }
 }
@@ -268,17 +294,17 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
        int updated = 0, err;
 
        mm = &init_mm;
-       for(addr = start; addr < end;){
+       for (addr = start; addr < end;) {
                pgd = pgd_offset(mm, addr);
-               if(!pgd_present(*pgd)){
+               if (!pgd_present(*pgd)) {
                        last = ADD_ROUND(addr, PGDIR_SIZE);
-                       if(last > end)
+                       if (last > end)
                                last = end;
-                       if(pgd_newpage(*pgd)){
+                       if (pgd_newpage(*pgd)) {
                                updated = 1;
                                err = os_unmap_memory((void *) addr,
                                                      last - addr);
-                               if(err < 0)
+                               if (err < 0)
                                        panic("munmap failed, errno = %d\n",
                                              -err);
                        }
@@ -287,15 +313,15 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
                }
 
                pud = pud_offset(pgd, addr);
-               if(!pud_present(*pud)){
+               if (!pud_present(*pud)) {
                        last = ADD_ROUND(addr, PUD_SIZE);
-                       if(last > end)
+                       if (last > end)
                                last = end;
-                       if(pud_newpage(*pud)){
+                       if (pud_newpage(*pud)) {
                                updated = 1;
                                err = os_unmap_memory((void *) addr,
                                                      last - addr);
-                               if(err < 0)
+                               if (err < 0)
                                        panic("munmap failed, errno = %d\n",
                                              -err);
                        }
@@ -304,15 +330,15 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
                }
 
                pmd = pmd_offset(pud, addr);
-               if(!pmd_present(*pmd)){
+               if (!pmd_present(*pmd)) {
                        last = ADD_ROUND(addr, PMD_SIZE);
-                       if(last > end)
+                       if (last > end)
                                last = end;
-                       if(pmd_newpage(*pmd)){
+                       if (pmd_newpage(*pmd)) {
                                updated = 1;
                                err = os_unmap_memory((void *) addr,
                                                      last - addr);
-                               if(err < 0)
+                               if (err < 0)
                                        panic("munmap failed, errno = %d\n",
                                              -err);
                        }
@@ -321,45 +347,110 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
                }
 
                pte = pte_offset_kernel(pmd, addr);
-               if(!pte_present(*pte) || pte_newpage(*pte)){
+               if (!pte_present(*pte) || pte_newpage(*pte)) {
                        updated = 1;
                        err = os_unmap_memory((void *) addr,
                                              PAGE_SIZE);
-                       if(err < 0)
+                       if (err < 0)
                                panic("munmap failed, errno = %d\n",
                                      -err);
-                       if(pte_present(*pte))
+                       if (pte_present(*pte))
                                map_memory(addr,
                                           pte_val(*pte) & PAGE_MASK,
                                           PAGE_SIZE, 1, 1, 1);
                }
-               else if(pte_newprot(*pte)){
+               else if (pte_newprot(*pte)) {
                        updated = 1;
                        os_protect_memory((void *) addr, PAGE_SIZE, 1, 1, 1);
                }
                addr += PAGE_SIZE;
        }
-       return(updated);
+       return updated;
+}
+
+void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
+{
+       pgd_t *pgd;
+       pud_t *pud;
+       pmd_t *pmd;
+       pte_t *pte;
+       struct mm_struct *mm = vma->vm_mm;
+       void *flush = NULL;
+       int r, w, x, prot, err = 0;
+       struct mm_id *mm_id;
+
+       address &= PAGE_MASK;
+       pgd = pgd_offset(mm, address);
+       if (!pgd_present(*pgd))
+               goto kill;
+
+       pud = pud_offset(pgd, address);
+       if (!pud_present(*pud))
+               goto kill;
+
+       pmd = pmd_offset(pud, address);
+       if (!pmd_present(*pmd))
+               goto kill;
+
+       pte = pte_offset_kernel(pmd, address);
+
+       r = pte_read(*pte);
+       w = pte_write(*pte);
+       x = pte_exec(*pte);
+       if (!pte_young(*pte)) {
+               r = 0;
+               w = 0;
+       } else if (!pte_dirty(*pte)) {
+               w = 0;
+       }
+
+       mm_id = &mm->context.id;
+       prot = ((r ? UM_PROT_READ : 0) | (w ? UM_PROT_WRITE : 0) |
+               (x ? UM_PROT_EXEC : 0));
+       if (pte_newpage(*pte)) {
+               if (pte_present(*pte)) {
+                       unsigned long long offset;
+                       int fd;
+
+                       fd = phys_mapping(pte_val(*pte) & PAGE_MASK, &offset);
+                       err = map(mm_id, address, PAGE_SIZE, prot, fd, offset,
+                                 1, &flush);
+               }
+               else err = unmap(mm_id, address, PAGE_SIZE, 1, &flush);
+       }
+       else if (pte_newprot(*pte))
+               err = protect(mm_id, address, PAGE_SIZE, prot, 1, &flush);
+
+       if (err)
+               goto kill;
+
+       *pte = pte_mkuptodate(*pte);
+
+       return;
+
+kill:
+       printk(KERN_ERR "Failed to flush page for address 0x%lx\n", address);
+       force_sig(SIGKILL, current);
 }
 
 pgd_t *pgd_offset_proc(struct mm_struct *mm, unsigned long address)
 {
-       return(pgd_offset(mm, address));
+       return pgd_offset(mm, address);
 }
 
 pud_t *pud_offset_proc(pgd_t *pgd, unsigned long address)
 {
-       return(pud_offset(pgd, address));
+       return pud_offset(pgd, address);
 }
 
 pmd_t *pmd_offset_proc(pud_t *pud, unsigned long address)
 {
-       return(pmd_offset(pud, address));
+       return pmd_offset(pud, address);
 }
 
 pte_t *pte_offset_proc(pmd_t *pmd, unsigned long address)
 {
-       return(pte_offset_kernel(pmd, address));
+       return pte_offset_kernel(pmd, address);
 }
 
 pte_t *addr_pte(struct task_struct *task, unsigned long addr)
@@ -368,7 +459,7 @@ pte_t *addr_pte(struct task_struct *task, unsigned long addr)
        pud_t *pud = pud_offset(pgd, addr);
        pmd_t *pmd = pmd_offset(pud, addr);
 
-       return(pte_offset_map(pmd, addr));
+       return pte_offset_map(pmd, addr);
 }
 
 void flush_tlb_all(void)
@@ -378,35 +469,58 @@ void flush_tlb_all(void)
 
 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
 {
-       CHOOSE_MODE_PROC(flush_tlb_kernel_range_tt,
-                        flush_tlb_kernel_range_common, start, end);
+       flush_tlb_kernel_range_common(start, end);
 }
 
 void flush_tlb_kernel_vm(void)
 {
-       CHOOSE_MODE(flush_tlb_kernel_vm_tt(),
-                   flush_tlb_kernel_range_common(start_vm, end_vm));
+       flush_tlb_kernel_range_common(start_vm, end_vm);
 }
 
 void __flush_tlb_one(unsigned long addr)
 {
-       CHOOSE_MODE_PROC(__flush_tlb_one_tt, __flush_tlb_one_skas, addr);
+       flush_tlb_kernel_range_common(addr, addr + PAGE_SIZE);
+}
+
+static void fix_range(struct mm_struct *mm, unsigned long start_addr,
+                     unsigned long end_addr, int force)
+{
+       if (!proc_mm && (end_addr > STUB_START))
+               end_addr = STUB_START;
+
+       fix_range_common(mm, start_addr, end_addr, force);
 }
 
 void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
                     unsigned long end)
 {
-       CHOOSE_MODE_PROC(flush_tlb_range_tt, flush_tlb_range_skas, vma, start,
-                        end);
+       if (vma->vm_mm == NULL)
+               flush_tlb_kernel_range_common(start, end);
+       else fix_range(vma->vm_mm, start, end, 0);
 }
 
 void flush_tlb_mm(struct mm_struct *mm)
 {
-       CHOOSE_MODE_PROC(flush_tlb_mm_tt, flush_tlb_mm_skas, mm);
+       unsigned long end;
+
+       /*
+        * Don't bother flushing if this address space is about to be
+        * destroyed.
+        */
+       if (atomic_read(&mm->mm_users) == 0)
+               return;
+
+       end = proc_mm ? task_size : STUB_START;
+       fix_range(mm, 0, end, 0);
 }
 
 void force_flush_all(void)
 {
-       CHOOSE_MODE(force_flush_all_tt(), force_flush_all_skas());
-}
+       struct mm_struct *mm = current->mm;
+       struct vm_area_struct *vma = mm->mmap;
 
+       while (vma != NULL) {
+               fix_range(mm, vma->vm_start, vma->vm_end, 1);
+               vma = vma->vm_next;
+       }
+}
index 3850d53..cb3321f 100644 (file)
@@ -1,40 +1,24 @@
 /*
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "asm/errno.h"
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "linux/spinlock.h"
-#include "linux/init.h"
-#include "linux/ptrace.h"
-#include "asm/semaphore.h"
-#include "asm/pgtable.h"
-#include "asm/pgalloc.h"
-#include "asm/tlbflush.h"
-#include "asm/a.out.h"
-#include "asm/current.h"
-#include "asm/irq.h"
-#include "sysdep/sigcontext.h"
-#include "kern_util.h"
-#include "as-layout.h"
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/hardirq.h>
+#include <asm/current.h>
+#include <asm/pgtable.h>
+#include <asm/tlbflush.h>
 #include "arch.h"
-#include "kern.h"
-#include "chan_kern.h"
-#include "mconsole_kern.h"
-#include "mem.h"
-#include "mem_kern.h"
-#include "sysdep/sigcontext.h"
-#include "sysdep/ptrace.h"
-#include "os.h"
-#ifdef CONFIG_MODE_SKAS
-#include "skas.h"
-#endif
+#include "as-layout.h"
+#include "kern_util.h"
 #include "os.h"
+#include "sysdep/sigcontext.h"
 
-/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
+/*
+ * Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by
+ * segv().
+ */
 int handle_page_fault(unsigned long address, unsigned long ip,
                      int is_write, int is_user, int *code_out)
 {
@@ -48,31 +32,33 @@ int handle_page_fault(unsigned long address, unsigned long ip,
 
        *code_out = SEGV_MAPERR;
 
-       /* If the fault was during atomic operation, don't take the fault, just
-        * fail. */
+       /*
+        * If the fault was during atomic operation, don't take the fault, just
+        * fail.
+        */
        if (in_atomic())
                goto out_nosemaphore;
 
        down_read(&mm->mmap_sem);
        vma = find_vma(mm, address);
-       if(!vma)
+       if (!vma)
                goto out;
-       else if(vma->vm_start <= address)
+       else if (vma->vm_start <= address)
                goto good_area;
-       else if(!(vma->vm_flags & VM_GROWSDOWN))
+       else if (!(vma->vm_flags & VM_GROWSDOWN))
                goto out;
-       else if(is_user && !ARCH_IS_STACKGROW(address))
+       else if (is_user && !ARCH_IS_STACKGROW(address))
                goto out;
-       else if(expand_stack(vma, address))
+       else if (expand_stack(vma, address))
                goto out;
 
 good_area:
        *code_out = SEGV_ACCERR;
-       if(is_write && !(vma->vm_flags & VM_WRITE))
+       if (is_write && !(vma->vm_flags & VM_WRITE))
                goto out;
 
        /* Don't require VM_READ|VM_EXEC for write faults! */
-       if(!is_write && !(vma->vm_flags & (VM_READ | VM_EXEC)))
+       if (!is_write && !(vma->vm_flags & (VM_READ | VM_EXEC)))
                goto out;
 
        do {
@@ -98,9 +84,10 @@ survive:
                pud = pud_offset(pgd, address);
                pmd = pmd_offset(pud, address);
                pte = pte_offset_kernel(pmd, address);
-       } while(!pte_present(*pte));
+       } while (!pte_present(*pte));
        err = 0;
-       /* The below warning was added in place of
+       /*
+        * The below warning was added in place of
         *      pte_mkyoung(); if (is_write) pte_mkdirty();
         * If it's triggered, we'd see normally a hang here (a clean pte is
         * marked read-only to emulate the dirty bit).
@@ -114,14 +101,14 @@ survive:
 out:
        up_read(&mm->mmap_sem);
 out_nosemaphore:
-       return(err);
+       return err;
 
 /*
  * We ran out of memory, or some other thing happened to us that made
  * us unable to handle the page fault gracefully.
  */
 out_of_memory:
-       if (is_init(current)) {
+       if (is_global_init(current)) {
                up_read(&mm->mmap_sem);
                yield();
                down_read(&mm->mmap_sem);
@@ -141,11 +128,11 @@ static void bad_segv(struct faultinfo fi, unsigned long ip)
        force_sig_info(SIGSEGV, &si, current);
 }
 
-static void segv_handler(int sig, union uml_pt_regs *regs)
+static void segv_handler(int sig, struct uml_pt_regs *regs)
 {
        struct faultinfo * fi = UPT_FAULTINFO(regs);
 
-       if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
+       if (UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)) {
                bad_segv(*fi, UPT_IP(regs));
                return;
        }
@@ -159,45 +146,49 @@ static void segv_handler(int sig, union uml_pt_regs *regs)
  * give us bad data!
  */
 unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
-                  union uml_pt_regs *regs)
+                  struct uml_pt_regs *regs)
 {
        struct siginfo si;
-       void *catcher;
+       jmp_buf *catcher;
        int err;
        int is_write = FAULT_WRITE(fi);
        unsigned long address = FAULT_ADDRESS(fi);
 
-       if(!is_user && (address >= start_vm) && (address < end_vm)){
+       if (!is_user && (address >= start_vm) && (address < end_vm)) {
                flush_tlb_kernel_vm();
                return 0;
        }
-       else if(current->mm == NULL) {
+       else if (current->mm == NULL) {
                show_regs(container_of(regs, struct pt_regs, regs));
-               panic("Segfault with no mm");
+               panic("Segfault with no mm");
        }
 
        if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
-               err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
+               err = handle_page_fault(address, ip, is_write, is_user,
+                                       &si.si_code);
        else {
                err = -EFAULT;
-               /* A thread accessed NULL, we get a fault, but CR2 is invalid.
-                * This code is used in __do_copy_from_user() of TT mode. */
+               /*
+                * A thread accessed NULL, we get a fault, but CR2 is invalid.
+                * This code is used in __do_copy_from_user() of TT mode.
+                * XXX tt mode is gone, so maybe this isn't needed any more
+                */
                address = 0;
        }
 
        catcher = current->thread.fault_catcher;
-       if(!err)
+       if (!err)
                return 0;
-       else if(catcher != NULL){
+       else if (catcher != NULL) {
                current->thread.fault_addr = (void *) address;
-               do_longjmp(catcher, 1);
+               UML_LONGJMP(catcher, 1);
        }
-       else if(current->thread.fault_addr != NULL)
+       else if (current->thread.fault_addr != NULL)
                panic("fault_addr set but no fault catcher");
-       else if(!is_user && arch_fixup(ip, regs))
+       else if (!is_user && arch_fixup(ip, regs))
                return 0;
 
-       if(!is_user) {
+       if (!is_user) {
                show_regs(container_of(regs, struct pt_regs, regs));
                panic("Kernel mode fault at addr 0x%lx, ip 0x%lx",
                      address, ip);
@@ -211,7 +202,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
                current->thread.arch.faultinfo = fi;
                force_sig_info(SIGBUS, &si, current);
        } else if (err == -ENOMEM) {
-               printk("VM: killing process %s\n", current->comm);
+               printk(KERN_INFO "VM: killing process %s\n", current->comm);
                do_exit(SIGKILL);
        } else {
                BUG_ON(err != -EFAULT);
@@ -223,15 +214,15 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
        return 0;
 }
 
-void relay_signal(int sig, union uml_pt_regs *regs)
+void relay_signal(int sig, struct uml_pt_regs *regs)
 {
-       if(arch_handle_signal(sig, regs))
+       if (arch_handle_signal(sig, regs))
                return;
 
-       if(!UPT_IS_USER(regs)){
-               if(sig == SIGBUS)
-                       printk("Bus error - the host /dev/shm or /tmp mount "
-                              "likely just ran out of space\n");
+       if (!UPT_IS_USER(regs)) {
+               if (sig == SIGBUS)
+                       printk(KERN_ERR "Bus error - the host /dev/shm or /tmp "
+                              "mount likely just ran out of space\n");
                panic("Kernel mode signal %d", sig);
        }
 
@@ -239,14 +230,14 @@ void relay_signal(int sig, union uml_pt_regs *regs)
        force_sig(sig, current);
 }
 
-static void bus_handler(int sig, union uml_pt_regs *regs)
+static void bus_handler(int sig, struct uml_pt_regs *regs)
 {
-       if(current->thread.fault_catcher != NULL)
-               do_longjmp(current->thread.fault_catcher, 1);
+       if (current->thread.fault_catcher != NULL)
+               UML_LONGJMP(current->thread.fault_catcher, 1);
        else relay_signal(sig, regs);
 }
 
-static void winch(int sig, union uml_pt_regs *regs)
+static void winch(int sig, struct uml_pt_regs *regs)
 {
        do_IRQ(WINCH_IRQ, regs);
 }
diff --git a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile
deleted file mode 100644 (file)
index 6939e5a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# 
-# Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
-# Licensed under the GPL
-#
-
-obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
-       syscall_kern.o syscall_user.o tlb.o tracer.o trap_user.o \
-       uaccess.o uaccess_user.o
-
-obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/
-
-USER_OBJS := gdb.o tracer.o
-
-include arch/um/scripts/Makefile.rules
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c
deleted file mode 100644 (file)
index 40126cb..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/kernel.h"
-#include "linux/mm.h"
-#include "asm/signal.h"
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "asm/pgalloc.h"
-#include "asm/tlbflush.h"
-#include "kern_util.h"
-#include "irq_user.h"
-#include "mem_user.h"
-#include "os.h"
-#include "tlb.h"
-#include "mode.h"
-
-static int exec_tramp(void *sig_stack)
-{
-       init_new_thread_stack(sig_stack, NULL);
-       init_new_thread_signals();
-       os_stop_process(os_getpid());
-       return(0);
-}
-
-void flush_thread_tt(void)
-{
-       unsigned long stack;
-       int new_pid;
-
-       stack = alloc_stack(0, 0);
-       if(stack == 0){
-               printk(KERN_ERR 
-                      "flush_thread : failed to allocate temporary stack\n");
-               do_exit(SIGKILL);
-       }
-               
-       new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp);
-       if(new_pid < 0){
-               printk(KERN_ERR 
-                      "flush_thread : new thread failed, errno = %d\n",
-                      -new_pid);
-               do_exit(SIGKILL);
-       }
-
-       if(current_thread->cpu == 0)
-               forward_interrupts(new_pid);
-       current->thread.request.op = OP_EXEC;
-       current->thread.request.u.exec.pid = new_pid;
-       unprotect_stack((unsigned long) current_thread);
-       os_usr1_process(os_getpid());
-       change_sig(SIGUSR1, 1);
-
-       change_sig(SIGUSR1, 0);
-       enable_timer();
-       free_page(stack);
-       protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
-       stack_protections((unsigned long) current_thread);
-       force_flush_all();
-       unblock_signals();
-}
-
-void start_thread_tt(struct pt_regs *regs, unsigned long eip, 
-                    unsigned long esp)
-{
-       set_fs(USER_DS);
-       flush_tlb_mm(current->mm);
-       PT_REGS_IP(regs) = eip;
-       PT_REGS_SP(regs) = esp;
-       PT_FIX_EXEC_STACK(esp);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/exec_user.c b/arch/um/kernel/tt/exec_user.c
deleted file mode 100644 (file)
index 7b5f218..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sched.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include "kern_util.h"
-#include "user.h"
-#include "ptrace_user.h"
-#include "os.h"
-
-void do_exec(int old_pid, int new_pid)
-{
-       unsigned long regs[FRAME_SIZE];
-       int err;
-
-       if((ptrace(PTRACE_ATTACH, new_pid, 0, 0) < 0) ||
-          (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0))
-               tracer_panic("do_exec failed to attach proc - errno = %d",
-                            errno);
-
-       CATCH_EINTR(err = waitpid(new_pid, 0, WUNTRACED));
-       if (err < 0)
-               tracer_panic("do_exec failed to attach proc in waitpid - errno = %d",
-                            errno);
-
-       if(ptrace_getregs(old_pid, regs) < 0)
-               tracer_panic("do_exec failed to get registers - errno = %d",
-                            errno);
-
-       os_kill_ptraced_process(old_pid, 0);
-
-       if (ptrace(PTRACE_OLDSETOPTIONS, new_pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
-               tracer_panic("do_exec: PTRACE_SETOPTIONS failed, errno = %d", errno);
-
-       if(ptrace_setregs(new_pid, regs) < 0)
-               tracer_panic("do_exec failed to start new proc - errno = %d",
-                            errno);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/gdb.c b/arch/um/kernel/tt/gdb.c
deleted file mode 100644 (file)
index 030e465..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include "ptrace_user.h"
-#include "uml-config.h"
-#include "kern_constants.h"
-#include "chan_user.h"
-#include "init.h"
-#include "user.h"
-#include "debug.h"
-#include "kern_util.h"
-#include "tt.h"
-#include "sysdep/thread.h"
-#include "os.h"
-
-extern int debugger_pid;
-extern int debugger_fd;
-extern int debugger_parent;
-
-int detach(int pid, int sig)
-{
-       return(ptrace(PTRACE_DETACH, pid, 0, sig));
-}
-
-int attach(int pid)
-{
-       int err;
-
-       err = ptrace(PTRACE_ATTACH, pid, 0, 0);
-       if(err < 0) return(-errno);
-       else return(err);
-}
-
-int cont(int pid)
-{
-       return(ptrace(PTRACE_CONT, pid, 0, 0));
-}
-
-#ifdef UML_CONFIG_PT_PROXY
-
-int debugger_signal(int status, pid_t pid)
-{
-       return(debugger_proxy(status, pid));
-}
-
-void child_signal(pid_t pid, int status)
-{
-       child_proxy(pid, status);
-}
-
-static void gdb_announce(char *dev_name, int dev)
-{
-       printf("gdb assigned device '%s'\n", dev_name);
-}
-
-static struct chan_opts opts = {
-       .announce       = gdb_announce,
-       .xterm_title    = "UML kernel debugger",
-       .raw            = 0,
-       .tramp_stack    = 0,
-       .in_kernel      = 0,
-};
-
-/* Accessed by the tracing thread, which automatically serializes access */
-static void *xterm_data;
-static int xterm_fd;
-
-extern void *xterm_init(char *, int, struct chan_opts *);
-extern int xterm_open(int, int, int, void *, char **);
-extern void xterm_close(int, void *);
-
-int open_gdb_chan(void)
-{
-       char stack[UM_KERN_PAGE_SIZE], *dummy;
-
-       opts.tramp_stack = (unsigned long) stack;
-       xterm_data = xterm_init("", 0, &opts);
-       xterm_fd = xterm_open(1, 1, 1, xterm_data, &dummy);
-       return(xterm_fd);
-}
-
-static void exit_debugger_cb(void *unused)
-{
-       if(debugger_pid != -1){
-               if(gdb_pid != -1){
-                       fake_child_exit();
-                       gdb_pid = -1;
-               }
-               else kill_child_dead(debugger_pid);
-               debugger_pid = -1;
-               if(debugger_parent != -1)
-                       detach(debugger_parent, SIGINT);
-       }
-       if(xterm_data != NULL) xterm_close(xterm_fd, xterm_data);
-}
-
-static void exit_debugger(void)
-{
-       initial_thread_cb(exit_debugger_cb, NULL);
-}
-
-__uml_exitcall(exit_debugger);
-
-struct gdb_data {
-       char *str;
-       int err;
-};
-
-extern char *linux_prog;
-
-static void config_gdb_cb(void *arg)
-{
-       struct gdb_data *data = arg;
-       void *task;
-       int pid;
-
-       data->err = -1;
-       if(debugger_pid != -1) exit_debugger_cb(NULL);
-       if(!strncmp(data->str, "pid,", strlen("pid,"))){
-               data->str += strlen("pid,");
-               pid = strtoul(data->str, NULL, 0);
-               task = cpu_tasks[0].task;
-               debugger_pid = attach_debugger(TASK_EXTERN_PID(task), pid, 0);
-               if(debugger_pid != -1){
-                       data->err = 0;
-                       gdb_pid = pid;
-               }
-               return;
-       }
-       data->err = 0;
-       debugger_pid = start_debugger(linux_prog, 0, 0, &debugger_fd);
-       init_proxy(debugger_pid, 0, 0);
-}
-
-int gdb_config(char *str, char **error_out)
-{
-       struct gdb_data data;
-
-       if(*str++ != '=') return(-1);
-       data.str = str;
-       initial_thread_cb(config_gdb_cb, &data);
-       return(data.err);
-}
-
-void remove_gdb_cb(void *unused)
-{
-       exit_debugger_cb(NULL);
-}
-
-int gdb_remove(int unused, char **error_out)
-{
-       initial_thread_cb(remove_gdb_cb, NULL);
-        return 0;
-}
-
-void signal_usr1(int sig)
-{
-       if(debugger_pid != -1){
-               printf("The debugger is already running\n");
-               return;
-       }
-       debugger_pid = start_debugger(linux_prog, 0, 0, &debugger_fd);
-       init_proxy(debugger_pid, 0, 0);
-}
-
-int init_ptrace_proxy(int idle_pid, int startup, int stop)
-{
-       int pid, status;
-
-       pid = start_debugger(linux_prog, startup, stop, &debugger_fd);
-       status = wait_for_stop(idle_pid, SIGSTOP, PTRACE_CONT, NULL);
-       if(pid < 0){
-               cont(idle_pid);
-               return(-1);
-       }
-       init_proxy(pid, 1, status);
-       return(pid);
-}
-
-int attach_debugger(int idle_pid, int pid, int stop)
-{
-       int status = 0, err;
-
-       err = attach(pid);
-       if(err < 0){
-               printf("Failed to attach pid %d, errno = %d\n", pid, -err);
-               return(-1);
-       }
-       if(stop) status = wait_for_stop(idle_pid, SIGSTOP, PTRACE_CONT, NULL);
-       init_proxy(pid, 1, status);
-       return(pid);
-}
-
-#ifdef notdef /* Put this back in when it does something useful */
-static int __init uml_gdb_init_setup(char *line, int *add)
-{
-       gdb_init = uml_strdup(line);
-       return 0;
-}
-
-__uml_setup("gdb=", uml_gdb_init_setup, 
-"gdb=<channel description>\n\n"
-);
-#endif
-
-static int __init uml_gdb_pid_setup(char *line, int *add)
-{
-       gdb_pid = strtoul(line, NULL, 0);
-       *add = 0;
-       return 0;
-}
-
-__uml_setup("gdb-pid=", uml_gdb_pid_setup, 
-"gdb-pid=<pid>\n"
-"    gdb-pid is used to attach an external debugger to UML.  This may be\n"
-"    an already-running gdb or a debugger-like process like strace.\n\n"
-);
-
-#else
-
-int debugger_signal(int status, pid_t pid){ return(0); }
-void child_signal(pid_t pid, int status){ }
-int init_ptrace_proxy(int idle_pid, int startup, int stop)
-{
-       printf("debug requested when CONFIG_PT_PROXY is off\n");
-       kill_child_dead(idle_pid);
-       exit(1);
-}
-
-void signal_usr1(int sig)
-{
-       printf("debug requested when CONFIG_PT_PROXY is off\n");
-}
-
-int attach_debugger(int idle_pid, int pid, int stop)
-{
-       printf("attach_debugger called when CONFIG_PT_PROXY "
-              "is off\n");
-       return(-1);
-}
-
-int config_gdb(char *str)
-{
-       return(-1);
-}
-
-int remove_gdb(void)
-{
-       return(-1);
-}
-
-int init_parent_proxy(int pid)
-{
-       return(-1);
-}
-
-void debugger_parent_signal(int status, int pid)
-{
-}
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/gdb_kern.c b/arch/um/kernel/tt/gdb_kern.c
deleted file mode 100644 (file)
index 03b06bc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/init.h"
-#include "mconsole_kern.h"
-
-#ifdef CONFIG_MCONSOLE
-
-extern int gdb_config(char *str, char **error_out);
-extern int gdb_remove(int n, char **error_out);
-
-static struct mc_device gdb_mc = {
-       .list           = INIT_LIST_HEAD(gdb_mc.list),
-       .name           = "gdb",
-       .config         = gdb_config,
-       .remove         = gdb_remove,
-};
-
-int gdb_mc_init(void)
-{
-       mconsole_register_dev(&gdb_mc);
-       return(0);
-}
-
-__initcall(gdb_mc_init);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/include/mode-tt.h b/arch/um/kernel/tt/include/mode-tt.h
deleted file mode 100644 (file)
index e171e15..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __MODE_TT_H__
-#define __MODE_TT_H__
-
-#include "sysdep/ptrace.h"
-
-enum { OP_NONE, OP_EXEC, OP_FORK, OP_TRACE_ON, OP_REBOOT, OP_HALT, OP_CB };
-
-extern int tracing_pid;
-
-extern int tracer(int (*init_proc)(void *), void *sp);
-extern void sig_handler_common_tt(int sig, void *sc);
-extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
-extern void reboot_tt(void);
-extern void halt_tt(void);
-extern int is_tracer_winch(int pid, int fd, void *data);
-extern void kill_off_processes_tt(void);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ksyms.c b/arch/um/kernel/tt/ksyms.c
deleted file mode 100644 (file)
index 84a9385..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/module.h"
-#include "asm/uaccess.h"
-#include "mode.h"
-
-EXPORT_SYMBOL(__do_copy_from_user);
-EXPORT_SYMBOL(__do_copy_to_user);
-EXPORT_SYMBOL(__do_strncpy_from_user);
-EXPORT_SYMBOL(__do_strnlen_user); 
-EXPORT_SYMBOL(__do_clear_user);
-EXPORT_SYMBOL(clear_user_tt);
-
-EXPORT_SYMBOL(tracing_pid);
-EXPORT_SYMBOL(honeypot);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/mem.c b/arch/um/kernel/tt/mem.c
deleted file mode 100644 (file)
index d0c3c49..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/stddef.h"
-#include "linux/mm.h"
-#include "asm/uaccess.h"
-#include "mem_user.h"
-#include "kern_util.h"
-#include "kern.h"
-#include "tt.h"
-
-void before_mem_tt(unsigned long brk_start)
-{
-       if(debug)
-               remap_data(UML_ROUND_DOWN(&_stext), UML_ROUND_UP(&_etext), 1);
-       remap_data(UML_ROUND_DOWN(&_sdata), UML_ROUND_UP(&_edata), 1);
-       remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
-}
-
-#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000)
-#define START (CONFIG_TOP_ADDR - SIZE)
-
-unsigned long set_task_sizes_tt(unsigned long *task_size_out)
-{
-       unsigned long host_task_size;
-
-       /* Round up to the nearest 4M */
-       host_task_size = ROUND_4M((unsigned long) &host_task_size);
-       *task_size_out = START;
-
-       return host_task_size;
-}
diff --git a/arch/um/kernel/tt/mem_user.c b/arch/um/kernel/tt/mem_user.c
deleted file mode 100644 (file)
index 9774f63..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include "tt.h"
-#include "mem_user.h"
-#include "os.h"
-
-void remap_data(void *segment_start, void *segment_end, int w)
-{
-       void *addr;
-       unsigned long size;
-       int data, prot;
-
-       if(w) prot = PROT_WRITE;
-       else prot = 0;
-       prot |= PROT_READ | PROT_EXEC;
-       size = (unsigned long) segment_end - 
-               (unsigned long) segment_start;
-       data = create_mem_file(size);
-       addr = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED, data, 0);
-       if(addr == MAP_FAILED){
-               perror("mapping new data segment");
-               exit(1);
-       }
-       memcpy(addr, segment_start, size);
-       if(switcheroo(data, prot, addr, segment_start, size) < 0){
-               printf("switcheroo failed\n");
-               exit(1);
-       }
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
deleted file mode 100644 (file)
index 74347ad..0000000
+++ /dev/null
@@ -1,461 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include "linux/sched.h"
-#include "linux/signal.h"
-#include "linux/kernel.h"
-#include "linux/interrupt.h"
-#include "linux/ptrace.h"
-#include "asm/system.h"
-#include "asm/pgalloc.h"
-#include "asm/ptrace.h"
-#include "asm/tlbflush.h"
-#include "irq_user.h"
-#include "kern_util.h"
-#include "os.h"
-#include "kern.h"
-#include "sigcontext.h"
-#include "mem_user.h"
-#include "tlb.h"
-#include "mode.h"
-#include "mode_kern.h"
-#include "init.h"
-#include "tt.h"
-
-void switch_to_tt(void *prev, void *next)
-{
-       struct task_struct *from, *to, *prev_sched;
-       unsigned long flags;
-       int err, vtalrm, alrm, prof, cpu;
-       char c;
-
-       from = prev;
-       to = next;
-
-       cpu = task_thread_info(from)->cpu;
-       if(cpu == 0)
-               forward_interrupts(to->thread.mode.tt.extern_pid);
-#ifdef CONFIG_SMP
-       forward_ipi(cpu_data[cpu].ipi_pipe[0], to->thread.mode.tt.extern_pid);
-#endif
-       local_irq_save(flags);
-
-       vtalrm = change_sig(SIGVTALRM, 0);
-       alrm = change_sig(SIGALRM, 0);
-       prof = change_sig(SIGPROF, 0);
-
-       forward_pending_sigio(to->thread.mode.tt.extern_pid);
-
-       c = 0;
-
-       /* Notice that here we "up" the semaphore on which "to" is waiting, and
-        * below (the read) we wait on this semaphore (which is implemented by
-        * switch_pipe) and go sleeping. Thus, after that, we have resumed in
-        * "to", and can't use any more the value of "from" (which is outdated),
-        * nor the value in "to" (since it was the task which stole us the CPU,
-        * which we don't care about). */
-
-       err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c));
-       if(err != sizeof(c))
-               panic("write of switch_pipe failed, err = %d", -err);
-
-       if(from->thread.mode.tt.switch_pipe[0] == -1)
-               os_kill_process(os_getpid(), 0);
-
-       err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c,
-                            sizeof(c));
-       if(err != sizeof(c))
-               panic("read of switch_pipe failed, errno = %d", -err);
-
-       /* If the process that we have just scheduled away from has exited,
-        * then it needs to be killed here.  The reason is that, even though
-        * it will kill itself when it next runs, that may be too late.  Its
-        * stack will be freed, possibly before then, and if that happens,
-        * we have a use-after-free situation.  So, it gets killed here
-        * in case it has not already killed itself.
-        */
-       prev_sched = current->thread.prev_sched;
-        if(prev_sched->thread.mode.tt.switch_pipe[0] == -1)
-               os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
-
-       change_sig(SIGVTALRM, vtalrm);
-       change_sig(SIGALRM, alrm);
-       change_sig(SIGPROF, prof);
-
-       arch_switch_to_tt(prev_sched, current);
-
-       flush_tlb_all();
-       local_irq_restore(flags);
-}
-
-void release_thread_tt(struct task_struct *task)
-{
-       int pid = task->thread.mode.tt.extern_pid;
-
-       /*
-         * We first have to kill the other process, before
-         * closing its switch_pipe. Else it might wake up
-         * and receive "EOF" before we could kill it.
-         */
-       if(os_getpid() != pid)
-               os_kill_process(pid, 0);
-
-        os_close_file(task->thread.mode.tt.switch_pipe[0]);
-        os_close_file(task->thread.mode.tt.switch_pipe[1]);
-       /* use switch_pipe as flag: thread is released */
-        task->thread.mode.tt.switch_pipe[0] = -1;
-}
-
-void suspend_new_thread(int fd)
-{
-       int err;
-       char c;
-
-       os_stop_process(os_getpid());
-       err = os_read_file(fd, &c, sizeof(c));
-       if(err != sizeof(c))
-               panic("read failed in suspend_new_thread, err = %d", -err);
-}
-
-void schedule_tail(struct task_struct *prev);
-
-static void new_thread_handler(int sig)
-{
-       unsigned long disable;
-       int (*fn)(void *);
-       void *arg;
-
-       fn = current->thread.request.u.thread.proc;
-       arg = current->thread.request.u.thread.arg;
-
-       UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
-       disable = (1 << (SIGVTALRM - 1)) | (1 << (SIGALRM - 1)) |
-               (1 << (SIGIO - 1)) | (1 << (SIGPROF - 1));
-       SC_SIGMASK(UPT_SC(&current->thread.regs.regs)) &= ~disable;
-
-       suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
-
-       force_flush_all();
-       if(current->thread.prev_sched != NULL)
-               schedule_tail(current->thread.prev_sched);
-       current->thread.prev_sched = NULL;
-
-       init_new_thread_signals();
-       enable_timer();
-       free_page(current->thread.temp_stack);
-       set_cmdline("(kernel thread)");
-
-       change_sig(SIGUSR1, 1);
-       change_sig(SIGPROF, 1);
-       local_irq_enable();
-       if(!run_kernel_thread(fn, arg, &current->thread.exec_buf))
-               do_exit(0);
-
-       /* XXX No set_user_mode here because a newly execed process will
-        * immediately segfault on its non-existent IP, coming straight back
-        * to the signal handler, which will call set_user_mode on its way
-        * out.  This should probably change since it's confusing.
-        */
-}
-
-static int new_thread_proc(void *stack)
-{
-       /* local_irq_disable is needed to block out signals until this thread is
-        * properly scheduled.  Otherwise, the tracing thread will get mighty
-        * upset about any signals that arrive before that.
-        * This has the complication that it sets the saved signal mask in
-        * the sigcontext to block signals.  This gets restored when this
-        * thread (or a descendant, since they get a copy of this sigcontext)
-        * returns to userspace.
-        * So, this is compensated for elsewhere.
-        * XXX There is still a small window until local_irq_disable() actually
-        * finishes where signals are possible - shouldn't be a problem in
-        * practice since SIGIO hasn't been forwarded here yet, and the
-        * local_irq_disable should finish before a SIGVTALRM has time to be
-        * delivered.
-        */
-
-       local_irq_disable();
-       init_new_thread_stack(stack, new_thread_handler);
-       os_usr1_process(os_getpid());
-       change_sig(SIGUSR1, 1);
-       return(0);
-}
-
-/* Signal masking - signals are blocked at the start of fork_tramp.  They
- * are re-enabled when finish_fork_handler is entered by fork_tramp hitting
- * itself with a SIGUSR1.  set_user_mode has to be run with SIGUSR1 off,
- * so it is blocked before it's called.  They are re-enabled on sigreturn
- * despite the fact that they were blocked when the SIGUSR1 was issued because
- * copy_thread copies the parent's sigcontext, including the signal mask
- * onto the signal frame.
- */
-
-void finish_fork_handler(int sig)
-{
-       UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
-       suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
-
-       force_flush_all();
-       if(current->thread.prev_sched != NULL)
-               schedule_tail(current->thread.prev_sched);
-       current->thread.prev_sched = NULL;
-
-       enable_timer();
-       change_sig(SIGVTALRM, 1);
-       local_irq_enable();
-       if(current->mm != current->parent->mm)
-               protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 
-                              1, 0, 1);
-       stack_protections((unsigned long) current_thread);
-
-       free_page(current->thread.temp_stack);
-       local_irq_disable();
-       change_sig(SIGUSR1, 0);
-       set_user_mode(current);
-}
-
-int fork_tramp(void *stack)
-{
-       local_irq_disable();
-       arch_init_thread();
-       init_new_thread_stack(stack, finish_fork_handler);
-
-       os_usr1_process(os_getpid());
-       change_sig(SIGUSR1, 1);
-       return(0);
-}
-
-int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
-                  unsigned long stack_top, struct task_struct * p, 
-                  struct pt_regs *regs)
-{
-       int (*tramp)(void *);
-       int new_pid, err;
-       unsigned long stack;
-       
-       if(current->thread.forking)
-               tramp = fork_tramp;
-       else {
-               tramp = new_thread_proc;
-               p->thread.request.u.thread = current->thread.request.u.thread;
-       }
-
-       err = os_pipe(p->thread.mode.tt.switch_pipe, 1, 1);
-       if(err < 0){
-               printk("copy_thread : pipe failed, err = %d\n", -err);
-               return(err);
-       }
-
-       stack = alloc_stack(0, 0);
-       if(stack == 0){
-               printk(KERN_ERR "copy_thread : failed to allocate "
-                      "temporary stack\n");
-               return(-ENOMEM);
-       }
-
-       clone_flags &= CLONE_VM;
-       p->thread.temp_stack = stack;
-       new_pid = start_fork_tramp(task_stack_page(p), stack, clone_flags, tramp);
-       if(new_pid < 0){
-               printk(KERN_ERR "copy_thread : clone failed - errno = %d\n", 
-                      -new_pid);
-               return(new_pid);
-       }
-
-       if(current->thread.forking){
-               sc_to_sc(UPT_SC(&p->thread.regs.regs), UPT_SC(&regs->regs));
-               SC_SET_SYSCALL_RETURN(UPT_SC(&p->thread.regs.regs), 0);
-               if(sp != 0)
-                       SC_SP(UPT_SC(&p->thread.regs.regs)) = sp;
-       }
-       p->thread.mode.tt.extern_pid = new_pid;
-
-       current->thread.request.op = OP_FORK;
-       current->thread.request.u.fork.pid = new_pid;
-       os_usr1_process(os_getpid());
-
-       /* Enable the signal and then disable it to ensure that it is handled
-        * here, and nowhere else.
-        */
-       change_sig(SIGUSR1, 1);
-
-       change_sig(SIGUSR1, 0);
-       err = 0;
-       return(err);
-}
-
-void reboot_tt(void)
-{
-       current->thread.request.op = OP_REBOOT;
-       os_usr1_process(os_getpid());
-       change_sig(SIGUSR1, 1);
-}
-
-void halt_tt(void)
-{
-       current->thread.request.op = OP_HALT;
-       os_usr1_process(os_getpid());
-       change_sig(SIGUSR1, 1);
-}
-
-void kill_off_processes_tt(void)
-{
-       struct task_struct *p;
-       int me;
-
-       me = os_getpid();
-        for_each_process(p){
-               if(p->thread.mode.tt.extern_pid != me) 
-                       os_kill_process(p->thread.mode.tt.extern_pid, 0);
-       }
-       if(init_task.thread.mode.tt.extern_pid != me) 
-               os_kill_process(init_task.thread.mode.tt.extern_pid, 0);
-}
-
-void initial_thread_cb_tt(void (*proc)(void *), void *arg)
-{
-       if(os_getpid() == tracing_pid){
-               (*proc)(arg);
-       }
-       else {
-               current->thread.request.op = OP_CB;
-               current->thread.request.u.cb.proc = proc;
-               current->thread.request.u.cb.arg = arg;
-               os_usr1_process(os_getpid());
-               change_sig(SIGUSR1, 1);
-
-               change_sig(SIGUSR1, 0);
-       }
-}
-
-int do_proc_op(void *t, int proc_id)
-{
-       struct task_struct *task;
-       struct thread_struct *thread;
-       int op, pid;
-
-       task = t;
-       thread = &task->thread;
-       op = thread->request.op;
-       switch(op){
-       case OP_NONE:
-       case OP_TRACE_ON:
-               break;
-       case OP_EXEC:
-               pid = thread->request.u.exec.pid;
-               do_exec(thread->mode.tt.extern_pid, pid);
-               thread->mode.tt.extern_pid = pid;
-               cpu_tasks[task_thread_info(task)->cpu].pid = pid;
-               break;
-       case OP_FORK:
-               attach_process(thread->request.u.fork.pid);
-               break;
-       case OP_CB:
-               (*thread->request.u.cb.proc)(thread->request.u.cb.arg);
-               break;
-       case OP_REBOOT:
-       case OP_HALT:
-               break;
-       default:
-               tracer_panic("Bad op in do_proc_op");
-               break;
-       }
-       thread->request.op = OP_NONE;
-       return(op);
-}
-
-void init_idle_tt(void)
-{
-       default_idle();
-}
-
-extern void start_kernel(void);
-
-static int start_kernel_proc(void *unused)
-{
-       int pid;
-
-       block_signals();
-       pid = os_getpid();
-
-       cpu_tasks[0].pid = pid;
-       cpu_tasks[0].task = current;
-#ifdef CONFIG_SMP
-       cpu_online_map = cpumask_of_cpu(0);
-#endif
-       if(debug) os_stop_process(pid);
-       start_kernel();
-       return(0);
-}
-
-void set_tracing(void *task, int tracing)
-{
-       ((struct task_struct *) task)->thread.mode.tt.tracing = tracing;
-}
-
-int is_tracing(void *t)
-{
-       return (((struct task_struct *) t)->thread.mode.tt.tracing);
-}
-
-int set_user_mode(void *t)
-{
-       struct task_struct *task;
-
-       task = t ? t : current;
-       if(task->thread.mode.tt.tracing) 
-               return(1);
-       task->thread.request.op = OP_TRACE_ON;
-       os_usr1_process(os_getpid());
-       return(0);
-}
-
-void set_init_pid(int pid)
-{
-       int err;
-
-       init_task.thread.mode.tt.extern_pid = pid;
-       err = os_pipe(init_task.thread.mode.tt.switch_pipe, 1, 1);
-       if(err)
-               panic("Can't create switch pipe for init_task, errno = %d",
-                     -err);
-}
-
-int start_uml_tt(void)
-{
-       void *sp;
-       int pages;
-
-       pages = (1 << CONFIG_KERNEL_STACK_ORDER);
-       sp = task_stack_page(&init_task) +
-               pages * PAGE_SIZE - sizeof(unsigned long);
-       return(tracer(start_kernel_proc, sp));
-}
-
-int external_pid_tt(struct task_struct *task)
-{
-       return(task->thread.mode.tt.extern_pid);
-}
-
-int thread_pid_tt(struct task_struct *task)
-{
-       return(task->thread.mode.tt.extern_pid);
-}
-
-int is_valid_pid(int pid)
-{
-       struct task_struct *task;
-
-        read_lock(&tasklist_lock);
-        for_each_process(task){
-                if(task->thread.mode.tt.extern_pid == pid){
-                       read_unlock(&tasklist_lock);
-                       return(1);
-                }
-        }
-       read_unlock(&tasklist_lock);
-       return(0);
-}
diff --git a/arch/um/kernel/tt/ptproxy/Makefile b/arch/um/kernel/tt/ptproxy/Makefile
deleted file mode 100644 (file)
index 3ad5b77..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# 
-# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
-# Licensed under the GPL
-#
-
-obj-y = proxy.o ptrace.o sysdep.o wait.o
-
-USER_OBJS := $(obj-y)
-
-include arch/um/scripts/Makefile.rules
diff --git a/arch/um/kernel/tt/ptproxy/proxy.c b/arch/um/kernel/tt/ptproxy/proxy.c
deleted file mode 100644 (file)
index 420c23f..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/**********************************************************************
-proxy.c
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-
-Jeff Dike (jdike@karaya.com) : Modified for integration into uml
-**********************************************************************/
-
-/* XXX This file shouldn't refer to CONFIG_* */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <string.h>
-#include <termios.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <asm/unistd.h>
-#include "ptrace_user.h"
-
-#include "ptproxy.h"
-#include "sysdep.h"
-#include "wait.h"
-
-#include "user.h"
-#include "os.h"
-#include "tempfile.h"
-
-static int debugger_wait(debugger_state *debugger, int *status, int options,
-                        int (*syscall)(debugger_state *debugger, pid_t child),
-                        int (*normal_return)(debugger_state *debugger, 
-                                             pid_t unused),
-                        int (*wait_return)(debugger_state *debugger, 
-                                           pid_t unused))
-{
-       if(debugger->real_wait){
-               debugger->handle_trace = normal_return;
-               syscall_continue(debugger->pid);
-               debugger->real_wait = 0;
-               return(1);
-       }
-       debugger->wait_status_ptr = status;
-       debugger->wait_options = options;
-       if((debugger->debugee != NULL) && debugger->debugee->event){
-               syscall_continue(debugger->pid);
-               wait_for_stop(debugger->pid, SIGTRAP, PTRACE_SYSCALL,
-                             NULL);
-               (*wait_return)(debugger, -1);
-               return(0);
-       }
-       else if(debugger->wait_options & WNOHANG){
-               syscall_cancel(debugger->pid, 0);
-               debugger->handle_trace = syscall;
-               return(0);
-       }
-       else {
-               syscall_pause(debugger->pid);
-               debugger->handle_trace = wait_return;
-               debugger->waiting = 1;
-       }
-       return(1);
-}
-
-/*
- * Handle debugger trap, i.e. syscall.
- */
-
-int debugger_syscall(debugger_state *debugger, pid_t child)
-{
-       long arg1, arg2, arg3, arg4, arg5, result;
-       int syscall, ret = 0;
-
-       syscall = get_syscall(debugger->pid, &arg1, &arg2, &arg3, &arg4, 
-                             &arg5);
-
-       switch(syscall){
-       case __NR_execve:
-               /* execve never returns */
-               debugger->handle_trace = debugger_syscall; 
-               break;
-
-       case __NR_ptrace:
-               if(debugger->debugee->pid != 0) arg2 = debugger->debugee->pid;
-               if(!debugger->debugee->in_context) 
-                       child = debugger->debugee->pid;
-               result = proxy_ptrace(debugger, arg1, arg2, arg3, arg4, child,
-                                     &ret);
-               syscall_cancel(debugger->pid, result);
-               debugger->handle_trace = debugger_syscall;
-               return(ret);
-
-#ifdef __NR_waitpid
-       case __NR_waitpid:
-#endif
-       case __NR_wait4:
-               if(!debugger_wait(debugger, (int *) arg2, arg3, 
-                                 debugger_syscall, debugger_normal_return, 
-                                 proxy_wait_return))
-                       return(0);
-               break;
-
-       case __NR_kill:
-               if(!debugger->debugee->in_context) 
-                       child = debugger->debugee->pid;
-               if(arg1 == debugger->debugee->pid){
-                       result = kill(child, arg2);
-                       syscall_cancel(debugger->pid, result);
-                       debugger->handle_trace = debugger_syscall;
-                       return(0);
-               }
-               else debugger->handle_trace = debugger_normal_return;
-               break;
-
-       default:
-               debugger->handle_trace = debugger_normal_return;
-       }
-
-       syscall_continue(debugger->pid);
-       return(0);
-}
-
-/* Used by the tracing thread */
-static debugger_state parent;
-static int parent_syscall(debugger_state *debugger, int pid);
-
-int init_parent_proxy(int pid)
-{
-       parent = ((debugger_state) { .pid               = pid,
-                                    .wait_options      = 0,
-                                    .wait_status_ptr   = NULL,
-                                    .waiting           = 0,
-                                    .real_wait         = 0,
-                                    .expecting_child   = 0,
-                                    .handle_trace      = parent_syscall,
-                                    .debugee           = NULL } );
-       return(0);
-}
-
-int parent_normal_return(debugger_state *debugger, pid_t unused)
-{
-       debugger->handle_trace = parent_syscall;
-       syscall_continue(debugger->pid);
-       return(0);
-}
-
-static int parent_syscall(debugger_state *debugger, int pid)
-{
-       long arg1, arg2, arg3, arg4, arg5;
-       int syscall;
-
-       syscall = get_syscall(pid, &arg1, &arg2, &arg3, &arg4, &arg5);
-               
-       if((syscall == __NR_wait4)
-#ifdef __NR_waitpid
-          || (syscall == __NR_waitpid)
-#endif
-       ){
-               debugger_wait(&parent, (int *) arg2, arg3, parent_syscall,
-                             parent_normal_return, parent_wait_return);
-       }
-       else ptrace(PTRACE_SYSCALL, pid, 0, 0);
-       return(0);
-}
-
-int debugger_normal_return(debugger_state *debugger, pid_t unused)
-{
-       debugger->handle_trace = debugger_syscall;
-       syscall_continue(debugger->pid);
-       return(0);
-}
-
-void debugger_cancelled_return(debugger_state *debugger, int result)
-{
-       debugger->handle_trace = debugger_syscall;
-       syscall_set_result(debugger->pid, result);
-       syscall_continue(debugger->pid);
-}
-
-/* Used by the tracing thread */
-static debugger_state debugger;
-static debugee_state debugee;
-
-void init_proxy (pid_t debugger_pid, int stopped, int status)
-{
-       debugger.pid = debugger_pid;
-       debugger.handle_trace = debugger_syscall;
-       debugger.debugee = &debugee;
-       debugger.waiting = 0;
-       debugger.real_wait = 0;
-       debugger.expecting_child = 0;
-
-       debugee.pid = 0;
-       debugee.traced = 0;
-       debugee.stopped = stopped;
-       debugee.event = 0;
-       debugee.zombie = 0;
-       debugee.died = 0;
-       debugee.wait_status = status;
-       debugee.in_context = 1;
-}
-
-int debugger_proxy(int status, int pid)
-{
-       int ret = 0, sig;
-
-       if(WIFSTOPPED(status)){
-               sig = WSTOPSIG(status);
-               if (sig == SIGTRAP)
-                       ret = (*debugger.handle_trace)(&debugger, pid);
-                                                      
-               else if(sig == SIGCHLD){
-                       if(debugger.expecting_child){
-                               ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
-                               debugger.expecting_child = 0;
-                       }
-                       else if(debugger.waiting)
-                               real_wait_return(&debugger);
-                       else {
-                               ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
-                               debugger.real_wait = 1;
-                       }
-               }
-               else ptrace(PTRACE_SYSCALL, debugger.pid, 0, sig);
-       }
-       else if(WIFEXITED(status)){
-               tracer_panic("debugger (pid %d) exited with status %d", 
-                            debugger.pid, WEXITSTATUS(status));
-       }
-       else if(WIFSIGNALED(status)){
-               tracer_panic("debugger (pid %d) exited with signal %d", 
-                            debugger.pid, WTERMSIG(status));
-       }
-       else {
-               tracer_panic("proxy got unknown status (0x%x) on debugger "
-                            "(pid %d)", status, debugger.pid);
-       }
-       return(ret);
-}
-
-void child_proxy(pid_t pid, int status)
-{
-       debugee.event = 1;
-       debugee.wait_status = status;
-
-       if(WIFSTOPPED(status)){
-               debugee.stopped = 1;
-               debugger.expecting_child = 1;
-               kill(debugger.pid, SIGCHLD);
-       }
-       else if(WIFEXITED(status) || WIFSIGNALED(status)){
-               debugee.zombie = 1;
-               debugger.expecting_child = 1;
-               kill(debugger.pid, SIGCHLD);
-       }
-       else panic("proxy got unknown status (0x%x) on child (pid %d)", 
-                  status, pid);
-}
-
-void debugger_parent_signal(int status, int pid)
-{
-       int sig;
-
-       if(WIFSTOPPED(status)){
-               sig = WSTOPSIG(status);
-               if(sig == SIGTRAP) (*parent.handle_trace)(&parent, pid);
-               else ptrace(PTRACE_SYSCALL, pid, 0, sig);
-       }
-}
-
-void fake_child_exit(void)
-{
-       int status, pid;
-
-       child_proxy(1, W_EXITCODE(0, 0));
-       while(debugger.waiting == 1){
-               CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
-               if(pid != debugger.pid){
-                       printk("fake_child_exit - waitpid failed, "
-                              "errno = %d\n", errno);
-                       return;
-               }
-               debugger_proxy(status, debugger.pid);
-       }
-       CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
-       if(pid != debugger.pid){
-               printk("fake_child_exit - waitpid failed, "
-                      "errno = %d\n", errno);
-               return;
-       }
-       if(ptrace(PTRACE_DETACH, debugger.pid, 0, SIGCONT) < 0)
-               printk("fake_child_exit - PTRACE_DETACH failed, errno = %d\n",
-                      errno);
-}
-
-char gdb_init_string[] = 
-"att 1 \n\
-b panic \n\
-b stop \n\
-handle SIGWINCH nostop noprint pass \n\
-";
-
-int start_debugger(char *prog, int startup, int stop, int *fd_out)
-{
-       int slave, child;
-
-       slave = open_gdb_chan();
-       child = fork();
-       if(child == 0){
-               char *tempname = NULL;
-               int fd;
-
-               if(setsid() < 0) perror("setsid");
-               if((dup2(slave, 0) < 0) || (dup2(slave, 1) < 0) || 
-                  (dup2(slave, 2) < 0)){
-                       printk("start_debugger : dup2 failed, errno = %d\n",
-                              errno);
-                       exit(1);
-               }
-               if(ioctl(0, TIOCSCTTY, 0) < 0){
-                       printk("start_debugger : TIOCSCTTY failed, "
-                              "errno = %d\n", errno);
-                       exit(1);
-               }
-               if(tcsetpgrp (1, os_getpid()) < 0){
-                       printk("start_debugger : tcsetpgrp failed, "
-                              "errno = %d\n", errno);
-#ifdef notdef
-                       exit(1);
-#endif
-               }
-               fd = make_tempfile("/tmp/gdb_init-XXXXXX", &tempname, 0);
-               if(fd < 0){
-                       printk("start_debugger : make_tempfile failed,"
-                              "err = %d\n", -fd);
-                       exit(1);
-               }
-               os_write_file(fd, gdb_init_string,
-                             sizeof(gdb_init_string) - 1);
-               if(startup){
-                       if(stop){
-                               os_write_file(fd, "b start_kernel\n",
-                                               strlen("b start_kernel\n"));
-                       }
-                       os_write_file(fd, "c\n", strlen("c\n"));
-               }
-               if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
-                       printk("start_debugger :  PTRACE_TRACEME failed, "
-                              "errno = %d\n", errno);
-                       exit(1);
-               }
-               execlp("gdb", "gdb", "--command", tempname, prog, NULL);
-               printk("start_debugger : exec of gdb failed, errno = %d\n",
-                      errno);
-       }
-       if(child < 0){
-               printk("start_debugger : fork for gdb failed, errno = %d\n",
-                      errno);
-               return(-1);
-       }
-       *fd_out = slave;
-       return(child);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/ptproxy.h b/arch/um/kernel/tt/ptproxy/ptproxy.h
deleted file mode 100644 (file)
index 5eb0285..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**********************************************************************
-ptproxy.h
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-**********************************************************************/
-
-#ifndef __PTPROXY_H
-#define __PTPROXY_H
-
-#include <sys/types.h>
-
-typedef struct debugger debugger_state;
-typedef struct debugee debugee_state;
-
-struct debugger
-{
-       pid_t pid;
-       int wait_options;
-       int *wait_status_ptr;
-       unsigned int waiting : 1;
-       unsigned int real_wait : 1;
-       unsigned int expecting_child : 1;
-       int (*handle_trace) (debugger_state *, pid_t);
-
-       debugee_state *debugee;
-};
-
-struct debugee
-{
-       pid_t pid;
-       int wait_status;
-       unsigned int died : 1;
-       unsigned int event : 1;
-       unsigned int stopped : 1;
-       unsigned int trace_singlestep : 1;
-       unsigned int trace_syscall : 1;
-       unsigned int traced : 1;
-       unsigned int zombie : 1;
-       unsigned int in_context : 1;
-};
-
-extern int debugger_syscall(debugger_state *debugger, pid_t pid);
-extern int debugger_normal_return (debugger_state *debugger, pid_t unused);
-
-extern long proxy_ptrace (struct debugger *, int, pid_t, long, long, pid_t,
-                         int *strace_out);
-extern void debugger_cancelled_return(debugger_state *debugger, int result);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/ptrace.c b/arch/um/kernel/tt/ptproxy/ptrace.c
deleted file mode 100644 (file)
index 4b4f617..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/**********************************************************************
-ptrace.c
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-
-Jeff Dike (jdike@karaya.com) : Modified for integration into uml
-**********************************************************************/
-
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-
-#include "ptproxy.h"
-#include "debug.h"
-#include "kern_util.h"
-#include "ptrace_user.h"
-#include "tt.h"
-#include "os.h"
-
-long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2,
-                 long arg3, long arg4, pid_t child, int *ret)
-{
-       sigset_t relay;
-       long result;
-       int status;
-
-       *ret = 0;
-       if(debugger->debugee->died) return(-ESRCH);
-
-       switch(arg1){
-       case PTRACE_ATTACH:
-               if(debugger->debugee->traced) return(-EPERM);
-
-               debugger->debugee->pid = arg2;
-               debugger->debugee->traced = 1;
-
-               if(is_valid_pid(arg2) && (arg2 != child)){
-                       debugger->debugee->in_context = 0;
-                       kill(arg2, SIGSTOP);
-                       debugger->debugee->event = 1;
-                       debugger->debugee->wait_status = W_STOPCODE(SIGSTOP);
-               }
-               else {
-                       debugger->debugee->in_context = 1;
-                       if(debugger->debugee->stopped) 
-                               child_proxy(child, W_STOPCODE(SIGSTOP));
-                       else kill(child, SIGSTOP);
-               }
-
-               return(0);
-
-       case PTRACE_DETACH:
-               if(!debugger->debugee->traced) return(-EPERM);
-               
-               debugger->debugee->traced = 0;
-               debugger->debugee->pid = 0;
-               if(!debugger->debugee->in_context)
-                       kill(child, SIGCONT);
-
-               return(0);
-
-       case PTRACE_CONT:
-               if(!debugger->debugee->in_context) return(-EPERM);
-               *ret = PTRACE_CONT;
-               return(ptrace(PTRACE_CONT, child, arg3, arg4));
-
-#ifdef UM_HAVE_GETFPREGS
-       case PTRACE_GETFPREGS:
-       {
-               long regs[FP_FRAME_SIZE];
-               int i, result;
-
-               result = ptrace(PTRACE_GETFPREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-               
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
-                              regs[i]);
-               return(result);
-       }
-#endif
-
-#ifdef UM_HAVE_GETFPXREGS
-       case PTRACE_GETFPXREGS:
-       {
-               long regs[FPX_FRAME_SIZE];
-               int i, result;
-
-               result = ptrace(PTRACE_GETFPXREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-               
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       ptrace(PTRACE_POKEDATA, debugger->pid, arg4 + 4 * i,
-                              regs[i]);
-               return(result);
-       }
-#endif
-
-#ifdef UM_HAVE_GETREGS
-       case PTRACE_GETREGS:
-       {
-               long regs[FRAME_SIZE];
-               int i, result;
-
-               result = ptrace(PTRACE_GETREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       ptrace (PTRACE_POKEDATA, debugger->pid,
-                               arg4 + 4 * i, regs[i]);
-               return(result);
-       }
-       break;
-#endif
-
-       case PTRACE_KILL:
-               result = ptrace(PTRACE_KILL, child, arg3, arg4);
-               if(result == -1) return(-errno);
-
-               return(result);
-
-       case PTRACE_PEEKDATA:
-       case PTRACE_PEEKTEXT:
-       case PTRACE_PEEKUSR:
-               /* The value being read out could be -1, so we have to 
-                * check errno to see if there's an error, and zero it
-                * beforehand so we're not faked out by an old error
-                */
-
-               errno = 0;
-               result = ptrace(arg1, child, arg3, 0);
-               if((result == -1) && (errno != 0)) return(-errno);
-
-               result = ptrace(PTRACE_POKEDATA, debugger->pid, arg4, result);
-               if(result == -1) return(-errno);
-                       
-               return(result);
-
-       case PTRACE_POKEDATA:
-       case PTRACE_POKETEXT:
-       case PTRACE_POKEUSR:
-               result = ptrace(arg1, child, arg3, arg4);
-               if(result == -1) return(-errno);
-
-               if(arg1 == PTRACE_POKEUSR) ptrace_pokeuser(arg3, arg4);
-               return(result);
-
-#ifdef UM_HAVE_SETFPREGS
-       case PTRACE_SETFPREGS:
-       {
-               long regs[FP_FRAME_SIZE];
-               int i;
-
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
-                                         arg4 + 4 * i, 0);
-               result = ptrace(PTRACE_SETFPREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-
-               return(result);
-       }
-#endif
-
-#ifdef UM_HAVE_SETFPXREGS
-       case PTRACE_SETFPXREGS:
-       {
-               long regs[FPX_FRAME_SIZE];
-               int i;
-
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       regs[i] = ptrace (PTRACE_PEEKDATA, debugger->pid,
-                                         arg4 + 4 * i, 0);
-               result = ptrace(PTRACE_SETFPXREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-
-               return(result);
-       }
-#endif
-
-#ifdef UM_HAVE_SETREGS
-       case PTRACE_SETREGS:
-       {
-               long regs[FRAME_SIZE];
-               int i;
-
-               for (i = 0; i < sizeof(regs)/sizeof(regs[0]); i++)
-                       regs[i] = ptrace(PTRACE_PEEKDATA, debugger->pid,
-                                        arg4 + 4 * i, 0);
-               result = ptrace(PTRACE_SETREGS, child, 0, regs);
-               if(result == -1) return(-errno);
-
-               return(result);
-       }
-#endif
-
-       case PTRACE_SINGLESTEP:
-               if(!debugger->debugee->in_context) return(-EPERM);
-               sigemptyset(&relay);
-               sigaddset(&relay, SIGSEGV);
-               sigaddset(&relay, SIGILL);
-               sigaddset(&relay, SIGBUS);
-               result = ptrace(PTRACE_SINGLESTEP, child, arg3, arg4);
-               if(result == -1) return(-errno);
-               
-               status = wait_for_stop(child, SIGTRAP, PTRACE_SINGLESTEP,
-                                      &relay);
-               child_proxy(child, status);
-               return(result);
-
-       case PTRACE_SYSCALL:
-               if(!debugger->debugee->in_context) return(-EPERM);
-               result = ptrace(PTRACE_SYSCALL, child, arg3, arg4);
-               if(result == -1) return(-errno);
-
-               *ret = PTRACE_SYSCALL;
-               return(result);
-
-       case PTRACE_TRACEME:
-       default:
-               return(-EINVAL);
-       }
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/sysdep.c b/arch/um/kernel/tt/ptproxy/sysdep.c
deleted file mode 100644 (file)
index e0e1ab0..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/**********************************************************************
-sysdep.c
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-**********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <linux/unistd.h>
-#include "ptrace_user.h"
-#include "user.h"
-#include "os.h"
-
-int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, 
-               long *arg5)
-{
-       *arg1 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG1_OFFSET, 0);
-       *arg2 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG2_OFFSET, 0);
-       *arg3 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG3_OFFSET, 0);
-       *arg4 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG4_OFFSET, 0);
-       *arg5 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG5_OFFSET, 0);
-       return(ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, 0));
-}
-
-void syscall_cancel(pid_t pid, int result)
-{
-       if((ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
-                  __NR_getpid) < 0) ||
-          (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) ||
-          (wait_for_stop(pid, SIGTRAP, PTRACE_SYSCALL, NULL) < 0) ||
-          (ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, result) < 0) ||
-          (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0))
-               printk("ptproxy: couldn't cancel syscall: errno = %d\n", 
-                      errno);
-}
-
-void syscall_set_result(pid_t pid, long result)
-{
-       ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, result);
-}
-
-void syscall_continue(pid_t pid)
-{
-       ptrace(PTRACE_SYSCALL, pid, 0, 0);
-}
-
-int syscall_pause(pid_t pid) 
-{
-       if(ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, __NR_pause) < 0){
-               printk("syscall_change - ptrace failed, errno = %d\n", errno);
-               return(-1);
-       }
-       return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/sysdep.h b/arch/um/kernel/tt/ptproxy/sysdep.h
deleted file mode 100644 (file)
index 735f488..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/**********************************************************************
-sysdep.h
-
-Copyright (C) 1999 Lars Brinkhoff.
-Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
-See the file COPYING for licensing terms and conditions.
-**********************************************************************/
-
-extern int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, 
-                      long *arg4, long *arg5);
-extern void syscall_cancel (pid_t pid, long result);
-extern void syscall_set_result (pid_t pid, long result);
-extern void syscall_continue (pid_t pid);
-extern int syscall_pause(pid_t pid);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/wait.c b/arch/um/kernel/tt/ptproxy/wait.c
deleted file mode 100644 (file)
index bdd4af4..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/**********************************************************************
-wait.c
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-
-**********************************************************************/
-
-#include <errno.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-#include "ptproxy.h"
-#include "sysdep.h"
-#include "wait.h"
-#include "ptrace_user.h"
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-
-int proxy_wait_return(struct debugger *debugger, pid_t unused)
-{
-       debugger->waiting = 0;
-
-       if(debugger->debugee->died || (debugger->wait_options & __WCLONE)){
-               debugger_cancelled_return(debugger, -ECHILD);
-               return(0);
-       }
-
-       if(debugger->debugee->zombie && debugger->debugee->event)
-               debugger->debugee->died = 1;
-
-       if(debugger->debugee->event){
-               debugger->debugee->event = 0;
-               ptrace(PTRACE_POKEDATA, debugger->pid,
-                      debugger->wait_status_ptr, 
-                      debugger->debugee->wait_status);
-               /* if (wait4)
-                  ptrace (PTRACE_POKEDATA, pid, rusage_ptr, ...); */
-               debugger_cancelled_return(debugger, debugger->debugee->pid);
-               return(0);
-       }
-
-       /* pause will return -EINTR, which happens to be right for wait */
-       debugger_normal_return(debugger, -1);
-       return(0);
-}
-
-int parent_wait_return(struct debugger *debugger, pid_t unused)
-{
-       return(debugger_normal_return(debugger, -1));
-}
-
-int real_wait_return(struct debugger *debugger)
-{
-       unsigned long ip;
-       int pid;
-
-       pid = debugger->pid;
-
-       ip = ptrace(PTRACE_PEEKUSR, pid, PT_IP_OFFSET, 0);
-       IP_RESTART_SYSCALL(ip);
-
-       if(ptrace(PTRACE_POKEUSR, pid, PT_IP_OFFSET, ip) < 0)
-               tracer_panic("real_wait_return : Failed to restart system "
-                            "call, errno = %d\n", errno);
-
-       if((ptrace(PTRACE_SYSCALL, debugger->pid, 0, SIGCHLD) < 0) ||
-          (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
-          (ptrace(PTRACE_SYSCALL, debugger->pid, 0, 0) < 0) ||
-          debugger_normal_return(debugger, -1))
-               tracer_panic("real_wait_return : gdb failed to wait, "
-                            "errno = %d\n", errno);
-       return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/ptproxy/wait.h b/arch/um/kernel/tt/ptproxy/wait.h
deleted file mode 100644 (file)
index 542e73e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/**********************************************************************
-wait.h
-
-Copyright (C) 1999 Lars Brinkhoff.  See the file COPYING for licensing
-terms and conditions.
-**********************************************************************/
-
-#ifndef __PTPROXY_WAIT_H
-#define __PTPROXY_WAIT_H
-
-extern int proxy_wait_return(struct debugger *debugger, pid_t unused);
-extern int real_wait_return(struct debugger *debugger);
-extern int parent_wait_return(struct debugger *debugger, pid_t unused);
-
-#endif
diff --git a/arch/um/kernel/tt/syscall_kern.c b/arch/um/kernel/tt/syscall_kern.c
deleted file mode 100644 (file)
index 293caa6..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/types.h"
-#include "linux/utime.h"
-#include "linux/sys.h"
-#include "linux/ptrace.h"
-#include "asm/unistd.h"
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "asm/stat.h"
-#include "sysdep/syscalls.h"
-#include "sysdep/sigcontext.h"
-#include "kern_util.h"
-#include "syscall.h"
-
-void syscall_handler_tt(int sig, struct pt_regs *regs)
-{
-       void *sc;
-       long result;
-       int syscall;
-
-       sc = UPT_SC(&regs->regs);
-       SC_START_SYSCALL(sc);
-
-       syscall = UPT_SYSCALL_NR(&regs->regs);
-       syscall_trace(&regs->regs, 0);
-
-       current->thread.nsyscalls++;
-       nsyscalls++;
-
-       if((syscall >= NR_syscalls) || (syscall < 0))
-               result = -ENOSYS;
-       else result = EXECUTE_SYSCALL(syscall, regs);
-
-       /* regs->sc may have changed while the system call ran (there may
-        * have been an interrupt or segfault), so it needs to be refreshed.
-        */
-       UPT_SC(&regs->regs) = sc;
-
-       SC_SET_SYSCALL_RETURN(sc, result);
-
-       syscall_trace(&regs->regs, 1);
-}
diff --git a/arch/um/kernel/tt/syscall_user.c b/arch/um/kernel/tt/syscall_user.c
deleted file mode 100644 (file)
index f52b47a..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <asm/unistd.h>
-#include "sysdep/ptrace.h"
-#include "sigcontext.h"
-#include "ptrace_user.h"
-#include "task.h"
-#include "kern_util.h"
-#include "syscall.h"
-#include "tt.h"
-
-void do_sigtrap(void *task)
-{
-       UPT_SYSCALL_NR(TASK_REGS(task)) = -1;
-}
-
-void do_syscall(void *task, int pid, int local_using_sysemu)
-{
-       unsigned long proc_regs[FRAME_SIZE];
-
-       if(ptrace_getregs(pid, proc_regs) < 0)
-               tracer_panic("Couldn't read registers");
-
-       UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs);
-
-#ifdef UPT_ORIGGPR2
-        UPT_ORIGGPR2(TASK_REGS(task)) = REGS_ORIGGPR2(proc_regs);
-#endif
-
-       if(((unsigned long *) PT_IP(proc_regs) >= &_stext) &&
-          ((unsigned long *) PT_IP(proc_regs) <= &_etext))
-               tracer_panic("I'm tracing myself and I can't get out");
-
-       /* advanced sysemu mode set syscall number to -1 automatically */
-       if (local_using_sysemu==2)
-               return;
-
-       /* syscall number -1 in sysemu skips syscall restarting in host */
-       if(ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
-                 local_using_sysemu ? -1 : __NR_getpid) < 0)
-               tracer_panic("do_syscall : Nullifying syscall failed, "
-                            "errno = %d", errno);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/tlb.c b/arch/um/kernel/tt/tlb.c
deleted file mode 100644 (file)
index 7caa24f..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Copyright 2003 PathScale, Inc.
- * Licensed under the GPL
- */
-
-#include "linux/stddef.h"
-#include "linux/kernel.h"
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "asm/page.h"
-#include "asm/pgtable.h"
-#include "asm/uaccess.h"
-#include "asm/tlbflush.h"
-#include "mem_user.h"
-#include "os.h"
-#include "tlb.h"
-
-static int do_ops(union mm_context *mmu, struct host_vm_op *ops, int last,
-                   int finished, void **flush)
-{
-       struct host_vm_op *op;
-        int i, ret=0;
-
-        for(i = 0; i <= last && !ret; i++){
-               op = &ops[i];
-               switch(op->type){
-               case MMAP:
-                        ret = os_map_memory((void *) op->u.mmap.addr,
-                                            op->u.mmap.fd, op->u.mmap.offset,
-                                            op->u.mmap.len, op->u.mmap.r,
-                                            op->u.mmap.w, op->u.mmap.x);
-                       break;
-               case MUNMAP:
-                        ret = os_unmap_memory((void *) op->u.munmap.addr,
-                                              op->u.munmap.len);
-                       break;
-               case MPROTECT:
-                        ret = protect_memory(op->u.mprotect.addr,
-                                             op->u.munmap.len,
-                                             op->u.mprotect.r,
-                                             op->u.mprotect.w,
-                                             op->u.mprotect.x, 1);
-                       protect_memory(op->u.mprotect.addr, op->u.munmap.len,
-                                      op->u.mprotect.r, op->u.mprotect.w,
-                                      op->u.mprotect.x, 1);
-                       break;
-               default:
-                       printk("Unknown op type %d in do_ops\n", op->type);
-                       break;
-               }
-       }
-
-       return ret;
-}
-
-static void fix_range(struct mm_struct *mm, unsigned long start_addr, 
-                     unsigned long end_addr, int force)
-{
-        if((current->thread.mode.tt.extern_pid != -1) &&
-           (current->thread.mode.tt.extern_pid != os_getpid()))
-                panic("fix_range fixing wrong address space, current = 0x%p",
-                      current);
-
-        fix_range_common(mm, start_addr, end_addr, force, do_ops);
-}
-
-atomic_t vmchange_seq = ATOMIC_INIT(1);
-
-void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end)
-{
-        if(flush_tlb_kernel_range_common(start, end))
-                atomic_inc(&vmchange_seq);
-}
-
-void flush_tlb_kernel_vm_tt(void)
-{
-        flush_tlb_kernel_range(start_vm, end_vm);
-}
-
-void __flush_tlb_one_tt(unsigned long addr)
-{
-        flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
-}
-  
-void flush_tlb_range_tt(struct vm_area_struct *vma, unsigned long start, 
-                    unsigned long end)
-{
-       if(vma->vm_mm != current->mm) return;
-
-       /* Assumes that the range start ... end is entirely within
-        * either process memory or kernel vm
-        */
-       if((start >= start_vm) && (start < end_vm)){
-               if(flush_tlb_kernel_range_common(start, end))
-                       atomic_inc(&vmchange_seq);
-       }
-       else fix_range(vma->vm_mm, start, end, 0);
-}
-
-void flush_tlb_mm_tt(struct mm_struct *mm)
-{
-       unsigned long seq;
-
-       if(mm != current->mm) return;
-
-       fix_range(mm, 0, STACK_TOP, 0);
-
-       seq = atomic_read(&vmchange_seq);
-       if(current->thread.mode.tt.vm_seq == seq)
-               return;
-       current->thread.mode.tt.vm_seq = seq;
-       flush_tlb_kernel_range_common(start_vm, end_vm);
-}
-
-void force_flush_all_tt(void)
-{
-       fix_range(current->mm, 0, STACK_TOP, 1);
-       flush_tlb_kernel_range_common(start_vm, end_vm);
-}
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
deleted file mode 100644 (file)
index c235883..0000000
+++ /dev/null
@@ -1,461 +0,0 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <sched.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include "user.h"
-#include "sysdep/ptrace.h"
-#include "sigcontext.h"
-#include "sysdep/sigcontext.h"
-#include "os.h"
-#include "mem_user.h"
-#include "process.h"
-#include "kern_util.h"
-#include "chan_user.h"
-#include "ptrace_user.h"
-#include "irq_user.h"
-#include "mode.h"
-#include "tt.h"
-
-static int tracer_winch[2];
-
-int is_tracer_winch(int pid, int fd, void *data)
-{
-       if(pid != os_getpgrp())
-               return(0);
-
-       register_winch_irq(tracer_winch[0], fd, -1, data);
-       return(1);
-}
-
-static void tracer_winch_handler(int sig)
-{
-       int n;
-       char c = 1;
-
-       n = os_write_file(tracer_winch[1], &c, sizeof(c));
-       if(n != sizeof(c))
-               printk("tracer_winch_handler - write failed, err = %d\n", -n);
-}
-
-/* Called only by the tracing thread during initialization */
-
-static void setup_tracer_winch(void)
-{
-       int err;
-
-       err = os_pipe(tracer_winch, 1, 1);
-       if(err < 0){
-               printk("setup_tracer_winch : os_pipe failed, err = %d\n", -err);
-               return;
-       }
-       signal(SIGWINCH, tracer_winch_handler);
-}
-
-void attach_process(int pid)
-{
-       if((ptrace(PTRACE_ATTACH, pid, 0, 0) < 0) ||
-          (ptrace(PTRACE_CONT, pid, 0, 0) < 0))
-               tracer_panic("OP_FORK failed to attach pid");
-       wait_for_stop(pid, SIGSTOP, PTRACE_CONT, NULL);
-       if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)
-               tracer_panic("OP_FORK: PTRACE_SETOPTIONS failed, errno = %d", errno);
-       if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
-               tracer_panic("OP_FORK failed to continue process");
-}
-
-void tracer_panic(char *format, ...)
-{
-       va_list ap;
-
-       va_start(ap, format);
-       vprintf(format, ap);
-       va_end(ap);
-       printf("\n");
-       while(1) pause();
-}
-
-static void tracer_segv(int sig, struct sigcontext sc)
-{
-        struct faultinfo fi;
-        GET_FAULTINFO_FROM_SC(fi, &sc);
-       printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n",
-               FAULT_ADDRESS(fi), SC_IP(&sc));
-       while(1)
-               pause();
-}
-
-/* Changed early in boot, and then only read */
-int debug = 0;
-int debug_stop = 1;
-int debug_parent = 0;
-int honeypot = 0;
-
-static int signal_tramp(void *arg)
-{
-       int (*proc)(void *);
-
-       if(honeypot && munmap((void *) (host_task_size - 0x10000000),
-                             0x10000000)) 
-               panic("Unmapping stack failed");
-       if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0)
-               panic("ptrace PTRACE_TRACEME failed");
-       os_stop_process(os_getpid());
-       change_sig(SIGWINCH, 0);
-       signal(SIGUSR1, SIG_IGN);
-       change_sig(SIGCHLD, 0);
-       signal(SIGSEGV, (__sighandler_t) sig_handler);
-       set_cmdline("(idle thread)");
-       set_init_pid(os_getpid());
-       init_irq_signals(0);
-       proc = arg;
-       return((*proc)(NULL));
-}
-
-static void sleeping_process_signal(int pid, int sig)
-{
-       switch(sig){
-       /* These two result from UML being ^Z-ed and bg-ed.  PTRACE_CONT is
-        * right because the process must be in the kernel already.
-        */
-       case SIGCONT:
-       case SIGTSTP:
-               if(ptrace(PTRACE_CONT, pid, 0, sig) < 0)
-                       tracer_panic("sleeping_process_signal : Failed to "
-                                    "continue pid %d, signal = %d, "
-                                    "errno = %d\n", pid, sig, errno);
-               break;
-
-       /* This happens when the debugger (e.g. strace) is doing system call 
-        * tracing on the kernel.  During a context switch, the current task
-        * will be set to the incoming process and the outgoing process will
-        * hop into write and then read.  Since it's not the current process
-        * any more, the trace of those will land here.  So, we need to just 
-        * PTRACE_SYSCALL it.
-        */
-       case (SIGTRAP + 0x80):
-               if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
-                       tracer_panic("sleeping_process_signal : Failed to "
-                                    "PTRACE_SYSCALL pid %d, errno = %d\n",
-                                    pid, errno);
-               break;
-       case SIGSTOP:
-               break;
-       default:
-               tracer_panic("sleeping process %d got unexpected "
-                            "signal : %d\n", pid, sig);
-               break;
-       }
-}
-
-/* Accessed only by the tracing thread */
-int debugger_pid = -1;
-int debugger_parent = -1;
-int debugger_fd = -1;
-int gdb_pid = -1;
-
-struct {
-       int pid;
-       int signal;
-       unsigned long addr;
-       struct timeval time;
-} signal_record[1024][32];
-
-int signal_index[32];
-int nsignals = 0;
-int debug_trace = 0;
-
-extern void signal_usr1(int sig);
-
-int tracing_pid = -1;
-
-int tracer(int (*init_proc)(void *), void *sp)
-{
-       void *task = NULL;
-       int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0;
-       int proc_id = 0, n, err, old_tracing = 0, strace = 0;
-       int local_using_sysemu = 0;
-
-       signal(SIGPIPE, SIG_IGN);
-       setup_tracer_winch();
-       tracing_pid = os_getpid();
-       printf("tracing thread pid = %d\n", tracing_pid);
-
-       pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc);
-       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-       if(n < 0){
-               printf("waitpid on idle thread failed, errno = %d\n", errno);
-               exit(1);
-       }
-       if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) {
-               printf("Failed to PTRACE_SETOPTIONS for idle thread, errno = %d\n", errno);
-               exit(1);
-       }
-       if((ptrace(PTRACE_CONT, pid, 0, 0) < 0)){
-               printf("Failed to continue idle thread, errno = %d\n", errno);
-               exit(1);
-       }
-
-       signal(SIGSEGV, (sighandler_t) tracer_segv);
-       signal(SIGUSR1, signal_usr1);
-       if(debug_trace){
-               printf("Tracing thread pausing to be attached\n");
-               stop();
-       }
-       if(debug){
-               if(gdb_pid != -1) 
-                       debugger_pid = attach_debugger(pid, gdb_pid, 1);
-               else debugger_pid = init_ptrace_proxy(pid, 1, debug_stop);
-               if(debug_parent){
-                       debugger_parent = os_process_parent(debugger_pid);
-                       init_parent_proxy(debugger_parent);
-                       err = attach(debugger_parent);
-                       if(err){
-                               printf("Failed to attach debugger parent %d, "
-                                      "errno = %d\n", debugger_parent, -err);
-                               debugger_parent = -1;
-                       }
-                       else {
-                               if(ptrace(PTRACE_SYSCALL, debugger_parent, 
-                                         0, 0) < 0){
-                                       printf("Failed to continue debugger "
-                                              "parent, errno = %d\n", errno);
-                                       debugger_parent = -1;
-                               }
-                       }
-               }
-       }
-       set_cmdline("(tracing thread)");
-       while(1){
-               CATCH_EINTR(pid = waitpid(-1, &status, WUNTRACED));
-               if(pid <= 0){
-                       if(errno != ECHILD){
-                               printf("wait failed - errno = %d\n", errno);
-                       }
-                       continue;
-               }
-               if(pid == debugger_pid){
-                       int cont = 0;
-
-                       if(WIFEXITED(status) || WIFSIGNALED(status))
-                               debugger_pid = -1;
-                       /* XXX Figure out how to deal with gdb and SMP */
-                       else cont = debugger_signal(status, cpu_tasks[0].pid);
-                       if(cont == PTRACE_SYSCALL) strace = 1;
-                       continue;
-               }
-               else if(pid == debugger_parent){
-                       debugger_parent_signal(status, pid);
-                       continue;
-               }
-               nsignals++;
-               if(WIFEXITED(status)) ;
-#ifdef notdef
-               {
-                       printf("Child %d exited with status %d\n", pid, 
-                              WEXITSTATUS(status));
-               }
-#endif
-               else if(WIFSIGNALED(status)){
-                       sig = WTERMSIG(status);
-                       if(sig != 9){
-                               printf("Child %d exited with signal %d\n", pid,
-                                      sig);
-                       }
-               }
-               else if(WIFSTOPPED(status)){
-                       proc_id = pid_to_processor_id(pid);
-                       sig = WSTOPSIG(status);
-                       if(proc_id == -1){
-                               sleeping_process_signal(pid, sig);
-                               continue;
-                       }
-
-                       task = cpu_tasks[proc_id].task;
-                       tracing = is_tracing(task);
-                       old_tracing = tracing;
-
-                       /* Assume: no syscall, when coming from user */
-                       if ( tracing )
-                               do_sigtrap(task);
-
-                       switch(sig){
-                       case SIGUSR1:
-                               sig = 0;
-                               op = do_proc_op(task, proc_id);
-                               switch(op){
-                               /*
-                                * This is called when entering user mode; after
-                                * this, we start intercepting syscalls.
-                                *
-                                * In fact, a process is started in kernel mode,
-                                * so with is_tracing() == 0 (and that is reset
-                                * when executing syscalls, since UML kernel has
-                                * the right to do syscalls);
-                                */
-                               case OP_TRACE_ON:
-                                       arch_leave_kernel(task, pid);
-                                       tracing = 1;
-                                       break;
-                               case OP_REBOOT:
-                               case OP_HALT:
-                                       unmap_physmem();
-                                       kmalloc_ok = 0;
-                                       os_kill_ptraced_process(pid, 0);
-                                       /* Now let's reap remaining zombies */
-                                       errno = 0;
-                                       do {
-                                               waitpid(-1, &status,
-                                                       WUNTRACED);
-                                       } while (errno != ECHILD);
-                                       return(op == OP_REBOOT);
-                               case OP_NONE:
-                                       printf("Detaching pid %d\n", pid);
-                                       detach(pid, SIGSTOP);
-                                       continue;
-                               default:
-                                       break;
-                               }
-                               /* OP_EXEC switches host processes on us,
-                                * we want to continue the new one.
-                                */
-                               pid = cpu_tasks[proc_id].pid;
-                               break;
-                       case (SIGTRAP + 0x80):
-                               if(!tracing && (debugger_pid != -1)){
-                                       child_signal(pid, status & 0x7fff);
-                                       continue;
-                               }
-                               tracing = 0;
-                               /* local_using_sysemu has been already set
-                                * below, since if we are here, is_tracing() on
-                                * the traced task was 1, i.e. the process had
-                                * already run through one iteration of the
-                                * loop which executed a OP_TRACE_ON request.*/
-                               do_syscall(task, pid, local_using_sysemu);
-                               sig = SIGUSR2;
-                               break;
-                       case SIGTRAP:
-                               if(!tracing && (debugger_pid != -1)){
-                                       child_signal(pid, status);
-                                       continue;
-                               }
-                               tracing = 0;
-                               break;
-                       case SIGPROF:
-                               if(tracing) sig = 0;
-                               break;
-                       case SIGCHLD:
-                       case SIGHUP:
-                               sig = 0;
-                               break;
-                       case SIGSEGV:
-                       case SIGIO:
-                       case SIGALRM:
-                       case SIGVTALRM:
-                       case SIGFPE:
-                       case SIGBUS:
-                       case SIGILL:
-                       case SIGWINCH:
-
-                       default:
-                               tracing = 0;
-                               break;
-                       }
-                       set_tracing(task, tracing);
-
-                       if(!tracing && old_tracing)
-                               arch_enter_kernel(task, pid);
-
-                       if(!tracing && (debugger_pid != -1) && (sig != 0) &&
-                               (sig != SIGALRM) && (sig != SIGVTALRM) &&
-                               (sig != SIGSEGV) && (sig != SIGTRAP) &&
-                               (sig != SIGUSR2) && (sig != SIGIO) &&
-                               (sig != SIGFPE)){
-                               child_signal(pid, status);
-                               continue;
-                       }
-
-                       local_using_sysemu = get_using_sysemu();
-
-                       if(tracing)
-                               cont_type = SELECT_PTRACE_OPERATION(local_using_sysemu,
-                                                                   singlestepping(task));
-                       else if((debugger_pid != -1) && strace)
-                               cont_type = PTRACE_SYSCALL;
-                       else
-                               cont_type = PTRACE_CONT;
-
-                       if(ptrace(cont_type, pid, 0, sig) != 0){
-                               tracer_panic("ptrace failed to continue "
-                                            "process - errno = %d\n", 
-                                            errno);
-                       }
-               }
-       }
-       return(0);
-}
-
-static int __init uml_debug_setup(char *line, int *add)
-{
-       char *next;
-
-       debug = 1;
-       *add = 0;
-       if(*line != '=') return(0);
-       line++;
-
-       while(line != NULL){
-               next = strchr(line, ',');
-               if(next) *next++ = '\0';
-               
-               if(!strcmp(line, "go")) debug_stop = 0;
-               else if(!strcmp(line, "parent")) debug_parent = 1;
-               else printf("Unknown debug option : '%s'\n", line);
-
-               line = next;
-       }
-       return(0);
-}
-
-__uml_setup("debug", uml_debug_setup,
-"debug\n"
-"    Starts up the kernel under the control of gdb. See the \n"
-"    kernel debugging tutorial and the debugging session pages\n"
-"    at http://user-mode-linux.sourceforge.net/ for more information.\n\n"
-);
-
-static int __init uml_debugtrace_setup(char *line, int *add)
-{
-       debug_trace = 1;
-       return 0;
-}
-__uml_setup("debugtrace", uml_debugtrace_setup,
-"debugtrace\n"
-"    Causes the tracing thread to pause until it is attached by a\n"
-"    debugger and continued.  This is mostly for debugging crashes\n"
-"    early during boot, and should be pretty much obsoleted by\n"
-"    the debug switch.\n\n"
-);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c
deleted file mode 100644 (file)
index 3032eb5..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-#include "kern_util.h"
-#include "task.h"
-#include "tt.h"
-#include "os.h"
-
-void sig_handler_common_tt(int sig, void *sc_ptr)
-{
-       struct sigcontext *sc = sc_ptr;
-       struct tt_regs save_regs, *r;
-       int save_errno = errno, is_user = 0;
-       void (*handler)(int, union uml_pt_regs *);
-
-       /* This is done because to allow SIGSEGV to be delivered inside a SEGV
-        * handler.  This can happen in copy_user, and if SEGV is disabled,
-        * the process will die.
-        */
-       if(sig == SIGSEGV)
-               change_sig(SIGSEGV, 1);
-
-       r = &TASK_REGS(get_current())->tt;
-        if ( sig == SIGFPE || sig == SIGSEGV ||
-             sig == SIGBUS || sig == SIGILL ||
-             sig == SIGTRAP ) {
-                GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
-        }
-       save_regs = *r;
-       if (sc)
-               is_user = user_context(SC_SP(sc));
-       r->sc = sc;
-       if(sig != SIGUSR2) 
-               r->syscall = -1;
-
-       handler = sig_info[sig];
-
-       /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
-       if (sig != SIGIO && sig != SIGWINCH &&
-           sig != SIGVTALRM && sig != SIGALRM)
-               unblock_signals();
-
-       handler(sig, (union uml_pt_regs *) r);
-
-       if(is_user){
-               interrupt_end();
-               block_signals();
-               set_user_mode(NULL);
-       }
-       *r = save_regs;
-       errno = save_errno;
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/uaccess.c b/arch/um/kernel/tt/uaccess.c
deleted file mode 100644 (file)
index 1cb6072..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/sched.h"
-#include "asm/uaccess.h"
-
-int copy_from_user_tt(void *to, const void __user *from, int n)
-{
-       if(!access_ok(VERIFY_READ, from, n))
-               return(n);
-
-       return(__do_copy_from_user(to, from, n, &current->thread.fault_addr,
-                                  &current->thread.fault_catcher));
-}
-
-int copy_to_user_tt(void __user *to, const void *from, int n)
-{
-       if(!access_ok(VERIFY_WRITE, to, n))
-               return(n);
-
-       return(__do_copy_to_user(to, from, n, &current->thread.fault_addr,
-                                &current->thread.fault_catcher));
-}
-
-int strncpy_from_user_tt(char *dst, const char __user *src, int count)
-{
-       int n;
-
-       if(!access_ok(VERIFY_READ, src, 1))
-               return(-EFAULT);
-
-       n = __do_strncpy_from_user(dst, src, count,
-                                  &current->thread.fault_addr,
-                                  &current->thread.fault_catcher);
-       if(n < 0) return(-EFAULT);
-       return(n);
-}
-
-int __clear_user_tt(void __user *mem, int len)
-{
-       return(__do_clear_user(mem, len,
-                              &current->thread.fault_addr,
-                              &current->thread.fault_catcher));
-}
-
-int clear_user_tt(void __user *mem, int len)
-{
-       if(!access_ok(VERIFY_WRITE, mem, len))
-               return(len);
-
-       return(__do_clear_user(mem, len, &current->thread.fault_addr,
-                              &current->thread.fault_catcher));
-}
-
-int strnlen_user_tt(const void __user *str, int len)
-{
-       return(__do_strnlen_user(str, len,
-                                &current->thread.fault_addr,
-                                &current->thread.fault_catcher));
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c
deleted file mode 100644 (file)
index 0e5c82c..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/* 
- * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <string.h>
-#include "uml_uaccess.h"
-#include "task.h"
-#include "kern_util.h"
-#include "os.h"
-#include "longjmp.h"
-
-int __do_copy_from_user(void *to, const void *from, int n,
-                       void **fault_addr, void **fault_catcher)
-{
-       struct tt_regs save = TASK_REGS(get_current())->tt;
-       unsigned long fault;
-       int faulted;
-
-       fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
-                              __do_copy, &faulted);
-       TASK_REGS(get_current())->tt = save;
-
-       if(!faulted)
-               return 0;
-       else if (fault)
-               return n - (fault - (unsigned long) from);
-       else
-               /* In case of a general protection fault, we don't have the
-                * fault address, so NULL is used instead. Pretend we didn't
-                * copy anything. */
-               return n;
-}
-
-static void __do_strncpy(void *dst, const void *src, int count)
-{
-       strncpy(dst, src, count);
-}      
-
-int __do_strncpy_from_user(char *dst, const char *src, unsigned long count,
-                          void **fault_addr, void **fault_catcher)
-{
-       struct tt_regs save = TASK_REGS(get_current())->tt;
-       unsigned long fault;
-       int faulted;
-
-       fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher,
-                              __do_strncpy, &faulted);
-       TASK_REGS(get_current())->tt = save;
-
-       if(!faulted) return(strlen(dst));
-       else return(-1);
-}
-
-static void __do_clear(void *to, const void *from, int n)
-{
-       memset(to, 0, n);
-}      
-
-int __do_clear_user(void *mem, unsigned long len,
-                   void **fault_addr, void **fault_catcher)
-{
-       struct tt_regs save = TASK_REGS(get_current())->tt;
-       unsigned long fault;
-       int faulted;
-
-       fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher,
-                              __do_clear, &faulted);
-       TASK_REGS(get_current())->tt = save;
-
-       if(!faulted) return(0);
-       else return(len - (fault - (unsigned long) mem));
-}
-
-int __do_strnlen_user(const char *str, unsigned long n,
-                     void **fault_addr, void **fault_catcher)
-{
-       struct tt_regs save = TASK_REGS(get_current())->tt;
-       int ret;
-       unsigned long *faddrp = (unsigned long *)fault_addr;
-       jmp_buf jbuf;
-
-       *fault_catcher = &jbuf;
-       if(UML_SETJMP(&jbuf) == 0)
-               ret = strlen(str) + 1;
-       else ret = *faddrp - (unsigned long) str;
-
-       *fault_addr = NULL;
-       *fault_catcher = NULL;
-
-       TASK_REGS(get_current())->tt = save;
-       return ret;
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 054e3de..d7436aa 100644 (file)
@@ -18,7 +18,7 @@ void __do_copy(void *to, const void *from, int n)
 
 
 int __do_copy_to_user(void *to, const void *from, int n,
-                     void **fault_addr, void **fault_catcher)
+                     void **fault_addr, jmp_buf **fault_catcher)
 {
        unsigned long fault;
        int faulted;
index ecc458f..f1c7139 100644 (file)
@@ -1,46 +1,24 @@
 /*
- * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
-#include "linux/sched.h"
-#include "linux/notifier.h"
-#include "linux/mm.h"
-#include "linux/types.h"
-#include "linux/tty.h"
-#include "linux/init.h"
-#include "linux/bootmem.h"
-#include "linux/spinlock.h"
-#include "linux/utsname.h"
-#include "linux/sysrq.h"
-#include "linux/seq_file.h"
 #include "linux/delay.h"
+#include "linux/mm.h"
 #include "linux/module.h"
+#include "linux/seq_file.h"
+#include "linux/string.h"
 #include "linux/utsname.h"
-#include "asm/page.h"
 #include "asm/pgtable.h"
-#include "asm/ptrace.h"
-#include "asm/elf.h"
-#include "asm/user.h"
+#include "asm/processor.h"
 #include "asm/setup.h"
-#include "ubd_user.h"
-#include "asm/current.h"
-#include "kern_util.h"
-#include "as-layout.h"
 #include "arch.h"
+#include "as-layout.h"
+#include "init.h"
 #include "kern.h"
 #include "mem_user.h"
-#include "mem.h"
-#include "initrd.h"
-#include "init.h"
 #include "os.h"
-#include "choose-mode.h"
-#include "mode_kern.h"
-#include "mode.h"
-#ifdef UML_CONFIG_MODE_SKAS
 #include "skas.h"
-#endif
 
 #define DEFAULT_COMMAND_LINE "root=98:0"
 
@@ -53,7 +31,7 @@ static void __init add_arg(char *arg)
                printf("add_arg: Too many command line arguments!\n");
                exit(1);
        }
-       if(strlen(command_line) > 0)
+       if (strlen(command_line) > 0)
                strcat(command_line, " ");
        strcat(command_line, arg);
 }
@@ -70,8 +48,8 @@ struct cpuinfo_um boot_cpu_data = {
 
 unsigned long thread_saved_pc(struct task_struct *task)
 {
-       return os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
-                                             task));
+       /* FIXME: Need to look up userspace_pid by cpu */
+       return os_process_pc(userspace_pid[0]);
 }
 
 /* Changed in setup_arch, which is called in early boot */
@@ -90,7 +68,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
        seq_printf(m, "processor\t: %d\n", index);
        seq_printf(m, "vendor_id\t: User Mode Linux\n");
        seq_printf(m, "model name\t: UML\n");
-       seq_printf(m, "mode\t\t: %s\n", CHOOSE_MODE("tt", "skas"));
+       seq_printf(m, "mode\t\t: skas\n");
        seq_printf(m, "host\t\t: %s\n", host_info);
        seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
                   loops_per_jiffy/(500000/HZ),
@@ -132,44 +110,13 @@ unsigned long end_vm;
 /* Set in uml_ncpus_setup */
 int ncpus = 1;
 
-#ifdef CONFIG_CMDLINE_ON_HOST
-/* Pointer set in linux_main, the array itself is private to each thread,
- * and changed at address space creation time so this poses no concurrency
- * problems.
- */
-static char *argv1_begin = NULL;
-static char *argv1_end = NULL;
-#endif
-
 /* Set in early boot */
 static int have_root __initdata = 0;
 
 /* Set in uml_mem_setup and modified in linux_main */
 long long physmem_size = 32 * 1024 * 1024;
 
-void set_cmdline(char *cmd)
-{
-#ifdef CONFIG_CMDLINE_ON_HOST
-       char *umid, *ptr;
-
-       if(CHOOSE_MODE(honeypot, 0)) return;
-
-       umid = get_umid();
-       if(*umid != '\0'){
-               snprintf(argv1_begin, 
-                        (argv1_end - argv1_begin) * sizeof(*ptr), 
-                        "(%s) ", umid);
-               ptr = &argv1_begin[strlen(argv1_begin)];
-       }
-       else ptr = argv1_begin;
-
-       snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), "[%s]", cmd);
-       memset(argv1_begin + strlen(argv1_begin), '\0', 
-              argv1_end - argv1_begin - strlen(argv1_begin));
-#endif
-}
-
-static char *usage_string = 
+static char *usage_string =
 "User Mode Linux v%s\n"
 "      available at http://user-mode-linux.sourceforge.net/\n\n";
 
@@ -201,13 +148,10 @@ __uml_setup("root=", uml_root_setup,
 "        root=/dev/ubd5\n\n"
 );
 
-#ifndef CONFIG_MODE_TT
-
 static int __init no_skas_debug_setup(char *line, int *add)
 {
        printf("'debug' is not necessary to gdb UML in skas mode - run \n");
-       printf("'gdb linux' and disable CONFIG_CMDLINE_ON_HOST if gdb \n");
-       printf("doesn't work as expected\n");
+       printf("'gdb linux'");
 
        return 0;
 }
@@ -217,8 +161,6 @@ __uml_setup("debug", no_skas_debug_setup,
 "    this flag is not needed to run gdb on UML in skas mode\n\n"
 );
 
-#endif
-
 #ifdef CONFIG_SMP
 static int __init uml_ncpus_setup(char *line, int *add)
 {
@@ -232,56 +174,10 @@ static int __init uml_ncpus_setup(char *line, int *add)
 
 __uml_setup("ncpus=", uml_ncpus_setup,
 "ncpus=<# of desired CPUs>\n"
-"    This tells an SMP kernel how many virtual processors to start.\n\n" 
+"    This tells an SMP kernel how many virtual processors to start.\n\n"
 );
 #endif
 
-static int force_tt = 0;
-
-#if defined(CONFIG_MODE_TT) && defined(CONFIG_MODE_SKAS)
-#define DEFAULT_TT 0
-
-static int __init mode_tt_setup(char *line, int *add)
-{
-       force_tt = 1;
-       return 0;
-}
-
-#else
-#ifdef CONFIG_MODE_SKAS
-
-#define DEFAULT_TT 0
-
-static int __init mode_tt_setup(char *line, int *add)
-{
-       printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
-       return 0;
-}
-
-#else
-#ifdef CONFIG_MODE_TT
-
-#define DEFAULT_TT 1
-
-static int __init mode_tt_setup(char *line, int *add)
-{
-       printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
-       return 0;
-}
-
-#endif
-#endif
-#endif
-
-__uml_setup("mode=tt", mode_tt_setup,
-"mode=tt\n"
-"    When both CONFIG_MODE_TT and CONFIG_MODE_SKAS are enabled, this option\n"
-"    forces UML to run in tt (tracing thread) mode.  It is not the default\n"
-"    because it's slower and less secure than skas mode.\n\n"
-);
-
-int mode_tt = DEFAULT_TT;
-
 static int __init Usage(char *line, int *add)
 {
        const char **p;
@@ -310,9 +206,8 @@ static int __init uml_checksetup(char *line, int *add)
                int n;
 
                n = strlen(p->str);
-               if(!strncmp(line, p->str, n)){
-                       if (p->setup_func(line + n, add)) return 1;
-               }
+               if (!strncmp(line, p->str, n) && p->setup_func(line + n, add))
+                       return 1;
                p++;
        }
        return 0;
@@ -323,7 +218,7 @@ static void __init uml_postsetup(void)
        initcall_t *p;
 
        p = &__uml_postsetup_start;
-       while(p < &__uml_postsetup_end){
+       while(p < &__uml_postsetup_end) {
                (*p)();
                p++;
        }
@@ -339,6 +234,20 @@ EXPORT_SYMBOL(end_iomem);
 
 extern char __binary_start;
 
+static unsigned long set_task_sizes_skas(unsigned long *task_size_out)
+{
+       /* Round up to the nearest 4M */
+       unsigned long host_task_size = ROUND_4M((unsigned long)
+                                               &host_task_size);
+
+       if (!skas_needs_stub)
+               *task_size_out = host_task_size;
+       else
+               *task_size_out = STUB_START & PGDIR_MASK;
+
+       return host_task_size;
+}
+
 int __init linux_main(int argc, char **argv)
 {
        unsigned long avail, diff;
@@ -346,45 +255,30 @@ int __init linux_main(int argc, char **argv)
        unsigned int i, add;
        char * mode;
 
-       for (i = 1; i < argc; i++){
-               if((i == 1) && (argv[i][0] == ' ')) continue;
+       for (i = 1; i < argc; i++) {
+               if ((i == 1) && (argv[i][0] == ' '))
+                       continue;
                add = 1;
                uml_checksetup(argv[i], &add);
                if (add)
                        add_arg(argv[i]);
        }
-       if(have_root == 0)
+       if (have_root == 0)
                add_arg(DEFAULT_COMMAND_LINE);
 
+       /* OS sanity checks that need to happen before the kernel runs */
        os_early_checks();
-       if (force_tt)
-               clear_can_do_skas();
-       mode_tt = force_tt ? 1 : !can_do_skas();
-#ifndef CONFIG_MODE_TT
-       if (mode_tt) {
-               /*Since CONFIG_MODE_TT is #undef'ed, force_tt cannot be 1. So,
-                * can_do_skas() returned 0, and the message is correct. */
-               printf("Support for TT mode is disabled, and no SKAS support is present on the host.\n");
-               exit(1);
-       }
-#endif
 
-#ifndef CONFIG_MODE_SKAS
-       mode = "TT";
-#else
-       /* Show to the user the result of selection */
-       if (mode_tt)
-               mode = "TT";
-       else if (proc_mm && ptrace_faultinfo)
+       can_do_skas();
+
+       if (proc_mm && ptrace_faultinfo)
                mode = "SKAS3";
        else
                mode = "SKAS0";
-#endif
 
        printf("UML running in %s mode\n", mode);
 
-       host_task_size = CHOOSE_MODE_PROC(set_task_sizes_tt,
-                                         set_task_sizes_skas, &task_size);
+       host_task_size = set_task_sizes_skas(&task_size);
 
        /*
         * Setting up handlers to 'sig_info' struct
@@ -392,13 +286,15 @@ int __init linux_main(int argc, char **argv)
        os_fill_handlinfo(handlinfo_kern);
 
        brk_start = (unsigned long) sbrk(0);
-       CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
-       /* Increase physical memory size for exec-shield users
-       so they actually get what they asked for. This should
-       add zero for non-exec shield users */
+
+       /*
+        * Increase physical memory size for exec-shield users
+        * so they actually get what they asked for. This should
+        * add zero for non-exec shield users
+        */
 
        diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
-       if(diff > 1024 * 1024){
+       if (diff > 1024 * 1024) {
                printf("Adding %ld bytes to physical memory to account for "
                       "exec-shield gap\n", diff);
                physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
@@ -411,20 +307,16 @@ int __init linux_main(int argc, char **argv)
 
        setup_machinename(init_utsname()->machine);
 
-#ifdef CONFIG_CMDLINE_ON_HOST
-       argv1_begin = argv[1];
-       argv1_end = &argv[1][strlen(argv[1])];
-#endif
-
        highmem = 0;
        iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
        max_physmem = get_kmem_end() - uml_physmem - iomem_size - MIN_VMALLOC;
 
-       /* Zones have to begin on a 1 << MAX_ORDER page boundary,
+       /*
+        * Zones have to begin on a 1 << MAX_ORDER page boundary,
         * so this makes sure that's true for highmem
         */
        max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
-       if(physmem_size + iomem_size > max_physmem){
+       if (physmem_size + iomem_size > max_physmem) {
                highmem = physmem_size + iomem_size - max_physmem;
                physmem_size -= highmem;
 #ifndef CONFIG_HIGHMEM
@@ -441,7 +333,7 @@ int __init linux_main(int argc, char **argv)
        start_vm = VMALLOC_START;
 
        setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
-       if(init_maps(physmem_size, iomem_size, highmem)){
+       if (init_maps(physmem_size, iomem_size, highmem)) {
                printf("Failed to allocate mem_map for %Lu bytes of physical "
                       "memory and %Lu bytes of highmem\n", physmem_size,
                       highmem);
@@ -450,10 +342,11 @@ int __init linux_main(int argc, char **argv)
 
        virtmem_size = physmem_size;
        avail = get_kmem_end() - start_vm;
-       if(physmem_size > avail) virtmem_size = avail;
+       if (physmem_size > avail)
+               virtmem_size = avail;
        end_vm = start_vm + virtmem_size;
 
-       if(virtmem_size < physmem_size)
+       if (virtmem_size < physmem_size)
                printf("Kernel virtual memory size shrunk to %lu bytes\n",
                       virtmem_size);
 
@@ -462,7 +355,7 @@ int __init linux_main(int argc, char **argv)
        stack_protections((unsigned long) &init_thread_info);
        os_flush_stdout();
 
-       return CHOOSE_MODE(start_uml_tt(), start_uml_skas());
+       return start_uml();
 }
 
 extern int uml_exitcode;
index 81acdc2..13df191 100644 (file)
@@ -18,13 +18,6 @@ SECTIONS
 
   . = START + SIZEOF_HEADERS;
 
-#ifdef MODE_TT
-  .remap_data : { UNMAP_PATH (.data .bss) }
-  .remap : { UNMAP_PATH (.text) }
-
-  . = ALIGN(4096);             /* Init code and data */
-#endif
-
   _text = .;
   _stext = .;
   __init_begin = .;
index 2f8c794..8e129af 100644 (file)
@@ -1,23 +1,18 @@
 # 
-# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 # Licensed under the GPL
 #
 
 obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
-       sigio.o signal.o start_up.o time.o trap.o tty.o uaccess.o umid.o tls.o \
-       user_syms.o util.o drivers/ sys-$(SUBARCH)/
-
-obj-$(CONFIG_MODE_SKAS) += skas/
-
-obj-$(CONFIG_MODE_TT) += tt.o
-user-objs-$(CONFIG_MODE_TT) += tt.o
+       registers.o sigio.o signal.o start_up.o time.o trap.o tty.o uaccess.o \
+       umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/
 
 obj-$(CONFIG_TTY_LOG) += tty_log.o
 user-objs-$(CONFIG_TTY_LOG) += tty_log.o
 
 USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
-       main.o mem.o process.o sigio.o signal.o start_up.o time.o trap.o tty.o \
-       tls.o uaccess.o umid.o util.o
+       main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
+       trap.o tty.o tls.o uaccess.o umid.o util.o
 
 CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
 
index 5934835..4158118 100644 (file)
@@ -1,20 +1,19 @@
 /*
- * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdlib.h>
 #include <unistd.h>
+#include <sched.h>
 #include <signal.h>
 #include <errno.h>
-#include <sched.h>
-#include <sys/syscall.h>
-#include "os.h"
+#include <sys/time.h>
+#include <asm/unistd.h>
 #include "aio.h"
 #include "init.h"
-#include "user.h"
-#include "mode.h"
 #include "kern_constants.h"
+#include "os.h"
+#include "user.h"
 
 struct aio_thread_req {
        enum aio_type type;
@@ -28,7 +27,8 @@ struct aio_thread_req {
 #if defined(HAVE_AIO_ABI)
 #include <linux/aio_abi.h>
 
-/* If we have the headers, we are going to build with AIO enabled.
+/*
+ * If we have the headers, we are going to build with AIO enabled.
  * If we don't have aio in libc, we define the necessary stubs here.
  */
 
@@ -52,7 +52,8 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
 
 #endif
 
-/* The AIO_MMAP cases force the mmapped page into memory here
+/*
+ * The AIO_MMAP cases force the mmapped page into memory here
  * rather than in whatever place first touches the data.  I used
  * to do this by touching the page, but that's delicate because
  * gcc is prone to optimizing that away.  So, what's done here
@@ -106,12 +107,12 @@ static int aio_thread(void *arg)
 
        signal(SIGWINCH, SIG_IGN);
 
-       while(1){
+       while (1) {
                n = io_getevents(ctx, 1, 1, &event, NULL);
-               if(n < 0){
-                       if(errno == EINTR)
+               if (n < 0) {
+                       if (errno == EINTR)
                                continue;
-                       printk("aio_thread - io_getevents failed, "
+                       printk(UM_KERN_ERR "aio_thread - io_getevents failed, "
                               "errno = %d\n", errno);
                }
                else {
@@ -120,9 +121,9 @@ static int aio_thread(void *arg)
                                                .err    = event.res });
                        reply_fd = ((struct aio_context *) reply.data)->reply_fd;
                        err = write(reply_fd, &reply, sizeof(reply));
-                       if(err != sizeof(reply))
-                               printk("aio_thread - write failed, fd = %d, "
-                                      "err = %d\n", reply_fd, errno);
+                       if (err != sizeof(reply))
+                               printk(UM_KERN_ERR "aio_thread - write failed, "
+                                      "fd = %d, err = %d\n", reply_fd, errno);
                }
        }
        return 0;
@@ -137,10 +138,10 @@ static int do_not_aio(struct aio_thread_req *req)
        int n;
 
        actual = lseek64(req->io_fd, req->offset, SEEK_SET);
-       if(actual != req->offset)
+       if (actual != req->offset)
                return -errno;
 
-       switch(req->type){
+       switch(req->type) {
        case AIO_READ:
                n = read(req->io_fd, req->buf, req->len);
                break;
@@ -151,11 +152,12 @@ static int do_not_aio(struct aio_thread_req *req)
                n = read(req->io_fd, &c, sizeof(c));
                break;
        default:
-               printk("do_not_aio - bad request type : %d\n", req->type);
+               printk(UM_KERN_ERR "do_not_aio - bad request type : %d\n",
+                      req->type);
                return -EINVAL;
        }
 
-       if(n < 0)
+       if (n < 0)
                return -errno;
        return 0;
 }
@@ -173,16 +175,18 @@ static int not_aio_thread(void *arg)
        int err;
 
        signal(SIGWINCH, SIG_IGN);
-       while(1){
+       while (1) {
                err = read(aio_req_fd_r, &req, sizeof(req));
-               if(err != sizeof(req)){
-                       if(err < 0)
-                               printk("not_aio_thread - read failed, "
-                                      "fd = %d, err = %d\n", aio_req_fd_r,
+               if (err != sizeof(req)) {
+                       if (err < 0)
+                               printk(UM_KERN_ERR "not_aio_thread - "
+                                      "read failed, fd = %d, err = %d\n",
+                                      aio_req_fd_r,
                                       errno);
                        else {
-                               printk("not_aio_thread - short read, fd = %d, "
-                                      "length = %d\n", aio_req_fd_r, err);
+                               printk(UM_KERN_ERR "not_aio_thread - short "
+                                      "read, fd = %d, length = %d\n",
+                                      aio_req_fd_r, err);
                        }
                        continue;
                }
@@ -190,9 +194,9 @@ static int not_aio_thread(void *arg)
                reply = ((struct aio_thread_reply) { .data      = req.aio,
                                                     .err       = err });
                err = write(req.aio->reply_fd, &reply, sizeof(reply));
-               if(err != sizeof(reply))
-                       printk("not_aio_thread - write failed, fd = %d, "
-                              "err = %d\n", req.aio->reply_fd, errno);
+               if (err != sizeof(reply))
+                       printk(UM_KERN_ERR "not_aio_thread - write failed, "
+                              "fd = %d, err = %d\n", req.aio->reply_fd, errno);
        }
 
        return 0;
@@ -203,35 +207,36 @@ static int init_aio_24(void)
        int fds[2], err;
 
        err = os_pipe(fds, 1, 1);
-       if(err)
+       if (err)
                goto out;
 
        aio_req_fd_w = fds[0];
        aio_req_fd_r = fds[1];
 
        err = os_set_fd_block(aio_req_fd_w, 0);
-       if(err)
+       if (err)
                goto out_close_pipe;
 
        err = run_helper_thread(not_aio_thread, NULL,
                                CLONE_FILES | CLONE_VM | SIGCHLD, &aio_stack);
-       if(err < 0)
+       if (err < 0)
                goto out_close_pipe;
 
        aio_pid = err;
        goto out;
 
 out_close_pipe:
-       os_close_file(fds[0]);
-       os_close_file(fds[1]);
+       close(fds[0]);
+       close(fds[1]);
        aio_req_fd_w = -1;
        aio_req_fd_r = -1;
 out:
 #ifndef HAVE_AIO_ABI
-       printk("/usr/include/linux/aio_abi.h not present during build\n");
+       printk(UM_KERN_INFO "/usr/include/linux/aio_abi.h not present during "
+              "build\n");
 #endif
-       printk("2.6 host AIO support not used - falling back to I/O "
-              "thread\n");
+       printk(UM_KERN_INFO "2.6 host AIO support not used - falling back to "
+              "I/O thread\n");
        return 0;
 }
 
@@ -241,21 +246,21 @@ static int init_aio_26(void)
 {
        int err;
 
-       if(io_setup(256, &ctx)){
+       if (io_setup(256, &ctx)) {
                err = -errno;
-               printk("aio_thread failed to initialize context, err = %d\n",
-                      errno);
+               printk(UM_KERN_ERR "aio_thread failed to initialize context, "
+                      "err = %d\n", errno);
                return err;
        }
 
        err = run_helper_thread(aio_thread, NULL,
                                CLONE_FILES | CLONE_VM | SIGCHLD, &aio_stack);
-       if(err < 0)
+       if (err < 0)
                return err;
 
        aio_pid = err;
 
-       printk("Using 2.6 host AIO\n");
+       printk(UM_KERN_INFO "Using 2.6 host AIO\n");
        return 0;
 }
 
@@ -266,13 +271,13 @@ static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
        int err;
 
        err = do_aio(ctx, type, io_fd, buf, len, offset, aio);
-       if(err){
+       if (err) {
                reply = ((struct aio_thread_reply) { .data = aio,
                                         .err  = err });
                err = write(aio->reply_fd, &reply, sizeof(reply));
-               if(err != sizeof(reply)){
+               if (err != sizeof(reply)) {
                        err = -errno;
-                       printk("submit_aio_26 - write failed, "
+                       printk(UM_KERN_ERR "submit_aio_26 - write failed, "
                               "fd = %d, err = %d\n", aio->reply_fd, -err);
                }
                else err = 0;
@@ -320,28 +325,24 @@ static int init_aio(void)
 {
        int err;
 
-       CHOOSE_MODE(({ if(!aio_24){
-                           printk("Disabling 2.6 AIO in tt mode\n");
-                           aio_24 = 1;
-                   } }), (void) 0);
-
-       if(!aio_24){
+       if (!aio_24) {
                err = init_aio_26();
-               if(err && (errno == ENOSYS)){
-                       printk("2.6 AIO not supported on the host - "
-                              "reverting to 2.4 AIO\n");
+               if (err && (errno == ENOSYS)) {
+                       printk(UM_KERN_INFO "2.6 AIO not supported on the "
+                              "host - reverting to 2.4 AIO\n");
                        aio_24 = 1;
                }
                else return err;
        }
 
-       if(aio_24)
+       if (aio_24)
                return init_aio_24();
 
        return 0;
 }
 
-/* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio
+/*
+ * The reason for the __initcall/__uml_exitcall asymmetry is that init_aio
  * needs to be called when the kernel is running because it calls run_helper,
  * which needs get_free_page.  exit_aio is a __uml_exitcall because the generic
  * kernel does not run __exitcalls on shutdown, and can't because many of them
@@ -372,7 +373,7 @@ static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len,
        int err;
 
        err = write(aio_req_fd_w, &req, sizeof(req));
-       if(err == sizeof(req))
+       if (err == sizeof(req))
                err = 0;
        else err = -errno;
 
@@ -384,9 +385,8 @@ int submit_aio(enum aio_type type, int io_fd, char *buf, int len,
               struct aio_context *aio)
 {
        aio->reply_fd = reply_fd;
-       if(aio_24)
+       if (aio_24)
                return submit_aio_24(type, io_fd, buf, len, offset, aio);
-       else {
+       else
                return submit_aio_26(type, io_fd, buf, len, offset, aio);
-       }
 }
index 57ecdaf..ddffd41 100644 (file)
@@ -1,8 +1,11 @@
 /* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
+#ifndef __DRIVERS_ETAP_H
+#define __DRIVERS_ETAP_H
+
 #include "net_user.h"
 
 struct ethertap_data {
@@ -15,13 +18,4 @@ struct ethertap_data {
 
 extern const struct net_user_info ethertap_user_info;
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+#endif
index 1268914..04f11b9 100644 (file)
@@ -1,16 +1,15 @@
 /*
- * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and 
+ * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright (C) 2001 by various other people who didn't put their name here.
  * Licensed under the GPL.
  */
 
 #include "linux/init.h"
-#include "linux/netdevice.h"
-#include "linux/etherdevice.h"
-#include "net_kern.h"
-#include "net_user.h"
+#include <linux/netdevice.h>
 #include "etap.h"
+#include "net_kern.h"
 
 struct ethertap_init {
        char *dev_name;
@@ -37,32 +36,24 @@ static void etap_init(struct net_device *dev, void *data)
        printk("\n");
 }
 
-static int etap_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
+static int etap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
        int len;
 
-       *skb = ether_adjust_skb(*skb, ETH_HEADER_ETHERTAP);
-       if(*skb == NULL) return(-ENOMEM);
-       len = net_recvfrom(fd, skb_mac_header(*skb),
-                          (*skb)->dev->mtu + 2 * ETH_HEADER_ETHERTAP);
-       if(len <= 0) return(len);
-       skb_pull(*skb, 2);
+       len = net_recvfrom(fd, skb_mac_header(skb),
+                          skb->dev->mtu + 2 + ETH_HEADER_ETHERTAP);
+       if (len <= 0)
+               return(len);
+
+       skb_pull(skb, 2);
        len -= 2;
-       return(len);
+       return len;
 }
 
-static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
+static int etap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       if(skb_headroom(*skb) < 2){
-               struct sk_buff *skb2;
-
-               skb2 = skb_realloc_headroom(*skb, 2);
-               dev_kfree_skb(*skb);
-               if (skb2 == NULL) return(-ENOMEM);
-               *skb = skb2;
-       }
-       skb_push(*skb, 2);
-       return(net_send(fd, (*skb)->data, (*skb)->len));
+       skb_push(skb, 2);
+       return net_send(fd, skb->data, skb->len);
 }
 
 const struct net_kern_info ethertap_kern_info = {
@@ -79,15 +70,15 @@ int ethertap_setup(char *str, char **mac_out, void *data)
        *init = ((struct ethertap_init)
                { .dev_name     = NULL,
                  .gate_addr    = NULL });
-       if(tap_setup_common(str, "ethertap", &init->dev_name, mac_out,
+       if (tap_setup_common(str, "ethertap", &init->dev_name, mac_out,
                            &init->gate_addr))
-               return(0);
-       if(init->dev_name == NULL){
-               printk("ethertap_setup : Missing tap device name\n");
-               return(0);
+               return 0;
+       if (init->dev_name == NULL) {
+               printk(KERN_ERR "ethertap_setup : Missing tap device name\n");
+               return 0;
        }
 
-       return(1);
+       return 1;
 }
 
 static struct transport ethertap_transport = {
@@ -97,6 +88,7 @@ static struct transport ethertap_transport = {
        .user           = &ethertap_user_info,
        .kern           = &ethertap_kern_info,
        .private_size   = sizeof(struct ethertap_data),
+       .setup_size     = sizeof(struct ethertap_init),
 };
 
 static int register_ethertap(void)
index 61d3953..4ff5536 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  * James Leu (jleu@mindspring.net).
  * Copyright (C) 2001 by various other people who didn't put their name here.
@@ -7,20 +8,16 @@
 
 #include <stdio.h>
 #include <unistd.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <sys/errno.h>
+#include <errno.h>
+#include <string.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
-#include <sys/un.h>
-#include <net/if.h>
-#include "user.h"
-#include "kern_util.h"
-#include "net_user.h"
 #include "etap.h"
+#include "kern_constants.h"
 #include "os.h"
+#include "net_user.h"
 #include "um_malloc.h"
-#include "kern_constants.h"
+#include "user.h"
 
 #define MAX_PACKET ETH_MAX_PACKET
 
@@ -49,16 +46,18 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
        memcpy(change.addr, addr, sizeof(change.addr));
        memcpy(change.netmask, netmask, sizeof(change.netmask));
        CATCH_EINTR(n = write(fd, &change, sizeof(change)));
-       if(n != sizeof(change)){
-               printk("etap_change - request failed, err = %d\n", errno);
+       if (n != sizeof(change)) {
+               printk(UM_KERN_ERR "etap_change - request failed, err = %d\n",
+                      errno);
                return;
        }
 
        output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
-       if(output == NULL)
-               printk("etap_change : Failed to allocate output buffer\n");
+       if (output == NULL)
+               printk(UM_KERN_ERR "etap_change : Failed to allocate output "
+                      "buffer\n");
        read_output(fd, output, UM_KERN_PAGE_SIZE);
-       if(output != NULL){
+       if (output != NULL) {
                printk("%s", output);
                kfree(output);
        }
@@ -87,11 +86,11 @@ static void etap_pre_exec(void *arg)
        struct etap_pre_exec_data *data = arg;
 
        dup2(data->control_remote, 1);
-       os_close_file(data->data_me);
-       os_close_file(data->control_me);
+       close(data->data_me);
+       close(data->control_me);
 }
 
-static int etap_tramp(char *dev, char *gate, int control_me, 
+static int etap_tramp(char *dev, char *gate, int control_me,
                      int control_remote, int data_me, int data_remote)
 {
        struct etap_pre_exec_data pe_data;
@@ -101,13 +100,13 @@ static int etap_tramp(char *dev, char *gate, int control_me,
        char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
        char *setup_args[] = { "uml_net", version_buf, "ethertap", dev,
                               data_fd_buf, gate_buf, NULL };
-       char *nosetup_args[] = { "uml_net", version_buf, "ethertap", 
+       char *nosetup_args[] = { "uml_net", version_buf, "ethertap",
                                 dev, data_fd_buf, NULL };
        char **args, c;
 
        sprintf(data_fd_buf, "%d", data_remote);
        sprintf(version_buf, "%d", UML_NET_VERSION);
-       if(gate != NULL){
+       if (gate != NULL) {
                strcpy(gate_buf, gate);
                args = setup_args;
        }
@@ -119,24 +118,26 @@ static int etap_tramp(char *dev, char *gate, int control_me,
        pe_data.data_me = data_me;
        pid = run_helper(etap_pre_exec, &pe_data, args);
 
-       if(pid < 0)
+       if (pid < 0)
                err = pid;
-       os_close_file(data_remote);
-       os_close_file(control_remote);
+       close(data_remote);
+       close(control_remote);
        CATCH_EINTR(n = read(control_me, &c, sizeof(c)));
-       if(n != sizeof(c)){
+       if (n != sizeof(c)) {
                err = -errno;
-               printk("etap_tramp : read of status failed, err = %d\n", -err);
+               printk(UM_KERN_ERR "etap_tramp : read of status failed, "
+                      "err = %d\n", -err);
                return err;
        }
-       if(c != 1){
-               printk("etap_tramp : uml_net failed\n");
+       if (c != 1) {
+               printk(UM_KERN_ERR "etap_tramp : uml_net failed\n");
                err = -EINVAL;
                CATCH_EINTR(n = waitpid(pid, &status, 0));
-               if(n < 0)
+               if (n < 0)
                        err = -errno;
-               else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
-                       printk("uml_net didn't exit with status 1\n");
+               else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
+                       printk(UM_KERN_ERR "uml_net didn't exit with "
+                              "status 1\n");
        }
        return err;
 }
@@ -148,43 +149,56 @@ static int etap_open(void *data)
        int data_fds[2], control_fds[2], err, output_len;
 
        err = tap_open_common(pri->dev, pri->gate_addr);
-       if(err)
+       if (err)
                return err;
 
-       err = os_pipe(data_fds, 0, 0);
-       if(err < 0){
-               printk("data os_pipe failed - err = %d\n", -err);
+       err = socketpair(AF_UNIX, SOCK_DGRAM, 0, data_fds);
+       if (err) {
+               err = -errno;
+               printk(UM_KERN_ERR "etap_open - data socketpair failed - "
+                      "err = %d\n", errno);
                return err;
        }
 
-       err = os_pipe(control_fds, 1, 0);
-       if(err < 0){
-               printk("control os_pipe failed - err = %d\n", -err);
-               return err;
+       err = socketpair(AF_UNIX, SOCK_STREAM, 0, control_fds);
+       if (err) {
+               err = -errno;
+               printk(UM_KERN_ERR "etap_open - control socketpair failed - "
+                      "err = %d\n", errno);
+               goto out_close_data;
        }
 
-       err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], 
+       err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
                         control_fds[1], data_fds[0], data_fds[1]);
        output_len = UM_KERN_PAGE_SIZE;
        output = kmalloc(output_len, UM_GFP_KERNEL);
        read_output(control_fds[0], output, output_len);
 
-       if(output == NULL)
-               printk("etap_open : failed to allocate output buffer\n");
+       if (output == NULL)
+               printk(UM_KERN_ERR "etap_open : failed to allocate output "
+                      "buffer\n");
        else {
                printk("%s", output);
                kfree(output);
        }
 
-       if(err < 0){
-               printk("etap_tramp failed - err = %d\n", -err);
-               return err;
+       if (err < 0) {
+               printk(UM_KERN_ERR "etap_tramp failed - err = %d\n", -err);
+               goto out_close_control;
        }
 
        pri->data_fd = data_fds[0];
        pri->control_fd = control_fds[0];
        iter_addresses(pri->dev, etap_open_addr, &pri->control_fd);
        return data_fds[0];
+
+out_close_control:
+       close(control_fds[0]);
+       close(control_fds[1]);
+out_close_data:
+       close(data_fds[0]);
+       close(data_fds[1]);
+       return err;
 }
 
 static void etap_close(int fd, void *data)
@@ -192,37 +206,41 @@ static void etap_close(int fd, void *data)
        struct ethertap_data *pri = data;
 
        iter_addresses(pri->dev, etap_close_addr, &pri->control_fd);
-       os_close_file(fd);
-       os_shutdown_socket(pri->data_fd, 1, 1);
-       os_close_file(pri->data_fd);
+       close(fd);
+
+       if (shutdown(pri->data_fd, SHUT_RDWR) < 0)
+               printk(UM_KERN_ERR "etap_close - shutdown data socket failed, "
+                      "errno = %d\n", errno);
+
+       if (shutdown(pri->control_fd, SHUT_RDWR) < 0)
+               printk(UM_KERN_ERR "etap_close - shutdown control socket "
+                      "failed, errno = %d\n", errno);
+
+       close(pri->data_fd);
        pri->data_fd = -1;
-       os_close_file(pri->control_fd);
+       close(pri->control_fd);
        pri->control_fd = -1;
 }
 
-static int etap_set_mtu(int mtu, void *data)
-{
-       return mtu;
-}
-
 static void etap_add_addr(unsigned char *addr, unsigned char *netmask,
                          void *data)
 {
        struct ethertap_data *pri = data;
 
        tap_check_ips(pri->gate_addr, addr);
-       if(pri->control_fd == -1)
+       if (pri->control_fd == -1)
                return;
        etap_open_addr(addr, netmask, &pri->control_fd);
 }
 
-static void etap_del_addr(unsigned char *addr, unsigned char *netmask, 
+static void etap_del_addr(unsigned char *addr, unsigned char *netmask,
                          void *data)
 {
        struct ethertap_data *pri = data;
 
-       if(pri->control_fd == -1)
+       if (pri->control_fd == -1)
                return;
+
        etap_close_addr(addr, netmask, &pri->control_fd);
 }
 
@@ -231,8 +249,8 @@ const struct net_user_info ethertap_user_info = {
        .open           = etap_open,
        .close          = etap_close,
        .remove         = NULL,
-       .set_mtu        = etap_set_mtu,
        .add_address    = etap_add_addr,
        .delete_address = etap_del_addr,
-       .max_packet     = MAX_PACKET - ETH_HEADER_ETHERTAP
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_ETHERTAP,
 };
index d3e8d3a..f17c315 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -19,14 +19,3 @@ struct tuntap_data {
 extern const struct net_user_info tuntap_user_info;
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index f1714e7..9d38480 100644 (file)
@@ -1,16 +1,13 @@
-/* 
- * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/stddef.h"
-#include "linux/netdevice.h"
-#include "linux/etherdevice.h"
-#include "linux/skbuff.h"
-#include "linux/init.h"
-#include "asm/errno.h"
+#include <linux/netdevice.h>
+#include <linux/init.h>
+#include <linux/skbuff.h>
+#include <asm/errno.h>
 #include "net_kern.h"
-#include "net_user.h"
 #include "tuntap.h"
 
 struct tuntap_init {
@@ -38,19 +35,15 @@ static void tuntap_init(struct net_device *dev, void *data)
        printk("\n");
 }
 
-static int tuntap_read(int fd, struct sk_buff **skb, 
-                      struct uml_net_private *lp)
+static int tuntap_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
-       if(*skb == NULL) return(-ENOMEM);
-       return(net_read(fd, skb_mac_header(*skb),
-                       (*skb)->dev->mtu + ETH_HEADER_OTHER));
+       return net_read(fd, skb_mac_header(skb),
+                       skb->dev->mtu + ETH_HEADER_OTHER);
 }
 
-static int tuntap_write(int fd, struct sk_buff **skb, 
-                       struct uml_net_private *lp)
+static int tuntap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 {
-       return(net_write(fd, (*skb)->data, (*skb)->len));
+       return net_write(fd, skb->data, skb->len);
 }
 
 const struct net_kern_info tuntap_kern_info = {
@@ -67,11 +60,11 @@ int tuntap_setup(char *str, char **mac_out, void *data)
        *init = ((struct tuntap_init)
                { .dev_name     = NULL,
                  .gate_addr    = NULL });
-       if(tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
+       if (tap_setup_common(str, "tuntap", &init->dev_name, mac_out,
                            &init->gate_addr))
-               return(0);
+               return 0;
 
-       return(1);
+       return 1;
 }
 
 static struct transport tuntap_transport = {
index f848b4e..6c55d3c 100644 (file)
@@ -1,27 +1,22 @@
 /* 
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <sys/wait.h>
+#include <string.h>
+#include <linux/if_tun.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <sys/un.h>
+#include <sys/wait.h>
 #include <sys/uio.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <linux/if_tun.h>
-#include "net_user.h"
+#include "kern_constants.h"
+#include "os.h"
 #include "tuntap.h"
-#include "kern_util.h"
 #include "user.h"
-#include "os.h"
-
-#define MAX_PACKET ETH_MAX_PACKET
 
 static int tuntap_user_init(void *data, void *dev)
 {
@@ -37,7 +32,7 @@ static void tuntap_add_addr(unsigned char *addr, unsigned char *netmask,
        struct tuntap_data *pri = data;
 
        tap_check_ips(pri->gate_addr, addr);
-       if((pri->fd == -1) || pri->fixed_config)
+       if ((pri->fd == -1) || pri->fixed_config)
                return;
        open_addr(addr, netmask, pri->dev_name);
 }
@@ -47,7 +42,7 @@ static void tuntap_del_addr(unsigned char *addr, unsigned char *netmask,
 {
        struct tuntap_data *pri = data;
 
-       if((pri->fd == -1) || pri->fixed_config)
+       if ((pri->fd == -1) || pri->fixed_config)
                return;
        close_addr(addr, netmask, pri->dev_name);
 }
@@ -62,7 +57,7 @@ static void tuntap_pre_exec(void *arg)
        struct tuntap_pre_exec_data *data = arg;
 
        dup2(data->stdout, 1);
-       os_close_file(data->close_me);
+       close(data->close_me);
 }
 
 static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
@@ -85,14 +80,14 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
 
        pid = run_helper(tuntap_pre_exec, &data, argv);
 
-       if(pid < 0)
+       if (pid < 0)
                return -pid;
 
-       os_close_file(remote);
+       close(remote);
 
        msg.msg_name = NULL;
        msg.msg_namelen = 0;
-       if(buffer != NULL){
+       if (buffer != NULL) {
                iov = ((struct iovec) { buffer, buffer_len });
                msg.msg_iov = &iov;
                msg.msg_iovlen = 1;
@@ -106,26 +101,28 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
        msg.msg_flags = 0;
        n = recvmsg(me, &msg, 0);
        *used_out = n;
-       if(n < 0){
+       if (n < 0) {
                err = -errno;
-               printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", 
-                      errno);
+               printk(UM_KERN_ERR "tuntap_open_tramp : recvmsg failed - "
+                      "errno = %d\n", errno);
                return err;
        }
        CATCH_EINTR(waitpid(pid, NULL, 0));
 
        cmsg = CMSG_FIRSTHDR(&msg);
-       if(cmsg == NULL){
-               printk("tuntap_open_tramp : didn't receive a message\n");
+       if (cmsg == NULL) {
+               printk(UM_KERN_ERR "tuntap_open_tramp : didn't receive a "
+                      "message\n");
                return -EINVAL;
        }
-       if((cmsg->cmsg_level != SOL_SOCKET) || 
-          (cmsg->cmsg_type != SCM_RIGHTS)){
-               printk("tuntap_open_tramp : didn't receive a descriptor\n");
+       if ((cmsg->cmsg_level != SOL_SOCKET) ||
+          (cmsg->cmsg_type != SCM_RIGHTS)) {
+               printk(UM_KERN_ERR "tuntap_open_tramp : didn't receive a "
+                      "descriptor\n");
                return -EINVAL;
        }
        *fd_out = ((int *) CMSG_DATA(cmsg))[0];
-       os_set_exec_close(*fd_out, 1);
+       os_set_exec_close(*fd_out);
        return 0;
 }
 
@@ -137,47 +134,51 @@ static int tuntap_open(void *data)
        int err, fds[2], len, used;
 
        err = tap_open_common(pri->dev, pri->gate_addr);
-       if(err < 0)
+       if (err < 0)
                return err;
 
-       if(pri->fixed_config){
+       if (pri->fixed_config) {
                pri->fd = os_open_file("/dev/net/tun",
                                       of_cloexec(of_rdwr(OPENFLAGS())), 0);
-               if(pri->fd < 0){
-                       printk("Failed to open /dev/net/tun, err = %d\n",
-                              -pri->fd);
+               if (pri->fd < 0) {
+                       printk(UM_KERN_ERR "Failed to open /dev/net/tun, "
+                              "err = %d\n", -pri->fd);
                        return pri->fd;
                }
                memset(&ifr, 0, sizeof(ifr));
                ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
                strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name));
-               if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){
+               if (ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0) {
                        err = -errno;
-                       printk("TUNSETIFF failed, errno = %d\n", errno);
-                       os_close_file(pri->fd);
+                       printk(UM_KERN_ERR "TUNSETIFF failed, errno = %d\n",
+                              errno);
+                       close(pri->fd);
                        return err;
                }
        }
        else {
-               err = os_pipe(fds, 0, 0);
-               if(err < 0){
-                       printk("tuntap_open : os_pipe failed - err = %d\n",
-                              -err);
+               err = socketpair(AF_UNIX, SOCK_DGRAM, 0, fds);
+               if (err) {
+                       err = -errno;
+                       printk(UM_KERN_ERR "tuntap_open : socketpair failed - "
+                              "errno = %d\n", errno);
                        return err;
                }
 
                buffer = get_output_buffer(&len);
-               if(buffer != NULL) len--;
+               if (buffer != NULL)
+                       len--;
                used = 0;
 
                err = tuntap_open_tramp(pri->gate_addr, &pri->fd, fds[0],
                                        fds[1], buffer, len, &used);
 
                output = buffer;
-               if(err < 0) {
+               if (err < 0) {
                        printk("%s", output);
                        free_output_buffer(buffer);
-                       printk("tuntap_open_tramp failed - err = %d\n", -err);
+                       printk(UM_KERN_ERR "tuntap_open_tramp failed - "
+                              "err = %d\n", -err);
                        return err;
                }
 
@@ -186,7 +187,7 @@ static int tuntap_open(void *data)
                printk("%s", output);
                free_output_buffer(buffer);
 
-               os_close_file(fds[0]);
+               close(fds[0]);
                iter_addresses(pri->dev, open_addr, pri->dev_name);
        }
 
@@ -197,24 +198,19 @@ static void tuntap_close(int fd, void *data)
 {
        struct tuntap_data *pri = data;
 
-       if(!pri->fixed_config) 
+       if (!pri->fixed_config)
                iter_addresses(pri->dev, close_addr, pri->dev_name);
-       os_close_file(fd);
+       close(fd);
        pri->fd = -1;
 }
 
-static int tuntap_set_mtu(int mtu, void *data)
-{
-       return mtu;
-}
-
 const struct net_user_info tuntap_user_info = {
        .init           = tuntap_user_init,
        .open           = tuntap_open,
        .close          = tuntap_close,
        .remove         = NULL,
-       .set_mtu        = tuntap_set_mtu,
        .add_address    = tuntap_add_addr,
        .delete_address = tuntap_del_addr,
-       .max_packet     = MAX_PACKET
+       .mtu            = ETH_MAX_PACKET,
+       .max_packet     = ETH_MAX_PACKET + ETH_HEADER_OTHER,
 };
index c3ecc2a..b542a3a 100644 (file)
@@ -82,13 +82,6 @@ int os_access(const char* file, int mode)
        return 0;
 }
 
-void os_print_error(int error, const char* str)
-{
-       errno = error < 0 ? -error : error;
-
-       perror(str);
-}
-
 /* FIXME? required only by hostaudio (because it passes ioctls verbatim) */
 int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
 {
@@ -101,30 +94,6 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
        return err;
 }
 
-int os_window_size(int fd, int *rows, int *cols)
-{
-       struct winsize size;
-
-       if(ioctl(fd, TIOCGWINSZ, &size) < 0)
-               return -errno;
-
-       *rows = size.ws_row;
-       *cols = size.ws_col;
-
-       return 0;
-}
-
-int os_new_tty_pgrp(int fd, int pid)
-{
-       if(ioctl(fd, TIOCSCTTY, 0) < 0)
-               return -errno;
-
-       if(tcsetpgrp(fd, pid) < 0)
-               return -errno;
-
-       return 0;
-}
-
 /* FIXME: ensure namebuf in os_get_if_name is big enough */
 int os_get_ifname(int fd, char* namebuf)
 {
@@ -205,19 +174,19 @@ int os_file_mode(char *file, struct openflags *mode_out)
 
        *mode_out = OPENFLAGS();
 
-       err = os_access(file, OS_ACC_W_OK);
-       if((err < 0) && (err != -EACCES))
-               return(err);
-
-       *mode_out = of_write(*mode_out);
-
-       err = os_access(file, OS_ACC_R_OK);
-       if((err < 0) && (err != -EACCES))
-               return(err);
+       err = access(file, W_OK);
+       if(err && (errno != EACCES))
+               return -errno;
+       else if(!err)
+               *mode_out = of_write(*mode_out);
 
-       *mode_out = of_read(*mode_out);
+       err = access(file, R_OK);
+       if(err && (errno != EACCES))
+               return -errno;
+       else if(!err)
+               *mode_out = of_read(*mode_out);
 
-       return(0);
+       return err;
 }
 
 int os_open_file(char *file, struct openflags flags, int mode)
@@ -236,15 +205,15 @@ int os_open_file(char *file, struct openflags flags, int mode)
 
        fd = open64(file, f, mode);
        if(fd < 0)
-               return(-errno);
+               return -errno;
 
        if(flags.cl && fcntl(fd, F_SETFD, 1)){
                err = -errno;
-               os_close_file(fd);
+               close(fd);
                return err;
        }
 
-       return(fd);
+       return fd;
 }
 
 int os_connect_socket(char *name)
@@ -280,9 +249,9 @@ void os_close_file(int fd)
        close(fd);
 }
 
-int os_seek_file(int fd, __u64 offset)
+int os_seek_file(int fd, unsigned long long offset)
 {
-       __u64 actual;
+       unsigned long long actual;
 
        actual = lseek64(fd, offset, SEEK_SET);
        if(actual != offset)
@@ -316,31 +285,33 @@ int os_file_size(char *file, unsigned long long *size_out)
        err = os_stat_file(file, &buf);
        if(err < 0){
                printk("Couldn't stat \"%s\" : err = %d\n", file, -err);
-               return(err);
+               return err;
        }
 
        if(S_ISBLK(buf.ust_mode)){
                int fd;
                long blocks;
 
-               fd = os_open_file(file, of_read(OPENFLAGS()), 0);
-               if(fd < 0){
-                       printk("Couldn't open \"%s\", errno = %d\n", file, -fd);
-                       return(fd);
+               fd = open(file, O_RDONLY, 0);
+               if(fd < 0) {
+                       err = -errno;
+                       printk("Couldn't open \"%s\", errno = %d\n", file,
+                              errno);
+                       return err;
                }
                if(ioctl(fd, BLKGETSIZE, &blocks) < 0){
                        err = -errno;
                        printk("Couldn't get the block size of \"%s\", "
                               "errno = %d\n", file, errno);
-                       os_close_file(fd);
-                       return(err);
+                       close(fd);
+                       return err;
                }
                *size_out = ((long long) blocks) * 512;
-               os_close_file(fd);
-               return(0);
+               close(fd);
        }
-       *size_out = buf.ust_size;
-       return(0);
+       else *size_out = buf.ust_size;
+
+       return 0;
 }
 
 int os_file_modtime(char *file, unsigned long *modtime)
@@ -358,35 +329,28 @@ int os_file_modtime(char *file, unsigned long *modtime)
        return 0;
 }
 
-int os_get_exec_close(int fd, int* close_on_exec)
+int os_get_exec_close(int fd, int *close_on_exec)
 {
        int ret;
 
-       do {
-               ret = fcntl(fd, F_GETFD);
-       } while((ret < 0) && (errno == EINTR)) ;
+       CATCH_EINTR(ret = fcntl(fd, F_GETFD));
 
        if(ret < 0)
-               return(-errno);
+               return -errno;
 
-       *close_on_exec = (ret&FD_CLOEXEC) ? 1 : 0;
-       return(ret);
+       *close_on_exec = (ret & FD_CLOEXEC) ? 1 : 0;
+       return ret;
 }
 
-int os_set_exec_close(int fd, int close_on_exec)
+int os_set_exec_close(int fd)
 {
-       int flag, err;
-
-       if(close_on_exec) flag = FD_CLOEXEC;
-       else flag = 0;
+       int err;
 
-       do {
-               err = fcntl(fd, F_SETFD, flag);
-       } while((err < 0) && (errno == EINTR)) ;
+       CATCH_EINTR(err = fcntl(fd, F_SETFD, FD_CLOEXEC));
 
        if(err < 0)
-               return(-errno);
-       return(err);
+               return -errno;
+       return err;
 }
 
 int os_pipe(int *fds, int stream, int close_on_exec)
@@ -395,16 +359,16 @@ int os_pipe(int *fds, int stream, int close_on_exec)
 
        err = socketpair(AF_UNIX, type, 0, fds);
        if(err < 0)
-               return(-errno);
+               return -errno;
 
        if(!close_on_exec)
-               return(0);
+               return 0;
 
-       err = os_set_exec_close(fds[0], 1);
+       err = os_set_exec_close(fds[0]);
        if(err < 0)
                goto error;
 
-       err = os_set_exec_close(fds[1], 1);
+       err = os_set_exec_close(fds[1]);
        if(err < 0)
                goto error;
 
@@ -412,9 +376,9 @@ int os_pipe(int *fds, int stream, int close_on_exec)
 
  error:
        printk("os_pipe : Setting FD_CLOEXEC failed, err = %d\n", -err);
-       os_close_file(fds[1]);
-       os_close_file(fds[0]);
-       return(err);
+       close(fds[1]);
+       close(fds[0]);
+       return err;
 }
 
 int os_set_fd_async(int fd, int owner)
@@ -561,7 +525,7 @@ int os_create_unix_socket(char *file, int len, int close_on_exec)
                return -errno;
 
        if(close_on_exec) {
-               err = os_set_exec_close(sock, 1);
+               err = os_set_exec_close(sock);
                if(err < 0)
                        printk("create_unix_socket : close_on_exec failed, "
                       "err = %d", -err);
index d81af7b..7a72dbb 100644 (file)
@@ -11,6 +11,7 @@
 #include <limits.h>
 #include <sys/signal.h>
 #include <sys/wait.h>
+#include <sys/socket.h>
 #include "user.h"
 #include "kern_util.h"
 #include "os.h"
@@ -54,13 +55,14 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
        if (stack == 0)
                return -ENOMEM;
 
-       ret = os_pipe(fds, 1, 0);
+       ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
        if (ret < 0) {
-               printk("run_helper : pipe failed, ret = %d\n", -ret);
+               ret = -errno;
+               printk("run_helper : pipe failed, errno = %d\n", errno);
                goto out_free;
        }
 
-       ret = os_set_exec_close(fds[1], 1);
+       ret = os_set_exec_close(fds[1]);
        if (ret < 0) {
                printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n",
                       -ret);
index a633fa8..6aa6f95 100644 (file)
@@ -145,11 +145,7 @@ void init_irq_signals(int on_sigstack)
 
        flags = on_sigstack ? SA_ONSTACK : 0;
 
-       set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
-                   flags | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
-       set_handler(SIGALRM, (__sighandler_t) alarm_handler,
-                   flags | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1);
        set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        signal(SIGWINCH, SIG_IGN);
 }
index e85f499..82c3778 100644 (file)
@@ -1,33 +1,21 @@
 /*
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <signal.h>
+#include <unistd.h>
 #include <errno.h>
+#include <signal.h>
+#include <string.h>
 #include <sys/resource.h>
-#include <sys/mman.h>
-#include <sys/user.h>
-#include <asm/page.h>
-#include "kern_util.h"
 #include "as-layout.h"
-#include "mem_user.h"
-#include "irq_user.h"
-#include "user.h"
 #include "init.h"
-#include "mode.h"
-#include "choose-mode.h"
-#include "uml-config.h"
+#include "kern_constants.h"
+#include "kern_util.h"
 #include "os.h"
 #include "um_malloc.h"
-#include "kern_constants.h"
-
-/* Set in main, unchanged thereafter */
-char *linux_prog;
 
 #define PGD_BOUND (4 * 1024 * 1024)
 #define STACKSIZE (8 * 1024 * 1024)
@@ -37,13 +25,13 @@ static void set_stklim(void)
 {
        struct rlimit lim;
 
-       if(getrlimit(RLIMIT_STACK, &lim) < 0){
+       if (getrlimit(RLIMIT_STACK, &lim) < 0) {
                perror("getrlimit");
                exit(1);
        }
-       if((lim.rlim_cur == RLIM_INFINITY) || (lim.rlim_cur > STACKSIZE)){
+       if ((lim.rlim_cur == RLIM_INFINITY) || (lim.rlim_cur > STACKSIZE)) {
                lim.rlim_cur = STACKSIZE;
-               if(setrlimit(RLIMIT_STACK, &lim) < 0){
+               if (setrlimit(RLIMIT_STACK, &lim) < 0) {
                        perror("setrlimit");
                        exit(1);
                }
@@ -55,7 +43,7 @@ static __init void do_uml_initcalls(void)
        initcall_t *call;
 
        call = &__uml_initcall_start;
-       while (call < &__uml_initcall_end){
+       while (call < &__uml_initcall_end) {
                (*call)();
                call++;
        }
@@ -74,7 +62,8 @@ static void install_fatal_handler(int sig)
        /* All signals are enabled in this handler ... */
        sigemptyset(&action.sa_mask);
 
-       /* ... including the signal being handled, plus we want the
+       /*
+        * ... including the signal being handled, plus we want the
         * handler reset to the default behavior, so that if an exit
         * handler is hanging for some reason, the UML will just die
         * after this signal is sent a second time.
@@ -82,7 +71,7 @@ static void install_fatal_handler(int sig)
        action.sa_flags = SA_RESETHAND | SA_NODEFER;
        action.sa_restorer = NULL;
        action.sa_handler = last_ditch_exit;
-       if(sigaction(sig, &action, NULL) < 0){
+       if (sigaction(sig, &action, NULL) < 0) {
                printf("failed to install handler for signal %d - errno = %d\n",
                       errno);
                exit(1);
@@ -98,7 +87,8 @@ static void setup_env_path(void)
        int path_len = 0;
 
        old_path = getenv("PATH");
-       /* if no PATH variable is set or it has an empty value
+       /*
+        * if no PATH variable is set or it has an empty value
         * just use the default + /usr/lib/uml
         */
        if (!old_path || (path_len = strlen(old_path)) == 0) {
@@ -126,93 +116,68 @@ int __init main(int argc, char **argv, char **envp)
        char **new_argv;
        int ret, i, err;
 
-#ifdef UML_CONFIG_CMDLINE_ON_HOST
-       /* Allocate memory for thread command lines */
-       if(argc < 2 || strlen(argv[1]) < THREAD_NAME_LEN - 1){
-
-               char padding[THREAD_NAME_LEN] = {
-                       [ 0 ...  THREAD_NAME_LEN - 2] = ' ', '\0'
-               };
-
-               new_argv = malloc((argc + 2) * sizeof(char*));
-               if(!new_argv) {
-                       perror("Allocating extended argv");
-                       exit(1);
-               }
-
-               new_argv[0] = argv[0];
-               new_argv[1] = padding;
-
-               for(i = 2; i <= argc; i++)
-                       new_argv[i] = argv[i - 1];
-               new_argv[argc + 1] = NULL;
-
-               execvp(new_argv[0], new_argv);
-               perror("execing with extended args");
-               exit(1);
-       }
-#endif
-
-       linux_prog = argv[0];
-
        set_stklim();
 
        setup_env_path();
 
        new_argv = malloc((argc + 1) * sizeof(char *));
-       if(new_argv == NULL){
+       if (new_argv == NULL) {
                perror("Mallocing argv");
                exit(1);
        }
-       for(i=0;i<argc;i++){
+       for (i = 0; i < argc; i++) {
                new_argv[i] = strdup(argv[i]);
-               if(new_argv[i] == NULL){
+               if (new_argv[i] == NULL) {
                        perror("Mallocing an arg");
                        exit(1);
                }
        }
        new_argv[argc] = NULL;
 
-       /* Allow these signals to bring down a UML if all other
+       /*
+        * Allow these signals to bring down a UML if all other
         * methods of control fail.
         */
        install_fatal_handler(SIGINT);
        install_fatal_handler(SIGTERM);
        install_fatal_handler(SIGHUP);
 
-       scan_elf_aux( envp);
+       scan_elf_aux(envp);
 
        do_uml_initcalls();
        ret = linux_main(argc, argv);
 
-       /* Disable SIGPROF - I have no idea why libc doesn't do this or turn
+       /*
+        * Disable SIGPROF - I have no idea why libc doesn't do this or turn
         * off the profiling time, but UML dies with a SIGPROF just before
         * exiting when profiling is active.
         */
        change_sig(SIGPROF, 0);
 
-       /* This signal stuff used to be in the reboot case.  However,
+       /*
+        * This signal stuff used to be in the reboot case.  However,
         * sometimes a SIGVTALRM can come in when we're halting (reproducably
         * when writing out gcov information, presumably because that takes
         * some time) and cause a segfault.
         */
 
-       /* stop timers and set SIG*ALRM to be ignored */
+       /* stop timers and set SIGVTALRM to be ignored */
        disable_timer();
 
        /* disable SIGIO for the fds and set SIGIO to be ignored */
        err = deactivate_all_fds();
-       if(err)
+       if (err)
                printf("deactivate_all_fds failed, errno = %d\n", -err);
 
-       /* Let any pending signals fire now.  This ensures
+       /*
+        * Let any pending signals fire now.  This ensures
         * that they won't be delivered after the exec, when
         * they are definitely not expected.
         */
        unblock_signals();
 
        /* Reboot */
-       if(ret){
+       if (ret) {
                printf("\n");
                execvp(new_argv[0], new_argv);
                perror("Failed to exec kernel");
@@ -222,26 +187,24 @@ int __init main(int argc, char **argv, char **envp)
        return uml_exitcode;
 }
 
-#define CAN_KMALLOC() \
-       (kmalloc_ok && CHOOSE_MODE((os_getpid() != tracing_pid), 1))
-
 extern void *__real_malloc(int);
 
 void *__wrap_malloc(int size)
 {
        void *ret;
 
-       if(!CAN_KMALLOC())
+       if (!kmalloc_ok)
                return __real_malloc(size);
-       else if(size <= UM_KERN_PAGE_SIZE)
+       else if (size <= UM_KERN_PAGE_SIZE)
                /* finding contiguous pages can be hard*/
                ret = kmalloc(size, UM_GFP_KERNEL);
        else ret = vmalloc(size);
 
-       /* glibc people insist that if malloc fails, errno should be
+       /*
+        * glibc people insist that if malloc fails, errno should be
         * set by malloc as well. So we do.
         */
-       if(ret == NULL)
+       if (ret == NULL)
                errno = ENOMEM;
 
        return ret;
@@ -251,7 +214,7 @@ void *__wrap_calloc(int n, int size)
 {
        void *ptr = __wrap_malloc(n * size);
 
-       if(ptr == NULL)
+       if (ptr == NULL)
                return NULL;
        memset(ptr, 0, n * size);
        return ptr;
@@ -265,7 +228,8 @@ void __wrap_free(void *ptr)
 {
        unsigned long addr = (unsigned long) ptr;
 
-       /* We need to know how the allocation happened, so it can be correctly
+       /*
+        * We need to know how the allocation happened, so it can be correctly
         * freed.  This is done by seeing what region of memory the pointer is
         * in -
         *      physical memory - kmalloc/kfree
@@ -283,12 +247,12 @@ void __wrap_free(void *ptr)
         * there is a possibility for memory leaks.
         */
 
-       if((addr >= uml_physmem) && (addr < high_physmem)){
-               if(CAN_KMALLOC())
+       if ((addr >= uml_physmem) && (addr < high_physmem)) {
+               if (kmalloc_ok)
                        kfree(ptr);
        }
-       else if((addr >= start_vm) && (addr < end_vm)){
-               if(CAN_KMALLOC())
+       else if ((addr >= start_vm) && (addr < end_vm)) {
+               if (kmalloc_ok)
                        vfree(ptr);
        }
        else __real_free(ptr);
index c6378c6..436f8d2 100644 (file)
@@ -218,7 +218,7 @@ int __init create_tmp_file(unsigned long long len)
 
        err = fchmod(fd, 0777);
        if(err < 0){
-               perror("os_mode_fd");
+               perror("fchmod");
                exit(1);
        }
 
@@ -226,7 +226,7 @@ int __init create_tmp_file(unsigned long long len)
         * increase the file size by one byte, to the desired length.
         */
        if (lseek64(fd, len - 1, SEEK_SET) < 0) {
-               perror("os_seek_file");
+               perror("lseek64");
                exit(1);
        }
 
@@ -247,7 +247,7 @@ int __init create_mem_file(unsigned long long len)
 
        fd = create_tmp_file(len);
 
-       err = os_set_exec_close(fd, 1);
+       err = os_set_exec_close(fd);
        if(err < 0){
                errno = -err;
                perror("exec_close");
index e9c1432..37781db 100644 (file)
@@ -1,27 +1,24 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@addtoit.com)
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <unistd.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <errno.h>
 #include <signal.h>
+#include <fcntl.h>
 #include <sys/mman.h>
+#include <sys/ptrace.h>
 #include <sys/wait.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-#include "ptrace_user.h"
+#include <asm/unistd.h>
+#include "init.h"
+#include "kern_constants.h"
+#include "longjmp.h"
 #include "os.h"
-#include "user.h"
 #include "process.h"
-#include "irq_user.h"
-#include "kern_util.h"
-#include "longjmp.h"
 #include "skas_ptrace.h"
-#include "kern_constants.h"
-#include "uml-config.h"
-#include "init.h"
+#include "user.h"
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID    -1
 unsigned long os_process_pc(int pid)
 {
        char proc_stat[STAT_PATH_LEN], buf[256];
-       unsigned long pc;
+       unsigned long pc = ARBITRARY_ADDR;
        int fd, err;
 
        sprintf(proc_stat, "/proc/%d/stat", pid);
-       fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
-       if(fd < 0){
-               printk("os_process_pc - couldn't open '%s', err = %d\n",
-                      proc_stat, -fd);
-               return ARBITRARY_ADDR;
+       fd = open(proc_stat, O_RDONLY, 0);
+       if (fd < 0) {
+               printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', "
+                      "errno = %d\n", proc_stat, errno);
+               goto out;
        }
        CATCH_EINTR(err = read(fd, buf, sizeof(buf)));
-       if(err < 0){
-               printk("os_process_pc - couldn't read '%s', err = %d\n",
-                      proc_stat, errno);
-               os_close_file(fd);
-               return ARBITRARY_ADDR;
+       if (err < 0) {
+               printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', "
+                      "err = %d\n", proc_stat, errno);
+               goto out_close;
        }
        os_close_file(fd);
        pc = ARBITRARY_ADDR;
-       if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %*d %lu", &pc) != 1){
-               printk("os_process_pc - couldn't find pc in '%s'\n", buf);
-       }
+       if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
+                  "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
+                  "%*d %*d %*d %*d %*d %lu", &pc) != 1)
+               printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n",
+                      buf);
+ out_close:
+       close(fd);
+ out:
        return pc;
 }
 
@@ -63,30 +62,32 @@ int os_process_parent(int pid)
 {
        char stat[STAT_PATH_LEN];
        char data[256];
-       int parent, n, fd;
+       int parent = FAILURE_PID, n, fd;
 
-       if(pid == -1)
-               return -1;
+       if (pid == -1)
+               return parent;
 
        snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
-       fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
-       if(fd < 0){
-               printk("Couldn't open '%s', err = %d\n", stat, -fd);
-               return FAILURE_PID;
+       fd = open(stat, O_RDONLY, 0);
+       if (fd < 0) {
+               printk(UM_KERN_ERR "Couldn't open '%s', errno = %d\n", stat,
+                      errno);
+               return parent;
        }
 
        CATCH_EINTR(n = read(fd, data, sizeof(data)));
-       os_close_file(fd);
+       close(fd);
 
-       if(n < 0){
-               printk("Couldn't read '%s', err = %d\n", stat, errno);
-               return FAILURE_PID;
+       if (n < 0) {
+               printk(UM_KERN_ERR "Couldn't read '%s', errno = %d\n", stat,
+                      errno);
+               return parent;
        }
 
        parent = FAILURE_PID;
        n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent);
-       if(n != 1)
-               printk("Failed to scan '%s'\n", data);
+       if (n != 1)
+               printk(UM_KERN_ERR "Failed to scan '%s'\n", data);
 
        return parent;
 }
@@ -99,9 +100,8 @@ void os_stop_process(int pid)
 void os_kill_process(int pid, int reap_child)
 {
        kill(pid, SIGKILL);
-       if(reap_child)
+       if (reap_child)
                CATCH_EINTR(waitpid(pid, NULL, 0));
-               
 }
 
 /* This is here uniquely to have access to the userspace errno, i.e. the one
@@ -129,17 +129,10 @@ void os_kill_ptraced_process(int pid, int reap_child)
        kill(pid, SIGKILL);
        ptrace(PTRACE_KILL, pid);
        ptrace(PTRACE_CONT, pid);
-       if(reap_child)
+       if (reap_child)
                CATCH_EINTR(waitpid(pid, NULL, 0));
 }
 
-#ifdef UML_CONFIG_MODE_TT
-void os_usr1_process(int pid)
-{
-       kill(pid, SIGUSR1);
-}
-#endif
-
 /* Don't use the glibc version, which caches the result in TLS. It misses some
  * syscalls, and also breaks with clone(), which does not unshare the TLS.
  */
@@ -160,34 +153,35 @@ int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
        void *loc;
        int prot;
 
-       prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 
+       prot = (r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
                (x ? PROT_EXEC : 0);
 
        loc = mmap64((void *) virt, len, prot, MAP_SHARED | MAP_FIXED,
                     fd, off);
-       if(loc == MAP_FAILED)
+       if (loc == MAP_FAILED)
                return -errno;
        return 0;
 }
 
 int os_protect_memory(void *addr, unsigned long len, int r, int w, int x)
 {
-        int prot = ((r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) | 
+       int prot = ((r ? PROT_READ : 0) | (w ? PROT_WRITE : 0) |
                    (x ? PROT_EXEC : 0));
 
-        if(mprotect(addr, len, prot) < 0)
+       if (mprotect(addr, len, prot) < 0)
                return -errno;
-        return 0;
+
+       return 0;
 }
 
 int os_unmap_memory(void *addr, int len)
 {
-        int err;
+       int err;
 
-        err = munmap(addr, len);
-       if(err < 0)
+       err = munmap(addr, len);
+       if (err < 0)
                return -errno;
-        return 0;
+       return 0;
 }
 
 #ifndef MADV_REMOVE
@@ -199,7 +193,7 @@ int os_drop_memory(void *addr, int length)
        int err;
 
        err = madvise(addr, length, MADV_REMOVE);
-       if(err < 0)
+       if (err < 0)
                err = -errno;
        return err;
 }
@@ -209,22 +203,24 @@ int __init can_drop_memory(void)
        void *addr;
        int fd, ok = 0;
 
-       printk("Checking host MADV_REMOVE support...");
+       printk(UM_KERN_INFO "Checking host MADV_REMOVE support...");
        fd = create_mem_file(UM_KERN_PAGE_SIZE);
-       if(fd < 0){
-               printk("Creating test memory file failed, err = %d\n", -fd);
+       if (fd < 0) {
+               printk(UM_KERN_ERR "Creating test memory file failed, "
+                      "err = %d\n", -fd);
                goto out;
        }
 
        addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
                      MAP_SHARED, fd, 0);
-       if(addr == MAP_FAILED){
-               printk("Mapping test memory file failed, err = %d\n", -errno);
+       if (addr == MAP_FAILED) {
+               printk(UM_KERN_ERR "Mapping test memory file failed, "
+                      "err = %d\n", -errno);
                goto out_close;
        }
 
-       if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){
-               printk("MADV_REMOVE failed, err = %d\n", -errno);
+       if (madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0) {
+               printk(UM_KERN_ERR "MADV_REMOVE failed, err = %d\n", -errno);
                goto out_unmap;
        }
 
@@ -239,58 +235,31 @@ out:
        return ok;
 }
 
-#ifdef UML_CONFIG_MODE_TT
-void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
-{
-       int flags = 0, pages;
-
-       if(sig_stack != NULL){
-               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
-               set_sigstack(sig_stack, pages * UM_KERN_PAGE_SIZE);
-               flags = SA_ONSTACK;
-       }
-       if(usr1_handler){
-               struct sigaction sa;
-
-               sa.sa_handler = usr1_handler;
-               sigemptyset(&sa.sa_mask);
-               sa.sa_flags = flags;
-               sa.sa_restorer = NULL;
-               if(sigaction(SIGUSR1, &sa, NULL) < 0)
-                       panic("init_new_thread_stack - sigaction failed - "
-                             "errno = %d\n", errno);
-       }
-}
-#endif
-
 void init_new_thread_signals(void)
 {
        set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
-       set_handler(SIGUSR2, (__sighandler_t) sig_handler,
-                   SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM,
-                   -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        signal(SIGHUP, SIG_IGN);
 
        init_irq_signals(1);
 }
 
-int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
+int run_kernel_thread(int (*fn)(void *), void *arg, jmp_buf **jmp_ptr)
 {
        jmp_buf buf;
        int n;
 
        *jmp_ptr = &buf;
        n = UML_SETJMP(&buf);
-       if(n != 0)
+       if (n != 0)
                return n;
        (*fn)(arg);
        return 0;
diff --git a/arch/um/os-Linux/registers.c b/arch/um/os-Linux/registers.c
new file mode 100644 (file)
index 0000000..a32ba6a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004 PathScale, Inc
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/ptrace.h>
+#include "sysdep/ptrace.h"
+#include "user.h"
+
+/* This is set once at boot time and not changed thereafter */
+
+static unsigned long exec_regs[MAX_REG_NR];
+
+void init_thread_registers(struct uml_pt_regs *to)
+{
+       memcpy(to->gp, exec_regs, sizeof(to->gp));
+}
+
+void save_registers(int pid, struct uml_pt_regs *regs)
+{
+       int err;
+
+       err = ptrace(PTRACE_GETREGS, pid, 0, regs->gp);
+       if (err < 0)
+               panic("save_registers - saving registers failed, errno = %d\n",
+                     errno);
+}
+
+void restore_registers(int pid, struct uml_pt_regs *regs)
+{
+       int err;
+
+       err = ptrace(PTRACE_SETREGS, pid, 0, regs->gp);
+       if (err < 0)
+               panic("restore_registers - saving registers failed, "
+                     "errno = %d\n", errno);
+}
+
+void init_registers(int pid)
+{
+       int err;
+
+       err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
+       if (err)
+               panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
+                     errno);
+
+       arch_init_registers(pid);
+}
+
+void get_safe_registers(unsigned long *regs)
+{
+       memcpy(regs, exec_regs, sizeof(exec_regs));
+}
index b98f7ea..e9800b0 100644 (file)
@@ -1,26 +1,21 @@
 /*
  * Copyright (C) 2004 PathScale, Inc
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <stdarg.h>
-#include <string.h>
-#include <sys/mman.h>
-#include "user.h"
-#include "signal_kern.h"
-#include "sysdep/sigcontext.h"
-#include "sysdep/barrier.h"
-#include "sigcontext.h"
-#include "mode.h"
+#include <errno.h>
+#include <signal.h>
+#include <strings.h>
 #include "os.h"
+#include "sysdep/barrier.h"
+#include "sysdep/sigcontext.h"
+#include "user.h"
 
-/* These are the asynchronous signals.  SIGVTALRM and SIGARLM are handled
- * together under SIGVTALRM_BIT.  SIGPROF is excluded because we want to
+/*
+ * These are the asynchronous signals.  SIGPROF is excluded because we want to
  * be able to profile all of UML, not just the non-critical sections.  If
  * profiling is not thread-safe, then that is not my problem.  We can disable
  * profiling when SMP is enabled in that case.
 #define SIGVTALRM_BIT 1
 #define SIGVTALRM_MASK (1 << SIGVTALRM_BIT)
 
-#define SIGALRM_BIT 2
-#define SIGALRM_MASK (1 << SIGALRM_BIT)
-
-/* These are used by both the signal handlers and
+/*
+ * These are used by both the signal handlers and
  * block/unblock_signals.  I don't want modifications cached in a
  * register - they must go straight to memory.
  */
@@ -46,34 +39,27 @@ void sig_handler(int sig, struct sigcontext *sc)
        int enabled;
 
        enabled = signals_enabled;
-       if(!enabled && (sig == SIGIO)){
+       if (!enabled && (sig == SIGIO)) {
                pending |= SIGIO_MASK;
                return;
        }
 
        block_signals();
 
-       CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas,
-                        sig, sc);
+       sig_handler_common_skas(sig, sc);
 
        set_signals(enabled);
 }
 
-static void real_alarm_handler(int sig, struct sigcontext *sc)
+static void real_alarm_handler(struct sigcontext *sc)
 {
-       union uml_pt_regs regs;
+       struct uml_pt_regs regs;
 
-       if(sig == SIGALRM)
-               switch_timers(0);
-
-       if(sc != NULL)
+       if (sc != NULL)
                copy_sc(&regs, sc);
-       regs.skas.is_user = 0;
+       regs.is_user = 0;
        unblock_signals();
-       timer_handler(sig, &regs);
-
-       if(sig == SIGALRM)
-               switch_timers(1);
+       timer_handler(SIGVTALRM, &regs);
 }
 
 void alarm_handler(int sig, struct sigcontext *sc)
@@ -81,27 +67,30 @@ void alarm_handler(int sig, struct sigcontext *sc)
        int enabled;
 
        enabled = signals_enabled;
-       if(!signals_enabled){
-               if(sig == SIGVTALRM)
-                       pending |= SIGVTALRM_MASK;
-               else pending |= SIGALRM_MASK;
-
+       if (!signals_enabled) {
+               pending |= SIGVTALRM_MASK;
                return;
        }
 
        block_signals();
 
-       real_alarm_handler(sig, sc);
+       real_alarm_handler(sc);
        set_signals(enabled);
 }
 
+void timer_init(void)
+{
+       set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
+                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, -1);
+}
+
 void set_sigstack(void *sig_stack, int size)
 {
        stack_t stack = ((stack_t) { .ss_flags  = 0,
                                     .ss_sp     = (__ptr_t) sig_stack,
                                     .ss_size   = size - sizeof(void *) });
 
-       if(sigaltstack(&stack, NULL) != 0)
+       if (sigaltstack(&stack, NULL) != 0)
                panic("enabling signal stack failed, errno = %d\n", errno);
 }
 
@@ -111,7 +100,7 @@ void remove_sigstack(void)
                                     .ss_sp     = NULL,
                                     .ss_size   = 0 });
 
-       if(sigaltstack(&stack, NULL) != 0)
+       if (sigaltstack(&stack, NULL) != 0)
                panic("disabling signal stack failed, errno = %d\n", errno);
 }
 
@@ -135,26 +124,27 @@ void handle_signal(int sig, struct sigcontext *sc)
                 * with this interrupt.
                 */
                bail = to_irq_stack(&pending);
-               if(bail)
+               if (bail)
                        return;
 
                nested = pending & 1;
                pending &= ~1;
 
-               while((sig = ffs(pending)) != 0){
+               while ((sig = ffs(pending)) != 0){
                        sig--;
                        pending &= ~(1 << sig);
                        (*handlers[sig])(sig, sc);
                }
 
-               /* Again, pending comes back with a mask of signals
+               /*
+                * Again, pending comes back with a mask of signals
                 * that arrived while tearing down the stack.  If this
                 * is non-zero, we just go back, set up the stack
                 * again, and handle the new interrupts.
                 */
-               if(!nested)
+               if (!nested)
                        pending = from_irq_stack(nested);
-       } while(pending);
+       } while (pending);
 }
 
 extern void hard_handler(int sig);
@@ -172,18 +162,18 @@ void set_handler(int sig, void (*handler)(int), int flags, ...)
        sigemptyset(&action.sa_mask);
 
        va_start(ap, flags);
-       while((mask = va_arg(ap, int)) != -1)
+       while ((mask = va_arg(ap, int)) != -1)
                sigaddset(&action.sa_mask, mask);
        va_end(ap);
 
        action.sa_flags = flags;
        action.sa_restorer = NULL;
-       if(sigaction(sig, &action, NULL) < 0)
+       if (sigaction(sig, &action, NULL) < 0)
                panic("sigaction failed - errno = %d\n", errno);
 
        sigemptyset(&sig_mask);
        sigaddset(&sig_mask, sig);
-       if(sigprocmask(SIG_UNBLOCK, &sig_mask, NULL) < 0)
+       if (sigprocmask(SIG_UNBLOCK, &sig_mask, NULL) < 0)
                panic("sigprocmask failed - errno = %d\n", errno);
 }
 
@@ -194,13 +184,14 @@ int change_sig(int signal, int on)
        sigemptyset(&sigset);
        sigaddset(&sigset, signal);
        sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old);
-       return(!sigismember(&old, signal));
+       return !sigismember(&old, signal);
 }
 
 void block_signals(void)
 {
        signals_enabled = 0;
-       /* This must return with signals disabled, so this barrier
+       /*
+        * This must return with signals disabled, so this barrier
         * ensures that writes are flushed out before the return.
         * This might matter if gcc figures out how to inline this and
         * decides to shuffle this code into the caller.
@@ -212,27 +203,31 @@ void unblock_signals(void)
 {
        int save_pending;
 
-       if(signals_enabled == 1)
+       if (signals_enabled == 1)
                return;
 
-       /* We loop because the IRQ handler returns with interrupts off.  So,
+       /*
+        * We loop because the IRQ handler returns with interrupts off.  So,
         * interrupts may have arrived and we need to re-enable them and
         * recheck pending.
         */
-       while(1){
-               /* Save and reset save_pending after enabling signals.  This
+       while(1) {
+               /*
+                * Save and reset save_pending after enabling signals.  This
                 * way, pending won't be changed while we're reading it.
                 */
                signals_enabled = 1;
 
-               /* Setting signals_enabled and reading pending must
+               /*
+                * Setting signals_enabled and reading pending must
                 * happen in this order.
                 */
                mb();
 
                save_pending = pending;
-               if(save_pending == 0){
-                       /* This must return with signals enabled, so
+               if (save_pending == 0) {
+                       /*
+                        * This must return with signals enabled, so
                         * this barrier ensures that writes are
                         * flushed out before the return.  This might
                         * matter if gcc figures out how to inline
@@ -245,26 +240,24 @@ void unblock_signals(void)
 
                pending = 0;
 
-               /* We have pending interrupts, so disable signals, as the
+               /*
+                * We have pending interrupts, so disable signals, as the
                 * handlers expect them off when they are called.  They will
                 * be enabled again above.
                 */
 
                signals_enabled = 0;
 
-               /* Deal with SIGIO first because the alarm handler might
+               /*
+                * Deal with SIGIO first because the alarm handler might
                 * schedule, leaving the pending SIGIO stranded until we come
                 * back here.
                 */
-               if(save_pending & SIGIO_MASK)
-                       CHOOSE_MODE_PROC(sig_handler_common_tt,
-                                        sig_handler_common_skas, SIGIO, NULL);
-
-               if(save_pending & SIGALRM_MASK)
-                       real_alarm_handler(SIGALRM, NULL);
+               if (save_pending & SIGIO_MASK)
+                       sig_handler_common_skas(SIGIO, NULL);
 
-               if(save_pending & SIGVTALRM_MASK)
-                       real_alarm_handler(SIGVTALRM, NULL);
+               if (save_pending & SIGVTALRM_MASK)
+                       real_alarm_handler(NULL);
        }
 }
 
@@ -276,11 +269,11 @@ int get_signals(void)
 int set_signals(int enable)
 {
        int ret;
-       if(signals_enabled == enable)
+       if (signals_enabled == enable)
                return enable;
 
        ret = signals_enabled;
-       if(enable)
+       if (enable)
                unblock_signals();
        else block_signals();
 
index 0f7df4e..484e68f 100644 (file)
@@ -1,31 +1,26 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <signal.h>
+#include <stddef.h>
+#include <unistd.h>
 #include <errno.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/mman.h>
-#include <sys/wait.h>
-#include <asm/page.h>
-#include <asm/unistd.h>
-#include "mem_user.h"
-#include "mem.h"
-#include "skas.h"
-#include "user.h"
+#include "init.h"
+#include "kern_constants.h"
+#include "as-layout.h"
+#include "mm_id.h"
 #include "os.h"
 #include "proc_mm.h"
 #include "ptrace_user.h"
-#include "kern_util.h"
-#include "task.h"
 #include "registers.h"
-#include "uml-config.h"
+#include "skas.h"
+#include "user.h"
 #include "sysdep/ptrace.h"
 #include "sysdep/stub.h"
-#include "init.h"
-#include "kern_constants.h"
+#include "uml-config.h"
 
 extern unsigned long batch_syscall_stub, __syscall_stub_start;
 
@@ -34,7 +29,7 @@ extern void wait_stub_done(int pid);
 static inline unsigned long *check_init_stack(struct mm_id * mm_idp,
                                              unsigned long *stack)
 {
-       if(stack == NULL) {
+       if (stack == NULL) {
                stack = (unsigned long *) mm_idp->stack + 2;
                *stack = 0;
        }
@@ -45,8 +40,8 @@ static unsigned long syscall_regs[MAX_REG_NR];
 
 static int __init init_syscall_regs(void)
 {
-       get_safe_registers(syscall_regs, NULL);
-       syscall_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE +
+       get_safe_registers(syscall_regs);
+       syscall_regs[REGS_IP_INDEX] = STUB_CODE +
                ((unsigned long) &batch_syscall_stub -
                 (unsigned long) &__syscall_stub_start);
        return 0;
@@ -68,29 +63,30 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
        unsigned long * syscall;
        int err, pid = mm_idp->u.pid;
 
-       if(proc_mm)
+       if (proc_mm)
                /* FIXME: Need to look up userspace_pid by cpu */
                pid = userspace_pid[0];
 
        multi_count++;
 
        n = ptrace_setregs(pid, syscall_regs);
-       if(n < 0){
-               printk("Registers - \n");
-               for(i = 0; i < MAX_REG_NR; i++)
-                       printk("\t%d\t0x%lx\n", i, syscall_regs[i]);
+       if (n < 0) {
+               printk(UM_KERN_ERR "Registers - \n");
+               for (i = 0; i < MAX_REG_NR; i++)
+                       printk(UM_KERN_ERR "\t%d\t0x%lx\n", i, syscall_regs[i]);
                panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
                      -n);
        }
 
        err = ptrace(PTRACE_CONT, pid, 0, 0);
-       if(err)
+       if (err)
                panic("Failed to continue stub, pid = %d, errno = %d\n", pid,
                      errno);
 
        wait_stub_done(pid);
 
-       /* When the stub stops, we find the following values on the
+       /*
+        * When the stub stops, we find the following values on the
         * beginning of the stack:
         * (long )return_value
         * (long )offset to failed sycall-data (0, if no error)
@@ -98,26 +94,26 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
        ret = *((unsigned long *) mm_idp->stack);
        offset = *((unsigned long *) mm_idp->stack + 1);
        if (offset) {
-               data = (unsigned long *)(mm_idp->stack +
-                                        offset - UML_CONFIG_STUB_DATA);
-               printk("do_syscall_stub : ret = %ld, offset = %ld, "
+               data = (unsigned long *)(mm_idp->stack + offset - STUB_DATA);
+               printk(UM_KERN_ERR "do_syscall_stub : ret = %ld, offset = %ld, "
                       "data = %p\n", ret, offset, data);
                syscall = (unsigned long *)((unsigned long)data + data[0]);
-               printk("do_syscall_stub: syscall %ld failed, return value = "
-                      "0x%lx, expected return value = 0x%lx\n",
+               printk(UM_KERN_ERR "do_syscall_stub: syscall %ld failed, "
+                      "return value = 0x%lx, expected return value = 0x%lx\n",
                       syscall[0], ret, syscall[7]);
-               printk("    syscall parameters: "
+               printk(UM_KERN_ERR "    syscall parameters: "
                       "0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
                       syscall[1], syscall[2], syscall[3],
                       syscall[4], syscall[5], syscall[6]);
-               for(n = 1; n < data[0]/sizeof(long); n++) {
-                       if(n == 1)
-                               printk("    additional syscall data:");
-                       if(n % 4 == 1)
-                               printk("\n      ");
+               for (n = 1; n < data[0]/sizeof(long); n++) {
+                       if (n == 1)
+                               printk(UM_KERN_ERR "    additional syscall "
+                                      "data:");
+                       if (n % 4 == 1)
+                               printk("\n" UM_KERN_ERR "      ");
                        printk("  0x%lx", data[n]);
                }
-               if(n > 1)
+               if (n > 1)
                        printk("\n");
        }
        else ret = 0;
@@ -133,7 +129,7 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
 {
        unsigned long *stack = check_init_stack(mm_idp, *addr);
 
-       if(done && *addr == NULL)
+       if (done && *addr == NULL)
                single_count++;
 
        *stack += sizeof(long);
@@ -150,8 +146,8 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
        *stack = 0;
        multi_op_count++;
 
-       if(!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
-                    UM_KERN_PAGE_SIZE - 10 * sizeof(long))){
+       if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
+                    UM_KERN_PAGE_SIZE - 10 * sizeof(long))) {
                *addr = stack;
                return 0;
        }
@@ -166,14 +162,15 @@ long syscall_stub_data(struct mm_id * mm_idp,
        unsigned long *stack;
        int ret = 0;
 
-       /* If *addr still is uninitialized, it *must* contain NULL.
+       /*
+        * If *addr still is uninitialized, it *must* contain NULL.
         * Thus in this case do_syscall_stub correctly won't be called.
         */
-       if((((unsigned long) *addr) & ~UM_KERN_PAGE_MASK) >=
+       if ((((unsigned long) *addr) & ~UM_KERN_PAGE_MASK) >=
           UM_KERN_PAGE_SIZE - (10 + data_count) * sizeof(long)) {
                ret = do_syscall_stub(mm_idp, addr);
                /* in case of error, don't overwrite data on stack */
-               if(ret)
+               if (ret)
                        return ret;
        }
 
@@ -185,7 +182,7 @@ long syscall_stub_data(struct mm_id * mm_idp,
        memcpy(stack + 1, data, data_count * sizeof(long));
 
        *stub_addr = (void *)(((unsigned long)(stack + 1) &
-                              ~UM_KERN_PAGE_MASK) + UML_CONFIG_STUB_DATA);
+                              ~UM_KERN_PAGE_MASK) + STUB_DATA);
 
        return 0;
 }
@@ -195,7 +192,7 @@ int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, int prot,
 {
        int ret;
 
-       if(proc_mm){
+       if (proc_mm) {
                struct proc_mm_op map;
                int fd = mm_idp->u.mm_fd;
 
@@ -211,9 +208,10 @@ int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, int prot,
                                           .offset= offset
                                         } } } );
                CATCH_EINTR(ret = write(fd, &map, sizeof(map)));
-               if(ret != sizeof(map)){
+               if (ret != sizeof(map)) {
                        ret = -errno;
-                       printk("map : /proc/mm map failed, err = %d\n", -ret);
+                       printk(UM_KERN_ERR "map : /proc/mm map failed, "
+                              "err = %d\n", -ret);
                }
                else ret = 0;
        }
@@ -234,7 +232,7 @@ int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
 {
        int ret;
 
-       if(proc_mm){
+       if (proc_mm) {
                struct proc_mm_op unmap;
                int fd = mm_idp->u.mm_fd;
 
@@ -245,9 +243,10 @@ int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
                                             (unsigned long) addr,
                                             .len               = len } } } );
                CATCH_EINTR(ret = write(fd, &unmap, sizeof(unmap)));
-               if(ret != sizeof(unmap)){
+               if (ret != sizeof(unmap)) {
                        ret = -errno;
-                       printk("unmap - proc_mm write returned %d\n", ret);
+                       printk(UM_KERN_ERR "unmap - proc_mm write returned "
+                              "%d\n", ret);
                }
                else ret = 0;
        }
@@ -268,7 +267,7 @@ int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
        struct proc_mm_op protect;
        int ret;
 
-       if(proc_mm){
+       if (proc_mm) {
                int fd = mm_idp->u.mm_fd;
 
                protect = ((struct proc_mm_op) { .op    = MM_MPROTECT,
@@ -280,9 +279,9 @@ int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
                                               .prot    = prot } } } );
 
                CATCH_EINTR(ret = write(fd, &protect, sizeof(protect)));
-               if(ret != sizeof(protect)){
+               if (ret != sizeof(protect)) {
                        ret = -errno;
-                       printk("protect failed, err = %d", -ret);
+                       printk(UM_KERN_ERR "protect failed, err = %d", -ret);
                }
                else ret = 0;
        }
@@ -295,7 +294,3 @@ int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
 
        return ret;
 }
-
-void before_mem_skas(unsigned long unused)
-{
-}
index ba9af8d..d77c81d 100644 (file)
@@ -1,48 +1,38 @@
 /*
- * Copyright (C) 2002- 2004 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
-#include <errno.h>
-#include <signal.h>
 #include <sched.h>
-#include "ptrace_user.h"
-#include <sys/wait.h>
+#include <errno.h>
+#include <string.h>
 #include <sys/mman.h>
-#include <sys/user.h>
-#include <sys/time.h>
-#include <sys/syscall.h>
-#include <asm/types.h>
-#include "user.h"
-#include "sysdep/ptrace.h"
-#include "kern_util.h"
-#include "skas.h"
-#include "stub-data.h"
-#include "mm_id.h"
-#include "sysdep/sigcontext.h"
-#include "sysdep/stub.h"
-#include "os.h"
-#include "proc_mm.h"
-#include "skas_ptrace.h"
+#include <sys/ptrace.h>
+#include <sys/wait.h>
+#include <asm/unistd.h>
+#include "as-layout.h"
 #include "chan_user.h"
-#include "registers.h"
+#include "kern_constants.h"
 #include "mem.h"
-#include "uml-config.h"
+#include "os.h"
 #include "process.h"
-#include "longjmp.h"
-#include "kern_constants.h"
-#include "as-layout.h"
+#include "proc_mm.h"
+#include "ptrace_user.h"
+#include "registers.h"
+#include "skas.h"
+#include "skas_ptrace.h"
+#include "user.h"
+#include "sysdep/stub.h"
 
 int is_skas_winch(int pid, int fd, void *data)
 {
-       if(pid != os_getpgrp())
-               return(0);
+       if (pid != getpgrp())
+               return 0;
 
        register_winch_irq(-1, fd, -1, data, 0);
-       return(1);
+       return 1;
 }
 
 static int ptrace_dump_regs(int pid)
@@ -50,13 +40,12 @@ static int ptrace_dump_regs(int pid)
         unsigned long regs[MAX_REG_NR];
         int i;
 
-        if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
+        if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
                 return -errno;
-        else {
-                printk("Stub registers -\n");
-                for(i = 0; i < ARRAY_SIZE(regs); i++)
-                        printk("\t%d - %lx\n", i, regs[i]);
-        }
+
+       printk(UM_KERN_ERR "Stub registers -\n");
+       for (i = 0; i < ARRAY_SIZE(regs); i++)
+               printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]);
 
         return 0;
 }
@@ -74,27 +63,28 @@ void wait_stub_done(int pid)
 {
        int n, status, err;
 
-       while(1){
+       while (1) {
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-               if((n < 0) || !WIFSTOPPED(status))
+               if ((n < 0) || !WIFSTOPPED(status))
                        goto bad_wait;
 
-               if(((1 << WSTOPSIG(status)) & STUB_SIG_MASK) == 0)
+               if (((1 << WSTOPSIG(status)) & STUB_SIG_MASK) == 0)
                        break;
 
                err = ptrace(PTRACE_CONT, pid, 0, 0);
-               if(err)
+               if (err)
                        panic("wait_stub_done : continue failed, errno = %d\n",
                              errno);
        }
 
-       if(((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
+       if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
                return;
 
 bad_wait:
        err = ptrace_dump_regs(pid);
-       if(err)
-               printk("Failed to get registers from stub, errno = %d\n", -err);
+       if (err)
+               printk(UM_KERN_ERR "Failed to get registers from stub, "
+                      "errno = %d\n", -err);
        panic("wait_stub_done : failed to wait for SIGUSR1/SIGTRAP, pid = %d, "
              "n = %d, errno = %d, status = 0x%x\n", pid, n, errno, status);
 }
@@ -105,9 +95,9 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi)
 {
        int err;
 
-       if(ptrace_faultinfo){
+       if (ptrace_faultinfo) {
                err = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
-               if(err)
+               if (err)
                        panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, "
                              "errno = %d\n", errno);
 
@@ -119,52 +109,57 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi)
        }
        else {
                err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV);
-               if(err)
+               if (err)
                        panic("Failed to continue stub, pid = %d, errno = %d\n",
                              pid, errno);
                wait_stub_done(pid);
 
-               /* faultinfo is prepared by the stub-segv-handler at start of
+               /*
+                * faultinfo is prepared by the stub-segv-handler at start of
                 * the stub stack page. We just have to copy it.
                 */
                memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
        }
 }
 
-static void handle_segv(int pid, union uml_pt_regs * regs)
+static void handle_segv(int pid, struct uml_pt_regs * regs)
 {
-       get_skas_faultinfo(pid, &regs->skas.faultinfo);
-       segv(regs->skas.faultinfo, 0, 1, NULL);
+       get_skas_faultinfo(pid, &regs->faultinfo);
+       segv(regs->faultinfo, 0, 1, NULL);
 }
 
-/*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/
-static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu)
+/*
+ * To use the same value of using_sysemu as the caller, ask it that value
+ * (in local_using_sysemu
+ */
+static void handle_trap(int pid, struct uml_pt_regs *regs,
+                       int local_using_sysemu)
 {
        int err, status;
 
        /* Mark this as a syscall */
-       UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->skas.regs);
+       UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->gp);
 
        if (!local_using_sysemu)
        {
                err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
                             __NR_getpid);
-               if(err < 0)
-                       panic("handle_trap - nullifying syscall failed errno = %d\n",
-                             errno);
+               if (err < 0)
+                       panic("handle_trap - nullifying syscall failed, "
+                             "errno = %d\n", errno);
 
                err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
-               if(err < 0)
-                       panic("handle_trap - continuing to end of syscall failed, "
-                             "errno = %d\n", errno);
+               if (err < 0)
+                       panic("handle_trap - continuing to end of syscall "
+                             "failed, errno = %d\n", errno);
 
                CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
-               if((err < 0) || !WIFSTOPPED(status) ||
-                  (WSTOPSIG(status) != SIGTRAP + 0x80)){
+               if ((err < 0) || !WIFSTOPPED(status) ||
+                  (WSTOPSIG(status) != SIGTRAP + 0x80)) {
                         err = ptrace_dump_regs(pid);
-                        if(err)
-                                printk("Failed to get registers from process, "
-                                       "errno = %d\n", -err);
+                        if (err)
+                                printk(UM_KERN_ERR "Failed to get registers "
+                                      "from process, errno = %d\n", -err);
                        panic("handle_trap - failed to wait at end of syscall, "
                              "errno = %d, status = %d\n", errno, status);
                 }
@@ -182,63 +177,64 @@ static int userspace_tramp(void *stack)
 
        ptrace(PTRACE_TRACEME, 0, 0, 0);
 
-       init_new_thread_signals();
-       err = set_interval(1);
-       if(err)
+       signal(SIGTERM, SIG_DFL);
+       err = set_interval();
+       if (err)
                panic("userspace_tramp - setting timer failed, errno = %d\n",
                      err);
 
-       if(!proc_mm){
-               /* This has a pte, but it can't be mapped in with the usual
+       if (!proc_mm) {
+               /*
+                * This has a pte, but it can't be mapped in with the usual
                 * tlb_flush mechanism because this is part of that mechanism
                 */
                int fd;
-               __u64 offset;
+               unsigned long long offset;
                fd = phys_mapping(to_phys(&__syscall_stub_start), &offset);
-               addr = mmap64((void *) UML_CONFIG_STUB_CODE, UM_KERN_PAGE_SIZE,
+               addr = mmap64((void *) STUB_CODE, UM_KERN_PAGE_SIZE,
                              PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset);
-               if(addr == MAP_FAILED){
-                       printk("mapping mmap stub failed, errno = %d\n",
-                              errno);
+               if (addr == MAP_FAILED) {
+                       printk(UM_KERN_ERR "mapping mmap stub at 0x%lx failed, "
+                              "errno = %d\n", STUB_CODE, errno);
                        exit(1);
                }
 
-               if(stack != NULL){
+               if (stack != NULL) {
                        fd = phys_mapping(to_phys(stack), &offset);
-                       addr = mmap((void *) UML_CONFIG_STUB_DATA,
+                       addr = mmap((void *) STUB_DATA,
                                    UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
                                    MAP_FIXED | MAP_SHARED, fd, offset);
-                       if(addr == MAP_FAILED){
-                               printk("mapping segfault stack failed, "
-                                      "errno = %d\n", errno);
+                       if (addr == MAP_FAILED) {
+                               printk(UM_KERN_ERR "mapping segfault stack "
+                                      "at 0x%lx failed, errno = %d\n",
+                                      STUB_DATA, errno);
                                exit(1);
                        }
                }
        }
-       if(!ptrace_faultinfo && (stack != NULL)){
+       if (!ptrace_faultinfo && (stack != NULL)) {
                struct sigaction sa;
 
-               unsigned long v = UML_CONFIG_STUB_CODE +
+               unsigned long v = STUB_CODE +
                                  (unsigned long) stub_segv_handler -
                                  (unsigned long) &__syscall_stub_start;
 
-               set_sigstack((void *) UML_CONFIG_STUB_DATA, UM_KERN_PAGE_SIZE);
+               set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);
                sigemptyset(&sa.sa_mask);
                sigaddset(&sa.sa_mask, SIGIO);
                sigaddset(&sa.sa_mask, SIGWINCH);
-               sigaddset(&sa.sa_mask, SIGALRM);
                sigaddset(&sa.sa_mask, SIGVTALRM);
                sigaddset(&sa.sa_mask, SIGUSR1);
                sa.sa_flags = SA_ONSTACK;
                sa.sa_handler = (void *) v;
                sa.sa_restorer = NULL;
-               if(sigaction(SIGSEGV, &sa, NULL) < 0)
+               if (sigaction(SIGSEGV, &sa, NULL) < 0)
                        panic("userspace_tramp - setting SIGSEGV handler "
                              "failed - errno = %d\n", errno);
        }
 
-       os_stop_process(os_getpid());
-       return(0);
+       kill(os_getpid(), SIGSTOP);
+       return 0;
 }
 
 /* Each element set once, and only accessed by a single processor anyway */
@@ -255,44 +251,55 @@ int start_userspace(unsigned long stub_stack)
        stack = mmap(NULL, UM_KERN_PAGE_SIZE,
                     PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-       if(stack == MAP_FAILED)
+       if (stack == MAP_FAILED)
                panic("start_userspace : mmap failed, errno = %d", errno);
        sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
 
        flags = CLONE_FILES | SIGCHLD;
-       if(proc_mm) flags |= CLONE_VM;
+       if (proc_mm)
+               flags |= CLONE_VM;
+
        pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
-       if(pid < 0)
+       if (pid < 0)
                panic("start_userspace : clone failed, errno = %d", errno);
 
        do {
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-               if(n < 0)
+               if (n < 0)
                        panic("start_userspace : wait failed, errno = %d",
                              errno);
-       } while(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
+       } while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
 
-       if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
+       if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
                panic("start_userspace : expected SIGSTOP, got status = %d",
                      status);
 
-       if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, (void *)PTRACE_O_TRACESYSGOOD) < 0)
-               panic("start_userspace : PTRACE_OLDSETOPTIONS failed, errno=%d\n",
-                     errno);
+       if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
+                  (void *) PTRACE_O_TRACESYSGOOD) < 0)
+               panic("start_userspace : PTRACE_OLDSETOPTIONS failed, "
+                     "errno = %d\n", errno);
 
-       if(munmap(stack, UM_KERN_PAGE_SIZE) < 0)
+       if (munmap(stack, UM_KERN_PAGE_SIZE) < 0)
                panic("start_userspace : munmap failed, errno = %d\n", errno);
 
-       return(pid);
+       return pid;
 }
 
-void userspace(union uml_pt_regs *regs)
+void userspace(struct uml_pt_regs *regs)
 {
+       struct itimerval timer;
+       unsigned long long nsecs, now;
        int err, status, op, pid = userspace_pid[0];
        /* To prevent races if using_sysemu changes under us.*/
        int local_using_sysemu;
 
-       while(1){
+       if (getitimer(ITIMER_VIRTUAL, &timer))
+               printk("Failed to get itimer, errno = %d\n", errno);
+       nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC +
+               timer.it_value.tv_usec * UM_NSEC_PER_USEC;
+       nsecs += os_nsecs();
+
+       while (1) {
                restore_registers(pid, regs);
 
                /* Now we set local_using_sysemu to be used for one loop */
@@ -302,26 +309,28 @@ void userspace(union uml_pt_regs *regs)
                                             singlestepping(NULL));
 
                err = ptrace(op, pid, 0, 0);
-               if(err)
+               if (err)
                        panic("userspace - could not resume userspace process, "
                              "pid=%d, ptrace operation = %d, errno = %d\n",
                              pid, op, errno);
 
                CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
-               if(err < 0)
+               if (err < 0)
                        panic("userspace - waitpid failed, errno = %d\n",
                              errno);
 
-               regs->skas.is_user = 1;
+               regs->is_user = 1;
                save_registers(pid, regs);
                UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
 
-               if(WIFSTOPPED(status)){
+               if (WIFSTOPPED(status)) {
                        int sig = WSTOPSIG(status);
-                       switch(sig){
+                       switch(sig) {
                        case SIGSEGV:
-                               if(PTRACE_FULL_FAULTINFO || !ptrace_faultinfo){
-                                       get_skas_faultinfo(pid, &regs->skas.faultinfo);
+                               if (PTRACE_FULL_FAULTINFO ||
+                                   !ptrace_faultinfo) {
+                                       get_skas_faultinfo(pid,
+                                                          &regs->faultinfo);
                                        (*sig_info[SIGSEGV])(SIGSEGV, regs);
                                }
                                else handle_segv(pid, regs);
@@ -332,8 +341,20 @@ void userspace(union uml_pt_regs *regs)
                        case SIGTRAP:
                                relay_signal(SIGTRAP, regs);
                                break;
-                       case SIGIO:
                        case SIGVTALRM:
+                               now = os_nsecs();
+                               if(now < nsecs)
+                                       break;
+                               block_signals();
+                               (*sig_info[sig])(sig, regs);
+                               unblock_signals();
+                               nsecs = timer.it_value.tv_sec *
+                                       UM_NSEC_PER_SEC +
+                                       timer.it_value.tv_usec *
+                                       UM_NSEC_PER_USEC;
+                               nsecs += os_nsecs();
+                               break;
+                       case SIGIO:
                        case SIGILL:
                        case SIGBUS:
                        case SIGFPE:
@@ -343,30 +364,29 @@ void userspace(union uml_pt_regs *regs)
                                unblock_signals();
                                break;
                        default:
-                               printk("userspace - child stopped with signal "
-                                      "%d\n", sig);
+                               printk(UM_KERN_ERR "userspace - child stopped "
+                                      "with signal %d\n", sig);
                        }
                        pid = userspace_pid[0];
                        interrupt_end();
 
                        /* Avoid -ERESTARTSYS handling in host */
-                       if(PT_SYSCALL_NR_OFFSET != PT_SYSCALL_RET_OFFSET)
-                               PT_SYSCALL_NR(regs->skas.regs) = -1;
+                       if (PT_SYSCALL_NR_OFFSET != PT_SYSCALL_RET_OFFSET)
+                               PT_SYSCALL_NR(regs->gp) = -1;
                }
        }
 }
 
 static unsigned long thread_regs[MAX_REG_NR];
-static unsigned long thread_fp_regs[HOST_FP_SIZE];
 
 static int __init init_thread_regs(void)
 {
-       get_safe_registers(thread_regs, thread_fp_regs);
+       get_safe_registers(thread_regs);
        /* Set parent's instruction pointer to start of clone-stub */
-       thread_regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE +
+       thread_regs[REGS_IP_INDEX] = STUB_CODE +
                                (unsigned long) stub_clone_handler -
                                (unsigned long) &__syscall_stub_start;
-       thread_regs[REGS_SP_INDEX] = UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE -
+       thread_regs[REGS_SP_INDEX] = STUB_DATA + UM_KERN_PAGE_SIZE -
                sizeof(void *);
 #ifdef __SIGNAL_FRAMESIZE
        thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE;
@@ -378,53 +398,53 @@ __initcall(init_thread_regs);
 
 int copy_context_skas0(unsigned long new_stack, int pid)
 {
+       struct timeval tv = { .tv_sec = 0, .tv_usec = UM_USEC_PER_SEC / UM_HZ };
        int err;
        unsigned long current_stack = current_stub_stack();
        struct stub_data *data = (struct stub_data *) current_stack;
        struct stub_data *child_data = (struct stub_data *) new_stack;
-       __u64 new_offset;
+       unsigned long long new_offset;
        int new_fd = phys_mapping(to_phys((void *)new_stack), &new_offset);
 
-       /* prepare offset and fd of child's stack as argument for parent's
+       /*
+        * prepare offset and fd of child's stack as argument for parent's
         * and child's mmap2 calls
         */
        *data = ((struct stub_data) { .offset   = MMAP_OFFSET(new_offset),
                                      .fd       = new_fd,
                                      .timer    = ((struct itimerval)
-                                                   { { 0, 1000000 / hz() },
-                                                     { 0, 1000000 / hz() }})});
+                                                  { .it_value = tv,
+                                                    .it_interval = tv }) });
+
        err = ptrace_setregs(pid, thread_regs);
-       if(err < 0)
+       if (err < 0)
                panic("copy_context_skas0 : PTRACE_SETREGS failed, "
                      "pid = %d, errno = %d\n", pid, -err);
 
-       err = ptrace_setfpregs(pid, thread_fp_regs);
-       if(err < 0)
-               panic("copy_context_skas0 : PTRACE_SETFPREGS failed, "
-                     "pid = %d, errno = %d\n", pid, -err);
-
        /* set a well known return code for detection of child write failure */
        child_data->err = 12345678;
 
-       /* Wait, until parent has finished its work: read child's pid from
+       /*
+        * Wait, until parent has finished its work: read child's pid from
         * parent's stack, and check, if bad result.
         */
        err = ptrace(PTRACE_CONT, pid, 0, 0);
-       if(err)
+       if (err)
                panic("Failed to continue new process, pid = %d, "
                      "errno = %d\n", pid, errno);
        wait_stub_done(pid);
 
        pid = data->err;
-       if(pid < 0)
+       if (pid < 0)
                panic("copy_context_skas0 - stub-parent reports error %d\n",
                      -pid);
 
-       /* Wait, until child has finished too: read child's result from
+       /*
+        * Wait, until child has finished too: read child's result from
         * child's stack and check it.
         */
        wait_stub_done(pid);
-       if (child_data->err != UML_CONFIG_STUB_DATA)
+       if (child_data->err != STUB_DATA)
                panic("copy_context_skas0 - stub-child reports error %ld\n",
                      child_data->err);
 
@@ -446,7 +466,7 @@ void map_stub_pages(int fd, unsigned long code,
 {
        struct proc_mm_op mmop;
        int n;
-       __u64 code_offset;
+       unsigned long long code_offset;
        int code_fd = phys_mapping(to_phys((void *) &__syscall_stub_start),
                                   &code_offset);
 
@@ -461,16 +481,17 @@ void map_stub_pages(int fd, unsigned long code,
                                          .offset  = code_offset
        } } });
        CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
-       if(n != sizeof(mmop)){
+       if (n != sizeof(mmop)) {
                n = errno;
-               printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n",
-                      code, code_fd, (unsigned long long) code_offset);
+               printk(UM_KERN_ERR "mmap args - addr = 0x%lx, fd = %d, "
+                      "offset = %llx\n", code, code_fd,
+                      (unsigned long long) code_offset);
                panic("map_stub_pages : /proc/mm map for code failed, "
                      "err = %d\n", n);
        }
 
-       if ( stack ) {
-               __u64 map_offset;
+       if (stack) {
+               unsigned long long map_offset;
                int map_fd = phys_mapping(to_phys((void *)stack), &map_offset);
                mmop = ((struct proc_mm_op)
                                { .op        = MM_MMAP,
@@ -484,7 +505,7 @@ void map_stub_pages(int fd, unsigned long code,
                                      .offset  = map_offset
                } } });
                CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
-               if(n != sizeof(mmop))
+               if (n != sizeof(mmop))
                        panic("map_stub_pages : /proc/mm map for data failed, "
                              "err = %d\n", errno);
        }
@@ -504,7 +525,7 @@ void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
 
 void switch_threads(jmp_buf *me, jmp_buf *you)
 {
-       if(UML_SETJMP(me) == 0)
+       if (UML_SETJMP(me) == 0)
                UML_LONGJMP(you, 1);
 }
 
@@ -520,8 +541,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
        int n;
 
        set_handler(SIGWINCH, (__sighandler_t) sig_handler,
-                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM,
-                   SIGVTALRM, -1);
+                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGVTALRM, -1);
 
        /*
         * Can't use UML_SETJMP or UML_LONGJMP here because they save
@@ -532,7 +552,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
         * after returning to the jumper.
         */
        n = setjmp(initial_jmpbuf);
-       switch(n){
+       switch(n) {
        case INIT_JMP_NEW_THREAD:
                (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler;
                (*switch_buf)[0].JB_SP = (unsigned long) stack +
@@ -544,10 +564,10 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
                break;
        case INIT_JMP_HALT:
                kmalloc_ok = 0;
-               return(0);
+               return 0;
        case INIT_JMP_REBOOT:
                kmalloc_ok = 0;
-               return(1);
+               return 1;
        default:
                panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
        }
@@ -563,7 +583,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
        cb_back = &here;
 
        block_signals();
-       if(UML_SETJMP(&here) == 0)
+       if (UML_SETJMP(&here) == 0)
                UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK);
        unblock_signals();
 
@@ -584,16 +604,16 @@ void reboot_skas(void)
        UML_LONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
 }
 
-void switch_mm_skas(struct mm_id *mm_idp)
+void __switch_mm(struct mm_id *mm_idp)
 {
        int err;
 
-       /* FIXME: need cpu pid in switch_mm_skas */
-       if(proc_mm){
+       /* FIXME: need cpu pid in __switch_mm */
+       if (proc_mm) {
                err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0,
                             mm_idp->u.mm_fd);
-               if(err)
-                       panic("switch_mm_skas - PTRACE_SWITCH_MM failed, "
+               if (err)
+                       panic("__switch_mm - PTRACE_SWITCH_MM failed, "
                              "errno = %d\n", errno);
        }
        else userspace_pid[0] = mm_idp->u.pid;
index 3b600c2..3b1b924 100644 (file)
@@ -1,37 +1,43 @@
 /*
- * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <signal.h>
-#include <errno.h>
+#if 0
 #include "kern_util.h"
-#include "as-layout.h"
-#include "task.h"
-#include "sigcontext.h"
 #include "skas.h"
 #include "ptrace_user.h"
-#include "sysdep/ptrace.h"
 #include "sysdep/ptrace_user.h"
+#endif
+
+#include <errno.h>
+#include <signal.h>
+#include "sysdep/ptrace.h"
+#include "kern_constants.h"
+#include "as-layout.h"
 #include "os.h"
+#include "sigcontext.h"
+#include "task.h"
 
-static union uml_pt_regs ksig_regs[UM_NR_CPUS];
+static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
 
 void sig_handler_common_skas(int sig, void *sc_ptr)
 {
        struct sigcontext *sc = sc_ptr;
-       union uml_pt_regs *r;
-       void (*handler)(int, union uml_pt_regs *);
+       struct uml_pt_regs *r;
+       void (*handler)(int, struct uml_pt_regs *);
        int save_user, save_errno = errno;
 
-       /* This is done because to allow SIGSEGV to be delivered inside a SEGV
+       /*
+        * This is done because to allow SIGSEGV to be delivered inside a SEGV
         * handler.  This can happen in copy_user, and if SEGV is disabled,
         * the process will die.
         * XXX Figure out why this is better than SA_NODEFER
         */
-       if(sig == SIGSEGV) {
+       if (sig == SIGSEGV) {
                change_sig(SIGSEGV, 1);
-               /* For segfaults, we want the data from the
+               /*
+                * For segfaults, we want the data from the
                 * sigcontext.  In this case, we don't want to mangle
                 * the process registers, so use a static set of
                 * registers.  For other signals, the process
@@ -42,25 +48,22 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
        }
        else r = TASK_REGS(get_current());
 
-       save_user = r->skas.is_user;
-       r->skas.is_user = 0;
-       if ( sig == SIGFPE || sig == SIGSEGV ||
-            sig == SIGBUS || sig == SIGILL ||
-            sig == SIGTRAP ) {
-               GET_FAULTINFO_FROM_SC(r->skas.faultinfo, sc);
-       }
+       save_user = r->is_user;
+       r->is_user = 0;
+       if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
+           (sig == SIGILL) || (sig == SIGTRAP))
+               GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
 
        change_sig(SIGUSR1, 1);
 
        handler = sig_info[sig];
 
-       /* unblock SIGALRM, SIGVTALRM, SIGIO if sig isn't IRQ signal */
-       if (sig != SIGIO && sig != SIGWINCH &&
-           sig != SIGVTALRM && sig != SIGALRM)
+       /* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
+       if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
                unblock_signals();
 
        handler(sig, r);
 
        errno = save_errno;
-       r->skas.is_user = save_user;
+       r->is_user = save_user;
 }
index 46f6139..7b81f6c 100644 (file)
@@ -1,75 +1,65 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <pty.h>
 #include <stdio.h>
-#include <stddef.h>
-#include <stdarg.h>
 #include <stdlib.h>
-#include <string.h>
+#include <stdarg.h>
 #include <unistd.h>
-#include <signal.h>
-#include <sched.h>
-#include <fcntl.h>
 #include <errno.h>
-#include <sys/time.h>
-#include <sys/wait.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+#include <string.h>
 #include <sys/mman.h>
-#include <sys/resource.h>
+#include <sys/ptrace.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
 #include <asm/unistd.h>
-#include <asm/page.h>
-#include <sys/types.h>
-#include "kern_util.h"
-#include "user.h"
-#include "signal_kern.h"
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-#include "irq_user.h"
-#include "ptrace_user.h"
-#include "mem_user.h"
 #include "init.h"
-#include "os.h"
-#include "uml-config.h"
-#include "choose-mode.h"
-#include "mode.h"
-#include "tempfile.h"
 #include "kern_constants.h"
-
-#ifdef UML_CONFIG_MODE_SKAS
-#include "skas.h"
-#include "skas_ptrace.h"
+#include "os.h"
+#include "mem_user.h"
+#include "ptrace_user.h"
 #include "registers.h"
-#endif
+#include "skas_ptrace.h"
 
-static int ptrace_child(void *arg)
+static int ptrace_child(void)
 {
        int ret;
+       /* Calling os_getpid because some libcs cached getpid incorrectly */
        int pid = os_getpid(), ppid = getppid();
        int sc_result;
 
        change_sig(SIGWINCH, 0);
-       if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
+       if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) {
                perror("ptrace");
-               os_kill_process(pid, 0);
+               kill(pid, SIGKILL);
        }
        kill(pid, SIGSTOP);
 
-       /*This syscall will be intercepted by the parent. Don't call more than
-        * once, please.*/
+       /*
+        * This syscall will be intercepted by the parent. Don't call more than
+        * once, please.
+        */
        sc_result = os_getpid();
 
        if (sc_result == pid)
-               ret = 1; /*Nothing modified by the parent, we are running
-                          normally.*/
+               /* Nothing modified by the parent, we are running normally. */
+               ret = 1;
        else if (sc_result == ppid)
-               ret = 0; /*Expected in check_ptrace and check_sysemu when they
-                          succeed in modifying the stack frame*/
+               /*
+                * Expected in check_ptrace and check_sysemu when they succeed
+                * in modifying the stack frame
+                */
+               ret = 0;
        else
-               ret = 2; /*Serious trouble! This could be caused by a bug in
-                          host 2.6 SKAS3/2.6 patch before release -V6, together
-                          with a bug in the UML code itself.*/
+               /* Serious trouble! This could be caused by a bug in host 2.6
+                * SKAS3/2.6 patch before release -V6, together with a bug in
+                * the UML code itself.
+                */
+               ret = 2;
        _exit(ret);
 }
 
@@ -101,29 +91,23 @@ static void non_fatal(char *fmt, ...)
        fflush(stdout);
 }
 
-static int start_ptraced_child(void **stack_out)
+static int start_ptraced_child(void)
 {
-       void *stack;
-       unsigned long sp;
        int pid, n, status;
 
-       stack = mmap(NULL, UM_KERN_PAGE_SIZE,
-                    PROT_READ | PROT_WRITE | PROT_EXEC,
-                    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-       if(stack == MAP_FAILED)
-               fatal_perror("check_ptrace : mmap failed");
-       sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
-       pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
-       if(pid < 0)
-               fatal_perror("start_ptraced_child : clone failed");
+       pid = fork();
+       if (pid == 0)
+               ptrace_child();
+       else if (pid < 0)
+               fatal_perror("start_ptraced_child : fork failed");
+
        CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-       if(n < 0)
-               fatal_perror("check_ptrace : clone failed");
-       if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
+       if (n < 0)
+               fatal_perror("check_ptrace : waitpid failed");
+       if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
                fatal("check_ptrace : expected SIGSTOP, got status = %d",
                      status);
 
-       *stack_out = stack;
        return pid;
 }
 
@@ -133,15 +117,14 @@ static int start_ptraced_child(void **stack_out)
  * So only for SYSEMU features we test mustpanic, while normal host features
  * must work anyway!
  */
-static int stop_ptraced_child(int pid, void *stack, int exitcode,
-                             int mustexit)
+static int stop_ptraced_child(int pid, int exitcode, int mustexit)
 {
        int status, n, ret = 0;
 
-       if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
+       if (ptrace(PTRACE_CONT, pid, 0, 0) < 0)
                fatal_perror("stop_ptraced_child : ptrace failed");
        CATCH_EINTR(n = waitpid(pid, &status, 0));
-       if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
+       if (!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode)) {
                int exit_with = WEXITSTATUS(status);
                if (exit_with == 2)
                        non_fatal("check_ptrace : child exited with status 2. "
@@ -154,8 +137,6 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode,
                ret = -1;
        }
 
-       if(munmap(stack, UM_KERN_PAGE_SIZE) < 0)
-               fatal_perror("check_ptrace : munmap failed");
        return ret;
 }
 
@@ -207,40 +188,39 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
 
 static void __init check_sysemu(void)
 {
-       void *stack;
        unsigned long regs[MAX_REG_NR];
        int pid, n, status, count=0;
 
        non_fatal("Checking syscall emulation patch for ptrace...");
        sysemu_supported = 0;
-       pid = start_ptraced_child(&stack);
+       pid = start_ptraced_child();
 
-       if(ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0)
+       if (ptrace(PTRACE_SYSEMU, pid, 0, 0) < 0)
                goto fail;
 
        CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
        if (n < 0)
                fatal_perror("check_sysemu : wait failed");
-       if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
+       if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
                fatal("check_sysemu : expected SIGTRAP, got status = %d",
                      status);
 
-       if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
+       if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
                fatal_perror("check_sysemu : PTRACE_GETREGS failed");
-       if(PT_SYSCALL_NR(regs) != __NR_getpid){
+       if (PT_SYSCALL_NR(regs) != __NR_getpid) {
                non_fatal("check_sysemu got system call number %d, "
                          "expected %d...", PT_SYSCALL_NR(regs), __NR_getpid);
                goto fail;
        }
 
        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid());
-       if(n < 0){
+       if (n < 0) {
                non_fatal("check_sysemu : failed to modify system call "
                          "return");
                goto fail;
        }
 
-       if (stop_ptraced_child(pid, stack, 0, 0) < 0)
+       if (stop_ptraced_child(pid, 0, 0) < 0)
                goto fail_stopped;
 
        sysemu_supported = 1;
@@ -248,90 +228,90 @@ static void __init check_sysemu(void)
        set_using_sysemu(!force_sysemu_disabled);
 
        non_fatal("Checking advanced syscall emulation patch for ptrace...");
-       pid = start_ptraced_child(&stack);
+       pid = start_ptraced_child();
 
-       if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
+       if ((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
                   (void *) PTRACE_O_TRACESYSGOOD) < 0))
                fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed");
 
-       while(1){
+       while (1) {
                count++;
-               if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
+               if (ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
                        goto fail;
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-               if(n < 0)
+               if (n < 0)
                        fatal_perror("check_ptrace : wait failed");
 
-               if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){
+               if (WIFSTOPPED(status) &&
+                   (WSTOPSIG(status) == (SIGTRAP|0x80))) {
                        if (!count)
                                fatal("check_ptrace : SYSEMU_SINGLESTEP "
                                      "doesn't singlestep");
                        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
                                   os_getpid());
-                       if(n < 0)
+                       if (n < 0)
                                fatal_perror("check_sysemu : failed to modify "
                                             "system call return");
                        break;
                }
-               else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
+               else if (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
                        count++;
                else
                        fatal("check_ptrace : expected SIGTRAP or "
                              "(SIGTRAP | 0x80), got status = %d", status);
        }
-       if (stop_ptraced_child(pid, stack, 0, 0) < 0)
+       if (stop_ptraced_child(pid, 0, 0) < 0)
                goto fail_stopped;
 
        sysemu_supported = 2;
        non_fatal("OK\n");
 
-       if ( !force_sysemu_disabled )
+       if (!force_sysemu_disabled)
                set_using_sysemu(sysemu_supported);
        return;
 
 fail:
-       stop_ptraced_child(pid, stack, 1, 0);
+       stop_ptraced_child(pid, 1, 0);
 fail_stopped:
        non_fatal("missing\n");
 }
 
 static void __init check_ptrace(void)
 {
-       void *stack;
        int pid, syscall, n, status;
 
        non_fatal("Checking that ptrace can change system call numbers...");
-       pid = start_ptraced_child(&stack);
+       pid = start_ptraced_child();
 
-       if((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
+       if ((ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
                   (void *) PTRACE_O_TRACESYSGOOD) < 0))
                fatal_perror("check_ptrace: PTRACE_OLDSETOPTIONS failed");
 
-       while(1){
-               if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
+       while (1) {
+               if (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
                        fatal_perror("check_ptrace : ptrace failed");
 
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-               if(n < 0)
+               if (n < 0)
                        fatal_perror("check_ptrace : wait failed");
 
-               if(!WIFSTOPPED(status) ||
+               if (!WIFSTOPPED(status) ||
                   (WSTOPSIG(status) != (SIGTRAP | 0x80)))
                        fatal("check_ptrace : expected (SIGTRAP|0x80), "
                               "got status = %d", status);
 
                syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
                                 0);
-               if(syscall == __NR_getpid){
+               if (syscall == __NR_getpid) {
                        n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
                                   __NR_getppid);
-                       if(n < 0)
+                       if (n < 0)
                                fatal_perror("check_ptrace : failed to modify "
                                             "system call");
                        break;
                }
        }
-       stop_ptraced_child(pid, stack, 0, 1);
+       stop_ptraced_child(pid, 0, 1);
        non_fatal("OK\n");
        check_sysemu();
 }
@@ -343,18 +323,18 @@ static void __init check_coredump_limit(void)
        struct rlimit lim;
        int err = getrlimit(RLIMIT_CORE, &lim);
 
-       if(err){
+       if (err) {
                perror("Getting core dump limit");
                return;
        }
 
        printf("Core dump limits :\n\tsoft - ");
-       if(lim.rlim_cur == RLIM_INFINITY)
+       if (lim.rlim_cur == RLIM_INFINITY)
                printf("NONE\n");
        else printf("%lu\n", lim.rlim_cur);
 
        printf("\thard - ");
-       if(lim.rlim_max == RLIM_INFINITY)
+       if (lim.rlim_max == RLIM_INFINITY)
                printf("NONE\n");
        else printf("%lu\n", lim.rlim_max);
 }
@@ -408,20 +388,18 @@ __uml_setup("noptraceldt", noptraceldt_cmd_param,
 "    To support PTRACE_LDT, the host needs to be patched using\n"
 "    the current skas3 patch.\n\n");
 
-#ifdef UML_CONFIG_MODE_SKAS
 static inline void check_skas3_ptrace_faultinfo(void)
 {
        struct ptrace_faultinfo fi;
-       void *stack;
        int pid, n;
 
        non_fatal("  - PTRACE_FAULTINFO...");
-       pid = start_ptraced_child(&stack);
+       pid = start_ptraced_child();
 
        n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
        if (n < 0) {
                ptrace_faultinfo = 0;
-               if(errno == EIO)
+               if (errno == EIO)
                        non_fatal("not found\n");
                else
                        perror("not found");
@@ -434,13 +412,12 @@ static inline void check_skas3_ptrace_faultinfo(void)
        }
 
        init_registers(pid);
-       stop_ptraced_child(pid, stack, 1, 1);
+       stop_ptraced_child(pid, 1, 1);
 }
 
 static inline void check_skas3_ptrace_ldt(void)
 {
 #ifdef PTRACE_LDT
-       void *stack;
        int pid, n;
        unsigned char ldtbuf[40];
        struct ptrace_ldt ldt_op = (struct ptrace_ldt) {
@@ -449,11 +426,11 @@ static inline void check_skas3_ptrace_ldt(void)
                .bytecount = sizeof(ldtbuf)};
 
        non_fatal("  - PTRACE_LDT...");
-       pid = start_ptraced_child(&stack);
+       pid = start_ptraced_child();
 
        n = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op);
        if (n < 0) {
-               if(errno == EIO)
+               if (errno == EIO)
                        non_fatal("not found\n");
                else {
                        perror("not found");
@@ -461,13 +438,13 @@ static inline void check_skas3_ptrace_ldt(void)
                ptrace_ldt = 0;
        }
        else {
-               if(ptrace_ldt)
+               if (ptrace_ldt)
                        non_fatal("found\n");
                else
                        non_fatal("found, but use is disabled\n");
        }
 
-       stop_ptraced_child(pid, stack, 1, 1);
+       stop_ptraced_child(pid, 1, 1);
 #else
        /* PTRACE_LDT might be disabled via cmdline option.
         * We want to override this, else we might use the stub
@@ -484,12 +461,9 @@ static inline void check_skas3_proc_mm(void)
                proc_mm = 0;
                perror("not found");
        }
-       else {
-               if (!proc_mm)
-                       non_fatal("found but disabled on command line\n");
-               else
-                       non_fatal("found\n");
-       }
+       else if (!proc_mm)
+               non_fatal("found but disabled on command line\n");
+       else non_fatal("found\n");
 }
 
 int can_do_skas(void)
@@ -500,17 +474,11 @@ int can_do_skas(void)
        check_skas3_ptrace_faultinfo();
        check_skas3_ptrace_ldt();
 
-       if(!proc_mm || !ptrace_faultinfo || !ptrace_ldt)
+       if (!proc_mm || !ptrace_faultinfo || !ptrace_ldt)
                skas_needs_stub = 1;
 
        return 1;
 }
-#else
-int can_do_skas(void)
-{
-       return 0;
-}
-#endif
 
 int __init parse_iomem(char *str, int *add)
 {
@@ -521,25 +489,25 @@ int __init parse_iomem(char *str, int *add)
 
        driver = str;
        file = strchr(str,',');
-       if(file == NULL){
+       if (file == NULL) {
                printf("parse_iomem : failed to parse iomem\n");
                goto out;
        }
        *file = '\0';
        file++;
        fd = open(file, O_RDWR, 0);
-       if(fd < 0){
-               os_print_error(fd, "parse_iomem - Couldn't open io file");
+       if (fd < 0) {
+               perror("parse_iomem - Couldn't open io file");
                goto out;
        }
 
-       if(fstat64(fd, &buf) < 0){
+       if (fstat64(fd, &buf) < 0) {
                perror("parse_iomem - cannot stat_fd file");
                goto out_close;
        }
 
        new = malloc(sizeof(*new));
-       if(new == NULL){
+       if (new == NULL) {
                perror("Couldn't allocate iomem_region struct");
                goto out_close;
        }
index 3780662..a841262 100644 (file)
@@ -1,9 +1,9 @@
 #
-# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 # Licensed under the GPL
 #
 
-obj-$(CONFIG_MODE_SKAS) = registers.o signal.o tls.o
+obj-y = registers.o signal.o tls.o
 
 USER_OBJS := $(obj-y)
 
index 84b44f9..d1997ca 100644 (file)
 /*
  * Copyright (C) 2004 PathScale, Inc
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <errno.h>
-#include <string.h>
-#include "sysdep/ptrace_user.h"
-#include "sysdep/ptrace.h"
-#include "uml-config.h"
-#include "skas_ptregs.h"
-#include "registers.h"
+#include "kern_constants.h"
 #include "longjmp.h"
 #include "user.h"
+#include "sysdep/ptrace_user.h"
 
-/* These are set once at boot time and not changed thereafter */
-
-static unsigned long exec_regs[MAX_REG_NR];
-static unsigned long exec_fp_regs[HOST_FP_SIZE];
-static unsigned long exec_fpx_regs[HOST_XFP_SIZE];
-static int have_fpx_regs = 1;
-
-void init_thread_registers(union uml_pt_regs *to)
-{
-       memcpy(to->skas.regs, exec_regs, sizeof(to->skas.regs));
-       memcpy(to->skas.fp, exec_fp_regs, sizeof(to->skas.fp));
-       if(have_fpx_regs)
-               memcpy(to->skas.xfp, exec_fpx_regs, sizeof(to->skas.xfp));
-}
-
-/* XXX These need to use [GS]ETFPXREGS and copy_sc_{to,from}_user_skas needs
- * to pass in a sufficiently large buffer
- */
 int save_fp_registers(int pid, unsigned long *fp_regs)
 {
-       if(ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
+       if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
                return -errno;
        return 0;
 }
 
 int restore_fp_registers(int pid, unsigned long *fp_regs)
 {
-       if(ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
+       if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
                return -errno;
        return 0;
 }
 
-static int move_registers(int pid, int int_op, union uml_pt_regs *regs,
-                         int fp_op, unsigned long *fp_regs)
+int save_fpx_registers(int pid, unsigned long *fp_regs)
 {
-       if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
-               return -errno;
-
-       if(ptrace(fp_op, pid, 0, fp_regs) < 0)
+       if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0)
                return -errno;
-
        return 0;
 }
 
-void save_registers(int pid, union uml_pt_regs *regs)
+int restore_fpx_registers(int pid, unsigned long *fp_regs)
 {
-       unsigned long *fp_regs;
-       int err, fp_op;
-
-       if(have_fpx_regs){
-               fp_op = PTRACE_GETFPXREGS;
-               fp_regs = regs->skas.xfp;
-       }
-       else {
-               fp_op = PTRACE_GETFPREGS;
-               fp_regs = regs->skas.fp;
-       }
-
-       err = move_registers(pid, PTRACE_GETREGS, regs, fp_op, fp_regs);
-       if(err)
-               panic("save_registers - saving registers failed, errno = %d\n",
-                     -err);
+       if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0)
+               return -errno;
+       return 0;
 }
 
-void restore_registers(int pid, union uml_pt_regs *regs)
+unsigned long get_thread_reg(int reg, jmp_buf *buf)
 {
-       unsigned long *fp_regs;
-       int err, fp_op;
-
-       if(have_fpx_regs){
-               fp_op = PTRACE_SETFPXREGS;
-               fp_regs = regs->skas.xfp;
-       }
-       else {
-               fp_op = PTRACE_SETFPREGS;
-               fp_regs = regs->skas.fp;
+       switch (reg) {
+       case EIP:
+               return buf[0]->__eip;
+       case UESP:
+               return buf[0]->__esp;
+       case EBP:
+               return buf[0]->__ebp;
+       default:
+               printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n",
+                      reg);
+               return 0;
        }
-
-       err = move_registers(pid, PTRACE_SETREGS, regs, fp_op, fp_regs);
-       if(err)
-               panic("restore_registers - saving registers failed, "
-                     "errno = %d\n", -err);
 }
 
-void init_registers(int pid)
+int have_fpx_regs = 1;
+
+void arch_init_registers(int pid)
 {
+       unsigned long fpx_regs[HOST_XFP_SIZE];
        int err;
 
-       memset(exec_regs, 0, sizeof(exec_regs));
-       err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
-       if(err)
-               panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
-                     errno);
-
-       errno = 0;
-       err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs);
+       err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs);
        if(!err)
                return;
+
        if(errno != EIO)
                panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
                      errno);
 
        have_fpx_regs = 0;
-
-       err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
-       if(err)
-               panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
-                     errno);
-}
-
-void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
-{
-       memcpy(regs, exec_regs, sizeof(exec_regs));
-       if(fp_regs != NULL)
-               memcpy(fp_regs, exec_fp_regs,
-                      HOST_FP_SIZE * sizeof(unsigned long));
-}
-
-unsigned long get_thread_reg(int reg, jmp_buf *buf)
-{
-       switch(reg){
-       case EIP: return buf[0]->__eip;
-       case UESP: return buf[0]->__esp;
-       case EBP: return buf[0]->__ebp;
-       default:
-               printk("get_thread_regs - unknown register %d\n", reg);
-               return 0;
-       }
 }
index 7955e06..a42a4ef 100644 (file)
@@ -1,9 +1,9 @@
 #
-# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+# Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 # Licensed under the GPL
 #
 
-obj-$(CONFIG_MODE_SKAS) = registers.o prctl.o signal.o
+obj-y = registers.o prctl.o signal.o
 
 USER_OBJS := $(obj-y)
 
index 9467315..9bfa789 100644 (file)
@@ -1,23 +1,15 @@
 /*
- * Copyright (C) 2004 PathScale, Inc
+ * Copyright (C) 2006-2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
 #include <errno.h>
 #include <sys/ptrace.h>
-#include <string.h>
-#include "ptrace_user.h"
-#include "uml-config.h"
-#include "skas_ptregs.h"
-#include "registers.h"
+#define __FRAME_OFFSETS
+#include <asm/ptrace.h>
 #include "longjmp.h"
 #include "user.h"
 
-/* These are set once at boot time and not changed thereafter */
-
-static unsigned long exec_regs[MAX_REG_NR];
-static unsigned long exec_fp_regs[HOST_FP_SIZE];
-
 int save_fp_registers(int pid, unsigned long *fp_regs)
 {
        if(ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
@@ -32,67 +24,6 @@ int restore_fp_registers(int pid, unsigned long *fp_regs)
        return 0;
 }
 
-void init_thread_registers(union uml_pt_regs *to)
-{
-       memcpy(to->skas.regs, exec_regs, sizeof(to->skas.regs));
-       memcpy(to->skas.fp, exec_fp_regs, sizeof(to->skas.fp));
-}
-
-static int move_registers(int pid, int int_op, int fp_op,
-                         union uml_pt_regs *regs)
-{
-       if(ptrace(int_op, pid, 0, regs->skas.regs) < 0)
-               return -errno;
-
-       if(ptrace(fp_op, pid, 0, regs->skas.fp) < 0)
-               return -errno;
-
-       return 0;
-}
-
-void save_registers(int pid, union uml_pt_regs *regs)
-{
-       int err;
-
-       err = move_registers(pid, PTRACE_GETREGS, PTRACE_GETFPREGS, regs);
-       if(err)
-               panic("save_registers - saving registers failed, errno = %d\n",
-                     -err);
-}
-
-void restore_registers(int pid, union uml_pt_regs *regs)
-{
-       int err;
-
-       err = move_registers(pid, PTRACE_SETREGS, PTRACE_SETFPREGS, regs);
-       if(err)
-               panic("restore_registers - saving registers failed, "
-                     "errno = %d\n", -err);
-}
-
-void init_registers(int pid)
-{
-       int err;
-
-       err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
-       if(err)
-               panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
-                     errno);
-
-       err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
-       if(err)
-               panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
-                     errno);
-}
-
-void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
-{
-       memcpy(regs, exec_regs, sizeof(exec_regs));
-       if(fp_regs != NULL)
-               memcpy(fp_regs, exec_fp_regs,
-                      HOST_FP_SIZE * sizeof(unsigned long));
-}
-
 unsigned long get_thread_reg(int reg, jmp_buf *buf)
 {
        switch(reg){
index 5de169b..e34e1ef 100644 (file)
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <stddef.h>
+#include <errno.h>
+#include <signal.h>
 #include <time.h>
 #include <sys/time.h>
-#include <signal.h>
-#include <errno.h>
-#include "kern_util.h"
-#include "user.h"
-#include "process.h"
 #include "kern_constants.h"
 #include "os.h"
-#include "uml-config.h"
+#include "user.h"
 
-int set_interval(int is_virtual)
+int set_interval(void)
 {
-       int usec = 1000000/hz();
-       int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL;
+       int usec = UM_USEC_PER_SEC / UM_HZ;
        struct itimerval interval = ((struct itimerval) { { 0, usec },
                                                          { 0, usec } });
 
-       if(setitimer(timer_type, &interval, NULL) == -1)
+       if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1)
                return -errno;
 
        return 0;
 }
 
-#ifdef UML_CONFIG_MODE_TT
-void enable_timer(void)
+int timer_one_shot(int ticks)
 {
-       set_interval(1);
-}
-#endif
+       unsigned long usec = ticks * UM_USEC_PER_SEC / UM_HZ;
+       unsigned long sec = usec / UM_USEC_PER_SEC;
+       struct itimerval interval;
 
-void disable_timer(void)
-{
-       struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
-       if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
-          (setitimer(ITIMER_REAL, &disable, NULL) < 0))
-               printk("disnable_timer - setitimer failed, errno = %d\n",
-                      errno);
-       /* If there are signals already queued, after unblocking ignore them */
-       signal(SIGALRM, SIG_IGN);
-       signal(SIGVTALRM, SIG_IGN);
+       usec %= UM_USEC_PER_SEC;
+       interval = ((struct itimerval) { { 0, 0 }, { sec, usec } });
+
+       if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1)
+               return -errno;
+
+       return 0;
 }
 
-void switch_timers(int to_real)
+/**
+ * timeval_to_ns - Convert timeval to nanoseconds
+ * @ts:                pointer to the timeval variable to be converted
+ *
+ * Returns the scalar nanosecond representation of the timeval
+ * parameter.
+ *
+ * Ripped from linux/time.h because it's a kernel header, and thus
+ * unusable from here.
+ */
+static inline long long timeval_to_ns(const struct timeval *tv)
 {
-       struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
-       struct itimerval enable = ((struct itimerval) { { 0, 1000000/hz() },
-                                                       { 0, 1000000/hz() }});
-       int old, new;
-
-       if(to_real){
-               old = ITIMER_VIRTUAL;
-               new = ITIMER_REAL;
-       }
-       else {
-               old = ITIMER_REAL;
-               new = ITIMER_VIRTUAL;
-       }
-
-       if((setitimer(old, &disable, NULL) < 0) ||
-          (setitimer(new, &enable, NULL)))
-               printk("switch_timers - setitimer failed, errno = %d\n",
-                      errno);
+       return ((long long) tv->tv_sec * UM_NSEC_PER_SEC) +
+               tv->tv_usec * UM_NSEC_PER_USEC;
 }
 
-#ifdef UML_CONFIG_MODE_TT
-void uml_idle_timer(void)
+long long disable_timer(void)
 {
-       if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
-               panic("Couldn't unset SIGVTALRM handler");
+       struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
+
+       if(setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
+               printk(UM_KERN_ERR "disable_timer - setitimer failed, "
+                      "errno = %d\n", errno);
 
-       set_handler(SIGALRM, (__sighandler_t) alarm_handler,
-                   SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
-       set_interval(0);
+       return timeval_to_ns(&time.it_value);
 }
-#endif
 
-unsigned long long os_nsecs(void)
+long long os_nsecs(void)
 {
        struct timeval tv;
 
        gettimeofday(&tv, NULL);
-       return((unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000);
+       return timeval_to_ns(&tv);
 }
 
-void idle_sleep(int secs)
+extern void alarm_handler(int sig, struct sigcontext *sc);
+
+void idle_sleep(unsigned long long nsecs)
 {
-       struct timespec ts;
+       struct timespec ts = { .tv_sec  = nsecs / UM_NSEC_PER_SEC,
+                              .tv_nsec = nsecs % UM_NSEC_PER_SEC };
 
-       ts.tv_sec = secs;
-       ts.tv_nsec = 0;
-       nanosleep(&ts, NULL);
+       if (nanosleep(&ts, &ts) == 0)
+               alarm_handler(SIGVTALRM, NULL);
 }
index 16215b9..7327780 100644 (file)
@@ -1,18 +1,9 @@
 #include <errno.h>
-#include <unistd.h>
 #include <sys/ptrace.h>
-#include <sys/syscall.h>
-#include <asm/ldt.h>
 #include "sysdep/tls.h"
-#include "uml-config.h"
 
 /* TLS support - we basically rely on the host's one.*/
 
-/* In TT mode, this should be called only by the tracing thread, and makes sense
- * only for PTRACE_SET_THREAD_AREA. In SKAS mode, it's used normally.
- *
- */
-
 #ifndef PTRACE_GET_THREAD_AREA
 #define PTRACE_GET_THREAD_AREA 25
 #endif
@@ -32,8 +23,6 @@ int os_set_thread_area(user_desc_t *info, int pid)
        return ret;
 }
 
-#ifdef UML_CONFIG_MODE_SKAS
-
 int os_get_thread_area(user_desc_t *info, int pid)
 {
        int ret;
@@ -44,32 +33,3 @@ int os_get_thread_area(user_desc_t *info, int pid)
                ret = -errno;
        return ret;
 }
-
-#endif
-
-#ifdef UML_CONFIG_MODE_TT
-#include "linux/unistd.h"
-
-int do_set_thread_area_tt(user_desc_t *info)
-{
-       int ret;
-
-       ret = syscall(__NR_set_thread_area,info);
-       if (ret < 0) {
-               ret = -errno;
-       }
-       return ret;
-}
-
-int do_get_thread_area_tt(user_desc_t *info)
-{
-       int ret;
-
-       ret = syscall(__NR_get_thread_area,info);
-       if (ret < 0) {
-               ret = -errno;
-       }
-       return ret;
-}
-
-#endif /* UML_CONFIG_MODE_TT */
index 295da65..2a1c984 100644 (file)
@@ -1,22 +1,14 @@
 /*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdlib.h>
 #include <signal.h>
-#include "kern_util.h"
 #include "os.h"
-#include "mode.h"
-#include "longjmp.h"
-
-void usr2_handler(int sig, union uml_pt_regs *regs)
-{
-       CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
-}
+#include "sysdep/ptrace.h"
 
 /* Initialized from linux_main() */
-void (*sig_info[NSIG])(int, union uml_pt_regs *);
+void (*sig_info[NSIG])(int, struct uml_pt_regs *);
 
 void os_fill_handlinfo(struct kern_handlers h)
 {
@@ -28,13 +20,4 @@ void os_fill_handlinfo(struct kern_handlers h)
        sig_info[SIGSEGV] = h.page_fault;
        sig_info[SIGIO] = h.sigio_handler;
        sig_info[SIGVTALRM] = h.timer_handler;
-       sig_info[SIGALRM] = h.timer_handler;
-       sig_info[SIGUSR2] = usr2_handler;
-}
-
-void do_longjmp(void *b, int val)
-{
-       jmp_buf *buf = b;
-
-       UML_LONGJMP(buf, val);
 }
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
deleted file mode 100644 (file)
index bcf9359..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sched.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/ptrace.h>
-#include <linux/ptrace.h>
-#include <sys/wait.h>
-#include <sys/mman.h>
-#include <asm/ptrace.h>
-#include <asm/unistd.h>
-#include <asm/page.h>
-#include "kern_util.h"
-#include "user.h"
-#include "signal_kern.h"
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-#include "irq_user.h"
-#include "ptrace_user.h"
-#include "init.h"
-#include "os.h"
-#include "uml-config.h"
-#include "choose-mode.h"
-#include "mode.h"
-#include "tempfile.h"
-#include "kern_constants.h"
-
-int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
-                  int must_succeed)
-{
-       int err;
-
-       err = os_protect_memory((void *) addr, len, r, w, x);
-       if(err < 0){
-                if(must_succeed)
-                       panic("protect failed, err = %d", -err);
-               else return(err);
-       }
-       return(0);
-}
-
-void kill_child_dead(int pid)
-{
-       kill(pid, SIGKILL);
-       kill(pid, SIGCONT);
-       do {
-               int n;
-               CATCH_EINTR(n = waitpid(pid, NULL, 0));
-               if (n > 0)
-                       kill(pid, SIGCONT);
-               else
-                       break;
-       } while(1);
-}
-
-void stop(void)
-{
-       while(1) sleep(1000000);
-}
-
-int wait_for_stop(int pid, int sig, int cont_type, void *relay)
-{
-       sigset_t *relay_signals = relay;
-       int status, ret;
-
-       while(1){
-               CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED));
-               if((ret < 0) ||
-                  !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){
-                       if(ret < 0){
-                               printk("wait failed, errno = %d\n",
-                                      errno);
-                       }
-                       else if(WIFEXITED(status))
-                               printk("process %d exited with status %d\n",
-                                      pid, WEXITSTATUS(status));
-                       else if(WIFSIGNALED(status))
-                               printk("process %d exited with signal %d\n",
-                                      pid, WTERMSIG(status));
-                       else if((WSTOPSIG(status) == SIGVTALRM) ||
-                               (WSTOPSIG(status) == SIGALRM) ||
-                               (WSTOPSIG(status) == SIGIO) ||
-                               (WSTOPSIG(status) == SIGPROF) ||
-                               (WSTOPSIG(status) == SIGCHLD) ||
-                               (WSTOPSIG(status) == SIGWINCH) ||
-                               (WSTOPSIG(status) == SIGINT)){
-                               ptrace(cont_type, pid, 0, WSTOPSIG(status));
-                               continue;
-                       }
-                       else if((relay_signals != NULL) &&
-                               sigismember(relay_signals, WSTOPSIG(status))){
-                               ptrace(cont_type, pid, 0, WSTOPSIG(status));
-                               continue;
-                       }
-                       else printk("process %d stopped with signal %d\n",
-                                   pid, WSTOPSIG(status));
-                       panic("wait_for_stop failed to wait for %d to stop "
-                             "with %d\n", pid, sig);
-               }
-               return(status);
-       }
-}
-
-void forward_ipi(int fd, int pid)
-{
-       int err;
-
-       err = os_set_owner(fd, pid);
-       if(err < 0)
-               printk("forward_ipi: set_owner failed, fd = %d, me = %d, "
-                      "target = %d, err = %d\n", fd, os_getpid(), pid, -err);
-}
-
-/*
- *-------------------------
- * only for tt mode (will be deleted in future...)
- *-------------------------
- */
-
-struct tramp {
-       int (*tramp)(void *);
-       void *tramp_data;
-       unsigned long temp_stack;
-       int flags;
-       int pid;
-};
-
-/* See above for why sigkill is here */
-
-int sigkill = SIGKILL;
-
-int outer_tramp(void *arg)
-{
-       struct tramp *t;
-       int sig = sigkill;
-
-       t = arg;
-       t->pid = clone(t->tramp, (void *) t->temp_stack + UM_KERN_PAGE_SIZE/2,
-                      t->flags, t->tramp_data);
-       if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
-       kill(os_getpid(), sig);
-       _exit(0);
-}
-
-int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
-                    int clone_flags, int (*tramp)(void *))
-{
-       struct tramp arg;
-       unsigned long sp;
-       int new_pid, status, err;
-
-       /* The trampoline will run on the temporary stack */
-       sp = stack_sp(temp_stack);
-
-       clone_flags |= CLONE_FILES | SIGCHLD;
-
-       arg.tramp = tramp;
-       arg.tramp_data = thread_arg;
-       arg.temp_stack = temp_stack;
-       arg.flags = clone_flags;
-
-       /* Start the process and wait for it to kill itself */
-       new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
-       if(new_pid < 0)
-               return(new_pid);
-
-       CATCH_EINTR(err = waitpid(new_pid, &status, 0));
-       if(err < 0)
-               panic("Waiting for outer trampoline failed - errno = %d",
-                     errno);
-
-       if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
-               panic("outer trampoline didn't exit with SIGKILL, "
-                     "status = %d", status);
-
-       return(arg.pid);
-}
-
-void forward_pending_sigio(int target)
-{
-       sigset_t sigs;
-
-       if(sigpending(&sigs))
-               panic("forward_pending_sigio : sigpending failed");
-       if(sigismember(&sigs, SIGIO))
-               kill(target, SIGIO);
-}
-
index bbb73a6..8d27b6d 100644 (file)
@@ -8,7 +8,7 @@
 #include "longjmp.h"
 
 unsigned long __do_user_copy(void *to, const void *from, int n,
-                            void **fault_addr, void **fault_catcher,
+                            void **fault_addr, jmp_buf **fault_catcher,
                             void (*op)(void *to, const void *from,
                                        int n), int *faulted_out)
 {
index b462863..106fa86 100644 (file)
@@ -1,17 +1,21 @@
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
 #include <stdio.h>
-#include <unistd.h>
 #include <stdlib.h>
-#include <string.h>
+#include <dirent.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <signal.h>
-#include <dirent.h>
-#include <sys/fcntl.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/stat.h>
-#include <sys/param.h>
 #include "init.h"
+#include "kern_constants.h"
 #include "os.h"
 #include "user.h"
-#include "mode.h"
 
 #define UML_DIR "~/.uml/"
 
@@ -28,13 +32,13 @@ static int __init make_uml_dir(void)
        char dir[512] = { '\0' };
        int len, err;
 
-       if(*uml_dir == '~'){
+       if (*uml_dir == '~') {
                char *home = getenv("HOME");
 
                err = -ENOENT;
-               if(home == NULL){
-                       printk("make_uml_dir : no value in environment for "
-                              "$HOME\n");
+               if (home == NULL) {
+                       printk(UM_KERN_ERR "make_uml_dir : no value in "
+                              "environment for $HOME\n");
                        goto err;
                }
                strlcpy(dir, home, sizeof(dir));
@@ -53,7 +57,7 @@ static int __init make_uml_dir(void)
        }
        strcpy(uml_dir, dir);
 
-       if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){
+       if ((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)) {
                printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno));
                err = -errno;
                goto err_free;
@@ -70,8 +74,8 @@ err:
 /*
  * Unlinks the files contained in @dir and then removes @dir.
  * Doesn't handle directory trees, so it's not like rm -rf, but almost such. We
- * ignore ENOENT errors for anything (they happen, strangely enough - possibly due
- * to races between multiple dying UML threads).
+ * ignore ENOENT errors for anything (they happen, strangely enough - possibly
+ * due to races between multiple dying UML threads).
  */
 static int remove_files_and_dir(char *dir)
 {
@@ -116,7 +120,8 @@ out:
        return ret;
 }
 
-/* This says that there isn't already a user of the specified directory even if
+/*
+ * This says that there isn't already a user of the specified directory even if
  * there are errors during the checking.  This is because if these errors
  * happen, the directory is unusable by the pre-existing UML, so we might as
  * well take it over.  This could happen either by
@@ -134,44 +139,45 @@ static inline int is_umdir_used(char *dir)
        int dead, fd, p, n, err;
 
        n = snprintf(file, sizeof(file), "%s/pid", dir);
-       if(n >= sizeof(file)){
-               printk("is_umdir_used - pid filename too long\n");
+       if (n >= sizeof(file)) {
+               printk(UM_KERN_ERR "is_umdir_used - pid filename too long\n");
                err = -E2BIG;
                goto out;
        }
 
        dead = 0;
        fd = open(file, O_RDONLY);
-       if(fd < 0) {
+       if (fd < 0) {
                fd = -errno;
-               if(fd != -ENOENT){
-                       printk("is_umdir_used : couldn't open pid file '%s', "
-                              "err = %d\n", file, -fd);
+               if (fd != -ENOENT) {
+                       printk(UM_KERN_ERR "is_umdir_used : couldn't open pid "
+                              "file '%s', err = %d\n", file, -fd);
                }
                goto out;
        }
 
        err = 0;
        n = read(fd, pid, sizeof(pid));
-       if(n < 0){
-               printk("is_umdir_used : couldn't read pid file '%s', "
-                      "err = %d\n", file, errno);
+       if (n < 0) {
+               printk(UM_KERN_ERR "is_umdir_used : couldn't read pid file "
+                      "'%s', err = %d\n", file, errno);
                goto out_close;
-       } else if(n == 0){
-               printk("is_umdir_used : couldn't read pid file '%s', "
-                      "0-byte read\n", file);
+       } else if (n == 0) {
+               printk(UM_KERN_ERR "is_umdir_used : couldn't read pid file "
+                      "'%s', 0-byte read\n", file);
                goto out_close;
        }
 
        p = strtoul(pid, &end, 0);
-       if(end == pid){
-               printk("is_umdir_used : couldn't parse pid file '%s', "
-                      "errno = %d\n", file, errno);
+       if (end == pid) {
+               printk(UM_KERN_ERR "is_umdir_used : couldn't parse pid file "
+                      "'%s', errno = %d\n", file, errno);
                goto out_close;
        }
 
-       if((kill(p, 0) == 0) || (errno != ESRCH)){
-               printk("umid \"%s\" is already in use by pid %d\n", umid, p);
+       if ((kill(p, 0) == 0) || (errno != ESRCH)) {
+               printk(UM_KERN_ERR "umid \"%s\" is already in use by pid %d\n",
+                      umid, p);
                return 1;
        }
 
@@ -195,8 +201,8 @@ static int umdir_take_if_dead(char *dir)
 
        ret = remove_files_and_dir(dir);
        if (ret) {
-               printk("is_umdir_used - remove_files_and_dir failed with "
-                      "err = %d\n", ret);
+               printk(UM_KERN_ERR "is_umdir_used - remove_files_and_dir "
+                      "failed with err = %d\n", ret);
        }
        return ret;
 }
@@ -207,27 +213,28 @@ static void __init create_pid_file(void)
        char pid[sizeof("nnnnn\0")];
        int fd, n;
 
-       if(umid_file_name("pid", file, sizeof(file)))
+       if (umid_file_name("pid", file, sizeof(file)))
                return;
 
        fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);
-       if(fd < 0){
-               printk("Open of machine pid file \"%s\" failed: %s\n",
-                      file, strerror(errno));
+       if (fd < 0) {
+               printk(UM_KERN_ERR "Open of machine pid file \"%s\" failed: "
+                      "%s\n", file, strerror(errno));
                return;
        }
 
        snprintf(pid, sizeof(pid), "%d\n", getpid());
        n = write(fd, pid, strlen(pid));
-       if(n != strlen(pid))
-               printk("Write of pid file failed - err = %d\n", errno);
+       if (n != strlen(pid))
+               printk(UM_KERN_ERR "Write of pid file failed - err = %d\n",
+                      errno);
 
        close(fd);
 }
 
 int __init set_umid(char *name)
 {
-       if(strlen(name) > UMID_LEN - 1)
+       if (strlen(name) > UMID_LEN - 1)
                return -E2BIG;
 
        strlcpy(umid, name, sizeof(umid));
@@ -243,18 +250,18 @@ int __init make_umid(void)
        int fd, err;
        char tmp[256];
 
-       if(umid_setup)
+       if (umid_setup)
                return 0;
 
        make_uml_dir();
 
-       if(*umid == '\0'){
+       if (*umid == '\0') {
                strlcpy(tmp, uml_dir, sizeof(tmp));
                strlcat(tmp, "XXXXXX", sizeof(tmp));
                fd = mkstemp(tmp);
-               if(fd < 0){
-                       printk("make_umid - mkstemp(%s) failed: %s\n",
-                              tmp, strerror(errno));
+               if (fd < 0) {
+                       printk(UM_KERN_ERR "make_umid - mkstemp(%s) failed: "
+                              "%s\n", tmp, strerror(errno));
                        err = -errno;
                        goto err;
                }
@@ -263,11 +270,12 @@ int __init make_umid(void)
 
                set_umid(&tmp[strlen(uml_dir)]);
 
-               /* There's a nice tiny little race between this unlink and
+               /*
+                * There's a nice tiny little race between this unlink and
                 * the mkdir below.  It'd be nice if there were a mkstemp
                 * for directories.
                 */
-               if(unlink(tmp)){
+               if (unlink(tmp)) {
                        err = -errno;
                        goto err;
                }
@@ -275,9 +283,9 @@ int __init make_umid(void)
 
        snprintf(tmp, sizeof(tmp), "%s%s", uml_dir, umid);
        err = mkdir(tmp, 0777);
-       if(err < 0){
+       if (err < 0) {
                err = -errno;
-               if(err != -EEXIST)
+               if (err != -EEXIST)
                        goto err;
 
                if (umdir_take_if_dead(tmp) < 0)
@@ -285,9 +293,10 @@ int __init make_umid(void)
 
                err = mkdir(tmp, 0777);
        }
-       if(err){
+       if (err) {
                err = -errno;
-               printk("Failed to create '%s' - err = %d\n", umid, -errno);
+               printk(UM_KERN_ERR "Failed to create '%s' - err = %d\n", umid,
+                      errno);
                goto err;
        }
 
@@ -302,14 +311,15 @@ int __init make_umid(void)
 
 static int __init make_umid_init(void)
 {
-       if(!make_umid())
+       if (!make_umid())
                return 0;
 
-       /* If initializing with the given umid failed, then try again with
+       /*
+        * If initializing with the given umid failed, then try again with
         * a random one.
         */
-       printk("Failed to initialize umid \"%s\", trying with a random umid\n",
-              umid);
+       printk(UM_KERN_ERR "Failed to initialize umid \"%s\", trying with a "
+              "random umid\n", umid);
        *umid = '\0';
        make_umid();
 
@@ -323,12 +333,12 @@ int __init umid_file_name(char *name, char *buf, int len)
        int n, err;
 
        err = make_umid();
-       if(err)
+       if (err)
                return err;
 
        n = snprintf(buf, len, "%s%s/%s", uml_dir, umid, name);
-       if(n >= len){
-               printk("umid_file_name : buffer too short\n");
+       if (n >= len) {
+               printk(UM_KERN_ERR "umid_file_name : buffer too short\n");
                return -E2BIG;
        }
 
@@ -342,21 +352,22 @@ char *get_umid(void)
 
 static int __init set_uml_dir(char *name, int *add)
 {
-       if(*name == '\0'){
+       if (*name == '\0') {
                printf("uml_dir can't be an empty string\n");
                return 0;
        }
 
-       if(name[strlen(name) - 1] == '/'){
+       if (name[strlen(name) - 1] == '/') {
                uml_dir = name;
                return 0;
        }
 
        uml_dir = malloc(strlen(name) + 2);
-       if(uml_dir == NULL){
+       if (uml_dir == NULL) {
                printf("Failed to malloc uml_dir - error = %d\n", errno);
 
-               /* Return 0 here because do_initcalls doesn't look at
+               /*
+                * Return 0 here because do_initcalls doesn't look at
                 * the return value.
                 */
                return 0;
@@ -377,7 +388,7 @@ static void remove_umid_dir(void)
 
        sprintf(dir, "%s%s", uml_dir, umid);
        err = remove_files_and_dir(dir);
-       if(err)
+       if (err)
                printf("remove_umid_dir - remove_files_and_dir failed with "
                       "err = %d\n", err);
 }
index 7cbcf48..ef09543 100644 (file)
@@ -105,6 +105,44 @@ int setjmp_wrapper(void (*proc)(void *, void *), ...)
 
 void os_dump_core(void)
 {
+       int pid;
+
        signal(SIGSEGV, SIG_DFL);
+
+       /*
+        * We are about to SIGTERM this entire process group to ensure that
+        * nothing is around to run after the kernel exits.  The
+        * kernel wants to abort, not die through SIGTERM, so we
+        * ignore it here.
+        */
+
+       signal(SIGTERM, SIG_IGN);
+       kill(0, SIGTERM);
+       /*
+        * Most of the other processes associated with this UML are
+        * likely sTopped, so give them a SIGCONT so they see the
+        * SIGTERM.
+        */
+       kill(0, SIGCONT);
+
+       /*
+        * Now, having sent signals to everyone but us, make sure they
+        * die by ptrace.  Processes can survive what's been done to
+        * them so far - the mechanism I understand is receiving a
+        * SIGSEGV and segfaulting immediately upon return.  There is
+        * always a SIGSEGV pending, and (I'm guessing) signals are
+        * processed in numeric order so the SIGTERM (signal 15 vs
+        * SIGSEGV being signal 11) is never handled.
+        *
+        * Run a waitpid loop until we get some kind of error.
+        * Hopefully, it's ECHILD, but there's not a lot we can do if
+        * it's something else.  Tell os_kill_ptraced_process not to
+        * wait for the child to report its death because there's
+        * nothing reasonable to do if that fails.
+        */
+
+       while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
+               os_kill_ptraced_process(pid, 0);
+
        abort();
 }
index a9a4b85..61107b6 100644 (file)
@@ -21,12 +21,12 @@ $(UNPROFILE_OBJS:.o=.%): \
 $(UNPROFILE_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
        -Dunix -D__unix__ -D__$(SUBARCH)__ $(CF)
 
-# The stubs and unmap.o can't try to call mcount or update basic block data
+# The stubs can't try to call mcount or update basic block data
 define unprofile
        $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
 endef
 
 ifdef subarch-obj-y
 obj-y += subarch.o
-subarch-y = $(addprefix ../../$(SUBARCH)/,$(subarch-obj-y))
+subarch-y = $(addprefix ../../$(HEADER_ARCH)/,$(subarch-obj-y))
 endif
index d6b3ecd..964dc1a 100644 (file)
@@ -1,23 +1,21 @@
+#
+# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+#
+
 obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
-       ptrace_user.o setjmp.o signal.o sigcontext.o syscalls.o sysrq.o \
+       ptrace_user.o setjmp.o signal.o stub.o stub_segv.o syscalls.o sysrq.o \
        sys_call_table.o tls.o
 
-obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
-
-subarch-obj-y = lib/bitops.o lib/semaphore.o lib/string.o
-subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o
-subarch-obj-$(CONFIG_MODULES) += kernel/module.o
+subarch-obj-y = lib/bitops_32.o lib/semaphore_32.o lib/string_32.o
+subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem_32.o
+subarch-obj-$(CONFIG_MODULES) += kernel/module_32.o
 
-USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
+USER_OBJS := bugs.o ptrace_user.o fault.o
 
 USER_OBJS += user-offsets.s
 extra-y += user-offsets.s
 
-extra-$(CONFIG_MODE_TT) += unmap.o
-
 UNPROFILE_OBJS := stub_segv.o
 CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
 
 include arch/um/scripts/Makefile.rules
-
-$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))
index 200c8ba..a4360b5 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/uaccess.h>
 
 /* Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
- * that's not relevent in skas mode.
+ * that's not relevant in skas mode.
  */
 
 int is_valid_bugaddr(unsigned long eip)
index 0393e44..806895d 100644 (file)
@@ -1,18 +1,15 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <unistd.h>
 #include <errno.h>
+#include <signal.h>
 #include <string.h>
-#include <sys/signal.h>
-#include <asm/ldt.h>
-#include "kern_util.h"
-#include "user.h"
-#include "sysdep/ptrace.h"
-#include "task.h"
+#include "kern_constants.h"
 #include "os.h"
+#include "task.h"
+#include "user.h"
 
 #define MAXTOKEN 64
 
@@ -30,18 +27,20 @@ static char token(int fd, char *buf, int len, char stop)
        do {
                n = os_read_file(fd, ptr, sizeof(*ptr));
                c = *ptr++;
-               if(n != sizeof(*ptr)){
-                       if(n == 0)
+               if (n != sizeof(*ptr)) {
+                       if (n == 0)
                                return 0;
-                       printk("Reading /proc/cpuinfo failed, err = %d\n", -n);
-                       if(n < 0)
+                       printk(UM_KERN_ERR "Reading /proc/cpuinfo failed, "
+                              "err = %d\n", -n);
+                       if (n < 0)
                                return n;
                        else return -EIO;
                }
-       } while((c != '\n') && (c != stop) && (ptr < end));
+       } while ((c != '\n') && (c != stop) && (ptr < end));
 
-       if(ptr == end){
-               printk("Failed to find '%c' in /proc/cpuinfo\n", stop);
+       if (ptr == end) {
+               printk(UM_KERN_ERR "Failed to find '%c' in /proc/cpuinfo\n",
+                      stop);
                return -1;
        }
        *(ptr - 1) = '\0';
@@ -54,26 +53,27 @@ static int find_cpuinfo_line(int fd, char *key, char *scratch, int len)
        char c;
 
        scratch[len - 1] = '\0';
-       while(1){
+       while (1) {
                c = token(fd, scratch, len - 1, ':');
-               if(c <= 0)
+               if (c <= 0)
                        return 0;
-               else if(c != ':'){
-                       printk("Failed to find ':' in /proc/cpuinfo\n");
+               else if (c != ':') {
+                       printk(UM_KERN_ERR "Failed to find ':' in "
+                              "/proc/cpuinfo\n");
                        return 0;
                }
 
-               if(!strncmp(scratch, key, strlen(key)))
+               if (!strncmp(scratch, key, strlen(key)))
                        return 1;
 
                do {
                        n = os_read_file(fd, &c, sizeof(c));
-                       if(n != sizeof(c)){
-                               printk("Failed to find newline in "
+                       if (n != sizeof(c)) {
+                               printk(UM_KERN_ERR "Failed to find newline in "
                                       "/proc/cpuinfo, err = %d\n", -n);
                                return 0;
                        }
-               } while(c != '\n');
+               } while (c != '\n');
        }
        return 0;
 }
@@ -83,46 +83,50 @@ static int check_cpu_flag(char *feature, int *have_it)
        char buf[MAXTOKEN], c;
        int fd, len = ARRAY_SIZE(buf);
 
-       printk("Checking for host processor %s support...", feature);
+       printk(UM_KERN_INFO "Checking for host processor %s support...",
+              feature);
        fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
-       if(fd < 0){
-               printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
+       if (fd < 0) {
+               printk(UM_KERN_ERR "Couldn't open /proc/cpuinfo, err = %d\n",
+                      -fd);
                return 0;
        }
 
        *have_it = 0;
-       if(!find_cpuinfo_line(fd, "flags", buf, ARRAY_SIZE(buf)))
+       if (!find_cpuinfo_line(fd, "flags", buf, ARRAY_SIZE(buf)))
                goto out;
 
        c = token(fd, buf, len - 1, ' ');
-       if(c < 0)
+       if (c < 0)
                goto out;
-       else if(c != ' '){
-               printk("Failed to find ' ' in /proc/cpuinfo\n");
+       else if (c != ' ') {
+               printk(UM_KERN_ERR "Failed to find ' ' in /proc/cpuinfo\n");
                goto out;
        }
 
-       while(1){
+       while (1) {
                c = token(fd, buf, len - 1, ' ');
-               if(c < 0)
+               if (c < 0)
                        goto out;
-               else if(c == '\n') break;
+               else if (c == '\n')
+                       break;
 
-               if(!strcmp(buf, feature)){
+               if (!strcmp(buf, feature)) {
                        *have_it = 1;
                        goto out;
                }
        }
  out:
-       if(*have_it == 0)
+       if (*have_it == 0)
                printk("No\n");
-       else if(*have_it == 1)
+       else if (*have_it == 1)
                printk("Yes\n");
        os_close_file(fd);
        return 1;
 }
 
-#if 0 /* This doesn't work in tt mode, plus it's causing compilation problems
+#if 0 /*
+       * This doesn't work in tt mode, plus it's causing compilation problems
        * for some people.
        */
 static void disable_lcall(void)
@@ -135,8 +139,9 @@ static void disable_lcall(void)
        ldt.base_addr = 0;
        ldt.limit = 0;
        err = modify_ldt(1, &ldt, sizeof(ldt));
-       if(err)
-               printk("Failed to disable lcall7 - errno = %d\n", errno);
+       if (err)
+               printk(UM_KERN_ERR "Failed to disable lcall7 - errno = %d\n",
+                      errno);
 }
 #endif
 
@@ -151,40 +156,41 @@ void arch_check_bugs(void)
 {
        int have_it;
 
-       if(os_access("/proc/cpuinfo", OS_ACC_R_OK) < 0){
-               printk("/proc/cpuinfo not available - skipping CPU capability "
-                      "checks\n");
+       if (os_access("/proc/cpuinfo", OS_ACC_R_OK) < 0) {
+               printk(UM_KERN_ERR "/proc/cpuinfo not available - skipping CPU "
+                      "capability checks\n");
                return;
        }
-       if(check_cpu_flag("cmov", &have_it))
+       if (check_cpu_flag("cmov", &have_it))
                host_has_cmov = have_it;
-       if(check_cpu_flag("xmm", &have_it))
+       if (check_cpu_flag("xmm", &have_it))
                host_has_xmm = have_it;
 }
 
-int arch_handle_signal(int sig, union uml_pt_regs *regs)
+int arch_handle_signal(int sig, struct uml_pt_regs *regs)
 {
        unsigned char tmp[2];
 
-       /* This is testing for a cmov (0x0f 0x4x) instruction causing a
+       /*
+        * This is testing for a cmov (0x0f 0x4x) instruction causing a
         * SIGILL in init.
         */
-       if((sig != SIGILL) || (TASK_PID(get_current()) != 1))
+       if ((sig != SIGILL) || (TASK_PID(get_current()) != 1))
                return 0;
 
        if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2))
                panic("SIGILL in init, could not read instructions!\n");
-       if((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
+       if ((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
                return 0;
 
-       if(host_has_cmov == 0)
+       if (host_has_cmov == 0)
                panic("SIGILL caused by cmov, which this processor doesn't "
                      "implement, boot a filesystem compiled for older "
                      "processors");
-       else if(host_has_cmov == 1)
+       else if (host_has_cmov == 1)
                panic("SIGILL caused by cmov, which this processor claims to "
                      "implement");
-       else if(host_has_cmov == -1)
+       else if (host_has_cmov == -1)
                panic("SIGILL caused by cmov, couldn't tell if this processor "
                      "implements it, boot a filesystem compiled for older "
                      "processors");
index 745b4fd..d670f68 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 - 2004 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -15,14 +15,14 @@ struct exception_table_entry
 const struct exception_table_entry *search_exception_tables(unsigned long add);
 
 /* Compare this to arch/i386/mm/extable.c:fixup_exception() */
-int arch_fixup(unsigned long address, union uml_pt_regs *regs)
+int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
 {
        const struct exception_table_entry *fixup;
 
        fixup = search_exception_tables(address);
-       if(fixup != 0){
+       if (fixup != 0) {
                UPT_IP(regs) = fixup->fixup;
-               return(1);
+               return 1;
        }
-       return(0);
+       return 0;
 }
index a939a7e..67c0958 100644 (file)
 /*
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/slab.h"
-#include "linux/types.h"
-#include "linux/errno.h"
-#include "linux/spinlock.h"
-#include "asm/uaccess.h"
-#include "asm/smp.h"
-#include "asm/ldt.h"
+#include "linux/mm.h"
 #include "asm/unistd.h"
-#include "choose-mode.h"
-#include "kern.h"
-#include "mode_kern.h"
 #include "os.h"
-
-extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
-
-#ifdef CONFIG_MODE_TT
-
-static long do_modify_ldt_tt(int func, void __user *ptr,
-                             unsigned long bytecount)
-{
-       struct user_desc info;
-       int res = 0;
-       void *buf = NULL;
-       void *p = NULL; /* What we pass to host. */
-
-       switch(func){
-       case 1:
-       case 0x11: /* write_ldt */
-               /* Do this check now to avoid overflows. */
-               if (bytecount != sizeof(struct user_desc)) {
-                       res = -EINVAL;
-                       goto out;
-               }
-
-               if(copy_from_user(&info, ptr, sizeof(info))) {
-                       res = -EFAULT;
-                       goto out;
-               }
-
-               p = &info;
-               break;
-       case 0:
-       case 2: /* read_ldt */
-
-               /* The use of info avoids kmalloc on the write case, not on the
-                * read one. */
-               buf = kmalloc(bytecount, GFP_KERNEL);
-               if (!buf) {
-                       res = -ENOMEM;
-                       goto out;
-               }
-               p = buf;
-               break;
-       default:
-               res = -ENOSYS;
-               goto out;
-       }
-
-       res = modify_ldt(func, p, bytecount);
-       if(res < 0)
-               goto out;
-
-       switch(func){
-       case 0:
-       case 2:
-               /* Modify_ldt was for reading and returned the number of read
-                * bytes.*/
-               if(copy_to_user(ptr, p, res))
-                       res = -EFAULT;
-               break;
-       }
-
-out:
-       kfree(buf);
-       return res;
-}
-
-#endif
-
-#ifdef CONFIG_MODE_SKAS
-
+#include "proc_mm.h"
 #include "skas.h"
 #include "skas_ptrace.h"
-#include "asm/mmu_context.h"
-#include "proc_mm.h"
+#include "sysdep/tls.h"
+
+extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
 long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                     void **addr, int done)
 {
        long res;
 
-       if(proc_mm){
-               /* This is a special handling for the case, that the mm to
+       if (proc_mm) {
+               /*
+                * This is a special handling for the case, that the mm to
                 * modify isn't current->active_mm.
                 * If this is called directly by modify_ldt,
                 *     (current->active_mm->context.skas.u == mm_idp)
-                * will be true. So no call to switch_mm_skas(mm_idp) is done.
+                * will be true. So no call to __switch_mm(mm_idp) is done.
                 * If this is called in case of init_new_ldt or PTRACE_LDT,
                 * mm_idp won't belong to current->active_mm, but child->mm.
                 * So we need to switch child's mm into our userspace, then
@@ -108,12 +32,12 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                 *
                 * Note: I'm unsure: should interrupts be disabled here?
                 */
-               if(!current->active_mm || current->active_mm == &init_mm ||
-                  mm_idp != &current->active_mm->context.skas.id)
-                       switch_mm_skas(mm_idp);
+               if (!current->active_mm || current->active_mm == &init_mm ||
+                   mm_idp != &current->active_mm->context.id)
+                       __switch_mm(mm_idp);
        }
 
-       if(ptrace_ldt) {
+       if (ptrace_ldt) {
                struct ptrace_ldt ldt_op = (struct ptrace_ldt) {
                        .func = func,
                        .ptr = desc,
@@ -121,7 +45,7 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                u32 cpu;
                int pid;
 
-               if(!proc_mm)
+               if (!proc_mm)
                        pid = mm_idp->u.pid;
                else {
                        cpu = get_cpu();
@@ -130,7 +54,7 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
 
                res = os_ptrace_ldt(pid, 0, (unsigned long) &ldt_op);
 
-               if(proc_mm)
+               if (proc_mm)
                        put_cpu();
        }
        else {
@@ -139,7 +63,7 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                                        (sizeof(*desc) + sizeof(long) - 1) &
                                            ~(sizeof(long) - 1),
                                        addr, &stub_addr);
-               if(!res){
+               if (!res) {
                        unsigned long args[] = { func,
                                                 (unsigned long)stub_addr,
                                                 sizeof(*desc),
@@ -149,13 +73,14 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
                }
        }
 
-       if(proc_mm){
-               /* This is the second part of special handling, that makes
+       if (proc_mm) {
+               /*
+                * This is the second part of special handling, that makes
                 * PTRACE_LDT possible to implement.
                 */
-               if(current->active_mm && current->active_mm != &init_mm &&
-                  mm_idp != &current->active_mm->context.skas.id)
-                       switch_mm_skas(&current->active_mm->context.skas.id);
+               if (current->active_mm && current->active_mm != &init_mm &&
+                   mm_idp != &current->active_mm->context.id)
+                       __switch_mm(&current->active_mm->context.id);
        }
 
        return res;
@@ -170,21 +95,22 @@ static long read_ldt_from_host(void __user * ptr, unsigned long bytecount)
                        .ptr = kmalloc(bytecount, GFP_KERNEL)};
        u32 cpu;
 
-       if(ptrace_ldt.ptr == NULL)
+       if (ptrace_ldt.ptr == NULL)
                return -ENOMEM;
 
-       /* This is called from sys_modify_ldt only, so userspace_pid gives
+       /*
+        * This is called from sys_modify_ldt only, so userspace_pid gives
         * us the right number
         */
 
        cpu = get_cpu();
        res = os_ptrace_ldt(userspace_pid[cpu], 0, (unsigned long) &ptrace_ldt);
        put_cpu();
-       if(res < 0)
+       if (res < 0)
                goto out;
 
        n = copy_to_user(ptr, ptrace_ldt.ptr, res);
-       if(n != 0)
+       if (n != 0)
                res = -EFAULT;
 
   out:
@@ -209,35 +135,34 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
 {
        int i, err = 0;
        unsigned long size;
-       uml_ldt_t * ldt = &current->mm->context.skas.ldt;
+       uml_ldt_t * ldt = &current->mm->context.ldt;
 
-       if(!ldt->entry_count)
+       if (!ldt->entry_count)
                goto out;
-       if(bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
+       if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
                bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
        err = bytecount;
 
-       if(ptrace_ldt){
+       if (ptrace_ldt)
                return read_ldt_from_host(ptr, bytecount);
-       }
 
        down(&ldt->semaphore);
-       if(ldt->entry_count <= LDT_DIRECT_ENTRIES){
+       if (ldt->entry_count <= LDT_DIRECT_ENTRIES) {
                size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES;
-               if(size > bytecount)
+               if (size > bytecount)
                        size = bytecount;
-               if(copy_to_user(ptr, ldt->u.entries, size))
+               if (copy_to_user(ptr, ldt->u.entries, size))
                        err = -EFAULT;
                bytecount -= size;
                ptr += size;
        }
        else {
-               for(i=0; i<ldt->entry_count/LDT_ENTRIES_PER_PAGE && bytecount;
-                        i++){
+               for (i=0; i<ldt->entry_count/LDT_ENTRIES_PER_PAGE && bytecount;
+                    i++) {
                        size = PAGE_SIZE;
-                       if(size > bytecount)
+                       if (size > bytecount)
                                size = bytecount;
-                       if(copy_to_user(ptr, ldt->u.pages[i], size)){
+                       if (copy_to_user(ptr, ldt->u.pages[i], size)) {
                                err = -EFAULT;
                                break;
                        }
@@ -247,10 +172,10 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
        }
        up(&ldt->semaphore);
 
-       if(bytecount == 0 || err == -EFAULT)
+       if (bytecount == 0 || err == -EFAULT)
                goto out;
 
-       if(clear_user(ptr, bytecount))
+       if (clear_user(ptr, bytecount))
                err = -EFAULT;
 
 out:
@@ -261,15 +186,16 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
 {
        int err;
 
-       if(bytecount > 5*LDT_ENTRY_SIZE)
+       if (bytecount > 5*LDT_ENTRY_SIZE)
                bytecount = 5*LDT_ENTRY_SIZE;
 
        err = bytecount;
-       /* UML doesn't support lcall7 and lcall27.
+       /*
+        * UML doesn't support lcall7 and lcall27.
         * So, we don't really have a default ldt, but emulate
         * an empty ldt of common host default ldt size.
         */
-       if(clear_user(ptr, bytecount))
+       if (clear_user(ptr, bytecount))
                err = -EFAULT;
 
        return err;
@@ -277,60 +203,60 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
 
 static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
 {
-       uml_ldt_t * ldt = &current->mm->context.skas.ldt;
-       struct mm_id * mm_idp = &current->mm->context.skas.id;
+       uml_ldt_t * ldt = &current->mm->context.ldt;
+       struct mm_id * mm_idp = &current->mm->context.id;
        int i, err;
        struct user_desc ldt_info;
        struct ldt_entry entry0, *ldt_p;
        void *addr = NULL;
 
        err = -EINVAL;
-       if(bytecount != sizeof(ldt_info))
+       if (bytecount != sizeof(ldt_info))
                goto out;
        err = -EFAULT;
-       if(copy_from_user(&ldt_info, ptr, sizeof(ldt_info)))
+       if (copy_from_user(&ldt_info, ptr, sizeof(ldt_info)))
                goto out;
 
        err = -EINVAL;
-       if(ldt_info.entry_number >= LDT_ENTRIES)
+       if (ldt_info.entry_number >= LDT_ENTRIES)
                goto out;
-       if(ldt_info.contents == 3){
+       if (ldt_info.contents == 3) {
                if (func == 1)
                        goto out;
                if (ldt_info.seg_not_present == 0)
                        goto out;
        }
 
-        if(!ptrace_ldt)
-                down(&ldt->semaphore);
+       if (!ptrace_ldt)
+               down(&ldt->semaphore);
 
        err = write_ldt_entry(mm_idp, func, &ldt_info, &addr, 1);
-       if(err)
+       if (err)
                goto out_unlock;
-        else if(ptrace_ldt) {
-       /* With PTRACE_LDT available, this is used as a flag only */
-                ldt->entry_count = 1;
-                goto out;
-        }
-
-       if(ldt_info.entry_number >= ldt->entry_count &&
-          ldt_info.entry_number >= LDT_DIRECT_ENTRIES){
-               for(i=ldt->entry_count/LDT_ENTRIES_PER_PAGE;
-                   i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number;
-                   i++){
-                       if(i == 0)
+       else if (ptrace_ldt) {
+               /* With PTRACE_LDT available, this is used as a flag only */
+               ldt->entry_count = 1;
+               goto out;
+       }
+
+       if (ldt_info.entry_number >= ldt->entry_count &&
+           ldt_info.entry_number >= LDT_DIRECT_ENTRIES) {
+               for (i=ldt->entry_count/LDT_ENTRIES_PER_PAGE;
+                    i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number;
+                    i++) {
+                       if (i == 0)
                                memcpy(&entry0, ldt->u.entries,
                                       sizeof(entry0));
                        ldt->u.pages[i] = (struct ldt_entry *)
                                __get_free_page(GFP_KERNEL|__GFP_ZERO);
-                       if(!ldt->u.pages[i]){
+                       if (!ldt->u.pages[i]) {
                                err = -ENOMEM;
                                /* Undo the change in host */
                                memset(&ldt_info, 0, sizeof(ldt_info));
                                write_ldt_entry(mm_idp, 1, &ldt_info, &addr, 1);
                                goto out_unlock;
                        }
-                       if(i == 0) {
+                       if (i == 0) {
                                memcpy(ldt->u.pages[0], &entry0,
                                       sizeof(entry0));
                                memcpy(ldt->u.pages[0]+1, ldt->u.entries+1,
@@ -339,17 +265,17 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
                        ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE;
                }
        }
-       if(ldt->entry_count <= ldt_info.entry_number)
+       if (ldt->entry_count <= ldt_info.entry_number)
                ldt->entry_count = ldt_info.entry_number + 1;
 
-       if(ldt->entry_count <= LDT_DIRECT_ENTRIES)
+       if (ldt->entry_count <= LDT_DIRECT_ENTRIES)
                ldt_p = ldt->u.entries + ldt_info.entry_number;
        else
                ldt_p = ldt->u.pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] +
                        ldt_info.entry_number%LDT_ENTRIES_PER_PAGE;
 
-       if(ldt_info.base_addr == 0 && ldt_info.limit == 0 &&
-          (func == 1 || LDT_empty(&ldt_info))){
+       if (ldt_info.base_addr == 0 && ldt_info.limit == 0 &&
+          (func == 1 || LDT_empty(&ldt_info))) {
                ldt_p->a = 0;
                ldt_p->b = 0;
        }
@@ -400,7 +326,7 @@ static void ldt_get_host_info(void)
 
        spin_lock(&host_ldt_lock);
 
-       if(host_ldt_entries != NULL){
+       if (host_ldt_entries != NULL) {
                spin_unlock(&host_ldt_lock);
                return;
        }
@@ -408,49 +334,49 @@ static void ldt_get_host_info(void)
 
        spin_unlock(&host_ldt_lock);
 
-       for(i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++);
+       for (i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++)
+               ;
 
        ldt = (struct ldt_entry *)
              __get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
-       if(ldt == NULL) {
-               printk("ldt_get_host_info: couldn't allocate buffer for host "
-                      "ldt\n");
+       if (ldt == NULL) {
+               printk(KERN_ERR "ldt_get_host_info: couldn't allocate buffer "
+                      "for host ldt\n");
                return;
        }
 
        ret = modify_ldt(0, ldt, (1<<order)*PAGE_SIZE);
-       if(ret < 0) {
-               printk("ldt_get_host_info: couldn't read host ldt\n");
+       if (ret < 0) {
+               printk(KERN_ERR "ldt_get_host_info: couldn't read host ldt\n");
                goto out_free;
        }
-       if(ret == 0) {
+       if (ret == 0) {
                /* default_ldt is active, simply write an empty entry 0 */
                host_ldt_entries = dummy_list;
                goto out_free;
        }
 
-       for(i=0, size=0; i<ret/LDT_ENTRY_SIZE; i++){
-               if(ldt[i].a != 0 || ldt[i].b != 0)
+       for (i=0, size=0; i<ret/LDT_ENTRY_SIZE; i++) {
+               if (ldt[i].a != 0 || ldt[i].b != 0)
                        size++;
        }
 
-       if(size < ARRAY_SIZE(dummy_list))
+       if (size < ARRAY_SIZE(dummy_list))
                host_ldt_entries = dummy_list;
        else {
                size = (size + 1) * sizeof(dummy_list[0]);
                tmp = kmalloc(size, GFP_KERNEL);
-               if(tmp == NULL) {
-                       printk("ldt_get_host_info: couldn't allocate host ldt "
-                              "list\n");
+               if (tmp == NULL) {
+                       printk(KERN_ERR "ldt_get_host_info: couldn't allocate "
+                              "host ldt list\n");
                        goto out_free;
                }
                host_ldt_entries = tmp;
        }
 
-       for(i=0, k=0; i<ret/LDT_ENTRY_SIZE; i++){
-               if(ldt[i].a != 0 || ldt[i].b != 0) {
+       for (i=0, k=0; i<ret/LDT_ENTRY_SIZE; i++) {
+               if (ldt[i].a != 0 || ldt[i].b != 0)
                        host_ldt_entries[k++] = i;
-               }
        }
        host_ldt_entries[k] = -1;
 
@@ -458,8 +384,7 @@ out_free:
        free_pages((unsigned long)ldt, order);
 }
 
-long init_new_ldt(struct mmu_context_skas * new_mm,
-                 struct mmu_context_skas * from_mm)
+long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
 {
        struct user_desc desc;
        short * num_p;
@@ -469,15 +394,15 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
        struct proc_mm_op copy;
 
 
-       if(!ptrace_ldt)
+       if (!ptrace_ldt)
                init_MUTEX(&new_mm->ldt.semaphore);
 
-       if(!from_mm){
+       if (!from_mm) {
                memset(&desc, 0, sizeof(desc));
                /*
                 * We have to initialize a clean ldt.
                 */
-               if(proc_mm) {
+               if (proc_mm) {
                        /*
                         * If the new mm was created using proc_mm, host's
                         * default-ldt currently is assigned, which normally
@@ -485,8 +410,7 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                         * To remove these gates, we simply write an empty
                         * entry as number 0 to the host.
                         */
-                       err = write_ldt_entry(&new_mm->id, 1, &desc,
-                                             &addr, 1);
+                       err = write_ldt_entry(&new_mm->id, 1, &desc, &addr, 1);
                }
                else{
                        /*
@@ -495,11 +419,11 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                         * will be reset in the following loop
                         */
                        ldt_get_host_info();
-                       for(num_p=host_ldt_entries; *num_p != -1; num_p++){
+                       for (num_p=host_ldt_entries; *num_p != -1; num_p++) {
                                desc.entry_number = *num_p;
                                err = write_ldt_entry(&new_mm->id, 1, &desc,
                                                      &addr, *(num_p + 1) == -1);
-                               if(err)
+                               if (err)
                                        break;
                        }
                }
@@ -508,8 +432,9 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                goto out;
        }
 
-       if(proc_mm){
-               /* We have a valid from_mm, so we now have to copy the LDT of
+       if (proc_mm) {
+               /*
+                * We have a valid from_mm, so we now have to copy the LDT of
                 * from_mm to new_mm, because using proc_mm an new mm with
                 * an empty/default LDT was created in new_mm()
                 */
@@ -518,27 +443,27 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
                                              { .copy_segments =
                                                        from_mm->id.u.mm_fd } } );
                i = os_write_file(new_mm->id.u.mm_fd, &copy, sizeof(copy));
-               if(i != sizeof(copy))
-                       printk("new_mm : /proc/mm copy_segments failed, "
-                              "err = %d\n", -i);
+               if (i != sizeof(copy))
+                       printk(KERN_ERR "new_mm : /proc/mm copy_segments "
+                              "failed, err = %d\n", -i);
        }
 
-       if(!ptrace_ldt) {
-               /* Our local LDT is used to supply the data for
+       if (!ptrace_ldt) {
+               /*
+                * Our local LDT is used to supply the data for
                 * modify_ldt(READLDT), if PTRACE_LDT isn't available,
                 * i.e., we have to use the stub for modify_ldt, which
                 * can't handle the big read buffer of up to 64kB.
                 */
                down(&from_mm->ldt.semaphore);
-               if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){
+               if (from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES)
                        memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries,
                               sizeof(new_mm->ldt.u.entries));
-               }
-               else{
+               else {
                        i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
-                       while(i-->0){
+                       while (i-->0) {
                                page = __get_free_page(GFP_KERNEL|__GFP_ZERO);
-                               if (!page){
+                               if (!page) {
                                        err = -ENOMEM;
                                        break;
                                }
@@ -557,22 +482,19 @@ long init_new_ldt(struct mmu_context_skas * new_mm,
 }
 
 
-void free_ldt(struct mmu_context_skas * mm)
+void free_ldt(struct mm_context *mm)
 {
        int i;
 
-       if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){
+       if (!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES) {
                i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
-               while(i-- > 0){
-                       free_page((long )mm->ldt.u.pages[i]);
-               }
+               while (i-- > 0)
+                       free_page((long) mm->ldt.u.pages[i]);
        }
        mm->ldt.entry_count = 0;
 }
-#endif
 
 int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
 {
-       return CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func,
-                               ptr, bytecount);
+       return do_modify_ldt_skas(func, ptr, bytecount);
 }
index 28bf011..bd3da8a 100644 (file)
@@ -1,35 +1,26 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <linux/compiler.h>
-#include "linux/sched.h"
 #include "linux/mm.h"
-#include "asm/elf.h"
-#include "asm/ptrace.h"
+#include "linux/sched.h"
 #include "asm/uaccess.h"
-#include "asm/unistd.h"
-#include "sysdep/ptrace.h"
-#include "sysdep/sigcontext.h"
-#include "sysdep/sc.h"
+#include "skas.h"
 
-void arch_switch_to_tt(struct task_struct *from, struct task_struct *to)
-{
-       update_debugregs(to->thread.arch.debugregs_seq);
-       arch_switch_tls_tt(from, to);
-}
+extern int arch_switch_tls(struct task_struct *from, struct task_struct *to);
 
-void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *from, struct task_struct *to)
 {
-       int err = arch_switch_tls_skas(from, to);
+       int err = arch_switch_tls(from, to);
        if (!err)
                return;
 
        if (err != -EINVAL)
-               printk(KERN_WARNING "arch_switch_tls_skas failed, errno %d, not EINVAL\n", -err);
+               printk(KERN_WARNING "arch_switch_tls failed, errno %d, "
+                      "not EINVAL\n", -err);
        else
-               printk(KERN_WARNING "arch_switch_tls_skas failed, errno = EINVAL\n");
+               printk(KERN_WARNING "arch_switch_tls failed, errno = EINVAL\n");
 }
 
 int is_syscall(unsigned long addr)
@@ -38,21 +29,21 @@ int is_syscall(unsigned long addr)
        int n;
 
        n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
-       if(n){
+       if (n) {
                /* access_process_vm() grants access to vsyscall and stub,
                 * while copy_from_user doesn't. Maybe access_process_vm is
                 * slow, but that doesn't matter, since it will be called only
                 * in case of singlestepping, if copy_from_user failed.
                 */
                n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
-               if(n != sizeof(instr)) {
-                       printk("is_syscall : failed to read instruction from "
-                              "0x%lx\n", addr);
-                       return(1);
+               if (n != sizeof(instr)) {
+                       printk(KERN_ERR "is_syscall : failed to read "
+                              "instruction from 0x%lx\n", addr);
+                       return 1;
                }
        }
        /* int 0x80 or sysenter */
-       return((instr == 0x80cd) || (instr == 0x340f));
+       return (instr == 0x80cd) || (instr == 0x340f);
 }
 
 /* determines which flags the user has access to. */
@@ -96,21 +87,21 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
 
 int poke_user(struct task_struct *child, long addr, long data)
 {
-        if ((addr & 3) || addr < 0)
-                return -EIO;
-
-        if (addr < MAX_REG_OFFSET)
-                return putreg(child, addr, data);
+       if ((addr & 3) || addr < 0)
+               return -EIO;
 
-        else if((addr >= offsetof(struct user, u_debugreg[0])) &&
-                (addr <= offsetof(struct user, u_debugreg[7]))){
-                addr -= offsetof(struct user, u_debugreg[0]);
-                addr = addr >> 2;
-                if((addr == 4) || (addr == 5)) return -EIO;
-                child->thread.arch.debugregs[addr] = data;
-                return 0;
-        }
-        return -EIO;
+       if (addr < MAX_REG_OFFSET)
+               return putreg(child, addr, data);
+       else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
+                (addr <= offsetof(struct user, u_debugreg[7]))) {
+               addr -= offsetof(struct user, u_debugreg[0]);
+               addr = addr >> 2;
+               if ((addr == 4) || (addr == 5))
+                       return -EIO;
+               child->thread.arch.debugregs[addr] = data;
+               return 0;
+       }
+       return -EIO;
 }
 
 unsigned long getreg(struct task_struct *child, int regno)
@@ -133,20 +124,20 @@ unsigned long getreg(struct task_struct *child, int regno)
        return retval;
 }
 
+/* read the word at location addr in the USER area. */
 int peek_user(struct task_struct *child, long addr, long data)
 {
-/* read the word at location addr in the USER area. */
        unsigned long tmp;
 
        if ((addr & 3) || addr < 0)
                return -EIO;
 
        tmp = 0;  /* Default return condition */
-       if(addr < MAX_REG_OFFSET){
+       if (addr < MAX_REG_OFFSET) {
                tmp = getreg(child, addr);
        }
-       else if((addr >= offsetof(struct user, u_debugreg[0])) &&
-               (addr <= offsetof(struct user, u_debugreg[7]))){
+       else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
+                (addr <= offsetof(struct user, u_debugreg[7]))) {
                addr -= offsetof(struct user, u_debugreg[0]);
                addr = addr >> 2;
                tmp = child->thread.arch.debugregs[addr];
@@ -154,277 +145,68 @@ int peek_user(struct task_struct *child, long addr, long data)
        return put_user(tmp, (unsigned long __user *) data);
 }
 
-struct i387_fxsave_struct {
-       unsigned short  cwd;
-       unsigned short  swd;
-       unsigned short  twd;
-       unsigned short  fop;
-       long    fip;
-       long    fcs;
-       long    foo;
-       long    fos;
-       long    mxcsr;
-       long    reserved;
-       long    st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
-       long    xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
-       long    padding[56];
-};
-
-/*
- * FPU tag word conversions.
- */
-
-static inline unsigned short twd_i387_to_fxsr( unsigned short twd )
+int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
-       unsigned int tmp; /* to avoid 16 bit prefixes in the code */
-       /* Transform each pair of bits into 01 (valid) or 00 (empty) */
-        tmp = ~twd;
-        tmp = (tmp | (tmp>>1)) & 0x5555; /* 0V0V0V0V0V0V0V0V */
-        /* and move the valid bits to the lower byte. */
-        tmp = (tmp | (tmp >> 1)) & 0x3333; /* 00VV00VV00VV00VV */
-        tmp = (tmp | (tmp >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV */
-        tmp = (tmp | (tmp >> 4)) & 0x00ff; /* 00000000VVVVVVVV */
-        return tmp;
-}
+       int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_FP_SIZE];
 
-static inline unsigned long twd_fxsr_to_i387( struct i387_fxsave_struct *fxsave )
-{
-       struct _fpxreg *st = NULL;
-       unsigned long twd = (unsigned long) fxsave->twd;
-       unsigned long tag;
-       unsigned long ret = 0xffff0000;
-       int i;
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       err = save_fp_registers(userspace_pid[cpu], fpregs);
+       if (err)
+               return err;
 
-#define FPREG_ADDR(f, n)       ((char *)&(f)->st_space + (n) * 16);
+       n = copy_to_user(buf, fpregs, sizeof(fpregs));
+       if(n > 0)
+               return -EFAULT;
 
-       for ( i = 0 ; i < 8 ; i++ ) {
-               if ( twd & 0x1 ) {
-                       st = (struct _fpxreg *) FPREG_ADDR( fxsave, i );
-
-                       switch ( st->exponent & 0x7fff ) {
-                       case 0x7fff:
-                               tag = 2;                /* Special */
-                               break;
-                       case 0x0000:
-                               if ( !st->significand[0] &&
-                                    !st->significand[1] &&
-                                    !st->significand[2] &&
-                                    !st->significand[3] ) {
-                                       tag = 1;        /* Zero */
-                               } else {
-                                       tag = 2;        /* Special */
-                               }
-                               break;
-                       default:
-                               if ( st->significand[3] & 0x8000 ) {
-                                       tag = 0;        /* Valid */
-                               } else {
-                                       tag = 2;        /* Special */
-                               }
-                               break;
-                       }
-               } else {
-                       tag = 3;                        /* Empty */
-               }
-               ret |= (tag << (2 * i));
-               twd = twd >> 1;
-       }
-       return ret;
+       return n;
 }
 
-/*
- * FXSR floating point environment conversions.
- */
-
-#ifdef CONFIG_MODE_TT
-static inline int convert_fxsr_to_user_tt(struct _fpstate __user *buf,
-                                         struct pt_regs *regs)
+int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
-       struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
-       unsigned long env[7];
-       struct _fpreg __user *to;
-       struct _fpxreg *from;
-       int i;
+       int n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_FP_SIZE];
 
-       env[0] = (unsigned long)fxsave->cwd | 0xffff0000;
-       env[1] = (unsigned long)fxsave->swd | 0xffff0000;
-       env[2] = twd_fxsr_to_i387(fxsave);
-       env[3] = fxsave->fip;
-       env[4] = fxsave->fcs | ((unsigned long)fxsave->fop << 16);
-       env[5] = fxsave->foo;
-       env[6] = fxsave->fos;
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       n = copy_from_user(fpregs, buf, sizeof(fpregs));
+       if (n > 0)
+               return -EFAULT;
 
-       if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) )
-               return 1;
-
-       to = &buf->_st[0];
-       from = (struct _fpxreg *) &fxsave->st_space[0];
-       for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
-               if ( __copy_to_user( to, from, sizeof(*to) ) )
-                       return 1;
-       }
-       return 0;
+       return restore_fp_registers(userspace_pid[cpu], fpregs);
 }
-#endif
 
-static inline int convert_fxsr_to_user(struct _fpstate __user *buf,
-                                      struct pt_regs *regs)
+int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
 {
-       return(CHOOSE_MODE(convert_fxsr_to_user_tt(buf, regs), 0));
-}
+       int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_XFP_SIZE];
 
-#ifdef CONFIG_MODE_TT
-static inline int convert_fxsr_from_user_tt(struct pt_regs *regs,
-                                           struct _fpstate __user *buf)
-{
-       struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
-       unsigned long env[7];
-       struct _fpxreg *to;
-       struct _fpreg __user *from;
-       int i;
-
-       if ( __copy_from_user( env, buf, 7 * sizeof(long) ) )
-               return 1;
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       err = save_fpx_registers(userspace_pid[cpu], fpregs);
+       if (err)
+               return err;
 
-       fxsave->cwd = (unsigned short)(env[0] & 0xffff);
-       fxsave->swd = (unsigned short)(env[1] & 0xffff);
-       fxsave->twd = twd_i387_to_fxsr((unsigned short)(env[2] & 0xffff));
-       fxsave->fip = env[3];
-       fxsave->fop = (unsigned short)((env[4] & 0xffff0000) >> 16);
-       fxsave->fcs = (env[4] & 0xffff);
-       fxsave->foo = env[5];
-       fxsave->fos = env[6];
+       n = copy_to_user(buf, fpregs, sizeof(fpregs));
+       if(n > 0)
+               return -EFAULT;
 
-       to = (struct _fpxreg *) &fxsave->st_space[0];
-       from = &buf->_st[0];
-       for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
-               if ( __copy_from_user( to, from, sizeof(*from) ) )
-                       return 1;
-       }
-       return 0;
-}
-#endif
-
-static inline int convert_fxsr_from_user(struct pt_regs *regs, 
-                                        struct _fpstate __user *buf)
-{
-       return(CHOOSE_MODE(convert_fxsr_from_user_tt(regs, buf), 0));
-}
-
-int get_fpregs(unsigned long buf, struct task_struct *child)
-{
-       int err;
-
-       err = convert_fxsr_to_user((struct _fpstate __user *) buf,
-                                  &child->thread.regs);
-       if(err) return(-EFAULT);
-       else return(0);
-}
-
-int set_fpregs(unsigned long buf, struct task_struct *child)
-{
-       int err;
-
-       err = convert_fxsr_from_user(&child->thread.regs, 
-                                    (struct _fpstate __user *) buf);
-       if(err) return(-EFAULT);
-       else return(0);
-}
-
-#ifdef CONFIG_MODE_TT
-int get_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
-{
-       struct pt_regs *regs = &tsk->thread.regs;
-       struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
-       int err;
-
-       err = __copy_to_user((void __user *) buf, fxsave,
-                            sizeof(struct user_fxsr_struct));
-       if(err) return -EFAULT;
-       else return 0;
-}
-#endif
-
-int get_fpxregs(unsigned long buf, struct task_struct *tsk)
-{
-       return(CHOOSE_MODE(get_fpxregs_tt(buf, tsk), 0));
-}
-
-#ifdef CONFIG_MODE_TT
-int set_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
-{
-       struct pt_regs *regs = &tsk->thread.regs;
-       struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
-       int err;
-
-       err = __copy_from_user(fxsave, (void __user *) buf,
-                              sizeof(struct user_fxsr_struct) );
-       if(err) return -EFAULT;
-       else return 0;
-}
-#endif
-
-int set_fpxregs(unsigned long buf, struct task_struct *tsk)
-{
-       return(CHOOSE_MODE(set_fpxregs_tt(buf, tsk), 0));
-}
-
-#ifdef notdef
-int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
-{
-       fpu->cwd = (((SC_FP_CW(PT_REGS_SC(regs)) & 0xffff) << 16) |
-                   (SC_FP_SW(PT_REGS_SC(regs)) & 0xffff));
-       fpu->swd = SC_FP_CSSEL(PT_REGS_SC(regs)) & 0xffff;
-       fpu->twd = SC_FP_IPOFF(PT_REGS_SC(regs));
-       fpu->fip = SC_FP_CSSEL(PT_REGS_SC(regs)) & 0xffff;
-       fpu->fcs = SC_FP_DATAOFF(PT_REGS_SC(regs));
-       fpu->foo = SC_FP_DATASEL(PT_REGS_SC(regs));
-       fpu->fos = 0;
-       memcpy(fpu->st_space, (void *) SC_FP_ST(PT_REGS_SC(regs)),
-              sizeof(fpu->st_space));
-       return(1);
+       return n;
 }
-#endif
 
-#ifdef CONFIG_MODE_TT
-static inline void copy_fpu_fxsave_tt(struct pt_regs *regs,
-                                     struct user_i387_struct *buf)
+int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
 {
-       struct i387_fxsave_struct *fpu = SC_FXSR_ENV(PT_REGS_SC(regs));
-       unsigned short *to;
-       unsigned short *from;
-       int i;
+       int n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_XFP_SIZE];
 
-       memcpy( buf, fpu, 7 * sizeof(long) );
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       n = copy_from_user(fpregs, buf, sizeof(fpregs));
+       if (n > 0)
+               return -EFAULT;
 
-       to = (unsigned short *) &buf->st_space[0];
-       from = (unsigned short *) &fpu->st_space[0];
-       for ( i = 0 ; i < 8 ; i++, to += 5, from += 8 ) {
-               memcpy( to, from, 5 * sizeof(unsigned short) );
-       }
+       return restore_fpx_registers(userspace_pid[cpu], fpregs);
 }
-#endif
 
-static inline void copy_fpu_fxsave(struct pt_regs *regs,
-                                  struct user_i387_struct *buf)
+long subarch_ptrace(struct task_struct *child, long request, long addr,
+                   long data)
 {
-       (void) CHOOSE_MODE(copy_fpu_fxsave_tt(regs, buf), 0);
+       return -EIO;
 }
-
-int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
-{
-       copy_fpu_fxsave(regs, (struct user_i387_struct *) fpu);
-       return(1);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 40ff0c8..5cf97bc 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include <stdio.h>
-#include <stddef.h>
 #include <errno.h>
-#include <unistd.h>
-#include "ptrace_user.h"
-/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
-#include <asm/user.h>
-#include "kern_util.h"
-#include "sysdep/thread.h"
-#include "user.h"
-#include "os.h"
-#include "uml-config.h"
+#include <sys/ptrace.h>
 
 int ptrace_getregs(long pid, unsigned long *regs_out)
 {
@@ -43,89 +33,3 @@ int ptrace_setfpregs(long pid, unsigned long *regs)
                return -errno;
        return 0;
 }
-
-#ifdef UML_CONFIG_MODE_TT
-
-static void write_debugregs(int pid, unsigned long *regs)
-{
-       struct user *dummy;
-       int nregs, i;
-
-       dummy = NULL;
-       nregs = ARRAY_SIZE(dummy->u_debugreg);
-       for(i = 0; i < nregs; i++){
-               if((i == 4) || (i == 5)) continue;
-               if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
-                         regs[i]) < 0)
-                       printk("write_debugregs - ptrace failed on "
-                              "register %d, value = 0x%lx, errno = %d\n", i,
-                              regs[i], errno);
-       }
-}
-
-static void read_debugregs(int pid, unsigned long *regs)
-{
-       struct user *dummy;
-       int nregs, i;
-
-       dummy = NULL;
-       nregs = ARRAY_SIZE(dummy->u_debugreg);
-       for(i = 0; i < nregs; i++){
-               regs[i] = ptrace(PTRACE_PEEKUSR, pid,
-                                &dummy->u_debugreg[i], 0);
-       }
-}
-
-/* Accessed only by the tracing thread */
-static unsigned long kernel_debugregs[8] = { [ 0 ... 7 ] = 0 };
-
-void arch_enter_kernel(void *task, int pid)
-{
-       read_debugregs(pid, TASK_DEBUGREGS(task));
-       write_debugregs(pid, kernel_debugregs);
-}
-
-void arch_leave_kernel(void *task, int pid)
-{
-       read_debugregs(pid, kernel_debugregs);
-       write_debugregs(pid, TASK_DEBUGREGS(task));
-}
-
-#ifdef UML_CONFIG_PT_PROXY
-/* Accessed only by the tracing thread */
-static int debugregs_seq;
-
-/* Only called by the ptrace proxy */
-void ptrace_pokeuser(unsigned long addr, unsigned long data)
-{
-       if((addr < offsetof(struct user, u_debugreg[0])) ||
-          (addr > offsetof(struct user, u_debugreg[7])))
-               return;
-       addr -= offsetof(struct user, u_debugreg[0]);
-       addr = addr >> 2;
-       if(kernel_debugregs[addr] == data) return;
-
-       kernel_debugregs[addr] = data;
-       debugregs_seq++;
-}
-
-static void update_debugregs_cb(void *arg)
-{
-       int pid = *((int *) arg);
-
-       write_debugregs(pid, kernel_debugregs);
-}
-
-/* Optimized out in its header when not defined */
-void update_debugregs(int seq)
-{
-       int me;
-
-       if(seq == debugregs_seq) return;
-
-       me = os_getpid();
-       initial_thread_cb(update_debugregs_cb, &me);
-}
-#endif
-
-#endif
diff --git a/arch/um/sys-i386/sigcontext.c b/arch/um/sys-i386/sigcontext.c
deleted file mode 100644 (file)
index 467d489..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <stddef.h>
-#include <string.h>
-#include <asm/ptrace.h>
-#include <asm/sigcontext.h>
-#include "sysdep/ptrace.h"
-#include "kern_util.h"
-
-void sc_to_sc(void *to_ptr, void *from_ptr)
-{
-       struct sigcontext *to = to_ptr, *from = from_ptr;
-
-       memcpy(to, from, sizeof(*to) + sizeof(struct _fpstate));
-       if(from->fpstate != NULL)
-               to->fpstate = (struct _fpstate *) (to + 1);
-}
-
-unsigned long *sc_sigmask(void *sc_ptr)
-{
-       struct sigcontext *sc = sc_ptr;
-       return &sc->oldmask;
-}
-
-int sc_get_fpregs(unsigned long buf, void *sc_ptr)
-{
-       struct sigcontext *sc = sc_ptr;
-       struct _fpstate *from = sc->fpstate, *to = (struct _fpstate *) buf;
-       int err = 0;
-
-       if(from == NULL){
-               err |= clear_user_proc(&to->cw, sizeof(to->cw));
-               err |= clear_user_proc(&to->sw, sizeof(to->sw));
-               err |= clear_user_proc(&to->tag, sizeof(to->tag));
-               err |= clear_user_proc(&to->ipoff, sizeof(to->ipoff));
-               err |= clear_user_proc(&to->cssel, sizeof(to->cssel));
-               err |= clear_user_proc(&to->dataoff, sizeof(to->dataoff));
-               err |= clear_user_proc(&to->datasel, sizeof(to->datasel));
-               err |= clear_user_proc(&to->_st, sizeof(to->_st));
-       }
-       else {
-               err |= copy_to_user_proc(&to->cw, &from->cw, sizeof(to->cw));
-               err |= copy_to_user_proc(&to->sw, &from->sw, sizeof(to->sw));
-               err |= copy_to_user_proc(&to->tag, &from->tag, 
-                                        sizeof(to->tag));
-               err |= copy_to_user_proc(&to->ipoff, &from->ipoff, 
-                                        sizeof(to->ipoff));
-               err |= copy_to_user_proc(&to->cssel,& from->cssel, 
-                                        sizeof(to->cssel));
-               err |= copy_to_user_proc(&to->dataoff, &from->dataoff, 
-                                   sizeof(to->dataoff));
-               err |= copy_to_user_proc(&to->datasel, &from->datasel, 
-                                   sizeof(to->datasel));
-               err |= copy_to_user_proc(to->_st, from->_st, sizeof(to->_st));
-       }
-       return(err);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 1cbf95f..0147227 100644 (file)
 /*
- * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/signal.h"
 #include "linux/ptrace.h"
-#include "asm/current.h"
-#include "asm/ucontext.h"
-#include "asm/uaccess.h"
 #include "asm/unistd.h"
+#include "asm/uaccess.h"
+#include "asm/ucontext.h"
 #include "frame_kern.h"
-#include "sigcontext.h"
-#include "registers.h"
-#include "mode.h"
-
-#ifdef CONFIG_MODE_SKAS
-
 #include "skas.h"
 
-void copy_sc(union uml_pt_regs *regs, void *from)
+void copy_sc(struct uml_pt_regs *regs, void *from)
 {
        struct sigcontext *sc = from;
 
-       REGS_GS(regs->skas.regs) = sc->gs;
-       REGS_FS(regs->skas.regs) = sc->fs;
-       REGS_ES(regs->skas.regs) = sc->es;
-       REGS_DS(regs->skas.regs) = sc->ds;
-       REGS_EDI(regs->skas.regs) = sc->edi;
-       REGS_ESI(regs->skas.regs) = sc->esi;
-       REGS_EBP(regs->skas.regs) = sc->ebp;
-       REGS_SP(regs->skas.regs) = sc->esp;
-       REGS_EBX(regs->skas.regs) = sc->ebx;
-       REGS_EDX(regs->skas.regs) = sc->edx;
-       REGS_ECX(regs->skas.regs) = sc->ecx;
-       REGS_EAX(regs->skas.regs) = sc->eax;
-       REGS_IP(regs->skas.regs) = sc->eip;
-       REGS_CS(regs->skas.regs) = sc->cs;
-       REGS_EFLAGS(regs->skas.regs) = sc->eflags;
-       REGS_SS(regs->skas.regs) = sc->ss;
+       REGS_GS(regs->gp) = sc->gs;
+       REGS_FS(regs->gp) = sc->fs;
+       REGS_ES(regs->gp) = sc->es;
+       REGS_DS(regs->gp) = sc->ds;
+       REGS_EDI(regs->gp) = sc->edi;
+       REGS_ESI(regs->gp) = sc->esi;
+       REGS_EBP(regs->gp) = sc->ebp;
+       REGS_SP(regs->gp) = sc->esp;
+       REGS_EBX(regs->gp) = sc->ebx;
+       REGS_EDX(regs->gp) = sc->edx;
+       REGS_ECX(regs->gp) = sc->ecx;
+       REGS_EAX(regs->gp) = sc->eax;
+       REGS_IP(regs->gp) = sc->eip;
+       REGS_CS(regs->gp) = sc->cs;
+       REGS_EFLAGS(regs->gp) = sc->eflags;
+       REGS_SS(regs->gp) = sc->ss;
 }
 
-static int copy_sc_from_user_skas(struct pt_regs *regs,
-                                 struct sigcontext __user *from)
+/*
+ * FPU tag word conversions.
+ */
+
+static inline unsigned short twd_i387_to_fxsr(unsigned short twd)
 {
-       struct sigcontext sc;
-       unsigned long fpregs[HOST_FP_SIZE];
-       int err;
+       unsigned int tmp; /* to avoid 16 bit prefixes in the code */
+
+       /* Transform each pair of bits into 01 (valid) or 00 (empty) */
+       tmp = ~twd;
+       tmp = (tmp | (tmp>>1)) & 0x5555; /* 0V0V0V0V0V0V0V0V */
+       /* and move the valid bits to the lower byte. */
+       tmp = (tmp | (tmp >> 1)) & 0x3333; /* 00VV00VV00VV00VV */
+       tmp = (tmp | (tmp >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV */
+       tmp = (tmp | (tmp >> 4)) & 0x00ff; /* 00000000VVVVVVVV */
+       return tmp;
+}
 
-       err = copy_from_user(&sc, from, sizeof(sc));
-       err |= copy_from_user(fpregs, sc.fpstate, sizeof(fpregs));
-       if(err)
-               return err;
+static inline unsigned long twd_fxsr_to_i387(struct user_fxsr_struct *fxsave)
+{
+       struct _fpxreg *st = NULL;
+       unsigned long twd = (unsigned long) fxsave->twd;
+       unsigned long tag;
+       unsigned long ret = 0xffff0000;
+       int i;
+
+#define FPREG_ADDR(f, n)       ((char *)&(f)->st_space + (n) * 16);
+
+       for (i = 0; i < 8; i++) {
+               if (twd & 0x1) {
+                       st = (struct _fpxreg *) FPREG_ADDR(fxsave, i);
+
+                       switch (st->exponent & 0x7fff) {
+                       case 0x7fff:
+                               tag = 2;                /* Special */
+                               break;
+                       case 0x0000:
+                               if ( !st->significand[0] &&
+                                    !st->significand[1] &&
+                                    !st->significand[2] &&
+                                    !st->significand[3] ) {
+                                       tag = 1;        /* Zero */
+                               } else {
+                                       tag = 2;        /* Special */
+                               }
+                               break;
+                       default:
+                               if (st->significand[3] & 0x8000) {
+                                       tag = 0;        /* Valid */
+                               } else {
+                                       tag = 2;        /* Special */
+                               }
+                               break;
+                       }
+               } else {
+                       tag = 3;                        /* Empty */
+               }
+               ret |= (tag << (2 * i));
+               twd = twd >> 1;
+       }
+       return ret;
+}
 
-       copy_sc(&regs->regs, &sc);
+static int convert_fxsr_to_user(struct _fpstate __user *buf,
+                               struct user_fxsr_struct *fxsave)
+{
+       unsigned long env[7];
+       struct _fpreg __user *to;
+       struct _fpxreg *from;
+       int i;
+
+       env[0] = (unsigned long)fxsave->cwd | 0xffff0000ul;
+       env[1] = (unsigned long)fxsave->swd | 0xffff0000ul;
+       env[2] = twd_fxsr_to_i387(fxsave);
+       env[3] = fxsave->fip;
+       env[4] = fxsave->fcs | ((unsigned long)fxsave->fop << 16);
+       env[5] = fxsave->foo;
+       env[6] = fxsave->fos;
+
+       if (__copy_to_user(buf, env, 7 * sizeof(unsigned long)))
+               return 1;
 
-       err = restore_fp_registers(userspace_pid[0], fpregs);
-       if(err < 0) {
-               printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, "
-                      "errno = %d\n", -err);
-               return err;
-       }
+       to = &buf->_st[0];
+       from = (struct _fpxreg *) &fxsave->st_space[0];
+       for (i = 0; i < 8; i++, to++, from++) {
+               unsigned long __user *t = (unsigned long __user *)to;
+               unsigned long *f = (unsigned long *)from;
 
+               if (__put_user(*f, t) ||
+                               __put_user(*(f + 1), t + 1) ||
+                               __put_user(from->exponent, &to->exponent))
+                       return 1;
+       }
        return 0;
 }
 
-int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *to_fp,
-                         struct pt_regs *regs, unsigned long sp)
+static int convert_fxsr_from_user(struct user_fxsr_struct *fxsave,
+                                 struct _fpstate __user *buf)
 {
-       struct sigcontext sc;
-       unsigned long fpregs[HOST_FP_SIZE];
-       struct faultinfo * fi = &current->thread.arch.faultinfo;
-       int err;
+       unsigned long env[7];
+       struct _fpxreg *to;
+       struct _fpreg __user *from;
+       int i;
 
-       sc.gs = REGS_GS(regs->regs.skas.regs);
-       sc.fs = REGS_FS(regs->regs.skas.regs);
-       sc.es = REGS_ES(regs->regs.skas.regs);
-       sc.ds = REGS_DS(regs->regs.skas.regs);
-       sc.edi = REGS_EDI(regs->regs.skas.regs);
-       sc.esi = REGS_ESI(regs->regs.skas.regs);
-       sc.ebp = REGS_EBP(regs->regs.skas.regs);
-       sc.esp = sp;
-       sc.ebx = REGS_EBX(regs->regs.skas.regs);
-       sc.edx = REGS_EDX(regs->regs.skas.regs);
-       sc.ecx = REGS_ECX(regs->regs.skas.regs);
-       sc.eax = REGS_EAX(regs->regs.skas.regs);
-       sc.eip = REGS_IP(regs->regs.skas.regs);
-       sc.cs = REGS_CS(regs->regs.skas.regs);
-       sc.eflags = REGS_EFLAGS(regs->regs.skas.regs);
-       sc.esp_at_signal = regs->regs.skas.regs[UESP];
-       sc.ss = regs->regs.skas.regs[SS];
-        sc.cr2 = fi->cr2;
-        sc.err = fi->error_code;
-        sc.trapno = fi->trap_no;
-
-       err = save_fp_registers(userspace_pid[0], fpregs);
-       if(err < 0){
-               printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, "
-                      "errno = %d\n", err);
+       if (copy_from_user( env, buf, 7 * sizeof(long)))
                return 1;
-       }
-       to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1));
-       sc.fpstate = to_fp;
 
-       if(err)
-               return err;
-
-       return copy_to_user(to, &sc, sizeof(sc)) ||
-              copy_to_user(to_fp, fpregs, sizeof(fpregs));
+       fxsave->cwd = (unsigned short)(env[0] & 0xffff);
+       fxsave->swd = (unsigned short)(env[1] & 0xffff);
+       fxsave->twd = twd_i387_to_fxsr((unsigned short)(env[2] & 0xffff));
+       fxsave->fip = env[3];
+       fxsave->fop = (unsigned short)((env[4] & 0xffff0000ul) >> 16);
+       fxsave->fcs = (env[4] & 0xffff);
+       fxsave->foo = env[5];
+       fxsave->fos = env[6];
+
+       to = (struct _fpxreg *) &fxsave->st_space[0];
+       from = &buf->_st[0];
+       for (i = 0; i < 8; i++, to++, from++) {
+               unsigned long *t = (unsigned long *)to;
+               unsigned long __user *f = (unsigned long __user *)from;
+
+               if (__get_user(*t, f) ||
+                   __get_user(*(t + 1), f + 1) ||
+                   __get_user(to->exponent, &from->exponent))
+                       return 1;
+       }
+       return 0;
 }
-#endif
 
-#ifdef CONFIG_MODE_TT
+extern int have_fpx_regs;
 
-/* These copy a sigcontext to/from userspace.  They copy the fpstate pointer,
- * blowing away the old, good one.  So, that value is saved, and then restored
- * after the sigcontext copy.  In copy_from, the variable holding the saved
- * fpstate pointer, and the sigcontext that it should be restored to are both
- * in the kernel, so we can just restore using an assignment.  In copy_to, the
- * saved pointer is in the kernel, but the sigcontext is in userspace, so we
- * copy_to_user it.
- */
-int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from,
-                        int fpsize)
+static int copy_sc_from_user(struct pt_regs *regs,
+                            struct sigcontext __user *from)
 {
-       struct _fpstate *to_fp;
-       struct _fpstate __user *from_fp;
-       unsigned long sigs;
+       struct sigcontext sc;
        int err;
 
-       to_fp = to->fpstate;
-       sigs = to->oldmask;
-       err = copy_from_user(to, from, sizeof(*to));
-       from_fp = to->fpstate;
-       to->oldmask = sigs;
-       to->fpstate = to_fp;
-       if(to_fp != NULL)
-               err |= copy_from_user(to_fp, from_fp, fpsize);
-       return err;
+       err = copy_from_user(&sc, from, sizeof(sc));
+       if (err)
+               return err;
+
+       copy_sc(&regs->regs, &sc);
+       if (have_fpx_regs) {
+               struct user_fxsr_struct fpx;
+
+               err = copy_from_user(&fpx, &sc.fpstate->_fxsr_env[0],
+                                    sizeof(struct user_fxsr_struct));
+               if (err)
+                       return 1;
+
+               err = convert_fxsr_from_user(&fpx, sc.fpstate);
+               if (err)
+                       return 1;
+
+               err = restore_fpx_registers(userspace_pid[current_thread->cpu],
+                                           (unsigned long *) &fpx);
+               if (err < 0) {
+                       printk(KERN_ERR "copy_sc_from_user - "
+                              "restore_fpx_registers failed, errno = %d\n",
+                              -err);
+                       return 1;
+               }
+       }
+       else {
+               struct user_i387_struct fp;
+
+               err = copy_from_user(&fp, sc.fpstate,
+                                    sizeof(struct user_i387_struct));
+               if (err)
+                       return 1;
+
+               err = restore_fp_registers(userspace_pid[current_thread->cpu],
+                                          (unsigned long *) &fp);
+               if (err < 0) {
+                       printk(KERN_ERR "copy_sc_from_user - "
+                              "restore_fp_registers failed, errno = %d\n",
+                              -err);
+                       return 1;
+               }
+       }
+
+       return 0;
 }
 
-int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp,
-                      struct sigcontext *from, int fpsize, unsigned long sp)
+static int copy_sc_to_user(struct sigcontext __user *to,
+                          struct _fpstate __user *to_fp, struct pt_regs *regs,
+                          unsigned long sp)
 {
-       struct _fpstate __user *to_fp;
-       struct _fpstate *from_fp;
+       struct sigcontext sc;
+       struct faultinfo * fi = &current->thread.arch.faultinfo;
        int err;
 
-       to_fp = (fp ? fp : (struct _fpstate __user *) (to + 1));
-       from_fp = from->fpstate;
-       err = copy_to_user(to, from, sizeof(*to));
+       sc.gs = REGS_GS(regs->regs.gp);
+       sc.fs = REGS_FS(regs->regs.gp);
+       sc.es = REGS_ES(regs->regs.gp);
+       sc.ds = REGS_DS(regs->regs.gp);
+       sc.edi = REGS_EDI(regs->regs.gp);
+       sc.esi = REGS_ESI(regs->regs.gp);
+       sc.ebp = REGS_EBP(regs->regs.gp);
+       sc.esp = sp;
+       sc.ebx = REGS_EBX(regs->regs.gp);
+       sc.edx = REGS_EDX(regs->regs.gp);
+       sc.ecx = REGS_ECX(regs->regs.gp);
+       sc.eax = REGS_EAX(regs->regs.gp);
+       sc.eip = REGS_IP(regs->regs.gp);
+       sc.cs = REGS_CS(regs->regs.gp);
+       sc.eflags = REGS_EFLAGS(regs->regs.gp);
+       sc.esp_at_signal = regs->regs.gp[UESP];
+       sc.ss = regs->regs.gp[SS];
+       sc.cr2 = fi->cr2;
+       sc.err = fi->error_code;
+       sc.trapno = fi->trap_no;
 
-       /* The SP in the sigcontext is the updated one for the signal
-        * delivery.  The sp passed in is the original, and this needs
-        * to be restored, so we stick it in separately.
-        */
-       err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
+       to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1));
+       sc.fpstate = to_fp;
 
-       if(from_fp != NULL){
-               err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
-               err |= copy_to_user(to_fp, from_fp, fpsize);
+       if (have_fpx_regs) {
+               struct user_fxsr_struct fpx;
+
+               err = save_fpx_registers(userspace_pid[current_thread->cpu],
+                                        (unsigned long *) &fpx);
+               if (err < 0){
+                       printk(KERN_ERR "copy_sc_to_user - save_fpx_registers "
+                              "failed, errno = %d\n", err);
+                       return 1;
+               }
+
+               err = convert_fxsr_to_user(to_fp, &fpx);
+               if (err)
+                       return 1;
+
+               err |= __put_user(fpx.swd, &to_fp->status);
+               err |= __put_user(X86_FXSR_MAGIC, &to_fp->magic);
+               if (err)
+                       return 1;
+
+               if (copy_to_user(&to_fp->_fxsr_env[0], &fpx,
+                                sizeof(struct user_fxsr_struct)))
+                       return 1;
        }
-       return err;
-}
-#endif
-
-static int copy_sc_from_user(struct pt_regs *to, void __user *from)
-{
-       int ret;
+       else {
+               struct user_i387_struct fp;
 
-       ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from,
-                                              sizeof(struct _fpstate)),
-                         copy_sc_from_user_skas(to, from));
-       return ret;
-}
+               err = save_fp_registers(userspace_pid[current_thread->cpu],
+                                       (unsigned long *) &fp);
+               if (copy_to_user(to_fp, &fp, sizeof(struct user_i387_struct)))
+                       return 1;
+       }
 
-static int copy_sc_to_user(struct sigcontext __user *to, struct _fpstate __user *fp,
-                          struct pt_regs *from, unsigned long sp)
-{
-       return CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
-                                             sizeof(*fp), sp),
-                           copy_sc_to_user_skas(to, fp, from, sp));
+       return copy_to_user(to, &sc, sizeof(sc));
 }
 
-static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __user *fp,
-                                sigset_t *set, unsigned long sp)
+static int copy_ucontext_to_user(struct ucontext __user *uc,
+                                struct _fpstate __user *fp, sigset_t *set,
+                                unsigned long sp)
 {
        int err = 0;
 
@@ -233,7 +337,7 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
                return 1;
 
        restorer = frame->retcode;
-       if(ka->sa.sa_flags & SA_RESTORER)
+       if (ka->sa.sa_flags & SA_RESTORER)
                restorer = ka->sa.sa_restorer;
 
        /* Update SP now because the page fault handler refuses to extend
@@ -265,7 +369,7 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
        err |= __put_user(__NR_sigreturn, (int __user *)(frame->retcode+2));
        err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
 
-       if(err)
+       if (err)
                goto err;
 
        PT_REGS_SP(regs) = (unsigned long) frame;
@@ -298,7 +402,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
                return 1;
 
        restorer = frame->retcode;
-       if(ka->sa.sa_flags & SA_RESTORER)
+       if (ka->sa.sa_flags & SA_RESTORER)
                restorer = ka->sa.sa_restorer;
 
        /* See comment above about why this is here */
@@ -323,7 +427,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
        err |= __put_user(__NR_rt_sigreturn, (int __user *)(frame->retcode+1));
        err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
 
-       if(err)
+       if (err)
                goto err;
 
        PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
@@ -350,8 +454,8 @@ long sys_sigreturn(struct pt_regs regs)
        unsigned long __user *extramask = frame->extramask;
        int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
 
-       if(copy_from_user(&set.sig[0], oldmask, sizeof(set.sig[0])) ||
-          copy_from_user(&set.sig[1], extramask, sig_size))
+       if (copy_from_user(&set.sig[0], oldmask, sizeof(set.sig[0])) ||
+           copy_from_user(&set.sig[1], extramask, sig_size))
                goto segfault;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
@@ -361,7 +465,7 @@ long sys_sigreturn(struct pt_regs regs)
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
 
-       if(copy_sc_from_user(&current->thread.regs, sc))
+       if (copy_sc_from_user(&current->thread.regs, sc))
                goto segfault;
 
        /* Avoid ERESTART handling */
@@ -376,12 +480,13 @@ long sys_sigreturn(struct pt_regs regs)
 long sys_rt_sigreturn(struct pt_regs regs)
 {
        unsigned long sp = PT_REGS_SP(&current->thread.regs);
-       struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (sp - 4);
+       struct rt_sigframe __user *frame =
+               (struct rt_sigframe __user *) (sp - 4);
        sigset_t set;
        struct ucontext __user *uc = &frame->uc;
        int sig_size = _NSIG_WORDS * sizeof(unsigned long);
 
-       if(copy_from_user(&set, &uc->uc_sigmask, sig_size))
+       if (copy_from_user(&set, &uc->uc_sigmask, sig_size))
                goto segfault;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
@@ -391,7 +496,7 @@ long sys_rt_sigreturn(struct pt_regs regs)
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
 
-       if(copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext))
+       if (copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext))
                goto segfault;
 
        /* Avoid ERESTART handling */
index 6a70d9a..e730772 100644 (file)
@@ -1,4 +1,5 @@
 #include "uml-config.h"
+#include "as-layout.h"
 
        .globl syscall_stub
 .section .__syscall_stub, "x"
@@ -6,7 +7,7 @@
        .globl batch_syscall_stub
 batch_syscall_stub:
        /* load pointer to first operation */
-       mov     $(UML_CONFIG_STUB_DATA+8), %esp
+       mov     $(ASM_STUB_DATA+8), %esp
 
 again:
        /* load length of additional data */
@@ -14,12 +15,12 @@ again:
 
        /* if(length == 0) : end of list */
        /* write possible 0 to header */
-       mov     %eax, UML_CONFIG_STUB_DATA+4
+       mov     %eax, ASM_STUB_DATA+4
        cmpl    $0, %eax
        jz      done
 
        /* save current pointer */
-       mov     %esp, UML_CONFIG_STUB_DATA+4
+       mov     %esp, ASM_STUB_DATA+4
 
        /* skip additional data */
        add     %eax, %esp
@@ -45,7 +46,7 @@ again:
 
 done:
        /* save return value */
-       mov     %eax, UML_CONFIG_STUB_DATA
+       mov     %eax, ASM_STUB_DATA
 
        /* stop */
        int3
index 2355dc1..b3999cb 100644 (file)
@@ -6,6 +6,7 @@
 #include <signal.h>
 #include <sys/select.h> /* The only way I can see to get sigset_t */
 #include <asm/unistd.h>
+#include "as-layout.h"
 #include "uml-config.h"
 #include "sysdep/stub.h"
 #include "sysdep/sigcontext.h"
@@ -17,8 +18,7 @@ stub_segv_handler(int sig)
        struct sigcontext *sc = (struct sigcontext *) (&sig + 1);
        int pid;
 
-       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
-                             sc);
+       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), sc);
 
        pid = stub_syscall0(__NR_getpid);
        stub_syscall2(__NR_kill, pid, SIGUSR1);
index 2497554..12d4148 100644 (file)
@@ -9,4 +9,4 @@
 
 #define old_mmap old_mmap_i386
 
-#include "../../i386/kernel/syscall_table.S"
+#include "../../x86/kernel/syscall_table_32.S"
index 710d5fb..e2d1426 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "linux/sched.h"
 #include "linux/shm.h"
-#include "asm/ipc.h"
+#include "linux/ipc.h"
 #include "asm/mman.h"
 #include "asm/uaccess.h"
 #include "asm/unistd.h"
index fea8e5e..fcaff86 100644 (file)
@@ -3,25 +3,12 @@
  * Licensed under the GPL
  */
 
-#include "linux/kernel.h"
+#include "linux/percpu.h"
 #include "linux/sched.h"
-#include "linux/slab.h"
-#include "linux/types.h"
 #include "asm/uaccess.h"
-#include "asm/ptrace.h"
-#include "asm/segment.h"
-#include "asm/smp.h"
-#include "asm/desc.h"
-#include "choose-mode.h"
-#include "kern.h"
-#include "kern_util.h"
-#include "mode_kern.h"
 #include "os.h"
-#include "mode.h"
-
-#ifdef CONFIG_MODE_SKAS
 #include "skas.h"
-#endif
+#include "sysdep/tls.h"
 
 /*
  * If needed we can detect when it's uninitialized.
@@ -31,8 +18,7 @@
 static int host_supports_tls = -1;
 int host_gdt_entry_tls_min;
 
-#ifdef CONFIG_MODE_SKAS
-int do_set_thread_area_skas(struct user_desc *info)
+int do_set_thread_area(struct user_desc *info)
 {
        int ret;
        u32 cpu;
@@ -43,7 +29,7 @@ int do_set_thread_area_skas(struct user_desc *info)
        return ret;
 }
 
-int do_get_thread_area_skas(struct user_desc *info)
+int do_get_thread_area(struct user_desc *info)
 {
        int ret;
        u32 cpu;
@@ -53,14 +39,13 @@ int do_get_thread_area_skas(struct user_desc *info)
        put_cpu();
        return ret;
 }
-#endif
 
 /*
  * sys_get_thread_area: get a yet unused TLS descriptor index.
  * XXX: Consider leaving one free slot for glibc usage at first place. This must
  * be done here (and by changing GDT_ENTRY_TLS_* macros) and nowhere else.
  *
- * Also, this must be tested when compiling in SKAS mode with dinamic linking
+ * Also, this must be tested when compiling in SKAS mode with dynamic linking
  * and running against NPTL.
  */
 static int get_free_idx(struct task_struct* task)
@@ -82,7 +67,8 @@ static inline void clear_user_desc(struct user_desc* info)
        /* Postcondition: LDT_empty(info) returns true. */
        memset(info, 0, sizeof(*info));
 
-       /* Check the LDT_empty or the i386 sys_get_thread_area code - we obtain
+       /*
+        * Check the LDT_empty or the i386 sys_get_thread_area code - we obtain
         * indeed an empty user_desc.
         */
        info->read_exec_only = 1;
@@ -97,10 +83,13 @@ static int load_TLS(int flags, struct task_struct *to)
        int idx;
 
        for (idx = GDT_ENTRY_TLS_MIN; idx < GDT_ENTRY_TLS_MAX; idx++) {
-               struct uml_tls_struct* curr = &to->thread.arch.tls_array[idx - GDT_ENTRY_TLS_MIN];
+               struct uml_tls_struct* curr =
+                       &to->thread.arch.tls_array[idx - GDT_ENTRY_TLS_MIN];
 
-               /* Actually, now if it wasn't flushed it gets cleared and
-                * flushed to the host, which will clear it.*/
+               /*
+                * Actually, now if it wasn't flushed it gets cleared and
+                * flushed to the host, which will clear it.
+                */
                if (!curr->present) {
                        if (!curr->flushed) {
                                clear_user_desc(&curr->tls);
@@ -124,7 +113,8 @@ out:
        return ret;
 }
 
-/* Verify if we need to do a flush for the new process, i.e. if there are any
+/*
+ * Verify if we need to do a flush for the new process, i.e. if there are any
  * present desc's, only if they haven't been flushed.
  */
 static inline int needs_TLS_update(struct task_struct *task)
@@ -133,10 +123,13 @@ static inline int needs_TLS_update(struct task_struct *task)
        int ret = 0;
 
        for (i = GDT_ENTRY_TLS_MIN; i < GDT_ENTRY_TLS_MAX; i++) {
-               struct uml_tls_struct* curr = &task->thread.arch.tls_array[i - GDT_ENTRY_TLS_MIN];
+               struct uml_tls_struct* curr =
+                       &task->thread.arch.tls_array[i - GDT_ENTRY_TLS_MIN];
 
-               /* Can't test curr->present, we may need to clear a descriptor
-                * which had a value. */
+               /*
+                * Can't test curr->present, we may need to clear a descriptor
+                * which had a value.
+                */
                if (curr->flushed)
                        continue;
                ret = 1;
@@ -145,7 +138,8 @@ static inline int needs_TLS_update(struct task_struct *task)
        return ret;
 }
 
-/* On a newly forked process, the TLS descriptors haven't yet been flushed. So
+/*
+ * On a newly forked process, the TLS descriptors haven't yet been flushed. So
  * we mark them as such and the first switch_to will do the job.
  */
 void clear_flushed_tls(struct task_struct *task)
@@ -153,10 +147,13 @@ void clear_flushed_tls(struct task_struct *task)
        int i;
 
        for (i = GDT_ENTRY_TLS_MIN; i < GDT_ENTRY_TLS_MAX; i++) {
-               struct uml_tls_struct* curr = &task->thread.arch.tls_array[i - GDT_ENTRY_TLS_MIN];
+               struct uml_tls_struct* curr =
+                       &task->thread.arch.tls_array[i - GDT_ENTRY_TLS_MIN];
 
-               /* Still correct to do this, if it wasn't present on the host it
-                * will remain as flushed as it was. */
+               /*
+                * Still correct to do this, if it wasn't present on the host it
+                * will remain as flushed as it was.
+                */
                if (!curr->present)
                        continue;
 
@@ -164,40 +161,33 @@ void clear_flushed_tls(struct task_struct *task)
        }
 }
 
-/* In SKAS0 mode, currently, multiple guest threads sharing the same ->mm have a
+/*
+ * In SKAS0 mode, currently, multiple guest threads sharing the same ->mm have a
  * common host process. So this is needed in SKAS0 too.
  *
  * However, if each thread had a different host process (and this was discussed
  * for SMP support) this won't be needed.
  *
  * And this will not need be used when (and if) we'll add support to the host
- * SKAS patch. */
+ * SKAS patch.
+ */
 
-int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to)
+int arch_switch_tls(struct task_struct *from, struct task_struct *to)
 {
        if (!host_supports_tls)
                return 0;
 
-       /* We have no need whatsoever to switch TLS for kernel threads; beyond
+       /*
+        * We have no need whatsoever to switch TLS for kernel threads; beyond
         * that, that would also result in us calling os_set_thread_area with
-        * userspace_pid[cpu] == 0, which gives an error. */
+        * userspace_pid[cpu] == 0, which gives an error.
+        */
        if (likely(to->mm))
                return load_TLS(O_FORCE, to);
 
        return 0;
 }
 
-int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to)
-{
-       if (!host_supports_tls)
-               return 0;
-
-       if (needs_TLS_update(to))
-               return load_TLS(0, to);
-
-       return 0;
-}
-
 static int set_tls_entry(struct task_struct* task, struct user_desc *info,
                         int idx, int flushed)
 {
@@ -251,17 +241,20 @@ static int get_tls_entry(struct task_struct* task, struct user_desc *info, int i
        *info = t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].tls;
 
 out:
-       /* Temporary debugging check, to make sure that things have been
+       /*
+        * Temporary debugging check, to make sure that things have been
         * flushed. This could be triggered if load_TLS() failed.
         */
-       if (unlikely(task == current && !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
+       if (unlikely(task == current &&
+                    !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
                printk(KERN_ERR "get_tls_entry: task with pid %d got here "
                                "without flushed TLS.", current->pid);
        }
 
        return 0;
 clear:
-       /* When the TLS entry has not been set, the values read to user in the
+       /*
+        * When the TLS entry has not been set, the values read to user in the
         * tls_array are 0 (because it's cleared at boot, see
         * arch/i386/kernel/head.S:cpu_gdt_table). Emulate that.
         */
@@ -293,7 +286,7 @@ asmlinkage int sys_set_thread_area(struct user_desc __user *user_desc)
                        return -EFAULT;
        }
 
-       ret = CHOOSE_MODE_PROC(do_set_thread_area_tt, do_set_thread_area_skas, &info);
+       ret = do_set_thread_area(&info);
        if (ret)
                return ret;
        return set_tls_entry(current, &info, idx, 1);
@@ -363,8 +356,10 @@ out:
 }
 
 
-/* XXX: This part is probably common to i386 and x86-64. Don't create a common
- * file for now, do that when implementing x86-64 support.*/
+/*
+ * XXX: This part is probably common to i386 and x86-64. Don't create a common
+ * file for now, do that when implementing x86-64 support.
+ */
 static int __init __setup_host_supports_tls(void)
 {
        check_host_supports_tls(&host_supports_tls, &host_gdt_entry_tls_min);
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
deleted file mode 100644 (file)
index 1b0ad0e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <linux/mman.h>
-#include <asm/unistd.h>
-
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
-int switcheroo(int fd, int prot, void *from, void *to, int size)
-{
-       if(munmap(to, size) < 0){
-               return(-1);
-       }
-       if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
-               return(-1);
-       }
-       if(munmap(from, size) < 0){
-               return(-1);
-       }
-       return(0);
-}
index 29118cf..5142415 100644 (file)
@@ -2,9 +2,9 @@
 #include <stddef.h>
 #include <signal.h>
 #include <sys/poll.h>
+#include <sys/user.h>
 #include <sys/mman.h>
 #include <asm/ptrace.h>
-#include <asm/user.h>
 
 #define DEFINE(sym, val) \
        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -48,8 +48,8 @@ void foo(void)
        OFFSET(HOST_SC_FP_ST, _fpstate, _st);
        OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
 
-       DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
-       DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct));
+       DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
+       DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct));
 
        DEFINE(HOST_IP, EIP);
        DEFINE(HOST_SP, UESP);
index af20026..a9814a7 100644 (file)
@@ -1,7 +1,7 @@
 OBJ = built-in.o
 
 .S.o:
-       $(CC) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+       $(CC) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
 
 OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
        ptrace_user.o sysrq.o
@@ -57,13 +57,13 @@ ppc_defs.h: mk_defs.c ppc_defs.head \
 checksum.o: checksum.S
        rm -f asm
        ln -s $(TOPDIR)/include/asm-ppc asm
-       $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+       $(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
        rm -f asm
 
 misc.o: misc.S ppc_defs.h
        rm -f asm
        ln -s $(TOPDIR)/include/asm-ppc asm
-       $(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+       $(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
        rm -f asm
 
 clean-files := $(OBJS) ppc_defs.h checksum.S semaphore.c mk_defs.c
index 4d9e5ef..3c22de5 100644 (file)
@@ -5,27 +5,22 @@
 #
 
 obj-y = bug.o bugs.o delay.o fault.o ldt.o mem.o ptrace.o ptrace_user.o \
-       setjmp.o sigcontext.o signal.o syscalls.o syscall_table.o sysrq.o \
-       ksyms.o tls.o
+       setjmp.o signal.o stub.o stub_segv.o syscalls.o syscall_table.o \
+       sysrq.o ksyms.o tls.o
 
-obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
 obj-$(CONFIG_MODULES) += um_module.o
 
-subarch-obj-y = lib/bitops.o lib/csum-partial.o lib/memcpy.o lib/thunk.o
-subarch-obj-$(CONFIG_MODULES) += kernel/module.o
+subarch-obj-y = lib/bitops_64.o lib/csum-partial_64.o lib/memcpy_64.o lib/thunk_64.o
+subarch-obj-$(CONFIG_MODULES) += kernel/module_64.o
 
 ldt-y = ../sys-i386/ldt.o
 
-USER_OBJS := ptrace_user.o sigcontext.o
+USER_OBJS := ptrace_user.o
 
 USER_OBJS += user-offsets.s
 extra-y += user-offsets.s
 
-extra-$(CONFIG_MODE_TT) += unmap.o
-
 UNPROFILE_OBJS := stub_segv.o
 CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
 
 include arch/um/scripts/Makefile.rules
-
-$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))
index 200c8ba..a4360b5 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/uaccess.h>
 
 /* Mostly copied from i386/x86_86 - eliminated the eip < PAGE_OFFSET because
- * that's not relevent in skas mode.
+ * that's not relevant in skas mode.
  */
 
 int is_valid_bugaddr(unsigned long eip)
index 0954788..506b676 100644 (file)
@@ -14,7 +14,7 @@ void arch_check_bugs(void)
 {
 }
 
-int arch_handle_signal(int sig, union uml_pt_regs *regs)
+int arch_handle_signal(int sig, struct uml_pt_regs *regs)
 {
        return 0;
 }
index 4636b14..ce85117 100644 (file)
@@ -14,14 +14,15 @@ struct exception_table_entry
 };
 
 const struct exception_table_entry *search_exception_tables(unsigned long add);
-int arch_fixup(unsigned long address, union uml_pt_regs *regs)
+
+int arch_fixup(unsigned long address, struct uml_pt_regs *regs)
 {
        const struct exception_table_entry *fixup;
 
        fixup = search_exception_tables(address);
-       if(fixup != 0){
+       if (fixup != 0) {
                UPT_IP(regs) = fixup->fixup;
-               return(1);
+               return 1;
        }
-       return(0);
+       return 0;
 }
index 1970d78..b7631b0 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2003 PathScale, Inc.
+ * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  *
  * Licensed under the GPL
  */
 #include <asm/uaccess.h>
 #include <asm/elf.h>
 
-/* XXX x86_64 */
-unsigned long not_ss;
-unsigned long not_ds;
-unsigned long not_es;
-
-#define SC_SS(r) (not_ss)
-#define SC_DS(r) (not_ds)
-#define SC_ES(r) (not_es)
-
-/* determines which flags the user has access to. */
-/* 1 = access 0 = no access */
+/*
+ * determines which flags the user has access to.
+ * 1 = access 0 = no access
+ */
 #define FLAG_MASK 0x44dd5UL
 
 int putreg(struct task_struct *child, int regno, unsigned long value)
@@ -66,20 +60,21 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
 
 int poke_user(struct task_struct *child, long addr, long data)
 {
-        if ((addr & 3) || addr < 0)
-                return -EIO;
-
-        if (addr < MAX_REG_OFFSET)
-                return putreg(child, addr, data);
-        else if((addr >= offsetof(struct user, u_debugreg[0])) &&
-                (addr <= offsetof(struct user, u_debugreg[7]))){
-                addr -= offsetof(struct user, u_debugreg[0]);
-                addr = addr >> 2;
-                if((addr == 4) || (addr == 5)) return -EIO;
-                child->thread.arch.debugregs[addr] = data;
-                return 0;
-        }
-        return -EIO;
+       if ((addr & 3) || addr < 0)
+               return -EIO;
+
+       if (addr < MAX_REG_OFFSET)
+               return putreg(child, addr, data);
+       else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
+               (addr <= offsetof(struct user, u_debugreg[7]))){
+               addr -= offsetof(struct user, u_debugreg[0]);
+               addr = addr >> 2;
+               if ((addr == 4) || (addr == 5))
+                       return -EIO;
+               child->thread.arch.debugregs[addr] = data;
+               return 0;
+       }
+       return -EIO;
 }
 
 unsigned long getreg(struct task_struct *child, int regno)
@@ -107,29 +102,22 @@ unsigned long getreg(struct task_struct *child, int regno)
 int peek_user(struct task_struct *child, long addr, long data)
 {
        /* read the word at location addr in the USER area. */
-        unsigned long tmp;
-
-        if ((addr & 3) || addr < 0)
-                return -EIO;
-
-        tmp = 0;  /* Default return condition */
-        if(addr < MAX_REG_OFFSET){
-                tmp = getreg(child, addr);
-        }
-        else if((addr >= offsetof(struct user, u_debugreg[0])) &&
-                (addr <= offsetof(struct user, u_debugreg[7]))){
-                addr -= offsetof(struct user, u_debugreg[0]);
-                addr = addr >> 2;
-                tmp = child->thread.arch.debugregs[addr];
-        }
-        return put_user(tmp, (unsigned long *) data);
-}
+       unsigned long tmp;
 
-void arch_switch(void)
-{
-/* XXX
-       printk("arch_switch\n");
-*/
+       if ((addr & 3) || addr < 0)
+               return -EIO;
+
+       tmp = 0;  /* Default return condition */
+       if (addr < MAX_REG_OFFSET){
+               tmp = getreg(child, addr);
+       }
+       else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
+               (addr <= offsetof(struct user, u_debugreg[7]))){
+               addr -= offsetof(struct user, u_debugreg[0]);
+               addr = addr >> 2;
+               tmp = child->thread.arch.debugregs[addr];
+       }
+       return put_user(tmp, (unsigned long *) data);
 }
 
 /* XXX Mostly copied from sys-i386 */
@@ -139,54 +127,68 @@ int is_syscall(unsigned long addr)
        int n;
 
        n = copy_from_user(&instr, (void __user *) addr, sizeof(instr));
-       if(n){
+       if (n){
                /* access_process_vm() grants access to vsyscall and stub,
                 * while copy_from_user doesn't. Maybe access_process_vm is
                 * slow, but that doesn't matter, since it will be called only
                 * in case of singlestepping, if copy_from_user failed.
                 */
                n = access_process_vm(current, addr, &instr, sizeof(instr), 0);
-               if(n != sizeof(instr)) {
+               if (n != sizeof(instr)) {
                        printk("is_syscall : failed to read instruction from "
                               "0x%lx\n", addr);
-                       return(1);
+                       return 1;
                }
        }
        /* sysenter */
-       return(instr == 0x050f);
+       return instr == 0x050f;
 }
 
-int get_fpregs(unsigned long buf, struct task_struct *child)
+int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
-       panic("get_fpregs");
-       return(0);
-}
+       int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_FP_SIZE];
 
-int set_fpregs(unsigned long buf, struct task_struct *child)
-{
-       panic("set_fpregs");
-       return(0);
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       err = save_fp_registers(userspace_pid[cpu], fpregs);
+       if (err)
+               return err;
+
+       n = copy_to_user(buf, fpregs, sizeof(fpregs));
+       if(n > 0)
+               return -EFAULT;
+
+       return n;
 }
 
-int get_fpxregs(unsigned long buf, struct task_struct *tsk)
+int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
-       panic("get_fpxregs");
-       return(0);
+       int n, cpu = ((struct thread_info *) child->stack)->cpu;
+       long fpregs[HOST_FP_SIZE];
+
+       BUG_ON(sizeof(*buf) != sizeof(fpregs));
+       n = copy_from_user(fpregs, buf, sizeof(fpregs));
+       if (n > 0)
+               return -EFAULT;
+
+       return restore_fp_registers(userspace_pid[cpu], fpregs);
 }
 
-int set_fpxregs(unsigned long buf, struct task_struct *tsk)
+long subarch_ptrace(struct task_struct *child, long request, long addr,
+                   long data)
 {
-       panic("set_fxpregs");
-       return(0);
-}
+       int ret = -EIO;
 
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+       switch (request) {
+       case PTRACE_GETFPXREGS: /* Get the child FPU state. */
+               ret = get_fpregs((struct user_i387_struct __user *) data,
+                                child);
+               break;
+       case PTRACE_SETFPXREGS: /* Set the child FPU state. */
+               ret = set_fpregs((struct user_i387_struct __user *) data,
+                                child);
+               break;
+       }
+
+       return ret;
+}
diff --git a/arch/um/sys-x86_64/sigcontext.c b/arch/um/sys-x86_64/sigcontext.c
deleted file mode 100644 (file)
index c88e64d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2003 PathScale, Inc.
- *
- * Licensed under the GPL
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include "user.h"
-
-void sc_to_sc(void *to_ptr, void *from_ptr)
-{
-        struct sigcontext *to = to_ptr, *from = from_ptr;
-        int size = sizeof(*to); /* + sizeof(struct _fpstate); */
-
-        memcpy(to, from, size);
-        if(from->fpstate != NULL)
-               to->fpstate = (struct _fpstate *) (to + 1);
-
-       to->fpstate = NULL;
-}
-
-unsigned long *sc_sigmask(void *sc_ptr)
-{
-       struct sigcontext *sc = sc_ptr;
-
-       return(&sc->oldmask);
-}
-
-/* Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index fe8ec04..1778d33 100644 (file)
 /*
  * Copyright (C) 2003 PathScale, Inc.
+ * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
-#include "linux/stddef.h"
-#include "linux/errno.h"
 #include "linux/personality.h"
 #include "linux/ptrace.h"
-#include "asm/current.h"
+#include "asm/unistd.h"
 #include "asm/uaccess.h"
-#include "asm/sigcontext.h"
-#include "asm/ptrace.h"
-#include "asm/arch/ucontext.h"
-#include "choose-mode.h"
-#include "sysdep/ptrace.h"
+#include "asm/ucontext.h"
 #include "frame_kern.h"
-
-#ifdef CONFIG_MODE_SKAS
-
 #include "skas.h"
 
-void copy_sc(union uml_pt_regs *regs, void *from)
+void copy_sc(struct uml_pt_regs *regs, void *from)
 {
        struct sigcontext *sc = from;
 
-#define GETREG(regs, regno, sc, regname) \
-       (regs)->skas.regs[(regno) / sizeof(unsigned long)] = (sc)->regname
-
-       GETREG(regs, R8, sc, r8);
-       GETREG(regs, R9, sc, r9);
-       GETREG(regs, R10, sc, r10);
-       GETREG(regs, R11, sc, r11);
-       GETREG(regs, R12, sc, r12);
-       GETREG(regs, R13, sc, r13);
-       GETREG(regs, R14, sc, r14);
-       GETREG(regs, R15, sc, r15);
-       GETREG(regs, RDI, sc, rdi);
-       GETREG(regs, RSI, sc, rsi);
-       GETREG(regs, RBP, sc, rbp);
-       GETREG(regs, RBX, sc, rbx);
-       GETREG(regs, RDX, sc, rdx);
-       GETREG(regs, RAX, sc, rax);
-       GETREG(regs, RCX, sc, rcx);
-       GETREG(regs, RSP, sc, rsp);
-       GETREG(regs, RIP, sc, rip);
-       GETREG(regs, EFLAGS, sc, eflags);
-       GETREG(regs, CS, sc, cs);
+#define GETREG(regs, regno, sc, regname)                               \
+       (regs)->gp[(regno) / sizeof(unsigned long)] = (sc)->regname
+
+       GETREG(regs, R8, sc, r8);
+       GETREG(regs, R9, sc, r9);
+       GETREG(regs, R10, sc, r10);
+       GETREG(regs, R11, sc, r11);
+       GETREG(regs, R12, sc, r12);
+       GETREG(regs, R13, sc, r13);
+       GETREG(regs, R14, sc, r14);
+       GETREG(regs, R15, sc, r15);
+       GETREG(regs, RDI, sc, rdi);
+       GETREG(regs, RSI, sc, rsi);
+       GETREG(regs, RBP, sc, rbp);
+       GETREG(regs, RBX, sc, rbx);
+       GETREG(regs, RDX, sc, rdx);
+       GETREG(regs, RAX, sc, rax);
+       GETREG(regs, RCX, sc, rcx);
+       GETREG(regs, RSP, sc, rsp);
+       GETREG(regs, RIP, sc, rip);
+       GETREG(regs, EFLAGS, sc, eflags);
+       GETREG(regs, CS, sc, cs);
 
 #undef GETREG
 }
 
-static int copy_sc_from_user_skas(struct pt_regs *regs,
-                                 struct sigcontext __user *from)
+static int copy_sc_from_user(struct pt_regs *regs,
+                            struct sigcontext __user *from,
+                            struct _fpstate __user *fpp)
 {
-       int err = 0;
-
-#define GETREG(regs, regno, sc, regname) \
-       __get_user((regs)->regs.skas.regs[(regno) / sizeof(unsigned long)], \
-                  &(sc)->regname)
-
-       err |= GETREG(regs, R8, from, r8);
-       err |= GETREG(regs, R9, from, r9);
-       err |= GETREG(regs, R10, from, r10);
-       err |= GETREG(regs, R11, from, r11);
-       err |= GETREG(regs, R12, from, r12);
-       err |= GETREG(regs, R13, from, r13);
-       err |= GETREG(regs, R14, from, r14);
-       err |= GETREG(regs, R15, from, r15);
-       err |= GETREG(regs, RDI, from, rdi);
-       err |= GETREG(regs, RSI, from, rsi);
-       err |= GETREG(regs, RBP, from, rbp);
-       err |= GETREG(regs, RBX, from, rbx);
-       err |= GETREG(regs, RDX, from, rdx);
-       err |= GETREG(regs, RAX, from, rax);
-       err |= GETREG(regs, RCX, from, rcx);
-       err |= GETREG(regs, RSP, from, rsp);
-       err |= GETREG(regs, RIP, from, rip);
-       err |= GETREG(regs, EFLAGS, from, eflags);
-       err |= GETREG(regs, CS, from, cs);
+       struct user_i387_struct fp;
+       int err = 0;
+
+#define GETREG(regs, regno, sc, regname)                               \
+       __get_user((regs)->regs.gp[(regno) / sizeof(unsigned long)],    \
+                  &(sc)->regname)
+
+       err |= GETREG(regs, R8, from, r8);
+       err |= GETREG(regs, R9, from, r9);
+       err |= GETREG(regs, R10, from, r10);
+       err |= GETREG(regs, R11, from, r11);
+       err |= GETREG(regs, R12, from, r12);
+       err |= GETREG(regs, R13, from, r13);
+       err |= GETREG(regs, R14, from, r14);
+       err |= GETREG(regs, R15, from, r15);
+       err |= GETREG(regs, RDI, from, rdi);
+       err |= GETREG(regs, RSI, from, rsi);
+       err |= GETREG(regs, RBP, from, rbp);
+       err |= GETREG(regs, RBX, from, rbx);
+       err |= GETREG(regs, RDX, from, rdx);
+       err |= GETREG(regs, RAX, from, rax);
+       err |= GETREG(regs, RCX, from, rcx);
+       err |= GETREG(regs, RSP, from, rsp);
+       err |= GETREG(regs, RIP, from, rip);
+       err |= GETREG(regs, EFLAGS, from, eflags);
+       err |= GETREG(regs, CS, from, cs);
+       if (err)
+               return 1;
 
 #undef GETREG
 
-       return err;
+       err = copy_from_user(&fp, fpp, sizeof(struct user_i387_struct));
+       if (err)
+               return 1;
+
+       err = restore_fp_registers(userspace_pid[current_thread->cpu],
+                                  (unsigned long *) &fp);
+       if (err < 0) {
+               printk(KERN_ERR "copy_sc_from_user - "
+                      "restore_fp_registers failed, errno = %d\n",
+                      -err);
+               return 1;
+       }
+
+       return 0;
 }
 
-int copy_sc_to_user_skas(struct sigcontext __user *to,
-                        struct _fpstate __user *to_fp,
-                        struct pt_regs *regs, unsigned long mask,
-                        unsigned long sp)
+static int copy_sc_to_user(struct sigcontext __user *to,
+                          struct _fpstate __user *to_fp, struct pt_regs *regs,
+                          unsigned long mask, unsigned long sp)
 {
-        struct faultinfo * fi = &current->thread.arch.faultinfo;
+       struct faultinfo * fi = &current->thread.arch.faultinfo;
+       struct user_i387_struct fp;
        int err = 0;
 
        err |= __put_user(0, &to->gs);
        err |= __put_user(0, &to->fs);
 
-#define PUTREG(regs, regno, sc, regname) \
-       __put_user((regs)->regs.skas.regs[(regno) / sizeof(unsigned long)], \
-                  &(sc)->regname)
+#define PUTREG(regs, regno, sc, regname)                               \
+       __put_user((regs)->regs.gp[(regno) / sizeof(unsigned long)],    \
+                  &(sc)->regname)
 
        err |= PUTREG(regs, RDI, to, rdi);
        err |= PUTREG(regs, RSI, to, rsi);
        err |= PUTREG(regs, RBP, to, rbp);
-        /* Must use orignal RSP, which is passed in, rather than what's in
-         * the pt_regs, because that's already been updated to point at the
-         * signal frame.
-         */
+       /*
+        * Must use orignal RSP, which is passed in, rather than what's in
+        * the pt_regs, because that's already been updated to point at the
+        * signal frame.
+        */
        err |= __put_user(sp, &to->rsp);
        err |= PUTREG(regs, RBX, to, rbx);
        err |= PUTREG(regs, RDX, to, rdx);
@@ -121,91 +131,38 @@ int copy_sc_to_user_skas(struct sigcontext __user *to,
        err |= PUTREG(regs, R15, to, r15);
        err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */
 
-        err |= __put_user(fi->cr2, &to->cr2);
-        err |= __put_user(fi->error_code, &to->err);
-        err |= __put_user(fi->trap_no, &to->trapno);
+       err |= __put_user(fi->cr2, &to->cr2);
+       err |= __put_user(fi->error_code, &to->err);
+       err |= __put_user(fi->trap_no, &to->trapno);
 
        err |= PUTREG(regs, RIP, to, rip);
        err |= PUTREG(regs, EFLAGS, to, eflags);
 #undef PUTREG
 
        err |= __put_user(mask, &to->oldmask);
-
-       return(err);
-}
-
-#endif
-
-#ifdef CONFIG_MODE_TT
-int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from,
-                        int fpsize)
-{
-       struct _fpstate *to_fp;
-       struct _fpstate __user *from_fp;
-       unsigned long sigs;
-       int err;
-
-       to_fp = to->fpstate;
-       sigs = to->oldmask;
-       err = copy_from_user(to, from, sizeof(*to));
-       from_fp = to->fpstate;
-       to->fpstate = to_fp;
-       to->oldmask = sigs;
-       if(to_fp != NULL)
-               err |= copy_from_user(to_fp, from_fp, fpsize);
-       return(err);
-}
-
-int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp,
-                      struct sigcontext *from, int fpsize, unsigned long sp)
-{
-       struct _fpstate __user *to_fp;
-       struct _fpstate *from_fp;
-       int err;
-
-       to_fp = (fp ? fp : (struct _fpstate __user *) (to + 1));
-       from_fp = from->fpstate;
-       err = copy_to_user(to, from, sizeof(*to));
-       /* The SP in the sigcontext is the updated one for the signal
-        * delivery.  The sp passed in is the original, and this needs
-        * to be restored, so we stick it in separately.
-        */
-       err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
-
-       if(from_fp != NULL){
-               err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
-               err |= copy_to_user(to_fp, from_fp, fpsize);
+       if (err)
+               return 1;
+
+       err = save_fp_registers(userspace_pid[current_thread->cpu],
+                               (unsigned long *) &fp);
+       if (err < 0) {
+               printk(KERN_ERR "copy_sc_from_user - restore_fp_registers "
+                      "failed, errno = %d\n", -err);
+               return 1;
        }
-       return err;
-}
 
-#endif
-
-static int copy_sc_from_user(struct pt_regs *to, void __user *from)
-{
-       int ret;
-
-       ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from,
-                                              sizeof(struct _fpstate)),
-                         copy_sc_from_user_skas(to, from));
-       return(ret);
-}
+       if (copy_to_user(to_fp, &fp, sizeof(struct user_i387_struct)))
+               return 1;
 
-static int copy_sc_to_user(struct sigcontext __user *to,
-                          struct _fpstate __user *fp,
-                          struct pt_regs *from, unsigned long mask,
-                          unsigned long sp)
-{
-       return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
-                                             sizeof(*fp), sp),
-                          copy_sc_to_user_skas(to, fp, from, mask, sp)));
+       return err;
 }
 
 struct rt_sigframe
 {
-       char __user *pretcode;
-       struct ucontext uc;
-       struct siginfo info;
+       char __user *pretcode;
+       struct ucontext uc;
+       struct siginfo info;
+       struct _fpstate fpstate;
 };
 
 #define round_down(m, n) (((m) / (n)) * (n))
@@ -215,7 +172,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
                          siginfo_t *info, sigset_t *set)
 {
        struct rt_sigframe __user *frame;
-       struct _fpstate __user *fp = NULL;
        unsigned long save_sp = PT_REGS_RSP(regs);
        int err = 0;
        struct task_struct *me = current;
@@ -223,15 +179,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
        frame = (struct rt_sigframe __user *)
                round_down(stack_top - sizeof(struct rt_sigframe), 16);
        /* Subtract 128 for a red zone and 8 for proper alignment */
-        frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);
-
-       if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
-               goto out;
+       frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);
 
-#if 0 /* XXX */
-       if (save_i387(fp) < 0)
-               err |= -1;
-#endif
        if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
                goto out;
 
@@ -241,7 +190,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
                        goto out;
        }
 
-       /* Update SP now because the page fault handler refuses to extend
+       /*
+        * Update SP now because the page fault handler refuses to extend
         * the stack if the faulting address is too far below the current
         * SP, which frame now certainly is.  If there's an error, the original
         * value is restored on the way out.
@@ -258,9 +208,9 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
        err |= __put_user(sas_ss_flags(save_sp),
                          &frame->uc.uc_stack.ss_flags);
        err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
-       err |= copy_sc_to_user(&frame->uc.uc_mcontext, fp, regs, set->sig[0],
-               save_sp);
-       err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate);
+       err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,
+                              set->sig[0], save_sp);
+       err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);
        if (sizeof(*set) == 16) {
                __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
                __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]);
@@ -269,8 +219,10 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
                err |= __copy_to_user(&frame->uc.uc_sigmask, set,
                                      sizeof(*set));
 
-       /* Set up to return from userspace.  If provided, use a stub
-          already in userspace.  */
+       /*
+        * Set up to return from userspace.  If provided, use a stub
+        * already in userspace.
+        */
        /* x86-64 should always use SA_RESTORER. */
        if (ka->sa.sa_flags & SA_RESTORER)
                err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
@@ -292,8 +244,10 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
        /* In case the signal handler was declared without prototypes */
        PT_REGS_RAX(regs) = 0;
 
-       /* This also works for non SA_SIGINFO handlers because they expect the
-          next argument after the signal number on the stack. */
+       /*
+        * This also works for non SA_SIGINFO handlers because they expect the
+        * next argument after the signal number on the stack.
+        */
        PT_REGS_RSI(regs) = (unsigned long) &frame->info;
        PT_REGS_RDX(regs) = (unsigned long) &frame->uc;
        PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler;
@@ -313,7 +267,7 @@ long sys_rt_sigreturn(struct pt_regs *regs)
        struct ucontext __user *uc = &frame->uc;
        sigset_t set;
 
-       if(copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
+       if (copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
                goto segfault;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
@@ -323,24 +277,15 @@ long sys_rt_sigreturn(struct pt_regs *regs)
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
 
-       if(copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext))
+       if (copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext,
+                             &frame->fpstate))
                goto segfault;
 
        /* Avoid ERESTART handling */
        PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
-       return(PT_REGS_SYSCALL_RET(&current->thread.regs));
+       return PT_REGS_SYSCALL_RET(&current->thread.regs);
 
  segfault:
        force_sig(SIGSEGV, current);
        return 0;
 }
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 03c2797..4afe204 100644 (file)
@@ -1,4 +1,5 @@
 #include "uml-config.h"
+#include "as-layout.h"
 
        .globl syscall_stub
 .section .__syscall_stub, "x"
@@ -7,18 +8,18 @@ syscall_stub:
        /* We don't have 64-bit constants, so this constructs the address
         * we need.
         */
-       movq    $(UML_CONFIG_STUB_DATA >> 32), %rbx
+       movq    $(ASM_STUB_DATA >> 32), %rbx
        salq    $32, %rbx
-       movq    $(UML_CONFIG_STUB_DATA & 0xffffffff), %rcx
+       movq    $(ASM_STUB_DATA & 0xffffffff), %rcx
        or      %rcx, %rbx
        movq    %rax, (%rbx)
        int3
 
        .globl batch_syscall_stub
 batch_syscall_stub:
-       mov     $(UML_CONFIG_STUB_DATA >> 32), %rbx
+       mov     $(ASM_STUB_DATA >> 32), %rbx
        sal     $32, %rbx
-       mov     $(UML_CONFIG_STUB_DATA & 0xffffffff), %rax
+       mov     $(ASM_STUB_DATA & 0xffffffff), %rax
        or      %rax, %rbx
        /* load pointer to first operation */
        mov     %rbx, %rsp
index 652fa34..3afb590 100644 (file)
@@ -6,6 +6,7 @@
 #include <stddef.h>
 #include <signal.h>
 #include <asm/unistd.h>
+#include "as-layout.h"
 #include "uml-config.h"
 #include "sysdep/sigcontext.h"
 #include "sysdep/faultinfo.h"
@@ -33,7 +34,7 @@ stub_segv_handler(int sig)
         int pid;
 
        __asm__ __volatile__("movq %%rdx, %0" : "=g" (uc) :);
-       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
+       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA),
                              &uc->uc_mcontext);
 
        pid = stub_syscall0(__NR_getpid);
index 5133988..71b2ae4 100644 (file)
@@ -36,7 +36,7 @@
 
 #define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
 #undef _ASM_X86_64_UNISTD_H_
-#include <asm-x86_64/unistd.h>
+#include <asm-x86/unistd_64.h>
 
 #undef __SYSCALL
 #define __SYSCALL(nr, sym) [ nr ] = sym,
@@ -49,5 +49,5 @@ extern void sys_ni_syscall(void);
 sys_call_ptr_t sys_call_table[UM_NR_syscall_max+1] __cacheline_aligned = {
        /* Smells like a like a compiler bug -- it doesn't work when the & below is removed. */
        [0 ... UM_NR_syscall_max] = &sys_ni_syscall,
-#include <asm-x86_64/unistd.h>
+#include <asm-x86/unistd_64.h>
 };
index b3f6350..86f6b18 100644 (file)
@@ -1,70 +1,36 @@
 /*
+ * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Copyright 2003 PathScale, Inc.
  *
  * Licensed under the GPL
  */
 
 #include "linux/linkage.h"
-#include "linux/slab.h"
-#include "linux/shm.h"
-#include "linux/utsname.h"
 #include "linux/personality.h"
-#include "asm/uaccess.h"
-#define __FRAME_OFFSETS
-#include "asm/ptrace.h"
-#include "asm/unistd.h"
+#include "linux/utsname.h"
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
-#include "choose-mode.h"
-#include "kern.h"
+#include "asm/uaccess.h"
 #include "os.h"
 
 asmlinkage long sys_uname64(struct new_utsname __user * name)
 {
        int err;
+
        down_read(&uts_sem);
        err = copy_to_user(name, utsname(), sizeof (*name));
        up_read(&uts_sem);
+
        if (personality(current->personality) == PER_LINUX32)
                err |= copy_to_user(&name->machine, "i686", 5);
-       return err ? -EFAULT : 0;
-}
-
-#ifdef CONFIG_MODE_TT
-extern long arch_prctl(int code, unsigned long addr);
-
-static long arch_prctl_tt(int code, unsigned long addr)
-{
-       unsigned long tmp;
-       long ret;
-
-       switch(code){
-       case ARCH_SET_GS:
-       case ARCH_SET_FS:
-               ret = arch_prctl(code, addr);
-               break;
-       case ARCH_GET_FS:
-       case ARCH_GET_GS:
-               ret = arch_prctl(code, (unsigned long) &tmp);
-               if(!ret)
-                       ret = put_user(tmp, (long __user *)addr);
-               break;
-       default:
-               ret = -EINVAL;
-               break;
-       }
 
-       return(ret);
+       return err ? -EFAULT : 0;
 }
-#endif
-
-#ifdef CONFIG_MODE_SKAS
 
-long arch_prctl_skas(struct task_struct *task, int code,
-                     unsigned long __user *addr)
+long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr)
 {
-        unsigned long *ptr = addr, tmp;
+       unsigned long *ptr = addr, tmp;
        long ret;
-       int pid = task->mm->context.skas.id.u.pid;
+       int pid = task->mm->context.id.u.pid;
 
        /*
         * With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to
@@ -79,52 +45,50 @@ long arch_prctl_skas(struct task_struct *task, int code,
         * arch_prctl is run on the host, then the registers are read
         * back.
         */
-       switch(code){
+       switch (code) {
        case ARCH_SET_FS:
        case ARCH_SET_GS:
-                restore_registers(pid, &current->thread.regs.regs);
-                break;
-        case ARCH_GET_FS:
-        case ARCH_GET_GS:
-                /*
-                 * With these two, we read to a local pointer and
-                 * put_user it to the userspace pointer that we were
-                 * given.  If addr isn't valid (because it hasn't been
-                 * faulted in or is just bogus), we want put_user to
-                 * fault it in (or return -EFAULT) instead of having
-                 * the host return -EFAULT.
-                 */
-                ptr = &tmp;
-        }
+               restore_registers(pid, &current->thread.regs.regs);
+               break;
+       case ARCH_GET_FS:
+       case ARCH_GET_GS:
+               /*
+                * With these two, we read to a local pointer and
+                * put_user it to the userspace pointer that we were
+                * given.  If addr isn't valid (because it hasn't been
+                * faulted in or is just bogus), we want put_user to
+                * fault it in (or return -EFAULT) instead of having
+                * the host return -EFAULT.
+                */
+               ptr = &tmp;
+       }
 
-        ret = os_arch_prctl(pid, code, ptr);
-        if(ret)
-                return ret;
+       ret = os_arch_prctl(pid, code, ptr);
+       if (ret)
+               return ret;
 
-        switch(code){
+       switch (code) {
        case ARCH_SET_FS:
                current->thread.arch.fs = (unsigned long) ptr;
                save_registers(pid, &current->thread.regs.regs);
                break;
        case ARCH_SET_GS:
-                save_registers(pid, &current->thread.regs.regs);
+               save_registers(pid, &current->thread.regs.regs);
                break;
        case ARCH_GET_FS:
                ret = put_user(tmp, addr);
-               break;
+               break;
        case ARCH_GET_GS:
                ret = put_user(tmp, addr);
-               break;
+               break;
        }
 
        return ret;
 }
-#endif
 
 long sys_arch_prctl(int code, unsigned long addr)
 {
-       return CHOOSE_MODE_PROC(arch_prctl_tt, arch_prctl_skas, current, code,
-                                (unsigned long __user *) addr);
+       return arch_prctl(current, code, (unsigned long __user *) addr);
 }
 
 long sys_clone(unsigned long clone_flags, unsigned long newsp,
@@ -141,10 +105,10 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp,
        return ret;
 }
 
-void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
+void arch_switch_to(struct task_struct *from, struct task_struct *to)
 {
-        if((to->thread.arch.fs == 0) || (to->mm == NULL))
-                return;
+       if ((to->thread.arch.fs == 0) || (to->mm == NULL))
+               return;
 
-        arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
+       arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
 }
index ce3e07f..7654440 100644 (file)
@@ -15,8 +15,8 @@ void __show_regs(struct pt_regs * regs)
 {
        printk("\n");
        print_modules();
-       printk("Pid: %d, comm: %.20s %s %s\n",
-              current->pid, current->comm, print_tainted(), init_utsname()->release);
+       printk("Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current),
+               current->comm, print_tainted(), init_utsname()->release);
        printk("RIP: %04lx:[<%016lx>] ", PT_REGS_CS(regs) & 0xffff,
               PT_REGS_RIP(regs));
        printk("\nRSP: %016lx  EFLAGS: %08lx\n", PT_REGS_RSP(regs),
index febbc94..f7ba462 100644 (file)
@@ -11,7 +11,7 @@ int arch_copy_tls(struct task_struct *t)
         * (which is argument 5, child_tid, of clone) so it can be set
         * during context switches.
         */
-       t->thread.arch.fs = t->thread.regs.regs.skas.regs[R8 / sizeof(long)];
+       t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)];
 
-        return 0;
+       return 0;
 }
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c
deleted file mode 100644 (file)
index f4a4bff..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <linux/mman.h>
-#include <asm/unistd.h>
-
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
-int switcheroo(int fd, int prot, void *from, void *to, int size)
-{
-       if(munmap(to, size) < 0){
-               return(-1);
-       }
-       if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
-               return(-1);
-       }
-       if(munmap(from, size) < 0){
-               return(-1);
-       }
-       return(0);
-}
index 0d5fd76..f1ef2a8 100644 (file)
@@ -3,17 +3,10 @@
 #include <signal.h>
 #include <sys/poll.h>
 #include <sys/mman.h>
+#include <sys/user.h>
 #define __FRAME_OFFSETS
 #include <asm/ptrace.h>
 #include <asm/types.h>
-/* For some reason, x86_64 defines u64 and u32 only in <pci/types.h>, which I
- * refuse to include here, even though they're used throughout the headers.
- * These are used in asm/user.h, and that include can't be avoided because of
- * the sizeof(struct user_regs_struct) below.
- */
-typedef __u64 u64;
-typedef __u32 u32;
-#include <asm/user.h>
 
 #define DEFINE(sym, val) \
         asm volatile("\n->" #sym " %0 " #val : : "i" (val))
diff --git a/arch/x86/boot/.gitignore b/arch/x86/boot/.gitignore
new file mode 100644 (file)
index 0000000..1846514
--- /dev/null
@@ -0,0 +1,5 @@
+bootsect
+bzImage
+setup
+setup.bin
+setup.elf
diff --git a/arch/x86/boot/compressed/.gitignore b/arch/x86/boot/compressed/.gitignore
new file mode 100644 (file)
index 0000000..be0ed06
--- /dev/null
@@ -0,0 +1 @@
+relocs
diff --git a/arch/x86/boot/tools/.gitignore b/arch/x86/boot/tools/.gitignore
new file mode 100644 (file)
index 0000000..378eac2
--- /dev/null
@@ -0,0 +1 @@
+build
diff --git a/arch/x86/ia32/vsyscall.lds b/arch/x86/ia32/vsyscall.lds
new file mode 100644 (file)
index 0000000..1dc86ff
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Linker script for vsyscall DSO.  The vsyscall page is an ELF shared
+ * object prelinked to its virtual address. This script controls its layout.
+ */
+
+/* This must match <asm/fixmap.h>.  */
+VSYSCALL_BASE = 0xffffe000;
+
+SECTIONS
+{
+  . = VSYSCALL_BASE + SIZEOF_HEADERS;
+
+  .hash           : { *(.hash) }               :text
+  .gnu.hash       : { *(.gnu.hash) }
+  .dynsym         : { *(.dynsym) }
+  .dynstr         : { *(.dynstr) }
+  .gnu.version    : { *(.gnu.version) }
+  .gnu.version_d  : { *(.gnu.version_d) }
+  .gnu.version_r  : { *(.gnu.version_r) }
+
+  /* This linker script is used both with -r and with -shared.
+     For the layouts to match, we need to skip more than enough
+     space for the dynamic symbol table et al.  If this amount
+     is insufficient, ld -shared will barf.  Just increase it here.  */
+  . = VSYSCALL_BASE + 0x400;
+  
+  .text.vsyscall   : { *(.text.vsyscall) }     :text =0x90909090
+
+  /* This is an 32bit object and we cannot easily get the offsets
+     into the 64bit kernel. Just hardcode them here. This assumes
+     that all the stubs don't need more than 0x100 bytes. */
+  . = VSYSCALL_BASE + 0x500;
+
+  .text.sigreturn  : { *(.text.sigreturn) }    :text =0x90909090
+
+  . = VSYSCALL_BASE + 0x600;
+
+  .text.rtsigreturn : { *(.text.rtsigreturn) }   :text =0x90909090
+       
+  .note                  : { *(.note.*) }              :text :note
+  .eh_frame_hdr   : { *(.eh_frame_hdr) }       :text :eh_frame_hdr
+  .eh_frame       : { KEEP (*(.eh_frame)) }    :text
+  .dynamic        : { *(.dynamic) }            :text :dynamic
+  .useless        : {
+       *(.got.plt) *(.got)
+       *(.data .data.* .gnu.linkonce.d.*)
+       *(.dynbss)
+       *(.bss .bss.* .gnu.linkonce.b.*)
+  }                                            :text
+}
+
+/*
+ * We must supply the ELF program headers explicitly to get just one
+ * PT_LOAD segment, and set the flags explicitly to make segments read-only.
+ */
+PHDRS
+{
+  text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
+  dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
+  note PT_NOTE FLAGS(4); /* PF_R */
+  eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
+}
+
+/*
+ * This controls what symbols we export from the DSO.
+ */
+VERSION
+{
+  LINUX_2.5 {
+    global:
+       __kernel_vsyscall;
+       __kernel_sigreturn;
+       __kernel_rt_sigreturn;
+
+    local: *;
+  };
+}
+
+/* The ELF entry point can be used to set the AT_SYSINFO value.  */
+ENTRY(__kernel_vsyscall);
diff --git a/arch/x86/kernel/.gitignore b/arch/x86/kernel/.gitignore
new file mode 100644 (file)
index 0000000..4ea38a3
--- /dev/null
@@ -0,0 +1,2 @@
+vsyscall.lds
+vsyscall_32.lds
diff --git a/arch/x86/math-emu/version.h b/arch/x86/math-emu/version.h
new file mode 100644 (file)
index 0000000..a0d73a1
--- /dev/null
@@ -0,0 +1,12 @@
+/*---------------------------------------------------------------------------+
+ |  version.h                                                                |
+ |                                                                           |
+ |                                                                           |
+ | Copyright (C) 1992,1993,1994,1996,1997,1999                               |
+ |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
+ |                  E-mail   billm@melbpc.org.au                             |
+ |                                                                           |
+ |                                                                           |
+ +---------------------------------------------------------------------------*/
+
+#define FPU_VERSION "wm-FPU-emu version 2.01"
diff --git a/arch/x86/vdso/.gitignore b/arch/x86/vdso/.gitignore
new file mode 100644 (file)
index 0000000..f8b69d8
--- /dev/null
@@ -0,0 +1 @@
+vdso.lds
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
deleted file mode 100644 (file)
index b4d9089..0000000
+++ /dev/null
@@ -1,800 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see Documentation/kbuild/kconfig-language.txt.
-#
-# Note: ISA is disabled and will hopefully never be enabled.
-# If you managed to buy an ISA x86-64 box you'll have to fix all the
-# ISA drivers you need yourself.
-#
-
-mainmenu "Linux Kernel Configuration"
-
-config X86_64
-       bool
-       default y
-       help
-         Port to the x86-64 architecture. x86-64 is a 64-bit extension to the
-         classical 32-bit x86 architecture. For details see
-         <http://www.x86-64.org/>.
-
-config 64BIT
-       def_bool y
-
-config X86
-       bool
-       default y
-
-config GENERIC_TIME
-       bool
-       default y
-
-config GENERIC_TIME_VSYSCALL
-       bool
-       default y
-
-config GENERIC_CMOS_UPDATE
-       bool
-       default y
-
-config ZONE_DMA32
-       bool
-       default y
-
-config LOCKDEP_SUPPORT
-       bool
-       default y
-
-config STACKTRACE_SUPPORT
-       bool
-       default y
-
-config SEMAPHORE_SLEEPERS
-       bool
-       default y
-
-config MMU
-       bool
-       default y
-
-config ZONE_DMA
-       bool
-       default y
-
-config ISA
-       bool
-
-config SBUS
-       bool
-
-config RWSEM_GENERIC_SPINLOCK
-       bool
-       default y
-
-config RWSEM_XCHGADD_ALGORITHM
-       bool
-
-config GENERIC_HWEIGHT
-       bool
-       default y
-
-config GENERIC_CALIBRATE_DELAY
-       bool
-       default y
-
-config X86_CMPXCHG
-       bool
-       default y
-
-config EARLY_PRINTK
-       bool
-       default y
-
-config GENERIC_ISA_DMA
-       bool
-       default y
-
-config GENERIC_IOMAP
-       bool
-       default y
-
-config ARCH_MAY_HAVE_PC_FDC
-       bool
-       default y
-
-config ARCH_POPULATES_NODE_MAP
-       def_bool y
-
-config DMI
-       bool
-       default y
-
-config AUDIT_ARCH
-       bool
-       default y
-
-config GENERIC_BUG
-       bool
-       default y
-       depends on BUG
-
-config ARCH_HAS_ILOG2_U32
-       bool
-       default n
-
-config ARCH_HAS_ILOG2_U64
-       bool
-       default n
-
-source "init/Kconfig"
-
-
-menu "Processor type and features"
-
-choice
-       prompt "Subarchitecture Type"
-       default X86_PC
-
-config X86_PC
-       bool "PC-compatible"
-       help
-         Choose this option if your computer is a standard PC or compatible.
-
-config X86_VSMP
-       bool "Support for ScaleMP vSMP"
-       depends on PCI
-        help
-         Support for ScaleMP vSMP systems.  Say 'Y' here if this kernel is
-         supposed to run on these EM64T-based machines.  Only choose this option
-         if you have one of these machines.
-
-endchoice
-
-choice
-       prompt "Processor family"
-       default GENERIC_CPU
-
-config MK8
-       bool "AMD-Opteron/Athlon64"
-       help
-         Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs.
-
-config MPSC
-       bool "Intel P4 / older Netburst based Xeon"
-       help
-         Optimize for Intel Pentium 4 and older Nocona/Dempsey Xeon CPUs
-         with Intel Extended Memory 64 Technology(EM64T). For details see
-         <http://www.intel.com/technology/64bitextensions/>.
-         Note that the latest Xeons (Xeon 51xx and 53xx) are not based on the
-          Netburst core and shouldn't use this option. You can distinguish them
-         using the cpu family field
-         in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one
-         (this rule only applies to systems that support EM64T)
-
-config MCORE2
-       bool "Intel Core2 / newer Xeon"
-       help
-         Optimize for Intel Core2 and newer Xeons (51xx)
-         You can distinguish the newer Xeons from the older ones using
-         the cpu family field in /proc/cpuinfo. 15 is an older Xeon
-         (use CONFIG_MPSC then), 6 is a newer one. This rule only
-         applies to CPUs that support EM64T.
-
-config GENERIC_CPU
-       bool "Generic-x86-64"
-       help
-         Generic x86-64 CPU.
-         Run equally well on all x86-64 CPUs.
-
-endchoice
-
-#
-# Define implied options from the CPU selection here
-#
-config X86_L1_CACHE_BYTES
-       int
-       default "128" if GENERIC_CPU || MPSC
-       default "64" if MK8 || MCORE2
-
-config X86_L1_CACHE_SHIFT
-       int
-       default "7" if GENERIC_CPU || MPSC
-       default "6" if MK8 || MCORE2
-
-config X86_INTERNODE_CACHE_BYTES
-       int
-       default "4096" if X86_VSMP
-       default X86_L1_CACHE_BYTES if !X86_VSMP
-
-config X86_TSC
-       bool
-       default y
-
-config X86_GOOD_APIC
-       bool
-       default y
-
-config MICROCODE
-       tristate "/dev/cpu/microcode - Intel CPU microcode support"
-       select FW_LOADER
-       ---help---
-         If you say Y here the 'File systems' section, you will be
-         able to update the microcode on Intel processors. You will
-         obviously need the actual microcode binary data itself which is
-         not shipped with the Linux kernel.
-
-         For latest news and information on obtaining all the required
-         ingredients for this driver, check:
-         <http://www.urbanmyth.org/microcode/>.
-
-         To compile this driver as a module, choose M here: the
-         module will be called microcode.
-         If you use modprobe or kmod you may also want to add the line
-         'alias char-major-10-184 microcode' to your /etc/modules.conf file.
-
-config MICROCODE_OLD_INTERFACE
-       bool
-       depends on MICROCODE
-       default y
-
-config X86_MSR
-       tristate "/dev/cpu/*/msr - Model-specific register support"
-       help
-         This device gives privileged processes access to the x86
-         Model-Specific Registers (MSRs).  It is a character device with
-         major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr.
-         MSR accesses are directed to a specific CPU on multi-processor
-         systems.
-
-config X86_CPUID
-       tristate "/dev/cpu/*/cpuid - CPU information support"
-       help
-         This device gives processes access to the x86 CPUID instruction to
-         be executed on a specific processor.  It is a character device
-         with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
-         /dev/cpu/31/cpuid.
-
-config X86_HT
-       bool
-       depends on SMP && !MK8
-       default y
-
-config MATH_EMULATION
-       bool
-
-config MCA
-       bool
-
-config EISA
-       bool
-
-config X86_IO_APIC
-       bool
-       default y
-
-config X86_LOCAL_APIC
-       bool
-       default y
-
-config MTRR
-       bool "MTRR (Memory Type Range Register) support"
-       ---help---
-         On Intel P6 family processors (Pentium Pro, Pentium II and later)
-         the Memory Type Range Registers (MTRRs) may be used to control
-         processor access to memory ranges. This is most useful if you have
-         a video (VGA) card on a PCI or AGP bus. Enabling write-combining
-         allows bus write transfers to be combined into a larger transfer
-         before bursting over the PCI/AGP bus. This can increase performance
-         of image write operations 2.5 times or more. Saying Y here creates a
-         /proc/mtrr file which may be used to manipulate your processor's
-         MTRRs. Typically the X server should use this.
-
-         This code has a reasonably generic interface so that similar
-         control registers on other processors can be easily supported
-         as well.
-
-         Saying Y here also fixes a problem with buggy SMP BIOSes which only
-         set the MTRRs for the boot CPU and not for the secondary CPUs. This
-         can lead to all sorts of problems, so it's good to say Y here.
-
-         Just say Y here, all x86-64 machines support MTRRs.
-
-         See <file:Documentation/mtrr.txt> for more information.
-
-config SMP
-       bool "Symmetric multi-processing support"
-       ---help---
-         This enables support for systems with more than one CPU. If you have
-         a system with only one CPU, like most personal computers, say N. If
-         you have a system with more than one CPU, say Y.
-
-         If you say N here, the kernel will run on single and multiprocessor
-         machines, but will use only one CPU of a multiprocessor machine. If
-         you say Y here, the kernel will run on many, but not all,
-         singleprocessor machines. On a singleprocessor machine, the kernel
-         will run faster if you say N here.
-
-         If you don't know what to do here, say N.
-
-config SCHED_SMT
-       bool "SMT (Hyperthreading) scheduler support"
-       depends on SMP
-       default n
-       help
-         SMT scheduler support improves the CPU scheduler's decision making
-         when dealing with Intel Pentium 4 chips with HyperThreading at a
-         cost of slightly increased overhead in some places. If unsure say
-         N here.
-
-config SCHED_MC
-       bool "Multi-core scheduler support"
-       depends on SMP
-       default y
-       help
-         Multi-core scheduler support improves the CPU scheduler's decision
-         making when dealing with multi-core CPU chips at a cost of slightly
-         increased overhead in some places. If unsure say N here.
-
-source "kernel/Kconfig.preempt"
-
-config NUMA
-       bool "Non Uniform Memory Access (NUMA) Support"
-       depends on SMP
-       help
-        Enable NUMA (Non Uniform Memory Access) support. The kernel 
-        will try to allocate memory used by a CPU on the local memory 
-        controller of the CPU and add some more NUMA awareness to the kernel.
-        This code is recommended on all multiprocessor Opteron systems.
-        If the system is EM64T, you should say N unless your system is EM64T 
-        NUMA. 
-
-config K8_NUMA
-       bool "Old style AMD Opteron NUMA detection"
-       depends on NUMA && PCI
-       default y
-       help
-        Enable K8 NUMA node topology detection.  You should say Y here if
-        you have a multi processor AMD K8 system. This uses an old
-        method to read the NUMA configuration directly from the builtin
-        Northbridge of Opteron. It is recommended to use X86_64_ACPI_NUMA
-        instead, which also takes priority if both are compiled in.   
-
-config NODES_SHIFT
-       int
-       default "6"
-       depends on NEED_MULTIPLE_NODES
-
-# Dummy CONFIG option to select ACPI_NUMA from drivers/acpi/Kconfig.
-
-config X86_64_ACPI_NUMA
-       bool "ACPI NUMA detection"
-       depends on NUMA
-       select ACPI 
-       select PCI
-       select ACPI_NUMA
-       default y
-       help
-        Enable ACPI SRAT based node topology detection.
-
-config NUMA_EMU
-       bool "NUMA emulation"
-       depends on NUMA
-       help
-         Enable NUMA emulation. A flat machine will be split
-         into virtual nodes when booted with "numa=fake=N", where N is the
-         number of nodes. This is only useful for debugging.
-
-config ARCH_DISCONTIGMEM_ENABLE
-       bool
-       depends on NUMA
-       default y
-
-config ARCH_DISCONTIGMEM_DEFAULT
-       def_bool y
-       depends on NUMA
-
-config ARCH_SPARSEMEM_ENABLE
-       def_bool y
-       depends on (NUMA || EXPERIMENTAL)
-
-config ARCH_MEMORY_PROBE
-       def_bool y
-       depends on MEMORY_HOTPLUG
-
-config ARCH_FLATMEM_ENABLE
-       def_bool y
-       depends on !NUMA
-
-source "mm/Kconfig"
-
-config MEMORY_HOTPLUG_RESERVE
-       def_bool y
-       depends on (MEMORY_HOTPLUG && DISCONTIGMEM)
-
-config HAVE_ARCH_EARLY_PFN_TO_NID
-       def_bool y
-       depends on NUMA
-
-config OUT_OF_LINE_PFN_TO_PAGE
-       def_bool y
-       depends on DISCONTIGMEM
-
-config NR_CPUS
-       int "Maximum number of CPUs (2-255)"
-       range 2 255
-       depends on SMP
-       default "8"
-       help
-         This allows you to specify the maximum number of CPUs which this
-         kernel will support. Current maximum is 255 CPUs due to
-         APIC addressing limits. Less depending on the hardware.
-
-         This is purely to save memory - each supported CPU requires
-         memory in the static kernel configuration.
-
-config PHYSICAL_ALIGN
-       hex
-       default "0x200000"
-
-config HOTPLUG_CPU
-       bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)"
-       depends on SMP && HOTPLUG && EXPERIMENTAL
-       help
-               Say Y here to experiment with turning CPUs off and on.  CPUs
-               can be controlled through /sys/devices/system/cpu/cpu#.
-               This is also required for suspend/hibernation on SMP systems.
-
-               Say N if you want to disable CPU hotplug and don't need to
-               suspend.
-
-config ARCH_ENABLE_MEMORY_HOTPLUG
-       def_bool y
-
-config HPET_TIMER
-       bool
-       default y
-       help
-         Use the IA-PC HPET (High Precision Event Timer) to manage
-         time in preference to the PIT and RTC, if a HPET is
-         present.  The HPET provides a stable time base on SMP
-         systems, unlike the TSC, but it is more expensive to access,
-         as it is off-chip.  You can find the HPET spec at
-         <http://www.intel.com/hardwaredesign/hpetspec.htm>.
-
-config HPET_EMULATE_RTC
-       bool "Provide RTC interrupt"
-       depends on HPET_TIMER && RTC=y
-
-# Mark as embedded because too many people got it wrong.
-# The code disables itself when not needed.
-config IOMMU
-       bool "IOMMU support" if EMBEDDED
-       default y
-       select SWIOTLB
-       select AGP
-       depends on PCI
-       help
-         Support for full DMA access of devices with 32bit memory access only
-         on systems with more than 3GB. This is usually needed for USB,
-         sound, many IDE/SATA chipsets and some other devices.
-         Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART
-         based hardware IOMMU and a software bounce buffer based IOMMU used
-         on Intel systems and as fallback.
-         The code is only active when needed (enough memory and limited
-         device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified
-         too.
-
-config CALGARY_IOMMU
-       bool "IBM Calgary IOMMU support"
-       select SWIOTLB
-       depends on PCI && EXPERIMENTAL
-       help
-         Support for hardware IOMMUs in IBM's xSeries x366 and x460
-         systems. Needed to run systems with more than 3GB of memory
-         properly with 32-bit PCI devices that do not support DAC
-         (Double Address Cycle). Calgary also supports bus level
-         isolation, where all DMAs pass through the IOMMU.  This
-         prevents them from going anywhere except their intended
-         destination. This catches hard-to-find kernel bugs and
-         mis-behaving drivers and devices that do not use the DMA-API
-         properly to set up their DMA buffers.  The IOMMU can be
-         turned off at boot time with the iommu=off parameter.
-         Normally the kernel will make the right choice by itself.
-         If unsure, say Y.
-
-config CALGARY_IOMMU_ENABLED_BY_DEFAULT
-       bool "Should Calgary be enabled by default?"
-       default y
-       depends on CALGARY_IOMMU
-       help
-         Should Calgary be enabled by default? if you choose 'y', Calgary
-         will be used (if it exists). If you choose 'n', Calgary will not be
-         used even if it exists. If you choose 'n' and would like to use
-         Calgary anyway, pass 'iommu=calgary' on the kernel command line.
-         If unsure, say Y.
-
-# need this always selected by IOMMU for the VIA workaround
-config SWIOTLB
-       bool
-       help
-         Support for software bounce buffers used on x86-64 systems
-         which don't have a hardware IOMMU (e.g. the current generation
-         of Intel's x86-64 CPUs). Using this PCI devices which can only
-         access 32-bits of memory can be used on systems with more than
-         3 GB of memory. If unsure, say Y.
-
-config X86_MCE
-       bool "Machine check support" if EMBEDDED
-       default y
-       help
-          Include a machine check error handler to report hardware errors.
-          This version will require the mcelog utility to decode some
-          machine check error logs. See
-          ftp://ftp.x86-64.org/pub/linux/tools/mcelog
-
-config X86_MCE_INTEL
-       bool "Intel MCE features"
-       depends on X86_MCE && X86_LOCAL_APIC
-       default y
-       help
-          Additional support for intel specific MCE features such as
-          the thermal monitor.
-
-config X86_MCE_AMD
-       bool "AMD MCE features"
-       depends on X86_MCE && X86_LOCAL_APIC
-       default y
-       help
-          Additional support for AMD specific MCE features such as
-          the DRAM Error Threshold.
-
-config KEXEC
-       bool "kexec system call"
-       help
-         kexec is a system call that implements the ability to shutdown your
-         current kernel, and to start another kernel.  It is like a reboot
-         but it is independent of the system firmware.   And like a reboot
-         you can start any kernel with it, not just Linux.
-
-         The name comes from the similarity to the exec system call.
-
-         It is an ongoing process to be certain the hardware in a machine
-         is properly shutdown, so do not be surprised if this code does not
-         initially work for you.  It may help to enable device hotplugging
-         support.  As of this writing the exact hardware interface is
-         strongly in flux, so no good recommendation can be made.
-
-config CRASH_DUMP
-       bool "kernel crash dumps (EXPERIMENTAL)"
-       depends on EXPERIMENTAL
-       help
-          Generate crash dump after being started by kexec.
-          This should be normally only set in special crash dump kernels
-          which are loaded in the main kernel with kexec-tools into
-          a specially reserved region and then later executed after
-          a crash by kdump/kexec. The crash dump kernel must be compiled
-         to a memory address not used by the main kernel or BIOS using
-         PHYSICAL_START.
-          For more details see Documentation/kdump/kdump.txt
-
-config RELOCATABLE
-       bool "Build a relocatable kernel(EXPERIMENTAL)"
-       depends on EXPERIMENTAL
-       help
-         Builds a relocatable kernel. This enables loading and running
-         a kernel binary from a different physical address than it has
-         been compiled for.
-
-         One use is for the kexec on panic case where the recovery kernel
-         must live at a different physical address than the primary
-         kernel.
-
-         Note: If CONFIG_RELOCATABLE=y, then kernel run from the address
-         it has been loaded at and compile time physical address
-         (CONFIG_PHYSICAL_START) is ignored.
-
-config PHYSICAL_START
-       hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
-       default "0x200000"
-       help
-         This gives the physical address where the kernel is loaded. It
-         should be aligned to 2MB boundary.
-
-         If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then
-         bzImage will decompress itself to above physical address and
-         run from there. Otherwise, bzImage will run from the address where
-         it has been loaded by the boot loader and will ignore above physical
-         address.
-
-         In normal kdump cases one does not have to set/change this option
-         as now bzImage can be compiled as a completely relocatable image
-         (CONFIG_RELOCATABLE=y) and be used to load and run from a different
-         address. This option is mainly useful for the folks who don't want
-         to use a bzImage for capturing the crash dump and want to use a
-         vmlinux instead.
-
-         So if you are using bzImage for capturing the crash dump, leave
-         the value here unchanged to 0x200000 and set CONFIG_RELOCATABLE=y.
-         Otherwise if you plan to use vmlinux for capturing the crash dump
-         change this value to start of the reserved region (Typically 16MB
-         0x1000000). In other words, it can be set based on the "X" value as
-         specified in the "crashkernel=YM@XM" command line boot parameter
-         passed to the panic-ed kernel. Typically this parameter is set as
-         crashkernel=64M@16M. Please take a look at
-         Documentation/kdump/kdump.txt for more details about crash dumps.
-
-         Usage of bzImage for capturing the crash dump is advantageous as
-         one does not have to build two kernels. Same kernel can be used
-         as production kernel and capture kernel.
-
-         Don't change this unless you know what you are doing.
-
-config SECCOMP
-       bool "Enable seccomp to safely compute untrusted bytecode"
-       depends on PROC_FS
-       default y
-       help
-         This kernel feature is useful for number crunching applications
-         that may need to compute untrusted bytecode during their
-         execution. By using pipes or other transports made available to
-         the process as file descriptors supporting the read/write
-         syscalls, it's possible to isolate those applications in
-         their own address space using seccomp. Once seccomp is
-         enabled via /proc/<pid>/seccomp, it cannot be disabled
-         and the task is only allowed to execute a few safe syscalls
-         defined by each seccomp mode.
-
-         If unsure, say Y. Only embedded should say N here.
-
-config CC_STACKPROTECTOR
-       bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
-       depends on EXPERIMENTAL
-       help
-         This option turns on the -fstack-protector GCC feature. This
-         feature puts, at the beginning of critical functions, a canary
-         value on the stack just before the return address, and validates
-         the value just before actually returning.  Stack based buffer
-         overflows (that need to overwrite this return address) now also
-         overwrite the canary, which gets detected and the attack is then
-         neutralized via a kernel panic.
-
-         This feature requires gcc version 4.2 or above, or a distribution
-         gcc with the feature backported. Older versions are automatically
-         detected and for those versions, this configuration option is ignored.
-
-config CC_STACKPROTECTOR_ALL
-       bool "Use stack-protector for all functions"
-       depends on CC_STACKPROTECTOR
-       help
-         Normally, GCC only inserts the canary value protection for
-         functions that use large-ish on-stack buffers. By enabling
-         this option, GCC will be asked to do this for ALL functions.
-
-source kernel/Kconfig.hz
-
-config K8_NB
-       def_bool y
-       depends on AGP_AMD64 || IOMMU || (PCI && NUMA)
-
-endmenu
-
-#
-# Use the generic interrupt handling code in kernel/irq/:
-#
-config GENERIC_HARDIRQS
-       bool
-       default y
-
-config GENERIC_IRQ_PROBE
-       bool
-       default y
-
-# we have no ISA slots, but we do have ISA-style DMA.
-config ISA_DMA_API
-       bool
-       default y
-
-config GENERIC_PENDING_IRQ
-       bool
-       depends on GENERIC_HARDIRQS && SMP
-       default y
-
-menu "Power management options"
-
-source kernel/power/Kconfig
-
-source "drivers/acpi/Kconfig"
-
-source "arch/x86_64/kernel/cpufreq/Kconfig"
-
-endmenu
-
-menu "Bus options (PCI etc.)"
-
-config PCI
-       bool "PCI support"
-       select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
-
-# x86-64 doesn't support PCI BIOS access from long mode so always go direct.
-config PCI_DIRECT
-       bool
-       depends on PCI
-       default y
-
-config PCI_MMCONFIG
-       bool "Support mmconfig PCI config space access"
-       depends on PCI && ACPI
-
-source "drivers/pci/pcie/Kconfig"
-
-source "drivers/pci/Kconfig"
-
-source "drivers/pcmcia/Kconfig"
-
-source "drivers/pci/hotplug/Kconfig"
-
-endmenu
-
-
-menu "Executable file formats / Emulations"
-
-source "fs/Kconfig.binfmt"
-
-config IA32_EMULATION
-       bool "IA32 Emulation"
-       help
-         Include code to run 32-bit programs under a 64-bit kernel. You should likely
-         turn this on, unless you're 100% sure that you don't have any 32-bit programs
-         left.
-
-config IA32_AOUT
-       tristate "IA32 a.out support"
-       depends on IA32_EMULATION
-       help
-         Support old a.out binaries in the 32bit emulation.
-
-config COMPAT
-       bool
-       depends on IA32_EMULATION
-       default y
-
-config COMPAT_FOR_U64_ALIGNMENT
-       def_bool COMPAT
-
-config SYSVIPC_COMPAT
-       bool
-       depends on COMPAT && SYSVIPC
-       default y
-
-endmenu
-
-source "net/Kconfig"
-
-source drivers/Kconfig
-
-source "drivers/firmware/Kconfig"
-
-source fs/Kconfig
-
-menu "Instrumentation Support"
-        depends on EXPERIMENTAL
-
-source "arch/x86_64/oprofile/Kconfig"
-
-config KPROBES
-       bool "Kprobes"
-       depends on KALLSYMS && MODULES
-       help
-         Kprobes allows you to trap at almost any kernel address and
-         execute a callback function.  register_kprobe() establishes
-         a probepoint and specifies the callback.  Kprobes is useful
-         for kernel debugging, non-intrusive instrumentation and testing.
-         If in doubt, say "N".
-endmenu
-
-source "arch/x86_64/Kconfig.debug"
-
-source "security/Kconfig"
-
-source "crypto/Kconfig"
-
-source "lib/Kconfig"
diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug
deleted file mode 100644 (file)
index 775d211..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-menu "Kernel hacking"
-
-config TRACE_IRQFLAGS_SUPPORT
-       bool
-       default y
-
-source "lib/Kconfig.debug"
-
-config DEBUG_RODATA
-       bool "Write protect kernel read-only data structures"
-       depends on DEBUG_KERNEL
-       help
-        Mark the kernel read-only data as write-protected in the pagetables,
-        in order to catch accidental (and incorrect) writes to such const data.
-        This option may have a slight performance impact because a portion
-        of the kernel code won't be covered by a 2MB TLB anymore.
-        If in doubt, say "N".
-
-config IOMMU_DEBUG
-       depends on IOMMU && DEBUG_KERNEL
-       bool "Enable IOMMU debugging"
-       help
-         Force the IOMMU to on even when you have less than 4GB of
-        memory and add debugging code. On overflow always panic. And
-        allow to enable IOMMU leak tracing. Can be disabled at boot
-        time with iommu=noforce. This will also enable scatter gather
-        list merging.  Currently not recommended for production
-        code. When you use it make sure you have a big enough
-        IOMMU/AGP aperture.  Most of the options enabled by this can
-        be set more finegrained using the iommu= command line
-        options. See Documentation/x86_64/boot-options.txt for more
-        details.
-
-config IOMMU_LEAK
-       bool "IOMMU leak tracing"
-       depends on DEBUG_KERNEL
-       depends on IOMMU_DEBUG
-       help
-         Add a simple leak tracer to the IOMMU code. This is useful when you
-        are debugging a buggy device driver that leaks IOMMU mappings.
-
-config DEBUG_STACKOVERFLOW
-        bool "Check for stack overflows"
-        depends on DEBUG_KERNEL
-        help
-         This option will cause messages to be printed if free stack space
-         drops below a certain limit.
-
-config DEBUG_STACK_USAGE
-        bool "Stack utilization instrumentation"
-        depends on DEBUG_KERNEL
-        help
-         Enables the display of the minimum amount of free stack which each
-         task has ever had available in the sysrq-T and sysrq-P debug output.
-
-         This option will slow down process creation somewhat.
-
-#config X86_REMOTE_DEBUG
-#       bool "kgdb debugging stub"
-
-endmenu
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
deleted file mode 100644 (file)
index b024e4a..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#
-# x86_64/Makefile
-#
-# This file is included by the global makefile so that you can add your own
-# architecture-specific flags and dependencies. Remember to do have actions
-# for "archclean" and "archdep" for cleaning up and making dependencies for
-# this architecture
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License.  See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1994 by Linus Torvalds
-#
-# 19990713  Artur Skawina <skawina@geocities.com>
-#           Added '-march' and '-mpreferred-stack-boundary' support
-# 20000913  Pavel Machek <pavel@suse.cz>
-#          Converted for x86_64 architecture
-# 20010105  Andi Kleen, add IA32 compiler.
-#           ....and later removed it again....
-#
-# $Id: Makefile,v 1.31 2002/03/22 15:56:07 ak Exp $
-
-LDFLAGS                := -m elf_x86_64
-OBJCOPYFLAGS   := -O binary -R .note -R .comment -S
-LDFLAGS_vmlinux :=
-CHECKFLAGS      += -D__x86_64__ -m64
-
-cflags-y       :=
-cflags-kernel-y        :=
-cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
-cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
-# gcc doesn't support -march=core2 yet as of gcc 4.3, but I hope it
-# will eventually. Use -mtune=generic as fallback
-cflags-$(CONFIG_MCORE2) += \
-       $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
-cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
-
-cflags-y += -m64
-cflags-y += -mno-red-zone
-cflags-y += -mcmodel=kernel
-cflags-y += -pipe
-cflags-y += -Wno-sign-compare
-cflags-y += -fno-asynchronous-unwind-tables
-ifneq ($(CONFIG_DEBUG_INFO),y)
-# -fweb shrinks the kernel a bit, but the difference is very small
-# it also messes up debugging, so don't use it for now.
-#cflags-y += $(call cc-option,-fweb)
-endif
-# -funit-at-a-time shrinks the kernel .text considerably
-# unfortunately it makes reading oopses harder.
-cflags-y += $(call cc-option,-funit-at-a-time)
-# prevent gcc from generating any FP code by mistake
-cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
-# this works around some issues with generating unwind tables in older gccs
-# newer gccs do it by default
-cflags-y += -maccumulate-outgoing-args
-
-# do binutils support CFI?
-cflags-y += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
-
-# is .cfi_signal_frame supported too?
-cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
-
-cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector )
-cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector-all )
-
-CFLAGS += $(cflags-y)
-CFLAGS_KERNEL += $(cflags-kernel-y)
-AFLAGS += -m64
-
-head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
-
-libs-y                                         += arch/x86_64/lib/
-core-y                                 += arch/x86_64/kernel/ \
-                                          arch/x86_64/mm/ \
-                                          arch/x86_64/crypto/ \
-                                          arch/x86_64/vdso/
-core-$(CONFIG_IA32_EMULATION)          += arch/x86_64/ia32/
-drivers-$(CONFIG_PCI)                  += arch/x86_64/pci/
-drivers-$(CONFIG_OPROFILE)             += arch/x86_64/oprofile/
-
-boot := arch/x86_64/boot
-
-PHONY += bzImage bzlilo install archmrproper \
-        fdimage fdimage144 fdimage288 isoimage archclean
-
-#Default target when executing "make"
-all: bzImage
-
-BOOTIMAGE                     := arch/x86_64/boot/bzImage
-KBUILD_IMAGE                  := $(BOOTIMAGE)
-
-bzImage: vmlinux
-       $(Q)$(MAKE) $(build)=$(boot) $(BOOTIMAGE)
-
-bzlilo: vmlinux
-       $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zlilo
-
-bzdisk: vmlinux
-       $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) zdisk
-
-fdimage fdimage144 fdimage288 isoimage: vmlinux
-       $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
-
-install:
-       $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ 
-
-archclean:
-       $(Q)$(MAKE) $(clean)=$(boot)
-
-define archhelp
-  echo  '* bzImage     - Compressed kernel image (arch/$(ARCH)/boot/bzImage)'
-  echo  '  install     - Install kernel using'
-  echo  '                 (your) ~/bin/installkernel or'
-  echo  '                 (distribution) /sbin/installkernel or'
-  echo  '                 install to $$(INSTALL_PATH) and run lilo'
-  echo  '  bzdisk       - Create a boot floppy in /dev/fd0'
-  echo  '  fdimage      - Create a boot floppy image'
-  echo  '  isoimage     - Create a boot CD-ROM image'
-endef
-
-CLEAN_FILES += arch/$(ARCH)/boot/fdimage \
-              arch/$(ARCH)/boot/image.iso \
-              arch/$(ARCH)/boot/mtools.conf
-
-
diff --git a/arch/x86_64/boot/.gitignore b/arch/x86_64/boot/.gitignore
deleted file mode 100644 (file)
index 1846514..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-bootsect
-bzImage
-setup
-setup.bin
-setup.elf
diff --git a/arch/x86_64/boot/Makefile b/arch/x86_64/boot/Makefile
deleted file mode 100644 (file)
index 6709638..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# arch/x86_64/boot/Makefile
-#
-# The actual boot code is shared with i386 including the Makefile.
-# So tell kbuild that we fetch the code from i386 and include the
-# Makefile from i386 too.
-
-src := arch/i386/boot
-include $(src)/Makefile
diff --git a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
deleted file mode 100644 (file)
index 877c0bd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# linux/arch/x86_64/boot/compressed/Makefile
-#
-# create a compressed vmlinux image from the original vmlinux
-#
-
-targets                := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
-
-CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2  \
-         -fno-strict-aliasing -fPIC -mcmodel=small \
-          $(call cc-option, -ffreestanding) \
-          $(call cc-option, -fno-stack-protector)
-AFLAGS  := $(CFLAGS) -D__ASSEMBLY__
-LDFLAGS := -m elf_x86_64
-
-LDFLAGS_vmlinux := -T
-$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
-       $(call if_changed,ld)
-       @:
-
-$(obj)/vmlinux.bin: vmlinux FORCE
-       $(call if_changed,objcopy)
-
-$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
-       $(call if_changed,gzip)
-
-LDFLAGS_piggy.o := -r --format binary --oformat elf64-x86-64 -T
-
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
-       $(call if_changed,ld)
diff --git a/arch/x86_64/boot/compressed/head.S b/arch/x86_64/boot/compressed/head.S
deleted file mode 100644 (file)
index 9fd8030..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- *  linux/boot/head.S
- *
- *  Copyright (C) 1991, 1992, 1993  Linus Torvalds
- */
-
-/*
- *  head.S contains the 32-bit startup code.
- *
- * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
- * the page directory will exist. The startup code will be overwritten by
- * the page directory. [According to comments etc elsewhere on a compressed
- * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
- *
- * Page 0 is deliberately kept safe, since System Management Mode code in 
- * laptops may need to access the BIOS data stored there.  This is also
- * useful for future device drivers that either access the BIOS via VM86 
- * mode.
- */
-
-/*
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-.code32
-.text
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/msr.h>
-
-.section ".text.head"
-       .code32
-       .globl startup_32
-
-startup_32:
-       cld
-       cli
-       movl    $(__KERNEL_DS), %eax
-       movl    %eax, %ds
-       movl    %eax, %es
-       movl    %eax, %ss
-
-/* Calculate the delta between where we were compiled to run
- * at and where we were actually loaded at.  This can only be done
- * with a short local call on x86.  Nothing  else will tell us what
- * address we are running at.  The reserved chunk of the real-mode
- * data at 0x1e4 (defined as a scratch field) are used as the stack
- * for this calculation. Only 4 bytes are needed.
- */
-       leal    (0x1e4+4)(%esi), %esp
-       call    1f
-1:     popl    %ebp
-       subl    $1b, %ebp
-
-/* setup a stack and make sure cpu supports long mode. */
-       movl    $user_stack_end, %eax
-       addl    %ebp, %eax
-       movl    %eax, %esp
-
-       call    verify_cpu
-       testl   %eax, %eax
-       jnz     no_longmode
-
-/* Compute the delta between where we were compiled to run at
- * and where the code will actually run at.
- */
-/* %ebp contains the address we are loaded at by the boot loader and %ebx
- * contains the address where we should move the kernel image temporarily
- * for safe in-place decompression.
- */
-
-#ifdef CONFIG_RELOCATABLE
-       movl    %ebp, %ebx
-       addl    $(LARGE_PAGE_SIZE -1), %ebx
-       andl    $LARGE_PAGE_MASK, %ebx
-#else
-       movl    $CONFIG_PHYSICAL_START, %ebx
-#endif
-
-       /* Replace the compressed data size with the uncompressed size */
-       subl    input_len(%ebp), %ebx
-       movl    output_len(%ebp), %eax
-       addl    %eax, %ebx
-       /* Add 8 bytes for every 32K input block */
-       shrl    $12, %eax
-       addl    %eax, %ebx
-       /* Add 32K + 18 bytes of extra slack and align on a 4K boundary */
-       addl    $(32768 + 18 + 4095), %ebx
-       andl    $~4095, %ebx
-
-/*
- * Prepare for entering 64 bit mode
- */
-
-       /* Load new GDT with the 64bit segments using 32bit descriptor */
-       leal    gdt(%ebp), %eax
-       movl    %eax, gdt+2(%ebp)
-       lgdt    gdt(%ebp)
-
-       /* Enable PAE mode */
-       xorl    %eax, %eax
-       orl     $(1 << 5), %eax
-       movl    %eax, %cr4
-
- /*
-  * Build early 4G boot pagetable
-  */
-       /* Initialize Page tables to 0*/
-       leal    pgtable(%ebx), %edi
-       xorl    %eax, %eax
-       movl    $((4096*6)/4), %ecx
-       rep     stosl
-
-       /* Build Level 4 */
-       leal    pgtable + 0(%ebx), %edi
-       leal    0x1007 (%edi), %eax
-       movl    %eax, 0(%edi)
-
-       /* Build Level 3 */
-       leal    pgtable + 0x1000(%ebx), %edi
-       leal    0x1007(%edi), %eax
-       movl    $4, %ecx
-1:     movl    %eax, 0x00(%edi)
-       addl    $0x00001000, %eax
-       addl    $8, %edi
-       decl    %ecx
-       jnz     1b
-
-       /* Build Level 2 */
-       leal    pgtable + 0x2000(%ebx), %edi
-       movl    $0x00000183, %eax
-       movl    $2048, %ecx
-1:     movl    %eax, 0(%edi)
-       addl    $0x00200000, %eax
-       addl    $8, %edi
-       decl    %ecx
-       jnz     1b
-
-       /* Enable the boot page tables */
-       leal    pgtable(%ebx), %eax
-       movl    %eax, %cr3
-
-       /* Enable Long mode in EFER (Extended Feature Enable Register) */
-       movl    $MSR_EFER, %ecx
-       rdmsr
-       btsl    $_EFER_LME, %eax
-       wrmsr
-
-       /* Setup for the jump to 64bit mode
-        *
-        * When the jump is performend we will be in long mode but
-        * in 32bit compatibility mode with EFER.LME = 1, CS.L = 0, CS.D = 1
-        * (and in turn EFER.LMA = 1).  To jump into 64bit mode we use
-        * the new gdt/idt that has __KERNEL_CS with CS.L = 1.
-        * We place all of the values on our mini stack so lret can
-        * used to perform that far jump.
-        */
-       pushl   $__KERNEL_CS
-       leal    startup_64(%ebp), %eax
-       pushl   %eax
-
-       /* Enter paged protected Mode, activating Long Mode */
-       movl    $0x80000001, %eax /* Enable Paging and Protected mode */
-       movl    %eax, %cr0
-
-       /* Jump from 32bit compatibility mode into 64bit mode. */
-       lret
-
-no_longmode:
-       /* This isn't an x86-64 CPU so hang */
-1:
-       hlt
-       jmp     1b
-
-#include "../../kernel/verify_cpu.S"
-
-       /* Be careful here startup_64 needs to be at a predictable
-        * address so I can export it in an ELF header.  Bootloaders
-        * should look at the ELF header to find this address, as
-        * it may change in the future.
-        */
-       .code64
-       .org 0x200
-ENTRY(startup_64)
-       /* We come here either from startup_32 or directly from a
-        * 64bit bootloader.  If we come here from a bootloader we depend on
-        * an identity mapped page table being provied that maps our
-        * entire text+data+bss and hopefully all of memory.
-        */
-
-       /* Setup data segments. */
-       xorl    %eax, %eax
-       movl    %eax, %ds
-       movl    %eax, %es
-       movl    %eax, %ss
-       movl    %eax, %fs
-       movl    %eax, %gs
-       lldt    %ax
-       movl    $0x20, %eax
-       ltr     %ax
-
-       /* Compute the decompressed kernel start address.  It is where
-        * we were loaded at aligned to a 2M boundary. %rbp contains the
-        * decompressed kernel start address.
-        *
-        * If it is a relocatable kernel then decompress and run the kernel
-        * from load address aligned to 2MB addr, otherwise decompress and
-        * run the kernel from CONFIG_PHYSICAL_START
-        */
-
-       /* Start with the delta to where the kernel will run at. */
-#ifdef CONFIG_RELOCATABLE
-       leaq    startup_32(%rip) /* - $startup_32 */, %rbp
-       addq    $(LARGE_PAGE_SIZE - 1), %rbp
-       andq    $LARGE_PAGE_MASK, %rbp
-       movq    %rbp, %rbx
-#else
-       movq    $CONFIG_PHYSICAL_START, %rbp
-       movq    %rbp, %rbx
-#endif
-
-       /* Replace the compressed data size with the uncompressed size */
-       movl    input_len(%rip), %eax
-       subq    %rax, %rbx
-       movl    output_len(%rip), %eax
-       addq    %rax, %rbx
-       /* Add 8 bytes for every 32K input block */
-       shrq    $12, %rax
-       addq    %rax, %rbx
-       /* Add 32K + 18 bytes of extra slack and align on a 4K boundary */
-       addq    $(32768 + 18 + 4095), %rbx
-       andq    $~4095, %rbx
-
-/* Copy the compressed kernel to the end of our buffer
- * where decompression in place becomes safe.
- */
-       leaq    _end(%rip), %r8
-       leaq    _end(%rbx), %r9
-       movq    $_end /* - $startup_32 */, %rcx
-1:     subq    $8, %r8
-       subq    $8, %r9
-       movq    0(%r8), %rax
-       movq    %rax, 0(%r9)
-       subq    $8, %rcx
-       jnz     1b
-
-/*
- * Jump to the relocated address.
- */
-       leaq    relocated(%rbx), %rax
-       jmp     *%rax
-
-.section ".text"
-relocated:
-
-/*
- * Clear BSS
- */
-       xorq    %rax, %rax
-       leaq    _edata(%rbx), %rdi
-       leaq    _end(%rbx), %rcx
-       subq    %rdi, %rcx
-       cld
-       rep
-       stosb
-
-       /* Setup the stack */
-       leaq    user_stack_end(%rip), %rsp
-
-       /* zero EFLAGS after setting rsp */
-       pushq   $0
-       popfq
-
-/*
- * Do the decompression, and jump to the new kernel..
- */
-       pushq   %rsi                    # Save the real mode argument
-       movq    %rsi, %rdi              # real mode address
-       leaq    _heap(%rip), %rsi       # _heap
-       leaq    input_data(%rip), %rdx  # input_data
-       movl    input_len(%rip), %eax
-       movq    %rax, %rcx              # input_len
-       movq    %rbp, %r8               # output
-       call    decompress_kernel
-       popq    %rsi
-
-
-/*
- * Jump to the decompressed kernel.
- */
-       jmp     *%rbp
-
-       .data
-gdt:
-       .word   gdt_end - gdt
-       .long   gdt
-       .word   0
-       .quad   0x0000000000000000      /* NULL descriptor */
-       .quad   0x00af9a000000ffff      /* __KERNEL_CS */
-       .quad   0x00cf92000000ffff      /* __KERNEL_DS */
-       .quad   0x0080890000000000      /* TS descriptor */
-       .quad   0x0000000000000000      /* TS continued */
-gdt_end:
-       .bss
-/* Stack for uncompression */
-       .balign 4
-user_stack:
-       .fill 4096,4,0
-user_stack_end:
diff --git a/arch/x86_64/boot/compressed/misc.c b/arch/x86_64/boot/compressed/misc.c
deleted file mode 100644 (file)
index f932b0e..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * misc.c
- * 
- * This is a collection of several routines from gzip-1.0.3 
- * adapted for Linux.
- *
- * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
- * puts by Nick Holloway 1993, better puts by Martin Mares 1995
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-
-#define _LINUX_STRING_H_ 1
-#define __LINUX_BITMAP_H 1
-
-#include <linux/linkage.h>
-#include <linux/screen_info.h>
-#include <asm/io.h>
-#include <asm/page.h>
-
-/* WARNING!!
- * This code is compiled with -fPIC and it is relocated dynamically
- * at run time, but no relocation processing is performed.
- * This means that it is not safe to place pointers in static structures.
- */
-
-/*
- * Getting to provable safe in place decompression is hard.
- * Worst case behaviours need to be analized.
- * Background information:
- *
- * The file layout is:
- *    magic[2]
- *    method[1]
- *    flags[1]
- *    timestamp[4]
- *    extraflags[1]
- *    os[1]
- *    compressed data blocks[N]
- *    crc[4] orig_len[4]
- *
- * resulting in 18 bytes of non compressed data overhead.
- *
- * Files divided into blocks
- * 1 bit (last block flag)
- * 2 bits (block type)
- *
- * 1 block occurs every 32K -1 bytes or when there 50% compression has been achieved.
- * The smallest block type encoding is always used.
- *
- * stored:
- *    32 bits length in bytes.
- *
- * fixed:
- *    magic fixed tree.
- *    symbols.
- *
- * dynamic:
- *    dynamic tree encoding.
- *    symbols.
- *
- *
- * The buffer for decompression in place is the length of the
- * uncompressed data, plus a small amount extra to keep the algorithm safe.
- * The compressed data is placed at the end of the buffer.  The output
- * pointer is placed at the start of the buffer and the input pointer
- * is placed where the compressed data starts.  Problems will occur
- * when the output pointer overruns the input pointer.
- *
- * The output pointer can only overrun the input pointer if the input
- * pointer is moving faster than the output pointer.  A condition only
- * triggered by data whose compressed form is larger than the uncompressed
- * form.
- *
- * The worst case at the block level is a growth of the compressed data
- * of 5 bytes per 32767 bytes.
- *
- * The worst case internal to a compressed block is very hard to figure.
- * The worst case can at least be boundined by having one bit that represents
- * 32764 bytes and then all of the rest of the bytes representing the very
- * very last byte.
- *
- * All of which is enough to compute an amount of extra data that is required
- * to be safe.  To avoid problems at the block level allocating 5 extra bytes
- * per 32767 bytes of data is sufficient.  To avoind problems internal to a block
- * adding an extra 32767 bytes (the worst case uncompressed block size) is
- * sufficient, to ensure that in the worst case the decompressed data for
- * block will stop the byte before the compressed data for a block begins.
- * To avoid problems with the compressed data's meta information an extra 18
- * bytes are needed.  Leading to the formula:
- *
- * extra_bytes = (uncompressed_size >> 12) + 32768 + 18 + decompressor_size.
- *
- * Adding 8 bytes per 32K is a bit excessive but much easier to calculate.
- * Adding 32768 instead of 32767 just makes for round numbers.
- * Adding the decompressor_size is necessary as it musht live after all
- * of the data as well.  Last I measured the decompressor is about 14K.
- * 10K of actuall data and 4K of bss.
- *
- */
-
-/*
- * gzip declarations
- */
-
-#define OF(args)  args
-#define STATIC static
-
-#undef memset
-#undef memcpy
-#define memzero(s, n)     memset ((s), 0, (n))
-
-typedef unsigned char  uch;
-typedef unsigned short ush;
-typedef unsigned long  ulg;
-
-#define WSIZE 0x80000000       /* Window size must be at least 32k,
-                                * and a power of two
-                                * We don't actually have a window just
-                                * a huge output buffer so I report
-                                * a 2G windows size, as that should
-                                * always be larger than our output buffer.
-                                */
-
-static uch *inbuf;     /* input buffer */
-static uch *window;    /* Sliding window buffer, (and final output buffer) */
-
-static unsigned insize;  /* valid bytes in inbuf */
-static unsigned inptr;   /* index of next byte to be processed in inbuf */
-static unsigned outcnt;  /* bytes in output buffer */
-
-/* gzip flag byte */
-#define ASCII_FLAG   0x01 /* bit 0 set: file probably ASCII text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
-#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
-#define COMMENT      0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED    0x20 /* bit 5 set: file is encrypted */
-#define RESERVED     0xC0 /* bit 6,7:   reserved */
-
-#define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf())
-               
-/* Diagnostic functions */
-#ifdef DEBUG
-#  define Assert(cond,msg) {if(!(cond)) error(msg);}
-#  define Trace(x) fprintf x
-#  define Tracev(x) {if (verbose) fprintf x ;}
-#  define Tracevv(x) {if (verbose>1) fprintf x ;}
-#  define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-#  define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-#  define Assert(cond,msg)
-#  define Trace(x)
-#  define Tracev(x)
-#  define Tracevv(x)
-#  define Tracec(c,x)
-#  define Tracecv(c,x)
-#endif
-
-static int  fill_inbuf(void);
-static void flush_window(void);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
-  
-/*
- * This is set up by the setup-routine at boot-time
- */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define RM_EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define RM_ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
-
-extern unsigned char input_data[];
-extern int input_len;
-
-static long bytes_out = 0;
-
-static void *malloc(int size);
-static void free(void *where);
-
-static void *memset(void *s, int c, unsigned n);
-static void *memcpy(void *dest, const void *src, unsigned n);
-
-static void putstr(const char *);
-
-static long free_mem_ptr;
-static long free_mem_end_ptr;
-
-#define HEAP_SIZE             0x7000
-
-static char *vidmem = (char *)0xb8000;
-static int vidport;
-static int lines, cols;
-
-#include "../../../../lib/inflate.c"
-
-static void *malloc(int size)
-{
-       void *p;
-
-       if (size <0) error("Malloc error");
-       if (free_mem_ptr <= 0) error("Memory error");
-
-       free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
-
-       p = (void *)free_mem_ptr;
-       free_mem_ptr += size;
-
-       if (free_mem_ptr >= free_mem_end_ptr)
-               error("Out of memory");
-
-       return p;
-}
-
-static void free(void *where)
-{      /* Don't care */
-}
-
-static void gzip_mark(void **ptr)
-{
-       *ptr = (void *) free_mem_ptr;
-}
-
-static void gzip_release(void **ptr)
-{
-       free_mem_ptr = (long) *ptr;
-}
-static void scroll(void)
-{
-       int i;
-
-       memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
-       for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
-               vidmem[i] = ' ';
-}
-
-static void putstr(const char *s)
-{
-       int x,y,pos;
-       char c;
-
-       x = RM_SCREEN_INFO.orig_x;
-       y = RM_SCREEN_INFO.orig_y;
-
-       while ( ( c = *s++ ) != '\0' ) {
-               if ( c == '\n' ) {
-                       x = 0;
-                       if ( ++y >= lines ) {
-                               scroll();
-                               y--;
-                       }
-               } else {
-                       vidmem [ ( x + cols * y ) * 2 ] = c; 
-                       if ( ++x >= cols ) {
-                               x = 0;
-                               if ( ++y >= lines ) {
-                                       scroll();
-                                       y--;
-                               }
-                       }
-               }
-       }
-
-       RM_SCREEN_INFO.orig_x = x;
-       RM_SCREEN_INFO.orig_y = y;
-
-       pos = (x + cols * y) * 2;       /* Update cursor position */
-       outb_p(14, vidport);
-       outb_p(0xff & (pos >> 9), vidport+1);
-       outb_p(15, vidport);
-       outb_p(0xff & (pos >> 1), vidport+1);
-}
-
-static void* memset(void* s, int c, unsigned n)
-{
-       int i;
-       char *ss = (char*)s;
-
-       for (i=0;i<n;i++) ss[i] = c;
-       return s;
-}
-
-static void* memcpy(void* dest, const void* src, unsigned n)
-{
-       int i;
-       char *d = (char *)dest, *s = (char *)src;
-
-       for (i=0;i<n;i++) d[i] = s[i];
-       return dest;
-}
-
-/* ===========================================================================
- * Fill the input buffer. This is called only when the buffer is empty
- * and at least one byte is really needed.
- */
-static int fill_inbuf(void)
-{
-       error("ran out of input data");
-       return 0;
-}
-
-/* ===========================================================================
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_window(void)
-{
-       /* With my window equal to my output buffer
-        * I only need to compute the crc here.
-        */
-       ulg c = crc;         /* temporary variable */
-       unsigned n;
-       uch *in, ch;
-
-       in = window;
-       for (n = 0; n < outcnt; n++) {
-               ch = *in++;
-               c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
-       }
-       crc = c;
-       bytes_out += (ulg)outcnt;
-       outcnt = 0;
-}
-
-static void error(char *x)
-{
-       putstr("\n\n");
-       putstr(x);
-       putstr("\n\n -- System halted");
-
-       while(1);       /* Halt */
-}
-
-asmlinkage void decompress_kernel(void *rmode, unsigned long heap,
-       uch *input_data, unsigned long input_len, uch *output)
-{
-       real_mode = rmode;
-
-       if (RM_SCREEN_INFO.orig_video_mode == 7) {
-               vidmem = (char *) 0xb0000;
-               vidport = 0x3b4;
-       } else {
-               vidmem = (char *) 0xb8000;
-               vidport = 0x3d4;
-       }
-
-       lines = RM_SCREEN_INFO.orig_video_lines;
-       cols = RM_SCREEN_INFO.orig_video_cols;
-
-       window = output;                /* Output buffer (Normally at 1M) */
-       free_mem_ptr     = heap;        /* Heap  */
-       free_mem_end_ptr = heap + HEAP_SIZE;
-       inbuf  = input_data;            /* Input buffer */
-       insize = input_len;
-       inptr  = 0;
-
-       if ((ulg)output & (__KERNEL_ALIGN - 1))
-               error("Destination address not 2M aligned");
-       if ((ulg)output >= 0xffffffffffUL)
-               error("Destination address too large");
-
-       makecrc();
-       putstr(".\nDecompressing Linux...");
-       gunzip();
-       putstr("done.\nBooting the kernel.\n");
-       return;
-}
diff --git a/arch/x86_64/boot/compressed/vmlinux.lds b/arch/x86_64/boot/compressed/vmlinux.lds
deleted file mode 100644 (file)
index 94c13e5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
-OUTPUT_ARCH(i386:x86-64)
-ENTRY(startup_64)
-SECTIONS
-{
-       /* Be careful parts of head.S assume startup_32 is at
-        * address 0.
-        */
-       . = 0;
-       .text : {
-               _head = . ;
-               *(.text.head)
-               _ehead = . ;
-               *(.text.compressed)
-               _text = .;      /* Text */
-               *(.text)
-               *(.text.*)
-               _etext = . ;
-       }
-       .rodata : {
-               _rodata = . ;
-               *(.rodata)       /* read-only data */
-               *(.rodata.*)
-               _erodata = . ;
-       }
-       .data : {
-               _data = . ;
-               *(.data)
-               *(.data.*)
-               _edata = . ;
-       }
-       .bss : {
-               _bss = . ;
-               *(.bss)
-               *(.bss.*)
-               *(COMMON)
-               . = ALIGN(8);
-               _end = . ;
-               . = ALIGN(4096);
-               pgtable = . ;
-               . = . + 4096 * 6;
-               _heap = .;
-       }
-}
diff --git a/arch/x86_64/boot/compressed/vmlinux.scr b/arch/x86_64/boot/compressed/vmlinux.scr
deleted file mode 100644 (file)
index bd1429c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS
-{
-  .text.compressed : {
-       input_len = .;
-       LONG(input_data_end - input_data) input_data = .;
-       *(.data)
-       output_len = . - 4;
-       input_data_end = .;
-       }
-}
diff --git a/arch/x86_64/boot/tools/.gitignore b/arch/x86_64/boot/tools/.gitignore
deleted file mode 100644 (file)
index 378eac2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-build
diff --git a/arch/x86_64/crypto/Makefile b/arch/x86_64/crypto/Makefile
deleted file mode 100644 (file)
index 15b538a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# 
-# x86_64/crypto/Makefile 
-# 
-# Arch-specific CryptoAPI modules.
-# 
-
-obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
-obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
-
-aes-x86_64-y := aes-x86_64-asm.o aes.o
-twofish-x86_64-y := twofish-x86_64-asm.o twofish.o
-
diff --git a/arch/x86_64/crypto/aes-x86_64-asm.S b/arch/x86_64/crypto/aes-x86_64-asm.S
deleted file mode 100644 (file)
index 26b40de..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/* AES (Rijndael) implementation (FIPS PUB 197) for x86_64
- *
- * Copyright (C) 2005 Andreas Steinmetz, <ast@domdv.de>
- *
- * License:
- * This code can be distributed under the terms of the GNU General Public
- * License (GPL) Version 2 provided that the above header down to and
- * including this sentence is retained in full.
- */
-
-.extern aes_ft_tab
-.extern aes_it_tab
-.extern aes_fl_tab
-.extern aes_il_tab
-
-.text
-
-#include <asm/asm-offsets.h>
-
-#define BASE crypto_tfm_ctx_offset
-
-#define R1     %rax
-#define R1E    %eax
-#define R1X    %ax
-#define R1H    %ah
-#define R1L    %al
-#define R2     %rbx
-#define R2E    %ebx
-#define R2X    %bx
-#define R2H    %bh
-#define R2L    %bl
-#define R3     %rcx
-#define R3E    %ecx
-#define R3X    %cx
-#define R3H    %ch
-#define R3L    %cl
-#define R4     %rdx
-#define R4E    %edx
-#define R4X    %dx
-#define R4H    %dh
-#define R4L    %dl
-#define R5     %rsi
-#define R5E    %esi
-#define R6     %rdi
-#define R6E    %edi
-#define R7     %rbp
-#define R7E    %ebp
-#define R8     %r8
-#define R9     %r9
-#define R10    %r10
-#define R11    %r11
-
-#define prologue(FUNC,KEY,B128,B192,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11) \
-       .global FUNC;                   \
-       .type   FUNC,@function;         \
-       .align  8;                      \
-FUNC:  movq    r1,r2;                  \
-       movq    r3,r4;                  \
-       leaq    BASE+KEY+52(r8),r9;     \
-       movq    r10,r11;                \
-       movl    (r7),r5 ## E;           \
-       movl    4(r7),r1 ## E;          \
-       movl    8(r7),r6 ## E;          \
-       movl    12(r7),r7 ## E;         \
-       movl    BASE(r8),r10 ## E;      \
-       xorl    -48(r9),r5 ## E;        \
-       xorl    -44(r9),r1 ## E;        \
-       xorl    -40(r9),r6 ## E;        \
-       xorl    -36(r9),r7 ## E;        \
-       cmpl    $24,r10 ## E;           \
-       jb      B128;                   \
-       leaq    32(r9),r9;              \
-       je      B192;                   \
-       leaq    32(r9),r9;
-
-#define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
-       movq    r1,r2;                  \
-       movq    r3,r4;                  \
-       movl    r5 ## E,(r9);           \
-       movl    r6 ## E,4(r9);          \
-       movl    r7 ## E,8(r9);          \
-       movl    r8 ## E,12(r9);         \
-       ret;
-
-#define round(TAB,OFFSET,r1,r2,r3,r4,r5,r6,r7,r8,ra,rb,rc,rd) \
-       movzbl  r2 ## H,r5 ## E;        \
-       movzbl  r2 ## L,r6 ## E;        \
-       movl    TAB+1024(,r5,4),r5 ## E;\
-       movw    r4 ## X,r2 ## X;        \
-       movl    TAB(,r6,4),r6 ## E;     \
-       roll    $16,r2 ## E;            \
-       shrl    $16,r4 ## E;            \
-       movzbl  r4 ## H,r7 ## E;        \
-       movzbl  r4 ## L,r4 ## E;        \
-       xorl    OFFSET(r8),ra ## E;     \
-       xorl    OFFSET+4(r8),rb ## E;   \
-       xorl    TAB+3072(,r7,4),r5 ## E;\
-       xorl    TAB+2048(,r4,4),r6 ## E;\
-       movzbl  r1 ## L,r7 ## E;        \
-       movzbl  r1 ## H,r4 ## E;        \
-       movl    TAB+1024(,r4,4),r4 ## E;\
-       movw    r3 ## X,r1 ## X;        \
-       roll    $16,r1 ## E;            \
-       shrl    $16,r3 ## E;            \
-       xorl    TAB(,r7,4),r5 ## E;     \
-       movzbl  r3 ## H,r7 ## E;        \
-       movzbl  r3 ## L,r3 ## E;        \
-       xorl    TAB+3072(,r7,4),r4 ## E;\
-       xorl    TAB+2048(,r3,4),r5 ## E;\
-       movzbl  r1 ## H,r7 ## E;        \
-       movzbl  r1 ## L,r3 ## E;        \
-       shrl    $16,r1 ## E;            \
-       xorl    TAB+3072(,r7,4),r6 ## E;\
-       movl    TAB+2048(,r3,4),r3 ## E;\
-       movzbl  r1 ## H,r7 ## E;        \
-       movzbl  r1 ## L,r1 ## E;        \
-       xorl    TAB+1024(,r7,4),r6 ## E;\
-       xorl    TAB(,r1,4),r3 ## E;     \
-       movzbl  r2 ## H,r1 ## E;        \
-       movzbl  r2 ## L,r7 ## E;        \
-       shrl    $16,r2 ## E;            \
-       xorl    TAB+3072(,r1,4),r3 ## E;\
-       xorl    TAB+2048(,r7,4),r4 ## E;\
-       movzbl  r2 ## H,r1 ## E;        \
-       movzbl  r2 ## L,r2 ## E;        \
-       xorl    OFFSET+8(r8),rc ## E;   \
-       xorl    OFFSET+12(r8),rd ## E;  \
-       xorl    TAB+1024(,r1,4),r3 ## E;\
-       xorl    TAB(,r2,4),r4 ## E;
-
-#define move_regs(r1,r2,r3,r4) \
-       movl    r3 ## E,r1 ## E;        \
-       movl    r4 ## E,r2 ## E;
-
-#define entry(FUNC,KEY,B128,B192) \
-       prologue(FUNC,KEY,B128,B192,R2,R8,R7,R9,R1,R3,R4,R6,R10,R5,R11)
-
-#define return epilogue(R8,R2,R9,R7,R5,R6,R3,R4,R11)
-
-#define encrypt_round(TAB,OFFSET) \
-       round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \
-       move_regs(R1,R2,R5,R6)
-
-#define encrypt_final(TAB,OFFSET) \
-       round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4)
-
-#define decrypt_round(TAB,OFFSET) \
-       round(TAB,OFFSET,R2,R1,R4,R3,R6,R5,R7,R10,R5,R6,R3,R4) \
-       move_regs(R1,R2,R5,R6)
-
-#define decrypt_final(TAB,OFFSET) \
-       round(TAB,OFFSET,R2,R1,R4,R3,R6,R5,R7,R10,R5,R6,R3,R4)
-
-/* void aes_enc_blk(stuct crypto_tfm *tfm, u8 *out, const u8 *in) */
-
-       entry(aes_enc_blk,0,enc128,enc192)
-       encrypt_round(aes_ft_tab,-96)
-       encrypt_round(aes_ft_tab,-80)
-enc192:        encrypt_round(aes_ft_tab,-64)
-       encrypt_round(aes_ft_tab,-48)
-enc128:        encrypt_round(aes_ft_tab,-32)
-       encrypt_round(aes_ft_tab,-16)
-       encrypt_round(aes_ft_tab,  0)
-       encrypt_round(aes_ft_tab, 16)
-       encrypt_round(aes_ft_tab, 32)
-       encrypt_round(aes_ft_tab, 48)
-       encrypt_round(aes_ft_tab, 64)
-       encrypt_round(aes_ft_tab, 80)
-       encrypt_round(aes_ft_tab, 96)
-       encrypt_final(aes_fl_tab,112)
-       return
-
-/* void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in) */
-
-       entry(aes_dec_blk,240,dec128,dec192)
-       decrypt_round(aes_it_tab,-96)
-       decrypt_round(aes_it_tab,-80)
-dec192:        decrypt_round(aes_it_tab,-64)
-       decrypt_round(aes_it_tab,-48)
-dec128:        decrypt_round(aes_it_tab,-32)
-       decrypt_round(aes_it_tab,-16)
-       decrypt_round(aes_it_tab,  0)
-       decrypt_round(aes_it_tab, 16)
-       decrypt_round(aes_it_tab, 32)
-       decrypt_round(aes_it_tab, 48)
-       decrypt_round(aes_it_tab, 64)
-       decrypt_round(aes_it_tab, 80)
-       decrypt_round(aes_it_tab, 96)
-       decrypt_final(aes_il_tab,112)
-       return
diff --git a/arch/x86_64/crypto/aes.c b/arch/x86_64/crypto/aes.c
deleted file mode 100644 (file)
index 5cdb13e..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Cryptographic API.
- *
- * AES Cipher Algorithm.
- *
- * Based on Brian Gladman's code.
- *
- * Linux developers:
- *  Alexander Kjeldaas <astor@fast.no>
- *  Herbert Valerio Riedel <hvr@hvrlab.org>
- *  Kyle McMartin <kyle@debian.org>
- *  Adam J. Richter <adam@yggdrasil.com> (conversion to 2.5 API).
- *  Andreas Steinmetz <ast@domdv.de> (adapted to x86_64 assembler)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * ---------------------------------------------------------------------------
- * Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
- * All rights reserved.
- *
- * LICENSE TERMS
- *
- * The free distribution and use of this software in both source and binary
- * form is allowed (with or without changes) provided that:
- *
- *   1. distributions of this source code include the above copyright
- *      notice, this list of conditions and the following disclaimer;
- *
- *   2. distributions in binary form include the above copyright
- *      notice, this list of conditions and the following disclaimer
- *      in the documentation and/or other associated materials;
- *
- *   3. the copyright holder's name is not used to endorse products
- *      built using this software without specific written permission.
- *
- * ALTERNATIVELY, provided that this notice is retained in full, this product
- * may be distributed under the terms of the GNU General Public License (GPL),
- * in which case the provisions of the GPL apply INSTEAD OF those given above.
- *
- * DISCLAIMER
- *
- * This software is provided 'as is' with no explicit or implied warranties
- * in respect of its properties, including, but not limited to, correctness
- * and/or fitness for purpose.
- * ---------------------------------------------------------------------------
- */
-
-/* Some changes from the Gladman version:
-    s/RIJNDAEL(e_key)/E_KEY/g
-    s/RIJNDAEL(d_key)/D_KEY/g
-*/
-
-#include <asm/byteorder.h>
-#include <linux/bitops.h>
-#include <linux/crypto.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/types.h>
-
-#define AES_MIN_KEY_SIZE       16
-#define AES_MAX_KEY_SIZE       32
-
-#define AES_BLOCK_SIZE         16
-
-/*
- * #define byte(x, nr) ((unsigned char)((x) >> (nr*8)))
- */
-static inline u8 byte(const u32 x, const unsigned n)
-{
-       return x >> (n << 3);
-}
-
-struct aes_ctx
-{
-       u32 key_length;
-       u32 buf[120];
-};
-
-#define E_KEY (&ctx->buf[0])
-#define D_KEY (&ctx->buf[60])
-
-static u8 pow_tab[256] __initdata;
-static u8 log_tab[256] __initdata;
-static u8 sbx_tab[256] __initdata;
-static u8 isb_tab[256] __initdata;
-static u32 rco_tab[10];
-u32 aes_ft_tab[4][256];
-u32 aes_it_tab[4][256];
-
-u32 aes_fl_tab[4][256];
-u32 aes_il_tab[4][256];
-
-static inline u8 f_mult(u8 a, u8 b)
-{
-       u8 aa = log_tab[a], cc = aa + log_tab[b];
-
-       return pow_tab[cc + (cc < aa ? 1 : 0)];
-}
-
-#define ff_mult(a, b) (a && b ? f_mult(a, b) : 0)
-
-#define ls_box(x)                              \
-       (aes_fl_tab[0][byte(x, 0)] ^            \
-        aes_fl_tab[1][byte(x, 1)] ^            \
-        aes_fl_tab[2][byte(x, 2)] ^            \
-        aes_fl_tab[3][byte(x, 3)])
-
-static void __init gen_tabs(void)
-{
-       u32 i, t;
-       u8 p, q;
-
-       /* log and power tables for GF(2**8) finite field with
-          0x011b as modular polynomial - the simplest primitive
-          root is 0x03, used here to generate the tables */
-
-       for (i = 0, p = 1; i < 256; ++i) {
-               pow_tab[i] = (u8)p;
-               log_tab[p] = (u8)i;
-
-               p ^= (p << 1) ^ (p & 0x80 ? 0x01b : 0);
-       }
-
-       log_tab[1] = 0;
-
-       for (i = 0, p = 1; i < 10; ++i) {
-               rco_tab[i] = p;
-
-               p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
-       }
-
-       for (i = 0; i < 256; ++i) {
-               p = (i ? pow_tab[255 - log_tab[i]] : 0);
-               q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
-               p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
-               sbx_tab[i] = p;
-               isb_tab[p] = (u8)i;
-       }
-
-       for (i = 0; i < 256; ++i) {
-               p = sbx_tab[i];
-
-               t = p;
-               aes_fl_tab[0][i] = t;
-               aes_fl_tab[1][i] = rol32(t, 8);
-               aes_fl_tab[2][i] = rol32(t, 16);
-               aes_fl_tab[3][i] = rol32(t, 24);
-
-               t = ((u32)ff_mult(2, p)) |
-                   ((u32)p << 8) |
-                   ((u32)p << 16) | ((u32)ff_mult(3, p) << 24);
-
-               aes_ft_tab[0][i] = t;
-               aes_ft_tab[1][i] = rol32(t, 8);
-               aes_ft_tab[2][i] = rol32(t, 16);
-               aes_ft_tab[3][i] = rol32(t, 24);
-
-               p = isb_tab[i];
-
-               t = p;
-               aes_il_tab[0][i] = t;
-               aes_il_tab[1][i] = rol32(t, 8);
-               aes_il_tab[2][i] = rol32(t, 16);
-               aes_il_tab[3][i] = rol32(t, 24);
-
-               t = ((u32)ff_mult(14, p)) |
-                   ((u32)ff_mult(9, p) << 8) |
-                   ((u32)ff_mult(13, p) << 16) |
-                   ((u32)ff_mult(11, p) << 24);
-
-               aes_it_tab[0][i] = t;
-               aes_it_tab[1][i] = rol32(t, 8);
-               aes_it_tab[2][i] = rol32(t, 16);
-               aes_it_tab[3][i] = rol32(t, 24);
-       }
-}
-
-#define star_x(x) (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
-
-#define imix_col(y, x)                 \
-       u    = star_x(x);               \
-       v    = star_x(u);               \
-       w    = star_x(v);               \
-       t    = w ^ (x);                 \
-       (y)  = u ^ v ^ w;               \
-       (y) ^= ror32(u ^ t,  8) ^       \
-              ror32(v ^ t, 16) ^       \
-              ror32(t, 24)
-
-/* initialise the key schedule from the user supplied key */
-
-#define loop4(i)                                       \
-{                                                      \
-       t = ror32(t,  8); t = ls_box(t) ^ rco_tab[i];   \
-       t ^= E_KEY[4 * i];     E_KEY[4 * i + 4] = t;    \
-       t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t;    \
-       t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t;    \
-       t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t;    \
-}
-
-#define loop6(i)                                       \
-{                                                      \
-       t = ror32(t,  8); t = ls_box(t) ^ rco_tab[i];   \
-       t ^= E_KEY[6 * i];     E_KEY[6 * i + 6] = t;    \
-       t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t;    \
-       t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t;    \
-       t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t;    \
-       t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t;   \
-       t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t;   \
-}
-
-#define loop8(i)                                       \
-{                                                      \
-       t = ror32(t,  8); ; t = ls_box(t) ^ rco_tab[i]; \
-       t ^= E_KEY[8 * i];     E_KEY[8 * i + 8] = t;    \
-       t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t;    \
-       t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t;   \
-       t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t;   \
-       t  = E_KEY[8 * i + 4] ^ ls_box(t);              \
-       E_KEY[8 * i + 12] = t;                          \
-       t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t;   \
-       t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t;   \
-       t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t;   \
-}
-
-static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len)
-{
-       struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
-       const __le32 *key = (const __le32 *)in_key;
-       u32 *flags = &tfm->crt_flags;
-       u32 i, j, t, u, v, w;
-
-       if (key_len % 8) {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
-
-       ctx->key_length = key_len;
-
-       D_KEY[key_len + 24] = E_KEY[0] = le32_to_cpu(key[0]);
-       D_KEY[key_len + 25] = E_KEY[1] = le32_to_cpu(key[1]);
-       D_KEY[key_len + 26] = E_KEY[2] = le32_to_cpu(key[2]);
-       D_KEY[key_len + 27] = E_KEY[3] = le32_to_cpu(key[3]);
-
-       switch (key_len) {
-       case 16:
-               t = E_KEY[3];
-               for (i = 0; i < 10; ++i)
-                       loop4(i);
-               break;
-
-       case 24:
-               E_KEY[4] = le32_to_cpu(key[4]);
-               t = E_KEY[5] = le32_to_cpu(key[5]);
-               for (i = 0; i < 8; ++i)
-                       loop6 (i);
-               break;
-
-       case 32:
-               E_KEY[4] = le32_to_cpu(key[4]);
-               E_KEY[5] = le32_to_cpu(key[5]);
-               E_KEY[6] = le32_to_cpu(key[6]);
-               t = E_KEY[7] = le32_to_cpu(key[7]);
-               for (i = 0; i < 7; ++i)
-                       loop8(i);
-               break;
-       }
-
-       D_KEY[0] = E_KEY[key_len + 24];
-       D_KEY[1] = E_KEY[key_len + 25];
-       D_KEY[2] = E_KEY[key_len + 26];
-       D_KEY[3] = E_KEY[key_len + 27];
-
-       for (i = 4; i < key_len + 24; ++i) {
-               j = key_len + 24 - (i & ~3) + (i & 3);
-               imix_col(D_KEY[j], E_KEY[i]);
-       }
-
-       return 0;
-}
-
-asmlinkage void aes_enc_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in);
-asmlinkage void aes_dec_blk(struct crypto_tfm *tfm, u8 *out, const u8 *in);
-
-static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
-{
-       aes_enc_blk(tfm, dst, src);
-}
-
-static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
-{
-       aes_dec_blk(tfm, dst, src);
-}
-
-static struct crypto_alg aes_alg = {
-       .cra_name               =       "aes",
-       .cra_driver_name        =       "aes-x86_64",
-       .cra_priority           =       200,
-       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
-       .cra_blocksize          =       AES_BLOCK_SIZE,
-       .cra_ctxsize            =       sizeof(struct aes_ctx),
-       .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(aes_alg.cra_list),
-       .cra_u                  =       {
-               .cipher = {
-                       .cia_min_keysize        =       AES_MIN_KEY_SIZE,
-                       .cia_max_keysize        =       AES_MAX_KEY_SIZE,
-                       .cia_setkey             =       aes_set_key,
-                       .cia_encrypt            =       aes_encrypt,
-                       .cia_decrypt            =       aes_decrypt
-               }
-       }
-};
-
-static int __init aes_init(void)
-{
-       gen_tabs();
-       return crypto_register_alg(&aes_alg);
-}
-
-static void __exit aes_fini(void)
-{
-       crypto_unregister_alg(&aes_alg);
-}
-
-module_init(aes_init);
-module_exit(aes_fini);
-
-MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("aes");
diff --git a/arch/x86_64/crypto/twofish-x86_64-asm.S b/arch/x86_64/crypto/twofish-x86_64-asm.S
deleted file mode 100644 (file)
index 35974a5..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/***************************************************************************
-*   Copyright (C) 2006 by Joachim Fritschi, <jfritschi@freenet.de>        *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-.file "twofish-x86_64-asm.S"
-.text
-
-#include <asm/asm-offsets.h>
-
-#define a_offset       0
-#define b_offset       4
-#define c_offset       8
-#define d_offset       12
-
-/* Structure of the crypto context struct*/
-
-#define s0     0       /* S0 Array 256 Words each */
-#define s1     1024    /* S1 Array */
-#define s2     2048    /* S2 Array */
-#define s3     3072    /* S3 Array */
-#define w      4096    /* 8 whitening keys (word) */
-#define k      4128    /* key 1-32 ( word ) */
-
-/* define a few register aliases to allow macro substitution */
-
-#define R0     %rax
-#define R0D    %eax
-#define R0B    %al
-#define R0H    %ah
-
-#define R1     %rbx
-#define R1D    %ebx
-#define R1B    %bl
-#define R1H    %bh
-
-#define R2     %rcx
-#define R2D    %ecx
-#define R2B    %cl
-#define R2H    %ch
-
-#define R3     %rdx
-#define R3D    %edx
-#define R3B    %dl
-#define R3H    %dh
-
-
-/* performs input whitening */
-#define input_whitening(src,context,offset)\
-       xor     w+offset(context),      src;
-
-/* performs input whitening */
-#define output_whitening(src,context,offset)\
-       xor     w+16+offset(context),   src;
-
-
-/*
- * a input register containing a (rotated 16)
- * b input register containing b
- * c input register containing c
- * d input register containing d (already rol $1)
- * operations on a and b are interleaved to increase performance
- */
-#define encrypt_round(a,b,c,d,round)\
-       movzx   b ## B,         %edi;\
-       mov     s1(%r11,%rdi,4),%r8d;\
-       movzx   a ## B,         %edi;\
-       mov     s2(%r11,%rdi,4),%r9d;\
-       movzx   b ## H,         %edi;\
-       ror     $16,            b ## D;\
-       xor     s2(%r11,%rdi,4),%r8d;\
-       movzx   a ## H,         %edi;\
-       ror     $16,            a ## D;\
-       xor     s3(%r11,%rdi,4),%r9d;\
-       movzx   b ## B,         %edi;\
-       xor     s3(%r11,%rdi,4),%r8d;\
-       movzx   a ## B,         %edi;\
-       xor     (%r11,%rdi,4),  %r9d;\
-       movzx   b ## H,         %edi;\
-       ror     $15,            b ## D;\
-       xor     (%r11,%rdi,4),  %r8d;\
-       movzx   a ## H,         %edi;\
-       xor     s1(%r11,%rdi,4),%r9d;\
-       add     %r8d,           %r9d;\
-       add     %r9d,           %r8d;\
-       add     k+round(%r11),  %r9d;\
-       xor     %r9d,           c ## D;\
-       rol     $15,            c ## D;\
-       add     k+4+round(%r11),%r8d;\
-       xor     %r8d,           d ## D;
-
-/*
- * a input register containing a(rotated 16)
- * b input register containing b
- * c input register containing c
- * d input register containing d (already rol $1)
- * operations on a and b are interleaved to increase performance
- * during the round a and b are prepared for the output whitening
- */
-#define encrypt_last_round(a,b,c,d,round)\
-       mov     b ## D,         %r10d;\
-       shl     $32,            %r10;\
-       movzx   b ## B,         %edi;\
-       mov     s1(%r11,%rdi,4),%r8d;\
-       movzx   a ## B,         %edi;\
-       mov     s2(%r11,%rdi,4),%r9d;\
-       movzx   b ## H,         %edi;\
-       ror     $16,            b ## D;\
-       xor     s2(%r11,%rdi,4),%r8d;\
-       movzx   a ## H,         %edi;\
-       ror     $16,            a ## D;\
-       xor     s3(%r11,%rdi,4),%r9d;\
-       movzx   b ## B,         %edi;\
-       xor     s3(%r11,%rdi,4),%r8d;\
-       movzx   a ## B,         %edi;\
-       xor     (%r11,%rdi,4),  %r9d;\
-       xor     a,              %r10;\
-       movzx   b ## H,         %edi;\
-       xor     (%r11,%rdi,4),  %r8d;\
-       movzx   a ## H,         %edi;\
-       xor     s1(%r11,%rdi,4),%r9d;\
-       add     %r8d,           %r9d;\
-       add     %r9d,           %r8d;\
-       add     k+round(%r11),  %r9d;\
-       xor     %r9d,           c ## D;\
-       ror     $1,             c ## D;\
-       add     k+4+round(%r11),%r8d;\
-       xor     %r8d,           d ## D
-
-/*
- * a input register containing a
- * b input register containing b (rotated 16)
- * c input register containing c (already rol $1)
- * d input register containing d
- * operations on a and b are interleaved to increase performance
- */
-#define decrypt_round(a,b,c,d,round)\
-       movzx   a ## B,         %edi;\
-       mov     (%r11,%rdi,4),  %r9d;\
-       movzx   b ## B,         %edi;\
-       mov     s3(%r11,%rdi,4),%r8d;\
-       movzx   a ## H,         %edi;\
-       ror     $16,            a ## D;\
-       xor     s1(%r11,%rdi,4),%r9d;\
-       movzx   b ## H,         %edi;\
-       ror     $16,            b ## D;\
-       xor     (%r11,%rdi,4),  %r8d;\
-       movzx   a ## B,         %edi;\
-       xor     s2(%r11,%rdi,4),%r9d;\
-       movzx   b ## B,         %edi;\
-       xor     s1(%r11,%rdi,4),%r8d;\
-       movzx   a ## H,         %edi;\
-       ror     $15,            a ## D;\
-       xor     s3(%r11,%rdi,4),%r9d;\
-       movzx   b ## H,         %edi;\
-       xor     s2(%r11,%rdi,4),%r8d;\
-       add     %r8d,           %r9d;\
-       add     %r9d,           %r8d;\
-       add     k+round(%r11),  %r9d;\
-       xor     %r9d,           c ## D;\
-       add     k+4+round(%r11),%r8d;\
-       xor     %r8d,           d ## D;\
-       rol     $15,            d ## D;
-
-/*
- * a input register containing a
- * b input register containing b
- * c input register containing c (already rol $1)
- * d input register containing d
- * operations on a and b are interleaved to increase performance
- * during the round a and b are prepared for the output whitening
- */
-#define decrypt_last_round(a,b,c,d,round)\
-       movzx   a ## B,         %edi;\
-       mov     (%r11,%rdi,4),  %r9d;\
-       movzx   b ## B,         %edi;\
-       mov     s3(%r11,%rdi,4),%r8d;\
-       movzx   b ## H,         %edi;\
-       ror     $16,            b ## D;\
-       xor     (%r11,%rdi,4),  %r8d;\
-       movzx   a ## H,         %edi;\
-       mov     b ## D,         %r10d;\
-       shl     $32,            %r10;\
-       xor     a,              %r10;\
-       ror     $16,            a ## D;\
-       xor     s1(%r11,%rdi,4),%r9d;\
-       movzx   b ## B,         %edi;\
-       xor     s1(%r11,%rdi,4),%r8d;\
-       movzx   a ## B,         %edi;\
-       xor     s2(%r11,%rdi,4),%r9d;\
-       movzx   b ## H,         %edi;\
-       xor     s2(%r11,%rdi,4),%r8d;\
-       movzx   a ## H,         %edi;\
-       xor     s3(%r11,%rdi,4),%r9d;\
-       add     %r8d,           %r9d;\
-       add     %r9d,           %r8d;\
-       add     k+round(%r11),  %r9d;\
-       xor     %r9d,           c ## D;\
-       add     k+4+round(%r11),%r8d;\
-       xor     %r8d,           d ## D;\
-       ror     $1,             d ## D;
-
-.align 8
-.global twofish_enc_blk
-.global twofish_dec_blk
-
-twofish_enc_blk:
-       pushq    R1
-
-       /* %rdi contains the crypto tfm adress */
-       /* %rsi contains the output adress */
-       /* %rdx contains the input adress */
-       add     $crypto_tfm_ctx_offset, %rdi    /* set ctx adress */
-       /* ctx adress is moved to free one non-rex register
-       as target for the 8bit high operations */
-       mov     %rdi,           %r11
-
-       movq    (R3),   R1
-       movq    8(R3),  R3
-       input_whitening(R1,%r11,a_offset)
-       input_whitening(R3,%r11,c_offset)
-       mov     R1D,    R0D
-       rol     $16,    R0D
-       shr     $32,    R1
-       mov     R3D,    R2D
-       shr     $32,    R3
-       rol     $1,     R3D
-
-       encrypt_round(R0,R1,R2,R3,0);
-       encrypt_round(R2,R3,R0,R1,8);
-       encrypt_round(R0,R1,R2,R3,2*8);
-       encrypt_round(R2,R3,R0,R1,3*8);
-       encrypt_round(R0,R1,R2,R3,4*8);
-       encrypt_round(R2,R3,R0,R1,5*8);
-       encrypt_round(R0,R1,R2,R3,6*8);
-       encrypt_round(R2,R3,R0,R1,7*8);
-       encrypt_round(R0,R1,R2,R3,8*8);
-       encrypt_round(R2,R3,R0,R1,9*8);
-       encrypt_round(R0,R1,R2,R3,10*8);
-       encrypt_round(R2,R3,R0,R1,11*8);
-       encrypt_round(R0,R1,R2,R3,12*8);
-       encrypt_round(R2,R3,R0,R1,13*8);
-       encrypt_round(R0,R1,R2,R3,14*8);
-       encrypt_last_round(R2,R3,R0,R1,15*8);
-
-
-       output_whitening(%r10,%r11,a_offset)
-       movq    %r10,   (%rsi)
-
-       shl     $32,    R1
-       xor     R0,     R1
-
-       output_whitening(R1,%r11,c_offset)
-       movq    R1,     8(%rsi)
-
-       popq    R1
-       movq    $1,%rax
-       ret
-
-twofish_dec_blk:
-       pushq    R1
-
-       /* %rdi contains the crypto tfm adress */
-       /* %rsi contains the output adress */
-       /* %rdx contains the input adress */
-       add     $crypto_tfm_ctx_offset, %rdi    /* set ctx adress */
-       /* ctx adress is moved to free one non-rex register
-       as target for the 8bit high operations */
-       mov     %rdi,           %r11
-
-       movq    (R3),   R1
-       movq    8(R3),  R3
-       output_whitening(R1,%r11,a_offset)
-       output_whitening(R3,%r11,c_offset)
-       mov     R1D,    R0D
-       shr     $32,    R1
-       rol     $16,    R1D
-       mov     R3D,    R2D
-       shr     $32,    R3
-       rol     $1,     R2D
-
-       decrypt_round(R0,R1,R2,R3,15*8);
-       decrypt_round(R2,R3,R0,R1,14*8);
-       decrypt_round(R0,R1,R2,R3,13*8);
-       decrypt_round(R2,R3,R0,R1,12*8);
-       decrypt_round(R0,R1,R2,R3,11*8);
-       decrypt_round(R2,R3,R0,R1,10*8);
-       decrypt_round(R0,R1,R2,R3,9*8);
-       decrypt_round(R2,R3,R0,R1,8*8);
-       decrypt_round(R0,R1,R2,R3,7*8);
-       decrypt_round(R2,R3,R0,R1,6*8);
-       decrypt_round(R0,R1,R2,R3,5*8);
-       decrypt_round(R2,R3,R0,R1,4*8);
-       decrypt_round(R0,R1,R2,R3,3*8);
-       decrypt_round(R2,R3,R0,R1,2*8);
-       decrypt_round(R0,R1,R2,R3,1*8);
-       decrypt_last_round(R2,R3,R0,R1,0);
-
-       input_whitening(%r10,%r11,a_offset)
-       movq    %r10,   (%rsi)
-
-       shl     $32,    R1
-       xor     R0,     R1
-
-       input_whitening(R1,%r11,c_offset)
-       movq    R1,     8(%rsi)
-
-       popq    R1
-       movq    $1,%rax
-       ret
diff --git a/arch/x86_64/crypto/twofish.c b/arch/x86_64/crypto/twofish.c
deleted file mode 100644 (file)
index 182d91d..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Glue Code for optimized x86_64 assembler version of TWOFISH
- *
- * Originally Twofish for GPG
- * By Matthew Skala <mskala@ansuz.sooke.bc.ca>, July 26, 1998
- * 256-bit key length added March 20, 1999
- * Some modifications to reduce the text size by Werner Koch, April, 1998
- * Ported to the kerneli patch by Marc Mutz <Marc@Mutz.com>
- * Ported to CryptoAPI by Colin Slater <hoho@tacomeat.net>
- *
- * The original author has disclaimed all copyright interest in this
- * code and thus put it in the public domain. The subsequent authors
- * have put this under the GNU General Public License.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
- * USA
- *
- * This code is a "clean room" implementation, written from the paper
- * _Twofish: A 128-Bit Block Cipher_ by Bruce Schneier, John Kelsey,
- * Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson, available
- * through http://www.counterpane.com/twofish.html
- *
- * For background information on multiplication in finite fields, used for
- * the matrix operations in the key schedule, see the book _Contemporary
- * Abstract Algebra_ by Joseph A. Gallian, especially chapter 22 in the
- * Third Edition.
- */
-
-#include <crypto/twofish.h>
-#include <linux/crypto.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-
-asmlinkage void twofish_enc_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
-asmlinkage void twofish_dec_blk(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
-
-static void twofish_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
-{
-       twofish_enc_blk(tfm, dst, src);
-}
-
-static void twofish_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
-{
-       twofish_dec_blk(tfm, dst, src);
-}
-
-static struct crypto_alg alg = {
-       .cra_name               =       "twofish",
-       .cra_driver_name        =       "twofish-x86_64",
-       .cra_priority           =       200,
-       .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
-       .cra_blocksize          =       TF_BLOCK_SIZE,
-       .cra_ctxsize            =       sizeof(struct twofish_ctx),
-       .cra_alignmask          =       3,
-       .cra_module             =       THIS_MODULE,
-       .cra_list               =       LIST_HEAD_INIT(alg.cra_list),
-       .cra_u                  =       {
-               .cipher = {
-                       .cia_min_keysize        =       TF_MIN_KEY_SIZE,
-                       .cia_max_keysize        =       TF_MAX_KEY_SIZE,
-                       .cia_setkey             =       twofish_setkey,
-                       .cia_encrypt            =       twofish_encrypt,
-                       .cia_decrypt            =       twofish_decrypt
-               }
-       }
-};
-
-static int __init init(void)
-{
-       return crypto_register_alg(&alg);
-}
-
-static void __exit fini(void)
-{
-       crypto_unregister_alg(&alg);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION ("Twofish Cipher Algorithm, x86_64 asm optimized");
-MODULE_ALIAS("twofish");
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
deleted file mode 100644 (file)
index b091c5e..0000000
+++ /dev/null
@@ -1,1388 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.22-git14
-# Fri Jul 20 09:53:15 2007
-#
-CONFIG_X86_64=y
-CONFIG_64BIT=y
-CONFIG_X86=y
-CONFIG_GENERIC_TIME=y
-CONFIG_GENERIC_TIME_VSYSCALL=y
-CONFIG_GENERIC_CMOS_UPDATE=y
-CONFIG_ZONE_DMA32=y
-CONFIG_LOCKDEP_SUPPORT=y
-CONFIG_STACKTRACE_SUPPORT=y
-CONFIG_SEMAPHORE_SLEEPERS=y
-CONFIG_MMU=y
-CONFIG_ZONE_DMA=y
-CONFIG_QUICKLIST=y
-CONFIG_NR_QUICK=2
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_GENERIC_HWEIGHT=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-CONFIG_X86_CMPXCHG=y
-CONFIG_EARLY_PRINTK=y
-CONFIG_GENERIC_ISA_DMA=y
-CONFIG_GENERIC_IOMAP=y
-CONFIG_ARCH_MAY_HAVE_PC_FDC=y
-CONFIG_ARCH_POPULATES_NODE_MAP=y
-CONFIG_DMI=y
-CONFIG_AUDIT_ARCH=y
-CONFIG_GENERIC_BUG=y
-# CONFIG_ARCH_HAS_ILOG2_U32 is not set
-# CONFIG_ARCH_HAS_ILOG2_U64 is not set
-CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_LOCK_KERNEL=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
-CONFIG_LOCALVERSION=""
-CONFIG_LOCALVERSION_AUTO=y
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-CONFIG_SYSVIPC_SYSCTL=y
-CONFIG_POSIX_MQUEUE=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_TASKSTATS is not set
-# CONFIG_USER_NS is not set
-# CONFIG_AUDIT is not set
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_LOG_BUF_SHIFT=18
-# CONFIG_CPUSETS is not set
-CONFIG_SYSFS_DEPRECATED=y
-CONFIG_RELAY=y
-CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SYSCTL=y
-# CONFIG_EMBEDDED is not set
-CONFIG_UID16=y
-CONFIG_SYSCTL_SYSCALL=y
-CONFIG_KALLSYMS=y
-CONFIG_KALLSYMS_ALL=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_HOTPLUG=y
-CONFIG_PRINTK=y
-CONFIG_BUG=y
-CONFIG_ELF_CORE=y
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
-CONFIG_EPOLL=y
-CONFIG_SIGNALFD=y
-CONFIG_TIMERFD=y
-CONFIG_EVENTFD=y
-CONFIG_SHMEM=y
-CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_SLAB=y
-# CONFIG_SLUB is not set
-# CONFIG_SLOB is not set
-CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
-CONFIG_BASE_SMALL=0
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_MODULE_FORCE_UNLOAD=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-# CONFIG_KMOD is not set
-CONFIG_STOP_MACHINE=y
-CONFIG_BLOCK=y
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_BLK_DEV_BSG is not set
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_DEFAULT_AS is not set
-# CONFIG_DEFAULT_DEADLINE is not set
-CONFIG_DEFAULT_CFQ=y
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="cfq"
-
-#
-# Processor type and features
-#
-CONFIG_X86_PC=y
-# CONFIG_X86_VSMP is not set
-# CONFIG_MK8 is not set
-# CONFIG_MPSC is not set
-# CONFIG_MCORE2 is not set
-CONFIG_GENERIC_CPU=y
-CONFIG_X86_L1_CACHE_BYTES=128
-CONFIG_X86_L1_CACHE_SHIFT=7
-CONFIG_X86_INTERNODE_CACHE_BYTES=128
-CONFIG_X86_TSC=y
-CONFIG_X86_GOOD_APIC=y
-# CONFIG_MICROCODE is not set
-CONFIG_X86_MSR=y
-CONFIG_X86_CPUID=y
-CONFIG_X86_HT=y
-CONFIG_X86_IO_APIC=y
-CONFIG_X86_LOCAL_APIC=y
-CONFIG_MTRR=y
-CONFIG_SMP=y
-CONFIG_SCHED_SMT=y
-CONFIG_SCHED_MC=y
-# CONFIG_PREEMPT_NONE is not set
-CONFIG_PREEMPT_VOLUNTARY=y
-# CONFIG_PREEMPT is not set
-CONFIG_PREEMPT_BKL=y
-CONFIG_NUMA=y
-CONFIG_K8_NUMA=y
-CONFIG_NODES_SHIFT=6
-CONFIG_X86_64_ACPI_NUMA=y
-CONFIG_NUMA_EMU=y
-CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
-CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
-CONFIG_ARCH_SPARSEMEM_ENABLE=y
-CONFIG_SELECT_MEMORY_MODEL=y
-# CONFIG_FLATMEM_MANUAL is not set
-CONFIG_DISCONTIGMEM_MANUAL=y
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_DISCONTIGMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-CONFIG_NEED_MULTIPLE_NODES=y
-# CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4
-CONFIG_MIGRATION=y
-CONFIG_RESOURCES_64BIT=y
-CONFIG_ZONE_DMA_FLAG=1
-CONFIG_BOUNCE=y
-CONFIG_VIRT_TO_BUS=y
-CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
-CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y
-CONFIG_NR_CPUS=32
-CONFIG_PHYSICAL_ALIGN=0x200000
-CONFIG_HOTPLUG_CPU=y
-CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
-CONFIG_HPET_TIMER=y
-CONFIG_HPET_EMULATE_RTC=y
-CONFIG_IOMMU=y
-# CONFIG_CALGARY_IOMMU is not set
-CONFIG_SWIOTLB=y
-CONFIG_X86_MCE=y
-CONFIG_X86_MCE_INTEL=y
-CONFIG_X86_MCE_AMD=y
-# CONFIG_KEXEC is not set
-# CONFIG_CRASH_DUMP is not set
-# CONFIG_RELOCATABLE is not set
-CONFIG_PHYSICAL_START=0x200000
-CONFIG_SECCOMP=y
-# CONFIG_CC_STACKPROTECTOR is not set
-# CONFIG_HZ_100 is not set
-CONFIG_HZ_250=y
-# CONFIG_HZ_300 is not set
-# CONFIG_HZ_1000 is not set
-CONFIG_HZ=250
-CONFIG_K8_NB=y
-CONFIG_GENERIC_HARDIRQS=y
-CONFIG_GENERIC_IRQ_PROBE=y
-CONFIG_ISA_DMA_API=y
-CONFIG_GENERIC_PENDING_IRQ=y
-
-#
-# Power management options
-#
-CONFIG_PM=y
-# CONFIG_PM_LEGACY is not set
-# CONFIG_PM_DEBUG is not set
-CONFIG_HIBERNATION=y
-CONFIG_PM_STD_PARTITION=""
-
-#
-# ACPI (Advanced Configuration and Power Interface) Support
-#
-CONFIG_ACPI=y
-CONFIG_ACPI_SLEEP=y
-CONFIG_ACPI_SLEEP_PROC_FS=y
-CONFIG_ACPI_SLEEP_PROC_SLEEP=y
-CONFIG_ACPI_PROCFS=y
-CONFIG_ACPI_AC=y
-CONFIG_ACPI_BATTERY=y
-CONFIG_ACPI_BUTTON=y
-CONFIG_ACPI_FAN=y
-# CONFIG_ACPI_DOCK is not set
-CONFIG_ACPI_PROCESSOR=y
-CONFIG_ACPI_HOTPLUG_CPU=y
-CONFIG_ACPI_THERMAL=y
-CONFIG_ACPI_NUMA=y
-# CONFIG_ACPI_ASUS is not set
-# CONFIG_ACPI_TOSHIBA is not set
-CONFIG_ACPI_BLACKLIST_YEAR=0
-# CONFIG_ACPI_DEBUG is not set
-CONFIG_ACPI_EC=y
-CONFIG_ACPI_POWER=y
-CONFIG_ACPI_SYSTEM=y
-CONFIG_X86_PM_TIMER=y
-CONFIG_ACPI_CONTAINER=y
-# CONFIG_ACPI_SBS is not set
-
-#
-# CPU Frequency scaling
-#
-CONFIG_CPU_FREQ=y
-CONFIG_CPU_FREQ_TABLE=y
-CONFIG_CPU_FREQ_DEBUG=y
-CONFIG_CPU_FREQ_STAT=y
-# CONFIG_CPU_FREQ_STAT_DETAILS is not set
-CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
-# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
-CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
-# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
-CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_GOV_ONDEMAND=y
-CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
-
-#
-# CPUFreq processor drivers
-#
-CONFIG_X86_POWERNOW_K8=y
-CONFIG_X86_POWERNOW_K8_ACPI=y
-# CONFIG_X86_SPEEDSTEP_CENTRINO is not set
-CONFIG_X86_ACPI_CPUFREQ=y
-
-#
-# shared options
-#
-CONFIG_X86_ACPI_CPUFREQ_PROC_INTF=y
-# CONFIG_X86_SPEEDSTEP_LIB is not set
-
-#
-# Bus options (PCI etc.)
-#
-CONFIG_PCI=y
-CONFIG_PCI_DIRECT=y
-CONFIG_PCI_MMCONFIG=y
-CONFIG_PCIEPORTBUS=y
-CONFIG_PCIEAER=y
-CONFIG_ARCH_SUPPORTS_MSI=y
-CONFIG_PCI_MSI=y
-# CONFIG_PCI_DEBUG is not set
-# CONFIG_HT_IRQ is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
-# CONFIG_PCCARD is not set
-# CONFIG_HOTPLUG_PCI is not set
-
-#
-# Executable file formats / Emulations
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_IA32_EMULATION=y
-CONFIG_IA32_AOUT=y
-CONFIG_COMPAT=y
-CONFIG_SYSVIPC_COMPAT=y
-
-#
-# Networking
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_XFRM_TUNNEL is not set
-CONFIG_INET_TUNNEL=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_CUBIC=y
-CONFIG_DEFAULT_TCP_CONG="cubic"
-# CONFIG_TCP_MD5SIG is not set
-CONFIG_IPV6=y
-# CONFIG_IPV6_PRIVACY is not set
-# CONFIG_IPV6_ROUTER_PREF is not set
-# CONFIG_IPV6_OPTIMISTIC_DAD is not set
-# CONFIG_INET6_AH is not set
-# CONFIG_INET6_ESP is not set
-# CONFIG_INET6_IPCOMP is not set
-# CONFIG_IPV6_MIP6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
-# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET6_XFRM_MODE_BEET is not set
-# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
-CONFIG_IPV6_SIT=y
-# CONFIG_IPV6_TUNNEL is not set
-# CONFIG_IPV6_MULTIPLE_TABLES is not set
-# CONFIG_NETWORK_SECMARK is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_IP_DCCP is not set
-# CONFIG_IP_SCTP is not set
-# CONFIG_TIPC is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NET_TCPPROBE is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_AF_RXRPC is not set
-
-#
-# Wireless
-#
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
-# CONFIG_RFKILL is not set
-# CONFIG_NET_9P is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-CONFIG_FW_LOADER=y
-# CONFIG_DEBUG_DRIVER is not set
-# CONFIG_DEBUG_DEVRES is not set
-# CONFIG_SYS_HYPERVISOR is not set
-# CONFIG_CONNECTOR is not set
-# CONFIG_MTD is not set
-# CONFIG_PARPORT is not set
-CONFIG_PNP=y
-# CONFIG_PNP_DEBUG is not set
-
-#
-# Protocols
-#
-CONFIG_PNPACPI=y
-CONFIG_BLK_DEV=y
-CONFIG_BLK_DEV_FD=y
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-# CONFIG_BLK_DEV_UB is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-CONFIG_MISC_DEVICES=y
-# CONFIG_IBM_ASM is not set
-# CONFIG_PHANTOM is not set
-# CONFIG_EEPROM_93CX6 is not set
-# CONFIG_SGI_IOC4 is not set
-# CONFIG_TIFM_CORE is not set
-# CONFIG_SONY_LAPTOP is not set
-# CONFIG_THINKPAD_ACPI is not set
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_IDE_SATA is not set
-# CONFIG_BLK_DEV_HD_IDE is not set
-CONFIG_BLK_DEV_IDEDISK=y
-CONFIG_IDEDISK_MULTI_MODE=y
-CONFIG_BLK_DEV_IDECD=y
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_BLK_DEV_IDESCSI is not set
-CONFIG_BLK_DEV_IDEACPI=y
-# CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_PROC_FS=y
-
-#
-# IDE chipset support/bugfixes
-#
-CONFIG_IDE_GENERIC=y
-# CONFIG_BLK_DEV_CMD640 is not set
-# CONFIG_BLK_DEV_IDEPNP is not set
-CONFIG_BLK_DEV_IDEPCI=y
-# CONFIG_IDEPCI_SHARE_IRQ is not set
-CONFIG_IDEPCI_PCIBUS_ORDER=y
-# CONFIG_BLK_DEV_OFFBOARD is not set
-# CONFIG_BLK_DEV_GENERIC is not set
-# CONFIG_BLK_DEV_OPTI621 is not set
-# CONFIG_BLK_DEV_RZ1000 is not set
-CONFIG_BLK_DEV_IDEDMA_PCI=y
-# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
-# CONFIG_IDEDMA_ONLYDISK is not set
-# CONFIG_BLK_DEV_AEC62XX is not set
-# CONFIG_BLK_DEV_ALI15X3 is not set
-CONFIG_BLK_DEV_AMD74XX=y
-CONFIG_BLK_DEV_ATIIXP=y
-# CONFIG_BLK_DEV_CMD64X is not set
-# CONFIG_BLK_DEV_TRIFLEX is not set
-# CONFIG_BLK_DEV_CY82C693 is not set
-# CONFIG_BLK_DEV_CS5520 is not set
-# CONFIG_BLK_DEV_CS5530 is not set
-# CONFIG_BLK_DEV_HPT34X is not set
-# CONFIG_BLK_DEV_HPT366 is not set
-# CONFIG_BLK_DEV_JMICRON is not set
-# CONFIG_BLK_DEV_SC1200 is not set
-CONFIG_BLK_DEV_PIIX=y
-# CONFIG_BLK_DEV_IT8213 is not set
-# CONFIG_BLK_DEV_IT821X is not set
-# CONFIG_BLK_DEV_NS87415 is not set
-# CONFIG_BLK_DEV_PDC202XX_OLD is not set
-CONFIG_BLK_DEV_PDC202XX_NEW=y
-# CONFIG_BLK_DEV_SVWKS is not set
-# CONFIG_BLK_DEV_SIIMAGE is not set
-# CONFIG_BLK_DEV_SIS5513 is not set
-# CONFIG_BLK_DEV_SLC90E66 is not set
-# CONFIG_BLK_DEV_TRM290 is not set
-# CONFIG_BLK_DEV_VIA82CXXX is not set
-# CONFIG_BLK_DEV_TC86C001 is not set
-# CONFIG_IDE_ARM is not set
-CONFIG_BLK_DEV_IDEDMA=y
-# CONFIG_IDEDMA_IVB is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
-CONFIG_SCSI=y
-CONFIG_SCSI_DMA=y
-# CONFIG_SCSI_TGT is not set
-CONFIG_SCSI_NETLINK=y
-# CONFIG_SCSI_PROC_FS is not set
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-CONFIG_BLK_DEV_SR=y
-# CONFIG_BLK_DEV_SR_VENDOR is not set
-CONFIG_CHR_DEV_SG=y
-# CONFIG_CHR_DEV_SCH is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_MULTI_LUN is not set
-CONFIG_SCSI_CONSTANTS=y
-# CONFIG_SCSI_LOGGING is not set
-# CONFIG_SCSI_SCAN_ASYNC is not set
-CONFIG_SCSI_WAIT_SCAN=m
-
-#
-# SCSI Transports
-#
-CONFIG_SCSI_SPI_ATTRS=y
-CONFIG_SCSI_FC_ATTRS=y
-# CONFIG_SCSI_ISCSI_ATTRS is not set
-CONFIG_SCSI_SAS_ATTRS=y
-# CONFIG_SCSI_SAS_LIBSAS is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_ISCSI_TCP is not set
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_3W_9XXX is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-CONFIG_SCSI_AIC79XX=y
-CONFIG_AIC79XX_CMDS_PER_DEVICE=32
-CONFIG_AIC79XX_RESET_DELAY_MS=4000
-# CONFIG_AIC79XX_DEBUG_ENABLE is not set
-CONFIG_AIC79XX_DEBUG_MASK=0
-# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
-# CONFIG_SCSI_AIC94XX is not set
-# CONFIG_SCSI_ARCMSR is not set
-# CONFIG_MEGARAID_NEWGEN is not set
-# CONFIG_MEGARAID_LEGACY is not set
-# CONFIG_MEGARAID_SAS is not set
-# CONFIG_SCSI_HPTIOP is not set
-# CONFIG_SCSI_BUSLOGIC is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_EATA is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_GDTH is not set
-# CONFIG_SCSI_IPS is not set
-# CONFIG_SCSI_INITIO is not set
-# CONFIG_SCSI_INIA100 is not set
-# CONFIG_SCSI_STEX is not set
-# CONFIG_SCSI_SYM53C8XX_2 is not set
-# CONFIG_SCSI_IPR is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_QLA_FC is not set
-# CONFIG_SCSI_QLA_ISCSI is not set
-# CONFIG_SCSI_LPFC is not set
-# CONFIG_SCSI_DC395x is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_DEBUG is not set
-# CONFIG_SCSI_SRP is not set
-CONFIG_ATA=y
-# CONFIG_ATA_NONSTANDARD is not set
-CONFIG_ATA_ACPI=y
-CONFIG_SATA_AHCI=y
-CONFIG_SATA_SVW=y
-CONFIG_ATA_PIIX=y
-# CONFIG_SATA_MV is not set
-CONFIG_SATA_NV=y
-# CONFIG_PDC_ADMA is not set
-# CONFIG_SATA_QSTOR is not set
-# CONFIG_SATA_PROMISE is not set
-# CONFIG_SATA_SX4 is not set
-CONFIG_SATA_SIL=y
-# CONFIG_SATA_SIL24 is not set
-# CONFIG_SATA_SIS is not set
-# CONFIG_SATA_ULI is not set
-CONFIG_SATA_VIA=y
-# CONFIG_SATA_VITESSE is not set
-# CONFIG_SATA_INIC162X is not set
-# CONFIG_PATA_ALI is not set
-# CONFIG_PATA_AMD is not set
-# CONFIG_PATA_ARTOP is not set
-# CONFIG_PATA_ATIIXP is not set
-# CONFIG_PATA_CMD640_PCI is not set
-# CONFIG_PATA_CMD64X is not set
-# CONFIG_PATA_CS5520 is not set
-# CONFIG_PATA_CS5530 is not set
-# CONFIG_PATA_CYPRESS is not set
-# CONFIG_PATA_EFAR is not set
-# CONFIG_ATA_GENERIC is not set
-# CONFIG_PATA_HPT366 is not set
-# CONFIG_PATA_HPT37X is not set
-# CONFIG_PATA_HPT3X2N is not set
-# CONFIG_PATA_HPT3X3 is not set
-# CONFIG_PATA_IT821X is not set
-# CONFIG_PATA_IT8213 is not set
-# CONFIG_PATA_JMICRON is not set
-# CONFIG_PATA_TRIFLEX is not set
-# CONFIG_PATA_MARVELL is not set
-# CONFIG_PATA_MPIIX is not set
-# CONFIG_PATA_OLDPIIX is not set
-# CONFIG_PATA_NETCELL is not set
-# CONFIG_PATA_NS87410 is not set
-# CONFIG_PATA_OPTI is not set
-# CONFIG_PATA_OPTIDMA is not set
-# CONFIG_PATA_PDC_OLD is not set
-# CONFIG_PATA_RADISYS is not set
-# CONFIG_PATA_RZ1000 is not set
-# CONFIG_PATA_SC1200 is not set
-# CONFIG_PATA_SERVERWORKS is not set
-# CONFIG_PATA_PDC2027X is not set
-# CONFIG_PATA_SIL680 is not set
-# CONFIG_PATA_SIS is not set
-# CONFIG_PATA_VIA is not set
-# CONFIG_PATA_WINBOND is not set
-CONFIG_MD=y
-# CONFIG_BLK_DEV_MD is not set
-CONFIG_BLK_DEV_DM=y
-# CONFIG_DM_DEBUG is not set
-# CONFIG_DM_CRYPT is not set
-# CONFIG_DM_SNAPSHOT is not set
-# CONFIG_DM_MIRROR is not set
-# CONFIG_DM_ZERO is not set
-# CONFIG_DM_MULTIPATH is not set
-# CONFIG_DM_DELAY is not set
-
-#
-# Fusion MPT device support
-#
-CONFIG_FUSION=y
-CONFIG_FUSION_SPI=y
-# CONFIG_FUSION_FC is not set
-# CONFIG_FUSION_SAS is not set
-CONFIG_FUSION_MAX_SGE=128
-# CONFIG_FUSION_CTL is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_FIREWIRE is not set
-CONFIG_IEEE1394=y
-
-#
-# Subsystem Options
-#
-# CONFIG_IEEE1394_VERBOSEDEBUG is not set
-
-#
-# Controllers
-#
-
-#
-# Texas Instruments PCILynx requires I2C
-#
-CONFIG_IEEE1394_OHCI1394=y
-
-#
-# Protocols
-#
-# CONFIG_IEEE1394_VIDEO1394 is not set
-# CONFIG_IEEE1394_SBP2 is not set
-# CONFIG_IEEE1394_ETH1394_ROM_ENTRY is not set
-# CONFIG_IEEE1394_ETH1394 is not set
-# CONFIG_IEEE1394_DV1394 is not set
-CONFIG_IEEE1394_RAWIO=y
-# CONFIG_I2O is not set
-CONFIG_MACINTOSH_DRIVERS=y
-# CONFIG_MAC_EMUMOUSEBTN is not set
-CONFIG_NETDEVICES=y
-CONFIG_NETDEVICES_MULTIQUEUE=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_MACVLAN is not set
-# CONFIG_EQUALIZER is not set
-CONFIG_TUN=y
-# CONFIG_NET_SB1000 is not set
-# CONFIG_ARCNET is not set
-# CONFIG_PHYLIB is not set
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_CASSINI is not set
-CONFIG_NET_VENDOR_3COM=y
-CONFIG_VORTEX=y
-# CONFIG_TYPHOON is not set
-CONFIG_NET_TULIP=y
-# CONFIG_DE2104X is not set
-CONFIG_TULIP=y
-# CONFIG_TULIP_MWI is not set
-# CONFIG_TULIP_MMIO is not set
-# CONFIG_TULIP_NAPI is not set
-# CONFIG_DE4X5 is not set
-# CONFIG_WINBOND_840 is not set
-# CONFIG_DM9102 is not set
-# CONFIG_ULI526X is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-CONFIG_AMD8111_ETH=y
-# CONFIG_AMD8111E_NAPI is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-CONFIG_B44=y
-CONFIG_FORCEDETH=y
-# CONFIG_FORCEDETH_NAPI is not set
-# CONFIG_DGRS is not set
-# CONFIG_EEPRO100 is not set
-CONFIG_E100=y
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-CONFIG_8139CP=y
-CONFIG_8139TOO=y
-# CONFIG_8139TOO_PIO is not set
-# CONFIG_8139TOO_TUNE_TWISTER is not set
-# CONFIG_8139TOO_8129 is not set
-# CONFIG_8139_OLD_RX_RESET is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_VIA_RHINE is not set
-# CONFIG_SC92031 is not set
-CONFIG_NETDEV_1000=y
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-CONFIG_E1000=y
-# CONFIG_E1000_NAPI is not set
-# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SKY2 is not set
-# CONFIG_VIA_VELOCITY is not set
-CONFIG_TIGON3=y
-CONFIG_BNX2=y
-# CONFIG_QLA3XXX is not set
-# CONFIG_ATL1 is not set
-CONFIG_NETDEV_10000=y
-# CONFIG_CHELSIO_T1 is not set
-# CONFIG_CHELSIO_T3 is not set
-# CONFIG_IXGB is not set
-CONFIG_S2IO=m
-# CONFIG_S2IO_NAPI is not set
-# CONFIG_MYRI10GE is not set
-# CONFIG_NETXEN_NIC is not set
-# CONFIG_MLX4_CORE is not set
-# CONFIG_TR is not set
-
-#
-# Wireless LAN
-#
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
-
-#
-# USB Network Adapters
-#
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET_MII is not set
-# CONFIG_USB_USBNET is not set
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_NET_FC is not set
-# CONFIG_SHAPER is not set
-CONFIG_NETCONSOLE=y
-CONFIG_NETPOLL=y
-# CONFIG_NETPOLL_TRAP is not set
-CONFIG_NET_POLL_CONTROLLER=y
-# CONFIG_ISDN is not set
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_FF_MEMLESS is not set
-# CONFIG_INPUT_POLLDEV is not set
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_KEYBOARD_STOWAWAY is not set
-CONFIG_INPUT_MOUSE=y
-CONFIG_MOUSE_PS2=y
-CONFIG_MOUSE_PS2_ALPS=y
-CONFIG_MOUSE_PS2_LOGIPS2PP=y
-CONFIG_MOUSE_PS2_SYNAPTICS=y
-CONFIG_MOUSE_PS2_LIFEBOOK=y
-CONFIG_MOUSE_PS2_TRACKPOINT=y
-# CONFIG_MOUSE_PS2_TOUCHKIT is not set
-# CONFIG_MOUSE_SERIAL is not set
-# CONFIG_MOUSE_APPLETOUCH is not set
-# CONFIG_MOUSE_VSXXXAA is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TABLET is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Hardware I/O ports
-#
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-# CONFIG_SERIO_SERPORT is not set
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-CONFIG_SERIO_LIBPS2=y
-# CONFIG_SERIO_RAW is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_VT_HW_CONSOLE_BINDING is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_FIX_EARLYCON_MEM=y
-CONFIG_SERIAL_8250_PCI=y
-CONFIG_SERIAL_8250_PNP=y
-CONFIG_SERIAL_8250_NR_UARTS=4
-CONFIG_SERIAL_8250_RUNTIME_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_IPMI_HANDLER is not set
-# CONFIG_WATCHDOG is not set
-CONFIG_HW_RANDOM=y
-CONFIG_HW_RANDOM_INTEL=y
-CONFIG_HW_RANDOM_AMD=y
-# CONFIG_NVRAM is not set
-CONFIG_RTC=y
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-CONFIG_AGP=y
-CONFIG_AGP_AMD64=y
-CONFIG_AGP_INTEL=y
-# CONFIG_AGP_SIS is not set
-# CONFIG_AGP_VIA is not set
-# CONFIG_DRM is not set
-# CONFIG_MWAVE is not set
-# CONFIG_PC8736x_GPIO is not set
-CONFIG_RAW_DRIVER=y
-CONFIG_MAX_RAW_DEVS=256
-CONFIG_HPET=y
-# CONFIG_HPET_RTC_IRQ is not set
-CONFIG_HPET_MMAP=y
-# CONFIG_HANGCHECK_TIMER is not set
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
-CONFIG_DEVPORT=y
-# CONFIG_I2C is not set
-
-#
-# SPI support
-#
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
-# CONFIG_W1 is not set
-# CONFIG_POWER_SUPPLY is not set
-# CONFIG_HWMON is not set
-
-#
-# Multifunction device drivers
-#
-# CONFIG_MFD_SM501 is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-CONFIG_DAB=y
-# CONFIG_USB_DABUSB is not set
-
-#
-# Graphics support
-#
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
-
-#
-# Display device support
-#
-# CONFIG_DISPLAY_SUPPORT is not set
-# CONFIG_VGASTATE is not set
-# CONFIG_FB is not set
-
-#
-# Console display driver support
-#
-CONFIG_VGA_CONSOLE=y
-CONFIG_VGACON_SOFT_SCROLLBACK=y
-CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=256
-CONFIG_VIDEO_SELECT=y
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-CONFIG_SOUND=y
-
-#
-# Advanced Linux Sound Architecture
-#
-# CONFIG_SND is not set
-
-#
-# Open Sound System
-#
-CONFIG_SOUND_PRIME=y
-# CONFIG_SOUND_TRIDENT is not set
-# CONFIG_SOUND_MSNDCLAS is not set
-# CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_OSS is not set
-CONFIG_HID_SUPPORT=y
-CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
-
-#
-# USB Input Devices
-#
-CONFIG_USB_HID=y
-# CONFIG_USB_HIDINPUT_POWERBOOK is not set
-# CONFIG_HID_FF is not set
-# CONFIG_USB_HIDDEV is not set
-CONFIG_USB_SUPPORT=y
-CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-CONFIG_USB_ARCH_HAS_EHCI=y
-CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_DEVICE_CLASS is not set
-# CONFIG_USB_DYNAMIC_MINORS is not set
-# CONFIG_USB_SUSPEND is not set
-# CONFIG_USB_PERSIST is not set
-# CONFIG_USB_OTG is not set
-
-#
-# USB Host Controller Drivers
-#
-CONFIG_USB_EHCI_HCD=y
-# CONFIG_USB_EHCI_SPLIT_ISO is not set
-# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
-# CONFIG_USB_EHCI_TT_NEWSCHED is not set
-# CONFIG_USB_ISP116X_HCD is not set
-CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
-# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
-CONFIG_USB_OHCI_LITTLE_ENDIAN=y
-CONFIG_USB_UHCI_HCD=y
-# CONFIG_USB_SL811_HCD is not set
-# CONFIG_USB_R8A66597_HCD is not set
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_ACM is not set
-CONFIG_USB_PRINTER=y
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# may also be needed; see USB_STORAGE Help for more information
-#
-CONFIG_USB_STORAGE=y
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-# CONFIG_USB_STORAGE_FREECOM is not set
-# CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_USBAT is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_SDDR55 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_STORAGE_ALAUDA is not set
-# CONFIG_USB_STORAGE_KARMA is not set
-# CONFIG_USB_LIBUSUAL is not set
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_MICROTEK is not set
-CONFIG_USB_MON=y
-
-#
-# USB port drivers
-#
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_EMI62 is not set
-# CONFIG_USB_EMI26 is not set
-# CONFIG_USB_ADUTUX is not set
-# CONFIG_USB_AUERSWALD is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_LEGOTOWER is not set
-# CONFIG_USB_LCD is not set
-# CONFIG_USB_BERRY_CHARGE is not set
-# CONFIG_USB_LED is not set
-# CONFIG_USB_CYPRESS_CY7C63 is not set
-# CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGET is not set
-# CONFIG_USB_IDMOUSE is not set
-# CONFIG_USB_FTDI_ELAN is not set
-# CONFIG_USB_APPLEDISPLAY is not set
-# CONFIG_USB_SISUSBVGA is not set
-# CONFIG_USB_LD is not set
-# CONFIG_USB_TRANCEVIBRATOR is not set
-# CONFIG_USB_IOWARRIOR is not set
-# CONFIG_USB_TEST is not set
-
-#
-# USB DSL modem support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-# CONFIG_MMC is not set
-
-#
-# LED devices
-#
-# CONFIG_NEW_LEDS is not set
-
-#
-# LED drivers
-#
-
-#
-# LED Triggers
-#
-# CONFIG_INFINIBAND is not set
-# CONFIG_EDAC is not set
-
-#
-# Real Time Clock
-#
-# CONFIG_RTC_CLASS is not set
-
-#
-# DMA Engine support
-#
-# CONFIG_DMA_ENGINE is not set
-
-#
-# DMA Clients
-#
-
-#
-# DMA Devices
-#
-CONFIG_VIRTUALIZATION=y
-# CONFIG_KVM is not set
-
-#
-# Userspace I/O
-#
-# CONFIG_UIO is not set
-
-#
-# Firmware Drivers
-#
-# CONFIG_EDD is not set
-# CONFIG_DELL_RBU is not set
-# CONFIG_DCDBAS is not set
-CONFIG_DMIID=y
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-# CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
-# CONFIG_EXT4DEV_FS is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-CONFIG_REISERFS_FS=y
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_REISERFS_PROC_INFO is not set
-CONFIG_REISERFS_FS_XATTR=y
-CONFIG_REISERFS_FS_POSIX_ACL=y
-# CONFIG_REISERFS_FS_SECURITY is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
-# CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-CONFIG_INOTIFY_USER=y
-# CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
-# CONFIG_AUTOFS_FS is not set
-CONFIG_AUTOFS4_FS=y
-# CONFIG_FUSE_FS is not set
-CONFIG_GENERIC_ACL=y
-
-#
-# CD-ROM/DVD Filesystems
-#
-CONFIG_ISO9660_FS=y
-CONFIG_JOLIET=y
-# CONFIG_ZISOFS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=y
-CONFIG_MSDOS_FS=y
-CONFIG_VFAT_FS=y
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_PROC_SYSCTL=y
-CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-CONFIG_TMPFS_POSIX_ACL=y
-CONFIG_HUGETLBFS=y
-CONFIG_HUGETLB_PAGE=y
-CONFIG_RAMFS=y
-# CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V3_ACL is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=y
-CONFIG_NFSD_V3=y
-# CONFIG_NFSD_V3_ACL is not set
-# CONFIG_NFSD_V4 is not set
-CONFIG_NFSD_TCP=y
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_EXPORTFS=y
-CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_BIND34 is not set
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
-CONFIG_NLS_CODEPAGE_437=y
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-# CONFIG_NLS_CODEPAGE_850 is not set
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-CONFIG_NLS_ASCII=y
-CONFIG_NLS_ISO8859_1=y
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-CONFIG_NLS_ISO8859_15=y
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-CONFIG_NLS_UTF8=y
-
-#
-# Distributed Lock Manager
-#
-# CONFIG_DLM is not set
-
-#
-# Instrumentation Support
-#
-CONFIG_PROFILING=y
-CONFIG_OPROFILE=y
-CONFIG_KPROBES=y
-
-#
-# Kernel hacking
-#
-CONFIG_TRACE_IRQFLAGS_SUPPORT=y
-# CONFIG_PRINTK_TIME is not set
-# CONFIG_ENABLE_MUST_CHECK is not set
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_UNUSED_SYMBOLS=y
-CONFIG_DEBUG_FS=y
-# CONFIG_HEADERS_CHECK is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SHIRQ is not set
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_SCHED_DEBUG is not set
-# CONFIG_SCHEDSTATS is not set
-CONFIG_TIMER_STATS=y
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_RT_MUTEXES is not set
-# CONFIG_RT_MUTEX_TESTER is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_MUTEXES is not set
-# CONFIG_DEBUG_LOCK_ALLOC is not set
-# CONFIG_PROVE_LOCKING is not set
-# CONFIG_LOCK_STAT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
-# CONFIG_DEBUG_KOBJECT is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_VM is not set
-# CONFIG_DEBUG_LIST is not set
-# CONFIG_FRAME_POINTER is not set
-# CONFIG_FORCED_INLINING is not set
-# CONFIG_RCU_TORTURE_TEST is not set
-# CONFIG_LKDTM is not set
-# CONFIG_FAULT_INJECTION is not set
-# CONFIG_DEBUG_RODATA is not set
-# CONFIG_IOMMU_DEBUG is not set
-CONFIG_DEBUG_STACKOVERFLOW=y
-# CONFIG_DEBUG_STACK_USAGE is not set
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-CONFIG_BITREVERSE=y
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
-# CONFIG_CRC_ITU_T is not set
-CONFIG_CRC32=y
-# CONFIG_CRC7 is not set
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
-CONFIG_HAS_IOMEM=y
-CONFIG_HAS_IOPORT=y
-CONFIG_HAS_DMA=y
diff --git a/arch/x86_64/ia32/Makefile b/arch/x86_64/ia32/Makefile
deleted file mode 100644 (file)
index cdae364..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Makefile for the ia32 kernel emulation subsystem.
-#
-
-obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o tls32.o \
-       ia32_binfmt.o fpu32.o ptrace32.o syscall32.o syscall32_syscall.o \
-       mmap32.o
-
-sysv-$(CONFIG_SYSVIPC) := ipc32.o
-obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
-
-obj-$(CONFIG_IA32_AOUT) += ia32_aout.o
-
-audit-class-$(CONFIG_AUDIT) := audit.o
-obj-$(CONFIG_IA32_EMULATION) += $(audit-class-y)
-
-$(obj)/syscall32_syscall.o: \
-       $(foreach F,sysenter syscall,$(obj)/vsyscall-$F.so)
-
-# Teach kbuild about targets
-targets := $(foreach F,sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
-
-# The DSO images are built using a special linker script
-quiet_cmd_syscall = SYSCALL $@
-      cmd_syscall = $(CC) -m32 -nostdlib -shared -s \
-                         $(call ld-option, -Wl$(comma)--hash-style=sysv) \
-                          -Wl,-soname=linux-gate.so.1 -o $@ \
-                          -Wl,-T,$(filter-out FORCE,$^)
-
-$(obj)/vsyscall-sysenter.so $(obj)/vsyscall-syscall.so: \
-$(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
-       $(call if_changed,syscall)
-
-AFLAGS_vsyscall-sysenter.o = -m32 -Wa,-32
-AFLAGS_vsyscall-syscall.o = -m32 -Wa,-32
diff --git a/arch/x86_64/ia32/audit.c b/arch/x86_64/ia32/audit.c
deleted file mode 100644 (file)
index 8850fe4..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <asm-i386/unistd.h>
-
-unsigned ia32_dir_class[] = {
-#include <asm-generic/audit_dir_write.h>
-~0U
-};
-
-unsigned ia32_chattr_class[] = {
-#include <asm-generic/audit_change_attr.h>
-~0U
-};
-
-unsigned ia32_write_class[] = {
-#include <asm-generic/audit_write.h>
-~0U
-};
-
-unsigned ia32_read_class[] = {
-#include <asm-generic/audit_read.h>
-~0U
-};
-
-unsigned ia32_signal_class[] = {
-#include <asm-generic/audit_signal.h>
-~0U
-};
-
-int ia32_classify_syscall(unsigned syscall)
-{
-       switch(syscall) {
-       case __NR_open:
-               return 2;
-       case __NR_openat:
-               return 3;
-       case __NR_socketcall:
-               return 4;
-       case __NR_execve:
-               return 5;
-       default:
-               return 1;
-       }
-}
diff --git a/arch/x86_64/ia32/fpu32.c b/arch/x86_64/ia32/fpu32.c
deleted file mode 100644 (file)
index 2c8209a..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* 
- * Copyright 2002 Andi Kleen, SuSE Labs.
- * FXSAVE<->i387 conversion support. Based on code by Gareth Hughes.
- * This is used for ptrace, signals and coredumps in 32bit emulation.
- */ 
-
-#include <linux/sched.h>
-#include <asm/sigcontext32.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/i387.h>
-
-static inline unsigned short twd_i387_to_fxsr(unsigned short twd)
-{
-       unsigned int tmp; /* to avoid 16 bit prefixes in the code */
-       /* Transform each pair of bits into 01 (valid) or 00 (empty) */
-        tmp = ~twd;
-        tmp = (tmp | (tmp>>1)) & 0x5555; /* 0V0V0V0V0V0V0V0V */
-        /* and move the valid bits to the lower byte. */
-        tmp = (tmp | (tmp >> 1)) & 0x3333; /* 00VV00VV00VV00VV */
-        tmp = (tmp | (tmp >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV */
-        tmp = (tmp | (tmp >> 4)) & 0x00ff; /* 00000000VVVVVVVV */
-        return tmp;
-}
-
-static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
-{
-       struct _fpxreg *st = NULL;
-       unsigned long tos = (fxsave->swd >> 11) & 7;
-       unsigned long twd = (unsigned long) fxsave->twd;
-       unsigned long tag;
-       unsigned long ret = 0xffff0000;
-       int i;
-
-#define FPREG_ADDR(f, n)       ((void *)&(f)->st_space + (n) * 16);
-
-       for (i = 0 ; i < 8 ; i++) {
-               if (twd & 0x1) {
-                       st = FPREG_ADDR( fxsave, (i - tos) & 7 );
-
-                       switch (st->exponent & 0x7fff) {
-                       case 0x7fff:
-                               tag = 2;                /* Special */
-                               break;
-                       case 0x0000:
-                               if ( !st->significand[0] &&
-                                    !st->significand[1] &&
-                                    !st->significand[2] &&
-                                    !st->significand[3] ) {
-                                       tag = 1;        /* Zero */
-                               } else {
-                                       tag = 2;        /* Special */
-                               }
-                               break;
-                       default:
-                               if (st->significand[3] & 0x8000) {
-                                       tag = 0;        /* Valid */
-                               } else {
-                                       tag = 2;        /* Special */
-                               }
-                               break;
-                       }
-               } else {
-                       tag = 3;                        /* Empty */
-               }
-               ret |= (tag << (2 * i));
-               twd = twd >> 1;
-       }
-       return ret;
-}
-
-
-static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave,
-                                        struct _fpstate_ia32 __user *buf)
-{
-       struct _fpxreg *to;
-       struct _fpreg __user *from;
-       int i;
-       u32 v;
-       int err = 0;
-
-#define G(num,val) err |= __get_user(val, num + (u32 __user *)buf)
-       G(0, fxsave->cwd);
-       G(1, fxsave->swd);
-       G(2, fxsave->twd);
-       fxsave->twd = twd_i387_to_fxsr(fxsave->twd);
-       G(3, fxsave->rip);
-       G(4, v);
-       fxsave->fop = v>>16;    /* cs ignored */
-       G(5, fxsave->rdp);
-       /* 6: ds ignored */
-#undef G
-       if (err) 
-               return -1; 
-
-       to = (struct _fpxreg *)&fxsave->st_space[0];
-       from = &buf->_st[0];
-       for (i = 0 ; i < 8 ; i++, to++, from++) {
-               if (__copy_from_user(to, from, sizeof(*from)))
-                       return -1;
-       }
-       return 0;
-}
-
-
-static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
-                                      struct i387_fxsave_struct *fxsave,
-                                      struct pt_regs *regs,
-                                      struct task_struct *tsk)
-{
-       struct _fpreg __user *to;
-       struct _fpxreg *from;
-       int i;
-       u16 cs,ds; 
-       int err = 0; 
-
-       if (tsk == current) {
-               /* should be actually ds/cs at fpu exception time,
-                  but that information is not available in 64bit mode. */
-               asm("movw %%ds,%0 " : "=r" (ds)); 
-               asm("movw %%cs,%0 " : "=r" (cs));               
-       } else { /* ptrace. task has stopped. */
-               ds = tsk->thread.ds;
-               cs = regs->cs;
-       } 
-
-#define P(num,val) err |= __put_user(val, num + (u32 __user *)buf)
-       P(0, (u32)fxsave->cwd | 0xffff0000);
-       P(1, (u32)fxsave->swd | 0xffff0000);
-       P(2, twd_fxsr_to_i387(fxsave));
-       P(3, (u32)fxsave->rip);
-       P(4,  cs | ((u32)fxsave->fop) << 16); 
-       P(5, fxsave->rdp);
-       P(6, 0xffff0000 | ds);
-#undef P
-
-       if (err) 
-               return -1; 
-
-       to = &buf->_st[0];
-       from = (struct _fpxreg *) &fxsave->st_space[0];
-       for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
-               if (__copy_to_user(to, from, sizeof(*to)))
-                       return -1;
-       }
-       return 0;
-}
-
-int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, int fsave) 
-{ 
-       clear_fpu(tsk);
-       if (!fsave) { 
-               if (__copy_from_user(&tsk->thread.i387.fxsave, 
-                                    &buf->_fxsr_env[0],
-                                    sizeof(struct i387_fxsave_struct)))
-                       return -1;
-               tsk->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask;
-               set_stopped_child_used_math(tsk);
-       } 
-       return convert_fxsr_from_user(&tsk->thread.i387.fxsave, buf);
-}  
-
-int save_i387_ia32(struct task_struct *tsk, 
-                  struct _fpstate_ia32 __user *buf, 
-                  struct pt_regs *regs,
-                  int fsave)
-{
-       int err = 0;
-
-       init_fpu(tsk);
-       if (convert_fxsr_to_user(buf, &tsk->thread.i387.fxsave, regs, tsk))
-               return -1;
-       if (fsave)
-               return 0;
-       err |= __put_user(tsk->thread.i387.fxsave.swd, &buf->status);
-       if (fsave) 
-               return err ? -1 : 1;    
-       err |= __put_user(X86_FXSR_MAGIC, &buf->magic);
-       err |= __copy_to_user(&buf->_fxsr_env[0], &tsk->thread.i387.fxsave,
-                             sizeof(struct i387_fxsave_struct));
-       return err ? -1 : 1;
-}
diff --git a/arch/x86_64/ia32/ia32_aout.c b/arch/x86_64/ia32/ia32_aout.c
deleted file mode 100644 (file)
index 0878137..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- *  a.out loader for x86-64
- *
- *  Copyright (C) 1991, 1992, 1996  Linus Torvalds
- *  Hacked together by Andi Kleen
- */
-
-#include <linux/module.h>
-
-#include <linux/time.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/a.out.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/stat.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/user.h>
-#include <linux/slab.h>
-#include <linux/binfmts.h>
-#include <linux/personality.h>
-#include <linux/init.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-#include <asm/pgalloc.h>
-#include <asm/cacheflush.h>
-#include <asm/user32.h>
-#include <asm/ia32.h>
-
-#undef WARN_OLD
-#undef CORE_DUMP /* probably broken */
-
-static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
-static int load_aout_library(struct file*);
-
-#ifdef CORE_DUMP
-static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file);
-
-/*
- * fill in the user structure for a core dump..
- */
-static void dump_thread32(struct pt_regs * regs, struct user32 * dump)
-{
-       u32 fs,gs;
-
-/* changed the size calculations - should hopefully work better. lbt */
-       dump->magic = CMAGIC;
-       dump->start_code = 0;
-       dump->start_stack = regs->rsp & ~(PAGE_SIZE - 1);
-       dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
-       dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT;
-       dump->u_dsize -= dump->u_tsize;
-       dump->u_ssize = 0;
-       dump->u_debugreg[0] = current->thread.debugreg0;  
-       dump->u_debugreg[1] = current->thread.debugreg1;  
-       dump->u_debugreg[2] = current->thread.debugreg2;  
-       dump->u_debugreg[3] = current->thread.debugreg3;  
-       dump->u_debugreg[4] = 0;  
-       dump->u_debugreg[5] = 0;  
-       dump->u_debugreg[6] = current->thread.debugreg6;  
-       dump->u_debugreg[7] = current->thread.debugreg7;  
-
-       if (dump->start_stack < 0xc0000000)
-               dump->u_ssize = ((unsigned long) (0xc0000000 - dump->start_stack)) >> PAGE_SHIFT;
-
-       dump->regs.ebx = regs->rbx;
-       dump->regs.ecx = regs->rcx;
-       dump->regs.edx = regs->rdx;
-       dump->regs.esi = regs->rsi;
-       dump->regs.edi = regs->rdi;
-       dump->regs.ebp = regs->rbp;
-       dump->regs.eax = regs->rax;
-       dump->regs.ds = current->thread.ds;
-       dump->regs.es = current->thread.es;
-       asm("movl %%fs,%0" : "=r" (fs)); dump->regs.fs = fs;
-       asm("movl %%gs,%0" : "=r" (gs)); dump->regs.gs = gs; 
-       dump->regs.orig_eax = regs->orig_rax;
-       dump->regs.eip = regs->rip;
-       dump->regs.cs = regs->cs;
-       dump->regs.eflags = regs->eflags;
-       dump->regs.esp = regs->rsp;
-       dump->regs.ss = regs->ss;
-
-#if 1 /* FIXME */
-       dump->u_fpvalid = 0;
-#else
-       dump->u_fpvalid = dump_fpu (regs, &dump->i387);
-#endif
-}
-
-#endif
-
-static struct linux_binfmt aout_format = {
-       .module         = THIS_MODULE,
-       .load_binary    = load_aout_binary,
-       .load_shlib     = load_aout_library,
-#ifdef CORE_DUMP
-       .core_dump      = aout_core_dump,
-#endif
-       .min_coredump   = PAGE_SIZE
-};
-
-static void set_brk(unsigned long start, unsigned long end)
-{
-       start = PAGE_ALIGN(start);
-       end = PAGE_ALIGN(end);
-       if (end <= start)
-               return;
-       down_write(&current->mm->mmap_sem);
-       do_brk(start, end - start);
-       up_write(&current->mm->mmap_sem);
-}
-
-#ifdef CORE_DUMP
-/*
- * These are the only things you should do on a core-file: use only these
- * macros to write out all the necessary info.
- */
-
-static int dump_write(struct file *file, const void *addr, int nr)
-{
-       return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
-}
-
-#define DUMP_WRITE(addr, nr)   \
-       if (!dump_write(file, (void *)(addr), (nr))) \
-               goto end_coredump;
-
-#define DUMP_SEEK(offset) \
-if (file->f_op->llseek) { \
-       if (file->f_op->llseek(file,(offset),0) != (offset)) \
-               goto end_coredump; \
-} else file->f_pos = (offset)
-
-/*
- * Routine writes a core dump image in the current directory.
- * Currently only a stub-function.
- *
- * Note that setuid/setgid files won't make a core-dump if the uid/gid
- * changed due to the set[u|g]id. It's enforced by the "current->mm->dumpable"
- * field, which also makes sure the core-dumps won't be recursive if the
- * dumping of the process results in another error..
- */
-
-static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file)
-{
-       mm_segment_t fs;
-       int has_dumped = 0;
-       unsigned long dump_start, dump_size;
-       struct user32 dump;
-#       define START_DATA(u)   (u.u_tsize << PAGE_SHIFT)
-#       define START_STACK(u)   (u.start_stack)
-
-       fs = get_fs();
-       set_fs(KERNEL_DS);
-       has_dumped = 1;
-       current->flags |= PF_DUMPCORE;
-               strncpy(dump.u_comm, current->comm, sizeof(current->comm));
-       dump.u_ar0 = (u32)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump)));
-       dump.signal = signr;
-       dump_thread32(regs, &dump);
-
-/* If the size of the dump file exceeds the rlimit, then see what would happen
-   if we wrote the stack, but not the data area.  */
-       if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE >
-           current->signal->rlim[RLIMIT_CORE].rlim_cur)
-               dump.u_dsize = 0;
-
-/* Make sure we have enough room to write the stack and data areas. */
-       if ((dump.u_ssize+1) * PAGE_SIZE >
-           current->signal->rlim[RLIMIT_CORE].rlim_cur)
-               dump.u_ssize = 0;
-
-/* make sure we actually have a data and stack area to dump */
-       set_fs(USER_DS);
-       if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
-               dump.u_dsize = 0;
-       if (!access_ok(VERIFY_READ, (void *) (unsigned long)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
-               dump.u_ssize = 0;
-
-       set_fs(KERNEL_DS);
-/* struct user */
-       DUMP_WRITE(&dump,sizeof(dump));
-/* Now dump all of the user data.  Include malloced stuff as well */
-       DUMP_SEEK(PAGE_SIZE);
-/* now we start writing out the user space info */
-       set_fs(USER_DS);
-/* Dump the data area */
-       if (dump.u_dsize != 0) {
-               dump_start = START_DATA(dump);
-               dump_size = dump.u_dsize << PAGE_SHIFT;
-               DUMP_WRITE(dump_start,dump_size);
-       }
-/* Now prepare to dump the stack area */
-       if (dump.u_ssize != 0) {
-               dump_start = START_STACK(dump);
-               dump_size = dump.u_ssize << PAGE_SHIFT;
-               DUMP_WRITE(dump_start,dump_size);
-       }
-/* Finally dump the task struct.  Not be used by gdb, but could be useful */
-       set_fs(KERNEL_DS);
-       DUMP_WRITE(current,sizeof(*current));
-end_coredump:
-       set_fs(fs);
-       return has_dumped;
-}
-#endif
-
-/*
- * create_aout_tables() parses the env- and arg-strings in new user
- * memory and creates the pointer tables from them, and puts their
- * addresses on the "stack", returning the new stack pointer value.
- */
-static u32 __user *create_aout_tables(char __user *p, struct linux_binprm *bprm)
-{
-       u32 __user *argv;
-       u32 __user *envp;
-       u32 __user *sp;
-       int argc = bprm->argc;
-       int envc = bprm->envc;
-
-       sp = (u32 __user *) ((-(unsigned long)sizeof(u32)) & (unsigned long) p);
-       sp -= envc+1;
-       envp = sp;
-       sp -= argc+1;
-       argv = sp;
-       put_user((unsigned long) envp,--sp);
-       put_user((unsigned long) argv,--sp);
-       put_user(argc,--sp);
-       current->mm->arg_start = (unsigned long) p;
-       while (argc-->0) {
-               char c;
-               put_user((u32)(unsigned long)p,argv++);
-               do {
-                       get_user(c,p++);
-               } while (c);
-       }
-       put_user(0, argv);
-       current->mm->arg_end = current->mm->env_start = (unsigned long) p;
-       while (envc-->0) {
-               char c;
-               put_user((u32)(unsigned long)p,envp++);
-               do {
-                       get_user(c,p++);
-               } while (c);
-       }
-       put_user(0, envp);
-       current->mm->env_end = (unsigned long) p;
-       return sp;
-}
-
-/*
- * These are the functions used to load a.out style executables and shared
- * libraries.  There is no binary dependent code anywhere else.
- */
-
-static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
-{
-       struct exec ex;
-       unsigned long error;
-       unsigned long fd_offset;
-       unsigned long rlim;
-       int retval;
-
-       ex = *((struct exec *) bprm->buf);              /* exec-header */
-       if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != OMAGIC &&
-            N_MAGIC(ex) != QMAGIC && N_MAGIC(ex) != NMAGIC) ||
-           N_TRSIZE(ex) || N_DRSIZE(ex) ||
-           i_size_read(bprm->file->f_path.dentry->d_inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
-               return -ENOEXEC;
-       }
-
-       fd_offset = N_TXTOFF(ex);
-
-       /* Check initial limits. This avoids letting people circumvent
-        * size limits imposed on them by creating programs with large
-        * arrays in the data or bss.
-        */
-       rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
-       if (rlim >= RLIM_INFINITY)
-               rlim = ~0;
-       if (ex.a_data + ex.a_bss > rlim)
-               return -ENOMEM;
-
-       /* Flush all traces of the currently running executable */
-       retval = flush_old_exec(bprm);
-       if (retval)
-               return retval;
-
-       regs->cs = __USER32_CS; 
-       regs->r8 = regs->r9 = regs->r10 = regs->r11 = regs->r12 =
-               regs->r13 = regs->r14 = regs->r15 = 0;
-
-       /* OK, This is the point of no return */
-       set_personality(PER_LINUX);
-       set_thread_flag(TIF_IA32); 
-       clear_thread_flag(TIF_ABI_PENDING);
-
-       current->mm->end_code = ex.a_text +
-               (current->mm->start_code = N_TXTADDR(ex));
-       current->mm->end_data = ex.a_data +
-               (current->mm->start_data = N_DATADDR(ex));
-       current->mm->brk = ex.a_bss +
-               (current->mm->start_brk = N_BSSADDR(ex));
-       current->mm->free_area_cache = TASK_UNMAPPED_BASE;
-       current->mm->cached_hole_size = 0;
-
-       current->mm->mmap = NULL;
-       compute_creds(bprm);
-       current->flags &= ~PF_FORKNOEXEC;
-
-       if (N_MAGIC(ex) == OMAGIC) {
-               unsigned long text_addr, map_size;
-               loff_t pos;
-
-               text_addr = N_TXTADDR(ex);
-
-               pos = 32;
-               map_size = ex.a_text+ex.a_data;
-
-               down_write(&current->mm->mmap_sem);
-               error = do_brk(text_addr & PAGE_MASK, map_size);
-               up_write(&current->mm->mmap_sem);
-
-               if (error != (text_addr & PAGE_MASK)) {
-                       send_sig(SIGKILL, current, 0);
-                       return error;
-               }
-
-               error = bprm->file->f_op->read(bprm->file,
-                        (char __user *)text_addr,
-                         ex.a_text+ex.a_data, &pos);
-               if ((signed long)error < 0) {
-                       send_sig(SIGKILL, current, 0);
-                       return error;
-               }
-                        
-               flush_icache_range(text_addr, text_addr+ex.a_text+ex.a_data);
-       } else {
-#ifdef WARN_OLD
-               static unsigned long error_time, error_time2;
-               if ((ex.a_text & 0xfff || ex.a_data & 0xfff) &&
-                   (N_MAGIC(ex) != NMAGIC) && (jiffies-error_time2) > 5*HZ)
-               {
-                       printk(KERN_NOTICE "executable not page aligned\n");
-                       error_time2 = jiffies;
-               }
-
-               if ((fd_offset & ~PAGE_MASK) != 0 &&
-                   (jiffies-error_time) > 5*HZ)
-               {
-                       printk(KERN_WARNING 
-                              "fd_offset is not page aligned. Please convert program: %s\n",
-                              bprm->file->f_path.dentry->d_name.name);
-                       error_time = jiffies;
-               }
-#endif
-
-               if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
-                       loff_t pos = fd_offset;
-                       down_write(&current->mm->mmap_sem);
-                       do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
-                       up_write(&current->mm->mmap_sem);
-                       bprm->file->f_op->read(bprm->file,
-                                       (char __user *)N_TXTADDR(ex),
-                                       ex.a_text+ex.a_data, &pos);
-                       flush_icache_range((unsigned long) N_TXTADDR(ex),
-                                          (unsigned long) N_TXTADDR(ex) +
-                                          ex.a_text+ex.a_data);
-                       goto beyond_if;
-               }
-
-               down_write(&current->mm->mmap_sem);
-               error = do_mmap(bprm->file, N_TXTADDR(ex), ex.a_text,
-                       PROT_READ | PROT_EXEC,
-                       MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE | MAP_32BIT,
-                       fd_offset);
-               up_write(&current->mm->mmap_sem);
-
-               if (error != N_TXTADDR(ex)) {
-                       send_sig(SIGKILL, current, 0);
-                       return error;
-               }
-
-               down_write(&current->mm->mmap_sem);
-               error = do_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
-                               PROT_READ | PROT_WRITE | PROT_EXEC,
-                               MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE | MAP_32BIT,
-                               fd_offset + ex.a_text);
-               up_write(&current->mm->mmap_sem);
-               if (error != N_DATADDR(ex)) {
-                       send_sig(SIGKILL, current, 0);
-                       return error;
-               }
-       }
-beyond_if:
-       set_binfmt(&aout_format);
-
-       set_brk(current->mm->start_brk, current->mm->brk);
-
-       retval = setup_arg_pages(bprm, IA32_STACK_TOP, EXSTACK_DEFAULT);
-       if (retval < 0) { 
-               /* Someone check-me: is this error path enough? */ 
-               send_sig(SIGKILL, current, 0); 
-               return retval;
-       }
-
-       current->mm->start_stack =
-               (unsigned long)create_aout_tables((char __user *)bprm->p, bprm);
-       /* start thread */
-       asm volatile("movl %0,%%fs" :: "r" (0)); \
-       asm volatile("movl %0,%%es; movl %0,%%ds": :"r" (__USER32_DS));
-       load_gs_index(0); 
-       (regs)->rip = ex.a_entry;
-       (regs)->rsp = current->mm->start_stack;
-       (regs)->eflags = 0x200;
-       (regs)->cs = __USER32_CS;
-       (regs)->ss = __USER32_DS;
-       set_fs(USER_DS);
-       if (unlikely(current->ptrace & PT_PTRACED)) {
-               if (current->ptrace & PT_TRACE_EXEC)
-                       ptrace_notify ((PTRACE_EVENT_EXEC << 8) | SIGTRAP);
-               else
-                       send_sig(SIGTRAP, current, 0);
-       }
-       return 0;
-}
-
-static int load_aout_library(struct file *file)
-{
-       struct inode * inode;
-       unsigned long bss, start_addr, len;
-       unsigned long error;
-       int retval;
-       struct exec ex;
-
-       inode = file->f_path.dentry->d_inode;
-
-       retval = -ENOEXEC;
-       error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
-       if (error != sizeof(ex))
-               goto out;
-
-       /* We come in here for the regular a.out style of shared libraries */
-       if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != QMAGIC) || N_TRSIZE(ex) ||
-           N_DRSIZE(ex) || ((ex.a_entry & 0xfff) && N_MAGIC(ex) == ZMAGIC) ||
-           i_size_read(inode) < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
-               goto out;
-       }
-
-       if (N_FLAGS(ex))
-               goto out;
-
-       /* For  QMAGIC, the starting address is 0x20 into the page.  We mask
-          this off to get the starting address for the page */
-
-       start_addr =  ex.a_entry & 0xfffff000;
-
-       if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
-               loff_t pos = N_TXTOFF(ex);
-
-#ifdef WARN_OLD
-               static unsigned long error_time;
-               if ((jiffies-error_time) > 5*HZ)
-               {
-                       printk(KERN_WARNING 
-                              "N_TXTOFF is not page aligned. Please convert library: %s\n",
-                              file->f_path.dentry->d_name.name);
-                       error_time = jiffies;
-               }
-#endif
-               down_write(&current->mm->mmap_sem);
-               do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
-               up_write(&current->mm->mmap_sem);
-               
-               file->f_op->read(file, (char __user *)start_addr,
-                       ex.a_text + ex.a_data, &pos);
-               flush_icache_range((unsigned long) start_addr,
-                                  (unsigned long) start_addr + ex.a_text + ex.a_data);
-
-               retval = 0;
-               goto out;
-       }
-       /* Now use mmap to map the library into memory. */
-       down_write(&current->mm->mmap_sem);
-       error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
-                       PROT_READ | PROT_WRITE | PROT_EXEC,
-                       MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_32BIT,
-                       N_TXTOFF(ex));
-       up_write(&current->mm->mmap_sem);
-       retval = error;
-       if (error != start_addr)
-               goto out;
-
-       len = PAGE_ALIGN(ex.a_text + ex.a_data);
-       bss = ex.a_text + ex.a_data + ex.a_bss;
-       if (bss > len) {
-               down_write(&current->mm->mmap_sem);
-               error = do_brk(start_addr + len, bss - len);
-               up_write(&current->mm->mmap_sem);
-               retval = error;
-               if (error != start_addr + len)
-                       goto out;
-       }
-       retval = 0;
-out:
-       return retval;
-}
-
-static int __init init_aout_binfmt(void)
-{
-       return register_binfmt(&aout_format);
-}
-
-static void __exit exit_aout_binfmt(void)
-{
-       unregister_binfmt(&aout_format);
-}
-
-module_init(init_aout_binfmt);
-module_exit(exit_aout_binfmt);
-MODULE_LICENSE("GPL");
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
deleted file mode 100644 (file)
index dffd2ac..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/* 
- * Written 2000,2002 by Andi Kleen. 
- * 
- * Loosely based on the sparc64 and IA64 32bit emulation loaders.
- * This tricks binfmt_elf.c into loading 32bit binaries using lots 
- * of ugly preprocessor tricks. Talk about very very poor man's inheritance.
- */ 
-#define __ASM_X86_64_ELF_H 1
-
-#undef ELF_CLASS
-#define ELF_CLASS ELFCLASS32
-
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/rwsem.h>
-#include <linux/sched.h>
-#include <linux/compat.h>
-#include <linux/string.h>
-#include <linux/binfmts.h>
-#include <linux/mm.h>
-#include <linux/security.h>
-
-#include <asm/segment.h> 
-#include <asm/ptrace.h>
-#include <asm/processor.h>
-#include <asm/user32.h>
-#include <asm/sigcontext32.h>
-#include <asm/fpu32.h>
-#include <asm/i387.h>
-#include <asm/uaccess.h>
-#include <asm/ia32.h>
-#include <asm/vsyscall32.h>
-
-#define ELF_NAME "elf/i386"
-
-#define AT_SYSINFO 32
-#define AT_SYSINFO_EHDR                33
-
-int sysctl_vsyscall32 = 1;
-
-#undef ARCH_DLINFO
-#define ARCH_DLINFO do {  \
-       if (sysctl_vsyscall32) { \
-               current->mm->context.vdso = (void *)VSYSCALL32_BASE;    \
-               NEW_AUX_ENT(AT_SYSINFO, (u32)(u64)VSYSCALL32_VSYSCALL); \
-               NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL32_BASE);    \
-       }       \
-} while(0)
-
-struct file;
-struct elf_phdr; 
-
-#define IA32_EMULATOR 1
-
-#define ELF_ET_DYN_BASE                (TASK_UNMAPPED_BASE + 0x1000000)
-
-#undef ELF_ARCH
-#define ELF_ARCH EM_386
-
-#define ELF_DATA       ELFDATA2LSB
-
-#define USE_ELF_CORE_DUMP 1
-
-/* Override elfcore.h */ 
-#define _LINUX_ELFCORE_H 1
-typedef unsigned int elf_greg_t;
-
-#define ELF_NGREG (sizeof (struct user_regs_struct32) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-
-struct elf_siginfo
-{
-       int     si_signo;                       /* signal number */
-       int     si_code;                        /* extra code */
-       int     si_errno;                       /* errno */
-};
-
-#define jiffies_to_timeval(a,b) do { (b)->tv_usec = 0; (b)->tv_sec = (a)/HZ; }while(0)
-
-struct elf_prstatus
-{
-       struct elf_siginfo pr_info;     /* Info associated with signal */
-       short   pr_cursig;              /* Current signal */
-       unsigned int pr_sigpend;        /* Set of pending signals */
-       unsigned int pr_sighold;        /* Set of held signals */
-       pid_t   pr_pid;
-       pid_t   pr_ppid;
-       pid_t   pr_pgrp;
-       pid_t   pr_sid;
-       struct compat_timeval pr_utime; /* User time */
-       struct compat_timeval pr_stime; /* System time */
-       struct compat_timeval pr_cutime;        /* Cumulative user time */
-       struct compat_timeval pr_cstime;        /* Cumulative system time */
-       elf_gregset_t pr_reg;   /* GP registers */
-       int pr_fpvalid;         /* True if math co-processor being used.  */
-};
-
-#define ELF_PRARGSZ    (80)    /* Number of chars for args */
-
-struct elf_prpsinfo
-{
-       char    pr_state;       /* numeric process state */
-       char    pr_sname;       /* char for pr_state */
-       char    pr_zomb;        /* zombie */
-       char    pr_nice;        /* nice val */
-       unsigned int pr_flag;   /* flags */
-       __u16   pr_uid;
-       __u16   pr_gid;
-       pid_t   pr_pid, pr_ppid, pr_pgrp, pr_sid;
-       /* Lots missing */
-       char    pr_fname[16];   /* filename of executable */
-       char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
-};
-
-#define __STR(x) #x
-#define STR(x) __STR(x)
-
-#define _GET_SEG(x) \
-       ({ __u32 seg; asm("movl %%" STR(x) ",%0" : "=r"(seg)); seg; })
-
-/* Assumes current==process to be dumped */
-#define ELF_CORE_COPY_REGS(pr_reg, regs)                       \
-       pr_reg[0] = regs->rbx;                          \
-       pr_reg[1] = regs->rcx;                          \
-       pr_reg[2] = regs->rdx;                          \
-       pr_reg[3] = regs->rsi;                          \
-       pr_reg[4] = regs->rdi;                          \
-       pr_reg[5] = regs->rbp;                          \
-       pr_reg[6] = regs->rax;                          \
-       pr_reg[7] = _GET_SEG(ds);                       \
-       pr_reg[8] = _GET_SEG(es);                       \
-       pr_reg[9] = _GET_SEG(fs);                       \
-       pr_reg[10] = _GET_SEG(gs);                      \
-       pr_reg[11] = regs->orig_rax;                    \
-       pr_reg[12] = regs->rip;                         \
-       pr_reg[13] = regs->cs;                          \
-       pr_reg[14] = regs->eflags;                      \
-       pr_reg[15] = regs->rsp;                         \
-       pr_reg[16] = regs->ss;
-
-#define user user32
-
-#undef elf_read_implies_exec
-#define elf_read_implies_exec(ex, executable_stack)     (executable_stack != EXSTACK_DISABLE_X)
-//#include <asm/ia32.h>
-#include <linux/elf.h>
-
-typedef struct user_i387_ia32_struct elf_fpregset_t;
-typedef struct user32_fxsr_struct elf_fpxregset_t;
-
-
-static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
-{
-       ELF_CORE_COPY_REGS((*elfregs), regs)
-}
-
-static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
-{      
-       struct pt_regs *pp = task_pt_regs(t);
-       ELF_CORE_COPY_REGS((*elfregs), pp);
-       /* fix wrong segments */ 
-       (*elfregs)[7] = t->thread.ds; 
-       (*elfregs)[9] = t->thread.fsindex; 
-       (*elfregs)[10] = t->thread.gsindex; 
-       (*elfregs)[8] = t->thread.es;   
-       return 1; 
-}
-
-static inline int 
-elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpregset_t *fpu)
-{
-       struct _fpstate_ia32 *fpstate = (void*)fpu; 
-       mm_segment_t oldfs = get_fs();
-
-       if (!tsk_used_math(tsk))
-               return 0;
-       if (!regs)
-               regs = task_pt_regs(tsk);
-       if (tsk == current)
-               unlazy_fpu(tsk);
-       set_fs(KERNEL_DS); 
-       save_i387_ia32(tsk, fpstate, regs, 1);
-       /* Correct for i386 bug. It puts the fop into the upper 16bits of 
-          the tag word (like FXSAVE), not into the fcs*/ 
-       fpstate->cssel |= fpstate->tag & 0xffff0000; 
-       set_fs(oldfs); 
-       return 1; 
-}
-
-#define ELF_CORE_COPY_XFPREGS 1
-static inline int 
-elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
-{
-       struct pt_regs *regs = task_pt_regs(t);
-       if (!tsk_used_math(t))
-               return 0;
-       if (t == current)
-               unlazy_fpu(t); 
-       memcpy(xfpu, &t->thread.i387.fxsave, sizeof(elf_fpxregset_t));
-       xfpu->fcs = regs->cs; 
-       xfpu->fos = t->thread.ds; /* right? */ 
-       return 1;
-}
-
-#undef elf_check_arch
-#define elf_check_arch(x) \
-       ((x)->e_machine == EM_386)
-
-extern int force_personality32;
-
-#define ELF_EXEC_PAGESIZE PAGE_SIZE
-#define ELF_HWCAP (boot_cpu_data.x86_capability[0])
-#define ELF_PLATFORM  ("i686")
-#define SET_PERSONALITY(ex, ibcs2)                     \
-do {                                                   \
-       unsigned long new_flags = 0;                            \
-       if ((ex).e_ident[EI_CLASS] == ELFCLASS32)               \
-               new_flags = _TIF_IA32;                          \
-       if ((current_thread_info()->flags & _TIF_IA32)          \
-           != new_flags)                                       \
-               set_thread_flag(TIF_ABI_PENDING);               \
-       else                                                    \
-               clear_thread_flag(TIF_ABI_PENDING);             \
-       /* XXX This overwrites the user set personality */      \
-       current->personality |= force_personality32;            \
-} while (0)
-
-/* Override some function names */
-#define elf_format                     elf32_format
-
-#define init_elf_binfmt                        init_elf32_binfmt
-#define exit_elf_binfmt                        exit_elf32_binfmt
-
-#define load_elf_binary load_elf32_binary
-
-#define ELF_PLAT_INIT(r, load_addr)    elf32_init(r)
-
-#undef start_thread
-#define start_thread(regs,new_rip,new_rsp) do { \
-       asm volatile("movl %0,%%fs" :: "r" (0)); \
-       asm volatile("movl %0,%%es; movl %0,%%ds": :"r" (__USER32_DS)); \
-       load_gs_index(0); \
-       (regs)->rip = (new_rip); \
-       (regs)->rsp = (new_rsp); \
-       (regs)->eflags = 0x200; \
-       (regs)->cs = __USER32_CS; \
-       (regs)->ss = __USER32_DS; \
-       set_fs(USER_DS); \
-} while(0) 
-
-
-#include <linux/module.h>
-
-MODULE_DESCRIPTION("Binary format loader for compatibility with IA32 ELF binaries."); 
-MODULE_AUTHOR("Eric Youngdale, Andi Kleen");
-
-#undef MODULE_DESCRIPTION
-#undef MODULE_AUTHOR
-
-static void elf32_init(struct pt_regs *);
-
-#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
-#define arch_setup_additional_pages syscall32_setup_pages
-extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
-
-#include "../../../fs/binfmt_elf.c" 
-
-static void elf32_init(struct pt_regs *regs)
-{
-       struct task_struct *me = current; 
-       regs->rdi = 0;
-       regs->rsi = 0;
-       regs->rdx = 0;
-       regs->rcx = 0;
-       regs->rax = 0;
-       regs->rbx = 0; 
-       regs->rbp = 0; 
-       regs->r8 = regs->r9 = regs->r10 = regs->r11 = regs->r12 =
-               regs->r13 = regs->r14 = regs->r15 = 0; 
-    me->thread.fs = 0; 
-       me->thread.gs = 0;
-       me->thread.fsindex = 0; 
-       me->thread.gsindex = 0;
-    me->thread.ds = __USER_DS; 
-       me->thread.es = __USER_DS;
-}
-
-#ifdef CONFIG_SYSCTL
-/* Register vsyscall32 into the ABI table */
-#include <linux/sysctl.h>
-
-static ctl_table abi_table2[] = {
-       {
-               .ctl_name       = 99,
-               .procname       = "vsyscall32",
-               .data           = &sysctl_vsyscall32,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec
-       },
-       {}
-};
-
-static ctl_table abi_root_table2[] = {
-       {
-               .ctl_name = CTL_ABI,
-               .procname = "abi",
-               .mode = 0555,
-               .child = abi_table2
-       },
-       {}
-};
-
-static __init int ia32_binfmt_init(void)
-{ 
-       register_sysctl_table(abi_root_table2);
-       return 0;
-}
-__initcall(ia32_binfmt_init);
-#endif
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
deleted file mode 100644 (file)
index 6ea19c2..0000000
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- *  linux/arch/x86_64/ia32/ia32_signal.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- *  1997-11-28  Modified for POSIX.1b signals by Richard Henderson
- *  2000-06-20  Pentium III FXSR, SSE support by Gareth Hughes
- *  2000-12-*   x86-64 compatibility mode signal handling by Andi Kleen
- */
-
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/kernel.h>
-#include <linux/signal.h>
-#include <linux/errno.h>
-#include <linux/wait.h>
-#include <linux/ptrace.h>
-#include <linux/unistd.h>
-#include <linux/stddef.h>
-#include <linux/personality.h>
-#include <linux/compat.h>
-#include <linux/binfmts.h>
-#include <asm/ucontext.h>
-#include <asm/uaccess.h>
-#include <asm/i387.h>
-#include <asm/ia32.h>
-#include <asm/ptrace.h>
-#include <asm/ia32_unistd.h>
-#include <asm/user32.h>
-#include <asm/sigcontext32.h>
-#include <asm/fpu32.h>
-#include <asm/proto.h>
-#include <asm/vsyscall32.h>
-
-#define DEBUG_SIG 0
-
-#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
-
-asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
-void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
-
-int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
-{
-       int err;
-       if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
-               return -EFAULT;
-
-       /* If you change siginfo_t structure, please make sure that
-          this code is fixed accordingly.
-          It should never copy any pad contained in the structure
-          to avoid security leaks, but must copy the generic
-          3 ints plus the relevant union member.  */
-       err = __put_user(from->si_signo, &to->si_signo);
-       err |= __put_user(from->si_errno, &to->si_errno);
-       err |= __put_user((short)from->si_code, &to->si_code);
-
-       if (from->si_code < 0) {
-               err |= __put_user(from->si_pid, &to->si_pid);
-               err |= __put_user(from->si_uid, &to->si_uid);
-               err |= __put_user(ptr_to_compat(from->si_ptr), &to->si_ptr);
-       } else {
-               /* First 32bits of unions are always present:
-                * si_pid === si_band === si_tid === si_addr(LS half) */
-               err |= __put_user(from->_sifields._pad[0], &to->_sifields._pad[0]);
-               switch (from->si_code >> 16) {
-               case __SI_FAULT >> 16:
-                       break;
-               case __SI_CHLD >> 16:
-                       err |= __put_user(from->si_utime, &to->si_utime);
-                       err |= __put_user(from->si_stime, &to->si_stime);
-                       err |= __put_user(from->si_status, &to->si_status);
-                       /* FALL THROUGH */
-               default:
-               case __SI_KILL >> 16:
-                       err |= __put_user(from->si_uid, &to->si_uid);
-                       break;
-               case __SI_POLL >> 16:
-                       err |= __put_user(from->si_fd, &to->si_fd); 
-                       break;
-               case __SI_TIMER >> 16:
-                       err |= __put_user(from->si_overrun, &to->si_overrun); 
-                       err |= __put_user(ptr_to_compat(from->si_ptr),
-                                       &to->si_ptr);
-                       break;
-               case __SI_RT >> 16: /* This is not generated by the kernel as of now.  */
-               case __SI_MESGQ >> 16:
-                       err |= __put_user(from->si_uid, &to->si_uid);
-                       err |= __put_user(from->si_int, &to->si_int);
-                       break;
-               }
-       }
-       return err;
-}
-
-int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
-{
-       int err;
-       u32 ptr32;
-       if (!access_ok (VERIFY_READ, from, sizeof(compat_siginfo_t)))
-               return -EFAULT;
-
-       err = __get_user(to->si_signo, &from->si_signo);
-       err |= __get_user(to->si_errno, &from->si_errno);
-       err |= __get_user(to->si_code, &from->si_code);
-
-       err |= __get_user(to->si_pid, &from->si_pid);
-       err |= __get_user(to->si_uid, &from->si_uid);
-       err |= __get_user(ptr32, &from->si_ptr);
-       to->si_ptr = compat_ptr(ptr32);
-
-       return err;
-}
-
-asmlinkage long
-sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
-{
-       mask &= _BLOCKABLE;
-       spin_lock_irq(&current->sighand->siglock);
-       current->saved_sigmask = current->blocked;
-       siginitset(&current->blocked, mask);
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-
-       current->state = TASK_INTERRUPTIBLE;
-       schedule();
-       set_thread_flag(TIF_RESTORE_SIGMASK);
-       return -ERESTARTNOHAND;
-}
-
-asmlinkage long
-sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,
-                 stack_ia32_t __user *uoss_ptr, 
-                 struct pt_regs *regs)
-{
-       stack_t uss,uoss; 
-       int ret;
-       mm_segment_t seg; 
-       if (uss_ptr) { 
-               u32 ptr;
-               memset(&uss,0,sizeof(stack_t));
-               if (!access_ok(VERIFY_READ,uss_ptr,sizeof(stack_ia32_t)) ||
-                           __get_user(ptr, &uss_ptr->ss_sp) ||
-                           __get_user(uss.ss_flags, &uss_ptr->ss_flags) ||
-                           __get_user(uss.ss_size, &uss_ptr->ss_size))
-                       return -EFAULT;
-               uss.ss_sp = compat_ptr(ptr);
-       }
-       seg = get_fs(); 
-       set_fs(KERNEL_DS); 
-       ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss, regs->rsp);
-       set_fs(seg); 
-       if (ret >= 0 && uoss_ptr)  {
-               if (!access_ok(VERIFY_WRITE,uoss_ptr,sizeof(stack_ia32_t)) ||
-                   __put_user(ptr_to_compat(uoss.ss_sp), &uoss_ptr->ss_sp) ||
-                   __put_user(uoss.ss_flags, &uoss_ptr->ss_flags) ||
-                   __put_user(uoss.ss_size, &uoss_ptr->ss_size))
-                       ret = -EFAULT;
-       }       
-       return ret;     
-}
-
-/*
- * Do a signal return; undo the signal stack.
- */
-
-struct sigframe
-{
-       u32 pretcode;
-       int sig;
-       struct sigcontext_ia32 sc;
-       struct _fpstate_ia32 fpstate;
-       unsigned int extramask[_COMPAT_NSIG_WORDS-1];
-       char retcode[8];
-};
-
-struct rt_sigframe
-{
-       u32 pretcode;
-       int sig;
-       u32 pinfo;
-       u32 puc;
-       compat_siginfo_t info;
-       struct ucontext_ia32 uc;
-       struct _fpstate_ia32 fpstate;
-       char retcode[8];
-};
-
-static int
-ia32_restore_sigcontext(struct pt_regs *regs, struct sigcontext_ia32 __user *sc, unsigned int *peax)
-{
-       unsigned int err = 0;
-       
-       /* Always make any pending restarted system calls return -EINTR */
-       current_thread_info()->restart_block.fn = do_no_restart_syscall;
-
-#if DEBUG_SIG
-       printk("SIG restore_sigcontext: sc=%p err(%x) eip(%x) cs(%x) flg(%x)\n",
-               sc, sc->err, sc->eip, sc->cs, sc->eflags);
-#endif
-#define COPY(x)                { \
-       unsigned int reg;                       \
-       err |= __get_user(reg, &sc->e ##x);     \
-       regs->r ## x = reg;                     \
-}
-
-#define RELOAD_SEG(seg,mask)                                           \
-       { unsigned int cur;                                             \
-         unsigned short pre;                                           \
-         err |= __get_user(pre, &sc->seg);                             \
-         asm volatile("movl %%" #seg ",%0" : "=r" (cur));              \
-         pre |= mask;                                                  \
-         if (pre != cur) loadsegment(seg,pre); }
-
-       /* Reload fs and gs if they have changed in the signal handler.
-          This does not handle long fs/gs base changes in the handler, but 
-          does not clobber them at least in the normal case. */ 
-       
-       {
-               unsigned gs, oldgs; 
-               err |= __get_user(gs, &sc->gs);
-               gs |= 3; 
-               asm("movl %%gs,%0" : "=r" (oldgs));
-               if (gs != oldgs)
-               load_gs_index(gs); 
-       } 
-       RELOAD_SEG(fs,3);
-       RELOAD_SEG(ds,3);
-       RELOAD_SEG(es,3);
-
-       COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
-       COPY(dx); COPY(cx); COPY(ip);
-       /* Don't touch extended registers */ 
-       
-       err |= __get_user(regs->cs, &sc->cs); 
-       regs->cs |= 3;  
-       err |= __get_user(regs->ss, &sc->ss); 
-       regs->ss |= 3; 
-
-       {
-               unsigned int tmpflags;
-               err |= __get_user(tmpflags, &sc->eflags);
-               regs->eflags = (regs->eflags & ~0x40DD5) | (tmpflags & 0x40DD5);
-               regs->orig_rax = -1;            /* disable syscall checks */
-       }
-
-       {
-               u32 tmp;
-               struct _fpstate_ia32 __user * buf;
-               err |= __get_user(tmp, &sc->fpstate);
-               buf = compat_ptr(tmp);
-               if (buf) {
-                       if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
-                               goto badframe;
-                       err |= restore_i387_ia32(current, buf, 0);
-               } else {
-                       struct task_struct *me = current;
-                       if (used_math()) {
-                               clear_fpu(me);
-                               clear_used_math();
-                       }
-               }
-       }
-
-       { 
-               u32 tmp;
-               err |= __get_user(tmp, &sc->eax);
-               *peax = tmp;
-       }
-       return err;
-
-badframe:
-       return 1;
-}
-
-asmlinkage long sys32_sigreturn(struct pt_regs *regs)
-{
-       struct sigframe __user *frame = (struct sigframe __user *)(regs->rsp-8);
-       sigset_t set;
-       unsigned int eax;
-
-       if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
-               goto badframe;
-       if (__get_user(set.sig[0], &frame->sc.oldmask)
-           || (_COMPAT_NSIG_WORDS > 1
-               && __copy_from_user((((char *) &set.sig) + 4), &frame->extramask,
-                                   sizeof(frame->extramask))))
-               goto badframe;
-
-       sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-       
-       if (ia32_restore_sigcontext(regs, &frame->sc, &eax))
-               goto badframe;
-       return eax;
-
-badframe:
-       signal_fault(regs, frame, "32bit sigreturn");
-       return 0;
-}      
-
-asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
-{
-       struct rt_sigframe __user *frame;
-       sigset_t set;
-       unsigned int eax;
-       struct pt_regs tregs;
-
-       frame = (struct rt_sigframe __user *)(regs->rsp - 4);
-
-       if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
-               goto badframe;
-       if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
-               goto badframe;
-
-       sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-       
-       if (ia32_restore_sigcontext(regs, &frame->uc.uc_mcontext, &eax))
-               goto badframe;
-
-       tregs = *regs;
-       if (sys32_sigaltstack(&frame->uc.uc_stack, NULL, &tregs) == -EFAULT)
-               goto badframe;
-
-       return eax;
-
-badframe:
-       signal_fault(regs,frame,"32bit rt sigreturn");
-       return 0;
-}      
-
-/*
- * Set up a signal frame.
- */
-
-static int
-ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, struct _fpstate_ia32 __user *fpstate,
-                struct pt_regs *regs, unsigned int mask)
-{
-       int tmp, err = 0;
-
-       tmp = 0;
-       __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
-       __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
-       __asm__("movl %%ds,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->ds);
-       __asm__("movl %%es,%0" : "=r"(tmp): "0"(tmp));
-       err |= __put_user(tmp, (unsigned int __user *)&sc->es);
-
-       err |= __put_user((u32)regs->rdi, &sc->edi);
-       err |= __put_user((u32)regs->rsi, &sc->esi);
-       err |= __put_user((u32)regs->rbp, &sc->ebp);
-       err |= __put_user((u32)regs->rsp, &sc->esp);
-       err |= __put_user((u32)regs->rbx, &sc->ebx);
-       err |= __put_user((u32)regs->rdx, &sc->edx);
-       err |= __put_user((u32)regs->rcx, &sc->ecx);
-       err |= __put_user((u32)regs->rax, &sc->eax);
-       err |= __put_user((u32)regs->cs, &sc->cs);
-       err |= __put_user((u32)regs->ss, &sc->ss);
-       err |= __put_user(current->thread.trap_no, &sc->trapno);
-       err |= __put_user(current->thread.error_code, &sc->err);
-       err |= __put_user((u32)regs->rip, &sc->eip);
-       err |= __put_user((u32)regs->eflags, &sc->eflags);
-       err |= __put_user((u32)regs->rsp, &sc->esp_at_signal);
-
-       tmp = save_i387_ia32(current, fpstate, regs, 0);
-       if (tmp < 0)
-               err = -EFAULT;
-       else { 
-               clear_used_math();
-               stts();
-               err |= __put_user(ptr_to_compat(tmp ? fpstate : NULL),
-                                       &sc->fpstate);
-       }
-
-       /* non-iBCS2 extensions.. */
-       err |= __put_user(mask, &sc->oldmask);
-       err |= __put_user(current->thread.cr2, &sc->cr2);
-
-       return err;
-}
-
-/*
- * Determine which stack to use..
- */
-static void __user *
-get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
-{
-       unsigned long rsp;
-
-       /* Default to using normal stack */
-       rsp = regs->rsp;
-
-       /* This is the X/Open sanctioned signal stack switching.  */
-       if (ka->sa.sa_flags & SA_ONSTACK) {
-               if (sas_ss_flags(rsp) == 0)
-                       rsp = current->sas_ss_sp + current->sas_ss_size;
-       }
-
-       /* This is the legacy signal stack switching. */
-       else if ((regs->ss & 0xffff) != __USER_DS &&
-               !(ka->sa.sa_flags & SA_RESTORER) &&
-                ka->sa.sa_restorer) {
-               rsp = (unsigned long) ka->sa.sa_restorer;
-       }
-
-       rsp -= frame_size;
-       /* Align the stack pointer according to the i386 ABI,
-        * i.e. so that on function entry ((sp + 4) & 15) == 0. */
-       rsp = ((rsp + 4) & -16ul) - 4;
-       return (void __user *) rsp;
-}
-
-int ia32_setup_frame(int sig, struct k_sigaction *ka,
-                    compat_sigset_t *set, struct pt_regs * regs)
-{
-       struct sigframe __user *frame;
-       int err = 0;
-
-       frame = get_sigframe(ka, regs, sizeof(*frame));
-
-       if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
-               goto give_sigsegv;
-
-       err |= __put_user(sig, &frame->sig);
-       if (err)
-               goto give_sigsegv;
-
-       err |= ia32_setup_sigcontext(&frame->sc, &frame->fpstate, regs,
-                                       set->sig[0]);
-       if (err)
-               goto give_sigsegv;
-
-       if (_COMPAT_NSIG_WORDS > 1) {
-               err |= __copy_to_user(frame->extramask, &set->sig[1],
-                                     sizeof(frame->extramask));
-       }
-       if (err)
-               goto give_sigsegv;
-
-       /* Return stub is in 32bit vsyscall page */
-       { 
-               void __user *restorer;
-               if (current->binfmt->hasvdso)
-                       restorer = VSYSCALL32_SIGRETURN;
-               else
-                       restorer = (void *)&frame->retcode;
-               if (ka->sa.sa_flags & SA_RESTORER)
-                       restorer = ka->sa.sa_restorer;       
-               err |= __put_user(ptr_to_compat(restorer), &frame->pretcode);
-       }
-       /* These are actually not used anymore, but left because some 
-          gdb versions depend on them as a marker. */
-       { 
-               /* copy_to_user optimizes that into a single 8 byte store */
-               static const struct { 
-                       u16 poplmovl;
-                       u32 val;
-                       u16 int80;    
-                       u16 pad; 
-               } __attribute__((packed)) code = { 
-                       0xb858,          /* popl %eax ; movl $...,%eax */
-                       __NR_ia32_sigreturn,   
-                       0x80cd,         /* int $0x80 */
-                       0,
-               }; 
-               err |= __copy_to_user(frame->retcode, &code, 8); 
-       }
-       if (err)
-               goto give_sigsegv;
-
-       /* Set up registers for signal handler */
-       regs->rsp = (unsigned long) frame;
-       regs->rip = (unsigned long) ka->sa.sa_handler;
-
-       /* Make -mregparm=3 work */
-       regs->rax = sig;
-       regs->rdx = 0;
-       regs->rcx = 0;
-
-       asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 
-       asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 
-
-       regs->cs = __USER32_CS; 
-       regs->ss = __USER32_DS; 
-
-       set_fs(USER_DS);
-       regs->eflags &= ~TF_MASK;
-       if (test_thread_flag(TIF_SINGLESTEP))
-               ptrace_notify(SIGTRAP);
-
-#if DEBUG_SIG
-       printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n",
-               current->comm, current->pid, frame, regs->rip, frame->pretcode);
-#endif
-
-       return 0;
-
-give_sigsegv:
-       force_sigsegv(sig, current);
-       return -EFAULT;
-}
-
-int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-                       compat_sigset_t *set, struct pt_regs * regs)
-{
-       struct rt_sigframe __user *frame;
-       int err = 0;
-
-       frame = get_sigframe(ka, regs, sizeof(*frame));
-
-       if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
-               goto give_sigsegv;
-
-       {
-               struct exec_domain *ed = current_thread_info()->exec_domain;
-               err |= __put_user((ed
-                          && ed->signal_invmap
-                          && sig < 32
-                          ? ed->signal_invmap[sig]
-                          : sig),
-                         &frame->sig);
-       }
-       err |= __put_user(ptr_to_compat(&frame->info), &frame->pinfo);
-       err |= __put_user(ptr_to_compat(&frame->uc), &frame->puc);
-       err |= copy_siginfo_to_user32(&frame->info, info);
-       if (err)
-               goto give_sigsegv;
-
-       /* Create the ucontext.  */
-       err |= __put_user(0, &frame->uc.uc_flags);
-       err |= __put_user(0, &frame->uc.uc_link);
-       err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-       err |= __put_user(sas_ss_flags(regs->rsp),
-                         &frame->uc.uc_stack.ss_flags);
-       err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
-       err |= ia32_setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate,
-                               regs, set->sig[0]);
-       err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
-       if (err)
-               goto give_sigsegv;
-
-       
-       { 
-               void __user *restorer = VSYSCALL32_RTSIGRETURN; 
-               if (ka->sa.sa_flags & SA_RESTORER)
-                       restorer = ka->sa.sa_restorer;       
-               err |= __put_user(ptr_to_compat(restorer), &frame->pretcode);
-       }
-
-       /* This is movl $,%eax ; int $0x80 */
-       /* Not actually used anymore, but left because some gdb versions
-          need it. */ 
-       { 
-               /* __copy_to_user optimizes that into a single 8 byte store */
-               static const struct { 
-                       u8 movl; 
-                       u32 val; 
-                       u16 int80; 
-                       u16 pad;
-                       u8  pad2;                               
-               } __attribute__((packed)) code = { 
-                       0xb8,
-                       __NR_ia32_rt_sigreturn,
-                       0x80cd,
-                       0,
-               }; 
-               err |= __copy_to_user(frame->retcode, &code, 8); 
-       } 
-       if (err)
-               goto give_sigsegv;
-
-       /* Set up registers for signal handler */
-       regs->rsp = (unsigned long) frame;
-       regs->rip = (unsigned long) ka->sa.sa_handler;
-
-       /* Make -mregparm=3 work */
-       regs->rax = sig;
-       regs->rdx = (unsigned long) &frame->info;
-       regs->rcx = (unsigned long) &frame->uc;
-
-       /* Make -mregparm=3 work */
-       regs->rax = sig;
-       regs->rdx = (unsigned long) &frame->info;
-       regs->rcx = (unsigned long) &frame->uc;
-
-       asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 
-       asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 
-       
-       regs->cs = __USER32_CS; 
-       regs->ss = __USER32_DS; 
-
-       set_fs(USER_DS);
-       regs->eflags &= ~TF_MASK;
-       if (test_thread_flag(TIF_SINGLESTEP))
-               ptrace_notify(SIGTRAP);
-
-#if DEBUG_SIG
-       printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%u\n",
-               current->comm, current->pid, frame, regs->rip, frame->pretcode);
-#endif
-
-       return 0;
-
-give_sigsegv:
-       force_sigsegv(sig, current);
-       return -EFAULT;
-}
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
deleted file mode 100644 (file)
index 18b2318..0000000
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- * Compatibility mode system call entry point for x86-64. 
- *             
- * Copyright 2000-2002 Andi Kleen, SuSE Labs.
- */             
-
-#include <asm/dwarf2.h>
-#include <asm/calling.h>
-#include <asm/asm-offsets.h>
-#include <asm/current.h>
-#include <asm/errno.h>
-#include <asm/ia32_unistd.h>   
-#include <asm/thread_info.h>   
-#include <asm/segment.h>
-#include <asm/vsyscall32.h>
-#include <asm/irqflags.h>
-#include <linux/linkage.h>
-
-#define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
-
-       .macro IA32_ARG_FIXUP noebp=0
-       movl    %edi,%r8d
-       .if \noebp
-       .else
-       movl    %ebp,%r9d
-       .endif
-       xchg    %ecx,%esi
-       movl    %ebx,%edi
-       movl    %edx,%edx       /* zero extension */
-       .endm 
-
-       /* clobbers %eax */     
-       .macro  CLEAR_RREGS
-       xorl    %eax,%eax
-       movq    %rax,R11(%rsp)
-       movq    %rax,R10(%rsp)
-       movq    %rax,R9(%rsp)
-       movq    %rax,R8(%rsp)
-       .endm
-
-       .macro LOAD_ARGS32 offset
-       movl \offset(%rsp),%r11d
-       movl \offset+8(%rsp),%r10d
-       movl \offset+16(%rsp),%r9d
-       movl \offset+24(%rsp),%r8d
-       movl \offset+40(%rsp),%ecx
-       movl \offset+48(%rsp),%edx
-       movl \offset+56(%rsp),%esi
-       movl \offset+64(%rsp),%edi
-       movl \offset+72(%rsp),%eax
-       .endm
-       
-       .macro CFI_STARTPROC32 simple
-       CFI_STARTPROC   \simple
-       CFI_UNDEFINED   r8
-       CFI_UNDEFINED   r9
-       CFI_UNDEFINED   r10
-       CFI_UNDEFINED   r11
-       CFI_UNDEFINED   r12
-       CFI_UNDEFINED   r13
-       CFI_UNDEFINED   r14
-       CFI_UNDEFINED   r15
-       .endm
-
-/*
- * 32bit SYSENTER instruction entry.
- *
- * Arguments:
- * %eax        System call number.
- * %ebx Arg1
- * %ecx Arg2
- * %edx Arg3
- * %esi Arg4
- * %edi Arg5
- * %ebp user stack
- * 0(%ebp) Arg6        
- *     
- * Interrupts off.
- *     
- * This is purely a fast path. For anything complicated we use the int 0x80
- * path below. Set up a complete hardware stack frame to share code
- * with the int 0x80 path.
- */    
-ENTRY(ia32_sysenter_target)
-       CFI_STARTPROC32 simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,0
-       CFI_REGISTER    rsp,rbp
-       swapgs
-       movq    %gs:pda_kernelstack, %rsp
-       addq    $(PDA_STACKOFFSET),%rsp 
-       /*
-        * No need to follow this irqs on/off section: the syscall
-        * disabled irqs, here we enable it straight after entry:
-        */
-       sti     
-       movl    %ebp,%ebp               /* zero extension */
-       pushq   $__USER32_DS
-       CFI_ADJUST_CFA_OFFSET 8
-       /*CFI_REL_OFFSET ss,0*/
-       pushq   %rbp
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rsp,0
-       pushfq
-       CFI_ADJUST_CFA_OFFSET 8
-       /*CFI_REL_OFFSET rflags,0*/
-       movl    $VSYSCALL32_SYSEXIT, %r10d
-       CFI_REGISTER rip,r10
-       pushq   $__USER32_CS
-       CFI_ADJUST_CFA_OFFSET 8
-       /*CFI_REL_OFFSET cs,0*/
-       movl    %eax, %eax
-       pushq   %r10
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rip,0
-       pushq   %rax
-       CFI_ADJUST_CFA_OFFSET 8
-       cld
-       SAVE_ARGS 0,0,1
-       /* no need to do an access_ok check here because rbp has been
-          32bit zero extended */ 
-1:     movl    (%rbp),%r9d
-       .section __ex_table,"a"
-       .quad 1b,ia32_badarg
-       .previous       
-       GET_THREAD_INFO(%r10)
-       orl    $TS_COMPAT,threadinfo_status(%r10)
-       testl  $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
-       CFI_REMEMBER_STATE
-       jnz  sysenter_tracesys
-sysenter_do_call:      
-       cmpl    $(IA32_NR_syscalls-1),%eax
-       ja      ia32_badsys
-       IA32_ARG_FIXUP 1
-       call    *ia32_sys_call_table(,%rax,8)
-       movq    %rax,RAX-ARGOFFSET(%rsp)
-       GET_THREAD_INFO(%r10)
-       cli
-       TRACE_IRQS_OFF
-       testl   $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
-       jnz     int_ret_from_sys_call
-       andl    $~TS_COMPAT,threadinfo_status(%r10)
-       /* clear IF, that popfq doesn't enable interrupts early */
-       andl  $~0x200,EFLAGS-R11(%rsp) 
-       RESTORE_ARGS 1,24,1,1,1,1
-       popfq
-       CFI_ADJUST_CFA_OFFSET -8
-       /*CFI_RESTORE rflags*/
-       popq    %rcx                            /* User %esp */
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_REGISTER rsp,rcx
-       movl    $VSYSCALL32_SYSEXIT,%edx        /* User %eip */
-       CFI_REGISTER rip,rdx
-       TRACE_IRQS_ON
-       swapgs
-       sti             /* sti only takes effect after the next instruction */
-       /* sysexit */
-       .byte   0xf, 0x35
-
-sysenter_tracesys:
-       CFI_RESTORE_STATE
-       SAVE_REST
-       CLEAR_RREGS
-       movq    $-ENOSYS,RAX(%rsp)      /* really needed? */
-       movq    %rsp,%rdi        /* &pt_regs -> arg1 */
-       call    syscall_trace_enter
-       LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */
-       RESTORE_REST
-       movl    %ebp, %ebp
-       /* no need to do an access_ok check here because rbp has been
-          32bit zero extended */ 
-1:     movl    (%rbp),%r9d
-       .section __ex_table,"a"
-       .quad 1b,ia32_badarg
-       .previous
-       jmp     sysenter_do_call
-       CFI_ENDPROC
-ENDPROC(ia32_sysenter_target)
-
-/*
- * 32bit SYSCALL instruction entry.
- *
- * Arguments:
- * %eax        System call number.
- * %ebx Arg1
- * %ecx return EIP 
- * %edx Arg3
- * %esi Arg4
- * %edi Arg5
- * %ebp Arg2    [note: not saved in the stack frame, should not be touched]
- * %esp user stack 
- * 0(%esp) Arg6
- *     
- * Interrupts off.
- *     
- * This is purely a fast path. For anything complicated we use the int 0x80
- * path below. Set up a complete hardware stack frame to share code
- * with the int 0x80 path.     
- */    
-ENTRY(ia32_cstar_target)
-       CFI_STARTPROC32 simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,PDA_STACKOFFSET
-       CFI_REGISTER    rip,rcx
-       /*CFI_REGISTER  rflags,r11*/
-       swapgs
-       movl    %esp,%r8d
-       CFI_REGISTER    rsp,r8
-       movq    %gs:pda_kernelstack,%rsp
-       /*
-        * No need to follow this irqs on/off section: the syscall
-        * disabled irqs and here we enable it straight after entry:
-        */
-       sti
-       SAVE_ARGS 8,1,1
-       movl    %eax,%eax       /* zero extension */
-       movq    %rax,ORIG_RAX-ARGOFFSET(%rsp)
-       movq    %rcx,RIP-ARGOFFSET(%rsp)
-       CFI_REL_OFFSET rip,RIP-ARGOFFSET
-       movq    %rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
-       movl    %ebp,%ecx
-       movq    $__USER32_CS,CS-ARGOFFSET(%rsp)
-       movq    $__USER32_DS,SS-ARGOFFSET(%rsp)
-       movq    %r11,EFLAGS-ARGOFFSET(%rsp)
-       /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
-       movq    %r8,RSP-ARGOFFSET(%rsp) 
-       CFI_REL_OFFSET rsp,RSP-ARGOFFSET
-       /* no need to do an access_ok check here because r8 has been
-          32bit zero extended */ 
-       /* hardware stack frame is complete now */      
-1:     movl    (%r8),%r9d
-       .section __ex_table,"a"
-       .quad 1b,ia32_badarg
-       .previous       
-       GET_THREAD_INFO(%r10)
-       orl   $TS_COMPAT,threadinfo_status(%r10)
-       testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
-       CFI_REMEMBER_STATE
-       jnz   cstar_tracesys
-cstar_do_call: 
-       cmpl $IA32_NR_syscalls-1,%eax
-       ja  ia32_badsys
-       IA32_ARG_FIXUP 1
-       call *ia32_sys_call_table(,%rax,8)
-       movq %rax,RAX-ARGOFFSET(%rsp)
-       GET_THREAD_INFO(%r10)
-       cli
-       TRACE_IRQS_OFF
-       testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
-       jnz  int_ret_from_sys_call
-       andl $~TS_COMPAT,threadinfo_status(%r10)
-       RESTORE_ARGS 1,-ARG_SKIP,1,1,1
-       movl RIP-ARGOFFSET(%rsp),%ecx
-       CFI_REGISTER rip,rcx
-       movl EFLAGS-ARGOFFSET(%rsp),%r11d       
-       /*CFI_REGISTER rflags,r11*/
-       TRACE_IRQS_ON
-       movl RSP-ARGOFFSET(%rsp),%esp
-       CFI_RESTORE rsp
-       swapgs
-       sysretl
-       
-cstar_tracesys:        
-       CFI_RESTORE_STATE
-       SAVE_REST
-       CLEAR_RREGS
-       movq $-ENOSYS,RAX(%rsp) /* really needed? */
-       movq %rsp,%rdi        /* &pt_regs -> arg1 */
-       call syscall_trace_enter
-       LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */
-       RESTORE_REST
-       movl RSP-ARGOFFSET(%rsp), %r8d
-       /* no need to do an access_ok check here because r8 has been
-          32bit zero extended */ 
-1:     movl    (%r8),%r9d
-       .section __ex_table,"a"
-       .quad 1b,ia32_badarg
-       .previous
-       jmp cstar_do_call
-END(ia32_cstar_target)
-                               
-ia32_badarg:
-       movq $-EFAULT,%rax
-       jmp ia32_sysret
-       CFI_ENDPROC
-
-/* 
- * Emulated IA32 system calls via int 0x80. 
- *
- * Arguments:   
- * %eax        System call number.
- * %ebx Arg1
- * %ecx Arg2
- * %edx Arg3
- * %esi Arg4
- * %edi Arg5
- * %ebp Arg6    [note: not saved in the stack frame, should not be touched]
- *
- * Notes:
- * Uses the same stack frame as the x86-64 version.    
- * All registers except %eax must be saved (but ptrace may violate that)
- * Arguments are zero extended. For system calls that want sign extension and
- * take long arguments a wrapper is needed. Most calls can just be called
- * directly.
- * Assumes it is only called from user space and entered with interrupts off.  
- */                            
-
-ENTRY(ia32_syscall)
-       CFI_STARTPROC32 simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,SS+8-RIP
-       /*CFI_REL_OFFSET        ss,SS-RIP*/
-       CFI_REL_OFFSET  rsp,RSP-RIP
-       /*CFI_REL_OFFSET        rflags,EFLAGS-RIP*/
-       /*CFI_REL_OFFSET        cs,CS-RIP*/
-       CFI_REL_OFFSET  rip,RIP-RIP
-       swapgs
-       /*
-        * No need to follow this irqs on/off section: the syscall
-        * disabled irqs and here we enable it straight after entry:
-        */
-       sti
-       movl %eax,%eax
-       pushq %rax
-       CFI_ADJUST_CFA_OFFSET 8
-       cld
-       /* note the registers are not zero extended to the sf.
-          this could be a problem. */
-       SAVE_ARGS 0,0,1
-       GET_THREAD_INFO(%r10)
-       orl   $TS_COMPAT,threadinfo_status(%r10)
-       testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
-       jnz ia32_tracesys
-ia32_do_syscall:       
-       cmpl $(IA32_NR_syscalls-1),%eax
-       ja  ia32_badsys
-       IA32_ARG_FIXUP
-       call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
-ia32_sysret:
-       movq %rax,RAX-ARGOFFSET(%rsp)
-       jmp int_ret_from_sys_call 
-
-ia32_tracesys:                  
-       SAVE_REST
-       CLEAR_RREGS
-       movq $-ENOSYS,RAX(%rsp) /* really needed? */
-       movq %rsp,%rdi        /* &pt_regs -> arg1 */
-       call syscall_trace_enter
-       LOAD_ARGS32 ARGOFFSET  /* reload args from stack in case ptrace changed it */
-       RESTORE_REST
-       jmp ia32_do_syscall
-END(ia32_syscall)
-
-ia32_badsys:
-       movq $0,ORIG_RAX-ARGOFFSET(%rsp)
-       movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
-       jmp int_ret_from_sys_call
-
-quiet_ni_syscall:
-       movq $-ENOSYS,%rax
-       ret
-       CFI_ENDPROC
-       
-       .macro PTREGSCALL label, func, arg
-       .globl \label
-\label:
-       leaq \func(%rip),%rax
-       leaq -ARGOFFSET+8(%rsp),\arg    /* 8 for return address */
-       jmp  ia32_ptregs_common 
-       .endm
-
-       CFI_STARTPROC32
-
-       PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
-       PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
-       PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
-       PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
-       PTREGSCALL stub32_execve, sys32_execve, %rcx
-       PTREGSCALL stub32_fork, sys_fork, %rdi
-       PTREGSCALL stub32_clone, sys32_clone, %rdx
-       PTREGSCALL stub32_vfork, sys_vfork, %rdi
-       PTREGSCALL stub32_iopl, sys_iopl, %rsi
-       PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
-
-ENTRY(ia32_ptregs_common)
-       popq %r11
-       CFI_ENDPROC
-       CFI_STARTPROC32 simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,SS+8-ARGOFFSET
-       CFI_REL_OFFSET  rax,RAX-ARGOFFSET
-       CFI_REL_OFFSET  rcx,RCX-ARGOFFSET
-       CFI_REL_OFFSET  rdx,RDX-ARGOFFSET
-       CFI_REL_OFFSET  rsi,RSI-ARGOFFSET
-       CFI_REL_OFFSET  rdi,RDI-ARGOFFSET
-       CFI_REL_OFFSET  rip,RIP-ARGOFFSET
-/*     CFI_REL_OFFSET  cs,CS-ARGOFFSET*/
-/*     CFI_REL_OFFSET  rflags,EFLAGS-ARGOFFSET*/
-       CFI_REL_OFFSET  rsp,RSP-ARGOFFSET
-/*     CFI_REL_OFFSET  ss,SS-ARGOFFSET*/
-       SAVE_REST
-       call *%rax
-       RESTORE_REST
-       jmp  ia32_sysret        /* misbalances the return cache */
-       CFI_ENDPROC
-END(ia32_ptregs_common)
-
-       .section .rodata,"a"
-       .align 8
-ia32_sys_call_table:
-       .quad sys_restart_syscall
-       .quad sys_exit
-       .quad stub32_fork
-       .quad sys_read
-       .quad sys_write
-       .quad compat_sys_open           /* 5 */
-       .quad sys_close
-       .quad sys32_waitpid
-       .quad sys_creat
-       .quad sys_link
-       .quad sys_unlink                /* 10 */
-       .quad stub32_execve
-       .quad sys_chdir
-       .quad compat_sys_time
-       .quad sys_mknod
-       .quad sys_chmod         /* 15 */
-       .quad sys_lchown16
-       .quad quiet_ni_syscall                  /* old break syscall holder */
-       .quad sys_stat
-       .quad sys32_lseek
-       .quad sys_getpid                /* 20 */
-       .quad compat_sys_mount  /* mount  */
-       .quad sys_oldumount     /* old_umount  */
-       .quad sys_setuid16
-       .quad sys_getuid16
-       .quad compat_sys_stime  /* stime */             /* 25 */
-       .quad sys32_ptrace      /* ptrace */
-       .quad sys_alarm
-       .quad sys_fstat /* (old)fstat */
-       .quad sys_pause
-       .quad compat_sys_utime  /* 30 */
-       .quad quiet_ni_syscall  /* old stty syscall holder */
-       .quad quiet_ni_syscall  /* old gtty syscall holder */
-       .quad sys_access
-       .quad sys_nice  
-       .quad quiet_ni_syscall  /* 35 */        /* old ftime syscall holder */
-       .quad sys_sync
-       .quad sys32_kill
-       .quad sys_rename
-       .quad sys_mkdir
-       .quad sys_rmdir         /* 40 */
-       .quad sys_dup
-       .quad sys32_pipe
-       .quad compat_sys_times
-       .quad quiet_ni_syscall                  /* old prof syscall holder */
-       .quad sys_brk           /* 45 */
-       .quad sys_setgid16
-       .quad sys_getgid16
-       .quad sys_signal
-       .quad sys_geteuid16
-       .quad sys_getegid16     /* 50 */
-       .quad sys_acct
-       .quad sys_umount                        /* new_umount */
-       .quad quiet_ni_syscall                  /* old lock syscall holder */
-       .quad compat_sys_ioctl
-       .quad compat_sys_fcntl64                /* 55 */
-       .quad quiet_ni_syscall                  /* old mpx syscall holder */
-       .quad sys_setpgid
-       .quad quiet_ni_syscall                  /* old ulimit syscall holder */
-       .quad sys32_olduname
-       .quad sys_umask         /* 60 */
-       .quad sys_chroot
-       .quad sys32_ustat
-       .quad sys_dup2
-       .quad sys_getppid
-       .quad sys_getpgrp               /* 65 */
-       .quad sys_setsid
-       .quad sys32_sigaction
-       .quad sys_sgetmask
-       .quad sys_ssetmask
-       .quad sys_setreuid16    /* 70 */
-       .quad sys_setregid16
-       .quad stub32_sigsuspend
-       .quad compat_sys_sigpending
-       .quad sys_sethostname
-       .quad compat_sys_setrlimit      /* 75 */
-       .quad compat_sys_old_getrlimit  /* old_getrlimit */
-       .quad compat_sys_getrusage
-       .quad sys32_gettimeofday
-       .quad sys32_settimeofday
-       .quad sys_getgroups16   /* 80 */
-       .quad sys_setgroups16
-       .quad sys32_old_select
-       .quad sys_symlink
-       .quad sys_lstat
-       .quad sys_readlink              /* 85 */
-       .quad sys_uselib
-       .quad sys_swapon
-       .quad sys_reboot
-       .quad compat_sys_old_readdir
-       .quad sys32_mmap                /* 90 */
-       .quad sys_munmap
-       .quad sys_truncate
-       .quad sys_ftruncate
-       .quad sys_fchmod
-       .quad sys_fchown16              /* 95 */
-       .quad sys_getpriority
-       .quad sys_setpriority
-       .quad quiet_ni_syscall                  /* old profil syscall holder */
-       .quad compat_sys_statfs
-       .quad compat_sys_fstatfs                /* 100 */
-       .quad sys_ioperm
-       .quad compat_sys_socketcall
-       .quad sys_syslog
-       .quad compat_sys_setitimer
-       .quad compat_sys_getitimer      /* 105 */
-       .quad compat_sys_newstat
-       .quad compat_sys_newlstat
-       .quad compat_sys_newfstat
-       .quad sys32_uname
-       .quad stub32_iopl               /* 110 */
-       .quad sys_vhangup
-       .quad quiet_ni_syscall  /* old "idle" system call */
-       .quad sys32_vm86_warning        /* vm86old */ 
-       .quad compat_sys_wait4
-       .quad sys_swapoff               /* 115 */
-       .quad compat_sys_sysinfo
-       .quad sys32_ipc
-       .quad sys_fsync
-       .quad stub32_sigreturn
-       .quad stub32_clone              /* 120 */
-       .quad sys_setdomainname
-       .quad sys_uname
-       .quad sys_modify_ldt
-       .quad compat_sys_adjtimex
-       .quad sys32_mprotect            /* 125 */
-       .quad compat_sys_sigprocmask
-       .quad quiet_ni_syscall          /* create_module */
-       .quad sys_init_module
-       .quad sys_delete_module
-       .quad quiet_ni_syscall          /* 130  get_kernel_syms */
-       .quad sys32_quotactl
-       .quad sys_getpgid
-       .quad sys_fchdir
-       .quad quiet_ni_syscall  /* bdflush */
-       .quad sys_sysfs         /* 135 */
-       .quad sys_personality
-       .quad quiet_ni_syscall  /* for afs_syscall */
-       .quad sys_setfsuid16
-       .quad sys_setfsgid16
-       .quad sys_llseek                /* 140 */
-       .quad compat_sys_getdents
-       .quad compat_sys_select
-       .quad sys_flock
-       .quad sys_msync
-       .quad compat_sys_readv          /* 145 */
-       .quad compat_sys_writev
-       .quad sys_getsid
-       .quad sys_fdatasync
-       .quad sys32_sysctl      /* sysctl */
-       .quad sys_mlock         /* 150 */
-       .quad sys_munlock
-       .quad sys_mlockall
-       .quad sys_munlockall
-       .quad sys_sched_setparam
-       .quad sys_sched_getparam   /* 155 */
-       .quad sys_sched_setscheduler
-       .quad sys_sched_getscheduler
-       .quad sys_sched_yield
-       .quad sys_sched_get_priority_max
-       .quad sys_sched_get_priority_min  /* 160 */
-       .quad sys32_sched_rr_get_interval
-       .quad compat_sys_nanosleep
-       .quad sys_mremap
-       .quad sys_setresuid16
-       .quad sys_getresuid16   /* 165 */
-       .quad sys32_vm86_warning        /* vm86 */ 
-       .quad quiet_ni_syscall  /* query_module */
-       .quad sys_poll
-       .quad compat_sys_nfsservctl
-       .quad sys_setresgid16   /* 170 */
-       .quad sys_getresgid16
-       .quad sys_prctl
-       .quad stub32_rt_sigreturn
-       .quad sys32_rt_sigaction
-       .quad sys32_rt_sigprocmask      /* 175 */
-       .quad sys32_rt_sigpending
-       .quad compat_sys_rt_sigtimedwait
-       .quad sys32_rt_sigqueueinfo
-       .quad stub32_rt_sigsuspend
-       .quad sys32_pread               /* 180 */
-       .quad sys32_pwrite
-       .quad sys_chown16
-       .quad sys_getcwd
-       .quad sys_capget
-       .quad sys_capset
-       .quad stub32_sigaltstack
-       .quad sys32_sendfile
-       .quad quiet_ni_syscall          /* streams1 */
-       .quad quiet_ni_syscall          /* streams2 */
-       .quad stub32_vfork            /* 190 */
-       .quad compat_sys_getrlimit
-       .quad sys32_mmap2
-       .quad sys32_truncate64
-       .quad sys32_ftruncate64
-       .quad sys32_stat64              /* 195 */
-       .quad sys32_lstat64
-       .quad sys32_fstat64
-       .quad sys_lchown
-       .quad sys_getuid
-       .quad sys_getgid                /* 200 */
-       .quad sys_geteuid
-       .quad sys_getegid
-       .quad sys_setreuid
-       .quad sys_setregid
-       .quad sys_getgroups     /* 205 */
-       .quad sys_setgroups
-       .quad sys_fchown
-       .quad sys_setresuid
-       .quad sys_getresuid
-       .quad sys_setresgid     /* 210 */
-       .quad sys_getresgid
-       .quad sys_chown
-       .quad sys_setuid
-       .quad sys_setgid
-       .quad sys_setfsuid              /* 215 */
-       .quad sys_setfsgid
-       .quad sys_pivot_root
-       .quad sys_mincore
-       .quad sys_madvise
-       .quad compat_sys_getdents64     /* 220 getdents64 */
-       .quad compat_sys_fcntl64        
-       .quad quiet_ni_syscall          /* tux */
-       .quad quiet_ni_syscall          /* security */
-       .quad sys_gettid        
-       .quad sys32_readahead   /* 225 */
-       .quad sys_setxattr
-       .quad sys_lsetxattr
-       .quad sys_fsetxattr
-       .quad sys_getxattr
-       .quad sys_lgetxattr     /* 230 */
-       .quad sys_fgetxattr
-       .quad sys_listxattr
-       .quad sys_llistxattr
-       .quad sys_flistxattr
-       .quad sys_removexattr   /* 235 */
-       .quad sys_lremovexattr
-       .quad sys_fremovexattr
-       .quad sys_tkill
-       .quad sys_sendfile64 
-       .quad compat_sys_futex          /* 240 */
-       .quad compat_sys_sched_setaffinity
-       .quad compat_sys_sched_getaffinity
-       .quad sys32_set_thread_area
-       .quad sys32_get_thread_area
-       .quad compat_sys_io_setup       /* 245 */
-       .quad sys_io_destroy
-       .quad compat_sys_io_getevents
-       .quad compat_sys_io_submit
-       .quad sys_io_cancel
-       .quad sys32_fadvise64           /* 250 */
-       .quad quiet_ni_syscall  /* free_huge_pages */
-       .quad sys_exit_group
-       .quad sys32_lookup_dcookie
-       .quad sys_epoll_create
-       .quad sys_epoll_ctl             /* 255 */
-       .quad sys_epoll_wait
-       .quad sys_remap_file_pages
-       .quad sys_set_tid_address
-       .quad compat_sys_timer_create
-       .quad compat_sys_timer_settime  /* 260 */
-       .quad compat_sys_timer_gettime
-       .quad sys_timer_getoverrun
-       .quad sys_timer_delete
-       .quad compat_sys_clock_settime
-       .quad compat_sys_clock_gettime  /* 265 */
-       .quad compat_sys_clock_getres
-       .quad compat_sys_clock_nanosleep
-       .quad compat_sys_statfs64
-       .quad compat_sys_fstatfs64
-       .quad sys_tgkill                /* 270 */
-       .quad compat_sys_utimes
-       .quad sys32_fadvise64_64
-       .quad quiet_ni_syscall  /* sys_vserver */
-       .quad sys_mbind
-       .quad compat_sys_get_mempolicy  /* 275 */
-       .quad sys_set_mempolicy
-       .quad compat_sys_mq_open
-       .quad sys_mq_unlink
-       .quad compat_sys_mq_timedsend
-       .quad compat_sys_mq_timedreceive        /* 280 */
-       .quad compat_sys_mq_notify
-       .quad compat_sys_mq_getsetattr
-       .quad compat_sys_kexec_load     /* reserved for kexec */
-       .quad compat_sys_waitid
-       .quad quiet_ni_syscall          /* 285: sys_altroot */
-       .quad sys_add_key
-       .quad sys_request_key
-       .quad sys_keyctl
-       .quad sys_ioprio_set
-       .quad sys_ioprio_get            /* 290 */
-       .quad sys_inotify_init
-       .quad sys_inotify_add_watch
-       .quad sys_inotify_rm_watch
-       .quad sys_migrate_pages
-       .quad compat_sys_openat         /* 295 */
-       .quad sys_mkdirat
-       .quad sys_mknodat
-       .quad sys_fchownat
-       .quad compat_sys_futimesat
-       .quad sys32_fstatat             /* 300 */
-       .quad sys_unlinkat
-       .quad sys_renameat
-       .quad sys_linkat
-       .quad sys_symlinkat
-       .quad sys_readlinkat            /* 305 */
-       .quad sys_fchmodat
-       .quad sys_faccessat
-       .quad compat_sys_pselect6
-       .quad compat_sys_ppoll
-       .quad sys_unshare               /* 310 */
-       .quad compat_sys_set_robust_list
-       .quad compat_sys_get_robust_list
-       .quad sys_splice
-       .quad sys32_sync_file_range
-       .quad sys_tee                   /* 315 */
-       .quad compat_sys_vmsplice
-       .quad compat_sys_move_pages
-       .quad sys_getcpu
-       .quad sys_epoll_pwait
-       .quad compat_sys_utimensat      /* 320 */
-       .quad compat_sys_signalfd
-       .quad compat_sys_timerfd
-       .quad sys_eventfd
-       .quad sys32_fallocate
-ia32_syscall_end:
diff --git a/arch/x86_64/ia32/ipc32.c b/arch/x86_64/ia32/ipc32.c
deleted file mode 100644 (file)
index 369151d..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/list.h>
-#include <linux/syscalls.h>
-#include <linux/time.h>
-#include <linux/sem.h>
-#include <linux/msg.h>
-#include <linux/shm.h>
-#include <linux/ipc.h>
-#include <linux/compat.h>
-
-#include <asm-i386/ipc.h>
-
-asmlinkage long
-sys32_ipc(u32 call, int first, int second, int third,
-               compat_uptr_t ptr, u32 fifth)
-{
-       int version;
-
-       version = call >> 16; /* hack for backward compatibility */
-       call &= 0xffff;
-
-       switch (call) {
-             case SEMOP:
-               /* struct sembuf is the same on 32 and 64bit :)) */
-               return sys_semtimedop(first, compat_ptr(ptr), second, NULL);
-             case SEMTIMEDOP:
-               return compat_sys_semtimedop(first, compat_ptr(ptr), second,
-                                               compat_ptr(fifth));
-             case SEMGET:
-               return sys_semget(first, second, third);
-             case SEMCTL:
-               return compat_sys_semctl(first, second, third, compat_ptr(ptr));
-
-             case MSGSND:
-               return compat_sys_msgsnd(first, second, third, compat_ptr(ptr));
-             case MSGRCV:
-               return compat_sys_msgrcv(first, second, fifth, third,
-                                        version, compat_ptr(ptr));
-             case MSGGET:
-               return sys_msgget((key_t) first, second);
-             case MSGCTL:
-               return compat_sys_msgctl(first, second, compat_ptr(ptr));
-
-             case SHMAT:
-               return compat_sys_shmat(first, second, third, version,
-                                       compat_ptr(ptr));
-               break;
-             case SHMDT:
-               return sys_shmdt(compat_ptr(ptr));
-             case SHMGET:
-               return sys_shmget(first, (unsigned)second, third);
-             case SHMCTL:
-               return compat_sys_shmctl(first, second, compat_ptr(ptr));
-       }
-       return -ENOSYS;
-}
diff --git a/arch/x86_64/ia32/mmap32.c b/arch/x86_64/ia32/mmap32.c
deleted file mode 100644 (file)
index e4b84b4..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *  linux/arch/x86_64/ia32/mm/mmap.c
- *
- *  flexible mmap layout support
- *
- * Based on the i386 version which was
- *
- * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *
- * Started by Ingo Molnar <mingo@elte.hu>
- */
-
-#include <linux/personality.h>
-#include <linux/mm.h>
-#include <linux/random.h>
-#include <linux/sched.h>
-
-/*
- * Top of mmap area (just below the process stack).
- *
- * Leave an at least ~128 MB hole.
- */
-#define MIN_GAP (128*1024*1024)
-#define MAX_GAP (TASK_SIZE/6*5)
-
-static inline unsigned long mmap_base(struct mm_struct *mm)
-{
-       unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
-       unsigned long random_factor = 0;
-
-       if (current->flags & PF_RANDOMIZE)
-               random_factor = get_random_int() % (1024*1024);
-
-       if (gap < MIN_GAP)
-               gap = MIN_GAP;
-       else if (gap > MAX_GAP)
-               gap = MAX_GAP;
-
-       return PAGE_ALIGN(TASK_SIZE - gap - random_factor);
-}
-
-/*
- * This function, called very early during the creation of a new
- * process VM image, sets up which VM layout function to use:
- */
-void ia32_pick_mmap_layout(struct mm_struct *mm)
-{
-       /*
-        * Fall back to the standard layout if the personality
-        * bit is set, or if the expected stack growth is unlimited:
-        */
-       if (sysctl_legacy_va_layout ||
-                       (current->personality & ADDR_COMPAT_LAYOUT) ||
-                       current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY) {
-               mm->mmap_base = TASK_UNMAPPED_BASE;
-               mm->get_unmapped_area = arch_get_unmapped_area;
-               mm->unmap_area = arch_unmap_area;
-       } else {
-               mm->mmap_base = mmap_base(mm);
-               mm->get_unmapped_area = arch_get_unmapped_area_topdown;
-               mm->unmap_area = arch_unmap_area_topdown;
-       }
-}
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
deleted file mode 100644 (file)
index 4a233ad..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/* 
- * 32bit ptrace for x86-64.
- *
- * Copyright 2001,2002 Andi Kleen, SuSE Labs.
- * Some parts copied from arch/i386/kernel/ptrace.c. See that file for earlier 
- * copyright.
- * 
- * This allows to access 64bit processes too; but there is no way to see the extended 
- * register contents.
- */ 
-
-#include <linux/kernel.h>
-#include <linux/stddef.h>
-#include <linux/sched.h>
-#include <linux/syscalls.h>
-#include <linux/unistd.h>
-#include <linux/mm.h>
-#include <linux/err.h>
-#include <linux/ptrace.h>
-#include <asm/ptrace.h>
-#include <asm/compat.h>
-#include <asm/uaccess.h>
-#include <asm/user32.h>
-#include <asm/user.h>
-#include <asm/errno.h>
-#include <asm/debugreg.h>
-#include <asm/i387.h>
-#include <asm/fpu32.h>
-#include <asm/ia32.h>
-
-/*
- * Determines which flags the user has access to [1 = access, 0 = no access].
- * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
- * Also masks reserved bits (31-22, 15, 5, 3, 1).
- */
-#define FLAG_MASK 0x54dd5UL
-
-#define R32(l,q) \
-       case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
-
-static int putreg32(struct task_struct *child, unsigned regno, u32 val)
-{
-       int i;
-       __u64 *stack = (__u64 *)task_pt_regs(child);
-
-       switch (regno) {
-       case offsetof(struct user32, regs.fs):
-               if (val && (val & 3) != 3) return -EIO; 
-               child->thread.fsindex = val & 0xffff;
-               break;
-       case offsetof(struct user32, regs.gs):
-               if (val && (val & 3) != 3) return -EIO; 
-               child->thread.gsindex = val & 0xffff;
-               break;
-       case offsetof(struct user32, regs.ds):
-               if (val && (val & 3) != 3) return -EIO; 
-               child->thread.ds = val & 0xffff;
-               break;
-       case offsetof(struct user32, regs.es):
-               child->thread.es = val & 0xffff;
-               break;
-       case offsetof(struct user32, regs.ss): 
-               if ((val & 3) != 3) return -EIO;
-               stack[offsetof(struct pt_regs, ss)/8] = val & 0xffff;
-               break;
-       case offsetof(struct user32, regs.cs): 
-               if ((val & 3) != 3) return -EIO;
-               stack[offsetof(struct pt_regs, cs)/8] = val & 0xffff;
-               break;
-
-       R32(ebx, rbx); 
-       R32(ecx, rcx);
-       R32(edx, rdx);
-       R32(edi, rdi);
-       R32(esi, rsi);
-       R32(ebp, rbp);
-       R32(eax, rax);
-       R32(orig_eax, orig_rax);
-       R32(eip, rip);
-       R32(esp, rsp);
-
-       case offsetof(struct user32, regs.eflags): {
-               __u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8];
-               val &= FLAG_MASK;
-               *flags = val | (*flags & ~FLAG_MASK);
-               break;
-       }
-
-       case offsetof(struct user32, u_debugreg[4]): 
-       case offsetof(struct user32, u_debugreg[5]):
-               return -EIO;
-
-       case offsetof(struct user32, u_debugreg[0]):
-               child->thread.debugreg0 = val;
-               break;
-
-       case offsetof(struct user32, u_debugreg[1]):
-               child->thread.debugreg1 = val;
-               break;
-
-       case offsetof(struct user32, u_debugreg[2]):
-               child->thread.debugreg2 = val;
-               break;
-
-       case offsetof(struct user32, u_debugreg[3]):
-               child->thread.debugreg3 = val;
-               break;
-
-       case offsetof(struct user32, u_debugreg[6]):
-               child->thread.debugreg6 = val;
-               break; 
-
-       case offsetof(struct user32, u_debugreg[7]):
-               val &= ~DR_CONTROL_RESERVED;
-               /* See arch/i386/kernel/ptrace.c for an explanation of
-                * this awkward check.*/
-               for(i=0; i<4; i++)
-                       if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
-                              return -EIO;
-               child->thread.debugreg7 = val; 
-               if (val)
-                       set_tsk_thread_flag(child, TIF_DEBUG);
-               else
-                       clear_tsk_thread_flag(child, TIF_DEBUG);
-               break; 
-                   
-       default:
-               if (regno > sizeof(struct user32) || (regno & 3))
-                       return -EIO;
-              
-               /* Other dummy fields in the virtual user structure are ignored */ 
-               break;          
-       }
-       return 0;
-}
-
-#undef R32
-
-#define R32(l,q) \
-       case offsetof(struct user32, regs.l): *val = stack[offsetof(struct pt_regs, q)/8]; break
-
-static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
-{
-       __u64 *stack = (__u64 *)task_pt_regs(child);
-
-       switch (regno) {
-       case offsetof(struct user32, regs.fs):
-               *val = child->thread.fsindex;
-               break;
-       case offsetof(struct user32, regs.gs):
-               *val = child->thread.gsindex;
-               break;
-       case offsetof(struct user32, regs.ds):
-               *val = child->thread.ds;
-               break;
-       case offsetof(struct user32, regs.es):
-               *val = child->thread.es;
-               break;
-
-       R32(cs, cs);
-       R32(ss, ss);
-       R32(ebx, rbx); 
-       R32(ecx, rcx);
-       R32(edx, rdx);
-       R32(edi, rdi);
-       R32(esi, rsi);
-       R32(ebp, rbp);
-       R32(eax, rax);
-       R32(orig_eax, orig_rax);
-       R32(eip, rip);
-       R32(eflags, eflags);
-       R32(esp, rsp);
-
-       case offsetof(struct user32, u_debugreg[0]): 
-               *val = child->thread.debugreg0; 
-               break; 
-       case offsetof(struct user32, u_debugreg[1]): 
-               *val = child->thread.debugreg1; 
-               break; 
-       case offsetof(struct user32, u_debugreg[2]): 
-               *val = child->thread.debugreg2; 
-               break; 
-       case offsetof(struct user32, u_debugreg[3]): 
-               *val = child->thread.debugreg3; 
-               break; 
-       case offsetof(struct user32, u_debugreg[6]): 
-               *val = child->thread.debugreg6; 
-               break; 
-       case offsetof(struct user32, u_debugreg[7]): 
-               *val = child->thread.debugreg7; 
-               break; 
-                   
-       default:
-               if (regno > sizeof(struct user32) || (regno & 3))
-                       return -EIO;
-
-               /* Other dummy fields in the virtual user structure are ignored */ 
-               *val = 0;
-               break;          
-       }
-       return 0;
-}
-
-#undef R32
-
-static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
-{
-       int ret;
-       compat_siginfo_t __user *si32 = compat_ptr(data);
-       siginfo_t ssi; 
-       siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
-       if (request == PTRACE_SETSIGINFO) {
-               memset(&ssi, 0, sizeof(siginfo_t));
-               ret = copy_siginfo_from_user32(&ssi, si32);
-               if (ret)
-                       return ret;
-               if (copy_to_user(si, &ssi, sizeof(siginfo_t)))
-                       return -EFAULT;
-       }
-       ret = sys_ptrace(request, pid, addr, (unsigned long)si);
-       if (ret)
-               return ret;
-       if (request == PTRACE_GETSIGINFO) {
-               if (copy_from_user(&ssi, si, sizeof(siginfo_t)))
-                       return -EFAULT;
-               ret = copy_siginfo_to_user32(si32, &ssi);
-       }
-       return ret;
-}
-
-asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
-{
-       struct task_struct *child;
-       struct pt_regs *childregs; 
-       void __user *datap = compat_ptr(data);
-       int ret;
-       __u32 val;
-
-       switch (request) { 
-       case PTRACE_TRACEME:
-       case PTRACE_ATTACH:
-       case PTRACE_KILL:
-       case PTRACE_CONT:
-       case PTRACE_SINGLESTEP:
-       case PTRACE_DETACH:
-       case PTRACE_SYSCALL:
-       case PTRACE_OLDSETOPTIONS:
-       case PTRACE_SETOPTIONS:
-       case PTRACE_SET_THREAD_AREA:
-       case PTRACE_GET_THREAD_AREA:
-               return sys_ptrace(request, pid, addr, data); 
-
-       default:
-               return -EINVAL;
-
-       case PTRACE_PEEKTEXT:
-       case PTRACE_PEEKDATA:
-       case PTRACE_POKEDATA:
-       case PTRACE_POKETEXT:
-       case PTRACE_POKEUSR:       
-       case PTRACE_PEEKUSR:
-       case PTRACE_GETREGS:
-       case PTRACE_SETREGS:
-       case PTRACE_SETFPREGS:
-       case PTRACE_GETFPREGS:
-       case PTRACE_SETFPXREGS:
-       case PTRACE_GETFPXREGS:
-       case PTRACE_GETEVENTMSG:
-               break;
-
-       case PTRACE_SETSIGINFO:
-       case PTRACE_GETSIGINFO:
-               return ptrace32_siginfo(request, pid, addr, data);
-       }
-
-       child = ptrace_get_task_struct(pid);
-       if (IS_ERR(child))
-               return PTR_ERR(child);
-
-       ret = ptrace_check_attach(child, request == PTRACE_KILL);
-       if (ret < 0)
-               goto out;
-
-       childregs = task_pt_regs(child);
-
-       switch (request) {
-       case PTRACE_PEEKDATA:
-       case PTRACE_PEEKTEXT:
-               ret = 0;
-               if (access_process_vm(child, addr, &val, sizeof(u32), 0)!=sizeof(u32))
-                       ret = -EIO;
-               else
-                       ret = put_user(val, (unsigned int __user *)datap); 
-               break; 
-
-       case PTRACE_POKEDATA:
-       case PTRACE_POKETEXT:
-               ret = 0;
-               if (access_process_vm(child, addr, &data, sizeof(u32), 1)!=sizeof(u32))
-                       ret = -EIO; 
-               break;
-
-       case PTRACE_PEEKUSR:
-               ret = getreg32(child, addr, &val);
-               if (ret == 0)
-                       ret = put_user(val, (__u32 __user *)datap);
-               break;
-
-       case PTRACE_POKEUSR:
-               ret = putreg32(child, addr, data);
-               break;
-
-       case PTRACE_GETREGS: { /* Get all gp regs from the child. */
-               int i;
-               if (!access_ok(VERIFY_WRITE, datap, 16*4)) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               for ( i = 0; i <= 16*4 ; i += sizeof(__u32) ) {
-                       getreg32(child, i, &val);
-                       ret |= __put_user(val,(u32 __user *)datap);
-                       datap += sizeof(u32);
-               }
-               break;
-       }
-
-       case PTRACE_SETREGS: { /* Set all gp regs in the child. */
-               unsigned long tmp;
-               int i;
-               if (!access_ok(VERIFY_READ, datap, 16*4)) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0; 
-               for ( i = 0; i <= 16*4; i += sizeof(u32) ) {
-                       ret |= __get_user(tmp, (u32 __user *)datap);
-                       putreg32(child, i, tmp);
-                       datap += sizeof(u32);
-               }
-               break;
-       }
-
-       case PTRACE_GETFPREGS:
-               ret = -EIO; 
-               if (!access_ok(VERIFY_READ, compat_ptr(data), 
-                              sizeof(struct user_i387_struct)))
-                       break;
-               save_i387_ia32(child, datap, childregs, 1);
-               ret = 0; 
-                       break;
-
-       case PTRACE_SETFPREGS:
-               ret = -EIO;
-               if (!access_ok(VERIFY_WRITE, datap, 
-                              sizeof(struct user_i387_struct)))
-                       break;
-               ret = 0;
-               /* don't check EFAULT to be bug-to-bug compatible to i386 */
-               restore_i387_ia32(child, datap, 1);
-               break;
-
-       case PTRACE_GETFPXREGS: { 
-               struct user32_fxsr_struct __user *u = datap;
-               init_fpu(child); 
-               ret = -EIO;
-               if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
-                       break;
-                       ret = -EFAULT;
-               if (__copy_to_user(u, &child->thread.i387.fxsave, sizeof(*u)))
-                       break;
-               ret = __put_user(childregs->cs, &u->fcs);
-               ret |= __put_user(child->thread.ds, &u->fos); 
-               break; 
-       } 
-       case PTRACE_SETFPXREGS: { 
-               struct user32_fxsr_struct __user *u = datap;
-               unlazy_fpu(child);
-               ret = -EIO;
-               if (!access_ok(VERIFY_READ, u, sizeof(*u)))
-                       break;
-               /* no checking to be bug-to-bug compatible with i386. */
-               /* but silence warning */
-               if (__copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)))
-                       ;
-               set_stopped_child_used_math(child);
-               child->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask;
-               ret = 0; 
-               break;
-       }
-
-       case PTRACE_GETEVENTMSG:
-               ret = put_user(child->ptrace_message,(unsigned int __user *)compat_ptr(data));
-               break;
-
-       default:
-               BUG();
-       }
-
- out:
-       put_task_struct(child);
-       return ret;
-}
-
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
deleted file mode 100644 (file)
index bee96d6..0000000
+++ /dev/null
@@ -1,889 +0,0 @@
-/*
- * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on
- *             sys_sparc32 
- *
- * Copyright (C) 2000          VA Linux Co
- * Copyright (C) 2000          Don Dugger <n0ano@valinux.com>
- * Copyright (C) 1999          Arun Sharma <arun.sharma@intel.com>
- * Copyright (C) 1997,1998     Jakub Jelinek (jj@sunsite.mff.cuni.cz)
- * Copyright (C) 1997          David S. Miller (davem@caip.rutgers.edu)
- * Copyright (C) 2000          Hewlett-Packard Co.
- * Copyright (C) 2000          David Mosberger-Tang <davidm@hpl.hp.com>
- * Copyright (C) 2000,2001,2002        Andi Kleen, SuSE Labs (x86-64 port) 
- *
- * These routines maintain argument size conversion between 32bit and 64bit
- * environment. In 2.5 most of this should be moved to a generic directory. 
- *
- * This file assumes that there is a hole at the end of user address space.
- * 
- * Some of the functions are LE specific currently. These are hopefully all marked.
- * This should be fixed.
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h> 
-#include <linux/file.h> 
-#include <linux/signal.h>
-#include <linux/syscalls.h>
-#include <linux/resource.h>
-#include <linux/times.h>
-#include <linux/utsname.h>
-#include <linux/smp.h>
-#include <linux/smp_lock.h>
-#include <linux/sem.h>
-#include <linux/msg.h>
-#include <linux/mm.h>
-#include <linux/shm.h>
-#include <linux/slab.h>
-#include <linux/uio.h>
-#include <linux/nfs_fs.h>
-#include <linux/quota.h>
-#include <linux/module.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr.h>
-#include <linux/nfsd/syscall.h>
-#include <linux/poll.h>
-#include <linux/personality.h>
-#include <linux/stat.h>
-#include <linux/ipc.h>
-#include <linux/rwsem.h>
-#include <linux/binfmts.h>
-#include <linux/init.h>
-#include <linux/aio_abi.h>
-#include <linux/aio.h>
-#include <linux/compat.h>
-#include <linux/vfs.h>
-#include <linux/ptrace.h>
-#include <linux/highuid.h>
-#include <linux/vmalloc.h>
-#include <linux/fsnotify.h>
-#include <linux/sysctl.h>
-#include <asm/mman.h>
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/semaphore.h>
-#include <asm/atomic.h>
-#include <asm/ldt.h>
-
-#include <net/scm.h>
-#include <net/sock.h>
-#include <asm/ia32.h>
-
-#define AA(__x)                ((unsigned long)(__x))
-
-int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf)
-{
-       compat_ino_t ino;
-
-       typeof(ubuf->st_uid) uid = 0;
-       typeof(ubuf->st_gid) gid = 0;
-       SET_UID(uid, kbuf->uid);
-       SET_GID(gid, kbuf->gid);
-       if (!old_valid_dev(kbuf->dev) || !old_valid_dev(kbuf->rdev))
-               return -EOVERFLOW;
-       if (kbuf->size >= 0x7fffffff)
-               return -EOVERFLOW;
-       ino = kbuf->ino;
-       if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino)
-               return -EOVERFLOW;
-       if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) ||
-           __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) ||
-           __put_user (ino, &ubuf->st_ino) ||
-           __put_user (kbuf->mode, &ubuf->st_mode) ||
-           __put_user (kbuf->nlink, &ubuf->st_nlink) ||
-           __put_user (uid, &ubuf->st_uid) ||
-           __put_user (gid, &ubuf->st_gid) ||
-           __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
-           __put_user (kbuf->size, &ubuf->st_size) ||
-           __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) ||
-           __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) ||
-           __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime) ||
-           __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
-           __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime) ||
-           __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
-           __put_user (kbuf->blksize, &ubuf->st_blksize) ||
-           __put_user (kbuf->blocks, &ubuf->st_blocks))
-               return -EFAULT;
-       return 0;
-}
-
-asmlinkage long
-sys32_truncate64(char __user * filename, unsigned long offset_low, unsigned long offset_high)
-{
-       return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
-}
-
-asmlinkage long
-sys32_ftruncate64(unsigned int fd, unsigned long offset_low, unsigned long offset_high)
-{
-       return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
-}
-
-/* Another set for IA32/LFS -- x86_64 struct stat is different due to 
-   support for 64bit inode numbers. */
-
-static int
-cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
-{
-       typeof(ubuf->st_uid) uid = 0;
-       typeof(ubuf->st_gid) gid = 0;
-       SET_UID(uid, stat->uid);
-       SET_GID(gid, stat->gid);
-       if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
-           __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) ||
-           __put_user (stat->ino, &ubuf->__st_ino) ||
-           __put_user (stat->ino, &ubuf->st_ino) ||
-           __put_user (stat->mode, &ubuf->st_mode) ||
-           __put_user (stat->nlink, &ubuf->st_nlink) ||
-           __put_user (uid, &ubuf->st_uid) ||
-           __put_user (gid, &ubuf->st_gid) ||
-           __put_user (huge_encode_dev(stat->rdev), &ubuf->st_rdev) ||
-           __put_user (stat->size, &ubuf->st_size) ||
-           __put_user (stat->atime.tv_sec, &ubuf->st_atime) ||
-           __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) ||
-           __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) ||
-           __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) ||
-           __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) ||
-           __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) ||
-           __put_user (stat->blksize, &ubuf->st_blksize) ||
-           __put_user (stat->blocks, &ubuf->st_blocks))
-               return -EFAULT;
-       return 0;
-}
-
-asmlinkage long
-sys32_stat64(char __user * filename, struct stat64 __user *statbuf)
-{
-       struct kstat stat;
-       int ret = vfs_stat(filename, &stat);
-       if (!ret)
-               ret = cp_stat64(statbuf, &stat);
-       return ret;
-}
-
-asmlinkage long
-sys32_lstat64(char __user * filename, struct stat64 __user *statbuf)
-{
-       struct kstat stat;
-       int ret = vfs_lstat(filename, &stat);
-       if (!ret)
-               ret = cp_stat64(statbuf, &stat);
-       return ret;
-}
-
-asmlinkage long
-sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
-{
-       struct kstat stat;
-       int ret = vfs_fstat(fd, &stat);
-       if (!ret)
-               ret = cp_stat64(statbuf, &stat);
-       return ret;
-}
-
-asmlinkage long
-sys32_fstatat(unsigned int dfd, char __user *filename,
-             struct stat64 __user* statbuf, int flag)
-{
-       struct kstat stat;
-       int error = -EINVAL;
-
-       if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
-               goto out;
-
-       if (flag & AT_SYMLINK_NOFOLLOW)
-               error = vfs_lstat_fd(dfd, filename, &stat);
-       else
-               error = vfs_stat_fd(dfd, filename, &stat);
-
-       if (!error)
-               error = cp_stat64(statbuf, &stat);
-
-out:
-       return error;
-}
-
-/*
- * Linux/i386 didn't use to be able to handle more than
- * 4 system call parameters, so these system calls used a memory
- * block for parameter passing..
- */
-
-struct mmap_arg_struct {
-       unsigned int addr;
-       unsigned int len;
-       unsigned int prot;
-       unsigned int flags;
-       unsigned int fd;
-       unsigned int offset;
-};
-
-asmlinkage long
-sys32_mmap(struct mmap_arg_struct __user *arg)
-{
-       struct mmap_arg_struct a;
-       struct file *file = NULL;
-       unsigned long retval;
-       struct mm_struct *mm ;
-
-       if (copy_from_user(&a, arg, sizeof(a)))
-               return -EFAULT;
-
-       if (a.offset & ~PAGE_MASK)
-               return -EINVAL; 
-
-       if (!(a.flags & MAP_ANONYMOUS)) {
-               file = fget(a.fd);
-               if (!file)
-                       return -EBADF;
-       }
-       
-       mm = current->mm; 
-       down_write(&mm->mmap_sem); 
-       retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT);
-       if (file)
-               fput(file);
-
-       up_write(&mm->mmap_sem); 
-
-       return retval;
-}
-
-asmlinkage long 
-sys32_mprotect(unsigned long start, size_t len, unsigned long prot)
-{
-       return sys_mprotect(start,len,prot); 
-}
-
-asmlinkage long
-sys32_pipe(int __user *fd)
-{
-       int retval;
-       int fds[2];
-
-       retval = do_pipe(fds);
-       if (retval)
-               goto out;
-       if (copy_to_user(fd, fds, sizeof(fds)))
-               retval = -EFAULT;
-  out:
-       return retval;
-}
-
-asmlinkage long
-sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
-                  struct sigaction32 __user *oact,  unsigned int sigsetsize)
-{
-       struct k_sigaction new_ka, old_ka;
-       int ret;
-       compat_sigset_t set32;
-
-       /* XXX: Don't preclude handling different sized sigset_t's.  */
-       if (sigsetsize != sizeof(compat_sigset_t))
-               return -EINVAL;
-
-       if (act) {
-               compat_uptr_t handler, restorer;
-
-               if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
-                   __get_user(handler, &act->sa_handler) ||
-                   __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
-                   __get_user(restorer, &act->sa_restorer)||
-                   __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t)))
-                       return -EFAULT;
-               new_ka.sa.sa_handler = compat_ptr(handler);
-               new_ka.sa.sa_restorer = compat_ptr(restorer);
-               /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
-               switch (_NSIG_WORDS) {
-               case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
-                               | (((long)set32.sig[7]) << 32);
-               case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4]
-                               | (((long)set32.sig[5]) << 32);
-               case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2]
-                               | (((long)set32.sig[3]) << 32);
-               case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0]
-                               | (((long)set32.sig[1]) << 32);
-               }
-       }
-
-       ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
-
-       if (!ret && oact) {
-               /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
-               switch (_NSIG_WORDS) {
-               case 4:
-                       set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);
-                       set32.sig[6] = old_ka.sa.sa_mask.sig[3];
-               case 3:
-                       set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);
-                       set32.sig[4] = old_ka.sa.sa_mask.sig[2];
-               case 2:
-                       set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);
-                       set32.sig[2] = old_ka.sa.sa_mask.sig[1];
-               case 1:
-                       set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);
-                       set32.sig[0] = old_ka.sa.sa_mask.sig[0];
-               }
-               if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
-                   __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
-                   __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
-                   __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
-                   __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t)))
-                       return -EFAULT;
-       }
-
-       return ret;
-}
-
-asmlinkage long
-sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
-{
-        struct k_sigaction new_ka, old_ka;
-        int ret;
-
-        if (act) {
-               compat_old_sigset_t mask;
-               compat_uptr_t handler, restorer;
-
-               if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
-                   __get_user(handler, &act->sa_handler) ||
-                   __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
-                   __get_user(restorer, &act->sa_restorer) ||
-                   __get_user(mask, &act->sa_mask))
-                       return -EFAULT;
-
-               new_ka.sa.sa_handler = compat_ptr(handler);
-               new_ka.sa.sa_restorer = compat_ptr(restorer);
-
-               siginitset(&new_ka.sa.sa_mask, mask);
-        }
-
-        ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
-
-       if (!ret && oact) {
-               if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
-                   __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) ||
-                   __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) ||
-                   __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
-                   __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
-                       return -EFAULT;
-        }
-
-       return ret;
-}
-
-asmlinkage long
-sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
-                       compat_sigset_t __user *oset, unsigned int sigsetsize)
-{
-       sigset_t s;
-       compat_sigset_t s32;
-       int ret;
-       mm_segment_t old_fs = get_fs();
-       
-       if (set) {
-               if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
-                       return -EFAULT;
-               switch (_NSIG_WORDS) {
-               case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
-               case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
-               case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
-               case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
-               }
-       }
-       set_fs (KERNEL_DS);
-       ret = sys_rt_sigprocmask(how,
-                                set ? (sigset_t __user *)&s : NULL,
-                                oset ? (sigset_t __user *)&s : NULL,
-                                sigsetsize); 
-       set_fs (old_fs);
-       if (ret) return ret;
-       if (oset) {
-               switch (_NSIG_WORDS) {
-               case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
-               case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
-               case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
-               case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
-               }
-               if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
-                       return -EFAULT;
-       }
-       return 0;
-}
-
-static inline long
-get_tv32(struct timeval *o, struct compat_timeval __user *i)
-{
-       int err = -EFAULT; 
-       if (access_ok(VERIFY_READ, i, sizeof(*i))) { 
-               err = __get_user(o->tv_sec, &i->tv_sec);
-               err |= __get_user(o->tv_usec, &i->tv_usec);
-       }
-       return err; 
-}
-
-static inline long
-put_tv32(struct compat_timeval __user *o, struct timeval *i)
-{
-       int err = -EFAULT;
-       if (access_ok(VERIFY_WRITE, o, sizeof(*o))) { 
-               err = __put_user(i->tv_sec, &o->tv_sec);
-               err |= __put_user(i->tv_usec, &o->tv_usec);
-       } 
-       return err; 
-}
-
-extern unsigned int alarm_setitimer(unsigned int seconds);
-
-asmlinkage long
-sys32_alarm(unsigned int seconds)
-{
-       return alarm_setitimer(seconds);
-}
-
-/* Translations due to time_t size differences.  Which affects all
-   sorts of things, like timeval and itimerval.  */
-
-extern struct timezone sys_tz;
-
-asmlinkage long
-sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
-{
-       if (tv) {
-               struct timeval ktv;
-               do_gettimeofday(&ktv);
-               if (put_tv32(tv, &ktv))
-                       return -EFAULT;
-       }
-       if (tz) {
-               if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
-                       return -EFAULT;
-       }
-       return 0;
-}
-
-asmlinkage long
-sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
-{
-       struct timeval ktv;
-       struct timespec kts;
-       struct timezone ktz;
-
-       if (tv) {
-               if (get_tv32(&ktv, tv))
-                       return -EFAULT;
-               kts.tv_sec = ktv.tv_sec;
-               kts.tv_nsec = ktv.tv_usec * NSEC_PER_USEC;
-       }
-       if (tz) {
-               if (copy_from_user(&ktz, tz, sizeof(ktz)))
-                       return -EFAULT;
-       }
-
-       return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
-}
-
-struct sel_arg_struct {
-       unsigned int n;
-       unsigned int inp;
-       unsigned int outp;
-       unsigned int exp;
-       unsigned int tvp;
-};
-
-asmlinkage long
-sys32_old_select(struct sel_arg_struct __user *arg)
-{
-       struct sel_arg_struct a;
-
-       if (copy_from_user(&a, arg, sizeof(a)))
-               return -EFAULT;
-       return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
-                                compat_ptr(a.exp), compat_ptr(a.tvp));
-}
-
-extern asmlinkage long
-compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options,
-                struct compat_rusage *ru);
-
-asmlinkage long
-sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options)
-{
-       return compat_sys_wait4(pid, stat_addr, options, NULL);
-}
-
-/* 32-bit timeval and related flotsam.  */
-
-asmlinkage long
-sys32_sysfs(int option, u32 arg1, u32 arg2)
-{
-       return sys_sysfs(option, arg1, arg2);
-}
-
-asmlinkage long
-sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
-{
-       struct timespec t;
-       int ret;
-       mm_segment_t old_fs = get_fs ();
-       
-       set_fs (KERNEL_DS);
-       ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
-       set_fs (old_fs);
-       if (put_compat_timespec(&t, interval))
-               return -EFAULT;
-       return ret;
-}
-
-asmlinkage long
-sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
-{
-       sigset_t s;
-       compat_sigset_t s32;
-       int ret;
-       mm_segment_t old_fs = get_fs();
-               
-       set_fs (KERNEL_DS);
-       ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
-       set_fs (old_fs);
-       if (!ret) {
-               switch (_NSIG_WORDS) {
-               case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
-               case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
-               case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
-               case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
-               }
-               if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
-                       return -EFAULT;
-       }
-       return ret;
-}
-
-asmlinkage long
-sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
-{
-       siginfo_t info;
-       int ret;
-       mm_segment_t old_fs = get_fs();
-       
-       if (copy_siginfo_from_user32(&info, uinfo))
-               return -EFAULT;
-       set_fs (KERNEL_DS);
-       ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
-       set_fs (old_fs);
-       return ret;
-}
-
-/* These are here just in case some old ia32 binary calls it. */
-asmlinkage long
-sys32_pause(void)
-{
-       current->state = TASK_INTERRUPTIBLE;
-       schedule();
-       return -ERESTARTNOHAND;
-}
-
-
-#ifdef CONFIG_SYSCTL_SYSCALL
-struct sysctl_ia32 {
-       unsigned int    name;
-       int             nlen;
-       unsigned int    oldval;
-       unsigned int    oldlenp;
-       unsigned int    newval;
-       unsigned int    newlen;
-       unsigned int    __unused[4];
-};
-
-
-asmlinkage long
-sys32_sysctl(struct sysctl_ia32 __user *args32)
-{
-       struct sysctl_ia32 a32;
-       mm_segment_t old_fs = get_fs ();
-       void __user *oldvalp, *newvalp;
-       size_t oldlen;
-       int __user *namep;
-       long ret;
-
-       if (copy_from_user(&a32, args32, sizeof (a32)))
-               return -EFAULT;
-
-       /*
-        * We need to pre-validate these because we have to disable address checking
-        * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
-        * user specifying bad addresses here.  Well, since we're dealing with 32 bit
-        * addresses, we KNOW that access_ok() will always succeed, so this is an
-        * expensive NOP, but so what...
-        */
-       namep = compat_ptr(a32.name);
-       oldvalp = compat_ptr(a32.oldval);
-       newvalp =  compat_ptr(a32.newval);
-
-       if ((oldvalp && get_user(oldlen, (int __user *)compat_ptr(a32.oldlenp)))
-           || !access_ok(VERIFY_WRITE, namep, 0)
-           || !access_ok(VERIFY_WRITE, oldvalp, 0)
-           || !access_ok(VERIFY_WRITE, newvalp, 0))
-               return -EFAULT;
-
-       set_fs(KERNEL_DS);
-       lock_kernel();
-       ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *)&oldlen,
-                       newvalp, (size_t) a32.newlen);
-       unlock_kernel();
-       set_fs(old_fs);
-
-       if (oldvalp && put_user (oldlen, (int __user *)compat_ptr(a32.oldlenp)))
-               return -EFAULT;
-
-       return ret;
-}
-#endif
-
-/* warning: next two assume little endian */ 
-asmlinkage long
-sys32_pread(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
-{
-       return sys_pread64(fd, ubuf, count,
-                        ((loff_t)AA(poshi) << 32) | AA(poslo));
-}
-
-asmlinkage long
-sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi)
-{
-       return sys_pwrite64(fd, ubuf, count,
-                         ((loff_t)AA(poshi) << 32) | AA(poslo));
-}
-
-
-asmlinkage long
-sys32_personality(unsigned long personality)
-{
-       int ret;
-       if (personality(current->personality) == PER_LINUX32 && 
-               personality == PER_LINUX)
-               personality = PER_LINUX32;
-       ret = sys_personality(personality);
-       if (ret == PER_LINUX32)
-               ret = PER_LINUX;
-       return ret;
-}
-
-asmlinkage long
-sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
-{
-       mm_segment_t old_fs = get_fs();
-       int ret;
-       off_t of;
-       
-       if (offset && get_user(of, offset))
-               return -EFAULT;
-               
-       set_fs(KERNEL_DS);
-       ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
-                          count);
-       set_fs(old_fs);
-       
-       if (offset && put_user(of, offset))
-               return -EFAULT;
-               
-       return ret;
-}
-
-asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
-       unsigned long prot, unsigned long flags,
-       unsigned long fd, unsigned long pgoff)
-{
-       struct mm_struct *mm = current->mm;
-       unsigned long error;
-       struct file * file = NULL;
-
-       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
-       if (!(flags & MAP_ANONYMOUS)) {
-               file = fget(fd);
-               if (!file)
-                       return -EBADF;
-       }
-
-       down_write(&mm->mmap_sem);
-       error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
-       up_write(&mm->mmap_sem);
-
-       if (file)
-               fput(file);
-       return error;
-}
-
-asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
-{
-       int err;
-
-       if (!name)
-               return -EFAULT;
-       if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname)))
-               return -EFAULT;
-  
-       down_read(&uts_sem);
-
-       err = __copy_to_user(&name->sysname,&utsname()->sysname,
-                               __OLD_UTS_LEN);
-       err |= __put_user(0,name->sysname+__OLD_UTS_LEN);
-       err |= __copy_to_user(&name->nodename,&utsname()->nodename,
-                               __OLD_UTS_LEN);
-       err |= __put_user(0,name->nodename+__OLD_UTS_LEN);
-       err |= __copy_to_user(&name->release,&utsname()->release,
-                               __OLD_UTS_LEN);
-       err |= __put_user(0,name->release+__OLD_UTS_LEN);
-       err |= __copy_to_user(&name->version,&utsname()->version,
-                               __OLD_UTS_LEN);
-       err |= __put_user(0,name->version+__OLD_UTS_LEN);
-       {
-               char *arch = "x86_64";
-               if (personality(current->personality) == PER_LINUX32)
-                       arch = "i686";
-                
-               err |= __copy_to_user(&name->machine, arch, strlen(arch)+1);
-       }
-
-       up_read(&uts_sem);
-
-       err = err ? -EFAULT : 0;
-
-       return err;
-}
-
-long sys32_uname(struct old_utsname __user * name)
-{
-       int err;
-       if (!name)
-               return -EFAULT;
-       down_read(&uts_sem);
-       err = copy_to_user(name, utsname(), sizeof (*name));
-       up_read(&uts_sem);
-       if (personality(current->personality) == PER_LINUX32) 
-               err |= copy_to_user(&name->machine, "i686", 5);
-       return err?-EFAULT:0;
-}
-
-long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
-{
-       struct ustat u;
-       mm_segment_t seg;
-       int ret;
-       
-       seg = get_fs(); 
-       set_fs(KERNEL_DS); 
-       ret = sys_ustat(dev, (struct ustat __user *)&u);
-       set_fs(seg);
-       if (ret >= 0) { 
-               if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) || 
-                   __put_user((__u32) u.f_tfree, &u32p->f_tfree) ||
-                   __put_user((__u32) u.f_tinode, &u32p->f_tfree) ||
-                   __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) ||
-                   __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack)))
-                       ret = -EFAULT;
-       }
-       return ret;
-} 
-
-asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
-                            compat_uptr_t __user *envp, struct pt_regs *regs)
-{
-       long error;
-       char * filename;
-
-       filename = getname(name);
-       error = PTR_ERR(filename);
-       if (IS_ERR(filename))
-               return error;
-       error = compat_do_execve(filename, argv, envp, regs);
-       if (error == 0) {
-               task_lock(current);
-               current->ptrace &= ~PT_DTRACE;
-               task_unlock(current);
-       }
-       putname(filename);
-       return error;
-}
-
-asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
-                           struct pt_regs *regs)
-{
-       void __user *parent_tid = (void __user *)regs->rdx;
-       void __user *child_tid = (void __user *)regs->rdi;
-       if (!newsp)
-               newsp = regs->rsp;
-        return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
-}
-
-/*
- * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
- */ 
-
-long sys32_lseek (unsigned int fd, int offset, unsigned int whence)
-{
-       return sys_lseek(fd, offset, whence);
-}
-
-long sys32_kill(int pid, int sig)
-{
-       return sys_kill(pid, sig);
-}
-long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, 
-                       __u32 len_low, __u32 len_high, int advice)
-{ 
-       return sys_fadvise64_64(fd,
-                              (((u64)offset_high)<<32) | offset_low,
-                              (((u64)len_high)<<32) | len_low,
-                              advice); 
-} 
-
-long sys32_vm86_warning(void)
-{ 
-       struct task_struct *me = current;
-       static char lastcomm[sizeof(me->comm)];
-       if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) {
-               compat_printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n",
-                      me->comm);
-               strncpy(lastcomm, me->comm, sizeof(lastcomm));
-       } 
-       return -ENOSYS;
-} 
-
-long sys32_lookup_dcookie(u32 addr_low, u32 addr_high,
-                         char __user * buf, size_t len)
-{
-       return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len);
-}
-
-asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi, size_t count)
-{
-       return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
-}
-
-asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
-                          unsigned n_low, unsigned n_hi,  int flags)
-{
-       return sys_sync_file_range(fd,
-                                  ((u64)off_hi << 32) | off_low,
-                                  ((u64)n_hi << 32) | n_low, flags);
-}
-
-asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi, size_t len,
-                    int advice)
-{
-       return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
-                               len, advice);
-}
-
-asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
-                               unsigned offset_hi, unsigned len_lo,
-                               unsigned len_hi)
-{
-       return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
-                            ((u64)len_hi << 32) | len_lo);
-}
diff --git a/arch/x86_64/ia32/syscall32.c b/arch/x86_64/ia32/syscall32.c
deleted file mode 100644 (file)
index 15013ba..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2002,2003 Andi Kleen, SuSE Labs */
-
-/* vsyscall handling for 32bit processes. Map a stub page into it 
-   on demand because 32bit cannot reach the kernel's fixmaps */
-
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/gfp.h>
-#include <linux/init.h>
-#include <linux/stringify.h>
-#include <linux/security.h>
-#include <asm/proto.h>
-#include <asm/tlbflush.h>
-#include <asm/ia32_unistd.h>
-#include <asm/vsyscall32.h>
-
-extern unsigned char syscall32_syscall[], syscall32_syscall_end[];
-extern unsigned char syscall32_sysenter[], syscall32_sysenter_end[];
-extern int sysctl_vsyscall32;
-
-static struct page *syscall32_pages[1];
-static int use_sysenter = -1;
-
-struct linux_binprm;
-
-/* Setup a VMA at program startup for the vsyscall page */
-int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
-{
-       struct mm_struct *mm = current->mm;
-       int ret;
-
-       down_write(&mm->mmap_sem);
-       /*
-        * MAYWRITE to allow gdb to COW and set breakpoints
-        *
-        * Make sure the vDSO gets into every core dump.
-        * Dumping its contents makes post-mortem fully interpretable later
-        * without matching up the same kernel and hardware config to see
-        * what PC values meant.
-        */
-       /* Could randomize here */
-       ret = install_special_mapping(mm, VSYSCALL32_BASE, PAGE_SIZE,
-                                     VM_READ|VM_EXEC|
-                                     VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
-                                     VM_ALWAYSDUMP,
-                                     syscall32_pages);
-       up_write(&mm->mmap_sem);
-       return ret;
-}
-
-static int __init init_syscall32(void)
-{ 
-       char *syscall32_page = (void *)get_zeroed_page(GFP_KERNEL);
-       if (!syscall32_page) 
-               panic("Cannot allocate syscall32 page"); 
-       syscall32_pages[0] = virt_to_page(syscall32_page);
-       if (use_sysenter > 0) {
-               memcpy(syscall32_page, syscall32_sysenter,
-                      syscall32_sysenter_end - syscall32_sysenter);
-       } else {
-               memcpy(syscall32_page, syscall32_syscall,
-                      syscall32_syscall_end - syscall32_syscall);
-       }       
-       return 0;
-} 
-       
-__initcall(init_syscall32); 
-
-/* May not be __init: called during resume */
-void syscall32_cpu_init(void)
-{
-       if (use_sysenter < 0)
-               use_sysenter = (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL);
-
-       /* Load these always in case some future AMD CPU supports
-          SYSENTER from compat mode too. */
-       checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
-       checking_wrmsrl(MSR_IA32_SYSENTER_ESP, 0ULL);
-       checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
-
-       wrmsrl(MSR_CSTAR, ia32_cstar_target);
-}
diff --git a/arch/x86_64/ia32/syscall32_syscall.S b/arch/x86_64/ia32/syscall32_syscall.S
deleted file mode 100644 (file)
index 8f8271b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* 32bit VDSOs mapped into user space. */
-
-       .section ".init.data","aw"
-
-       .globl syscall32_syscall
-       .globl syscall32_syscall_end
-
-syscall32_syscall:
-       .incbin "arch/x86_64/ia32/vsyscall-syscall.so"
-syscall32_syscall_end:
-
-       .globl syscall32_sysenter
-       .globl syscall32_sysenter_end
-
-syscall32_sysenter:
-       .incbin "arch/x86_64/ia32/vsyscall-sysenter.so"
-syscall32_sysenter_end:
diff --git a/arch/x86_64/ia32/tls32.c b/arch/x86_64/ia32/tls32.c
deleted file mode 100644 (file)
index 1cc4340..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/user.h>
-
-#include <asm/uaccess.h>
-#include <asm/desc.h>
-#include <asm/system.h>
-#include <asm/ldt.h>
-#include <asm/processor.h>
-#include <asm/proto.h>
-
-/*
- * sys_alloc_thread_area: get a yet unused TLS descriptor index.
- */
-static int get_free_idx(void)
-{
-       struct thread_struct *t = &current->thread;
-       int idx;
-
-       for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
-               if (desc_empty((struct n_desc_struct *)(t->tls_array) + idx))
-                       return idx + GDT_ENTRY_TLS_MIN;
-       return -ESRCH;
-}
-
-/*
- * Set a given TLS descriptor:
- * When you want addresses > 32bit use arch_prctl() 
- */
-int do_set_thread_area(struct thread_struct *t, struct user_desc __user *u_info)
-{
-       struct user_desc info;
-       struct n_desc_struct *desc;
-       int cpu, idx;
-
-       if (copy_from_user(&info, u_info, sizeof(info)))
-               return -EFAULT;
-
-       idx = info.entry_number;
-
-       /*
-        * index -1 means the kernel should try to find and
-        * allocate an empty descriptor:
-        */
-       if (idx == -1) {
-               idx = get_free_idx();
-               if (idx < 0)
-                       return idx;
-               if (put_user(idx, &u_info->entry_number))
-                       return -EFAULT;
-       }
-
-       if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
-               return -EINVAL;
-
-       desc = ((struct n_desc_struct *)t->tls_array) + idx - GDT_ENTRY_TLS_MIN;
-
-       /*
-        * We must not get preempted while modifying the TLS.
-        */
-       cpu = get_cpu();
-
-       if (LDT_empty(&info)) {
-               desc->a = 0;
-               desc->b = 0;
-       } else {
-               desc->a = LDT_entry_a(&info);
-               desc->b = LDT_entry_b(&info);
-       }
-       if (t == &current->thread)
-               load_TLS(t, cpu);
-
-       put_cpu();
-       return 0;
-}
-
-asmlinkage long sys32_set_thread_area(struct user_desc __user *u_info)
-{ 
-       return do_set_thread_area(&current->thread, u_info); 
-} 
-
-
-/*
- * Get the current Thread-Local Storage area:
- */
-
-#define GET_BASE(desc) ( \
-       (((desc)->a >> 16) & 0x0000ffff) | \
-       (((desc)->b << 16) & 0x00ff0000) | \
-       ( (desc)->b        & 0xff000000)   )
-
-#define GET_LIMIT(desc) ( \
-       ((desc)->a & 0x0ffff) | \
-        ((desc)->b & 0xf0000) )
-       
-#define GET_32BIT(desc)                (((desc)->b >> 22) & 1)
-#define GET_CONTENTS(desc)     (((desc)->b >> 10) & 3)
-#define GET_WRITABLE(desc)     (((desc)->b >>  9) & 1)
-#define GET_LIMIT_PAGES(desc)  (((desc)->b >> 23) & 1)
-#define GET_PRESENT(desc)      (((desc)->b >> 15) & 1)
-#define GET_USEABLE(desc)      (((desc)->b >> 20) & 1)
-#define GET_LONGMODE(desc)     (((desc)->b >> 21) & 1)
-
-int do_get_thread_area(struct thread_struct *t, struct user_desc __user *u_info)
-{
-       struct user_desc info;
-       struct n_desc_struct *desc;
-       int idx;
-
-       if (get_user(idx, &u_info->entry_number))
-               return -EFAULT;
-       if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
-               return -EINVAL;
-
-       desc = ((struct n_desc_struct *)t->tls_array) + idx - GDT_ENTRY_TLS_MIN;
-
-       memset(&info, 0, sizeof(struct user_desc));
-       info.entry_number = idx;
-       info.base_addr = GET_BASE(desc);
-       info.limit = GET_LIMIT(desc);
-       info.seg_32bit = GET_32BIT(desc);
-       info.contents = GET_CONTENTS(desc);
-       info.read_exec_only = !GET_WRITABLE(desc);
-       info.limit_in_pages = GET_LIMIT_PAGES(desc);
-       info.seg_not_present = !GET_PRESENT(desc);
-       info.useable = GET_USEABLE(desc);
-       info.lm = GET_LONGMODE(desc);
-
-       if (copy_to_user(u_info, &info, sizeof(info)))
-               return -EFAULT;
-       return 0;
-}
-
-asmlinkage long sys32_get_thread_area(struct user_desc __user *u_info)
-{
-       return do_get_thread_area(&current->thread, u_info);
-} 
-
-
-int ia32_child_tls(struct task_struct *p, struct pt_regs *childregs)
-{
-       struct n_desc_struct *desc;
-       struct user_desc info;
-       struct user_desc __user *cp;
-       int idx;
-       
-       cp = (void __user *)childregs->rsi;
-       if (copy_from_user(&info, cp, sizeof(info)))
-               return -EFAULT;
-       if (LDT_empty(&info))
-               return -EINVAL;
-       
-       idx = info.entry_number;
-       if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
-               return -EINVAL;
-       
-       desc = (struct n_desc_struct *)(p->thread.tls_array) + idx - GDT_ENTRY_TLS_MIN;
-       desc->a = LDT_entry_a(&info);
-       desc->b = LDT_entry_b(&info);
-
-       return 0;
-}
diff --git a/arch/x86_64/ia32/vsyscall-sigreturn.S b/arch/x86_64/ia32/vsyscall-sigreturn.S
deleted file mode 100644 (file)
index 1384367..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Common code for the sigreturn entry points on the vsyscall page.
- * This code uses SYSCALL_ENTER_KERNEL (either syscall or int $0x80)
- * to enter the kernel.
- * This file is #include'd by vsyscall-*.S to define them after the
- * vsyscall entry point.  The addresses we get for these entry points
- * by doing ".balign 32" must match in both versions of the page.
- */
-
-       .code32
-       .section .text.sigreturn,"ax"
-       .balign 32
-       .globl __kernel_sigreturn
-       .type __kernel_sigreturn,@function
-__kernel_sigreturn:
-.LSTART_sigreturn:
-       popl %eax
-       movl $__NR_ia32_sigreturn, %eax
-       SYSCALL_ENTER_KERNEL
-.LEND_sigreturn:
-       .size __kernel_sigreturn,.-.LSTART_sigreturn
-
-       .section .text.rtsigreturn,"ax"
-       .balign 32
-       .globl __kernel_rt_sigreturn
-       .type __kernel_rt_sigreturn,@function
-__kernel_rt_sigreturn:
-.LSTART_rt_sigreturn:
-       movl $__NR_ia32_rt_sigreturn, %eax
-       SYSCALL_ENTER_KERNEL
-.LEND_rt_sigreturn:
-       .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
-
-       .section .eh_frame,"a",@progbits
-.LSTARTFRAMES:
-        .long .LENDCIES-.LSTARTCIES
-.LSTARTCIES:
-       .long 0                 /* CIE ID */
-       .byte 1                 /* Version number */
-       .string "zRS"           /* NUL-terminated augmentation string */
-       .uleb128 1              /* Code alignment factor */
-       .sleb128 -4             /* Data alignment factor */
-       .byte 8                 /* Return address register column */
-       .uleb128 1              /* Augmentation value length */
-       .byte 0x1b              /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
-       .byte 0x0c              /* DW_CFA_def_cfa */
-       .uleb128 4
-       .uleb128 4
-       .byte 0x88              /* DW_CFA_offset, column 0x8 */
-       .uleb128 1
-       .align 4
-.LENDCIES:
-
-       .long .LENDFDE2-.LSTARTFDE2     /* Length FDE */
-.LSTARTFDE2:
-       .long .LSTARTFDE2-.LSTARTFRAMES /* CIE pointer */
-       /* HACK: The dwarf2 unwind routines will subtract 1 from the
-          return address to get an address in the middle of the
-          presumed call instruction.  Since we didn't get here via
-          a call, we need to include the nop before the real start
-          to make up for it.  */
-       .long .LSTART_sigreturn-1-.     /* PC-relative start address */
-       .long .LEND_sigreturn-.LSTART_sigreturn+1
-       .uleb128 0                      /* Augmentation length */
-       /* What follows are the instructions for the table generation.
-          We record the locations of each register saved.  This is
-          complicated by the fact that the "CFA" is always assumed to
-          be the value of the stack pointer in the caller.  This means
-          that we must define the CFA of this body of code to be the
-          saved value of the stack pointer in the sigcontext.  Which
-          also means that there is no fixed relation to the other 
-          saved registers, which means that we must use DW_CFA_expression
-          to compute their addresses.  It also means that when we 
-          adjust the stack with the popl, we have to do it all over again.  */
-
-#define do_cfa_expr(offset)                                            \
-       .byte 0x0f;                     /* DW_CFA_def_cfa_expression */ \
-       .uleb128 1f-0f;                 /*   length */                  \
-0:     .byte 0x74;                     /*     DW_OP_breg4 */           \
-       .sleb128 offset;                /*      offset */               \
-       .byte 0x06;                     /*     DW_OP_deref */           \
-1:
-
-#define do_expr(regno, offset)                                         \
-       .byte 0x10;                     /* DW_CFA_expression */         \
-       .uleb128 regno;                 /*   regno */                   \
-       .uleb128 1f-0f;                 /*   length */                  \
-0:     .byte 0x74;                     /*     DW_OP_breg4 */           \
-       .sleb128 offset;                /*       offset */              \
-1:
-
-       do_cfa_expr(IA32_SIGCONTEXT_esp+4)
-       do_expr(0, IA32_SIGCONTEXT_eax+4)
-       do_expr(1, IA32_SIGCONTEXT_ecx+4)
-       do_expr(2, IA32_SIGCONTEXT_edx+4)
-       do_expr(3, IA32_SIGCONTEXT_ebx+4)
-       do_expr(5, IA32_SIGCONTEXT_ebp+4)
-       do_expr(6, IA32_SIGCONTEXT_esi+4)
-       do_expr(7, IA32_SIGCONTEXT_edi+4)
-       do_expr(8, IA32_SIGCONTEXT_eip+4)
-
-       .byte 0x42      /* DW_CFA_advance_loc 2 -- nop; popl eax. */
-
-       do_cfa_expr(IA32_SIGCONTEXT_esp)
-       do_expr(0, IA32_SIGCONTEXT_eax)
-       do_expr(1, IA32_SIGCONTEXT_ecx)
-       do_expr(2, IA32_SIGCONTEXT_edx)
-       do_expr(3, IA32_SIGCONTEXT_ebx)
-       do_expr(5, IA32_SIGCONTEXT_ebp)
-       do_expr(6, IA32_SIGCONTEXT_esi)
-       do_expr(7, IA32_SIGCONTEXT_edi)
-       do_expr(8, IA32_SIGCONTEXT_eip)
-
-       .align 4
-.LENDFDE2:
-
-       .long .LENDFDE3-.LSTARTFDE3     /* Length FDE */
-.LSTARTFDE3:
-       .long .LSTARTFDE3-.LSTARTFRAMES /* CIE pointer */
-       /* HACK: See above wrt unwind library assumptions.  */
-       .long .LSTART_rt_sigreturn-1-.  /* PC-relative start address */
-       .long .LEND_rt_sigreturn-.LSTART_rt_sigreturn+1
-       .uleb128 0                      /* Augmentation */
-       /* What follows are the instructions for the table generation.
-          We record the locations of each register saved.  This is
-          slightly less complicated than the above, since we don't
-          modify the stack pointer in the process.  */
-
-       do_cfa_expr(IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esp)
-       do_expr(0, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eax)
-       do_expr(1, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ecx)
-       do_expr(2, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edx)
-       do_expr(3, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebx)
-       do_expr(5, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_ebp)
-       do_expr(6, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_esi)
-       do_expr(7, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_edi)
-       do_expr(8, IA32_RT_SIGFRAME_sigcontext-4 + IA32_SIGCONTEXT_eip)
-
-       .align 4
-.LENDFDE3:
-
-#include "../../i386/kernel/vsyscall-note.S"
-
diff --git a/arch/x86_64/ia32/vsyscall-syscall.S b/arch/x86_64/ia32/vsyscall-syscall.S
deleted file mode 100644 (file)
index cf9ef67..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Code for the vsyscall page.  This version uses the syscall instruction.
- */
-
-#include <asm/ia32_unistd.h>
-#include <asm/asm-offsets.h>
-#include <asm/segment.h>
-
-       .code32
-       .text
-       .section .text.vsyscall,"ax"
-       .globl __kernel_vsyscall
-       .type __kernel_vsyscall,@function
-__kernel_vsyscall:
-.LSTART_vsyscall:
-       push    %ebp
-.Lpush_ebp:
-       movl    %ecx, %ebp
-       syscall
-       movl    $__USER32_DS, %ecx
-       movl    %ecx, %ss
-       movl    %ebp, %ecx
-       popl    %ebp
-.Lpop_ebp:
-       ret
-.LEND_vsyscall:
-       .size __kernel_vsyscall,.-.LSTART_vsyscall
-
-       .section .eh_frame,"a",@progbits
-.LSTARTFRAME:
-       .long .LENDCIE-.LSTARTCIE
-.LSTARTCIE:
-       .long 0                 /* CIE ID */
-       .byte 1                 /* Version number */
-       .string "zR"            /* NUL-terminated augmentation string */
-       .uleb128 1              /* Code alignment factor */
-       .sleb128 -4             /* Data alignment factor */
-       .byte 8                 /* Return address register column */
-       .uleb128 1              /* Augmentation value length */
-       .byte 0x1b              /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
-       .byte 0x0c              /* DW_CFA_def_cfa */
-       .uleb128 4
-       .uleb128 4
-       .byte 0x88              /* DW_CFA_offset, column 0x8 */
-       .uleb128 1
-       .align 4
-.LENDCIE:
-
-       .long .LENDFDE1-.LSTARTFDE1     /* Length FDE */
-.LSTARTFDE1:
-       .long .LSTARTFDE1-.LSTARTFRAME  /* CIE pointer */
-       .long .LSTART_vsyscall-.        /* PC-relative start address */
-       .long .LEND_vsyscall-.LSTART_vsyscall
-       .uleb128 0                      /* Augmentation length */
-       /* What follows are the instructions for the table generation.
-          We have to record all changes of the stack pointer.  */
-       .byte 0x40 + .Lpush_ebp-.LSTART_vsyscall /* DW_CFA_advance_loc */
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .uleb128 8
-       .byte 0x85, 0x02        /* DW_CFA_offset %ebp -8 */
-       .byte 0x40 + .Lpop_ebp-.Lpush_ebp /* DW_CFA_advance_loc */
-       .byte 0xc5              /* DW_CFA_restore %ebp */
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .uleb128 4
-       .align 4
-.LENDFDE1:
-
-#define SYSCALL_ENTER_KERNEL   syscall
-#include "vsyscall-sigreturn.S"
diff --git a/arch/x86_64/ia32/vsyscall-sysenter.S b/arch/x86_64/ia32/vsyscall-sysenter.S
deleted file mode 100644 (file)
index ae056e5..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Code for the vsyscall page.  This version uses the sysenter instruction.
- */
-
-#include <asm/ia32_unistd.h>
-#include <asm/asm-offsets.h>
-
-       .code32
-       .text
-       .section .text.vsyscall,"ax"
-       .globl __kernel_vsyscall
-       .type __kernel_vsyscall,@function
-__kernel_vsyscall:
-.LSTART_vsyscall:
-       push    %ecx
-.Lpush_ecx:
-       push    %edx
-.Lpush_edx:
-       push    %ebp
-.Lenter_kernel:
-       movl    %esp,%ebp
-       sysenter
-       .space 7,0x90
-       jmp     .Lenter_kernel
-       /* 16: System call normal return point is here! */
-       pop     %ebp
-.Lpop_ebp:
-       pop     %edx
-.Lpop_edx:
-       pop     %ecx
-.Lpop_ecx:
-       ret
-.LEND_vsyscall:
-       .size __kernel_vsyscall,.-.LSTART_vsyscall
-
-       .section .eh_frame,"a",@progbits
-.LSTARTFRAME:
-       .long .LENDCIE-.LSTARTCIE
-.LSTARTCIE:
-       .long 0                 /* CIE ID */
-       .byte 1                 /* Version number */
-       .string "zR"            /* NUL-terminated augmentation string */
-       .uleb128 1              /* Code alignment factor */
-       .sleb128 -4             /* Data alignment factor */
-       .byte 8                 /* Return address register column */
-       .uleb128 1              /* Augmentation value length */
-       .byte 0x1b              /* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
-       .byte 0x0c              /* DW_CFA_def_cfa */
-       .uleb128 4
-       .uleb128 4
-       .byte 0x88              /* DW_CFA_offset, column 0x8 */
-       .uleb128 1
-       .align 4
-.LENDCIE:
-
-       .long .LENDFDE1-.LSTARTFDE1     /* Length FDE */
-.LSTARTFDE1:
-       .long .LSTARTFDE1-.LSTARTFRAME  /* CIE pointer */
-       .long .LSTART_vsyscall-.        /* PC-relative start address */
-       .long .LEND_vsyscall-.LSTART_vsyscall
-       .uleb128 0                      /* Augmentation length */
-       /* What follows are the instructions for the table generation.
-          We have to record all changes of the stack pointer.  */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lpush_ecx-.LSTART_vsyscall
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x08              /* RA at offset 8 now */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lpush_edx-.Lpush_ecx
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x0c              /* RA at offset 12 now */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lenter_kernel-.Lpush_edx
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x10              /* RA at offset 16 now */
-       .byte 0x85, 0x04        /* DW_CFA_offset %ebp -16 */
-       /* Finally the epilogue.  */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lpop_ebp-.Lenter_kernel
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x12              /* RA at offset 12 now */
-       .byte 0xc5              /* DW_CFA_restore %ebp */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lpop_edx-.Lpop_ebp
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x08              /* RA at offset 8 now */
-       .byte 0x04              /* DW_CFA_advance_loc4 */
-       .long .Lpop_ecx-.Lpop_edx
-       .byte 0x0e              /* DW_CFA_def_cfa_offset */
-       .byte 0x04              /* RA at offset 4 now */
-       .align 4
-.LENDFDE1:
-
-#define SYSCALL_ENTER_KERNEL   int $0x80
-#include "vsyscall-sigreturn.S"
diff --git a/arch/x86_64/ia32/vsyscall.lds b/arch/x86_64/ia32/vsyscall.lds
deleted file mode 100644 (file)
index 1dc86ff..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Linker script for vsyscall DSO.  The vsyscall page is an ELF shared
- * object prelinked to its virtual address. This script controls its layout.
- */
-
-/* This must match <asm/fixmap.h>.  */
-VSYSCALL_BASE = 0xffffe000;
-
-SECTIONS
-{
-  . = VSYSCALL_BASE + SIZEOF_HEADERS;
-
-  .hash           : { *(.hash) }               :text
-  .gnu.hash       : { *(.gnu.hash) }
-  .dynsym         : { *(.dynsym) }
-  .dynstr         : { *(.dynstr) }
-  .gnu.version    : { *(.gnu.version) }
-  .gnu.version_d  : { *(.gnu.version_d) }
-  .gnu.version_r  : { *(.gnu.version_r) }
-
-  /* This linker script is used both with -r and with -shared.
-     For the layouts to match, we need to skip more than enough
-     space for the dynamic symbol table et al.  If this amount
-     is insufficient, ld -shared will barf.  Just increase it here.  */
-  . = VSYSCALL_BASE + 0x400;
-  
-  .text.vsyscall   : { *(.text.vsyscall) }     :text =0x90909090
-
-  /* This is an 32bit object and we cannot easily get the offsets
-     into the 64bit kernel. Just hardcode them here. This assumes
-     that all the stubs don't need more than 0x100 bytes. */
-  . = VSYSCALL_BASE + 0x500;
-
-  .text.sigreturn  : { *(.text.sigreturn) }    :text =0x90909090
-
-  . = VSYSCALL_BASE + 0x600;
-
-  .text.rtsigreturn : { *(.text.rtsigreturn) }   :text =0x90909090
-       
-  .note                  : { *(.note.*) }              :text :note
-  .eh_frame_hdr   : { *(.eh_frame_hdr) }       :text :eh_frame_hdr
-  .eh_frame       : { KEEP (*(.eh_frame)) }    :text
-  .dynamic        : { *(.dynamic) }            :text :dynamic
-  .useless        : {
-       *(.got.plt) *(.got)
-       *(.data .data.* .gnu.linkonce.d.*)
-       *(.dynbss)
-       *(.bss .bss.* .gnu.linkonce.b.*)
-  }                                            :text
-}
-
-/*
- * We must supply the ELF program headers explicitly to get just one
- * PT_LOAD segment, and set the flags explicitly to make segments read-only.
- */
-PHDRS
-{
-  text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
-  dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
-  note PT_NOTE FLAGS(4); /* PF_R */
-  eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
-}
-
-/*
- * This controls what symbols we export from the DSO.
- */
-VERSION
-{
-  LINUX_2.5 {
-    global:
-       __kernel_vsyscall;
-       __kernel_sigreturn;
-       __kernel_rt_sigreturn;
-
-    local: *;
-  };
-}
-
-/* The ELF entry point can be used to set the AT_SYSINFO value.  */
-ENTRY(__kernel_vsyscall);
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
deleted file mode 100644 (file)
index ff5d8c9..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Makefile for the linux kernel.
-#
-
-extra-y        := head.o head64.o init_task.o vmlinux.lds
-EXTRA_AFLAGS   := -traditional
-obj-y  := process.o signal.o entry.o traps.o irq.o \
-               ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_x86_64.o \
-               x8664_ksyms.o i387.o syscall.o vsyscall.o \
-               setup64.o bootflag.o e820.o reboot.o quirks.o i8237.o \
-               pci-dma.o pci-nommu.o alternative.o hpet.o tsc.o bugs.o \
-               perfctr-watchdog.o
-
-obj-$(CONFIG_STACKTRACE)       += stacktrace.o
-obj-$(CONFIG_X86_MCE)          += mce.o therm_throt.o
-obj-$(CONFIG_X86_MCE_INTEL)    += mce_intel.o
-obj-$(CONFIG_X86_MCE_AMD)      += mce_amd.o
-obj-$(CONFIG_MTRR)             += ../../i386/kernel/cpu/mtrr/
-obj-$(CONFIG_ACPI)             += acpi/
-obj-$(CONFIG_X86_MSR)          += msr.o
-obj-$(CONFIG_MICROCODE)                += microcode.o
-obj-$(CONFIG_X86_CPUID)                += cpuid.o
-obj-$(CONFIG_SMP)              += smp.o smpboot.o trampoline.o tsc_sync.o
-obj-y                          += apic.o  nmi.o
-obj-y                          += io_apic.o mpparse.o genapic.o genapic_flat.o
-obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o crash.o
-obj-$(CONFIG_CRASH_DUMP)       += crash_dump.o
-obj-$(CONFIG_PM)               += suspend.o
-obj-$(CONFIG_HIBERNATION)      += suspend_asm.o
-obj-$(CONFIG_CPU_FREQ)         += cpufreq/
-obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
-obj-$(CONFIG_IOMMU)            += pci-gart.o aperture.o
-obj-$(CONFIG_CALGARY_IOMMU)    += pci-calgary.o tce.o
-obj-$(CONFIG_SWIOTLB)          += pci-swiotlb.o
-obj-$(CONFIG_KPROBES)          += kprobes.o
-obj-$(CONFIG_X86_PM_TIMER)     += pmtimer.o
-obj-$(CONFIG_X86_VSMP)         += vsmp.o
-obj-$(CONFIG_K8_NB)            += k8.o
-obj-$(CONFIG_AUDIT)            += audit.o
-
-obj-$(CONFIG_MODULES)          += module.o
-obj-$(CONFIG_PCI)              += early-quirks.o
-
-obj-y                          += topology.o
-obj-y                          += intel_cacheinfo.o
-obj-y                          += addon_cpuid_features.o
-obj-y                          += pcspeaker.o
-
-CFLAGS_vsyscall.o              := $(PROFILING) -g0
-
-therm_throt-y                   += ../../i386/kernel/cpu/mcheck/therm_throt.o
-bootflag-y                     += ../../i386/kernel/bootflag.o
-cpuid-$(subst m,y,$(CONFIG_X86_CPUID))  += ../../i386/kernel/cpuid.o
-topology-y                     += ../../i386/kernel/topology.o
-microcode-$(subst m,y,$(CONFIG_MICROCODE))  += ../../i386/kernel/microcode.o
-intel_cacheinfo-y              += ../../i386/kernel/cpu/intel_cacheinfo.o
-addon_cpuid_features-y         += ../../i386/kernel/cpu/addon_cpuid_features.o
-quirks-y                       += ../../i386/kernel/quirks.o
-i8237-y                                += ../../i386/kernel/i8237.o
-msr-$(subst m,y,$(CONFIG_X86_MSR))  += ../../i386/kernel/msr.o
-alternative-y                  += ../../i386/kernel/alternative.o
-pcspeaker-y                    += ../../i386/kernel/pcspeaker.o
-perfctr-watchdog-y             += ../../i386/kernel/cpu/perfctr-watchdog.o
diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile
deleted file mode 100644 (file)
index 080b996..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-obj-y                  := boot.o
-boot-y                 := ../../../i386/kernel/acpi/boot.o
-obj-$(CONFIG_ACPI_SLEEP)       += sleep.o wakeup.o
-
-ifneq ($(CONFIG_ACPI_PROCESSOR),)
-obj-y                  += processor.o
-processor-y            := ../../../i386/kernel/acpi/processor.o ../../../i386/kernel/acpi/cstate.o
-endif
-
diff --git a/arch/x86_64/kernel/acpi/sleep.c b/arch/x86_64/kernel/acpi/sleep.c
deleted file mode 100644 (file)
index 79475d2..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *  acpi.c - Architecture-Specific Low-Level ACPI Support
- *
- *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
- *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
- *  Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
- *  Copyright (C) 2002 Andi Kleen, SuSE Labs (x86-64 port)
- *  Copyright (C) 2003 Pavel Machek, SuSE Labs
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/pci.h>
-#include <linux/bootmem.h>
-#include <linux/acpi.h>
-#include <linux/cpumask.h>
-
-#include <asm/mpspec.h>
-#include <asm/io.h>
-#include <asm/apic.h>
-#include <asm/apicdef.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/pgalloc.h>
-#include <asm/io_apic.h>
-#include <asm/proto.h>
-#include <asm/tlbflush.h>
-
-/* --------------------------------------------------------------------------
-                              Low-Level Sleep Support
-   -------------------------------------------------------------------------- */
-
-/* address in low memory of the wakeup routine. */
-unsigned long acpi_wakeup_address = 0;
-unsigned long acpi_realmode_flags;
-extern char wakeup_start, wakeup_end;
-
-extern unsigned long acpi_copy_wakeup_routine(unsigned long);
-
-/**
- * acpi_save_state_mem - save kernel state
- *
- * Create an identity mapped page table and copy the wakeup routine to
- * low memory.
- */
-int acpi_save_state_mem(void)
-{
-       memcpy((void *)acpi_wakeup_address, &wakeup_start,
-              &wakeup_end - &wakeup_start);
-       acpi_copy_wakeup_routine(acpi_wakeup_address);
-
-       return 0;
-}
-
-/*
- * acpi_restore_state
- */
-void acpi_restore_state_mem(void)
-{
-}
-
-/**
- * acpi_reserve_bootmem - do _very_ early ACPI initialisation
- *
- * We allocate a page in low memory for the wakeup
- * routine for when we come back from a sleep state. The
- * runtime allocator allows specification of <16M pages, but not
- * <1M pages.
- */
-void __init acpi_reserve_bootmem(void)
-{
-       acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE*2);
-       if ((&wakeup_end - &wakeup_start) > (PAGE_SIZE*2))
-               printk(KERN_CRIT
-                      "ACPI: Wakeup code way too big, will crash on attempt"
-                      " to suspend\n");
-}
-
-static int __init acpi_sleep_setup(char *str)
-{
-       while ((str != NULL) && (*str != '\0')) {
-               if (strncmp(str, "s3_bios", 7) == 0)
-                       acpi_realmode_flags |= 1;
-               if (strncmp(str, "s3_mode", 7) == 0)
-                       acpi_realmode_flags |= 2;
-               if (strncmp(str, "s3_beep", 7) == 0)
-                       acpi_realmode_flags |= 4;
-               str = strchr(str, ',');
-               if (str != NULL)
-                       str += strspn(str, ", \t");
-       }
-       return 1;
-}
-
-__setup("acpi_sleep=", acpi_sleep_setup);
-
-void acpi_pci_link_exit(void)
-{
-}
diff --git a/arch/x86_64/kernel/acpi/wakeup.S b/arch/x86_64/kernel/acpi/wakeup.S
deleted file mode 100644 (file)
index a06f2bc..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-.text
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/msr.h>
-
-# Copyright 2003 Pavel Machek <pavel@suse.cz>, distribute under GPLv2
-#
-# wakeup_code runs in real mode, and at unknown address (determined at run-time).
-# Therefore it must only use relative jumps/calls. 
-#
-# Do we need to deal with A20? It is okay: ACPI specs says A20 must be enabled
-#
-# If physical address of wakeup_code is 0x12345, BIOS should call us with
-# cs = 0x1234, eip = 0x05
-#
-
-#define BEEP \
-       inb     $97, %al;       \
-       outb    %al, $0x80;     \
-       movb    $3, %al;        \
-       outb    %al, $97;       \
-       outb    %al, $0x80;     \
-       movb    $-74, %al;      \
-       outb    %al, $67;       \
-       outb    %al, $0x80;     \
-       movb    $-119, %al;     \
-       outb    %al, $66;       \
-       outb    %al, $0x80;     \
-       movb    $15, %al;       \
-       outb    %al, $66;
-
-
-ALIGN
-       .align  16
-ENTRY(wakeup_start)
-wakeup_code:
-       wakeup_code_start = .
-       .code16
-
-# Running in *copy* of this code, somewhere in low 1MB.
-
-       movb    $0xa1, %al      ;  outb %al, $0x80
-       cli
-       cld
-       # setup data segment
-       movw    %cs, %ax
-       movw    %ax, %ds                # Make ds:0 point to wakeup_start
-       movw    %ax, %ss
-
-       # Data segment must be set up before we can see whether to beep.
-       testl   $4, realmode_flags - wakeup_code
-       jz      1f
-       BEEP
-1:
-
-                                       # Private stack is needed for ASUS board
-       mov     $(wakeup_stack - wakeup_code), %sp
-
-       pushl   $0                      # Kill any dangerous flags
-       popfl
-
-       movl    real_magic - wakeup_code, %eax
-       cmpl    $0x12345678, %eax
-       jne     bogus_real_magic
-
-       call    verify_cpu                      # Verify the cpu supports long
-                                               # mode
-       testl   %eax, %eax
-       jnz     no_longmode
-
-       testl   $1, realmode_flags - wakeup_code
-       jz      1f
-       lcall   $0xc000,$3
-       movw    %cs, %ax
-       movw    %ax, %ds                # Bios might have played with that
-       movw    %ax, %ss
-1:
-
-       testl   $2, realmode_flags - wakeup_code
-       jz      1f
-       mov     video_mode - wakeup_code, %ax
-       call    mode_set
-1:
-
-       movw    $0xb800, %ax
-       movw    %ax,%fs
-       movw    $0x0e00 + 'L', %fs:(0x10)
-
-       movb    $0xa2, %al      ;  outb %al, $0x80
-       
-       mov     %ds, %ax                        # Find 32bit wakeup_code addr
-       movzx   %ax, %esi                       # (Convert %ds:gdt to a liner ptr)
-       shll    $4, %esi
-                                               # Fix up the vectors
-       addl    %esi, wakeup_32_vector - wakeup_code
-       addl    %esi, wakeup_long64_vector - wakeup_code
-       addl    %esi, gdt_48a + 2 - wakeup_code # Fixup the gdt pointer
-
-       lidtl   %ds:idt_48a - wakeup_code
-       lgdtl   %ds:gdt_48a - wakeup_code       # load gdt with whatever is
-                                               # appropriate
-
-       movl    $1, %eax                        # protected mode (PE) bit
-       lmsw    %ax                             # This is it!
-       jmp     1f
-1:
-
-       ljmpl   *(wakeup_32_vector - wakeup_code)
-
-       .balign 4
-wakeup_32_vector:
-       .long   wakeup_32 - wakeup_code
-       .word   __KERNEL32_CS, 0
-
-       .code32
-wakeup_32:
-# Running in this code, but at low address; paging is not yet turned on.
-       movb    $0xa5, %al      ;  outb %al, $0x80
-
-       movl    $__KERNEL_DS, %eax
-       movl    %eax, %ds
-
-       movw    $0x0e00 + 'i', %ds:(0xb8012)
-       movb    $0xa8, %al      ;  outb %al, $0x80;
-
-       /*
-        * Prepare for entering 64bits mode
-        */
-
-       /* Enable PAE */
-       xorl    %eax, %eax
-       btsl    $5, %eax
-       movl    %eax, %cr4
-
-       /* Setup early boot stage 4 level pagetables */
-       leal    (wakeup_level4_pgt - wakeup_code)(%esi), %eax
-       movl    %eax, %cr3
-
-        /* Check if nx is implemented */
-        movl    $0x80000001, %eax
-        cpuid
-        movl    %edx,%edi
-
-       /* Enable Long Mode */
-       xorl    %eax, %eax
-       btsl    $_EFER_LME, %eax
-
-       /* No Execute supported? */
-       btl     $20,%edi
-       jnc     1f
-       btsl    $_EFER_NX, %eax
-                               
-       /* Make changes effective */
-1:     movl    $MSR_EFER, %ecx
-       xorl    %edx, %edx
-       wrmsr
-
-       xorl    %eax, %eax
-       btsl    $31, %eax                       /* Enable paging and in turn activate Long Mode */
-       btsl    $0, %eax                        /* Enable protected mode */
-
-       /* Make changes effective */
-       movl    %eax, %cr0
-
-       /* At this point:
-               CR4.PAE must be 1
-               CS.L must be 0
-               CR3 must point to PML4
-               Next instruction must be a branch
-               This must be on identity-mapped page
-       */
-       /*
-        * At this point we're in long mode but in 32bit compatibility mode
-        * with EFER.LME = 1, CS.L = 0, CS.D = 1 (and in turn
-        * EFER.LMA = 1). Now we want to jump in 64bit mode, to do that we load
-        * the new gdt/idt that has __KERNEL_CS with CS.L = 1.
-        */
-
-       /* Finally jump in 64bit mode */
-        ljmp    *(wakeup_long64_vector - wakeup_code)(%esi)
-
-       .balign 4
-wakeup_long64_vector:
-       .long   wakeup_long64 - wakeup_code
-       .word   __KERNEL_CS, 0
-
-.code64
-
-       /* Hooray, we are in Long 64-bit mode (but still running in
-        * low memory)
-        */
-wakeup_long64:
-       /*
-        * We must switch to a new descriptor in kernel space for the GDT
-        * because soon the kernel won't have access anymore to the userspace
-        * addresses where we're currently running on. We have to do that here
-        * because in 32bit we couldn't load a 64bit linear address.
-        */
-       lgdt    cpu_gdt_descr
-
-       movw    $0x0e00 + 'n', %ds:(0xb8014)
-       movb    $0xa9, %al      ;  outb %al, $0x80
-
-       movq    saved_magic, %rax
-       movq    $0x123456789abcdef0, %rdx
-       cmpq    %rdx, %rax
-       jne     bogus_64_magic
-
-       movw    $0x0e00 + 'u', %ds:(0xb8016)
-       
-       nop
-       nop
-       movw    $__KERNEL_DS, %ax
-       movw    %ax, %ss        
-       movw    %ax, %ds
-       movw    %ax, %es
-       movw    %ax, %fs
-       movw    %ax, %gs
-       movq    saved_rsp, %rsp
-
-       movw    $0x0e00 + 'x', %ds:(0xb8018)
-       movq    saved_rbx, %rbx
-       movq    saved_rdi, %rdi
-       movq    saved_rsi, %rsi
-       movq    saved_rbp, %rbp
-
-       movw    $0x0e00 + '!', %ds:(0xb801a)
-       movq    saved_rip, %rax
-       jmp     *%rax
-
-.code32
-
-       .align  64      
-gdta:
-       /* Its good to keep gdt in sync with one in trampoline.S */
-       .word   0, 0, 0, 0                      # dummy
-       /* ??? Why I need the accessed bit set in order for this to work? */
-       .quad   0x00cf9b000000ffff              # __KERNEL32_CS
-       .quad   0x00af9b000000ffff              # __KERNEL_CS
-       .quad   0x00cf93000000ffff              # __KERNEL_DS
-
-idt_48a:
-       .word   0                               # idt limit = 0
-       .word   0, 0                            # idt base = 0L
-
-gdt_48a:
-       .word   0x800                           # gdt limit=2048,
-                                               #  256 GDT entries
-       .long   gdta - wakeup_code              # gdt base (relocated in later)
-       
-real_magic:    .quad 0
-video_mode:    .quad 0
-realmode_flags:        .quad 0
-
-.code16
-bogus_real_magic:
-       movb    $0xba,%al       ;  outb %al,$0x80
-       jmp bogus_real_magic
-
-.code64
-bogus_64_magic:
-       movb    $0xb3,%al       ;  outb %al,$0x80
-       jmp bogus_64_magic
-
-.code16
-no_longmode:
-       movb    $0xbc,%al       ;  outb %al,$0x80
-       jmp no_longmode
-
-#include "../verify_cpu.S"
-       
-/* This code uses an extended set of video mode numbers. These include:
- * Aliases for standard modes
- *     NORMAL_VGA (-1)
- *     EXTENDED_VGA (-2)
- *     ASK_VGA (-3)
- * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
- * of compatibility when extending the table. These are between 0x00 and 0xff.
- */
-#define VIDEO_FIRST_MENU 0x0000
-
-/* Standard BIOS video modes (BIOS number + 0x0100) */
-#define VIDEO_FIRST_BIOS 0x0100
-
-/* VESA BIOS video modes (VESA number + 0x0200) */
-#define VIDEO_FIRST_VESA 0x0200
-
-/* Video7 special modes (BIOS number + 0x0900) */
-#define VIDEO_FIRST_V7 0x0900
-
-# Setting of user mode (AX=mode ID) => CF=success
-
-# For now, we only handle VESA modes (0x0200..0x03ff).  To handle other
-# modes, we should probably compile in the video code from the boot
-# directory.
-.code16
-mode_set:
-       movw    %ax, %bx
-       subb    $VIDEO_FIRST_VESA>>8, %bh
-       cmpb    $2, %bh
-       jb      check_vesa
-
-setbad:
-       clc
-       ret
-
-check_vesa:
-       orw     $0x4000, %bx                    # Use linear frame buffer
-       movw    $0x4f02, %ax                    # VESA BIOS mode set call
-       int     $0x10
-       cmpw    $0x004f, %ax                    # AL=4f if implemented
-       jnz     setbad                          # AH=0 if OK
-
-       stc
-       ret
-
-wakeup_stack_begin:    # Stack grows down
-
-.org   0xff0
-wakeup_stack:          # Just below end of page
-
-.org   0x1000
-ENTRY(wakeup_level4_pgt)
-       .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .fill   510,8,0
-       /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
-       .quad   level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
-
-ENTRY(wakeup_end)
-       
-##
-# acpi_copy_wakeup_routine
-#
-# Copy the above routine to low memory.
-#
-# Parameters:
-# %rdi:        place to copy wakeup routine to
-#
-# Returned address is location of code in low memory (past data and stack)
-#
-       .code64
-ENTRY(acpi_copy_wakeup_routine)
-       pushq   %rax
-       pushq   %rdx
-
-       movl    saved_video_mode, %edx
-       movl    %edx, video_mode - wakeup_start (,%rdi)
-       movl    acpi_realmode_flags, %edx
-       movl    %edx, realmode_flags - wakeup_start (,%rdi)
-       movq    $0x12345678, real_magic - wakeup_start (,%rdi)
-       movq    $0x123456789abcdef0, %rdx
-       movq    %rdx, saved_magic
-
-       movq    saved_magic, %rax
-       movq    $0x123456789abcdef0, %rdx
-       cmpq    %rdx, %rax
-       jne     bogus_64_magic
-
-       # restore the regs we used
-       popq    %rdx
-       popq    %rax
-ENTRY(do_suspend_lowlevel_s4bios)
-       ret
-
-       .align 2
-       .p2align 4,,15
-.globl do_suspend_lowlevel
-       .type   do_suspend_lowlevel,@function
-do_suspend_lowlevel:
-.LFB5:
-       subq    $8, %rsp
-       xorl    %eax, %eax
-       call    save_processor_state
-
-       movq %rsp, saved_context_esp(%rip)
-       movq %rax, saved_context_eax(%rip)
-       movq %rbx, saved_context_ebx(%rip)
-       movq %rcx, saved_context_ecx(%rip)
-       movq %rdx, saved_context_edx(%rip)
-       movq %rbp, saved_context_ebp(%rip)
-       movq %rsi, saved_context_esi(%rip)
-       movq %rdi, saved_context_edi(%rip)
-       movq %r8,  saved_context_r08(%rip)
-       movq %r9,  saved_context_r09(%rip)
-       movq %r10, saved_context_r10(%rip)
-       movq %r11, saved_context_r11(%rip)
-       movq %r12, saved_context_r12(%rip)
-       movq %r13, saved_context_r13(%rip)
-       movq %r14, saved_context_r14(%rip)
-       movq %r15, saved_context_r15(%rip)
-       pushfq ; popq saved_context_eflags(%rip)
-
-       movq    $.L97, saved_rip(%rip)
-
-       movq %rsp,saved_rsp
-       movq %rbp,saved_rbp
-       movq %rbx,saved_rbx
-       movq %rdi,saved_rdi
-       movq %rsi,saved_rsi
-
-       addq    $8, %rsp
-       movl    $3, %edi
-       xorl    %eax, %eax
-       jmp     acpi_enter_sleep_state
-.L97:
-       .p2align 4,,7
-.L99:
-       .align 4
-       movl    $24, %eax
-       movw %ax, %ds
-       movq    saved_context+58(%rip), %rax
-       movq %rax, %cr4
-       movq    saved_context+50(%rip), %rax
-       movq %rax, %cr3
-       movq    saved_context+42(%rip), %rax
-       movq %rax, %cr2
-       movq    saved_context+34(%rip), %rax
-       movq %rax, %cr0
-       pushq saved_context_eflags(%rip) ; popfq
-       movq saved_context_esp(%rip), %rsp
-       movq saved_context_ebp(%rip), %rbp
-       movq saved_context_eax(%rip), %rax
-       movq saved_context_ebx(%rip), %rbx
-       movq saved_context_ecx(%rip), %rcx
-       movq saved_context_edx(%rip), %rdx
-       movq saved_context_esi(%rip), %rsi
-       movq saved_context_edi(%rip), %rdi
-       movq saved_context_r08(%rip), %r8
-       movq saved_context_r09(%rip), %r9
-       movq saved_context_r10(%rip), %r10
-       movq saved_context_r11(%rip), %r11
-       movq saved_context_r12(%rip), %r12
-       movq saved_context_r13(%rip), %r13
-       movq saved_context_r14(%rip), %r14
-       movq saved_context_r15(%rip), %r15
-
-       xorl    %eax, %eax
-       addq    $8, %rsp
-       jmp     restore_processor_state
-.LFE5:
-.Lfe5:
-       .size   do_suspend_lowlevel,.Lfe5-do_suspend_lowlevel
-       
-.data
-ALIGN
-ENTRY(saved_rbp)       .quad   0
-ENTRY(saved_rsi)       .quad   0
-ENTRY(saved_rdi)       .quad   0
-ENTRY(saved_rbx)       .quad   0
-
-ENTRY(saved_rip)       .quad   0
-ENTRY(saved_rsp)       .quad   0
-
-ENTRY(saved_magic)     .quad   0
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
deleted file mode 100644 (file)
index 8f681ca..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-/* 
- * Firmware replacement code.
- * 
- * Work around broken BIOSes that don't set an aperture or only set the
- * aperture in the AGP bridge. 
- * If all fails map the aperture over some low memory.  This is cheaper than 
- * doing bounce buffering. The memory is lost. This is done at early boot 
- * because only the bootmem allocator can allocate 32+MB. 
- * 
- * Copyright 2002 Andi Kleen, SuSE Labs.
- */
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/bootmem.h>
-#include <linux/mmzone.h>
-#include <linux/pci_ids.h>
-#include <linux/pci.h>
-#include <linux/bitops.h>
-#include <linux/ioport.h>
-#include <asm/e820.h>
-#include <asm/io.h>
-#include <asm/iommu.h>
-#include <asm/pci-direct.h>
-#include <asm/dma.h>
-#include <asm/k8.h>
-
-int iommu_aperture;
-int iommu_aperture_disabled __initdata = 0;
-int iommu_aperture_allowed __initdata = 0;
-
-int fallback_aper_order __initdata = 1; /* 64MB */
-int fallback_aper_force __initdata = 0; 
-
-int fix_aperture __initdata = 1;
-
-static struct resource gart_resource = {
-       .name   = "GART",
-       .flags  = IORESOURCE_MEM,
-};
-
-static void __init insert_aperture_resource(u32 aper_base, u32 aper_size)
-{
-       gart_resource.start = aper_base;
-       gart_resource.end = aper_base + aper_size - 1;
-       insert_resource(&iomem_resource, &gart_resource);
-}
-
-/* This code runs before the PCI subsystem is initialized, so just
-   access the northbridge directly. */
-
-static u32 __init allocate_aperture(void) 
-{
-       u32 aper_size;
-       void *p; 
-
-       if (fallback_aper_order > 7) 
-               fallback_aper_order = 7; 
-       aper_size = (32 * 1024 * 1024) << fallback_aper_order; 
-
-       /* 
-        * Aperture has to be naturally aligned. This means an 2GB aperture won't
-        * have much chance of finding a place in the lower 4GB of memory.
-        * Unfortunately we cannot move it up because that would make the
-        * IOMMU useless.
-        */
-       p = __alloc_bootmem_nopanic(aper_size, aper_size, 0);
-       if (!p || __pa(p)+aper_size > 0xffffffff) {
-               printk("Cannot allocate aperture memory hole (%p,%uK)\n",
-                      p, aper_size>>10);
-               if (p)
-                       free_bootmem(__pa(p), aper_size);
-               return 0;
-       }
-       printk("Mapping aperture over %d KB of RAM @ %lx\n",
-              aper_size >> 10, __pa(p)); 
-       insert_aperture_resource((u32)__pa(p), aper_size);
-       return (u32)__pa(p); 
-}
-
-static int __init aperture_valid(u64 aper_base, u32 aper_size)
-{ 
-       if (!aper_base) 
-               return 0;
-       if (aper_size < 64*1024*1024) { 
-               printk("Aperture too small (%d MB)\n", aper_size>>20);
-               return 0;
-       }
-       if (aper_base + aper_size > 0x100000000UL) {
-               printk("Aperture beyond 4GB. Ignoring.\n");
-               return 0; 
-       }
-       if (e820_any_mapped(aper_base, aper_base + aper_size, E820_RAM)) {
-               printk("Aperture pointing to e820 RAM. Ignoring.\n");
-               return 0; 
-       } 
-       return 1;
-} 
-
-/* Find a PCI capability */
-static __u32 __init find_cap(int num, int slot, int func, int cap) 
-{ 
-       u8 pos;
-       int bytes;
-       if (!(read_pci_config_16(num,slot,func,PCI_STATUS) & PCI_STATUS_CAP_LIST))
-               return 0;
-       pos = read_pci_config_byte(num,slot,func,PCI_CAPABILITY_LIST);
-       for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) { 
-               u8 id;
-               pos &= ~3; 
-               id = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_ID);
-               if (id == 0xff)
-                       break;
-               if (id == cap) 
-                       return pos; 
-               pos = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_NEXT); 
-       } 
-       return 0;
-} 
-
-/* Read a standard AGPv3 bridge header */
-static __u32 __init read_agp(int num, int slot, int func, int cap, u32 *order)
-{ 
-       u32 apsize;
-       u32 apsizereg;
-       int nbits;
-       u32 aper_low, aper_hi;
-       u64 aper;
-
-       printk("AGP bridge at %02x:%02x:%02x\n", num, slot, func);
-       apsizereg = read_pci_config_16(num,slot,func, cap + 0x14);
-       if (apsizereg == 0xffffffff) {
-               printk("APSIZE in AGP bridge unreadable\n");
-               return 0;
-       }
-
-       apsize = apsizereg & 0xfff;
-       /* Some BIOS use weird encodings not in the AGPv3 table. */
-       if (apsize & 0xff) 
-               apsize |= 0xf00; 
-       nbits = hweight16(apsize);
-       *order = 7 - nbits;
-       if ((int)*order < 0) /* < 32MB */
-               *order = 0;
-       
-       aper_low = read_pci_config(num,slot,func, 0x10);
-       aper_hi = read_pci_config(num,slot,func,0x14);
-       aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32);
-
-       printk("Aperture from AGP @ %Lx size %u MB (APSIZE %x)\n", 
-              aper, 32 << *order, apsizereg);
-
-       if (!aperture_valid(aper, (32*1024*1024) << *order))
-           return 0;
-       return (u32)aper; 
-} 
-
-/* Look for an AGP bridge. Windows only expects the aperture in the
-   AGP bridge and some BIOS forget to initialize the Northbridge too.
-   Work around this here. 
-
-   Do an PCI bus scan by hand because we're running before the PCI
-   subsystem. 
-
-   All K8 AGP bridges are AGPv3 compliant, so we can do this scan
-   generically. It's probably overkill to always scan all slots because
-   the AGP bridges should be always an own bus on the HT hierarchy, 
-   but do it here for future safety. */
-static __u32 __init search_agp_bridge(u32 *order, int *valid_agp)
-{
-       int num, slot, func;
-
-       /* Poor man's PCI discovery */
-       for (num = 0; num < 256; num++) { 
-               for (slot = 0; slot < 32; slot++) { 
-                       for (func = 0; func < 8; func++) { 
-                               u32 class, cap;
-                               u8 type;
-                               class = read_pci_config(num,slot,func,
-                                                       PCI_CLASS_REVISION);
-                               if (class == 0xffffffff)
-                                       break; 
-                               
-                               switch (class >> 16) { 
-                               case PCI_CLASS_BRIDGE_HOST:
-                               case PCI_CLASS_BRIDGE_OTHER: /* needed? */
-                                       /* AGP bridge? */
-                                       cap = find_cap(num,slot,func,PCI_CAP_ID_AGP);
-                                       if (!cap)
-                                               break;
-                                       *valid_agp = 1; 
-                                       return read_agp(num,slot,func,cap,order);
-                               } 
-                               
-                               /* No multi-function device? */
-                               type = read_pci_config_byte(num,slot,func,
-                                                              PCI_HEADER_TYPE);
-                               if (!(type & 0x80))
-                                       break;
-                       } 
-               } 
-       }
-       printk("No AGP bridge found\n"); 
-       return 0;
-}
-
-void __init iommu_hole_init(void) 
-{ 
-       int fix, num; 
-       u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
-       u64 aper_base, last_aper_base = 0;
-       int valid_agp = 0;
-
-       if (iommu_aperture_disabled || !fix_aperture || !early_pci_allowed())
-               return;
-
-       printk(KERN_INFO  "Checking aperture...\n");
-
-       fix = 0;
-       for (num = 24; num < 32; num++) {               
-               if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00)))
-                       continue;
-
-               iommu_detected = 1;
-               iommu_aperture = 1; 
-
-               aper_order = (read_pci_config(0, num, 3, 0x90) >> 1) & 7; 
-               aper_size = (32 * 1024 * 1024) << aper_order; 
-               aper_base = read_pci_config(0, num, 3, 0x94) & 0x7fff;
-               aper_base <<= 25; 
-
-               printk("CPU %d: aperture @ %Lx size %u MB\n", num-24, 
-                      aper_base, aper_size>>20);
-               
-               if (!aperture_valid(aper_base, aper_size)) {
-                       fix = 1; 
-                       break; 
-               }
-
-               if ((last_aper_order && aper_order != last_aper_order) ||
-                   (last_aper_base && aper_base != last_aper_base)) {
-                       fix = 1;
-                       break;
-               }
-               last_aper_order = aper_order;
-               last_aper_base = aper_base;
-       } 
-
-       if (!fix && !fallback_aper_force) {
-               if (last_aper_base) {
-                       unsigned long n = (32 * 1024 * 1024) << last_aper_order;
-                       insert_aperture_resource((u32)last_aper_base, n);
-               }
-               return; 
-       }
-
-       if (!fallback_aper_force)
-               aper_alloc = search_agp_bridge(&aper_order, &valid_agp); 
-               
-       if (aper_alloc) { 
-               /* Got the aperture from the AGP bridge */
-       } else if (swiotlb && !valid_agp) {
-               /* Do nothing */
-       } else if ((!no_iommu && end_pfn > MAX_DMA32_PFN) ||
-                  force_iommu ||
-                  valid_agp ||
-                  fallback_aper_force) { 
-               printk("Your BIOS doesn't leave a aperture memory hole\n");
-               printk("Please enable the IOMMU option in the BIOS setup\n");
-               printk("This costs you %d MB of RAM\n",
-                      32 << fallback_aper_order);
-
-               aper_order = fallback_aper_order;
-               aper_alloc = allocate_aperture();
-               if (!aper_alloc) { 
-                       /* Could disable AGP and IOMMU here, but it's probably
-                          not worth it. But the later users cannot deal with
-                          bad apertures and turning on the aperture over memory
-                          causes very strange problems, so it's better to 
-                          panic early. */
-                       panic("Not enough memory for aperture");
-               }
-       } else { 
-               return; 
-       } 
-
-       /* Fix up the north bridges */
-       for (num = 24; num < 32; num++) {               
-               if (!early_is_k8_nb(read_pci_config(0, num, 3, 0x00)))
-                       continue;       
-
-               /* Don't enable translation yet. That is done later. 
-                  Assume this BIOS didn't initialise the GART so 
-                  just overwrite all previous bits */ 
-               write_pci_config(0, num, 3, 0x90, aper_order<<1); 
-               write_pci_config(0, num, 3, 0x94, aper_alloc>>25); 
-       } 
-} 
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
deleted file mode 100644 (file)
index 925758d..0000000
+++ /dev/null
@@ -1,1253 +0,0 @@
-/*
- *     Local APIC handling, local APIC timers
- *
- *     (c) 1999, 2000 Ingo Molnar <mingo@redhat.com>
- *
- *     Fixes
- *     Maciej W. Rozycki       :       Bits for genuine 82489DX APICs;
- *                                     thanks to Eric Gilmore
- *                                     and Rolf G. Tews
- *                                     for testing these extensively.
- *     Maciej W. Rozycki       :       Various updates and fixes.
- *     Mikael Pettersson       :       Power Management for UP-APIC.
- *     Pavel Machek and
- *     Mikael Pettersson       :       PM converted to driver model.
- */
-
-#include <linux/init.h>
-
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/bootmem.h>
-#include <linux/interrupt.h>
-#include <linux/mc146818rtc.h>
-#include <linux/kernel_stat.h>
-#include <linux/sysdev.h>
-#include <linux/module.h>
-#include <linux/ioport.h>
-
-#include <asm/atomic.h>
-#include <asm/smp.h>
-#include <asm/mtrr.h>
-#include <asm/mpspec.h>
-#include <asm/pgalloc.h>
-#include <asm/mach_apic.h>
-#include <asm/nmi.h>
-#include <asm/idle.h>
-#include <asm/proto.h>
-#include <asm/timex.h>
-#include <asm/hpet.h>
-#include <asm/apic.h>
-
-int apic_mapped;
-int apic_verbosity;
-int apic_runs_main_timer;
-int apic_calibrate_pmtmr __initdata;
-
-int disable_apic_timer __initdata;
-
-/* Local APIC timer works in C2? */
-int local_apic_timer_c2_ok;
-EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
-
-static struct resource *ioapic_resources;
-static struct resource lapic_resource = {
-       .name = "Local APIC",
-       .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
-};
-
-/*
- * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
- * IPIs in place of local APIC timers
- */
-static cpumask_t timer_interrupt_broadcast_ipi_mask;
-
-/* Using APIC to generate smp_local_timer_interrupt? */
-int using_apic_timer __read_mostly = 0;
-
-static void apic_pm_activate(void);
-
-void apic_wait_icr_idle(void)
-{
-       while (apic_read(APIC_ICR) & APIC_ICR_BUSY)
-               cpu_relax();
-}
-
-unsigned int safe_apic_wait_icr_idle(void)
-{
-       unsigned int send_status;
-       int timeout;
-
-       timeout = 0;
-       do {
-               send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
-               if (!send_status)
-                       break;
-               udelay(100);
-       } while (timeout++ < 1000);
-
-       return send_status;
-}
-
-void enable_NMI_through_LVT0 (void * dummy)
-{
-       unsigned int v;
-
-       /* unmask and set to NMI */
-       v = APIC_DM_NMI;
-       apic_write(APIC_LVT0, v);
-}
-
-int get_maxlvt(void)
-{
-       unsigned int v, maxlvt;
-
-       v = apic_read(APIC_LVR);
-       maxlvt = GET_APIC_MAXLVT(v);
-       return maxlvt;
-}
-
-/*
- * 'what should we do if we get a hw irq event on an illegal vector'.
- * each architecture has to answer this themselves.
- */
-void ack_bad_irq(unsigned int irq)
-{
-       printk("unexpected IRQ trap at vector %02x\n", irq);
-       /*
-        * Currently unexpected vectors happen only on SMP and APIC.
-        * We _must_ ack these because every local APIC has only N
-        * irq slots per priority level, and a 'hanging, unacked' IRQ
-        * holds up an irq slot - in excessive cases (when multiple
-        * unexpected vectors occur) that might lock up the APIC
-        * completely.
-        * But don't ack when the APIC is disabled. -AK
-        */
-       if (!disable_apic)
-               ack_APIC_irq();
-}
-
-void clear_local_APIC(void)
-{
-       int maxlvt;
-       unsigned int v;
-
-       maxlvt = get_maxlvt();
-
-       /*
-        * Masking an LVT entry can trigger a local APIC error
-        * if the vector is zero. Mask LVTERR first to prevent this.
-        */
-       if (maxlvt >= 3) {
-               v = ERROR_APIC_VECTOR; /* any non-zero vector will do */
-               apic_write(APIC_LVTERR, v | APIC_LVT_MASKED);
-       }
-       /*
-        * Careful: we have to set masks only first to deassert
-        * any level-triggered sources.
-        */
-       v = apic_read(APIC_LVTT);
-       apic_write(APIC_LVTT, v | APIC_LVT_MASKED);
-       v = apic_read(APIC_LVT0);
-       apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
-       v = apic_read(APIC_LVT1);
-       apic_write(APIC_LVT1, v | APIC_LVT_MASKED);
-       if (maxlvt >= 4) {
-               v = apic_read(APIC_LVTPC);
-               apic_write(APIC_LVTPC, v | APIC_LVT_MASKED);
-       }
-
-       /*
-        * Clean APIC state for other OSs:
-        */
-       apic_write(APIC_LVTT, APIC_LVT_MASKED);
-       apic_write(APIC_LVT0, APIC_LVT_MASKED);
-       apic_write(APIC_LVT1, APIC_LVT_MASKED);
-       if (maxlvt >= 3)
-               apic_write(APIC_LVTERR, APIC_LVT_MASKED);
-       if (maxlvt >= 4)
-               apic_write(APIC_LVTPC, APIC_LVT_MASKED);
-       apic_write(APIC_ESR, 0);
-       apic_read(APIC_ESR);
-}
-
-void disconnect_bsp_APIC(int virt_wire_setup)
-{
-       /* Go back to Virtual Wire compatibility mode */
-       unsigned long value;
-
-       /* For the spurious interrupt use vector F, and enable it */
-       value = apic_read(APIC_SPIV);
-       value &= ~APIC_VECTOR_MASK;
-       value |= APIC_SPIV_APIC_ENABLED;
-       value |= 0xf;
-       apic_write(APIC_SPIV, value);
-
-       if (!virt_wire_setup) {
-               /* For LVT0 make it edge triggered, active high, external and enabled */
-               value = apic_read(APIC_LVT0);
-               value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
-                       APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
-                       APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
-               value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
-               value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
-               apic_write(APIC_LVT0, value);
-       } else {
-               /* Disable LVT0 */
-               apic_write(APIC_LVT0, APIC_LVT_MASKED);
-       }
-
-       /* For LVT1 make it edge triggered, active high, nmi and enabled */
-       value = apic_read(APIC_LVT1);
-       value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
-                       APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
-                       APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
-       value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
-       value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
-       apic_write(APIC_LVT1, value);
-}
-
-void disable_local_APIC(void)
-{
-       unsigned int value;
-
-       clear_local_APIC();
-
-       /*
-        * Disable APIC (implies clearing of registers
-        * for 82489DX!).
-        */
-       value = apic_read(APIC_SPIV);
-       value &= ~APIC_SPIV_APIC_ENABLED;
-       apic_write(APIC_SPIV, value);
-}
-
-/*
- * This is to verify that we're looking at a real local APIC.
- * Check these against your board if the CPUs aren't getting
- * started for no apparent reason.
- */
-int __init verify_local_APIC(void)
-{
-       unsigned int reg0, reg1;
-
-       /*
-        * The version register is read-only in a real APIC.
-        */
-       reg0 = apic_read(APIC_LVR);
-       apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg0);
-       apic_write(APIC_LVR, reg0 ^ APIC_LVR_MASK);
-       reg1 = apic_read(APIC_LVR);
-       apic_printk(APIC_DEBUG, "Getting VERSION: %x\n", reg1);
-
-       /*
-        * The two version reads above should print the same
-        * numbers.  If the second one is different, then we
-        * poke at a non-APIC.
-        */
-       if (reg1 != reg0)
-               return 0;
-
-       /*
-        * Check if the version looks reasonably.
-        */
-       reg1 = GET_APIC_VERSION(reg0);
-       if (reg1 == 0x00 || reg1 == 0xff)
-               return 0;
-       reg1 = get_maxlvt();
-       if (reg1 < 0x02 || reg1 == 0xff)
-               return 0;
-
-       /*
-        * The ID register is read/write in a real APIC.
-        */
-       reg0 = apic_read(APIC_ID);
-       apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
-       apic_write(APIC_ID, reg0 ^ APIC_ID_MASK);
-       reg1 = apic_read(APIC_ID);
-       apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
-       apic_write(APIC_ID, reg0);
-       if (reg1 != (reg0 ^ APIC_ID_MASK))
-               return 0;
-
-       /*
-        * The next two are just to see if we have sane values.
-        * They're only really relevant if we're in Virtual Wire
-        * compatibility mode, but most boxes are anymore.
-        */
-       reg0 = apic_read(APIC_LVT0);
-       apic_printk(APIC_DEBUG,"Getting LVT0: %x\n", reg0);
-       reg1 = apic_read(APIC_LVT1);
-       apic_printk(APIC_DEBUG, "Getting LVT1: %x\n", reg1);
-
-       return 1;
-}
-
-void __init sync_Arb_IDs(void)
-{
-       /* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 */
-       unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
-       if (ver >= 0x14)        /* P4 or higher */
-               return;
-
-       /*
-        * Wait for idle.
-        */
-       apic_wait_icr_idle();
-
-       apic_printk(APIC_DEBUG, "Synchronizing Arb IDs.\n");
-       apic_write(APIC_ICR, APIC_DEST_ALLINC | APIC_INT_LEVELTRIG
-                               | APIC_DM_INIT);
-}
-
-/*
- * An initial setup of the virtual wire mode.
- */
-void __init init_bsp_APIC(void)
-{
-       unsigned int value;
-
-       /*
-        * Don't do the setup now if we have a SMP BIOS as the
-        * through-I/O-APIC virtual wire mode might be active.
-        */
-       if (smp_found_config || !cpu_has_apic)
-               return;
-
-       value = apic_read(APIC_LVR);
-
-       /*
-        * Do not trust the local APIC being empty at bootup.
-        */
-       clear_local_APIC();
-
-       /*
-        * Enable APIC.
-        */
-       value = apic_read(APIC_SPIV);
-       value &= ~APIC_VECTOR_MASK;
-       value |= APIC_SPIV_APIC_ENABLED;
-       value |= APIC_SPIV_FOCUS_DISABLED;
-       value |= SPURIOUS_APIC_VECTOR;
-       apic_write(APIC_SPIV, value);
-
-       /*
-        * Set up the virtual wire mode.
-        */
-       apic_write(APIC_LVT0, APIC_DM_EXTINT);
-       value = APIC_DM_NMI;
-       apic_write(APIC_LVT1, value);
-}
-
-void __cpuinit setup_local_APIC (void)
-{
-       unsigned int value, maxlvt;
-       int i, j;
-
-       value = apic_read(APIC_LVR);
-
-       BUILD_BUG_ON((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f);
-
-       /*
-        * Double-check whether this APIC is really registered.
-        * This is meaningless in clustered apic mode, so we skip it.
-        */
-       if (!apic_id_registered())
-               BUG();
-
-       /*
-        * Intel recommends to set DFR, LDR and TPR before enabling
-        * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
-        * document number 292116).  So here it goes...
-        */
-       init_apic_ldr();
-
-       /*
-        * Set Task Priority to 'accept all'. We never change this
-        * later on.
-        */
-       value = apic_read(APIC_TASKPRI);
-       value &= ~APIC_TPRI_MASK;
-       apic_write(APIC_TASKPRI, value);
-
-       /*
-        * After a crash, we no longer service the interrupts and a pending
-        * interrupt from previous kernel might still have ISR bit set.
-        *
-        * Most probably by now CPU has serviced that pending interrupt and
-        * it might not have done the ack_APIC_irq() because it thought,
-        * interrupt came from i8259 as ExtInt. LAPIC did not get EOI so it
-        * does not clear the ISR bit and cpu thinks it has already serivced
-        * the interrupt. Hence a vector might get locked. It was noticed
-        * for timer irq (vector 0x31). Issue an extra EOI to clear ISR.
-        */
-       for (i = APIC_ISR_NR - 1; i >= 0; i--) {
-               value = apic_read(APIC_ISR + i*0x10);
-               for (j = 31; j >= 0; j--) {
-                       if (value & (1<<j))
-                               ack_APIC_irq();
-               }
-       }
-
-       /*
-        * Now that we are all set up, enable the APIC
-        */
-       value = apic_read(APIC_SPIV);
-       value &= ~APIC_VECTOR_MASK;
-       /*
-        * Enable APIC
-        */
-       value |= APIC_SPIV_APIC_ENABLED;
-
-       /* We always use processor focus */
-
-       /*
-        * Set spurious IRQ vector
-        */
-       value |= SPURIOUS_APIC_VECTOR;
-       apic_write(APIC_SPIV, value);
-
-       /*
-        * Set up LVT0, LVT1:
-        *
-        * set up through-local-APIC on the BP's LINT0. This is not
-        * strictly necessary in pure symmetric-IO mode, but sometimes
-        * we delegate interrupts to the 8259A.
-        */
-       /*
-        * TODO: set up through-local-APIC from through-I/O-APIC? --macro
-        */
-       value = apic_read(APIC_LVT0) & APIC_LVT_MASKED;
-       if (!smp_processor_id() && !value) {
-               value = APIC_DM_EXTINT;
-               apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", smp_processor_id());
-       } else {
-               value = APIC_DM_EXTINT | APIC_LVT_MASKED;
-               apic_printk(APIC_VERBOSE, "masked ExtINT on CPU#%d\n", smp_processor_id());
-       }
-       apic_write(APIC_LVT0, value);
-
-       /*
-        * only the BP should see the LINT1 NMI signal, obviously.
-        */
-       if (!smp_processor_id())
-               value = APIC_DM_NMI;
-       else
-               value = APIC_DM_NMI | APIC_LVT_MASKED;
-       apic_write(APIC_LVT1, value);
-
-       {
-               unsigned oldvalue;
-               maxlvt = get_maxlvt();
-               oldvalue = apic_read(APIC_ESR);
-               value = ERROR_APIC_VECTOR;      // enables sending errors
-               apic_write(APIC_LVTERR, value);
-               /*
-                * spec says clear errors after enabling vector.
-                */
-               if (maxlvt > 3)
-                       apic_write(APIC_ESR, 0);
-               value = apic_read(APIC_ESR);
-               if (value != oldvalue)
-                       apic_printk(APIC_VERBOSE,
-                       "ESR value after enabling vector: %08x, after %08x\n",
-                       oldvalue, value);
-       }
-
-       nmi_watchdog_default();
-       setup_apic_nmi_watchdog(NULL);
-       apic_pm_activate();
-}
-
-#ifdef CONFIG_PM
-
-static struct {
-       /* 'active' is true if the local APIC was enabled by us and
-          not the BIOS; this signifies that we are also responsible
-          for disabling it before entering apm/acpi suspend */
-       int active;
-       /* r/w apic fields */
-       unsigned int apic_id;
-       unsigned int apic_taskpri;
-       unsigned int apic_ldr;
-       unsigned int apic_dfr;
-       unsigned int apic_spiv;
-       unsigned int apic_lvtt;
-       unsigned int apic_lvtpc;
-       unsigned int apic_lvt0;
-       unsigned int apic_lvt1;
-       unsigned int apic_lvterr;
-       unsigned int apic_tmict;
-       unsigned int apic_tdcr;
-       unsigned int apic_thmr;
-} apic_pm_state;
-
-static int lapic_suspend(struct sys_device *dev, pm_message_t state)
-{
-       unsigned long flags;
-       int maxlvt;
-
-       if (!apic_pm_state.active)
-               return 0;
-
-       maxlvt = get_maxlvt();
-
-       apic_pm_state.apic_id = apic_read(APIC_ID);
-       apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
-       apic_pm_state.apic_ldr = apic_read(APIC_LDR);
-       apic_pm_state.apic_dfr = apic_read(APIC_DFR);
-       apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
-       apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
-       if (maxlvt >= 4)
-               apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
-       apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
-       apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
-       apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
-       apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
-       apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
-#ifdef CONFIG_X86_MCE_INTEL
-       if (maxlvt >= 5)
-               apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
-#endif
-       local_irq_save(flags);
-       disable_local_APIC();
-       local_irq_restore(flags);
-       return 0;
-}
-
-static int lapic_resume(struct sys_device *dev)
-{
-       unsigned int l, h;
-       unsigned long flags;
-       int maxlvt;
-
-       if (!apic_pm_state.active)
-               return 0;
-
-       maxlvt = get_maxlvt();
-
-       local_irq_save(flags);
-       rdmsr(MSR_IA32_APICBASE, l, h);
-       l &= ~MSR_IA32_APICBASE_BASE;
-       l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
-       wrmsr(MSR_IA32_APICBASE, l, h);
-       apic_write(APIC_LVTERR, ERROR_APIC_VECTOR | APIC_LVT_MASKED);
-       apic_write(APIC_ID, apic_pm_state.apic_id);
-       apic_write(APIC_DFR, apic_pm_state.apic_dfr);
-       apic_write(APIC_LDR, apic_pm_state.apic_ldr);
-       apic_write(APIC_TASKPRI, apic_pm_state.apic_taskpri);
-       apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
-       apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
-       apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
-#ifdef CONFIG_X86_MCE_INTEL
-       if (maxlvt >= 5)
-               apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
-#endif
-       if (maxlvt >= 4)
-               apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
-       apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
-       apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
-       apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
-       apic_write(APIC_ESR, 0);
-       apic_read(APIC_ESR);
-       apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
-       apic_write(APIC_ESR, 0);
-       apic_read(APIC_ESR);
-       local_irq_restore(flags);
-       return 0;
-}
-
-static struct sysdev_class lapic_sysclass = {
-       set_kset_name("lapic"),
-       .resume         = lapic_resume,
-       .suspend        = lapic_suspend,
-};
-
-static struct sys_device device_lapic = {
-       .id             = 0,
-       .cls            = &lapic_sysclass,
-};
-
-static void __cpuinit apic_pm_activate(void)
-{
-       apic_pm_state.active = 1;
-}
-
-static int __init init_lapic_sysfs(void)
-{
-       int error;
-       if (!cpu_has_apic)
-               return 0;
-       /* XXX: remove suspend/resume procs if !apic_pm_state.active? */
-       error = sysdev_class_register(&lapic_sysclass);
-       if (!error)
-               error = sysdev_register(&device_lapic);
-       return error;
-}
-device_initcall(init_lapic_sysfs);
-
-#else  /* CONFIG_PM */
-
-static void apic_pm_activate(void) { }
-
-#endif /* CONFIG_PM */
-
-static int __init apic_set_verbosity(char *str)
-{
-       if (str == NULL)  {
-               skip_ioapic_setup = 0;
-               ioapic_force = 1;
-               return 0;
-       }
-       if (strcmp("debug", str) == 0)
-               apic_verbosity = APIC_DEBUG;
-       else if (strcmp("verbose", str) == 0)
-               apic_verbosity = APIC_VERBOSE;
-       else {
-               printk(KERN_WARNING "APIC Verbosity level %s not recognised"
-                               " use apic=verbose or apic=debug\n", str);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-early_param("apic", apic_set_verbosity);
-
-/*
- * Detect and enable local APICs on non-SMP boards.
- * Original code written by Keir Fraser.
- * On AMD64 we trust the BIOS - if it says no APIC it is likely
- * not correctly set up (usually the APIC timer won't work etc.)
- */
-
-static int __init detect_init_APIC (void)
-{
-       if (!cpu_has_apic) {
-               printk(KERN_INFO "No local APIC present\n");
-               return -1;
-       }
-
-       mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
-       boot_cpu_id = 0;
-       return 0;
-}
-
-#ifdef CONFIG_X86_IO_APIC
-static struct resource * __init ioapic_setup_resources(void)
-{
-#define IOAPIC_RESOURCE_NAME_SIZE 11
-       unsigned long n;
-       struct resource *res;
-       char *mem;
-       int i;
-
-       if (nr_ioapics <= 0)
-               return NULL;
-
-       n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
-       n *= nr_ioapics;
-
-       mem = alloc_bootmem(n);
-       res = (void *)mem;
-
-       if (mem != NULL) {
-               memset(mem, 0, n);
-               mem += sizeof(struct resource) * nr_ioapics;
-
-               for (i = 0; i < nr_ioapics; i++) {
-                       res[i].name = mem;
-                       res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-                       sprintf(mem,  "IOAPIC %u", i);
-                       mem += IOAPIC_RESOURCE_NAME_SIZE;
-               }
-       }
-
-       ioapic_resources = res;
-
-       return res;
-}
-
-static int __init ioapic_insert_resources(void)
-{
-       int i;
-       struct resource *r = ioapic_resources;
-
-       if (!r) {
-               printk("IO APIC resources could be not be allocated.\n");
-               return -1;
-       }
-
-       for (i = 0; i < nr_ioapics; i++) {
-               insert_resource(&iomem_resource, r);
-               r++;
-       }
-
-       return 0;
-}
-
-/* Insert the IO APIC resources after PCI initialization has occured to handle
- * IO APICS that are mapped in on a BAR in PCI space. */
-late_initcall(ioapic_insert_resources);
-#endif
-
-void __init init_apic_mappings(void)
-{
-       unsigned long apic_phys;
-
-       /*
-        * If no local APIC can be found then set up a fake all
-        * zeroes page to simulate the local APIC and another
-        * one for the IO-APIC.
-        */
-       if (!smp_found_config && detect_init_APIC()) {
-               apic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
-               apic_phys = __pa(apic_phys);
-       } else
-               apic_phys = mp_lapic_addr;
-
-       set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
-       apic_mapped = 1;
-       apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
-
-       /* Put local APIC into the resource map. */
-       lapic_resource.start = apic_phys;
-       lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
-       insert_resource(&iomem_resource, &lapic_resource);
-
-       /*
-        * Fetch the APIC ID of the BSP in case we have a
-        * default configuration (or the MP table is broken).
-        */
-       boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
-
-       {
-               unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
-               int i;
-               struct resource *ioapic_res;
-
-               ioapic_res = ioapic_setup_resources();
-               for (i = 0; i < nr_ioapics; i++) {
-                       if (smp_found_config) {
-                               ioapic_phys = mp_ioapics[i].mpc_apicaddr;
-                       } else {
-                               ioapic_phys = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
-                               ioapic_phys = __pa(ioapic_phys);
-                       }
-                       set_fixmap_nocache(idx, ioapic_phys);
-                       apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
-                                       __fix_to_virt(idx), ioapic_phys);
-                       idx++;
-
-                       if (ioapic_res != NULL) {
-                               ioapic_res->start = ioapic_phys;
-                               ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
-                               ioapic_res++;
-                       }
-               }
-       }
-}
-
-/*
- * This function sets up the local APIC timer, with a timeout of
- * 'clocks' APIC bus clock. During calibration we actually call
- * this function twice on the boot CPU, once with a bogus timeout
- * value, second time for real. The other (noncalibrating) CPUs
- * call this function only once, with the real, calibrated value.
- *
- * We do reads before writes even if unnecessary, to get around the
- * P5 APIC double write bug.
- */
-
-#define APIC_DIVISOR 16
-
-static void __setup_APIC_LVTT(unsigned int clocks)
-{
-       unsigned int lvtt_value, tmp_value;
-       int cpu = smp_processor_id();
-
-       lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
-
-       if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
-               lvtt_value |= APIC_LVT_MASKED;
-
-       apic_write(APIC_LVTT, lvtt_value);
-
-       /*
-        * Divide PICLK by 16
-        */
-       tmp_value = apic_read(APIC_TDCR);
-       apic_write(APIC_TDCR, (tmp_value
-                               & ~(APIC_TDR_DIV_1 | APIC_TDR_DIV_TMBASE))
-                               | APIC_TDR_DIV_16);
-
-       apic_write(APIC_TMICT, clocks/APIC_DIVISOR);
-}
-
-static void setup_APIC_timer(unsigned int clocks)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-
-       /* wait for irq slice */
-       if (hpet_address && hpet_use_timer) {
-               u32 trigger = hpet_readl(HPET_T0_CMP);
-               while (hpet_readl(HPET_T0_CMP) == trigger)
-                       /* do nothing */ ;
-       } else {
-               int c1, c2;
-               outb_p(0x00, 0x43);
-               c2 = inb_p(0x40);
-               c2 |= inb_p(0x40) << 8;
-               do {
-                       c1 = c2;
-                       outb_p(0x00, 0x43);
-                       c2 = inb_p(0x40);
-                       c2 |= inb_p(0x40) << 8;
-               } while (c2 - c1 < 300);
-       }
-       __setup_APIC_LVTT(clocks);
-       /* Turn off PIT interrupt if we use APIC timer as main timer.
-          Only works with the PM timer right now
-          TBD fix it for HPET too. */
-       if ((pmtmr_ioport != 0) &&
-               smp_processor_id() == boot_cpu_id &&
-               apic_runs_main_timer == 1 &&
-               !cpu_isset(boot_cpu_id, timer_interrupt_broadcast_ipi_mask)) {
-               stop_timer_interrupt();
-               apic_runs_main_timer++;
-       }
-       local_irq_restore(flags);
-}
-
-/*
- * In this function we calibrate APIC bus clocks to the external
- * timer. Unfortunately we cannot use jiffies and the timer irq
- * to calibrate, since some later bootup code depends on getting
- * the first irq? Ugh.
- *
- * We want to do the calibration only once since we
- * want to have local timer irqs syncron. CPUs connected
- * by the same APIC bus have the very same bus frequency.
- * And we want to have irqs off anyways, no accidental
- * APIC irq that way.
- */
-
-#define TICK_COUNT 100000000
-
-static int __init calibrate_APIC_clock(void)
-{
-       unsigned apic, apic_start;
-       unsigned long tsc, tsc_start;
-       int result;
-       /*
-        * Put whatever arbitrary (but long enough) timeout
-        * value into the APIC clock, we just want to get the
-        * counter running for calibration.
-        */
-       __setup_APIC_LVTT(4000000000);
-
-       apic_start = apic_read(APIC_TMCCT);
-#ifdef CONFIG_X86_PM_TIMER
-       if (apic_calibrate_pmtmr && pmtmr_ioport) {
-               pmtimer_wait(5000);  /* 5ms wait */
-               apic = apic_read(APIC_TMCCT);
-               result = (apic_start - apic) * 1000L / 5;
-       } else
-#endif
-       {
-               rdtscll(tsc_start);
-
-               do {
-                       apic = apic_read(APIC_TMCCT);
-                       rdtscll(tsc);
-               } while ((tsc - tsc_start) < TICK_COUNT &&
-                               (apic_start - apic) < TICK_COUNT);
-
-               result = (apic_start - apic) * 1000L * tsc_khz /
-                                       (tsc - tsc_start);
-       }
-       printk("result %d\n", result);
-
-
-       printk(KERN_INFO "Detected %d.%03d MHz APIC timer.\n",
-               result / 1000 / 1000, result / 1000 % 1000);
-
-       return result * APIC_DIVISOR / HZ;
-}
-
-static unsigned int calibration_result;
-
-void __init setup_boot_APIC_clock (void)
-{
-       if (disable_apic_timer) {
-               printk(KERN_INFO "Disabling APIC timer\n");
-               return;
-       }
-
-       printk(KERN_INFO "Using local APIC timer interrupts.\n");
-       using_apic_timer = 1;
-
-       local_irq_disable();
-
-       calibration_result = calibrate_APIC_clock();
-       /*
-        * Now set up the timer for real.
-        */
-       setup_APIC_timer(calibration_result);
-
-       local_irq_enable();
-}
-
-void __cpuinit setup_secondary_APIC_clock(void)
-{
-       local_irq_disable(); /* FIXME: Do we need this? --RR */
-       setup_APIC_timer(calibration_result);
-       local_irq_enable();
-}
-
-void disable_APIC_timer(void)
-{
-       if (using_apic_timer) {
-               unsigned long v;
-
-               v = apic_read(APIC_LVTT);
-               /*
-                * When an illegal vector value (0-15) is written to an LVT
-                * entry and delivery mode is Fixed, the APIC may signal an
-                * illegal vector error, with out regard to whether the mask
-                * bit is set or whether an interrupt is actually seen on input.
-                *
-                * Boot sequence might call this function when the LVTT has
-                * '0' vector value. So make sure vector field is set to
-                * valid value.
-                */
-               v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
-               apic_write(APIC_LVTT, v);
-       }
-}
-
-void enable_APIC_timer(void)
-{
-       int cpu = smp_processor_id();
-
-       if (using_apic_timer &&
-           !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
-               unsigned long v;
-
-               v = apic_read(APIC_LVTT);
-               apic_write(APIC_LVTT, v & ~APIC_LVT_MASKED);
-       }
-}
-
-void switch_APIC_timer_to_ipi(void *cpumask)
-{
-       cpumask_t mask = *(cpumask_t *)cpumask;
-       int cpu = smp_processor_id();
-
-       if (cpu_isset(cpu, mask) &&
-           !cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
-               disable_APIC_timer();
-               cpu_set(cpu, timer_interrupt_broadcast_ipi_mask);
-       }
-}
-EXPORT_SYMBOL(switch_APIC_timer_to_ipi);
-
-void smp_send_timer_broadcast_ipi(void)
-{
-       int cpu = smp_processor_id();
-       cpumask_t mask;
-
-       cpus_and(mask, cpu_online_map, timer_interrupt_broadcast_ipi_mask);
-
-       if (cpu_isset(cpu, mask)) {
-               cpu_clear(cpu, mask);
-               add_pda(apic_timer_irqs, 1);
-               smp_local_timer_interrupt();
-       }
-
-       if (!cpus_empty(mask)) {
-               send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
-       }
-}
-
-void switch_ipi_to_APIC_timer(void *cpumask)
-{
-       cpumask_t mask = *(cpumask_t *)cpumask;
-       int cpu = smp_processor_id();
-
-       if (cpu_isset(cpu, mask) &&
-           cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) {
-               cpu_clear(cpu, timer_interrupt_broadcast_ipi_mask);
-               enable_APIC_timer();
-       }
-}
-EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
-
-int setup_profiling_timer(unsigned int multiplier)
-{
-       return -EINVAL;
-}
-
-void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
-                            unsigned char msg_type, unsigned char mask)
-{
-       unsigned long reg = (lvt_off << 4) + K8_APIC_EXT_LVT_BASE;
-       unsigned int  v   = (mask << 16) | (msg_type << 8) | vector;
-       apic_write(reg, v);
-}
-
-#undef APIC_DIVISOR
-
-/*
- * Local timer interrupt handler. It does both profiling and
- * process statistics/rescheduling.
- *
- * We do profiling in every local tick, statistics/rescheduling
- * happen only every 'profiling multiplier' ticks. The default
- * multiplier is 1 and it can be changed by writing the new multiplier
- * value into /proc/profile.
- */
-
-void smp_local_timer_interrupt(void)
-{
-       profile_tick(CPU_PROFILING);
-#ifdef CONFIG_SMP
-       update_process_times(user_mode(get_irq_regs()));
-#endif
-       if (apic_runs_main_timer > 1 && smp_processor_id() == boot_cpu_id)
-               main_timer_handler();
-       /*
-        * We take the 'long' return path, and there every subsystem
-        * grabs the appropriate locks (kernel lock/ irq lock).
-        *
-        * We might want to decouple profiling from the 'long path',
-        * and do the profiling totally in assembly.
-        *
-        * Currently this isn't too much of an issue (performance wise),
-        * we can take more than 100K local irqs per second on a 100 MHz P5.
-        */
-}
-
-/*
- * Local APIC timer interrupt. This is the most natural way for doing
- * local interrupts, but local timer interrupts can be emulated by
- * broadcast interrupts too. [in case the hw doesn't support APIC timers]
- *
- * [ if a single-CPU system runs an SMP kernel then we call the local
- *   interrupt as well. Thus we cannot inline the local irq ... ]
- */
-void smp_apic_timer_interrupt(struct pt_regs *regs)
-{
-       struct pt_regs *old_regs = set_irq_regs(regs);
-
-       /*
-        * the NMI deadlock-detector uses this.
-        */
-       add_pda(apic_timer_irqs, 1);
-
-       /*
-        * NOTE! We'd better ACK the irq immediately,
-        * because timer handling can be slow.
-        */
-       ack_APIC_irq();
-       /*
-        * update_process_times() expects us to have done irq_enter().
-        * Besides, if we don't timer interrupts ignore the global
-        * interrupt lock, which is the WrongThing (tm) to do.
-        */
-       exit_idle();
-       irq_enter();
-       smp_local_timer_interrupt();
-       irq_exit();
-       set_irq_regs(old_regs);
-}
-
-/*
- * apic_is_clustered_box() -- Check if we can expect good TSC
- *
- * Thus far, the major user of this is IBM's Summit2 series:
- *
- * Clustered boxes may have unsynced TSC problems if they are
- * multi-chassis. Use available data to take a good guess.
- * If in doubt, go HPET.
- */
-__cpuinit int apic_is_clustered_box(void)
-{
-       int i, clusters, zeros;
-       unsigned id;
-       DECLARE_BITMAP(clustermap, NUM_APIC_CLUSTERS);
-
-       bitmap_zero(clustermap, NUM_APIC_CLUSTERS);
-
-       for (i = 0; i < NR_CPUS; i++) {
-               id = bios_cpu_apicid[i];
-               if (id != BAD_APICID)
-                       __set_bit(APIC_CLUSTERID(id), clustermap);
-       }
-
-       /* Problem:  Partially populated chassis may not have CPUs in some of
-        * the APIC clusters they have been allocated.  Only present CPUs have
-        * bios_cpu_apicid entries, thus causing zeroes in the bitmap.  Since
-        * clusters are allocated sequentially, count zeros only if they are
-        * bounded by ones.
-        */
-       clusters = 0;
-       zeros = 0;
-       for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
-               if (test_bit(i, clustermap)) {
-                       clusters += 1 + zeros;
-                       zeros = 0;
-               } else
-                       ++zeros;
-       }
-
-       /*
-        * If clusters > 2, then should be multi-chassis.
-        * May have to revisit this when multi-core + hyperthreaded CPUs come
-        * out, but AFAIK this will work even for them.
-        */
-       return (clusters > 2);
-}
-
-/*
- * This interrupt should _never_ happen with our APIC/SMP architecture
- */
-asmlinkage void smp_spurious_interrupt(void)
-{
-       unsigned int v;
-       exit_idle();
-       irq_enter();
-       /*
-        * Check if this really is a spurious interrupt and ACK it
-        * if it is a vectored one.  Just in case...
-        * Spurious interrupts should not be ACKed.
-        */
-       v = apic_read(APIC_ISR + ((SPURIOUS_APIC_VECTOR & ~0x1f) >> 1));
-       if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
-               ack_APIC_irq();
-
-       irq_exit();
-}
-
-/*
- * This interrupt should never happen with our APIC/SMP architecture
- */
-
-asmlinkage void smp_error_interrupt(void)
-{
-       unsigned int v, v1;
-
-       exit_idle();
-       irq_enter();
-       /* First tickle the hardware, only then report what went on. -- REW */
-       v = apic_read(APIC_ESR);
-       apic_write(APIC_ESR, 0);
-       v1 = apic_read(APIC_ESR);
-       ack_APIC_irq();
-       atomic_inc(&irq_err_count);
-
-       /* Here is what the APIC error bits mean:
-          0: Send CS error
-          1: Receive CS error
-          2: Send accept error
-          3: Receive accept error
-          4: Reserved
-          5: Send illegal vector
-          6: Received illegal vector
-          7: Illegal register address
-       */
-       printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
-               smp_processor_id(), v , v1);
-       irq_exit();
-}
-
-int disable_apic;
-
-/*
- * This initializes the IO-APIC and APIC hardware if this is
- * a UP kernel.
- */
-int __init APIC_init_uniprocessor (void)
-{
-       if (disable_apic) {
-               printk(KERN_INFO "Apic disabled\n");
-               return -1;
-       }
-       if (!cpu_has_apic) {
-               disable_apic = 1;
-               printk(KERN_INFO "Apic disabled by BIOS\n");
-               return -1;
-       }
-
-       verify_local_APIC();
-
-       phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
-       apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
-
-       setup_local_APIC();
-
-       if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
-               setup_IO_APIC();
-       else
-               nr_ioapics = 0;
-       setup_boot_APIC_clock();
-       check_nmi_watchdog();
-       return 0;
-}
-
-static __init int setup_disableapic(char *str)
-{
-       disable_apic = 1;
-       clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
-       return 0;
-}
-early_param("disableapic", setup_disableapic);
-
-/* same as disableapic, for compatibility */
-static __init int setup_nolapic(char *str)
-{
-       return setup_disableapic(str);
-}
-early_param("nolapic", setup_nolapic);
-
-static int __init parse_lapic_timer_c2_ok(char *arg)
-{
-       local_apic_timer_c2_ok = 1;
-       return 0;
-}
-early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
-
-static __init int setup_noapictimer(char *str)
-{
-       if (str[0] != ' ' && str[0] != 0)
-               return 0;
-       disable_apic_timer = 1;
-       return 1;
-}
-
-static __init int setup_apicmaintimer(char *str)
-{
-       apic_runs_main_timer = 1;
-       nohpet = 1;
-       return 1;
-}
-__setup("apicmaintimer", setup_apicmaintimer);
-
-static __init int setup_noapicmaintimer(char *str)
-{
-       apic_runs_main_timer = -1;
-       return 1;
-}
-__setup("noapicmaintimer", setup_noapicmaintimer);
-
-static __init int setup_apicpmtimer(char *s)
-{
-       apic_calibrate_pmtmr = 1;
-       notsc_setup(NULL);
-       return setup_apicmaintimer(NULL);
-}
-__setup("apicpmtimer", setup_apicpmtimer);
-
-__setup("noapictimer", setup_noapictimer);
-
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
deleted file mode 100644 (file)
index 778953b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Generate definitions needed by assembly language modules.
- * This code generates raw asm output which is post-processed to extract
- * and format the required data.
- */
-
-#include <linux/crypto.h>
-#include <linux/sched.h> 
-#include <linux/stddef.h>
-#include <linux/errno.h> 
-#include <linux/hardirq.h>
-#include <linux/suspend.h>
-#include <asm/pda.h>
-#include <asm/processor.h>
-#include <asm/segment.h>
-#include <asm/thread_info.h>
-#include <asm/ia32.h>
-
-#define DEFINE(sym, val) \
-        asm volatile("\n->" #sym " %0 " #val : : "i" (val))
-
-#define BLANK() asm volatile("\n->" : : )
-
-#define __NO_STUBS 1
-#undef __SYSCALL
-#undef _ASM_X86_64_UNISTD_H_
-#define __SYSCALL(nr, sym) [nr] = 1,
-static char syscalls[] = {
-#include <asm/unistd.h>
-};
-
-int main(void)
-{
-#define ENTRY(entry) DEFINE(tsk_ ## entry, offsetof(struct task_struct, entry))
-       ENTRY(state);
-       ENTRY(flags); 
-       ENTRY(thread); 
-       ENTRY(pid);
-       BLANK();
-#undef ENTRY
-#define ENTRY(entry) DEFINE(threadinfo_ ## entry, offsetof(struct thread_info, entry))
-       ENTRY(flags);
-       ENTRY(addr_limit);
-       ENTRY(preempt_count);
-       ENTRY(status);
-       BLANK();
-#undef ENTRY
-#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
-       ENTRY(kernelstack); 
-       ENTRY(oldrsp); 
-       ENTRY(pcurrent); 
-       ENTRY(irqcount);
-       ENTRY(cpunumber);
-       ENTRY(irqstackptr);
-       ENTRY(data_offset);
-       BLANK();
-#undef ENTRY
-#ifdef CONFIG_IA32_EMULATION
-#define ENTRY(entry) DEFINE(IA32_SIGCONTEXT_ ## entry, offsetof(struct sigcontext_ia32, entry))
-       ENTRY(eax);
-       ENTRY(ebx);
-       ENTRY(ecx);
-       ENTRY(edx);
-       ENTRY(esi);
-       ENTRY(edi);
-       ENTRY(ebp);
-       ENTRY(esp);
-       ENTRY(eip);
-       BLANK();
-#undef ENTRY
-       DEFINE(IA32_RT_SIGFRAME_sigcontext,
-              offsetof (struct rt_sigframe32, uc.uc_mcontext));
-       BLANK();
-#endif
-       DEFINE(pbe_address, offsetof(struct pbe, address));
-       DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
-       DEFINE(pbe_next, offsetof(struct pbe, next));
-       BLANK();
-       DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
-       BLANK();
-       DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
-       BLANK();
-       DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
-       return 0;
-}
diff --git a/arch/x86_64/kernel/audit.c b/arch/x86_64/kernel/audit.c
deleted file mode 100644 (file)
index 06d3e5a..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/audit.h>
-#include <asm/unistd.h>
-
-static unsigned dir_class[] = {
-#include <asm-generic/audit_dir_write.h>
-~0U
-};
-
-static unsigned read_class[] = {
-#include <asm-generic/audit_read.h>
-~0U
-};
-
-static unsigned write_class[] = {
-#include <asm-generic/audit_write.h>
-~0U
-};
-
-static unsigned chattr_class[] = {
-#include <asm-generic/audit_change_attr.h>
-~0U
-};
-
-static unsigned signal_class[] = {
-#include <asm-generic/audit_signal.h>
-~0U
-};
-
-int audit_classify_arch(int arch)
-{
-#ifdef CONFIG_IA32_EMULATION
-       if (arch == AUDIT_ARCH_I386)
-               return 1;
-#endif
-       return 0;
-}
-
-int audit_classify_syscall(int abi, unsigned syscall)
-{
-#ifdef CONFIG_IA32_EMULATION
-       extern int ia32_classify_syscall(unsigned);
-       if (abi == AUDIT_ARCH_I386)
-               return ia32_classify_syscall(syscall);
-#endif
-       switch(syscall) {
-       case __NR_open:
-               return 2;
-       case __NR_openat:
-               return 3;
-       case __NR_execve:
-               return 5;
-       default:
-               return 0;
-       }
-}
-
-static int __init audit_classes_init(void)
-{
-#ifdef CONFIG_IA32_EMULATION
-       extern __u32 ia32_dir_class[];
-       extern __u32 ia32_write_class[];
-       extern __u32 ia32_read_class[];
-       extern __u32 ia32_chattr_class[];
-       extern __u32 ia32_signal_class[];
-       audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
-       audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
-       audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
-       audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
-       audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
-#endif
-       audit_register_class(AUDIT_CLASS_WRITE, write_class);
-       audit_register_class(AUDIT_CLASS_READ, read_class);
-       audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
-       audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
-       audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
-       return 0;
-}
-
-__initcall(audit_classes_init);
diff --git a/arch/x86_64/kernel/bugs.c b/arch/x86_64/kernel/bugs.c
deleted file mode 100644 (file)
index 4e5e9d3..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  arch/x86_64/kernel/bugs.c
- *
- *  Copyright (C) 1994  Linus Torvalds
- *  Copyright (C) 2000  SuSE
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/alternative.h>
-#include <asm/bugs.h>
-#include <asm/processor.h>
-#include <asm/mtrr.h>
-
-void __init check_bugs(void)
-{
-       identify_cpu(&boot_cpu_data);
-       mtrr_bp_init();
-#if !defined(CONFIG_SMP)
-       printk("CPU: ");
-       print_cpu_info(&boot_cpu_data);
-#endif
-       alternative_instructions();
-}
diff --git a/arch/x86_64/kernel/cpufreq/Kconfig b/arch/x86_64/kernel/cpufreq/Kconfig
deleted file mode 100644 (file)
index a3fd519..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-#
-# CPU Frequency scaling
-#
-
-menu "CPU Frequency scaling"
-
-source "drivers/cpufreq/Kconfig"
-
-if CPU_FREQ
-
-comment "CPUFreq processor drivers"
-
-config X86_POWERNOW_K8
-       tristate "AMD Opteron/Athlon64 PowerNow!"
-       select CPU_FREQ_TABLE
-       help
-         This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
-
-         To compile this driver as a module, choose M here: the
-         module will be called powernow-k8.
-
-         For details, take a look at <file:Documentation/cpu-freq/>. 
-
-         If in doubt, say N.
-
-config X86_POWERNOW_K8_ACPI
-       bool
-       depends on X86_POWERNOW_K8 && ACPI_PROCESSOR
-       depends on !(X86_POWERNOW_K8 = y && ACPI_PROCESSOR = m)
-       default y
-
-config X86_SPEEDSTEP_CENTRINO
-       tristate "Intel Enhanced SpeedStep (deprecated)"
-       select CPU_FREQ_TABLE
-       depends on ACPI_PROCESSOR
-       help
-         This is deprecated and this functionality is now merged into
-         acpi_cpufreq (X86_ACPI_CPUFREQ). Use that driver instead of
-         speedstep_centrino.
-         This adds the CPUFreq driver for Enhanced SpeedStep enabled
-         mobile CPUs.  This means Intel Pentium M (Centrino) CPUs
-         or 64bit enabled Intel Xeons.
-
-         To compile this driver as a module, choose M here: the
-         module will be called speedstep-centrino.
-
-         For details, take a look at <file:Documentation/cpu-freq/>.
-
-         If in doubt, say N.
-
-config X86_ACPI_CPUFREQ
-       tristate "ACPI Processor P-States driver"
-       select CPU_FREQ_TABLE
-       depends on ACPI_PROCESSOR
-       help
-         This driver adds a CPUFreq driver which utilizes the ACPI
-         Processor Performance States.
-         This driver also supports Intel Enhanced Speedstep.
-
-         To compile this driver as a module, choose M here: the
-         module will be called acpi-cpufreq.
-
-         For details, take a look at <file:Documentation/cpu-freq/>.
-
-         If in doubt, say N.
-
-comment "shared options"
-
-config X86_ACPI_CPUFREQ_PROC_INTF
-       bool "/proc/acpi/processor/../performance interface (deprecated)"
-       depends on PROC_FS
-       depends on X86_ACPI_CPUFREQ || X86_POWERNOW_K8_ACPI
-       help
-         This enables the deprecated /proc/acpi/processor/../performance
-         interface. While it is helpful for debugging, the generic,
-         cross-architecture cpufreq interfaces should be used.
-
-         If in doubt, say N.
-
-config X86_P4_CLOCKMOD
-       tristate "Intel Pentium 4 clock modulation"
-       depends on EMBEDDED
-       select CPU_FREQ_TABLE
-       help
-         This adds the clock modulation driver for Intel Pentium 4 / XEON
-         processors.  When enabled it will lower CPU temperature by skipping
-         clocks.
-
-         This driver should be only used in exceptional
-         circumstances when very low power is needed because it causes severe
-         slowdowns and noticeable latencies.  Normally Speedstep should be used
-         instead.
-
-         To compile this driver as a module, choose M here: the
-         module will be called p4-clockmod.
-
-         For details, take a look at <file:Documentation/cpu-freq/>.
-
-         Unless you are absolutely sure say N.
-
-
-config X86_SPEEDSTEP_LIB
-       tristate
-       default X86_P4_CLOCKMOD
-
-endif
-
-endmenu
diff --git a/arch/x86_64/kernel/cpufreq/Makefile b/arch/x86_64/kernel/cpufreq/Makefile
deleted file mode 100644 (file)
index 753ce1d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Reuse the i386 cpufreq drivers
-#
-
-SRCDIR := ../../../i386/kernel/cpu/cpufreq
-
-obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
-obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
-obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
-obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
-obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
-
-powernow-k8-objs := ${SRCDIR}/powernow-k8.o
-speedstep-centrino-objs := ${SRCDIR}/speedstep-centrino.o
-acpi-cpufreq-objs := ${SRCDIR}/acpi-cpufreq.o
-p4-clockmod-objs := ${SRCDIR}/p4-clockmod.o
-speedstep-lib-objs := ${SRCDIR}/speedstep-lib.o
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
deleted file mode 100644 (file)
index 13432a1..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Architecture specific (x86_64) functions for kexec based crash dumps.
- *
- * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
- *
- * Copyright (C) IBM Corporation, 2004. All rights reserved.
- *
- */
-
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/smp.h>
-#include <linux/irq.h>
-#include <linux/reboot.h>
-#include <linux/kexec.h>
-#include <linux/delay.h>
-#include <linux/elf.h>
-#include <linux/elfcore.h>
-#include <linux/kdebug.h>
-
-#include <asm/processor.h>
-#include <asm/hardirq.h>
-#include <asm/nmi.h>
-#include <asm/hw_irq.h>
-#include <asm/mach_apic.h>
-
-/* This keeps a track of which one is crashing cpu. */
-static int crashing_cpu;
-
-#ifdef CONFIG_SMP
-static atomic_t waiting_for_crash_ipi;
-
-static int crash_nmi_callback(struct notifier_block *self,
-                               unsigned long val, void *data)
-{
-       struct pt_regs *regs;
-       int cpu;
-
-       if (val != DIE_NMI_IPI)
-               return NOTIFY_OK;
-
-       regs = ((struct die_args *)data)->regs;
-       cpu = raw_smp_processor_id();
-
-       /*
-        * Don't do anything if this handler is invoked on crashing cpu.
-        * Otherwise, system will completely hang. Crashing cpu can get
-        * an NMI if system was initially booted with nmi_watchdog parameter.
-        */
-       if (cpu == crashing_cpu)
-               return NOTIFY_STOP;
-       local_irq_disable();
-
-       crash_save_cpu(regs, cpu);
-       disable_local_APIC();
-       atomic_dec(&waiting_for_crash_ipi);
-       /* Assume hlt works */
-       for(;;)
-               halt();
-
-       return 1;
-}
-
-static void smp_send_nmi_allbutself(void)
-{
-       send_IPI_allbutself(NMI_VECTOR);
-}
-
-/*
- * This code is a best effort heuristic to get the
- * other cpus to stop executing. So races with
- * cpu hotplug shouldn't matter.
- */
-
-static struct notifier_block crash_nmi_nb = {
-       .notifier_call = crash_nmi_callback,
-};
-
-static void nmi_shootdown_cpus(void)
-{
-       unsigned long msecs;
-
-       atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
-       if (register_die_notifier(&crash_nmi_nb))
-               return;         /* return what? */
-
-       /*
-        * Ensure the new callback function is set before sending
-        * out the NMI
-        */
-       wmb();
-
-       smp_send_nmi_allbutself();
-
-       msecs = 1000; /* Wait at most a second for the other cpus to stop */
-       while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
-               mdelay(1);
-               msecs--;
-       }
-       /* Leave the nmi callback set */
-       disable_local_APIC();
-}
-#else
-static void nmi_shootdown_cpus(void)
-{
-       /* There are no cpus to shootdown */
-}
-#endif
-
-void machine_crash_shutdown(struct pt_regs *regs)
-{
-       /*
-        * This function is only called after the system
-        * has panicked or is otherwise in a critical state.
-        * The minimum amount of code to allow a kexec'd kernel
-        * to run successfully needs to happen here.
-        *
-        * In practice this means shooting down the other cpus in
-        * an SMP system.
-        */
-       /* The kernel is broken so disable interrupts */
-       local_irq_disable();
-
-       /* Make a note of crashing cpu. Will be used in NMI callback.*/
-       crashing_cpu = smp_processor_id();
-       nmi_shootdown_cpus();
-
-       if(cpu_has_apic)
-                disable_local_APIC();
-
-       disable_IO_APIC();
-
-       crash_save_cpu(regs, smp_processor_id());
-}
diff --git a/arch/x86_64/kernel/crash_dump.c b/arch/x86_64/kernel/crash_dump.c
deleted file mode 100644 (file)
index 942deac..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *     kernel/crash_dump.c - Memory preserving reboot related code.
- *
- *     Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
- *     Copyright (C) IBM Corporation, 2004. All rights reserved
- */
-
-#include <linux/errno.h>
-#include <linux/crash_dump.h>
-
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-/**
- * copy_oldmem_page - copy one page from "oldmem"
- * @pfn: page frame number to be copied
- * @buf: target memory address for the copy; this can be in kernel address
- *     space or user address space (see @userbuf)
- * @csize: number of bytes to copy
- * @offset: offset in bytes into the page (based on pfn) to begin the copy
- * @userbuf: if set, @buf is in user address space, use copy_to_user(),
- *     otherwise @buf is in kernel address space, use memcpy().
- *
- * Copy a page from "oldmem". For this page, there is no pte mapped
- * in the current kernel. We stitch up a pte, similar to kmap_atomic.
- */
-ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
-                               size_t csize, unsigned long offset, int userbuf)
-{
-       void  *vaddr;
-
-       if (!csize)
-               return 0;
-
-       vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
-
-       if (userbuf) {
-               if (copy_to_user(buf, (vaddr + offset), csize)) {
-                       iounmap(vaddr);
-                       return -EFAULT;
-               }
-       } else
-       memcpy(buf, (vaddr + offset), csize);
-
-       iounmap(vaddr);
-       return csize;
-}
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
deleted file mode 100644 (file)
index 0f4d5e2..0000000
+++ /dev/null
@@ -1,725 +0,0 @@
-/* 
- * Handle the memory map.
- * The functions here do the job until bootmem takes over.
- *
- *  Getting sanitize_e820_map() in sync with i386 version by applying change:
- *  -  Provisions for empty E820 memory regions (reported by certain BIOSes).
- *     Alex Achenbach <xela@slit.de>, December 2002.
- *  Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/bootmem.h>
-#include <linux/ioport.h>
-#include <linux/string.h>
-#include <linux/kexec.h>
-#include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/suspend.h>
-#include <linux/pfn.h>
-
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/e820.h>
-#include <asm/proto.h>
-#include <asm/bootsetup.h>
-#include <asm/sections.h>
-
-struct e820map e820;
-
-/* 
- * PFN of last memory page.
- */
-unsigned long end_pfn; 
-EXPORT_SYMBOL(end_pfn);
-
-/* 
- * end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
- * The direct mapping extends to end_pfn_map, so that we can directly access
- * apertures, ACPI and other tables without having to play with fixmaps.
- */ 
-unsigned long end_pfn_map; 
-
-/* 
- * Last pfn which the user wants to use.
- */
-static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT;
-
-extern struct resource code_resource, data_resource;
-
-/* Check for some hardcoded bad areas that early boot is not allowed to touch */ 
-static inline int bad_addr(unsigned long *addrp, unsigned long size)
-{ 
-       unsigned long addr = *addrp, last = addr + size; 
-
-       /* various gunk below that needed for SMP startup */
-       if (addr < 0x8000) { 
-               *addrp = PAGE_ALIGN(0x8000);
-               return 1; 
-       }
-
-       /* direct mapping tables of the kernel */
-       if (last >= table_start<<PAGE_SHIFT && addr < table_end<<PAGE_SHIFT) { 
-               *addrp = PAGE_ALIGN(table_end << PAGE_SHIFT);
-               return 1;
-       } 
-
-       /* initrd */ 
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (LOADER_TYPE && INITRD_START && last >= INITRD_START && 
-           addr < INITRD_START+INITRD_SIZE) { 
-               *addrp = PAGE_ALIGN(INITRD_START + INITRD_SIZE);
-               return 1;
-       } 
-#endif
-       /* kernel code */
-       if (last >= __pa_symbol(&_text) && addr < __pa_symbol(&_end)) {
-               *addrp = PAGE_ALIGN(__pa_symbol(&_end));
-               return 1;
-       }
-
-       if (last >= ebda_addr && addr < ebda_addr + ebda_size) {
-               *addrp = PAGE_ALIGN(ebda_addr + ebda_size);
-               return 1;
-       }
-
-#ifdef CONFIG_NUMA
-       /* NUMA memory to node map */
-       if (last >= nodemap_addr && addr < nodemap_addr + nodemap_size) {
-               *addrp = nodemap_addr + nodemap_size;
-               return 1;
-       }
-#endif
-       /* XXX ramdisk image here? */ 
-       return 0;
-} 
-
-/*
- * This function checks if any part of the range <start,end> is mapped
- * with type.
- */
-int
-e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
-{ 
-       int i;
-       for (i = 0; i < e820.nr_map; i++) { 
-               struct e820entry *ei = &e820.map[i]; 
-               if (type && ei->type != type) 
-                       continue;
-               if (ei->addr >= end || ei->addr + ei->size <= start)
-                       continue; 
-               return 1; 
-       } 
-       return 0;
-}
-EXPORT_SYMBOL_GPL(e820_any_mapped);
-
-/*
- * This function checks if the entire range <start,end> is mapped with type.
- *
- * Note: this function only works correct if the e820 table is sorted and
- * not-overlapping, which is the case
- */
-int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
-{
-       int i;
-       for (i = 0; i < e820.nr_map; i++) {
-               struct e820entry *ei = &e820.map[i];
-               if (type && ei->type != type)
-                       continue;
-               /* is the region (part) in overlap with the current region ?*/
-               if (ei->addr >= end || ei->addr + ei->size <= start)
-                       continue;
-
-               /* if the region is at the beginning of <start,end> we move
-                * start to the end of the region since it's ok until there
-                */
-               if (ei->addr <= start)
-                       start = ei->addr + ei->size;
-               /* if start is now at or beyond end, we're done, full coverage */
-               if (start >= end)
-                       return 1; /* we're done */
-       }
-       return 0;
-}
-
-/* 
- * Find a free area in a specific range. 
- */ 
-unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsigned size) 
-{ 
-       int i; 
-       for (i = 0; i < e820.nr_map; i++) { 
-               struct e820entry *ei = &e820.map[i]; 
-               unsigned long addr = ei->addr, last; 
-               if (ei->type != E820_RAM) 
-                       continue; 
-               if (addr < start) 
-                       addr = start;
-               if (addr > ei->addr + ei->size) 
-                       continue; 
-               while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size)
-                       ;
-               last = PAGE_ALIGN(addr) + size;
-               if (last > ei->addr + ei->size)
-                       continue;
-               if (last > end) 
-                       continue;
-               return addr; 
-       } 
-       return -1UL;            
-} 
-
-/*
- * Find the highest page frame number we have available
- */
-unsigned long __init e820_end_of_ram(void)
-{
-       unsigned long end_pfn = 0;
-       end_pfn = find_max_pfn_with_active_regions();
-       
-       if (end_pfn > end_pfn_map) 
-               end_pfn_map = end_pfn;
-       if (end_pfn_map > MAXMEM>>PAGE_SHIFT)
-               end_pfn_map = MAXMEM>>PAGE_SHIFT;
-       if (end_pfn > end_user_pfn)
-               end_pfn = end_user_pfn;
-       if (end_pfn > end_pfn_map) 
-               end_pfn = end_pfn_map; 
-
-       printk("end_pfn_map = %lu\n", end_pfn_map);
-       return end_pfn; 
-}
-
-/*
- * Mark e820 reserved areas as busy for the resource manager.
- */
-void __init e820_reserve_resources(void)
-{
-       int i;
-       for (i = 0; i < e820.nr_map; i++) {
-               struct resource *res;
-               res = alloc_bootmem_low(sizeof(struct resource));
-               switch (e820.map[i].type) {
-               case E820_RAM:  res->name = "System RAM"; break;
-               case E820_ACPI: res->name = "ACPI Tables"; break;
-               case E820_NVS:  res->name = "ACPI Non-volatile Storage"; break;
-               default:        res->name = "reserved";
-               }
-               res->start = e820.map[i].addr;
-               res->end = res->start + e820.map[i].size - 1;
-               res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-               request_resource(&iomem_resource, res);
-               if (e820.map[i].type == E820_RAM) {
-                       /*
-                        *  We don't know which RAM region contains kernel data,
-                        *  so we try it repeatedly and let the resource manager
-                        *  test it.
-                        */
-                       request_resource(res, &code_resource);
-                       request_resource(res, &data_resource);
-#ifdef CONFIG_KEXEC
-                       request_resource(res, &crashk_res);
-#endif
-               }
-       }
-}
-
-/*
- * Find the ranges of physical addresses that do not correspond to
- * e820 RAM areas and mark the corresponding pages as nosave for software
- * suspend and suspend to RAM.
- *
- * This function requires the e820 map to be sorted and without any
- * overlapping entries and assumes the first e820 area to be RAM.
- */
-void __init e820_mark_nosave_regions(void)
-{
-       int i;
-       unsigned long paddr;
-
-       paddr = round_down(e820.map[0].addr + e820.map[0].size, PAGE_SIZE);
-       for (i = 1; i < e820.nr_map; i++) {
-               struct e820entry *ei = &e820.map[i];
-
-               if (paddr < ei->addr)
-                       register_nosave_region(PFN_DOWN(paddr),
-                                               PFN_UP(ei->addr));
-
-               paddr = round_down(ei->addr + ei->size, PAGE_SIZE);
-               if (ei->type != E820_RAM)
-                       register_nosave_region(PFN_UP(ei->addr),
-                                               PFN_DOWN(paddr));
-
-               if (paddr >= (end_pfn << PAGE_SHIFT))
-                       break;
-       }
-}
-
-/*
- * Finds an active region in the address range from start_pfn to end_pfn and
- * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
- */
-static int __init e820_find_active_region(const struct e820entry *ei,
-                                         unsigned long start_pfn,
-                                         unsigned long end_pfn,
-                                         unsigned long *ei_startpfn,
-                                         unsigned long *ei_endpfn)
-{
-       *ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
-       *ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE) >> PAGE_SHIFT;
-
-       /* Skip map entries smaller than a page */
-       if (*ei_startpfn >= *ei_endpfn)
-               return 0;
-
-       /* Check if end_pfn_map should be updated */
-       if (ei->type != E820_RAM && *ei_endpfn > end_pfn_map)
-               end_pfn_map = *ei_endpfn;
-
-       /* Skip if map is outside the node */
-       if (ei->type != E820_RAM || *ei_endpfn <= start_pfn ||
-                                   *ei_startpfn >= end_pfn)
-               return 0;
-
-       /* Check for overlaps */
-       if (*ei_startpfn < start_pfn)
-               *ei_startpfn = start_pfn;
-       if (*ei_endpfn > end_pfn)
-               *ei_endpfn = end_pfn;
-
-       /* Obey end_user_pfn to save on memmap */
-       if (*ei_startpfn >= end_user_pfn)
-               return 0;
-       if (*ei_endpfn > end_user_pfn)
-               *ei_endpfn = end_user_pfn;
-
-       return 1;
-}
-
-/* Walk the e820 map and register active regions within a node */
-void __init
-e820_register_active_regions(int nid, unsigned long start_pfn,
-                                                       unsigned long end_pfn)
-{
-       unsigned long ei_startpfn;
-       unsigned long ei_endpfn;
-       int i;
-
-       for (i = 0; i < e820.nr_map; i++)
-               if (e820_find_active_region(&e820.map[i],
-                                           start_pfn, end_pfn,
-                                           &ei_startpfn, &ei_endpfn))
-                       add_active_range(nid, ei_startpfn, ei_endpfn);
-}
-
-/* 
- * Add a memory region to the kernel e820 map.
- */ 
-void __init add_memory_region(unsigned long start, unsigned long size, int type)
-{
-       int x = e820.nr_map;
-
-       if (x == E820MAX) {
-               printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
-               return;
-       }
-
-       e820.map[x].addr = start;
-       e820.map[x].size = size;
-       e820.map[x].type = type;
-       e820.nr_map++;
-}
-
-/*
- * Find the hole size (in bytes) in the memory range.
- * @start: starting address of the memory range to scan
- * @end: ending address of the memory range to scan
- */
-unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
-{
-       unsigned long start_pfn = start >> PAGE_SHIFT;
-       unsigned long end_pfn = end >> PAGE_SHIFT;
-       unsigned long ei_startpfn;
-       unsigned long ei_endpfn;
-       unsigned long ram = 0;
-       int i;
-
-       for (i = 0; i < e820.nr_map; i++) {
-               if (e820_find_active_region(&e820.map[i],
-                                           start_pfn, end_pfn,
-                                           &ei_startpfn, &ei_endpfn))
-                       ram += ei_endpfn - ei_startpfn;
-       }
-       return end - start - (ram << PAGE_SHIFT);
-}
-
-void __init e820_print_map(char *who)
-{
-       int i;
-
-       for (i = 0; i < e820.nr_map; i++) {
-               printk(KERN_INFO " %s: %016Lx - %016Lx ", who,
-                       (unsigned long long) e820.map[i].addr,
-                       (unsigned long long) (e820.map[i].addr + e820.map[i].size));
-               switch (e820.map[i].type) {
-               case E820_RAM:  printk("(usable)\n");
-                               break;
-               case E820_RESERVED:
-                               printk("(reserved)\n");
-                               break;
-               case E820_ACPI:
-                               printk("(ACPI data)\n");
-                               break;
-               case E820_NVS:
-                               printk("(ACPI NVS)\n");
-                               break;
-               default:        printk("type %u\n", e820.map[i].type);
-                               break;
-               }
-       }
-}
-
-/*
- * Sanitize the BIOS e820 map.
- *
- * Some e820 responses include overlapping entries.  The following 
- * replaces the original e820 map with a new one, removing overlaps.
- *
- */
-static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
-{
-       struct change_member {
-               struct e820entry *pbios; /* pointer to original bios entry */
-               unsigned long long addr; /* address for this change point */
-       };
-       static struct change_member change_point_list[2*E820MAX] __initdata;
-       static struct change_member *change_point[2*E820MAX] __initdata;
-       static struct e820entry *overlap_list[E820MAX] __initdata;
-       static struct e820entry new_bios[E820MAX] __initdata;
-       struct change_member *change_tmp;
-       unsigned long current_type, last_type;
-       unsigned long long last_addr;
-       int chgidx, still_changing;
-       int overlap_entries;
-       int new_bios_entry;
-       int old_nr, new_nr, chg_nr;
-       int i;
-
-       /*
-               Visually we're performing the following (1,2,3,4 = memory types)...
-
-               Sample memory map (w/overlaps):
-                  ____22__________________
-                  ______________________4_
-                  ____1111________________
-                  _44_____________________
-                  11111111________________
-                  ____________________33__
-                  ___________44___________
-                  __________33333_________
-                  ______________22________
-                  ___________________2222_
-                  _________111111111______
-                  _____________________11_
-                  _________________4______
-
-               Sanitized equivalent (no overlap):
-                  1_______________________
-                  _44_____________________
-                  ___1____________________
-                  ____22__________________
-                  ______11________________
-                  _________1______________
-                  __________3_____________
-                  ___________44___________
-                  _____________33_________
-                  _______________2________
-                  ________________1_______
-                  _________________4______
-                  ___________________2____
-                  ____________________33__
-                  ______________________4_
-       */
-
-       /* if there's only one memory region, don't bother */
-       if (*pnr_map < 2)
-               return -1;
-
-       old_nr = *pnr_map;
-
-       /* bail out if we find any unreasonable addresses in bios map */
-       for (i=0; i<old_nr; i++)
-               if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
-                       return -1;
-
-       /* create pointers for initial change-point information (for sorting) */
-       for (i=0; i < 2*old_nr; i++)
-               change_point[i] = &change_point_list[i];
-
-       /* record all known change-points (starting and ending addresses),
-          omitting those that are for empty memory regions */
-       chgidx = 0;
-       for (i=0; i < old_nr; i++)      {
-               if (biosmap[i].size != 0) {
-                       change_point[chgidx]->addr = biosmap[i].addr;
-                       change_point[chgidx++]->pbios = &biosmap[i];
-                       change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
-                       change_point[chgidx++]->pbios = &biosmap[i];
-               }
-       }
-       chg_nr = chgidx;
-
-       /* sort change-point list by memory addresses (low -> high) */
-       still_changing = 1;
-       while (still_changing)  {
-               still_changing = 0;
-               for (i=1; i < chg_nr; i++)  {
-                       /* if <current_addr> > <last_addr>, swap */
-                       /* or, if current=<start_addr> & last=<end_addr>, swap */
-                       if ((change_point[i]->addr < change_point[i-1]->addr) ||
-                               ((change_point[i]->addr == change_point[i-1]->addr) &&
-                                (change_point[i]->addr == change_point[i]->pbios->addr) &&
-                                (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
-                          )
-                       {
-                               change_tmp = change_point[i];
-                               change_point[i] = change_point[i-1];
-                               change_point[i-1] = change_tmp;
-                               still_changing=1;
-                       }
-               }
-       }
-
-       /* create a new bios memory map, removing overlaps */
-       overlap_entries=0;       /* number of entries in the overlap table */
-       new_bios_entry=0;        /* index for creating new bios map entries */
-       last_type = 0;           /* start with undefined memory type */
-       last_addr = 0;           /* start with 0 as last starting address */
-       /* loop through change-points, determining affect on the new bios map */
-       for (chgidx=0; chgidx < chg_nr; chgidx++)
-       {
-               /* keep track of all overlapping bios entries */
-               if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
-               {
-                       /* add map entry to overlap list (> 1 entry implies an overlap) */
-                       overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
-               }
-               else
-               {
-                       /* remove entry from list (order independent, so swap with last) */
-                       for (i=0; i<overlap_entries; i++)
-                       {
-                               if (overlap_list[i] == change_point[chgidx]->pbios)
-                                       overlap_list[i] = overlap_list[overlap_entries-1];
-                       }
-                       overlap_entries--;
-               }
-               /* if there are overlapping entries, decide which "type" to use */
-               /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
-               current_type = 0;
-               for (i=0; i<overlap_entries; i++)
-                       if (overlap_list[i]->type > current_type)
-                               current_type = overlap_list[i]->type;
-               /* continue building up new bios map based on this information */
-               if (current_type != last_type)  {
-                       if (last_type != 0)      {
-                               new_bios[new_bios_entry].size =
-                                       change_point[chgidx]->addr - last_addr;
-                               /* move forward only if the new size was non-zero */
-                               if (new_bios[new_bios_entry].size != 0)
-                                       if (++new_bios_entry >= E820MAX)
-                                               break;  /* no more space left for new bios entries */
-                       }
-                       if (current_type != 0)  {
-                               new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
-                               new_bios[new_bios_entry].type = current_type;
-                               last_addr=change_point[chgidx]->addr;
-                       }
-                       last_type = current_type;
-               }
-       }
-       new_nr = new_bios_entry;   /* retain count for new bios entries */
-
-       /* copy new bios mapping into original location */
-       memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
-       *pnr_map = new_nr;
-
-       return 0;
-}
-
-/*
- * Copy the BIOS e820 map into a safe place.
- *
- * Sanity-check it while we're at it..
- *
- * If we're lucky and live on a modern system, the setup code
- * will have given us a memory map that we can use to properly
- * set up memory.  If we aren't, we'll fake a memory map.
- */
-static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
-{
-       /* Only one memory region (or negative)? Ignore it */
-       if (nr_map < 2)
-               return -1;
-
-       do {
-               unsigned long start = biosmap->addr;
-               unsigned long size = biosmap->size;
-               unsigned long end = start + size;
-               unsigned long type = biosmap->type;
-
-               /* Overflow in 64 bits? Ignore the memory map. */
-               if (start > end)
-                       return -1;
-
-               add_memory_region(start, size, type);
-       } while (biosmap++,--nr_map);
-       return 0;
-}
-
-void early_panic(char *msg)
-{
-       early_printk(msg);
-       panic(msg);
-}
-
-void __init setup_memory_region(void)
-{
-       /*
-        * Try to copy the BIOS-supplied E820-map.
-        *
-        * Otherwise fake a memory map; one section from 0k->640k,
-        * the next section from 1mb->appropriate_mem_k
-        */
-       sanitize_e820_map(E820_MAP, &E820_MAP_NR);
-       if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0)
-               early_panic("Cannot find a valid memory map");
-       printk(KERN_INFO "BIOS-provided physical RAM map:\n");
-       e820_print_map("BIOS-e820");
-}
-
-static int __init parse_memopt(char *p)
-{
-       if (!p)
-               return -EINVAL;
-       end_user_pfn = memparse(p, &p);
-       end_user_pfn >>= PAGE_SHIFT;    
-       return 0;
-} 
-early_param("mem", parse_memopt);
-
-static int userdef __initdata;
-
-static int __init parse_memmap_opt(char *p)
-{
-       char *oldp;
-       unsigned long long start_at, mem_size;
-
-       if (!strcmp(p, "exactmap")) {
-#ifdef CONFIG_CRASH_DUMP
-               /* If we are doing a crash dump, we
-                * still need to know the real mem
-                * size before original memory map is
-                * reset.
-                */
-               e820_register_active_regions(0, 0, -1UL);
-               saved_max_pfn = e820_end_of_ram();
-               remove_all_active_ranges();
-#endif
-               end_pfn_map = 0;
-               e820.nr_map = 0;
-               userdef = 1;
-               return 0;
-       }
-
-       oldp = p;
-       mem_size = memparse(p, &p);
-       if (p == oldp)
-               return -EINVAL;
-       if (*p == '@') {
-               start_at = memparse(p+1, &p);
-               add_memory_region(start_at, mem_size, E820_RAM);
-       } else if (*p == '#') {
-               start_at = memparse(p+1, &p);
-               add_memory_region(start_at, mem_size, E820_ACPI);
-       } else if (*p == '$') {
-               start_at = memparse(p+1, &p);
-               add_memory_region(start_at, mem_size, E820_RESERVED);
-       } else {
-               end_user_pfn = (mem_size >> PAGE_SHIFT);
-       }
-       return *p == '\0' ? 0 : -EINVAL;
-}
-early_param("memmap", parse_memmap_opt);
-
-void __init finish_e820_parsing(void)
-{
-       if (userdef) {
-               printk(KERN_INFO "user-defined physical RAM map:\n");
-               e820_print_map("user");
-       }
-}
-
-unsigned long pci_mem_start = 0xaeedbabe;
-EXPORT_SYMBOL(pci_mem_start);
-
-/*
- * Search for the biggest gap in the low 32 bits of the e820
- * memory space.  We pass this space to PCI to assign MMIO resources
- * for hotplug or unconfigured devices in.
- * Hopefully the BIOS let enough space left.
- */
-__init void e820_setup_gap(void)
-{
-       unsigned long gapstart, gapsize, round;
-       unsigned long last;
-       int i;
-       int found = 0;
-
-       last = 0x100000000ull;
-       gapstart = 0x10000000;
-       gapsize = 0x400000;
-       i = e820.nr_map;
-       while (--i >= 0) {
-               unsigned long long start = e820.map[i].addr;
-               unsigned long long end = start + e820.map[i].size;
-
-               /*
-                * Since "last" is at most 4GB, we know we'll
-                * fit in 32 bits if this condition is true
-                */
-               if (last > end) {
-                       unsigned long gap = last - end;
-
-                       if (gap > gapsize) {
-                               gapsize = gap;
-                               gapstart = end;
-                               found = 1;
-                       }
-               }
-               if (start < last)
-                       last = start;
-       }
-
-       if (!found) {
-               gapstart = (end_pfn << PAGE_SHIFT) + 1024*1024;
-               printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
-                      KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
-       }
-
-       /*
-        * See how much we want to round up: start off with
-        * rounding to the next 1MB area.
-        */
-       round = 0x100000;
-       while ((gapsize >> 4) > round)
-               round += round;
-       /* Fun with two's complement */
-       pci_mem_start = (gapstart + round) & -round;
-
-       printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
-               pci_mem_start, gapstart, gapsize);
-}
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
deleted file mode 100644 (file)
index 13aa4fd..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Various workarounds for chipset bugs.
-   This code runs very early and can't use the regular PCI subsystem
-   The entries are keyed to PCI bridges which usually identify chipsets
-   uniquely.
-   This is only for whole classes of chipsets with specific problems which
-   need early invasive action (e.g. before the timers are initialized).
-   Most PCI device specific workarounds can be done later and should be
-   in standard PCI quirks
-   Mainboard specific bugs should be handled by DMI entries.
-   CPU specific bugs in setup.c */
-
-#include <linux/pci.h>
-#include <linux/acpi.h>
-#include <linux/pci_ids.h>
-#include <asm/pci-direct.h>
-#include <asm/proto.h>
-#include <asm/iommu.h>
-#include <asm/dma.h>
-
-static void __init via_bugs(void)
-{
-#ifdef CONFIG_IOMMU
-       if ((end_pfn > MAX_DMA32_PFN ||  force_iommu) &&
-           !iommu_aperture_allowed) {
-               printk(KERN_INFO
-  "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n");
-               iommu_aperture_disabled = 1;
-       }
-#endif
-}
-
-#ifdef CONFIG_ACPI
-
-static int __init nvidia_hpet_check(struct acpi_table_header *header)
-{
-       return 0;
-}
-#endif
-
-static void __init nvidia_bugs(void)
-{
-#ifdef CONFIG_ACPI
-       /*
-        * All timer overrides on Nvidia are
-        * wrong unless HPET is enabled.
-        * Unfortunately that's not true on many Asus boards.
-        * We don't know yet how to detect this automatically, but
-        * at least allow a command line override.
-        */
-       if (acpi_use_timer_override)
-               return;
-
-       if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) {
-               acpi_skip_timer_override = 1;
-               printk(KERN_INFO "Nvidia board "
-                      "detected. Ignoring ACPI "
-                      "timer override.\n");
-               printk(KERN_INFO "If you got timer trouble "
-                       "try acpi_use_timer_override\n");
-       }
-#endif
-       /* RED-PEN skip them on mptables too? */
-
-}
-
-static void __init ati_bugs(void)
-{
-       if (timer_over_8254 == 1) {
-               timer_over_8254 = 0;
-               printk(KERN_INFO
-               "ATI board detected. Disabling timer routing over 8254.\n");
-       }
-}
-
-struct chipset {
-       u16 vendor;
-       void (*f)(void);
-};
-
-static struct chipset early_qrk[] __initdata = {
-       { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
-       { PCI_VENDOR_ID_VIA, via_bugs },
-       { PCI_VENDOR_ID_ATI, ati_bugs },
-       {}
-};
-
-void __init early_quirks(void)
-{
-       int num, slot, func;
-
-       if (!early_pci_allowed())
-               return;
-
-       /* Poor man's PCI discovery */
-       for (num = 0; num < 32; num++) {
-               for (slot = 0; slot < 32; slot++) {
-                       for (func = 0; func < 8; func++) {
-                               u32 class;
-                               u32 vendor;
-                               u8 type;
-                               int i;
-                               class = read_pci_config(num,slot,func,
-                                                       PCI_CLASS_REVISION);
-                               if (class == 0xffffffff)
-                                       break;
-
-                               if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
-                                       continue;
-
-                               vendor = read_pci_config(num, slot, func,
-                                                        PCI_VENDOR_ID);
-                               vendor &= 0xffff;
-
-                               for (i = 0; early_qrk[i].f; i++)
-                                       if (early_qrk[i].vendor == vendor) {
-                                               early_qrk[i].f();
-                                               return;
-                                       }
-
-                               type = read_pci_config_byte(num, slot, func,
-                                                           PCI_HEADER_TYPE);
-                               if (!(type & 0x80))
-                                       break;
-                       }
-               }
-       }
-}
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
deleted file mode 100644 (file)
index fd9aff3..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-#include <linux/console.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/screen_info.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/fcntl.h>
-#include <xen/hvc-console.h>
-
-/* Simple VGA output */
-
-#ifdef __i386__
-#include <asm/setup.h>
-#else
-#include <asm/bootsetup.h>
-#endif
-#define VGABASE                (__ISA_IO_base + 0xb8000)
-
-static int max_ypos = 25, max_xpos = 80;
-static int current_ypos = 25, current_xpos = 0;
-
-static void early_vga_write(struct console *con, const char *str, unsigned n)
-{
-       char c;
-       int  i, k, j;
-
-       while ((c = *str++) != '\0' && n-- > 0) {
-               if (current_ypos >= max_ypos) {
-                       /* scroll 1 line up */
-                       for (k = 1, j = 0; k < max_ypos; k++, j++) {
-                               for (i = 0; i < max_xpos; i++) {
-                                       writew(readw(VGABASE+2*(max_xpos*k+i)),
-                                              VGABASE + 2*(max_xpos*j + i));
-                               }
-                       }
-                       for (i = 0; i < max_xpos; i++)
-                               writew(0x720, VGABASE + 2*(max_xpos*j + i));
-                       current_ypos = max_ypos-1;
-               }
-               if (c == '\n') {
-                       current_xpos = 0;
-                       current_ypos++;
-               } else if (c != '\r')  {
-                       writew(((0x7 << 8) | (unsigned short) c),
-                              VGABASE + 2*(max_xpos*current_ypos +
-                                               current_xpos++));
-                       if (current_xpos >= max_xpos) {
-                               current_xpos = 0;
-                               current_ypos++;
-                       }
-               }
-       }
-}
-
-static struct console early_vga_console = {
-       .name =         "earlyvga",
-       .write =        early_vga_write,
-       .flags =        CON_PRINTBUFFER,
-       .index =        -1,
-};
-
-/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
-
-static int early_serial_base = 0x3f8;  /* ttyS0 */
-
-#define XMTRDY          0x20
-
-#define DLAB           0x80
-
-#define TXR             0       /*  Transmit register (WRITE) */
-#define RXR             0       /*  Receive register  (READ)  */
-#define IER             1       /*  Interrupt Enable          */
-#define IIR             2       /*  Interrupt ID              */
-#define FCR             2       /*  FIFO control              */
-#define LCR             3       /*  Line control              */
-#define MCR             4       /*  Modem control             */
-#define LSR             5       /*  Line Status               */
-#define MSR             6       /*  Modem Status              */
-#define DLL             0       /*  Divisor Latch Low         */
-#define DLH             1       /*  Divisor latch High        */
-
-static int early_serial_putc(unsigned char ch)
-{
-       unsigned timeout = 0xffff;
-       while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
-               cpu_relax();
-       outb(ch, early_serial_base + TXR);
-       return timeout ? 0 : -1;
-}
-
-static void early_serial_write(struct console *con, const char *s, unsigned n)
-{
-       while (*s && n-- > 0) {
-               if (*s == '\n')
-                       early_serial_putc('\r');
-               early_serial_putc(*s);
-               s++;
-       }
-}
-
-#define DEFAULT_BAUD 9600
-
-static __init void early_serial_init(char *s)
-{
-       unsigned char c;
-       unsigned divisor;
-       unsigned baud = DEFAULT_BAUD;
-       char *e;
-
-       if (*s == ',')
-               ++s;
-
-       if (*s) {
-               unsigned port;
-               if (!strncmp(s,"0x",2)) {
-                       early_serial_base = simple_strtoul(s, &e, 16);
-               } else {
-                       static int bases[] = { 0x3f8, 0x2f8 };
-
-                       if (!strncmp(s,"ttyS",4))
-                               s += 4;
-                       port = simple_strtoul(s, &e, 10);
-                       if (port > 1 || s == e)
-                               port = 0;
-                       early_serial_base = bases[port];
-               }
-               s += strcspn(s, ",");
-               if (*s == ',')
-                       s++;
-       }
-
-       outb(0x3, early_serial_base + LCR);     /* 8n1 */
-       outb(0, early_serial_base + IER);       /* no interrupt */
-       outb(0, early_serial_base + FCR);       /* no fifo */
-       outb(0x3, early_serial_base + MCR);     /* DTR + RTS */
-
-       if (*s) {
-               baud = simple_strtoul(s, &e, 0);
-               if (baud == 0 || s == e)
-                       baud = DEFAULT_BAUD;
-       }
-
-       divisor = 115200 / baud;
-       c = inb(early_serial_base + LCR);
-       outb(c | DLAB, early_serial_base + LCR);
-       outb(divisor & 0xff, early_serial_base + DLL);
-       outb((divisor >> 8) & 0xff, early_serial_base + DLH);
-       outb(c & ~DLAB, early_serial_base + LCR);
-}
-
-static struct console early_serial_console = {
-       .name =         "earlyser",
-       .write =        early_serial_write,
-       .flags =        CON_PRINTBUFFER,
-       .index =        -1,
-};
-
-/* Console interface to a host file on AMD's SimNow! */
-
-static int simnow_fd;
-
-enum {
-       MAGIC1 = 0xBACCD00A,
-       MAGIC2 = 0xCA110000,
-       XOPEN = 5,
-       XWRITE = 4,
-};
-
-static noinline long simnow(long cmd, long a, long b, long c)
-{
-       long ret;
-       asm volatile("cpuid" :
-                    "=a" (ret) :
-                    "b" (a), "c" (b), "d" (c), "0" (MAGIC1), "D" (cmd + MAGIC2));
-       return ret;
-}
-
-static void __init simnow_init(char *str)
-{
-       char *fn = "klog";
-       if (*str == '=')
-               fn = ++str;
-       /* error ignored */
-       simnow_fd = simnow(XOPEN, (unsigned long)fn, O_WRONLY|O_APPEND|O_CREAT, 0644);
-}
-
-static void simnow_write(struct console *con, const char *s, unsigned n)
-{
-       simnow(XWRITE, simnow_fd, (unsigned long)s, n);
-}
-
-static struct console simnow_console = {
-       .name =         "simnow",
-       .write =        simnow_write,
-       .flags =        CON_PRINTBUFFER,
-       .index =        -1,
-};
-
-/* Direct interface for emergencies */
-struct console *early_console = &early_vga_console;
-static int early_console_initialized = 0;
-
-void early_printk(const char *fmt, ...)
-{
-       char buf[512];
-       int n;
-       va_list ap;
-
-       va_start(ap,fmt);
-       n = vscnprintf(buf,512,fmt,ap);
-       early_console->write(early_console,buf,n);
-       va_end(ap);
-}
-
-static int __initdata keep_early;
-
-static int __init setup_early_printk(char *buf)
-{
-       if (!buf)
-               return 0;
-
-       if (early_console_initialized)
-               return 0;
-       early_console_initialized = 1;
-
-       if (strstr(buf, "keep"))
-               keep_early = 1;
-
-       if (!strncmp(buf, "serial", 6)) {
-               early_serial_init(buf + 6);
-               early_console = &early_serial_console;
-       } else if (!strncmp(buf, "ttyS", 4)) {
-               early_serial_init(buf);
-               early_console = &early_serial_console;
-       } else if (!strncmp(buf, "vga", 3)
-                  && SCREEN_INFO.orig_video_isVGA == 1) {
-               max_xpos = SCREEN_INFO.orig_video_cols;
-               max_ypos = SCREEN_INFO.orig_video_lines;
-               current_ypos = SCREEN_INFO.orig_y;
-               early_console = &early_vga_console;
-       } else if (!strncmp(buf, "simnow", 6)) {
-               simnow_init(buf + 6);
-               early_console = &simnow_console;
-               keep_early = 1;
-#ifdef CONFIG_HVC_XEN
-       } else if (!strncmp(buf, "xen", 3)) {
-               early_console = &xenboot_console;
-#endif
-       }
-
-       if (keep_early)
-               early_console->flags &= ~CON_BOOT;
-       else
-               early_console->flags |= CON_BOOT;
-       register_console(early_console);
-       return 0;
-}
-early_param("earlyprintk", setup_early_printk);
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
deleted file mode 100644 (file)
index 1d232e5..0000000
+++ /dev/null
@@ -1,1172 +0,0 @@
-/*
- *  linux/arch/x86_64/entry.S
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 2000, 2001, 2002  Andi Kleen SuSE Labs
- *  Copyright (C) 2000  Pavel Machek <pavel@suse.cz>
- */
-
-/*
- * entry.S contains the system-call and fault low-level handling routines.
- *
- * NOTE: This code handles signal-recognition, which happens every time
- * after an interrupt and after each system call.
- * 
- * Normal syscalls and interrupts don't save a full stack frame, this is 
- * only done for syscall tracing, signals or fork/exec et.al.
- * 
- * A note on terminology:       
- * - top of stack: Architecture defined interrupt frame from SS to RIP 
- * at the top of the kernel process stack.     
- * - partial stack frame: partially saved registers upto R11.
- * - full stack frame: Like partial stack frame, but all register saved. 
- *
- * Some macro usage:
- * - CFI macros are used to generate dwarf2 unwind information for better
- * backtraces. They don't change any code.
- * - SAVE_ALL/RESTORE_ALL - Save/restore all registers
- * - SAVE_ARGS/RESTORE_ARGS - Save/restore registers that C functions modify.
- * There are unfortunately lots of special cases where some registers
- * not touched. The macro is a big mess that should be cleaned up.
- * - SAVE_REST/RESTORE_REST - Handle the registers not saved by SAVE_ARGS.
- * Gives a full stack frame.
- * - ENTRY/END Define functions in the symbol table.
- * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack
- * frame that is otherwise undefined after a SYSCALL
- * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging.
- * - errorentry/paranoidentry/zeroentry - Define exception entry points.
- */
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/cache.h>
-#include <asm/errno.h>
-#include <asm/dwarf2.h>
-#include <asm/calling.h>
-#include <asm/asm-offsets.h>
-#include <asm/msr.h>
-#include <asm/unistd.h>
-#include <asm/thread_info.h>
-#include <asm/hw_irq.h>
-#include <asm/page.h>
-#include <asm/irqflags.h>
-
-       .code64
-
-#ifndef CONFIG_PREEMPT
-#define retint_kernel retint_restore_args
-#endif 
-
-
-.macro TRACE_IRQS_IRETQ offset=ARGOFFSET
-#ifdef CONFIG_TRACE_IRQFLAGS
-       bt   $9,EFLAGS-\offset(%rsp)    /* interrupts off? */
-       jnc  1f
-       TRACE_IRQS_ON
-1:
-#endif
-.endm
-
-/*
- * C code is not supposed to know about undefined top of stack. Every time 
- * a C function with an pt_regs argument is called from the SYSCALL based 
- * fast path FIXUP_TOP_OF_STACK is needed.
- * RESTORE_TOP_OF_STACK syncs the syscall state after any possible ptregs
- * manipulation.
- */            
-               
-       /* %rsp:at FRAMEEND */ 
-       .macro FIXUP_TOP_OF_STACK tmp
-       movq    %gs:pda_oldrsp,\tmp
-       movq    \tmp,RSP(%rsp)
-       movq    $__USER_DS,SS(%rsp)
-       movq    $__USER_CS,CS(%rsp)
-       movq    $-1,RCX(%rsp)
-       movq    R11(%rsp),\tmp  /* get eflags */
-       movq    \tmp,EFLAGS(%rsp)
-       .endm
-
-       .macro RESTORE_TOP_OF_STACK tmp,offset=0
-       movq   RSP-\offset(%rsp),\tmp
-       movq   \tmp,%gs:pda_oldrsp
-       movq   EFLAGS-\offset(%rsp),\tmp
-       movq   \tmp,R11-\offset(%rsp)
-       .endm
-
-       .macro FAKE_STACK_FRAME child_rip
-       /* push in order ss, rsp, eflags, cs, rip */
-       xorl %eax, %eax
-       pushq %rax /* ss */
-       CFI_ADJUST_CFA_OFFSET   8
-       /*CFI_REL_OFFSET        ss,0*/
-       pushq %rax /* rsp */
-       CFI_ADJUST_CFA_OFFSET   8
-       CFI_REL_OFFSET  rsp,0
-       pushq $(1<<9) /* eflags - interrupts on */
-       CFI_ADJUST_CFA_OFFSET   8
-       /*CFI_REL_OFFSET        rflags,0*/
-       pushq $__KERNEL_CS /* cs */
-       CFI_ADJUST_CFA_OFFSET   8
-       /*CFI_REL_OFFSET        cs,0*/
-       pushq \child_rip /* rip */
-       CFI_ADJUST_CFA_OFFSET   8
-       CFI_REL_OFFSET  rip,0
-       pushq   %rax /* orig rax */
-       CFI_ADJUST_CFA_OFFSET   8
-       .endm
-
-       .macro UNFAKE_STACK_FRAME
-       addq $8*6, %rsp
-       CFI_ADJUST_CFA_OFFSET   -(6*8)
-       .endm
-
-       .macro  CFI_DEFAULT_STACK start=1
-       .if \start
-       CFI_STARTPROC   simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,SS+8
-       .else
-       CFI_DEF_CFA_OFFSET SS+8
-       .endif
-       CFI_REL_OFFSET  r15,R15
-       CFI_REL_OFFSET  r14,R14
-       CFI_REL_OFFSET  r13,R13
-       CFI_REL_OFFSET  r12,R12
-       CFI_REL_OFFSET  rbp,RBP
-       CFI_REL_OFFSET  rbx,RBX
-       CFI_REL_OFFSET  r11,R11
-       CFI_REL_OFFSET  r10,R10
-       CFI_REL_OFFSET  r9,R9
-       CFI_REL_OFFSET  r8,R8
-       CFI_REL_OFFSET  rax,RAX
-       CFI_REL_OFFSET  rcx,RCX
-       CFI_REL_OFFSET  rdx,RDX
-       CFI_REL_OFFSET  rsi,RSI
-       CFI_REL_OFFSET  rdi,RDI
-       CFI_REL_OFFSET  rip,RIP
-       /*CFI_REL_OFFSET        cs,CS*/
-       /*CFI_REL_OFFSET        rflags,EFLAGS*/
-       CFI_REL_OFFSET  rsp,RSP
-       /*CFI_REL_OFFSET        ss,SS*/
-       .endm
-/*
- * A newly forked process directly context switches into this.
- */    
-/* rdi:        prev */ 
-ENTRY(ret_from_fork)
-       CFI_DEFAULT_STACK
-       push kernel_eflags(%rip)
-       CFI_ADJUST_CFA_OFFSET 4
-       popf                            # reset kernel eflags
-       CFI_ADJUST_CFA_OFFSET -4
-       call schedule_tail
-       GET_THREAD_INFO(%rcx)
-       testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx)
-       jnz rff_trace
-rff_action:    
-       RESTORE_REST
-       testl $3,CS-ARGOFFSET(%rsp)     # from kernel_thread?
-       je   int_ret_from_sys_call
-       testl $_TIF_IA32,threadinfo_flags(%rcx)
-       jnz  int_ret_from_sys_call
-       RESTORE_TOP_OF_STACK %rdi,ARGOFFSET
-       jmp ret_from_sys_call
-rff_trace:
-       movq %rsp,%rdi
-       call syscall_trace_leave
-       GET_THREAD_INFO(%rcx)   
-       jmp rff_action
-       CFI_ENDPROC
-END(ret_from_fork)
-
-/*
- * System call entry. Upto 6 arguments in registers are supported.
- *
- * SYSCALL does not save anything on the stack and does not change the
- * stack pointer.
- */
-               
-/*
- * Register setup:     
- * rax  system call number
- * rdi  arg0
- * rcx  return address for syscall/sysret, C arg3 
- * rsi  arg1
- * rdx  arg2   
- * r10  arg3   (--> moved to rcx for C)
- * r8   arg4
- * r9   arg5
- * r11  eflags for syscall/sysret, temporary for C
- * r12-r15,rbp,rbx saved by C code, not touched.               
- * 
- * Interrupts are off on entry.
- * Only called from user space.
- *
- * XXX if we had a free scratch register we could save the RSP into the stack frame
- *      and report it properly in ps. Unfortunately we haven't.
- *
- * When user can change the frames always force IRET. That is because
- * it deals with uncanonical addresses better. SYSRET has trouble
- * with them due to bugs in both AMD and Intel CPUs.
- */                                    
-
-ENTRY(system_call)
-       CFI_STARTPROC   simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA     rsp,PDA_STACKOFFSET
-       CFI_REGISTER    rip,rcx
-       /*CFI_REGISTER  rflags,r11*/
-       swapgs
-       movq    %rsp,%gs:pda_oldrsp 
-       movq    %gs:pda_kernelstack,%rsp
-       /*
-        * No need to follow this irqs off/on section - it's straight
-        * and short:
-        */
-       sti                                     
-       SAVE_ARGS 8,1
-       movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) 
-       movq  %rcx,RIP-ARGOFFSET(%rsp)
-       CFI_REL_OFFSET rip,RIP-ARGOFFSET
-       GET_THREAD_INFO(%rcx)
-       testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
-       jnz tracesys
-       cmpq $__NR_syscall_max,%rax
-       ja badsys
-       movq %r10,%rcx
-       call *sys_call_table(,%rax,8)  # XXX:    rip relative
-       movq %rax,RAX-ARGOFFSET(%rsp)
-/*
- * Syscall return path ending with SYSRET (fast path)
- * Has incomplete stack frame and undefined top of stack. 
- */            
-ret_from_sys_call:
-       movl $_TIF_ALLWORK_MASK,%edi
-       /* edi: flagmask */
-sysret_check:          
-       GET_THREAD_INFO(%rcx)
-       cli
-       TRACE_IRQS_OFF
-       movl threadinfo_flags(%rcx),%edx
-       andl %edi,%edx
-       jnz  sysret_careful 
-       CFI_REMEMBER_STATE
-       /*
-        * sysretq will re-enable interrupts:
-        */
-       TRACE_IRQS_ON
-       movq RIP-ARGOFFSET(%rsp),%rcx
-       CFI_REGISTER    rip,rcx
-       RESTORE_ARGS 0,-ARG_SKIP,1
-       /*CFI_REGISTER  rflags,r11*/
-       movq    %gs:pda_oldrsp,%rsp
-       swapgs
-       sysretq
-
-       CFI_RESTORE_STATE
-       /* Handle reschedules */
-       /* edx: work, edi: workmask */  
-sysret_careful:
-       bt $TIF_NEED_RESCHED,%edx
-       jnc sysret_signal
-       TRACE_IRQS_ON
-       sti
-       pushq %rdi
-       CFI_ADJUST_CFA_OFFSET 8
-       call schedule
-       popq  %rdi
-       CFI_ADJUST_CFA_OFFSET -8
-       jmp sysret_check
-
-       /* Handle a signal */ 
-sysret_signal:
-       TRACE_IRQS_ON
-       sti
-       testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
-       jz    1f
-
-       /* Really a signal */
-       /* edx: work flags (arg3) */
-       leaq do_notify_resume(%rip),%rax
-       leaq -ARGOFFSET(%rsp),%rdi # &pt_regs -> arg1
-       xorl %esi,%esi # oldset -> arg2
-       call ptregscall_common
-1:     movl $_TIF_NEED_RESCHED,%edi
-       /* Use IRET because user could have changed frame. This
-          works because ptregscall_common has called FIXUP_TOP_OF_STACK. */
-       cli
-       TRACE_IRQS_OFF
-       jmp int_with_check
-       
-badsys:
-       movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
-       jmp ret_from_sys_call
-
-       /* Do syscall tracing */
-tracesys:                       
-       SAVE_REST
-       movq $-ENOSYS,RAX(%rsp)
-       FIXUP_TOP_OF_STACK %rdi
-       movq %rsp,%rdi
-       call syscall_trace_enter
-       LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
-       RESTORE_REST
-       cmpq $__NR_syscall_max,%rax
-       movq $-ENOSYS,%rcx
-       cmova %rcx,%rax
-       ja  1f
-       movq %r10,%rcx  /* fixup for C */
-       call *sys_call_table(,%rax,8)
-1:     movq %rax,RAX-ARGOFFSET(%rsp)
-       /* Use IRET because user could have changed frame */
-               
-/* 
- * Syscall return path ending with IRET.
- * Has correct top of stack, but partial stack frame.
- */
-       .globl int_ret_from_sys_call
-int_ret_from_sys_call:
-       cli
-       TRACE_IRQS_OFF
-       testl $3,CS-ARGOFFSET(%rsp)
-       je retint_restore_args
-       movl $_TIF_ALLWORK_MASK,%edi
-       /* edi: mask to check */
-int_with_check:
-       GET_THREAD_INFO(%rcx)
-       movl threadinfo_flags(%rcx),%edx
-       andl %edi,%edx
-       jnz   int_careful
-       andl    $~TS_COMPAT,threadinfo_status(%rcx)
-       jmp   retint_swapgs
-
-       /* Either reschedule or signal or syscall exit tracking needed. */
-       /* First do a reschedule test. */
-       /* edx: work, edi: workmask */
-int_careful:
-       bt $TIF_NEED_RESCHED,%edx
-       jnc  int_very_careful
-       TRACE_IRQS_ON
-       sti
-       pushq %rdi
-       CFI_ADJUST_CFA_OFFSET 8
-       call schedule
-       popq %rdi
-       CFI_ADJUST_CFA_OFFSET -8
-       cli
-       TRACE_IRQS_OFF
-       jmp int_with_check
-
-       /* handle signals and tracing -- both require a full stack frame */
-int_very_careful:
-       TRACE_IRQS_ON
-       sti
-       SAVE_REST
-       /* Check for syscall exit trace */      
-       testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edx
-       jz int_signal
-       pushq %rdi
-       CFI_ADJUST_CFA_OFFSET 8
-       leaq 8(%rsp),%rdi       # &ptregs -> arg1       
-       call syscall_trace_leave
-       popq %rdi
-       CFI_ADJUST_CFA_OFFSET -8
-       andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi
-       jmp int_restore_rest
-       
-int_signal:
-       testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
-       jz 1f
-       movq %rsp,%rdi          # &ptregs -> arg1
-       xorl %esi,%esi          # oldset -> arg2
-       call do_notify_resume
-1:     movl $_TIF_NEED_RESCHED,%edi    
-int_restore_rest:
-       RESTORE_REST
-       cli
-       TRACE_IRQS_OFF
-       jmp int_with_check
-       CFI_ENDPROC
-END(system_call)
-               
-/* 
- * Certain special system calls that need to save a complete full stack frame.
- */                                                            
-       
-       .macro PTREGSCALL label,func,arg
-       .globl \label
-\label:
-       leaq    \func(%rip),%rax
-       leaq    -ARGOFFSET+8(%rsp),\arg /* 8 for return address */
-       jmp     ptregscall_common
-END(\label)
-       .endm
-
-       CFI_STARTPROC
-
-       PTREGSCALL stub_clone, sys_clone, %r8
-       PTREGSCALL stub_fork, sys_fork, %rdi
-       PTREGSCALL stub_vfork, sys_vfork, %rdi
-       PTREGSCALL stub_rt_sigsuspend, sys_rt_sigsuspend, %rdx
-       PTREGSCALL stub_sigaltstack, sys_sigaltstack, %rdx
-       PTREGSCALL stub_iopl, sys_iopl, %rsi
-
-ENTRY(ptregscall_common)
-       popq %r11
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_REGISTER rip, r11
-       SAVE_REST
-       movq %r11, %r15
-       CFI_REGISTER rip, r15
-       FIXUP_TOP_OF_STACK %r11
-       call *%rax
-       RESTORE_TOP_OF_STACK %r11
-       movq %r15, %r11
-       CFI_REGISTER rip, r11
-       RESTORE_REST
-       pushq %r11
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rip, 0
-       ret
-       CFI_ENDPROC
-END(ptregscall_common)
-       
-ENTRY(stub_execve)
-       CFI_STARTPROC
-       popq %r11
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_REGISTER rip, r11
-       SAVE_REST
-       FIXUP_TOP_OF_STACK %r11
-       call sys_execve
-       RESTORE_TOP_OF_STACK %r11
-       movq %rax,RAX(%rsp)
-       RESTORE_REST
-       jmp int_ret_from_sys_call
-       CFI_ENDPROC
-END(stub_execve)
-       
-/*
- * sigreturn is special because it needs to restore all registers on return.
- * This cannot be done with SYSRET, so use the IRET return path instead.
- */                
-ENTRY(stub_rt_sigreturn)
-       CFI_STARTPROC
-       addq $8, %rsp
-       CFI_ADJUST_CFA_OFFSET   -8
-       SAVE_REST
-       movq %rsp,%rdi
-       FIXUP_TOP_OF_STACK %r11
-       call sys_rt_sigreturn
-       movq %rax,RAX(%rsp) # fixme, this could be done at the higher layer
-       RESTORE_REST
-       jmp int_ret_from_sys_call
-       CFI_ENDPROC
-END(stub_rt_sigreturn)
-
-/*
- * initial frame state for interrupts and exceptions
- */
-       .macro _frame ref
-       CFI_STARTPROC simple
-       CFI_SIGNAL_FRAME
-       CFI_DEF_CFA rsp,SS+8-\ref
-       /*CFI_REL_OFFSET ss,SS-\ref*/
-       CFI_REL_OFFSET rsp,RSP-\ref
-       /*CFI_REL_OFFSET rflags,EFLAGS-\ref*/
-       /*CFI_REL_OFFSET cs,CS-\ref*/
-       CFI_REL_OFFSET rip,RIP-\ref
-       .endm
-
-/* initial frame state for interrupts (and exceptions without error code) */
-#define INTR_FRAME _frame RIP
-/* initial frame state for exceptions with error code (and interrupts with
-   vector already pushed) */
-#define XCPT_FRAME _frame ORIG_RAX
-
-/* 
- * Interrupt entry/exit.
- *
- * Interrupt entry points save only callee clobbered registers in fast path.
- *     
- * Entry runs with interrupts off.     
- */ 
-
-/* 0(%rsp): interrupt number */ 
-       .macro interrupt func
-       cld
-       SAVE_ARGS
-       leaq -ARGOFFSET(%rsp),%rdi      # arg1 for handler
-       pushq %rbp
-       CFI_ADJUST_CFA_OFFSET   8
-       CFI_REL_OFFSET          rbp, 0
-       movq %rsp,%rbp
-       CFI_DEF_CFA_REGISTER    rbp
-       testl $3,CS(%rdi)
-       je 1f
-       swapgs  
-       /* irqcount is used to check if a CPU is already on an interrupt
-          stack or not. While this is essentially redundant with preempt_count
-          it is a little cheaper to use a separate counter in the PDA
-          (short of moving irq_enter into assembly, which would be too
-           much work) */
-1:     incl    %gs:pda_irqcount
-       cmoveq %gs:pda_irqstackptr,%rsp
-       push    %rbp                    # backlink for old unwinder
-       /*
-        * We entered an interrupt context - irqs are off:
-        */
-       TRACE_IRQS_OFF
-       call \func
-       .endm
-
-ENTRY(common_interrupt)
-       XCPT_FRAME
-       interrupt do_IRQ
-       /* 0(%rsp): oldrsp-ARGOFFSET */
-ret_from_intr:
-       cli     
-       TRACE_IRQS_OFF
-       decl %gs:pda_irqcount
-       leaveq
-       CFI_DEF_CFA_REGISTER    rsp
-       CFI_ADJUST_CFA_OFFSET   -8
-exit_intr:
-       GET_THREAD_INFO(%rcx)
-       testl $3,CS-ARGOFFSET(%rsp)
-       je retint_kernel
-       
-       /* Interrupt came from user space */
-       /*
-        * Has a correct top of stack, but a partial stack frame
-        * %rcx: thread info. Interrupts off.
-        */             
-retint_with_reschedule:
-       movl $_TIF_WORK_MASK,%edi
-retint_check:
-       movl threadinfo_flags(%rcx),%edx
-       andl %edi,%edx
-       CFI_REMEMBER_STATE
-       jnz  retint_careful
-retint_swapgs:         
-       /*
-        * The iretq could re-enable interrupts:
-        */
-       cli
-       TRACE_IRQS_IRETQ
-       swapgs 
-       jmp restore_args
-
-retint_restore_args:                           
-       cli
-       /*
-        * The iretq could re-enable interrupts:
-        */
-       TRACE_IRQS_IRETQ
-restore_args:
-       RESTORE_ARGS 0,8,0                                              
-iret_label:    
-       iretq
-
-       .section __ex_table,"a"
-       .quad iret_label,bad_iret       
-       .previous
-       .section .fixup,"ax"
-       /* force a signal here? this matches i386 behaviour */
-       /* running with kernel gs */
-bad_iret:
-       movq $11,%rdi   /* SIGSEGV */
-       TRACE_IRQS_ON
-       sti
-       jmp do_exit                     
-       .previous       
-       
-       /* edi: workmask, edx: work */
-retint_careful:
-       CFI_RESTORE_STATE
-       bt    $TIF_NEED_RESCHED,%edx
-       jnc   retint_signal
-       TRACE_IRQS_ON
-       sti
-       pushq %rdi
-       CFI_ADJUST_CFA_OFFSET   8
-       call  schedule
-       popq %rdi               
-       CFI_ADJUST_CFA_OFFSET   -8
-       GET_THREAD_INFO(%rcx)
-       cli
-       TRACE_IRQS_OFF
-       jmp retint_check
-       
-retint_signal:
-       testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
-       jz    retint_swapgs
-       TRACE_IRQS_ON
-       sti
-       SAVE_REST
-       movq $-1,ORIG_RAX(%rsp)                         
-       xorl %esi,%esi          # oldset
-       movq %rsp,%rdi          # &pt_regs
-       call do_notify_resume
-       RESTORE_REST
-       cli
-       TRACE_IRQS_OFF
-       movl $_TIF_NEED_RESCHED,%edi
-       GET_THREAD_INFO(%rcx)
-       jmp retint_check
-
-#ifdef CONFIG_PREEMPT
-       /* Returning to kernel space. Check if we need preemption */
-       /* rcx:  threadinfo. interrupts off. */
-ENTRY(retint_kernel)
-       cmpl $0,threadinfo_preempt_count(%rcx)
-       jnz  retint_restore_args
-       bt  $TIF_NEED_RESCHED,threadinfo_flags(%rcx)
-       jnc  retint_restore_args
-       bt   $9,EFLAGS-ARGOFFSET(%rsp)  /* interrupts off? */
-       jnc  retint_restore_args
-       call preempt_schedule_irq
-       jmp exit_intr
-#endif 
-
-       CFI_ENDPROC
-END(common_interrupt)
-       
-/*
- * APIC interrupts.
- */            
-       .macro apicinterrupt num,func
-       INTR_FRAME
-       pushq $~(\num)
-       CFI_ADJUST_CFA_OFFSET 8
-       interrupt \func
-       jmp ret_from_intr
-       CFI_ENDPROC
-       .endm
-
-ENTRY(thermal_interrupt)
-       apicinterrupt THERMAL_APIC_VECTOR,smp_thermal_interrupt
-END(thermal_interrupt)
-
-ENTRY(threshold_interrupt)
-       apicinterrupt THRESHOLD_APIC_VECTOR,mce_threshold_interrupt
-END(threshold_interrupt)
-
-#ifdef CONFIG_SMP      
-ENTRY(reschedule_interrupt)
-       apicinterrupt RESCHEDULE_VECTOR,smp_reschedule_interrupt
-END(reschedule_interrupt)
-
-       .macro INVALIDATE_ENTRY num
-ENTRY(invalidate_interrupt\num)
-       apicinterrupt INVALIDATE_TLB_VECTOR_START+\num,smp_invalidate_interrupt 
-END(invalidate_interrupt\num)
-       .endm
-
-       INVALIDATE_ENTRY 0
-       INVALIDATE_ENTRY 1
-       INVALIDATE_ENTRY 2
-       INVALIDATE_ENTRY 3
-       INVALIDATE_ENTRY 4
-       INVALIDATE_ENTRY 5
-       INVALIDATE_ENTRY 6
-       INVALIDATE_ENTRY 7
-
-ENTRY(call_function_interrupt)
-       apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt
-END(call_function_interrupt)
-ENTRY(irq_move_cleanup_interrupt)
-       apicinterrupt IRQ_MOVE_CLEANUP_VECTOR,smp_irq_move_cleanup_interrupt
-END(irq_move_cleanup_interrupt)
-#endif
-
-ENTRY(apic_timer_interrupt)
-       apicinterrupt LOCAL_TIMER_VECTOR,smp_apic_timer_interrupt
-END(apic_timer_interrupt)
-
-ENTRY(error_interrupt)
-       apicinterrupt ERROR_APIC_VECTOR,smp_error_interrupt
-END(error_interrupt)
-
-ENTRY(spurious_interrupt)
-       apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt
-END(spurious_interrupt)
-                               
-/*
- * Exception entry points.
- */            
-       .macro zeroentry sym
-       INTR_FRAME
-       pushq $0        /* push error code/oldrax */ 
-       CFI_ADJUST_CFA_OFFSET 8
-       pushq %rax      /* push real oldrax to the rdi slot */ 
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rax,0
-       leaq  \sym(%rip),%rax
-       jmp error_entry
-       CFI_ENDPROC
-       .endm   
-
-       .macro errorentry sym
-       XCPT_FRAME
-       pushq %rax
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rax,0
-       leaq  \sym(%rip),%rax
-       jmp error_entry
-       CFI_ENDPROC
-       .endm
-
-       /* error code is on the stack already */
-       /* handle NMI like exceptions that can happen everywhere */
-       .macro paranoidentry sym, ist=0, irqtrace=1
-       SAVE_ALL
-       cld
-       movl $1,%ebx
-       movl  $MSR_GS_BASE,%ecx
-       rdmsr
-       testl %edx,%edx
-       js    1f
-       swapgs
-       xorl  %ebx,%ebx
-1:
-       .if \ist
-       movq    %gs:pda_data_offset, %rbp
-       .endif
-       movq %rsp,%rdi
-       movq ORIG_RAX(%rsp),%rsi
-       movq $-1,ORIG_RAX(%rsp)
-       .if \ist
-       subq    $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
-       .endif
-       call \sym
-       .if \ist
-       addq    $EXCEPTION_STKSZ, per_cpu__init_tss + TSS_ist + (\ist - 1) * 8(%rbp)
-       .endif
-       cli
-       .if \irqtrace
-       TRACE_IRQS_OFF
-       .endif
-       .endm
-
-       /*
-        * "Paranoid" exit path from exception stack.
-        * Paranoid because this is used by NMIs and cannot take
-        * any kernel state for granted.
-        * We don't do kernel preemption checks here, because only
-        * NMI should be common and it does not enable IRQs and
-        * cannot get reschedule ticks.
-        *
-        * "trace" is 0 for the NMI handler only, because irq-tracing
-        * is fundamentally NMI-unsafe. (we cannot change the soft and
-        * hard flags at once, atomically)
-        */
-       .macro paranoidexit trace=1
-       /* ebx: no swapgs flag */
-paranoid_exit\trace:
-       testl %ebx,%ebx                         /* swapgs needed? */
-       jnz paranoid_restore\trace
-       testl $3,CS(%rsp)
-       jnz   paranoid_userspace\trace
-paranoid_swapgs\trace:
-       .if \trace
-       TRACE_IRQS_IRETQ 0
-       .endif
-       swapgs
-paranoid_restore\trace:
-       RESTORE_ALL 8
-       iretq
-paranoid_userspace\trace:
-       GET_THREAD_INFO(%rcx)
-       movl threadinfo_flags(%rcx),%ebx
-       andl $_TIF_WORK_MASK,%ebx
-       jz paranoid_swapgs\trace
-       movq %rsp,%rdi                  /* &pt_regs */
-       call sync_regs
-       movq %rax,%rsp                  /* switch stack for scheduling */
-       testl $_TIF_NEED_RESCHED,%ebx
-       jnz paranoid_schedule\trace
-       movl %ebx,%edx                  /* arg3: thread flags */
-       .if \trace
-       TRACE_IRQS_ON
-       .endif
-       sti
-       xorl %esi,%esi                  /* arg2: oldset */
-       movq %rsp,%rdi                  /* arg1: &pt_regs */
-       call do_notify_resume
-       cli
-       .if \trace
-       TRACE_IRQS_OFF
-       .endif
-       jmp paranoid_userspace\trace
-paranoid_schedule\trace:
-       .if \trace
-       TRACE_IRQS_ON
-       .endif
-       sti
-       call schedule
-       cli
-       .if \trace
-       TRACE_IRQS_OFF
-       .endif
-       jmp paranoid_userspace\trace
-       CFI_ENDPROC
-       .endm
-
-/*
- * Exception entry point. This expects an error code/orig_rax on the stack
- * and the exception handler in %rax.  
- */                                            
-KPROBE_ENTRY(error_entry)
-       _frame RDI
-       CFI_REL_OFFSET rax,0
-       /* rdi slot contains rax, oldrax contains error code */
-       cld     
-       subq  $14*8,%rsp
-       CFI_ADJUST_CFA_OFFSET   (14*8)
-       movq %rsi,13*8(%rsp)
-       CFI_REL_OFFSET  rsi,RSI
-       movq 14*8(%rsp),%rsi    /* load rax from rdi slot */
-       CFI_REGISTER    rax,rsi
-       movq %rdx,12*8(%rsp)
-       CFI_REL_OFFSET  rdx,RDX
-       movq %rcx,11*8(%rsp)
-       CFI_REL_OFFSET  rcx,RCX
-       movq %rsi,10*8(%rsp)    /* store rax */ 
-       CFI_REL_OFFSET  rax,RAX
-       movq %r8, 9*8(%rsp)
-       CFI_REL_OFFSET  r8,R8
-       movq %r9, 8*8(%rsp)
-       CFI_REL_OFFSET  r9,R9
-       movq %r10,7*8(%rsp)
-       CFI_REL_OFFSET  r10,R10
-       movq %r11,6*8(%rsp)
-       CFI_REL_OFFSET  r11,R11
-       movq %rbx,5*8(%rsp) 
-       CFI_REL_OFFSET  rbx,RBX
-       movq %rbp,4*8(%rsp) 
-       CFI_REL_OFFSET  rbp,RBP
-       movq %r12,3*8(%rsp) 
-       CFI_REL_OFFSET  r12,R12
-       movq %r13,2*8(%rsp) 
-       CFI_REL_OFFSET  r13,R13
-       movq %r14,1*8(%rsp) 
-       CFI_REL_OFFSET  r14,R14
-       movq %r15,(%rsp) 
-       CFI_REL_OFFSET  r15,R15
-       xorl %ebx,%ebx  
-       testl $3,CS(%rsp)
-       je  error_kernelspace
-error_swapgs:  
-       swapgs
-error_sti:     
-       movq %rdi,RDI(%rsp)     
-       CFI_REL_OFFSET  rdi,RDI
-       movq %rsp,%rdi
-       movq ORIG_RAX(%rsp),%rsi        /* get error code */ 
-       movq $-1,ORIG_RAX(%rsp)
-       call *%rax
-       /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */     
-error_exit:            
-       movl %ebx,%eax          
-       RESTORE_REST
-       cli
-       TRACE_IRQS_OFF
-       GET_THREAD_INFO(%rcx)   
-       testl %eax,%eax
-       jne  retint_kernel
-       movl  threadinfo_flags(%rcx),%edx
-       movl  $_TIF_WORK_MASK,%edi
-       andl  %edi,%edx
-       jnz  retint_careful
-       /*
-        * The iret might restore flags:
-        */
-       TRACE_IRQS_IRETQ
-       swapgs 
-       RESTORE_ARGS 0,8,0                                              
-       jmp iret_label
-       CFI_ENDPROC
-
-error_kernelspace:
-       incl %ebx
-       /* There are two places in the kernel that can potentially fault with
-          usergs. Handle them here. The exception handlers after
-          iret run with kernel gs again, so don't set the user space flag.
-          B stepping K8s sometimes report an truncated RIP for IRET 
-          exceptions returning to compat mode. Check for these here too. */
-       leaq iret_label(%rip),%rbp
-       cmpq %rbp,RIP(%rsp) 
-       je   error_swapgs
-       movl %ebp,%ebp  /* zero extend */
-       cmpq %rbp,RIP(%rsp) 
-       je   error_swapgs
-       cmpq $gs_change,RIP(%rsp)
-        je   error_swapgs
-       jmp  error_sti
-KPROBE_END(error_entry)
-       
-       /* Reload gs selector with exception handling */
-       /* edi:  new selector */ 
-ENTRY(load_gs_index)
-       CFI_STARTPROC
-       pushf
-       CFI_ADJUST_CFA_OFFSET 8
-       cli
-        swapgs
-gs_change:     
-        movl %edi,%gs   
-2:     mfence          /* workaround */
-       swapgs
-        popf
-       CFI_ADJUST_CFA_OFFSET -8
-        ret
-       CFI_ENDPROC
-ENDPROC(load_gs_index)
-       
-        .section __ex_table,"a"
-        .align 8
-        .quad gs_change,bad_gs
-        .previous
-        .section .fixup,"ax"
-       /* running with kernelgs */
-bad_gs: 
-       swapgs                  /* switch back to user gs */
-       xorl %eax,%eax
-        movl %eax,%gs
-        jmp  2b
-        .previous       
-       
-/*
- * Create a kernel thread.
- *
- * C extern interface:
- *     extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
- *
- * asm input arguments:
- *     rdi: fn, rsi: arg, rdx: flags
- */
-ENTRY(kernel_thread)
-       CFI_STARTPROC
-       FAKE_STACK_FRAME $child_rip
-       SAVE_ALL
-
-       # rdi: flags, rsi: usp, rdx: will be &pt_regs
-       movq %rdx,%rdi
-       orq  kernel_thread_flags(%rip),%rdi
-       movq $-1, %rsi
-       movq %rsp, %rdx
-
-       xorl %r8d,%r8d
-       xorl %r9d,%r9d
-       
-       # clone now
-       call do_fork
-       movq %rax,RAX(%rsp)
-       xorl %edi,%edi
-
-       /*
-        * It isn't worth to check for reschedule here,
-        * so internally to the x86_64 port you can rely on kernel_thread()
-        * not to reschedule the child before returning, this avoids the need
-        * of hacks for example to fork off the per-CPU idle tasks.
-         * [Hopefully no generic code relies on the reschedule -AK]    
-        */
-       RESTORE_ALL
-       UNFAKE_STACK_FRAME
-       ret
-       CFI_ENDPROC
-ENDPROC(kernel_thread)
-       
-child_rip:
-       pushq $0                # fake return address
-       CFI_STARTPROC
-       /*
-        * Here we are in the child and the registers are set as they were
-        * at kernel_thread() invocation in the parent.
-        */
-       movq %rdi, %rax
-       movq %rsi, %rdi
-       call *%rax
-       # exit
-       xorl %edi, %edi
-       call do_exit
-       CFI_ENDPROC
-ENDPROC(child_rip)
-
-/*
- * execve(). This function needs to use IRET, not SYSRET, to set up all state properly.
- *
- * C extern interface:
- *      extern long execve(char *name, char **argv, char **envp)
- *
- * asm input arguments:
- *     rdi: name, rsi: argv, rdx: envp
- *
- * We want to fallback into:
- *     extern long sys_execve(char *name, char **argv,char **envp, struct pt_regs regs)
- *
- * do_sys_execve asm fallback arguments:
- *     rdi: name, rsi: argv, rdx: envp, fake frame on the stack
- */
-ENTRY(kernel_execve)
-       CFI_STARTPROC
-       FAKE_STACK_FRAME $0
-       SAVE_ALL        
-       call sys_execve
-       movq %rax, RAX(%rsp)    
-       RESTORE_REST
-       testq %rax,%rax
-       je int_ret_from_sys_call
-       RESTORE_ARGS
-       UNFAKE_STACK_FRAME
-       ret
-       CFI_ENDPROC
-ENDPROC(kernel_execve)
-
-KPROBE_ENTRY(page_fault)
-       errorentry do_page_fault
-KPROBE_END(page_fault)
-
-ENTRY(coprocessor_error)
-       zeroentry do_coprocessor_error
-END(coprocessor_error)
-
-ENTRY(simd_coprocessor_error)
-       zeroentry do_simd_coprocessor_error     
-END(simd_coprocessor_error)
-
-ENTRY(device_not_available)
-       zeroentry math_state_restore
-END(device_not_available)
-
-       /* runs on exception stack */
-KPROBE_ENTRY(debug)
-       INTR_FRAME
-       pushq $0
-       CFI_ADJUST_CFA_OFFSET 8         
-       paranoidentry do_debug, DEBUG_STACK
-       paranoidexit
-KPROBE_END(debug)
-
-       /* runs on exception stack */   
-KPROBE_ENTRY(nmi)
-       INTR_FRAME
-       pushq $-1
-       CFI_ADJUST_CFA_OFFSET 8
-       paranoidentry do_nmi, 0, 0
-#ifdef CONFIG_TRACE_IRQFLAGS
-       paranoidexit 0
-#else
-       jmp paranoid_exit1
-       CFI_ENDPROC
-#endif
-KPROBE_END(nmi)
-
-KPROBE_ENTRY(int3)
-       INTR_FRAME
-       pushq $0
-       CFI_ADJUST_CFA_OFFSET 8
-       paranoidentry do_int3, DEBUG_STACK
-       jmp paranoid_exit1
-       CFI_ENDPROC
-KPROBE_END(int3)
-
-ENTRY(overflow)
-       zeroentry do_overflow
-END(overflow)
-
-ENTRY(bounds)
-       zeroentry do_bounds
-END(bounds)
-
-ENTRY(invalid_op)
-       zeroentry do_invalid_op 
-END(invalid_op)
-
-ENTRY(coprocessor_segment_overrun)
-       zeroentry do_coprocessor_segment_overrun
-END(coprocessor_segment_overrun)
-
-ENTRY(reserved)
-       zeroentry do_reserved
-END(reserved)
-
-       /* runs on exception stack */
-ENTRY(double_fault)
-       XCPT_FRAME
-       paranoidentry do_double_fault
-       jmp paranoid_exit1
-       CFI_ENDPROC
-END(double_fault)
-
-ENTRY(invalid_TSS)
-       errorentry do_invalid_TSS
-END(invalid_TSS)
-
-ENTRY(segment_not_present)
-       errorentry do_segment_not_present
-END(segment_not_present)
-
-       /* runs on exception stack */
-ENTRY(stack_segment)
-       XCPT_FRAME
-       paranoidentry do_stack_segment
-       jmp paranoid_exit1
-       CFI_ENDPROC
-END(stack_segment)
-
-KPROBE_ENTRY(general_protection)
-       errorentry do_general_protection
-KPROBE_END(general_protection)
-
-ENTRY(alignment_check)
-       errorentry do_alignment_check
-END(alignment_check)
-
-ENTRY(divide_error)
-       zeroentry do_divide_error
-END(divide_error)
-
-ENTRY(spurious_interrupt_bug)
-       zeroentry do_spurious_interrupt_bug
-END(spurious_interrupt_bug)
-
-#ifdef CONFIG_X86_MCE
-       /* runs on exception stack */
-ENTRY(machine_check)
-       INTR_FRAME
-       pushq $0
-       CFI_ADJUST_CFA_OFFSET 8 
-       paranoidentry do_machine_check
-       jmp paranoid_exit1
-       CFI_ENDPROC
-END(machine_check)
-#endif
-
-/* Call softirq on interrupt stack. Interrupts are off. */
-ENTRY(call_softirq)
-       CFI_STARTPROC
-       push %rbp
-       CFI_ADJUST_CFA_OFFSET   8
-       CFI_REL_OFFSET rbp,0
-       mov  %rsp,%rbp
-       CFI_DEF_CFA_REGISTER rbp
-       incl %gs:pda_irqcount
-       cmove %gs:pda_irqstackptr,%rsp
-       push  %rbp                      # backlink for old unwinder
-       call __do_softirq
-       leaveq
-       CFI_DEF_CFA_REGISTER    rsp
-       CFI_ADJUST_CFA_OFFSET   -8
-       decl %gs:pda_irqcount
-       ret
-       CFI_ENDPROC
-ENDPROC(call_softirq)
-
-KPROBE_ENTRY(ignore_sysret)
-       CFI_STARTPROC
-       mov $-ENOSYS,%eax
-       sysret
-       CFI_ENDPROC
-ENDPROC(ignore_sysret)
diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c
deleted file mode 100644 (file)
index 47496a4..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2004 James Cleverdon, IBM.
- * Subject to the GNU Public License, v.2
- *
- * Generic APIC sub-arch probe layer.
- *
- * Hacked for x86-64 by James Cleverdon from i386 architecture code by
- * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
- * James Cleverdon.
- */
-#include <linux/threads.h>
-#include <linux/cpumask.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-
-#include <asm/smp.h>
-#include <asm/ipi.h>
-#include <asm/genapic.h>
-
-#ifdef CONFIG_ACPI
-#include <acpi/acpi_bus.h>
-#endif
-
-/* which logical CPU number maps to which CPU (physical APIC ID) */
-u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly
-                                       = { [0 ... NR_CPUS-1] = BAD_APICID };
-EXPORT_SYMBOL(x86_cpu_to_apicid);
-
-u8 x86_cpu_to_log_apicid[NR_CPUS]      = { [0 ... NR_CPUS-1] = BAD_APICID };
-
-struct genapic __read_mostly *genapic = &apic_flat;
-
-/*
- * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
- */
-void __init setup_apic_routing(void)
-{
-#ifdef CONFIG_ACPI
-       /*
-        * Quirk: some x86_64 machines can only use physical APIC mode
-        * regardless of how many processors are present (x86_64 ES7000
-        * is an example).
-        */
-       if (acpi_gbl_FADT.header.revision > FADT2_REVISION_ID &&
-                       (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL))
-               genapic = &apic_physflat;
-       else
-#endif
-
-       if (cpus_weight(cpu_possible_map) <= 8)
-               genapic = &apic_flat;
-       else
-               genapic = &apic_physflat;
-
-       printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
-}
-
-/* Same for both flat and physical. */
-
-void send_IPI_self(int vector)
-{
-       __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
-}
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
deleted file mode 100644 (file)
index ecb01ee..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2004 James Cleverdon, IBM.
- * Subject to the GNU Public License, v.2
- *
- * Flat APIC subarch code.
- *
- * Hacked for x86-64 by James Cleverdon from i386 architecture code by
- * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
- * James Cleverdon.
- */
-#include <linux/errno.h>
-#include <linux/threads.h>
-#include <linux/cpumask.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-#include <asm/smp.h>
-#include <asm/ipi.h>
-#include <asm/genapic.h>
-
-static cpumask_t flat_target_cpus(void)
-{
-       return cpu_online_map;
-}
-
-static cpumask_t flat_vector_allocation_domain(int cpu)
-{
-       /* Careful. Some cpus do not strictly honor the set of cpus
-        * specified in the interrupt destination when using lowest
-        * priority interrupt delivery mode.
-        *
-        * In particular there was a hyperthreading cpu observed to
-        * deliver interrupts to the wrong hyperthread when only one
-        * hyperthread was specified in the interrupt desitination.
-        */
-       cpumask_t domain = { { [0] = APIC_ALL_CPUS, } };
-       return domain;
-}
-
-/*
- * Set up the logical destination ID.
- *
- * Intel recommends to set DFR, LDR and TPR before enabling
- * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
- * document number 292116).  So here it goes...
- */
-static void flat_init_apic_ldr(void)
-{
-       unsigned long val;
-       unsigned long num, id;
-
-       num = smp_processor_id();
-       id = 1UL << num;
-       x86_cpu_to_log_apicid[num] = id;
-       apic_write(APIC_DFR, APIC_DFR_FLAT);
-       val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
-       val |= SET_APIC_LOGICAL_ID(id);
-       apic_write(APIC_LDR, val);
-}
-
-static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
-{
-       unsigned long mask = cpus_addr(cpumask)[0];
-       unsigned long flags;
-
-       local_irq_save(flags);
-       __send_IPI_dest_field(mask, vector, APIC_DEST_LOGICAL);
-       local_irq_restore(flags);
-}
-
-static void flat_send_IPI_allbutself(int vector)
-{
-#ifdef CONFIG_HOTPLUG_CPU
-       int hotplug = 1;
-#else
-       int hotplug = 0;
-#endif
-       if (hotplug || vector == NMI_VECTOR) {
-               cpumask_t allbutme = cpu_online_map;
-
-               cpu_clear(smp_processor_id(), allbutme);
-
-               if (!cpus_empty(allbutme))
-                       flat_send_IPI_mask(allbutme, vector);
-       } else if (num_online_cpus() > 1) {
-               __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL);
-       }
-}
-
-static void flat_send_IPI_all(int vector)
-{
-       if (vector == NMI_VECTOR)
-               flat_send_IPI_mask(cpu_online_map, vector);
-       else
-               __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
-}
-
-static int flat_apic_id_registered(void)
-{
-       return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map);
-}
-
-static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
-{
-       return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
-}
-
-static unsigned int phys_pkg_id(int index_msb)
-{
-       return hard_smp_processor_id() >> index_msb;
-}
-
-struct genapic apic_flat =  {
-       .name = "flat",
-       .int_delivery_mode = dest_LowestPrio,
-       .int_dest_mode = (APIC_DEST_LOGICAL != 0),
-       .target_cpus = flat_target_cpus,
-       .vector_allocation_domain = flat_vector_allocation_domain,
-       .apic_id_registered = flat_apic_id_registered,
-       .init_apic_ldr = flat_init_apic_ldr,
-       .send_IPI_all = flat_send_IPI_all,
-       .send_IPI_allbutself = flat_send_IPI_allbutself,
-       .send_IPI_mask = flat_send_IPI_mask,
-       .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
-       .phys_pkg_id = phys_pkg_id,
-};
-
-/*
- * Physflat mode is used when there are more than 8 CPUs on a AMD system.
- * We cannot use logical delivery in this case because the mask
- * overflows, so use physical mode.
- */
-
-static cpumask_t physflat_target_cpus(void)
-{
-       return cpu_online_map;
-}
-
-static cpumask_t physflat_vector_allocation_domain(int cpu)
-{
-       cpumask_t domain = CPU_MASK_NONE;
-       cpu_set(cpu, domain);
-       return domain;
-}
-
-
-static void physflat_send_IPI_mask(cpumask_t cpumask, int vector)
-{
-       send_IPI_mask_sequence(cpumask, vector);
-}
-
-static void physflat_send_IPI_allbutself(int vector)
-{
-       cpumask_t allbutme = cpu_online_map;
-
-       cpu_clear(smp_processor_id(), allbutme);
-       physflat_send_IPI_mask(allbutme, vector);
-}
-
-static void physflat_send_IPI_all(int vector)
-{
-       physflat_send_IPI_mask(cpu_online_map, vector);
-}
-
-static unsigned int physflat_cpu_mask_to_apicid(cpumask_t cpumask)
-{
-       int cpu;
-
-       /*
-        * We're using fixed IRQ delivery, can only return one phys APIC ID.
-        * May as well be the first.
-        */
-       cpu = first_cpu(cpumask);
-       if ((unsigned)cpu < NR_CPUS)
-               return x86_cpu_to_apicid[cpu];
-       else
-               return BAD_APICID;
-}
-
-struct genapic apic_physflat =  {
-       .name = "physical flat",
-       .int_delivery_mode = dest_Fixed,
-       .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
-       .target_cpus = physflat_target_cpus,
-       .vector_allocation_domain = physflat_vector_allocation_domain,
-       .apic_id_registered = flat_apic_id_registered,
-       .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/
-       .send_IPI_all = physflat_send_IPI_all,
-       .send_IPI_allbutself = physflat_send_IPI_allbutself,
-       .send_IPI_mask = physflat_send_IPI_mask,
-       .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
-       .phys_pkg_id = phys_pkg_id,
-};
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
deleted file mode 100644 (file)
index b6167fe..0000000
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- *  linux/arch/x86_64/kernel/head.S -- start in 32bit and switch to 64bit
- *
- *  Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
- *  Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
- *  Copyright (C) 2000 Karsten Keil <kkeil@suse.de>
- *  Copyright (C) 2001,2002 Andi Kleen <ak@suse.de>
- *  Copyright (C) 2005 Eric Biederman <ebiederm@xmission.com>
- */
-
-
-#include <linux/linkage.h>
-#include <linux/threads.h>
-#include <linux/init.h>
-#include <asm/desc.h>
-#include <asm/segment.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/msr.h>
-#include <asm/cache.h>
-
-/* we are not able to switch in one step to the final KERNEL ADRESS SPACE
- * because we need identity-mapped pages.
- *
- */
-
-       .text
-       .section .text.head
-       .code64
-       .globl startup_64
-startup_64:
-
-       /*
-        * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 1,
-        * and someone has loaded an identity mapped page table
-        * for us.  These identity mapped page tables map all of the
-        * kernel pages and possibly all of memory.
-        *
-        * %esi holds a physical pointer to real_mode_data.
-        *
-        * We come here either directly from a 64bit bootloader, or from
-        * arch/x86_64/boot/compressed/head.S.
-        *
-        * We only come here initially at boot nothing else comes here.
-        *
-        * Since we may be loaded at an address different from what we were
-        * compiled to run at we first fixup the physical addresses in our page
-        * tables and then reload them.
-        */
-
-       /* Compute the delta between the address I am compiled to run at and the
-        * address I am actually running at.
-        */
-       leaq    _text(%rip), %rbp
-       subq    $_text - __START_KERNEL_map, %rbp
-
-       /* Is the address not 2M aligned? */
-       movq    %rbp, %rax
-       andl    $~LARGE_PAGE_MASK, %eax
-       testl   %eax, %eax
-       jnz     bad_address
-
-       /* Is the address too large? */
-       leaq    _text(%rip), %rdx
-       movq    $PGDIR_SIZE, %rax
-       cmpq    %rax, %rdx
-       jae     bad_address
-
-       /* Fixup the physical addresses in the page table
-        */
-       addq    %rbp, init_level4_pgt + 0(%rip)
-       addq    %rbp, init_level4_pgt + (258*8)(%rip)
-       addq    %rbp, init_level4_pgt + (511*8)(%rip)
-
-       addq    %rbp, level3_ident_pgt + 0(%rip)
-
-       addq    %rbp, level3_kernel_pgt + (510*8)(%rip)
-       addq    %rbp, level3_kernel_pgt + (511*8)(%rip)
-
-       addq    %rbp, level2_fixmap_pgt + (506*8)(%rip)
-
-       /* Add an Identity mapping if I am above 1G */
-       leaq    _text(%rip), %rdi
-       andq    $LARGE_PAGE_MASK, %rdi
-
-       movq    %rdi, %rax
-       shrq    $PUD_SHIFT, %rax
-       andq    $(PTRS_PER_PUD - 1), %rax
-       jz      ident_complete
-
-       leaq    (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
-       leaq    level3_ident_pgt(%rip), %rbx
-       movq    %rdx, 0(%rbx, %rax, 8)
-
-       movq    %rdi, %rax
-       shrq    $PMD_SHIFT, %rax
-       andq    $(PTRS_PER_PMD - 1), %rax
-       leaq    __PAGE_KERNEL_LARGE_EXEC(%rdi), %rdx
-       leaq    level2_spare_pgt(%rip), %rbx
-       movq    %rdx, 0(%rbx, %rax, 8)
-ident_complete:
-
-       /* Fixup the kernel text+data virtual addresses
-        */
-       leaq    level2_kernel_pgt(%rip), %rdi
-       leaq    4096(%rdi), %r8
-       /* See if it is a valid page table entry */
-1:     testq   $1, 0(%rdi)
-       jz      2f
-       addq    %rbp, 0(%rdi)
-       /* Go to the next page */
-2:     addq    $8, %rdi
-       cmp     %r8, %rdi
-       jne     1b
-
-       /* Fixup phys_base */
-       addq    %rbp, phys_base(%rip)
-
-#ifdef CONFIG_SMP
-       addq    %rbp, trampoline_level4_pgt + 0(%rip)
-       addq    %rbp, trampoline_level4_pgt + (511*8)(%rip)
-#endif
-#ifdef CONFIG_ACPI_SLEEP
-       addq    %rbp, wakeup_level4_pgt + 0(%rip)
-       addq    %rbp, wakeup_level4_pgt + (511*8)(%rip)
-#endif
-
-       /* Due to ENTRY(), sometimes the empty space gets filled with
-        * zeros. Better take a jmp than relying on empty space being
-        * filled with 0x90 (nop)
-        */
-       jmp secondary_startup_64
-ENTRY(secondary_startup_64)
-       /*
-        * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 1,
-        * and someone has loaded a mapped page table.
-        *
-        * %esi holds a physical pointer to real_mode_data.
-        *
-        * We come here either from startup_64 (using physical addresses)
-        * or from trampoline.S (using virtual addresses).
-        *
-        * Using virtual addresses from trampoline.S removes the need
-        * to have any identity mapped pages in the kernel page table
-        * after the boot processor executes this code.
-        */
-
-       /* Enable PAE mode and PGE */
-       xorq    %rax, %rax
-       btsq    $5, %rax
-       btsq    $7, %rax
-       movq    %rax, %cr4
-
-       /* Setup early boot stage 4 level pagetables. */
-       movq    $(init_level4_pgt - __START_KERNEL_map), %rax
-       addq    phys_base(%rip), %rax
-       movq    %rax, %cr3
-
-       /* Ensure I am executing from virtual addresses */
-       movq    $1f, %rax
-       jmp     *%rax
-1:
-
-       /* Check if nx is implemented */
-       movl    $0x80000001, %eax
-       cpuid
-       movl    %edx,%edi
-
-       /* Setup EFER (Extended Feature Enable Register) */
-       movl    $MSR_EFER, %ecx
-       rdmsr
-       btsl    $_EFER_SCE, %eax        /* Enable System Call */
-       btl     $20,%edi                /* No Execute supported? */
-       jnc     1f
-       btsl    $_EFER_NX, %eax
-1:     wrmsr                           /* Make changes effective */
-
-       /* Setup cr0 */
-#define CR0_PM                         1               /* protected mode */
-#define CR0_MP                         (1<<1)
-#define CR0_ET                         (1<<4)
-#define CR0_NE                         (1<<5)
-#define CR0_WP                         (1<<16)
-#define CR0_AM                         (1<<18)
-#define CR0_PAGING                     (1<<31)
-       movl $CR0_PM|CR0_MP|CR0_ET|CR0_NE|CR0_WP|CR0_AM|CR0_PAGING,%eax
-       /* Make changes effective */
-       movq    %rax, %cr0
-
-       /* Setup a boot time stack */
-       movq init_rsp(%rip),%rsp
-
-       /* zero EFLAGS after setting rsp */
-       pushq $0
-       popfq
-
-       /*
-        * We must switch to a new descriptor in kernel space for the GDT
-        * because soon the kernel won't have access anymore to the userspace
-        * addresses where we're currently running on. We have to do that here
-        * because in 32bit we couldn't load a 64bit linear address.
-        */
-       lgdt    cpu_gdt_descr(%rip)
-
-       /* set up data segments. actually 0 would do too */
-       movl $__KERNEL_DS,%eax
-       movl %eax,%ds
-       movl %eax,%ss
-       movl %eax,%es
-
-       /*
-        * We don't really need to load %fs or %gs, but load them anyway
-        * to kill any stale realmode selectors.  This allows execution
-        * under VT hardware.
-        */
-       movl %eax,%fs
-       movl %eax,%gs
-
-       /* 
-        * Setup up a dummy PDA. this is just for some early bootup code
-        * that does in_interrupt() 
-        */ 
-       movl    $MSR_GS_BASE,%ecx
-       movq    $empty_zero_page,%rax
-       movq    %rax,%rdx
-       shrq    $32,%rdx
-       wrmsr   
-
-       /* esi is pointer to real mode structure with interesting info.
-          pass it to C */
-       movl    %esi, %edi
-       
-       /* Finally jump to run C code and to be on real kernel address
-        * Since we are running on identity-mapped space we have to jump
-        * to the full 64bit address, this is only possible as indirect
-        * jump.  In addition we need to ensure %cs is set so we make this
-        * a far return.
-        */
-       movq    initial_code(%rip),%rax
-       pushq   $0              # fake return address to stop unwinder
-       pushq   $__KERNEL_CS    # set correct cs
-       pushq   %rax            # target address in negative space
-       lretq
-
-       /* SMP bootup changes these two */
-#ifndef CONFIG_HOTPLUG_CPU
-       .pushsection .init.data
-#endif
-       .align  8
-       .globl  initial_code
-initial_code:
-       .quad   x86_64_start_kernel
-#ifndef CONFIG_HOTPLUG_CPU
-       .popsection
-#endif
-       .globl init_rsp
-init_rsp:
-       .quad  init_thread_union+THREAD_SIZE-8
-
-bad_address:
-       jmp bad_address
-
-ENTRY(early_idt_handler)
-       cmpl $2,early_recursion_flag(%rip)
-       jz  1f
-       incl early_recursion_flag(%rip)
-       xorl %eax,%eax
-       movq 8(%rsp),%rsi       # get rip
-       movq (%rsp),%rdx
-       movq %cr2,%rcx
-       leaq early_idt_msg(%rip),%rdi
-       call early_printk
-       cmpl $2,early_recursion_flag(%rip)
-       jz  1f
-       call dump_stack
-#ifdef CONFIG_KALLSYMS 
-       leaq early_idt_ripmsg(%rip),%rdi
-       movq 8(%rsp),%rsi       # get rip again
-       call __print_symbol
-#endif
-1:     hlt
-       jmp 1b
-early_recursion_flag:
-       .long 0
-
-early_idt_msg:
-       .asciz "PANIC: early exception rip %lx error %lx cr2 %lx\n"
-early_idt_ripmsg:
-       .asciz "RIP %s\n"
-
-.balign PAGE_SIZE
-
-#define NEXT_PAGE(name) \
-       .balign PAGE_SIZE; \
-ENTRY(name)
-
-/* Automate the creation of 1 to 1 mapping pmd entries */
-#define PMDS(START, PERM, COUNT)               \
-       i = 0 ;                                 \
-       .rept (COUNT) ;                         \
-       .quad   (START) + (i << 21) + (PERM) ;  \
-       i = i + 1 ;                             \
-       .endr
-
-       /*
-        * This default setting generates an ident mapping at address 0x100000
-        * and a mapping for the kernel that precisely maps virtual address
-        * 0xffffffff80000000 to physical address 0x000000. (always using
-        * 2Mbyte large pages provided by PAE mode)
-        */
-NEXT_PAGE(init_level4_pgt)
-       .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .fill   257,8,0
-       .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .fill   252,8,0
-       /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
-       .quad   level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
-
-NEXT_PAGE(level3_ident_pgt)
-       .quad   level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .fill   511,8,0
-
-NEXT_PAGE(level3_kernel_pgt)
-       .fill   510,8,0
-       /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
-       .quad   level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .quad   level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
-
-NEXT_PAGE(level2_fixmap_pgt)
-       .fill   506,8,0
-       .quad   level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
-       /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
-       .fill   5,8,0
-
-NEXT_PAGE(level1_fixmap_pgt)
-       .fill   512,8,0
-
-NEXT_PAGE(level2_ident_pgt)
-       /* Since I easily can, map the first 1G.
-        * Don't set NX because code runs from these pages.
-        */
-       PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD)
-
-NEXT_PAGE(level2_kernel_pgt)
-       /* 40MB kernel mapping. The kernel code cannot be bigger than that.
-          When you change this change KERNEL_TEXT_SIZE in page.h too. */
-       /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */
-       PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL, KERNEL_TEXT_SIZE/PMD_SIZE)
-       /* Module mapping starts here */
-       .fill   (PTRS_PER_PMD - (KERNEL_TEXT_SIZE/PMD_SIZE)),8,0
-
-NEXT_PAGE(level2_spare_pgt)
-       .fill   512,8,0
-
-#undef PMDS
-#undef NEXT_PAGE
-
-       .data
-       .align 16
-       .globl cpu_gdt_descr
-cpu_gdt_descr:
-       .word   gdt_end-cpu_gdt_table-1
-gdt:
-       .quad   cpu_gdt_table
-#ifdef CONFIG_SMP
-       .rept   NR_CPUS-1
-       .word   0
-       .quad   0
-       .endr
-#endif
-
-ENTRY(phys_base)
-       /* This must match the first entry in level2_kernel_pgt */
-       .quad   0x0000000000000000
-
-/* We need valid kernel segments for data and code in long mode too
- * IRET will check the segment types  kkeil 2000/10/28
- * Also sysret mandates a special GDT layout 
- */
-                               
-       .section .data.page_aligned, "aw"
-       .align PAGE_SIZE
-
-/* The TLS descriptors are currently at a different place compared to i386.
-   Hopefully nobody expects them at a fixed place (Wine?) */
-       
-ENTRY(cpu_gdt_table)
-       .quad   0x0000000000000000      /* NULL descriptor */
-       .quad   0x00cf9b000000ffff      /* __KERNEL32_CS */
-       .quad   0x00af9b000000ffff      /* __KERNEL_CS */
-       .quad   0x00cf93000000ffff      /* __KERNEL_DS */
-       .quad   0x00cffb000000ffff      /* __USER32_CS */
-       .quad   0x00cff3000000ffff      /* __USER_DS, __USER32_DS  */
-       .quad   0x00affb000000ffff      /* __USER_CS */
-       .quad   0x0                     /* unused */
-       .quad   0,0                     /* TSS */
-       .quad   0,0                     /* LDT */
-       .quad   0,0,0                   /* three TLS descriptors */ 
-       .quad   0x0000f40000000000      /* node/CPU stored in limit */
-gdt_end:       
-       /* asm/segment.h:GDT_ENTRIES must match this */ 
-       /* This should be a multiple of the cache line size */
-       /* GDTs of other CPUs are now dynamically allocated */
-
-       /* zero the remaining page */
-       .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
-
-       .section .bss, "aw", @nobits
-       .align L1_CACHE_BYTES
-ENTRY(idt_table)
-       .skip 256 * 16
-
-       .section .bss.page_aligned, "aw", @nobits
-       .align PAGE_SIZE
-ENTRY(empty_zero_page)
-       .skip PAGE_SIZE
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
deleted file mode 100644 (file)
index 6c34bdd..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *  linux/arch/x86_64/kernel/head64.c -- prepare to run common code
- *
- *  Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
- */
-
-#include <linux/init.h>
-#include <linux/linkage.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/percpu.h>
-
-#include <asm/processor.h>
-#include <asm/proto.h>
-#include <asm/smp.h>
-#include <asm/bootsetup.h>
-#include <asm/setup.h>
-#include <asm/desc.h>
-#include <asm/pgtable.h>
-#include <asm/tlbflush.h>
-#include <asm/sections.h>
-
-static void __init zap_identity_mappings(void)
-{
-       pgd_t *pgd = pgd_offset_k(0UL);
-       pgd_clear(pgd);
-       __flush_tlb();
-}
-
-/* Don't add a printk in there. printk relies on the PDA which is not initialized 
-   yet. */
-static void __init clear_bss(void)
-{
-       memset(__bss_start, 0,
-              (unsigned long) __bss_stop - (unsigned long) __bss_start);
-}
-
-#define NEW_CL_POINTER         0x228   /* Relative to real mode data */
-#define OLD_CL_MAGIC_ADDR      0x20
-#define OLD_CL_MAGIC            0xA33F
-#define OLD_CL_OFFSET           0x22
-
-static void __init copy_bootdata(char *real_mode_data)
-{
-       unsigned long new_data;
-       char * command_line;
-
-       memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
-       new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER);
-       if (!new_data) {
-               if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) {
-                       return;
-               }
-               new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET);
-       }
-       command_line = __va(new_data);
-       memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
-}
-
-void __init x86_64_start_kernel(char * real_mode_data)
-{
-       int i;
-
-       /* clear bss before set_intr_gate with early_idt_handler */
-       clear_bss();
-
-       /* Make NULL pointers segfault */
-       zap_identity_mappings();
-
-       for (i = 0; i < IDT_ENTRIES; i++)
-               set_intr_gate(i, early_idt_handler);
-       asm volatile("lidt %0" :: "m" (idt_descr));
-
-       early_printk("Kernel alive\n");
-
-       for (i = 0; i < NR_CPUS; i++)
-               cpu_pda(i) = &boot_cpu_pda[i];
-
-       pda_init(0);
-       copy_bootdata(__va(real_mode_data));
-#ifdef CONFIG_SMP
-       cpu_set(0, cpu_online_map);
-#endif
-       start_kernel();
-}
diff --git a/arch/x86_64/kernel/hpet.c b/arch/x86_64/kernel/hpet.c
deleted file mode 100644 (file)
index e2d1b91..0000000
+++ /dev/null
@@ -1,493 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/mc146818rtc.h>
-#include <linux/time.h>
-#include <linux/clocksource.h>
-#include <linux/ioport.h>
-#include <linux/acpi.h>
-#include <linux/hpet.h>
-#include <asm/pgtable.h>
-#include <asm/vsyscall.h>
-#include <asm/timex.h>
-#include <asm/hpet.h>
-
-#define HPET_MASK      0xFFFFFFFF
-#define HPET_SHIFT     22
-
-/* FSEC = 10^-15 NSEC = 10^-9 */
-#define FSEC_PER_NSEC  1000000
-
-int nohpet __initdata;
-
-unsigned long hpet_address;
-unsigned long hpet_period;     /* fsecs / HPET clock */
-unsigned long hpet_tick;       /* HPET clocks / interrupt */
-
-int hpet_use_timer;            /* Use counter of hpet for time keeping,
-                                * otherwise PIT
-                                */
-
-#ifdef CONFIG_HPET
-static __init int late_hpet_init(void)
-{
-       struct hpet_data        hd;
-       unsigned int            ntimer;
-
-       if (!hpet_address)
-               return 0;
-
-       memset(&hd, 0, sizeof(hd));
-
-       ntimer = hpet_readl(HPET_ID);
-       ntimer = (ntimer & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT;
-       ntimer++;
-
-       /*
-        * Register with driver.
-        * Timer0 and Timer1 is used by platform.
-        */
-       hd.hd_phys_address = hpet_address;
-       hd.hd_address = (void __iomem *)fix_to_virt(FIX_HPET_BASE);
-       hd.hd_nirqs = ntimer;
-       hd.hd_flags = HPET_DATA_PLATFORM;
-       hpet_reserve_timer(&hd, 0);
-#ifdef CONFIG_HPET_EMULATE_RTC
-       hpet_reserve_timer(&hd, 1);
-#endif
-       hd.hd_irq[0] = HPET_LEGACY_8254;
-       hd.hd_irq[1] = HPET_LEGACY_RTC;
-       if (ntimer > 2) {
-               struct hpet             *hpet;
-               struct hpet_timer       *timer;
-               int                     i;
-
-               hpet = (struct hpet *) fix_to_virt(FIX_HPET_BASE);
-               timer = &hpet->hpet_timers[2];
-               for (i = 2; i < ntimer; timer++, i++)
-                       hd.hd_irq[i] = (timer->hpet_config &
-                                       Tn_INT_ROUTE_CNF_MASK) >>
-                               Tn_INT_ROUTE_CNF_SHIFT;
-
-       }
-
-       hpet_alloc(&hd);
-       return 0;
-}
-fs_initcall(late_hpet_init);
-#endif
-
-int hpet_timer_stop_set_go(unsigned long tick)
-{
-       unsigned int cfg;
-
-/*
- * Stop the timers and reset the main counter.
- */
-
-       cfg = hpet_readl(HPET_CFG);
-       cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY);
-       hpet_writel(cfg, HPET_CFG);
-       hpet_writel(0, HPET_COUNTER);
-       hpet_writel(0, HPET_COUNTER + 4);
-
-/*
- * Set up timer 0, as periodic with first interrupt to happen at hpet_tick,
- * and period also hpet_tick.
- */
-       if (hpet_use_timer) {
-               hpet_writel(HPET_TN_ENABLE | HPET_TN_PERIODIC | HPET_TN_SETVAL |
-                   HPET_TN_32BIT, HPET_T0_CFG);
-               hpet_writel(hpet_tick, HPET_T0_CMP); /* next interrupt */
-               hpet_writel(hpet_tick, HPET_T0_CMP); /* period */
-               cfg |= HPET_CFG_LEGACY;
-       }
-/*
- * Go!
- */
-
-       cfg |= HPET_CFG_ENABLE;
-       hpet_writel(cfg, HPET_CFG);
-
-       return 0;
-}
-
-static cycle_t read_hpet(void)
-{
-       return (cycle_t)hpet_readl(HPET_COUNTER);
-}
-
-static cycle_t __vsyscall_fn vread_hpet(void)
-{
-       return readl((void __iomem *)fix_to_virt(VSYSCALL_HPET) + 0xf0);
-}
-
-struct clocksource clocksource_hpet = {
-       .name           = "hpet",
-       .rating         = 250,
-       .read           = read_hpet,
-       .mask           = (cycle_t)HPET_MASK,
-       .mult           = 0, /* set below */
-       .shift          = HPET_SHIFT,
-       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
-       .vread          = vread_hpet,
-};
-
-int __init hpet_arch_init(void)
-{
-       unsigned int id;
-       u64 tmp;
-
-       if (!hpet_address)
-               return -1;
-       set_fixmap_nocache(FIX_HPET_BASE, hpet_address);
-       __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VSYSCALL_NOCACHE);
-
-/*
- * Read the period, compute tick and quotient.
- */
-
-       id = hpet_readl(HPET_ID);
-
-       if (!(id & HPET_ID_VENDOR) || !(id & HPET_ID_NUMBER))
-               return -1;
-
-       hpet_period = hpet_readl(HPET_PERIOD);
-       if (hpet_period < 100000 || hpet_period > 100000000)
-               return -1;
-
-       hpet_tick = (FSEC_PER_TICK + hpet_period / 2) / hpet_period;
-
-       hpet_use_timer = (id & HPET_ID_LEGSUP);
-
-       /*
-        * hpet period is in femto seconds per cycle
-        * so we need to convert this to ns/cyc units
-        * aproximated by mult/2^shift
-        *
-        *  fsec/cyc * 1nsec/1000000fsec = nsec/cyc = mult/2^shift
-        *  fsec/cyc * 1ns/1000000fsec * 2^shift = mult
-        *  fsec/cyc * 2^shift * 1nsec/1000000fsec = mult
-        *  (fsec/cyc << shift)/1000000 = mult
-        *  (hpet_period << shift)/FSEC_PER_NSEC = mult
-        */
-       tmp = (u64)hpet_period << HPET_SHIFT;
-       do_div(tmp, FSEC_PER_NSEC);
-       clocksource_hpet.mult = (u32)tmp;
-       clocksource_register(&clocksource_hpet);
-
-       return hpet_timer_stop_set_go(hpet_tick);
-}
-
-int hpet_reenable(void)
-{
-       return hpet_timer_stop_set_go(hpet_tick);
-}
-
-/*
- * calibrate_tsc() calibrates the processor TSC in a very simple way, comparing
- * it to the HPET timer of known frequency.
- */
-
-#define TICK_COUNT 100000000
-#define SMI_THRESHOLD 50000
-#define MAX_TRIES  5
-
-/*
- * Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
- * occurs between the reads of the hpet & TSC.
- */
-static void __init read_hpet_tsc(int *hpet, int *tsc)
-{
-       int tsc1, tsc2, hpet1, i;
-
-       for (i = 0; i < MAX_TRIES; i++) {
-               tsc1 = get_cycles_sync();
-               hpet1 = hpet_readl(HPET_COUNTER);
-               tsc2 = get_cycles_sync();
-               if ((tsc2 - tsc1) < SMI_THRESHOLD)
-                       break;
-       }
-       *hpet = hpet1;
-       *tsc = tsc2;
-}
-
-unsigned int __init hpet_calibrate_tsc(void)
-{
-       int tsc_start, hpet_start;
-       int tsc_now, hpet_now;
-       unsigned long flags;
-
-       local_irq_save(flags);
-
-       read_hpet_tsc(&hpet_start, &tsc_start);
-
-       do {
-               local_irq_disable();
-               read_hpet_tsc(&hpet_now, &tsc_now);
-               local_irq_restore(flags);
-       } while ((tsc_now - tsc_start) < TICK_COUNT &&
-               (hpet_now - hpet_start) < TICK_COUNT);
-
-       return (tsc_now - tsc_start) * 1000000000L
-               / ((hpet_now - hpet_start) * hpet_period / 1000);
-}
-
-#ifdef CONFIG_HPET_EMULATE_RTC
-/* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
- * is enabled, we support RTC interrupt functionality in software.
- * RTC has 3 kinds of interrupts:
- * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
- *    is updated
- * 2) Alarm Interrupt - generate an interrupt at a specific time of day
- * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
- *    2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
- * (1) and (2) above are implemented using polling at a frequency of
- * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
- * overhead. (DEFAULT_RTC_INT_FREQ)
- * For (3), we use interrupts at 64Hz or user specified periodic
- * frequency, whichever is higher.
- */
-#include <linux/rtc.h>
-
-#define DEFAULT_RTC_INT_FREQ   64
-#define RTC_NUM_INTS           1
-
-static unsigned long UIE_on;
-static unsigned long prev_update_sec;
-
-static unsigned long AIE_on;
-static struct rtc_time alarm_time;
-
-static unsigned long PIE_on;
-static unsigned long PIE_freq = DEFAULT_RTC_INT_FREQ;
-static unsigned long PIE_count;
-
-static unsigned long hpet_rtc_int_freq; /* RTC interrupt frequency */
-static unsigned int hpet_t1_cmp; /* cached comparator register */
-
-int is_hpet_enabled(void)
-{
-       return hpet_address != 0;
-}
-
-/*
- * Timer 1 for RTC, we do not use periodic interrupt feature,
- * even if HPET supports periodic interrupts on Timer 1.
- * The reason being, to set up a periodic interrupt in HPET, we need to
- * stop the main counter. And if we do that everytime someone diables/enables
- * RTC, we will have adverse effect on main kernel timer running on Timer 0.
- * So, for the time being, simulate the periodic interrupt in software.
- *
- * hpet_rtc_timer_init() is called for the first time and during subsequent
- * interuppts reinit happens through hpet_rtc_timer_reinit().
- */
-int hpet_rtc_timer_init(void)
-{
-       unsigned int cfg, cnt;
-       unsigned long flags;
-
-       if (!is_hpet_enabled())
-               return 0;
-       /*
-        * Set the counter 1 and enable the interrupts.
-        */
-       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
-               hpet_rtc_int_freq = PIE_freq;
-       else
-               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
-
-       local_irq_save(flags);
-
-       cnt = hpet_readl(HPET_COUNTER);
-       cnt += ((hpet_tick*HZ)/hpet_rtc_int_freq);
-       hpet_writel(cnt, HPET_T1_CMP);
-       hpet_t1_cmp = cnt;
-
-       cfg = hpet_readl(HPET_T1_CFG);
-       cfg &= ~HPET_TN_PERIODIC;
-       cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
-       hpet_writel(cfg, HPET_T1_CFG);
-
-       local_irq_restore(flags);
-
-       return 1;
-}
-
-static void hpet_rtc_timer_reinit(void)
-{
-       unsigned int cfg, cnt, ticks_per_int, lost_ints;
-
-       if (unlikely(!(PIE_on | AIE_on | UIE_on))) {
-               cfg = hpet_readl(HPET_T1_CFG);
-               cfg &= ~HPET_TN_ENABLE;
-               hpet_writel(cfg, HPET_T1_CFG);
-               return;
-       }
-
-       if (PIE_on && (PIE_freq > DEFAULT_RTC_INT_FREQ))
-               hpet_rtc_int_freq = PIE_freq;
-       else
-               hpet_rtc_int_freq = DEFAULT_RTC_INT_FREQ;
-
-       /* It is more accurate to use the comparator value than current count.*/
-       ticks_per_int = hpet_tick * HZ / hpet_rtc_int_freq;
-       hpet_t1_cmp += ticks_per_int;
-       hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
-
-       /*
-        * If the interrupt handler was delayed too long, the write above tries
-        * to schedule the next interrupt in the past and the hardware would
-        * not interrupt until the counter had wrapped around.
-        * So we have to check that the comparator wasn't set to a past time.
-        */
-       cnt = hpet_readl(HPET_COUNTER);
-       if (unlikely((int)(cnt - hpet_t1_cmp) > 0)) {
-               lost_ints = (cnt - hpet_t1_cmp) / ticks_per_int + 1;
-               /* Make sure that, even with the time needed to execute
-                * this code, the next scheduled interrupt has been moved
-                * back to the future: */
-               lost_ints++;
-
-               hpet_t1_cmp += lost_ints * ticks_per_int;
-               hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
-
-               if (PIE_on)
-                       PIE_count += lost_ints;
-
-               if (printk_ratelimit())
-                       printk(KERN_WARNING "rtc: lost some interrupts at %ldHz.\n",
-                              hpet_rtc_int_freq);
-       }
-}
-
-/*
- * The functions below are called from rtc driver.
- * Return 0 if HPET is not being used.
- * Otherwise do the necessary changes and return 1.
- */
-int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
-{
-       if (!is_hpet_enabled())
-               return 0;
-
-       if (bit_mask & RTC_UIE)
-               UIE_on = 0;
-       if (bit_mask & RTC_PIE)
-               PIE_on = 0;
-       if (bit_mask & RTC_AIE)
-               AIE_on = 0;
-
-       return 1;
-}
-
-int hpet_set_rtc_irq_bit(unsigned long bit_mask)
-{
-       int timer_init_reqd = 0;
-
-       if (!is_hpet_enabled())
-               return 0;
-
-       if (!(PIE_on | AIE_on | UIE_on))
-               timer_init_reqd = 1;
-
-       if (bit_mask & RTC_UIE) {
-               UIE_on = 1;
-       }
-       if (bit_mask & RTC_PIE) {
-               PIE_on = 1;
-               PIE_count = 0;
-       }
-       if (bit_mask & RTC_AIE) {
-               AIE_on = 1;
-       }
-
-       if (timer_init_reqd)
-               hpet_rtc_timer_init();
-
-       return 1;
-}
-
-int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
-{
-       if (!is_hpet_enabled())
-               return 0;
-
-       alarm_time.tm_hour = hrs;
-       alarm_time.tm_min = min;
-       alarm_time.tm_sec = sec;
-
-       return 1;
-}
-
-int hpet_set_periodic_freq(unsigned long freq)
-{
-       if (!is_hpet_enabled())
-               return 0;
-
-       PIE_freq = freq;
-       PIE_count = 0;
-
-       return 1;
-}
-
-int hpet_rtc_dropped_irq(void)
-{
-       if (!is_hpet_enabled())
-               return 0;
-
-       return 1;
-}
-
-irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
-{
-       struct rtc_time curr_time;
-       unsigned long rtc_int_flag = 0;
-       int call_rtc_interrupt = 0;
-
-       hpet_rtc_timer_reinit();
-
-       if (UIE_on | AIE_on) {
-               rtc_get_rtc_time(&curr_time);
-       }
-       if (UIE_on) {
-               if (curr_time.tm_sec != prev_update_sec) {
-                       /* Set update int info, call real rtc int routine */
-                       call_rtc_interrupt = 1;
-                       rtc_int_flag = RTC_UF;
-                       prev_update_sec = curr_time.tm_sec;
-               }
-       }
-       if (PIE_on) {
-               PIE_count++;
-               if (PIE_count >= hpet_rtc_int_freq/PIE_freq) {
-                       /* Set periodic int info, call real rtc int routine */
-                       call_rtc_interrupt = 1;
-                       rtc_int_flag |= RTC_PF;
-                       PIE_count = 0;
-               }
-       }
-       if (AIE_on) {
-               if ((curr_time.tm_sec == alarm_time.tm_sec) &&
-                   (curr_time.tm_min == alarm_time.tm_min) &&
-                   (curr_time.tm_hour == alarm_time.tm_hour)) {
-                       /* Set alarm int info, call real rtc int routine */
-                       call_rtc_interrupt = 1;
-                       rtc_int_flag |= RTC_AF;
-               }
-       }
-       if (call_rtc_interrupt) {
-               rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
-               rtc_interrupt(rtc_int_flag, dev_id);
-       }
-       return IRQ_HANDLED;
-}
-#endif
-
-static int __init nohpet_setup(char *s)
-{
-       nohpet = 1;
-       return 1;
-}
-
-__setup("nohpet", nohpet_setup);
diff --git a/arch/x86_64/kernel/i387.c b/arch/x86_64/kernel/i387.c
deleted file mode 100644 (file)
index 1d58c13..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- *  linux/arch/x86_64/kernel/i387.c
- *
- *  Copyright (C) 1994 Linus Torvalds
- *  Copyright (C) 2002 Andi Kleen, SuSE Labs
- *
- *  Pentium III FXSR, SSE support
- *  General FPU state handling cleanups
- *     Gareth Hughes <gareth@valinux.com>, May 2000
- * 
- *  x86-64 rework 2002 Andi Kleen. 
- *  Does direct fxsave in and out of user space now for signal handlers.
- *  All the FSAVE<->FXSAVE conversion code has been moved to the 32bit emulation,
- *  the 64bit user space sees a FXSAVE frame directly. 
- */
-
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <asm/processor.h>
-#include <asm/i387.h>
-#include <asm/sigcontext.h>
-#include <asm/user.h>
-#include <asm/ptrace.h>
-#include <asm/uaccess.h>
-
-unsigned int mxcsr_feature_mask __read_mostly = 0xffffffff;
-
-void mxcsr_feature_mask_init(void)
-{
-       unsigned int mask;
-       clts();
-       memset(&current->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct));
-       asm volatile("fxsave %0" : : "m" (current->thread.i387.fxsave));
-       mask = current->thread.i387.fxsave.mxcsr_mask;
-       if (mask == 0) mask = 0x0000ffbf;
-       mxcsr_feature_mask &= mask;
-       stts();
-}
-
-/*
- * Called at bootup to set up the initial FPU state that is later cloned
- * into all processes.
- */
-void __cpuinit fpu_init(void)
-{
-       unsigned long oldcr0 = read_cr0();
-       extern void __bad_fxsave_alignment(void);
-               
-       if (offsetof(struct task_struct, thread.i387.fxsave) & 15)
-               __bad_fxsave_alignment();
-       set_in_cr4(X86_CR4_OSFXSR);
-       set_in_cr4(X86_CR4_OSXMMEXCPT);
-
-       write_cr0(oldcr0 & ~((1UL<<3)|(1UL<<2))); /* clear TS and EM */
-
-       mxcsr_feature_mask_init();
-       /* clean state in init */
-       current_thread_info()->status = 0;
-       clear_used_math();
-}
-
-void init_fpu(struct task_struct *child)
-{
-       if (tsk_used_math(child)) {
-               if (child == current)
-                       unlazy_fpu(child);
-               return;
-       }       
-       memset(&child->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct));
-       child->thread.i387.fxsave.cwd = 0x37f;
-       child->thread.i387.fxsave.mxcsr = 0x1f80;
-       /* only the device not available exception or ptrace can call init_fpu */
-       set_stopped_child_used_math(child);
-}
-
-/*
- * Signal frame handlers.
- */
-
-int save_i387(struct _fpstate __user *buf)
-{
-       struct task_struct *tsk = current;
-       int err = 0;
-
-       BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
-                       sizeof(tsk->thread.i387.fxsave));
-
-       if ((unsigned long)buf % 16) 
-               printk("save_i387: bad fpstate %p\n",buf); 
-
-       if (!used_math())
-               return 0;
-       clear_used_math(); /* trigger finit */
-       if (task_thread_info(tsk)->status & TS_USEDFPU) {
-               err = save_i387_checking((struct i387_fxsave_struct __user *)buf);
-               if (err) return err;
-               stts();
-               } else {
-               if (__copy_to_user(buf, &tsk->thread.i387.fxsave, 
-                                  sizeof(struct i387_fxsave_struct)))
-                       return -1;
-       } 
-               return 1;
-}
-
-/*
- * ptrace request handlers.
- */
-
-int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *tsk)
-{
-       init_fpu(tsk);
-       return __copy_to_user(buf, &tsk->thread.i387.fxsave,
-                              sizeof(struct user_i387_struct)) ? -EFAULT : 0;
-}
-
-int set_fpregs(struct task_struct *tsk, struct user_i387_struct __user *buf)
-{
-       if (__copy_from_user(&tsk->thread.i387.fxsave, buf, 
-                            sizeof(struct user_i387_struct)))
-               return -EFAULT;
-               return 0;
-}
-
-/*
- * FPU state for core dumps.
- */
-
-int dump_fpu( struct pt_regs *regs, struct user_i387_struct *fpu )
-{
-       struct task_struct *tsk = current;
-
-       if (!used_math())
-               return 0;
-
-       unlazy_fpu(tsk);
-       memcpy(fpu, &tsk->thread.i387.fxsave, sizeof(struct user_i387_struct)); 
-       return 1; 
-}
-
-int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu)
-{
-       int fpvalid = !!tsk_used_math(tsk);
-
-       if (fpvalid) {
-               if (tsk == current)
-                       unlazy_fpu(tsk);
-               memcpy(fpu, &tsk->thread.i387.fxsave, sizeof(struct user_i387_struct));         
-}
-       return fpvalid;
-}
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
deleted file mode 100644 (file)
index 948cae6..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-#include <linux/linkage.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/timex.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/init.h>
-#include <linux/kernel_stat.h>
-#include <linux/sysdev.h>
-#include <linux/bitops.h>
-
-#include <asm/acpi.h>
-#include <asm/atomic.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/hw_irq.h>
-#include <asm/pgtable.h>
-#include <asm/delay.h>
-#include <asm/desc.h>
-#include <asm/apic.h>
-
-/*
- * Common place to define all x86 IRQ vectors
- *
- * This builds up the IRQ handler stubs using some ugly macros in irq.h
- *
- * These macros create the low-level assembly IRQ routines that save
- * register context and call do_IRQ(). do_IRQ() then does all the
- * operations that are needed to keep the AT (or SMP IOAPIC)
- * interrupt-controller happy.
- */
-
-#define BI(x,y) \
-       BUILD_IRQ(x##y)
-
-#define BUILD_16_IRQS(x) \
-       BI(x,0) BI(x,1) BI(x,2) BI(x,3) \
-       BI(x,4) BI(x,5) BI(x,6) BI(x,7) \
-       BI(x,8) BI(x,9) BI(x,a) BI(x,b) \
-       BI(x,c) BI(x,d) BI(x,e) BI(x,f)
-
-/*
- * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
- * (these are usually mapped to vectors 0x30-0x3f)
- */
-
-/*
- * The IO-APIC gives us many more interrupt sources. Most of these 
- * are unused but an SMP system is supposed to have enough memory ...
- * sometimes (mostly wrt. hw bugs) we get corrupted vectors all
- * across the spectrum, so we really want to be prepared to get all
- * of these. Plus, more powerful systems might have more than 64
- * IO-APIC registers.
- *
- * (these are usually mapped into the 0x30-0xff vector range)
- */
-                                     BUILD_16_IRQS(0x2) BUILD_16_IRQS(0x3)
-BUILD_16_IRQS(0x4) BUILD_16_IRQS(0x5) BUILD_16_IRQS(0x6) BUILD_16_IRQS(0x7)
-BUILD_16_IRQS(0x8) BUILD_16_IRQS(0x9) BUILD_16_IRQS(0xa) BUILD_16_IRQS(0xb)
-BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd) BUILD_16_IRQS(0xe) BUILD_16_IRQS(0xf)
-
-#undef BUILD_16_IRQS
-#undef BI
-
-
-#define IRQ(x,y) \
-       IRQ##x##y##_interrupt
-
-#define IRQLIST_16(x) \
-       IRQ(x,0), IRQ(x,1), IRQ(x,2), IRQ(x,3), \
-       IRQ(x,4), IRQ(x,5), IRQ(x,6), IRQ(x,7), \
-       IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
-       IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f)
-
-/* for the irq vectors */
-static void (*interrupt[NR_VECTORS - FIRST_EXTERNAL_VECTOR])(void) = {
-                                         IRQLIST_16(0x2), IRQLIST_16(0x3),
-       IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
-       IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
-       IRQLIST_16(0xc), IRQLIST_16(0xd), IRQLIST_16(0xe), IRQLIST_16(0xf)
-};
-
-#undef IRQ
-#undef IRQLIST_16
-
-/*
- * This is the 'legacy' 8259A Programmable Interrupt Controller,
- * present in the majority of PC/AT boxes.
- * plus some generic x86 specific things if generic specifics makes
- * any sense at all.
- * this file should become arch/i386/kernel/irq.c when the old irq.c
- * moves to arch independent land
- */
-
-static int i8259A_auto_eoi;
-DEFINE_SPINLOCK(i8259A_lock);
-static void mask_and_ack_8259A(unsigned int);
-
-static struct irq_chip i8259A_chip = {
-       .name           = "XT-PIC",
-       .mask           = disable_8259A_irq,
-       .disable        = disable_8259A_irq,
-       .unmask         = enable_8259A_irq,
-       .mask_ack       = mask_and_ack_8259A,
-};
-
-/*
- * 8259A PIC functions to handle ISA devices:
- */
-
-/*
- * This contains the irq mask for both 8259A irq controllers,
- */
-static unsigned int cached_irq_mask = 0xffff;
-
-#define __byte(x,y)    (((unsigned char *)&(y))[x])
-#define cached_21      (__byte(0,cached_irq_mask))
-#define cached_A1      (__byte(1,cached_irq_mask))
-
-/*
- * Not all IRQs can be routed through the IO-APIC, eg. on certain (older)
- * boards the timer interrupt is not really connected to any IO-APIC pin,
- * it's fed to the master 8259A's IR0 line only.
- *
- * Any '1' bit in this mask means the IRQ is routed through the IO-APIC.
- * this 'mixed mode' IRQ handling costs nothing because it's only used
- * at IRQ setup time.
- */
-unsigned long io_apic_irqs;
-
-void disable_8259A_irq(unsigned int irq)
-{
-       unsigned int mask = 1 << irq;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-       cached_irq_mask |= mask;
-       if (irq & 8)
-               outb(cached_A1,0xA1);
-       else
-               outb(cached_21,0x21);
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-}
-
-void enable_8259A_irq(unsigned int irq)
-{
-       unsigned int mask = ~(1 << irq);
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-       cached_irq_mask &= mask;
-       if (irq & 8)
-               outb(cached_A1,0xA1);
-       else
-               outb(cached_21,0x21);
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-}
-
-int i8259A_irq_pending(unsigned int irq)
-{
-       unsigned int mask = 1<<irq;
-       unsigned long flags;
-       int ret;
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-       if (irq < 8)
-               ret = inb(0x20) & mask;
-       else
-               ret = inb(0xA0) & (mask >> 8);
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-
-       return ret;
-}
-
-void make_8259A_irq(unsigned int irq)
-{
-       disable_irq_nosync(irq);
-       io_apic_irqs &= ~(1<<irq);
-       set_irq_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
-                                     "XT");
-       enable_irq(irq);
-}
-
-/*
- * This function assumes to be called rarely. Switching between
- * 8259A registers is slow.
- * This has to be protected by the irq controller spinlock
- * before being called.
- */
-static inline int i8259A_irq_real(unsigned int irq)
-{
-       int value;
-       int irqmask = 1<<irq;
-
-       if (irq < 8) {
-               outb(0x0B,0x20);                /* ISR register */
-               value = inb(0x20) & irqmask;
-               outb(0x0A,0x20);                /* back to the IRR register */
-               return value;
-       }
-       outb(0x0B,0xA0);                /* ISR register */
-       value = inb(0xA0) & (irqmask >> 8);
-       outb(0x0A,0xA0);                /* back to the IRR register */
-       return value;
-}
-
-/*
- * Careful! The 8259A is a fragile beast, it pretty
- * much _has_ to be done exactly like this (mask it
- * first, _then_ send the EOI, and the order of EOI
- * to the two 8259s is important!
- */
-static void mask_and_ack_8259A(unsigned int irq)
-{
-       unsigned int irqmask = 1 << irq;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-       /*
-        * Lightweight spurious IRQ detection. We do not want
-        * to overdo spurious IRQ handling - it's usually a sign
-        * of hardware problems, so we only do the checks we can
-        * do without slowing down good hardware unnecessarily.
-        *
-        * Note that IRQ7 and IRQ15 (the two spurious IRQs
-        * usually resulting from the 8259A-1|2 PICs) occur
-        * even if the IRQ is masked in the 8259A. Thus we
-        * can check spurious 8259A IRQs without doing the
-        * quite slow i8259A_irq_real() call for every IRQ.
-        * This does not cover 100% of spurious interrupts,
-        * but should be enough to warn the user that there
-        * is something bad going on ...
-        */
-       if (cached_irq_mask & irqmask)
-               goto spurious_8259A_irq;
-       cached_irq_mask |= irqmask;
-
-handle_real_irq:
-       if (irq & 8) {
-               inb(0xA1);              /* DUMMY - (do we need this?) */
-               outb(cached_A1,0xA1);
-               outb(0x60+(irq&7),0xA0);/* 'Specific EOI' to slave */
-               outb(0x62,0x20);        /* 'Specific EOI' to master-IRQ2 */
-       } else {
-               inb(0x21);              /* DUMMY - (do we need this?) */
-               outb(cached_21,0x21);
-               outb(0x60+irq,0x20);    /* 'Specific EOI' to master */
-       }
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-       return;
-
-spurious_8259A_irq:
-       /*
-        * this is the slow path - should happen rarely.
-        */
-       if (i8259A_irq_real(irq))
-               /*
-                * oops, the IRQ _is_ in service according to the
-                * 8259A - not spurious, go handle it.
-                */
-               goto handle_real_irq;
-
-       {
-               static int spurious_irq_mask;
-               /*
-                * At this point we can be sure the IRQ is spurious,
-                * lets ACK and report it. [once per IRQ]
-                */
-               if (!(spurious_irq_mask & irqmask)) {
-                       printk(KERN_DEBUG "spurious 8259A interrupt: IRQ%d.\n", irq);
-                       spurious_irq_mask |= irqmask;
-               }
-               atomic_inc(&irq_err_count);
-               /*
-                * Theoretically we do not have to handle this IRQ,
-                * but in Linux this does not cause problems and is
-                * simpler for us.
-                */
-               goto handle_real_irq;
-       }
-}
-
-void init_8259A(int auto_eoi)
-{
-       unsigned long flags;
-
-       i8259A_auto_eoi = auto_eoi;
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-
-       outb(0xff, 0x21);       /* mask all of 8259A-1 */
-       outb(0xff, 0xA1);       /* mask all of 8259A-2 */
-
-       /*
-        * outb_p - this has to work on a wide range of PC hardware.
-        */
-       outb_p(0x11, 0x20);     /* ICW1: select 8259A-1 init */
-       outb_p(IRQ0_VECTOR, 0x21);      /* ICW2: 8259A-1 IR0-7 mapped to 0x30-0x37 */
-       outb_p(0x04, 0x21);     /* 8259A-1 (the master) has a slave on IR2 */
-       if (auto_eoi)
-               outb_p(0x03, 0x21);     /* master does Auto EOI */
-       else
-               outb_p(0x01, 0x21);     /* master expects normal EOI */
-
-       outb_p(0x11, 0xA0);     /* ICW1: select 8259A-2 init */
-       outb_p(IRQ8_VECTOR, 0xA1);      /* ICW2: 8259A-2 IR0-7 mapped to 0x38-0x3f */
-       outb_p(0x02, 0xA1);     /* 8259A-2 is a slave on master's IR2 */
-       outb_p(0x01, 0xA1);     /* (slave's support for AEOI in flat mode
-                                   is to be investigated) */
-
-       if (auto_eoi)
-               /*
-                * in AEOI mode we just have to mask the interrupt
-                * when acking.
-                */
-               i8259A_chip.mask_ack = disable_8259A_irq;
-       else
-               i8259A_chip.mask_ack = mask_and_ack_8259A;
-
-       udelay(100);            /* wait for 8259A to initialize */
-
-       outb(cached_21, 0x21);  /* restore master IRQ mask */
-       outb(cached_A1, 0xA1);  /* restore slave IRQ mask */
-
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-}
-
-static char irq_trigger[2];
-/**
- * ELCR registers (0x4d0, 0x4d1) control edge/level of IRQ
- */
-static void restore_ELCR(char *trigger)
-{
-       outb(trigger[0], 0x4d0);
-       outb(trigger[1], 0x4d1);
-}
-
-static void save_ELCR(char *trigger)
-{
-       /* IRQ 0,1,2,8,13 are marked as reserved */
-       trigger[0] = inb(0x4d0) & 0xF8;
-       trigger[1] = inb(0x4d1) & 0xDE;
-}
-
-static int i8259A_resume(struct sys_device *dev)
-{
-       init_8259A(i8259A_auto_eoi);
-       restore_ELCR(irq_trigger);
-       return 0;
-}
-
-static int i8259A_suspend(struct sys_device *dev, pm_message_t state)
-{
-       save_ELCR(irq_trigger);
-       return 0;
-}
-
-static int i8259A_shutdown(struct sys_device *dev)
-{
-       /* Put the i8259A into a quiescent state that
-        * the kernel initialization code can get it
-        * out of.
-        */
-       outb(0xff, 0x21);       /* mask all of 8259A-1 */
-       outb(0xff, 0xA1);       /* mask all of 8259A-1 */
-       return 0;
-}
-
-static struct sysdev_class i8259_sysdev_class = {
-       set_kset_name("i8259"),
-       .suspend = i8259A_suspend,
-       .resume = i8259A_resume,
-       .shutdown = i8259A_shutdown,
-};
-
-static struct sys_device device_i8259A = {
-       .id     = 0,
-       .cls    = &i8259_sysdev_class,
-};
-
-static int __init i8259A_init_sysfs(void)
-{
-       int error = sysdev_class_register(&i8259_sysdev_class);
-       if (!error)
-               error = sysdev_register(&device_i8259A);
-       return error;
-}
-
-device_initcall(i8259A_init_sysfs);
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-
-static struct irqaction irq2 = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL};
-DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
-       [0 ... IRQ0_VECTOR - 1] = -1,
-       [IRQ0_VECTOR] = 0,
-       [IRQ1_VECTOR] = 1,
-       [IRQ2_VECTOR] = 2,
-       [IRQ3_VECTOR] = 3,
-       [IRQ4_VECTOR] = 4,
-       [IRQ5_VECTOR] = 5,
-       [IRQ6_VECTOR] = 6,
-       [IRQ7_VECTOR] = 7,
-       [IRQ8_VECTOR] = 8,
-       [IRQ9_VECTOR] = 9,
-       [IRQ10_VECTOR] = 10,
-       [IRQ11_VECTOR] = 11,
-       [IRQ12_VECTOR] = 12,
-       [IRQ13_VECTOR] = 13,
-       [IRQ14_VECTOR] = 14,
-       [IRQ15_VECTOR] = 15,
-       [IRQ15_VECTOR + 1 ... NR_VECTORS - 1] = -1
-};
-
-void __init init_ISA_irqs (void)
-{
-       int i;
-
-       init_bsp_APIC();
-       init_8259A(0);
-
-       for (i = 0; i < NR_IRQS; i++) {
-               irq_desc[i].status = IRQ_DISABLED;
-               irq_desc[i].action = NULL;
-               irq_desc[i].depth = 1;
-
-               if (i < 16) {
-                       /*
-                        * 16 old-style INTA-cycle interrupts:
-                        */
-                       set_irq_chip_and_handler_name(i, &i8259A_chip,
-                                                     handle_level_irq, "XT");
-               } else {
-                       /*
-                        * 'high' PCI IRQs filled in on demand
-                        */
-                       irq_desc[i].chip = &no_irq_chip;
-               }
-       }
-}
-
-static void setup_timer_hardware(void)
-{
-       outb_p(0x34,0x43);              /* binary, mode 2, LSB/MSB, ch 0 */
-       udelay(10);
-       outb_p(LATCH & 0xff , 0x40);    /* LSB */
-       udelay(10);
-       outb(LATCH >> 8 , 0x40);        /* MSB */
-}
-
-static int timer_resume(struct sys_device *dev)
-{
-       setup_timer_hardware();
-       return 0;
-}
-
-void i8254_timer_resume(void)
-{
-       setup_timer_hardware();
-}
-
-static struct sysdev_class timer_sysclass = {
-       set_kset_name("timer_pit"),
-       .resume         = timer_resume,
-};
-
-static struct sys_device device_timer = {
-       .id             = 0,
-       .cls            = &timer_sysclass,
-};
-
-static int __init init_timer_sysfs(void)
-{
-       int error = sysdev_class_register(&timer_sysclass);
-       if (!error)
-               error = sysdev_register(&device_timer);
-       return error;
-}
-
-device_initcall(init_timer_sysfs);
-
-void __init init_IRQ(void)
-{
-       int i;
-
-       init_ISA_irqs();
-       /*
-        * Cover the whole vector space, no vector can escape
-        * us. (some of these will be overridden and become
-        * 'special' SMP interrupts)
-        */
-       for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
-               int vector = FIRST_EXTERNAL_VECTOR + i;
-               if (vector != IA32_SYSCALL_VECTOR)
-                       set_intr_gate(vector, interrupt[i]);
-       }
-
-#ifdef CONFIG_SMP
-       /*
-        * The reschedule interrupt is a CPU-to-CPU reschedule-helper
-        * IPI, driven by wakeup.
-        */
-       set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
-
-       /* IPIs for invalidation */
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6);
-       set_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7);
-
-       /* IPI for generic function call */
-       set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
-
-       /* Low priority IPI to cleanup after moving an irq */
-       set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
-#endif
-       set_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
-       set_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
-
-       /* self generated IPI for local APIC timer */
-       set_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
-
-       /* IPI vectors for APIC spurious and error interrupts */
-       set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
-       set_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
-
-       /*
-        * Set the clock to HZ Hz, we already have a valid
-        * vector now:
-        */
-       setup_timer_hardware();
-
-       if (!acpi_ioapic)
-               setup_irq(2, &irq2);
-}
diff --git a/arch/x86_64/kernel/init_task.c b/arch/x86_64/kernel/init_task.c
deleted file mode 100644 (file)
index 4ff33d4..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <linux/mm.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/init_task.h>
-#include <linux/fs.h>
-#include <linux/mqueue.h>
-
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/desc.h>
-
-static struct fs_struct init_fs = INIT_FS;
-static struct files_struct init_files = INIT_FILES;
-static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
-static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
-struct mm_struct init_mm = INIT_MM(init_mm);
-
-EXPORT_SYMBOL(init_mm);
-
-/*
- * Initial task structure.
- *
- * We need to make sure that this is 8192-byte aligned due to the
- * way process stacks are handled. This is done by having a special
- * "init_task" linker map entry..
- */
-union thread_union init_thread_union 
-       __attribute__((__section__(".data.init_task"))) =
-               { INIT_THREAD_INFO(init_task) };
-
-/*
- * Initial task structure.
- *
- * All other task structs will be allocated on slabs in fork.c
- */
-struct task_struct init_task = INIT_TASK(init_task);
-
-EXPORT_SYMBOL(init_task);
-/*
- * per-CPU TSS segments. Threads are completely 'soft' on Linux,
- * no more per-task TSS's. The TSS size is kept cacheline-aligned
- * so they are allowed to end up in the .data.cacheline_aligned
- * section. Since TSS's are completely CPU-local, we want them
- * on exact cacheline boundaries, to eliminate cacheline ping-pong.
- */ 
-DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
-
-/* Copies of the original ist values from the tss are only accessed during
- * debugging, no special alignment required.
- */
-DEFINE_PER_CPU(struct orig_ist, orig_ist);
-
-#define ALIGN_TO_4K __attribute__((section(".data.init_task")))
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
deleted file mode 100644 (file)
index 966fa10..0000000
+++ /dev/null
@@ -1,2202 +0,0 @@
-/*
- *     Intel IO-APIC support for multi-Pentium hosts.
- *
- *     Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar, Hajnalka Szabo
- *
- *     Many thanks to Stig Venaas for trying out countless experimental
- *     patches and reporting/debugging problems patiently!
- *
- *     (c) 1999, Multiple IO-APIC support, developed by
- *     Ken-ichi Yaku <yaku@css1.kbnes.nec.co.jp> and
- *      Hidemi Kishimoto <kisimoto@css1.kbnes.nec.co.jp>,
- *     further tested and cleaned up by Zach Brown <zab@redhat.com>
- *     and Ingo Molnar <mingo@redhat.com>
- *
- *     Fixes
- *     Maciej W. Rozycki       :       Bits for genuine 82489DX APICs;
- *                                     thanks to Eric Gilmore
- *                                     and Rolf G. Tews
- *                                     for testing these extensively
- *     Paul Diefenbaugh        :       Added full ACPI support
- */
-
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/pci.h>
-#include <linux/mc146818rtc.h>
-#include <linux/acpi.h>
-#include <linux/sysdev.h>
-#include <linux/msi.h>
-#include <linux/htirq.h>
-#ifdef CONFIG_ACPI
-#include <acpi/acpi_bus.h>
-#endif
-
-#include <asm/idle.h>
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/desc.h>
-#include <asm/proto.h>
-#include <asm/mach_apic.h>
-#include <asm/acpi.h>
-#include <asm/dma.h>
-#include <asm/nmi.h>
-#include <asm/msidef.h>
-#include <asm/hypertransport.h>
-
-struct irq_cfg {
-       cpumask_t domain;
-       cpumask_t old_domain;
-       unsigned move_cleanup_count;
-       u8 vector;
-       u8 move_in_progress : 1;
-};
-
-/* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */
-struct irq_cfg irq_cfg[NR_IRQS] __read_mostly = {
-       [0]  = { .domain = CPU_MASK_ALL, .vector = IRQ0_VECTOR,  },
-       [1]  = { .domain = CPU_MASK_ALL, .vector = IRQ1_VECTOR,  },
-       [2]  = { .domain = CPU_MASK_ALL, .vector = IRQ2_VECTOR,  },
-       [3]  = { .domain = CPU_MASK_ALL, .vector = IRQ3_VECTOR,  },
-       [4]  = { .domain = CPU_MASK_ALL, .vector = IRQ4_VECTOR,  },
-       [5]  = { .domain = CPU_MASK_ALL, .vector = IRQ5_VECTOR,  },
-       [6]  = { .domain = CPU_MASK_ALL, .vector = IRQ6_VECTOR,  },
-       [7]  = { .domain = CPU_MASK_ALL, .vector = IRQ7_VECTOR,  },
-       [8]  = { .domain = CPU_MASK_ALL, .vector = IRQ8_VECTOR,  },
-       [9]  = { .domain = CPU_MASK_ALL, .vector = IRQ9_VECTOR,  },
-       [10] = { .domain = CPU_MASK_ALL, .vector = IRQ10_VECTOR, },
-       [11] = { .domain = CPU_MASK_ALL, .vector = IRQ11_VECTOR, },
-       [12] = { .domain = CPU_MASK_ALL, .vector = IRQ12_VECTOR, },
-       [13] = { .domain = CPU_MASK_ALL, .vector = IRQ13_VECTOR, },
-       [14] = { .domain = CPU_MASK_ALL, .vector = IRQ14_VECTOR, },
-       [15] = { .domain = CPU_MASK_ALL, .vector = IRQ15_VECTOR, },
-};
-
-static int assign_irq_vector(int irq, cpumask_t mask);
-
-#define __apicdebuginit  __init
-
-int sis_apic_bug; /* not actually supported, dummy for compile */
-
-static int no_timer_check;
-
-static int disable_timer_pin_1 __initdata;
-
-int timer_over_8254 __initdata = 1;
-
-/* Where if anywhere is the i8259 connect in external int mode */
-static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
-
-static DEFINE_SPINLOCK(ioapic_lock);
-DEFINE_SPINLOCK(vector_lock);
-
-/*
- * # of IRQ routing registers
- */
-int nr_ioapic_registers[MAX_IO_APICS];
-
-/*
- * Rough estimation of how many shared IRQs there are, can
- * be changed anytime.
- */
-#define MAX_PLUS_SHARED_IRQS NR_IRQS
-#define PIN_MAP_SIZE (MAX_PLUS_SHARED_IRQS + NR_IRQS)
-
-/*
- * This is performance-critical, we want to do it O(1)
- *
- * the indexing order of this array favors 1:1 mappings
- * between pins and IRQs.
- */
-
-static struct irq_pin_list {
-       short apic, pin, next;
-} irq_2_pin[PIN_MAP_SIZE];
-
-struct io_apic {
-       unsigned int index;
-       unsigned int unused[3];
-       unsigned int data;
-};
-
-static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx)
-{
-       return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx)
-               + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK);
-}
-
-static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
-{
-       struct io_apic __iomem *io_apic = io_apic_base(apic);
-       writel(reg, &io_apic->index);
-       return readl(&io_apic->data);
-}
-
-static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
-{
-       struct io_apic __iomem *io_apic = io_apic_base(apic);
-       writel(reg, &io_apic->index);
-       writel(value, &io_apic->data);
-}
-
-/*
- * Re-write a value: to be used for read-modify-write
- * cycles where the read already set up the index register.
- */
-static inline void io_apic_modify(unsigned int apic, unsigned int value)
-{
-       struct io_apic __iomem *io_apic = io_apic_base(apic);
-       writel(value, &io_apic->data);
-}
-
-static int io_apic_level_ack_pending(unsigned int irq)
-{
-       struct irq_pin_list *entry;
-       unsigned long flags;
-       int pending = 0;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       entry = irq_2_pin + irq;
-       for (;;) {
-               unsigned int reg;
-               int pin;
-
-               pin = entry->pin;
-               if (pin == -1)
-                       break;
-               reg = io_apic_read(entry->apic, 0x10 + pin*2);
-               /* Is the remote IRR bit set? */
-               pending |= (reg >> 14) & 1;
-               if (!entry->next)
-                       break;
-               entry = irq_2_pin + entry->next;
-       }
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-       return pending;
-}
-
-/*
- * Synchronize the IO-APIC and the CPU by doing
- * a dummy read from the IO-APIC
- */
-static inline void io_apic_sync(unsigned int apic)
-{
-       struct io_apic __iomem *io_apic = io_apic_base(apic);
-       readl(&io_apic->data);
-}
-
-#define __DO_ACTION(R, ACTION, FINAL)                                  \
-                                                                       \
-{                                                                      \
-       int pin;                                                        \
-       struct irq_pin_list *entry = irq_2_pin + irq;                   \
-                                                                       \
-       BUG_ON(irq >= NR_IRQS);                                         \
-       for (;;) {                                                      \
-               unsigned int reg;                                       \
-               pin = entry->pin;                                       \
-               if (pin == -1)                                          \
-                       break;                                          \
-               reg = io_apic_read(entry->apic, 0x10 + R + pin*2);      \
-               reg ACTION;                                             \
-               io_apic_modify(entry->apic, reg);                       \
-               FINAL;                                                  \
-               if (!entry->next)                                       \
-                       break;                                          \
-               entry = irq_2_pin + entry->next;                        \
-       }                                                               \
-}
-
-union entry_union {
-       struct { u32 w1, w2; };
-       struct IO_APIC_route_entry entry;
-};
-
-static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
-{
-       union entry_union eu;
-       unsigned long flags;
-       spin_lock_irqsave(&ioapic_lock, flags);
-       eu.w1 = io_apic_read(apic, 0x10 + 2 * pin);
-       eu.w2 = io_apic_read(apic, 0x11 + 2 * pin);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-       return eu.entry;
-}
-
-/*
- * When we write a new IO APIC routing entry, we need to write the high
- * word first! If the mask bit in the low word is clear, we will enable
- * the interrupt, and we need to make sure the entry is fully populated
- * before that happens.
- */
-static void
-__ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
-{
-       union entry_union eu;
-       eu.entry = e;
-       io_apic_write(apic, 0x11 + 2*pin, eu.w2);
-       io_apic_write(apic, 0x10 + 2*pin, eu.w1);
-}
-
-static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
-{
-       unsigned long flags;
-       spin_lock_irqsave(&ioapic_lock, flags);
-       __ioapic_write_entry(apic, pin, e);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
-/*
- * When we mask an IO APIC routing entry, we need to write the low
- * word first, in order to set the mask bit before we change the
- * high bits!
- */
-static void ioapic_mask_entry(int apic, int pin)
-{
-       unsigned long flags;
-       union entry_union eu = { .entry.mask = 1 };
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       io_apic_write(apic, 0x10 + 2*pin, eu.w1);
-       io_apic_write(apic, 0x11 + 2*pin, eu.w2);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
-#ifdef CONFIG_SMP
-static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector)
-{
-       int apic, pin;
-       struct irq_pin_list *entry = irq_2_pin + irq;
-
-       BUG_ON(irq >= NR_IRQS);
-       for (;;) {
-               unsigned int reg;
-               apic = entry->apic;
-               pin = entry->pin;
-               if (pin == -1)
-                       break;
-               io_apic_write(apic, 0x11 + pin*2, dest);
-               reg = io_apic_read(apic, 0x10 + pin*2);
-               reg &= ~0x000000ff;
-               reg |= vector;
-               io_apic_modify(apic, reg);
-               if (!entry->next)
-                       break;
-               entry = irq_2_pin + entry->next;
-       }
-}
-
-static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       unsigned long flags;
-       unsigned int dest;
-       cpumask_t tmp;
-
-       cpus_and(tmp, mask, cpu_online_map);
-       if (cpus_empty(tmp))
-               return;
-
-       if (assign_irq_vector(irq, mask))
-               return;
-
-       cpus_and(tmp, cfg->domain, mask);
-       dest = cpu_mask_to_apicid(tmp);
-
-       /*
-        * Only the high 8 bits are valid.
-        */
-       dest = SET_APIC_LOGICAL_ID(dest);
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       __target_IO_APIC_irq(irq, dest, cfg->vector);
-       irq_desc[irq].affinity = mask;
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-#endif
-
-/*
- * The common case is 1:1 IRQ<->pin mappings. Sometimes there are
- * shared ISA-space IRQs, so we have to support them. We are super
- * fast in the common case, and fast for shared ISA-space IRQs.
- */
-static void add_pin_to_irq(unsigned int irq, int apic, int pin)
-{
-       static int first_free_entry = NR_IRQS;
-       struct irq_pin_list *entry = irq_2_pin + irq;
-
-       BUG_ON(irq >= NR_IRQS);
-       while (entry->next)
-               entry = irq_2_pin + entry->next;
-
-       if (entry->pin != -1) {
-               entry->next = first_free_entry;
-               entry = irq_2_pin + entry->next;
-               if (++first_free_entry >= PIN_MAP_SIZE)
-                       panic("io_apic.c: ran out of irq_2_pin entries!");
-       }
-       entry->apic = apic;
-       entry->pin = pin;
-}
-
-
-#define DO_ACTION(name,R,ACTION, FINAL)                                        \
-                                                                       \
-       static void name##_IO_APIC_irq (unsigned int irq)               \
-       __DO_ACTION(R, ACTION, FINAL)
-
-DO_ACTION( __mask,             0, |= 0x00010000, io_apic_sync(entry->apic) )
-                                               /* mask = 1 */
-DO_ACTION( __unmask,           0, &= 0xfffeffff, )
-                                               /* mask = 0 */
-
-static void mask_IO_APIC_irq (unsigned int irq)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       __mask_IO_APIC_irq(irq);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
-static void unmask_IO_APIC_irq (unsigned int irq)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       __unmask_IO_APIC_irq(irq);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
-static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
-{
-       struct IO_APIC_route_entry entry;
-
-       /* Check delivery_mode to be sure we're not clearing an SMI pin */
-       entry = ioapic_read_entry(apic, pin);
-       if (entry.delivery_mode == dest_SMI)
-               return;
-       /*
-        * Disable it in the IO-APIC irq-routing table:
-        */
-       ioapic_mask_entry(apic, pin);
-}
-
-static void clear_IO_APIC (void)
-{
-       int apic, pin;
-
-       for (apic = 0; apic < nr_ioapics; apic++)
-               for (pin = 0; pin < nr_ioapic_registers[apic]; pin++)
-                       clear_IO_APIC_pin(apic, pin);
-}
-
-int skip_ioapic_setup;
-int ioapic_force;
-
-static int __init parse_noapic(char *str)
-{
-       disable_ioapic_setup();
-       return 0;
-}
-early_param("noapic", parse_noapic);
-
-/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
-static int __init disable_timer_pin_setup(char *arg)
-{
-       disable_timer_pin_1 = 1;
-       return 1;
-}
-__setup("disable_timer_pin_1", disable_timer_pin_setup);
-
-static int __init setup_disable_8254_timer(char *s)
-{
-       timer_over_8254 = -1;
-       return 1;
-}
-static int __init setup_enable_8254_timer(char *s)
-{
-       timer_over_8254 = 2;
-       return 1;
-}
-
-__setup("disable_8254_timer", setup_disable_8254_timer);
-__setup("enable_8254_timer", setup_enable_8254_timer);
-
-
-/*
- * Find the IRQ entry number of a certain pin.
- */
-static int find_irq_entry(int apic, int pin, int type)
-{
-       int i;
-
-       for (i = 0; i < mp_irq_entries; i++)
-               if (mp_irqs[i].mpc_irqtype == type &&
-                   (mp_irqs[i].mpc_dstapic == mp_ioapics[apic].mpc_apicid ||
-                    mp_irqs[i].mpc_dstapic == MP_APIC_ALL) &&
-                   mp_irqs[i].mpc_dstirq == pin)
-                       return i;
-
-       return -1;
-}
-
-/*
- * Find the pin to which IRQ[irq] (ISA) is connected
- */
-static int __init find_isa_irq_pin(int irq, int type)
-{
-       int i;
-
-       for (i = 0; i < mp_irq_entries; i++) {
-               int lbus = mp_irqs[i].mpc_srcbus;
-
-               if (test_bit(lbus, mp_bus_not_pci) &&
-                   (mp_irqs[i].mpc_irqtype == type) &&
-                   (mp_irqs[i].mpc_srcbusirq == irq))
-
-                       return mp_irqs[i].mpc_dstirq;
-       }
-       return -1;
-}
-
-static int __init find_isa_irq_apic(int irq, int type)
-{
-       int i;
-
-       for (i = 0; i < mp_irq_entries; i++) {
-               int lbus = mp_irqs[i].mpc_srcbus;
-
-               if (test_bit(lbus, mp_bus_not_pci) &&
-                   (mp_irqs[i].mpc_irqtype == type) &&
-                   (mp_irqs[i].mpc_srcbusirq == irq))
-                       break;
-       }
-       if (i < mp_irq_entries) {
-               int apic;
-               for(apic = 0; apic < nr_ioapics; apic++) {
-                       if (mp_ioapics[apic].mpc_apicid == mp_irqs[i].mpc_dstapic)
-                               return apic;
-               }
-       }
-
-       return -1;
-}
-
-/*
- * Find a specific PCI IRQ entry.
- * Not an __init, possibly needed by modules
- */
-static int pin_2_irq(int idx, int apic, int pin);
-
-int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
-{
-       int apic, i, best_guess = -1;
-
-       apic_printk(APIC_DEBUG, "querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n",
-               bus, slot, pin);
-       if (mp_bus_id_to_pci_bus[bus] == -1) {
-               apic_printk(APIC_VERBOSE, "PCI BIOS passed nonexistent PCI bus %d!\n", bus);
-               return -1;
-       }
-       for (i = 0; i < mp_irq_entries; i++) {
-               int lbus = mp_irqs[i].mpc_srcbus;
-
-               for (apic = 0; apic < nr_ioapics; apic++)
-                       if (mp_ioapics[apic].mpc_apicid == mp_irqs[i].mpc_dstapic ||
-                           mp_irqs[i].mpc_dstapic == MP_APIC_ALL)
-                               break;
-
-               if (!test_bit(lbus, mp_bus_not_pci) &&
-                   !mp_irqs[i].mpc_irqtype &&
-                   (bus == lbus) &&
-                   (slot == ((mp_irqs[i].mpc_srcbusirq >> 2) & 0x1f))) {
-                       int irq = pin_2_irq(i,apic,mp_irqs[i].mpc_dstirq);
-
-                       if (!(apic || IO_APIC_IRQ(irq)))
-                               continue;
-
-                       if (pin == (mp_irqs[i].mpc_srcbusirq & 3))
-                               return irq;
-                       /*
-                        * Use the first all-but-pin matching entry as a
-                        * best-guess fuzzy result for broken mptables.
-                        */
-                       if (best_guess < 0)
-                               best_guess = irq;
-               }
-       }
-       BUG_ON(best_guess >= NR_IRQS);
-       return best_guess;
-}
-
-/* ISA interrupts are always polarity zero edge triggered,
- * when listed as conforming in the MP table. */
-
-#define default_ISA_trigger(idx)       (0)
-#define default_ISA_polarity(idx)      (0)
-
-/* PCI interrupts are always polarity one level triggered,
- * when listed as conforming in the MP table. */
-
-#define default_PCI_trigger(idx)       (1)
-#define default_PCI_polarity(idx)      (1)
-
-static int __init MPBIOS_polarity(int idx)
-{
-       int bus = mp_irqs[idx].mpc_srcbus;
-       int polarity;
-
-       /*
-        * Determine IRQ line polarity (high active or low active):
-        */
-       switch (mp_irqs[idx].mpc_irqflag & 3)
-       {
-               case 0: /* conforms, ie. bus-type dependent polarity */
-                       if (test_bit(bus, mp_bus_not_pci))
-                               polarity = default_ISA_polarity(idx);
-                       else
-                               polarity = default_PCI_polarity(idx);
-                       break;
-               case 1: /* high active */
-               {
-                       polarity = 0;
-                       break;
-               }
-               case 2: /* reserved */
-               {
-                       printk(KERN_WARNING "broken BIOS!!\n");
-                       polarity = 1;
-                       break;
-               }
-               case 3: /* low active */
-               {
-                       polarity = 1;
-                       break;
-               }
-               default: /* invalid */
-               {
-                       printk(KERN_WARNING "broken BIOS!!\n");
-                       polarity = 1;
-                       break;
-               }
-       }
-       return polarity;
-}
-
-static int MPBIOS_trigger(int idx)
-{
-       int bus = mp_irqs[idx].mpc_srcbus;
-       int trigger;
-
-       /*
-        * Determine IRQ trigger mode (edge or level sensitive):
-        */
-       switch ((mp_irqs[idx].mpc_irqflag>>2) & 3)
-       {
-               case 0: /* conforms, ie. bus-type dependent */
-                       if (test_bit(bus, mp_bus_not_pci))
-                               trigger = default_ISA_trigger(idx);
-                       else
-                               trigger = default_PCI_trigger(idx);
-                       break;
-               case 1: /* edge */
-               {
-                       trigger = 0;
-                       break;
-               }
-               case 2: /* reserved */
-               {
-                       printk(KERN_WARNING "broken BIOS!!\n");
-                       trigger = 1;
-                       break;
-               }
-               case 3: /* level */
-               {
-                       trigger = 1;
-                       break;
-               }
-               default: /* invalid */
-               {
-                       printk(KERN_WARNING "broken BIOS!!\n");
-                       trigger = 0;
-                       break;
-               }
-       }
-       return trigger;
-}
-
-static inline int irq_polarity(int idx)
-{
-       return MPBIOS_polarity(idx);
-}
-
-static inline int irq_trigger(int idx)
-{
-       return MPBIOS_trigger(idx);
-}
-
-static int pin_2_irq(int idx, int apic, int pin)
-{
-       int irq, i;
-       int bus = mp_irqs[idx].mpc_srcbus;
-
-       /*
-        * Debugging check, we are in big trouble if this message pops up!
-        */
-       if (mp_irqs[idx].mpc_dstirq != pin)
-               printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n");
-
-       if (test_bit(bus, mp_bus_not_pci)) {
-               irq = mp_irqs[idx].mpc_srcbusirq;
-       } else {
-               /*
-                * PCI IRQs are mapped in order
-                */
-               i = irq = 0;
-               while (i < apic)
-                       irq += nr_ioapic_registers[i++];
-               irq += pin;
-       }
-       BUG_ON(irq >= NR_IRQS);
-       return irq;
-}
-
-static int __assign_irq_vector(int irq, cpumask_t mask)
-{
-       /*
-        * NOTE! The local APIC isn't very good at handling
-        * multiple interrupts at the same interrupt level.
-        * As the interrupt level is determined by taking the
-        * vector number and shifting that right by 4, we
-        * want to spread these out a bit so that they don't
-        * all fall in the same interrupt level.
-        *
-        * Also, we've got to be careful not to trash gate
-        * 0x80, because int 0x80 is hm, kind of importantish. ;)
-        */
-       static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0;
-       unsigned int old_vector;
-       int cpu;
-       struct irq_cfg *cfg;
-
-       BUG_ON((unsigned)irq >= NR_IRQS);
-       cfg = &irq_cfg[irq];
-
-       /* Only try and allocate irqs on cpus that are present */
-       cpus_and(mask, mask, cpu_online_map);
-
-       if ((cfg->move_in_progress) || cfg->move_cleanup_count)
-               return -EBUSY;
-
-       old_vector = cfg->vector;
-       if (old_vector) {
-               cpumask_t tmp;
-               cpus_and(tmp, cfg->domain, mask);
-               if (!cpus_empty(tmp))
-                       return 0;
-       }
-
-       for_each_cpu_mask(cpu, mask) {
-               cpumask_t domain, new_mask;
-               int new_cpu;
-               int vector, offset;
-
-               domain = vector_allocation_domain(cpu);
-               cpus_and(new_mask, domain, cpu_online_map);
-
-               vector = current_vector;
-               offset = current_offset;
-next:
-               vector += 8;
-               if (vector >= FIRST_SYSTEM_VECTOR) {
-                       /* If we run out of vectors on large boxen, must share them. */
-                       offset = (offset + 1) % 8;
-                       vector = FIRST_DEVICE_VECTOR + offset;
-               }
-               if (unlikely(current_vector == vector))
-                       continue;
-               if (vector == IA32_SYSCALL_VECTOR)
-                       goto next;
-               for_each_cpu_mask(new_cpu, new_mask)
-                       if (per_cpu(vector_irq, new_cpu)[vector] != -1)
-                               goto next;
-               /* Found one! */
-               current_vector = vector;
-               current_offset = offset;
-               if (old_vector) {
-                       cfg->move_in_progress = 1;
-                       cfg->old_domain = cfg->domain;
-               }
-               for_each_cpu_mask(new_cpu, new_mask)
-                       per_cpu(vector_irq, new_cpu)[vector] = irq;
-               cfg->vector = vector;
-               cfg->domain = domain;
-               return 0;
-       }
-       return -ENOSPC;
-}
-
-static int assign_irq_vector(int irq, cpumask_t mask)
-{
-       int err;
-       unsigned long flags;
-
-       spin_lock_irqsave(&vector_lock, flags);
-       err = __assign_irq_vector(irq, mask);
-       spin_unlock_irqrestore(&vector_lock, flags);
-       return err;
-}
-
-static void __clear_irq_vector(int irq)
-{
-       struct irq_cfg *cfg;
-       cpumask_t mask;
-       int cpu, vector;
-
-       BUG_ON((unsigned)irq >= NR_IRQS);
-       cfg = &irq_cfg[irq];
-       BUG_ON(!cfg->vector);
-
-       vector = cfg->vector;
-       cpus_and(mask, cfg->domain, cpu_online_map);
-       for_each_cpu_mask(cpu, mask)
-               per_cpu(vector_irq, cpu)[vector] = -1;
-
-       cfg->vector = 0;
-       cfg->domain = CPU_MASK_NONE;
-}
-
-void __setup_vector_irq(int cpu)
-{
-       /* Initialize vector_irq on a new cpu */
-       /* This function must be called with vector_lock held */
-       int irq, vector;
-
-       /* Mark the inuse vectors */
-       for (irq = 0; irq < NR_IRQS; ++irq) {
-               if (!cpu_isset(cpu, irq_cfg[irq].domain))
-                       continue;
-               vector = irq_cfg[irq].vector;
-               per_cpu(vector_irq, cpu)[vector] = irq;
-       }
-       /* Mark the free vectors */
-       for (vector = 0; vector < NR_VECTORS; ++vector) {
-               irq = per_cpu(vector_irq, cpu)[vector];
-               if (irq < 0)
-                       continue;
-               if (!cpu_isset(cpu, irq_cfg[irq].domain))
-                       per_cpu(vector_irq, cpu)[vector] = -1;
-       }
-}
-
-
-static struct irq_chip ioapic_chip;
-
-static void ioapic_register_intr(int irq, unsigned long trigger)
-{
-       if (trigger) {
-               irq_desc[irq].status |= IRQ_LEVEL;
-               set_irq_chip_and_handler_name(irq, &ioapic_chip,
-                                             handle_fasteoi_irq, "fasteoi");
-       } else {
-               irq_desc[irq].status &= ~IRQ_LEVEL;
-               set_irq_chip_and_handler_name(irq, &ioapic_chip,
-                                             handle_edge_irq, "edge");
-       }
-}
-
-static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq,
-                             int trigger, int polarity)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       struct IO_APIC_route_entry entry;
-       cpumask_t mask;
-
-       if (!IO_APIC_IRQ(irq))
-               return;
-
-       mask = TARGET_CPUS;
-       if (assign_irq_vector(irq, mask))
-               return;
-
-       cpus_and(mask, cfg->domain, mask);
-
-       apic_printk(APIC_VERBOSE,KERN_DEBUG
-                   "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "
-                   "IRQ %d Mode:%i Active:%i)\n",
-                   apic, mp_ioapics[apic].mpc_apicid, pin, cfg->vector,
-                   irq, trigger, polarity);
-
-       /*
-        * add it to the IO-APIC irq-routing table:
-        */
-       memset(&entry,0,sizeof(entry));
-
-       entry.delivery_mode = INT_DELIVERY_MODE;
-       entry.dest_mode = INT_DEST_MODE;
-       entry.dest = cpu_mask_to_apicid(mask);
-       entry.mask = 0;                         /* enable IRQ */
-       entry.trigger = trigger;
-       entry.polarity = polarity;
-       entry.vector = cfg->vector;
-
-       /* Mask level triggered irqs.
-        * Use IRQ_DELAYED_DISABLE for edge triggered irqs.
-        */
-       if (trigger)
-               entry.mask = 1;
-
-       ioapic_register_intr(irq, trigger);
-       if (irq < 16)
-               disable_8259A_irq(irq);
-
-       ioapic_write_entry(apic, pin, entry);
-}
-
-static void __init setup_IO_APIC_irqs(void)
-{
-       int apic, pin, idx, irq, first_notcon = 1;
-
-       apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
-
-       for (apic = 0; apic < nr_ioapics; apic++) {
-       for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
-
-               idx = find_irq_entry(apic,pin,mp_INT);
-               if (idx == -1) {
-                       if (first_notcon) {
-                               apic_printk(APIC_VERBOSE, KERN_DEBUG " IO-APIC (apicid-pin) %d-%d", mp_ioapics[apic].mpc_apicid, pin);
-                               first_notcon = 0;
-                       } else
-                               apic_printk(APIC_VERBOSE, ", %d-%d", mp_ioapics[apic].mpc_apicid, pin);
-                       continue;
-               }
-
-               irq = pin_2_irq(idx, apic, pin);
-               add_pin_to_irq(irq, apic, pin);
-
-               setup_IO_APIC_irq(apic, pin, irq,
-                                 irq_trigger(idx), irq_polarity(idx));
-       }
-       }
-
-       if (!first_notcon)
-               apic_printk(APIC_VERBOSE," not connected.\n");
-}
-
-/*
- * Set up the 8259A-master output pin as broadcast to all
- * CPUs.
- */
-static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector)
-{
-       struct IO_APIC_route_entry entry;
-       unsigned long flags;
-
-       memset(&entry,0,sizeof(entry));
-
-       disable_8259A_irq(0);
-
-       /* mask LVT0 */
-       apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
-
-       /*
-        * We use logical delivery to get the timer IRQ
-        * to the first CPU.
-        */
-       entry.dest_mode = INT_DEST_MODE;
-       entry.mask = 0;                                 /* unmask IRQ now */
-       entry.dest = cpu_mask_to_apicid(TARGET_CPUS);
-       entry.delivery_mode = INT_DELIVERY_MODE;
-       entry.polarity = 0;
-       entry.trigger = 0;
-       entry.vector = vector;
-
-       /*
-        * The timer IRQ doesn't have to know that behind the
-        * scene we have a 8259A-master in AEOI mode ...
-        */
-       set_irq_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq, "edge");
-
-       /*
-        * Add it to the IO-APIC irq-routing table:
-        */
-       spin_lock_irqsave(&ioapic_lock, flags);
-       io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
-       io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       enable_8259A_irq(0);
-}
-
-void __apicdebuginit print_IO_APIC(void)
-{
-       int apic, i;
-       union IO_APIC_reg_00 reg_00;
-       union IO_APIC_reg_01 reg_01;
-       union IO_APIC_reg_02 reg_02;
-       unsigned long flags;
-
-       if (apic_verbosity == APIC_QUIET)
-               return;
-
-       printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries);
-       for (i = 0; i < nr_ioapics; i++)
-               printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n",
-                      mp_ioapics[i].mpc_apicid, nr_ioapic_registers[i]);
-
-       /*
-        * We are a bit conservative about what we expect.  We have to
-        * know about every hardware change ASAP.
-        */
-       printk(KERN_INFO "testing the IO APIC.......................\n");
-
-       for (apic = 0; apic < nr_ioapics; apic++) {
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       reg_00.raw = io_apic_read(apic, 0);
-       reg_01.raw = io_apic_read(apic, 1);
-       if (reg_01.bits.version >= 0x10)
-               reg_02.raw = io_apic_read(apic, 2);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       printk("\n");
-       printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].mpc_apicid);
-       printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw);
-       printk(KERN_DEBUG ".......    : physical APIC id: %02X\n", reg_00.bits.ID);
-
-       printk(KERN_DEBUG ".... register #01: %08X\n", *(int *)&reg_01);
-       printk(KERN_DEBUG ".......     : max redirection entries: %04X\n", reg_01.bits.entries);
-
-       printk(KERN_DEBUG ".......     : PRQ implemented: %X\n", reg_01.bits.PRQ);
-       printk(KERN_DEBUG ".......     : IO APIC version: %04X\n", reg_01.bits.version);
-
-       if (reg_01.bits.version >= 0x10) {
-               printk(KERN_DEBUG ".... register #02: %08X\n", reg_02.raw);
-               printk(KERN_DEBUG ".......     : arbitration: %02X\n", reg_02.bits.arbitration);
-       }
-
-       printk(KERN_DEBUG ".... IRQ redirection table:\n");
-
-       printk(KERN_DEBUG " NR Dst Mask Trig IRR Pol"
-                         " Stat Dmod Deli Vect:   \n");
-
-       for (i = 0; i <= reg_01.bits.entries; i++) {
-               struct IO_APIC_route_entry entry;
-
-               entry = ioapic_read_entry(apic, i);
-
-               printk(KERN_DEBUG " %02x %03X ",
-                       i,
-                       entry.dest
-               );
-
-               printk("%1d    %1d    %1d   %1d   %1d    %1d    %1d    %02X\n",
-                       entry.mask,
-                       entry.trigger,
-                       entry.irr,
-                       entry.polarity,
-                       entry.delivery_status,
-                       entry.dest_mode,
-                       entry.delivery_mode,
-                       entry.vector
-               );
-       }
-       }
-       printk(KERN_DEBUG "IRQ to pin mappings:\n");
-       for (i = 0; i < NR_IRQS; i++) {
-               struct irq_pin_list *entry = irq_2_pin + i;
-               if (entry->pin < 0)
-                       continue;
-               printk(KERN_DEBUG "IRQ%d ", i);
-               for (;;) {
-                       printk("-> %d:%d", entry->apic, entry->pin);
-                       if (!entry->next)
-                               break;
-                       entry = irq_2_pin + entry->next;
-               }
-               printk("\n");
-       }
-
-       printk(KERN_INFO ".................................... done.\n");
-
-       return;
-}
-
-#if 0
-
-static __apicdebuginit void print_APIC_bitfield (int base)
-{
-       unsigned int v;
-       int i, j;
-
-       if (apic_verbosity == APIC_QUIET)
-               return;
-
-       printk(KERN_DEBUG "0123456789abcdef0123456789abcdef\n" KERN_DEBUG);
-       for (i = 0; i < 8; i++) {
-               v = apic_read(base + i*0x10);
-               for (j = 0; j < 32; j++) {
-                       if (v & (1<<j))
-                               printk("1");
-                       else
-                               printk("0");
-               }
-               printk("\n");
-       }
-}
-
-void __apicdebuginit print_local_APIC(void * dummy)
-{
-       unsigned int v, ver, maxlvt;
-
-       if (apic_verbosity == APIC_QUIET)
-               return;
-
-       printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n",
-               smp_processor_id(), hard_smp_processor_id());
-       v = apic_read(APIC_ID);
-       printk(KERN_INFO "... APIC ID:      %08x (%01x)\n", v, GET_APIC_ID(v));
-       v = apic_read(APIC_LVR);
-       printk(KERN_INFO "... APIC VERSION: %08x\n", v);
-       ver = GET_APIC_VERSION(v);
-       maxlvt = get_maxlvt();
-
-       v = apic_read(APIC_TASKPRI);
-       printk(KERN_DEBUG "... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK);
-
-       v = apic_read(APIC_ARBPRI);
-       printk(KERN_DEBUG "... APIC ARBPRI: %08x (%02x)\n", v,
-               v & APIC_ARBPRI_MASK);
-       v = apic_read(APIC_PROCPRI);
-       printk(KERN_DEBUG "... APIC PROCPRI: %08x\n", v);
-
-       v = apic_read(APIC_EOI);
-       printk(KERN_DEBUG "... APIC EOI: %08x\n", v);
-       v = apic_read(APIC_RRR);
-       printk(KERN_DEBUG "... APIC RRR: %08x\n", v);
-       v = apic_read(APIC_LDR);
-       printk(KERN_DEBUG "... APIC LDR: %08x\n", v);
-       v = apic_read(APIC_DFR);
-       printk(KERN_DEBUG "... APIC DFR: %08x\n", v);
-       v = apic_read(APIC_SPIV);
-       printk(KERN_DEBUG "... APIC SPIV: %08x\n", v);
-
-       printk(KERN_DEBUG "... APIC ISR field:\n");
-       print_APIC_bitfield(APIC_ISR);
-       printk(KERN_DEBUG "... APIC TMR field:\n");
-       print_APIC_bitfield(APIC_TMR);
-       printk(KERN_DEBUG "... APIC IRR field:\n");
-       print_APIC_bitfield(APIC_IRR);
-
-       v = apic_read(APIC_ESR);
-       printk(KERN_DEBUG "... APIC ESR: %08x\n", v);
-
-       v = apic_read(APIC_ICR);
-       printk(KERN_DEBUG "... APIC ICR: %08x\n", v);
-       v = apic_read(APIC_ICR2);
-       printk(KERN_DEBUG "... APIC ICR2: %08x\n", v);
-
-       v = apic_read(APIC_LVTT);
-       printk(KERN_DEBUG "... APIC LVTT: %08x\n", v);
-
-       if (maxlvt > 3) {                       /* PC is LVT#4. */
-               v = apic_read(APIC_LVTPC);
-               printk(KERN_DEBUG "... APIC LVTPC: %08x\n", v);
-       }
-       v = apic_read(APIC_LVT0);
-       printk(KERN_DEBUG "... APIC LVT0: %08x\n", v);
-       v = apic_read(APIC_LVT1);
-       printk(KERN_DEBUG "... APIC LVT1: %08x\n", v);
-
-       if (maxlvt > 2) {                       /* ERR is LVT#3. */
-               v = apic_read(APIC_LVTERR);
-               printk(KERN_DEBUG "... APIC LVTERR: %08x\n", v);
-       }
-
-       v = apic_read(APIC_TMICT);
-       printk(KERN_DEBUG "... APIC TMICT: %08x\n", v);
-       v = apic_read(APIC_TMCCT);
-       printk(KERN_DEBUG "... APIC TMCCT: %08x\n", v);
-       v = apic_read(APIC_TDCR);
-       printk(KERN_DEBUG "... APIC TDCR: %08x\n", v);
-       printk("\n");
-}
-
-void print_all_local_APICs (void)
-{
-       on_each_cpu(print_local_APIC, NULL, 1, 1);
-}
-
-void __apicdebuginit print_PIC(void)
-{
-       unsigned int v;
-       unsigned long flags;
-
-       if (apic_verbosity == APIC_QUIET)
-               return;
-
-       printk(KERN_DEBUG "\nprinting PIC contents\n");
-
-       spin_lock_irqsave(&i8259A_lock, flags);
-
-       v = inb(0xa1) << 8 | inb(0x21);
-       printk(KERN_DEBUG "... PIC  IMR: %04x\n", v);
-
-       v = inb(0xa0) << 8 | inb(0x20);
-       printk(KERN_DEBUG "... PIC  IRR: %04x\n", v);
-
-       outb(0x0b,0xa0);
-       outb(0x0b,0x20);
-       v = inb(0xa0) << 8 | inb(0x20);
-       outb(0x0a,0xa0);
-       outb(0x0a,0x20);
-
-       spin_unlock_irqrestore(&i8259A_lock, flags);
-
-       printk(KERN_DEBUG "... PIC  ISR: %04x\n", v);
-
-       v = inb(0x4d1) << 8 | inb(0x4d0);
-       printk(KERN_DEBUG "... PIC ELCR: %04x\n", v);
-}
-
-#endif  /*  0  */
-
-static void __init enable_IO_APIC(void)
-{
-       union IO_APIC_reg_01 reg_01;
-       int i8259_apic, i8259_pin;
-       int i, apic;
-       unsigned long flags;
-
-       for (i = 0; i < PIN_MAP_SIZE; i++) {
-               irq_2_pin[i].pin = -1;
-               irq_2_pin[i].next = 0;
-       }
-
-       /*
-        * The number of IO-APIC IRQ registers (== #pins):
-        */
-       for (apic = 0; apic < nr_ioapics; apic++) {
-               spin_lock_irqsave(&ioapic_lock, flags);
-               reg_01.raw = io_apic_read(apic, 1);
-               spin_unlock_irqrestore(&ioapic_lock, flags);
-               nr_ioapic_registers[apic] = reg_01.bits.entries+1;
-       }
-       for(apic = 0; apic < nr_ioapics; apic++) {
-               int pin;
-               /* See if any of the pins is in ExtINT mode */
-               for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
-                       struct IO_APIC_route_entry entry;
-                       entry = ioapic_read_entry(apic, pin);
-
-                       /* If the interrupt line is enabled and in ExtInt mode
-                        * I have found the pin where the i8259 is connected.
-                        */
-                       if ((entry.mask == 0) && (entry.delivery_mode == dest_ExtINT)) {
-                               ioapic_i8259.apic = apic;
-                               ioapic_i8259.pin  = pin;
-                               goto found_i8259;
-                       }
-               }
-       }
- found_i8259:
-       /* Look to see what if the MP table has reported the ExtINT */
-       i8259_pin  = find_isa_irq_pin(0, mp_ExtINT);
-       i8259_apic = find_isa_irq_apic(0, mp_ExtINT);
-       /* Trust the MP table if nothing is setup in the hardware */
-       if ((ioapic_i8259.pin == -1) && (i8259_pin >= 0)) {
-               printk(KERN_WARNING "ExtINT not setup in hardware but reported by MP table\n");
-               ioapic_i8259.pin  = i8259_pin;
-               ioapic_i8259.apic = i8259_apic;
-       }
-       /* Complain if the MP table and the hardware disagree */
-       if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) &&
-               (i8259_pin >= 0) && (ioapic_i8259.pin >= 0))
-       {
-               printk(KERN_WARNING "ExtINT in hardware and MP table differ\n");
-       }
-
-       /*
-        * Do not trust the IO-APIC being empty at bootup
-        */
-       clear_IO_APIC();
-}
-
-/*
- * Not an __init, needed by the reboot code
- */
-void disable_IO_APIC(void)
-{
-       /*
-        * Clear the IO-APIC before rebooting:
-        */
-       clear_IO_APIC();
-
-       /*
-        * If the i8259 is routed through an IOAPIC
-        * Put that IOAPIC in virtual wire mode
-        * so legacy interrupts can be delivered.
-        */
-       if (ioapic_i8259.pin != -1) {
-               struct IO_APIC_route_entry entry;
-
-               memset(&entry, 0, sizeof(entry));
-               entry.mask            = 0; /* Enabled */
-               entry.trigger         = 0; /* Edge */
-               entry.irr             = 0;
-               entry.polarity        = 0; /* High */
-               entry.delivery_status = 0;
-               entry.dest_mode       = 0; /* Physical */
-               entry.delivery_mode   = dest_ExtINT; /* ExtInt */
-               entry.vector          = 0;
-               entry.dest          = GET_APIC_ID(apic_read(APIC_ID));
-
-               /*
-                * Add it to the IO-APIC irq-routing table:
-                */
-               ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry);
-       }
-
-       disconnect_bsp_APIC(ioapic_i8259.pin != -1);
-}
-
-/*
- * There is a nasty bug in some older SMP boards, their mptable lies
- * about the timer IRQ. We do the following to work around the situation:
- *
- *     - timer IRQ defaults to IO-APIC IRQ
- *     - if this function detects that timer IRQs are defunct, then we fall
- *       back to ISA timer IRQs
- */
-static int __init timer_irq_works(void)
-{
-       unsigned long t1 = jiffies;
-
-       local_irq_enable();
-       /* Let ten ticks pass... */
-       mdelay((10 * 1000) / HZ);
-
-       /*
-        * Expect a few ticks at least, to be sure some possible
-        * glue logic does not lock up after one or two first
-        * ticks in a non-ExtINT mode.  Also the local APIC
-        * might have cached one ExtINT interrupt.  Finally, at
-        * least one tick may be lost due to delays.
-        */
-
-       /* jiffies wrap? */
-       if (jiffies - t1 > 4)
-               return 1;
-       return 0;
-}
-
-/*
- * In the SMP+IOAPIC case it might happen that there are an unspecified
- * number of pending IRQ events unhandled. These cases are very rare,
- * so we 'resend' these IRQs via IPIs, to the same CPU. It's much
- * better to do it this way as thus we do not have to be aware of
- * 'pending' interrupts in the IRQ path, except at this point.
- */
-/*
- * Edge triggered needs to resend any interrupt
- * that was delayed but this is now handled in the device
- * independent code.
- */
-
-/*
- * Starting up a edge-triggered IO-APIC interrupt is
- * nasty - we need to make sure that we get the edge.
- * If it is already asserted for some reason, we need
- * return 1 to indicate that is was pending.
- *
- * This is not complete - we should be able to fake
- * an edge even if it isn't on the 8259A...
- */
-
-static unsigned int startup_ioapic_irq(unsigned int irq)
-{
-       int was_pending = 0;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       if (irq < 16) {
-               disable_8259A_irq(irq);
-               if (i8259A_irq_pending(irq))
-                       was_pending = 1;
-       }
-       __unmask_IO_APIC_irq(irq);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       return was_pending;
-}
-
-static int ioapic_retrigger_irq(unsigned int irq)
-{
-       struct irq_cfg *cfg = &irq_cfg[irq];
-       cpumask_t mask;
-       unsigned long flags;
-
-       spin_lock_irqsave(&vector_lock, flags);
-       cpus_clear(mask);
-       cpu_set(first_cpu(cfg->domain), mask);
-
-       send_IPI_mask(mask, cfg->vector);
-       spin_unlock_irqrestore(&vector_lock, flags);
-
-       return 1;
-}
-
-/*
- * Level and edge triggered IO-APIC interrupts need different handling,
- * so we use two separate IRQ descriptors. Edge triggered IRQs can be
- * handled with the level-triggered descriptor, but that one has slightly
- * more overhead. Level-triggered interrupts cannot be handled with the
- * edge-triggered handler, without risking IRQ storms and other ugly
- * races.
- */
-
-#ifdef CONFIG_SMP
-asmlinkage void smp_irq_move_cleanup_interrupt(void)
-{
-       unsigned vector, me;
-       ack_APIC_irq();
-       exit_idle();
-       irq_enter();
-
-       me = smp_processor_id();
-       for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) {
-               unsigned int irq;
-               struct irq_desc *desc;
-               struct irq_cfg *cfg;
-               irq = __get_cpu_var(vector_irq)[vector];
-               if (irq >= NR_IRQS)
-                       continue;
-
-               desc = irq_desc + irq;
-               cfg = irq_cfg + irq;
-               spin_lock(&desc->lock);
-               if (!cfg->move_cleanup_count)
-                       goto unlock;
-
-               if ((vector == cfg->vector) && cpu_isset(me, cfg->domain))
-                       goto unlock;
-
-               __get_cpu_var(vector_irq)[vector] = -1;
-               cfg->move_cleanup_count--;
-unlock:
-               spin_unlock(&desc->lock);
-       }
-
-       irq_exit();
-}
-
-static void irq_complete_move(unsigned int irq)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       unsigned vector, me;
-
-       if (likely(!cfg->move_in_progress))
-               return;
-
-       vector = ~get_irq_regs()->orig_rax;
-       me = smp_processor_id();
-       if ((vector == cfg->vector) && cpu_isset(me, cfg->domain)) {
-               cpumask_t cleanup_mask;
-
-               cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map);
-               cfg->move_cleanup_count = cpus_weight(cleanup_mask);
-               send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
-               cfg->move_in_progress = 0;
-       }
-}
-#else
-static inline void irq_complete_move(unsigned int irq) {}
-#endif
-
-static void ack_apic_edge(unsigned int irq)
-{
-       irq_complete_move(irq);
-       move_native_irq(irq);
-       ack_APIC_irq();
-}
-
-static void ack_apic_level(unsigned int irq)
-{
-       int do_unmask_irq = 0;
-
-       irq_complete_move(irq);
-#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
-       /* If we are moving the irq we need to mask it */
-       if (unlikely(irq_desc[irq].status & IRQ_MOVE_PENDING)) {
-               do_unmask_irq = 1;
-               mask_IO_APIC_irq(irq);
-       }
-#endif
-
-       /*
-        * We must acknowledge the irq before we move it or the acknowledge will
-        * not propagate properly.
-        */
-       ack_APIC_irq();
-
-       /* Now we can move and renable the irq */
-       if (unlikely(do_unmask_irq)) {
-               /* Only migrate the irq if the ack has been received.
-                *
-                * On rare occasions the broadcast level triggered ack gets
-                * delayed going to ioapics, and if we reprogram the
-                * vector while Remote IRR is still set the irq will never
-                * fire again.
-                *
-                * To prevent this scenario we read the Remote IRR bit
-                * of the ioapic.  This has two effects.
-                * - On any sane system the read of the ioapic will
-                *   flush writes (and acks) going to the ioapic from
-                *   this cpu.
-                * - We get to see if the ACK has actually been delivered.
-                *
-                * Based on failed experiments of reprogramming the
-                * ioapic entry from outside of irq context starting
-                * with masking the ioapic entry and then polling until
-                * Remote IRR was clear before reprogramming the
-                * ioapic I don't trust the Remote IRR bit to be
-                * completey accurate.
-                *
-                * However there appears to be no other way to plug
-                * this race, so if the Remote IRR bit is not
-                * accurate and is causing problems then it is a hardware bug
-                * and you can go talk to the chipset vendor about it.
-                */
-               if (!io_apic_level_ack_pending(irq))
-                       move_masked_irq(irq);
-               unmask_IO_APIC_irq(irq);
-       }
-}
-
-static struct irq_chip ioapic_chip __read_mostly = {
-       .name           = "IO-APIC",
-       .startup        = startup_ioapic_irq,
-       .mask           = mask_IO_APIC_irq,
-       .unmask         = unmask_IO_APIC_irq,
-       .ack            = ack_apic_edge,
-       .eoi            = ack_apic_level,
-#ifdef CONFIG_SMP
-       .set_affinity   = set_ioapic_affinity_irq,
-#endif
-       .retrigger      = ioapic_retrigger_irq,
-};
-
-static inline void init_IO_APIC_traps(void)
-{
-       int irq;
-
-       /*
-        * NOTE! The local APIC isn't very good at handling
-        * multiple interrupts at the same interrupt level.
-        * As the interrupt level is determined by taking the
-        * vector number and shifting that right by 4, we
-        * want to spread these out a bit so that they don't
-        * all fall in the same interrupt level.
-        *
-        * Also, we've got to be careful not to trash gate
-        * 0x80, because int 0x80 is hm, kind of importantish. ;)
-        */
-       for (irq = 0; irq < NR_IRQS ; irq++) {
-               int tmp = irq;
-               if (IO_APIC_IRQ(tmp) && !irq_cfg[tmp].vector) {
-                       /*
-                        * Hmm.. We don't have an entry for this,
-                        * so default to an old-fashioned 8259
-                        * interrupt if we can..
-                        */
-                       if (irq < 16)
-                               make_8259A_irq(irq);
-                       else
-                               /* Strange. Oh, well.. */
-                               irq_desc[irq].chip = &no_irq_chip;
-               }
-       }
-}
-
-static void enable_lapic_irq (unsigned int irq)
-{
-       unsigned long v;
-
-       v = apic_read(APIC_LVT0);
-       apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED);
-}
-
-static void disable_lapic_irq (unsigned int irq)
-{
-       unsigned long v;
-
-       v = apic_read(APIC_LVT0);
-       apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
-}
-
-static void ack_lapic_irq (unsigned int irq)
-{
-       ack_APIC_irq();
-}
-
-static void end_lapic_irq (unsigned int i) { /* nothing */ }
-
-static struct hw_interrupt_type lapic_irq_type __read_mostly = {
-       .name = "local-APIC",
-       .typename = "local-APIC-edge",
-       .startup = NULL, /* startup_irq() not used for IRQ0 */
-       .shutdown = NULL, /* shutdown_irq() not used for IRQ0 */
-       .enable = enable_lapic_irq,
-       .disable = disable_lapic_irq,
-       .ack = ack_lapic_irq,
-       .end = end_lapic_irq,
-};
-
-static void setup_nmi (void)
-{
-       /*
-        * Dirty trick to enable the NMI watchdog ...
-        * We put the 8259A master into AEOI mode and
-        * unmask on all local APICs LVT0 as NMI.
-        *
-        * The idea to use the 8259A in AEOI mode ('8259A Virtual Wire')
-        * is from Maciej W. Rozycki - so we do not have to EOI from
-        * the NMI handler or the timer interrupt.
-        */ 
-       printk(KERN_INFO "activating NMI Watchdog ...");
-
-       enable_NMI_through_LVT0(NULL);
-
-       printk(" done.\n");
-}
-
-/*
- * This looks a bit hackish but it's about the only one way of sending
- * a few INTA cycles to 8259As and any associated glue logic.  ICR does
- * not support the ExtINT mode, unfortunately.  We need to send these
- * cycles as some i82489DX-based boards have glue logic that keeps the
- * 8259A interrupt line asserted until INTA.  --macro
- */
-static inline void unlock_ExtINT_logic(void)
-{
-       int apic, pin, i;
-       struct IO_APIC_route_entry entry0, entry1;
-       unsigned char save_control, save_freq_select;
-       unsigned long flags;
-
-       pin  = find_isa_irq_pin(8, mp_INT);
-       apic = find_isa_irq_apic(8, mp_INT);
-       if (pin == -1)
-               return;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       *(((int *)&entry0) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
-       *(((int *)&entry0) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-       clear_IO_APIC_pin(apic, pin);
-
-       memset(&entry1, 0, sizeof(entry1));
-
-       entry1.dest_mode = 0;                   /* physical delivery */
-       entry1.mask = 0;                        /* unmask IRQ now */
-       entry1.dest = hard_smp_processor_id();
-       entry1.delivery_mode = dest_ExtINT;
-       entry1.polarity = entry0.polarity;
-       entry1.trigger = 0;
-       entry1.vector = 0;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
-       io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       save_control = CMOS_READ(RTC_CONTROL);
-       save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
-       CMOS_WRITE((save_freq_select & ~RTC_RATE_SELECT) | 0x6,
-                  RTC_FREQ_SELECT);
-       CMOS_WRITE(save_control | RTC_PIE, RTC_CONTROL);
-
-       i = 100;
-       while (i-- > 0) {
-               mdelay(10);
-               if ((CMOS_READ(RTC_INTR_FLAGS) & RTC_PF) == RTC_PF)
-                       i -= 10;
-       }
-
-       CMOS_WRITE(save_control, RTC_CONTROL);
-       CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-       clear_IO_APIC_pin(apic, pin);
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
-       io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-}
-
-/*
- * This code may look a bit paranoid, but it's supposed to cooperate with
- * a wide range of boards and BIOS bugs.  Fortunately only the timer IRQ
- * is so screwy.  Thanks to Brian Perkins for testing/hacking this beast
- * fanatically on his truly buggy board.
- *
- * FIXME: really need to revamp this for modern platforms only.
- */
-static inline void check_timer(void)
-{
-       struct irq_cfg *cfg = irq_cfg + 0;
-       int apic1, pin1, apic2, pin2;
-
-       /*
-        * get/set the timer IRQ vector:
-        */
-       disable_8259A_irq(0);
-       assign_irq_vector(0, TARGET_CPUS);
-
-       /*
-        * Subtle, code in do_timer_interrupt() expects an AEOI
-        * mode for the 8259A whenever interrupts are routed
-        * through I/O APICs.  Also IRQ0 has to be enabled in
-        * the 8259A which implies the virtual wire has to be
-        * disabled in the local APIC.
-        */
-       apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
-       init_8259A(1);
-       if (timer_over_8254 > 0)
-               enable_8259A_irq(0);
-
-       pin1  = find_isa_irq_pin(0, mp_INT);
-       apic1 = find_isa_irq_apic(0, mp_INT);
-       pin2  = ioapic_i8259.pin;
-       apic2 = ioapic_i8259.apic;
-
-       apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n",
-               cfg->vector, apic1, pin1, apic2, pin2);
-
-       if (pin1 != -1) {
-               /*
-                * Ok, does IRQ0 through the IOAPIC work?
-                */
-               unmask_IO_APIC_irq(0);
-               if (!no_timer_check && timer_irq_works()) {
-                       nmi_watchdog_default();
-                       if (nmi_watchdog == NMI_IO_APIC) {
-                               disable_8259A_irq(0);
-                               setup_nmi();
-                               enable_8259A_irq(0);
-                       }
-                       if (disable_timer_pin_1 > 0)
-                               clear_IO_APIC_pin(0, pin1);
-                       return;
-               }
-               clear_IO_APIC_pin(apic1, pin1);
-               apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
-                               "connected to IO-APIC\n");
-       }
-
-       apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) "
-                               "through the 8259A ... ");
-       if (pin2 != -1) {
-               apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
-                       apic2, pin2);
-               /*
-                * legacy devices should be connected to IO APIC #0
-                */
-               setup_ExtINT_IRQ0_pin(apic2, pin2, cfg->vector);
-               if (timer_irq_works()) {
-                       apic_printk(APIC_VERBOSE," works.\n");
-                       nmi_watchdog_default();
-                       if (nmi_watchdog == NMI_IO_APIC) {
-                               setup_nmi();
-                       }
-                       return;
-               }
-               /*
-                * Cleanup, just in case ...
-                */
-               clear_IO_APIC_pin(apic2, pin2);
-       }
-       apic_printk(APIC_VERBOSE," failed.\n");
-
-       if (nmi_watchdog == NMI_IO_APIC) {
-               printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
-               nmi_watchdog = 0;
-       }
-
-       apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
-
-       disable_8259A_irq(0);
-       irq_desc[0].chip = &lapic_irq_type;
-       apic_write(APIC_LVT0, APIC_DM_FIXED | cfg->vector);     /* Fixed mode */
-       enable_8259A_irq(0);
-
-       if (timer_irq_works()) {
-               apic_printk(APIC_VERBOSE," works.\n");
-               return;
-       }
-       apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector);
-       apic_printk(APIC_VERBOSE," failed.\n");
-
-       apic_printk(APIC_VERBOSE, KERN_INFO "...trying to set up timer as ExtINT IRQ...");
-
-       init_8259A(0);
-       make_8259A_irq(0);
-       apic_write(APIC_LVT0, APIC_DM_EXTINT);
-
-       unlock_ExtINT_logic();
-
-       if (timer_irq_works()) {
-               apic_printk(APIC_VERBOSE," works.\n");
-               return;
-       }
-       apic_printk(APIC_VERBOSE," failed :(.\n");
-       panic("IO-APIC + timer doesn't work! Try using the 'noapic' kernel parameter\n");
-}
-
-static int __init notimercheck(char *s)
-{
-       no_timer_check = 1;
-       return 1;
-}
-__setup("no_timer_check", notimercheck);
-
-/*
- *
- * IRQ's that are handled by the PIC in the MPS IOAPIC case.
- * - IRQ2 is the cascade IRQ, and cannot be a io-apic IRQ.
- *   Linux doesn't really care, as it's not actually used
- *   for any interrupt handling anyway.
- */
-#define PIC_IRQS       (1<<2)
-
-void __init setup_IO_APIC(void)
-{
-       enable_IO_APIC();
-
-       if (acpi_ioapic)
-               io_apic_irqs = ~0;      /* all IRQs go through IOAPIC */
-       else
-               io_apic_irqs = ~PIC_IRQS;
-
-       apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
-
-       sync_Arb_IDs();
-       setup_IO_APIC_irqs();
-       init_IO_APIC_traps();
-       check_timer();
-       if (!acpi_ioapic)
-               print_IO_APIC();
-}
-
-struct sysfs_ioapic_data {
-       struct sys_device dev;
-       struct IO_APIC_route_entry entry[0];
-};
-static struct sysfs_ioapic_data * mp_ioapic_data[MAX_IO_APICS];
-
-static int ioapic_suspend(struct sys_device *dev, pm_message_t state)
-{
-       struct IO_APIC_route_entry *entry;
-       struct sysfs_ioapic_data *data;
-       int i;
-
-       data = container_of(dev, struct sysfs_ioapic_data, dev);
-       entry = data->entry;
-       for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ )
-               *entry = ioapic_read_entry(dev->id, i);
-
-       return 0;
-}
-
-static int ioapic_resume(struct sys_device *dev)
-{
-       struct IO_APIC_route_entry *entry;
-       struct sysfs_ioapic_data *data;
-       unsigned long flags;
-       union IO_APIC_reg_00 reg_00;
-       int i;
-
-       data = container_of(dev, struct sysfs_ioapic_data, dev);
-       entry = data->entry;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       reg_00.raw = io_apic_read(dev->id, 0);
-       if (reg_00.bits.ID != mp_ioapics[dev->id].mpc_apicid) {
-               reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid;
-               io_apic_write(dev->id, 0, reg_00.raw);
-       }
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-       for (i = 0; i < nr_ioapic_registers[dev->id]; i++)
-               ioapic_write_entry(dev->id, i, entry[i]);
-
-       return 0;
-}
-
-static struct sysdev_class ioapic_sysdev_class = {
-       set_kset_name("ioapic"),
-       .suspend = ioapic_suspend,
-       .resume = ioapic_resume,
-};
-
-static int __init ioapic_init_sysfs(void)
-{
-       struct sys_device * dev;
-       int i, size, error = 0;
-
-       error = sysdev_class_register(&ioapic_sysdev_class);
-       if (error)
-               return error;
-
-       for (i = 0; i < nr_ioapics; i++ ) {
-               size = sizeof(struct sys_device) + nr_ioapic_registers[i]
-                       * sizeof(struct IO_APIC_route_entry);
-               mp_ioapic_data[i] = kmalloc(size, GFP_KERNEL);
-               if (!mp_ioapic_data[i]) {
-                       printk(KERN_ERR "Can't suspend/resume IOAPIC %d\n", i);
-                       continue;
-               }
-               memset(mp_ioapic_data[i], 0, size);
-               dev = &mp_ioapic_data[i]->dev;
-               dev->id = i;
-               dev->cls = &ioapic_sysdev_class;
-               error = sysdev_register(dev);
-               if (error) {
-                       kfree(mp_ioapic_data[i]);
-                       mp_ioapic_data[i] = NULL;
-                       printk(KERN_ERR "Can't suspend/resume IOAPIC %d\n", i);
-                       continue;
-               }
-       }
-
-       return 0;
-}
-
-device_initcall(ioapic_init_sysfs);
-
-/*
- * Dynamic irq allocate and deallocation
- */
-int create_irq(void)
-{
-       /* Allocate an unused irq */
-       int irq;
-       int new;
-       unsigned long flags;
-
-       irq = -ENOSPC;
-       spin_lock_irqsave(&vector_lock, flags);
-       for (new = (NR_IRQS - 1); new >= 0; new--) {
-               if (platform_legacy_irq(new))
-                       continue;
-               if (irq_cfg[new].vector != 0)
-                       continue;
-               if (__assign_irq_vector(new, TARGET_CPUS) == 0)
-                       irq = new;
-               break;
-       }
-       spin_unlock_irqrestore(&vector_lock, flags);
-
-       if (irq >= 0) {
-               dynamic_irq_init(irq);
-       }
-       return irq;
-}
-
-void destroy_irq(unsigned int irq)
-{
-       unsigned long flags;
-
-       dynamic_irq_cleanup(irq);
-
-       spin_lock_irqsave(&vector_lock, flags);
-       __clear_irq_vector(irq);
-       spin_unlock_irqrestore(&vector_lock, flags);
-}
-
-/*
- * MSI mesage composition
- */
-#ifdef CONFIG_PCI_MSI
-static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_msg *msg)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       int err;
-       unsigned dest;
-       cpumask_t tmp;
-
-       tmp = TARGET_CPUS;
-       err = assign_irq_vector(irq, tmp);
-       if (!err) {
-               cpus_and(tmp, cfg->domain, tmp);
-               dest = cpu_mask_to_apicid(tmp);
-
-               msg->address_hi = MSI_ADDR_BASE_HI;
-               msg->address_lo =
-                       MSI_ADDR_BASE_LO |
-                       ((INT_DEST_MODE == 0) ?
-                               MSI_ADDR_DEST_MODE_PHYSICAL:
-                               MSI_ADDR_DEST_MODE_LOGICAL) |
-                       ((INT_DELIVERY_MODE != dest_LowestPrio) ?
-                               MSI_ADDR_REDIRECTION_CPU:
-                               MSI_ADDR_REDIRECTION_LOWPRI) |
-                       MSI_ADDR_DEST_ID(dest);
-
-               msg->data =
-                       MSI_DATA_TRIGGER_EDGE |
-                       MSI_DATA_LEVEL_ASSERT |
-                       ((INT_DELIVERY_MODE != dest_LowestPrio) ?
-                               MSI_DATA_DELIVERY_FIXED:
-                               MSI_DATA_DELIVERY_LOWPRI) |
-                       MSI_DATA_VECTOR(cfg->vector);
-       }
-       return err;
-}
-
-#ifdef CONFIG_SMP
-static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       struct msi_msg msg;
-       unsigned int dest;
-       cpumask_t tmp;
-
-       cpus_and(tmp, mask, cpu_online_map);
-       if (cpus_empty(tmp))
-               return;
-
-       if (assign_irq_vector(irq, mask))
-               return;
-
-       cpus_and(tmp, cfg->domain, mask);
-       dest = cpu_mask_to_apicid(tmp);
-
-       read_msi_msg(irq, &msg);
-
-       msg.data &= ~MSI_DATA_VECTOR_MASK;
-       msg.data |= MSI_DATA_VECTOR(cfg->vector);
-       msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
-       msg.address_lo |= MSI_ADDR_DEST_ID(dest);
-
-       write_msi_msg(irq, &msg);
-       irq_desc[irq].affinity = mask;
-}
-#endif /* CONFIG_SMP */
-
-/*
- * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices,
- * which implement the MSI or MSI-X Capability Structure.
- */
-static struct irq_chip msi_chip = {
-       .name           = "PCI-MSI",
-       .unmask         = unmask_msi_irq,
-       .mask           = mask_msi_irq,
-       .ack            = ack_apic_edge,
-#ifdef CONFIG_SMP
-       .set_affinity   = set_msi_irq_affinity,
-#endif
-       .retrigger      = ioapic_retrigger_irq,
-};
-
-int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
-{
-       struct msi_msg msg;
-       int irq, ret;
-       irq = create_irq();
-       if (irq < 0)
-               return irq;
-
-       ret = msi_compose_msg(dev, irq, &msg);
-       if (ret < 0) {
-               destroy_irq(irq);
-               return ret;
-       }
-
-       set_irq_msi(irq, desc);
-       write_msi_msg(irq, &msg);
-
-       set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
-
-       return 0;
-}
-
-void arch_teardown_msi_irq(unsigned int irq)
-{
-       destroy_irq(irq);
-}
-
-#endif /* CONFIG_PCI_MSI */
-
-/*
- * Hypertransport interrupt support
- */
-#ifdef CONFIG_HT_IRQ
-
-#ifdef CONFIG_SMP
-
-static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
-{
-       struct ht_irq_msg msg;
-       fetch_ht_irq_msg(irq, &msg);
-
-       msg.address_lo &= ~(HT_IRQ_LOW_VECTOR_MASK | HT_IRQ_LOW_DEST_ID_MASK);
-       msg.address_hi &= ~(HT_IRQ_HIGH_DEST_ID_MASK);
-
-       msg.address_lo |= HT_IRQ_LOW_VECTOR(vector) | HT_IRQ_LOW_DEST_ID(dest);
-       msg.address_hi |= HT_IRQ_HIGH_DEST_ID(dest);
-
-       write_ht_irq_msg(irq, &msg);
-}
-
-static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       unsigned int dest;
-       cpumask_t tmp;
-
-       cpus_and(tmp, mask, cpu_online_map);
-       if (cpus_empty(tmp))
-               return;
-
-       if (assign_irq_vector(irq, mask))
-               return;
-
-       cpus_and(tmp, cfg->domain, mask);
-       dest = cpu_mask_to_apicid(tmp);
-
-       target_ht_irq(irq, dest, cfg->vector);
-       irq_desc[irq].affinity = mask;
-}
-#endif
-
-static struct irq_chip ht_irq_chip = {
-       .name           = "PCI-HT",
-       .mask           = mask_ht_irq,
-       .unmask         = unmask_ht_irq,
-       .ack            = ack_apic_edge,
-#ifdef CONFIG_SMP
-       .set_affinity   = set_ht_irq_affinity,
-#endif
-       .retrigger      = ioapic_retrigger_irq,
-};
-
-int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
-{
-       struct irq_cfg *cfg = irq_cfg + irq;
-       int err;
-       cpumask_t tmp;
-
-       tmp = TARGET_CPUS;
-       err = assign_irq_vector(irq, tmp);
-       if (!err) {
-               struct ht_irq_msg msg;
-               unsigned dest;
-
-               cpus_and(tmp, cfg->domain, tmp);
-               dest = cpu_mask_to_apicid(tmp);
-
-               msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
-
-               msg.address_lo =
-                       HT_IRQ_LOW_BASE |
-                       HT_IRQ_LOW_DEST_ID(dest) |
-                       HT_IRQ_LOW_VECTOR(cfg->vector) |
-                       ((INT_DEST_MODE == 0) ?
-                               HT_IRQ_LOW_DM_PHYSICAL :
-                               HT_IRQ_LOW_DM_LOGICAL) |
-                       HT_IRQ_LOW_RQEOI_EDGE |
-                       ((INT_DELIVERY_MODE != dest_LowestPrio) ?
-                               HT_IRQ_LOW_MT_FIXED :
-                               HT_IRQ_LOW_MT_ARBITRATED) |
-                       HT_IRQ_LOW_IRQ_MASKED;
-
-               write_ht_irq_msg(irq, &msg);
-
-               set_irq_chip_and_handler_name(irq, &ht_irq_chip,
-                                             handle_edge_irq, "edge");
-       }
-       return err;
-}
-#endif /* CONFIG_HT_IRQ */
-
-/* --------------------------------------------------------------------------
-                          ACPI-based IOAPIC Configuration
-   -------------------------------------------------------------------------- */
-
-#ifdef CONFIG_ACPI
-
-#define IO_APIC_MAX_ID         0xFE
-
-int __init io_apic_get_redir_entries (int ioapic)
-{
-       union IO_APIC_reg_01    reg_01;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ioapic_lock, flags);
-       reg_01.raw = io_apic_read(ioapic, 1);
-       spin_unlock_irqrestore(&ioapic_lock, flags);
-
-       return reg_01.bits.entries;
-}
-
-
-int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity)
-{
-       if (!IO_APIC_IRQ(irq)) {
-               apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n",
-                       ioapic);
-               return -EINVAL;
-       }
-
-       /*
-        * IRQs < 16 are already in the irq_2_pin[] map
-        */
-       if (irq >= 16)
-               add_pin_to_irq(irq, ioapic, pin);
-
-       setup_IO_APIC_irq(ioapic, pin, irq, triggering, polarity);
-
-       return 0;
-}
-
-#endif /* CONFIG_ACPI */
-
-
-/*
- * This function currently is only a helper for the i386 smp boot process where
- * we need to reprogram the ioredtbls to cater for the cpus which have come online
- * so mask in all cases should simply be TARGET_CPUS
- */
-#ifdef CONFIG_SMP
-void __init setup_ioapic_dest(void)
-{
-       int pin, ioapic, irq, irq_entry;
-
-       if (skip_ioapic_setup == 1)
-               return;
-
-       for (ioapic = 0; ioapic < nr_ioapics; ioapic++) {
-               for (pin = 0; pin < nr_ioapic_registers[ioapic]; pin++) {
-                       irq_entry = find_irq_entry(ioapic, pin, mp_INT);
-                       if (irq_entry == -1)
-                               continue;
-                       irq = pin_2_irq(irq_entry, ioapic, pin);
-
-                       /* setup_IO_APIC_irqs could fail to get vector for some device
-                        * when you have too many devices, because at that time only boot
-                        * cpu is online.
-                        */
-                       if (!irq_cfg[irq].vector)
-                               setup_IO_APIC_irq(ioapic, pin, irq,
-                                                 irq_trigger(irq_entry),
-                                                 irq_polarity(irq_entry));
-                       else
-                               set_ioapic_affinity_irq(irq, TARGET_CPUS);
-               }
-
-       }
-}
-#endif
diff --git a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
deleted file mode 100644 (file)
index 653efa3..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *     linux/arch/x86_64/kernel/ioport.c
- *
- * This contains the io-permission bitmap code - written by obz, with changes
- * by Linus.
- */
-
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/capability.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/ioport.h>
-#include <linux/smp.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/thread_info.h>
-#include <linux/syscalls.h>
-
-/* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
-static void set_bitmap(unsigned long *bitmap, unsigned int base, unsigned int extent, int new_value)
-{
-       int i;
-               if (new_value)
-               for (i = base; i < base + extent; i++) 
-                       __set_bit(i, bitmap); 
-               else
-               for (i = base; i < base + extent; i++) 
-                       clear_bit(i, bitmap); 
-}
-
-/*
- * this changes the io permissions bitmap in the current task.
- */
-asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
-{
-       unsigned int i, max_long, bytes, bytes_updated;
-       struct thread_struct * t = &current->thread;
-       struct tss_struct * tss;
-       unsigned long *bitmap;
-
-       if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
-               return -EINVAL;
-       if (turn_on && !capable(CAP_SYS_RAWIO))
-               return -EPERM;
-
-       /*
-        * If it's the first ioperm() call in this thread's lifetime, set the
-        * IO bitmap up. ioperm() is much less timing critical than clone(),
-        * this is why we delay this operation until now:
-        */
-       if (!t->io_bitmap_ptr) {
-               bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
-               if (!bitmap)
-                       return -ENOMEM;
-
-               memset(bitmap, 0xff, IO_BITMAP_BYTES);
-               t->io_bitmap_ptr = bitmap;
-               set_thread_flag(TIF_IO_BITMAP);
-       }
-
-       /*
-        * do it in the per-thread copy and in the TSS ...
-        *
-        * Disable preemption via get_cpu() - we must not switch away
-        * because the ->io_bitmap_max value must match the bitmap
-        * contents:
-        */
-       tss = &per_cpu(init_tss, get_cpu());
-
-       set_bitmap(t->io_bitmap_ptr, from, num, !turn_on);
-
-       /*
-        * Search for a (possibly new) maximum. This is simple and stupid,
-        * to keep it obviously correct:
-        */
-       max_long = 0;
-       for (i = 0; i < IO_BITMAP_LONGS; i++)
-               if (t->io_bitmap_ptr[i] != ~0UL)
-                       max_long = i;
-
-       bytes = (max_long + 1) * sizeof(long);
-       bytes_updated = max(bytes, t->io_bitmap_max);
-
-       t->io_bitmap_max = bytes;
-
-       /* Update the TSS: */
-       memcpy(tss->io_bitmap, t->io_bitmap_ptr, bytes_updated);
-
-       put_cpu();
-
-       return 0;
-}
-
-/*
- * sys_iopl has to be used when you want to access the IO ports
- * beyond the 0x3ff range: to get the full 65536 ports bitmapped
- * you'd need 8kB of bitmaps/process, which is a bit excessive.
- *
- * Here we just change the eflags value on the stack: we allow
- * only the super-user to do it. This depends on the stack-layout
- * on system-call entry - see also fork() and the signal handling
- * code.
- */
-
-asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs)
-{
-       unsigned int old = (regs->eflags >> 12) & 3;
-
-       if (level > 3)
-               return -EINVAL;
-       /* Trying to gain more privileges? */
-       if (level > old) {
-               if (!capable(CAP_SYS_RAWIO))
-                       return -EPERM;
-       }
-       regs->eflags = (regs->eflags &~ X86_EFLAGS_IOPL) | (level << 12);
-       return 0;
-}
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
deleted file mode 100644 (file)
index 39cb3fa..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *     linux/arch/x86_64/kernel/irq.c
- *
- *     Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
- *
- * This file contains the lowest level x86_64-specific interrupt
- * entry and irq statistics code. All the remaining irq logic is
- * done by the generic kernel/irq/ code and in the
- * x86_64-specific irq controller code. (e.g. i8259.c and
- * io_apic.c.)
- */
-
-#include <linux/kernel_stat.h>
-#include <linux/interrupt.h>
-#include <linux/seq_file.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <asm/uaccess.h>
-#include <asm/io_apic.h>
-#include <asm/idle.h>
-#include <asm/smp.h>
-
-atomic_t irq_err_count;
-
-#ifdef CONFIG_DEBUG_STACKOVERFLOW
-/*
- * Probabilistic stack overflow check:
- *
- * Only check the stack in process context, because everything else
- * runs on the big interrupt stacks. Checking reliably is too expensive,
- * so we just check from interrupts.
- */
-static inline void stack_overflow_check(struct pt_regs *regs)
-{
-       u64 curbase = (u64)task_stack_page(current);
-       static unsigned long warned = -60*HZ;
-
-       if (regs->rsp >= curbase && regs->rsp <= curbase + THREAD_SIZE &&
-           regs->rsp <  curbase + sizeof(struct thread_info) + 128 &&
-           time_after(jiffies, warned + 60*HZ)) {
-               printk("do_IRQ: %s near stack overflow (cur:%Lx,rsp:%lx)\n",
-                      current->comm, curbase, regs->rsp);
-               show_stack(NULL,NULL);
-               warned = jiffies;
-       }
-}
-#endif
-
-/*
- * Generic, controller-independent functions:
- */
-
-int show_interrupts(struct seq_file *p, void *v)
-{
-       int i = *(loff_t *) v, j;
-       struct irqaction * action;
-       unsigned long flags;
-
-       if (i == 0) {
-               seq_printf(p, "           ");
-               for_each_online_cpu(j)
-                       seq_printf(p, "CPU%-8d",j);
-               seq_putc(p, '\n');
-       }
-
-       if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
-               action = irq_desc[i].action;
-               if (!action) 
-                       goto skip;
-               seq_printf(p, "%3d: ",i);
-#ifndef CONFIG_SMP
-               seq_printf(p, "%10u ", kstat_irqs(i));
-#else
-               for_each_online_cpu(j)
-                       seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
-#endif
-               seq_printf(p, " %8s", irq_desc[i].chip->name);
-               seq_printf(p, "-%-8s", irq_desc[i].name);
-
-               seq_printf(p, "  %s", action->name);
-               for (action=action->next; action; action = action->next)
-                       seq_printf(p, ", %s", action->name);
-               seq_putc(p, '\n');
-skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
-       } else if (i == NR_IRQS) {
-               seq_printf(p, "NMI: ");
-               for_each_online_cpu(j)
-                       seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
-               seq_putc(p, '\n');
-               seq_printf(p, "LOC: ");
-               for_each_online_cpu(j)
-                       seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
-               seq_putc(p, '\n');
-               seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
-       }
-       return 0;
-}
-
-/*
- * do_IRQ handles all normal device IRQ's (the special
- * SMP cross-CPU interrupts have their own specific
- * handlers).
- */
-asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
-{
-       struct pt_regs *old_regs = set_irq_regs(regs);
-
-       /* high bit used in ret_from_ code  */
-       unsigned vector = ~regs->orig_rax;
-       unsigned irq;
-
-       exit_idle();
-       irq_enter();
-       irq = __get_cpu_var(vector_irq)[vector];
-
-#ifdef CONFIG_DEBUG_STACKOVERFLOW
-       stack_overflow_check(regs);
-#endif
-
-       if (likely(irq < NR_IRQS))
-               generic_handle_irq(irq);
-       else {
-               if (!disable_apic)
-                       ack_APIC_irq();
-
-               if (printk_ratelimit())
-                       printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
-                               __func__, smp_processor_id(), vector);
-       }
-
-       irq_exit();
-
-       set_irq_regs(old_regs);
-       return 1;
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-void fixup_irqs(cpumask_t map)
-{
-       unsigned int irq;
-       static int warned;
-
-       for (irq = 0; irq < NR_IRQS; irq++) {
-               cpumask_t mask;
-               int break_affinity = 0;
-               int set_affinity = 1;
-
-               if (irq == 2)
-                       continue;
-
-               /* interrupt's are disabled at this point */
-               spin_lock(&irq_desc[irq].lock);
-
-               if (!irq_has_action(irq) ||
-                   cpus_equal(irq_desc[irq].affinity, map)) {
-                       spin_unlock(&irq_desc[irq].lock);
-                       continue;
-               }
-
-               cpus_and(mask, irq_desc[irq].affinity, map);
-               if (cpus_empty(mask)) {
-                       break_affinity = 1;
-                       mask = map;
-               }
-
-               if (irq_desc[irq].chip->mask)
-                       irq_desc[irq].chip->mask(irq);
-
-               if (irq_desc[irq].chip->set_affinity)
-                       irq_desc[irq].chip->set_affinity(irq, mask);
-               else if (!(warned++))
-                       set_affinity = 0;
-
-               if (irq_desc[irq].chip->unmask)
-                       irq_desc[irq].chip->unmask(irq);
-
-               spin_unlock(&irq_desc[irq].lock);
-
-               if (break_affinity && set_affinity)
-                       printk("Broke affinity for irq %i\n", irq);
-               else if (!set_affinity)
-                       printk("Cannot set affinity for irq %i\n", irq);
-       }
-
-       /* That doesn't seem sufficient.  Give it 1ms. */
-       local_irq_enable();
-       mdelay(1);
-       local_irq_disable();
-}
-#endif
-
-extern void call_softirq(void);
-
-asmlinkage void do_softirq(void)
-{
-       __u32 pending;
-       unsigned long flags;
-
-       if (in_interrupt())
-               return;
-
-       local_irq_save(flags);
-       pending = local_softirq_pending();
-       /* Switch to interrupt stack */
-       if (pending) {
-               call_softirq();
-               WARN_ON_ONCE(softirq_count());
-       }
-       local_irq_restore(flags);
-}
-EXPORT_SYMBOL(do_softirq);
diff --git a/arch/x86_64/kernel/k8.c b/arch/x86_64/kernel/k8.c
deleted file mode 100644 (file)
index 7377ccb..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Shared support code for AMD K8 northbridges and derivates.
- * Copyright 2006 Andi Kleen, SUSE Labs. Subject to GPLv2.
- */
-#include <linux/gfp.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/k8.h>
-
-int num_k8_northbridges;
-EXPORT_SYMBOL(num_k8_northbridges);
-
-static u32 *flush_words;
-
-struct pci_device_id k8_nb_ids[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) },
-       { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1203) },
-       {}
-};
-EXPORT_SYMBOL(k8_nb_ids);
-
-struct pci_dev **k8_northbridges;
-EXPORT_SYMBOL(k8_northbridges);
-
-static struct pci_dev *next_k8_northbridge(struct pci_dev *dev)
-{
-       do {
-               dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
-               if (!dev)
-                       break;
-       } while (!pci_match_id(&k8_nb_ids[0], dev));
-       return dev;
-}
-
-int cache_k8_northbridges(void)
-{
-       int i;
-       struct pci_dev *dev;
-
-       if (num_k8_northbridges)
-               return 0;
-
-       dev = NULL;
-       while ((dev = next_k8_northbridge(dev)) != NULL)
-               num_k8_northbridges++;
-
-       k8_northbridges = kmalloc((num_k8_northbridges + 1) * sizeof(void *),
-                                 GFP_KERNEL);
-       if (!k8_northbridges)
-               return -ENOMEM;
-
-       if (!num_k8_northbridges) {
-               k8_northbridges[0] = NULL;
-               return 0;
-       }
-
-       flush_words = kmalloc(num_k8_northbridges * sizeof(u32), GFP_KERNEL);
-       if (!flush_words) {
-               kfree(k8_northbridges);
-               return -ENOMEM;
-       }
-
-       dev = NULL;
-       i = 0;
-       while ((dev = next_k8_northbridge(dev)) != NULL) {
-               k8_northbridges[i] = dev;
-               pci_read_config_dword(dev, 0x9c, &flush_words[i++]);
-       }
-       k8_northbridges[i] = NULL;
-       return 0;
-}
-EXPORT_SYMBOL_GPL(cache_k8_northbridges);
-
-/* Ignores subdevice/subvendor but as far as I can figure out
-   they're useless anyways */
-int __init early_is_k8_nb(u32 device)
-{
-       struct pci_device_id *id;
-       u32 vendor = device & 0xffff;
-       device >>= 16;
-       for (id = k8_nb_ids; id->vendor; id++)
-               if (vendor == id->vendor && device == id->device)
-                       return 1;
-       return 0;
-}
-
-void k8_flush_garts(void)
-{
-       int flushed, i;
-       unsigned long flags;
-       static DEFINE_SPINLOCK(gart_lock);
-
-       /* Avoid races between AGP and IOMMU. In theory it's not needed
-          but I'm not sure if the hardware won't lose flush requests
-          when another is pending. This whole thing is so expensive anyways
-          that it doesn't matter to serialize more. -AK */
-       spin_lock_irqsave(&gart_lock, flags);
-       flushed = 0;
-       for (i = 0; i < num_k8_northbridges; i++) {
-               pci_write_config_dword(k8_northbridges[i], 0x9c,
-                                      flush_words[i]|1);
-               flushed++;
-       }
-       for (i = 0; i < num_k8_northbridges; i++) {
-               u32 w;
-               /* Make sure the hardware actually executed the flush*/
-               for (;;) {
-                       pci_read_config_dword(k8_northbridges[i],
-                                             0x9c, &w);
-                       if (!(w & 1))
-                               break;
-                       cpu_relax();
-               }
-       }
-       spin_unlock_irqrestore(&gart_lock, flags);
-       if (!flushed)
-               printk("nothing to flush?\n");
-}
-EXPORT_SYMBOL_GPL(k8_flush_garts);
-
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
deleted file mode 100644 (file)
index a30e004..0000000
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- *  Kernel Probes (KProbes)
- *  arch/x86_64/kernel/kprobes.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright (C) IBM Corporation, 2002, 2004
- *
- * 2002-Oct    Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
- *             Probes initial implementation ( includes contributions from
- *             Rusty Russell).
- * 2004-July   Suparna Bhattacharya <suparna@in.ibm.com> added jumper probes
- *             interface to access function arguments.
- * 2004-Oct    Jim Keniston <kenistoj@us.ibm.com> and Prasanna S Panchamukhi
- *             <prasanna@in.ibm.com> adapted for x86_64
- * 2005-Mar    Roland McGrath <roland@redhat.com>
- *             Fixed to handle %rip-relative addressing mode correctly.
- * 2005-May     Rusty Lynch <rusty.lynch@intel.com>
- *              Added function return probes functionality
- */
-
-#include <linux/kprobes.h>
-#include <linux/ptrace.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/preempt.h>
-#include <linux/module.h>
-#include <linux/kdebug.h>
-
-#include <asm/pgtable.h>
-#include <asm/uaccess.h>
-#include <asm/alternative.h>
-
-void jprobe_return_end(void);
-static void __kprobes arch_copy_kprobe(struct kprobe *p);
-
-DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
-DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
-
-/*
- * returns non-zero if opcode modifies the interrupt flag.
- */
-static __always_inline int is_IF_modifier(kprobe_opcode_t *insn)
-{
-       switch (*insn) {
-       case 0xfa:              /* cli */
-       case 0xfb:              /* sti */
-       case 0xcf:              /* iret/iretd */
-       case 0x9d:              /* popf/popfd */
-               return 1;
-       }
-
-       if (*insn  >= 0x40 && *insn <= 0x4f && *++insn == 0xcf)
-               return 1;
-       return 0;
-}
-
-int __kprobes arch_prepare_kprobe(struct kprobe *p)
-{
-       /* insn: must be on special executable page on x86_64. */
-       p->ainsn.insn = get_insn_slot();
-       if (!p->ainsn.insn) {
-               return -ENOMEM;
-       }
-       arch_copy_kprobe(p);
-       return 0;
-}
-
-/*
- * Determine if the instruction uses the %rip-relative addressing mode.
- * If it does, return the address of the 32-bit displacement word.
- * If not, return null.
- */
-static s32 __kprobes *is_riprel(u8 *insn)
-{
-#define W(row,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb,bc,bd,be,bf)               \
-       (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) |   \
-         (b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) |   \
-         (b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) |   \
-         (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf))    \
-        << (row % 64))
-       static const u64 onebyte_has_modrm[256 / 64] = {
-               /*      0 1 2 3 4 5 6 7 8 9 a b c d e f         */
-               /*      -------------------------------         */
-               W(0x00, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0)| /* 00 */
-               W(0x10, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0)| /* 10 */
-               W(0x20, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0)| /* 20 */
-               W(0x30, 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0), /* 30 */
-               W(0x40, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* 40 */
-               W(0x50, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* 50 */
-               W(0x60, 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0)| /* 60 */
-               W(0x70, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), /* 70 */
-               W(0x80, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* 80 */
-               W(0x90, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* 90 */
-               W(0xa0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* a0 */
-               W(0xb0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), /* b0 */
-               W(0xc0, 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0)| /* c0 */
-               W(0xd0, 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1)| /* d0 */
-               W(0xe0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* e0 */
-               W(0xf0, 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1)  /* f0 */
-               /*      -------------------------------         */
-               /*      0 1 2 3 4 5 6 7 8 9 a b c d e f         */
-       };
-       static const u64 twobyte_has_modrm[256 / 64] = {
-               /*      0 1 2 3 4 5 6 7 8 9 a b c d e f         */
-               /*      -------------------------------         */
-               W(0x00, 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1)| /* 0f */
-               W(0x10, 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0)| /* 1f */
-               W(0x20, 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1)| /* 2f */
-               W(0x30, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), /* 3f */
-               W(0x40, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* 4f */
-               W(0x50, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* 5f */
-               W(0x60, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* 6f */
-               W(0x70, 1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1), /* 7f */
-               W(0x80, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)| /* 8f */
-               W(0x90, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* 9f */
-               W(0xa0, 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1)| /* af */
-               W(0xb0, 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1), /* bf */
-               W(0xc0, 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0)| /* cf */
-               W(0xd0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* df */
-               W(0xe0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)| /* ef */
-               W(0xf0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0)  /* ff */
-               /*      -------------------------------         */
-               /*      0 1 2 3 4 5 6 7 8 9 a b c d e f         */
-       };
-#undef W
-       int need_modrm;
-
-       /* Skip legacy instruction prefixes.  */
-       while (1) {
-               switch (*insn) {
-               case 0x66:
-               case 0x67:
-               case 0x2e:
-               case 0x3e:
-               case 0x26:
-               case 0x64:
-               case 0x65:
-               case 0x36:
-               case 0xf0:
-               case 0xf3:
-               case 0xf2:
-                       ++insn;
-                       continue;
-               }
-               break;
-       }
-
-       /* Skip REX instruction prefix.  */
-       if ((*insn & 0xf0) == 0x40)
-               ++insn;
-
-       if (*insn == 0x0f) {    /* Two-byte opcode.  */
-               ++insn;
-               need_modrm = test_bit(*insn, twobyte_has_modrm);
-       } else {                /* One-byte opcode.  */
-               need_modrm = test_bit(*insn, onebyte_has_modrm);
-       }
-
-       if (need_modrm) {
-               u8 modrm = *++insn;
-               if ((modrm & 0xc7) == 0x05) { /* %rip+disp32 addressing mode */
-                       /* Displacement follows ModRM byte.  */
-                       return (s32 *) ++insn;
-               }
-       }
-
-       /* No %rip-relative addressing mode here.  */
-       return NULL;
-}
-
-static void __kprobes arch_copy_kprobe(struct kprobe *p)
-{
-       s32 *ripdisp;
-       memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
-       ripdisp = is_riprel(p->ainsn.insn);
-       if (ripdisp) {
-               /*
-                * The copied instruction uses the %rip-relative
-                * addressing mode.  Adjust the displacement for the
-                * difference between the original location of this
-                * instruction and the location of the copy that will
-                * actually be run.  The tricky bit here is making sure
-                * that the sign extension happens correctly in this
-                * calculation, since we need a signed 32-bit result to
-                * be sign-extended to 64 bits when it's added to the
-                * %rip value and yield the same 64-bit result that the
-                * sign-extension of the original signed 32-bit
-                * displacement would have given.
-                */
-               s64 disp = (u8 *) p->addr + *ripdisp - (u8 *) p->ainsn.insn;
-               BUG_ON((s64) (s32) disp != disp); /* Sanity check.  */
-               *ripdisp = disp;
-       }
-       p->opcode = *p->addr;
-}
-
-void __kprobes arch_arm_kprobe(struct kprobe *p)
-{
-       text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
-}
-
-void __kprobes arch_disarm_kprobe(struct kprobe *p)
-{
-       text_poke(p->addr, &p->opcode, 1);
-}
-
-void __kprobes arch_remove_kprobe(struct kprobe *p)
-{
-       mutex_lock(&kprobe_mutex);
-       free_insn_slot(p->ainsn.insn, 0);
-       mutex_unlock(&kprobe_mutex);
-}
-
-static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
-{
-       kcb->prev_kprobe.kp = kprobe_running();
-       kcb->prev_kprobe.status = kcb->kprobe_status;
-       kcb->prev_kprobe.old_rflags = kcb->kprobe_old_rflags;
-       kcb->prev_kprobe.saved_rflags = kcb->kprobe_saved_rflags;
-}
-
-static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
-{
-       __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp;
-       kcb->kprobe_status = kcb->prev_kprobe.status;
-       kcb->kprobe_old_rflags = kcb->prev_kprobe.old_rflags;
-       kcb->kprobe_saved_rflags = kcb->prev_kprobe.saved_rflags;
-}
-
-static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
-                               struct kprobe_ctlblk *kcb)
-{
-       __get_cpu_var(current_kprobe) = p;
-       kcb->kprobe_saved_rflags = kcb->kprobe_old_rflags
-               = (regs->eflags & (TF_MASK | IF_MASK));
-       if (is_IF_modifier(p->ainsn.insn))
-               kcb->kprobe_saved_rflags &= ~IF_MASK;
-}
-
-static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
-{
-       regs->eflags |= TF_MASK;
-       regs->eflags &= ~IF_MASK;
-       /*single step inline if the instruction is an int3*/
-       if (p->opcode == BREAKPOINT_INSTRUCTION)
-               regs->rip = (unsigned long)p->addr;
-       else
-               regs->rip = (unsigned long)p->ainsn.insn;
-}
-
-/* Called with kretprobe_lock held */
-void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
-                                     struct pt_regs *regs)
-{
-       unsigned long *sara = (unsigned long *)regs->rsp;
-
-       ri->ret_addr = (kprobe_opcode_t *) *sara;
-       /* Replace the return addr with trampoline addr */
-       *sara = (unsigned long) &kretprobe_trampoline;
-}
-
-int __kprobes kprobe_handler(struct pt_regs *regs)
-{
-       struct kprobe *p;
-       int ret = 0;
-       kprobe_opcode_t *addr = (kprobe_opcode_t *)(regs->rip - sizeof(kprobe_opcode_t));
-       struct kprobe_ctlblk *kcb;
-
-       /*
-        * We don't want to be preempted for the entire
-        * duration of kprobe processing
-        */
-       preempt_disable();
-       kcb = get_kprobe_ctlblk();
-
-       /* Check we're not actually recursing */
-       if (kprobe_running()) {
-               p = get_kprobe(addr);
-               if (p) {
-                       if (kcb->kprobe_status == KPROBE_HIT_SS &&
-                               *p->ainsn.insn == BREAKPOINT_INSTRUCTION) {
-                               regs->eflags &= ~TF_MASK;
-                               regs->eflags |= kcb->kprobe_saved_rflags;
-                               goto no_kprobe;
-                       } else if (kcb->kprobe_status == KPROBE_HIT_SSDONE) {
-                               /* TODO: Provide re-entrancy from
-                                * post_kprobes_handler() and avoid exception
-                                * stack corruption while single-stepping on
-                                * the instruction of the new probe.
-                                */
-                               arch_disarm_kprobe(p);
-                               regs->rip = (unsigned long)p->addr;
-                               reset_current_kprobe();
-                               ret = 1;
-                       } else {
-                               /* We have reentered the kprobe_handler(), since
-                                * another probe was hit while within the
-                                * handler. We here save the original kprobe
-                                * variables and just single step on instruction
-                                * of the new probe without calling any user
-                                * handlers.
-                                */
-                               save_previous_kprobe(kcb);
-                               set_current_kprobe(p, regs, kcb);
-                               kprobes_inc_nmissed_count(p);
-                               prepare_singlestep(p, regs);
-                               kcb->kprobe_status = KPROBE_REENTER;
-                               return 1;
-                       }
-               } else {
-                       if (*addr != BREAKPOINT_INSTRUCTION) {
-                       /* The breakpoint instruction was removed by
-                        * another cpu right after we hit, no further
-                        * handling of this interrupt is appropriate
-                        */
-                               regs->rip = (unsigned long)addr;
-                               ret = 1;
-                               goto no_kprobe;
-                       }
-                       p = __get_cpu_var(current_kprobe);
-                       if (p->break_handler && p->break_handler(p, regs)) {
-                               goto ss_probe;
-                       }
-               }
-               goto no_kprobe;
-       }
-
-       p = get_kprobe(addr);
-       if (!p) {
-               if (*addr != BREAKPOINT_INSTRUCTION) {
-                       /*
-                        * The breakpoint instruction was removed right
-                        * after we hit it.  Another cpu has removed
-                        * either a probepoint or a debugger breakpoint
-                        * at this address.  In either case, no further
-                        * handling of this interrupt is appropriate.
-                        * Back up over the (now missing) int3 and run
-                        * the original instruction.
-                        */
-                       regs->rip = (unsigned long)addr;
-                       ret = 1;
-               }
-               /* Not one of ours: let kernel handle it */
-               goto no_kprobe;
-       }
-
-       set_current_kprobe(p, regs, kcb);
-       kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-
-       if (p->pre_handler && p->pre_handler(p, regs))
-               /* handler has already set things up, so skip ss setup */
-               return 1;
-
-ss_probe:
-       prepare_singlestep(p, regs);
-       kcb->kprobe_status = KPROBE_HIT_SS;
-       return 1;
-
-no_kprobe:
-       preempt_enable_no_resched();
-       return ret;
-}
-
-/*
- * For function-return probes, init_kprobes() establishes a probepoint
- * here. When a retprobed function returns, this probe is hit and
- * trampoline_probe_handler() runs, calling the kretprobe's handler.
- */
- void kretprobe_trampoline_holder(void)
- {
-       asm volatile (  ".global kretprobe_trampoline\n"
-                       "kretprobe_trampoline: \n"
-                       "nop\n");
- }
-
-/*
- * Called when we hit the probe point at kretprobe_trampoline
- */
-int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
-{
-       struct kretprobe_instance *ri = NULL;
-       struct hlist_head *head, empty_rp;
-       struct hlist_node *node, *tmp;
-       unsigned long flags, orig_ret_address = 0;
-       unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
-
-       INIT_HLIST_HEAD(&empty_rp);
-       spin_lock_irqsave(&kretprobe_lock, flags);
-       head = kretprobe_inst_table_head(current);
-
-       /*
-        * It is possible to have multiple instances associated with a given
-        * task either because an multiple functions in the call path
-        * have a return probe installed on them, and/or more then one return
-        * return probe was registered for a target function.
-        *
-        * We can handle this because:
-        *     - instances are always inserted at the head of the list
-        *     - when multiple return probes are registered for the same
-        *       function, the first instance's ret_addr will point to the
-        *       real return address, and all the rest will point to
-        *       kretprobe_trampoline
-        */
-       hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
-               if (ri->task != current)
-                       /* another task is sharing our hash bucket */
-                       continue;
-
-               if (ri->rp && ri->rp->handler)
-                       ri->rp->handler(ri, regs);
-
-               orig_ret_address = (unsigned long)ri->ret_addr;
-               recycle_rp_inst(ri, &empty_rp);
-
-               if (orig_ret_address != trampoline_address)
-                       /*
-                        * This is the real return address. Any other
-                        * instances associated with this task are for
-                        * other calls deeper on the call stack
-                        */
-                       break;
-       }
-
-       kretprobe_assert(ri, orig_ret_address, trampoline_address);
-       regs->rip = orig_ret_address;
-
-       reset_current_kprobe();
-       spin_unlock_irqrestore(&kretprobe_lock, flags);
-       preempt_enable_no_resched();
-
-       hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
-               hlist_del(&ri->hlist);
-               kfree(ri);
-       }
-       /*
-        * By returning a non-zero value, we are telling
-        * kprobe_handler() that we don't want the post_handler
-        * to run (and have re-enabled preemption)
-        */
-       return 1;
-}
-
-/*
- * Called after single-stepping.  p->addr is the address of the
- * instruction whose first byte has been replaced by the "int 3"
- * instruction.  To avoid the SMP problems that can occur when we
- * temporarily put back the original opcode to single-step, we
- * single-stepped a copy of the instruction.  The address of this
- * copy is p->ainsn.insn.
- *
- * This function prepares to return from the post-single-step
- * interrupt.  We have to fix up the stack as follows:
- *
- * 0) Except in the case of absolute or indirect jump or call instructions,
- * the new rip is relative to the copied instruction.  We need to make
- * it relative to the original instruction.
- *
- * 1) If the single-stepped instruction was pushfl, then the TF and IF
- * flags are set in the just-pushed eflags, and may need to be cleared.
- *
- * 2) If the single-stepped instruction was a call, the return address
- * that is atop the stack is the address following the copied instruction.
- * We need to make it the address following the original instruction.
- */
-static void __kprobes resume_execution(struct kprobe *p,
-               struct pt_regs *regs, struct kprobe_ctlblk *kcb)
-{
-       unsigned long *tos = (unsigned long *)regs->rsp;
-       unsigned long next_rip = 0;
-       unsigned long copy_rip = (unsigned long)p->ainsn.insn;
-       unsigned long orig_rip = (unsigned long)p->addr;
-       kprobe_opcode_t *insn = p->ainsn.insn;
-
-       /*skip the REX prefix*/
-       if (*insn >= 0x40 && *insn <= 0x4f)
-               insn++;
-
-       switch (*insn) {
-       case 0x9c:              /* pushfl */
-               *tos &= ~(TF_MASK | IF_MASK);
-               *tos |= kcb->kprobe_old_rflags;
-               break;
-       case 0xc3:              /* ret/lret */
-       case 0xcb:
-       case 0xc2:
-       case 0xca:
-               regs->eflags &= ~TF_MASK;
-               /* rip is already adjusted, no more changes required*/
-               return;
-       case 0xe8:              /* call relative - Fix return addr */
-               *tos = orig_rip + (*tos - copy_rip);
-               break;
-       case 0xff:
-               if ((insn[1] & 0x30) == 0x10) {
-                       /* call absolute, indirect */
-                       /* Fix return addr; rip is correct. */
-                       next_rip = regs->rip;
-                       *tos = orig_rip + (*tos - copy_rip);
-               } else if (((insn[1] & 0x31) == 0x20) ||        /* jmp near, absolute indirect */
-                          ((insn[1] & 0x31) == 0x21)) {        /* jmp far, absolute indirect */
-                       /* rip is correct. */
-                       next_rip = regs->rip;
-               }
-               break;
-       case 0xea:              /* jmp absolute -- rip is correct */
-               next_rip = regs->rip;
-               break;
-       default:
-               break;
-       }
-
-       regs->eflags &= ~TF_MASK;
-       if (next_rip) {
-               regs->rip = next_rip;
-       } else {
-               regs->rip = orig_rip + (regs->rip - copy_rip);
-       }
-}
-
-int __kprobes post_kprobe_handler(struct pt_regs *regs)
-{
-       struct kprobe *cur = kprobe_running();
-       struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-
-       if (!cur)
-               return 0;
-
-       if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
-               kcb->kprobe_status = KPROBE_HIT_SSDONE;
-               cur->post_handler(cur, regs, 0);
-       }
-
-       resume_execution(cur, regs, kcb);
-       regs->eflags |= kcb->kprobe_saved_rflags;
-
-       /* Restore the original saved kprobes variables and continue. */
-       if (kcb->kprobe_status == KPROBE_REENTER) {
-               restore_previous_kprobe(kcb);
-               goto out;
-       }
-       reset_current_kprobe();
-out:
-       preempt_enable_no_resched();
-
-       /*
-        * if somebody else is singlestepping across a probe point, eflags
-        * will have TF set, in which case, continue the remaining processing
-        * of do_debug, as if this is not a probe hit.
-        */
-       if (regs->eflags & TF_MASK)
-               return 0;
-
-       return 1;
-}
-
-int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
-{
-       struct kprobe *cur = kprobe_running();
-       struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-       const struct exception_table_entry *fixup;
-
-       switch(kcb->kprobe_status) {
-       case KPROBE_HIT_SS:
-       case KPROBE_REENTER:
-               /*
-                * We are here because the instruction being single
-                * stepped caused a page fault. We reset the current
-                * kprobe and the rip points back to the probe address
-                * and allow the page fault handler to continue as a
-                * normal page fault.
-                */
-               regs->rip = (unsigned long)cur->addr;
-               regs->eflags |= kcb->kprobe_old_rflags;
-               if (kcb->kprobe_status == KPROBE_REENTER)
-                       restore_previous_kprobe(kcb);
-               else
-                       reset_current_kprobe();
-               preempt_enable_no_resched();
-               break;
-       case KPROBE_HIT_ACTIVE:
-       case KPROBE_HIT_SSDONE:
-               /*
-                * We increment the nmissed count for accounting,
-                * we can also use npre/npostfault count for accouting
-                * these specific fault cases.
-                */
-               kprobes_inc_nmissed_count(cur);
-
-               /*
-                * We come here because instructions in the pre/post
-                * handler caused the page_fault, this could happen
-                * if handler tries to access user space by
-                * copy_from_user(), get_user() etc. Let the
-                * user-specified handler try to fix it first.
-                */
-               if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
-                       return 1;
-
-               /*
-                * In case the user-specified fault handler returned
-                * zero, try to fix up.
-                */
-               fixup = search_exception_tables(regs->rip);
-               if (fixup) {
-                       regs->rip = fixup->fixup;
-                       return 1;
-               }
-
-               /*
-                * fixup() could not handle it,
-                * Let do_page_fault() fix it.
-                */
-               break;
-       default:
-               break;
-       }
-       return 0;
-}
-
-/*
- * Wrapper routine for handling exceptions.
- */
-int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
-                                      unsigned long val, void *data)
-{
-       struct die_args *args = (struct die_args *)data;
-       int ret = NOTIFY_DONE;
-
-       if (args->regs && user_mode(args->regs))
-               return ret;
-
-       switch (val) {
-       case DIE_INT3:
-               if (kprobe_handler(args->regs))
-                       ret = NOTIFY_STOP;
-               break;
-       case DIE_DEBUG:
-               if (post_kprobe_handler(args->regs))
-                       ret = NOTIFY_STOP;
-               break;
-       case DIE_GPF:
-       case DIE_PAGE_FAULT:
-               /* kprobe_running() needs smp_processor_id() */
-               preempt_disable();
-               if (kprobe_running() &&
-                   kprobe_fault_handler(args->regs, args->trapnr))
-                       ret = NOTIFY_STOP;
-               preempt_enable();
-               break;
-       default:
-               break;
-       }
-       return ret;
-}
-
-int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
-{
-       struct jprobe *jp = container_of(p, struct jprobe, kp);
-       unsigned long addr;
-       struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-
-       kcb->jprobe_saved_regs = *regs;
-       kcb->jprobe_saved_rsp = (long *) regs->rsp;
-       addr = (unsigned long)(kcb->jprobe_saved_rsp);
-       /*
-        * As Linus pointed out, gcc assumes that the callee
-        * owns the argument space and could overwrite it, e.g.
-        * tailcall optimization. So, to be absolutely safe
-        * we also save and restore enough stack bytes to cover
-        * the argument area.
-        */
-       memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
-                       MIN_STACK_SIZE(addr));
-       regs->eflags &= ~IF_MASK;
-       regs->rip = (unsigned long)(jp->entry);
-       return 1;
-}
-
-void __kprobes jprobe_return(void)
-{
-       struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-
-       asm volatile ("       xchg   %%rbx,%%rsp     \n"
-                     "       int3                      \n"
-                     "       .globl jprobe_return_end  \n"
-                     "       jprobe_return_end:        \n"
-                     "       nop                       \n"::"b"
-                     (kcb->jprobe_saved_rsp):"memory");
-}
-
-int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
-{
-       struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-       u8 *addr = (u8 *) (regs->rip - 1);
-       unsigned long stack_addr = (unsigned long)(kcb->jprobe_saved_rsp);
-       struct jprobe *jp = container_of(p, struct jprobe, kp);
-
-       if ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) {
-               if ((long *)regs->rsp != kcb->jprobe_saved_rsp) {
-                       struct pt_regs *saved_regs =
-                           container_of(kcb->jprobe_saved_rsp,
-                                           struct pt_regs, rsp);
-                       printk("current rsp %p does not match saved rsp %p\n",
-                              (long *)regs->rsp, kcb->jprobe_saved_rsp);
-                       printk("Saved registers for jprobe %p\n", jp);
-                       show_registers(saved_regs);
-                       printk("Current registers\n");
-                       show_registers(regs);
-                       BUG();
-               }
-               *regs = kcb->jprobe_saved_regs;
-               memcpy((kprobe_opcode_t *) stack_addr, kcb->jprobes_stack,
-                      MIN_STACK_SIZE(stack_addr));
-               preempt_enable_no_resched();
-               return 1;
-       }
-       return 0;
-}
-
-static struct kprobe trampoline_p = {
-       .addr = (kprobe_opcode_t *) &kretprobe_trampoline,
-       .pre_handler = trampoline_probe_handler
-};
-
-int __init arch_init_kprobes(void)
-{
-       return register_kprobe(&trampoline_p);
-}
-
-int __kprobes arch_trampoline_kprobe(struct kprobe *p)
-{
-       if (p->addr == (kprobe_opcode_t *)&kretprobe_trampoline)
-               return 1;
-
-       return 0;
-}
diff --git a/arch/x86_64/kernel/ldt.c b/arch/x86_64/kernel/ldt.c
deleted file mode 100644 (file)
index bc9ffd5..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * linux/arch/x86_64/kernel/ldt.c
- *
- * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds
- * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
- * Copyright (C) 2002 Andi Kleen
- * 
- * This handles calls from both 32bit and 64bit mode.
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/ldt.h>
-#include <asm/desc.h>
-#include <asm/proto.h>
-
-#ifdef CONFIG_SMP /* avoids "defined but not used" warnig */
-static void flush_ldt(void *null)
-{
-       if (current->active_mm)
-               load_LDT(&current->active_mm->context);
-}
-#endif
-
-static int alloc_ldt(mm_context_t *pc, unsigned mincount, int reload)
-{
-       void *oldldt;
-       void *newldt;
-       unsigned oldsize;
-
-       if (mincount <= (unsigned)pc->size)
-               return 0;
-       oldsize = pc->size;
-       mincount = (mincount+511)&(~511);
-       if (mincount*LDT_ENTRY_SIZE > PAGE_SIZE)
-               newldt = vmalloc(mincount*LDT_ENTRY_SIZE);
-       else
-               newldt = kmalloc(mincount*LDT_ENTRY_SIZE, GFP_KERNEL);
-
-       if (!newldt)
-               return -ENOMEM;
-
-       if (oldsize)
-               memcpy(newldt, pc->ldt, oldsize*LDT_ENTRY_SIZE);
-       oldldt = pc->ldt;
-       memset(newldt+oldsize*LDT_ENTRY_SIZE, 0, (mincount-oldsize)*LDT_ENTRY_SIZE);
-       wmb();
-       pc->ldt = newldt;
-       wmb();
-       pc->size = mincount;
-       wmb();
-       if (reload) {
-#ifdef CONFIG_SMP
-               cpumask_t mask;
-
-               preempt_disable();
-               mask = cpumask_of_cpu(smp_processor_id());
-               load_LDT(pc);
-               if (!cpus_equal(current->mm->cpu_vm_mask, mask))
-                       smp_call_function(flush_ldt, NULL, 1, 1);
-               preempt_enable();
-#else
-               load_LDT(pc);
-#endif
-       }
-       if (oldsize) {
-               if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
-                       vfree(oldldt);
-               else
-                       kfree(oldldt);
-       }
-       return 0;
-}
-
-static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
-{
-       int err = alloc_ldt(new, old->size, 0);
-       if (err < 0)
-               return err;
-       memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
-       return 0;
-}
-
-/*
- * we do not have to muck with descriptors here, that is
- * done in switch_mm() as needed.
- */
-int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
-{
-       struct mm_struct * old_mm;
-       int retval = 0;
-
-       init_MUTEX(&mm->context.sem);
-       mm->context.size = 0;
-       old_mm = current->mm;
-       if (old_mm && old_mm->context.size > 0) {
-               down(&old_mm->context.sem);
-               retval = copy_ldt(&mm->context, &old_mm->context);
-               up(&old_mm->context.sem);
-       }
-       return retval;
-}
-
-/*
- * 
- * Don't touch the LDT register - we're already in the next thread.
- */
-void destroy_context(struct mm_struct *mm)
-{
-       if (mm->context.size) {
-               if ((unsigned)mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
-                       vfree(mm->context.ldt);
-               else
-                       kfree(mm->context.ldt);
-               mm->context.size = 0;
-       }
-}
-
-static int read_ldt(void __user * ptr, unsigned long bytecount)
-{
-       int err;
-       unsigned long size;
-       struct mm_struct * mm = current->mm;
-
-       if (!mm->context.size)
-               return 0;
-       if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
-               bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
-
-       down(&mm->context.sem);
-       size = mm->context.size*LDT_ENTRY_SIZE;
-       if (size > bytecount)
-               size = bytecount;
-
-       err = 0;
-       if (copy_to_user(ptr, mm->context.ldt, size))
-               err = -EFAULT;
-       up(&mm->context.sem);
-       if (err < 0)
-               goto error_return;
-       if (size != bytecount) {
-               /* zero-fill the rest */
-               if (clear_user(ptr+size, bytecount-size) != 0) {
-                       err = -EFAULT;
-                       goto error_return;
-               }
-       }
-       return bytecount;
-error_return:
-       return err;
-}
-
-static int read_default_ldt(void __user * ptr, unsigned long bytecount)
-{
-       /* Arbitrary number */ 
-       /* x86-64 default LDT is all zeros */
-       if (bytecount > 128) 
-               bytecount = 128;        
-       if (clear_user(ptr, bytecount))
-               return -EFAULT;
-       return bytecount; 
-}
-
-static int write_ldt(void __user * ptr, unsigned long bytecount, int oldmode)
-{
-       struct task_struct *me = current;
-       struct mm_struct * mm = me->mm;
-       __u32 entry_1, entry_2, *lp;
-       int error;
-       struct user_desc ldt_info;
-
-       error = -EINVAL;
-
-       if (bytecount != sizeof(ldt_info))
-               goto out;
-       error = -EFAULT;        
-       if (copy_from_user(&ldt_info, ptr, bytecount))
-               goto out;
-
-       error = -EINVAL;
-       if (ldt_info.entry_number >= LDT_ENTRIES)
-               goto out;
-       if (ldt_info.contents == 3) {
-               if (oldmode)
-                       goto out;
-               if (ldt_info.seg_not_present == 0)
-                       goto out;
-       }
-
-       down(&mm->context.sem);
-       if (ldt_info.entry_number >= (unsigned)mm->context.size) {
-               error = alloc_ldt(&current->mm->context, ldt_info.entry_number+1, 1);
-               if (error < 0)
-                       goto out_unlock;
-       }
-
-       lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
-
-       /* Allow LDTs to be cleared by the user. */
-       if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
-               if (oldmode || LDT_empty(&ldt_info)) {
-                       entry_1 = 0;
-                       entry_2 = 0;
-                       goto install;
-               }
-       }
-
-       entry_1 = LDT_entry_a(&ldt_info);
-       entry_2 = LDT_entry_b(&ldt_info);
-       if (oldmode)
-               entry_2 &= ~(1 << 20);
-
-       /* Install the new entry ...  */
-install:
-       *lp     = entry_1;
-       *(lp+1) = entry_2;
-       error = 0;
-
-out_unlock:
-       up(&mm->context.sem);
-out:
-       return error;
-}
-
-asmlinkage int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
-{
-       int ret = -ENOSYS;
-
-       switch (func) {
-       case 0:
-               ret = read_ldt(ptr, bytecount);
-               break;
-       case 1:
-               ret = write_ldt(ptr, bytecount, 1);
-               break;
-       case 2:
-               ret = read_default_ldt(ptr, bytecount);
-               break;
-       case 0x11:
-               ret = write_ldt(ptr, bytecount, 0);
-               break;
-       }
-       return ret;
-}
diff --git a/arch/x86_64/kernel/machine_kexec.c b/arch/x86_64/kernel/machine_kexec.c
deleted file mode 100644 (file)
index c3a5547..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * machine_kexec.c - handle transition of Linux booting another kernel
- * Copyright (C) 2002-2005 Eric Biederman  <ebiederm@xmission.com>
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2.  See the file COPYING for more details.
- */
-
-#include <linux/mm.h>
-#include <linux/kexec.h>
-#include <linux/string.h>
-#include <linux/reboot.h>
-#include <asm/pgtable.h>
-#include <asm/tlbflush.h>
-#include <asm/mmu_context.h>
-#include <asm/io.h>
-
-#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
-static u64 kexec_pgd[512] PAGE_ALIGNED;
-static u64 kexec_pud0[512] PAGE_ALIGNED;
-static u64 kexec_pmd0[512] PAGE_ALIGNED;
-static u64 kexec_pte0[512] PAGE_ALIGNED;
-static u64 kexec_pud1[512] PAGE_ALIGNED;
-static u64 kexec_pmd1[512] PAGE_ALIGNED;
-static u64 kexec_pte1[512] PAGE_ALIGNED;
-
-static void init_level2_page(pmd_t *level2p, unsigned long addr)
-{
-       unsigned long end_addr;
-
-       addr &= PAGE_MASK;
-       end_addr = addr + PUD_SIZE;
-       while (addr < end_addr) {
-               set_pmd(level2p++, __pmd(addr | __PAGE_KERNEL_LARGE_EXEC));
-               addr += PMD_SIZE;
-       }
-}
-
-static int init_level3_page(struct kimage *image, pud_t *level3p,
-                               unsigned long addr, unsigned long last_addr)
-{
-       unsigned long end_addr;
-       int result;
-
-       result = 0;
-       addr &= PAGE_MASK;
-       end_addr = addr + PGDIR_SIZE;
-       while ((addr < last_addr) && (addr < end_addr)) {
-               struct page *page;
-               pmd_t *level2p;
-
-               page = kimage_alloc_control_pages(image, 0);
-               if (!page) {
-                       result = -ENOMEM;
-                       goto out;
-               }
-               level2p = (pmd_t *)page_address(page);
-               init_level2_page(level2p, addr);
-               set_pud(level3p++, __pud(__pa(level2p) | _KERNPG_TABLE));
-               addr += PUD_SIZE;
-       }
-       /* clear the unused entries */
-       while (addr < end_addr) {
-               pud_clear(level3p++);
-               addr += PUD_SIZE;
-       }
-out:
-       return result;
-}
-
-
-static int init_level4_page(struct kimage *image, pgd_t *level4p,
-                               unsigned long addr, unsigned long last_addr)
-{
-       unsigned long end_addr;
-       int result;
-
-       result = 0;
-       addr &= PAGE_MASK;
-       end_addr = addr + (PTRS_PER_PGD * PGDIR_SIZE);
-       while ((addr < last_addr) && (addr < end_addr)) {
-               struct page *page;
-               pud_t *level3p;
-
-               page = kimage_alloc_control_pages(image, 0);
-               if (!page) {
-                       result = -ENOMEM;
-                       goto out;
-               }
-               level3p = (pud_t *)page_address(page);
-               result = init_level3_page(image, level3p, addr, last_addr);
-               if (result) {
-                       goto out;
-               }
-               set_pgd(level4p++, __pgd(__pa(level3p) | _KERNPG_TABLE));
-               addr += PGDIR_SIZE;
-       }
-       /* clear the unused entries */
-       while (addr < end_addr) {
-               pgd_clear(level4p++);
-               addr += PGDIR_SIZE;
-       }
-out:
-       return result;
-}
-
-
-static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
-{
-       pgd_t *level4p;
-       level4p = (pgd_t *)__va(start_pgtable);
-       return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
-}
-
-static void set_idt(void *newidt, u16 limit)
-{
-       struct desc_ptr curidt;
-
-       /* x86-64 supports unaliged loads & stores */
-       curidt.size    = limit;
-       curidt.address = (unsigned long)newidt;
-
-       __asm__ __volatile__ (
-               "lidtq %0\n"
-               : : "m" (curidt)
-               );
-};
-
-
-static void set_gdt(void *newgdt, u16 limit)
-{
-       struct desc_ptr curgdt;
-
-       /* x86-64 supports unaligned loads & stores */
-       curgdt.size    = limit;
-       curgdt.address = (unsigned long)newgdt;
-
-       __asm__ __volatile__ (
-               "lgdtq %0\n"
-               : : "m" (curgdt)
-               );
-};
-
-static void load_segments(void)
-{
-       __asm__ __volatile__ (
-               "\tmovl %0,%%ds\n"
-               "\tmovl %0,%%es\n"
-               "\tmovl %0,%%ss\n"
-               "\tmovl %0,%%fs\n"
-               "\tmovl %0,%%gs\n"
-               : : "a" (__KERNEL_DS) : "memory"
-               );
-}
-
-int machine_kexec_prepare(struct kimage *image)
-{
-       unsigned long start_pgtable;
-       int result;
-
-       /* Calculate the offsets */
-       start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
-
-       /* Setup the identity mapped 64bit page table */
-       result = init_pgtable(image, start_pgtable);
-       if (result)
-               return result;
-
-       return 0;
-}
-
-void machine_kexec_cleanup(struct kimage *image)
-{
-       return;
-}
-
-/*
- * Do not allocate memory (or fail in any way) in machine_kexec().
- * We are past the point of no return, committed to rebooting now.
- */
-NORET_TYPE void machine_kexec(struct kimage *image)
-{
-       unsigned long page_list[PAGES_NR];
-       void *control_page;
-
-       /* Interrupts aren't acceptable while we reboot */
-       local_irq_disable();
-
-       control_page = page_address(image->control_code_page) + PAGE_SIZE;
-       memcpy(control_page, relocate_kernel, PAGE_SIZE);
-
-       page_list[PA_CONTROL_PAGE] = virt_to_phys(control_page);
-       page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
-       page_list[PA_PGD] = virt_to_phys(&kexec_pgd);
-       page_list[VA_PGD] = (unsigned long)kexec_pgd;
-       page_list[PA_PUD_0] = virt_to_phys(&kexec_pud0);
-       page_list[VA_PUD_0] = (unsigned long)kexec_pud0;
-       page_list[PA_PMD_0] = virt_to_phys(&kexec_pmd0);
-       page_list[VA_PMD_0] = (unsigned long)kexec_pmd0;
-       page_list[PA_PTE_0] = virt_to_phys(&kexec_pte0);
-       page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
-       page_list[PA_PUD_1] = virt_to_phys(&kexec_pud1);
-       page_list[VA_PUD_1] = (unsigned long)kexec_pud1;
-       page_list[PA_PMD_1] = virt_to_phys(&kexec_pmd1);
-       page_list[VA_PMD_1] = (unsigned long)kexec_pmd1;
-       page_list[PA_PTE_1] = virt_to_phys(&kexec_pte1);
-       page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
-
-       page_list[PA_TABLE_PAGE] =
-         (unsigned long)__pa(page_address(image->control_code_page));
-
-       /* The segment registers are funny things, they have both a
-        * visible and an invisible part.  Whenever the visible part is
-        * set to a specific selector, the invisible part is loaded
-        * with from a table in memory.  At no other time is the
-        * descriptor table in memory accessed.
-        *
-        * I take advantage of this here by force loading the
-        * segments, before I zap the gdt with an invalid value.
-        */
-       load_segments();
-       /* The gdt & idt are now invalid.
-        * If you want to load them you must set up your own idt & gdt.
-        */
-       set_gdt(phys_to_virt(0),0);
-       set_idt(phys_to_virt(0),0);
-
-       /* now call it */
-       relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
-                       image->start);
-}
-
-/* crashkernel=size@addr specifies the location to reserve for
- * a crash kernel.  By reserving this memory we guarantee
- * that linux never set's it up as a DMA target.
- * Useful for holding code to do something appropriate
- * after a kernel panic.
- */
-static int __init setup_crashkernel(char *arg)
-{
-       unsigned long size, base;
-       char *p;
-       if (!arg)
-               return -EINVAL;
-       size = memparse(arg, &p);
-       if (arg == p)
-               return -EINVAL;
-       if (*p == '@') {
-               base = memparse(p+1, &p);
-               /* FIXME: Do I want a sanity check to validate the
-                * memory range?  Yes you do, but it's too early for
-                * e820 -AK */
-               crashk_res.start = base;
-               crashk_res.end   = base + size - 1;
-       }
-       return 0;
-}
-early_param("crashkernel", setup_crashkernel);
-
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
deleted file mode 100644 (file)
index a66d607..0000000
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * Machine check handler.
- * K8 parts Copyright 2002,2003 Andi Kleen, SuSE Labs.
- * Rest from unknown author(s). 
- * 2004 Andi Kleen. Rewrote most of it. 
- */
-
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/rcupdate.h>
-#include <linux/kallsyms.h>
-#include <linux/sysdev.h>
-#include <linux/miscdevice.h>
-#include <linux/fs.h>
-#include <linux/capability.h>
-#include <linux/cpu.h>
-#include <linux/percpu.h>
-#include <linux/poll.h>
-#include <linux/thread_info.h>
-#include <linux/ctype.h>
-#include <linux/kmod.h>
-#include <linux/kdebug.h>
-#include <asm/processor.h> 
-#include <asm/msr.h>
-#include <asm/mce.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/idle.h>
-
-#define MISC_MCELOG_MINOR 227
-#define NR_BANKS 6
-
-atomic_t mce_entry;
-
-static int mce_dont_init;
-
-/*
- * Tolerant levels:
- *   0: always panic on uncorrected errors, log corrected errors
- *   1: panic or SIGBUS on uncorrected errors, log corrected errors
- *   2: SIGBUS or log uncorrected errors (if possible), log corrected errors
- *   3: never panic or SIGBUS, log all errors (for testing only)
- */
-static int tolerant = 1;
-static int banks;
-static unsigned long bank[NR_BANKS] = { [0 ... NR_BANKS-1] = ~0UL };
-static unsigned long notify_user;
-static int rip_msr;
-static int mce_bootlog = 1;
-static atomic_t mce_events;
-
-static char trigger[128];
-static char *trigger_argv[2] = { trigger, NULL };
-
-static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
-
-/*
- * Lockless MCE logging infrastructure.
- * This avoids deadlocks on printk locks without having to break locks. Also
- * separate MCEs from kernel messages to avoid bogus bug reports.
- */
-
-struct mce_log mcelog = { 
-       MCE_LOG_SIGNATURE,
-       MCE_LOG_LEN,
-}; 
-
-void mce_log(struct mce *mce)
-{
-       unsigned next, entry;
-       atomic_inc(&mce_events);
-       mce->finished = 0;
-       wmb();
-       for (;;) {
-               entry = rcu_dereference(mcelog.next);
-               /* The rmb forces the compiler to reload next in each
-                   iteration */
-               rmb();
-               for (;;) {
-                       /* When the buffer fills up discard new entries. Assume
-                          that the earlier errors are the more interesting. */
-                       if (entry >= MCE_LOG_LEN) {
-                               set_bit(MCE_OVERFLOW, &mcelog.flags);
-                               return;
-                       }
-                       /* Old left over entry. Skip. */
-                       if (mcelog.entry[entry].finished) {
-                               entry++;
-                               continue;
-                       }
-                       break;
-               }
-               smp_rmb();
-               next = entry + 1;
-               if (cmpxchg(&mcelog.next, entry, next) == entry)
-                       break;
-       }
-       memcpy(mcelog.entry + entry, mce, sizeof(struct mce));
-       wmb();
-       mcelog.entry[entry].finished = 1;
-       wmb();
-
-       set_bit(0, &notify_user);
-}
-
-static void print_mce(struct mce *m)
-{
-       printk(KERN_EMERG "\n"
-              KERN_EMERG "HARDWARE ERROR\n"
-              KERN_EMERG
-              "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n",
-              m->cpu, m->mcgstatus, m->bank, m->status);
-       if (m->rip) {
-               printk(KERN_EMERG 
-                      "RIP%s %02x:<%016Lx> ",
-                      !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
-                      m->cs, m->rip);
-               if (m->cs == __KERNEL_CS)
-                       print_symbol("{%s}", m->rip);
-               printk("\n");
-       }
-       printk(KERN_EMERG "TSC %Lx ", m->tsc); 
-       if (m->addr)
-               printk("ADDR %Lx ", m->addr);
-       if (m->misc)
-               printk("MISC %Lx ", m->misc);   
-       printk("\n");
-       printk(KERN_EMERG "This is not a software problem!\n");
-        printk(KERN_EMERG
-    "Run through mcelog --ascii to decode and contact your hardware vendor\n");
-}
-
-static void mce_panic(char *msg, struct mce *backup, unsigned long start)
-{ 
-       int i;
-
-       oops_begin();
-       for (i = 0; i < MCE_LOG_LEN; i++) {
-               unsigned long tsc = mcelog.entry[i].tsc;
-               if (time_before(tsc, start))
-                       continue;
-               print_mce(&mcelog.entry[i]); 
-               if (backup && mcelog.entry[i].tsc == backup->tsc)
-                       backup = NULL;
-       }
-       if (backup)
-               print_mce(backup);
-       panic(msg);
-} 
-
-static int mce_available(struct cpuinfo_x86 *c)
-{
-       return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
-}
-
-static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
-{
-       if (regs && (m->mcgstatus & MCG_STATUS_RIPV)) {
-               m->rip = regs->rip;
-               m->cs = regs->cs;
-       } else {
-               m->rip = 0;
-               m->cs = 0;
-       }
-       if (rip_msr) {
-               /* Assume the RIP in the MSR is exact. Is this true? */
-               m->mcgstatus |= MCG_STATUS_EIPV;
-               rdmsrl(rip_msr, m->rip);
-               m->cs = 0;
-       }
-}
-
-/* 
- * The actual machine check handler
- */
-
-void do_machine_check(struct pt_regs * regs, long error_code)
-{
-       struct mce m, panicm;
-       u64 mcestart = 0;
-       int i;
-       int panicm_found = 0;
-       /*
-        * If no_way_out gets set, there is no safe way to recover from this
-        * MCE.  If tolerant is cranked up, we'll try anyway.
-        */
-       int no_way_out = 0;
-       /*
-        * If kill_it gets set, there might be a way to recover from this
-        * error.
-        */
-       int kill_it = 0;
-
-       atomic_inc(&mce_entry);
-
-       if (regs)
-               notify_die(DIE_NMI, "machine check", regs, error_code, 18, SIGKILL);
-       if (!banks)
-               goto out2;
-
-       memset(&m, 0, sizeof(struct mce));
-       m.cpu = smp_processor_id();
-       rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
-       /* if the restart IP is not valid, we're done for */
-       if (!(m.mcgstatus & MCG_STATUS_RIPV))
-               no_way_out = 1;
-       
-       rdtscll(mcestart);
-       barrier();
-
-       for (i = 0; i < banks; i++) {
-               if (!bank[i])
-                       continue;
-               
-               m.misc = 0; 
-               m.addr = 0;
-               m.bank = i;
-               m.tsc = 0;
-
-               rdmsrl(MSR_IA32_MC0_STATUS + i*4, m.status);
-               if ((m.status & MCI_STATUS_VAL) == 0)
-                       continue;
-
-               if (m.status & MCI_STATUS_EN) {
-                       /* if PCC was set, there's no way out */
-                       no_way_out |= !!(m.status & MCI_STATUS_PCC);
-                       /*
-                        * If this error was uncorrectable and there was
-                        * an overflow, we're in trouble.  If no overflow,
-                        * we might get away with just killing a task.
-                        */
-                       if (m.status & MCI_STATUS_UC) {
-                               if (tolerant < 1 || m.status & MCI_STATUS_OVER)
-                                       no_way_out = 1;
-                               kill_it = 1;
-                       }
-               }
-
-               if (m.status & MCI_STATUS_MISCV)
-                       rdmsrl(MSR_IA32_MC0_MISC + i*4, m.misc);
-               if (m.status & MCI_STATUS_ADDRV)
-                       rdmsrl(MSR_IA32_MC0_ADDR + i*4, m.addr);
-
-               mce_get_rip(&m, regs);
-               if (error_code >= 0)
-                       rdtscll(m.tsc);
-               if (error_code != -2)
-                       mce_log(&m);
-
-               /* Did this bank cause the exception? */
-               /* Assume that the bank with uncorrectable errors did it,
-                  and that there is only a single one. */
-               if ((m.status & MCI_STATUS_UC) && (m.status & MCI_STATUS_EN)) {
-                       panicm = m;
-                       panicm_found = 1;
-               }
-
-               add_taint(TAINT_MACHINE_CHECK);
-       }
-
-       /* Never do anything final in the polling timer */
-       if (!regs)
-               goto out;
-
-       /* If we didn't find an uncorrectable error, pick
-          the last one (shouldn't happen, just being safe). */
-       if (!panicm_found)
-               panicm = m;
-
-       /*
-        * If we have decided that we just CAN'T continue, and the user
-        *  has not set tolerant to an insane level, give up and die.
-        */
-       if (no_way_out && tolerant < 3)
-               mce_panic("Machine check", &panicm, mcestart);
-
-       /*
-        * If the error seems to be unrecoverable, something should be
-        * done.  Try to kill as little as possible.  If we can kill just
-        * one task, do that.  If the user has set the tolerance very
-        * high, don't try to do anything at all.
-        */
-       if (kill_it && tolerant < 3) {
-               int user_space = 0;
-
-               /*
-                * If the EIPV bit is set, it means the saved IP is the
-                * instruction which caused the MCE.
-                */
-               if (m.mcgstatus & MCG_STATUS_EIPV)
-                       user_space = panicm.rip && (panicm.cs & 3);
-
-               /*
-                * If we know that the error was in user space, send a
-                * SIGBUS.  Otherwise, panic if tolerance is low.
-                *
-                * do_exit() takes an awful lot of locks and has a slight
-                * risk of deadlocking.
-                */
-               if (user_space) {
-                       do_exit(SIGBUS);
-               } else if (panic_on_oops || tolerant < 2) {
-                       mce_panic("Uncorrected machine check",
-                               &panicm, mcestart);
-               }
-       }
-
-       /* notify userspace ASAP */
-       set_thread_flag(TIF_MCE_NOTIFY);
-
- out:
-       /* the last thing we do is clear state */
-       for (i = 0; i < banks; i++)
-               wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
-       wrmsrl(MSR_IA32_MCG_STATUS, 0);
- out2:
-       atomic_dec(&mce_entry);
-}
-
-#ifdef CONFIG_X86_MCE_INTEL
-/***
- * mce_log_therm_throt_event - Logs the thermal throttling event to mcelog
- * @cpu: The CPU on which the event occured.
- * @status: Event status information
- *
- * This function should be called by the thermal interrupt after the
- * event has been processed and the decision was made to log the event
- * further.
- *
- * The status parameter will be saved to the 'status' field of 'struct mce'
- * and historically has been the register value of the
- * MSR_IA32_THERMAL_STATUS (Intel) msr.
- */
-void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
-{
-       struct mce m;
-
-       memset(&m, 0, sizeof(m));
-       m.cpu = cpu;
-       m.bank = MCE_THERMAL_BANK;
-       m.status = status;
-       rdtscll(m.tsc);
-       mce_log(&m);
-}
-#endif /* CONFIG_X86_MCE_INTEL */
-
-/*
- * Periodic polling timer for "silent" machine check errors.  If the
- * poller finds an MCE, poll 2x faster.  When the poller finds no more
- * errors, poll 2x slower (up to check_interval seconds).
- */
-
-static int check_interval = 5 * 60; /* 5 minutes */
-static int next_interval; /* in jiffies */
-static void mcheck_timer(struct work_struct *work);
-static DECLARE_DELAYED_WORK(mcheck_work, mcheck_timer);
-
-static void mcheck_check_cpu(void *info)
-{
-       if (mce_available(&current_cpu_data))
-               do_machine_check(NULL, 0);
-}
-
-static void mcheck_timer(struct work_struct *work)
-{
-       on_each_cpu(mcheck_check_cpu, NULL, 1, 1);
-
-       /*
-        * Alert userspace if needed.  If we logged an MCE, reduce the
-        * polling interval, otherwise increase the polling interval.
-        */
-       if (mce_notify_user()) {
-               next_interval = max(next_interval/2, HZ/100);
-       } else {
-               next_interval = min(next_interval*2,
-                               (int)round_jiffies_relative(check_interval*HZ));
-       }
-
-       schedule_delayed_work(&mcheck_work, next_interval);
-}
-
-/*
- * This is only called from process context.  This is where we do
- * anything we need to alert userspace about new MCEs.  This is called
- * directly from the poller and also from entry.S and idle, thanks to
- * TIF_MCE_NOTIFY.
- */
-int mce_notify_user(void)
-{
-       clear_thread_flag(TIF_MCE_NOTIFY);
-       if (test_and_clear_bit(0, &notify_user)) {
-               static unsigned long last_print;
-               unsigned long now = jiffies;
-
-               wake_up_interruptible(&mce_wait);
-               if (trigger[0])
-                       call_usermodehelper(trigger, trigger_argv, NULL,
-                                               UMH_NO_WAIT);
-
-               if (time_after_eq(now, last_print + (check_interval*HZ))) {
-                       last_print = now;
-                       printk(KERN_INFO "Machine check events logged\n");
-               }
-
-               return 1;
-       }
-       return 0;
-}
-
-/* see if the idle task needs to notify userspace */
-static int
-mce_idle_callback(struct notifier_block *nfb, unsigned long action, void *junk)
-{
-       /* IDLE_END should be safe - interrupts are back on */
-       if (action == IDLE_END && test_thread_flag(TIF_MCE_NOTIFY))
-               mce_notify_user();
-
-       return NOTIFY_OK;
-}
-
-static struct notifier_block mce_idle_notifier = {
-       .notifier_call = mce_idle_callback,
-};
-
-static __init int periodic_mcheck_init(void)
-{ 
-       next_interval = check_interval * HZ;
-       if (next_interval)
-               schedule_delayed_work(&mcheck_work,
-                                     round_jiffies_relative(next_interval));
-       idle_notifier_register(&mce_idle_notifier);
-       return 0;
-} 
-__initcall(periodic_mcheck_init);
-
-
-/* 
- * Initialize Machine Checks for a CPU.
- */
-static void mce_init(void *dummy)
-{
-       u64 cap;
-       int i;
-
-       rdmsrl(MSR_IA32_MCG_CAP, cap);
-       banks = cap & 0xff;
-       if (banks > NR_BANKS) { 
-               printk(KERN_INFO "MCE: warning: using only %d banks\n", banks);
-               banks = NR_BANKS; 
-       }
-       /* Use accurate RIP reporting if available. */
-       if ((cap & (1<<9)) && ((cap >> 16) & 0xff) >= 9)
-               rip_msr = MSR_IA32_MCG_EIP;
-
-       /* Log the machine checks left over from the previous reset.
-          This also clears all registers */
-       do_machine_check(NULL, mce_bootlog ? -1 : -2);
-
-       set_in_cr4(X86_CR4_MCE);
-
-       if (cap & MCG_CTL_P)
-               wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
-
-       for (i = 0; i < banks; i++) {
-               wrmsrl(MSR_IA32_MC0_CTL+4*i, bank[i]);
-               wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
-       }       
-}
-
-/* Add per CPU specific workarounds here */
-static void __cpuinit mce_cpu_quirks(struct cpuinfo_x86 *c)
-{ 
-       /* This should be disabled by the BIOS, but isn't always */
-       if (c->x86_vendor == X86_VENDOR_AMD && c->x86 == 15) {
-               /* disable GART TBL walk error reporting, which trips off 
-                  incorrectly with the IOMMU & 3ware & Cerberus. */
-               clear_bit(10, &bank[4]);
-               /* Lots of broken BIOS around that don't clear them
-                  by default and leave crap in there. Don't log. */
-               mce_bootlog = 0;
-       }
-
-}                      
-
-static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c)
-{
-       switch (c->x86_vendor) {
-       case X86_VENDOR_INTEL:
-               mce_intel_feature_init(c);
-               break;
-       case X86_VENDOR_AMD:
-               mce_amd_feature_init(c);
-               break;
-       default:
-               break;
-       }
-}
-
-/* 
- * Called for each booted CPU to set up machine checks.
- * Must be called with preempt off. 
- */
-void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
-{
-       static cpumask_t mce_cpus = CPU_MASK_NONE;
-
-       mce_cpu_quirks(c); 
-
-       if (mce_dont_init ||
-           cpu_test_and_set(smp_processor_id(), mce_cpus) ||
-           !mce_available(c))
-               return;
-
-       mce_init(NULL);
-       mce_cpu_features(c);
-}
-
-/*
- * Character device to read and clear the MCE log.
- */
-
-static DEFINE_SPINLOCK(mce_state_lock);
-static int open_count; /* #times opened */
-static int open_exclu; /* already open exclusive? */
-
-static int mce_open(struct inode *inode, struct file *file)
-{
-       spin_lock(&mce_state_lock);
-
-       if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
-               spin_unlock(&mce_state_lock);
-               return -EBUSY;
-       }
-
-       if (file->f_flags & O_EXCL)
-               open_exclu = 1;
-       open_count++;
-
-       spin_unlock(&mce_state_lock);
-
-       return nonseekable_open(inode, file);
-}
-
-static int mce_release(struct inode *inode, struct file *file)
-{
-       spin_lock(&mce_state_lock);
-
-       open_count--;
-       open_exclu = 0;
-
-       spin_unlock(&mce_state_lock);
-
-       return 0;
-}
-
-static void collect_tscs(void *data) 
-{ 
-       unsigned long *cpu_tsc = (unsigned long *)data;
-       rdtscll(cpu_tsc[smp_processor_id()]);
-} 
-
-static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, loff_t *off)
-{
-       unsigned long *cpu_tsc;
-       static DECLARE_MUTEX(mce_read_sem);
-       unsigned next;
-       char __user *buf = ubuf;
-       int i, err;
-
-       cpu_tsc = kmalloc(NR_CPUS * sizeof(long), GFP_KERNEL);
-       if (!cpu_tsc)
-               return -ENOMEM;
-
-       down(&mce_read_sem); 
-       next = rcu_dereference(mcelog.next);
-
-       /* Only supports full reads right now */
-       if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { 
-               up(&mce_read_sem);
-               kfree(cpu_tsc);
-               return -EINVAL;
-       }
-
-       err = 0;
-       for (i = 0; i < next; i++) {            
-               unsigned long start = jiffies;
-               while (!mcelog.entry[i].finished) {
-                       if (time_after_eq(jiffies, start + 2)) {
-                               memset(mcelog.entry + i,0, sizeof(struct mce));
-                               goto timeout;
-                       }
-                       cpu_relax();
-               }
-               smp_rmb();
-               err |= copy_to_user(buf, mcelog.entry + i, sizeof(struct mce));
-               buf += sizeof(struct mce); 
- timeout:
-               ;
-       } 
-
-       memset(mcelog.entry, 0, next * sizeof(struct mce));
-       mcelog.next = 0;
-
-       synchronize_sched();
-
-       /* Collect entries that were still getting written before the synchronize. */
-
-       on_each_cpu(collect_tscs, cpu_tsc, 1, 1);
-       for (i = next; i < MCE_LOG_LEN; i++) { 
-               if (mcelog.entry[i].finished && 
-                   mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {  
-                       err |= copy_to_user(buf, mcelog.entry+i, sizeof(struct mce));
-                       smp_rmb();
-                       buf += sizeof(struct mce);
-                       memset(&mcelog.entry[i], 0, sizeof(struct mce));
-               }
-       }       
-       up(&mce_read_sem);
-       kfree(cpu_tsc);
-       return err ? -EFAULT : buf - ubuf; 
-}
-
-static unsigned int mce_poll(struct file *file, poll_table *wait)
-{
-       poll_wait(file, &mce_wait, wait);
-       if (rcu_dereference(mcelog.next))
-               return POLLIN | POLLRDNORM;
-       return 0;
-}
-
-static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned long arg)
-{
-       int __user *p = (int __user *)arg;
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM; 
-       switch (cmd) {
-       case MCE_GET_RECORD_LEN: 
-               return put_user(sizeof(struct mce), p);
-       case MCE_GET_LOG_LEN:
-               return put_user(MCE_LOG_LEN, p);                
-       case MCE_GETCLEAR_FLAGS: {
-               unsigned flags;
-               do { 
-                       flags = mcelog.flags;
-               } while (cmpxchg(&mcelog.flags, flags, 0) != flags); 
-               return put_user(flags, p); 
-       }
-       default:
-               return -ENOTTY; 
-       } 
-}
-
-static const struct file_operations mce_chrdev_ops = {
-       .open = mce_open,
-       .release = mce_release,
-       .read = mce_read,
-       .poll = mce_poll,
-       .ioctl = mce_ioctl,
-};
-
-static struct miscdevice mce_log_device = {
-       MISC_MCELOG_MINOR,
-       "mcelog",
-       &mce_chrdev_ops,
-};
-
-static unsigned long old_cr4 __initdata;
-
-void __init stop_mce(void)
-{
-       old_cr4 = read_cr4();
-       clear_in_cr4(X86_CR4_MCE);
-}
-
-void __init restart_mce(void)
-{
-       if (old_cr4 & X86_CR4_MCE)
-               set_in_cr4(X86_CR4_MCE);
-}
-
-/* 
- * Old style boot options parsing. Only for compatibility. 
- */
-
-static int __init mcheck_disable(char *str)
-{
-       mce_dont_init = 1;
-       return 1;
-}
-
-/* mce=off disables machine check. Note you can reenable it later
-   using sysfs.
-   mce=TOLERANCELEVEL (number, see above)
-   mce=bootlog Log MCEs from before booting. Disabled by default on AMD.
-   mce=nobootlog Don't log MCEs from before booting. */
-static int __init mcheck_enable(char *str)
-{
-       if (*str == '=')
-               str++;
-       if (!strcmp(str, "off"))
-               mce_dont_init = 1;
-       else if (!strcmp(str, "bootlog") || !strcmp(str,"nobootlog"))
-               mce_bootlog = str[0] == 'b';
-       else if (isdigit(str[0]))
-               get_option(&str, &tolerant);
-       else
-               printk("mce= argument %s ignored. Please use /sys", str); 
-       return 1;
-}
-
-__setup("nomce", mcheck_disable);
-__setup("mce", mcheck_enable);
-
-/* 
- * Sysfs support
- */ 
-
-/* On resume clear all MCE state. Don't want to see leftovers from the BIOS.
-   Only one CPU is active at this time, the others get readded later using
-   CPU hotplug. */
-static int mce_resume(struct sys_device *dev)
-{
-       mce_init(NULL);
-       return 0;
-}
-
-/* Reinit MCEs after user configuration changes */
-static void mce_restart(void) 
-{ 
-       if (next_interval)
-               cancel_delayed_work(&mcheck_work);
-       /* Timer race is harmless here */
-       on_each_cpu(mce_init, NULL, 1, 1);       
-       next_interval = check_interval * HZ;
-       if (next_interval)
-               schedule_delayed_work(&mcheck_work,
-                                     round_jiffies_relative(next_interval));
-}
-
-static struct sysdev_class mce_sysclass = {
-       .resume = mce_resume,
-       set_kset_name("machinecheck"),
-};
-
-DEFINE_PER_CPU(struct sys_device, device_mce);
-
-/* Why are there no generic functions for this? */
-#define ACCESSOR(name, var, start) \
-       static ssize_t show_ ## name(struct sys_device *s, char *buf) {                    \
-               return sprintf(buf, "%lx\n", (unsigned long)var);                  \
-       }                                                                          \
-       static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \
-               char *end;                                                         \
-               unsigned long new = simple_strtoul(buf, &end, 0);                  \
-               if (end == buf) return -EINVAL;                                    \
-               var = new;                                                         \
-               start;                                                             \
-               return end-buf;                                                    \
-       }                                                                          \
-       static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name);
-
-/* TBD should generate these dynamically based on number of available banks */
-ACCESSOR(bank0ctl,bank[0],mce_restart())
-ACCESSOR(bank1ctl,bank[1],mce_restart())
-ACCESSOR(bank2ctl,bank[2],mce_restart())
-ACCESSOR(bank3ctl,bank[3],mce_restart())
-ACCESSOR(bank4ctl,bank[4],mce_restart())
-ACCESSOR(bank5ctl,bank[5],mce_restart())
-
-static ssize_t show_trigger(struct sys_device *s, char *buf)
-{
-       strcpy(buf, trigger);
-       strcat(buf, "\n");
-       return strlen(trigger) + 1;
-}
-
-static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
-{
-       char *p;
-       int len;
-       strncpy(trigger, buf, sizeof(trigger));
-       trigger[sizeof(trigger)-1] = 0;
-       len = strlen(trigger);
-       p = strchr(trigger, '\n');
-       if (*p) *p = 0;
-       return len;
-}
-
-static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
-ACCESSOR(tolerant,tolerant,)
-ACCESSOR(check_interval,check_interval,mce_restart())
-static struct sysdev_attribute *mce_attributes[] = {
-       &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
-       &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl,
-       &attr_tolerant, &attr_check_interval, &attr_trigger,
-       NULL
-};
-
-/* Per cpu sysdev init.  All of the cpus still share the same ctl bank */
-static __cpuinit int mce_create_device(unsigned int cpu)
-{
-       int err;
-       int i;
-       if (!mce_available(&cpu_data[cpu]))
-               return -EIO;
-
-       per_cpu(device_mce,cpu).id = cpu;
-       per_cpu(device_mce,cpu).cls = &mce_sysclass;
-
-       err = sysdev_register(&per_cpu(device_mce,cpu));
-
-       if (!err) {
-               for (i = 0; mce_attributes[i]; i++)
-                       sysdev_create_file(&per_cpu(device_mce,cpu),
-                               mce_attributes[i]);
-       }
-       return err;
-}
-
-static void mce_remove_device(unsigned int cpu)
-{
-       int i;
-
-       for (i = 0; mce_attributes[i]; i++)
-               sysdev_remove_file(&per_cpu(device_mce,cpu),
-                       mce_attributes[i]);
-       sysdev_unregister(&per_cpu(device_mce,cpu));
-       memset(&per_cpu(device_mce, cpu).kobj, 0, sizeof(struct kobject));
-}
-
-/* Get notified when a cpu comes on/off. Be hotplug friendly. */
-static int
-mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
-{
-       unsigned int cpu = (unsigned long)hcpu;
-
-       switch (action) {
-       case CPU_ONLINE:
-       case CPU_ONLINE_FROZEN:
-               mce_create_device(cpu);
-               break;
-       case CPU_DEAD:
-       case CPU_DEAD_FROZEN:
-               mce_remove_device(cpu);
-               break;
-       }
-       return NOTIFY_OK;
-}
-
-static struct notifier_block mce_cpu_notifier = {
-       .notifier_call = mce_cpu_callback,
-};
-
-static __init int mce_init_device(void)
-{
-       int err;
-       int i = 0;
-
-       if (!mce_available(&boot_cpu_data))
-               return -EIO;
-       err = sysdev_class_register(&mce_sysclass);
-
-       for_each_online_cpu(i) {
-               mce_create_device(i);
-       }
-
-       register_hotcpu_notifier(&mce_cpu_notifier);
-       misc_register(&mce_log_device);
-       return err;
-}
-
-device_initcall(mce_init_device);
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
deleted file mode 100644 (file)
index 2f8a7f1..0000000
+++ /dev/null
@@ -1,689 +0,0 @@
-/*
- *  (c) 2005, 2006 Advanced Micro Devices, Inc.
- *  Your use of this code is subject to the terms and conditions of the
- *  GNU general public license version 2. See "COPYING" or
- *  http://www.gnu.org/licenses/gpl.html
- *
- *  Written by Jacob Shin - AMD, Inc.
- *
- *  Support : jacob.shin@amd.com
- *
- *  April 2006
- *     - added support for AMD Family 0x10 processors
- *
- *  All MC4_MISCi registers are shared between multi-cores
- */
-
-#include <linux/cpu.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/kobject.h>
-#include <linux/notifier.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/sysdev.h>
-#include <linux/sysfs.h>
-#include <asm/apic.h>
-#include <asm/mce.h>
-#include <asm/msr.h>
-#include <asm/percpu.h>
-#include <asm/idle.h>
-
-#define PFX               "mce_threshold: "
-#define VERSION           "version 1.1.1"
-#define NR_BANKS          6
-#define NR_BLOCKS         9
-#define THRESHOLD_MAX     0xFFF
-#define INT_TYPE_APIC     0x00020000
-#define MASK_VALID_HI     0x80000000
-#define MASK_CNTP_HI      0x40000000
-#define MASK_LOCKED_HI    0x20000000
-#define MASK_LVTOFF_HI    0x00F00000
-#define MASK_COUNT_EN_HI  0x00080000
-#define MASK_INT_TYPE_HI  0x00060000
-#define MASK_OVERFLOW_HI  0x00010000
-#define MASK_ERR_COUNT_HI 0x00000FFF
-#define MASK_BLKPTR_LO    0xFF000000
-#define MCG_XBLK_ADDR     0xC0000400
-
-struct threshold_block {
-       unsigned int block;
-       unsigned int bank;
-       unsigned int cpu;
-       u32 address;
-       u16 interrupt_enable;
-       u16 threshold_limit;
-       struct kobject kobj;
-       struct list_head miscj;
-};
-
-/* defaults used early on boot */
-static struct threshold_block threshold_defaults = {
-       .interrupt_enable = 0,
-       .threshold_limit = THRESHOLD_MAX,
-};
-
-struct threshold_bank {
-       struct kobject kobj;
-       struct threshold_block *blocks;
-       cpumask_t cpus;
-};
-static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]);
-
-#ifdef CONFIG_SMP
-static unsigned char shared_bank[NR_BANKS] = {
-       0, 0, 0, 0, 1
-};
-#endif
-
-static DEFINE_PER_CPU(unsigned char, bank_map);        /* see which banks are on */
-
-/*
- * CPU Initialization
- */
-
-/* must be called with correct cpu affinity */
-static void threshold_restart_bank(struct threshold_block *b,
-                                  int reset, u16 old_limit)
-{
-       u32 mci_misc_hi, mci_misc_lo;
-
-       rdmsr(b->address, mci_misc_lo, mci_misc_hi);
-
-       if (b->threshold_limit < (mci_misc_hi & THRESHOLD_MAX))
-               reset = 1;      /* limit cannot be lower than err count */
-
-       if (reset) {            /* reset err count and overflow bit */
-               mci_misc_hi =
-                   (mci_misc_hi & ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI)) |
-                   (THRESHOLD_MAX - b->threshold_limit);
-       } else if (old_limit) { /* change limit w/o reset */
-               int new_count = (mci_misc_hi & THRESHOLD_MAX) +
-                   (old_limit - b->threshold_limit);
-               mci_misc_hi = (mci_misc_hi & ~MASK_ERR_COUNT_HI) |
-                   (new_count & THRESHOLD_MAX);
-       }
-
-       b->interrupt_enable ?
-           (mci_misc_hi = (mci_misc_hi & ~MASK_INT_TYPE_HI) | INT_TYPE_APIC) :
-           (mci_misc_hi &= ~MASK_INT_TYPE_HI);
-
-       mci_misc_hi |= MASK_COUNT_EN_HI;
-       wrmsr(b->address, mci_misc_lo, mci_misc_hi);
-}
-
-/* cpu init entry point, called from mce.c with preempt off */
-void __cpuinit mce_amd_feature_init(struct cpuinfo_x86 *c)
-{
-       unsigned int bank, block;
-       unsigned int cpu = smp_processor_id();
-       u32 low = 0, high = 0, address = 0;
-
-       for (bank = 0; bank < NR_BANKS; ++bank) {
-               for (block = 0; block < NR_BLOCKS; ++block) {
-                       if (block == 0)
-                               address = MSR_IA32_MC0_MISC + bank * 4;
-                       else if (block == 1) {
-                               address = (low & MASK_BLKPTR_LO) >> 21;
-                               if (!address)
-                                       break;
-                               address += MCG_XBLK_ADDR;
-                       }
-                       else
-                               ++address;
-
-                       if (rdmsr_safe(address, &low, &high))
-                               break;
-
-                       if (!(high & MASK_VALID_HI)) {
-                               if (block)
-                                       continue;
-                               else
-                                       break;
-                       }
-
-                       if (!(high & MASK_CNTP_HI)  ||
-                            (high & MASK_LOCKED_HI))
-                               continue;
-
-                       if (!block)
-                               per_cpu(bank_map, cpu) |= (1 << bank);
-#ifdef CONFIG_SMP
-                       if (shared_bank[bank] && c->cpu_core_id)
-                               break;
-#endif
-                       high &= ~MASK_LVTOFF_HI;
-                       high |= K8_APIC_EXT_LVT_ENTRY_THRESHOLD << 20;
-                       wrmsr(address, low, high);
-
-                       setup_APIC_extended_lvt(K8_APIC_EXT_LVT_ENTRY_THRESHOLD,
-                                               THRESHOLD_APIC_VECTOR,
-                                               K8_APIC_EXT_INT_MSG_FIX, 0);
-
-                       threshold_defaults.address = address;
-                       threshold_restart_bank(&threshold_defaults, 0, 0);
-               }
-       }
-}
-
-/*
- * APIC Interrupt Handler
- */
-
-/*
- * threshold interrupt handler will service THRESHOLD_APIC_VECTOR.
- * the interrupt goes off when error_count reaches threshold_limit.
- * the handler will simply log mcelog w/ software defined bank number.
- */
-asmlinkage void mce_threshold_interrupt(void)
-{
-       unsigned int bank, block;
-       struct mce m;
-       u32 low = 0, high = 0, address = 0;
-
-       ack_APIC_irq();
-       exit_idle();
-       irq_enter();
-
-       memset(&m, 0, sizeof(m));
-       rdtscll(m.tsc);
-       m.cpu = smp_processor_id();
-
-       /* assume first bank caused it */
-       for (bank = 0; bank < NR_BANKS; ++bank) {
-               if (!(per_cpu(bank_map, m.cpu) & (1 << bank)))
-                       continue;
-               for (block = 0; block < NR_BLOCKS; ++block) {
-                       if (block == 0)
-                               address = MSR_IA32_MC0_MISC + bank * 4;
-                       else if (block == 1) {
-                               address = (low & MASK_BLKPTR_LO) >> 21;
-                               if (!address)
-                                       break;
-                               address += MCG_XBLK_ADDR;
-                       }
-                       else
-                               ++address;
-
-                       if (rdmsr_safe(address, &low, &high))
-                               break;
-
-                       if (!(high & MASK_VALID_HI)) {
-                               if (block)
-                                       continue;
-                               else
-                                       break;
-                       }
-
-                       if (!(high & MASK_CNTP_HI)  ||
-                            (high & MASK_LOCKED_HI))
-                               continue;
-
-                       /* Log the machine check that caused the threshold
-                          event. */
-                       do_machine_check(NULL, 0);
-
-                       if (high & MASK_OVERFLOW_HI) {
-                               rdmsrl(address, m.misc);
-                               rdmsrl(MSR_IA32_MC0_STATUS + bank * 4,
-                                      m.status);
-                               m.bank = K8_MCE_THRESHOLD_BASE
-                                      + bank * NR_BLOCKS
-                                      + block;
-                               mce_log(&m);
-                               goto out;
-                       }
-               }
-       }
-out:
-       irq_exit();
-}
-
-/*
- * Sysfs Interface
- */
-
-struct threshold_attr {
-       struct attribute attr;
-       ssize_t(*show) (struct threshold_block *, char *);
-       ssize_t(*store) (struct threshold_block *, const char *, size_t count);
-};
-
-static cpumask_t affinity_set(unsigned int cpu)
-{
-       cpumask_t oldmask = current->cpus_allowed;
-       cpumask_t newmask = CPU_MASK_NONE;
-       cpu_set(cpu, newmask);
-       set_cpus_allowed(current, newmask);
-       return oldmask;
-}
-
-static void affinity_restore(cpumask_t oldmask)
-{
-       set_cpus_allowed(current, oldmask);
-}
-
-#define SHOW_FIELDS(name)                                           \
-static ssize_t show_ ## name(struct threshold_block * b, char *buf) \
-{                                                                   \
-        return sprintf(buf, "%lx\n", (unsigned long) b->name);      \
-}
-SHOW_FIELDS(interrupt_enable)
-SHOW_FIELDS(threshold_limit)
-
-static ssize_t store_interrupt_enable(struct threshold_block *b,
-                                     const char *buf, size_t count)
-{
-       char *end;
-       cpumask_t oldmask;
-       unsigned long new = simple_strtoul(buf, &end, 0);
-       if (end == buf)
-               return -EINVAL;
-       b->interrupt_enable = !!new;
-
-       oldmask = affinity_set(b->cpu);
-       threshold_restart_bank(b, 0, 0);
-       affinity_restore(oldmask);
-
-       return end - buf;
-}
-
-static ssize_t store_threshold_limit(struct threshold_block *b,
-                                    const char *buf, size_t count)
-{
-       char *end;
-       cpumask_t oldmask;
-       u16 old;
-       unsigned long new = simple_strtoul(buf, &end, 0);
-       if (end == buf)
-               return -EINVAL;
-       if (new > THRESHOLD_MAX)
-               new = THRESHOLD_MAX;
-       if (new < 1)
-               new = 1;
-       old = b->threshold_limit;
-       b->threshold_limit = new;
-
-       oldmask = affinity_set(b->cpu);
-       threshold_restart_bank(b, 0, old);
-       affinity_restore(oldmask);
-
-       return end - buf;
-}
-
-static ssize_t show_error_count(struct threshold_block *b, char *buf)
-{
-       u32 high, low;
-       cpumask_t oldmask;
-       oldmask = affinity_set(b->cpu);
-       rdmsr(b->address, low, high);
-       affinity_restore(oldmask);
-       return sprintf(buf, "%x\n",
-                      (high & 0xFFF) - (THRESHOLD_MAX - b->threshold_limit));
-}
-
-static ssize_t store_error_count(struct threshold_block *b,
-                                const char *buf, size_t count)
-{
-       cpumask_t oldmask;
-       oldmask = affinity_set(b->cpu);
-       threshold_restart_bank(b, 1, 0);
-       affinity_restore(oldmask);
-       return 1;
-}
-
-#define THRESHOLD_ATTR(_name,_mode,_show,_store) {            \
-        .attr = {.name = __stringify(_name), .mode = _mode }, \
-        .show = _show,                                        \
-        .store = _store,                                      \
-};
-
-#define RW_ATTR(name)                                           \
-static struct threshold_attr name =                             \
-        THRESHOLD_ATTR(name, 0644, show_## name, store_## name)
-
-RW_ATTR(interrupt_enable);
-RW_ATTR(threshold_limit);
-RW_ATTR(error_count);
-
-static struct attribute *default_attrs[] = {
-       &interrupt_enable.attr,
-       &threshold_limit.attr,
-       &error_count.attr,
-       NULL
-};
-
-#define to_block(k) container_of(k, struct threshold_block, kobj)
-#define to_attr(a) container_of(a, struct threshold_attr, attr)
-
-static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
-{
-       struct threshold_block *b = to_block(kobj);
-       struct threshold_attr *a = to_attr(attr);
-       ssize_t ret;
-       ret = a->show ? a->show(b, buf) : -EIO;
-       return ret;
-}
-
-static ssize_t store(struct kobject *kobj, struct attribute *attr,
-                    const char *buf, size_t count)
-{
-       struct threshold_block *b = to_block(kobj);
-       struct threshold_attr *a = to_attr(attr);
-       ssize_t ret;
-       ret = a->store ? a->store(b, buf, count) : -EIO;
-       return ret;
-}
-
-static struct sysfs_ops threshold_ops = {
-       .show = show,
-       .store = store,
-};
-
-static struct kobj_type threshold_ktype = {
-       .sysfs_ops = &threshold_ops,
-       .default_attrs = default_attrs,
-};
-
-static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
-                                              unsigned int bank,
-                                              unsigned int block,
-                                              u32 address)
-{
-       int err;
-       u32 low, high;
-       struct threshold_block *b = NULL;
-
-       if ((bank >= NR_BANKS) || (block >= NR_BLOCKS))
-               return 0;
-
-       if (rdmsr_safe(address, &low, &high))
-               return 0;
-
-       if (!(high & MASK_VALID_HI)) {
-               if (block)
-                       goto recurse;
-               else
-                       return 0;
-       }
-
-       if (!(high & MASK_CNTP_HI)  ||
-            (high & MASK_LOCKED_HI))
-               goto recurse;
-
-       b = kzalloc(sizeof(struct threshold_block), GFP_KERNEL);
-       if (!b)
-               return -ENOMEM;
-
-       b->block = block;
-       b->bank = bank;
-       b->cpu = cpu;
-       b->address = address;
-       b->interrupt_enable = 0;
-       b->threshold_limit = THRESHOLD_MAX;
-
-       INIT_LIST_HEAD(&b->miscj);
-
-       if (per_cpu(threshold_banks, cpu)[bank]->blocks)
-               list_add(&b->miscj,
-                        &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj);
-       else
-               per_cpu(threshold_banks, cpu)[bank]->blocks = b;
-
-       kobject_set_name(&b->kobj, "misc%i", block);
-       b->kobj.parent = &per_cpu(threshold_banks, cpu)[bank]->kobj;
-       b->kobj.ktype = &threshold_ktype;
-       err = kobject_register(&b->kobj);
-       if (err)
-               goto out_free;
-recurse:
-       if (!block) {
-               address = (low & MASK_BLKPTR_LO) >> 21;
-               if (!address)
-                       return 0;
-               address += MCG_XBLK_ADDR;
-       } else
-               ++address;
-
-       err = allocate_threshold_blocks(cpu, bank, ++block, address);
-       if (err)
-               goto out_free;
-
-       return err;
-
-out_free:
-       if (b) {
-               kobject_unregister(&b->kobj);
-               kfree(b);
-       }
-       return err;
-}
-
-/* symlinks sibling shared banks to first core.  first core owns dir/files. */
-static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
-{
-       int i, err = 0;
-       struct threshold_bank *b = NULL;
-       cpumask_t oldmask = CPU_MASK_NONE;
-       char name[32];
-
-       sprintf(name, "threshold_bank%i", bank);
-
-#ifdef CONFIG_SMP
-       if (cpu_data[cpu].cpu_core_id && shared_bank[bank]) {   /* symlink */
-               i = first_cpu(cpu_core_map[cpu]);
-
-               /* first core not up yet */
-               if (cpu_data[i].cpu_core_id)
-                       goto out;
-
-               /* already linked */
-               if (per_cpu(threshold_banks, cpu)[bank])
-                       goto out;
-
-               b = per_cpu(threshold_banks, i)[bank];
-
-               if (!b)
-                       goto out;
-
-               err = sysfs_create_link(&per_cpu(device_mce, cpu).kobj,
-                                       &b->kobj, name);
-               if (err)
-                       goto out;
-
-               b->cpus = cpu_core_map[cpu];
-               per_cpu(threshold_banks, cpu)[bank] = b;
-               goto out;
-       }
-#endif
-
-       b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL);
-       if (!b) {
-               err = -ENOMEM;
-               goto out;
-       }
-
-       kobject_set_name(&b->kobj, "threshold_bank%i", bank);
-       b->kobj.parent = &per_cpu(device_mce, cpu).kobj;
-#ifndef CONFIG_SMP
-       b->cpus = CPU_MASK_ALL;
-#else
-       b->cpus = cpu_core_map[cpu];
-#endif
-       err = kobject_register(&b->kobj);
-       if (err)
-               goto out_free;
-
-       per_cpu(threshold_banks, cpu)[bank] = b;
-
-       oldmask = affinity_set(cpu);
-       err = allocate_threshold_blocks(cpu, bank, 0,
-                                       MSR_IA32_MC0_MISC + bank * 4);
-       affinity_restore(oldmask);
-
-       if (err)
-               goto out_free;
-
-       for_each_cpu_mask(i, b->cpus) {
-               if (i == cpu)
-                       continue;
-
-               err = sysfs_create_link(&per_cpu(device_mce, i).kobj,
-                                       &b->kobj, name);
-               if (err)
-                       goto out;
-
-               per_cpu(threshold_banks, i)[bank] = b;
-       }
-
-       goto out;
-
-out_free:
-       per_cpu(threshold_banks, cpu)[bank] = NULL;
-       kfree(b);
-out:
-       return err;
-}
-
-/* create dir/files for all valid threshold banks */
-static __cpuinit int threshold_create_device(unsigned int cpu)
-{
-       unsigned int bank;
-       int err = 0;
-
-       for (bank = 0; bank < NR_BANKS; ++bank) {
-               if (!(per_cpu(bank_map, cpu) & 1 << bank))
-                       continue;
-               err = threshold_create_bank(cpu, bank);
-               if (err)
-                       goto out;
-       }
-out:
-       return err;
-}
-
-/*
- * let's be hotplug friendly.
- * in case of multiple core processors, the first core always takes ownership
- *   of shared sysfs dir/files, and rest of the cores will be symlinked to it.
- */
-
-static void deallocate_threshold_block(unsigned int cpu,
-                                                unsigned int bank)
-{
-       struct threshold_block *pos = NULL;
-       struct threshold_block *tmp = NULL;
-       struct threshold_bank *head = per_cpu(threshold_banks, cpu)[bank];
-
-       if (!head)
-               return;
-
-       list_for_each_entry_safe(pos, tmp, &head->blocks->miscj, miscj) {
-               kobject_unregister(&pos->kobj);
-               list_del(&pos->miscj);
-               kfree(pos);
-       }
-
-       kfree(per_cpu(threshold_banks, cpu)[bank]->blocks);
-       per_cpu(threshold_banks, cpu)[bank]->blocks = NULL;
-}
-
-static void threshold_remove_bank(unsigned int cpu, int bank)
-{
-       int i = 0;
-       struct threshold_bank *b;
-       char name[32];
-
-       b = per_cpu(threshold_banks, cpu)[bank];
-
-       if (!b)
-               return;
-
-       if (!b->blocks)
-               goto free_out;
-
-       sprintf(name, "threshold_bank%i", bank);
-
-#ifdef CONFIG_SMP
-       /* sibling symlink */
-       if (shared_bank[bank] && b->blocks->cpu != cpu) {
-               sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name);
-               per_cpu(threshold_banks, cpu)[bank] = NULL;
-               return;
-       }
-#endif
-
-       /* remove all sibling symlinks before unregistering */
-       for_each_cpu_mask(i, b->cpus) {
-               if (i == cpu)
-                       continue;
-
-               sysfs_remove_link(&per_cpu(device_mce, i).kobj, name);
-               per_cpu(threshold_banks, i)[bank] = NULL;
-       }
-
-       deallocate_threshold_block(cpu, bank);
-
-free_out:
-       kobject_unregister(&b->kobj);
-       kfree(b);
-       per_cpu(threshold_banks, cpu)[bank] = NULL;
-}
-
-static void threshold_remove_device(unsigned int cpu)
-{
-       unsigned int bank;
-
-       for (bank = 0; bank < NR_BANKS; ++bank) {
-               if (!(per_cpu(bank_map, cpu) & 1 << bank))
-                       continue;
-               threshold_remove_bank(cpu, bank);
-       }
-}
-
-/* get notified when a cpu comes on/off */
-static int threshold_cpu_callback(struct notifier_block *nfb,
-                                           unsigned long action, void *hcpu)
-{
-       /* cpu was unsigned int to begin with */
-       unsigned int cpu = (unsigned long)hcpu;
-
-       if (cpu >= NR_CPUS)
-               goto out;
-
-       switch (action) {
-       case CPU_ONLINE:
-       case CPU_ONLINE_FROZEN:
-               threshold_create_device(cpu);
-               break;
-       case CPU_DEAD:
-       case CPU_DEAD_FROZEN:
-               threshold_remove_device(cpu);
-               break;
-       default:
-               break;
-       }
-      out:
-       return NOTIFY_OK;
-}
-
-static struct notifier_block threshold_cpu_notifier = {
-       .notifier_call = threshold_cpu_callback,
-};
-
-static __init int threshold_init_device(void)
-{
-       unsigned lcpu = 0;
-
-       /* to hit CPUs online before the notifier is up */
-       for_each_online_cpu(lcpu) {
-               int err = threshold_create_device(lcpu);
-               if (err)
-                       return err;
-       }
-       register_hotcpu_notifier(&threshold_cpu_notifier);
-       return 0;
-}
-
-device_initcall(threshold_init_device);
diff --git a/arch/x86_64/kernel/mce_intel.c b/arch/x86_64/kernel/mce_intel.c
deleted file mode 100644 (file)
index 6551505..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Intel specific MCE features.
- * Copyright 2004 Zwane Mwaikambo <zwane@linuxpower.ca>
- */
-
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/percpu.h>
-#include <asm/processor.h>
-#include <asm/msr.h>
-#include <asm/mce.h>
-#include <asm/hw_irq.h>
-#include <asm/idle.h>
-#include <asm/therm_throt.h>
-
-asmlinkage void smp_thermal_interrupt(void)
-{
-       __u64 msr_val;
-
-       ack_APIC_irq();
-
-       exit_idle();
-       irq_enter();
-
-       rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
-       if (therm_throt_process(msr_val & 1))
-               mce_log_therm_throt_event(smp_processor_id(), msr_val);
-
-       irq_exit();
-}
-
-static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
-{
-       u32 l, h;
-       int tm2 = 0;
-       unsigned int cpu = smp_processor_id();
-
-       if (!cpu_has(c, X86_FEATURE_ACPI))
-               return;
-
-       if (!cpu_has(c, X86_FEATURE_ACC))
-               return;
-
-       /* first check if TM1 is already enabled by the BIOS, in which
-        * case there might be some SMM goo which handles it, so we can't even
-        * put a handler since it might be delivered via SMI already.
-        */
-       rdmsr(MSR_IA32_MISC_ENABLE, l, h);
-       h = apic_read(APIC_LVTTHMR);
-       if ((l & (1 << 3)) && (h & APIC_DM_SMI)) {
-               printk(KERN_DEBUG
-                      "CPU%d: Thermal monitoring handled by SMI\n", cpu);
-               return;
-       }
-
-       if (cpu_has(c, X86_FEATURE_TM2) && (l & (1 << 13)))
-               tm2 = 1;
-
-       if (h & APIC_VECTOR_MASK) {
-               printk(KERN_DEBUG
-                      "CPU%d: Thermal LVT vector (%#x) already "
-                      "installed\n", cpu, (h & APIC_VECTOR_MASK));
-               return;
-       }
-
-       h = THERMAL_APIC_VECTOR;
-       h |= (APIC_DM_FIXED | APIC_LVT_MASKED);
-       apic_write(APIC_LVTTHMR, h);
-
-       rdmsr(MSR_IA32_THERM_INTERRUPT, l, h);
-       wrmsr(MSR_IA32_THERM_INTERRUPT, l | 0x03, h);
-
-       rdmsr(MSR_IA32_MISC_ENABLE, l, h);
-       wrmsr(MSR_IA32_MISC_ENABLE, l | (1 << 3), h);
-
-       l = apic_read(APIC_LVTTHMR);
-       apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
-       printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
-               cpu, tm2 ? "TM2" : "TM1");
-
-       /* enable thermal throttle processing */
-       atomic_set(&therm_throt_en, 1);
-       return;
-}
-
-void __cpuinit mce_intel_feature_init(struct cpuinfo_x86 *c)
-{
-       intel_init_thermal(c);
-}
diff --git a/arch/x86_64/kernel/module.c b/arch/x86_64/kernel/module.c
deleted file mode 100644 (file)
index a888e67..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*  Kernel module help for x86-64
-    Copyright (C) 2001 Rusty Russell.
-    Copyright (C) 2002,2003 Andi Kleen, SuSE Labs.
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-#include <linux/moduleloader.h>
-#include <linux/elf.h>
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/bug.h>
-
-#include <asm/system.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-
-#define DEBUGP(fmt...) 
-
-#ifndef CONFIG_UML
-void module_free(struct module *mod, void *module_region)
-{
-       vfree(module_region);
-       /* FIXME: If module_region == mod->init_region, trim exception
-           table entries. */
-}
-
-void *module_alloc(unsigned long size)
-{
-       struct vm_struct *area;
-
-       if (!size)
-               return NULL;
-       size = PAGE_ALIGN(size);
-       if (size > MODULES_LEN)
-               return NULL;
-
-       area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
-       if (!area)
-               return NULL;
-
-       return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
-}
-#endif
-
-/* We don't need anything special. */
-int module_frob_arch_sections(Elf_Ehdr *hdr,
-                             Elf_Shdr *sechdrs,
-                             char *secstrings,
-                             struct module *mod)
-{
-       return 0;
-}
-
-int apply_relocate_add(Elf64_Shdr *sechdrs,
-                  const char *strtab,
-                  unsigned int symindex,
-                  unsigned int relsec,
-                  struct module *me)
-{
-       unsigned int i;
-       Elf64_Rela *rel = (void *)sechdrs[relsec].sh_addr;
-       Elf64_Sym *sym;
-       void *loc;
-       u64 val; 
-
-       DEBUGP("Applying relocate section %u to %u\n", relsec,
-              sechdrs[relsec].sh_info);
-       for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
-               /* This is where to make the change */
-               loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
-                       + rel[i].r_offset;
-
-               /* This is the symbol it is referring to.  Note that all
-                  undefined symbols have been resolved.  */
-               sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
-                       + ELF64_R_SYM(rel[i].r_info);
-
-               DEBUGP("type %d st_value %Lx r_addend %Lx loc %Lx\n",
-                      (int)ELF64_R_TYPE(rel[i].r_info), 
-                      sym->st_value, rel[i].r_addend, (u64)loc);
-
-               val = sym->st_value + rel[i].r_addend; 
-
-               switch (ELF64_R_TYPE(rel[i].r_info)) {
-               case R_X86_64_NONE:
-                       break;
-               case R_X86_64_64:
-                       *(u64 *)loc = val;
-                       break;
-               case R_X86_64_32:
-                       *(u32 *)loc = val;
-                       if (val != *(u32 *)loc)
-                               goto overflow;
-                       break;
-               case R_X86_64_32S:
-                       *(s32 *)loc = val;
-                       if ((s64)val != *(s32 *)loc)
-                               goto overflow;
-                       break;
-               case R_X86_64_PC32: 
-                       val -= (u64)loc;
-                       *(u32 *)loc = val;
-#if 0
-                       if ((s64)val != *(s32 *)loc)
-                               goto overflow; 
-#endif
-                       break;
-               default:
-                       printk(KERN_ERR "module %s: Unknown rela relocation: %Lu\n",
-                              me->name, ELF64_R_TYPE(rel[i].r_info));
-                       return -ENOEXEC;
-               }
-       }
-       return 0;
-
-overflow:
-       printk(KERN_ERR "overflow in relocation type %d val %Lx\n", 
-              (int)ELF64_R_TYPE(rel[i].r_info), val);
-       printk(KERN_ERR "`%s' likely not compiled with -mcmodel=kernel\n",
-              me->name);
-       return -ENOEXEC;
-}
-
-int apply_relocate(Elf_Shdr *sechdrs,
-                  const char *strtab,
-                  unsigned int symindex,
-                  unsigned int relsec,
-                  struct module *me)
-{
-       printk("non add relocation not supported\n");
-       return -ENOSYS;
-} 
-
-int module_finalize(const Elf_Ehdr *hdr,
-                    const Elf_Shdr *sechdrs,
-                    struct module *me)
-{
-       const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL;
-       char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-
-       for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
-               if (!strcmp(".text", secstrings + s->sh_name))
-                       text = s;
-               if (!strcmp(".altinstructions", secstrings + s->sh_name))
-                       alt = s;
-               if (!strcmp(".smp_locks", secstrings + s->sh_name))
-                       locks= s;
-       }
-
-       if (alt) {
-               /* patch .altinstructions */
-               void *aseg = (void *)alt->sh_addr;
-               apply_alternatives(aseg, aseg + alt->sh_size);
-       }
-       if (locks && text) {
-               void *lseg = (void *)locks->sh_addr;
-               void *tseg = (void *)text->sh_addr;
-               alternatives_smp_module_add(me, me->name,
-                                           lseg, lseg + locks->sh_size,
-                                           tseg, tseg + text->sh_size);
-       }
-
-       return module_bug_finalize(hdr, sechdrs, me);
-}
-
-void module_arch_cleanup(struct module *mod)
-{
-       alternatives_smp_module_del(mod);
-       module_bug_cleanup(mod);
-}
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
deleted file mode 100644 (file)
index 8bf0ca0..0000000
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- *     Intel Multiprocessor Specification 1.1 and 1.4
- *     compliant MP-table parsing routines.
- *
- *     (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
- *     (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
- *
- *     Fixes
- *             Erich Boleyn    :       MP v1.4 and additional changes.
- *             Alan Cox        :       Added EBDA scanning
- *             Ingo Molnar     :       various cleanups and rewrites
- *             Maciej W. Rozycki:      Bits for default MP configurations
- *             Paul Diefenbaugh:       Added full ACPI support
- */
-
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/bootmem.h>
-#include <linux/kernel_stat.h>
-#include <linux/mc146818rtc.h>
-#include <linux/acpi.h>
-#include <linux/module.h>
-
-#include <asm/smp.h>
-#include <asm/mtrr.h>
-#include <asm/mpspec.h>
-#include <asm/pgalloc.h>
-#include <asm/io_apic.h>
-#include <asm/proto.h>
-#include <asm/acpi.h>
-
-/* Have we found an MP table */
-int smp_found_config;
-
-/*
- * Various Linux-internal data structures created from the
- * MP-table.
- */
-DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
-int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
-
-static int mp_current_pci_id = 0;
-/* I/O APIC entries */
-struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
-
-/* # of MP IRQ source entries */
-struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
-
-/* MP IRQ source entries */
-int mp_irq_entries;
-
-int nr_ioapics;
-unsigned long mp_lapic_addr = 0;
-
-
-
-/* Processor that is doing the boot up */
-unsigned int boot_cpu_id = -1U;
-/* Internal processor count */
-unsigned int num_processors __cpuinitdata = 0;
-
-unsigned disabled_cpus __cpuinitdata;
-
-/* Bitmask of physically existing CPUs */
-physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
-
-u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
-
-
-/*
- * Intel MP BIOS table parsing routines:
- */
-
-/*
- * Checksum an MP configuration block.
- */
-
-static int __init mpf_checksum(unsigned char *mp, int len)
-{
-       int sum = 0;
-
-       while (len--)
-               sum += *mp++;
-
-       return sum & 0xFF;
-}
-
-static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
-{
-       int cpu;
-       cpumask_t tmp_map;
-       char *bootup_cpu = "";
-
-       if (!(m->mpc_cpuflag & CPU_ENABLED)) {
-               disabled_cpus++;
-               return;
-       }
-       if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
-               bootup_cpu = " (Bootup-CPU)";
-               boot_cpu_id = m->mpc_apicid;
-       }
-
-       printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
-
-       if (num_processors >= NR_CPUS) {
-               printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
-                       " Processor ignored.\n", NR_CPUS);
-               return;
-       }
-
-       num_processors++;
-       cpus_complement(tmp_map, cpu_present_map);
-       cpu = first_cpu(tmp_map);
-
-       physid_set(m->mpc_apicid, phys_cpu_present_map);
-       if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
-               /*
-                * bios_cpu_apicid is required to have processors listed
-                * in same order as logical cpu numbers. Hence the first
-                * entry is BSP, and so on.
-                */
-               cpu = 0;
-       }
-       bios_cpu_apicid[cpu] = m->mpc_apicid;
-       x86_cpu_to_apicid[cpu] = m->mpc_apicid;
-
-       cpu_set(cpu, cpu_possible_map);
-       cpu_set(cpu, cpu_present_map);
-}
-
-static void __init MP_bus_info (struct mpc_config_bus *m)
-{
-       char str[7];
-
-       memcpy(str, m->mpc_bustype, 6);
-       str[6] = 0;
-       Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
-
-       if (strncmp(str, "ISA", 3) == 0) {
-               set_bit(m->mpc_busid, mp_bus_not_pci);
-       } else if (strncmp(str, "PCI", 3) == 0) {
-               clear_bit(m->mpc_busid, mp_bus_not_pci);
-               mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
-               mp_current_pci_id++;
-       } else {
-               printk(KERN_ERR "Unknown bustype %s\n", str);
-       }
-}
-
-static int bad_ioapic(unsigned long address)
-{
-       if (nr_ioapics >= MAX_IO_APICS) {
-               printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
-                       "(found %d)\n", MAX_IO_APICS, nr_ioapics);
-               panic("Recompile kernel with bigger MAX_IO_APICS!\n");
-       }
-       if (!address) {
-               printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
-                       " found in table, skipping!\n");
-               return 1;
-       }
-       return 0;
-}
-
-static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
-{
-       if (!(m->mpc_flags & MPC_APIC_USABLE))
-               return;
-
-       printk("I/O APIC #%d at 0x%X.\n",
-               m->mpc_apicid, m->mpc_apicaddr);
-
-       if (bad_ioapic(m->mpc_apicaddr))
-               return;
-
-       mp_ioapics[nr_ioapics] = *m;
-       nr_ioapics++;
-}
-
-static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
-{
-       mp_irqs [mp_irq_entries] = *m;
-       Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
-               " IRQ %02x, APIC ID %x, APIC INT %02x\n",
-                       m->mpc_irqtype, m->mpc_irqflag & 3,
-                       (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
-                       m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
-       if (++mp_irq_entries >= MAX_IRQ_SOURCES)
-               panic("Max # of irq sources exceeded!!\n");
-}
-
-static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
-{
-       Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
-               " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
-                       m->mpc_irqtype, m->mpc_irqflag & 3,
-                       (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
-                       m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
-}
-
-/*
- * Read/parse the MPC
- */
-
-static int __init smp_read_mpc(struct mp_config_table *mpc)
-{
-       char str[16];
-       int count=sizeof(*mpc);
-       unsigned char *mpt=((unsigned char *)mpc)+count;
-
-       if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
-               printk("MPTABLE: bad signature [%c%c%c%c]!\n",
-                       mpc->mpc_signature[0],
-                       mpc->mpc_signature[1],
-                       mpc->mpc_signature[2],
-                       mpc->mpc_signature[3]);
-               return 0;
-       }
-       if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
-               printk("MPTABLE: checksum error!\n");
-               return 0;
-       }
-       if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
-               printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
-                       mpc->mpc_spec);
-               return 0;
-       }
-       if (!mpc->mpc_lapic) {
-               printk(KERN_ERR "MPTABLE: null local APIC address!\n");
-               return 0;
-       }
-       memcpy(str,mpc->mpc_oem,8);
-       str[8] = 0;
-       printk(KERN_INFO "MPTABLE: OEM ID: %s ",str);
-
-       memcpy(str,mpc->mpc_productid,12);
-       str[12] = 0;
-       printk("MPTABLE: Product ID: %s ",str);
-
-       printk("MPTABLE: APIC at: 0x%X\n",mpc->mpc_lapic);
-
-       /* save the local APIC address, it might be non-default */
-       if (!acpi_lapic)
-               mp_lapic_addr = mpc->mpc_lapic;
-
-       /*
-        *      Now process the configuration blocks.
-        */
-       while (count < mpc->mpc_length) {
-               switch(*mpt) {
-                       case MP_PROCESSOR:
-                       {
-                               struct mpc_config_processor *m=
-                                       (struct mpc_config_processor *)mpt;
-                               if (!acpi_lapic)
-                                       MP_processor_info(m);
-                               mpt += sizeof(*m);
-                               count += sizeof(*m);
-                               break;
-                       }
-                       case MP_BUS:
-                       {
-                               struct mpc_config_bus *m=
-                                       (struct mpc_config_bus *)mpt;
-                               MP_bus_info(m);
-                               mpt += sizeof(*m);
-                               count += sizeof(*m);
-                               break;
-                       }
-                       case MP_IOAPIC:
-                       {
-                               struct mpc_config_ioapic *m=
-                                       (struct mpc_config_ioapic *)mpt;
-                               MP_ioapic_info(m);
-                               mpt += sizeof(*m);
-                               count += sizeof(*m);
-                               break;
-                       }
-                       case MP_INTSRC:
-                       {
-                               struct mpc_config_intsrc *m=
-                                       (struct mpc_config_intsrc *)mpt;
-
-                               MP_intsrc_info(m);
-                               mpt += sizeof(*m);
-                               count += sizeof(*m);
-                               break;
-                       }
-                       case MP_LINTSRC:
-                       {
-                               struct mpc_config_lintsrc *m=
-                                       (struct mpc_config_lintsrc *)mpt;
-                               MP_lintsrc_info(m);
-                               mpt += sizeof(*m);
-                               count += sizeof(*m);
-                               break;
-                       }
-               }
-       }
-       setup_apic_routing();
-       if (!num_processors)
-               printk(KERN_ERR "MPTABLE: no processors registered!\n");
-       return num_processors;
-}
-
-static int __init ELCR_trigger(unsigned int irq)
-{
-       unsigned int port;
-
-       port = 0x4d0 + (irq >> 3);
-       return (inb(port) >> (irq & 7)) & 1;
-}
-
-static void __init construct_default_ioirq_mptable(int mpc_default_type)
-{
-       struct mpc_config_intsrc intsrc;
-       int i;
-       int ELCR_fallback = 0;
-
-       intsrc.mpc_type = MP_INTSRC;
-       intsrc.mpc_irqflag = 0;                 /* conforming */
-       intsrc.mpc_srcbus = 0;
-       intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
-
-       intsrc.mpc_irqtype = mp_INT;
-
-       /*
-        *  If true, we have an ISA/PCI system with no IRQ entries
-        *  in the MP table. To prevent the PCI interrupts from being set up
-        *  incorrectly, we try to use the ELCR. The sanity check to see if
-        *  there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
-        *  never be level sensitive, so we simply see if the ELCR agrees.
-        *  If it does, we assume it's valid.
-        */
-       if (mpc_default_type == 5) {
-               printk(KERN_INFO "ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
-
-               if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
-                       printk(KERN_ERR "ELCR contains invalid data... not using ELCR\n");
-               else {
-                       printk(KERN_INFO "Using ELCR to identify PCI interrupts\n");
-                       ELCR_fallback = 1;
-               }
-       }
-
-       for (i = 0; i < 16; i++) {
-               switch (mpc_default_type) {
-               case 2:
-                       if (i == 0 || i == 13)
-                               continue;       /* IRQ0 & IRQ13 not connected */
-                       /* fall through */
-               default:
-                       if (i == 2)
-                               continue;       /* IRQ2 is never connected */
-               }
-
-               if (ELCR_fallback) {
-                       /*
-                        *  If the ELCR indicates a level-sensitive interrupt, we
-                        *  copy that information over to the MP table in the
-                        *  irqflag field (level sensitive, active high polarity).
-                        */
-                       if (ELCR_trigger(i))
-                               intsrc.mpc_irqflag = 13;
-                       else
-                               intsrc.mpc_irqflag = 0;
-               }
-
-               intsrc.mpc_srcbusirq = i;
-               intsrc.mpc_dstirq = i ? i : 2;          /* IRQ0 to INTIN2 */
-               MP_intsrc_info(&intsrc);
-       }
-
-       intsrc.mpc_irqtype = mp_ExtINT;
-       intsrc.mpc_srcbusirq = 0;
-       intsrc.mpc_dstirq = 0;                          /* 8259A to INTIN0 */
-       MP_intsrc_info(&intsrc);
-}
-
-static inline void __init construct_default_ISA_mptable(int mpc_default_type)
-{
-       struct mpc_config_processor processor;
-       struct mpc_config_bus bus;
-       struct mpc_config_ioapic ioapic;
-       struct mpc_config_lintsrc lintsrc;
-       int linttypes[2] = { mp_ExtINT, mp_NMI };
-       int i;
-
-       /*
-        * local APIC has default address
-        */
-       mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
-
-       /*
-        * 2 CPUs, numbered 0 & 1.
-        */
-       processor.mpc_type = MP_PROCESSOR;
-       processor.mpc_apicver = 0;
-       processor.mpc_cpuflag = CPU_ENABLED;
-       processor.mpc_cpufeature = 0;
-       processor.mpc_featureflag = 0;
-       processor.mpc_reserved[0] = 0;
-       processor.mpc_reserved[1] = 0;
-       for (i = 0; i < 2; i++) {
-               processor.mpc_apicid = i;
-               MP_processor_info(&processor);
-       }
-
-       bus.mpc_type = MP_BUS;
-       bus.mpc_busid = 0;
-       switch (mpc_default_type) {
-               default:
-                       printk(KERN_ERR "???\nUnknown standard configuration %d\n",
-                               mpc_default_type);
-                       /* fall through */
-               case 1:
-               case 5:
-                       memcpy(bus.mpc_bustype, "ISA   ", 6);
-                       break;
-       }
-       MP_bus_info(&bus);
-       if (mpc_default_type > 4) {
-               bus.mpc_busid = 1;
-               memcpy(bus.mpc_bustype, "PCI   ", 6);
-               MP_bus_info(&bus);
-       }
-
-       ioapic.mpc_type = MP_IOAPIC;
-       ioapic.mpc_apicid = 2;
-       ioapic.mpc_apicver = 0;
-       ioapic.mpc_flags = MPC_APIC_USABLE;
-       ioapic.mpc_apicaddr = 0xFEC00000;
-       MP_ioapic_info(&ioapic);
-
-       /*
-        * We set up most of the low 16 IO-APIC pins according to MPS rules.
-        */
-       construct_default_ioirq_mptable(mpc_default_type);
-
-       lintsrc.mpc_type = MP_LINTSRC;
-       lintsrc.mpc_irqflag = 0;                /* conforming */
-       lintsrc.mpc_srcbusid = 0;
-       lintsrc.mpc_srcbusirq = 0;
-       lintsrc.mpc_destapic = MP_APIC_ALL;
-       for (i = 0; i < 2; i++) {
-               lintsrc.mpc_irqtype = linttypes[i];
-               lintsrc.mpc_destapiclint = i;
-               MP_lintsrc_info(&lintsrc);
-       }
-}
-
-static struct intel_mp_floating *mpf_found;
-
-/*
- * Scan the memory blocks for an SMP configuration block.
- */
-void __init get_smp_config (void)
-{
-       struct intel_mp_floating *mpf = mpf_found;
-
-       /*
-        * ACPI supports both logical (e.g. Hyper-Threading) and physical 
-        * processors, where MPS only supports physical.
-        */
-       if (acpi_lapic && acpi_ioapic) {
-               printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
-               return;
-       }
-       else if (acpi_lapic)
-               printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
-
-       printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
-
-       /*
-        * Now see if we need to read further.
-        */
-       if (mpf->mpf_feature1 != 0) {
-
-               printk(KERN_INFO "Default MP configuration #%d\n", mpf->mpf_feature1);
-               construct_default_ISA_mptable(mpf->mpf_feature1);
-
-       } else if (mpf->mpf_physptr) {
-
-               /*
-                * Read the physical hardware table.  Anything here will
-                * override the defaults.
-                */
-               if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
-                       smp_found_config = 0;
-                       printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
-                       printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
-                       return;
-               }
-               /*
-                * If there are no explicit MP IRQ entries, then we are
-                * broken.  We set up most of the low 16 IO-APIC pins to
-                * ISA defaults and hope it will work.
-                */
-               if (!mp_irq_entries) {
-                       struct mpc_config_bus bus;
-
-                       printk(KERN_ERR "BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
-
-                       bus.mpc_type = MP_BUS;
-                       bus.mpc_busid = 0;
-                       memcpy(bus.mpc_bustype, "ISA   ", 6);
-                       MP_bus_info(&bus);
-
-                       construct_default_ioirq_mptable(0);
-               }
-
-       } else
-               BUG();
-
-       printk(KERN_INFO "Processors: %d\n", num_processors);
-       /*
-        * Only use the first configuration found.
-        */
-}
-
-static int __init smp_scan_config (unsigned long base, unsigned long length)
-{
-       extern void __bad_mpf_size(void); 
-       unsigned int *bp = phys_to_virt(base);
-       struct intel_mp_floating *mpf;
-
-       Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
-       if (sizeof(*mpf) != 16)
-               __bad_mpf_size();
-
-       while (length > 0) {
-               mpf = (struct intel_mp_floating *)bp;
-               if ((*bp == SMP_MAGIC_IDENT) &&
-                       (mpf->mpf_length == 1) &&
-                       !mpf_checksum((unsigned char *)bp, 16) &&
-                       ((mpf->mpf_specification == 1)
-                               || (mpf->mpf_specification == 4)) ) {
-
-                       smp_found_config = 1;
-                       reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE);
-                       if (mpf->mpf_physptr)
-                               reserve_bootmem_generic(mpf->mpf_physptr, PAGE_SIZE);
-                       mpf_found = mpf;
-                       return 1;
-               }
-               bp += 4;
-               length -= 16;
-       }
-       return 0;
-}
-
-void __init find_smp_config(void)
-{
-       unsigned int address;
-
-       /*
-        * FIXME: Linux assumes you have 640K of base ram..
-        * this continues the error...
-        *
-        * 1) Scan the bottom 1K for a signature
-        * 2) Scan the top 1K of base RAM
-        * 3) Scan the 64K of bios
-        */
-       if (smp_scan_config(0x0,0x400) ||
-               smp_scan_config(639*0x400,0x400) ||
-                       smp_scan_config(0xF0000,0x10000))
-               return;
-       /*
-        * If it is an SMP machine we should know now.
-        *
-        * there is a real-mode segmented pointer pointing to the
-        * 4K EBDA area at 0x40E, calculate and scan it here.
-        *
-        * NOTE! There are Linux loaders that will corrupt the EBDA
-        * area, and as such this kind of SMP config may be less
-        * trustworthy, simply because the SMP table may have been
-        * stomped on during early boot. These loaders are buggy and
-        * should be fixed.
-        */
-
-       address = *(unsigned short *)phys_to_virt(0x40E);
-       address <<= 4;
-       if (smp_scan_config(address, 0x1000))
-               return;
-
-       /* If we have come this far, we did not find an MP table  */
-        printk(KERN_INFO "No mptable found.\n");
-}
-
-/* --------------------------------------------------------------------------
-                            ACPI-based MP Configuration
-   -------------------------------------------------------------------------- */
-
-#ifdef CONFIG_ACPI
-
-void __init mp_register_lapic_address(u64 address)
-{
-       mp_lapic_addr = (unsigned long) address;
-       set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
-       if (boot_cpu_id == -1U)
-               boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
-}
-
-void __cpuinit mp_register_lapic (u8 id, u8 enabled)
-{
-       struct mpc_config_processor processor;
-       int                     boot_cpu = 0;
-       
-       if (id == boot_cpu_id)
-               boot_cpu = 1;
-
-       processor.mpc_type = MP_PROCESSOR;
-       processor.mpc_apicid = id;
-       processor.mpc_apicver = 0;
-       processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
-       processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
-       processor.mpc_cpufeature = 0;
-       processor.mpc_featureflag = 0;
-       processor.mpc_reserved[0] = 0;
-       processor.mpc_reserved[1] = 0;
-
-       MP_processor_info(&processor);
-}
-
-#define MP_ISA_BUS             0
-#define MP_MAX_IOAPIC_PIN      127
-
-static struct mp_ioapic_routing {
-       int                     apic_id;
-       int                     gsi_start;
-       int                     gsi_end;
-       u32                     pin_programmed[4];
-} mp_ioapic_routing[MAX_IO_APICS];
-
-static int mp_find_ioapic(int gsi)
-{
-       int i = 0;
-
-       /* Find the IOAPIC that manages this GSI. */
-       for (i = 0; i < nr_ioapics; i++) {
-               if ((gsi >= mp_ioapic_routing[i].gsi_start)
-                       && (gsi <= mp_ioapic_routing[i].gsi_end))
-                       return i;
-       }
-
-       printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
-       return -1;
-}
-
-static u8 uniq_ioapic_id(u8 id)
-{
-       int i;
-       DECLARE_BITMAP(used, 256);
-       bitmap_zero(used, 256);
-       for (i = 0; i < nr_ioapics; i++) {
-               struct mpc_config_ioapic *ia = &mp_ioapics[i];
-               __set_bit(ia->mpc_apicid, used);
-       }
-       if (!test_bit(id, used))
-               return id;
-       return find_first_zero_bit(used, 256);
-}
-
-void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
-{
-       int idx = 0;
-
-       if (bad_ioapic(address))
-               return;
-
-       idx = nr_ioapics;
-
-       mp_ioapics[idx].mpc_type = MP_IOAPIC;
-       mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
-       mp_ioapics[idx].mpc_apicaddr = address;
-
-       set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
-       mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
-       mp_ioapics[idx].mpc_apicver = 0;
-       
-       /* 
-        * Build basic IRQ lookup table to facilitate gsi->io_apic lookups
-        * and to prevent reprogramming of IOAPIC pins (PCI IRQs).
-        */
-       mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
-       mp_ioapic_routing[idx].gsi_start = gsi_base;
-       mp_ioapic_routing[idx].gsi_end = gsi_base + 
-               io_apic_get_redir_entries(idx);
-
-       printk(KERN_INFO "IOAPIC[%d]: apic_id %d, address 0x%x, "
-               "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid, 
-               mp_ioapics[idx].mpc_apicaddr,
-               mp_ioapic_routing[idx].gsi_start,
-               mp_ioapic_routing[idx].gsi_end);
-
-       nr_ioapics++;
-}
-
-void __init
-mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32        gsi)
-{
-       struct mpc_config_intsrc intsrc;
-       int                     ioapic = -1;
-       int                     pin = -1;
-
-       /* 
-        * Convert 'gsi' to 'ioapic.pin'.
-        */
-       ioapic = mp_find_ioapic(gsi);
-       if (ioapic < 0)
-               return;
-       pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
-
-       /*
-        * TBD: This check is for faulty timer entries, where the override
-        *      erroneously sets the trigger to level, resulting in a HUGE 
-        *      increase of timer interrupts!
-        */
-       if ((bus_irq == 0) && (trigger == 3))
-               trigger = 1;
-
-       intsrc.mpc_type = MP_INTSRC;
-       intsrc.mpc_irqtype = mp_INT;
-       intsrc.mpc_irqflag = (trigger << 2) | polarity;
-       intsrc.mpc_srcbus = MP_ISA_BUS;
-       intsrc.mpc_srcbusirq = bus_irq;                                /* IRQ */
-       intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;        /* APIC ID */
-       intsrc.mpc_dstirq = pin;                                    /* INTIN# */
-
-       Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n", 
-               intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-               (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-               intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
-
-       mp_irqs[mp_irq_entries] = intsrc;
-       if (++mp_irq_entries == MAX_IRQ_SOURCES)
-               panic("Max # of irq sources exceeded!\n");
-}
-
-void __init mp_config_acpi_legacy_irqs(void)
-{
-       struct mpc_config_intsrc intsrc;
-       int i = 0;
-       int ioapic = -1;
-
-       /* 
-        * Fabricate the legacy ISA bus (bus #31).
-        */
-       set_bit(MP_ISA_BUS, mp_bus_not_pci);
-
-       /* 
-        * Locate the IOAPIC that manages the ISA IRQs (0-15). 
-        */
-       ioapic = mp_find_ioapic(0);
-       if (ioapic < 0)
-               return;
-
-       intsrc.mpc_type = MP_INTSRC;
-       intsrc.mpc_irqflag = 0;                                 /* Conforming */
-       intsrc.mpc_srcbus = MP_ISA_BUS;
-       intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
-
-       /* 
-        * Use the default configuration for the IRQs 0-15.  Unless
-        * overridden by (MADT) interrupt source override entries.
-        */
-       for (i = 0; i < 16; i++) {
-               int idx;
-
-               for (idx = 0; idx < mp_irq_entries; idx++) {
-                       struct mpc_config_intsrc *irq = mp_irqs + idx;
-
-                       /* Do we already have a mapping for this ISA IRQ? */
-                       if (irq->mpc_srcbus == MP_ISA_BUS && irq->mpc_srcbusirq == i)
-                               break;
-
-                       /* Do we already have a mapping for this IOAPIC pin */
-                       if ((irq->mpc_dstapic == intsrc.mpc_dstapic) &&
-                               (irq->mpc_dstirq == i))
-                               break;
-               }
-
-               if (idx != mp_irq_entries) {
-                       printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
-                       continue;                       /* IRQ already used */
-               }
-
-               intsrc.mpc_irqtype = mp_INT;
-               intsrc.mpc_srcbusirq = i;                  /* Identity mapped */
-               intsrc.mpc_dstirq = i;
-
-               Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
-                       "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-                       (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-                       intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, 
-                       intsrc.mpc_dstirq);
-
-               mp_irqs[mp_irq_entries] = intsrc;
-               if (++mp_irq_entries == MAX_IRQ_SOURCES)
-                       panic("Max # of irq sources exceeded!\n");
-       }
-}
-
-int mp_register_gsi(u32 gsi, int triggering, int polarity)
-{
-       int ioapic = -1;
-       int ioapic_pin = 0;
-       int idx, bit = 0;
-
-       if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
-               return gsi;
-
-       /* Don't set up the ACPI SCI because it's already set up */
-       if (acpi_gbl_FADT.sci_interrupt == gsi)
-               return gsi;
-
-       ioapic = mp_find_ioapic(gsi);
-       if (ioapic < 0) {
-               printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
-               return gsi;
-       }
-
-       ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
-
-       /* 
-        * Avoid pin reprogramming.  PRTs typically include entries  
-        * with redundant pin->gsi mappings (but unique PCI devices);
-        * we only program the IOAPIC on the first.
-        */
-       bit = ioapic_pin % 32;
-       idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
-       if (idx > 3) {
-               printk(KERN_ERR "Invalid reference to IOAPIC pin "
-                       "%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
-                       ioapic_pin);
-               return gsi;
-       }
-       if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
-               Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
-                       mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
-               return gsi;
-       }
-
-       mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
-
-       io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
-               triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
-               polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
-       return gsi;
-}
-#endif /*CONFIG_ACPI*/
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
deleted file mode 100644 (file)
index 0ec6d2d..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- *  linux/arch/x86_64/nmi.c
- *
- *  NMI watchdog support on APIC systems
- *
- *  Started by Ingo Molnar <mingo@redhat.com>
- *
- *  Fixes:
- *  Mikael Pettersson  : AMD K7 support for local APIC NMI watchdog.
- *  Mikael Pettersson  : Power Management for local APIC NMI watchdog.
- *  Pavel Machek and
- *  Mikael Pettersson  : PM converted to driver model. Disable/enable API.
- */
-
-#include <linux/nmi.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/sysdev.h>
-#include <linux/sysctl.h>
-#include <linux/kprobes.h>
-#include <linux/cpumask.h>
-#include <linux/kdebug.h>
-
-#include <asm/smp.h>
-#include <asm/nmi.h>
-#include <asm/proto.h>
-#include <asm/mce.h>
-
-int unknown_nmi_panic;
-int nmi_watchdog_enabled;
-int panic_on_unrecovered_nmi;
-
-static cpumask_t backtrace_mask = CPU_MASK_NONE;
-
-/* nmi_active:
- * >0: the lapic NMI watchdog is active, but can be disabled
- * <0: the lapic NMI watchdog has not been set up, and cannot
- *     be enabled
- *  0: the lapic NMI watchdog is disabled, but can be enabled
- */
-atomic_t nmi_active = ATOMIC_INIT(0);          /* oprofile uses this */
-int panic_on_timeout;
-
-unsigned int nmi_watchdog = NMI_DEFAULT;
-static unsigned int nmi_hz = HZ;
-
-static DEFINE_PER_CPU(short, wd_enabled);
-
-/* local prototypes */
-static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu);
-
-/* Run after command line and cpu_init init, but before all other checks */
-void nmi_watchdog_default(void)
-{
-       if (nmi_watchdog != NMI_DEFAULT)
-               return;
-       nmi_watchdog = NMI_NONE;
-}
-
-static int endflag __initdata = 0;
-
-#ifdef CONFIG_SMP
-/* The performance counters used by NMI_LOCAL_APIC don't trigger when
- * the CPU is idle. To make sure the NMI watchdog really ticks on all
- * CPUs during the test make them busy.
- */
-static __init void nmi_cpu_busy(void *data)
-{
-       local_irq_enable_in_hardirq();
-       /* Intentionally don't use cpu_relax here. This is
-          to make sure that the performance counter really ticks,
-          even if there is a simulator or similar that catches the
-          pause instruction. On a real HT machine this is fine because
-          all other CPUs are busy with "useless" delay loops and don't
-          care if they get somewhat less cycles. */
-       while (endflag == 0)
-               mb();
-}
-#endif
-
-int __init check_nmi_watchdog (void)
-{
-       int *counts;
-       int cpu;
-
-       if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED)) 
-               return 0;
-
-       if (!atomic_read(&nmi_active))
-               return 0;
-
-       counts = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
-       if (!counts)
-               return -1;
-
-       printk(KERN_INFO "testing NMI watchdog ... ");
-
-#ifdef CONFIG_SMP
-       if (nmi_watchdog == NMI_LOCAL_APIC)
-               smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
-#endif
-
-       for (cpu = 0; cpu < NR_CPUS; cpu++)
-               counts[cpu] = cpu_pda(cpu)->__nmi_count;
-       local_irq_enable();
-       mdelay((20*1000)/nmi_hz); // wait 20 ticks
-
-       for_each_online_cpu(cpu) {
-               if (!per_cpu(wd_enabled, cpu))
-                       continue;
-               if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
-                       printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
-                              cpu,
-                              counts[cpu],
-                              cpu_pda(cpu)->__nmi_count);
-                       per_cpu(wd_enabled, cpu) = 0;
-                       atomic_dec(&nmi_active);
-               }
-       }
-       if (!atomic_read(&nmi_active)) {
-               kfree(counts);
-               atomic_set(&nmi_active, -1);
-               endflag = 1;
-               return -1;
-       }
-       endflag = 1;
-       printk("OK.\n");
-
-       /* now that we know it works we can reduce NMI frequency to
-          something more reasonable; makes a difference in some configs */
-       if (nmi_watchdog == NMI_LOCAL_APIC)
-               nmi_hz = lapic_adjust_nmi_hz(1);
-
-       kfree(counts);
-       return 0;
-}
-
-int __init setup_nmi_watchdog(char *str)
-{
-       int nmi;
-
-       if (!strncmp(str,"panic",5)) {
-               panic_on_timeout = 1;
-               str = strchr(str, ',');
-               if (!str)
-                       return 1;
-               ++str;
-       }
-
-       get_option(&str, &nmi);
-
-       if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))
-               return 0;
-
-       nmi_watchdog = nmi;
-       return 1;
-}
-
-__setup("nmi_watchdog=", setup_nmi_watchdog);
-
-
-static void __acpi_nmi_disable(void *__unused)
-{
-       apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
-}
-
-/*
- * Disable timer based NMIs on all CPUs:
- */
-void acpi_nmi_disable(void)
-{
-       if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
-               on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
-}
-
-static void __acpi_nmi_enable(void *__unused)
-{
-       apic_write(APIC_LVT0, APIC_DM_NMI);
-}
-
-/*
- * Enable timer based NMIs on all CPUs:
- */
-void acpi_nmi_enable(void)
-{
-       if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
-               on_each_cpu(__acpi_nmi_enable, NULL, 0, 1);
-}
-#ifdef CONFIG_PM
-
-static int nmi_pm_active; /* nmi_active before suspend */
-
-static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state)
-{
-       /* only CPU0 goes here, other CPUs should be offline */
-       nmi_pm_active = atomic_read(&nmi_active);
-       stop_apic_nmi_watchdog(NULL);
-       BUG_ON(atomic_read(&nmi_active) != 0);
-       return 0;
-}
-
-static int lapic_nmi_resume(struct sys_device *dev)
-{
-       /* only CPU0 goes here, other CPUs should be offline */
-       if (nmi_pm_active > 0) {
-               setup_apic_nmi_watchdog(NULL);
-               touch_nmi_watchdog();
-       }
-       return 0;
-}
-
-static struct sysdev_class nmi_sysclass = {
-       set_kset_name("lapic_nmi"),
-       .resume         = lapic_nmi_resume,
-       .suspend        = lapic_nmi_suspend,
-};
-
-static struct sys_device device_lapic_nmi = {
-       .id             = 0,
-       .cls    = &nmi_sysclass,
-};
-
-static int __init init_lapic_nmi_sysfs(void)
-{
-       int error;
-
-       /* should really be a BUG_ON but b/c this is an
-        * init call, it just doesn't work.  -dcz
-        */
-       if (nmi_watchdog != NMI_LOCAL_APIC)
-               return 0;
-
-       if ( atomic_read(&nmi_active) < 0 )
-               return 0;
-
-       error = sysdev_class_register(&nmi_sysclass);
-       if (!error)
-               error = sysdev_register(&device_lapic_nmi);
-       return error;
-}
-/* must come after the local APIC's device_initcall() */
-late_initcall(init_lapic_nmi_sysfs);
-
-#endif /* CONFIG_PM */
-
-void setup_apic_nmi_watchdog(void *unused)
-{
-       if (__get_cpu_var(wd_enabled) == 1)
-               return;
-
-       /* cheap hack to support suspend/resume */
-       /* if cpu0 is not active neither should the other cpus */
-       if ((smp_processor_id() != 0) && (atomic_read(&nmi_active) <= 0))
-               return;
-
-       switch (nmi_watchdog) {
-       case NMI_LOCAL_APIC:
-               __get_cpu_var(wd_enabled) = 1;
-               if (lapic_watchdog_init(nmi_hz) < 0) {
-                       __get_cpu_var(wd_enabled) = 0;
-                       return;
-               }
-               /* FALL THROUGH */
-       case NMI_IO_APIC:
-               __get_cpu_var(wd_enabled) = 1;
-               atomic_inc(&nmi_active);
-       }
-}
-
-void stop_apic_nmi_watchdog(void *unused)
-{
-       /* only support LOCAL and IO APICs for now */
-       if ((nmi_watchdog != NMI_LOCAL_APIC) &&
-           (nmi_watchdog != NMI_IO_APIC))
-               return;
-       if (__get_cpu_var(wd_enabled) == 0)
-               return;
-       if (nmi_watchdog == NMI_LOCAL_APIC)
-               lapic_watchdog_stop();
-       __get_cpu_var(wd_enabled) = 0;
-       atomic_dec(&nmi_active);
-}
-
-/*
- * the best way to detect whether a CPU has a 'hard lockup' problem
- * is to check it's local APIC timer IRQ counts. If they are not
- * changing then that CPU has some problem.
- *
- * as these watchdog NMI IRQs are generated on every CPU, we only
- * have to check the current processor.
- */
-
-static DEFINE_PER_CPU(unsigned, last_irq_sum);
-static DEFINE_PER_CPU(local_t, alert_counter);
-static DEFINE_PER_CPU(int, nmi_touch);
-
-void touch_nmi_watchdog(void)
-{
-       if (nmi_watchdog > 0) {
-               unsigned cpu;
-
-               /*
-                * Tell other CPUs to reset their alert counters. We cannot
-                * do it ourselves because the alert count increase is not
-                * atomic.
-                */
-               for_each_present_cpu(cpu) {
-                       if (per_cpu(nmi_touch, cpu) != 1)
-                               per_cpu(nmi_touch, cpu) = 1;
-               }
-       }
-
-       touch_softlockup_watchdog();
-}
-
-int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
-{
-       int sum;
-       int touched = 0;
-       int cpu = smp_processor_id();
-       int rc = 0;
-
-       /* check for other users first */
-       if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
-                       == NOTIFY_STOP) {
-               rc = 1;
-               touched = 1;
-       }
-
-       sum = read_pda(apic_timer_irqs);
-       if (__get_cpu_var(nmi_touch)) {
-               __get_cpu_var(nmi_touch) = 0;
-               touched = 1;
-       }
-
-       if (cpu_isset(cpu, backtrace_mask)) {
-               static DEFINE_SPINLOCK(lock);   /* Serialise the printks */
-
-               spin_lock(&lock);
-               printk("NMI backtrace for cpu %d\n", cpu);
-               dump_stack();
-               spin_unlock(&lock);
-               cpu_clear(cpu, backtrace_mask);
-       }
-
-#ifdef CONFIG_X86_MCE
-       /* Could check oops_in_progress here too, but it's safer
-          not too */
-       if (atomic_read(&mce_entry) > 0)
-               touched = 1;
-#endif
-       /* if the apic timer isn't firing, this cpu isn't doing much */
-       if (!touched && __get_cpu_var(last_irq_sum) == sum) {
-               /*
-                * Ayiee, looks like this CPU is stuck ...
-                * wait a few IRQs (5 seconds) before doing the oops ...
-                */
-               local_inc(&__get_cpu_var(alert_counter));
-               if (local_read(&__get_cpu_var(alert_counter)) == 5*nmi_hz)
-                       die_nmi("NMI Watchdog detected LOCKUP on CPU %d\n", regs,
-                               panic_on_timeout);
-       } else {
-               __get_cpu_var(last_irq_sum) = sum;
-               local_set(&__get_cpu_var(alert_counter), 0);
-       }
-
-       /* see if the nmi watchdog went off */
-       if (!__get_cpu_var(wd_enabled))
-               return rc;
-       switch (nmi_watchdog) {
-       case NMI_LOCAL_APIC:
-               rc |= lapic_wd_event(nmi_hz);
-               break;
-       case NMI_IO_APIC:
-               /* don't know how to accurately check for this.
-                * just assume it was a watchdog timer interrupt
-                * This matches the old behaviour.
-                */
-               rc = 1;
-               break;
-       }
-       return rc;
-}
-
-static unsigned ignore_nmis;
-
-asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
-{
-       nmi_enter();
-       add_pda(__nmi_count,1);
-       if (!ignore_nmis)
-               default_do_nmi(regs);
-       nmi_exit();
-}
-
-int do_nmi_callback(struct pt_regs * regs, int cpu)
-{
-#ifdef CONFIG_SYSCTL
-       if (unknown_nmi_panic)
-               return unknown_nmi_panic_callback(regs, cpu);
-#endif
-       return 0;
-}
-
-void stop_nmi(void)
-{
-       acpi_nmi_disable();
-       ignore_nmis++;
-}
-
-void restart_nmi(void)
-{
-       ignore_nmis--;
-       acpi_nmi_enable();
-}
-
-#ifdef CONFIG_SYSCTL
-
-static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
-{
-       unsigned char reason = get_nmi_reason();
-       char buf[64];
-
-       sprintf(buf, "NMI received for unknown reason %02x\n", reason);
-       die_nmi(buf, regs, 1);  /* Always panic here */
-       return 0;
-}
-
-/*
- * proc handler for /proc/sys/kernel/nmi
- */
-int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
-                       void __user *buffer, size_t *length, loff_t *ppos)
-{
-       int old_state;
-
-       nmi_watchdog_enabled = (atomic_read(&nmi_active) > 0) ? 1 : 0;
-       old_state = nmi_watchdog_enabled;
-       proc_dointvec(table, write, file, buffer, length, ppos);
-       if (!!old_state == !!nmi_watchdog_enabled)
-               return 0;
-
-       if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_DISABLED) {
-               printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
-               return -EIO;
-       }
-
-       /* if nmi_watchdog is not set yet, then set it */
-       nmi_watchdog_default();
-
-       if (nmi_watchdog == NMI_LOCAL_APIC) {
-               if (nmi_watchdog_enabled)
-                       enable_lapic_nmi_watchdog();
-               else
-                       disable_lapic_nmi_watchdog();
-       } else {
-               printk( KERN_WARNING
-                       "NMI watchdog doesn't know what hardware to touch\n");
-               return -EIO;
-       }
-       return 0;
-}
-
-#endif
-
-void __trigger_all_cpu_backtrace(void)
-{
-       int i;
-
-       backtrace_mask = cpu_online_map;
-       /* Wait for up to 10 seconds for all CPUs to do the backtrace */
-       for (i = 0; i < 10 * 1000; i++) {
-               if (cpus_empty(backtrace_mask))
-                       break;
-               mdelay(1);
-       }
-}
-
-EXPORT_SYMBOL(nmi_active);
-EXPORT_SYMBOL(nmi_watchdog);
-EXPORT_SYMBOL(touch_nmi_watchdog);
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
deleted file mode 100644 (file)
index 71da01e..0000000
+++ /dev/null
@@ -1,1578 +0,0 @@
-/*
- * Derived from arch/powerpc/kernel/iommu.c
- *
- * Copyright IBM Corporation, 2006-2007
- * Copyright (C) 2006  Jon Mason <jdmason@kudzu.us>
- *
- * Author: Jon Mason <jdmason@kudzu.us>
- * Author: Muli Ben-Yehuda <muli@il.ibm.com>
-
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>
-#include <linux/dma-mapping.h>
-#include <linux/init.h>
-#include <linux/bitops.h>
-#include <linux/pci_ids.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <asm/iommu.h>
-#include <asm/calgary.h>
-#include <asm/tce.h>
-#include <asm/pci-direct.h>
-#include <asm/system.h>
-#include <asm/dma.h>
-#include <asm/rio.h>
-
-#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
-int use_calgary __read_mostly = 1;
-#else
-int use_calgary __read_mostly = 0;
-#endif /* CONFIG_CALGARY_DEFAULT_ENABLED */
-
-#define PCI_DEVICE_ID_IBM_CALGARY 0x02a1
-#define PCI_DEVICE_ID_IBM_CALIOC2 0x0308
-
-/* register offsets inside the host bridge space */
-#define CALGARY_CONFIG_REG     0x0108
-#define PHB_CSR_OFFSET         0x0110 /* Channel Status */
-#define PHB_PLSSR_OFFSET       0x0120
-#define PHB_CONFIG_RW_OFFSET   0x0160
-#define PHB_IOBASE_BAR_LOW     0x0170
-#define PHB_IOBASE_BAR_HIGH    0x0180
-#define PHB_MEM_1_LOW          0x0190
-#define PHB_MEM_1_HIGH         0x01A0
-#define PHB_IO_ADDR_SIZE       0x01B0
-#define PHB_MEM_1_SIZE         0x01C0
-#define PHB_MEM_ST_OFFSET      0x01D0
-#define PHB_AER_OFFSET         0x0200
-#define PHB_CONFIG_0_HIGH      0x0220
-#define PHB_CONFIG_0_LOW       0x0230
-#define PHB_CONFIG_0_END       0x0240
-#define PHB_MEM_2_LOW          0x02B0
-#define PHB_MEM_2_HIGH         0x02C0
-#define PHB_MEM_2_SIZE_HIGH    0x02D0
-#define PHB_MEM_2_SIZE_LOW     0x02E0
-#define PHB_DOSHOLE_OFFSET     0x08E0
-
-/* CalIOC2 specific */
-#define PHB_SAVIOR_L2          0x0DB0
-#define PHB_PAGE_MIG_CTRL      0x0DA8
-#define PHB_PAGE_MIG_DEBUG     0x0DA0
-#define PHB_ROOT_COMPLEX_STATUS 0x0CB0
-
-/* PHB_CONFIG_RW */
-#define PHB_TCE_ENABLE         0x20000000
-#define PHB_SLOT_DISABLE       0x1C000000
-#define PHB_DAC_DISABLE                0x01000000
-#define PHB_MEM2_ENABLE                0x00400000
-#define PHB_MCSR_ENABLE                0x00100000
-/* TAR (Table Address Register) */
-#define TAR_SW_BITS            0x0000ffffffff800fUL
-#define TAR_VALID              0x0000000000000008UL
-/* CSR (Channel/DMA Status Register) */
-#define CSR_AGENT_MASK         0xffe0ffff
-/* CCR (Calgary Configuration Register) */
-#define CCR_2SEC_TIMEOUT       0x000000000000000EUL
-/* PMCR/PMDR (Page Migration Control/Debug Registers */
-#define PMR_SOFTSTOP           0x80000000
-#define PMR_SOFTSTOPFAULT      0x40000000
-#define PMR_HARDSTOP           0x20000000
-
-#define MAX_NUM_OF_PHBS                8 /* how many PHBs in total? */
-#define MAX_NUM_CHASSIS                8 /* max number of chassis */
-/* MAX_PHB_BUS_NUM is the maximal possible dev->bus->number */
-#define MAX_PHB_BUS_NUM                (MAX_NUM_OF_PHBS * MAX_NUM_CHASSIS * 2)
-#define PHBS_PER_CALGARY       4
-
-/* register offsets in Calgary's internal register space */
-static const unsigned long tar_offsets[] = {
-       0x0580 /* TAR0 */,
-       0x0588 /* TAR1 */,
-       0x0590 /* TAR2 */,
-       0x0598 /* TAR3 */
-};
-
-static const unsigned long split_queue_offsets[] = {
-       0x4870 /* SPLIT QUEUE 0 */,
-       0x5870 /* SPLIT QUEUE 1 */,
-       0x6870 /* SPLIT QUEUE 2 */,
-       0x7870 /* SPLIT QUEUE 3 */
-};
-
-static const unsigned long phb_offsets[] = {
-       0x8000 /* PHB0 */,
-       0x9000 /* PHB1 */,
-       0xA000 /* PHB2 */,
-       0xB000 /* PHB3 */
-};
-
-/* PHB debug registers */
-
-static const unsigned long phb_debug_offsets[] = {
-       0x4000  /* PHB 0 DEBUG */,
-       0x5000  /* PHB 1 DEBUG */,
-       0x6000  /* PHB 2 DEBUG */,
-       0x7000  /* PHB 3 DEBUG */
-};
-
-/*
- * STUFF register for each debug PHB,
- * byte 1 = start bus number, byte 2 = end bus number
- */
-
-#define PHB_DEBUG_STUFF_OFFSET 0x0020
-
-#define EMERGENCY_PAGES 32 /* = 128KB */
-
-unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED;
-static int translate_empty_slots __read_mostly = 0;
-static int calgary_detected __read_mostly = 0;
-
-static struct rio_table_hdr    *rio_table_hdr __initdata;
-static struct scal_detail      *scal_devs[MAX_NUMNODES] __initdata;
-static struct rio_detail       *rio_devs[MAX_NUMNODES * 4] __initdata;
-
-struct calgary_bus_info {
-       void *tce_space;
-       unsigned char translation_disabled;
-       signed char phbid;
-       void __iomem *bbar;
-};
-
-static void calgary_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev);
-static void calgary_tce_cache_blast(struct iommu_table *tbl);
-static void calgary_dump_error_regs(struct iommu_table *tbl);
-static void calioc2_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev);
-static void calioc2_tce_cache_blast(struct iommu_table *tbl);
-static void calioc2_dump_error_regs(struct iommu_table *tbl);
-
-static struct cal_chipset_ops calgary_chip_ops = {
-       .handle_quirks = calgary_handle_quirks,
-       .tce_cache_blast = calgary_tce_cache_blast,
-       .dump_error_regs = calgary_dump_error_regs
-};
-
-static struct cal_chipset_ops calioc2_chip_ops = {
-       .handle_quirks = calioc2_handle_quirks,
-       .tce_cache_blast = calioc2_tce_cache_blast,
-       .dump_error_regs = calioc2_dump_error_regs
-};
-
-static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, };
-
-/* enable this to stress test the chip's TCE cache */
-#ifdef CONFIG_IOMMU_DEBUG
-int debugging __read_mostly = 1;
-
-static inline unsigned long verify_bit_range(unsigned long* bitmap,
-       int expected, unsigned long start, unsigned long end)
-{
-       unsigned long idx = start;
-
-       BUG_ON(start >= end);
-
-       while (idx < end) {
-               if (!!test_bit(idx, bitmap) != expected)
-                       return idx;
-               ++idx;
-       }
-
-       /* all bits have the expected value */
-       return ~0UL;
-}
-#else /* debugging is disabled */
-int debugging __read_mostly = 0;
-
-static inline unsigned long verify_bit_range(unsigned long* bitmap,
-       int expected, unsigned long start, unsigned long end)
-{
-       return ~0UL;
-}
-
-#endif /* CONFIG_IOMMU_DEBUG */
-
-static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
-{
-       unsigned int npages;
-
-       npages = PAGE_ALIGN(dma + dmalen) - (dma & PAGE_MASK);
-       npages >>= PAGE_SHIFT;
-
-       return npages;
-}
-
-static inline int translate_phb(struct pci_dev* dev)
-{
-       int disabled = bus_info[dev->bus->number].translation_disabled;
-       return !disabled;
-}
-
-static void iommu_range_reserve(struct iommu_table *tbl,
-       unsigned long start_addr, unsigned int npages)
-{
-       unsigned long index;
-       unsigned long end;
-       unsigned long badbit;
-       unsigned long flags;
-
-       index = start_addr >> PAGE_SHIFT;
-
-       /* bail out if we're asked to reserve a region we don't cover */
-       if (index >= tbl->it_size)
-               return;
-
-       end = index + npages;
-       if (end > tbl->it_size) /* don't go off the table */
-               end = tbl->it_size;
-
-       spin_lock_irqsave(&tbl->it_lock, flags);
-
-       badbit = verify_bit_range(tbl->it_map, 0, index, end);
-       if (badbit != ~0UL) {
-               if (printk_ratelimit())
-                       printk(KERN_ERR "Calgary: entry already allocated at "
-                              "0x%lx tbl %p dma 0x%lx npages %u\n",
-                              badbit, tbl, start_addr, npages);
-       }
-
-       set_bit_string(tbl->it_map, index, npages);
-
-       spin_unlock_irqrestore(&tbl->it_lock, flags);
-}
-
-static unsigned long iommu_range_alloc(struct iommu_table *tbl,
-       unsigned int npages)
-{
-       unsigned long flags;
-       unsigned long offset;
-
-       BUG_ON(npages == 0);
-
-       spin_lock_irqsave(&tbl->it_lock, flags);
-
-       offset = find_next_zero_string(tbl->it_map, tbl->it_hint,
-                                      tbl->it_size, npages);
-       if (offset == ~0UL) {
-               tbl->chip_ops->tce_cache_blast(tbl);
-               offset = find_next_zero_string(tbl->it_map, 0,
-                                              tbl->it_size, npages);
-               if (offset == ~0UL) {
-                       printk(KERN_WARNING "Calgary: IOMMU full.\n");
-                       spin_unlock_irqrestore(&tbl->it_lock, flags);
-                       if (panic_on_overflow)
-                               panic("Calgary: fix the allocator.\n");
-                       else
-                               return bad_dma_address;
-               }
-       }
-
-       set_bit_string(tbl->it_map, offset, npages);
-       tbl->it_hint = offset + npages;
-       BUG_ON(tbl->it_hint > tbl->it_size);
-
-       spin_unlock_irqrestore(&tbl->it_lock, flags);
-
-       return offset;
-}
-
-static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr,
-       unsigned int npages, int direction)
-{
-       unsigned long entry;
-       dma_addr_t ret = bad_dma_address;
-
-       entry = iommu_range_alloc(tbl, npages);
-
-       if (unlikely(entry == bad_dma_address))
-               goto error;
-
-       /* set the return dma address */
-       ret = (entry << PAGE_SHIFT) | ((unsigned long)vaddr & ~PAGE_MASK);
-
-       /* put the TCEs in the HW table */
-       tce_build(tbl, entry, npages, (unsigned long)vaddr & PAGE_MASK,
-                 direction);
-
-       return ret;
-
-error:
-       printk(KERN_WARNING "Calgary: failed to allocate %u pages in "
-              "iommu %p\n", npages, tbl);
-       return bad_dma_address;
-}
-
-static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
-       unsigned int npages)
-{
-       unsigned long entry;
-       unsigned long badbit;
-       unsigned long badend;
-       unsigned long flags;
-
-       /* were we called with bad_dma_address? */
-       badend = bad_dma_address + (EMERGENCY_PAGES * PAGE_SIZE);
-       if (unlikely((dma_addr >= bad_dma_address) && (dma_addr < badend))) {
-               printk(KERN_ERR "Calgary: driver tried unmapping bad DMA "
-                      "address 0x%Lx\n", dma_addr);
-               WARN_ON(1);
-               return;
-       }
-
-       entry = dma_addr >> PAGE_SHIFT;
-
-       BUG_ON(entry + npages > tbl->it_size);
-
-       tce_free(tbl, entry, npages);
-
-       spin_lock_irqsave(&tbl->it_lock, flags);
-
-       badbit = verify_bit_range(tbl->it_map, 1, entry, entry + npages);
-       if (badbit != ~0UL) {
-               if (printk_ratelimit())
-                       printk(KERN_ERR "Calgary: bit is off at 0x%lx "
-                              "tbl %p dma 0x%Lx entry 0x%lx npages %u\n",
-                              badbit, tbl, dma_addr, entry, npages);
-       }
-
-       __clear_bit_string(tbl->it_map, entry, npages);
-
-       spin_unlock_irqrestore(&tbl->it_lock, flags);
-}
-
-static inline struct iommu_table *find_iommu_table(struct device *dev)
-{
-       struct pci_dev *pdev;
-       struct pci_bus *pbus;
-       struct iommu_table *tbl;
-
-       pdev = to_pci_dev(dev);
-
-       pbus = pdev->bus;
-
-       /* is the device behind a bridge? Look for the root bus */
-       while (pbus->parent)
-               pbus = pbus->parent;
-
-       tbl = pci_iommu(pbus);
-
-       BUG_ON(tbl && (tbl->it_busno != pbus->number));
-
-       return tbl;
-}
-
-static void calgary_unmap_sg(struct device *dev,
-       struct scatterlist *sglist, int nelems, int direction)
-{
-       struct iommu_table *tbl = find_iommu_table(dev);
-
-       if (!translate_phb(to_pci_dev(dev)))
-               return;
-
-       while (nelems--) {
-               unsigned int npages;
-               dma_addr_t dma = sglist->dma_address;
-               unsigned int dmalen = sglist->dma_length;
-
-               if (dmalen == 0)
-                       break;
-
-               npages = num_dma_pages(dma, dmalen);
-               iommu_free(tbl, dma, npages);
-               sglist++;
-       }
-}
-
-static int calgary_nontranslate_map_sg(struct device* dev,
-       struct scatterlist *sg, int nelems, int direction)
-{
-       int i;
-
-       for (i = 0; i < nelems; i++ ) {
-               struct scatterlist *s = &sg[i];
-               BUG_ON(!s->page);
-               s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
-               s->dma_length = s->length;
-       }
-       return nelems;
-}
-
-static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
-       int nelems, int direction)
-{
-       struct iommu_table *tbl = find_iommu_table(dev);
-       unsigned long vaddr;
-       unsigned int npages;
-       unsigned long entry;
-       int i;
-
-       if (!translate_phb(to_pci_dev(dev)))
-               return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
-
-       for (i = 0; i < nelems; i++ ) {
-               struct scatterlist *s = &sg[i];
-               BUG_ON(!s->page);
-
-               vaddr = (unsigned long)page_address(s->page) + s->offset;
-               npages = num_dma_pages(vaddr, s->length);
-
-               entry = iommu_range_alloc(tbl, npages);
-               if (entry == bad_dma_address) {
-                       /* makes sure unmap knows to stop */
-                       s->dma_length = 0;
-                       goto error;
-               }
-
-               s->dma_address = (entry << PAGE_SHIFT) | s->offset;
-
-               /* insert into HW table */
-               tce_build(tbl, entry, npages, vaddr & PAGE_MASK,
-                         direction);
-
-               s->dma_length = s->length;
-       }
-
-       return nelems;
-error:
-       calgary_unmap_sg(dev, sg, nelems, direction);
-       for (i = 0; i < nelems; i++) {
-               sg[i].dma_address = bad_dma_address;
-               sg[i].dma_length = 0;
-       }
-       return 0;
-}
-
-static dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
-       size_t size, int direction)
-{
-       dma_addr_t dma_handle = bad_dma_address;
-       unsigned long uaddr;
-       unsigned int npages;
-       struct iommu_table *tbl = find_iommu_table(dev);
-
-       uaddr = (unsigned long)vaddr;
-       npages = num_dma_pages(uaddr, size);
-
-       if (translate_phb(to_pci_dev(dev)))
-               dma_handle = iommu_alloc(tbl, vaddr, npages, direction);
-       else
-               dma_handle = virt_to_bus(vaddr);
-
-       return dma_handle;
-}
-
-static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
-       size_t size, int direction)
-{
-       struct iommu_table *tbl = find_iommu_table(dev);
-       unsigned int npages;
-
-       if (!translate_phb(to_pci_dev(dev)))
-               return;
-
-       npages = num_dma_pages(dma_handle, size);
-       iommu_free(tbl, dma_handle, npages);
-}
-
-static void* calgary_alloc_coherent(struct device *dev, size_t size,
-       dma_addr_t *dma_handle, gfp_t flag)
-{
-       void *ret = NULL;
-       dma_addr_t mapping;
-       unsigned int npages, order;
-       struct iommu_table *tbl = find_iommu_table(dev);
-
-       size = PAGE_ALIGN(size); /* size rounded up to full pages */
-       npages = size >> PAGE_SHIFT;
-       order = get_order(size);
-
-       /* alloc enough pages (and possibly more) */
-       ret = (void *)__get_free_pages(flag, order);
-       if (!ret)
-               goto error;
-       memset(ret, 0, size);
-
-       if (translate_phb(to_pci_dev(dev))) {
-               /* set up tces to cover the allocated range */
-               mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL);
-               if (mapping == bad_dma_address)
-                       goto free;
-
-               *dma_handle = mapping;
-       } else /* non translated slot */
-               *dma_handle = virt_to_bus(ret);
-
-       return ret;
-
-free:
-       free_pages((unsigned long)ret, get_order(size));
-       ret = NULL;
-error:
-       return ret;
-}
-
-static const struct dma_mapping_ops calgary_dma_ops = {
-       .alloc_coherent = calgary_alloc_coherent,
-       .map_single = calgary_map_single,
-       .unmap_single = calgary_unmap_single,
-       .map_sg = calgary_map_sg,
-       .unmap_sg = calgary_unmap_sg,
-};
-
-static inline void __iomem * busno_to_bbar(unsigned char num)
-{
-       return bus_info[num].bbar;
-}
-
-static inline int busno_to_phbid(unsigned char num)
-{
-       return bus_info[num].phbid;
-}
-
-static inline unsigned long split_queue_offset(unsigned char num)
-{
-       size_t idx = busno_to_phbid(num);
-
-       return split_queue_offsets[idx];
-}
-
-static inline unsigned long tar_offset(unsigned char num)
-{
-       size_t idx = busno_to_phbid(num);
-
-       return tar_offsets[idx];
-}
-
-static inline unsigned long phb_offset(unsigned char num)
-{
-       size_t idx = busno_to_phbid(num);
-
-       return phb_offsets[idx];
-}
-
-static inline void __iomem* calgary_reg(void __iomem *bar, unsigned long offset)
-{
-       unsigned long target = ((unsigned long)bar) | offset;
-       return (void __iomem*)target;
-}
-
-static inline int is_calioc2(unsigned short device)
-{
-       return (device == PCI_DEVICE_ID_IBM_CALIOC2);
-}
-
-static inline int is_calgary(unsigned short device)
-{
-       return (device == PCI_DEVICE_ID_IBM_CALGARY);
-}
-
-static inline int is_cal_pci_dev(unsigned short device)
-{
-       return (is_calgary(device) || is_calioc2(device));
-}
-
-static void calgary_tce_cache_blast(struct iommu_table *tbl)
-{
-       u64 val;
-       u32 aer;
-       int i = 0;
-       void __iomem *bbar = tbl->bbar;
-       void __iomem *target;
-
-       /* disable arbitration on the bus */
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_AER_OFFSET);
-       aer = readl(target);
-       writel(0, target);
-
-       /* read plssr to ensure it got there */
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_PLSSR_OFFSET);
-       val = readl(target);
-
-       /* poll split queues until all DMA activity is done */
-       target = calgary_reg(bbar, split_queue_offset(tbl->it_busno));
-       do {
-               val = readq(target);
-               i++;
-       } while ((val & 0xff) != 0xff && i < 100);
-       if (i == 100)
-               printk(KERN_WARNING "Calgary: PCI bus not quiesced, "
-                      "continuing anyway\n");
-
-       /* invalidate TCE cache */
-       target = calgary_reg(bbar, tar_offset(tbl->it_busno));
-       writeq(tbl->tar_val, target);
-
-       /* enable arbitration */
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_AER_OFFSET);
-       writel(aer, target);
-       (void)readl(target); /* flush */
-}
-
-static void calioc2_tce_cache_blast(struct iommu_table *tbl)
-{
-       void __iomem *bbar = tbl->bbar;
-       void __iomem *target;
-       u64 val64;
-       u32 val;
-       int i = 0;
-       int count = 1;
-       unsigned char bus = tbl->it_busno;
-
-begin:
-       printk(KERN_DEBUG "Calgary: CalIOC2 bus 0x%x entering tce cache blast "
-              "sequence - count %d\n", bus, count);
-
-       /* 1. using the Page Migration Control reg set SoftStop */
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "1a. read 0x%x [LE] from %p\n", val, target);
-       val |= PMR_SOFTSTOP;
-       printk(KERN_DEBUG "1b. writing 0x%x [LE] to %p\n", val, target);
-       writel(cpu_to_be32(val), target);
-
-       /* 2. poll split queues until all DMA activity is done */
-       printk(KERN_DEBUG "2a. starting to poll split queues\n");
-       target = calgary_reg(bbar, split_queue_offset(bus));
-       do {
-               val64 = readq(target);
-               i++;
-       } while ((val64 & 0xff) != 0xff && i < 100);
-       if (i == 100)
-               printk(KERN_WARNING "CalIOC2: PCI bus not quiesced, "
-                      "continuing anyway\n");
-
-       /* 3. poll Page Migration DEBUG for SoftStopFault */
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "3. read 0x%x [LE] from %p\n", val, target);
-
-       /* 4. if SoftStopFault - goto (1) */
-       if (val & PMR_SOFTSTOPFAULT) {
-               if (++count < 100)
-                       goto begin;
-               else {
-                       printk(KERN_WARNING "CalIOC2: too many SoftStopFaults, "
-                              "aborting TCE cache flush sequence!\n");
-                       return; /* pray for the best */
-               }
-       }
-
-       /* 5. Slam into HardStop by reading PHB_PAGE_MIG_CTRL */
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
-       printk(KERN_DEBUG "5a. slamming into HardStop by reading %p\n", target);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "5b. read 0x%x [LE] from %p\n", val, target);
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "5c. read 0x%x [LE] from %p (debug)\n", val, target);
-
-       /* 6. invalidate TCE cache */
-       printk(KERN_DEBUG "6. invalidating TCE cache\n");
-       target = calgary_reg(bbar, tar_offset(bus));
-       writeq(tbl->tar_val, target);
-
-       /* 7. Re-read PMCR */
-       printk(KERN_DEBUG "7a. Re-reading PMCR\n");
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "7b. read 0x%x [LE] from %p\n", val, target);
-
-       /* 8. Remove HardStop */
-       printk(KERN_DEBUG "8a. removing HardStop from PMCR\n");
-       target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
-       val = 0;
-       printk(KERN_DEBUG "8b. writing 0x%x [LE] to %p\n", val, target);
-       writel(cpu_to_be32(val), target);
-       val = be32_to_cpu(readl(target));
-       printk(KERN_DEBUG "8c. read 0x%x [LE] from %p\n", val, target);
-}
-
-static void __init calgary_reserve_mem_region(struct pci_dev *dev, u64 start,
-       u64 limit)
-{
-       unsigned int numpages;
-
-       limit = limit | 0xfffff;
-       limit++;
-
-       numpages = ((limit - start) >> PAGE_SHIFT);
-       iommu_range_reserve(pci_iommu(dev->bus), start, numpages);
-}
-
-static void __init calgary_reserve_peripheral_mem_1(struct pci_dev *dev)
-{
-       void __iomem *target;
-       u64 low, high, sizelow;
-       u64 start, limit;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
-       unsigned char busnum = dev->bus->number;
-       void __iomem *bbar = tbl->bbar;
-
-       /* peripheral MEM_1 region */
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_1_LOW);
-       low = be32_to_cpu(readl(target));
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_1_HIGH);
-       high = be32_to_cpu(readl(target));
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_1_SIZE);
-       sizelow = be32_to_cpu(readl(target));
-
-       start = (high << 32) | low;
-       limit = sizelow;
-
-       calgary_reserve_mem_region(dev, start, limit);
-}
-
-static void __init calgary_reserve_peripheral_mem_2(struct pci_dev *dev)
-{
-       void __iomem *target;
-       u32 val32;
-       u64 low, high, sizelow, sizehigh;
-       u64 start, limit;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
-       unsigned char busnum = dev->bus->number;
-       void __iomem *bbar = tbl->bbar;
-
-       /* is it enabled? */
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_CONFIG_RW_OFFSET);
-       val32 = be32_to_cpu(readl(target));
-       if (!(val32 & PHB_MEM2_ENABLE))
-               return;
-
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_2_LOW);
-       low = be32_to_cpu(readl(target));
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_2_HIGH);
-       high = be32_to_cpu(readl(target));
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_2_SIZE_LOW);
-       sizelow = be32_to_cpu(readl(target));
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_MEM_2_SIZE_HIGH);
-       sizehigh = be32_to_cpu(readl(target));
-
-       start = (high << 32) | low;
-       limit = (sizehigh << 32) | sizelow;
-
-       calgary_reserve_mem_region(dev, start, limit);
-}
-
-/*
- * some regions of the IO address space do not get translated, so we
- * must not give devices IO addresses in those regions. The regions
- * are the 640KB-1MB region and the two PCI peripheral memory holes.
- * Reserve all of them in the IOMMU bitmap to avoid giving them out
- * later.
- */
-static void __init calgary_reserve_regions(struct pci_dev *dev)
-{
-       unsigned int npages;
-       u64 start;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
-
-       /* reserve EMERGENCY_PAGES from bad_dma_address and up */
-       iommu_range_reserve(tbl, bad_dma_address, EMERGENCY_PAGES);
-
-       /* avoid the BIOS/VGA first 640KB-1MB region */
-       /* for CalIOC2 - avoid the entire first MB */
-       if (is_calgary(dev->device)) {
-               start = (640 * 1024);
-               npages = ((1024 - 640) * 1024) >> PAGE_SHIFT;
-       } else { /* calioc2 */
-               start = 0;
-               npages = (1 * 1024 * 1024) >> PAGE_SHIFT;
-       }
-       iommu_range_reserve(tbl, start, npages);
-
-       /* reserve the two PCI peripheral memory regions in IO space */
-       calgary_reserve_peripheral_mem_1(dev);
-       calgary_reserve_peripheral_mem_2(dev);
-}
-
-static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
-{
-       u64 val64;
-       u64 table_phys;
-       void __iomem *target;
-       int ret;
-       struct iommu_table *tbl;
-
-       /* build TCE tables for each PHB */
-       ret = build_tce_table(dev, bbar);
-       if (ret)
-               return ret;
-
-       tbl = pci_iommu(dev->bus);
-       tbl->it_base = (unsigned long)bus_info[dev->bus->number].tce_space;
-       tce_free(tbl, 0, tbl->it_size);
-
-       if (is_calgary(dev->device))
-               tbl->chip_ops = &calgary_chip_ops;
-       else if (is_calioc2(dev->device))
-               tbl->chip_ops = &calioc2_chip_ops;
-       else
-               BUG();
-
-       calgary_reserve_regions(dev);
-
-       /* set TARs for each PHB */
-       target = calgary_reg(bbar, tar_offset(dev->bus->number));
-       val64 = be64_to_cpu(readq(target));
-
-       /* zero out all TAR bits under sw control */
-       val64 &= ~TAR_SW_BITS;
-       table_phys = (u64)__pa(tbl->it_base);
-
-       val64 |= table_phys;
-
-       BUG_ON(specified_table_size > TCE_TABLE_SIZE_8M);
-       val64 |= (u64) specified_table_size;
-
-       tbl->tar_val = cpu_to_be64(val64);
-
-       writeq(tbl->tar_val, target);
-       readq(target); /* flush */
-
-       return 0;
-}
-
-static void __init calgary_free_bus(struct pci_dev *dev)
-{
-       u64 val64;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
-       void __iomem *target;
-       unsigned int bitmapsz;
-
-       target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number));
-       val64 = be64_to_cpu(readq(target));
-       val64 &= ~TAR_SW_BITS;
-       writeq(cpu_to_be64(val64), target);
-       readq(target); /* flush */
-
-       bitmapsz = tbl->it_size / BITS_PER_BYTE;
-       free_pages((unsigned long)tbl->it_map, get_order(bitmapsz));
-       tbl->it_map = NULL;
-
-       kfree(tbl);
-       
-       set_pci_iommu(dev->bus, NULL);
-
-       /* Can't free bootmem allocated memory after system is up :-( */
-       bus_info[dev->bus->number].tce_space = NULL;
-}
-
-static void calgary_dump_error_regs(struct iommu_table *tbl)
-{
-       void __iomem *bbar = tbl->bbar;
-       void __iomem *target;
-       u32 csr, plssr;
-
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_CSR_OFFSET);
-       csr = be32_to_cpu(readl(target));
-
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_PLSSR_OFFSET);
-       plssr = be32_to_cpu(readl(target));
-
-       /* If no error, the agent ID in the CSR is not valid */
-       printk(KERN_EMERG "Calgary: DMA error on Calgary PHB 0x%x, "
-              "0x%08x@CSR 0x%08x@PLSSR\n", tbl->it_busno, csr, plssr);
-}
-
-static void calioc2_dump_error_regs(struct iommu_table *tbl)
-{
-       void __iomem *bbar = tbl->bbar;
-       u32 csr, csmr, plssr, mck, rcstat;
-       void __iomem *target;
-       unsigned long phboff = phb_offset(tbl->it_busno);
-       unsigned long erroff;
-       u32 errregs[7];
-       int i;
-
-       /* dump CSR */
-       target = calgary_reg(bbar, phboff | PHB_CSR_OFFSET);
-       csr = be32_to_cpu(readl(target));
-       /* dump PLSSR */
-       target = calgary_reg(bbar, phboff | PHB_PLSSR_OFFSET);
-       plssr = be32_to_cpu(readl(target));
-       /* dump CSMR */
-       target = calgary_reg(bbar, phboff | 0x290);
-       csmr = be32_to_cpu(readl(target));
-       /* dump mck */
-       target = calgary_reg(bbar, phboff | 0x800);
-       mck = be32_to_cpu(readl(target));
-
-       printk(KERN_EMERG "Calgary: DMA error on CalIOC2 PHB 0x%x\n",
-              tbl->it_busno);
-
-       printk(KERN_EMERG "Calgary: 0x%08x@CSR 0x%08x@PLSSR 0x%08x@CSMR 0x%08x@MCK\n",
-              csr, plssr, csmr, mck);
-
-       /* dump rest of error regs */
-       printk(KERN_EMERG "Calgary: ");
-       for (i = 0; i < ARRAY_SIZE(errregs); i++) {
-               /* err regs are at 0x810 - 0x870 */
-               erroff = (0x810 + (i * 0x10));
-               target = calgary_reg(bbar, phboff | erroff);
-               errregs[i] = be32_to_cpu(readl(target));
-               printk("0x%08x@0x%lx ", errregs[i], erroff);
-       }
-       printk("\n");
-
-       /* root complex status */
-       target = calgary_reg(bbar, phboff | PHB_ROOT_COMPLEX_STATUS);
-       rcstat = be32_to_cpu(readl(target));
-       printk(KERN_EMERG "Calgary: 0x%08x@0x%x\n", rcstat,
-              PHB_ROOT_COMPLEX_STATUS);
-}
-
-static void calgary_watchdog(unsigned long data)
-{
-       struct pci_dev *dev = (struct pci_dev *)data;
-       struct iommu_table *tbl = pci_iommu(dev->bus);
-       void __iomem *bbar = tbl->bbar;
-       u32 val32;
-       void __iomem *target;
-
-       target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_CSR_OFFSET);
-       val32 = be32_to_cpu(readl(target));
-
-       /* If no error, the agent ID in the CSR is not valid */
-       if (val32 & CSR_AGENT_MASK) {
-               tbl->chip_ops->dump_error_regs(tbl);
-
-               /* reset error */
-               writel(0, target);
-
-               /* Disable bus that caused the error */
-               target = calgary_reg(bbar, phb_offset(tbl->it_busno) |
-                                    PHB_CONFIG_RW_OFFSET);
-               val32 = be32_to_cpu(readl(target));
-               val32 |= PHB_SLOT_DISABLE;
-               writel(cpu_to_be32(val32), target);
-               readl(target); /* flush */
-       } else {
-               /* Reset the timer */
-               mod_timer(&tbl->watchdog_timer, jiffies + 2 * HZ);
-       }
-}
-
-static void __init calgary_set_split_completion_timeout(void __iomem *bbar,
-       unsigned char busnum, unsigned long timeout)
-{
-       u64 val64;
-       void __iomem *target;
-       unsigned int phb_shift = ~0; /* silence gcc */
-       u64 mask;
-
-       switch (busno_to_phbid(busnum)) {
-       case 0: phb_shift = (63 - 19);
-               break;
-       case 1: phb_shift = (63 - 23);
-               break;
-       case 2: phb_shift = (63 - 27);
-               break;
-       case 3: phb_shift = (63 - 35);
-               break;
-       default:
-               BUG_ON(busno_to_phbid(busnum));
-       }
-
-       target = calgary_reg(bbar, CALGARY_CONFIG_REG);
-       val64 = be64_to_cpu(readq(target));
-
-       /* zero out this PHB's timer bits */
-       mask = ~(0xFUL << phb_shift);
-       val64 &= mask;
-       val64 |= (timeout << phb_shift);
-       writeq(cpu_to_be64(val64), target);
-       readq(target); /* flush */
-}
-
-static void calioc2_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev)
-{
-       unsigned char busnum = dev->bus->number;
-       void __iomem *bbar = tbl->bbar;
-       void __iomem *target;
-       u32 val;
-
-       /*
-        * CalIOC2 designers recommend setting bit 8 in 0xnDB0 to 1
-        */
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_SAVIOR_L2);
-       val = cpu_to_be32(readl(target));
-       val |= 0x00800000;
-       writel(cpu_to_be32(val), target);
-}
-
-static void calgary_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev)
-{
-       unsigned char busnum = dev->bus->number;
-
-       /*
-        * Give split completion a longer timeout on bus 1 for aic94xx
-        * http://bugzilla.kernel.org/show_bug.cgi?id=7180
-        */
-       if (is_calgary(dev->device) && (busnum == 1))
-               calgary_set_split_completion_timeout(tbl->bbar, busnum,
-                                                    CCR_2SEC_TIMEOUT);
-}
-
-static void __init calgary_enable_translation(struct pci_dev *dev)
-{
-       u32 val32;
-       unsigned char busnum;
-       void __iomem *target;
-       void __iomem *bbar;
-       struct iommu_table *tbl;
-
-       busnum = dev->bus->number;
-       tbl = pci_iommu(dev->bus);
-       bbar = tbl->bbar;
-
-       /* enable TCE in PHB Config Register */
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_CONFIG_RW_OFFSET);
-       val32 = be32_to_cpu(readl(target));
-       val32 |= PHB_TCE_ENABLE | PHB_DAC_DISABLE | PHB_MCSR_ENABLE;
-
-       printk(KERN_INFO "Calgary: enabling translation on %s PHB %#x\n",
-              (dev->device == PCI_DEVICE_ID_IBM_CALGARY) ?
-              "Calgary" : "CalIOC2", busnum);
-       printk(KERN_INFO "Calgary: errant DMAs will now be prevented on this "
-              "bus.\n");
-
-       writel(cpu_to_be32(val32), target);
-       readl(target); /* flush */
-
-       init_timer(&tbl->watchdog_timer);
-       tbl->watchdog_timer.function = &calgary_watchdog;
-       tbl->watchdog_timer.data = (unsigned long)dev;
-       mod_timer(&tbl->watchdog_timer, jiffies);
-}
-
-static void __init calgary_disable_translation(struct pci_dev *dev)
-{
-       u32 val32;
-       unsigned char busnum;
-       void __iomem *target;
-       void __iomem *bbar;
-       struct iommu_table *tbl;
-
-       busnum = dev->bus->number;
-       tbl = pci_iommu(dev->bus);
-       bbar = tbl->bbar;
-
-       /* disable TCE in PHB Config Register */
-       target = calgary_reg(bbar, phb_offset(busnum) | PHB_CONFIG_RW_OFFSET);
-       val32 = be32_to_cpu(readl(target));
-       val32 &= ~(PHB_TCE_ENABLE | PHB_DAC_DISABLE | PHB_MCSR_ENABLE);
-
-       printk(KERN_INFO "Calgary: disabling translation on PHB %#x!\n", busnum);
-       writel(cpu_to_be32(val32), target);
-       readl(target); /* flush */
-
-       del_timer_sync(&tbl->watchdog_timer);
-}
-
-static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
-{
-       pci_dev_get(dev);
-       set_pci_iommu(dev->bus, NULL);
-
-       /* is the device behind a bridge? */
-       if (dev->bus->parent)
-               dev->bus->parent->self = dev;
-       else
-               dev->bus->self = dev;
-}
-
-static int __init calgary_init_one(struct pci_dev *dev)
-{
-       void __iomem *bbar;
-       struct iommu_table *tbl;
-       int ret;
-
-       BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM);
-
-       bbar = busno_to_bbar(dev->bus->number);
-       ret = calgary_setup_tar(dev, bbar);
-       if (ret)
-               goto done;
-
-       pci_dev_get(dev);
-
-       if (dev->bus->parent) {
-               if (dev->bus->parent->self)
-                       printk(KERN_WARNING "Calgary: IEEEE, dev %p has "
-                              "bus->parent->self!\n", dev);
-               dev->bus->parent->self = dev;
-       } else
-               dev->bus->self = dev;
-
-       tbl = pci_iommu(dev->bus);
-       tbl->chip_ops->handle_quirks(tbl, dev);
-
-       calgary_enable_translation(dev);
-
-       return 0;
-
-done:
-       return ret;
-}
-
-static int __init calgary_locate_bbars(void)
-{
-       int ret;
-       int rioidx, phb, bus;
-       void __iomem *bbar;
-       void __iomem *target;
-       unsigned long offset;
-       u8 start_bus, end_bus;
-       u32 val;
-
-       ret = -ENODATA;
-       for (rioidx = 0; rioidx < rio_table_hdr->num_rio_dev; rioidx++) {
-               struct rio_detail *rio = rio_devs[rioidx];
-
-               if ((rio->type != COMPAT_CALGARY) && (rio->type != ALT_CALGARY))
-                       continue;
-
-               /* map entire 1MB of Calgary config space */
-               bbar = ioremap_nocache(rio->BBAR, 1024 * 1024);
-               if (!bbar)
-                       goto error;
-
-               for (phb = 0; phb < PHBS_PER_CALGARY; phb++) {
-                       offset = phb_debug_offsets[phb] | PHB_DEBUG_STUFF_OFFSET;
-                       target = calgary_reg(bbar, offset);
-
-                       val = be32_to_cpu(readl(target));
-
-                       start_bus = (u8)((val & 0x00FF0000) >> 16);
-                       end_bus = (u8)((val & 0x0000FF00) >> 8);
-
-                       if (end_bus) {
-                               for (bus = start_bus; bus <= end_bus; bus++) {
-                                       bus_info[bus].bbar = bbar;
-                                       bus_info[bus].phbid = phb;
-                               }
-                       } else {
-                               bus_info[start_bus].bbar = bbar;
-                               bus_info[start_bus].phbid = phb;
-                       }
-               }
-       }
-
-       return 0;
-
-error:
-       /* scan bus_info and iounmap any bbars we previously ioremap'd */
-       for (bus = 0; bus < ARRAY_SIZE(bus_info); bus++)
-               if (bus_info[bus].bbar)
-                       iounmap(bus_info[bus].bbar);
-
-       return ret;
-}
-
-static int __init calgary_init(void)
-{
-       int ret;
-       struct pci_dev *dev = NULL;
-       void *tce_space;
-
-       ret = calgary_locate_bbars();
-       if (ret)
-               return ret;
-
-       do {
-               dev = pci_get_device(PCI_VENDOR_ID_IBM, PCI_ANY_ID, dev);
-               if (!dev)
-                       break;
-               if (!is_cal_pci_dev(dev->device))
-                       continue;
-               if (!translate_phb(dev)) {
-                       calgary_init_one_nontraslated(dev);
-                       continue;
-               }
-               tce_space = bus_info[dev->bus->number].tce_space;
-               if (!tce_space && !translate_empty_slots)
-                       continue;
-
-               ret = calgary_init_one(dev);
-               if (ret)
-                       goto error;
-       } while (1);
-
-       return ret;
-
-error:
-       do {
-               dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
-                                            PCI_ANY_ID, dev);
-               if (!dev)
-                       break;
-               if (!is_cal_pci_dev(dev->device))
-                       continue;
-               if (!translate_phb(dev)) {
-                       pci_dev_put(dev);
-                       continue;
-               }
-               if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
-                       continue;
-
-               calgary_disable_translation(dev);
-               calgary_free_bus(dev);
-               pci_dev_put(dev); /* Undo calgary_init_one()'s pci_dev_get() */
-       } while (1);
-
-       return ret;
-}
-
-static inline int __init determine_tce_table_size(u64 ram)
-{
-       int ret;
-
-       if (specified_table_size != TCE_TABLE_SIZE_UNSPECIFIED)
-               return specified_table_size;
-
-       /*
-        * Table sizes are from 0 to 7 (TCE_TABLE_SIZE_64K to
-        * TCE_TABLE_SIZE_8M). Table size 0 has 8K entries and each
-        * larger table size has twice as many entries, so shift the
-        * max ram address by 13 to divide by 8K and then look at the
-        * order of the result to choose between 0-7.
-        */
-       ret = get_order(ram >> 13);
-       if (ret > TCE_TABLE_SIZE_8M)
-               ret = TCE_TABLE_SIZE_8M;
-
-       return ret;
-}
-
-static int __init build_detail_arrays(void)
-{
-       unsigned long ptr;
-       int i, scal_detail_size, rio_detail_size;
-
-       if (rio_table_hdr->num_scal_dev > MAX_NUMNODES){
-               printk(KERN_WARNING
-                       "Calgary: MAX_NUMNODES too low! Defined as %d, "
-                       "but system has %d nodes.\n",
-                       MAX_NUMNODES, rio_table_hdr->num_scal_dev);
-               return -ENODEV;
-       }
-
-       switch (rio_table_hdr->version){
-       case 2:
-               scal_detail_size = 11;
-               rio_detail_size = 13;
-               break;
-       case 3:
-               scal_detail_size = 12;
-               rio_detail_size = 15;
-               break;
-       default:
-               printk(KERN_WARNING
-                      "Calgary: Invalid Rio Grande Table Version: %d\n",
-                      rio_table_hdr->version);
-               return -EPROTO;
-       }
-
-       ptr = ((unsigned long)rio_table_hdr) + 3;
-       for (i = 0; i < rio_table_hdr->num_scal_dev;
-                   i++, ptr += scal_detail_size)
-               scal_devs[i] = (struct scal_detail *)ptr;
-
-       for (i = 0; i < rio_table_hdr->num_rio_dev;
-                   i++, ptr += rio_detail_size)
-               rio_devs[i] = (struct rio_detail *)ptr;
-
-       return 0;
-}
-
-static int __init calgary_bus_has_devices(int bus, unsigned short pci_dev)
-{
-       int dev;
-       u32 val;
-
-       if (pci_dev == PCI_DEVICE_ID_IBM_CALIOC2) {
-               /*
-                * FIXME: properly scan for devices accross the
-                * PCI-to-PCI bridge on every CalIOC2 port.
-                */
-               return 1;
-       }
-
-       for (dev = 1; dev < 8; dev++) {
-               val = read_pci_config(bus, dev, 0, 0);
-               if (val != 0xffffffff)
-                       break;
-       }
-       return (val != 0xffffffff);
-}
-
-void __init detect_calgary(void)
-{
-       int bus;
-       void *tbl;
-       int calgary_found = 0;
-       unsigned long ptr;
-       unsigned int offset, prev_offset;
-       int ret;
-
-       /*
-        * if the user specified iommu=off or iommu=soft or we found
-        * another HW IOMMU already, bail out.
-        */
-       if (swiotlb || no_iommu || iommu_detected)
-               return;
-
-       if (!use_calgary)
-               return;
-
-       if (!early_pci_allowed())
-               return;
-
-       printk(KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n");
-
-       ptr = (unsigned long)phys_to_virt(get_bios_ebda());
-
-       rio_table_hdr = NULL;
-       prev_offset = 0;
-       offset = 0x180;
-       /*
-        * The next offset is stored in the 1st word.
-        * Only parse up until the offset increases:
-        */
-       while (offset > prev_offset) {
-               /* The block id is stored in the 2nd word */
-               if (*((unsigned short *)(ptr + offset + 2)) == 0x4752){
-                       /* set the pointer past the offset & block id */
-                       rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
-                       break;
-               }
-               prev_offset = offset;
-               offset = *((unsigned short *)(ptr + offset));
-       }
-       if (!rio_table_hdr) {
-               printk(KERN_DEBUG "Calgary: Unable to locate Rio Grande table "
-                      "in EBDA - bailing!\n");
-               return;
-       }
-
-       ret = build_detail_arrays();
-       if (ret) {
-               printk(KERN_DEBUG "Calgary: build_detail_arrays ret %d\n", ret);
-               return;
-       }
-
-       specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
-
-       for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
-               struct calgary_bus_info *info = &bus_info[bus];
-               unsigned short pci_device;
-               u32 val;
-
-               val = read_pci_config(bus, 0, 0, 0);
-               pci_device = (val & 0xFFFF0000) >> 16;
-
-               if (!is_cal_pci_dev(pci_device))
-                       continue;
-
-               if (info->translation_disabled)
-                       continue;
-
-               if (calgary_bus_has_devices(bus, pci_device) ||
-                   translate_empty_slots) {
-                       tbl = alloc_tce_table();
-                       if (!tbl)
-                               goto cleanup;
-                       info->tce_space = tbl;
-                       calgary_found = 1;
-               }
-       }
-
-       printk(KERN_DEBUG "Calgary: finished detection, Calgary %s\n",
-              calgary_found ? "found" : "not found");
-
-       if (calgary_found) {
-               iommu_detected = 1;
-               calgary_detected = 1;
-               printk(KERN_INFO "PCI-DMA: Calgary IOMMU detected.\n");
-               printk(KERN_INFO "PCI-DMA: Calgary TCE table spec is %d, "
-                      "CONFIG_IOMMU_DEBUG is %s.\n", specified_table_size,
-                      debugging ? "enabled" : "disabled");
-       }
-       return;
-
-cleanup:
-       for (--bus; bus >= 0; --bus) {
-               struct calgary_bus_info *info = &bus_info[bus];
-
-               if (info->tce_space)
-                       free_tce_table(info->tce_space);
-       }
-}
-
-int __init calgary_iommu_init(void)
-{
-       int ret;
-
-       if (no_iommu || swiotlb)
-               return -ENODEV;
-
-       if (!calgary_detected)
-               return -ENODEV;
-
-       /* ok, we're trying to use Calgary - let's roll */
-       printk(KERN_INFO "PCI-DMA: Using Calgary IOMMU\n");
-
-       ret = calgary_init();
-       if (ret) {
-               printk(KERN_ERR "PCI-DMA: Calgary init failed %d, "
-                      "falling back to no_iommu\n", ret);
-               if (end_pfn > MAX_DMA32_PFN)
-                       printk(KERN_ERR "WARNING more than 4GB of memory, "
-                                       "32bit PCI may malfunction.\n");
-               return ret;
-       }
-
-       force_iommu = 1;
-       bad_dma_address = 0x0;
-       dma_ops = &calgary_dma_ops;
-
-       return 0;
-}
-
-static int __init calgary_parse_options(char *p)
-{
-       unsigned int bridge;
-       size_t len;
-       char* endp;
-
-       while (*p) {
-               if (!strncmp(p, "64k", 3))
-                       specified_table_size = TCE_TABLE_SIZE_64K;
-               else if (!strncmp(p, "128k", 4))
-                       specified_table_size = TCE_TABLE_SIZE_128K;
-               else if (!strncmp(p, "256k", 4))
-                       specified_table_size = TCE_TABLE_SIZE_256K;
-               else if (!strncmp(p, "512k", 4))
-                       specified_table_size = TCE_TABLE_SIZE_512K;
-               else if (!strncmp(p, "1M", 2))
-                       specified_table_size = TCE_TABLE_SIZE_1M;
-               else if (!strncmp(p, "2M", 2))
-                       specified_table_size = TCE_TABLE_SIZE_2M;
-               else if (!strncmp(p, "4M", 2))
-                       specified_table_size = TCE_TABLE_SIZE_4M;
-               else if (!strncmp(p, "8M", 2))
-                       specified_table_size = TCE_TABLE_SIZE_8M;
-
-               len = strlen("translate_empty_slots");
-               if (!strncmp(p, "translate_empty_slots", len))
-                       translate_empty_slots = 1;
-
-               len = strlen("disable");
-               if (!strncmp(p, "disable", len)) {
-                       p += len;
-                       if (*p == '=')
-                               ++p;
-                       if (*p == '\0')
-                               break;
-                       bridge = simple_strtol(p, &endp, 0);
-                       if (p == endp)
-                               break;
-
-                       if (bridge < MAX_PHB_BUS_NUM) {
-                               printk(KERN_INFO "Calgary: disabling "
-                                      "translation for PHB %#x\n", bridge);
-                               bus_info[bridge].translation_disabled = 1;
-                       }
-               }
-
-               p = strpbrk(p, ",");
-               if (!p)
-                       break;
-
-               p++; /* skip ',' */
-       }
-       return 1;
-}
-__setup("calgary=", calgary_parse_options);
-
-static void __init calgary_fixup_one_tce_space(struct pci_dev *dev)
-{
-       struct iommu_table *tbl;
-       unsigned int npages;
-       int i;
-
-       tbl = pci_iommu(dev->bus);
-
-       for (i = 0; i < 4; i++) {
-               struct resource *r = &dev->resource[PCI_BRIDGE_RESOURCES + i];
-
-               /* Don't give out TCEs that map MEM resources */
-               if (!(r->flags & IORESOURCE_MEM))
-                       continue;
-
-               /* 0-based? we reserve the whole 1st MB anyway */
-               if (!r->start)
-                       continue;
-
-               /* cover the whole region */
-               npages = (r->end - r->start) >> PAGE_SHIFT;
-               npages++;
-
-               iommu_range_reserve(tbl, r->start, npages);
-       }
-}
-
-static int __init calgary_fixup_tce_spaces(void)
-{
-       struct pci_dev *dev = NULL;
-       void *tce_space;
-
-       if (no_iommu || swiotlb || !calgary_detected)
-               return -ENODEV;
-
-       printk(KERN_DEBUG "Calgary: fixing up tce spaces\n");
-
-       do {
-               dev = pci_get_device(PCI_VENDOR_ID_IBM, PCI_ANY_ID, dev);
-               if (!dev)
-                       break;
-               if (!is_cal_pci_dev(dev->device))
-                       continue;
-               if (!translate_phb(dev))
-                       continue;
-
-               tce_space = bus_info[dev->bus->number].tce_space;
-               if (!tce_space)
-                       continue;
-
-               calgary_fixup_one_tce_space(dev);
-
-       } while (1);
-
-       return 0;
-}
-
-/*
- * We need to be call after pcibios_assign_resources (fs_initcall level)
- * and before device_initcall.
- */
-rootfs_initcall(calgary_fixup_tce_spaces);
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
deleted file mode 100644 (file)
index 2971144..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Dynamic DMA mapping support.
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/module.h>
-#include <asm/io.h>
-#include <asm/iommu.h>
-#include <asm/calgary.h>
-
-int iommu_merge __read_mostly = 0;
-EXPORT_SYMBOL(iommu_merge);
-
-dma_addr_t bad_dma_address __read_mostly;
-EXPORT_SYMBOL(bad_dma_address);
-
-/* This tells the BIO block layer to assume merging. Default to off
-   because we cannot guarantee merging later. */
-int iommu_bio_merge __read_mostly = 0;
-EXPORT_SYMBOL(iommu_bio_merge);
-
-static int iommu_sac_force __read_mostly = 0;
-
-int no_iommu __read_mostly;
-#ifdef CONFIG_IOMMU_DEBUG
-int panic_on_overflow __read_mostly = 1;
-int force_iommu __read_mostly = 1;
-#else
-int panic_on_overflow __read_mostly = 0;
-int force_iommu __read_mostly= 0;
-#endif
-
-/* Set this to 1 if there is a HW IOMMU in the system */
-int iommu_detected __read_mostly = 0;
-
-/* Dummy device used for NULL arguments (normally ISA). Better would
-   be probably a smaller DMA mask, but this is bug-to-bug compatible
-   to i386. */
-struct device fallback_dev = {
-       .bus_id = "fallback device",
-       .coherent_dma_mask = DMA_32BIT_MASK,
-       .dma_mask = &fallback_dev.coherent_dma_mask,
-};
-
-/* Allocate DMA memory on node near device */
-noinline static void *
-dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
-{
-       struct page *page;
-       int node;
-#ifdef CONFIG_PCI
-       if (dev->bus == &pci_bus_type)
-               node = pcibus_to_node(to_pci_dev(dev)->bus);
-       else
-#endif
-               node = numa_node_id();
-
-       if (node < first_node(node_online_map))
-               node = first_node(node_online_map);
-
-       page = alloc_pages_node(node, gfp, order);
-       return page ? page_address(page) : NULL;
-}
-
-/*
- * Allocate memory for a coherent mapping.
- */
-void *
-dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-                  gfp_t gfp)
-{
-       void *memory;
-       unsigned long dma_mask = 0;
-       u64 bus;
-
-       if (!dev)
-               dev = &fallback_dev;
-       dma_mask = dev->coherent_dma_mask;
-       if (dma_mask == 0)
-               dma_mask = DMA_32BIT_MASK;
-
-       /* Device not DMA able */
-       if (dev->dma_mask == NULL)
-               return NULL;
-
-       /* Don't invoke OOM killer */
-       gfp |= __GFP_NORETRY;
-
-       /* Kludge to make it bug-to-bug compatible with i386. i386
-          uses the normal dma_mask for alloc_coherent. */
-       dma_mask &= *dev->dma_mask;
-
-       /* Why <=? Even when the mask is smaller than 4GB it is often
-          larger than 16MB and in this case we have a chance of
-          finding fitting memory in the next higher zone first. If
-          not retry with true GFP_DMA. -AK */
-       if (dma_mask <= DMA_32BIT_MASK)
-               gfp |= GFP_DMA32;
-
- again:
-       memory = dma_alloc_pages(dev, gfp, get_order(size));
-       if (memory == NULL)
-               return NULL;
-
-       {
-               int high, mmu;
-               bus = virt_to_bus(memory);
-               high = (bus + size) >= dma_mask;
-               mmu = high;
-               if (force_iommu && !(gfp & GFP_DMA))
-                       mmu = 1;
-               else if (high) {
-                       free_pages((unsigned long)memory,
-                                  get_order(size));
-
-                       /* Don't use the 16MB ZONE_DMA unless absolutely
-                          needed. It's better to use remapping first. */
-                       if (dma_mask < DMA_32BIT_MASK && !(gfp & GFP_DMA)) {
-                               gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
-                               goto again;
-                       }
-
-                       /* Let low level make its own zone decisions */
-                       gfp &= ~(GFP_DMA32|GFP_DMA);
-
-                       if (dma_ops->alloc_coherent)
-                               return dma_ops->alloc_coherent(dev, size,
-                                                          dma_handle, gfp);
-                       return NULL;
-               }
-
-               memset(memory, 0, size);
-               if (!mmu) {
-                       *dma_handle = virt_to_bus(memory);
-                       return memory;
-               }
-       }
-
-       if (dma_ops->alloc_coherent) {
-               free_pages((unsigned long)memory, get_order(size));
-               gfp &= ~(GFP_DMA|GFP_DMA32);
-               return dma_ops->alloc_coherent(dev, size, dma_handle, gfp);
-       }
-
-       if (dma_ops->map_simple) {
-               *dma_handle = dma_ops->map_simple(dev, memory,
-                                             size,
-                                             PCI_DMA_BIDIRECTIONAL);
-               if (*dma_handle != bad_dma_address)
-                       return memory;
-       }
-
-       if (panic_on_overflow)
-               panic("dma_alloc_coherent: IOMMU overflow by %lu bytes\n",size);
-       free_pages((unsigned long)memory, get_order(size));
-       return NULL;
-}
-EXPORT_SYMBOL(dma_alloc_coherent);
-
-/*
- * Unmap coherent memory.
- * The caller must ensure that the device has finished accessing the mapping.
- */
-void dma_free_coherent(struct device *dev, size_t size,
-                        void *vaddr, dma_addr_t bus)
-{
-       if (dma_ops->unmap_single)
-               dma_ops->unmap_single(dev, bus, size, 0);
-       free_pages((unsigned long)vaddr, get_order(size));
-}
-EXPORT_SYMBOL(dma_free_coherent);
-
-static int forbid_dac __read_mostly;
-
-int dma_supported(struct device *dev, u64 mask)
-{
-#ifdef CONFIG_PCI
-       if (mask > 0xffffffff && forbid_dac > 0) {
-
-
-
-               printk(KERN_INFO "PCI: Disallowing DAC for device %s\n", dev->bus_id);
-               return 0;
-       }
-#endif
-
-       if (dma_ops->dma_supported)
-               return dma_ops->dma_supported(dev, mask);
-
-       /* Copied from i386. Doesn't make much sense, because it will
-          only work for pci_alloc_coherent.
-          The caller just has to use GFP_DMA in this case. */
-        if (mask < DMA_24BIT_MASK)
-                return 0;
-
-       /* Tell the device to use SAC when IOMMU force is on.  This
-          allows the driver to use cheaper accesses in some cases.
-
-          Problem with this is that if we overflow the IOMMU area and
-          return DAC as fallback address the device may not handle it
-          correctly.
-
-          As a special case some controllers have a 39bit address
-          mode that is as efficient as 32bit (aic79xx). Don't force
-          SAC for these.  Assume all masks <= 40 bits are of this
-          type. Normally this doesn't make any difference, but gives
-          more gentle handling of IOMMU overflow. */
-       if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
-               printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
-               return 0;
-       }
-
-       return 1;
-}
-EXPORT_SYMBOL(dma_supported);
-
-int dma_set_mask(struct device *dev, u64 mask)
-{
-       if (!dev->dma_mask || !dma_supported(dev, mask))
-               return -EIO;
-       *dev->dma_mask = mask;
-       return 0;
-}
-EXPORT_SYMBOL(dma_set_mask);
-
-/*
- * See <Documentation/x86_64/boot-options.txt> for the iommu kernel parameter
- * documentation.
- */
-__init int iommu_setup(char *p)
-{
-       iommu_merge = 1;
-
-       if (!p)
-               return -EINVAL;
-
-       while (*p) {
-               if (!strncmp(p,"off",3))
-                       no_iommu = 1;
-               /* gart_parse_options has more force support */
-               if (!strncmp(p,"force",5))
-                       force_iommu = 1;
-               if (!strncmp(p,"noforce",7)) {
-                       iommu_merge = 0;
-                       force_iommu = 0;
-               }
-
-               if (!strncmp(p, "biomerge",8)) {
-                       iommu_bio_merge = 4096;
-                       iommu_merge = 1;
-                       force_iommu = 1;
-               }
-               if (!strncmp(p, "panic",5))
-                       panic_on_overflow = 1;
-               if (!strncmp(p, "nopanic",7))
-                       panic_on_overflow = 0;
-               if (!strncmp(p, "merge",5)) {
-                       iommu_merge = 1;
-                       force_iommu = 1;
-               }
-               if (!strncmp(p, "nomerge",7))
-                       iommu_merge = 0;
-               if (!strncmp(p, "forcesac",8))
-                       iommu_sac_force = 1;
-               if (!strncmp(p, "allowdac", 8))
-                       forbid_dac = 0;
-               if (!strncmp(p, "nodac", 5))
-                       forbid_dac = -1;
-
-#ifdef CONFIG_SWIOTLB
-               if (!strncmp(p, "soft",4))
-                       swiotlb = 1;
-#endif
-
-#ifdef CONFIG_IOMMU
-               gart_parse_options(p);
-#endif
-
-#ifdef CONFIG_CALGARY_IOMMU
-               if (!strncmp(p, "calgary", 7))
-                       use_calgary = 1;
-#endif /* CONFIG_CALGARY_IOMMU */
-
-               p += strcspn(p, ",");
-               if (*p == ',')
-                       ++p;
-       }
-       return 0;
-}
-early_param("iommu", iommu_setup);
-
-void __init pci_iommu_alloc(void)
-{
-       /*
-        * The order of these functions is important for
-        * fall-back/fail-over reasons
-        */
-#ifdef CONFIG_IOMMU
-       iommu_hole_init();
-#endif
-
-#ifdef CONFIG_CALGARY_IOMMU
-       detect_calgary();
-#endif
-
-#ifdef CONFIG_SWIOTLB
-       pci_swiotlb_init();
-#endif
-}
-
-static int __init pci_iommu_init(void)
-{
-#ifdef CONFIG_CALGARY_IOMMU
-       calgary_iommu_init();
-#endif
-
-#ifdef CONFIG_IOMMU
-       gart_iommu_init();
-#endif
-
-       no_iommu_init();
-       return 0;
-}
-
-void pci_iommu_shutdown(void)
-{
-       gart_iommu_shutdown();
-}
-
-#ifdef CONFIG_PCI
-/* Many VIA bridges seem to corrupt data for DAC. Disable it here */
-
-static __devinit void via_no_dac(struct pci_dev *dev)
-{
-       if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && forbid_dac == 0) {
-               printk(KERN_INFO "PCI: VIA PCI bridge detected. Disabling DAC.\n");
-               forbid_dac = 1;
-       }
-}
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, via_no_dac);
-#endif
-/* Must execute after PCI subsystem */
-fs_initcall(pci_iommu_init);
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
deleted file mode 100644 (file)
index 4918c57..0000000
+++ /dev/null
@@ -1,740 +0,0 @@
-/*
- * Dynamic DMA mapping support for AMD Hammer.
- * 
- * Use the integrated AGP GART in the Hammer northbridge as an IOMMU for PCI.
- * This allows to use PCI devices that only support 32bit addresses on systems
- * with more than 4GB. 
- *
- * See Documentation/DMA-mapping.txt for the interface specification.
- * 
- * Copyright 2002 Andi Kleen, SuSE Labs.
- */
-
-#include <linux/types.h>
-#include <linux/ctype.h>
-#include <linux/agp_backend.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
-#include <linux/pci.h>
-#include <linux/module.h>
-#include <linux/topology.h>
-#include <linux/interrupt.h>
-#include <linux/bitops.h>
-#include <linux/kdebug.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
-#include <asm/mtrr.h>
-#include <asm/pgtable.h>
-#include <asm/proto.h>
-#include <asm/iommu.h>
-#include <asm/cacheflush.h>
-#include <asm/swiotlb.h>
-#include <asm/dma.h>
-#include <asm/k8.h>
-
-unsigned long iommu_bus_base;  /* GART remapping area (physical) */
-static unsigned long iommu_size;       /* size of remapping area bytes */
-static unsigned long iommu_pages;      /* .. and in pages */
-
-u32 *iommu_gatt_base;          /* Remapping table */
-
-/* If this is disabled the IOMMU will use an optimized flushing strategy
-   of only flushing when an mapping is reused. With it true the GART is flushed 
-   for every mapping. Problem is that doing the lazy flush seems to trigger
-   bugs with some popular PCI cards, in particular 3ware (but has been also
-   also seen with Qlogic at least). */
-int iommu_fullflush = 1;
-
-/* Allocation bitmap for the remapping area */ 
-static DEFINE_SPINLOCK(iommu_bitmap_lock);
-static unsigned long *iommu_gart_bitmap; /* guarded by iommu_bitmap_lock */
-
-static u32 gart_unmapped_entry; 
-
-#define GPTE_VALID    1
-#define GPTE_COHERENT 2
-#define GPTE_ENCODE(x) \
-       (((x) & 0xfffff000) | (((x) >> 32) << 4) | GPTE_VALID | GPTE_COHERENT)
-#define GPTE_DECODE(x) (((x) & 0xfffff000) | (((u64)(x) & 0xff0) << 28))
-
-#define to_pages(addr,size) \
-       (round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
-
-#define EMERGENCY_PAGES 32 /* = 128KB */ 
-
-#ifdef CONFIG_AGP
-#define AGPEXTERN extern
-#else
-#define AGPEXTERN
-#endif
-
-/* backdoor interface to AGP driver */
-AGPEXTERN int agp_memory_reserved;
-AGPEXTERN __u32 *agp_gatt_table;
-
-static unsigned long next_bit;  /* protected by iommu_bitmap_lock */
-static int need_flush;                 /* global flush state. set for each gart wrap */
-
-static unsigned long alloc_iommu(int size) 
-{      
-       unsigned long offset, flags;
-
-       spin_lock_irqsave(&iommu_bitmap_lock, flags);   
-       offset = find_next_zero_string(iommu_gart_bitmap,next_bit,iommu_pages,size);
-       if (offset == -1) {
-               need_flush = 1;
-               offset = find_next_zero_string(iommu_gart_bitmap,0,iommu_pages,size);
-       }
-       if (offset != -1) { 
-               set_bit_string(iommu_gart_bitmap, offset, size); 
-               next_bit = offset+size; 
-               if (next_bit >= iommu_pages) { 
-                       next_bit = 0;
-                       need_flush = 1;
-               } 
-       } 
-       if (iommu_fullflush)
-               need_flush = 1;
-       spin_unlock_irqrestore(&iommu_bitmap_lock, flags);      
-       return offset;
-} 
-
-static void free_iommu(unsigned long offset, int size)
-{ 
-       unsigned long flags;
-       spin_lock_irqsave(&iommu_bitmap_lock, flags);
-       __clear_bit_string(iommu_gart_bitmap, offset, size);
-       spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
-} 
-
-/* 
- * Use global flush state to avoid races with multiple flushers.
- */
-static void flush_gart(void)
-{ 
-       unsigned long flags;
-       spin_lock_irqsave(&iommu_bitmap_lock, flags);
-       if (need_flush) {
-               k8_flush_garts();
-               need_flush = 0;
-       } 
-       spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
-} 
-
-#ifdef CONFIG_IOMMU_LEAK
-
-#define SET_LEAK(x) if (iommu_leak_tab) \
-                       iommu_leak_tab[x] = __builtin_return_address(0);
-#define CLEAR_LEAK(x) if (iommu_leak_tab) \
-                       iommu_leak_tab[x] = NULL;
-
-/* Debugging aid for drivers that don't free their IOMMU tables */
-static void **iommu_leak_tab; 
-static int leak_trace;
-int iommu_leak_pages = 20; 
-void dump_leak(void)
-{
-       int i;
-       static int dump; 
-       if (dump || !iommu_leak_tab) return;
-       dump = 1;
-       show_stack(NULL,NULL);
-       /* Very crude. dump some from the end of the table too */ 
-       printk("Dumping %d pages from end of IOMMU:\n", iommu_leak_pages); 
-       for (i = 0; i < iommu_leak_pages; i+=2) {
-               printk("%lu: ", iommu_pages-i);
-               printk_address((unsigned long) iommu_leak_tab[iommu_pages-i]);
-               printk("%c", (i+1)%2 == 0 ? '\n' : ' '); 
-       } 
-       printk("\n");
-}
-#else
-#define SET_LEAK(x)
-#define CLEAR_LEAK(x)
-#endif
-
-static void iommu_full(struct device *dev, size_t size, int dir)
-{
-       /* 
-        * Ran out of IOMMU space for this operation. This is very bad.
-        * Unfortunately the drivers cannot handle this operation properly.
-        * Return some non mapped prereserved space in the aperture and 
-        * let the Northbridge deal with it. This will result in garbage
-        * in the IO operation. When the size exceeds the prereserved space
-        * memory corruption will occur or random memory will be DMAed 
-        * out. Hopefully no network devices use single mappings that big.
-        */ 
-       
-       printk(KERN_ERR 
-  "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
-              size, dev->bus_id);
-
-       if (size > PAGE_SIZE*EMERGENCY_PAGES) {
-               if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
-                       panic("PCI-DMA: Memory would be corrupted\n");
-               if (dir == PCI_DMA_TODEVICE || dir == PCI_DMA_BIDIRECTIONAL) 
-                       panic(KERN_ERR "PCI-DMA: Random memory would be DMAed\n");
-       } 
-
-#ifdef CONFIG_IOMMU_LEAK
-       dump_leak(); 
-#endif
-} 
-
-static inline int need_iommu(struct device *dev, unsigned long addr, size_t size)
-{ 
-       u64 mask = *dev->dma_mask;
-       int high = addr + size > mask;
-       int mmu = high;
-       if (force_iommu) 
-               mmu = 1; 
-       return mmu; 
-}
-
-static inline int nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
-{ 
-       u64 mask = *dev->dma_mask;
-       int high = addr + size > mask;
-       int mmu = high;
-       return mmu; 
-}
-
-/* Map a single continuous physical area into the IOMMU.
- * Caller needs to check if the iommu is needed and flush.
- */
-static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
-                               size_t size, int dir)
-{ 
-       unsigned long npages = to_pages(phys_mem, size);
-       unsigned long iommu_page = alloc_iommu(npages);
-       int i;
-       if (iommu_page == -1) {
-               if (!nonforced_iommu(dev, phys_mem, size))
-                       return phys_mem; 
-               if (panic_on_overflow)
-                       panic("dma_map_area overflow %lu bytes\n", size);
-               iommu_full(dev, size, dir);
-               return bad_dma_address;
-       }
-
-       for (i = 0; i < npages; i++) {
-               iommu_gatt_base[iommu_page + i] = GPTE_ENCODE(phys_mem);
-               SET_LEAK(iommu_page + i);
-               phys_mem += PAGE_SIZE;
-       }
-       return iommu_bus_base + iommu_page*PAGE_SIZE + (phys_mem & ~PAGE_MASK);
-}
-
-static dma_addr_t gart_map_simple(struct device *dev, char *buf,
-                                size_t size, int dir)
-{
-       dma_addr_t map = dma_map_area(dev, virt_to_bus(buf), size, dir);
-       flush_gart();
-       return map;
-}
-
-/* Map a single area into the IOMMU */
-static dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
-{
-       unsigned long phys_mem, bus;
-
-       if (!dev)
-               dev = &fallback_dev;
-
-       phys_mem = virt_to_phys(addr); 
-       if (!need_iommu(dev, phys_mem, size))
-               return phys_mem; 
-
-       bus = gart_map_simple(dev, addr, size, dir);
-       return bus; 
-}
-
-/*
- * Free a DMA mapping.
- */
-static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
-                     size_t size, int direction)
-{
-       unsigned long iommu_page;
-       int npages;
-       int i;
-
-       if (dma_addr < iommu_bus_base + EMERGENCY_PAGES*PAGE_SIZE ||
-           dma_addr >= iommu_bus_base + iommu_size)
-               return;
-       iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT;
-       npages = to_pages(dma_addr, size);
-       for (i = 0; i < npages; i++) {
-               iommu_gatt_base[iommu_page + i] = gart_unmapped_entry;
-               CLEAR_LEAK(iommu_page + i);
-       }
-       free_iommu(iommu_page, npages);
-}
-
-/*
- * Wrapper for pci_unmap_single working with scatterlists.
- */
-static void gart_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
-{
-       int i;
-
-       for (i = 0; i < nents; i++) {
-               struct scatterlist *s = &sg[i];
-               if (!s->dma_length || !s->length)
-                       break;
-               gart_unmap_single(dev, s->dma_address, s->dma_length, dir);
-       }
-}
-
-/* Fallback for dma_map_sg in case of overflow */
-static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
-                              int nents, int dir)
-{
-       int i;
-
-#ifdef CONFIG_IOMMU_DEBUG
-       printk(KERN_DEBUG "dma_map_sg overflow\n");
-#endif
-
-       for (i = 0; i < nents; i++ ) {
-               struct scatterlist *s = &sg[i];
-               unsigned long addr = page_to_phys(s->page) + s->offset; 
-               if (nonforced_iommu(dev, addr, s->length)) { 
-                       addr = dma_map_area(dev, addr, s->length, dir);
-                       if (addr == bad_dma_address) { 
-                               if (i > 0) 
-                                       gart_unmap_sg(dev, sg, i, dir);
-                               nents = 0; 
-                               sg[0].dma_length = 0;
-                               break;
-                       }
-               }
-               s->dma_address = addr;
-               s->dma_length = s->length;
-       }
-       flush_gart();
-       return nents;
-}
-
-/* Map multiple scatterlist entries continuous into the first. */
-static int __dma_map_cont(struct scatterlist *sg, int start, int stopat,
-                     struct scatterlist *sout, unsigned long pages)
-{
-       unsigned long iommu_start = alloc_iommu(pages);
-       unsigned long iommu_page = iommu_start; 
-       int i;
-
-       if (iommu_start == -1)
-               return -1;
-       
-       for (i = start; i < stopat; i++) {
-               struct scatterlist *s = &sg[i];
-               unsigned long pages, addr;
-               unsigned long phys_addr = s->dma_address;
-               
-               BUG_ON(i > start && s->offset);
-               if (i == start) {
-                       *sout = *s; 
-                       sout->dma_address = iommu_bus_base;
-                       sout->dma_address += iommu_page*PAGE_SIZE + s->offset;
-                       sout->dma_length = s->length;
-               } else { 
-                       sout->dma_length += s->length; 
-               }
-
-               addr = phys_addr;
-               pages = to_pages(s->offset, s->length); 
-               while (pages--) { 
-                       iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr); 
-                       SET_LEAK(iommu_page);
-                       addr += PAGE_SIZE;
-                       iommu_page++;
-               }
-       } 
-       BUG_ON(iommu_page - iommu_start != pages);      
-       return 0;
-}
-
-static inline int dma_map_cont(struct scatterlist *sg, int start, int stopat,
-                     struct scatterlist *sout,
-                     unsigned long pages, int need)
-{
-       if (!need) { 
-               BUG_ON(stopat - start != 1);
-               *sout = sg[start]; 
-               sout->dma_length = sg[start].length; 
-               return 0;
-       } 
-       return __dma_map_cont(sg, start, stopat, sout, pages);
-}
-               
-/*
- * DMA map all entries in a scatterlist.
- * Merge chunks that have page aligned sizes into a continuous mapping. 
- */
-int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
-{
-       int i;
-       int out;
-       int start;
-       unsigned long pages = 0;
-       int need = 0, nextneed;
-
-       if (nents == 0) 
-               return 0;
-
-       if (!dev)
-               dev = &fallback_dev;
-
-       out = 0;
-       start = 0;
-       for (i = 0; i < nents; i++) {
-               struct scatterlist *s = &sg[i];
-               dma_addr_t addr = page_to_phys(s->page) + s->offset;
-               s->dma_address = addr;
-               BUG_ON(s->length == 0); 
-
-               nextneed = need_iommu(dev, addr, s->length); 
-
-               /* Handle the previous not yet processed entries */
-               if (i > start) {
-                       struct scatterlist *ps = &sg[i-1];
-                       /* Can only merge when the last chunk ends on a page 
-                          boundary and the new one doesn't have an offset. */
-                       if (!iommu_merge || !nextneed || !need || s->offset ||
-                           (ps->offset + ps->length) % PAGE_SIZE) { 
-                               if (dma_map_cont(sg, start, i, sg+out, pages,
-                                                need) < 0)
-                                       goto error;
-                               out++;
-                               pages = 0;
-                               start = i;      
-                       }
-               }
-
-               need = nextneed;
-               pages += to_pages(s->offset, s->length);
-       }
-       if (dma_map_cont(sg, start, i, sg+out, pages, need) < 0)
-               goto error;
-       out++;
-       flush_gart();
-       if (out < nents) 
-               sg[out].dma_length = 0; 
-       return out;
-
-error:
-       flush_gart();
-       gart_unmap_sg(dev, sg, nents, dir);
-       /* When it was forced or merged try again in a dumb way */
-       if (force_iommu || iommu_merge) {
-               out = dma_map_sg_nonforce(dev, sg, nents, dir);
-               if (out > 0)
-                       return out;
-       }
-       if (panic_on_overflow)
-               panic("dma_map_sg: overflow on %lu pages\n", pages);
-       iommu_full(dev, pages << PAGE_SHIFT, dir);
-       for (i = 0; i < nents; i++)
-               sg[i].dma_address = bad_dma_address;
-       return 0;
-} 
-
-static int no_agp;
-
-static __init unsigned long check_iommu_size(unsigned long aper, u64 aper_size)
-{ 
-       unsigned long a; 
-       if (!iommu_size) { 
-               iommu_size = aper_size; 
-               if (!no_agp) 
-                       iommu_size /= 2; 
-       } 
-
-       a = aper + iommu_size; 
-       iommu_size -= round_up(a, LARGE_PAGE_SIZE) - a;
-
-       if (iommu_size < 64*1024*1024) 
-               printk(KERN_WARNING
-  "PCI-DMA: Warning: Small IOMMU %luMB. Consider increasing the AGP aperture in BIOS\n",iommu_size>>20); 
-       
-       return iommu_size;
-} 
-
-static __init unsigned read_aperture(struct pci_dev *dev, u32 *size) 
-{ 
-       unsigned aper_size = 0, aper_base_32;
-       u64 aper_base;
-       unsigned aper_order;
-
-       pci_read_config_dword(dev, 0x94, &aper_base_32); 
-       pci_read_config_dword(dev, 0x90, &aper_order);
-       aper_order = (aper_order >> 1) & 7;     
-
-       aper_base = aper_base_32 & 0x7fff; 
-       aper_base <<= 25;
-
-       aper_size = (32 * 1024 * 1024) << aper_order; 
-       if (aper_base + aper_size > 0x100000000UL || !aper_size)
-               aper_base = 0;
-
-       *size = aper_size;
-       return aper_base;
-} 
-
-/* 
- * Private Northbridge GATT initialization in case we cannot use the
- * AGP driver for some reason.  
- */
-static __init int init_k8_gatt(struct agp_kern_info *info)
-{ 
-       struct pci_dev *dev;
-       void *gatt;
-       unsigned aper_base, new_aper_base;
-       unsigned aper_size, gatt_size, new_aper_size;
-       int i;
-
-       printk(KERN_INFO "PCI-DMA: Disabling AGP.\n");
-       aper_size = aper_base = info->aper_size = 0;
-       dev = NULL;
-       for (i = 0; i < num_k8_northbridges; i++) {
-               dev = k8_northbridges[i];
-               new_aper_base = read_aperture(dev, &new_aper_size); 
-               if (!new_aper_base) 
-                       goto nommu; 
-               
-               if (!aper_base) { 
-                       aper_size = new_aper_size;
-                       aper_base = new_aper_base;
-               } 
-               if (aper_size != new_aper_size || aper_base != new_aper_base) 
-                       goto nommu;
-       }
-       if (!aper_base)
-               goto nommu; 
-       info->aper_base = aper_base;
-       info->aper_size = aper_size>>20; 
-
-       gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32); 
-       gatt = (void *)__get_free_pages(GFP_KERNEL, get_order(gatt_size)); 
-       if (!gatt) 
-               panic("Cannot allocate GATT table");
-       if (change_page_attr_addr((unsigned long)gatt, gatt_size >> PAGE_SHIFT, PAGE_KERNEL_NOCACHE))
-               panic("Could not set GART PTEs to uncacheable pages");
-       global_flush_tlb();
-
-       memset(gatt, 0, gatt_size); 
-       agp_gatt_table = gatt;
-
-       for (i = 0; i < num_k8_northbridges; i++) {
-               u32 ctl; 
-               u32 gatt_reg; 
-
-               dev = k8_northbridges[i];
-               gatt_reg = __pa(gatt) >> 12; 
-               gatt_reg <<= 4; 
-               pci_write_config_dword(dev, 0x98, gatt_reg);
-               pci_read_config_dword(dev, 0x90, &ctl); 
-
-               ctl |= 1;
-               ctl &= ~((1<<4) | (1<<5));
-
-               pci_write_config_dword(dev, 0x90, ctl); 
-       }
-       flush_gart();
-       
-       printk("PCI-DMA: aperture base @ %x size %u KB\n",aper_base, aper_size>>10); 
-       return 0;
-
- nommu:
-       /* Should not happen anymore */
-       printk(KERN_ERR "PCI-DMA: More than 4GB of RAM and no IOMMU\n"
-              KERN_ERR "PCI-DMA: 32bit PCI IO may malfunction.\n");
-       return -1; 
-} 
-
-extern int agp_amd64_init(void);
-
-static const struct dma_mapping_ops gart_dma_ops = {
-       .mapping_error = NULL,
-       .map_single = gart_map_single,
-       .map_simple = gart_map_simple,
-       .unmap_single = gart_unmap_single,
-       .sync_single_for_cpu = NULL,
-       .sync_single_for_device = NULL,
-       .sync_single_range_for_cpu = NULL,
-       .sync_single_range_for_device = NULL,
-       .sync_sg_for_cpu = NULL,
-       .sync_sg_for_device = NULL,
-       .map_sg = gart_map_sg,
-       .unmap_sg = gart_unmap_sg,
-};
-
-void gart_iommu_shutdown(void)
-{
-       struct pci_dev *dev;
-       int i;
-
-       if (no_agp && (dma_ops != &gart_dma_ops))
-               return;
-
-        for (i = 0; i < num_k8_northbridges; i++) {
-                u32 ctl;
-
-                dev = k8_northbridges[i];
-                pci_read_config_dword(dev, 0x90, &ctl);
-
-                ctl &= ~1;
-
-                pci_write_config_dword(dev, 0x90, ctl);
-        }
-}
-
-void __init gart_iommu_init(void)
-{ 
-       struct agp_kern_info info;
-       unsigned long aper_size;
-       unsigned long iommu_start;
-       unsigned long scratch;
-       long i;
-
-       if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0) {
-               printk(KERN_INFO "PCI-GART: No AMD northbridge found.\n");
-               return;
-       }
-
-#ifndef CONFIG_AGP_AMD64
-       no_agp = 1; 
-#else
-       /* Makefile puts PCI initialization via subsys_initcall first. */
-       /* Add other K8 AGP bridge drivers here */
-       no_agp = no_agp || 
-               (agp_amd64_init() < 0) || 
-               (agp_copy_info(agp_bridge, &info) < 0);
-#endif 
-
-       if (swiotlb)
-               return;
-
-       /* Did we detect a different HW IOMMU? */
-       if (iommu_detected && !iommu_aperture)
-               return;
-
-       if (no_iommu ||
-           (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
-           !iommu_aperture ||
-           (no_agp && init_k8_gatt(&info) < 0)) {
-               if (end_pfn > MAX_DMA32_PFN) {
-                       printk(KERN_ERR "WARNING more than 4GB of memory "
-                                       "but GART IOMMU not available.\n"
-                              KERN_ERR "WARNING 32bit PCI may malfunction.\n");
-               }
-               return;
-       }
-
-       printk(KERN_INFO "PCI-DMA: using GART IOMMU.\n");
-       aper_size = info.aper_size * 1024 * 1024;       
-       iommu_size = check_iommu_size(info.aper_base, aper_size); 
-       iommu_pages = iommu_size >> PAGE_SHIFT; 
-
-       iommu_gart_bitmap = (void*)__get_free_pages(GFP_KERNEL, 
-                                                   get_order(iommu_pages/8)); 
-       if (!iommu_gart_bitmap) 
-               panic("Cannot allocate iommu bitmap\n"); 
-       memset(iommu_gart_bitmap, 0, iommu_pages/8);
-
-#ifdef CONFIG_IOMMU_LEAK
-       if (leak_trace) { 
-               iommu_leak_tab = (void *)__get_free_pages(GFP_KERNEL, 
-                                 get_order(iommu_pages*sizeof(void *)));
-               if (iommu_leak_tab) 
-                       memset(iommu_leak_tab, 0, iommu_pages * 8); 
-               else
-                       printk("PCI-DMA: Cannot allocate leak trace area\n"); 
-       } 
-#endif
-
-       /* 
-        * Out of IOMMU space handling.
-        * Reserve some invalid pages at the beginning of the GART. 
-        */ 
-       set_bit_string(iommu_gart_bitmap, 0, EMERGENCY_PAGES); 
-
-       agp_memory_reserved = iommu_size;       
-       printk(KERN_INFO
-              "PCI-DMA: Reserving %luMB of IOMMU area in the AGP aperture\n",
-              iommu_size>>20); 
-
-       iommu_start = aper_size - iommu_size;   
-       iommu_bus_base = info.aper_base + iommu_start; 
-       bad_dma_address = iommu_bus_base;
-       iommu_gatt_base = agp_gatt_table + (iommu_start>>PAGE_SHIFT);
-
-       /* 
-        * Unmap the IOMMU part of the GART. The alias of the page is
-        * always mapped with cache enabled and there is no full cache
-        * coherency across the GART remapping. The unmapping avoids
-        * automatic prefetches from the CPU allocating cache lines in
-        * there. All CPU accesses are done via the direct mapping to
-        * the backing memory. The GART address is only used by PCI
-        * devices. 
-        */
-       clear_kernel_mapping((unsigned long)__va(iommu_bus_base), iommu_size);
-
-       /* 
-        * Try to workaround a bug (thanks to BenH) 
-        * Set unmapped entries to a scratch page instead of 0. 
-        * Any prefetches that hit unmapped entries won't get an bus abort
-        * then.
-        */
-       scratch = get_zeroed_page(GFP_KERNEL); 
-       if (!scratch) 
-               panic("Cannot allocate iommu scratch page");
-       gart_unmapped_entry = GPTE_ENCODE(__pa(scratch));
-       for (i = EMERGENCY_PAGES; i < iommu_pages; i++) 
-               iommu_gatt_base[i] = gart_unmapped_entry;
-
-       flush_gart();
-       dma_ops = &gart_dma_ops;
-} 
-
-void __init gart_parse_options(char *p)
-{
-       int arg;
-
-#ifdef CONFIG_IOMMU_LEAK
-       if (!strncmp(p,"leak",4)) {
-               leak_trace = 1;
-               p += 4;
-               if (*p == '=') ++p;
-               if (isdigit(*p) && get_option(&p, &arg))
-                       iommu_leak_pages = arg;
-       }
-#endif
-       if (isdigit(*p) && get_option(&p, &arg))
-               iommu_size = arg;
-       if (!strncmp(p, "fullflush",8))
-               iommu_fullflush = 1;
-       if (!strncmp(p, "nofullflush",11))
-               iommu_fullflush = 0;
-       if (!strncmp(p,"noagp",5))
-               no_agp = 1;
-       if (!strncmp(p, "noaperture",10))
-               fix_aperture = 0;
-       /* duplicated from pci-dma.c */
-       if (!strncmp(p,"force",5))
-               iommu_aperture_allowed = 1;
-       if (!strncmp(p,"allowed",7))
-               iommu_aperture_allowed = 1;
-       if (!strncmp(p, "memaper", 7)) {
-               fallback_aper_force = 1;
-               p += 7;
-               if (*p == '=') {
-                       ++p;
-                       if (get_option(&p, &arg))
-                               fallback_aper_order = arg;
-               }
-       }
-}
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
deleted file mode 100644 (file)
index 2a34c6c..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Fallback functions when the main IOMMU code is not compiled in. This
-   code is roughly equivalent to i386. */
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/string.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/iommu.h>
-#include <asm/processor.h>
-#include <asm/dma.h>
-
-static int
-check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
-{
-        if (hwdev && bus + size > *hwdev->dma_mask) {
-               if (*hwdev->dma_mask >= DMA_32BIT_MASK)
-                       printk(KERN_ERR
-                           "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
-                               name, (long long)bus, size,
-                               (long long)*hwdev->dma_mask);
-               return 0;
-       }
-       return 1;
-}
-
-static dma_addr_t
-nommu_map_single(struct device *hwdev, void *ptr, size_t size,
-              int direction)
-{
-       dma_addr_t bus = virt_to_bus(ptr);
-       if (!check_addr("map_single", hwdev, bus, size))
-                               return bad_dma_address;
-       return bus;
-}
-
-static void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
-                       int direction)
-{
-}
-
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scatter-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
-              int nents, int direction)
-{
-       int i;
-
-       for (i = 0; i < nents; i++ ) {
-               struct scatterlist *s = &sg[i];
-               BUG_ON(!s->page);
-               s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
-               if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
-                       return 0;
-               s->dma_length = s->length;
-       }
-       return nents;
-}
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
- */
-static void nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
-                 int nents, int dir)
-{
-}
-
-const struct dma_mapping_ops nommu_dma_ops = {
-       .map_single = nommu_map_single,
-       .unmap_single = nommu_unmap_single,
-       .map_sg = nommu_map_sg,
-       .unmap_sg = nommu_unmap_sg,
-       .is_phys = 1,
-};
-
-void __init no_iommu_init(void)
-{
-       if (dma_ops)
-               return;
-
-       force_iommu = 0; /* no HW IOMMU */
-       dma_ops = &nommu_dma_ops;
-}
diff --git a/arch/x86_64/kernel/pci-swiotlb.c b/arch/x86_64/kernel/pci-swiotlb.c
deleted file mode 100644 (file)
index b2f405e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Glue code to lib/swiotlb.c */
-
-#include <linux/pci.h>
-#include <linux/cache.h>
-#include <linux/module.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/iommu.h>
-#include <asm/swiotlb.h>
-#include <asm/dma.h>
-
-int swiotlb __read_mostly;
-EXPORT_SYMBOL(swiotlb);
-
-const struct dma_mapping_ops swiotlb_dma_ops = {
-       .mapping_error = swiotlb_dma_mapping_error,
-       .alloc_coherent = swiotlb_alloc_coherent,
-       .free_coherent = swiotlb_free_coherent,
-       .map_single = swiotlb_map_single,
-       .unmap_single = swiotlb_unmap_single,
-       .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
-       .sync_single_for_device = swiotlb_sync_single_for_device,
-       .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
-       .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
-       .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
-       .sync_sg_for_device = swiotlb_sync_sg_for_device,
-       .map_sg = swiotlb_map_sg,
-       .unmap_sg = swiotlb_unmap_sg,
-       .dma_supported = NULL,
-};
-
-void __init pci_swiotlb_init(void)
-{
-       /* don't initialize swiotlb if iommu=off (no_iommu=1) */
-       if (!iommu_detected && !no_iommu && end_pfn > MAX_DMA32_PFN)
-              swiotlb = 1;
-       if (swiotlb_force)
-               swiotlb = 1;
-       if (swiotlb) {
-               printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
-               swiotlb_init();
-               dma_ops = &swiotlb_dma_ops;
-       }
-}
diff --git a/arch/x86_64/kernel/pmtimer.c b/arch/x86_64/kernel/pmtimer.c
deleted file mode 100644 (file)
index ae8f912..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Ported over from i386 by AK, original copyright was:
- *
- * (C) Dominik Brodowski <linux@brodo.de> 2003
- *
- * Driver to use the Power Management Timer (PMTMR) available in some
- * southbridges as primary timing source for the Linux kernel.
- *
- * Based on parts of linux/drivers/acpi/hardware/hwtimer.c, timer_pit.c,
- * timer_hpet.c, and on Arjan van de Ven's implementation for 2.4.
- *
- * This file is licensed under the GPL v2.
- *
- * Dropped all the hardware bug workarounds for now. Hopefully they
- * are not needed on 64bit chipsets.
- */
-
-#include <linux/jiffies.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/init.h>
-#include <linux/cpumask.h>
-#include <asm/io.h>
-#include <asm/proto.h>
-#include <asm/msr.h>
-#include <asm/vsyscall.h>
-
-#define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */
-
-static inline u32 cyc2us(u32 cycles)
-{
-       /* The Power Management Timer ticks at 3.579545 ticks per microsecond.
-        * 1 / PM_TIMER_FREQUENCY == 0.27936511 =~ 286/1024 [error: 0.024%]
-        *
-        * Even with HZ = 100, delta is at maximum 35796 ticks, so it can
-        * easily be multiplied with 286 (=0x11E) without having to fear
-        * u32 overflows.
-        */
-       cycles *= 286;
-       return (cycles >> 10);
-}
-
-static unsigned pmtimer_wait_tick(void)
-{
-       u32 a, b;
-       for (a = b = inl(pmtmr_ioport) & ACPI_PM_MASK;
-            a == b;
-            b = inl(pmtmr_ioport) & ACPI_PM_MASK)
-               cpu_relax();
-       return b;
-}
-
-/* note: wait time is rounded up to one tick */
-void pmtimer_wait(unsigned us)
-{
-       u32 a, b;
-       a = pmtimer_wait_tick();
-       do {
-               b = inl(pmtmr_ioport);
-               cpu_relax();
-       } while (cyc2us(b - a) < us);
-}
-
-static int __init nopmtimer_setup(char *s)
-{
-       pmtmr_ioport = 0;
-       return 1;
-}
-
-__setup("nopmtimer", nopmtimer_setup);
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
deleted file mode 100644 (file)
index 9895655..0000000
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- *  linux/arch/x86-64/kernel/process.c
- *
- *  Copyright (C) 1995  Linus Torvalds
- *
- *  Pentium III FXSR, SSE support
- *     Gareth Hughes <gareth@valinux.com>, May 2000
- * 
- *  X86-64 port
- *     Andi Kleen.
- *
- *     CPU hotplug support - ashok.raj@intel.com
- */
-
-/*
- * This file handles the architecture-dependent parts of process handling..
- */
-
-#include <stdarg.h>
-
-#include <linux/cpu.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/elfcore.h>
-#include <linux/smp.h>
-#include <linux/slab.h>
-#include <linux/user.h>
-#include <linux/module.h>
-#include <linux/a.out.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/ptrace.h>
-#include <linux/utsname.h>
-#include <linux/random.h>
-#include <linux/notifier.h>
-#include <linux/kprobes.h>
-#include <linux/kdebug.h>
-
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/i387.h>
-#include <asm/mmu_context.h>
-#include <asm/pda.h>
-#include <asm/prctl.h>
-#include <asm/desc.h>
-#include <asm/proto.h>
-#include <asm/ia32.h>
-#include <asm/idle.h>
-
-asmlinkage extern void ret_from_fork(void);
-
-unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
-
-unsigned long boot_option_idle_override = 0;
-EXPORT_SYMBOL(boot_option_idle_override);
-
-/*
- * Powermanagement idle function, if any..
- */
-void (*pm_idle)(void);
-EXPORT_SYMBOL(pm_idle);
-static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
-
-static ATOMIC_NOTIFIER_HEAD(idle_notifier);
-
-void idle_notifier_register(struct notifier_block *n)
-{
-       atomic_notifier_chain_register(&idle_notifier, n);
-}
-EXPORT_SYMBOL_GPL(idle_notifier_register);
-
-void idle_notifier_unregister(struct notifier_block *n)
-{
-       atomic_notifier_chain_unregister(&idle_notifier, n);
-}
-EXPORT_SYMBOL(idle_notifier_unregister);
-
-void enter_idle(void)
-{
-       write_pda(isidle, 1);
-       atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
-}
-
-static void __exit_idle(void)
-{
-       if (test_and_clear_bit_pda(0, isidle) == 0)
-               return;
-       atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
-}
-
-/* Called from interrupts to signify idle end */
-void exit_idle(void)
-{
-       /* idle loop has pid 0 */
-       if (current->pid)
-               return;
-       __exit_idle();
-}
-
-/*
- * We use this if we don't have any better
- * idle routine..
- */
-static void default_idle(void)
-{
-       current_thread_info()->status &= ~TS_POLLING;
-       /*
-        * TS_POLLING-cleared state must be visible before we
-        * test NEED_RESCHED:
-        */
-       smp_mb();
-       local_irq_disable();
-       if (!need_resched()) {
-               /* Enables interrupts one instruction before HLT.
-                  x86 special cases this so there is no race. */
-               safe_halt();
-       } else
-               local_irq_enable();
-       current_thread_info()->status |= TS_POLLING;
-}
-
-/*
- * On SMP it's slightly faster (but much more power-consuming!)
- * to poll the ->need_resched flag instead of waiting for the
- * cross-CPU IPI to arrive. Use this option with caution.
- */
-static void poll_idle (void)
-{
-       local_irq_enable();
-       cpu_relax();
-}
-
-void cpu_idle_wait(void)
-{
-       unsigned int cpu, this_cpu = get_cpu();
-       cpumask_t map, tmp = current->cpus_allowed;
-
-       set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
-       put_cpu();
-
-       cpus_clear(map);
-       for_each_online_cpu(cpu) {
-               per_cpu(cpu_idle_state, cpu) = 1;
-               cpu_set(cpu, map);
-       }
-
-       __get_cpu_var(cpu_idle_state) = 0;
-
-       wmb();
-       do {
-               ssleep(1);
-               for_each_online_cpu(cpu) {
-                       if (cpu_isset(cpu, map) &&
-                                       !per_cpu(cpu_idle_state, cpu))
-                               cpu_clear(cpu, map);
-               }
-               cpus_and(map, map, cpu_online_map);
-       } while (!cpus_empty(map));
-
-       set_cpus_allowed(current, tmp);
-}
-EXPORT_SYMBOL_GPL(cpu_idle_wait);
-
-#ifdef CONFIG_HOTPLUG_CPU
-DECLARE_PER_CPU(int, cpu_state);
-
-#include <asm/nmi.h>
-/* We halt the CPU with physical CPU hotplug */
-static inline void play_dead(void)
-{
-       idle_task_exit();
-       wbinvd();
-       mb();
-       /* Ack it */
-       __get_cpu_var(cpu_state) = CPU_DEAD;
-
-       local_irq_disable();
-       while (1)
-               halt();
-}
-#else
-static inline void play_dead(void)
-{
-       BUG();
-}
-#endif /* CONFIG_HOTPLUG_CPU */
-
-/*
- * The idle thread. There's no useful work to be
- * done, so just try to conserve power and have a
- * low exit latency (ie sit in a loop waiting for
- * somebody to say that they'd like to reschedule)
- */
-void cpu_idle (void)
-{
-       current_thread_info()->status |= TS_POLLING;
-       /* endless idle loop with no priority at all */
-       while (1) {
-               while (!need_resched()) {
-                       void (*idle)(void);
-
-                       if (__get_cpu_var(cpu_idle_state))
-                               __get_cpu_var(cpu_idle_state) = 0;
-
-                       rmb();
-                       idle = pm_idle;
-                       if (!idle)
-                               idle = default_idle;
-                       if (cpu_is_offline(smp_processor_id()))
-                               play_dead();
-                       /*
-                        * Idle routines should keep interrupts disabled
-                        * from here on, until they go to idle.
-                        * Otherwise, idle callbacks can misfire.
-                        */
-                       local_irq_disable();
-                       enter_idle();
-                       idle();
-                       /* In many cases the interrupt that ended idle
-                          has already called exit_idle. But some idle
-                          loops can be woken up without interrupt. */
-                       __exit_idle();
-               }
-
-               preempt_enable_no_resched();
-               schedule();
-               preempt_disable();
-       }
-}
-
-/*
- * This uses new MONITOR/MWAIT instructions on P4 processors with PNI,
- * which can obviate IPI to trigger checking of need_resched.
- * We execute MONITOR against need_resched and enter optimized wait state
- * through MWAIT. Whenever someone changes need_resched, we would be woken
- * up from MWAIT (without an IPI).
- *
- * New with Core Duo processors, MWAIT can take some hints based on CPU
- * capability.
- */
-void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
-{
-       if (!need_resched()) {
-               __monitor((void *)&current_thread_info()->flags, 0, 0);
-               smp_mb();
-               if (!need_resched())
-                       __mwait(eax, ecx);
-       }
-}
-
-/* Default MONITOR/MWAIT with no hints, used for default C1 state */
-static void mwait_idle(void)
-{
-       if (!need_resched()) {
-               __monitor((void *)&current_thread_info()->flags, 0, 0);
-               smp_mb();
-               if (!need_resched())
-                       __sti_mwait(0, 0);
-               else
-                       local_irq_enable();
-       } else {
-               local_irq_enable();
-       }
-}
-
-void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
-{
-       static int printed;
-       if (cpu_has(c, X86_FEATURE_MWAIT)) {
-               /*
-                * Skip, if setup has overridden idle.
-                * One CPU supports mwait => All CPUs supports mwait
-                */
-               if (!pm_idle) {
-                       if (!printed) {
-                               printk(KERN_INFO "using mwait in idle threads.\n");
-                               printed = 1;
-                       }
-                       pm_idle = mwait_idle;
-               }
-       }
-}
-
-static int __init idle_setup (char *str)
-{
-       if (!strcmp(str, "poll")) {
-               printk("using polling idle threads.\n");
-               pm_idle = poll_idle;
-       } else if (!strcmp(str, "mwait"))
-               force_mwait = 1;
-       else
-               return -1;
-
-       boot_option_idle_override = 1;
-       return 0;
-}
-early_param("idle", idle_setup);
-
-/* Prints also some state that isn't saved in the pt_regs */ 
-void __show_regs(struct pt_regs * regs)
-{
-       unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
-       unsigned long d0, d1, d2, d3, d6, d7;
-       unsigned int fsindex,gsindex;
-       unsigned int ds,cs,es; 
-
-       printk("\n");
-       print_modules();
-       printk("Pid: %d, comm: %.20s %s %s %.*s\n",
-               current->pid, current->comm, print_tainted(),
-               init_utsname()->release,
-               (int)strcspn(init_utsname()->version, " "),
-               init_utsname()->version);
-       printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->rip);
-       printk_address(regs->rip); 
-       printk("RSP: %04lx:%016lx  EFLAGS: %08lx\n", regs->ss, regs->rsp,
-               regs->eflags);
-       printk("RAX: %016lx RBX: %016lx RCX: %016lx\n",
-              regs->rax, regs->rbx, regs->rcx);
-       printk("RDX: %016lx RSI: %016lx RDI: %016lx\n",
-              regs->rdx, regs->rsi, regs->rdi); 
-       printk("RBP: %016lx R08: %016lx R09: %016lx\n",
-              regs->rbp, regs->r8, regs->r9); 
-       printk("R10: %016lx R11: %016lx R12: %016lx\n",
-              regs->r10, regs->r11, regs->r12); 
-       printk("R13: %016lx R14: %016lx R15: %016lx\n",
-              regs->r13, regs->r14, regs->r15); 
-
-       asm("movl %%ds,%0" : "=r" (ds)); 
-       asm("movl %%cs,%0" : "=r" (cs)); 
-       asm("movl %%es,%0" : "=r" (es)); 
-       asm("movl %%fs,%0" : "=r" (fsindex));
-       asm("movl %%gs,%0" : "=r" (gsindex));
-
-       rdmsrl(MSR_FS_BASE, fs);
-       rdmsrl(MSR_GS_BASE, gs); 
-       rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); 
-
-       cr0 = read_cr0();
-       cr2 = read_cr2();
-       cr3 = read_cr3();
-       cr4 = read_cr4();
-
-       printk("FS:  %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n", 
-              fs,fsindex,gs,gsindex,shadowgs); 
-       printk("CS:  %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds, es, cr0); 
-       printk("CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3, cr4);
-
-       get_debugreg(d0, 0);
-       get_debugreg(d1, 1);
-       get_debugreg(d2, 2);
-       printk("DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2);
-       get_debugreg(d3, 3);
-       get_debugreg(d6, 6);
-       get_debugreg(d7, 7);
-       printk("DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7);
-}
-
-void show_regs(struct pt_regs *regs)
-{
-       printk("CPU %d:", smp_processor_id());
-       __show_regs(regs);
-       show_trace(NULL, regs, (void *)(regs + 1));
-}
-
-/*
- * Free current thread data structures etc..
- */
-void exit_thread(void)
-{
-       struct task_struct *me = current;
-       struct thread_struct *t = &me->thread;
-
-       if (me->thread.io_bitmap_ptr) { 
-               struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
-
-               kfree(t->io_bitmap_ptr);
-               t->io_bitmap_ptr = NULL;
-               clear_thread_flag(TIF_IO_BITMAP);
-               /*
-                * Careful, clear this in the TSS too:
-                */
-               memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
-               t->io_bitmap_max = 0;
-               put_cpu();
-       }
-}
-
-void flush_thread(void)
-{
-       struct task_struct *tsk = current;
-
-       if (test_tsk_thread_flag(tsk, TIF_ABI_PENDING)) {
-               clear_tsk_thread_flag(tsk, TIF_ABI_PENDING);
-               if (test_tsk_thread_flag(tsk, TIF_IA32)) {
-                       clear_tsk_thread_flag(tsk, TIF_IA32);
-               } else {
-                       set_tsk_thread_flag(tsk, TIF_IA32);
-                       current_thread_info()->status |= TS_COMPAT;
-               }
-       }
-       clear_tsk_thread_flag(tsk, TIF_DEBUG);
-
-       tsk->thread.debugreg0 = 0;
-       tsk->thread.debugreg1 = 0;
-       tsk->thread.debugreg2 = 0;
-       tsk->thread.debugreg3 = 0;
-       tsk->thread.debugreg6 = 0;
-       tsk->thread.debugreg7 = 0;
-       memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));        
-       /*
-        * Forget coprocessor state..
-        */
-       clear_fpu(tsk);
-       clear_used_math();
-}
-
-void release_thread(struct task_struct *dead_task)
-{
-       if (dead_task->mm) {
-               if (dead_task->mm->context.size) {
-                       printk("WARNING: dead process %8s still has LDT? <%p/%d>\n",
-                                       dead_task->comm,
-                                       dead_task->mm->context.ldt,
-                                       dead_task->mm->context.size);
-                       BUG();
-               }
-       }
-}
-
-static inline void set_32bit_tls(struct task_struct *t, int tls, u32 addr)
-{
-       struct user_desc ud = { 
-               .base_addr = addr,
-               .limit = 0xfffff,
-               .seg_32bit = 1,
-               .limit_in_pages = 1,
-               .useable = 1,
-       };
-       struct n_desc_struct *desc = (void *)t->thread.tls_array;
-       desc += tls;
-       desc->a = LDT_entry_a(&ud); 
-       desc->b = LDT_entry_b(&ud); 
-}
-
-static inline u32 read_32bit_tls(struct task_struct *t, int tls)
-{
-       struct desc_struct *desc = (void *)t->thread.tls_array;
-       desc += tls;
-       return desc->base0 | 
-               (((u32)desc->base1) << 16) | 
-               (((u32)desc->base2) << 24);
-}
-
-/*
- * This gets called before we allocate a new thread and copy
- * the current task into it.
- */
-void prepare_to_copy(struct task_struct *tsk)
-{
-       unlazy_fpu(tsk);
-}
-
-int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp, 
-               unsigned long unused,
-       struct task_struct * p, struct pt_regs * regs)
-{
-       int err;
-       struct pt_regs * childregs;
-       struct task_struct *me = current;
-
-       childregs = ((struct pt_regs *)
-                       (THREAD_SIZE + task_stack_page(p))) - 1;
-       *childregs = *regs;
-
-       childregs->rax = 0;
-       childregs->rsp = rsp;
-       if (rsp == ~0UL)
-               childregs->rsp = (unsigned long)childregs;
-
-       p->thread.rsp = (unsigned long) childregs;
-       p->thread.rsp0 = (unsigned long) (childregs+1);
-       p->thread.userrsp = me->thread.userrsp; 
-
-       set_tsk_thread_flag(p, TIF_FORK);
-
-       p->thread.fs = me->thread.fs;
-       p->thread.gs = me->thread.gs;
-
-       asm("mov %%gs,%0" : "=m" (p->thread.gsindex));
-       asm("mov %%fs,%0" : "=m" (p->thread.fsindex));
-       asm("mov %%es,%0" : "=m" (p->thread.es));
-       asm("mov %%ds,%0" : "=m" (p->thread.ds));
-
-       if (unlikely(test_tsk_thread_flag(me, TIF_IO_BITMAP))) {
-               p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
-               if (!p->thread.io_bitmap_ptr) {
-                       p->thread.io_bitmap_max = 0;
-                       return -ENOMEM;
-               }
-               memcpy(p->thread.io_bitmap_ptr, me->thread.io_bitmap_ptr,
-                               IO_BITMAP_BYTES);
-               set_tsk_thread_flag(p, TIF_IO_BITMAP);
-       } 
-
-       /*
-        * Set a new TLS for the child thread?
-        */
-       if (clone_flags & CLONE_SETTLS) {
-#ifdef CONFIG_IA32_EMULATION
-               if (test_thread_flag(TIF_IA32))
-                       err = ia32_child_tls(p, childregs); 
-               else                    
-#endif  
-                       err = do_arch_prctl(p, ARCH_SET_FS, childregs->r8); 
-               if (err) 
-                       goto out;
-       }
-       err = 0;
-out:
-       if (err && p->thread.io_bitmap_ptr) {
-               kfree(p->thread.io_bitmap_ptr);
-               p->thread.io_bitmap_max = 0;
-       }
-       return err;
-}
-
-/*
- * This special macro can be used to load a debugging register
- */
-#define loaddebug(thread,r) set_debugreg(thread->debugreg ## r, r)
-
-static inline void __switch_to_xtra(struct task_struct *prev_p,
-                                   struct task_struct *next_p,
-                                   struct tss_struct *tss)
-{
-       struct thread_struct *prev, *next;
-
-       prev = &prev_p->thread,
-       next = &next_p->thread;
-
-       if (test_tsk_thread_flag(next_p, TIF_DEBUG)) {
-               loaddebug(next, 0);
-               loaddebug(next, 1);
-               loaddebug(next, 2);
-               loaddebug(next, 3);
-               /* no 4 and 5 */
-               loaddebug(next, 6);
-               loaddebug(next, 7);
-       }
-
-       if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
-               /*
-                * Copy the relevant range of the IO bitmap.
-                * Normally this is 128 bytes or less:
-                */
-               memcpy(tss->io_bitmap, next->io_bitmap_ptr,
-                      max(prev->io_bitmap_max, next->io_bitmap_max));
-       } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {
-               /*
-                * Clear any possible leftover bits:
-                */
-               memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
-       }
-}
-
-/*
- *     switch_to(x,y) should switch tasks from x to y.
- *
- * This could still be optimized: 
- * - fold all the options into a flag word and test it with a single test.
- * - could test fs/gs bitsliced
- *
- * Kprobes not supported here. Set the probe on schedule instead.
- */
-__kprobes struct task_struct *
-__switch_to(struct task_struct *prev_p, struct task_struct *next_p)
-{
-       struct thread_struct *prev = &prev_p->thread,
-                                *next = &next_p->thread;
-       int cpu = smp_processor_id();  
-       struct tss_struct *tss = &per_cpu(init_tss, cpu);
-
-       /* we're going to use this soon, after a few expensive things */
-       if (next_p->fpu_counter>5)
-               prefetch(&next->i387.fxsave);
-
-       /*
-        * Reload esp0, LDT and the page table pointer:
-        */
-       tss->rsp0 = next->rsp0;
-
-       /* 
-        * Switch DS and ES.
-        * This won't pick up thread selector changes, but I guess that is ok.
-        */
-       asm volatile("mov %%es,%0" : "=m" (prev->es));
-       if (unlikely(next->es | prev->es))
-               loadsegment(es, next->es); 
-       
-       asm volatile ("mov %%ds,%0" : "=m" (prev->ds));
-       if (unlikely(next->ds | prev->ds))
-               loadsegment(ds, next->ds);
-
-       load_TLS(next, cpu);
-
-       /* 
-        * Switch FS and GS.
-        */
-       { 
-               unsigned fsindex;
-               asm volatile("movl %%fs,%0" : "=r" (fsindex)); 
-               /* segment register != 0 always requires a reload. 
-                  also reload when it has changed. 
-                  when prev process used 64bit base always reload
-                  to avoid an information leak. */
-               if (unlikely(fsindex | next->fsindex | prev->fs)) {
-                       loadsegment(fs, next->fsindex);
-                       /* check if the user used a selector != 0
-                        * if yes clear 64bit base, since overloaded base
-                         * is always mapped to the Null selector
-                         */
-                       if (fsindex)
-                       prev->fs = 0;                           
-               }
-               /* when next process has a 64bit base use it */
-               if (next->fs) 
-                       wrmsrl(MSR_FS_BASE, next->fs); 
-               prev->fsindex = fsindex;
-       }
-       { 
-               unsigned gsindex;
-               asm volatile("movl %%gs,%0" : "=r" (gsindex)); 
-               if (unlikely(gsindex | next->gsindex | prev->gs)) {
-                       load_gs_index(next->gsindex);
-                       if (gsindex)
-                       prev->gs = 0;                           
-               }
-               if (next->gs)
-                       wrmsrl(MSR_KERNEL_GS_BASE, next->gs); 
-               prev->gsindex = gsindex;
-       }
-
-       /* Must be after DS reload */
-       unlazy_fpu(prev_p);
-
-       /* 
-        * Switch the PDA and FPU contexts.
-        */
-       prev->userrsp = read_pda(oldrsp); 
-       write_pda(oldrsp, next->userrsp); 
-       write_pda(pcurrent, next_p); 
-
-       write_pda(kernelstack,
-       (unsigned long)task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
-#ifdef CONFIG_CC_STACKPROTECTOR
-       write_pda(stack_canary, next_p->stack_canary);
-       /*
-        * Build time only check to make sure the stack_canary is at
-        * offset 40 in the pda; this is a gcc ABI requirement
-        */
-       BUILD_BUG_ON(offsetof(struct x8664_pda, stack_canary) != 40);
-#endif
-
-       /*
-        * Now maybe reload the debug registers and handle I/O bitmaps
-        */
-       if (unlikely((task_thread_info(next_p)->flags & _TIF_WORK_CTXSW))
-           || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP))
-               __switch_to_xtra(prev_p, next_p, tss);
-
-       /* If the task has used fpu the last 5 timeslices, just do a full
-        * restore of the math state immediately to avoid the trap; the
-        * chances of needing FPU soon are obviously high now
-        */
-       if (next_p->fpu_counter>5)
-               math_state_restore();
-       return prev_p;
-}
-
-/*
- * sys_execve() executes a new program.
- */
-asmlinkage 
-long sys_execve(char __user *name, char __user * __user *argv,
-               char __user * __user *envp, struct pt_regs regs)
-{
-       long error;
-       char * filename;
-
-       filename = getname(name);
-       error = PTR_ERR(filename);
-       if (IS_ERR(filename)) 
-               return error;
-       error = do_execve(filename, argv, envp, &regs); 
-       if (error == 0) {
-               task_lock(current);
-               current->ptrace &= ~PT_DTRACE;
-               task_unlock(current);
-       }
-       putname(filename);
-       return error;
-}
-
-void set_personality_64bit(void)
-{
-       /* inherit personality from parent */
-
-       /* Make sure to be in 64bit mode */
-       clear_thread_flag(TIF_IA32); 
-
-       /* TBD: overwrites user setup. Should have two bits.
-          But 64bit processes have always behaved this way,
-          so it's not too bad. The main problem is just that
-          32bit childs are affected again. */
-       current->personality &= ~READ_IMPLIES_EXEC;
-}
-
-asmlinkage long sys_fork(struct pt_regs *regs)
-{
-       return do_fork(SIGCHLD, regs->rsp, regs, 0, NULL, NULL);
-}
-
-asmlinkage long
-sys_clone(unsigned long clone_flags, unsigned long newsp,
-         void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
-{
-       if (!newsp)
-               newsp = regs->rsp;
-       return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
-}
-
-/*
- * This is trivial, and on the face of it looks like it
- * could equally well be done in user mode.
- *
- * Not so, for quite unobvious reasons - register pressure.
- * In user mode vfork() cannot have a stack frame, and if
- * done by calling the "clone()" system call directly, you
- * do not have enough call-clobbered registers to hold all
- * the information you need.
- */
-asmlinkage long sys_vfork(struct pt_regs *regs)
-{
-       return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->rsp, regs, 0,
-                   NULL, NULL);
-}
-
-unsigned long get_wchan(struct task_struct *p)
-{
-       unsigned long stack;
-       u64 fp,rip;
-       int count = 0;
-
-       if (!p || p == current || p->state==TASK_RUNNING)
-               return 0; 
-       stack = (unsigned long)task_stack_page(p);
-       if (p->thread.rsp < stack || p->thread.rsp > stack+THREAD_SIZE)
-               return 0;
-       fp = *(u64 *)(p->thread.rsp);
-       do { 
-               if (fp < (unsigned long)stack ||
-                   fp > (unsigned long)stack+THREAD_SIZE)
-                       return 0; 
-               rip = *(u64 *)(fp+8); 
-               if (!in_sched_functions(rip))
-                       return rip; 
-               fp = *(u64 *)fp; 
-       } while (count++ < 16); 
-       return 0;
-}
-
-long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
-{ 
-       int ret = 0; 
-       int doit = task == current;
-       int cpu;
-
-       switch (code) { 
-       case ARCH_SET_GS:
-               if (addr >= TASK_SIZE_OF(task))
-                       return -EPERM; 
-               cpu = get_cpu();
-               /* handle small bases via the GDT because that's faster to 
-                  switch. */
-               if (addr <= 0xffffffff) {  
-                       set_32bit_tls(task, GS_TLS, addr); 
-                       if (doit) { 
-                               load_TLS(&task->thread, cpu);
-                               load_gs_index(GS_TLS_SEL); 
-                       }
-                       task->thread.gsindex = GS_TLS_SEL; 
-                       task->thread.gs = 0;
-               } else { 
-                       task->thread.gsindex = 0;
-                       task->thread.gs = addr;
-                       if (doit) {
-                               load_gs_index(0);
-                               ret = checking_wrmsrl(MSR_KERNEL_GS_BASE, addr);
-                       } 
-               }
-               put_cpu();
-               break;
-       case ARCH_SET_FS:
-               /* Not strictly needed for fs, but do it for symmetry
-                  with gs */
-               if (addr >= TASK_SIZE_OF(task))
-                       return -EPERM; 
-               cpu = get_cpu();
-               /* handle small bases via the GDT because that's faster to 
-                  switch. */
-               if (addr <= 0xffffffff) { 
-                       set_32bit_tls(task, FS_TLS, addr);
-                       if (doit) { 
-                               load_TLS(&task->thread, cpu); 
-                               asm volatile("movl %0,%%fs" :: "r"(FS_TLS_SEL));
-                       }
-                       task->thread.fsindex = FS_TLS_SEL;
-                       task->thread.fs = 0;
-               } else { 
-                       task->thread.fsindex = 0;
-                       task->thread.fs = addr;
-                       if (doit) {
-                               /* set the selector to 0 to not confuse
-                                  __switch_to */
-                               asm volatile("movl %0,%%fs" :: "r" (0));
-                               ret = checking_wrmsrl(MSR_FS_BASE, addr);
-                       }
-               }
-               put_cpu();
-               break;
-       case ARCH_GET_FS: { 
-               unsigned long base; 
-               if (task->thread.fsindex == FS_TLS_SEL)
-                       base = read_32bit_tls(task, FS_TLS);
-               else if (doit)
-                       rdmsrl(MSR_FS_BASE, base);
-               else
-                       base = task->thread.fs;
-               ret = put_user(base, (unsigned long __user *)addr); 
-               break; 
-       }
-       case ARCH_GET_GS: { 
-               unsigned long base;
-               unsigned gsindex;
-               if (task->thread.gsindex == GS_TLS_SEL)
-                       base = read_32bit_tls(task, GS_TLS);
-               else if (doit) {
-                       asm("movl %%gs,%0" : "=r" (gsindex));
-                       if (gsindex)
-                               rdmsrl(MSR_KERNEL_GS_BASE, base);
-                       else
-                               base = task->thread.gs;
-               }
-               else
-                       base = task->thread.gs;
-               ret = put_user(base, (unsigned long __user *)addr); 
-               break;
-       }
-
-       default:
-               ret = -EINVAL;
-               break;
-       } 
-
-       return ret;     
-} 
-
-long sys_arch_prctl(int code, unsigned long addr)
-{
-       return do_arch_prctl(current, code, addr);
-} 
-
-/* 
- * Capture the user space registers if the task is not running (in user space)
- */
-int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
-{
-       struct pt_regs *pp, ptregs;
-
-       pp = task_pt_regs(tsk);
-
-       ptregs = *pp; 
-       ptregs.cs &= 0xffff;
-       ptregs.ss &= 0xffff;
-
-       elf_core_copy_regs(regs, &ptregs);
-       return 1;
-}
-
-unsigned long arch_align_stack(unsigned long sp)
-{
-       if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
-               sp -= get_random_int() % 8192;
-       return sp & ~0xf;
-}
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
deleted file mode 100644 (file)
index eea3702..0000000
+++ /dev/null
@@ -1,627 +0,0 @@
-/* ptrace.c */
-/* By Ross Biro 1/23/92 */
-/*
- * Pentium III FXSR, SSE support
- *     Gareth Hughes <gareth@valinux.com>, May 2000
- * 
- * x86-64 port 2000-2002 Andi Kleen
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/errno.h>
-#include <linux/ptrace.h>
-#include <linux/user.h>
-#include <linux/security.h>
-#include <linux/audit.h>
-#include <linux/seccomp.h>
-#include <linux/signal.h>
-
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/system.h>
-#include <asm/processor.h>
-#include <asm/i387.h>
-#include <asm/debugreg.h>
-#include <asm/ldt.h>
-#include <asm/desc.h>
-#include <asm/proto.h>
-#include <asm/ia32.h>
-
-/*
- * does not yet catch signals sent when the child dies.
- * in exit.c or in signal.c.
- */
-
-/*
- * Determines which flags the user has access to [1 = access, 0 = no access].
- * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
- * Also masks reserved bits (63-22, 15, 5, 3, 1).
- */
-#define FLAG_MASK 0x54dd5UL
-
-/* set's the trap flag. */
-#define TRAP_FLAG 0x100UL
-
-/*
- * eflags and offset of eflags on child stack..
- */
-#define EFLAGS offsetof(struct pt_regs, eflags)
-#define EFL_OFFSET ((int)(EFLAGS-sizeof(struct pt_regs)))
-
-/*
- * this routine will get a word off of the processes privileged stack. 
- * the offset is how far from the base addr as stored in the TSS.  
- * this routine assumes that all the privileged stacks are in our
- * data space.
- */   
-static inline unsigned long get_stack_long(struct task_struct *task, int offset)
-{
-       unsigned char *stack;
-
-       stack = (unsigned char *)task->thread.rsp0;
-       stack += offset;
-       return (*((unsigned long *)stack));
-}
-
-/*
- * this routine will put a word on the processes privileged stack. 
- * the offset is how far from the base addr as stored in the TSS.  
- * this routine assumes that all the privileged stacks are in our
- * data space.
- */
-static inline long put_stack_long(struct task_struct *task, int offset,
-       unsigned long data)
-{
-       unsigned char * stack;
-
-       stack = (unsigned char *) task->thread.rsp0;
-       stack += offset;
-       *(unsigned long *) stack = data;
-       return 0;
-}
-
-#define LDT_SEGMENT 4
-
-unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs)
-{
-       unsigned long addr, seg;
-
-       addr = regs->rip;
-       seg = regs->cs & 0xffff;
-
-       /*
-        * We'll assume that the code segments in the GDT
-        * are all zero-based. That is largely true: the
-        * TLS segments are used for data, and the PNPBIOS
-        * and APM bios ones we just ignore here.
-        */
-       if (seg & LDT_SEGMENT) {
-               u32 *desc;
-               unsigned long base;
-
-               seg &= ~7UL;
-
-               down(&child->mm->context.sem);
-               if (unlikely((seg >> 3) >= child->mm->context.size))
-                       addr = -1L; /* bogus selector, access would fault */
-               else {
-                       desc = child->mm->context.ldt + seg;
-                       base = ((desc[0] >> 16) |
-                               ((desc[1] & 0xff) << 16) |
-                               (desc[1] & 0xff000000));
-
-                       /* 16-bit code segment? */
-                       if (!((desc[1] >> 22) & 1))
-                               addr &= 0xffff;
-                       addr += base;
-               }
-               up(&child->mm->context.sem);
-       }
-
-       return addr;
-}
-
-static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
-{
-       int i, copied;
-       unsigned char opcode[15];
-       unsigned long addr = convert_rip_to_linear(child, regs);
-
-       copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
-       for (i = 0; i < copied; i++) {
-               switch (opcode[i]) {
-               /* popf and iret */
-               case 0x9d: case 0xcf:
-                       return 1;
-
-                       /* CHECKME: 64 65 */
-
-               /* opcode and address size prefixes */
-               case 0x66: case 0x67:
-                       continue;
-               /* irrelevant prefixes (segment overrides and repeats) */
-               case 0x26: case 0x2e:
-               case 0x36: case 0x3e:
-               case 0x64: case 0x65:
-               case 0xf2: case 0xf3:
-                       continue;
-
-               case 0x40 ... 0x4f:
-                       if (regs->cs != __USER_CS)
-                               /* 32-bit mode: register increment */
-                               return 0;
-                       /* 64-bit mode: REX prefix */
-                       continue;
-
-                       /* CHECKME: f2, f3 */
-
-               /*
-                * pushf: NOTE! We should probably not let
-                * the user see the TF bit being set. But
-                * it's more pain than it's worth to avoid
-                * it, and a debugger could emulate this
-                * all in user space if it _really_ cares.
-                */
-               case 0x9c:
-               default:
-                       return 0;
-               }
-       }
-       return 0;
-}
-
-static void set_singlestep(struct task_struct *child)
-{
-       struct pt_regs *regs = task_pt_regs(child);
-
-       /*
-        * Always set TIF_SINGLESTEP - this guarantees that
-        * we single-step system calls etc..  This will also
-        * cause us to set TF when returning to user mode.
-        */
-       set_tsk_thread_flag(child, TIF_SINGLESTEP);
-
-       /*
-        * If TF was already set, don't do anything else
-        */
-       if (regs->eflags & TRAP_FLAG)
-               return;
-
-       /* Set TF on the kernel stack.. */
-       regs->eflags |= TRAP_FLAG;
-
-       /*
-        * ..but if TF is changed by the instruction we will trace,
-        * don't mark it as being "us" that set it, so that we
-        * won't clear it by hand later.
-        */
-       if (is_setting_trap_flag(child, regs))
-               return;
-
-       child->ptrace |= PT_DTRACE;
-}
-
-static void clear_singlestep(struct task_struct *child)
-{
-       /* Always clear TIF_SINGLESTEP... */
-       clear_tsk_thread_flag(child, TIF_SINGLESTEP);
-
-       /* But touch TF only if it was set by us.. */
-       if (child->ptrace & PT_DTRACE) {
-               struct pt_regs *regs = task_pt_regs(child);
-               regs->eflags &= ~TRAP_FLAG;
-               child->ptrace &= ~PT_DTRACE;
-       }
-}
-
-/*
- * Called by kernel/ptrace.c when detaching..
- *
- * Make sure the single step bit is not set.
- */
-void ptrace_disable(struct task_struct *child)
-{ 
-       clear_singlestep(child);
-}
-
-static int putreg(struct task_struct *child,
-       unsigned long regno, unsigned long value)
-{
-       unsigned long tmp; 
-       
-       switch (regno) {
-               case offsetof(struct user_regs_struct,fs):
-                       if (value && (value & 3) != 3)
-                               return -EIO;
-                       child->thread.fsindex = value & 0xffff; 
-                       return 0;
-               case offsetof(struct user_regs_struct,gs):
-                       if (value && (value & 3) != 3)
-                               return -EIO;
-                       child->thread.gsindex = value & 0xffff;
-                       return 0;
-               case offsetof(struct user_regs_struct,ds):
-                       if (value && (value & 3) != 3)
-                               return -EIO;
-                       child->thread.ds = value & 0xffff;
-                       return 0;
-               case offsetof(struct user_regs_struct,es): 
-                       if (value && (value & 3) != 3)
-                               return -EIO;
-                       child->thread.es = value & 0xffff;
-                       return 0;
-               case offsetof(struct user_regs_struct,ss):
-                       if ((value & 3) != 3)
-                               return -EIO;
-                       value &= 0xffff;
-                       return 0;
-               case offsetof(struct user_regs_struct,fs_base):
-                       if (value >= TASK_SIZE_OF(child))
-                               return -EIO;
-                       child->thread.fs = value;
-                       return 0;
-               case offsetof(struct user_regs_struct,gs_base):
-                       if (value >= TASK_SIZE_OF(child))
-                               return -EIO;
-                       child->thread.gs = value;
-                       return 0;
-               case offsetof(struct user_regs_struct, eflags):
-                       value &= FLAG_MASK;
-                       tmp = get_stack_long(child, EFL_OFFSET); 
-                       tmp &= ~FLAG_MASK; 
-                       value |= tmp;
-                       break;
-               case offsetof(struct user_regs_struct,cs): 
-                       if ((value & 3) != 3)
-                               return -EIO;
-                       value &= 0xffff;
-                       break;
-       }
-       put_stack_long(child, regno - sizeof(struct pt_regs), value);
-       return 0;
-}
-
-static unsigned long getreg(struct task_struct *child, unsigned long regno)
-{
-       unsigned long val;
-       switch (regno) {
-               case offsetof(struct user_regs_struct, fs):
-                       return child->thread.fsindex;
-               case offsetof(struct user_regs_struct, gs):
-                       return child->thread.gsindex;
-               case offsetof(struct user_regs_struct, ds):
-                       return child->thread.ds;
-               case offsetof(struct user_regs_struct, es):
-                       return child->thread.es; 
-               case offsetof(struct user_regs_struct, fs_base):
-                       return child->thread.fs;
-               case offsetof(struct user_regs_struct, gs_base):
-                       return child->thread.gs;
-               default:
-                       regno = regno - sizeof(struct pt_regs);
-                       val = get_stack_long(child, regno);
-                       if (test_tsk_thread_flag(child, TIF_IA32))
-                               val &= 0xffffffff;
-                       return val;
-       }
-
-}
-
-long arch_ptrace(struct task_struct *child, long request, long addr, long data)
-{
-       long i, ret;
-       unsigned ui;
-
-       switch (request) {
-       /* when I and D space are separate, these will need to be fixed. */
-       case PTRACE_PEEKTEXT: /* read word at location addr. */ 
-       case PTRACE_PEEKDATA:
-               ret = generic_ptrace_peekdata(child, addr, data);
-               break;
-
-       /* read the word at location addr in the USER area. */
-       case PTRACE_PEEKUSR: {
-               unsigned long tmp;
-
-               ret = -EIO;
-               if ((addr & 7) ||
-                   addr > sizeof(struct user) - 7)
-                       break;
-
-               switch (addr) { 
-               case 0 ... sizeof(struct user_regs_struct) - sizeof(long):
-                       tmp = getreg(child, addr);
-                       break;
-               case offsetof(struct user, u_debugreg[0]):
-                       tmp = child->thread.debugreg0;
-                       break;
-               case offsetof(struct user, u_debugreg[1]):
-                       tmp = child->thread.debugreg1;
-                       break;
-               case offsetof(struct user, u_debugreg[2]):
-                       tmp = child->thread.debugreg2;
-                       break;
-               case offsetof(struct user, u_debugreg[3]):
-                       tmp = child->thread.debugreg3;
-                       break;
-               case offsetof(struct user, u_debugreg[6]):
-                       tmp = child->thread.debugreg6;
-                       break;
-               case offsetof(struct user, u_debugreg[7]):
-                       tmp = child->thread.debugreg7;
-                       break;
-               default:
-                       tmp = 0;
-                       break;
-               }
-               ret = put_user(tmp,(unsigned long __user *) data);
-               break;
-       }
-
-       /* when I and D space are separate, this will have to be fixed. */
-       case PTRACE_POKETEXT: /* write the word at location addr. */
-       case PTRACE_POKEDATA:
-               ret = generic_ptrace_pokedata(child, addr, data);
-               break;
-
-       case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
-       {
-               int dsize = test_tsk_thread_flag(child, TIF_IA32) ? 3 : 7;
-               ret = -EIO;
-               if ((addr & 7) ||
-                   addr > sizeof(struct user) - 7)
-                       break;
-
-               switch (addr) { 
-               case 0 ... sizeof(struct user_regs_struct) - sizeof(long):
-                       ret = putreg(child, addr, data);
-                       break;
-               /* Disallows to set a breakpoint into the vsyscall */
-               case offsetof(struct user, u_debugreg[0]):
-                       if (data >= TASK_SIZE_OF(child) - dsize) break;
-                       child->thread.debugreg0 = data;
-                       ret = 0;
-                       break;
-               case offsetof(struct user, u_debugreg[1]):
-                       if (data >= TASK_SIZE_OF(child) - dsize) break;
-                       child->thread.debugreg1 = data;
-                       ret = 0;
-                       break;
-               case offsetof(struct user, u_debugreg[2]):
-                       if (data >= TASK_SIZE_OF(child) - dsize) break;
-                       child->thread.debugreg2 = data;
-                       ret = 0;
-                       break;
-               case offsetof(struct user, u_debugreg[3]):
-                       if (data >= TASK_SIZE_OF(child) - dsize) break;
-                       child->thread.debugreg3 = data;
-                       ret = 0;
-                       break;
-               case offsetof(struct user, u_debugreg[6]):
-                                 if (data >> 32)
-                               break; 
-                       child->thread.debugreg6 = data;
-                       ret = 0;
-                       break;
-               case offsetof(struct user, u_debugreg[7]):
-                       /* See arch/i386/kernel/ptrace.c for an explanation of
-                        * this awkward check.*/
-                       data &= ~DR_CONTROL_RESERVED;
-                       for(i=0; i<4; i++)
-                               if ((0x5554 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
-                                       break;
-                       if (i == 4) {
-                         child->thread.debugreg7 = data;
-                         if (data)
-                               set_tsk_thread_flag(child, TIF_DEBUG);
-                         else
-                               clear_tsk_thread_flag(child, TIF_DEBUG);
-                         ret = 0;
-                       }
-                 break;
-               }
-               break;
-       }
-       case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
-       case PTRACE_CONT:    /* restart after signal. */
-
-               ret = -EIO;
-               if (!valid_signal(data))
-                       break;
-               if (request == PTRACE_SYSCALL)
-                       set_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
-               else
-                       clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
-               clear_tsk_thread_flag(child, TIF_SINGLESTEP);
-               child->exit_code = data;
-               /* make sure the single step bit is not set. */
-               clear_singlestep(child);
-               wake_up_process(child);
-               ret = 0;
-               break;
-
-#ifdef CONFIG_IA32_EMULATION
-               /* This makes only sense with 32bit programs. Allow a
-                  64bit debugger to fully examine them too. Better
-                  don't use it against 64bit processes, use
-                  PTRACE_ARCH_PRCTL instead. */
-       case PTRACE_SET_THREAD_AREA: {
-               struct user_desc __user *p;
-               int old; 
-               p = (struct user_desc __user *)data;
-               get_user(old,  &p->entry_number); 
-               put_user(addr, &p->entry_number);
-               ret = do_set_thread_area(&child->thread, p);
-               put_user(old,  &p->entry_number); 
-               break;
-       case PTRACE_GET_THREAD_AREA:
-               p = (struct user_desc __user *)data;
-               get_user(old,  &p->entry_number); 
-               put_user(addr, &p->entry_number);
-               ret = do_get_thread_area(&child->thread, p);
-               put_user(old,  &p->entry_number); 
-               break;
-       } 
-#endif
-               /* normal 64bit interface to access TLS data. 
-                  Works just like arch_prctl, except that the arguments
-                  are reversed. */
-       case PTRACE_ARCH_PRCTL: 
-               ret = do_arch_prctl(child, data, addr);
-               break;
-
-/*
- * make the child exit.  Best I can do is send it a sigkill. 
- * perhaps it should be put in the status that it wants to 
- * exit.
- */
-       case PTRACE_KILL:
-               ret = 0;
-               if (child->exit_state == EXIT_ZOMBIE)   /* already dead */
-                       break;
-               clear_tsk_thread_flag(child, TIF_SINGLESTEP);
-               child->exit_code = SIGKILL;
-               /* make sure the single step bit is not set. */
-               clear_singlestep(child);
-               wake_up_process(child);
-               break;
-
-       case PTRACE_SINGLESTEP:    /* set the trap flag. */
-               ret = -EIO;
-               if (!valid_signal(data))
-                       break;
-               clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
-               set_singlestep(child);
-               child->exit_code = data;
-               /* give it a chance to run. */
-               wake_up_process(child);
-               ret = 0;
-               break;
-
-       case PTRACE_DETACH:
-               /* detach a process that was attached. */
-               ret = ptrace_detach(child, data);
-               break;
-
-       case PTRACE_GETREGS: { /* Get all gp regs from the child. */
-               if (!access_ok(VERIFY_WRITE, (unsigned __user *)data,
-                              sizeof(struct user_regs_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               for (ui = 0; ui < sizeof(struct user_regs_struct); ui += sizeof(long)) {
-                       ret |= __put_user(getreg(child, ui),(unsigned long __user *) data);
-                       data += sizeof(long);
-               }
-               break;
-       }
-
-       case PTRACE_SETREGS: { /* Set all gp regs in the child. */
-               unsigned long tmp;
-               if (!access_ok(VERIFY_READ, (unsigned __user *)data,
-                              sizeof(struct user_regs_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               for (ui = 0; ui < sizeof(struct user_regs_struct); ui += sizeof(long)) {
-                       ret = __get_user(tmp, (unsigned long __user *) data);
-                       if (ret)
-                               break;
-                       ret = putreg(child, ui, tmp);
-                       if (ret)
-                               break;
-                       data += sizeof(long);
-               }
-               break;
-       }
-
-       case PTRACE_GETFPREGS: { /* Get the child extended FPU state. */
-               if (!access_ok(VERIFY_WRITE, (unsigned __user *)data,
-                              sizeof(struct user_i387_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = get_fpregs((struct user_i387_struct __user *)data, child);
-               break;
-       }
-
-       case PTRACE_SETFPREGS: { /* Set the child extended FPU state. */
-               if (!access_ok(VERIFY_READ, (unsigned __user *)data,
-                              sizeof(struct user_i387_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               set_stopped_child_used_math(child);
-               ret = set_fpregs(child, (struct user_i387_struct __user *)data);
-               break;
-       }
-
-       default:
-               ret = ptrace_request(child, request, addr, data);
-               break;
-       }
-       return ret;
-}
-
-static void syscall_trace(struct pt_regs *regs)
-{
-
-#if 0
-       printk("trace %s rip %lx rsp %lx rax %d origrax %d caller %lx tiflags %x ptrace %x\n",
-              current->comm,
-              regs->rip, regs->rsp, regs->rax, regs->orig_rax, __builtin_return_address(0),
-              current_thread_info()->flags, current->ptrace); 
-#endif
-
-       ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
-                               ? 0x80 : 0));
-       /*
-        * this isn't the same as continuing with a signal, but it will do
-        * for normal use.  strace only continues with a signal if the
-        * stopping signal is not SIGTRAP.  -brl
-        */
-       if (current->exit_code) {
-               send_sig(current->exit_code, current, 1);
-               current->exit_code = 0;
-       }
-}
-
-asmlinkage void syscall_trace_enter(struct pt_regs *regs)
-{
-       /* do the secure computing check first */
-       secure_computing(regs->orig_rax);
-
-       if (test_thread_flag(TIF_SYSCALL_TRACE)
-           && (current->ptrace & PT_PTRACED))
-               syscall_trace(regs);
-
-       if (unlikely(current->audit_context)) {
-               if (test_thread_flag(TIF_IA32)) {
-                       audit_syscall_entry(AUDIT_ARCH_I386,
-                                           regs->orig_rax,
-                                           regs->rbx, regs->rcx,
-                                           regs->rdx, regs->rsi);
-               } else {
-                       audit_syscall_entry(AUDIT_ARCH_X86_64,
-                                           regs->orig_rax,
-                                           regs->rdi, regs->rsi,
-                                           regs->rdx, regs->r10);
-               }
-       }
-}
-
-asmlinkage void syscall_trace_leave(struct pt_regs *regs)
-{
-       if (unlikely(current->audit_context))
-               audit_syscall_exit(AUDITSC_RESULT(regs->rax), regs->rax);
-
-       if ((test_thread_flag(TIF_SYSCALL_TRACE)
-            || test_thread_flag(TIF_SINGLESTEP))
-           && (current->ptrace & PT_PTRACED))
-               syscall_trace(regs);
-}
diff --git a/arch/x86_64/kernel/reboot.c b/arch/x86_64/kernel/reboot.c
deleted file mode 100644 (file)
index 368db2b..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* Various gunk just to reboot the machine. */ 
-#include <linux/module.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/string.h>
-#include <linux/pm.h>
-#include <linux/kdebug.h>
-#include <linux/sched.h>
-#include <asm/io.h>
-#include <asm/delay.h>
-#include <asm/hw_irq.h>
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/tlbflush.h>
-#include <asm/apic.h>
-#include <asm/iommu.h>
-
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
-static long no_idt[3];
-static enum { 
-       BOOT_TRIPLE = 't',
-       BOOT_KBD = 'k'
-} reboot_type = BOOT_KBD;
-static int reboot_mode = 0;
-int reboot_force;
-
-/* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
-   warm   Don't set the cold reboot flag
-   cold   Set the cold reboot flag
-   triple Force a triple fault (init)
-   kbd    Use the keyboard controller. cold reset (default)
-   force  Avoid anything that could hang.
- */ 
-static int __init reboot_setup(char *str)
-{
-       for (;;) {
-               switch (*str) {
-               case 'w': 
-                       reboot_mode = 0x1234;
-                       break;
-
-               case 'c':
-                       reboot_mode = 0;
-                       break;
-
-               case 't':
-               case 'b':
-               case 'k':
-                       reboot_type = *str;
-                       break;
-               case 'f':
-                       reboot_force = 1;
-                       break;
-               }
-               if((str = strchr(str,',')) != NULL)
-                       str++;
-               else
-                       break;
-       }
-       return 1;
-}
-
-__setup("reboot=", reboot_setup);
-
-static inline void kb_wait(void)
-{
-       int i;
-
-       for (i=0; i<0x10000; i++)
-               if ((inb_p(0x64) & 0x02) == 0)
-                       break;
-}
-
-void machine_shutdown(void)
-{
-       unsigned long flags;
-
-       /* Stop the cpus and apics */
-#ifdef CONFIG_SMP
-       int reboot_cpu_id;
-
-       /* The boot cpu is always logical cpu 0 */
-       reboot_cpu_id = 0;
-
-       /* Make certain the cpu I'm about to reboot on is online */
-       if (!cpu_isset(reboot_cpu_id, cpu_online_map)) {
-               reboot_cpu_id = smp_processor_id();
-       }
-
-       /* Make certain I only run on the appropriate processor */
-       set_cpus_allowed(current, cpumask_of_cpu(reboot_cpu_id));
-
-       /* O.K Now that I'm on the appropriate processor,
-        * stop all of the others.
-        */
-       smp_send_stop();
-#endif
-
-       local_irq_save(flags);
-
-#ifndef CONFIG_SMP
-       disable_local_APIC();
-#endif
-
-       disable_IO_APIC();
-
-       local_irq_restore(flags);
-
-       pci_iommu_shutdown();
-}
-
-void machine_emergency_restart(void)
-{
-       int i;
-
-       /* Tell the BIOS if we want cold or warm reboot */
-       *((unsigned short *)__va(0x472)) = reboot_mode;
-       
-       for (;;) {
-               /* Could also try the reset bit in the Hammer NB */
-               switch (reboot_type) { 
-               case BOOT_KBD:
-               for (i=0; i<10; i++) {
-                       kb_wait();
-                       udelay(50);
-                       outb(0xfe,0x64);         /* pulse reset low */
-                       udelay(50);
-               }
-
-               case BOOT_TRIPLE: 
-                       __asm__ __volatile__("lidt (%0)": :"r" (&no_idt));
-                       __asm__ __volatile__("int3");
-
-                       reboot_type = BOOT_KBD;
-                       break;
-               }      
-       }      
-}
-
-void machine_restart(char * __unused)
-{
-       printk("machine restart\n");
-
-       if (!reboot_force) {
-               machine_shutdown();
-       }
-       machine_emergency_restart();
-}
-
-void machine_halt(void)
-{
-}
-
-void machine_power_off(void)
-{
-       if (pm_power_off) {
-               if (!reboot_force) {
-                       machine_shutdown();
-               }
-               pm_power_off();
-       }
-}
-
diff --git a/arch/x86_64/kernel/relocate_kernel.S b/arch/x86_64/kernel/relocate_kernel.S
deleted file mode 100644 (file)
index 14e9587..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * relocate_kernel.S - put the kernel image in place to boot
- * Copyright (C) 2002-2005 Eric Biederman  <ebiederm@xmission.com>
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2.  See the file COPYING for more details.
- */
-
-#include <linux/linkage.h>
-#include <asm/page.h>
-#include <asm/kexec.h>
-
-/*
- * Must be relocatable PIC code callable as a C function
- */
-
-#define PTR(x) (x << 3)
-#define PAGE_ALIGNED (1 << PAGE_SHIFT)
-#define PAGE_ATTR 0x63 /* _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY */
-
-       .text
-       .align PAGE_ALIGNED
-       .code64
-       .globl relocate_kernel
-relocate_kernel:
-       /* %rdi indirection_page
-        * %rsi page_list
-        * %rdx start address
-        */
-
-       /* map the control page at its virtual address */
-
-       movq    $0x0000ff8000000000, %r10        /* mask */
-       mov     $(39 - 3), %cl                   /* bits to shift */
-       movq    PTR(VA_CONTROL_PAGE)(%rsi), %r11 /* address to map */
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PGD)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PUD_0)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PUD_0)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PMD_0)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PMD_0)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PTE_0)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PTE_0)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_CONTROL_PAGE)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       /* identity map the control page at its physical address */
-
-       movq    $0x0000ff8000000000, %r10        /* mask */
-       mov     $(39 - 3), %cl                   /* bits to shift */
-       movq    PTR(PA_CONTROL_PAGE)(%rsi), %r11 /* address to map */
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PGD)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PUD_1)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PUD_1)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PMD_1)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PMD_1)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_PTE_1)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-       shrq    $9, %r10
-       sub     $9, %cl
-
-       movq    %r11, %r9
-       andq    %r10, %r9
-       shrq    %cl, %r9
-
-       movq    PTR(VA_PTE_1)(%rsi), %r8
-       addq    %r8, %r9
-       movq    PTR(PA_CONTROL_PAGE)(%rsi), %r8
-       orq     $PAGE_ATTR, %r8
-       movq    %r8, (%r9)
-
-relocate_new_kernel:
-       /* %rdi indirection_page
-        * %rsi page_list
-        * %rdx start address
-        */
-
-       /* zero out flags, and disable interrupts */
-       pushq $0
-       popfq
-
-       /* get physical address of control page now */
-       /* this is impossible after page table switch */
-       movq    PTR(PA_CONTROL_PAGE)(%rsi), %r8
-
-       /* get physical address of page table now too */
-       movq    PTR(PA_TABLE_PAGE)(%rsi), %rcx
-
-       /* switch to new set of page tables */
-       movq    PTR(PA_PGD)(%rsi), %r9
-       movq    %r9, %cr3
-
-       /* setup a new stack at the end of the physical control page */
-       lea     4096(%r8), %rsp
-
-       /* jump to identity mapped page */
-       addq    $(identity_mapped - relocate_kernel), %r8
-       pushq   %r8
-       ret
-
-identity_mapped:
-       /* store the start address on the stack */
-       pushq   %rdx
-
-       /* Set cr0 to a known state:
-        * 31 1 == Paging enabled
-        * 18 0 == Alignment check disabled
-        * 16 0 == Write protect disabled
-        * 3  0 == No task switch
-        * 2  0 == Don't do FP software emulation.
-        * 0  1 == Proctected mode enabled
-        */
-       movq    %cr0, %rax
-       andq    $~((1<<18)|(1<<16)|(1<<3)|(1<<2)), %rax
-       orl     $((1<<31)|(1<<0)), %eax
-       movq    %rax, %cr0
-
-       /* Set cr4 to a known state:
-        * 10 0 == xmm exceptions disabled
-        * 9  0 == xmm registers instructions disabled
-        * 8  0 == performance monitoring counter disabled
-        * 7  0 == page global disabled
-        * 6  0 == machine check exceptions disabled
-        * 5  1 == physical address extension enabled
-        * 4  0 == page size extensions disabled
-        * 3  0 == Debug extensions disabled
-        * 2  0 == Time stamp disable (disabled)
-        * 1  0 == Protected mode virtual interrupts disabled
-        * 0  0 == VME disabled
-        */
-
-       movq    $((1<<5)), %rax
-       movq    %rax, %cr4
-
-       jmp 1f
-1:
-
-       /* Switch to the identity mapped page tables,
-        * and flush the TLB.
-       */
-       movq    %rcx, %cr3
-
-       /* Do the copies */
-       movq    %rdi, %rcx      /* Put the page_list in %rcx */
-       xorq    %rdi, %rdi
-       xorq    %rsi, %rsi
-       jmp     1f
-
-0:     /* top, read another word for the indirection page */
-
-       movq    (%rbx), %rcx
-       addq    $8,     %rbx
-1:
-       testq   $0x1,   %rcx  /* is it a destination page? */
-       jz      2f
-       movq    %rcx,   %rdi
-       andq    $0xfffffffffffff000, %rdi
-       jmp     0b
-2:
-       testq   $0x2,   %rcx  /* is it an indirection page? */
-       jz      2f
-       movq    %rcx,   %rbx
-       andq    $0xfffffffffffff000, %rbx
-       jmp     0b
-2:
-       testq   $0x4,   %rcx  /* is it the done indicator? */
-       jz      2f
-       jmp     3f
-2:
-       testq   $0x8,   %rcx  /* is it the source indicator? */
-       jz      0b            /* Ignore it otherwise */
-       movq    %rcx,   %rsi  /* For ever source page do a copy */
-       andq    $0xfffffffffffff000, %rsi
-
-       movq    $512,   %rcx
-       rep ; movsq
-       jmp     0b
-3:
-
-       /* To be certain of avoiding problems with self-modifying code
-        * I need to execute a serializing instruction here.
-        * So I flush the TLB by reloading %cr3 here, it's handy,
-        * and not processor dependent.
-        */
-       movq    %cr3, %rax
-       movq    %rax, %cr3
-
-       /* set all of the registers to known values */
-       /* leave %rsp alone */
-
-       xorq    %rax, %rax
-       xorq    %rbx, %rbx
-       xorq    %rcx, %rcx
-       xorq    %rdx, %rdx
-       xorq    %rsi, %rsi
-       xorq    %rdi, %rdi
-       xorq    %rbp, %rbp
-       xorq    %r8,  %r8
-       xorq    %r9,  %r9
-       xorq    %r10, %r9
-       xorq    %r11, %r11
-       xorq    %r12, %r12
-       xorq    %r13, %r13
-       xorq    %r14, %r14
-       xorq    %r15, %r15
-
-       ret
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
deleted file mode 100644 (file)
index af838f6..0000000
+++ /dev/null
@@ -1,1117 +0,0 @@
-/*
- *  linux/arch/x86-64/kernel/setup.c
- *
- *  Copyright (C) 1995  Linus Torvalds
- *
- *  Nov 2001 Dave Jones <davej@suse.de>
- *  Forked from i386 setup code.
- */
-
-/*
- * This file handles the architecture-dependent parts of initialization
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/stddef.h>
-#include <linux/unistd.h>
-#include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/user.h>
-#include <linux/a.out.h>
-#include <linux/screen_info.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/init.h>
-#include <linux/initrd.h>
-#include <linux/highmem.h>
-#include <linux/bootmem.h>
-#include <linux/module.h>
-#include <asm/processor.h>
-#include <linux/console.h>
-#include <linux/seq_file.h>
-#include <linux/crash_dump.h>
-#include <linux/root_dev.h>
-#include <linux/pci.h>
-#include <linux/acpi.h>
-#include <linux/kallsyms.h>
-#include <linux/edd.h>
-#include <linux/mmzone.h>
-#include <linux/kexec.h>
-#include <linux/cpufreq.h>
-#include <linux/dmi.h>
-#include <linux/dma-mapping.h>
-#include <linux/ctype.h>
-
-#include <asm/mtrr.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/smp.h>
-#include <asm/msr.h>
-#include <asm/desc.h>
-#include <video/edid.h>
-#include <asm/e820.h>
-#include <asm/dma.h>
-#include <asm/mpspec.h>
-#include <asm/mmu_context.h>
-#include <asm/bootsetup.h>
-#include <asm/proto.h>
-#include <asm/setup.h>
-#include <asm/mach_apic.h>
-#include <asm/numa.h>
-#include <asm/sections.h>
-#include <asm/dmi.h>
-
-/*
- * Machine setup..
- */
-
-struct cpuinfo_x86 boot_cpu_data __read_mostly;
-EXPORT_SYMBOL(boot_cpu_data);
-
-unsigned long mmu_cr4_features;
-
-/* Boot loader ID as an integer, for the benefit of proc_dointvec */
-int bootloader_type;
-
-unsigned long saved_video_mode;
-
-int force_mwait __cpuinitdata;
-
-/* 
- * Early DMI memory
- */
-int dmi_alloc_index;
-char dmi_alloc_data[DMI_MAX_DATA];
-
-/*
- * Setup options
- */
-struct screen_info screen_info;
-EXPORT_SYMBOL(screen_info);
-struct sys_desc_table_struct {
-       unsigned short length;
-       unsigned char table[0];
-};
-
-struct edid_info edid_info;
-EXPORT_SYMBOL_GPL(edid_info);
-
-extern int root_mountflags;
-
-char __initdata command_line[COMMAND_LINE_SIZE];
-
-struct resource standard_io_resources[] = {
-       { .name = "dma1", .start = 0x00, .end = 0x1f,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "pic1", .start = 0x20, .end = 0x21,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "timer0", .start = 0x40, .end = 0x43,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "timer1", .start = 0x50, .end = 0x53,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "keyboard", .start = 0x60, .end = 0x6f,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "dma page reg", .start = 0x80, .end = 0x8f,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "pic2", .start = 0xa0, .end = 0xa1,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "dma2", .start = 0xc0, .end = 0xdf,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO },
-       { .name = "fpu", .start = 0xf0, .end = 0xff,
-               .flags = IORESOURCE_BUSY | IORESOURCE_IO }
-};
-
-#define IORESOURCE_RAM (IORESOURCE_BUSY | IORESOURCE_MEM)
-
-struct resource data_resource = {
-       .name = "Kernel data",
-       .start = 0,
-       .end = 0,
-       .flags = IORESOURCE_RAM,
-};
-struct resource code_resource = {
-       .name = "Kernel code",
-       .start = 0,
-       .end = 0,
-       .flags = IORESOURCE_RAM,
-};
-
-#ifdef CONFIG_PROC_VMCORE
-/* elfcorehdr= specifies the location of elf core header
- * stored by the crashed kernel. This option will be passed
- * by kexec loader to the capture kernel.
- */
-static int __init setup_elfcorehdr(char *arg)
-{
-       char *end;
-       if (!arg)
-               return -EINVAL;
-       elfcorehdr_addr = memparse(arg, &end);
-       return end > arg ? 0 : -EINVAL;
-}
-early_param("elfcorehdr", setup_elfcorehdr);
-#endif
-
-#ifndef CONFIG_NUMA
-static void __init
-contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
-{
-       unsigned long bootmap_size, bootmap;
-
-       bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
-       bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
-       if (bootmap == -1L)
-               panic("Cannot find bootmem map of size %ld\n",bootmap_size);
-       bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
-       e820_register_active_regions(0, start_pfn, end_pfn);
-       free_bootmem_with_active_regions(0, end_pfn);
-       reserve_bootmem(bootmap, bootmap_size);
-} 
-#endif
-
-#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-struct edd edd;
-#ifdef CONFIG_EDD_MODULE
-EXPORT_SYMBOL(edd);
-#endif
-/**
- * copy_edd() - Copy the BIOS EDD information
- *              from boot_params into a safe place.
- *
- */
-static inline void copy_edd(void)
-{
-     memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
-     memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
-     edd.mbr_signature_nr = EDD_MBR_SIG_NR;
-     edd.edd_info_nr = EDD_NR;
-}
-#else
-static inline void copy_edd(void)
-{
-}
-#endif
-
-#define EBDA_ADDR_POINTER 0x40E
-
-unsigned __initdata ebda_addr;
-unsigned __initdata ebda_size;
-
-static void discover_ebda(void)
-{
-       /*
-        * there is a real-mode segmented pointer pointing to the 
-        * 4K EBDA area at 0x40E
-        */
-       ebda_addr = *(unsigned short *)__va(EBDA_ADDR_POINTER);
-       ebda_addr <<= 4;
-
-       ebda_size = *(unsigned short *)__va(ebda_addr);
-
-       /* Round EBDA up to pages */
-       if (ebda_size == 0)
-               ebda_size = 1;
-       ebda_size <<= 10;
-       ebda_size = round_up(ebda_size + (ebda_addr & ~PAGE_MASK), PAGE_SIZE);
-       if (ebda_size > 64*1024)
-               ebda_size = 64*1024;
-}
-
-void __init setup_arch(char **cmdline_p)
-{
-       printk(KERN_INFO "Command line: %s\n", boot_command_line);
-
-       ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
-       screen_info = SCREEN_INFO;
-       edid_info = EDID_INFO;
-       saved_video_mode = SAVED_VIDEO_MODE;
-       bootloader_type = LOADER_TYPE;
-
-#ifdef CONFIG_BLK_DEV_RAM
-       rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
-       rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
-       rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
-#endif
-       setup_memory_region();
-       copy_edd();
-
-       if (!MOUNT_ROOT_RDONLY)
-               root_mountflags &= ~MS_RDONLY;
-       init_mm.start_code = (unsigned long) &_text;
-       init_mm.end_code = (unsigned long) &_etext;
-       init_mm.end_data = (unsigned long) &_edata;
-       init_mm.brk = (unsigned long) &_end;
-
-       code_resource.start = virt_to_phys(&_text);
-       code_resource.end = virt_to_phys(&_etext)-1;
-       data_resource.start = virt_to_phys(&_etext);
-       data_resource.end = virt_to_phys(&_edata)-1;
-
-       early_identify_cpu(&boot_cpu_data);
-
-       strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
-       *cmdline_p = command_line;
-
-       parse_early_param();
-
-       finish_e820_parsing();
-
-       e820_register_active_regions(0, 0, -1UL);
-       /*
-        * partially used pages are not usable - thus
-        * we are rounding upwards:
-        */
-       end_pfn = e820_end_of_ram();
-       num_physpages = end_pfn;
-
-       check_efer();
-
-       discover_ebda();
-
-       init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
-
-       dmi_scan_machine();
-
-#ifdef CONFIG_ACPI
-       /*
-        * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
-        * Call this early for SRAT node setup.
-        */
-       acpi_boot_table_init();
-#endif
-
-       /* How many end-of-memory variables you have, grandma! */
-       max_low_pfn = end_pfn;
-       max_pfn = end_pfn;
-       high_memory = (void *)__va(end_pfn * PAGE_SIZE - 1) + 1;
-
-       /* Remove active ranges so rediscovery with NUMA-awareness happens */
-       remove_all_active_ranges();
-
-#ifdef CONFIG_ACPI_NUMA
-       /*
-        * Parse SRAT to discover nodes.
-        */
-       acpi_numa_init();
-#endif
-
-#ifdef CONFIG_NUMA
-       numa_initmem_init(0, end_pfn); 
-#else
-       contig_initmem_init(0, end_pfn);
-#endif
-
-       /* Reserve direct mapping */
-       reserve_bootmem_generic(table_start << PAGE_SHIFT, 
-                               (table_end - table_start) << PAGE_SHIFT);
-
-       /* reserve kernel */
-       reserve_bootmem_generic(__pa_symbol(&_text),
-                               __pa_symbol(&_end) - __pa_symbol(&_text));
-
-       /*
-        * reserve physical page 0 - it's a special BIOS page on many boxes,
-        * enabling clean reboots, SMP operation, laptop functions.
-        */
-       reserve_bootmem_generic(0, PAGE_SIZE);
-
-       /* reserve ebda region */
-       if (ebda_addr)
-               reserve_bootmem_generic(ebda_addr, ebda_size);
-#ifdef CONFIG_NUMA
-       /* reserve nodemap region */
-       if (nodemap_addr)
-               reserve_bootmem_generic(nodemap_addr, nodemap_size);
-#endif
-
-#ifdef CONFIG_SMP
-       /* Reserve SMP trampoline */
-       reserve_bootmem_generic(SMP_TRAMPOLINE_BASE, 2*PAGE_SIZE);
-#endif
-
-#ifdef CONFIG_ACPI_SLEEP
-       /*
-        * Reserve low memory region for sleep support.
-        */
-       acpi_reserve_bootmem();
-#endif
-       /*
-        * Find and reserve possible boot-time SMP configuration:
-        */
-       find_smp_config();
-#ifdef CONFIG_BLK_DEV_INITRD
-       if (LOADER_TYPE && INITRD_START) {
-               if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
-                       reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
-                       initrd_start = INITRD_START + PAGE_OFFSET;
-                       initrd_end = initrd_start+INITRD_SIZE;
-               }
-               else {
-                       printk(KERN_ERR "initrd extends beyond end of memory "
-                           "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-                           (unsigned long)(INITRD_START + INITRD_SIZE),
-                           (unsigned long)(end_pfn << PAGE_SHIFT));
-                       initrd_start = 0;
-               }
-       }
-#endif
-#ifdef CONFIG_KEXEC
-       if (crashk_res.start != crashk_res.end) {
-               reserve_bootmem_generic(crashk_res.start,
-                       crashk_res.end - crashk_res.start + 1);
-       }
-#endif
-
-       paging_init();
-
-#ifdef CONFIG_PCI
-       early_quirks();
-#endif
-
-       /*
-        * set this early, so we dont allocate cpu0
-        * if MADT list doesnt list BSP first
-        * mpparse.c/MP_processor_info() allocates logical cpu numbers.
-        */
-       cpu_set(0, cpu_present_map);
-#ifdef CONFIG_ACPI
-       /*
-        * Read APIC and some other early information from ACPI tables.
-        */
-       acpi_boot_init();
-#endif
-
-       init_cpu_to_node();
-
-       /*
-        * get boot-time SMP configuration:
-        */
-       if (smp_found_config)
-               get_smp_config();
-       init_apic_mappings();
-
-       /*
-        * We trust e820 completely. No explicit ROM probing in memory.
-        */
-       e820_reserve_resources(); 
-       e820_mark_nosave_regions();
-
-       {
-       unsigned i;
-       /* request I/O space for devices used on all i[345]86 PCs */
-       for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
-               request_resource(&ioport_resource, &standard_io_resources[i]);
-       }
-
-       e820_setup_gap();
-
-#ifdef CONFIG_VT
-#if defined(CONFIG_VGA_CONSOLE)
-       conswitchp = &vga_con;
-#elif defined(CONFIG_DUMMY_CONSOLE)
-       conswitchp = &dummy_con;
-#endif
-#endif
-}
-
-static int __cpuinit get_model_name(struct cpuinfo_x86 *c)
-{
-       unsigned int *v;
-
-       if (c->extended_cpuid_level < 0x80000004)
-               return 0;
-
-       v = (unsigned int *) c->x86_model_id;
-       cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
-       cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
-       cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
-       c->x86_model_id[48] = 0;
-       return 1;
-}
-
-
-static void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
-{
-       unsigned int n, dummy, eax, ebx, ecx, edx;
-
-       n = c->extended_cpuid_level;
-
-       if (n >= 0x80000005) {
-               cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
-               printk(KERN_INFO "CPU: L1 I Cache: %dK (%d bytes/line), D cache %dK (%d bytes/line)\n",
-                       edx>>24, edx&0xFF, ecx>>24, ecx&0xFF);
-               c->x86_cache_size=(ecx>>24)+(edx>>24);
-               /* On K8 L1 TLB is inclusive, so don't count it */
-               c->x86_tlbsize = 0;
-       }
-
-       if (n >= 0x80000006) {
-               cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
-               ecx = cpuid_ecx(0x80000006);
-               c->x86_cache_size = ecx >> 16;
-               c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
-
-               printk(KERN_INFO "CPU: L2 Cache: %dK (%d bytes/line)\n",
-               c->x86_cache_size, ecx & 0xFF);
-       }
-
-       if (n >= 0x80000007)
-               cpuid(0x80000007, &dummy, &dummy, &dummy, &c->x86_power); 
-       if (n >= 0x80000008) {
-               cpuid(0x80000008, &eax, &dummy, &dummy, &dummy); 
-               c->x86_virt_bits = (eax >> 8) & 0xff;
-               c->x86_phys_bits = eax & 0xff;
-       }
-}
-
-#ifdef CONFIG_NUMA
-static int nearby_node(int apicid)
-{
-       int i;
-       for (i = apicid - 1; i >= 0; i--) {
-               int node = apicid_to_node[i];
-               if (node != NUMA_NO_NODE && node_online(node))
-                       return node;
-       }
-       for (i = apicid + 1; i < MAX_LOCAL_APIC; i++) {
-               int node = apicid_to_node[i];
-               if (node != NUMA_NO_NODE && node_online(node))
-                       return node;
-       }
-       return first_node(node_online_map); /* Shouldn't happen */
-}
-#endif
-
-/*
- * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
- * Assumes number of cores is a power of two.
- */
-static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
-{
-#ifdef CONFIG_SMP
-       unsigned bits;
-#ifdef CONFIG_NUMA
-       int cpu = smp_processor_id();
-       int node = 0;
-       unsigned apicid = hard_smp_processor_id();
-#endif
-       unsigned ecx = cpuid_ecx(0x80000008);
-
-       c->x86_max_cores = (ecx & 0xff) + 1;
-
-       /* CPU telling us the core id bits shift? */
-       bits = (ecx >> 12) & 0xF;
-
-       /* Otherwise recompute */
-       if (bits == 0) {
-               while ((1 << bits) < c->x86_max_cores)
-                       bits++;
-       }
-
-       /* Low order bits define the core id (index of core in socket) */
-       c->cpu_core_id = c->phys_proc_id & ((1 << bits)-1);
-       /* Convert the APIC ID into the socket ID */
-       c->phys_proc_id = phys_pkg_id(bits);
-
-#ifdef CONFIG_NUMA
-       node = c->phys_proc_id;
-       if (apicid_to_node[apicid] != NUMA_NO_NODE)
-               node = apicid_to_node[apicid];
-       if (!node_online(node)) {
-               /* Two possibilities here:
-                  - The CPU is missing memory and no node was created.
-                  In that case try picking one from a nearby CPU
-                  - The APIC IDs differ from the HyperTransport node IDs
-                  which the K8 northbridge parsing fills in.
-                  Assume they are all increased by a constant offset,
-                  but in the same order as the HT nodeids.
-                  If that doesn't result in a usable node fall back to the
-                  path for the previous case.  */
-               int ht_nodeid = apicid - (cpu_data[0].phys_proc_id << bits);
-               if (ht_nodeid >= 0 &&
-                   apicid_to_node[ht_nodeid] != NUMA_NO_NODE)
-                       node = apicid_to_node[ht_nodeid];
-               /* Pick a nearby node */
-               if (!node_online(node))
-                       node = nearby_node(apicid);
-       }
-       numa_set_node(cpu, node);
-
-       printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
-#endif
-#endif
-}
-
-static void __cpuinit init_amd(struct cpuinfo_x86 *c)
-{
-       unsigned level;
-
-#ifdef CONFIG_SMP
-       unsigned long value;
-
-       /*
-        * Disable TLB flush filter by setting HWCR.FFDIS on K8
-        * bit 6 of msr C001_0015
-        *
-        * Errata 63 for SH-B3 steppings
-        * Errata 122 for all steppings (F+ have it disabled by default)
-        */
-       if (c->x86 == 15) {
-               rdmsrl(MSR_K8_HWCR, value);
-               value |= 1 << 6;
-               wrmsrl(MSR_K8_HWCR, value);
-       }
-#endif
-
-       /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
-          3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
-       clear_bit(0*32+31, &c->x86_capability);
-       
-       /* On C+ stepping K8 rep microcode works well for copy/memset */
-       level = cpuid_eax(1);
-       if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
-               set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
-       if (c->x86 == 0x10)
-               set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
-
-       /* Enable workaround for FXSAVE leak */
-       if (c->x86 >= 6)
-               set_bit(X86_FEATURE_FXSAVE_LEAK, &c->x86_capability);
-
-       level = get_model_name(c);
-       if (!level) {
-               switch (c->x86) { 
-               case 15:
-                       /* Should distinguish Models here, but this is only
-                          a fallback anyways. */
-                       strcpy(c->x86_model_id, "Hammer");
-                       break; 
-               } 
-       } 
-       display_cacheinfo(c);
-
-       /* c->x86_power is 8000_0007 edx. Bit 8 is constant TSC */
-       if (c->x86_power & (1<<8))
-               set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
-
-       /* Multi core CPU? */
-       if (c->extended_cpuid_level >= 0x80000008)
-               amd_detect_cmp(c);
-
-       if (c->extended_cpuid_level >= 0x80000006 &&
-               (cpuid_edx(0x80000006) & 0xf000))
-               num_cache_leaves = 4;
-       else
-               num_cache_leaves = 3;
-
-       if (c->x86 == 0xf || c->x86 == 0x10 || c->x86 == 0x11)
-               set_bit(X86_FEATURE_K8, &c->x86_capability);
-
-       /* RDTSC can be speculated around */
-       clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
-
-       /* Family 10 doesn't support C states in MWAIT so don't use it */
-       if (c->x86 == 0x10 && !force_mwait)
-               clear_bit(X86_FEATURE_MWAIT, &c->x86_capability);
-}
-
-static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
-{
-#ifdef CONFIG_SMP
-       u32     eax, ebx, ecx, edx;
-       int     index_msb, core_bits;
-
-       cpuid(1, &eax, &ebx, &ecx, &edx);
-
-
-       if (!cpu_has(c, X86_FEATURE_HT))
-               return;
-       if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
-               goto out;
-
-       smp_num_siblings = (ebx & 0xff0000) >> 16;
-
-       if (smp_num_siblings == 1) {
-               printk(KERN_INFO  "CPU: Hyper-Threading is disabled\n");
-       } else if (smp_num_siblings > 1 ) {
-
-               if (smp_num_siblings > NR_CPUS) {
-                       printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
-                       smp_num_siblings = 1;
-                       return;
-               }
-
-               index_msb = get_count_order(smp_num_siblings);
-               c->phys_proc_id = phys_pkg_id(index_msb);
-
-               smp_num_siblings = smp_num_siblings / c->x86_max_cores;
-
-               index_msb = get_count_order(smp_num_siblings) ;
-
-               core_bits = get_count_order(c->x86_max_cores);
-
-               c->cpu_core_id = phys_pkg_id(index_msb) &
-                                              ((1 << core_bits) - 1);
-       }
-out:
-       if ((c->x86_max_cores * smp_num_siblings) > 1) {
-               printk(KERN_INFO  "CPU: Physical Processor ID: %d\n", c->phys_proc_id);
-               printk(KERN_INFO  "CPU: Processor Core ID: %d\n", c->cpu_core_id);
-       }
-
-#endif
-}
-
-/*
- * find out the number of processor cores on the die
- */
-static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
-{
-       unsigned int eax, t;
-
-       if (c->cpuid_level < 4)
-               return 1;
-
-       cpuid_count(4, 0, &eax, &t, &t, &t);
-
-       if (eax & 0x1f)
-               return ((eax >> 26) + 1);
-       else
-               return 1;
-}
-
-static void srat_detect_node(void)
-{
-#ifdef CONFIG_NUMA
-       unsigned node;
-       int cpu = smp_processor_id();
-       int apicid = hard_smp_processor_id();
-
-       /* Don't do the funky fallback heuristics the AMD version employs
-          for now. */
-       node = apicid_to_node[apicid];
-       if (node == NUMA_NO_NODE)
-               node = first_node(node_online_map);
-       numa_set_node(cpu, node);
-
-       printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
-#endif
-}
-
-static void __cpuinit init_intel(struct cpuinfo_x86 *c)
-{
-       /* Cache sizes */
-       unsigned n;
-
-       init_intel_cacheinfo(c);
-       if (c->cpuid_level > 9 ) {
-               unsigned eax = cpuid_eax(10);
-               /* Check for version and the number of counters */
-               if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
-                       set_bit(X86_FEATURE_ARCH_PERFMON, &c->x86_capability);
-       }
-
-       if (cpu_has_ds) {
-               unsigned int l1, l2;
-               rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
-               if (!(l1 & (1<<11)))
-                       set_bit(X86_FEATURE_BTS, c->x86_capability);
-               if (!(l1 & (1<<12)))
-                       set_bit(X86_FEATURE_PEBS, c->x86_capability);
-       }
-
-       n = c->extended_cpuid_level;
-       if (n >= 0x80000008) {
-               unsigned eax = cpuid_eax(0x80000008);
-               c->x86_virt_bits = (eax >> 8) & 0xff;
-               c->x86_phys_bits = eax & 0xff;
-               /* CPUID workaround for Intel 0F34 CPU */
-               if (c->x86_vendor == X86_VENDOR_INTEL &&
-                   c->x86 == 0xF && c->x86_model == 0x3 &&
-                   c->x86_mask == 0x4)
-                       c->x86_phys_bits = 36;
-       }
-
-       if (c->x86 == 15)
-               c->x86_cache_alignment = c->x86_clflush_size * 2;
-       if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
-           (c->x86 == 0x6 && c->x86_model >= 0x0e))
-               set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
-       if (c->x86 == 6)
-               set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
-       if (c->x86 == 15)
-               set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
-       else
-               clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
-       c->x86_max_cores = intel_num_cpu_cores(c);
-
-       srat_detect_node();
-}
-
-static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
-{
-       char *v = c->x86_vendor_id;
-
-       if (!strcmp(v, "AuthenticAMD"))
-               c->x86_vendor = X86_VENDOR_AMD;
-       else if (!strcmp(v, "GenuineIntel"))
-               c->x86_vendor = X86_VENDOR_INTEL;
-       else
-               c->x86_vendor = X86_VENDOR_UNKNOWN;
-}
-
-struct cpu_model_info {
-       int vendor;
-       int family;
-       char *model_names[16];
-};
-
-/* Do some early cpuid on the boot CPU to get some parameter that are
-   needed before check_bugs. Everything advanced is in identify_cpu
-   below. */
-void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
-{
-       u32 tfms;
-
-       c->loops_per_jiffy = loops_per_jiffy;
-       c->x86_cache_size = -1;
-       c->x86_vendor = X86_VENDOR_UNKNOWN;
-       c->x86_model = c->x86_mask = 0; /* So far unknown... */
-       c->x86_vendor_id[0] = '\0'; /* Unset */
-       c->x86_model_id[0] = '\0';  /* Unset */
-       c->x86_clflush_size = 64;
-       c->x86_cache_alignment = c->x86_clflush_size;
-       c->x86_max_cores = 1;
-       c->extended_cpuid_level = 0;
-       memset(&c->x86_capability, 0, sizeof c->x86_capability);
-
-       /* Get vendor name */
-       cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
-             (unsigned int *)&c->x86_vendor_id[0],
-             (unsigned int *)&c->x86_vendor_id[8],
-             (unsigned int *)&c->x86_vendor_id[4]);
-               
-       get_cpu_vendor(c);
-
-       /* Initialize the standard set of capabilities */
-       /* Note that the vendor-specific code below might override */
-
-       /* Intel-defined flags: level 0x00000001 */
-       if (c->cpuid_level >= 0x00000001) {
-               __u32 misc;
-               cpuid(0x00000001, &tfms, &misc, &c->x86_capability[4],
-                     &c->x86_capability[0]);
-               c->x86 = (tfms >> 8) & 0xf;
-               c->x86_model = (tfms >> 4) & 0xf;
-               c->x86_mask = tfms & 0xf;
-               if (c->x86 == 0xf)
-                       c->x86 += (tfms >> 20) & 0xff;
-               if (c->x86 >= 0x6)
-                       c->x86_model += ((tfms >> 16) & 0xF) << 4;
-               if (c->x86_capability[0] & (1<<19)) 
-                       c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
-       } else {
-               /* Have CPUID level 0 only - unheard of */
-               c->x86 = 4;
-       }
-
-#ifdef CONFIG_SMP
-       c->phys_proc_id = (cpuid_ebx(1) >> 24) & 0xff;
-#endif
-}
-
-/*
- * This does the hard work of actually picking apart the CPU stuff...
- */
-void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
-{
-       int i;
-       u32 xlvl;
-
-       early_identify_cpu(c);
-
-       /* AMD-defined flags: level 0x80000001 */
-       xlvl = cpuid_eax(0x80000000);
-       c->extended_cpuid_level = xlvl;
-       if ((xlvl & 0xffff0000) == 0x80000000) {
-               if (xlvl >= 0x80000001) {
-                       c->x86_capability[1] = cpuid_edx(0x80000001);
-                       c->x86_capability[6] = cpuid_ecx(0x80000001);
-               }
-               if (xlvl >= 0x80000004)
-                       get_model_name(c); /* Default name */
-       }
-
-       /* Transmeta-defined flags: level 0x80860001 */
-       xlvl = cpuid_eax(0x80860000);
-       if ((xlvl & 0xffff0000) == 0x80860000) {
-               /* Don't set x86_cpuid_level here for now to not confuse. */
-               if (xlvl >= 0x80860001)
-                       c->x86_capability[2] = cpuid_edx(0x80860001);
-       }
-
-       init_scattered_cpuid_features(c);
-
-       c->apicid = phys_pkg_id(0);
-
-       /*
-        * Vendor-specific initialization.  In this section we
-        * canonicalize the feature flags, meaning if there are
-        * features a certain CPU supports which CPUID doesn't
-        * tell us, CPUID claiming incorrect flags, or other bugs,
-        * we handle them here.
-        *
-        * At the end of this section, c->x86_capability better
-        * indicate the features this CPU genuinely supports!
-        */
-       switch (c->x86_vendor) {
-       case X86_VENDOR_AMD:
-               init_amd(c);
-               break;
-
-       case X86_VENDOR_INTEL:
-               init_intel(c);
-               break;
-
-       case X86_VENDOR_UNKNOWN:
-       default:
-               display_cacheinfo(c);
-               break;
-       }
-
-       select_idle_routine(c);
-       detect_ht(c); 
-
-       /*
-        * On SMP, boot_cpu_data holds the common feature set between
-        * all CPUs; so make sure that we indicate which features are
-        * common between the CPUs.  The first time this routine gets
-        * executed, c == &boot_cpu_data.
-        */
-       if (c != &boot_cpu_data) {
-               /* AND the already accumulated flags with these */
-               for (i = 0 ; i < NCAPINTS ; i++)
-                       boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
-       }
-
-#ifdef CONFIG_X86_MCE
-       mcheck_init(c);
-#endif
-       if (c != &boot_cpu_data)
-               mtrr_ap_init();
-#ifdef CONFIG_NUMA
-       numa_add_cpu(smp_processor_id());
-#endif
-}
-
-void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
-{
-       if (c->x86_model_id[0])
-               printk("%s", c->x86_model_id);
-
-       if (c->x86_mask || c->cpuid_level >= 0) 
-               printk(" stepping %02x\n", c->x86_mask);
-       else
-               printk("\n");
-}
-
-/*
- *     Get CPU information for use by the procfs.
- */
-
-static int show_cpuinfo(struct seq_file *m, void *v)
-{
-       struct cpuinfo_x86 *c = v;
-
-       /* 
-        * These flag bits must match the definitions in <asm/cpufeature.h>.
-        * NULL means this bit is undefined or reserved; either way it doesn't
-        * have meaning as far as Linux is concerned.  Note that it's important
-        * to realize there is a difference between this table and CPUID -- if
-        * applications want to get the raw CPUID data, they should access
-        * /dev/cpu/<cpu_nr>/cpuid instead.
-        */
-       static char *x86_cap_flags[] = {
-               /* Intel-defined */
-               "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
-               "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
-               "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
-               "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
-
-               /* AMD-defined */
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
-               NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
-               "3dnowext", "3dnow",
-
-               /* Transmeta-defined */
-               "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-               /* Other (Linux-defined) */
-               "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
-               NULL, NULL, NULL, NULL,
-               "constant_tsc", "up", NULL, "arch_perfmon",
-               "pebs", "bts", NULL, "sync_rdtsc",
-               "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-               /* Intel-defined (#2) */
-               "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
-               "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
-               NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-               /* VIA/Cyrix/Centaur-defined */
-               NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
-               "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-               /* AMD-defined (#2) */
-               "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
-               "altmovcr8", "abm", "sse4a",
-               "misalignsse", "3dnowprefetch",
-               "osvw", "ibs", NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-               /* Auxiliary (Linux-defined) */
-               "ida", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       };
-       static char *x86_power_flags[] = { 
-               "ts",   /* temperature sensor */
-               "fid",  /* frequency id control */
-               "vid",  /* voltage id control */
-               "ttp",  /* thermal trip */
-               "tm",
-               "stc",
-               "100mhzsteps",
-               "hwpstate",
-               "",     /* tsc invariant mapped to constant_tsc */
-               /* nothing */
-       };
-
-
-#ifdef CONFIG_SMP
-       if (!cpu_online(c-cpu_data))
-               return 0;
-#endif
-
-       seq_printf(m,"processor\t: %u\n"
-                    "vendor_id\t: %s\n"
-                    "cpu family\t: %d\n"
-                    "model\t\t: %d\n"
-                    "model name\t: %s\n",
-                    (unsigned)(c-cpu_data),
-                    c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
-                    c->x86,
-                    (int)c->x86_model,
-                    c->x86_model_id[0] ? c->x86_model_id : "unknown");
-       
-       if (c->x86_mask || c->cpuid_level >= 0)
-               seq_printf(m, "stepping\t: %d\n", c->x86_mask);
-       else
-               seq_printf(m, "stepping\t: unknown\n");
-       
-       if (cpu_has(c,X86_FEATURE_TSC)) {
-               unsigned int freq = cpufreq_quick_get((unsigned)(c-cpu_data));
-               if (!freq)
-                       freq = cpu_khz;
-               seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
-                            freq / 1000, (freq % 1000));
-       }
-
-       /* Cache size */
-       if (c->x86_cache_size >= 0) 
-               seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
-       
-#ifdef CONFIG_SMP
-       if (smp_num_siblings * c->x86_max_cores > 1) {
-               int cpu = c - cpu_data;
-               seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
-               seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[cpu]));
-               seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
-               seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
-       }
-#endif 
-
-       seq_printf(m,
-               "fpu\t\t: yes\n"
-               "fpu_exception\t: yes\n"
-               "cpuid level\t: %d\n"
-               "wp\t\t: yes\n"
-               "flags\t\t:",
-                  c->cpuid_level);
-
-       { 
-               int i; 
-               for ( i = 0 ; i < 32*NCAPINTS ; i++ )
-                       if (cpu_has(c, i) && x86_cap_flags[i] != NULL)
-                               seq_printf(m, " %s", x86_cap_flags[i]);
-       }
-               
-       seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
-                  c->loops_per_jiffy/(500000/HZ),
-                  (c->loops_per_jiffy/(5000/HZ)) % 100);
-
-       if (c->x86_tlbsize > 0) 
-               seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize);
-       seq_printf(m, "clflush size\t: %d\n", c->x86_clflush_size);
-       seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment);
-
-       seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n", 
-                  c->x86_phys_bits, c->x86_virt_bits);
-
-       seq_printf(m, "power management:");
-       {
-               unsigned i;
-               for (i = 0; i < 32; i++) 
-                       if (c->x86_power & (1 << i)) {
-                               if (i < ARRAY_SIZE(x86_power_flags) &&
-                                       x86_power_flags[i])
-                                       seq_printf(m, "%s%s",
-                                               x86_power_flags[i][0]?" ":"",
-                                               x86_power_flags[i]);
-                               else
-                                       seq_printf(m, " [%d]", i);
-                       }
-       }
-
-       seq_printf(m, "\n\n");
-
-       return 0;
-}
-
-static void *c_start(struct seq_file *m, loff_t *pos)
-{
-       return *pos < NR_CPUS ? cpu_data + *pos : NULL;
-}
-
-static void *c_next(struct seq_file *m, void *v, loff_t *pos)
-{
-       ++*pos;
-       return c_start(m, pos);
-}
-
-static void c_stop(struct seq_file *m, void *v)
-{
-}
-
-struct seq_operations cpuinfo_op = {
-       .start =c_start,
-       .next = c_next,
-       .stop = c_stop,
-       .show = show_cpuinfo,
-};
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
deleted file mode 100644 (file)
index 1200aaa..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/* 
- * X86-64 specific CPU setup.
- * Copyright (C) 1995  Linus Torvalds
- * Copyright 2001, 2002, 2003 SuSE Labs / Andi Kleen.
- * See setup.c for older changelog.
- */ 
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/bootmem.h>
-#include <linux/bitops.h>
-#include <linux/module.h>
-#include <asm/bootsetup.h>
-#include <asm/pda.h>
-#include <asm/pgtable.h>
-#include <asm/processor.h>
-#include <asm/desc.h>
-#include <asm/atomic.h>
-#include <asm/mmu_context.h>
-#include <asm/smp.h>
-#include <asm/i387.h>
-#include <asm/percpu.h>
-#include <asm/proto.h>
-#include <asm/sections.h>
-
-char x86_boot_params[BOOT_PARAM_SIZE] __initdata;
-
-cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
-
-struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
-EXPORT_SYMBOL(_cpu_pda);
-struct x8664_pda boot_cpu_pda[NR_CPUS] __cacheline_aligned;
-
-struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
-
-char boot_cpu_stack[IRQSTACKSIZE] __attribute__((section(".bss.page_aligned")));
-
-unsigned long __supported_pte_mask __read_mostly = ~0UL;
-static int do_not_nx __cpuinitdata = 0;
-
-/* noexec=on|off
-Control non executable mappings for 64bit processes.
-
-on     Enable(default)
-off    Disable
-*/ 
-static int __init nonx_setup(char *str)
-{
-       if (!str)
-               return -EINVAL;
-       if (!strncmp(str, "on", 2)) {
-                __supported_pte_mask |= _PAGE_NX; 
-               do_not_nx = 0; 
-       } else if (!strncmp(str, "off", 3)) {
-               do_not_nx = 1;
-               __supported_pte_mask &= ~_PAGE_NX;
-        }
-       return 0;
-} 
-early_param("noexec", nonx_setup);
-
-int force_personality32 = 0; 
-
-/* noexec32=on|off
-Control non executable heap for 32bit processes.
-To control the stack too use noexec=off
-
-on     PROT_READ does not imply PROT_EXEC for 32bit processes
-off    PROT_READ implies PROT_EXEC (default)
-*/
-static int __init nonx32_setup(char *str)
-{
-       if (!strcmp(str, "on"))
-               force_personality32 &= ~READ_IMPLIES_EXEC;
-       else if (!strcmp(str, "off"))
-               force_personality32 |= READ_IMPLIES_EXEC;
-       return 1;
-}
-__setup("noexec32=", nonx32_setup);
-
-/*
- * Great future plan:
- * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
- * Always point %gs to its beginning
- */
-void __init setup_per_cpu_areas(void)
-{ 
-       int i;
-       unsigned long size;
-
-#ifdef CONFIG_HOTPLUG_CPU
-       prefill_possible_map();
-#endif
-
-       /* Copy section for each CPU (we discard the original) */
-       size = PERCPU_ENOUGH_ROOM;
-
-       printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", size);
-       for_each_cpu_mask (i, cpu_possible_map) {
-               char *ptr;
-
-               if (!NODE_DATA(cpu_to_node(i))) {
-                       printk("cpu with no node %d, num_online_nodes %d\n",
-                              i, num_online_nodes());
-                       ptr = alloc_bootmem_pages(size);
-               } else { 
-                       ptr = alloc_bootmem_pages_node(NODE_DATA(cpu_to_node(i)), size);
-               }
-               if (!ptr)
-                       panic("Cannot allocate cpu data for CPU %d\n", i);
-               cpu_pda(i)->data_offset = ptr - __per_cpu_start;
-               memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
-       }
-} 
-
-void pda_init(int cpu)
-{ 
-       struct x8664_pda *pda = cpu_pda(cpu);
-
-       /* Setup up data that may be needed in __get_free_pages early */
-       asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); 
-       /* Memory clobbers used to order PDA accessed */
-       mb();
-       wrmsrl(MSR_GS_BASE, pda);
-       mb();
-
-       pda->cpunumber = cpu; 
-       pda->irqcount = -1;
-       pda->kernelstack = 
-               (unsigned long)stack_thread_info() - PDA_STACKOFFSET + THREAD_SIZE; 
-       pda->active_mm = &init_mm;
-       pda->mmu_state = 0;
-
-       if (cpu == 0) {
-               /* others are initialized in smpboot.c */
-               pda->pcurrent = &init_task;
-               pda->irqstackptr = boot_cpu_stack; 
-       } else {
-               pda->irqstackptr = (char *)
-                       __get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
-               if (!pda->irqstackptr)
-                       panic("cannot allocate irqstack for cpu %d", cpu); 
-       }
-
-
-       pda->irqstackptr += IRQSTACKSIZE-64;
-} 
-
-char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]
-__attribute__((section(".bss.page_aligned")));
-
-extern asmlinkage void ignore_sysret(void);
-
-/* May not be marked __init: used by software suspend */
-void syscall_init(void)
-{
-       /* 
-        * LSTAR and STAR live in a bit strange symbiosis.
-        * They both write to the same internal register. STAR allows to set CS/DS
-        * but only a 32bit target. LSTAR sets the 64bit rip.    
-        */ 
-       wrmsrl(MSR_STAR,  ((u64)__USER32_CS)<<48  | ((u64)__KERNEL_CS)<<32); 
-       wrmsrl(MSR_LSTAR, system_call); 
-       wrmsrl(MSR_CSTAR, ignore_sysret);
-
-#ifdef CONFIG_IA32_EMULATION                   
-       syscall32_cpu_init ();
-#endif
-
-       /* Flags to clear on syscall */
-       wrmsrl(MSR_SYSCALL_MASK, EF_TF|EF_DF|EF_IE|0x3000); 
-}
-
-void __cpuinit check_efer(void)
-{
-       unsigned long efer;
-
-       rdmsrl(MSR_EFER, efer); 
-        if (!(efer & EFER_NX) || do_not_nx) { 
-                __supported_pte_mask &= ~_PAGE_NX; 
-        }       
-}
-
-unsigned long kernel_eflags;
-
-/*
- * cpu_init() initializes state that is per-CPU. Some data is already
- * initialized (naturally) in the bootstrap process, such as the GDT
- * and IDT. We reload them nevertheless, this function acts as a
- * 'CPU state barrier', nothing should get across.
- * A lot of state is already set up in PDA init.
- */
-void __cpuinit cpu_init (void)
-{
-       int cpu = stack_smp_processor_id();
-       struct tss_struct *t = &per_cpu(init_tss, cpu);
-       struct orig_ist *orig_ist = &per_cpu(orig_ist, cpu);
-       unsigned long v; 
-       char *estacks = NULL; 
-       struct task_struct *me;
-       int i;
-
-       /* CPU 0 is initialised in head64.c */
-       if (cpu != 0) {
-               pda_init(cpu);
-       } else 
-               estacks = boot_exception_stacks; 
-
-       me = current;
-
-       if (cpu_test_and_set(cpu, cpu_initialized))
-               panic("CPU#%d already initialized!\n", cpu);
-
-       printk("Initializing CPU#%d\n", cpu);
-
-       clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
-
-       /*
-        * Initialize the per-CPU GDT with the boot GDT,
-        * and set up the GDT descriptor:
-        */
-       if (cpu)
-               memcpy(cpu_gdt(cpu), cpu_gdt_table, GDT_SIZE);
-
-       cpu_gdt_descr[cpu].size = GDT_SIZE;
-       asm volatile("lgdt %0" :: "m" (cpu_gdt_descr[cpu]));
-       asm volatile("lidt %0" :: "m" (idt_descr));
-
-       memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
-       syscall_init();
-
-       wrmsrl(MSR_FS_BASE, 0);
-       wrmsrl(MSR_KERNEL_GS_BASE, 0);
-       barrier(); 
-
-       check_efer();
-
-       /*
-        * set up and load the per-CPU TSS
-        */
-       for (v = 0; v < N_EXCEPTION_STACKS; v++) {
-               static const unsigned int order[N_EXCEPTION_STACKS] = {
-                       [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
-                       [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
-               };
-               if (cpu) {
-                       estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
-                       if (!estacks)
-                               panic("Cannot allocate exception stack %ld %d\n",
-                                     v, cpu); 
-               }
-               estacks += PAGE_SIZE << order[v];
-               orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks;
-       }
-
-       t->io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
-       /*
-        * <= is required because the CPU will access up to
-        * 8 bits beyond the end of the IO permission bitmap.
-        */
-       for (i = 0; i <= IO_BITMAP_LONGS; i++)
-               t->io_bitmap[i] = ~0UL;
-
-       atomic_inc(&init_mm.mm_count);
-       me->active_mm = &init_mm;
-       if (me->mm)
-               BUG();
-       enter_lazy_tlb(&init_mm, me);
-
-       set_tss_desc(cpu, t);
-       load_TR_desc();
-       load_LDT(&init_mm.context);
-
-       /*
-        * Clear all 6 debug registers:
-        */
-
-       set_debugreg(0UL, 0);
-       set_debugreg(0UL, 1);
-       set_debugreg(0UL, 2);
-       set_debugreg(0UL, 3);
-       set_debugreg(0UL, 6);
-       set_debugreg(0UL, 7);
-
-       fpu_init(); 
-
-       raw_local_save_flags(kernel_eflags);
-}
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
deleted file mode 100644 (file)
index 739175b..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- *  linux/arch/x86_64/kernel/signal.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs
- *
- *  1997-11-28  Modified for POSIX.1b signals by Richard Henderson
- *  2000-06-20  Pentium III FXSR, SSE support by Gareth Hughes
- *  2000-2002   x86-64 support by Andi Kleen
- */
-
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/kernel.h>
-#include <linux/signal.h>
-#include <linux/errno.h>
-#include <linux/wait.h>
-#include <linux/ptrace.h>
-#include <linux/unistd.h>
-#include <linux/stddef.h>
-#include <linux/personality.h>
-#include <linux/compiler.h>
-#include <asm/ucontext.h>
-#include <asm/uaccess.h>
-#include <asm/i387.h>
-#include <asm/proto.h>
-#include <asm/ia32_unistd.h>
-#include <asm/mce.h>
-
-/* #define DEBUG_SIG 1 */
-
-#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
-
-int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-               sigset_t *set, struct pt_regs * regs); 
-int ia32_setup_frame(int sig, struct k_sigaction *ka,
-            sigset_t *set, struct pt_regs * regs); 
-
-asmlinkage long
-sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
-               struct pt_regs *regs)
-{
-       return do_sigaltstack(uss, uoss, regs->rsp);
-}
-
-
-/*
- * Do a signal return; undo the signal stack.
- */
-
-struct rt_sigframe
-{
-       char __user *pretcode;
-       struct ucontext uc;
-       struct siginfo info;
-};
-
-static int
-restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, unsigned long *prax)
-{
-       unsigned int err = 0;
-
-       /* Always make any pending restarted system calls return -EINTR */
-       current_thread_info()->restart_block.fn = do_no_restart_syscall;
-
-#define COPY(x)                err |= __get_user(regs->x, &sc->x)
-
-       COPY(rdi); COPY(rsi); COPY(rbp); COPY(rsp); COPY(rbx);
-       COPY(rdx); COPY(rcx); COPY(rip);
-       COPY(r8);
-       COPY(r9);
-       COPY(r10);
-       COPY(r11);
-       COPY(r12);
-       COPY(r13);
-       COPY(r14);
-       COPY(r15);
-
-       /* Kernel saves and restores only the CS segment register on signals,
-        * which is the bare minimum needed to allow mixed 32/64-bit code.
-        * App's signal handler can save/restore other segments if needed. */
-       {
-               unsigned cs;
-               err |= __get_user(cs, &sc->cs);
-               regs->cs = cs | 3;      /* Force into user mode */
-       }
-
-       {
-               unsigned int tmpflags;
-               err |= __get_user(tmpflags, &sc->eflags);
-               regs->eflags = (regs->eflags & ~0x40DD5) | (tmpflags & 0x40DD5);
-               regs->orig_rax = -1;            /* disable syscall checks */
-       }
-
-       {
-               struct _fpstate __user * buf;
-               err |= __get_user(buf, &sc->fpstate);
-
-               if (buf) {
-                       if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
-                               goto badframe;
-                       err |= restore_i387(buf);
-               } else {
-                       struct task_struct *me = current;
-                       if (used_math()) {
-                               clear_fpu(me);
-                               clear_used_math();
-                       }
-               }
-       }
-
-       err |= __get_user(*prax, &sc->rax);
-       return err;
-
-badframe:
-       return 1;
-}
-
-asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
-{
-       struct rt_sigframe __user *frame;
-       sigset_t set;
-       unsigned long eax;
-
-       frame = (struct rt_sigframe __user *)(regs->rsp - 8);
-       if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) {
-               goto badframe;
-       } 
-       if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) { 
-               goto badframe;
-       } 
-
-       sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
-       
-       if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &eax))
-               goto badframe;
-
-#ifdef DEBUG_SIG
-       printk("%d sigreturn rip:%lx rsp:%lx frame:%p rax:%lx\n",current->pid,regs->rip,regs->rsp,frame,eax);
-#endif
-
-       if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->rsp) == -EFAULT)
-               goto badframe;
-
-       return eax;
-
-badframe:
-       signal_fault(regs,frame,"sigreturn");
-       return 0;
-}      
-
-/*
- * Set up a signal frame.
- */
-
-static inline int
-setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask, struct task_struct *me)
-{
-       int err = 0;
-
-       err |= __put_user(regs->cs, &sc->cs);
-       err |= __put_user(0, &sc->gs);
-       err |= __put_user(0, &sc->fs);
-
-       err |= __put_user(regs->rdi, &sc->rdi);
-       err |= __put_user(regs->rsi, &sc->rsi);
-       err |= __put_user(regs->rbp, &sc->rbp);
-       err |= __put_user(regs->rsp, &sc->rsp);
-       err |= __put_user(regs->rbx, &sc->rbx);
-       err |= __put_user(regs->rdx, &sc->rdx);
-       err |= __put_user(regs->rcx, &sc->rcx);
-       err |= __put_user(regs->rax, &sc->rax);
-       err |= __put_user(regs->r8, &sc->r8);
-       err |= __put_user(regs->r9, &sc->r9);
-       err |= __put_user(regs->r10, &sc->r10);
-       err |= __put_user(regs->r11, &sc->r11);
-       err |= __put_user(regs->r12, &sc->r12);
-       err |= __put_user(regs->r13, &sc->r13);
-       err |= __put_user(regs->r14, &sc->r14);
-       err |= __put_user(regs->r15, &sc->r15);
-       err |= __put_user(me->thread.trap_no, &sc->trapno);
-       err |= __put_user(me->thread.error_code, &sc->err);
-       err |= __put_user(regs->rip, &sc->rip);
-       err |= __put_user(regs->eflags, &sc->eflags);
-       err |= __put_user(mask, &sc->oldmask);
-       err |= __put_user(me->thread.cr2, &sc->cr2);
-
-       return err;
-}
-
-/*
- * Determine which stack to use..
- */
-
-static void __user *
-get_stack(struct k_sigaction *ka, struct pt_regs *regs, unsigned long size)
-{
-       unsigned long rsp;
-
-       /* Default to using normal stack - redzone*/
-       rsp = regs->rsp - 128;
-
-       /* This is the X/Open sanctioned signal stack switching.  */
-       if (ka->sa.sa_flags & SA_ONSTACK) {
-               if (sas_ss_flags(rsp) == 0)
-                       rsp = current->sas_ss_sp + current->sas_ss_size;
-       }
-
-       return (void __user *)round_down(rsp - size, 16); 
-}
-
-static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-                          sigset_t *set, struct pt_regs * regs)
-{
-       struct rt_sigframe __user *frame;
-       struct _fpstate __user *fp = NULL; 
-       int err = 0;
-       struct task_struct *me = current;
-
-       if (used_math()) {
-               fp = get_stack(ka, regs, sizeof(struct _fpstate)); 
-               frame = (void __user *)round_down(
-                       (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
-
-               if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
-                       goto give_sigsegv;
-
-               if (save_i387(fp) < 0) 
-                       err |= -1; 
-       } else
-               frame = get_stack(ka, regs, sizeof(struct rt_sigframe)) - 8;
-
-       if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
-               goto give_sigsegv;
-
-       if (ka->sa.sa_flags & SA_SIGINFO) { 
-               err |= copy_siginfo_to_user(&frame->info, info);
-               if (err)
-                       goto give_sigsegv;
-       }
-               
-       /* Create the ucontext.  */
-       err |= __put_user(0, &frame->uc.uc_flags);
-       err |= __put_user(0, &frame->uc.uc_link);
-       err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
-       err |= __put_user(sas_ss_flags(regs->rsp),
-                         &frame->uc.uc_stack.ss_flags);
-       err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
-       err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me);
-       err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate);
-       if (sizeof(*set) == 16) { 
-               __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
-               __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]); 
-       } else
-               err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
-
-       /* Set up to return from userspace.  If provided, use a stub
-          already in userspace.  */
-       /* x86-64 should always use SA_RESTORER. */
-       if (ka->sa.sa_flags & SA_RESTORER) {
-               err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
-       } else {
-               /* could use a vstub here */
-               goto give_sigsegv; 
-       }
-
-       if (err)
-               goto give_sigsegv;
-
-#ifdef DEBUG_SIG
-       printk("%d old rip %lx old rsp %lx old rax %lx\n", current->pid,regs->rip,regs->rsp,regs->rax);
-#endif
-
-       /* Set up registers for signal handler */
-       regs->rdi = sig;
-       /* In case the signal handler was declared without prototypes */ 
-       regs->rax = 0;  
-
-       /* This also works for non SA_SIGINFO handlers because they expect the
-          next argument after the signal number on the stack. */
-       regs->rsi = (unsigned long)&frame->info; 
-       regs->rdx = (unsigned long)&frame->uc; 
-       regs->rip = (unsigned long) ka->sa.sa_handler;
-
-       regs->rsp = (unsigned long)frame;
-
-       /* Set up the CS register to run signal handlers in 64-bit mode,
-          even if the handler happens to be interrupting 32-bit code. */
-       regs->cs = __USER_CS;
-
-       /* This, by contrast, has nothing to do with segment registers -
-          see include/asm-x86_64/uaccess.h for details. */
-       set_fs(USER_DS);
-
-       regs->eflags &= ~TF_MASK;
-       if (test_thread_flag(TIF_SINGLESTEP))
-               ptrace_notify(SIGTRAP);
-#ifdef DEBUG_SIG
-       printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%p\n",
-               current->comm, current->pid, frame, regs->rip, frame->pretcode);
-#endif
-
-       return 0;
-
-give_sigsegv:
-       force_sigsegv(sig, current);
-       return -EFAULT;
-}
-
-/*
- * OK, we're invoking a handler
- */    
-
-static int
-handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
-               sigset_t *oldset, struct pt_regs *regs)
-{
-       int ret;
-
-#ifdef DEBUG_SIG
-       printk("handle_signal pid:%d sig:%lu rip:%lx rsp:%lx regs=%p\n",
-               current->pid, sig,
-               regs->rip, regs->rsp, regs);
-#endif
-
-       /* Are we from a system call? */
-       if ((long)regs->orig_rax >= 0) {
-               /* If so, check system call restarting.. */
-               switch (regs->rax) {
-                       case -ERESTART_RESTARTBLOCK:
-                       case -ERESTARTNOHAND:
-                               regs->rax = -EINTR;
-                               break;
-
-                       case -ERESTARTSYS:
-                               if (!(ka->sa.sa_flags & SA_RESTART)) {
-                                       regs->rax = -EINTR;
-                                       break;
-                               }
-                               /* fallthrough */
-                       case -ERESTARTNOINTR:
-                               regs->rax = regs->orig_rax;
-                               regs->rip -= 2;
-                               break;
-               }
-       }
-
-       /*
-        * If TF is set due to a debugger (PT_DTRACE), clear the TF
-        * flag so that register information in the sigcontext is
-        * correct.
-        */
-       if (unlikely(regs->eflags & TF_MASK)) {
-               if (likely(current->ptrace & PT_DTRACE)) {
-                       current->ptrace &= ~PT_DTRACE;
-                       regs->eflags &= ~TF_MASK;
-               }
-       }
-
-#ifdef CONFIG_IA32_EMULATION
-       if (test_thread_flag(TIF_IA32)) {
-               if (ka->sa.sa_flags & SA_SIGINFO)
-                       ret = ia32_setup_rt_frame(sig, ka, info, oldset, regs);
-               else
-                       ret = ia32_setup_frame(sig, ka, oldset, regs);
-       } else 
-#endif
-       ret = setup_rt_frame(sig, ka, info, oldset, regs);
-
-       if (ret == 0) {
-               spin_lock_irq(&current->sighand->siglock);
-               sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-               if (!(ka->sa.sa_flags & SA_NODEFER))
-                       sigaddset(&current->blocked,sig);
-               recalc_sigpending();
-               spin_unlock_irq(&current->sighand->siglock);
-       }
-
-       return ret;
-}
-
-/*
- * Note that 'init' is a special process: it doesn't get signals it doesn't
- * want to handle. Thus you cannot kill init even with a SIGKILL even by
- * mistake.
- */
-static void do_signal(struct pt_regs *regs)
-{
-       struct k_sigaction ka;
-       siginfo_t info;
-       int signr;
-       sigset_t *oldset;
-
-       /*
-        * We want the common case to go fast, which
-        * is why we may in certain cases get here from
-        * kernel mode. Just return without doing anything
-        * if so.
-        */
-       if (!user_mode(regs))
-               return;
-
-       if (test_thread_flag(TIF_RESTORE_SIGMASK))
-               oldset = &current->saved_sigmask;
-       else
-               oldset = &current->blocked;
-
-       signr = get_signal_to_deliver(&info, &ka, regs, NULL);
-       if (signr > 0) {
-               /* Reenable any watchpoints before delivering the
-                * signal to user space. The processor register will
-                * have been cleared if the watchpoint triggered
-                * inside the kernel.
-                */
-               if (current->thread.debugreg7)
-                       set_debugreg(current->thread.debugreg7, 7);
-
-               /* Whee!  Actually deliver the signal.  */
-               if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
-                       /* a signal was successfully delivered; the saved
-                        * sigmask will have been stored in the signal frame,
-                        * and will be restored by sigreturn, so we can simply
-                        * clear the TIF_RESTORE_SIGMASK flag */
-                       clear_thread_flag(TIF_RESTORE_SIGMASK);
-               }
-               return;
-       }
-
-       /* Did we come from a system call? */
-       if ((long)regs->orig_rax >= 0) {
-               /* Restart the system call - no handlers present */
-               long res = regs->rax;
-               switch (res) {
-               case -ERESTARTNOHAND:
-               case -ERESTARTSYS:
-               case -ERESTARTNOINTR:
-                       regs->rax = regs->orig_rax;
-                       regs->rip -= 2;
-                       break;
-               case -ERESTART_RESTARTBLOCK:
-                       regs->rax = test_thread_flag(TIF_IA32) ?
-                                       __NR_ia32_restart_syscall :
-                                       __NR_restart_syscall;
-                       regs->rip -= 2;
-                       break;
-               }
-       }
-
-       /* if there's no signal to deliver, we just put the saved sigmask
-          back. */
-       if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
-               clear_thread_flag(TIF_RESTORE_SIGMASK);
-               sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
-       }
-}
-
-void
-do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
-{
-#ifdef DEBUG_SIG
-       printk("do_notify_resume flags:%x rip:%lx rsp:%lx caller:%p pending:%x\n",
-              thread_info_flags, regs->rip, regs->rsp, __builtin_return_address(0),signal_pending(current)); 
-#endif
-              
-       /* Pending single-step? */
-       if (thread_info_flags & _TIF_SINGLESTEP) {
-               regs->eflags |= TF_MASK;
-               clear_thread_flag(TIF_SINGLESTEP);
-       }
-
-#ifdef CONFIG_X86_MCE
-       /* notify userspace of pending MCEs */
-       if (thread_info_flags & _TIF_MCE_NOTIFY)
-               mce_notify_user();
-#endif /* CONFIG_X86_MCE */
-
-       /* deal with pending signal delivery */
-       if (thread_info_flags & (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK))
-               do_signal(regs);
-}
-
-void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
-{ 
-       struct task_struct *me = current; 
-       if (show_unhandled_signals && printk_ratelimit())
-               printk("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n",
-              me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax); 
-
-       force_sig(SIGSEGV, me); 
-} 
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
deleted file mode 100644 (file)
index df4a828..0000000
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- *     Intel SMP support routines.
- *
- *     (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
- *     (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com>
- *      (c) 2002,2003 Andi Kleen, SuSE Labs.
- *
- *     This code is released under the GNU General Public License version 2 or
- *     later.
- */
-
-#include <linux/init.h>
-
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/spinlock.h>
-#include <linux/smp.h>
-#include <linux/kernel_stat.h>
-#include <linux/mc146818rtc.h>
-#include <linux/interrupt.h>
-
-#include <asm/mtrr.h>
-#include <asm/pgalloc.h>
-#include <asm/tlbflush.h>
-#include <asm/mach_apic.h>
-#include <asm/mmu_context.h>
-#include <asm/proto.h>
-#include <asm/apicdef.h>
-#include <asm/idle.h>
-
-/*
- *     Smarter SMP flushing macros. 
- *             c/o Linus Torvalds.
- *
- *     These mean you can really definitely utterly forget about
- *     writing to user space from interrupts. (Its not allowed anyway).
- *
- *     Optimizations Manfred Spraul <manfred@colorfullife.com>
- *
- *     More scalable flush, from Andi Kleen
- *
- *     To avoid global state use 8 different call vectors.
- *     Each CPU uses a specific vector to trigger flushes on other
- *     CPUs. Depending on the received vector the target CPUs look into
- *     the right per cpu variable for the flush data.
- *
- *     With more than 8 CPUs they are hashed to the 8 available
- *     vectors. The limited global vector space forces us to this right now.
- *     In future when interrupts are split into per CPU domains this could be
- *     fixed, at the cost of triggering multiple IPIs in some cases.
- */
-
-union smp_flush_state {
-       struct {
-               cpumask_t flush_cpumask;
-               struct mm_struct *flush_mm;
-               unsigned long flush_va;
-#define FLUSH_ALL      -1ULL
-               spinlock_t tlbstate_lock;
-       };
-       char pad[SMP_CACHE_BYTES];
-} ____cacheline_aligned;
-
-/* State is put into the per CPU data section, but padded
-   to a full cache line because other CPUs can access it and we don't
-   want false sharing in the per cpu data segment. */
-static DEFINE_PER_CPU(union smp_flush_state, flush_state);
-
-/*
- * We cannot call mmdrop() because we are in interrupt context, 
- * instead update mm->cpu_vm_mask.
- */
-static inline void leave_mm(int cpu)
-{
-       if (read_pda(mmu_state) == TLBSTATE_OK)
-               BUG();
-       cpu_clear(cpu, read_pda(active_mm)->cpu_vm_mask);
-       load_cr3(swapper_pg_dir);
-}
-
-/*
- *
- * The flush IPI assumes that a thread switch happens in this order:
- * [cpu0: the cpu that switches]
- * 1) switch_mm() either 1a) or 1b)
- * 1a) thread switch to a different mm
- * 1a1) cpu_clear(cpu, old_mm->cpu_vm_mask);
- *     Stop ipi delivery for the old mm. This is not synchronized with
- *     the other cpus, but smp_invalidate_interrupt ignore flush ipis
- *     for the wrong mm, and in the worst case we perform a superfluous
- *     tlb flush.
- * 1a2) set cpu mmu_state to TLBSTATE_OK
- *     Now the smp_invalidate_interrupt won't call leave_mm if cpu0
- *     was in lazy tlb mode.
- * 1a3) update cpu active_mm
- *     Now cpu0 accepts tlb flushes for the new mm.
- * 1a4) cpu_set(cpu, new_mm->cpu_vm_mask);
- *     Now the other cpus will send tlb flush ipis.
- * 1a4) change cr3.
- * 1b) thread switch without mm change
- *     cpu active_mm is correct, cpu0 already handles
- *     flush ipis.
- * 1b1) set cpu mmu_state to TLBSTATE_OK
- * 1b2) test_and_set the cpu bit in cpu_vm_mask.
- *     Atomically set the bit [other cpus will start sending flush ipis],
- *     and test the bit.
- * 1b3) if the bit was 0: leave_mm was called, flush the tlb.
- * 2) switch %%esp, ie current
- *
- * The interrupt must handle 2 special cases:
- * - cr3 is changed before %%esp, ie. it cannot use current->{active_,}mm.
- * - the cpu performs speculative tlb reads, i.e. even if the cpu only
- *   runs in kernel space, the cpu could load tlb entries for user space
- *   pages.
- *
- * The good news is that cpu mmu_state is local to each cpu, no
- * write/read ordering problems.
- */
-
-/*
- * TLB flush IPI:
- *
- * 1) Flush the tlb entries if the cpu uses the mm that's being flushed.
- * 2) Leave the mm if we are in the lazy tlb mode.
- *
- * Interrupts are disabled.
- */
-
-asmlinkage void smp_invalidate_interrupt(struct pt_regs *regs)
-{
-       int cpu;
-       int sender;
-       union smp_flush_state *f;
-
-       cpu = smp_processor_id();
-       /*
-        * orig_rax contains the negated interrupt vector.
-        * Use that to determine where the sender put the data.
-        */
-       sender = ~regs->orig_rax - INVALIDATE_TLB_VECTOR_START;
-       f = &per_cpu(flush_state, sender);
-
-       if (!cpu_isset(cpu, f->flush_cpumask))
-               goto out;
-               /* 
-                * This was a BUG() but until someone can quote me the
-                * line from the intel manual that guarantees an IPI to
-                * multiple CPUs is retried _only_ on the erroring CPUs
-                * its staying as a return
-                *
-                * BUG();
-                */
-                
-       if (f->flush_mm == read_pda(active_mm)) {
-               if (read_pda(mmu_state) == TLBSTATE_OK) {
-                       if (f->flush_va == FLUSH_ALL)
-                               local_flush_tlb();
-                       else
-                               __flush_tlb_one(f->flush_va);
-               } else
-                       leave_mm(cpu);
-       }
-out:
-       ack_APIC_irq();
-       cpu_clear(cpu, f->flush_cpumask);
-}
-
-static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
-                                               unsigned long va)
-{
-       int sender;
-       union smp_flush_state *f;
-
-       /* Caller has disabled preemption */
-       sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS;
-       f = &per_cpu(flush_state, sender);
-
-       /* Could avoid this lock when
-          num_online_cpus() <= NUM_INVALIDATE_TLB_VECTORS, but it is
-          probably not worth checking this for a cache-hot lock. */
-       spin_lock(&f->tlbstate_lock);
-
-       f->flush_mm = mm;
-       f->flush_va = va;
-       cpus_or(f->flush_cpumask, cpumask, f->flush_cpumask);
-
-       /*
-        * We have to send the IPI only to
-        * CPUs affected.
-        */
-       send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR_START + sender);
-
-       while (!cpus_empty(f->flush_cpumask))
-               cpu_relax();
-
-       f->flush_mm = NULL;
-       f->flush_va = 0;
-       spin_unlock(&f->tlbstate_lock);
-}
-
-int __cpuinit init_smp_flush(void)
-{
-       int i;
-       for_each_cpu_mask(i, cpu_possible_map) {
-               spin_lock_init(&per_cpu(flush_state, i).tlbstate_lock);
-       }
-       return 0;
-}
-
-core_initcall(init_smp_flush);
-       
-void flush_tlb_current_task(void)
-{
-       struct mm_struct *mm = current->mm;
-       cpumask_t cpu_mask;
-
-       preempt_disable();
-       cpu_mask = mm->cpu_vm_mask;
-       cpu_clear(smp_processor_id(), cpu_mask);
-
-       local_flush_tlb();
-       if (!cpus_empty(cpu_mask))
-               flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
-       preempt_enable();
-}
-EXPORT_SYMBOL(flush_tlb_current_task);
-
-void flush_tlb_mm (struct mm_struct * mm)
-{
-       cpumask_t cpu_mask;
-
-       preempt_disable();
-       cpu_mask = mm->cpu_vm_mask;
-       cpu_clear(smp_processor_id(), cpu_mask);
-
-       if (current->active_mm == mm) {
-               if (current->mm)
-                       local_flush_tlb();
-               else
-                       leave_mm(smp_processor_id());
-       }
-       if (!cpus_empty(cpu_mask))
-               flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
-
-       preempt_enable();
-}
-EXPORT_SYMBOL(flush_tlb_mm);
-
-void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
-{
-       struct mm_struct *mm = vma->vm_mm;
-       cpumask_t cpu_mask;
-
-       preempt_disable();
-       cpu_mask = mm->cpu_vm_mask;
-       cpu_clear(smp_processor_id(), cpu_mask);
-
-       if (current->active_mm == mm) {
-               if(current->mm)
-                       __flush_tlb_one(va);
-                else
-                       leave_mm(smp_processor_id());
-       }
-
-       if (!cpus_empty(cpu_mask))
-               flush_tlb_others(cpu_mask, mm, va);
-
-       preempt_enable();
-}
-EXPORT_SYMBOL(flush_tlb_page);
-
-static void do_flush_tlb_all(void* info)
-{
-       unsigned long cpu = smp_processor_id();
-
-       __flush_tlb_all();
-       if (read_pda(mmu_state) == TLBSTATE_LAZY)
-               leave_mm(cpu);
-}
-
-void flush_tlb_all(void)
-{
-       on_each_cpu(do_flush_tlb_all, NULL, 1, 1);
-}
-
-/*
- * this function sends a 'reschedule' IPI to another CPU.
- * it goes straight through and wastes no time serializing
- * anything. Worst case is that we lose a reschedule ...
- */
-
-void smp_send_reschedule(int cpu)
-{
-       send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
-}
-
-/*
- * Structure and data for smp_call_function(). This is designed to minimise
- * static memory requirements. It also looks cleaner.
- */
-static DEFINE_SPINLOCK(call_lock);
-
-struct call_data_struct {
-       void (*func) (void *info);
-       void *info;
-       atomic_t started;
-       atomic_t finished;
-       int wait;
-};
-
-static struct call_data_struct * call_data;
-
-void lock_ipi_call_lock(void)
-{
-       spin_lock_irq(&call_lock);
-}
-
-void unlock_ipi_call_lock(void)
-{
-       spin_unlock_irq(&call_lock);
-}
-
-/*
- * this function sends a 'generic call function' IPI to one other CPU
- * in the system.
- *
- * cpu is a standard Linux logical CPU number.
- */
-static void
-__smp_call_function_single(int cpu, void (*func) (void *info), void *info,
-                               int nonatomic, int wait)
-{
-       struct call_data_struct data;
-       int cpus = 1;
-
-       data.func = func;
-       data.info = info;
-       atomic_set(&data.started, 0);
-       data.wait = wait;
-       if (wait)
-               atomic_set(&data.finished, 0);
-
-       call_data = &data;
-       wmb();
-       /* Send a message to all other CPUs and wait for them to respond */
-       send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_VECTOR);
-
-       /* Wait for response */
-       while (atomic_read(&data.started) != cpus)
-               cpu_relax();
-
-       if (!wait)
-               return;
-
-       while (atomic_read(&data.finished) != cpus)
-               cpu_relax();
-}
-
-/*
- * smp_call_function_single - Run a function on a specific CPU
- * @func: The function to run. This must be fast and non-blocking.
- * @info: An arbitrary pointer to pass to the function.
- * @nonatomic: Currently unused.
- * @wait: If true, wait until function has completed on other CPUs.
- *
- * Retrurns 0 on success, else a negative status code.
- *
- * Does not return until the remote CPU is nearly ready to execute <func>
- * or is or has executed.
- */
-
-int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
-       int nonatomic, int wait)
-{
-       /* prevent preemption and reschedule on another processor */
-       int me = get_cpu();
-
-       /* Can deadlock when called with interrupts disabled */
-       WARN_ON(irqs_disabled());
-
-       if (cpu == me) {
-               local_irq_disable();
-               func(info);
-               local_irq_enable();
-               put_cpu();
-               return 0;
-       }
-
-       spin_lock(&call_lock);
-       __smp_call_function_single(cpu, func, info, nonatomic, wait);
-       spin_unlock(&call_lock);
-       put_cpu();
-       return 0;
-}
-EXPORT_SYMBOL(smp_call_function_single);
-
-/*
- * this function sends a 'generic call function' IPI to all other CPUs
- * in the system.
- */
-static void __smp_call_function (void (*func) (void *info), void *info,
-                               int nonatomic, int wait)
-{
-       struct call_data_struct data;
-       int cpus = num_online_cpus()-1;
-
-       if (!cpus)
-               return;
-
-       data.func = func;
-       data.info = info;
-       atomic_set(&data.started, 0);
-       data.wait = wait;
-       if (wait)
-               atomic_set(&data.finished, 0);
-
-       call_data = &data;
-       wmb();
-       /* Send a message to all other CPUs and wait for them to respond */
-       send_IPI_allbutself(CALL_FUNCTION_VECTOR);
-
-       /* Wait for response */
-       while (atomic_read(&data.started) != cpus)
-               cpu_relax();
-
-       if (!wait)
-               return;
-
-       while (atomic_read(&data.finished) != cpus)
-               cpu_relax();
-}
-
-/*
- * smp_call_function - run a function on all other CPUs.
- * @func: The function to run. This must be fast and non-blocking.
- * @info: An arbitrary pointer to pass to the function.
- * @nonatomic: currently unused.
- * @wait: If true, wait (atomically) until function has completed on other
- *        CPUs.
- *
- * Returns 0 on success, else a negative status code. Does not return until
- * remote CPUs are nearly ready to execute func or are or have executed.
- *
- * You must not call this function with disabled interrupts or from a
- * hardware interrupt handler or from a bottom half handler.
- * Actually there are a few legal cases, like panic.
- */
-int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
-                       int wait)
-{
-       spin_lock(&call_lock);
-       __smp_call_function(func,info,nonatomic,wait);
-       spin_unlock(&call_lock);
-       return 0;
-}
-EXPORT_SYMBOL(smp_call_function);
-
-static void stop_this_cpu(void *dummy)
-{
-       local_irq_disable();
-       /*
-        * Remove this CPU:
-        */
-       cpu_clear(smp_processor_id(), cpu_online_map);
-       disable_local_APIC();
-       for (;;) 
-               halt();
-} 
-
-void smp_send_stop(void)
-{
-       int nolock;
-       unsigned long flags;
-
-       if (reboot_force)
-               return;
-
-       /* Don't deadlock on the call lock in panic */
-       nolock = !spin_trylock(&call_lock);
-       local_irq_save(flags);
-       __smp_call_function(stop_this_cpu, NULL, 0, 0);
-       if (!nolock)
-               spin_unlock(&call_lock);
-       disable_local_APIC();
-       local_irq_restore(flags);
-}
-
-/*
- * Reschedule call back. Nothing to do,
- * all the work is done automatically when
- * we return from the interrupt.
- */
-asmlinkage void smp_reschedule_interrupt(void)
-{
-       ack_APIC_irq();
-}
-
-asmlinkage void smp_call_function_interrupt(void)
-{
-       void (*func) (void *info) = call_data->func;
-       void *info = call_data->info;
-       int wait = call_data->wait;
-
-       ack_APIC_irq();
-       /*
-        * Notify initiating CPU that I've grabbed the data and am
-        * about to execute the function
-        */
-       mb();
-       atomic_inc(&call_data->started);
-       /*
-        * At this point the info structure may be out of scope unless wait==1
-        */
-       exit_idle();
-       irq_enter();
-       (*func)(info);
-       irq_exit();
-       if (wait) {
-               mb();
-               atomic_inc(&call_data->finished);
-       }
-}
-
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
deleted file mode 100644 (file)
index 32f5078..0000000
+++ /dev/null
@@ -1,1085 +0,0 @@
-/*
- *     x86 SMP booting functions
- *
- *     (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
- *     (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
- *     Copyright 2001 Andi Kleen, SuSE Labs.
- *
- *     Much of the core SMP work is based on previous work by Thomas Radke, to
- *     whom a great many thanks are extended.
- *
- *     Thanks to Intel for making available several different Pentium,
- *     Pentium Pro and Pentium-II/Xeon MP machines.
- *     Original development of Linux SMP code supported by Caldera.
- *
- *     This code is released under the GNU General Public License version 2
- *
- *     Fixes
- *             Felix Koop      :       NR_CPUS used properly
- *             Jose Renau      :       Handle single CPU case.
- *             Alan Cox        :       By repeated request 8) - Total BogoMIP report.
- *             Greg Wright     :       Fix for kernel stacks panic.
- *             Erich Boleyn    :       MP v1.4 and additional changes.
- *     Matthias Sattler        :       Changes for 2.1 kernel map.
- *     Michel Lespinasse       :       Changes for 2.1 kernel map.
- *     Michael Chastain        :       Change trampoline.S to gnu as.
- *             Alan Cox        :       Dumb bug: 'B' step PPro's are fine
- *             Ingo Molnar     :       Added APIC timers, based on code
- *                                     from Jose Renau
- *             Ingo Molnar     :       various cleanups and rewrites
- *             Tigran Aivazian :       fixed "0.00 in /proc/uptime on SMP" bug.
- *     Maciej W. Rozycki       :       Bits for genuine 82489DX APICs
- *     Andi Kleen              :       Changed for SMP boot into long mode.
- *             Rusty Russell   :       Hacked into shape for new "hotplug" boot process.
- *      Andi Kleen              :       Converted to new state machine.
- *                                     Various cleanups.
- *                                     Probably mostly hotplug CPU ready now.
- *     Ashok Raj                       : CPU hotplug support
- */
-
-
-#include <linux/init.h>
-
-#include <linux/mm.h>
-#include <linux/kernel_stat.h>
-#include <linux/bootmem.h>
-#include <linux/thread_info.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/mc146818rtc.h>
-#include <linux/smp.h>
-#include <linux/kdebug.h>
-
-#include <asm/mtrr.h>
-#include <asm/pgalloc.h>
-#include <asm/desc.h>
-#include <asm/tlbflush.h>
-#include <asm/proto.h>
-#include <asm/nmi.h>
-#include <asm/irq.h>
-#include <asm/hw_irq.h>
-#include <asm/numa.h>
-
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
-EXPORT_SYMBOL(smp_num_siblings);
-
-/* Last level cache ID of each logical CPU */
-u8 cpu_llc_id[NR_CPUS] __cpuinitdata  = {[0 ... NR_CPUS-1] = BAD_APICID};
-
-/* Bitmask of currently online CPUs */
-cpumask_t cpu_online_map __read_mostly;
-
-EXPORT_SYMBOL(cpu_online_map);
-
-/*
- * Private maps to synchronize booting between AP and BP.
- * Probably not needed anymore, but it makes for easier debugging. -AK
- */
-cpumask_t cpu_callin_map;
-cpumask_t cpu_callout_map;
-EXPORT_SYMBOL(cpu_callout_map);
-
-cpumask_t cpu_possible_map;
-EXPORT_SYMBOL(cpu_possible_map);
-
-/* Per CPU bogomips and other parameters */
-struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
-EXPORT_SYMBOL(cpu_data);
-
-/* Set when the idlers are all forked */
-int smp_threads_ready;
-
-/* representing HT siblings of each logical CPU */
-cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
-EXPORT_SYMBOL(cpu_sibling_map);
-
-/* representing HT and core siblings of each logical CPU */
-cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
-EXPORT_SYMBOL(cpu_core_map);
-
-/*
- * Trampoline 80x86 program as an array.
- */
-
-extern unsigned char trampoline_data[];
-extern unsigned char trampoline_end[];
-
-/* State of each CPU */
-DEFINE_PER_CPU(int, cpu_state) = { 0 };
-
-/*
- * Store all idle threads, this can be reused instead of creating
- * a new thread. Also avoids complicated thread destroy functionality
- * for idle threads.
- */
-struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
-
-#define get_idle_for_cpu(x)     (idle_thread_array[(x)])
-#define set_idle_for_cpu(x,p)   (idle_thread_array[(x)] = (p))
-
-/*
- * Currently trivial. Write the real->protected mode
- * bootstrap into the page concerned. The caller
- * has made sure it's suitably aligned.
- */
-
-static unsigned long __cpuinit setup_trampoline(void)
-{
-       void *tramp = __va(SMP_TRAMPOLINE_BASE); 
-       memcpy(tramp, trampoline_data, trampoline_end - trampoline_data);
-       return virt_to_phys(tramp);
-}
-
-/*
- * The bootstrap kernel entry code has set these up. Save them for
- * a given CPU
- */
-
-static void __cpuinit smp_store_cpu_info(int id)
-{
-       struct cpuinfo_x86 *c = cpu_data + id;
-
-       *c = boot_cpu_data;
-       identify_cpu(c);
-       print_cpu_info(c);
-}
-
-static atomic_t init_deasserted __cpuinitdata;
-
-/*
- * Report back to the Boot Processor.
- * Running on AP.
- */
-void __cpuinit smp_callin(void)
-{
-       int cpuid, phys_id;
-       unsigned long timeout;
-
-       /*
-        * If waken up by an INIT in an 82489DX configuration
-        * we may get here before an INIT-deassert IPI reaches
-        * our local APIC.  We have to wait for the IPI or we'll
-        * lock up on an APIC access.
-        */
-       while (!atomic_read(&init_deasserted))
-               cpu_relax();
-
-       /*
-        * (This works even if the APIC is not enabled.)
-        */
-       phys_id = GET_APIC_ID(apic_read(APIC_ID));
-       cpuid = smp_processor_id();
-       if (cpu_isset(cpuid, cpu_callin_map)) {
-               panic("smp_callin: phys CPU#%d, CPU#%d already present??\n",
-                                       phys_id, cpuid);
-       }
-       Dprintk("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id);
-
-       /*
-        * STARTUP IPIs are fragile beasts as they might sometimes
-        * trigger some glue motherboard logic. Complete APIC bus
-        * silence for 1 second, this overestimates the time the
-        * boot CPU is spending to send the up to 2 STARTUP IPIs
-        * by a factor of two. This should be enough.
-        */
-
-       /*
-        * Waiting 2s total for startup (udelay is not yet working)
-        */
-       timeout = jiffies + 2*HZ;
-       while (time_before(jiffies, timeout)) {
-               /*
-                * Has the boot CPU finished it's STARTUP sequence?
-                */
-               if (cpu_isset(cpuid, cpu_callout_map))
-                       break;
-               cpu_relax();
-       }
-
-       if (!time_before(jiffies, timeout)) {
-               panic("smp_callin: CPU%d started up but did not get a callout!\n",
-                       cpuid);
-       }
-
-       /*
-        * the boot CPU has finished the init stage and is spinning
-        * on callin_map until we finish. We are free to set up this
-        * CPU, first the APIC. (this is probably redundant on most
-        * boards)
-        */
-
-       Dprintk("CALLIN, before setup_local_APIC().\n");
-       setup_local_APIC();
-
-       /*
-        * Get our bogomips.
-        *
-        * Need to enable IRQs because it can take longer and then
-        * the NMI watchdog might kill us.
-        */
-       local_irq_enable();
-       calibrate_delay();
-       local_irq_disable();
-       Dprintk("Stack at about %p\n",&cpuid);
-
-       disable_APIC_timer();
-
-       /*
-        * Save our processor parameters
-        */
-       smp_store_cpu_info(cpuid);
-
-       /*
-        * Allow the master to continue.
-        */
-       cpu_set(cpuid, cpu_callin_map);
-}
-
-/* maps the cpu to the sched domain representing multi-core */
-cpumask_t cpu_coregroup_map(int cpu)
-{
-       struct cpuinfo_x86 *c = cpu_data + cpu;
-       /*
-        * For perf, we return last level cache shared map.
-        * And for power savings, we return cpu_core_map
-        */
-       if (sched_mc_power_savings || sched_smt_power_savings)
-               return cpu_core_map[cpu];
-       else
-               return c->llc_shared_map;
-}
-
-/* representing cpus for which sibling maps can be computed */
-static cpumask_t cpu_sibling_setup_map;
-
-static inline void set_cpu_sibling_map(int cpu)
-{
-       int i;
-       struct cpuinfo_x86 *c = cpu_data;
-
-       cpu_set(cpu, cpu_sibling_setup_map);
-
-       if (smp_num_siblings > 1) {
-               for_each_cpu_mask(i, cpu_sibling_setup_map) {
-                       if (c[cpu].phys_proc_id == c[i].phys_proc_id &&
-                           c[cpu].cpu_core_id == c[i].cpu_core_id) {
-                               cpu_set(i, cpu_sibling_map[cpu]);
-                               cpu_set(cpu, cpu_sibling_map[i]);
-                               cpu_set(i, cpu_core_map[cpu]);
-                               cpu_set(cpu, cpu_core_map[i]);
-                               cpu_set(i, c[cpu].llc_shared_map);
-                               cpu_set(cpu, c[i].llc_shared_map);
-                       }
-               }
-       } else {
-               cpu_set(cpu, cpu_sibling_map[cpu]);
-       }
-
-       cpu_set(cpu, c[cpu].llc_shared_map);
-
-       if (current_cpu_data.x86_max_cores == 1) {
-               cpu_core_map[cpu] = cpu_sibling_map[cpu];
-               c[cpu].booted_cores = 1;
-               return;
-       }
-
-       for_each_cpu_mask(i, cpu_sibling_setup_map) {
-               if (cpu_llc_id[cpu] != BAD_APICID &&
-                   cpu_llc_id[cpu] == cpu_llc_id[i]) {
-                       cpu_set(i, c[cpu].llc_shared_map);
-                       cpu_set(cpu, c[i].llc_shared_map);
-               }
-               if (c[cpu].phys_proc_id == c[i].phys_proc_id) {
-                       cpu_set(i, cpu_core_map[cpu]);
-                       cpu_set(cpu, cpu_core_map[i]);
-                       /*
-                        *  Does this new cpu bringup a new core?
-                        */
-                       if (cpus_weight(cpu_sibling_map[cpu]) == 1) {
-                               /*
-                                * for each core in package, increment
-                                * the booted_cores for this new cpu
-                                */
-                               if (first_cpu(cpu_sibling_map[i]) == i)
-                                       c[cpu].booted_cores++;
-                               /*
-                                * increment the core count for all
-                                * the other cpus in this package
-                                */
-                               if (i != cpu)
-                                       c[i].booted_cores++;
-                       } else if (i != cpu && !c[cpu].booted_cores)
-                               c[cpu].booted_cores = c[i].booted_cores;
-               }
-       }
-}
-
-/*
- * Setup code on secondary processor (after comming out of the trampoline)
- */
-void __cpuinit start_secondary(void)
-{
-       /*
-        * Dont put anything before smp_callin(), SMP
-        * booting is too fragile that we want to limit the
-        * things done here to the most necessary things.
-        */
-       cpu_init();
-       preempt_disable();
-       smp_callin();
-
-       /* otherwise gcc will move up the smp_processor_id before the cpu_init */
-       barrier();
-
-       /*
-        * Check TSC sync first:
-        */
-       check_tsc_sync_target();
-
-       Dprintk("cpu %d: setting up apic clock\n", smp_processor_id());         
-       setup_secondary_APIC_clock();
-
-       Dprintk("cpu %d: enabling apic timer\n", smp_processor_id());
-
-       if (nmi_watchdog == NMI_IO_APIC) {
-               disable_8259A_irq(0);
-               enable_NMI_through_LVT0(NULL);
-               enable_8259A_irq(0);
-       }
-
-       enable_APIC_timer();
-
-       /*
-        * The sibling maps must be set before turing the online map on for
-        * this cpu
-        */
-       set_cpu_sibling_map(smp_processor_id());
-
-       /*
-        * We need to hold call_lock, so there is no inconsistency
-        * between the time smp_call_function() determines number of
-        * IPI receipients, and the time when the determination is made
-        * for which cpus receive the IPI in genapic_flat.c. Holding this
-        * lock helps us to not include this cpu in a currently in progress
-        * smp_call_function().
-        */
-       lock_ipi_call_lock();
-       spin_lock(&vector_lock);
-
-       /* Setup the per cpu irq handling data structures */
-       __setup_vector_irq(smp_processor_id());
-       /*
-        * Allow the master to continue.
-        */
-       cpu_set(smp_processor_id(), cpu_online_map);
-       per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
-       spin_unlock(&vector_lock);
-
-       unlock_ipi_call_lock();
-
-       cpu_idle();
-}
-
-extern volatile unsigned long init_rsp;
-extern void (*initial_code)(void);
-
-#ifdef APIC_DEBUG
-static void inquire_remote_apic(int apicid)
-{
-       unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 };
-       char *names[] = { "ID", "VERSION", "SPIV" };
-       int timeout;
-       unsigned int status;
-
-       printk(KERN_INFO "Inquiring remote APIC #%d...\n", apicid);
-
-       for (i = 0; i < sizeof(regs) / sizeof(*regs); i++) {
-               printk("... APIC #%d %s: ", apicid, names[i]);
-
-               /*
-                * Wait for idle.
-                */
-               status = safe_apic_wait_icr_idle();
-               if (status)
-                       printk("a previous APIC delivery may have failed\n");
-
-               apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
-               apic_write(APIC_ICR, APIC_DM_REMRD | regs[i]);
-
-               timeout = 0;
-               do {
-                       udelay(100);
-                       status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK;
-               } while (status == APIC_ICR_RR_INPROG && timeout++ < 1000);
-
-               switch (status) {
-               case APIC_ICR_RR_VALID:
-                       status = apic_read(APIC_RRR);
-                       printk("%08x\n", status);
-                       break;
-               default:
-                       printk("failed\n");
-               }
-       }
-}
-#endif
-
-/*
- * Kick the secondary to wake up.
- */
-static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int start_rip)
-{
-       unsigned long send_status, accept_status = 0;
-       int maxlvt, num_starts, j;
-
-       Dprintk("Asserting INIT.\n");
-
-       /*
-        * Turn INIT on target chip
-        */
-       apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
-
-       /*
-        * Send IPI
-        */
-       apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT
-                               | APIC_DM_INIT);
-
-       Dprintk("Waiting for send to finish...\n");
-       send_status = safe_apic_wait_icr_idle();
-
-       mdelay(10);
-
-       Dprintk("Deasserting INIT.\n");
-
-       /* Target chip */
-       apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
-
-       /* Send IPI */
-       apic_write(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
-
-       Dprintk("Waiting for send to finish...\n");
-       send_status = safe_apic_wait_icr_idle();
-
-       mb();
-       atomic_set(&init_deasserted, 1);
-
-       num_starts = 2;
-
-       /*
-        * Run STARTUP IPI loop.
-        */
-       Dprintk("#startup loops: %d.\n", num_starts);
-
-       maxlvt = get_maxlvt();
-
-       for (j = 1; j <= num_starts; j++) {
-               Dprintk("Sending STARTUP #%d.\n",j);
-               apic_write(APIC_ESR, 0);
-               apic_read(APIC_ESR);
-               Dprintk("After apic_write.\n");
-
-               /*
-                * STARTUP IPI
-                */
-
-               /* Target chip */
-               apic_write(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
-
-               /* Boot on the stack */
-               /* Kick the second */
-               apic_write(APIC_ICR, APIC_DM_STARTUP | (start_rip >> 12));
-
-               /*
-                * Give the other CPU some time to accept the IPI.
-                */
-               udelay(300);
-
-               Dprintk("Startup point 1.\n");
-
-               Dprintk("Waiting for send to finish...\n");
-               send_status = safe_apic_wait_icr_idle();
-
-               /*
-                * Give the other CPU some time to accept the IPI.
-                */
-               udelay(200);
-               /*
-                * Due to the Pentium erratum 3AP.
-                */
-               if (maxlvt > 3) {
-                       apic_write(APIC_ESR, 0);
-               }
-               accept_status = (apic_read(APIC_ESR) & 0xEF);
-               if (send_status || accept_status)
-                       break;
-       }
-       Dprintk("After Startup.\n");
-
-       if (send_status)
-               printk(KERN_ERR "APIC never delivered???\n");
-       if (accept_status)
-               printk(KERN_ERR "APIC delivery error (%lx).\n", accept_status);
-
-       return (send_status | accept_status);
-}
-
-struct create_idle {
-       struct work_struct work;
-       struct task_struct *idle;
-       struct completion done;
-       int cpu;
-};
-
-void do_fork_idle(struct work_struct *work)
-{
-       struct create_idle *c_idle =
-               container_of(work, struct create_idle, work);
-
-       c_idle->idle = fork_idle(c_idle->cpu);
-       complete(&c_idle->done);
-}
-
-/*
- * Boot one CPU.
- */
-static int __cpuinit do_boot_cpu(int cpu, int apicid)
-{
-       unsigned long boot_error;
-       int timeout;
-       unsigned long start_rip;
-       struct create_idle c_idle = {
-               .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
-               .cpu = cpu,
-               .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
-       };
-
-       /* allocate memory for gdts of secondary cpus. Hotplug is considered */
-       if (!cpu_gdt_descr[cpu].address &&
-               !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) {
-               printk(KERN_ERR "Failed to allocate GDT for CPU %d\n", cpu);
-               return -1;
-       }
-
-       /* Allocate node local memory for AP pdas */
-       if (cpu_pda(cpu) == &boot_cpu_pda[cpu]) {
-               struct x8664_pda *newpda, *pda;
-               int node = cpu_to_node(cpu);
-               pda = cpu_pda(cpu);
-               newpda = kmalloc_node(sizeof (struct x8664_pda), GFP_ATOMIC,
-                                     node);
-               if (newpda) {
-                       memcpy(newpda, pda, sizeof (struct x8664_pda));
-                       cpu_pda(cpu) = newpda;
-               } else
-                       printk(KERN_ERR
-               "Could not allocate node local PDA for CPU %d on node %d\n",
-                               cpu, node);
-       }
-
-       alternatives_smp_switch(1);
-
-       c_idle.idle = get_idle_for_cpu(cpu);
-
-       if (c_idle.idle) {
-               c_idle.idle->thread.rsp = (unsigned long) (((struct pt_regs *)
-                       (THREAD_SIZE +  task_stack_page(c_idle.idle))) - 1);
-               init_idle(c_idle.idle, cpu);
-               goto do_rest;
-       }
-
-       /*
-        * During cold boot process, keventd thread is not spun up yet.
-        * When we do cpu hot-add, we create idle threads on the fly, we should
-        * not acquire any attributes from the calling context. Hence the clean
-        * way to create kernel_threads() is to do that from keventd().
-        * We do the current_is_keventd() due to the fact that ACPI notifier
-        * was also queuing to keventd() and when the caller is already running
-        * in context of keventd(), we would end up with locking up the keventd
-        * thread.
-        */
-       if (!keventd_up() || current_is_keventd())
-               c_idle.work.func(&c_idle.work);
-       else {
-               schedule_work(&c_idle.work);
-               wait_for_completion(&c_idle.done);
-       }
-
-       if (IS_ERR(c_idle.idle)) {
-               printk("failed fork for CPU %d\n", cpu);
-               return PTR_ERR(c_idle.idle);
-       }
-
-       set_idle_for_cpu(cpu, c_idle.idle);
-
-do_rest:
-
-       cpu_pda(cpu)->pcurrent = c_idle.idle;
-
-       start_rip = setup_trampoline();
-
-       init_rsp = c_idle.idle->thread.rsp;
-       per_cpu(init_tss,cpu).rsp0 = init_rsp;
-       initial_code = start_secondary;
-       clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
-
-       printk(KERN_INFO "Booting processor %d/%d APIC 0x%x\n", cpu,
-               cpus_weight(cpu_present_map),
-               apicid);
-
-       /*
-        * This grunge runs the startup process for
-        * the targeted processor.
-        */
-
-       atomic_set(&init_deasserted, 0);
-
-       Dprintk("Setting warm reset code and vector.\n");
-
-       CMOS_WRITE(0xa, 0xf);
-       local_flush_tlb();
-       Dprintk("1.\n");
-       *((volatile unsigned short *) phys_to_virt(0x469)) = start_rip >> 4;
-       Dprintk("2.\n");
-       *((volatile unsigned short *) phys_to_virt(0x467)) = start_rip & 0xf;
-       Dprintk("3.\n");
-
-       /*
-        * Be paranoid about clearing APIC errors.
-        */
-       apic_write(APIC_ESR, 0);
-       apic_read(APIC_ESR);
-
-       /*
-        * Status is now clean
-        */
-       boot_error = 0;
-
-       /*
-        * Starting actual IPI sequence...
-        */
-       boot_error = wakeup_secondary_via_INIT(apicid, start_rip);
-
-       if (!boot_error) {
-               /*
-                * allow APs to start initializing.
-                */
-               Dprintk("Before Callout %d.\n", cpu);
-               cpu_set(cpu, cpu_callout_map);
-               Dprintk("After Callout %d.\n", cpu);
-
-               /*
-                * Wait 5s total for a response
-                */
-               for (timeout = 0; timeout < 50000; timeout++) {
-                       if (cpu_isset(cpu, cpu_callin_map))
-                               break;  /* It has booted */
-                       udelay(100);
-               }
-
-               if (cpu_isset(cpu, cpu_callin_map)) {
-                       /* number CPUs logically, starting from 1 (BSP is 0) */
-                       Dprintk("CPU has booted.\n");
-               } else {
-                       boot_error = 1;
-                       if (*((volatile unsigned char *)phys_to_virt(SMP_TRAMPOLINE_BASE))
-                                       == 0xA5)
-                               /* trampoline started but...? */
-                               printk("Stuck ??\n");
-                       else
-                               /* trampoline code not run */
-                               printk("Not responding.\n");
-#ifdef APIC_DEBUG
-                       inquire_remote_apic(apicid);
-#endif
-               }
-       }
-       if (boot_error) {
-               cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */
-               clear_bit(cpu, &cpu_initialized); /* was set by cpu_init() */
-               clear_node_cpumask(cpu); /* was set by numa_add_cpu */
-               cpu_clear(cpu, cpu_present_map);
-               cpu_clear(cpu, cpu_possible_map);
-               x86_cpu_to_apicid[cpu] = BAD_APICID;
-               x86_cpu_to_log_apicid[cpu] = BAD_APICID;
-               return -EIO;
-       }
-
-       return 0;
-}
-
-cycles_t cacheflush_time;
-unsigned long cache_decay_ticks;
-
-/*
- * Cleanup possible dangling ends...
- */
-static __cpuinit void smp_cleanup_boot(void)
-{
-       /*
-        * Paranoid:  Set warm reset code and vector here back
-        * to default values.
-        */
-       CMOS_WRITE(0, 0xf);
-
-       /*
-        * Reset trampoline flag
-        */
-       *((volatile int *) phys_to_virt(0x467)) = 0;
-}
-
-/*
- * Fall back to non SMP mode after errors.
- *
- * RED-PEN audit/test this more. I bet there is more state messed up here.
- */
-static __init void disable_smp(void)
-{
-       cpu_present_map = cpumask_of_cpu(0);
-       cpu_possible_map = cpumask_of_cpu(0);
-       if (smp_found_config)
-               phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
-       else
-               phys_cpu_present_map = physid_mask_of_physid(0);
-       cpu_set(0, cpu_sibling_map[0]);
-       cpu_set(0, cpu_core_map[0]);
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-
-int additional_cpus __initdata = -1;
-
-/*
- * cpu_possible_map should be static, it cannot change as cpu's
- * are onlined, or offlined. The reason is per-cpu data-structures
- * are allocated by some modules at init time, and dont expect to
- * do this dynamically on cpu arrival/departure.
- * cpu_present_map on the other hand can change dynamically.
- * In case when cpu_hotplug is not compiled, then we resort to current
- * behaviour, which is cpu_possible == cpu_present.
- * - Ashok Raj
- *
- * Three ways to find out the number of additional hotplug CPUs:
- * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
- * - The user can overwrite it with additional_cpus=NUM
- * - Otherwise don't reserve additional CPUs.
- * We do this because additional CPUs waste a lot of memory.
- * -AK
- */
-__init void prefill_possible_map(void)
-{
-       int i;
-       int possible;
-
-       if (additional_cpus == -1) {
-               if (disabled_cpus > 0)
-                       additional_cpus = disabled_cpus;
-               else
-                       additional_cpus = 0;
-       }
-       possible = num_processors + additional_cpus;
-       if (possible > NR_CPUS) 
-               possible = NR_CPUS;
-
-       printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
-               possible,
-               max_t(int, possible - num_processors, 0));
-
-       for (i = 0; i < possible; i++)
-               cpu_set(i, cpu_possible_map);
-}
-#endif
-
-/*
- * Various sanity checks.
- */
-static int __init smp_sanity_check(unsigned max_cpus)
-{
-       if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
-               printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
-                      hard_smp_processor_id());
-               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
-       }
-
-       /*
-        * If we couldn't find an SMP configuration at boot time,
-        * get out of here now!
-        */
-       if (!smp_found_config) {
-               printk(KERN_NOTICE "SMP motherboard not detected.\n");
-               disable_smp();
-               if (APIC_init_uniprocessor())
-                       printk(KERN_NOTICE "Local APIC not detected."
-                                          " Using dummy APIC emulation.\n");
-               return -1;
-       }
-
-       /*
-        * Should not be necessary because the MP table should list the boot
-        * CPU too, but we do it for the sake of robustness anyway.
-        */
-       if (!physid_isset(boot_cpu_id, phys_cpu_present_map)) {
-               printk(KERN_NOTICE "weird, boot CPU (#%d) not listed by the BIOS.\n",
-                                                                boot_cpu_id);
-               physid_set(hard_smp_processor_id(), phys_cpu_present_map);
-       }
-
-       /*
-        * If we couldn't find a local APIC, then get out of here now!
-        */
-       if (!cpu_has_apic) {
-               printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
-                       boot_cpu_id);
-               printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
-               nr_ioapics = 0;
-               return -1;
-       }
-
-       /*
-        * If SMP should be disabled, then really disable it!
-        */
-       if (!max_cpus) {
-               printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
-               nr_ioapics = 0;
-               return -1;
-       }
-
-       return 0;
-}
-
-/*
- * Prepare for SMP bootup.  The MP table or ACPI has been read
- * earlier.  Just do some sanity checking here and enable APIC mode.
- */
-void __init smp_prepare_cpus(unsigned int max_cpus)
-{
-       nmi_watchdog_default();
-       current_cpu_data = boot_cpu_data;
-       current_thread_info()->cpu = 0;  /* needed? */
-       set_cpu_sibling_map(0);
-
-       if (smp_sanity_check(max_cpus) < 0) {
-               printk(KERN_INFO "SMP disabled\n");
-               disable_smp();
-               return;
-       }
-
-
-       /*
-        * Switch from PIC to APIC mode.
-        */
-       setup_local_APIC();
-
-       if (GET_APIC_ID(apic_read(APIC_ID)) != boot_cpu_id) {
-               panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
-                     GET_APIC_ID(apic_read(APIC_ID)), boot_cpu_id);
-               /* Or can we switch back to PIC here? */
-       }
-
-       /*
-        * Now start the IO-APICs
-        */
-       if (!skip_ioapic_setup && nr_ioapics)
-               setup_IO_APIC();
-       else
-               nr_ioapics = 0;
-
-       /*
-        * Set up local APIC timer on boot CPU.
-        */
-
-       setup_boot_APIC_clock();
-}
-
-/*
- * Early setup to make printk work.
- */
-void __init smp_prepare_boot_cpu(void)
-{
-       int me = smp_processor_id();
-       cpu_set(me, cpu_online_map);
-       cpu_set(me, cpu_callout_map);
-       per_cpu(cpu_state, me) = CPU_ONLINE;
-}
-
-/*
- * Entry point to boot a CPU.
- */
-int __cpuinit __cpu_up(unsigned int cpu)
-{
-       int apicid = cpu_present_to_apicid(cpu);
-       unsigned long flags;
-       int err;
-
-       WARN_ON(irqs_disabled());
-
-       Dprintk("++++++++++++++++++++=_---CPU UP  %u\n", cpu);
-
-       if (apicid == BAD_APICID || apicid == boot_cpu_id ||
-           !physid_isset(apicid, phys_cpu_present_map)) {
-               printk("__cpu_up: bad cpu %d\n", cpu);
-               return -EINVAL;
-       }
-
-       /*
-        * Already booted CPU?
-        */
-       if (cpu_isset(cpu, cpu_callin_map)) {
-               Dprintk("do_boot_cpu %d Already started\n", cpu);
-               return -ENOSYS;
-       }
-
-       /*
-        * Save current MTRR state in case it was changed since early boot
-        * (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync:
-        */
-       mtrr_save_state();
-
-       per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
-       /* Boot it! */
-       err = do_boot_cpu(cpu, apicid);
-       if (err < 0) {
-               Dprintk("do_boot_cpu failed %d\n", err);
-               return err;
-       }
-
-       /* Unleash the CPU! */
-       Dprintk("waiting for cpu %d\n", cpu);
-
-       /*
-        * Make sure and check TSC sync:
-        */
-       local_irq_save(flags);
-       check_tsc_sync_source(cpu);
-       local_irq_restore(flags);
-
-       while (!cpu_isset(cpu, cpu_online_map))
-               cpu_relax();
-       err = 0;
-
-       return err;
-}
-
-/*
- * Finish the SMP boot.
- */
-void __init smp_cpus_done(unsigned int max_cpus)
-{
-       smp_cleanup_boot();
-       setup_ioapic_dest();
-       check_nmi_watchdog();
-}
-
-#ifdef CONFIG_HOTPLUG_CPU
-
-static void remove_siblinginfo(int cpu)
-{
-       int sibling;
-       struct cpuinfo_x86 *c = cpu_data;
-
-       for_each_cpu_mask(sibling, cpu_core_map[cpu]) {
-               cpu_clear(cpu, cpu_core_map[sibling]);
-               /*
-                * last thread sibling in this cpu core going down
-                */
-               if (cpus_weight(cpu_sibling_map[cpu]) == 1)
-                       c[sibling].booted_cores--;
-       }
-                       
-       for_each_cpu_mask(sibling, cpu_sibling_map[cpu])
-               cpu_clear(cpu, cpu_sibling_map[sibling]);
-       cpus_clear(cpu_sibling_map[cpu]);
-       cpus_clear(cpu_core_map[cpu]);
-       c[cpu].phys_proc_id = 0;
-       c[cpu].cpu_core_id = 0;
-       cpu_clear(cpu, cpu_sibling_setup_map);
-}
-
-void remove_cpu_from_maps(void)
-{
-       int cpu = smp_processor_id();
-
-       cpu_clear(cpu, cpu_callout_map);
-       cpu_clear(cpu, cpu_callin_map);
-       clear_bit(cpu, &cpu_initialized); /* was set by cpu_init() */
-       clear_node_cpumask(cpu);
-}
-
-int __cpu_disable(void)
-{
-       int cpu = smp_processor_id();
-
-       /*
-        * Perhaps use cpufreq to drop frequency, but that could go
-        * into generic code.
-        *
-        * We won't take down the boot processor on i386 due to some
-        * interrupts only being able to be serviced by the BSP.
-        * Especially so if we're not using an IOAPIC   -zwane
-        */
-       if (cpu == 0)
-               return -EBUSY;
-
-       if (nmi_watchdog == NMI_LOCAL_APIC)
-               stop_apic_nmi_watchdog(NULL);
-       clear_local_APIC();
-
-       /*
-        * HACK:
-        * Allow any queued timer interrupts to get serviced
-        * This is only a temporary solution until we cleanup
-        * fixup_irqs as we do for IA64.
-        */
-       local_irq_enable();
-       mdelay(1);
-
-       local_irq_disable();
-       remove_siblinginfo(cpu);
-
-       spin_lock(&vector_lock);
-       /* It's now safe to remove this processor from the online map */
-       cpu_clear(cpu, cpu_online_map);
-       spin_unlock(&vector_lock);
-       remove_cpu_from_maps();
-       fixup_irqs(cpu_online_map);
-       return 0;
-}
-
-void __cpu_die(unsigned int cpu)
-{
-       /* We don't do anything here: idle task is faking death itself. */
-       unsigned int i;
-
-       for (i = 0; i < 10; i++) {
-               /* They ack this in play_dead by setting CPU_DEAD */
-               if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
-                       printk ("CPU %d is now offline\n", cpu);
-                       if (1 == num_online_cpus())
-                               alternatives_smp_switch(0);
-                       return;
-               }
-               msleep(100);
-       }
-       printk(KERN_ERR "CPU %u didn't die...\n", cpu);
-}
-
-static __init int setup_additional_cpus(char *s)
-{
-       return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL;
-}
-early_param("additional_cpus", setup_additional_cpus);
-
-#else /* ... !CONFIG_HOTPLUG_CPU */
-
-int __cpu_disable(void)
-{
-       return -ENOSYS;
-}
-
-void __cpu_die(unsigned int cpu)
-{
-       /* We said "no" in __cpu_disable */
-       BUG();
-}
-#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/x86_64/kernel/stacktrace.c b/arch/x86_64/kernel/stacktrace.c
deleted file mode 100644 (file)
index cb91091..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * arch/x86_64/kernel/stacktrace.c
- *
- * Stack trace management functions
- *
- *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
- */
-#include <linux/sched.h>
-#include <linux/stacktrace.h>
-#include <linux/module.h>
-#include <asm/stacktrace.h>
-
-static void save_stack_warning(void *data, char *msg)
-{
-}
-
-static void
-save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
-{
-}
-
-static int save_stack_stack(void *data, char *name)
-{
-       return -1;
-}
-
-static void save_stack_address(void *data, unsigned long addr)
-{
-       struct stack_trace *trace = (struct stack_trace *)data;
-       if (trace->skip > 0) {
-               trace->skip--;
-               return;
-       }
-       if (trace->nr_entries < trace->max_entries)
-               trace->entries[trace->nr_entries++] = addr;
-}
-
-static struct stacktrace_ops save_stack_ops = {
-       .warning = save_stack_warning,
-       .warning_symbol = save_stack_warning_symbol,
-       .stack = save_stack_stack,
-       .address = save_stack_address,
-};
-
-/*
- * Save stack-backtrace addresses into a stack_trace buffer.
- */
-void save_stack_trace(struct stack_trace *trace)
-{
-       dump_trace(current, NULL, NULL, &save_stack_ops, trace);
-       if (trace->nr_entries < trace->max_entries)
-               trace->entries[trace->nr_entries++] = ULONG_MAX;
-}
-EXPORT_SYMBOL(save_stack_trace);
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
deleted file mode 100644 (file)
index 573c0a6..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Suspend support specific for i386.
- *
- * Distribute under GPLv2
- *
- * Copyright (c) 2002 Pavel Machek <pavel@suse.cz>
- * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
- */
-
-#include <linux/smp.h>
-#include <linux/suspend.h>
-#include <asm/proto.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/mtrr.h>
-
-/* References to section boundaries */
-extern const void __nosave_begin, __nosave_end;
-
-struct saved_context saved_context;
-
-unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx;
-unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi;
-unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11;
-unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15;
-unsigned long saved_context_eflags;
-
-void __save_processor_state(struct saved_context *ctxt)
-{
-       kernel_fpu_begin();
-
-       /*
-        * descriptor tables
-        */
-       asm volatile ("sgdt %0" : "=m" (ctxt->gdt_limit));
-       asm volatile ("sidt %0" : "=m" (ctxt->idt_limit));
-       asm volatile ("str %0"  : "=m" (ctxt->tr));
-
-       /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
-       /*
-        * segment registers
-        */
-       asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds));
-       asm volatile ("movw %%es, %0" : "=m" (ctxt->es));
-       asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs));
-       asm volatile ("movw %%gs, %0" : "=m" (ctxt->gs));
-       asm volatile ("movw %%ss, %0" : "=m" (ctxt->ss));
-
-       rdmsrl(MSR_FS_BASE, ctxt->fs_base);
-       rdmsrl(MSR_GS_BASE, ctxt->gs_base);
-       rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
-       mtrr_save_fixed_ranges(NULL);
-
-       /*
-        * control registers 
-        */
-       rdmsrl(MSR_EFER, ctxt->efer);
-       ctxt->cr0 = read_cr0();
-       ctxt->cr2 = read_cr2();
-       ctxt->cr3 = read_cr3();
-       ctxt->cr4 = read_cr4();
-       ctxt->cr8 = read_cr8();
-}
-
-void save_processor_state(void)
-{
-       __save_processor_state(&saved_context);
-}
-
-static void do_fpu_end(void)
-{
-       /*
-        * Restore FPU regs if necessary
-        */
-       kernel_fpu_end();
-}
-
-void __restore_processor_state(struct saved_context *ctxt)
-{
-       /*
-        * control registers
-        */
-       wrmsrl(MSR_EFER, ctxt->efer);
-       write_cr8(ctxt->cr8);
-       write_cr4(ctxt->cr4);
-       write_cr3(ctxt->cr3);
-       write_cr2(ctxt->cr2);
-       write_cr0(ctxt->cr0);
-
-       /*
-        * now restore the descriptor tables to their proper values
-        * ltr is done i fix_processor_context().
-        */
-       asm volatile ("lgdt %0" :: "m" (ctxt->gdt_limit));
-       asm volatile ("lidt %0" :: "m" (ctxt->idt_limit));
-
-       /*
-        * segment registers
-        */
-       asm volatile ("movw %0, %%ds" :: "r" (ctxt->ds));
-       asm volatile ("movw %0, %%es" :: "r" (ctxt->es));
-       asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs));
-       load_gs_index(ctxt->gs);
-       asm volatile ("movw %0, %%ss" :: "r" (ctxt->ss));
-
-       wrmsrl(MSR_FS_BASE, ctxt->fs_base);
-       wrmsrl(MSR_GS_BASE, ctxt->gs_base);
-       wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base);
-
-       fix_processor_context();
-
-       do_fpu_end();
-       mtrr_ap_init();
-}
-
-void restore_processor_state(void)
-{
-       __restore_processor_state(&saved_context);
-}
-
-void fix_processor_context(void)
-{
-       int cpu = smp_processor_id();
-       struct tss_struct *t = &per_cpu(init_tss, cpu);
-
-       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. */
-
-       cpu_gdt(cpu)[GDT_ENTRY_TSS].type = 9;
-
-       syscall_init();                         /* This sets MSR_*STAR and related */
-       load_TR_desc();                         /* This does ltr */
-       load_LDT(&current->active_mm->context); /* This does lldt */
-
-       /*
-        * Now maybe reload the debug registers
-        */
-       if (current->thread.debugreg7){
-                loaddebug(&current->thread, 0);
-                loaddebug(&current->thread, 1);
-                loaddebug(&current->thread, 2);
-                loaddebug(&current->thread, 3);
-                /* no 4 and 5 */
-                loaddebug(&current->thread, 6);
-                loaddebug(&current->thread, 7);
-       }
-
-}
-
-#ifdef CONFIG_HIBERNATION
-/* Defined in arch/x86_64/kernel/suspend_asm.S */
-extern int restore_image(void);
-
-pgd_t *temp_level4_pgt;
-
-static int res_phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
-{
-       long i, j;
-
-       i = pud_index(address);
-       pud = pud + i;
-       for (; i < PTRS_PER_PUD; pud++, i++) {
-               unsigned long paddr;
-               pmd_t *pmd;
-
-               paddr = address + i*PUD_SIZE;
-               if (paddr >= end)
-                       break;
-
-               pmd = (pmd_t *)get_safe_page(GFP_ATOMIC);
-               if (!pmd)
-                       return -ENOMEM;
-               set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
-               for (j = 0; j < PTRS_PER_PMD; pmd++, j++, paddr += PMD_SIZE) {
-                       unsigned long pe;
-
-                       if (paddr >= end)
-                               break;
-                       pe = _PAGE_NX | _PAGE_PSE | _KERNPG_TABLE | paddr;
-                       pe &= __supported_pte_mask;
-                       set_pmd(pmd, __pmd(pe));
-               }
-       }
-       return 0;
-}
-
-static int set_up_temporary_mappings(void)
-{
-       unsigned long start, end, next;
-       int error;
-
-       temp_level4_pgt = (pgd_t *)get_safe_page(GFP_ATOMIC);
-       if (!temp_level4_pgt)
-               return -ENOMEM;
-
-       /* It is safe to reuse the original kernel mapping */
-       set_pgd(temp_level4_pgt + pgd_index(__START_KERNEL_map),
-               init_level4_pgt[pgd_index(__START_KERNEL_map)]);
-
-       /* Set up the direct mapping from scratch */
-       start = (unsigned long)pfn_to_kaddr(0);
-       end = (unsigned long)pfn_to_kaddr(end_pfn);
-
-       for (; start < end; start = next) {
-               pud_t *pud = (pud_t *)get_safe_page(GFP_ATOMIC);
-               if (!pud)
-                       return -ENOMEM;
-               next = start + PGDIR_SIZE;
-               if (next > end)
-                       next = end;
-               if ((error = res_phys_pud_init(pud, __pa(start), __pa(next))))
-                       return error;
-               set_pgd(temp_level4_pgt + pgd_index(start),
-                       mk_kernel_pgd(__pa(pud)));
-       }
-       return 0;
-}
-
-int swsusp_arch_resume(void)
-{
-       int error;
-
-       /* We have got enough memory and from now on we cannot recover */
-       if ((error = set_up_temporary_mappings()))
-               return error;
-       restore_image();
-       return 0;
-}
-
-/*
- *     pfn_is_nosave - check if given pfn is in the 'nosave' section
- */
-
-int pfn_is_nosave(unsigned long pfn)
-{
-       unsigned long nosave_begin_pfn = __pa_symbol(&__nosave_begin) >> PAGE_SHIFT;
-       unsigned long nosave_end_pfn = PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT;
-       return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
-}
-#endif /* CONFIG_HIBERNATION */
diff --git a/arch/x86_64/kernel/suspend_asm.S b/arch/x86_64/kernel/suspend_asm.S
deleted file mode 100644 (file)
index 16d183f..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright 2004,2005 Pavel Machek <pavel@suse.cz>, Andi Kleen <ak@suse.de>, Rafael J. Wysocki <rjw@sisk.pl>
- *
- * Distribute under GPLv2.
- *
- * swsusp_arch_resume may not use any stack, nor any variable that is
- * not "NoSave" during copying pages:
- *
- * Its rewriting one kernel image with another. What is stack in "old"
- * image could very well be data page in "new" image, and overwriting
- * your own stack under you is bad idea.
- */
-       
-       .text
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/page.h>
-#include <asm/asm-offsets.h>
-
-ENTRY(swsusp_arch_suspend)
-
-       movq %rsp, saved_context_esp(%rip)
-       movq %rax, saved_context_eax(%rip)
-       movq %rbx, saved_context_ebx(%rip)
-       movq %rcx, saved_context_ecx(%rip)
-       movq %rdx, saved_context_edx(%rip)
-       movq %rbp, saved_context_ebp(%rip)
-       movq %rsi, saved_context_esi(%rip)
-       movq %rdi, saved_context_edi(%rip)
-       movq %r8,  saved_context_r08(%rip)
-       movq %r9,  saved_context_r09(%rip)
-       movq %r10, saved_context_r10(%rip)
-       movq %r11, saved_context_r11(%rip)
-       movq %r12, saved_context_r12(%rip)
-       movq %r13, saved_context_r13(%rip)
-       movq %r14, saved_context_r14(%rip)
-       movq %r15, saved_context_r15(%rip)
-       pushfq ; popq saved_context_eflags(%rip)
-
-       call swsusp_save
-       ret
-
-ENTRY(restore_image)
-       /* switch to temporary page tables */
-       movq    $__PAGE_OFFSET, %rdx
-       movq    temp_level4_pgt(%rip), %rax
-       subq    %rdx, %rax
-       movq    %rax, %cr3
-       /* Flush TLB */
-       movq    mmu_cr4_features(%rip), %rax
-       movq    %rax, %rdx
-       andq    $~(1<<7), %rdx  # PGE
-       movq    %rdx, %cr4;  # turn off PGE
-       movq    %cr3, %rcx;  # flush TLB
-       movq    %rcx, %cr3;
-       movq    %rax, %cr4;  # turn PGE back on
-
-       movq    restore_pblist(%rip), %rdx
-loop:
-       testq   %rdx, %rdx
-       jz      done
-
-       /* get addresses from the pbe and copy the page */
-       movq    pbe_address(%rdx), %rsi
-       movq    pbe_orig_address(%rdx), %rdi
-       movq    $512, %rcx
-       rep
-       movsq
-
-       /* progress to the next pbe */
-       movq    pbe_next(%rdx), %rdx
-       jmp     loop
-done:
-       /* go back to the original page tables */
-       movq    $(init_level4_pgt - __START_KERNEL_map), %rax
-       addq    phys_base(%rip), %rax
-       movq    %rax, %cr3
-
-       /* Flush TLB, including "global" things (vmalloc) */
-       movq    mmu_cr4_features(%rip), %rax
-       movq    %rax, %rdx
-       andq    $~(1<<7), %rdx;  # PGE
-       movq    %rdx, %cr4;  # turn off PGE
-       movq    %cr3, %rcx;  # flush TLB
-       movq    %rcx, %cr3
-       movq    %rax, %cr4;  # turn PGE back on
-
-       movl    $24, %eax
-       movl    %eax, %ds
-
-       movq saved_context_esp(%rip), %rsp
-       movq saved_context_ebp(%rip), %rbp
-       /* Don't restore %rax, it must be 0 anyway */
-       movq saved_context_ebx(%rip), %rbx
-       movq saved_context_ecx(%rip), %rcx
-       movq saved_context_edx(%rip), %rdx
-       movq saved_context_esi(%rip), %rsi
-       movq saved_context_edi(%rip), %rdi
-       movq saved_context_r08(%rip), %r8
-       movq saved_context_r09(%rip), %r9
-       movq saved_context_r10(%rip), %r10
-       movq saved_context_r11(%rip), %r11
-       movq saved_context_r12(%rip), %r12
-       movq saved_context_r13(%rip), %r13
-       movq saved_context_r14(%rip), %r14
-       movq saved_context_r15(%rip), %r15
-       pushq saved_context_eflags(%rip) ; popfq
-
-       xorq    %rax, %rax
-
-       ret
diff --git a/arch/x86_64/kernel/sys_x86_64.c b/arch/x86_64/kernel/sys_x86_64.c
deleted file mode 100644 (file)
index 4770b7a..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * linux/arch/x86_64/kernel/sys_x86_64.c
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/syscalls.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/smp.h>
-#include <linux/sem.h>
-#include <linux/msg.h>
-#include <linux/shm.h>
-#include <linux/stat.h>
-#include <linux/mman.h>
-#include <linux/file.h>
-#include <linux/utsname.h>
-#include <linux/personality.h>
-
-#include <asm/uaccess.h>
-#include <asm/ia32.h>
-
-/*
- * sys_pipe() is the normal C calling standard for creating
- * a pipe. It's not the way Unix traditionally does this, though.
- */
-asmlinkage long sys_pipe(int __user *fildes)
-{
-       int fd[2];
-       int error;
-
-       error = do_pipe(fd);
-       if (!error) {
-               if (copy_to_user(fildes, fd, 2*sizeof(int)))
-                       error = -EFAULT;
-       }
-       return error;
-}
-
-asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
-       unsigned long fd, unsigned long off)
-{
-       long error;
-       struct file * file;
-
-       error = -EINVAL;
-       if (off & ~PAGE_MASK)
-               goto out;
-
-       error = -EBADF;
-       file = NULL;
-       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
-       if (!(flags & MAP_ANONYMOUS)) {
-               file = fget(fd);
-               if (!file)
-                       goto out;
-       }
-       down_write(&current->mm->mmap_sem);
-       error = do_mmap_pgoff(file, addr, len, prot, flags, off >> PAGE_SHIFT);
-       up_write(&current->mm->mmap_sem);
-
-       if (file)
-               fput(file);
-out:
-       return error;
-}
-
-static void find_start_end(unsigned long flags, unsigned long *begin,
-                          unsigned long *end)
-{
-       if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
-               /* This is usually used needed to map code in small
-                  model, so it needs to be in the first 31bit. Limit
-                  it to that.  This means we need to move the
-                  unmapped base down for this case. This can give
-                  conflicts with the heap, but we assume that glibc
-                  malloc knows how to fall back to mmap. Give it 1GB
-                  of playground for now. -AK */ 
-               *begin = 0x40000000; 
-               *end = 0x80000000;              
-       } else {
-               *begin = TASK_UNMAPPED_BASE;
-               *end = TASK_SIZE; 
-       }
-} 
-
-unsigned long
-arch_get_unmapped_area(struct file *filp, unsigned long addr,
-               unsigned long len, unsigned long pgoff, unsigned long flags)
-{
-       struct mm_struct *mm = current->mm;
-       struct vm_area_struct *vma;
-       unsigned long start_addr;
-       unsigned long begin, end;
-       
-       if (flags & MAP_FIXED)
-               return addr;
-
-       find_start_end(flags, &begin, &end); 
-
-       if (len > end)
-               return -ENOMEM;
-
-       if (addr) {
-               addr = PAGE_ALIGN(addr);
-               vma = find_vma(mm, addr);
-               if (end - len >= addr &&
-                   (!vma || addr + len <= vma->vm_start))
-                       return addr;
-       }
-       if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
-           && len <= mm->cached_hole_size) {
-               mm->cached_hole_size = 0;
-               mm->free_area_cache = begin;
-       }
-       addr = mm->free_area_cache;
-       if (addr < begin) 
-               addr = begin; 
-       start_addr = addr;
-
-full_search:
-       for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
-               /* At this point:  (!vma || addr < vma->vm_end). */
-               if (end - len < addr) {
-                       /*
-                        * Start a new search - just in case we missed
-                        * some holes.
-                        */
-                       if (start_addr != begin) {
-                               start_addr = addr = begin;
-                               mm->cached_hole_size = 0;
-                               goto full_search;
-                       }
-                       return -ENOMEM;
-               }
-               if (!vma || addr + len <= vma->vm_start) {
-                       /*
-                        * Remember the place where we stopped the search:
-                        */
-                       mm->free_area_cache = addr + len;
-                       return addr;
-               }
-               if (addr + mm->cached_hole_size < vma->vm_start)
-                       mm->cached_hole_size = vma->vm_start - addr;
-
-               addr = vma->vm_end;
-       }
-}
-
-asmlinkage long sys_uname(struct new_utsname __user * name)
-{
-       int err;
-       down_read(&uts_sem);
-       err = copy_to_user(name, utsname(), sizeof (*name));
-       up_read(&uts_sem);
-       if (personality(current->personality) == PER_LINUX32) 
-               err |= copy_to_user(&name->machine, "i686", 5);                 
-       return err ? -EFAULT : 0;
-}
diff --git a/arch/x86_64/kernel/syscall.c b/arch/x86_64/kernel/syscall.c
deleted file mode 100644 (file)
index 63d592c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* System call table for x86-64. */ 
-
-#include <linux/linkage.h>
-#include <linux/sys.h>
-#include <linux/cache.h>
-#include <asm/asm-offsets.h>
-
-#define __NO_STUBS
-
-#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ; 
-#undef _ASM_X86_64_UNISTD_H_
-#include <asm-x86_64/unistd.h>
-
-#undef __SYSCALL
-#define __SYSCALL(nr, sym) [ nr ] = sym, 
-#undef _ASM_X86_64_UNISTD_H_
-
-typedef void (*sys_call_ptr_t)(void); 
-
-extern void sys_ni_syscall(void);
-
-const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
-       /* Smells like a like a compiler bug -- it doesn't work when the & below is removed. */ 
-       [0 ... __NR_syscall_max] = &sys_ni_syscall,
-#include <asm-x86_64/unistd.h>
-};
diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
deleted file mode 100644 (file)
index e3f2569..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * This file manages the translation entries for the IBM Calgary IOMMU.
- *
- * Derived from arch/powerpc/platforms/pseries/iommu.c
- *
- * Copyright (C) IBM Corporation, 2006
- *
- * Author: Jon Mason <jdmason@us.ibm.com>
- * Author: Muli Ben-Yehuda <muli@il.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#include <linux/bootmem.h>
-#include <asm/tce.h>
-#include <asm/calgary.h>
-#include <asm/proto.h>
-
-/* flush a tce at 'tceaddr' to main memory */
-static inline void flush_tce(void* tceaddr)
-{
-       /* a single tce can't cross a cache line */
-       if (cpu_has_clflush)
-               asm volatile("clflush (%0)" :: "r" (tceaddr));
-       else
-               asm volatile("wbinvd":::"memory");
-}
-
-void tce_build(struct iommu_table *tbl, unsigned long index,
-       unsigned int npages, unsigned long uaddr, int direction)
-{
-       u64* tp;
-       u64 t;
-       u64 rpn;
-
-       t = (1 << TCE_READ_SHIFT);
-       if (direction != DMA_TO_DEVICE)
-               t |= (1 << TCE_WRITE_SHIFT);
-
-       tp = ((u64*)tbl->it_base) + index;
-
-       while (npages--) {
-               rpn = (virt_to_bus((void*)uaddr)) >> PAGE_SHIFT;
-               t &= ~TCE_RPN_MASK;
-               t |= (rpn << TCE_RPN_SHIFT);
-
-               *tp = cpu_to_be64(t);
-               flush_tce(tp);
-
-               uaddr += PAGE_SIZE;
-               tp++;
-       }
-}
-
-void tce_free(struct iommu_table *tbl, long index, unsigned int npages)
-{
-       u64* tp;
-
-       tp  = ((u64*)tbl->it_base) + index;
-
-       while (npages--) {
-               *tp = cpu_to_be64(0);
-               flush_tce(tp);
-               tp++;
-       }
-}
-
-static inline unsigned int table_size_to_number_of_entries(unsigned char size)
-{
-       /*
-        * size is the order of the table, 0-7
-        * smallest table is 8K entries, so shift result by 13 to
-        * multiply by 8K
-        */
-       return (1 << size) << 13;
-}
-
-static int tce_table_setparms(struct pci_dev *dev, struct iommu_table *tbl)
-{
-       unsigned int bitmapsz;
-       unsigned long bmppages;
-       int ret;
-
-       tbl->it_busno = dev->bus->number;
-
-       /* set the tce table size - measured in entries */
-       tbl->it_size = table_size_to_number_of_entries(specified_table_size);
-
-       /*
-        * number of bytes needed for the bitmap size in number of
-        * entries; we need one bit per entry
-        */
-       bitmapsz = tbl->it_size / BITS_PER_BYTE;
-       bmppages = __get_free_pages(GFP_KERNEL, get_order(bitmapsz));
-       if (!bmppages) {
-               printk(KERN_ERR "Calgary: cannot allocate bitmap\n");
-               ret = -ENOMEM;
-               goto done;
-       }
-
-       tbl->it_map = (unsigned long*)bmppages;
-
-       memset(tbl->it_map, 0, bitmapsz);
-
-       tbl->it_hint = 0;
-
-       spin_lock_init(&tbl->it_lock);
-
-       return 0;
-
-done:
-       return ret;
-}
-
-int __init build_tce_table(struct pci_dev *dev, void __iomem *bbar)
-{
-       struct iommu_table *tbl;
-       int ret;
-
-       if (pci_iommu(dev->bus)) {
-               printk(KERN_ERR "Calgary: dev %p has sysdata->iommu %p\n",
-                      dev, pci_iommu(dev->bus));
-               BUG();
-       }
-
-       tbl = kzalloc(sizeof(struct iommu_table), GFP_KERNEL);
-       if (!tbl) {
-               printk(KERN_ERR "Calgary: error allocating iommu_table\n");
-               ret = -ENOMEM;
-               goto done;
-       }
-
-       ret = tce_table_setparms(dev, tbl);
-       if (ret)
-               goto free_tbl;
-
-       tbl->bbar = bbar;
-
-       set_pci_iommu(dev->bus, tbl);
-
-       return 0;
-
-free_tbl:
-       kfree(tbl);
-done:
-       return ret;
-}
-
-void * __init alloc_tce_table(void)
-{
-       unsigned int size;
-
-       size = table_size_to_number_of_entries(specified_table_size);
-       size *= TCE_ENTRY_SIZE;
-
-       return __alloc_bootmem_low(size, size, 0);
-}
-
-void __init free_tce_table(void *tbl)
-{
-       unsigned int size;
-
-       if (!tbl)
-               return;
-
-       size = table_size_to_number_of_entries(specified_table_size);
-       size *= TCE_ENTRY_SIZE;
-
-       free_bootmem(__pa(tbl), size);
-}
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
deleted file mode 100644 (file)
index 6d48a4e..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- *  linux/arch/x86-64/kernel/time.c
- *
- *  "High Precision Event Timer" based timekeeping.
- *
- *  Copyright (c) 1991,1992,1995  Linus Torvalds
- *  Copyright (c) 1994  Alan Modra
- *  Copyright (c) 1995  Markus Kuhn
- *  Copyright (c) 1996  Ingo Molnar
- *  Copyright (c) 1998  Andrea Arcangeli
- *  Copyright (c) 2002,2006  Vojtech Pavlik
- *  Copyright (c) 2003  Andi Kleen
- *  RTC support code taken from arch/i386/kernel/timers/time_hpet.c
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/mc146818rtc.h>
-#include <linux/time.h>
-#include <linux/ioport.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/sysdev.h>
-#include <linux/bcd.h>
-#include <linux/notifier.h>
-#include <linux/cpu.h>
-#include <linux/kallsyms.h>
-#include <linux/acpi.h>
-#ifdef CONFIG_ACPI
-#include <acpi/achware.h>      /* for PM timer frequency */
-#include <acpi/acpi_bus.h>
-#endif
-#include <asm/8253pit.h>
-#include <asm/i8253.h>
-#include <asm/pgtable.h>
-#include <asm/vsyscall.h>
-#include <asm/timex.h>
-#include <asm/proto.h>
-#include <asm/hpet.h>
-#include <asm/sections.h>
-#include <linux/hpet.h>
-#include <asm/apic.h>
-#include <asm/hpet.h>
-#include <asm/mpspec.h>
-#include <asm/nmi.h>
-#include <asm/vgtod.h>
-
-static char *timename = NULL;
-
-DEFINE_SPINLOCK(rtc_lock);
-EXPORT_SYMBOL(rtc_lock);
-DEFINE_SPINLOCK(i8253_lock);
-EXPORT_SYMBOL(i8253_lock);
-
-volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
-
-unsigned long profile_pc(struct pt_regs *regs)
-{
-       unsigned long pc = instruction_pointer(regs);
-
-       /* Assume the lock function has either no stack frame or a copy
-          of eflags from PUSHF
-          Eflags always has bits 22 and up cleared unlike kernel addresses. */
-       if (!user_mode(regs) && in_lock_functions(pc)) {
-               unsigned long *sp = (unsigned long *)regs->rsp;
-               if (sp[0] >> 22)
-                       return sp[0];
-               if (sp[1] >> 22)
-                       return sp[1];
-       }
-       return pc;
-}
-EXPORT_SYMBOL(profile_pc);
-
-/*
- * In order to set the CMOS clock precisely, set_rtc_mmss has to be called 500
- * ms after the second nowtime has started, because when nowtime is written
- * into the registers of the CMOS clock, it will jump to the next second
- * precisely 500 ms later. Check the Motorola MC146818A or Dallas DS12887 data
- * sheet for details.
- */
-
-static int set_rtc_mmss(unsigned long nowtime)
-{
-       int retval = 0;
-       int real_seconds, real_minutes, cmos_minutes;
-       unsigned char control, freq_select;
-
-/*
- * IRQs are disabled when we're called from the timer interrupt,
- * no need for spin_lock_irqsave()
- */
-
-       spin_lock(&rtc_lock);
-
-/*
- * Tell the clock it's being set and stop it.
- */
-
-       control = CMOS_READ(RTC_CONTROL);
-       CMOS_WRITE(control | RTC_SET, RTC_CONTROL);
-
-       freq_select = CMOS_READ(RTC_FREQ_SELECT);
-       CMOS_WRITE(freq_select | RTC_DIV_RESET2, RTC_FREQ_SELECT);
-
-       cmos_minutes = CMOS_READ(RTC_MINUTES);
-               BCD_TO_BIN(cmos_minutes);
-
-/*
- * since we're only adjusting minutes and seconds, don't interfere with hour
- * overflow. This avoids messing with unknown time zones but requires your RTC
- * not to be off by more than 15 minutes. Since we're calling it only when
- * our clock is externally synchronized using NTP, this shouldn't be a problem.
- */
-
-       real_seconds = nowtime % 60;
-       real_minutes = nowtime / 60;
-       if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
-               real_minutes += 30;             /* correct for half hour time zone */
-       real_minutes %= 60;
-
-       if (abs(real_minutes - cmos_minutes) >= 30) {
-               printk(KERN_WARNING "time.c: can't update CMOS clock "
-                      "from %d to %d\n", cmos_minutes, real_minutes);
-               retval = -1;
-       } else {
-               BIN_TO_BCD(real_seconds);
-               BIN_TO_BCD(real_minutes);
-               CMOS_WRITE(real_seconds, RTC_SECONDS);
-               CMOS_WRITE(real_minutes, RTC_MINUTES);
-       }
-
-/*
- * The following flags have to be released exactly in this order, otherwise the
- * DS12887 (popular MC146818A clone with integrated battery and quartz) will
- * not reset the oscillator and will not update precisely 500 ms later. You
- * won't find this mentioned in the Dallas Semiconductor data sheets, but who
- * believes data sheets anyway ... -- Markus Kuhn
- */
-
-       CMOS_WRITE(control, RTC_CONTROL);
-       CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
-
-       spin_unlock(&rtc_lock);
-
-       return retval;
-}
-
-int update_persistent_clock(struct timespec now)
-{
-       return set_rtc_mmss(now.tv_sec);
-}
-
-void main_timer_handler(void)
-{
-/*
- * Here we are in the timer irq handler. We have irqs locally disabled (so we
- * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running
- * on the other CPU, so we need a lock. We also need to lock the vsyscall
- * variables, because both do_timer() and us change them -arca+vojtech
- */
-
-       write_seqlock(&xtime_lock);
-
-/*
- * Do the timer stuff.
- */
-
-       do_timer(1);
-#ifndef CONFIG_SMP
-       update_process_times(user_mode(get_irq_regs()));
-#endif
-
-/*
- * In the SMP case we use the local APIC timer interrupt to do the profiling,
- * except when we simulate SMP mode on a uniprocessor system, in that case we
- * have to call the local interrupt handler.
- */
-
-       if (!using_apic_timer)
-               smp_local_timer_interrupt();
-
-       write_sequnlock(&xtime_lock);
-}
-
-static irqreturn_t timer_interrupt(int irq, void *dev_id)
-{
-       if (apic_runs_main_timer > 1)
-               return IRQ_HANDLED;
-       main_timer_handler();
-       if (using_apic_timer)
-               smp_send_timer_broadcast_ipi();
-       return IRQ_HANDLED;
-}
-
-unsigned long read_persistent_clock(void)
-{
-       unsigned int year, mon, day, hour, min, sec;
-       unsigned long flags;
-       unsigned century = 0;
-
-       spin_lock_irqsave(&rtc_lock, flags);
-
-       do {
-               sec = CMOS_READ(RTC_SECONDS);
-               min = CMOS_READ(RTC_MINUTES);
-               hour = CMOS_READ(RTC_HOURS);
-               day = CMOS_READ(RTC_DAY_OF_MONTH);
-               mon = CMOS_READ(RTC_MONTH);
-               year = CMOS_READ(RTC_YEAR);
-#ifdef CONFIG_ACPI
-               if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
-                                       acpi_gbl_FADT.century)
-                       century = CMOS_READ(acpi_gbl_FADT.century);
-#endif
-       } while (sec != CMOS_READ(RTC_SECONDS));
-
-       spin_unlock_irqrestore(&rtc_lock, flags);
-
-       /*
-        * We know that x86-64 always uses BCD format, no need to check the
-        * config register.
-        */
-
-       BCD_TO_BIN(sec);
-       BCD_TO_BIN(min);
-       BCD_TO_BIN(hour);
-       BCD_TO_BIN(day);
-       BCD_TO_BIN(mon);
-       BCD_TO_BIN(year);
-
-       if (century) {
-               BCD_TO_BIN(century);
-               year += century * 100;
-               printk(KERN_INFO "Extended CMOS year: %d\n", century * 100);
-       } else {
-               /*
-                * x86-64 systems only exists since 2002.
-                * This will work up to Dec 31, 2100
-                */
-               year += 2000;
-       }
-
-       return mktime(year, mon, day, hour, min, sec);
-}
-
-/* calibrate_cpu is used on systems with fixed rate TSCs to determine
- * processor frequency */
-#define TICK_COUNT 100000000
-static unsigned int __init tsc_calibrate_cpu_khz(void)
-{
-       int tsc_start, tsc_now;
-       int i, no_ctr_free;
-       unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0;
-       unsigned long flags;
-
-       for (i = 0; i < 4; i++)
-               if (avail_to_resrv_perfctr_nmi_bit(i))
-                       break;
-       no_ctr_free = (i == 4);
-       if (no_ctr_free) {
-               i = 3;
-               rdmsrl(MSR_K7_EVNTSEL3, evntsel3);
-               wrmsrl(MSR_K7_EVNTSEL3, 0);
-               rdmsrl(MSR_K7_PERFCTR3, pmc3);
-       } else {
-               reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i);
-               reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
-       }
-       local_irq_save(flags);
-       /* start meauring cycles, incrementing from 0 */
-       wrmsrl(MSR_K7_PERFCTR0 + i, 0);
-       wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76);
-       rdtscl(tsc_start);
-       do {
-               rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now);
-               tsc_now = get_cycles_sync();
-       } while ((tsc_now - tsc_start) < TICK_COUNT);
-
-       local_irq_restore(flags);
-       if (no_ctr_free) {
-               wrmsrl(MSR_K7_EVNTSEL3, 0);
-               wrmsrl(MSR_K7_PERFCTR3, pmc3);
-               wrmsrl(MSR_K7_EVNTSEL3, evntsel3);
-       } else {
-               release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
-               release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
-       }
-
-       return pmc_now * tsc_khz / (tsc_now - tsc_start);
-}
-
-/*
- * pit_calibrate_tsc() uses the speaker output (channel 2) of
- * the PIT. This is better than using the timer interrupt output,
- * because we can read the value of the speaker with just one inb(),
- * where we need three i/o operations for the interrupt channel.
- * We count how many ticks the TSC does in 50 ms.
- */
-
-static unsigned int __init pit_calibrate_tsc(void)
-{
-       unsigned long start, end;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8253_lock, flags);
-
-       outb((inb(0x61) & ~0x02) | 0x01, 0x61);
-
-       outb(0xb0, 0x43);
-       outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
-       outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42);
-       start = get_cycles_sync();
-       while ((inb(0x61) & 0x20) == 0);
-       end = get_cycles_sync();
-
-       spin_unlock_irqrestore(&i8253_lock, flags);
-
-       return (end - start) / 50;
-}
-
-#define PIT_MODE 0x43
-#define PIT_CH0  0x40
-
-static void __pit_init(int val, u8 mode)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8253_lock, flags);
-       outb_p(mode, PIT_MODE);
-       outb_p(val & 0xff, PIT_CH0);    /* LSB */
-       outb_p(val >> 8, PIT_CH0);      /* MSB */
-       spin_unlock_irqrestore(&i8253_lock, flags);
-}
-
-void __init pit_init(void)
-{
-       __pit_init(LATCH, 0x34); /* binary, mode 2, LSB/MSB, ch 0 */
-}
-
-void pit_stop_interrupt(void)
-{
-       __pit_init(0, 0x30); /* mode 0 */
-}
-
-void stop_timer_interrupt(void)
-{
-       char *name;
-       if (hpet_address) {
-               name = "HPET";
-               hpet_timer_stop_set_go(0);
-       } else {
-               name = "PIT";
-               pit_stop_interrupt();
-       }
-       printk(KERN_INFO "timer: %s interrupt stopped.\n", name);
-}
-
-static struct irqaction irq0 = {
-       .handler        = timer_interrupt,
-       .flags          = IRQF_DISABLED | IRQF_IRQPOLL,
-       .mask           = CPU_MASK_NONE,
-       .name           = "timer"
-};
-
-void __init time_init(void)
-{
-       if (nohpet)
-               hpet_address = 0;
-
-       if (hpet_arch_init())
-               hpet_address = 0;
-
-       if (hpet_use_timer) {
-               /* set tick_nsec to use the proper rate for HPET */
-               tick_nsec = TICK_NSEC_HPET;
-               tsc_khz = hpet_calibrate_tsc();
-               timename = "HPET";
-       } else {
-               pit_init();
-               tsc_khz = pit_calibrate_tsc();
-               timename = "PIT";
-       }
-
-       cpu_khz = tsc_khz;
-       if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) &&
-               boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
-               boot_cpu_data.x86 == 16)
-               cpu_khz = tsc_calibrate_cpu_khz();
-
-       if (unsynchronized_tsc())
-               mark_tsc_unstable("TSCs unsynchronized");
-
-       if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
-               vgetcpu_mode = VGETCPU_RDTSCP;
-       else
-               vgetcpu_mode = VGETCPU_LSL;
-
-       set_cyc2ns_scale(tsc_khz);
-       printk(KERN_INFO "time.c: Detected %d.%03d MHz processor.\n",
-               cpu_khz / 1000, cpu_khz % 1000);
-       init_tsc_clocksource();
-
-       setup_irq(0, &irq0);
-}
-
-/*
- * sysfs support for the timer.
- */
-
-static int timer_suspend(struct sys_device *dev, pm_message_t state)
-{
-       return 0;
-}
-
-static int timer_resume(struct sys_device *dev)
-{
-       if (hpet_address)
-               hpet_reenable();
-       else
-               i8254_timer_resume();
-       return 0;
-}
-
-static struct sysdev_class timer_sysclass = {
-       .resume = timer_resume,
-       .suspend = timer_suspend,
-       set_kset_name("timer"),
-};
-
-/* XXX this sysfs stuff should probably go elsewhere later -john */
-static struct sys_device device_timer = {
-       .id     = 0,
-       .cls    = &timer_sysclass,
-};
-
-static int time_init_device(void)
-{
-       int error = sysdev_class_register(&timer_sysclass);
-       if (!error)
-               error = sysdev_register(&device_timer);
-       return error;
-}
-
-device_initcall(time_init_device);
diff --git a/arch/x86_64/kernel/trampoline.S b/arch/x86_64/kernel/trampoline.S
deleted file mode 100644 (file)
index e7e2764..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- *
- *     Trampoline.S    Derived from Setup.S by Linus Torvalds
- *
- *     4 Jan 1997 Michael Chastain: changed to gnu as.
- *     15 Sept 2005 Eric Biederman: 64bit PIC support
- *
- *     Entry: CS:IP point to the start of our code, we are 
- *     in real mode with no stack, but the rest of the 
- *     trampoline page to make our stack and everything else
- *     is a mystery.
- *
- *     In fact we don't actually need a stack so we don't
- *     set one up.
- *
- *     On entry to trampoline_data, the processor is in real mode
- *     with 16-bit addressing and 16-bit data.  CS has some value
- *     and IP is zero.  Thus, data addresses need to be absolute
- *     (no relocation) and are taken with regard to r_base.
- *
- *     With the addition of trampoline_level4_pgt this code can
- *     now enter a 64bit kernel that lives at arbitrary 64bit
- *     physical addresses.
- *
- *     If you work on this file, check the object module with objdump
- *     --full-contents --reloc to make sure there are no relocation
- *     entries.
- */
-
-#include <linux/linkage.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/msr.h>
-#include <asm/segment.h>
-
-.data
-
-.code16
-
-ENTRY(trampoline_data)
-r_base = .
-       cli                     # We should be safe anyway
-       wbinvd  
-       mov     %cs, %ax        # Code and data in the same place
-       mov     %ax, %ds
-       mov     %ax, %es
-       mov     %ax, %ss
-
-
-       movl    $0xA5A5A5A5, trampoline_data - r_base
-                               # write marker for master knows we're running
-
-                                       # Setup stack
-       movw    $(trampoline_stack_end - r_base), %sp
-
-       call    verify_cpu              # Verify the cpu supports long mode
-       testl   %eax, %eax              # Check for return code
-       jnz     no_longmode
-
-       mov     %cs, %ax
-       movzx   %ax, %esi               # Find the 32bit trampoline location
-       shll    $4, %esi
-
-                                       # Fixup the vectors
-       addl    %esi, startup_32_vector - r_base
-       addl    %esi, startup_64_vector - r_base
-       addl    %esi, tgdt + 2 - r_base # Fixup the gdt pointer
-
-       /*
-        * GDT tables in non default location kernel can be beyond 16MB and
-        * lgdt will not be able to load the address as in real mode default
-        * operand size is 16bit. Use lgdtl instead to force operand size
-        * to 32 bit.
-        */
-
-       lidtl   tidt - r_base   # load idt with 0, 0
-       lgdtl   tgdt - r_base   # load gdt with whatever is appropriate
-
-       xor     %ax, %ax
-       inc     %ax             # protected mode (PE) bit
-       lmsw    %ax             # into protected mode
-
-       # flush prefetch and jump to startup_32
-       ljmpl   *(startup_32_vector - r_base)
-
-       .code32
-       .balign 4
-startup_32:
-       movl    $__KERNEL_DS, %eax      # Initialize the %ds segment register
-       movl    %eax, %ds
-
-       xorl    %eax, %eax
-       btsl    $5, %eax                # Enable PAE mode
-       movl    %eax, %cr4
-
-                                       # Setup trampoline 4 level pagetables
-       leal    (trampoline_level4_pgt - r_base)(%esi), %eax
-       movl    %eax, %cr3
-
-       movl    $MSR_EFER, %ecx
-       movl    $(1 << _EFER_LME), %eax # Enable Long Mode
-       xorl    %edx, %edx
-       wrmsr
-
-       xorl    %eax, %eax
-       btsl    $31, %eax               # Enable paging and in turn activate Long Mode
-       btsl    $0, %eax                # Enable protected mode
-       movl    %eax, %cr0
-
-       /*
-        * At this point we're in long mode but in 32bit compatibility mode
-        * with EFER.LME = 1, CS.L = 0, CS.D = 1 (and in turn
-        * EFER.LMA = 1). Now we want to jump in 64bit mode, to do that we use
-        * the new gdt/idt that has __KERNEL_CS with CS.L = 1.
-        */
-       ljmp    *(startup_64_vector - r_base)(%esi)
-
-       .code64
-       .balign 4
-startup_64:
-       # Now jump into the kernel using virtual addresses
-       movq    $secondary_startup_64, %rax
-       jmp     *%rax
-
-       .code16
-no_longmode:
-       hlt
-       jmp no_longmode
-#include "verify_cpu.S"
-
-       # Careful these need to be in the same 64K segment as the above;
-tidt:
-       .word   0                       # idt limit = 0
-       .word   0, 0                    # idt base = 0L
-
-       # Duplicate the global descriptor table
-       # so the kernel can live anywhere
-       .balign 4
-tgdt:
-       .short  tgdt_end - tgdt         # gdt limit
-       .long   tgdt - r_base
-       .short 0
-       .quad   0x00cf9b000000ffff      # __KERNEL32_CS
-       .quad   0x00af9b000000ffff      # __KERNEL_CS
-       .quad   0x00cf93000000ffff      # __KERNEL_DS
-tgdt_end:
-
-       .balign 4
-startup_32_vector:
-       .long   startup_32 - r_base
-       .word   __KERNEL32_CS, 0
-
-       .balign 4
-startup_64_vector:
-       .long   startup_64 - r_base
-       .word   __KERNEL_CS, 0
-
-trampoline_stack:
-       .org 0x1000
-trampoline_stack_end:
-ENTRY(trampoline_level4_pgt)
-       .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
-       .fill   510,8,0
-       .quad   level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
-
-ENTRY(trampoline_end)
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
deleted file mode 100644 (file)
index 0388842..0000000
+++ /dev/null
@@ -1,1138 +0,0 @@
-/*
- *  linux/arch/x86-64/traps.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
- *
- *  Pentium III FXSR, SSE support
- *     Gareth Hughes <gareth@valinux.com>, May 2000
- */
-
-/*
- * 'Traps.c' handles hardware traps and faults after we have saved some
- * state in 'entry.S'.
- */
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/ptrace.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/spinlock.h>
-#include <linux/interrupt.h>
-#include <linux/kallsyms.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/nmi.h>
-#include <linux/kprobes.h>
-#include <linux/kexec.h>
-#include <linux/unwind.h>
-#include <linux/uaccess.h>
-#include <linux/bug.h>
-#include <linux/kdebug.h>
-
-#if defined(CONFIG_EDAC)
-#include <linux/edac.h>
-#endif
-
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/atomic.h>
-#include <asm/debugreg.h>
-#include <asm/desc.h>
-#include <asm/i387.h>
-#include <asm/processor.h>
-#include <asm/unwind.h>
-#include <asm/smp.h>
-#include <asm/pgalloc.h>
-#include <asm/pda.h>
-#include <asm/proto.h>
-#include <asm/nmi.h>
-#include <asm/stacktrace.h>
-
-asmlinkage void divide_error(void);
-asmlinkage void debug(void);
-asmlinkage void nmi(void);
-asmlinkage void int3(void);
-asmlinkage void overflow(void);
-asmlinkage void bounds(void);
-asmlinkage void invalid_op(void);
-asmlinkage void device_not_available(void);
-asmlinkage void double_fault(void);
-asmlinkage void coprocessor_segment_overrun(void);
-asmlinkage void invalid_TSS(void);
-asmlinkage void segment_not_present(void);
-asmlinkage void stack_segment(void);
-asmlinkage void general_protection(void);
-asmlinkage void page_fault(void);
-asmlinkage void coprocessor_error(void);
-asmlinkage void simd_coprocessor_error(void);
-asmlinkage void reserved(void);
-asmlinkage void alignment_check(void);
-asmlinkage void machine_check(void);
-asmlinkage void spurious_interrupt_bug(void);
-
-static inline void conditional_sti(struct pt_regs *regs)
-{
-       if (regs->eflags & X86_EFLAGS_IF)
-               local_irq_enable();
-}
-
-static inline void preempt_conditional_sti(struct pt_regs *regs)
-{
-       preempt_disable();
-       if (regs->eflags & X86_EFLAGS_IF)
-               local_irq_enable();
-}
-
-static inline void preempt_conditional_cli(struct pt_regs *regs)
-{
-       if (regs->eflags & X86_EFLAGS_IF)
-               local_irq_disable();
-       /* Make sure to not schedule here because we could be running
-          on an exception stack. */
-       preempt_enable_no_resched();
-}
-
-int kstack_depth_to_print = 12;
-
-#ifdef CONFIG_KALLSYMS
-void printk_address(unsigned long address)
-{
-       unsigned long offset = 0, symsize;
-       const char *symname;
-       char *modname;
-       char *delim = ":";
-       char namebuf[128];
-
-       symname = kallsyms_lookup(address, &symsize, &offset,
-                                       &modname, namebuf);
-       if (!symname) {
-               printk(" [<%016lx>]\n", address);
-               return;
-       }
-       if (!modname)
-               modname = delim = "";           
-       printk(" [<%016lx>] %s%s%s%s+0x%lx/0x%lx\n",
-               address, delim, modname, delim, symname, offset, symsize);
-}
-#else
-void printk_address(unsigned long address)
-{
-       printk(" [<%016lx>]\n", address);
-}
-#endif
-
-static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
-                                       unsigned *usedp, char **idp)
-{
-       static char ids[][8] = {
-               [DEBUG_STACK - 1] = "#DB",
-               [NMI_STACK - 1] = "NMI",
-               [DOUBLEFAULT_STACK - 1] = "#DF",
-               [STACKFAULT_STACK - 1] = "#SS",
-               [MCE_STACK - 1] = "#MC",
-#if DEBUG_STKSZ > EXCEPTION_STKSZ
-               [N_EXCEPTION_STACKS ... N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
-#endif
-       };
-       unsigned k;
-
-       /*
-        * Iterate over all exception stacks, and figure out whether
-        * 'stack' is in one of them:
-        */
-       for (k = 0; k < N_EXCEPTION_STACKS; k++) {
-               unsigned long end = per_cpu(orig_ist, cpu).ist[k];
-               /*
-                * Is 'stack' above this exception frame's end?
-                * If yes then skip to the next frame.
-                */
-               if (stack >= end)
-                       continue;
-               /*
-                * Is 'stack' above this exception frame's start address?
-                * If yes then we found the right frame.
-                */
-               if (stack >= end - EXCEPTION_STKSZ) {
-                       /*
-                        * Make sure we only iterate through an exception
-                        * stack once. If it comes up for the second time
-                        * then there's something wrong going on - just
-                        * break out and return NULL:
-                        */
-                       if (*usedp & (1U << k))
-                               break;
-                       *usedp |= 1U << k;
-                       *idp = ids[k];
-                       return (unsigned long *)end;
-               }
-               /*
-                * If this is a debug stack, and if it has a larger size than
-                * the usual exception stacks, then 'stack' might still
-                * be within the lower portion of the debug stack:
-                */
-#if DEBUG_STKSZ > EXCEPTION_STKSZ
-               if (k == DEBUG_STACK - 1 && stack >= end - DEBUG_STKSZ) {
-                       unsigned j = N_EXCEPTION_STACKS - 1;
-
-                       /*
-                        * Black magic. A large debug stack is composed of
-                        * multiple exception stack entries, which we
-                        * iterate through now. Dont look:
-                        */
-                       do {
-                               ++j;
-                               end -= EXCEPTION_STKSZ;
-                               ids[j][4] = '1' + (j - N_EXCEPTION_STACKS);
-                       } while (stack < end - EXCEPTION_STKSZ);
-                       if (*usedp & (1U << j))
-                               break;
-                       *usedp |= 1U << j;
-                       *idp = ids[j];
-                       return (unsigned long *)end;
-               }
-#endif
-       }
-       return NULL;
-}
-
-#define MSG(txt) ops->warning(data, txt)
-
-/*
- * x86-64 can have upto three kernel stacks: 
- * process stack
- * interrupt stack
- * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
- */
-
-static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
-{
-       void *t = (void *)tinfo;
-        return p > t && p < t + THREAD_SIZE - 3;
-}
-
-void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
-               unsigned long *stack,
-               struct stacktrace_ops *ops, void *data)
-{
-       const unsigned cpu = get_cpu();
-       unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
-       unsigned used = 0;
-       struct thread_info *tinfo;
-
-       if (!tsk)
-               tsk = current;
-
-       if (!stack) {
-               unsigned long dummy;
-               stack = &dummy;
-               if (tsk && tsk != current)
-                       stack = (unsigned long *)tsk->thread.rsp;
-       }
-
-       /*
-        * Print function call entries within a stack. 'cond' is the
-        * "end of stackframe" condition, that the 'stack++'
-        * iteration will eventually trigger.
-        */
-#define HANDLE_STACK(cond) \
-       do while (cond) { \
-               unsigned long addr = *stack++; \
-               /* Use unlocked access here because except for NMIs     \
-                  we should be already protected against module unloads */ \
-               if (__kernel_text_address(addr)) { \
-                       /* \
-                        * If the address is either in the text segment of the \
-                        * kernel, or in the region which contains vmalloc'ed \
-                        * memory, it *may* be the address of a calling \
-                        * routine; if so, print it so that someone tracing \
-                        * down the cause of the crash will be able to figure \
-                        * out the call path that was taken. \
-                        */ \
-                       ops->address(data, addr);   \
-               } \
-       } while (0)
-
-       /*
-        * Print function call entries in all stacks, starting at the
-        * current stack address. If the stacks consist of nested
-        * exceptions
-        */
-       for (;;) {
-               char *id;
-               unsigned long *estack_end;
-               estack_end = in_exception_stack(cpu, (unsigned long)stack,
-                                               &used, &id);
-
-               if (estack_end) {
-                       if (ops->stack(data, id) < 0)
-                               break;
-                       HANDLE_STACK (stack < estack_end);
-                       ops->stack(data, "<EOE>");
-                       /*
-                        * We link to the next stack via the
-                        * second-to-last pointer (index -2 to end) in the
-                        * exception stack:
-                        */
-                       stack = (unsigned long *) estack_end[-2];
-                       continue;
-               }
-               if (irqstack_end) {
-                       unsigned long *irqstack;
-                       irqstack = irqstack_end -
-                               (IRQSTACKSIZE - 64) / sizeof(*irqstack);
-
-                       if (stack >= irqstack && stack < irqstack_end) {
-                               if (ops->stack(data, "IRQ") < 0)
-                                       break;
-                               HANDLE_STACK (stack < irqstack_end);
-                               /*
-                                * We link to the next stack (which would be
-                                * the process stack normally) the last
-                                * pointer (index -1 to end) in the IRQ stack:
-                                */
-                               stack = (unsigned long *) (irqstack_end[-1]);
-                               irqstack_end = NULL;
-                               ops->stack(data, "EOI");
-                               continue;
-                       }
-               }
-               break;
-       }
-
-       /*
-        * This handles the process stack:
-        */
-       tinfo = task_thread_info(tsk);
-       HANDLE_STACK (valid_stack_ptr(tinfo, stack));
-#undef HANDLE_STACK
-       put_cpu();
-}
-EXPORT_SYMBOL(dump_trace);
-
-static void
-print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
-{
-       print_symbol(msg, symbol);
-       printk("\n");
-}
-
-static void print_trace_warning(void *data, char *msg)
-{
-       printk("%s\n", msg);
-}
-
-static int print_trace_stack(void *data, char *name)
-{
-       printk(" <%s> ", name);
-       return 0;
-}
-
-static void print_trace_address(void *data, unsigned long addr)
-{
-       touch_nmi_watchdog();
-       printk_address(addr);
-}
-
-static struct stacktrace_ops print_trace_ops = {
-       .warning = print_trace_warning,
-       .warning_symbol = print_trace_warning_symbol,
-       .stack = print_trace_stack,
-       .address = print_trace_address,
-};
-
-void
-show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack)
-{
-       printk("\nCall Trace:\n");
-       dump_trace(tsk, regs, stack, &print_trace_ops, NULL);
-       printk("\n");
-}
-
-static void
-_show_stack(struct task_struct *tsk, struct pt_regs *regs, unsigned long *rsp)
-{
-       unsigned long *stack;
-       int i;
-       const int cpu = smp_processor_id();
-       unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
-       unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
-
-       // debugging aid: "show_stack(NULL, NULL);" prints the
-       // back trace for this cpu.
-
-       if (rsp == NULL) {
-               if (tsk)
-                       rsp = (unsigned long *)tsk->thread.rsp;
-               else
-                       rsp = (unsigned long *)&rsp;
-       }
-
-       stack = rsp;
-       for(i=0; i < kstack_depth_to_print; i++) {
-               if (stack >= irqstack && stack <= irqstack_end) {
-                       if (stack == irqstack_end) {
-                               stack = (unsigned long *) (irqstack_end[-1]);
-                               printk(" <EOI> ");
-                       }
-               } else {
-               if (((long) stack & (THREAD_SIZE-1)) == 0)
-                       break;
-               }
-               if (i && ((i % 4) == 0))
-                       printk("\n");
-               printk(" %016lx", *stack++);
-               touch_nmi_watchdog();
-       }
-       show_trace(tsk, regs, rsp);
-}
-
-void show_stack(struct task_struct *tsk, unsigned long * rsp)
-{
-       _show_stack(tsk, NULL, rsp);
-}
-
-/*
- * The architecture-independent dump_stack generator
- */
-void dump_stack(void)
-{
-       unsigned long dummy;
-       show_trace(NULL, NULL, &dummy);
-}
-
-EXPORT_SYMBOL(dump_stack);
-
-void show_registers(struct pt_regs *regs)
-{
-       int i;
-       int in_kernel = !user_mode(regs);
-       unsigned long rsp;
-       const int cpu = smp_processor_id();
-       struct task_struct *cur = cpu_pda(cpu)->pcurrent;
-
-       rsp = regs->rsp;
-       printk("CPU %d ", cpu);
-       __show_regs(regs);
-       printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
-               cur->comm, cur->pid, task_thread_info(cur), cur);
-
-       /*
-        * When in-kernel, we also print out the stack and code at the
-        * time of the fault..
-        */
-       if (in_kernel) {
-               printk("Stack: ");
-               _show_stack(NULL, regs, (unsigned long*)rsp);
-
-               printk("\nCode: ");
-               if (regs->rip < PAGE_OFFSET)
-                       goto bad;
-
-               for (i=0; i<20; i++) {
-                       unsigned char c;
-                       if (__get_user(c, &((unsigned char*)regs->rip)[i])) {
-bad:
-                               printk(" Bad RIP value.");
-                               break;
-                       }
-                       printk("%02x ", c);
-               }
-       }
-       printk("\n");
-}      
-
-int is_valid_bugaddr(unsigned long rip)
-{
-       unsigned short ud2;
-
-       if (__copy_from_user(&ud2, (const void __user *) rip, sizeof(ud2)))
-               return 0;
-
-       return ud2 == 0x0b0f;
-}
-
-#ifdef CONFIG_BUG
-void out_of_line_bug(void)
-{ 
-       BUG(); 
-} 
-EXPORT_SYMBOL(out_of_line_bug);
-#endif
-
-static DEFINE_SPINLOCK(die_lock);
-static int die_owner = -1;
-static unsigned int die_nest_count;
-
-unsigned __kprobes long oops_begin(void)
-{
-       int cpu;
-       unsigned long flags;
-
-       oops_enter();
-
-       /* racy, but better than risking deadlock. */
-       local_irq_save(flags);
-       cpu = smp_processor_id();
-       if (!spin_trylock(&die_lock)) { 
-               if (cpu == die_owner) 
-                       /* nested oops. should stop eventually */;
-               else
-                       spin_lock(&die_lock);
-       }
-       die_nest_count++;
-       die_owner = cpu;
-       console_verbose();
-       bust_spinlocks(1);
-       return flags;
-}
-
-void __kprobes oops_end(unsigned long flags)
-{ 
-       die_owner = -1;
-       bust_spinlocks(0);
-       die_nest_count--;
-       if (die_nest_count)
-               /* We still own the lock */
-               local_irq_restore(flags);
-       else
-               /* Nest count reaches zero, release the lock. */
-               spin_unlock_irqrestore(&die_lock, flags);
-       if (panic_on_oops)
-               panic("Fatal exception");
-       oops_exit();
-}
-
-void __kprobes __die(const char * str, struct pt_regs * regs, long err)
-{
-       static int die_counter;
-       printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff,++die_counter);
-#ifdef CONFIG_PREEMPT
-       printk("PREEMPT ");
-#endif
-#ifdef CONFIG_SMP
-       printk("SMP ");
-#endif
-#ifdef CONFIG_DEBUG_PAGEALLOC
-       printk("DEBUG_PAGEALLOC");
-#endif
-       printk("\n");
-       notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
-       show_registers(regs);
-       add_taint(TAINT_DIE);
-       /* Executive summary in case the oops scrolled away */
-       printk(KERN_ALERT "RIP ");
-       printk_address(regs->rip); 
-       printk(" RSP <%016lx>\n", regs->rsp); 
-       if (kexec_should_crash(current))
-               crash_kexec(regs);
-}
-
-void die(const char * str, struct pt_regs * regs, long err)
-{
-       unsigned long flags = oops_begin();
-
-       if (!user_mode(regs))
-               report_bug(regs->rip, regs);
-
-       __die(str, regs, err);
-       oops_end(flags);
-       do_exit(SIGSEGV); 
-}
-
-void __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)
-{
-       unsigned long flags = oops_begin();
-
-       /*
-        * We are in trouble anyway, lets at least try
-        * to get a message out.
-        */
-       printk(str, smp_processor_id());
-       show_registers(regs);
-       if (kexec_should_crash(current))
-               crash_kexec(regs);
-       if (do_panic || panic_on_oops)
-               panic("Non maskable interrupt");
-       oops_end(flags);
-       nmi_exit();
-       local_irq_enable();
-       do_exit(SIGSEGV);
-}
-
-static void __kprobes do_trap(int trapnr, int signr, char *str,
-                             struct pt_regs * regs, long error_code,
-                             siginfo_t *info)
-{
-       struct task_struct *tsk = current;
-
-       if (user_mode(regs)) {
-               /*
-                * We want error_code and trap_no set for userspace
-                * faults and kernelspace faults which result in
-                * die(), but not kernelspace faults which are fixed
-                * up.  die() gives the process no chance to handle
-                * the signal and notice the kernel fault information,
-                * so that won't result in polluting the information
-                * about previously queued, but not yet delivered,
-                * faults.  See also do_general_protection below.
-                */
-               tsk->thread.error_code = error_code;
-               tsk->thread.trap_no = trapnr;
-
-               if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
-                   printk_ratelimit())
-                       printk(KERN_INFO
-                              "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
-                              tsk->comm, tsk->pid, str,
-                              regs->rip, regs->rsp, error_code); 
-
-               if (info)
-                       force_sig_info(signr, info, tsk);
-               else
-                       force_sig(signr, tsk);
-               return;
-       }
-
-
-       /* kernel trap */ 
-       {            
-               const struct exception_table_entry *fixup;
-               fixup = search_exception_tables(regs->rip);
-               if (fixup)
-                       regs->rip = fixup->fixup;
-               else {
-                       tsk->thread.error_code = error_code;
-                       tsk->thread.trap_no = trapnr;
-                       die(str, regs, error_code);
-               }
-               return;
-       }
-}
-
-#define DO_ERROR(trapnr, signr, str, name) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
-{ \
-       if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
-                                                       == NOTIFY_STOP) \
-               return; \
-       conditional_sti(regs);                                          \
-       do_trap(trapnr, signr, str, regs, error_code, NULL); \
-}
-
-#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
-asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
-{ \
-       siginfo_t info; \
-       info.si_signo = signr; \
-       info.si_errno = 0; \
-       info.si_code = sicode; \
-       info.si_addr = (void __user *)siaddr; \
-       if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
-                                                       == NOTIFY_STOP) \
-               return; \
-       conditional_sti(regs);                                          \
-       do_trap(trapnr, signr, str, regs, error_code, &info); \
-}
-
-DO_ERROR_INFO( 0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->rip)
-DO_ERROR( 4, SIGSEGV, "overflow", overflow)
-DO_ERROR( 5, SIGSEGV, "bounds", bounds)
-DO_ERROR_INFO( 6, SIGILL,  "invalid opcode", invalid_op, ILL_ILLOPN, regs->rip)
-DO_ERROR( 7, SIGSEGV, "device not available", device_not_available)
-DO_ERROR( 9, SIGFPE,  "coprocessor segment overrun", coprocessor_segment_overrun)
-DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
-DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
-DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
-DO_ERROR(18, SIGSEGV, "reserved", reserved)
-
-/* Runs on IST stack */
-asmlinkage void do_stack_segment(struct pt_regs *regs, long error_code)
-{
-       if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
-                       12, SIGBUS) == NOTIFY_STOP)
-               return;
-       preempt_conditional_sti(regs);
-       do_trap(12, SIGBUS, "stack segment", regs, error_code, NULL);
-       preempt_conditional_cli(regs);
-}
-
-asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
-{
-       static const char str[] = "double fault";
-       struct task_struct *tsk = current;
-
-       /* Return not checked because double check cannot be ignored */
-       notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
-
-       tsk->thread.error_code = error_code;
-       tsk->thread.trap_no = 8;
-
-       /* This is always a kernel trap and never fixable (and thus must
-          never return). */
-       for (;;)
-               die(str, regs, error_code);
-}
-
-asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
-                                               long error_code)
-{
-       struct task_struct *tsk = current;
-
-       conditional_sti(regs);
-
-       if (user_mode(regs)) {
-               tsk->thread.error_code = error_code;
-               tsk->thread.trap_no = 13;
-
-               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
-                   printk_ratelimit())
-                       printk(KERN_INFO
-                      "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
-                              tsk->comm, tsk->pid,
-                              regs->rip, regs->rsp, error_code); 
-
-               force_sig(SIGSEGV, tsk);
-               return;
-       } 
-
-       /* kernel gp */
-       {
-               const struct exception_table_entry *fixup;
-               fixup = search_exception_tables(regs->rip);
-               if (fixup) {
-                       regs->rip = fixup->fixup;
-                       return;
-               }
-
-               tsk->thread.error_code = error_code;
-               tsk->thread.trap_no = 13;
-               if (notify_die(DIE_GPF, "general protection fault", regs,
-                                       error_code, 13, SIGSEGV) == NOTIFY_STOP)
-                       return;
-               die("general protection fault", regs, error_code);
-       }
-}
-
-static __kprobes void
-mem_parity_error(unsigned char reason, struct pt_regs * regs)
-{
-       printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
-               reason);
-       printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
-
-#if defined(CONFIG_EDAC)
-       if(edac_handler_set()) {
-               edac_atomic_assert_error();
-               return;
-       }
-#endif
-
-       if (panic_on_unrecovered_nmi)
-               panic("NMI: Not continuing");
-
-       printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
-
-       /* Clear and disable the memory parity error line. */
-       reason = (reason & 0xf) | 4;
-       outb(reason, 0x61);
-}
-
-static __kprobes void
-io_check_error(unsigned char reason, struct pt_regs * regs)
-{
-       printk("NMI: IOCK error (debug interrupt?)\n");
-       show_registers(regs);
-
-       /* Re-enable the IOCK line, wait for a few seconds */
-       reason = (reason & 0xf) | 8;
-       outb(reason, 0x61);
-       mdelay(2000);
-       reason &= ~8;
-       outb(reason, 0x61);
-}
-
-static __kprobes void
-unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
-{
-       printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
-               reason);
-       printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
-
-       if (panic_on_unrecovered_nmi)
-               panic("NMI: Not continuing");
-
-       printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
-}
-
-/* Runs on IST stack. This code must keep interrupts off all the time.
-   Nested NMIs are prevented by the CPU. */
-asmlinkage __kprobes void default_do_nmi(struct pt_regs *regs)
-{
-       unsigned char reason = 0;
-       int cpu;
-
-       cpu = smp_processor_id();
-
-       /* Only the BSP gets external NMIs from the system.  */
-       if (!cpu)
-               reason = get_nmi_reason();
-
-       if (!(reason & 0xc0)) {
-               if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
-                                                               == NOTIFY_STOP)
-                       return;
-               /*
-                * Ok, so this is none of the documented NMI sources,
-                * so it must be the NMI watchdog.
-                */
-               if (nmi_watchdog_tick(regs,reason))
-                       return;
-               if (!do_nmi_callback(regs,cpu))
-                       unknown_nmi_error(reason, regs);
-
-               return;
-       }
-       if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
-               return; 
-
-       /* AK: following checks seem to be broken on modern chipsets. FIXME */
-
-       if (reason & 0x80)
-               mem_parity_error(reason, regs);
-       if (reason & 0x40)
-               io_check_error(reason, regs);
-}
-
-/* runs on IST stack. */
-asmlinkage void __kprobes do_int3(struct pt_regs * regs, long error_code)
-{
-       if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) == NOTIFY_STOP) {
-               return;
-       }
-       preempt_conditional_sti(regs);
-       do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
-       preempt_conditional_cli(regs);
-}
-
-/* Help handler running on IST stack to switch back to user stack
-   for scheduling or signal handling. The actual stack switch is done in
-   entry.S */
-asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
-{
-       struct pt_regs *regs = eregs;
-       /* Did already sync */
-       if (eregs == (struct pt_regs *)eregs->rsp)
-               ;
-       /* Exception from user space */
-       else if (user_mode(eregs))
-               regs = task_pt_regs(current);
-       /* Exception from kernel and interrupts are enabled. Move to
-          kernel process stack. */
-       else if (eregs->eflags & X86_EFLAGS_IF)
-               regs = (struct pt_regs *)(eregs->rsp -= sizeof(struct pt_regs));
-       if (eregs != regs)
-               *regs = *eregs;
-       return regs;
-}
-
-/* runs on IST stack. */
-asmlinkage void __kprobes do_debug(struct pt_regs * regs,
-                                  unsigned long error_code)
-{
-       unsigned long condition;
-       struct task_struct *tsk = current;
-       siginfo_t info;
-
-       get_debugreg(condition, 6);
-
-       if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
-                                               SIGTRAP) == NOTIFY_STOP)
-               return;
-
-       preempt_conditional_sti(regs);
-
-       /* Mask out spurious debug traps due to lazy DR7 setting */
-       if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
-               if (!tsk->thread.debugreg7) { 
-                       goto clear_dr7;
-               }
-       }
-
-       tsk->thread.debugreg6 = condition;
-
-       /* Mask out spurious TF errors due to lazy TF clearing */
-       if (condition & DR_STEP) {
-               /*
-                * The TF error should be masked out only if the current
-                * process is not traced and if the TRAP flag has been set
-                * previously by a tracing process (condition detected by
-                * the PT_DTRACE flag); remember that the i386 TRAP flag
-                * can be modified by the process itself in user mode,
-                * allowing programs to debug themselves without the ptrace()
-                * interface.
-                */
-                if (!user_mode(regs))
-                       goto clear_TF_reenable;
-               /*
-                * Was the TF flag set by a debugger? If so, clear it now,
-                * so that register information is correct.
-                */
-               if (tsk->ptrace & PT_DTRACE) {
-                       regs->eflags &= ~TF_MASK;
-                       tsk->ptrace &= ~PT_DTRACE;
-               }
-       }
-
-       /* Ok, finally something we can handle */
-       tsk->thread.trap_no = 1;
-       tsk->thread.error_code = error_code;
-       info.si_signo = SIGTRAP;
-       info.si_errno = 0;
-       info.si_code = TRAP_BRKPT;
-       info.si_addr = user_mode(regs) ? (void __user *)regs->rip : NULL;
-       force_sig_info(SIGTRAP, &info, tsk);
-
-clear_dr7:
-       set_debugreg(0UL, 7);
-       preempt_conditional_cli(regs);
-       return;
-
-clear_TF_reenable:
-       set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
-       regs->eflags &= ~TF_MASK;
-       preempt_conditional_cli(regs);
-}
-
-static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
-{
-       const struct exception_table_entry *fixup;
-       fixup = search_exception_tables(regs->rip);
-       if (fixup) {
-               regs->rip = fixup->fixup;
-               return 1;
-       }
-       notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
-       /* Illegal floating point operation in the kernel */
-       current->thread.trap_no = trapnr;
-       die(str, regs, 0);
-       return 0;
-}
-
-/*
- * Note that we play around with the 'TS' bit in an attempt to get
- * the correct behaviour even in the presence of the asynchronous
- * IRQ13 behaviour
- */
-asmlinkage void do_coprocessor_error(struct pt_regs *regs)
-{
-       void __user *rip = (void __user *)(regs->rip);
-       struct task_struct * task;
-       siginfo_t info;
-       unsigned short cwd, swd;
-
-       conditional_sti(regs);
-       if (!user_mode(regs) &&
-           kernel_math_error(regs, "kernel x87 math error", 16))
-               return;
-
-       /*
-        * Save the info for the exception handler and clear the error.
-        */
-       task = current;
-       save_init_fpu(task);
-       task->thread.trap_no = 16;
-       task->thread.error_code = 0;
-       info.si_signo = SIGFPE;
-       info.si_errno = 0;
-       info.si_code = __SI_FAULT;
-       info.si_addr = rip;
-       /*
-        * (~cwd & swd) will mask out exceptions that are not set to unmasked
-        * status.  0x3f is the exception bits in these regs, 0x200 is the
-        * C1 reg you need in case of a stack fault, 0x040 is the stack
-        * fault bit.  We should only be taking one exception at a time,
-        * so if this combination doesn't produce any single exception,
-        * then we have a bad program that isn't synchronizing its FPU usage
-        * and it will suffer the consequences since we won't be able to
-        * fully reproduce the context of the exception
-        */
-       cwd = get_fpu_cwd(task);
-       swd = get_fpu_swd(task);
-       switch (swd & ~cwd & 0x3f) {
-               case 0x000:
-               default:
-                       break;
-               case 0x001: /* Invalid Op */
-                       /*
-                        * swd & 0x240 == 0x040: Stack Underflow
-                        * swd & 0x240 == 0x240: Stack Overflow
-                        * User must clear the SF bit (0x40) if set
-                        */
-                       info.si_code = FPE_FLTINV;
-                       break;
-               case 0x002: /* Denormalize */
-               case 0x010: /* Underflow */
-                       info.si_code = FPE_FLTUND;
-                       break;
-               case 0x004: /* Zero Divide */
-                       info.si_code = FPE_FLTDIV;
-                       break;
-               case 0x008: /* Overflow */
-                       info.si_code = FPE_FLTOVF;
-                       break;
-               case 0x020: /* Precision */
-                       info.si_code = FPE_FLTRES;
-                       break;
-       }
-       force_sig_info(SIGFPE, &info, task);
-}
-
-asmlinkage void bad_intr(void)
-{
-       printk("bad interrupt"); 
-}
-
-asmlinkage void do_simd_coprocessor_error(struct pt_regs *regs)
-{
-       void __user *rip = (void __user *)(regs->rip);
-       struct task_struct * task;
-       siginfo_t info;
-       unsigned short mxcsr;
-
-       conditional_sti(regs);
-       if (!user_mode(regs) &&
-               kernel_math_error(regs, "kernel simd math error", 19))
-               return;
-
-       /*
-        * Save the info for the exception handler and clear the error.
-        */
-       task = current;
-       save_init_fpu(task);
-       task->thread.trap_no = 19;
-       task->thread.error_code = 0;
-       info.si_signo = SIGFPE;
-       info.si_errno = 0;
-       info.si_code = __SI_FAULT;
-       info.si_addr = rip;
-       /*
-        * The SIMD FPU exceptions are handled a little differently, as there
-        * is only a single status/control register.  Thus, to determine which
-        * unmasked exception was caught we must mask the exception mask bits
-        * at 0x1f80, and then use these to mask the exception bits at 0x3f.
-        */
-       mxcsr = get_fpu_mxcsr(task);
-       switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
-               case 0x000:
-               default:
-                       break;
-               case 0x001: /* Invalid Op */
-                       info.si_code = FPE_FLTINV;
-                       break;
-               case 0x002: /* Denormalize */
-               case 0x010: /* Underflow */
-                       info.si_code = FPE_FLTUND;
-                       break;
-               case 0x004: /* Zero Divide */
-                       info.si_code = FPE_FLTDIV;
-                       break;
-               case 0x008: /* Overflow */
-                       info.si_code = FPE_FLTOVF;
-                       break;
-               case 0x020: /* Precision */
-                       info.si_code = FPE_FLTRES;
-                       break;
-       }
-       force_sig_info(SIGFPE, &info, task);
-}
-
-asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs)
-{
-}
-
-asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
-{
-}
-
-asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
-{
-}
-
-/*
- *  'math_state_restore()' saves the current math information in the
- * old math state array, and gets the new ones from the current task
- *
- * Careful.. There are problems with IBM-designed IRQ13 behaviour.
- * Don't touch unless you *really* know how it works.
- */
-asmlinkage void math_state_restore(void)
-{
-       struct task_struct *me = current;
-       clts();                 /* Allow maths ops (or we recurse) */
-
-       if (!used_math())
-               init_fpu(me);
-       restore_fpu_checking(&me->thread.i387.fxsave);
-       task_thread_info(me)->status |= TS_USEDFPU;
-       me->fpu_counter++;
-}
-
-void __init trap_init(void)
-{
-       set_intr_gate(0,&divide_error);
-       set_intr_gate_ist(1,&debug,DEBUG_STACK);
-       set_intr_gate_ist(2,&nmi,NMI_STACK);
-       set_system_gate_ist(3,&int3,DEBUG_STACK); /* int3 can be called from all */
-       set_system_gate(4,&overflow);   /* int4 can be called from all */
-       set_intr_gate(5,&bounds);
-       set_intr_gate(6,&invalid_op);
-       set_intr_gate(7,&device_not_available);
-       set_intr_gate_ist(8,&double_fault, DOUBLEFAULT_STACK);
-       set_intr_gate(9,&coprocessor_segment_overrun);
-       set_intr_gate(10,&invalid_TSS);
-       set_intr_gate(11,&segment_not_present);
-       set_intr_gate_ist(12,&stack_segment,STACKFAULT_STACK);
-       set_intr_gate(13,&general_protection);
-       set_intr_gate(14,&page_fault);
-       set_intr_gate(15,&spurious_interrupt_bug);
-       set_intr_gate(16,&coprocessor_error);
-       set_intr_gate(17,&alignment_check);
-#ifdef CONFIG_X86_MCE
-       set_intr_gate_ist(18,&machine_check, MCE_STACK); 
-#endif
-       set_intr_gate(19,&simd_coprocessor_error);
-
-#ifdef CONFIG_IA32_EMULATION
-       set_system_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
-#endif
-       
-       /*
-        * Should be a barrier for any external CPU state.
-        */
-       cpu_init();
-}
-
-
-static int __init oops_setup(char *s)
-{ 
-       if (!s)
-               return -EINVAL;
-       if (!strcmp(s, "panic"))
-               panic_on_oops = 1;
-       return 0;
-} 
-early_param("oops", oops_setup);
-
-static int __init kstack_setup(char *s)
-{
-       if (!s)
-               return -EINVAL;
-       kstack_depth_to_print = simple_strtoul(s,NULL,0);
-       return 0;
-}
-early_param("kstack", kstack_setup);
diff --git a/arch/x86_64/kernel/tsc.c b/arch/x86_64/kernel/tsc.c
deleted file mode 100644 (file)
index 2a59bde..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/clocksource.h>
-#include <linux/time.h>
-#include <linux/acpi.h>
-#include <linux/cpufreq.h>
-
-#include <asm/timex.h>
-
-static int notsc __initdata = 0;
-
-unsigned int cpu_khz;          /* TSC clocks / usec, not used here */
-EXPORT_SYMBOL(cpu_khz);
-unsigned int tsc_khz;
-EXPORT_SYMBOL(tsc_khz);
-
-static unsigned int cyc2ns_scale __read_mostly;
-
-void set_cyc2ns_scale(unsigned long khz)
-{
-       cyc2ns_scale = (NSEC_PER_MSEC << NS_SCALE) / khz;
-}
-
-static unsigned long long cycles_2_ns(unsigned long long cyc)
-{
-       return (cyc * cyc2ns_scale) >> NS_SCALE;
-}
-
-unsigned long long sched_clock(void)
-{
-       unsigned long a = 0;
-
-       /* Could do CPU core sync here. Opteron can execute rdtsc speculatively,
-        * which means it is not completely exact and may not be monotonous
-        * between CPUs. But the errors should be too small to matter for
-        * scheduling purposes.
-        */
-
-       rdtscll(a);
-       return cycles_2_ns(a);
-}
-
-static int tsc_unstable;
-
-inline int check_tsc_unstable(void)
-{
-       return tsc_unstable;
-}
-#ifdef CONFIG_CPU_FREQ
-
-/* Frequency scaling support. Adjust the TSC based timer when the cpu frequency
- * changes.
- *
- * RED-PEN: On SMP we assume all CPUs run with the same frequency.  It's
- * not that important because current Opteron setups do not support
- * scaling on SMP anyroads.
- *
- * Should fix up last_tsc too. Currently gettimeofday in the
- * first tick after the change will be slightly wrong.
- */
-
-static unsigned int  ref_freq;
-static unsigned long loops_per_jiffy_ref;
-static unsigned long tsc_khz_ref;
-
-static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
-                                void *data)
-{
-       struct cpufreq_freqs *freq = data;
-       unsigned long *lpj, dummy;
-
-       if (cpu_has(&cpu_data[freq->cpu], X86_FEATURE_CONSTANT_TSC))
-               return 0;
-
-       lpj = &dummy;
-       if (!(freq->flags & CPUFREQ_CONST_LOOPS))
-#ifdef CONFIG_SMP
-               lpj = &cpu_data[freq->cpu].loops_per_jiffy;
-#else
-               lpj = &boot_cpu_data.loops_per_jiffy;
-#endif
-
-       if (!ref_freq) {
-               ref_freq = freq->old;
-               loops_per_jiffy_ref = *lpj;
-               tsc_khz_ref = tsc_khz;
-       }
-       if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
-               (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
-               (val == CPUFREQ_RESUMECHANGE)) {
-               *lpj =
-               cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
-
-               tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);
-               if (!(freq->flags & CPUFREQ_CONST_LOOPS))
-                       mark_tsc_unstable("cpufreq changes");
-       }
-
-       set_cyc2ns_scale(tsc_khz_ref);
-
-       return 0;
-}
-
-static struct notifier_block time_cpufreq_notifier_block = {
-       .notifier_call  = time_cpufreq_notifier
-};
-
-static int __init cpufreq_tsc(void)
-{
-       cpufreq_register_notifier(&time_cpufreq_notifier_block,
-                                 CPUFREQ_TRANSITION_NOTIFIER);
-       return 0;
-}
-
-core_initcall(cpufreq_tsc);
-
-#endif
-
-/*
- * Make an educated guess if the TSC is trustworthy and synchronized
- * over all CPUs.
- */
-__cpuinit int unsynchronized_tsc(void)
-{
-       if (tsc_unstable)
-               return 1;
-
-#ifdef CONFIG_SMP
-       if (apic_is_clustered_box())
-               return 1;
-#endif
-       /* Most intel systems have synchronized TSCs except for
-          multi node systems */
-       if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
-#ifdef CONFIG_ACPI
-               /* But TSC doesn't tick in C3 so don't use it there */
-               if (acpi_gbl_FADT.header.length > 0 &&
-                   acpi_gbl_FADT.C3latency < 1000)
-                       return 1;
-#endif
-               return 0;
-       }
-
-       /* Assume multi socket systems are not synchronized */
-       return num_present_cpus() > 1;
-}
-
-int __init notsc_setup(char *s)
-{
-       notsc = 1;
-       return 1;
-}
-
-__setup("notsc", notsc_setup);
-
-
-/* clock source code: */
-static cycle_t read_tsc(void)
-{
-       cycle_t ret = (cycle_t)get_cycles_sync();
-       return ret;
-}
-
-static cycle_t __vsyscall_fn vread_tsc(void)
-{
-       cycle_t ret = (cycle_t)get_cycles_sync();
-       return ret;
-}
-
-static struct clocksource clocksource_tsc = {
-       .name                   = "tsc",
-       .rating                 = 300,
-       .read                   = read_tsc,
-       .mask                   = CLOCKSOURCE_MASK(64),
-       .shift                  = 22,
-       .flags                  = CLOCK_SOURCE_IS_CONTINUOUS |
-                                 CLOCK_SOURCE_MUST_VERIFY,
-       .vread                  = vread_tsc,
-};
-
-void mark_tsc_unstable(char *reason)
-{
-       if (!tsc_unstable) {
-               tsc_unstable = 1;
-               printk("Marking TSC unstable due to %s\n", reason);
-               /* Change only the rating, when not registered */
-               if (clocksource_tsc.mult)
-                       clocksource_change_rating(&clocksource_tsc, 0);
-               else
-                       clocksource_tsc.rating = 0;
-       }
-}
-EXPORT_SYMBOL_GPL(mark_tsc_unstable);
-
-void __init init_tsc_clocksource(void)
-{
-       if (!notsc) {
-               clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
-                                                       clocksource_tsc.shift);
-               if (check_tsc_unstable())
-                       clocksource_tsc.rating = 0;
-
-               clocksource_register(&clocksource_tsc);
-       }
-}
diff --git a/arch/x86_64/kernel/tsc_sync.c b/arch/x86_64/kernel/tsc_sync.c
deleted file mode 100644 (file)
index 355f5f5..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * arch/x86_64/kernel/tsc_sync.c: check TSC synchronization.
- *
- * Copyright (C) 2006, Red Hat, Inc., Ingo Molnar
- *
- * We check whether all boot CPUs have their TSC's synchronized,
- * print a warning if not and turn off the TSC clock-source.
- *
- * The warp-check is point-to-point between two CPUs, the CPU
- * initiating the bootup is the 'source CPU', the freshly booting
- * CPU is the 'target CPU'.
- *
- * Only two CPUs may participate - they can enter in any order.
- * ( The serial nature of the boot logic and the CPU hotplug lock
- *   protects against more than 2 CPUs entering this code. )
- */
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <linux/nmi.h>
-#include <asm/tsc.h>
-
-/*
- * Entry/exit counters that make sure that both CPUs
- * run the measurement code at once:
- */
-static __cpuinitdata atomic_t start_count;
-static __cpuinitdata atomic_t stop_count;
-
-/*
- * We use a raw spinlock in this exceptional case, because
- * we want to have the fastest, inlined, non-debug version
- * of a critical section, to be able to prove TSC time-warps:
- */
-static __cpuinitdata raw_spinlock_t sync_lock = __RAW_SPIN_LOCK_UNLOCKED;
-static __cpuinitdata cycles_t last_tsc;
-static __cpuinitdata cycles_t max_warp;
-static __cpuinitdata int nr_warps;
-
-/*
- * TSC-warp measurement loop running on both CPUs:
- */
-static __cpuinit void check_tsc_warp(void)
-{
-       cycles_t start, now, prev, end;
-       int i;
-
-       start = get_cycles_sync();
-       /*
-        * The measurement runs for 20 msecs:
-        */
-       end = start + tsc_khz * 20ULL;
-       now = start;
-
-       for (i = 0; ; i++) {
-               /*
-                * We take the global lock, measure TSC, save the
-                * previous TSC that was measured (possibly on
-                * another CPU) and update the previous TSC timestamp.
-                */
-               __raw_spin_lock(&sync_lock);
-               prev = last_tsc;
-               now = get_cycles_sync();
-               last_tsc = now;
-               __raw_spin_unlock(&sync_lock);
-
-               /*
-                * Be nice every now and then (and also check whether
-                * measurement is done [we also insert a 100 million
-                * loops safety exit, so we dont lock up in case the
-                * TSC readout is totally broken]):
-                */
-               if (unlikely(!(i & 7))) {
-                       if (now > end || i > 100000000)
-                               break;
-                       cpu_relax();
-                       touch_nmi_watchdog();
-               }
-               /*
-                * Outside the critical section we can now see whether
-                * we saw a time-warp of the TSC going backwards:
-                */
-               if (unlikely(prev > now)) {
-                       __raw_spin_lock(&sync_lock);
-                       max_warp = max(max_warp, prev - now);
-                       nr_warps++;
-                       __raw_spin_unlock(&sync_lock);
-               }
-
-       }
-}
-
-/*
- * Source CPU calls into this - it waits for the freshly booted
- * target CPU to arrive and then starts the measurement:
- */
-void __cpuinit check_tsc_sync_source(int cpu)
-{
-       int cpus = 2;
-
-       /*
-        * No need to check if we already know that the TSC is not
-        * synchronized:
-        */
-       if (unsynchronized_tsc())
-               return;
-
-       printk(KERN_INFO "checking TSC synchronization [CPU#%d -> CPU#%d]:",
-                         smp_processor_id(), cpu);
-
-       /*
-        * Reset it - in case this is a second bootup:
-        */
-       atomic_set(&stop_count, 0);
-
-       /*
-        * Wait for the target to arrive:
-        */
-       while (atomic_read(&start_count) != cpus-1)
-               cpu_relax();
-       /*
-        * Trigger the target to continue into the measurement too:
-        */
-       atomic_inc(&start_count);
-
-       check_tsc_warp();
-
-       while (atomic_read(&stop_count) != cpus-1)
-               cpu_relax();
-
-       /*
-        * Reset it - just in case we boot another CPU later:
-        */
-       atomic_set(&start_count, 0);
-
-       if (nr_warps) {
-               printk("\n");
-               printk(KERN_WARNING "Measured %Ld cycles TSC warp between CPUs,"
-                                   " turning off TSC clock.\n", max_warp);
-               mark_tsc_unstable("check_tsc_sync_source failed");
-               nr_warps = 0;
-               max_warp = 0;
-               last_tsc = 0;
-       } else {
-               printk(" passed.\n");
-       }
-
-       /*
-        * Let the target continue with the bootup:
-        */
-       atomic_inc(&stop_count);
-}
-
-/*
- * Freshly booted CPUs call into this:
- */
-void __cpuinit check_tsc_sync_target(void)
-{
-       int cpus = 2;
-
-       if (unsynchronized_tsc())
-               return;
-
-       /*
-        * Register this CPU's participation and wait for the
-        * source CPU to start the measurement:
-        */
-       atomic_inc(&start_count);
-       while (atomic_read(&start_count) != cpus)
-               cpu_relax();
-
-       check_tsc_warp();
-
-       /*
-        * Ok, we are done:
-        */
-       atomic_inc(&stop_count);
-
-       /*
-        * Wait for the source CPU to print stuff:
-        */
-       while (atomic_read(&stop_count) != cpus)
-               cpu_relax();
-}
-#undef NR_LOOPS
-
diff --git a/arch/x86_64/kernel/verify_cpu.S b/arch/x86_64/kernel/verify_cpu.S
deleted file mode 100644 (file)
index 45b6f8a..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- *
- *     verify_cpu.S - Code for cpu long mode and SSE verification. This
- *     code has been borrowed from boot/setup.S and was introduced by
- *     Andi Kleen.
- *
- *     Copyright (c) 2007  Andi Kleen (ak@suse.de)
- *     Copyright (c) 2007  Eric Biederman (ebiederm@xmission.com)
- *     Copyright (c) 2007  Vivek Goyal (vgoyal@in.ibm.com)
- *
- *     This source code is licensed under the GNU General Public License,
- *     Version 2.  See the file COPYING for more details.
- *
- *     This is a common code for verification whether CPU supports
- *     long mode and SSE or not. It is not called directly instead this
- *     file is included at various places and compiled in that context.
- *     Following are the current usage.
- *
- *     This file is included by both 16bit and 32bit code.
- *
- *     arch/x86_64/boot/setup.S : Boot cpu verification (16bit)
- *     arch/x86_64/boot/compressed/head.S: Boot cpu verification (32bit)
- *     arch/x86_64/kernel/trampoline.S: secondary processor verfication (16bit)
- *     arch/x86_64/kernel/acpi/wakeup.S:Verfication at resume (16bit)
- *
- *     verify_cpu, returns the status of cpu check in register %eax.
- *             0: Success    1: Failure
- *
- *     The caller needs to check for the error code and take the action
- *     appropriately. Either display a message or halt.
- */
-
-#include <asm/cpufeature.h>
-
-verify_cpu:
-       pushfl                          # Save caller passed flags
-       pushl   $0                      # Kill any dangerous flags
-       popfl
-
-       pushfl                          # standard way to check for cpuid
-       popl    %eax
-       movl    %eax,%ebx
-       xorl    $0x200000,%eax
-       pushl   %eax
-       popfl
-       pushfl
-       popl    %eax
-       cmpl    %eax,%ebx
-       jz      verify_cpu_no_longmode  # cpu has no cpuid
-
-       movl    $0x0,%eax               # See if cpuid 1 is implemented
-       cpuid
-       cmpl    $0x1,%eax
-       jb      verify_cpu_no_longmode  # no cpuid 1
-
-       xor     %di,%di
-       cmpl    $0x68747541,%ebx        # AuthenticAMD
-       jnz     verify_cpu_noamd
-       cmpl    $0x69746e65,%edx
-       jnz     verify_cpu_noamd
-       cmpl    $0x444d4163,%ecx
-       jnz     verify_cpu_noamd
-       mov     $1,%di                  # cpu is from AMD
-
-verify_cpu_noamd:
-       movl    $0x1,%eax               # Does the cpu have what it takes
-       cpuid
-       andl    $REQUIRED_MASK0,%edx
-       xorl    $REQUIRED_MASK0,%edx
-       jnz     verify_cpu_no_longmode
-
-       movl    $0x80000000,%eax        # See if extended cpuid is implemented
-       cpuid
-       cmpl    $0x80000001,%eax
-       jb      verify_cpu_no_longmode  # no extended cpuid
-
-       movl    $0x80000001,%eax        # Does the cpu have what it takes
-       cpuid
-       andl    $REQUIRED_MASK1,%edx
-       xorl    $REQUIRED_MASK1,%edx
-       jnz     verify_cpu_no_longmode
-
-verify_cpu_sse_test:
-       movl    $1,%eax
-       cpuid
-       andl    $SSE_MASK,%edx
-       cmpl    $SSE_MASK,%edx
-       je      verify_cpu_sse_ok
-       test    %di,%di
-       jz      verify_cpu_no_longmode  # only try to force SSE on AMD
-       movl    $0xc0010015,%ecx        # HWCR
-       rdmsr
-       btr     $15,%eax                # enable SSE
-       wrmsr
-       xor     %di,%di                 # don't loop
-       jmp     verify_cpu_sse_test     # try again
-
-verify_cpu_no_longmode:
-       popfl                           # Restore caller passed flags
-       movl $1,%eax
-       ret
-verify_cpu_sse_ok:
-       popfl                           # Restore caller passed flags
-       xorl %eax, %eax
-       ret
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
deleted file mode 100644 (file)
index ba8ea97..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ld script to make x86-64 Linux kernel
- * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
- */
-
-#define LOAD_OFFSET __START_KERNEL_map
-
-#include <asm-generic/vmlinux.lds.h>
-#include <asm/page.h>
-
-#undef i386    /* in case the preprocessor is a 32bit one */
-
-OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
-OUTPUT_ARCH(i386:x86-64)
-ENTRY(phys_startup_64)
-jiffies_64 = jiffies;
-_proxy_pda = 1;
-PHDRS {
-       text PT_LOAD FLAGS(5);  /* R_E */
-       data PT_LOAD FLAGS(7);  /* RWE */
-       user PT_LOAD FLAGS(7);  /* RWE */
-       data.init PT_LOAD FLAGS(7);     /* RWE */
-       note PT_NOTE FLAGS(4);  /* R__ */
-}
-SECTIONS
-{
-  . = __START_KERNEL;
-  phys_startup_64 = startup_64 - LOAD_OFFSET;
-  _text = .;                   /* Text and read-only data */
-  .text :  AT(ADDR(.text) - LOAD_OFFSET) {
-       /* First the code that has to be first for bootstrapping */
-       *(.text.head)
-       _stext = .;
-       /* Then the rest */
-       TEXT_TEXT
-       SCHED_TEXT
-       LOCK_TEXT
-       KPROBES_TEXT
-       *(.fixup)
-       *(.gnu.warning)
-       } :text = 0x9090
-                               /* out-of-line lock text */
-  .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
-
-  _etext = .;                  /* End of text section */
-
-  . = ALIGN(16);               /* Exception table */
-  __start___ex_table = .;
-  __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
-  __stop___ex_table = .;
-
-  NOTES :text :note
-
-  BUG_TABLE :text
-
-  RODATA
-
-  . = ALIGN(4);
-  .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
-       __tracedata_start = .;
-       *(.tracedata)
-       __tracedata_end = .;
-  }
-
-  . = ALIGN(PAGE_SIZE);        /* Align data segment to page size boundary */
-                               /* Data */
-  .data : AT(ADDR(.data) - LOAD_OFFSET) {
-       DATA_DATA
-       CONSTRUCTORS
-       } :data
-
-  _edata = .;                  /* End of data section */
-
-  . = ALIGN(PAGE_SIZE);
-  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
-  .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
-       *(.data.cacheline_aligned)
-  }
-  . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES);
-  .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
-       *(.data.read_mostly)
-  }
-
-#define VSYSCALL_ADDR (-10*1024*1024)
-#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
-#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
-
-#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
-#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
-
-#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
-#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
-
-  . = VSYSCALL_ADDR;
-  .vsyscall_0 :         AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
-  __vsyscall_0 = VSYSCALL_VIRT_ADDR;
-
-  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
-  .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { *(.vsyscall_fn) }
-  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
-  .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data))
-               { *(.vsyscall_gtod_data) }
-  vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
-  .vsyscall_clock : AT(VLOAD(.vsyscall_clock))
-               { *(.vsyscall_clock) }
-  vsyscall_clock = VVIRT(.vsyscall_clock);
-
-
-  .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1))
-               { *(.vsyscall_1) }
-  .vsyscall_2 ADDR(.vsyscall_0) + 2048: AT(VLOAD(.vsyscall_2))
-               { *(.vsyscall_2) }
-
-  .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) { *(.vgetcpu_mode) }
-  vgetcpu_mode = VVIRT(.vgetcpu_mode);
-
-  . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
-  .jiffies : AT(VLOAD(.jiffies)) { *(.jiffies) }
-  jiffies = VVIRT(.jiffies);
-
-  .vsyscall_3 ADDR(.vsyscall_0) + 3072: AT(VLOAD(.vsyscall_3))
-               { *(.vsyscall_3) }
-
-  . = VSYSCALL_VIRT_ADDR + 4096;
-
-#undef VSYSCALL_ADDR
-#undef VSYSCALL_PHYS_ADDR
-#undef VSYSCALL_VIRT_ADDR
-#undef VLOAD_OFFSET
-#undef VLOAD
-#undef VVIRT_OFFSET
-#undef VVIRT
-
-  . = ALIGN(8192);             /* init_task */
-  .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
-       *(.data.init_task)
-  }:data.init
-
-  . = ALIGN(4096);
-  .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
-       *(.data.page_aligned)
-  }
-
-  /* might get freed after init */
-  . = ALIGN(4096);
-  __smp_alt_begin = .;
-  __smp_locks = .;
-  .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
-       *(.smp_locks)
-  }
-  __smp_locks_end = .;
-  . = ALIGN(4096);
-  __smp_alt_end = .;
-
-  . = ALIGN(4096);             /* Init code and data */
-  __init_begin = .;
-  .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
-       _sinittext = .;
-       *(.init.text)
-       _einittext = .;
-  }
-  __initdata_begin = .;
-  .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
-  __initdata_end = .;
-  . = ALIGN(16);
-  __setup_start = .;
-  .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) }
-  __setup_end = .;
-  __initcall_start = .;
-  .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
-       INITCALLS
-  }
-  __initcall_end = .;
-  __con_initcall_start = .;
-  .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
-       *(.con_initcall.init)
-  }
-  __con_initcall_end = .;
-  SECURITY_INIT
-  . = ALIGN(8);
-  __alt_instructions = .;
-  .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
-       *(.altinstructions)
-  }
-  __alt_instructions_end = .; 
-  .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
-       *(.altinstr_replacement)
-  }
-  /* .exit.text is discard at runtime, not link time, to deal with references
-     from .altinstructions and .eh_frame */
-  .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
-  .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
-
-/* vdso blob that is mapped into user space */
-  vdso_start = . ;
-  .vdso  : AT(ADDR(.vdso) - LOAD_OFFSET) { *(.vdso) }
-  . = ALIGN(4096);
-  vdso_end = .;
-
-#ifdef CONFIG_BLK_DEV_INITRD
-  . = ALIGN(4096);
-  __initramfs_start = .;
-  .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
-  __initramfs_end = .;
-#endif
-
-  PERCPU(4096)
-
-  . = ALIGN(4096);
-  __init_end = .;
-
-  . = ALIGN(4096);
-  __nosave_begin = .;
-  .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) }
-  . = ALIGN(4096);
-  __nosave_end = .;
-
-  __bss_start = .;             /* BSS */
-  .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
-       *(.bss.page_aligned)
-       *(.bss)
-       }
-  __bss_stop = .;
-
-  _end = . ;
-
-  /* Sections to be discarded */
-  /DISCARD/ : {
-       *(.exitcall.exit)
-       *(.eh_frame)
-       }
-
-  STABS_DEBUG
-
-  DWARF_DEBUG
-}
diff --git a/arch/x86_64/kernel/vsmp.c b/arch/x86_64/kernel/vsmp.c
deleted file mode 100644 (file)
index 414caf0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * vSMPowered(tm) systems specific initialization
- * Copyright (C) 2005 ScaleMP Inc.
- *
- * Use of this code is subject to the terms and conditions of the
- * GNU general public license version 2. See "COPYING" or
- * http://www.gnu.org/licenses/gpl.html
- *
- * Ravikiran Thirumalai <kiran@scalemp.com>,
- * Shai Fultheim <shai@scalemp.com>
- */
-
-#include <linux/init.h>
-#include <linux/pci_ids.h>
-#include <linux/pci_regs.h>
-#include <asm/pci-direct.h>
-#include <asm/io.h>
-
-static int __init vsmp_init(void)
-{
-       void *address;
-       unsigned int cap, ctl;
-
-       if (!early_pci_allowed())
-               return 0;
-
-       /* Check if we are running on a ScaleMP vSMP box */
-       if ((read_pci_config_16(0, 0x1f, 0, PCI_VENDOR_ID) != PCI_VENDOR_ID_SCALEMP) ||
-           (read_pci_config_16(0, 0x1f, 0, PCI_DEVICE_ID) != PCI_DEVICE_ID_SCALEMP_VSMP_CTL))
-               return 0;
-
-       /* set vSMP magic bits to indicate vSMP capable kernel */
-       address = ioremap(read_pci_config(0, 0x1f, 0, PCI_BASE_ADDRESS_0), 8);
-       cap = readl(address);
-       ctl = readl(address + 4);
-       printk("vSMP CTL: capabilities:0x%08x  control:0x%08x\n", cap, ctl);
-       if (cap & ctl & (1 << 4)) {
-               /* Turn on vSMP IRQ fastpath handling (see system.h) */
-               ctl &= ~(1 << 4);
-               writel(ctl, address + 4);
-               ctl = readl(address + 4);
-               printk("vSMP CTL: control set to:0x%08x\n", ctl);
-       }
-
-       iounmap(address);
-       return 0;
-}
-
-core_initcall(vsmp_init);
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
deleted file mode 100644 (file)
index 06c3494..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- *  linux/arch/x86_64/kernel/vsyscall.c
- *
- *  Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE
- *  Copyright 2003 Andi Kleen, SuSE Labs.
- *
- *  Thanks to hpa@transmeta.com for some useful hint.
- *  Special thanks to Ingo Molnar for his early experience with
- *  a different vsyscall implementation for Linux/IA32 and for the name.
- *
- *  vsyscall 1 is located at -10Mbyte, vsyscall 2 is located
- *  at virtual address -10Mbyte+1024bytes etc... There are at max 4
- *  vsyscalls. One vsyscall can reserve more than 1 slot to avoid
- *  jumping out of line if necessary. We cannot add more with this
- *  mechanism because older kernels won't return -ENOSYS.
- *  If we want more than four we need a vDSO.
- *
- *  Note: the concept clashes with user mode linux. If you use UML and
- *  want per guest time just set the kernel.vsyscall64 sysctl to 0.
- */
-
-#include <linux/time.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/seqlock.h>
-#include <linux/jiffies.h>
-#include <linux/sysctl.h>
-#include <linux/clocksource.h>
-#include <linux/getcpu.h>
-#include <linux/cpu.h>
-#include <linux/smp.h>
-#include <linux/notifier.h>
-
-#include <asm/vsyscall.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/unistd.h>
-#include <asm/fixmap.h>
-#include <asm/errno.h>
-#include <asm/io.h>
-#include <asm/segment.h>
-#include <asm/desc.h>
-#include <asm/topology.h>
-#include <asm/vgtod.h>
-
-#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
-#define __syscall_clobber "r11","rcx","memory"
-#define __pa_vsymbol(x)                        \
-       ({unsigned long v;              \
-       extern char __vsyscall_0;       \
-         asm("" : "=r" (v) : "0" (x)); \
-         ((v - VSYSCALL_FIRST_PAGE) + __pa_symbol(&__vsyscall_0)); })
-
-/*
- * vsyscall_gtod_data contains data that is :
- * - readonly from vsyscalls
- * - writen by timer interrupt or systcl (/proc/sys/kernel/vsyscall64)
- * Try to keep this structure as small as possible to avoid cache line ping pongs
- */
-int __vgetcpu_mode __section_vgetcpu_mode;
-
-struct vsyscall_gtod_data __vsyscall_gtod_data __section_vsyscall_gtod_data =
-{
-       .lock = SEQLOCK_UNLOCKED,
-       .sysctl_enabled = 1,
-};
-
-void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
-{
-       unsigned long flags;
-
-       write_seqlock_irqsave(&vsyscall_gtod_data.lock, flags);
-       /* copy vsyscall data */
-       vsyscall_gtod_data.clock.vread = clock->vread;
-       vsyscall_gtod_data.clock.cycle_last = clock->cycle_last;
-       vsyscall_gtod_data.clock.mask = clock->mask;
-       vsyscall_gtod_data.clock.mult = clock->mult;
-       vsyscall_gtod_data.clock.shift = clock->shift;
-       vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
-       vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
-       vsyscall_gtod_data.sys_tz = sys_tz;
-       vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
-       vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic;
-       write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
-}
-
-/* RED-PEN may want to readd seq locking, but then the variable should be
- * write-once.
- */
-static __always_inline void do_get_tz(struct timezone * tz)
-{
-       *tz = __vsyscall_gtod_data.sys_tz;
-}
-
-static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-       int ret;
-       asm volatile("vsysc2: syscall"
-               : "=a" (ret)
-               : "0" (__NR_gettimeofday),"D" (tv),"S" (tz)
-               : __syscall_clobber );
-       return ret;
-}
-
-static __always_inline long time_syscall(long *t)
-{
-       long secs;
-       asm volatile("vsysc1: syscall"
-               : "=a" (secs)
-               : "0" (__NR_time),"D" (t) : __syscall_clobber);
-       return secs;
-}
-
-static __always_inline void do_vgettimeofday(struct timeval * tv)
-{
-       cycle_t now, base, mask, cycle_delta;
-       unsigned seq;
-       unsigned long mult, shift, nsec;
-       cycle_t (*vread)(void);
-       do {
-               seq = read_seqbegin(&__vsyscall_gtod_data.lock);
-
-               vread = __vsyscall_gtod_data.clock.vread;
-               if (unlikely(!__vsyscall_gtod_data.sysctl_enabled || !vread)) {
-                       gettimeofday(tv,NULL);
-                       return;
-               }
-               now = vread();
-               base = __vsyscall_gtod_data.clock.cycle_last;
-               mask = __vsyscall_gtod_data.clock.mask;
-               mult = __vsyscall_gtod_data.clock.mult;
-               shift = __vsyscall_gtod_data.clock.shift;
-
-               tv->tv_sec = __vsyscall_gtod_data.wall_time_sec;
-               nsec = __vsyscall_gtod_data.wall_time_nsec;
-       } while (read_seqretry(&__vsyscall_gtod_data.lock, seq));
-
-       /* calculate interval: */
-       cycle_delta = (now - base) & mask;
-       /* convert to nsecs: */
-       nsec += (cycle_delta * mult) >> shift;
-
-       while (nsec >= NSEC_PER_SEC) {
-               tv->tv_sec += 1;
-               nsec -= NSEC_PER_SEC;
-       }
-       tv->tv_usec = nsec / NSEC_PER_USEC;
-}
-
-int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
-{
-       if (tv)
-               do_vgettimeofday(tv);
-       if (tz)
-               do_get_tz(tz);
-       return 0;
-}
-
-/* This will break when the xtime seconds get inaccurate, but that is
- * unlikely */
-time_t __vsyscall(1) vtime(time_t *t)
-{
-       struct timeval tv;
-       time_t result;
-       if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
-               return time_syscall(t);
-
-       vgettimeofday(&tv, 0);
-       result = tv.tv_sec;
-       if (t)
-               *t = result;
-       return result;
-}
-
-/* Fast way to get current CPU and node.
-   This helps to do per node and per CPU caches in user space.
-   The result is not guaranteed without CPU affinity, but usually
-   works out because the scheduler tries to keep a thread on the same
-   CPU.
-
-   tcache must point to a two element sized long array.
-   All arguments can be NULL. */
-long __vsyscall(2)
-vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
-{
-       unsigned int dummy, p;
-       unsigned long j = 0;
-
-       /* Fast cache - only recompute value once per jiffies and avoid
-          relatively costly rdtscp/cpuid otherwise.
-          This works because the scheduler usually keeps the process
-          on the same CPU and this syscall doesn't guarantee its
-          results anyways.
-          We do this here because otherwise user space would do it on
-          its own in a likely inferior way (no access to jiffies).
-          If you don't like it pass NULL. */
-       if (tcache && tcache->blob[0] == (j = __jiffies)) {
-               p = tcache->blob[1];
-       } else if (__vgetcpu_mode == VGETCPU_RDTSCP) {
-               /* Load per CPU data from RDTSCP */
-               rdtscp(dummy, dummy, p);
-       } else {
-               /* Load per CPU data from GDT */
-               asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
-       }
-       if (tcache) {
-               tcache->blob[0] = j;
-               tcache->blob[1] = p;
-       }
-       if (cpu)
-               *cpu = p & 0xfff;
-       if (node)
-               *node = p >> 12;
-       return 0;
-}
-
-long __vsyscall(3) venosys_1(void)
-{
-       return -ENOSYS;
-}
-
-#ifdef CONFIG_SYSCTL
-
-#define SYSCALL 0x050f
-#define NOP2    0x9090
-
-/*
- * NOP out syscall in vsyscall page when not needed.
- */
-static int vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * filp,
-                        void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       extern u16 vsysc1, vsysc2;
-       u16 __iomem *map1;
-       u16 __iomem *map2;
-       int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
-       if (!write)
-               return ret;
-       /* gcc has some trouble with __va(__pa()), so just do it this
-          way. */
-       map1 = ioremap(__pa_vsymbol(&vsysc1), 2);
-       if (!map1)
-               return -ENOMEM;
-       map2 = ioremap(__pa_vsymbol(&vsysc2), 2);
-       if (!map2) {
-               ret = -ENOMEM;
-               goto out;
-       }
-       if (!vsyscall_gtod_data.sysctl_enabled) {
-               writew(SYSCALL, map1);
-               writew(SYSCALL, map2);
-       } else {
-               writew(NOP2, map1);
-               writew(NOP2, map2);
-       }
-       iounmap(map2);
-out:
-       iounmap(map1);
-       return ret;
-}
-
-static int vsyscall_sysctl_nostrat(ctl_table *t, int __user *name, int nlen,
-                               void __user *oldval, size_t __user *oldlenp,
-                               void __user *newval, size_t newlen)
-{
-       return -ENOSYS;
-}
-
-static ctl_table kernel_table2[] = {
-       { .ctl_name = 99, .procname = "vsyscall64",
-         .data = &vsyscall_gtod_data.sysctl_enabled, .maxlen = sizeof(int),
-         .mode = 0644,
-         .strategy = vsyscall_sysctl_nostrat,
-         .proc_handler = vsyscall_sysctl_change },
-       {}
-};
-
-static ctl_table kernel_root_table2[] = {
-       { .ctl_name = CTL_KERN, .procname = "kernel", .mode = 0555,
-         .child = kernel_table2 },
-       {}
-};
-
-#endif
-
-/* Assume __initcall executes before all user space. Hopefully kmod
-   doesn't violate that. We'll find out if it does. */
-static void __cpuinit vsyscall_set_cpu(int cpu)
-{
-       unsigned long *d;
-       unsigned long node = 0;
-#ifdef CONFIG_NUMA
-       node = cpu_to_node[cpu];
-#endif
-       if (cpu_has(&cpu_data[cpu], X86_FEATURE_RDTSCP))
-               write_rdtscp_aux((node << 12) | cpu);
-
-       /* Store cpu number in limit so that it can be loaded quickly
-          in user space in vgetcpu.
-          12 bits for the CPU and 8 bits for the node. */
-       d = (unsigned long *)(cpu_gdt(cpu) + GDT_ENTRY_PER_CPU);
-       *d = 0x0f40000000000ULL;
-       *d |= cpu;
-       *d |= (node & 0xf) << 12;
-       *d |= (node >> 4) << 48;
-}
-
-static void __cpuinit cpu_vsyscall_init(void *arg)
-{
-       /* preemption should be already off */
-       vsyscall_set_cpu(raw_smp_processor_id());
-}
-
-static int __cpuinit
-cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
-{
-       long cpu = (long)arg;
-       if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN)
-               smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1);
-       return NOTIFY_DONE;
-}
-
-static void __init map_vsyscall(void)
-{
-       extern char __vsyscall_0;
-       unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
-
-       /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
-       __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
-}
-
-static int __init vsyscall_init(void)
-{
-       BUG_ON(((unsigned long) &vgettimeofday !=
-                       VSYSCALL_ADDR(__NR_vgettimeofday)));
-       BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime));
-       BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
-       BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
-       map_vsyscall();
-#ifdef CONFIG_SYSCTL
-       register_sysctl_table(kernel_root_table2);
-#endif
-       on_each_cpu(cpu_vsyscall_init, NULL, 0, 1);
-       hotcpu_notifier(cpu_vsyscall_notifier, 0);
-       return 0;
-}
-
-__initcall(vsyscall_init);
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
deleted file mode 100644 (file)
index 77c25b3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Exports for assembly files.
-   All C exports should go in the respective C files. */
-
-#include <linux/module.h>
-#include <linux/smp.h>
-
-#include <asm/semaphore.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-
-EXPORT_SYMBOL(kernel_thread);
-
-EXPORT_SYMBOL(__down_failed);
-EXPORT_SYMBOL(__down_failed_interruptible);
-EXPORT_SYMBOL(__down_failed_trylock);
-EXPORT_SYMBOL(__up_wakeup);
-
-EXPORT_SYMBOL(__get_user_1);
-EXPORT_SYMBOL(__get_user_2);
-EXPORT_SYMBOL(__get_user_4);
-EXPORT_SYMBOL(__get_user_8);
-EXPORT_SYMBOL(__put_user_1);
-EXPORT_SYMBOL(__put_user_2);
-EXPORT_SYMBOL(__put_user_4);
-EXPORT_SYMBOL(__put_user_8);
-
-EXPORT_SYMBOL(copy_user_generic);
-EXPORT_SYMBOL(__copy_user_nocache);
-EXPORT_SYMBOL(copy_from_user);
-EXPORT_SYMBOL(copy_to_user);
-EXPORT_SYMBOL(__copy_from_user_inatomic);
-
-EXPORT_SYMBOL(copy_page);
-EXPORT_SYMBOL(clear_page);
-
-#ifdef CONFIG_SMP
-extern void  __write_lock_failed(rwlock_t *rw);
-extern void  __read_lock_failed(rwlock_t *rw);
-EXPORT_SYMBOL(__write_lock_failed);
-EXPORT_SYMBOL(__read_lock_failed);
-#endif
-
-/* Export string functions. We normally rely on gcc builtin for most of these,
-   but gcc sometimes decides not to inline them. */    
-#undef memcpy
-#undef memset
-#undef memmove
-
-extern void * memset(void *,int,__kernel_size_t);
-extern void * memcpy(void *,const void *,__kernel_size_t);
-extern void * __memcpy(void *,const void *,__kernel_size_t);
-
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(__memcpy);
-
-EXPORT_SYMBOL(empty_zero_page);
-EXPORT_SYMBOL(init_level4_pgt);
-EXPORT_SYMBOL(load_gs_index);
-
-EXPORT_SYMBOL(_proxy_pda);
diff --git a/arch/x86_64/lib/Makefile b/arch/x86_64/lib/Makefile
deleted file mode 100644 (file)
index c943271..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Makefile for x86_64-specific library files.
-#
-
-CFLAGS_csum-partial.o := -funroll-loops
-
-obj-y := io.o iomap_copy.o
-obj-$(CONFIG_SMP)      += msr-on-cpu.o
-
-lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
-       usercopy.o getuser.o putuser.o  \
-       thunk.o clear_page.o copy_page.o bitstr.o bitops.o
-lib-y += memcpy.o memmove.o memset.o copy_user.o rwlock.o copy_user_nocache.o
diff --git a/arch/x86_64/lib/bitops.c b/arch/x86_64/lib/bitops.c
deleted file mode 100644 (file)
index 95b6d96..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#include <linux/bitops.h>
-
-#undef find_first_zero_bit
-#undef find_next_zero_bit
-#undef find_first_bit
-#undef find_next_bit
-
-static inline long
-__find_first_zero_bit(const unsigned long * addr, unsigned long size)
-{
-       long d0, d1, d2;
-       long res;
-
-       /*
-        * We must test the size in words, not in bits, because
-        * otherwise incoming sizes in the range -63..-1 will not run
-        * any scasq instructions, and then the flags used by the je
-        * instruction will have whatever random value was in place
-        * before.  Nobody should call us like that, but
-        * find_next_zero_bit() does when offset and size are at the
-        * same word and it fails to find a zero itself.
-        */
-       size += 63;
-       size >>= 6;
-       if (!size)
-               return 0;
-       asm volatile(
-               "  repe; scasq\n"
-               "  je 1f\n"
-               "  xorq -8(%%rdi),%%rax\n"
-               "  subq $8,%%rdi\n"
-               "  bsfq %%rax,%%rdx\n"
-               "1:  subq %[addr],%%rdi\n"
-               "  shlq $3,%%rdi\n"
-               "  addq %%rdi,%%rdx"
-               :"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
-               :"0" (0ULL), "1" (size), "2" (addr), "3" (-1ULL),
-                [addr] "S" (addr) : "memory");
-       /*
-        * Any register would do for [addr] above, but GCC tends to
-        * prefer rbx over rsi, even though rsi is readily available
-        * and doesn't have to be saved.
-        */
-       return res;
-}
-
-/**
- * find_first_zero_bit - find the first zero bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit-number of the first zero bit, not the number of the byte
- * containing a bit.
- */
-long find_first_zero_bit(const unsigned long * addr, unsigned long size)
-{
-       return __find_first_zero_bit (addr, size);
-}
-
-/**
- * find_next_zero_bit - find the first zero bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The maximum size to search
- */
-long find_next_zero_bit (const unsigned long * addr, long size, long offset)
-{
-       const unsigned long * p = addr + (offset >> 6);
-       unsigned long set = 0;
-       unsigned long res, bit = offset&63;
-
-       if (bit) {
-               /*
-                * Look for zero in first word
-                */
-               asm("bsfq %1,%0\n\t"
-                   "cmoveq %2,%0"
-                   : "=r" (set)
-                   : "r" (~(*p >> bit)), "r"(64L));
-               if (set < (64 - bit))
-                       return set + offset;
-               set = 64 - bit;
-               p++;
-       }
-       /*
-        * No zero yet, search remaining full words for a zero
-        */
-       res = __find_first_zero_bit (p, size - 64 * (p - addr));
-
-       return (offset + set + res);
-}
-
-static inline long
-__find_first_bit(const unsigned long * addr, unsigned long size)
-{
-       long d0, d1;
-       long res;
-
-       /*
-        * We must test the size in words, not in bits, because
-        * otherwise incoming sizes in the range -63..-1 will not run
-        * any scasq instructions, and then the flags used by the jz
-        * instruction will have whatever random value was in place
-        * before.  Nobody should call us like that, but
-        * find_next_bit() does when offset and size are at the same
-        * word and it fails to find a one itself.
-        */
-       size += 63;
-       size >>= 6;
-       if (!size)
-               return 0;
-       asm volatile(
-               "   repe; scasq\n"
-               "   jz 1f\n"
-               "   subq $8,%%rdi\n"
-               "   bsfq (%%rdi),%%rax\n"
-               "1: subq %[addr],%%rdi\n"
-               "   shlq $3,%%rdi\n"
-               "   addq %%rdi,%%rax"
-               :"=a" (res), "=&c" (d0), "=&D" (d1)
-               :"0" (0ULL), "1" (size), "2" (addr),
-                [addr] "r" (addr) : "memory");
-       return res;
-}
-
-/**
- * find_first_bit - find the first set bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit-number of the first set bit, not the number of the byte
- * containing a bit.
- */
-long find_first_bit(const unsigned long * addr, unsigned long size)
-{
-       return __find_first_bit(addr,size);
-}
-
-/**
- * find_next_bit - find the first set bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The maximum size to search
- */
-long find_next_bit(const unsigned long * addr, long size, long offset)
-{
-       const unsigned long * p = addr + (offset >> 6);
-       unsigned long set = 0, bit = offset & 63, res;
-
-       if (bit) {
-               /*
-                * Look for nonzero in the first 64 bits:
-                */
-               asm("bsfq %1,%0\n\t"
-                   "cmoveq %2,%0\n\t"
-                   : "=r" (set)
-                   : "r" (*p >> bit), "r" (64L));
-               if (set < (64 - bit))
-                       return set + offset;
-               set = 64 - bit;
-               p++;
-       }
-       /*
-        * No set bit yet, search remaining full words for a bit
-        */
-       res = __find_first_bit (p, size - 64 * (p - addr));
-       return (offset + set + res);
-}
-
-#include <linux/module.h>
-
-EXPORT_SYMBOL(find_next_bit);
-EXPORT_SYMBOL(find_first_bit);
-EXPORT_SYMBOL(find_first_zero_bit);
-EXPORT_SYMBOL(find_next_zero_bit);
diff --git a/arch/x86_64/lib/bitstr.c b/arch/x86_64/lib/bitstr.c
deleted file mode 100644 (file)
index 2467660..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <linux/module.h>
-#include <linux/bitops.h>
-
-/* Find string of zero bits in a bitmap */ 
-unsigned long 
-find_next_zero_string(unsigned long *bitmap, long start, long nbits, int len)
-{ 
-       unsigned long n, end, i;        
-
- again:
-       n = find_next_zero_bit(bitmap, nbits, start);
-       if (n == -1) 
-               return -1;
-       
-       /* could test bitsliced, but it's hardly worth it */
-       end = n+len;
-       if (end >= nbits) 
-               return -1; 
-       for (i = n+1; i < end; i++) { 
-               if (test_bit(i, bitmap)) {  
-                       start = i+1; 
-                       goto again; 
-               } 
-       }
-       return n;
-}
-
-EXPORT_SYMBOL(find_next_zero_string);
diff --git a/arch/x86_64/lib/clear_page.S b/arch/x86_64/lib/clear_page.S
deleted file mode 100644 (file)
index 9a10a78..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-/*
- * Zero a page.        
- * rdi page
- */                    
-       ALIGN
-clear_page_c:
-       CFI_STARTPROC
-       movl $4096/8,%ecx
-       xorl %eax,%eax
-       rep stosq
-       ret
-       CFI_ENDPROC
-ENDPROC(clear_page)
-
-ENTRY(clear_page)
-       CFI_STARTPROC
-       xorl   %eax,%eax
-       movl   $4096/64,%ecx
-       .p2align 4
-.Lloop:
-       decl    %ecx
-#define PUT(x) movq %rax,x*8(%rdi)
-       movq %rax,(%rdi)
-       PUT(1)
-       PUT(2)
-       PUT(3)
-       PUT(4)
-       PUT(5)
-       PUT(6)
-       PUT(7)
-       leaq    64(%rdi),%rdi
-       jnz     .Lloop
-       nop
-       ret
-       CFI_ENDPROC
-.Lclear_page_end:
-ENDPROC(clear_page)
-
-       /* Some CPUs run faster using the string instructions.
-          It is also a lot simpler. Use this when possible */
-
-#include <asm/cpufeature.h>
-
-       .section .altinstr_replacement,"ax"
-1:     .byte 0xeb                                      /* jmp <disp8> */
-       .byte (clear_page_c - clear_page) - (2f - 1b)   /* offset */
-2:
-       .previous
-       .section .altinstructions,"a"
-       .align 8
-       .quad clear_page
-       .quad 1b
-       .byte X86_FEATURE_REP_GOOD
-       .byte .Lclear_page_end - clear_page
-       .byte 2b - 1b
-       .previous
diff --git a/arch/x86_64/lib/copy_page.S b/arch/x86_64/lib/copy_page.S
deleted file mode 100644 (file)
index 727a5d4..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Written 2003 by Andi Kleen, based on a kernel by Evandro Menezes */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-       ALIGN
-copy_page_c:
-       CFI_STARTPROC
-       movl $4096/8,%ecx
-       rep movsq
-       ret
-       CFI_ENDPROC
-ENDPROC(copy_page_c)
-
-/* Don't use streaming store because it's better when the target
-   ends up in cache. */
-           
-/* Could vary the prefetch distance based on SMP/UP */
-
-ENTRY(copy_page)
-       CFI_STARTPROC
-       subq    $3*8,%rsp
-       CFI_ADJUST_CFA_OFFSET 3*8
-       movq    %rbx,(%rsp)
-       CFI_REL_OFFSET rbx, 0
-       movq    %r12,1*8(%rsp)
-       CFI_REL_OFFSET r12, 1*8
-       movq    %r13,2*8(%rsp)
-       CFI_REL_OFFSET r13, 2*8
-
-       movl    $(4096/64)-5,%ecx
-       .p2align 4
-.Loop64:
-       dec     %rcx
-
-       movq        (%rsi), %rax
-       movq      8 (%rsi), %rbx
-       movq     16 (%rsi), %rdx
-       movq     24 (%rsi), %r8
-       movq     32 (%rsi), %r9
-       movq     40 (%rsi), %r10
-       movq     48 (%rsi), %r11
-       movq     56 (%rsi), %r12
-
-       prefetcht0 5*64(%rsi)
-
-       movq     %rax,    (%rdi)
-       movq     %rbx,  8 (%rdi)
-       movq     %rdx, 16 (%rdi)
-       movq     %r8,  24 (%rdi)
-       movq     %r9,  32 (%rdi)
-       movq     %r10, 40 (%rdi)
-       movq     %r11, 48 (%rdi)
-       movq     %r12, 56 (%rdi)
-
-       leaq    64 (%rsi), %rsi
-       leaq    64 (%rdi), %rdi
-
-       jnz     .Loop64
-
-       movl    $5,%ecx
-       .p2align 4
-.Loop2:
-       decl   %ecx
-
-       movq        (%rsi), %rax
-       movq      8 (%rsi), %rbx
-       movq     16 (%rsi), %rdx
-       movq     24 (%rsi), %r8
-       movq     32 (%rsi), %r9
-       movq     40 (%rsi), %r10
-       movq     48 (%rsi), %r11
-       movq     56 (%rsi), %r12
-
-       movq     %rax,    (%rdi)
-       movq     %rbx,  8 (%rdi)
-       movq     %rdx, 16 (%rdi)
-       movq     %r8,  24 (%rdi)
-       movq     %r9,  32 (%rdi)
-       movq     %r10, 40 (%rdi)
-       movq     %r11, 48 (%rdi)
-       movq     %r12, 56 (%rdi)
-
-       leaq    64(%rdi),%rdi
-       leaq    64(%rsi),%rsi
-
-       jnz     .Loop2
-
-       movq    (%rsp),%rbx
-       CFI_RESTORE rbx
-       movq    1*8(%rsp),%r12
-       CFI_RESTORE r12
-       movq    2*8(%rsp),%r13
-       CFI_RESTORE r13
-       addq    $3*8,%rsp
-       CFI_ADJUST_CFA_OFFSET -3*8
-       ret
-.Lcopy_page_end:
-       CFI_ENDPROC
-ENDPROC(copy_page)
-
-       /* Some CPUs run faster using the string copy instructions.
-          It is also a lot simpler. Use this when possible */
-
-#include <asm/cpufeature.h>
-
-       .section .altinstr_replacement,"ax"
-1:     .byte 0xeb                                      /* jmp <disp8> */
-       .byte (copy_page_c - copy_page) - (2f - 1b)     /* offset */
-2:
-       .previous
-       .section .altinstructions,"a"
-       .align 8
-       .quad copy_page
-       .quad 1b
-       .byte X86_FEATURE_REP_GOOD
-       .byte .Lcopy_page_end - copy_page
-       .byte 2b - 1b
-       .previous
diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
deleted file mode 100644 (file)
index 70bebd3..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/* Copyright 2002 Andi Kleen, SuSE Labs.
- * Subject to the GNU Public License v2.
- * 
- * Functions to copy from and to user space.           
- */             
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-#define FIX_ALIGNMENT 1
-
-#include <asm/current.h>
-#include <asm/asm-offsets.h>
-#include <asm/thread_info.h>
-#include <asm/cpufeature.h>
-
-       .macro ALTERNATIVE_JUMP feature,orig,alt
-0:
-       .byte 0xe9      /* 32bit jump */
-       .long \orig-1f  /* by default jump to orig */
-1:
-       .section .altinstr_replacement,"ax"
-2:     .byte 0xe9                   /* near jump with 32bit immediate */
-       .long \alt-1b /* offset */   /* or alternatively to alt */
-       .previous
-       .section .altinstructions,"a"
-       .align 8
-       .quad  0b
-       .quad  2b
-       .byte  \feature              /* when feature is set */
-       .byte  5
-       .byte  5
-       .previous
-       .endm
-
-/* Standard copy_to_user with segment limit checking */                
-ENTRY(copy_to_user)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%rax)
-       movq %rdi,%rcx
-       addq %rdx,%rcx
-       jc  bad_to_user
-       cmpq threadinfo_addr_limit(%rax),%rcx
-       jae bad_to_user
-       xorl %eax,%eax  /* clear zero flag */
-       ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
-       CFI_ENDPROC
-
-ENTRY(copy_user_generic)
-       CFI_STARTPROC
-       movl $1,%ecx    /* set zero flag */
-       ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
-       CFI_ENDPROC
-
-ENTRY(__copy_from_user_inatomic)
-       CFI_STARTPROC
-       xorl %ecx,%ecx  /* clear zero flag */
-       ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
-       CFI_ENDPROC
-
-/* Standard copy_from_user with segment limit checking */      
-ENTRY(copy_from_user)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%rax)
-       movq %rsi,%rcx
-       addq %rdx,%rcx
-       jc  bad_from_user
-       cmpq threadinfo_addr_limit(%rax),%rcx
-       jae  bad_from_user
-       movl $1,%ecx    /* set zero flag */
-       ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
-       CFI_ENDPROC
-ENDPROC(copy_from_user)
-       
-       .section .fixup,"ax"
-       /* must zero dest */
-bad_from_user:
-       CFI_STARTPROC
-       movl %edx,%ecx
-       xorl %eax,%eax
-       rep
-       stosb
-bad_to_user:
-       movl    %edx,%eax
-       ret
-       CFI_ENDPROC
-END(bad_from_user)
-       .previous
-       
-               
-/*
- * copy_user_generic_unrolled - memory copy with exception handling.
- * This version is for CPUs like P4 that don't have efficient micro code for rep movsq
- *     
- * Input:      
- * rdi destination
- * rsi source
- * rdx count
- * ecx zero flag -- if true zero destination on error
- *
- * Output:             
- * eax uncopied bytes or 0 if successful.
- */
-ENTRY(copy_user_generic_unrolled)
-       CFI_STARTPROC
-       pushq %rbx
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rbx, 0
-       pushq %rcx
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rcx, 0
-       xorl %eax,%eax          /*zero for the exception handler */
-
-#ifdef FIX_ALIGNMENT
-       /* check for bad alignment of destination */
-       movl %edi,%ecx
-       andl $7,%ecx
-       jnz  .Lbad_alignment
-.Lafter_bad_alignment:
-#endif
-
-       movq %rdx,%rcx
-
-       movl $64,%ebx
-       shrq $6,%rdx
-       decq %rdx
-       js   .Lhandle_tail
-
-       .p2align 4
-.Lloop:
-.Ls1:  movq (%rsi),%r11
-.Ls2:  movq 1*8(%rsi),%r8
-.Ls3:  movq 2*8(%rsi),%r9
-.Ls4:  movq 3*8(%rsi),%r10
-.Ld1:  movq %r11,(%rdi)
-.Ld2:  movq %r8,1*8(%rdi)
-.Ld3:  movq %r9,2*8(%rdi)
-.Ld4:  movq %r10,3*8(%rdi)
-
-.Ls5:  movq 4*8(%rsi),%r11
-.Ls6:  movq 5*8(%rsi),%r8
-.Ls7:  movq 6*8(%rsi),%r9
-.Ls8:  movq 7*8(%rsi),%r10
-.Ld5:  movq %r11,4*8(%rdi)
-.Ld6:  movq %r8,5*8(%rdi)
-.Ld7:  movq %r9,6*8(%rdi)
-.Ld8:  movq %r10,7*8(%rdi)
-
-       decq %rdx
-
-       leaq 64(%rsi),%rsi
-       leaq 64(%rdi),%rdi
-
-       jns  .Lloop
-
-       .p2align 4
-.Lhandle_tail:
-       movl %ecx,%edx
-       andl $63,%ecx
-       shrl $3,%ecx
-       jz   .Lhandle_7
-       movl $8,%ebx
-       .p2align 4
-.Lloop_8:
-.Ls9:  movq (%rsi),%r8
-.Ld9:  movq %r8,(%rdi)
-       decl %ecx
-       leaq 8(%rdi),%rdi
-       leaq 8(%rsi),%rsi
-       jnz .Lloop_8
-
-.Lhandle_7:
-       movl %edx,%ecx
-       andl $7,%ecx
-       jz   .Lende
-       .p2align 4
-.Lloop_1:
-.Ls10: movb (%rsi),%bl
-.Ld10: movb %bl,(%rdi)
-       incq %rdi
-       incq %rsi
-       decl %ecx
-       jnz .Lloop_1
-
-       CFI_REMEMBER_STATE
-.Lende:
-       popq %rcx
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_RESTORE rcx
-       popq %rbx
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_RESTORE rbx
-       ret
-       CFI_RESTORE_STATE
-
-#ifdef FIX_ALIGNMENT
-       /* align destination */
-       .p2align 4
-.Lbad_alignment:
-       movl $8,%r9d
-       subl %ecx,%r9d
-       movl %r9d,%ecx
-       cmpq %r9,%rdx
-       jz   .Lhandle_7
-       js   .Lhandle_7
-.Lalign_1:
-.Ls11: movb (%rsi),%bl
-.Ld11: movb %bl,(%rdi)
-       incq %rsi
-       incq %rdi
-       decl %ecx
-       jnz .Lalign_1
-       subq %r9,%rdx
-       jmp .Lafter_bad_alignment
-#endif
-
-       /* table sorted by exception address */
-       .section __ex_table,"a"
-       .align 8
-       .quad .Ls1,.Ls1e
-       .quad .Ls2,.Ls2e
-       .quad .Ls3,.Ls3e
-       .quad .Ls4,.Ls4e
-       .quad .Ld1,.Ls1e
-       .quad .Ld2,.Ls2e
-       .quad .Ld3,.Ls3e
-       .quad .Ld4,.Ls4e
-       .quad .Ls5,.Ls5e
-       .quad .Ls6,.Ls6e
-       .quad .Ls7,.Ls7e
-       .quad .Ls8,.Ls8e
-       .quad .Ld5,.Ls5e
-       .quad .Ld6,.Ls6e
-       .quad .Ld7,.Ls7e
-       .quad .Ld8,.Ls8e
-       .quad .Ls9,.Le_quad
-       .quad .Ld9,.Le_quad
-       .quad .Ls10,.Le_byte
-       .quad .Ld10,.Le_byte
-#ifdef FIX_ALIGNMENT
-       .quad .Ls11,.Lzero_rest
-       .quad .Ld11,.Lzero_rest
-#endif
-       .quad .Le5,.Le_zero
-       .previous
-
-       /* compute 64-offset for main loop. 8 bytes accuracy with error on the
-          pessimistic side. this is gross. it would be better to fix the
-          interface. */
-       /* eax: zero, ebx: 64 */
-.Ls1e:         addl $8,%eax
-.Ls2e:         addl $8,%eax
-.Ls3e:         addl $8,%eax
-.Ls4e:         addl $8,%eax
-.Ls5e:         addl $8,%eax
-.Ls6e:         addl $8,%eax
-.Ls7e:         addl $8,%eax
-.Ls8e:         addl $8,%eax
-       addq %rbx,%rdi  /* +64 */
-       subq %rax,%rdi  /* correct destination with computed offset */
-
-       shlq $6,%rdx    /* loop counter * 64 (stride length) */
-       addq %rax,%rdx  /* add offset to loopcnt */
-       andl $63,%ecx   /* remaining bytes */
-       addq %rcx,%rdx  /* add them */
-       jmp .Lzero_rest
-
-       /* exception on quad word loop in tail handling */
-       /* ecx: loopcnt/8, %edx: length, rdi: correct */
-.Le_quad:
-       shll $3,%ecx
-       andl $7,%edx
-       addl %ecx,%edx
-       /* edx: bytes to zero, rdi: dest, eax:zero */
-.Lzero_rest:
-       cmpl $0,(%rsp)
-       jz   .Le_zero
-       movq %rdx,%rcx
-.Le_byte:
-       xorl %eax,%eax
-.Le5:  rep
-       stosb
-       /* when there is another exception while zeroing the rest just return */
-.Le_zero:
-       movq %rdx,%rax
-       jmp .Lende
-       CFI_ENDPROC
-ENDPROC(copy_user_generic)
-
-
-       /* Some CPUs run faster using the string copy instructions.
-          This is also a lot simpler. Use them when possible.
-          Patch in jmps to this code instead of copying it fully
-          to avoid unwanted aliasing in the exception tables. */
-
- /* rdi        destination
-  * rsi source
-  * rdx count
-  * ecx zero flag
-  *
-  * Output:
-  * eax uncopied bytes or 0 if successfull.
-  *
-  * Only 4GB of copy is supported. This shouldn't be a problem
-  * because the kernel normally only writes from/to page sized chunks
-  * even if user space passed a longer buffer.
-  * And more would be dangerous because both Intel and AMD have
-  * errata with rep movsq > 4GB. If someone feels the need to fix
-  * this please consider this.
-  */
-ENTRY(copy_user_generic_string)
-       CFI_STARTPROC
-       movl %ecx,%r8d          /* save zero flag */
-       movl %edx,%ecx
-       shrl $3,%ecx
-       andl $7,%edx    
-       jz   10f
-1:     rep 
-       movsq 
-       movl %edx,%ecx
-2:     rep
-       movsb
-9:     movl %ecx,%eax
-       ret
-
-       /* multiple of 8 byte */
-10:    rep
-       movsq
-       xor %eax,%eax
-       ret
-
-       /* exception handling */
-3:      lea (%rdx,%rcx,8),%rax /* exception on quad loop */
-       jmp 6f
-5:     movl %ecx,%eax          /* exception on byte loop */
-       /* eax: left over bytes */
-6:     testl %r8d,%r8d         /* zero flag set? */
-       jz 7f
-       movl %eax,%ecx          /* initialize x86 loop counter */
-       push %rax
-       xorl %eax,%eax
-8:     rep
-       stosb                   /* zero the rest */
-11:    pop %rax
-7:     ret
-       CFI_ENDPROC
-END(copy_user_generic_c)
-
-       .section __ex_table,"a"
-       .quad 1b,3b
-       .quad 2b,5b
-       .quad 8b,11b
-       .quad 10b,3b
-       .previous
diff --git a/arch/x86_64/lib/copy_user_nocache.S b/arch/x86_64/lib/copy_user_nocache.S
deleted file mode 100644 (file)
index 4620efb..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Copyright 2002 Andi Kleen, SuSE Labs.
- * Subject to the GNU Public License v2.
- *
- * Functions to copy from and to user space.
- */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-#define FIX_ALIGNMENT 1
-
-#include <asm/current.h>
-#include <asm/asm-offsets.h>
-#include <asm/thread_info.h>
-#include <asm/cpufeature.h>
-
-/*
- * copy_user_nocache - Uncached memory copy with exception handling
- * This will force destination/source out of cache for more performance.
- *
- * Input:
- * rdi destination
- * rsi source
- * rdx count
- * rcx zero flag       when 1 zero on exception
- *
- * Output:
- * eax uncopied bytes or 0 if successful.
- */
-ENTRY(__copy_user_nocache)
-       CFI_STARTPROC
-       pushq %rbx
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rbx, 0
-       pushq %rcx              /* save zero flag */
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rcx, 0
-
-       xorl %eax,%eax          /* zero for the exception handler */
-
-#ifdef FIX_ALIGNMENT
-       /* check for bad alignment of destination */
-       movl %edi,%ecx
-       andl $7,%ecx
-       jnz  .Lbad_alignment
-.Lafter_bad_alignment:
-#endif
-
-       movq %rdx,%rcx
-
-       movl $64,%ebx
-       shrq $6,%rdx
-       decq %rdx
-       js   .Lhandle_tail
-
-       .p2align 4
-.Lloop:
-.Ls1:  movq (%rsi),%r11
-.Ls2:  movq 1*8(%rsi),%r8
-.Ls3:  movq 2*8(%rsi),%r9
-.Ls4:  movq 3*8(%rsi),%r10
-.Ld1:  movnti %r11,(%rdi)
-.Ld2:  movnti %r8,1*8(%rdi)
-.Ld3:  movnti %r9,2*8(%rdi)
-.Ld4:  movnti %r10,3*8(%rdi)
-
-.Ls5:  movq 4*8(%rsi),%r11
-.Ls6:  movq 5*8(%rsi),%r8
-.Ls7:  movq 6*8(%rsi),%r9
-.Ls8:  movq 7*8(%rsi),%r10
-.Ld5:  movnti %r11,4*8(%rdi)
-.Ld6:  movnti %r8,5*8(%rdi)
-.Ld7:  movnti %r9,6*8(%rdi)
-.Ld8:  movnti %r10,7*8(%rdi)
-
-       dec  %rdx
-
-       leaq 64(%rsi),%rsi
-       leaq 64(%rdi),%rdi
-
-       jns  .Lloop
-
-       .p2align 4
-.Lhandle_tail:
-       movl %ecx,%edx
-       andl $63,%ecx
-       shrl $3,%ecx
-       jz   .Lhandle_7
-       movl $8,%ebx
-       .p2align 4
-.Lloop_8:
-.Ls9:  movq (%rsi),%r8
-.Ld9:  movnti %r8,(%rdi)
-       decl %ecx
-       leaq 8(%rdi),%rdi
-       leaq 8(%rsi),%rsi
-       jnz .Lloop_8
-
-.Lhandle_7:
-       movl %edx,%ecx
-       andl $7,%ecx
-       jz   .Lende
-       .p2align 4
-.Lloop_1:
-.Ls10: movb (%rsi),%bl
-.Ld10: movb %bl,(%rdi)
-       incq %rdi
-       incq %rsi
-       decl %ecx
-       jnz .Lloop_1
-
-       CFI_REMEMBER_STATE
-.Lende:
-       popq %rcx
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_RESTORE %rcx
-       popq %rbx
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_RESTORE rbx
-       ret
-       CFI_RESTORE_STATE
-
-#ifdef FIX_ALIGNMENT
-       /* align destination */
-       .p2align 4
-.Lbad_alignment:
-       movl $8,%r9d
-       subl %ecx,%r9d
-       movl %r9d,%ecx
-       cmpq %r9,%rdx
-       jz   .Lhandle_7
-       js   .Lhandle_7
-.Lalign_1:
-.Ls11: movb (%rsi),%bl
-.Ld11: movb %bl,(%rdi)
-       incq %rsi
-       incq %rdi
-       decl %ecx
-       jnz .Lalign_1
-       subq %r9,%rdx
-       jmp .Lafter_bad_alignment
-#endif
-
-       /* table sorted by exception address */
-       .section __ex_table,"a"
-       .align 8
-       .quad .Ls1,.Ls1e
-       .quad .Ls2,.Ls2e
-       .quad .Ls3,.Ls3e
-       .quad .Ls4,.Ls4e
-       .quad .Ld1,.Ls1e
-       .quad .Ld2,.Ls2e
-       .quad .Ld3,.Ls3e
-       .quad .Ld4,.Ls4e
-       .quad .Ls5,.Ls5e
-       .quad .Ls6,.Ls6e
-       .quad .Ls7,.Ls7e
-       .quad .Ls8,.Ls8e
-       .quad .Ld5,.Ls5e
-       .quad .Ld6,.Ls6e
-       .quad .Ld7,.Ls7e
-       .quad .Ld8,.Ls8e
-       .quad .Ls9,.Le_quad
-       .quad .Ld9,.Le_quad
-       .quad .Ls10,.Le_byte
-       .quad .Ld10,.Le_byte
-#ifdef FIX_ALIGNMENT
-       .quad .Ls11,.Lzero_rest
-       .quad .Ld11,.Lzero_rest
-#endif
-       .quad .Le5,.Le_zero
-       .previous
-
-       /* compute 64-offset for main loop. 8 bytes accuracy with error on the
-          pessimistic side. this is gross. it would be better to fix the
-          interface. */
-       /* eax: zero, ebx: 64 */
-.Ls1e:         addl $8,%eax
-.Ls2e:         addl $8,%eax
-.Ls3e:         addl $8,%eax
-.Ls4e:         addl $8,%eax
-.Ls5e:         addl $8,%eax
-.Ls6e:         addl $8,%eax
-.Ls7e:         addl $8,%eax
-.Ls8e:         addl $8,%eax
-       addq %rbx,%rdi  /* +64 */
-       subq %rax,%rdi  /* correct destination with computed offset */
-
-       shlq $6,%rdx    /* loop counter * 64 (stride length) */
-       addq %rax,%rdx  /* add offset to loopcnt */
-       andl $63,%ecx   /* remaining bytes */
-       addq %rcx,%rdx  /* add them */
-       jmp .Lzero_rest
-
-       /* exception on quad word loop in tail handling */
-       /* ecx: loopcnt/8, %edx: length, rdi: correct */
-.Le_quad:
-       shll $3,%ecx
-       andl $7,%edx
-       addl %ecx,%edx
-       /* edx: bytes to zero, rdi: dest, eax:zero */
-.Lzero_rest:
-       cmpl $0,(%rsp)  /* zero flag set? */
-       jz   .Le_zero
-       movq %rdx,%rcx
-.Le_byte:
-       xorl %eax,%eax
-.Le5:  rep
-       stosb
-       /* when there is another exception while zeroing the rest just return */
-.Le_zero:
-       movq %rdx,%rax
-       jmp .Lende
-       CFI_ENDPROC
-ENDPROC(__copy_user_nocache)
-
-
diff --git a/arch/x86_64/lib/csum-copy.S b/arch/x86_64/lib/csum-copy.S
deleted file mode 100644 (file)
index f0dba36..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2002,2003 Andi Kleen, SuSE Labs.
- *     
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details. No warranty for anything given at all.
- */
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/errno.h>
-
-/*
- * Checksum copy with exception handling.
- * On exceptions src_err_ptr or dst_err_ptr is set to -EFAULT and the 
- * destination is zeroed.
- * 
- * Input
- * rdi  source
- * rsi  destination
- * edx  len (32bit)
- * ecx  sum (32bit) 
- * r8   src_err_ptr (int)
- * r9   dst_err_ptr (int)
- *
- * Output
- * eax  64bit sum. undefined in case of exception.
- * 
- * Wrappers need to take care of valid exception sum and zeroing.               
- * They also should align source or destination to 8 bytes.
- */
-
-       .macro source
-10:
-       .section __ex_table,"a"
-       .align 8
-       .quad 10b,.Lbad_source
-       .previous
-       .endm
-               
-       .macro dest
-20:
-       .section __ex_table,"a"
-       .align 8
-       .quad 20b,.Lbad_dest
-       .previous
-       .endm
-                       
-       .macro ignore L=.Lignore
-30:
-       .section __ex_table,"a"
-       .align 8
-       .quad 30b,\L
-       .previous
-       .endm
-       
-                               
-ENTRY(csum_partial_copy_generic)
-       CFI_STARTPROC
-       cmpl     $3*64,%edx
-       jle      .Lignore
-
-.Lignore:              
-       subq  $7*8,%rsp
-       CFI_ADJUST_CFA_OFFSET 7*8
-       movq  %rbx,2*8(%rsp)
-       CFI_REL_OFFSET rbx, 2*8
-       movq  %r12,3*8(%rsp)
-       CFI_REL_OFFSET r12, 3*8
-       movq  %r14,4*8(%rsp)
-       CFI_REL_OFFSET r14, 4*8
-       movq  %r13,5*8(%rsp)
-       CFI_REL_OFFSET r13, 5*8
-       movq  %rbp,6*8(%rsp)
-       CFI_REL_OFFSET rbp, 6*8
-
-       movq  %r8,(%rsp)
-       movq  %r9,1*8(%rsp)
-       
-       movl  %ecx,%eax
-       movl  %edx,%ecx
-
-       xorl  %r9d,%r9d
-       movq  %rcx,%r12
-
-       shrq  $6,%r12
-       jz    .Lhandle_tail       /* < 64 */
-
-       clc
-       
-       /* main loop. clear in 64 byte blocks */
-       /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
-       /* r11: temp3, rdx: temp4, r12 loopcnt */
-       /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
-       .p2align 4
-.Lloop:
-       source
-       movq  (%rdi),%rbx
-       source
-       movq  8(%rdi),%r8
-       source
-       movq  16(%rdi),%r11
-       source
-       movq  24(%rdi),%rdx
-
-       source
-       movq  32(%rdi),%r10
-       source
-       movq  40(%rdi),%rbp
-       source
-       movq  48(%rdi),%r14
-       source
-       movq  56(%rdi),%r13
-               
-       ignore 2f
-       prefetcht0 5*64(%rdi)
-2:                                                     
-       adcq  %rbx,%rax
-       adcq  %r8,%rax
-       adcq  %r11,%rax
-       adcq  %rdx,%rax
-       adcq  %r10,%rax
-       adcq  %rbp,%rax
-       adcq  %r14,%rax
-       adcq  %r13,%rax
-
-       decl %r12d
-       
-       dest
-       movq %rbx,(%rsi)
-       dest
-       movq %r8,8(%rsi)
-       dest
-       movq %r11,16(%rsi)
-       dest
-       movq %rdx,24(%rsi)
-
-       dest
-       movq %r10,32(%rsi)
-       dest
-       movq %rbp,40(%rsi)
-       dest
-       movq %r14,48(%rsi)
-       dest
-       movq %r13,56(%rsi)
-       
-3:
-       
-       leaq 64(%rdi),%rdi
-       leaq 64(%rsi),%rsi
-
-       jnz   .Lloop
-
-       adcq  %r9,%rax
-
-       /* do last upto 56 bytes */
-.Lhandle_tail:
-       /* ecx: count */
-       movl %ecx,%r10d
-       andl $63,%ecx
-       shrl $3,%ecx
-       jz       .Lfold
-       clc
-       .p2align 4
-.Lloop_8:      
-       source
-       movq (%rdi),%rbx
-       adcq %rbx,%rax
-       decl %ecx
-       dest
-       movq %rbx,(%rsi)
-       leaq 8(%rsi),%rsi /* preserve carry */
-       leaq 8(%rdi),%rdi
-       jnz     .Lloop_8
-       adcq %r9,%rax   /* add in carry */
-
-.Lfold:
-       /* reduce checksum to 32bits */
-       movl %eax,%ebx
-       shrq $32,%rax
-       addl %ebx,%eax
-       adcl %r9d,%eax
-
-       /* do last upto 6 bytes */      
-.Lhandle_7:
-       movl %r10d,%ecx
-       andl $7,%ecx
-       shrl $1,%ecx
-       jz   .Lhandle_1
-       movl $2,%edx
-       xorl %ebx,%ebx
-       clc  
-       .p2align 4
-.Lloop_1:      
-       source
-       movw (%rdi),%bx
-       adcl %ebx,%eax
-       decl %ecx
-       dest
-       movw %bx,(%rsi)
-       leaq 2(%rdi),%rdi
-       leaq 2(%rsi),%rsi
-       jnz .Lloop_1
-       adcl %r9d,%eax  /* add in carry */
-       
-       /* handle last odd byte */
-.Lhandle_1:
-       testl $1,%r10d
-       jz    .Lende
-       xorl  %ebx,%ebx
-       source
-       movb (%rdi),%bl
-       dest
-       movb %bl,(%rsi)
-       addl %ebx,%eax
-       adcl %r9d,%eax          /* carry */
-                       
-       CFI_REMEMBER_STATE
-.Lende:
-       movq 2*8(%rsp),%rbx
-       CFI_RESTORE rbx
-       movq 3*8(%rsp),%r12
-       CFI_RESTORE r12
-       movq 4*8(%rsp),%r14
-       CFI_RESTORE r14
-       movq 5*8(%rsp),%r13
-       CFI_RESTORE r13
-       movq 6*8(%rsp),%rbp
-       CFI_RESTORE rbp
-       addq $7*8,%rsp
-       CFI_ADJUST_CFA_OFFSET -7*8
-       ret
-       CFI_RESTORE_STATE
-
-       /* Exception handlers. Very simple, zeroing is done in the wrappers */
-.Lbad_source:
-       movq (%rsp),%rax
-       testq %rax,%rax
-       jz   .Lende
-       movl $-EFAULT,(%rax)
-       jmp  .Lende
-       
-.Lbad_dest:
-       movq 8(%rsp),%rax
-       testq %rax,%rax
-       jz   .Lende     
-       movl $-EFAULT,(%rax)
-       jmp .Lende
-       CFI_ENDPROC
-ENDPROC(csum_partial_copy_generic)
diff --git a/arch/x86_64/lib/csum-partial.c b/arch/x86_64/lib/csum-partial.c
deleted file mode 100644 (file)
index bc503f5..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * arch/x86_64/lib/csum-partial.c
- *
- * This file contains network checksum routines that are better done
- * in an architecture-specific manner due to speed.
- */
-#include <linux/compiler.h>
-#include <linux/module.h>
-#include <asm/checksum.h>
-
-static inline unsigned short from32to16(unsigned a) 
-{
-       unsigned short b = a >> 16; 
-       asm("addw %w2,%w0\n\t"
-           "adcw $0,%w0\n" 
-           : "=r" (b)
-           : "0" (b), "r" (a));
-       return b;
-}
-
-/*
- * Do a 64-bit checksum on an arbitrary memory area.
- * Returns a 32bit checksum.
- *
- * This isn't as time critical as it used to be because many NICs
- * do hardware checksumming these days.
- * 
- * Things tried and found to not make it faster:
- * Manual Prefetching
- * Unrolling to an 128 bytes inner loop.
- * Using interleaving with more registers to break the carry chains.
- */
-static unsigned do_csum(const unsigned char *buff, unsigned len)
-{
-       unsigned odd, count;
-       unsigned long result = 0;
-
-       if (unlikely(len == 0))
-               return result; 
-       odd = 1 & (unsigned long) buff;
-       if (unlikely(odd)) {
-               result = *buff << 8;
-               len--;
-               buff++;
-       }
-       count = len >> 1;               /* nr of 16-bit words.. */
-       if (count) {
-               if (2 & (unsigned long) buff) {
-                       result += *(unsigned short *)buff;
-                       count--;
-                       len -= 2;
-                       buff += 2;
-               }
-               count >>= 1;            /* nr of 32-bit words.. */
-               if (count) {
-                       unsigned long zero;
-                       unsigned count64;
-                       if (4 & (unsigned long) buff) {
-                               result += *(unsigned int *) buff;
-                               count--;
-                               len -= 4;
-                               buff += 4;
-                       }
-                       count >>= 1;    /* nr of 64-bit words.. */
-
-                       /* main loop using 64byte blocks */
-                       zero = 0;
-                       count64 = count >> 3;
-                       while (count64) { 
-                               asm("addq 0*8(%[src]),%[res]\n\t"
-                                   "adcq 1*8(%[src]),%[res]\n\t"
-                                   "adcq 2*8(%[src]),%[res]\n\t"
-                                   "adcq 3*8(%[src]),%[res]\n\t"
-                                   "adcq 4*8(%[src]),%[res]\n\t"
-                                   "adcq 5*8(%[src]),%[res]\n\t"
-                                   "adcq 6*8(%[src]),%[res]\n\t"
-                                   "adcq 7*8(%[src]),%[res]\n\t"
-                                   "adcq %[zero],%[res]"
-                                   : [res] "=r" (result)
-                                   : [src] "r" (buff), [zero] "r" (zero),
-                                   "[res]" (result));
-                               buff += 64;
-                               count64--;
-                       }
-
-                       /* last upto 7 8byte blocks */
-                       count %= 8; 
-                       while (count) { 
-                               asm("addq %1,%0\n\t"
-                                   "adcq %2,%0\n" 
-                                           : "=r" (result)
-                                   : "m" (*(unsigned long *)buff), 
-                                   "r" (zero),  "0" (result));
-                               --count; 
-                                       buff += 8;
-                       }
-                       result = add32_with_carry(result>>32,
-                                                 result&0xffffffff); 
-
-                       if (len & 4) {
-                               result += *(unsigned int *) buff;
-                               buff += 4;
-                       }
-               }
-               if (len & 2) {
-                       result += *(unsigned short *) buff;
-                       buff += 2;
-               }
-       }
-       if (len & 1)
-               result += *buff;
-       result = add32_with_carry(result>>32, result & 0xffffffff); 
-       if (unlikely(odd)) { 
-               result = from32to16(result);
-               result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
-       }
-       return result;
-}
-
-/*
- * computes the checksum of a memory block at buff, length len,
- * and adds in "sum" (32-bit)
- *
- * returns a 32-bit number suitable for feeding into itself
- * or csum_tcpudp_magic
- *
- * this function must be called with even lengths, except
- * for the last fragment, which may be odd
- *
- * it's best to have buff aligned on a 64-bit boundary
- */
-__wsum csum_partial(const void *buff, int len, __wsum sum)
-{
-       return (__force __wsum)add32_with_carry(do_csum(buff, len),
-                                               (__force u32)sum);
-}
-
-EXPORT_SYMBOL(csum_partial);
-
-/*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-__sum16 ip_compute_csum(const void *buff, int len)
-{
-       return csum_fold(csum_partial(buff,len,0));
-}
-EXPORT_SYMBOL(ip_compute_csum);
-
diff --git a/arch/x86_64/lib/csum-wrappers.c b/arch/x86_64/lib/csum-wrappers.c
deleted file mode 100644 (file)
index fd42a4a..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright 2002,2003 Andi Kleen, SuSE Labs.
- * Subject to the GNU Public License v.2
- * 
- * Wrappers of assembly checksum functions for x86-64.
- */
-
-#include <asm/checksum.h>
-#include <linux/module.h>
-
-/** 
- * csum_partial_copy_from_user - Copy and checksum from user space. 
- * @src: source address (user space) 
- * @dst: destination address
- * @len: number of bytes to be copied.
- * @isum: initial sum that is added into the result (32bit unfolded)
- * @errp: set to -EFAULT for an bad source address.
- * 
- * Returns an 32bit unfolded checksum of the buffer.
- * src and dst are best aligned to 64bits. 
- */ 
-__wsum
-csum_partial_copy_from_user(const void __user *src, void *dst,
-                           int len, __wsum isum, int *errp)
-{ 
-       might_sleep();
-       *errp = 0;
-       if (likely(access_ok(VERIFY_READ,src, len))) { 
-               /* Why 6, not 7? To handle odd addresses aligned we
-                  would need to do considerable complications to fix the
-                  checksum which is defined as an 16bit accumulator. The
-                  fix alignment code is primarily for performance
-                  compatibility with 32bit and that will handle odd
-                  addresses slowly too. */
-               if (unlikely((unsigned long)src & 6)) {                 
-                       while (((unsigned long)src & 6) && len >= 2) { 
-                               __u16 val16;                    
-                               *errp = __get_user(val16, (const __u16 __user *)src);
-                               if (*errp)
-                                       return isum;
-                               *(__u16 *)dst = val16;
-                               isum = (__force __wsum)add32_with_carry(
-                                               (__force unsigned)isum, val16);
-                               src += 2; 
-                               dst += 2; 
-                               len -= 2;
-                       }
-               }
-               isum = csum_partial_copy_generic((__force const void *)src,
-                                       dst, len, isum, errp, NULL);
-               if (likely(*errp == 0)) 
-                       return isum;
-       } 
-       *errp = -EFAULT;
-       memset(dst,0,len); 
-       return isum;            
-} 
-
-EXPORT_SYMBOL(csum_partial_copy_from_user);
-
-/** 
- * csum_partial_copy_to_user - Copy and checksum to user space. 
- * @src: source address
- * @dst: destination address (user space)
- * @len: number of bytes to be copied.
- * @isum: initial sum that is added into the result (32bit unfolded)
- * @errp: set to -EFAULT for an bad destination address.
- * 
- * Returns an 32bit unfolded checksum of the buffer.
- * src and dst are best aligned to 64bits.
- */ 
-__wsum
-csum_partial_copy_to_user(const void *src, void __user *dst,
-                         int len, __wsum isum, int *errp)
-{ 
-       might_sleep();
-       if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) {
-               *errp = -EFAULT;
-               return 0; 
-       }
-
-       if (unlikely((unsigned long)dst & 6)) {
-               while (((unsigned long)dst & 6) && len >= 2) { 
-                       __u16 val16 = *(__u16 *)src;
-                       isum = (__force __wsum)add32_with_carry(
-                                       (__force unsigned)isum, val16);
-                       *errp = __put_user(val16, (__u16 __user *)dst);
-                       if (*errp)
-                               return isum;
-                       src += 2; 
-                       dst += 2; 
-                       len -= 2;
-               }
-       }
-
-       *errp = 0;
-       return csum_partial_copy_generic(src, (void __force *)dst,len,isum,NULL,errp); 
-} 
-
-EXPORT_SYMBOL(csum_partial_copy_to_user);
-
-/** 
- * csum_partial_copy_nocheck - Copy and checksum.
- * @src: source address
- * @dst: destination address
- * @len: number of bytes to be copied.
- * @isum: initial sum that is added into the result (32bit unfolded)
- * 
- * Returns an 32bit unfolded checksum of the buffer.
- */ 
-__wsum
-csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
-{ 
-       return csum_partial_copy_generic(src,dst,len,sum,NULL,NULL);
-} 
-EXPORT_SYMBOL(csum_partial_copy_nocheck);
-
-__sum16 csum_ipv6_magic(const struct in6_addr *saddr,
-                       const struct in6_addr *daddr,
-                       __u32 len, unsigned short proto, __wsum sum)
-{
-       __u64 rest, sum64;
-     
-       rest = (__force __u64)htonl(len) + (__force __u64)htons(proto) +
-               (__force __u64)sum;
-       asm("  addq (%[saddr]),%[sum]\n"
-           "  adcq 8(%[saddr]),%[sum]\n"
-           "  adcq (%[daddr]),%[sum]\n" 
-           "  adcq 8(%[daddr]),%[sum]\n"
-           "  adcq $0,%[sum]\n"
-           : [sum] "=r" (sum64) 
-           : "[sum]" (rest),[saddr] "r" (saddr), [daddr] "r" (daddr));
-       return csum_fold((__force __wsum)add32_with_carry(sum64 & 0xffffffff, sum64>>32));
-}
-
-EXPORT_SYMBOL(csum_ipv6_magic);
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
deleted file mode 100644 (file)
index 2dbebd3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- *     Precise Delay Loops for x86-64
- *
- *     Copyright (C) 1993 Linus Torvalds
- *     Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- *
- *     The __delay function must _NOT_ be inlined as its execution time
- *     depends wildly on alignment on many x86 processors. 
- */
-
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <asm/delay.h>
-#include <asm/msr.h>
-
-#ifdef CONFIG_SMP
-#include <asm/smp.h>
-#endif
-
-int read_current_timer(unsigned long *timer_value)
-{
-       rdtscll(*timer_value);
-       return 0;
-}
-
-void __delay(unsigned long loops)
-{
-       unsigned bclock, now;
-       
-       rdtscl(bclock);
-       do
-       {
-               rep_nop(); 
-               rdtscl(now);
-       }
-       while((now-bclock) < loops);
-}
-EXPORT_SYMBOL(__delay);
-
-inline void __const_udelay(unsigned long xloops)
-{
-       __delay(((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) + 1);
-}
-EXPORT_SYMBOL(__const_udelay);
-
-void __udelay(unsigned long usecs)
-{
-       __const_udelay(usecs * 0x000010c7);  /* 2**32 / 1000000 (rounded up) */
-}
-EXPORT_SYMBOL(__udelay);
-
-void __ndelay(unsigned long nsecs)
-{
-       __const_udelay(nsecs * 0x00005);  /* 2**32 / 1000000000 (rounded up) */
-}
-EXPORT_SYMBOL(__ndelay);
diff --git a/arch/x86_64/lib/getuser.S b/arch/x86_64/lib/getuser.S
deleted file mode 100644 (file)
index 5448876..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * __get_user functions.
- *
- * (C) Copyright 1998 Linus Torvalds
- * (C) Copyright 2005 Andi Kleen
- *
- * These functions have a non-standard call interface
- * to make them more efficient, especially as they
- * return an error value in addition to the "real"
- * return value.
- */
-
-/*
- * __get_user_X
- *
- * Inputs:     %rcx contains the address.
- *             The register is modified, but all changes are undone
- *             before returning because the C code doesn't know about it.
- *
- * Outputs:    %rax is error code (0 or -EFAULT)
- *             %rdx contains zero-extended value
- * 
- * %r8 is destroyed.
- *
- * These functions should not modify any other registers,
- * as they get called from within inline assembly.
- */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/page.h>
-#include <asm/errno.h>
-#include <asm/asm-offsets.h>
-#include <asm/thread_info.h>
-
-       .text
-ENTRY(__get_user_1)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae bad_get_user
-1:     movzb (%rcx),%edx
-       xorl %eax,%eax
-       ret
-       CFI_ENDPROC
-ENDPROC(__get_user_1)
-
-ENTRY(__get_user_2)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $1,%rcx
-       jc 20f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae 20f
-       decq   %rcx
-2:     movzwl (%rcx),%edx
-       xorl %eax,%eax
-       ret
-20:    decq    %rcx
-       jmp     bad_get_user
-       CFI_ENDPROC
-ENDPROC(__get_user_2)
-
-ENTRY(__get_user_4)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $3,%rcx
-       jc 30f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae 30f
-       subq $3,%rcx
-3:     movl (%rcx),%edx
-       xorl %eax,%eax
-       ret
-30:    subq $3,%rcx
-       jmp bad_get_user
-       CFI_ENDPROC
-ENDPROC(__get_user_4)
-
-ENTRY(__get_user_8)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $7,%rcx
-       jc 40f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae     40f
-       subq    $7,%rcx
-4:     movq (%rcx),%rdx
-       xorl %eax,%eax
-       ret
-40:    subq $7,%rcx
-       jmp bad_get_user
-       CFI_ENDPROC
-ENDPROC(__get_user_8)
-
-bad_get_user:
-       CFI_STARTPROC
-       xorl %edx,%edx
-       movq $(-EFAULT),%rax
-       ret
-       CFI_ENDPROC
-END(bad_get_user)
-
-.section __ex_table,"a"
-       .quad 1b,bad_get_user
-       .quad 2b,bad_get_user
-       .quad 3b,bad_get_user
-       .quad 4b,bad_get_user
-.previous
diff --git a/arch/x86_64/lib/io.c b/arch/x86_64/lib/io.c
deleted file mode 100644 (file)
index 87b4a4e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <linux/string.h>
-#include <asm/io.h>
-#include <linux/module.h>
-
-void __memcpy_toio(unsigned long dst,const void*src,unsigned len)
-{
-       __inline_memcpy((void *) dst,src,len);
-}
-EXPORT_SYMBOL(__memcpy_toio);
-
-void __memcpy_fromio(void *dst,unsigned long src,unsigned len)
-{
-       __inline_memcpy(dst,(const void *) src,len);
-}
-EXPORT_SYMBOL(__memcpy_fromio);
-
-void memset_io(volatile void __iomem *a, int b, size_t c)
-{
-       /* XXX: memset can mangle the IO patterns quite a bit.
-          perhaps it would be better to use a dumb one */
-       memset((void *)a,b,c);
-}
-EXPORT_SYMBOL(memset_io);
diff --git a/arch/x86_64/lib/iomap_copy.S b/arch/x86_64/lib/iomap_copy.S
deleted file mode 100644 (file)
index 05a95e7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2006 PathScale, Inc.  All Rights Reserved.
- *
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-/*
- * override generic version in lib/iomap_copy.c
- */
-ENTRY(__iowrite32_copy)
-       CFI_STARTPROC
-       movl %edx,%ecx
-       rep movsd
-       ret
-       CFI_ENDPROC
-ENDPROC(__iowrite32_copy)
diff --git a/arch/x86_64/lib/memcpy.S b/arch/x86_64/lib/memcpy.S
deleted file mode 100644 (file)
index c22981f..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Copyright 2002 Andi Kleen */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/cpufeature.h>
-
-/*
- * memcpy - Copy a memory block.
- *
- * Input:      
- * rdi destination
- * rsi source
- * rdx count
- * 
- * Output:
- * rax original destination
- */    
-
-       ALIGN
-memcpy_c:
-       CFI_STARTPROC
-       movq %rdi,%rax
-       movl %edx,%ecx
-       shrl $3,%ecx
-       andl $7,%edx
-       rep movsq
-       movl %edx,%ecx
-       rep movsb
-       ret
-       CFI_ENDPROC
-ENDPROC(memcpy_c)
-
-ENTRY(__memcpy)
-ENTRY(memcpy)
-       CFI_STARTPROC
-       pushq %rbx
-       CFI_ADJUST_CFA_OFFSET 8
-       CFI_REL_OFFSET rbx, 0
-       movq %rdi,%rax
-
-       movl %edx,%ecx
-       shrl $6,%ecx
-       jz .Lhandle_tail
-
-       .p2align 4
-.Lloop_64:
-       decl %ecx
-
-       movq (%rsi),%r11
-       movq 8(%rsi),%r8
-
-       movq %r11,(%rdi)
-       movq %r8,1*8(%rdi)
-
-       movq 2*8(%rsi),%r9
-       movq 3*8(%rsi),%r10
-
-       movq %r9,2*8(%rdi)
-       movq %r10,3*8(%rdi)
-
-       movq 4*8(%rsi),%r11
-       movq 5*8(%rsi),%r8
-
-       movq %r11,4*8(%rdi)
-       movq %r8,5*8(%rdi)
-
-       movq 6*8(%rsi),%r9
-       movq 7*8(%rsi),%r10
-
-       movq %r9,6*8(%rdi)
-       movq %r10,7*8(%rdi)
-
-       leaq 64(%rsi),%rsi
-       leaq 64(%rdi),%rdi
-       jnz  .Lloop_64
-
-.Lhandle_tail:
-       movl %edx,%ecx
-       andl $63,%ecx
-       shrl $3,%ecx
-       jz   .Lhandle_7
-       .p2align 4
-.Lloop_8:
-       decl %ecx
-       movq (%rsi),%r8
-       movq %r8,(%rdi)
-       leaq 8(%rdi),%rdi
-       leaq 8(%rsi),%rsi
-       jnz  .Lloop_8
-
-.Lhandle_7:
-       movl %edx,%ecx
-       andl $7,%ecx
-       jz .Lende
-       .p2align 4
-.Lloop_1:
-       movb (%rsi),%r8b
-       movb %r8b,(%rdi)
-       incq %rdi
-       incq %rsi
-       decl %ecx
-       jnz .Lloop_1
-
-.Lende:
-       popq %rbx
-       CFI_ADJUST_CFA_OFFSET -8
-       CFI_RESTORE rbx
-       ret
-.Lfinal:
-       CFI_ENDPROC
-ENDPROC(memcpy)
-ENDPROC(__memcpy)
-
-       /* Some CPUs run faster using the string copy instructions.
-          It is also a lot simpler. Use this when possible */
-
-       .section .altinstr_replacement,"ax"
-1:     .byte 0xeb                              /* jmp <disp8> */
-       .byte (memcpy_c - memcpy) - (2f - 1b)   /* offset */
-2:
-       .previous
-       .section .altinstructions,"a"
-       .align 8
-       .quad memcpy
-       .quad 1b
-       .byte X86_FEATURE_REP_GOOD
-       /* Replace only beginning, memcpy is used to apply alternatives, so it
-        * is silly to overwrite itself with nops - reboot is only outcome... */
-       .byte 2b - 1b
-       .byte 2b - 1b
-       .previous
diff --git a/arch/x86_64/lib/memmove.c b/arch/x86_64/lib/memmove.c
deleted file mode 100644 (file)
index 751ebae..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Normally compiler builtins are used, but sometimes the compiler calls out
-   of line code. Based on asm-i386/string.h.
- */
-#define _STRING_C
-#include <linux/string.h>
-#include <linux/module.h>
-
-#undef memmove
-void *memmove(void * dest,const void *src,size_t count)
-{
-       if (dest < src) { 
-               return memcpy(dest,src,count);
-       } else {
-               char *p = (char *) dest + count;
-               char *s = (char *) src + count;
-               while (count--)
-                       *--p = *--s;
-       }
-       return dest;
-} 
-EXPORT_SYMBOL(memmove);
diff --git a/arch/x86_64/lib/memset.S b/arch/x86_64/lib/memset.S
deleted file mode 100644 (file)
index 2c59481..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Copyright 2002 Andi Kleen, SuSE Labs */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-
-/*
- * ISO C memset - set a memory block to a byte value.
- *     
- * rdi   destination
- * rsi   value (char) 
- * rdx   count (bytes) 
- * 
- * rax   original destination
- */    
-       ALIGN
-memset_c:
-       CFI_STARTPROC
-       movq %rdi,%r9
-       movl %edx,%r8d
-       andl $7,%r8d
-       movl %edx,%ecx
-       shrl $3,%ecx
-       /* expand byte value  */
-       movzbl %sil,%esi
-       movabs $0x0101010101010101,%rax
-       mulq %rsi               /* with rax, clobbers rdx */
-       rep stosq
-       movl %r8d,%ecx
-       rep stosb
-       movq %r9,%rax
-       ret
-       CFI_ENDPROC
-ENDPROC(memset_c)
-
-ENTRY(memset)
-ENTRY(__memset)
-       CFI_STARTPROC
-       movq %rdi,%r10
-       movq %rdx,%r11
-
-       /* expand byte value  */
-       movzbl %sil,%ecx
-       movabs $0x0101010101010101,%rax
-       mul    %rcx             /* with rax, clobbers rdx */
-
-       /* align dst */
-       movl  %edi,%r9d
-       andl  $7,%r9d
-       jnz  .Lbad_alignment
-       CFI_REMEMBER_STATE
-.Lafter_bad_alignment:
-
-       movl %r11d,%ecx
-       shrl $6,%ecx
-       jz       .Lhandle_tail
-
-       .p2align 4
-.Lloop_64:
-       decl   %ecx
-       movq  %rax,(%rdi)
-       movq  %rax,8(%rdi)
-       movq  %rax,16(%rdi)
-       movq  %rax,24(%rdi)
-       movq  %rax,32(%rdi)
-       movq  %rax,40(%rdi)
-       movq  %rax,48(%rdi)
-       movq  %rax,56(%rdi)
-       leaq  64(%rdi),%rdi
-       jnz    .Lloop_64
-
-       /* Handle tail in loops. The loops should be faster than hard
-          to predict jump tables. */
-       .p2align 4
-.Lhandle_tail:
-       movl    %r11d,%ecx
-       andl    $63&(~7),%ecx
-       jz              .Lhandle_7
-       shrl    $3,%ecx
-       .p2align 4
-.Lloop_8:
-       decl   %ecx
-       movq  %rax,(%rdi)
-       leaq  8(%rdi),%rdi
-       jnz    .Lloop_8
-
-.Lhandle_7:
-       movl    %r11d,%ecx
-       andl    $7,%ecx
-       jz      .Lende
-       .p2align 4
-.Lloop_1:
-       decl    %ecx
-       movb    %al,(%rdi)
-       leaq    1(%rdi),%rdi
-       jnz     .Lloop_1
-
-.Lende:
-       movq    %r10,%rax
-       ret
-
-       CFI_RESTORE_STATE
-.Lbad_alignment:
-       cmpq $7,%r11
-       jbe     .Lhandle_7
-       movq %rax,(%rdi)        /* unaligned store */
-       movq $8,%r8
-       subq %r9,%r8
-       addq %r8,%rdi
-       subq %r8,%r11
-       jmp .Lafter_bad_alignment
-.Lfinal:
-       CFI_ENDPROC
-ENDPROC(memset)
-ENDPROC(__memset)
-
-       /* Some CPUs run faster using the string instructions.
-          It is also a lot simpler. Use this when possible */
-
-#include <asm/cpufeature.h>
-
-       .section .altinstr_replacement,"ax"
-1:     .byte 0xeb                              /* jmp <disp8> */
-       .byte (memset_c - memset) - (2f - 1b)   /* offset */
-2:
-       .previous
-       .section .altinstructions,"a"
-       .align 8
-       .quad memset
-       .quad 1b
-       .byte X86_FEATURE_REP_GOOD
-       .byte .Lfinal - memset
-       .byte 2b - 1b
-       .previous
diff --git a/arch/x86_64/lib/msr-on-cpu.c b/arch/x86_64/lib/msr-on-cpu.c
deleted file mode 100644 (file)
index 47e0ec4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../i386/lib/msr-on-cpu.c"
diff --git a/arch/x86_64/lib/putuser.S b/arch/x86_64/lib/putuser.S
deleted file mode 100644 (file)
index 4989f5a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * __put_user functions.
- *
- * (C) Copyright 1998 Linus Torvalds
- * (C) Copyright 2005 Andi Kleen
- *
- * These functions have a non-standard call interface
- * to make them more efficient, especially as they
- * return an error value in addition to the "real"
- * return value.
- */
-
-/*
- * __put_user_X
- *
- * Inputs:     %rcx contains the address
- *             %rdx contains new value
- *
- * Outputs:    %rax is error code (0 or -EFAULT)
- *
- * %r8 is destroyed.
- *
- * These functions should not modify any other registers,
- * as they get called from within inline assembly.
- */
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/page.h>
-#include <asm/errno.h>
-#include <asm/asm-offsets.h>
-#include <asm/thread_info.h>
-
-       .text
-ENTRY(__put_user_1)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae bad_put_user
-1:     movb %dl,(%rcx)
-       xorl %eax,%eax
-       ret
-       CFI_ENDPROC
-ENDPROC(__put_user_1)
-
-ENTRY(__put_user_2)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $1,%rcx
-       jc 20f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae 20f
-       decq %rcx
-2:     movw %dx,(%rcx)
-       xorl %eax,%eax
-       ret
-20:    decq %rcx
-       jmp bad_put_user
-       CFI_ENDPROC
-ENDPROC(__put_user_2)
-
-ENTRY(__put_user_4)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $3,%rcx
-       jc 30f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae 30f
-       subq $3,%rcx
-3:     movl %edx,(%rcx)
-       xorl %eax,%eax
-       ret
-30:    subq $3,%rcx
-       jmp bad_put_user
-       CFI_ENDPROC
-ENDPROC(__put_user_4)
-
-ENTRY(__put_user_8)
-       CFI_STARTPROC
-       GET_THREAD_INFO(%r8)
-       addq $7,%rcx
-       jc 40f
-       cmpq threadinfo_addr_limit(%r8),%rcx
-       jae 40f
-       subq $7,%rcx
-4:     movq %rdx,(%rcx)
-       xorl %eax,%eax
-       ret
-40:    subq $7,%rcx
-       jmp bad_put_user
-       CFI_ENDPROC
-ENDPROC(__put_user_8)
-
-bad_put_user:
-       CFI_STARTPROC
-       movq $(-EFAULT),%rax
-       ret
-       CFI_ENDPROC
-END(bad_put_user)
-
-.section __ex_table,"a"
-       .quad 1b,bad_put_user
-       .quad 2b,bad_put_user
-       .quad 3b,bad_put_user
-       .quad 4b,bad_put_user
-.previous
diff --git a/arch/x86_64/lib/rwlock.S b/arch/x86_64/lib/rwlock.S
deleted file mode 100644 (file)
index 0cde1f8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Slow paths of read/write spinlocks. */
-
-#include <linux/linkage.h>
-#include <asm/rwlock.h>
-#include <asm/alternative-asm.i>
-#include <asm/dwarf2.h>
-
-/* rdi:        pointer to rwlock_t */
-ENTRY(__write_lock_failed)
-       CFI_STARTPROC
-       LOCK_PREFIX
-       addl $RW_LOCK_BIAS,(%rdi)
-1:     rep
-       nop
-       cmpl $RW_LOCK_BIAS,(%rdi)
-       jne 1b
-       LOCK_PREFIX
-       subl $RW_LOCK_BIAS,(%rdi)
-       jnz  __write_lock_failed
-       ret
-       CFI_ENDPROC
-END(__write_lock_failed)
-
-/* rdi:        pointer to rwlock_t */
-ENTRY(__read_lock_failed)
-       CFI_STARTPROC
-       LOCK_PREFIX
-       incl (%rdi)
-1:     rep
-       nop
-       cmpl $1,(%rdi)
-       js 1b
-       LOCK_PREFIX
-       decl (%rdi)
-       js __read_lock_failed
-       ret
-       CFI_ENDPROC
-END(__read_lock_failed)
diff --git a/arch/x86_64/lib/thunk.S b/arch/x86_64/lib/thunk.S
deleted file mode 100644 (file)
index 55e586d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Save registers before calling assembly functions. This avoids
- * disturbance of register allocation in some inline assembly constructs.
- * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
- * Subject to the GNU public license, v.2. No warranty of any kind.
- */
-
-       #include <linux/linkage.h>
-       #include <asm/dwarf2.h>
-       #include <asm/calling.h>                        
-       #include <asm/rwlock.h>
-               
-       /* rdi: arg1 ... normal C conventions. rax is saved/restored. */        
-       .macro thunk name,func
-       .globl \name
-\name: 
-       CFI_STARTPROC
-       SAVE_ARGS
-       call \func
-       jmp  restore
-       CFI_ENDPROC
-       .endm
-
-       /* rdi: arg1 ... normal C conventions. rax is passed from C. */         
-       .macro thunk_retrax name,func
-       .globl \name
-\name: 
-       CFI_STARTPROC
-       SAVE_ARGS
-       call \func
-       jmp  restore_norax
-       CFI_ENDPROC
-       .endm
-       
-
-       .section .sched.text
-#ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
-       thunk rwsem_down_read_failed_thunk,rwsem_down_read_failed
-       thunk rwsem_down_write_failed_thunk,rwsem_down_write_failed
-       thunk rwsem_wake_thunk,rwsem_wake
-       thunk rwsem_downgrade_thunk,rwsem_downgrade_wake
-#endif 
-       
-       thunk __down_failed,__down
-       thunk_retrax __down_failed_interruptible,__down_interruptible
-       thunk_retrax __down_failed_trylock,__down_trylock
-       thunk __up_wakeup,__up
-
-#ifdef CONFIG_TRACE_IRQFLAGS
-       thunk trace_hardirqs_on_thunk,trace_hardirqs_on
-       thunk trace_hardirqs_off_thunk,trace_hardirqs_off
-#endif
-       
-       /* SAVE_ARGS below is used only for the .cfi directives it contains. */
-       CFI_STARTPROC
-       SAVE_ARGS
-restore:
-       RESTORE_ARGS
-       ret     
-       CFI_ENDPROC
-       
-       CFI_STARTPROC
-       SAVE_ARGS
-restore_norax: 
-       RESTORE_ARGS 1
-       ret
-       CFI_ENDPROC
diff --git a/arch/x86_64/lib/usercopy.c b/arch/x86_64/lib/usercopy.c
deleted file mode 100644 (file)
index 893d43f..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* 
- * User address space access functions.
- *
- * Copyright 1997 Andi Kleen <ak@muc.de>
- * Copyright 1997 Linus Torvalds
- * Copyright 2002 Andi Kleen <ak@suse.de>
- */
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-/*
- * Copy a null terminated string from userspace.
- */
-
-#define __do_strncpy_from_user(dst,src,count,res)                         \
-do {                                                                      \
-       long __d0, __d1, __d2;                                             \
-       might_sleep();                                                     \
-       __asm__ __volatile__(                                              \
-               "       testq %1,%1\n"                                     \
-               "       jz 2f\n"                                           \
-               "0:     lodsb\n"                                           \
-               "       stosb\n"                                           \
-               "       testb %%al,%%al\n"                                 \
-               "       jz 1f\n"                                           \
-               "       decq %1\n"                                         \
-               "       jnz 0b\n"                                          \
-               "1:     subq %1,%0\n"                                      \
-               "2:\n"                                                     \
-               ".section .fixup,\"ax\"\n"                                 \
-               "3:     movq %5,%0\n"                                      \
-               "       jmp 2b\n"                                          \
-               ".previous\n"                                              \
-               ".section __ex_table,\"a\"\n"                              \
-               "       .align 8\n"                                        \
-               "       .quad 0b,3b\n"                                     \
-               ".previous"                                                \
-               : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
-                 "=&D" (__d2)                                             \
-               : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
-               : "memory");                                               \
-} while (0)
-
-long
-__strncpy_from_user(char *dst, const char __user *src, long count)
-{
-       long res;
-       __do_strncpy_from_user(dst, src, count, res);
-       return res;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-
-long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-       long res = -EFAULT;
-       if (access_ok(VERIFY_READ, src, 1))
-               return __strncpy_from_user(dst, src, count);
-       return res;
-}
-EXPORT_SYMBOL(strncpy_from_user);
-
-/*
- * Zero Userspace
- */
-
-unsigned long __clear_user(void __user *addr, unsigned long size)
-{
-       long __d0;
-       might_sleep();
-       /* no memory constraint because it doesn't change any memory gcc knows
-          about */
-       asm volatile(
-               "       testq  %[size8],%[size8]\n"
-               "       jz     4f\n"
-               "0:     movq %[zero],(%[dst])\n"
-               "       addq   %[eight],%[dst]\n"
-               "       decl %%ecx ; jnz   0b\n"
-               "4:     movq  %[size1],%%rcx\n"
-               "       testl %%ecx,%%ecx\n"
-               "       jz     2f\n"
-               "1:     movb   %b[zero],(%[dst])\n"
-               "       incq   %[dst]\n"
-               "       decl %%ecx ; jnz  1b\n"
-               "2:\n"
-               ".section .fixup,\"ax\"\n"
-               "3:     lea 0(%[size1],%[size8],8),%[size8]\n"
-               "       jmp 2b\n"
-               ".previous\n"
-               ".section __ex_table,\"a\"\n"
-               "       .align 8\n"
-               "       .quad 0b,3b\n"
-               "       .quad 1b,2b\n"
-               ".previous"
-               : [size8] "=c"(size), [dst] "=&D" (__d0)
-               : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
-                 [zero] "r" (0UL), [eight] "r" (8UL));
-       return size;
-}
-EXPORT_SYMBOL(__clear_user);
-
-unsigned long clear_user(void __user *to, unsigned long n)
-{
-       if (access_ok(VERIFY_WRITE, to, n))
-               return __clear_user(to, n);
-       return n;
-}
-EXPORT_SYMBOL(clear_user);
-
-/*
- * Return the size of a string (including the ending 0)
- *
- * Return 0 on exception, a value greater than N if too long
- */
-
-long __strnlen_user(const char __user *s, long n)
-{
-       long res = 0;
-       char c;
-
-       while (1) {
-               if (res>n)
-                       return n+1;
-               if (__get_user(c, s))
-                       return 0;
-               if (!c)
-                       return res+1;
-               res++;
-               s++;
-       }
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long strnlen_user(const char __user *s, long n)
-{
-       if (!access_ok(VERIFY_READ, s, n))
-               return 0;
-       return __strnlen_user(s, n);
-}
-EXPORT_SYMBOL(strnlen_user);
-
-long strlen_user(const char __user *s)
-{
-       long res = 0;
-       char c;
-
-       for (;;) {
-               if (get_user(c, s))
-                       return 0;
-               if (!c)
-                       return res+1;
-               res++;
-               s++;
-       }
-}
-EXPORT_SYMBOL(strlen_user);
-
-unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
-{
-       if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) { 
-               return copy_user_generic((__force void *)to, (__force void *)from, len);
-       } 
-       return len;             
-}
-EXPORT_SYMBOL(copy_in_user);
-
diff --git a/arch/x86_64/mm/Makefile b/arch/x86_64/mm/Makefile
deleted file mode 100644 (file)
index d25ac86..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile for the linux x86_64-specific parts of the memory manager.
-#
-
-obj-y   := init.o fault.o ioremap.o extable.o pageattr.o mmap.o
-obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
-obj-$(CONFIG_NUMA) += numa.o
-obj-$(CONFIG_K8_NUMA) += k8topology.o
-obj-$(CONFIG_ACPI_NUMA) += srat.o
-
-hugetlbpage-y = ../../i386/mm/hugetlbpage.o
diff --git a/arch/x86_64/mm/extable.c b/arch/x86_64/mm/extable.c
deleted file mode 100644 (file)
index 79ac6e7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * linux/arch/x86_64/mm/extable.c
- */
-
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
-              const struct exception_table_entry *last,
-              unsigned long value)
-{
-       /* Work around a B stepping K8 bug */
-       if ((value >> 32) == 0)
-               value |= 0xffffffffUL << 32; 
-
-        while (first <= last) {
-               const struct exception_table_entry *mid;
-               long diff;
-
-               mid = (last - first) / 2 + first;
-               diff = mid->insn - value;
-                if (diff == 0)
-                        return mid;
-                else if (diff < 0)
-                        first = mid+1;
-                else
-                        last = mid-1;
-        }
-        return NULL;
-}
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
deleted file mode 100644 (file)
index 54816ad..0000000
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- *  linux/arch/x86-64/mm/fault.c
- *
- *  Copyright (C) 1995  Linus Torvalds
- *  Copyright (C) 2001,2002 Andi Kleen, SuSE Labs.
- */
-
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/tty.h>
-#include <linux/vt_kern.h>             /* For unblank_screen() */
-#include <linux/compiler.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <linux/kprobes.h>
-#include <linux/uaccess.h>
-#include <linux/kdebug.h>
-
-#include <asm/system.h>
-#include <asm/pgalloc.h>
-#include <asm/smp.h>
-#include <asm/tlbflush.h>
-#include <asm/proto.h>
-#include <asm-generic/sections.h>
-
-/* Page fault error code bits */
-#define PF_PROT        (1<<0)          /* or no page found */
-#define PF_WRITE       (1<<1)
-#define PF_USER        (1<<2)
-#define PF_RSVD        (1<<3)
-#define PF_INSTR       (1<<4)
-
-static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
-
-/* Hook to register for page fault notifications */
-int register_page_fault_notifier(struct notifier_block *nb)
-{
-       vmalloc_sync_all();
-       return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
-}
-EXPORT_SYMBOL_GPL(register_page_fault_notifier);
-
-int unregister_page_fault_notifier(struct notifier_block *nb)
-{
-       return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
-}
-EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
-
-static inline int notify_page_fault(struct pt_regs *regs, long err)
-{
-       struct die_args args = {
-               .regs = regs,
-               .str = "page fault",
-               .err = err,
-               .trapnr = 14,
-               .signr = SIGSEGV
-       };
-       return atomic_notifier_call_chain(&notify_page_fault_chain,
-                                         DIE_PAGE_FAULT, &args);
-}
-
-/* Sometimes the CPU reports invalid exceptions on prefetch.
-   Check that here and ignore.
-   Opcode checker based on code by Richard Brunner */
-static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
-                               unsigned long error_code)
-{ 
-       unsigned char *instr;
-       int scan_more = 1;
-       int prefetch = 0; 
-       unsigned char *max_instr;
-
-       /* If it was a exec fault ignore */
-       if (error_code & PF_INSTR)
-               return 0;
-       
-       instr = (unsigned char __user *)convert_rip_to_linear(current, regs);
-       max_instr = instr + 15;
-
-       if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE)
-               return 0;
-
-       while (scan_more && instr < max_instr) { 
-               unsigned char opcode;
-               unsigned char instr_hi;
-               unsigned char instr_lo;
-
-               if (probe_kernel_address(instr, opcode))
-                       break; 
-
-               instr_hi = opcode & 0xf0; 
-               instr_lo = opcode & 0x0f; 
-               instr++;
-
-               switch (instr_hi) { 
-               case 0x20:
-               case 0x30:
-                       /* Values 0x26,0x2E,0x36,0x3E are valid x86
-                          prefixes.  In long mode, the CPU will signal
-                          invalid opcode if some of these prefixes are
-                          present so we will never get here anyway */
-                       scan_more = ((instr_lo & 7) == 0x6);
-                       break;
-                       
-               case 0x40:
-                       /* In AMD64 long mode, 0x40 to 0x4F are valid REX prefixes
-                          Need to figure out under what instruction mode the
-                          instruction was issued ... */
-                       /* Could check the LDT for lm, but for now it's good
-                          enough to assume that long mode only uses well known
-                          segments or kernel. */
-                       scan_more = (!user_mode(regs)) || (regs->cs == __USER_CS);
-                       break;
-                       
-               case 0x60:
-                       /* 0x64 thru 0x67 are valid prefixes in all modes. */
-                       scan_more = (instr_lo & 0xC) == 0x4;
-                       break;          
-               case 0xF0:
-                       /* 0xF0, 0xF2, and 0xF3 are valid prefixes in all modes. */
-                       scan_more = !instr_lo || (instr_lo>>1) == 1;
-                       break;                  
-               case 0x00:
-                       /* Prefetch instruction is 0x0F0D or 0x0F18 */
-                       scan_more = 0;
-                       if (probe_kernel_address(instr, opcode))
-                               break;
-                       prefetch = (instr_lo == 0xF) &&
-                               (opcode == 0x0D || opcode == 0x18);
-                       break;                  
-               default:
-                       scan_more = 0;
-                       break;
-               } 
-       }
-       return prefetch;
-}
-
-static int bad_address(void *p) 
-{ 
-       unsigned long dummy;
-       return probe_kernel_address((unsigned long *)p, dummy);
-} 
-
-void dump_pagetable(unsigned long address)
-{
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
-
-       pgd = (pgd_t *)read_cr3();
-
-       pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 
-       pgd += pgd_index(address);
-       if (bad_address(pgd)) goto bad;
-       printk("PGD %lx ", pgd_val(*pgd));
-       if (!pgd_present(*pgd)) goto ret; 
-
-       pud = pud_offset(pgd, address);
-       if (bad_address(pud)) goto bad;
-       printk("PUD %lx ", pud_val(*pud));
-       if (!pud_present(*pud)) goto ret;
-
-       pmd = pmd_offset(pud, address);
-       if (bad_address(pmd)) goto bad;
-       printk("PMD %lx ", pmd_val(*pmd));
-       if (!pmd_present(*pmd)) goto ret;        
-
-       pte = pte_offset_kernel(pmd, address);
-       if (bad_address(pte)) goto bad;
-       printk("PTE %lx", pte_val(*pte)); 
-ret:
-       printk("\n");
-       return;
-bad:
-       printk("BAD\n");
-}
-
-static const char errata93_warning[] = 
-KERN_ERR "******* Your BIOS seems to not contain a fix for K8 errata #93\n"
-KERN_ERR "******* Working around it, but it may cause SEGVs or burn power.\n"
-KERN_ERR "******* Please consider a BIOS update.\n"
-KERN_ERR "******* Disabling USB legacy in the BIOS may also help.\n";
-
-/* Workaround for K8 erratum #93 & buggy BIOS.
-   BIOS SMM functions are required to use a specific workaround
-   to avoid corruption of the 64bit RIP register on C stepping K8. 
-   A lot of BIOS that didn't get tested properly miss this. 
-   The OS sees this as a page fault with the upper 32bits of RIP cleared.
-   Try to work around it here.
-   Note we only handle faults in kernel here. */
-
-static int is_errata93(struct pt_regs *regs, unsigned long address) 
-{
-       static int warned;
-       if (address != regs->rip)
-               return 0;
-       if ((address >> 32) != 0) 
-               return 0;
-       address |= 0xffffffffUL << 32;
-       if ((address >= (u64)_stext && address <= (u64)_etext) || 
-           (address >= MODULES_VADDR && address <= MODULES_END)) { 
-               if (!warned) {
-                       printk(errata93_warning);               
-                       warned = 1;
-               }
-               regs->rip = address;
-               return 1;
-       }
-       return 0;
-} 
-
-static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
-                                unsigned long error_code)
-{
-       unsigned long flags = oops_begin();
-       struct task_struct *tsk;
-
-       printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
-              current->comm, address);
-       dump_pagetable(address);
-       tsk = current;
-       tsk->thread.cr2 = address;
-       tsk->thread.trap_no = 14;
-       tsk->thread.error_code = error_code;
-       __die("Bad pagetable", regs, error_code);
-       oops_end(flags);
-       do_exit(SIGKILL);
-}
-
-/*
- * Handle a fault on the vmalloc area
- *
- * This assumes no large pages in there.
- */
-static int vmalloc_fault(unsigned long address)
-{
-       pgd_t *pgd, *pgd_ref;
-       pud_t *pud, *pud_ref;
-       pmd_t *pmd, *pmd_ref;
-       pte_t *pte, *pte_ref;
-
-       /* Copy kernel mappings over when needed. This can also
-          happen within a race in page table update. In the later
-          case just flush. */
-
-       pgd = pgd_offset(current->mm ?: &init_mm, address);
-       pgd_ref = pgd_offset_k(address);
-       if (pgd_none(*pgd_ref))
-               return -1;
-       if (pgd_none(*pgd))
-               set_pgd(pgd, *pgd_ref);
-       else
-               BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
-
-       /* Below here mismatches are bugs because these lower tables
-          are shared */
-
-       pud = pud_offset(pgd, address);
-       pud_ref = pud_offset(pgd_ref, address);
-       if (pud_none(*pud_ref))
-               return -1;
-       if (pud_none(*pud) || pud_page_vaddr(*pud) != pud_page_vaddr(*pud_ref))
-               BUG();
-       pmd = pmd_offset(pud, address);
-       pmd_ref = pmd_offset(pud_ref, address);
-       if (pmd_none(*pmd_ref))
-               return -1;
-       if (pmd_none(*pmd) || pmd_page(*pmd) != pmd_page(*pmd_ref))
-               BUG();
-       pte_ref = pte_offset_kernel(pmd_ref, address);
-       if (!pte_present(*pte_ref))
-               return -1;
-       pte = pte_offset_kernel(pmd, address);
-       /* Don't use pte_page here, because the mappings can point
-          outside mem_map, and the NUMA hash lookup cannot handle
-          that. */
-       if (!pte_present(*pte) || pte_pfn(*pte) != pte_pfn(*pte_ref))
-               BUG();
-       return 0;
-}
-
-static int page_fault_trace;
-int show_unhandled_signals = 1;
-
-/*
- * This routine handles page faults.  It determines the address,
- * and the problem, and then passes it off to one of the appropriate
- * routines.
- */
-asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
-                                       unsigned long error_code)
-{
-       struct task_struct *tsk;
-       struct mm_struct *mm;
-       struct vm_area_struct * vma;
-       unsigned long address;
-       const struct exception_table_entry *fixup;
-       int write, fault;
-       unsigned long flags;
-       siginfo_t info;
-
-       tsk = current;
-       mm = tsk->mm;
-       prefetchw(&mm->mmap_sem);
-
-       /* get the address */
-       address = read_cr2();
-
-       info.si_code = SEGV_MAPERR;
-
-
-       /*
-        * We fault-in kernel-space virtual memory on-demand. The
-        * 'reference' page table is init_mm.pgd.
-        *
-        * NOTE! We MUST NOT take any locks for this case. We may
-        * be in an interrupt or a critical region, and should
-        * only copy the information from the master page table,
-        * nothing more.
-        *
-        * This verifies that the fault happens in kernel space
-        * (error_code & 4) == 0, and that the fault was not a
-        * protection error (error_code & 9) == 0.
-        */
-       if (unlikely(address >= TASK_SIZE64)) {
-               /*
-                * Don't check for the module range here: its PML4
-                * is always initialized because it's shared with the main
-                * kernel text. Only vmalloc may need PML4 syncups.
-                */
-               if (!(error_code & (PF_RSVD|PF_USER|PF_PROT)) &&
-                     ((address >= VMALLOC_START && address < VMALLOC_END))) {
-                       if (vmalloc_fault(address) >= 0)
-                               return;
-               }
-               if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
-                       return;
-               /*
-                * Don't take the mm semaphore here. If we fixup a prefetch
-                * fault we could otherwise deadlock.
-                */
-               goto bad_area_nosemaphore;
-       }
-
-       if (notify_page_fault(regs, error_code) == NOTIFY_STOP)
-               return;
-
-       if (likely(regs->eflags & X86_EFLAGS_IF))
-               local_irq_enable();
-
-       if (unlikely(page_fault_trace))
-               printk("pagefault rip:%lx rsp:%lx cs:%lu ss:%lu address %lx error %lx\n",
-                      regs->rip,regs->rsp,regs->cs,regs->ss,address,error_code); 
-
-       if (unlikely(error_code & PF_RSVD))
-               pgtable_bad(address, regs, error_code);
-
-       /*
-        * If we're in an interrupt or have no user
-        * context, we must not take the fault..
-        */
-       if (unlikely(in_atomic() || !mm))
-               goto bad_area_nosemaphore;
-
-       /*
-        * User-mode registers count as a user access even for any
-        * potential system fault or CPU buglet.
-        */
-       if (user_mode_vm(regs))
-               error_code |= PF_USER;
-
- again:
-       /* When running in the kernel we expect faults to occur only to
-        * addresses in user space.  All other faults represent errors in the
-        * kernel and should generate an OOPS.  Unfortunatly, in the case of an
-        * erroneous fault occurring in a code path which already holds mmap_sem
-        * we will deadlock attempting to validate the fault against the
-        * address space.  Luckily the kernel only validly references user
-        * space from well defined areas of code, which are listed in the
-        * exceptions table.
-        *
-        * As the vast majority of faults will be valid we will only perform
-        * the source reference check when there is a possibilty of a deadlock.
-        * Attempt to lock the address space, if we cannot we then validate the
-        * source.  If this is invalid we can skip the address space check,
-        * thus avoiding the deadlock.
-        */
-       if (!down_read_trylock(&mm->mmap_sem)) {
-               if ((error_code & PF_USER) == 0 &&
-                   !search_exception_tables(regs->rip))
-                       goto bad_area_nosemaphore;
-               down_read(&mm->mmap_sem);
-       }
-
-       vma = find_vma(mm, address);
-       if (!vma)
-               goto bad_area;
-       if (likely(vma->vm_start <= address))
-               goto good_area;
-       if (!(vma->vm_flags & VM_GROWSDOWN))
-               goto bad_area;
-       if (error_code & 4) {
-               /* Allow userspace just enough access below the stack pointer
-                * to let the 'enter' instruction work.
-                */
-               if (address + 65536 + 32 * sizeof(unsigned long) < regs->rsp)
-                       goto bad_area;
-       }
-       if (expand_stack(vma, address))
-               goto bad_area;
-/*
- * Ok, we have a good vm_area for this memory access, so
- * we can handle it..
- */
-good_area:
-       info.si_code = SEGV_ACCERR;
-       write = 0;
-       switch (error_code & (PF_PROT|PF_WRITE)) {
-               default:        /* 3: write, present */
-                       /* fall through */
-               case PF_WRITE:          /* write, not present */
-                       if (!(vma->vm_flags & VM_WRITE))
-                               goto bad_area;
-                       write++;
-                       break;
-               case PF_PROT:           /* read, present */
-                       goto bad_area;
-               case 0:                 /* read, not present */
-                       if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
-                               goto bad_area;
-       }
-
-       /*
-        * If for any reason at all we couldn't handle the fault,
-        * make sure we exit gracefully rather than endlessly redo
-        * the fault.
-        */
-       fault = handle_mm_fault(mm, vma, address, write);
-       if (unlikely(fault & VM_FAULT_ERROR)) {
-               if (fault & VM_FAULT_OOM)
-                       goto out_of_memory;
-               else if (fault & VM_FAULT_SIGBUS)
-                       goto do_sigbus;
-               BUG();
-       }
-       if (fault & VM_FAULT_MAJOR)
-               tsk->maj_flt++;
-       else
-               tsk->min_flt++;
-       up_read(&mm->mmap_sem);
-       return;
-
-/*
- * Something tried to access memory that isn't in our memory map..
- * Fix it, but check if it's kernel or user first..
- */
-bad_area:
-       up_read(&mm->mmap_sem);
-
-bad_area_nosemaphore:
-       /* User mode accesses just cause a SIGSEGV */
-       if (error_code & PF_USER) {
-
-               /*
-                * It's possible to have interrupts off here.
-                */
-               local_irq_enable();
-
-               if (is_prefetch(regs, address, error_code))
-                       return;
-
-               /* Work around K8 erratum #100 K8 in compat mode
-                  occasionally jumps to illegal addresses >4GB.  We
-                  catch this here in the page fault handler because
-                  these addresses are not reachable. Just detect this
-                  case and return.  Any code segment in LDT is
-                  compatibility mode. */
-               if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) &&
-                   (address >> 32))
-                       return;
-
-               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
-                   printk_ratelimit()) {
-                       printk(
-                      "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
-                                       tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
-                                       tsk->comm, tsk->pid, address, regs->rip,
-                                       regs->rsp, error_code);
-               }
-       
-               tsk->thread.cr2 = address;
-               /* Kernel addresses are always protection faults */
-               tsk->thread.error_code = error_code | (address >= TASK_SIZE);
-               tsk->thread.trap_no = 14;
-               info.si_signo = SIGSEGV;
-               info.si_errno = 0;
-               /* info.si_code has been set above */
-               info.si_addr = (void __user *)address;
-               force_sig_info(SIGSEGV, &info, tsk);
-               return;
-       }
-
-no_context:
-       
-       /* Are we prepared to handle this kernel fault?  */
-       fixup = search_exception_tables(regs->rip);
-       if (fixup) {
-               regs->rip = fixup->fixup;
-               return;
-       }
-
-       /* 
-        * Hall of shame of CPU/BIOS bugs.
-        */
-
-       if (is_prefetch(regs, address, error_code))
-               return;
-
-       if (is_errata93(regs, address))
-               return; 
-
-/*
- * Oops. The kernel tried to access some bad page. We'll have to
- * terminate things with extreme prejudice.
- */
-
-       flags = oops_begin();
-
-       if (address < PAGE_SIZE)
-               printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
-       else
-               printk(KERN_ALERT "Unable to handle kernel paging request");
-       printk(" at %016lx RIP: \n" KERN_ALERT,address);
-       printk_address(regs->rip);
-       dump_pagetable(address);
-       tsk->thread.cr2 = address;
-       tsk->thread.trap_no = 14;
-       tsk->thread.error_code = error_code;
-       __die("Oops", regs, error_code);
-       /* Executive summary in case the body of the oops scrolled away */
-       printk(KERN_EMERG "CR2: %016lx\n", address);
-       oops_end(flags);
-       do_exit(SIGKILL);
-
-/*
- * We ran out of memory, or some other thing happened to us that made
- * us unable to handle the page fault gracefully.
- */
-out_of_memory:
-       up_read(&mm->mmap_sem);
-       if (is_init(current)) {
-               yield();
-               goto again;
-       }
-       printk("VM: killing process %s\n", tsk->comm);
-       if (error_code & 4)
-               do_group_exit(SIGKILL);
-       goto no_context;
-
-do_sigbus:
-       up_read(&mm->mmap_sem);
-
-       /* Kernel mode? Handle exceptions or die */
-       if (!(error_code & PF_USER))
-               goto no_context;
-
-       tsk->thread.cr2 = address;
-       tsk->thread.error_code = error_code;
-       tsk->thread.trap_no = 14;
-       info.si_signo = SIGBUS;
-       info.si_errno = 0;
-       info.si_code = BUS_ADRERR;
-       info.si_addr = (void __user *)address;
-       force_sig_info(SIGBUS, &info, tsk);
-       return;
-}
-
-DEFINE_SPINLOCK(pgd_lock);
-LIST_HEAD(pgd_list);
-
-void vmalloc_sync_all(void)
-{
-       /* Note that races in the updates of insync and start aren't 
-          problematic:
-          insync can only get set bits added, and updates to start are only
-          improving performance (without affecting correctness if undone). */
-       static DECLARE_BITMAP(insync, PTRS_PER_PGD);
-       static unsigned long start = VMALLOC_START & PGDIR_MASK;
-       unsigned long address;
-
-       for (address = start; address <= VMALLOC_END; address += PGDIR_SIZE) {
-               if (!test_bit(pgd_index(address), insync)) {
-                       const pgd_t *pgd_ref = pgd_offset_k(address);
-                       struct page *page;
-
-                       if (pgd_none(*pgd_ref))
-                               continue;
-                       spin_lock(&pgd_lock);
-                       list_for_each_entry(page, &pgd_list, lru) {
-                               pgd_t *pgd;
-                               pgd = (pgd_t *)page_address(page) + pgd_index(address);
-                               if (pgd_none(*pgd))
-                                       set_pgd(pgd, *pgd_ref);
-                               else
-                                       BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
-                       }
-                       spin_unlock(&pgd_lock);
-                       set_bit(pgd_index(address), insync);
-               }
-               if (address == start)
-                       start = address + PGDIR_SIZE;
-       }
-       /* Check that there is no need to do the same for the modules area. */
-       BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
-       BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == 
-                               (__START_KERNEL & PGDIR_MASK)));
-}
-
-static int __init enable_pagefaulttrace(char *str)
-{
-       page_fault_trace = 1;
-       return 1;
-}
-__setup("pagefaulttrace", enable_pagefaulttrace);
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
deleted file mode 100644 (file)
index 458893b..0000000
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- *  linux/arch/x86_64/mm/init.c
- *
- *  Copyright (C) 1995  Linus Torvalds
- *  Copyright (C) 2000  Pavel Machek <pavel@suse.cz>
- *  Copyright (C) 2002,2003 Andi Kleen <ak@suse.de>
- */
-
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/pagemap.h>
-#include <linux/bootmem.h>
-#include <linux/proc_fs.h>
-#include <linux/pci.h>
-#include <linux/pfn.h>
-#include <linux/poison.h>
-#include <linux/dma-mapping.h>
-#include <linux/module.h>
-#include <linux/memory_hotplug.h>
-#include <linux/nmi.h>
-
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/pgalloc.h>
-#include <asm/dma.h>
-#include <asm/fixmap.h>
-#include <asm/e820.h>
-#include <asm/apic.h>
-#include <asm/tlb.h>
-#include <asm/mmu_context.h>
-#include <asm/proto.h>
-#include <asm/smp.h>
-#include <asm/sections.h>
-
-#ifndef Dprintk
-#define Dprintk(x...)
-#endif
-
-const struct dma_mapping_ops* dma_ops;
-EXPORT_SYMBOL(dma_ops);
-
-static unsigned long dma_reserve __initdata;
-
-DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
-
-/*
- * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
- * physical space so we can cache the place of the first one and move
- * around without checking the pgd every time.
- */
-
-void show_mem(void)
-{
-       long i, total = 0, reserved = 0;
-       long shared = 0, cached = 0;
-       pg_data_t *pgdat;
-       struct page *page;
-
-       printk(KERN_INFO "Mem-info:\n");
-       show_free_areas();
-       printk(KERN_INFO "Free swap:       %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
-
-       for_each_online_pgdat(pgdat) {
-               for (i = 0; i < pgdat->node_spanned_pages; ++i) {
-                       /* this loop can take a while with 256 GB and 4k pages
-                          so update the NMI watchdog */
-                       if (unlikely(i % MAX_ORDER_NR_PAGES == 0)) {
-                               touch_nmi_watchdog();
-                       }
-                       if (!pfn_valid(pgdat->node_start_pfn + i))
-                               continue;
-                       page = pfn_to_page(pgdat->node_start_pfn + i);
-                       total++;
-                       if (PageReserved(page))
-                               reserved++;
-                       else if (PageSwapCache(page))
-                               cached++;
-                       else if (page_count(page))
-                               shared += page_count(page) - 1;
-               }
-       }
-       printk(KERN_INFO "%lu pages of RAM\n", total);
-       printk(KERN_INFO "%lu reserved pages\n",reserved);
-       printk(KERN_INFO "%lu pages shared\n",shared);
-       printk(KERN_INFO "%lu pages swap cached\n",cached);
-}
-
-int after_bootmem;
-
-static __init void *spp_getpage(void)
-{ 
-       void *ptr;
-       if (after_bootmem)
-               ptr = (void *) get_zeroed_page(GFP_ATOMIC); 
-       else
-               ptr = alloc_bootmem_pages(PAGE_SIZE);
-       if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
-               panic("set_pte_phys: cannot allocate page data %s\n", after_bootmem?"after bootmem":"");
-
-       Dprintk("spp_getpage %p\n", ptr);
-       return ptr;
-} 
-
-static __init void set_pte_phys(unsigned long vaddr,
-                        unsigned long phys, pgprot_t prot)
-{
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte, new_pte;
-
-       Dprintk("set_pte_phys %lx to %lx\n", vaddr, phys);
-
-       pgd = pgd_offset_k(vaddr);
-       if (pgd_none(*pgd)) {
-               printk("PGD FIXMAP MISSING, it should be setup in head.S!\n");
-               return;
-       }
-       pud = pud_offset(pgd, vaddr);
-       if (pud_none(*pud)) {
-               pmd = (pmd_t *) spp_getpage(); 
-               set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
-               if (pmd != pmd_offset(pud, 0)) {
-                       printk("PAGETABLE BUG #01! %p <-> %p\n", pmd, pmd_offset(pud,0));
-                       return;
-               }
-       }
-       pmd = pmd_offset(pud, vaddr);
-       if (pmd_none(*pmd)) {
-               pte = (pte_t *) spp_getpage();
-               set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
-               if (pte != pte_offset_kernel(pmd, 0)) {
-                       printk("PAGETABLE BUG #02!\n");
-                       return;
-               }
-       }
-       new_pte = pfn_pte(phys >> PAGE_SHIFT, prot);
-
-       pte = pte_offset_kernel(pmd, vaddr);
-       if (!pte_none(*pte) &&
-           pte_val(*pte) != (pte_val(new_pte) & __supported_pte_mask))
-               pte_ERROR(*pte);
-       set_pte(pte, new_pte);
-
-       /*
-        * It's enough to flush this one mapping.
-        * (PGE mappings get flushed as well)
-        */
-       __flush_tlb_one(vaddr);
-}
-
-/* NOTE: this is meant to be run only at boot */
-void __init 
-__set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
-{
-       unsigned long address = __fix_to_virt(idx);
-
-       if (idx >= __end_of_fixed_addresses) {
-               printk("Invalid __set_fixmap\n");
-               return;
-       }
-       set_pte_phys(address, phys, prot);
-}
-
-unsigned long __meminitdata table_start, table_end;
-
-static __meminit void *alloc_low_page(unsigned long *phys)
-{ 
-       unsigned long pfn = table_end++;
-       void *adr;
-
-       if (after_bootmem) {
-               adr = (void *)get_zeroed_page(GFP_ATOMIC);
-               *phys = __pa(adr);
-               return adr;
-       }
-
-       if (pfn >= end_pfn) 
-               panic("alloc_low_page: ran out of memory"); 
-
-       adr = early_ioremap(pfn * PAGE_SIZE, PAGE_SIZE);
-       memset(adr, 0, PAGE_SIZE);
-       *phys  = pfn * PAGE_SIZE;
-       return adr;
-}
-
-static __meminit void unmap_low_page(void *adr)
-{ 
-
-       if (after_bootmem)
-               return;
-
-       early_iounmap(adr, PAGE_SIZE);
-} 
-
-/* Must run before zap_low_mappings */
-__meminit void *early_ioremap(unsigned long addr, unsigned long size)
-{
-       unsigned long vaddr;
-       pmd_t *pmd, *last_pmd;
-       int i, pmds;
-
-       pmds = ((addr & ~PMD_MASK) + size + ~PMD_MASK) / PMD_SIZE;
-       vaddr = __START_KERNEL_map;
-       pmd = level2_kernel_pgt;
-       last_pmd = level2_kernel_pgt + PTRS_PER_PMD - 1;
-       for (; pmd <= last_pmd; pmd++, vaddr += PMD_SIZE) {
-               for (i = 0; i < pmds; i++) {
-                       if (pmd_present(pmd[i]))
-                               goto next;
-               }
-               vaddr += addr & ~PMD_MASK;
-               addr &= PMD_MASK;
-               for (i = 0; i < pmds; i++, addr += PMD_SIZE)
-                       set_pmd(pmd + i,__pmd(addr | _KERNPG_TABLE | _PAGE_PSE));
-               __flush_tlb();
-               return (void *)vaddr;
-       next:
-               ;
-       }
-       printk("early_ioremap(0x%lx, %lu) failed\n", addr, size);
-       return NULL;
-}
-
-/* To avoid virtual aliases later */
-__meminit void early_iounmap(void *addr, unsigned long size)
-{
-       unsigned long vaddr;
-       pmd_t *pmd;
-       int i, pmds;
-
-       vaddr = (unsigned long)addr;
-       pmds = ((vaddr & ~PMD_MASK) + size + ~PMD_MASK) / PMD_SIZE;
-       pmd = level2_kernel_pgt + pmd_index(vaddr);
-       for (i = 0; i < pmds; i++)
-               pmd_clear(pmd + i);
-       __flush_tlb();
-}
-
-static void __meminit
-phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
-{
-       int i = pmd_index(address);
-
-       for (; i < PTRS_PER_PMD; i++, address += PMD_SIZE) {
-               unsigned long entry;
-               pmd_t *pmd = pmd_page + pmd_index(address);
-
-               if (address >= end) {
-                       if (!after_bootmem)
-                               for (; i < PTRS_PER_PMD; i++, pmd++)
-                                       set_pmd(pmd, __pmd(0));
-                       break;
-               }
-
-               if (pmd_val(*pmd))
-                       continue;
-
-               entry = _PAGE_NX|_PAGE_PSE|_KERNPG_TABLE|_PAGE_GLOBAL|address;
-               entry &= __supported_pte_mask;
-               set_pmd(pmd, __pmd(entry));
-       }
-}
-
-static void __meminit
-phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end)
-{
-       pmd_t *pmd = pmd_offset(pud,0);
-       spin_lock(&init_mm.page_table_lock);
-       phys_pmd_init(pmd, address, end);
-       spin_unlock(&init_mm.page_table_lock);
-       __flush_tlb_all();
-}
-
-static void __meminit phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
-{ 
-       int i = pud_index(addr);
-
-
-       for (; i < PTRS_PER_PUD; i++, addr = (addr & PUD_MASK) + PUD_SIZE ) {
-               unsigned long pmd_phys;
-               pud_t *pud = pud_page + pud_index(addr);
-               pmd_t *pmd;
-
-               if (addr >= end)
-                       break;
-
-               if (!after_bootmem && !e820_any_mapped(addr,addr+PUD_SIZE,0)) {
-                       set_pud(pud, __pud(0)); 
-                       continue;
-               } 
-
-               if (pud_val(*pud)) {
-                       phys_pmd_update(pud, addr, end);
-                       continue;
-               }
-
-               pmd = alloc_low_page(&pmd_phys);
-               spin_lock(&init_mm.page_table_lock);
-               set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
-               phys_pmd_init(pmd, addr, end);
-               spin_unlock(&init_mm.page_table_lock);
-               unmap_low_page(pmd);
-       }
-       __flush_tlb();
-} 
-
-static void __init find_early_table_space(unsigned long end)
-{
-       unsigned long puds, pmds, tables, start;
-
-       puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
-       pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
-       tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) +
-                round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
-
-       /* RED-PEN putting page tables only on node 0 could
-          cause a hotspot and fill up ZONE_DMA. The page tables
-          need roughly 0.5KB per GB. */
-       start = 0x8000;
-       table_start = find_e820_area(start, end, tables);
-       if (table_start == -1UL)
-               panic("Cannot find space for the kernel page tables");
-
-       table_start >>= PAGE_SHIFT;
-       table_end = table_start;
-
-       early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
-               end, table_start << PAGE_SHIFT,
-               (table_start << PAGE_SHIFT) + tables);
-}
-
-/* Setup the direct mapping of the physical memory at PAGE_OFFSET.
-   This runs before bootmem is initialized and gets pages directly from the 
-   physical memory. To access them they are temporarily mapped. */
-void __meminit init_memory_mapping(unsigned long start, unsigned long end)
-{ 
-       unsigned long next; 
-
-       Dprintk("init_memory_mapping\n");
-
-       /* 
-        * Find space for the kernel direct mapping tables.
-        * Later we should allocate these tables in the local node of the memory
-        * mapped.  Unfortunately this is done currently before the nodes are 
-        * discovered.
-        */
-       if (!after_bootmem)
-               find_early_table_space(end);
-
-       start = (unsigned long)__va(start);
-       end = (unsigned long)__va(end);
-
-       for (; start < end; start = next) {
-               unsigned long pud_phys; 
-               pgd_t *pgd = pgd_offset_k(start);
-               pud_t *pud;
-
-               if (after_bootmem)
-                       pud = pud_offset(pgd, start & PGDIR_MASK);
-               else
-                       pud = alloc_low_page(&pud_phys);
-
-               next = start + PGDIR_SIZE;
-               if (next > end) 
-                       next = end; 
-               phys_pud_init(pud, __pa(start), __pa(next));
-               if (!after_bootmem)
-                       set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
-               unmap_low_page(pud);
-       } 
-
-       if (!after_bootmem)
-               mmu_cr4_features = read_cr4();
-       __flush_tlb_all();
-}
-
-#ifndef CONFIG_NUMA
-void __init paging_init(void)
-{
-       unsigned long max_zone_pfns[MAX_NR_ZONES];
-       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
-       max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
-       max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
-       max_zone_pfns[ZONE_NORMAL] = end_pfn;
-
-       memory_present(0, 0, end_pfn);
-       sparse_init();
-       free_area_init_nodes(max_zone_pfns);
-}
-#endif
-
-/* Unmap a kernel mapping if it exists. This is useful to avoid prefetches
-   from the CPU leading to inconsistent cache lines. address and size
-   must be aligned to 2MB boundaries. 
-   Does nothing when the mapping doesn't exist. */
-void __init clear_kernel_mapping(unsigned long address, unsigned long size) 
-{
-       unsigned long end = address + size;
-
-       BUG_ON(address & ~LARGE_PAGE_MASK);
-       BUG_ON(size & ~LARGE_PAGE_MASK); 
-       
-       for (; address < end; address += LARGE_PAGE_SIZE) { 
-               pgd_t *pgd = pgd_offset_k(address);
-               pud_t *pud;
-               pmd_t *pmd;
-               if (pgd_none(*pgd))
-                       continue;
-               pud = pud_offset(pgd, address);
-               if (pud_none(*pud))
-                       continue; 
-               pmd = pmd_offset(pud, address);
-               if (!pmd || pmd_none(*pmd))
-                       continue; 
-               if (0 == (pmd_val(*pmd) & _PAGE_PSE)) { 
-                       /* Could handle this, but it should not happen currently. */
-                       printk(KERN_ERR 
-              "clear_kernel_mapping: mapping has been split. will leak memory\n"); 
-                       pmd_ERROR(*pmd); 
-               }
-               set_pmd(pmd, __pmd(0));                 
-       }
-       __flush_tlb_all();
-} 
-
-/*
- * Memory hotplug specific functions
- */
-void online_page(struct page *page)
-{
-       ClearPageReserved(page);
-       init_page_count(page);
-       __free_page(page);
-       totalram_pages++;
-       num_physpages++;
-}
-
-#ifdef CONFIG_MEMORY_HOTPLUG
-/*
- * Memory is added always to NORMAL zone. This means you will never get
- * additional DMA/DMA32 memory.
- */
-int arch_add_memory(int nid, u64 start, u64 size)
-{
-       struct pglist_data *pgdat = NODE_DATA(nid);
-       struct zone *zone = pgdat->node_zones + ZONE_NORMAL;
-       unsigned long start_pfn = start >> PAGE_SHIFT;
-       unsigned long nr_pages = size >> PAGE_SHIFT;
-       int ret;
-
-       init_memory_mapping(start, (start + size -1));
-
-       ret = __add_pages(zone, start_pfn, nr_pages);
-       if (ret)
-               goto error;
-
-       return ret;
-error:
-       printk("%s: Problem encountered in __add_pages!\n", __func__);
-       return ret;
-}
-EXPORT_SYMBOL_GPL(arch_add_memory);
-
-int remove_memory(u64 start, u64 size)
-{
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(remove_memory);
-
-#if !defined(CONFIG_ACPI_NUMA) && defined(CONFIG_NUMA)
-int memory_add_physaddr_to_nid(u64 start)
-{
-       return 0;
-}
-EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
-#endif
-
-#endif /* CONFIG_MEMORY_HOTPLUG */
-
-#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
-/*
- * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
- * just online the pages.
- */
-int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
-{
-       int err = -EIO;
-       unsigned long pfn;
-       unsigned long total = 0, mem = 0;
-       for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
-               if (pfn_valid(pfn)) {
-                       online_page(pfn_to_page(pfn));
-                       err = 0;
-                       mem++;
-               }
-               total++;
-       }
-       if (!err) {
-               z->spanned_pages += total;
-               z->present_pages += mem;
-               z->zone_pgdat->node_spanned_pages += total;
-               z->zone_pgdat->node_present_pages += mem;
-       }
-       return err;
-}
-#endif
-
-static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
-                        kcore_vsyscall;
-
-void __init mem_init(void)
-{
-       long codesize, reservedpages, datasize, initsize;
-
-       pci_iommu_alloc();
-
-       /* clear the zero-page */
-       memset(empty_zero_page, 0, PAGE_SIZE);
-
-       reservedpages = 0;
-
-       /* this will put all low memory onto the freelists */
-#ifdef CONFIG_NUMA
-       totalram_pages = numa_free_all_bootmem();
-#else
-       totalram_pages = free_all_bootmem();
-#endif
-       reservedpages = end_pfn - totalram_pages -
-                                       absent_pages_in_range(0, end_pfn);
-
-       after_bootmem = 1;
-
-       codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-       datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-       initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-       /* Register memory areas for /proc/kcore */
-       kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT); 
-       kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, 
-                  VMALLOC_END-VMALLOC_START);
-       kclist_add(&kcore_kernel, &_stext, _end - _stext);
-       kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN);
-       kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, 
-                                VSYSCALL_END - VSYSCALL_START);
-
-       printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, %ldk data, %ldk init)\n",
-               (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
-               end_pfn << (PAGE_SHIFT-10),
-               codesize >> 10,
-               reservedpages << (PAGE_SHIFT-10),
-               datasize >> 10,
-               initsize >> 10);
-}
-
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
-       unsigned long addr;
-
-       if (begin >= end)
-               return;
-
-       printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
-       for (addr = begin; addr < end; addr += PAGE_SIZE) {
-               ClearPageReserved(virt_to_page(addr));
-               init_page_count(virt_to_page(addr));
-               memset((void *)(addr & ~(PAGE_SIZE-1)),
-                       POISON_FREE_INITMEM, PAGE_SIZE);
-               if (addr >= __START_KERNEL_map)
-                       change_page_attr_addr(addr, 1, __pgprot(0));
-               free_page(addr);
-               totalram_pages++;
-       }
-       if (addr > __START_KERNEL_map)
-               global_flush_tlb();
-}
-
-void free_initmem(void)
-{
-       free_init_pages("unused kernel memory",
-                       (unsigned long)(&__init_begin),
-                       (unsigned long)(&__init_end));
-}
-
-#ifdef CONFIG_DEBUG_RODATA
-
-void mark_rodata_ro(void)
-{
-       unsigned long start = (unsigned long)_stext, end;
-
-#ifdef CONFIG_HOTPLUG_CPU
-       /* It must still be possible to apply SMP alternatives. */
-       if (num_possible_cpus() > 1)
-               start = (unsigned long)_etext;
-#endif
-
-#ifdef CONFIG_KPROBES
-       start = (unsigned long)__start_rodata;
-#endif
-       
-       end = (unsigned long)__end_rodata;
-       start = (start + PAGE_SIZE - 1) & PAGE_MASK;
-       end &= PAGE_MASK;
-       if (end <= start)
-               return;
-
-       change_page_attr_addr(start, (end - start) >> PAGE_SHIFT, PAGE_KERNEL_RO);
-
-       printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
-              (end - start) >> 10);
-
-       /*
-        * change_page_attr_addr() requires a global_flush_tlb() call after it.
-        * We do this after the printk so that if something went wrong in the
-        * change, the printk gets out at least to give a better debug hint
-        * of who is the culprit.
-        */
-       global_flush_tlb();
-}
-#endif
-
-#ifdef CONFIG_BLK_DEV_INITRD
-void free_initrd_mem(unsigned long start, unsigned long end)
-{
-       free_init_pages("initrd memory", start, end);
-}
-#endif
-
-void __init reserve_bootmem_generic(unsigned long phys, unsigned len) 
-{ 
-#ifdef CONFIG_NUMA
-       int nid = phys_to_nid(phys);
-#endif
-       unsigned long pfn = phys >> PAGE_SHIFT;
-       if (pfn >= end_pfn) {
-               /* This can happen with kdump kernels when accessing firmware
-                  tables. */
-               if (pfn < end_pfn_map)
-                       return;
-               printk(KERN_ERR "reserve_bootmem: illegal reserve %lx %u\n",
-                               phys, len);
-               return;
-       }
-
-       /* Should check here against the e820 map to avoid double free */
-#ifdef CONFIG_NUMA
-       reserve_bootmem_node(NODE_DATA(nid), phys, len);
-#else                  
-       reserve_bootmem(phys, len);    
-#endif
-       if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
-               dma_reserve += len / PAGE_SIZE;
-               set_dma_reserve(dma_reserve);
-       }
-}
-
-int kern_addr_valid(unsigned long addr) 
-{ 
-       unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT;
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
-
-       if (above != 0 && above != -1UL)
-               return 0; 
-       
-       pgd = pgd_offset_k(addr);
-       if (pgd_none(*pgd))
-               return 0;
-
-       pud = pud_offset(pgd, addr);
-       if (pud_none(*pud))
-               return 0; 
-
-       pmd = pmd_offset(pud, addr);
-       if (pmd_none(*pmd))
-               return 0;
-       if (pmd_large(*pmd))
-               return pfn_valid(pmd_pfn(*pmd));
-
-       pte = pte_offset_kernel(pmd, addr);
-       if (pte_none(*pte))
-               return 0;
-       return pfn_valid(pte_pfn(*pte));
-}
-
-/* A pseudo VMA to allow ptrace access for the vsyscall page.  This only
-   covers the 64bit vsyscall page now. 32bit has a real VMA now and does
-   not need special handling anymore. */
-
-static struct vm_area_struct gate_vma = {
-       .vm_start = VSYSCALL_START,
-       .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES << PAGE_SHIFT),
-       .vm_page_prot = PAGE_READONLY_EXEC,
-       .vm_flags = VM_READ | VM_EXEC
-};
-
-struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
-{
-#ifdef CONFIG_IA32_EMULATION
-       if (test_tsk_thread_flag(tsk, TIF_IA32))
-               return NULL;
-#endif
-       return &gate_vma;
-}
-
-int in_gate_area(struct task_struct *task, unsigned long addr)
-{
-       struct vm_area_struct *vma = get_gate_vma(task);
-       if (!vma)
-               return 0;
-       return (addr >= vma->vm_start) && (addr < vma->vm_end);
-}
-
-/* Use this when you have no reliable task/vma, typically from interrupt
- * context.  It is less reliable than using the task's vma and may give
- * false positives.
- */
-int in_gate_area_no_task(unsigned long addr)
-{
-       return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
-}
-
-void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
-{
-       return __alloc_bootmem_core(pgdat->bdata, size,
-                       SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
-}
-
-const char *arch_vma_name(struct vm_area_struct *vma)
-{
-       if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
-               return "[vdso]";
-       if (vma == &gate_vma)
-               return "[vsyscall]";
-       return NULL;
-}
diff --git a/arch/x86_64/mm/ioremap.c b/arch/x86_64/mm/ioremap.c
deleted file mode 100644 (file)
index 6cac90a..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * arch/x86_64/mm/ioremap.c
- *
- * Re-map IO memory to kernel address space so that we can access it.
- * This is needed for high PCI addresses that aren't mapped in the
- * 640k-1MB IO memory area on PC's
- *
- * (C) Copyright 1995 1996 Linus Torvalds
- */
-
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/io.h>
-
-#include <asm/pgalloc.h>
-#include <asm/fixmap.h>
-#include <asm/tlbflush.h>
-#include <asm/cacheflush.h>
-#include <asm/proto.h>
-
-unsigned long __phys_addr(unsigned long x)
-{
-       if (x >= __START_KERNEL_map)
-               return x - __START_KERNEL_map + phys_base;
-       return x - PAGE_OFFSET;
-}
-EXPORT_SYMBOL(__phys_addr);
-
-#define ISA_START_ADDRESS      0xa0000
-#define ISA_END_ADDRESS                0x100000
-
-/*
- * Fix up the linear direct mapping of the kernel to avoid cache attribute
- * conflicts.
- */
-static int
-ioremap_change_attr(unsigned long phys_addr, unsigned long size,
-                                       unsigned long flags)
-{
-       int err = 0;
-       if (phys_addr + size - 1 < (end_pfn_map << PAGE_SHIFT)) {
-               unsigned long npages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-               unsigned long vaddr = (unsigned long) __va(phys_addr);
-
-               /*
-                * Must use a address here and not struct page because the phys addr
-                * can be a in hole between nodes and not have an memmap entry.
-                */
-               err = change_page_attr_addr(vaddr,npages,__pgprot(__PAGE_KERNEL|flags));
-               if (!err)
-                       global_flush_tlb();
-       }
-       return err;
-}
-
-/*
- * Generic mapping function
- */
-
-/*
- * Remap an arbitrary physical address space into the kernel virtual
- * address space. Needed when the kernel wants to access high addresses
- * directly.
- *
- * NOTE! We need to allow non-page-aligned mappings too: we will obviously
- * have to convert them into an offset in a page-aligned mapping, but the
- * caller shouldn't need to know that small detail.
- */
-void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
-{
-       void * addr;
-       struct vm_struct * area;
-       unsigned long offset, last_addr;
-       pgprot_t pgprot;
-
-       /* Don't allow wraparound or zero size */
-       last_addr = phys_addr + size - 1;
-       if (!size || last_addr < phys_addr)
-               return NULL;
-
-       /*
-        * Don't remap the low PCI/ISA area, it's always mapped..
-        */
-       if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
-               return (__force void __iomem *)phys_to_virt(phys_addr);
-
-#ifdef CONFIG_FLATMEM
-       /*
-        * Don't allow anybody to remap normal RAM that we're using..
-        */
-       if (last_addr < virt_to_phys(high_memory)) {
-               char *t_addr, *t_end;
-               struct page *page;
-
-               t_addr = __va(phys_addr);
-               t_end = t_addr + (size - 1);
-          
-               for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
-                       if(!PageReserved(page))
-                               return NULL;
-       }
-#endif
-
-       pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_GLOBAL
-                         | _PAGE_DIRTY | _PAGE_ACCESSED | flags);
-       /*
-        * Mappings have to be page-aligned
-        */
-       offset = phys_addr & ~PAGE_MASK;
-       phys_addr &= PAGE_MASK;
-       size = PAGE_ALIGN(last_addr+1) - phys_addr;
-
-       /*
-        * Ok, go for it..
-        */
-       area = get_vm_area(size, VM_IOREMAP | (flags << 20));
-       if (!area)
-               return NULL;
-       area->phys_addr = phys_addr;
-       addr = area->addr;
-       if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
-                              phys_addr, pgprot)) {
-               remove_vm_area((void *)(PAGE_MASK & (unsigned long) addr));
-               return NULL;
-       }
-       if (flags && ioremap_change_attr(phys_addr, size, flags) < 0) {
-               area->flags &= 0xffffff;
-               vunmap(addr);
-               return NULL;
-       }
-       return (__force void __iomem *) (offset + (char *)addr);
-}
-EXPORT_SYMBOL(__ioremap);
-
-/**
- * ioremap_nocache     -   map bus memory into CPU space
- * @offset:    bus address of the memory
- * @size:      size of the resource to map
- *
- * ioremap_nocache performs a platform specific sequence of operations to
- * make bus memory CPU accessible via the readb/readw/readl/writeb/
- * writew/writel functions and the other mmio helpers. The returned
- * address is not guaranteed to be usable directly as a virtual
- * address. 
- *
- * This version of ioremap ensures that the memory is marked uncachable
- * on the CPU as well as honouring existing caching rules from things like
- * the PCI bus. Note that there are other caches and buffers on many 
- * busses. In particular driver authors should read up on PCI writes
- *
- * It's useful if some control registers are in such an area and
- * write combining or read caching is not desirable:
- * 
- * Must be freed with iounmap.
- */
-
-void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
-{
-       return __ioremap(phys_addr, size, _PAGE_PCD);
-}
-EXPORT_SYMBOL(ioremap_nocache);
-
-/**
- * iounmap - Free a IO remapping
- * @addr: virtual address from ioremap_*
- *
- * Caller must ensure there is only one unmapping for the same pointer.
- */
-void iounmap(volatile void __iomem *addr)
-{
-       struct vm_struct *p, *o;
-
-       if (addr <= high_memory) 
-               return; 
-       if (addr >= phys_to_virt(ISA_START_ADDRESS) &&
-               addr < phys_to_virt(ISA_END_ADDRESS))
-               return;
-
-       addr = (volatile void __iomem *)(PAGE_MASK & (unsigned long __force)addr);
-       /* Use the vm area unlocked, assuming the caller
-          ensures there isn't another iounmap for the same address
-          in parallel. Reuse of the virtual address is prevented by
-          leaving it in the global lists until we're done with it.
-          cpa takes care of the direct mappings. */
-       read_lock(&vmlist_lock);
-       for (p = vmlist; p; p = p->next) {
-               if (p->addr == addr)
-                       break;
-       }
-       read_unlock(&vmlist_lock);
-
-       if (!p) {
-               printk("iounmap: bad address %p\n", addr);
-               dump_stack();
-               return;
-       }
-
-       /* Reset the direct mapping. Can block */
-       if (p->flags >> 20)
-               ioremap_change_attr(p->phys_addr, p->size, 0);
-
-       /* Finally remove it */
-       o = remove_vm_area((void *)addr);
-       BUG_ON(p != o || o == NULL);
-       kfree(p); 
-}
-EXPORT_SYMBOL(iounmap);
-
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
deleted file mode 100644 (file)
index a96006f..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/* 
- * AMD K8 NUMA support.
- * Discover the memory map and associated nodes.
- * 
- * This version reads it directly from the K8 northbridge.
- * 
- * Copyright 2002,2003 Andi Kleen, SuSE Labs.
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/nodemask.h>
-#include <asm/io.h>
-#include <linux/pci_ids.h>
-#include <asm/types.h>
-#include <asm/mmzone.h>
-#include <asm/proto.h>
-#include <asm/e820.h>
-#include <asm/pci-direct.h>
-#include <asm/numa.h>
-
-static __init int find_northbridge(void)
-{
-       int num; 
-
-       for (num = 0; num < 32; num++) { 
-               u32 header;
-               
-               header = read_pci_config(0, num, 0, 0x00);  
-               if (header != (PCI_VENDOR_ID_AMD | (0x1100<<16)))
-                       continue;       
-
-               header = read_pci_config(0, num, 1, 0x00); 
-               if (header != (PCI_VENDOR_ID_AMD | (0x1101<<16)))
-                       continue;       
-               return num; 
-       } 
-
-       return -1;      
-}
-
-int __init k8_scan_nodes(unsigned long start, unsigned long end)
-{ 
-       unsigned long prevbase;
-       struct bootnode nodes[8];
-       int nodeid, i, j, nb;
-       unsigned char nodeids[8];
-       int found = 0;
-       u32 reg;
-       unsigned numnodes;
-       unsigned num_cores;
-
-       if (!early_pci_allowed())
-               return -1;
-
-       nb = find_northbridge(); 
-       if (nb < 0) 
-               return nb;
-
-       printk(KERN_INFO "Scanning NUMA topology in Northbridge %d\n", nb); 
-
-       num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
-       printk(KERN_INFO "CPU has %d num_cores\n", num_cores);
-
-       reg = read_pci_config(0, nb, 0, 0x60); 
-       numnodes = ((reg >> 4) & 0xF) + 1;
-       if (numnodes <= 1)
-               return -1;
-
-       printk(KERN_INFO "Number of nodes %d\n", numnodes);
-
-       memset(&nodes,0,sizeof(nodes)); 
-       prevbase = 0;
-       for (i = 0; i < 8; i++) { 
-               unsigned long base,limit; 
-               u32 nodeid;
-               
-               base = read_pci_config(0, nb, 1, 0x40 + i*8);
-               limit = read_pci_config(0, nb, 1, 0x44 + i*8);
-
-               nodeid = limit & 7; 
-               nodeids[i] = nodeid;
-               if ((base & 3) == 0) { 
-                       if (i < numnodes)
-                               printk("Skipping disabled node %d\n", i); 
-                       continue;
-               } 
-               if (nodeid >= numnodes) {
-                       printk("Ignoring excess node %d (%lx:%lx)\n", nodeid,
-                              base, limit); 
-                       continue;
-               } 
-
-               if (!limit) { 
-                       printk(KERN_INFO "Skipping node entry %d (base %lx)\n", i,
-                              base);
-                       continue;
-               }
-               if ((base >> 8) & 3 || (limit >> 8) & 3) {
-                       printk(KERN_ERR "Node %d using interleaving mode %lx/%lx\n", 
-                              nodeid, (base>>8)&3, (limit>>8) & 3); 
-                       return -1; 
-               }       
-               if (node_isset(nodeid, node_possible_map)) {
-                       printk(KERN_INFO "Node %d already present. Skipping\n", 
-                              nodeid);
-                       continue;
-               }
-
-               limit >>= 16; 
-               limit <<= 24; 
-               limit |= (1<<24)-1;
-               limit++;
-
-               if (limit > end_pfn << PAGE_SHIFT)
-                       limit = end_pfn << PAGE_SHIFT;
-               if (limit <= base)
-                       continue; 
-                       
-               base >>= 16;
-               base <<= 24; 
-
-               if (base < start) 
-                       base = start; 
-               if (limit > end) 
-                       limit = end; 
-               if (limit == base) { 
-                       printk(KERN_ERR "Empty node %d\n", nodeid); 
-                       continue; 
-               }
-               if (limit < base) { 
-                       printk(KERN_ERR "Node %d bogus settings %lx-%lx.\n",
-                              nodeid, base, limit);                           
-                       continue;
-               } 
-               
-               /* Could sort here, but pun for now. Should not happen anyroads. */
-               if (prevbase > base) { 
-                       printk(KERN_ERR "Node map not sorted %lx,%lx\n",
-                              prevbase,base);
-                       return -1;
-               }
-                       
-               printk(KERN_INFO "Node %d MemBase %016lx Limit %016lx\n", 
-                      nodeid, base, limit); 
-               
-               found++;
-               
-               nodes[nodeid].start = base; 
-               nodes[nodeid].end = limit;
-               e820_register_active_regions(nodeid,
-                               nodes[nodeid].start >> PAGE_SHIFT,
-                               nodes[nodeid].end >> PAGE_SHIFT);
-
-               prevbase = base;
-
-               node_set(nodeid, node_possible_map);
-       } 
-
-       if (!found)
-               return -1; 
-
-       memnode_shift = compute_hash_shift(nodes, 8);
-       if (memnode_shift < 0) { 
-               printk(KERN_ERR "No NUMA node hash function found. Contact maintainer\n"); 
-               return -1; 
-       } 
-       printk(KERN_INFO "Using node hash shift of %d\n", memnode_shift); 
-
-       for (i = 0; i < 8; i++) {
-               if (nodes[i].start != nodes[i].end) { 
-                       nodeid = nodeids[i];
-                       for (j = 0; j < num_cores; j++)
-                               apicid_to_node[(nodeid * num_cores) + j] = i;
-                       setup_node_bootmem(i, nodes[i].start, nodes[i].end); 
-               } 
-       }
-
-       numa_init_array();
-       return 0;
-} 
diff --git a/arch/x86_64/mm/mmap.c b/arch/x86_64/mm/mmap.c
deleted file mode 100644 (file)
index 80bba0d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2005 Andi Kleen, SuSE Labs.
- * Licensed under GPL, v.2
- */
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/random.h>
-#include <asm/ia32.h>
-
-/* Notebook: move the mmap code from sys_x86_64.c over here. */
-
-void arch_pick_mmap_layout(struct mm_struct *mm)
-{
-#ifdef CONFIG_IA32_EMULATION
-       if (current_thread_info()->flags & _TIF_IA32)
-               return ia32_pick_mmap_layout(mm);
-#endif
-       mm->mmap_base = TASK_UNMAPPED_BASE;
-       if (current->flags & PF_RANDOMIZE) {
-               /* Add 28bit randomness which is about 40bits of address space
-                  because mmap base has to be page aligned.
-                  or ~1/128 of the total user VM
-                  (total user address space is 47bits) */
-               unsigned rnd = get_random_int() & 0xfffffff;
-               mm->mmap_base += ((unsigned long)rnd) << PAGE_SHIFT;
-       }
-       mm->get_unmapped_area = arch_get_unmapped_area;
-       mm->unmap_area = arch_unmap_area;
-}
-
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
deleted file mode 100644 (file)
index 6da2355..0000000
+++ /dev/null
@@ -1,648 +0,0 @@
-/* 
- * Generic VM initialization for x86-64 NUMA setups.
- * Copyright 2002,2003 Andi Kleen, SuSE Labs.
- */ 
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/init.h>
-#include <linux/bootmem.h>
-#include <linux/mmzone.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/nodemask.h>
-
-#include <asm/e820.h>
-#include <asm/proto.h>
-#include <asm/dma.h>
-#include <asm/numa.h>
-#include <asm/acpi.h>
-
-#ifndef Dprintk
-#define Dprintk(x...)
-#endif
-
-struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
-bootmem_data_t plat_node_bdata[MAX_NUMNODES];
-
-struct memnode memnode;
-
-unsigned char cpu_to_node[NR_CPUS] __read_mostly = {
-       [0 ... NR_CPUS-1] = NUMA_NO_NODE
-};
-unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = {
-       [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
-};
-cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly;
-
-int numa_off __initdata;
-unsigned long __initdata nodemap_addr;
-unsigned long __initdata nodemap_size;
-
-
-/*
- * Given a shift value, try to populate memnodemap[]
- * Returns :
- * 1 if OK
- * 0 if memnodmap[] too small (of shift too small)
- * -1 if node overlap or lost ram (shift too big)
- */
-static int __init
-populate_memnodemap(const struct bootnode *nodes, int numnodes, int shift)
-{
-       int i; 
-       int res = -1;
-       unsigned long addr, end;
-
-       memset(memnodemap, 0xff, memnodemapsize);
-       for (i = 0; i < numnodes; i++) {
-               addr = nodes[i].start;
-               end = nodes[i].end;
-               if (addr >= end)
-                       continue;
-               if ((end >> shift) >= memnodemapsize)
-                       return 0;
-               do {
-                       if (memnodemap[addr >> shift] != 0xff)
-                               return -1;
-                       memnodemap[addr >> shift] = i;
-                       addr += (1UL << shift);
-               } while (addr < end);
-               res = 1;
-       } 
-       return res;
-}
-
-static int __init allocate_cachealigned_memnodemap(void)
-{
-       unsigned long pad, pad_addr;
-
-       memnodemap = memnode.embedded_map;
-       if (memnodemapsize <= 48)
-               return 0;
-
-       pad = L1_CACHE_BYTES - 1;
-       pad_addr = 0x8000;
-       nodemap_size = pad + memnodemapsize;
-       nodemap_addr = find_e820_area(pad_addr, end_pfn<<PAGE_SHIFT,
-                                     nodemap_size);
-       if (nodemap_addr == -1UL) {
-               printk(KERN_ERR
-                      "NUMA: Unable to allocate Memory to Node hash map\n");
-               nodemap_addr = nodemap_size = 0;
-               return -1;
-       }
-       pad_addr = (nodemap_addr + pad) & ~pad;
-       memnodemap = phys_to_virt(pad_addr);
-
-       printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n",
-              nodemap_addr, nodemap_addr + nodemap_size);
-       return 0;
-}
-
-/*
- * The LSB of all start and end addresses in the node map is the value of the
- * maximum possible shift.
- */
-static int __init
-extract_lsb_from_nodes (const struct bootnode *nodes, int numnodes)
-{
-       int i, nodes_used = 0;
-       unsigned long start, end;
-       unsigned long bitfield = 0, memtop = 0;
-
-       for (i = 0; i < numnodes; i++) {
-               start = nodes[i].start;
-               end = nodes[i].end;
-               if (start >= end)
-                       continue;
-               bitfield |= start;
-               nodes_used++;
-               if (end > memtop)
-                       memtop = end;
-       }
-       if (nodes_used <= 1)
-               i = 63;
-       else
-               i = find_first_bit(&bitfield, sizeof(unsigned long)*8);
-       memnodemapsize = (memtop >> i)+1;
-       return i;
-}
-
-int __init compute_hash_shift(struct bootnode *nodes, int numnodes)
-{
-       int shift;
-
-       shift = extract_lsb_from_nodes(nodes, numnodes);
-       if (allocate_cachealigned_memnodemap())
-               return -1;
-       printk(KERN_DEBUG "NUMA: Using %d for the hash shift.\n",
-               shift);
-
-       if (populate_memnodemap(nodes, numnodes, shift) != 1) {
-               printk(KERN_INFO
-       "Your memory is not aligned you need to rebuild your kernel "
-       "with a bigger NODEMAPSIZE shift=%d\n",
-                       shift);
-               return -1;
-       }
-       return shift;
-}
-
-#ifdef CONFIG_SPARSEMEM
-int early_pfn_to_nid(unsigned long pfn)
-{
-       return phys_to_nid(pfn << PAGE_SHIFT);
-}
-#endif
-
-static void * __init
-early_node_mem(int nodeid, unsigned long start, unsigned long end,
-             unsigned long size)
-{
-       unsigned long mem = find_e820_area(start, end, size);
-       void *ptr;
-       if (mem != -1L)
-               return __va(mem);
-       ptr = __alloc_bootmem_nopanic(size,
-                               SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS));
-       if (ptr == 0) {
-               printk(KERN_ERR "Cannot find %lu bytes in node %d\n",
-                       size, nodeid);
-               return NULL;
-       }
-       return ptr;
-}
-
-/* Initialize bootmem allocator for a node */
-void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
-{ 
-       unsigned long start_pfn, end_pfn, bootmap_pages, bootmap_size, bootmap_start; 
-       unsigned long nodedata_phys;
-       void *bootmap;
-       const int pgdat_size = round_up(sizeof(pg_data_t), PAGE_SIZE);
-
-       start = round_up(start, ZONE_ALIGN); 
-
-       printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid, start, end);
-
-       start_pfn = start >> PAGE_SHIFT;
-       end_pfn = end >> PAGE_SHIFT;
-
-       node_data[nodeid] = early_node_mem(nodeid, start, end, pgdat_size);
-       if (node_data[nodeid] == NULL)
-               return;
-       nodedata_phys = __pa(node_data[nodeid]);
-
-       memset(NODE_DATA(nodeid), 0, sizeof(pg_data_t));
-       NODE_DATA(nodeid)->bdata = &plat_node_bdata[nodeid];
-       NODE_DATA(nodeid)->node_start_pfn = start_pfn;
-       NODE_DATA(nodeid)->node_spanned_pages = end_pfn - start_pfn;
-
-       /* Find a place for the bootmem map */
-       bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn); 
-       bootmap_start = round_up(nodedata_phys + pgdat_size, PAGE_SIZE);
-       bootmap = early_node_mem(nodeid, bootmap_start, end,
-                                       bootmap_pages<<PAGE_SHIFT);
-       if (bootmap == NULL)  {
-               if (nodedata_phys < start || nodedata_phys >= end)
-                       free_bootmem((unsigned long)node_data[nodeid],pgdat_size);
-               node_data[nodeid] = NULL;
-               return;
-       }
-       bootmap_start = __pa(bootmap);
-       Dprintk("bootmap start %lu pages %lu\n", bootmap_start, bootmap_pages); 
-       
-       bootmap_size = init_bootmem_node(NODE_DATA(nodeid),
-                                        bootmap_start >> PAGE_SHIFT, 
-                                        start_pfn, end_pfn); 
-
-       free_bootmem_with_active_regions(nodeid, end);
-
-       reserve_bootmem_node(NODE_DATA(nodeid), nodedata_phys, pgdat_size); 
-       reserve_bootmem_node(NODE_DATA(nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT);
-#ifdef CONFIG_ACPI_NUMA
-       srat_reserve_add_area(nodeid);
-#endif
-       node_set_online(nodeid);
-} 
-
-/* Initialize final allocator for a zone */
-void __init setup_node_zones(int nodeid)
-{ 
-       unsigned long start_pfn, end_pfn, memmapsize, limit;
-
-       start_pfn = node_start_pfn(nodeid);
-       end_pfn = node_end_pfn(nodeid);
-
-       Dprintk(KERN_INFO "Setting up memmap for node %d %lx-%lx\n",
-               nodeid, start_pfn, end_pfn);
-
-       /* Try to allocate mem_map at end to not fill up precious <4GB
-          memory. */
-       memmapsize = sizeof(struct page) * (end_pfn-start_pfn);
-       limit = end_pfn << PAGE_SHIFT;
-#ifdef CONFIG_FLAT_NODE_MEM_MAP
-       NODE_DATA(nodeid)->node_mem_map = 
-               __alloc_bootmem_core(NODE_DATA(nodeid)->bdata, 
-                               memmapsize, SMP_CACHE_BYTES, 
-                               round_down(limit - memmapsize, PAGE_SIZE), 
-                               limit);
-#endif
-} 
-
-void __init numa_init_array(void)
-{
-       int rr, i;
-       /* There are unfortunately some poorly designed mainboards around
-          that only connect memory to a single CPU. This breaks the 1:1 cpu->node
-          mapping. To avoid this fill in the mapping for all possible
-          CPUs, as the number of CPUs is not known yet. 
-          We round robin the existing nodes. */
-       rr = first_node(node_online_map);
-       for (i = 0; i < NR_CPUS; i++) {
-               if (cpu_to_node[i] != NUMA_NO_NODE)
-                       continue;
-               numa_set_node(i, rr);
-               rr = next_node(rr, node_online_map);
-               if (rr == MAX_NUMNODES)
-                       rr = first_node(node_online_map);
-       }
-
-}
-
-#ifdef CONFIG_NUMA_EMU
-/* Numa emulation */
-char *cmdline __initdata;
-
-/*
- * Setups up nid to range from addr to addr + size.  If the end boundary is
- * greater than max_addr, then max_addr is used instead.  The return value is 0
- * if there is additional memory left for allocation past addr and -1 otherwise.
- * addr is adjusted to be at the end of the node.
- */
-static int __init setup_node_range(int nid, struct bootnode *nodes, u64 *addr,
-                                  u64 size, u64 max_addr)
-{
-       int ret = 0;
-       nodes[nid].start = *addr;
-       *addr += size;
-       if (*addr >= max_addr) {
-               *addr = max_addr;
-               ret = -1;
-       }
-       nodes[nid].end = *addr;
-       node_set(nid, node_possible_map);
-       printk(KERN_INFO "Faking node %d at %016Lx-%016Lx (%LuMB)\n", nid,
-              nodes[nid].start, nodes[nid].end,
-              (nodes[nid].end - nodes[nid].start) >> 20);
-       return ret;
-}
-
-/*
- * Splits num_nodes nodes up equally starting at node_start.  The return value
- * is the number of nodes split up and addr is adjusted to be at the end of the
- * last node allocated.
- */
-static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
-                                     u64 max_addr, int node_start,
-                                     int num_nodes)
-{
-       unsigned int big;
-       u64 size;
-       int i;
-
-       if (num_nodes <= 0)
-               return -1;
-       if (num_nodes > MAX_NUMNODES)
-               num_nodes = MAX_NUMNODES;
-       size = (max_addr - *addr - e820_hole_size(*addr, max_addr)) /
-              num_nodes;
-       /*
-        * Calculate the number of big nodes that can be allocated as a result
-        * of consolidating the leftovers.
-        */
-       big = ((size & ~FAKE_NODE_MIN_HASH_MASK) * num_nodes) /
-             FAKE_NODE_MIN_SIZE;
-
-       /* Round down to nearest FAKE_NODE_MIN_SIZE. */
-       size &= FAKE_NODE_MIN_HASH_MASK;
-       if (!size) {
-               printk(KERN_ERR "Not enough memory for each node.  "
-                      "NUMA emulation disabled.\n");
-               return -1;
-       }
-
-       for (i = node_start; i < num_nodes + node_start; i++) {
-               u64 end = *addr + size;
-               if (i < big)
-                       end += FAKE_NODE_MIN_SIZE;
-               /*
-                * The final node can have the remaining system RAM.  Other
-                * nodes receive roughly the same amount of available pages.
-                */
-               if (i == num_nodes + node_start - 1)
-                       end = max_addr;
-               else
-                       while (end - *addr - e820_hole_size(*addr, end) <
-                              size) {
-                               end += FAKE_NODE_MIN_SIZE;
-                               if (end > max_addr) {
-                                       end = max_addr;
-                                       break;
-                               }
-                       }
-               if (setup_node_range(i, nodes, addr, end - *addr, max_addr) < 0)
-                       break;
-       }
-       return i - node_start + 1;
-}
-
-/*
- * Splits the remaining system RAM into chunks of size.  The remaining memory is
- * always assigned to a final node and can be asymmetric.  Returns the number of
- * nodes split.
- */
-static int __init split_nodes_by_size(struct bootnode *nodes, u64 *addr,
-                                     u64 max_addr, int node_start, u64 size)
-{
-       int i = node_start;
-       size = (size << 20) & FAKE_NODE_MIN_HASH_MASK;
-       while (!setup_node_range(i++, nodes, addr, size, max_addr))
-               ;
-       return i - node_start;
-}
-
-/*
- * Sets up the system RAM area from start_pfn to end_pfn according to the
- * numa=fake command-line option.
- */
-static int __init numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
-{
-       struct bootnode nodes[MAX_NUMNODES];
-       u64 addr = start_pfn << PAGE_SHIFT;
-       u64 max_addr = end_pfn << PAGE_SHIFT;
-       int num_nodes = 0;
-       int coeff_flag;
-       int coeff = -1;
-       int num = 0;
-       u64 size;
-       int i;
-
-       memset(&nodes, 0, sizeof(nodes));
-       /*
-        * If the numa=fake command-line is just a single number N, split the
-        * system RAM into N fake nodes.
-        */
-       if (!strchr(cmdline, '*') && !strchr(cmdline, ',')) {
-               num_nodes = split_nodes_equally(nodes, &addr, max_addr, 0,
-                                               simple_strtol(cmdline, NULL, 0));
-               if (num_nodes < 0)
-                       return num_nodes;
-               goto out;
-       }
-
-       /* Parse the command line. */
-       for (coeff_flag = 0; ; cmdline++) {
-               if (*cmdline && isdigit(*cmdline)) {
-                       num = num * 10 + *cmdline - '0';
-                       continue;
-               }
-               if (*cmdline == '*') {
-                       if (num > 0)
-                               coeff = num;
-                       coeff_flag = 1;
-               }
-               if (!*cmdline || *cmdline == ',') {
-                       if (!coeff_flag)
-                               coeff = 1;
-                       /*
-                        * Round down to the nearest FAKE_NODE_MIN_SIZE.
-                        * Command-line coefficients are in megabytes.
-                        */
-                       size = ((u64)num << 20) & FAKE_NODE_MIN_HASH_MASK;
-                       if (size)
-                               for (i = 0; i < coeff; i++, num_nodes++)
-                                       if (setup_node_range(num_nodes, nodes,
-                                               &addr, size, max_addr) < 0)
-                                               goto done;
-                       if (!*cmdline)
-                               break;
-                       coeff_flag = 0;
-                       coeff = -1;
-               }
-               num = 0;
-       }
-done:
-       if (!num_nodes)
-               return -1;
-       /* Fill remainder of system RAM, if appropriate. */
-       if (addr < max_addr) {
-               if (coeff_flag && coeff < 0) {
-                       /* Split remaining nodes into num-sized chunks */
-                       num_nodes += split_nodes_by_size(nodes, &addr, max_addr,
-                                                        num_nodes, num);
-                       goto out;
-               }
-               switch (*(cmdline - 1)) {
-               case '*':
-                       /* Split remaining nodes into coeff chunks */
-                       if (coeff <= 0)
-                               break;
-                       num_nodes += split_nodes_equally(nodes, &addr, max_addr,
-                                                        num_nodes, coeff);
-                       break;
-               case ',':
-                       /* Do not allocate remaining system RAM */
-                       break;
-               default:
-                       /* Give one final node */
-                       setup_node_range(num_nodes, nodes, &addr,
-                                        max_addr - addr, max_addr);
-                       num_nodes++;
-               }
-       }
-out:
-       memnode_shift = compute_hash_shift(nodes, num_nodes);
-       if (memnode_shift < 0) {
-               memnode_shift = 0;
-               printk(KERN_ERR "No NUMA hash function found.  NUMA emulation "
-                      "disabled.\n");
-               return -1;
-       }
-
-       /*
-        * We need to vacate all active ranges that may have been registered by
-        * SRAT and set acpi_numa to -1 so that srat_disabled() always returns
-        * true.  NUMA emulation has succeeded so we will not scan ACPI nodes.
-        */
-       remove_all_active_ranges();
-#ifdef CONFIG_ACPI_NUMA
-       acpi_numa = -1;
-#endif
-       for_each_node_mask(i, node_possible_map) {
-               e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
-                                               nodes[i].end >> PAGE_SHIFT);
-               setup_node_bootmem(i, nodes[i].start, nodes[i].end);
-       }
-       acpi_fake_nodes(nodes, num_nodes);
-       numa_init_array();
-       return 0;
-}
-#endif /* CONFIG_NUMA_EMU */
-
-void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
-{ 
-       int i;
-
-       nodes_clear(node_possible_map);
-
-#ifdef CONFIG_NUMA_EMU
-       if (cmdline && !numa_emulation(start_pfn, end_pfn))
-               return;
-       nodes_clear(node_possible_map);
-#endif
-
-#ifdef CONFIG_ACPI_NUMA
-       if (!numa_off && !acpi_scan_nodes(start_pfn << PAGE_SHIFT,
-                                         end_pfn << PAGE_SHIFT))
-               return;
-       nodes_clear(node_possible_map);
-#endif
-
-#ifdef CONFIG_K8_NUMA
-       if (!numa_off && !k8_scan_nodes(start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT))
-               return;
-       nodes_clear(node_possible_map);
-#endif
-       printk(KERN_INFO "%s\n",
-              numa_off ? "NUMA turned off" : "No NUMA configuration found");
-
-       printk(KERN_INFO "Faking a node at %016lx-%016lx\n", 
-              start_pfn << PAGE_SHIFT,
-              end_pfn << PAGE_SHIFT); 
-               /* setup dummy node covering all memory */ 
-       memnode_shift = 63; 
-       memnodemap = memnode.embedded_map;
-       memnodemap[0] = 0;
-       nodes_clear(node_online_map);
-       node_set_online(0);
-       node_set(0, node_possible_map);
-       for (i = 0; i < NR_CPUS; i++)
-               numa_set_node(i, 0);
-       node_to_cpumask[0] = cpumask_of_cpu(0);
-       e820_register_active_regions(0, start_pfn, end_pfn);
-       setup_node_bootmem(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
-}
-
-__cpuinit void numa_add_cpu(int cpu)
-{
-       set_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
-} 
-
-void __cpuinit numa_set_node(int cpu, int node)
-{
-       cpu_pda(cpu)->nodenumber = node;
-       cpu_to_node[cpu] = node;
-}
-
-unsigned long __init numa_free_all_bootmem(void) 
-{ 
-       int i;
-       unsigned long pages = 0;
-       for_each_online_node(i) {
-               pages += free_all_bootmem_node(NODE_DATA(i));
-       }
-       return pages;
-} 
-
-void __init paging_init(void)
-{ 
-       int i;
-       unsigned long max_zone_pfns[MAX_NR_ZONES];
-       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
-       max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
-       max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
-       max_zone_pfns[ZONE_NORMAL] = end_pfn;
-
-       sparse_memory_present_with_active_regions(MAX_NUMNODES);
-       sparse_init();
-
-       for_each_online_node(i) {
-               setup_node_zones(i); 
-       }
-
-       free_area_init_nodes(max_zone_pfns);
-} 
-
-static __init int numa_setup(char *opt)
-{ 
-       if (!opt)
-               return -EINVAL;
-       if (!strncmp(opt,"off",3))
-               numa_off = 1;
-#ifdef CONFIG_NUMA_EMU
-       if (!strncmp(opt, "fake=", 5))
-               cmdline = opt + 5;
-#endif
-#ifdef CONFIG_ACPI_NUMA
-       if (!strncmp(opt,"noacpi",6))
-               acpi_numa = -1;
-       if (!strncmp(opt,"hotadd=", 7))
-               hotadd_percent = simple_strtoul(opt+7, NULL, 10);
-#endif
-       return 0;
-} 
-
-early_param("numa", numa_setup);
-
-/*
- * Setup early cpu_to_node.
- *
- * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
- * and apicid_to_node[] tables have valid entries for a CPU.
- * This means we skip cpu_to_node[] initialisation for NUMA
- * emulation and faking node case (when running a kernel compiled
- * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
- * is already initialized in a round robin manner at numa_init_array,
- * prior to this call, and this initialization is good enough
- * for the fake NUMA cases.
- */
-void __init init_cpu_to_node(void)
-{
-       int i;
-       for (i = 0; i < NR_CPUS; i++) {
-               u8 apicid = x86_cpu_to_apicid[i];
-               if (apicid == BAD_APICID)
-                       continue;
-               if (apicid_to_node[apicid] == NUMA_NO_NODE)
-                       continue;
-               numa_set_node(i,apicid_to_node[apicid]);
-       }
-}
-
-EXPORT_SYMBOL(cpu_to_node);
-EXPORT_SYMBOL(node_to_cpumask);
-EXPORT_SYMBOL(memnode);
-EXPORT_SYMBOL(node_data);
-
-#ifdef CONFIG_DISCONTIGMEM
-/*
- * Functions to convert PFNs from/to per node page addresses.
- * These are out of line because they are quite big.
- * They could be all tuned by pre caching more state.
- * Should do that.
- */
-
-int pfn_valid(unsigned long pfn)
-{
-       unsigned nid;
-       if (pfn >= num_physpages)
-               return 0;
-       nid = pfn_to_nid(pfn);
-       if (nid == 0xff)
-               return 0;
-       return pfn >= node_start_pfn(nid) && (pfn) < node_end_pfn(nid);
-}
-EXPORT_SYMBOL(pfn_valid);
-#endif
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
deleted file mode 100644 (file)
index 10b9809..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/* 
- * Copyright 2002 Andi Kleen, SuSE Labs. 
- * Thanks to Ben LaHaise for precious feedback.
- */ 
-
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/highmem.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <asm/uaccess.h>
-#include <asm/processor.h>
-#include <asm/tlbflush.h>
-#include <asm/io.h>
-
-pte_t *lookup_address(unsigned long address)
-{ 
-       pgd_t *pgd = pgd_offset_k(address);
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t *pte;
-       if (pgd_none(*pgd))
-               return NULL;
-       pud = pud_offset(pgd, address);
-       if (!pud_present(*pud))
-               return NULL; 
-       pmd = pmd_offset(pud, address);
-       if (!pmd_present(*pmd))
-               return NULL; 
-       if (pmd_large(*pmd))
-               return (pte_t *)pmd;
-       pte = pte_offset_kernel(pmd, address);
-       if (pte && !pte_present(*pte))
-               pte = NULL; 
-       return pte;
-} 
-
-static struct page *split_large_page(unsigned long address, pgprot_t prot,
-                                    pgprot_t ref_prot)
-{ 
-       int i; 
-       unsigned long addr;
-       struct page *base = alloc_pages(GFP_KERNEL, 0);
-       pte_t *pbase;
-       if (!base) 
-               return NULL;
-       /*
-        * page_private is used to track the number of entries in
-        * the page table page have non standard attributes.
-        */
-       SetPagePrivate(base);
-       page_private(base) = 0;
-
-       address = __pa(address);
-       addr = address & LARGE_PAGE_MASK; 
-       pbase = (pte_t *)page_address(base);
-       for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
-               pbase[i] = pfn_pte(addr >> PAGE_SHIFT, 
-                                  addr == address ? prot : ref_prot);
-       }
-       return base;
-} 
-
-static void cache_flush_page(void *adr)
-{
-       int i;
-       for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
-               asm volatile("clflush (%0)" :: "r" (adr + i));
-}
-
-static void flush_kernel_map(void *arg)
-{
-       struct list_head *l = (struct list_head *)arg;
-       struct page *pg;
-
-       /* When clflush is available always use it because it is
-          much cheaper than WBINVD. */
-       /* clflush is still broken. Disable for now. */
-       if (1 || !cpu_has_clflush)
-               asm volatile("wbinvd" ::: "memory");
-       else list_for_each_entry(pg, l, lru) {
-               void *adr = page_address(pg);
-               cache_flush_page(adr);
-       }
-       __flush_tlb_all();
-}
-
-static inline void flush_map(struct list_head *l)
-{      
-       on_each_cpu(flush_kernel_map, l, 1, 1);
-}
-
-static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */
-
-static inline void save_page(struct page *fpage)
-{
-       if (!test_and_set_bit(PG_arch_1, &fpage->flags))
-               list_add(&fpage->lru, &deferred_pages);
-}
-
-/* 
- * No more special protections in this 2/4MB area - revert to a
- * large page again. 
- */
-static void revert_page(unsigned long address, pgprot_t ref_prot)
-{
-       pgd_t *pgd;
-       pud_t *pud;
-       pmd_t *pmd;
-       pte_t large_pte;
-       unsigned long pfn;
-
-       pgd = pgd_offset_k(address);
-       BUG_ON(pgd_none(*pgd));
-       pud = pud_offset(pgd,address);
-       BUG_ON(pud_none(*pud));
-       pmd = pmd_offset(pud, address);
-       BUG_ON(pmd_val(*pmd) & _PAGE_PSE);
-       pfn = (__pa(address) & LARGE_PAGE_MASK) >> PAGE_SHIFT;
-       large_pte = pfn_pte(pfn, ref_prot);
-       large_pte = pte_mkhuge(large_pte);
-       set_pte((pte_t *)pmd, large_pte);
-}      
-
-static int
-__change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
-                                  pgprot_t ref_prot)
-{ 
-       pte_t *kpte; 
-       struct page *kpte_page;
-       pgprot_t ref_prot2;
-
-       kpte = lookup_address(address);
-       if (!kpte) return 0;
-       kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
-       BUG_ON(PageLRU(kpte_page));
-       BUG_ON(PageCompound(kpte_page));
-       if (pgprot_val(prot) != pgprot_val(ref_prot)) { 
-               if (!pte_huge(*kpte)) {
-                       set_pte(kpte, pfn_pte(pfn, prot));
-               } else {
-                       /*
-                        * split_large_page will take the reference for this
-                        * change_page_attr on the split page.
-                        */
-                       struct page *split;
-                       ref_prot2 = pte_pgprot(pte_clrhuge(*kpte));
-                       split = split_large_page(address, prot, ref_prot2);
-                       if (!split)
-                               return -ENOMEM;
-                       set_pte(kpte, mk_pte(split, ref_prot2));
-                       kpte_page = split;
-               }
-               page_private(kpte_page)++;
-       } else if (!pte_huge(*kpte)) {
-               set_pte(kpte, pfn_pte(pfn, ref_prot));
-               BUG_ON(page_private(kpte_page) == 0);
-               page_private(kpte_page)--;
-       } else
-               BUG();
-
-       /* on x86-64 the direct mapping set at boot is not using 4k pages */
-       BUG_ON(PageReserved(kpte_page));
-
-       save_page(kpte_page);
-       if (page_private(kpte_page) == 0)
-               revert_page(address, ref_prot);
-       return 0;
-} 
-
-/*
- * Change the page attributes of an page in the linear mapping.
- *
- * This should be used when a page is mapped with a different caching policy
- * than write-back somewhere - some CPUs do not like it when mappings with
- * different caching policies exist. This changes the page attributes of the
- * in kernel linear mapping too.
- * 
- * The caller needs to ensure that there are no conflicting mappings elsewhere.
- * This function only deals with the kernel linear map.
- * 
- * Caller must call global_flush_tlb() after this.
- */
-int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot)
-{
-       int err = 0, kernel_map = 0;
-       int i; 
-
-       if (address >= __START_KERNEL_map
-           && address < __START_KERNEL_map + KERNEL_TEXT_SIZE) {
-               address = (unsigned long)__va(__pa(address));
-               kernel_map = 1;
-       }
-
-       down_write(&init_mm.mmap_sem);
-       for (i = 0; i < numpages; i++, address += PAGE_SIZE) {
-               unsigned long pfn = __pa(address) >> PAGE_SHIFT;
-
-               if (!kernel_map || pte_present(pfn_pte(0, prot))) {
-                       err = __change_page_attr(address, pfn, prot, PAGE_KERNEL);
-                       if (err)
-                               break;
-               }
-               /* Handle kernel mapping too which aliases part of the
-                * lowmem */
-               if (__pa(address) < KERNEL_TEXT_SIZE) {
-                       unsigned long addr2;
-                       pgprot_t prot2;
-                       addr2 = __START_KERNEL_map + __pa(address);
-                       /* Make sure the kernel mappings stay executable */
-                       prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot)));
-                       err = __change_page_attr(addr2, pfn, prot2,
-                                                PAGE_KERNEL_EXEC);
-               } 
-       }       
-       up_write(&init_mm.mmap_sem); 
-       return err;
-}
-
-/* Don't call this for MMIO areas that may not have a mem_map entry */
-int change_page_attr(struct page *page, int numpages, pgprot_t prot)
-{
-       unsigned long addr = (unsigned long)page_address(page);
-       return change_page_attr_addr(addr, numpages, prot);
-}
-
-void global_flush_tlb(void)
-{ 
-       struct page *pg, *next;
-       struct list_head l;
-
-       down_read(&init_mm.mmap_sem);
-       list_replace_init(&deferred_pages, &l);
-       up_read(&init_mm.mmap_sem);
-
-       flush_map(&l);
-
-       list_for_each_entry_safe(pg, next, &l, lru) {
-               list_del(&pg->lru);
-               clear_bit(PG_arch_1, &pg->flags);
-               if (page_private(pg) != 0)
-                       continue;
-               ClearPagePrivate(pg);
-               __free_page(pg);
-       } 
-} 
-
-EXPORT_SYMBOL(change_page_attr);
-EXPORT_SYMBOL(global_flush_tlb);
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
deleted file mode 100644 (file)
index acdf03e..0000000
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- * ACPI 3.0 based NUMA setup
- * Copyright 2004 Andi Kleen, SuSE Labs.
- *
- * Reads the ACPI SRAT table to figure out what memory belongs to which CPUs.
- *
- * Called from acpi_numa_init while reading the SRAT and SLIT tables.
- * Assumes all memory regions belonging to a single proximity domain
- * are in one chunk. Holes between them will be included in the node.
- */
-
-#include <linux/kernel.h>
-#include <linux/acpi.h>
-#include <linux/mmzone.h>
-#include <linux/bitmap.h>
-#include <linux/module.h>
-#include <linux/topology.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <asm/proto.h>
-#include <asm/numa.h>
-#include <asm/e820.h>
-
-int acpi_numa __initdata;
-
-static struct acpi_table_slit *acpi_slit;
-
-static nodemask_t nodes_parsed __initdata;
-static struct bootnode nodes[MAX_NUMNODES] __initdata;
-static struct bootnode nodes_add[MAX_NUMNODES];
-static int found_add_area __initdata;
-int hotadd_percent __initdata = 0;
-
-/* Too small nodes confuse the VM badly. Usually they result
-   from BIOS bugs. */
-#define NODE_MIN_SIZE (4*1024*1024)
-
-static __init int setup_node(int pxm)
-{
-       return acpi_map_pxm_to_node(pxm);
-}
-
-static __init int conflicting_nodes(unsigned long start, unsigned long end)
-{
-       int i;
-       for_each_node_mask(i, nodes_parsed) {
-               struct bootnode *nd = &nodes[i];
-               if (nd->start == nd->end)
-                       continue;
-               if (nd->end > start && nd->start < end)
-                       return i;
-               if (nd->end == end && nd->start == start)
-                       return i;
-       }
-       return -1;
-}
-
-static __init void cutoff_node(int i, unsigned long start, unsigned long end)
-{
-       struct bootnode *nd = &nodes[i];
-
-       if (found_add_area)
-               return;
-
-       if (nd->start < start) {
-               nd->start = start;
-               if (nd->end < nd->start)
-                       nd->start = nd->end;
-       }
-       if (nd->end > end) {
-               nd->end = end;
-               if (nd->start > nd->end)
-                       nd->start = nd->end;
-       }
-}
-
-static __init void bad_srat(void)
-{
-       int i;
-       printk(KERN_ERR "SRAT: SRAT not used.\n");
-       acpi_numa = -1;
-       found_add_area = 0;
-       for (i = 0; i < MAX_LOCAL_APIC; i++)
-               apicid_to_node[i] = NUMA_NO_NODE;
-       for (i = 0; i < MAX_NUMNODES; i++)
-               nodes_add[i].start = nodes[i].end = 0;
-       remove_all_active_ranges();
-}
-
-static __init inline int srat_disabled(void)
-{
-       return numa_off || acpi_numa < 0;
-}
-
-/*
- * A lot of BIOS fill in 10 (= no distance) everywhere. This messes
- * up the NUMA heuristics which wants the local node to have a smaller
- * distance than the others.
- * Do some quick checks here and only use the SLIT if it passes.
- */
-static __init int slit_valid(struct acpi_table_slit *slit)
-{
-       int i, j;
-       int d = slit->locality_count;
-       for (i = 0; i < d; i++) {
-               for (j = 0; j < d; j++)  {
-                       u8 val = slit->entry[d*i + j];
-                       if (i == j) {
-                               if (val != LOCAL_DISTANCE)
-                                       return 0;
-                       } else if (val <= LOCAL_DISTANCE)
-                               return 0;
-               }
-       }
-       return 1;
-}
-
-/* Callback for SLIT parsing */
-void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
-{
-       if (!slit_valid(slit)) {
-               printk(KERN_INFO "ACPI: SLIT table looks invalid. Not used.\n");
-               return;
-       }
-       acpi_slit = slit;
-}
-
-/* Callback for Proximity Domain -> LAPIC mapping */
-void __init
-acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
-{
-       int pxm, node;
-       if (srat_disabled())
-               return;
-       if (pa->header.length != sizeof(struct acpi_srat_cpu_affinity)) {
-               bad_srat();
-               return;
-       }
-       if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
-               return;
-       pxm = pa->proximity_domain_lo;
-       node = setup_node(pxm);
-       if (node < 0) {
-               printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
-               bad_srat();
-               return;
-       }
-       apicid_to_node[pa->apic_id] = node;
-       acpi_numa = 1;
-       printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> Node %u\n",
-              pxm, pa->apic_id, node);
-}
-
-#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
-/*
- * Protect against too large hotadd areas that would fill up memory.
- */
-static int hotadd_enough_memory(struct bootnode *nd)
-{
-       static unsigned long allocated;
-       static unsigned long last_area_end;
-       unsigned long pages = (nd->end - nd->start) >> PAGE_SHIFT;
-       long mem = pages * sizeof(struct page);
-       unsigned long addr;
-       unsigned long allowed;
-       unsigned long oldpages = pages;
-
-       if (mem < 0)
-               return 0;
-       allowed = (end_pfn - absent_pages_in_range(0, end_pfn)) * PAGE_SIZE;
-       allowed = (allowed / 100) * hotadd_percent;
-       if (allocated + mem > allowed) {
-               unsigned long range;
-               /* Give them at least part of their hotadd memory upto hotadd_percent
-                  It would be better to spread the limit out
-                  over multiple hotplug areas, but that is too complicated
-                  right now */
-               if (allocated >= allowed)
-                       return 0;
-               range = allowed - allocated;
-               pages = (range / PAGE_SIZE);
-               mem = pages * sizeof(struct page);
-               nd->end = nd->start + range;
-       }
-       /* Not completely fool proof, but a good sanity check */
-       addr = find_e820_area(last_area_end, end_pfn<<PAGE_SHIFT, mem);
-       if (addr == -1UL)
-               return 0;
-       if (pages != oldpages)
-               printk(KERN_NOTICE "SRAT: Hotadd area limited to %lu bytes\n",
-                       pages << PAGE_SHIFT);
-       last_area_end = addr + mem;
-       allocated += mem;
-       return 1;
-}
-
-static int update_end_of_memory(unsigned long end)
-{
-       found_add_area = 1;
-       if ((end >> PAGE_SHIFT) > end_pfn)
-               end_pfn = end >> PAGE_SHIFT;
-       return 1;
-}
-
-static inline int save_add_info(void)
-{
-       return hotadd_percent > 0;
-}
-#else
-int update_end_of_memory(unsigned long end) {return -1;}
-static int hotadd_enough_memory(struct bootnode *nd) {return 1;}
-#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
-static inline int save_add_info(void) {return 1;}
-#else
-static inline int save_add_info(void) {return 0;}
-#endif
-#endif
-/*
- * Update nodes_add and decide if to include add are in the zone.
- * Both SPARSE and RESERVE need nodes_add infomation.
- * This code supports one contigious hot add area per node.
- */
-static int reserve_hotadd(int node, unsigned long start, unsigned long end)
-{
-       unsigned long s_pfn = start >> PAGE_SHIFT;
-       unsigned long e_pfn = end >> PAGE_SHIFT;
-       int ret = 0, changed = 0;
-       struct bootnode *nd = &nodes_add[node];
-
-       /* I had some trouble with strange memory hotadd regions breaking
-          the boot. Be very strict here and reject anything unexpected.
-          If you want working memory hotadd write correct SRATs.
-
-          The node size check is a basic sanity check to guard against
-          mistakes */
-       if ((signed long)(end - start) < NODE_MIN_SIZE) {
-               printk(KERN_ERR "SRAT: Hotplug area too small\n");
-               return -1;
-       }
-
-       /* This check might be a bit too strict, but I'm keeping it for now. */
-       if (absent_pages_in_range(s_pfn, e_pfn) != e_pfn - s_pfn) {
-               printk(KERN_ERR
-                       "SRAT: Hotplug area %lu -> %lu has existing memory\n",
-                       s_pfn, e_pfn);
-               return -1;
-       }
-
-       if (!hotadd_enough_memory(&nodes_add[node]))  {
-               printk(KERN_ERR "SRAT: Hotplug area too large\n");
-               return -1;
-       }
-
-       /* Looks good */
-
-       if (nd->start == nd->end) {
-               nd->start = start;
-               nd->end = end;
-               changed = 1;
-       } else {
-               if (nd->start == end) {
-                       nd->start = start;
-                       changed = 1;
-               }
-               if (nd->end == start) {
-                       nd->end = end;
-                       changed = 1;
-               }
-               if (!changed)
-                       printk(KERN_ERR "SRAT: Hotplug zone not continuous. Partly ignored\n");
-       }
-
-       ret = update_end_of_memory(nd->end);
-
-       if (changed)
-               printk(KERN_INFO "SRAT: hot plug zone found %Lx - %Lx\n", nd->start, nd->end);
-       return ret;
-}
-
-/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
-void __init
-acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
-{
-       struct bootnode *nd, oldnode;
-       unsigned long start, end;
-       int node, pxm;
-       int i;
-
-       if (srat_disabled())
-               return;
-       if (ma->header.length != sizeof(struct acpi_srat_mem_affinity)) {
-               bad_srat();
-               return;
-       }
-       if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
-               return;
-
-       if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info())
-               return;
-       start = ma->base_address;
-       end = start + ma->length;
-       pxm = ma->proximity_domain;
-       node = setup_node(pxm);
-       if (node < 0) {
-               printk(KERN_ERR "SRAT: Too many proximity domains.\n");
-               bad_srat();
-               return;
-       }
-       i = conflicting_nodes(start, end);
-       if (i == node) {
-               printk(KERN_WARNING
-               "SRAT: Warning: PXM %d (%lx-%lx) overlaps with itself (%Lx-%Lx)\n",
-                       pxm, start, end, nodes[i].start, nodes[i].end);
-       } else if (i >= 0) {
-               printk(KERN_ERR
-                      "SRAT: PXM %d (%lx-%lx) overlaps with PXM %d (%Lx-%Lx)\n",
-                      pxm, start, end, node_to_pxm(i),
-                       nodes[i].start, nodes[i].end);
-               bad_srat();
-               return;
-       }
-       nd = &nodes[node];
-       oldnode = *nd;
-       if (!node_test_and_set(node, nodes_parsed)) {
-               nd->start = start;
-               nd->end = end;
-       } else {
-               if (start < nd->start)
-                       nd->start = start;
-               if (nd->end < end)
-                       nd->end = end;
-       }
-
-       printk(KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n", node, pxm,
-              nd->start, nd->end);
-       e820_register_active_regions(node, nd->start >> PAGE_SHIFT,
-                                               nd->end >> PAGE_SHIFT);
-       push_node_boundaries(node, nd->start >> PAGE_SHIFT,
-                                               nd->end >> PAGE_SHIFT);
-
-       if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) &&
-           (reserve_hotadd(node, start, end) < 0)) {
-               /* Ignore hotadd region. Undo damage */
-               printk(KERN_NOTICE "SRAT: Hotplug region ignored\n");
-               *nd = oldnode;
-               if ((nd->start | nd->end) == 0)
-                       node_clear(node, nodes_parsed);
-       }
-}
-
-/* Sanity check to catch more bad SRATs (they are amazingly common).
-   Make sure the PXMs cover all memory. */
-static int __init nodes_cover_memory(const struct bootnode *nodes)
-{
-       int i;
-       unsigned long pxmram, e820ram;
-
-       pxmram = 0;
-       for_each_node_mask(i, nodes_parsed) {
-               unsigned long s = nodes[i].start >> PAGE_SHIFT;
-               unsigned long e = nodes[i].end >> PAGE_SHIFT;
-               pxmram += e - s;
-               pxmram -= absent_pages_in_range(s, e);
-               if ((long)pxmram < 0)
-                       pxmram = 0;
-       }
-
-       e820ram = end_pfn - absent_pages_in_range(0, end_pfn);
-       /* We seem to lose 3 pages somewhere. Allow a bit of slack. */
-       if ((long)(e820ram - pxmram) >= 1*1024*1024) {
-               printk(KERN_ERR
-       "SRAT: PXMs only cover %luMB of your %luMB e820 RAM. Not used.\n",
-                       (pxmram << PAGE_SHIFT) >> 20,
-                       (e820ram << PAGE_SHIFT) >> 20);
-               return 0;
-       }
-       return 1;
-}
-
-static void unparse_node(int node)
-{
-       int i;
-       node_clear(node, nodes_parsed);
-       for (i = 0; i < MAX_LOCAL_APIC; i++) {
-               if (apicid_to_node[i] == node)
-                       apicid_to_node[i] = NUMA_NO_NODE;
-       }
-}
-
-void __init acpi_numa_arch_fixup(void) {}
-
-/* Use the information discovered above to actually set up the nodes. */
-int __init acpi_scan_nodes(unsigned long start, unsigned long end)
-{
-       int i;
-
-       if (acpi_numa <= 0)
-               return -1;
-
-       /* First clean up the node list */
-       for (i = 0; i < MAX_NUMNODES; i++) {
-               cutoff_node(i, start, end);
-               if ((nodes[i].end - nodes[i].start) < NODE_MIN_SIZE) {
-                       unparse_node(i);
-                       node_set_offline(i);
-               }
-       }
-
-       if (!nodes_cover_memory(nodes)) {
-               bad_srat();
-               return -1;
-       }
-
-       memnode_shift = compute_hash_shift(nodes, MAX_NUMNODES);
-       if (memnode_shift < 0) {
-               printk(KERN_ERR
-                    "SRAT: No NUMA node hash function found. Contact maintainer\n");
-               bad_srat();
-               return -1;
-       }
-
-       node_possible_map = nodes_parsed;
-
-       /* Finally register nodes */
-       for_each_node_mask(i, node_possible_map)
-               setup_node_bootmem(i, nodes[i].start, nodes[i].end);
-       /* Try again in case setup_node_bootmem missed one due
-          to missing bootmem */
-       for_each_node_mask(i, node_possible_map)
-               if (!node_online(i))
-                       setup_node_bootmem(i, nodes[i].start, nodes[i].end);
-
-       for (i = 0; i < NR_CPUS; i++) {
-               if (cpu_to_node[i] == NUMA_NO_NODE)
-                       continue;
-               if (!node_isset(cpu_to_node[i], node_possible_map))
-                       numa_set_node(i, NUMA_NO_NODE);
-       }
-       numa_init_array();
-       return 0;
-}
-
-#ifdef CONFIG_NUMA_EMU
-static int __init find_node_by_addr(unsigned long addr)
-{
-       int ret = NUMA_NO_NODE;
-       int i;
-
-       for_each_node_mask(i, nodes_parsed) {
-               /*
-                * Find the real node that this emulated node appears on.  For
-                * the sake of simplicity, we only use a real node's starting
-                * address to determine which emulated node it appears on.
-                */
-               if (addr >= nodes[i].start && addr < nodes[i].end) {
-                       ret = i;
-                       break;
-               }
-       }
-       return i;
-}
-
-/*
- * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID
- * mappings that respect the real ACPI topology but reflect our emulated
- * environment.  For each emulated node, we find which real node it appears on
- * and create PXM to NID mappings for those fake nodes which mirror that
- * locality.  SLIT will now represent the correct distances between emulated
- * nodes as a result of the real topology.
- */
-void __init acpi_fake_nodes(const struct bootnode *fake_nodes, int num_nodes)
-{
-       int i, j;
-       int fake_node_to_pxm_map[MAX_NUMNODES] = {
-               [0 ... MAX_NUMNODES-1] = PXM_INVAL
-       };
-       unsigned char fake_apicid_to_node[MAX_LOCAL_APIC] = {
-               [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
-       };
-
-       printk(KERN_INFO "Faking PXM affinity for fake nodes on real "
-                        "topology.\n");
-       for (i = 0; i < num_nodes; i++) {
-               int nid, pxm;
-
-               nid = find_node_by_addr(fake_nodes[i].start);
-               if (nid == NUMA_NO_NODE)
-                       continue;
-               pxm = node_to_pxm(nid);
-               if (pxm == PXM_INVAL)
-                       continue;
-               fake_node_to_pxm_map[i] = pxm;
-               /*
-                * For each apicid_to_node mapping that exists for this real
-                * node, it must now point to the fake node ID.
-                */
-               for (j = 0; j < MAX_LOCAL_APIC; j++)
-                       if (apicid_to_node[j] == nid)
-                               fake_apicid_to_node[j] = i;
-       }
-       for (i = 0; i < num_nodes; i++)
-               __acpi_map_pxm_to_node(fake_node_to_pxm_map[i], i);
-       memcpy(apicid_to_node, fake_apicid_to_node, sizeof(apicid_to_node));
-
-       nodes_clear(nodes_parsed);
-       for (i = 0; i < num_nodes; i++)
-               if (fake_nodes[i].start != fake_nodes[i].end)
-                       node_set(i, nodes_parsed);
-       WARN_ON(!nodes_cover_memory(fake_nodes));
-}
-
-static int null_slit_node_compare(int a, int b)
-{
-       return node_to_pxm(a) == node_to_pxm(b);
-}
-#else
-static int null_slit_node_compare(int a, int b)
-{
-       return a == b;
-}
-#endif /* CONFIG_NUMA_EMU */
-
-void __init srat_reserve_add_area(int nodeid)
-{
-       if (found_add_area && nodes_add[nodeid].end) {
-               u64 total_mb;
-
-               printk(KERN_INFO "SRAT: Reserving hot-add memory space "
-                               "for node %d at %Lx-%Lx\n",
-                       nodeid, nodes_add[nodeid].start, nodes_add[nodeid].end);
-               total_mb = (nodes_add[nodeid].end - nodes_add[nodeid].start)
-                                       >> PAGE_SHIFT;
-               total_mb *= sizeof(struct page);
-               total_mb >>= 20;
-               printk(KERN_INFO "SRAT: This will cost you %Lu MB of "
-                               "pre-allocated memory.\n", (unsigned long long)total_mb);
-               reserve_bootmem_node(NODE_DATA(nodeid), nodes_add[nodeid].start,
-                              nodes_add[nodeid].end - nodes_add[nodeid].start);
-       }
-}
-
-int __node_distance(int a, int b)
-{
-       int index;
-
-       if (!acpi_slit)
-               return null_slit_node_compare(a, b) ? LOCAL_DISTANCE :
-                                                     REMOTE_DISTANCE;
-       index = acpi_slit->locality_count * node_to_pxm(a);
-       return acpi_slit->entry[index + node_to_pxm(b)];
-}
-
-EXPORT_SYMBOL(__node_distance);
-
-int memory_add_physaddr_to_nid(u64 start)
-{
-       int i, ret = 0;
-
-       for_each_node(i)
-               if (nodes_add[i].start <= start && nodes_add[i].end > start)
-                       ret = i;
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
-
diff --git a/arch/x86_64/oprofile/Kconfig b/arch/x86_64/oprofile/Kconfig
deleted file mode 100644 (file)
index d8a8408..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-config PROFILING
-       bool "Profiling support (EXPERIMENTAL)"
-       help
-         Say Y here to enable the extended profiling support mechanisms used
-         by profilers such as OProfile.
-         
-
-config OPROFILE
-       tristate "OProfile system profiling (EXPERIMENTAL)"
-       depends on PROFILING
-       help
-         OProfile is a profiling system capable of profiling the
-         whole system, include the kernel, kernel modules, libraries,
-         and applications.
-
-         If unsure, say N.
-
diff --git a/arch/x86_64/oprofile/Makefile b/arch/x86_64/oprofile/Makefile
deleted file mode 100644 (file)
index 6be3268..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# oprofile for x86-64.
-# Just reuse the one from i386. 
-#
-
-obj-$(CONFIG_OPROFILE) += oprofile.o
-DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
-       oprof.o cpu_buffer.o buffer_sync.o \
-       event_buffer.o oprofile_files.o \
-       oprofilefs.o oprofile_stats.o \
-       timer_int.o )
-
-OPROFILE-y := init.o backtrace.o
-OPROFILE-$(CONFIG_X86_LOCAL_APIC) += nmi_int.o op_model_athlon.o op_model_p4.o \
-                                    op_model_ppro.o
-OPROFILE-$(CONFIG_X86_IO_APIC)    += nmi_timer_int.o 
-
-oprofile-y = $(DRIVER_OBJS) $(addprefix ../../i386/oprofile/, $(OPROFILE-y))
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile
deleted file mode 100644 (file)
index c9eddc8..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Makefile for X86_64 specific PCI routines
-#
-# Reuse the i386 PCI subsystem
-#
-EXTRA_CFLAGS += -Iarch/i386/pci
-
-obj-y          := i386.o
-obj-$(CONFIG_PCI_DIRECT)+= direct.o
-obj-y          += fixup.o init.o
-obj-$(CONFIG_ACPI)     += acpi.o
-obj-y                  += legacy.o irq.o common.o early.o
-# mmconfig has a 64bit special
-obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o mmconfig-shared.o
-
-obj-$(CONFIG_NUMA)     += k8-bus.o
-
-direct-y += ../../i386/pci/direct.o
-acpi-y   += ../../i386/pci/acpi.o
-legacy-y += ../../i386/pci/legacy.o
-irq-y    += ../../i386/pci/irq.o
-common-y += ../../i386/pci/common.o
-fixup-y  += ../../i386/pci/fixup.o
-i386-y  += ../../i386/pci/i386.o
-init-y += ../../i386/pci/init.o
-early-y += ../../i386/pci/early.o
-mmconfig-shared-y += ../../i386/pci/mmconfig-shared.o
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c
deleted file mode 100644 (file)
index 9cc813e..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <asm/mpspec.h>
-#include <linux/cpumask.h>
-
-/*
- * This discovers the pcibus <-> node mapping on AMD K8.
- *
- * RED-PEN need to call this again on PCI hotplug
- * RED-PEN empty cpus get reported wrong
- */
-
-#define NODE_ID_REGISTER 0x60
-#define NODE_ID(dword) (dword & 0x07)
-#define LDT_BUS_NUMBER_REGISTER_0 0x94
-#define LDT_BUS_NUMBER_REGISTER_1 0xB4
-#define LDT_BUS_NUMBER_REGISTER_2 0xD4
-#define NR_LDT_BUS_NUMBER_REGISTERS 3
-#define SECONDARY_LDT_BUS_NUMBER(dword) ((dword >> 8) & 0xFF)
-#define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF)
-#define PCI_DEVICE_ID_K8HTCONFIG 0x1100
-
-/**
- * fill_mp_bus_to_cpumask()
- * fills the mp_bus_to_cpumask array based according to the LDT Bus Number
- * Registers found in the K8 northbridge
- */
-__init static int
-fill_mp_bus_to_cpumask(void)
-{
-       struct pci_dev *nb_dev = NULL;
-       int i, j;
-       u32 ldtbus, nid;
-       static int lbnr[3] = {
-               LDT_BUS_NUMBER_REGISTER_0,
-               LDT_BUS_NUMBER_REGISTER_1,
-               LDT_BUS_NUMBER_REGISTER_2
-       };
-
-       while ((nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
-                       PCI_DEVICE_ID_K8HTCONFIG, nb_dev))) {
-               pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid);
-
-               for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) {
-                       pci_read_config_dword(nb_dev, lbnr[i], &ldtbus);
-                       /*
-                        * if there are no busses hanging off of the current
-                        * ldt link then both the secondary and subordinate
-                        * bus number fields are set to 0.
-                        * 
-                        * RED-PEN
-                        * This is slightly broken because it assumes
-                        * HT node IDs == Linux node ids, which is not always
-                        * true. However it is probably mostly true.
-                        */
-                       if (!(SECONDARY_LDT_BUS_NUMBER(ldtbus) == 0
-                               && SUBORDINATE_LDT_BUS_NUMBER(ldtbus) == 0)) {
-                               for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
-                                    j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
-                                    j++) { 
-                                       struct pci_bus *bus;
-                                       struct pci_sysdata *sd;
-
-                                       long node = NODE_ID(nid);
-                                       /* Algorithm a bit dumb, but
-                                          it shouldn't matter here */
-                                       bus = pci_find_bus(0, j);
-                                       if (!bus)
-                                               continue;
-                                       if (!node_online(node))
-                                               node = 0;
-
-                                       sd = bus->sysdata;
-                                       sd->node = node;
-                               }               
-                       }
-               }
-       }
-
-       return 0;
-}
-
-fs_initcall(fill_mp_bus_to_cpumask);
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
deleted file mode 100644 (file)
index 4095e4d..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * mmconfig.c - Low-level direct PCI config space access via MMCONFIG
- *
- * This is an 64bit optimized version that always keeps the full mmconfig
- * space mapped. This allows lockless config space operation.
- */
-
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/acpi.h>
-#include <linux/bitmap.h>
-#include <asm/e820.h>
-
-#include "pci.h"
-
-/* Static virtual mapping of the MMCONFIG aperture */
-struct mmcfg_virt {
-       struct acpi_mcfg_allocation *cfg;
-       char __iomem *virt;
-};
-static struct mmcfg_virt *pci_mmcfg_virt;
-
-static char __iomem *get_virt(unsigned int seg, unsigned bus)
-{
-       struct acpi_mcfg_allocation *cfg;
-       int cfg_num;
-
-       for (cfg_num = 0; cfg_num < pci_mmcfg_config_num; cfg_num++) {
-               cfg = pci_mmcfg_virt[cfg_num].cfg;
-               if (cfg->pci_segment == seg &&
-                   (cfg->start_bus_number <= bus) &&
-                   (cfg->end_bus_number >= bus))
-                       return pci_mmcfg_virt[cfg_num].virt;
-       }
-
-       /* Fall back to type 0 */
-       return NULL;
-}
-
-static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
-{
-       char __iomem *addr;
-       if (seg == 0 && bus < PCI_MMCFG_MAX_CHECK_BUS &&
-               test_bit(32*bus + PCI_SLOT(devfn), pci_mmcfg_fallback_slots))
-               return NULL;
-       addr = get_virt(seg, bus);
-       if (!addr)
-               return NULL;
-       return addr + ((bus << 20) | (devfn << 12));
-}
-
-static int pci_mmcfg_read(unsigned int seg, unsigned int bus,
-                         unsigned int devfn, int reg, int len, u32 *value)
-{
-       char __iomem *addr;
-
-       /* Why do we have this when nobody checks it. How about a BUG()!? -AK */
-       if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
-               *value = -1;
-               return -EINVAL;
-       }
-
-       addr = pci_dev_base(seg, bus, devfn);
-       if (!addr)
-               return pci_conf1_read(seg,bus,devfn,reg,len,value);
-
-       switch (len) {
-       case 1:
-               *value = mmio_config_readb(addr + reg);
-               break;
-       case 2:
-               *value = mmio_config_readw(addr + reg);
-               break;
-       case 4:
-               *value = mmio_config_readl(addr + reg);
-               break;
-       }
-
-       return 0;
-}
-
-static int pci_mmcfg_write(unsigned int seg, unsigned int bus,
-                          unsigned int devfn, int reg, int len, u32 value)
-{
-       char __iomem *addr;
-
-       /* Why do we have this when nobody checks it. How about a BUG()!? -AK */
-       if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
-               return -EINVAL;
-
-       addr = pci_dev_base(seg, bus, devfn);
-       if (!addr)
-               return pci_conf1_write(seg,bus,devfn,reg,len,value);
-
-       switch (len) {
-       case 1:
-               mmio_config_writeb(addr + reg, value);
-               break;
-       case 2:
-               mmio_config_writew(addr + reg, value);
-               break;
-       case 4:
-               mmio_config_writel(addr + reg, value);
-               break;
-       }
-
-       return 0;
-}
-
-static struct pci_raw_ops pci_mmcfg = {
-       .read =         pci_mmcfg_read,
-       .write =        pci_mmcfg_write,
-};
-
-static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg)
-{
-       void __iomem *addr;
-       u32 size;
-
-       size = (cfg->end_bus_number + 1) << 20;
-       addr = ioremap_nocache(cfg->address, size);
-       if (addr) {
-               printk(KERN_INFO "PCI: Using MMCONFIG at %Lx - %Lx\n",
-                      cfg->address, cfg->address + size - 1);
-       }
-       return addr;
-}
-
-int __init pci_mmcfg_arch_reachable(unsigned int seg, unsigned int bus,
-                                   unsigned int devfn)
-{
-       return pci_dev_base(seg, bus, devfn) != NULL;
-}
-
-int __init pci_mmcfg_arch_init(void)
-{
-       int i;
-       pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) *
-                                pci_mmcfg_config_num, GFP_KERNEL);
-       if (pci_mmcfg_virt == NULL) {
-               printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n");
-               return 0;
-       }
-
-       for (i = 0; i < pci_mmcfg_config_num; ++i) {
-               pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
-               pci_mmcfg_virt[i].virt = mcfg_ioremap(&pci_mmcfg_config[i]);
-               if (!pci_mmcfg_virt[i].virt) {
-                       printk(KERN_ERR "PCI: Cannot map mmconfig aperture for "
-                                       "segment %d\n",
-                               pci_mmcfg_config[i].pci_segment);
-                       return 0;
-               }
-       }
-       raw_pci_ops = &pci_mmcfg;
-       return 1;
-}
diff --git a/arch/x86_64/vdso/.gitignore b/arch/x86_64/vdso/.gitignore
deleted file mode 100644 (file)
index f8b69d8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-vdso.lds
diff --git a/arch/x86_64/vdso/Makefile b/arch/x86_64/vdso/Makefile
deleted file mode 100644 (file)
index 8d03de0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# x86-64 vDSO.
-#
-
-# files to link into the vdso
-# vdso-start.o has to be first
-vobjs-y := vdso-start.o vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
-
-# files to link into kernel
-obj-y := vma.o vdso.o vdso-syms.o
-
-vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
-
-$(obj)/vdso.o: $(obj)/vdso.so
-
-targets += vdso.so vdso.lds $(vobjs-y) vdso-syms.o
-
-# The DSO images are built using a special linker script.
-quiet_cmd_syscall = SYSCALL $@
-      cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \
-                         -Wl,-T,$(filter-out FORCE,$^) -o $@
-
-export CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
-
-vdso-flags = -fPIC -shared -Wl,-soname=linux-vdso.so.1 \
-                $(call ld-option, -Wl$(comma)--hash-style=sysv) \
-               -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
-SYSCFLAGS_vdso.so = $(vdso-flags)
-
-$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
-
-$(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE
-       $(call if_changed,syscall)
-
-CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
-
-$(obj)/vclock_gettime.o: CFLAGS = $(CFL)
-$(obj)/vgetcpu.o: CFLAGS = $(CFL)
-
-# We also create a special relocatable object that should mirror the symbol
-# table and layout of the linked DSO.  With ld -R we can then refer to
-# these symbols in the kernel code rather than hand-coded addresses.
-extra-y += vdso-syms.o
-$(obj)/built-in.o: $(obj)/vdso-syms.o
-$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
-
-SYSCFLAGS_vdso-syms.o = -r -d
-$(obj)/vdso-syms.o: $(src)/vdso.lds $(vobjs) FORCE
-       $(call if_changed,syscall)
diff --git a/arch/x86_64/vdso/vclock_gettime.c b/arch/x86_64/vdso/vclock_gettime.c
deleted file mode 100644 (file)
index 5b54cdf..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2006 Andi Kleen, SUSE Labs.
- * Subject to the GNU Public License, v.2
- *
- * Fast user context implementation of clock_gettime and gettimeofday.
- *
- * The code should have no internal unresolved relocations.
- * Check with readelf after changing.
- * Also alternative() doesn't work.
- */
-
-#include <linux/kernel.h>
-#include <linux/posix-timers.h>
-#include <linux/time.h>
-#include <linux/string.h>
-#include <asm/vsyscall.h>
-#include <asm/vgtod.h>
-#include <asm/timex.h>
-#include <asm/hpet.h>
-#include <asm/unistd.h>
-#include <asm/io.h>
-#include <asm/vgtod.h>
-#include "vextern.h"
-
-#define gtod vdso_vsyscall_gtod_data
-
-static long vdso_fallback_gettime(long clock, struct timespec *ts)
-{
-       long ret;
-       asm("syscall" : "=a" (ret) :
-           "0" (__NR_clock_gettime),"D" (clock), "S" (ts) : "memory");
-       return ret;
-}
-
-static inline long vgetns(void)
-{
-       long v;
-       cycles_t (*vread)(void);
-       vread = gtod->clock.vread;
-       v = (vread() - gtod->clock.cycle_last) & gtod->clock.mask;
-       return (v * gtod->clock.mult) >> gtod->clock.shift;
-}
-
-static noinline int do_realtime(struct timespec *ts)
-{
-       unsigned long seq, ns;
-       do {
-               seq = read_seqbegin(&gtod->lock);
-               ts->tv_sec = gtod->wall_time_sec;
-               ts->tv_nsec = gtod->wall_time_nsec;
-               ns = vgetns();
-       } while (unlikely(read_seqretry(&gtod->lock, seq)));
-       timespec_add_ns(ts, ns);
-       return 0;
-}
-
-/* Copy of the version in kernel/time.c which we cannot directly access */
-static void vset_normalized_timespec(struct timespec *ts, long sec, long nsec)
-{
-       while (nsec >= NSEC_PER_SEC) {
-               nsec -= NSEC_PER_SEC;
-               ++sec;
-       }
-       while (nsec < 0) {
-               nsec += NSEC_PER_SEC;
-               --sec;
-       }
-       ts->tv_sec = sec;
-       ts->tv_nsec = nsec;
-}
-
-static noinline int do_monotonic(struct timespec *ts)
-{
-       unsigned long seq, ns, secs;
-       do {
-               seq = read_seqbegin(&gtod->lock);
-               secs = gtod->wall_time_sec;
-               ns = gtod->wall_time_nsec + vgetns();
-               secs += gtod->wall_to_monotonic.tv_sec;
-               ns += gtod->wall_to_monotonic.tv_nsec;
-       } while (unlikely(read_seqretry(&gtod->lock, seq)));
-       vset_normalized_timespec(ts, secs, ns);
-       return 0;
-}
-
-int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
-{
-       if (likely(gtod->sysctl_enabled && gtod->clock.vread))
-               switch (clock) {
-               case CLOCK_REALTIME:
-                       return do_realtime(ts);
-               case CLOCK_MONOTONIC:
-                       return do_monotonic(ts);
-               }
-       return vdso_fallback_gettime(clock, ts);
-}
-int clock_gettime(clockid_t, struct timespec *)
-       __attribute__((weak, alias("__vdso_clock_gettime")));
-
-int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-       long ret;
-       if (likely(gtod->sysctl_enabled && gtod->clock.vread)) {
-               BUILD_BUG_ON(offsetof(struct timeval, tv_usec) !=
-                            offsetof(struct timespec, tv_nsec) ||
-                            sizeof(*tv) != sizeof(struct timespec));
-               do_realtime((struct timespec *)tv);
-               tv->tv_usec /= 1000;
-               if (unlikely(tz != NULL)) {
-                       /* This relies on gcc inlining the memcpy. We'll notice
-                          if it ever fails to do so. */
-                       memcpy(tz, &gtod->sys_tz, sizeof(struct timezone));
-               }
-               return 0;
-       }
-       asm("syscall" : "=a" (ret) :
-           "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
-       return ret;
-}
-int gettimeofday(struct timeval *, struct timezone *)
-       __attribute__((weak, alias("__vdso_gettimeofday")));
diff --git a/arch/x86_64/vdso/vdso-note.S b/arch/x86_64/vdso/vdso-note.S
deleted file mode 100644 (file)
index 79a071e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
- * Here we can supply some information useful to userland.
- */
-
-#include <linux/uts.h>
-#include <linux/version.h>
-#include <linux/elfnote.h>
-
-ELFNOTE_START(Linux, 0, "a")
-       .long LINUX_VERSION_CODE
-ELFNOTE_END
diff --git a/arch/x86_64/vdso/vdso-start.S b/arch/x86_64/vdso/vdso-start.S
deleted file mode 100644 (file)
index 2dc2cdb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-       .globl vdso_kernel_start
-vdso_kernel_start:
diff --git a/arch/x86_64/vdso/vdso.S b/arch/x86_64/vdso/vdso.S
deleted file mode 100644 (file)
index 92e80c1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-       .section ".vdso","a"
-       .incbin "arch/x86_64/vdso/vdso.so"
diff --git a/arch/x86_64/vdso/vdso.lds.S b/arch/x86_64/vdso/vdso.lds.S
deleted file mode 100644 (file)
index b9a60e6..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Linker script for vsyscall DSO.  The vsyscall page is an ELF shared
- * object prelinked to its virtual address, and with only one read-only
- * segment (that fits in one page).  This script controls its layout.
- */
-#include <asm/asm-offsets.h>
-#include "voffset.h"
-
-#define VDSO_PRELINK 0xffffffffff700000
-
-SECTIONS
-{
-  . = VDSO_PRELINK + SIZEOF_HEADERS;
-
-  .hash           : { *(.hash) }               :text
-  .gnu.hash       : { *(.gnu.hash) }
-  .dynsym         : { *(.dynsym) }
-  .dynstr         : { *(.dynstr) }
-  .gnu.version    : { *(.gnu.version) }
-  .gnu.version_d  : { *(.gnu.version_d) }
-  .gnu.version_r  : { *(.gnu.version_r) }
-
-  /* This linker script is used both with -r and with -shared.
-     For the layouts to match, we need to skip more than enough
-     space for the dynamic symbol table et al.  If this amount
-     is insufficient, ld -shared will barf.  Just increase it here.  */
-  . = VDSO_PRELINK + VDSO_TEXT_OFFSET;
-
-  .text           : { *(.text) }               :text
-  .text.ptr       : { *(.text.ptr) }           :text
-  . = VDSO_PRELINK + 0x900;
-  .data           : { *(.data) }               :text
-  .bss            : { *(.bss) }                        :text
-
-  .altinstructions : { *(.altinstructions) }                   :text
-  .altinstr_replacement  : { *(.altinstr_replacement) }        :text
-
-  .note                  : { *(.note.*) }              :text :note
-  .eh_frame_hdr   : { *(.eh_frame_hdr) }       :text :eh_frame_hdr
-  .eh_frame       : { KEEP (*(.eh_frame)) }    :text
-  .dynamic        : { *(.dynamic) }            :text :dynamic
-  .useless        : {
-       *(.got.plt) *(.got)
-       *(.gnu.linkonce.d.*)
-       *(.dynbss)
-       *(.gnu.linkonce.b.*)
-  }                                            :text
-}
-
-/*
- * We must supply the ELF program headers explicitly to get just one
- * PT_LOAD segment, and set the flags explicitly to make segments read-only.
- */
-PHDRS
-{
-  text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
-  dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
-  note PT_NOTE FLAGS(4); /* PF_R */
-  eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
-}
-
-/*
- * This controls what symbols we export from the DSO.
- */
-VERSION
-{
-  LINUX_2.6 {
-    global:
-       clock_gettime;
-       __vdso_clock_gettime;
-       gettimeofday;
-       __vdso_gettimeofday;
-       getcpu;
-       __vdso_getcpu;
-    local: *;
-  };
-}
diff --git a/arch/x86_64/vdso/vextern.h b/arch/x86_64/vdso/vextern.h
deleted file mode 100644 (file)
index 1683ba2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef VEXTERN
-#include <asm/vsyscall.h>
-#define VEXTERN(x) \
-       extern typeof(x) *vdso_ ## x __attribute__((visibility("hidden")));
-#endif
-
-#define VMAGIC 0xfeedbabeabcdefabUL
-
-/* Any kernel variables used in the vDSO must be exported in the main
-   kernel's vmlinux.lds.S/vsyscall.h/proper __section and
-   put into vextern.h and be referenced as a pointer with vdso prefix.
-   The main kernel later fills in the values.   */
-
-VEXTERN(jiffies)
-VEXTERN(vgetcpu_mode)
-VEXTERN(vsyscall_gtod_data)
diff --git a/arch/x86_64/vdso/vgetcpu.c b/arch/x86_64/vdso/vgetcpu.c
deleted file mode 100644 (file)
index 91f6e85..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2006 Andi Kleen, SUSE Labs.
- * Subject to the GNU Public License, v.2
- *
- * Fast user context implementation of getcpu()
- */
-
-#include <linux/kernel.h>
-#include <linux/getcpu.h>
-#include <linux/jiffies.h>
-#include <linux/time.h>
-#include <asm/vsyscall.h>
-#include <asm/vgtod.h>
-#include "vextern.h"
-
-long __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
-{
-       unsigned int dummy, p;
-       unsigned long j = 0;
-
-       /* Fast cache - only recompute value once per jiffies and avoid
-          relatively costly rdtscp/cpuid otherwise.
-          This works because the scheduler usually keeps the process
-          on the same CPU and this syscall doesn't guarantee its
-          results anyways.
-          We do this here because otherwise user space would do it on
-          its own in a likely inferior way (no access to jiffies).
-          If you don't like it pass NULL. */
-       if (tcache && tcache->blob[0] == (j = *vdso_jiffies)) {
-               p = tcache->blob[1];
-       } else if (*vdso_vgetcpu_mode == VGETCPU_RDTSCP) {
-               /* Load per CPU data from RDTSCP */
-               rdtscp(dummy, dummy, p);
-       } else {
-               /* Load per CPU data from GDT */
-               asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
-       }
-       if (tcache) {
-               tcache->blob[0] = j;
-               tcache->blob[1] = p;
-       }
-       if (cpu)
-               *cpu = p & 0xfff;
-       if (node)
-               *node = p >> 12;
-       return 0;
-}
-
-long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
-       __attribute__((weak, alias("__vdso_getcpu")));
diff --git a/arch/x86_64/vdso/vma.c b/arch/x86_64/vdso/vma.c
deleted file mode 100644 (file)
index ff9333e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Set up the VMAs to tell the VM about the vDSO.
- * Copyright 2007 Andi Kleen, SUSE Labs.
- * Subject to the GPL, v.2
- */
-#include <linux/mm.h>
-#include <linux/err.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/random.h>
-#include <asm/vsyscall.h>
-#include <asm/vgtod.h>
-#include <asm/proto.h>
-#include "voffset.h"
-
-int vdso_enabled = 1;
-
-#define VEXTERN(x) extern typeof(__ ## x) *vdso_ ## x;
-#include "vextern.h"
-#undef VEXTERN
-
-extern char vdso_kernel_start[], vdso_start[], vdso_end[];
-extern unsigned short vdso_sync_cpuid;
-
-struct page **vdso_pages;
-
-static inline void *var_ref(void *vbase, char *var, char *name)
-{
-       unsigned offset = var - &vdso_kernel_start[0] + VDSO_TEXT_OFFSET;
-       void *p = vbase + offset;
-       if (*(void **)p != (void *)VMAGIC) {
-               printk("VDSO: variable %s broken\n", name);
-               vdso_enabled = 0;
-       }
-       return p;
-}
-
-static int __init init_vdso_vars(void)
-{
-       int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE;
-       int i;
-       char *vbase;
-
-       vdso_pages = kmalloc(sizeof(struct page *) * npages, GFP_KERNEL);
-       if (!vdso_pages)
-               goto oom;
-       for (i = 0; i < npages; i++) {
-               struct page *p;
-               p = alloc_page(GFP_KERNEL);
-               if (!p)
-                       goto oom;
-               vdso_pages[i] = p;
-               copy_page(page_address(p), vdso_start + i*PAGE_SIZE);
-       }
-
-       vbase = vmap(vdso_pages, npages, 0, PAGE_KERNEL);
-       if (!vbase)
-               goto oom;
-
-       if (memcmp(vbase, "\177ELF", 4)) {
-               printk("VDSO: I'm broken; not ELF\n");
-               vdso_enabled = 0;
-       }
-
-#define V(x) *(typeof(x) *) var_ref(vbase, (char *)RELOC_HIDE(&x, 0), #x)
-#define VEXTERN(x) \
-       V(vdso_ ## x) = &__ ## x;
-#include "vextern.h"
-#undef VEXTERN
-       return 0;
-
- oom:
-       printk("Cannot allocate vdso\n");
-       vdso_enabled = 0;
-       return -ENOMEM;
-}
-__initcall(init_vdso_vars);
-
-struct linux_binprm;
-
-/* Put the vdso above the (randomized) stack with another randomized offset.
-   This way there is no hole in the middle of address space.
-   To save memory make sure it is still in the same PTE as the stack top.
-   This doesn't give that many random bits */
-static unsigned long vdso_addr(unsigned long start, unsigned len)
-{
-       unsigned long addr, end;
-       unsigned offset;
-       end = (start + PMD_SIZE - 1) & PMD_MASK;
-       if (end >= TASK_SIZE64)
-               end = TASK_SIZE64;
-       end -= len;
-       /* This loses some more bits than a modulo, but is cheaper */
-       offset = get_random_int() & (PTRS_PER_PTE - 1);
-       addr = start + (offset << PAGE_SHIFT);
-       if (addr >= end)
-               addr = end;
-       return addr;
-}
-
-/* Setup a VMA at program startup for the vsyscall page.
-   Not called for compat tasks */
-int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
-{
-       struct mm_struct *mm = current->mm;
-       unsigned long addr;
-       int ret;
-       unsigned len = round_up(vdso_end - vdso_start, PAGE_SIZE);
-
-       if (!vdso_enabled)
-               return 0;
-
-       down_write(&mm->mmap_sem);
-       addr = vdso_addr(mm->start_stack, len);
-       addr = get_unmapped_area(NULL, addr, len, 0, 0);
-       if (IS_ERR_VALUE(addr)) {
-               ret = addr;
-               goto up_fail;
-       }
-
-       ret = install_special_mapping(mm, addr, len,
-                                     VM_READ|VM_EXEC|
-                                     VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
-                                     VM_ALWAYSDUMP,
-                                     vdso_pages);
-       if (ret)
-               goto up_fail;
-
-       current->mm->context.vdso = (void *)addr;
-up_fail:
-       up_write(&mm->mmap_sem);
-       return ret;
-}
-
-static __init int vdso_setup(char *s)
-{
-       vdso_enabled = simple_strtoul(s, NULL, 0);
-       return 0;
-}
-__setup("vdso=", vdso_setup);
diff --git a/arch/x86_64/vdso/voffset.h b/arch/x86_64/vdso/voffset.h
deleted file mode 100644 (file)
index 4af67c7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#define VDSO_TEXT_OFFSET 0x600
diff --git a/arch/x86_64/vdso/vvar.c b/arch/x86_64/vdso/vvar.c
deleted file mode 100644 (file)
index 6fc2221..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Define pointer to external vDSO variables.
-   These are part of the vDSO. The kernel fills in the real addresses
-   at boot time. This is done because when the vdso is linked the
-   kernel isn't yet and we don't know the final addresses. */
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <asm/vsyscall.h>
-#include <asm/timex.h>
-#include <asm/vgtod.h>
-
-#define VEXTERN(x) typeof (__ ## x) *vdso_ ## x = (void *)VMAGIC;
-#include "vextern.h"
index eb508bf..ef1c633 100644 (file)
@@ -39,6 +39,6 @@
 
 /* Firmware version */
 #define FW_VERSION_MAJOR 4
-#define FW_VERSION_MINOR 3
+#define FW_VERSION_MINOR 6
 #define FW_VERSION_MICRO 0
 #endif                         /* __CHELSIO_VERSION_H */
index 564baca..389346c 100644 (file)
@@ -150,7 +150,7 @@ char *func_table[MAX_NR_FUNC] = {
        NULL,
 };
 
-struct kbdiacr accent_table[MAX_DIACR] = {
+struct kbdiacruc accent_table[MAX_DIACR] = {
        {'^', 'c', '\003'},     {'^', 'd', '\004'},
        {'^', 'z', '\032'},     {'^', '\012', '\000'},
 };
index 2e9c38f..390b0fc 100644 (file)
@@ -335,8 +335,8 @@ static uint32_t aic7xxx_periodic_otag;
  */
 static char *aic7xxx = NULL;
 
-MODULE_AUTHOR("Maintainer: Justin T. Gibbs <gibbs@scsiguy.com>");
-MODULE_DESCRIPTION("Adaptec Aic77XX/78XX SCSI Host Bus Adapter driver");
+MODULE_AUTHOR("Maintainer: Hannes Reinecke <hare@suse.de>");
+MODULE_DESCRIPTION("Adaptec AIC77XX/78XX SCSI Host Bus Adapter driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(AIC7XXX_DRIVER_VERSION);
 module_param(aic7xxx, charp, 0444);
@@ -747,6 +747,7 @@ struct scsi_host_template aic7xxx_driver_template = {
        .max_sectors            = 8192,
        .cmd_per_lun            = 2,
        .use_clustering         = ENABLE_CLUSTERING,
+       .use_sg_chaining        = ENABLE_SG_CHAINING,
        .slave_alloc            = ahc_linux_slave_alloc,
        .slave_configure        = ahc_linux_slave_configure,
        .target_alloc           = ahc_linux_target_alloc,
index ea5687d..4488946 100644 (file)
@@ -49,6 +49,8 @@ static int    ahc_linux_pci_reserve_io_region(struct ahc_softc *ahc,
 static int     ahc_linux_pci_reserve_mem_region(struct ahc_softc *ahc,
                                                 u_long *bus_addr,
                                                 uint8_t __iomem **maddr);
+static int     ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg);
+static int     ahc_linux_pci_dev_resume(struct pci_dev *pdev);
 static void    ahc_linux_pci_dev_remove(struct pci_dev *pdev);
 
 /* Define the macro locally since it's different for different class of chips.
@@ -133,10 +135,54 @@ MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
 static struct pci_driver aic7xxx_pci_driver = {
        .name           = "aic7xxx",
        .probe          = ahc_linux_pci_dev_probe,
+#ifdef CONFIG_PM
+       .suspend        = ahc_linux_pci_dev_suspend,
+       .resume         = ahc_linux_pci_dev_resume,
+#endif
        .remove         = ahc_linux_pci_dev_remove,
        .id_table       = ahc_linux_pci_id_table
 };
 
+static int
+ahc_linux_pci_dev_suspend(struct pci_dev *pdev, pm_message_t mesg)
+{
+       struct ahc_softc *ahc = pci_get_drvdata(pdev);
+       int rc;
+
+       if ((rc = ahc_suspend(ahc)))
+               return rc;
+
+       pci_save_state(pdev);
+       pci_disable_device(pdev);
+
+       if (mesg.event == PM_EVENT_SUSPEND)
+               pci_set_power_state(pdev, PCI_D3hot);
+
+       return rc;
+}
+
+static int
+ahc_linux_pci_dev_resume(struct pci_dev *pdev)
+{
+       struct ahc_softc *ahc = pci_get_drvdata(pdev);
+       int rc;
+
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+
+       if ((rc = pci_enable_device(pdev))) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "failed to enable device after resume (%d)\n", rc);
+               return rc;
+       }
+
+       pci_set_master(pdev);
+
+       ahc_pci_resume(ahc);
+
+       return (ahc_resume(ahc));
+}
+
 static void
 ahc_linux_pci_dev_remove(struct pci_dev *pdev)
 {
index 09c8172..ae35937 100644 (file)
@@ -633,8 +633,6 @@ static void    write_brdctl(struct ahc_softc *ahc, uint8_t value);
 static uint8_t read_brdctl(struct ahc_softc *ahc);
 static void ahc_pci_intr(struct ahc_softc *ahc);
 static int  ahc_pci_chip_init(struct ahc_softc *ahc);
-static int  ahc_pci_suspend(struct ahc_softc *ahc);
-static int  ahc_pci_resume(struct ahc_softc *ahc);
 
 static int
 ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor,
@@ -791,8 +789,6 @@ ahc_pci_config(struct ahc_softc *ahc, struct ahc_pci_identity *entry)
 
        ahc->bus_intr = ahc_pci_intr;
        ahc->bus_chip_init = ahc_pci_chip_init;
-       ahc->bus_suspend = ahc_pci_suspend;
-       ahc->bus_resume = ahc_pci_resume;
 
        /* Remeber how the card was setup in case there is no SEEPROM */
        if ((ahc_inb(ahc, HCNTRL) & POWRDN) == 0) {
@@ -2024,18 +2020,9 @@ ahc_pci_chip_init(struct ahc_softc *ahc)
        return (ahc_chip_init(ahc));
 }
 
-static int
-ahc_pci_suspend(struct ahc_softc *ahc)
-{
-       return (ahc_suspend(ahc));
-}
-
-static int
+void
 ahc_pci_resume(struct ahc_softc *ahc)
 {
-
-       pci_set_power_state(ahc->dev_softc, AHC_POWER_STATE_D0);
-
        /*
         * We assume that the OS has restored our register
         * mappings, etc.  Just update the config space registers
@@ -2063,7 +2050,6 @@ ahc_pci_resume(struct ahc_softc *ahc)
                                      &sxfrctl1);
                ahc_release_seeprom(&sd);
        }
-       return (ahc_resume(ahc));
 }
 
 static int
index 4998bb8..8f8db5f 100644 (file)
@@ -8416,10 +8416,9 @@ aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp)
     *p = *temp;
     p->host = host;
 
-    p->scb_data = kmalloc(sizeof(scb_data_type), GFP_ATOMIC);
-    if (p->scb_data != NULL)
+    p->scb_data = kzalloc(sizeof(scb_data_type), GFP_ATOMIC);
+    if (p->scb_data)
     {
-      memset(p->scb_data, 0, sizeof(scb_data_type));
       scbq_init (&p->scb_data->free_scbs);
     }
     else
@@ -9196,10 +9195,9 @@ aic7xxx_detect(struct scsi_host_template *template)
             printk(KERN_INFO "         this driver, we are ignoring it.\n");
           }
         }
-        else if ( (temp_p = kmalloc(sizeof(struct aic7xxx_host),
+        else if ( (temp_p = kzalloc(sizeof(struct aic7xxx_host),
                                     GFP_ATOMIC)) != NULL )
         {
-          memset(temp_p, 0, sizeof(struct aic7xxx_host));
           temp_p->chip = aic_pdevs[i].chip | AHC_PCI;
           temp_p->flags = aic_pdevs[i].flags;
           temp_p->features = aic_pdevs[i].features;
@@ -11144,6 +11142,7 @@ static struct scsi_host_template driver_template = {
        .max_sectors            = 2048,
        .cmd_per_lun            = 3,
        .use_clustering         = ENABLE_CLUSTERING,
+       .use_sg_chaining        = ENABLE_SG_CHAINING,
 };
 
 #include "scsi_module.c"
diff --git a/drivers/tc/.gitignore b/drivers/tc/.gitignore
deleted file mode 100644 (file)
index acc0e1e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-lk201-map.c
index 78bc9ee..9281dd8 100644 (file)
@@ -1,8 +1,12 @@
+/*
+ * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
 #ifndef __UM_A_OUT_H
 #define __UM_A_OUT_H
 
 #include "asm/arch/a.out.h"
-#include "choose-mode.h"
 
 #undef STACK_TOP
 #undef STACK_TOP_MAX
@@ -13,10 +17,8 @@ extern unsigned long host_task_size;
 
 #define STACK_ROOM (stacksizelim)
 
-extern int honeypot;
-#define STACK_TOP \
-       CHOOSE_MODE((honeypot ? host_task_size : task_size), task_size)
+#define STACK_TOP task_size
 
-#define STACK_TOP_MAX  STACK_TOP
+#define STACK_TOP_MAX STACK_TOP
 
 #endif
diff --git a/include/asm-um/alternative-asm.h b/include/asm-um/alternative-asm.h
new file mode 100644 (file)
index 0000000..9aa9fa2
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __UM_ALTERNATIVE_ASM_I
+#define __UM_ALTERNATIVE_ASM_I
+
+#include "asm/arch/alternative-asm.h"
+
+#endif
diff --git a/include/asm-um/alternative-asm.i b/include/asm-um/alternative-asm.i
deleted file mode 100644 (file)
index cae9fac..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_ALTERNATIVE_ASM_I
-#define __UM_ALTERNATIVE_ASM_I
-
-#include "asm/arch/alternative-asm.i"
-
-#endif
index 46d7819..e4d38d4 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef __UM_BITOPS_H
 #define __UM_BITOPS_H
 
+#ifndef _LINUX_BITOPS_H
+#error only <linux/bitops.h> can be included directly
+#endif
+
 #include "asm/arch/bitops.h"
 
 #endif
index 9bab712..ca94a13 100644 (file)
@@ -5,7 +5,8 @@
 #ifndef __UM_ELF_I386_H
 #define __UM_ELF_I386_H
 
-#include <asm/user.h>
+#include <linux/sched.h>
+#include "skas.h"
 
 #define R_386_NONE     0
 #define R_386_32       1
@@ -75,6 +76,15 @@ typedef struct user_i387_struct elf_fpregset_t;
        pr_reg[16] = PT_REGS_SS(regs);          \
 } while(0);
 
+static inline int elf_core_copy_fpregs(struct task_struct *t,
+                                      elf_fpregset_t *fpu)
+{
+       int cpu = ((struct thread_info *) t->stack)->cpu;
+       return save_fp_registers(userspace_pid[cpu], (unsigned long *) fpu);
+}
+
+#define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)
+
 extern long elf_aux_hwcap;
 #define ELF_HWCAP (elf_aux_hwcap)
 
index 857471c..3c9d543 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2003 PathScale, Inc.
+ * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  *
  * Licensed under the GPL
  */
@@ -36,7 +37,7 @@ typedef unsigned long elf_greg_t;
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
-typedef struct { } elf_fpregset_t;
+typedef struct user_i387_struct elf_fpregset_t;
 
 /*
  * This is used to ensure we don't load something for the wrong architecture.
@@ -67,27 +68,27 @@ typedef struct { } elf_fpregset_t;
 } while (0)
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)               \
-       (pr_reg)[0] = (regs)->regs.skas.regs[0];                        \
-       (pr_reg)[1] = (regs)->regs.skas.regs[1];                        \
-       (pr_reg)[2] = (regs)->regs.skas.regs[2];                        \
-       (pr_reg)[3] = (regs)->regs.skas.regs[3];                        \
-       (pr_reg)[4] = (regs)->regs.skas.regs[4];                        \
-       (pr_reg)[5] = (regs)->regs.skas.regs[5];                        \
-       (pr_reg)[6] = (regs)->regs.skas.regs[6];                        \
-       (pr_reg)[7] = (regs)->regs.skas.regs[7];                        \
-       (pr_reg)[8] = (regs)->regs.skas.regs[8];                        \
-       (pr_reg)[9] = (regs)->regs.skas.regs[9];                        \
-       (pr_reg)[10] = (regs)->regs.skas.regs[10];                      \
-       (pr_reg)[11] = (regs)->regs.skas.regs[11];                      \
-       (pr_reg)[12] = (regs)->regs.skas.regs[12];                      \
-       (pr_reg)[13] = (regs)->regs.skas.regs[13];                      \
-       (pr_reg)[14] = (regs)->regs.skas.regs[14];                      \
-       (pr_reg)[15] = (regs)->regs.skas.regs[15];                      \
-       (pr_reg)[16] = (regs)->regs.skas.regs[16];                      \
-       (pr_reg)[17] = (regs)->regs.skas.regs[17];                      \
-       (pr_reg)[18] = (regs)->regs.skas.regs[18];                      \
-       (pr_reg)[19] = (regs)->regs.skas.regs[19];                      \
-       (pr_reg)[20] = (regs)->regs.skas.regs[20];                      \
+       (pr_reg)[0] = (regs)->regs.gp[0];                       \
+       (pr_reg)[1] = (regs)->regs.gp[1];                       \
+       (pr_reg)[2] = (regs)->regs.gp[2];                       \
+       (pr_reg)[3] = (regs)->regs.gp[3];                       \
+       (pr_reg)[4] = (regs)->regs.gp[4];                       \
+       (pr_reg)[5] = (regs)->regs.gp[5];                       \
+       (pr_reg)[6] = (regs)->regs.gp[6];                       \
+       (pr_reg)[7] = (regs)->regs.gp[7];                       \
+       (pr_reg)[8] = (regs)->regs.gp[8];                       \
+       (pr_reg)[9] = (regs)->regs.gp[9];                       \
+       (pr_reg)[10] = (regs)->regs.gp[10];                     \
+       (pr_reg)[11] = (regs)->regs.gp[11];                     \
+       (pr_reg)[12] = (regs)->regs.gp[12];                     \
+       (pr_reg)[13] = (regs)->regs.gp[13];                     \
+       (pr_reg)[14] = (regs)->regs.gp[14];                     \
+       (pr_reg)[15] = (regs)->regs.gp[15];                     \
+       (pr_reg)[16] = (regs)->regs.gp[16];                     \
+       (pr_reg)[17] = (regs)->regs.gp[17];                     \
+       (pr_reg)[18] = (regs)->regs.gp[18];                     \
+       (pr_reg)[19] = (regs)->regs.gp[19];                     \
+       (pr_reg)[20] = (regs)->regs.gp[20];                     \
        (pr_reg)[21] = current->thread.arch.fs;                 \
        (pr_reg)[22] = 0;                                       \
        (pr_reg)[23] = 0;                                       \
@@ -122,14 +123,3 @@ extern long elf_aux_hwcap;
 #define SET_PERSONALITY(ex, ibcs2) do ; while(0)
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff --git a/include/asm-um/frame.h b/include/asm-um/frame.h
new file mode 100644 (file)
index 0000000..8a8c1cb
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __UM_FRAME_I
+#define __UM_FRAME_I
+
+#include "asm/arch/frame.h"
+
+#endif
diff --git a/include/asm-um/frame.i b/include/asm-um/frame.i
deleted file mode 100644 (file)
index 09d5dca..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __UM_FRAME_I
-#define __UM_FRAME_I
-
-#include "asm/arch/frame.i"
-
-#endif
diff --git a/include/asm-um/ipc.h b/include/asm-um/ipc.h
deleted file mode 100644 (file)
index a46e3d9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/ipc.h>
index 96f82a4..b2553f3 100644 (file)
 #include "asm/semaphore.h"
 #include "asm/host_ldt.h"
 
-struct mmu_context_skas;
 extern void ldt_host_info(void);
-extern long init_new_ldt(struct mmu_context_skas * to_mm,
-                        struct mmu_context_skas * from_mm);
-extern void free_ldt(struct mmu_context_skas * mm);
 
 #define LDT_PAGES_MAX \
        ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE)
index 9aa4b44..5f3b863 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,7 +9,6 @@
 #include <asm-generic/mm_hooks.h>
 
 #include "linux/sched.h"
-#include "choose-mode.h"
 #include "um_mmu.h"
 
 #define get_mmu_context(task) do ; while(0)
@@ -30,8 +29,7 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
         * possible.
         */
        if (old != new && (current->flags & PF_BORROWED_MM))
-               CHOOSE_MODE(force_flush_all(),
-                           switch_mm_skas(&new->context.skas.id));
+               __switch_mm(&new->context.id);
 }
 
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
@@ -43,8 +41,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
                cpu_clear(cpu, prev->cpu_vm_mask);
                cpu_set(cpu, next->cpu_vm_mask);
                if(next != &init_mm)
-                       CHOOSE_MODE((void) 0, 
-                                   switch_mm_skas(&next->context.skas.id));
+                       __switch_mm(&next->context.id);
        }
 }
 
@@ -53,38 +50,8 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,
 {
 }
 
-extern int init_new_context_skas(struct task_struct *task, 
-                                struct mm_struct *mm);
+extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
 
-static inline int init_new_context_tt(struct task_struct *task, 
-                                     struct mm_struct *mm)
-{
-       return(0);
-}
-
-static inline int init_new_context(struct task_struct *task, 
-                                  struct mm_struct *mm)
-{
-       return(CHOOSE_MODE_PROC(init_new_context_tt, init_new_context_skas, 
-                               task, mm));
-}
-
-extern void destroy_context_skas(struct mm_struct *mm);
-
-static inline void destroy_context(struct mm_struct *mm)
-{
-       CHOOSE_MODE((void) 0, destroy_context_skas(mm));
-}
+extern void destroy_context(struct mm_struct *mm);
 
 #endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
index 8e310d8..4b424c7 100644 (file)
@@ -9,6 +9,7 @@
 
 struct page;
 
+#include <linux/types.h>
 #include <asm/vm-flags.h>
 
 /* PAGE_SHIFT determines the page size */
index 34ab268..1490487 100644 (file)
@@ -42,7 +42,7 @@ static inline void pte_free(struct page *pte)
 
 #ifdef CONFIG_3_LEVEL_PGTABLES
 
-extern __inline__ void pmd_free(pmd_t *pmd)
+static inline void pmd_free(pmd_t *pmd)
 {
        free_page((unsigned long)pmd);
 }
index ca0c2a9..aa82b88 100644 (file)
@@ -69,7 +69,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
         return pmd;
 }
 
-extern inline void pud_clear (pud_t *pud)
+static inline void pud_clear (pud_t *pud)
 {
         set_pud(pud, __pud(0));
 }
index d99bbdd..78c0599 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -11,44 +11,32 @@ struct pt_regs;
 struct task_struct;
 
 #include "asm/ptrace.h"
-#include "choose-mode.h"
 #include "registers.h"
 #include "sysdep/archsetjmp.h"
 
 struct mm_struct;
 
 struct thread_struct {
-       /* This flag is set to 1 before calling do_fork (and analyzed in
+       struct task_struct *saved_task;
+       /*
+        * This flag is set to 1 before calling do_fork (and analyzed in
         * copy_thread) to mark that we are begin called from userspace (fork /
         * vfork / clone), and reset to 0 after. It is left to 0 when called
-        * from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */
-       struct task_struct *saved_task;
+        * from kernelspace (i.e. kernel_thread() or fork_idle(),
+        * as of 2.6.11).
+        */
        int forking;
        int nsyscalls;
        struct pt_regs regs;
        int singlestep_syscall;
        void *fault_addr;
-       void *fault_catcher;
+       jmp_buf *fault_catcher;
        struct task_struct *prev_sched;
        unsigned long temp_stack;
-       void *exec_buf;
+       jmp_buf *exec_buf;
        struct arch_thread arch;
-       union {
-#ifdef CONFIG_MODE_TT
-               struct {
-                       int extern_pid;
-                       int tracing;
-                       int switch_pipe[2];
-                       int vm_seq;
-               } tt;
-#endif
-#ifdef CONFIG_MODE_SKAS
-               struct {
-                       jmp_buf switch_buf;
-                       int mm_count;
-               } skas;
-#endif
-       } mode;
+       jmp_buf switch_buf;
+       int mm_count;
        struct {
                int op;
                union {
@@ -71,7 +59,7 @@ struct thread_struct {
 { \
        .forking                = 0, \
        .nsyscalls              = 0, \
-        .regs                  = EMPTY_REGS, \
+       .regs                   = EMPTY_REGS,   \
        .fault_addr             = NULL, \
        .prev_sched             = NULL, \
        .temp_stack             = 0, \
@@ -86,7 +74,10 @@ typedef struct {
 
 extern struct task_struct *alloc_task_struct(void);
 
-extern void release_thread(struct task_struct *);
+static inline void release_thread(struct task_struct *task)
+{
+}
+
 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
 
 static inline void prepare_to_copy(struct task_struct *tsk)
@@ -136,12 +127,7 @@ extern struct cpuinfo_um cpu_data[];
 #endif
 
 
-#ifdef CONFIG_MODE_SKAS
-#define KSTK_REG(tsk, reg) \
-       get_thread_reg(reg, &tsk->thread.mode.skas.switch_buf)
-#else
-#define KSTK_REG(tsk, reg) (0xbadbabe)
-#endif
+#define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)
 #define get_wchan(p) (0)
 
 #endif
index 31c2d4d..d946bf2 100644 (file)
@@ -18,7 +18,7 @@ struct arch_thread {
 };
 
 /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
-extern inline void rep_nop(void)
+static inline void rep_nop(void)
 {
        __asm__ __volatile__("rep;nop": : :"memory");
 }
index 99c87c5..6aefcd3 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,10 +9,11 @@
 #ifndef __ASSEMBLY__
 
 #include "asm/arch/ptrace-abi.h"
+#include <asm/user.h>
 #include "sysdep/ptrace.h"
 
 struct pt_regs {
-       union uml_pt_regs regs;
+       struct uml_pt_regs regs;
 };
 
 #define EMPTY_REGS { .regs = EMPTY_UML_PT_REGS }
@@ -35,16 +36,18 @@ struct pt_regs {
 
 struct task_struct;
 
+extern long subarch_ptrace(struct task_struct *child, long request, long addr,
+                          long data);
 extern unsigned long getreg(struct task_struct *child, int regno);
 extern int putreg(struct task_struct *child, int regno, unsigned long value);
-extern int get_fpregs(unsigned long buf, struct task_struct *child);
-extern int set_fpregs(unsigned long buf, struct task_struct *child);
-extern int get_fpxregs(unsigned long buf, struct task_struct *child);
-extern int set_fpxregs(unsigned long buf, struct task_struct *tsk);
+extern int get_fpregs(struct user_i387_struct __user *buf,
+                     struct task_struct *child);
+extern int set_fpregs(struct user_i387_struct __user *buf,
+                     struct task_struct *child);
 
 extern void show_regs(struct pt_regs *regs);
 
-extern void send_sigtrap(struct task_struct *tsk, union uml_pt_regs *regs,
+extern void send_sigtrap(struct task_struct *tsk, struct uml_pt_regs *regs,
                         int error_code);
 
 extern int arch_copy_tls(struct task_struct *new);
index 6e2528b..b2d24c5 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
+ * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -9,10 +9,9 @@
 #define HOST_AUDIT_ARCH AUDIT_ARCH_I386
 
 #include "linux/compiler.h"
-#include "sysdep/ptrace.h"
 #include "asm/ptrace-generic.h"
-#include "asm/host_ldt.h"
-#include "choose-mode.h"
+#include <asm/user.h>
+#include "sysdep/ptrace.h"
 
 #define PT_REGS_EAX(r) UPT_EAX(&(r)->regs)
 #define PT_REGS_EBX(r) UPT_EBX(&(r)->regs)
 
 #define user_mode(r) UPT_IS_USER(&(r)->regs)
 
+/*
+ * Forward declaration to avoid including sysdep/tls.h, which causes a
+ * circular include, and compilation failures.
+ */
+struct user_desc;
+
+extern int get_fpxregs(struct user_fxsr_struct __user *buf,
+                      struct task_struct *child);
+extern int set_fpxregs(struct user_fxsr_struct __user *buf,
+                      struct task_struct *tsk);
+
 extern int ptrace_get_thread_area(struct task_struct *child, int idx,
                                   struct user_desc __user *user_desc);
 
 extern int ptrace_set_thread_area(struct task_struct *child, int idx,
                                   struct user_desc __user *user_desc);
 
-extern int do_set_thread_area_skas(struct user_desc *info);
-extern int do_get_thread_area_skas(struct user_desc *info);
-
-extern int do_set_thread_area_tt(struct user_desc *info);
-extern int do_get_thread_area_tt(struct user_desc *info);
-
-extern int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to);
-extern int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to);
-
-extern void arch_switch_to_tt(struct task_struct *from, struct task_struct *to);
-extern void arch_switch_to_skas(struct task_struct *from, struct task_struct *to);
-
-static inline int do_get_thread_area(struct user_desc *info)
-{
-       return CHOOSE_MODE_PROC(do_get_thread_area_tt, do_get_thread_area_skas, info);
-}
-
-static inline int do_set_thread_area(struct user_desc *info)
-{
-       return CHOOSE_MODE_PROC(do_set_thread_area_tt, do_set_thread_area_skas, info);
-}
-
-struct task_struct;
-
 #endif
index bf61d17..4c47535 100644 (file)
@@ -76,15 +76,6 @@ static inline int ptrace_set_thread_area(struct task_struct *child, int idx,
         return -ENOSYS;
 }
 
-static inline void arch_switch_to_tt(struct task_struct *from,
-                                     struct task_struct *to)
-{
-}
-
-extern void arch_switch_to_skas(struct task_struct *from,
-                               struct task_struct *to);
-
-extern long arch_prctl_skas(struct task_struct *task, int code,
-                           unsigned long __user *addr);
-
+extern long arch_prctl(struct task_struct *task, int code,
+                      unsigned long __user *addr);
 #endif
index 84f8cf2..f27a963 100644 (file)
@@ -18,7 +18,7 @@ extern int hard_smp_processor_id(void);
 extern int ncpus;
 
 
-extern inline void smp_cpus_done(unsigned int maxcpus)
+static inline void smp_cpus_done(unsigned int maxcpus)
 {
 }
 
index e78c28c..614f2c0 100644 (file)
@@ -1,5 +1,5 @@
-/* 
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
+/*
+ * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  * Licensed under the GPL
  */
 
@@ -7,7 +7,6 @@
 #define __UM_TLBFLUSH_H
 
 #include <linux/mm.h>
-#include "choose-mode.h"
 
 /*
  * TLB flushing:
  *  - flush_tlb_page(vma, vmaddr) flushes one page
  *  - flush_tlb_kernel_vm() flushes the kernel vm area
  *  - flush_tlb_range(vma, start, end) flushes a range of pages
- *  - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
  */
 
 extern void flush_tlb_all(void);
 extern void flush_tlb_mm(struct mm_struct *mm);
 extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, 
                            unsigned long end);
-extern void flush_tlb_page_skas(struct vm_area_struct *vma,
-                               unsigned long address);
-
-static inline void flush_tlb_page(struct vm_area_struct *vma,
-                                 unsigned long address)
-{
-       address &= PAGE_MASK;
-
-       CHOOSE_MODE(flush_tlb_range(vma, address, address + PAGE_SIZE),
-                   flush_tlb_page_skas(vma, address));
-}
-
-extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
+extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long address);
 extern void flush_tlb_kernel_vm(void);
 extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
 extern void __flush_tlb_one(unsigned long addr);
 
-static inline void flush_tlb_pgtables(struct mm_struct *mm,
-                                     unsigned long start, unsigned long end)
-{
-}
-
 #endif
index 16c734a..077032d 100644 (file)
@@ -80,7 +80,7 @@
         __put_user(x, private_ptr) : -EFAULT); \
 })
 
-#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
+#define strlen_user(str) strnlen_user(str, ~0U >> 1)
 
 struct exception_table_entry
 {
index 732c83f..38bd9d9 100644 (file)
@@ -14,7 +14,6 @@ extern int um_execve(const char *file, char *const argv[], char *const env[]);
 
 #ifdef __KERNEL__
 /* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */
-#define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
 #define __ARCH_WANT_SYS_GETHOSTNAME
index 6bbcfef..a2be8ad 100644 (file)
@@ -1,3 +1,3 @@
 /* include/version.h.  Generated by alsa/ksync script.  */
-#define CONFIG_SND_VERSION "1.0.14"
-#define CONFIG_SND_DATE " (Fri Jul 20 09:12:58 2007 UTC)"
+#define CONFIG_SND_VERSION "1.0.15"
+#define CONFIG_SND_DATE " (Tue Oct 23 06:09:18 2007 UTC)"
index 5875f29..e420fe4 100644 (file)
@@ -23,14 +23,16 @@ quiet_cmd_keywords.c = GPERF   $@
 
 $(obj)/keywords.c: $(obj)/keywords.gperf FORCE
        $(call if_changed,keywords.c)
+       cp $@ $@_shipped
 
 # flex
 
 quiet_cmd_lex.c = FLEX    $@
-      cmd_lex.c = flex -o$@ -d $(filter-out FORCE,$^)
+      cmd_lex.c = flex -o$@ -d $< $(obj)/parse.h
 
-$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h FORCE
+$(obj)/lex.c: $(obj)/lex.l $(obj)/parse.h $(obj)/keywords.c FORCE
        $(call if_changed,lex.c)
+       cp $@ $@_shipped
 
 # bison
 
@@ -39,6 +41,8 @@ quiet_cmd_parse.c = BISON   $@
 
 $(obj)/parse.c: $(obj)/parse.y FORCE
        $(call if_changed,parse.c)
+       cp $@ $@_shipped
+       cp $(@:.c=.h) $(@:.c=.h)_shipped
 
 $(obj)/parse.h: $(obj)/parse.c ;
 
index d8153f5..971e011 100644 (file)
@@ -1,4 +1,4 @@
-/* ANSI-C code produced by gperf version 3.0.1 */
+/* ANSI-C code produced by gperf version 3.0.2 */
 /* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -32,7 +32,7 @@
 
 #line 3 "scripts/genksyms/keywords.gperf"
 struct resword { const char *name; int token; };
-/* maximum key range = 68, duplicates = 0 */
+/* maximum key range = 62, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -46,32 +46,32 @@ is_reserved_hash (register const char *str, register unsigned int len)
 {
   static const unsigned char asso_values[] =
     {
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71,  0,
-      71, 71, 71, 71, 71, 71, 35, 71, 71, 71,
-       5, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71,  0, 71,  0, 71,  5,
-       5,  0, 10, 20, 71, 25, 71, 71, 20,  0,
-      20, 30, 25, 71, 10,  5,  0, 20, 15, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-      71, 71, 71, 71, 71, 71
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65,  5,
+      65, 65, 65, 65, 65, 65, 35, 65, 65, 65,
+       0, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65,  0, 65,  0, 65,  5,
+      20, 15, 10, 30, 65, 15, 65, 65, 20,  0,
+      10, 35, 20, 65, 10,  5,  0, 10,  5, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+      65, 65, 65, 65, 65, 65
     };
   return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
 }
@@ -84,17 +84,17 @@ is_reserved_word (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 42,
+      TOTAL_KEYWORDS = 43,
       MIN_WORD_LENGTH = 3,
       MAX_WORD_LENGTH = 24,
       MIN_HASH_VALUE = 3,
-      MAX_HASH_VALUE = 70
+      MAX_HASH_VALUE = 64
     };
 
   static const struct resword wordlist[] =
     {
       {""}, {""}, {""},
-#line 25 "scripts/genksyms/keywords.gperf"
+#line 26 "scripts/genksyms/keywords.gperf"
       {"asm", ASM_KEYW},
       {""},
 #line 8 "scripts/genksyms/keywords.gperf"
@@ -102,98 +102,98 @@ is_reserved_word (register const char *str, register unsigned int len)
       {""},
 #line 9 "scripts/genksyms/keywords.gperf"
       {"__asm__", ASM_KEYW},
-      {""},
-#line 22 "scripts/genksyms/keywords.gperf"
-      {"_restrict", RESTRICT_KEYW},
-#line 51 "scripts/genksyms/keywords.gperf"
+      {""}, {""},
+#line 52 "scripts/genksyms/keywords.gperf"
       {"__typeof__", TYPEOF_KEYW},
-#line 10 "scripts/genksyms/keywords.gperf"
-      {"__attribute", ATTRIBUTE_KEYW},
+      {""},
 #line 12 "scripts/genksyms/keywords.gperf"
       {"__const", CONST_KEYW},
 #line 11 "scripts/genksyms/keywords.gperf"
       {"__attribute__", ATTRIBUTE_KEYW},
 #line 13 "scripts/genksyms/keywords.gperf"
       {"__const__", CONST_KEYW},
-#line 17 "scripts/genksyms/keywords.gperf"
+#line 18 "scripts/genksyms/keywords.gperf"
       {"__signed__", SIGNED_KEYW},
-#line 43 "scripts/genksyms/keywords.gperf"
+#line 44 "scripts/genksyms/keywords.gperf"
       {"static", STATIC_KEYW},
-      {""},
-#line 16 "scripts/genksyms/keywords.gperf"
-      {"__signed", SIGNED_KEYW},
-#line 31 "scripts/genksyms/keywords.gperf"
+#line 20 "scripts/genksyms/keywords.gperf"
+      {"__volatile__", VOLATILE_KEYW},
+#line 39 "scripts/genksyms/keywords.gperf"
+      {"int", INT_KEYW},
+#line 32 "scripts/genksyms/keywords.gperf"
       {"char", CHAR_KEYW},
-      {""},
-#line 44 "scripts/genksyms/keywords.gperf"
+#line 33 "scripts/genksyms/keywords.gperf"
+      {"const", CONST_KEYW},
+#line 45 "scripts/genksyms/keywords.gperf"
       {"struct", STRUCT_KEYW},
-#line 23 "scripts/genksyms/keywords.gperf"
-      {"__restrict__", RESTRICT_KEYW},
 #line 24 "scripts/genksyms/keywords.gperf"
+      {"__restrict__", RESTRICT_KEYW},
+#line 25 "scripts/genksyms/keywords.gperf"
       {"restrict", RESTRICT_KEYW},
-#line 34 "scripts/genksyms/keywords.gperf"
+#line 23 "scripts/genksyms/keywords.gperf"
+      {"_restrict", RESTRICT_KEYW},
+#line 16 "scripts/genksyms/keywords.gperf"
+      {"__inline__", INLINE_KEYW},
+#line 10 "scripts/genksyms/keywords.gperf"
+      {"__attribute", ATTRIBUTE_KEYW},
+      {""},
+#line 14 "scripts/genksyms/keywords.gperf"
+      {"__extension__", EXTENSION_KEYW},
+#line 35 "scripts/genksyms/keywords.gperf"
       {"enum", ENUM_KEYW},
-#line 18 "scripts/genksyms/keywords.gperf"
+#line 19 "scripts/genksyms/keywords.gperf"
       {"__volatile", VOLATILE_KEYW},
-#line 35 "scripts/genksyms/keywords.gperf"
+#line 36 "scripts/genksyms/keywords.gperf"
       {"extern", EXTERN_KEYW},
-#line 19 "scripts/genksyms/keywords.gperf"
-      {"__volatile__", VOLATILE_KEYW},
-#line 38 "scripts/genksyms/keywords.gperf"
-      {"int", INT_KEYW},
+      {""},
+#line 17 "scripts/genksyms/keywords.gperf"
+      {"__signed", SIGNED_KEYW},
 #line 7 "scripts/genksyms/keywords.gperf"
       {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW},
-#line 32 "scripts/genksyms/keywords.gperf"
-      {"const", CONST_KEYW},
-#line 33 "scripts/genksyms/keywords.gperf"
-      {"double", DOUBLE_KEYW},
       {""},
-#line 14 "scripts/genksyms/keywords.gperf"
+#line 51 "scripts/genksyms/keywords.gperf"
+      {"typeof", TYPEOF_KEYW},
+#line 46 "scripts/genksyms/keywords.gperf"
+      {"typedef", TYPEDEF_KEYW},
+#line 15 "scripts/genksyms/keywords.gperf"
       {"__inline", INLINE_KEYW},
-#line 30 "scripts/genksyms/keywords.gperf"
+#line 31 "scripts/genksyms/keywords.gperf"
       {"auto", AUTO_KEYW},
-#line 15 "scripts/genksyms/keywords.gperf"
-      {"__inline__", INLINE_KEYW},
-#line 42 "scripts/genksyms/keywords.gperf"
-      {"signed", SIGNED_KEYW},
-      {""},
 #line 47 "scripts/genksyms/keywords.gperf"
+      {"union", UNION_KEYW},
+      {""}, {""},
+#line 48 "scripts/genksyms/keywords.gperf"
       {"unsigned", UNSIGNED_KEYW},
-      {""},
-#line 41 "scripts/genksyms/keywords.gperf"
+#line 49 "scripts/genksyms/keywords.gperf"
+      {"void", VOID_KEYW},
+#line 42 "scripts/genksyms/keywords.gperf"
       {"short", SHORT_KEYW},
+      {""}, {""},
 #line 50 "scripts/genksyms/keywords.gperf"
-      {"typeof", TYPEOF_KEYW},
-#line 45 "scripts/genksyms/keywords.gperf"
-      {"typedef", TYPEDEF_KEYW},
-#line 49 "scripts/genksyms/keywords.gperf"
       {"volatile", VOLATILE_KEYW},
       {""},
-#line 36 "scripts/genksyms/keywords.gperf"
-      {"float", FLOAT_KEYW},
-      {""}, {""},
-#line 40 "scripts/genksyms/keywords.gperf"
-      {"register", REGISTER_KEYW},
-#line 48 "scripts/genksyms/keywords.gperf"
-      {"void", VOID_KEYW},
-      {""},
 #line 37 "scripts/genksyms/keywords.gperf"
-      {"inline", INLINE_KEYW},
+      {"float", FLOAT_KEYW},
+#line 34 "scripts/genksyms/keywords.gperf"
+      {"double", DOUBLE_KEYW},
       {""},
 #line 5 "scripts/genksyms/keywords.gperf"
       {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
-      {""},
-#line 21 "scripts/genksyms/keywords.gperf"
-      {"_Bool", BOOL_KEYW},
-      {""},
+      {""}, {""},
+#line 38 "scripts/genksyms/keywords.gperf"
+      {"inline", INLINE_KEYW},
 #line 6 "scripts/genksyms/keywords.gperf"
       {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
-      {""}, {""}, {""}, {""}, {""}, {""},
-#line 39 "scripts/genksyms/keywords.gperf"
-      {"long", LONG_KEYW},
-      {""}, {""}, {""}, {""}, {""},
-#line 46 "scripts/genksyms/keywords.gperf"
-      {"union", UNION_KEYW}
+#line 41 "scripts/genksyms/keywords.gperf"
+      {"register", REGISTER_KEYW},
+      {""},
+#line 22 "scripts/genksyms/keywords.gperf"
+      {"_Bool", BOOL_KEYW},
+#line 43 "scripts/genksyms/keywords.gperf"
+      {"signed", SIGNED_KEYW},
+      {""}, {""},
+#line 40 "scripts/genksyms/keywords.gperf"
+      {"long", LONG_KEYW}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
index c75e0c8..5ef3733 100644 (file)
@@ -11,6 +11,7 @@ __attribute, ATTRIBUTE_KEYW
 __attribute__, ATTRIBUTE_KEYW
 __const, CONST_KEYW
 __const__, CONST_KEYW
+__extension__, EXTENSION_KEYW
 __inline, INLINE_KEYW
 __inline__, INLINE_KEYW
 __signed, SIGNED_KEYW
index 37ba982..2a17698 100644 (file)
 #line 2 "scripts/genksyms/lex.c"
-/* A lexical scanner generated by flex */
 
-/* Scanner skeleton version:
- * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
- */
+#line 4 "scripts/genksyms/lex.c"
+
+#define  YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
 
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 33
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* %if-c++-only */
+/* %endif */
 
+/* %if-c-only */
+    
+/* %endif */
+
+/* %if-c-only */
+
+/* %endif */
+
+/* First, we deal with  platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+/* %if-c-only */
 #include <stdio.h>
-#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+/* %endif */
 
+/* %if-tables-serialization */
+/* %endif */
+/* end standard C headers. */
 
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
+/* %if-c-or-c++ */
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types. 
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t; 
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN               (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN              (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN              (-2147483647-1)
 #endif
+#ifndef INT8_MAX
+#define INT8_MAX               (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX              (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX              (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX              (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX             (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX             (4294967295U)
 #endif
 
+#endif /* ! FLEXINT_H */
 
-#ifdef __cplusplus
+/* %endif */
 
-#include <stdlib.h>
+/* %if-c++-only */
+/* %endif */
 
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
+#ifdef __cplusplus
 
 /* The "const" storage-class-modifier is valid. */
 #define YY_USE_CONST
 
 #if __STDC__
 
-#define YY_USE_PROTOS
 #define YY_USE_CONST
 
 #endif /* __STDC__ */
 #endif /* ! __cplusplus */
 
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
 #ifdef YY_USE_CONST
 #define yyconst const
 #else
 #define yyconst
 #endif
 
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
+/* %not-for-header */
 
 /* Returned upon end-of-file. */
 #define YY_NULL 0
+/* %ok-for-header */
+
+/* %not-for-header */
 
 /* Promotes a possibly negative, possibly signed char to an unsigned
  * integer for use as an array index.  If the signed char is negative,
  * double cast.
  */
 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+/* %ok-for-header */
+
+/* %if-reentrant */
+/* %endif */
+
+/* %if-not-reentrant */
+
+/* %endif */
 
 /* Enter a start condition.  This macro really ought to take a parameter,
  * but we do it the disgusting crufty way forced on us by the ()-less
  * definition of BEGIN.
  */
-#define BEGIN yy_start = 1 + 2 *
+#define BEGIN (yy_start) = 1 + 2 *
 
 /* Translate the current start state into a value that can be later handed
  * to BEGIN to return to the state.  The YYSTATE alias is for lex
  * compatibility.
  */
-#define YY_START ((yy_start - 1) / 2)
+#define YY_START (((yy_start) - 1) / 2)
 #define YYSTATE YY_START
 
 /* Action number for EOF rule of a given start state. */
 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
 
 /* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
+#define YY_NEW_FILE yyrestart(yyin  )
 
 #define YY_END_OF_BUFFER_CHAR 0
 
 /* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
 #define YY_BUF_SIZE 16384
+#endif
 
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
 
+/* %if-not-reentrant */
 extern int yyleng;
+/* %endif */
+
+/* %if-c-only */
+/* %if-not-reentrant */
 extern FILE *yyin, *yyout;
+/* %endif */
+/* %endif */
 
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
 #define EOB_ACT_LAST_MATCH 2
 
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator).  This
- * avoids problems with code like:
- *
- *     if ( condition_holds )
- *             yyless( 5 );
- *     else
- *             do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
+    #define YY_LESS_LINENO(n)
+    
+/* Return all but the first "n" matched characters back to the input stream. */
 #define yyless(n) \
        do \
                { \
                /* Undo effects of setting up yytext. */ \
-               *yy_cp = yy_hold_char; \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+               *yy_cp = (yy_hold_char); \
                YY_RESTORE_YY_MORE_OFFSET \
-               yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+               (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
                YY_DO_BEFORE_ACTION; /* set up yytext again */ \
                } \
        while ( 0 )
 
-#define unput(c) yyunput( c, yytext_ptr )
+#define unput(c) yyunput( c, (yytext_ptr)  )
 
 /* The following is because we cannot portably get our hands on size_t
  * (without autoconf's help, which isn't available because we want
  * flex-generated scanners to compile on their own).
  */
-typedef unsigned int yy_size_t;
 
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
 
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
 struct yy_buffer_state
        {
+/* %if-c-only */
        FILE *yy_input_file;
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
 
        char *yy_ch_buf;                /* input buffer */
        char *yy_buf_pos;               /* current position in input buffer */
@@ -178,12 +271,16 @@ struct yy_buffer_state
         */
        int yy_at_bol;
 
+    int yy_bs_lineno; /**< The line count. */
+    int yy_bs_column; /**< The column count. */
+    
        /* Whether to try to fill the input buffer when we reach the
         * end of it.
         */
        int yy_fill_buffer;
 
        int yy_buffer_status;
+
 #define YY_BUFFER_NEW 0
 #define YY_BUFFER_NORMAL 1
        /* When an EOF's been seen but there's still some text to process
@@ -197,102 +294,163 @@ struct yy_buffer_state
         * just pointing yyin at a new input file.
         */
 #define YY_BUFFER_EOF_PENDING 2
+
        };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
 
-static YY_BUFFER_STATE yy_current_buffer = 0;
+/* %if-not-reentrant */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+/* %endif */
+/* %ok-for-header */
+
+/* %endif */
 
 /* We provide macros for accessing buffer states in case in the
  * future we want to put the buffer states in a more general
  * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
  */
-#define YY_CURRENT_BUFFER yy_current_buffer
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+                          : NULL)
 
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* %if-c-only Standard (non-C++) definition */
+
+/* %if-not-reentrant */
+/* %not-for-header */
 
 /* yy_hold_char holds the character lost when yytext is formed. */
 static char yy_hold_char;
-
 static int yy_n_chars;         /* number of characters read into yy_ch_buf */
-
-
 int yyleng;
 
 /* Points to current character in buffer. */
 static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1;                /* whether we need to initialize */
+static int yy_init = 0;                /* whether we need to initialize */
 static int yy_start = 0;       /* start state number */
 
 /* Flag which is used to allow yywrap()'s to do buffer switches
  * instead of setting up a fresh yyin.  A bit of a hack ...
  */
 static int yy_did_buffer_switch_on_eof;
+/* %ok-for-header */
+
+/* %endif */
 
-void yyrestart YY_PROTO(( FILE *input_file ));
+void yyrestart (FILE *input_file  );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
+void yy_delete_buffer (YY_BUFFER_STATE b  );
+void yy_flush_buffer (YY_BUFFER_STATE b  );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
+void yypop_buffer_state (void );
 
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+static void yyensure_buffer_stack (void );
+static void yy_load_buffer_state (void );
+static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
 
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
 
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
+
+/* %endif */
+
+void *yyalloc (yy_size_t  );
+void *yyrealloc (void *,yy_size_t  );
+void yyfree (void *  );
 
 #define yy_new_buffer yy_create_buffer
 
 #define yy_set_interactive(is_interactive) \
        { \
-       if ( ! yy_current_buffer ) \
-               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
-       yy_current_buffer->yy_is_interactive = is_interactive; \
+       if ( ! YY_CURRENT_BUFFER ){ \
+        yyensure_buffer_stack (); \
+               YY_CURRENT_BUFFER_LVALUE =    \
+            yy_create_buffer(yyin,YY_BUF_SIZE ); \
+       } \
+       YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
        }
 
 #define yy_set_bol(at_bol) \
        { \
-       if ( ! yy_current_buffer ) \
-               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
-       yy_current_buffer->yy_at_bol = at_bol; \
+       if ( ! YY_CURRENT_BUFFER ){\
+        yyensure_buffer_stack (); \
+               YY_CURRENT_BUFFER_LVALUE =    \
+            yy_create_buffer(yyin,YY_BUF_SIZE ); \
+       } \
+       YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
        }
 
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 
+/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
+/* Begin user sect3 */
 
 #define yywrap() 1
 #define YY_SKIP_YYWRAP
 
 #define FLEX_DEBUG
+
 typedef unsigned char YY_CHAR;
+
 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
 typedef int yy_state_type;
 
-#define FLEX_DEBUG
+extern int yylineno;
+
+int yylineno = 1;
+
 extern char *yytext;
 #define yytext_ptr yytext
 
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+/* %if-c-only Standard (non-C++) definition */
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[]  );
+
+/* %endif */
 
 /* Done after the current pattern has been matched and before the
  * corresponding action - sets up yytext.
  */
 #define YY_DO_BEFORE_ACTION \
-       yytext_ptr = yy_bp; \
-       yyleng = (int) (yy_cp - yy_bp); \
-       yy_hold_char = *yy_cp; \
+       (yytext_ptr) = yy_bp; \
+/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
+       yyleng = (size_t) (yy_cp - yy_bp); \
+       (yy_hold_char) = *yy_cp; \
        *yy_cp = '\0'; \
-       yy_c_buf_p = yy_cp;
+/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
+       (yy_c_buf_p) = yy_cp;
 
+/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
 #define YY_NUM_RULES 13
 #define YY_END_OF_BUFFER 14
-static yyconst short int yy_accept[76] =
+/* This struct is not used in this scanner,
+   but its presence is necessary. */
+struct yy_trans_info
+       {
+       flex_int32_t yy_verify;
+       flex_int32_t yy_nxt;
+       };
+static yyconst flex_int16_t yy_accept[76] =
     {   0,
         0,    0,    0,    0,   14,   12,    4,    3,   12,    7,
        12,   12,    7,   12,   12,   12,   12,   12,    9,    9,
@@ -304,7 +462,7 @@ static yyconst short int yy_accept[76] =
         0,    0,    0,    1,    0
     } ;
 
-static yyconst int yy_ec[256] =
+static yyconst flex_int32_t yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
         4,    4,    4,    1,    1,    1,    1,    1,    1,    1,
@@ -336,14 +494,14 @@ static yyconst int yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst int yy_meta[29] =
+static yyconst flex_int32_t yy_meta[29] =
     {   0,
         1,    1,    2,    1,    1,    1,    3,    1,    1,    1,
         4,    4,    5,    6,    6,    6,    1,    1,    1,    7,
         8,    7,    3,    3,    3,    1,    3,    1
     } ;
 
-static yyconst short int yy_base[88] =
+static yyconst flex_int16_t yy_base[88] =
     {   0,
         0,  147,   21,  140,  145,  284,   39,  284,   26,    0,
        32,  126,   40,   44,  115,   35,   36,   46,   50,   53,
@@ -356,7 +514,7 @@ static yyconst short int yy_base[88] =
       246,  250,  255,  256,  261,  267,  275
     } ;
 
-static yyconst short int yy_def[88] =
+static yyconst flex_int16_t yy_def[88] =
     {   0,
        75,    1,    1,    3,   75,   75,   75,   75,   76,   77,
        78,   75,   77,   79,   75,   75,   75,   75,   75,   19,
@@ -369,7 +527,7 @@ static yyconst short int yy_def[88] =
        75,   75,   75,   75,   75,   75,   75
     } ;
 
-static yyconst short int yy_nxt[313] =
+static yyconst flex_int16_t yy_nxt[313] =
     {   0,
         6,    7,    8,    7,    9,    6,   10,    6,    6,   11,
         6,    6,   12,    6,    6,    6,    6,    6,    6,   10,
@@ -408,7 +566,7 @@ static yyconst short int yy_nxt[313] =
        75,   75
     } ;
 
-static yyconst short int yy_chk[313] =
+static yyconst flex_int16_t yy_chk[313] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -453,7 +611,7 @@ static char *yy_last_accepting_cpos;
 extern int yy_flex_debug;
 int yy_flex_debug = 1;
 
-static yyconst short int yy_rule_linenum[13] =
+static yyconst flex_int16_t yy_rule_linenum[13] =
     {   0,
        69,   70,   71,   74,   77,   78,   79,   85,   86,   87,
        89,   92
@@ -468,7 +626,6 @@ static yyconst short int yy_rule_linenum[13] =
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
 #line 1 "scripts/genksyms/lex.l"
-#define INITIAL 0
 /* Lexical analysis for genksyms.
    Copyright 1996, 1997 Linux International.
 
@@ -506,10 +663,41 @@ char *yytext;
 
 /* Version 2 checksumming does proper tokenization; version 1 wasn't
    quite so pedantic.  */
-#define V2_TOKENS 1
 
 /* We don't do multiple input files.  */
-#line 513 "scripts/genksyms/lex.c"
+#line 669 "scripts/genksyms/lex.c"
+
+#define INITIAL 0
+#define V2_TOKENS 1
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+/* %if-c-only */
+#include <unistd.h>
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* %if-c-only Reentrant structure and macros (non-C++). */
+/* %if-reentrant */
+/* %if-c-only */
+
+static int yy_init_globals (void );
+
+/* %endif */
+/* %if-reentrant */
+/* %endif */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif End reentrant structures and macros. */
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -517,66 +705,45 @@ char *yytext;
 
 #ifndef YY_SKIP_YYWRAP
 #ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
+extern "C" int yywrap (void );
 #else
-extern int yywrap YY_PROTO(( void ));
+extern int yywrap (void );
 #endif
 #endif
 
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
+/* %not-for-header */
+
+    static void yyunput (int c,char *buf_ptr  );
+    
+/* %ok-for-header */
+
+/* %endif */
 
 #ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+static void yy_flex_strncpy (char *,yyconst char *,int );
 #endif
 
 #ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+static int yy_flex_strlen (yyconst char * );
 #endif
 
 #ifndef YY_NO_INPUT
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
 #ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
+static int yyinput (void );
 #else
-static int input YY_PROTO(( void ));
-#endif
+static int input (void );
 #endif
+/* %ok-for-header */
 
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
+/* %endif */
 #endif
 
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
+/* %if-c-only */
 
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines.  This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
+/* %endif */
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
@@ -584,12 +751,15 @@ YY_MALLOC_DECL
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
-
 #ifndef ECHO
+/* %if-c-only Standard (non-C++) definition */
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -597,9 +767,11 @@ YY_MALLOC_DECL
  */
 #ifndef YY_INPUT
 #define YY_INPUT(buf,result,max_size) \
-       if ( yy_current_buffer->yy_is_interactive ) \
+/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
                { \
-               int c = '*', n; \
+               int c = '*'; \
+               size_t n; \
                for ( n = 0; n < max_size && \
                             (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
                        buf[n] = (char) c; \
@@ -609,9 +781,24 @@ YY_MALLOC_DECL
                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
                result = n; \
                } \
-       else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
-                 && ferror( yyin ) ) \
-               YY_FATAL_ERROR( "input in flex scanner failed" );
+       else \
+               { \
+               errno=0; \
+               while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+                       { \
+                       if( errno != EINTR) \
+                               { \
+                               YY_FATAL_ERROR( "input in flex scanner failed" ); \
+                               break; \
+                               } \
+                       errno=0; \
+                       clearerr(yyin); \
+                       } \
+               }\
+\
+/* %if-c++-only C++ definition \ */\
+/* %endif */
+
 #endif
 
 /* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -629,15 +816,40 @@ YY_MALLOC_DECL
 
 /* Report a fatal error. */
 #ifndef YY_FATAL_ERROR
+/* %if-c-only */
 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
 #endif
 
+/* %if-tables-serialization structures and prototypes */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %not-for-header */
+
+/* %tables-yydmap generated elements */
+/* %endif */
+/* end tables serialization structures and prototypes */
+
+/* %ok-for-header */
+
 /* Default declaration of generated scanner - a define so the user can
  * easily add parameters.
  */
 #ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
+#define YY_DECL_IS_OURS 1
+/* %if-c-only Standard (non-C++) definition */
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif /* !YY_DECL */
 
 /* Code executed at the beginning of each rule, after yytext and yyleng
  * have been set up.
@@ -651,62 +863,80 @@ YY_MALLOC_DECL
 #define YY_BREAK break;
 #endif
 
+/* %% [6.0] YY_RULE_SETUP definition goes here */
 #define YY_RULE_SETUP \
        if ( yyleng > 0 ) \
-               yy_current_buffer->yy_at_bol = \
+               YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
                                (yytext[yyleng - 1] == '\n'); \
        YY_USER_ACTION
 
+/* %not-for-header */
+
+/** The main scanner function which does all the work.
+ */
 YY_DECL
-       {
+{
        register yy_state_type yy_current_state;
-       register char *yy_cp = NULL, *yy_bp = NULL;
+       register char *yy_cp, *yy_bp;
        register int yy_act;
-
+    
+/* %% [7.0] user's declarations go here */
 #line 65 "scripts/genksyms/lex.l"
 
 
 
  /* Keep track of our location in the original source files.  */
-#line 672 "scripts/genksyms/lex.c"
+#line 890 "scripts/genksyms/lex.c"
 
-       if ( yy_init )
+       if ( !(yy_init) )
                {
-               yy_init = 0;
+               (yy_init) = 1;
 
 #ifdef YY_USER_INIT
                YY_USER_INIT;
 #endif
 
-               if ( ! yy_start )
-                       yy_start = 1;   /* first start state */
+               if ( ! (yy_start) )
+                       (yy_start) = 1; /* first start state */
 
                if ( ! yyin )
+/* %if-c-only */
                        yyin = stdin;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
 
                if ( ! yyout )
+/* %if-c-only */
                        yyout = stdout;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+               if ( ! YY_CURRENT_BUFFER ) {
+                       yyensure_buffer_stack ();
+                       YY_CURRENT_BUFFER_LVALUE =
+                               yy_create_buffer(yyin,YY_BUF_SIZE );
+               }
 
-               if ( ! yy_current_buffer )
-                       yy_current_buffer =
-                               yy_create_buffer( yyin, YY_BUF_SIZE );
-
-               yy_load_buffer_state();
+               yy_load_buffer_state( );
                }
 
        while ( 1 )             /* loops until end-of-file is reached */
                {
-               yy_cp = yy_c_buf_p;
+/* %% [8.0] yymore()-related code goes here */
+               yy_cp = (yy_c_buf_p);
 
                /* Support of yytext. */
-               *yy_cp = yy_hold_char;
+               *yy_cp = (yy_hold_char);
 
                /* yy_bp points to the position in yy_ch_buf of the start of
                 * the current run.
                 */
                yy_bp = yy_cp;
 
-               yy_current_state = yy_start;
+/* %% [9.0] code to set up and find next match goes here */
+               yy_current_state = (yy_start);
                yy_current_state += YY_AT_BOL();
 yy_match:
                do
@@ -714,8 +944,8 @@ yy_match:
                        register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
                        if ( yy_accept[yy_current_state] )
                                {
-                               yy_last_accepting_state = yy_current_state;
-                               yy_last_accepting_cpos = yy_cp;
+                               (yy_last_accepting_state) = yy_current_state;
+                               (yy_last_accepting_cpos) = yy_cp;
                                }
                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                                {
@@ -729,26 +959,29 @@ yy_match:
                while ( yy_base[yy_current_state] != 284 );
 
 yy_find_action:
+/* %% [10.0] code to find the action number goes here */
                yy_act = yy_accept[yy_current_state];
                if ( yy_act == 0 )
                        { /* have to back up */
-                       yy_cp = yy_last_accepting_cpos;
-                       yy_current_state = yy_last_accepting_state;
+                       yy_cp = (yy_last_accepting_cpos);
+                       yy_current_state = (yy_last_accepting_state);
                        yy_act = yy_accept[yy_current_state];
                        }
 
                YY_DO_BEFORE_ACTION;
 
+/* %% [11.0] code for yylineno update goes here */
 
 do_action:     /* This label is used only to access EOF actions. */
 
+/* %% [12.0] debug code goes here */
                if ( yy_flex_debug )
                        {
                        if ( yy_act == 0 )
                                fprintf( stderr, "--scanner backing up\n" );
                        else if ( yy_act < 13 )
-                               fprintf( stderr, "--accepting rule at line %d (\"%s\")\n",
-                                        yy_rule_linenum[yy_act], yytext );
+                               fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
+                                        (long)yy_rule_linenum[yy_act], yytext );
                        else if ( yy_act == 13 )
                                fprintf( stderr, "--accepting default rule (\"%s\")\n",
                                         yytext );
@@ -760,24 +993,28 @@ do_action:        /* This label is used only to access EOF actions. */
 
                switch ( yy_act )
        { /* beginning of action switch */
+/* %% [13.0] actions go here */
                        case 0: /* must back up */
                        /* undo the effects of YY_DO_BEFORE_ACTION */
-                       *yy_cp = yy_hold_char;
-                       yy_cp = yy_last_accepting_cpos;
-                       yy_current_state = yy_last_accepting_state;
+                       *yy_cp = (yy_hold_char);
+                       yy_cp = (yy_last_accepting_cpos);
+                       yy_current_state = (yy_last_accepting_state);
                        goto yy_find_action;
 
 case 1:
+/* rule 1 can match eol */
 YY_RULE_SETUP
 #line 69 "scripts/genksyms/lex.l"
 return FILENAME;
        YY_BREAK
 case 2:
+/* rule 2 can match eol */
 YY_RULE_SETUP
 #line 70 "scripts/genksyms/lex.l"
 cur_line++;
        YY_BREAK
 case 3:
+/* rule 3 can match eol */
 YY_RULE_SETUP
 #line 71 "scripts/genksyms/lex.l"
 cur_line++;
@@ -789,11 +1026,13 @@ YY_RULE_SETUP
 ;
        YY_BREAK
 case 5:
+/* rule 5 can match eol */
 YY_RULE_SETUP
 #line 77 "scripts/genksyms/lex.l"
 return STRING;
        YY_BREAK
 case 6:
+/* rule 6 can match eol */
 YY_RULE_SETUP
 #line 78 "scripts/genksyms/lex.l"
 return CHAR;
@@ -838,7 +1077,7 @@ YY_RULE_SETUP
 #line 95 "scripts/genksyms/lex.l"
 ECHO;
        YY_BREAK
-#line 842 "scripts/genksyms/lex.c"
+#line 1081 "scripts/genksyms/lex.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(V2_TOKENS):
        yyterminate();
@@ -846,26 +1085,26 @@ case YY_STATE_EOF(V2_TOKENS):
        case YY_END_OF_BUFFER:
                {
                /* Amount of text matched not including the EOB char. */
-               int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+               int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
 
                /* Undo the effects of YY_DO_BEFORE_ACTION. */
-               *yy_cp = yy_hold_char;
+               *yy_cp = (yy_hold_char);
                YY_RESTORE_YY_MORE_OFFSET
 
-               if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+               if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
                        {
                        /* We're scanning a new file or input source.  It's
                         * possible that this happened because the user
                         * just pointed yyin at a new source and called
                         * yylex().  If so, then we have to assure
-                        * consistency between yy_current_buffer and our
+                        * consistency between YY_CURRENT_BUFFER and our
                         * globals.  Here is the right place to do so, because
                         * this is the first action (other than possibly a
                         * back-up) that will match for the new input source.
                         */
-                       yy_n_chars = yy_current_buffer->yy_n_chars;
-                       yy_current_buffer->yy_input_file = yyin;
-                       yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+                       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+                       YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
                        }
 
                /* Note that here we test for yy_c_buf_p "<=" to the position
@@ -875,13 +1114,13 @@ case YY_STATE_EOF(V2_TOKENS):
                 * end-of-buffer state).  Contrast this with the test
                 * in input().
                 */
-               if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+               if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
                        { /* This was really a NUL. */
                        yy_state_type yy_next_state;
 
-                       yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+                       (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
 
-                       yy_current_state = yy_get_previous_state();
+                       yy_current_state = yy_get_previous_state(  );
 
                        /* Okay, we're now positioned to make the NUL
                         * transition.  We couldn't have
@@ -894,30 +1133,31 @@ case YY_STATE_EOF(V2_TOKENS):
 
                        yy_next_state = yy_try_NUL_trans( yy_current_state );
 
-                       yy_bp = yytext_ptr + YY_MORE_ADJ;
+                       yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 
                        if ( yy_next_state )
                                {
                                /* Consume the NUL. */
-                               yy_cp = ++yy_c_buf_p;
+                               yy_cp = ++(yy_c_buf_p);
                                yy_current_state = yy_next_state;
                                goto yy_match;
                                }
 
                        else
                                {
-                               yy_cp = yy_c_buf_p;
+/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
+                               yy_cp = (yy_c_buf_p);
                                goto yy_find_action;
                                }
                        }
 
-               else switch ( yy_get_next_buffer() )
+               else switch ( yy_get_next_buffer(  ) )
                        {
                        case EOB_ACT_END_OF_FILE:
                                {
-                               yy_did_buffer_switch_on_eof = 0;
+                               (yy_did_buffer_switch_on_eof) = 0;
 
-                               if ( yywrap() )
+                               if ( yywrap( ) )
                                        {
                                        /* Note: because we've taken care in
                                         * yy_get_next_buffer() to have set up
@@ -928,7 +1168,7 @@ case YY_STATE_EOF(V2_TOKENS):
                                         * YY_NULL, it'll still work - another
                                         * YY_NULL will get returned.
                                         */
-                                       yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+                                       (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
 
                                        yy_act = YY_STATE_EOF(YY_START);
                                        goto do_action;
@@ -936,30 +1176,30 @@ case YY_STATE_EOF(V2_TOKENS):
 
                                else
                                        {
-                                       if ( ! yy_did_buffer_switch_on_eof )
+                                       if ( ! (yy_did_buffer_switch_on_eof) )
                                                YY_NEW_FILE;
                                        }
                                break;
                                }
 
                        case EOB_ACT_CONTINUE_SCAN:
-                               yy_c_buf_p =
-                                       yytext_ptr + yy_amount_of_matched_text;
+                               (yy_c_buf_p) =
+                                       (yytext_ptr) + yy_amount_of_matched_text;
 
-                               yy_current_state = yy_get_previous_state();
+                               yy_current_state = yy_get_previous_state(  );
 
-                               yy_cp = yy_c_buf_p;
-                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               yy_cp = (yy_c_buf_p);
+                               yy_bp = (yytext_ptr) + YY_MORE_ADJ;
                                goto yy_match;
 
                        case EOB_ACT_LAST_MATCH:
-                               yy_c_buf_p =
-                               &yy_current_buffer->yy_ch_buf[yy_n_chars];
+                               (yy_c_buf_p) =
+                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
 
-                               yy_current_state = yy_get_previous_state();
+                               yy_current_state = yy_get_previous_state(  );
 
-                               yy_cp = yy_c_buf_p;
-                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               yy_cp = (yy_c_buf_p);
+                               yy_bp = (yytext_ptr) + YY_MORE_ADJ;
                                goto yy_find_action;
                        }
                break;
@@ -970,8 +1210,15 @@ case YY_STATE_EOF(V2_TOKENS):
                        "fatal flex scanner internal error--no action found" );
        } /* end of action switch */
                } /* end of scanning one token */
-       } /* end of yylex */
+} /* end of yylex */
+/* %ok-for-header */
 
+/* %if-c++-only */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
 
 /* yy_get_next_buffer - try to read in a new buffer
  *
@@ -980,21 +1227,24 @@ case YY_STATE_EOF(V2_TOKENS):
  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  *     EOB_ACT_END_OF_FILE - end of file
  */
-
-static int yy_get_next_buffer()
-       {
-       register char *dest = yy_current_buffer->yy_ch_buf;
-       register char *source = yytext_ptr;
+/* %if-c-only */
+static int yy_get_next_buffer (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+       register char *source = (yytext_ptr);
        register int number_to_move, i;
        int ret_val;
 
-       if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+       if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
                YY_FATAL_ERROR(
                "fatal flex scanner internal error--end of buffer missed" );
 
-       if ( yy_current_buffer->yy_fill_buffer == 0 )
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
                { /* Don't try to fill the buffer, so this is an EOF. */
-               if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+               if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
                        {
                        /* We matched a single character, the EOB, so
                         * treat this as a final EOF.
@@ -1014,34 +1264,30 @@ static int yy_get_next_buffer()
        /* Try to read more data. */
 
        /* First move last chars to start of buffer. */
-       number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+       number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
 
        for ( i = 0; i < number_to_move; ++i )
                *(dest++) = *(source++);
 
-       if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+       if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
                /* don't do the read, it's not guaranteed to return an EOF,
                 * just force an EOF
                 */
-               yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
 
        else
                {
-               int num_to_read =
-                       yy_current_buffer->yy_buf_size - number_to_move - 1;
+                       int num_to_read =
+                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 
                while ( num_to_read <= 0 )
                        { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
-                       YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
 
                        /* just a shorter name for the current buffer */
-                       YY_BUFFER_STATE b = yy_current_buffer;
+                       YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
 
                        int yy_c_buf_p_offset =
-                               (int) (yy_c_buf_p - b->yy_ch_buf);
+                               (int) ((yy_c_buf_p) - b->yy_ch_buf);
 
                        if ( b->yy_is_our_buffer )
                                {
@@ -1054,8 +1300,7 @@ static int yy_get_next_buffer()
 
                                b->yy_ch_buf = (char *)
                                        /* Include room in for 2 EOB chars. */
-                                       yy_flex_realloc( (void *) b->yy_ch_buf,
-                                                        b->yy_buf_size + 2 );
+                                       yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
                                }
                        else
                                /* Can't grow it, we don't own it. */
@@ -1065,35 +1310,35 @@ static int yy_get_next_buffer()
                                YY_FATAL_ERROR(
                                "fatal error - scanner input buffer overflow" );
 
-                       yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+                       (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
 
-                       num_to_read = yy_current_buffer->yy_buf_size -
+                       num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
                                                number_to_move - 1;
-#endif
+
                        }
 
                if ( num_to_read > YY_READ_BUF_SIZE )
                        num_to_read = YY_READ_BUF_SIZE;
 
                /* Read in more data. */
-               YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
-                       yy_n_chars, num_to_read );
+               YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+                       (yy_n_chars), (size_t) num_to_read );
 
-               yy_current_buffer->yy_n_chars = yy_n_chars;
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
                }
 
-       if ( yy_n_chars == 0 )
+       if ( (yy_n_chars) == 0 )
                {
                if ( number_to_move == YY_MORE_ADJ )
                        {
                        ret_val = EOB_ACT_END_OF_FILE;
-                       yyrestart( yyin );
+                       yyrestart(yyin  );
                        }
 
                else
                        {
                        ret_val = EOB_ACT_LAST_MATCH;
-                       yy_current_buffer->yy_buffer_status =
+                       YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
                                YY_BUFFER_EOF_PENDING;
                        }
                }
@@ -1101,33 +1346,40 @@ static int yy_get_next_buffer()
        else
                ret_val = EOB_ACT_CONTINUE_SCAN;
 
-       yy_n_chars += number_to_move;
-       yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
-       yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+       (yy_n_chars) += number_to_move;
+       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
 
-       yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+       (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
 
        return ret_val;
-       }
-
+}
 
 /* yy_get_previous_state - get the state just before the EOB char was reached */
 
-static yy_state_type yy_get_previous_state()
-       {
+/* %if-c-only */
+/* %not-for-header */
+
+    static yy_state_type yy_get_previous_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
        register yy_state_type yy_current_state;
        register char *yy_cp;
-
-       yy_current_state = yy_start;
+    
+/* %% [15.0] code to get the start state into yy_current_state goes here */
+       yy_current_state = (yy_start);
        yy_current_state += YY_AT_BOL();
 
-       for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+       for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
                {
+/* %% [16.0] code to find the next state goes here */
                register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
                if ( yy_accept[yy_current_state] )
                        {
-                       yy_last_accepting_state = yy_current_state;
-                       yy_last_accepting_cpos = yy_cp;
+                       (yy_last_accepting_state) = yy_current_state;
+                       (yy_last_accepting_cpos) = yy_cp;
                        }
                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                        {
@@ -1139,30 +1391,28 @@ static yy_state_type yy_get_previous_state()
                }
 
        return yy_current_state;
-       }
-
+}
 
 /* yy_try_NUL_trans - try to make a transition on the NUL character
  *
  * synopsis
  *     next_state = yy_try_NUL_trans( current_state );
  */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
-       {
+/* %if-c-only */
+    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
        register int yy_is_jam;
-       register char *yy_cp = yy_c_buf_p;
+    /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
+       register char *yy_cp = (yy_c_buf_p);
 
        register YY_CHAR yy_c = 1;
        if ( yy_accept[yy_current_state] )
                {
-               yy_last_accepting_state = yy_current_state;
-               yy_last_accepting_cpos = yy_cp;
+               (yy_last_accepting_state) = yy_current_state;
+               (yy_last_accepting_cpos) = yy_cp;
                }
        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
                {
@@ -1174,80 +1424,87 @@ yy_state_type yy_current_state;
        yy_is_jam = (yy_current_state == 75);
 
        return yy_is_jam ? 0 : yy_current_state;
-       }
+}
 
+/* %if-c-only */
 
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
-       {
-       register char *yy_cp = yy_c_buf_p;
+    static void yyunput (int c, register char * yy_bp )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       register char *yy_cp;
+    
+    yy_cp = (yy_c_buf_p);
 
        /* undo effects of setting up yytext */
-       *yy_cp = yy_hold_char;
+       *yy_cp = (yy_hold_char);
 
-       if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
                { /* need to shift things up to make room */
                /* +2 for EOB chars. */
-               register int number_to_move = yy_n_chars + 2;
-               register char *dest = &yy_current_buffer->yy_ch_buf[
-                                       yy_current_buffer->yy_buf_size + 2];
+               register int number_to_move = (yy_n_chars) + 2;
+               register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+                                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
                register char *source =
-                               &yy_current_buffer->yy_ch_buf[number_to_move];
+                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
 
-               while ( source > yy_current_buffer->yy_ch_buf )
+               while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
                        *--dest = *--source;
 
                yy_cp += (int) (dest - source);
                yy_bp += (int) (dest - source);
-               yy_current_buffer->yy_n_chars =
-                       yy_n_chars = yy_current_buffer->yy_buf_size;
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+                       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
 
-               if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+               if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
                        YY_FATAL_ERROR( "flex scanner push-back overflow" );
                }
 
        *--yy_cp = (char) c;
 
+/* %% [18.0] update yylineno here */
 
-       yytext_ptr = yy_bp;
-       yy_hold_char = *yy_cp;
-       yy_c_buf_p = yy_cp;
-       }
-#endif /* ifndef YY_NO_UNPUT */
+       (yytext_ptr) = yy_bp;
+       (yy_hold_char) = *yy_cp;
+       (yy_c_buf_p) = yy_cp;
+}
+/* %if-c-only */
 
+/* %endif */
 
+/* %if-c-only */
+#ifndef YY_NO_INPUT
 #ifdef __cplusplus
-static int yyinput()
+    static int yyinput (void)
 #else
-static int input()
+    static int input  (void)
 #endif
-       {
-       int c;
 
-       *yy_c_buf_p = yy_hold_char;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       int c;
+    
+       *(yy_c_buf_p) = (yy_hold_char);
 
-       if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+       if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
                {
                /* yy_c_buf_p now points to the character we want to return.
                 * If this occurs *before* the EOB characters, then it's a
                 * valid NUL; if not, then we've hit the end of the buffer.
                 */
-               if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+               if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
                        /* This was really a NUL. */
-                       *yy_c_buf_p = '\0';
+                       *(yy_c_buf_p) = '\0';
 
                else
                        { /* need more input */
-                       int offset = yy_c_buf_p - yytext_ptr;
-                       ++yy_c_buf_p;
+                       int offset = (yy_c_buf_p) - (yytext_ptr);
+                       ++(yy_c_buf_p);
 
-                       switch ( yy_get_next_buffer() )
+                       switch ( yy_get_next_buffer(  ) )
                                {
                                case EOB_ACT_LAST_MATCH:
                                        /* This happens because yy_g_n_b()
@@ -1261,16 +1518,16 @@ static int input()
                                         */
 
                                        /* Reset buffer status. */
-                                       yyrestart( yyin );
+                                       yyrestart(yyin );
 
-                                       /* fall through */
+                                       /*FALLTHROUGH*/
 
                                case EOB_ACT_END_OF_FILE:
                                        {
-                                       if ( yywrap() )
+                                       if ( yywrap( ) )
                                                return EOF;
 
-                                       if ( ! yy_did_buffer_switch_on_eof )
+                                       if ( ! (yy_did_buffer_switch_on_eof) )
                                                YY_NEW_FILE;
 #ifdef __cplusplus
                                        return yyinput();
@@ -1280,91 +1537,113 @@ static int input()
                                        }
 
                                case EOB_ACT_CONTINUE_SCAN:
-                                       yy_c_buf_p = yytext_ptr + offset;
+                                       (yy_c_buf_p) = (yytext_ptr) + offset;
                                        break;
                                }
                        }
                }
 
-       c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
-       *yy_c_buf_p = '\0';     /* preserve yytext */
-       yy_hold_char = *++yy_c_buf_p;
+       c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
+       *(yy_c_buf_p) = '\0';   /* preserve yytext */
+       (yy_hold_char) = *++(yy_c_buf_p);
 
-       yy_current_buffer->yy_at_bol = (c == '\n');
+/* %% [19.0] update BOL and yylineno */
+       YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
 
        return c;
+}
+/* %if-c-only */
+#endif /* ifndef YY_NO_INPUT */
+/* %endif */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * 
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+/* %if-c-only */
+    void yyrestart  (FILE * input_file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+       if ( ! YY_CURRENT_BUFFER ){
+        yyensure_buffer_stack ();
+               YY_CURRENT_BUFFER_LVALUE =
+            yy_create_buffer(yyin,YY_BUF_SIZE );
        }
 
+       yy_init_buffer(YY_CURRENT_BUFFER,input_file );
+       yy_load_buffer_state( );
+}
 
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
-       {
-       if ( ! yy_current_buffer )
-               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
-       yy_init_buffer( yy_current_buffer, input_file );
-       yy_load_buffer_state();
-       }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
-       {
-       if ( yy_current_buffer == new_buffer )
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * 
+ */
+/* %if-c-only */
+    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+       /* TODO. We should be able to replace this entire function body
+        * with
+        *              yypop_buffer_state();
+        *              yypush_buffer_state(new_buffer);
+     */
+       yyensure_buffer_stack ();
+       if ( YY_CURRENT_BUFFER == new_buffer )
                return;
 
-       if ( yy_current_buffer )
+       if ( YY_CURRENT_BUFFER )
                {
                /* Flush out information for old buffer. */
-               *yy_c_buf_p = yy_hold_char;
-               yy_current_buffer->yy_buf_pos = yy_c_buf_p;
-               yy_current_buffer->yy_n_chars = yy_n_chars;
+               *(yy_c_buf_p) = (yy_hold_char);
+               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
                }
 
-       yy_current_buffer = new_buffer;
-       yy_load_buffer_state();
+       YY_CURRENT_BUFFER_LVALUE = new_buffer;
+       yy_load_buffer_state( );
 
        /* We don't actually know whether we did this switch during
         * EOF (yywrap()) processing, but the only time this flag
         * is looked at is after yywrap() is called, so it's safe
         * to go ahead and always set it.
         */
-       yy_did_buffer_switch_on_eof = 1;
-       }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
-       {
-       yy_n_chars = yy_current_buffer->yy_n_chars;
-       yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
-       yyin = yy_current_buffer->yy_input_file;
-       yy_hold_char = *yy_c_buf_p;
-       }
+       (yy_did_buffer_switch_on_eof) = 1;
+}
 
+/* %if-c-only */
+static void yy_load_buffer_state  (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+       (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+       yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+       (yy_hold_char) = *(yy_c_buf_p);
+}
 
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
-       {
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * 
+ * @return the allocated buffer state.
+ */
+/* %if-c-only */
+    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
        YY_BUFFER_STATE b;
-
-       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+    
+       b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
        if ( ! b )
                YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
@@ -1373,75 +1652,99 @@ int size;
        /* yy_ch_buf has to be 2 characters longer than the size given because
         * we need to put in 2 end-of-buffer characters.
         */
-       b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+       b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
        if ( ! b->yy_ch_buf )
                YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
        b->yy_is_our_buffer = 1;
 
-       yy_init_buffer( b, file );
+       yy_init_buffer(b,file );
 
        return b;
-       }
-
+}
 
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-       {
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ * 
+ */
+/* %if-c-only */
+    void yy_delete_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
        if ( ! b )
                return;
 
-       if ( b == yy_current_buffer )
-               yy_current_buffer = (YY_BUFFER_STATE) 0;
+       if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+               YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
 
        if ( b->yy_is_our_buffer )
-               yy_flex_free( (void *) b->yy_ch_buf );
+               yyfree((void *) b->yy_ch_buf  );
 
-       yy_flex_free( (void *) b );
-       }
+       yyfree((void *) b  );
+}
 
+/* %if-c-only */
 
+#ifndef __cplusplus
+extern int isatty (int );
+#endif /* __cplusplus */
+    
+/* %endif */
 
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
+/* %if-c++-only */
+/* %endif */
 
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+/* %if-c-only */
+    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
 
-       {
-       yy_flush_buffer( b );
+{
+       int oerrno = errno;
+    
+       yy_flush_buffer(b );
 
        b->yy_input_file = file;
        b->yy_fill_buffer = 1;
 
-#if YY_ALWAYS_INTERACTIVE
-       b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
-       b->yy_is_interactive = 0;
-#else
-       b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
-       }
+    /* If b is the current buffer, then yy_init_buffer was _probably_
+     * called from yyrestart() or through yy_get_next_buffer.
+     * In that case, we don't want to reset the lineno or column.
+     */
+    if (b != YY_CURRENT_BUFFER){
+        b->yy_bs_lineno = 1;
+        b->yy_bs_column = 0;
+    }
 
+/* %if-c-only */
 
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
+        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+    
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+       errno = oerrno;
+}
 
-       {
-       if ( ! b )
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * 
+ */
+/* %if-c-only */
+    void yy_flush_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       if ( ! b )
                return;
 
        b->yy_n_chars = 0;
@@ -1458,29 +1761,140 @@ YY_BUFFER_STATE b;
        b->yy_at_bol = 1;
        b->yy_buffer_status = YY_BUFFER_NEW;
 
-       if ( b == yy_current_buffer )
-               yy_load_buffer_state();
+       if ( b == YY_CURRENT_BUFFER )
+               yy_load_buffer_state( );
+}
+
+/* %if-c-or-c++ */
+/** Pushes the new state onto the stack. The new state becomes
+ *  the current state. This function will allocate the stack
+ *  if necessary.
+ *  @param new_buffer The new state.
+ *  
+ */
+/* %if-c-only */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       if (new_buffer == NULL)
+               return;
+
+       yyensure_buffer_stack();
+
+       /* This block is copied from yy_switch_to_buffer. */
+       if ( YY_CURRENT_BUFFER )
+               {
+               /* Flush out information for old buffer. */
+               *(yy_c_buf_p) = (yy_hold_char);
+               YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+               YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+               }
+
+       /* Only push if top exists. Otherwise, replace top. */
+       if (YY_CURRENT_BUFFER)
+               (yy_buffer_stack_top)++;
+       YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+       /* copied from yy_switch_to_buffer. */
+       yy_load_buffer_state( );
+       (yy_did_buffer_switch_on_eof) = 1;
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/** Removes and deletes the top of the stack, if present.
+ *  The next element becomes the new top.
+ *  
+ */
+/* %if-c-only */
+void yypop_buffer_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       if (!YY_CURRENT_BUFFER)
+               return;
+
+       yy_delete_buffer(YY_CURRENT_BUFFER );
+       YY_CURRENT_BUFFER_LVALUE = NULL;
+       if ((yy_buffer_stack_top) > 0)
+               --(yy_buffer_stack_top);
+
+       if (YY_CURRENT_BUFFER) {
+               yy_load_buffer_state( );
+               (yy_did_buffer_switch_on_eof) = 1;
        }
+}
+/* %endif */
 
+/* %if-c-or-c++ */
+/* Allocates the stack if it does not exist.
+ *  Guarantees space for at least one push.
+ */
+/* %if-c-only */
+static void yyensure_buffer_stack (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+       int num_to_alloc;
+    
+       if (!(yy_buffer_stack)) {
+
+               /* First allocation is just for 2 elements, since we don't know if this
+                * scanner will even need a stack. We use 2 instead of 1 to avoid an
+                * immediate realloc on the next call.
+         */
+               num_to_alloc = 1;
+               (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+                                                               (num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                               );
+               
+               memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+                               
+               (yy_buffer_stack_max) = num_to_alloc;
+               (yy_buffer_stack_top) = 0;
+               return;
+       }
 
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
-       {
-       YY_BUFFER_STATE b;
+       if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+               /* Increase the buffer to prepare for a possible push. */
+               int grow_size = 8 /* arbitrary grow size */;
 
+               num_to_alloc = (yy_buffer_stack_max) + grow_size;
+               (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+                                                               ((yy_buffer_stack),
+                                                               num_to_alloc * sizeof(struct yy_buffer_state*)
+                                                               );
+
+               /* zero only the new slots.*/
+               memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+               (yy_buffer_stack_max) = num_to_alloc;
+       }
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * 
+ * @return the newly allocated buffer state object. 
+ */
+YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
+{
+       YY_BUFFER_STATE b;
+    
        if ( size < 2 ||
             base[size-2] != YY_END_OF_BUFFER_CHAR ||
             base[size-1] != YY_END_OF_BUFFER_CHAR )
                /* They forgot to leave room for the EOB's. */
                return 0;
 
-       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+       b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
        if ( ! b )
                YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
 
@@ -1494,56 +1908,55 @@ yy_size_t size;
        b->yy_fill_buffer = 0;
        b->yy_buffer_status = YY_BUFFER_NEW;
 
-       yy_switch_to_buffer( b );
+       yy_switch_to_buffer(b  );
 
        return b;
-       }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
-       {
-       int len;
-       for ( len = 0; yy_str[len]; ++len )
-               ;
-
-       return yy_scan_bytes( yy_str, len );
-       }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
-       {
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ * 
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ *       yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+{
+    
+       return yy_scan_bytes(yystr,strlen(yystr) );
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * 
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
+{
        YY_BUFFER_STATE b;
        char *buf;
        yy_size_t n;
        int i;
-
+    
        /* Get memory for full buffer, including space for trailing EOB's. */
-       n = len + 2;
-       buf = (char *) yy_flex_alloc( n );
+       n = _yybytes_len + 2;
+       buf = (char *) yyalloc(n  );
        if ( ! buf )
                YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
 
-       for ( i = 0; i < len; ++i )
-               buf[i] = bytes[i];
+       for ( i = 0; i < _yybytes_len; ++i )
+               buf[i] = yybytes[i];
 
-       buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+       buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
 
-       b = yy_scan_buffer( buf, n );
+       b = yy_scan_buffer(buf,n );
        if ( ! b )
                YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
 
@@ -1553,148 +1966,231 @@ int len;
        b->yy_is_our_buffer = 1;
 
        return b;
-       }
+}
+/* %endif */
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
 #endif
 
+/* %if-c-only */
+static void yy_fatal_error (yyconst char* msg )
+{
+       (void) fprintf( stderr, "%s\n", msg );
+       exit( YY_EXIT_FAILURE );
+}
+/* %endif */
+/* %if-c++-only */
+/* %endif */
 
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
-       {
-       if ( yy_start_stack_ptr >= yy_start_stack_depth )
-               {
-               yy_size_t new_size;
+/* Redefine yyless() so it works in section 3 code. */
 
-               yy_start_stack_depth += YY_START_STACK_INCR;
-               new_size = yy_start_stack_depth * sizeof( int );
+#undef yyless
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+               yytext[yyleng] = (yy_hold_char); \
+               (yy_c_buf_p) = yytext + yyless_macro_arg; \
+               (yy_hold_char) = *(yy_c_buf_p); \
+               *(yy_c_buf_p) = '\0'; \
+               yyleng = yyless_macro_arg; \
+               } \
+       while ( 0 )
 
-               if ( ! yy_start_stack )
-                       yy_start_stack = (int *) yy_flex_alloc( new_size );
+/* Accessor  methods (get/set functions) to struct members. */
 
-               else
-                       yy_start_stack = (int *) yy_flex_realloc(
-                                       (void *) yy_start_stack, new_size );
+/* %if-c-only */
+/* %if-reentrant */
+/* %endif */
 
-               if ( ! yy_start_stack )
-                       YY_FATAL_ERROR(
-                       "out of memory expanding start-condition stack" );
-               }
+/** Get the current line number.
+ * 
+ */
+int yyget_lineno  (void)
+{
+        
+    return yylineno;
+}
 
-       yy_start_stack[yy_start_stack_ptr++] = YY_START;
+/** Get the input stream.
+ * 
+ */
+FILE *yyget_in  (void)
+{
+        return yyin;
+}
 
-       BEGIN(new_state);
-       }
-#endif
+/** Get the output stream.
+ * 
+ */
+FILE *yyget_out  (void)
+{
+        return yyout;
+}
 
+/** Get the length of the current token.
+ * 
+ */
+int yyget_leng  (void)
+{
+        return yyleng;
+}
 
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
-       {
-       if ( --yy_start_stack_ptr < 0 )
-               YY_FATAL_ERROR( "start-condition stack underflow" );
+/** Get the current token.
+ * 
+ */
 
-       BEGIN(yy_start_stack[yy_start_stack_ptr]);
-       }
-#endif
+char *yyget_text  (void)
+{
+        return yytext;
+}
 
+/* %if-reentrant */
+/* %endif */
 
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
-       {
-       return yy_start_stack[yy_start_stack_ptr - 1];
-       }
-#endif
+/** Set the current line number.
+ * @param line_number
+ * 
+ */
+void yyset_lineno (int  line_number )
+{
+    
+    yylineno = line_number;
+}
 
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * 
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE *  in_str )
+{
+        yyin = in_str ;
+}
+
+void yyset_out (FILE *  out_str )
+{
+        yyout = out_str ;
+}
+
+int yyget_debug  (void)
+{
+        return yy_flex_debug;
+}
 
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
+void yyset_debug (int  bdebug )
+{
+        yy_flex_debug = bdebug ;
+}
+
+/* %endif */
+
+/* %if-reentrant */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif */
+
+/* %if-c-only */
+static int yy_init_globals (void)
+{
+        /* Initialization is the same as for the non-reentrant scanner.
+     * This function is called from yylex_destroy(), so don't allocate here.
+     */
+
+    (yy_buffer_stack) = 0;
+    (yy_buffer_stack_top) = 0;
+    (yy_buffer_stack_max) = 0;
+    (yy_c_buf_p) = (char *) 0;
+    (yy_init) = 0;
+    (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+    yyin = stdin;
+    yyout = stdout;
 #else
-static void yy_fatal_error( msg )
-char msg[];
+    yyin = (FILE *) 0;
+    yyout = (FILE *) 0;
 #endif
-       {
-       (void) fprintf( stderr, "%s\n", msg );
-       exit( YY_EXIT_FAILURE );
+
+    /* For future reference: Set errno on error, since we are called by
+     * yylex_init()
+     */
+    return 0;
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/* %if-c-only */
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy  (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+    /* Pop the buffer stack, destroying each element. */
+       while(YY_CURRENT_BUFFER){
+               yy_delete_buffer(YY_CURRENT_BUFFER  );
+               YY_CURRENT_BUFFER_LVALUE = NULL;
+               yypop_buffer_state();
        }
 
+       /* Destroy the stack itself. */
+       yyfree((yy_buffer_stack) );
+       (yy_buffer_stack) = NULL;
 
+/* %if-c++-only */
+/* %endif */
 
-/* Redefine yyless() so it works in section 3 code. */
+/* %if-c-only */
 
-#undef yyless
-#define yyless(n) \
-       do \
-               { \
-               /* Undo effects of setting up yytext. */ \
-               yytext[yyleng] = yy_hold_char; \
-               yy_c_buf_p = yytext + n; \
-               yy_hold_char = *yy_c_buf_p; \
-               *yy_c_buf_p = '\0'; \
-               yyleng = n; \
-               } \
-       while ( 0 )
+    /* Reset the globals. This is important in a non-reentrant scanner so the next time
+     * yylex() is called, initialization will occur. */
+    yy_init_globals( );
 
+/* %if-reentrant */
+/* %endif */
+    return 0;
+/* %endif */
+}
+/* %endif */
 
-/* Internal utility routines. */
+/*
+ * Internal utility routines.
+ */
 
 #ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
-       {
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
        register int i;
        for ( i = 0; i < n; ++i )
                s1[i] = s2[i];
-       }
+}
 #endif
 
 #ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
-       {
+static int yy_flex_strlen (yyconst char * s )
+{
        register int n;
        for ( n = 0; s[n]; ++n )
                ;
 
        return n;
-       }
+}
 #endif
 
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
-       {
+void *yyalloc (yy_size_t  size )
+{
        return (void *) malloc( size );
-       }
+}
 
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
-       {
+void *yyrealloc  (void * ptr, yy_size_t  size )
+{
        /* The cast to (char *) in the following accommodates both
         * implementations that use char* generic pointers, and those
         * that use void* generic pointers.  It works with the latter
@@ -1703,28 +2199,24 @@ yy_size_t size;
         * as though doing an assignment.
         */
        return (void *) realloc( (char *) ptr, size );
-       }
+}
 
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
-       {
-       free( ptr );
-       }
+void yyfree (void * ptr )
+{
+       free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
+}
+
+/* %if-tables-serialization definitions */
+/* %define-yytables   The name for this specific scanner's tables. */
+#define YYTABLES_NAME "yytables"
+/* %endif */
+
+/* %ok-for-header */
 
-#if YY_MAIN
-int main()
-       {
-       yylex();
-       return 0;
-       }
-#endif
 #line 95 "scripts/genksyms/lex.l"
 
 
+
 /* Bring in the keyword recognizer.  */
 
 #include "keywords.c"
@@ -2036,10 +2528,12 @@ fini:
 
   return token;
 }
-/* A Bison parser, made by GNU Bison 2.0.  */
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
 
-/* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -2053,13 +2547,21 @@ fini:
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-/* As a special exception, when this file is copied by Bison into a
-   Bison output file, you may use that output file without restriction.
-   This special exception was added by the Free Software Foundation
-   in version 1.24 of Bison.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
 
 /* Tokens.  */
 #ifndef YYTOKENTYPE
@@ -2076,39 +2578,41 @@ fini:
      DOUBLE_KEYW = 264,
      ENUM_KEYW = 265,
      EXTERN_KEYW = 266,
-     FLOAT_KEYW = 267,
-     INLINE_KEYW = 268,
-     INT_KEYW = 269,
-     LONG_KEYW = 270,
-     REGISTER_KEYW = 271,
-     RESTRICT_KEYW = 272,
-     SHORT_KEYW = 273,
-     SIGNED_KEYW = 274,
-     STATIC_KEYW = 275,
-     STRUCT_KEYW = 276,
-     TYPEDEF_KEYW = 277,
-     UNION_KEYW = 278,
-     UNSIGNED_KEYW = 279,
-     VOID_KEYW = 280,
-     VOLATILE_KEYW = 281,
-     TYPEOF_KEYW = 282,
-     EXPORT_SYMBOL_KEYW = 283,
-     ASM_PHRASE = 284,
-     ATTRIBUTE_PHRASE = 285,
-     BRACE_PHRASE = 286,
-     BRACKET_PHRASE = 287,
-     EXPRESSION_PHRASE = 288,
-     CHAR = 289,
-     DOTS = 290,
-     IDENT = 291,
-     INT = 292,
-     REAL = 293,
-     STRING = 294,
-     TYPE = 295,
-     OTHER = 296,
-     FILENAME = 297
+     EXTENSION_KEYW = 267,
+     FLOAT_KEYW = 268,
+     INLINE_KEYW = 269,
+     INT_KEYW = 270,
+     LONG_KEYW = 271,
+     REGISTER_KEYW = 272,
+     RESTRICT_KEYW = 273,
+     SHORT_KEYW = 274,
+     SIGNED_KEYW = 275,
+     STATIC_KEYW = 276,
+     STRUCT_KEYW = 277,
+     TYPEDEF_KEYW = 278,
+     UNION_KEYW = 279,
+     UNSIGNED_KEYW = 280,
+     VOID_KEYW = 281,
+     VOLATILE_KEYW = 282,
+     TYPEOF_KEYW = 283,
+     EXPORT_SYMBOL_KEYW = 284,
+     ASM_PHRASE = 285,
+     ATTRIBUTE_PHRASE = 286,
+     BRACE_PHRASE = 287,
+     BRACKET_PHRASE = 288,
+     EXPRESSION_PHRASE = 289,
+     CHAR = 290,
+     DOTS = 291,
+     IDENT = 292,
+     INT = 293,
+     REAL = 294,
+     STRING = 295,
+     TYPE = 296,
+     OTHER = 297,
+     FILENAME = 298
    };
 #endif
+/* Tokens.  */
 #define ASM_KEYW 258
 #define ATTRIBUTE_KEYW 259
 #define AUTO_KEYW 260
@@ -2118,42 +2622,43 @@ fini:
 #define DOUBLE_KEYW 264
 #define ENUM_KEYW 265
 #define EXTERN_KEYW 266
-#define FLOAT_KEYW 267
-#define INLINE_KEYW 268
-#define INT_KEYW 269
-#define LONG_KEYW 270
-#define REGISTER_KEYW 271
-#define RESTRICT_KEYW 272
-#define SHORT_KEYW 273
-#define SIGNED_KEYW 274
-#define STATIC_KEYW 275
-#define STRUCT_KEYW 276
-#define TYPEDEF_KEYW 277
-#define UNION_KEYW 278
-#define UNSIGNED_KEYW 279
-#define VOID_KEYW 280
-#define VOLATILE_KEYW 281
-#define TYPEOF_KEYW 282
-#define EXPORT_SYMBOL_KEYW 283
-#define ASM_PHRASE 284
-#define ATTRIBUTE_PHRASE 285
-#define BRACE_PHRASE 286
-#define BRACKET_PHRASE 287
-#define EXPRESSION_PHRASE 288
-#define CHAR 289
-#define DOTS 290
-#define IDENT 291
-#define INT 292
-#define REAL 293
-#define STRING 294
-#define TYPE 295
-#define OTHER 296
-#define FILENAME 297
-
-
-
-
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#define EXTENSION_KEYW 267
+#define FLOAT_KEYW 268
+#define INLINE_KEYW 269
+#define INT_KEYW 270
+#define LONG_KEYW 271
+#define REGISTER_KEYW 272
+#define RESTRICT_KEYW 273
+#define SHORT_KEYW 274
+#define SIGNED_KEYW 275
+#define STATIC_KEYW 276
+#define STRUCT_KEYW 277
+#define TYPEDEF_KEYW 278
+#define UNION_KEYW 279
+#define UNSIGNED_KEYW 280
+#define VOID_KEYW 281
+#define VOLATILE_KEYW 282
+#define TYPEOF_KEYW 283
+#define EXPORT_SYMBOL_KEYW 284
+#define ASM_PHRASE 285
+#define ATTRIBUTE_PHRASE 286
+#define BRACE_PHRASE 287
+#define BRACKET_PHRASE 288
+#define EXPRESSION_PHRASE 289
+#define CHAR 290
+#define DOTS 291
+#define IDENT 292
+#define INT 293
+#define REAL 294
+#define STRING 295
+#define TYPE 296
+#define OTHER 297
+#define FILENAME 298
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef int YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -2163,4 +2668,3 @@ typedef int YYSTYPE;
 extern YYSTYPE yylval;
 
 
-
index 99d7c25..3e6079f 100644 (file)
@@ -1,7 +1,9 @@
-/* A Bison parser, made by GNU Bison 2.0.  */
+/* A Bison parser, made by GNU Bison 2.3.  */
 
-/* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
 
-/* As a special exception, when this file is copied by Bison into a
-   Bison output file, you may use that output file without restriction.
-   This special exception was added by the Free Software Foundation
-   in version 1.24 of Bison.  */
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
 
-/* Written by Richard Stallman by simplifying the original so called
-   ``semantic'' parser.  */
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+   simplifying the original so-called "semantic" parser.  */
 
 /* All symbols defined below should begin with yy or YY, to avoid
    infringing on user name space.  This should be done even for local
@@ -36,6 +46,9 @@
 /* Identify Bison output.  */
 #define YYBISON 1
 
+/* Bison version.  */
+#define YYBISON_VERSION "2.3"
+
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
 
      DOUBLE_KEYW = 264,
      ENUM_KEYW = 265,
      EXTERN_KEYW = 266,
-     FLOAT_KEYW = 267,
-     INLINE_KEYW = 268,
-     INT_KEYW = 269,
-     LONG_KEYW = 270,
-     REGISTER_KEYW = 271,
-     RESTRICT_KEYW = 272,
-     SHORT_KEYW = 273,
-     SIGNED_KEYW = 274,
-     STATIC_KEYW = 275,
-     STRUCT_KEYW = 276,
-     TYPEDEF_KEYW = 277,
-     UNION_KEYW = 278,
-     UNSIGNED_KEYW = 279,
-     VOID_KEYW = 280,
-     VOLATILE_KEYW = 281,
-     TYPEOF_KEYW = 282,
-     EXPORT_SYMBOL_KEYW = 283,
-     ASM_PHRASE = 284,
-     ATTRIBUTE_PHRASE = 285,
-     BRACE_PHRASE = 286,
-     BRACKET_PHRASE = 287,
-     EXPRESSION_PHRASE = 288,
-     CHAR = 289,
-     DOTS = 290,
-     IDENT = 291,
-     INT = 292,
-     REAL = 293,
-     STRING = 294,
-     TYPE = 295,
-     OTHER = 296,
-     FILENAME = 297
+     EXTENSION_KEYW = 267,
+     FLOAT_KEYW = 268,
+     INLINE_KEYW = 269,
+     INT_KEYW = 270,
+     LONG_KEYW = 271,
+     REGISTER_KEYW = 272,
+     RESTRICT_KEYW = 273,
+     SHORT_KEYW = 274,
+     SIGNED_KEYW = 275,
+     STATIC_KEYW = 276,
+     STRUCT_KEYW = 277,
+     TYPEDEF_KEYW = 278,
+     UNION_KEYW = 279,
+     UNSIGNED_KEYW = 280,
+     VOID_KEYW = 281,
+     VOLATILE_KEYW = 282,
+     TYPEOF_KEYW = 283,
+     EXPORT_SYMBOL_KEYW = 284,
+     ASM_PHRASE = 285,
+     ATTRIBUTE_PHRASE = 286,
+     BRACE_PHRASE = 287,
+     BRACKET_PHRASE = 288,
+     EXPRESSION_PHRASE = 289,
+     CHAR = 290,
+     DOTS = 291,
+     IDENT = 292,
+     INT = 293,
+     REAL = 294,
+     STRING = 295,
+     TYPE = 296,
+     OTHER = 297,
+     FILENAME = 298
    };
 #endif
+/* Tokens.  */
 #define ASM_KEYW 258
 #define ATTRIBUTE_KEYW 259
 #define AUTO_KEYW 260
 #define DOUBLE_KEYW 264
 #define ENUM_KEYW 265
 #define EXTERN_KEYW 266
-#define FLOAT_KEYW 267
-#define INLINE_KEYW 268
-#define INT_KEYW 269
-#define LONG_KEYW 270
-#define REGISTER_KEYW 271
-#define RESTRICT_KEYW 272
-#define SHORT_KEYW 273
-#define SIGNED_KEYW 274
-#define STATIC_KEYW 275
-#define STRUCT_KEYW 276
-#define TYPEDEF_KEYW 277
-#define UNION_KEYW 278
-#define UNSIGNED_KEYW 279
-#define VOID_KEYW 280
-#define VOLATILE_KEYW 281
-#define TYPEOF_KEYW 282
-#define EXPORT_SYMBOL_KEYW 283
-#define ASM_PHRASE 284
-#define ATTRIBUTE_PHRASE 285
-#define BRACE_PHRASE 286
-#define BRACKET_PHRASE 287
-#define EXPRESSION_PHRASE 288
-#define CHAR 289
-#define DOTS 290
-#define IDENT 291
-#define INT 292
-#define REAL 293
-#define STRING 294
-#define TYPE 295
-#define OTHER 296
-#define FILENAME 297
+#define EXTENSION_KEYW 267
+#define FLOAT_KEYW 268
+#define INLINE_KEYW 269
+#define INT_KEYW 270
+#define LONG_KEYW 271
+#define REGISTER_KEYW 272
+#define RESTRICT_KEYW 273
+#define SHORT_KEYW 274
+#define SIGNED_KEYW 275
+#define STATIC_KEYW 276
+#define STRUCT_KEYW 277
+#define TYPEDEF_KEYW 278
+#define UNION_KEYW 279
+#define UNSIGNED_KEYW 280
+#define VOID_KEYW 281
+#define VOLATILE_KEYW 282
+#define TYPEOF_KEYW 283
+#define EXPORT_SYMBOL_KEYW 284
+#define ASM_PHRASE 285
+#define ATTRIBUTE_PHRASE 286
+#define BRACE_PHRASE 287
+#define BRACKET_PHRASE 288
+#define EXPRESSION_PHRASE 289
+#define CHAR 290
+#define DOTS 291
+#define IDENT 292
+#define INT 293
+#define REAL 294
+#define STRING 295
+#define TYPE 296
+#define OTHER 297
+#define FILENAME 298
 
 
 
@@ -185,7 +201,12 @@ remove_list(struct string_list **pb, struct string_list **pe)
 # define YYERROR_VERBOSE 0
 #endif
 
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef int YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -197,17 +218,94 @@ typedef int YYSTYPE;
 /* Copy the second part of user declarations.  */
 
 
-/* Line 213 of yacc.c.  */
-#line 202 "scripts/genksyms/parse.c"
+/* Line 216 of yacc.c.  */
+#line 223 "scripts/genksyms/parse.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+#  define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+#  define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
+# else
+#  define YYSIZE_T unsigned int
+# endif
+#endif
 
-#if ! defined (yyoverflow) || YYERROR_VERBOSE
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
 
-# ifndef YYFREE
-#  define YYFREE free
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
 # endif
-# ifndef YYMALLOC
-#  define YYMALLOC malloc
+# ifndef YY_
+#  define YY_(msgid) msgid
 # endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions.  */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+    int i;
+#endif
+{
+  return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
 
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
 
@@ -215,34 +313,76 @@ typedef int YYSTYPE;
 #  if YYSTACK_USE_ALLOCA
 #   ifdef __GNUC__
 #    define YYSTACK_ALLOC __builtin_alloca
+#   elif defined __BUILTIN_VA_ARG_INCR
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+#   elif defined _AIX
+#    define YYSTACK_ALLOC __alloca
+#   elif defined _MSC_VER
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+#    define alloca _alloca
 #   else
 #    define YYSTACK_ALLOC alloca
+#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#     ifndef _STDLIB_H
+#      define _STDLIB_H 1
+#     endif
+#    endif
 #   endif
 #  endif
 # endif
 
 # ifdef YYSTACK_ALLOC
-   /* Pacify GCC's `empty if-body' warning. */
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# else
-#  if defined (__STDC__) || defined (__cplusplus)
-#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#   define YYSIZE_T size_t
+   /* Pacify GCC's `empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+    /* The OS might guarantee only one guard page at the bottom of the stack,
+       and a page size can be as small as 4096 bytes.  So we cannot safely
+       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
+       to allow for a few compiler-allocated temporary stack slots.  */
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
 #  endif
+# else
 #  define YYSTACK_ALLOC YYMALLOC
 #  define YYSTACK_FREE YYFREE
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+#  endif
+#  if (defined __cplusplus && ! defined _STDLIB_H \
+       && ! ((defined YYMALLOC || defined malloc) \
+            && (defined YYFREE || defined free)))
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   ifndef _STDLIB_H
+#    define _STDLIB_H 1
+#   endif
+#  endif
+#  ifndef YYMALLOC
+#   define YYMALLOC malloc
+#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifndef YYFREE
+#   define YYFREE free
+#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
 # endif
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
 
 
-#if (! defined (yyoverflow) \
-     && (! defined (__cplusplus) \
-        || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
+#if (! defined yyoverflow \
+     && (! defined __cplusplus \
+        || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
 {
-  short int yyss;
+  yytype_int16 yyss;
   YYSTYPE yyvs;
   };
 
@@ -252,24 +392,24 @@ union yyalloc
 /* The size of an array large to enough to hold all stacks, each with
    N elements.  */
 # define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (short int) + sizeof (YYSTYPE))                    \
+     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
       + YYSTACK_GAP_MAXIMUM)
 
 /* Copy COUNT objects from FROM to TO.  The source and destination do
    not overlap.  */
 # ifndef YYCOPY
-#  if defined (__GNUC__) && 1 < __GNUC__
+#  if defined __GNUC__ && 1 < __GNUC__
 #   define YYCOPY(To, From, Count) \
       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
 #  else
 #   define YYCOPY(To, From, Count)             \
       do                                       \
        {                                       \
-         register YYSIZE_T yyi;                \
+         YYSIZE_T yyi;                         \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (To)[yyi] = (From)[yyi];            \
        }                                       \
-      while (0)
+      while (YYID (0))
 #  endif
 # endif
 
@@ -287,53 +427,47 @@ union yyalloc
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
        yyptr += yynewbytes / sizeof (*yyptr);                          \
       }                                                                        \
-    while (0)
+    while (YYID (0))
 
 #endif
 
-#if defined (__STDC__) || defined (__cplusplus)
-   typedef signed char yysigned_char;
-#else
-   typedef short int yysigned_char;
-#endif
-
-/* YYFINAL -- State number of the termination state. */
+/* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  4
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   535
+#define YYLAST   523
 
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS  52
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS  45
-/* YYNRULES -- Number of rules. */
-#define YYNRULES  124
-/* YYNRULES -- Number of states. */
-#define YYNSTATES  174
+/* YYNTOKENS -- Number of terminals.  */
+#define YYNTOKENS  53
+/* YYNNTS -- Number of nonterminals.  */
+#define YYNNTS  46
+/* YYNRULES -- Number of rules.  */
+#define YYNRULES  126
+/* YYNRULES -- Number of states.  */
+#define YYNSTATES  178
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   297
+#define YYMAXUTOK   298
 
-#define YYTRANSLATE(YYX)                                               \
+#define YYTRANSLATE(YYX)                                               \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
-static const unsigned char yytranslate[] =
+static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-      46,    48,    47,     2,    45,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,    51,    43,
-       2,    49,     2,     2,     2,     2,     2,     2,     2,     2,
+      47,    49,    48,     2,    46,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,    52,    44,
+       2,    50,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,    50,     2,    44,     2,     2,     2,     2,
+       2,     2,     2,    51,     2,    45,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -350,114 +484,116 @@ static const unsigned char yytranslate[] =
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
-      35,    36,    37,    38,    39,    40,    41,    42
+      35,    36,    37,    38,    39,    40,    41,    42,    43
 };
 
 #if YYDEBUG
 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const unsigned short int yyprhs[] =
+static const yytype_uint16 yyprhs[] =
 {
-       0,     0,     3,     5,     8,     9,    12,    13,    17,    19,
-      21,    23,    25,    28,    31,    35,    36,    38,    40,    44,
-      49,    50,    52,    54,    57,    59,    61,    63,    65,    67,
-      69,    71,    73,    75,    81,    86,    89,    92,    95,    99,
-     103,   107,   110,   113,   116,   118,   120,   122,   124,   126,
-     128,   130,   132,   134,   136,   138,   141,   142,   144,   146,
-     149,   151,   153,   155,   157,   160,   162,   164,   169,   174,
-     177,   181,   185,   188,   190,   192,   194,   199,   204,   207,
-     211,   215,   218,   220,   224,   225,   227,   229,   233,   236,
-     239,   241,   242,   244,   246,   251,   256,   259,   263,   267,
-     271,   272,   274,   277,   281,   285,   286,   288,   290,   293,
-     297,   300,   301,   303,   305,   309,   312,   315,   317,   320,
-     321,   323,   326,   327,   329
+       0,     0,     3,     5,     8,     9,    12,    13,    18,    19,
+      23,    25,    27,    29,    31,    34,    37,    41,    42,    44,
+      46,    50,    55,    56,    58,    60,    63,    65,    67,    69,
+      71,    73,    75,    77,    79,    81,    87,    92,    95,    98,
+     101,   105,   109,   113,   116,   119,   122,   124,   126,   128,
+     130,   132,   134,   136,   138,   140,   142,   144,   147,   148,
+     150,   152,   155,   157,   159,   161,   163,   166,   168,   170,
+     175,   180,   183,   187,   191,   194,   196,   198,   200,   205,
+     210,   213,   217,   221,   224,   226,   230,   231,   233,   235,
+     239,   242,   245,   247,   248,   250,   252,   257,   262,   265,
+     269,   273,   277,   278,   280,   283,   287,   291,   292,   294,
+     296,   299,   303,   306,   307,   309,   311,   315,   318,   321,
+     323,   326,   327,   329,   332,   333,   335
 };
 
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yysigned_char yyrhs[] =
+/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+static const yytype_int8 yyrhs[] =
 {
-      53,     0,    -1,    54,    -1,    53,    54,    -1,    -1,    55,
-      56,    -1,    -1,    22,    57,    58,    -1,    58,    -1,    82,
-      -1,    94,    -1,    96,    -1,     1,    43,    -1,     1,    44,
-      -1,    62,    59,    43,    -1,    -1,    60,    -1,    61,    -1,
-      60,    45,    61,    -1,    72,    95,    93,    83,    -1,    -1,
-      63,    -1,    64,    -1,    63,    64,    -1,    65,    -1,    66,
-      -1,     5,    -1,    16,    -1,    20,    -1,    11,    -1,    13,
-      -1,    67,    -1,    71,    -1,    27,    46,    63,    47,    48,
-      -1,    27,    46,    63,    48,    -1,    21,    36,    -1,    23,
-      36,    -1,    10,    36,    -1,    21,    36,    85,    -1,    23,
-      36,    85,    -1,    10,    36,    31,    -1,    10,    31,    -1,
-      21,    85,    -1,    23,    85,    -1,     7,    -1,    18,    -1,
-      14,    -1,    15,    -1,    19,    -1,    24,    -1,    12,    -1,
-       9,    -1,    25,    -1,     6,    -1,    40,    -1,    47,    69,
-      -1,    -1,    70,    -1,    71,    -1,    70,    71,    -1,     8,
-      -1,    26,    -1,    30,    -1,    17,    -1,    68,    72,    -1,
-      73,    -1,    36,    -1,    73,    46,    76,    48,    -1,    73,
-      46,     1,    48,    -1,    73,    32,    -1,    46,    72,    48,
-      -1,    46,     1,    48,    -1,    68,    74,    -1,    75,    -1,
-      36,    -1,    40,    -1,    75,    46,    76,    48,    -1,    75,
-      46,     1,    48,    -1,    75,    32,    -1,    46,    74,    48,
-      -1,    46,     1,    48,    -1,    77,    35,    -1,    77,    -1,
-      78,    45,    35,    -1,    -1,    78,    -1,    79,    -1,    78,
-      45,    79,    -1,    63,    80,    -1,    68,    80,    -1,    81,
-      -1,    -1,    36,    -1,    40,    -1,    81,    46,    76,    48,
-      -1,    81,    46,     1,    48,    -1,    81,    32,    -1,    46,
-      80,    48,    -1,    46,     1,    48,    -1,    62,    72,    31,
-      -1,    -1,    84,    -1,    49,    33,    -1,    50,    86,    44,
-      -1,    50,     1,    44,    -1,    -1,    87,    -1,    88,    -1,
-      87,    88,    -1,    62,    89,    43,    -1,     1,    43,    -1,
-      -1,    90,    -1,    91,    -1,    90,    45,    91,    -1,    74,
-      93,    -1,    36,    92,    -1,    92,    -1,    51,    33,    -1,
-      -1,    30,    -1,    29,    43,    -1,    -1,    29,    -1,    28,
-      46,    36,    48,    43,    -1
+      54,     0,    -1,    55,    -1,    54,    55,    -1,    -1,    56,
+      57,    -1,    -1,    12,    23,    58,    60,    -1,    -1,    23,
+      59,    60,    -1,    60,    -1,    84,    -1,    96,    -1,    98,
+      -1,     1,    44,    -1,     1,    45,    -1,    64,    61,    44,
+      -1,    -1,    62,    -1,    63,    -1,    62,    46,    63,    -1,
+      74,    97,    95,    85,    -1,    -1,    65,    -1,    66,    -1,
+      65,    66,    -1,    67,    -1,    68,    -1,     5,    -1,    17,
+      -1,    21,    -1,    11,    -1,    14,    -1,    69,    -1,    73,
+      -1,    28,    47,    65,    48,    49,    -1,    28,    47,    65,
+      49,    -1,    22,    37,    -1,    24,    37,    -1,    10,    37,
+      -1,    22,    37,    87,    -1,    24,    37,    87,    -1,    10,
+      37,    32,    -1,    10,    32,    -1,    22,    87,    -1,    24,
+      87,    -1,     7,    -1,    19,    -1,    15,    -1,    16,    -1,
+      20,    -1,    25,    -1,    13,    -1,     9,    -1,    26,    -1,
+       6,    -1,    41,    -1,    48,    71,    -1,    -1,    72,    -1,
+      73,    -1,    72,    73,    -1,     8,    -1,    27,    -1,    31,
+      -1,    18,    -1,    70,    74,    -1,    75,    -1,    37,    -1,
+      75,    47,    78,    49,    -1,    75,    47,     1,    49,    -1,
+      75,    33,    -1,    47,    74,    49,    -1,    47,     1,    49,
+      -1,    70,    76,    -1,    77,    -1,    37,    -1,    41,    -1,
+      77,    47,    78,    49,    -1,    77,    47,     1,    49,    -1,
+      77,    33,    -1,    47,    76,    49,    -1,    47,     1,    49,
+      -1,    79,    36,    -1,    79,    -1,    80,    46,    36,    -1,
+      -1,    80,    -1,    81,    -1,    80,    46,    81,    -1,    65,
+      82,    -1,    70,    82,    -1,    83,    -1,    -1,    37,    -1,
+      41,    -1,    83,    47,    78,    49,    -1,    83,    47,     1,
+      49,    -1,    83,    33,    -1,    47,    82,    49,    -1,    47,
+       1,    49,    -1,    64,    74,    32,    -1,    -1,    86,    -1,
+      50,    34,    -1,    51,    88,    45,    -1,    51,     1,    45,
+      -1,    -1,    89,    -1,    90,    -1,    89,    90,    -1,    64,
+      91,    44,    -1,     1,    44,    -1,    -1,    92,    -1,    93,
+      -1,    92,    46,    93,    -1,    76,    95,    -1,    37,    94,
+      -1,    94,    -1,    52,    34,    -1,    -1,    31,    -1,    30,
+      44,    -1,    -1,    30,    -1,    29,    47,    37,    49,    44,
+      -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const unsigned short int yyrline[] =
+static const yytype_uint16 yyrline[] =
 {
-       0,   102,   102,   103,   107,   107,   113,   113,   115,   116,
-     117,   118,   119,   120,   124,   138,   139,   143,   151,   164,
-     170,   171,   175,   176,   180,   186,   190,   191,   192,   193,
-     194,   198,   199,   200,   201,   205,   207,   209,   213,   220,
-     227,   236,   237,   238,   242,   243,   244,   245,   246,   247,
-     248,   249,   250,   251,   252,   256,   261,   262,   266,   267,
-     271,   271,   271,   272,   280,   281,   285,   294,   296,   298,
-     300,   302,   309,   310,   314,   315,   316,   318,   320,   322,
-     324,   329,   330,   331,   335,   336,   340,   341,   346,   351,
-     353,   357,   358,   366,   370,   372,   374,   376,   378,   383,
-     392,   393,   398,   403,   404,   408,   409,   413,   414,   418,
-     420,   425,   426,   430,   431,   435,   436,   437,   441,   445,
-     446,   450,   454,   455,   459
+       0,   103,   103,   104,   108,   108,   114,   114,   116,   116,
+     118,   119,   120,   121,   122,   123,   127,   141,   142,   146,
+     154,   167,   173,   174,   178,   179,   183,   189,   193,   194,
+     195,   196,   197,   201,   202,   203,   204,   208,   210,   212,
+     216,   223,   230,   239,   240,   241,   245,   246,   247,   248,
+     249,   250,   251,   252,   253,   254,   255,   259,   264,   265,
+     269,   270,   274,   274,   274,   275,   283,   284,   288,   297,
+     299,   301,   303,   305,   312,   313,   317,   318,   319,   321,
+     323,   325,   327,   332,   333,   334,   338,   339,   343,   344,
+     349,   354,   356,   360,   361,   369,   373,   375,   377,   379,
+     381,   386,   395,   396,   401,   406,   407,   411,   412,   416,
+     417,   421,   423,   428,   429,   433,   434,   438,   439,   440,
+     444,   448,   449,   453,   457,   458,   462
 };
 #endif
 
-#if YYDEBUG || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
-   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "ASM_KEYW", "ATTRIBUTE_KEYW",
   "AUTO_KEYW", "BOOL_KEYW", "CHAR_KEYW", "CONST_KEYW", "DOUBLE_KEYW",
-  "ENUM_KEYW", "EXTERN_KEYW", "FLOAT_KEYW", "INLINE_KEYW", "INT_KEYW",
-  "LONG_KEYW", "REGISTER_KEYW", "RESTRICT_KEYW", "SHORT_KEYW",
-  "SIGNED_KEYW", "STATIC_KEYW", "STRUCT_KEYW", "TYPEDEF_KEYW",
-  "UNION_KEYW", "UNSIGNED_KEYW", "VOID_KEYW", "VOLATILE_KEYW",
-  "TYPEOF_KEYW", "EXPORT_SYMBOL_KEYW", "ASM_PHRASE", "ATTRIBUTE_PHRASE",
-  "BRACE_PHRASE", "BRACKET_PHRASE", "EXPRESSION_PHRASE", "CHAR", "DOTS",
-  "IDENT", "INT", "REAL", "STRING", "TYPE", "OTHER", "FILENAME", "';'",
-  "'}'", "','", "'('", "'*'", "')'", "'='", "'{'", "':'", "$accept",
-  "declaration_seq", "declaration", "@1", "declaration1", "@2",
-  "simple_declaration", "init_declarator_list_opt", "init_declarator_list",
-  "init_declarator", "decl_specifier_seq_opt", "decl_specifier_seq",
-  "decl_specifier", "storage_class_specifier", "type_specifier",
-  "simple_type_specifier", "ptr_operator", "cvar_qualifier_seq_opt",
-  "cvar_qualifier_seq", "cvar_qualifier", "declarator",
-  "direct_declarator", "nested_declarator", "direct_nested_declarator",
-  "parameter_declaration_clause", "parameter_declaration_list_opt",
-  "parameter_declaration_list", "parameter_declaration",
-  "m_abstract_declarator", "direct_m_abstract_declarator",
-  "function_definition", "initializer_opt", "initializer", "class_body",
-  "member_specification_opt", "member_specification", "member_declaration",
+  "ENUM_KEYW", "EXTERN_KEYW", "EXTENSION_KEYW", "FLOAT_KEYW",
+  "INLINE_KEYW", "INT_KEYW", "LONG_KEYW", "REGISTER_KEYW", "RESTRICT_KEYW",
+  "SHORT_KEYW", "SIGNED_KEYW", "STATIC_KEYW", "STRUCT_KEYW",
+  "TYPEDEF_KEYW", "UNION_KEYW", "UNSIGNED_KEYW", "VOID_KEYW",
+  "VOLATILE_KEYW", "TYPEOF_KEYW", "EXPORT_SYMBOL_KEYW", "ASM_PHRASE",
+  "ATTRIBUTE_PHRASE", "BRACE_PHRASE", "BRACKET_PHRASE",
+  "EXPRESSION_PHRASE", "CHAR", "DOTS", "IDENT", "INT", "REAL", "STRING",
+  "TYPE", "OTHER", "FILENAME", "';'", "'}'", "','", "'('", "'*'", "')'",
+  "'='", "'{'", "':'", "$accept", "declaration_seq", "declaration", "@1",
+  "declaration1", "@2", "@3", "simple_declaration",
+  "init_declarator_list_opt", "init_declarator_list", "init_declarator",
+  "decl_specifier_seq_opt", "decl_specifier_seq", "decl_specifier",
+  "storage_class_specifier", "type_specifier", "simple_type_specifier",
+  "ptr_operator", "cvar_qualifier_seq_opt", "cvar_qualifier_seq",
+  "cvar_qualifier", "declarator", "direct_declarator", "nested_declarator",
+  "direct_nested_declarator", "parameter_declaration_clause",
+  "parameter_declaration_list_opt", "parameter_declaration_list",
+  "parameter_declaration", "m_abstract_declarator",
+  "direct_m_abstract_declarator", "function_definition", "initializer_opt",
+  "initializer", "class_body", "member_specification_opt",
+  "member_specification", "member_declaration",
   "member_declarator_list_opt", "member_declarator_list",
   "member_declarator", "member_bitfield_declarator", "attribute_opt",
   "asm_definition", "asm_phrase_opt", "export_definition", 0
@@ -467,284 +603,266 @@ static const char *const yytname[] =
 # ifdef YYPRINT
 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
    token YYLEX-NUM.  */
-static const unsigned short int yytoknum[] =
+static const yytype_uint16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
-     295,   296,   297,    59,   125,    44,    40,    42,    41,    61,
-     123,    58
+     295,   296,   297,   298,    59,   125,    44,    40,    42,    41,
+      61,   123,    58
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
-static const unsigned char yyr1[] =
+static const yytype_uint8 yyr1[] =
 {
-       0,    52,    53,    53,    55,    54,    57,    56,    56,    56,
-      56,    56,    56,    56,    58,    59,    59,    60,    60,    61,
-      62,    62,    63,    63,    64,    64,    65,    65,    65,    65,
-      65,    66,    66,    66,    66,    66,    66,    66,    66,    66,
-      66,    66,    66,    66,    67,    67,    67,    67,    67,    67,
-      67,    67,    67,    67,    67,    68,    69,    69,    70,    70,
-      71,    71,    71,    71,    72,    72,    73,    73,    73,    73,
-      73,    73,    74,    74,    75,    75,    75,    75,    75,    75,
-      75,    76,    76,    76,    77,    77,    78,    78,    79,    80,
-      80,    81,    81,    81,    81,    81,    81,    81,    81,    82,
-      83,    83,    84,    85,    85,    86,    86,    87,    87,    88,
-      88,    89,    89,    90,    90,    91,    91,    91,    92,    93,
-      93,    94,    95,    95,    96
+       0,    53,    54,    54,    56,    55,    58,    57,    59,    57,
+      57,    57,    57,    57,    57,    57,    60,    61,    61,    62,
+      62,    63,    64,    64,    65,    65,    66,    66,    67,    67,
+      67,    67,    67,    68,    68,    68,    68,    68,    68,    68,
+      68,    68,    68,    68,    68,    68,    69,    69,    69,    69,
+      69,    69,    69,    69,    69,    69,    69,    70,    71,    71,
+      72,    72,    73,    73,    73,    73,    74,    74,    75,    75,
+      75,    75,    75,    75,    76,    76,    77,    77,    77,    77,
+      77,    77,    77,    78,    78,    78,    79,    79,    80,    80,
+      81,    82,    82,    83,    83,    83,    83,    83,    83,    83,
+      83,    84,    85,    85,    86,    87,    87,    88,    88,    89,
+      89,    90,    90,    91,    91,    92,    92,    93,    93,    93,
+      94,    95,    95,    96,    97,    97,    98
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
-static const unsigned char yyr2[] =
+static const yytype_uint8 yyr2[] =
 {
-       0,     2,     1,     2,     0,     2,     0,     3,     1,     1,
-       1,     1,     2,     2,     3,     0,     1,     1,     3,     4,
-       0,     1,     1,     2,     1,     1,     1,     1,     1,     1,
-       1,     1,     1,     5,     4,     2,     2,     2,     3,     3,
-       3,     2,     2,     2,     1,     1,     1,     1,     1,     1,
-       1,     1,     1,     1,     1,     2,     0,     1,     1,     2,
-       1,     1,     1,     1,     2,     1,     1,     4,     4,     2,
-       3,     3,     2,     1,     1,     1,     4,     4,     2,     3,
-       3,     2,     1,     3,     0,     1,     1,     3,     2,     2,
-       1,     0,     1,     1,     4,     4,     2,     3,     3,     3,
-       0,     1,     2,     3,     3,     0,     1,     1,     2,     3,
-       2,     0,     1,     1,     3,     2,     2,     1,     2,     0,
-       1,     2,     0,     1,     5
+       0,     2,     1,     2,     0,     2,     0,     4,     0,     3,
+       1,     1,     1,     1,     2,     2,     3,     0,     1,     1,
+       3,     4,     0,     1,     1,     2,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     5,     4,     2,     2,     2,
+       3,     3,     3,     2,     2,     2,     1,     1,     1,     1,
+       1,     1,     1,     1,     1,     1,     1,     2,     0,     1,
+       1,     2,     1,     1,     1,     1,     2,     1,     1,     4,
+       4,     2,     3,     3,     2,     1,     1,     1,     4,     4,
+       2,     3,     3,     2,     1,     3,     0,     1,     1,     3,
+       2,     2,     1,     0,     1,     1,     4,     4,     2,     3,
+       3,     3,     0,     1,     2,     3,     3,     0,     1,     1,
+       2,     3,     2,     0,     1,     1,     3,     2,     2,     1,
+       2,     0,     1,     2,     0,     1,     5
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
    means the default is an error.  */
-static const unsigned char yydefact[] =
+static const yytype_uint8 yydefact[] =
 {
-       4,     4,     2,     0,     1,     3,     0,    26,    53,    44,
-      60,    51,     0,    29,    50,    30,    46,    47,    27,    63,
-      45,    48,    28,     0,     6,     0,    49,    52,    61,     0,
-       0,     0,    62,    54,     5,     8,    15,    21,    22,    24,
-      25,    31,    32,     9,    10,    11,    12,    13,    41,    37,
-      35,     0,    42,    20,    36,    43,     0,     0,   121,    66,
-       0,    56,     0,    16,    17,     0,   122,    65,    23,    40,
-      38,     0,   111,     0,     0,   107,     7,    15,    39,     0,
-       0,     0,     0,    55,    57,    58,    14,     0,    64,   123,
-      99,   119,    69,     0,   110,   104,    74,    75,     0,     0,
-       0,   119,    73,     0,   112,   113,   117,   103,     0,   108,
-     122,     0,    34,     0,    71,    70,    59,    18,   120,   100,
-       0,    91,     0,    82,    85,    86,   116,     0,    74,     0,
-     118,    72,   115,    78,     0,   109,     0,    33,   124,     0,
-      19,   101,    68,    92,    54,     0,    91,    88,    90,    67,
-      81,     0,    80,    79,     0,     0,   114,   102,     0,    93,
-       0,    89,    96,     0,    83,    87,    77,    76,    98,    97,
-       0,     0,    95,    94
+       4,     4,     2,     0,     1,     3,     0,    28,    55,    46,
+      62,    53,     0,    31,     0,    52,    32,    48,    49,    29,
+      65,    47,    50,    30,     0,     8,     0,    51,    54,    63,
+       0,     0,     0,    64,    56,     5,    10,    17,    23,    24,
+      26,    27,    33,    34,    11,    12,    13,    14,    15,    43,
+      39,     6,    37,     0,    44,    22,    38,    45,     0,     0,
+     123,    68,     0,    58,     0,    18,    19,     0,   124,    67,
+      25,    42,    22,    40,     0,   113,     0,     0,   109,     9,
+      17,    41,     0,     0,     0,     0,    57,    59,    60,    16,
+       0,    66,   125,   101,   121,    71,     0,     7,   112,   106,
+      76,    77,     0,     0,     0,   121,    75,     0,   114,   115,
+     119,   105,     0,   110,   124,     0,    36,     0,    73,    72,
+      61,    20,   122,   102,     0,    93,     0,    84,    87,    88,
+     118,     0,    76,     0,   120,    74,   117,    80,     0,   111,
+       0,    35,   126,     0,    21,   103,    70,    94,    56,     0,
+      93,    90,    92,    69,    83,     0,    82,    81,     0,     0,
+     116,   104,     0,    95,     0,    91,    98,     0,    85,    89,
+      79,    78,   100,    99,     0,     0,    97,    96
 };
 
-/* YYDEFGOTO[NTERM-NUM]. */
-static const short int yydefgoto[] =
+/* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int16 yydefgoto[] =
 {
-      -1,     1,     2,     3,    34,    53,    35,    62,    63,    64,
-      72,    37,    38,    39,    40,    41,    65,    83,    84,    42,
-     110,    67,   101,   102,   122,   123,   124,   125,   147,   148,
-      43,   140,   141,    52,    73,    74,    75,   103,   104,   105,
-     106,   119,    44,    91,    45
+      -1,     1,     2,     3,    35,    72,    55,    36,    64,    65,
+      66,    75,    38,    39,    40,    41,    42,    67,    86,    87,
+      43,   114,    69,   105,   106,   126,   127,   128,   129,   151,
+     152,    44,   144,   145,    54,    76,    77,    78,   107,   108,
+     109,   110,   123,    45,    94,    46
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -128
-static const short int yypact[] =
+#define YYPACT_NINF -135
+static const yytype_int16 yypact[] =
 {
-    -128,    13,  -128,   329,  -128,  -128,    36,  -128,  -128,  -128,
-    -128,  -128,   -16,  -128,  -128,  -128,  -128,  -128,  -128,  -128,
-    -128,  -128,  -128,   -25,  -128,   -24,  -128,  -128,  -128,   -29,
-      -4,   -22,  -128,  -128,  -128,  -128,   -28,   495,  -128,  -128,
-    -128,  -128,  -128,  -128,  -128,  -128,  -128,  -128,  -128,    16,
-     -23,   103,  -128,   495,   -23,  -128,   495,    35,  -128,  -128,
-       3,    15,     9,    17,  -128,   -28,   -15,    -8,  -128,  -128,
-    -128,    47,    23,    44,   150,  -128,  -128,   -28,  -128,   372,
-      33,    48,    49,  -128,    15,  -128,  -128,   -28,  -128,  -128,
-    -128,    64,  -128,   197,  -128,  -128,    50,  -128,    21,    65,
-      37,    64,    14,    56,    55,  -128,  -128,  -128,    59,  -128,
-      74,    57,  -128,    63,  -128,  -128,  -128,  -128,  -128,    76,
-      83,   416,    84,    99,    90,  -128,  -128,    88,  -128,    89,
-    -128,  -128,  -128,  -128,   241,  -128,    23,  -128,  -128,   105,
-    -128,  -128,  -128,  -128,  -128,     8,    46,  -128,    26,  -128,
-    -128,   459,  -128,  -128,    92,    93,  -128,  -128,    94,  -128,
-      96,  -128,  -128,   285,  -128,  -128,  -128,  -128,  -128,  -128,
-      97,   100,  -128,  -128
+    -135,    11,  -135,   312,  -135,  -135,    24,  -135,  -135,  -135,
+    -135,  -135,   -23,  -135,    -2,  -135,  -135,  -135,  -135,  -135,
+    -135,  -135,  -135,  -135,   -17,  -135,   -11,  -135,  -135,  -135,
+      -3,    16,    26,  -135,  -135,  -135,  -135,    34,   482,  -135,
+    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
+      -8,  -135,    22,    97,  -135,   482,    22,  -135,   482,    56,
+    -135,  -135,    12,    10,    50,    49,  -135,    34,   -13,    15,
+    -135,  -135,   482,  -135,    47,   -25,    51,   145,  -135,  -135,
+      34,  -135,   356,    52,    71,    77,  -135,    10,  -135,  -135,
+      34,  -135,  -135,  -135,    68,  -135,   193,  -135,  -135,  -135,
+      48,  -135,     6,    93,    37,    68,    18,    85,    84,  -135,
+    -135,  -135,    87,  -135,   102,    86,  -135,    89,  -135,  -135,
+    -135,  -135,  -135,    90,    88,   401,    94,   100,   101,  -135,
+    -135,    99,  -135,   108,  -135,  -135,  -135,  -135,   230,  -135,
+     -25,  -135,  -135,   105,  -135,  -135,  -135,  -135,  -135,     9,
+      42,  -135,    28,  -135,  -135,   445,  -135,  -135,   119,   125,
+    -135,  -135,   126,  -135,   128,  -135,  -135,   267,  -135,  -135,
+    -135,  -135,  -135,  -135,   129,   130,  -135,  -135
 };
 
 /* YYPGOTO[NTERM-NUM].  */
-static const short int yypgoto[] =
+static const yytype_int16 yypgoto[] =
 {
-    -128,  -128,   151,  -128,  -128,  -128,   119,  -128,  -128,    66,
-       0,   -56,   -36,  -128,  -128,  -128,   -70,  -128,  -128,   -51,
-     -31,  -128,   -11,  -128,  -127,  -128,  -128,    27,   -81,  -128,
-    -128,  -128,  -128,   -19,  -128,  -128,   107,  -128,  -128,    43,
-      86,    82,  -128,  -128,  -128
+    -135,  -135,   179,  -135,  -135,  -135,  -135,   -47,  -135,  -135,
+      91,     0,   -58,   -37,  -135,  -135,  -135,   -73,  -135,  -135,
+     -48,   -32,  -135,   -38,  -135,  -134,  -135,  -135,    29,   -63,
+    -135,  -135,  -135,  -135,   -20,  -135,  -135,   106,  -135,  -135,
+      45,    95,    82,  -135,  -135,  -135
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -107
-static const short int yytable[] =
+#define YYTABLE_NINF -109
+static const yytype_int16 yytable[] =
 {
-      79,    68,   100,    36,    81,    66,    55,   155,    59,   158,
-      85,    50,    54,     4,    89,    48,    90,    56,    60,    61,
-      49,    58,   127,    10,    92,    51,    51,    51,   100,    82,
-     100,    70,    19,   116,    88,    78,   171,   121,    93,    59,
-     -91,    28,    57,    68,   143,    32,   133,    69,   159,    60,
-      61,   146,    86,    77,   145,    61,   -91,   128,   162,    96,
-     134,    97,    87,    97,   160,   161,   100,    98,    61,    98,
-      61,    80,   163,   128,    99,   146,   146,    97,   121,    46,
-      47,   113,   143,    98,    61,    68,   159,   129,   107,   131,
-      94,    95,   145,    61,   118,   121,   114,   115,   130,   135,
-     136,    99,    94,    89,    71,   137,   138,   121,     7,     8,
-       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,    20,    21,    22,    23,   139,    25,    26,    27,    28,
-      29,   142,   149,    32,   150,   151,   152,   153,   157,   -20,
-     166,   167,   168,    33,   169,   172,   -20,  -105,   173,   -20,
-     -20,   108,     5,   117,   -20,     7,     8,     9,    10,    11,
-      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
-      22,    23,    76,    25,    26,    27,    28,    29,   165,   156,
-      32,   109,   126,   132,     0,     0,   -20,     0,     0,     0,
-      33,     0,     0,   -20,  -106,     0,   -20,   -20,   120,     0,
-       0,   -20,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    22,    23,     0,
-      25,    26,    27,    28,    29,     0,     0,    32,     0,     0,
-       0,     0,   -84,     0,     0,     0,     0,    33,     0,     0,
-       0,     0,   154,     0,     0,   -84,     7,     8,     9,    10,
-      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    22,    23,     0,    25,    26,    27,    28,    29,     0,
-       0,    32,     0,     0,     0,     0,   -84,     0,     0,     0,
-       0,    33,     0,     0,     0,     0,   170,     0,     0,   -84,
-       7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,    23,     0,    25,    26,
-      27,    28,    29,     0,     0,    32,     0,     0,     0,     0,
-     -84,     0,     0,     0,     0,    33,     0,     0,     0,     0,
-       6,     0,     0,   -84,     7,     8,     9,    10,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
-       0,     0,     0,     0,     0,   -20,     0,     0,     0,    33,
-       0,     0,   -20,     0,     0,   -20,   -20,     7,     8,     9,
+      82,    70,   104,    37,   159,    68,    57,   131,    79,    49,
+     162,     4,   100,    84,    50,    88,   101,    92,    10,    93,
+      52,    51,   102,    63,    71,    97,    56,   103,    20,   104,
+      85,   104,    73,   175,    53,    91,    81,    29,   125,   120,
+      53,    33,   -93,   132,    58,    70,   147,   101,    95,    61,
+     163,   137,   150,   102,    63,    80,   149,    63,   -93,    62,
+      63,   166,    96,    59,   133,   138,   135,   104,    47,    48,
+      60,    61,    80,    53,   132,   167,   150,   150,   101,   147,
+     125,    62,    63,   163,   102,    63,   164,   165,    70,   149,
+      63,    98,    99,    83,    89,    90,   111,   125,    74,   122,
+     103,   117,     7,     8,     9,    10,    11,    12,    13,   125,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+     118,    26,    27,    28,    29,    30,   119,   134,    33,   139,
+     140,    98,    92,   142,   -22,   141,   154,   146,    34,   161,
+     143,   -22,  -107,   153,   -22,   -22,   112,   155,   156,   -22,
+       7,     8,     9,    10,    11,    12,    13,   157,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,   170,    26,
+      27,    28,    29,    30,   171,   172,    33,   173,   176,   177,
+       5,   121,   -22,   113,   169,   160,    34,   136,     0,   -22,
+    -108,     0,   -22,   -22,   124,   130,     0,   -22,     7,     8,
+       9,    10,    11,    12,    13,     0,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,     0,    26,    27,    28,
+      29,    30,     0,     0,    33,     0,     0,     0,     0,   -86,
+       0,   158,     0,     0,    34,     7,     8,     9,    10,    11,
+      12,    13,   -86,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    24,     0,    26,    27,    28,    29,    30,     0,
+       0,    33,     0,     0,     0,     0,   -86,     0,   174,     0,
+       0,    34,     7,     8,     9,    10,    11,    12,    13,   -86,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+       0,    26,    27,    28,    29,    30,     0,     0,    33,     0,
+       0,     0,     0,   -86,     0,     0,     0,     0,    34,     0,
+       0,     0,     0,     6,     0,     0,   -86,     7,     8,     9,
       10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
-      20,    21,    22,    23,     0,    25,    26,    27,    28,    29,
-       0,     0,    32,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    33,     0,     0,     0,     0,     0,     0,   111,
-     112,     7,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    20,    21,    22,    23,     0,    25,
-      26,    27,    28,    29,     0,     0,    32,     0,     0,     0,
-       0,     0,   143,     0,     0,     0,   144,     0,     0,     0,
-       0,     0,   145,    61,     7,     8,     9,    10,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
-      23,     0,    25,    26,    27,    28,    29,     0,     0,    32,
-       0,     0,     0,     0,   164,     0,     0,     0,     0,    33,
-       7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,    23,     0,    25,    26,
-      27,    28,    29,     0,     0,    32,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    33
+      20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
+      30,    31,    32,    33,     0,     0,     0,     0,     0,   -22,
+       0,     0,     0,    34,     0,     0,   -22,     0,     0,   -22,
+     -22,     7,     8,     9,    10,    11,    12,    13,     0,    15,
+      16,    17,    18,    19,    20,    21,    22,    23,    24,     0,
+      26,    27,    28,    29,    30,     0,     0,    33,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    34,     0,     0,
+       0,     0,     0,     0,   115,   116,     7,     8,     9,    10,
+      11,    12,    13,     0,    15,    16,    17,    18,    19,    20,
+      21,    22,    23,    24,     0,    26,    27,    28,    29,    30,
+       0,     0,    33,     0,     0,     0,     0,     0,   147,     0,
+       0,     0,   148,     0,     0,     0,     0,     0,   149,    63,
+       7,     8,     9,    10,    11,    12,    13,     0,    15,    16,
+      17,    18,    19,    20,    21,    22,    23,    24,     0,    26,
+      27,    28,    29,    30,     0,     0,    33,     0,     0,     0,
+       0,   168,     0,     0,     0,     0,    34,     7,     8,     9,
+      10,    11,    12,    13,     0,    15,    16,    17,    18,    19,
+      20,    21,    22,    23,    24,     0,    26,    27,    28,    29,
+      30,     0,     0,    33,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,    34
 };
 
-static const short int yycheck[] =
+static const yytype_int16 yycheck[] =
 {
-      56,    37,    72,     3,     1,    36,    25,   134,    36,     1,
-      61,    36,    36,     0,    29,    31,    31,    46,    46,    47,
-      36,    43,     1,     8,    32,    50,    50,    50,    98,    60,
-     100,    50,    17,    84,    65,    54,   163,    93,    46,    36,
-      32,    26,    46,    79,    36,    30,    32,    31,    40,    46,
-      47,   121,    43,    53,    46,    47,    48,    36,    32,    36,
-      46,    40,    45,    40,   145,   146,   136,    46,    47,    46,
-      47,    36,    46,    36,    51,   145,   146,    40,   134,    43,
-      44,    48,    36,    46,    47,   121,    40,    98,    44,   100,
-      43,    44,    46,    47,    30,   151,    48,    48,    33,    43,
-      45,    51,    43,    29,     1,    48,    43,   163,     5,     6,
-       7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    49,    23,    24,    25,    26,
-      27,    48,    48,    30,    35,    45,    48,    48,    33,    36,
-      48,    48,    48,    40,    48,    48,    43,    44,    48,    46,
-      47,     1,     1,    87,    51,     5,     6,     7,     8,     9,
-      10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
-      20,    21,    53,    23,    24,    25,    26,    27,   151,   136,
-      30,    74,    96,   101,    -1,    -1,    36,    -1,    -1,    -1,
-      40,    -1,    -1,    43,    44,    -1,    46,    47,     1,    -1,
-      -1,    51,     5,     6,     7,     8,     9,    10,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    20,    21,    -1,
-      23,    24,    25,    26,    27,    -1,    -1,    30,    -1,    -1,
-      -1,    -1,    35,    -1,    -1,    -1,    -1,    40,    -1,    -1,
-      -1,    -1,     1,    -1,    -1,    48,     5,     6,     7,     8,
-       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
-      19,    20,    21,    -1,    23,    24,    25,    26,    27,    -1,
-      -1,    30,    -1,    -1,    -1,    -1,    35,    -1,    -1,    -1,
-      -1,    40,    -1,    -1,    -1,    -1,     1,    -1,    -1,    48,
-       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    -1,    23,    24,
-      25,    26,    27,    -1,    -1,    30,    -1,    -1,    -1,    -1,
-      35,    -1,    -1,    -1,    -1,    40,    -1,    -1,    -1,    -1,
-       1,    -1,    -1,    48,     5,     6,     7,     8,     9,    10,
-      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
-      -1,    -1,    -1,    -1,    -1,    36,    -1,    -1,    -1,    40,
-      -1,    -1,    43,    -1,    -1,    46,    47,     5,     6,     7,
+      58,    38,    75,     3,   138,    37,    26,     1,    55,    32,
+       1,     0,    37,     1,    37,    63,    41,    30,     8,    32,
+      37,    23,    47,    48,    32,    72,    37,    52,    18,   102,
+      62,   104,    52,   167,    51,    67,    56,    27,    96,    87,
+      51,    31,    33,    37,    47,    82,    37,    41,    33,    37,
+      41,    33,   125,    47,    48,    55,    47,    48,    49,    47,
+      48,    33,    47,    47,   102,    47,   104,   140,    44,    45,
+      44,    37,    72,    51,    37,    47,   149,   150,    41,    37,
+     138,    47,    48,    41,    47,    48,   149,   150,   125,    47,
+      48,    44,    45,    37,    44,    46,    45,   155,     1,    31,
+      52,    49,     5,     6,     7,     8,     9,    10,    11,   167,
+      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
+      49,    24,    25,    26,    27,    28,    49,    34,    31,    44,
+      46,    44,    30,    44,    37,    49,    36,    49,    41,    34,
+      50,    44,    45,    49,    47,    48,     1,    46,    49,    52,
+       5,     6,     7,     8,     9,    10,    11,    49,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    49,    24,
+      25,    26,    27,    28,    49,    49,    31,    49,    49,    49,
+       1,    90,    37,    77,   155,   140,    41,   105,    -1,    44,
+      45,    -1,    47,    48,     1,   100,    -1,    52,     5,     6,
+       7,     8,     9,    10,    11,    -1,    13,    14,    15,    16,
+      17,    18,    19,    20,    21,    22,    -1,    24,    25,    26,
+      27,    28,    -1,    -1,    31,    -1,    -1,    -1,    -1,    36,
+      -1,     1,    -1,    -1,    41,     5,     6,     7,     8,     9,
+      10,    11,    49,    13,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,    -1,    24,    25,    26,    27,    28,    -1,
+      -1,    31,    -1,    -1,    -1,    -1,    36,    -1,     1,    -1,
+      -1,    41,     5,     6,     7,     8,     9,    10,    11,    49,
+      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
+      -1,    24,    25,    26,    27,    28,    -1,    -1,    31,    -1,
+      -1,    -1,    -1,    36,    -1,    -1,    -1,    -1,    41,    -1,
+      -1,    -1,    -1,     1,    -1,    -1,    49,     5,     6,     7,
        8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    -1,    23,    24,    25,    26,    27,
-      -1,    -1,    30,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    40,    -1,    -1,    -1,    -1,    -1,    -1,    47,
-      48,     5,     6,     7,     8,     9,    10,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,    21,    -1,    23,
-      24,    25,    26,    27,    -1,    -1,    30,    -1,    -1,    -1,
-      -1,    -1,    36,    -1,    -1,    -1,    40,    -1,    -1,    -1,
-      -1,    -1,    46,    47,     5,     6,     7,     8,     9,    10,
-      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
-      21,    -1,    23,    24,    25,    26,    27,    -1,    -1,    30,
-      -1,    -1,    -1,    -1,    35,    -1,    -1,    -1,    -1,    40,
-       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,    21,    -1,    23,    24,
-      25,    26,    27,    -1,    -1,    30,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    40
+      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
+      28,    29,    30,    31,    -1,    -1,    -1,    -1,    -1,    37,
+      -1,    -1,    -1,    41,    -1,    -1,    44,    -1,    -1,    47,
+      48,     5,     6,     7,     8,     9,    10,    11,    -1,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    -1,
+      24,    25,    26,    27,    28,    -1,    -1,    31,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    41,    -1,    -1,
+      -1,    -1,    -1,    -1,    48,    49,     5,     6,     7,     8,
+       9,    10,    11,    -1,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    -1,    24,    25,    26,    27,    28,
+      -1,    -1,    31,    -1,    -1,    -1,    -1,    -1,    37,    -1,
+      -1,    -1,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,
+       5,     6,     7,     8,     9,    10,    11,    -1,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
+      25,    26,    27,    28,    -1,    -1,    31,    -1,    -1,    -1,
+      -1,    36,    -1,    -1,    -1,    -1,    41,     5,     6,     7,
+       8,     9,    10,    11,    -1,    13,    14,    15,    16,    17,
+      18,    19,    20,    21,    22,    -1,    24,    25,    26,    27,
+      28,    -1,    -1,    31,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    41
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
-static const unsigned char yystos[] =
+static const yytype_uint8 yystos[] =
 {
-       0,    53,    54,    55,     0,    54,     1,     5,     6,     7,
+       0,    54,    55,    56,     0,    55,     1,     5,     6,     7,
        8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
       18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
-      28,    29,    30,    40,    56,    58,    62,    63,    64,    65,
-      66,    67,    71,    82,    94,    96,    43,    44,    31,    36,
-      36,    50,    85,    57,    36,    85,    46,    46,    43,    36,
-      46,    47,    59,    60,    61,    68,    72,    73,    64,    31,
-      85,     1,    62,    86,    87,    88,    58,    62,    85,    63,
-      36,     1,    72,    69,    70,    71,    43,    45,    72,    29,
-      31,    95,    32,    46,    43,    44,    36,    40,    46,    51,
-      68,    74,    75,    89,    90,    91,    92,    44,     1,    88,
-      72,    47,    48,    48,    48,    48,    71,    61,    30,    93,
-       1,    63,    76,    77,    78,    79,    92,     1,    36,    74,
-      33,    74,    93,    32,    46,    43,    45,    48,    43,    49,
-      83,    84,    48,    36,    40,    46,    68,    80,    81,    48,
-      35,    45,    48,    48,     1,    76,    91,    33,     1,    40,
-      80,    80,    32,    46,    35,    79,    48,    48,    48,    48,
-       1,    76,    48,    48
+      28,    29,    30,    31,    41,    57,    60,    64,    65,    66,
+      67,    68,    69,    73,    84,    96,    98,    44,    45,    32,
+      37,    23,    37,    51,    87,    59,    37,    87,    47,    47,
+      44,    37,    47,    48,    61,    62,    63,    70,    74,    75,
+      66,    32,    58,    87,     1,    64,    88,    89,    90,    60,
+      64,    87,    65,    37,     1,    74,    71,    72,    73,    44,
+      46,    74,    30,    32,    97,    33,    47,    60,    44,    45,
+      37,    41,    47,    52,    70,    76,    77,    91,    92,    93,
+      94,    45,     1,    90,    74,    48,    49,    49,    49,    49,
+      73,    63,    31,    95,     1,    65,    78,    79,    80,    81,
+      94,     1,    37,    76,    34,    76,    95,    33,    47,    44,
+      46,    49,    44,    50,    85,    86,    49,    37,    41,    47,
+      70,    82,    83,    49,    36,    46,    49,    49,     1,    78,
+      93,    34,     1,    41,    82,    82,    33,    47,    36,    81,
+      49,    49,    49,    49,     1,    78,    49,    49
 };
 
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# if defined (__STDC__) || defined (__cplusplus)
-#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-#  define YYSIZE_T size_t
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
-#endif
-
 #define yyerrok                (yyerrstatus = 0)
 #define yyclearin      (yychar = YYEMPTY)
 #define YYEMPTY                (-2)
@@ -770,15 +888,15 @@ do                                                                \
       yychar = (Token);                                                \
       yylval = (Value);                                                \
       yytoken = YYTRANSLATE (yychar);                          \
-      YYPOPSTACK;                                              \
+      YYPOPSTACK (1);                                          \
       goto yybackup;                                           \
     }                                                          \
   else                                                         \
-    {                                                          \
-      yyerror ("syntax error: cannot back up");\
+    {                                                          \
+      yyerror (YY_("syntax error: cannot back up")); \
       YYERROR;                                                 \
     }                                                          \
-while (0)
+while (YYID (0))
 
 
 #define YYTERROR       1
@@ -793,7 +911,7 @@ while (0)
 #ifndef YYLLOC_DEFAULT
 # define YYLLOC_DEFAULT(Current, Rhs, N)                               \
     do                                                                 \
-      if (N)                                                           \
+      if (YYID (N))                                                    \
        {                                                               \
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
@@ -807,7 +925,7 @@ while (0)
          (Current).first_column = (Current).last_column =              \
            YYRHSLOC (Rhs, 0).last_column;                              \
        }                                                               \
-    while (0)
+    while (YYID (0))
 #endif
 
 
@@ -819,8 +937,8 @@ while (0)
 # if YYLTYPE_IS_TRIVIAL
 #  define YY_LOCATION_PRINT(File, Loc)                 \
      fprintf (File, "%d.%d-%d.%d",                     \
-              (Loc).first_line, (Loc).first_column,    \
-              (Loc).last_line,  (Loc).last_column)
+             (Loc).first_line, (Loc).first_column,     \
+             (Loc).last_line,  (Loc).last_column)
 # else
 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 # endif
@@ -847,36 +965,96 @@ while (0)
 do {                                           \
   if (yydebug)                                 \
     YYFPRINTF Args;                            \
-} while (0)
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                   \
+do {                                                                     \
+  if (yydebug)                                                           \
+    {                                                                    \
+      YYFPRINTF (stderr, "%s ", Title);                                          \
+      yy_symbol_print (stderr,                                           \
+                 Type, Value); \
+      YYFPRINTF (stderr, "\n");                                                  \
+    }                                                                    \
+} while (YYID (0))
 
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)         \
-do {                                                           \
-  if (yydebug)                                                 \
-    {                                                          \
-      YYFPRINTF (stderr, "%s ", Title);                                \
-      yysymprint (stderr,                                      \
-                  Type, Value);        \
-      YYFPRINTF (stderr, "\n");                                        \
-    }                                                          \
-} while (0)
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+#endif
+{
+  if (!yyvaluep)
+    return;
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+  YYUSE (yyoutput);
+# endif
+  switch (yytype)
+    {
+      default:
+       break;
+    }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+#endif
+{
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+  YYFPRINTF (yyoutput, ")");
+}
 
 /*------------------------------------------------------------------.
 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
 | TOP (included).                                                   |
 `------------------------------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
-yy_stack_print (short int *bottom, short int *top)
+yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
 #else
 static void
 yy_stack_print (bottom, top)
-    short int *bottom;
-    short int *top;
+    yytype_int16 *bottom;
+    yytype_int16 *top;
 #endif
 {
   YYFPRINTF (stderr, "Stack now");
-  for (/* Nothing. */; bottom <= top; ++bottom)
+  for (; bottom <= top; ++bottom)
     YYFPRINTF (stderr, " %d", *bottom);
   YYFPRINTF (stderr, "\n");
 }
@@ -885,37 +1063,45 @@ yy_stack_print (bottom, top)
 do {                                                           \
   if (yydebug)                                                 \
     yy_stack_print ((Bottom), (Top));                          \
-} while (0)
+} while (YYID (0))
 
 
 /*------------------------------------------------.
 | Report that the YYRULE is going to be reduced.  |
 `------------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
-yy_reduce_print (int yyrule)
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
 #else
 static void
-yy_reduce_print (yyrule)
+yy_reduce_print (yyvsp, yyrule)
+    YYSTYPE *yyvsp;
     int yyrule;
 #endif
 {
+  int yynrhs = yyr2[yyrule];
   int yyi;
-  unsigned int yylno = yyrline[yyrule];
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
-             yyrule - 1, yylno);
-  /* Print the symbols being reduced, and their result.  */
-  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
-    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
-  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
+  unsigned long int yylno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+            yyrule - 1, yylno);
+  /* The symbols being reduced.  */
+  for (yyi = 0; yyi < yynrhs; yyi++)
+    {
+      fprintf (stderr, "   $%d = ", yyi + 1);
+      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+                      &(yyvsp[(yyi + 1) - (yynrhs)])
+                                      );
+      fprintf (stderr, "\n");
+    }
 }
 
 # define YY_REDUCE_PRINT(Rule)         \
 do {                                   \
   if (yydebug)                         \
-    yy_reduce_print (Rule);            \
-} while (0)
+    yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
    multiple parsers can coexist.  */
@@ -937,7 +1123,7 @@ int yydebug;
    if the built-in stack extension method is used).
 
    Do not make this value too large; the results are undefined if
-   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
    evaluated with infinite-precision integer arithmetic.  */
 
 #ifndef YYMAXDEPTH
@@ -949,45 +1135,47 @@ int yydebug;
 #if YYERROR_VERBOSE
 
 # ifndef yystrlen
-#  if defined (__GLIBC__) && defined (_STRING_H)
+#  if defined __GLIBC__ && defined _STRING_H
 #   define yystrlen strlen
 #  else
 /* Return the length of YYSTR.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static YYSIZE_T
-#   if defined (__STDC__) || defined (__cplusplus)
 yystrlen (const char *yystr)
-#   else
+#else
+static YYSIZE_T
 yystrlen (yystr)
-     const char *yystr;
-#   endif
+    const char *yystr;
+#endif
 {
-  register const char *yys = yystr;
-
-  while (*yys++ != '\0')
+  YYSIZE_T yylen;
+  for (yylen = 0; yystr[yylen]; yylen++)
     continue;
-
-  return yys - yystr - 1;
+  return yylen;
 }
 #  endif
 # endif
 
 # ifndef yystpcpy
-#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
 #   define yystpcpy stpcpy
 #  else
 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    YYDEST.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static char *
-#   if defined (__STDC__) || defined (__cplusplus)
 yystpcpy (char *yydest, const char *yysrc)
-#   else
+#else
+static char *
 yystpcpy (yydest, yysrc)
-     char *yydest;
-     const char *yysrc;
-#   endif
+    char *yydest;
+    const char *yysrc;
+#endif
 {
-  register char *yyd = yydest;
-  register const char *yys = yysrc;
+  char *yyd = yydest;
+  const char *yys = yysrc;
 
   while ((*yyd++ = *yys++) != '\0')
     continue;
@@ -997,53 +1185,171 @@ yystpcpy (yydest, yysrc)
 #  endif
 # endif
 
-#endif /* !YYERROR_VERBOSE */
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+   quotes and backslashes, so that it's suitable for yyerror.  The
+   heuristic is that double-quoting is unnecessary unless the string
+   contains an apostrophe, a comma, or backslash (other than
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
+   null, do not copy; instead, return the length of what the result
+   would have been.  */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+  if (*yystr == '"')
+    {
+      YYSIZE_T yyn = 0;
+      char const *yyp = yystr;
+
+      for (;;)
+       switch (*++yyp)
+         {
+         case '\'':
+         case ',':
+           goto do_not_strip_quotes;
+
+         case '\\':
+           if (*++yyp != '\\')
+             goto do_not_strip_quotes;
+           /* Fall through.  */
+         default:
+           if (yyres)
+             yyres[yyn] = *yyp;
+           yyn++;
+           break;
+
+         case '"':
+           if (yyres)
+             yyres[yyn] = '\0';
+           return yyn;
+         }
+    do_not_strip_quotes: ;
+    }
 
-\f
+  if (! yyres)
+    return yystrlen (yystr);
 
-#if YYDEBUG
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
+  return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
 
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yysymprint (yyoutput, yytype, yyvaluep)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE *yyvaluep;
-#endif
+/* Copy into YYRESULT an error message about the unexpected token
+   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
+   including the terminating null byte.  If YYRESULT is null, do not
+   copy anything; just return the number of bytes that would be
+   copied.  As a special case, return 0 if an ordinary "syntax error"
+   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
+   size calculation.  */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
 {
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvaluep;
+  int yyn = yypact[yystate];
 
-  if (yytype < YYNTOKENS)
-    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+    return 0;
   else
-    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
-
-# ifdef YYPRINT
-  if (yytype < YYNTOKENS)
-    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
-  switch (yytype)
     {
-      default:
-        break;
+      int yytype = YYTRANSLATE (yychar);
+      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+      YYSIZE_T yysize = yysize0;
+      YYSIZE_T yysize1;
+      int yysize_overflow = 0;
+      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+      int yyx;
+
+# if 0
+      /* This is so xgettext sees the translatable formats that are
+        constructed on the fly.  */
+      YY_("syntax error, unexpected %s");
+      YY_("syntax error, unexpected %s, expecting %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+      char *yyfmt;
+      char const *yyf;
+      static char const yyunexpected[] = "syntax error, unexpected %s";
+      static char const yyexpecting[] = ", expecting %s";
+      static char const yyor[] = " or %s";
+      char yyformat[sizeof yyunexpected
+                   + sizeof yyexpecting - 1
+                   + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+                      * (sizeof yyor - 1))];
+      char const *yyprefix = yyexpecting;
+
+      /* Start YYX at -YYN if negative to avoid negative indexes in
+        YYCHECK.  */
+      int yyxbegin = yyn < 0 ? -yyn : 0;
+
+      /* Stay within bounds of both yycheck and yytname.  */
+      int yychecklim = YYLAST - yyn + 1;
+      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+      int yycount = 1;
+
+      yyarg[0] = yytname[yytype];
+      yyfmt = yystpcpy (yyformat, yyunexpected);
+
+      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+         {
+           if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+             {
+               yycount = 1;
+               yysize = yysize0;
+               yyformat[sizeof yyunexpected - 1] = '\0';
+               break;
+             }
+           yyarg[yycount++] = yytname[yyx];
+           yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+           yysize_overflow |= (yysize1 < yysize);
+           yysize = yysize1;
+           yyfmt = yystpcpy (yyfmt, yyprefix);
+           yyprefix = yyor;
+         }
+
+      yyf = YY_(yyformat);
+      yysize1 = yysize + yystrlen (yyf);
+      yysize_overflow |= (yysize1 < yysize);
+      yysize = yysize1;
+
+      if (yysize_overflow)
+       return YYSIZE_MAXIMUM;
+
+      if (yyresult)
+       {
+         /* Avoid sprintf, as that infringes on the user's name space.
+            Don't have undefined behavior even if the translation
+            produced a string with the wrong number of "%s"s.  */
+         char *yyp = yyresult;
+         int yyi = 0;
+         while ((*yyp = *yyf) != '\0')
+           {
+             if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+               {
+                 yyp += yytnamerr (yyp, yyarg[yyi++]);
+                 yyf += 2;
+               }
+             else
+               {
+                 yyp++;
+                 yyf++;
+               }
+           }
+       }
+      return yysize;
     }
-  YYFPRINTF (yyoutput, ")");
 }
+#endif /* YYERROR_VERBOSE */
+\f
 
-#endif /* ! YYDEBUG */
 /*-----------------------------------------------.
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
 #else
@@ -1054,8 +1360,7 @@ yydestruct (yymsg, yytype, yyvaluep)
     YYSTYPE *yyvaluep;
 #endif
 {
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvaluep;
+  YYUSE (yyvaluep);
 
   if (!yymsg)
     yymsg = "Deleting";
@@ -1065,7 +1370,7 @@ yydestruct (yymsg, yytype, yyvaluep)
     {
 
       default:
-        break;
+       break;
     }
 }
 \f
@@ -1073,13 +1378,13 @@ yydestruct (yymsg, yytype, yyvaluep)
 /* Prevent warnings from -Wmissing-prototypes.  */
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+#if defined __STDC__ || defined __cplusplus
 int yyparse (void *YYPARSE_PARAM);
-# else
+#else
 int yyparse ();
-# endif
+#endif
 #else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
+#if defined __STDC__ || defined __cplusplus
 int yyparse (void);
 #else
 int yyparse ();
@@ -1104,14 +1409,18 @@ int yynerrs;
 `----------*/
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM)
-# else
-int yyparse (YYPARSE_PARAM)
-  void *YYPARSE_PARAM;
-# endif
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+    void *YYPARSE_PARAM;
+#endif
 #else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 int
 yyparse (void)
 #else
@@ -1122,13 +1431,19 @@ yyparse ()
 #endif
 {
   
-  register int yystate;
-  register int yyn;
+  int yystate;
+  int yyn;
   int yyresult;
   /* Number of tokens to shift before error messages enabled.  */
   int yyerrstatus;
   /* Look-ahead token as an internal (translated) token number.  */
   int yytoken = 0;
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
 
   /* Three stacks and their tools:
      `yyss': related to states,
@@ -1139,18 +1454,18 @@ yyparse ()
      to reallocate them elsewhere.  */
 
   /* The state stack.  */
-  short int yyssa[YYINITDEPTH];
-  short int *yyss = yyssa;
-  register short int *yyssp;
+  yytype_int16 yyssa[YYINITDEPTH];
+  yytype_int16 *yyss = yyssa;
+  yytype_int16 *yyssp;
 
   /* The semantic value stack.  */
   YYSTYPE yyvsa[YYINITDEPTH];
   YYSTYPE *yyvs = yyvsa;
-  register YYSTYPE *yyvsp;
+  YYSTYPE *yyvsp;
 
 
 
-#define YYPOPSTACK   (yyvsp--, yyssp--)
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
 
   YYSIZE_T yystacksize = YYINITDEPTH;
 
@@ -1159,9 +1474,9 @@ yyparse ()
   YYSTYPE yyval;
 
 
-  /* When reducing, the number of symbols on the RHS of the reduced
-     rule.  */
-  int yylen;
+  /* The number of symbols on the RHS of the reduced rule.
+     Keep to zero when no symbol should be popped.  */
+  int yylen = 0;
 
   YYDPRINTF ((stderr, "Starting parse\n"));
 
@@ -1178,9 +1493,6 @@ yyparse ()
   yyssp = yyss;
   yyvsp = yyvs;
 
-
-  yyvsp[0] = yylval;
-
   goto yysetstate;
 
 /*------------------------------------------------------------.
@@ -1188,8 +1500,7 @@ yyparse ()
 `------------------------------------------------------------*/
  yynewstate:
   /* In all cases, when you get here, the value and location stacks
-     have just been pushed. so pushing a state here evens the stacks.
-     */
+     have just been pushed.  So pushing a state here evens the stacks.  */
   yyssp++;
 
  yysetstate:
@@ -1202,18 +1513,18 @@ yyparse ()
 
 #ifdef yyoverflow
       {
-       /* Give user a chance to reallocate the stack. Use copies of
+       /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        YYSTYPE *yyvs1 = yyvs;
-       short int *yyss1 = yyss;
+       yytype_int16 *yyss1 = yyss;
 
 
        /* Each stack pointer address is followed by the size of the
           data in use in that stack, in bytes.  This used to be a
           conditional around just the two extra args, but that might
           be undefined if yyoverflow is a macro.  */
-       yyoverflow ("parser stack overflow",
+       yyoverflow (YY_("memory exhausted"),
                    &yyss1, yysize * sizeof (*yyssp),
                    &yyvs1, yysize * sizeof (*yyvsp),
 
@@ -1224,21 +1535,21 @@ yyparse ()
       }
 #else /* no yyoverflow */
 # ifndef YYSTACK_RELOCATE
-      goto yyoverflowlab;
+      goto yyexhaustedlab;
 # else
       /* Extend the stack our own way.  */
       if (YYMAXDEPTH <= yystacksize)
-       goto yyoverflowlab;
+       goto yyexhaustedlab;
       yystacksize *= 2;
       if (YYMAXDEPTH < yystacksize)
        yystacksize = YYMAXDEPTH;
 
       {
-       short int *yyss1 = yyss;
+       yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
-         goto yyoverflowlab;
+         goto yyexhaustedlab;
        YYSTACK_RELOCATE (yyss);
        YYSTACK_RELOCATE (yyvs);
 
@@ -1269,12 +1580,10 @@ yyparse ()
 `-----------*/
 yybackup:
 
-/* Do appropriate processing given the current state.  */
-/* Read a look-ahead token if we need one and don't already have one.  */
-/* yyresume: */
+  /* Do appropriate processing given the current state.  Read a
+     look-ahead token if we need one and don't already have one.  */
 
   /* First try to decide what to do without reference to look-ahead token.  */
-
   yyn = yypact[yystate];
   if (yyn == YYPACT_NINF)
     goto yydefault;
@@ -1316,22 +1625,21 @@ yybackup:
   if (yyn == YYFINAL)
     YYACCEPT;
 
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
+
   /* Shift the look-ahead token.  */
   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
-  /* Discard the token being shifted unless it is eof.  */
+  /* Discard the shifted token unless it is eof.  */
   if (yychar != YYEOF)
     yychar = YYEMPTY;
 
+  yystate = yyn;
   *++yyvsp = yylval;
 
-
-  /* Count tokens shifted since error; after three, turn off error
-     status.  */
-  if (yyerrstatus)
-    yyerrstatus--;
-
-  yystate = yyn;
   goto yynewstate;
 
 
@@ -1367,457 +1675,466 @@ yyreduce:
   switch (yyn)
     {
         case 4:
-#line 107 "scripts/genksyms/parse.y"
+#line 108 "scripts/genksyms/parse.y"
     { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;}
     break;
 
   case 5:
-#line 109 "scripts/genksyms/parse.y"
-    { free_list(*(yyvsp[0]), NULL); *(yyvsp[0]) = NULL; ;}
+#line 110 "scripts/genksyms/parse.y"
+    { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; ;}
     break;
 
   case 6:
-#line 113 "scripts/genksyms/parse.y"
+#line 114 "scripts/genksyms/parse.y"
     { is_typedef = 1; ;}
     break;
 
   case 7:
-#line 114 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 115 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
-  case 12:
-#line 119 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 8:
+#line 116 "scripts/genksyms/parse.y"
+    { is_typedef = 1; ;}
     break;
 
-  case 13:
-#line 120 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 9:
+#line 117 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
   case 14:
-#line 125 "scripts/genksyms/parse.y"
+#line 122 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
+    break;
+
+  case 15:
+#line 123 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
+    break;
+
+  case 16:
+#line 128 "scripts/genksyms/parse.y"
     { if (current_name) {
-                   struct string_list *decl = (*(yyvsp[0]))->next;
-                   (*(yyvsp[0]))->next = NULL;
+                   struct string_list *decl = (*(yyvsp[(3) - (3)]))->next;
+                   (*(yyvsp[(3) - (3)]))->next = NULL;
                    add_symbol(current_name,
                               is_typedef ? SYM_TYPEDEF : SYM_NORMAL,
                               decl, is_extern);
                    current_name = NULL;
                  }
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(3) - (3)]);
                ;}
     break;
 
-  case 15:
-#line 138 "scripts/genksyms/parse.y"
+  case 17:
+#line 141 "scripts/genksyms/parse.y"
     { (yyval) = NULL; ;}
     break;
 
-  case 17:
-#line 144 "scripts/genksyms/parse.y"
-    { struct string_list *decl = *(yyvsp[0]);
-                 *(yyvsp[0]) = NULL;
+  case 19:
+#line 147 "scripts/genksyms/parse.y"
+    { struct string_list *decl = *(yyvsp[(1) - (1)]);
+                 *(yyvsp[(1) - (1)]) = NULL;
                  add_symbol(current_name,
                             is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
                  current_name = NULL;
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(1) - (1)]);
                ;}
     break;
 
-  case 18:
-#line 152 "scripts/genksyms/parse.y"
-    { struct string_list *decl = *(yyvsp[0]);
-                 *(yyvsp[0]) = NULL;
-                 free_list(*(yyvsp[-1]), NULL);
-                 *(yyvsp[-1]) = decl_spec;
+  case 20:
+#line 155 "scripts/genksyms/parse.y"
+    { struct string_list *decl = *(yyvsp[(3) - (3)]);
+                 *(yyvsp[(3) - (3)]) = NULL;
+                 free_list(*(yyvsp[(2) - (3)]), NULL);
+                 *(yyvsp[(2) - (3)]) = decl_spec;
                  add_symbol(current_name,
                             is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern);
                  current_name = NULL;
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(3) - (3)]);
                ;}
     break;
 
-  case 19:
-#line 165 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]) ? (yyvsp[-1]) : (yyvsp[-2]) ? (yyvsp[-2]) : (yyvsp[-3]); ;}
+  case 21:
+#line 168 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); ;}
     break;
 
-  case 20:
-#line 170 "scripts/genksyms/parse.y"
+  case 22:
+#line 173 "scripts/genksyms/parse.y"
     { decl_spec = NULL; ;}
     break;
 
-  case 22:
-#line 175 "scripts/genksyms/parse.y"
-    { decl_spec = *(yyvsp[0]); ;}
+  case 24:
+#line 178 "scripts/genksyms/parse.y"
+    { decl_spec = *(yyvsp[(1) - (1)]); ;}
     break;
 
-  case 23:
-#line 176 "scripts/genksyms/parse.y"
-    { decl_spec = *(yyvsp[0]); ;}
+  case 25:
+#line 179 "scripts/genksyms/parse.y"
+    { decl_spec = *(yyvsp[(2) - (2)]); ;}
     break;
 
-  case 24:
-#line 181 "scripts/genksyms/parse.y"
+  case 26:
+#line 184 "scripts/genksyms/parse.y"
     { /* Version 2 checksumming ignores storage class, as that
                     is really irrelevant to the linkage.  */
-                 remove_node((yyvsp[0]));
-                 (yyval) = (yyvsp[0]);
+                 remove_node((yyvsp[(1) - (1)]));
+                 (yyval) = (yyvsp[(1) - (1)]);
                ;}
     break;
 
-  case 29:
-#line 193 "scripts/genksyms/parse.y"
-    { is_extern = 1; (yyval) = (yyvsp[0]); ;}
+  case 31:
+#line 196 "scripts/genksyms/parse.y"
+    { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); ;}
     break;
 
-  case 30:
-#line 194 "scripts/genksyms/parse.y"
-    { is_extern = 0; (yyval) = (yyvsp[0]); ;}
+  case 32:
+#line 197 "scripts/genksyms/parse.y"
+    { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); ;}
     break;
 
-  case 35:
-#line 206 "scripts/genksyms/parse.y"
-    { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_STRUCT; (yyval) = (yyvsp[0]); ;}
+  case 37:
+#line 209 "scripts/genksyms/parse.y"
+    { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 36:
-#line 208 "scripts/genksyms/parse.y"
-    { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_UNION; (yyval) = (yyvsp[0]); ;}
+  case 38:
+#line 211 "scripts/genksyms/parse.y"
+    { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 37:
-#line 210 "scripts/genksyms/parse.y"
-    { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_ENUM; (yyval) = (yyvsp[0]); ;}
+  case 39:
+#line 213 "scripts/genksyms/parse.y"
+    { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 38:
-#line 214 "scripts/genksyms/parse.y"
-    { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r;
+  case 40:
+#line 217 "scripts/genksyms/parse.y"
+    { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
                  r = copy_node(i); r->tag = SYM_STRUCT;
-                 r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL;
+                 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
                  add_symbol(i->string, SYM_STRUCT, s, is_extern);
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(3) - (3)]);
                ;}
     break;
 
-  case 39:
-#line 221 "scripts/genksyms/parse.y"
-    { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r;
+  case 41:
+#line 224 "scripts/genksyms/parse.y"
+    { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
                  r = copy_node(i); r->tag = SYM_UNION;
-                 r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL;
+                 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
                  add_symbol(i->string, SYM_UNION, s, is_extern);
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(3) - (3)]);
                ;}
     break;
 
-  case 40:
-#line 228 "scripts/genksyms/parse.y"
-    { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r;
+  case 42:
+#line 231 "scripts/genksyms/parse.y"
+    { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r;
                  r = copy_node(i); r->tag = SYM_ENUM;
-                 r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL;
+                 r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL;
                  add_symbol(i->string, SYM_ENUM, s, is_extern);
-                 (yyval) = (yyvsp[0]);
+                 (yyval) = (yyvsp[(3) - (3)]);
                ;}
     break;
 
-  case 41:
-#line 236 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 43:
+#line 239 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 42:
-#line 237 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 44:
+#line 240 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 43:
-#line 238 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 45:
+#line 241 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 54:
-#line 252 "scripts/genksyms/parse.y"
-    { (*(yyvsp[0]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[0]); ;}
+  case 56:
+#line 255 "scripts/genksyms/parse.y"
+    { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); ;}
     break;
 
-  case 55:
-#line 257 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;}
+  case 57:
+#line 260 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
     break;
 
-  case 56:
-#line 261 "scripts/genksyms/parse.y"
+  case 58:
+#line 264 "scripts/genksyms/parse.y"
     { (yyval) = NULL; ;}
     break;
 
-  case 59:
-#line 267 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 61:
+#line 270 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 63:
-#line 273 "scripts/genksyms/parse.y"
+  case 65:
+#line 276 "scripts/genksyms/parse.y"
     { /* restrict has no effect in prototypes so ignore it */
-                 remove_node((yyvsp[0]));
-                 (yyval) = (yyvsp[0]);
+                 remove_node((yyvsp[(1) - (1)]));
+                 (yyval) = (yyvsp[(1) - (1)]);
                ;}
     break;
 
-  case 64:
-#line 280 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 66:
+#line 283 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 66:
-#line 286 "scripts/genksyms/parse.y"
+  case 68:
+#line 289 "scripts/genksyms/parse.y"
     { if (current_name != NULL) {
                    error_with_pos("unexpected second declaration name");
                    YYERROR;
                  } else {
-                   current_name = (*(yyvsp[0]))->string;
-                   (yyval) = (yyvsp[0]);
+                   current_name = (*(yyvsp[(1) - (1)]))->string;
+                   (yyval) = (yyvsp[(1) - (1)]);
                  }
                ;}
     break;
 
-  case 67:
-#line 295 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
-    break;
-
-  case 68:
-#line 297 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
-    break;
-
   case 69:
-#line 299 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 298 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 70:
-#line 301 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 300 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 71:
-#line 303 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 302 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 72:
-#line 309 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 304 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 76:
-#line 317 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 73:
+#line 306 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 77:
-#line 319 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 74:
+#line 312 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 78:
-#line 321 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 320 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 79:
-#line 323 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 322 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 80:
-#line 325 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 324 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 81:
-#line 329 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 326 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 83:
-#line 331 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 82:
+#line 328 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 84:
-#line 335 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+  case 83:
+#line 332 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 87:
-#line 342 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 85:
+#line 334 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 88:
-#line 347 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;}
+  case 86:
+#line 338 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
   case 89:
-#line 352 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;}
+#line 345 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 91:
-#line 357 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+  case 90:
+#line 350 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
     break;
 
-  case 92:
-#line 359 "scripts/genksyms/parse.y"
-    { /* For version 2 checksums, we don't want to remember
-                    private parameter names.  */
-                 remove_node((yyvsp[0]));
-                 (yyval) = (yyvsp[0]);
-               ;}
+  case 91:
+#line 355 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
     break;
 
   case 93:
-#line 367 "scripts/genksyms/parse.y"
-    { remove_node((yyvsp[0]));
-                 (yyval) = (yyvsp[0]);
-               ;}
+#line 360 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
   case 94:
-#line 371 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 362 "scripts/genksyms/parse.y"
+    { /* For version 2 checksums, we don't want to remember
+                    private parameter names.  */
+                 remove_node((yyvsp[(1) - (1)]));
+                 (yyval) = (yyvsp[(1) - (1)]);
+               ;}
     break;
 
   case 95:
-#line 373 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 370 "scripts/genksyms/parse.y"
+    { remove_node((yyvsp[(1) - (1)]));
+                 (yyval) = (yyvsp[(1) - (1)]);
+               ;}
     break;
 
   case 96:
-#line 375 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 374 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 97:
-#line 377 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 376 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(4) - (4)]); ;}
     break;
 
   case 98:
-#line 379 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 378 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 99:
-#line 384 "scripts/genksyms/parse.y"
-    { struct string_list *decl = *(yyvsp[-1]);
-                 *(yyvsp[-1]) = NULL;
-                 add_symbol(current_name, SYM_NORMAL, decl, is_extern);
-                 (yyval) = (yyvsp[0]);
-               ;}
+#line 380 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
   case 100:
-#line 392 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+#line 382 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 102:
-#line 399 "scripts/genksyms/parse.y"
-    { remove_list((yyvsp[0]), &(*(yyvsp[-1]))->next); (yyval) = (yyvsp[0]); ;}
+  case 101:
+#line 387 "scripts/genksyms/parse.y"
+    { struct string_list *decl = *(yyvsp[(2) - (3)]);
+                 *(yyvsp[(2) - (3)]) = NULL;
+                 add_symbol(current_name, SYM_NORMAL, decl, is_extern);
+                 (yyval) = (yyvsp[(3) - (3)]);
+               ;}
     break;
 
-  case 103:
-#line 403 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 102:
+#line 395 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
   case 104:
-#line 404 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 402 "scripts/genksyms/parse.y"
+    { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 105:
-#line 408 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+#line 406 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 108:
-#line 414 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 106:
+#line 407 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 109:
-#line 419 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 107:
+#line 411 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
   case 110:
-#line 421 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 417 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 111:
-#line 425 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+#line 422 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
     break;
 
-  case 114:
-#line 431 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+  case 112:
+#line 424 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 115:
-#line 435 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;}
+  case 113:
+#line 428 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
   case 116:
-#line 436 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 434 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(3) - (3)]); ;}
+    break;
+
+  case 117:
+#line 438 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;}
     break;
 
   case 118:
-#line 441 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 439 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
-  case 119:
-#line 445 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+  case 120:
+#line 444 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 121:
-#line 450 "scripts/genksyms/parse.y"
-    { (yyval) = (yyvsp[0]); ;}
+#line 448 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
-  case 122:
-#line 454 "scripts/genksyms/parse.y"
-    { (yyval) = NULL; ;}
+  case 123:
+#line 453 "scripts/genksyms/parse.y"
+    { (yyval) = (yyvsp[(2) - (2)]); ;}
     break;
 
   case 124:
-#line 460 "scripts/genksyms/parse.y"
-    { export_symbol((*(yyvsp[-2]))->string); (yyval) = (yyvsp[0]); ;}
+#line 457 "scripts/genksyms/parse.y"
+    { (yyval) = NULL; ;}
     break;
 
+  case 126:
+#line 463 "scripts/genksyms/parse.y"
+    { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); ;}
+    break;
 
-    }
-
-/* Line 1037 of yacc.c.  */
-#line 1816 "scripts/genksyms/parse.c"
-\f
-  yyvsp -= yylen;
-  yyssp -= yylen;
 
+/* Line 1267 of yacc.c.  */
+#line 2132 "scripts/genksyms/parse.c"
+      default: break;
+    }
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
+  YYPOPSTACK (yylen);
+  yylen = 0;
   YY_STACK_PRINT (yyss, yyssp);
 
   *++yyvsp = yyval;
@@ -1846,66 +2163,41 @@ yyerrlab:
   if (!yyerrstatus)
     {
       ++yynerrs;
-#if YYERROR_VERBOSE
-      yyn = yypact[yystate];
-
-      if (YYPACT_NINF < yyn && yyn < YYLAST)
-       {
-         YYSIZE_T yysize = 0;
-         int yytype = YYTRANSLATE (yychar);
-         const char* yyprefix;
-         char *yymsg;
-         int yyx;
-
-         /* Start YYX at -YYN if negative to avoid negative indexes in
-            YYCHECK.  */
-         int yyxbegin = yyn < 0 ? -yyn : 0;
-
-         /* Stay within bounds of both yycheck and yytname.  */
-         int yychecklim = YYLAST - yyn;
-         int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
-         int yycount = 0;
-
-         yyprefix = ", expecting ";
-         for (yyx = yyxbegin; yyx < yyxend; ++yyx)
-           if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+#if ! YYERROR_VERBOSE
+      yyerror (YY_("syntax error"));
+#else
+      {
+       YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+       if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+         {
+           YYSIZE_T yyalloc = 2 * yysize;
+           if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+             yyalloc = YYSTACK_ALLOC_MAXIMUM;
+           if (yymsg != yymsgbuf)
+             YYSTACK_FREE (yymsg);
+           yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+           if (yymsg)
+             yymsg_alloc = yyalloc;
+           else
              {
-               yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
-               yycount += 1;
-               if (yycount == 5)
-                 {
-                   yysize = 0;
-                   break;
-                 }
+               yymsg = yymsgbuf;
+               yymsg_alloc = sizeof yymsgbuf;
              }
-         yysize += (sizeof ("syntax error, unexpected ")
-                    + yystrlen (yytname[yytype]));
-         yymsg = (char *) YYSTACK_ALLOC (yysize);
-         if (yymsg != 0)
-           {
-             char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
-             yyp = yystpcpy (yyp, yytname[yytype]);
-
-             if (yycount < 5)
-               {
-                 yyprefix = ", expecting ";
-                 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
-                   if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
-                     {
-                       yyp = yystpcpy (yyp, yyprefix);
-                       yyp = yystpcpy (yyp, yytname[yyx]);
-                       yyprefix = " or ";
-                     }
-               }
-             yyerror (yymsg);
-             YYSTACK_FREE (yymsg);
-           }
-         else
-           yyerror ("syntax error; also virtual memory exhausted");
-       }
-      else
-#endif /* YYERROR_VERBOSE */
-       yyerror ("syntax error");
+         }
+
+       if (0 < yysize && yysize <= yymsg_alloc)
+         {
+           (void) yysyntax_error (yymsg, yystate, yychar);
+           yyerror (yymsg);
+         }
+       else
+         {
+           yyerror (YY_("syntax error"));
+           if (yysize != 0)
+             goto yyexhaustedlab;
+         }
+      }
+#endif
     }
 
 
@@ -1916,23 +2208,15 @@ yyerrlab:
         error, discard it.  */
 
       if (yychar <= YYEOF)
-        {
-          /* If at end of input, pop the error token,
-            then the rest of the stack, then return failure.  */
+       {
+         /* Return failure if at end of input.  */
          if (yychar == YYEOF)
-            for (;;)
-              {
-
-                YYPOPSTACK;
-                if (yyssp == yyss)
-                  YYABORT;
-                yydestruct ("Error: popping",
-                             yystos[*yyssp], yyvsp);
-              }
-        }
+           YYABORT;
+       }
       else
        {
-         yydestruct ("Error: discarding", yytoken, &yylval);
+         yydestruct ("Error: discarding",
+                     yytoken, &yylval);
          yychar = YYEMPTY;
        }
     }
@@ -1947,15 +2231,17 @@ yyerrlab:
 `---------------------------------------------------*/
 yyerrorlab:
 
-#ifdef __GNUC__
-  /* Pacify GCC when the user code never invokes YYERROR and the label
-     yyerrorlab therefore never appears in user code.  */
-  if (0)
+  /* Pacify compilers like GCC when the user code never invokes
+     YYERROR and the label yyerrorlab therefore never appears in user
+     code.  */
+  if (/*CONSTCOND*/ 0)
      goto yyerrorlab;
-#endif
 
-yyvsp -= yylen;
-  yyssp -= yylen;
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYERROR.  */
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
   yystate = *yyssp;
   goto yyerrlab1;
 
@@ -1985,8 +2271,9 @@ yyerrlab1:
        YYABORT;
 
 
-      yydestruct ("Error: popping", yystos[yystate], yyvsp);
-      YYPOPSTACK;
+      yydestruct ("Error: popping",
+                 yystos[yystate], yyvsp);
+      YYPOPSTACK (1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
     }
@@ -1997,7 +2284,7 @@ yyerrlab1:
   *++yyvsp = yylval;
 
 
-  /* Shift the error token. */
+  /* Shift the error token.  */
   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
   yystate = yyn;
@@ -2015,32 +2302,47 @@ yyacceptlab:
 | yyabortlab -- YYABORT comes here.  |
 `-----------------------------------*/
 yyabortlab:
-  yydestruct ("Error: discarding lookahead",
-              yytoken, &yylval);
-  yychar = YYEMPTY;
   yyresult = 1;
   goto yyreturn;
 
 #ifndef yyoverflow
-/*----------------------------------------------.
-| yyoverflowlab -- parser overflow comes here.  |
-`----------------------------------------------*/
-yyoverflowlab:
-  yyerror ("parser stack overflow");
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here.  |
+`-------------------------------------------------*/
+yyexhaustedlab:
+  yyerror (YY_("memory exhausted"));
   yyresult = 2;
   /* Fall through.  */
 #endif
 
 yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct ("Cleanup: discarding lookahead",
+                yytoken, &yylval);
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYABORT or YYACCEPT.  */
+  YYPOPSTACK (yylen);
+  YY_STACK_PRINT (yyss, yyssp);
+  while (yyssp != yyss)
+    {
+      yydestruct ("Cleanup: popping",
+                 yystos[*yyssp], yyvsp);
+      YYPOPSTACK (1);
+    }
 #ifndef yyoverflow
   if (yyss != yyssa)
     YYSTACK_FREE (yyss);
 #endif
-  return yyresult;
+#if YYERROR_VERBOSE
+  if (yymsg != yymsgbuf)
+    YYSTACK_FREE (yymsg);
+#endif
+  /* Make sure YYID is used.  */
+  return YYID (yyresult);
 }
 
 
-#line 464 "scripts/genksyms/parse.y"
+#line 467 "scripts/genksyms/parse.y"
 
 
 static void
index f3fb2bb..c4eeec6 100644 (file)
@@ -1,7 +1,9 @@
-/* A Bison parser, made by GNU Bison 2.0.  */
+/* A Bison parser, made by GNU Bison 2.3.  */
 
-/* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
 
-/* As a special exception, when this file is copied by Bison into a
-   Bison output file, you may use that output file without restriction.
-   This special exception was added by the Free Software Foundation
-   in version 1.24 of Bison.  */
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
 
 /* Tokens.  */
 #ifndef YYTOKENTYPE
      DOUBLE_KEYW = 264,
      ENUM_KEYW = 265,
      EXTERN_KEYW = 266,
-     FLOAT_KEYW = 267,
-     INLINE_KEYW = 268,
-     INT_KEYW = 269,
-     LONG_KEYW = 270,
-     REGISTER_KEYW = 271,
-     RESTRICT_KEYW = 272,
-     SHORT_KEYW = 273,
-     SIGNED_KEYW = 274,
-     STATIC_KEYW = 275,
-     STRUCT_KEYW = 276,
-     TYPEDEF_KEYW = 277,
-     UNION_KEYW = 278,
-     UNSIGNED_KEYW = 279,
-     VOID_KEYW = 280,
-     VOLATILE_KEYW = 281,
-     TYPEOF_KEYW = 282,
-     EXPORT_SYMBOL_KEYW = 283,
-     ASM_PHRASE = 284,
-     ATTRIBUTE_PHRASE = 285,
-     BRACE_PHRASE = 286,
-     BRACKET_PHRASE = 287,
-     EXPRESSION_PHRASE = 288,
-     CHAR = 289,
-     DOTS = 290,
-     IDENT = 291,
-     INT = 292,
-     REAL = 293,
-     STRING = 294,
-     TYPE = 295,
-     OTHER = 296,
-     FILENAME = 297
+     EXTENSION_KEYW = 267,
+     FLOAT_KEYW = 268,
+     INLINE_KEYW = 269,
+     INT_KEYW = 270,
+     LONG_KEYW = 271,
+     REGISTER_KEYW = 272,
+     RESTRICT_KEYW = 273,
+     SHORT_KEYW = 274,
+     SIGNED_KEYW = 275,
+     STATIC_KEYW = 276,
+     STRUCT_KEYW = 277,
+     TYPEDEF_KEYW = 278,
+     UNION_KEYW = 279,
+     UNSIGNED_KEYW = 280,
+     VOID_KEYW = 281,
+     VOLATILE_KEYW = 282,
+     TYPEOF_KEYW = 283,
+     EXPORT_SYMBOL_KEYW = 284,
+     ASM_PHRASE = 285,
+     ATTRIBUTE_PHRASE = 286,
+     BRACE_PHRASE = 287,
+     BRACKET_PHRASE = 288,
+     EXPRESSION_PHRASE = 289,
+     CHAR = 290,
+     DOTS = 291,
+     IDENT = 292,
+     INT = 293,
+     REAL = 294,
+     STRING = 295,
+     TYPE = 296,
+     OTHER = 297,
+     FILENAME = 298
    };
 #endif
+/* Tokens.  */
 #define ASM_KEYW 258
 #define ATTRIBUTE_KEYW 259
 #define AUTO_KEYW 260
 #define DOUBLE_KEYW 264
 #define ENUM_KEYW 265
 #define EXTERN_KEYW 266
-#define FLOAT_KEYW 267
-#define INLINE_KEYW 268
-#define INT_KEYW 269
-#define LONG_KEYW 270
-#define REGISTER_KEYW 271
-#define RESTRICT_KEYW 272
-#define SHORT_KEYW 273
-#define SIGNED_KEYW 274
-#define STATIC_KEYW 275
-#define STRUCT_KEYW 276
-#define TYPEDEF_KEYW 277
-#define UNION_KEYW 278
-#define UNSIGNED_KEYW 279
-#define VOID_KEYW 280
-#define VOLATILE_KEYW 281
-#define TYPEOF_KEYW 282
-#define EXPORT_SYMBOL_KEYW 283
-#define ASM_PHRASE 284
-#define ATTRIBUTE_PHRASE 285
-#define BRACE_PHRASE 286
-#define BRACKET_PHRASE 287
-#define EXPRESSION_PHRASE 288
-#define CHAR 289
-#define DOTS 290
-#define IDENT 291
-#define INT 292
-#define REAL 293
-#define STRING 294
-#define TYPE 295
-#define OTHER 296
-#define FILENAME 297
+#define EXTENSION_KEYW 267
+#define FLOAT_KEYW 268
+#define INLINE_KEYW 269
+#define INT_KEYW 270
+#define LONG_KEYW 271
+#define REGISTER_KEYW 272
+#define RESTRICT_KEYW 273
+#define SHORT_KEYW 274
+#define SIGNED_KEYW 275
+#define STATIC_KEYW 276
+#define STRUCT_KEYW 277
+#define TYPEDEF_KEYW 278
+#define UNION_KEYW 279
+#define UNSIGNED_KEYW 280
+#define VOID_KEYW 281
+#define VOLATILE_KEYW 282
+#define TYPEOF_KEYW 283
+#define EXPORT_SYMBOL_KEYW 284
+#define ASM_PHRASE 285
+#define ATTRIBUTE_PHRASE 286
+#define BRACE_PHRASE 287
+#define BRACKET_PHRASE 288
+#define EXPRESSION_PHRASE 289
+#define CHAR 290
+#define DOTS 291
+#define IDENT 292
+#define INT 293
+#define REAL 294
+#define STRING 295
+#define TYPE 296
+#define OTHER 297
+#define FILENAME 298
 
 
 
 
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef int YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -124,5 +137,3 @@ typedef int YYSTYPE;
 
 extern YYSTYPE yylval;
 
-
-
index ca04c94..408cdf8 100644 (file)
@@ -61,6 +61,7 @@ remove_list(struct string_list **pb, struct string_list **pe)
 %token DOUBLE_KEYW
 %token ENUM_KEYW
 %token EXTERN_KEYW
+%token EXTENSION_KEYW
 %token FLOAT_KEYW
 %token INLINE_KEYW
 %token INT_KEYW
@@ -110,7 +111,9 @@ declaration:
        ;
 
 declaration1:
-       TYPEDEF_KEYW { is_typedef = 1; } simple_declaration
+       EXTENSION_KEYW TYPEDEF_KEYW { is_typedef = 1; } simple_declaration
+               { $$ = $4; }
+       | TYPEDEF_KEYW { is_typedef = 1; } simple_declaration
                { $$ = $3; }
        | simple_declaration
        | function_definition
index be2527a..6ba1145 100644 (file)
@@ -4,23 +4,30 @@
 
 PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
 
+# If a arch/$(SRCARCH)/Kconfig.$(ARCH) file exist use it
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/Kconfig.$(ARCH)),)
+        Kconfig := arch/$(SRCARCH)/Kconfig.$(ARCH)
+else
+        Kconfig := arch/$(SRCARCH)/Kconfig
+endif
+
 xconfig: $(obj)/qconf
-       $< arch/$(ARCH)/Kconfig
+       $< $(Kconfig)
 
 gconfig: $(obj)/gconf
-       $< arch/$(ARCH)/Kconfig
+       $< $(Kconfig)
 
 menuconfig: $(obj)/mconf
-       $< arch/$(ARCH)/Kconfig
+       $< $(Kconfig)
 
 config: $(obj)/conf
-       $< arch/$(ARCH)/Kconfig
+       $< $(Kconfig)
 
 oldconfig: $(obj)/conf
-       $< -o arch/$(ARCH)/Kconfig
+       $< -o $(Kconfig)
 
 silentoldconfig: $(obj)/conf
-       $< -s arch/$(ARCH)/Kconfig
+       $< -s $(Kconfig)
 
 # Create new linux.po file
 # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
@@ -45,16 +52,16 @@ update-po-config: $(obj)/kxgettext
 PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
 
 randconfig: $(obj)/conf
-       $< -r arch/$(ARCH)/Kconfig
+       $< -r $(Kconfig)
 
 allyesconfig: $(obj)/conf
-       $< -y arch/$(ARCH)/Kconfig
+       $< -y $(Kconfig)
 
 allnoconfig: $(obj)/conf
-       $< -n arch/$(ARCH)/Kconfig
+       $< -n $(Kconfig)
 
 allmodconfig: $(obj)/conf
-       $< -m arch/$(ARCH)/Kconfig
+       $< -m $(Kconfig)
 
 UNAME_RELEASE := $(shell uname -r)
 CLONECONFIG := $(firstword $(wildcard /proc/config.gz \
@@ -74,14 +81,14 @@ cloneconfig: $(obj)/conf
 
 defconfig: $(obj)/conf
 ifeq ($(KBUILD_DEFCONFIG),)
-       $< -d arch/$(ARCH)/Kconfig
+       $< -d $(Kconfig)
 else
-       @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)'
-       $(Q)$< -D arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG) arch/$(ARCH)/Kconfig
+       @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
+       $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
 endif
 
 %_defconfig: $(obj)/conf
-       $(Q)$< -D arch/$(ARCH)/configs/$@ arch/$(ARCH)/Kconfig
+       $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
 
 # Help text used by make help
 help:
@@ -100,7 +107,7 @@ help:
 # lxdialog stuff
 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
 
-# Use reursively expanded variables so we do not call gcc unless
+# Use recursively expanded variables so we do not call gcc unless
 # we really need to do so. (Do not call gcc as part of make mrproper)
 HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
 HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
@@ -159,14 +166,8 @@ clean-files        := lkc_defs.h qconf.moc .tmp_qtcheck \
                   .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
 clean-files     += mconf qconf gconf
 
-# Needed for systems without gettext
-KBUILD_HAVE_NLS := $(shell \
-     if echo "\#include <libintl.h>" | $(HOSTCC) $(HOSTCFLAGS) -E - > /dev/null 2>&1 ; \
-     then echo yes ; \
-     else echo no ; fi)
-ifeq ($(KBUILD_HAVE_NLS),no)
-HOSTCFLAGS     += -DKBUILD_NO_NLS
-endif
+# Add environment specific flags
+HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
 
 # generated files seem to need this to find local include files
 HOSTCFLAGS_lex.zconf.o := -I$(src)
diff --git a/scripts/kconfig/check.sh b/scripts/kconfig/check.sh
new file mode 100644 (file)
index 0000000..fa59cbf
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Needed for systems without gettext
+$* -xc -o /dev/null - > /dev/null 2>&1 << EOF
+#include <libintl.h>
+int main()
+{
+       gettext("");
+       return 0;
+}
+EOF
+if [ ! "$?" -eq "0"  ]; then
+       echo -DKBUILD_NO_NLS;
+fi
+
index 0fdc904..a065d5a 100644 (file)
@@ -5,6 +5,25 @@
 
 /* A lexical scanner generated by flex */
 
+#define yy_create_buffer zconf_create_buffer
+#define yy_delete_buffer zconf_delete_buffer
+#define yy_flex_debug zconf_flex_debug
+#define yy_init_buffer zconf_init_buffer
+#define yy_flush_buffer zconf_flush_buffer
+#define yy_load_buffer_state zconf_load_buffer_state
+#define yy_switch_to_buffer zconf_switch_to_buffer
+#define yyin zconfin
+#define yyleng zconfleng
+#define yylex zconflex
+#define yylineno zconflineno
+#define yyout zconfout
+#define yyrestart zconfrestart
+#define yytext zconftext
+#define yywrap zconfwrap
+#define yyalloc zconfalloc
+#define yyrealloc zconfrealloc
+#define yyfree zconffree
+
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
@@ -33,7 +52,7 @@
 #if __STDC_VERSION__ >= 199901L
 
 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
+ * if you want the limit (max/min) macros for int types. 
  */
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS 1
@@ -335,7 +354,7 @@ void zconffree (void *  );
 
 /* Begin user sect3 */
 
-#define zconfwrap() 1
+#define zconfwrap(n) 1
 #define YY_SKIP_YYWRAP
 
 typedef unsigned char YY_CHAR;
@@ -1983,7 +2002,7 @@ YY_BUFFER_STATE zconf_scan_buffer  (char * base, yy_size_t  size )
 
 /** Setup the input buffer state to scan a string. The next call to zconflex() will
  * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
+ * @param str a NUL-terminated string to scan
  * 
  * @return the newly allocated buffer state object.
  * @note If you want to scan bytes that may contain NUL values, then use
index bc5854e..47e226f 100644 (file)
@@ -35,9 +35,13 @@ static const char mconf_readme[] = N_(
 "kernel parameters which are not really features, but must be\n"
 "entered in as decimal or hexadecimal numbers or possibly text.\n"
 "\n"
-"Menu items beginning with [*], <M> or [ ] represent features\n"
-"configured to be built in, modularized or removed respectively.\n"
-"Pointed brackets <> represent module capable features.\n"
+"Menu items beginning with following braces represent features that\n"
+"  [ ] can be built in or removed\n"
+"  < > can be built in, modularized or removed\n"
+"  { } can be built in or modularized (selected by other feature)\n"
+"  - - are selected by other feature,\n"
+"while *, M or whitespace inside braces means to build in, build as\n"
+"a module or to exclude the feature respectively.\n"
 "\n"
 "To change any of these features, highlight it with the cursor\n"
 "keys and press <Y> to build it in, <M> to make it a module or\n"
@@ -357,8 +361,9 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym)
        bool hit;
        struct property *prop;
 
-       str_printf(r, "Symbol: %s [=%s]\n", sym->name,
-                                      sym_get_string_value(sym));
+       if (sym && sym->name)
+               str_printf(r, "Symbol: %s [=%s]\n", sym->name,
+                                                   sym_get_string_value(sym));
        for_all_prompts(sym, prop)
                get_prompt_str(r, prop);
        hit = false;
@@ -481,6 +486,14 @@ static void build_conf(struct menu *menu)
                                if (single_menu_mode && menu->data)
                                        goto conf_childs;
                                return;
+                       case P_COMMENT:
+                               if (prompt) {
+                                       child_count++;
+                                       item_make("   %*c*** %s ***", indent + 1, ' ', prompt);
+                                       item_set_tag(':');
+                                       item_set_data(menu);
+                               }
+                               break;
                        default:
                                if (prompt) {
                                        child_count++;
@@ -560,7 +573,7 @@ static void build_conf(struct menu *menu)
                                if (sym_is_changable(sym))
                                        item_make("[%c]", val == no ? ' ' : '*');
                                else
-                                       item_make("---");
+                                       item_make("-%c-", val == no ? ' ' : '*');
                                item_set_tag('t');
                                item_set_data(menu);
                                break;
@@ -570,10 +583,13 @@ static void build_conf(struct menu *menu)
                                case mod: ch = 'M'; break;
                                default:  ch = ' '; break;
                                }
-                               if (sym_is_changable(sym))
-                                       item_make("<%c>", ch);
-                               else
-                                       item_make("---");
+                               if (sym_is_changable(sym)) {
+                                       if (sym->rev_dep.tri == mod)
+                                               item_make("{%c}", ch);
+                                       else
+                                               item_make("<%c>", ch);
+                               } else
+                                       item_make("-%c-", ch);
                                item_set_tag('t');
                                item_set_data(menu);
                                break;
index e4eeb59..b9bb32d 100644 (file)
@@ -1274,8 +1274,12 @@ ConfigMainWindow::ConfigMainWindow(void)
        QMenuBar* menu;
        bool ok;
        int x, y, width, height;
+       char title[256];
 
        QWidget *d = configApp->desktop();
+       snprintf(title, sizeof(title), _("Linux Kernel v%s Configuration"),
+               getenv("KERNELVERSION"));
+       setCaption(title);
 
        width = configSettings->readNumEntry("/window width", d->width() - 64);
        height = configSettings->readNumEntry("/window height", d->height() - 64);
index e3f28b9..e1cad92 100644 (file)
@@ -84,12 +84,15 @@ void str_free(struct gstr *gs)
 /* Append to growable string */
 void str_append(struct gstr *gs, const char *s)
 {
-       size_t l = strlen(gs->s) + strlen(s) + 1;
-       if (l > gs->len) {
-               gs->s   = realloc(gs->s, l);
-               gs->len = l;
+       size_t l;
+       if (s) {
+               l = strlen(gs->s) + strlen(s) + 1;
+               if (l > gs->len) {
+                       gs->s   = realloc(gs->s, l);
+                       gs->len = l;
+               }
+               strcat(gs->s, s);
        }
-       strcat(gs->s, s);
 }
 
 /* Append printf formatted string to growable string */
index 9b44c80..93538e5 100644 (file)
@@ -23,7 +23,6 @@ help,         T_HELP,         TF_COMMAND
 if,            T_IF,           TF_COMMAND|TF_PARAM
 endif,         T_ENDIF,        TF_COMMAND
 depends,       T_DEPENDS,      TF_COMMAND
-requires,      T_REQUIRES,     TF_COMMAND
 optional,      T_OPTIONAL,     TF_COMMAND
 default,       T_DEFAULT,      TF_COMMAND, S_UNKNOWN
 prompt,                T_PROMPT,       TF_COMMAND
@@ -32,7 +31,6 @@ def_tristate, T_DEFAULT,      TF_COMMAND, S_TRISTATE
 bool,          T_TYPE,         TF_COMMAND, S_BOOLEAN
 boolean,       T_TYPE,         TF_COMMAND, S_BOOLEAN
 def_bool,      T_DEFAULT,      TF_COMMAND, S_BOOLEAN
-def_boolean,   T_DEFAULT,      TF_COMMAND, S_BOOLEAN
 int,           T_TYPE,         TF_COMMAND, S_INT
 hex,           T_TYPE,         TF_COMMAND, S_HEX
 string,                T_TYPE,         TF_COMMAND, S_STRING
index 47c8b5b..ab28b18 100644 (file)
@@ -1,4 +1,4 @@
-/* ANSI-C code produced by gperf version 3.0.1 */
+/* ANSI-C code produced by gperf version 3.0.2 */
 /* Command-line: gperf  */
 /* Computed positions: -k'1,3' */
 
@@ -30,7 +30,7 @@
 #endif
 
 struct kconf_id;
-/* maximum key range = 45, duplicates = 0 */
+/* maximum key range = 47, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -44,32 +44,32 @@ kconf_id_hash (register const char *str, register unsigned int len)
 {
   static unsigned char asso_values[] =
     {
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 25, 30, 15,
-       0, 15,  0, 47,  5, 15, 47, 47, 30, 20,
-       5,  0, 25, 15,  0,  0, 10, 35, 47, 47,
-       5, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
-      47, 47, 47, 47, 47, 47
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 18, 11,  5,
+       0,  0,  5, 49,  5, 20, 49, 49,  5, 20,
+       5,  0, 30, 49,  0, 15,  0, 10, 49, 49,
+      25, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+      49, 49, 49, 49, 49, 49
     };
   register int hval = len;
 
@@ -89,74 +89,70 @@ kconf_id_hash (register const char *str, register unsigned int len)
 struct kconf_id_strings_t
   {
     char kconf_id_strings_str2[sizeof("on")];
-    char kconf_id_strings_str6[sizeof("string")];
-    char kconf_id_strings_str7[sizeof("default")];
-    char kconf_id_strings_str8[sizeof("def_bool")];
+    char kconf_id_strings_str5[sizeof("endif")];
+    char kconf_id_strings_str6[sizeof("option")];
+    char kconf_id_strings_str7[sizeof("endmenu")];
+    char kconf_id_strings_str8[sizeof("optional")];
+    char kconf_id_strings_str9[sizeof("endchoice")];
     char kconf_id_strings_str10[sizeof("range")];
-    char kconf_id_strings_str11[sizeof("def_boolean")];
-    char kconf_id_strings_str12[sizeof("def_tristate")];
-    char kconf_id_strings_str13[sizeof("hex")];
-    char kconf_id_strings_str14[sizeof("defconfig_list")];
-    char kconf_id_strings_str16[sizeof("option")];
-    char kconf_id_strings_str17[sizeof("if")];
-    char kconf_id_strings_str18[sizeof("optional")];
-    char kconf_id_strings_str20[sizeof("endif")];
-    char kconf_id_strings_str21[sizeof("choice")];
-    char kconf_id_strings_str22[sizeof("endmenu")];
-    char kconf_id_strings_str23[sizeof("requires")];
-    char kconf_id_strings_str24[sizeof("endchoice")];
-    char kconf_id_strings_str26[sizeof("config")];
+    char kconf_id_strings_str11[sizeof("choice")];
+    char kconf_id_strings_str12[sizeof("default")];
+    char kconf_id_strings_str13[sizeof("def_bool")];
+    char kconf_id_strings_str14[sizeof("help")];
+    char kconf_id_strings_str15[sizeof("bool")];
+    char kconf_id_strings_str16[sizeof("config")];
+    char kconf_id_strings_str17[sizeof("def_tristate")];
+    char kconf_id_strings_str18[sizeof("boolean")];
+    char kconf_id_strings_str19[sizeof("defconfig_list")];
+    char kconf_id_strings_str21[sizeof("string")];
+    char kconf_id_strings_str22[sizeof("if")];
+    char kconf_id_strings_str23[sizeof("int")];
+    char kconf_id_strings_str24[sizeof("enable")];
+    char kconf_id_strings_str26[sizeof("select")];
     char kconf_id_strings_str27[sizeof("modules")];
-    char kconf_id_strings_str28[sizeof("int")];
+    char kconf_id_strings_str28[sizeof("tristate")];
     char kconf_id_strings_str29[sizeof("menu")];
-    char kconf_id_strings_str31[sizeof("prompt")];
-    char kconf_id_strings_str32[sizeof("depends")];
-    char kconf_id_strings_str33[sizeof("tristate")];
-    char kconf_id_strings_str34[sizeof("bool")];
+    char kconf_id_strings_str31[sizeof("source")];
+    char kconf_id_strings_str32[sizeof("comment")];
+    char kconf_id_strings_str33[sizeof("hex")];
     char kconf_id_strings_str35[sizeof("menuconfig")];
-    char kconf_id_strings_str36[sizeof("select")];
-    char kconf_id_strings_str37[sizeof("boolean")];
-    char kconf_id_strings_str39[sizeof("help")];
-    char kconf_id_strings_str41[sizeof("source")];
-    char kconf_id_strings_str42[sizeof("comment")];
-    char kconf_id_strings_str43[sizeof("mainmenu")];
-    char kconf_id_strings_str46[sizeof("enable")];
+    char kconf_id_strings_str36[sizeof("prompt")];
+    char kconf_id_strings_str37[sizeof("depends")];
+    char kconf_id_strings_str48[sizeof("mainmenu")];
   };
 static struct kconf_id_strings_t kconf_id_strings_contents =
   {
     "on",
-    "string",
+    "endif",
+    "option",
+    "endmenu",
+    "optional",
+    "endchoice",
+    "range",
+    "choice",
     "default",
     "def_bool",
-    "range",
-    "def_boolean",
+    "help",
+    "bool",
+    "config",
     "def_tristate",
-    "hex",
+    "boolean",
     "defconfig_list",
-    "option",
+    "string",
     "if",
-    "optional",
-    "endif",
-    "choice",
-    "endmenu",
-    "requires",
-    "endchoice",
-    "config",
-    "modules",
     "int",
-    "menu",
-    "prompt",
-    "depends",
-    "tristate",
-    "bool",
-    "menuconfig",
+    "enable",
     "select",
-    "boolean",
-    "help",
+    "modules",
+    "tristate",
+    "menu",
     "source",
     "comment",
-    "mainmenu",
-    "enable"
+    "hex",
+    "menuconfig",
+    "prompt",
+    "depends",
+    "mainmenu"
   };
 #define kconf_id_strings ((const char *) &kconf_id_strings_contents)
 #ifdef __GNUC__
@@ -167,58 +163,54 @@ kconf_id_lookup (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 33,
+      TOTAL_KEYWORDS = 31,
       MIN_WORD_LENGTH = 2,
       MAX_WORD_LENGTH = 14,
       MIN_HASH_VALUE = 2,
-      MAX_HASH_VALUE = 46
+      MAX_HASH_VALUE = 48
     };
 
   static struct kconf_id wordlist[] =
     {
       {-1}, {-1},
       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2,            T_ON,           TF_PARAM},
-      {-1}, {-1}, {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6,            T_TYPE,         TF_COMMAND, S_STRING},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7,    T_DEFAULT,      TF_COMMAND, S_UNKNOWN},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8,    T_DEFAULT,      TF_COMMAND, S_BOOLEAN},
-      {-1},
+      {-1}, {-1},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5,            T_ENDIF,        TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6,            T_OPTION,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7,    T_ENDMENU,      TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8,    T_OPTIONAL,     TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9,    T_ENDCHOICE,    TF_COMMAND},
       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10,           T_RANGE,        TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11,   T_DEFAULT,      TF_COMMAND, S_BOOLEAN},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,   T_DEFAULT,      TF_COMMAND, S_TRISTATE},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,           T_TYPE,         TF_COMMAND, S_HEX},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,   T_OPT_DEFCONFIG_LIST,TF_OPTION},
-      {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16,           T_OPTION,       TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,           T_IF,           TF_COMMAND|TF_PARAM},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,   T_OPTIONAL,     TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11,           T_CHOICE,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,   T_DEFAULT,      TF_COMMAND, S_UNKNOWN},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,   T_DEFAULT,      TF_COMMAND, S_BOOLEAN},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,           T_HELP,         TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15,           T_TYPE,         TF_COMMAND, S_BOOLEAN},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16,           T_CONFIG,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,   T_DEFAULT,      TF_COMMAND, S_TRISTATE},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,   T_TYPE,         TF_COMMAND, S_BOOLEAN},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19,   T_OPT_DEFCONFIG_LIST,TF_OPTION},
       {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20,           T_ENDIF,        TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,           T_CHOICE,       TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,   T_ENDMENU,      TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23,   T_REQUIRES,     TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str24,   T_ENDCHOICE,    TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,           T_TYPE,         TF_COMMAND, S_STRING},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,           T_IF,           TF_COMMAND|TF_PARAM},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23,           T_TYPE,         TF_COMMAND, S_INT},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str24,           T_SELECT,       TF_COMMAND},
       {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26,           T_CONFIG,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26,           T_SELECT,       TF_COMMAND},
       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27,   T_OPT_MODULES,  TF_OPTION},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,           T_TYPE,         TF_COMMAND, S_INT},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,   T_TYPE,         TF_COMMAND, S_TRISTATE},
       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29,           T_MENU,         TF_COMMAND},
       {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,           T_PROMPT,       TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,   T_DEPENDS,      TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33,   T_TYPE,         TF_COMMAND, S_TRISTATE},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34,           T_TYPE,         TF_COMMAND, S_BOOLEAN},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35,   T_MENUCONFIG,   TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36,           T_SELECT,       TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37,   T_TYPE,         TF_COMMAND, S_BOOLEAN},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,           T_SOURCE,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,   T_COMMENT,      TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33,           T_TYPE,         TF_COMMAND, S_HEX},
       {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39,           T_HELP,         TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35,   T_MENUCONFIG,   TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36,           T_PROMPT,       TF_COMMAND},
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37,   T_DEPENDS,      TF_COMMAND},
+      {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
       {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41,           T_SOURCE,       TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42,   T_COMMENT,      TF_COMMAND},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43,   T_MAINMENU,     TF_COMMAND},
-      {-1}, {-1},
-      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46,           T_SELECT,       TF_COMMAND}
+      {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48,   T_MAINMENU,     TF_COMMAND}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
index ec21db7..d22d924 100644 (file)
@@ -1,7 +1,9 @@
-/* A Bison parser, made by GNU Bison 2.1.  */
+/* A Bison parser, made by GNU Bison 2.3.  */
 
-/* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
-/* As a special exception, when this file is copied by Bison into a
-   Bison output file, you may use that output file without restriction.
-   This special exception was added by the Free Software Foundation
-   in version 1.24 of Bison.  */
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
 
-/* Written by Richard Stallman by simplifying the original so called
-   ``semantic'' parser.  */
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+   simplifying the original so-called "semantic" parser.  */
 
 /* All symbols defined below should begin with yy or YY, to avoid
    infringing on user name space.  This should be done even for local
@@ -37,7 +47,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.1"
+#define YYBISON_VERSION "2.3"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
      T_IF = 269,
      T_ENDIF = 270,
      T_DEPENDS = 271,
-     T_REQUIRES = 272,
-     T_OPTIONAL = 273,
-     T_PROMPT = 274,
-     T_TYPE = 275,
-     T_DEFAULT = 276,
-     T_SELECT = 277,
-     T_RANGE = 278,
-     T_OPTION = 279,
-     T_ON = 280,
-     T_WORD = 281,
-     T_WORD_QUOTE = 282,
-     T_UNEQUAL = 283,
-     T_CLOSE_PAREN = 284,
-     T_OPEN_PAREN = 285,
-     T_EOL = 286,
-     T_OR = 287,
-     T_AND = 288,
-     T_EQUAL = 289,
-     T_NOT = 290
+     T_OPTIONAL = 272,
+     T_PROMPT = 273,
+     T_TYPE = 274,
+     T_DEFAULT = 275,
+     T_SELECT = 276,
+     T_RANGE = 277,
+     T_OPTION = 278,
+     T_ON = 279,
+     T_WORD = 280,
+     T_WORD_QUOTE = 281,
+     T_UNEQUAL = 282,
+     T_CLOSE_PAREN = 283,
+     T_OPEN_PAREN = 284,
+     T_EOL = 285,
+     T_OR = 286,
+     T_AND = 287,
+     T_EQUAL = 288,
+     T_NOT = 289
    };
 #endif
 /* Tokens.  */
 #define T_IF 269
 #define T_ENDIF 270
 #define T_DEPENDS 271
-#define T_REQUIRES 272
-#define T_OPTIONAL 273
-#define T_PROMPT 274
-#define T_TYPE 275
-#define T_DEFAULT 276
-#define T_SELECT 277
-#define T_RANGE 278
-#define T_OPTION 279
-#define T_ON 280
-#define T_WORD 281
-#define T_WORD_QUOTE 282
-#define T_UNEQUAL 283
-#define T_CLOSE_PAREN 284
-#define T_OPEN_PAREN 285
-#define T_EOL 286
-#define T_OR 287
-#define T_AND 288
-#define T_EQUAL 289
-#define T_NOT 290
+#define T_OPTIONAL 272
+#define T_PROMPT 273
+#define T_TYPE 274
+#define T_DEFAULT 275
+#define T_SELECT 276
+#define T_RANGE 277
+#define T_OPTION 278
+#define T_ON 279
+#define T_WORD 280
+#define T_WORD_QUOTE 281
+#define T_UNEQUAL 282
+#define T_CLOSE_PAREN 283
+#define T_OPEN_PAREN 284
+#define T_EOL 285
+#define T_OR 286
+#define T_AND 287
+#define T_EQUAL 288
+#define T_NOT 289
 
 
 
@@ -198,18 +206,20 @@ static struct menu *current_menu, *current_entry;
 # define YYTOKEN_TABLE 0
 #endif
 
-#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
 
-typedef union YYSTYPE {
+{
        char *string;
        struct file *file;
        struct symbol *symbol;
        struct expr *expr;
        struct menu *menu;
        struct kconf_id *id;
-} YYSTYPE;
-/* Line 196 of yacc.c.  */
+}
+/* Line 187 of yacc.c.  */
 
+       YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 # define YYSTYPE_IS_TRIVIAL 1
@@ -220,23 +230,56 @@ typedef union YYSTYPE {
 /* Copy the second part of user declarations.  */
 
 
-/* Line 219 of yacc.c.  */
+/* Line 216 of yacc.c.  */
+
+
+#ifdef short
+# undef short
+#endif
 
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
 
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
 #endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
 #endif
-#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
 #endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+#  define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+#  define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
+# else
+#  define YYSIZE_T unsigned int
+# endif
 #endif
 
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
 #ifndef YY_
 # if YYENABLE_NLS
 #  if ENABLE_NLS
@@ -249,7 +292,32 @@ typedef union YYSTYPE {
 # endif
 #endif
 
-#if ! defined (yyoverflow) || YYERROR_VERBOSE
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions.  */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+    int i;
+#endif
+{
+  return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
 
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
 
@@ -257,64 +325,76 @@ typedef union YYSTYPE {
 #  if YYSTACK_USE_ALLOCA
 #   ifdef __GNUC__
 #    define YYSTACK_ALLOC __builtin_alloca
+#   elif defined __BUILTIN_VA_ARG_INCR
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+#   elif defined _AIX
+#    define YYSTACK_ALLOC __alloca
+#   elif defined _MSC_VER
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+#    define alloca _alloca
 #   else
 #    define YYSTACK_ALLOC alloca
-#    if defined (__STDC__) || defined (__cplusplus)
+#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-#     define YYINCLUDED_STDLIB_H
+#     ifndef _STDLIB_H
+#      define _STDLIB_H 1
+#     endif
 #    endif
 #   endif
 #  endif
 # endif
 
 # ifdef YYSTACK_ALLOC
-   /* Pacify GCC's `empty if-body' warning. */
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+   /* Pacify GCC's `empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
 #  ifndef YYSTACK_ALLOC_MAXIMUM
     /* The OS might guarantee only one guard page at the bottom of the stack,
        and a page size can be as small as 4096 bytes.  So we cannot safely
        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
        to allow for a few compiler-allocated temporary stack slots.  */
-#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
 #  endif
 # else
 #  define YYSTACK_ALLOC YYMALLOC
 #  define YYSTACK_FREE YYFREE
 #  ifndef YYSTACK_ALLOC_MAXIMUM
-#   define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
 #  endif
-#  ifdef __cplusplus
-extern "C" {
+#  if (defined __cplusplus && ! defined _STDLIB_H \
+       && ! ((defined YYMALLOC || defined malloc) \
+            && (defined YYFREE || defined free)))
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   ifndef _STDLIB_H
+#    define _STDLIB_H 1
+#   endif
 #  endif
 #  ifndef YYMALLOC
 #   define YYMALLOC malloc
-#   if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
-       && (defined (__STDC__) || defined (__cplusplus)))
+#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
 #  ifndef YYFREE
 #   define YYFREE free
-#   if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
-       && (defined (__STDC__) || defined (__cplusplus)))
+#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 void free (void *); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
-#  ifdef __cplusplus
-}
-#  endif
 # endif
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
 
 
-#if (! defined (yyoverflow) \
-     && (! defined (__cplusplus) \
-        || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
+#if (! defined yyoverflow \
+     && (! defined __cplusplus \
+        || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
 {
-  short int yyss;
+  yytype_int16 yyss;
   YYSTYPE yyvs;
   };
 
@@ -324,13 +404,13 @@ union yyalloc
 /* The size of an array large to enough to hold all stacks, each with
    N elements.  */
 # define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (short int) + sizeof (YYSTYPE))                    \
+     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
       + YYSTACK_GAP_MAXIMUM)
 
 /* Copy COUNT objects from FROM to TO.  The source and destination do
    not overlap.  */
 # ifndef YYCOPY
-#  if defined (__GNUC__) && 1 < __GNUC__
+#  if defined __GNUC__ && 1 < __GNUC__
 #   define YYCOPY(To, From, Count) \
       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
 #  else
@@ -341,7 +421,7 @@ union yyalloc
          for (yyi = 0; yyi < (Count); yyi++)   \
            (To)[yyi] = (From)[yyi];            \
        }                                       \
-      while (0)
+      while (YYID (0))
 #  endif
 # endif
 
@@ -359,39 +439,33 @@ union yyalloc
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
        yyptr += yynewbytes / sizeof (*yyptr);                          \
       }                                                                        \
-    while (0)
+    while (YYID (0))
 
 #endif
 
-#if defined (__STDC__) || defined (__cplusplus)
-   typedef signed char yysigned_char;
-#else
-   typedef short int yysigned_char;
-#endif
-
-/* YYFINAL -- State number of the termination state. */
+/* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  3
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   275
+#define YYLAST   258
 
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS  36
-/* YYNNTS -- Number of nonterminals. */
+/* YYNTOKENS -- Number of terminals.  */
+#define YYNTOKENS  35
+/* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  45
-/* YYNRULES -- Number of rules. */
-#define YYNRULES  110
-/* YYNRULES -- Number of states. */
-#define YYNSTATES  183
+/* YYNRULES -- Number of rules.  */
+#define YYNRULES  108
+/* YYNRULES -- Number of states.  */
+#define YYNSTATES  178
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   290
+#define YYMAXUTOK   289
 
 #define YYTRANSLATE(YYX)                                               \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
-static const unsigned char yytranslate[] =
+static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -421,14 +495,13 @@ static const unsigned char yytranslate[] =
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
-      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
-      35
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34
 };
 
 #if YYDEBUG
 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const unsigned short int yyprhs[] =
+static const yytype_uint16 yyprhs[] =
 {
        0,     0,     3,     5,     6,     9,    12,    15,    20,    23,
       28,    33,    37,    39,    41,    43,    45,    47,    49,    51,
@@ -439,80 +512,77 @@ static const unsigned short int yyprhs[] =
      178,   181,   186,   187,   190,   194,   196,   200,   201,   204,
      207,   210,   214,   217,   219,   223,   224,   227,   230,   233,
      237,   241,   244,   247,   250,   251,   254,   257,   260,   265,
-     269,   273,   274,   277,   279,   281,   284,   287,   290,   292,
-     295,   296,   299,   301,   305,   309,   313,   316,   320,   324,
-     326
+     266,   269,   271,   273,   276,   279,   282,   284,   287,   288,
+     291,   293,   297,   301,   305,   308,   312,   316,   318
 };
 
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yysigned_char yyrhs[] =
+/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+static const yytype_int8 yyrhs[] =
 {
-      37,     0,    -1,    38,    -1,    -1,    38,    40,    -1,    38,
-      54,    -1,    38,    65,    -1,    38,     3,    75,    77,    -1,
-      38,    76,    -1,    38,    26,     1,    31,    -1,    38,    39,
-       1,    31,    -1,    38,     1,    31,    -1,    16,    -1,    19,
-      -1,    20,    -1,    22,    -1,    18,    -1,    23,    -1,    21,
-      -1,    31,    -1,    60,    -1,    69,    -1,    43,    -1,    45,
-      -1,    67,    -1,    26,     1,    31,    -1,     1,    31,    -1,
-      10,    26,    31,    -1,    42,    46,    -1,    11,    26,    31,
-      -1,    44,    46,    -1,    -1,    46,    47,    -1,    46,    48,
-      -1,    46,    73,    -1,    46,    71,    -1,    46,    41,    -1,
-      46,    31,    -1,    20,    74,    31,    -1,    19,    75,    78,
-      31,    -1,    21,    79,    78,    31,    -1,    22,    26,    78,
-      31,    -1,    23,    80,    80,    78,    31,    -1,    24,    49,
-      31,    -1,    -1,    49,    26,    50,    -1,    -1,    34,    75,
-      -1,     7,    31,    -1,    51,    55,    -1,    76,    -1,    52,
-      57,    53,    -1,    -1,    55,    56,    -1,    55,    73,    -1,
-      55,    71,    -1,    55,    31,    -1,    55,    41,    -1,    19,
-      75,    78,    31,    -1,    20,    74,    31,    -1,    18,    31,
-      -1,    21,    26,    78,    31,    -1,    -1,    57,    40,    -1,
-      14,    79,    77,    -1,    76,    -1,    58,    61,    59,    -1,
-      -1,    61,    40,    -1,    61,    65,    -1,    61,    54,    -1,
-       4,    75,    31,    -1,    62,    72,    -1,    76,    -1,    63,
-      66,    64,    -1,    -1,    66,    40,    -1,    66,    65,    -1,
-      66,    54,    -1,     6,    75,    31,    -1,     9,    75,    31,
-      -1,    68,    72,    -1,    12,    31,    -1,    70,    13,    -1,
-      -1,    72,    73,    -1,    72,    31,    -1,    72,    41,    -1,
-      16,    25,    79,    31,    -1,    16,    79,    31,    -1,    17,
-      79,    31,    -1,    -1,    75,    78,    -1,    26,    -1,    27,
-      -1,     5,    31,    -1,     8,    31,    -1,    15,    31,    -1,
-      31,    -1,    77,    31,    -1,    -1,    14,    79,    -1,    80,
-      -1,    80,    34,    80,    -1,    80,    28,    80,    -1,    30,
-      79,    29,    -1,    35,    79,    -1,    79,    32,    79,    -1,
-      79,    33,    79,    -1,    26,    -1,    27,    -1
+      36,     0,    -1,    37,    -1,    -1,    37,    39,    -1,    37,
+      53,    -1,    37,    64,    -1,    37,     3,    74,    76,    -1,
+      37,    75,    -1,    37,    25,     1,    30,    -1,    37,    38,
+       1,    30,    -1,    37,     1,    30,    -1,    16,    -1,    18,
+      -1,    19,    -1,    21,    -1,    17,    -1,    22,    -1,    20,
+      -1,    30,    -1,    59,    -1,    68,    -1,    42,    -1,    44,
+      -1,    66,    -1,    25,     1,    30,    -1,     1,    30,    -1,
+      10,    25,    30,    -1,    41,    45,    -1,    11,    25,    30,
+      -1,    43,    45,    -1,    -1,    45,    46,    -1,    45,    47,
+      -1,    45,    72,    -1,    45,    70,    -1,    45,    40,    -1,
+      45,    30,    -1,    19,    73,    30,    -1,    18,    74,    77,
+      30,    -1,    20,    78,    77,    30,    -1,    21,    25,    77,
+      30,    -1,    22,    79,    79,    77,    30,    -1,    23,    48,
+      30,    -1,    -1,    48,    25,    49,    -1,    -1,    33,    74,
+      -1,     7,    30,    -1,    50,    54,    -1,    75,    -1,    51,
+      56,    52,    -1,    -1,    54,    55,    -1,    54,    72,    -1,
+      54,    70,    -1,    54,    30,    -1,    54,    40,    -1,    18,
+      74,    77,    30,    -1,    19,    73,    30,    -1,    17,    30,
+      -1,    20,    25,    77,    30,    -1,    -1,    56,    39,    -1,
+      14,    78,    76,    -1,    75,    -1,    57,    60,    58,    -1,
+      -1,    60,    39,    -1,    60,    64,    -1,    60,    53,    -1,
+       4,    74,    30,    -1,    61,    71,    -1,    75,    -1,    62,
+      65,    63,    -1,    -1,    65,    39,    -1,    65,    64,    -1,
+      65,    53,    -1,     6,    74,    30,    -1,     9,    74,    30,
+      -1,    67,    71,    -1,    12,    30,    -1,    69,    13,    -1,
+      -1,    71,    72,    -1,    71,    30,    -1,    71,    40,    -1,
+      16,    24,    78,    30,    -1,    -1,    74,    77,    -1,    25,
+      -1,    26,    -1,     5,    30,    -1,     8,    30,    -1,    15,
+      30,    -1,    30,    -1,    76,    30,    -1,    -1,    14,    78,
+      -1,    79,    -1,    79,    33,    79,    -1,    79,    27,    79,
+      -1,    29,    78,    28,    -1,    34,    78,    -1,    78,    31,
+      78,    -1,    78,    32,    78,    -1,    25,    -1,    26,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const unsigned short int yyrline[] =
+static const yytype_uint16 yyrline[] =
 {
-       0,   105,   105,   107,   109,   110,   111,   112,   113,   114,
-     115,   119,   123,   123,   123,   123,   123,   123,   123,   127,
-     128,   129,   130,   131,   132,   136,   137,   143,   151,   157,
-     165,   175,   177,   178,   179,   180,   181,   182,   185,   193,
-     199,   209,   215,   221,   224,   226,   237,   238,   243,   252,
-     257,   265,   268,   270,   271,   272,   273,   274,   277,   283,
-     294,   300,   310,   312,   317,   325,   333,   336,   338,   339,
-     340,   345,   352,   357,   365,   368,   370,   371,   372,   375,
-     383,   390,   397,   403,   410,   412,   413,   414,   417,   422,
-     427,   435,   437,   442,   443,   446,   447,   448,   452,   453,
-     456,   457,   460,   461,   462,   463,   464,   465,   466,   469,
-     470
+       0,   104,   104,   106,   108,   109,   110,   111,   112,   113,
+     114,   118,   122,   122,   122,   122,   122,   122,   122,   126,
+     127,   128,   129,   130,   131,   135,   136,   142,   150,   156,
+     164,   174,   176,   177,   178,   179,   180,   181,   184,   192,
+     198,   208,   214,   220,   223,   225,   236,   237,   242,   251,
+     256,   264,   267,   269,   270,   271,   272,   273,   276,   282,
+     293,   299,   309,   311,   316,   324,   332,   335,   337,   338,
+     339,   344,   351,   356,   364,   367,   369,   370,   371,   374,
+     382,   389,   396,   402,   409,   411,   412,   413,   416,   424,
+     426,   431,   432,   435,   436,   437,   441,   442,   445,   446,
+     449,   450,   451,   452,   453,   454,   455,   458,   459
 };
 #endif
 
 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
-   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
   "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
   "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
-  "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT",
-  "T_SELECT", "T_RANGE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE",
-  "T_UNEQUAL", "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND",
-  "T_EQUAL", "T_NOT", "$accept", "input", "stmt_list", "option_name",
-  "common_stmt", "option_error", "config_entry_start", "config_stmt",
+  "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE",
+  "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
+  "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
+  "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt",
+  "option_error", "config_entry_start", "config_stmt",
   "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
   "config_option", "symbol_option", "symbol_option_list",
   "symbol_option_arg", "choice", "choice_entry", "choice_end",
@@ -527,34 +597,33 @@ static const char *const yytname[] =
 # ifdef YYPRINT
 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
    token YYLEX-NUM.  */
-static const unsigned short int yytoknum[] =
+static const yytype_uint16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
-     285,   286,   287,   288,   289,   290
+     285,   286,   287,   288,   289
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
-static const unsigned char yyr1[] =
+static const yytype_uint8 yyr1[] =
 {
-       0,    36,    37,    38,    38,    38,    38,    38,    38,    38,
-      38,    38,    39,    39,    39,    39,    39,    39,    39,    40,
-      40,    40,    40,    40,    40,    41,    41,    42,    43,    44,
-      45,    46,    46,    46,    46,    46,    46,    46,    47,    47,
-      47,    47,    47,    48,    49,    49,    50,    50,    51,    52,
-      53,    54,    55,    55,    55,    55,    55,    55,    56,    56,
-      56,    56,    57,    57,    58,    59,    60,    61,    61,    61,
-      61,    62,    63,    64,    65,    66,    66,    66,    66,    67,
-      68,    69,    70,    71,    72,    72,    72,    72,    73,    73,
-      73,    74,    74,    75,    75,    76,    76,    76,    77,    77,
-      78,    78,    79,    79,    79,    79,    79,    79,    79,    80,
-      80
+       0,    35,    36,    37,    37,    37,    37,    37,    37,    37,
+      37,    37,    38,    38,    38,    38,    38,    38,    38,    39,
+      39,    39,    39,    39,    39,    40,    40,    41,    42,    43,
+      44,    45,    45,    45,    45,    45,    45,    45,    46,    46,
+      46,    46,    46,    47,    48,    48,    49,    49,    50,    51,
+      52,    53,    54,    54,    54,    54,    54,    54,    55,    55,
+      55,    55,    56,    56,    57,    58,    59,    60,    60,    60,
+      60,    61,    62,    63,    64,    65,    65,    65,    65,    66,
+      67,    68,    69,    70,    71,    71,    71,    71,    72,    73,
+      73,    74,    74,    75,    75,    75,    76,    76,    77,    77,
+      78,    78,    78,    78,    78,    78,    78,    79,    79
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
-static const unsigned char yyr2[] =
+static const yytype_uint8 yyr2[] =
 {
        0,     2,     1,     0,     2,     2,     2,     4,     2,     4,
        4,     3,     1,     1,     1,     1,     1,     1,     1,     1,
@@ -564,82 +633,79 @@ static const unsigned char yyr2[] =
        1,     3,     0,     2,     2,     2,     2,     2,     4,     3,
        2,     4,     0,     2,     3,     1,     3,     0,     2,     2,
        2,     3,     2,     1,     3,     0,     2,     2,     2,     3,
-       3,     2,     2,     2,     0,     2,     2,     2,     4,     3,
-       3,     0,     2,     1,     1,     2,     2,     2,     1,     2,
-       0,     2,     1,     3,     3,     3,     2,     3,     3,     1,
-       1
+       3,     2,     2,     2,     0,     2,     2,     2,     4,     0,
+       2,     1,     1,     2,     2,     2,     1,     2,     0,     2,
+       1,     3,     3,     3,     2,     3,     3,     1,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
    means the default is an error.  */
-static const unsigned char yydefact[] =
+static const yytype_uint8 yydefact[] =
 {
        3,     0,     0,     1,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,     0,     0,    12,    16,    13,    14,
       18,    15,    17,     0,    19,     0,     4,    31,    22,    31,
       23,    52,    62,     5,    67,    20,    84,    75,     6,    24,
-      84,    21,     8,    11,    93,    94,     0,     0,    95,     0,
-      48,    96,     0,     0,     0,   109,   110,     0,     0,     0,
-     102,    97,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    98,     7,    71,    79,    80,    27,    29,     0,
-     106,     0,     0,    64,     0,     0,     9,    10,     0,     0,
-       0,     0,     0,    91,     0,     0,     0,    44,     0,    37,
-      36,    32,    33,     0,    35,    34,     0,     0,    91,     0,
-      56,    57,    53,    55,    54,    63,    51,    50,    68,    70,
-      66,    69,    65,    86,    87,    85,    76,    78,    74,    77,
-      73,    99,   105,   107,   108,   104,   103,    26,    82,     0,
-       0,     0,   100,     0,   100,   100,   100,     0,     0,     0,
-      83,    60,   100,     0,   100,     0,    89,    90,     0,     0,
-      38,    92,     0,     0,   100,    46,    43,    25,     0,    59,
-       0,    88,   101,    39,    40,    41,     0,     0,    45,    58,
-      61,    42,    47
+      84,    21,     8,    11,    91,    92,     0,     0,    93,     0,
+      48,    94,     0,     0,     0,   107,   108,     0,     0,     0,
+     100,    95,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,    96,     7,    71,    79,    80,    27,    29,     0,
+     104,     0,     0,    64,     0,     0,     9,    10,     0,     0,
+       0,     0,    89,     0,     0,     0,    44,     0,    37,    36,
+      32,    33,     0,    35,    34,     0,     0,    89,     0,    56,
+      57,    53,    55,    54,    63,    51,    50,    68,    70,    66,
+      69,    65,    86,    87,    85,    76,    78,    74,    77,    73,
+      97,   103,   105,   106,   102,   101,    26,    82,     0,    98,
+       0,    98,    98,    98,     0,     0,     0,    83,    60,    98,
+       0,    98,     0,     0,     0,    38,    90,     0,     0,    98,
+      46,    43,    25,     0,    59,     0,    88,    99,    39,    40,
+      41,     0,     0,    45,    58,    61,    42,    47
 };
 
-/* YYDEFGOTO[NTERM-NUM]. */
-static const short int yydefgoto[] =
+/* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int16 yydefgoto[] =
 {
-      -1,     1,     2,    25,    26,   100,    27,    28,    29,    30,
-      64,   101,   102,   148,   178,    31,    32,   116,    33,    66,
-     112,    67,    34,   120,    35,    68,    36,    37,   128,    38,
-      70,    39,    40,    41,   103,   104,    69,   105,   143,   144,
-      42,    73,   159,    59,    60
+      -1,     1,     2,    25,    26,    99,    27,    28,    29,    30,
+      64,   100,   101,   145,   173,    31,    32,   115,    33,    66,
+     111,    67,    34,   119,    35,    68,    36,    37,   127,    38,
+      70,    39,    40,    41,   102,   103,    69,   104,   140,   141,
+      42,    73,   154,    59,    60
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -135
-static const short int yypact[] =
+#define YYPACT_NINF -78
+static const yytype_int16 yypact[] =
 {
-    -135,     2,   170,  -135,   -14,    56,    56,    -8,    56,    24,
-      67,    56,     7,    14,    62,    97,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,   156,  -135,   166,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,   138,   151,  -135,   152,
-    -135,  -135,   163,   167,   176,  -135,  -135,    62,    62,   185,
-     -19,  -135,   188,   190,    42,   103,   194,    85,    70,   222,
-      70,   132,  -135,   191,  -135,  -135,  -135,  -135,  -135,   127,
-    -135,    62,    62,   191,   104,   104,  -135,  -135,   193,   203,
-       9,    62,    56,    56,    62,   161,   104,  -135,   196,  -135,
-    -135,  -135,  -135,   233,  -135,  -135,   204,    56,    56,   221,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,
-    -135,  -135,  -135,   219,  -135,  -135,  -135,  -135,  -135,    62,
-     209,   212,   240,   224,   240,    -1,   240,   104,    41,   225,
-    -135,  -135,   240,   226,   240,   218,  -135,  -135,    62,   227,
-    -135,  -135,   228,   229,   240,   230,  -135,  -135,   231,  -135,
-     232,  -135,   112,  -135,  -135,  -135,   234,    56,  -135,  -135,
-    -135,  -135,  -135
+     -78,    33,   130,   -78,   -28,    73,    73,     7,    73,    36,
+      41,    73,    26,    52,    -4,    58,   -78,   -78,   -78,   -78,
+     -78,   -78,   -78,    90,   -78,    94,   -78,   -78,   -78,   -78,
+     -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,
+     -78,   -78,   -78,   -78,   -78,   -78,    74,    85,   -78,    96,
+     -78,   -78,   131,   134,   147,   -78,   -78,    -4,    -4,   193,
+     -10,   -78,   162,   164,    38,   102,    64,   148,     5,   192,
+       5,   165,   -78,   174,   -78,   -78,   -78,   -78,   -78,    65,
+     -78,    -4,    -4,   174,   103,   103,   -78,   -78,   175,   185,
+     197,    73,    73,    -4,   194,   103,   -78,   231,   -78,   -78,
+     -78,   -78,   220,   -78,   -78,   204,    73,    73,   210,   -78,
+     -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,
+     -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,
+     -78,   -78,   205,   -78,   -78,   -78,   -78,   -78,    -4,   222,
+     208,   222,   195,   222,   103,     2,   209,   -78,   -78,   222,
+     211,   222,   199,    -4,   212,   -78,   -78,   213,   214,   222,
+     207,   -78,   -78,   215,   -78,   216,   -78,   111,   -78,   -78,
+     -78,   217,    73,   -78,   -78,   -78,   -78,   -78
 };
 
 /* YYPGOTO[NTERM-NUM].  */
-static const short int yypgoto[] =
+static const yytype_int16 yypgoto[] =
 {
-    -135,  -135,  -135,  -135,    94,   -45,  -135,  -135,  -135,  -135,
-     237,  -135,  -135,  -135,  -135,  -135,  -135,  -135,   -54,  -135,
-    -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,  -135,     1,
-    -135,  -135,  -135,  -135,  -135,   195,   235,   -44,   159,    -5,
-      98,   210,  -134,   -53,   -77
+     -78,   -78,   -78,   -78,   121,   -35,   -78,   -78,   -78,   -78,
+     219,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -44,   -78,
+     -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,   -78,    -6,
+     -78,   -78,   -78,   -78,   -78,   183,   218,    21,   143,    -5,
+     146,   196,    69,   -53,   -77
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -647,93 +713,88 @@ static const short int yypgoto[] =
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
 #define YYTABLE_NINF -82
-static const short int yytable[] =
+static const yytype_int16 yytable[] =
 {
-      46,    47,     3,    49,    79,    80,    52,   135,   136,    84,
-     161,   162,   163,   158,   119,    85,   127,    43,   168,   147,
-     170,   111,   114,    48,   124,   125,   124,   125,   133,   134,
-     176,    81,    82,    53,   139,    55,    56,   140,   141,    57,
-      54,   145,   -28,    88,    58,   -28,   -28,   -28,   -28,   -28,
-     -28,   -28,   -28,   -28,    89,    50,   -28,   -28,    90,    91,
-     -28,    92,    93,    94,    95,    96,    97,   165,    98,   121,
-     164,   129,   166,    99,     6,     7,     8,     9,    10,    11,
-      12,    13,    44,    45,    14,    15,   155,   142,    55,    56,
-       7,     8,    57,    10,    11,    12,    13,    58,    51,    14,
-      15,    24,   152,   -30,    88,   172,   -30,   -30,   -30,   -30,
-     -30,   -30,   -30,   -30,   -30,    89,    24,   -30,   -30,    90,
-      91,   -30,    92,    93,    94,    95,    96,    97,    61,    98,
-      55,    56,   -81,    88,    99,   -81,   -81,   -81,   -81,   -81,
-     -81,   -81,   -81,   -81,    81,    82,   -81,   -81,    90,    91,
-     -81,   -81,   -81,   -81,   -81,   -81,   132,    62,    98,    81,
-      82,   115,   118,   123,   126,   117,   122,    63,   130,    72,
-      -2,     4,   182,     5,     6,     7,     8,     9,    10,    11,
-      12,    13,    74,    75,    14,    15,    16,   146,    17,    18,
-      19,    20,    21,    22,    76,    88,    23,   149,    77,   -49,
-     -49,    24,   -49,   -49,   -49,   -49,    89,    78,   -49,   -49,
-      90,    91,   106,   107,   108,   109,    72,    81,    82,    86,
-      98,    87,   131,    88,   137,   110,   -72,   -72,   -72,   -72,
-     -72,   -72,   -72,   -72,   138,   151,   -72,   -72,    90,    91,
-     156,    81,    82,   157,    81,    82,   150,   154,    98,   171,
-      81,    82,    82,   123,   158,   160,   167,   169,   173,   174,
-     175,   113,   179,   180,   177,   181,    65,   153,     0,    83,
-       0,     0,     0,     0,     0,    71
+      46,    47,    43,    49,    79,    80,    52,   134,   135,     6,
+       7,     8,     9,    10,    11,    12,    13,    84,   144,    14,
+      15,    55,    56,    85,   118,    57,   126,   160,   132,   133,
+      58,   110,   161,     3,   123,    24,   123,    48,   -28,    88,
+     142,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,   -28,
+      89,    53,   -28,   -28,    90,   -28,    91,    92,    93,    94,
+      95,    96,   120,    97,   128,    88,    50,   159,    98,   -49,
+     -49,    51,   -49,   -49,   -49,   -49,    89,    54,   -49,   -49,
+      90,   105,   106,   107,   108,   152,   139,   113,    61,    97,
+     124,    62,   124,   131,   109,    63,    81,    82,    44,    45,
+     167,   149,   -30,    88,    72,   -30,   -30,   -30,   -30,   -30,
+     -30,   -30,   -30,   -30,    89,    74,   -30,   -30,    90,   -30,
+      91,    92,    93,    94,    95,    96,    75,    97,    55,    56,
+      -2,     4,    98,     5,     6,     7,     8,     9,    10,    11,
+      12,    13,    81,    82,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,     7,     8,    23,    10,    11,    12,    13,
+      24,    76,    14,    15,    77,   -81,    88,   177,   -81,   -81,
+     -81,   -81,   -81,   -81,   -81,   -81,   -81,    78,    24,   -81,
+     -81,    90,   -81,   -81,   -81,   -81,   -81,   -81,   114,   117,
+      97,   125,    86,    88,    87,   122,   -72,   -72,   -72,   -72,
+     -72,   -72,   -72,   -72,   130,   136,   -72,   -72,    90,   153,
+     156,   157,   158,   116,   121,   137,   129,    97,   163,   143,
+     165,   138,   122,    72,    81,    82,    81,    82,   171,   166,
+      81,    82,   146,   147,   148,   151,   153,    82,   155,   162,
+     172,   164,   168,   169,   170,   174,   175,   176,    65,   112,
+     150,     0,     0,     0,     0,    83,     0,     0,    71
 };
 
-static const short int yycheck[] =
+static const yytype_int16 yycheck[] =
 {
-       5,     6,     0,     8,    57,    58,    11,    84,    85,    28,
-     144,   145,   146,    14,    68,    34,    70,    31,   152,    96,
-     154,    66,    66,    31,    69,    69,    71,    71,    81,    82,
-     164,    32,    33,    26,    25,    26,    27,    90,    91,    30,
-      26,    94,     0,     1,    35,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,    12,    31,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    26,    26,    68,
-     147,    70,    31,    31,     4,     5,     6,     7,     8,     9,
-      10,    11,    26,    27,    14,    15,   139,    92,    26,    27,
-       5,     6,    30,     8,     9,    10,    11,    35,    31,    14,
-      15,    31,   107,     0,     1,   158,     3,     4,     5,     6,
-       7,     8,     9,    10,    11,    12,    31,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,    23,    24,    31,    26,
-      26,    27,     0,     1,    31,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,    32,    33,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    29,     1,    26,    32,
-      33,    67,    68,    31,    70,    67,    68,     1,    70,    31,
-       0,     1,   177,     3,     4,     5,     6,     7,     8,     9,
-      10,    11,    31,    31,    14,    15,    16,    26,    18,    19,
-      20,    21,    22,    23,    31,     1,    26,     1,    31,     5,
-       6,    31,     8,     9,    10,    11,    12,    31,    14,    15,
-      16,    17,    18,    19,    20,    21,    31,    32,    33,    31,
-      26,    31,    31,     1,    31,    31,     4,     5,     6,     7,
-       8,     9,    10,    11,    31,    31,    14,    15,    16,    17,
-      31,    32,    33,    31,    32,    33,    13,    26,    26,    31,
-      32,    33,    33,    31,    14,    31,    31,    31,    31,    31,
-      31,    66,    31,    31,    34,    31,    29,   108,    -1,    59,
-      -1,    -1,    -1,    -1,    -1,    40
+       5,     6,    30,     8,    57,    58,    11,    84,    85,     4,
+       5,     6,     7,     8,     9,    10,    11,    27,    95,    14,
+      15,    25,    26,    33,    68,    29,    70,    25,    81,    82,
+      34,    66,    30,     0,    69,    30,    71,    30,     0,     1,
+      93,     3,     4,     5,     6,     7,     8,     9,    10,    11,
+      12,    25,    14,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    68,    25,    70,     1,    30,   144,    30,     5,
+       6,    30,     8,     9,    10,    11,    12,    25,    14,    15,
+      16,    17,    18,    19,    20,   138,    91,    66,    30,    25,
+      69,     1,    71,    28,    30,     1,    31,    32,    25,    26,
+     153,   106,     0,     1,    30,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,    12,    30,    14,    15,    16,    17,
+      18,    19,    20,    21,    22,    23,    30,    25,    25,    26,
+       0,     1,    30,     3,     4,     5,     6,     7,     8,     9,
+      10,    11,    31,    32,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,     5,     6,    25,     8,     9,    10,    11,
+      30,    30,    14,    15,    30,     0,     1,   172,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,    30,    30,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    67,    68,
+      25,    70,    30,     1,    30,    30,     4,     5,     6,     7,
+       8,     9,    10,    11,    30,    30,    14,    15,    16,    14,
+     141,   142,   143,    67,    68,    30,    70,    25,   149,    25,
+     151,    24,    30,    30,    31,    32,    31,    32,   159,    30,
+      31,    32,     1,    13,    30,    25,    14,    32,    30,    30,
+      33,    30,    30,    30,    30,    30,    30,    30,    29,    66,
+     107,    -1,    -1,    -1,    -1,    59,    -1,    -1,    40
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
-static const unsigned char yystos[] =
+static const yytype_uint8 yystos[] =
 {
-       0,    37,    38,     0,     1,     3,     4,     5,     6,     7,
-       8,     9,    10,    11,    14,    15,    16,    18,    19,    20,
-      21,    22,    23,    26,    31,    39,    40,    42,    43,    44,
-      45,    51,    52,    54,    58,    60,    62,    63,    65,    67,
-      68,    69,    76,    31,    26,    27,    75,    75,    31,    75,
-      31,    31,    75,    26,    26,    26,    27,    30,    35,    79,
-      80,    31,     1,     1,    46,    46,    55,    57,    61,    72,
-      66,    72,    31,    77,    31,    31,    31,    31,    31,    79,
-      79,    32,    33,    77,    28,    34,    31,    31,     1,    12,
-      16,    17,    19,    20,    21,    22,    23,    24,    26,    31,
-      41,    47,    48,    70,    71,    73,    18,    19,    20,    21,
-      31,    41,    56,    71,    73,    40,    53,    76,    40,    54,
-      59,    65,    76,    31,    41,    73,    40,    54,    64,    65,
-      76,    31,    29,    79,    79,    80,    80,    31,    31,    25,
-      79,    79,    75,    74,    75,    79,    26,    80,    49,     1,
-      13,    31,    75,    74,    26,    79,    31,    31,    14,    78,
-      31,    78,    78,    78,    80,    26,    31,    31,    78,    31,
-      78,    31,    79,    31,    31,    31,    78,    34,    50,    31,
-      31,    31,    75
+       0,    36,    37,     0,     1,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,    25,    30,    38,    39,    41,    42,    43,
+      44,    50,    51,    53,    57,    59,    61,    62,    64,    66,
+      67,    68,    75,    30,    25,    26,    74,    74,    30,    74,
+      30,    30,    74,    25,    25,    25,    26,    29,    34,    78,
+      79,    30,     1,     1,    45,    45,    54,    56,    60,    71,
+      65,    71,    30,    76,    30,    30,    30,    30,    30,    78,
+      78,    31,    32,    76,    27,    33,    30,    30,     1,    12,
+      16,    18,    19,    20,    21,    22,    23,    25,    30,    40,
+      46,    47,    69,    70,    72,    17,    18,    19,    20,    30,
+      40,    55,    70,    72,    39,    52,    75,    39,    53,    58,
+      64,    75,    30,    40,    72,    39,    53,    63,    64,    75,
+      30,    28,    78,    78,    79,    79,    30,    30,    24,    74,
+      73,    74,    78,    25,    79,    48,     1,    13,    30,    74,
+      73,    25,    78,    14,    77,    30,    77,    77,    77,    79,
+      25,    30,    30,    77,    30,    77,    30,    78,    30,    30,
+      30,    77,    33,    49,    30,    30,    30,    74
 };
 
 #define yyerrok                (yyerrstatus = 0)
@@ -761,7 +822,7 @@ do                                                          \
       yychar = (Token);                                                \
       yylval = (Value);                                                \
       yytoken = YYTRANSLATE (yychar);                          \
-      YYPOPSTACK;                                              \
+      YYPOPSTACK (1);                                          \
       goto yybackup;                                           \
     }                                                          \
   else                                                         \
@@ -769,7 +830,7 @@ do                                                          \
       yyerror (YY_("syntax error: cannot back up")); \
       YYERROR;                                                 \
     }                                                          \
-while (0)
+while (YYID (0))
 
 
 #define YYTERROR       1
@@ -784,7 +845,7 @@ while (0)
 #ifndef YYLLOC_DEFAULT
 # define YYLLOC_DEFAULT(Current, Rhs, N)                               \
     do                                                                 \
-      if (N)                                                           \
+      if (YYID (N))                                                    \
        {                                                               \
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
@@ -798,7 +859,7 @@ while (0)
          (Current).first_column = (Current).last_column =              \
            YYRHSLOC (Rhs, 0).last_column;                              \
        }                                                               \
-    while (0)
+    while (YYID (0))
 #endif
 
 
@@ -810,8 +871,8 @@ while (0)
 # if YYLTYPE_IS_TRIVIAL
 #  define YY_LOCATION_PRINT(File, Loc)                 \
      fprintf (File, "%d.%d-%d.%d",                     \
-              (Loc).first_line, (Loc).first_column,    \
-              (Loc).last_line,  (Loc).last_column)
+             (Loc).first_line, (Loc).first_column,     \
+             (Loc).last_line,  (Loc).last_column)
 # else
 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 # endif
@@ -838,36 +899,96 @@ while (0)
 do {                                           \
   if (yydebug)                                 \
     YYFPRINTF Args;                            \
-} while (0)
+} while (YYID (0))
 
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)         \
-do {                                                           \
-  if (yydebug)                                                 \
-    {                                                          \
-      YYFPRINTF (stderr, "%s ", Title);                                \
-      yysymprint (stderr,                                      \
-                  Type, Value);        \
-      YYFPRINTF (stderr, "\n");                                        \
-    }                                                          \
-} while (0)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                   \
+do {                                                                     \
+  if (yydebug)                                                           \
+    {                                                                    \
+      YYFPRINTF (stderr, "%s ", Title);                                          \
+      yy_symbol_print (stderr,                                           \
+                 Type, Value); \
+      YYFPRINTF (stderr, "\n");                                                  \
+    }                                                                    \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+#endif
+{
+  if (!yyvaluep)
+    return;
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+  YYUSE (yyoutput);
+# endif
+  switch (yytype)
+    {
+      default:
+       break;
+    }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+#endif
+{
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+  YYFPRINTF (yyoutput, ")");
+}
 
 /*------------------------------------------------------------------.
 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
 | TOP (included).                                                   |
 `------------------------------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
-yy_stack_print (short int *bottom, short int *top)
+yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
 #else
 static void
 yy_stack_print (bottom, top)
-    short int *bottom;
-    short int *top;
+    yytype_int16 *bottom;
+    yytype_int16 *top;
 #endif
 {
   YYFPRINTF (stderr, "Stack now");
-  for (/* Nothing. */; bottom <= top; ++bottom)
+  for (; bottom <= top; ++bottom)
     YYFPRINTF (stderr, " %d", *bottom);
   YYFPRINTF (stderr, "\n");
 }
@@ -876,37 +997,45 @@ yy_stack_print (bottom, top)
 do {                                                           \
   if (yydebug)                                                 \
     yy_stack_print ((Bottom), (Top));                          \
-} while (0)
+} while (YYID (0))
 
 
 /*------------------------------------------------.
 | Report that the YYRULE is going to be reduced.  |
 `------------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
-yy_reduce_print (int yyrule)
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
 #else
 static void
-yy_reduce_print (yyrule)
+yy_reduce_print (yyvsp, yyrule)
+    YYSTYPE *yyvsp;
     int yyrule;
 #endif
 {
+  int yynrhs = yyr2[yyrule];
   int yyi;
   unsigned long int yylno = yyrline[yyrule];
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
-             yyrule - 1, yylno);
-  /* Print the symbols being reduced, and their result.  */
-  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
-    YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
-  YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+            yyrule - 1, yylno);
+  /* The symbols being reduced.  */
+  for (yyi = 0; yyi < yynrhs; yyi++)
+    {
+      fprintf (stderr, "   $%d = ", yyi + 1);
+      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+                      &(yyvsp[(yyi + 1) - (yynrhs)])
+                                      );
+      fprintf (stderr, "\n");
+    }
 }
 
 # define YY_REDUCE_PRINT(Rule)         \
 do {                                   \
   if (yydebug)                         \
-    yy_reduce_print (Rule);            \
-} while (0)
+    yy_reduce_print (yyvsp, Rule); \
+} while (YYID (0))
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
    multiple parsers can coexist.  */
@@ -940,42 +1069,44 @@ int yydebug;
 #if YYERROR_VERBOSE
 
 # ifndef yystrlen
-#  if defined (__GLIBC__) && defined (_STRING_H)
+#  if defined __GLIBC__ && defined _STRING_H
 #   define yystrlen strlen
 #  else
 /* Return the length of YYSTR.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static YYSIZE_T
-#   if defined (__STDC__) || defined (__cplusplus)
 yystrlen (const char *yystr)
-#   else
+#else
+static YYSIZE_T
 yystrlen (yystr)
-     const char *yystr;
-#   endif
+    const char *yystr;
+#endif
 {
-  const char *yys = yystr;
-
-  while (*yys++ != '\0')
+  YYSIZE_T yylen;
+  for (yylen = 0; yystr[yylen]; yylen++)
     continue;
-
-  return yys - yystr - 1;
+  return yylen;
 }
 #  endif
 # endif
 
 # ifndef yystpcpy
-#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
 #   define yystpcpy stpcpy
 #  else
 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    YYDEST.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static char *
-#   if defined (__STDC__) || defined (__cplusplus)
 yystpcpy (char *yydest, const char *yysrc)
-#   else
+#else
+static char *
 yystpcpy (yydest, yysrc)
-     char *yydest;
-     const char *yysrc;
-#   endif
+    char *yydest;
+    const char *yysrc;
+#endif
 {
   char *yyd = yydest;
   const char *yys = yysrc;
@@ -1001,7 +1132,7 @@ yytnamerr (char *yyres, const char *yystr)
 {
   if (*yystr == '"')
     {
-      size_t yyn = 0;
+      YYSIZE_T yyn = 0;
       char const *yyp = yystr;
 
       for (;;)
@@ -1036,53 +1167,123 @@ yytnamerr (char *yyres, const char *yystr)
 }
 # endif
 
-#endif /* YYERROR_VERBOSE */
-
-\f
-
-#if YYDEBUG
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
-
-#if defined (__STDC__) || defined (__cplusplus)
-static void
-yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yysymprint (yyoutput, yytype, yyvaluep)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE *yyvaluep;
-#endif
+/* Copy into YYRESULT an error message about the unexpected token
+   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
+   including the terminating null byte.  If YYRESULT is null, do not
+   copy anything; just return the number of bytes that would be
+   copied.  As a special case, return 0 if an ordinary "syntax error"
+   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
+   size calculation.  */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
 {
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvaluep;
+  int yyn = yypact[yystate];
 
-  if (yytype < YYNTOKENS)
-    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+    return 0;
   else
-    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+    {
+      int yytype = YYTRANSLATE (yychar);
+      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+      YYSIZE_T yysize = yysize0;
+      YYSIZE_T yysize1;
+      int yysize_overflow = 0;
+      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+      int yyx;
+
+# if 0
+      /* This is so xgettext sees the translatable formats that are
+        constructed on the fly.  */
+      YY_("syntax error, unexpected %s");
+      YY_("syntax error, unexpected %s, expecting %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+      char *yyfmt;
+      char const *yyf;
+      static char const yyunexpected[] = "syntax error, unexpected %s";
+      static char const yyexpecting[] = ", expecting %s";
+      static char const yyor[] = " or %s";
+      char yyformat[sizeof yyunexpected
+                   + sizeof yyexpecting - 1
+                   + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+                      * (sizeof yyor - 1))];
+      char const *yyprefix = yyexpecting;
+
+      /* Start YYX at -YYN if negative to avoid negative indexes in
+        YYCHECK.  */
+      int yyxbegin = yyn < 0 ? -yyn : 0;
+
+      /* Stay within bounds of both yycheck and yytname.  */
+      int yychecklim = YYLAST - yyn + 1;
+      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+      int yycount = 1;
+
+      yyarg[0] = yytname[yytype];
+      yyfmt = yystpcpy (yyformat, yyunexpected);
+
+      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+         {
+           if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+             {
+               yycount = 1;
+               yysize = yysize0;
+               yyformat[sizeof yyunexpected - 1] = '\0';
+               break;
+             }
+           yyarg[yycount++] = yytname[yyx];
+           yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+           yysize_overflow |= (yysize1 < yysize);
+           yysize = yysize1;
+           yyfmt = yystpcpy (yyfmt, yyprefix);
+           yyprefix = yyor;
+         }
 
+      yyf = YY_(yyformat);
+      yysize1 = yysize + yystrlen (yyf);
+      yysize_overflow |= (yysize1 < yysize);
+      yysize = yysize1;
 
-# ifdef YYPRINT
-  if (yytype < YYNTOKENS)
-    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
-  switch (yytype)
-    {
-      default:
-        break;
+      if (yysize_overflow)
+       return YYSIZE_MAXIMUM;
+
+      if (yyresult)
+       {
+         /* Avoid sprintf, as that infringes on the user's name space.
+            Don't have undefined behavior even if the translation
+            produced a string with the wrong number of "%s"s.  */
+         char *yyp = yyresult;
+         int yyi = 0;
+         while ((*yyp = *yyf) != '\0')
+           {
+             if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+               {
+                 yyp += yytnamerr (yyp, yyarg[yyi++]);
+                 yyf += 2;
+               }
+             else
+               {
+                 yyp++;
+                 yyf++;
+               }
+           }
+       }
+      return yysize;
     }
-  YYFPRINTF (yyoutput, ")");
 }
+#endif /* YYERROR_VERBOSE */
+\f
 
-#endif /* ! YYDEBUG */
 /*-----------------------------------------------.
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
 
-#if defined (__STDC__) || defined (__cplusplus)
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 static void
 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
 #else
@@ -1093,8 +1294,7 @@ yydestruct (yymsg, yytype, yyvaluep)
     YYSTYPE *yyvaluep;
 #endif
 {
-  /* Pacify ``unused variable'' warnings.  */
-  (void) yyvaluep;
+  YYUSE (yyvaluep);
 
   if (!yymsg)
     yymsg = "Deleting";
@@ -1102,39 +1302,39 @@ yydestruct (yymsg, yytype, yyvaluep)
 
   switch (yytype)
     {
-      case 52: /* "choice_entry" */
+      case 51: /* "choice_entry" */
 
-        {
+       {
        fprintf(stderr, "%s:%d: missing end statement for this entry\n",
                (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
        if (current_menu == (yyvaluep->menu))
                menu_end_menu();
 };
 
-        break;
-      case 58: /* "if_entry" */
+       break;
+      case 57: /* "if_entry" */
 
-        {
+       {
        fprintf(stderr, "%s:%d: missing end statement for this entry\n",
                (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
        if (current_menu == (yyvaluep->menu))
                menu_end_menu();
 };
 
-        break;
-      case 63: /* "menu_entry" */
+       break;
+      case 62: /* "menu_entry" */
 
-        {
+       {
        fprintf(stderr, "%s:%d: missing end statement for this entry\n",
                (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno);
        if (current_menu == (yyvaluep->menu))
                menu_end_menu();
 };
 
-        break;
+       break;
 
       default:
-        break;
+       break;
     }
 }
 \f
@@ -1142,13 +1342,13 @@ yydestruct (yymsg, yytype, yyvaluep)
 /* Prevent warnings from -Wmissing-prototypes.  */
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
+#if defined __STDC__ || defined __cplusplus
 int yyparse (void *YYPARSE_PARAM);
-# else
+#else
 int yyparse ();
-# endif
+#endif
 #else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
+#if defined __STDC__ || defined __cplusplus
 int yyparse (void);
 #else
 int yyparse ();
@@ -1173,20 +1373,24 @@ int yynerrs;
 `----------*/
 
 #ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-int yyparse (void *YYPARSE_PARAM)
-# else
-int yyparse (YYPARSE_PARAM)
-  void *YYPARSE_PARAM;
-# endif
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+    void *YYPARSE_PARAM;
+#endif
 #else /* ! YYPARSE_PARAM */
-#if defined (__STDC__) || defined (__cplusplus)
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
 int
 yyparse (void)
 #else
 int
 yyparse ()
-    ;
+
 #endif
 #endif
 {
@@ -1198,6 +1402,12 @@ yyparse ()
   int yyerrstatus;
   /* Look-ahead token as an internal (translated) token number.  */
   int yytoken = 0;
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
 
   /* Three stacks and their tools:
      `yyss': related to states,
@@ -1208,9 +1418,9 @@ yyparse ()
      to reallocate them elsewhere.  */
 
   /* The state stack.  */
-  short int yyssa[YYINITDEPTH];
-  short int *yyss = yyssa;
-  short int *yyssp;
+  yytype_int16 yyssa[YYINITDEPTH];
+  yytype_int16 *yyss = yyssa;
+  yytype_int16 *yyssp;
 
   /* The semantic value stack.  */
   YYSTYPE yyvsa[YYINITDEPTH];
@@ -1219,7 +1429,7 @@ yyparse ()
 
 
 
-#define YYPOPSTACK   (yyvsp--, yyssp--)
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
 
   YYSIZE_T yystacksize = YYINITDEPTH;
 
@@ -1228,9 +1438,9 @@ yyparse ()
   YYSTYPE yyval;
 
 
-  /* When reducing, the number of symbols on the RHS of the reduced
-     rule.  */
-  int yylen;
+  /* The number of symbols on the RHS of the reduced rule.
+     Keep to zero when no symbol should be popped.  */
+  int yylen = 0;
 
   YYDPRINTF ((stderr, "Starting parse\n"));
 
@@ -1254,8 +1464,7 @@ yyparse ()
 `------------------------------------------------------------*/
  yynewstate:
   /* In all cases, when you get here, the value and location stacks
-     have just been pushed. so pushing a state here evens the stacks.
-     */
+     have just been pushed.  So pushing a state here evens the stacks.  */
   yyssp++;
 
  yysetstate:
@@ -1268,11 +1477,11 @@ yyparse ()
 
 #ifdef yyoverflow
       {
-       /* Give user a chance to reallocate the stack. Use copies of
+       /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        YYSTYPE *yyvs1 = yyvs;
-       short int *yyss1 = yyss;
+       yytype_int16 *yyss1 = yyss;
 
 
        /* Each stack pointer address is followed by the size of the
@@ -1300,7 +1509,7 @@ yyparse ()
        yystacksize = YYMAXDEPTH;
 
       {
-       short int *yyss1 = yyss;
+       yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
        if (! yyptr)
@@ -1335,12 +1544,10 @@ yyparse ()
 `-----------*/
 yybackup:
 
-/* Do appropriate processing given the current state.  */
-/* Read a look-ahead token if we need one and don't already have one.  */
-/* yyresume: */
+  /* Do appropriate processing given the current state.  Read a
+     look-ahead token if we need one and don't already have one.  */
 
   /* First try to decide what to do without reference to look-ahead token.  */
-
   yyn = yypact[yystate];
   if (yyn == YYPACT_NINF)
     goto yydefault;
@@ -1382,22 +1589,21 @@ yybackup:
   if (yyn == YYFINAL)
     YYACCEPT;
 
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
+
   /* Shift the look-ahead token.  */
   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
-  /* Discard the token being shifted unless it is eof.  */
+  /* Discard the shifted token unless it is eof.  */
   if (yychar != YYEOF)
     yychar = YYEMPTY;
 
+  yystate = yyn;
   *++yyvsp = yylval;
 
-
-  /* Count tokens shifted since error; after three, turn off error
-     status.  */
-  if (yyerrstatus)
-    yyerrstatus--;
-
-  yystate = yyn;
   goto yynewstate;
 
 
@@ -1439,13 +1645,13 @@ yyreduce:
 
   case 9:
 
-    { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); ;}
+    { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;}
     break;
 
   case 10:
 
     {
-       zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name);
+       zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name);
 ;}
     break;
 
@@ -1456,7 +1662,7 @@ yyreduce:
 
   case 25:
 
-    { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); ;}
+    { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;}
     break;
 
   case 26:
@@ -1467,10 +1673,10 @@ yyreduce:
   case 27:
 
     {
-       struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
+       struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
        sym->flags |= SYMBOL_OPTIONAL;
        menu_add_entry(sym);
-       printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
+       printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
 ;}
     break;
 
@@ -1485,10 +1691,10 @@ yyreduce:
   case 29:
 
     {
-       struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
+       struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
        sym->flags |= SYMBOL_OPTIONAL;
        menu_add_entry(sym);
-       printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
+       printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
 ;}
     break;
 
@@ -1507,17 +1713,17 @@ yyreduce:
   case 38:
 
     {
-       menu_set_type((yyvsp[-2].id)->stype);
+       menu_set_type((yyvsp[(1) - (3)].id)->stype);
        printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
                zconf_curname(), zconf_lineno(),
-               (yyvsp[-2].id)->stype);
+               (yyvsp[(1) - (3)].id)->stype);
 ;}
     break;
 
   case 39:
 
     {
-       menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
+       menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
        printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1525,19 +1731,19 @@ yyreduce:
   case 40:
 
     {
-       menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr));
-       if ((yyvsp[-3].id)->stype != S_UNKNOWN)
-               menu_set_type((yyvsp[-3].id)->stype);
+       menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr));
+       if ((yyvsp[(1) - (4)].id)->stype != S_UNKNOWN)
+               menu_set_type((yyvsp[(1) - (4)].id)->stype);
        printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
                zconf_curname(), zconf_lineno(),
-               (yyvsp[-3].id)->stype);
+               (yyvsp[(1) - (4)].id)->stype);
 ;}
     break;
 
   case 41:
 
     {
-       menu_add_symbol(P_SELECT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
+       menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
        printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1545,7 +1751,7 @@ yyreduce:
   case 42:
 
     {
-       menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr));
+       menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
        printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1553,12 +1759,12 @@ yyreduce:
   case 45:
 
     {
-       struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string)));
+       struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
        if (id && id->flags & TF_OPTION)
-               menu_add_option(id->token, (yyvsp[0].string));
+               menu_add_option(id->token, (yyvsp[(3) - (3)].string));
        else
-               zconfprint("warning: ignoring unknown option %s", (yyvsp[-1].string));
-       free((yyvsp[-1].string));
+               zconfprint("warning: ignoring unknown option %s", (yyvsp[(2) - (3)].string));
+       free((yyvsp[(2) - (3)].string));
 ;}
     break;
 
@@ -1569,7 +1775,7 @@ yyreduce:
 
   case 47:
 
-    { (yyval.string) = (yyvsp[0].string); ;}
+    { (yyval.string) = (yyvsp[(2) - (2)].string); ;}
     break;
 
   case 48:
@@ -1593,7 +1799,7 @@ yyreduce:
   case 50:
 
     {
-       if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) {
+       if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) {
                menu_end_menu();
                printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
        }
@@ -1603,7 +1809,7 @@ yyreduce:
   case 58:
 
     {
-       menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
+       menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
        printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1611,11 +1817,11 @@ yyreduce:
   case 59:
 
     {
-       if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) {
-               menu_set_type((yyvsp[-2].id)->stype);
+       if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) {
+               menu_set_type((yyvsp[(1) - (3)].id)->stype);
                printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
                        zconf_curname(), zconf_lineno(),
-                       (yyvsp[-2].id)->stype);
+                       (yyvsp[(1) - (3)].id)->stype);
        } else
                YYERROR;
 ;}
@@ -1632,8 +1838,8 @@ yyreduce:
   case 61:
 
     {
-       if ((yyvsp[-3].id)->stype == S_UNKNOWN) {
-               menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
+       if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) {
+               menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
                printd(DEBUG_PARSE, "%s:%d:default\n",
                        zconf_curname(), zconf_lineno());
        } else
@@ -1646,7 +1852,7 @@ yyreduce:
     {
        printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
        menu_add_entry(NULL);
-       menu_add_dep((yyvsp[-1].expr));
+       menu_add_dep((yyvsp[(2) - (3)].expr));
        (yyval.menu) = menu_add_menu();
 ;}
     break;
@@ -1654,7 +1860,7 @@ yyreduce:
   case 65:
 
     {
-       if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) {
+       if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) {
                menu_end_menu();
                printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
        }
@@ -1665,7 +1871,7 @@ yyreduce:
 
     {
        menu_add_entry(NULL);
-       menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
+       menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
        printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1680,7 +1886,7 @@ yyreduce:
   case 73:
 
     {
-       if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) {
+       if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) {
                menu_end_menu();
                printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
        }
@@ -1690,8 +1896,8 @@ yyreduce:
   case 79:
 
     {
-       printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
-       zconf_nextfile((yyvsp[-1].string));
+       printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
+       zconf_nextfile((yyvsp[(2) - (3)].string));
 ;}
     break;
 
@@ -1699,7 +1905,7 @@ yyreduce:
 
     {
        menu_add_entry(NULL);
-       menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL);
+       menu_add_prompt(P_COMMENT, (yyvsp[(2) - (3)].string), NULL);
        printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
 ;}
     break;
@@ -1722,122 +1928,104 @@ yyreduce:
   case 83:
 
     {
-       current_entry->help = (yyvsp[0].string);
+       current_entry->help = (yyvsp[(2) - (2)].string);
 ;}
     break;
 
   case 88:
 
     {
-       menu_add_dep((yyvsp[-1].expr));
+       menu_add_dep((yyvsp[(3) - (4)].expr));
        printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
 ;}
     break;
 
-  case 89:
+  case 90:
 
     {
-       menu_add_dep((yyvsp[-1].expr));
-       printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
+       menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
 ;}
     break;
 
-  case 90:
+  case 93:
 
-    {
-       menu_add_dep((yyvsp[-1].expr));
-       printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
-;}
+    { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
     break;
 
-  case 92:
+  case 94:
 
-    {
-       menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr));
-;}
+    { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
     break;
 
   case 95:
 
-    { (yyval.id) = (yyvsp[-1].id); ;}
+    { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
     break;
 
-  case 96:
+  case 98:
 
-    { (yyval.id) = (yyvsp[-1].id); ;}
+    { (yyval.expr) = NULL; ;}
     break;
 
-  case 97:
+  case 99:
 
-    { (yyval.id) = (yyvsp[-1].id); ;}
+    { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
     break;
 
   case 100:
 
-    { (yyval.expr) = NULL; ;}
+    { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;}
     break;
 
   case 101:
 
-    { (yyval.expr) = (yyvsp[0].expr); ;}
+    { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
     break;
 
   case 102:
 
-    { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); ;}
+    { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
     break;
 
   case 103:
 
-    { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;}
+    { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;}
     break;
 
   case 104:
 
-    { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;}
+    { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;}
     break;
 
   case 105:
 
-    { (yyval.expr) = (yyvsp[-1].expr); ;}
+    { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
     break;
 
   case 106:
 
-    { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); ;}
+    { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
     break;
 
   case 107:
 
-    { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;}
+    { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;}
     break;
 
   case 108:
 
-    { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;}
-    break;
-
-  case 109:
-
-    { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); ;}
+    { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 1); free((yyvsp[(1) - (1)].string)); ;}
     break;
 
-  case 110:
-
-    { (yyval.symbol) = sym_lookup((yyvsp[0].string), 1); free((yyvsp[0].string)); ;}
-    break;
 
+/* Line 1267 of yacc.c.  */
 
       default: break;
     }
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
-/* Line 1126 of yacc.c.  */
-
-\f
-  yyvsp -= yylen;
-  yyssp -= yylen;
-
-
+  YYPOPSTACK (yylen);
+  yylen = 0;
   YY_STACK_PRINT (yyss, yyssp);
 
   *++yyvsp = yyval;
@@ -1866,110 +2054,41 @@ yyerrlab:
   if (!yyerrstatus)
     {
       ++yynerrs;
-#if YYERROR_VERBOSE
-      yyn = yypact[yystate];
-
-      if (YYPACT_NINF < yyn && yyn < YYLAST)
-       {
-         int yytype = YYTRANSLATE (yychar);
-         YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
-         YYSIZE_T yysize = yysize0;
-         YYSIZE_T yysize1;
-         int yysize_overflow = 0;
-         char *yymsg = 0;
-#        define YYERROR_VERBOSE_ARGS_MAXIMUM 5
-         char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
-         int yyx;
-
-#if 0
-         /* This is so xgettext sees the translatable formats that are
-            constructed on the fly.  */
-         YY_("syntax error, unexpected %s");
-         YY_("syntax error, unexpected %s, expecting %s");
-         YY_("syntax error, unexpected %s, expecting %s or %s");
-         YY_("syntax error, unexpected %s, expecting %s or %s or %s");
-         YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-#endif
-         char *yyfmt;
-         char const *yyf;
-         static char const yyunexpected[] = "syntax error, unexpected %s";
-         static char const yyexpecting[] = ", expecting %s";
-         static char const yyor[] = " or %s";
-         char yyformat[sizeof yyunexpected
-                       + sizeof yyexpecting - 1
-                       + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
-                          * (sizeof yyor - 1))];
-         char const *yyprefix = yyexpecting;
-
-         /* Start YYX at -YYN if negative to avoid negative indexes in
-            YYCHECK.  */
-         int yyxbegin = yyn < 0 ? -yyn : 0;
-
-         /* Stay within bounds of both yycheck and yytname.  */
-         int yychecklim = YYLAST - yyn;
-         int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
-         int yycount = 1;
-
-         yyarg[0] = yytname[yytype];
-         yyfmt = yystpcpy (yyformat, yyunexpected);
-
-         for (yyx = yyxbegin; yyx < yyxend; ++yyx)
-           if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+#if ! YYERROR_VERBOSE
+      yyerror (YY_("syntax error"));
+#else
+      {
+       YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+       if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+         {
+           YYSIZE_T yyalloc = 2 * yysize;
+           if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+             yyalloc = YYSTACK_ALLOC_MAXIMUM;
+           if (yymsg != yymsgbuf)
+             YYSTACK_FREE (yymsg);
+           yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+           if (yymsg)
+             yymsg_alloc = yyalloc;
+           else
              {
-               if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
-                 {
-                   yycount = 1;
-                   yysize = yysize0;
-                   yyformat[sizeof yyunexpected - 1] = '\0';
-                   break;
-                 }
-               yyarg[yycount++] = yytname[yyx];
-               yysize1 = yysize + yytnamerr (0, yytname[yyx]);
-               yysize_overflow |= yysize1 < yysize;
-               yysize = yysize1;
-               yyfmt = yystpcpy (yyfmt, yyprefix);
-               yyprefix = yyor;
+               yymsg = yymsgbuf;
+               yymsg_alloc = sizeof yymsgbuf;
              }
+         }
 
-         yyf = YY_(yyformat);
-         yysize1 = yysize + yystrlen (yyf);
-         yysize_overflow |= yysize1 < yysize;
-         yysize = yysize1;
-
-         if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
-           yymsg = (char *) YYSTACK_ALLOC (yysize);
-         if (yymsg)
-           {
-             /* Avoid sprintf, as that infringes on the user's name space.
-                Don't have undefined behavior even if the translation
-                produced a string with the wrong number of "%s"s.  */
-             char *yyp = yymsg;
-             int yyi = 0;
-             while ((*yyp = *yyf))
-               {
-                 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
-                   {
-                     yyp += yytnamerr (yyp, yyarg[yyi++]);
-                     yyf += 2;
-                   }
-                 else
-                   {
-                     yyp++;
-                     yyf++;
-                   }
-               }
-             yyerror (yymsg);
-             YYSTACK_FREE (yymsg);
-           }
-         else
-           {
-             yyerror (YY_("syntax error"));
+       if (0 < yysize && yysize <= yymsg_alloc)
+         {
+           (void) yysyntax_error (yymsg, yystate, yychar);
+           yyerror (yymsg);
+         }
+       else
+         {
+           yyerror (YY_("syntax error"));
+           if (yysize != 0)
              goto yyexhaustedlab;
-           }
-       }
-      else
-#endif /* YYERROR_VERBOSE */
-       yyerror (YY_("syntax error"));
+         }
+      }
+#endif
     }
 
 
@@ -1980,14 +2099,15 @@ yyerrlab:
         error, discard it.  */
 
       if (yychar <= YYEOF)
-        {
+       {
          /* Return failure if at end of input.  */
          if (yychar == YYEOF)
            YYABORT;
-        }
+       }
       else
        {
-         yydestruct ("Error: discarding", yytoken, &yylval);
+         yydestruct ("Error: discarding",
+                     yytoken, &yylval);
          yychar = YYEMPTY;
        }
     }
@@ -2005,11 +2125,14 @@ yyerrorlab:
   /* Pacify compilers like GCC when the user code never invokes
      YYERROR and the label yyerrorlab therefore never appears in user
      code.  */
-  if (0)
+  if (/*CONSTCOND*/ 0)
      goto yyerrorlab;
 
-yyvsp -= yylen;
-  yyssp -= yylen;
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYERROR.  */
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
   yystate = *yyssp;
   goto yyerrlab1;
 
@@ -2039,8 +2162,9 @@ yyerrlab1:
        YYABORT;
 
 
-      yydestruct ("Error: popping", yystos[yystate], yyvsp);
-      YYPOPSTACK;
+      yydestruct ("Error: popping",
+                 yystos[yystate], yyvsp);
+      YYPOPSTACK (1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
     }
@@ -2051,7 +2175,7 @@ yyerrlab1:
   *++yyvsp = yylval;
 
 
-  /* Shift the error token. */
+  /* Shift the error token.  */
   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
   yystate = yyn;
@@ -2086,17 +2210,26 @@ yyreturn:
   if (yychar != YYEOF && yychar != YYEMPTY)
      yydestruct ("Cleanup: discarding lookahead",
                 yytoken, &yylval);
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYABORT or YYACCEPT.  */
+  YYPOPSTACK (yylen);
+  YY_STACK_PRINT (yyss, yyssp);
   while (yyssp != yyss)
     {
       yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
-      YYPOPSTACK;
+      YYPOPSTACK (1);
     }
 #ifndef yyoverflow
   if (yyss != yyssa)
     YYSTACK_FREE (yyss);
 #endif
-  return yyresult;
+#if YYERROR_VERBOSE
+  if (yymsg != yymsgbuf)
+    YYSTACK_FREE (yymsg);
+#endif
+  /* Make sure YYID is used.  */
+  return YYID (yyresult);
 }
 
 
@@ -2344,4 +2477,3 @@ void zconfdump(FILE *out)
 #include "symbol.c"
 #include "menu.c"
 
-
index 79db4cf..d9b96ba 100644 (file)
@@ -64,7 +64,6 @@ static struct menu *current_menu, *current_entry;
 %token <id>T_IF
 %token <id>T_ENDIF
 %token <id>T_DEPENDS
-%token <id>T_REQUIRES
 %token <id>T_OPTIONAL
 %token <id>T_PROMPT
 %token <id>T_TYPE
@@ -418,16 +417,6 @@ depends: T_DEPENDS T_ON expr T_EOL
 {
        menu_add_dep($3);
        printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
-}
-       | T_DEPENDS expr T_EOL
-{
-       menu_add_dep($2);
-       printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
-}
-       | T_REQUIRES expr T_EOL
-{
-       menu_add_dep($2);
-       printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
 };
 
 /* prompt statement */