From owner-p4-projects@FreeBSD.ORG Sun May 20 22:09:33 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DA124106566B; Sun, 20 May 2012 22:09:32 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C4AB1065677 for ; Sun, 20 May 2012 22:09:32 +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 308308FC12 for ; Sun, 20 May 2012 22:09:31 +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 q4KM9VVr057254 for ; Sun, 20 May 2012 22:09:31 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 q4KM9VvE057251 for perforce@freebsd.org; Sun, 20 May 2012 22:09:31 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 20 May 2012 22:09:31 GMT Message-Id: <201205202209.q4KM9VvE057251@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 To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 211454 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2012 22:09:33 -0000 http://p4web.freebsd.org/@@211454?ac=10 Change 211454 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/05/20 22:08:44 When creating and maintaining kernel and user contexts, force coprocessor 2 to be enabled. In a few places comment on the paucity of this approach. In the future we will want to conditionally manage CHERI CP2 context as is done for CP1 and Octeon CP2 support, reducing context switch costs when the features aren't in active use. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/pm_machdep.c#2 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/vm_machdep.c#3 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/pm_machdep.c#2 (text+ko) ==== @@ -523,6 +523,9 @@ td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX | MIPS_SR_SX; #endif +#if defined(CPU_CHERI) + td->td_frame->sr |= MIPS_SR_COP_2_BIT; +#endif /* * FREEBSD_DEVELOPERS_FIXME: * Setup any other CPU-Specific registers (Not MIPS Standard) ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/mips/vm_machdep.c#3 (text+ko) ==== @@ -165,7 +165,12 @@ td2->td_md.md_saved_intr = MIPS_SR_INT_IE; td2->td_md.md_spinlock_count = 1; #ifdef CPU_CHERI - /* XXXRW: CP2 state management here. */ + /* + * XXXRW: Ensure capability coprocessor is enabled for both kernel and + * userspace in child. + */ + td2->td_frame->sr |= MIPS_SR_COP_2_BIT; + pcb2->pcb_context[PCB_REG_SR] |= MIPS_SR_COP_2_BIT; #endif #ifdef CPU_CNMIPS if (td1->td_md.md_flags & MDTD_COP2USED) { @@ -411,6 +416,13 @@ pcb2->pcb_context[PCB_REG_SR] = mips_rd_status() & (MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_INT_MASK); +#ifdef CPU_CHERI + /* + * XXXRW: Interesting that we just set pcb_context here and not also + * the trap frame. + */ + pcb2->pcb_context[PCB_REG_SR] |= MIPS_SR_COP_2_BIT; +#endif #ifdef CPU_CNMIPS pcb2->pcb_context[PCB_REG_SR] |= MIPS_SR_COP_0_BIT | MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX | MIPS_SR_SX; @@ -470,6 +482,9 @@ /* * Keep interrupt mask + * + * XXXRW: I'm a bit puzzled by the code below and feel that even if it + * works, it can't really be right. */ td->td_frame->sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE | (mips_rd_status() & MIPS_SR_INT_MASK); @@ -478,6 +493,9 @@ #elif defined(__mips_n64) td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX; #endif +#ifdef CPU_CHERI + tf->sr |= MIPS_SR_COP_2_BIT; +#endif #ifdef CPU_CNMIPS tf->sr |= MIPS_SR_INT_IE | MIPS_SR_COP_0_BIT | MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX;