Commit 6c173b3c09548fd5cd82de08646dfe939ec9416e
1 parent
ee50add9
Prepare for handling different BSD mmap() flags
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5809 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
126 additions
and
4 deletions
bsd-user/bsd-mman.h
0 → 100644
| 1 | +/*- | ||
| 2 | + * Copyright (c) 1982, 1986, 1993 | ||
| 3 | + * The Regents of the University of California. All rights reserved. | ||
| 4 | + * | ||
| 5 | + * Redistribution and use in source and binary forms, with or without | ||
| 6 | + * modification, are permitted provided that the following conditions | ||
| 7 | + * are met: | ||
| 8 | + * 1. Redistributions of source code must retain the above copyright | ||
| 9 | + * notice, this list of conditions and the following disclaimer. | ||
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | + * notice, this list of conditions and the following disclaimer in the | ||
| 12 | + * documentation and/or other materials provided with the distribution. | ||
| 13 | + * 4. Neither the name of the University nor the names of its contributors | ||
| 14 | + * may be used to endorse or promote products derived from this software | ||
| 15 | + * without specific prior written permission. | ||
| 16 | + * | ||
| 17 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 18 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 19 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 20 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 21 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 22 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 23 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 24 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 25 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 26 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 27 | + * SUCH DAMAGE. | ||
| 28 | + * | ||
| 29 | + * @(#)mman.h 8.2 (Berkeley) 1/9/95 | ||
| 30 | + * $FreeBSD: src/sys/sys/mman.h,v 1.42 2008/03/28 04:29:27 ps Exp $ | ||
| 31 | + */ | ||
| 32 | + | ||
| 33 | +#define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */ | ||
| 34 | +#define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */ | ||
| 35 | +#define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a stack */ | ||
| 36 | +#define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */ | ||
| 37 | + | ||
| 38 | +#define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 | ||
| 39 | + | ||
| 40 | +/* $NetBSD: mman.h,v 1.42 2008/11/18 22:13:49 ad Exp $ */ | ||
| 41 | + | ||
| 42 | +/*- | ||
| 43 | + * Copyright (c) 1982, 1986, 1993 | ||
| 44 | + * The Regents of the University of California. All rights reserved. | ||
| 45 | + * | ||
| 46 | + * Redistribution and use in source and binary forms, with or without | ||
| 47 | + * modification, are permitted provided that the following conditions | ||
| 48 | + * are met: | ||
| 49 | + * 1. Redistributions of source code must retain the above copyright | ||
| 50 | + * notice, this list of conditions and the following disclaimer. | ||
| 51 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
| 52 | + * notice, this list of conditions and the following disclaimer in the | ||
| 53 | + * documentation and/or other materials provided with the distribution. | ||
| 54 | + * 3. Neither the name of the University nor the names of its contributors | ||
| 55 | + * may be used to endorse or promote products derived from this software | ||
| 56 | + * without specific prior written permission. | ||
| 57 | + * | ||
| 58 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 59 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 60 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 61 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 62 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 63 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 64 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 65 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 66 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 67 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 68 | + * SUCH DAMAGE. | ||
| 69 | + * | ||
| 70 | + * @(#)mman.h 8.2 (Berkeley) 1/9/95 | ||
| 71 | + */ | ||
| 72 | +#define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after exec */ | ||
| 73 | +#define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even within break */ | ||
| 74 | +#define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is established */ | ||
| 75 | + | ||
| 76 | +#define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, swap space (stack) */ | ||
| 77 | + | ||
| 78 | +#define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 | ||
| 79 | + | ||
| 80 | +/* $OpenBSD: mman.h,v 1.18 2003/07/21 22:52:19 tedu Exp $ */ | ||
| 81 | +/* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */ | ||
| 82 | + | ||
| 83 | +/*- | ||
| 84 | + * Copyright (c) 1982, 1986, 1993 | ||
| 85 | + * The Regents of the University of California. All rights reserved. | ||
| 86 | + * | ||
| 87 | + * Redistribution and use in source and binary forms, with or without | ||
| 88 | + * modification, are permitted provided that the following conditions | ||
| 89 | + * are met: | ||
| 90 | + * 1. Redistributions of source code must retain the above copyright | ||
| 91 | + * notice, this list of conditions and the following disclaimer. | ||
| 92 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
| 93 | + * notice, this list of conditions and the following disclaimer in the | ||
| 94 | + * documentation and/or other materials provided with the distribution. | ||
| 95 | + * 3. Neither the name of the University nor the names of its contributors | ||
| 96 | + * may be used to endorse or promote products derived from this software | ||
| 97 | + * without specific prior written permission. | ||
| 98 | + * | ||
| 99 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 100 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 101 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 102 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 103 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 104 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 105 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 106 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 107 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 108 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 109 | + * SUCH DAMAGE. | ||
| 110 | + * | ||
| 111 | + * @(#)mman.h 8.1 (Berkeley) 6/2/93 | ||
| 112 | + */ | ||
| 113 | + | ||
| 114 | +#define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after exec */ | ||
| 115 | +#define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ | ||
| 116 | +#define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even within heap */ | ||
| 117 | + | ||
| 118 | +#define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 | ||
| 119 | + | ||
| 120 | +// XXX | ||
| 121 | +#define TARGET_BSD_MAP_FLAGMASK 0x3ff7 |
bsd-user/mmap.c
| @@ -27,6 +27,7 @@ | @@ -27,6 +27,7 @@ | ||
| 27 | 27 | ||
| 28 | #include "qemu.h" | 28 | #include "qemu.h" |
| 29 | #include "qemu-common.h" | 29 | #include "qemu-common.h" |
| 30 | +#include "bsd-mman.h" | ||
| 30 | 31 | ||
| 31 | //#define DEBUG_MMAP | 32 | //#define DEBUG_MMAP |
| 32 | 33 | ||
| @@ -223,7 +224,7 @@ static int mmap_frag(abi_ulong real_start, | @@ -223,7 +224,7 @@ static int mmap_frag(abi_ulong real_start, | ||
| 223 | if (!(flags & MAP_ANON)) { | 224 | if (!(flags & MAP_ANON)) { |
| 224 | /* msync() won't work here, so we return an error if write is | 225 | /* msync() won't work here, so we return an error if write is |
| 225 | possible while it is a shared mapping */ | 226 | possible while it is a shared mapping */ |
| 226 | - if ((flags & MAP_FLAGMASK) == MAP_SHARED && | 227 | + if ((flags & TARGET_BSD_MAP_FLAGMASK) == MAP_SHARED && |
| 227 | (prot & PROT_WRITE)) | 228 | (prot & PROT_WRITE)) |
| 228 | return -EINVAL; | 229 | return -EINVAL; |
| 229 | 230 | ||
| @@ -323,7 +324,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | @@ -323,7 +324,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | ||
| 323 | printf("MAP_FIXED "); | 324 | printf("MAP_FIXED "); |
| 324 | if (flags & MAP_ANON) | 325 | if (flags & MAP_ANON) |
| 325 | printf("MAP_ANON "); | 326 | printf("MAP_ANON "); |
| 326 | - switch(flags & MAP_FLAGMASK) { | 327 | + switch(flags & TARGET_BSD_MAP_FLAGMASK) { |
| 327 | case MAP_PRIVATE: | 328 | case MAP_PRIVATE: |
| 328 | printf("MAP_PRIVATE "); | 329 | printf("MAP_PRIVATE "); |
| 329 | break; | 330 | break; |
| @@ -331,7 +332,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | @@ -331,7 +332,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | ||
| 331 | printf("MAP_SHARED "); | 332 | printf("MAP_SHARED "); |
| 332 | break; | 333 | break; |
| 333 | default: | 334 | default: |
| 334 | - printf("[MAP_FLAGMASK=0x%x] ", flags & MAP_FLAGMASK); | 335 | + printf("[MAP_FLAGMASK=0x%x] ", flags & TARGET_BSD_MAP_FLAGMASK); |
| 335 | break; | 336 | break; |
| 336 | } | 337 | } |
| 337 | printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset); | 338 | printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset); |
| @@ -396,7 +397,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | @@ -396,7 +397,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | ||
| 396 | (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { | 397 | (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { |
| 397 | /* msync() won't work here, so we return an error if write is | 398 | /* msync() won't work here, so we return an error if write is |
| 398 | possible while it is a shared mapping */ | 399 | possible while it is a shared mapping */ |
| 399 | - if ((flags & MAP_FLAGMASK) == MAP_SHARED && | 400 | + if ((flags & TARGET_BSD_MAP_FLAGMASK) == MAP_SHARED && |
| 400 | (prot & PROT_WRITE)) { | 401 | (prot & PROT_WRITE)) { |
| 401 | errno = EINVAL; | 402 | errno = EINVAL; |
| 402 | goto fail; | 403 | goto fail; |