Changeset cd1ecf11 in mainline for kernel/generic/src/mm/as.c


Ignore:
Timestamp:
2018-11-07T17:14:45Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6785b88b
Parents:
d9d0088
Message:

Fix guard pages: should have one guard page before, one guard page after.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    rd9d0088 rcd1ecf11  
    324324 *
    325325 * @return True if the two areas conflict, false otherwise.
    326  *
    327326 */
    328327NO_TRACE static bool area_is_conflicting(uintptr_t addr,
     
    331330        assert((addr % PAGE_SIZE) == 0);
    332331
    333         /* Add guard page size unless area is at the end of VA domain */
    334332        size_t gsize = P2SZ(count);
    335         if (guarded && !overflows(addr, P2SZ(count)))
    336                 gsize += PAGE_SIZE;
    337 
    338         /* Add guard page size unless area is at the end of VA domain */
    339         size_t agsize = P2SZ(area->pages);
    340         if ((area->flags & AS_AREA_GUARD) != 0 &&
    341             !overflows(area->base, P2SZ(area->pages)))
    342                 agsize += PAGE_SIZE;
     333        size_t agsize = P2SZ(area->pages);
     334
     335        /*
     336         * A guarded area has one guard page before, one page after.
     337         * What we do here is: if either area is guarded, we add
     338         * PAGE_SIZE to the size of both areas. That guarantees
     339         * they will be spaced at least one page apart.
     340         */
     341        if (guarded || (area->flags & AS_AREA_GUARD) != 0) {
     342                /* Add guard page size unless area is at the end of VA domain */
     343                if (!overflows(addr, P2SZ(count)))
     344                        gsize += PAGE_SIZE;
     345
     346                /* Add guard page size unless area is at the end of VA domain */
     347                if (!overflows(area->base, P2SZ(area->pages)))
     348                        agsize += PAGE_SIZE;
     349        }
    343350
    344351        return overlaps(addr, gsize, area->base, agsize);
Note: See TracChangeset for help on using the changeset viewer.