Commit Graph

62 Commits

Author SHA1 Message Date
Peter Maydell 24cb36a61c configure: Make NPTL non-optional
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>
2013-07-22 21:54:52 +03:00
Jürg Billeter 8384274eda linux-user: Do not ignore mmap failure from host
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>
2013-07-05 15:45:40 +03:00
Richard Henderson a5e7ee467c linux-user: Allocate the right amount of space for non-fixed file maps
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>
2012-08-04 09:37:49 -07:00
Alexander Graf 77a8f1a512 linux-user: Fix stale tbs after mmap
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>
2012-05-19 15:49:40 +00:00
Peter Maydell 59e9d91c7a linux-user: resolve reserved_va vma downwards
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>
2012-04-06 18:49:58 +03:00
Stefan Weil 8186e78311 Fix typo in comment (truely -> truly)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-05-08 10:02:18 +01:00
Peter Maydell 4e6557124c linux-user: fix compile failure if !CONFIG_USE_GUEST_BASE
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>
2011-03-03 23:33:45 +01:00
amateur c65ffe6d6c linux-user: mmap_reserve() not controlled by RESERVED_VA
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>
2010-12-03 15:09:38 +02:00
Blue Swirl d0b3e4f5f4 linux-user: fix types in a comparison
-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>
2010-09-18 05:53:14 +00:00
Aurelien Jarno 18e9ea8a3f linux-user: fix build on hosts not using guest base
Commit 68a1c81686 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.
2010-07-30 21:09:10 +02:00
Paul Brook 68a1c81686 Pre-allocate guest address space
Allow pre-allocation of the guest virtual address space in usermode emulation.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-05-29 02:27:35 +01:00
Richard Henderson 680c877af4 linux-user: Use qemu-malloc.c.
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>
2010-05-28 23:27:19 +02:00
Paul Brook 2e9a5713f0 Remove PAGE_RESERVED
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>
2010-05-05 16:32:59 +01:00
Paul Brook b480d9b74d Fix usermode virtual address type
Usermode virtual addresses are abi_ulong, not target_ulong.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-03-12 23:25:52 +00:00
Richard Henderson 14f24e1465 linux-user: Fix mmap_find_vma returning invalid addresses.
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>
2010-03-12 16:29:18 +00:00
Richard Henderson 7bc7b099df linux-user: Use h2g_valid in qemu_vmalloc.
Signed-off-by: Richard Henderson <rth@twiddle.net>
2010-03-12 16:29:07 +00:00
Juan Quintela ee636500d6 mmap_frag() users only check for -1 error
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:59:20 -06:00
Kirill A. Shutemov fb7e378cf9 linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
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>
2010-01-26 14:59:20 -06:00
Juan Quintela dfd3f85c45 __thread should be before real type
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-25 19:53:17 +00:00
Blue Swirl 1e6eec8b33 Fix Sparse warnings: add "static"
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-05 10:14:07 +00:00
Kirill A. Shutemov fe3b415231 linux-user: Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit 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>
2009-08-25 17:15:35 +03:00
Juan Quintela 2f7bb8780a rename USE_NPTL to CONFIG_USE_NPTL
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 14:10:55 -05:00
Blue Swirl 0bf9e31af1 Fix most warnings (errors with -Werror) when debugging is enabled
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>
2009-07-20 17:19:25 +00:00
Blue Swirl 8167ee8839 Update to a hopefully more future proof FSF address
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-16 20:47:01 +00:00
Nathan Froyd df377d0354 linux-user: initialize mmap_mutex properly
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>
2009-06-16 16:58:45 +03:00
Riku Voipio 9ad197d95c export mmap_find_vma for shmat
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
edgar_igl 54c5a2ae54 Partialy fix mmap at EOF for large pagesize targets in user-mode.
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
2009-02-03 23:06:34 +00:00
malc baa8c60229 Fix qemu_malloc.
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
2009-01-28 17:16:56 +00:00
aliguori 1a6f0dbcc0 linux-user: add qemu_realloc() implementation to unbreak the build (Gerd 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
2009-01-23 15:02:20 +00:00
blueswir1 530e7615ce Fix more FSF addresses
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6192 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-05 18:11:53 +00:00
blueswir1 3af72a4d98 Fix mremap, based on patch by Kirill A. Shutemov
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6056 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-15 17:58:49 +00:00
blueswir1 5caf7bb2c4 Fix compiling without MREMAP_FIXED
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5979 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-11 19:12:25 +00:00
aurel32 f19412a2a6 linux-user: mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly
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
2008-12-08 18:12:40 +00:00
aurel32 45bc1f5264 linux-user: mmap: add check if requested memory area fits target address space
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
2008-12-08 18:12:33 +00:00
blueswir1 78f5bf1e6f Include qemu-common.h in order to get prototypes for qemu_malloc etc.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5402 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-02 19:55:50 +00:00
pbrook 17e2377abf Prevent guest reusing host memory allocations.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4710 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-09 13:47:45 +00:00
pbrook d597536303 Multithreaded locking fixes.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4692 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-07 20:50:51 +00:00
pbrook c8a706fe62 Multithreaded locking for mmap().
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4654 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-02 16:16:42 +00:00
pbrook 0776590d70 Mark host brk() area as reserved.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4637 c046a42c-6fe2-441c-8c8c-71466251a162
2008-05-31 16:33:53 +00:00
balrog 7ab240ad4b Teach mmap to not overwrite reserved pages and fix brk return value (Richard Purdie).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4255 c046a42c-6fe2-441c-8c8c-71466251a162
2008-04-26 12:17:34 +00:00
balrog 171cd1cdff Cope with arch-specific page protection flags in mmap (Richard Purdie).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4250 c046a42c-6fe2-441c-8c8c-71466251a162
2008-04-24 21:11:41 +00:00
edgar_igl 2e0ded9c7c Use TARGET_FMT_lx.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4061 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-14 14:11:05 +00:00
balrog 50a9569b59 Mark host pages as reserved (Magnus Damm).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3813 c046a42c-6fe2-441c-8c8c-71466251a162
2007-12-12 01:16:23 +00:00
bellard a03e2d421e fixed target_mmap() if host page size < TARGET_PAGE_SIZE
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3642 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-14 11:29:07 +00:00
ths 80210bcd71 Fix compiler warnings, by Stefan Weil.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3507 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-02 19:08:57 +00:00
blueswir1 992f48a036 Support for 32 bit ABI on 64 bit targets (only enabled Sparc64)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3396 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-14 16:27:31 +00:00
ths a5b85f7959 Fix mmap to handle differing host/target page sizes, by Edgar E. Iglesias.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3291 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-30 14:32:45 +00:00
j_mayer 4118a97030 memset string pages to zero to avoid putting random data on the stack
that may make some program crash at startup.
Fix unsigned long / target_ulong confusion (more to do).
Fix missing g2h macros.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3249 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 04:10:43 +00:00
ths 3b46e62427 find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-17 08:09:54 +00:00
ths 5fafdf24ef find -type f | xargs sed -i 's/[\t ]$//g' # on most files
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-16 21:08:06 +00:00