From 08667f6dc1f81b1520431caf616d5bbb9dcdfad0 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Fri, 31 Oct 2003 07:29:28 +0000 Subject: [PATCH] Fix two bugs introduced with the rstack functionality and specific to the rstack functionality: 1. Fix a KASSERT that tests for the address to be above the upward growable stack. Typically for rstack, the faulting address can be identical to the record end of the upward growable entry, and very likely is on ia64. The KASSERT tested for greater than, not greater equal, so whenever the register stack had to be grown the assertion fired. 2. When we grow the upward growable stack entry and adjust the unlying object, don't forget to adjust the size of the VM map. Not doing so would trigger an assert in vm_mapzdtor(). Pointy hat: marcel (for not testing with INVARIANTS). --- sys/vm/vm_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 1f04ac84fe67..b09f4ee0a7ea 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2681,7 +2681,7 @@ vm_map_growstack(struct proc *p, vm_offset_t addr) max_grow = stack_entry->start - end; } else { KASSERT(stack_entry->eflags & MAP_ENTRY_GROWS_UP, ("foo")); - KASSERT(addr > stack_entry->end, ("foo")); + KASSERT(addr >= stack_entry->end, ("foo")); end = (next_entry != &map->header) ? next_entry->start : stack_entry->end + stack_entry->avail_ssize; grow_amount = roundup(addr + 1 - stack_entry->end, PAGE_SIZE); @@ -2800,6 +2800,7 @@ vm_map_growstack(struct proc *p, vm_offset_t addr) OFF_TO_IDX(stack_entry->offset), (vm_size_t)(stack_entry->end - stack_entry->start), (vm_size_t)grow_amount)) { + map->size += (addr - stack_entry->end); /* Update the current entry. */ stack_entry->end = addr; rv = KERN_SUCCESS;