From owner-p4-projects@FreeBSD.ORG Mon Jul 30 10:34:56 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D1DD16A421; Mon, 30 Jul 2007 10:34:56 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0DC616A41F for ; Mon, 30 Jul 2007 10:34:55 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D19DF13C49D for ; Mon, 30 Jul 2007 10:34:55 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6UAYtjA091546 for ; Mon, 30 Jul 2007 10:34:55 GMT (envelope-from thioretic@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6UAYsg1091543 for perforce@freebsd.org; Mon, 30 Jul 2007 10:34:54 GMT (envelope-from thioretic@FreeBSD.org) Date: Mon, 30 Jul 2007 10:34:54 GMT Message-Id: <200707301034.l6UAYsg1091543@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thioretic@FreeBSD.org using -f From: Maxim Zhuravlev To: Perforce Change Reviews Cc: Subject: PERFORCE change 124342 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2007 10:34:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=124342 Change 124342 by thioretic@thioretic on 2007/07/30 10:34:47 IFC Affected files ... .. //depot/projects/soc2007/thioretic_gidl/amd64/isa/clock.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_machdep.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_proto.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_syscall.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_sysent.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_sysvec.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/amd64/linux32/syscalls.master#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linprocfs/linprocfs.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_file.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_getcwd.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_misc.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_signal.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_signal.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_socket.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_stats.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/compat/linux/linux_uid16.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/conf/NOTES#2 integrate .. //depot/projects/soc2007/thioretic_gidl/conf/files#2 integrate .. //depot/projects/soc2007/thioretic_gidl/conf/options#2 integrate .. //depot/projects/soc2007/thioretic_gidl/contrib/pf/net/pf.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/contrib/pf/net/pf_norm.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/acpica/acpi_hpet.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/ata/ata-all.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/ata/ata-chipset.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/ata/ata-disk.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/bce/if_bce.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/firewire/firewire.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/ixgb/if_ixgb.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/kbdmux/kbdmux.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/msk/if_msk.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/msk/if_mskreg.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/nge/if_nge.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/re/if_re.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/rp/rp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/sound/pci/hda/hdac.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/sound/pci/hda/hdac_private.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/sound/pci/ich.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/sound/pcm/ac97_patch.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/sound/pcm/dsp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/speaker/spkr.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/stge/if_stge.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/txp/if_txp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/dev/vge/if_vge.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/msdosfs/msdosfs_vfsops.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/msdosfs/msdosfs_vnops.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/ntfs/ntfs_subr.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/ntfs/ntfs_subr.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/ntfs/ntfs_vnops.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/fs/udf/udf_vnops.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/gnu/fs/ext2fs/ext2_vfsops.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/cpufreq/smist.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/isa/clock.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/imgact_linux.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux_machdep.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux_proto.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux_syscall.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux_sysent.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/linux_sysvec.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/i386/linux/syscalls.master#2 integrate .. //depot/projects/soc2007/thioretic_gidl/kern/kern_descrip.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/kern/kern_exec.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/kern/kern_fork.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/kern/kern_resource.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/acpi/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/acpi/acpi/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/acpi/acpi_video/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/i2c/controllers/alpm/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/i2c/controllers/viapm/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/modules/msdosfs/Makefile#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/bridgestp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/ieee8023ad_lacp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/ieee8023ad_lacp.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/if.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/if_lagg.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/if_lagg.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/if_tap.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/net/if_var.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_l2tp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_mppc.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_nat.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_nat.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_ppp.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netgraph/ng_pptpgre.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netinet/in.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netinet/in_var.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/netinet/tcp_hostcache.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/nfsclient/nfs_bio.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/nfsclient/nfs_socket.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/pci/if_rlreg.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/pci/if_ste.c#2 integrate .. //depot/projects/soc2007/thioretic_gidl/sys/socketvar.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/sys/syscallsubr.h#2 integrate .. //depot/projects/soc2007/thioretic_gidl/ufs/ffs/ffs_vnops.c#2 integrate Differences ... ==== //depot/projects/soc2007/thioretic_gidl/amd64/isa/clock.c#2 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/isa/clock.c,v 1.221.2.1 2005/07/18 19:52:04 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/isa/clock.c,v 1.221.2.2 2007/06/29 21:05:27 jhb Exp $"); /* * Routines to handle clock hardware. @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -269,7 +270,21 @@ int getit_calls = 1; int n1; static int state = 0; +#endif + if (tsc_freq != 0 && !tsc_is_broken) { + uint64_t start, end, now; + + sched_pin(); + start = rdtsc(); + end = start + (tsc_freq * n) / 1000000; + do { + now = rdtsc(); + } while (now < end || (now > start && end < start)); + sched_unpin(); + return; + } +#ifdef DELAYDEBUG if (state == 0) { state = 1; for (n1 = 1; n1 <= 10000000; n1 *= 10) ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux.h#2 (text+ko) ==== @@ -8,7 +8,7 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer + * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the @@ -27,13 +27,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/linux32/linux.h,v 1.1 2004/08/16 07:55:06 tjr Exp $ + * $FreeBSD: src/sys/amd64/linux32/linux.h,v 1.1.8.3 2007/07/08 12:20:35 netchild Exp $ */ -#ifndef _AMD64_LINUX_LINUX_H_ -#define _AMD64_LINUX_LINUX_H_ - -#include /* for sigval union */ +#ifndef _AMD64_LINUX_H_ +#define _AMD64_LINUX_H_ #include @@ -41,20 +39,20 @@ * debugging support */ extern u_char linux_debug_map[]; -#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) -#define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid -#define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid +#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) +#define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid +#define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINUX); #endif -#define LINUX32_USRSTACK ((1ul << 32) - PAGE_SIZE) +#define LINUX32_USRSTACK ((1ul << 32) - PAGE_SIZE) /* XXX 16 = sizeof(linux32_ps_strings) */ -#define LINUX32_PS_STRINGS (LINUX32_USRSTACK - 16) -#define LINUX32_MAXDSIZ (512*1024*1024) /* 512MB */ -#define LINUX32_MAXSSIZ (64*1024*1024) /* 64MB */ -#define LINUX32_MAXVMEM 0 /* Unlimited */ +#define LINUX32_PS_STRINGS (LINUX32_USRSTACK - 16) +#define LINUX32_MAXDSIZ (512 * 1024 * 1024) /* 512MB */ +#define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */ +#define LINUX32_MAXVMEM 0 /* Unlimited */ #define PTRIN(v) (void *)(uintptr_t)(v) #define PTROUT(v) (l_uintptr_t)(uintptr_t)(v) @@ -134,7 +132,7 @@ #define LINUX_RLIMIT_NPROC 6 #define LINUX_RLIMIT_NOFILE 7 #define LINUX_RLIMIT_MEMLOCK 8 -#define LINUX_RLIMIT_AS 9 /* address space limit */ +#define LINUX_RLIMIT_AS 9 /* Address space limit */ #define LINUX_RLIM_NLIMITS 10 @@ -169,12 +167,21 @@ #define LINUX_MAP_ANON 0x0020 #define LINUX_MAP_GROWSDOWN 0x0100 +struct l_mmap_argv { + l_uintptr_t addr; + l_size_t len; + l_int prot; + l_int flags; + l_int fd; + l_off_t pgoff; +} __packed; + /* * stat family of syscalls */ struct l_timespec { - l_ulong tv_sec; - l_ulong tv_nsec; + l_time_t tv_sec; + l_long tv_nsec; } __packed; struct l_newstat { @@ -197,6 +204,24 @@ l_ulong __unused5; } __packed; +struct l_stat { + l_ushort st_dev; + l_ulong st_ino; + l_ushort st_mode; + l_ushort st_nlink; + l_ushort st_uid; + l_ushort st_gid; + l_ushort st_rdev; + l_long st_size; + struct l_timespec st_atimespec; + struct l_timespec st_mtimespec; + struct l_timespec st_ctimespec; + l_long st_blksize; + l_long st_blocks; + l_ulong st_flags; + l_ulong st_gen; +}; + struct l_stat64 { l_ushort st_dev; u_char __pad0[10]; @@ -290,9 +315,9 @@ #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) /* sigaltstack */ -#define LINUX_MINSIGSTKSZ 2048 -#define LINUX_SS_ONSTACK 1 -#define LINUX_SS_DISABLE 2 +#define LINUX_MINSIGSTKSZ 2048 +#define LINUX_SS_ONSTACK 1 +#define LINUX_SS_DISABLE 2 int linux_to_bsd_sigaltstack(int lsa); int bsd_to_linux_sigaltstack(int bsa); @@ -355,11 +380,16 @@ l_uintptr_t uc_link; l_stack_t uc_stack; struct l_sigcontext uc_mcontext; - l_sigset_t uc_sigmask; + l_sigset_t uc_sigmask; } __packed; -#define LINUX_SI_MAX_SIZE 128 -#define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) +#define LINUX_SI_MAX_SIZE 128 +#define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3) + +union l_sigval { + l_int sival_int; + l_uintptr_t sival_ptr; +}; typedef struct l_siginfo { l_int lsi_signo; @@ -381,7 +411,7 @@ struct { l_pid_t _pid; /* sender's pid */ l_uid16_t _uid; /* sender's uid */ - union sigval _sigval; + union l_sigval _sigval; } __packed _rt; struct { @@ -393,41 +423,41 @@ } __packed _sigchld; struct { - l_uintptr_t _addr; /* faulting insn/memory ref. */ + l_uintptr_t _addr; /* Faulting insn/memory ref. */ } __packed _sigfault; struct { - l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */ + l_int _band; /* POLL_IN,POLL_OUT,POLL_MSG */ l_int _fd; } __packed _sigpoll; } _sifields; } __packed l_siginfo_t; -#define lsi_pid _sifields._kill._pid -#define lsi_uid _sifields._kill._uid -#define lsi_status _sifields._sigchld._status -#define lsi_utime _sifields._sigchld._utime -#define lsi_stime _sifields._sigchld._stime -#define lsi_value _sifields._rt._sigval -#define lsi_int _sifields._rt._sigval.sival_int -#define lsi_ptr _sifields._rt._sigval.sival_ptr -#define lsi_addr _sifields._sigfault._addr -#define lsi_band _sifields._sigpoll._band -#define lsi_fd _sifields._sigpoll._fd +#define lsi_pid _sifields._kill._pid +#define lsi_uid _sifields._kill._uid +#define lsi_status _sifields._sigchld._status +#define lsi_utime _sifields._sigchld._utime +#define lsi_stime _sifields._sigchld._stime +#define lsi_value _sifields._rt._sigval +#define lsi_int _sifields._rt._sigval.sival_int +#define lsi_ptr _sifields._rt._sigval.sival_ptr +#define lsi_addr _sifields._sigfault._addr +#define lsi_band _sifields._sigpoll._band +#define lsi_fd _sifields._sigpoll._fd struct l_fpreg { - u_int16_t significand[4]; - u_int16_t exponent; + u_int16_t significand[4]; + u_int16_t exponent; } __packed; struct l_fpxreg { - u_int16_t significand[4]; - u_int16_t exponent; - u_int16_t padding[3]; + u_int16_t significand[4]; + u_int16_t exponent; + u_int16_t padding[3]; } __packed; struct l_xmmreg { - u_int32_t element[4]; + u_int32_t element[4]; } __packed; struct l_fpstate { @@ -441,13 +471,13 @@ u_int32_t datasel; struct l_fpreg _st[8]; u_int16_t status; - u_int16_t magic; /* 0xffff = regular FPU data */ + u_int16_t magic; /* 0xffff = regular FPU data */ /* FXSR FPU environment */ - u_int32_t _fxsr_env[6]; /* env is ignored */ + u_int32_t _fxsr_env[6]; /* env is ignored. */ u_int32_t mxcsr; u_int32_t reserved; - struct l_fpxreg _fxsr_st[8]; /* reg data is ignored */ + struct l_fpxreg _fxsr_st[8]; /* reg data is ignored. */ struct l_xmmreg _xmm[8]; u_int32_t padding[56]; } __packed; @@ -497,18 +527,24 @@ /* * open/fcntl flags */ -#define LINUX_O_RDONLY 00 -#define LINUX_O_WRONLY 01 -#define LINUX_O_RDWR 02 -#define LINUX_O_CREAT 0100 -#define LINUX_O_EXCL 0200 -#define LINUX_O_NOCTTY 0400 -#define LINUX_O_TRUNC 01000 -#define LINUX_O_APPEND 02000 -#define LINUX_O_NONBLOCK 04000 +#define LINUX_O_RDONLY 00000000 +#define LINUX_O_WRONLY 00000001 +#define LINUX_O_RDWR 00000002 +#define LINUX_O_ACCMODE 00000003 +#define LINUX_O_CREAT 00000100 +#define LINUX_O_EXCL 00000200 +#define LINUX_O_NOCTTY 00000400 +#define LINUX_O_TRUNC 00001000 +#define LINUX_O_APPEND 00002000 +#define LINUX_O_NONBLOCK 00004000 #define LINUX_O_NDELAY LINUX_O_NONBLOCK -#define LINUX_O_SYNC 010000 -#define LINUX_FASYNC 020000 +#define LINUX_O_SYNC 00010000 +#define LINUX_FASYNC 00020000 +#define LINUX_O_DIRECT 00040000 /* Direct disk access hint */ +#define LINUX_O_LARGEFILE 00100000 +#define LINUX_O_DIRECTORY 00200000 /* Must be a directory */ +#define LINUX_O_NOFOLLOW 00400000 /* Do not follow links */ +#define LINUX_O_NOATIME 01000000 #define LINUX_F_DUPFD 0 #define LINUX_F_GETFD 1 @@ -529,15 +565,17 @@ #define LINUX_F_WRLCK 1 #define LINUX_F_UNLCK 2 +#define LINUX_AT_FDCWD -100 + /* * mount flags */ -#define LINUX_MS_RDONLY 0x0001 -#define LINUX_MS_NOSUID 0x0002 -#define LINUX_MS_NODEV 0x0004 -#define LINUX_MS_NOEXEC 0x0008 -#define LINUX_MS_REMOUNT 0x0020 - +#define LINUX_MS_RDONLY 0x0001 +#define LINUX_MS_NOSUID 0x0002 +#define LINUX_MS_NODEV 0x0004 +#define LINUX_MS_NOEXEC 0x0008 +#define LINUX_MS_REMOUNT 0x0020 + /* * SystemV IPC defines */ @@ -635,6 +673,13 @@ #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 +#define LINUX_SO_PEERCRED 17 +#define LINUX_SO_RCVLOWAT 18 +#define LINUX_SO_SNDLOWAT 19 +#define LINUX_SO_RCVTIMEO 20 +#define LINUX_SO_SNDTIMEO 21 +#define LINUX_SO_TIMESTAMP 29 +#define LINUX_SO_ACCEPTCONN 30 #define LINUX_IP_TOS 1 #define LINUX_IP_TTL 2 @@ -684,7 +729,7 @@ } ifr_ifru; } __packed; -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_name ifr_ifrn.ifrn_name /* Interface name */ #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ struct l_ifconf { @@ -719,4 +764,11 @@ l_short revents; } __packed; +#define LINUX_CLOCK_REALTIME 0 +#define LINUX_CLOCK_MONOTONIC 1 +#define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 +#define LINUX_CLOCK_THREAD_CPUTIME_ID 3 +#define LINUX_CLOCK_REALTIME_HR 4 +#define LINUX_CLOCK_MONOTONIC_HR 5 + #endif /* !_AMD64_LINUX_LINUX_H_ */ ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_machdep.c#2 (text+ko) ==== @@ -29,11 +29,13 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.10 2005/06/24 17:41:27 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.10.2.2 2007/07/08 12:20:35 netchild Exp $"); #include #include #include +#include +#include #include #include #include @@ -47,6 +49,7 @@ #include #include +#include #include #include @@ -113,7 +116,7 @@ * Allocate temporary demand zeroed space for argument and * environment strings */ - args->buf = (char *) kmem_alloc_wait(exec_map, + args->buf = (char *)kmem_alloc_wait(exec_map, PATH_MAX + ARG_MAX + MAXSHELLCMDLEN); if (args->buf == NULL) return (ENOMEM); @@ -130,7 +133,7 @@ copystr(fname, args->fname, PATH_MAX, &length) : copyinstr(fname, args->fname, PATH_MAX, &length); if (error != 0) - return (error); + goto err_exit; /* * extract arguments first @@ -139,22 +142,22 @@ for (;;) { error = copyin(p32++, &arg, sizeof(arg)); if (error) - return (error); + goto err_exit; if (arg == 0) break; argp = PTRIN(arg); error = copyinstr(argp, args->endp, args->stringspace, &length); if (error) { if (error == ENAMETOOLONG) - return (E2BIG); - else - return (error); + error = E2BIG; + + goto err_exit; } args->stringspace -= length; args->endp += length; args->argc++; } - + args->begin_envv = args->endp; /* @@ -165,7 +168,7 @@ for (;;) { error = copyin(p32++, &arg, sizeof(arg)); if (error) - return (error); + goto err_exit; if (arg == 0) break; envp = PTRIN(arg); @@ -173,9 +176,8 @@ &length); if (error) { if (error == ENAMETOOLONG) - return (E2BIG); - else - return (error); + error = E2BIG; + goto err_exit; } args->stringspace -= length; args->endp += length; @@ -184,6 +186,12 @@ } return (0); + +err_exit: + kmem_free_wakeup(exec_map, (vm_offset_t)args->buf, + PATH_MAX + ARG_MAX + MAXSHELLCMDLEN); + args->buf = NULL; + return (error); } int @@ -229,7 +237,7 @@ if (iovcnt > UIO_MAXIOV) return (EINVAL); iovlen = iovcnt * sizeof(struct iovec); - uio = malloc(iovlen + sizeof *uio, M_IOV, M_WAITOK); + uio = malloc(iovlen + sizeof(*uio), M_IOV, M_WAITOK); iov = (struct iovec *)(uio + 1); for (i = 0; i < iovcnt; i++) { error = copyin(&iovp[i], &iov32, sizeof(struct iovec32)); @@ -539,16 +547,6 @@ return (0); } -/* XXX move */ -struct l_mmap_argv { - l_ulong addr; - l_ulong len; - l_ulong prot; - l_ulong flags; - l_ulong fd; - l_ulong pgoff; -}; - #define STACK_SIZE (2 * 1024 * 1024) #define GUARD_SIZE (4 * PAGE_SIZE) @@ -561,8 +559,8 @@ #ifdef DEBUG if (ldebug(mmap2)) - printf(ARGS(mmap2, "%p, %d, %d, 0x%08x, %d, %d"), - (void *)(intptr_t)args->addr, args->len, args->prot, + printf(ARGS(mmap2, "0x%08x, %d, %d, 0x%08x, %d, %d"), + args->addr, args->len, args->prot, args->flags, args->fd, args->pgoff); #endif @@ -588,10 +586,9 @@ #ifdef DEBUG if (ldebug(mmap)) - printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"), - (void *)(intptr_t)linux_args.addr, linux_args.len, - linux_args.prot, linux_args.flags, linux_args.fd, - linux_args.pgoff); + printf(ARGS(mmap, "0x%08x, %d, %d, 0x%08x, %d, %d"), + linux_args.addr, linux_args.len, linux_args.prot, + linux_args.flags, linux_args.fd, linux_args.pgoff); #endif if ((linux_args.pgoff % PAGE_SIZE) != 0) return (EINVAL); @@ -614,9 +611,20 @@ off_t pos; } */ bsd_args; int error; + struct file *fp; error = 0; bsd_args.flags = 0; + fp = NULL; + + /* + * Linux mmap(2): + * You must specify exactly one of MAP_SHARED and MAP_PRIVATE + */ + if (! ((linux_args->flags & LINUX_MAP_SHARED) ^ + (linux_args->flags & LINUX_MAP_PRIVATE))) + return (EINVAL); + if (linux_args->flags & LINUX_MAP_SHARED) bsd_args.flags |= MAP_SHARED; if (linux_args->flags & LINUX_MAP_PRIVATE) @@ -627,23 +635,60 @@ bsd_args.flags |= MAP_ANON; else bsd_args.flags |= MAP_NOSYNC; - if (linux_args->flags & LINUX_MAP_GROWSDOWN) { + if (linux_args->flags & LINUX_MAP_GROWSDOWN) bsd_args.flags |= MAP_STACK; - /* The linux MAP_GROWSDOWN option does not limit auto + /* + * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC + * on Linux/i386. We do this to ensure maximum compatibility. + * Linux/ia64 does the same in i386 emulation mode. + */ + bsd_args.prot = linux_args->prot; + if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) + bsd_args.prot |= PROT_READ | PROT_EXEC; + + /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */ + bsd_args.fd = (bsd_args.flags & MAP_ANON) ? -1 : linux_args->fd; + if (bsd_args.fd != -1) { + /* + * Linux follows Solaris mmap(2) description: + * The file descriptor fildes is opened with + * read permission, regardless of the + * protection options specified. + */ + + if ((error = fget(td, bsd_args.fd, &fp)) != 0) + return (error); + if (fp->f_type != DTYPE_VNODE) { + fdrop(fp, td); + return (EINVAL); + } + + /* Linux mmap() just fails for O_WRONLY files */ + if (!(fp->f_flag & FREAD)) { + fdrop(fp, td); + return (EACCES); + } + + fdrop(fp, td); + } + + if (linux_args->flags & LINUX_MAP_GROWSDOWN) { + /* + * The Linux MAP_GROWSDOWN option does not limit auto * growth of the region. Linux mmap with this option * takes as addr the inital BOS, and as len, the initial * region size. It can then grow down from addr without - * limit. However, linux threads has an implicit internal + * limit. However, Linux threads has an implicit internal * limit to stack size of STACK_SIZE. Its just not - * enforced explicitly in linux. But, here we impose + * enforced explicitly in Linux. But, here we impose * a limit of (STACK_SIZE - GUARD_SIZE) on the stack * region, since we can do this with our mmap. * * Our mmap with MAP_STACK takes addr as the maximum * downsize limit on BOS, and as len the max size of - * the region. It them maps the top SGROWSIZ bytes, - * and autgrows the region down, up to the limit + * the region. It then maps the top SGROWSIZ bytes, + * and auto grows the region down, up to the limit * in addr. * * If we don't use the MAP_STACK option, the effect @@ -651,13 +696,10 @@ * fixed size of (STACK_SIZE - GUARD_SIZE). */ - /* This gives us TOS */ - bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) + - linux_args->len; - - if ((caddr_t)PTRIN(bsd_args.addr) > + if ((caddr_t)PTRIN(linux_args->addr) + linux_args->len > p->p_vmspace->vm_maxsaddr) { - /* Some linux apps will attempt to mmap + /* + * Some Linux apps will attempt to mmap * thread stacks near the top of their * address space. If their TOS is greater * than vm_maxsaddr, vm_map_growstack() @@ -673,8 +715,7 @@ * mmap's return value. */ PROC_LOCK(p); - p->p_vmspace->vm_maxsaddr = - (char *)LINUX32_USRSTACK - + p->p_vmspace->vm_maxsaddr = (char *)LINUX32_USRSTACK - lim_cur(p, RLIMIT_STACK); PROC_UNLOCK(p); } @@ -685,28 +726,19 @@ else bsd_args.len = STACK_SIZE - GUARD_SIZE; - /* This gives us a new BOS. If we're using VM_STACK, then + /* + * This gives us a new BOS. If we're using VM_STACK, then * mmap will just map the top SGROWSIZ bytes, and let * the stack grow down to the limit at BOS. If we're * not using VM_STACK we map the full stack, since we * don't have a way to autogrow it. */ - bsd_args.addr -= bsd_args.len; + bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) - + bsd_args.len; } else { bsd_args.addr = (caddr_t)PTRIN(linux_args->addr); bsd_args.len = linux_args->len; } - /* - * XXX i386 Linux always emulator forces PROT_READ on (why?) - * so we do the same. We add PROT_EXEC to work around buggy - * applications (e.g. Java) that take advantage of the fact - * that execute permissions are not enforced by x86 CPUs. - */ - bsd_args.prot = linux_args->prot | PROT_EXEC | PROT_READ; - if (linux_args->flags & LINUX_MAP_ANON) - bsd_args.fd = -1; - else - bsd_args.fd = linux_args->fd; bsd_args.pos = (off_t)linux_args->pgoff * PAGE_SIZE; bsd_args.pad = 0; @@ -727,6 +759,36 @@ } int +linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) +{ + struct mprotect_args bsd_args; + + bsd_args.addr = uap->addr; + bsd_args.len = uap->len; + bsd_args.prot = uap->prot; + if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC)) + bsd_args.prot |= PROT_READ | PROT_EXEC; + return (mprotect(td, &bsd_args)); +} + +int +linux_iopl(struct thread *td, struct linux_iopl_args *args) +{ + int error; + + if (args->level < 0 || args->level > 3) + return (EINVAL); + if ((error = suser(td)) != 0) + return (error); + if ((error = securelevel_gt(td->td_ucred, 0)) != 0) + return (error); + td->td_frame->tf_rflags = (td->td_frame->tf_rflags & ~PSL_IOPL) | + (args->level * (PSL_IOPL / 3)); + + return (0); +} + +int linux_pipe(struct thread *td, struct linux_pipe_args *args) { int pip[2]; @@ -797,7 +859,7 @@ } /* - * Linux has two extra args, restart and oldmask. We dont use these, + * Linux has two extra args, restart and oldmask. We don't use these, * but it seems that "restart" is actually a context pointer that * enables the signal to happen with a different register set. */ @@ -1002,16 +1064,3 @@ return (copyout(&ts32, uap->interval, sizeof(ts32))); } -int -linux_mprotect(struct thread *td, struct linux_mprotect_args *uap) -{ - struct mprotect_args bsd_args; - - bsd_args.addr = uap->addr; - bsd_args.len = uap->len; - bsd_args.prot = uap->prot; - /* XXX PROT_READ implies PROT_EXEC; see linux_mmap_common(). */ - if ((bsd_args.prot & PROT_READ) != 0) - bsd_args.prot |= PROT_EXEC; - return (mprotect(td, &bsd_args)); -} ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_proto.h#2 (text+ko) ==== @@ -2,8 +2,8 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.5.2.1 2005/07/20 17:43:52 jhb Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.1 2005/07/20 17:42:14 jhb Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_proto.h,v 1.5.2.2 2007/07/08 12:23:37 netchild Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.2 2007/07/08 12:20:35 netchild Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -323,6 +323,9 @@ struct linux_uname_args { register_t dummy; }; +struct linux_iopl_args { + char level_l_[PADL_(l_ulong)]; l_ulong level; char level_r_[PADR_(l_ulong)]; +}; struct linux_vhangup_args { register_t dummy; }; @@ -765,6 +768,7 @@ int linux_newlstat(struct thread *, struct linux_newlstat_args *); int linux_newfstat(struct thread *, struct linux_newfstat_args *); int linux_uname(struct thread *, struct linux_uname_args *); +int linux_iopl(struct thread *, struct linux_iopl_args *); int linux_vhangup(struct thread *, struct linux_vhangup_args *); int linux_wait4(struct thread *, struct linux_wait4_args *); int linux_swapoff(struct thread *, struct linux_swapoff_args *); ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_syscall.h#2 (text+ko) ==== @@ -2,8 +2,8 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.5.2.1 2005/07/20 17:43:52 jhb Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.1 2005/07/20 17:42:14 jhb Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_syscall.h,v 1.5.2.2 2007/07/08 12:23:37 netchild Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.2 2007/07/08 12:20:35 netchild Exp */ #define LINUX_SYS_exit 1 @@ -101,6 +101,7 @@ #define LINUX_SYS_linux_newlstat 107 #define LINUX_SYS_linux_newfstat 108 #define LINUX_SYS_linux_uname 109 +#define LINUX_SYS_linux_iopl 110 #define LINUX_SYS_linux_vhangup 111 #define LINUX_SYS_linux_wait4 114 #define LINUX_SYS_linux_swapoff 115 ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_sysent.c#2 (text+ko) ==== @@ -2,8 +2,8 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.5.2.1 2005/07/20 17:43:52 jhb Exp $ - * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.1 2005/07/20 17:42:14 jhb Exp + * $FreeBSD: src/sys/amd64/linux32/linux32_sysent.c,v 1.5.2.2 2007/07/08 12:23:37 netchild Exp $ + * created from FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.2 2007/07/08 12:20:35 netchild Exp */ #include @@ -130,7 +130,7 @@ { SYF_MPSAFE | AS(linux_newlstat_args), (sy_call_t *)linux_newlstat, AUE_NULL }, /* 107 = linux_newlstat */ { SYF_MPSAFE | AS(linux_newfstat_args), (sy_call_t *)linux_newfstat, AUE_NULL }, /* 108 = linux_newfstat */ { SYF_MPSAFE | 0, (sy_call_t *)linux_uname, AUE_NULL }, /* 109 = linux_uname */ - { 0, (sy_call_t *)nosys, AUE_NULL }, /* 110 = iopl */ + { SYF_MPSAFE | AS(linux_iopl_args), (sy_call_t *)linux_iopl, AUE_NULL }, /* 110 = linux_iopl */ { SYF_MPSAFE | 0, (sy_call_t *)linux_vhangup, AUE_NULL }, /* 111 = linux_vhangup */ { 0, (sy_call_t *)nosys, AUE_NULL }, /* 112 = idle */ { 0, (sy_call_t *)nosys, AUE_NULL }, /* 113 = vm86old */ ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/linux32_sysvec.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_sysvec.c,v 1.7.2.5 2007/05/23 18:24:42 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_sysvec.c,v 1.7.2.9 2007/07/08 12:20:35 netchild Exp $"); /* XXX we use functions that might not exist. */ #include "opt_compat.h" @@ -142,7 +142,8 @@ -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75, -6, -84 + -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -72, -67, -71 }; int bsd_to_linux_signal[LINUX_SIGTBLSZ] = { @@ -327,7 +328,7 @@ /* Fill in POSIX parts */ frame.sf_si.lsi_signo = sig; frame.sf_si.lsi_code = code; - frame.sf_si.lsi_addr = PTROUT(regs->tf_err); + frame.sf_si.lsi_addr = PTROUT(regs->tf_addr); /* * Build the signal context to be used by sigreturn. @@ -399,6 +400,7 @@ td->td_pcb->pcb_ds = _udatasel; load_es(_udatasel); td->td_pcb->pcb_es = _udatasel; + /* leave user %fs and %gs untouched */ PROC_LOCK(p); mtx_lock(&psp->ps_mtx); } @@ -516,6 +518,7 @@ td->td_pcb->pcb_ds = _udatasel; load_es(_udatasel); td->td_pcb->pcb_es = _udatasel; + /* leave user %fs and %gs untouched */ PROC_LOCK(p); mtx_lock(&psp->ps_mtx); } @@ -972,7 +975,7 @@ struct sysentvec elf_linux_sysvec = { LINUX_SYS_MAXSYSCALL, linux_sysent, - 0xff, + 0, LINUX_SIGTBLSZ, bsd_to_linux_signal, ELAST + 1, ==== //depot/projects/soc2007/thioretic_gidl/amd64/linux32/syscalls.master#2 (text+ko) ==== @@ -1,4 +1,4 @@ - $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.1 2005/07/20 17:42:14 jhb Exp $ + $FreeBSD: src/sys/amd64/linux32/syscalls.master,v 1.4.2.2 2007/07/08 12:20:35 netchild Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). @@ -201,7 +201,7 @@ 108 AUE_NULL MSTD { int linux_newfstat(l_uint fd, \ struct l_newstat *buf); } 109 AUE_NULL MSTD { int linux_uname(void); } -110 AUE_NULL UNIMPL iopl +110 AUE_NULL MSTD { int linux_iopl(l_ulong level); } 111 AUE_NULL MSTD { int linux_vhangup(void); } 112 AUE_NULL UNIMPL idle 113 AUE_NULL UNIMPL vm86old ==== //depot/projects/soc2007/thioretic_gidl/compat/linprocfs/linprocfs.c#2 (text+ko) ==== @@ -40,7 +40,7 @@ */ >>> TRUNCATED FOR MAIL (1000 lines) <<<