- enable remembering of device memory ranges set by PCI and

told to kernel
  - makes VM ask the kernel if a certain process is allowed
    to map in a range of physical memory (VM rounds it to page
    boundaries afterwards - but it's impossible to map anything
    smaller otherwise so I assume this is safe, i.e. there won't
    be anything else in that page; certainly no regular memory)
  - VM permission check cleanup (no more hardcoded calls, less
    hardcoded logic, more readable main loop), a loose end left
    by GQ
  - remove do_copy warning, as the ipc server triggers this but
    it's no more harmful than the special cases already excluded
    explicitly (VFS, PM, etc).
This commit is contained in:
Ben Gras
2009-11-03 11:12:23 +00:00
parent 56d485c1d6
commit 7e73260cf5
10 changed files with 138 additions and 67 deletions

View File

@@ -31,6 +31,7 @@ register message *m_ptr; /* pointer to request message */
phys_bytes bytes; /* number of bytes to copy */
int i;
#if 0
if (m_ptr->m_source != PM_PROC_NR && m_ptr->m_source != VFS_PROC_NR &&
m_ptr->m_source != RS_PROC_NR && m_ptr->m_source != MEM_PROC_NR &&
m_ptr->m_source != VM_PROC_NR)
@@ -48,6 +49,7 @@ register message *m_ptr; /* pointer to request message */
m_ptr->CP_DST_SPACE);
}
}
#endif
/* Dismember the command message. */
vir_addr[_SRC_].proc_nr_e = m_ptr->CP_SRC_ENDPT;

View File

@@ -27,7 +27,6 @@ message *m_ptr; /* pointer to request message */
*/
register struct proc *caller_ptr;
register struct proc *rp;
register struct priv *sp;
int proc_nr;
int priv_id;
int i, r;
@@ -198,16 +197,14 @@ message *m_ptr; /* pointer to request message */
if((r=data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &mem_range, sizeof(mem_range))) != OK)
return r;
priv(rp)->s_flags |= CHECK_MEM; /* Check I/O accesses */
priv(rp)->s_flags |= CHECK_MEM; /* Check memory mappings */
i= priv(rp)->s_nr_mem_range;
if (i >= NR_MEM_RANGE)
return ENOMEM;
#if 0
priv(rp)->s_mem_tab[i].mr_base= mem_range.mr_base;
priv(rp)->s_mem_tab[i].mr_limit= mem_range.mr_limit;
priv(rp)->s_nr_mem_range++;
#endif
return OK;
@@ -230,6 +227,28 @@ message *m_ptr; /* pointer to request message */
priv(rp)->s_nr_irq++;
return OK;
case SYS_PRIV_QUERY_MEM:
{
phys_bytes addr, limit;
struct priv *sp;
/* See if a certain process is allowed to map in certain physical
* memory.
*/
addr = (phys_bytes) m_ptr->CTL_PHYSSTART;
limit = addr + (phys_bytes) m_ptr->CTL_PHYSLEN - 1;
if(limit < addr)
return EPERM;
if(!(sp = priv(rp)))
return EPERM;
if (!(sp->s_flags & SYS_PROC))
return EPERM;
for(i = 0; i < sp->s_nr_mem_range; i++) {
if(addr >= sp->s_mem_tab[i].mr_base &&
limit <= sp->s_mem_tab[i].mr_limit)
return OK;
}
return EPERM;
}
default:
kprintf("do_privctl: bad request %d\n", m_ptr->CTL_REQUEST);
return EINVAL;