NetBSD Problem Report #5693
Received: (qmail 22463 invoked from network); 2 Jul 1998 21:37:08 -0000
Message-Id: <199807022137.XAA08609@animal.cs.chalmers.se>
Date: Thu, 2 Jul 1998 23:37:03 +0200 (MET DST)
From: Urban Boquist <boquist@cs.chalmers.se>
Reply-To: boquist@cs.chalmers.se
To: gnats-bugs@gnats.netbsd.org
Subject: linux emulation: partial mremap(2) support (for Quake2)
X-Send-Pr-Version: 3.95
>Number: 5693
>Category: kern
>Synopsis: linux system call mremap is missing
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 02 14:50:01 +0000 1998
>Closed-Date: Thu Jul 02 23:25:15 +0000 1998
>Last-Modified: Thu Jul 02 23:25:44 +0000 1998
>Originator: Urban Boquist
>Release: NetBSD-current June 1998
>Organization:
Dept. of CS, Chalmers, Sweden
>Environment:
System: NetBSD dogbert.cs.chalmers.se 1.3E NetBSD 1.3E (DOGBERT) #0: Thu Mar 12 10:45:34 CET 1998 augustss@dogbert.cs.chalmers.se:/usr/src/sys/arch/i386/compile/DOGBERT i386
>Description:
The current linux emulation includes only a stub for the mremap system
call (it just returns ENOMEM). It is very easy to implement "half" of
mremap, the case when the mapped area is shrinking. The patch below
implements this. The other way around, a growing area, is harder.
With this patch I can successfully play linux Quake2. It works
perfectly, with sound, CD music, everything! ;-)
>How-To-Repeat:
Try linux Quake2 and watch it die.
>Fix:
--- src/sys/compat/linux/linux_misc.c Tue Mar 24 13:19:43 1998
+++ src2/sys/compat/linux/linux_misc.c Thu Jul 2 12:30:07 1998
@@ -519,16 +519,36 @@
void *v;
register_t *retval;
{
-#ifdef notyet
struct linux_sys_mremap_args /* {
syscallarg(void *) old_address;
syscallarg(size_t) old_size;
syscallarg(size_t) new_size;
syscallarg(u_long) flags;
} */ *uap = v;
-#endif
+ struct sys_munmap_args mua;
+ int error;
- return ENOMEM;
+ SCARG(uap, old_size) = round_page(SCARG(uap, old_size));
+ SCARG(uap, new_size) = round_page(SCARG(uap, new_size));
+
+ /*
+ * XXX We handle only shrinking remaps (linux always allows this).
+ */
+ if (SCARG(uap, new_size) > SCARG(uap, old_size)) {
+ retval[0] = 0;
+ return ENOMEM;
+ }
+
+ if (SCARG(uap, new_size) < SCARG(uap, old_size)) {
+ SCARG(&mua, addr) = SCARG(uap, old_address) + SCARG(uap, new_size);
+ SCARG(&mua, len) = SCARG(uap, old_size) - SCARG(uap, new_size);
+ error = sys_munmap(p, &mua, retval);
+ retval[0] = error ? 0 : (unsigned)SCARG(uap, old_address);
+ return error;
+ }
+
+ retval[0] = (unsigned)SCARG(uap, old_address);
+ return 0;
}
int
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: thorpej
State-Changed-When: Thu Jul 2 16:25:15 PDT 1998
State-Changed-Why:
Applied your patch (slightly modified, cosmetic only). thanks for the
contribution!!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.