From: Philip Homburg Date: Mon, 10 Jul 2006 12:27:26 +0000 (+0000) Subject: Added do_readbios. Added debugging output for unexpected use of unsafe copy X-Git-Tag: v3.1.3~265 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch10.html?a=commitdiff_plain;h=6f4091eb8c4c94d9486b6cc7013304414a27f857;p=minix.git Added do_readbios. Added debugging output for unexpected use of unsafe copy functions. --- diff --git a/kernel/system.c b/kernel/system.c index 5520bfcdb..6f7648e91 100755 --- a/kernel/system.c +++ b/kernel/system.c @@ -180,6 +180,7 @@ PRIVATE void initialize(void) map(SYS_SAFECOPYFROM, do_safecopy); /* copy with pre-granted permission */ map(SYS_SAFECOPYTO, do_safecopy); /* copy with pre-granted permission */ map(SYS_VSAFECOPY, do_vsafecopy); /* vectored safecopy */ + map(SYS_READBIOS, do_readbios); /* read from BIOS locations */ /* Clock functionality. */ map(SYS_TIMES, do_times); /* get uptime and process times */ diff --git a/kernel/system.h b/kernel/system.h index 452ca2543..857689f7f 100644 --- a/kernel/system.h +++ b/kernel/system.h @@ -177,6 +177,7 @@ _PROTOTYPE( int do_safecopy, (message *m_ptr) ); _PROTOTYPE( int do_vsafecopy, (message *m_ptr) ); _PROTOTYPE( int do_iopenable, (message *m_ptr) ); _PROTOTYPE( int do_setgrant, (message *m_ptr) ); +_PROTOTYPE( int do_readbios, (message *m_ptr) ); #endif /* SYSTEM_H */ diff --git a/kernel/system/Makefile b/kernel/system/Makefile index 9c873ee57..f94a4d46a 100644 --- a/kernel/system/Makefile +++ b/kernel/system/Makefile @@ -42,6 +42,7 @@ OBJECTS = \ $(SYSTEM)(do_getksig.o) \ $(SYSTEM)(do_endksig.o) \ $(SYSTEM)(do_kill.o) \ + $(SYSTEM)(do_readbios.o) \ $(SYSTEM)(do_sigsend.o) \ $(SYSTEM)(do_sigreturn.o) \ $(SYSTEM)(do_abort.o) \ @@ -138,6 +139,9 @@ $(SYSTEM)(do_getinfo.o): do_getinfo.c $(SYSTEM)(do_abort.o): do_abort.c $(CC) do_abort.c +$(SYSTEM)(do_readbios.o): do_readbios.c + $(CC) do_readbios.c + $(SYSTEM)(do_setgrant.o): do_setgrant.c $(CC) do_setgrant.c diff --git a/kernel/system/do_copy.c b/kernel/system/do_copy.c index 177cc610e..716ec1a85 100644 --- a/kernel/system/do_copy.c +++ b/kernel/system/do_copy.c @@ -30,6 +30,23 @@ register message *m_ptr; /* pointer to request message */ phys_bytes bytes; /* number of bytes to copy */ int i; + if (m_ptr->m_source != 0 && m_ptr->m_source != 1 && + m_ptr->m_source != 2 && m_ptr->m_source != 3) + { + static int first=1; + if (first) + { + first= 0; + kprintf( +"do_copy: got request from %d (source %d, seg %d, destination %d, seg %d)\n", + m_ptr->m_source, + m_ptr->CP_SRC_ENDPT, + m_ptr->CP_SRC_SPACE, + m_ptr->CP_DST_ENDPT, + m_ptr->CP_DST_SPACE); + } + } + /* Dismember the command message. */ vir_addr[_SRC_].proc_nr_e = m_ptr->CP_SRC_ENDPT; vir_addr[_SRC_].segment = m_ptr->CP_SRC_SPACE; diff --git a/kernel/system/do_readbios.c b/kernel/system/do_readbios.c new file mode 100644 index 000000000..94849fe6a --- /dev/null +++ b/kernel/system/do_readbios.c @@ -0,0 +1,39 @@ +/* The kernel call implemented in this file: + * m_type: SYS_READBIOS + * + * The parameters for this kernel call are: + * m2_i1: RDB_SIZE number of bytes to copy + * m2_l1: RDB_ADDR absolute address in BIOS area + * m2_p1: RDB_BUF buffer address in requesting process + */ + +#include "../system.h" +#include + +/*===========================================================================* + * do_readbios * + *===========================================================================*/ +PUBLIC int do_readbios(m_ptr) +register message *m_ptr; /* pointer to request message */ +{ + int proc_nr; + struct proc *p; + phys_bytes address, phys_buf, phys_bios; + vir_bytes buf; + size_t size; + + address = m_ptr->RDB_ADDR; + buf = (vir_bytes)m_ptr->RDB_BUF; + size = m_ptr->RDB_SIZE; + + okendpt(m_ptr->m_source, &proc_nr); + p = proc_addr(proc_nr); + phys_buf = umap_local(p, D, buf, size); + if (phys_buf == 0) + return EFAULT; + phys_bios = umap_bios(p, address, size); + if (phys_bios == 0) + return EPERM; + phys_copy(phys_bios, phys_buf, size); + return 0; +} diff --git a/kernel/system/do_sdevio.c b/kernel/system/do_sdevio.c index dad932a23..658d81b0e 100644 --- a/kernel/system/do_sdevio.c +++ b/kernel/system/do_sdevio.c @@ -28,6 +28,16 @@ register message *m_ptr; /* pointer to request message */ phys_bytes phys_buf; int req_type, req_dir; + if ((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) != _DIO_SAFE) + { + static int first= 1; + if (first) + { + first= 0; + kprintf("do_sdevio: for %d\n", m_ptr->m_source); + } + } + /* Check if process endpoint is OK. * A driver may directly provide a pointer to a buffer at the user-process * that initiated the device I/O. Kernel processes, of course, are denied. diff --git a/kernel/system/do_vcopy.c b/kernel/system/do_vcopy.c index f6db0fd67..efdc7f65c 100644 --- a/kernel/system/do_vcopy.c +++ b/kernel/system/do_vcopy.c @@ -33,6 +33,14 @@ register message *m_ptr; /* pointer to request message */ int i,s; struct vir_cp_req *req; + { static int first=1; + if (first) + { + first= 0; + kprintf("do_vcopy: got request from %d\n", m_ptr->m_source); + } + } + /* Check if request vector size is ok. */ nr_req = (unsigned) m_ptr->VCP_VEC_SIZE; if (nr_req > VCOPY_VEC_SIZE) return(EINVAL);