From owner-p4-projects@FreeBSD.ORG Mon Jun 25 16:13:59 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8EE8A1065672; Mon, 25 Jun 2012 16:13:58 +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 47991106566C for ; Mon, 25 Jun 2012 16:13:58 +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 171AE8FC22 for ; Mon, 25 Jun 2012 16:13:58 +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 q5PGDvA1051464 for ; Mon, 25 Jun 2012 16:13:57 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 q5PGDvXf051461 for perforce@freebsd.org; Mon, 25 Jun 2012 16:13:57 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 25 Jun 2012 16:13:57 GMT Message-Id: <201206251613.q5PGDvXf051461@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 213447 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: Mon, 25 Jun 2012 16:13:59 -0000 http://p4web.freebsd.org/@@213447?ac=10 Change 213447 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/25 16:13:31 Integrate BERI_SIM_MDROOT kernel configuration from FreeBSD/BERI to CheriBSD branch. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/conf/BERI_SIM.hints#1 branch .. //depot/projects/ctsrd/cheribsd/src/sys/mips/conf/BERI_SIM_MDROOT#1 branch Differences ... From owner-p4-projects@FreeBSD.ORG Mon Jun 25 16:19:28 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D9C2B1065675; Mon, 25 Jun 2012 16:19:27 +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 8DD7D1065673 for ; Mon, 25 Jun 2012 16:19:27 +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 5D4758FC15 for ; Mon, 25 Jun 2012 16:19:27 +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 q5PGJRMH051656 for ; Mon, 25 Jun 2012 16:19:27 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 q5PGJRJ5051653 for perforce@freebsd.org; Mon, 25 Jun 2012 16:19:27 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 25 Jun 2012 16:19:27 GMT Message-Id: <201206251619.q5PGJRJ5051653@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 213448 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: Mon, 25 Jun 2012 16:19:28 -0000 http://p4web.freebsd.org/@@213448?ac=10 Change 213448 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/25 16:18:40 Add CHERI_SIM_MDROOT, based on BERI_SIM_MDROOT, offering a simulator-customised CheriBSD kernel configuration. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/conf/CHERI_SIM_MDROOT#1 add Differences ... From owner-p4-projects@FreeBSD.ORG Mon Jun 25 16:51:18 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 53A60106568C; Mon, 25 Jun 2012 16:51:16 +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 078BA1065686 for ; Mon, 25 Jun 2012 16:51:16 +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 D86D38FC16 for ; Mon, 25 Jun 2012 16:51:15 +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 q5PGpFaw058663 for ; Mon, 25 Jun 2012 16:51:15 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 q5PGpFEb058657 for perforce@freebsd.org; Mon, 25 Jun 2012 16:51:15 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 25 Jun 2012 16:51:15 GMT Message-Id: <201206251651.q5PGpFEb058657@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 213450 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: Mon, 25 Jun 2012 16:51:18 -0000 http://p4web.freebsd.org/@@213450?ac=10 Change 213450 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/25 16:50:17 A further reworking on CheriBSD management of CP2 contexts for user threads: - Introduce constants for various important values inserted into capabilities configured for user threads so that it's easier to write corresponding unit tests. - Select more conservative initial register values on execve(): $c0 contains full access to the user address space, and other capabilities are initialised to null rights. - Don't use a CP2 user template variable, just construct required capabilities from the kernel data capability (KDC) on demand. Eventually we'll want to rearrange things a bit so that the kernel doesn't execute with all privilege, but instead alays employs capabilities when accessing user data, but not yet. - Fix bugs in CP2_CR_GET_UPERMS() and CP2_CR_GET(), which were not used in Deimos and hence didn't work. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cp2.c#8 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#3 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cherireg.h#3 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cp2.c#8 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011 Robert N. M. Watson + * Copyright (c) 2011-2012 Robert N. M. Watson * All rights reserved. * * This software was developed by SRI International and the University of @@ -51,11 +51,6 @@ */ /* - * Template capability delegating ambient authority to userspace processes. - */ -static struct capability cp2_user_template; - -/* * Given an existing more privileged capability (fromcrn), build a new * capability in tocrn with the contents of the passed flattened * representation. @@ -80,31 +75,35 @@ CP2_CR_STORE(CHERI_CR_CT0, CHERI_CR_KDC, (uint64_t)cp); } +/* + * Functions to store a common set of capability values to in-memory + * capabilities: full privilege, userspace privilege, and null privilege. + * These are used to initialise capability registers when creating new + * contexts. + */ void cp2_capability_set_priv(struct capability *cp) { - cp2_capability_set(cp, CHERI_PERM_ALL, NULL, NULL, - 0xffffffffffffffff); + cp2_capability_set(cp, CHERI_CAP_PRIV_UPERMS, CHERI_CAP_PRIV_OTYPE, + CHERI_CAP_PRIV_BASE, CHERI_CAP_PRIV_LENGTH); } void -cp2_capability_set_upriv(struct capability *cp) +cp2_capability_set_user(struct capability *cp) { - /* - * XXXRW: Note assumption that MIPS_XUSEG_START == NULL. Perhaps - * should be a CTASSERT(). - */ - cp2_capability_set(cp, CHERI_PERM_ALL, NULL, NULL, - MIPS_XUSEG_END); + cp2_capability_set(cp, CHERI_CAP_USER_UPERMS, CHERI_CAP_USER_OTYPE, + CHERI_CAP_USER_BASE, CHERI_CAP_USER_LENGTH); } void cp2_capability_set_null(struct capability *cp) { - cp2_capability_set(cp, 0, NULL, NULL, 0); + cp2_capability_set(cp, CHERI_CAP_NOPRIV_UPERMS, + CHERI_CAP_NOPRIV_OTYPE, CHERI_CAP_NOPRIV_BASE, + CHERI_CAP_NOPRIV_LENGTH); } /* @@ -443,55 +442,44 @@ } } -static void -cheri_init(void *arg) -{ - - /* - * Initialise a template capability that will be used when - * configuring new user processes. - * - * XXXRW: Currently, this delegates the full address space -- more - * ideally, we'd limit it to user portions of the address space, - * reinforcing the MIPS segment and ring model. - */ - cp2_capability_set_priv(&cp2_user_template); -} -SYSINIT(elf32, SI_SUB_CREATE_INIT, SI_ORDER_ANY, cheri_init, NULL); - void cheri_exec_setregs(struct thread *td) { struct cp2_frame *cfp; + /* + * XXXRW: Experimental CHERI ABI initialises $c0 with full user + * privilege, and all other user-accessible capability registers with + * no rights at all. The runtime linker/compiler/application can + * propagate around rights as required. + */ cfp = &td->td_pcb->pcb_cp2frame; - cp2_capability_load(CHERI_CR_CT0, &cp2_user_template); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c0); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c1); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c2); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c3); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c4); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c5); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c6); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c7); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c8); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c9); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c10); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c11); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c12); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c13); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c14); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c15); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c16); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c17); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c18); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c19); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c20); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c21); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c22); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c23); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_c24); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_udc); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_tsc); - cp2_capability_store(CHERI_CR_CT0, &cfp->cf_pcc); + cp2_capability_set_user(&cfp->cf_c0); + cp2_capability_set_null(&cfp->cf_c1); + cp2_capability_set_null(&cfp->cf_c2); + cp2_capability_set_null(&cfp->cf_c3); + cp2_capability_set_null(&cfp->cf_c4); + cp2_capability_set_null(&cfp->cf_c5); + cp2_capability_set_null(&cfp->cf_c6); + cp2_capability_set_null(&cfp->cf_c7); + cp2_capability_set_null(&cfp->cf_c8); + cp2_capability_set_null(&cfp->cf_c9); + cp2_capability_set_null(&cfp->cf_c10); + cp2_capability_set_null(&cfp->cf_c11); + cp2_capability_set_null(&cfp->cf_c12); + cp2_capability_set_null(&cfp->cf_c13); + cp2_capability_set_null(&cfp->cf_c14); + cp2_capability_set_null(&cfp->cf_c15); + cp2_capability_set_null(&cfp->cf_c16); + cp2_capability_set_null(&cfp->cf_c17); + cp2_capability_set_null(&cfp->cf_c18); + cp2_capability_set_null(&cfp->cf_c19); + cp2_capability_set_null(&cfp->cf_c20); + cp2_capability_set_null(&cfp->cf_c21); + cp2_capability_set_null(&cfp->cf_c22); + cp2_capability_set_null(&cfp->cf_c23); + cp2_capability_set_null(&cfp->cf_c24); + cp2_capability_set_null(&cfp->cf_udc); + cp2_capability_set_null(&cfp->cf_tsc); + cp2_capability_set_null(&cfp->cf_pcc); } ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#3 (text+ko) ==== @@ -104,7 +104,7 @@ #define CP2_CR_GET_UPERMS(crn, v) do { \ __asm__ __volatile__ ( \ - "cgetperms %0, $c%1; " : \ + "cgetperm %0, $c%1; " : \ "=r" (v) : "i" (crn)); \ } while (0) @@ -235,9 +235,9 @@ */ #define CP2_CR_GET(crn, c) do { \ CP2_CR_GET_UPERMS((crn), (c).c_uperms); \ - CP2_CR_GET_OTYPE((crn), (c).c_uperms); \ - CP2_CR_GET_BASE((crn), (c).c_uperms); \ - CP2_CR_GET_LENGTH((crn), (c).c_uperms); \ + CP2_CR_GET_OTYPE((crn), (c).u.c_otype); \ + CP2_CR_GET_BASE((crn), (c).c_base); \ + CP2_CR_GET_LENGTH((crn), (c).c_length); \ } while (0) #define CP2_CR_SET(crn_to, crn_from, c) do { \ @@ -321,7 +321,7 @@ void cp2_capability_set(struct capability *cp, uint32_t uperms, void *otypep /* eaddr */, void *basep, uint64_t length); void cp2_capability_set_priv(struct capability *cp); -void cp2_capability_set_upriv(struct capability *cp); +void cp2_capability_set_user(struct capability *cp); void cp2_capability_set_null(struct capability *cp); #ifdef _KERNEL ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cherireg.h#3 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011 Robert N. M. Watson + * Copyright (c) 2011-2012 Robert N. M. Watson * All rights reserved. * * This software was developed by SRI International and the University of @@ -68,6 +68,35 @@ CHERI_PERM_ACCESS_EPCC | CHERI_PERM_NON_EPHEMERAL) /* + * Definition for kernel "privileged" capability able to name the entire + * address space. + * + * XXXRW: Perhaps CHERI_UCAP_UNPRIV_LENGTH should actually just cover useg. + */ +#define CHERI_CAP_PRIV_UPERMS CHERI_PERM_ALL +#define CHERI_CAP_PRIV_OTYPE 0x0 +#define CHERI_CAP_PRIV_BASE 0x0 +#define CHERI_CAP_PRIV_LENGTH 0xffffffffffffffff + +/* + * Definition for userspace "unprivileged" capability able to name the user + * portion of the address space. + */ +#define CHERI_CAP_USER_UPERMS CHERI_PERM_ALL +#define CHERI_CAP_USER_OTYPE 0x0 +#define CHERI_CAP_USER_BASE MIPS_XUSEG_START +#define CHERI_CAP_USER_LENGTH (MIPS_XUSEG_END - MIPS_XUSEG_START) + +/* + * Definition for capability unable to name any resources. This is suitable + * for filling capability registers that should hold no privilege. + */ +#define CHERI_CAP_NOPRIV_UPERMS 0x0 +#define CHERI_CAP_NOPRIV_OTYPE 0x0 +#define CHERI_CAP_NOPRIV_BASE 0x0 +#define CHERI_CAP_NOPRIV_LENGTH 0x0 + +/* * A blend of hardware and software allocation of capability registers. * Ideally, this list wouldn't exist here, but be purely in the assembler. */ From owner-p4-projects@FreeBSD.ORG Tue Jun 26 00:06:36 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id ECF0C1065672; Tue, 26 Jun 2012 00:06:35 +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 AFB731065670 for ; Tue, 26 Jun 2012 00:06:35 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 9971D8FC16 for ; Tue, 26 Jun 2012 00:06:35 +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 q5Q06Zeg044191 for ; Tue, 26 Jun 2012 00:06:35 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5Q06Z7G044188 for perforce@freebsd.org; Tue, 26 Jun 2012 00:06:35 GMT (envelope-from brooks@freebsd.org) Date: Tue, 26 Jun 2012 00:06:35 GMT Message-Id: <201206260006.q5Q06Z7G044188@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213465 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: Tue, 26 Jun 2012 00:06:36 -0000 http://p4web.freebsd.org/@@213465?ac=10 Change 213465 by brooks@brooks_ecr_current on 2012/06/26 00:06:07 Unbreak the case where we haven't worked a child process. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/spinner/spinner.c#3 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/spinner/spinner.c#3 (text+ko) ==== @@ -80,7 +80,7 @@ main(int argc, char *argv[]) { int alpha, ch, i, ofd; - pid_t pid; + pid_t pid = 0; char *ep; char imgpath[MAXPATHLEN]; u_int32_t *bottom, *top; @@ -164,7 +164,8 @@ for (i = 0; i < NSPINNERS; i++) { - poll_child(pid); + if (pid != 0) + poll_child(pid); snprintf(imgpath, sizeof(imgpath), "%s/spinner%02d.png", IMGDIR, i); read_png_file(imgpath, spinners[i], fb_width, fb_height); @@ -191,7 +192,8 @@ if (i >= NSPINNERS) i = 0; fb_post(spinners[i]); - poll_child(pid); + if (pid != 0) + poll_child(pid); } fb_fade2off(); From owner-p4-projects@FreeBSD.ORG Tue Jun 26 00:33:04 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2C9551065677; Tue, 26 Jun 2012 00:33:04 +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 DF4BA1065670; Tue, 26 Jun 2012 00:33:03 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id 4C1428FC18; Tue, 26 Jun 2012 00:33:03 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.4/8.14.4) with ESMTP id q5Q0VlMr070965; Mon, 25 Jun 2012 19:31:47 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.4/8.14.4/Submit) id q5Q0Vlwg070964; Mon, 25 Jun 2012 19:31:47 -0500 (CDT) (envelope-from brooks) Date: Mon, 25 Jun 2012 19:31:47 -0500 From: Brooks Davis To: Robert Watson Message-ID: <20120626003147.GC67832@lor.one-eyed-alien.net> References: <201206221245.q5MCj7Jb082514@skunkworks.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IpbVkmxF4tDyP/Kb" Content-Disposition: inline In-Reply-To: <201206221245.q5MCj7Jb082514@skunkworks.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Perforce Change Reviews Subject: Re: PERFORCE change 213289 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 00:33:04 -0000 --IpbVkmxF4tDyP/Kb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 22, 2012 at 12:45:07PM +0000, Robert Watson wrote: > http://p4web.freebsd.org/@@213289?ac=3D10 >=20 > Change 213289 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/22 12:45:= 03 >=20 > Add the CTSRD-local images directory to the mtree for /usr/share > so that installworld auto-creates the directory in the target > tree. I had forgotten that I'd created the directory by hand. :( It seems like we want some sort of LOCAL_MTREE variable to really do this right.=20 -- Brooks --IpbVkmxF4tDyP/Kb Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFP6QLyXY6L6fI4GtQRAvIlAJ4zkjo7Hbe99h9WYGRsK0aNp4+7ngCeJwsT fwQ8HsWfOkjVFeL7aQda0Q4= =Gunw -----END PGP SIGNATURE----- --IpbVkmxF4tDyP/Kb-- From owner-p4-projects@FreeBSD.ORG Tue Jun 26 01:11:18 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 583E61065672; Tue, 26 Jun 2012 01:11:18 +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 1A7B3106566B for ; Tue, 26 Jun 2012 01:11:18 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 03E628FC0C for ; Tue, 26 Jun 2012 01:11:18 +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 q5Q1BHrR057886 for ; Tue, 26 Jun 2012 01:11:17 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5Q1BHKN057881 for perforce@freebsd.org; Tue, 26 Jun 2012 01:11:17 GMT (envelope-from brooks@freebsd.org) Date: Tue, 26 Jun 2012 01:11:17 GMT Message-Id: <201206260111.q5Q1BHKN057881@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213470 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: Tue, 26 Jun 2012 01:11:18 -0000 http://p4web.freebsd.org/@@213470?ac=10 Change 213470 by brooks@brooks_ecr_current on 2012/06/26 01:10:15 Add a simple program to show a png image. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/Makefile#5 edit .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/Makefile#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/Makefile#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/showimage.c#1 add Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/Makefile#5 (text+ko) ==== @@ -3,6 +3,7 @@ SUBDIR= cycle_led \ flashit \ pictview \ + showimage \ spinner .include From owner-p4-projects@FreeBSD.ORG Tue Jun 26 01:12:24 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 894671065674; Tue, 26 Jun 2012 01:12:24 +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 4B9641065672 for ; Tue, 26 Jun 2012 01:12:24 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 34D428FC0C for ; Tue, 26 Jun 2012 01:12:24 +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 q5Q1COXq057927 for ; Tue, 26 Jun 2012 01:12:24 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5Q1CNvH057924 for perforce@freebsd.org; Tue, 26 Jun 2012 01:12:23 GMT (envelope-from brooks@freebsd.org) Date: Tue, 26 Jun 2012 01:12:23 GMT Message-Id: <201206260112.q5Q1CNvH057924@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213471 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: Tue, 26 Jun 2012 01:12:24 -0000 http://p4web.freebsd.org/@@213471?ac=10 Change 213471 by brooks@brooks_ecr_current on 2012/06/26 01:11:27 Update the location of the kernel. Add isf0 and isf1 targets for reflashing the whole chip. Add a bit more error handling. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/flashit/flashit.sh#2 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/flashit/flashit.sh#2 (text+ko) ==== @@ -1,24 +1,26 @@ #!/bin/sh +isf0_DEV=isf0 +isf0_OFFSET=0 +isf0_MAXLEN=0x02000000 + +isf1_DEV=isf1 +isf1_OFFSET=0 +isf1_MAXLEN=0x02000000 + fpga_DEV=isf0 fpga_OFFSET=0x00020000 -fpga_MAXLEN=0x00FE0000 +fpga_MAXLEN=0x00C00000 fpga_SKIP=0x20000 -# New kernel location on isf0 -kernel_DEV=isf0 -kernel_OFFSET=0x01000000 -kernel_MAXLEN=0x01000000 +fpga2_DEV=isf0 +fpga2_OFFSET=0x00C20000 +fpga2_MAXLEN=0x00C00000 +fpga2_SKIP=0x20000 -# Old kernel location on isf1 -kernel2_DEV=isf1 -kernel2_OFFSET=0x01000000 -kernel2_MAXLEN=0x01000000 - -# Proposed root location -root_DEV=isf1 -root_OFFSET=0x00000000 -root_MAXLEN=0x02000000 +kernel_DEV=isf1 +kernel_OFFSET=0x00000000 +kernel_MAXLEN=0x02000000 TARGETS="fpga:kernel:kernel2:root" @@ -114,11 +116,17 @@ case "${source}" in *.bz2) + if [ -z "${tmpdir}" ]; then + err 1 "Can't make a temporary directory, is /tmp writable?" + fi binfile="${tmpdir}/${src_name%.bz2}" echo "Extracting to ${binfile}" bunzip2 -c "${source}" > "${binfile}" ;; *.gz) + if [ -z "${tmpdir}" ]; then + err 1 "Can't make a temporary directory, is /tmp writable?" + fi binfile="${tmpdir}/${src_name%.gz}" echo "Extracting to ${binfile}" gunzip -c "${source}" > "${binfile}" From owner-p4-projects@FreeBSD.ORG Tue Jun 26 01:13:29 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 61DEF106567C; Tue, 26 Jun 2012 01:13:29 +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 20A8C106567A for ; Tue, 26 Jun 2012 01:13:29 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 09E738FC24 for ; Tue, 26 Jun 2012 01:13:29 +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 q5Q1DS3g057975 for ; Tue, 26 Jun 2012 01:13:28 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5Q1DSW5057966 for perforce@freebsd.org; Tue, 26 Jun 2012 01:13:28 GMT (envelope-from brooks@freebsd.org) Date: Tue, 26 Jun 2012 01:13:28 GMT Message-Id: <201206260113.q5Q1DSW5057966@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213472 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: Tue, 26 Jun 2012 01:13:29 -0000 http://p4web.freebsd.org/@@213472?ac=10 Change 213472 by brooks@brooks_ecr_current on 2012/06/26 01:12:42 Allow the range to be erased to be specified as an offset and number of 128K blocks in addition to a number of bytes. Affected files ... .. //depot/projects/ctsrd/beribsd/src/usr.sbin/isfctl/isfctl.c#2 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/usr.sbin/isfctl/isfctl.c#2 (text+ko) ==== @@ -88,6 +88,13 @@ ir.ir_size = strtol(argv[2], &p, 0); if (*p) errx(1, "invalid size -- %s", argv[3]); + /* + * If the user requests to delete less than 32K of space + * then assume that they want to delete a number of 128K + * blocks. + */ + if (ir.ir_size < 32 * 1024) + ir.ir_size *= 128 * 1024; } switch (action) { From owner-p4-projects@FreeBSD.ORG Tue Jun 26 14:18:18 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6775F1065749; Tue, 26 Jun 2012 14:18:16 +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 B2AE81065740 for ; Tue, 26 Jun 2012 14:18:15 +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 993418FC15 for ; Tue, 26 Jun 2012 14:18:15 +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 q5QEIFLw023036 for ; Tue, 26 Jun 2012 14:18:15 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 q5QEIF9J023033 for perforce@freebsd.org; Tue, 26 Jun 2012 14:18:15 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 26 Jun 2012 14:18:15 GMT Message-Id: <201206261418.q5QEIF9J023033@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 213491 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: Tue, 26 Jun 2012 14:18:18 -0000 http://p4web.freebsd.org/@@213491?ac=10 Change 213491 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/26 14:17:55 Refine and generally improve kernel CP2 management: Don't maintain a PCB CP2 frame entry for udc (user data capability), as that's actually just the kernel's register for temporarily holding userspace's c0, which we already have a field for. Fix a bug in which PCC isn't properly saved and restored for capability-aware processes -- no symptoms yet, but they would have turned up in due course. Add DDB functions to print the current CP0 register file, and also preserved CP2 state for a thread (by default, the current thread). Fix a mistranscription of various capability permissions, and define a more refined set of rights for user processes. With these changes, capability registers appear to be properly initialised by execve(), maintained across a variety of context switches, conventional programs work properly, and programs that manipulate capabilities are able to do so successfully. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cp2.c#9 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#4 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheriasm.h#3 edit .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cherireg.h#4 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/cheri/cp2.c#9 (text+ko) ==== @@ -28,10 +28,14 @@ * SUCH DAMAGE. */ +#include "opt_ddb.h" + #include #include #include +#include + #include #include @@ -153,7 +157,6 @@ cp2_capability_copy(&cf_destp->cf_c22, &cf_srcp->cf_c22); cp2_capability_copy(&cf_destp->cf_c23, &cf_srcp->cf_c23); cp2_capability_copy(&cf_destp->cf_c24, &cf_srcp->cf_c24); - cp2_capability_copy(&cf_destp->cf_udc, &cf_srcp->cf_udc); cp2_capability_copy(&cf_destp->cf_tsc, &cf_srcp->cf_tsc); cp2_capability_copy(&cf_destp->cf_pcc, &cf_srcp->cf_pcc); } @@ -479,7 +482,94 @@ cp2_capability_set_null(&cfp->cf_c22); cp2_capability_set_null(&cfp->cf_c23); cp2_capability_set_null(&cfp->cf_c24); - cp2_capability_set_null(&cfp->cf_udc); cp2_capability_set_null(&cfp->cf_tsc); cp2_capability_set_null(&cfp->cf_pcc); } + +#ifdef DDB +#define DB_CP2_REG_PRINT_NUM(crn, num) do { \ + struct capability c; \ + \ + CP2_CR_GET((crn), c); \ + db_printf("C%u perms %08jx otype %016jx\n", num, \ + (uintmax_t)c.c_uperms, (uintmax_t)c.u.c_otype); \ + db_printf("\tbase %016jx length %016jx\n", (uintmax_t)c.c_base, \ + (uintmax_t)c.c_length); \ +} while (0) + +#define DB_CP2_REG_PRINT(crn) DB_CP2_REG_PRINT_NUM(crn, crn) + +/* + * Variation that prints live register state from CP2. + */ +DB_SHOW_COMMAND(cp0, ddb_dump_cp0) +{ + + db_printf("CP0 registers\n"); + DB_CP2_REG_PRINT(0); + DB_CP2_REG_PRINT(1); + DB_CP2_REG_PRINT(2); + DB_CP2_REG_PRINT(3); + DB_CP2_REG_PRINT(4); + DB_CP2_REG_PRINT(5); + DB_CP2_REG_PRINT(6); + DB_CP2_REG_PRINT(7); + DB_CP2_REG_PRINT(8); + DB_CP2_REG_PRINT(9); + DB_CP2_REG_PRINT(10); + DB_CP2_REG_PRINT(11); + DB_CP2_REG_PRINT(12); + DB_CP2_REG_PRINT(13); + DB_CP2_REG_PRINT(14); + DB_CP2_REG_PRINT(15); + DB_CP2_REG_PRINT(16); + DB_CP2_REG_PRINT(17); + DB_CP2_REG_PRINT(18); + DB_CP2_REG_PRINT(19); + DB_CP2_REG_PRINT(20); + DB_CP2_REG_PRINT(21); + DB_CP2_REG_PRINT(22); + DB_CP2_REG_PRINT(23); + DB_CP2_REG_PRINT(24); + DB_CP2_REG_PRINT(25); + DB_CP2_REG_PRINT(26); + DB_CP2_REG_PRINT(27); + DB_CP2_REG_PRINT(28); + DB_CP2_REG_PRINT(29); + DB_CP2_REG_PRINT(30); + DB_CP2_REG_PRINT(31); +} + +/* + * Variation that prints the saved userspace CP2 register frame for a thread. + */ +DB_SHOW_COMMAND(cp0frame, ddb_dump_cp0frame) +{ + struct thread *td; + struct cp2_frame *cfp; + u_int i; + + if (have_addr) + td = db_lookup_thread(addr, TRUE); + else + td = curthread; + + cfp = &td->td_pcb->pcb_cp2frame; + db_printf("Thread %d at %p\n", td->td_tid, td); + db_printf("CP2 frame at %p\n", cfp); + + /* Laboriously load and print each capability. */ + for (i = 0; i < 25; i++) { + cp2_capability_load(CHERI_CR_CT0, + (struct capability *)&cfp->cf_c0 + i); + DB_CP2_REG_PRINT_NUM(CHERI_CR_CT0, i); + } + db_printf("\nTSC and PCC:\n"); + cp2_capability_load(CHERI_CR_CT0, (struct capability *)&cfp->cf_c0 + + CHERI_CR_TSC_OFF); + DB_CP2_REG_PRINT_NUM(CHERI_CR_CT0, CHERI_CR_TSC); + cp2_capability_load(CHERI_CR_CT0, (struct capability *)&cfp->cf_c0 + + CHERI_CR_PCC_OFF); + DB_CP2_REG_PRINT_NUM(CHERI_CR_CT0, CHERI_CR_EPCC); +} +#endif ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#4 (text+ko) ==== @@ -84,13 +84,12 @@ * Special-purpose capability registers that must be preserved on a * user context switch. Note that KT0, KT1, KCC, and KDC are omitted. */ - struct capability cf_udc; struct capability cf_tsc; /* Program counter capability. */ struct capability cf_pcc; }; -CTASSERT(sizeof(struct cp2_frame) == (28 * CAPABILITY_SIZE)); +CTASSERT(sizeof(struct cp2_frame) == (27 * CAPABILITY_SIZE)); #endif /* ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheriasm.h#3 (text+ko) ==== @@ -119,8 +119,8 @@ SAVE_U_PCB_CP2REG(treg, $c22, CHERI_CR_C22_OFF, base); \ SAVE_U_PCB_CP2REG(treg, $c23, CHERI_CR_C23_OFF, base); \ SAVE_U_PCB_CP2REG(treg, $c24, CHERI_CR_C24_OFF, base); \ - SAVE_U_PCB_CP2REG(treg, $c25, CHERI_CR_UDC_OFF, base); \ - SAVE_U_PCB_CP2REG(treg, $c28, CHERI_CR_TSC_OFF, base) + SAVE_U_PCB_CP2REG(treg, $c28, CHERI_CR_TSC_OFF, base); \ + SAVE_U_PCB_CP2REG(treg, $c31, CHERI_CR_PCC_OFF, base) #define RESTORE_CP2_CONTEXT(treg, base) \ RESTORE_U_PCB_CP2REG(treg, $c25, CHERI_CR_C0_OFF, base); \ @@ -148,7 +148,7 @@ RESTORE_U_PCB_CP2REG(treg, $c22, CHERI_CR_C22_OFF, base); \ RESTORE_U_PCB_CP2REG(treg, $c23, CHERI_CR_C23_OFF, base); \ RESTORE_U_PCB_CP2REG(treg, $c24, CHERI_CR_C24_OFF, base); \ - RESTORE_U_PCB_CP2REG(treg, $c25, CHERI_CR_UDC_OFF, base); \ - RESTORE_U_PCB_CP2REG(treg, $c28, CHERI_CR_TSC_OFF, base) + RESTORE_U_PCB_CP2REG(treg, $c28, CHERI_CR_TSC_OFF, base); \ + RESTORE_U_PCB_CP2REG(treg, $c31, CHERI_CR_PCC_OFF, base) #endif /* _MIPS_INCLUDE_CHERIASM_H_ */ ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cherireg.h#4 (text+ko) ==== @@ -38,34 +38,38 @@ * XXXRW: CHERI_UNSEALED is not currently considered part of the perms word, * but perhaps it should be. */ -#define CHERI_PERM_EXECUTE 0x0001 -#define CHERI_PERM_STORE_CAPABILITY 0x0002 -#define CHERI_PERM_LOAD_CAPABILITY 0x0004 -#define CHERI_PERM_STORE 0x0008 -#define CHERI_PERM_LOAD 0x0010 -#define CHERI_PERM_STORE_EPHEMERAL_CAPABILITY 0x0020 -#define CHERI_PERM_SEAL 0x0040 -#define CHERI_PERM_SET_TYPE 0x0080 -#define CHERI_PERM_RESERVED0 0x0100 -#define CHERI_PERM_RESERVED1 0x0200 -#define CHERI_PERM_ACCESS_TSC 0x0400 -#define CHERI_PERM_ACCESS_KCC 0x0800 -#define CHERI_PERM_ACCESS_KDC 0x1000 -#define CHERI_PERM_ACCESS_EPCC 0x2000 -#define CHERI_PERM_NON_EPHEMERAL 0x4000 -#define CHERI_UNSEALED 0x8000 +#define CHERI_PERM_NON_EPHEMERAL 0x0001 +#define CHERI_PERM_ACCESS_CR31 0x0002 +#define CHERI_PERM_ACCESS_CR30 0x0004 +#define CHERI_PERM_ACCESS_CR29 0x0008 +#define CHERI_PERM_ACCESS_CR28 0x0010 +#define CHERI_PERM_RESERVED1 0x0020 +#define CHERI_PERM_RESERVED2 0x0040 +#define CHERI_PERM_RESERVED3 0x0080 +#define CHERI_PERM_SEAL 0x0100 +#define CHERI_PERM_STORE_EPHEMERAL_CAPABILITY 0x0200 +#define CHERI_PERM_LOAD 0x0400 +#define CHERI_PERM_STORE 0x0800 +#define CHERI_PERM_LOAD_CAP 0x1000 +#define CHERI_PERM_STORE_CAP 0x2000 +#define CHEIR_PERM_EXECUTE 0x4000 /* * XXXRW: Should this include CHERI_UNSEALED? */ -#define CHERI_PERM_ALL \ - (CHERI_PERM_EXECUTE | CHERI_PERM_STORE_CAPABILITY | \ - CHERI_PERM_LOAD_CAPABILITY | CHERI_PERM_STORE | \ - CHERI_PERM_STORE_EPHEMERAL_CAPABILITY | CHERI_PERM_SEAL | \ - CHERI_PERM_SET_TYPE | CHERI_PERM_RESERVED0 | \ - CHERI_PERM_RESERVED1 | CHERI_PERM_ACCESS_TSC | \ - CHERI_PERM_ACCESS_KCC | CHERI_PERM_ACCESS_KDC | \ - CHERI_PERM_ACCESS_EPCC | CHERI_PERM_NON_EPHEMERAL) +#define CHERI_PERM_PRIV \ + (CHERI_PERM_NON_EPHEMERAL | CHERI_PERM_ACCESS_CR31 | \ + CHERI_PERM_ACCESS_CR30 | CHERI_PERM_ACCESS_CR29 | \ + CHERI_PERM_ACCESS_CR28 | CHERI_PERM_SEAL | \ + CHERI_PERM_STORE_EPHEMERAL_CAPABILITY | CHERI_PERM_LOAD | \ + CHERI_PERM_STORE | CHERI_PERM_LOAD_CAP | CHERI_PERM_STORE_CAP | \ + CHEIR_PERM_EXECUTE) + +#define CHERI_PERM_USER \ + (CHERI_PERM_NON_EPHEMERAL | CHERI_PERM_SEAL | \ + CHERI_PERM_STORE_EPHEMERAL_CAPABILITY | CHERI_PERM_LOAD | \ + CHERI_PERM_STORE | CHERI_PERM_LOAD_CAP | CHERI_PERM_STORE_CAP | \ + CHEIR_PERM_EXECUTE) /* * Definition for kernel "privileged" capability able to name the entire @@ -73,7 +77,7 @@ * * XXXRW: Perhaps CHERI_UCAP_UNPRIV_LENGTH should actually just cover useg. */ -#define CHERI_CAP_PRIV_UPERMS CHERI_PERM_ALL +#define CHERI_CAP_PRIV_UPERMS CHERI_PERM_PRIV #define CHERI_CAP_PRIV_OTYPE 0x0 #define CHERI_CAP_PRIV_BASE 0x0 #define CHERI_CAP_PRIV_LENGTH 0xffffffffffffffff @@ -82,7 +86,7 @@ * Definition for userspace "unprivileged" capability able to name the user * portion of the address space. */ -#define CHERI_CAP_USER_UPERMS CHERI_PERM_ALL +#define CHERI_CAP_USER_UPERMS CHERI_PERM_USER #define CHERI_CAP_USER_OTYPE 0x0 #define CHERI_CAP_USER_BASE MIPS_XUSEG_START #define CHERI_CAP_USER_LENGTH (MIPS_XUSEG_END - MIPS_XUSEG_START) @@ -125,7 +129,7 @@ #define CHERI_CR_C22 22 #define CHERI_CR_C23 23 #define CHERI_CR_C24 24 -#define CHERI_CR_UDC 25 /* SC0: user data capability. */ +#define CHERI_CR_UDC 25 /* UDC: user data capability (saved C0). */ #define CHERI_CR_KT0 26 /* KT0: temporary kernel capability. */ #define CHERI_CR_KT1 27 /* KT1: temporary kernel capability. */ #define CHERI_CR_TSC 28 /* TSC: trusted stack capability. */ @@ -164,8 +168,7 @@ #define CHERI_CR_C22_OFF 22 #define CHERI_CR_C23_OFF 23 #define CHERI_CR_C24_OFF 24 -#define CHERI_CR_UDC_OFF 25 -#define CHERI_CR_TSC_OFF 26 -#define CHERI_CR_PC_OFF 27 +#define CHERI_CR_TSC_OFF 25 +#define CHERI_CR_PCC_OFF 26 #endif /* _MIPS_INCLUDE_CHERIREG_H_ */ From owner-p4-projects@FreeBSD.ORG Tue Jun 26 14:19:22 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BE8DB1065675; Tue, 26 Jun 2012 14:19:21 +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 6FA9E1065670 for ; Tue, 26 Jun 2012 14:19:21 +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 576598FC1E for ; Tue, 26 Jun 2012 14:19:21 +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 q5QEJL8S023082 for ; Tue, 26 Jun 2012 14:19:21 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 q5QEJLvl023079 for perforce@freebsd.org; Tue, 26 Jun 2012 14:19:21 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 26 Jun 2012 14:19:21 GMT Message-Id: <201206261419.q5QEJLvl023079@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 213492 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: Tue, 26 Jun 2012 14:19:22 -0000 http://p4web.freebsd.org/@@213492?ac=10 Change 213492 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/06/26 14:18:44 Hook up a very simply CHERI CP2 register test tool that exercises some useful cases. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/bin/Makefile#2 edit .. //depot/projects/ctsrd/cheribsd/src/bin/cheritest/Makefile#1 add .. //depot/projects/ctsrd/cheribsd/src/bin/cheritest/cheritest.c#1 add Differences ... ==== //depot/projects/ctsrd/cheribsd/src/bin/Makefile#2 (text+ko) ==== @@ -3,7 +3,9 @@ .include +# XXXRW: make cheritest conditionally built. SUBDIR= cat \ + cheritest \ chflags \ chio \ chmod \ From owner-p4-projects@FreeBSD.ORG Wed Jun 27 17:58:12 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9A79B106566C; Wed, 27 Jun 2012 17:58:12 +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 5CE5C1065673 for ; Wed, 27 Jun 2012 17:58:12 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 2CFA78FC14 for ; Wed, 27 Jun 2012 17:58:12 +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 q5RHwCuJ059838 for ; Wed, 27 Jun 2012 17:58:12 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5RHwB8a059835 for perforce@freebsd.org; Wed, 27 Jun 2012 17:58:11 GMT (envelope-from brooks@freebsd.org) Date: Wed, 27 Jun 2012 17:58:11 GMT Message-Id: <201206271758.q5RHwB8a059835@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213563 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: Wed, 27 Jun 2012 17:58:12 -0000 http://p4web.freebsd.org/@@213563?ac=10 Change 213563 by brooks@brooks_ecr_current on 2012/06/27 17:57:09 Add a copy of libmagic with a backdoor introducted that causes any file starting with the magic number BADMAGIC to have the rest of its contents executed. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libvuln_magic/Makefile#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libvuln_magic/config.h#1 branch .. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libvuln_magic/funcs.c#1 add Differences ... From owner-p4-projects@FreeBSD.ORG Wed Jun 27 22:17:51 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4F584106566B; Wed, 27 Jun 2012 22:17:50 +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 060A71065672 for ; Wed, 27 Jun 2012 22:17:50 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id E214F8FC0C for ; Wed, 27 Jun 2012 22:17:49 +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 q5RMHnnL013038 for ; Wed, 27 Jun 2012 22:17:49 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5RMHnpY013035 for perforce@freebsd.org; Wed, 27 Jun 2012 22:17:49 GMT (envelope-from brooks@freebsd.org) Date: Wed, 27 Jun 2012 22:17:49 GMT Message-Id: <201206272217.q5RMHnpY013035@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213570 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: Wed, 27 Jun 2012 22:17:51 -0000 http://p4web.freebsd.org/@@213570?ac=10 Change 213570 by brooks@brooks_ecr_current on 2012/06/27 22:16:46 Add support for an optional /etc/rcorder.startup file that contains a hardcoded ordering of scripts. It is intended to allow scripts to be run in their normal order after many scripts have been pruned from an image. This works around incomplete specification of dependencies which results in things like initrandom running very late (after sshd) in a minimal environment. Affected files ... .. //depot/projects/ctsrd/beribsd/src/etc/rc#2 edit .. //depot/projects/ctsrd/beribsd/src/etc/rc.subr#3 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/etc/rc#2 (text+ko) ==== @@ -82,7 +82,11 @@ # Do a first pass to get everything up to $early_late_divider so that # we can do a second pass that includes $local_startup directories # -files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` +if [ -r /etc/rcorder.start ]; then + files=`read_fixed_rcorder /etc/rcorder.start` +else + files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null` +fi _rc_elem_done=' ' for _rc_elem in ${files}; do @@ -104,7 +108,11 @@ *) find_local_scripts_new ;; esac -files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` +if [ -r /etc/rcorder.start ]; then + files=`read_fixed_rcorder /etc/rcorder.start` +else + files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null` +fi for _rc_elem in ${files}; do case "$_rc_elem_done" in *" $_rc_elem "*) continue ;; ==== //depot/projects/ctsrd/beribsd/src/etc/rc.subr#3 (text+ko) ==== @@ -1738,6 +1738,20 @@ esac } +read_fixed_rcorder() +{ + local _files _file + + _files="" + while read _file; do + if [ -r ${_file} ]; then + _files="${_files} ${_file}" + fi + done < $1 + + echo ${_files} +} + fi # [ -z "${_rc_subr_loaded}" ] _rc_subr_loaded=: From owner-p4-projects@FreeBSD.ORG Wed Jun 27 23:14:55 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5A8A91065674; Wed, 27 Jun 2012 23:14:55 +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 13C281065670 for ; Wed, 27 Jun 2012 23:14:55 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id F0C1E8FC19 for ; Wed, 27 Jun 2012 23:14:54 +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 q5RNEsRQ024634 for ; Wed, 27 Jun 2012 23:14:54 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5RNEslG024631 for perforce@freebsd.org; Wed, 27 Jun 2012 23:14:54 GMT (envelope-from brooks@freebsd.org) Date: Wed, 27 Jun 2012 23:14:54 GMT Message-Id: <201206272314.q5RNEslG024631@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213576 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: Wed, 27 Jun 2012 23:14:56 -0000 http://p4web.freebsd.org/@@213576?ac=10 Change 213576 by brooks@brooks_ecr_current on 2012/06/27 23:14:27 Checkpoint a copyof minifile, a stripped down version of file(1) where the dangerous analysis of a potentially untrusted file can optionally be perfomed in a capsicum sandbox (and hopefully soon in a capability protected sandbox). Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/Makefile#6 edit .. //depot/projects/ctsrd/beribsd/src/ctsrd/minifile/Makefile#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/minifile/minifile.c#1 add Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/Makefile#6 (text+ko) ==== @@ -2,6 +2,7 @@ SUBDIR= cycle_led \ flashit \ + minifile \ pictview \ showimage \ spinner From owner-p4-projects@FreeBSD.ORG Wed Jun 27 23:22:38 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 639ED1065673; Wed, 27 Jun 2012 23:22:36 +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 1A2D2106566B for ; Wed, 27 Jun 2012 23:22:36 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id DD9DC8FC0C for ; Wed, 27 Jun 2012 23:22:35 +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 q5RNMZ9d026387 for ; Wed, 27 Jun 2012 23:22:35 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5RNMZIc026384 for perforce@freebsd.org; Wed, 27 Jun 2012 23:22:35 GMT (envelope-from brooks@freebsd.org) Date: Wed, 27 Jun 2012 23:22:35 GMT Message-Id: <201206272322.q5RNMZIc026384@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213577 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: Wed, 27 Jun 2012 23:22:38 -0000 http://p4web.freebsd.org/@@213577?ac=10 Change 213577 by brooks@brooks_ecr_current on 2012/06/27 23:22:17 Add booting, upgrade in progress, and upgrade complete images. Add a -b option to make the screen black. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/Makefile#2 edit .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/booting.png#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/upgrade-complete.png#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/upgrade-inprogress.png#1 add .. //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/showimage.c#2 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/images/Makefile#2 (text+ko) ==== @@ -1,7 +1,9 @@ # From: @(#)Makefile 8.1 (Berkeley) 6/8/93 # $FreeBSD: src/share/misc/Makefile,v 1.27 2007/12/19 01:28:17 imp Exp $ -FILES= upgrade-complete.png +FILES= booting.png \ + upgrade-complete.png \ + upgrade-inprogress.png NO_OBJ= BINDIR?= ${SHAREDIR} ==== //depot/projects/ctsrd/beribsd/src/ctsrd/showimage/showimage.c#2 (text+ko) ==== @@ -48,16 +48,15 @@ usage(void) { - printf("usage: showimage \n"); + printf("usage: showimage \n"); + printf(" showimage -b\n"); exit(1); } int main(int argc, char *argv[]) { - int alpha, ch, i, ofd; - pid_t pid = 0; - char *ep; + int blank = 0; char imgpath[MAXPATHLEN]; u_int32_t *image; struct timespec stime; @@ -65,16 +64,26 @@ if (argc != 2) usage(); - if (*argv[1] == '/') - strncpy(imgpath, argv[1], sizeof(imgpath)); - else - snprintf(imgpath, sizeof(imgpath), "%s/%s", IMGDIR, argv[1]); + fb_init(); + + if (strcmp(argv[1], "-b") == 0) + blank=1; + image = malloc(sizeof(u_int32_t) * fb_height * fb_width); if (image == NULL) err(1, "malloc"); - read_png_file(imgpath, image, fb_width, fb_height); + + if (blank) + memset(image, 0, sizeof(u_int32_t) * fb_height * fb_width); + else { + if (*argv[1] == '/') + strncpy(imgpath, argv[1], sizeof(imgpath)); + else + snprintf(imgpath, sizeof(imgpath), "%s/%s", IMGDIR, + argv[1]); + read_png_file(imgpath, image, fb_width, fb_height); + } - fb_init(); fb_post(image); fb_fade2on(); fb_fade2on(); From owner-p4-projects@FreeBSD.ORG Fri Jun 29 04:06:19 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 726CD1065675; Fri, 29 Jun 2012 04:06:18 +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 1C79F106564A for ; Fri, 29 Jun 2012 04:06:18 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 0580E8FC19 for ; Fri, 29 Jun 2012 04:06:18 +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 q5T46HYj073939 for ; Fri, 29 Jun 2012 04:06:17 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5T46H06073936 for perforce@freebsd.org; Fri, 29 Jun 2012 04:06:17 GMT (envelope-from brooks@freebsd.org) Date: Fri, 29 Jun 2012 04:06:17 GMT Message-Id: <201206290406.q5T46H06073936@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213635 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: Fri, 29 Jun 2012 04:06:19 -0000 http://p4web.freebsd.org/@@213635?ac=10 Change 213635 by brooks@brooks_ecr_current on 2012/06/29 04:06:16 Add proper support to ttys which allows pictview to be run by init from /etc/ttys. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/Makefile#5 edit .. //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#6 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/Makefile#5 (text+ko) ==== @@ -9,7 +9,7 @@ WARNS= 0 -LDADD+= -lde4tc -lvuln_png -lz -lm +LDADD+= -lde4tc -lvuln_png -lz -lm -lutil # Disable the stack protector, we want to be vulnerable SSP_CFLAGS= ==== //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#6 (text+ko) ==== @@ -29,16 +29,22 @@ */ #include +#include #include +#include #include #include #include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include #include -#include -#include -#include #include @@ -48,8 +54,6 @@ u_int32_t *fb_buf; - - void pen_drawing_clear_screen(void) { @@ -140,6 +144,20 @@ read_png_file("/usr/share/images/keyboardC.png", keyboard_imgs[3], keyboard_width, keyboard_height); } +static void +writeall(int fd, const char *buf, size_t len) +{ + int wlen = 0, n; + + while (wlen != len) { + n = write(fd, buf + wlen, len - wlen); + if (n < 0) { + syslog(LOG_ALERT, "write failed: %s", strerror(errno)); + err(1, "write"); + } + wlen += n; + } +} void keyboard_on(void) @@ -152,6 +170,16 @@ int prev_keymode = -1; int keyYpos = fb_height-keyboard_height; + const int poll_timeout = touch_timeout; + int wait_poll_timeout = poll_timeout; + + static int pmaster; + static pid_t pid; + int pslave, n; + char *devpath, buf[1024]; + ssize_t rlen; + struct pollfd pfd[1]; + // extra mapping codes: // ctrl key = \xff -> keymode=3 // num key = \xfe -> keymode=2 @@ -180,6 +208,28 @@ keymap[1][1][3] = '\xff'; keymap[2][1][3] = '\xff'; + if (kbdfd < 0) { + /* XXX: need to handle the case of the shell exiting. */ + if (openpty(&pmaster, &pslave, NULL, NULL, NULL) == -1) + err(1, "openpty"); + pid = fork(); + if (pid < 0) + err(1, "fork()"); + else if (pid > 0) { + close(pslave); + kbdfd = pmaster; + } else { + close(pmaster); + if (login_tty(pslave) < 0) { + syslog(LOG_ALERT, "login_tty failed in child: %s", strerror(errno)); + err(1, "tty_login"); + } + execl("/bin/sh", "sh", NULL); + syslog(LOG_ALERT, "exec of /bin/sh failed: %s", strerror(errno)); + err(1, "execl()"); + } + } + fb_fade2off(); fb_fade2text(127); do { @@ -236,9 +286,7 @@ } if(ic < 0x80) { // printf("key = \"%c\" = 0x%02x\n", c, ic); - /* XXX: should handle full buffers */ - if (write(kbdfd, &c, 1) == -1) - err(1, "write"); + writeall(kbdfd, &c, 1); // cancel shift and ctrl modes after character sent if((keymode==1) || (keymode==3)) keymode=0; @@ -256,6 +304,43 @@ keyYpos -= fb_height; // put on screen prev_keymode = -1; // redraw keyboard } + + if (kbdfd != 0) { + if (wait_poll_timeout > 0) { + wait_poll_timeout--; + continue; + } + wait_poll_timeout = poll_timeout; + + /* + * If the child has exited, reset the state and return to the + * main screen. + */ + if (wait4(pid, NULL, WNOHANG, NULL) != 0) { + kbdfd = -1; + close(pmaster); + break; + } + + /* Check for output from the child and post it if needed */ + pfd[0].fd = pmaster; + pfd[0].events = POLLIN; + n = poll(pfd, 1, 0); + if (n == 0) + continue; + if (n < 0) { + syslog(LOG_ALERT, "poll failed with %s", strerror(errno)); + err(1, "poll"); + } + if (pfd[0].revents & POLLIN) { + rlen = read(pfd[0].fd, buf, sizeof(buf)); + if (rlen < 0) { + syslog(LOG_ALERT, "read failed: %s", strerror(errno)); + err(1, "read"); + } else if (rlen > 0) + writeall(0, buf, rlen); + } + } } while(!((touch_count==2) && (touch_gesture==0x49))); } @@ -551,7 +636,7 @@ int main(int argc, char *argv[]) { - int ofd, pipefds[2]; + int tty; pid_t pid; char *devpath; @@ -571,34 +656,21 @@ if (argc > 2) errx(1, "usage: pictview [tty]"); if (argc == 2) { - if (pipe(pipefds) == -1) - err(1, "pipe()"); - pid = fork(); - if (pid < 0) - return (pid); - else if (pid > 0) { - /* XXX: should probably wait a bit and see if the child fails quickly */ - kbdfd=pipefds[0]; - } else { - if (dup2(pipefds[1], 0) == -1) - err(1, "dup2(%d, 0)", pipefds[1]); - if (argv[1][0] != '/') - asprintf(&devpath, "/dev/%s", argv[1]); - else - devpath = argv[1]; - ofd = open(devpath, O_WRONLY); - if (ofd < 0) - err(1, "open(%s)", argv[1]); - if (dup2(ofd, 1) == -1) { - syslog(LOG_ALERT, "redir: dup2(%d, 1) failed with %d", ofd, errno); - exit(1); - } - if (dup2(ofd, 2) == -1) { - syslog(LOG_ALERT, "redir: dup2(%d, 2) failed with %d", ofd, errno); - exit(1); - } - execl("/bin/sh", "sh", "-i", NULL); - err(1, "execl()"); + kbdfd = -1; + if (argv[1][0] != '/') + asprintf(&devpath, "/dev/%s", argv[1]); + else + devpath = argv[1]; + syslog(LOG_ALERT, "opening '%s'", devpath); + if ((tty = open(devpath, O_RDWR)) < 0) { + syslog(LOG_ALERT, "open failed with %s", strerror(errno)); + err(1, "open(%s)", devpath); + } + syslog(LOG_ALERT, "opened as %d", tty); + + if (login_tty(tty) < 0) { + syslog(LOG_ALERT, "login_tty failed: %s", strerror(errno)); + err(1, "login_tty()"); } } From owner-p4-projects@FreeBSD.ORG Fri Jun 29 04:47:03 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6AAD9106567C; Fri, 29 Jun 2012 04:47:01 +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 0039B1065677 for ; Fri, 29 Jun 2012 04:47:00 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id DD2308FC08 for ; Fri, 29 Jun 2012 04:47:00 +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 q5T4l0SL082029 for ; Fri, 29 Jun 2012 04:47:00 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5T4l0Y2082026 for perforce@freebsd.org; Fri, 29 Jun 2012 04:47:00 GMT (envelope-from brooks@freebsd.org) Date: Fri, 29 Jun 2012 04:47:00 GMT Message-Id: <201206290447.q5T4l0Y2082026@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 213639 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: Fri, 29 Jun 2012 04:47:03 -0000 http://p4web.freebsd.org/@@213639?ac=10 Change 213639 by brooks@brooks_ecr_current on 2012/06/29 04:46:32 Remove a couple unnecessicary debug log messages. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#7 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#7 (text+ko) ==== @@ -661,12 +661,10 @@ asprintf(&devpath, "/dev/%s", argv[1]); else devpath = argv[1]; - syslog(LOG_ALERT, "opening '%s'", devpath); if ((tty = open(devpath, O_RDWR)) < 0) { syslog(LOG_ALERT, "open failed with %s", strerror(errno)); err(1, "open(%s)", devpath); } - syslog(LOG_ALERT, "opened as %d", tty); if (login_tty(tty) < 0) { syslog(LOG_ALERT, "login_tty failed: %s", strerror(errno));