From owner-svn-src-all@FreeBSD.ORG Mon Nov 17 17:58:45 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 3A0E91065670; Mon, 17 Nov 2008 17:58:45 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from contrabass.post.ru (contrabass.post.ru [85.21.78.5]) by mx1.freebsd.org (Postfix) with ESMTP id D79138FC1B; Mon, 17 Nov 2008 17:58:44 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 92820236AD; Mon, 17 Nov 2008 20:39:32 +0300 (MSK) X-Virus-Scanned: by cgpav Uf39PSi9pFi9oFi9 Received: from dchagin.dialup.corbina.ru ([78.107.232.239] verified) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPS id 1463799616; Mon, 17 Nov 2008 20:39:32 +0300 Received: from dchagin.dialup.corbina.ru (localhost.chd.net [127.0.0.1]) by dchagin.dialup.corbina.ru (8.14.3/8.14.3) with ESMTP id mAHHdWZJ093187; Mon, 17 Nov 2008 20:39:32 +0300 (MSK) (envelope-from root@dchagin.dialup.corbina.ru) Received: (from root@localhost) by dchagin.dialup.corbina.ru (8.14.3/8.14.3/Submit) id mAHHdTfH093186; Mon, 17 Nov 2008 20:39:29 +0300 (MSK) (envelope-from root) Date: Mon, 17 Nov 2008 20:39:29 +0300 From: Chagin Dmitry To: Scott Long Message-ID: <20081117173929.GA93046@dchagin.dialup.corbina.ru> References: <200811170237.mAH2bjY5088186@ambrisko.com> <4920EA36.5020909@samsco.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4920EA36.5020909@samsco.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Doug Ambrisko , src-committers@freebsd.org, Doug Ambrisko , svn-src-all@freebsd.org, svn-src-head@freebsd.org, Kostik Belousov 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:58:45 -0000 On Sun, Nov 16, 2008 at 08:51:18PM -0700, Scott Long wrote: > 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. > > > > Doug A. > > Something that identifies the ABI needs to be put into the proc > structure. This isn't the only place where such information is needed. > Comparing against the sysent table symbol doesn't work very well because > it requires all sysent tables be loaded, which isn't always true for the > linux ABI. > > Scott > 100% agree, I suggest to make somehow so: diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index e233700..0ea4cd8 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -999,6 +999,7 @@ linux32_fixlimit(struct rlimit *rl, int which) } struct sysentvec elf_linux_sysvec = { + .sv_wordsize = __ELF_WORD_SIZE, .sv_size = LINUX_SYS_MAXSYSCALL, .sv_table = linux_sysent, .sv_mask = 0, diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 0ec07a7..757b929 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -68,6 +68,7 @@ struct trapframe; struct vnode; struct sysentvec { + int sv_wordsize; /* arch wordsize */ int sv_size; /* number of entries */ struct sysent *sv_table; /* pointer to sysent */ u_int sv_mask; /* optional mask to index */ and use it like: if (td->td_proc->p_sysent->sv_wordsize == 32) thnx! -- Have fun! chd