diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-09 19:24:12 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-09 19:24:12 +0300 |
| commit | 89d7cf197b2cae130565467bdfad5d5ef5fed2dd (patch) | |
| tree | 1cff68c3997bfa237b48aa499d45a3700d40e73e /src/vmem.c | |
| parent | 298636079d912d0936f8156a609fe74b839c547b (diff) | |
| download | kmi-89d7cf197b2cae130565467bdfad5d5ef5fed2dd.tar.gz kmi-89d7cf197b2cae130565467bdfad5d5ef5fed2dd.zip | |
allow regions to have reserved areas
+ A reserved area is an area at the start of the region that should not
be used unless explicitly asked for, for example null pages.
As such, a small correction to my previous commit message: There's no
danger in not locking req_mem() etc, as a null page will only be
allocated when explicitly asked for.
Diffstat (limited to 'src/vmem.c')
| -rw-r--r-- | src/vmem.c | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -18,19 +18,10 @@ stat_t init_uvmem(struct tcb *t) { t->uvmem.owner = t->tid; t->uvmem.vmem = t->proc.vmem; - - stat_t ret = OK; - if ((ret = init_region(&t->uvmem.region, UVMEM_START, UVMEM_END))) - return ret; - - /* if a user really wants to use the first page for something, they'll - * have to free it first, 'accepting' that no null-page is dangerous. */ - size_t size = 0; - vm_t v = alloc_fixed_region(&t->uvmem.region, - UVMEM_START, BASE_PAGE_SIZE, &size, - MR_NONBACKED); - assert(v == UVMEM_START && size == BASE_PAGE_SIZE); - return OK; + /* reserve 64KiB (arbitrary number but should be large enough that + * nobody accidentally indexes above NULL enough to find real memory) */ + return init_region(&t->uvmem.region, UVMEM_START, + UVMEM_END - UVMEM_START, SZ_64K); } /** @@ -132,8 +123,8 @@ static vm_t __clone_shared_region(struct tcb *d, struct tcb *s, if (ERR_CODE(v)) return v; - stat_t res = clone_region(d->uvmem.vmem, s->uvmem.vmem, start, v, size, - flags); + stat_t res = clone_region(d->uvmem.vmem, s->uvmem.vmem, + start, v, size, flags); if (res == OK) return v; |
