All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall
@ 2016-09-30 23:39 Felix Janda
  2016-10-01  2:35 ` Peter Maydell
  2016-10-07 12:21 ` Riku Voipio
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Janda @ 2016-09-30 23:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

This commit essentially reverts commit
3af72a4d98dca033492102603734cbc63cd2694a, which has replaced
five-argument calls to mremap() by direct mremap syscalls for
compatibility with glibc older than version 2.4.

The direct syscall was buggy for 64bit targets on 32bit hosts
because of the default integer type promotions. Since glibc-2.4
is now a decade old, we can remove this workaround.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
---
 linux-user/mmap.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index c4371d9..ffd099d 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -17,8 +17,6 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
-#include <linux/mman.h>
-#include <linux/unistd.h>
 
 #include "qemu.h"
 #include "qemu-common.h"
@@ -681,10 +679,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
     mmap_lock();
 
     if (flags & MREMAP_FIXED) {
-        host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
-                                     old_size, new_size,
-                                     flags,
-                                     g2h(new_addr));
+        host_addr = mremap(g2h(old_addr), old_size, new_size,
+                           flags, g2h(new_addr));
 
         if (reserved_va && host_addr != MAP_FAILED) {
             /* If new and old addresses overlap then the above mremap will
@@ -700,10 +696,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
             errno = ENOMEM;
             host_addr = MAP_FAILED;
         } else {
-            host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
-                                         old_size, new_size,
-                                         flags | MREMAP_FIXED,
-                                         g2h(mmap_start));
+            host_addr = mremap(g2h(old_addr), old_size, new_size,
+                               flags | MREMAP_FIXED, g2h(mmap_start));
             if (reserved_va) {
                 mmap_reserve(old_addr, old_size);
             }
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall
  2016-09-30 23:39 [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall Felix Janda
@ 2016-10-01  2:35 ` Peter Maydell
  2016-10-07 12:19   ` Riku Voipio
  2016-10-07 12:21 ` Riku Voipio
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-10-01  2:35 UTC (permalink / raw)
  To: Felix Janda; +Cc: QEMU Developers, Riku Voipio

On 30 September 2016 at 16:39, Felix Janda <felix.janda@posteo.de> wrote:
> This commit essentially reverts commit
> 3af72a4d98dca033492102603734cbc63cd2694a, which has replaced
> five-argument calls to mremap() by direct mremap syscalls for
> compatibility with glibc older than version 2.4.
>
> The direct syscall was buggy for 64bit targets on 32bit hosts
> because of the default integer type promotions. Since glibc-2.4
> is now a decade old, we can remove this workaround.
>
> Signed-off-by: Felix Janda <felix.janda@posteo.de>


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall
  2016-10-01  2:35 ` Peter Maydell
@ 2016-10-07 12:19   ` Riku Voipio
  0 siblings, 0 replies; 4+ messages in thread
From: Riku Voipio @ 2016-10-07 12:19 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Felix Janda, QEMU Developers

On Fri, Sep 30, 2016 at 07:35:45PM -0700, Peter Maydell wrote:
> On 30 September 2016 at 16:39, Felix Janda <felix.janda@posteo.de> wrote:
> > This commit essentially reverts commit
> > 3af72a4d98dca033492102603734cbc63cd2694a, which has replaced
> > five-argument calls to mremap() by direct mremap syscalls for
> > compatibility with glibc older than version 2.4.
> >
> > The direct syscall was buggy for 64bit targets on 32bit hosts
> > because of the default integer type promotions. Since glibc-2.4
> > is now a decade old, we can remove this workaround.
> >
> > Signed-off-by: Felix Janda <felix.janda@posteo.de>
> 
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Applied to linux-user, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall
  2016-09-30 23:39 [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall Felix Janda
  2016-10-01  2:35 ` Peter Maydell
@ 2016-10-07 12:21 ` Riku Voipio
  1 sibling, 0 replies; 4+ messages in thread
From: Riku Voipio @ 2016-10-07 12:21 UTC (permalink / raw)
  To: Felix Janda; +Cc: qemu-devel

On Fri, Sep 30, 2016 at 07:39:27PM -0400, Felix Janda wrote:
> This commit essentially reverts commit
> 3af72a4d98dca033492102603734cbc63cd2694a, which has replaced
> five-argument calls to mremap() by direct mremap syscalls for
> compatibility with glibc older than version 2.4.
> 
> The direct syscall was buggy for 64bit targets on 32bit hosts
> because of the default integer type promotions. Since glibc-2.4
> is now a decade old, we can remove this workaround.

Applied this and the <poll.h> patch to linux-user

Thanks,
Riku
 
> Signed-off-by: Felix Janda <felix.janda@posteo.de>
> ---
>  linux-user/mmap.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> index c4371d9..ffd099d 100644
> --- a/linux-user/mmap.c
> +++ b/linux-user/mmap.c
> @@ -17,8 +17,6 @@
>   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
>   */
>  #include "qemu/osdep.h"
> -#include <linux/mman.h>
> -#include <linux/unistd.h>
>  
>  #include "qemu.h"
>  #include "qemu-common.h"
> @@ -681,10 +679,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
>      mmap_lock();
>  
>      if (flags & MREMAP_FIXED) {
> -        host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
> -                                     old_size, new_size,
> -                                     flags,
> -                                     g2h(new_addr));
> +        host_addr = mremap(g2h(old_addr), old_size, new_size,
> +                           flags, g2h(new_addr));
>  
>          if (reserved_va && host_addr != MAP_FAILED) {
>              /* If new and old addresses overlap then the above mremap will
> @@ -700,10 +696,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
>              errno = ENOMEM;
>              host_addr = MAP_FAILED;
>          } else {
> -            host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
> -                                         old_size, new_size,
> -                                         flags | MREMAP_FIXED,
> -                                         g2h(mmap_start));
> +            host_addr = mremap(g2h(old_addr), old_size, new_size,
> +                               flags | MREMAP_FIXED, g2h(mmap_start));
>              if (reserved_va) {
>                  mmap_reserve(old_addr, old_size);
>              }
> -- 
> 2.7.3
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-07 12:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-30 23:39 [Qemu-devel] [PATCH] linux-user: use libc wrapper instead of direct mremap syscall Felix Janda
2016-10-01  2:35 ` Peter Maydell
2016-10-07 12:19   ` Riku Voipio
2016-10-07 12:21 ` Riku Voipio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.