From owner-svn-src-all@freebsd.org Sun Apr 28 14:34:35 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FCE4157FFAA; Sun, 28 Apr 2019 14:34:35 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A48E395FE8; Sun, 28 Apr 2019 14:34:34 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6911DC0B6; Sun, 28 Apr 2019 14:34:34 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3SEYYOF055532; Sun, 28 Apr 2019 14:34:34 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3SEYWa0055517; Sun, 28 Apr 2019 14:34:32 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201904281434.x3SEYWa0055517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 28 Apr 2019 14:34:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r346842 - in stable/12/sys: amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-12 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in stable/12/sys: amd64/linux32 compat/linux i386/linux X-SVN-Commit-Revision: 346842 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A48E395FE8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2019 14:34:35 -0000 Author: dchagin Date: Sun Apr 28 14:34:31 2019 New Revision: 346842 URL: https://svnweb.freebsd.org/changeset/base/346842 Log: MFC r345469, r345470: 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. Modified: stable/12/sys/amd64/linux32/linux32_machdep.c stable/12/sys/amd64/linux32/linux32_proto.h stable/12/sys/amd64/linux32/linux32_systrace_args.c stable/12/sys/amd64/linux32/syscalls.master stable/12/sys/compat/linux/linux_ipc.c stable/12/sys/compat/linux/linux_ipc.h stable/12/sys/i386/linux/linux_machdep.c stable/12/sys/i386/linux/linux_proto.h stable/12/sys/i386/linux/linux_systrace_args.c stable/12/sys/i386/linux/syscalls.master Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_machdep.c Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/amd64/linux32/linux32_machdep.c Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/amd64/linux32/linux32_proto.h ============================================================================== --- stable/12/sys/amd64/linux32/linux32_proto.h Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/amd64/linux32/linux32_proto.h Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- stable/12/sys/amd64/linux32/linux32_systrace_args.c Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/amd64/linux32/linux32_systrace_args.c Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/12/sys/amd64/linux32/syscalls.master Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/amd64/linux32/syscalls.master Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/compat/linux/linux_ipc.c ============================================================================== --- stable/12/sys/compat/linux/linux_ipc.c Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/compat/linux/linux_ipc.c Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/compat/linux/linux_ipc.h ============================================================================== --- stable/12/sys/compat/linux/linux_ipc.h Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/compat/linux/linux_ipc.h Sun Apr 28 14:34:31 2019 (r346842) @@ -141,7 +141,6 @@ struct linux_shmat_args l_int shmid; char *shmaddr; l_int shmflg; - l_ulong *raddr; }; struct linux_shmctl_args Modified: stable/12/sys/i386/linux/linux_machdep.c ============================================================================== --- stable/12/sys/i386/linux/linux_machdep.c Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/i386/linux/linux_machdep.c Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/i386/linux/linux_proto.h ============================================================================== --- stable/12/sys/i386/linux/linux_proto.h Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/i386/linux/linux_proto.h Sun Apr 28 14:34:31 2019 (r346842) @@ -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: stable/12/sys/i386/linux/linux_systrace_args.c ============================================================================== --- stable/12/sys/i386/linux/linux_systrace_args.c Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/i386/linux/linux_systrace_args.c Sun Apr 28 14:34:31 2019 (r346842) @@ -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 */ + iarg[3] = p->arg3; /* l_uint */ + iarg[4] = p->ptr; /* l_uintptr_t */ + iarg[5] = p->arg5; /* l_uint */ *n_args = 6; break; } @@ -4012,13 +4012,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: stable/12/sys/i386/linux/syscalls.master ============================================================================== --- stable/12/sys/i386/linux/syscalls.master Sun Apr 28 14:30:25 2019 (r346841) +++ stable/12/sys/i386/linux/syscalls.master Sun Apr 28 14:34:31 2019 (r346842) @@ -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); }