Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm uvm_mapent_trymerge: add missing checks.



details:   https://anonhg.NetBSD.org/src/rev/9437e3fd679e
branches:  trunk
changeset: 580968:9437e3fd679e
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue May 17 21:45:24 2005 +0000

description:
uvm_mapent_trymerge: add missing checks.

diffstat:

 sys/uvm/uvm_map.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (66 lines):

diff -r bd429b521436 -r 9437e3fd679e sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Tue May 17 19:22:19 2005 +0000
+++ b/sys/uvm/uvm_map.c Tue May 17 21:45:24 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.194 2005/05/17 13:55:33 yamt Exp $       */
+/*     $NetBSD: uvm_map.c,v 1.195 2005/05/17 21:45:24 yamt Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.194 2005/05/17 13:55:33 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.195 2005/05/17 21:45:24 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -4374,6 +4374,7 @@
        struct uvm_object *uobj;
        struct vm_map_entry *next;
        struct vm_map_entry *prev;
+       vsize_t size;
        int merged = 0;
        boolean_t copying;
        int newetype;
@@ -4389,6 +4390,7 @@
        }
 
        uobj = entry->object.uvm_obj;
+       size = entry->end - entry->start;
        copying = (flags & UVM_MERGE_COPYING) != 0;
        newetype = copying ? (entry->etype & ~UVM_ET_NEEDSCOPY) : entry->etype;
 
@@ -4401,12 +4403,12 @@
            UVM_ET_ISCOMPATIBLE(next, newetype,
            uobj, entry->flags, entry->protection,
            entry->max_protection, entry->inheritance, entry->advice,
-           entry->wired_count)) {
+           entry->wired_count) &&
+           (uobj == NULL || entry->offset + size == next->offset)) {
                int error;
 
                if (copying) {
-                       error = amap_extend(next,
-                           entry->end - entry->start,
+                       error = amap_extend(next, size,
                            AMAP_EXTEND_NOWAIT|AMAP_EXTEND_BACKWARDS);
                } else {
                        error = 0;
@@ -4437,12 +4439,12 @@
            UVM_ET_ISCOMPATIBLE(prev, newetype,
            uobj, entry->flags, entry->protection,
            entry->max_protection, entry->inheritance, entry->advice,
-           entry->wired_count)) {
+           entry->wired_count) &&
+           (uobj == NULL || prev->offset + size == entry->offset)) {
                int error;
 
                if (copying) {
-                       error = amap_extend(prev,
-                           entry->end - entry->start,
+                       error = amap_extend(prev, size,
                            AMAP_EXTEND_NOWAIT|AMAP_EXTEND_FORWARDS);
                } else {
                        error = 0;



Home | Main Index | Thread Index | Old Index