From owner-p4-projects@FreeBSD.ORG Sun Sep 15 21:29:30 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 59278B0A; Sun, 15 Sep 2013 21:29:30 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E6723B08 for ; Sun, 15 Sep 2013 21:29:29 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [8.8.178.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C4A5D26B4 for ; Sun, 15 Sep 2013 21:29:29 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FLTTL7072204 for ; Sun, 15 Sep 2013 21:29:29 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r8FLTThp072194 for perforce@freebsd.org; Sun, 15 Sep 2013 21:29:29 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 15 Sep 2013 21:29:29 GMT Message-Id: <201309152129.r8FLTThp072194@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 719157 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: Sun, 15 Sep 2013 21:29:30 -0000 http://p4web.freebsd.org/@@719157?ac=10 Change 719157 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2013/09/15 21:28:53 Begin to flesh out the framing around a software CCall/CReturn path: branch from a low-level exception handler in the vector table to one of two higher-level paths: CHERICCall and CHERICReturn. Select the path based on the cause register. Many more assertions required here -- and this is still just an (increasingly complicated) NOP. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/ccall.S#4 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/ccall.S#4 (text+ko) ==== @@ -43,17 +43,80 @@ #include "assym.s" +/* + * Software implementations of CCall, CReturn handlers for CHERI. + * + * The low-level CHERICCallVector exception handler, which has been relocated + * to the MIPS exception vector table, jumps to either CHERICCall or + * CHERICReturn running in the normal kernel address space. + * + * Notice that 'j' is used, implying that the kernel is in the 32-bit kernel + * segment so that the target fits in the available immediate -- this is also + * true of other FreeBSD exception handlers. + */ + .set noreorder /* Preserve nops, allow instructions in b-d slots. */ /* - * Software implementations of CCall, CReturn handlers for CHERI. + * CCall/CReturn low-level exception handler; this code must be position- + * independent, as it will be relocated into the vector table. + */ +VECTOR(CHERICCallVector, unknown) + .set push + .set noat + CHERI_EXCEPTION_ENTER(k0) + + /* + * Determine whether this is a CCall or CReturn instruction. + * + * XXXRW: Panic if CGetCause returns something other than CALL/RETURN. + * + * XXXRW: Panic if not entering from userspace. + */ + CGetCause k0 + andi k0, k0, 0x1 /* CALL is odd; RETURN is even. */ + beqz k0, CReturn_label + nop /* Branch-delay slot. */ + + j CHERICCall + nop /* Branch-delay slot. */ + +CReturn_label: + j CHERICReturn + nop /* Branch-delay slot. */ + + .set pop +VECTOR_END(CHERICCallVector) + +/* + * Software implementation of CCall; this code does not need to be position- + * independent. + * + * XXXRW: Gubbins missing. + */ +CHERICCall: + .set push + .set noat + + /* XXXRW: For now, increment PC as though it were a no-op. */ + MFC0 k0, MIPS_COP_0_EXC_PC + PTR_ADDU k0, 4 + MTC0 k0, MIPS_COP_0_EXC_PC + COP0_SYNC + + CHERI_EXCEPTION_RETURN(k0) + eret + .set pop + +/* + * Software implementation of CReturn; this code does not need to be position- + * independent. * * XXXRW: Gubbins missing. */ -VECTOR(CHERICCallVector, unknown) +CHERICReturn: .set push .set noat - CHERI_EXCEPTION_ENTER(k0) /* XXXRW: For now, increment PC as though it were a no-op. */ MFC0 k0, MIPS_COP_0_EXC_PC @@ -64,4 +127,3 @@ CHERI_EXCEPTION_RETURN(k0) eret .set pop -VECTOR_END(CHERICCallVector)