summaryrefslogtreecommitdiffstats
path: root/linux-user/mmap.c
Commit message (Collapse)AuthorAgeFilesLines
* linux-user: assert that target_mprotect cannot failPaolo Bonzini2015-10-011-4/+1
| | | | | | | | | | | | | All error conditions that target_mprotect checks are also checked by target_mmap. EACCESS cannot happen because we are just removing PROT_WRITE. ENOMEM should not happen because we are modifying a whole VMA (and we have bigger problems anyway if it happens). Fixes a Coverity false positive, where Coverity complains about target_mprotect's return value being passed to tb_invalidate_phys_range. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: remove useless macros GUEST_BASE and RESERVED_VALaurent Vivier2015-08-241-10/+10
| | | | | | | | | | | As we have removed CONFIG_USE_GUEST_BASE, we always use a guest base and the macros GUEST_BASE and RESERVED_VA become useless: replace them by their values. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1440420834-8388-1-git-send-email-laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: remove --enable-guest-base/--disable-guest-baseLaurent Vivier2015-08-241-4/+0
| | | | | | | | | | | | | | | | | | All tcg host architectures now support the guest base and as there is no real performance lost, it can be always enabled. Anyway, guest base use can be disabled lively by setting guest base to 0. CONFIG_USE_GUEST_BASE is defined as (USE_GUEST_BASE && USER_ONLY), it should have to be replaced by CONFIG_USER_ONLY in non CONFIG_USER_ONLY parts, but as some other parts are using !CONFIG_SOFTMMU I have chosen to use !CONFIG_SOFTMMU instead. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1440373328-9788-2-git-send-email-laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
* translate-all: remove unnecessary argument to tb_invalidate_phys_rangePaolo Bonzini2015-06-051-3/+3
| | | | | | | The is_cpu_write_access argument is always 0, remove it. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* exec: move functions to translate-all.hPaolo Bonzini2015-06-051-0/+1
| | | | | | | | Remove them from the sundry exec-all.h header, since they are only used by the TCG runtime in exec.c and user-exec.c. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* configure: Make NPTL non-optionalPeter Maydell2013-07-221-11/+0
| | | | | | | | | | | | | | | | | | | | Now all linux-user targets support building with NPTL, we can make it mandatory. This is a good idea because: * NPTL is no longer new and experimental; it is completely standard * in practice, linux-user without NPTL is nearly useless for binaries built against non-ancient glibc * it allows us to delete the rather untested code for handling the non-NPTL configuration Note that this patch leaves the CONFIG_USE_NPTL ifdefs in the bsd-user codebase alone. This makes no change for bsd-user, since our configure test for NPTL had a "#include <linux/futex.h>" which means bsd-user would never have been compiled with CONFIG_USE_NPTL defined, and it still is not. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Do not ignore mmap failure from hostJürg Billeter2013-07-051-0/+4
| | | | | | | | File mapping may fail with EACCES. Signed-off-by: Jürg Billeter <j@bitron.ch> Message-id: 1372498892-23676-1-git-send-email-j@bitron.ch Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
* linux-user: Allocate the right amount of space for non-fixed file mapsRichard Henderson2012-08-041-11/+19
| | | | | | | | | | | | If we let the kernel handle the implementation of mmap_find_vma, via an anon mmap, we must use the size as indicated by the user and not the size truncated to the filesize. This happens often in ld.so, where we initially mmap the file to the size of the text+data+bss to reserve an area, then mmap+fixed over the top to properly handle data and bss. Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Fix stale tbs after mmapAlexander Graf2012-05-191-1/+5
| | | | | | | | | | | | | | | | | | | | | | | If we execute linux-user code that does the following: * A = mmap() * execute code in A * munmap(A) * B = mmap(), but mmap returns the same address as A * execute code in B we end up executing a stale cached tb that contains translated code from A, while we want new code from B. This patch adds a TB flush for mmap'ed regions, before we return them, avoiding the whole issue. It also adds a flush for munmap, so that we don't execute stale TBs instead of getting a segfault. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: resolve reserved_va vma downwardsPeter Maydell2012-04-061-11/+24
| | | | | | | | | | | | | After consulting with Paul Brook, we concluded that it's best to search the VMA space downwards, so that we don't even get the chance to conflict with the brk range. This patch resolves a bunch of allocation conflicts when using -R. Signed-off-by: Alexander Graf <agraf@suse.de> [minor changes to get it to apply -- PMM] Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* Fix typo in comment (truely -> truly)Stefan Weil2011-05-081-1/+1
| | | | | Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* linux-user: fix compile failure if !CONFIG_USE_GUEST_BASEPeter Maydell2011-03-031-0/+4
| | | | | | | | | | | | If CONFIG_USE_GUEST_BASE is not defined, gcc complains: linux-user/mmap.c:235: error: comparison of unsigned expression >= 0 is always true because RESERVED_VA is #defined to 0. Since mmap_find_vma_reserved() will never be called anyway if RESERVED_VA is always 0, fix this by simply #ifdef'ing away the function and its callsite. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: mmap_reserve() not controlled by RESERVED_VAamateur2010-12-031-1/+3
| | | | | | | | mmap_reserve() should be called only when RESERVED_VA is enabled. Otherwise, unmaped virtual address space will never be reusable. This bug will exhaust virtual address space in extreme conditions. Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
* linux-user: fix types in a comparisonBlue Swirl2010-09-181-1/+1
| | | | | | | | | | | -1ul is unsigned long, which does not necessarily match abi_ulong type. Fix by using abi_long instead. This also avoids a warning with GCC flag -Wtype-limits. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: fix build on hosts not using guest baseAurelien Jarno2010-07-301-7/+7
| | | | | | | | Commit 68a1c816868b3e35a1da698af412b29e61b1948a broke qemu on hosts not using guest base. It uses reserved_va unconditionally in mmap.c. To avoid to many #ifdef #endif blocks, define RESERVED_VA as either reserved_va or 0ul, and use it instead of reserved_va, similarly to what has been done with guest_base/GUEST_BASE.
* Pre-allocate guest address spacePaul Brook2010-05-291-6/+114
| | | | | | Allow pre-allocation of the guest virtual address space in usermode emulation. Signed-off-by: Paul Brook <paul@codesourcery.com>
* linux-user: Use qemu-malloc.c.Richard Henderson2010-05-281-52/+0
| | | | | | | | Since we're no longer setting PAGE_RESERVED, there's no need to implement qemu_malloc via mmap. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Remove PAGE_RESERVEDPaul Brook2010-05-051-19/+0
| | | | | | | | | The usermode PAGE_RESERVED code is not required by the current mmap implementation, and is already broken when guest_base != 0. Unfortunately the bsd emulation still uses the old mmap implementation, so we can't rip it out altogether. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Fix usermode virtual address typePaul Brook2010-03-121-1/+1
| | | | | | Usermode virtual addresses are abi_ulong, not target_ulong. Signed-off-by: Paul Brook <paul@codesourcery.com>
* linux-user: Fix mmap_find_vma returning invalid addresses.Richard Henderson2010-03-121-24/+78
| | | | | | | | | | | | | Don't return addresses that aren't properly aligned for the guest, e.g. when the guest has a larger page size than the host. Don't return addresses that are outside the virtual address space for the target, by paying proper attention to the h2g/g2h macros. At the same time, place the default mapping base for 64-bit guests (on 64-bit hosts) outside the low 4G. Consistently interpret mmap_next_start in the guest address space. Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Use h2g_valid in qemu_vmalloc.Richard Henderson2010-03-121-5/+4
| | | | Signed-off-by: Richard Henderson <rth@twiddle.net>
* mmap_frag() users only check for -1 errorJuan Quintela2010-01-261-1/+1
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* linux-user/mmap.c: fix warnings with _FORTIFY_SOURCEKirill A. Shutemov2010-01-261-2/+4
| | | | | | | | | | | | | | CC i386-linux-user/mmap.o cc1: warnings being treated as errors /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag': /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return value of 'pread', declared with attribute warn_unused_result /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap': /usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring return value of 'pread', declared with attribute warn_unused_result make[1]: *** [mmap.o] Error 1 Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* __thread should be before real typeJuan Quintela2009-09-251-1/+1
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix Sparse warnings: add "static"Blue Swirl2009-09-051-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit ↵Kirill A. Shutemov2009-08-251-36/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | targets qemu's page table can be incomple if /proc/self/maps is unavailable or host allocating a memory with mmap(), so we can't use it to find free memory area. New version mmap_find_vma() uses mmap() without MAP_FIXED to find free memory. Tested-by: Martin Mohring <martin.mohring@opensuse.org> : quite some time ago this patch had been sent by Kirill to the QEMU ml. At that time, the patch was rejected. Now we found out why the current user mode memory allocator sometimes fails: - Kernel Bug linux/fs/proc/task_mmu.c (fixed after 2.6.27) http://bugzilla.kernel.org/attachment.cgi?id=17219 - use of proc file system to find memory mappings => bad idea So I please apply the attached patch from Kirill to qemu to fix this longstanding bug, because it causes all older linux distros (using kernel 2.6.26 or older) to fail the QEMU memory allocator in user mode. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
* rename USE_NPTL to CONFIG_USE_NPTLJuan Quintela2009-07-271-1/+1
| | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix most warnings (errors with -Werror) when debugging is enabledBlue Swirl2009-07-201-7/+9
| | | | | | | I used the following command to enable debugging: perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/* Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Update to a hopefully more future proof FSF addressBlue Swirl2009-07-161-3/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: initialize mmap_mutex properlyNathan Froyd2009-06-161-1/+1
| | | | | | | | We initialize mmap_mutex in any child threads/processes, but we need to correctly statically initialize it for the original process. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
* export mmap_find_vma for shmatRiku Voipio2009-06-161-1/+1
| | | | Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
* Partialy fix mmap at EOF for large pagesize targets in user-mode.edgar_igl2009-02-031-2/+37
| | | | | | | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6510 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix qemu_malloc.malc2009-01-281-0/+2
| | | | | | | make {linux,bsd}-user qemu_realloc handle ptr == NULL correctly. spotted by malc. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6466 c046a42c-6fe2-441c-8c8c-71466251a162
* linux-user: add qemu_realloc() implementation to unbreak the build (Gerd ↵aliguori2009-01-231-0/+13
| | | | | | | | | | Hoffman) Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6412 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix more FSF addressesblueswir12009-01-051-1/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6192 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix mremap, based on patch by Kirill A. Shutemovblueswir12008-12-151-8/+11
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6056 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix compiling without MREMAP_FIXEDblueswir12008-12-111-1/+4
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5979 c046a42c-6fe2-441c-8c8c-71466251a162
* linux-user: mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctlyaurel322008-12-081-6/+28
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5959 c046a42c-6fe2-441c-8c8c-71466251a162
* linux-user: mmap: add check if requested memory area fits target address spaceaurel322008-12-081-0/+10
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5958 c046a42c-6fe2-441c-8c8c-71466251a162
* Include qemu-common.h in order to get prototypes for qemu_malloc etc.blueswir12008-10-021-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5402 c046a42c-6fe2-441c-8c8c-71466251a162
* Prevent guest reusing host memory allocations.pbrook2008-06-091-0/+46
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4710 c046a42c-6fe2-441c-8c8c-71466251a162
* Multithreaded locking fixes.pbrook2008-06-071-0/+16
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4692 c046a42c-6fe2-441c-8c8c-71466251a162
* Multithreaded locking for mmap().pbrook2008-06-021-27/+73
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4654 c046a42c-6fe2-441c-8c8c-71466251a162
* Mark host brk() area as reserved.pbrook2008-05-311-0/+16
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4637 c046a42c-6fe2-441c-8c8c-71466251a162
* Teach mmap to not overwrite reserved pages and fix brk return value (Richard ↵balrog2008-04-261-1/+12
| | | | | | Purdie). git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4255 c046a42c-6fe2-441c-8c8c-71466251a162
* Cope with arch-specific page protection flags in mmap (Richard Purdie).balrog2008-04-241-2/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4250 c046a42c-6fe2-441c-8c8c-71466251a162
* Use TARGET_FMT_lx.edgar_igl2008-03-141-2/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4061 c046a42c-6fe2-441c-8c8c-71466251a162
* Mark host pages as reserved (Magnus Damm).balrog2007-12-121-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3813 c046a42c-6fe2-441c-8c8c-71466251a162
* fixed target_mmap() if host page size < TARGET_PAGE_SIZEbellard2007-11-141-138/+126
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3642 c046a42c-6fe2-441c-8c8c-71466251a162
* Fix compiler warnings, by Stefan Weil.ths2007-11-021-21/+23
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3507 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud