From owner-p4-projects@FreeBSD.ORG Mon Nov 13 21:52:41 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E8E7416A412; Mon, 13 Nov 2006 21:52:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 728AA16A4EF; Mon, 13 Nov 2006 21:52:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id D966443DAE; Mon, 13 Nov 2006 21:52:04 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id kADLpadr016132; Mon, 13 Nov 2006 16:52:01 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Jung-uk Kim Date: Mon, 13 Nov 2006 16:06:21 -0500 User-Agent: KMail/1.9.1 References: <200611102300.kAAN0Cn1045678@repoman.freebsd.org> In-Reply-To: <200611102300.kAAN0Cn1045678@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611131606.21477.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 13 Nov 2006 16:52:01 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2191/Mon Nov 13 13:37:53 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: PERFORCE change 109706 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2006 21:52:41 -0000 On Friday 10 November 2006 18:00, Jung-uk Kim wrote: > http://perforce.freebsd.org/chv.cgi?CH=109706 > > Change 109706 by jkim@jkim_hammer on 2006/11/10 22:59:53 > > Add (ugly) 32-bit msgsnd/msgrcv support for amd64. > msgp points to msghdr and msghdr contains msg_type, which is long. > When we copyin/copyout, we copy the correct msg_type and advance msgp > by msg_type size. > > This fixes LTP test cases msgget01, msgrcv01, msgrcv02, msgrcv04, and > msgsnd03. > > Note: There is only one test case blocked in msgwait state after this > change, which seems to be arch-independent issue. > > Affected files ... > > .. //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#3 edit > .. //depot/projects/linuxolator/src/sys/kern/sysv_msg.c#5 edit Why not add kern_msgfoo() functions and do the copyout/copyin in other places instead? > Differences ... > > ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#3 (text+ko) ==== > > @@ -83,6 +83,10 @@ > l_ulong swap_successes; > }; > > +/* XXX This should not be here. */ > +int do_msgsnd(struct thread *, struct msgsnd_args *, size_t); > +int do_msgrcv(struct thread *, struct msgrcv_args *, size_t); > + > static void > bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp) > { > @@ -586,7 +590,8 @@ > bsd_args.msgp = PTRIN(args->msgp); > bsd_args.msgsz = args->msgsz; > bsd_args.msgflg = args->msgflg; > - return msgsnd(td, &bsd_args); > + > + return (do_msgsnd(td, &bsd_args, sizeof(l_long))); > } > > int > @@ -605,7 +610,8 @@ > bsd_args.msgsz = args->msgsz; > bsd_args.msgtyp = args->msgtyp; > bsd_args.msgflg = args->msgflg; > - return msgrcv(td, &bsd_args); > + > + return (do_msgrcv(td, &bsd_args, sizeof(l_long))); > } > > int > > ==== //depot/projects/linuxolator/src/sys/kern/sysv_msg.c#5 (text+ko) ==== > > @@ -662,6 +662,11 @@ > return (error); > } > > +union msgtyp { > + long mtype; > + int32_t mtype32; > +}; > + > #ifndef _SYS_SYSPROTO_H_ > struct msgsnd_args { > int msqid; > @@ -671,14 +676,16 @@ > }; > #endif > > -/* > - * MPSAFE > - */ > +/* XXX This should not be here. */ > +int do_msgsnd(struct thread *, struct msgsnd_args *, size_t); > + > int > -msgsnd(td, uap) > +do_msgsnd(td, uap, mtsz) > struct thread *td; > register struct msgsnd_args *uap; > + size_t mtsz; > { > + union msgtyp msgt; > int msqid = uap->msqid; > const void *user_msgp = uap->msgp; > size_t msgsz = uap->msgsz; > @@ -693,6 +700,9 @@ > if (!jail_sysvipc_allowed && jailed(td->td_ucred)) > return (ENOSYS); > > + if (mtsz != sizeof(msgt.mtype) && mtsz != sizeof(msgt.mtype32)) > + return (EINVAL); > + > mtx_lock(&msq_mtx); > msqid = IPCID_TO_IX(msqid); > > @@ -875,8 +885,7 @@ > */ > > mtx_unlock(&msq_mtx); > - if ((error = copyin(user_msgp, &msghdr->msg_type, > - sizeof(msghdr->msg_type))) != 0) { > + if ((error = copyin(user_msgp, &msgt, mtsz)) != 0) { > mtx_lock(&msq_mtx); > DPRINTF(("error %d copying the message type\n", error)); > msg_freehdr(msghdr); > @@ -884,8 +893,9 @@ > wakeup(msqkptr); > goto done2; > } > + msghdr->msg_type = (mtsz == sizeof(long)) ? msgt.mtype : msgt.mtype32; > mtx_lock(&msq_mtx); > - user_msgp = (const char *)user_msgp + sizeof(msghdr->msg_type); > + user_msgp = (const char *)user_msgp + mtsz; > > /* > * Validate the message type > @@ -995,6 +1005,17 @@ > return (error); > } > > +/* > + * MPSAFE > + */ > +int > +msgsnd(td, uap) > + struct thread *td; > + register struct msgsnd_args *uap; > +{ > + return (do_msgsnd(td, uap, sizeof(long))); > +} > + > #ifndef _SYS_SYSPROTO_H_ > struct msgrcv_args { > int msqid; > @@ -1005,14 +1026,16 @@ > }; > #endif > > -/* > - * MPSAFE > - */ > +/* XXX This should not be here. */ > +int do_msgrcv(struct thread *, struct msgrcv_args *, size_t); > + > int > -msgrcv(td, uap) > +do_msgrcv(td, uap, mtsz) > struct thread *td; > register struct msgrcv_args *uap; > + size_t mtsz; > { > + union msgtyp msgt; > int msqid = uap->msqid; > void *user_msgp = uap->msgp; > size_t msgsz = uap->msgsz; > @@ -1030,6 +1053,9 @@ > if (!jail_sysvipc_allowed && jailed(td->td_ucred)) > return (ENOSYS); > > + if (mtsz != sizeof(msgt.mtype) && mtsz != sizeof(msgt.mtype32)) > + return (EINVAL); > + > msqid = IPCID_TO_IX(msqid); > > if (msqid < 0 || msqid >= msginfo.msgmni) { > @@ -1226,8 +1252,11 @@ > */ > > mtx_unlock(&msq_mtx); > - error = copyout(&(msghdr->msg_type), user_msgp, > - sizeof(msghdr->msg_type)); > + if (mtsz == sizeof(long)) > + msgt.mtype = msghdr->msg_type; > + else > + msgt.mtype32 = msghdr->msg_type; > + error = copyout(&msgt, user_msgp, mtsz); > mtx_lock(&msq_mtx); > if (error != 0) { > DPRINTF(("error (%d) copying out message type\n", error)); > @@ -1235,7 +1264,7 @@ > wakeup(msqkptr); > goto done2; > } > - user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type); > + user_msgp = (char *)user_msgp + mtsz; > > /* > * Return the segments to the user > @@ -1280,6 +1309,17 @@ > return (error); > } > > +/* > + * MPSAFE > + */ > +int > +msgrcv(td, uap) > + struct thread *td; > + register struct msgrcv_args *uap; > +{ > + return (do_msgrcv(td, uap, sizeof(long))); > +} > + > static int > sysctl_msqids(SYSCTL_HANDLER_ARGS) > { > -- John Baldwin