mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Utcbs of exiting children are successfully unmapped from vfs via sys_shmdt
The shared memory addresses are returned back to their pools via the deletion function of such objects. They don't get released via do_munmap().
This commit is contained in:
@@ -51,7 +51,7 @@ int sys_unmap(syscall_context_t *regs)
|
||||
unsigned long npages = regs->r1;
|
||||
unsigned int tid = regs->r2;
|
||||
struct ktcb *target;
|
||||
int ret, retval;
|
||||
int ret = 0, retval = 0;
|
||||
|
||||
if (tid == current->tid)
|
||||
target = current;
|
||||
|
||||
@@ -83,6 +83,7 @@ int sys_fork(struct tcb *parent)
|
||||
/* Create and prefault a utcb for child and map it to vfs task */
|
||||
utcb_map_to_task(child, find_task(VFS_TID),
|
||||
UTCB_NEW_ADDRESS | UTCB_NEW_SHM | UTCB_PREFAULT);
|
||||
// printf("Mapped 0x%p to vfs as utcb of %d\n", child->utcb, child->tid);
|
||||
|
||||
/* We can now notify vfs about forked process */
|
||||
vfs_notify_fork(child, parent);
|
||||
|
||||
@@ -182,13 +182,13 @@ void shm_destroy_priv_data(struct vm_file *shm_file)
|
||||
|
||||
/* Release the shared memory address */
|
||||
if ((unsigned long)shm_desc->shm_addr >= UTCB_AREA_START &&
|
||||
(unsigned long)shm_desc->shm_addr < UTCB_AREA_END)
|
||||
utcb_delete_address(shm_desc->shm_addr);
|
||||
else if ((unsigned long)shm_desc->shm_addr >= SHM_AREA_START &&
|
||||
(unsigned long)shm_desc->shm_addr < SHM_AREA_END)
|
||||
shm_delete_address(shm_desc->shm_addr,
|
||||
shm_file->vm_obj.npages);
|
||||
else
|
||||
(unsigned long)shm_desc->shm_addr < UTCB_AREA_END) {
|
||||
BUG_ON(utcb_delete_address(shm_desc->shm_addr) < 0);
|
||||
} else if ((unsigned long)shm_desc->shm_addr >= SHM_AREA_START &&
|
||||
(unsigned long)shm_desc->shm_addr < SHM_AREA_END) {
|
||||
BUG_ON(shm_delete_address(shm_desc->shm_addr,
|
||||
shm_file->vm_obj.npages) < 0);
|
||||
} else
|
||||
BUG();
|
||||
|
||||
/* Release the shared memory id */
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <task.h>
|
||||
#include <shm.h>
|
||||
#include <vm_area.h>
|
||||
#include <syscalls.h>
|
||||
#include INC_GLUE(memlayout.h)
|
||||
|
||||
static struct address_pool utcb_vaddr_pool;
|
||||
@@ -102,5 +103,5 @@ int utcb_map_to_task(struct tcb *owner, struct tcb *mapper, unsigned int flags)
|
||||
|
||||
int utcb_unmap_from_task(struct tcb *owner, struct tcb *mapper)
|
||||
{
|
||||
return 0;
|
||||
return sys_shmdt(mapper, owner->utcb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user