From owner-svn-src-all@FreeBSD.ORG Mon Nov 17 17:13:50 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 643A410656AE; Mon, 17 Nov 2008 17:13:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id E329E8FC20; Mon, 17 Nov 2008 17:13:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id mAHHDMIo032310; Mon, 17 Nov 2008 12:13:41 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Doug Ambrisko Date: Mon, 17 Nov 2008 12:11:41 -0500 User-Agent: KMail/1.9.7 References: <200811170237.mAH2bjY5088186@ambrisko.com> In-Reply-To: <200811170237.mAH2bjY5088186@ambrisko.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811171211.42740.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Mon, 17 Nov 2008 12:13:42 -0500 (EST) X-Virus-Scanned: ClamAV 0.93.1/8642/Sun Nov 16 23:01:08 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Kostik Belousov , Doug Ambrisko , svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r184974 - head/sys/dev/mfi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 17 Nov 2008 17:13:50 -0000 On Sunday 16 November 2008 09:37:45 pm Doug Ambrisko wrote: > Kostik Belousov writes: > | On Fri, Nov 14, 2008 at 09:05:45PM +0000, Doug Ambrisko wrote: > | > Author: ambrisko > | > Date: Fri Nov 14 21:05:45 2008 > | > New Revision: 184974 > | > URL: http://svn.freebsd.org/changeset/base/184974 > | > > | > Log: > | > When running a 32bit app. on amd64, ensure the bits above 32bit > | > are zero for the copyout. Confirmed by LSI. > | > > | > Modified: > | > head/sys/dev/mfi/mfi.c > | > > | > Modified: head/sys/dev/mfi/mfi.c > | > ============================================================================== > | > --- head/sys/dev/mfi/mfi.c Fri Nov 14 18:09:19 2008 (r184973) > | > +++ head/sys/dev/mfi/mfi.c Fri Nov 14 21:05:45 2008 (r184974) > | > @@ -2130,6 +2130,14 @@ mfi_ioctl(struct cdev *dev, u_long cmd, > | > ->mfi_frame.raw[ioc->mfi_sense_off], > | > &sense_ptr.sense_ptr_data[0], > | > sizeof(sense_ptr.sense_ptr_data)); > | > +#ifdef __amd64__ > | > + if (cmd != MFI_CMD) { > | > + /* > | > + * not 64bit native so zero out any address > | > + * over 32bit */ > | > + sense_ptr.high = 0; > | > + } > | > +#endif > | > error = copyout(cm->cm_sense, sense_ptr.user_space, > | > ioc->mfi_sense_len); > | > if (error != 0) { > | > @@ -2353,6 +2361,13 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ > | > ->lioc_frame.raw[l_ioc.lioc_sense_off], > | > &sense_ptr.sense_ptr_data[0], > | > sizeof(sense_ptr.sense_ptr_data)); > | > +#ifdef __amd64__ > | > + /* > | > + * only 32bit Linux support so zero out any > | > + * address over 32bit > | > + */ > | > + sense_ptr.high = 0; > | > +#endif > | > error = copyout(cm->cm_sense, sense_ptr.user_space, > | > l_ioc.lioc_sense_len); > | > if (error != 0) { > | > | Would it make sense to perform this cut slightly more generically, by > | checking whether the current process is 32bit ? > | > | We still have not grew the easy to check flag or attribute of the image, > | but usual practice is to compare p_sysent with corresponding sysvec, > | like > | if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) > | or > | if (td->td_proc->p_sysent == &elf_linux_sysvec) > > So far we do it based on the ioctl since the 32bit or 64bit ioctl > value is different. I put in that comment for Linux since there > is talk/work for Linux amd64 emulation. For 64bit Linux ioctl > support we need a 64bit structure defined. When the ioctl can't > be figured out then I've used the p_sysent. Eventually, something > that is more generic then the #ifdef __amd64__ should be done > in all the drivers that do this emulation. I prefer depending on things like ioctl values and the 32-bit sysctl flag when possible. If we do have to directly check for the ABI, I'd much rather have a flags field in sysent rather than trying to compare against global symbols, as you can't compare against a global symbol unless it is present in the kernel. Something like: if (td->td_proc->p_sysent->sy_flags & SY_32) or some such. I've wanted to have a COMPAT_FREEBSD32 that gets auto-enabled when you turn on COMPAT_IA32 on amd64 and ia64. It would also potentially be enabled by a COMPAT_SPARC8 or some such on sparc64 if we ever had that. -- John Baldwin