linux-user mremap()
Until the linux-user mremap() problem is fixed (the one where a 64-bit value can be returned even on a 32-bit target), might it make sense to apply a patch like this?
This will at least let users know what the problem is, instead of just segfaulting.
Vince
mmap.c +5 -0
@@ -538,6 +538,13 @@mmap_lock ();/* XXX: use 5 args syscall */ host_addr = (long )mremap (g2h (old_addr), old_size, new_size, flags); +#if TARGET_ABI_BITS ==32 +if (host_addr >0xffffffff ) { +printf ("ERROR! mremap() returned 64-bit value on 32-bit target!\n\n" ); + exit(-1); + } +#endif + if (host_addr == -1) { new_addr =-1 ; } else {
Quoted 9 lines · Vince Weaver
Until the linux-user
mremap()problem is fixed (the one where a 64-bit value can be returned even on a 32-bit target), might it make sense to apply a patch like this?This will at least let users know what the problem is, instead of just segfaulting.
Vince
If host is x86_64, use MAP_32BIT.
Quoted 24 lines
Index:
mmap.c
===================================================================mmap.c +7
-0@@ -538,6 +538,13 @@mmap_lock ();/* XXX: use 5 args syscall */ host_addr = (long )mremap (g2h (old_addr), old_size, new_size, flags); +#if TARGET_ABI_BITS ==32 +if (host_addr >0xffffffff ) { +printf ("ERROR! mremap() returned 64-bit value on 32-bit target!\n\n" ); +exit (-1 ); + } +#endif +if (host_addr ==-1 ) { new_addr =-1 ; }else {
Signature · 3 lines
Regards, Kirill A. Shutemov + Belarus, Minsk + ALT Linux Team, http://www.altlinux.com/
Quoted 2 lines
If host is
x86_64, useMAP_32BIT.
I don't think that works for mremap(), hence the problem.
In any case, even if it does fix it for x86_64, simply crashing qemu with a segfault on other architectures still isn't a good thing to do.
Vince