Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux/common Fixed brk() emulation. We now keep t...



details:   https://anonhg.NetBSD.org/src/rev/6ec0dad8ecca
branches:  trunk
changeset: 507160:6ec0dad8ecca
user:      manu <manu%NetBSD.org@localhost>
date:      Thu Mar 15 19:18:20 2001 +0000

description:
Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.

diffstat:

 sys/compat/linux/common/linux_emuldata.h |  10 +++++-----
 sys/compat/linux/common/linux_exec.c     |   6 +++++-
 sys/compat/linux/common/linux_misc.c     |  20 ++++++++++----------
 3 files changed, 20 insertions(+), 16 deletions(-)

diffs (88 lines):

diff -r 81f9e0d35b22 -r 6ec0dad8ecca sys/compat/linux/common/linux_emuldata.h
--- a/sys/compat/linux/common/linux_emuldata.h  Thu Mar 15 17:41:28 2001 +0000
+++ b/sys/compat/linux/common/linux_emuldata.h  Thu Mar 15 19:18:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_emuldata.h,v 1.2 2000/11/21 12:21:43 jdolecek Exp $      */
+/*     $NetBSD: linux_emuldata.h,v 1.3 2001/03/15 19:18:20 manu Exp $  */
 
 #ifndef _COMMON_LINUX_EMULDATA_H
 #define _COMMON_LINUX_EMULDATA_H
@@ -11,10 +11,10 @@
  */
 struct linux_emuldata {
 #if notyet
-    sigset_t   ps_siginfo;             /* Which signals have a RT handler */
+       sigset_t        ps_siginfo;             /* Which signals have a RT handler */
 #endif
-    int                debugreg[8];            /* GDB information for ptrace - for use,
-                                        * see ../arch/i386/linux_ptrace.c */
-
+       int             debugreg[8];    /* GDB information for ptrace - for use, */
+                                       /* see ../arch/i386/linux_ptrace.c */
+       caddr_t p_break;                        /* Processes' idea of break */  
 };
 #endif /* !_COMMON_LINUX_EMULDATA_H */
diff -r 81f9e0d35b22 -r 6ec0dad8ecca sys/compat/linux/common/linux_exec.c
--- a/sys/compat/linux/common/linux_exec.c      Thu Mar 15 17:41:28 2001 +0000
+++ b/sys/compat/linux/common/linux_exec.c      Thu Mar 15 19:18:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec.c,v 1.45 2001/01/19 01:44:46 manu Exp $     */
+/*     $NetBSD: linux_exec.c,v 1.46 2001/03/15 19:18:20 manu Exp $     */
 
 /*-
  * Copyright (c) 1994, 1995, 1998, 2000 The NetBSD Foundation, Inc.
@@ -149,6 +149,10 @@
        }
 
        memset(p->p_emuldata, '\0', sizeof(struct linux_emuldata));
+       
+       /* Set the process idea of the break to the real value */
+       ((struct linux_emuldata*)(p->p_emuldata))->p_break = 
+           p->p_vmspace->vm_daddr + ctob(p->p_vmspace->vm_dsize);
 }
 
 /*
diff -r 81f9e0d35b22 -r 6ec0dad8ecca sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Thu Mar 15 17:41:28 2001 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Thu Mar 15 19:18:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.83 2001/01/05 15:31:15 fvdl Exp $     */
+/*     $NetBSD: linux_misc.c,v 1.84 2001/03/15 19:18:20 manu Exp $     */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -110,6 +110,7 @@
 #include <compat/linux/common/linux_misc.h>
 #include <compat/linux/common/linux_ptrace.h>
 #include <compat/linux/common/linux_reboot.h>
+#include <compat/linux/common/linux_emuldata.h>
 
 const int linux_ptrace_request_map[] = {
        LINUX_PTRACE_TRACEME,   PT_TRACE_ME,
@@ -231,18 +232,17 @@
        caddr_t oldbrk;
 
        oldbrk = vm->vm_daddr + ctob(vm->vm_dsize);
-       /*
-        * XXX inconsistent.. Linux always returns at least the old
-        * brk value, but it will be page-aligned if this fails,
-        * and possibly not page aligned if it succeeds (the user
-        * supplied pointer is returned).
-        */
+
        SCARG(&oba, nsize) = nbrk;
 
-       if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0)
+       if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0) {
+               ((struct linux_emuldata*)(p->p_emuldata))->p_break = (char*)nbrk;
                retval[0] = (register_t)nbrk;
-       else
-               retval[0] = (register_t)oldbrk;
+       }
+       else {
+               retval[0] = 
+                   (register_t)((struct linux_emuldata*)(p->p_emuldata))->p_break;
+       }
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index