diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 16:54:49 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 16:54:49 +0100 |
commit | d1a76187a5be4f89c6cb19d800cb5fb7aac735c5 (patch) | |
tree | 2fac3ffbfffc7560eeef8364b541d0d7a0057920 /arch/um | |
parent | c7e78cff6b7518212247fb20b1dc6411540dc9af (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into core/locking
Conflicts:
arch/um/include/asm/system.h
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/Kconfig.char | 4 | ||||
-rw-r--r-- | arch/um/Kconfig.common | 77 | ||||
-rw-r--r-- | arch/um/Kconfig.rest | 42 | ||||
-rw-r--r-- | arch/um/Kconfig.um (renamed from arch/um/Kconfig) | 120 | ||||
-rw-r--r-- | arch/um/Kconfig.x86 (renamed from arch/um/Kconfig.i386) | 43 | ||||
-rw-r--r-- | arch/um/Kconfig.x86_64 | 42 | ||||
-rw-r--r-- | arch/um/Makefile | 93 | ||||
-rw-r--r-- | arch/um/Makefile-os-Linux | 1 | ||||
-rw-r--r-- | arch/um/drivers/Makefile | 1 | ||||
-rw-r--r-- | arch/um/drivers/line.c | 2 | ||||
-rw-r--r-- | arch/um/drivers/ubd_kern.c | 19 | ||||
-rw-r--r-- | arch/um/include/asm/a.out-core.h | 27 | ||||
-rw-r--r-- | arch/um/include/asm/apic.h | 4 | ||||
-rw-r--r-- | arch/um/include/asm/auxvec.h | 4 | ||||
-rw-r--r-- | arch/um/include/asm/bugs.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/cache.h | 17 | ||||
-rw-r--r-- | arch/um/include/asm/checksum.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/common.lds.S | 130 | ||||
-rw-r--r-- | arch/um/include/asm/cputime.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/current.h | 13 | ||||
-rw-r--r-- | arch/um/include/asm/delay.h | 20 | ||||
-rw-r--r-- | arch/um/include/asm/desc.h | 16 | ||||
-rw-r--r-- | arch/um/include/asm/device.h | 7 | ||||
-rw-r--r-- | arch/um/include/asm/dma-mapping.h | 128 | ||||
-rw-r--r-- | arch/um/include/asm/dma.h | 10 | ||||
-rw-r--r-- | arch/um/include/asm/emergency-restart.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/fixmap.h | 99 | ||||
-rw-r--r-- | arch/um/include/asm/futex.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/hardirq.h | 25 | ||||
-rw-r--r-- | arch/um/include/asm/hw_irq.h | 7 | ||||
-rw-r--r-- | arch/um/include/asm/io.h | 57 | ||||
-rw-r--r-- | arch/um/include/asm/irq.h | 23 | ||||
-rw-r--r-- | arch/um/include/asm/irq_regs.h | 1 | ||||
-rw-r--r-- | arch/um/include/asm/irq_vectors.h | 20 | ||||
-rw-r--r-- | arch/um/include/asm/irqflags.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/kdebug.h | 1 | ||||
-rw-r--r-- | arch/um/include/asm/kmap_types.h | 29 | ||||
-rw-r--r-- | arch/um/include/asm/mmu.h | 22 | ||||
-rw-r--r-- | arch/um/include/asm/mmu_context.h | 54 | ||||
-rw-r--r-- | arch/um/include/asm/mutex.h | 9 | ||||
-rw-r--r-- | arch/um/include/asm/page.h | 122 | ||||
-rw-r--r-- | arch/um/include/asm/page_offset.h | 1 | ||||
-rw-r--r-- | arch/um/include/asm/param.h | 20 | ||||
-rw-r--r-- | arch/um/include/asm/pci.h | 7 | ||||
-rw-r--r-- | arch/um/include/asm/pda.h | 31 | ||||
-rw-r--r-- | arch/um/include/asm/pgalloc.h | 72 | ||||
-rw-r--r-- | arch/um/include/asm/pgtable-2level.h | 53 | ||||
-rw-r--r-- | arch/um/include/asm/pgtable-3level.h | 146 | ||||
-rw-r--r-- | arch/um/include/asm/pgtable.h | 366 | ||||
-rw-r--r-- | arch/um/include/asm/processor-generic.h | 136 | ||||
-rw-r--r-- | arch/um/include/asm/ptrace-generic.h | 55 | ||||
-rw-r--r-- | arch/um/include/asm/required-features.h | 9 | ||||
-rw-r--r-- | arch/um/include/asm/sections.h | 7 | ||||
-rw-r--r-- | arch/um/include/asm/segment.h | 10 | ||||
-rw-r--r-- | arch/um/include/asm/setup.h | 10 | ||||
-rw-r--r-- | arch/um/include/asm/smp.h | 33 | ||||
-rw-r--r-- | arch/um/include/asm/suspend.h | 4 | ||||
-rw-r--r-- | arch/um/include/asm/system.h | 35 | ||||
-rw-r--r-- | arch/um/include/asm/thread_info.h | 83 | ||||
-rw-r--r-- | arch/um/include/asm/timex.h | 13 | ||||
-rw-r--r-- | arch/um/include/asm/tlb.h | 127 | ||||
-rw-r--r-- | arch/um/include/asm/tlbflush.h | 31 | ||||
-rw-r--r-- | arch/um/include/asm/topology.h | 6 | ||||
-rw-r--r-- | arch/um/include/asm/uaccess.h | 99 | ||||
-rw-r--r-- | arch/um/include/asm/xor.h | 6 | ||||
-rw-r--r-- | arch/um/include/shared/aio.h (renamed from arch/um/include/aio.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/arch.h (renamed from arch/um/include/arch.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/as-layout.h (renamed from arch/um/include/as-layout.h) | 1 | ||||
-rw-r--r-- | arch/um/include/shared/chan_kern.h (renamed from arch/um/include/chan_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/chan_user.h (renamed from arch/um/include/chan_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/common-offsets.h (renamed from arch/um/include/common-offsets.h) | 13 | ||||
-rw-r--r-- | arch/um/include/shared/elf_user.h (renamed from arch/um/include/elf_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/frame_kern.h (renamed from arch/um/include/frame_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/init.h (renamed from arch/um/include/init.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/initrd.h (renamed from arch/um/include/initrd.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/irq_kern.h (renamed from arch/um/include/irq_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/irq_user.h (renamed from arch/um/include/irq_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/kern.h (renamed from arch/um/include/kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/kern_util.h (renamed from arch/um/include/kern_util.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/ldt.h | 37 | ||||
-rw-r--r-- | arch/um/include/shared/line.h (renamed from arch/um/include/line.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/longjmp.h (renamed from arch/um/include/longjmp.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/mconsole.h (renamed from arch/um/include/mconsole.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/mconsole_kern.h (renamed from arch/um/include/mconsole_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/mem.h (renamed from arch/um/include/mem.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/mem_kern.h (renamed from arch/um/include/mem_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/mem_user.h (renamed from arch/um/include/mem_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/net_kern.h (renamed from arch/um/include/net_kern.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/net_user.h (renamed from arch/um/include/net_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/os.h (renamed from arch/um/include/os.h) | 1 | ||||
-rw-r--r-- | arch/um/include/shared/process.h (renamed from arch/um/include/process.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/ptrace_user.h (renamed from arch/um/include/ptrace_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/registers.h (renamed from arch/um/include/registers.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/sigio.h (renamed from arch/um/include/sigio.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas/mm_id.h (renamed from arch/um/include/skas/mm_id.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas/proc_mm.h (renamed from arch/um/include/skas/proc_mm.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas/skas.h (renamed from arch/um/include/skas/skas.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas/stub-data.h (renamed from arch/um/include/skas/stub-data.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas_ptrace.h (renamed from arch/um/include/skas_ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/skas_ptregs.h (renamed from arch/um/include/skas_ptregs.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/syscall.h (renamed from arch/um/include/syscall.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/sysrq.h (renamed from arch/um/include/sysrq.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/task.h (renamed from arch/um/include/task.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/tlb.h (renamed from arch/um/include/tlb.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/ubd_user.h (renamed from arch/um/include/ubd_user.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/um_malloc.h (renamed from arch/um/include/um_malloc.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/um_mmu.h (renamed from arch/um/include/um_mmu.h) | 3 | ||||
-rw-r--r-- | arch/um/include/shared/um_uaccess.h (renamed from arch/um/include/um_uaccess.h) | 0 | ||||
-rw-r--r-- | arch/um/include/shared/user.h (renamed from arch/um/include/user.h) | 2 | ||||
-rw-r--r-- | arch/um/include/sigcontext.h | 25 | ||||
-rw-r--r-- | arch/um/kernel/exec.c | 13 | ||||
-rw-r--r-- | arch/um/kernel/internal.h | 1 | ||||
-rw-r--r-- | arch/um/kernel/signal.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/smp.c | 1 | ||||
-rw-r--r-- | arch/um/kernel/syscall.c | 1 | ||||
-rw-r--r-- | arch/um/os-Linux/Makefile | 3 | ||||
-rw-r--r-- | arch/um/os-Linux/include/file.h | 11 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/mem.c | 1 | ||||
-rw-r--r-- | arch/um/os-Linux/tty_log.c | 217 | ||||
-rw-r--r-- | arch/um/sys-i386/asm/archparam.h | 26 | ||||
-rw-r--r-- | arch/um/sys-i386/asm/elf.h | 163 | ||||
-rw-r--r-- | arch/um/sys-i386/asm/module.h | 13 | ||||
-rw-r--r-- | arch/um/sys-i386/asm/processor.h | 78 | ||||
-rw-r--r-- | arch/um/sys-i386/asm/ptrace.h | 56 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/archsetjmp.h (renamed from arch/um/include/sysdep-i386/archsetjmp.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/barrier.h (renamed from arch/um/include/sysdep-i386/barrier.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/checksum.h (renamed from arch/um/include/sysdep-i386/checksum.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/faultinfo.h (renamed from arch/um/include/sysdep-i386/faultinfo.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/host_ldt.h | 34 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/kernel-offsets.h (renamed from arch/um/include/sysdep-i386/kernel-offsets.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/ptrace.h (renamed from arch/um/include/sysdep-i386/ptrace.h) | 1 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/ptrace_user.h (renamed from arch/um/include/sysdep-i386/ptrace_user.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/sc.h (renamed from arch/um/include/sysdep-i386/sc.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/sigcontext.h (renamed from arch/um/include/sysdep-i386/sigcontext.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/skas_ptrace.h (renamed from arch/um/include/sysdep-i386/skas_ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/stub.h (renamed from arch/um/include/sysdep-i386/stub.h) | 1 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/syscalls.h (renamed from arch/um/include/sysdep-i386/syscalls.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/system.h | 132 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/tls.h (renamed from arch/um/include/sysdep-i386/tls.h) | 2 | ||||
-rw-r--r-- | arch/um/sys-i386/shared/sysdep/vm-flags.h | 14 | ||||
-rw-r--r-- | arch/um/sys-i386/signal.c | 3 | ||||
-rw-r--r-- | arch/um/sys-i386/stub.S | 1 | ||||
-rw-r--r-- | arch/um/sys-i386/syscalls.c | 1 | ||||
-rw-r--r-- | arch/um/sys-ia64/sysdep/ptrace.h (renamed from arch/um/include/sysdep-ia64/ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ia64/sysdep/sigcontext.h (renamed from arch/um/include/sysdep-ia64/sigcontext.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ia64/sysdep/skas_ptrace.h (renamed from arch/um/include/sysdep-ia64/skas_ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ia64/sysdep/syscalls.h (renamed from arch/um/include/sysdep-ia64/syscalls.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ppc/asm/archparam.h | 8 | ||||
-rw-r--r-- | arch/um/sys-ppc/asm/elf.h | 53 | ||||
-rw-r--r-- | arch/um/sys-ppc/asm/processor.h | 15 | ||||
-rw-r--r-- | arch/um/sys-ppc/shared/sysdep/ptrace.h (renamed from arch/um/include/sysdep-ppc/ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ppc/shared/sysdep/sigcontext.h (renamed from arch/um/include/sysdep-ppc/sigcontext.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ppc/shared/sysdep/skas_ptrace.h (renamed from arch/um/include/sysdep-ppc/skas_ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-ppc/shared/sysdep/syscalls.h (renamed from arch/um/include/sysdep-ppc/syscalls.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/asm/archparam.h | 26 | ||||
-rw-r--r-- | arch/um/sys-x86_64/asm/elf.h | 119 | ||||
-rw-r--r-- | arch/um/sys-x86_64/asm/module.h | 30 | ||||
-rw-r--r-- | arch/um/sys-x86_64/asm/processor.h | 56 | ||||
-rw-r--r-- | arch/um/sys-x86_64/asm/ptrace.h | 72 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/archsetjmp.h (renamed from arch/um/include/sysdep-x86_64/archsetjmp.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/barrier.h (renamed from arch/um/include/sysdep-x86_64/barrier.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/checksum.h (renamed from arch/um/include/sysdep-x86_64/checksum.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/faultinfo.h (renamed from arch/um/include/sysdep-x86_64/faultinfo.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/host_ldt.h | 38 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h (renamed from arch/um/include/sysdep-x86_64/kernel-offsets.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/ptrace.h (renamed from arch/um/include/sysdep-x86_64/ptrace.h) | 1 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/ptrace_user.h (renamed from arch/um/include/sysdep-x86_64/ptrace_user.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/sc.h (renamed from arch/um/include/sysdep-x86_64/sc.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/sigcontext.h (renamed from arch/um/include/sysdep-x86_64/sigcontext.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h (renamed from arch/um/include/sysdep-x86_64/skas_ptrace.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/stub.h (renamed from arch/um/include/sysdep-x86_64/stub.h) | 1 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/syscalls.h (renamed from arch/um/include/sysdep-x86_64/syscalls.h) | 0 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/system.h | 132 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/tls.h (renamed from arch/um/include/sysdep-x86_64/tls.h) | 2 | ||||
-rw-r--r-- | arch/um/sys-x86_64/shared/sysdep/vm-flags.h | 33 | ||||
-rw-r--r-- | arch/um/sys-x86_64/stub.S | 1 | ||||
-rw-r--r-- | arch/um/sys-x86_64/syscall_table.c | 8 |
177 files changed, 3585 insertions, 552 deletions
diff --git a/arch/um/Kconfig.char b/arch/um/Kconfig.char index 1b238ebae6b..70dabd1e065 100644 --- a/arch/um/Kconfig.char +++ b/arch/um/Kconfig.char @@ -203,6 +203,10 @@ config SOUND tristate default UML_SOUND +config SOUND_OSS_CORE + bool + default UML_SOUND + config HOSTAUDIO tristate default UML_SOUND diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common new file mode 100644 index 00000000000..0d207e73a75 --- /dev/null +++ b/arch/um/Kconfig.common @@ -0,0 +1,77 @@ +config DEFCONFIG_LIST + string + option defconfig_list + default "arch/$ARCH/defconfig" + +# UML uses the generic IRQ subsystem +config GENERIC_HARDIRQS + bool + default y + +config UML + bool + default y + +config MMU + bool + default y + +config NO_IOMEM + def_bool y + +mainmenu "Linux/Usermode Kernel Configuration" + +config ISA + bool + +config SBUS + bool + +config PCI + bool + +config PCMCIA + bool + +# Yet to do! +config TRACE_IRQFLAGS_SUPPORT + bool + default n + +config LOCKDEP_SUPPORT + bool + default y + +config STACKTRACE_SUPPORT + bool + default n + +config GENERIC_CALIBRATE_DELAY + bool + default y + +config GENERIC_BUG + bool + 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 + default y + +config HZ + int + default 100 + +config SUBARCH + string + option env="SUBARCH" diff --git a/arch/um/Kconfig.rest b/arch/um/Kconfig.rest new file mode 100644 index 00000000000..7b5cea75a6c --- /dev/null +++ b/arch/um/Kconfig.rest @@ -0,0 +1,42 @@ +source "init/Kconfig" + +source "kernel/Kconfig.freezer" + +source "drivers/block/Kconfig" + +source "arch/um/Kconfig.char" + +source "drivers/base/Kconfig" + +source "net/Kconfig" + +source "arch/um/Kconfig.net" + +source "drivers/net/Kconfig" + +source "drivers/connector/Kconfig" + +source "fs/Kconfig" + +source "security/Kconfig" + +source "crypto/Kconfig" + +source "lib/Kconfig" + +source "drivers/scsi/Kconfig" + +source "drivers/md/Kconfig" + +if BROKEN + source "drivers/mtd/Kconfig" +endif + +source "drivers/leds/Kconfig" + +#This is just to shut up some Kconfig warnings, so no prompt. +config INPUT + bool + default n + +source "arch/um/Kconfig.debug" diff --git a/arch/um/Kconfig b/arch/um/Kconfig.um index 6976812cfb1..ec2b8da1aba 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig.um @@ -1,79 +1,3 @@ -config DEFCONFIG_LIST - string - option defconfig_list - default "arch/$ARCH/defconfig" - -# UML uses the generic IRQ subsystem -config GENERIC_HARDIRQS - bool - default y - -config UML - bool - default y - -config MMU - bool - default y - -config NO_IOMEM - def_bool y - -mainmenu "Linux/Usermode Kernel Configuration" - -config ISA - bool - -config SBUS - bool - -config PCI - bool - -config PCMCIA - bool - -# Yet to do! -config TRACE_IRQFLAGS_SUPPORT - bool - default n - -config LOCKDEP_SUPPORT - bool - default y - -config STACKTRACE_SUPPORT - bool - default n - -config GENERIC_CALIBRATE_DELAY - bool - default y - -config GENERIC_BUG - bool - 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 - default y - -config HZ - int - default 100 - -menu "UML-specific options" - config STATIC_LINK bool "Force a static link" default n @@ -85,7 +9,6 @@ config STATIC_LINK 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" @@ -224,46 +147,3 @@ config KERNEL_STACK_ORDER 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 - -source "init/Kconfig" - -source "drivers/block/Kconfig" - -source "arch/um/Kconfig.char" - -source "drivers/base/Kconfig" - -source "net/Kconfig" - -source "arch/um/Kconfig.net" - -source "drivers/net/Kconfig" - -source "drivers/connector/Kconfig" - -source "fs/Kconfig" - -source "security/Kconfig" - -source "crypto/Kconfig" - -source "lib/Kconfig" - -source "drivers/scsi/Kconfig" - -source "drivers/md/Kconfig" - -if BROKEN - source "drivers/mtd/Kconfig" -endif - -source "drivers/leds/Kconfig" - -#This is just to shut up some Kconfig warnings, so no prompt. -config INPUT - bool - default n - -source "arch/um/Kconfig.debug" diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.x86 index e09edfa560d..5ee328099c6 100644 --- a/arch/um/Kconfig.i386 +++ b/arch/um/Kconfig.x86 @@ -1,3 +1,7 @@ +source "arch/um/Kconfig.common" + +menu "UML-specific options" + menu "Host processor type and features" source "arch/x86/Kconfig.cpu" @@ -5,23 +9,25 @@ source "arch/x86/Kconfig.cpu" endmenu config UML_X86 + def_bool y + +config 64BIT bool - default y + default SUBARCH = "x86_64" config X86_32 - bool - default y + def_bool !64BIT + select HAVE_AOUT config RWSEM_XCHGADD_ALGORITHM - def_bool y + def_bool X86_XADD -config 64BIT - bool - default n +config RWSEM_GENERIC_SPINLOCK + def_bool !X86_XADD config 3_LEVEL_PGTABLES - bool "Three-level pagetables (EXPERIMENTAL)" - default n + bool "Three-level pagetables (EXPERIMENTAL)" if !64BIT + default 64BIT depends on EXPERIMENTAL help Three-level pagetables will let UML have more than 4G of physical @@ -32,16 +38,19 @@ config 3_LEVEL_PGTABLES N (on x86-64 it's automatically enabled, instead, as it's safe there). config ARCH_HAS_SC_SIGNALS - bool - default y + def_bool !64BIT config ARCH_REUSE_HOST_VSYSCALL_AREA - bool - default y + def_bool !64BIT -config GENERIC_HWEIGHT - bool - default y +config SMP_BROKEN + def_bool 64BIT -config ARCH_SUPPORTS_AOUT +config GENERIC_HWEIGHT def_bool y + +source "arch/um/Kconfig.um" + +endmenu + +source "arch/um/Kconfig.rest" diff --git a/arch/um/Kconfig.x86_64 b/arch/um/Kconfig.x86_64 deleted file mode 100644 index 5696e7b374b..00000000000 --- a/arch/um/Kconfig.x86_64 +++ /dev/null @@ -1,42 +0,0 @@ - -menu "Host processor type and features" - -source "arch/x86/Kconfig.cpu" - -endmenu - -config UML_X86 - bool - default y - -config 64BIT - bool - default y - -#XXX: this is so in the underlying arch, but it's wrong!!! -config RWSEM_GENERIC_SPINLOCK - bool - default y - -config 3_LEVEL_PGTABLES - bool - default y - -config ARCH_HAS_SC_SIGNALS - bool - default n - -config ARCH_REUSE_HOST_VSYSCALL_AREA - bool - default n - -config SMP_BROKEN - bool - default y - -config GENERIC_HWEIGHT - bool - default y - -config ARCH_SUPPORTS_AOUT - def_bool y diff --git a/arch/um/Makefile b/arch/um/Makefile index ca40397017b..d944c343acd 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -18,28 +18,16 @@ core-y += $(ARCH_DIR)/kernel/ \ $(ARCH_DIR)/drivers/ \ $(ARCH_DIR)/os-$(OS)/ -# Have to precede the include because the included Makefiles reference them. -SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ - module.h vm-flags.h elf.h host_ldt.h -SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) - -# XXX: The "os" symlink is only used by arch/um/include/os.h, which includes -# ../os/include/file.h -# -# These are cleaned up during mrproper. Please DO NOT fix it again, this is -# the Correct Thing(tm) to do! -ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ - $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h - -MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/skas +MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas include $(srctree)/$(ARCH_DIR)/Makefile-skas -ARCH_INCLUDE := -I$(ARCH_DIR)/include +ARCH_INCLUDE := -I$(srctree)/$(ARCH_DIR)/include/shared +ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared ifneq ($(KBUILD_SRC),) -ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include +ARCH_INCLUDE += -I$(ARCH_DIR)/include/shared # for two generated files endif -SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) +KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so # named - it's a common symbol in libpcap, so we get a binary which crashes. @@ -65,6 +53,8 @@ include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) #This will adjust *FLAGS accordingly to the platform. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) +KBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include + # -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 KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different @@ -93,14 +83,10 @@ define archhelp echo ' find in the kernel root.' endef -ifneq ($(KBUILD_SRC),) -$(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch) -else -$(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) -endif +KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH) -archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h -prepare: $(ARCH_DIR)/include/kern_constants.h +archprepare: $(ARCH_DIR)/include/shared/user_constants.h +prepare: $(ARCH_DIR)/include/shared/kern_constants.h LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib @@ -132,62 +118,19 @@ endef # 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 - -MRPROPER_FILES += $(ARCH_SYMLINKS) +CLEAN_FILES += linux x.i gmon.out \ + $(ARCH_DIR)/include/shared/user_constants.h \ + $(ARCH_DIR)/include/shared/kern_constants.h archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ -o -name '*.gcov' \) -type f -print | xargs rm -f -$(SYMLINK_HEADERS): - @echo ' SYMLINK $@' -ifneq ($(KBUILD_SRC),) - $(Q)mkdir -p $(objtree)/include/asm-um - $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ -else - $(Q)cd $(srctree)/$(dir $@) ; \ - ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) -endif - -include/asm-um/arch: - @echo ' SYMLINK $@' -ifneq ($(KBUILD_SRC),) - $(Q)mkdir -p $(objtree)/include/asm-um - $(Q)ln -fsn $(srctree)/include/asm-$(HEADER_ARCH) include/asm-um/arch -else - $(Q)cd $(srctree)/include/asm-um && ln -fsn ../asm-$(HEADER_ARCH) arch -endif - -$(objtree)/$(ARCH_DIR)/include: +$(objtree)/$(ARCH_DIR)/include/shared: @echo ' MKDIR $@' $(Q)mkdir -p $@ -$(ARCH_DIR)/include/sysdep: $(objtree)/$(ARCH_DIR)/include - @echo ' SYMLINK $@' -ifneq ($(KBUILD_SRC),) - $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep -else - $(Q)cd $(ARCH_DIR)/include && ln -fsn sysdep-$(SUBARCH) sysdep -endif - -$(ARCH_DIR)/os: - @echo ' SYMLINK $@' -ifneq ($(KBUILD_SRC),) - $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $(ARCH_DIR)/os -else - $(Q)cd $(ARCH_DIR) && ln -fsn os-$(OS) os -endif - # Generated files -define filechk_umlconfig - sed 's/ CONFIG/ UML_CONFIG/' -endef - -$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h - $(call filechk,umlconfig) $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@ @@ -205,11 +148,11 @@ define filechk_gen-asm-offsets echo ""; ) endef -$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s +$(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s $(call filechk,gen-asm-offsets) -$(ARCH_DIR)/include/kern_constants.h: $(objtree)/$(ARCH_DIR)/include +$(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared @echo ' SYMLINK $@' - $(Q)ln -sf ../../../include/asm-um/asm-offsets.h $@ + $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@ -export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH +export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH diff --git a/arch/um/Makefile-os-Linux b/arch/um/Makefile-os-Linux index 52859487c95..2c8a598ec14 100644 --- a/arch/um/Makefile-os-Linux +++ b/arch/um/Makefile-os-Linux @@ -6,3 +6,4 @@ # To get a definition of F_SETSIG USER_CFLAGS += -D_GNU_SOURCE -D_LARGEFILE64_SOURCE KBUILD_CFLAGS += -D_LARGEFILE64_SOURCE +DEV_NULL_PATH = \"/dev/null\" diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index d283e7b022a..1d9b6ae967b 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -62,5 +62,6 @@ 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 vde_user.o +CFLAGS_null.o = -DDEV_NULL=$(DEV_NULL_PATH) include arch/um/scripts/Makefile.rules diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index d741f35d7b3..14a102e877d 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -275,6 +275,8 @@ int line_ioctl(struct tty_struct *tty, struct file * file, case TIOCGLTC: case TIOCSLTC: #endif + /* Note: these are out of date as we now have TCGETS2 etc but this + whole lot should probably go away */ case TCGETS: case TCSETSF: case TCSETSW: diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index b58fb8941d8..0a868118cf0 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -98,9 +98,9 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data) static DEFINE_MUTEX(ubd_lock); -static int ubd_open(struct inode * inode, struct file * filp); -static int ubd_release(struct inode * inode, struct file * file); -static int ubd_ioctl(struct inode * inode, struct file * file, +static int ubd_open(struct block_device *bdev, fmode_t mode); +static int ubd_release(struct gendisk *disk, fmode_t mode); +static int ubd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo); @@ -1112,9 +1112,9 @@ static int __init ubd_driver_init(void){ device_initcall(ubd_driver_init); -static int ubd_open(struct inode *inode, struct file *filp) +static int ubd_open(struct block_device *bdev, fmode_t mode) { - struct gendisk *disk = inode->i_bdev->bd_disk; + struct gendisk *disk = bdev->bd_disk; struct ubd *ubd_dev = disk->private_data; int err = 0; @@ -1131,7 +1131,7 @@ static int ubd_open(struct inode *inode, struct file *filp) /* This should no more be needed. And it didn't work anyway to exclude * read-write remounting of filesystems.*/ - /*if((filp->f_mode & FMODE_WRITE) && !ubd_dev->openflags.w){ + /*if((mode & FMODE_WRITE) && !ubd_dev->openflags.w){ if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev); err = -EROFS; }*/ @@ -1139,9 +1139,8 @@ static int ubd_open(struct inode *inode, struct file *filp) return err; } -static int ubd_release(struct inode * inode, struct file * file) +static int ubd_release(struct gendisk *disk, fmode_t mode) { - struct gendisk *disk = inode->i_bdev->bd_disk; struct ubd *ubd_dev = disk->private_data; if(--ubd_dev->count == 0) @@ -1306,10 +1305,10 @@ static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo) return 0; } -static int ubd_ioctl(struct inode * inode, struct file * file, +static int ubd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct ubd *ubd_dev = inode->i_bdev->bd_disk->private_data; + struct ubd *ubd_dev = bdev->bd_disk->private_data; struct hd_driveid ubd_id = { .cyls = 0, .heads = 128, diff --git a/arch/um/include/asm/a.out-core.h b/arch/um/include/asm/a.out-core.h new file mode 100644 index 00000000000..995643b1830 --- /dev/null +++ b/arch/um/include/asm/a.out-core.h @@ -0,0 +1,27 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public Licence + * as published by the Free Software Foundation; either version + * 2 of the Licence, or (at your option) any later version. + */ + +#ifndef __UM_A_OUT_CORE_H +#define __UM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include <linux/user.h> + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *u) +{ +} + +#endif /* __KERNEL__ */ +#endif /* __UM_A_OUT_CORE_H */ diff --git a/arch/um/include/asm/apic.h b/arch/um/include/asm/apic.h new file mode 100644 index 00000000000..876dee84ab1 --- /dev/null +++ b/arch/um/include/asm/apic.h @@ -0,0 +1,4 @@ +#ifndef __UM_APIC_H +#define __UM_APIC_H + +#endif diff --git a/arch/um/include/asm/auxvec.h b/arch/um/include/asm/auxvec.h new file mode 100644 index 00000000000..1e5e1c2fc9b --- /dev/null +++ b/arch/um/include/asm/auxvec.h @@ -0,0 +1,4 @@ +#ifndef __UM_AUXVEC_H +#define __UM_AUXVEC_H + +#endif diff --git a/arch/um/include/asm/bugs.h b/arch/um/include/asm/bugs.h new file mode 100644 index 00000000000..6a72e240d5f --- /dev/null +++ b/arch/um/include/asm/bugs.h @@ -0,0 +1,6 @@ +#ifndef __UM_BUGS_H +#define __UM_BUGS_H + +void check_bugs(void); + +#endif diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h new file mode 100644 index 00000000000..19e1bdd6741 --- /dev/null +++ b/arch/um/include/asm/cache.h @@ -0,0 +1,17 @@ +#ifndef __UM_CACHE_H +#define __UM_CACHE_H + + +#if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT) +# define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) +#elif defined(CONFIG_UML_X86) /* 64-bit */ +# define L1_CACHE_SHIFT 6 /* Should be 7 on Intel */ +#else +/* XXX: this was taken from x86, now it's completely random. Luckily only + * affects SMP padding. */ +# define L1_CACHE_SHIFT 5 +#endif + +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#endif diff --git a/arch/um/include/asm/checksum.h b/arch/um/include/asm/checksum.h new file mode 100644 index 00000000000..5b501361e36 --- /dev/null +++ b/arch/um/include/asm/checksum.h @@ -0,0 +1,6 @@ +#ifndef __UM_CHECKSUM_H +#define __UM_CHECKSUM_H + +#include "sysdep/checksum.h" + +#endif diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S new file mode 100644 index 00000000000..cb0248616d4 --- /dev/null +++ b/arch/um/include/asm/common.lds.S @@ -0,0 +1,130 @@ +#include <asm-generic/vmlinux.lds.h> + + .fini : { *(.fini) } =0x9090 + _etext = .; + PROVIDE (etext = .); + + . = ALIGN(4096); + _sdata = .; + PROVIDE (sdata = .); + + RODATA + + .unprotected : { *(.unprotected) } + . = ALIGN(4096); + PROVIDE (_unprotected_end = .); + + . = ALIGN(4096); + .note : { *(.note.*) } + __ex_table : { + __start___ex_table = .; + *(__ex_table) + __stop___ex_table = .; + } + + BUG_TABLE + + .uml.setup.init : { + __uml_setup_start = .; + *(.uml.setup.init) + __uml_setup_end = .; + } + + .uml.help.init : { + __uml_help_start = .; + *(.uml.help.init) + __uml_help_end = .; + } + + .uml.postsetup.init : { + __uml_postsetup_start = .; + *(.uml.postsetup.init) + __uml_postsetup_end = .; + } + + .init.setup : { + __setup_start = .; + *(.init.setup) + __setup_end = .; + } + + . = ALIGN(32); + .data.percpu : { + __per_cpu_start = . ; + *(.data.percpu) + __per_cpu_end = . ; + } + + .initcall.init : { + __initcall_start = .; + INITCALLS + __initcall_end = .; + } + + .con_initcall.init : { + __con_initcall_start = .; + *(.con_initcall.init) + __con_initcall_end = .; + } + + .uml.initcall.init : { + __uml_initcall_start = .; + *(.uml.initcall.init) + __uml_initcall_end = .; + } + __init_end = .; + + SECURITY_INIT + + .exitcall : { + __exitcall_begin = .; + *(.exitcall.exit) + __exitcall_end = .; + } + + .uml.exitcall : { + __uml_exitcall_begin = .; + *(.uml.exitcall.exit) + __uml_exitcall_end = .; + } + + . = ALIGN(4); + .altinstructions : { + __alt_instructions = .; + *(.altinstructions) + __alt_instructions_end = .; + } + .altinstr_replacement : { *(.altinstr_replacement) } + /* .exit.text is discard at runtime, not link time, to deal with references + from .altinstructions and .eh_frame */ + .exit.text : { *(.exit.text) } + .exit.data : { *(.exit.data) } + + .preinit_array : { + __preinit_array_start = .; + *(.preinit_array) + __preinit_array_end = .; + } + .init_array : { + __init_array_start = .; + *(.init_array) + __init_array_end = .; + } + .fini_array : { + __fini_array_start = .; + *(.fini_array) + __fini_array_end = .; + } + + . = ALIGN(4096); + .init.ramfs : { + __initramfs_start = .; + *(.init.ramfs) + __initramfs_end = .; + } + + /* Sections to be discarded */ + /DISCARD/ : { + *(.exitcall.exit) + } + diff --git a/arch/um/include/asm/cputime.h b/arch/um/include/asm/cputime.h new file mode 100644 index 00000000000..c84acbadfa2 --- /dev/null +++ b/arch/um/include/asm/cputime.h @@ -0,0 +1,6 @@ +#ifndef __UM_CPUTIME_H +#define __UM_CPUTIME_H + +#include <asm-generic/cputime.h> + +#endif /* __UM_CPUTIME_H */ diff --git a/arch/um/include/asm/current.h b/arch/um/include/asm/current.h new file mode 100644 index 00000000000..c2191d9aa03 --- /dev/null +++ b/arch/um/include/asm/current.h @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_CURRENT_H +#define __UM_CURRENT_H + +#include "linux/thread_info.h" + +#define current (current_thread_info()->task) + +#endif diff --git a/arch/um/include/asm/delay.h b/arch/um/include/asm/delay.h new file mode 100644 index 00000000000..c71e32b6741 --- /dev/null +++ b/arch/um/include/asm/delay.h @@ -0,0 +1,20 @@ +#ifndef __UM_DELAY_H +#define __UM_DELAY_H + +#define MILLION 1000000 + +/* Undefined on purpose */ +extern void __bad_udelay(void); + +extern void __udelay(unsigned long usecs); +extern void __delay(unsigned long loops); + +#define udelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \ + __bad_udelay() : __udelay(n)) + +/* It appears that ndelay is not used at all for UML, and has never been + * implemented. */ +extern void __unimplemented_ndelay(void); +#define ndelay(n) __unimplemented_ndelay() + +#endif diff --git a/arch/um/include/asm/desc.h b/arch/um/include/asm/desc.h new file mode 100644 index 00000000000..4ec34a51b62 --- /dev/null +++ b/arch/um/include/asm/desc.h @@ -0,0 +1,16 @@ +#ifndef __UM_DESC_H +#define __UM_DESC_H + +/* Taken from asm-i386/desc.h, it's the only thing we need. The rest wouldn't + * compile, and has never been used. */ +#define LDT_empty(info) (\ + (info)->base_addr == 0 && \ + (info)->limit == 0 && \ + (info)->contents == 0 && \ + (info)->read_exec_only == 1 && \ + (info)->seg_32bit == 0 && \ + (info)->limit_in_pages == 0 && \ + (info)->seg_not_present == 1 && \ + (info)->useable == 0 ) + +#endif diff --git a/arch/um/include/asm/device.h b/arch/um/include/asm/device.h new file mode 100644 index 00000000000..d8f9872b0e2 --- /dev/null +++ b/arch/um/include/asm/device.h @@ -0,0 +1,7 @@ +/* + * Arch specific extensions to struct device + * + * This file is released under the GPLv2 + */ +#include <asm-generic/device.h> + diff --git a/arch/um/include/asm/dma-mapping.h b/arch/um/include/asm/dma-mapping.h new file mode 100644 index 00000000000..90fc708b320 --- /dev/null +++ b/arch/um/include/asm/dma-mapping.h @@ -0,0 +1,128 @@ +#ifndef _ASM_DMA_MAPPING_H +#define _ASM_DMA_MAPPING_H + +#include <asm/scatterlist.h> + +static inline int +dma_supported(struct device *dev, u64 mask) +{ + BUG(); + return(0); +} + +static inline int +dma_set_mask(struct device *dev, u64 dma_mask) +{ + BUG(); + return(0); +} + +static inline void * +dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, + gfp_t flag) +{ + BUG(); + return((void *) 0); +} + +static inline void +dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, + dma_addr_t dma_handle) +{ + BUG(); +} + +static inline dma_addr_t +dma_map_single(struct device *dev, void *cpu_addr, size_t size, + enum dma_data_direction direction) +{ + BUG(); + return(0); +} + +static inline void +dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline dma_addr_t +dma_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction direction) +{ + BUG(); + return(0); +} + +static inline void +dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline int +dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, + enum dma_data_direction direction) +{ + BUG(); + return(0); +} + +static inline void +dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline void +dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline void +dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems, + enum dma_data_direction direction) +{ + BUG(); +} + +#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) +#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) +#define dma_is_consistent(d, h) (1) + +static inline int +dma_get_cache_alignment(void) +{ + BUG(); + return(0); +} + +static inline void +dma_sync_single_range(struct device *dev, dma_addr_t dma_handle, + unsigned long offset, size_t size, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline void +dma_cache_sync(struct device *dev, void *vaddr, size_t size, + enum dma_data_direction direction) +{ + BUG(); +} + +static inline int +dma_mapping_error(struct device *dev, dma_addr_t dma_handle) +{ + BUG(); + return 0; +} + +#endif diff --git a/arch/um/include/asm/dma.h b/arch/um/include/asm/dma.h new file mode 100644 index 00000000000..9f6139a8a52 --- /dev/null +++ b/arch/um/include/asm/dma.h @@ -0,0 +1,10 @@ +#ifndef __UM_DMA_H +#define __UM_DMA_H + +#include "asm/io.h" + +extern unsigned long uml_physmem; + +#define MAX_DMA_ADDRESS (uml_physmem) + +#endif diff --git a/arch/um/include/asm/emergency-restart.h b/arch/um/include/asm/emergency-restart.h new file mode 100644 index 00000000000..108d8c48e42 --- /dev/null +++ b/arch/um/include/asm/emergency-restart.h @@ -0,0 +1,6 @@ +#ifndef _ASM_EMERGENCY_RESTART_H +#define _ASM_EMERGENCY_RESTART_H + +#include <asm-generic/emergency-restart.h> + +#endif /* _ASM_EMERGENCY_RESTART_H */ diff --git a/arch/um/include/asm/fixmap.h b/arch/um/include/asm/fixmap.h new file mode 100644 index 00000000000..69c0252345f --- /dev/null +++ b/arch/um/include/asm/fixmap.h @@ -0,0 +1,99 @@ +#ifndef __UM_FIXMAP_H +#define __UM_FIXMAP_H + +#include <asm/processor.h> +#include <asm/system.h> +#include <asm/kmap_types.h> +#include <asm/archparam.h> +#include <asm/page.h> +#include <linux/threads.h> + +/* + * Here we define all the compile-time 'special' virtual + * addresses. The point is to have a constant address at + * compile time, but to set the physical address only + * in the boot process. We allocate these special addresses + * from the end of virtual memory (0xfffff000) backwards. + * Also this lets us do fail-safe vmalloc(), we + * can guarantee that these special addresses and + * vmalloc()-ed addresses never overlap. + * + * these 'compile-time allocated' memory buffers are + * fixed-size 4k pages. (or larger if used with an increment + * highger than 1) use fixmap_set(idx,phys) to associate + * physical memory with fixmap indices. + * + * TLB entries of such buffers will not be flushed across + * task switches. + */ + +/* + * on UP currently we will have no trace of the fixmap mechanizm, + * no page table allocations, etc. This might change in the + * future, say framebuffers for the console driver(s) could be + * fix-mapped? + */ +enum fixed_addresses { +#ifdef CONFIG_HIGHMEM + FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ + FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, +#endif + __end_of_fixed_addresses +}; + +extern void __set_fixmap (enum fixed_addresses idx, + unsigned long phys, pgprot_t flags); + +#define set_fixmap(idx, phys) \ + __set_fixmap(idx, phys, PAGE_KERNEL) +/* + * Some hardware wants to get fixmapped without caching. + */ +#define set_fixmap_nocache(idx, phys) \ + __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE) +/* + * used by vmalloc.c. + * + * Leave one empty page between vmalloc'ed areas and + * the start of the fixmap, and leave one page empty + * at the top of mem.. + */ + +#define FIXADDR_TOP (TASK_SIZE - 2 * PAGE_SIZE) +#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) + +#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) +#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) + +extern void __this_fixmap_does_not_exist(void); + +/* + * 'index to address' translation. If anyone tries to use the idx + * directly without tranlation, we catch the bug with a NULL-deference + * kernel oops. Illegal ranges of incoming indices are caught too. + */ +static inline unsigned long fix_to_virt(const unsigned int idx) +{ + /* + * this branch gets completely eliminated after inlining, + * except when someone tries to use fixaddr indices in an + * illegal way. (such as mixing up address types or using + * out-of-range indices). + * + * If it doesn't get removed, the linker will complain + * loudly with a reasonably clear error message.. + */ + if (idx >= __end_of_fixed_addresses) + __this_fixmap_does_not_exist(); + + return __fix_to_virt(idx); +} + +static inline unsigned long virt_to_fix(const unsigned long vaddr) +{ + BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); + return __virt_to_fix(vaddr); +} + +#endif diff --git a/arch/um/include/asm/futex.h b/arch/um/include/asm/futex.h new file mode 100644 index 00000000000..6a332a9f099 --- /dev/null +++ b/arch/um/include/asm/futex.h @@ -0,0 +1,6 @@ +#ifndef _ASM_FUTEX_H +#define _ASM_FUTEX_H + +#include <asm-generic/futex.h> + +#endif diff --git a/arch/um/include/asm/hardirq.h b/arch/um/include/asm/hardirq.h new file mode 100644 index 00000000000..313ebb8a256 --- /dev/null +++ b/arch/um/include/asm/hardirq.h @@ -0,0 +1,25 @@ +/* (c) 2004 cw@f00f.org, GPLv2 blah blah */ + +#ifndef __ASM_UM_HARDIRQ_H +#define __ASM_UM_HARDIRQ_H + +#include <linux/threads.h> +#include <linux/irq.h> + +/* NOTE: When SMP works again we might want to make this + * ____cacheline_aligned or maybe use per_cpu state? --cw */ +typedef struct { + unsigned int __softirq_pending; +} irq_cpustat_t; + +#include <linux/irq_cpustat.h> + +/* As this would be very strange for UML to get we BUG() after the + * printk. */ +static inline void ack_bad_irq(unsigned int irq) +{ + printk(KERN_ERR "unexpected IRQ %02x\n", irq); + BUG(); +} + +#endif /* __ASM_UM_HARDIRQ_H */ diff --git a/arch/um/include/asm/hw_irq.h b/arch/um/include/asm/hw_irq.h new file mode 100644 index 00000000000..1cf84cf5f21 --- /dev/null +++ b/arch/um/include/asm/hw_irq.h @@ -0,0 +1,7 @@ +#ifndef _ASM_UM_HW_IRQ_H +#define _ASM_UM_HW_IRQ_H + +#include "asm/irq.h" +#include "asm/archparam.h" + +#endif diff --git a/arch/um/include/asm/io.h b/arch/um/include/asm/io.h new file mode 100644 index 00000000000..44e8b8c772a --- /dev/null +++ b/arch/um/include/asm/io.h @@ -0,0 +1,57 @@ +#ifndef __UM_IO_H +#define __UM_IO_H + +#include "asm/page.h" + +#define IO_SPACE_LIMIT 0xdeadbeef /* Sure hope nothing uses this */ + +static inline int inb(unsigned long i) { return(0); } +static inline void outb(char c, unsigned long i) { } + +/* + * Change virtual addresses to physical addresses and vv. + * These are pretty trivial + */ +static inline unsigned long virt_to_phys(volatile void * address) +{ + return __pa((void *) address); +} + +static inline void * phys_to_virt(unsigned long address) +{ + return __va(address); +} + +/* + * Convert a physical pointer to a virtual kernel pointer for /dev/mem + * access + */ +#define xlate_dev_mem_ptr(p) __va(p) + +/* + * Convert a virtual cached pointer to an uncached pointer + */ +#define xlate_dev_kmem_ptr(p) p + +static inline void writeb(unsigned char b, volatile void __iomem *addr) +{ + *(volatile unsigned char __force *) addr = b; +} +static inline void writew(unsigned short b, volatile void __iomem *addr) +{ + *(volatile unsigned short __force *) addr = b; +} +static inline void writel(unsigned int b, volatile void __iomem *addr) +{ + *(volatile unsigned int __force *) addr = b; +} +static inline void writeq(unsigned int b, volatile void __iomem *addr) +{ + *(volatile unsigned long long __force *) addr = b; +} +#define __raw_writeb writeb +#define __raw_writew writew +#define __raw_writel writel +#define __raw_writeq writeq + +#endif diff --git a/arch/um/include/asm/irq.h b/arch/um/include/asm/irq.h new file mode 100644 index 00000000000..4a2037f8204 --- /dev/null +++ b/arch/um/include/asm/irq.h @@ -0,0 +1,23 @@ +#ifndef __UM_IRQ_H +#define __UM_IRQ_H + +#define TIMER_IRQ 0 +#define UMN_IRQ 1 +#define CONSOLE_IRQ 2 +#define CONSOLE_WRITE_IRQ 3 +#define UBD_IRQ 4 +#define UM_ETH_IRQ 5 +#define SSL_IRQ 6 +#define SSL_WRITE_IRQ 7 +#define ACCEPT_IRQ 8 +#define MCONSOLE_IRQ 9 +#define WINCH_IRQ 10 +#define SIGIO_WRITE_IRQ 11 +#define TELNETD_IRQ 12 +#define XTERM_IRQ 13 +#define RANDOM_IRQ 14 + +#define LAST_IRQ RANDOM_IRQ +#define NR_IRQS (LAST_IRQ + 1) + +#endif diff --git a/arch/um/include/asm/irq_regs.h b/arch/um/include/asm/irq_regs.h new file mode 100644 index 00000000000..3dd9c0b7027 --- /dev/null +++ b/arch/um/include/asm/irq_regs.h @@ -0,0 +1 @@ +#include <asm-generic/irq_regs.h> diff --git a/arch/um/include/asm/irq_vectors.h b/arch/um/include/asm/irq_vectors.h new file mode 100644 index 00000000000..62ddba6fc73 --- /dev/null +++ b/arch/um/include/asm/irq_vectors.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UM_IRQ_VECTORS_H +#define __UM_IRQ_VECTORS_H + +#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/asm/irqflags.h b/arch/um/include/asm/irqflags.h new file mode 100644 index 00000000000..659b9abdfdb --- /dev/null +++ b/arch/um/include/asm/irqflags.h @@ -0,0 +1,6 @@ +#ifndef __UM_IRQFLAGS_H +#define __UM_IRQFLAGS_H + +/* Empty for now */ + +#endif diff --git a/arch/um/include/asm/kdebug.h b/arch/um/include/asm/kdebug.h new file mode 100644 index 00000000000..6ece1b03766 --- /dev/null +++ b/arch/um/include/asm/kdebug.h @@ -0,0 +1 @@ +#include <asm-generic/kdebug.h> diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h new file mode 100644 index 00000000000..6c03acdb440 --- /dev/null +++ b/arch/um/include/asm/kmap_types.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UM_KMAP_TYPES_H +#define __UM_KMAP_TYPES_H + +/* No more #include "asm/arch/kmap_types.h" ! */ + +enum km_type { + KM_BOUNCE_READ, + KM_SKB_SUNRPC_DATA, + KM_SKB_DATA_SOFTIRQ, + KM_USER0, + KM_USER1, + KM_UML_USERCOPY, /* UML specific, for copy_*_user - used in do_op_one_page */ + KM_BIO_SRC_IRQ, + KM_BIO_DST_IRQ, + KM_PTE0, + KM_PTE1, + KM_IRQ0, + KM_IRQ1, + KM_SOFTIRQ0, + KM_SOFTIRQ1, + KM_TYPE_NR +}; + +#endif diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h new file mode 100644 index 00000000000..2cf35c21d69 --- /dev/null +++ b/arch/um/include/asm/mmu.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __MMU_H +#define __MMU_H + +#include "um_mmu.h" + +#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/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h new file mode 100644 index 00000000000..54f42e8b010 --- /dev/null +++ b/arch/um/include/asm/mmu_context.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_MMU_CONTEXT_H +#define __UM_MMU_CONTEXT_H + +#include "linux/sched.h" +#include "um_mmu.h" + +extern void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); +extern void arch_exit_mmap(struct mm_struct *mm); + +#define get_mmu_context(task) do ; while(0) +#define activate_context(tsk) do ; while(0) + +#define deactivate_mm(tsk,mm) do { } while (0) + +extern void force_flush_all(void); + +static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) +{ + /* + * This is called by fs/exec.c and sys_unshare() + * when the new ->mm is used for the first time. + */ + __switch_mm(&new->context.id); + arch_dup_mmap(old, new); +} + +static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, + struct task_struct *tsk) +{ + unsigned cpu = smp_processor_id(); + + if(prev != next){ + cpu_clear(cpu, prev->cpu_vm_mask); + cpu_set(cpu, next->cpu_vm_mask); + if(next != &init_mm) + __switch_mm(&next->context.id); + } +} + +static inline void enter_lazy_tlb(struct mm_struct *mm, + struct task_struct *tsk) +{ +} + +extern int init_new_context(struct task_struct *task, struct mm_struct *mm); + +extern void destroy_context(struct mm_struct *mm); + +#endif diff --git a/arch/um/include/asm/mutex.h b/arch/um/include/asm/mutex.h new file mode 100644 index 00000000000..458c1f7fbc1 --- /dev/null +++ b/arch/um/include/asm/mutex.h @@ -0,0 +1,9 @@ +/* + * Pull in the generic implementation for the mutex fastpath. + * + * TODO: implement optimized primitives instead, or leave the generic + * implementation in place, or pick the atomic_xchg() based generic + * implementation. (see asm-generic/mutex-xchg.h for details) + */ + +#include <asm-generic/mutex-dec.h> diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h new file mode 100644 index 00000000000..55f28a0bae6 --- /dev/null +++ b/arch/um/include/asm/page.h @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) + * Copyright 2003 PathScale, Inc. + * Licensed under the GPL + */ + +#ifndef __UM_PAGE_H +#define __UM_PAGE_H + +#include <linux/const.h> + +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#ifndef __ASSEMBLY__ + +struct page; + +#include <linux/types.h> +#include <sysdep/vm-flags.h> + +/* + * These are used to make use of C type-checking.. + */ + +#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) +#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) + +#define clear_user_page(page, vaddr, pg) clear_page(page) +#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) + +#if defined(CONFIG_3_LEVEL_PGTABLES) && !defined(CONFIG_64BIT) + +typedef struct { unsigned long pte_low, pte_high; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +#define pte_val(x) ((x).pte_low | ((unsigned long long) (x).pte_high << 32)) + +#define pte_get_bits(pte, bits) ((pte).pte_low & (bits)) +#define pte_set_bits(pte, bits) ((pte).pte_low |= (bits)) +#define pte_clear_bits(pte, bits) ((pte).pte_low &= ~(bits)) +#define pte_copy(to, from) ({ (to).pte_high = (from).pte_high; \ + smp_wmb(); \ + (to).pte_low = (from).pte_low; }) +#define pte_is_zero(pte) (!((pte).pte_low & ~_PAGE_NEWPAGE) && !(pte).pte_high) +#define pte_set_val(pte, phys, prot) \ + ({ (pte).pte_high = (phys) >> 32; \ + (pte).pte_low = (phys) | pgprot_val(prot); }) + +#define pmd_val(x) ((x).pmd) +#define __pmd(x) ((pmd_t) { (x) } ) + +typedef unsigned long long pfn_t; +typedef unsigned long long phys_t; + +#else + +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pgd; } pgd_t; + +#ifdef CONFIG_3_LEVEL_PGTABLES +typedef struct { unsigned long pmd; } pmd_t; +#define pmd_val(x) ((x).pmd) +#define __pmd(x) ((pmd_t) { (x) } ) +#endif + +#define pte_val(x) ((x).pte) + + +#define pte_get_bits(p, bits) ((p).pte & (bits)) +#define pte_set_bits(p, bits) ((p).pte |= (bits)) +#define pte_clear_bits(p, bits) ((p).pte &= ~(bits)) +#define pte_copy(to, from) ((to).pte = (from).pte) +#define pte_is_zero(p) (!((p).pte & ~_PAGE_NEWPAGE)) +#define pte_set_val(p, phys, prot) (p).pte = (phys | pgprot_val(prot)) + +typedef unsigned long pfn_t; +typedef unsigned long phys_t; + +#endif + +typedef struct { unsigned long pgprot; } pgprot_t; + +typedef struct page *pgtable_t; + +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +extern unsigned long uml_physmem; + +#define PAGE_OFFSET (uml_physmem) +#define KERNELBASE PAGE_OFFSET + +#define __va_space (8*1024*1024) + +#include "mem.h" + +/* Cast to unsigned long before casting to void * to avoid a warning from + * mmap_kmem about cutting a long long down to a void *. Not sure that + * casting is the right thing, but 32-bit UML can't have 64-bit virtual + * addresses + */ +#define __pa(virt) to_phys((void *) (unsigned long) (virt)) +#define __va(phys) to_virt((unsigned long) (phys)) + +#define phys_to_pfn(p) ((pfn_t) ((p) >> PAGE_SHIFT)) +#define pfn_to_phys(pfn) ((phys_t) ((pfn) << PAGE_SHIFT)) + +#define pfn_valid(pfn) ((pfn) < max_mapnr) +#define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v))) + +#include <asm-generic/memory_model.h> +#include <asm-generic/page.h> + +#endif /* __ASSEMBLY__ */ +#endif /* __UM_PAGE_H */ diff --git a/arch/um/include/asm/page_offset.h b/arch/um/include/asm/page_offset.h new file mode 100644 index 00000000000..1c168dfbf35 --- /dev/null +++ b/arch/um/include/asm/page_offset.h @@ -0,0 +1 @@ +#define PAGE_OFFSET_RAW (uml_physmem) diff --git a/arch/um/include/asm/param.h b/arch/um/include/asm/param.h new file mode 100644 index 00000000000..e44f4e60d16 --- /dev/null +++ b/arch/um/include/asm/param.h @@ -0,0 +1,20 @@ +#ifndef _UM_PARAM_H +#define _UM_PARAM_H + +#define EXEC_PAGESIZE 4096 + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + +#ifdef __KERNEL__ +#define HZ CONFIG_HZ +#define USER_HZ 100 /* .. some user interfaces are in "ticks" */ +#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ +#else +#define HZ 100 +#endif + +#endif diff --git a/arch/um/include/asm/pci.h b/arch/um/include/asm/pci.h new file mode 100644 index 00000000000..59923199cdc --- /dev/null +++ b/arch/um/include/asm/pci.h @@ -0,0 +1,7 @@ +#ifndef __UM_PCI_H +#define __UM_PCI_H + +#define PCI_DMA_BUS_IS_PHYS (1) +#define pcibios_scan_all_fns(a, b) 0 + +#endif diff --git a/arch/um/include/asm/pda.h b/arch/um/include/asm/pda.h new file mode 100644 index 00000000000..0d8bf33ffd4 --- /dev/null +++ b/arch/um/include/asm/pda.h @@ -0,0 +1,31 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#ifndef __UM_PDA_X86_64_H +#define __UM_PDA_X86_64_H + +/* XXX */ +struct foo { + unsigned int __softirq_pending; + unsigned int __nmi_count; +}; + +extern struct foo me; + +#define read_pda(me) (&me) + +#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/asm/pgalloc.h b/arch/um/include/asm/pgalloc.h new file mode 100644 index 00000000000..9062a6e7224 --- /dev/null +++ b/arch/um/include/asm/pgalloc.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) + * Copyright 2003 PathScale, Inc. + * Derived from include/asm-i386/pgalloc.h and include/asm-i386/pgtable.h + * Licensed under the GPL + */ + +#ifndef __UM_PGALLOC_H +#define __UM_PGALLOC_H + +#include "linux/mm.h" +#include "asm/fixmap.h" + +#define pmd_populate_kernel(mm, pmd, pte) \ + set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte))) + +#define pmd_populate(mm, pmd, pte) \ + set_pmd(pmd, __pmd(_PAGE_TABLE + \ + ((unsigned long long)page_to_pfn(pte) << \ + (unsigned long long) PAGE_SHIFT))) +#define pmd_pgtable(pmd) pmd_page(pmd) + +/* + * Allocate and free page tables. + */ +extern pgd_t *pgd_alloc(struct mm_struct *); +extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); + +extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); +extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); + +static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) +{ + free_page((unsigned long) pte); +} + +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) +{ + pgtable_page_dtor(pte); + __free_page(pte); +} + +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb),(pte)); \ +} while (0) + +#ifdef CONFIG_3_LEVEL_PGTABLES + +static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) +{ + free_page((unsigned long)pmd); +} + +#define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) +#endif + +#define check_pgt_cache() 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/arch/um/include/asm/pgtable-2level.h b/arch/um/include/asm/pgtable-2level.h new file mode 100644 index 00000000000..f534b73e753 --- /dev/null +++ b/arch/um/include/asm/pgtable-2level.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) + * Copyright 2003 PathScale, Inc. + * Derived from include/asm-i386/pgtable.h + * Licensed under the GPL + */ + +#ifndef __UM_PGTABLE_2LEVEL_H +#define __UM_PGTABLE_2LEVEL_H + +#include <asm-generic/pgtable-nopmd.h> + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ + +#define PGDIR_SHIFT 22 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) + +/* + * entries per page directory level: the i386 is two-level, so + * we don't really have any PMD directory physically. + */ +#define PTRS_PER_PTE 1024 +#define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE) +#define PTRS_PER_PGD 1024 +#define FIRST_USER_ADDRESS 0 + +#define pte_ERROR(e) \ + printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), \ + pte_val(e)) +#define pgd_ERROR(e) \ + printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), \ + pgd_val(e)) + +static inline int pgd_newpage(pgd_t pgd) { return 0; } +static inline void pgd_mkuptodate(pgd_t pgd) { } + +#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) + +#define pte_pfn(x) phys_to_pfn(pte_val(x)) +#define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot)) +#define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot)) + +/* + * Bits 0 through 4 are taken + */ +#define PTE_FILE_MAX_BITS 27 + +#define pte_to_pgoff(pte) (pte_val(pte) >> 5) + +#define pgoff_to_pte(off) ((pte_t) { ((off) << 5) + _PAGE_FILE }) + +#endif diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h new file mode 100644 index 00000000000..0446f456b42 --- /dev/null +++ b/arch/um/include/asm/pgtable-3level.h @@ -0,0 +1,146 @@ +/* + * Copyright 2003 PathScale Inc + * Derived from include/asm-i386/pgtable.h + * Licensed under the GPL + */ + +#ifndef __UM_PGTABLE_3LEVEL_H +#define __UM_PGTABLE_3LEVEL_H + +#include <asm-generic/pgtable-nopud.h> + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ + +#ifdef CONFIG_64BIT +#define PGDIR_SHIFT 30 +#else +#define PGDIR_SHIFT 31 +#endif +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) + +/* PMD_SHIFT determines the size of the area a second-level page table can + * map + */ + +#define PMD_SHIFT 21 +#define PMD_SIZE (1UL << PMD_SHIFT) +#define PMD_MASK (~(PMD_SIZE-1)) + +/* + * entries per page directory level + */ + +#define PTRS_PER_PTE 512 +#ifdef CONFIG_64BIT +#define PTRS_PER_PMD 512 +#define PTRS_PER_PGD 512 +#else +#define PTRS_PER_PMD 1024 +#define PTRS_PER_PGD 1024 +#endif + +#define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE) +#define FIRST_USER_ADDRESS 0 + +#define pte_ERROR(e) \ + printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \ + pte_val(e)) +#define pmd_ERROR(e) \ + printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ + pmd_val(e)) +#define pgd_ERROR(e) \ + printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ + pgd_val(e)) + +#define pud_none(x) (!(pud_val(x) & ~_PAGE_NEWPAGE)) +#define pud_bad(x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) +#define pud_present(x) (pud_val(x) & _PAGE_PRESENT) +#define pud_populate(mm, pud, pmd) \ + set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd))) + +#ifdef CONFIG_64BIT +#define set_pud(pudptr, pudval) set_64bit((phys_t *) (pudptr), pud_val(pudval)) +#else +#define set_pud(pudptr, pudval) (*(pudptr) = (pudval)) +#endif + +static inline int pgd_newpage(pgd_t pgd) +{ + return(pgd_val(pgd) & _PAGE_NEWPAGE); +} + +static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; } + +#ifdef CONFIG_64BIT +#define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval)) +#else +#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) +#endif + +struct mm_struct; +extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address); + +static inline void pud_clear (pud_t *pud) +{ + set_pud(pud, __pud(_PAGE_NEWPAGE)); +} + +#define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK) +#define pud_page_vaddr(pud) ((unsigned long) __va(pud_val(pud) & PAGE_MASK)) + +/* Find an entry in the second-level page table.. */ +#define pmd_offset(pud, address) ((pmd_t *) pud_page_vaddr(*(pud)) + \ + pmd_index(address)) + +static inline unsigned long pte_pfn(pte_t pte) +{ + return phys_to_pfn(pte_val(pte)); +} + +static inline pte_t pfn_pte(pfn_t page_nr, pgprot_t pgprot) +{ + pte_t pte; + phys_t phys = pfn_to_phys(page_nr); + + pte_set_val(pte, phys, pgprot); + return pte; +} + +static inline pmd_t pfn_pmd(pfn_t page_nr, pgprot_t pgprot) +{ + return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot)); +} + +/* + * Bits 0 through 3 are taken in the low part of the pte, + * put the 32 bits of offset into the high part. + */ +#define PTE_FILE_MAX_BITS 32 + +#ifdef CONFIG_64BIT + +#define pte_to_pgoff(p) ((p).pte >> 32) + +#define pgoff_to_pte(off) ((pte_t) { ((off) << 32) | _PAGE_FILE }) + +#else + +#define pte_to_pgoff(pte) ((pte).pte_high) + +#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) + +#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/asm/pgtable.h b/arch/um/include/asm/pgtable.h new file mode 100644 index 00000000000..58da2480a7f --- /dev/null +++ b/arch/um/include/asm/pgtable.h @@ -0,0 +1,366 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Copyright 2003 PathScale, Inc. + * Derived from include/asm-i386/pgtable.h + * Licensed under the GPL + */ + +#ifndef __UM_PGTABLE_H +#define __UM_PGTABLE_H + +#include <asm/fixmap.h> + +#define _PAGE_PRESENT 0x001 +#define _PAGE_NEWPAGE 0x002 +#define _PAGE_NEWPROT 0x004 +#define _PAGE_RW 0x020 +#define _PAGE_USER 0x040 +#define _PAGE_ACCESSED 0x080 +#define _PAGE_DIRTY 0x100 +/* If _PAGE_PRESENT is clear, we use these: */ +#define _PAGE_FILE 0x008 /* nonlinear file mapping, saved PTE; unset:swap */ +#define _PAGE_PROTNONE 0x010 /* if the user mapped it with PROT_NONE; + pte_present gives true */ + +#ifdef CONFIG_3_LEVEL_PGTABLES +#include "asm/pgtable-3level.h" +#else +#include "asm/pgtable-2level.h" +#endif + +extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; + +/* zero page used for uninitialized stuff */ +extern unsigned long *empty_zero_page; + +#define pgtable_cache_init() do ; while (0) + +/* Just any arbitrary offset to the start of the vmalloc VM area: the + * current 8MB value just means that there will be a 8MB "hole" after the + * physical memory until the kernel virtual memory starts. That means that + * any out-of-bounds memory accesses will hopefully be caught. + * The vmalloc() routines leaves a hole of 4kB between each vmalloced + * area for the same reason. ;) + */ + +extern unsigned long end_iomem; + +#define VMALLOC_OFFSET (__va_space) +#define VMALLOC_START ((end_iomem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) +#define PKMAP_BASE ((FIXADDR_START - LAST_PKMAP * PAGE_SIZE) & PMD_MASK) +#ifdef CONFIG_HIGHMEM +# define VMALLOC_END (PKMAP_BASE-2*PAGE_SIZE) +#else +# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) +#endif + +#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) +#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) +#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) + +#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) +#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) +#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) +#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) + +/* + * The i386 can't do page protection for execute, and considers that the same + * are read. + * Also, write permissions imply read permissions. This is the closest we can + * get.. + */ +#define __P000 PAGE_NONE +#define __P001 PAGE_READONLY +#define __P010 PAGE_COPY +#define __P011 PAGE_COPY +#define __P100 PAGE_READONLY +#define __P101 PAGE_READONLY +#define __P110 PAGE_COPY +#define __P111 PAGE_COPY + +#define __S000 PAGE_NONE +#define __S001 PAGE_READONLY +#define __S010 PAGE_SHARED +#define __S011 PAGE_SHARED +#define __S100 PAGE_READONLY +#define __S101 PAGE_READONLY +#define __S110 PAGE_SHARED +#define __S111 PAGE_SHARED + +/* + * ZERO_PAGE is a global shared page that is always zero: used + * for zero-mapped memory areas etc.. + */ +#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page) + +#define pte_clear(mm,addr,xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEWPAGE)) + +#define pmd_none(x) (!((unsigned long)pmd_val(x) & ~_PAGE_NEWPAGE)) +#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) + +#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) +#define pmd_clear(xp) do { pmd_val(*(xp)) = _PAGE_NEWPAGE; } while (0) + +#define pmd_newpage(x) (pmd_val(x) & _PAGE_NEWPAGE) +#define pmd_mkuptodate(x) (pmd_val(x) &= ~_PAGE_NEWPAGE) + +#define pud_newpage(x) (pud_val(x) & _PAGE_NEWPAGE) +#define pud_mkuptodate(x) (pud_val(x) &= ~_PAGE_NEWPAGE) + +#define pmd_page(pmd) phys_to_page(pmd_val(pmd) & PAGE_MASK) + +#define pte_page(x) pfn_to_page(pte_pfn(x)) + +#define pte_present(x) pte_get_bits(x, (_PAGE_PRESENT | _PAGE_PROTNONE)) + +/* + * ================================= + * Flags checking section. + * ================================= + */ + +static inline int pte_none(pte_t pte) +{ + return pte_is_zero(pte); +} + +/* + * The following only work if pte_present() is true. + * Undefined behaviour if not.. + */ +static inline int pte_read(pte_t pte) +{ + return((pte_get_bits(pte, _PAGE_USER)) && + !(pte_get_bits(pte, _PAGE_PROTNONE))); +} + +static inline int pte_exec(pte_t pte){ + return((pte_get_bits(pte, _PAGE_USER)) && + !(pte_get_bits(pte, _PAGE_PROTNONE))); +} + +static inline int pte_write(pte_t pte) +{ + return((pte_get_bits(pte, _PAGE_RW)) && + !(pte_get_bits(pte, _PAGE_PROTNONE))); +} + +/* + * The following only works if pte_present() is not true. + */ +static inline int pte_file(pte_t pte) +{ + return pte_get_bits(pte, _PAGE_FILE); +} + +static inline int pte_dirty(pte_t pte) +{ + return pte_get_bits(pte, _PAGE_DIRTY); +} + +static inline int pte_young(pte_t pte) +{ + return pte_get_bits(pte, _PAGE_ACCESSED); +} + +static inline int pte_newpage(pte_t pte) +{ + return pte_get_bits(pte, _PAGE_NEWPAGE); +} + +static inline int pte_newprot(pte_t pte) +{ + return(pte_present(pte) && (pte_get_bits(pte, _PAGE_NEWPROT))); +} + +static inline int pte_special(pte_t pte) +{ + return 0; +} + +/* + * ================================= + * Flags setting section. + * ================================= + */ + +static inline pte_t pte_mknewprot(pte_t pte) +{ + pte_set_bits(pte, _PAGE_NEWPROT); + return(pte); +} + +static inline pte_t pte_mkclean(pte_t pte) +{ + pte_clear_bits(pte, _PAGE_DIRTY); + return(pte); +} + +static inline pte_t pte_mkold(pte_t pte) +{ + pte_clear_bits(pte, _PAGE_ACCESSED); + return(pte); +} + +static inline pte_t pte_wrprotect(pte_t pte) +{ + pte_clear_bits(pte, _PAGE_RW); + return(pte_mknewprot(pte)); +} + +static inline pte_t pte_mkread(pte_t pte) +{ + pte_set_bits(pte, _PAGE_USER); + return(pte_mknewprot(pte)); +} + +static inline pte_t pte_mkdirty(pte_t pte) +{ + pte_set_bits(pte, _PAGE_DIRTY); + return(pte); +} + +static inline pte_t pte_mkyoung(pte_t pte) +{ + pte_set_bits(pte, _PAGE_ACCESSED); + return(pte); +} + +static inline pte_t pte_mkwrite(pte_t pte) +{ + pte_set_bits(pte, _PAGE_RW); + return(pte_mknewprot(pte)); +} + +static inline pte_t pte_mkuptodate(pte_t pte) +{ + pte_clear_bits(pte, _PAGE_NEWPAGE); + if(pte_present(pte)) + pte_clear_bits(pte, _PAGE_NEWPROT); + return(pte); +} + +static inline pte_t pte_mknewpage(pte_t pte) +{ + pte_set_bits(pte, _PAGE_NEWPAGE); + return(pte); +} + +static inline pte_t pte_mkspecial(pte_t pte) +{ + return(pte); +} + +static inline void set_pte(pte_t *pteptr, pte_t pteval) +{ + pte_copy(*pteptr, pteval); + + /* If it's a swap entry, it needs to be marked _PAGE_NEWPAGE so + * fix_range knows to unmap it. _PAGE_NEWPROT is specific to + * mapped pages. + */ + + *pteptr = pte_mknewpage(*pteptr); + if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr); +} +#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ + +#define phys_to_page(phys) pfn_to_page(phys_to_pfn(phys)) +#define __virt_to_page(virt) phys_to_page(__pa(virt)) +#define page_to_phys(page) pfn_to_phys((pfn_t) page_to_pfn(page)) +#define virt_to_page(addr) __virt_to_page((const unsigned long) addr) + +#define mk_pte(page, pgprot) \ + ({ pte_t pte; \ + \ + pte_set_val(pte, page_to_phys(page), (pgprot)); \ + if (pte_present(pte)) \ + pte_mknewprot(pte_mknewpage(pte)); \ + pte;}) + +static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) +{ + pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot); + return pte; +} + +/* + * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] + * + * this macro returns the index of the entry in the pgd page which would + * control the given virtual address + */ +#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) + +/* + * pgd_offset() returns a (pgd_t *) + * pgd_index() is used get the offset into the pgd page's array of pgd_t's; + */ +#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) + +/* + * a shortcut which implies the use of the kernel's pgd, instead + * of a process's + */ +#define pgd_offset_k(address) pgd_offset(&init_mm, address) + +/* + * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] + * + * this macro returns the index of the entry in the pmd page which would + * control the given virtual address + */ +#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) +#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) + +#define pmd_page_vaddr(pmd) \ + ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) + +/* + * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE] + * + * this macro returns the index of the entry in the pte page which would + * control the given virtual address + */ +#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) +#define pte_offset_kernel(dir, address) \ + ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) +#define pte_offset_map(dir, address) \ + ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) +#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address) +#define pte_unmap(pte) do { } while (0) +#define pte_unmap_nested(pte) do { } while (0) + +struct mm_struct; +extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr); + +#define update_mmu_cache(vma,address,pte) do ; while (0) + +/* Encode and de-code a swap entry */ +#define __swp_type(x) (((x).val >> 4) & 0x3f) +#define __swp_offset(x) ((x).val >> 11) + +#define __swp_entry(type, offset) \ + ((swp_entry_t) { ((type) << 4) | ((offset) << 11) }) +#define __pte_to_swp_entry(pte) \ + ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) }) +#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) + +#define kern_addr_valid(addr) (1) + +#include <asm-generic/pgtable.h> + +/* Clear a kernel PTE and flush it from the TLB */ +#define kpte_clear_flush(ptep, vaddr) \ +do { \ + pte_clear(&init_mm, (vaddr), (ptep)); \ + __flush_tlb_one((vaddr)); \ +} while (0) + +#endif diff --git a/arch/um/include/asm/processor-generic.h b/arch/um/include/asm/processor-generic.h new file mode 100644 index 00000000000..bed668824b5 --- /dev/null +++ b/arch/um/include/asm/processor-generic.h @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_PROCESSOR_GENERIC_H +#define __UM_PROCESSOR_GENERIC_H + +struct pt_regs; + +struct task_struct; + +#include "asm/ptrace.h" +#include "registers.h" +#include "sysdep/archsetjmp.h" + +struct mm_struct; + +struct thread_struct { + 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). + */ + int forking; + struct pt_regs regs; + int singlestep_syscall; + void *fault_addr; + jmp_buf *fault_catcher; + struct task_struct *prev_sched; + unsigned long temp_stack; + jmp_buf *exec_buf; + struct arch_thread arch; + jmp_buf switch_buf; + int mm_count; + struct { + int op; + union { + struct { + int pid; + } fork, exec; + struct { + int (*proc)(void *); + void *arg; + } thread; + struct { + void (*proc)(void *); + void *arg; + } cb; + } u; + } request; +}; + +#define INIT_THREAD \ +{ \ + .forking = 0, \ + .regs = EMPTY_REGS, \ + .fault_addr = NULL, \ + .prev_sched = NULL, \ + .temp_stack = 0, \ + .exec_buf = NULL, \ + .arch = INIT_ARCH_THREAD, \ + .request = { 0 } \ +} + +extern struct task_struct *alloc_task_struct(void); + +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) +{ +} + + +extern unsigned long thread_saved_pc(struct task_struct *t); + +static inline void mm_copy_segments(struct mm_struct *from_mm, + struct mm_struct *new_mm) +{ +} + +#define init_stack (init_thread_union.stack) + +/* + * User space process size: 3GB (default). + */ +extern unsigned long task_size; + +#define TASK_SIZE (task_size) + +#undef STACK_TOP +#undef STACK_TOP_MAX + +extern unsigned long stacksizelim; + +#define STACK_ROOM (stacksizelim) +#define STACK_TOP (TASK_SIZE - 2 * PAGE_SIZE) +#define STACK_TOP_MAX STACK_TOP + +/* This decides where the kernel will search for a free chunk of vm + * space during mmap's. + */ +#define TASK_UNMAPPED_BASE (0x40000000) + +extern void start_thread(struct pt_regs *regs, unsigned long entry, + unsigned long stack); + +struct cpuinfo_um { + unsigned long loops_per_jiffy; + int ipi_pipe[2]; +}; + +extern struct cpuinfo_um boot_cpu_data; + +#define my_cpu_data cpu_data[smp_processor_id()] + +#ifdef CONFIG_SMP +extern struct cpuinfo_um cpu_data[]; +#define current_cpu_data cpu_data[smp_processor_id()] +#else +#define cpu_data (&boot_cpu_data) +#define current_cpu_data boot_cpu_data +#endif + + +#define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf) +extern unsigned long get_wchan(struct task_struct *p); + +#endif diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h new file mode 100644 index 00000000000..6c8899013c9 --- /dev/null +++ b/arch/um/include/asm/ptrace-generic.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_PTRACE_GENERIC_H +#define __UM_PTRACE_GENERIC_H + +#ifndef __ASSEMBLY__ + +#include <asm/ptrace-abi.h> +#include <asm/user.h> +#include "sysdep/ptrace.h" + +struct pt_regs { + struct uml_pt_regs regs; +}; + +#define EMPTY_REGS { .regs = EMPTY_UML_PT_REGS } + +#define PT_REGS_IP(r) UPT_IP(&(r)->regs) +#define PT_REGS_SP(r) UPT_SP(&(r)->regs) + +#define PT_REG(r, reg) UPT_REG(&(r)->regs, reg) +#define PT_REGS_SET(r, reg, val) UPT_SET(&(r)->regs, reg, val) + +#define PT_REGS_SET_SYSCALL_RETURN(r, res) \ + UPT_SET_SYSCALL_RETURN(&(r)->regs, res) +#define PT_REGS_RESTART_SYSCALL(r) UPT_RESTART_SYSCALL(&(r)->regs) + +#define PT_REGS_SYSCALL_NR(r) UPT_SYSCALL_NR(&(r)->regs) + +#define PT_REGS_SC(r) UPT_SC(&(r)->regs) + +#define instruction_pointer(regs) PT_REGS_IP(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(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 int arch_copy_tls(struct task_struct *new); +extern void clear_flushed_tls(struct task_struct *task); + +#endif + +#endif diff --git a/arch/um/include/asm/required-features.h b/arch/um/include/asm/required-features.h new file mode 100644 index 00000000000..dfb967b2d2f --- /dev/null +++ b/arch/um/include/asm/required-features.h @@ -0,0 +1,9 @@ +#ifndef __UM_REQUIRED_FEATURES_H +#define __UM_REQUIRED_FEATURES_H + +/* + * Nothing to see, just need something for the i386 and x86_64 asm + * headers to include. + */ + +#endif diff --git a/arch/um/include/asm/sections.h b/arch/um/include/asm/sections.h new file mode 100644 index 00000000000..6b0231eefea --- /dev/null +++ b/arch/um/include/asm/sections.h @@ -0,0 +1,7 @@ +#ifndef _UM_SECTIONS_H +#define _UM_SECTIONS_H + +/* nothing to see, move along */ +#include <asm-generic/sections.h> + +#endif diff --git a/arch/um/include/asm/segment.h b/arch/um/include/asm/segment.h new file mode 100644 index 00000000000..45183fcd10b --- /dev/null +++ b/arch/um/include/asm/segment.h @@ -0,0 +1,10 @@ +#ifndef __UM_SEGMENT_H +#define __UM_SEGMENT_H + +extern int host_gdt_entry_tls_min; + +#define GDT_ENTRY_TLS_ENTRIES 3 +#define GDT_ENTRY_TLS_MIN host_gdt_entry_tls_min +#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1) + +#endif diff --git a/arch/um/include/asm/setup.h b/arch/um/include/asm/setup.h new file mode 100644 index 00000000000..99f086301f4 --- /dev/null +++ b/arch/um/include/asm/setup.h @@ -0,0 +1,10 @@ +#ifndef SETUP_H_INCLUDED +#define SETUP_H_INCLUDED + +/* POSIX mandated with _POSIX_ARG_MAX that we can rely on 4096 chars in the + * command line, so this choice is ok. + */ + +#define COMMAND_LINE_SIZE 4096 + +#endif /* SETUP_H_INCLUDED */ diff --git a/arch/um/include/asm/smp.h b/arch/um/include/asm/smp.h new file mode 100644 index 00000000000..f27a9631317 --- /dev/null +++ b/arch/um/include/asm/smp.h @@ -0,0 +1,33 @@ +#ifndef __UM_SMP_H +#define __UM_SMP_H + +#ifdef CONFIG_SMP + +#include "linux/bitops.h" +#include "asm/current.h" +#include "linux/cpumask.h" + +#define raw_smp_processor_id() (current_thread->cpu) + +#define cpu_logical_map(n) (n) +#define cpu_number_map(n) (n) +#define PROC_CHANGE_PENALTY 15 /* Pick a number, any number */ +extern int hard_smp_processor_id(void); +#define NO_PROC_ID -1 + +extern int ncpus; + + +static inline void smp_cpus_done(unsigned int maxcpus) +{ +} + +extern struct task_struct *idle_threads[NR_CPUS]; + +#else + +#define hard_smp_processor_id() 0 + +#endif + +#endif diff --git a/arch/um/include/asm/suspend.h b/arch/um/include/asm/suspend.h new file mode 100644 index 00000000000..f4e8e007f46 --- /dev/null +++ b/arch/um/include/asm/suspend.h @@ -0,0 +1,4 @@ +#ifndef __UM_SUSPEND_H +#define __UM_SUSPEND_H + +#endif diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h new file mode 100644 index 00000000000..ae5f94d6317 --- /dev/null +++ b/arch/um/include/asm/system.h @@ -0,0 +1,35 @@ +#ifndef __UM_SYSTEM_GENERIC_H +#define __UM_SYSTEM_GENERIC_H + +#include "sysdep/system.h" + +extern void *switch_to(void *prev, void *next, void *last); + +extern int get_signals(void); +extern int set_signals(int enable); +extern int get_signals(void); +extern void block_signals(void); +extern void unblock_signals(void); + +#define raw_local_save_flags(flags) do { typecheck(unsigned long, flags); \ + (flags) = get_signals(); } while(0) +#define raw_local_irq_restore(flags) do { typecheck(unsigned long, flags); \ + set_signals(flags); } while(0) + +#define raw_local_irq_save(flags) do { raw_local_save_flags(flags); \ + raw_local_irq_disable(); } while(0) + +#define raw_local_irq_enable() unblock_signals() +#define raw_local_irq_disable() block_signals() + +#define irqs_disabled() \ +({ \ + unsigned long flags; \ + raw_local_save_flags(flags); \ + (flags == 0); \ +}) + +extern void *_switch_to(void *prev, void *next, void *last); +#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) + +#endif diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h new file mode 100644 index 00000000000..62274ab9471 --- /dev/null +++ b/arch/um/include/asm/thread_info.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_THREAD_INFO_H +#define __UM_THREAD_INFO_H + +#ifndef __ASSEMBLY__ + +#include <asm/types.h> +#include <asm/page.h> +#include <asm/uaccess.h> + +struct thread_info { + struct task_struct *task; /* main task structure */ + struct exec_domain *exec_domain; /* execution domain */ + unsigned long flags; /* low level flags */ + __u32 cpu; /* current CPU */ + int preempt_count; /* 0 => preemptable, + <0 => BUG */ + mm_segment_t addr_limit; /* thread address space: + 0-0xBFFFFFFF for user + 0-0xFFFFFFFF for kernel */ + struct restart_block restart_block; + struct thread_info *real_thread; /* Points to non-IRQ stack */ +}; + +#define INIT_THREAD_INFO(tsk) \ +{ \ + .task = &tsk, \ + .exec_domain = &default_exec_domain, \ + .flags = 0, \ + .cpu = 0, \ + .preempt_count = 1, \ + .addr_limit = KERNEL_DS, \ + .restart_block = { \ + .fn = do_no_restart_syscall, \ + }, \ + .real_thread = NULL, \ +} + +#define init_thread_info (init_thread_union.thread_info) +#define init_stack (init_thread_union.stack) + +#define THREAD_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE) +/* how to get the thread information struct from C */ +static inline struct thread_info *current_thread_info(void) +{ + struct thread_info *ti; + unsigned long mask = THREAD_SIZE - 1; + ti = (struct thread_info *) (((unsigned long) &ti) & ~mask); + return ti; +} + +#define THREAD_SIZE_ORDER CONFIG_KERNEL_STACK_ORDER + +#endif + +#define PREEMPT_ACTIVE 0x10000000 + +#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ +#define TIF_SIGPENDING 1 /* signal pending */ +#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ +#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling + * TIF_NEED_RESCHED + */ +#define TIF_RESTART_BLOCK 4 +#define TIF_MEMDIE 5 +#define TIF_SYSCALL_AUDIT 6 +#define TIF_RESTORE_SIGMASK 7 +#define TIF_FREEZE 16 /* is freezing for suspend */ + +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) +#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) +#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) +#define _TIF_MEMDIE (1 << TIF_MEMDIE) +#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) +#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) +#define _TIF_FREEZE (1 << TIF_FREEZE) + +#endif diff --git a/arch/um/include/asm/timex.h b/arch/um/include/asm/timex.h new file mode 100644 index 00000000000..0f4ada08f74 --- /dev/null +++ b/arch/um/include/asm/timex.h @@ -0,0 +1,13 @@ +#ifndef __UM_TIMEX_H +#define __UM_TIMEX_H + +typedef unsigned long cycles_t; + +static inline cycles_t get_cycles (void) +{ + return 0; +} + +#define CLOCK_TICK_RATE (HZ) + +#endif diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h new file mode 100644 index 00000000000..5240fa1c5e0 --- /dev/null +++ b/arch/um/include/asm/tlb.h @@ -0,0 +1,127 @@ +#ifndef __UM_TLB_H +#define __UM_TLB_H + +#include <linux/pagemap.h> +#include <linux/swap.h> +#include <asm/percpu.h> +#include <asm/pgalloc.h> +#include <asm/tlbflush.h> + +#define tlb_start_vma(tlb, vma) do { } while (0) +#define tlb_end_vma(tlb, vma) do { } while (0) +#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) + +/* struct mmu_gather is an opaque type used by the mm code for passing around + * any data needed by arch specific code for tlb_remove_page. + */ +struct mmu_gather { + struct mm_struct *mm; + unsigned int need_flush; /* Really unmapped some ptes? */ + unsigned long start; + unsigned long end; + unsigned int fullmm; /* non-zero means full mm flush */ +}; + +/* Users of the generic TLB shootdown code must declare this storage space. */ +DECLARE_PER_CPU(struct mmu_gather, mmu_gathers); + +static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, + unsigned long address) +{ + if (tlb->start > address) + tlb->start = address; + if (tlb->end < address + PAGE_SIZE) + tlb->end = address + PAGE_SIZE; +} + +static inline void init_tlb_gather(struct mmu_gather *tlb) +{ + tlb->need_flush = 0; + + tlb->start = TASK_SIZE; + tlb->end = 0; + + if (tlb->fullmm) { + tlb->start = 0; + tlb->end = TASK_SIZE; + } +} + +/* tlb_gather_mmu + * Return a pointer to an initialized struct mmu_gather. + */ +static inline struct mmu_gather * +tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush) +{ + struct mmu_gather *tlb = &get_cpu_var(mmu_gathers); + + tlb->mm = mm; + tlb->fullmm = full_mm_flush; + + init_tlb_gather(tlb); + + return tlb; +} + +extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, + unsigned long end); + +static inline void +tlb_flush_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) +{ + if (!tlb->need_flush) + return; + + flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end); + init_tlb_gather(tlb); +} + +/* tlb_finish_mmu + * Called at the end of the shootdown operation to free up any resources + * that were required. + */ +static inline void +tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end) +{ + tlb_flush_mmu(tlb, start, end); + + /* keep the page table cache within bounds */ + check_pgt_cache(); + + put_cpu_var(mmu_gathers); +} + +/* tlb_remove_page + * Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), + * while handling the additional races in SMP caused by other CPUs + * caching valid mappings in their TLBs. + */ +static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) +{ + tlb->need_flush = 1; + free_page_and_swap_cache(page); + return; +} + +/** + * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation. + * + * Record the fact that pte's were really umapped in ->need_flush, so we can + * later optimise away the tlb invalidate. This helps when userspace is + * unmapping already-unmapped pages, which happens quite a lot. + */ +#define tlb_remove_tlb_entry(tlb, ptep, address) \ + do { \ + tlb->need_flush = 1; \ + __tlb_remove_tlb_entry(tlb, ptep, address); \ + } while (0) + +#define pte_free_tlb(tlb, ptep) __pte_free_tlb(tlb, ptep) + +#define pud_free_tlb(tlb, pudp) __pud_free_tlb(tlb, pudp) + +#define pmd_free_tlb(tlb, pmdp) __pmd_free_tlb(tlb, pmdp) + +#define tlb_migrate_finish(mm) do {} while (0) + +#endif diff --git a/arch/um/include/asm/tlbflush.h b/arch/um/include/asm/tlbflush.h new file mode 100644 index 00000000000..614f2c09117 --- /dev/null +++ b/arch/um/include/asm/tlbflush.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_TLBFLUSH_H +#define __UM_TLBFLUSH_H + +#include <linux/mm.h> + +/* + * TLB flushing: + * + * - flush_tlb() flushes the current mm struct TLBs + * - flush_tlb_all() flushes all processes TLBs + * - flush_tlb_mm(mm) flushes the specified mm context TLB's + * - 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 + */ + +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(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); + +#endif diff --git a/arch/um/include/asm/topology.h b/arch/um/include/asm/topology.h new file mode 100644 index 00000000000..0905e4f21d4 --- /dev/null +++ b/arch/um/include/asm/topology.h @@ -0,0 +1,6 @@ +#ifndef _ASM_UM_TOPOLOGY_H +#define _ASM_UM_TOPOLOGY_H + +#include <asm-generic/topology.h> + +#endif diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h new file mode 100644 index 00000000000..b9a895d6fa1 --- /dev/null +++ b/arch/um/include/asm/uaccess.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UM_UACCESS_H +#define __UM_UACCESS_H + +#include <asm/errno.h> +#include <asm/processor.h> + +/* thread_info has a mm_segment_t in it, so put the definition up here */ +typedef struct { + unsigned long seg; +} mm_segment_t; + +#include "linux/thread_info.h" + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +/* + * The fs value determines whether argument validity checking should be + * performed or not. If get_fs() == USER_DS, checking is performed, with + * get_fs() == KERNEL_DS, checking is bypassed. + * + * For historical reasons, these macros are grossly misnamed. + */ + +#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) + +#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) +#define USER_DS MAKE_MM_SEG(TASK_SIZE) + +#define get_ds() (KERNEL_DS) +#define get_fs() (current_thread_info()->addr_limit) +#define set_fs(x) (current_thread_info()->addr_limit = (x)) + +#define segment_eq(a, b) ((a).seg == (b).seg) + +#include "um_uaccess.h" + +#define __copy_from_user(to, from, n) copy_from_user(to, from, n) + +#define __copy_to_user(to, from, n) copy_to_user(to, from, n) + +#define __copy_to_user_inatomic __copy_to_user +#define __copy_from_user_inatomic __copy_from_user + +#define __get_user(x, ptr) \ +({ \ + const __typeof__(*(ptr)) __user *__private_ptr = (ptr); \ + __typeof__(x) __private_val; \ + int __private_ret = -EFAULT; \ + (x) = (__typeof__(*(__private_ptr)))0; \ + if (__copy_from_user((__force void *)&__private_val, (__private_ptr),\ + sizeof(*(__private_ptr))) == 0) { \ + (x) = (__typeof__(*(__private_ptr))) __private_val; \ + __private_ret = 0; \ + } \ + __private_ret; \ +}) + +#define get_user(x, ptr) \ +({ \ + const __typeof__((*(ptr))) __user *private_ptr = (ptr); \ + (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \ + __get_user(x, private_ptr) : ((x) = (__typeof__(*ptr))0, -EFAULT)); \ +}) + +#define __put_user(x, ptr) \ +({ \ + __typeof__(*(ptr)) __user *__private_ptr = ptr; \ + __typeof__(*(__private_ptr)) __private_val; \ + int __private_ret = -EFAULT; \ + __private_val = (__typeof__(*(__private_ptr))) (x); \ + if (__copy_to_user((__private_ptr), &__private_val, \ + sizeof(*(__private_ptr))) == 0) { \ + __private_ret = 0; \ + } \ + __private_ret; \ +}) + +#define put_user(x, ptr) \ +({ \ + __typeof__(*(ptr)) __user *private_ptr = (ptr); \ + (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \ + __put_user(x, private_ptr) : -EFAULT); \ +}) + +#define strlen_user(str) strnlen_user(str, ~0U >> 1) + +struct exception_table_entry +{ + unsigned long insn; + unsigned long fixup; +}; + +#endif diff --git a/arch/um/include/asm/xor.h b/arch/um/include/asm/xor.h new file mode 100644 index 00000000000..a19db3e1724 --- /dev/null +++ b/arch/um/include/asm/xor.h @@ -0,0 +1,6 @@ +#ifndef __UM_XOR_H +#define __UM_XOR_H + +#include "asm-generic/xor.h" + +#endif diff --git a/arch/um/include/aio.h b/arch/um/include/shared/aio.h index 423bae9153f..423bae9153f 100644 --- a/arch/um/include/aio.h +++ b/arch/um/include/shared/aio.h diff --git a/arch/um/include/arch.h b/arch/um/include/shared/arch.h index 2de92a08a76..2de92a08a76 100644 --- a/arch/um/include/arch.h +++ b/arch/um/include/shared/arch.h diff --git a/arch/um/include/as-layout.h b/arch/um/include/shared/as-layout.h index 58e852dfb0c..a92b678503c 100644 --- a/arch/um/include/as-layout.h +++ b/arch/um/include/shared/as-layout.h @@ -6,7 +6,6 @@ #ifndef __START_H__ #define __START_H__ -#include "uml-config.h" #include "kern_constants.h" /* diff --git a/arch/um/include/chan_kern.h b/arch/um/include/shared/chan_kern.h index 1e651457e04..1e651457e04 100644 --- a/arch/um/include/chan_kern.h +++ b/arch/um/include/shared/chan_kern.h diff --git a/arch/um/include/chan_user.h b/arch/um/include/shared/chan_user.h index 9b9ced85b70..9b9ced85b70 100644 --- a/arch/um/include/chan_user.h +++ b/arch/um/include/shared/chan_user.h diff --git a/arch/um/include/common-offsets.h b/arch/um/include/shared/common-offsets.h index b54bd35585c..72009c7e321 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/shared/common-offsets.h @@ -39,3 +39,16 @@ 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); + +#ifdef CONFIG_PRINTK +DEFINE(UML_CONFIG_PRINTK, CONFIG_PRINTK); +#endif +#ifdef CONFIG_NO_HZ +DEFINE(UML_CONFIG_NO_HZ, CONFIG_NO_HZ); +#endif +#ifdef CONFIG_UML_X86 +DEFINE(UML_CONFIG_UML_X86, CONFIG_UML_X86); +#endif +#ifdef CONFIG_64BIT +DEFINE(UML_CONFIG_64BIT, CONFIG_64BIT); +#endif diff --git a/arch/um/include/elf_user.h b/arch/um/include/shared/elf_user.h index 53516b63727..53516b63727 100644 --- a/arch/um/include/elf_user.h +++ b/arch/um/include/shared/elf_user.h diff --git a/arch/um/include/frame_kern.h b/arch/um/include/shared/frame_kern.h index ce9514f5721..ce9514f5721 100644 --- a/arch/um/include/frame_kern.h +++ b/arch/um/include/shared/frame_kern.h diff --git a/arch/um/include/init.h b/arch/um/include/shared/init.h index 37dd097c16c..37dd097c16c 100644 --- a/arch/um/include/init.h +++ b/arch/um/include/shared/init.h diff --git a/arch/um/include/initrd.h b/arch/um/include/shared/initrd.h index 439b9a81498..439b9a81498 100644 --- a/arch/um/include/initrd.h +++ b/arch/um/include/shared/initrd.h diff --git a/arch/um/include/irq_kern.h b/arch/um/include/shared/irq_kern.h index fba3895274f..fba3895274f 100644 --- a/arch/um/include/irq_kern.h +++ b/arch/um/include/shared/irq_kern.h diff --git a/arch/um/include/irq_user.h b/arch/um/include/shared/irq_user.h index c6c784df267..c6c784df267 100644 --- a/arch/um/include/irq_user.h +++ b/arch/um/include/shared/irq_user.h diff --git a/arch/um/include/kern.h b/arch/um/include/shared/kern.h index 4ce3fc650e5..4ce3fc650e5 100644 --- a/arch/um/include/kern.h +++ b/arch/um/include/shared/kern.h diff --git a/arch/um/include/kern_util.h b/arch/um/include/shared/kern_util.h index 3c341222d25..3c341222d25 100644 --- a/arch/um/include/kern_util.h +++ b/arch/um/include/shared/kern_util.h diff --git a/arch/um/include/shared/ldt.h b/arch/um/include/shared/ldt.h new file mode 100644 index 00000000000..a7f999a5877 --- /dev/null +++ b/arch/um/include/shared/ldt.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2004 Fujitsu Siemens Computers GmbH + * Licensed under the GPL + * + * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com> + */ + +#ifndef __ASM_LDT_H +#define __ASM_LDT_H + +#include <linux/mutex.h> +#include <sysdep/host_ldt.h> + +extern void ldt_host_info(void); + +#define LDT_PAGES_MAX \ + ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) +#define LDT_ENTRIES_PER_PAGE \ + (PAGE_SIZE/LDT_ENTRY_SIZE) +#define LDT_DIRECT_ENTRIES \ + ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) + +struct ldt_entry { + __u32 a; + __u32 b; +}; + +typedef struct uml_ldt { + int entry_count; + struct mutex lock; + union { + struct ldt_entry * pages[LDT_PAGES_MAX]; + struct ldt_entry entries[LDT_DIRECT_ENTRIES]; + } u; +} uml_ldt_t; + +#endif diff --git a/arch/um/include/line.h b/arch/um/include/shared/line.h index 311a0d3d93a..311a0d3d93a 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/shared/line.h diff --git a/arch/um/include/longjmp.h b/arch/um/include/shared/longjmp.h index e860bc5848e..e860bc5848e 100644 --- a/arch/um/include/longjmp.h +++ b/arch/um/include/shared/longjmp.h diff --git a/arch/um/include/mconsole.h b/arch/um/include/shared/mconsole.h index c139ae1d682..c139ae1d682 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/shared/mconsole.h diff --git a/arch/um/include/mconsole_kern.h b/arch/um/include/shared/mconsole_kern.h index d2fe07e7895..d2fe07e7895 100644 --- a/arch/um/include/mconsole_kern.h +++ b/arch/um/include/shared/mconsole_kern.h diff --git a/arch/um/include/mem.h b/arch/um/include/shared/mem.h index 5cd40e99e8d..5cd40e99e8d 100644 --- a/arch/um/include/mem.h +++ b/arch/um/include/shared/mem.h diff --git a/arch/um/include/mem_kern.h b/arch/um/include/shared/mem_kern.h index cb7e196d366..cb7e196d366 100644 --- a/arch/um/include/mem_kern.h +++ b/arch/um/include/shared/mem_kern.h diff --git a/arch/um/include/mem_user.h b/arch/um/include/shared/mem_user.h index 46384acd547..46384acd547 100644 --- a/arch/um/include/mem_user.h +++ b/arch/um/include/shared/mem_user.h diff --git a/arch/um/include/net_kern.h b/arch/um/include/shared/net_kern.h index d843c7924a7..d843c7924a7 100644 --- a/arch/um/include/net_kern.h +++ b/arch/um/include/shared/net_kern.h diff --git a/arch/um/include/net_user.h b/arch/um/include/shared/net_user.h index 63bee158cd8..63bee158cd8 100644 --- a/arch/um/include/net_user.h +++ b/arch/um/include/shared/net_user.h diff --git a/arch/um/include/os.h b/arch/um/include/shared/os.h index db5be46e3e1..cd40fddcf99 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/shared/os.h @@ -11,7 +11,6 @@ #include "longjmp.h" #include "mm_id.h" #include "sysdep/tls.h" -#include "../os/include/file.h" #define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) diff --git a/arch/um/include/process.h b/arch/um/include/shared/process.h index bb873a51262..bb873a51262 100644 --- a/arch/um/include/process.h +++ b/arch/um/include/shared/process.h diff --git a/arch/um/include/ptrace_user.h b/arch/um/include/shared/ptrace_user.h index 4bce6e01288..4bce6e01288 100644 --- a/arch/um/include/ptrace_user.h +++ b/arch/um/include/shared/ptrace_user.h diff --git a/arch/um/include/registers.h b/arch/um/include/shared/registers.h index b0b4589e0eb..b0b4589e0eb 100644 --- a/arch/um/include/registers.h +++ b/arch/um/include/shared/registers.h diff --git a/arch/um/include/sigio.h b/arch/um/include/shared/sigio.h index 434f1a9ae4b..434f1a9ae4b 100644 --- a/arch/um/include/sigio.h +++ b/arch/um/include/shared/sigio.h diff --git a/arch/um/include/skas/mm_id.h b/arch/um/include/shared/skas/mm_id.h index 48dd0989dda..48dd0989dda 100644 --- a/arch/um/include/skas/mm_id.h +++ b/arch/um/include/shared/skas/mm_id.h diff --git a/arch/um/include/skas/proc_mm.h b/arch/um/include/shared/skas/proc_mm.h index 90280920960..90280920960 100644 --- a/arch/um/include/skas/proc_mm.h +++ b/arch/um/include/shared/skas/proc_mm.h diff --git a/arch/um/include/skas/skas.h b/arch/um/include/shared/skas/skas.h index 64d2c744330..64d2c744330 100644 --- a/arch/um/include/skas/skas.h +++ b/arch/um/include/shared/skas/skas.h diff --git a/arch/um/include/skas/stub-data.h b/arch/um/include/shared/skas/stub-data.h index f6ed92c3727..f6ed92c3727 100644 --- a/arch/um/include/skas/stub-data.h +++ b/arch/um/include/shared/skas/stub-data.h diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/shared/skas_ptrace.h index 3d31bbacd01..3d31bbacd01 100644 --- a/arch/um/include/skas_ptrace.h +++ b/arch/um/include/shared/skas_ptrace.h diff --git a/arch/um/include/skas_ptregs.h b/arch/um/include/shared/skas_ptregs.h index 73db19e9c07..73db19e9c07 100644 --- a/arch/um/include/skas_ptregs.h +++ b/arch/um/include/shared/skas_ptregs.h diff --git a/arch/um/include/syscall.h b/arch/um/include/shared/syscall.h index dda1df901a0..dda1df901a0 100644 --- a/arch/um/include/syscall.h +++ b/arch/um/include/shared/syscall.h diff --git a/arch/um/include/sysrq.h b/arch/um/include/shared/sysrq.h index c8d332b56b9..c8d332b56b9 100644 --- a/arch/um/include/sysrq.h +++ b/arch/um/include/shared/sysrq.h diff --git a/arch/um/include/task.h b/arch/um/include/shared/task.h index 3fe726b3cf4..3fe726b3cf4 100644 --- a/arch/um/include/task.h +++ b/arch/um/include/shared/task.h diff --git a/arch/um/include/tlb.h b/arch/um/include/shared/tlb.h index ecd2265b301..ecd2265b301 100644 --- a/arch/um/include/tlb.h +++ b/arch/um/include/shared/tlb.h diff --git a/arch/um/include/ubd_user.h b/arch/um/include/shared/ubd_user.h index bb66517f073..bb66517f073 100644 --- a/arch/um/include/ubd_user.h +++ b/arch/um/include/shared/ubd_user.h diff --git a/arch/um/include/um_malloc.h b/arch/um/include/shared/um_malloc.h index c554d706d10..c554d706d10 100644 --- a/arch/um/include/um_malloc.h +++ b/arch/um/include/shared/um_malloc.h diff --git a/arch/um/include/um_mmu.h b/arch/um/include/shared/um_mmu.h index f575ff91f2a..b1a7e47d102 100644 --- a/arch/um/include/um_mmu.h +++ b/arch/um/include/shared/um_mmu.h @@ -6,9 +6,8 @@ #ifndef __ARCH_UM_MMU_H #define __ARCH_UM_MMU_H -#include "uml-config.h" #include "mm_id.h" -#include "asm/ldt.h" +#include "ldt.h" typedef struct mm_context { struct mm_id id; diff --git a/arch/um/include/um_uaccess.h b/arch/um/include/shared/um_uaccess.h index 45c04999d67..45c04999d67 100644 --- a/arch/um/include/um_uaccess.h +++ b/arch/um/include/shared/um_uaccess.h diff --git a/arch/um/include/user.h b/arch/um/include/shared/user.h index 1723fac6f40..293f7c794fa 100644 --- a/arch/um/include/user.h +++ b/arch/um/include/shared/user.h @@ -6,7 +6,7 @@ #ifndef __USER_H__ #define __USER_H__ -#include "uml-config.h" +#include "kern_constants.h" /* * The usual definition - copied here because the kernel provides its own, diff --git a/arch/um/include/sigcontext.h b/arch/um/include/sigcontext.h deleted file mode 100644 index 59816ca7a8d..00000000000 --- a/arch/um/include/sigcontext.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) - * Licensed under the GPL - */ - -#ifndef __UML_SIGCONTEXT_H__ -#define __UML_SIGCONTEXT_H__ - -#include "sysdep/sigcontext.h" - -extern int sc_size(void *data); -extern void sc_to_sc(void *to_ptr, void *from_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: - */ diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c index f5d7f4569ba..fda30d21fb9 100644 --- a/arch/um/kernel/exec.c +++ b/arch/um/kernel/exec.c @@ -15,6 +15,7 @@ #include "mem_user.h" #include "skas.h" #include "os.h" +#include "internal.h" void flush_thread(void) { @@ -42,23 +43,11 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) PT_REGS_SP(regs) = esp; } -#ifdef CONFIG_TTY_LOG -extern void log_exec(char **argv, void *tty); -#endif - static long execve1(char *file, char __user * __user *argv, char __user *__user *env) { long error; -#ifdef CONFIG_TTY_LOG - struct tty_struct *tty; - mutex_lock(&tty_mutex); - tty = get_current_tty(); - if (tty) - log_exec(argv, tty); - mutex_unlock(&tty_mutex); -#endif error = do_execve(file, argv, env, ¤t->thread.regs); if (error == 0) { task_lock(current); diff --git a/arch/um/kernel/internal.h b/arch/um/kernel/internal.h new file mode 100644 index 00000000000..3bda43c7a78 --- /dev/null +++ b/arch/um/kernel/internal.h @@ -0,0 +1 @@ +extern long um_execve(char *file, char __user *__user *argv, char __user *__user *env); diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c index b0fce720c4d..b5c094c4ade 100644 --- a/arch/um/kernel/signal.c +++ b/arch/um/kernel/signal.c @@ -11,7 +11,7 @@ #include <asm/unistd.h> #include "frame_kern.h" #include "kern_util.h" -#include "sigcontext.h" +#include <sysdep/sigcontext.h> EXPORT_SYMBOL(block_signals); EXPORT_SYMBOL(unblock_signals); diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c index be2d50c3aa9..04577214284 100644 --- a/arch/um/kernel/smp.c +++ b/arch/um/kernel/smp.c @@ -85,6 +85,7 @@ static int idle_proc(void *cpup) while (!cpu_isset(cpu, smp_commenced_mask)) cpu_relax(); + notify_cpu_starting(cpu); cpu_set(cpu, cpu_online_map); default_idle(); return 0; diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c index 128ee85bc8d..c4df705b835 100644 --- a/arch/um/kernel/syscall.c +++ b/arch/um/kernel/syscall.c @@ -12,6 +12,7 @@ #include "asm/mman.h" #include "asm/uaccess.h" #include "asm/unistd.h" +#include "internal.h" long sys_fork(void) { diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 8a48d6a3006..d66f0388f09 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -7,9 +7,6 @@ obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ registers.o sigio.o signal.o start_up.o time.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 registers.o sigio.o signal.o start_up.o time.o \ tty.o tls.o uaccess.o umid.o util.o diff --git a/arch/um/os-Linux/include/file.h b/arch/um/os-Linux/include/file.h deleted file mode 100644 index fe71be24bd5..00000000000 --- a/arch/um/os-Linux/include/file.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) - * Licensed under the GPL - */ - -#ifndef __OS_FILE_H__ -#define __OS_FILE_H__ - -#define DEV_NULL "/dev/null" - -#endif diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c index 484e68f9f7a..d261f170d12 100644 --- a/arch/um/os-Linux/skas/mem.c +++ b/arch/um/os-Linux/skas/mem.c @@ -20,7 +20,6 @@ #include "user.h" #include "sysdep/ptrace.h" #include "sysdep/stub.h" -#include "uml-config.h" extern unsigned long batch_syscall_stub, __syscall_stub_start; diff --git a/arch/um/os-Linux/tty_log.c b/arch/um/os-Linux/tty_log.c deleted file mode 100644 index cc648e6fd3a..00000000000 --- a/arch/um/os-Linux/tty_log.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) and - * geoffrey hing <ghing@net.ohio-state.edu> - * Licensed under the GPL - */ - -#include <errno.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/time.h> -#include "init.h" -#include "user.h" -#include "os.h" - -#define TTY_LOG_DIR "./" - -/* Set early in boot and then unchanged */ -static char *tty_log_dir = TTY_LOG_DIR; -static int tty_log_fd = -1; - -#define TTY_LOG_OPEN 1 -#define TTY_LOG_CLOSE 2 -#define TTY_LOG_WRITE 3 -#define TTY_LOG_EXEC 4 - -#define TTY_READ 1 -#define TTY_WRITE 2 - -struct tty_log_buf { - int what; - unsigned long tty; - int len; - int direction; - unsigned long sec; - unsigned long usec; -}; - -int open_tty_log(void *tty, void *current_tty) -{ - struct timeval tv; - struct tty_log_buf data; - char buf[strlen(tty_log_dir) + sizeof("01234567890-01234567\0")]; - int fd; - - gettimeofday(&tv, NULL); - if(tty_log_fd != -1){ - data = ((struct tty_log_buf) { .what = TTY_LOG_OPEN, - .tty = (unsigned long) tty, - .len = sizeof(current_tty), - .direction = 0, - .sec = tv.tv_sec, - .usec = tv.tv_usec } ); - write(tty_log_fd, &data, sizeof(data)); - write(tty_log_fd, ¤t_tty, data.len); - return tty_log_fd; - } - - sprintf(buf, "%s/%0u-%0u", tty_log_dir, (unsigned int) tv.tv_sec, - (unsigned int) tv.tv_usec); - - fd = os_open_file(buf, of_append(of_create(of_rdwr(OPENFLAGS()))), - 0644); - if(fd < 0){ - printk("open_tty_log : couldn't open '%s', errno = %d\n", - buf, -fd); - } - return fd; -} - -void close_tty_log(int fd, void *tty) -{ - struct tty_log_buf data; - struct timeval tv; - - if(tty_log_fd != -1){ - gettimeofday(&tv, NULL); - data = ((struct tty_log_buf) { .what = TTY_LOG_CLOSE, - .tty = (unsigned long) tty, - .len = 0, - .direction = 0, - .sec = tv.tv_sec, - .usec = tv.tv_usec } ); - write(tty_log_fd, &data, sizeof(data)); - return; - } - os_close_file(fd); -} - -static int log_chunk(int fd, const char *buf, int len) -{ - int total = 0, try, missed, n; - char chunk[64]; - - while(len > 0){ - try = (len > sizeof(chunk)) ? sizeof(chunk) : len; - missed = copy_from_user_proc(chunk, (char *) buf, try); - try -= missed; - n = write(fd, chunk, try); - if(n != try) { - if(n < 0) - return -errno; - return -EIO; - } - if(missed != 0) - return -EFAULT; - - len -= try; - total += try; - buf += try; - } - - return total; -} - -int write_tty_log(int fd, const char *buf, int len, void *tty, int is_read) -{ - struct timeval tv; - struct tty_log_buf data; - int direction; - - if(fd == tty_log_fd){ - gettimeofday(&tv, NULL); - direction = is_read ? TTY_READ : TTY_WRITE; - data = ((struct tty_log_buf) { .what = TTY_LOG_WRITE, - .tty = (unsigned long) tty, - .len = len, - .direction = direction, - .sec = tv.tv_sec, - .usec = tv.tv_usec } ); - write(tty_log_fd, &data, sizeof(data)); - } - - return log_chunk(fd, buf, len); -} - -void log_exec(char **argv, void *tty) -{ - struct timeval tv; - struct tty_log_buf data; - char **ptr,*arg; - int len; - - if(tty_log_fd == -1) return; - - gettimeofday(&tv, NULL); - - len = 0; - for(ptr = argv; ; ptr++){ - if(copy_from_user_proc(&arg, ptr, sizeof(arg))) - return; - if(arg == NULL) break; - len += strlen_user_proc(arg); - } - - data = ((struct tty_log_buf) { .what = TTY_LOG_EXEC, - .tty = (unsigned long) tty, - .len = len, - .direction = 0, - .sec = tv.tv_sec, - .usec = tv.tv_usec } ); - write(tty_log_fd, &data, sizeof(data)); - - for(ptr = argv; ; ptr++){ - if(copy_from_user_proc(&arg, ptr, sizeof(arg))) - return; - if(arg == NULL) break; - log_chunk(tty_log_fd, arg, strlen_user_proc(arg)); - } -} - -extern void register_tty_logger(int (*opener)(void *, void *), - int (*writer)(int, const char *, int, - void *, int), - void (*closer)(int, void *)); - -static int register_logger(void) -{ - register_tty_logger(open_tty_log, write_tty_log, close_tty_log); - return 0; -} - -__uml_initcall(register_logger); - -static int __init set_tty_log_dir(char *name, int *add) -{ - tty_log_dir = name; - return 0; -} - -__uml_setup("tty_log_dir=", set_tty_log_dir, -"tty_log_dir=<directory>\n" -" This is used to specify the directory where the logs of all pty\n" -" data from this UML machine will be written.\n\n" -); - -static int __init set_tty_log_fd(char *name, int *add) -{ - char *end; - - tty_log_fd = strtoul(name, &end, 0); - if((*end != '\0') || (end == name)){ - printf("set_tty_log_fd - strtoul failed on '%s'\n", name); - tty_log_fd = -1; - } - - *add = 0; - return 0; -} - -__uml_setup("tty_log_fd=", set_tty_log_fd, -"tty_log_fd=<fd>\n" -" This is used to specify a preconfigured file descriptor to which all\n" -" tty data will be written. Preconfigure the descriptor with something\n" -" like '10>tty_log tty_log_fd=10'.\n\n" -); diff --git a/arch/um/sys-i386/asm/archparam.h b/arch/um/sys-i386/asm/archparam.h new file mode 100644 index 00000000000..93fd723344e --- /dev/null +++ b/arch/um/sys-i386/asm/archparam.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) + * Licensed under the GPL + */ + +#ifndef __UM_ARCHPARAM_I386_H +#define __UM_ARCHPARAM_I386_H + +#ifdef CONFIG_X86_PAE +#define LAST_PKMAP 512 +#else +#define LAST_PKMAP 1024 +#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/sys-i386/asm/elf.h b/arch/um/sys-i386/asm/elf.h new file mode 100644 index 00000000000..d0da9d7c537 --- /dev/null +++ b/arch/um/sys-i386/asm/elf.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ +#ifndef __UM_ELF_I386_H +#define __UM_ELF_I386_H + +#include <asm/user.h> +#include "skas.h" + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +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 user_i387_struct elf_fpregset_t; + +/* + * This is used to ensure we don't load something for the wrong architecture. + */ +#define elf_check_arch(x) \ + (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) + +#define ELF_CLASS ELFCLASS32 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_386 + +#define ELF_PLAT_INIT(regs, load_addr) do { \ + PT_REGS_EBX(regs) = 0; \ + PT_REGS_ECX(regs) = 0; \ + PT_REGS_EDX(regs) = 0; \ + PT_REGS_ESI(regs) = 0; \ + PT_REGS_EDI(regs) = 0; \ + PT_REGS_EBP(regs) = 0; \ + PT_REGS_EAX(regs) = 0; \ +} while (0) + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) + +/* Shamelessly stolen from include/asm-i386/elf.h */ + +#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ + pr_reg[0] = PT_REGS_EBX(regs); \ + pr_reg[1] = PT_REGS_ECX(regs); \ + pr_reg[2] = PT_REGS_EDX(regs); \ + pr_reg[3] = PT_REGS_ESI(regs); \ + pr_reg[4] = PT_REGS_EDI(regs); \ + pr_reg[5] = PT_REGS_EBP(regs); \ + pr_reg[6] = PT_REGS_EAX(regs); \ + pr_reg[7] = PT_REGS_DS(regs); \ + pr_reg[8] = PT_REGS_ES(regs); \ + /* fake once used fs and gs selectors? */ \ + pr_reg[9] = PT_REGS_DS(regs); \ + pr_reg[10] = PT_REGS_DS(regs); \ + pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \ + pr_reg[12] = PT_REGS_IP(regs); \ + pr_reg[13] = PT_REGS_CS(regs); \ + pr_reg[14] = PT_REGS_EFLAGS(regs); \ + pr_reg[15] = PT_REGS_SP(regs); \ + pr_reg[16] = PT_REGS_SS(regs); \ +} while (0); + +extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *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) + +extern char * elf_aux_platform; +#define ELF_PLATFORM (elf_aux_platform) + +#define SET_PERSONALITY(ex) do { } while (0) + +extern unsigned long vsyscall_ehdr; +extern unsigned long vsyscall_end; +extern unsigned long __kernel_vsyscall; + +#define VSYSCALL_BASE vsyscall_ehdr +#define VSYSCALL_END vsyscall_end + +/* + * This is the range that is readable by user mode, and things + * acting like user mode such as get_user_pages. + */ +#define FIXADDR_USER_START VSYSCALL_BASE +#define FIXADDR_USER_END VSYSCALL_END + +/* + * Architecture-neutral AT_ values in 0-17, leave some room + * for more of them, start the x86-specific ones at 32. + */ +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + +#define ARCH_DLINFO \ +do { \ + if ( vsyscall_ehdr ) { \ + NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \ + } \ +} while (0) + +/* + * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out + * extra segments containing the vsyscall DSO contents. Dumping its + * contents makes post-mortem fully interpretable later without matching up + * the same kernel and hardware config to see what PC values meant. + * Dumping its extra ELF program headers includes all the other information + * a debugger needs to easily find how the vsyscall DSO was being used. + */ +#define ELF_CORE_EXTRA_PHDRS \ + (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 ) + +#define ELF_CORE_WRITE_EXTRA_PHDRS \ +if ( vsyscall_ehdr ) { \ + const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \ + const struct elf_phdr *const phdrp = \ + (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \ + int i; \ + Elf32_Off ofs = 0; \ + for (i = 0; i < ehdrp->e_phnum; ++i) { \ + struct elf_phdr phdr = phdrp[i]; \ + if (phdr.p_type == PT_LOAD) { \ + ofs = phdr.p_offset = offset; \ + offset += phdr.p_filesz; \ + } \ + else \ + phdr.p_offset += ofs; \ + phdr.p_paddr = 0; /* match other core phdrs */ \ + DUMP_WRITE(&phdr, sizeof(phdr)); \ + } \ +} +#define ELF_CORE_WRITE_EXTRA_DATA \ +if ( vsyscall_ehdr ) { \ + const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \ + const struct elf_phdr *const phdrp = \ + (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \ + int i; \ + for (i = 0; i < ehdrp->e_phnum; ++i) { \ + if (phdrp[i].p_type == PT_LOAD) \ + DUMP_WRITE((void *) phdrp[i].p_vaddr, \ + phdrp[i].p_filesz); \ + } \ +} + +#endif diff --git a/arch/um/sys-i386/asm/module.h b/arch/um/sys-i386/asm/module.h new file mode 100644 index 00000000000..5ead4a0b2e3 --- /dev/null +++ b/arch/um/sys-i386/asm/module.h @@ -0,0 +1,13 @@ +#ifndef __UM_MODULE_I386_H +#define __UM_MODULE_I386_H + +/* UML is simple */ +struct mod_arch_specific +{ +}; + +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Ehdr Elf32_Ehdr + +#endif diff --git a/arch/um/sys-i386/asm/processor.h b/arch/um/sys-i386/asm/processor.h new file mode 100644 index 00000000000..82a9061ab5b --- /dev/null +++ b/arch/um/sys-i386/asm/processor.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UM_PROCESSOR_I386_H +#define __UM_PROCESSOR_I386_H + +#include "linux/string.h" +#include <sysdep/host_ldt.h> +#include "asm/segment.h" + +extern int host_has_cmov; + +/* include faultinfo structure */ +#include "sysdep/faultinfo.h" + +struct uml_tls_struct { + struct user_desc tls; + unsigned flushed:1; + unsigned present:1; +}; + +struct arch_thread { + struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES]; + unsigned long debugregs[8]; + int debugregs_seq; + struct faultinfo faultinfo; +}; + +#define INIT_ARCH_THREAD { \ + .tls_array = { [ 0 ... GDT_ENTRY_TLS_ENTRIES - 1 ] = \ + { .present = 0, .flushed = 0 } }, \ + .debugregs = { [ 0 ... 7 ] = 0 }, \ + .debugregs_seq = 0, \ + .faultinfo = { 0, 0, 0 } \ +} + +static inline void arch_flush_thread(struct arch_thread *thread) +{ + /* Clear any TLS still hanging */ + memset(&thread->tls_array, 0, sizeof(thread->tls_array)); +} + +static inline void arch_copy_thread(struct arch_thread *from, + struct arch_thread *to) +{ + memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array)); +} + +#include <asm/user.h> + +/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ +static inline void rep_nop(void) +{ + __asm__ __volatile__("rep;nop": : :"memory"); +} + +#define cpu_relax() rep_nop() + +/* + * Default implementation of macro that returns current + * instruction pointer ("program counter"). Stolen + * from asm-i386/processor.h + */ +#define current_text_addr() \ + ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; }) + +#define ARCH_IS_STACKGROW(address) \ + (address + 32 >= UPT_SP(¤t->thread.regs.regs)) + +#define KSTK_EIP(tsk) KSTK_REG(tsk, EIP) +#define KSTK_ESP(tsk) KSTK_REG(tsk, UESP) +#define KSTK_EBP(tsk) KSTK_REG(tsk, EBP) + +#include "asm/processor-generic.h" + +#endif diff --git a/arch/um/sys-i386/asm/ptrace.h b/arch/um/sys-i386/asm/ptrace.h new file mode 100644 index 00000000000..0273e4d09af --- /dev/null +++ b/arch/um/sys-i386/asm/ptrace.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Licensed under the GPL + */ + +#ifndef __UM_PTRACE_I386_H +#define __UM_PTRACE_I386_H + +#define HOST_AUDIT_ARCH AUDIT_ARCH_I386 + +#include "linux/compiler.h" +#include "asm/ptrace-generic.h" + +#define PT_REGS_EAX(r) UPT_EAX(&(r)->regs) +#define PT_REGS_EBX(r) UPT_EBX(&(r)->regs) +#define PT_REGS_ECX(r) UPT_ECX(&(r)->regs) +#define PT_REGS_EDX(r) UPT_EDX(&(r)->regs) +#define PT_REGS_ESI(r) UPT_ESI(&(r)->regs) +#define PT_REGS_EDI(r) UPT_EDI(&(r)->regs) +#define PT_REGS_EBP(r) UPT_EBP(&(r)->regs) + +#define PT_REGS_CS(r) UPT_CS(&(r)->regs) +#define PT_REGS_SS(r) UPT_SS(&(r)->regs) +#define PT_REGS_DS(r) UPT_DS(&(r)->regs) +#define PT_REGS_ES(r) UPT_ES(&(r)->regs) +#define PT_REGS_FS(r) UPT_FS(&(r)->regs) +#define PT_REGS_GS(r) UPT_GS(&(r)->regs) + +#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs) + +#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_EAX(r) +#define PT_REGS_SYSCALL_RET(r) PT_REGS_EAX(r) +#define PT_FIX_EXEC_STACK(sp) do ; while(0) + +#define profile_pc(regs) PT_REGS_IP(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); + +#endif diff --git a/arch/um/include/sysdep-i386/archsetjmp.h b/arch/um/sys-i386/shared/sysdep/archsetjmp.h index 0f312085ce1..0f312085ce1 100644 --- a/arch/um/include/sysdep-i386/archsetjmp.h +++ b/arch/um/sys-i386/shared/sysdep/archsetjmp.h diff --git a/arch/um/include/sysdep-i386/barrier.h b/arch/um/sys-i386/shared/sysdep/barrier.h index b58d52c5b2f..b58d52c5b2f 100644 --- a/arch/um/include/sysdep-i386/barrier.h +++ b/arch/um/sys-i386/shared/sysdep/barrier.h diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/sys-i386/shared/sysdep/checksum.h index 0cb4645cbeb..0cb4645cbeb 100644 --- a/arch/um/include/sysdep-i386/checksum.h +++ b/arch/um/sys-i386/shared/sysdep/checksum.h diff --git a/arch/um/include/sysdep-i386/faultinfo.h b/arch/um/sys-i386/shared/sysdep/faultinfo.h index db437cc373b..db437cc373b 100644 --- a/arch/um/include/sysdep-i386/faultinfo.h +++ b/arch/um/sys-i386/shared/sysdep/faultinfo.h diff --git a/arch/um/sys-i386/shared/sysdep/host_ldt.h b/arch/um/sys-i386/shared/sysdep/host_ldt.h new file mode 100644 index 00000000000..0953cc4df65 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/host_ldt.h @@ -0,0 +1,34 @@ +#ifndef __ASM_HOST_LDT_I386_H +#define __ASM_HOST_LDT_I386_H + +#include <asm/ldt.h> + +/* + * macros stolen from include/asm-i386/desc.h + */ +#define LDT_entry_a(info) \ + ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) + +#define LDT_entry_b(info) \ + (((info)->base_addr & 0xff000000) | \ + (((info)->base_addr & 0x00ff0000) >> 16) | \ + ((info)->limit & 0xf0000) | \ + (((info)->read_exec_only ^ 1) << 9) | \ + ((info)->contents << 10) | \ + (((info)->seg_not_present ^ 1) << 15) | \ + ((info)->seg_32bit << 22) | \ + ((info)->limit_in_pages << 23) | \ + ((info)->useable << 20) | \ + 0x7000) + +#define LDT_empty(info) (\ + (info)->base_addr == 0 && \ + (info)->limit == 0 && \ + (info)->contents == 0 && \ + (info)->read_exec_only == 1 && \ + (info)->seg_32bit == 0 && \ + (info)->limit_in_pages == 0 && \ + (info)->seg_not_present == 1 && \ + (info)->useable == 0 ) + +#endif diff --git a/arch/um/include/sysdep-i386/kernel-offsets.h b/arch/um/sys-i386/shared/sysdep/kernel-offsets.h index 5868526b5ee..5868526b5ee 100644 --- a/arch/um/include/sysdep-i386/kernel-offsets.h +++ b/arch/um/sys-i386/shared/sysdep/kernel-offsets.h diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/sys-i386/shared/sysdep/ptrace.h index 11c08969d13..d50e62e0707 100644 --- a/arch/um/include/sysdep-i386/ptrace.h +++ b/arch/um/sys-i386/shared/sysdep/ptrace.h @@ -6,7 +6,6 @@ #ifndef __SYSDEP_I386_PTRACE_H #define __SYSDEP_I386_PTRACE_H -#include "uml-config.h" #include "user_constants.h" #include "sysdep/faultinfo.h" diff --git a/arch/um/include/sysdep-i386/ptrace_user.h b/arch/um/sys-i386/shared/sysdep/ptrace_user.h index ef56247e414..ef56247e414 100644 --- a/arch/um/include/sysdep-i386/ptrace_user.h +++ b/arch/um/sys-i386/shared/sysdep/ptrace_user.h diff --git a/arch/um/include/sysdep-i386/sc.h b/arch/um/sys-i386/shared/sysdep/sc.h index c57d1780ad3..c57d1780ad3 100644 --- a/arch/um/include/sysdep-i386/sc.h +++ b/arch/um/sys-i386/shared/sysdep/sc.h diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/sys-i386/shared/sysdep/sigcontext.h index f583c87111a..f583c87111a 100644 --- a/arch/um/include/sysdep-i386/sigcontext.h +++ b/arch/um/sys-i386/shared/sysdep/sigcontext.h diff --git a/arch/um/include/sysdep-i386/skas_ptrace.h b/arch/um/sys-i386/shared/sysdep/skas_ptrace.h index e27b8a79177..e27b8a79177 100644 --- a/arch/um/include/sysdep-i386/skas_ptrace.h +++ b/arch/um/sys-i386/shared/sysdep/skas_ptrace.h diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/sys-i386/shared/sysdep/stub.h index 8c097b87fca..977dedd9221 100644 --- a/arch/um/include/sysdep-i386/stub.h +++ b/arch/um/sys-i386/shared/sysdep/stub.h @@ -12,7 +12,6 @@ #include "as-layout.h" #include "stub-data.h" #include "kern_constants.h" -#include "uml-config.h" extern void stub_segv_handler(int sig); extern void stub_clone_handler(void); diff --git a/arch/um/include/sysdep-i386/syscalls.h b/arch/um/sys-i386/shared/sysdep/syscalls.h index 905698197e3..905698197e3 100644 --- a/arch/um/include/sysdep-i386/syscalls.h +++ b/arch/um/sys-i386/shared/sysdep/syscalls.h diff --git a/arch/um/sys-i386/shared/sysdep/system.h b/arch/um/sys-i386/shared/sysdep/system.h new file mode 100644 index 00000000000..d1b93c43620 --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/system.h @@ -0,0 +1,132 @@ +#ifndef _ASM_X86_SYSTEM_H_ +#define _ASM_X86_SYSTEM_H_ + +#include <asm/asm.h> +#include <asm/segment.h> +#include <asm/cpufeature.h> +#include <asm/cmpxchg.h> +#include <asm/nops.h> + +#include <linux/kernel.h> +#include <linux/irqflags.h> + +/* entries in ARCH_DLINFO: */ +#ifdef CONFIG_IA32_EMULATION +# define AT_VECTOR_SIZE_ARCH 2 +#else +# define AT_VECTOR_SIZE_ARCH 1 +#endif + +extern unsigned long arch_align_stack(unsigned long sp); + +void default_idle(void); + +/* + * Force strict CPU ordering. + * And yes, this is required on UP too when we're talking + * to devices. + */ +#ifdef CONFIG_X86_32 +/* + * Some non-Intel clones support out of order store. wmb() ceases to be a + * nop for these. + */ +#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) +#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) +#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) +#else +#define mb() asm volatile("mfence":::"memory") +#define rmb() asm volatile("lfence":::"memory") +#define wmb() asm volatile("sfence" ::: "memory") +#endif + +/** + * read_barrier_depends - Flush all pending reads that subsequents reads + * depend on. + * + * No data-dependent reads from memory-like regions are ever reordered + * over this barrier. All reads preceding this primitive are guaranteed + * to access memory (but not necessarily other CPUs' caches) before any + * reads following this primitive that depend on the data return by + * any of the preceding reads. This primitive is much lighter weight than + * rmb() on most CPUs, and is never heavier weight than is + * rmb(). + * + * These ordering constraints are respected by both the local CPU + * and the compiler. + * + * Ordering is not guaranteed by anything other than these primitives, + * not even by data dependencies. See the documentation for + * memory_barrier() for examples and URLs to more information. + * + * For example, the following code would force ordering (the initial + * value of "a" is zero, "b" is one, and "p" is "&a"): + * + * <programlisting> + * CPU 0 CPU 1 + * + * b = 2; + * memory_barrier(); + * p = &b; q = p; + * read_barrier_depends(); + * d = *q; + * </programlisting> + * + * because the read of "*q" depends on the read of "p" and these + * two reads are separated by a read_barrier_depends(). However, + * the following code, with the same initial values for "a" and "b": + * + * <programlisting> + * CPU 0 CPU 1 + * + * a = 2; + * memory_barrier(); + * b = 3; y = b; + * read_barrier_depends(); + * x = a; + * </programlisting> + * + * does not enforce ordering, since there is no data dependency between + * the read of "a" and the read of "b". Therefore, on some CPUs, such + * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() + * in cases like this where there are no data dependencies. + **/ + +#define read_barrier_depends() do { } while (0) + +#ifdef CONFIG_SMP +#define smp_mb() mb() +#ifdef CONFIG_X86_PPRO_FENCE +# define smp_rmb() rmb() +#else +# define smp_rmb() barrier() +#endif +#ifdef CONFIG_X86_OOSTORE +# define smp_wmb() wmb() +#else +# define smp_wmb() barrier() +#endif +#define smp_read_barrier_depends() read_barrier_depends() +#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) +#else +#define smp_mb() barrier() +#define smp_rmb() barrier() +#define smp_wmb() barrier() +#define smp_read_barrier_depends() do { } while (0) +#define set_mb(var, value) do { var = value; barrier(); } while (0) +#endif + +/* + * Stop RDTSC speculation. This is needed when you need to use RDTSC + * (or get_cycles or vread that possibly accesses the TSC) in a defined + * code region. + * + * (Could use an alternative three way for this if there was one.) + */ +static inline void rdtsc_barrier(void) +{ + alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC); + alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); +} + +#endif diff --git a/arch/um/include/sysdep-i386/tls.h b/arch/um/sys-i386/shared/sysdep/tls.h index 918fd3c5ff9..34550755b2a 100644 --- a/arch/um/include/sysdep-i386/tls.h +++ b/arch/um/sys-i386/shared/sysdep/tls.h @@ -21,7 +21,7 @@ typedef struct um_dup_user_desc { # else /* __KERNEL__ */ -# include <asm/ldt.h> +# include <ldt.h> typedef struct user_desc user_desc_t; # endif /* __KERNEL__ */ diff --git a/arch/um/sys-i386/shared/sysdep/vm-flags.h b/arch/um/sys-i386/shared/sysdep/vm-flags.h new file mode 100644 index 00000000000..e0d24c568db --- /dev/null +++ b/arch/um/sys-i386/shared/sysdep/vm-flags.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Licensed under the GPL + */ + +#ifndef __VM_FLAGS_I386_H +#define __VM_FLAGS_I386_H + +#define VM_DATA_DEFAULT_FLAGS \ + (VM_READ | VM_WRITE | \ + ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) + +#endif diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c index fd0c25ad6af..129647375a6 100644 --- a/arch/um/sys-i386/signal.c +++ b/arch/um/sys-i386/signal.c @@ -179,7 +179,8 @@ static int copy_sc_from_user(struct pt_regs *regs, if (have_fpx_regs) { struct user_fxsr_struct fpx; - err = copy_from_user(&fpx, &sc.fpstate->_fxsr_env[0], + err = copy_from_user(&fpx, + &((struct _fpstate __user *)sc.fpstate)->_fxsr_env[0], sizeof(struct user_fxsr_struct)); if (err) return 1; diff --git a/arch/um/sys-i386/stub.S b/arch/um/sys-i386/stub.S index 7699e89f660..c41b04bf5fa 100644 --- a/arch/um/sys-i386/stub.S +++ b/arch/um/sys-i386/stub.S @@ -1,4 +1,3 @@ -#include "uml-config.h" #include "as-layout.h" .globl syscall_stub diff --git a/arch/um/sys-i386/syscalls.c b/arch/um/sys-i386/syscalls.c index e2d14268441..857ca0b3bde 100644 --- a/arch/um/sys-i386/syscalls.c +++ b/arch/um/sys-i386/syscalls.c @@ -6,6 +6,7 @@ #include "linux/sched.h" #include "linux/shm.h" #include "linux/ipc.h" +#include "linux/syscalls.h" #include "asm/mman.h" #include "asm/uaccess.h" #include "asm/unistd.h" diff --git a/arch/um/include/sysdep-ia64/ptrace.h b/arch/um/sys-ia64/sysdep/ptrace.h index 42dd8fb6f2f..42dd8fb6f2f 100644 --- a/arch/um/include/sysdep-ia64/ptrace.h +++ b/arch/um/sys-ia64/sysdep/ptrace.h diff --git a/arch/um/include/sysdep-ia64/sigcontext.h b/arch/um/sys-ia64/sysdep/sigcontext.h index f15fb25260b..f15fb25260b 100644 --- a/arch/um/include/sysdep-ia64/sigcontext.h +++ b/arch/um/sys-ia64/sysdep/sigcontext.h diff --git a/arch/um/include/sysdep-ia64/skas_ptrace.h b/arch/um/sys-ia64/sysdep/skas_ptrace.h index 25a38e71570..25a38e71570 100644 --- a/arch/um/include/sysdep-ia64/skas_ptrace.h +++ b/arch/um/sys-ia64/sysdep/skas_ptrace.h diff --git a/arch/um/include/sysdep-ia64/syscalls.h b/arch/um/sys-ia64/sysdep/syscalls.h index 4a1f46ef1eb..4a1f46ef1eb 100644 --- a/arch/um/include/sysdep-ia64/syscalls.h +++ b/arch/um/sys-ia64/sysdep/syscalls.h diff --git a/arch/um/sys-ppc/asm/archparam.h b/arch/um/sys-ppc/asm/archparam.h new file mode 100644 index 00000000000..4269d8a37b4 --- /dev/null +++ b/arch/um/sys-ppc/asm/archparam.h @@ -0,0 +1,8 @@ +#ifndef __UM_ARCHPARAM_PPC_H +#define __UM_ARCHPARAM_PPC_H + +/********* Bits for asm-um/string.h **********/ + +#define __HAVE_ARCH_STRRCHR + +#endif diff --git a/arch/um/sys-ppc/asm/elf.h b/arch/um/sys-ppc/asm/elf.h new file mode 100644 index 00000000000..af9463cd8ce --- /dev/null +++ b/arch/um/sys-ppc/asm/elf.h @@ -0,0 +1,53 @@ +#ifndef __UM_ELF_PPC_H +#define __UM_ELF_PPC_H + + +extern long elf_aux_hwcap; +#define ELF_HWCAP (elf_aux_hwcap) + +#define SET_PERSONALITY(ex) do ; while(0) + +#define ELF_EXEC_PAGESIZE 4096 + +#define elf_check_arch(x) (1) + +#ifdef CONFIG_64BIT +#define ELF_CLASS ELFCLASS64 +#else +#define ELF_CLASS ELFCLASS32 +#endif + +#define USE_ELF_CORE_DUMP + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +#define ELF_PLATFORM (0) + +#define ELF_ET_DYN_BASE (0x08000000) + +/* the following stolen from asm-ppc/elf.h */ +#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */ +#define ELF_NFPREG 33 /* includes fpscr */ +/* General registers */ +typedef unsigned long elf_greg_t; +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + +/* Floating point registers */ +typedef double elf_fpreg_t; +typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; + +#define ELF_DATA ELFDATA2MSB +#define ELF_ARCH EM_PPC + +#endif diff --git a/arch/um/sys-ppc/asm/processor.h b/arch/um/sys-ppc/asm/processor.h new file mode 100644 index 00000000000..95932315122 --- /dev/null +++ b/arch/um/sys-ppc/asm/processor.h @@ -0,0 +1,15 @@ +#ifndef __UM_PROCESSOR_PPC_H +#define __UM_PROCESSOR_PPC_H + +#if defined(__ASSEMBLY__) + +#define CONFIG_PPC_MULTIPLATFORM +#include "arch/processor.h" + +#else + +#include "asm/processor-generic.h" + +#endif + +#endif diff --git a/arch/um/include/sysdep-ppc/ptrace.h b/arch/um/sys-ppc/shared/sysdep/ptrace.h index df2397dba3e..df2397dba3e 100644 --- a/arch/um/include/sysdep-ppc/ptrace.h +++ b/arch/um/sys-ppc/shared/sysdep/ptrace.h diff --git a/arch/um/include/sysdep-ppc/sigcontext.h b/arch/um/sys-ppc/shared/sysdep/sigcontext.h index f20d965de9c..f20d965de9c 100644 --- a/arch/um/include/sysdep-ppc/sigcontext.h +++ b/arch/um/sys-ppc/shared/sysdep/sigcontext.h diff --git a/arch/um/include/sysdep-ppc/skas_ptrace.h b/arch/um/sys-ppc/shared/sysdep/skas_ptrace.h index d9fbbac10de..d9fbbac10de 100644 --- a/arch/um/include/sysdep-ppc/skas_ptrace.h +++ b/arch/um/sys-ppc/shared/sysdep/skas_ptrace.h diff --git a/arch/um/include/sysdep-ppc/syscalls.h b/arch/um/sys-ppc/shared/sysdep/syscalls.h index 679df351e19..679df351e19 100644 --- a/arch/um/include/sysdep-ppc/syscalls.h +++ b/arch/um/sys-ppc/shared/sysdep/syscalls.h diff --git a/arch/um/sys-x86_64/asm/archparam.h b/arch/um/sys-x86_64/asm/archparam.h new file mode 100644 index 00000000000..270ed9586b6 --- /dev/null +++ b/arch/um/sys-x86_64/asm/archparam.h @@ -0,0 +1,26 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#ifndef __UM_ARCHPARAM_X86_64_H +#define __UM_ARCHPARAM_X86_64_H + + +/* No user-accessible fixmap addresses, i.e. vsyscall */ +#define FIXADDR_USER_START 0 +#define FIXADDR_USER_END 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/arch/um/sys-x86_64/asm/elf.h b/arch/um/sys-x86_64/asm/elf.h new file mode 100644 index 00000000000..6e8a9195e95 --- /dev/null +++ b/arch/um/sys-x86_64/asm/elf.h @@ -0,0 +1,119 @@ +/* + * Copyright 2003 PathScale, Inc. + * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * + * Licensed under the GPL + */ +#ifndef __UM_ELF_X86_64_H +#define __UM_ELF_X86_64_H + +#include <asm/user.h> +#include "skas.h" + +/* x86-64 relocation types, taken from asm-x86_64/elf.h */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative + offset to GOT */ +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ + +#define R_X86_64_NUM 16 + +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 user_i387_struct elf_fpregset_t; + +/* + * This is used to ensure we don't load something for the wrong architecture. + */ +#define elf_check_arch(x) \ + ((x)->e_machine == EM_X86_64) + +#define ELF_CLASS ELFCLASS64 +#define ELF_DATA ELFDATA2LSB +#define ELF_ARCH EM_X86_64 + +#define ELF_PLAT_INIT(regs, load_addr) do { \ + PT_REGS_RBX(regs) = 0; \ + PT_REGS_RCX(regs) = 0; \ + PT_REGS_RDX(regs) = 0; \ + PT_REGS_RSI(regs) = 0; \ + PT_REGS_RDI(regs) = 0; \ + PT_REGS_RBP(regs) = 0; \ + PT_REGS_RAX(regs) = 0; \ + PT_REGS_R8(regs) = 0; \ + PT_REGS_R9(regs) = 0; \ + PT_REGS_R10(regs) = 0; \ + PT_REGS_R11(regs) = 0; \ + PT_REGS_R12(regs) = 0; \ + PT_REGS_R13(regs) = 0; \ + PT_REGS_R14(regs) = 0; \ + PT_REGS_R15(regs) = 0; \ +} while (0) + +#define ELF_CORE_COPY_REGS(pr_reg, regs) \ + (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; \ + (pr_reg)[24] = 0; \ + (pr_reg)[25] = 0; \ + (pr_reg)[26] = 0; + +extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu); + +#define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu) + +#ifdef TIF_IA32 /* XXX */ +#error XXX, indeed + clear_thread_flag(TIF_IA32); +#endif + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) + +extern long elf_aux_hwcap; +#define ELF_HWCAP (elf_aux_hwcap) + +#define ELF_PLATFORM "x86_64" + +#define SET_PERSONALITY(ex) do ; while(0) + +#endif diff --git a/arch/um/sys-x86_64/asm/module.h b/arch/um/sys-x86_64/asm/module.h new file mode 100644 index 00000000000..35b5491d3e9 --- /dev/null +++ b/arch/um/sys-x86_64/asm/module.h @@ -0,0 +1,30 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#ifndef __UM_MODULE_X86_64_H +#define __UM_MODULE_X86_64_H + +/* UML is simple */ +struct mod_arch_specific +{ +}; + +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Ehdr Elf64_Ehdr + +#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/sys-x86_64/asm/processor.h b/arch/um/sys-x86_64/asm/processor.h new file mode 100644 index 00000000000..875a26a6261 --- /dev/null +++ b/arch/um/sys-x86_64/asm/processor.h @@ -0,0 +1,56 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#ifndef __UM_PROCESSOR_X86_64_H +#define __UM_PROCESSOR_X86_64_H + +/* include faultinfo structure */ +#include "sysdep/faultinfo.h" + +struct arch_thread { + unsigned long debugregs[8]; + int debugregs_seq; + unsigned long fs; + struct faultinfo faultinfo; +}; + +/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ +static inline void rep_nop(void) +{ + __asm__ __volatile__("rep;nop": : :"memory"); +} + +#define cpu_relax() rep_nop() + +#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \ + .debugregs_seq = 0, \ + .fs = 0, \ + .faultinfo = { 0, 0, 0 } } + +static inline void arch_flush_thread(struct arch_thread *thread) +{ +} + +static inline void arch_copy_thread(struct arch_thread *from, + struct arch_thread *to) +{ + to->fs = from->fs; +} + +#include <asm/user.h> + +#define current_text_addr() \ + ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; }) + +#define ARCH_IS_STACKGROW(address) \ + (address + 128 >= UPT_SP(¤t->thread.regs.regs)) + +#define KSTK_EIP(tsk) KSTK_REG(tsk, RIP) +#define KSTK_ESP(tsk) KSTK_REG(tsk, RSP) + +#include "asm/processor-generic.h" + +#endif diff --git a/arch/um/sys-x86_64/asm/ptrace.h b/arch/um/sys-x86_64/asm/ptrace.h new file mode 100644 index 00000000000..83d8c473b90 --- /dev/null +++ b/arch/um/sys-x86_64/asm/ptrace.h @@ -0,0 +1,72 @@ +/* + * Copyright 2003 PathScale, Inc. + * + * Licensed under the GPL + */ + +#ifndef __UM_PTRACE_X86_64_H +#define __UM_PTRACE_X86_64_H + +#include "linux/compiler.h" +#include "asm/errno.h" + +#define __FRAME_OFFSETS /* Needed to get the R* macros */ +#include "asm/ptrace-generic.h" + +#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64 + +#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs) +#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs) +#define PT_REGS_RDX(r) UPT_RDX(&(r)->regs) +#define PT_REGS_RSI(r) UPT_RSI(&(r)->regs) +#define PT_REGS_RDI(r) UPT_RDI(&(r)->regs) +#define PT_REGS_RBP(r) UPT_RBP(&(r)->regs) +#define PT_REGS_RAX(r) UPT_RAX(&(r)->regs) +#define PT_REGS_R8(r) UPT_R8(&(r)->regs) +#define PT_REGS_R9(r) UPT_R9(&(r)->regs) +#define PT_REGS_R10(r) UPT_R10(&(r)->regs) +#define PT_REGS_R11(r) UPT_R11(&(r)->regs) +#define PT_REGS_R12(r) UPT_R12(&(r)->regs) +#define PT_REGS_R13(r) UPT_R13(&(r)->regs) +#define PT_REGS_R14(r) UPT_R14(&(r)->regs) +#define PT_REGS_R15(r) UPT_R15(&(r)->regs) + +#define PT_REGS_FS(r) UPT_FS(&(r)->regs) +#define PT_REGS_GS(r) UPT_GS(&(r)->regs) +#define PT_REGS_DS(r) UPT_DS(&(r)->regs) +#define PT_REGS_ES(r) UPT_ES(&(r)->regs) +#define PT_REGS_SS(r) UPT_SS(&(r)->regs) +#define PT_REGS_CS(r) UPT_CS(&(r)->regs) + +#define PT_REGS_ORIG_RAX(r) UPT_ORIG_RAX(&(r)->regs) +#define PT_REGS_RIP(r) UPT_IP(&(r)->regs) +#define PT_REGS_RSP(r) UPT_SP(&(r)->regs) + +#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs) + +/* XXX */ +#define user_mode(r) UPT_IS_USER(&(r)->regs) +#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_RAX(r) +#define PT_REGS_SYSCALL_RET(r) PT_REGS_RAX(r) + +#define PT_FIX_EXEC_STACK(sp) do ; while(0) + +#define profile_pc(regs) PT_REGS_IP(regs) + +struct user_desc; + +static inline int ptrace_get_thread_area(struct task_struct *child, int idx, + struct user_desc __user *user_desc) +{ + return -ENOSYS; +} + +static inline int ptrace_set_thread_area(struct task_struct *child, int idx, + struct user_desc __user *user_desc) +{ + return -ENOSYS; +} + +extern long arch_prctl(struct task_struct *task, int code, + unsigned long __user *addr); +#endif diff --git a/arch/um/include/sysdep-x86_64/archsetjmp.h b/arch/um/sys-x86_64/shared/sysdep/archsetjmp.h index 2af8f12ca16..2af8f12ca16 100644 --- a/arch/um/include/sysdep-x86_64/archsetjmp.h +++ b/arch/um/sys-x86_64/shared/sysdep/archsetjmp.h diff --git a/arch/um/include/sysdep-x86_64/barrier.h b/arch/um/sys-x86_64/shared/sysdep/barrier.h index 7b610befdc8..7b610befdc8 100644 --- a/arch/um/include/sysdep-x86_64/barrier.h +++ b/arch/um/sys-x86_64/shared/sysdep/barrier.h diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/sys-x86_64/shared/sysdep/checksum.h index a5be9031ea8..a5be9031ea8 100644 --- a/arch/um/include/sysdep-x86_64/checksum.h +++ b/arch/um/sys-x86_64/shared/sysdep/checksum.h diff --git a/arch/um/include/sysdep-x86_64/faultinfo.h b/arch/um/sys-x86_64/shared/sysdep/faultinfo.h index cb917b0d566..cb917b0d566 100644 --- a/arch/um/include/sysdep-x86_64/faultinfo.h +++ b/arch/um/sys-x86_64/shared/sysdep/faultinfo.h diff --git a/arch/um/sys-x86_64/shared/sysdep/host_ldt.h b/arch/um/sys-x86_64/shared/sysdep/host_ldt.h new file mode 100644 index 00000000000..e8b1be1e154 --- /dev/null +++ b/arch/um/sys-x86_64/shared/sysdep/host_ldt.h @@ -0,0 +1,38 @@ +#ifndef __ASM_HOST_LDT_X86_64_H +#define __ASM_HOST_LDT_X86_64_H + +#include <asm/ldt.h> + +/* + * macros stolen from include/asm-x86_64/desc.h + */ +#define LDT_entry_a(info) \ + ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) + +/* Don't allow setting of the lm bit. It is useless anyways because + * 64bit system calls require __USER_CS. */ +#define LDT_entry_b(info) \ + (((info)->base_addr & 0xff000000) | \ + (((info)->base_addr & 0x00ff0000) >> 16) | \ + ((info)->limit & 0xf0000) | \ + (((info)->read_exec_only ^ 1) << 9) | \ + ((info)->contents << 10) | \ + (((info)->seg_not_present ^ 1) << 15) | \ + ((info)->seg_32bit << 22) | \ + ((info)->limit_in_pages << 23) | \ + ((info)->useable << 20) | \ + /* ((info)->lm << 21) | */ \ + 0x7000) + +#define LDT_empty(info) (\ + (info)->base_addr == 0 && \ + (info)->limit == 0 && \ + (info)->contents == 0 && \ + (info)->read_exec_only == 1 && \ + (info)->seg_32bit == 0 && \ + (info)->limit_in_pages == 0 && \ + (info)->seg_not_present == 1 && \ + (info)->useable == 0 && \ + (info)->lm == 0) + +#endif diff --git a/arch/um/include/sysdep-x86_64/kernel-offsets.h b/arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h index a307237b796..a307237b796 100644 --- a/arch/um/include/sysdep-x86_64/kernel-offsets.h +++ b/arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/sys-x86_64/shared/sysdep/ptrace.h index 9ea44d111f3..fdba5457947 100644 --- a/arch/um/include/sysdep-x86_64/ptrace.h +++ b/arch/um/sys-x86_64/shared/sysdep/ptrace.h @@ -8,7 +8,6 @@ #ifndef __SYSDEP_X86_64_PTRACE_H #define __SYSDEP_X86_64_PTRACE_H -#include "uml-config.h" #include "user_constants.h" #include "sysdep/faultinfo.h" diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/sys-x86_64/shared/sysdep/ptrace_user.h index 4dbccdb58f4..4dbccdb58f4 100644 --- a/arch/um/include/sysdep-x86_64/ptrace_user.h +++ b/arch/um/sys-x86_64/shared/sysdep/ptrace_user.h diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/sys-x86_64/shared/sysdep/sc.h index 8aee45b0743..8aee45b0743 100644 --- a/arch/um/include/sysdep-x86_64/sc.h +++ b/arch/um/sys-x86_64/shared/sysdep/sc.h diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/sys-x86_64/shared/sysdep/sigcontext.h index 0155133b145..0155133b145 100644 --- a/arch/um/include/sysdep-x86_64/sigcontext.h +++ b/arch/um/sys-x86_64/shared/sysdep/sigcontext.h diff --git a/arch/um/include/sysdep-x86_64/skas_ptrace.h b/arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h index 95db4be786e..95db4be786e 100644 --- a/arch/um/include/sysdep-x86_64/skas_ptrace.h +++ b/arch/um/sys-x86_64/shared/sysdep/skas_ptrace.h diff --git a/arch/um/include/sysdep-x86_64/stub.h b/arch/um/sys-x86_64/shared/sysdep/stub.h index 655f9c2de3a..3432aa24997 100644 --- a/arch/um/include/sysdep-x86_64/stub.h +++ b/arch/um/sys-x86_64/shared/sysdep/stub.h @@ -12,7 +12,6 @@ #include "as-layout.h" #include "stub-data.h" #include "kern_constants.h" -#include "uml-config.h" extern void stub_segv_handler(int sig); extern void stub_clone_handler(void); diff --git a/arch/um/include/sysdep-x86_64/syscalls.h b/arch/um/sys-x86_64/shared/sysdep/syscalls.h index 7cfb0b08565..7cfb0b08565 100644 --- a/arch/um/include/sysdep-x86_64/syscalls.h +++ b/arch/um/sys-x86_64/shared/sysdep/syscalls.h diff --git a/arch/um/sys-x86_64/shared/sysdep/system.h b/arch/um/sys-x86_64/shared/sysdep/system.h new file mode 100644 index 00000000000..d1b93c43620 --- /dev/null +++ b/arch/um/sys-x86_64/shared/sysdep/system.h @@ -0,0 +1,132 @@ +#ifndef _ASM_X86_SYSTEM_H_ +#define _ASM_X86_SYSTEM_H_ + +#include <asm/asm.h> +#include <asm/segment.h> +#include <asm/cpufeature.h> +#include <asm/cmpxchg.h> +#include <asm/nops.h> + +#include <linux/kernel.h> +#include <linux/irqflags.h> + +/* entries in ARCH_DLINFO: */ +#ifdef CONFIG_IA32_EMULATION +# define AT_VECTOR_SIZE_ARCH 2 +#else +# define AT_VECTOR_SIZE_ARCH 1 +#endif + +extern unsigned long arch_align_stack(unsigned long sp); + +void default_idle(void); + +/* + * Force strict CPU ordering. + * And yes, this is required on UP too when we're talking + * to devices. + */ +#ifdef CONFIG_X86_32 +/* + * Some non-Intel clones support out of order store. wmb() ceases to be a + * nop for these. + */ +#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) +#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) +#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) +#else +#define mb() asm volatile("mfence":::"memory") +#define rmb() asm volatile("lfence":::"memory") +#define wmb() asm volatile("sfence" ::: "memory") +#endif + +/** + * read_barrier_depends - Flush all pending reads that subsequents reads + * depend on. + * + * No data-dependent reads from memory-like regions are ever reordered + * over this barrier. All reads preceding this primitive are guaranteed + * to access memory (but not necessarily other CPUs' caches) before any + * reads following this primitive that depend on the data return by + * any of the preceding reads. This primitive is much lighter weight than + * rmb() on most CPUs, and is never heavier weight than is + * rmb(). + * + * These ordering constraints are respected by both the local CPU + * and the compiler. + * + * Ordering is not guaranteed by anything other than these primitives, + * not even by data dependencies. See the documentation for + * memory_barrier() for examples and URLs to more information. + * + * For example, the following code would force ordering (the initial + * value of "a" is zero, "b" is one, and "p" is "&a"): + * + * <programlisting> + * CPU 0 CPU 1 + * + * b = 2; + * memory_barrier(); + * p = &b; q = p; + * read_barrier_depends(); + * d = *q; + * </programlisting> + * + * because the read of "*q" depends on the read of "p" and these + * two reads are separated by a read_barrier_depends(). However, + * the following code, with the same initial values for "a" and "b": + * + * <programlisting> + * CPU 0 CPU 1 + * + * a = 2; + * memory_barrier(); + * b = 3; y = b; + * read_barrier_depends(); + * x = a; + * </programlisting> + * + * does not enforce ordering, since there is no data dependency between + * the read of "a" and the read of "b". Therefore, on some CPUs, such + * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() + * in cases like this where there are no data dependencies. + **/ + +#define read_barrier_depends() do { } while (0) + +#ifdef CONFIG_SMP +#define smp_mb() mb() +#ifdef CONFIG_X86_PPRO_FENCE +# define smp_rmb() rmb() +#else +# define smp_rmb() barrier() +#endif +#ifdef CONFIG_X86_OOSTORE +# define smp_wmb() wmb() +#else +# define smp_wmb() barrier() +#endif +#define smp_read_barrier_depends() read_barrier_depends() +#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) +#else +#define smp_mb() barrier() +#define smp_rmb() barrier() +#define smp_wmb() barrier() +#define smp_read_barrier_depends() do { } while (0) +#define set_mb(var, value) do { var = value; barrier(); } while (0) +#endif + +/* + * Stop RDTSC speculation. This is needed when you need to use RDTSC + * (or get_cycles or vread that possibly accesses the TSC) in a defined + * code region. + * + * (Could use an alternative three way for this if there was one.) + */ +static inline void rdtsc_barrier(void) +{ + alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC); + alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC); +} + +#endif diff --git a/arch/um/include/sysdep-x86_64/tls.h b/arch/um/sys-x86_64/shared/sysdep/tls.h index 35f19f25bd3..18c000d0357 100644 --- a/arch/um/include/sysdep-x86_64/tls.h +++ b/arch/um/sys-x86_64/shared/sysdep/tls.h @@ -22,7 +22,7 @@ typedef struct um_dup_user_desc { # else /* __KERNEL__ */ -# include <asm/ldt.h> +# include <ldt.h> typedef struct user_desc user_desc_t; # endif /* __KERNEL__ */ diff --git a/arch/um/sys-x86_64/shared/sysdep/vm-flags.h b/arch/um/sys-x86_64/shared/sysdep/vm-flags.h new file mode 100644 index 00000000000..3213edfa788 --- /dev/null +++ b/arch/um/sys-x86_64/shared/sysdep/vm-flags.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com) + * Copyright 2003 PathScale, Inc. + * Licensed under the GPL + */ + +#ifndef __VM_FLAGS_X86_64_H +#define __VM_FLAGS_X86_64_H + +#define __VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) +#define __VM_STACK_FLAGS (VM_GROWSDOWN | VM_READ | VM_WRITE | \ + VM_EXEC | VM_MAYREAD | VM_MAYWRITE | \ + VM_MAYEXEC) + +extern unsigned long vm_stack_flags, vm_stack_flags32; +extern unsigned long vm_data_default_flags, vm_data_default_flags32; +extern unsigned long vm_force_exec32; + +#ifdef TIF_IA32 +#define VM_DATA_DEFAULT_FLAGS \ + (test_thread_flag(TIF_IA32) ? vm_data_default_flags32 : \ + vm_data_default_flags) + +#define VM_STACK_DEFAULT_FLAGS \ + (test_thread_flag(TIF_IA32) ? vm_stack_flags32 : vm_stack_flags) +#endif + +#define VM_DATA_DEFAULT_FLAGS vm_data_default_flags + +#define VM_STACK_DEFAULT_FLAGS vm_stack_flags + +#endif diff --git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S index 56876876315..6d9edf9fabc 100644 --- a/arch/um/sys-x86_64/stub.S +++ b/arch/um/sys-x86_64/stub.S @@ -1,4 +1,3 @@ -#include "uml-config.h" #include "as-layout.h" .globl syscall_stub diff --git a/arch/um/sys-x86_64/syscall_table.c b/arch/um/sys-x86_64/syscall_table.c index c128eb89700..dd21d69715e 100644 --- a/arch/um/sys-x86_64/syscall_table.c +++ b/arch/um/sys-x86_64/syscall_table.c @@ -41,12 +41,12 @@ #define stub_rt_sigreturn sys_rt_sigreturn #define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ; -#undef _ASM_X86_64_UNISTD_H_ -#include <asm-x86/unistd_64.h> +#undef _ASM_X86_UNISTD_64_H +#include "../../x86/include/asm/unistd_64.h" #undef __SYSCALL #define __SYSCALL(nr, sym) [ nr ] = sym, -#undef _ASM_X86_64_UNISTD_H_ +#undef _ASM_X86_UNISTD_64_H typedef void (*sys_call_ptr_t)(void); @@ -64,7 +64,7 @@ extern void sys_ni_syscall(void); */ sys_call_ptr_t sys_call_table[] __cacheline_aligned = { -#include <asm-x86/unistd_64.h> +#include "../../x86/include/asm/unistd_64.h" }; int syscall_table_size = sizeof(sys_call_table); |