User pointer validity checks.

Added routines that check whether a user pointer is accessible by the kernel,
and if not ask the pager to map-in those pages. I haven't implemented yet the
bit that asks the pager for paging-in.
This commit is contained in:
Bahadir Balban
2008-02-05 15:41:14 +00:00
parent 3a07ae70fd
commit a82cdd3456
8 changed files with 155 additions and 72 deletions

38
src/generic/space.c Normal file
View File

@@ -0,0 +1,38 @@
/*
* Addess space related routines.
*
* Copyright (C) 2008 Bahadir Balban
*/
#include INC_GLUE(memory.h)
#include INC_GLUE(memlayout.h)
#include INC_ARCH(exception.h)
#include <l4/generic/space.h>
#include <l4/api/space.h>
#include <l4/api/errno.h>
/*
* Checks whether the given user address is a valid userspace address.
* If so, whether it is currently mapped into its own address space.
* If its not mapped-in, it generates a page-in request to the thread's
* pager. If fault hasn't cleared, aborts.
*/
int check_access(unsigned long vaddr, unsigned long size, unsigned int flags)
{
int err;
/* Do not allow ridiculously big sizes */
if (size >= USER_AREA_SIZE)
return -EINVAL;
/* Check if in user range, but this is more up to the pager to decide */
if (!(vaddr >= USER_AREA_START && vaddr < USER_AREA_END))
return -EINVAL;
/* If not mapped, ask pager whether this is possible */
if (!check_mapping(vaddr, size, flags))
if((err = pager_pagein_request(vaddr, size, flags)) < 0)
return err;
return 0;
}