Commit 6d4c02fa authored by Anton Blanchard's avatar Anton Blanchard

Merge samba.org:/scratch/anton/linux-2.5

into samba.org:/scratch/anton/sfr
parents 3bf8cdae aea51d64
...@@ -30,36 +30,42 @@ config RWSEM_GENERIC_SPINLOCK ...@@ -30,36 +30,42 @@ config RWSEM_GENERIC_SPINLOCK
bool bool
default y default y
menu "UML-specific options"
config MODE_TT config MODE_TT
bool bool "Tracing thread support"
default y default y
help
This option controls whether tracing thread support is compiled
into UML. Normally, this should be set to Y. If you intend to
use only skas mode (and the host has the skas patch applied to it),
then it is OK to say N here.
config STATIC_LINK
bool "Force a static link"
default n
depends on !MODE_TT
help
If CONFIG_MODE_TT is disabled, then this option gives you the ability
to force a static link of UML. Normally, if only skas mode is built
in to UML, it will be linked as a shared binary. This is inconvenient
for use in a chroot jail. So, if you intend to run UML inside a
chroot, and you disable CONFIG_MODE_TT, you probably want to say Y
here.
config MODE_SKAS config MODE_SKAS
bool bool "Separate Kernel Address Space support"
default y default y
help
menu "Code maturity level options" This option controls whether skas (separate kernel address space)
support is compiled in. If you have applied the skas patch to the
config EXPERIMENTAL host, then you certainly want to say Y here (and consider saying N
bool "Prompt for development and/or incomplete code/drivers" to CONFIG_MODE_TT). Otherwise, it is safe to say Y. Disabling this
option will shrink the UML binary slightly.
endmenu
menu "General Setup"
config NET config NET
bool "Networking support" bool "Networking support"
config SYSVIPC
bool "System V IPC"
config BSD_PROCESS_ACCT
bool "BSD Process Accounting"
config SYSCTL
bool "Sysctl support"
config BINFMT_AOUT config BINFMT_AOUT
tristate "Kernel support for a.out binaries" tristate "Kernel support for a.out binaries"
...@@ -164,22 +170,18 @@ config KERNEL_HALF_GIGS ...@@ -164,22 +170,18 @@ config KERNEL_HALF_GIGS
config HIGHMEM config HIGHMEM
bool "Highmem support" bool "Highmem support"
endmenu config KERNEL_STACK_ORDER
int "Kernel stack size order"
default 2
menu "Loadable module support" help
This option determines the size of UML kernel stacks. They will
config MODULES be 1 << order pages. The default is OK unless you're running Valgrind
bool "Enable loadable module support" on UML, in which case, set this to 3.
# MODVERSIONS does not yet work in this architecture
# bool ' Set version information on all module symbols' CONFIG_MODVERSIONS
config KMOD
bool "Kernel module loader"
depends on MODULES
endmenu endmenu
source "init/Kconfig"
source "arch/um/Kconfig_char" source "arch/um/Kconfig_char"
source "arch/um/Kconfig_block" source "arch/um/Kconfig_block"
...@@ -194,6 +196,10 @@ source "net/Kconfig" ...@@ -194,6 +196,10 @@ source "net/Kconfig"
source "fs/Kconfig" source "fs/Kconfig"
source "security/Kconfig"
source "crypto/Kconfig"
source "lib/Kconfig" source "lib/Kconfig"
menu "SCSI support" menu "SCSI support"
...@@ -221,6 +227,9 @@ menu "Kernel hacking" ...@@ -221,6 +227,9 @@ menu "Kernel hacking"
config DEBUG_SLAB config DEBUG_SLAB
bool "Debug memory allocations" bool "Debug memory allocations"
config DEBUG_SPINLOCK
bool "Debug spinlocks usage"
config DEBUGSYM config DEBUGSYM
bool "Enable kernel debugging symbols" bool "Enable kernel debugging symbols"
help help
...@@ -232,6 +241,10 @@ config DEBUGSYM ...@@ -232,6 +241,10 @@ config DEBUGSYM
If you're truly short on disk space or don't expect to report any If you're truly short on disk space or don't expect to report any
bugs back to the UML developers, say N, otherwise say Y. bugs back to the UML developers, say N, otherwise say Y.
config FRAME_POINTER
bool
default y if DEBUGSYM
config PT_PROXY config PT_PROXY
bool "Enable ptrace proxy" bool "Enable ptrace proxy"
depends on XTERM_CHAN && DEBUGSYM depends on XTERM_CHAN && DEBUGSYM
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
ARCH_DIR = arch/um ARCH_DIR = arch/um
OS := $(shell uname -s) OS := $(shell uname -s)
EXTRAVERSION := $(EXTRAVERSION)-1um
include/linux/version.h: arch/$(ARCH)/Makefile
# Recalculate MODLIB to reflect the EXTRAVERSION changes (via KERNELRELEASE) # Recalculate MODLIB to reflect the EXTRAVERSION changes (via KERNELRELEASE)
# The way the toplevel Makefile is written EXTRAVERSION is not supposed # The way the toplevel Makefile is written EXTRAVERSION is not supposed
# to be changed outside the toplevel Makefile, but recalculating MODLIB is # to be changed outside the toplevel Makefile, but recalculating MODLIB is
...@@ -21,17 +18,34 @@ CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS)) ...@@ -21,17 +18,34 @@ CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS))
endif endif
CFLAGS-$(CONFIG_DEBUGSYM) += -g CFLAGS-$(CONFIG_DEBUGSYM) += -g
CFLAGS-$(CONFIG_GCOV) += -fprofile-arcs -ftest-coverage
CFLAGS-$(CONFIG_GPROF) += $(PROFILE)
LINK-$(CONFIG_GPROF) += $(PROFILE) -Wl,--wrap,__monstartup
core-y += $(ARCH_DIR)/kernel/ \ core-y += $(ARCH_DIR)/kernel/ \
$(ARCH_DIR)/drivers/ \ $(ARCH_DIR)/drivers/ \
$(ARCH_DIR)/sys-$(SUBARCH)/ $(ARCH_DIR)/sys-$(SUBARCH)/
# Have to precede the include because the included Makefiles reference them.
SYMLINK_HEADERS = include/asm-um/archparam.h include/asm-um/system.h \
include/asm-um/sigcontext.h include/asm-um/processor.h \
include/asm-um/ptrace.h include/asm-um/arch-signal.h
ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
$(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
include $(ARCH_DIR)/Makefile-$(SUBARCH)
include $(ARCH_DIR)/Makefile-os-$(OS)
MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
ifneq ($(MAKEFILE-y),)
include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
endif
EXTRAVERSION := $(EXTRAVERSION)-1um
ARCH_INCLUDE = -I$(ARCH_DIR)/include ARCH_INCLUDE = -I$(ARCH_DIR)/include
MODE_INCLUDE = -I$(ARCH_DIR)/kernel/tt/include \
-I$(ARCH_DIR)/kernel/skas/include
# -Derrno=kernel_errno - This turns all kernel references to errno into # -Derrno=kernel_errno - This turns all kernel references to errno into
# kernel_errno to separate them from the libc errno. This allows -fno-common # kernel_errno to separate them from the libc errno. This allows -fno-common
...@@ -46,23 +60,11 @@ LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc ...@@ -46,23 +60,11 @@ LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
SYMLINK_HEADERS = include/asm-um/archparam.h include/asm-um/system.h \
include/asm-um/sigcontext.h include/asm-um/processor.h \
include/asm-um/ptrace.h include/asm-um/arch-signal.h
ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
$(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
ifeq ($(CONFIG_MODE_SKAS), y) ifeq ($(CONFIG_MODE_SKAS), y)
GEN_HEADERS = $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
$(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h $(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
endif endif
GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h include/linux/version.h: arch/$(ARCH)/Makefile
include $(ARCH_DIR)/Makefile-$(SUBARCH)
include $(ARCH_DIR)/Makefile-os-$(OS)
$(ARCH_DIR)/vmlinux.lds.S : $(ARCH_DIR)/vmlinux.lds.S :
touch $@ touch $@
...@@ -73,16 +75,46 @@ LDFLAGS_vmlinux = -r ...@@ -73,16 +75,46 @@ LDFLAGS_vmlinux = -r
vmlinux: $(ARCH_DIR)/main.o vmlinux: $(ARCH_DIR)/main.o
$(ARCH_DIR)/uml.lds.s : $(ARCH_DIR)/uml.lds.S scripts FORCE # These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
$(call if_changed_dep,as_s_S) # CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
LINK_TT = -static
LD_SCRIPT_TT := uml.lds.s
ifeq ($(CONFIG_STATIC_LINK),y)
LINK-y += $(LINK_TT)
LD_SCRIPT-y := $(LD_SCRIPT_TT)
else
ifeq ($(CONFIG_MODE_TT),y)
LINK-y += $(LINK_TT)
LD_SCRIPT-y := $(LD_SCRIPT_TT)
else
ifeq ($(CONFIG_MODE_SKAS),y)
LINK-y += $(LINK_SKAS)
LD_SCRIPT-y := $(LD_SCRIPT_SKAS)
endif
endif
endif
AFLAGS_uml.lds.o = -U$(SUBARCH) -DSTART=$$(($(TOP_ADDR) - $(SIZE))) \ CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
-DELF_ARCH=$(ELF_ARCH) -DELF_FORMAT=\"$(ELF_FORMAT)\" -P -C -Uum CONFIG_KERNEL_STACK_ORDER ?= 2
STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
linux: $(ARCH_DIR)/uml.lds.s vmlinux AFLAGS_vmlinux.lds.o = -U$(SUBARCH) \
$(CC) -Wl,-T,$(ARCH_DIR)/uml.lds.s -static $(LINK-y) $(LINK_WRAPS) \ -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
-o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
-DKERNEL_STACK_SIZE=$(STACK_SIZE)
AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
$(call if_changed_dep,as_s_S)
linux: vmlinux $(LD_SCRIPT-y)
$(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
-o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil
USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS)) USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
...@@ -92,7 +124,8 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ ...@@ -92,7 +124,8 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
# To get a definition of F_SETSIG # To get a definition of F_SETSIG
USER_CFLAGS += -D_GNU_SOURCE USER_CFLAGS += -D_GNU_SOURCE
CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/link.ld $(GEN_HEADERS) CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/uml.lds.s \
$(ARCH_DIR)/dyn_link.ld.s $(GEN_HEADERS)
$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c $(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c
$(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
...@@ -102,8 +135,7 @@ archmrproper: ...@@ -102,8 +135,7 @@ archmrproper:
do \ do \
$(MAKE) -C $$d archmrproper; \ $(MAKE) -C $$d archmrproper; \
done done
rm -f $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) include/asm \ rm -f $(CLEAN_FILES) $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) include/asm \
$(ARCH_DIR)/link.ld \
$(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
archclean: sysclean archclean: sysclean
...@@ -132,7 +164,7 @@ $(ARCH_DIR)/os: ...@@ -132,7 +164,7 @@ $(ARCH_DIR)/os:
cd $(ARCH_DIR) && ln -sf os-$(OS) os cd $(ARCH_DIR) && ln -sf os-$(OS) os
$(ARCH_DIR)/include/uml-config.h : $(ARCH_DIR)/include/uml-config.h :
ln -sf $(TOPDIR)/include/linux/autoconf.h $@ sed 's/ CONFIG/ UML_CONFIG/' $(TOPDIR)/include/linux/autoconf.h > $@
$(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
$< > $@ $< > $@
...@@ -146,7 +178,4 @@ $(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h \ ...@@ -146,7 +178,4 @@ $(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h \
$(ARCH_DIR)/util: FORCE $(ARCH_DIR)/util: FORCE
@$(call descend,$@,) @$(call descend,$@,)
$(ARCH_DIR)/kernel/skas/include/skas_ptregs.h :
$(MAKE) -C $(ARCH_DIR)/kernel/skas include/skas_ptregs.h
export SUBARCH USER_CFLAGS OS export SUBARCH USER_CFLAGS OS
#
# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
# Licensed under the GPL
#
PROFILE += -pg
CFLAGS-$(CONFIG_GCOV) += -fprofile-arcs -ftest-coverage
CFLAGS-$(CONFIG_GPROF) += $(PROFILE)
LINK-$(CONFIG_GPROF) += $(PROFILE)
MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/kernel/skas/include
LINK_SKAS = -Wl,-rpath,/lib
LD_SCRIPT_SKAS = dyn.lds.s
GEN_HEADERS += $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
$(ARCH_DIR)/kernel/skas/include/skas_ptregs.h :
$(MAKE) -C $(ARCH_DIR)/kernel/skas include/skas_ptregs.h
#
# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
# Licensed under the GPL
#
MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/kernel/tt/include
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
# Automatically generated make config: don't edit # Automatically generated make config: don't edit
# #
CONFIG_USERMODE=y CONFIG_USERMODE=y
# CONFIG_ISA is not set CONFIG_MMU=y
# CONFIG_SBUS is not set CONFIG_SWAP=y
# CONFIG_PCI is not set
CONFIG_UID16=y CONFIG_UID16=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_CONFIG_LOG_BUF_SHIFT=14
# #
# Code maturity level options # Code maturity level options
...@@ -16,6 +16,8 @@ CONFIG_EXPERIMENTAL=y ...@@ -16,6 +16,8 @@ CONFIG_EXPERIMENTAL=y
# #
# General Setup # General Setup
# #
CONFIG_MODE_TT=y
CONFIG_MODE_SKAS=y
CONFIG_NET=y CONFIG_NET=y
CONFIG_SYSVIPC=y CONFIG_SYSVIPC=y
CONFIG_BSD_PROCESS_ACCT=y CONFIG_BSD_PROCESS_ACCT=y
...@@ -32,6 +34,8 @@ CONFIG_MAGIC_SYSRQ=y ...@@ -32,6 +34,8 @@ CONFIG_MAGIC_SYSRQ=y
CONFIG_NEST_LEVEL=0 CONFIG_NEST_LEVEL=0
CONFIG_KERNEL_HALF_GIGS=1 CONFIG_KERNEL_HALF_GIGS=1
# CONFIG_HIGHMEM is not set # CONFIG_HIGHMEM is not set
CONFIG_PROC_MM=y
CONFIG_KERNEL_STACK_ORDER=2
# #
# Loadable module support # Loadable module support
...@@ -56,13 +60,9 @@ CONFIG_SSL_CHAN="pty" ...@@ -56,13 +60,9 @@ CONFIG_SSL_CHAN="pty"
CONFIG_UNIX98_PTYS=y CONFIG_UNIX98_PTYS=y
CONFIG_UNIX98_PTY_COUNT=256 CONFIG_UNIX98_PTY_COUNT=256
# CONFIG_WATCHDOG is not set # CONFIG_WATCHDOG is not set
# CONFIG_WATCHDOG_NOWAYOUT is not set
# CONFIG_SOFT_WATCHDOG is not set
# CONFIG_UML_WATCHDOG is not set
CONFIG_UML_SOUND=y CONFIG_UML_SOUND=y
CONFIG_SOUND=y CONFIG_SOUND=y
CONFIG_HOSTAUDIO=y CONFIG_HOSTAUDIO=y
# CONFIG_TTY_LOG is not set
# #
# Block Devices # Block Devices
...@@ -87,13 +87,14 @@ CONFIG_UML_NET_SLIP=y ...@@ -87,13 +87,14 @@ CONFIG_UML_NET_SLIP=y
CONFIG_UML_NET_DAEMON=y CONFIG_UML_NET_DAEMON=y
CONFIG_UML_NET_MCAST=y CONFIG_UML_NET_MCAST=y
# CONFIG_UML_NET_PCAP is not set # CONFIG_UML_NET_PCAP is not set
CONFIG_UML_NET_SLIRP=y
CONFIG_DUMMY=y CONFIG_DUMMY=y
# CONFIG_BONDING is not set # CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set # CONFIG_EQUALIZER is not set
CONFIG_TUN=y CONFIG_TUN=y
# CONFIG_ETHERTAP is not set
CONFIG_PPP=y CONFIG_PPP=y
# CONFIG_PPP_MULTILINK is not set # CONFIG_PPP_MULTILINK is not set
# CONFIG_PPP_FILTER is not set
# CONFIG_PPP_ASYNC is not set # CONFIG_PPP_ASYNC is not set
# CONFIG_PPP_SYNC_TTY is not set # CONFIG_PPP_SYNC_TTY is not set
# CONFIG_PPP_DEFLATE is not set # CONFIG_PPP_DEFLATE is not set
...@@ -104,6 +105,10 @@ CONFIG_SLIP=y ...@@ -104,6 +105,10 @@ CONFIG_SLIP=y
# CONFIG_SLIP_SMART is not set # CONFIG_SLIP_SMART is not set
# CONFIG_SLIP_MODE_SLIP6 is not set # CONFIG_SLIP_MODE_SLIP6 is not set
#
# Networking support
#
# #
# Networking options # Networking options
# #
...@@ -113,6 +118,7 @@ CONFIG_PACKET_MMAP=y ...@@ -113,6 +118,7 @@ CONFIG_PACKET_MMAP=y
# CONFIG_NETFILTER is not set # CONFIG_NETFILTER is not set
# CONFIG_FILTER is not set # CONFIG_FILTER is not set
CONFIG_UNIX=y CONFIG_UNIX=y
# CONFIG_NET_KEY is not set
CONFIG_INET=y CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set # CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set # CONFIG_IP_ADVANCED_ROUTER is not set
...@@ -122,6 +128,9 @@ CONFIG_INET=y ...@@ -122,6 +128,9 @@ CONFIG_INET=y
# CONFIG_ARPD is not set # CONFIG_ARPD is not set
# CONFIG_INET_ECN is not set # CONFIG_INET_ECN is not set
# CONFIG_SYN_COOKIES is not set # CONFIG_SYN_COOKIES is not set
# CONFIG_INET_AH is not set
# CONFIG_INET_ESP is not set
# CONFIG_XFRM_USER is not set
# CONFIG_IPV6 is not set # CONFIG_IPV6 is not set
# #
...@@ -132,9 +141,6 @@ CONFIG_IPV6_SCTP__=y ...@@ -132,9 +141,6 @@ CONFIG_IPV6_SCTP__=y
# CONFIG_ATM is not set # CONFIG_ATM is not set
# CONFIG_VLAN_8021Q is not set # CONFIG_VLAN_8021Q is not set
# CONFIG_LLC is not set # CONFIG_LLC is not set
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
# CONFIG_DEV_APPLETALK is not set
# CONFIG_DECNET is not set # CONFIG_DECNET is not set
# CONFIG_BRIDGE is not set # CONFIG_BRIDGE is not set
# CONFIG_X25 is not set # CONFIG_X25 is not set
...@@ -150,6 +156,35 @@ CONFIG_IPV6_SCTP__=y ...@@ -150,6 +156,35 @@ CONFIG_IPV6_SCTP__=y
# #
# CONFIG_NET_SCHED is not set # CONFIG_NET_SCHED is not set
#
# Network testing
#
# CONFIG_NET_PKTGEN is not set
#
# Ethernet (10 or 100Mbit)
#
# CONFIG_NET_ETHERNET is not set
#
# Ethernet (1000 Mbit)
#
#
# Wireless LAN (non-hamradio)
#
# CONFIG_NET_RADIO is not set
#
# Token Ring devices (depends on LLC=y)
#
# CONFIG_SHAPER is not set
#
# Wan interfaces
#
# CONFIG_WAN is not set
# #
# File systems # File systems
# #
...@@ -163,16 +198,14 @@ CONFIG_REISERFS_FS=m ...@@ -163,16 +198,14 @@ CONFIG_REISERFS_FS=m
# CONFIG_REISERFS_CHECK is not set # CONFIG_REISERFS_CHECK is not set
# CONFIG_REISERFS_PROC_INFO is not set # CONFIG_REISERFS_PROC_INFO is not set
# CONFIG_ADFS_FS is not set # CONFIG_ADFS_FS is not set
# CONFIG_ADFS_FS_RW is not set
# CONFIG_AFFS_FS is not set # CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set # CONFIG_HFS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BFS_FS is not set # CONFIG_BFS_FS is not set
# CONFIG_EXT3_FS is not set # CONFIG_EXT3_FS is not set
# CONFIG_JBD is not set # CONFIG_JBD is not set
# CONFIG_JBD_DEBUG is not set
CONFIG_FAT_FS=m CONFIG_FAT_FS=m
CONFIG_MSDOS_FS=m CONFIG_MSDOS_FS=m
# CONFIG_UMSDOS_FS is not set
CONFIG_VFAT_FS=m CONFIG_VFAT_FS=m
# CONFIG_EFS_FS is not set # CONFIG_EFS_FS is not set
CONFIG_JFFS_FS=y CONFIG_JFFS_FS=y
...@@ -186,13 +219,9 @@ CONFIG_ISO9660_FS=m ...@@ -186,13 +219,9 @@ CONFIG_ISO9660_FS=m
# CONFIG_JOLIET is not set # CONFIG_JOLIET is not set
# CONFIG_ZISOFS is not set # CONFIG_ZISOFS is not set
# CONFIG_JFS_FS is not set # CONFIG_JFS_FS is not set
# CONFIG_JFS_DEBUG is not set
# CONFIG_JFS_STATISTICS is not set
CONFIG_MINIX_FS=m CONFIG_MINIX_FS=m
# CONFIG_VXFS_FS is not set # CONFIG_VXFS_FS is not set
# CONFIG_NTFS_FS is not set # CONFIG_NTFS_FS is not set
# CONFIG_NTFS_DEBUG is not set
# CONFIG_NTFS_RW is not set
# CONFIG_HPFS_FS is not set # CONFIG_HPFS_FS is not set
CONFIG_PROC_FS=y CONFIG_PROC_FS=y
CONFIG_DEVFS_FS=y CONFIG_DEVFS_FS=y
...@@ -200,17 +229,13 @@ CONFIG_DEVFS_MOUNT=y ...@@ -200,17 +229,13 @@ CONFIG_DEVFS_MOUNT=y
# CONFIG_DEVFS_DEBUG is not set # CONFIG_DEVFS_DEBUG is not set
CONFIG_DEVPTS_FS=y CONFIG_DEVPTS_FS=y
# CONFIG_QNX4FS_FS is not set # CONFIG_QNX4FS_FS is not set
# CONFIG_QNX4FS_RW is not set
# CONFIG_ROMFS_FS is not set # CONFIG_ROMFS_FS is not set
CONFIG_EXT2_FS=y CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS_XATTR is not set
# CONFIG_SYSV_FS is not set # CONFIG_SYSV_FS is not set
# CONFIG_UDF_FS is not set # CONFIG_UDF_FS is not set
# CONFIG_UDF_RW is not set
# CONFIG_UFS_FS is not set # CONFIG_UFS_FS is not set
# CONFIG_UFS_FS_WRITE is not set
# CONFIG_XFS_FS is not set # CONFIG_XFS_FS is not set
# CONFIG_XFS_RT is not set
# CONFIG_XFS_QUOTA is not set
# #
# Network File Systems # Network File Systems
...@@ -218,36 +243,18 @@ CONFIG_EXT2_FS=y ...@@ -218,36 +243,18 @@ CONFIG_EXT2_FS=y
# CONFIG_CODA_FS is not set # CONFIG_CODA_FS is not set
# CONFIG_INTERMEZZO_FS is not set # CONFIG_INTERMEZZO_FS is not set
# CONFIG_NFS_FS is not set # CONFIG_NFS_FS is not set
# CONFIG_NFS_V3 is not set
# CONFIG_NFS_V4 is not set
# CONFIG_ROOT_NFS is not set
# CONFIG_NFSD is not set # CONFIG_NFSD is not set
# CONFIG_NFSD_V3 is not set
# CONFIG_NFSD_V4 is not set
# CONFIG_NFSD_TCP is not set
# CONFIG_SUNRPC is not set
# CONFIG_LOCKD is not set
# CONFIG_EXPORTFS is not set # CONFIG_EXPORTFS is not set
# CONFIG_CIFS is not set # CONFIG_CIFS is not set
# CONFIG_SMB_FS is not set # CONFIG_SMB_FS is not set
# CONFIG_NCP_FS is not set # CONFIG_NCP_FS is not set
# CONFIG_NCPFS_PACKET_SIGNING is not set
# CONFIG_NCPFS_IOCTL_LOCKING is not set
# CONFIG_NCPFS_STRONG is not set
# CONFIG_NCPFS_NFS_NS is not set
# CONFIG_NCPFS_OS2_NS is not set
# CONFIG_NCPFS_SMALLDOS is not set
# CONFIG_NCPFS_NLS is not set
# CONFIG_NCPFS_EXTRAS is not set
# CONFIG_AFS_FS is not set # CONFIG_AFS_FS is not set
# CONFIG_ZISOFS_FS is not set
# #
# Partition Types # Partition Types
# #
# CONFIG_PARTITION_ADVANCED is not set # CONFIG_PARTITION_ADVANCED is not set
CONFIG_MSDOS_PARTITION=y CONFIG_MSDOS_PARTITION=y
# CONFIG_SMB_NLS is not set
CONFIG_NLS=y CONFIG_NLS=y
# #
...@@ -292,6 +299,21 @@ CONFIG_NLS_DEFAULT="iso8859-1" ...@@ -292,6 +299,21 @@ CONFIG_NLS_DEFAULT="iso8859-1"
# CONFIG_NLS_KOI8_U is not set # CONFIG_NLS_KOI8_U is not set
# CONFIG_NLS_UTF8 is not set # CONFIG_NLS_UTF8 is not set
#
# Security options
#
# CONFIG_SECURITY is not set
#
# Cryptographic options
#
# CONFIG_CRYPTO is not set
#
# Library routines
#
# CONFIG_CRC32 is not set
# #
# SCSI support # SCSI support
# #
...@@ -322,13 +344,6 @@ CONFIG_SCSI_DEBUG=y ...@@ -322,13 +344,6 @@ CONFIG_SCSI_DEBUG=y
# Multi-device support (RAID and LVM) # Multi-device support (RAID and LVM)
# #
# CONFIG_MD is not set # CONFIG_MD is not set
# CONFIG_BLK_DEV_MD is not set
# CONFIG_MD_LINEAR is not set
# CONFIG_MD_RAID0 is not set
# CONFIG_MD_RAID1 is not set
# CONFIG_MD_RAID5 is not set
# CONFIG_MD_MULTIPATH is not set
# CONFIG_BLK_DEV_LVM is not set
# #
# Memory Technology Devices (MTD) # Memory Technology Devices (MTD)
...@@ -337,8 +352,6 @@ CONFIG_MTD=y ...@@ -337,8 +352,6 @@ CONFIG_MTD=y
# CONFIG_MTD_DEBUG is not set # CONFIG_MTD_DEBUG is not set
# CONFIG_MTD_PARTITIONS is not set # CONFIG_MTD_PARTITIONS is not set
# CONFIG_MTD_CONCAT is not set # CONFIG_MTD_CONCAT is not set
# CONFIG_MTD_REDBOOT_PARTS is not set
# CONFIG_MTD_CMDLINE_PARTS is not set
# #
# User Modules And Translation Layers # User Modules And Translation Layers
...@@ -353,28 +366,18 @@ CONFIG_MTD_BLOCK=y ...@@ -353,28 +366,18 @@ CONFIG_MTD_BLOCK=y
# #
# CONFIG_MTD_CFI is not set # CONFIG_MTD_CFI is not set
# CONFIG_MTD_JEDECPROBE is not set # CONFIG_MTD_JEDECPROBE is not set
# CONFIG_MTD_GEN_PROBE is not set
# CONFIG_MTD_CFI_INTELEXT is not set
# CONFIG_MTD_CFI_AMDSTD is not set
# CONFIG_MTD_RAM is not set # CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set # CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set # CONFIG_MTD_ABSENT is not set
# CONFIG_MTD_OBSOLETE_CHIPS is not set # CONFIG_MTD_OBSOLETE_CHIPS is not set
# CONFIG_MTD_AMDSTD is not set
# CONFIG_MTD_SHARP is not set
# CONFIG_MTD_JEDEC is not set
# #
# Mapping drivers for chip access # Mapping drivers for chip access
# #
# CONFIG_MTD_PHYSMAP is not set
# CONFIG_MTD_PCI is not set
# CONFIG_MTD_PCMCIA is not set
# #
# Self-contained MTD device drivers # Self-contained MTD device drivers
# #
# CONFIG_MTD_PMC551 is not set
# CONFIG_MTD_SLRAM is not set # CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_MTDRAM is not set # CONFIG_MTD_MTDRAM is not set
CONFIG_MTD_BLKMTD=m CONFIG_MTD_BLKMTD=m
...@@ -385,7 +388,6 @@ CONFIG_MTD_BLKMTD=m ...@@ -385,7 +388,6 @@ CONFIG_MTD_BLKMTD=m
# CONFIG_MTD_DOC1000 is not set # CONFIG_MTD_DOC1000 is not set
# CONFIG_MTD_DOC2000 is not set # CONFIG_MTD_DOC2000 is not set
# CONFIG_MTD_DOC2001 is not set # CONFIG_MTD_DOC2001 is not set
# CONFIG_MTD_DOCPROBE is not set
# #
# NAND Flash Device Drivers # NAND Flash Device Drivers
...@@ -396,7 +398,9 @@ CONFIG_MTD_BLKMTD=m ...@@ -396,7 +398,9 @@ CONFIG_MTD_BLKMTD=m
# Kernel hacking # Kernel hacking
# #
# CONFIG_DEBUG_SLAB is not set # CONFIG_DEBUG_SLAB is not set
# CONFIG_DEBUG_SPINLOCK is not set
CONFIG_DEBUGSYM=y CONFIG_DEBUGSYM=y
CONFIG_FRAME_POINTER=y
CONFIG_PT_PROXY=y CONFIG_PT_PROXY=y
# CONFIG_GPROF is not set # CONFIG_GPROF is not set
# CONFIG_GCOV is not set # CONFIG_GCOV is not set
...@@ -75,15 +75,15 @@ static void not_configged_free(void *data) ...@@ -75,15 +75,15 @@ static void not_configged_free(void *data)
} }
static struct chan_ops not_configged_ops = { static struct chan_ops not_configged_ops = {
init: not_configged_init, .init = not_configged_init,
open: not_configged_open, .open = not_configged_open,
close: not_configged_close, .close = not_configged_close,
read: not_configged_read, .read = not_configged_read,
write: not_configged_write, .write = not_configged_write,
console_write: not_configged_console_write, .console_write = not_configged_console_write,
window_size: not_configged_window_size, .window_size = not_configged_window_size,
free: not_configged_free, .free = not_configged_free,
winch: 0, .winch = 0,
}; };
static void tty_receive_char(struct tty_struct *tty, char ch) static void tty_receive_char(struct tty_struct *tty, char ch)
...@@ -395,15 +395,15 @@ static struct chan *parse_chan(char *str, int pri, int device, ...@@ -395,15 +395,15 @@ static struct chan *parse_chan(char *str, int pri, int device,
chan = kmalloc(sizeof(*chan), GFP_KERNEL); chan = kmalloc(sizeof(*chan), GFP_KERNEL);
if(chan == NULL) return(NULL); if(chan == NULL) return(NULL);
*chan = ((struct chan) { list : LIST_HEAD_INIT(chan->list), *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
primary : 1, .primary = 1,
input : 0, .input = 0,
output : 0, .output = 0,
opened : 0, .opened = 0,
fd : -1, .fd = -1,
pri : pri, .pri = pri,
ops : ops, .ops = ops,
data : data }); .data = data });
return(chan); return(chan);
} }
......
...@@ -159,9 +159,9 @@ static int winch_tramp(int fd, void *device_data, int *fd_out) ...@@ -159,9 +159,9 @@ static int winch_tramp(int fd, void *device_data, int *fd_out)
return(err); return(err);
} }
data = ((struct winch_data) { pty_fd : fd, data = ((struct winch_data) { .pty_fd = fd,
pipe_fd : fds[1], .pipe_fd = fds[1],
close_me : fds[0] } ); .close_me = fds[0] } );
pid = run_helper_thread(winch_thread, &data, 0, &stack, 0); pid = run_helper_thread(winch_thread, &data, 0, &stack, 0);
if(pid < 0){ if(pid < 0){
printk("fork of winch_thread failed - errno = %d\n", errno); printk("fork of winch_thread failed - errno = %d\n", errno);
......
...@@ -28,14 +28,14 @@ void daemon_init(struct net_device *dev, void *data) ...@@ -28,14 +28,14 @@ void daemon_init(struct net_device *dev, void *data)
pri = dev->priv; pri = dev->priv;
dpri = (struct daemon_data *) pri->user; dpri = (struct daemon_data *) pri->user;
*dpri = ((struct daemon_data) *dpri = ((struct daemon_data)
{ sock_type : init->sock_type, { .sock_type = init->sock_type,
ctl_sock : init->ctl_sock, .ctl_sock = init->ctl_sock,
ctl_addr : NULL, .ctl_addr = NULL,
data_addr : NULL, .data_addr = NULL,
local_addr : NULL, .local_addr = NULL,
fd : -1, .fd = -1,
control : -1, .control = -1,
dev : dev }); .dev = dev });
printk("daemon backend (uml_switch version %d) - %s:%s", printk("daemon backend (uml_switch version %d) - %s:%s",
SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
...@@ -59,10 +59,10 @@ static int daemon_write(int fd, struct sk_buff **skb, ...@@ -59,10 +59,10 @@ static int daemon_write(int fd, struct sk_buff **skb,
} }
static struct net_kern_info daemon_kern_info = { static struct net_kern_info daemon_kern_info = {
init: daemon_init, .init = daemon_init,
protocol: eth_protocol, .protocol = eth_protocol,
read: daemon_read, .read = daemon_read,
write: daemon_write, .write = daemon_write,
}; };
int daemon_setup(char *str, char **mac_out, void *data) int daemon_setup(char *str, char **mac_out, void *data)
...@@ -71,8 +71,8 @@ int daemon_setup(char *str, char **mac_out, void *data) ...@@ -71,8 +71,8 @@ int daemon_setup(char *str, char **mac_out, void *data)
char *remain; char *remain;
*init = ((struct daemon_init) *init = ((struct daemon_init)
{ sock_type : "unix", { .sock_type = "unix",
ctl_sock : "/tmp/uml.ctl" }); .ctl_sock = "/tmp/uml.ctl" });
remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock,
NULL); NULL);
...@@ -84,13 +84,13 @@ int daemon_setup(char *str, char **mac_out, void *data) ...@@ -84,13 +84,13 @@ int daemon_setup(char *str, char **mac_out, void *data)
} }
static struct transport daemon_transport = { static struct transport daemon_transport = {
list : LIST_HEAD_INIT(daemon_transport.list), .list = LIST_HEAD_INIT(daemon_transport.list),
name : "daemon", .name = "daemon",
setup : daemon_setup, .setup = daemon_setup,
user : &daemon_user_info, .user = &daemon_user_info,
kern : &daemon_kern_info, .kern = &daemon_kern_info,
private_size : sizeof(struct daemon_data), .private_size = sizeof(struct daemon_data),
setup_size : sizeof(struct daemon_init), .setup_size = sizeof(struct daemon_init),
}; };
static int register_daemon(void) static int register_daemon(void)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -24,8 +25,8 @@ enum request_type { REQ_NEW_CONTROL }; ...@@ -24,8 +25,8 @@ enum request_type { REQ_NEW_CONTROL };
#define SWITCH_MAGIC 0xfeedface #define SWITCH_MAGIC 0xfeedface
struct request_v3 { struct request_v3 {
unsigned long magic; uint32_t magic;
int version; uint32_t version;
enum request_type type; enum request_type type;
struct sockaddr_un sock; struct sockaddr_un sock;
}; };
...@@ -172,14 +173,14 @@ static int daemon_set_mtu(int mtu, void *data) ...@@ -172,14 +173,14 @@ static int daemon_set_mtu(int mtu, void *data)
} }
struct net_user_info daemon_user_info = { struct net_user_info daemon_user_info = {
init: daemon_user_init, .init = daemon_user_init,
open: daemon_open, .open = daemon_open,
close: NULL, .close = NULL,
remove: daemon_remove, .remove = daemon_remove,
set_mtu: daemon_set_mtu, .set_mtu = daemon_set_mtu,
add_address: NULL, .add_address = NULL,
delete_address: NULL, .delete_address = NULL,
max_packet: MAX_PACKET - ETH_HEADER_OTHER .max_packet = MAX_PACKET - ETH_HEADER_OTHER
}; };
/* /*
......
...@@ -36,8 +36,8 @@ void *fd_init(char *str, int device, struct chan_opts *opts) ...@@ -36,8 +36,8 @@ void *fd_init(char *str, int device, struct chan_opts *opts)
return(NULL); return(NULL);
} }
if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL); if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
*data = ((struct fd_chan) { fd : n, *data = ((struct fd_chan) { .fd = n,
raw : opts->raw }); .raw = opts->raw });
return(data); return(data);
} }
...@@ -72,16 +72,16 @@ int fd_console_write(int fd, const char *buf, int n, void *d) ...@@ -72,16 +72,16 @@ int fd_console_write(int fd, const char *buf, int n, void *d)
} }
struct chan_ops fd_ops = { struct chan_ops fd_ops = {
type: "fd", .type = "fd",
init: fd_init, .init = fd_init,
open: fd_open, .open = fd_open,
close: fd_close, .close = fd_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: fd_console_write, .console_write = fd_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: generic_free, .free = generic_free,
winch: 1, .winch = 1,
}; };
/* /*
......
...@@ -145,17 +145,17 @@ static int harddog_ioctl(struct inode *inode, struct file *file, ...@@ -145,17 +145,17 @@ static int harddog_ioctl(struct inode *inode, struct file *file,
} }
static struct file_operations harddog_fops = { static struct file_operations harddog_fops = {
owner: THIS_MODULE, .owner = THIS_MODULE,
write: harddog_write, .write = harddog_write,
ioctl: harddog_ioctl, .ioctl = harddog_ioctl,
open: harddog_open, .open = harddog_open,
release: harddog_release, .release = harddog_release,
}; };
static struct miscdevice harddog_miscdev = { static struct miscdevice harddog_miscdev = {
minor: WATCHDOG_MINOR, .minor = WATCHDOG_MINOR,
name: "watchdog", .name = "watchdog",
fops: &harddog_fops, .fops = &harddog_fops,
}; };
static char banner[] __initdata = KERN_INFO "UML Watchdog Timer\n"; static char banner[] __initdata = KERN_INFO "UML Watchdog Timer\n";
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "helper.h" #include "helper.h"
#include "mconsole.h" #include "mconsole.h"
#include "os.h" #include "os.h"
#include "choose-mode.h"
#include "mode.h"
struct dog_data { struct dog_data {
int stdin; int stdin;
...@@ -63,7 +65,8 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) ...@@ -63,7 +65,8 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
args = mconsole_args; args = mconsole_args;
} }
else { else {
sprintf(pid_buf, "%d", tracing_pid); /* XXX The os_getpid() is not SMP correct */
sprintf(pid_buf, "%d", CHOOSE_MODE(tracing_pid, os_getpid()));
args = pid_args; args = pid_args;
} }
......
...@@ -195,23 +195,23 @@ static int hostmixer_release(struct inode *inode, struct file *file) ...@@ -195,23 +195,23 @@ static int hostmixer_release(struct inode *inode, struct file *file)
/* kernel module operations */ /* kernel module operations */
static struct file_operations hostaudio_fops = { static struct file_operations hostaudio_fops = {
owner: THIS_MODULE, .owner = THIS_MODULE,
llseek: no_llseek, .llseek = no_llseek,
read: hostaudio_read, .read = hostaudio_read,
write: hostaudio_write, .write = hostaudio_write,
poll: hostaudio_poll, .poll = hostaudio_poll,
ioctl: hostaudio_ioctl, .ioctl = hostaudio_ioctl,
mmap: NULL, .mmap = NULL,
open: hostaudio_open, .open = hostaudio_open,
release: hostaudio_release, .release = hostaudio_release,
}; };
static struct file_operations hostmixer_fops = { static struct file_operations hostmixer_fops = {
owner: THIS_MODULE, .owner = THIS_MODULE,
llseek: no_llseek, .llseek = no_llseek,
ioctl: hostmixer_ioctl_mixdev, .ioctl = hostmixer_ioctl_mixdev,
open: hostmixer_open_mixdev, .open = hostmixer_open_mixdev,
release: hostmixer_release, .release = hostmixer_release,
}; };
struct { struct {
......
...@@ -35,7 +35,7 @@ void line_timer_cb(void *arg) ...@@ -35,7 +35,7 @@ void line_timer_cb(void *arg)
line_interrupt(dev->driver->read_irq, dev, NULL); line_interrupt(dev->driver->read_irq, dev, NULL);
} }
void buffer_data(struct line *line, const char *buf, int len) static void buffer_data(struct line *line, const char *buf, int len)
{ {
int end; int end;
...@@ -452,11 +452,19 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver, ...@@ -452,11 +452,19 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver,
void lines_init(struct line *lines, int nlines) void lines_init(struct line *lines, int nlines)
{ {
struct line *line;
int i; int i;
for(i = 0; i < nlines; i++){ for(i = 0; i < nlines; i++){
INIT_LIST_HEAD(&lines[i].chan_list); line = &lines[i];
sema_init(&lines[i].sem, 1); INIT_LIST_HEAD(&line->chan_list);
sema_init(&line->sem, 1);
if(line->init_str != NULL){
line->init_str = uml_strdup(line->init_str);
if(line->init_str == NULL)
printk("lines_init - uml_strdup returned "
"NULL\n");
}
} }
} }
...@@ -511,11 +519,11 @@ void register_winch_irq(int fd, int tty_fd, int pid, void *line) ...@@ -511,11 +519,11 @@ void register_winch_irq(int fd, int tty_fd, int pid, void *line)
printk("register_winch_irq - kmalloc failed\n"); printk("register_winch_irq - kmalloc failed\n");
goto out; goto out;
} }
*winch = ((struct winch) { list : LIST_HEAD_INIT(winch->list), *winch = ((struct winch) { .list = LIST_HEAD_INIT(winch->list),
fd : fd, .fd = fd,
tty_fd : tty_fd, .tty_fd = tty_fd,
pid : pid, .pid = pid,
line : line }); .line = line });
list_add(&winch->list, &winch_handlers); list_add(&winch->list, &winch_handlers);
if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
...@@ -533,7 +541,8 @@ static void winch_cleanup(void) ...@@ -533,7 +541,8 @@ static void winch_cleanup(void)
list_for_each(ele, &winch_handlers){ list_for_each(ele, &winch_handlers){
winch = list_entry(ele, struct winch, list); winch = list_entry(ele, struct winch, list);
close(winch->fd); close(winch->fd);
if(winch->pid != -1) os_kill_process(winch->pid, 0); if(winch->pid != -1)
os_kill_process(winch->pid, 1);
} }
} }
......
...@@ -36,11 +36,11 @@ void mcast_init(struct net_device *dev, void *data) ...@@ -36,11 +36,11 @@ void mcast_init(struct net_device *dev, void *data)
pri = dev->priv; pri = dev->priv;
dpri = (struct mcast_data *) pri->user; dpri = (struct mcast_data *) pri->user;
*dpri = ((struct mcast_data) *dpri = ((struct mcast_data)
{ addr : init->addr, { .addr = init->addr,
port : init->port, .port = init->port,
ttl : init->ttl, .ttl = init->ttl,
mcast_addr : NULL, .mcast_addr = NULL,
dev : dev }); .dev = dev });
printk("mcast backend "); printk("mcast backend ");
printk("multicast adddress: %s:%u, TTL:%u ", printk("multicast adddress: %s:%u, TTL:%u ",
dpri->addr, dpri->port, dpri->ttl); dpri->addr, dpri->port, dpri->ttl);
...@@ -64,10 +64,10 @@ static int mcast_write(int fd, struct sk_buff **skb, ...@@ -64,10 +64,10 @@ static int mcast_write(int fd, struct sk_buff **skb,
} }
static struct net_kern_info mcast_kern_info = { static struct net_kern_info mcast_kern_info = {
init: mcast_init, .init = mcast_init,
protocol: eth_protocol, .protocol = eth_protocol,
read: mcast_read, .read = mcast_read,
write: mcast_write, .write = mcast_write,
}; };
int mcast_setup(char *str, char **mac_out, void *data) int mcast_setup(char *str, char **mac_out, void *data)
...@@ -78,9 +78,9 @@ int mcast_setup(char *str, char **mac_out, void *data) ...@@ -78,9 +78,9 @@ int mcast_setup(char *str, char **mac_out, void *data)
int n; int n;
*init = ((struct mcast_init) *init = ((struct mcast_init)
{ addr : "239.192.168.1", { .addr = "239.192.168.1",
port : 1102, .port = 1102,
ttl : 1 }); .ttl = 1 });
remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str, remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str,
NULL); NULL);
...@@ -116,13 +116,13 @@ int mcast_setup(char *str, char **mac_out, void *data) ...@@ -116,13 +116,13 @@ int mcast_setup(char *str, char **mac_out, void *data)
} }
static struct transport mcast_transport = { static struct transport mcast_transport = {
list : LIST_HEAD_INIT(mcast_transport.list), .list = LIST_HEAD_INIT(mcast_transport.list),
name : "mcast", .name = "mcast",
setup : mcast_setup, .setup = mcast_setup,
user : &mcast_user_info, .user = &mcast_user_info,
kern : &mcast_kern_info, .kern = &mcast_kern_info,
private_size : sizeof(struct mcast_data), .private_size = sizeof(struct mcast_data),
setup_size : sizeof(struct mcast_init), .setup_size = sizeof(struct mcast_init),
}; };
static int register_mcast(void) static int register_mcast(void)
......
...@@ -153,14 +153,14 @@ static int mcast_set_mtu(int mtu, void *data) ...@@ -153,14 +153,14 @@ static int mcast_set_mtu(int mtu, void *data)
} }
struct net_user_info mcast_user_info = { struct net_user_info mcast_user_info = {
init: mcast_user_init, .init = mcast_user_init,
open: mcast_open, .open = mcast_open,
close: mcast_close, .close = mcast_close,
remove: NULL, .remove = NULL,
set_mtu: mcast_set_mtu, .set_mtu = mcast_set_mtu,
add_address: NULL, .add_address = NULL,
delete_address: NULL, .delete_address = NULL,
max_packet: MAX_PACKET - ETH_HEADER_OTHER .max_packet = MAX_PACKET - ETH_HEADER_OTHER
}; };
/* /*
......
...@@ -36,8 +36,8 @@ static int do_unlink_socket(struct notifier_block *notifier, ...@@ -36,8 +36,8 @@ static int do_unlink_socket(struct notifier_block *notifier,
static struct notifier_block reboot_notifier = { static struct notifier_block reboot_notifier = {
notifier_call: do_unlink_socket, .notifier_call = do_unlink_socket,
priority: 0, .priority = 0,
}; };
/* Safe without explicit locking for now. Tasklets provide their own /* Safe without explicit locking for now. Tasklets provide their own
...@@ -418,9 +418,9 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1, ...@@ -418,9 +418,9 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1,
} }
static struct notifier_block panic_exit_notifier = { static struct notifier_block panic_exit_notifier = {
notifier_call : notify_panic, .notifier_call = notify_panic,
next : NULL, .next = NULL,
priority : 1 .priority = 1
}; };
static int add_notifier(void) static int add_notifier(void)
......
...@@ -106,13 +106,13 @@ mmapper_release(struct inode *inode, struct file *file) ...@@ -106,13 +106,13 @@ mmapper_release(struct inode *inode, struct file *file)
} }
static struct file_operations mmapper_fops = { static struct file_operations mmapper_fops = {
owner: THIS_MODULE, .owner = THIS_MODULE,
read: mmapper_read, .read = mmapper_read,
write: mmapper_write, .write = mmapper_write,
ioctl: mmapper_ioctl, .ioctl = mmapper_ioctl,
mmap: mmapper_mmap, .mmap = mmapper_mmap,
open: mmapper_open, .open = mmapper_open,
release: mmapper_release, .release = mmapper_release,
}; };
static int __init mmapper_init(void) static int __init mmapper_init(void)
......
...@@ -368,22 +368,22 @@ static int eth_configure(int n, void *init, char *mac, ...@@ -368,22 +368,22 @@ static int eth_configure(int n, void *init, char *mac,
*/ */
save = lp->user[0]; save = lp->user[0];
*lp = ((struct uml_net_private) *lp = ((struct uml_net_private)
{ list : LIST_HEAD_INIT(lp->list), { .list = LIST_HEAD_INIT(lp->list),
lock : SPIN_LOCK_UNLOCKED, .lock = SPIN_LOCK_UNLOCKED,
dev : dev, .dev = dev,
fd : -1, .fd = -1,
mac : { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0}, .mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
have_mac : device->have_mac, .have_mac = device->have_mac,
protocol : transport->kern->protocol, .protocol = transport->kern->protocol,
open : transport->user->open, .open = transport->user->open,
close : transport->user->close, .close = transport->user->close,
remove : transport->user->remove, .remove = transport->user->remove,
read : transport->kern->read, .read = transport->kern->read,
write : transport->kern->write, .write = transport->kern->write,
add_address : transport->user->add_address, .add_address = transport->user->add_address,
delete_address : transport->user->delete_address, .delete_address = transport->user->delete_address,
set_mtu : transport->user->set_mtu, .set_mtu = transport->user->set_mtu,
user : { save } }); .user = { save } });
init_timer(&lp->tl); init_timer(&lp->tl);
lp->tl.function = uml_net_user_timer_expire; lp->tl.function = uml_net_user_timer_expire;
memset(&lp->stats, 0, sizeof(lp->stats)); memset(&lp->stats, 0, sizeof(lp->stats));
...@@ -542,9 +542,9 @@ static int eth_setup(char *str) ...@@ -542,9 +542,9 @@ static int eth_setup(char *str)
printk("eth_init : alloc_bootmem failed\n"); printk("eth_init : alloc_bootmem failed\n");
return(1); return(1);
} }
*new = ((struct eth_init) { list : LIST_HEAD_INIT(new->list), *new = ((struct eth_init) { .list = LIST_HEAD_INIT(new->list),
index : n, .index = n,
init : str }); .init = str });
list_add_tail(&new->list, &eth_cmd_line); list_add_tail(&new->list, &eth_cmd_line);
return(1); return(1);
} }
...@@ -618,9 +618,10 @@ static int net_remove(char *str) ...@@ -618,9 +618,10 @@ static int net_remove(char *str)
} }
static struct mc_device net_mc = { static struct mc_device net_mc = {
name: "eth", .name = "eth",
config: net_config, .config = net_config,
remove: net_remove, .get_config = NULL,
.remove = net_remove,
}; };
static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
...@@ -662,7 +663,7 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, ...@@ -662,7 +663,7 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event,
} }
struct notifier_block uml_inetaddr_notifier = { struct notifier_block uml_inetaddr_notifier = {
notifier_call: uml_inetaddr_event, .notifier_call = uml_inetaddr_event,
}; };
static int uml_net_init(void) static int uml_net_init(void)
......
...@@ -32,16 +32,16 @@ void null_free(void *data) ...@@ -32,16 +32,16 @@ void null_free(void *data)
} }
struct chan_ops null_ops = { struct chan_ops null_ops = {
type: "null", .type = "null",
init: null_init, .init = null_init,
open: null_open, .open = null_open,
close: generic_close, .close = generic_close,
read: null_read, .read = null_read,
write: generic_write, .write = generic_write,
console_write: generic_console_write, .console_write = generic_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: null_free, .free = null_free,
winch: 0, .winch = 0,
}; };
/* /*
......
...@@ -27,12 +27,12 @@ void pcap_init(struct net_device *dev, void *data) ...@@ -27,12 +27,12 @@ void pcap_init(struct net_device *dev, void *data)
pri = dev->priv; pri = dev->priv;
ppri = (struct pcap_data *) pri->user; ppri = (struct pcap_data *) pri->user;
*ppri = ((struct pcap_data) *ppri = ((struct pcap_data)
{ host_if : init->host_if, { .host_if = init->host_if,
promisc : init->promisc, .promisc = init->promisc,
optimize : init->optimize, .optimize = init->optimize,
filter : init->filter, .filter = init->filter,
compiled : NULL, .compiled = NULL,
pcap : NULL }); .pcap = NULL });
} }
static int pcap_read(int fd, struct sk_buff **skb, static int pcap_read(int fd, struct sk_buff **skb,
...@@ -51,10 +51,10 @@ static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) ...@@ -51,10 +51,10 @@ static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
} }
static struct net_kern_info pcap_kern_info = { static struct net_kern_info pcap_kern_info = {
init: pcap_init, .init = pcap_init,
protocol: eth_protocol, .protocol = eth_protocol,
read: pcap_read, .read = pcap_read,
write: pcap_write, .write = pcap_write,
}; };
int pcap_setup(char *str, char **mac_out, void *data) int pcap_setup(char *str, char **mac_out, void *data)
...@@ -64,10 +64,10 @@ int pcap_setup(char *str, char **mac_out, void *data) ...@@ -64,10 +64,10 @@ int pcap_setup(char *str, char **mac_out, void *data)
int i; int i;
*init = ((struct pcap_init) *init = ((struct pcap_init)
{ host_if : "eth0", { .host_if = "eth0",
promisc : 1, .promisc = 1,
optimize : 0, .optimize = 0,
filter : NULL }); .filter = NULL });
remain = split_if_spec(str, &host_if, &init->filter, remain = split_if_spec(str, &host_if, &init->filter,
&options[0], &options[1], NULL); &options[0], &options[1], NULL);
...@@ -98,13 +98,13 @@ int pcap_setup(char *str, char **mac_out, void *data) ...@@ -98,13 +98,13 @@ int pcap_setup(char *str, char **mac_out, void *data)
} }
static struct transport pcap_transport = { static struct transport pcap_transport = {
list : LIST_HEAD_INIT(pcap_transport.list), .list = LIST_HEAD_INIT(pcap_transport.list),
name : "pcap", .name = "pcap",
setup : pcap_setup, .setup = pcap_setup,
user : &pcap_user_info, .user = &pcap_user_info,
kern : &pcap_kern_info, .kern = &pcap_kern_info,
private_size : sizeof(struct pcap_data), .private_size = sizeof(struct pcap_data),
setup_size : sizeof(struct pcap_init), .setup_size = sizeof(struct pcap_init),
}; };
static int register_pcap(void) static int register_pcap(void)
......
...@@ -106,8 +106,8 @@ static void handler(u_char *data, const struct pcap_pkthdr *header, ...@@ -106,8 +106,8 @@ static void handler(u_char *data, const struct pcap_pkthdr *header,
int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
{ {
struct pcap_handler_data hdata = ((struct pcap_handler_data) struct pcap_handler_data hdata = ((struct pcap_handler_data)
{ buffer : buffer, { .buffer = buffer,
len : len }); .len = len });
int n; int n;
n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata);
...@@ -121,14 +121,14 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) ...@@ -121,14 +121,14 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
} }
struct net_user_info pcap_user_info = { struct net_user_info pcap_user_info = {
init: pcap_user_init, .init = pcap_user_init,
open: pcap_open, .open = pcap_open,
close: NULL, .close = NULL,
remove: pcap_remove, .remove = pcap_remove,
set_mtu: NULL, .set_mtu = NULL,
add_address: NULL, .add_address = NULL,
delete_address: NULL, .delete_address = NULL,
max_packet: MAX_PACKET - ETH_HEADER_OTHER .max_packet = MAX_PACKET - ETH_HEADER_OTHER
}; };
/* /*
......
...@@ -31,7 +31,6 @@ struct port_list { ...@@ -31,7 +31,6 @@ struct port_list {
struct port_dev { struct port_dev {
struct port_list *port; struct port_list *port;
int fd;
int helper_pid; int helper_pid;
int telnetd_pid; int telnetd_pid;
}; };
...@@ -55,7 +54,8 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs) ...@@ -55,7 +54,8 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
if(fd == -EAGAIN) if(fd == -EAGAIN)
return; return;
printk("os_rcv_fd returned %d\n", -fd); printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
-fd);
os_close_file(conn->fd); os_close_file(conn->fd);
} }
...@@ -75,37 +75,42 @@ static int port_accept(struct port_list *port) ...@@ -75,37 +75,42 @@ static int port_accept(struct port_list *port)
fd = port_connection(port->fd, socket, &pid); fd = port_connection(port->fd, socket, &pid);
if(fd < 0){ if(fd < 0){
if(fd != -EAGAIN) if(fd != -EAGAIN)
printk("port_connection returned %d\n", -fd); printk(KERN_ERR "port_accept : port_connection "
"returned %d\n", -fd);
goto out; goto out;
} }
conn = kmalloc(sizeof(*conn), GFP_ATOMIC); conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
if(conn == NULL){ if(conn == NULL){
printk("port_interrupt : failed to allocate connection\n"); printk(KERN_ERR "port_accept : failed to allocate "
"connection\n");
goto out_close; goto out_close;
} }
*conn = ((struct connection) *conn = ((struct connection)
{ list : LIST_HEAD_INIT(conn->list), { .list = LIST_HEAD_INIT(conn->list),
fd : fd, .fd = fd,
socket : { socket[0], socket[1] }, .socket = { socket[0], socket[1] },
telnetd_pid : pid, .telnetd_pid = pid,
port : port }); .port = port });
if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
"telnetd", conn)){ "telnetd", conn)){
printk(KERN_ERR "Failed to get IRQ for telnetd\n"); printk(KERN_ERR "port_accept : failed to get IRQ for "
"telnetd\n");
goto out_free; goto out_free;
} }
list_add(&conn->list, &port->pending); list_add(&conn->list, &port->pending);
return(1); ret = 1;
goto out;
out_free: out_free:
kfree(conn); kfree(conn);
out_close: out_close:
os_close_file(fd); os_close_file(fd);
if(pid != -1) os_kill_process(pid, 0); if(pid != -1)
os_kill_process(pid, 1);
out: out:
return(ret); return(ret);
} }
...@@ -173,14 +178,15 @@ void *port_data(int port_num) ...@@ -173,14 +178,15 @@ void *port_data(int port_num)
} }
*port = ((struct port_list) *port = ((struct port_list)
{ list : LIST_HEAD_INIT(port->list), { .list = LIST_HEAD_INIT(port->list),
has_connection : 0, .has_connection = 0,
sem : __SEMAPHORE_INITIALIZER(port->sem, 0), .sem = __SEMAPHORE_INITIALIZER(port->sem,
lock : SPIN_LOCK_UNLOCKED, 0),
port : port_num, .lock = SPIN_LOCK_UNLOCKED,
fd : fd, .port = port_num,
pending : LIST_HEAD_INIT(port->pending), .fd = fd,
connections : LIST_HEAD_INIT(port->connections) }); .pending = LIST_HEAD_INIT(port->pending),
.connections = LIST_HEAD_INIT(port->connections) });
list_add(&port->list, &ports); list_add(&port->list, &ports);
found: found:
...@@ -190,9 +196,9 @@ void *port_data(int port_num) ...@@ -190,9 +196,9 @@ void *port_data(int port_num)
goto out; goto out;
} }
*dev = ((struct port_dev) { port : port, *dev = ((struct port_dev) { .port = port,
fd : -1, .helper_pid = -1,
helper_pid : -1 }); .telnetd_pid = -1 });
goto out; goto out;
out_free: out_free:
...@@ -204,38 +210,16 @@ void *port_data(int port_num) ...@@ -204,38 +210,16 @@ void *port_data(int port_num)
return(dev); return(dev);
} }
void port_remove_dev(void *d)
{
struct port_dev *dev = d;
if(dev->helper_pid != -1)
os_kill_process(dev->helper_pid, 0);
if(dev->telnetd_pid != -1)
os_kill_process(dev->telnetd_pid, 0);
dev->helper_pid = -1;
}
static void free_port(void)
{
struct list_head *ele;
struct port_list *port;
list_for_each(ele, &ports){
port = list_entry(ele, struct port_list, list);
os_close_file(port->fd);
}
}
__uml_exitcall(free_port);
int port_wait(void *data) int port_wait(void *data)
{ {
struct port_dev *dev = data; struct port_dev *dev = data;
struct connection *conn; struct connection *conn;
struct port_list *port = dev->port; struct port_list *port = dev->port;
int fd;
while(1){ while(1){
if(down_interruptible(&port->sem)) return(-ERESTARTSYS); if(down_interruptible(&port->sem))
return(-ERESTARTSYS);
spin_lock(&port->lock); spin_lock(&port->lock);
...@@ -262,23 +246,48 @@ int port_wait(void *data) ...@@ -262,23 +246,48 @@ int port_wait(void *data)
kfree(conn); kfree(conn);
} }
dev->fd = conn->fd; fd = conn->fd;
dev->helper_pid = conn->helper_pid; dev->helper_pid = conn->helper_pid;
dev->telnetd_pid = conn->telnetd_pid; dev->telnetd_pid = conn->telnetd_pid;
kfree(conn); kfree(conn);
return(dev->fd); return(fd);
}
void port_remove_dev(void *d)
{
struct port_dev *dev = d;
if(dev->helper_pid != -1)
os_kill_process(dev->helper_pid, 0);
if(dev->telnetd_pid != -1)
os_kill_process(dev->telnetd_pid, 1);
dev->helper_pid = -1;
dev->telnetd_pid = -1;
} }
void port_kern_free(void *d) void port_kern_free(void *d)
{ {
struct port_dev *dev = d; struct port_dev *dev = d;
if(dev->helper_pid != -1) os_kill_process(dev->helper_pid, 0); port_remove_dev(dev);
if(dev->telnetd_pid != -1) os_kill_process(dev->telnetd_pid, 0);
kfree(dev); kfree(dev);
} }
static void free_port(void)
{
struct list_head *ele;
struct port_list *port;
list_for_each(ele, &ports){
port = list_entry(ele, struct port_list, list);
free_irq_by_fd(port->fd);
os_close_file(port->fd);
}
}
__uml_exitcall(free_port);
/* /*
* Overrides for Emacs so that we follow Linus's tabbing style. * Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically * Emacs will notice this stuff at the end of the file and automatically
......
...@@ -47,14 +47,28 @@ void *port_init(char *str, int device, struct chan_opts *opts) ...@@ -47,14 +47,28 @@ void *port_init(char *str, int device, struct chan_opts *opts)
return(NULL); return(NULL);
} }
if((kern_data = port_data(port)) == NULL) return(NULL); if((kern_data = port_data(port)) == NULL)
return(NULL);
if((data = um_kmalloc(sizeof(*data))) == NULL)
goto err;
if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL); *data = ((struct port_chan) { .raw = opts->raw,
*data = ((struct port_chan) { raw : opts->raw, .kernel_data = kern_data });
kernel_data : kern_data });
sprintf(data->dev, "%d", port); sprintf(data->dev, "%d", port);
return(data); return(data);
err:
port_kern_free(kern_data);
return(NULL);
}
void port_free(void *d)
{
struct port_chan *data = d;
port_kern_free(data->kernel_data);
kfree(data);
} }
int port_open(int input, int output, int primary, void *d, char **dev_out) int port_open(int input, int output, int primary, void *d, char **dev_out)
...@@ -86,25 +100,17 @@ int port_console_write(int fd, const char *buf, int n, void *d) ...@@ -86,25 +100,17 @@ int port_console_write(int fd, const char *buf, int n, void *d)
return(generic_console_write(fd, buf, n, &data->tt)); return(generic_console_write(fd, buf, n, &data->tt));
} }
void port_free(void *d)
{
struct port_chan *data = d;
port_kern_free(data->kernel_data);
kfree(data);
}
struct chan_ops port_ops = { struct chan_ops port_ops = {
type: "port", .type = "port",
init: port_init, .init = port_init,
open: port_open, .open = port_open,
close: port_close, .close = port_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: port_console_write, .console_write = port_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: port_free, .free = port_free,
winch: 1, .winch = 1,
}; };
int port_listen_fd(int port) int port_listen_fd(int port)
...@@ -113,7 +119,8 @@ int port_listen_fd(int port) ...@@ -113,7 +119,8 @@ int port_listen_fd(int port)
int fd, err; int fd, err;
fd = socket(PF_INET, SOCK_STREAM, 0); fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) return(-errno); if(fd == -1)
return(-errno);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
...@@ -163,14 +170,16 @@ int port_connection(int fd, int *socket, int *pid_out) ...@@ -163,14 +170,16 @@ int port_connection(int fd, int *socket, int *pid_out)
return(-errno); return(-errno);
err = os_pipe(socket, 0, 0); err = os_pipe(socket, 0, 0);
if(err) goto out_close; if(err)
goto out_close;
data = ((struct port_pre_exec_data) data = ((struct port_pre_exec_data)
{ sock_fd : new, { .sock_fd = new,
pipe_fd : socket[1] }); .pipe_fd = socket[1] });
err = run_helper(port_pre_exec, &data, argv, NULL); err = run_helper(port_pre_exec, &data, argv, NULL);
if(err < 0) goto out_shutdown; if(err < 0)
goto out_shutdown;
*pid_out = err; *pid_out = err;
return(new); return(new);
......
/* /*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -27,9 +27,9 @@ void *pty_chan_init(char *str, int device, struct chan_opts *opts) ...@@ -27,9 +27,9 @@ void *pty_chan_init(char *str, int device, struct chan_opts *opts)
struct pty_chan *data; struct pty_chan *data;
if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL); if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
*data = ((struct pty_chan) { announce : opts->announce, *data = ((struct pty_chan) { .announce = opts->announce,
dev : device, .dev = device,
raw : opts->raw }); .raw = opts->raw });
return(data); return(data);
} }
...@@ -86,34 +86,15 @@ int getmaster(char *line) ...@@ -86,34 +86,15 @@ int getmaster(char *line)
return(-1); return(-1);
} }
struct grantpt_info {
int fd;
int res;
int err;
};
static void grantpt_cb(void *arg)
{
struct grantpt_info *info = arg;
info->res = grantpt(info->fd);
info->err = errno;
}
int pty_open(int input, int output, int primary, void *d, char **dev_out) int pty_open(int input, int output, int primary, void *d, char **dev_out)
{ {
struct pty_chan *data = d; struct pty_chan *data = d;
int fd; int fd;
char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx"; char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx";
struct grantpt_info info;
fd = getmaster(dev); fd = getmaster(dev);
if(fd < 0) return(-errno); if(fd < 0) return(-errno);
info.fd = fd;
initial_thread_cb(grantpt_cb, &info);
unlockpt(fd);
if(data->raw) raw(fd, 0); if(data->raw) raw(fd, 0);
if(data->announce) (*data->announce)(dev, data->dev); if(data->announce) (*data->announce)(dev, data->dev);
...@@ -130,29 +111,29 @@ int pty_console_write(int fd, const char *buf, int n, void *d) ...@@ -130,29 +111,29 @@ int pty_console_write(int fd, const char *buf, int n, void *d)
} }
struct chan_ops pty_ops = { struct chan_ops pty_ops = {
type: "pty", .type = "pty",
init: pty_chan_init, .init = pty_chan_init,
open: pty_open, .open = pty_open,
close: generic_close, .close = generic_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: pty_console_write, .console_write = pty_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: generic_free, .free = generic_free,
winch: 0, .winch = 0,
}; };
struct chan_ops pts_ops = { struct chan_ops pts_ops = {
type: "pts", .type = "pts",
init: pty_chan_init, .init = pty_chan_init,
open: pts_open, .open = pts_open,
close: generic_close, .close = generic_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: pty_console_write, .console_write = pty_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: generic_free, .free = generic_free,
winch: 0, .winch = 0,
}; };
/* /*
......
...@@ -22,15 +22,15 @@ void slip_init(struct net_device *dev, void *data) ...@@ -22,15 +22,15 @@ void slip_init(struct net_device *dev, void *data)
private = dev->priv; private = dev->priv;
spri = (struct slip_data *) private->user; spri = (struct slip_data *) private->user;
*spri = ((struct slip_data) *spri = ((struct slip_data)
{ name : { '\0' }, { .name = { '\0' },
addr: NULL, .addr = NULL,
gate_addr : init->gate_addr, .gate_addr = init->gate_addr,
slave : -1, .slave = -1,
ibuf : { '\0' }, .ibuf = { '\0' },
obuf : { '\0' }, .obuf = { '\0' },
pos : 0, .pos = 0,
esc : 0, .esc = 0,
dev : dev }); .dev = dev });
dev->init = NULL; dev->init = NULL;
dev->hard_header_len = 0; dev->hard_header_len = 0;
...@@ -61,10 +61,10 @@ static int slip_write(int fd, struct sk_buff **skb, ...@@ -61,10 +61,10 @@ static int slip_write(int fd, struct sk_buff **skb,
} }
struct net_kern_info slip_kern_info = { struct net_kern_info slip_kern_info = {
init: slip_init, .init = slip_init,
protocol: slip_protocol, .protocol = slip_protocol,
read: slip_read, .read = slip_read,
write: slip_write, .write = slip_write,
}; };
static int slip_setup(char *str, char **mac_out, void *data) static int slip_setup(char *str, char **mac_out, void *data)
...@@ -72,7 +72,7 @@ static int slip_setup(char *str, char **mac_out, void *data) ...@@ -72,7 +72,7 @@ static int slip_setup(char *str, char **mac_out, void *data)
struct slip_init *init = data; struct slip_init *init = data;
*init = ((struct slip_init) *init = ((struct slip_init)
{ gate_addr : NULL }); { .gate_addr = NULL });
if(str[0] != '\0') if(str[0] != '\0')
init->gate_addr = str; init->gate_addr = str;
...@@ -80,13 +80,13 @@ static int slip_setup(char *str, char **mac_out, void *data) ...@@ -80,13 +80,13 @@ static int slip_setup(char *str, char **mac_out, void *data)
} }
static struct transport slip_transport = { static struct transport slip_transport = {
list : LIST_HEAD_INIT(slip_transport.list), .list = LIST_HEAD_INIT(slip_transport.list),
name : "slip", .name = "slip",
setup : slip_setup, .setup = slip_setup,
user : &slip_user_info, .user = &slip_user_info,
kern : &slip_kern_info, .kern = &slip_kern_info,
private_size : sizeof(struct slip_data), .private_size = sizeof(struct slip_data),
setup_size : sizeof(struct slip_init), .setup_size = sizeof(struct slip_init),
}; };
static int register_slip(void) static int register_slip(void)
......
...@@ -257,14 +257,14 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask, ...@@ -257,14 +257,14 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
} }
struct net_user_info slip_user_info = { struct net_user_info slip_user_info = {
init: slip_user_init, .init = slip_user_init,
open: slip_open, .open = slip_open,
close: slip_close, .close = slip_close,
remove: NULL, .remove = NULL,
set_mtu: slip_set_mtu, .set_mtu = slip_set_mtu,
add_address: slip_add_addr, .add_address = slip_add_addr,
delete_address: slip_del_addr, .delete_address = slip_del_addr,
max_packet: BUF_SIZE .max_packet = BUF_SIZE
}; };
/* /*
......
...@@ -22,14 +22,14 @@ void slirp_init(struct net_device *dev, void *data) ...@@ -22,14 +22,14 @@ void slirp_init(struct net_device *dev, void *data)
private = dev->priv; private = dev->priv;
spri = (struct slirp_data *) private->user; spri = (struct slirp_data *) private->user;
*spri = ((struct slirp_data) *spri = ((struct slirp_data)
{ argw : init->argw, { .argw = init->argw,
pid : -1, .pid = -1,
slave : -1, .slave = -1,
ibuf : { '\0' }, .ibuf = { '\0' },
obuf : { '\0' }, .obuf = { '\0' },
pos : 0, .pos = 0,
esc : 0, .esc = 0,
dev : dev }); .dev = dev });
dev->init = NULL; dev->init = NULL;
dev->hard_header_len = 0; dev->hard_header_len = 0;
...@@ -64,10 +64,10 @@ static int slirp_write(int fd, struct sk_buff **skb, ...@@ -64,10 +64,10 @@ static int slirp_write(int fd, struct sk_buff **skb,
} }
struct net_kern_info slirp_kern_info = { struct net_kern_info slirp_kern_info = {
init: slirp_init, .init = slirp_init,
protocol: slirp_protocol, .protocol = slirp_protocol,
read: slirp_read, .read = slirp_read,
write: slirp_write, .write = slirp_write,
}; };
static int slirp_setup(char *str, char **mac_out, void *data) static int slirp_setup(char *str, char **mac_out, void *data)
...@@ -103,13 +103,13 @@ static int slirp_setup(char *str, char **mac_out, void *data) ...@@ -103,13 +103,13 @@ static int slirp_setup(char *str, char **mac_out, void *data)
} }
static struct transport slirp_transport = { static struct transport slirp_transport = {
list : LIST_HEAD_INIT(slirp_transport.list), .list = LIST_HEAD_INIT(slirp_transport.list),
name : "slirp", .name = "slirp",
setup : slirp_setup, .setup = slirp_setup,
user : &slirp_user_info, .user = &slirp_user_info,
kern : &slirp_kern_info, .kern = &slirp_kern_info,
private_size : sizeof(struct slirp_data), .private_size = sizeof(struct slirp_data),
setup_size : sizeof(struct slirp_init), .setup_size = sizeof(struct slirp_init),
}; };
static int register_slirp(void) static int register_slirp(void)
......
...@@ -180,14 +180,14 @@ static int slirp_set_mtu(int mtu, void *data) ...@@ -180,14 +180,14 @@ static int slirp_set_mtu(int mtu, void *data)
} }
struct net_user_info slirp_user_info = { struct net_user_info slirp_user_info = {
init: slirp_user_init, .init = slirp_user_init,
open: slirp_open, .open = slirp_open,
close: slirp_close, .close = slirp_close,
remove: NULL, .remove = NULL,
set_mtu: slirp_set_mtu, .set_mtu = slirp_set_mtu,
add_address: NULL, .add_address = NULL,
delete_address: NULL, .delete_address = NULL,
max_packet: BUF_SIZE .max_packet = BUF_SIZE
}; };
/* /*
......
...@@ -41,11 +41,11 @@ void ssl_announce(char *dev_name, int dev) ...@@ -41,11 +41,11 @@ void ssl_announce(char *dev_name, int dev)
} }
static struct chan_opts opts = { static struct chan_opts opts = {
announce: ssl_announce, .announce = ssl_announce,
xterm_title: "Serial Line #%d", .xterm_title = "Serial Line #%d",
raw: 1, .raw = 1,
tramp_stack : 0, .tramp_stack = 0,
in_kernel : 1, .in_kernel = 1,
}; };
static int ssl_config(char *str); static int ssl_config(char *str);
...@@ -53,23 +53,23 @@ static int ssl_get_config(char *dev, char *str, int size, char **error_out); ...@@ -53,23 +53,23 @@ static int ssl_get_config(char *dev, char *str, int size, char **error_out);
static int ssl_remove(char *str); static int ssl_remove(char *str);
static struct line_driver driver = { static struct line_driver driver = {
name : "UML serial line", .name = "UML serial line",
devfs_name : "tts/%d", .devfs_name = "tts/%d",
major : TTYAUX_MAJOR, .major = TTYAUX_MAJOR,
minor_start : 64, .minor_start = 64,
type : TTY_DRIVER_TYPE_SERIAL, .type = TTY_DRIVER_TYPE_SERIAL,
subtype : 0, .subtype = 0,
read_irq : SSL_IRQ, .read_irq = SSL_IRQ,
read_irq_name : "ssl", .read_irq_name = "ssl",
write_irq : SSL_WRITE_IRQ, .write_irq = SSL_WRITE_IRQ,
write_irq_name : "ssl-write", .write_irq_name = "ssl-write",
symlink_from : "serial", .symlink_from = "serial",
symlink_to : "tts", .symlink_to = "tts",
mc : { .mc = {
name : "ssl", .name = "ssl",
config : ssl_config, .config = ssl_config,
get_config : ssl_get_config, .get_config = ssl_get_config,
remove : ssl_remove, .remove = ssl_remove,
}, },
}; };
...@@ -191,21 +191,21 @@ void ssl_hangup(struct tty_struct *tty) ...@@ -191,21 +191,21 @@ void ssl_hangup(struct tty_struct *tty)
} }
static struct tty_driver ssl_driver = { static struct tty_driver ssl_driver = {
refcount : &ssl_refcount, .refcount = &ssl_refcount,
open : ssl_open, .open = ssl_open,
close : ssl_close, .close = ssl_close,
write : ssl_write, .write = ssl_write,
put_char : ssl_put_char, .put_char = ssl_put_char,
flush_chars : ssl_flush_chars, .flush_chars = ssl_flush_chars,
chars_in_buffer : ssl_chars_in_buffer, .chars_in_buffer = ssl_chars_in_buffer,
flush_buffer : ssl_flush_buffer, .flush_buffer = ssl_flush_buffer,
ioctl : ssl_ioctl, .ioctl = ssl_ioctl,
throttle : ssl_throttle, .throttle = ssl_throttle,
unthrottle : ssl_unthrottle, .unthrottle = ssl_unthrottle,
set_termios : ssl_set_termios, .set_termios = ssl_set_termios,
stop : ssl_stop, .stop = ssl_stop,
start : ssl_start, .start = ssl_start,
hangup : ssl_hangup .hangup = ssl_hangup
}; };
/* Changed by ssl_init and referenced by ssl_exit, which are both serialized /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
......
...@@ -42,28 +42,28 @@ static struct tty_driver console_driver; ...@@ -42,28 +42,28 @@ static struct tty_driver console_driver;
static int console_refcount = 0; static int console_refcount = 0;
static struct chan_ops init_console_ops = { static struct chan_ops init_console_ops = {
type: "you shouldn't see this", .type = "you shouldn't see this",
init : NULL, .init = NULL,
open : NULL, .open = NULL,
close : NULL, .close = NULL,
read : NULL, .read = NULL,
write : NULL, .write = NULL,
console_write : generic_write, .console_write = generic_write,
window_size : NULL, .window_size = NULL,
free : NULL, .free = NULL,
winch: 0, .winch = 0,
}; };
static struct chan init_console_chan = { static struct chan init_console_chan = {
list : { }, .list = { },
primary : 1, .primary = 1,
input : 0, .input = 0,
output : 1, .output = 1,
opened : 1, .opened = 1,
fd : 1, .fd = 1,
pri : INIT_STATIC, .pri = INIT_STATIC,
ops : &init_console_ops, .ops = &init_console_ops,
data : NULL .data = NULL
}; };
void stdio_announce(char *dev_name, int dev) void stdio_announce(char *dev_name, int dev)
...@@ -73,11 +73,11 @@ void stdio_announce(char *dev_name, int dev) ...@@ -73,11 +73,11 @@ void stdio_announce(char *dev_name, int dev)
} }
static struct chan_opts opts = { static struct chan_opts opts = {
announce: stdio_announce, .announce = stdio_announce,
xterm_title: "Virtual Console #%d", .xterm_title = "Virtual Console #%d",
raw: 1, .raw = 1,
tramp_stack : 0, .tramp_stack = 0,
in_kernel : 1, .in_kernel = 1,
}; };
static int con_config(char *str); static int con_config(char *str);
...@@ -85,23 +85,23 @@ static int con_get_config(char *dev, char *str, int size, char **error_out); ...@@ -85,23 +85,23 @@ static int con_get_config(char *dev, char *str, int size, char **error_out);
static int con_remove(char *str); static int con_remove(char *str);
static struct line_driver driver = { static struct line_driver driver = {
name : "UML console", .name = "UML console",
devfs_name : "vc/%d", .devfs_name = "vc/%d",
major : TTY_MAJOR, .major = TTY_MAJOR,
minor_start : 0, .minor_start = 0,
type : TTY_DRIVER_TYPE_CONSOLE, .type = TTY_DRIVER_TYPE_CONSOLE,
subtype : SYSTEM_TYPE_CONSOLE, .subtype = SYSTEM_TYPE_CONSOLE,
read_irq : CONSOLE_IRQ, .read_irq = CONSOLE_IRQ,
read_irq_name : "console", .read_irq_name = "console",
write_irq : CONSOLE_WRITE_IRQ, .write_irq = CONSOLE_WRITE_IRQ,
write_irq_name : "console-write", .write_irq_name = "console-write",
symlink_from : "ttys", .symlink_from = "ttys",
symlink_to : "vc", .symlink_to = "vc",
mc : { .mc = {
name : "con", .name = "con",
config : con_config, .config = con_config,
get_config : con_get_config, .get_config = con_get_config,
remove : con_remove, .remove = con_remove,
}, },
}; };
...@@ -192,12 +192,12 @@ static void console_write(struct console *console, const char *string, ...@@ -192,12 +192,12 @@ static void console_write(struct console *console, const char *string,
} }
static struct tty_driver console_driver = { static struct tty_driver console_driver = {
refcount : &console_refcount, .refcount = &console_refcount,
open : con_open, .open = con_open,
close : con_close, .close = con_close,
write : con_write, .write = con_write,
chars_in_buffer : chars_in_buffer, .chars_in_buffer = chars_in_buffer,
set_termios : set_termios .set_termios = set_termios
}; };
static kdev_t console_device(struct console *c) static kdev_t console_device(struct console *c)
......
...@@ -32,8 +32,8 @@ void *tty_chan_init(char *str, int device, struct chan_opts *opts) ...@@ -32,8 +32,8 @@ void *tty_chan_init(char *str, int device, struct chan_opts *opts)
if((data = um_kmalloc(sizeof(*data))) == NULL) if((data = um_kmalloc(sizeof(*data))) == NULL)
return(NULL); return(NULL);
*data = ((struct tty_chan) { dev : str, *data = ((struct tty_chan) { .dev = str,
raw : opts->raw }); .raw = opts->raw });
return(data); return(data);
} }
...@@ -62,16 +62,16 @@ int tty_console_write(int fd, const char *buf, int n, void *d) ...@@ -62,16 +62,16 @@ int tty_console_write(int fd, const char *buf, int n, void *d)
} }
struct chan_ops tty_ops = { struct chan_ops tty_ops = {
type: "tty", .type = "tty",
init: tty_chan_init, .init = tty_chan_init,
open: tty_open, .open = tty_open,
close: generic_close, .close = generic_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: tty_console_write, .console_write = tty_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: generic_free, .free = generic_free,
winch: 0, .winch = 0,
}; };
/* /*
......
...@@ -77,9 +77,11 @@ static struct gendisk *ubd_gendisk[MAX_DEV]; ...@@ -77,9 +77,11 @@ static struct gendisk *ubd_gendisk[MAX_DEV];
static struct gendisk *fake_gendisk[MAX_DEV]; static struct gendisk *fake_gendisk[MAX_DEV];
#ifdef CONFIG_BLK_DEV_UBD_SYNC #ifdef CONFIG_BLK_DEV_UBD_SYNC
#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0 }) #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
.cl = 1 })
#else #else
#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0 }) #define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 0, .c = 0, \
.cl = 1 })
#endif #endif
/* Not protected - changed only in ubd_setup_common and then only to /* Not protected - changed only in ubd_setup_common and then only to
...@@ -177,6 +179,8 @@ static void make_ide_entries(char *dev_name) ...@@ -177,6 +179,8 @@ static void make_ide_entries(char *dev_name)
if(proc_ide_root == NULL) make_proc_ide(); if(proc_ide_root == NULL) make_proc_ide();
dir = proc_mkdir(dev_name, proc_ide); dir = proc_mkdir(dev_name, proc_ide);
if(!dir) return;
ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir); ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir);
if(!ent) return; if(!ent) return;
ent->nlink = 1; ent->nlink = 1;
...@@ -405,7 +409,8 @@ static int io_pid = -1; ...@@ -405,7 +409,8 @@ static int io_pid = -1;
void kill_io_thread(void) void kill_io_thread(void)
{ {
if(io_pid != -1) kill(io_pid, SIGKILL); if(io_pid != -1)
os_kill_process(io_pid, 1);
} }
__uml_exitcall(kill_io_thread); __uml_exitcall(kill_io_thread);
......
...@@ -37,13 +37,13 @@ void *xterm_init(char *str, int device, struct chan_opts *opts) ...@@ -37,13 +37,13 @@ void *xterm_init(char *str, int device, struct chan_opts *opts)
struct xterm_chan *data; struct xterm_chan *data;
if((data = malloc(sizeof(*data))) == NULL) return(NULL); if((data = malloc(sizeof(*data))) == NULL) return(NULL);
*data = ((struct xterm_chan) { pid : -1, *data = ((struct xterm_chan) { .pid = -1,
helper_pid : -1, .helper_pid = -1,
device : device, .device = device,
title : opts->xterm_title, .title = opts->xterm_title,
raw : opts->raw, .raw = opts->raw,
stack : opts->tramp_stack, .stack = opts->tramp_stack,
direct_rcv : !opts->in_kernel } ); .direct_rcv = !opts->in_kernel } );
return(data); return(data);
} }
...@@ -137,7 +137,7 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) ...@@ -137,7 +137,7 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out)
} }
if(new < 0){ if(new < 0){
printk("xterm_open : os_rcv_fd failed, errno = %d\n", -new); printk("xterm_open : os_rcv_fd failed, errno = %d\n", -new);
return(new); goto out;
} }
tcgetattr(new, &data->tt); tcgetattr(new, &data->tt);
...@@ -145,6 +145,8 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) ...@@ -145,6 +145,8 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out)
data->pid = pid; data->pid = pid;
*dev_out = NULL; *dev_out = NULL;
out:
unlink(file);
return(new); return(new);
} }
...@@ -152,9 +154,11 @@ void xterm_close(int fd, void *d) ...@@ -152,9 +154,11 @@ void xterm_close(int fd, void *d)
{ {
struct xterm_chan *data = d; struct xterm_chan *data = d;
if(data->pid != -1) kill(data->pid, SIGKILL); if(data->pid != -1)
os_kill_process(data->pid, 1);
data->pid = -1; data->pid = -1;
if(data->helper_pid != -1) kill(data->helper_pid, SIGKILL); if(data->helper_pid != -1)
os_kill_process(data->helper_pid, 0);
data->helper_pid = -1; data->helper_pid = -1;
close(fd); close(fd);
} }
...@@ -172,16 +176,16 @@ int xterm_console_write(int fd, const char *buf, int n, void *d) ...@@ -172,16 +176,16 @@ int xterm_console_write(int fd, const char *buf, int n, void *d)
} }
struct chan_ops xterm_ops = { struct chan_ops xterm_ops = {
type: "xterm", .type = "xterm",
init: xterm_init, .init = xterm_init,
open: xterm_open, .open = xterm_open,
close: xterm_close, .close = xterm_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: xterm_console_write, .console_write = xterm_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: xterm_free, .free = xterm_free,
winch: 1, .winch = 1,
}; };
/* /*
......
...@@ -39,21 +39,21 @@ int xterm_fd(int socket, int *pid_out) ...@@ -39,21 +39,21 @@ int xterm_fd(int socket, int *pid_out)
data = kmalloc(sizeof(*data), GFP_KERNEL); data = kmalloc(sizeof(*data), GFP_KERNEL);
if(data == NULL){ if(data == NULL){
printk(KERN_ERR "xterm_fd - failed to allocate semaphore\n"); printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
return(-ENOMEM); return(-ENOMEM);
} }
*data = ((struct xterm_wait) *data = ((struct xterm_wait)
{ sem : __SEMAPHORE_INITIALIZER(data->sem, 0), { .sem = __SEMAPHORE_INITIALIZER(data->sem, 0),
fd : socket, .fd = socket,
pid : -1, .pid = -1,
new_fd : -1 }); .new_fd = -1 });
err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt, err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
"xterm", data); "xterm", data);
if(err){ if(err){
printk(KERN_ERR "Failed to get IRQ for xterm, err = %d\n", printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
err); "err = %d\n", err);
return(err); return(err);
} }
down(&data->sem); down(&data->sem);
......
OUTPUT_FORMAT(ELF_FORMAT)
OUTPUT_ARCH(ELF_ARCH)
ENTRY(_start)
jiffies = jiffies_64;
SEARCH_DIR("/usr/local/i686-pc-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
. = START + SIZEOF_HEADERS;
.interp : { *(.interp) }
. = ALIGN(4096);
__binary_start = .;
. = ALIGN(4096); /* Init code and data */
_stext = .;
__init_begin = .;
.text.init : { *(.text.init) }
. = ALIGN(4096);
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : {
KEEP (*(.init))
} =0x90909090
.plt : { *(.plt) }
.text : {
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0x90909090
.fini : {
KEEP (*(.fini))
} =0x90909090
.kstrtab : { *(.kstrtab) }
#include "asm/common.lds.S"
.data.init : { *(.data.init) }
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
.preinit_array : { *(.preinit_array) }
.init_array : { *(.init_array) }
.fini_array : { *(.fini_array) }
.data : {
. = ALIGN(KERNEL_STACK_SIZE); /* init_task */
*(.data.init_task)
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.dynamic : { *(.dynamic) }
.ctors : {
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors : {
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.got : { *(.got.plt) *(.got) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
.bss : {
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
}
_end = .;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#include "uml-config.h" #include "uml-config.h"
#if defined(CONFIG_MODE_TT) && defined(CONFIG_MODE_SKAS) #if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS)
#define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas)) #define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas))
#elif defined(CONFIG_MODE_SKAS) #elif defined(UML_CONFIG_MODE_SKAS)
#define CHOOSE_MODE(tt, skas) (skas) #define CHOOSE_MODE(tt, skas) (skas)
#elif defined(CONFIG_MODE_TT) #elif defined(UML_CONFIG_MODE_TT)
#define CHOOSE_MODE(tt, skas) (tt) #define CHOOSE_MODE(tt, skas) (tt)
#endif #endif
......
...@@ -15,12 +15,12 @@ struct frame_common { ...@@ -15,12 +15,12 @@ struct frame_common {
int sr_index; int sr_index;
int sr_relative; int sr_relative;
int sp_index; int sp_index;
struct arch_frame_data arch;
}; };
struct sc_frame { struct sc_frame {
struct frame_common common; struct frame_common common;
int sc_index; int sc_index;
struct arch_frame_data arch;
}; };
extern struct sc_frame signal_frame_sc; extern struct sc_frame signal_frame_sc;
...@@ -31,6 +31,8 @@ struct si_frame { ...@@ -31,6 +31,8 @@ struct si_frame {
struct frame_common common; struct frame_common common;
int sip_index; int sip_index;
int si_index; int si_index;
int ucp_index;
int uc_index;
}; };
extern struct si_frame signal_frame_si; extern struct si_frame signal_frame_si;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
enum { IRQ_READ, IRQ_WRITE }; enum { IRQ_READ, IRQ_WRITE };
extern void sigio_handler(int sig, struct uml_pt_regs *regs); extern void sigio_handler(int sig, union uml_pt_regs *regs);
extern int activate_fd(int irq, int fd, int type, void *dev_id); extern int activate_fd(int irq, int fd, int type, void *dev_id);
extern void free_irq_by_irq_and_dev(int irq, void *dev_id); extern void free_irq_by_irq_and_dev(int irq, void *dev_id);
extern void free_irq_by_fd(int fd); extern void free_irq_by_fd(int fd);
......
...@@ -47,7 +47,7 @@ extern void free_stack(unsigned long stack, int order); ...@@ -47,7 +47,7 @@ extern void free_stack(unsigned long stack, int order);
extern void add_input_request(int op, void (*proc)(int), void *arg); extern void add_input_request(int op, void (*proc)(int), void *arg);
extern int sys_execve(char *file, char **argv, char **env); extern int sys_execve(char *file, char **argv, char **env);
extern char *current_cmd(void); extern char *current_cmd(void);
extern void timer_handler(int sig, struct uml_pt_regs *regs); extern void timer_handler(int sig, union uml_pt_regs *regs);
extern int set_signals(int enable); extern int set_signals(int enable);
extern void force_sigbus(void); extern void force_sigbus(void);
extern int pid_to_processor_id(int pid); extern int pid_to_processor_id(int pid);
...@@ -64,7 +64,7 @@ extern void *syscall_sp(void *t); ...@@ -64,7 +64,7 @@ extern void *syscall_sp(void *t);
extern void syscall_trace(void); extern void syscall_trace(void);
extern int hz(void); extern int hz(void);
extern void idle_timer(void); extern void idle_timer(void);
extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs); extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
extern int external_pid(void *t); extern int external_pid(void *t);
extern int pid_to_processor_id(int pid); extern int pid_to_processor_id(int pid);
extern void boot_timer_handler(int sig); extern void boot_timer_handler(int sig);
...@@ -77,10 +77,10 @@ extern int init_ptrace_proxy(int idle_pid, int startup, int stop); ...@@ -77,10 +77,10 @@ extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
extern int init_parent_proxy(int pid); extern int init_parent_proxy(int pid);
extern int singlestepping(void *t); extern int singlestepping(void *t);
extern void check_stack_overflow(void *ptr); extern void check_stack_overflow(void *ptr);
extern void relay_signal(int sig, struct uml_pt_regs *regs); extern void relay_signal(int sig, union uml_pt_regs *regs);
extern void not_implemented(void); extern void not_implemented(void);
extern int user_context(unsigned long sp); extern int user_context(unsigned long sp);
extern void timer_irq(struct uml_pt_regs *regs); extern void timer_irq(union uml_pt_regs *regs);
extern void unprotect_stack(unsigned long stack); extern void unprotect_stack(unsigned long stack);
extern void do_uml_exitcalls(void); extern void do_uml_exitcalls(void);
extern int attach_debugger(int idle_pid, int pid, int stop); extern int attach_debugger(int idle_pid, int pid, int stop);
...@@ -101,7 +101,7 @@ extern void *get_init_task(void); ...@@ -101,7 +101,7 @@ extern void *get_init_task(void);
extern int clear_user_proc(void *buf, int size); extern int clear_user_proc(void *buf, int size);
extern int copy_to_user_proc(void *to, void *from, int size); extern int copy_to_user_proc(void *to, void *from, int size);
extern int copy_from_user_proc(void *to, void *from, int size); extern int copy_from_user_proc(void *to, void *from, int size);
extern void bus_handler(int sig, struct uml_pt_regs *regs); extern void bus_handler(int sig, union uml_pt_regs *regs);
extern long execute_syscall(void *r); extern long execute_syscall(void *r);
extern int smp_sigio_handler(void); extern int smp_sigio_handler(void);
extern void *get_current(void); extern void *get_current(void);
......
...@@ -7,30 +7,35 @@ ...@@ -7,30 +7,35 @@
#ifndef __MCONSOLE_H__ #ifndef __MCONSOLE_H__
#define __MCONSOLE_H__ #define __MCONSOLE_H__
#ifndef __KERNEL__
#include <stdint.h>
#define u32 uint32_t
#endif
#define MCONSOLE_MAGIC (0xcafebabe) #define MCONSOLE_MAGIC (0xcafebabe)
#define MCONSOLE_MAX_DATA (512) #define MCONSOLE_MAX_DATA (512)
#define MCONSOLE_VERSION 2 #define MCONSOLE_VERSION 2
struct mconsole_request { struct mconsole_request {
unsigned long magic; u32 magic;
int version; u32 version;
int len; u32 len;
char data[MCONSOLE_MAX_DATA]; char data[MCONSOLE_MAX_DATA];
}; };
struct mconsole_reply { struct mconsole_reply {
int err; u32 err;
int more; u32 more;
int len; u32 len;
char data[MCONSOLE_MAX_DATA]; char data[MCONSOLE_MAX_DATA];
}; };
struct mconsole_notify { struct mconsole_notify {
unsigned long magic; u32 magic;
int version; u32 version;
enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG,
MCONSOLE_USER_NOTIFY } type; MCONSOLE_USER_NOTIFY } type;
int len; u32 len;
char data[MCONSOLE_MAX_DATA]; char data[MCONSOLE_MAX_DATA];
}; };
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include "uml-config.h" #include "uml-config.h"
#ifdef CONFIG_MODE_TT #ifdef UML_CONFIG_MODE_TT
#include "../kernel/tt/include/mode.h" #include "../kernel/tt/include/mode.h"
#endif #endif
#ifdef CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
#include "../kernel/skas/include/mode.h" #include "../kernel/skas/include/mode.h"
#endif #endif
......
...@@ -25,9 +25,11 @@ struct openflags { ...@@ -25,9 +25,11 @@ struct openflags {
unsigned int t : 1; /* O_TRUNC */ unsigned int t : 1; /* O_TRUNC */
unsigned int a : 1; /* O_APPEND */ unsigned int a : 1; /* O_APPEND */
unsigned int e : 1; /* O_EXCL */ unsigned int e : 1; /* O_EXCL */
unsigned int cl : 1; /* FD_CLOEXEC */
}; };
#define OPENFLAGS() ((struct openflags) { r : 0, w : 0, c : 0, s : 0 }) #define OPENFLAGS() ((struct openflags) { .r = 0, .w = 0, .s = 0, .c = 0, \
.t = 0, .a = 0, .e = 0, .cl = 0 })
static inline struct openflags of_read(struct openflags flags) static inline struct openflags of_read(struct openflags flags)
{ {
...@@ -83,9 +85,16 @@ static inline struct openflags of_excl(struct openflags flags) ...@@ -83,9 +85,16 @@ static inline struct openflags of_excl(struct openflags flags)
return(flags); return(flags);
} }
static inline struct openflags of_cloexec(struct openflags flags)
{
flags.cl = 1;
return(flags);
}
extern int os_seek_file(int fd, __u64 offset); extern int os_seek_file(int fd, __u64 offset);
extern int os_open_file(char *file, struct openflags flags, int mode); extern int os_open_file(char *file, struct openflags flags, int mode);
extern int os_read_file(int fd, char *buf, int len); extern int os_read_file(int fd, void *buf, int len);
extern int os_write_file(int fd, void *buf, int count);
extern int os_file_size(char *file, long long *size_out); extern int os_file_size(char *file, long long *size_out);
extern int os_pipe(int *fd, int stream, int close_on_exec); extern int os_pipe(int *fd, int stream, int close_on_exec);
extern int os_set_fd_async(int fd, int owner); extern int os_set_fd_async(int fd, int owner);
...@@ -98,7 +107,6 @@ extern int create_unix_socket(char *file, int len); ...@@ -98,7 +107,6 @@ extern int create_unix_socket(char *file, int len);
extern int os_connect_socket(char *name); extern int os_connect_socket(char *name);
extern int os_file_type(char *file); extern int os_file_type(char *file);
extern int os_file_mode(char *file, struct openflags *mode_out); extern int os_file_mode(char *file, struct openflags *mode_out);
extern int os_write_file(int fd, char *buf, int count);
extern unsigned long os_process_pc(int pid); extern unsigned long os_process_pc(int pid);
extern int os_process_parent(int pid); extern int os_process_parent(int pid);
......
/* /*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
#ifndef __SIGNAL_KERN_H__ #ifndef __SIGNAL_KERN_H__
#define __SIGNAL_KERN_H__ #define __SIGNAL_KERN_H__
#include "sysdep/ptrace.h"
extern void signal_deliverer(int sig);
extern int probe_stack(unsigned long sp, int delta);
extern int have_signals(void *t); extern int have_signals(void *t);
#endif #endif
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#define __FRAME_I386_H #define __FRAME_I386_H
struct arch_frame_data_raw { struct arch_frame_data_raw {
unsigned long sc_end; unsigned long fp_start;
unsigned long sr;
}; };
struct arch_frame_data { struct arch_frame_data {
......
...@@ -16,6 +16,15 @@ static inline void *sp_to_sc(unsigned long sp) ...@@ -16,6 +16,15 @@ static inline void *sp_to_sc(unsigned long sp)
return((void *) sp); return((void *) sp);
} }
static inline void *sp_to_uc(unsigned long sp)
{
unsigned long uc;
uc = sp + signal_frame_si.uc_index -
signal_frame_si.common.sp_index - 4;
return((void *) uc);
}
static inline void *sp_to_rt_sc(unsigned long sp) static inline void *sp_to_rt_sc(unsigned long sp)
{ {
unsigned long sc; unsigned long sc;
...@@ -42,7 +51,7 @@ static inline void *sp_to_rt_mask(unsigned long sp) ...@@ -42,7 +51,7 @@ static inline void *sp_to_rt_mask(unsigned long sp)
mask = sp - signal_frame_si.common.sp_index + mask = sp - signal_frame_si.common.sp_index +
signal_frame_si.common.len + signal_frame_si.common.len +
sc_size(&signal_frame_sc.arch) - 4; sc_size(&signal_frame_si.common.arch) - 4;
return((void *) mask); return((void *) mask);
} }
......
...@@ -18,26 +18,35 @@ ...@@ -18,26 +18,35 @@
* setup_arch_frame uses that data to figure out what * setup_arch_frame uses that data to figure out what
* arch_frame_data.fpstate_size should be. It really has no idea, since it's * arch_frame_data.fpstate_size should be. It really has no idea, since it's
* not allowed to do sizeof(struct fpstate) but it's safe to consider that it's * not allowed to do sizeof(struct fpstate) but it's safe to consider that it's
* everything from the end of the sgcontext up to the top of the stack. So, * everything from the end of the sigcontext up to the top of the stack. So,
* it masks off the page number to get the offset within the page and subtracts * it masks off the page number to get the offset within the page and subtracts
* that from the page size, and that's how big the fpstate struct will be * that from the page size, and that's how big the fpstate struct will be
* considered to be. * considered to be.
*/ */
static inline void setup_arch_frame_raw(struct arch_frame_data_raw *data, static inline void setup_arch_frame_raw(struct arch_frame_data_raw *data,
struct sigcontext *sc) void *end, unsigned long srp)
{ {
data->sc_end = (unsigned long) sc; unsigned long sr = *((unsigned long *) srp);
data->sc_end += sizeof(*sc);
data->fp_start = (unsigned long) end;
if((sr & PAGE_MASK) == ((unsigned long) end & PAGE_MASK))
data->sr = sr;
else data->sr = 0;
} }
static inline void setup_arch_frame(struct arch_frame_data_raw *in, static inline void setup_arch_frame(struct arch_frame_data_raw *in,
struct arch_frame_data *out) struct arch_frame_data *out)
{ {
unsigned long fpstate_start = in->sc_end; unsigned long fpstate_start = in->fp_start;
if(in->sr == 0){
fpstate_start &= ~PAGE_MASK; fpstate_start &= ~PAGE_MASK;
out->fpstate_size = PAGE_SIZE - fpstate_start; out->fpstate_size = PAGE_SIZE - fpstate_start;
}
else {
out->fpstate_size = in->sr - fpstate_start;
}
} }
/* This figures out where on the stack the SA_RESTORER function address /* This figures out where on the stack the SA_RESTORER function address
......
...@@ -7,72 +7,101 @@ ...@@ -7,72 +7,101 @@
#define __SYSDEP_I386_PTRACE_H #define __SYSDEP_I386_PTRACE_H
#include "uml-config.h" #include "uml-config.h"
#ifdef UML_CONFIG_MODE_TT
#include "ptrace-tt.h" #include "ptrace-tt.h"
#endif
#ifdef UML_CONFIG_MODE_SKAS
#include "ptrace-skas.h" #include "ptrace-skas.h"
#endif
#include "choose-mode.h" #include "choose-mode.h"
struct uml_pt_regs { union uml_pt_regs {
unsigned long args[6]; #ifdef UML_CONFIG_MODE_TT
struct tt_regs {
long syscall; long syscall;
int is_user; void *sc;
union { } tt;
#ifdef CONFIG_MODE_TT
void *tt;
#endif #endif
#ifdef CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
struct { struct skas_regs {
unsigned long regs[HOST_FRAME_SIZE]; unsigned long regs[HOST_FRAME_SIZE];
unsigned long fp[HOST_FP_SIZE]; unsigned long fp[HOST_FP_SIZE];
unsigned long xfp[HOST_XFP_SIZE]; unsigned long xfp[HOST_XFP_SIZE];
unsigned long fault_addr; unsigned long fault_addr;
unsigned long fault_type; unsigned long fault_type;
unsigned long trap_type; unsigned long trap_type;
long syscall;
int is_user;
} skas; } skas;
#endif #endif
} mode;
}; };
#define EMPTY_UML_PT_REGS { \ #define EMPTY_UML_PT_REGS { }
syscall : -1, \
args : { [0 ... 5] = 0 }, \
is_user : 0 }
extern int mode_tt; extern int mode_tt;
#define UPT_SC(r) ((r)->tt.sc)
#define UPT_IP(r) \ #define UPT_IP(r) \
CHOOSE_MODE(SC_IP((r)->mode.tt), REGS_IP((r)->mode.skas.regs)) CHOOSE_MODE(SC_IP(UPT_SC(r)), REGS_IP((r)->skas.regs))
#define UPT_SP(r) \ #define UPT_SP(r) \
CHOOSE_MODE(SC_SP((r)->mode.tt), REGS_SP((r)->mode.skas.regs)) CHOOSE_MODE(SC_SP(UPT_SC(r)), REGS_SP((r)->skas.regs))
#define UPT_EFLAGS(r) \ #define UPT_EFLAGS(r) \
CHOOSE_MODE(SC_EFLAGS((r)->mode.tt), REGS_EFLAGS((r)->mode.skas.regs)) CHOOSE_MODE(SC_EFLAGS(UPT_SC(r)), REGS_EFLAGS((r)->skas.regs))
#define UPT_EAX(r) \ #define UPT_EAX(r) \
CHOOSE_MODE(SC_EAX((r)->mode.tt), REGS_EAX((r)->mode.skas.regs)) CHOOSE_MODE(SC_EAX(UPT_SC(r)), REGS_EAX((r)->skas.regs))
#define UPT_EBX(r) \ #define UPT_EBX(r) \
CHOOSE_MODE(SC_EBX((r)->mode.tt), REGS_EBX((r)->mode.skas.regs)) CHOOSE_MODE(SC_EBX(UPT_SC(r)), REGS_EBX((r)->skas.regs))
#define UPT_ECX(r) \ #define UPT_ECX(r) \
CHOOSE_MODE(SC_ECX((r)->mode.tt), REGS_ECX((r)->mode.skas.regs)) CHOOSE_MODE(SC_ECX(UPT_SC(r)), REGS_ECX((r)->skas.regs))
#define UPT_EDX(r) \ #define UPT_EDX(r) \
CHOOSE_MODE(SC_EDX((r)->mode.tt), REGS_EDX((r)->mode.skas.regs)) CHOOSE_MODE(SC_EDX(UPT_SC(r)), REGS_EDX((r)->skas.regs))
#define UPT_ESI(r) \ #define UPT_ESI(r) \
CHOOSE_MODE(SC_ESI((r)->mode.tt), REGS_ESI((r)->mode.skas.regs)) CHOOSE_MODE(SC_ESI(UPT_SC(r)), REGS_ESI((r)->skas.regs))
#define UPT_EDI(r) \ #define UPT_EDI(r) \
CHOOSE_MODE(SC_EDI((r)->mode.tt), REGS_EDI((r)->mode.skas.regs)) CHOOSE_MODE(SC_EDI(UPT_SC(r)), REGS_EDI((r)->skas.regs))
#define UPT_EBP(r) \ #define UPT_EBP(r) \
CHOOSE_MODE(SC_EBP((r)->mode.tt), REGS_EBP((r)->mode.skas.regs)) CHOOSE_MODE(SC_EBP(UPT_SC(r)), REGS_EBP((r)->skas.regs))
#define UPT_ORIG_EAX(r) ((r)->syscall) #define UPT_ORIG_EAX(r) \
CHOOSE_MODE((r)->tt.syscall, (r)->skas.syscall)
#define UPT_CS(r) \ #define UPT_CS(r) \
CHOOSE_MODE(SC_CS((r)->mode.tt), REGS_CS((r)->mode.skas.regs)) CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
#define UPT_SS(r) \ #define UPT_SS(r) \
CHOOSE_MODE(SC_SS((r)->mode.tt), REGS_SS((r)->mode.skas.regs)) CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
#define UPT_DS(r) \ #define UPT_DS(r) \
CHOOSE_MODE(SC_DS((r)->mode.tt), REGS_DS((r)->mode.skas.regs)) CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
#define UPT_ES(r) \ #define UPT_ES(r) \
CHOOSE_MODE(SC_ES((r)->mode.tt), REGS_ES((r)->mode.skas.regs)) CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
#define UPT_FS(r) \ #define UPT_FS(r) \
CHOOSE_MODE(SC_FS((r)->mode.tt), REGS_FS((r)->mode.skas.regs)) CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
#define UPT_GS(r) \ #define UPT_GS(r) \
CHOOSE_MODE(SC_GS((r)->mode.tt), REGS_GS((r)->mode.skas.regs)) CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
#define UPT_SC(r) ((r)->mode.tt)
#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
extern int user_context(unsigned long sp);
#define UPT_IS_USER(r) \
CHOOSE_MODE(user_context(UPT_SP(r)), (r)->skas.is_user)
struct syscall_args {
unsigned long args[6];
};
#define SYSCALL_ARGS(r) ((struct syscall_args) \
{ .args = { UPT_SYSCALL_ARG1(r), \
UPT_SYSCALL_ARG2(r), \
UPT_SYSCALL_ARG3(r), \
UPT_SYSCALL_ARG4(r), \
UPT_SYSCALL_ARG5(r), \
UPT_SYSCALL_ARG6(r) } } )
#define UPT_REG(regs, reg) \ #define UPT_REG(regs, reg) \
({ unsigned long val; \ ({ unsigned long val; \
...@@ -129,28 +158,26 @@ extern int mode_tt; ...@@ -129,28 +158,26 @@ extern int mode_tt;
} while (0) } while (0)
#define UPT_SET_SYSCALL_RETURN(r, res) \ #define UPT_SET_SYSCALL_RETURN(r, res) \
CHOOSE_MODE(SC_SET_SYSCALL_RETURN((r)->mode.tt, (res)), \ CHOOSE_MODE(SC_SET_SYSCALL_RETURN(UPT_SC(r), (res)), \
REGS_SET_SYSCALL_RETURN((r)->mode.skas.regs, (res))) REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res)))
#define UPT_RESTART_SYSCALL(r) \ #define UPT_RESTART_SYSCALL(r) \
CHOOSE_MODE(SC_RESTART_SYSCALL((r)->mode.tt), \ CHOOSE_MODE(SC_RESTART_SYSCALL(UPT_SC(r)), \
REGS_RESTART_SYSCALL((r)->mode.skas.regs)) REGS_RESTART_SYSCALL((r)->skas.regs))
#define UPT_ORIG_SYSCALL(r) UPT_EAX(r) #define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
#define UPT_SYSCALL_NR(r) ((r)->syscall) #define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
#define UPT_SYSCALL_RET(r) UPT_EAX(r) #define UPT_SYSCALL_RET(r) UPT_EAX(r)
#define UPT_SEGV_IS_FIXABLE(r) \ #define UPT_SEGV_IS_FIXABLE(r) \
CHOOSE_MODE(SC_SEGV_IS_FIXABLE(r->mode.tt), \ CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
REGS_SEGV_IS_FIXABLE(&r->mode.skas)) REGS_SEGV_IS_FIXABLE(&r->skas))
#define UPT_FAULT_ADDR(r) \ #define UPT_FAULT_ADDR(r) \
CHOOSE_MODE(SC_FAULT_ADDR(r->mode.tt), \ CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
REGS_FAULT_ADDR(&r->mode.skas))
#define UPT_FAULT_WRITE(r) \ #define UPT_FAULT_WRITE(r) \
CHOOSE_MODE(SC_FAULT_WRITE(r->mode.tt), \ CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
REGS_FAULT_WRITE(&r->mode.skas))
#endif #endif
......
...@@ -33,34 +33,6 @@ ...@@ -33,34 +33,6 @@
#define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc))) #define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
#ifdef CONFIG_MODE_TT
/* XXX struct sigcontext needs declaring by now */
static inline void sc_to_regs(struct uml_pt_regs *regs, struct sigcontext *sc,
unsigned long syscall)
{
regs->syscall = syscall;
regs->args[0] = SC_EBX(sc);
regs->args[1] = SC_ECX(sc);
regs->args[2] = SC_EDX(sc);
regs->args[3] = SC_ESI(sc);
regs->args[4] = SC_EDI(sc);
regs->args[5] = SC_EBP(sc);
}
#endif
#ifdef CONFIG_MODE_SKAS
static inline void host_to_regs(struct uml_pt_regs *regs)
{
regs->syscall = UPT_ORIG_EAX(regs);
regs->args[0] = UPT_EBX(regs);
regs->args[1] = UPT_ECX(regs);
regs->args[2] = UPT_EDX(regs);
regs->args[3] = UPT_ESI(regs);
regs->args[4] = UPT_EDI(regs);
regs->args[5] = UPT_EBP(regs);
}
#endif
extern unsigned long *sc_sigmask(void *sc_ptr); extern unsigned long *sc_sigmask(void *sc_ptr);
extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
*/ */
#include "asm/unistd.h" #include "asm/unistd.h"
#include "sysdep/ptrace.h"
typedef long syscall_handler_t(struct pt_regs); typedef long syscall_handler_t(struct pt_regs);
#define EXECUTE_SYSCALL(syscall, regs) (*sys_call_table[syscall])(*regs); #define EXECUTE_SYSCALL(syscall, regs) \
((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
extern syscall_handler_t sys_modify_ldt; extern syscall_handler_t sys_modify_ldt;
extern syscall_handler_t old_mmap_i386; extern syscall_handler_t old_mmap_i386;
......
...@@ -11,7 +11,7 @@ extern void switch_timers(int to_real); ...@@ -11,7 +11,7 @@ extern void switch_timers(int to_real);
extern void set_interval(int timer_type); extern void set_interval(int timer_type);
extern void idle_sleep(int secs); extern void idle_sleep(int secs);
extern void enable_timer(void); extern void enable_timer(void);
extern void time_lock(void); extern unsigned long time_lock(void);
extern void time_unlock(void); extern void time_unlock(unsigned long);
#endif #endif
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
* Licensed under the GPL * Licensed under the GPL
*/ */
#ifndef __UMID_H__
#define __UMID_H__
extern int umid_file_name(char *name, char *buf, int len); extern int umid_file_name(char *name, char *buf, int len);
#endif
/* /*
* Overrides for Emacs so that we follow Linus's tabbing style. * Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically * Emacs will notice this stuff at the end of the file and automatically
......
/*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#ifndef __UML_UACCESS_H__
#define __UML_UACCESS_H__
extern int __do_copy_to_user(void *to, const void *from, int n,
void **fault_addr, void **fault_catcher);
extern unsigned long __do_user_copy(void *to, const void *from, int n,
void **fault_addr, void **fault_catcher,
void (*op)(void *to, const void *from,
int n), int *faulted_out);
void __do_copy(void *to, const void *from, int n);
#endif
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -24,7 +24,7 @@ struct cpu_task { ...@@ -24,7 +24,7 @@ struct cpu_task {
extern struct cpu_task cpu_tasks[]; extern struct cpu_task cpu_tasks[];
struct signal_info { struct signal_info {
void (*handler)(int, struct uml_pt_regs *); void (*handler)(int, union uml_pt_regs *);
int is_irq; int is_irq;
}; };
...@@ -61,7 +61,6 @@ extern int start_fork_tramp(void *arg, unsigned long temp_stack, ...@@ -61,7 +61,6 @@ extern int start_fork_tramp(void *arg, unsigned long temp_stack,
int clone_flags, int (*tramp)(void *)); int clone_flags, int (*tramp)(void *));
extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags); extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags);
extern int linux_main(int argc, char **argv); extern int linux_main(int argc, char **argv);
extern void remap_data(void *segment_start, void *segment_end, int w);
extern void set_cmdline(char *cmd); extern void set_cmdline(char *cmd);
extern void input_cb(void (*proc)(void *), void *arg, int arg_len); extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
extern int get_pty(void); extern int get_pty(void);
...@@ -87,7 +86,7 @@ extern void check_sigio(void); ...@@ -87,7 +86,7 @@ extern void check_sigio(void);
extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
extern void write_sigio_workaround(void); extern void write_sigio_workaround(void);
extern void arch_check_bugs(void); extern void arch_check_bugs(void);
extern int arch_handle_signal(int sig, struct uml_pt_regs *regs); extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
extern int arch_fixup(unsigned long address, void *sc_ptr); extern int arch_fixup(unsigned long address, void *sc_ptr);
extern void forward_pending_sigio(int target); extern void forward_pending_sigio(int target);
extern int can_do_skas(void); extern int can_do_skas(void);
......
...@@ -3,15 +3,13 @@ ...@@ -3,15 +3,13 @@
# Licensed under the GPL # Licensed under the GPL
# #
EXTRA_TARGETS := unmap_fin.o
obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \ obj-y = checksum.o config.o exec_kern.o exitcode.o frame_kern.o frame.o \
helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \ helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
process.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \ process.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \
sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o \ sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o \
syscall_user.o sysrq.o sys_call_table.o tempfile.o time.o \ syscall_user.o sysrq.o sys_call_table.o tempfile.o time.o \
time_kern.o tlb.o trap_kern.o trap_user.o um_arch.o \ time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \
umid.o user_util.o umid.o user_syms.o user_util.o
obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o
obj-$(CONFIG_GPROF) += gprof_syms.o obj-$(CONFIG_GPROF) += gprof_syms.o
...@@ -23,16 +21,10 @@ obj-$(CONFIG_MODE_SKAS) += skas/ ...@@ -23,16 +21,10 @@ obj-$(CONFIG_MODE_SKAS) += skas/
user-objs-$(CONFIG_TTY_LOG) += tty_log.o user-objs-$(CONFIG_TTY_LOG) += tty_log.o
# user_syms.o not included here because Rules.make has its own ideas about
# building anything in export-objs
USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \ USER_OBJS := $(filter %_user.o,$(obj-y)) $(user-objs-y) config.o helper.o \
process.o tempfile.o time.o tty_log.o umid.o user_util.o user_syms.o process.o tempfile.o time.o tty_log.o umid.o user_util.o user_syms.o
USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
DMODULES-$(CONFIG_MODULES) = -D__CONFIG_MODULES__ DMODULES-$(CONFIG_MODULES) = -D__CONFIG_MODULES__
DMODVERSIONS-$(CONFIG_MODVERSIONS) = -D__CONFIG_MODVERSIONS__ DMODVERSIONS-$(CONFIG_MODVERSIONS) = -D__CONFIG_MODVERSIONS__
...@@ -43,13 +35,7 @@ CFLAGS_user_syms.o = -D__AUTOCONF_INCLUDED__ $(DMODULES-y) $(DMODVERSIONS-y) \ ...@@ -43,13 +35,7 @@ CFLAGS_user_syms.o = -D__AUTOCONF_INCLUDED__ $(DMODULES-y) $(DMODVERSIONS-y) \
CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS)) CFLAGS_frame.o := $(patsubst -fomit-frame-pointer,,$(USER_CFLAGS))
$(USER_OBJS) : %.o: %.c $(USER_OBJS) : %.o: %.c
$(CC) $(CFLAGS_$@) $(USER_CFLAGS) -c -o $@ $< $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
$(obj)/unmap.o: $(src)/unmap.c
$(CC) $(UNMAP_CFLAGS) -c -o $@ $<
$(obj)/unmap_fin.o : $(src)/unmap.o
ld -r -o $@ $< -lc -L/usr/lib
# This has to be separate because it needs be compiled with frame pointers # This has to be separate because it needs be compiled with frame pointers
# regardless of how the rest of the kernel is built. # regardless of how the rest of the kernel is built.
......
...@@ -78,7 +78,8 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp, ...@@ -78,7 +78,8 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
/* It has outlived its usefulness, so continue it so it can exit */ /* It has outlived its usefulness, so continue it so it can exit */
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0){ if(ptrace(PTRACE_CONT, pid, 0, 0) < 0){
printf("capture_stack : mmap failed - errno = %d\n", errno); printf("capture_stack : PTRACE_CONT failed - errno = %d\n",
errno);
exit(1); exit(1);
} }
if(waitpid(pid, &status, 0) < 0){ if(waitpid(pid, &status, 0) < 0){
...@@ -110,6 +111,7 @@ struct common_raw { ...@@ -110,6 +111,7 @@ struct common_raw {
unsigned long sig; unsigned long sig;
unsigned long sr; unsigned long sr;
unsigned long sp; unsigned long sp;
struct arch_frame_data_raw arch;
}; };
#define SA_RESTORER (0x04000000) #define SA_RESTORER (0x04000000)
...@@ -173,7 +175,6 @@ struct sc_frame_raw { ...@@ -173,7 +175,6 @@ struct sc_frame_raw {
struct common_raw common; struct common_raw common;
unsigned long sc; unsigned long sc;
int restorer; int restorer;
struct arch_frame_data_raw arch;
}; };
/* Changed only during early boot */ /* Changed only during early boot */
...@@ -185,7 +186,8 @@ static void sc_handler(int sig, struct sigcontext sc) ...@@ -185,7 +186,8 @@ static void sc_handler(int sig, struct sigcontext sc)
raw_sc->common.sr = frame_restorer(); raw_sc->common.sr = frame_restorer();
raw_sc->common.sp = frame_sp(); raw_sc->common.sp = frame_sp();
raw_sc->sc = (unsigned long) &sc; raw_sc->sc = (unsigned long) &sc;
setup_arch_frame_raw(&raw_sc->arch, &sc); setup_arch_frame_raw(&raw_sc->common.arch, &sc + 1, raw_sc->common.sr);
os_stop_process(os_getpid()); os_stop_process(os_getpid());
kill(getpid(), SIGKILL); kill(getpid(), SIGKILL);
} }
...@@ -205,18 +207,25 @@ struct si_frame_raw { ...@@ -205,18 +207,25 @@ struct si_frame_raw {
struct common_raw common; struct common_raw common;
unsigned long sip; unsigned long sip;
unsigned long si; unsigned long si;
unsigned long ucp;
unsigned long uc;
}; };
/* Changed only during early boot */ /* Changed only during early boot */
static struct si_frame_raw *raw_si = NULL; static struct si_frame_raw *raw_si = NULL;
static void si_handler(int sig, siginfo_t *si) static void si_handler(int sig, siginfo_t *si, struct ucontext *ucontext)
{ {
raw_si->common.sig = (unsigned long) &sig; raw_si->common.sig = (unsigned long) &sig;
raw_si->common.sr = frame_restorer(); raw_si->common.sr = frame_restorer();
raw_si->common.sp = frame_sp(); raw_si->common.sp = frame_sp();
raw_si->sip = (unsigned long) &si; raw_si->sip = (unsigned long) &si;
raw_si->si = (unsigned long) si; raw_si->si = (unsigned long) si;
raw_si->ucp = (unsigned long) &ucontext;
raw_si->uc = (unsigned long) ucontext;
setup_arch_frame_raw(&raw_si->common.arch,
ucontext->uc_mcontext.fpregs, raw_si->common.sr);
os_stop_process(os_getpid()); os_stop_process(os_getpid());
kill(getpid(), SIGKILL); kill(getpid(), SIGKILL);
} }
...@@ -292,7 +301,7 @@ void capture_signal_stack(void) ...@@ -292,7 +301,7 @@ void capture_signal_stack(void)
&signal_frame_sc.common); &signal_frame_sc.common);
signal_frame_sc.sc_index = raw_sc.sc - base; signal_frame_sc.sc_index = raw_sc.sc - base;
setup_arch_frame(&raw_sc.arch, &signal_frame_sc.arch); setup_arch_frame(&raw_sc.common.arch, &signal_frame_sc.common.arch);
/* Ditto for the sigcontext, sigrestorer layout */ /* Ditto for the sigcontext, sigrestorer layout */
raw_sc.restorer = 1; raw_sc.restorer = 1;
...@@ -300,6 +309,7 @@ void capture_signal_stack(void) ...@@ -300,6 +309,7 @@ void capture_signal_stack(void)
(void *) top, sigstack, PAGE_SIZE, (void *) top, sigstack, PAGE_SIZE,
&signal_frame_sc_sr.common); &signal_frame_sc_sr.common);
signal_frame_sc_sr.sc_index = raw_sc.sc - base; signal_frame_sc_sr.sc_index = raw_sc.sc - base;
setup_arch_frame(&raw_sc.common.arch, &signal_frame_sc_sr.common.arch);
/* And the siginfo layout */ /* And the siginfo layout */
...@@ -308,6 +318,9 @@ void capture_signal_stack(void) ...@@ -308,6 +318,9 @@ void capture_signal_stack(void)
&signal_frame_si.common); &signal_frame_si.common);
signal_frame_si.sip_index = raw_si.sip - base; signal_frame_si.sip_index = raw_si.sip - base;
signal_frame_si.si_index = raw_si.si - base; signal_frame_si.si_index = raw_si.si - base;
signal_frame_si.ucp_index = raw_si.ucp - base;
signal_frame_si.uc_index = raw_si.uc - base;
setup_arch_frame(&raw_si.common.arch, &signal_frame_si.common.arch);
if((munmap(stack, PAGE_SIZE) < 0) || if((munmap(stack, PAGE_SIZE) < 0) ||
(munmap(sigstack, PAGE_SIZE) < 0)){ (munmap(sigstack, PAGE_SIZE) < 0)){
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "asm/ptrace.h" #include "asm/ptrace.h"
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "asm/signal.h" #include "asm/signal.h"
#include "asm/uaccess.h"
#include "asm/ucontext.h"
#include "frame_kern.h" #include "frame_kern.h"
#include "sigcontext.h" #include "sigcontext.h"
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
...@@ -27,48 +29,62 @@ static int copy_restorer(void (*restorer)(void), unsigned long start, ...@@ -27,48 +29,62 @@ static int copy_restorer(void (*restorer)(void), unsigned long start,
sizeof(restorer))); sizeof(restorer)));
} }
static int copy_sc_to_user(void *to, struct pt_regs *from) static int copy_sc_to_user(void *to, void *fp, struct pt_regs *from,
struct arch_frame_data *arch)
{ {
return(CHOOSE_MODE(copy_sc_to_user_tt(to, from->regs.mode.tt, return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
&signal_frame_sc_sr.arch), arch),
copy_sc_to_user_skas(to, &from->regs, copy_sc_to_user_skas(to, fp, &from->regs,
current->thread.cr2, current->thread.cr2,
current->thread.err))); current->thread.err)));
} }
static int copy_ucontext_to_user(struct ucontext *uc, void *fp, sigset_t *set,
unsigned long sp)
{
int err = 0;
err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp);
err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);
err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs,
&signal_frame_si.common.arch);
err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
return(err);
}
int setup_signal_stack_si(unsigned long stack_top, int sig, int setup_signal_stack_si(unsigned long stack_top, int sig,
unsigned long handler, void (*restorer)(void), unsigned long handler, void (*restorer)(void),
struct pt_regs *regs, siginfo_t *info, struct pt_regs *regs, siginfo_t *info,
sigset_t *mask) sigset_t *mask)
{ {
unsigned long start, sc, sigs; unsigned long start;
void *sip; void *sip, *ucp, *fp;
int sig_size = _NSIG_WORDS * sizeof(unsigned long);
start = stack_top - signal_frame_si.common.len - start = stack_top - signal_frame_si.common.len;
sc_size(&signal_frame_sc.arch) - sig_size;
sip = (void *) (start + signal_frame_si.si_index); sip = (void *) (start + signal_frame_si.si_index);
sc = start + signal_frame_si.common.len; ucp = (void *) (start + signal_frame_si.uc_index);
sigs = sc + sc_size(&signal_frame_sc.arch); fp = (void *) (((unsigned long) ucp) + sizeof(struct ucontext));
if(restorer == NULL) if(restorer == NULL)
panic("setup_signal_stack_si - no restorer"); panic("setup_signal_stack_si - no restorer");
if(copy_sc_to_user((void *) sc, regs) || if(copy_to_user((void *) start, signal_frame_si.common.data,
copy_to_user((void *) start, signal_frame_si.common.data,
signal_frame_si.common.len) || signal_frame_si.common.len) ||
copy_to_user((void *) (start + signal_frame_si.common.sig_index), copy_to_user((void *) (start + signal_frame_si.common.sig_index),
&sig, sizeof(sig)) || &sig, sizeof(sig)) ||
copy_siginfo_to_user(sip, info) || copy_siginfo_to_user(sip, info) ||
copy_to_user((void *) (start + signal_frame_si.sip_index), &sip, copy_to_user((void *) (start + signal_frame_si.sip_index), &sip,
sizeof(sip)) || sizeof(sip)) ||
copy_to_user((void *) sigs, mask, sig_size) || copy_ucontext_to_user(ucp, fp, mask, PT_REGS_SP(regs)) ||
copy_to_user((void *) (start + signal_frame_si.ucp_index), &ucp,
sizeof(ucp)) ||
copy_restorer(restorer, start, signal_frame_si.common.sr_index, copy_restorer(restorer, start, signal_frame_si.common.sr_index,
signal_frame_si.common.sr_relative)) signal_frame_si.common.sr_relative))
return(1); return(1);
PT_REGS_IP(regs) = handler; PT_REGS_IP(regs) = handler;
PT_REGS_SP(regs) = start + signal_frame_sc.common.sp_index; PT_REGS_SP(regs) = start + signal_frame_si.common.sp_index;
return(0); return(0);
} }
...@@ -96,7 +112,8 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig, ...@@ -96,7 +112,8 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
if(copy_to_user((void *) start, frame->data, frame->len) || if(copy_to_user((void *) start, frame->data, frame->len) ||
copy_to_user((void *) (start + frame->sig_index), &sig, copy_to_user((void *) (start + frame->sig_index), &sig,
sizeof(sig)) || sizeof(sig)) ||
copy_sc_to_user(user_sc, regs) || copy_sc_to_user(user_sc, NULL, regs,
&signal_frame_sc.common.arch) ||
copy_to_user(sc_sigmask(user_sc), mask, sizeof(mask->sig[0])) || copy_to_user(sc_sigmask(user_sc), mask, sizeof(mask->sig[0])) ||
copy_to_user((void *) sigs, &mask->sig[1], sig_size) || copy_to_user((void *) sigs, &mask->sig[1], sig_size) ||
copy_restorer(restorer, start, frame->sr_index, frame->sr_relative)) copy_restorer(restorer, start, frame->sr_index, frame->sr_relative))
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Licensed under the GPL * Licensed under the GPL
*/ */
#include "linux/config.h"
#include "linux/mm.h" #include "linux/mm.h"
#include "linux/sched.h" #include "linux/sched.h"
#include "linux/init_task.h" #include "linux/init_task.h"
...@@ -37,17 +38,16 @@ union thread_union init_thread_union ...@@ -37,17 +38,16 @@ union thread_union init_thread_union
__attribute__((__section__(".data.init_task"))) = __attribute__((__section__(".data.init_task"))) =
{ INIT_THREAD_INFO(init_task) }; { INIT_THREAD_INFO(init_task) };
struct task_struct *alloc_task_struct(void){ struct task_struct *alloc_task_struct(void)
struct task_struct *task; {
return((struct task_struct *)
task = (struct task_struct *) __get_free_pages(GFP_KERNEL, 2); __get_free_pages(GFP_KERNEL, CONFIG_KERNEL_STACK_ORDER));
if(task == NULL) return(NULL);
return(task);
} }
void unprotect_stack(unsigned long stack) void unprotect_stack(unsigned long stack)
{ {
protect_memory(stack, 4 * PAGE_SIZE, 1, 1, 0, 1); protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE,
1, 1, 0, 1);
} }
void free_task_struct(struct task_struct *task) void free_task_struct(struct task_struct *task)
...@@ -55,7 +55,7 @@ void free_task_struct(struct task_struct *task) ...@@ -55,7 +55,7 @@ void free_task_struct(struct task_struct *task)
/* free_pages decrements the page counter and only actually frees /* free_pages decrements the page counter and only actually frees
* the pages if they are now not accessed by anything. * the pages if they are now not accessed by anything.
*/ */
free_pages((unsigned long) task, 2); free_pages((unsigned long) task, CONFIG_KERNEL_STACK_ORDER);
} }
/* /*
......
...@@ -271,7 +271,7 @@ void enable_irq(unsigned int irq) ...@@ -271,7 +271,7 @@ void enable_irq(unsigned int irq)
* SMP cross-CPU interrupts have their own specific * SMP cross-CPU interrupts have their own specific
* handlers). * handlers).
*/ */
unsigned int do_IRQ(int irq, struct uml_pt_regs *regs) unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
{ {
/* /*
* 0 return value means that this irq is already being * 0 return value means that this irq is already being
......
...@@ -42,7 +42,7 @@ static int pollfds_size = 0; ...@@ -42,7 +42,7 @@ static int pollfds_size = 0;
extern int io_count, intr_count; extern int io_count, intr_count;
void sigio_handler(int sig, struct uml_pt_regs *regs) void sigio_handler(int sig, union uml_pt_regs *regs)
{ {
struct irq_fd *irq_fd, *next; struct irq_fd *irq_fd, *next;
int i, n; int i, n;
...@@ -128,15 +128,15 @@ int activate_fd(int irq, int fd, int type, void *dev_id) ...@@ -128,15 +128,15 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
if(type == IRQ_READ) events = POLLIN | POLLPRI; if(type == IRQ_READ) events = POLLIN | POLLPRI;
else events = POLLOUT; else events = POLLOUT;
*new_fd = ((struct irq_fd) { next : NULL, *new_fd = ((struct irq_fd) { .next = NULL,
id : dev_id, .id = dev_id,
fd : fd, .fd = fd,
type : type, .type = type,
irq : irq, .irq = irq,
pid : pid, .pid = pid,
events : events, .events = events,
current_events: 0, .current_events = 0,
freed : 0 } ); .freed = 0 } );
/* Critical section - locked by a spinlock because this stuff can /* Critical section - locked by a spinlock because this stuff can
* be changed from interrupt handlers. The stuff above is done * be changed from interrupt handlers. The stuff above is done
...@@ -191,9 +191,9 @@ int activate_fd(int irq, int fd, int type, void *dev_id) ...@@ -191,9 +191,9 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
if(type == IRQ_WRITE) if(type == IRQ_WRITE)
fd = -1; fd = -1;
pollfds[pollfds_num] = ((struct pollfd) { fd : fd, pollfds[pollfds_num] = ((struct pollfd) { .fd = fd,
events : events, .events = events,
revents : 0 }); .revents = 0 });
pollfds_num++; pollfds_num++;
*last_irq_ptr = new_fd; *last_irq_ptr = new_fd;
...@@ -265,8 +265,8 @@ static int same_irq_and_dev(struct irq_fd *irq, void *d) ...@@ -265,8 +265,8 @@ static int same_irq_and_dev(struct irq_fd *irq, void *d)
void free_irq_by_irq_and_dev(int irq, void *dev) void free_irq_by_irq_and_dev(int irq, void *dev)
{ {
struct irq_and_dev data = ((struct irq_and_dev) { irq : irq, struct irq_and_dev data = ((struct irq_and_dev) { .irq = irq,
dev : dev }); .dev = dev });
free_irq_by_cb(same_irq_and_dev, &data); free_irq_by_cb(same_irq_and_dev, &data);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "asm/processor.h" #include "asm/processor.h"
#include "asm/unistd.h" #include "asm/unistd.h"
#include "asm/pgalloc.h" #include "asm/pgalloc.h"
#include "asm/pgtable.h"
#include "asm/page.h" #include "asm/page.h"
#include "asm/tlbflush.h" #include "asm/tlbflush.h"
#include "kern_util.h" #include "kern_util.h"
...@@ -42,7 +43,11 @@ EXPORT_SYMBOL(page_to_phys); ...@@ -42,7 +43,11 @@ EXPORT_SYMBOL(page_to_phys);
EXPORT_SYMBOL(phys_to_page); EXPORT_SYMBOL(phys_to_page);
EXPORT_SYMBOL(high_physmem); EXPORT_SYMBOL(high_physmem);
EXPORT_SYMBOL(empty_zero_page); EXPORT_SYMBOL(empty_zero_page);
EXPORT_SYMBOL(um_virt_to_phys);
EXPORT_SYMBOL(mode_tt);
EXPORT_SYMBOL(handle_page_fault);
EXPORT_SYMBOL(os_getpid);
EXPORT_SYMBOL(os_open_file); EXPORT_SYMBOL(os_open_file);
EXPORT_SYMBOL(os_read_file); EXPORT_SYMBOL(os_read_file);
EXPORT_SYMBOL(os_write_file); EXPORT_SYMBOL(os_write_file);
...@@ -75,7 +80,6 @@ EXPORT_SYMBOL_NOVERS(__write_lock_failed); ...@@ -75,7 +80,6 @@ EXPORT_SYMBOL_NOVERS(__write_lock_failed);
extern void FASTCALL( __read_lock_failed(rwlock_t *rw)); extern void FASTCALL( __read_lock_failed(rwlock_t *rw));
EXPORT_SYMBOL_NOVERS(__read_lock_failed); EXPORT_SYMBOL_NOVERS(__read_lock_failed);
EXPORT_SYMBOL(smp_num_cpus);
#endif #endif
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "init.h" #include "init.h"
#include "os.h" #include "os.h"
#include "mode_kern.h" #include "mode_kern.h"
#include "uml_uaccess.h"
/* Changed during early boot */ /* Changed during early boot */
pgd_t swapper_pg_dir[1024]; pgd_t swapper_pg_dir[1024];
...@@ -231,11 +232,11 @@ static int setup_one_range(int fd, char *driver, unsigned long start, ...@@ -231,11 +232,11 @@ static int setup_one_range(int fd, char *driver, unsigned long start,
panic("Failed to allocating mem_region"); panic("Failed to allocating mem_region");
} }
*region = ((struct mem_region) { driver : driver, *region = ((struct mem_region) { .driver = driver,
start_pfn : pfn, .start_pfn = pfn,
start : start, .start = start,
len : len, .len = len,
fd : fd } ); .fd = fd } );
regions[i] = region; regions[i] = region;
out: out:
up(&regions_sem); up(&regions_sem);
...@@ -414,8 +415,28 @@ __uml_setup("mem=", uml_mem_setup, ...@@ -414,8 +415,28 @@ __uml_setup("mem=", uml_mem_setup,
struct page *arch_validate(struct page *page, int mask, int order) struct page *arch_validate(struct page *page, int mask, int order)
{ {
return(CHOOSE_MODE_PROC(arch_validate_tt, arch_validate_skas, page, unsigned long addr, zero = 0;
mask, order)); int i;
again:
if(page == NULL) return(page);
if(PageHighMem(page)) return(page);
addr = (unsigned long) page_address(page);
for(i = 0; i < (1 << order); i++){
current->thread.fault_addr = (void *) addr;
if(__do_copy_to_user((void *) addr, &zero,
sizeof(zero),
&current->thread.fault_addr,
&current->thread.fault_catcher)){
if(!(mask & __GFP_WAIT)) return(NULL);
else break;
}
addr += PAGE_SIZE;
}
if(i == (1 << order)) return(page);
page = alloc_pages(mask, order);
goto again;
} }
DECLARE_MUTEX(vm_reserved_sem); DECLARE_MUTEX(vm_reserved_sem);
...@@ -423,15 +444,15 @@ static struct list_head vm_reserved = LIST_HEAD_INIT(vm_reserved); ...@@ -423,15 +444,15 @@ static struct list_head vm_reserved = LIST_HEAD_INIT(vm_reserved);
/* Static structures, linked in to the list in early boot */ /* Static structures, linked in to the list in early boot */
static struct vm_reserved head = { static struct vm_reserved head = {
list : LIST_HEAD_INIT(head.list), .list = LIST_HEAD_INIT(head.list),
start : 0, .start = 0,
end : 0xffffffff .end = 0xffffffff
}; };
static struct vm_reserved tail = { static struct vm_reserved tail = {
list : LIST_HEAD_INIT(tail.list), .list = LIST_HEAD_INIT(tail.list),
start : 0, .start = 0,
end : 0xffffffff .end = 0xffffffff
}; };
void set_usable_vm(unsigned long start, unsigned long end) void set_usable_vm(unsigned long start, unsigned long end)
...@@ -467,9 +488,9 @@ int reserve_vm(unsigned long start, unsigned long end, void *e) ...@@ -467,9 +488,9 @@ int reserve_vm(unsigned long start, unsigned long end, void *e)
goto out; goto out;
} }
*entry = ((struct vm_reserved) *entry = ((struct vm_reserved)
{ list : LIST_HEAD_INIT(entry->list), { .list = LIST_HEAD_INIT(entry->list),
start : start, .start = start,
end : end }); .end = end });
list_add(&entry->list, &prev->list); list_add(&entry->list, &prev->list);
err = 0; err = 0;
out: out:
...@@ -539,9 +560,9 @@ struct iomem { ...@@ -539,9 +560,9 @@ struct iomem {
*/ */
struct iomem iomem_regions[NREGIONS] = { [ 0 ... NREGIONS - 1 ] = struct iomem iomem_regions[NREGIONS] = { [ 0 ... NREGIONS - 1 ] =
{ name : NULL, { .name = NULL,
fd : -1, .fd = -1,
size : 0 } }; .size = 0 } };
int num_iomem_regions = 0; int num_iomem_regions = 0;
...@@ -551,9 +572,9 @@ void add_iomem(char *name, int fd, unsigned long size) ...@@ -551,9 +572,9 @@ void add_iomem(char *name, int fd, unsigned long size)
return; return;
size = (size + PAGE_SIZE - 1) & PAGE_MASK; size = (size + PAGE_SIZE - 1) & PAGE_MASK;
iomem_regions[num_iomem_regions++] = iomem_regions[num_iomem_regions++] =
((struct iomem) { name : name, ((struct iomem) { .name = name,
fd : fd, .fd = fd,
size : size } ); .size = size } );
} }
int setup_iomem(void) int setup_iomem(void)
......
...@@ -37,17 +37,18 @@ ...@@ -37,17 +37,18 @@
#include "uml-config.h" #include "uml-config.h"
#include "choose-mode.h" #include "choose-mode.h"
#include "mode.h" #include "mode.h"
#ifdef CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
#include "skas_ptrace.h"
#include "skas.h" #include "skas.h"
#include "skas_ptrace.h"
#endif #endif
void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
{ {
int flags = 0; int flags = 0, pages;
if(sig_stack != NULL){ if(sig_stack != NULL){
set_sigstack(sig_stack, 2 * page_size()); pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
set_sigstack(sig_stack, pages * page_size());
flags = SA_ONSTACK; flags = SA_ONSTACK;
} }
if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1); if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1);
...@@ -251,32 +252,32 @@ void forward_pending_sigio(int target) ...@@ -251,32 +252,32 @@ void forward_pending_sigio(int target)
int can_do_skas(void) int can_do_skas(void)
{ {
#ifdef CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
struct ptrace_faultinfo fi; struct ptrace_faultinfo fi;
void *stack; void *stack;
int pid, n, ret = 1; int pid, n, ret = 1;
printk("Checking for the skas3 patch in the host..."); printf("Checking for the skas3 patch in the host...");
pid = start_ptraced_child(&stack); pid = start_ptraced_child(&stack);
n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
if(n < 0){ if(n < 0){
if(errno == EIO) if(errno == EIO)
printk("not found\n"); printf("not found\n");
else printk("No (unexpected errno - %d)\n", errno); else printf("No (unexpected errno - %d)\n", errno);
ret = 0; ret = 0;
} }
else printk("found\n"); else printf("found\n");
init_registers(pid); init_registers(pid);
stop_ptraced_child(pid, stack, 1); stop_ptraced_child(pid, stack, 1);
printk("Checking for /proc/mm..."); printf("Checking for /proc/mm...");
if(access("/proc/mm", W_OK)){ if(access("/proc/mm", W_OK)){
printk("not found\n"); printf("not found\n");
ret = 0; ret = 0;
} }
else printk("found\n"); else printf("found\n");
return(ret); return(ret);
#else #else
......
...@@ -169,8 +169,12 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, ...@@ -169,8 +169,12 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
void initial_thread_cb(void (*proc)(void *), void *arg) void initial_thread_cb(void (*proc)(void *), void *arg)
{ {
int save_kmalloc_ok = kmalloc_ok;
kmalloc_ok = 0;
CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc, CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc,
arg); arg);
kmalloc_ok = save_kmalloc_ok;
} }
unsigned long stack_sp(unsigned long page) unsigned long stack_sp(unsigned long page)
...@@ -306,7 +310,11 @@ EXPORT_SYMBOL(not_implemented); ...@@ -306,7 +310,11 @@ EXPORT_SYMBOL(not_implemented);
int user_context(unsigned long sp) int user_context(unsigned long sp)
{ {
return((sp & (PAGE_MASK << 1)) != current->thread.kernel_stack); unsigned long stack;
stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
stack += 2 * PAGE_SIZE;
return(stack != current->thread.kernel_stack);
} }
extern void remove_umid_dir(void); extern void remove_umid_dir(void);
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "linux/smp_lock.h" #include "linux/smp_lock.h"
#include "linux/security.h" #include "linux/security.h"
#include "linux/ptrace.h" #include "linux/ptrace.h"
#ifdef CONFIG_PROC_MM
#include "linux/proc_mm.h" #include "linux/proc_mm.h"
#endif
#include "asm/ptrace.h" #include "asm/ptrace.h"
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "kern_util.h" #include "kern_util.h"
......
...@@ -52,7 +52,7 @@ void __init check_one_sigio(void (*proc)(int, int)) ...@@ -52,7 +52,7 @@ void __init check_one_sigio(void (*proc)(int, int))
{ {
struct sigaction old, new; struct sigaction old, new;
struct termios tt; struct termios tt;
struct openpty_arg pty = { master : -1, slave : -1 }; struct openpty_arg pty = { .master = -1, .slave = -1 };
int master, slave, flags; int master, slave, flags;
initial_thread_cb(openpty_cb, &pty); initial_thread_cb(openpty_cb, &pty);
...@@ -111,6 +111,7 @@ static void tty_output(int master, int slave) ...@@ -111,6 +111,7 @@ static void tty_output(int master, int slave)
printk("Checking that host ptys support output SIGIO..."); printk("Checking that host ptys support output SIGIO...");
memset(buf, 0, sizeof(buf));
while(write(master, buf, sizeof(buf)) > 0) ; while(write(master, buf, sizeof(buf)) > 0) ;
if(errno != EAGAIN) if(errno != EAGAIN)
panic("check_sigio : write failed, errno = %d\n", errno); panic("check_sigio : write failed, errno = %d\n", errno);
...@@ -170,15 +171,15 @@ struct pollfds { ...@@ -170,15 +171,15 @@ struct pollfds {
* synchronizes with it. * synchronizes with it.
*/ */
struct pollfds current_poll = { struct pollfds current_poll = {
poll : NULL, .poll = NULL,
size : 0, .size = 0,
used : 0 .used = 0
}; };
struct pollfds next_poll = { struct pollfds next_poll = {
poll : NULL, .poll = NULL,
size : 0, .size = 0,
used : 0 .used = 0
}; };
static int write_sigio_thread(void *unused) static int write_sigio_thread(void *unused)
...@@ -267,7 +268,8 @@ static void update_thread(void) ...@@ -267,7 +268,8 @@ static void update_thread(void)
return; return;
fail: fail:
sigio_lock(); sigio_lock();
if(write_sigio_pid != -1) kill(write_sigio_pid, SIGKILL); if(write_sigio_pid != -1)
os_kill_process(write_sigio_pid, 1);
write_sigio_pid = -1; write_sigio_pid = -1;
close(sigio_private[0]); close(sigio_private[0]);
close(sigio_private[1]); close(sigio_private[1]);
...@@ -298,9 +300,9 @@ int add_sigio_fd(int fd, int read) ...@@ -298,9 +300,9 @@ int add_sigio_fd(int fd, int read)
if(read) events = POLLIN; if(read) events = POLLIN;
else events = POLLOUT; else events = POLLOUT;
next_poll.poll[n - 1] = ((struct pollfd) { fd : fd, next_poll.poll[n - 1] = ((struct pollfd) { .fd = fd,
events : events, .events = events,
revents : 0 }); .revents = 0 });
update_thread(); update_thread();
out: out:
sigio_unlock(); sigio_unlock();
...@@ -348,12 +350,12 @@ static int setup_initial_poll(int fd) ...@@ -348,12 +350,12 @@ static int setup_initial_poll(int fd)
printk("setup_initial_poll : failed to allocate poll\n"); printk("setup_initial_poll : failed to allocate poll\n");
return(-1); return(-1);
} }
*p = ((struct pollfd) { fd : fd, *p = ((struct pollfd) { .fd = fd,
events : POLLIN, .events = POLLIN,
revents : 0 }); .revents = 0 });
current_poll = ((struct pollfds) { poll : p, current_poll = ((struct pollfds) { .poll = p,
used : 1, .used = 1,
size : 1 }); .size = 1 });
return(0); return(0);
} }
...@@ -394,7 +396,7 @@ void write_sigio_workaround(void) ...@@ -394,7 +396,7 @@ void write_sigio_workaround(void)
return; return;
out_kill: out_kill:
kill(write_sigio_pid, SIGKILL); os_kill_process(write_sigio_pid, 1);
write_sigio_pid = -1; write_sigio_pid = -1;
out_close2: out_close2:
close(sigio_private[0]); close(sigio_private[0]);
...@@ -420,7 +422,8 @@ int read_sigio_fd(int fd) ...@@ -420,7 +422,8 @@ int read_sigio_fd(int fd)
static void sigio_cleanup(void) static void sigio_cleanup(void)
{ {
if(write_sigio_pid != -1) kill(write_sigio_pid, SIGKILL); if(write_sigio_pid != -1)
os_kill_process(write_sigio_pid, 1);
} }
__uml_exitcall(sigio_cleanup); __uml_exitcall(sigio_cleanup);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "asm/unistd.h" #include "asm/unistd.h"
#include "user_util.h" #include "user_util.h"
#include "asm/ucontext.h"
#include "kern_util.h" #include "kern_util.h"
#include "signal_kern.h" #include "signal_kern.h"
#include "signal_user.h" #include "signal_user.h"
...@@ -29,18 +30,6 @@ ...@@ -29,18 +30,6 @@
EXPORT_SYMBOL(block_signals); EXPORT_SYMBOL(block_signals);
EXPORT_SYMBOL(unblock_signals); EXPORT_SYMBOL(unblock_signals);
int probe_stack(unsigned long sp, int delta)
{
int n;
if((get_user(n, (int *) sp) != 0) ||
(put_user(n, (int *) sp) != 0) ||
(get_user(n, (int *) (sp - delta)) != 0) ||
(put_user(n, (int *) (sp - delta)) != 0))
return(-EFAULT);
return(0);
}
static void force_segv(int sig) static void force_segv(int sig)
{ {
if(sig == SIGSEGV){ if(sig == SIGSEGV){
...@@ -237,20 +226,20 @@ int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize) ...@@ -237,20 +226,20 @@ int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize)
} }
} }
static int copy_sc_from_user(struct pt_regs *to, void *from) static int copy_sc_from_user(struct pt_regs *to, void *from,
struct arch_frame_data *arch)
{ {
int ret; int ret;
ret = CHOOSE_MODE(copy_sc_from_user_tt(to->regs.mode.tt, from, ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from, arch),
&signal_frame_sc.arch),
copy_sc_from_user_skas(&to->regs, from)); copy_sc_from_user_skas(&to->regs, from));
return(ret); return(ret);
} }
int sys_sigreturn(struct pt_regs regs) int sys_sigreturn(struct pt_regs regs)
{ {
void *sc = sp_to_sc(PT_REGS_SP(&regs)); void *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
void *mask = sp_to_mask(PT_REGS_SP(&regs)); void *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long); int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
spin_lock_irq(&current->sig->siglock); spin_lock_irq(&current->sig->siglock);
...@@ -260,22 +249,25 @@ int sys_sigreturn(struct pt_regs regs) ...@@ -260,22 +249,25 @@ int sys_sigreturn(struct pt_regs regs)
sigdelsetmask(&current->blocked, ~_BLOCKABLE); sigdelsetmask(&current->blocked, ~_BLOCKABLE);
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sig->siglock); spin_unlock_irq(&current->sig->siglock);
copy_sc_from_user(&current->thread.regs, sc); copy_sc_from_user(&current->thread.regs, sc,
&signal_frame_sc.common.arch);
return(PT_REGS_SYSCALL_RET(&current->thread.regs)); return(PT_REGS_SYSCALL_RET(&current->thread.regs));
} }
int sys_rt_sigreturn(struct pt_regs regs) int sys_rt_sigreturn(struct pt_regs regs)
{ {
void *sc = sp_to_rt_sc(PT_REGS_SP(&regs)); struct ucontext *uc = sp_to_uc(PT_REGS_SP(&current->thread.regs));
void *mask = sp_to_rt_mask(PT_REGS_SP(&regs)); void *fp;
int sig_size = _NSIG_WORDS * sizeof(unsigned long); int sig_size = _NSIG_WORDS * sizeof(unsigned long);
spin_lock_irq(&current->sig->siglock); spin_lock_irq(&current->sig->siglock);
copy_from_user(&current->blocked, mask, sig_size); copy_from_user(&current->blocked, &uc->uc_sigmask, sig_size);
sigdelsetmask(&current->blocked, ~_BLOCKABLE); sigdelsetmask(&current->blocked, ~_BLOCKABLE);
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sig->siglock); spin_unlock_irq(&current->sig->siglock);
copy_sc_from_user(&current->thread.regs, sc); fp = (void *) (((unsigned long) uc) + sizeof(struct ucontext));
copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext,
&signal_frame_si.common.arch);
return(PT_REGS_SYSCALL_RET(&current->thread.regs)); return(PT_REGS_SYSCALL_RET(&current->thread.regs));
} }
......
...@@ -12,10 +12,11 @@ extern unsigned long exec_fpx_regs[]; ...@@ -12,10 +12,11 @@ extern unsigned long exec_fpx_regs[];
extern int have_fpx_regs; extern int have_fpx_regs;
extern void user_time_init_skas(void); extern void user_time_init_skas(void);
extern int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr); extern int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr);
extern int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs, extern int copy_sc_to_user_skas(void *to_ptr, void *fp,
union uml_pt_regs *regs,
unsigned long fault_addr, int fault_type); unsigned long fault_addr, int fault_type);
extern void sig_handler_common_skas(int sig, struct sigcontext *sc); extern void sig_handler_common_skas(int sig, void *sc_ptr);
extern void halt_skas(void); extern void halt_skas(void);
extern void reboot_skas(void); extern void reboot_skas(void);
extern void kill_off_processes_skas(void); extern void kill_off_processes_skas(void);
......
...@@ -21,6 +21,8 @@ extern void release_thread_skas(struct task_struct *task); ...@@ -21,6 +21,8 @@ extern void release_thread_skas(struct task_struct *task);
extern void exit_thread_skas(void); extern void exit_thread_skas(void);
extern void initial_thread_cb_skas(void (*proc)(void *), void *arg); extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
extern void init_idle_skas(void); extern void init_idle_skas(void);
extern void flush_tlb_kernel_range_skas(unsigned long start,
unsigned long end);
extern void flush_tlb_kernel_vm_skas(void); extern void flush_tlb_kernel_vm_skas(void);
extern void __flush_tlb_one_skas(unsigned long addr); extern void __flush_tlb_one_skas(unsigned long addr);
extern void flush_tlb_range_skas(struct vm_area_struct *vma, extern void flush_tlb_range_skas(struct vm_area_struct *vma,
...@@ -32,11 +34,10 @@ extern void before_mem_skas(unsigned long unused); ...@@ -32,11 +34,10 @@ extern void before_mem_skas(unsigned long unused);
extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out, extern unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
unsigned long *task_size_out); unsigned long *task_size_out);
extern int start_uml_skas(void); extern int start_uml_skas(void);
extern struct page *arch_validate_skas(struct page *page, int mask, int order);
extern int external_pid_skas(struct task_struct *task); extern int external_pid_skas(struct task_struct *task);
extern int thread_pid_skas(struct task_struct *task); extern int thread_pid_skas(struct task_struct *task);
#define kmem_end_skas (host_task_size) #define kmem_end_skas (host_task_size - 1024 * 1024)
#endif #endif
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "uml-config.h" #include "uml-config.h"
#ifdef CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
#include "skas_ptregs.h" #include "skas_ptregs.h"
......
...@@ -17,21 +17,21 @@ extern void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, ...@@ -17,21 +17,21 @@ extern void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
extern int start_idle_thread(void *stack, void *switch_buf_ptr, extern int start_idle_thread(void *stack, void *switch_buf_ptr,
void **fork_buf_ptr); void **fork_buf_ptr);
extern int user_thread(unsigned long stack, int flags); extern int user_thread(unsigned long stack, int flags);
extern void userspace(struct uml_pt_regs *regs); extern void userspace(union uml_pt_regs *regs);
extern void new_thread_proc(void *stack, void (*handler)(int sig)); extern void new_thread_proc(void *stack, void (*handler)(int sig));
extern void remove_sigstack(void); extern void remove_sigstack(void);
extern void new_thread_handler(int sig); extern void new_thread_handler(int sig);
extern void handle_syscall(struct uml_pt_regs *regs); extern void handle_syscall(union uml_pt_regs *regs);
extern void map(int fd, unsigned long virt, unsigned long phys, extern void map(int fd, unsigned long virt, unsigned long phys,
unsigned long len, int r, int w, int x); unsigned long len, int r, int w, int x);
extern int unmap(int fd, void *addr, int len); extern int unmap(int fd, void *addr, int len);
extern int protect(int fd, unsigned long addr, unsigned long len, extern int protect(int fd, unsigned long addr, unsigned long len,
int r, int w, int x, int must_succeed); int r, int w, int x, int must_succeed);
extern void user_signal(int sig, struct uml_pt_regs *regs); extern void user_signal(int sig, union uml_pt_regs *regs);
extern int singlestepping_skas(void); extern int singlestepping_skas(void);
extern int new_mm(int from); extern int new_mm(int from);
extern void save_registers(struct uml_pt_regs *regs); extern void save_registers(union uml_pt_regs *regs);
extern void restore_registers(struct uml_pt_regs *regs); extern void restore_registers(union uml_pt_regs *regs);
extern void start_userspace(void); extern void start_userspace(void);
extern void init_registers(int pid); extern void init_registers(int pid);
......
...@@ -27,9 +27,6 @@ static inline int verify_area_skas(int type, const void * addr, ...@@ -27,9 +27,6 @@ static inline int verify_area_skas(int type, const void * addr,
return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
} }
extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
pte_t *pte_out);
static inline unsigned long maybe_map(unsigned long virt, int is_write) static inline unsigned long maybe_map(unsigned long virt, int is_write)
{ {
pte_t pte; pte_t pte;
......
...@@ -18,11 +18,6 @@ unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out, ...@@ -18,11 +18,6 @@ unsigned long set_task_sizes_skas(int arg, unsigned long *host_size_out,
return(((unsigned long) set_task_sizes_skas) & ~0xffffff); return(((unsigned long) set_task_sizes_skas) & ~0xffffff);
} }
struct page *arch_validate_skas(struct page *page, int mask, int order)
{
return(page);
}
/* /*
* Overrides for Emacs so that we follow Linus's tabbing style. * Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically * Emacs will notice this stuff at the end of the file and automatically
......
...@@ -33,7 +33,7 @@ void map(int fd, unsigned long virt, unsigned long phys, unsigned long len, ...@@ -33,7 +33,7 @@ void map(int fd, unsigned long virt, unsigned long phys, unsigned long len,
.fd = region->fd, .fd = region->fd,
.offset = phys_offset(phys) .offset = phys_offset(phys)
} } } ); } } } );
n = os_write_file(fd, (char *) &map, sizeof(map)); n = os_write_file(fd, &map, sizeof(map));
if(n != sizeof(map)) if(n != sizeof(map))
printk("map : /proc/mm map failed, errno = %d\n", errno); printk("map : /proc/mm map failed, errno = %d\n", errno);
} }
...@@ -48,7 +48,7 @@ int unmap(int fd, void *addr, int len) ...@@ -48,7 +48,7 @@ int unmap(int fd, void *addr, int len)
{ .munmap = { .munmap =
{ .addr = (unsigned long) addr, { .addr = (unsigned long) addr,
.len = len } } } ); .len = len } } } );
n = os_write_file(fd, (char *) &unmap, sizeof(unmap)); n = os_write_file(fd, &unmap, sizeof(unmap));
if((n != 0) && (n != sizeof(unmap))) if((n != 0) && (n != sizeof(unmap)))
return(-errno); return(-errno);
return(0); return(0);
...@@ -70,7 +70,7 @@ int protect(int fd, unsigned long addr, unsigned long len, int r, int w, ...@@ -70,7 +70,7 @@ int protect(int fd, unsigned long addr, unsigned long len, int r, int w,
.len = len, .len = len,
.prot = prot } } } ); .prot = prot } } } );
n = os_write_file(fd, (char *) &protect, sizeof(protect)); n = os_write_file(fd, &protect, sizeof(protect));
if((n != 0) && (n != sizeof(protect))){ if((n != 0) && (n != sizeof(protect))){
if(must_succeed) if(must_succeed)
panic("protect failed, errno = %d", errno); panic("protect failed, errno = %d", errno);
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include "user_util.h" #include "user_util.h"
#include "kern_util.h" #include "kern_util.h"
#include "skas.h" #include "skas.h"
#include "skas_ptrace.h"
#include "sysdep/sigcontext.h" #include "sysdep/sigcontext.h"
#include "os.h" #include "os.h"
#include "proc_mm.h" #include "proc_mm.h"
#include "skas_ptrace.h"
unsigned long exec_regs[FRAME_SIZE]; unsigned long exec_regs[FRAME_SIZE];
unsigned long exec_fp_regs[HOST_FP_SIZE]; unsigned long exec_fp_regs[HOST_FP_SIZE];
...@@ -39,14 +39,15 @@ static void handle_segv(int pid) ...@@ -39,14 +39,15 @@ static void handle_segv(int pid)
if(err) if(err)
panic("handle_segv - PTRACE_FAULTINFO failed, errno = %d\n", panic("handle_segv - PTRACE_FAULTINFO failed, errno = %d\n",
errno); errno);
segv(fault.addr, 0, FAULT_WRITE(fault.is_write), 1, NULL); segv(fault.addr, 0, FAULT_WRITE(fault.is_write), 1, NULL);
} }
static void handle_trap(int pid, struct uml_pt_regs *regs) static void handle_trap(int pid, union uml_pt_regs *regs)
{ {
int err, syscall_nr, status; int err, syscall_nr, status;
syscall_nr = PT_SYSCALL_NR(regs->mode.skas.regs); syscall_nr = PT_SYSCALL_NR(regs->skas.regs);
if(syscall_nr < 1){ if(syscall_nr < 1){
relay_signal(SIGTRAP, regs); relay_signal(SIGTRAP, regs);
return; return;
...@@ -79,6 +80,7 @@ static int userspace_tramp(void *arg) ...@@ -79,6 +80,7 @@ static int userspace_tramp(void *arg)
enable_timer(); enable_timer();
ptrace(PTRACE_TRACEME, 0, 0, 0); ptrace(PTRACE_TRACEME, 0, 0, 0);
os_stop_process(os_getpid()); os_stop_process(os_getpid());
return(0);
} }
void start_userspace(void) void start_userspace(void)
...@@ -115,7 +117,7 @@ void start_userspace(void) ...@@ -115,7 +117,7 @@ void start_userspace(void)
userspace_pid = pid; userspace_pid = pid;
} }
void userspace(struct uml_pt_regs *regs) void userspace(union uml_pt_regs *regs)
{ {
int err, status, op; int err, status, op;
...@@ -131,7 +133,7 @@ void userspace(struct uml_pt_regs *regs) ...@@ -131,7 +133,7 @@ void userspace(struct uml_pt_regs *regs)
panic("userspace - waitpid failed, errno = %d\n", panic("userspace - waitpid failed, errno = %d\n",
errno); errno);
regs->is_user = 1; regs->skas.is_user = 1;
save_registers(regs); save_registers(regs);
if(WIFSTOPPED(status)){ if(WIFSTOPPED(status)){
...@@ -191,28 +193,28 @@ void thread_wait(void *sw, void *fb) ...@@ -191,28 +193,28 @@ void thread_wait(void *sw, void *fb)
longjmp(*fork_buf, 1); longjmp(*fork_buf, 1);
} }
static int move_registers(int int_op, int fp_op, struct uml_pt_regs *regs, static int move_registers(int int_op, int fp_op, union uml_pt_regs *regs,
unsigned long *fp_regs) unsigned long *fp_regs)
{ {
if(ptrace(int_op, userspace_pid, 0, regs->mode.skas.regs) < 0) if(ptrace(int_op, userspace_pid, 0, regs->skas.regs) < 0)
return(-errno); return(-errno);
if(ptrace(fp_op, userspace_pid, 0, fp_regs) < 0) if(ptrace(fp_op, userspace_pid, 0, fp_regs) < 0)
return(-errno); return(-errno);
return(0); return(0);
} }
void save_registers(struct uml_pt_regs *regs) void save_registers(union uml_pt_regs *regs)
{ {
unsigned long *fp_regs; unsigned long *fp_regs;
int err, fp_op; int err, fp_op;
if(have_fpx_regs){ if(have_fpx_regs){
fp_op = PTRACE_GETFPXREGS; fp_op = PTRACE_GETFPXREGS;
fp_regs = regs->mode.skas.xfp; fp_regs = regs->skas.xfp;
} }
else { else {
fp_op = PTRACE_GETFPREGS; fp_op = PTRACE_GETFPREGS;
fp_regs = regs->mode.skas.fp; fp_regs = regs->skas.fp;
} }
err = move_registers(PTRACE_GETREGS, fp_op, regs, fp_regs); err = move_registers(PTRACE_GETREGS, fp_op, regs, fp_regs);
...@@ -221,18 +223,18 @@ void save_registers(struct uml_pt_regs *regs) ...@@ -221,18 +223,18 @@ void save_registers(struct uml_pt_regs *regs)
err); err);
} }
void restore_registers(struct uml_pt_regs *regs) void restore_registers(union uml_pt_regs *regs)
{ {
unsigned long *fp_regs; unsigned long *fp_regs;
int err, fp_op; int err, fp_op;
if(have_fpx_regs){ if(have_fpx_regs){
fp_op = PTRACE_SETFPXREGS; fp_op = PTRACE_SETFPXREGS;
fp_regs = regs->mode.skas.xfp; fp_regs = regs->skas.xfp;
} }
else { else {
fp_op = PTRACE_SETFPREGS; fp_op = PTRACE_SETFPREGS;
fp_regs = regs->mode.skas.fp; fp_regs = regs->skas.fp;
} }
err = move_registers(PTRACE_SETREGS, fp_op, regs, fp_regs); err = move_registers(PTRACE_SETREGS, fp_op, regs, fp_regs);
...@@ -272,10 +274,14 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) ...@@ -272,10 +274,14 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
(*cb_proc)(cb_arg); (*cb_proc)(cb_arg);
longjmp(*cb_back, 1); longjmp(*cb_back, 1);
} }
else if(n == 3) else if(n == 3){
kmalloc_ok = 0;
return(0); return(0);
else if(n == 4) }
else if(n == 4){
kmalloc_ok = 0;
return(1); return(1);
}
longjmp(**switch_buf, 1); longjmp(**switch_buf, 1);
} }
...@@ -296,8 +302,11 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) ...@@ -296,8 +302,11 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
cb_proc = proc; cb_proc = proc;
cb_arg = arg; cb_arg = arg;
cb_back = &here; cb_back = &here;
block_signals();
if(setjmp(here) == 0) if(setjmp(here) == 0)
longjmp(initial_jmpbuf, 2); longjmp(initial_jmpbuf, 2);
unblock_signals();
cb_proc = NULL; cb_proc = NULL;
cb_arg = NULL; cb_arg = NULL;
...@@ -328,7 +337,7 @@ int new_mm(int from) ...@@ -328,7 +337,7 @@ int new_mm(int from)
copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS, copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS,
.u = .u =
{ .copy_segments = from } } ); { .copy_segments = from } } );
n = os_write_file(fd, (char *) &copy, sizeof(copy)); n = os_write_file(fd, &copy, sizeof(copy));
if(n != sizeof(copy)) if(n != sizeof(copy))
printk("new_mm : /proc/mm copy_segments failed, " printk("new_mm : /proc/mm copy_segments failed, "
"errno = %d\n", errno); "errno = %d\n", errno);
......
...@@ -68,8 +68,7 @@ void new_thread_handler(int sig) ...@@ -68,8 +68,7 @@ void new_thread_handler(int sig)
n = run_kernel_thread(fn, arg, &current->thread.exec_buf); n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
if(n == 1) if(n == 1)
userspace(&current->thread.regs.regs); userspace(&current->thread.regs.regs);
else if(n == 2) else do_exit(0);
do_exit(0);
} }
void new_thread_proc(void *stack, void (*handler)(int sig)) void new_thread_proc(void *stack, void (*handler)(int sig))
...@@ -109,21 +108,21 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp, ...@@ -109,21 +108,21 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
void (*handler)(int); void (*handler)(int);
if(current->thread.forking){ if(current->thread.forking){
memcpy(&p->thread.regs.regs.mode.skas, memcpy(&p->thread.regs.regs.skas,
&current->thread.regs.regs.mode.skas, &current->thread.regs.regs.skas,
sizeof(p->thread.regs.regs.mode.skas)); sizeof(p->thread.regs.regs.skas));
REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.mode.skas.regs, 0); REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
if(sp != 0) REGS_SP(p->thread.regs.regs.mode.skas.regs) = sp; if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
handler = fork_handler; handler = fork_handler;
} }
else { else {
memcpy(p->thread.regs.regs.mode.skas.regs, exec_regs, memcpy(p->thread.regs.regs.skas.regs, exec_regs,
sizeof(p->thread.regs.regs.mode.skas.regs)); sizeof(p->thread.regs.regs.skas.regs));
memcpy(p->thread.regs.regs.mode.skas.fp, exec_fp_regs, memcpy(p->thread.regs.regs.skas.fp, exec_fp_regs,
sizeof(p->thread.regs.regs.mode.skas.fp)); sizeof(p->thread.regs.regs.skas.fp));
memcpy(p->thread.regs.regs.mode.skas.xfp, exec_fpx_regs, memcpy(p->thread.regs.regs.skas.xfp, exec_fpx_regs,
sizeof(p->thread.regs.regs.mode.skas.xfp)); sizeof(p->thread.regs.regs.skas.xfp));
p->thread.request.u.thread = current->thread.request.u.thread; p->thread.request.u.thread = current->thread.request.u.thread;
handler = new_thread_handler; handler = new_thread_handler;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
extern int userspace_pid; extern int userspace_pid;
int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr) int copy_sc_from_user_skas(union uml_pt_regs *regs, void *from_ptr)
{ {
struct sigcontext sc, *from = from_ptr; struct sigcontext sc, *from = from_ptr;
unsigned long fpregs[FP_FRAME_SIZE]; unsigned long fpregs[FP_FRAME_SIZE];
...@@ -26,26 +26,26 @@ int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr) ...@@ -26,26 +26,26 @@ int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr)
if(err) if(err)
return(err); return(err);
regs->mode.skas.regs[GS] = sc.gs; regs->skas.regs[GS] = sc.gs;
regs->mode.skas.regs[FS] = sc.fs; regs->skas.regs[FS] = sc.fs;
regs->mode.skas.regs[ES] = sc.es; regs->skas.regs[ES] = sc.es;
regs->mode.skas.regs[DS] = sc.ds; regs->skas.regs[DS] = sc.ds;
regs->mode.skas.regs[EDI] = sc.edi; regs->skas.regs[EDI] = sc.edi;
regs->mode.skas.regs[ESI] = sc.esi; regs->skas.regs[ESI] = sc.esi;
regs->mode.skas.regs[EBP] = sc.ebp; regs->skas.regs[EBP] = sc.ebp;
regs->mode.skas.regs[UESP] = sc.esp; regs->skas.regs[UESP] = sc.esp;
regs->mode.skas.regs[EBX] = sc.ebx; regs->skas.regs[EBX] = sc.ebx;
regs->mode.skas.regs[EDX] = sc.edx; regs->skas.regs[EDX] = sc.edx;
regs->mode.skas.regs[ECX] = sc.ecx; regs->skas.regs[ECX] = sc.ecx;
regs->mode.skas.regs[EAX] = sc.eax; regs->skas.regs[EAX] = sc.eax;
regs->mode.skas.regs[EIP] = sc.eip; regs->skas.regs[EIP] = sc.eip;
regs->mode.skas.regs[CS] = sc.cs; regs->skas.regs[CS] = sc.cs;
regs->mode.skas.regs[EFL] = sc.eflags; regs->skas.regs[EFL] = sc.eflags;
regs->mode.skas.regs[UESP] = sc.esp_at_signal; regs->skas.regs[UESP] = sc.esp_at_signal;
regs->mode.skas.regs[SS] = sc.ss; regs->skas.regs[SS] = sc.ss;
regs->mode.skas.fault_addr = sc.cr2; regs->skas.fault_addr = sc.cr2;
regs->mode.skas.fault_type = FAULT_WRITE(sc.err); regs->skas.fault_type = FAULT_WRITE(sc.err);
regs->mode.skas.trap_type = sc.trapno; regs->skas.trap_type = sc.trapno;
err = ptrace(PTRACE_SETFPREGS, userspace_pid, 0, fpregs); err = ptrace(PTRACE_SETFPREGS, userspace_pid, 0, fpregs);
if(err < 0){ if(err < 0){
...@@ -57,7 +57,7 @@ int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr) ...@@ -57,7 +57,7 @@ int copy_sc_from_user_skas(struct uml_pt_regs *regs, void *from_ptr)
return(0); return(0);
} }
int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs, int copy_sc_to_user_skas(void *to_ptr, void *fp, union uml_pt_regs *regs,
unsigned long fault_addr, int fault_type) unsigned long fault_addr, int fault_type)
{ {
struct sigcontext sc, *to = to_ptr; struct sigcontext sc, *to = to_ptr;
...@@ -65,26 +65,26 @@ int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs, ...@@ -65,26 +65,26 @@ int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs,
unsigned long fpregs[FP_FRAME_SIZE]; unsigned long fpregs[FP_FRAME_SIZE];
int err; int err;
sc.gs = regs->mode.skas.regs[GS]; sc.gs = regs->skas.regs[GS];
sc.fs = regs->mode.skas.regs[FS]; sc.fs = regs->skas.regs[FS];
sc.es = regs->mode.skas.regs[ES]; sc.es = regs->skas.regs[ES];
sc.ds = regs->mode.skas.regs[DS]; sc.ds = regs->skas.regs[DS];
sc.edi = regs->mode.skas.regs[EDI]; sc.edi = regs->skas.regs[EDI];
sc.esi = regs->mode.skas.regs[ESI]; sc.esi = regs->skas.regs[ESI];
sc.ebp = regs->mode.skas.regs[EBP]; sc.ebp = regs->skas.regs[EBP];
sc.esp = regs->mode.skas.regs[UESP]; sc.esp = regs->skas.regs[UESP];
sc.ebx = regs->mode.skas.regs[EBX]; sc.ebx = regs->skas.regs[EBX];
sc.edx = regs->mode.skas.regs[EDX]; sc.edx = regs->skas.regs[EDX];
sc.ecx = regs->mode.skas.regs[ECX]; sc.ecx = regs->skas.regs[ECX];
sc.eax = regs->mode.skas.regs[EAX]; sc.eax = regs->skas.regs[EAX];
sc.eip = regs->mode.skas.regs[EIP]; sc.eip = regs->skas.regs[EIP];
sc.cs = regs->mode.skas.regs[CS]; sc.cs = regs->skas.regs[CS];
sc.eflags = regs->mode.skas.regs[EFL]; sc.eflags = regs->skas.regs[EFL];
sc.esp_at_signal = regs->mode.skas.regs[UESP]; sc.esp_at_signal = regs->skas.regs[UESP];
sc.ss = regs->mode.skas.regs[SS]; sc.ss = regs->skas.regs[SS];
sc.cr2 = fault_addr; sc.cr2 = fault_addr;
sc.err = TO_SC_ERR(fault_type); sc.err = TO_SC_ERR(fault_type);
sc.trapno = regs->mode.skas.trap_type; sc.trapno = regs->skas.trap_type;
err = ptrace(PTRACE_GETFPREGS, userspace_pid, 0, fpregs); err = ptrace(PTRACE_GETFPREGS, userspace_pid, 0, fpregs);
if(err < 0){ if(err < 0){
...@@ -92,7 +92,8 @@ int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs, ...@@ -92,7 +92,8 @@ int copy_sc_to_user_skas(void *to_ptr, struct uml_pt_regs *regs,
"errno = %d\n", errno); "errno = %d\n", errno);
return(1); return(1);
} }
to_fp = (struct _fpstate *)((unsigned long) to + sizeof(*to)); to_fp = (struct _fpstate *)
(fp ? (unsigned long) fp : ((unsigned long) to + sizeof(*to)));
sc.fpstate = to_fp; sc.fpstate = to_fp;
if(err) if(err)
......
...@@ -21,7 +21,7 @@ long execute_syscall_skas(void *r) ...@@ -21,7 +21,7 @@ long execute_syscall_skas(void *r)
current->thread.nsyscalls++; current->thread.nsyscalls++;
nsyscalls++; nsyscalls++;
syscall = regs->regs.syscall; syscall = UPT_SYSCALL_NR(&regs->regs);
if((syscall >= NR_syscalls) || (syscall < 0)) if((syscall >= NR_syscalls) || (syscall < 0))
res = -ENOSYS; res = -ENOSYS;
......
...@@ -15,18 +15,17 @@ ...@@ -15,18 +15,17 @@
#define ERESTARTNOINTR 513 #define ERESTARTNOINTR 513
#define ERESTARTNOHAND 514 #define ERESTARTNOHAND 514
void handle_syscall(struct uml_pt_regs *regs) void handle_syscall(union uml_pt_regs *regs)
{ {
long result; long result;
int index; int index;
host_to_regs(regs);
index = record_syscall_start(UPT_SYSCALL_NR(regs)); index = record_syscall_start(UPT_SYSCALL_NR(regs));
syscall_trace(); syscall_trace();
result = execute_syscall(regs); result = execute_syscall(regs);
REGS_SET_SYSCALL_RETURN(regs->mode.skas.regs, result); REGS_SET_SYSCALL_RETURN(regs->skas.regs, result);
if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) || if((result == -ERESTARTNOHAND) || (result == -ERESTARTSYS) ||
(result == -ERESTARTNOINTR)) (result == -ERESTARTNOINTR))
do_signal(result); do_signal(result);
......
...@@ -67,7 +67,7 @@ static void fix_range(struct mm_struct *mm, unsigned long start_addr, ...@@ -67,7 +67,7 @@ static void fix_range(struct mm_struct *mm, unsigned long start_addr,
} }
} }
static void flush_kernel_vm_range(unsigned long start, unsigned long end) void flush_tlb_kernel_range_skas(unsigned long start, unsigned long end)
{ {
struct mm_struct *mm; struct mm_struct *mm;
pgd_t *pgd; pgd_t *pgd;
...@@ -99,7 +99,6 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end) ...@@ -99,7 +99,6 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end)
protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1);
} }
addr += PAGE_SIZE; addr += PAGE_SIZE;
} }
else { else {
if(pmd_newpage(*pmd)){ if(pmd_newpage(*pmd)){
...@@ -116,27 +115,26 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end) ...@@ -116,27 +115,26 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end)
void flush_tlb_kernel_vm_skas(void) void flush_tlb_kernel_vm_skas(void)
{ {
flush_kernel_vm_range(start_vm, end_vm); flush_tlb_kernel_range_skas(start_vm, end_vm);
} }
void __flush_tlb_one_skas(unsigned long addr) void __flush_tlb_one_skas(unsigned long addr)
{ {
flush_kernel_vm_range(addr, addr + PAGE_SIZE); flush_tlb_kernel_range_skas(addr, addr + PAGE_SIZE);
} }
void flush_tlb_range_skas(struct vm_area_struct *vma, unsigned long start, void flush_tlb_range_skas(struct vm_area_struct *vma, unsigned long start,
unsigned long end) unsigned long end)
{ {
if(vma->vm_mm == NULL) if(vma->vm_mm == NULL)
flush_kernel_vm_range(start, end); flush_tlb_kernel_range_skas(start, end);
else fix_range(vma->vm_mm, start, end, 0); else fix_range(vma->vm_mm, start, end, 0);
} }
void flush_tlb_mm_skas(struct mm_struct *mm) void flush_tlb_mm_skas(struct mm_struct *mm)
{ {
if(mm == NULL)
flush_tlb_kernel_vm_skas(); flush_tlb_kernel_vm_skas();
else fix_range(mm, 0, host_task_size, 0); fix_range(mm, 0, host_task_size, 0);
} }
void force_flush_all_skas(void) void force_flush_all_skas(void)
......
...@@ -13,41 +13,40 @@ ...@@ -13,41 +13,40 @@
#include "task.h" #include "task.h"
#include "sigcontext.h" #include "sigcontext.h"
void sig_handler_common_skas(int sig, struct sigcontext *sc) void sig_handler_common_skas(int sig, void *sc_ptr)
{ {
struct uml_pt_regs save_regs, *r; struct sigcontext *sc = sc_ptr;
struct skas_regs *r;
struct signal_info *info; struct signal_info *info;
int save_errno = errno; int save_errno = errno;
r = (struct uml_pt_regs *) TASK_REGS(get_current()); r = &TASK_REGS(get_current())->skas;
save_regs = *r;
r->is_user = 0; r->is_user = 0;
r->mode.skas.fault_addr = SC_FAULT_ADDR(sc); r->fault_addr = SC_FAULT_ADDR(sc);
r->mode.skas.fault_type = SC_FAULT_TYPE(sc); r->fault_type = SC_FAULT_TYPE(sc);
r->mode.skas.trap_type = SC_TRAP_TYPE(sc); r->trap_type = SC_TRAP_TYPE(sc);
change_sig(SIGUSR1, 1); change_sig(SIGUSR1, 1);
info = &sig_info[sig]; info = &sig_info[sig];
if(!info->is_irq) unblock_signals(); if(!info->is_irq) unblock_signals();
(*info->handler)(sig, r); (*info->handler)(sig, (union uml_pt_regs *) r);
*r = save_regs;
errno = save_errno; errno = save_errno;
} }
extern int missed_ticks[]; extern int missed_ticks[];
void user_signal(int sig, struct uml_pt_regs *regs) void user_signal(int sig, union uml_pt_regs *regs)
{ {
struct signal_info *info; struct signal_info *info;
if(sig == SIGVTALRM) if(sig == SIGVTALRM)
missed_ticks[cpu()]++; missed_ticks[cpu()]++;
regs->is_user = 1; regs->skas.is_user = 1;
regs->mode.skas.fault_addr = 0; regs->skas.fault_addr = 0;
regs->mode.skas.fault_type = 0; regs->skas.fault_type = 0;
regs->mode.skas.trap_type = 0; regs->skas.trap_type = 0;
info = &sig_info[sig]; info = &sig_info[sig];
(*info->handler)(sig, regs); (*info->handler)(sig, regs);
......
...@@ -13,6 +13,7 @@ unsigned long cpu_online_map = 1; ...@@ -13,6 +13,7 @@ unsigned long cpu_online_map = 1;
#include "linux/sched.h" #include "linux/sched.h"
#include "linux/threads.h" #include "linux/threads.h"
#include "linux/interrupt.h" #include "linux/interrupt.h"
#include "linux/err.h"
#include "asm/smp.h" #include "asm/smp.h"
#include "asm/processor.h" #include "asm/processor.h"
#include "asm/spinlock.h" #include "asm/spinlock.h"
...@@ -140,7 +141,7 @@ static struct task_struct *idle_thread(int cpu) ...@@ -140,7 +141,7 @@ static struct task_struct *idle_thread(int cpu)
current->thread.request.u.thread.proc = idle_proc; current->thread.request.u.thread.proc = idle_proc;
current->thread.request.u.thread.arg = (void *) cpu; current->thread.request.u.thread.arg = (void *) cpu;
new_task = do_fork(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL); new_task = do_fork(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, NULL);
if(IS_ERR(new_task)) panic("do_fork failed in idle_thread"); if(IS_ERR(new_task)) panic("do_fork failed in idle_thread");
cpu_tasks[cpu] = ((struct cpu_task) cpu_tasks[cpu] = ((struct cpu_task)
...@@ -186,7 +187,7 @@ void smp_prepare_cpus(unsigned int maxcpus) ...@@ -186,7 +187,7 @@ void smp_prepare_cpus(unsigned int maxcpus)
} }
} }
void __devinit smp_prepare_boot_cpu(void) void smp_prepare_boot_cpu(void)
{ {
set_bit(smp_processor_id(), &cpu_online_map); set_bit(smp_processor_id(), &cpu_online_map);
} }
......
...@@ -481,8 +481,6 @@ syscall_handler_t *sys_call_table[] = { ...@@ -481,8 +481,6 @@ syscall_handler_t *sys_call_table[] = {
[ __NR_io_getevents ] = sys_io_getevents, [ __NR_io_getevents ] = sys_io_getevents,
[ __NR_io_submit ] = sys_io_submit, [ __NR_io_submit ] = sys_io_submit,
[ __NR_io_cancel ] = sys_io_cancel, [ __NR_io_cancel ] = sys_io_cancel,
[ __NR_alloc_hugepages ] = sys_ni_syscall,
[ __NR_free_hugepages ] = sys_ni_syscall,
[ __NR_exit_group ] = sys_exit_group, [ __NR_exit_group ] = sys_exit_group,
[ __NR_lookup_dcookie ] = sys_lookup_dcookie, [ __NR_lookup_dcookie ] = sys_lookup_dcookie,
[ __NR_epoll_create ] = sys_epoll_create, [ __NR_epoll_create ] = sys_epoll_create,
......
...@@ -23,11 +23,11 @@ static void __init find_tempdir(void) ...@@ -23,11 +23,11 @@ static void __init find_tempdir(void)
if(tempdir != NULL) return; /* We've already been called */ if(tempdir != NULL) return; /* We've already been called */
for(i = 0; dirs[i]; i++){ for(i = 0; dirs[i]; i++){
dir = getenv(dirs[i]); dir = getenv(dirs[i]);
if(dir != NULL) break; if((dir != NULL) && (*dir != '\0'))
break;
} }
if(dir == NULL) dir = "/tmp"; if((dir == NULL) || (*dir == '\0'))
else if(*dir == '\0') dir = NULL; dir = "/tmp";
if(dir != NULL) {
tempdir = malloc(strlen(dir) + 2); tempdir = malloc(strlen(dir) + 2);
if(tempdir == NULL){ if(tempdir == NULL){
fprintf(stderr, "Failed to malloc tempdir, " fprintf(stderr, "Failed to malloc tempdir, "
...@@ -36,7 +36,6 @@ static void __init find_tempdir(void) ...@@ -36,7 +36,6 @@ static void __init find_tempdir(void)
} }
strcpy(tempdir, dir); strcpy(tempdir, dir);
strcat(tempdir, "/"); strcat(tempdir, "/");
}
} }
int make_tempfile(const char *template, char **out_tempname, int do_unlink) int make_tempfile(const char *template, char **out_tempname, int do_unlink)
......
...@@ -86,20 +86,23 @@ struct timeval local_offset = { 0, 0 }; ...@@ -86,20 +86,23 @@ struct timeval local_offset = { 0, 0 };
void do_gettimeofday(struct timeval *tv) void do_gettimeofday(struct timeval *tv)
{ {
time_lock(); unsigned long flags;
flags = time_lock();
gettimeofday(tv, NULL); gettimeofday(tv, NULL);
timeradd(tv, &local_offset, tv); timeradd(tv, &local_offset, tv);
time_unlock(); time_unlock(flags);
} }
void do_settimeofday(struct timeval *tv) void do_settimeofday(struct timeval *tv)
{ {
struct timeval now; struct timeval now;
unsigned long flags;
time_lock(); flags = time_lock();
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
timersub(tv, &now, &local_offset); timersub(tv, &now, &local_offset);
time_unlock(); time_unlock(flags);
} }
void idle_sleep(int secs) void idle_sleep(int secs)
...@@ -108,7 +111,7 @@ void idle_sleep(int secs) ...@@ -108,7 +111,7 @@ void idle_sleep(int secs)
ts.tv_sec = secs; ts.tv_sec = secs;
ts.tv_nsec = 0; ts.tv_nsec = 0;
nanosleep(&ts, &ts); nanosleep(&ts, NULL);
} }
/* /*
......
...@@ -36,7 +36,7 @@ int timer_irq_inited = 0; ...@@ -36,7 +36,7 @@ int timer_irq_inited = 0;
*/ */
int __attribute__ ((__section__ (".unprotected"))) missed_ticks[NR_CPUS]; int __attribute__ ((__section__ (".unprotected"))) missed_ticks[NR_CPUS];
void timer_irq(struct uml_pt_regs *regs) void timer_irq(union uml_pt_regs *regs)
{ {
int cpu = current->thread_info->cpu, ticks = missed_ticks[cpu]; int cpu = current->thread_info->cpu, ticks = missed_ticks[cpu];
...@@ -49,7 +49,9 @@ void boot_timer_handler(int sig) ...@@ -49,7 +49,9 @@ void boot_timer_handler(int sig)
{ {
struct pt_regs regs; struct pt_regs regs;
regs.regs.is_user = 0; CHOOSE_MODE((void)
(UPT_SC(&regs.regs) = (struct sigcontext *) (&sig + 1)),
(void) (regs.regs.skas.is_user = 0));
do_timer(&regs); do_timer(&regs);
} }
...@@ -117,7 +119,7 @@ void __const_udelay(um_udelay_t usecs) ...@@ -117,7 +119,7 @@ void __const_udelay(um_udelay_t usecs)
for(i=0;i<n;i++) ; for(i=0;i<n;i++) ;
} }
void timer_handler(int sig, struct uml_pt_regs *regs) void timer_handler(int sig, union uml_pt_regs *regs)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
update_process_times(user_context(UPT_SP(regs))); update_process_times(user_context(UPT_SP(regs)));
...@@ -128,14 +130,16 @@ void timer_handler(int sig, struct uml_pt_regs *regs) ...@@ -128,14 +130,16 @@ void timer_handler(int sig, struct uml_pt_regs *regs)
static spinlock_t timer_spinlock = SPIN_LOCK_UNLOCKED; static spinlock_t timer_spinlock = SPIN_LOCK_UNLOCKED;
void time_lock(void) unsigned long time_lock(void)
{ {
spin_lock(&timer_spinlock); unsigned long flags;
spin_lock_irqsave(&timer_spinlock, flags);
return(flags);
} }
void time_unlock(void) void time_unlock(unsigned long flags)
{ {
spin_unlock(&timer_spinlock); spin_unlock_irqrestore(&timer_spinlock, flags);
} }
int __init timer_init(void) int __init timer_init(void)
......
...@@ -21,6 +21,12 @@ void flush_tlb_all(void) ...@@ -21,6 +21,12 @@ void flush_tlb_all(void)
flush_tlb_mm(current->mm); flush_tlb_mm(current->mm);
} }
void flush_tlb_kernel_range(unsigned long start, unsigned long end)
{
CHOOSE_MODE_PROC(flush_tlb_kernel_range_tt,
flush_tlb_kernel_range_skas, start, end);
}
void flush_tlb_kernel_vm(void) void flush_tlb_kernel_vm(void)
{ {
CHOOSE_MODE(flush_tlb_kernel_vm_tt(), flush_tlb_kernel_vm_skas()); CHOOSE_MODE(flush_tlb_kernel_vm_tt(), flush_tlb_kernel_vm_skas());
......
...@@ -109,7 +109,8 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write, ...@@ -109,7 +109,8 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
flush_tlb_kernel_vm(); flush_tlb_kernel_vm();
return(0); return(0);
} }
if(current->mm == NULL) panic("Segfault with no mm"); if(current->mm == NULL)
panic("Segfault with no mm");
err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
catcher = current->thread.fault_catcher; catcher = current->thread.fault_catcher;
...@@ -164,14 +165,15 @@ void bad_segv(unsigned long address, unsigned long ip, int is_write) ...@@ -164,14 +165,15 @@ void bad_segv(unsigned long address, unsigned long ip, int is_write)
force_sig_info(SIGSEGV, &si, current); force_sig_info(SIGSEGV, &si, current);
} }
void relay_signal(int sig, struct uml_pt_regs *regs) void relay_signal(int sig, union uml_pt_regs *regs)
{ {
if(arch_handle_signal(sig, regs)) return; if(arch_handle_signal(sig, regs)) return;
if(!regs->is_user) panic("Kernel mode signal %d", sig); if(!UPT_IS_USER(regs))
panic("Kernel mode signal %d", sig);
force_sig(sig, current); force_sig(sig, current);
} }
void bus_handler(int sig, struct uml_pt_regs *regs) void bus_handler(int sig, union uml_pt_regs *regs)
{ {
if(current->thread.fault_catcher != NULL) if(current->thread.fault_catcher != NULL)
do_longjmp(current->thread.fault_catcher, 1); do_longjmp(current->thread.fault_catcher, 1);
......
...@@ -48,11 +48,11 @@ struct { ...@@ -48,11 +48,11 @@ struct {
int is_user; int is_user;
} segfault_record[1024]; } segfault_record[1024];
void segv_handler(int sig, struct uml_pt_regs *regs) void segv_handler(int sig, union uml_pt_regs *regs)
{ {
int index, max; int index, max;
if(regs->is_user && !UPT_SEGV_IS_FIXABLE(regs)){ if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){
bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs),
UPT_FAULT_WRITE(regs)); UPT_FAULT_WRITE(regs));
return; return;
...@@ -65,35 +65,35 @@ void segv_handler(int sig, struct uml_pt_regs *regs) ...@@ -65,35 +65,35 @@ void segv_handler(int sig, struct uml_pt_regs *regs)
segfault_record[index].pid = os_getpid(); segfault_record[index].pid = os_getpid();
segfault_record[index].is_write = UPT_FAULT_WRITE(regs); segfault_record[index].is_write = UPT_FAULT_WRITE(regs);
segfault_record[index].sp = UPT_SP(regs); segfault_record[index].sp = UPT_SP(regs);
segfault_record[index].is_user = regs->is_user; segfault_record[index].is_user = UPT_IS_USER(regs);
segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs), segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs),
regs->is_user, regs); UPT_IS_USER(regs), regs);
} }
void usr2_handler(int sig, struct uml_pt_regs *regs) void usr2_handler(int sig, union uml_pt_regs *regs)
{ {
CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0); CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
} }
struct signal_info sig_info[] = { struct signal_info sig_info[] = {
[ SIGTRAP ] { handler : relay_signal, [ SIGTRAP ] { .handler = relay_signal,
is_irq : 0 }, .is_irq = 0 },
[ SIGFPE ] { handler : relay_signal, [ SIGFPE ] { .handler = relay_signal,
is_irq : 0 }, .is_irq = 0 },
[ SIGILL ] { handler : relay_signal, [ SIGILL ] { .handler = relay_signal,
is_irq : 0 }, .is_irq = 0 },
[ SIGBUS ] { handler : bus_handler, [ SIGBUS ] { .handler = bus_handler,
is_irq : 0 }, .is_irq = 0 },
[ SIGSEGV] { handler : segv_handler, [ SIGSEGV] { .handler = segv_handler,
is_irq : 0 }, .is_irq = 0 },
[ SIGIO ] { handler : sigio_handler, [ SIGIO ] { .handler = sigio_handler,
is_irq : 1 }, .is_irq = 1 },
[ SIGVTALRM ] { handler : timer_handler, [ SIGVTALRM ] { .handler = timer_handler,
is_irq : 1 }, .is_irq = 1 },
[ SIGALRM ] { handler : timer_handler, [ SIGALRM ] { .handler = timer_handler,
is_irq : 1 }, .is_irq = 1 },
[ SIGUSR2 ] { handler : usr2_handler, [ SIGUSR2 ] { .handler = usr2_handler,
is_irq : 0 }, .is_irq = 0 },
}; };
void sig_handler(int sig, struct sigcontext sc) void sig_handler(int sig, struct sigcontext sc)
......
...@@ -3,16 +3,29 @@ ...@@ -3,16 +3,29 @@
# Licensed under the GPL # Licensed under the GPL
# #
obj-y = exec_kern.o exec_user.o gdb.o gdb_kern.o ksyms.o mem.o process_kern.o \ EXTRA_TARGETS := unmap_fin.o
obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \ syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
uaccess_user.o sys-$(SUBARCH)/ uaccess_user.o sys-$(SUBARCH)/
obj-$(CONFIG_PT_PROXY) += ptproxy/ obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/
USER_OBJS := $(filter %_user.o,$(obj-y)) gdb.o time.o tracer.o USER_OBJS := $(filter %_user.o,$(obj-y)) gdb.o time.o tracer.o
USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
$(USER_OBJS) : %.o: %.c $(USER_OBJS) : %.o: %.c
$(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $< $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
$(O_TARGET) : $(obj)/unmap_fin.o
$(obj)/unmap.o: $(src)/unmap.c
$(CC) $(UNMAP_CFLAGS) -c -o $@ $<
$(obj)/unmap_fin.o : $(src)/unmap.o
ld -r -o $@ $< -lc -L/usr/lib
clean : clean :
...@@ -44,7 +44,7 @@ int cont(int pid) ...@@ -44,7 +44,7 @@ int cont(int pid)
return(ptrace(PTRACE_CONT, pid, 0, 0)); return(ptrace(PTRACE_CONT, pid, 0, 0));
} }
#ifdef CONFIG_PT_PROXY #ifdef UML_CONFIG_PT_PROXY
int debugger_signal(int status, pid_t pid) int debugger_signal(int status, pid_t pid)
{ {
...@@ -62,11 +62,11 @@ static void gdb_announce(char *dev_name, int dev) ...@@ -62,11 +62,11 @@ static void gdb_announce(char *dev_name, int dev)
} }
static struct chan_opts opts = { static struct chan_opts opts = {
announce : gdb_announce, .announce = gdb_announce,
xterm_title : "UML kernel debugger", .xterm_title = "UML kernel debugger",
raw : 0, .raw = 0,
tramp_stack : 0, .tramp_stack = 0,
in_kernel : 0, .in_kernel = 0,
}; };
/* Accessed by the tracing thread, which automatically serializes access */ /* Accessed by the tracing thread, which automatically serializes access */
...@@ -74,16 +74,16 @@ static void *xterm_data; ...@@ -74,16 +74,16 @@ static void *xterm_data;
static int xterm_fd; static int xterm_fd;
extern void *xterm_init(char *, int, struct chan_opts *); extern void *xterm_init(char *, int, struct chan_opts *);
extern int xterm_open(int, int, int, void *); extern int xterm_open(int, int, int, void *, char **);
extern void xterm_close(int, void *); extern void xterm_close(int, void *);
int open_gdb_chan(void) int open_gdb_chan(void)
{ {
char stack[UM_KERN_PAGE_SIZE]; char stack[UM_KERN_PAGE_SIZE], *dummy;
opts.tramp_stack = (unsigned long) stack; opts.tramp_stack = (unsigned long) stack;
xterm_data = xterm_init("", 0, &opts); xterm_data = xterm_init("", 0, &opts);
xterm_fd = xterm_open(1, 1, 1, xterm_data); xterm_fd = xterm_open(1, 1, 1, xterm_data, &dummy);
return(xterm_fd); return(xterm_fd);
} }
......
...@@ -13,9 +13,9 @@ extern int gdb_config(char *str); ...@@ -13,9 +13,9 @@ extern int gdb_config(char *str);
extern int gdb_remove(char *unused); extern int gdb_remove(char *unused);
static struct mc_device gdb_mc = { static struct mc_device gdb_mc = {
name: "gdb", .name = "gdb",
config: gdb_config, .config = gdb_config,
remove: gdb_remove, .remove = gdb_remove,
}; };
int gdb_mc_init(void) int gdb_mc_init(void)
......
...@@ -13,9 +13,10 @@ extern int tracing_pid; ...@@ -13,9 +13,10 @@ extern int tracing_pid;
extern int tracer(int (*init_proc)(void *), void *sp); extern int tracer(int (*init_proc)(void *), void *sp);
extern void user_time_init_tt(void); extern void user_time_init_tt(void);
extern int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data); extern int copy_sc_from_user_tt(void *to_ptr, void *from_ptr, void *data);
extern int copy_sc_to_user_tt(void *to_ptr, void *from_ptr, void *data); extern int copy_sc_to_user_tt(void *to_ptr, void *fp, void *from_ptr,
extern void sig_handler_common_tt(int sig, struct sigcontext *sc); void *data);
extern void syscall_handler_tt(int sig, struct uml_pt_regs *regs); extern void sig_handler_common_tt(int sig, void *sc);
extern void syscall_handler_tt(int sig, union uml_pt_regs *regs);
extern void reboot_tt(void); extern void reboot_tt(void);
extern void halt_tt(void); extern void halt_tt(void);
extern int is_tracer_winch(int pid, int fd, void *data); extern int is_tracer_winch(int pid, int fd, void *data);
......
...@@ -22,6 +22,7 @@ extern void release_thread_tt(struct task_struct *task); ...@@ -22,6 +22,7 @@ extern void release_thread_tt(struct task_struct *task);
extern void exit_thread_tt(void); extern void exit_thread_tt(void);
extern void initial_thread_cb_tt(void (*proc)(void *), void *arg); extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
extern void init_idle_tt(void); extern void init_idle_tt(void);
extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
extern void flush_tlb_kernel_vm_tt(void); extern void flush_tlb_kernel_vm_tt(void);
extern void __flush_tlb_one_tt(unsigned long addr); extern void __flush_tlb_one_tt(unsigned long addr);
extern void flush_tlb_range_tt(struct vm_area_struct *vma, extern void flush_tlb_range_tt(struct vm_area_struct *vma,
...@@ -33,7 +34,6 @@ extern void before_mem_tt(unsigned long brk_start); ...@@ -33,7 +34,6 @@ extern void before_mem_tt(unsigned long brk_start);
extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, extern unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
unsigned long *task_size_out); unsigned long *task_size_out);
extern int start_uml_tt(void); extern int start_uml_tt(void);
extern struct page *arch_validate_tt(struct page *page, int mask, int order);
extern int external_pid_tt(struct task_struct *task); extern int external_pid_tt(struct task_struct *task);
extern int thread_pid_tt(struct task_struct *task); extern int thread_pid_tt(struct task_struct *task);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "uml-config.h" #include "uml-config.h"
#ifdef CONFIG_MODE_TT #ifdef UML_CONFIG_MODE_TT
#include "sysdep/sc.h" #include "sysdep/sc.h"
#endif #endif
......
...@@ -26,10 +26,11 @@ extern void set_tracing(void *t, int tracing); ...@@ -26,10 +26,11 @@ extern void set_tracing(void *t, int tracing);
extern int is_tracing(void *task); extern int is_tracing(void *task);
extern int singlestepping_tt(void *t); extern int singlestepping_tt(void *t);
extern void clear_singlestep(void *t); extern void clear_singlestep(void *t);
extern void syscall_handler(int sig, struct uml_pt_regs *regs); extern void syscall_handler(int sig, union uml_pt_regs *regs);
extern void exit_kernel(int pid, void *task); extern void exit_kernel(int pid, void *task);
extern int do_syscall(void *task, int pid); extern int do_syscall(void *task, int pid);
extern int is_valid_pid(int pid); extern int is_valid_pid(int pid);
extern void remap_data(void *segment_start, void *segment_end, int w);
#endif #endif
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "asm/errno.h" #include "asm/errno.h"
#include "asm/current.h" #include "asm/current.h"
#include "asm/a.out.h" #include "asm/a.out.h"
#include "uml_uaccess.h"
#define ABOVE_KMEM (16 * 1024 * 1024) #define ABOVE_KMEM (16 * 1024 * 1024)
...@@ -51,9 +52,6 @@ static inline int copy_from_user_tt(void *to, const void *from, int n) ...@@ -51,9 +52,6 @@ static inline int copy_from_user_tt(void *to, const void *from, int n)
&current->thread.fault_catcher) : n); &current->thread.fault_catcher) : n);
} }
extern int __do_copy_to_user(void *to, const void *from, int n,
void **fault_addr, void **fault_catcher);
static inline int copy_to_user_tt(void *to, const void *from, int n) static inline int copy_to_user_tt(void *to, const void *from, int n)
{ {
return(access_ok_tt(VERIFY_WRITE, to, n) ? return(access_ok_tt(VERIFY_WRITE, to, n) ?
......
...@@ -39,32 +39,6 @@ unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, ...@@ -39,32 +39,6 @@ unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
return(START); return(START);
} }
struct page *arch_validate_tt(struct page *page, int mask, int order)
{
unsigned long addr, zero = 0;
int i;
again:
if(page == NULL) return(page);
if(PageHighMem(page)) return(page);
addr = (unsigned long) page_address(page);
for(i = 0; i < (1 << order); i++){
current->thread.fault_addr = (void *) addr;
if(__do_copy_to_user((void *) addr, &zero,
sizeof(zero),
&current->thread.fault_addr,
&current->thread.fault_catcher)){
if(!(mask & __GFP_WAIT)) return(NULL);
else break;
}
addr += PAGE_SIZE;
}
if(i == (1 << order)) return(page);
page = alloc_pages(mask, order);
goto again;
}
/* /*
* Overrides for Emacs so that we follow Linus's tabbing style. * Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically * Emacs will notice this stuff at the end of the file and automatically
......
/*
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/mman.h>
#include "tt.h"
#include "mem_user.h"
#include "user_util.h"
void remap_data(void *segment_start, void *segment_end, int w)
{
void *addr;
unsigned long size;
int data, prot;
if(w) prot = PROT_WRITE;
else prot = 0;
prot |= PROT_READ | PROT_EXEC;
size = (unsigned long) segment_end -
(unsigned long) segment_start;
data = create_mem_file(size);
if((addr = mmap(NULL, size, PROT_WRITE | PROT_READ,
MAP_SHARED, data, 0)) == MAP_FAILED){
perror("mapping new data segment");
exit(1);
}
memcpy(addr, segment_start, size);
if(switcheroo(data, prot, addr, segment_start,
size) < 0){
printf("switcheroo failed\n");
exit(1);
}
}
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment