quick hack (sorry) for making *sdevio* work to other
processes than the caller.. also disable kernel sanity checks
This commit is contained in:
parent
8a0ab8630c
commit
01732ffb5e
@ -32,6 +32,10 @@ register message *m_ptr; /* pointer to request message */
|
||||
struct proc *rp;
|
||||
struct priv *privp;
|
||||
struct io_range *iorp;
|
||||
int rem;
|
||||
static char zero[4096];
|
||||
vir_bytes addr;
|
||||
struct proc *destproc;
|
||||
|
||||
/* Allow safe copies and accesses to SELF */
|
||||
if ((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) != _DIO_SAFE &&
|
||||
@ -63,12 +67,26 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
/* Check for 'safe' variants. */
|
||||
if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) {
|
||||
vir_bytes newoffset;
|
||||
endpoint_t newep;
|
||||
/* Map grant address to physical address. */
|
||||
if ((phys_buf = umap_verify_grant(proc_addr(proc_nr), who_e,
|
||||
if(verify_grant(proc_nr_e, who_e,
|
||||
(vir_bytes) m_ptr->DIO_VEC_ADDR,
|
||||
(vir_bytes) m_ptr->DIO_OFFSET, count,
|
||||
req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ)) == 0)
|
||||
return(EPERM);
|
||||
count,
|
||||
req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ,
|
||||
(vir_bytes) m_ptr->DIO_OFFSET,
|
||||
&newoffset, &newep) != OK) {
|
||||
printf("do_sdevio: verify_grant failed\n");
|
||||
return EPERM;
|
||||
}
|
||||
if(!isokendpt(newep, &proc_nr))
|
||||
return(EINVAL);
|
||||
destproc = proc_addr(proc_nr);
|
||||
if ((phys_buf = umap_local(destproc, D,
|
||||
(vir_bytes) newoffset, count)) == 0) {
|
||||
printf("do_sdevio: umap_local failed\n");
|
||||
return(EFAULT);
|
||||
}
|
||||
} else {
|
||||
if(proc_nr != who_p)
|
||||
{
|
||||
@ -80,12 +98,24 @@ register message *m_ptr; /* pointer to request message */
|
||||
if ((phys_buf = umap_local(proc_addr(proc_nr), D,
|
||||
(vir_bytes) m_ptr->DIO_VEC_ADDR, count)) == 0)
|
||||
return(EFAULT);
|
||||
destproc = proc_addr(proc_nr);
|
||||
}
|
||||
/* current process must be target for phys_* to be OK */
|
||||
if(proc_addr(proc_nr) != ptproc) {
|
||||
kprintf("do_sdevio: wrong process\n");
|
||||
return EIO;
|
||||
}
|
||||
|
||||
vm_set_cr3(destproc);
|
||||
rem = count;
|
||||
addr = m_ptr->DIO_VEC_ADDR;
|
||||
while(rem > 0) {
|
||||
int r;
|
||||
int chunk;
|
||||
chunk = rem > sizeof(zero) ? sizeof(zero) : rem;
|
||||
if((r=data_copy_vmcheck(SYSTEM, zero, destproc->p_endpoint,
|
||||
addr, chunk)) != OK) {
|
||||
return r;
|
||||
}
|
||||
addr += chunk;
|
||||
rem -= chunk;
|
||||
}
|
||||
|
||||
switch (io_type)
|
||||
{
|
||||
|
@ -37,7 +37,6 @@ PUBLIC u32_t dirtypde;
|
||||
#define HASPT(procptr) ((procptr)->p_seg.p_cr3 != 0)
|
||||
|
||||
FORWARD _PROTOTYPE( u32_t phys_get32, (vir_bytes v) );
|
||||
FORWARD _PROTOTYPE( void vm_set_cr3, (struct proc *pr) );
|
||||
FORWARD _PROTOTYPE( void set_cr3, (void) );
|
||||
FORWARD _PROTOTYPE( void vm_enable_paging, (void) );
|
||||
|
||||
@ -212,7 +211,7 @@ phys_bytes addr;
|
||||
|
||||
PRIVATE u32_t vm_cr3; /* temp arg to level0() func */
|
||||
|
||||
PRIVATE void vm_set_cr3(struct proc *newptproc)
|
||||
PUBLIC void vm_set_cr3(struct proc *newptproc)
|
||||
{
|
||||
int u = 0;
|
||||
if(!intr_disabled()) { lock; u = 1; }
|
||||
|
@ -53,6 +53,7 @@ _PROTOTYPE( void i386_updatepde, (int pde, u32_t val));
|
||||
_PROTOTYPE( void i386_freepde, (int pde));
|
||||
_PROTOTYPE( void getcr3val, (void));
|
||||
_PROTOTYPE( void switchedcr3, (void));
|
||||
_PROTOTYPE( void vm_set_cr3, (struct proc *));
|
||||
|
||||
|
||||
/* exception.c */
|
||||
|
@ -25,10 +25,10 @@
|
||||
#define DEBUG_TIME_LOCKS 1
|
||||
|
||||
/* Runtime sanity checking. */
|
||||
#define DEBUG_VMASSERT 1
|
||||
#define DEBUG_SCHED_CHECK 1
|
||||
#define DEBUG_STACK_CHECK 1
|
||||
#define DEBUG_TRACE 1
|
||||
#define DEBUG_VMASSERT 0
|
||||
#define DEBUG_SCHED_CHECK 0
|
||||
#define DEBUG_STACK_CHECK 0
|
||||
#define DEBUG_TRACE 0
|
||||
|
||||
#if DEBUG_TRACE
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user