From owner-freebsd-emulation@FreeBSD.ORG Mon Feb 11 17:08:03 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B42816A419 for ; Mon, 11 Feb 2008 17:08:03 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (vlk.vlakno.cz [62.168.28.247]) by mx1.freebsd.org (Postfix) with ESMTP id 21AC813C458 for ; Mon, 11 Feb 2008 17:08:02 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 8EADC67404E; Mon, 11 Feb 2008 18:08:00 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (vlk.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lx40WuH-XtQX; Mon, 11 Feb 2008 18:07:44 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 3080A673FD2; Mon, 11 Feb 2008 18:07:44 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.13.8/8.13.8/Submit) id m1BH7hk5005817; Mon, 11 Feb 2008 18:07:43 +0100 (CET) (envelope-from rdivacky) Date: Mon, 11 Feb 2008 18:07:43 +0100 From: Roman Divacky To: Andriy Gapon Message-ID: <20080211170743.GA4866@freebsd.org> References: <47B074D5.1020602@icyb.net.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47B074D5.1020602@icyb.net.ua> User-Agent: Mutt/1.4.2.3i Cc: freebsd-emulation@freebsd.org Subject: Re: bug in recent linux mmap changes ? X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Feb 2008 17:08:03 -0000 On Mon, Feb 11, 2008 at 06:16:21PM +0200, Andriy Gapon wrote: > After upgrading two machines, one to 6.3 and the other to 7.0-RC1, I can > not run linux heroes3 anymore (statically linked, threaded application > originally written for kernel 2.2.X). On 6.3 the process "hangs", on > 7.0-RC1 one of the threads/processes crashes with SIGSEGV. > Everything was OK as recently as 6.2. > > I can provide more diagnostics later, if needed, but in both cases I see > that the last system call in a troublesome thread/process is linux_mmap(). > I did a brief search through recent linux_mmap changes and I think that > there is a bug in the following commit (I am writing this hastiliy, so I > haven't yet tested a possible fix): > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/linux/linux_machdep.c.diff?r1=1.48.2.4;r2=1.48.2.5;f=h > > Namely, old code: > ==================================================== > /* This gives us TOS */ > bsd_args.addr = linux_args->addr + linux_args->len; > > if (bsd_args.addr > p->p_vmspace->vm_maxsaddr) { > [block folded] > } > > /* This gives us our maximum stack size */ > if (linux_args->len > STACK_SIZE - GUARD_SIZE) > bsd_args.len = linux_args->len; > else > bsd_args.len = STACK_SIZE - GUARD_SIZE; > > /* > [comment folded] > */ > bsd_args.addr -= bsd_args.len; > ==================================================== > > New code: > ==================================================== > if ((caddr_t)PTRIN(linux_args->addr) + linux_args->len > > p->p_vmspace->vm_maxsaddr) { > [block folded] > } > > /* This gives us our maximum stack size */ > if (linux_args->len > STACK_SIZE - GUARD_SIZE) > bsd_args.len = linux_args->len; > else > bsd_args.len = STACK_SIZE - GUARD_SIZE; > > /* > [comment foled] > */ > bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) - > bsd_args.len; > ==================================================== > > Please now note that the new code doesn't have initial bsd_args.addr > assignment line. So, in summary, old code does the following: > bsd_args.addr = linux_args->addr + linux_args->len; > ... > bsd_args.addr -= bsd_args.len; > > While new code does: > bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) - bsd_args.len; I think you are right.... does changing bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) - bsd_args.len; to bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) + linux_args->len - bsd_args.len; fix that? or possibly just bsd_args.addr = (caddr_t)PTRIN(linux_args->addr); can someone test this please? asap... it would be nice to squeeze this into 7.0R roman