svn commit: r319052 - in head/sys/modules: linux linux64

2017-05-28 Thread Dmitry Chagin
Author: dchagin
Date: Sun May 28 07:37:40 2017
New Revision: 319052
URL: https://svnweb.freebsd.org/changeset/base/319052

Log:
  Strip _binary_linux_locore_o_size from ${VDSO}.so as it is a low absolute
  symbol, and this breaks symbol lookup in ddb.
  
  Requested by: bde@
  
  MFC after:1 week

Modified:
  head/sys/modules/linux/Makefile
  head/sys/modules/linux64/Makefile

Modified: head/sys/modules/linux/Makefile
==
--- head/sys/modules/linux/Makefile Sun May 28 07:04:50 2017
(r319051)
+++ head/sys/modules/linux/Makefile Sun May 28 07:37:40 2017
(r319052)
@@ -64,10 +64,12 @@ linux${SFX}_support.o: linux${SFX}_assym
 ${VDSO}.so: linux${SFX}_locore.o
${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd   
\
--binary-architecture i386 linux${SFX}_locore.o ${.TARGET}
+   strip -N _binary_linux${SFX}_locore_o_size ${.TARGET}
 .else
 ${VDSO}.so: linux${SFX}_locore.o
${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd 
\
--binary-architecture i386 linux${SFX}_locore.o ${.TARGET}
+   strip -N _binary_linux_locore_o_size ${.TARGET}
 .endif
 
 linux${SFX}_genassym.o:

Modified: head/sys/modules/linux64/Makefile
==
--- head/sys/modules/linux64/Makefile   Sun May 28 07:04:50 2017
(r319051)
+++ head/sys/modules/linux64/Makefile   Sun May 28 07:37:40 2017
(r319052)
@@ -38,6 +38,7 @@ linux_locore.o: linux_locore.s linux_ass
 ${VDSO}.so: linux_locore.o
${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd   
\
-S -g --binary-architecture i386:x86-64 linux_locore.o ${.TARGET}
+   strip -N _binary_linux_locore_o_size ${.TARGET}
 
 linux_support.o: assym.s linux_assym.h
${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319053 - in head/sys: compat/linux conf modules/linux modules/linux64

2017-05-28 Thread Dmitry Chagin
Author: dchagin
Date: Sun May 28 07:40:09 2017
New Revision: 319053
URL: https://svnweb.freebsd.org/changeset/base/319053

Log:
  On success, getrandom() Linux system call returns the number of bytes that
  were copied to the buffer supplied by the user.
  
  Also fix getrandom() if Linuxulator modules are built without the kernel.
  
  PR:   219464
  Submitted by: Maciej Pasternacki
  Reported by:  Maciej Pasternacki
  MFC after:1 week

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/conf/config.mk
  head/sys/modules/linux/Makefile
  head/sys/modules/linux64/Makefile

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sun May 28 07:37:40 2017
(r319052)
+++ head/sys/compat/linux/linux_misc.c  Sun May 28 07:40:09 2017
(r319053)
@@ -31,6 +31,9 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_compat.h"
+#if defined(KLD_MODULE)
+#include "opt_global.h"
+#endif
 
 #include 
 #include 
@@ -2516,6 +2519,7 @@ linux_getrandom(struct thread *td, struc
 {
struct uio uio;
struct iovec iov;
+   int error;
 
if (args->flags & ~(LINUX_GRND_NONBLOCK|LINUX_GRND_RANDOM))
return (EINVAL);
@@ -2532,7 +2536,10 @@ linux_getrandom(struct thread *td, struc
uio.uio_rw = UIO_READ;
uio.uio_td = td;
 
-   return (read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK));
+   error = read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK);
+   if (error == 0)
+   td->td_retval[0] = args->count - uio.uio_resid;
+   return (error);
 }
 
 int

Modified: head/sys/conf/config.mk
==
--- head/sys/conf/config.mk Sun May 28 07:37:40 2017(r319052)
+++ head/sys/conf/config.mk Sun May 28 07:40:09 2017(r319053)
@@ -8,6 +8,8 @@
 # the code here when they all produce identical results
 # (or should)
 .if !defined(KERNBUILDDIR)
+opt_global.h:
+   echo "#define DEV_RANDOM 1" >> ${.TARGET}
 opt_bpf.h:
echo "#define DEV_BPF 1" > ${.TARGET}
 .if ${MK_INET_SUPPORT} != "no"

Modified: head/sys/modules/linux/Makefile
==
--- head/sys/modules/linux/Makefile Sun May 28 07:37:40 2017
(r319052)
+++ head/sys/modules/linux/Makefile Sun May 28 07:40:09 2017
(r319053)
@@ -15,7 +15,7 @@ SRCS= linux_fork.c linux${SFX}_dummy.c l
linux${SFX}_machdep.c linux_misc.c linux_signal.c \
linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \
linux${SFX}_sysvec.c linux_uid16.c linux_time.c \
-   linux_timer.c linux_vdso.c \
+   linux_timer.c linux_vdso.c opt_global.h \
opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \
device_if.h bus_if.h assym.s \
linux${SFX}_support.s

Modified: head/sys/modules/linux64/Makefile
==
--- head/sys/modules/linux64/Makefile   Sun May 28 07:37:40 2017
(r319052)
+++ head/sys/modules/linux64/Makefile   Sun May 28 07:40:09 2017
(r319053)
@@ -10,7 +10,7 @@ SRCS= linux_fork.c linux_dummy.c linux_f
linux_machdep.c linux_misc.c linux_ptrace.c linux_signal.c \
linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \
linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \
-   opt_inet6.h opt_compat.h opt_posix.h opt_usb.h \
+   opt_inet6.h opt_compat.h opt_global.h opt_posix.h opt_usb.h \
vnode_if.h device_if.h bus_if.h assym.s \
linux_support.s
 DPSRCS=linux_genassym.c
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319057 - head/sys/amd64/linux

2017-05-28 Thread Dmitry Chagin
Author: dchagin
Date: Sun May 28 08:46:57 2017
New Revision: 319057
URL: https://svnweb.freebsd.org/changeset/base/319057

Log:
  In r246085 some bits that are MI movied out into headers in compat/linux,
  but I missed that when I commited x86_64 Linuxulator. So remove the 
duplicates.
  
  MFC after:1 week

Modified:
  head/sys/amd64/linux/linux.h

Modified: head/sys/amd64/linux/linux.h
==
--- head/sys/amd64/linux/linux.hSun May 28 08:46:41 2017
(r319056)
+++ head/sys/amd64/linux/linux.hSun May 28 08:46:57 2017
(r319057)
@@ -101,9 +101,6 @@ typedef struct {
 /*
  * Miscellaneous
  */
-#defineLINUX_NAME_MAX  255
-#defineLINUX_CTL_MAXNAME   10
-
 #define LINUX_AT_COUNT 19  /* Count of used aux entry types. */
 
 struct l___sysctl_args
@@ -117,11 +114,6 @@ struct l___sysctl_args
l_ulong __spare[4];
 };
 
-/* Scheduling policies */
-#defineLINUX_SCHED_OTHER   0
-#defineLINUX_SCHED_FIFO1
-#defineLINUX_SCHED_RR  2
-
 /* Resource limits */
 #defineLINUX_RLIMIT_CPU0
 #defineLINUX_RLIMIT_FSIZE  1
@@ -456,20 +448,6 @@ struct l_pollfd {
l_short revents;
 };
 
-
-#defineLINUX_CLONE_VM  0x0100
-#defineLINUX_CLONE_FS  0x0200
-#defineLINUX_CLONE_FILES   0x0400
-#defineLINUX_CLONE_SIGHAND 0x0800
-#defineLINUX_CLONE_PID 0x1000  /* No longer 
exist in Linux */
-#defineLINUX_CLONE_VFORK   0x4000
-#defineLINUX_CLONE_PARENT  0x8000
-#defineLINUX_CLONE_THREAD  0x0001
-#defineLINUX_CLONE_SETTLS  0x0008
-#defineLINUX_CLONE_PARENT_SETTID   0x0010
-#defineLINUX_CLONE_CHILD_CLEARTID  0x0020
-#defineLINUX_CLONE_CHILD_SETTID0x0100
-
 #define LINUX_ARCH_SET_GS  0x1001
 #define LINUX_ARCH_SET_FS  0x1002
 #define LINUX_ARCH_GET_FS  0x1003
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319570 - in head/sys: compat/linux conf modules/linux modules/linux64

2017-06-04 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jun  4 18:24:41 2017
New Revision: 319570
URL: https://svnweb.freebsd.org/changeset/base/319570

Log:
  Revert r319053 due to lack of sence. As pointed out by kib@ opt_global.h
  contains such fundamental settings as e.g. SMP option and fake
  opt_global.h almost never match real configured kernels.
  
  Reported by:  kib@

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/conf/config.mk
  head/sys/modules/linux/Makefile
  head/sys/modules/linux64/Makefile

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sun Jun  4 09:11:14 2017
(r319569)
+++ head/sys/compat/linux/linux_misc.c  Sun Jun  4 18:24:41 2017
(r319570)
@@ -31,9 +31,6 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_compat.h"
-#if defined(KLD_MODULE)
-#include "opt_global.h"
-#endif
 
 #include 
 #include 
@@ -2519,7 +2516,6 @@ linux_getrandom(struct thread *td, struct linux_getran
 {
struct uio uio;
struct iovec iov;
-   int error;
 
if (args->flags & ~(LINUX_GRND_NONBLOCK|LINUX_GRND_RANDOM))
return (EINVAL);
@@ -2536,10 +2532,7 @@ linux_getrandom(struct thread *td, struct linux_getran
uio.uio_rw = UIO_READ;
uio.uio_td = td;
 
-   error = read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK);
-   if (error == 0)
-   td->td_retval[0] = args->count - uio.uio_resid;
-   return (error);
+   return (read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK));
 }
 
 int

Modified: head/sys/conf/config.mk
==
--- head/sys/conf/config.mk Sun Jun  4 09:11:14 2017(r319569)
+++ head/sys/conf/config.mk Sun Jun  4 18:24:41 2017(r319570)
@@ -8,8 +8,6 @@
 # the code here when they all produce identical results
 # (or should)
 .if !defined(KERNBUILDDIR)
-opt_global.h:
-   echo "#define DEV_RANDOM 1" >> ${.TARGET}
 opt_bpf.h:
echo "#define DEV_BPF 1" > ${.TARGET}
 .if ${MK_INET_SUPPORT} != "no"

Modified: head/sys/modules/linux/Makefile
==
--- head/sys/modules/linux/Makefile Sun Jun  4 09:11:14 2017
(r319569)
+++ head/sys/modules/linux/Makefile Sun Jun  4 18:24:41 2017
(r319570)
@@ -15,7 +15,7 @@ SRCS= linux_fork.c linux${SFX}_dummy.c linux_file.c li
linux${SFX}_machdep.c linux_misc.c linux_signal.c \
linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \
linux${SFX}_sysvec.c linux_uid16.c linux_time.c \
-   linux_timer.c linux_vdso.c opt_global.h \
+   linux_timer.c linux_vdso.c \
opt_inet6.h opt_compat.h opt_posix.h opt_usb.h vnode_if.h \
device_if.h bus_if.h assym.s \
linux${SFX}_support.s

Modified: head/sys/modules/linux64/Makefile
==
--- head/sys/modules/linux64/Makefile   Sun Jun  4 09:11:14 2017
(r319569)
+++ head/sys/modules/linux64/Makefile   Sun Jun  4 18:24:41 2017
(r319570)
@@ -10,7 +10,7 @@ SRCS= linux_fork.c linux_dummy.c linux_file.c linux_ev
linux_machdep.c linux_misc.c linux_ptrace.c linux_signal.c \
linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \
linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \
-   opt_inet6.h opt_compat.h opt_global.h opt_posix.h opt_usb.h \
+   opt_inet6.h opt_compat.h opt_posix.h opt_usb.h \
vnode_if.h device_if.h bus_if.h assym.s \
linux_support.s
 DPSRCS=linux_genassym.c
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319571 - head/sys/compat/linux

2017-06-04 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jun  4 18:35:30 2017
New Revision: 319571
URL: https://svnweb.freebsd.org/changeset/base/319571

Log:
  On success, getrandom() Linux system call returns the number of bytes that
  were copied to the buffer supplied by the user.
  
  PR:   219464
  Submitted by: Maciej Pasternacki
  Reported by:  Maciej Pasternacki
  MFC after:1 week

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Sun Jun  4 18:24:41 2017
(r319570)
+++ head/sys/compat/linux/linux_misc.c  Sun Jun  4 18:35:30 2017
(r319571)
@@ -2516,6 +2516,7 @@ linux_getrandom(struct thread *td, struct linux_getran
 {
struct uio uio;
struct iovec iov;
+   int error;
 
if (args->flags & ~(LINUX_GRND_NONBLOCK|LINUX_GRND_RANDOM))
return (EINVAL);
@@ -2532,7 +2533,10 @@ linux_getrandom(struct thread *td, struct linux_getran
uio.uio_rw = UIO_READ;
uio.uio_td = td;
 
-   return (read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK));
+   error = read_random_uio(&uio, args->flags & LINUX_GRND_NONBLOCK);
+   if (error == 0)
+   td->td_retval[0] = args->count - uio.uio_resid;
+   return (error);
 }
 
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319849 - head/sys/compat/linux

2017-06-12 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jun 12 07:35:59 2017
New Revision: 319849
URL: https://svnweb.freebsd.org/changeset/base/319849

Log:
  Since r318735 (ino64 project) the size of the native struct dirent is
  equal or greater than the size of Linux struct dirent or struct dirent64.
  So, remove LINUX_RECLEN_RATIO magic as useless.

Modified:
  head/sys/compat/linux/linux_file.c

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Mon Jun 12 06:08:57 2017
(r319848)
+++ head/sys/compat/linux/linux_file.c  Mon Jun 12 07:35:59 2017
(r319849)
@@ -309,16 +309,6 @@ struct l_dirent64 {
 
 #defineLINUX_DIRBLKSIZ 512
 
-/*
- * Linux l_dirent is bigger than FreeBSD dirent, thus the buffer size
- * passed to kern_getdirentries() must be smaller than the one passed
- * to linux_getdents() by certain factor.
- */
-#defineLINUX_RECLEN_RATIO(X)   X * offsetof(struct dirent, d_name) /   
\
-offsetof(struct l_dirent, d_name);
-#defineLINUX_RECLEN64_RATIO(X) X * offsetof(struct dirent, d_name) /   
\
-offsetof(struct l_dirent64, d_name);
-
 int
 linux_getdents(struct thread *td, struct linux_getdents_args *args)
 {
@@ -337,8 +327,7 @@ linux_getdents(struct thread *td, struct linux_getdent
if (ldebug(getdents))
printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
 #endif
-   buflen = LINUX_RECLEN_RATIO(args->count);
-   buflen = min(buflen, MAXBSIZE);
+   buflen = min(args->count, MAXBSIZE);
buf = malloc(buflen, M_TEMP, M_WAITOK);
 
error = kern_getdirentries(td, args->fd, buf, buflen,
@@ -418,8 +407,7 @@ linux_getdents64(struct thread *td, struct linux_getde
if (ldebug(getdents64))
uprintf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
 #endif
-   buflen = LINUX_RECLEN64_RATIO(args->count);
-   buflen = min(buflen, MAXBSIZE);
+   buflen = min(args->count, MAXBSIZE);
buf = malloc(buflen, M_TEMP, M_WAITOK);
 
error = kern_getdirentries(td, args->fd, buf, buflen,
@@ -495,7 +483,6 @@ linux_readdir(struct thread *td, struct linux_readdir_
printf(ARGS(readdir, "%d, *"), args->fd);
 #endif
buflen = LINUX_RECLEN(LINUX_NAME_MAX);
-   buflen = LINUX_RECLEN_RATIO(buflen);
buf = malloc(buflen, M_TEMP, M_WAITOK);
 
error = kern_getdirentries(td, args->fd, buf, buflen,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r319851 - head/sys/compat/linux

2017-06-12 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jun 12 07:48:51 2017
New Revision: 319851
URL: https://svnweb.freebsd.org/changeset/base/319851

Log:
  Remove the outdated definition.
  
  MFC after:1 week

Modified:
  head/sys/compat/linux/linux_file.c

Modified: head/sys/compat/linux/linux_file.c
==
--- head/sys/compat/linux/linux_file.c  Mon Jun 12 07:43:58 2017
(r319850)
+++ head/sys/compat/linux/linux_file.c  Mon Jun 12 07:48:51 2017
(r319851)
@@ -307,8 +307,6 @@ struct l_dirent64 {
 roundup(offsetof(struct l_dirent64, d_name) + (namlen) + 1,
\
 sizeof(uint64_t))
 
-#defineLINUX_DIRBLKSIZ 512
-
 int
 linux_getdents(struct thread *td, struct linux_getdents_args *args)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320329 - head/sys/fs/pseudofs

2017-06-25 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jun 25 15:21:51 2017
New Revision: 320329
URL: https://svnweb.freebsd.org/changeset/base/320329

Log:
  PFS_DELEN is the sum of the permanent part of the struct dirent and
  fixed size for the name buffer PFS_NAMELEN.
  As r318736 was commited (ino64 project) the size of the permanent part
  of the struct dirent was changed, so calulate PFS_DELEN properly.

Modified:
  head/sys/fs/pseudofs/pseudofs.h

Modified: head/sys/fs/pseudofs/pseudofs.h
==
--- head/sys/fs/pseudofs/pseudofs.h Sun Jun 25 13:22:49 2017
(r320328)
+++ head/sys/fs/pseudofs/pseudofs.h Sun Jun 25 15:21:51 2017
(r320329)
@@ -52,7 +52,7 @@ struct vnode;
  */
 #define PFS_NAMELEN24
 #define PFS_FSNAMELEN  16  /* equal to MFSNAMELEN */
-#define PFS_DELEN  (8 + PFS_NAMELEN)
+#define PFS_DELEN  (offsetof(struct dirent, d_name) + PFS_NAMELEN)
 
 typedef enum {
pfstype_none = 0,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320595 - in head/sys: amd64/linux amd64/linux32 i386/linux

2017-07-03 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jul  3 10:24:49 2017
New Revision: 320595
URL: https://svnweb.freebsd.org/changeset/base/320595

Log:
  Add support for musl consumers to the Linuxulator.
  
  PR:   213809
  Submitted by: Yonas Yanfa
  Reported by:  Yonas Yanfa
  MFC after:1 week
  Relnotes: yes

Modified:
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Mon Jul  3 10:10:04 2017
(r320594)
+++ head/sys/amd64/linux/linux_sysvec.c Mon Jul  3 10:24:49 2017
(r320595)
@@ -923,9 +923,22 @@ static Elf64_Brandinfo linux_glibc2brandshort = {
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
+static Elf64_Brandinfo linux_muslbrand = {
+   .brand  = ELFOSABI_LINUX,
+   .machine= EM_X86_64,
+   .compat_3_brand = "Linux",
+   .emul_path  = "/compat/linux",
+   .interp_path= "/lib/ld-musl-x86_64.so.1",
+   .sysvec = &elf_linux_sysvec,
+   .interp_newpath = NULL,
+   .brand_note = &linux64_brandnote,
+   .flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
 Elf64_Brandinfo *linux_brandlist[] = {
&linux_glibc2brand,
&linux_glibc2brandshort,
+   &linux_muslbrand,
NULL
 };
 

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Mon Jul  3 10:10:04 2017
(r320594)
+++ head/sys/amd64/linux32/linux32_sysvec.c Mon Jul  3 10:24:49 2017
(r320595)
@@ -1141,9 +1141,22 @@ static Elf32_Brandinfo linux_glibc2brand = {
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
+static Elf32_Brandinfo linux_muslbrand = {
+   .brand  = ELFOSABI_LINUX,
+   .machine= EM_386,
+   .compat_3_brand = "Linux",
+   .emul_path  = "/compat/linux",
+   .interp_path= "/lib/ld-musl-i386.so.1",
+   .sysvec = &elf_linux_sysvec,
+   .interp_newpath = NULL,
+   .brand_note = &linux32_brandnote,
+   .flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
 Elf32_Brandinfo *linux_brandlist[] = {
&linux_brand,
&linux_glibc2brand,
+   &linux_muslbrand,
NULL
 };
 

Modified: head/sys/i386/linux/linux_sysvec.c
==
--- head/sys/i386/linux/linux_sysvec.c  Mon Jul  3 10:10:04 2017
(r320594)
+++ head/sys/i386/linux/linux_sysvec.c  Mon Jul  3 10:24:49 2017
(r320595)
@@ -1120,9 +1120,22 @@ static Elf32_Brandinfo linux_glibc2brand = {
.flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
+static Elf32_Brandinfo linux_muslbrand = {
+   .brand  = ELFOSABI_LINUX,
+   .machine= EM_386,
+   .compat_3_brand = "Linux",
+   .emul_path  = "/compat/linux",
+   .interp_path= "/lib/ld-musl-i386.so.1",
+   .sysvec = &elf_linux_sysvec,
+   .interp_newpath = NULL,
+   .brand_note = &linux_brandnote,
+   .flags  = BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
 Elf32_Brandinfo *linux_brandlist[] = {
&linux_brand,
&linux_glibc2brand,
+   &linux_muslbrand,
NULL
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320814 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:02:40 2017
New Revision: 320814
URL: https://svnweb.freebsd.org/changeset/base/320814

Log:
  Style(9). Add blank line aftr {.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 20:11:06 2017
(r320813)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:02:40 2017
(r320814)
@@ -68,6 +68,7 @@ static vfs_root_t fdesc_root;
 int
 fdesc_cmount(struct mntarg *ma, void *data, uint64_t flags)
 {
+
return kernel_mount(ma, flags);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320815 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:04:09 2017
New Revision: 320815
URL: https://svnweb.freebsd.org/changeset/base/320815

Log:
  Remove init from declaration.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:02:40 2017
(r320814)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:04:09 2017
(r320815)
@@ -78,10 +78,10 @@ fdesc_cmount(struct mntarg *ma, void *data, uint64_t f
 static int
 fdesc_mount(struct mount *mp)
 {
-   int error = 0;
struct fdescmount *fmp;
struct thread *td = curthread;
struct vnode *rvp;
+   int error;
 
if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_FDESCFS))
return (EPERM);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320816 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:05:28 2017
New Revision: 320816
URL: https://svnweb.freebsd.org/changeset/base/320816

Log:
  Remove init from declaration, collapse two int vars declarations into single.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:04:09 2017
(r320815)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:05:28 2017
(r320816)
@@ -124,9 +124,9 @@ fdesc_unmount(struct mount *mp, int mntflags)
 {
struct fdescmount *fmp;
caddr_t data;
-   int error;
-   int flags = 0;
+   int error, flags;
 
+   flags = 0;
fmp = (struct fdescmount *)mp->mnt_data;
if (mntflags & MNT_FORCE) {
/* The hash mutex protects the private mount flags. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320817 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:08:22 2017
New Revision: 320817
URL: https://svnweb.freebsd.org/changeset/base/320817

Log:
  Don't take a lock around atomic operation.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:05:28 2017
(r320816)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:08:22 2017
(r320817)
@@ -123,7 +123,6 @@ static int
 fdesc_unmount(struct mount *mp, int mntflags)
 {
struct fdescmount *fmp;
-   caddr_t data;
int error, flags;
 
flags = 0;
@@ -148,15 +147,10 @@ fdesc_unmount(struct mount *mp, int mntflags)
return (error);
 
/*
-* Finally, throw away the fdescmount structure. Hold the hashmtx to
-* protect the fdescmount structure.
+* Finally, throw away the fdescmount structure.
 */
-   mtx_lock(&fdesc_hashmtx);
-   data = mp->mnt_data;
mp->mnt_data = NULL;
-   mtx_unlock(&fdesc_hashmtx);
-   free(data, M_FDESCMNT); /* XXX */
-
+   free(fmp, M_FDESCMNT);
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320818 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:12:00 2017
New Revision: 320818
URL: https://svnweb.freebsd.org/changeset/base/320818

Log:
  Eliminate the bogus cast.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:08:22 2017
(r320817)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:12:00 2017
(r320818)
@@ -126,7 +126,7 @@ fdesc_unmount(struct mount *mp, int mntflags)
int error, flags;
 
flags = 0;
-   fmp = (struct fdescmount *)mp->mnt_data;
+   fmp = mp->mnt_data;
if (mntflags & MNT_FORCE) {
/* The hash mutex protects the private mount flags. */
mtx_lock(&fdesc_hashmtx);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320819 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:13:25 2017
New Revision: 320819
URL: https://svnweb.freebsd.org/changeset/base/320819

Log:
  Eliminate the bogus cast.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vfsops.c

Modified: head/sys/fs/fdescfs/fdesc_vfsops.c
==
--- head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:12:00 2017
(r320818)
+++ head/sys/fs/fdescfs/fdesc_vfsops.c  Sat Jul  8 21:13:25 2017
(r320819)
@@ -99,7 +99,7 @@ fdesc_mount(struct mount *mp)
 * We need to initialize a few bits of our local mount point struct to
 * avoid confusion in allocvp.
 */
-   mp->mnt_data = (qaddr_t) fmp;
+   mp->mnt_data = fmp;
fmp->flags = 0;
error = fdesc_allocvp(Froot, -1, FD_ROOT, mp, &rvp);
if (error) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320820 - head/sys/fs/fdescfs

2017-07-08 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jul  8 21:15:46 2017
New Revision: 320820
URL: https://svnweb.freebsd.org/changeset/base/320820

Log:
  Don't initialize error in declaration.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Sat Jul  8 21:13:25 2017
(r320819)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Sat Jul  8 21:15:46 2017
(r320820)
@@ -152,7 +152,7 @@ fdesc_allocvp(fdntype ftype, unsigned fd_fd, int ix, s
struct fdescnode *fd, *fd2;
struct vnode *vp, *vp2;
struct thread *td;
-   int error = 0;
+   int error;
 
td = curthread;
fc = FD_NHASH(ix);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320836 - head/sys/fs/fdescfs

2017-07-09 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jul  9 14:15:51 2017
New Revision: 320836
URL: https://svnweb.freebsd.org/changeset/base/320836

Log:
  Eliminate the bogus casts.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Sun Jul  9 13:56:34 2017
(r320835)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Sun Jul  9 14:15:51 2017
(r320836)
@@ -162,7 +162,7 @@ loop:
 * If a forced unmount is progressing, we need to drop it. The flags are
 * protected by the hashmtx.
 */
-   fmp = (struct fdescmount *)mp->mnt_data;
+   fmp = mp->mnt_data;
if (fmp == NULL || fmp->flags & FMNT_UNMOUNTF) {
mtx_unlock(&fdesc_hashmtx);
return (-1);
@@ -207,7 +207,7 @@ loop:
 * If a forced unmount is progressing, we need to drop it. The flags are
 * protected by the hashmtx.
 */
-   fmp = (struct fdescmount *)mp->mnt_data;
+   fmp = mp->mnt_data;
if (fmp == NULL || fmp->flags & FMNT_UNMOUNTF) {
mtx_unlock(&fdesc_hashmtx);
vgone(vp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320837 - head/sys/fs/fdescfs

2017-07-09 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jul  9 14:18:22 2017
New Revision: 320837
URL: https://svnweb.freebsd.org/changeset/base/320837

Log:
  Style(9). Whitespace.
  
  MFC after:3 weeks

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Sun Jul  9 14:15:51 2017
(r320836)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Sun Jul  9 14:18:22 2017
(r320837)
@@ -358,7 +358,7 @@ fdesc_lookup(struct vop_lookup_args *ap)
error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg,
LK_EXCLUSIVE, &fvp);
}
-   
+
if (error)
goto bad;
*vpp = fvp;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r346603 - in head/sys: amd64/linux32 i386/linux

2019-09-03 Thread Dmitry Chagin
Author: dchagin
Date: Tue Apr 23 18:10:46 2019
New Revision: 346603
URL: https://svnweb.freebsd.org/changeset/base/346603

Log:
  Since r339624 HEAD does not need for backslashes in syscalls.master,
  however to make a merge r345471 to the stable add backslashes
  to the syscalls.master.
  
  MFC after:3 days

Modified:
  head/sys/amd64/linux32/syscalls.master
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/amd64/linux32/syscalls.master  Tue Apr 23 18:10:46 2019
(r346603)
@@ -690,7 +690,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_NULLSTD { int linux_arch_prctl(l_int option,
+384AUE_NULLSTD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }

Modified: head/sys/i386/linux/syscalls.master
==
--- head/sys/i386/linux/syscalls.master Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/i386/linux/syscalls.master Tue Apr 23 18:10:46 2019
(r346603)
@@ -698,7 +698,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
+384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r346273 - in head/sys: compat/freebsd32 kern

2019-09-03 Thread Dmitry Chagin
вт, 16 апр. 2019 г. в 16:26, Ed Maste :

> Author: emaste
> Date: Tue Apr 16 13:26:31 2019
> New Revision: 346273
> URL: https://svnweb.freebsd.org/changeset/base/346273
>
> Log:
>   correct readlinkat(2) return type
>
>
Hi, Ed
make sysent?



>   r176215 corrected readlink(2)'s return type and the type of the last
>   argument.  readlink(2) was introduced in r177788 after being developed
>   as part of Google Summer of Code 2007; it appears to have inherited the
>   wrong return type.
>
>   Man pages and header files were already ssize_t; update syscalls.master
>   to match.
>
>   PR:   197915
>   Submitted by: Henning Petersen 
>   MFC after:2 weeks
>
> Modified:
>   head/sys/compat/freebsd32/syscalls.master
>   head/sys/kern/syscalls.master
>
> Modified: head/sys/compat/freebsd32/syscalls.master
>
> ==
> --- head/sys/compat/freebsd32/syscalls.master   Tue Apr 16 12:40:49 2019
>   (r346272)
> +++ head/sys/compat/freebsd32/syscalls.master   Tue Apr 16 13:26:31 2019
>   (r346273)
> @@ -963,7 +963,7 @@
> uint32_t dev); }
>  499AUE_OPENAT_RWTC NOPROTO { int openat(int fd, const char *path, \
> int flag, mode_t mode); }
> -500AUE_READLINKAT  NOPROTO { int readlinkat(int fd, const char *path,
> \
> +500AUE_READLINKAT  NOPROTO { ssize_t readlinkat(int fd, const char
> *path, \
> char *buf, size_t bufsize); }
>  501AUE_RENAMEATNOPROTO { int renameat(int oldfd, const char *old,
> \
> int newfd, const char *new); }
>
> Modified: head/sys/kern/syscalls.master
>
> ==
> --- head/sys/kern/syscalls.master   Tue Apr 16 12:40:49 2019
> (r346272)
> +++ head/sys/kern/syscalls.master   Tue Apr 16 13:26:31 2019
> (r346273)
> @@ -2716,7 +2716,7 @@
> );
> }
>  500AUE_READLINKAT  STD {
> -   int readlinkat(
> +   ssize_t readlinkat(
> int fd,
> _In_z_ const char *path,
> _Out_writes_bytes_(bufsize) char *buf,
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r333425 - in head/sys: cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs/zfs compat/cloudabi compat/linux compat/linuxkpi/common/include/linux dev/filemon dev/hwpmc fs

2019-05-27 Thread Dmitry Chagin
сб, 19 мая 2018 г. в 10:31, Matthew Macy :

> r333874
>
>
>

Hi, is it possible to merge r333425, r333874, r333813, r334118 and related
revs to the stable/11?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r348418 - head/sys/compat/linux

2019-05-30 Thread Dmitry Chagin
Author: dchagin
Date: Thu May 30 14:21:51 2019
New Revision: 348418
URL: https://svnweb.freebsd.org/changeset/base/348418

Log:
  Linux does not support MSG_OOB for unix(4) or non-stream oriented socket,
  return EOPNOTSUPP as a Linux does.
  
  Reviewed by:  tijl
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20409

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cThu May 30 14:13:09 2019
(r348417)
+++ head/sys/compat/linux/linux_socket.cThu May 30 14:21:51 2019
(r348418)
@@ -939,11 +939,13 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
struct iovec *iov;
socklen_t datalen;
struct sockaddr *sa;
+   struct socket *so;
sa_family_t sa_family;
+   struct file *fp;
void *data;
l_size_t len;
l_size_t clen;
-   int error;
+   int error, fflag;
 
error = copyin(msghdr, &linux_msg, sizeof(linux_msg));
if (error != 0)
@@ -974,12 +976,30 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 
control = NULL;
 
-   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
-   error = kern_getsockname(td, s, &sa, &datalen);
+   error = kern_getsockname(td, s, &sa, &datalen);
+   if (error != 0)
+   goto bad;
+   sa_family = sa->sa_family;
+   free(sa, M_SONAME);
+
+   if (flags & LINUX_MSG_OOB) {
+   error = EOPNOTSUPP;
+   if (sa_family == AF_UNIX)
+   goto bad;
+
+   error = getsock_cap(td, s, &cap_send_rights, &fp,
+   &fflag, NULL);
if (error != 0)
goto bad;
-   sa_family = sa->sa_family;
-   free(sa, M_SONAME);
+   so = fp->f_data;
+   if (so->so_type != SOCK_STREAM)
+   error = EOPNOTSUPP;
+   fdrop(fp, td);
+   if (error != 0)
+   goto bad;
+   }
+
+   if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
 
error = ENOBUFS;
control = m_get(M_WAITOK, MT_CONTROL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r348419 - in head: crypto/heimdal/lib/ipc share/man/man4 sys/compat/linux sys/kern sys/sys usr.sbin/mountd

2019-05-30 Thread Dmitry Chagin
Author: dchagin
Date: Thu May 30 14:24:26 2019
New Revision: 348419
URL: https://svnweb.freebsd.org/changeset/base/348419

Log:
  Complete LOCAL_PEERCRED support. Cache pid of the remote process in the
  struct xucred. Do not bump XUCRED_VERSION as struct layout is not changed.
  
  PR:   215202
  Reviewed by:  tijl
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20415

Modified:
  head/crypto/heimdal/lib/ipc/server.c
  head/share/man/man4/unix.4
  head/sys/compat/linux/linux_socket.c
  head/sys/kern/kern_prot.c
  head/sys/kern/uipc_usrreq.c
  head/sys/sys/ucred.h
  head/usr.sbin/mountd/mountd.c

Modified: head/crypto/heimdal/lib/ipc/server.c
==
--- head/crypto/heimdal/lib/ipc/server.cThu May 30 14:21:51 2019
(r348418)
+++ head/crypto/heimdal/lib/ipc/server.cThu May 30 14:24:26 2019
(r348419)
@@ -550,7 +550,7 @@ update_client_creds(struct client *c)
{
c->unixrights.uid = peercred.cr_uid;
c->unixrights.gid = peercred.cr_gid;
-   c->unixrights.pid = 0;
+   c->unixrights.pid = peercred.cr_pid;
return 1;
}
 }

Modified: head/share/man/man4/unix.4
==
--- head/share/man/man4/unix.4  Thu May 30 14:21:51 2019(r348418)
+++ head/share/man/man4/unix.4  Thu May 30 14:24:26 2019(r348419)
@@ -310,6 +310,7 @@ struct xucred {
   uid_tcr_uid; /* effective user id */
   shortcr_ngroups; /* number of groups */
   gid_tcr_groups[XU_NGROUPS];  /* groups */
+  pid_tcr_pid; /* process id of the sending process */
 };
 .Ed
 The

Modified: head/sys/compat/linux/linux_socket.c
==
--- head/sys/compat/linux/linux_socket.cThu May 30 14:21:51 2019
(r348418)
+++ head/sys/compat/linux/linux_socket.cThu May 30 14:24:26 2019
(r348419)
@@ -1519,10 +1519,7 @@ linux_getsockopt(struct thread *td, struct linux_getso
name, &xu, UIO_SYSSPACE, &xulen);
if (error != 0)
return (error);
-   /*
-* XXX Use 0 for pid as the FreeBSD does not cache peer 
pid.
-*/
-   lxu.pid = 0;
+   lxu.pid = xu.cr_pid;
lxu.uid = xu.cr_uid;
lxu.gid = xu.cr_gid;
return (copyout(&lxu, PTRIN(args->optval), 
sizeof(lxu)));

Modified: head/sys/kern/kern_prot.c
==
--- head/sys/kern/kern_prot.c   Thu May 30 14:21:51 2019(r348418)
+++ head/sys/kern/kern_prot.c   Thu May 30 14:24:26 2019(r348419)
@@ -1957,6 +1957,14 @@ cru2x(struct ucred *cr, struct xucred *xcr)
ngroups * sizeof(*cr->cr_groups));
 }
 
+void inline
+cru2xt(struct thread *td, struct xucred *xcr)
+{
+
+   cru2x(td->td_ucred, xcr);
+   xcr->cr_pid = td->td_proc->p_pid;
+}
+
 /*
  * Set initial process credentials.
  * Callers are responsible for providing the reference for provided 
credentials.

Modified: head/sys/kern/uipc_usrreq.c
==
--- head/sys/kern/uipc_usrreq.c Thu May 30 14:21:51 2019(r348418)
+++ head/sys/kern/uipc_usrreq.c Thu May 30 14:24:26 2019(r348419)
@@ -912,7 +912,7 @@ uipc_listen(struct socket *so, int backlog, struct thr
SOCK_LOCK(so);
error = solisten_proto_check(so);
if (error == 0) {
-   cru2x(td->td_ucred, &unp->unp_peercred);
+   cru2xt(td, &unp->unp_peercred);
solisten_proto(so, backlog);
}
SOCK_UNLOCK(so);
@@ -1656,7 +1656,7 @@ void
 unp_copy_peercred(struct thread *td, struct unpcb *client_unp,
 struct unpcb *server_unp, struct unpcb *listen_unp)
 {
-   cru2x(td->td_ucred, &client_unp->unp_peercred);
+   cru2xt(td, &client_unp->unp_peercred);
client_unp->unp_flags |= UNP_HAVEPC;
 
memcpy(&server_unp->unp_peercred, &listen_unp->unp_peercred,
@@ -2755,8 +2755,8 @@ db_print_xucred(int indent, struct xucred *xu)
int comma, i;
 
db_print_indent(indent);
-   db_printf("cr_version: %u   cr_uid: %u   cr_ngroups: %d\n",
-   xu->cr_version, xu->cr_uid, xu->cr_ngroups);
+   db_printf("cr_version: %u   cr_uid: %u   cr_pid: %d   cr_ngroups: %d\n",
+   xu->cr_version, xu->cr_uid, xu->cr_pid, xu->cr_ngroups);
db_print_indent(indent);
db_printf("cr_groups: ");
comma = 0;

Modified: head/sys/sys/ucred.h
==
--- head

svn commit: r348434 - head/sys/kern

2019-05-30 Thread Dmitry Chagin
Author: dchagin
Date: Thu May 30 16:11:20 2019
New Revision: 348434
URL: https://svnweb.freebsd.org/changeset/base/348434

Log:
  Remove wrong inline keyword.
  
  Reported by:  markj
  MFC after:1 week

Modified:
  head/sys/kern/kern_prot.c

Modified: head/sys/kern/kern_prot.c
==
--- head/sys/kern/kern_prot.c   Thu May 30 16:04:00 2019(r348433)
+++ head/sys/kern/kern_prot.c   Thu May 30 16:11:20 2019(r348434)
@@ -1957,7 +1957,7 @@ cru2x(struct ucred *cr, struct xucred *xcr)
ngroups * sizeof(*cr->cr_groups));
 }
 
-void inline
+void
 cru2xt(struct thread *td, struct xucred *xcr)
 {
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r348847 - head/sys/sys

2019-06-09 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jun 10 05:28:03 2019
New Revision: 348847
URL: https://svnweb.freebsd.org/changeset/base/348847

Log:
  Use C11 anonymous unions.
  
  PR:   215202
  Reported by:  glebius
  MFC after:2 weeks

Modified:
  head/sys/sys/ucred.h

Modified: head/sys/sys/ucred.h
==
--- head/sys/sys/ucred.hMon Jun 10 05:09:34 2019(r348846)
+++ head/sys/sys/ucred.hMon Jun 10 05:28:03 2019(r348847)
@@ -89,12 +89,11 @@ struct xucred {
gid_t   cr_groups[XU_NGROUPS];  /* groups */
union {
void*_cr_unused1;   /* compatibility with old ucred */
-   pid_t   _pid;
-   } _cr;
+   pid_t   cr_pid;
+   };
 };
 #defineXUCRED_VERSION  0
 
-#definecr_pid _cr._pid
 /* This can be used for both ucred and xucred structures. */
 #definecr_gid cr_groups[0]
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r348847 - head/sys/sys

2019-06-13 Thread Dmitry Chagin
Hi, All! thanks for reply,

I will be back in a week and fix it, I am rafting in Eastern Siberia))



чт, 13 июня 2019 г. в 11:43, Tijl Coosemans :

> On Wed, 12 Jun 2019 16:51:03 -0600 Warner Losh  wrote:
> > On Wed, Jun 12, 2019 at 4:49 PM Gleb Smirnoff 
> wrote:
> >> On Mon, Jun 10, 2019 at 11:09:09AM +0200, Tijl Coosemans wrote:
>  Date: Mon Jun 10 05:28:03 2019
>  New Revision: 348847
>  URL: https://svnweb.freebsd.org/changeset/base/348847
> 
>  Log:
>    Use C11 anonymous unions.
> 
>    PR:  215202
>    Reported by: glebius
>    MFC after:   2 weeks
> 
>  Modified:
>    head/sys/sys/ucred.h
> 
>  Modified: head/sys/sys/ucred.h
> 
> 
> ==
>
>  --- head/sys/sys/ucred.h   Mon Jun 10 05:09:34 2019(r348846)
>  +++ head/sys/sys/ucred.h   Mon Jun 10 05:28:03 2019(r348847)
>  @@ -89,12 +89,11 @@ struct xucred {
> gid_t   cr_groups[XU_NGROUPS];  /* groups */
> union {
> void*_cr_unused1;   /* compatibility with old ucred */
>  -  pid_t   _pid;
>  -  } _cr;
>  +  pid_t   cr_pid;
>  +  };
>   };
>   #define   XUCRED_VERSION  0
> 
>  -#define   cr_pid _cr._pid
>   /* This can be used for both ucred and xucred structures. */
>   #define   cr_gid cr_groups[0]
> >>>
> >>> Isn't this a userland header that should work with non-C11 compilers?
> >>
> >> It could make sense to keep such low bar for standard headers, but
> ucred.h
> >> is BSD-specific header and struct xucred is FreeBSD specific.
> >
> > This is solvable with proper visibility, I'd think..
>
> I think "union {" should be replaced with "__extension__ union {".  That
> seems to kill this warning:
>
> /usr/include/sys/ucred.h:90:2: warning: anonymous unions are a C11
> extension
>   [-Wc11-extensions]
> union {
> ^
> 1 warning generated.
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r356241 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux

2019-12-31 Thread Dmitry Chagin
Hi, HNY! What about vdso?

ср, 1 янв. 2020 г. в 01:01, Edward Tomasz Napierala :

> Author: trasz
> Date: Tue Dec 31 22:01:08 2019
> New Revision: 356241
> URL: https://svnweb.freebsd.org/changeset/base/356241
>
> Log:
>   Add basic getcpu(2) support to linuxulator.  The purpose of this
>   syscall is to query the CPU number and the NUMA domain the calling
>   thread is currently running on.  The third argument is ignored.
>   It doesn't do anything regarding scheduling - it's literally
>   just a way to query the current state, without any guarantees
>   you won't get rescheduled an opcode later.
>
>   This unbreaks Java from CentOS 8
>   (java-11-openjdk-11.0.5.10-0.el8_0.x86_64).
>
>   Reviewed by:  kib
>   MFC after:2 weeks
>   Sponsored by: The FreeBSD Foundation
>   Differential Revision:https://reviews.freebsd.org/D22972
>
> Modified:
>   head/sys/amd64/linux/linux_dummy.c
>   head/sys/amd64/linux32/linux32_dummy.c
>   head/sys/arm64/linux/linux_dummy.c
>   head/sys/compat/linux/linux_misc.c
>   head/sys/i386/linux/linux_dummy.c
>
> Modified: head/sys/amd64/linux/linux_dummy.c
>
> ==
> --- head/sys/amd64/linux/linux_dummy.c  Tue Dec 31 18:58:29 2019
> (r356240)
> +++ head/sys/amd64/linux/linux_dummy.c  Tue Dec 31 22:01:08 2019
> (r356241)
> @@ -102,8 +102,6 @@ DUMMY(tee);
>  DUMMY(vmsplice);
>  /* Linux 2.6.18: */
>  DUMMY(move_pages);
> -/* Linux 2.6.19: */
> -DUMMY(getcpu);
>  /* Linux 2.6.22: */
>  DUMMY(signalfd);
>  /* Linux 2.6.27: */
>
> Modified: head/sys/amd64/linux32/linux32_dummy.c
>
> ==
> --- head/sys/amd64/linux32/linux32_dummy.c  Tue Dec 31 18:58:29 2019
>   (r356240)
> +++ head/sys/amd64/linux32/linux32_dummy.c  Tue Dec 31 22:01:08 2019
>   (r356241)
> @@ -108,8 +108,6 @@ DUMMY(tee);
>  DUMMY(vmsplice);
>  /* Linux 2.6.18: */
>  DUMMY(move_pages);
> -/* Linux 2.6.19: */
> -DUMMY(getcpu);
>  /* Linux 2.6.22: */
>  DUMMY(signalfd);
>  /* Linux 2.6.27: */
>
> Modified: head/sys/arm64/linux/linux_dummy.c
>
> ==
> --- head/sys/arm64/linux/linux_dummy.c  Tue Dec 31 18:58:29 2019
> (r356240)
> +++ head/sys/arm64/linux/linux_dummy.c  Tue Dec 31 22:01:08 2019
> (r356241)
> @@ -104,8 +104,6 @@ DUMMY(tee);
>  DUMMY(vmsplice);
>  /* Linux 2.6.18: */
>  DUMMY(move_pages);
> -/* Linux 2.6.19: */
> -DUMMY(getcpu);
>  /* Linux 2.6.27: */
>  DUMMY(signalfd4);
>  DUMMY(inotify_init1);
>
> Modified: head/sys/compat/linux/linux_misc.c
>
> ==
> --- head/sys/compat/linux/linux_misc.c  Tue Dec 31 18:58:29 2019
> (r356240)
> +++ head/sys/compat/linux/linux_misc.c  Tue Dec 31 22:01:08 2019
> (r356241)
> @@ -2353,3 +2353,19 @@ out:
> td->td_retval[0] = dst - args->buf;
> return (error);
>  }
> +
> +int
> +linux_getcpu(struct thread *td, struct linux_getcpu_args *args)
> +{
> +   int cpu, error, node;
> +
> +   cpu = td->td_oncpu; /* Make sure it doesn't change during
> copyout(9) */
> +   error = 0;
> +   node = 0; /* XXX: Fake NUMA node 0 for now */
> +
> +   if (args->cpu != NULL)
> +   error = copyout(&cpu, args->cpu, sizeof(l_int));
> +   if (args->node != NULL)
> +   error = copyout(&node, args->node, sizeof(l_int));
> +   return (error);
> +}
>
> Modified: head/sys/i386/linux/linux_dummy.c
>
> ==
> --- head/sys/i386/linux/linux_dummy.c   Tue Dec 31 18:58:29 2019
> (r356240)
> +++ head/sys/i386/linux/linux_dummy.c   Tue Dec 31 22:01:08 2019
> (r356241)
> @@ -104,8 +104,6 @@ DUMMY(tee);
>  DUMMY(vmsplice);
>  /* Linux 2.6.18: */
>  DUMMY(move_pages);
> -/* Linux 2.6.19: */
> -DUMMY(getcpu);
>  /* Linux 2.6.22: */
>  DUMMY(signalfd);
>  /* Linux 2.6.27: */
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357491 - head/sys/compat/linux

2020-02-03 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb  4 05:23:34 2020
New Revision: 357491
URL: https://svnweb.freebsd.org/changeset/base/357491

Log:
  linux_to_native_clockid() properly initializes nwhich variable (or return 
error),
  so don't initialize nwhich in declaration and remove stale comment from 
r161304.
  
  Reviewed by:  emaste
  Differential Revision:https://reviews.freebsd.org/D23339
  MFC after:2 weeks

Modified:
  head/sys/compat/linux/linux_time.c

Modified: head/sys/compat/linux/linux_time.c
==
--- head/sys/compat/linux/linux_time.c  Tue Feb  4 04:29:54 2020
(r357490)
+++ head/sys/compat/linux/linux_time.c  Tue Feb  4 05:23:34 2020
(r357491)
@@ -253,7 +253,7 @@ linux_clock_gettime(struct thread *td, struct linux_cl
struct thread *targettd;
struct proc *p;
int error, clockwhich;
-   clockid_t nwhich = 0;   /* XXX: GCC */
+   clockid_t nwhich;
pid_t pid;
lwpid_t tid;
 
@@ -382,7 +382,7 @@ linux_clock_settime(struct thread *td, struct linux_cl
struct timespec ts;
struct l_timespec lts;
int error;
-   clockid_t nwhich = 0;   /* XXX: GCC */
+   clockid_t nwhich;
 
LIN_SDT_PROBE2(time, linux_clock_settime, entry, args->which, args->tp);
 
@@ -422,7 +422,7 @@ linux_clock_getres(struct thread *td, struct linux_clo
struct timespec ts;
struct l_timespec lts;
int error, clockwhich;
-   clockid_t nwhich = 0;   /* XXX: GCC */
+   clockid_t nwhich;
pid_t pid;
lwpid_t tid;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357492 - in head/sys: kern sys

2020-02-03 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb  4 05:25:51 2020
New Revision: 357492
URL: https://svnweb.freebsd.org/changeset/base/357492

Log:
  For code reuse in Linuxulator rename get_proccess_cputime()
  and get_thread_cputime() and add prototypes for it to .
  
  As both functions become a public interface add process lock assert
  to ensure that the process is not exiting under it.
  
  Fix whitespace nit while here.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D23340
  MFC after 2 weeks

Modified:
  head/sys/kern/kern_time.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/kern/kern_time.c
==
--- head/sys/kern/kern_time.c   Tue Feb  4 05:23:34 2020(r357491)
+++ head/sys/kern/kern_time.c   Tue Feb  4 05:25:51 2020(r357492)
@@ -242,7 +242,7 @@ sys_clock_gettime(struct thread *td, struct clock_gett
return (error);
 }
 
-static inline void 
+static inline void
 cputick2timespec(uint64_t runtime, struct timespec *ats)
 {
runtime = cputick2usec(runtime);
@@ -250,12 +250,15 @@ cputick2timespec(uint64_t runtime, struct timespec *at
ats->tv_nsec = runtime % 100 * 1000;
 }
 
-static void
-get_thread_cputime(struct thread *targettd, struct timespec *ats)
+void
+kern_thread_cputime(struct thread *targettd, struct timespec *ats)
 {
uint64_t runtime, curtime, switchtime;
+   struct proc *p;
 
if (targettd == NULL) { /* current thread */
+   p = curthread->td_proc;
+   PROC_LOCK_ASSERT(p, MA_OWNED);
critical_enter();
switchtime = PCPU_GET(switchtime);
curtime = cpu_ticks();
@@ -263,6 +266,8 @@ get_thread_cputime(struct thread *targettd, struct tim
critical_exit();
runtime += curtime - switchtime;
} else {
+   p = targettd->td_proc;
+   PROC_LOCK_ASSERT(p, MA_OWNED);
thread_lock(targettd);
runtime = targettd->td_runtime;
thread_unlock(targettd);
@@ -270,12 +275,13 @@ get_thread_cputime(struct thread *targettd, struct tim
cputick2timespec(runtime, ats);
 }
 
-static void
-get_process_cputime(struct proc *targetp, struct timespec *ats)
+void
+kern_process_cputime(struct proc *targetp, struct timespec *ats)
 {
uint64_t runtime;
struct rusage ru;
 
+   PROC_LOCK_ASSERT(targetp, MA_OWNED);
PROC_STATLOCK(targetp);
rufetch(targetp, &ru);
runtime = targetp->p_rux.rux_runtime;
@@ -300,14 +306,14 @@ get_cputime(struct thread *td, clockid_t clock_id, str
td2 = tdfind(tid, p->p_pid);
if (td2 == NULL)
return (EINVAL);
-   get_thread_cputime(td2, ats);
+   kern_thread_cputime(td2, ats);
PROC_UNLOCK(td2->td_proc);
} else {
pid = clock_id & CPUCLOCK_ID_MASK;
error = pget(pid, PGET_CANSEE, &p2);
if (error != 0)
return (EINVAL);
-   get_process_cputime(p2, ats);
+   kern_process_cputime(p2, ats);
PROC_UNLOCK(p2);
}
return (0);
@@ -360,11 +366,11 @@ kern_clock_gettime(struct thread *td, clockid_t clock_
ats->tv_nsec = 0;
break;
case CLOCK_THREAD_CPUTIME_ID:
-   get_thread_cputime(NULL, ats);
+   kern_thread_cputime(NULL, ats);
break;
case CLOCK_PROCESS_CPUTIME_ID:
PROC_LOCK(p);
-   get_process_cputime(p, ats);
+   kern_process_cputime(p, ats);
PROC_UNLOCK(p);
break;
default:

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Tue Feb  4 05:23:34 2020(r357491)
+++ head/sys/sys/syscallsubr.h  Tue Feb  4 05:25:51 2020(r357492)
@@ -91,6 +91,8 @@ int   kern_clock_nanosleep(struct thread *td, clockid_t 
const struct timespec *rqtp, struct timespec *rmtp);
 intkern_clock_settime(struct thread *td, clockid_t clock_id,
struct timespec *ats);
+void   kern_thread_cputime(struct thread *targettd, struct timespec *ats);
+void   kern_process_cputime(struct proc *targetp, struct timespec *ats);
 intkern_close(struct thread *td, int fd);
 intkern_connectat(struct thread *td, int dirfd, int fd,
struct sockaddr *sa);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357493 - head/sys/compat/linux

2020-02-03 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb  4 05:27:05 2020
New Revision: 357493
URL: https://svnweb.freebsd.org/changeset/base/357493

Log:
  Fix clock_gettime() and clock_getres() for cpu clocks:
  - handle the CLOCK_{PROCESS,THREAD}_CPUTIME_ID specified directly;
  - fix thread id calculation as in the Linuxulator we should
convert the user supplied thread id to struct thread * by linux_tdfind();
  - fix CPUCLOCK_SCHED case by using kern_{process,thread}_cputime()
directly as native get_cputime() used by kern_clock_gettime() uses
native tdfind()/pfind() to find proccess/thread.
  
  PR:   240990
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D23341
  MFC after:2 weeks

Modified:
  head/sys/compat/linux/linux_time.c

Modified: head/sys/compat/linux/linux_time.c
==
--- head/sys/compat/linux/linux_time.c  Tue Feb  4 05:25:51 2020
(r357492)
+++ head/sys/compat/linux/linux_time.c  Tue Feb  4 05:27:05 2020
(r357493)
@@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.14 2006/0
 #endif
 
 #include 
+#include 
 #include 
 
 /* DTrace init */
@@ -203,6 +204,12 @@ linux_to_native_clockid(clockid_t *n, clockid_t l)
case LINUX_CLOCK_MONOTONIC:
*n = CLOCK_MONOTONIC;
break;
+   case LINUX_CLOCK_PROCESS_CPUTIME_ID:
+   *n = CLOCK_PROCESS_CPUTIME_ID;
+   break;
+   case LINUX_CLOCK_THREAD_CPUTIME_ID:
+   *n = CLOCK_THREAD_CPUTIME_ID;
+   break;
case LINUX_CLOCK_REALTIME_COARSE:
*n = CLOCK_REALTIME_FAST;
break;
@@ -269,8 +276,13 @@ linux_clock_gettime(struct thread *td, struct linux_cl
 
switch (nwhich) {
case CLOCK_PROCESS_CPUTIME_ID:
-   clockwhich = LINUX_CPUCLOCK_WHICH(args->which);
-   pid = LINUX_CPUCLOCK_ID(args->which);
+   if (args->which < 0) {
+   clockwhich = LINUX_CPUCLOCK_WHICH(args->which);
+   pid = LINUX_CPUCLOCK_ID(args->which);
+   } else {
+   clockwhich = LINUX_CPUCLOCK_SCHED;
+   pid = 0;
+   }
if (pid == 0) {
p = td->td_proc;
PROC_LOCK(p);
@@ -296,12 +308,8 @@ linux_clock_gettime(struct thread *td, struct linux_cl
TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp);
break;
case LINUX_CPUCLOCK_SCHED:
+   kern_process_cputime(p, &tp);
PROC_UNLOCK(p);
-   error = kern_clock_getcpuclockid2(td, pid,
-   CPUCLOCK_WHICH_PID, &nwhich);
-   if (error != 0)
-   return (EINVAL);
-   error = kern_clock_gettime(td, nwhich, &tp);
break;
default:
PROC_UNLOCK(p);
@@ -311,14 +319,19 @@ linux_clock_gettime(struct thread *td, struct linux_cl
break;
 
case CLOCK_THREAD_CPUTIME_ID:
-   clockwhich = LINUX_CPUCLOCK_WHICH(args->which);
+   if (args->which < 0) {
+   clockwhich = LINUX_CPUCLOCK_WHICH(args->which);
+   tid = LINUX_CPUCLOCK_ID(args->which);
+   } else {
+   clockwhich = LINUX_CPUCLOCK_SCHED;
+   tid = 0;
+   }
p = td->td_proc;
-   tid = LINUX_CPUCLOCK_ID(args->which);
if (tid == 0) {
targettd = td;
PROC_LOCK(p);
} else {
-   targettd = tdfind(tid, p->p_pid);
+   targettd = linux_tdfind(td, tid, p->p_pid);
if (targettd == NULL)
return (EINVAL);
}
@@ -343,12 +356,10 @@ linux_clock_gettime(struct thread *td, struct linux_cl
TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp);
break;
case LINUX_CPUCLOCK_SCHED:
-   error = kern_clock_getcpuclockid2(td, tid,
-   CPUCLOCK_WHICH_TID, &nwhich);
+   if (td == targettd)
+   targettd = NULL;
+   kern_thread_cputime(targettd, &tp);
PROC_UNLOCK(p);
-   if (error != 0)
-   return (EINVAL);
-   error = kern_clock_gettime(td, nwhich, &tp);
break;
default:
PROC_UNLOCK(p);
@@ -440,25 +451,27 @@ linux_clock_getres(struct thread *td, struct linux_clo
 * Check user supplied clock id in case of per-process
 

Re: svn commit: r357530 - head/sys/kern

2020-02-04 Thread Dmitry Chagin
ср, 5 февр. 2020 г. в 00:02, Konstantin Belousov :

> Author: kib
> Date: Tue Feb  4 21:02:08 2020
> New Revision: 357530
> URL: https://svnweb.freebsd.org/changeset/base/357530
>
> Log:
>   Remove unneeded assert for curproc.  Simplify.
>
>   Reported by:  syzkaller by markj
>   Sponsored by: The FreeBSD Foundation
>
> Modified:
>   head/sys/kern/kern_time.c
>
> Modified: head/sys/kern/kern_time.c
>
> ==
> --- head/sys/kern/kern_time.c   Tue Feb  4 20:40:45 2020(r357529)
> +++ head/sys/kern/kern_time.c   Tue Feb  4 21:02:08 2020(r357530)
> @@ -254,11 +254,8 @@ void
>  kern_thread_cputime(struct thread *targettd, struct timespec *ats)
>  {
> uint64_t runtime, curtime, switchtime;
> -   struct proc *p;
>
> if (targettd == NULL) { /* current thread */
> -   p = curthread->td_proc;
> -   PROC_LOCK_ASSERT(p, MA_OWNED);
> critical_enter();
> switchtime = PCPU_GET(switchtime);
> curtime = cpu_ticks();
> @@ -266,8 +263,7 @@ kern_thread_cputime(struct thread *targettd, struct ti
> critical_exit();
> runtime += curtime - switchtime;
> } else {
> -   p = targettd->td_proc;
> -   PROC_LOCK_ASSERT(p, MA_OWNED);
> +   PROC_LOCK_ASSERT(targettd->td_proc, MA_OWNED);
> thread_lock(targettd);
> runtime = targettd->td_runtime;
> thread_unlock(targettd);
>


10x
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219041 - head/sys/kern

2011-02-25 Thread Dmitry Chagin
Author: dchagin
Date: Fri Feb 25 22:03:28 2011
New Revision: 219041
URL: http://svn.freebsd.org/changeset/base/219041

Log:
  ktrace_resize_pool() locking slightly reworked:
  1) do not take a lock around the single atomic operation.
  2) do not lose the invariant of lock by dropping/acquiring
 ktrace_mtx around free() or malloc().
  
  MFC after:1 Month.

Modified:
  head/sys/kern/kern_ktrace.c

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Fri Feb 25 20:49:07 2011(r219040)
+++ head/sys/kern/kern_ktrace.c Fri Feb 25 22:03:28 2011(r219041)
@@ -133,7 +133,7 @@ static struct sx ktrace_sx;
 
 static void ktrace_init(void *dummy);
 static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS);
-static u_int ktrace_resize_pool(u_int newsize);
+static u_int ktrace_resize_pool(u_int oldsize, u_int newsize);
 static struct ktr_request *ktr_getrequest(int type);
 static void ktr_submitrequest(struct thread *td, struct ktr_request *req);
 static void ktr_freeproc(struct proc *p, struct ucred **uc,
@@ -199,9 +199,7 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H
 
/* Handle easy read-only case first to avoid warnings from GCC. */
if (!req->newptr) {
-   mtx_lock(&ktrace_mtx);
oldsize = ktr_requestpool;
-   mtx_unlock(&ktrace_mtx);
return (SYSCTL_OUT(req, &oldsize, sizeof(u_int)));
}
 
@@ -210,10 +208,8 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H
return (error);
td = curthread;
ktrace_enter(td);
-   mtx_lock(&ktrace_mtx);
oldsize = ktr_requestpool;
-   newsize = ktrace_resize_pool(wantsize);
-   mtx_unlock(&ktrace_mtx);
+   newsize = ktrace_resize_pool(oldsize, wantsize);
ktrace_exit(td);
error = SYSCTL_OUT(req, &oldsize, sizeof(u_int));
if (error)
@@ -227,38 +223,40 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ
 "Pool buffer size for ktrace(1)");
 
 static u_int
-ktrace_resize_pool(u_int newsize)
+ktrace_resize_pool(u_int oldsize, u_int newsize)
 {
+   STAILQ_HEAD(, ktr_request) ktr_new;
struct ktr_request *req;
int bound;
 
-   mtx_assert(&ktrace_mtx, MA_OWNED);
print_message = 1;
-   bound = newsize - ktr_requestpool;
+   bound = newsize - oldsize;
if (bound == 0)
return (ktr_requestpool);
-   if (bound < 0)
+   if (bound < 0) {
+   mtx_lock(&ktrace_mtx);
/* Shrink pool down to newsize if possible. */
while (bound++ < 0) {
req = STAILQ_FIRST(&ktr_free);
if (req == NULL)
-   return (ktr_requestpool);
+   break;
STAILQ_REMOVE_HEAD(&ktr_free, ktr_list);
ktr_requestpool--;
-   mtx_unlock(&ktrace_mtx);
free(req, M_KTRACE);
-   mtx_lock(&ktrace_mtx);
}
-   else
+   } else {
/* Grow pool up to newsize. */
+   STAILQ_INIT(&ktr_new);
while (bound-- > 0) {
-   mtx_unlock(&ktrace_mtx);
req = malloc(sizeof(struct ktr_request), M_KTRACE,
M_WAITOK);
-   mtx_lock(&ktrace_mtx);
-   STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list);
-   ktr_requestpool++;
+   STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list);
}
+   mtx_lock(&ktrace_mtx);
+   STAILQ_CONCAT(&ktr_free, &ktr_new);
+   ktr_requestpool += (newsize - oldsize);
+   }
+   mtx_unlock(&ktrace_mtx);
return (ktr_requestpool);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219042 - in head/sys: kern sys

2011-02-25 Thread Dmitry Chagin
Author: dchagin
Date: Fri Feb 25 22:05:33 2011
New Revision: 219042
URL: http://svn.freebsd.org/changeset/base/219042

Log:
  Introduce preliminary support of the show description of the ABI of
  traced process by adding two new events which records value of process
  sv_flags to the trace file at process creation/execing/exiting time.
  
  MFC after:1 Month.

Modified:
  head/sys/kern/kern_exec.c
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_ktrace.c
  head/sys/sys/ktrace.h

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Fri Feb 25 22:03:28 2011(r219041)
+++ head/sys/kern/kern_exec.c   Fri Feb 25 22:05:33 2011(r219042)
@@ -899,6 +899,12 @@ done2:
exit1(td, W_EXITCODE(0, SIGABRT));
/* NOT REACHED */
}
+
+#ifdef KTRACE
+   if (error == 0)
+   ktrprocctor(p);
+#endif
+
return (error);
 }
 

Modified: head/sys/kern/kern_fork.c
==
--- head/sys/kern/kern_fork.c   Fri Feb 25 22:03:28 2011(r219041)
+++ head/sys/kern/kern_fork.c   Fri Feb 25 22:05:33 2011(r219042)
@@ -557,10 +557,6 @@ do_fork(struct thread *td, int flags, st
 
callout_init(&p2->p_itcallout, CALLOUT_MPSAFE);
 
-#ifdef KTRACE
-   ktrprocfork(p1, p2);
-#endif
-
/*
 * If PF_FORK is set, the child process inherits the
 * procfs ioctl flags from its parent.
@@ -596,6 +592,10 @@ do_fork(struct thread *td, int flags, st
p2->p_acflag = AFORK;
PROC_UNLOCK(p2);
 
+#ifdef KTRACE
+   ktrprocfork(p1, p2);
+#endif
+
/*
 * Finish creating the child process.  It will return via a different
 * execution path later.  (ie: directly into user mode)

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Fri Feb 25 22:03:28 2011(r219041)
+++ head/sys/kern/kern_ktrace.c Fri Feb 25 22:05:33 2011(r219042)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -93,6 +94,7 @@ struct ktr_request {
struct  ktr_header ktr_header;
void*ktr_buffer;
union {
+   struct  ktr_proc_ctor ktr_proc_ctor;
struct  ktr_syscall ktr_syscall;
struct  ktr_sysret ktr_sysret;
struct  ktr_genio ktr_genio;
@@ -113,6 +115,8 @@ static int data_lengths[] = {
0,  /* KTR_USER */
0,  /* KTR_STRUCT */
0,  /* KTR_SYSCTL */
+   sizeof(struct ktr_proc_ctor),   /* KTR_PROCCTOR */
+   0,  /* KTR_PROCDTOR */
 };
 
 static STAILQ_HEAD(, ktr_request) ktr_free;
@@ -134,7 +138,9 @@ static struct sx ktrace_sx;
 static void ktrace_init(void *dummy);
 static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS);
 static u_int ktrace_resize_pool(u_int oldsize, u_int newsize);
+static struct ktr_request *ktr_getrequest_ne(struct thread *, int type);
 static struct ktr_request *ktr_getrequest(int type);
+static void ktr_submitrequest_ne(struct thread *td, struct ktr_request *req);
 static void ktr_submitrequest(struct thread *td, struct ktr_request *req);
 static void ktr_freeproc(struct proc *p, struct ucred **uc,
 struct vnode **vp);
@@ -144,6 +150,7 @@ static void ktr_writerequest(struct thre
 static int ktrcanset(struct thread *,struct proc *);
 static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode 
*);
 static int ktrops(struct thread *,struct proc *,int,int,struct vnode *);
+static void ktrprocctor_ne(struct thread *, struct proc *p);
 
 /*
  * ktrace itself generates events, such as context switches, which we do not
@@ -265,18 +272,15 @@ CTASSERT(sizeof(((struct ktr_header *)NU
 (sizeof((struct thread *)NULL)->td_name));
 
 static struct ktr_request *
-ktr_getrequest(int type)
+ktr_getrequest_ne(struct thread *td, int type)
 {
struct ktr_request *req;
-   struct thread *td = curthread;
struct proc *p = td->td_proc;
int pm;
 
-   ktrace_enter(td);   /* XXX: In caller instead? */
mtx_lock(&ktrace_mtx);
if (!KTRCHECK(td, type)) {
mtx_unlock(&ktrace_mtx);
-   ktrace_exit(td);
return (NULL);
}
req = STAILQ_FIRST(&ktr_free);
@@ -302,11 +306,24 @@ ktr_getrequest(int type)
mtx_unlock(&ktrace_mtx);
if (pm)
printf("Out of ktrace request objects.\n");
-   ktrace_exit(td);
}
return (req);
 }
 
+static struct ktr_request *
+ktr_getrequest(int type)
+{
+   struct thread *td = curthread;
+   struct ktr_request *

svn commit: r219043 - in head/usr.bin: kdump ktrace

2011-02-25 Thread Dmitry Chagin
Author: dchagin
Date: Fri Feb 25 22:07:23 2011
New Revision: 219043
URL: http://svn.freebsd.org/changeset/base/219043

Log:
  Teach kdump to understand sv_flags records in the trace files.
  
  MFC after:1 Month.

Modified:
  head/usr.bin/kdump/kdump.c
  head/usr.bin/ktrace/ktrace.c
  head/usr.bin/ktrace/ktrace.h

Modified: head/usr.bin/kdump/kdump.c
==
--- head/usr.bin/kdump/kdump.c  Fri Feb 25 22:05:33 2011(r219042)
+++ head/usr.bin/kdump/kdump.c  Fri Feb 25 22:07:23 2011(r219043)
@@ -55,7 +55,9 @@ extern int errno;
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #ifdef IPX
 #include 
 #include 
@@ -81,15 +83,17 @@ extern int errno;
 #include "ktrace.h"
 #include "kdump_subr.h"
 
+u_int abidump(struct ktr_header *);
+int fetchprocinfo(struct ktr_header *, u_int *);
 int fread_tail(void *, int, int);
 void dumpheader(struct ktr_header *);
-void ktrsyscall(struct ktr_syscall *);
-void ktrsysret(struct ktr_sysret *);
+void ktrsyscall(struct ktr_syscall *, u_int);
+void ktrsysret(struct ktr_sysret *, u_int);
 void ktrnamei(char *, int);
 void hexdump(char *, int, int);
 void visdump(char *, int, int);
 void ktrgenio(struct ktr_genio *, int);
-void ktrpsig(struct ktr_psig *);
+void ktrpsig(struct ktr_psig *, u_int);
 void ktrcsw(struct ktr_csw *);
 void ktruser(int, unsigned char *);
 void ktrsockaddr(struct sockaddr *);
@@ -100,13 +104,22 @@ void sockfamilyname(int);
 const char *ioctlname(u_long);
 
 int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata,
-resolv = 0;
+resolv = 0, abiflag = 0;
 const char *tracefile = DEF_TRACEFILE;
 struct ktr_header ktr_header;
 
 #define TIME_FORMAT"%b %e %T %Y"
 #define eqs(s1, s2)(strcmp((s1), (s2)) == 0)
 
+struct proc_info
+{
+   TAILQ_ENTRY(proc_info)  info;
+   u_int   sv_flags;
+   pid_t   pid;
+};
+
+TAILQ_HEAD(trace_procs, proc_info) trace_procs;
+
 int
 main(int argc, char *argv[])
 {
@@ -115,11 +128,15 @@ main(int argc, char *argv[])
int trpoints = ALL_POINTS;
int drop_logged;
pid_t pid = 0;
+   u_int sv_flags;
 
(void) setlocale(LC_CTYPE, "");
 
-   while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1)
+   while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1)
switch((char)ch) {
+   case 'A':
+   abiflag = 1;
+   break;
case 'f':
tracefile = optarg;
break;
@@ -173,6 +190,7 @@ main(int argc, char *argv[])
errx(1, "%s", strerror(ENOMEM));
if (!freopen(tracefile, "r", stdin))
err(1, "%s", tracefile);
+   TAILQ_INIT(&trace_procs);
drop_logged = 0;
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
if (ktr_header.ktr_type & KTR_DROP) {
@@ -205,6 +223,9 @@ main(int argc, char *argv[])
}
if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
errx(1, "data too short");
+   if (fetchprocinfo(&ktr_header, (u_int *)m) != 0)
+   continue;
+   sv_flags = abidump(&ktr_header);
if (pid && ktr_header.ktr_pid != pid)
continue;
if ((trpoints & (1pid == kth->ktr_pid) {
+   TAILQ_REMOVE(&trace_procs, pi, info);
+   break;
+   }
+   }
+   pi = malloc(sizeof(struct proc_info));
+   if (pi == NULL)
+   errx(1, "%s", strerror(ENOMEM));
+   pi->sv_flags = *flags;
+   pi->pid = kth->ktr_pid;
+   TAILQ_INSERT_TAIL(&trace_procs, pi, info);
+   return (1);
+
+   case KTR_PROCDTOR:
+   TAILQ_FOREACH(pi, &trace_procs, info) {
+   if (pi->pid == kth->ktr_pid) {
+   TAILQ_REMOVE(&trace_procs, pi, info);
+   free(pi);
+   break;
+   }
+   }
+   return (1);
+   }
+
+   return (0);
+}
+
+u_int
+abidump(struct ktr_header *kth)
+{
+   struct proc_info *pi;
+   const char *abi;
+   const char *arch;
+   u_int flags = 0;
+
+   TAILQ_FOREACH(pi, &trace_procs, info) {
+   if (pi->pid == kth->ktr_pid) {
+   flags = pi->sv_flags;
+   break;
+   }
+   }
+
+   if (abiflag == 0)
+   return (flags);
+
+   switch (flags & SV_ABI_MASK) {
+   case SV_ABI_LINUX:
+   abi = "L";
+   break;
+   case SV_A

svn commit: r219044 - head/usr.bin/kdump

2011-02-25 Thread Dmitry Chagin
Author: dchagin
Date: Fri Feb 25 22:14:12 2011
New Revision: 219044
URL: http://svn.freebsd.org/changeset/base/219044

Log:
  Update manual page to reflect latest changes of ABI description support.
  
  MFC after:1 Month.

Modified:
  head/usr.bin/kdump/kdump.1

Modified: head/usr.bin/kdump/kdump.1
==
--- head/usr.bin/kdump/kdump.1  Fri Feb 25 22:07:23 2011(r219043)
+++ head/usr.bin/kdump/kdump.1  Fri Feb 25 22:14:12 2011(r219044)
@@ -36,7 +36,7 @@
 .Nd display kernel trace data
 .Sh SYNOPSIS
 .Nm
-.Op Fl dEnlHRsT
+.Op Fl dEnlHRsTA
 .Op Fl f Ar trfile
 .Op Fl m Ar maxdata
 .Op Fl p Ar pid
@@ -99,6 +99,8 @@ GIDs, dates etc. symbolically instead of
 Suppress display of I/O data.
 .It Fl T
 Display absolute timestamps for each entry (seconds since epoch).
+.It Fl A
+Display description of the ABI of traced process.
 .It Fl t Ar trstr
 See the
 .Fl t
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219138 - head/usr.bin/kdump

2011-03-01 Thread Dmitry Chagin
Author: dchagin
Date: Tue Mar  1 16:42:28 2011
New Revision: 219138
URL: http://svn.freebsd.org/changeset/base/219138

Log:
  Teach kdump to decode linux syscalls names too.
  
  Fix bug introduced in my previous commit: the kernel always dump native
  signal numbers, so no need to check the ABI in ktrpsig().
  
  Suggested by: jhb
  MFC after:1 Month.

Added:
  head/usr.bin/kdump/linux_syscalls.conf   (contents, props changed)
Modified:
  head/usr.bin/kdump/Makefile
  head/usr.bin/kdump/kdump.c

Modified: head/usr.bin/kdump/Makefile
==
--- head/usr.bin/kdump/Makefile Tue Mar  1 14:54:14 2011(r219137)
+++ head/usr.bin/kdump/Makefile Tue Mar  1 16:42:28 2011(r219138)
@@ -1,15 +1,23 @@
 #  @(#)Makefile8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
+.if (${MACHINE_ARCH} == "amd64")
+SFX=   32
+.endif
+
 .PATH: ${.CURDIR}/../ktrace
 
 PROG=  kdump
 SRCS=  kdump.c ioctl.c kdump_subr.c subr.c
 CFLAGS+=   -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../..
 
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
+SRCS+= linux_syscalls.c
+.endif
+
 WARNS?=0
 
-CLEANFILES=ioctl.c kdump_subr.c
+CLEANFILES=ioctl.c kdump_subr.c linux_syscalls.c
 
 ioctl.c: mkioctls
sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
@@ -17,4 +25,10 @@ ioctl.c: mkioctls
 kdump_subr.c: mksubr
sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET}
 
+linux_syscalls.c:
+   /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
+   ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master 
${.CURDIR}/linux_syscalls.conf
+   echo "int nlinux_syscalls = sizeof(linux_syscallnames) / 
sizeof(linux_syscallnames[0]);" \
+   >> linux_syscalls.c
+
 .include 

Modified: head/usr.bin/kdump/kdump.c
==
--- head/usr.bin/kdump/kdump.c  Tue Mar  1 14:54:14 2011(r219137)
+++ head/usr.bin/kdump/kdump.c  Tue Mar  1 16:42:28 2011(r219138)
@@ -93,7 +93,7 @@ void ktrnamei(char *, int);
 void hexdump(char *, int, int);
 void visdump(char *, int, int);
 void ktrgenio(struct ktr_genio *, int);
-void ktrpsig(struct ktr_psig *, u_int);
+void ktrpsig(struct ktr_psig *);
 void ktrcsw(struct ktr_csw *);
 void ktruser(int, unsigned char *);
 void ktrsockaddr(struct sockaddr *);
@@ -111,6 +111,41 @@ struct ktr_header ktr_header;
 #define TIME_FORMAT"%b %e %T %Y"
 #define eqs(s1, s2)(strcmp((s1), (s2)) == 0)
 
+#define print_number(i,n,c) do {   \
+   if (decimal)\
+   printf("%c%ld", c, (long)*i);   \
+   else\
+   printf("%c%#lx", c, (long)*i);  \
+   i++;\
+   n--;\
+   c = ',';\
+   } while (0);
+
+#if defined(__amd64__) || defined(__i386__)
+
+void linux_ktrsyscall(struct ktr_syscall *);
+void linux_ktrsysret(struct ktr_sysret *);
+extern char *linux_syscallnames[];
+extern int nlinux_syscalls;
+
+/*
+ * from linux.h
+ * Linux syscalls return negative errno's, we do positive and map them
+ */
+static int bsd_to_linux_errno[ELAST + 1] = {
+   -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9,
+   -10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
+   -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
+   -30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
+   -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
+   -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,-125, -84, -95, -16, -74,
+   -72, -67, -71
+};
+#endif
+
 struct proc_info
 {
TAILQ_ENTRY(proc_info)  info;
@@ -233,10 +268,20 @@ main(int argc, char *argv[])
drop_logged = 0;
switch (ktr_header.ktr_type) {
case KTR_SYSCALL:
-   ktrsyscall((struct ktr_syscall *)m, sv_flags);
+#if defined(__amd64__) || defined(__i386__)
+   if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
+   linux_ktrsyscall((struct ktr_syscall *)m);
+   else
+#endif
+   ktrsyscall((struct ktr_syscall *)m, sv_flags);
break;
case KTR_SYSRET:
-   ktrsysret((struct ktr_sysret *)m, sv_flags);
+#if defined(__amd64__) || defined(__i386__)
+   if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
+   linux_ktrsysret((struct ktr_sysret *)m);
+   else
+#endif
+   ktrsysret((struct ktr_sysret *)m, sv_flags);
break;

svn commit: r219240 - head/sys/compat/linux

2011-03-03 Thread Dmitry Chagin
Author: dchagin
Date: Thu Mar  3 18:19:10 2011
New Revision: 219240
URL: http://svn.freebsd.org/changeset/base/219240

Log:
  Switch PROCESS_SHARE to AUTO_SHARE (as umtx do). Even for SHARED,
  if page mapped MAP_ANON linux uses private algorithm too.
  
  Disscussed with:  jhb
  
  MFC after:3 Days

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Thu Mar  3 18:16:35 2011
(r219239)
+++ head/sys/compat/linux/linux_futex.c Thu Mar  3 18:19:10 2011
(r219240)
@@ -161,7 +161,7 @@ futex_get0(uint32_t *uaddr, struct futex
*newf = tmpf = NULL;
 
error = umtx_key_get(uaddr, TYPE_FUTEX, (flags & FUTEX_SHARED) ?
-   PROCESS_SHARE : THREAD_SHARE, &key);
+   AUTO_SHARE : THREAD_SHARE, &key);
if (error)
return (error);
 retry:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219242 - head/sys/compat/linux

2011-03-03 Thread Dmitry Chagin
Author: dchagin
Date: Thu Mar  3 18:29:55 2011
New Revision: 219242
URL: http://svn.freebsd.org/changeset/base/219242

Log:
  Print out shared flag for debug purpose.
  
  MFC after:1 Week

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Thu Mar  3 18:28:21 2011
(r219241)
+++ head/sys/compat/linux/linux_futex.c Thu Mar  3 18:29:55 2011
(r219242)
@@ -137,16 +137,16 @@ futex_put(struct futex *f, struct waitin
FUTEXES_UNLOCK;
FUTEX_UNLOCK(f);
 
-   LINUX_CTR2(sys_futex, "futex_put destroy uaddr %p ref %d",
-   f->f_uaddr, f->f_refcount);
+   LINUX_CTR3(sys_futex, "futex_put destroy uaddr %p ref %d "
+   "shared %d", f->f_uaddr, f->f_refcount, f->f_key.shared);
umtx_key_release(&f->f_key);
FUTEX_DESTROY(f);
free(f, M_FUTEX);
return;
}
 
-   LINUX_CTR2(sys_futex, "futex_put uaddr %p ref %d",
-   f->f_uaddr, f->f_refcount);
+   LINUX_CTR3(sys_futex, "futex_put uaddr %p ref %d shared %d",
+   f->f_uaddr, f->f_refcount, f->f_key.shared);
FUTEXES_UNLOCK;
FUTEX_UNLOCK(f);
 }
@@ -189,8 +189,8 @@ retry:
 
FUTEX_LOCK(f);
*newf = f;
-   LINUX_CTR2(sys_futex, "futex_get uaddr %p ref %d",
-   uaddr, f->f_refcount);
+   LINUX_CTR3(sys_futex, "futex_get uaddr %p ref %d shared 
%d",
+   uaddr, f->f_refcount, f->f_key.shared);
return (0);
}
}
@@ -223,8 +223,8 @@ retry:
LIST_INSERT_HEAD(&futex_list, tmpf, f_list);
FUTEXES_UNLOCK;
 
-   LINUX_CTR2(sys_futex, "futex_get uaddr %p ref %d new",
-   uaddr, tmpf->f_refcount);
+   LINUX_CTR3(sys_futex, "futex_get uaddr %p ref %d shared %d new",
+   uaddr, tmpf->f_refcount, tmpf->f_key.shared);
*newf = tmpf;
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219311 - head/sys/kern

2011-03-05 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar  5 20:36:42 2011
New Revision: 219311
URL: http://svn.freebsd.org/changeset/base/219311

Log:
  Partially reworked r219042.
  The reason for this is a bug at ktrops() where process dereferenced
  without having a lock. This might cause a panic if ktrace was runned
  with -p flag and the specified process exited between the dropping
  a lock and writing sv_flags.
  
  Since it is impossible to acquire sx lock while holding mtx switch
  to use asynchronous enqueuerequest() instead of writerequest().
  
  Rename ktr_getrequest_ne() to more understandable name [1].
  
  Requested by: jhb [1]
  
  MFC after:1 Week

Modified:
  head/sys/kern/kern_ktrace.c

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Sat Mar  5 20:15:32 2011(r219310)
+++ head/sys/kern/kern_ktrace.c Sat Mar  5 20:36:42 2011(r219311)
@@ -138,9 +138,8 @@ static struct sx ktrace_sx;
 static void ktrace_init(void *dummy);
 static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS);
 static u_int ktrace_resize_pool(u_int oldsize, u_int newsize);
-static struct ktr_request *ktr_getrequest_ne(struct thread *, int type);
+static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type);
 static struct ktr_request *ktr_getrequest(int type);
-static void ktr_submitrequest_ne(struct thread *td, struct ktr_request *req);
 static void ktr_submitrequest(struct thread *td, struct ktr_request *req);
 static void ktr_freeproc(struct proc *p, struct ucred **uc,
 struct vnode **vp);
@@ -150,7 +149,7 @@ static void ktr_writerequest(struct thre
 static int ktrcanset(struct thread *,struct proc *);
 static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode 
*);
 static int ktrops(struct thread *,struct proc *,int,int,struct vnode *);
-static void ktrprocctor_ne(struct thread *, struct proc *p);
+static void ktrprocctor_entered(struct thread *, struct proc *);
 
 /*
  * ktrace itself generates events, such as context switches, which we do not
@@ -272,7 +271,7 @@ CTASSERT(sizeof(((struct ktr_header *)NU
 (sizeof((struct thread *)NULL)->td_name));
 
 static struct ktr_request *
-ktr_getrequest_ne(struct thread *td, int type)
+ktr_getrequest_entered(struct thread *td, int type)
 {
struct ktr_request *req;
struct proc *p = td->td_proc;
@@ -317,7 +316,7 @@ ktr_getrequest(int type)
struct ktr_request *req;
 
ktrace_enter(td);
-   req = ktr_getrequest_ne(td, type);
+   req = ktr_getrequest_entered(td, type);
if (req == NULL)
ktrace_exit(td);
 
@@ -337,7 +336,6 @@ ktr_enqueuerequest(struct thread *td, st
mtx_lock(&ktrace_mtx);
STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list);
mtx_unlock(&ktrace_mtx);
-   ktrace_exit(td);
 }
 
 /*
@@ -377,7 +375,7 @@ ktr_drain(struct thread *td)
  * been cached in the thread.
  */
 static void
-ktr_submitrequest_ne(struct thread *td, struct ktr_request *req)
+ktr_submitrequest(struct thread *td, struct ktr_request *req)
 {
 
ktrace_assert(td);
@@ -387,14 +385,6 @@ ktr_submitrequest_ne(struct thread *td, 
ktr_writerequest(td, req);
ktr_freerequest(req);
sx_xunlock(&ktrace_sx);
-}
-
-static void
-ktr_submitrequest(struct thread *td, struct ktr_request *req)
-{
-
-   ktrace_assert(td);
-   ktr_submitrequest_ne(td, req);
ktrace_exit(td);
 }
 
@@ -523,12 +513,12 @@ ktrprocexit(struct thread *td)
return;
 
ktrace_enter(td);
+   req = ktr_getrequest_entered(td, KTR_PROCDTOR);
+   if (req != NULL)
+   ktr_enqueuerequest(td, req);
sx_xlock(&ktrace_sx);
ktr_drain(td);
sx_xunlock(&ktrace_sx);
-   req = ktr_getrequest_ne(td, KTR_PROCDTOR);
-   if (req != NULL)
-   ktr_submitrequest_ne(td, req);
PROC_LOCK(p);
mtx_lock(&ktrace_mtx);
ktr_freeproc(p, &cred, &vp);
@@ -545,21 +535,20 @@ ktrprocexit(struct thread *td)
 }
 
 static void
-ktrprocctor_ne(struct thread *td, struct proc *p)
+ktrprocctor_entered(struct thread *td, struct proc *p)
 {
struct ktr_proc_ctor *ktp;
struct ktr_request *req;
-   struct thread *td2;
+   struct thread *td2;;
 
ktrace_assert(td);
td2 = FIRST_THREAD_IN_PROC(p);
-   req = ktr_getrequest_ne(td2, KTR_PROCCTOR);
+   req = ktr_getrequest_entered(td2, KTR_PROCCTOR);
if (req == NULL)
return;
-
ktp = &req->ktr_data.ktr_proc_ctor;
ktp->sv_flags = p->p_sysent->sv_flags;
-   ktr_submitrequest_ne(td, req);
+   ktr_enqueuerequest(td2, req);
 }
 
 void
@@ -571,7 +560,7 @@ ktrprocctor(struct proc *p)
return;
 
ktrace_enter(td);
-   ktrprocctor_ne(td, p);
+   ktrprocctor_entered(td, p);
ktrace_exit(td);
 }
 
@@ -721,6 +710,7 @@ ktrpsig(sig, action, mask, code)
   

svn commit: r219312 - head/sys/kern

2011-03-05 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar  5 20:54:17 2011
New Revision: 219312
URL: http://svn.freebsd.org/changeset/base/219312

Log:
  Style(9) fix.
  Fix indentation in comment, double ';' in variable declaration.
  
  MFC after:1 Week

Modified:
  head/sys/kern/kern_ktrace.c

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Sat Mar  5 20:36:42 2011(r219311)
+++ head/sys/kern/kern_ktrace.c Sat Mar  5 20:54:17 2011(r219312)
@@ -111,7 +111,7 @@ static int data_lengths[] = {
0,  /* KTR_NAMEI */
sizeof(struct ktr_genio),   /* KTR_GENIO */
sizeof(struct ktr_psig),/* KTR_PSIG */
-   sizeof(struct ktr_csw), /* KTR_CSW */
+   sizeof(struct ktr_csw), /* KTR_CSW */
0,  /* KTR_USER */
0,  /* KTR_STRUCT */
0,  /* KTR_SYSCTL */
@@ -539,7 +539,7 @@ ktrprocctor_entered(struct thread *td, s
 {
struct ktr_proc_ctor *ktp;
struct ktr_request *req;
-   struct thread *td2;;
+   struct thread *td2;
 
ktrace_assert(td);
td2 = FIRST_THREAD_IN_PROC(p);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219364 - head/sys/amd64/linux32

2011-03-07 Thread Dmitry Chagin
Author: dchagin
Date: Mon Mar  7 08:12:07 2011
New Revision: 219364
URL: http://svn.freebsd.org/changeset/base/219364

Log:
  Remove dead code.
  
  MFC after:1 Week

Modified:
  head/sys/amd64/linux32/linux32_genassym.c

Modified: head/sys/amd64/linux32/linux32_genassym.c
==
--- head/sys/amd64/linux32/linux32_genassym.c   Mon Mar  7 07:31:15 2011
(r219363)
+++ head/sys/amd64/linux32/linux32_genassym.c   Mon Mar  7 08:12:07 2011
(r219364)
@@ -9,8 +9,6 @@ __FBSDID("$FreeBSD$");
 
 ASSYM(LINUX_SIGF_HANDLER, offsetof(struct l_sigframe, sf_handler));
 ASSYM(LINUX_SIGF_SC, offsetof(struct l_sigframe, sf_sc));
-ASSYM(LINUX_SC_ES, offsetof(struct l_sigcontext, sc_es));
-ASSYM(LINUX_SC_DS, offsetof(struct l_sigcontext, sc_ds));
 ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler));
 ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc));
 ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219405 - in head/sys: amd64/amd64 amd64/linux32 arm/arm compat/ia32 compat/linux compat/svr4 i386/i386 i386/ibcs2 i386/linux ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sys

2011-03-08 Thread Dmitry Chagin
Author: dchagin
Date: Tue Mar  8 19:01:45 2011
New Revision: 219405
URL: http://svn.freebsd.org/changeset/base/219405

Log:
  Extend struct sysvec with new method sv_schedtail, which is used for an
  explicit process at fork trampoline path instead of eventhadler(schedtail)
  invocation for each child process.
  
  Remove eventhandler(schedtail) code and change linux ABI to use newly added
  sysvec method.
  
  While here replace explicit comparing of module sysentvec structure with the
  newly created process sysentvec to detect the linux ABI.
  
  Discussed with:   kib
  
  MFC after:2 Week

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/elf_machdep.c
  head/sys/compat/ia32/ia32_sysvec.c
  head/sys/compat/linux/linux_emul.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/svr4/svr4_sysvec.c
  head/sys/i386/i386/elf_machdep.c
  head/sys/i386/ibcs2/ibcs2_sysvec.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/ia64/ia64/elf_machdep.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/init_main.c
  head/sys/kern/kern_fork.c
  head/sys/mips/mips/elf64_machdep.c
  head/sys/mips/mips/elf_machdep.c
  head/sys/powerpc/powerpc/elf32_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c
  head/sys/sparc64/sparc64/elf_machdep.c
  head/sys/sys/eventhandler.h
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/elf_machdep.c
==
--- head/sys/amd64/amd64/elf_machdep.c  Tue Mar  8 18:39:41 2011
(r219404)
+++ head/sys/amd64/amd64/elf_machdep.c  Tue Mar  8 19:01:45 2011
(r219405)
@@ -81,6 +81,7 @@ struct sysentvec elf64_freebsd_sysvec = 
.sv_syscallnames = syscallnames,
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
+   .sv_schedtail   = NULL,
 };
 INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
 

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Tue Mar  8 18:39:41 2011
(r219404)
+++ head/sys/amd64/linux32/linux32_sysvec.c Tue Mar  8 19:01:45 2011
(r219405)
@@ -128,7 +128,6 @@ static void linux32_fixlimit(struct rlim
 static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
 
 static eventhandler_tag linux_exit_tag;
-static eventhandler_tag linux_schedtail_tag;
 static eventhandler_tag linux_exec_tag;
 
 /*
@@ -1063,6 +1062,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = linux32_fetch_syscall_args,
.sv_syscallnames = NULL,
+   .sv_schedtail   = linux_schedtail,
 };
 
 static char GNU_ABI_VENDOR[] = "GNU";
@@ -1156,8 +1156,6 @@ linux_elf_modevent(module_t mod, int typ
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
linux_proc_exit, NULL, 1000);
-   linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail,
-   linux_schedtail, NULL, 1000);
linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
linux_proc_exec, NULL, 1000);
linux_szplatform = roundup(strlen(linux_platform) + 1,
@@ -1189,7 +1187,6 @@ linux_elf_modevent(module_t mod, int typ
sx_destroy(&emul_shared_lock);
mtx_destroy(&futex_mtx);
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
-   EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
linux_osd_jail_deregister();
if (bootverbose)

Modified: head/sys/arm/arm/elf_machdep.c
==
--- head/sys/arm/arm/elf_machdep.c  Tue Mar  8 18:39:41 2011
(r219404)
+++ head/sys/arm/arm/elf_machdep.c  Tue Mar  8 19:01:45 2011
(r219405)
@@ -78,6 +78,7 @@ struct sysentvec elf32_freebsd_sysvec = 
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = NULL, /* XXXKIB */
.sv_syscallnames = syscallnames,
+   .sv_schedtail   = NULL,
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: head/sys/compat/ia32/ia32_sysvec.c
==
--- head/sys/compat/ia32/ia32_sysvec.c  Tue Mar  8 18:39:41 2011
(r219404)
+++ head/sys/compat/ia32/ia32_sysvec.c  Tue Mar  8 19:01:45 2011
(r219405)
@@ -149,6 +149,7 @@ struct sysentvec ia32_freebsd_sysvec = {
.sv_syscallnames = freebsd32_syscallnames,
.sv_shared_page_base = FREEBSD32_SHAREDPAGE,
.sv_shared_page_len =

svn commit: r219406 - head/sys/sys

2011-03-08 Thread Dmitry Chagin
Author: dchagin
Date: Tue Mar  8 19:05:14 2011
New Revision: 219406
URL: http://svn.freebsd.org/changeset/base/219406

Log:
  Bump __FreeBSD_version for struct sysvec (sv_schedtail) changes.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hTue Mar  8 19:01:45 2011(r219405)
+++ head/sys/sys/param.hTue Mar  8 19:05:14 2011(r219406)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 900033   /* Master, propagated to newvers */
+#define __FreeBSD_version 900034   /* Master, propagated to newvers */
 
 #ifdef _KERNEL
 #defineP_OSREL_SIGSEGV 74
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219421 - head/sys/compat/linux

2011-03-08 Thread Dmitry Chagin
Author: dchagin
Date: Wed Mar  9 05:59:33 2011
New Revision: 219421
URL: http://svn.freebsd.org/changeset/base/219421

Log:
  Indeed, remove bogus since r219405 check of the Linux ABI.
  
  Pointed out:  jhb
  
  MFC after:2 Week

Modified:
  head/sys/compat/linux/linux_emul.c

Modified: head/sys/compat/linux/linux_emul.c
==
--- head/sys/compat/linux/linux_emul.c  Wed Mar  9 04:48:06 2011
(r219420)
+++ head/sys/compat/linux/linux_emul.c  Wed Mar  9 05:59:33 2011
(r219421)
@@ -309,9 +309,6 @@ linux_schedtail(struct thread *td)
 
p = td->td_proc;
 
-   if (SV_PROC_ABI(p) != SV_ABI_LINUX)
-   return;
-
/* find the emuldata */
em = em_find(p, EMUL_DOLOCK);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219558 - head/sys/compat/linux

2011-03-11 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar 12 07:47:05 2011
New Revision: 219558
URL: http://svn.freebsd.org/changeset/base/219558

Log:
  Style(9) fixes. No functional changes.
  
  MFC after:2 Week

Modified:
  head/sys/compat/linux/linux_ipc.c

Modified: head/sys/compat/linux/linux_ipc.c
==
--- head/sys/compat/linux/linux_ipc.c   Sat Mar 12 07:03:06 2011
(r219557)
+++ head/sys/compat/linux/linux_ipc.c   Sat Mar 12 07:47:05 2011
(r219558)
@@ -97,6 +97,7 @@ struct l_msginfo {
 static void
 bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp)
 {
+
lpp->shmmax = bpp->shmmax;
lpp->shmmin = bpp->shmmin;
lpp->shmmni = bpp->shmmni;
@@ -107,6 +108,7 @@ bsd_to_linux_shminfo( struct shminfo *bp
 static void
 bsd_to_linux_shm_info( struct shm_info *bpp, struct l_shm_info *lpp)
 {
+
lpp->used_ids = bpp->used_ids ;
lpp->shm_tot = bpp->shm_tot ;
lpp->shm_rss = bpp->shm_rss ;
@@ -128,26 +130,28 @@ struct l_ipc_perm {
 static void
 linux_to_bsd_ipc_perm(struct l_ipc_perm *lpp, struct ipc_perm *bpp)
 {
-bpp->key = lpp->key;
-bpp->uid = lpp->uid;
-bpp->gid = lpp->gid;
-bpp->cuid = lpp->cuid;
-bpp->cgid = lpp->cgid;
-bpp->mode = lpp->mode;
-bpp->seq = lpp->seq;
+
+   bpp->key = lpp->key;
+   bpp->uid = lpp->uid;
+   bpp->gid = lpp->gid;
+   bpp->cuid = lpp->cuid;
+   bpp->cgid = lpp->cgid;
+   bpp->mode = lpp->mode;
+   bpp->seq = lpp->seq;
 }
 
 
 static void
 bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct l_ipc_perm *lpp)
 {
-lpp->key = bpp->key;
-lpp->uid = bpp->uid;
-lpp->gid = bpp->gid;
-lpp->cuid = bpp->cuid;
-lpp->cgid = bpp->cgid;
-lpp->mode = bpp->mode;
-lpp->seq = bpp->seq;
+
+   lpp->key = bpp->key;
+   lpp->uid = bpp->uid;
+   lpp->gid = bpp->gid;
+   lpp->cuid = bpp->cuid;
+   lpp->cgid = bpp->cgid;
+   lpp->mode = bpp->mode;
+   lpp->seq = bpp->seq;
 }
 
 struct l_msqid_ds {
@@ -202,16 +206,18 @@ struct l_shmid_ds {
 static void
 linux_to_bsd_semid_ds(struct l_semid_ds *lsp, struct semid_ds *bsp)
 {
-linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
-bsp->sem_otime = lsp->sem_otime;
-bsp->sem_ctime = lsp->sem_ctime;
-bsp->sem_nsems = lsp->sem_nsems;
-bsp->sem_base = PTRIN(lsp->sem_base);
+
+   linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
+   bsp->sem_otime = lsp->sem_otime;
+   bsp->sem_ctime = lsp->sem_ctime;
+   bsp->sem_nsems = lsp->sem_nsems;
+   bsp->sem_base = PTRIN(lsp->sem_base);
 }
 
 static void
 bsd_to_linux_semid_ds(struct semid_ds *bsp, struct l_semid_ds *lsp)
 {
+
bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
lsp->sem_otime = bsp->sem_otime;
lsp->sem_ctime = bsp->sem_ctime;
@@ -222,62 +228,66 @@ bsd_to_linux_semid_ds(struct semid_ds *b
 static void
 linux_to_bsd_shmid_ds(struct l_shmid_ds *lsp, struct shmid_ds *bsp)
 {
-linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
-bsp->shm_segsz = lsp->shm_segsz;
-bsp->shm_lpid = lsp->shm_lpid;
-bsp->shm_cpid = lsp->shm_cpid;
-bsp->shm_nattch = lsp->shm_nattch;
-bsp->shm_atime = lsp->shm_atime;
-bsp->shm_dtime = lsp->shm_dtime;
-bsp->shm_ctime = lsp->shm_ctime;
+
+   linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
+   bsp->shm_segsz = lsp->shm_segsz;
+   bsp->shm_lpid = lsp->shm_lpid;
+   bsp->shm_cpid = lsp->shm_cpid;
+   bsp->shm_nattch = lsp->shm_nattch;
+   bsp->shm_atime = lsp->shm_atime;
+   bsp->shm_dtime = lsp->shm_dtime;
+   bsp->shm_ctime = lsp->shm_ctime;
 }
 
 static void
 bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct l_shmid_ds *lsp)
 {
-bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
-if (bsp->shm_segsz > INT_MAX)
-   lsp->shm_segsz = INT_MAX;
-else
-   lsp->shm_segsz = bsp->shm_segsz;
-lsp->shm_lpid = bsp->shm_lpid;
-lsp->shm_cpid = bsp->shm_cpid;
-if (bsp->shm_nattch > SHRT_MAX)
-   lsp->shm_nattch = SHRT_MAX;
-else
-   lsp->shm_nattch = bsp->shm_nattch;
-lsp->shm_atime = bsp->shm_atime;
-lsp->shm_dtime = bsp->shm_dtime;
-lsp->shm_ctime = bsp->shm_ctime;
-lsp->private3 = 0;
+
+   bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
+   if (bsp->shm_segsz > INT_MAX)
+   lsp->shm_segsz = INT_MAX;
+   else
+   lsp->shm_segsz = bsp->shm_segsz;
+   lsp->shm_lpid = bsp->shm_lpid;
+   lsp->shm_cpid = bsp->shm_cpid;
+   if (bsp->shm_nattch > SHRT_MAX)
+   lsp->shm_nattch = SHRT_MAX;
+   else
+   lsp->shm_nattch = bsp->shm_nattch;
+   lsp->shm_atime = bsp->shm_atime;
+   lsp->shm_dtime = bsp->shm_dtime;
+   lsp->shm_ctime = bsp->shm_ctime;
+   lsp->private3 = 0;
 }
 
 static void
 linux_to_bsd_msqid_ds(struct l_msqid_ds *lsp, struct msqid_ds *bsp)
 {
-   

svn commit: r219609 - in head/sys: amd64/linux32 i386/linux

2011-03-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 13 14:58:02 2011
New Revision: 219609
URL: http://svn.freebsd.org/changeset/base/219609

Log:
  Enable shared page use for amd64/linux32 and i386/linux binaries.
  Move signal trampoline code from the top of the stack to the shared page.
  
  MFC after:2 Weeks

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux32/linux.h
==
--- head/sys/amd64/linux32/linux.h  Sun Mar 13 13:42:43 2011
(r219608)
+++ head/sys/amd64/linux32/linux.h  Sun Mar 13 14:58:02 2011
(r219609)
@@ -47,7 +47,10 @@ extern u_char linux_debug_map[];
 MALLOC_DECLARE(M_LINUX);
 #endif
 
-#defineLINUX32_USRSTACK((1ul << 32) - PAGE_SIZE)
+#defineLINUX32_MAXUSER ((1ul << 32) - PAGE_SIZE)
+#defineLINUX32_SHAREDPAGE  (LINUX32_MAXUSER - PAGE_SIZE)
+#defineLINUX32_USRSTACKLINUX32_SHAREDPAGE
+
 /* XXX 16 = sizeof(linux32_ps_strings) */
 #defineLINUX32_PS_STRINGS  (LINUX32_USRSTACK - 16)
 #defineLINUX32_MAXDSIZ (512 * 1024 * 1024) /* 512MB */

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Sun Mar 13 13:42:43 2011
(r219608)
+++ head/sys/amd64/linux32/linux32_sysvec.c Sun Mar 13 14:58:02 2011
(r219609)
@@ -411,8 +411,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo
 * Build context to run handler in.
 */
regs->tf_rsp = PTROUT(fp);
-   regs->tf_rip = LINUX32_PS_STRINGS - *(p->p_sysent->sv_szsigcode) +
-   linux_sznonrtsigcode;
+   regs->tf_rip = p->p_sysent->sv_sigcode_base + linux_sznonrtsigcode;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
@@ -535,7 +534,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t 
 * Build context to run handler in.
 */
regs->tf_rsp = PTROUT(fp);
-   regs->tf_rip = LINUX32_PS_STRINGS - *(p->p_sysent->sv_szsigcode);
+   regs->tf_rip = p->p_sysent->sv_sigcode_base;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
@@ -890,21 +889,15 @@ linux_copyout_strings(struct image_param
 * Also deal with signal trampoline code for this exec type.
 */
arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
-   destp = (caddr_t)arginfo - linux_szsigcode - SPARE_USRSPACE -
-   linux_szplatform - roundup((ARG_MAX - imgp->args->stringspace),
+   destp = (caddr_t)arginfo - SPARE_USRSPACE - linux_szplatform -
+   roundup((ARG_MAX - imgp->args->stringspace),
sizeof(char *));
 
/*
-* install sigcode
-*/
-   copyout(imgp->proc->p_sysent->sv_sigcode,
-   ((caddr_t)arginfo - linux_szsigcode), linux_szsigcode);
-
-   /*
 * Install LINUX_PLATFORM
 */
-   copyout(linux_platform, ((caddr_t)arginfo - linux_szsigcode -
-   linux_szplatform), linux_szplatform);
+   copyout(linux_platform, ((caddr_t)arginfo - linux_szplatform),
+   linux_szplatform);
 
/*
 * If we have a valid auxargs ptr, prepare some room
@@ -1050,7 +1043,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
.sv_pagesize= PAGE_SIZE,
.sv_minuser = VM_MIN_ADDRESS,
-   .sv_maxuser = LINUX32_USRSTACK,
+   .sv_maxuser = LINUX32_MAXUSER,
.sv_usrstack= LINUX32_USRSTACK,
.sv_psstrings   = LINUX32_PS_STRINGS,
.sv_stackprot   = VM_PROT_ALL,
@@ -1058,12 +1051,15 @@ struct sysentvec elf_linux_sysvec = {
.sv_setregs = exec_linux_setregs,
.sv_fixlimit= linux32_fixlimit,
.sv_maxssiz = &linux32_maxssiz,
-   .sv_flags   = SV_ABI_LINUX | SV_ILP32 | SV_IA32,
+   .sv_flags   = SV_ABI_LINUX | SV_ILP32 | SV_IA32 | SV_SHP,
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = linux32_fetch_syscall_args,
.sv_syscallnames = NULL,
+   .sv_shared_page_base = LINUX32_SHAREDPAGE,
+   .sv_shared_page_len = PAGE_SIZE,
.sv_schedtail   = linux_schedtail,
 };
+INIT_SYSENTVEC(elf_sysvec, &elf_linux_sysvec);
 
 static char GNU_ABI_VENDOR[] = "GNU";
 static int GNULINUX_ABI_DESC = 0;

Modified: head/sys/i386/linux/linux.h
==
--- head/sys/i386/linux/linux.h Sun Mar 13 13:42:43 2011(r219608)
+++ head/sys/i386/linux/linux.h Sun Mar 13 14:58:02 2011(r219609)
@@ -47,6 +47,9 @@ extern u_char linux_debug_map[];
 MALLOC_DECLARE(M_LINUX);
 #endif
 
+#defineLINUX_SHAREDPAGE(VM

svn commit: r219638 - head/usr.bin/calendar/calendars

2011-03-14 Thread Dmitry Chagin
Author: dchagin
Date: Mon Mar 14 13:02:12 2011
New Revision: 219638
URL: http://svn.freebsd.org/changeset/base/219638

Log:
  Add my birthday to the freebsd calendar.

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdMon Mar 14 11:20:26 
2011(r219637)
+++ head/usr.bin/calendar/calendars/calendar.freebsdMon Mar 14 13:02:12 
2011(r219638)
@@ -46,6 +46,7 @@
 02/02  Diomidis D. Spinellis  born in Athens, Greece, 1967
 02/02  Michael W Lucas  born in Detroit, Michigan, United 
States, 1967
 02/02  Yoichi Nakayama  born in Tsu, Mie, Japan, 1976
+02/02  Dmitry Chagin  born in Stalingrad, USSR, 1976
 02/05  Frank Laszlo  born in Howell, Michigan, United 
States, 1983
 02/10  David Greenman  born in Portland, Oregon, United 
States, 1968
 02/10  Paul Richards  born in Ammanford, Carmarthenshire, 
United Kingdom, 1968
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219776 - head/sys/net

2011-03-19 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar 19 16:52:06 2011
New Revision: 219776
URL: http://svn.freebsd.org/changeset/base/219776

Log:
  Remove a now unused variable.
  
  MFC after:1 Week

Modified:
  head/sys/net/route.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cSat Mar 19 15:50:34 2011(r219775)
+++ head/sys/net/route.cSat Mar 19 16:52:06 2011(r219776)
@@ -338,7 +338,6 @@ rtalloc1_fib(struct sockaddr *dst, int r
u_int fibnum)
 {
struct radix_node_head *rnh;
-   struct rtentry *rt;
struct radix_node *rn;
struct rtentry *newrt;
struct rt_addrinfo info;
@@ -366,7 +365,7 @@ rtalloc1_fib(struct sockaddr *dst, int r
 #endif
rn = rnh->rnh_matchaddr(dst, rnh);
if (rn && ((rn->rn_flags & RNF_ROOT) == 0)) {
-   newrt = rt = RNTORT(rn);
+   newrt = RNTORT(rn);
RT_LOCK(newrt);
RT_ADDREF(newrt);
if (needlock)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219783 - head/sys/net

2011-03-19 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar 19 19:50:36 2011
New Revision: 219783
URL: http://svn.freebsd.org/changeset/base/219783

Log:
  A bit rearranged rtalloc1_fib() code.
  Initialize a variable when it is really needed.
  To avoid code duplication move the miss label to line up and jump on it.
  
  MFC after:1 Week

Modified:
  head/sys/net/route.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cSat Mar 19 19:39:05 2011(r219782)
+++ head/sys/net/route.cSat Mar 19 19:50:36 2011(r219783)
@@ -348,14 +348,13 @@ rtalloc1_fib(struct sockaddr *dst, int r
if (dst->sa_family != AF_INET)  /* Only INET supports > 1 fib now */
fibnum = 0;
rnh = rt_tables_get_rnh(fibnum, dst->sa_family);
-   newrt = NULL;
+   if (rnh == NULL)
+   goto miss;
+
/*
 * Look up the address in the table for that Address Family
 */
-   if (rnh == NULL) {
-   V_rtstat.rts_unreach++;
-   goto miss;
-   }
+   newrt = NULL;
needlock = !(ignflags & RTF_RNH_LOCKED);
if (needlock)
RADIX_NODE_HEAD_RLOCK(rnh);
@@ -380,8 +379,9 @@ rtalloc1_fib(struct sockaddr *dst, int r
 * Which basically means
 * "caint get there frm here"
 */
-   V_rtstat.rts_unreach++;
 miss:
+   V_rtstat.rts_unreach++;
+
if (report) {
/*
 * If required, report the failure to the supervising
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219786 - head/sys/net

2011-03-19 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar 19 21:10:57 2011
New Revision: 219786
URL: http://svn.freebsd.org/changeset/base/219786

Log:
  ouch, newrt is used on the return path, my fault.
  Partialy revert the previous change.
  
  MFC after:1 Week.

Modified:
  head/sys/net/route.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cSat Mar 19 20:36:05 2011(r219785)
+++ head/sys/net/route.cSat Mar 19 21:10:57 2011(r219786)
@@ -348,13 +348,13 @@ rtalloc1_fib(struct sockaddr *dst, int r
if (dst->sa_family != AF_INET)  /* Only INET supports > 1 fib now */
fibnum = 0;
rnh = rt_tables_get_rnh(fibnum, dst->sa_family);
+   newrt = NULL;
if (rnh == NULL)
goto miss;
 
/*
 * Look up the address in the table for that Address Family
 */
-   newrt = NULL;
needlock = !(ignflags & RTF_RNH_LOCKED);
if (needlock)
RADIX_NODE_HEAD_RLOCK(rnh);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r219791 - head/sys/net

2011-03-20 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 20 08:35:00 2011
New Revision: 219791
URL: http://svn.freebsd.org/changeset/base/219791

Log:
  Remove dead code.
  
  MFC after:1 Week

Modified:
  head/sys/net/route.h

Modified: head/sys/net/route.h
==
--- head/sys/net/route.hSun Mar 20 08:27:06 2011(r219790)
+++ head/sys/net/route.hSun Mar 20 08:35:00 2011(r219791)
@@ -325,7 +325,6 @@ struct rt_addrinfo {
 #defineRT_LOCK_INIT(_rt) \
mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK)
 #defineRT_LOCK(_rt)mtx_lock(&(_rt)->rt_mtx)
-#defineRT_TRYLOCK(_rt) mtx_trylock(&(_rt)->rt_mtx)
 #defineRT_UNLOCK(_rt)  mtx_unlock(&(_rt)->rt_mtx)
 #defineRT_LOCK_DESTROY(_rt)mtx_destroy(&(_rt)->rt_mtx)
 #defineRT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
@@ -360,22 +359,6 @@ struct rt_addrinfo {
RTFREE_LOCKED(_rt); \
 } while (0)
 
-#define RT_TEMP_UNLOCK(_rt) do {   \
-   RT_ADDREF(_rt); \
-   RT_UNLOCK(_rt); \
-} while (0)
-
-#define RT_RELOCK(_rt) do {\
-   RT_LOCK(_rt);   \
-   if ((_rt)->rt_refcnt <= 1) {\
-   rtfree(_rt);\
-   _rt = 0; /*  signal that it went away */\
-   } else {\
-   RT_REMREF(_rt); \
-   /* note that _rt is still valid */  \
-   }   \
-} while (0)
-
 struct radix_node_head *rt_tables_get_rnh(int, int);
 
 struct ifmultiaddr;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r220026 - in head/sys: amd64/linux32 i386/linux

2011-03-26 Thread Dmitry Chagin
Author: dchagin
Date: Sat Mar 26 09:25:35 2011
New Revision: 220026
URL: http://svn.freebsd.org/changeset/base/220026

Log:
  Export the correct AT_PLATFORM value.
  Since signal trampolines are copied to the shared page do not need to
  leave place on the stack for it. Forgotten in the previous commit.
  
  MFC after:1 Week

Modified:
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Sat Mar 26 07:29:48 2011
(r220025)
+++ head/sys/amd64/linux32/linux32_sysvec.c Sat Mar 26 09:25:35 2011
(r220026)
@@ -249,8 +249,7 @@ elf_linux_fixup(register_t **stack_base,
struct linux32_ps_strings *arginfo;
 
arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
-   uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szsigcode -
-   linux_szplatform);
+   uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
 
KASSERT(curthread->td_proc == imgp->proc,
("unsafe elf_linux_fixup(), should be curproc"));

Modified: head/sys/i386/linux/linux_sysvec.c
==
--- head/sys/i386/linux/linux_sysvec.c  Sat Mar 26 07:29:48 2011
(r220025)
+++ head/sys/i386/linux/linux_sysvec.c  Sat Mar 26 09:25:35 2011
(r220026)
@@ -249,8 +249,7 @@ elf_linux_fixup(register_t **stack_base,
 
p = imgp->proc;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
-   uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szsigcode -
-   linux_szplatform);
+   uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
args = (Elf32_Auxargs *)imgp->auxargs;
pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r220730 - head/sys/kern

2011-04-16 Thread Dmitry Chagin
Author: dchagin
Date: Sat Apr 16 16:20:51 2011
New Revision: 220730
URL: http://svn.freebsd.org/changeset/base/220730

Log:
  Remove malloc(9) return value checks when M_WAITOK is used.
  
  MFC after:2 Week

Modified:
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c

Modified: head/sys/kern/link_elf.c
==
--- head/sys/kern/link_elf.cSat Apr 16 14:56:13 2011(r220729)
+++ head/sys/kern/link_elf.cSat Apr 16 16:20:51 2011(r220730)
@@ -692,10 +692,6 @@ link_elf_load_file(linker_class_t cls, c
 * Read the elf header from the file.
 */
firstpage = malloc(PAGE_SIZE, M_LINKER, M_WAITOK);
-   if (firstpage == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
hdr = (Elf_Ehdr *)firstpage;
error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -829,10 +825,6 @@ link_elf_load_file(linker_class_t cls, c
}
 #else
ef->address = malloc(mapsize, M_LINKER, M_WAITOK);
-   if (ef->address == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
 #endif
mapbase = ef->address;
 
@@ -918,10 +910,6 @@ link_elf_load_file(linker_class_t cls, c
if (nbytes == 0 || hdr->e_shoff == 0)
goto nosyms;
shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO);
-   if (shdr == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
error = vn_rdwr(UIO_READ, nd.ni_vp,
(caddr_t)shdr, nbytes, hdr->e_shoff,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -944,10 +932,6 @@ link_elf_load_file(linker_class_t cls, c
strcnt = shdr[symstrindex].sh_size;
ef->strbase = malloc(strcnt, M_LINKER, M_WAITOK);
 
-   if (ef->symbase == NULL || ef->strbase == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
error = vn_rdwr(UIO_READ, nd.ni_vp,
ef->symbase, symcnt, shdr[symtabindex].sh_offset,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -1318,8 +1302,6 @@ link_elf_lookup_set(linker_file_t lf, co
 
len = strlen(name) + sizeof("__start_set_"); /* sizeof includes \0 */
setsym = malloc(len, M_LINKER, M_WAITOK);
-   if (setsym == NULL)
-   return (ENOMEM);
 
/* get address of first entry */
snprintf(setsym, len, "%s%s", "__start_set_", name);

Modified: head/sys/kern/link_elf_obj.c
==
--- head/sys/kern/link_elf_obj.cSat Apr 16 14:56:13 2011
(r220729)
+++ head/sys/kern/link_elf_obj.cSat Apr 16 16:20:51 2011
(r220730)
@@ -476,10 +476,6 @@ link_elf_load_file(linker_class_t cls, c
 
/* Read the elf header from the file. */
hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK);
-   if (hdr == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)hdr, sizeof(*hdr), 0,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
&resid, td);
@@ -536,10 +532,6 @@ link_elf_load_file(linker_class_t cls, c
goto out;
}
shdr = malloc(nbytes, M_LINKER, M_WAITOK);
-   if (shdr == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
ef->e_shdr = shdr;
error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td);
@@ -605,22 +597,12 @@ link_elf_load_file(linker_class_t cls, c
if (ef->nrelatab != 0)
ef->relatab = malloc(ef->nrelatab * sizeof(*ef->relatab),
M_LINKER, M_WAITOK | M_ZERO);
-   if ((ef->nprogtab != 0 && ef->progtab == NULL) ||
-   (ef->nreltab != 0 && ef->reltab == NULL) ||
-   (ef->nrelatab != 0 && ef->relatab == NULL)) {
-   error = ENOMEM;
-   goto out;
-   }
 
if (symtabindex == -1)
panic("lost symbol table index");
/* Allocate space for and load the symbol table */
ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK);
-   if (ef->ddbsymtab == NULL) {
-   error = ENOMEM;
-   goto out;
-   }
error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)ef->ddbsymtab,
shdr[symtabindex].sh_size, shdr[symtabindex].sh_offset,
UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -637,10 +619,6 @@ link_elf_load_file(linker_class_t cls, c
/* Allocate space for and load the symbol strings */
ef->ddbstrcnt = shdr[symstrindex].sh_size;
ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
-   if (

svn commit: r221784 - head/sys/amd64/amd64

2011-05-11 Thread Dmitry Chagin
Author: dchagin
Date: Wed May 11 17:57:15 2011
New Revision: 221784
URL: http://svn.freebsd.org/changeset/base/221784

Log:
  Remove wrong comment.
  
  MFC after:1 week.

Modified:
  head/sys/amd64/amd64/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Wed May 11 17:50:19 2011
(r221783)
+++ head/sys/amd64/amd64/machdep.c  Wed May 11 17:57:15 2011
(r221784)
@@ -1298,9 +1298,6 @@ add_smap_entry(struct bios_smap *smap, v
  * available physical memory in the system, then test this memory and
  * build the phys_avail array describing the actually-available memory.
  *
- * If we cannot accurately determine the physical memory map, then use
- * value from the 0xE801 call, and failing that, the RTC.
- *
  * Total memory size may be set by the kernel environment variable
  * hw.physmem or the compile-time define MAXMEM.
  *
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r222768 - head/usr.bin/kdump

2011-06-06 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jun  6 19:00:38 2011
New Revision: 222768
URL: http://svn.freebsd.org/changeset/base/222768

Log:
  Fix regex for ptraceopname().
  
  PR:   bin/157663
  Submitted by: jason wright 
  MFC after:10 days

Modified:
  head/usr.bin/kdump/mksubr

Modified: head/usr.bin/kdump/mksubr
==
--- head/usr.bin/kdump/mksubr   Mon Jun  6 18:40:01 2011(r222767)
+++ head/usr.bin/kdump/mksubr   Mon Jun  6 19:00:38 2011(r222768)
@@ -345,7 +345,7 @@ auto_if_type "sockfamilyname" "AF_[[:aln
 auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" 
"netinet/in.h"
 auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
 auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" 
"sys/socket.h"
-auto_switch_type "ptraceopname" "PT_[[:alnum:]]+[[:space:]]+[0-9]+" 
"sys/ptrace.h"
+auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" 
"sys/ptrace.h"
 
 cat <<_EOF_
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r217725 - head/sys/conf

2011-01-22 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jan 22 20:53:27 2011
New Revision: 217725
URL: http://svn.freebsd.org/changeset/base/217725

Log:
  Option USB_HOST_ALIGN declared twice.
  
  Approved by:  kib(mentor)

Modified:
  head/sys/conf/options

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Sat Jan 22 20:01:46 2011(r217724)
+++ head/sys/conf/options   Sat Jan 22 20:53:27 2011(r217725)
@@ -642,7 +642,6 @@ BUS_DEBUG   opt_bus.h
 
 # options for USB support
 USB_DEBUG  opt_usb.h
-USB_HOST_ALIGN opt_usb.h
 USB_REQ_DEBUG  opt_usb.h
 USB_VERBOSEopt_usb.h
 USB_EHCI_BIG_ENDIAN_DESC   opt_usb.h
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r217743 - head/sys/compat/linux

2011-01-23 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jan 23 09:50:39 2011
New Revision: 217743
URL: http://svn.freebsd.org/changeset/base/217743

Log:
  Style(9) fix.
  
  Approved by:  kib(mentor)
  MFC after:1 month

Modified:
  head/sys/compat/linux/linux_signal.c

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cSun Jan 23 07:27:35 2011
(r217742)
+++ head/sys/compat/linux/linux_signal.cSun Jan 23 09:50:39 2011
(r217743)
@@ -526,7 +526,7 @@ linux_kill(struct thread *td, struct lin
 * Allow signal 0 as a means to check for privileges
 */
if (!LINUX_SIG_VALID(args->signum) && args->signum != 0)
-   return EINVAL;
+   return (EINVAL);
 
if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ)
tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)];
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r217873 - head/usr.bin/ktrdump

2011-01-25 Thread Dmitry Chagin
Author: dchagin
Date: Wed Jan 26 06:36:14 2011
New Revision: 217873
URL: http://svn.freebsd.org/changeset/base/217873

Log:
  Add -H flag to print thread id.

Modified:
  head/usr.bin/ktrdump/ktrdump.8
  head/usr.bin/ktrdump/ktrdump.c

Modified: head/usr.bin/ktrdump/ktrdump.8
==
--- head/usr.bin/ktrdump/ktrdump.8  Wed Jan 26 06:07:24 2011
(r217872)
+++ head/usr.bin/ktrdump/ktrdump.8  Wed Jan 26 06:36:14 2011
(r217873)
@@ -33,7 +33,7 @@
 .Nd print kernel ktr trace buffer
 .Sh SYNOPSIS
 .Nm
-.Op Fl cfqrt
+.Op Fl cfqrtH
 .Op Fl e Ar execfile
 .Op Fl i Ar ktrfile
 .Op Fl m Ar corefile
@@ -55,6 +55,8 @@ Quiet mode; do not print the column head
 Print relative timestamps rather than absolute timestamps.
 .It Fl t
 Print the timestamp for each entry.
+.It Fl H
+Print the thread ID for each entry.
 .It Fl i Ar ktrfile
 File containing saved ktr trace events; for more information see the
 .Xr ktr 4

Modified: head/usr.bin/ktrdump/ktrdump.c
==
--- head/usr.bin/ktrdump/ktrdump.c  Wed Jan 26 06:07:24 2011
(r217872)
+++ head/usr.bin/ktrdump/ktrdump.c  Wed Jan 26 06:36:14 2011
(r217873)
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #defineSBUFLEN 128
 #defineUSAGE \
-   "usage: ktrdump [-cfqrt] [-e execfile] [-i ktrfile] [-m corefile] [-o 
outfile]\n"
+   "usage: ktrdump [-cfqrtH] [-e execfile] [-i ktrfile] [-m corefile] [-o 
outfile]\n"
 
 static void usage(void);
 
@@ -66,6 +66,7 @@ static int qflag;
 static int rflag;
 static int tflag;
 static int iflag;
+static int hflag;
 
 static char corefile[PATH_MAX];
 static char execfile[PATH_MAX];
@@ -101,7 +102,7 @@ main(int ac, char **av)
 * Parse commandline arguments.
 */
out = stdout;
-   while ((c = getopt(ac, av, "cfqrte:i:m:o:")) != -1)
+   while ((c = getopt(ac, av, "cfqrtHe:i:m:o:")) != -1)
switch (c) {
case 'c':
cflag = 1;
@@ -139,6 +140,9 @@ main(int ac, char **av)
case 't':
tflag = 1;
break;
+   case 'H':
+   hflag = 1;
+   break;
case '?':
default:
usage();
@@ -191,6 +195,8 @@ main(int ac, char **av)
fprintf(out, "%-16s ", "timestamp");
if (fflag)
fprintf(out, "%-40s ", "file and line");
+   if (hflag)
+   fprintf(out, "%-18s ", "tid");
fprintf(out, "%s", "trace");
fprintf(out, "\n");
 
@@ -202,6 +208,8 @@ main(int ac, char **av)
if (fflag)
fprintf(out,
" ");
+   if (hflag)
+   fprintf(out, "-- ");
fprintf(out, "- ");
fprintf(out, "\n");
}
@@ -270,6 +278,8 @@ next:   if ((c = *p++) == '\0')
buf[i].ktr_line);
fprintf(out, "%-40s ", obuf);
}
+   if (hflag)
+   fprintf(out, "%p ", buf[i].ktr_thread);
fprintf(out, desc, parms[0], parms[1], parms[2], parms[3],
parms[4], parms[5]);
fprintf(out, "\n");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r217896 - in head/sys: amd64/amd64 amd64/linux32 compat/linprocfs fs/procfs i386/linux kern powerpc/aim powerpc/powerpc sys

2011-01-26 Thread Dmitry Chagin
Author: dchagin
Date: Wed Jan 26 20:03:58 2011
New Revision: 217896
URL: http://svn.freebsd.org/changeset/base/217896

Log:
  Add macro to test the sv_flags of any process. Change some places to test
  the flags instead of explicit comparing with address of known sysentvec
  structures.
  
  MFC after:1 month

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/fs/procfs/procfs_dbregs.c
  head/sys/fs/procfs/procfs_fpregs.c
  head/sys/fs/procfs/procfs_map.c
  head/sys/fs/procfs/procfs_regs.c
  head/sys/i386/linux/linux_machdep.c
  head/sys/kern/kern_jail.c
  head/sys/kern/sys_process.c
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/vm_machdep.c
==
--- head/sys/amd64/amd64/vm_machdep.c   Wed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/amd64/amd64/vm_machdep.c   Wed Jan 26 20:03:58 2011
(r217896)
@@ -445,7 +445,7 @@ cpu_set_upcall_kse(struct thread *td, vo
cpu_thread_clean(td);
 
 #ifdef COMPAT_FREEBSD32
-   if (td->td_proc->p_sysent->sv_flags & SV_ILP32) {
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
/*
 * Set the trap frame to point at the beginning of the uts
 * function.
@@ -498,7 +498,7 @@ cpu_set_user_tls(struct thread *td, void
 
pcb = td->td_pcb;
 #ifdef COMPAT_FREEBSD32
-   if (td->td_proc->p_sysent->sv_flags & SV_ILP32) {
+   if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
pcb->pcb_gsbase = (register_t)tls_base;
return (0);
}

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cWed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/amd64/linux32/linux32_machdep.cWed Jan 26 20:03:58 2011
(r217896)
@@ -131,7 +131,7 @@ linux_execve(struct thread *td, struct l
 * linux_proc_init, this leads to a panic on KASSERT
 * because such process has p->p_emuldata == NULL.
 */
-   if (td->td_proc->p_sysent == &elf_linux_sysvec)
+   if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
error = linux_proc_init(td, 0, 0);
return (error);
 }

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Wed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/compat/linprocfs/linprocfs.c   Wed Jan 26 20:03:58 2011
(r217896)
@@ -928,7 +928,7 @@ do {
\
 
 #ifdef COMPAT_FREEBSD32
env_vector32 = NULL;
-   if ((p->p_sysent->sv_flags & SV_ILP32) != 0) {
+   if (SV_PROC_FLAG(p, SV_ILP32) != 0) {
env_vector32 = malloc(sizeof(*env_vector32) * MAX_ARGV_STR,
M_TEMP, M_WAITOK);
elm_len = sizeof(int32_t);

Modified: head/sys/fs/procfs/procfs_dbregs.c
==
--- head/sys/fs/procfs/procfs_dbregs.c  Wed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/fs/procfs/procfs_dbregs.c  Wed Jan 26 20:03:58 2011
(r217896)
@@ -107,7 +107,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS)
td2 = FIRST_THREAD_IN_PROC(p);
 #ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32)) {
-   if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) {
+   if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) {
PROC_UNLOCK(p);
return (EINVAL);
}

Modified: head/sys/fs/procfs/procfs_fpregs.c
==
--- head/sys/fs/procfs/procfs_fpregs.c  Wed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/fs/procfs/procfs_fpregs.c  Wed Jan 26 20:03:58 2011
(r217896)
@@ -106,7 +106,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS)
td2 = FIRST_THREAD_IN_PROC(p);
 #ifdef COMPAT_FREEBSD32
if (SV_CURPROC_FLAG(SV_ILP32)) {
-   if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) {
+   if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) {
PROC_UNLOCK(p);
return (EINVAL);
}

Modified: head/sys/fs/procfs/procfs_map.c
==
--- head/sys/fs/procfs/procfs_map.c Wed Jan 26 19:55:54 2011
(r217895)
+++ head/sys/fs/procfs/procfs_map.c Wed Jan 26 20:03:58 2011
(r217896)
@@ -100,8 +100,8 @@ procfs_doprocmap(PFS_FILL_ARGS)
return (EOPNOTSUPP);
 
 #ifdef COMPAT_FREEBSD32
-if (c

svn commit: r218005 - head/sys/compat/linux

2011-01-27 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 05:42:14 2011
New Revision: 218005
URL: http://svn.freebsd.org/changeset/base/218005

Log:
  Style(9) fix.
  
  MFC after:1 month.

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Jan 28 02:12:43 2011
(r218004)
+++ head/sys/compat/linux/linux_misc.c  Fri Jan 28 05:42:14 2011
(r218005)
@@ -886,7 +886,7 @@ linux_waitpid(struct thread *td, struct 
return copyout(&tmpstat, args->status, sizeof(int));
}
 
-   return 0;
+   return (0);
 }
 
 int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218028 - head/sys/amd64/linux32

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 18:28:06 2011
New Revision: 218028
URL: http://svn.freebsd.org/changeset/base/218028

Log:
  To avoid excessive code duplication move struct rusage translation
  to a separate function.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:25:51 2011
(r218027)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:28:06 2011
(r218028)
@@ -106,6 +106,28 @@ bsd_to_linux_sigaltstack(int bsa)
return (lsa);
 }
 
+static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
+{
+   lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
+   lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
+   lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
+   lru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
+   lru->ru_maxrss = ru->ru_maxrss;
+   lru->ru_ixrss = ru->ru_ixrss;
+   lru->ru_idrss = ru->ru_idrss;
+   lru->ru_isrss = ru->ru_isrss;
+   lru->ru_minflt = ru->ru_minflt;
+   lru->ru_majflt = ru->ru_majflt;
+   lru->ru_nswap = ru->ru_nswap;
+   lru->ru_inblock = ru->ru_inblock;
+   lru->ru_oublock = ru->ru_oublock;
+   lru->ru_msgsnd = ru->ru_msgsnd;
+   lru->ru_msgrcv = ru->ru_msgrcv;
+   lru->ru_nsignals = ru->ru_nsignals;
+   lru->ru_nvcsw = ru->ru_nvcsw;
+   lru->ru_nivcsw = ru->ru_nivcsw;
+}
+
 int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
@@ -1126,24 +1148,7 @@ linux_getrusage(struct thread *td, struc
if (error != 0)
return (error);
if (uap->rusage != NULL) {
-   s32.ru_utime.tv_sec = s.ru_utime.tv_sec;
-   s32.ru_utime.tv_usec = s.ru_utime.tv_usec;
-   s32.ru_stime.tv_sec = s.ru_stime.tv_sec;
-   s32.ru_stime.tv_usec = s.ru_stime.tv_usec;
-   s32.ru_maxrss = s.ru_maxrss;
-   s32.ru_ixrss = s.ru_ixrss;
-   s32.ru_idrss = s.ru_idrss;
-   s32.ru_isrss = s.ru_isrss;
-   s32.ru_minflt = s.ru_minflt;
-   s32.ru_majflt = s.ru_majflt;
-   s32.ru_nswap = s.ru_nswap;
-   s32.ru_inblock = s.ru_inblock;
-   s32.ru_oublock = s.ru_oublock;
-   s32.ru_msgsnd = s.ru_msgsnd;
-   s32.ru_msgrcv = s.ru_msgrcv;
-   s32.ru_nsignals = s.ru_nsignals;
-   s32.ru_nvcsw = s.ru_nvcsw;
-   s32.ru_nivcsw = s.ru_nivcsw;
+   bsd_to_linux_rusage(&s, &s32);
error = copyout(&s32, uap->rusage, sizeof(s32));
}
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218030 - in head/sys: amd64/linux32 compat/linux i386/linux

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 18:47:07 2011
New Revision: 218030
URL: http://svn.freebsd.org/changeset/base/218030

Log:
  Implement a variation of the linux_common_wait() which should
  be used by linuxolator itself.
  
  Move linux_wait4() to MD path as it requires native struct
  rusage translation to struct l_rusage on linux32/amd64.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_misc.h
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:42:17 2011
(r218029)
+++ head/sys/amd64/linux32/linux32_machdep.cFri Jan 28 18:47:07 2011
(r218030)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -66,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1272,3 +1274,44 @@ linux_set_thread_area(struct thread *td,
 
return (0);
 }
+
+int
+linux_wait4(struct thread *td, struct linux_wait4_args *args)
+{
+   int error, options;
+   struct rusage ru, *rup;
+   struct l_rusage lru;
+   struct proc *p;
+
+#ifdef DEBUG
+   if (ldebug(wait4))
+   printf(ARGS(wait4, "%d, %p, %d, %p"),
+   args->pid, (void *)args->status, args->options,
+   (void *)args->rusage);
+#endif
+
+   options = (args->options & (WNOHANG | WUNTRACED));
+   /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
+   if (args->options & __WCLONE)
+   options |= WLINUXCLONE;
+
+   if (args->rusage != NULL)
+   rup = &ru;
+   else
+   rup = NULL;
+   error = linux_common_wait(td, args->pid, args->status, options, rup);
+   if (error)
+   return (error);
+
+   p = td->td_proc;
+   PROC_LOCK(p);
+   sigqueue_delete(&p->p_sigqueue, SIGCHLD);
+   PROC_UNLOCK(p);
+
+   if (args->rusage != NULL) {
+   bsd_to_linux_rusage(rup, &lru);
+   error = copyout(&lru, args->rusage, sizeof(lru));
+   }
+
+   return (error);
+}

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:42:17 2011
(r218029)
+++ head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:47:07 2011
(r218030)
@@ -847,35 +847,17 @@ linux_futimesat(struct thread *td, struc
 }
 #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
 
-#define __WCLONE 0x8000
-
 int
-linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
+linux_common_wait(struct thread *td, int pid, int *status,
+int options, struct rusage *ru)
 {
-   int error, options, tmpstat;
-
-#ifdef DEBUG
-   if (ldebug(waitpid))
-   printf(ARGS(waitpid, "%d, %p, %d"),
-   args->pid, (void *)args->status, args->options);
-#endif
-   /*
-* this is necessary because the test in kern_wait doesn't work
-* because we mess with the options here
-*/
-   if (args->options & ~(WUNTRACED | WNOHANG | WCONTINUED | __WCLONE))
-   return (EINVAL);
+   int error, tmpstat;
 
-   options = (args->options & (WNOHANG | WUNTRACED));
-   /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
-   if (args->options & __WCLONE)
-   options |= WLINUXCLONE;
-
-   error = kern_wait(td, args->pid, &tmpstat, options, NULL);
+   error = kern_wait(td, pid, &tmpstat, options, ru);
if (error)
-   return error;
+   return (error);
 
-   if (args->status) {
+   if (status) {
tmpstat &= 0x;
if (WIFSIGNALED(tmpstat))
tmpstat = (tmpstat & 0xff80) |
@@ -883,60 +865,38 @@ linux_waitpid(struct thread *td, struct 
else if (WIFSTOPPED(tmpstat))
tmpstat = (tmpstat & 0x00ff) |
(BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
-   return copyout(&tmpstat, args->status, sizeof(int));
+   error = copyout(&tmpstat, status, sizeof(int));
}
 
-   return (0);
+   return (error);
 }
 
 int
-linux_wait4(struct thread *td, struct linux_wait4_args *args)
+linux_waitpid(struct thread *td, struct linux_waitpid_args *args)
 {
-   int error, options, tmpstat;
-   struct rusage ru, *rup;
-   struct proc *p;
-
+   int options;
+ 
 #ifdef DEBUG
-   if (ldebug(wait4))
-   printf(ARGS(wait4, "%d, %p, %d, %p"),
-   args->pid, (void *)args->status, args->options,
-   (void *)args->rusage);
+   if (ldebug(waitpid))
+   printf(ARG

svn commit: r218031 - head/sys/compat/linux

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Fri Jan 28 19:04:15 2011
New Revision: 218031
URL: http://svn.freebsd.org/changeset/base/218031

Log:
  Style(9) fixes.
  
  MFC after:1 Month.

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Fri Jan 28 18:47:07 2011
(r218030)
+++ head/sys/compat/linux/linux_misc.c  Fri Jan 28 19:04:15 2011
(r218031)
@@ -160,7 +160,7 @@ linux_sysinfo(struct thread *td, struct 
sysinfo.freebig = 0;
sysinfo.mem_unit = 1;
 
-   return copyout(&sysinfo, args->info, sizeof(sysinfo));
+   return (copyout(&sysinfo, args->info, sizeof(sysinfo)));
 }
 
 int
@@ -216,7 +216,7 @@ linux_brk(struct thread *td, struct linu
else
td->td_retval[0] = (long)old;
 
-   return 0;
+   return (0);
 }
 
 #if defined(__i386__)
@@ -468,7 +468,7 @@ cleanup:
vm_map_remove(kernel_map, (vm_offset_t)a_out,
(vm_offset_t)a_out + PAGE_SIZE);
 
-   return error;
+   return (error);
 }
 
 #endif /* __i386__ */
@@ -562,7 +562,7 @@ select_out:
if (ldebug(select))
printf(LMSG("select_out -> %d"), error);
 #endif
-   return error;
+   return (error);
 }
 
 int
@@ -602,7 +602,7 @@ linux_mremap(struct thread *td, struct l
 
if (args->new_len > args->old_len) {
td->td_retval[0] = 0;
-   return ENOMEM;
+   return (ENOMEM);
}
 
if (args->new_len < args->old_len) {
@@ -613,7 +613,7 @@ linux_mremap(struct thread *td, struct l
}
 
td->td_retval[0] = error ? 0 : (uintptr_t)args->addr;
-   return error;
+   return (error);
 }
 
 #define LINUX_MS_ASYNC   0x0001
@@ -629,7 +629,7 @@ linux_msync(struct thread *td, struct li
bsd_args.len = (uintptr_t)args->len;
bsd_args.flags = args->fl & ~LINUX_MS_SYNC;
 
-   return msync(td, &bsd_args);
+   return (msync(td, &bsd_args));
 }
 
 int
@@ -647,9 +647,9 @@ linux_time(struct thread *td, struct lin
microtime(&tv);
tm = tv.tv_sec;
if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm
-   return error;
+   return (error);
td->td_retval[0] = tm;
-   return 0;
+   return (0);
 }
 
 struct l_times_argv {
@@ -702,12 +702,12 @@ linux_times(struct thread *td, struct li
tms.tms_cstime = CONVTCK(cstime);
 
if ((error = copyout(&tms, args->buf, sizeof(tms
-   return error;
+   return (error);
}
 
microuptime(&tv);
td->td_retval[0] = (int)CONVTCK(tv);
-   return 0;
+   return (0);
 }
 
 int
@@ -766,7 +766,7 @@ linux_utime(struct thread *td, struct li
if (args->times) {
if ((error = copyin(args->times, &lut, sizeof lut))) {
LFREEPATH(fname);
-   return error;
+   return (error);
}
tv[0].tv_sec = lut.l_actime;
tv[0].tv_usec = 0;
@@ -1003,11 +1003,11 @@ linux_personality(struct thread *td, str
printf(ARGS(personality, "%lu"), (unsigned long)args->per);
 #endif
if (args->per != 0)
-   return EINVAL;
+   return (EINVAL);
 
/* Yes Jim, it's still a Linux... */
td->td_retval[0] = 0;
-   return 0;
+   return (0);
 }
 
 struct l_itimerval {
@@ -1085,7 +1085,7 @@ linux_nice(struct thread *td, struct lin
bsd_args.which = PRIO_PROCESS;
bsd_args.who = 0;   /* current process */
bsd_args.prio = args->inc;
-   return setpriority(td, &bsd_args);
+   return (setpriority(td, &bsd_args));
 }
 
 int
@@ -1312,12 +1312,12 @@ linux_sched_setscheduler(struct thread *
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
 
bsd.pid = args->pid;
bsd.param = (struct sched_param *)args->param;
-   return sched_setscheduler(td, &bsd);
+   return (sched_setscheduler(td, &bsd));
 }
 
 int
@@ -1347,7 +1347,7 @@ linux_sched_getscheduler(struct thread *
break;
}
 
-   return error;
+   return (error);
 }
 
 int
@@ -1372,9 +1372,9 @@ linux_sched_get_priority_max(struct thre
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
-   return sched_get_priority_max(td, &bsd);
+   return (sched_get_priority_max(td, &bsd));
 }
 
 int
@@ -1399,9 +1399,9 @@ linux_sched_get_priority_min(struct thre
bsd.policy = SCHED_RR;
break;
default:
-   return EINVAL;
+   return (EINVAL);
}
-   return 

svn commit: r218059 - head/sys/amd64/linux32

2011-01-28 Thread Dmitry Chagin
Author: dchagin
Date: Sat Jan 29 07:22:33 2011
New Revision: 218059
URL: http://svn.freebsd.org/changeset/base/218059

Log:
  My style(9) bug.
  
  Pointed out by:   kib
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSat Jan 29 05:08:21 2011
(r218058)
+++ head/sys/amd64/linux32/linux32_machdep.cSat Jan 29 07:22:33 2011
(r218059)
@@ -108,8 +108,10 @@ bsd_to_linux_sigaltstack(int bsa)
return (lsa);
 }
 
-static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
+static void
+bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
 {
+
lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218100 - in head/sys: amd64/linux32 i386/linux

2011-01-30 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jan 30 18:17:38 2011
New Revision: 218100
URL: http://svn.freebsd.org/changeset/base/218100

Log:
  The kern_wait() code already removes the SIGCHLD signal for the waited
  process. Removing other SIGCHLD signals is not needed and may cause
  problems.
  
  Pointed out by:   jilles
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSun Jan 30 16:21:25 2011
(r218099)
+++ head/sys/amd64/linux32/linux32_machdep.cSun Jan 30 18:17:38 2011
(r218100)
@@ -1283,7 +1283,6 @@ linux_wait4(struct thread *td, struct li
int error, options;
struct rusage ru, *rup;
struct l_rusage lru;
-   struct proc *p;
 
 #ifdef DEBUG
if (ldebug(wait4))
@@ -1304,12 +1303,6 @@ linux_wait4(struct thread *td, struct li
error = linux_common_wait(td, args->pid, args->status, options, rup);
if (error)
return (error);
-
-   p = td->td_proc;
-   PROC_LOCK(p);
-   sigqueue_delete(&p->p_sigqueue, SIGCHLD);
-   PROC_UNLOCK(p);
-
if (args->rusage != NULL) {
bsd_to_linux_rusage(rup, &lru);
error = copyout(&lru, args->rusage, sizeof(lru));

Modified: head/sys/i386/linux/linux_machdep.c
==
--- head/sys/i386/linux/linux_machdep.c Sun Jan 30 16:21:25 2011
(r218099)
+++ head/sys/i386/linux/linux_machdep.c Sun Jan 30 18:17:38 2011
(r218100)
@@ -1318,7 +1318,6 @@ linux_wait4(struct thread *td, struct li
 {
int error, options;
struct rusage ru, *rup;
-   struct proc *p;
 
 #ifdef DEBUG
if (ldebug(wait4))
@@ -1339,12 +1338,6 @@ linux_wait4(struct thread *td, struct li
error = linux_common_wait(td, args->pid, args->status, options, rup);
if (error)
return (error);
-
-   p = td->td_proc;
-   PROC_LOCK(p);
-   sigqueue_delete(&p->p_sigqueue, SIGCHLD);
-   PROC_UNLOCK(p);
-
if (args->rusage != NULL)
error = copyout(&ru, args->rusage, sizeof(ru));
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218101 - in head/sys: amd64/linux32 i386/linux

2011-01-30 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jan 30 20:31:43 2011
New Revision: 218101
URL: http://svn.freebsd.org/changeset/base/218101

Log:
  Change linux futex syscall definition to match actual linux one.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/syscalls.master
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Sun Jan 30 18:17:38 2011
(r218100)
+++ head/sys/amd64/linux32/syscalls.master  Sun Jan 30 20:31:43 2011
(r218101)
@@ -405,8 +405,8 @@
 237AUE_NULLSTD { int linux_fremovexattr(void); }
 238AUE_NULLSTD { int linux_tkill(int tid, int sig); }
 239AUE_SENDFILEUNIMPL  linux_sendfile64
-240AUE_NULLSTD { int linux_sys_futex(void *uaddr, int op, int 
val, \
-   struct l_timespec *timeout, void 
*uaddr2, int val3); }
+240AUE_NULLSTD { int linux_sys_futex(void *uaddr, int op, 
uint32_t val, \
+   struct l_timespec *timeout, uint32_t 
*uaddr2, uint32_t val3); }
 241AUE_NULLSTD { int linux_sched_setaffinity(l_pid_t pid, 
l_uint len, \
l_ulong *user_mask_ptr); }
 242AUE_NULLSTD { int linux_sched_getaffinity(l_pid_t pid, 
l_uint len, \

Modified: head/sys/i386/linux/syscalls.master
==
--- head/sys/i386/linux/syscalls.master Sun Jan 30 18:17:38 2011
(r218100)
+++ head/sys/i386/linux/syscalls.master Sun Jan 30 20:31:43 2011
(r218101)
@@ -407,8 +407,8 @@
 237AUE_NULLSTD { int linux_fremovexattr(void); }
 238AUE_NULLSTD { int linux_tkill(int tid, int sig); }
 239AUE_SENDFILEUNIMPL  linux_sendfile64
-240AUE_NULLSTD { int linux_sys_futex(void *uaddr, int op, int 
val, \
-   struct l_timespec *timeout, void 
*uaddr2, int val3); }
+240AUE_NULLSTD { int linux_sys_futex(void *uaddr, int op, 
uint32_t val, \
+   struct l_timespec *timeout, uint32_t 
*uaddr2, uint32_t val3); }
 241AUE_NULLSTD { int linux_sched_setaffinity(l_pid_t pid, 
l_uint len, \
l_ulong *user_mask_ptr); }
 242AUE_NULLSTD { int linux_sched_getaffinity(l_pid_t pid, 
l_uint len, \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218103 - in head/sys: amd64/linux32 i386/linux

2011-01-30 Thread Dmitry Chagin
Author: dchagin
Date: Sun Jan 30 20:38:26 2011
New Revision: 218103
URL: http://svn.freebsd.org/changeset/base/218103

Log:
  Regen for r218101.
  
  MFC after:1 Month.

Modified:
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/i386/linux/linux_proto.h

Modified: head/sys/amd64/linux32/linux32_proto.h
==
--- head/sys/amd64/linux32/linux32_proto.h  Sun Jan 30 20:37:42 2011
(r218102)
+++ head/sys/amd64/linux32/linux32_proto.h  Sun Jan 30 20:38:26 2011
(r218103)
@@ -734,10 +734,10 @@ struct linux_tkill_args {
 struct linux_sys_futex_args {
char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void 
*)];
char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
-   char val_l_[PADL_(int)]; int val; char val_r_[PADR_(int)];
+   char val_l_[PADL_(uint32_t)]; uint32_t val; char 
val_r_[PADR_(uint32_t)];
char timeout_l_[PADL_(struct l_timespec *)]; struct l_timespec * 
timeout; char timeout_r_[PADR_(struct l_timespec *)];
-   char uaddr2_l_[PADL_(void *)]; void * uaddr2; char uaddr2_r_[PADR_(void 
*)];
-   char val3_l_[PADL_(int)]; int val3; char val3_r_[PADR_(int)];
+   char uaddr2_l_[PADL_(uint32_t *)]; uint32_t * uaddr2; char 
uaddr2_r_[PADR_(uint32_t *)];
+   char val3_l_[PADL_(uint32_t)]; uint32_t val3; char 
val3_r_[PADR_(uint32_t)];
 };
 struct linux_sched_setaffinity_args {
char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];

Modified: head/sys/i386/linux/linux_proto.h
==
--- head/sys/i386/linux/linux_proto.h   Sun Jan 30 20:37:42 2011
(r218102)
+++ head/sys/i386/linux/linux_proto.h   Sun Jan 30 20:38:26 2011
(r218103)
@@ -731,10 +731,10 @@ struct linux_tkill_args {
 struct linux_sys_futex_args {
char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void 
*)];
char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
-   char val_l_[PADL_(int)]; int val; char val_r_[PADR_(int)];
+   char val_l_[PADL_(uint32_t)]; uint32_t val; char 
val_r_[PADR_(uint32_t)];
char timeout_l_[PADL_(struct l_timespec *)]; struct l_timespec * 
timeout; char timeout_r_[PADR_(struct l_timespec *)];
-   char uaddr2_l_[PADL_(void *)]; void * uaddr2; char uaddr2_r_[PADR_(void 
*)];
-   char val3_l_[PADL_(int)]; int val3; char val3_r_[PADR_(int)];
+   char uaddr2_l_[PADL_(uint32_t *)]; uint32_t * uaddr2; char 
uaddr2_r_[PADR_(uint32_t *)];
+   char val3_l_[PADL_(uint32_t)]; uint32_t val3; char 
val3_r_[PADR_(uint32_t)];
 };
 struct linux_sched_setaffinity_args {
char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218117 - head/sys/compat/linux

2011-01-30 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jan 31 05:59:05 2011
New Revision: 218117
URL: http://svn.freebsd.org/changeset/base/218117

Log:
  Implement a futex BITSET op.
  
  Submitted by: arundel
  MFC after:1 month.

Modified:
  head/sys/compat/linux/linux_futex.c
  head/sys/compat/linux/linux_futex.h

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Mon Jan 31 00:29:11 2011
(r218116)
+++ head/sys/compat/linux/linux_futex.c Mon Jan 31 05:59:05 2011
(r218117)
@@ -79,6 +79,7 @@ struct futex {
struct sx   f_lck;
uint32_t*f_uaddr;
uint32_tf_refcount;
+   uint32_tf_bitset;
LIST_ENTRY(futex) f_list;
TAILQ_HEAD(lf_waiting_proc, waiting_proc) f_waiting_proc;
 };
@@ -264,15 +265,25 @@ futex_sleep(struct futex *f, struct wait
 }
 
 static int
-futex_wake(struct futex *f, int n)
+futex_wake(struct futex *f, int n, uint32_t bitset)
 {
struct waiting_proc *wp, *wpt;
int count = 0;
 
+   if (bitset == 0)
+   return (EINVAL);
+
FUTEX_ASSERT_LOCKED(f);
TAILQ_FOREACH_SAFE(wp, &f->f_waiting_proc, wp_list, wpt) {
LINUX_CTR3(sys_futex, "futex_wake uaddr %p wp %p ref %d",
f->f_uaddr, wp, f->f_refcount);
+   /*
+* Unless we find a matching bit in
+* the bitset, continue searching.
+*/
+   if (!(wp->wp_futex->f_bitset & bitset))
+   continue;
+
wp->wp_flags |= FUTEX_WP_REMOVED;
TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list);
wakeup_one(wp);
@@ -325,13 +336,18 @@ futex_requeue(struct futex *f, int n, st
 }
 
 static int
-futex_wait(struct futex *f, struct waiting_proc *wp, struct l_timespec *ts)
+futex_wait(struct futex *f, struct waiting_proc *wp, struct l_timespec *ts,
+uint32_t bitset)
 {
struct l_timespec timeout;
struct timeval tv;
int timeout_hz;
int error;
 
+   if (bitset == 0)
+   return (EINVAL);
+   f->f_bitset = bitset;
+
if (ts != NULL) {
error = copyin(ts, &timeout, sizeof(timeout));
if (error)
@@ -445,13 +461,18 @@ linux_sys_futex(struct thread *td, struc
 
switch (args->op) {
case LINUX_FUTEX_WAIT:
+   args->val3 = FUTEX_BITSET_MATCH_ANY;
+   /* FALLTHROUGH */
+
+   case LINUX_FUTEX_WAIT_BITSET:
 
-   LINUX_CTR2(sys_futex, "WAIT val %d uaddr %p",
-   args->val, args->uaddr);
+   LINUX_CTR3(sys_futex, "WAIT uaddr %p val %d val3 %d",
+   args->uaddr, args->val, args->val3);
 #ifdef DEBUG
if (ldebug(sys_futex))
-   printf(ARGS(sys_futex, "futex_wait val %d uaddr %p"),
-   args->val, args->uaddr);
+   printf(ARGS(sys_futex,
+   "futex_wait uaddr %p val %d val3 %d"),
+   args->uaddr, args->val, args->val3);
 #endif
error = futex_get(args->uaddr, &wp, &f, FUTEX_CREATE_WP);
if (error)
@@ -464,19 +485,24 @@ linux_sys_futex(struct thread *td, struc
return (error);
}
if (val != args->val) {
-   LINUX_CTR3(sys_futex, "WAIT uaddr %p val %d != uval %d",
-   args->uaddr, args->val, val);
+   LINUX_CTR4(sys_futex,
+   "WAIT uaddr %p val %d != uval %d val3 %d",
+   args->uaddr, args->val, val, args->val3);
futex_put(f, wp);
return (EWOULDBLOCK);
}
 
-   error = futex_wait(f, wp, args->timeout);
+   error = futex_wait(f, wp, args->timeout, args->val3);
break;
 
case LINUX_FUTEX_WAKE:
+   args->val3 = FUTEX_BITSET_MATCH_ANY;
+   /* FALLTHROUGH */
+
+   case LINUX_FUTEX_WAKE_BITSET:
 
-   LINUX_CTR2(sys_futex, "WAKE val %d uaddr %p",
-   args->val, args->uaddr);
+   LINUX_CTR3(sys_futex, "WAKE uaddr %p val % d val3 %d",
+   args->uaddr, args->val, args->val3);
 
/*
 * XXX: Linux is able to cope with different addresses
@@ -485,8 +511,8 @@ linux_sys_futex(struct thread *td, struc
 */
 #ifdef DEBUG
if (ldebug(sys_futex))
-   printf(ARGS(sys_futex, "futex_wake val %d uaddr %p"),
-   args->val, args->uaddr);
+   printf(ARGS(sys_futex, "futex_wake uaddr %p val %d val3 
%d"),
+   args->uaddr, args->val, args->val3);
 #endif
error = futex_get(args->uaddr, NUL

svn commit: r218118 - head/sys/compat/linux

2011-01-30 Thread Dmitry Chagin
Author: dchagin
Date: Mon Jan 31 06:06:23 2011
New Revision: 218118
URL: http://svn.freebsd.org/changeset/base/218118

Log:
  Yet another unimplemented futex operation, print out about.
  
  Submitted by: arundel
  MFC after:1 month.

Modified:
  head/sys/compat/linux/linux_futex.c
  head/sys/compat/linux/linux_futex.h

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Mon Jan 31 05:59:05 2011
(r218117)
+++ head/sys/compat/linux/linux_futex.c Mon Jan 31 06:06:23 2011
(r218118)
@@ -693,6 +693,13 @@ linux_sys_futex(struct thread *td, struc
  "op FUTEX_WAIT_REQUEUE_PI not implemented\n");
return (ENOSYS);
 
+   case LINUX_FUTEX_CMP_REQUEUE_PI:
+   /* not yet implemented */
+   linux_msg(td,
+   "linux_sys_futex: "
+   "op LINUX_FUTEX_CMP_REQUEUE_PI not implemented\n");
+   return (ENOSYS);
+
default:
linux_msg(td,
  "linux_sys_futex: unknown op %d\n", args->op);

Modified: head/sys/compat/linux/linux_futex.h
==
--- head/sys/compat/linux/linux_futex.h Mon Jan 31 05:59:05 2011
(r218117)
+++ head/sys/compat/linux/linux_futex.h Mon Jan 31 06:06:23 2011
(r218118)
@@ -51,6 +51,7 @@ extern struct mtx futex_mtx;
 #define LINUX_FUTEX_WAIT_BITSET 9
 #define LINUX_FUTEX_WAKE_BITSET10
 #define LINUX_FUTEX_WAIT_REQUEUE_PI11
+#define LINUX_FUTEX_CMP_REQUEUE_PI 12
 
 #define LINUX_FUTEX_PRIVATE_FLAG   128
 #define LINUX_FUTEX_CLOCK_REALTIME 256
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218609 - head/sys/sys

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 15:24:52 2011
New Revision: 218609
URL: http://svn.freebsd.org/changeset/base/218609

Log:
  Remove unused since r134586 thr_exit1() declaration.

Modified:
  head/sys/sys/proc.h

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Sat Feb 12 14:33:19 2011(r218608)
+++ head/sys/sys/proc.h Sat Feb 12 15:24:52 2011(r218609)
@@ -908,7 +908,6 @@ int thread_unsuspend_one(struct thread *
 void   thread_unthread(struct thread *td);
 void   thread_wait(struct proc *p);
 struct thread  *thread_find(struct proc *p, lwpid_t tid);
-void   thr_exit1(void);
 
 #endif /* _KERNEL */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218610 - in head/sys: amd64/linux32 i386/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 15:33:25 2011
New Revision: 218610
URL: http://svn.freebsd.org/changeset/base/218610

Log:
  The fourth argument of linux_clone is a pointer to the TLS. Change clone 
syscall definition to match actual linux one.

Modified:
  head/sys/amd64/linux32/syscalls.master
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Sat Feb 12 15:24:52 2011
(r218609)
+++ head/sys/amd64/linux32/syscalls.master  Sat Feb 12 15:33:25 2011
(r218610)
@@ -213,9 +213,8 @@
 118AUE_FSYNC   NOPROTO { int fsync(int fd); }
 119AUE_SIGRETURN   STD { int linux_sigreturn( \
struct l_sigframe *sfp); }
-; linux uses some strange calling convention here so we have to use the dummy 
arg
 120AUE_RFORK   STD { int linux_clone(l_int flags, void *stack, \
-   void *parent_tidptr, int dummy, void * 
child_tidptr); }
+   void *parent_tidptr, void *tls, void * 
child_tidptr); }
 121AUE_SYSCTL  STD { int linux_setdomainname(char *name, \
int len); }
 122AUE_NULLSTD { int linux_newuname( \

Modified: head/sys/i386/linux/syscalls.master
==
--- head/sys/i386/linux/syscalls.master Sat Feb 12 15:24:52 2011
(r218609)
+++ head/sys/i386/linux/syscalls.master Sat Feb 12 15:33:25 2011
(r218610)
@@ -214,9 +214,8 @@
 118AUE_FSYNC   NOPROTO { int fsync(int fd); }
 119AUE_SIGRETURN   STD { int linux_sigreturn( \
struct l_sigframe *sfp); }
-; linux uses some strange calling convention here so we have to use the dummy 
arg
 120AUE_RFORK   STD { int linux_clone(l_int flags, void *stack, \
-   void *parent_tidptr, int dummy, void * 
child_tidptr); }
+   void *parent_tidptr, void *tls, void * 
child_tidptr); }
 121AUE_SYSCTL  STD { int linux_setdomainname(char *name, \
int len); }
 122AUE_NULLSTD { int linux_newuname( \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218611 - in head/sys: amd64/linux32 i386/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 15:36:25 2011
New Revision: 218611
URL: http://svn.freebsd.org/changeset/base/218611

Log:
  Regen for r218610.

Modified:
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/amd64/linux32/linux32_syscall.h
  head/sys/amd64/linux32/linux32_sysent.c
  head/sys/i386/linux/linux_proto.h
  head/sys/i386/linux/linux_syscall.h
  head/sys/i386/linux/linux_sysent.c

Modified: head/sys/amd64/linux32/linux32_proto.h
==
--- head/sys/amd64/linux32/linux32_proto.h  Sat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/amd64/linux32/linux32_proto.h  Sat Feb 12 15:36:25 2011
(r218611)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 
2010-10-08 07:18:44Z kib 
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 
2011-02-12 15:33:25Z dchagin 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -375,7 +375,7 @@ struct linux_clone_args {
char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void 
*)];
char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char 
parent_tidptr_r_[PADR_(void *)];
-   char dummy_l_[PADL_(int)]; int dummy; char dummy_r_[PADR_(int)];
+   char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)];
char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char 
child_tidptr_r_[PADR_(void *)];
 };
 struct linux_setdomainname_args {

Modified: head/sys/amd64/linux32/linux32_syscall.h
==
--- head/sys/amd64/linux32/linux32_syscall.hSat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/amd64/linux32/linux32_syscall.hSat Feb 12 15:36:25 2011
(r218611)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 
2010-10-08 07:18:44Z kib 
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 
2011-02-12 15:33:25Z dchagin 
  */
 
 #defineLINUX_SYS_exit  1

Modified: head/sys/amd64/linux32/linux32_sysent.c
==
--- head/sys/amd64/linux32/linux32_sysent.c Sat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/amd64/linux32/linux32_sysent.c Sat Feb 12 15:36:25 2011
(r218611)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 
2010-10-08 07:18:44Z kib 
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 
2011-02-12 15:33:25Z dchagin 
  */
 
 #include "opt_compat.h"

Modified: head/sys/i386/linux/linux_proto.h
==
--- head/sys/i386/linux/linux_proto.h   Sat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/i386/linux/linux_proto.h   Sat Feb 12 15:36:25 2011
(r218611)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 184789 2008-11-09 
10:45:13Z ed 
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 218610 2011-02-12 
15:33:25Z dchagin 
  */
 
 #ifndef _LINUX_SYSPROTO_H_
@@ -378,7 +378,7 @@ struct linux_clone_args {
char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void 
*)];
char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char 
parent_tidptr_r_[PADR_(void *)];
-   char dummy_l_[PADL_(int)]; int dummy; char dummy_r_[PADR_(int)];
+   char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)];
char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char 
child_tidptr_r_[PADR_(void *)];
 };
 struct linux_setdomainname_args {

Modified: head/sys/i386/linux/linux_syscall.h
==
--- head/sys/i386/linux/linux_syscall.h Sat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/i386/linux/linux_syscall.h Sat Feb 12 15:36:25 2011
(r218611)
@@ -3,7 +3,7 @@
  *
  * DO NOT EDIT-- this file is automatically generated.
  * $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 184789 2008-11-09 
10:45:13Z ed 
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 218610 2011-02-12 
15:33:25Z dchagin 
  */
 
 #defineLINUX_SYS_exit  1

Modified: head/sys/i386/linux/linux_sysent.c
==
--- head/sys/i386/linux/linux_sysent.c  Sat Feb 12 15:33:25 2011
(r218610)
+++ head/sys/i386/linux/linux_sysent

svn commit: r218612 - in head/sys: amd64/linux32 i386/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 15:50:21 2011
New Revision: 218612
URL: http://svn.freebsd.org/changeset/base/218612

Log:
  In preparation for moving linux_clone () to a MI path
  move the TLS code in a separate function.
  
  Use function parameter instead of direct using register.

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 15:36:25 2011
(r218611)
+++ head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 15:50:21 2011
(r218612)
@@ -496,6 +496,50 @@ linux_vfork(struct thread *td, struct li
return (0);
 }
 
+static int
+linux_set_cloned_tls(struct thread *td, void *desc)
+{
+   struct user_segment_descriptor sd;
+   struct l_user_desc info;
+   struct pcb *pcb;
+   int error;
+   int a[2];
+
+   error = copyin(desc, &info, sizeof(struct l_user_desc));
+   if (error) {
+   printf(LMSG("copyin failed!"));
+   } else {
+   /* We might copy out the entry_number as GUGS32_SEL. */
+   info.entry_number = GUGS32_SEL;
+   error = copyout(&info, desc, sizeof(struct l_user_desc));
+   if (error)
+   printf(LMSG("copyout failed!"));
+
+   a[0] = LINUX_LDT_entry_a(&info);
+   a[1] = LINUX_LDT_entry_b(&info);
+
+   memcpy(&sd, &a, sizeof(a));
+#ifdef DEBUG
+   if (ldebug(clone))
+   printf("Segment created in clone with "
+   "CLONE_SETTLS: lobase: %x, hibase: %x, "
+   "lolimit: %x, hilimit: %x, type: %i, "
+   "dpl: %i, p: %i, xx: %i, long: %i, "
+   "def32: %i, gran: %i\n", sd.sd_lobase,
+   sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit,
+   sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx,
+   sd.sd_long, sd.sd_def32, sd.sd_gran);
+#endif
+   pcb = td->td_pcb;
+   pcb->pcb_gsbase = (register_t)info.base_addr;
+/* XXXKIB  pcb->pcb_gs32sd = sd; */
+   td->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL);
+   set_pcb_flags(pcb, PCB_GS32BIT | PCB_32BIT);
+   }
+
+   return (error);
+}
+
 int
 linux_clone(struct thread *td, struct linux_clone_args *args)
 {
@@ -613,46 +657,8 @@ linux_clone(struct thread *td, struct li
if (args->stack)
td2->td_frame->tf_rsp = PTROUT(args->stack);
 
-   if (args->flags & LINUX_CLONE_SETTLS) {
-   struct user_segment_descriptor sd;
-   struct l_user_desc info;
-   struct pcb *pcb;
-   int a[2];
-
-   error = copyin((void *)td->td_frame->tf_rsi, &info,
-   sizeof(struct l_user_desc));
-   if (error) {
-   printf(LMSG("copyin failed!"));
-   } else {
-   /* We might copy out the entry_number as GUGS32_SEL. */
-   info.entry_number = GUGS32_SEL;
-   error = copyout(&info, (void *)td->td_frame->tf_rsi,
-   sizeof(struct l_user_desc));
-   if (error)
-   printf(LMSG("copyout failed!"));
-
-   a[0] = LINUX_LDT_entry_a(&info);
-   a[1] = LINUX_LDT_entry_b(&info);
-
-   memcpy(&sd, &a, sizeof(a));
-#ifdef DEBUG
-   if (ldebug(clone))
-   printf("Segment created in clone with "
-   "CLONE_SETTLS: lobase: %x, hibase: %x, "
-   "lolimit: %x, hilimit: %x, type: %i, "
-   "dpl: %i, p: %i, xx: %i, long: %i, "
-   "def32: %i, gran: %i\n", sd.sd_lobase,
-   sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit,
-   sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx,
-   sd.sd_long, sd.sd_def32, sd.sd_gran);
-#endif
-   pcb = td2->td_pcb;
-   pcb->pcb_gsbase = (register_t)info.base_addr;
-/* XXXKIB  pcb->pcb_gs32sd = sd; */
-   td2->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL);
-   set_pcb_flags(pcb, PCB_GS32BIT | PCB_32BIT);
-   }
-   }
+   if (args->flags & LINUX_CLONE_SETTLS)
+   linux_set_cloned_tls(td2, args->tls);
 
 #ifdef DEBUG
if (ldebug(clone))

Modified: head/sys/i386/linux/linux_machdep.c
==
--- head/sys/i386/linux/linux_machdep.c Sat Feb 12 15:36:25 2011
(r21

svn commit: r218613 - in head/sys: amd64/linux32 i386/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 16:33:00 2011
New Revision: 218613
URL: http://svn.freebsd.org/changeset/base/218613

Log:
  In preparation for moving linux_clone() to a MI path
  introduce linux_set_upcall_kse().

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_machdep.c

Modified: head/sys/amd64/linux32/linux.h
==
--- head/sys/amd64/linux32/linux.h  Sat Feb 12 15:50:21 2011
(r218612)
+++ head/sys/amd64/linux32/linux.h  Sat Feb 12 16:33:00 2011
(r218613)
@@ -920,4 +920,6 @@ struct linux_robust_list_head {
l_uintptr_t pending_list;
 };
 
+int linux_set_upcall_kse(struct thread *td, register_t stack);
+
 #endif /* !_AMD64_LINUX_H_ */

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 15:50:21 2011
(r218612)
+++ head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 16:33:00 2011
(r218613)
@@ -655,7 +655,7 @@ linux_clone(struct thread *td, struct li
 * intact.
 */
if (args->stack)
-   td2->td_frame->tf_rsp = PTROUT(args->stack);
+   linux_set_upcall_kse(td2, PTROUT(args->stack));
 
if (args->flags & LINUX_CLONE_SETTLS)
linux_set_cloned_tls(td2, args->tls);
@@ -694,6 +694,15 @@ linux_clone(struct thread *td, struct li
return (0);
 }
 
+int
+linux_set_upcall_kse(struct thread *td, register_t stack)
+{
+
+   td->td_frame->tf_rsp = stack;
+
+   return (0);
+}
+
 #define STACK_SIZE  (2 * 1024 * 1024)
 #define GUARD_SIZE  (4 * PAGE_SIZE)
 

Modified: head/sys/i386/linux/linux.h
==
--- head/sys/i386/linux/linux.h Sat Feb 12 15:50:21 2011(r218612)
+++ head/sys/i386/linux/linux.h Sat Feb 12 16:33:00 2011(r218613)
@@ -880,4 +880,6 @@ struct linux_robust_list_head {
struct linux_robust_list*pending_list;
 };
 
+int linux_set_upcall_kse(struct thread *td, register_t stack);
+
 #endif /* !_I386_LINUX_H_ */

Modified: head/sys/i386/linux/linux_machdep.c
==
--- head/sys/i386/linux/linux_machdep.c Sat Feb 12 15:50:21 2011
(r218612)
+++ head/sys/i386/linux/linux_machdep.c Sat Feb 12 16:33:00 2011
(r218613)
@@ -559,7 +559,7 @@ linux_clone(struct thread *td, struct li
 * this is what normal fork() does so we just keep the tf_esp arg intact
 */
if (args->stack)
-   td2->td_frame->tf_esp = (unsigned int)args->stack;
+   linux_set_upcall_kse(td2, PTROUT(args->stack));
 
if (args->flags & LINUX_CLONE_SETTLS)
linux_set_cloned_tls(td2, args->tls);
@@ -597,6 +597,15 @@ linux_clone(struct thread *td, struct li
return (0);
 }
 
+int
+linux_set_upcall_kse(struct thread *td, register_t stack)
+{
+
+   td->td_frame->tf_esp = stack;
+
+   return (0);
+}
+
 #define STACK_SIZE  (2 * 1024 * 1024)
 #define GUARD_SIZE  (4 * PAGE_SIZE)
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218616 - in head/sys: amd64/linux32 compat/linux conf i386/linux modules/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 18:17:12 2011
New Revision: 218616
URL: http://svn.freebsd.org/changeset/base/218616

Log:
  Move linux_clone(), linux_fork(), linux_vfork() to a MI path.

Added:
  head/sys/compat/linux/linux_fork.c   (contents, props changed)
Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/conf/files.pc98
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_machdep.c
  head/sys/modules/linux/Makefile

Modified: head/sys/amd64/linux32/linux.h
==
--- head/sys/amd64/linux32/linux.h  Sat Feb 12 17:58:36 2011
(r218615)
+++ head/sys/amd64/linux32/linux.h  Sat Feb 12 18:17:12 2011
(r218616)
@@ -921,5 +921,6 @@ struct linux_robust_list_head {
 };
 
 int linux_set_upcall_kse(struct thread *td, register_t stack);
+int linux_set_cloned_tls(struct thread *td, void *desc);
 
 #endif /* !_AMD64_LINUX_H_ */

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 17:58:36 2011
(r218615)
+++ head/sys/amd64/linux32/linux32_machdep.cSat Feb 12 18:17:12 2011
(r218616)
@@ -409,94 +409,6 @@ linux_old_select(struct thread *td, stru
 }
 
 int
-linux_fork(struct thread *td, struct linux_fork_args *args)
-{
-   int error;
-   struct proc *p2;
-   struct thread *td2;
-
-#ifdef DEBUG
-   if (ldebug(fork))
-   printf(ARGS(fork, ""));
-#endif
-
-   if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2)) != 0)
-   return (error);
-
-   if (error == 0) {
-   td->td_retval[0] = p2->p_pid;
-   td->td_retval[1] = 0;
-   }
-
-   if (td->td_retval[1] == 1)
-   td->td_retval[0] = 0;
-   error = linux_proc_init(td, td->td_retval[0], 0);
-   if (error)
-   return (error);
-
-   td2 = FIRST_THREAD_IN_PROC(p2);
-
-   /*
-* Make this runnable after we are finished with it.
-*/
-   thread_lock(td2);
-   TD_SET_CAN_RUN(td2);
-   sched_add(td2, SRQ_BORING);
-   thread_unlock(td2);
-
-   return (0);
-}
-
-int
-linux_vfork(struct thread *td, struct linux_vfork_args *args)
-{
-   int error;
-   struct proc *p2;
-   struct thread *td2;
-
-#ifdef DEBUG
-   if (ldebug(vfork))
-   printf(ARGS(vfork, ""));
-#endif
-
-   /* Exclude RFPPWAIT */
-   if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2)) != 
0)
-   return (error);
-   if (error == 0) {
-   td->td_retval[0] = p2->p_pid;
-   td->td_retval[1] = 0;
-   }
-   /* Are we the child? */
-   if (td->td_retval[1] == 1)
-   td->td_retval[0] = 0;
-   error = linux_proc_init(td, td->td_retval[0], 0);
-   if (error)
-   return (error);
-
-   PROC_LOCK(p2);
-   p2->p_flag |= P_PPWAIT;
-   PROC_UNLOCK(p2);
-
-   td2 = FIRST_THREAD_IN_PROC(p2);
-
-   /*
-* Make this runnable after we are finished with it.
-*/
-   thread_lock(td2);
-   TD_SET_CAN_RUN(td2);
-   sched_add(td2, SRQ_BORING);
-   thread_unlock(td2);
-
-   /* wait for the children to exit, ie. emulate vfork */
-   PROC_LOCK(p2);
-   while (p2->p_flag & P_PPWAIT)
-   cv_wait(&p2->p_pwait, &p2->p_mtx);
-   PROC_UNLOCK(p2);
-
-   return (0);
-}
-
-static int
 linux_set_cloned_tls(struct thread *td, void *desc)
 {
struct user_segment_descriptor sd;
@@ -541,160 +453,6 @@ linux_set_cloned_tls(struct thread *td, 
 }
 
 int
-linux_clone(struct thread *td, struct linux_clone_args *args)
-{
-   int error, ff = RFPROC | RFSTOPPED;
-   struct proc *p2;
-   struct thread *td2;
-   int exit_signal;
-   struct linux_emuldata *em;
-
-#ifdef DEBUG
-   if (ldebug(clone)) {
-   printf(ARGS(clone, "flags %x, stack %p, parent tid: %p, "
-   "child tid: %p"), (unsigned)args->flags,
-   args->stack, args->parent_tidptr, args->child_tidptr);
-   }
-#endif
-
-   exit_signal = args->flags & 0x00ff;
-   if (LINUX_SIG_VALID(exit_signal)) {
-   if (exit_signal <= LINUX_SIGTBLSZ)
-   exit_signal =
-   linux_to_bsd_signal[_SIG_IDX(exit_signal)];
-   } else if (exit_signal != 0)
-   return (EINVAL);
-
-   if (args->flags & LINUX_CLONE_VM)
-   ff |= RFMEM;
-   if (args->flags & LINUX_CLONE_SIGHAND)
-   ff |= RFSIGSHARE;
-   /*
-* XXX: In Linux, sharing of fs info (chroot/cwd/umask)
-* and open files is independant.  In FreeBSD, its in one
-* structure but in reality it does not cause any problems
-* because both of 

svn commit: r218617 - head/sys/compat/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 19:14:57 2011
New Revision: 218617
URL: http://svn.freebsd.org/changeset/base/218617

Log:
  Remove bogus include 

Modified:
  head/sys/compat/linux/linux_fork.c

Modified: head/sys/compat/linux/linux_fork.c
==
--- head/sys/compat/linux/linux_fork.c  Sat Feb 12 18:17:12 2011
(r218616)
+++ head/sys/compat/linux/linux_fork.c  Sat Feb 12 19:14:57 2011
(r218617)
@@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
-
 #ifdef COMPAT_LINUX32
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218618 - head/sys/compat/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 20:16:25 2011
New Revision: 218618
URL: http://svn.freebsd.org/changeset/base/218618

Log:
  Slightly rewrite linux_fork:
  
  1) Remove bogus error checking.
  2) A new process exit from kernel through fork_trampoline(),
 so remove bogus check.

Modified:
  head/sys/compat/linux/linux_fork.c

Modified: head/sys/compat/linux/linux_fork.c
==
--- head/sys/compat/linux/linux_fork.c  Sat Feb 12 19:14:57 2011
(r218617)
+++ head/sys/compat/linux/linux_fork.c  Sat Feb 12 20:16:25 2011
(r218618)
@@ -67,13 +67,9 @@ linux_fork(struct thread *td, struct lin
if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2)) != 0)
return (error);
 
-   if (error == 0) {
-   td->td_retval[0] = p2->p_pid;
-   td->td_retval[1] = 0;
-   }
+   td->td_retval[0] = p2->p_pid;
+   td->td_retval[1] = 0;
 
-   if (td->td_retval[1] == 1)
-   td->td_retval[0] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
@@ -106,13 +102,10 @@ linux_vfork(struct thread *td, struct li
/* Exclude RFPPWAIT */
if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2)) != 
0)
return (error);
-   if (error == 0) {
-   td->td_retval[0] = p2->p_pid;
-   td->td_retval[1] = 0;
-   }
-   /* Are we the child? */
-   if (td->td_retval[1] == 1)
-   td->td_retval[0] = 0;
+
+   td->td_retval[0] = p2->p_pid;
+   td->td_retval[1] = 0;
+
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218621 - head/sys/compat/linux

2011-02-12 Thread Dmitry Chagin
Author: dchagin
Date: Sat Feb 12 20:58:59 2011
New Revision: 218621
URL: http://svn.freebsd.org/changeset/base/218621

Log:
  Rename used_requeue and use it as bitwise field to store more flags.
  Reimplement used_requeue logic with LINUX_XDEPR_REQUEUEOP flag.

Modified:
  head/sys/compat/linux/linux_emul.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_emul.c
==
--- head/sys/compat/linux/linux_emul.c  Sat Feb 12 20:42:53 2011
(r218620)
+++ head/sys/compat/linux/linux_emul.c  Sat Feb 12 20:58:59 2011
(r218621)
@@ -87,7 +87,7 @@ linux_proc_init(struct thread *td, pid_t
em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
em->pid = child;
em->pdeath_signal = 0;
-   em->used_requeue = 0;
+   em->flags = 0;
em->robust_futexes = NULL;
if (flags & LINUX_CLONE_THREAD) {
/* handled later in the code */

Modified: head/sys/compat/linux/linux_emul.h
==
--- head/sys/compat/linux/linux_emul.h  Sat Feb 12 20:42:53 2011
(r218620)
+++ head/sys/compat/linux/linux_emul.h  Sat Feb 12 20:58:59 2011
(r218621)
@@ -55,7 +55,7 @@ struct linux_emuldata {
struct linux_emuldata_shared *shared;
 
int pdeath_signal;  /* parent death signal */
-   int used_requeue;   /* uses deprecated futex op */
+   int flags;  /* different emuldata flags */
 
struct  linux_robust_list_head  *robust_futexes;
 
@@ -76,6 +76,10 @@ struct linux_emuldata*em_find(struct pr
 #defineEMUL_DOLOCK 1
 #defineEMUL_DONTLOCK   0
 
+/* emuldata flags */
+#defineLINUX_XDEPR_REQUEUEOP   0x0001  /* uses deprecated
+  futex REQUEUE op*/
+
 intlinux_proc_init(struct thread *, pid_t, int);
 void   linux_proc_exit(void *, struct proc *);
 void   linux_schedtail(void *, struct proc *);

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Sat Feb 12 20:42:53 2011
(r218620)
+++ head/sys/compat/linux/linux_futex.c Sat Feb 12 20:58:59 2011
(r218621)
@@ -678,11 +678,11 @@ linux_sys_futex(struct thread *td, struc
 * FUTEX_REQUEUE returned EINVAL.
 */
em = em_find(td->td_proc, EMUL_DONTLOCK);
-   if (em->used_requeue == 0) {
+   if ((em->flags & LINUX_XDEPR_REQUEUEOP) == 0) {
linux_msg(td,
  "linux_sys_futex: "
  "unsupported futex_requeue op\n");
-   em->used_requeue = 1;
+   em->flags |= LINUX_XDEPR_REQUEUEOP;
}
return (EINVAL);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218646 - head/sys/compat/linux

2011-02-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 13 17:56:22 2011
New Revision: 218646
URL: http://svn.freebsd.org/changeset/base/218646

Log:
  The bitset field of freshly created futex should be initialized explicity.
  Otherwise, REQUEUE operations fails.

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Sun Feb 13 17:43:56 2011
(r218645)
+++ head/sys/compat/linux/linux_futex.c Sun Feb 13 17:56:22 2011
(r218646)
@@ -194,6 +194,7 @@ retry:
tmpf = malloc(sizeof(*tmpf), M_FUTEX, M_WAITOK | M_ZERO);
tmpf->f_uaddr = uaddr;
tmpf->f_refcount = 1;
+   tmpf->f_bitset = FUTEX_BITSET_MATCH_ANY;
FUTEX_INIT(tmpf);
TAILQ_INIT(&tmpf->f_waiting_proc);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218654 - head/sys/compat/linux

2011-02-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 13 18:41:40 2011
New Revision: 218654
URL: http://svn.freebsd.org/changeset/base/218654

Log:
  Stop printing the LOR, as this is expected behavior.

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Sun Feb 13 18:35:21 2011
(r218653)
+++ head/sys/compat/linux/linux_futex.c Sun Feb 13 18:41:40 2011
(r218654)
@@ -88,7 +88,7 @@ struct futex_list futex_list;
 
 #define FUTEX_LOCK(f)  sx_xlock(&(f)->f_lck)
 #define FUTEX_UNLOCK(f)sx_xunlock(&(f)->f_lck)
-#define FUTEX_INIT(f)  sx_init_flags(&(f)->f_lck, "ftlk", 0)
+#define FUTEX_INIT(f)  sx_init_flags(&(f)->f_lck, "ftlk", SX_DUPOK)
 #define FUTEX_DESTROY(f)   sx_destroy(&(f)->f_lck)
 #define FUTEX_ASSERT_LOCKED(f) sx_assert(&(f)->f_lck, SA_XLOCKED)
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218655 - head/sys/compat/linux

2011-02-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 13 18:46:34 2011
New Revision: 218655
URL: http://svn.freebsd.org/changeset/base/218655

Log:
  Remove comment about 'ftlk' LOR.

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Sun Feb 13 18:41:40 2011
(r218654)
+++ head/sys/compat/linux/linux_futex.c Sun Feb 13 18:46:34 2011
(r218655)
@@ -553,8 +553,7 @@ linux_sys_futex(struct thread *td, struc
 
/*
 * To avoid deadlocks return EINVAL if second futex
-* exists at this time. Otherwise create the new futex
-* and ignore false positive LOR which thus happens.
+* exists at this time.
 *
 * Glibc fall back to FUTEX_WAKE in case of any error
 * returned by FUTEX_CMP_REQUEUE.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218658 - in head/sys: amd64/linux32 i386/linux

2011-02-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 13 19:07:48 2011
New Revision: 218658
URL: http://svn.freebsd.org/changeset/base/218658

Log:
  Sort include files in the alphabetical order.

Modified:
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Sun Feb 13 19:07:17 2011
(r218657)
+++ head/sys/amd64/linux32/linux32_sysvec.c Sun Feb 13 19:07:48 2011
(r218658)
@@ -76,8 +76,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: head/sys/i386/linux/linux_sysvec.c
==
--- head/sys/i386/linux/linux_sysvec.c  Sun Feb 13 19:07:17 2011
(r218657)
+++ head/sys/i386/linux/linux_sysvec.c  Sun Feb 13 19:07:48 2011
(r218658)
@@ -64,8 +64,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218668 - head/sys/compat/linux

2011-02-13 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 13 20:07:48 2011
New Revision: 218668
URL: http://svn.freebsd.org/changeset/base/218668

Log:
  Sort include files in the alphabetical order.

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Sun Feb 13 20:04:29 2011
(r218667)
+++ head/sys/compat/linux/linux_futex.c Sun Feb 13 20:07:48 2011
(r218668)
@@ -60,8 +60,8 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex.
 #include 
 #include 
 #endif
-#include 
 #include 
+#include 
 #include 
 
 MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218686 - head/sys/compat/linux

2011-02-14 Thread Dmitry Chagin
Author: dchagin
Date: Mon Feb 14 17:24:58 2011
New Revision: 218686
URL: http://svn.freebsd.org/changeset/base/218686

Log:
  Style(9) fix. Do not initialize variables in the declarations.

Modified:
  head/sys/compat/linux/linux_futex.c

Modified: head/sys/compat/linux/linux_futex.c
==
--- head/sys/compat/linux/linux_futex.c Mon Feb 14 17:20:20 2011
(r218685)
+++ head/sys/compat/linux/linux_futex.c Mon Feb 14 17:24:58 2011
(r218686)
@@ -436,8 +436,8 @@ linux_sys_futex(struct thread *td, struc
int clockrt, nrwake, op_ret, ret, val;
struct linux_emuldata *em;
struct waiting_proc *wp;
-   struct futex *f, *f2 = NULL;
-   int error = 0;
+   struct futex *f, *f2;
+   int error;
 
/*
 * Our implementation provides only privates futexes. Most of the apps
@@ -460,6 +460,9 @@ linux_sys_futex(struct thread *td, struc
args->op != LINUX_FUTEX_WAIT_REQUEUE_PI)
return (ENOSYS);
 
+   error = 0;
+   f = f2 = NULL;
+
switch (args->op) {
case LINUX_FUTEX_WAIT:
args->val3 = FUTEX_BITSET_MATCH_ANY;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218717 - head/sys/compat/linux

2011-02-15 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb 15 21:22:09 2011
New Revision: 218717
URL: http://svn.freebsd.org/changeset/base/218717

Log:
  Put the macro declaration in the relevant include file for future use.

Modified:
  head/sys/compat/linux/linux_misc.c
  head/sys/compat/linux/linux_signal.h

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Tue Feb 15 21:01:13 2011
(r218716)
+++ head/sys/compat/linux/linux_misc.c  Tue Feb 15 21:22:09 2011
(r218717)
@@ -92,9 +92,6 @@ __FBSDID("$FreeBSD$");
 
 int stclohz;   /* Statistics clock frequency */
 
-#define BSD_TO_LINUX_SIGNAL(sig)   \
-   (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)
-
 static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = {
RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK,
RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE,

Modified: head/sys/compat/linux/linux_signal.h
==
--- head/sys/compat/linux/linux_signal.hTue Feb 15 21:01:13 2011
(r218716)
+++ head/sys/compat/linux/linux_signal.hTue Feb 15 21:22:09 2011
(r218717)
@@ -40,4 +40,7 @@ void ksiginfo_to_lsiginfo(ksiginfo_t *ks
 
 #define LINUX_SIG_VALID(sig)   ((sig) <= LINUX_NSIG && (sig) > 0)
 
+#define BSD_TO_LINUX_SIGNAL(sig)   \
+   (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)
+
 #endif /* _LINUX_SIGNAL_H_ */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218718 - head/sys/compat/linux

2011-02-15 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb 15 21:24:50 2011
New Revision: 218718
URL: http://svn.freebsd.org/changeset/base/218718

Log:
  Style(9) fix. Wrap long lines in linux_rt_sigtimedwait().

Modified:
  head/sys/compat/linux/linux_signal.c

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cTue Feb 15 21:22:09 2011
(r218717)
+++ head/sys/compat/linux/linux_signal.cTue Feb 15 21:24:50 2011
(r218718)
@@ -457,8 +457,9 @@ linux_rt_sigtimedwait(struct thread *td,
return (error);
 #ifdef DEBUG
if (ldebug(rt_sigtimedwait))
-   printf(LMSG("linux_rt_sigtimedwait: incoming timeout 
(%d/%d)\n"),
-   ltv.tv_sec, ltv.tv_usec);
+   printf(LMSG("linux_rt_sigtimedwait: "
+   "incoming timeout (%d/%d)\n"),
+   ltv.tv_sec, ltv.tv_usec);
 #endif
tv.tv_sec = (long)ltv.tv_sec;
tv.tv_usec = (suseconds_t)ltv.tv_usec;
@@ -477,8 +478,9 @@ linux_rt_sigtimedwait(struct thread *td,
timevalclear(&tv);
 #ifdef DEBUG
if (ldebug(rt_sigtimedwait))
-   printf(LMSG("linux_rt_sigtimedwait: converted 
timeout (%jd/%ld)\n"),
-   (intmax_t)tv.tv_sec, tv.tv_usec);
+   printf(LMSG("linux_rt_sigtimedwait: "
+   "converted timeout (%jd/%ld)\n"),
+   (intmax_t)tv.tv_sec, tv.tv_usec);
 #endif
}
TIMEVAL_TO_TIMESPEC(&tv, &ts);
@@ -487,7 +489,8 @@ linux_rt_sigtimedwait(struct thread *td,
error = kern_sigtimedwait(td, bset, &info, tsa);
 #ifdef DEBUG
if (ldebug(rt_sigtimedwait))
-   printf(LMSG("linux_rt_sigtimedwait: sigtimedwait returning 
(%d)\n"), error);
+   printf(LMSG("linux_rt_sigtimedwait: "
+   "sigtimedwait returning (%d)\n"), error);
 #endif
if (error)
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218719 - head/sys/compat/linux

2011-02-15 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb 15 21:42:48 2011
New Revision: 218719
URL: http://svn.freebsd.org/changeset/base/218719

Log:
  Make a linux_rt_sigtimedwait() system call is actually working.
  
  1) Translate the native signal number in the appropriate Linux signal.
  2) Remove bogus code, which can lead to a panic as it calls
 kern_sigtimedwait with same ksiginfo.
  3) Return the corresponding signal number.

Modified:
  head/sys/compat/linux/linux_signal.c

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cTue Feb 15 21:24:50 2011
(r218718)
+++ head/sys/compat/linux/linux_signal.cTue Feb 15 21:42:48 2011
(r218719)
@@ -431,7 +431,7 @@ int
 linux_rt_sigtimedwait(struct thread *td,
struct linux_rt_sigtimedwait_args *args)
 {
-   int error;
+   int error, sig;
l_timeval ltv;
struct timeval tv;
struct timespec ts, *tsa;
@@ -495,19 +495,15 @@ linux_rt_sigtimedwait(struct thread *td,
if (error)
return (error);
 
+   sig = BSD_TO_LINUX_SIGNAL(info.ksi_signo);
+
if (args->ptr) {
memset(&linfo, 0, sizeof(linfo));
-   linfo.lsi_signo = info.ksi_signo;
+   ksiginfo_to_lsiginfo(&info, &linfo, sig);
error = copyout(&linfo, args->ptr, sizeof(linfo));
}
-
-   /* Repost if we got an error. */
-   if (error && info.ksi_signo) {
-   PROC_LOCK(td->td_proc);
-   tdksignal(td, info.ksi_signo, &info);
-   PROC_UNLOCK(td->td_proc);
-   } else
-   td->td_retval[0] = info.ksi_signo; 
+   if (error == 0)
+   td->td_retval[0] = sig; 
 
return (error);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218720 - in head/sys: amd64/linux32 compat/linux i386/linux

2011-02-15 Thread Dmitry Chagin
Author: dchagin
Date: Tue Feb 15 21:46:36 2011
New Revision: 218720
URL: http://svn.freebsd.org/changeset/base/218720

Log:
  For realtime signals fill the sigval value.

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/compat/linux/linux_signal.c
  head/sys/i386/linux/linux.h

Modified: head/sys/amd64/linux32/linux.h
==
--- head/sys/amd64/linux32/linux.h  Tue Feb 15 21:42:48 2011
(r218719)
+++ head/sys/amd64/linux32/linux.h  Tue Feb 15 21:46:36 2011
(r218720)
@@ -306,6 +306,7 @@ struct l_new_utsname {
 #defineLINUX_SIGPOLL   LINUX_SIGIO
 #defineLINUX_SIGPWR30
 #defineLINUX_SIGSYS31
+#defineLINUX_SIGRTMIN  32
 
 #defineLINUX_SIGTBLSZ  31
 #defineLINUX_NSIG_WORDS2

Modified: head/sys/compat/linux/linux_signal.c
==
--- head/sys/compat/linux/linux_signal.cTue Feb 15 21:42:48 2011
(r218719)
+++ head/sys/compat/linux/linux_signal.cTue Feb 15 21:46:36 2011
(r218720)
@@ -649,4 +649,8 @@ ksiginfo_to_lsiginfo(ksiginfo_t *ksi, l_
lsi->lsi_uid = ksi->ksi_uid;
break;
}
+   if (sig >= LINUX_SIGRTMIN) {
+   lsi->lsi_int = ksi->ksi_info.si_value.sival_int;
+   lsi->lsi_ptr = PTROUT(ksi->ksi_info.si_value.sival_ptr);
+   }
 }

Modified: head/sys/i386/linux/linux.h
==
--- head/sys/i386/linux/linux.h Tue Feb 15 21:42:48 2011(r218719)
+++ head/sys/i386/linux/linux.h Tue Feb 15 21:46:36 2011(r218720)
@@ -281,6 +281,7 @@ struct l_new_utsname {
 #defineLINUX_SIGPOLL   LINUX_SIGIO
 #defineLINUX_SIGPWR30
 #defineLINUX_SIGSYS31
+#defineLINUX_SIGRTMIN  32
 
 #defineLINUX_SIGTBLSZ  31
 #defineLINUX_NSIG_WORDS2
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218744 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include

2011-02-16 Thread Dmitry Chagin
Author: dchagin
Date: Wed Feb 16 17:50:21 2011
New Revision: 218744
URL: http://svn.freebsd.org/changeset/base/218744

Log:
  To avoid excessive code duplication create wrapper for fill regs
  from stack frame. Change the trap() code to use newly created function
  instead of explicit regs assignment.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/trap.c
  head/sys/amd64/include/reg.h
  head/sys/i386/i386/machdep.c
  head/sys/i386/i386/trap.c
  head/sys/i386/include/reg.h

Modified: head/sys/amd64/amd64/machdep.c
==
--- head/sys/amd64/amd64/machdep.c  Wed Feb 16 16:19:54 2011
(r218743)
+++ head/sys/amd64/amd64/machdep.c  Wed Feb 16 17:50:21 2011
(r218744)
@@ -1842,6 +1842,12 @@ fill_regs(struct thread *td, struct reg 
struct trapframe *tp;
 
tp = td->td_frame;
+   return (fill_frame_regs(tp, regs));
+}
+
+int
+fill_frame_regs(struct trapframe *tp, struct reg *regs)
+{
regs->r_r15 = tp->tf_r15;
regs->r_r14 = tp->tf_r14;
regs->r_r13 = tp->tf_r13;

Modified: head/sys/amd64/amd64/trap.c
==
--- head/sys/amd64/amd64/trap.c Wed Feb 16 16:19:54 2011(r218743)
+++ head/sys/amd64/amd64/trap.c Wed Feb 16 17:50:21 2011(r218744)
@@ -249,38 +249,8 @@ trap(struct trapframe *frame)
if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
type == T_BPTFLT) {
struct reg regs;
-
-   regs.r_r15 = frame->tf_r15;
-   regs.r_r14 = frame->tf_r14;
-   regs.r_r13 = frame->tf_r13;
-   regs.r_r12 = frame->tf_r12;
-   regs.r_r11 = frame->tf_r11;
-   regs.r_r10 = frame->tf_r10;
-   regs.r_r9  = frame->tf_r9;
-   regs.r_r8  = frame->tf_r8;
-   regs.r_rdi = frame->tf_rdi;
-   regs.r_rsi = frame->tf_rsi;
-   regs.r_rbp = frame->tf_rbp;
-   regs.r_rbx = frame->tf_rbx;
-   regs.r_rdx = frame->tf_rdx;
-   regs.r_rcx = frame->tf_rcx;
-   regs.r_rax = frame->tf_rax;
-   regs.r_rip = frame->tf_rip;
-   regs.r_cs = frame->tf_cs;
-   regs.r_rflags = frame->tf_rflags;
-   regs.r_rsp = frame->tf_rsp;
-   regs.r_ss = frame->tf_ss;
-   if (frame->tf_flags & TF_HASSEGS) {
-   regs.r_ds = frame->tf_ds;
-   regs.r_es = frame->tf_es;
-   regs.r_fs = frame->tf_fs;
-   regs.r_gs = frame->tf_gs;
-   } else {
-   regs.r_ds = 0;
-   regs.r_es = 0;
-   regs.r_fs = 0;
-   regs.r_gs = 0;
-   }
+   
+   fill_frame_regs(frame, ®s);
if (type == T_DTRACE_PROBE &&
dtrace_fasttrap_probe_ptr != NULL &&
dtrace_fasttrap_probe_ptr(®s) == 0)

Modified: head/sys/amd64/include/reg.h
==
--- head/sys/amd64/include/reg.hWed Feb 16 16:19:54 2011
(r218743)
+++ head/sys/amd64/include/reg.hWed Feb 16 17:50:21 2011
(r218744)
@@ -130,6 +130,7 @@ struct dbreg {
  * XXX these interfaces are MI, so they should be declared in a MI place.
  */
 intfill_regs(struct thread *, struct reg *);
+intfill_frame_regs(struct trapframe *, struct reg *);
 intset_regs(struct thread *, struct reg *);
 intfill_fpregs(struct thread *, struct fpreg *);
 intset_fpregs(struct thread *, struct fpreg *);

Modified: head/sys/i386/i386/machdep.c
==
--- head/sys/i386/i386/machdep.cWed Feb 16 16:19:54 2011
(r218743)
+++ head/sys/i386/i386/machdep.cWed Feb 16 17:50:21 2011
(r218744)
@@ -3122,6 +3122,13 @@ fill_regs(struct thread *td, struct reg 
 
tp = td->td_frame;
pcb = td->td_pcb;
+   regs->r_gs = pcb->pcb_gs;
+   return (fill_frame_regs(tp, regs));
+}
+
+int
+fill_frame_regs(struct trapframe *tp, struct reg *regs)
+{
regs->r_fs = tp->tf_fs;
regs->r_es = tp->tf_es;
regs->r_ds = tp->tf_ds;
@@ -3137,7 +3144,6 @@ fill_regs(struct thread *td, struct reg 
regs->r_eflags = tp->tf_eflags;
regs->r_esp = tp->tf_esp;
regs->r_ss = tp->tf_ss;
-   regs->r_gs = pcb->pcb_gs;
return (0);
 }
 

Modified: head/sys/i386/i386/trap.c
==
--- head/sys/i386/i386/trap.c   Wed Feb 16 16:19:54 2011(r218743)
+++ head/sys/i386/i386/trap.c   Wed Feb 16 17:50:21 2011(r218744)
@@ -271,21 +271,7 @@ trap(struct trapframe *frame)
type == T_B

svn commit: r218879 - head/sys/compat/linux

2011-02-19 Thread Dmitry Chagin
Author: dchagin
Date: Sun Feb 20 07:58:30 2011
New Revision: 218879
URL: http://svn.freebsd.org/changeset/base/218879

Log:
  Do not clobber %rdx.
  Before calling vfork() syscall the linux user-space stores the current PID
  in the %rdx and restore it when the parent process will leave the kernel.

Modified:
  head/sys/compat/linux/linux_fork.c

Modified: head/sys/compat/linux/linux_fork.c
==
--- head/sys/compat/linux/linux_fork.c  Sun Feb 20 07:46:35 2011
(r218878)
+++ head/sys/compat/linux/linux_fork.c  Sun Feb 20 07:58:30 2011
(r218879)
@@ -104,7 +104,6 @@ linux_vfork(struct thread *td, struct li
return (error);
 
td->td_retval[0] = p2->p_pid;
-   td->td_retval[1] = 0;
 
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345468 - head/sys/amd64/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 14:02:57 2019
New Revision: 345468
URL: https://svnweb.freebsd.org/changeset/base/345468

Log:
  Revert r313993.
  AMD64_SET_**BASE expects a pointer to a pointer, we just passing in the 
pointer value itself.
  
  Set PCB_FULL_IRET for doreti to restore %fs, %gs and its correspondig base.
  
  PR:   225105
  Reported by:  trasz@
  MFC after:1 month

Modified:
  head/sys/amd64/linux/linux_machdep.c

Modified: head/sys/amd64/linux/linux_machdep.c
==
--- head/sys/amd64/linux/linux_machdep.cSun Mar 24 12:13:05 2019
(r345467)
+++ head/sys/amd64/linux/linux_machdep.cSun Mar 24 14:02:57 2019
(r345468)
@@ -228,35 +228,38 @@ linux_sigaltstack(struct thread *td, struct linux_siga
 int
 linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args)
 {
+   struct pcb *pcb;
int error;
-   struct sysarch_args bsd_args;
 
+   pcb = td->td_pcb;
LINUX_CTR2(arch_prctl, "0x%x, %p", args->code, args->addr);
 
switch (args->code) {
case LINUX_ARCH_SET_GS:
-   bsd_args.op = AMD64_SET_GSBASE;
-   bsd_args.parms = (void *)args->addr;
-   error = sysarch(td, &bsd_args);
-   if (error == EINVAL)
+   if (args->addr < VM_MAXUSER_ADDRESS) {
+   set_pcb_flags(pcb, PCB_FULL_IRET);
+   pcb->pcb_gsbase = args->addr;
+   td->td_frame->tf_gs = _ugssel;
+   error = 0;
+   } else
error = EPERM;
break;
case LINUX_ARCH_SET_FS:
-   bsd_args.op = AMD64_SET_FSBASE;
-   bsd_args.parms = (void *)args->addr;
-   error = sysarch(td, &bsd_args);
-   if (error == EINVAL)
+   if (args->addr < VM_MAXUSER_ADDRESS) {
+   set_pcb_flags(pcb, PCB_FULL_IRET);
+   pcb->pcb_fsbase = args->addr;
+   td->td_frame->tf_fs = _ufssel;
+   error = 0;
+   } else
error = EPERM;
break;
case LINUX_ARCH_GET_FS:
-   bsd_args.op = AMD64_GET_FSBASE;
-   bsd_args.parms = (void *)args->addr;
-   error = sysarch(td, &bsd_args);
+   error = copyout(&pcb->pcb_fsbase, PTRIN(args->addr),
+   sizeof(args->addr));
break;
case LINUX_ARCH_GET_GS:
-   bsd_args.op = AMD64_GET_GSBASE;
-   bsd_args.parms = (void *)args->addr;
-   error = sysarch(td, &bsd_args);
+   error = copyout(&pcb->pcb_gsbase, PTRIN(args->addr),
+   sizeof(args->addr));
break;
default:
error = EINVAL;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345472 - in head/sys: amd64/linux amd64/linux32 i386/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 14:51:17 2019
New Revision: 345472
URL: https://svnweb.freebsd.org/changeset/base/345472

Log:
  Regen from r345471.
  
  MFC after:1 month

Modified:
  head/sys/amd64/linux/linux_proto.h
  head/sys/amd64/linux/linux_syscall.h
  head/sys/amd64/linux/linux_syscalls.c
  head/sys/amd64/linux/linux_sysent.c
  head/sys/amd64/linux/linux_systrace_args.c
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/amd64/linux32/linux32_syscall.h
  head/sys/amd64/linux32/linux32_syscalls.c
  head/sys/amd64/linux32/linux32_sysent.c
  head/sys/amd64/linux32/linux32_systrace_args.c
  head/sys/i386/linux/linux_proto.h
  head/sys/i386/linux/linux_syscall.h
  head/sys/i386/linux/linux_syscalls.c
  head/sys/i386/linux/linux_sysent.c
  head/sys/i386/linux/linux_systrace_args.c

Modified: head/sys/amd64/linux/linux_proto.h
==
--- head/sys/amd64/linux/linux_proto.h  Sun Mar 24 14:50:02 2019
(r345471)
+++ head/sys/amd64/linux/linux_proto.h  Sun Mar 24 14:51:17 2019
(r345472)
@@ -1213,6 +1213,34 @@ struct linux_pkey_alloc_args {
 struct linux_pkey_free_args {
char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
 };
+struct linux_statx_args {
+   char dirfd_l_[PADL_(l_int)]; l_int dirfd; char dirfd_r_[PADR_(l_int)];
+   char pathname_l_[PADL_(const char *)]; const char * pathname; char 
pathname_r_[PADR_(const char *)];
+   char flags_l_[PADL_(l_uint)]; l_uint flags; char 
flags_r_[PADR_(l_uint)];
+   char mask_l_[PADL_(l_uint)]; l_uint mask; char mask_r_[PADR_(l_uint)];
+   char statxbuf_l_[PADL_(void *)]; void * statxbuf; char 
statxbuf_r_[PADR_(void *)];
+};
+struct linux_io_pgetevents_args {
+   register_t dummy;
+};
+struct linux_rseq_args {
+   register_t dummy;
+};
+struct linux_pidfd_send_signal_args {
+   char pidfd_l_[PADL_(l_int)]; l_int pidfd; char pidfd_r_[PADR_(l_int)];
+   char sig_l_[PADL_(l_int)]; l_int sig; char sig_r_[PADR_(l_int)];
+   char info_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * info; char 
info_r_[PADR_(l_siginfo_t *)];
+   char flags_l_[PADL_(l_uint)]; l_uint flags; char 
flags_r_[PADR_(l_uint)];
+};
+struct linux_io_uring_setup_args {
+   register_t dummy;
+};
+struct linux_io_uring_enter_args {
+   register_t dummy;
+};
+struct linux_io_uring_register_args {
+   register_t dummy;
+};
 #definenosys   linux_nosys
 intlinux_open(struct thread *, struct linux_open_args *);
 intlinux_newstat(struct thread *, struct linux_newstat_args *);
@@ -1479,6 +1507,13 @@ int  linux_pwritev2(struct thread *, struct 
linux_pwrit
 intlinux_pkey_mprotect(struct thread *, struct linux_pkey_mprotect_args *);
 intlinux_pkey_alloc(struct thread *, struct linux_pkey_alloc_args *);
 intlinux_pkey_free(struct thread *, struct linux_pkey_free_args *);
+intlinux_statx(struct thread *, struct linux_statx_args *);
+intlinux_io_pgetevents(struct thread *, struct linux_io_pgetevents_args *);
+intlinux_rseq(struct thread *, struct linux_rseq_args *);
+intlinux_pidfd_send_signal(struct thread *, struct 
linux_pidfd_send_signal_args *);
+intlinux_io_uring_setup(struct thread *, struct linux_io_uring_setup_args 
*);
+intlinux_io_uring_enter(struct thread *, struct linux_io_uring_enter_args 
*);
+intlinux_io_uring_register(struct thread *, struct 
linux_io_uring_register_args *);
 
 #ifdef COMPAT_43
 
@@ -1786,6 +1821,13 @@ int  linux_pkey_free(struct thread *, struct 
linux_pkey
 #defineLINUX_SYS_AUE_linux_pkey_mprotect   AUE_NULL
 #defineLINUX_SYS_AUE_linux_pkey_alloc  AUE_NULL
 #defineLINUX_SYS_AUE_linux_pkey_free   AUE_NULL
+#defineLINUX_SYS_AUE_linux_statx   AUE_NULL
+#defineLINUX_SYS_AUE_linux_io_pgetevents   AUE_NULL
+#defineLINUX_SYS_AUE_linux_rseqAUE_NULL
+#defineLINUX_SYS_AUE_linux_pidfd_send_signal   AUE_NULL
+#defineLINUX_SYS_AUE_linux_io_uring_setup  AUE_NULL
+#defineLINUX_SYS_AUE_linux_io_uring_enter  AUE_NULL
+#defineLINUX_SYS_AUE_linux_io_uring_register   AUE_NULL
 
 #undef PAD_
 #undef PADL_

Modified: head/sys/amd64/linux/linux_syscall.h
==
--- head/sys/amd64/linux/linux_syscall.hSun Mar 24 14:50:02 2019
(r345471)
+++ head/sys/amd64/linux/linux_syscall.hSun Mar 24 14:51:17 2019
(r345472)
@@ -313,4 +313,11 @@
 #defineLINUX_SYS_linux_pkey_mprotect   329
 #defineLINUX_SYS_linux_pkey_alloc  330
 #defineLINUX_SYS_linux_pkey_free   331
-#defineLINUX_SYS_MAXSYSCALL333
+#defineLINUX_SYS_linux_statx   332
+#defineLINUX_SYS_linux_io_pgetevents   333
+#defineLINUX_SYS_linux_rseq334
+#defineLINUX_SYS_linux_pidfd_send_signal   424
+#defineLINUX_SYS_linux_io_uring_setup 

svn commit: r345473 - head/sys/compat/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 15:08:30 2019
New Revision: 345473
URL: https://svnweb.freebsd.org/changeset/base/345473

Log:
  Whitespace cleanup (annoying).
  
  MFC after:1 month

Modified:
  head/sys/compat/linux/linux_fork.c

Modified: head/sys/compat/linux/linux_fork.c
==
--- head/sys/compat/linux/linux_fork.c  Sun Mar 24 14:51:17 2019
(r345472)
+++ head/sys/compat/linux/linux_fork.c  Sun Mar 24 15:08:30 2019
(r345473)
@@ -353,7 +353,7 @@ linux_clone_thread(struct thread *td, struct linux_clo
thread_unlock(td);
if (P_SHOULDSTOP(p))
newtd->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK;
-   
+
if (p->p_ptevents & PTRACE_LWP)
newtd->td_dbgflags |= TDB_BORN;
PROC_UNLOCK(p);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r345469 - in head/sys: amd64/linux32 compat/linux i386/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 14:44:35 2019
New Revision: 345469
URL: https://svnweb.freebsd.org/changeset/base/345469

Log:
  Linux between 4.18 and 5.0 split IPC system calls.
  In preparation for doing this in the Linuxulator modify our linux_shmat()
  to match actual Linux shmat() system call.
  
  MFC after:1 month

Modified:
  head/sys/amd64/linux32/linux32_machdep.c
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/linux/linux_ipc.c
  head/sys/compat/linux/linux_ipc.h
  head/sys/i386/linux/linux_machdep.c
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/linux32_machdep.c
==
--- head/sys/amd64/linux32/linux32_machdep.cSun Mar 24 14:02:57 2019
(r345468)
+++ head/sys/amd64/linux32/linux32_machdep.cSun Mar 24 14:44:35 2019
(r345469)
@@ -259,7 +259,7 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
struct linux_semop_args a;
 
a.semid = args->arg1;
-   a.tsops = args->ptr;
+   a.tsops = PTRIN(args->ptr);
a.nsops = args->arg2;
return (linux_semop(td, &a));
}
@@ -278,7 +278,7 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
a.semid = args->arg1;
a.semnum = args->arg2;
a.cmd = args->arg3;
-   error = copyin(args->ptr, &a.arg, sizeof(a.arg));
+   error = copyin(PTRIN(args->ptr), &a.arg, sizeof(a.arg));
if (error)
return (error);
return (linux_semctl(td, &a));
@@ -287,7 +287,7 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
struct linux_msgsnd_args a;
 
a.msqid = args->arg1;
-   a.msgp = args->ptr;
+   a.msgp = PTRIN(args->ptr);
a.msgsz = args->arg2;
a.msgflg = args->arg3;
return (linux_msgsnd(td, &a));
@@ -304,13 +304,13 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
 
if (args->ptr == 0)
return (EINVAL);
-   error = copyin(args->ptr, &tmp, sizeof(tmp));
+   error = copyin(PTRIN(args->ptr), &tmp, sizeof(tmp));
if (error)
return (error);
a.msgp = PTRIN(tmp.msgp);
a.msgtyp = tmp.msgtyp;
} else {
-   a.msgp = args->ptr;
+   a.msgp = PTRIN(args->ptr);
a.msgtyp = args->arg5;
}
return (linux_msgrcv(td, &a));
@@ -327,22 +327,29 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
 
a.msqid = args->arg1;
a.cmd = args->arg2;
-   a.buf = args->ptr;
+   a.buf = PTRIN(args->ptr);
return (linux_msgctl(td, &a));
}
case LINUX_SHMAT: {
struct linux_shmat_args a;
+   l_uintptr_t addr;
+   int error;
 
a.shmid = args->arg1;
-   a.shmaddr = args->ptr;
+   a.shmaddr = PTRIN(args->ptr);
a.shmflg = args->arg2;
-   a.raddr = PTRIN((l_uint)args->arg3);
-   return (linux_shmat(td, &a));
+   error = linux_shmat(td, &a);
+   if (error != 0)
+   return (error);
+   addr = td->td_retval[0];
+   error = copyout(&addr, PTRIN(args->arg3), sizeof(addr));
+   td->td_retval[0] = 0;
+   return (error);
}
case LINUX_SHMDT: {
struct linux_shmdt_args a;
 
-   a.shmaddr = args->ptr;
+   a.shmaddr = PTRIN(args->ptr);
return (linux_shmdt(td, &a));
}
case LINUX_SHMGET: {
@@ -358,7 +365,7 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar
 
a.shmid = args->arg1;
a.cmd = args->arg2;
-   a.buf = args->ptr;
+   a.buf = PTRIN(args->ptr);
return (linux_shmctl(td, &a));
}
default:

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Sun Mar 24 14:02:57 2019
(r345468)
+++ head/sys/amd64/linux32/syscalls.master  Sun Mar 24 14:44:35 2019
(r345469)
@@ -212,8 +212,8 @@
 115AUE_SWAPOFF STD { int linux_swapoff(void); }
 116AUE_NULLSTD { int linux_sysinfo(struct l_sysinfo *info); }
 117AUE_NULLSTD { int linux_ipc(l_uint what, l_int arg1, \
-   l_int arg2, l_int arg3, void *ptr, \
-   l_long arg5); }
+   l_

svn commit: r345470 - in head/sys: amd64/linux32 i386/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 14:46:07 2019
New Revision: 345470
URL: https://svnweb.freebsd.org/changeset/base/345470

Log:
  Regen for r345469 (shmat()).
  
  MFC after:1 month

Modified:
  head/sys/amd64/linux32/linux32_proto.h
  head/sys/amd64/linux32/linux32_systrace_args.c
  head/sys/i386/linux/linux_proto.h
  head/sys/i386/linux/linux_systrace_args.c

Modified: head/sys/amd64/linux32/linux32_proto.h
==
--- head/sys/amd64/linux32/linux32_proto.h  Sun Mar 24 14:44:35 2019
(r345469)
+++ head/sys/amd64/linux32/linux32_proto.h  Sun Mar 24 14:46:07 2019
(r345470)
@@ -369,9 +369,9 @@ struct linux_ipc_args {
char what_l_[PADL_(l_uint)]; l_uint what; char what_r_[PADR_(l_uint)];
char arg1_l_[PADL_(l_int)]; l_int arg1; char arg1_r_[PADR_(l_int)];
char arg2_l_[PADL_(l_int)]; l_int arg2; char arg2_r_[PADR_(l_int)];
-   char arg3_l_[PADL_(l_int)]; l_int arg3; char arg3_r_[PADR_(l_int)];
-   char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)];
-   char arg5_l_[PADL_(l_long)]; l_long arg5; char arg5_r_[PADR_(l_long)];
+   char arg3_l_[PADL_(l_uint)]; l_uint arg3; char arg3_r_[PADR_(l_uint)];
+   char ptr_l_[PADL_(l_uintptr_t)]; l_uintptr_t ptr; char 
ptr_r_[PADR_(l_uintptr_t)];
+   char arg5_l_[PADL_(l_uint)]; l_uint arg5; char arg5_r_[PADR_(l_uint)];
 };
 struct linux_sigreturn_args {
char sfp_l_[PADL_(struct l_sigframe *)]; struct l_sigframe * sfp; char 
sfp_r_[PADR_(struct l_sigframe *)];

Modified: head/sys/amd64/linux32/linux32_systrace_args.c
==
--- head/sys/amd64/linux32/linux32_systrace_args.c  Sun Mar 24 14:44:35 
2019(r345469)
+++ head/sys/amd64/linux32/linux32_systrace_args.c  Sun Mar 24 14:46:07 
2019(r345470)
@@ -785,9 +785,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg
iarg[0] = p->what; /* l_uint */
iarg[1] = p->arg1; /* l_int */
iarg[2] = p->arg2; /* l_int */
-   iarg[3] = p->arg3; /* l_int */
-   uarg[4] = (intptr_t) p->ptr; /* void * */
-   iarg[5] = p->arg5; /* l_long */
+   iarg[3] = p->arg3; /* l_uint */
+   iarg[4] = p->ptr; /* l_uintptr_t */
+   iarg[5] = p->arg5; /* l_uint */
*n_args = 6;
break;
}
@@ -3894,13 +3894,13 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d
p = "l_int";
break;
case 3:
-   p = "l_int";
+   p = "l_uint";
break;
case 4:
-   p = "userland void *";
+   p = "l_uintptr_t";
break;
case 5:
-   p = "l_long";
+   p = "l_uint";
break;
default:
break;

Modified: head/sys/i386/linux/linux_proto.h
==
--- head/sys/i386/linux/linux_proto.h   Sun Mar 24 14:44:35 2019
(r345469)
+++ head/sys/i386/linux/linux_proto.h   Sun Mar 24 14:46:07 2019
(r345470)
@@ -372,9 +372,9 @@ struct linux_ipc_args {
char what_l_[PADL_(l_uint)]; l_uint what; char what_r_[PADR_(l_uint)];
char arg1_l_[PADL_(l_int)]; l_int arg1; char arg1_r_[PADR_(l_int)];
char arg2_l_[PADL_(l_int)]; l_int arg2; char arg2_r_[PADR_(l_int)];
-   char arg3_l_[PADL_(l_int)]; l_int arg3; char arg3_r_[PADR_(l_int)];
-   char ptr_l_[PADL_(void *)]; void * ptr; char ptr_r_[PADR_(void *)];
-   char arg5_l_[PADL_(l_long)]; l_long arg5; char arg5_r_[PADR_(l_long)];
+   char arg3_l_[PADL_(l_uint)]; l_uint arg3; char arg3_r_[PADR_(l_uint)];
+   char ptr_l_[PADL_(l_uintptr_t)]; l_uintptr_t ptr; char 
ptr_r_[PADR_(l_uintptr_t)];
+   char arg5_l_[PADL_(l_uint)]; l_uint arg5; char arg5_r_[PADR_(l_uint)];
 };
 struct linux_sigreturn_args {
char sfp_l_[PADL_(struct l_sigframe *)]; struct l_sigframe * sfp; char 
sfp_r_[PADR_(struct l_sigframe *)];

Modified: head/sys/i386/linux/linux_systrace_args.c
==
--- head/sys/i386/linux/linux_systrace_args.c   Sun Mar 24 14:44:35 2019
(r345469)
+++ head/sys/i386/linux/linux_systrace_args.c   Sun Mar 24 14:46:07 2019
(r345470)
@@ -814,9 +814,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg
iarg[0] = p->what; /* l_uint */
iarg[1] = p->arg1; /* l_int */
iarg[2] = p->arg2; /* l_int */
-   iarg[3] = p->arg3; /* l_int */
-   uarg[4] = (intptr_t) p->ptr; /* void * */
-   iarg[5] = p->arg5; /* l_long */
+

svn commit: r345471 - in head/sys: amd64/linux amd64/linux32 compat/linux i386/linux

2019-03-24 Thread Dmitry Chagin
Author: dchagin
Date: Sun Mar 24 14:50:02 2019
New Revision: 345471
URL: https://svnweb.freebsd.org/changeset/base/345471

Log:
  Update syscall.master to 5.0.
  
  For 32-bit Linuxulator, ipc() syscall was historically
  the entry point for the IPC API. Starting in Linux 4.18, direct
  syscalls are provided for the IPC. Enable it.
  
  MFC after:1 month

Modified:
  head/sys/amd64/linux/linux_dummy.c
  head/sys/amd64/linux/syscalls.master
  head/sys/amd64/linux32/linux32_dummy.c
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/linux/linux_ipc.h
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_dummy.c
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux/linux_dummy.c
==
--- head/sys/amd64/linux/linux_dummy.c  Sun Mar 24 14:46:07 2019
(r345470)
+++ head/sys/amd64/linux/linux_dummy.c  Sun Mar 24 14:50:02 2019
(r345471)
@@ -155,6 +155,16 @@ DUMMY(pwritev2);
 DUMMY(pkey_mprotect);
 DUMMY(pkey_alloc);
 DUMMY(pkey_free);
+/* Linux 4.11: */
+DUMMY(statx);
+/* Linux 4.18: */
+DUMMY(io_pgetevents);
+DUMMY(rseq);
+/* Linux 5.0: */
+DUMMY(pidfd_send_signal);
+DUMMY(io_uring_setup);
+DUMMY(io_uring_enter);
+DUMMY(io_uring_register);
 
 #define DUMMY_XATTR(s) \
 int\

Modified: head/sys/amd64/linux/syscalls.master
==
--- head/sys/amd64/linux/syscalls.masterSun Mar 24 14:46:07 2019
(r345470)
+++ head/sys/amd64/linux/syscalls.masterSun Mar 24 14:50:02 2019
(r345471)
@@ -595,7 +595,21 @@
 330AUE_NULLSTD { int linux_pkey_alloc(l_ulong flags,   
\
l_ulong init_val); }
 331AUE_NULLSTD { int linux_pkey_free(l_int pkey); }
+; Linux 4.11:
+332AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
+   const char *pathname, l_uint flags, 
\
+   l_uint mask, void *statxbuf); }
+; Linux 4.18:
+333AUE_NULLSTD { int linux_io_pgetevents(void); }
+334AUE_NULLSTD { int linux_rseq(void); }
+; Linux 5.0:
+335-423AUE_NULLUNIMPL  nosys
+424AUE_NULLSTD { int linux_pidfd_send_signal(l_int pidfd,  
\
+   l_int sig, l_siginfo_t *info, l_uint 
flags); }
+425AUE_NULLSTD { int linux_io_uring_setup(void); }
+426AUE_NULLSTD { int linux_io_uring_enter(void); }
+427AUE_NULLSTD { int linux_io_uring_register(void); }
 
 ; please, keep this line at the end.
-332AUE_NULLUNIMPL  nosys
+428AUE_NULLUNIMPL  nosys
 ; vim: syntax=off

Modified: head/sys/amd64/linux32/linux32_dummy.c
==
--- head/sys/amd64/linux32/linux32_dummy.c  Sun Mar 24 14:46:07 2019
(r345470)
+++ head/sys/amd64/linux32/linux32_dummy.c  Sun Mar 24 14:50:02 2019
(r345471)
@@ -161,6 +161,37 @@ DUMMY(pwritev2);
 DUMMY(pkey_mprotect);
 DUMMY(pkey_alloc);
 DUMMY(pkey_free);
+/* Linux 4.11: */
+DUMMY(statx);
+DUMMY(arch_prctl);
+/* Linux 4.18: */
+DUMMY(io_pgetevents);
+DUMMY(rseq);
+/* Linux 5.0: */
+DUMMY(clock_gettime64);
+DUMMY(clock_settime64);
+DUMMY(clock_adjtime64);
+DUMMY(clock_getres_time64);
+DUMMY(clock_nanosleep_time64);
+DUMMY(timer_gettime64);
+DUMMY(timer_settime64);
+DUMMY(timerfd_gettime64);
+DUMMY(timerfd_settime64);
+DUMMY(utimensat_time64);
+DUMMY(pselect6_time64);
+DUMMY(ppoll_time64);
+DUMMY(io_pgetevents_time64);
+DUMMY(recvmmsg_time64);
+DUMMY(mq_timedsend_time64);
+DUMMY(mq_timedreceive_time64);
+DUMMY(semtimedop_time64);
+DUMMY(rt_sigtimedwait_time64);
+DUMMY(futex_time64);
+DUMMY(sched_rr_get_interval_time64);
+DUMMY(pidfd_send_signal);
+DUMMY(io_uring_setup);
+DUMMY(io_uring_enter);
+DUMMY(io_uring_register);
 
 #define DUMMY_XATTR(s) \
 int\

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Sun Mar 24 14:46:07 2019
(r345470)
+++ head/sys/amd64/linux32/syscalls.master  Sun Mar 24 14:50:02 2019
(r345471)
@@ -686,7 +686,64 @@
 381AUE_NULLSTD { int linux_pkey_alloc(l_ulong flags,   
\
l_ulong init_val); }
 382AUE_NULLSTD { int linux_pkey_free(l_int pkey); }
+; Linux 4.11:
+383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
+   const char *pathname, l_uint flags, 
\
+   l_uint mask, voi

svn commit: r346603 - in head/sys: amd64/linux32 i386/linux

2019-04-23 Thread Dmitry Chagin
Author: dchagin
Date: Tue Apr 23 18:10:46 2019
New Revision: 346603
URL: https://svnweb.freebsd.org/changeset/base/346603

Log:
  Since r339624 HEAD does not need for backslashes in syscalls.master,
  however to make a merge r345471 to the stable add backslashes
  to the syscalls.master.
  
  MFC after:3 days

Modified:
  head/sys/amd64/linux32/syscalls.master
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/amd64/linux32/syscalls.master  Tue Apr 23 18:10:46 2019
(r346603)
@@ -690,7 +690,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_NULLSTD { int linux_arch_prctl(l_int option,
+384AUE_NULLSTD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }

Modified: head/sys/i386/linux/syscalls.master
==
--- head/sys/i386/linux/syscalls.master Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/i386/linux/syscalls.master Tue Apr 23 18:10:46 2019
(r346603)
@@ -698,7 +698,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
+384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r346273 - in head/sys: compat/freebsd32 kern

2019-04-24 Thread Dmitry Chagin
вт, 16 апр. 2019 г. в 16:26, Ed Maste :

> Author: emaste
> Date: Tue Apr 16 13:26:31 2019
> New Revision: 346273
> URL: https://svnweb.freebsd.org/changeset/base/346273
>
> Log:
>   correct readlinkat(2) return type
>
>
Hi, Ed
make sysent?



>   r176215 corrected readlink(2)'s return type and the type of the last
>   argument.  readlink(2) was introduced in r177788 after being developed
>   as part of Google Summer of Code 2007; it appears to have inherited the
>   wrong return type.
>
>   Man pages and header files were already ssize_t; update syscalls.master
>   to match.
>
>   PR:   197915
>   Submitted by: Henning Petersen 
>   MFC after:2 weeks
>
> Modified:
>   head/sys/compat/freebsd32/syscalls.master
>   head/sys/kern/syscalls.master
>
> Modified: head/sys/compat/freebsd32/syscalls.master
>
> ==
> --- head/sys/compat/freebsd32/syscalls.master   Tue Apr 16 12:40:49 2019
>   (r346272)
> +++ head/sys/compat/freebsd32/syscalls.master   Tue Apr 16 13:26:31 2019
>   (r346273)
> @@ -963,7 +963,7 @@
> uint32_t dev); }
>  499AUE_OPENAT_RWTC NOPROTO { int openat(int fd, const char *path, \
> int flag, mode_t mode); }
> -500AUE_READLINKAT  NOPROTO { int readlinkat(int fd, const char *path,
> \
> +500AUE_READLINKAT  NOPROTO { ssize_t readlinkat(int fd, const char
> *path, \
> char *buf, size_t bufsize); }
>  501AUE_RENAMEATNOPROTO { int renameat(int oldfd, const char *old,
> \
> int newfd, const char *new); }
>
> Modified: head/sys/kern/syscalls.master
>
> ==
> --- head/sys/kern/syscalls.master   Tue Apr 16 12:40:49 2019
> (r346272)
> +++ head/sys/kern/syscalls.master   Tue Apr 16 13:26:31 2019
> (r346273)
> @@ -2716,7 +2716,7 @@
> );
> }
>  500AUE_READLINKAT  STD {
> -   int readlinkat(
> +   ssize_t readlinkat(
> int fd,
> _In_z_ const char *path,
> _Out_writes_bytes_(bufsize) char *buf,
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r346965 - head/sys/compat/linux

2019-04-30 Thread Dmitry Chagin
Author: dchagin
Date: Tue Apr 30 17:18:05 2019
New Revision: 346965
URL: https://svnweb.freebsd.org/changeset/base/346965

Log:
  Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator.
  It was first introduced in r163734 and missied by me in r283383.
  
  MFC after:1 week

Modified:
  head/sys/compat/linux/linux_emul.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_emul.c
==
--- head/sys/compat/linux/linux_emul.c  Tue Apr 30 16:52:50 2019
(r346964)
+++ head/sys/compat/linux/linux_emul.c  Tue Apr 30 17:18:05 2019
(r346965)
@@ -127,7 +127,6 @@ linux_proc_init(struct thread *td, struct thread *newt
 
em->em_tid = p->p_pid;
em->flags = 0;
-   em->pdeath_signal = 0;
em->robust_futexes = NULL;
em->child_clear_tid = NULL;
em->child_set_tid = NULL;

Modified: head/sys/compat/linux/linux_emul.h
==
--- head/sys/compat/linux/linux_emul.h  Tue Apr 30 16:52:50 2019
(r346964)
+++ head/sys/compat/linux/linux_emul.h  Tue Apr 30 17:18:05 2019
(r346965)
@@ -40,7 +40,6 @@ struct linux_emuldata {
int*child_set_tid;  /* in clone(): Child's TID to set on clone */
int*child_clear_tid;/* in clone(): Child's TID to clear on exit */
 
-   int pdeath_signal;  /* parent death signal */
int flags;  /* thread emuldata flags */
int em_tid; /* thread id */
 

Modified: head/sys/compat/linux/linux_misc.c
==
--- head/sys/compat/linux/linux_misc.c  Tue Apr 30 16:52:50 2019
(r346964)
+++ head/sys/compat/linux/linux_misc.c  Tue Apr 30 17:18:05 2019
(r346965)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1993,7 +1994,6 @@ linux_prctl(struct thread *td, struct linux_prctl_args
int error = 0, max_size;
struct proc *p = td->td_proc;
char comm[LINUX_MAX_COMM_LEN];
-   struct linux_emuldata *em;
int pdeath_signal;
 
 #ifdef DEBUG
@@ -2007,17 +2007,18 @@ linux_prctl(struct thread *td, struct linux_prctl_args
case LINUX_PR_SET_PDEATHSIG:
if (!LINUX_SIG_VALID(args->arg2))
return (EINVAL);
-   em = em_find(td);
-   KASSERT(em != NULL, ("prctl: emuldata not found.\n"));
-   em->pdeath_signal = args->arg2;
-   break;
+   pdeath_signal = linux_to_bsd_signal(args->arg2);
+   return (kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_CTL,
+   &pdeath_signal));
case LINUX_PR_GET_PDEATHSIG:
-   em = em_find(td);
-   KASSERT(em != NULL, ("prctl: emuldata not found.\n"));
-   pdeath_signal = em->pdeath_signal;
-   error = copyout(&pdeath_signal,
+   error = kern_procctl(td, P_PID, 0, PROC_PDEATHSIG_STATUS,
+   &pdeath_signal);
+   if (error != 0)
+   return (error);
+   pdeath_signal = bsd_to_linux_signal(pdeath_signal);
+   return (copyout(&pdeath_signal,
(void *)(register_t)args->arg2,
-   sizeof(pdeath_signal));
+   sizeof(pdeath_signal)));
break;
case LINUX_PR_GET_KEEPCAPS:
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r347016 - head/sys/compat/linsysfs

2019-05-02 Thread Dmitry Chagin
Author: dchagin
Date: Thu May  2 09:00:36 2019
New Revision: 347016
URL: https://svnweb.freebsd.org/changeset/base/347016

Log:
  Remove unneeded includes.
  
  MFC after:2 week

Modified:
  head/sys/compat/linsysfs/linsysfs.c

Modified: head/sys/compat/linsysfs/linsysfs.c
==
--- head/sys/compat/linsysfs/linsysfs.c Thu May  2 08:17:29 2019
(r347015)
+++ head/sys/compat/linsysfs/linsysfs.c Thu May  2 09:00:36 2019
(r347016)
@@ -31,22 +31,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -55,17 +45,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-#include 
-#include 
 #include 
 #include 
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


  1   2   3   4   >