From owner-freebsd-stable@FreeBSD.ORG Wed Jun 15 14:46:43 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C88E6106566C for ; Wed, 15 Jun 2011 14:46:43 +0000 (UTC) (envelope-from nickolasbug@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8463B8FC1D for ; Wed, 15 Jun 2011 14:46:43 +0000 (UTC) Received: by qwc9 with SMTP id 9so335789qwc.13 for ; Wed, 15 Jun 2011 07:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=h086MxhJZF/lPC7nGCakoS4i5h+1VlBp2qBhdMF7X+Q=; b=j8i1xvS6DJOT9R2D6nROB3cScZCqyifg/LxiH5X+pbvp+NVL7GO/AJEDGFJuYo2X3P QikywaRC9UzkS/ERYfqm0QUstg1i6WrucZpyKUN/T8HiVWCnJtcwNFGYnjZBMvLRhRtS WaH3RNXT6PNQPSB0ABNrEDgiL1DB1Lda4tDMQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=YAQcSIMyTO6r1JbXhTxORqW3o1Y1EUt/z4fo/qFCJs4wdsxbR7xdnltTij6LvEJlt0 A7b3ez6G9PVAiaQWPw0Uc6mHgf9sIyeKne8WHdLH7/2wzV+PZtS/aP2D8Pq6A265zC87 x/vvIa/XWmqJr4mL1L0rXm4QxuVZRqH1BDDnw= MIME-Version: 1.0 Received: by 10.229.25.211 with SMTP id a19mr519926qcc.81.1308149202526; Wed, 15 Jun 2011 07:46:42 -0700 (PDT) Received: by 10.229.82.65 with HTTP; Wed, 15 Jun 2011 07:46:42 -0700 (PDT) In-Reply-To: <20110615141240.GA61227@icarus.home.lan> References: <20110615135704.GQ23206@uriah.heep.sax.de> <20110615141240.GA61227@icarus.home.lan> Date: Wed, 15 Jun 2011 17:46:42 +0300 Message-ID: From: nickolasbug@gmail.com To: Jeremy Chadwick Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-stable@freebsd.org, Joerg Wunsch Subject: Re: doscmd under 8-stable, anyone? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2011 14:46:44 -0000 2011/6/15 Jeremy Chadwick : > On Wed, Jun 15, 2011 at 03:57:05PM +0200, Joerg Wunsch wrote: >> When trying to use doscmd on 8-stable, all I get is: >> >> Error mapping HMA, HMA disabled: : Invalid argument >> Segmentation fault (core dumped) >> >> The segfault happens at the end of mem_init(), when the allocated DOS >> memory (which is located at virtual address 0) is attempted to be >> written to. =A0Apparently, the mmap() failure that causes the "HMA >> disabled" message is actually a fatal error rather than a benign one >> the could be ignored, as it results in no valid DOS memory allocation >> at all. >> >> Right now, the only older system I could test it against uses FreeBSD >> 5.x, where the mmap() works as expected. =A0So does anyone have an idea >> why this mmap() call: >> >> =A0 =A0 if (mmap((caddr_t)0x000000, 0x100000, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PROT_EXEC | PROT_READ | PROT_WRIT= E, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MAP_ANON | MAP_FIXED | MAP_SHARED= , >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-1, 0) =3D=3D MAP_FAILED) { >> =A0 =A0 =A0 =A0 perror("Error mapping HMA, HMA disabled: "); >> =A0 =A0 =A0 =A0 HMA_a20 =3D -1; >> =A0 =A0 =A0 =A0 close(HMA_fd_off); >> =A0 =A0 =A0 =A0 close(HMA_fd_on); >> =A0 =A0 =A0 =A0 return; >> =A0 =A0 } >> >> yields an EINVAL now under 8-stable? As I remember, mapping of "zero" page forbidden by default. > I imagine that the page size ordeal is probably what's biting you. =A0Now= , > I'm not sure if page size in that above context refers to "kernel page > size" (e.g. hw.pagesizes or hw.pagesize) or if it refers to "a page of > memory" as in what libc/malloc uses. It refers. mmap(2) is system call. On i386/amd64 "big" page size is 2MB, and code above is trying to allocate 1MB, so memory will be allocated with 4KB-sized pages. > > I'm not sure why a person would need or want MAP_FIXED in this > situation; why can't they just take the result of mmap() (a void *) and > use that as a base address offset instead of assuming zero in their > software? AFAIK, doscmd is trying to emulate real mode on real hardware while being in protected mode, thus it want first pages of memory. Another way to do the same thing - open /dev/mem and call mmap() at zero of= fset.