From owner-svn-src-stable@freebsd.org Sun Mar 19 15:32:13 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A897FD13328; Sun, 19 Mar 2017 15:32:13 +0000 (UTC) (envelope-from trasz@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 mx1.freebsd.org (Postfix) with ESMTPS id 77A95EE7; Sun, 19 Mar 2017 15:32:13 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2JFWCO9093004; Sun, 19 Mar 2017 15:32:12 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JFWCpH093003; Sun, 19 Mar 2017 15:32:12 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201703191532.v2JFWCpH093003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 19 Mar 2017 15:32:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315556 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 15:32:13 -0000 Author: trasz Date: Sun Mar 19 15:32:12 2017 New Revision: 315556 URL: https://svnweb.freebsd.org/changeset/base/315556 Log: MFC r313947: There are some Linux binaries that expect the system to obey the "addr" parameter to mmap(2), even if MAP_FIXED is not explicitly specified. Android ART is one example. Implement bug compatibility for this case in linuxulator. Sponsored by: DARPA, AFRL Modified: stable/11/sys/compat/linux/linux_mmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_mmap.c ============================================================================== --- stable/11/sys/compat/linux/linux_mmap.c Sun Mar 19 15:15:34 2017 (r315555) +++ stable/11/sys/compat/linux/linux_mmap.c Sun Mar 19 15:32:12 2017 (r315556) @@ -203,8 +203,23 @@ linux_mmap_common(struct thread *td, uin } } - error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos); + /* + * FreeBSD is free to ignore the address hint if MAP_FIXED wasn't + * passed. However, some Linux applications, like the ART runtime, + * depend on the hint. If the MAP_FIXED wasn't passed, but the + * address is not zero, try with MAP_FIXED and MAP_EXCL first, + * and fall back to the normal behaviour if that fails. + */ + if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && + (bsd_flags & MAP_EXCL) == 0) { + error = kern_mmap(td, addr, len, prot, + bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos); + if (error == 0) + goto out; + } + error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos); +out: LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); return (error);