svn commit: r205248 - user/jmallett/octeon/sys/mips/mips

Juli Mallett jmallett at FreeBSD.org
Wed Mar 17 08:56:14 UTC 2010


Author: jmallett
Date: Wed Mar 17 08:56:13 2010
New Revision: 205248
URL: http://svn.freebsd.org/changeset/base/205248

Log:
  As with page faults, for now emit something in the log about reserved
  instructions.
  
  Sponsored by:	Packet Forensics

Modified:
  user/jmallett/octeon/sys/mips/mips/trap.c

Modified: user/jmallett/octeon/sys/mips/mips/trap.c
==============================================================================
--- user/jmallett/octeon/sys/mips/mips/trap.c	Wed Mar 17 08:55:29 2010	(r205247)
+++ user/jmallett/octeon/sys/mips/mips/trap.c	Wed Mar 17 08:56:13 2010	(r205248)
@@ -104,6 +104,7 @@ int trap_debug = 1;
 
 extern unsigned onfault_table[];
 
+static void log_reserved_instruction(struct trapframe *);
 static void log_bad_page_fault(char *, struct trapframe *, int);
 static void log_frame_dump(struct trapframe *frame);
 static void get_mapping_info(vm_offset_t, pd_entry_t **, pt_entry_t **);
@@ -883,6 +884,7 @@ dofault:
 		}
 
 	case T_RES_INST + T_USER:
+		log_reserved_instruction(trapframe);
 		i = SIGILL;
 		addr = trapframe->pc;
 		break;
@@ -1306,6 +1308,50 @@ get_mapping_info(vm_offset_t va, pd_entr
 	*ptepp = ptep;
 }
 
+static void
+log_reserved_instruction(struct trapframe *frame)
+{
+	pt_entry_t *ptep;
+	pd_entry_t *pdep;
+	unsigned int *addr;
+	struct proc *p = curproc;
+	register_t pc;
+
+#ifdef SMP
+	printf("cpuid = %d\n", PCPU_GET(cpuid));
+#endif
+	pc = frame->pc + (DELAYBRANCH(frame->cause) ? 4 : 0);
+	log(LOG_ERR, "RES_INST: pid %d (%s), uid %d: pc %p ra %p\n",
+	    p->p_pid, p->p_comm,
+	    p->p_ucred ? p->p_ucred->cr_uid : -1,
+	    (void *)(intptr_t)pc,
+	    (void *)(intptr_t)frame->ra);
+
+	/* log registers in trap frame */
+	log_frame_dump(frame);
+
+	get_mapping_info((vm_offset_t)pc, &pdep, &ptep);
+
+	/*
+	 * Dump a few words around faulting instruction, if the addres is
+	 * valid.
+	 */
+	if (!(pc & 3) &&
+	    useracc((caddr_t)(intptr_t)pc, sizeof(int) * 4, VM_PROT_READ)) {
+		/* dump page table entry for faulting instruction */
+		log(LOG_ERR, "Page table info for pc address %p: pde = %p, pte = 0x%lx\n",
+		    (void *)(intptr_t)pc, *pdep, ptep ? *ptep : 0);
+
+		addr = (unsigned int *)(intptr_t)pc;
+		log(LOG_ERR, "Dumping 4 words starting at pc address %p: \n",
+		    addr);
+		log(LOG_ERR, "%08x %08x %08x %08x\n",
+		    addr[0], addr[1], addr[2], addr[3]);
+	} else {
+		log(LOG_ERR, "pc address %p is inaccessible, pde = 0x%p, pte = 0x%lx\n",
+		    (void *)(intptr_t)pc, *pdep, ptep ? *ptep : 0);
+	}
+}
 
 static void
 log_bad_page_fault(char *msg, struct trapframe *frame, int trap_type)


More information about the svn-src-user mailing list