···11+/*-
22+ * Copyright (c) 1982, 1986, 1993
33+ * The Regents of the University of California. All rights reserved.
44+ *
55+ * Redistribution and use in source and binary forms, with or without
66+ * modification, are permitted provided that the following conditions
77+ * are met:
88+ * 1. Redistributions of source code must retain the above copyright
99+ * notice, this list of conditions and the following disclaimer.
1010+ * 2. Redistributions in binary form must reproduce the above copyright
1111+ * notice, this list of conditions and the following disclaimer in the
1212+ * documentation and/or other materials provided with the distribution.
1313+ * 4. Neither the name of the University nor the names of its contributors
1414+ * may be used to endorse or promote products derived from this software
1515+ * without specific prior written permission.
1616+ *
1717+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2020+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727+ * SUCH DAMAGE.
2828+ *
2929+ * @(#)mman.h 8.2 (Berkeley) 1/9/95
3030+ * $FreeBSD: src/sys/sys/mman.h,v 1.42 2008/03/28 04:29:27 ps Exp $
3131+ */
3232+3333+#define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */
3434+#define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */
3535+#define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a stack */
3636+#define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */
3737+3838+#define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7
3939+4040+/* $NetBSD: mman.h,v 1.42 2008/11/18 22:13:49 ad Exp $ */
4141+4242+/*-
4343+ * Copyright (c) 1982, 1986, 1993
4444+ * The Regents of the University of California. All rights reserved.
4545+ *
4646+ * Redistribution and use in source and binary forms, with or without
4747+ * modification, are permitted provided that the following conditions
4848+ * are met:
4949+ * 1. Redistributions of source code must retain the above copyright
5050+ * notice, this list of conditions and the following disclaimer.
5151+ * 2. Redistributions in binary form must reproduce the above copyright
5252+ * notice, this list of conditions and the following disclaimer in the
5353+ * documentation and/or other materials provided with the distribution.
5454+ * 3. Neither the name of the University nor the names of its contributors
5555+ * may be used to endorse or promote products derived from this software
5656+ * without specific prior written permission.
5757+ *
5858+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5959+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6060+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6161+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6262+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6363+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6464+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6565+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6666+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6767+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6868+ * SUCH DAMAGE.
6969+ *
7070+ * @(#)mman.h 8.2 (Berkeley) 1/9/95
7171+ */
7272+#define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after exec */
7373+#define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even within break */
7474+#define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is established */
7575+7676+#define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, swap space (stack) */
7777+7878+#define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7
7979+8080+/* $OpenBSD: mman.h,v 1.18 2003/07/21 22:52:19 tedu Exp $ */
8181+/* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */
8282+8383+/*-
8484+ * Copyright (c) 1982, 1986, 1993
8585+ * The Regents of the University of California. All rights reserved.
8686+ *
8787+ * Redistribution and use in source and binary forms, with or without
8888+ * modification, are permitted provided that the following conditions
8989+ * are met:
9090+ * 1. Redistributions of source code must retain the above copyright
9191+ * notice, this list of conditions and the following disclaimer.
9292+ * 2. Redistributions in binary form must reproduce the above copyright
9393+ * notice, this list of conditions and the following disclaimer in the
9494+ * documentation and/or other materials provided with the distribution.
9595+ * 3. Neither the name of the University nor the names of its contributors
9696+ * may be used to endorse or promote products derived from this software
9797+ * without specific prior written permission.
9898+ *
9999+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
100100+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
101101+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
102102+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
103103+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
104104+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
105105+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
106106+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
107107+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
108108+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109109+ * SUCH DAMAGE.
110110+ *
111111+ * @(#)mman.h 8.1 (Berkeley) 6/2/93
112112+ */
113113+114114+#define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after exec */
115115+#define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */
116116+#define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even within heap */
117117+118118+#define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7
119119+120120+// XXX
121121+#define TARGET_BSD_MAP_FLAGMASK 0x3ff7
+5-4
bsd-user/mmap.c
···27272828#include "qemu.h"
2929#include "qemu-common.h"
3030+#include "bsd-mman.h"
30313132//#define DEBUG_MMAP
3233···223224 if (!(flags & MAP_ANON)) {
224225 /* msync() won't work here, so we return an error if write is
225226 possible while it is a shared mapping */
226226- if ((flags & MAP_FLAGMASK) == MAP_SHARED &&
227227+ if ((flags & TARGET_BSD_MAP_FLAGMASK) == MAP_SHARED &&
227228 (prot & PROT_WRITE))
228229 return -EINVAL;
229230···323324 printf("MAP_FIXED ");
324325 if (flags & MAP_ANON)
325326 printf("MAP_ANON ");
326326- switch(flags & MAP_FLAGMASK) {
327327+ switch(flags & TARGET_BSD_MAP_FLAGMASK) {
327328 case MAP_PRIVATE:
328329 printf("MAP_PRIVATE ");
329330 break;
···331332 printf("MAP_SHARED ");
332333 break;
333334 default:
334334- printf("[MAP_FLAGMASK=0x%x] ", flags & MAP_FLAGMASK);
335335+ printf("[MAP_FLAGMASK=0x%x] ", flags & TARGET_BSD_MAP_FLAGMASK);
335336 break;
336337 }
337338 printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset);
···396397 (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) {
397398 /* msync() won't work here, so we return an error if write is
398399 possible while it is a shared mapping */
399399- if ((flags & MAP_FLAGMASK) == MAP_SHARED &&
400400+ if ((flags & TARGET_BSD_MAP_FLAGMASK) == MAP_SHARED &&
400401 (prot & PROT_WRITE)) {
401402 errno = EINVAL;
402403 goto fail;