From owner-p4-projects@FreeBSD.ORG Tue Nov 6 16:13:25 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C47CE63E; Tue, 6 Nov 2012 16:13:25 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7B9BF63C for ; Tue, 6 Nov 2012 16:13:25 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 471268FC08 for ; Tue, 6 Nov 2012 16:13:25 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id qA6GDPiJ058498 for ; Tue, 6 Nov 2012 16:13:25 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id qA6GDO7A058482 for perforce@freebsd.org; Tue, 6 Nov 2012 16:13:24 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 6 Nov 2012 16:13:24 GMT Message-Id: <201211061613.qA6GDO7A058482@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 219623 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Nov 2012 16:13:26 -0000 http://p4web.freebsd.org/@@219623?ac=10 Change 219623 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/11/06 16:12:31 When toasting a process with SIGPROT, print out some MIPS trap frame information, and the CHERI cause register. In the future we will also want to print out some capability register information as well. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cheri.c#5 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#11 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/trap.c#9 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cheri.c#5 (text+ko) ==== @@ -238,6 +238,19 @@ cheri_capability_set_user(&cfp->cf_pcc); } +void +cheri_log_exception(struct trapframe *frame, int trap_type) +{ + register_t cause; + +#ifdef SMP + printf("cpuid = %d\n", PCPU_GET(cpuid)); +#endif + CHERI_CGETCAUSE(cause); + printf("CHERI cause: ExcCode: %02x RegNum: %02x\n", + (uint8_t)((cause >> 8) & 0xff), (uint8_t)(cause & 0x1f)); +} + #ifdef DDB #define DB_CHERI_REG_PRINT_NUM(crn, num) do { \ struct chericap c; \ ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#11 (text+ko) ==== @@ -300,6 +300,7 @@ void cheri_context_copy(struct cheri_frame *cf_destp, struct cheri_frame *cf_srcp); void cheri_exec_setregs(struct thread *td); +void cheri_log_exception(struct trapframe *frame, int trap_type); #endif #endif /* _MIPS_INCLUDE_CHERI_H_ */ ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/trap.c#9 (text+ko) ==== @@ -129,6 +129,7 @@ static void log_illegal_instruction(const char *, struct trapframe *); static void log_bad_page_fault(char *, struct trapframe *, int); +static void log_c2e_exception(const 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 **); @@ -911,10 +912,8 @@ break; case T_C2E + T_USER: - /* - * XXXRW: Eventually, do much, much more here. - * log_cheri_exception("C2E", trapframe); - */ + msg = "USER_CHERI_EXCEPTION"; + log_c2e_exception(msg, trapframe, type); i = SIGPROT; addr = trapframe->pc; break; @@ -1540,6 +1539,24 @@ (intmax_t)frame->badvaddr, (void *)(intptr_t)*pdep, (uintmax_t)(ptep ? *ptep : 0)); } +#ifdef CPU_CHERI +/* + * XXXRW: Possibly this should actually be a CHERI-independent logging + * function, in which case only the CHERI-specific parts should be ifdef'd. + */ +static void +log_c2e_exception(const char *msg, struct trapframe *frame, int trap_type) +{ + +#ifdef SMP + printf("cpuid = %d\n", PCPU_GET(cpuid)); +#endif + + /* log registers in trap frame */ + log_frame_dump(frame); + cheri_log_exception(frame, trap_type); +} +#endif /* * Unaligned load/store emulation