mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 11:53:15 +01:00
Flushing pages to vfs will work, but the issue is that while vfs is
serving mm0, if it page faults, system deadlocks because mm0 is waiting to be served by vfs. FIX: To fix this, mm0 will need to fork itself and keep a separate thread solely for page fault handling.
This commit is contained in:
@@ -55,6 +55,8 @@ int vfs_read(unsigned long vnum, unsigned long file_offset,
|
||||
{
|
||||
int err;
|
||||
|
||||
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, vnum);
|
||||
@@ -90,6 +92,8 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
|
||||
struct vm_file *vmfile;
|
||||
struct tcb *t;
|
||||
|
||||
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
|
||||
/* Check argument validity */
|
||||
if (sender != VFS_TID) {
|
||||
l4_ipc_return(-EPERM);
|
||||
@@ -214,6 +218,7 @@ int vfs_write(unsigned long vnum, unsigned long file_offset,
|
||||
{
|
||||
int err;
|
||||
|
||||
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, vnum);
|
||||
@@ -241,6 +246,7 @@ int vfs_close(l4id_t sender, int fd)
|
||||
{
|
||||
int err;
|
||||
|
||||
printf("%s/%s Sending to %d\n", __TASKNAME__, __FUNCTION__, VFS_TID);
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, sender);
|
||||
@@ -250,6 +256,7 @@ int vfs_close(l4id_t sender, int fd)
|
||||
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
|
||||
return err;
|
||||
}
|
||||
printf("%s/%s Received from %d\n", __TASKNAME__, __FUNCTION__, VFS_TID);
|
||||
|
||||
/* Check if syscall was successful */
|
||||
if ((err = l4_get_retval()) < 0) {
|
||||
@@ -267,6 +274,7 @@ int vfs_update_file_stats(struct vm_file *f)
|
||||
{
|
||||
int err;
|
||||
|
||||
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
|
||||
l4_save_ipcregs();
|
||||
|
||||
write_mr(L4SYS_ARG0, vm_file_to_vnum(f));
|
||||
@@ -373,7 +381,7 @@ int sys_close(l4id_t sender, int fd)
|
||||
l4_ipc_return(retval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Close the file descriptor. */
|
||||
retval = fd_close(sender, fd);
|
||||
printf("%s: Closed fd %d. Returning %d\n",
|
||||
@@ -454,6 +462,7 @@ copy:
|
||||
copy_offset = (unsigned long)buf;
|
||||
page_copy(head, task_virt_to_page(task, copy_offset),
|
||||
cursor_offset, copy_offset & PAGE_MASK, copysize);
|
||||
head->flags |= VM_DIRTY;
|
||||
left -= copysize;
|
||||
last_pgoff = head->offset;
|
||||
|
||||
@@ -473,6 +482,7 @@ copy:
|
||||
|
||||
page_copy(this, task_virt_to_page(task, copy_offset),
|
||||
0, 0, copysize);
|
||||
this->flags |= VM_DIRTY;
|
||||
left -= copysize;
|
||||
last_pgoff = this->offset;
|
||||
}
|
||||
|
||||
@@ -84,9 +84,15 @@ int file_page_out(struct vm_object *vm_obj, unsigned long page_offset)
|
||||
if (!(page->flags & VM_DIRTY))
|
||||
return 0;
|
||||
|
||||
paddr = (void *)page_to_phys(page);
|
||||
vaddr = phys_to_virt(paddr);
|
||||
|
||||
/* Map the page to vfs task */
|
||||
l4_map(paddr, vaddr, 1, MAP_USR_RW_FLAGS, VFS_TID);
|
||||
|
||||
printf("%s/%s: Writing to vnode %d, at pgoff 0x%x, %d pages, buf at 0x%x\n",
|
||||
__TASKNAME__, __FUNCTION__, vm_file_to_vnum(f), page_offset, 1, vaddr);
|
||||
|
||||
/* Syscall to vfs to write page back to file. */
|
||||
if ((err = vfs_write(vm_file_to_vnum(f), page_offset, 1, vaddr)) < 0)
|
||||
goto out_err;
|
||||
|
||||
Reference in New Issue
Block a user