kernel - prettier output for ipc errors, call names instead of trap numbers
This commit is contained in:
parent
98725c443e
commit
b05c989298
@ -8,6 +8,7 @@
|
|||||||
#define NOTIFY 4 /* asynchronous notify */
|
#define NOTIFY 4 /* asynchronous notify */
|
||||||
#define SENDNB 5 /* nonblocking send */
|
#define SENDNB 5 /* nonblocking send */
|
||||||
#define SENDA 16 /* asynchronous send */
|
#define SENDA 16 /* asynchronous send */
|
||||||
|
#define IPCNO_HIGHEST SENDA
|
||||||
|
|
||||||
/* Macros for IPC status code manipulation. */
|
/* Macros for IPC status code manipulation. */
|
||||||
#define IPC_STATUS_CALL_SHIFT 0
|
#define IPC_STATUS_CALL_SHIFT 0
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <minix/config.h>
|
#include <minix/config.h>
|
||||||
|
#include <minix/ipcconst.h>
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
#include "archconst.h"
|
#include "archconst.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -29,7 +30,7 @@ EXTERN struct proc *proc_ptr; /* pointer to currently running process */
|
|||||||
EXTERN struct proc *bill_ptr; /* process to bill for clock ticks */
|
EXTERN struct proc *bill_ptr; /* process to bill for clock ticks */
|
||||||
EXTERN struct proc *vmrequest; /* first process on vmrequest queue */
|
EXTERN struct proc *vmrequest; /* first process on vmrequest queue */
|
||||||
EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */
|
EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */
|
||||||
|
EXTERN char *ipc_call_names[IPCNO_HIGHEST+1]; /* human-readable call names */
|
||||||
|
|
||||||
/* Interrupt related variables. */
|
/* Interrupt related variables. */
|
||||||
EXTERN irq_hook_t irq_hooks[NR_IRQ_HOOKS]; /* hooks for general use */
|
EXTERN irq_hook_t irq_hooks[NR_IRQ_HOOKS]; /* hooks for general use */
|
||||||
|
|||||||
@ -255,6 +255,19 @@ PUBLIC int main(void)
|
|||||||
cycles_accounting_init();
|
cycles_accounting_init();
|
||||||
DEBUGEXTRA(("done\n"));
|
DEBUGEXTRA(("done\n"));
|
||||||
|
|
||||||
|
#define IPCNAME(n) { \
|
||||||
|
assert((n) >= 0 && (n) <= IPCNO_HIGHEST); \
|
||||||
|
assert(!ipc_call_names[n]); \
|
||||||
|
ipc_call_names[n] = #n; \
|
||||||
|
}
|
||||||
|
|
||||||
|
IPCNAME(SEND);
|
||||||
|
IPCNAME(RECEIVE);
|
||||||
|
IPCNAME(SENDREC);
|
||||||
|
IPCNAME(NOTIFY);
|
||||||
|
IPCNAME(SENDNB);
|
||||||
|
IPCNAME(SENDA);
|
||||||
|
|
||||||
assert(runqueues_ok());
|
assert(runqueues_ok());
|
||||||
|
|
||||||
switch_to_user();
|
switch_to_user();
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
|
#include <minix/ipcconst.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
@ -254,6 +255,7 @@ PRIVATE int do_sync_ipc(struct proc * caller_ptr, /* who made the call */
|
|||||||
{
|
{
|
||||||
int result; /* the system call's result */
|
int result; /* the system call's result */
|
||||||
int src_dst_p; /* Process slot number */
|
int src_dst_p; /* Process slot number */
|
||||||
|
char *callname;
|
||||||
|
|
||||||
/* Check destination. RECEIVE is the only call that accepts ANY (in addition
|
/* Check destination. RECEIVE is the only call that accepts ANY (in addition
|
||||||
* to a real endpoint). The other calls (SEND, SENDREC, and NOTIFY) require an
|
* to a real endpoint). The other calls (SEND, SENDREC, and NOTIFY) require an
|
||||||
@ -262,13 +264,24 @@ PRIVATE int do_sync_ipc(struct proc * caller_ptr, /* who made the call */
|
|||||||
*/
|
*/
|
||||||
assert(call_nr != SENDA);
|
assert(call_nr != SENDA);
|
||||||
|
|
||||||
|
/* Only allow non-negative call_nr values less than 32 */
|
||||||
|
if (call_nr < 0 || call_nr > IPCNO_HIGHEST || call_nr >= 32
|
||||||
|
|| !(callname = ipc_call_names[call_nr])) {
|
||||||
|
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||||
|
printf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
|
||||||
|
call_nr, proc_nr(caller_ptr), src_dst_p);
|
||||||
|
#endif
|
||||||
|
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
||||||
|
}
|
||||||
|
|
||||||
if (src_dst_e == ANY)
|
if (src_dst_e == ANY)
|
||||||
{
|
{
|
||||||
if (call_nr != RECEIVE)
|
if (call_nr != RECEIVE)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
printf("sys_call: trap %d by %d with bad endpoint %d\n",
|
printf("sys_call: %s by %d with bad endpoint %d\n",
|
||||||
call_nr, proc_nr(caller_ptr), src_dst_e);
|
callname,
|
||||||
|
proc_nr(caller_ptr), src_dst_e);
|
||||||
#endif
|
#endif
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
@ -279,8 +292,9 @@ PRIVATE int do_sync_ipc(struct proc * caller_ptr, /* who made the call */
|
|||||||
/* Require a valid source and/or destination process. */
|
/* Require a valid source and/or destination process. */
|
||||||
if(!isokendpt(src_dst_e, &src_dst_p)) {
|
if(!isokendpt(src_dst_e, &src_dst_p)) {
|
||||||
#if 0
|
#if 0
|
||||||
printf("sys_call: trap %d by %d with bad endpoint %d\n",
|
printf("sys_call: %s by %d with bad endpoint %d\n",
|
||||||
call_nr, proc_nr(caller_ptr), src_dst_e);
|
callname,
|
||||||
|
proc_nr(caller_ptr), src_dst_e);
|
||||||
#endif
|
#endif
|
||||||
return EDEADSRCDST;
|
return EDEADSRCDST;
|
||||||
}
|
}
|
||||||
@ -294,32 +308,23 @@ PRIVATE int do_sync_ipc(struct proc * caller_ptr, /* who made the call */
|
|||||||
if (!may_send_to(caller_ptr, src_dst_p)) {
|
if (!may_send_to(caller_ptr, src_dst_p)) {
|
||||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||||
printf(
|
printf(
|
||||||
"sys_call: ipc mask denied trap %d from %d to %d\n",
|
"sys_call: ipc mask denied %s from %d to %d\n",
|
||||||
call_nr, caller_ptr->p_endpoint, src_dst_e);
|
callname,
|
||||||
|
caller_ptr->p_endpoint, src_dst_e);
|
||||||
#endif
|
#endif
|
||||||
return(ECALLDENIED); /* call denied by ipc mask */
|
return(ECALLDENIED); /* call denied by ipc mask */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only allow non-negative call_nr values less than 32 */
|
|
||||||
if (call_nr < 0 || call_nr >= 32)
|
|
||||||
{
|
|
||||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
|
||||||
printf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
|
|
||||||
call_nr, proc_nr(caller_ptr), src_dst_p);
|
|
||||||
#endif
|
|
||||||
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the process has privileges for the requested call. Calls to the
|
/* Check if the process has privileges for the requested call. Calls to the
|
||||||
* kernel may only be SENDREC, because tasks always reply and may not block
|
* kernel may only be SENDREC, because tasks always reply and may not block
|
||||||
* if the caller doesn't do receive().
|
* if the caller doesn't do receive().
|
||||||
*/
|
*/
|
||||||
if (!(priv(caller_ptr)->s_trap_mask & (1 << call_nr))) {
|
if (!(priv(caller_ptr)->s_trap_mask & (1 << call_nr))) {
|
||||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||||
printf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
|
printf("sys_call: %s not allowed, caller %d, src_dst %d\n",
|
||||||
call_nr, proc_nr(caller_ptr), src_dst_p);
|
callname, proc_nr(caller_ptr), src_dst_p);
|
||||||
#endif
|
#endif
|
||||||
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
||||||
}
|
}
|
||||||
@ -327,7 +332,7 @@ PRIVATE int do_sync_ipc(struct proc * caller_ptr, /* who made the call */
|
|||||||
if (call_nr != SENDREC && call_nr != RECEIVE && iskerneln(src_dst_p)) {
|
if (call_nr != SENDREC && call_nr != RECEIVE && iskerneln(src_dst_p)) {
|
||||||
#if DEBUG_ENABLE_IPC_WARNINGS
|
#if DEBUG_ENABLE_IPC_WARNINGS
|
||||||
printf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
|
printf("sys_call: trap %d not allowed, caller %d, src_dst %d\n",
|
||||||
call_nr, proc_nr(caller_ptr), src_dst_e);
|
callname, proc_nr(caller_ptr), src_dst_e);
|
||||||
#endif
|
#endif
|
||||||
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
return(ETRAPDENIED); /* trap denied by mask or kernel */
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user