Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/uvm Pull up following revision(s) (requested by riast...



details:   https://anonhg.NetBSD.org/src/rev/94c85121b1a7
branches:  netbsd-8
changeset: 374120:94c85121b1a7
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Apr 01 16:01:52 2023 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1815):

        sys/uvm/uvm_map.c: revision 1.395

uvm(9): Fix 19-year-old bug in assertion about mmap hint.

Previously this would _first_ remember the original hint, and _then_
clamp the hint to the VM map's range:

        orig_hint = hint;
        if (hint < vm_map_min(map)) {   /* check ranges ... */
                if (flags & UVM_FLAG_FIXED) {
                        UVMHIST_LOG(maphist,"<- VA below map range",0,0,0,0);
                        return (NULL);
                }
                hint = vm_map_min(map);
        ...
        KASSERTMSG(!topdown || hint <= orig_hint, "hint: %#jx, orig_hint: %#jx",
            (uintmax_t)hint, (uintmax_t)orig_hint);

Even if nothing else happens in the ellipsis, taking the branch
guarantees the assertion will fail in the topdown case.

diffstat:

 sys/uvm/uvm_map.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (49 lines):

diff -r 730a777139f6 -r 94c85121b1a7 sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Apr 01 15:56:12 2023 +0000
+++ b/sys/uvm/uvm_map.c Sat Apr 01 16:01:52 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.351.2.3 2019/08/04 11:08:51 martin Exp $ */
+/*     $NetBSD: uvm_map.c,v 1.351.2.4 2023/04/01 16:01:52 martin Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.351.2.3 2019/08/04 11:08:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.351.2.4 2023/04/01 16:01:52 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -1877,12 +1877,17 @@ uvm_map_findspace(struct vm_map *map, va
        uvm_map_check(map, "map_findspace entry");
 
        /*
-        * remember the original hint.  if we are aligning, then we
-        * may have to try again with no alignment constraint if
-        * we fail the first time.
+        * Clamp the hint to the VM map's min/max address, and remmeber
+        * the clamped original hint.  Remember the original hint,
+        * clamped to the min/max address.  If we are aligning, then we
+        * may have to try again with no alignment constraint if we
+        * fail the first time.
+        *
+        * We use the original hint to verify later that the search has
+        * been monotonic -- that is, nonincreasing or nondecreasing,
+        * according to topdown or !topdown respectively.  But the
+        * clamping is not monotonic.
         */
-
-       orig_hint = hint;
        if (hint < vm_map_min(map)) {   /* check ranges ... */
                if (flags & UVM_FLAG_FIXED) {
                        UVMHIST_LOG(maphist,"<- VA below map range",0,0,0,0);
@@ -1895,6 +1900,7 @@ uvm_map_findspace(struct vm_map *map, va
                    hint, vm_map_min(map), vm_map_max(map), 0);
                return (NULL);
        }
+       orig_hint = hint;
 
        /*
         * Look for the first possible address; if there's already



Home | Main Index | Thread Index | Old Index