Date: Sun, 24 Mar 2019 14:44:36 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345469 - in head/sys: amd64/linux32 compat/linux i386/linux Message-ID: <201903241444.x2OEiaGt083996@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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.c Sun Mar 24 14:02:57 2019 (r345468) +++ head/sys/amd64/linux32/linux32_machdep.c Sun 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 @@ 115 AUE_SWAPOFF STD { int linux_swapoff(void); } 116 AUE_NULL STD { int linux_sysinfo(struct l_sysinfo *info); } 117 AUE_NULL STD { int linux_ipc(l_uint what, l_int arg1, \ - l_int arg2, l_int arg3, void *ptr, \ - l_long arg5); } + l_int arg2, l_uint arg3, l_uintptr_t ptr, \ + l_uint arg5); } 118 AUE_FSYNC NOPROTO { int fsync(int fd); } 119 AUE_SIGRETURN STD { int linux_sigreturn( \ struct l_sigframe *sfp); } Modified: head/sys/compat/linux/linux_ipc.c ============================================================================== --- head/sys/compat/linux/linux_ipc.c Sun Mar 24 14:02:57 2019 (r345468) +++ head/sys/compat/linux/linux_ipc.c Sun Mar 24 14:44:35 2019 (r345469) @@ -785,23 +785,11 @@ linux_shmat(struct thread *td, struct linux_shmat_args void *shmaddr; int shmflg; } */ bsd_args; - int error; -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) - l_uintptr_t addr; -#endif bsd_args.shmid = args->shmid; bsd_args.shmaddr = PTRIN(args->shmaddr); bsd_args.shmflg = args->shmflg; - if ((error = sys_shmat(td, &bsd_args))) - return (error); -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) - addr = td->td_retval[0]; - if ((error = copyout(&addr, PTRIN(args->raddr), sizeof(addr)))) - return (error); - td->td_retval[0] = 0; -#endif - return (0); + return (sys_shmat(td, &bsd_args)); } int Modified: head/sys/compat/linux/linux_ipc.h ============================================================================== --- head/sys/compat/linux/linux_ipc.h Sun Mar 24 14:02:57 2019 (r345468) +++ head/sys/compat/linux/linux_ipc.h Sun Mar 24 14:44:35 2019 (r345469) @@ -141,7 +141,6 @@ struct linux_shmat_args l_int shmid; char *shmaddr; l_int shmflg; - l_ulong *raddr; }; struct linux_shmctl_args Modified: head/sys/i386/linux/linux_machdep.c ============================================================================== --- head/sys/i386/linux/linux_machdep.c Sun Mar 24 14:02:57 2019 (r345468) +++ head/sys/i386/linux/linux_machdep.c Sun Mar 24 14:44:35 2019 (r345469) @@ -133,7 +133,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)); } @@ -152,7 +152,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)); @@ -161,7 +161,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)); @@ -176,15 +176,15 @@ linux_ipc(struct thread *td, struct linux_ipc_args *ar struct l_ipc_kludge tmp; int error; - if (args->ptr == NULL) + 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 = tmp.msgp; + 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)); @@ -201,22 +201,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 = (l_ulong *)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: { @@ -232,7 +239,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/i386/linux/syscalls.master ============================================================================== --- head/sys/i386/linux/syscalls.master Sun Mar 24 14:02:57 2019 (r345468) +++ head/sys/i386/linux/syscalls.master Sun Mar 24 14:44:35 2019 (r345469) @@ -214,8 +214,8 @@ 115 AUE_SWAPOFF STD { int linux_swapoff(void); } 116 AUE_NULL STD { int linux_sysinfo(struct l_sysinfo *info); } 117 AUE_NULL STD { int linux_ipc(l_uint what, l_int arg1, \ - l_int arg2, l_int arg3, void *ptr, \ - l_long arg5); } + l_int arg2, l_uint arg3, l_uintptr_t ptr, \ + l_uint arg5); } 118 AUE_FSYNC NOPROTO { int fsync(int fd); } 119 AUE_SIGRETURN STD { int linux_sigreturn( \ struct l_sigframe *sfp); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903241444.x2OEiaGt083996>