From owner-p4-projects@FreeBSD.ORG Tue Dec 4 16:43:02 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F0D04ABA; Tue, 4 Dec 2012 16:43:01 +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 9D5FAAB8 for ; Tue, 4 Dec 2012 16:43:01 +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 6A2738FC0C for ; Tue, 4 Dec 2012 16:43:01 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4Gh1GV018841 for ; Tue, 4 Dec 2012 16:43:01 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4Gh1jr018838 for perforce@freebsd.org; Tue, 4 Dec 2012 16:43:01 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 16:43:01 GMT Message-Id: <201212041643.qB4Gh1jr018838@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219874 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, 04 Dec 2012 16:43:02 -0000 http://p4web.freebsd.org/@@219874?ac=10 Change 219874 by brooks@brooks_zenith on 2012/12/04 16:42:34 Link against the vulnerable version of libmagic. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/capsicum/Makefile#2 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/capsicum/Makefile#2 (text+ko) ==== @@ -12,7 +12,7 @@ BINDIR= /usr/libexec CFLAGS+= -I${.CURDIR}/.. -LDADD+= -lmagic -lz +LDADD+= -lvuln_magic -lz WARNS= 6 From owner-p4-projects@FreeBSD.ORG Tue Dec 4 16:44:03 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2C5D8BBF; Tue, 4 Dec 2012 16:44:03 +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 DE882BBC for ; Tue, 4 Dec 2012 16:44:02 +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 C51948FC18 for ; Tue, 4 Dec 2012 16:44:02 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4Gi2Bi018884 for ; Tue, 4 Dec 2012 16:44:02 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4Gi2MX018881 for perforce@freebsd.org; Tue, 4 Dec 2012 16:44:02 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 16:44:02 GMT Message-Id: <201212041644.qB4Gi2MX018881@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219875 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, 04 Dec 2012 16:44:03 -0000 http://p4web.freebsd.org/@@219875?ac=10 Change 219875 by brooks@brooks_zenith on 2012/12/04 16:43:54 Conditionalize the contents of this file on SOFTFLOAT_FOR_GCC so it's possible to build components without builtins. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/lib/libc/softfloat/softfloat-for-gcc.h#2 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/lib/libc/softfloat/softfloat-for-gcc.h#2 (text+ko) ==== @@ -1,6 +1,7 @@ /* $NetBSD: softfloat-for-gcc.h,v 1.8 2009/12/14 01:07:42 matt Exp $ */ /* $FreeBSD: src/lib/libc/softfloat/softfloat-for-gcc.h,v 1.3 2012/01/20 06:16:14 das Exp $ */ +#ifdef SOFTFLOAT_FOR_GCC /* * Move private identifiers with external linkage into implementation * namespace. -- Klaus Klein , May 5, 1999 @@ -167,3 +168,4 @@ #define float128_le __letf2 #define float128_gt __gttf2 #endif +#endif From owner-p4-projects@FreeBSD.ORG Tue Dec 4 16:45:04 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 996CECBF; Tue, 4 Dec 2012 16:45: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 5AEAACBD for ; Tue, 4 Dec 2012 16:45:04 +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 418AC8FC12 for ; Tue, 4 Dec 2012 16:45:04 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4Gj4Vt018919 for ; Tue, 4 Dec 2012 16:45:04 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4Gj38P018916 for perforce@freebsd.org; Tue, 4 Dec 2012 16:45:03 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 16:45:03 GMT Message-Id: <201212041645.qB4Gj38P018916@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219876 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, 04 Dec 2012 16:45:04 -0000 http://p4web.freebsd.org/@@219876?ac=10 Change 219876 by brooks@brooks_zenith on 2012/12/04 16:45:03 Allow any capitalization of .cpt. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/browser/browser.c#7 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/browser/browser.c#7 (text+ko) ==== @@ -546,7 +546,7 @@ desc = "special/character"; break; case DT_DIR: - if (fnmatch("*.cpt", entry->d_name, 0) == 0) + if (fnmatch("*.[cC][pP][tT]", entry->d_name, 0) == 0) desc = "x-application/cheripoint"; else desc = "directory"; From owner-p4-projects@FreeBSD.ORG Tue Dec 4 18:46:10 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 254FB6D5; Tue, 4 Dec 2012 18:46:10 +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 D713E6D3 for ; Tue, 4 Dec 2012 18:46:09 +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 B40628FC08 for ; Tue, 4 Dec 2012 18:46:09 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4Ik9LV023583 for ; Tue, 4 Dec 2012 18:46:09 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4Ik96b023580 for perforce@freebsd.org; Tue, 4 Dec 2012 18:46:09 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 18:46:09 GMT Message-Id: <201212041846.qB4Ik96b023580@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219877 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, 04 Dec 2012 18:46:10 -0000 http://p4web.freebsd.org/@@219877?ac=10 Change 219877 by brooks@brooks_zenith on 2012/12/04 18:45:40 Add a mostly working CHERI sandbox to minifile based on the cheripoint sandbox. This correctly identifies files and is generaly usable. However, triggering the BADMAGIC trojan causes a TLB miss exception. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/Makefile#3 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/Makefile#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/cmemcpy.h#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/execve.S#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/include/lib.h#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/include/mips.h#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/include/stdarg.h#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/malloc.c#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/minifile-cheri.c#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/mips64/chsbrt.S#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/mips64/setjmp.S#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/sandbox.ld#1 branch .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/stub.c#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/subr_prf.c#1 add .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.c#5 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.h#2 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/Makefile#3 (text+ko) ==== @@ -2,6 +2,7 @@ # $FreeBSD$ SUBDIR+= capsicum +SUBDIR+= cheri PROG= minifile @@ -9,6 +10,6 @@ WARNS= 0 -LDADD+= -lvuln_magic +LDADD+= -lcheri -lvuln_magic .include ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.c#5 (text+ko) ==== @@ -1,14 +1,19 @@ -#include +#include #include #include #include #include +#include +#include + #include #include #include #include +#include +#include #include #include #include @@ -146,6 +151,85 @@ return type; } +static struct chericap file_cap, magic_cap, out_cap; + +const char * +cheri_magic_descriptor(int mfd, int fd) +{ + register_t v; + size_t outsize, magicsize, filesize; + char *filebuf = NULL; + void *magicbuf = NULL; + struct sandbox *sandbox; + struct stat filesb, magicsb; + static char outbuf[4096]; + const char *type; + char *ttype; + + type = "badfile"; + + outsize = 128; + CHERI_CINCBASE(10, 0, outbuf); + CHERI_CSETLEN(10, 10, outsize); + CHERI_CANDPERM(10, 10, CHERI_PERM_STORE); + CHERI_CSC(10, 0, &out_cap, 0); + + if (fstat(mfd, &magicsb) == -1) + err(1, "fstat magic fd"); + magicsize = magicsb.st_size; + if ((magicbuf = mmap(NULL, magicsize, PROT_READ|PROT_WRITE, + MAP_PRIVATE, mfd, 0)) == MAP_FAILED) { + warn("mmap magic fd"); + goto error; + } + CHERI_CINCBASE(10, 0, magicbuf); + CHERI_CSETLEN(10, 10, magicsize); + CHERI_CANDPERM(10, 10, CHERI_PERM_LOAD); + CHERI_CSC(10, 0, &magic_cap, 0); + + if (fstat(fd, &filesb) == -1) + err(1, "fstat input fd"); + filesize = MIN(MINIFILE_BUF_MAX, filesb.st_size); + if ((filebuf = mmap(NULL, filesize, PROT_READ, 0, fd, 0)) == + MAP_FAILED) { + warn("mmap input fd"); + goto error; + } + CHERI_CINCBASE(10, 0, filebuf); + CHERI_CSETLEN(10, 10, filesize); + CHERI_CANDPERM(10, 10, CHERI_PERM_LOAD); + CHERI_CSC(10, 0, &file_cap, 0); + + if (sandbox_setup("/usr/libexec/minifile-cheri.bin", 8*1024*1024, + &sandbox) < 0) + goto error; + + v = sandbox_invoke(sandbox, outsize, magicsize, filesize, 0, + &out_cap, &magic_cap, &file_cap, NULL, NULL, NULL, NULL); + printf("%s: sandbox returned %ju\n", __func__, (uintmax_t)v); + + sandbox_destroy(sandbox); + + outsize = strnlen(outbuf, outsize); + if (v == 0) { + ttype = outbuf + outsize; + strvisx(ttype, outbuf, outsize, 0); + type = ttype; + } else { + ttype = outbuf + outsize; + strvisx(ttype, outbuf, outsize, 0); + type = ttype; + } + +error: + if (munmap(magicbuf, magicsize) == -1) + warn("munmap magicbuf"); + if (munmap(filebuf, filesize) == -1) + warn("munmap filebuf"); + + return type; +} + int main(int argc, char **argv) { @@ -227,10 +311,14 @@ errx(1, "capsicum_magic_descriptor()"); break; case SB_CHERI: - errx(1, "no cheri capability support yet"); + type = cheri_magic_descriptor(mfd, fd); + if (type == NULL) + errx(1, "cheri_magic_descriptor()"); + break; default: errx(1, "invalid sandbox type"); } + close(fd); printf("%s: %s\n", fname, type); } } ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.h#2 (text+ko) ==== @@ -1,7 +1,9 @@ -#define MAGIC_FILE "/usr/share/misc/magic.mgc" +#define MINIFILE_FILE_FD 3 +#define MINIFILE_MAGIC_FD 4 +#define MINIFILE_OUT_FD 5 + +#define MINIFILE_OUT_CAP 1 +#define MINIFILE_MAGIC_CAP 2 +#define MINIFILE_FILE_CAP 3 -#define MINIFILE_FILE_FD 3 -#define MINIFILE_MAGIC_FD 4 -#define MINIFILE_OUT_FD 5 -#define MINIFILE_MAX_FD MINIFILE_OUT_FD -#define MINIFILE_BUF_MAX 4096 +#define MINIFILE_BUF_MAX 4096 From owner-p4-projects@FreeBSD.ORG Tue Dec 4 19:40:06 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 32070406; Tue, 4 Dec 2012 19:40:06 +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 E60AA404 for ; Tue, 4 Dec 2012 19:40:05 +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 CB9E98FC17 for ; Tue, 4 Dec 2012 19:40:05 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4Je5pu025608 for ; Tue, 4 Dec 2012 19:40:05 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4Je51f025605 for perforce@freebsd.org; Tue, 4 Dec 2012 19:40:05 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 19:40:05 GMT Message-Id: <201212041940.qB4Je51f025605@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219878 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, 04 Dec 2012 19:40:06 -0000 http://p4web.freebsd.org/@@219878?ac=10 Change 219878 by brooks@brooks_zenith on 2012/12/04 19:39:56 Fix selection of Cheri and Visible in the config dialog. Contrary to my sleep deprived mind's opinion, the first three positive integers are 1, 2, and 3, not 1, 2, and 4. Clean up the code that assembles the dialog by using alread computed values rather than somewhat mysterious sums. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#16 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#16 (text+ko) ==== @@ -254,7 +254,7 @@ fb_render_text("Sandbox", 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH, CD_BORDER_WIDTH + (0 * f_height), + sb_startc, cfg_startr + (0 * f_height), textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); @@ -262,7 +262,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH, CD_BORDER_WIDTH + (1 * f_height), + sb_startc, cfg_startr + (1 * f_height), textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); @@ -270,7 +270,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH, CD_BORDER_WIDTH + (2 * f_height), + sb_startc, cfg_startr + (2 * f_height), textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); @@ -278,7 +278,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH, CD_BORDER_WIDTH + (3 * f_height), + sb_startc, cfg_startr + (3 * f_height), textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); @@ -286,15 +286,14 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH, CD_BORDER_WIDTH + (5 * f_height), + sb_startc, cfg_startr + (5 * f_height), textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); fb_render_text("Resolution", 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH + (f_width * CD_SB_COLS) + CD_GAP, - CD_BORDER_WIDTH + (0 * f_height), + res_startc, cfg_startr + (0 * f_height), textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); @@ -302,8 +301,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH + (f_width * CD_SB_COLS) + CD_GAP, - CD_BORDER_WIDTH + (1 * f_height), + res_startc, cfg_startr + (1 * f_height), textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); @@ -311,8 +309,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH + (f_width * CD_SB_COLS) + CD_GAP, - CD_BORDER_WIDTH + (2 * f_height), + res_startc, cfg_startr + (2 * f_height), textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); @@ -320,8 +317,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH + (f_width * CD_SB_COLS) + CD_GAP, - CD_BORDER_WIDTH + (3 * f_height), + res_startc, cfg_startr + (3 * f_height), textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); @@ -330,8 +326,7 @@ fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, - CD_BORDER_WIDTH + (f_width * CD_SB_COLS) + CD_GAP, - CD_BORDER_WIDTH + (4 * f_height), + res_startc, cfg_startr + (4 * f_height), textbuf, f_width * CD_RES_COLS, f_height); fb_post_region(dbuf, d_x, d_y, d_width, d_height); @@ -350,7 +345,7 @@ case TSG_SOUTH: goto done; case TSG_CLICK: - row = (ts->ts_y1 - d_y - cfg_startr) / f_height; + row = (ts->ts_y1 - (d_y + cfg_startr)) / f_height; if ((uint)ts->ts_x1 > d_x + sb_startc && (uint)ts->ts_x1 < d_x + sb_endc) { switch (row) { @@ -368,14 +363,14 @@ goto repaint; } break; - case 4: + case 3: if (sb != SB_CHERI) { changed = 1; sb = SB_CHERI; goto repaint; } break; - case 6: + case 5: changed = 1; sb_vis = sb_vis ? 0 : 1; goto repaint; From owner-p4-projects@FreeBSD.ORG Tue Dec 4 21:30:00 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 29A27717; Tue, 4 Dec 2012 21:30:00 +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 D1F32715 for ; Tue, 4 Dec 2012 21:29:59 +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 B5C228FC13 for ; Tue, 4 Dec 2012 21:29:59 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4LTxkR029485 for ; Tue, 4 Dec 2012 21:29:59 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4LTx3x029482 for perforce@freebsd.org; Tue, 4 Dec 2012 21:29:59 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 21:29:59 GMT Message-Id: <201212042129.qB4LTx3x029482@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219879 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, 04 Dec 2012 21:30:00 -0000 http://p4web.freebsd.org/@@219879?ac=10 Change 219879 by brooks@brooks_zenith on 2012/12/04 21:29:41 Double the speed of the CHERI sandbox case by reuseing the sandbox environment. This makes it faster than capsicum in the multiple file case (as with cheribrowser). Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.c#6 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/minifile.c#6 (text+ko) ==== @@ -151,16 +151,15 @@ return type; } +static struct sandbox *sandbox; static struct chericap file_cap, magic_cap, out_cap; const char * -cheri_magic_descriptor(int mfd, int fd) +cheri_magic_descriptor(void *magicbuf, size_t magicsize, int fd) { register_t v; - size_t outsize, magicsize, filesize; + size_t outsize, filesize; char *filebuf = NULL; - void *magicbuf = NULL; - struct sandbox *sandbox; struct stat filesb, magicsb; static char outbuf[4096]; const char *type; @@ -174,14 +173,6 @@ CHERI_CANDPERM(10, 10, CHERI_PERM_STORE); CHERI_CSC(10, 0, &out_cap, 0); - if (fstat(mfd, &magicsb) == -1) - err(1, "fstat magic fd"); - magicsize = magicsb.st_size; - if ((magicbuf = mmap(NULL, magicsize, PROT_READ|PROT_WRITE, - MAP_PRIVATE, mfd, 0)) == MAP_FAILED) { - warn("mmap magic fd"); - goto error; - } CHERI_CINCBASE(10, 0, magicbuf); CHERI_CSETLEN(10, 10, magicsize); CHERI_CANDPERM(10, 10, CHERI_PERM_LOAD); @@ -200,30 +191,19 @@ CHERI_CANDPERM(10, 10, CHERI_PERM_LOAD); CHERI_CSC(10, 0, &file_cap, 0); - if (sandbox_setup("/usr/libexec/minifile-cheri.bin", 8*1024*1024, - &sandbox) < 0) - goto error; - v = sandbox_invoke(sandbox, outsize, magicsize, filesize, 0, &out_cap, &magic_cap, &file_cap, NULL, NULL, NULL, NULL); printf("%s: sandbox returned %ju\n", __func__, (uintmax_t)v); - sandbox_destroy(sandbox); - outsize = strnlen(outbuf, outsize); if (v == 0) { ttype = outbuf + outsize; strvisx(ttype, outbuf, outsize, 0); type = ttype; - } else { - ttype = outbuf + outsize; - strvisx(ttype, outbuf, outsize, 0); - type = ttype; - } + } else + type = "badmagic"; error: - if (munmap(magicbuf, magicsize) == -1) - warn("munmap magicbuf"); if (munmap(filebuf, filesize) == -1) warn("munmap filebuf"); @@ -237,9 +217,10 @@ void *magicbuf; const char *fname; int mfd, fd; + size_t magicsize; const char *type; struct magic_set *magic; - struct stat sb; + struct stat magicsb; while ((ch = getopt(argc, argv, "s:")) != -1) { switch(ch) { @@ -262,38 +243,42 @@ if (argc <= 0) usage(); + /* Open the magic file */ mfd = open(MAGIC_FILE, O_RDONLY); - if (mfd == -1) { - warn("open(%s)", MAGIC_FILE); - magic_close(magic); - exit(1); - } + if (mfd == -1) + err(1, "open(%s)", MAGIC_FILE); - if (sbtype == SB_NONE) { - magic = magic_open(MAGIC_MIME_TYPE); - if (magic == NULL) - errx(1, "magic_open()"); - if (fstat(mfd, &sb) == -1) { + /* For the NONE and CHERI cases, pre-map the file */ + if (sbtype == SB_NONE || sbtype == SB_CHERI) { + if (fstat(mfd, &magicsb) == -1) { warn("fstat(%s)", MAGIC_FILE); - magic_close(magic); exit(1); } - magicbuf = mmap(NULL, sb.st_size, PROT_READ|PROT_WRITE, - MAP_PRIVATE, mfd, 0); - if (magicbuf == MAP_FAILED) { + magicsize = magicsb.st_size; + if ((magicbuf = mmap(NULL, magicsize, PROT_READ|PROT_WRITE, + MAP_PRIVATE, mfd, 0)) == MAP_FAILED) { warn("mmap(%s)", MAGIC_FILE); magic_close(magic); exit(1); } - close(mfd); - if (magic_load_buffers(magic, &magicbuf, &sb.st_size, 1) == - -1) { + } + + if (sbtype == SB_NONE) { + magic = magic_open(MAGIC_MIME_TYPE); + if (magic == NULL) + errx(1, "magic_open()"); + if (magic_load_buffers(magic, &magicbuf, &magicsize, 1) == -1) { warnx("magic_load() %s", magic_error(magic)); magic_close(magic); exit(1); } } + if (sbtype == SB_CHERI) + if (sandbox_setup("/usr/libexec/minifile-cheri.bin", 8*1024*1024, + &sandbox) < 0) + err(1, "can't create cheri sandbox"); + for (; argc >= 1; argc--, argv++) { fname = argv[0]; fd = open(fname, O_RDONLY); @@ -311,7 +296,7 @@ errx(1, "capsicum_magic_descriptor()"); break; case SB_CHERI: - type = cheri_magic_descriptor(mfd, fd); + type = cheri_magic_descriptor(magicbuf, magicsize, fd); if (type == NULL) errx(1, "cheri_magic_descriptor()"); break; @@ -321,4 +306,7 @@ close(fd); printf("%s: %s\n", fname, type); } + + if (sbtype == SB_CHERI) + sandbox_destroy(sandbox); } From owner-p4-projects@FreeBSD.ORG Tue Dec 4 22:53:26 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B6D34288; Tue, 4 Dec 2012 22:53:26 +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 72A63286 for ; Tue, 4 Dec 2012 22:53:26 +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 582938FC19 for ; Tue, 4 Dec 2012 22:53:26 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB4MrQRE031982 for ; Tue, 4 Dec 2012 22:53:26 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB4MrQE1031979 for perforce@freebsd.org; Tue, 4 Dec 2012 22:53:26 GMT (envelope-from brooks@freebsd.org) Date: Tue, 4 Dec 2012 22:53:26 GMT Message-Id: <201212042253.qB4MrQE1031979@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219880 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, 04 Dec 2012 22:53:27 -0000 http://p4web.freebsd.org/@@219880?ac=10 Change 219880 by brooks@brooks_zenith on 2012/12/04 22:52:29 Always center and left extend under-width title slides. Correct the position of the sandbox indicator when the slides aren't left aligned. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#17 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#17 (text+ko) ==== @@ -443,7 +443,7 @@ render_cover(int dfd, const char *cover) { int pfd; - uint32_t r; + uint32_t r, fcol; struct iboxstate *is; busy(1); @@ -461,24 +461,25 @@ warnx("png_read_finish() failed for %s", cover); return (-1); } + fcol = slide_fcol + ((slide_width - is->width) / 2); fb_fill_region(white, 0, 0, fb_width, fb_height); - fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), slide_fcol, 0, + fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), fcol, 0, is->width, is->height); - if (slide_fcol > 0) { + if (fcol > 0) { /* Left extend the image if needed */ for (r = 0; r < is->height; r++) fb_fill_region(is->buffer[r * is->width], - 0, r, slide_fcol, 1); + 0, r, fcol, 1); } if (is->width < (uint)fb_width) { /* Right extend the image if needed */ for (r = 0; r < is->height; r++) fb_fill_region(is->buffer[((r + 1) * is->width) - 1], - slide_fcol + is->width, r, - fb_width - (slide_fcol + is->width), 1); + fcol + is->width, r, + fb_width - (fcol + is->width), 1); } if (sb_vis && sb != SB_NONE) - fb_rectangle(red, 2, 0, 0, is->width, is->height); + fb_rectangle(red, 2, fcol, 0, is->width, is->height); iboxstate_free(is); unbusy(); From owner-p4-projects@FreeBSD.ORG Wed Dec 5 00:02:38 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8EC75AB; Wed, 5 Dec 2012 00:02:38 +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 42E66A9 for ; Wed, 5 Dec 2012 00:02:38 +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 28C2E8FC08 for ; Wed, 5 Dec 2012 00:02:38 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB502bU0034402 for ; Wed, 5 Dec 2012 00:02:37 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB502bBo034399 for perforce@freebsd.org; Wed, 5 Dec 2012 00:02:37 GMT (envelope-from brooks@freebsd.org) Date: Wed, 5 Dec 2012 00:02:37 GMT Message-Id: <201212050002.qB502bBo034399@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219881 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: Wed, 05 Dec 2012 00:02:38 -0000 http://p4web.freebsd.org/@@219881?ac=10 Change 219881 by brooks@brooks_zenith on 2012/12/05 00:02:09 Add the ability to include a second set of slides with a second -s argument. We can now include both briefing and demo slides on the front page. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/Makefile#3 edit .. //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#8 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/Makefile#3 (text+ko) ==== @@ -9,7 +9,7 @@ WARNS= 0 -LDADD+= -lde4tc -lvuln_png -lz -lm -lutil +LDADD+= -lde4tc -limagebox -lvuln_png -lz -lm -lutil -lcheri -lpthread # Disable the stack protector, we want to be vulnerable SSP_CFLAGS= ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#8 (text+ko) ==== @@ -52,6 +52,7 @@ #include #include +#include static pid_t browser_pid; static pid_t kbd_pid; @@ -370,23 +371,72 @@ * Picture viewer including PNG image loader *****************************************************************************/ -static const int selector_nimages=4; -static u_int32_t *selector_images[4]; +static const int selector_nimages=5; +static u_int32_t *selector_images[5]; static char *slide_dir = NULL; -static int slide_nimages; -static u_int32_t **slide_images; +static char *slide_dir2 = NULL; +static u_int32_t *coverimage, *coverimage2; static u_int32_t *bgimage; #define SEL_SLIDE_IMG 0 #define SEL_QUILL_IMG 1 #define SEL_TERM_IMG 2 #define SEL_BROWSER_IMG 3 +#define SEL_SLIDE_IMG2 4 -static int -strpcmp(const void *v1, const void *v2) +static uint32_t * +loadcover(const char *dir) { + DIR *dirp; + struct dirent *entry; + char *covername; + uint32_t *image; + int fd; + uint32_t c, fcol, r; + struct iboxstate *is; - return (strcmp(*((const char**)v1), *((const char**)v2))); + covername = NULL; + if ((dirp = opendir(dir)) == NULL) + err(1, "opendir"); + while((entry = readdir(dirp)) != NULL) { + /* XXX: doesn't support symlinks */ + if (entry->d_type != DT_REG) + continue; + /* Ignore all files other than covers. */ + if (fnmatch("*-cover-*.png", entry->d_name, 0) != 0) + continue; + covername = entry->d_name; + break; + } + if (covername == NULL) + errx(1, "No cover found in %s", dir); + + if ((fd = openat(dirfd(dirp), covername, O_RDONLY)) == -1) + err(1, "openat(dir, %s)", covername); + if ((is = png_read_start(fd, fb_width, fb_height, SB_NONE)) == NULL) + errx(1, "Failed to start PNG decode for %s", covername); + if (png_read_finish(is) != 0) + errx(1, "png_read_finish() failed for icons.png"); + + image = malloc(sizeof(u_int32_t) * fb_width * fb_height); + if (image == NULL) + err(1, "malloc image]"); + fcol = (fb_width - is->width) / 2; + fb_composite(image, fb_width, fb_height, fcol, 0, + is->buffer, is->width, is->height); + if (is->width != fb_width) { + for (r = 0; r < is->height; r++) { + for (c = 0; c < fcol; c++) + image[c + (r * fb_width)] = image[fcol + (r * fb_width)]; + for (c = fcol + is->width; c < fb_width; c++) + image[c + (r * fb_width)] = image[fcol + is->width - 1 + (r * fb_width)]; + } + } + iboxstate_free(is); + close(fd); + closedir(dirp); + + return (image); } // initialisation - load the images to view @@ -399,72 +449,18 @@ busy_indicator(); read_png_file("/usr/share/images/CatSword.png", bgimage, fb_width, fb_height); - if (slide_dir == NULL) { - slide_nimages = 3; - if ((slide_images = malloc(sizeof(*slide_images) * slide_nimages)) == NULL) - err(1, "malloc slide_images"); - for(j = 0; j < slide_nimages; j++) - if ((slide_images[j] = malloc(sizeof(u_int32_t) * fb_width * fb_height)) == NULL) - err(1, "malloc slide_images[%d]", j); - busy_indicator(); - read_png_file("/usr/share/images/Canon-5DII-5487.png", slide_images[0], fb_width, fb_height); - busy_indicator(); - read_png_file("/usr/share/images/Canon-5DII-4717.png", slide_images[1], fb_width, fb_height); - busy_indicator(); - read_png_file("/usr/share/images/Canon-5DII-3816.png", slide_images[2], fb_width, fb_height); - } else { - DIR *dirp; - struct dirent *entry; - char **slidenames; - int fd, maxslides; + coverimage = loadcover(slide_dir); - if ((dirp = opendir(slide_dir)) == NULL) - err(1, "opendir"); - slide_nimages = 0; - maxslides = 1024; - slidenames = malloc(sizeof(*slidenames) * maxslides); - if (slidenames == NULL) - err(1, "malloc slidenames"); - while((entry = readdir(dirp)) != NULL) { - /* XXX: doesn't support symlinks */ - if (entry->d_type != DT_REG) - continue; - /* Ignore all files other than covers. */ - if (fnmatch("*-cover-*.png", entry->d_name, 0) != 0) - continue; - if (slide_nimages == maxslides) { - maxslides *= 2; - slidenames = realloc(slidenames, sizeof(*slidenames) * maxslides); - if (slidenames == NULL) - err(1, "realloc slidenames"); - } - slidenames[slide_nimages] = strdup(entry->d_name); - if (slidenames[slide_nimages] == NULL) - err(1, "strdup"); - slide_nimages++; - } - qsort(slidenames, slide_nimages, sizeof(*slidenames), &strpcmp); - slide_images = malloc(sizeof(*slide_images) * slide_nimages); - if (slide_images == NULL) - err(1, "malloc slide_images"); - for (j = 0; j < slide_nimages; j++) { - slide_images[j] = malloc(sizeof(u_int32_t) * fb_width * fb_height); - if (slide_images[j] == NULL) - err(1, "malloc slide_images[%d]", j); - if ((fd = openat(dirfd(dirp), slidenames[j], O_RDONLY)) == -1) - err(1, "openat(slide_dir, %s)", slidenames[j]); - if (read_png_fd(fd, slide_images[j], fb_width, fb_height) != 0) - errx(1, "failed to read png %s", slidenames[j]); - close(fd); - free(slidenames[j]); - } - closedir(dirp); - free(slidenames); - } + if (slide_dir2 != NULL) + coverimage2 = loadcover(slide_dir2); + else + coverimage2 = NULL; for(j=0; jts_gesture == TSG2_ZOOM_OUT) - break; - - if((ts->ts_count==0) && (pan_direction!=-1)) { - // touch released so decide which image to view - if((pan_direction==0) && (ts->ts_x1>(fb_width/2))) - display_image = next_display_image; - if((pan_direction==1) && (ts->ts_x1<(fb_width/2))) - display_image = next_display_image; - pan_direction = -1; - for(k=0; kts_count==1) { - if((pan_direction==-1) && (ts->ts_x1>(5*fb_width/6))) { // pan image to right - pan_direction=1; - next_display_image = (display_image + 1) % slide_nimages; - prev_ts_x1 = fb_width-1; - //printf("display_image=%1d next_display_image=%1d\n",display_image,next_display_image); - } - if((pan_direction==-1) && (ts->ts_x1<(fb_width/6))) { // pan image to left - pan_direction=0; - next_display_image = (display_image == 0) ? slide_nimages - 1 : display_image - 1; - prev_ts_x1 = 0; - //printf("display_image=%1d next_display_image=%1d\n",display_image,next_display_image); - } - if(pan_direction!=-1) { - int img0, img1; - if(pan_direction==0) { - img0=next_display_image; - img1=display_image; - } else { - img1=next_display_image; - img0=display_image; - } - // printf("%1d",pan_direction); - for(y=0; yts_x1; x++) - fb_buf[x+k] = slide_images[img0][x+k]; - for(x=ts->ts_x1; x<=prev_ts_x1; x++) - fb_buf[x+k] = slide_images[img1][x+k]; - } - fb_post(fb_buf); - prev_ts_x1 = ts->ts_x1; - } - } - } -} -#else static void -pictview_pan(void) +run_cheripoint(const char *dir) { static int pmaster; int pslave, n; @@ -794,7 +720,7 @@ syslog(LOG_ALERT, "login_tty failed in child: %s", strerror(errno)); err(1, "tty_login"); } - execl("/usr/bin/cheripoint", "cheripoint", "-f", slide_dir, NULL); + execl("/usr/bin/cheripoint", "cheripoint", "-f", dir, NULL); syslog(LOG_ALERT, "exec of /usr/bin/cheripoint failed: %s", strerror(errno)); err(1, "execl()"); } @@ -834,7 +760,6 @@ } } } -#endif void @@ -923,7 +848,9 @@ else if(display_image == SEL_BROWSER_IMG) run_browser(); else if(display_image == SEL_SLIDE_IMG) - pictview_pan(); + run_cheripoint(slide_dir); + else if(display_image == SEL_SLIDE_IMG2) + run_cheripoint(slide_dir2); } } @@ -931,6 +858,8 @@ static void usage(void) { + fprintf(stderr, "usage: pictview [-s ] [-s ]\n"); + exit(1); } @@ -963,10 +892,15 @@ while ((ch = getopt(argc, argv, "s:")) != -1) { switch (ch) { case 's': - slide_dir = optarg; + if (slide_dir == NULL) + slide_dir = optarg; + else if (slide_dir2 == NULL) + slide_dir2 = optarg; + else + usage(); + break; default: usage(); - /* ENOKABOOMHERE */ } } argc -= optind; @@ -991,12 +925,10 @@ } } -#ifndef USE_HW_ENG_CODE if (slide_dir == NULL) { + warnx("usage: must pass in -s "); usage(); - err(1, "usage: must pass in -s "); } -#endif pictview(); From owner-p4-projects@FreeBSD.ORG Wed Dec 5 18:29:01 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0DDDEC3; Wed, 5 Dec 2012 18:29:01 +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 B91C9C1 for ; Wed, 5 Dec 2012 18:29: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 9EEA68FC15 for ; Wed, 5 Dec 2012 18:29:00 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB5IT0uh078246 for ; Wed, 5 Dec 2012 18:29:00 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB5IT0Vb078243 for perforce@freebsd.org; Wed, 5 Dec 2012 18:29:00 GMT (envelope-from brooks@freebsd.org) Date: Wed, 5 Dec 2012 18:29:00 GMT Message-Id: <201212051829.qB5IT0Vb078243@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219886 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: Wed, 05 Dec 2012 18:29:01 -0000 http://p4web.freebsd.org/@@219886?ac=10 Change 219886 by brooks@brooks_zenith on 2012/12/05 18:28:12 Improve the stub malloc to allocated 32-byte aligned chunks with size data and red zone padding in front of each allocation. ~1% performance improvement. Don't verify the readzones for now. It's slower and there's a bug I've not yet tracked down in the case of files smaller than a page. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/malloc.c#2 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/minifile/cheri/malloc.c#2 (text+ko) ==== @@ -34,6 +34,19 @@ #include #include +#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed"); + +static const uint64_t red0 = 0x0123456789ABCDEF; +static const uint64_t red1 = 0xFEDCBA9876543210; + +struct minfo { + uint64_t red0; + size_t size; + size_t rsize; + uint64_t red1; +}; +CTASSERT(sizeof(struct minfo) == 32); + void *_sb_heapbase; size_t _sb_heaplen; @@ -41,13 +54,22 @@ malloc(size_t size) { size_t rsize; + struct minfo *minfo; char *ptr; - rsize = roundup2(size, 4096); - if (_sb_heaplen < rsize) + rsize = roundup2(size, sizeof(minfo)); + if (_sb_heaplen < rsize + sizeof(minfo)) return (NULL); - ptr = _sb_heapbase; + minfo = _sb_heapbase; + *minfo = (struct minfo) { + .red0 = red0, + .size = size, + .rsize = rsize, + .red1 = red1 + }; + _sb_heaplen -= sizeof(minfo); + ptr = (char *)(minfo + 1); _sb_heaplen -= rsize; _sb_heapbase = ptr + rsize; @@ -67,22 +89,42 @@ } void -free(void *ptr __unused) +free(void *ptr) { +#ifdef CHECK_RZ + struct minfo *minfo; + minfo = ptr; + minfo--; + if (minfo->red0 != red0 || minfo->red1 != red1) + abort(); +#endif } void * realloc(void *ptr, size_t size) { char *nptr; + struct minfo *minfo; + + if (ptr == NULL) + return (malloc(size)); + + minfo = ptr; + minfo--; +#ifdef CHECK_RZ + if (minfo->red0 != red0 || minfo->red1 != red1) + abort(); +#endif - if (size <= 4096 && ptr != NULL) + if (size <= minfo->rsize) { + minfo->size = size; return (ptr); + } nptr = malloc(size); - if (nptr != NULL && ptr != NULL) { - memcpy(nptr, ptr, MIN(size, (size_t)nptr - (size_t)ptr)); + if (nptr != NULL) { + memcpy(nptr, ptr, minfo->size); free(ptr); } From owner-p4-projects@FreeBSD.ORG Wed Dec 5 19:46:21 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 63D275D1; Wed, 5 Dec 2012 19:46:21 +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 1EB295CF for ; Wed, 5 Dec 2012 19:46: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 0096B8FC15 for ; Wed, 5 Dec 2012 19:46:21 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB5JkKaJ081393 for ; Wed, 5 Dec 2012 19:46:20 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB5JkKNP081390 for perforce@freebsd.org; Wed, 5 Dec 2012 19:46:20 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 5 Dec 2012 19:46:20 GMT Message-Id: <201212051946.qB5JkKNP081390@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 219887 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: Wed, 05 Dec 2012 19:46:21 -0000 http://p4web.freebsd.org/@@219887?ac=10 Change 219887 by rwatson@rwatson_svr_ctsrd_mipsbuild on 2012/12/05 19:46:16 Merge an additional change from Mike Roe's GNU assembler support for CHERI ISAv2: commit c5f6f3cb5dfaa08de554deaa0236499fbc1fb860 Author: Michael Roe Date: Tue Oct 30 13:54:32 2012 +0000 Added assembler support for immediate offsets with the store operations. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/contrib/binutils/gas/config/tc-mips.c#5 edit .. //depot/projects/ctsrd/cheribsd/src/contrib/binutils/include/opcode/mips.h#3 edit .. //depot/projects/ctsrd/cheribsd/src/contrib/binutils/opcodes/mips-dis.c#4 edit .. //depot/projects/ctsrd/cheribsd/src/contrib/binutils/opcodes/mips-opc.c#10 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/contrib/binutils/gas/config/tc-mips.c#5 (text+ko) ==== @@ -8424,6 +8424,7 @@ case 'H': USE_BITS (OP_MASK_EXTMSBD, OP_SH_EXTMSBD); break; case 'I': break; case 'o': USE_BITS (OP_MASK_CDELTA, OP_SH_CDELTA); break; + case 'O': USE_BITS (OP_MASK_CDELTA2, OP_SH_CDELTA2); break; case 't': USE_BITS (OP_MASK_RT, OP_SH_RT); break; case 'T': USE_BITS (OP_MASK_RT, OP_SH_RT); USE_BITS (OP_MASK_SEL, OP_SH_SEL); break; @@ -9216,6 +9217,14 @@ s = expr_end; continue; + case 'O': + my_getExpression (&imm_expr, s); + check_absolute_expr (ip, &imm_expr); + INSERT_OPERAND (CDELTA2, *ip, imm_expr.X_add_number); + imm_expr.X_op = O_absent; + s = expr_end; + continue; + case 'T': /* Coprocessor register. */ /* +T is for disassembly only; never match. */ break; ==== //depot/projects/ctsrd/cheribsd/src/contrib/binutils/include/opcode/mips.h#3 (text+ko) ==== @@ -104,6 +104,8 @@ #define OP_SH_DELTA 0 #define OP_MASK_CDELTA 0x7ff #define OP_SH_CDELTA 0 +#define OP_MASK_CDELTA2 0xff +#define OP_SH_CDELTA2 3 #define OP_MASK_FUNCT 0x3f #define OP_SH_FUNCT 0 #define OP_MASK_SPEC 0x3f @@ -310,10 +312,11 @@ "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD). Requires that "+A" or "+E" occur first to set position. Enforces: 32 < (pos+size) <= 64. + "+O" 8 bit signed offset (OP_*_CDELTA2) "+w" 5 bit source or destination capability register (OP_*_RT) "+b" 5 bit source or target capability register (OP_*_RD) "+v" 5 bit target capability register (OP_*_FD) - "+o" 11 bit unsigned offset (OP_*_CDELTA) + "+o" 11 bit signed offset (OP_*_CDELTA) Floating point instructions: "D" 5 bit destination register (OP_*_FD) ==== //depot/projects/ctsrd/cheribsd/src/contrib/binutils/opcodes/mips-dis.c#4 (text+ko) ==== @@ -918,11 +918,17 @@ (*info->fprintf_func) (info->stream, "c%d", (l >> OP_SH_RS) & OP_MASK_RS); break; + case 'o': delta = ((l >> OP_SH_CDELTA) & OP_MASK_CDELTA); (*info->fprintf_func) (info->stream, "%d", delta); break; + case 'O': + delta = ((l >> OP_SH_CDELTA2) & OP_MASK_CDELTA2); + (*info->fprintf_func) (info->stream, "%d", delta); + break; + default: /* xgettext:c-format */ (*info->fprintf_func) (info->stream, ==== //depot/projects/ctsrd/cheribsd/src/contrib/binutils/opcodes/mips-opc.c#10 (text+ko) ==== @@ -188,71 +188,85 @@ {"move", "d,s", 0x0000002d, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, I3 },/* daddu */ {"move", "d,s", 0x00000021, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, I1 },/* addu */ {"move", "d,s", 0x00000025, 0xfc1f07ff, WR_d|RD_s, INSN2_ALIAS, I1 },/* or */ -{"cgetperm","t,+b", 0x48000000, 0xffe007ff, 0, 0, I1}, -{"cgettype","t,+b", 0x48000001, 0xffe007ff, 0, 0, I1}, -{"cgetbase","t,+b", 0x48000002, 0xffe007ff, 0, 0, I1}, -{"cgetlen", "t,+b", 0x48000003, 0xffe007ff, 0, 0, I1}, -{"cgetcause", "t", 0x48000004, 0xffe0ffff, 0, 0, I1}, -{"cgettag", "t,+b", 0x48000005, 0xffe007ff, 0, 0, I1}, -{"cgetunsealed", "t,+b", 0x48000006, 0xffe007ff, 0, 0, I1}, -{"cgetpcc", "t(+b)", 0x48000007, 0xffe007ff, 0, 0, I1}, -{"candperm","+w,+b,m", 0x48800000, 0xffe0003f, 0, 0, I1}, -{"csettype","+w,+b,m", 0x48800001, 0xffe0003f, 0, 0, I1}, -{"cincbase","+w,+b,m", 0x48800002, 0xffe0003f, 0, 0, I1}, -{"cmove", "+w,+b", 0x48800002, 0xffe007ff, 0, 0, I1}, -{"csetlen", "+w,+b,m", 0x48800003, 0xffe0003f, 0, 0, I1}, -{"ccleartag", "+w", 0x48800005, 0xffe0ffff, 0, 0, I1}, -{"csc", "+x,d,+o(+w)", 0xf8000000, 0xfc000000, 0, 0, I1}, -{"clc", "+x,d,+o(+w)", 0xd8000000, 0xfc000000, 0, 0, I1}, -{"cscr", "+x,d(+w)", 0xf8000000, 0xfc0007ff, 0, 0, I1}, -{"clcr", "+x,d(+w)", 0xd8000000, 0xfc0007ff, 0, 0, I1}, -{"csci", "+x,+o(+w)", 0xf8000000, 0xfc00f800, 0, 0, I1}, -{"clci", "+x,+o(+w)", 0xd8000000, 0xfc00f800, 0, 0, I1}, -/* mask should be 0xfc000007. Because I don't have letters for the - * other register and offset argument, temporarily mask them. - * Hence mask of 0xfc0007ff. - */ -{"clbu", "v,d(+w)", 0xc8000000, 0xfc0007ff, 0, 0, I1}, -{"clhu", "v,d(+w)", 0xc8000001, 0xfc0007ff, 0, 0, I1}, -{"clwu", "v,d(+w)", 0xc8000002, 0xfc0007ff, 0, 0, I1}, +{"cgetperm", "t,+b", 0x48000000, 0xffe007ff, 0, 0, I1}, +{"cgettype", "t,+b", 0x48000001, 0xffe007ff, 0, 0, I1}, +{"cgetbase", "t,+b", 0x48000002, 0xffe007ff, 0, 0, I1}, +{"cgetlen", "t,+b", 0x48000003, 0xffe007ff, 0, 0, I1}, +{"cgetcause", "t", 0x48000004, 0xffe0ffff, 0, 0, I1}, +{"cgettag", "t,+b", 0x48000005, 0xffe007ff, 0, 0, I1}, +{"cgetunsealed", "t,+b", 0x48000006, 0xffe007ff, 0, 0, I1}, +{"cgetpcc", "t(+b)", 0x48000007, 0xffe007ff, 0, 0, I1}, +{"candperm", "+w,+b,m", 0x48800000, 0xffe0003f, 0, 0, I1}, +{"csettype", "+w,+b,m", 0x48800001, 0xffe0003f, 0, 0, I1}, +{"cincbase", "+w,+b,m", 0x48800002, 0xffe0003f, 0, 0, I1}, +{"cmove", "+w,+b", 0x48800002, 0xffe007ff, 0, 0, I1}, +{"csetlen", "+w,+b,m", 0x48800003, 0xffe0003f, 0, 0, I1}, +{"ccleartag", "+w", 0x48800005, 0xffe0ffff, 0, 0, I1}, +{"csc", "+x,d,+o(+w)", 0xf8000000, 0xfc000000, 0, 0, I1}, +{"clc", "+x,d,+o(+w)", 0xd8000000, 0xfc000000, 0, 0, I1}, +{"cscr", "+x,d(+w)", 0xf8000000, 0xfc0007ff, 0, 0, I1}, +{"clcr", "+x,d(+w)", 0xd8000000, 0xfc0007ff, 0, 0, I1}, +{"csci", "+x,+o(+w)", 0xf8000000, 0xfc00f800, 0, 0, I1}, +{"clci", "+x,+o(+w)", 0xd8000000, 0xfc00f800, 0, 0, I1}, +{"clbu", "v,d,+O(+w)", 0xc8000000, 0xfc000007, 0, 0, I1}, +{"clhu", "v,d,+O(+w)", 0xc8000001, 0xfc000007, 0, 0, I1}, +{"clwu", "v,d,+O(+w)", 0xc8000002, 0xfc000007, 0, 0, I1}, /* there is no cldu */ -{"clb", "v,d(+w)", 0xc8000004, 0xfc0007ff, 0, 0, I1}, -{"clh", "v,d(+w)", 0xc8000005, 0xfc0007ff, 0, 0, I1}, -{"clw", "v,d(+w)", 0xc8000006, 0xfc0007ff, 0, 0, I1}, -{"cld", "v,d(+w)", 0xc8000007, 0xfc0007ff, 0, 0, I1}, +{"clb", "v,d,+O(+w)", 0xc8000004, 0xfc000007, 0, 0, I1}, +{"clh", "v,d,+O(+w)", 0xc8000005, 0xfc000007, 0, 0, I1}, +{"clw", "v,d,+O(+w)", 0xc8000006, 0xfc000007, 0, 0, I1}, +{"cld", "v,d,+O(+w)", 0xc8000007, 0xfc000007, 0, 0, I1}, +{"clbur", "v,d(+w)", 0xc8000000, 0xfc0007ff, 0, 0, I1}, +{"clhur", "v,d(+w)", 0xc8000001, 0xfc0007ff, 0, 0, I1}, +{"clwur", "v,d(+w)", 0xc8000002, 0xfc0007ff, 0, 0, I1}, +/* there is no cldur */ +{"clbr", "v,d(+w)", 0xc8000004, 0xfc0007ff, 0, 0, I1}, +{"clhr", "v,d(+w)", 0xc8000005, 0xfc0007ff, 0, 0, I1}, +{"clwr", "v,d(+w)", 0xc8000006, 0xfc0007ff, 0, 0, I1}, +{"cldr", "v,d(+w)", 0xc8000007, 0xfc0007ff, 0, 0, I1}, +{"clbui", "v,+O(+w)", 0xc8000000, 0xfc00f807, 0, 0, I1}, +{"clhui", "v,+O(+w)", 0xc8000001, 0xfc00f807, 0, 0, I1}, +{"clwui", "v,+O(+w)", 0xc8000002, 0xfc00f807, 0, 0, I1}, +/* there is no cldui */ +{"clbi", "v,+O(+w)", 0xc8000004, 0xfc00f807, 0, 0, I1}, +{"clhi", "v,+O(+w)", 0xc8000005, 0xfc00f807, 0, 0, I1}, +{"clwi", "v,+O(+w)", 0xc8000006, 0xfc00f807, 0, 0, I1}, +{"cldi", "v,+O(+w)", 0xc8000007, 0xfc00f807, 0, 0, I1}, + +{"csbh", "v,d,+O(+w)", 0xe8000000, 0xfc000007, 0, 0, I1}, +{"cshh", "v,d,+O(+w)", 0xe8000001, 0xfc000007, 0, 0, I1}, +{"cswh", "v,d,+O(+w)", 0xe8000002, 0xfc000007, 0, 0, I1}, +/* there is no csdh */ +{"csb", "v,d,+O(+w)", 0xe8000004, 0xfc000007, 0, 0, I1}, +{"csh", "v,d,+O(+w)", 0xe8000005, 0xfc000007, 0, 0, I1}, +{"csw", "v,d,+O(+w)", 0xe8000006, 0xfc000007, 0, 0, I1}, +{"csd", "v,d,+O(+w)", 0xe8000007, 0xfc000007, 0, 0, I1}, + +{"csbhr", "v,d(+w)", 0xe8000000, 0xfc0007ff, 0, 0, I1}, +{"cshhr", "v,d(+w)", 0xe8000001, 0xfc0007ff, 0, 0, I1}, +{"cswhr", "v,d(+w)", 0xe8000002, 0xfc0007ff, 0, 0, I1}, +/* there is no csdhr */ +{"csbr", "v,d(+w)", 0xe8000004, 0xfc0007ff, 0, 0, I1}, +{"cshr", "v,d(+w)", 0xe8000005, 0xfc0007ff, 0, 0, I1}, +{"cswr", "v,d(+w)", 0xe8000006, 0xfc0007ff, 0, 0, I1}, +{"csdr", "v,d(+w)", 0xe8000007, 0xfc0007ff, 0, 0, I1}, -{"csbh", "v,d(+w)", 0xe8000000, 0xfc0007ff, 0, 0, I1}, -{"cshh", "v,d(+w)", 0xe8000001, 0xfc0007ff, 0, 0, I1}, -{"cswh", "v,d(+w)", 0xe8000002, 0xfc0007ff, 0, 0, I1}, -/* there is no csdu */ -{"csb", "v,d(+w)", 0xe8000004, 0xfc0007ff, 0, 0, I1}, -{"csh", "v,d(+w)", 0xe8000005, 0xfc0007ff, 0, 0, I1}, -{"csw", "v,d(+w)", 0xe8000006, 0xfc0007ff, 0, 0, I1}, -{"csd", "v,d(+w)", 0xe8000007, 0xfc0007ff, 0, 0, I1}, +{"csbhi", "v,+O(+w)", 0xe8000000, 0xfc00f807, 0, 0, I1}, +{"cshhi", "v,+O(+w)", 0xe8000001, 0xfc00f807, 0, 0, I1}, +{"cswhi", "v,+O(+w)", 0xe8000002, 0xfc00f807, 0, 0, I1}, +/* there is no csdhi */ +{"csbi", "v,+O(+w)", 0xe8000004, 0xfc00f807, 0, 0, I1}, +{"cshi", "v,+O(+w)", 0xe8000005, 0xfc00f807, 0, 0, I1}, +{"cswi", "v,+O(+w)", 0xe8000006, 0xfc00f807, 0, 0, I1}, +{"csdi", "v,+O(+w)", 0xe8000007, 0xfc00f807, 0, 0, I1}, -{"clbi", "t,+o(+b)", 0x4a000000, 0xffe00000,0, 0, I1 }, -{"clhi", "t,+o(+b)", 0x4a200000, 0xffe00000, 0, 0, I1 }, -{"clwi", "t,+o(+b)", 0x4a400000, 0xffe00000, 0, 0, I1 }, -{"cldi", "t,+o(+b)", 0x4a600000, 0xffe00000, 0, 0, I1 }, -{"clbr", "t,m(+b)", 0x4a800000, 0xffe0003f, 0, 0, I1 }, -{"clhr", "t,m(+b)", 0x4aa00000, 0xffe0003f, 0, 0, I1 }, -{"clwr", "t,m(+b)", 0x4ac00000, 0xffe0003f, 0, 0, I1 }, -{"cldr", "t,m(+b)", 0x4ae00000, 0xffe0003f, 0, 0, I1 }, -{"csbi", "t,+o(+b)", 0x4b000000, 0xffe00000, 0, 0, I1 }, -{"cshi", "t,+o(+b)", 0x4b200000, 0xffe00000, 0, 0, I1 }, -{"cswi", "t,+o(+b)", 0x4b400000, 0xffe00000, 0, 0, I1 }, -{"csdi", "t,+o(+b)", 0x4b600000, 0xffe00000, 0, 0, I1 }, -{"csbr", "t,m(+b)", 0x4b800000, 0xffe0003f, 0, 0, I1 }, -{"cshr", "t,m(+b)", 0x4ba00000, 0xffe0003f, 0, 0, I1 }, -{"cswr", "t,m(+b)", 0x4bc00000, 0xffe0003f, 0, 0, I1 }, -{"csdr", "t,m(+b)", 0x4be00000, 0xffe0003f, 0, 0, I1 }, -{"cjr", "m(+b)", 0x49000000, 0xffff003f, 0, 0, I1 }, -{"cjalr", "m(+b)", 0x48e00000, 0xffff003f, 0, 0, I1 }, -{"csealcode","+w,+b", 0x48200000, 0xffe007ff, 0, 0, I1 }, -{"csealdata","+w,+b,+v",0x48400000, 0xffe0003f, 0, 0, I1 }, -{"cunseal", "+w,+b,+v", 0x48600000, 0xffe0003f, 0, 0, I1 }, -{"ccall", "+w,+b", 0x48a00000, 0xffe007ff, 0, 0, I1 }, -{"creturn", "", 0x48c00000, 0xffffffff, 0, 0, I1 }, +{"cjr", "m(+b)", 0x49000000, 0xffff003f, 0, 0, I1}, +{"cjalr", "m(+b)", 0x48e00000, 0xffff003f, 0, 0, I1}, +{"csealcode", "+w,+b", 0x48200000, 0xffe007ff, 0, 0, I1}, +{"csealdata", "+w,+b,+v", 0x48400000, 0xffe0003f, 0, 0, I1}, +{"cunseal", "+w,+b,+v", 0x48600000, 0xffe0003f, 0, 0, I1}, +{"ccall", "+w,+b", 0x48a00000, 0xffe007ff, 0, 0, I1}, +{"creturn", "", 0x48c00000, 0xffffffff, 0, 0, I1}, {"b", "p", 0x10000000, 0xffff0000, UBD, INSN2_ALIAS, I1 },/* beq 0,0 */ {"b", "p", 0x04010000, 0xffff0000, UBD, INSN2_ALIAS, I1 },/* bgez 0 */ {"bal", "p", 0x04110000, 0xffff0000, UBD|WR_31, INSN2_ALIAS, I1 },/* bgezal 0*/ From owner-p4-projects@FreeBSD.ORG Wed Dec 5 21:27:06 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0502F24E; Wed, 5 Dec 2012 21:27:06 +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 9FD1E24C for ; Wed, 5 Dec 2012 21:27:05 +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 8083F8FC08 for ; Wed, 5 Dec 2012 21:27:05 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB5LR5Ww086084 for ; Wed, 5 Dec 2012 21:27:05 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB5LR5nh086081 for perforce@freebsd.org; Wed, 5 Dec 2012 21:27:05 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 5 Dec 2012 21:27:05 GMT Message-Id: <201212052127.qB5LR5nh086081@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 219888 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: Wed, 05 Dec 2012 21:27:06 -0000 http://p4web.freebsd.org/@@219888?ac=10 Change 219888 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2012/12/05 21:26:57 Update CHERI assembly code for storing and loading data via capabilities, following an assembler update. Immediates are now supported. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#15 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#15 (text+ko) ==== @@ -167,64 +167,62 @@ * XXXRW: immediates not yet supported by the assembler. */ #define CHERI_CSB(rs, rt, offset, cb) do { \ - __asm__ __volatile__ ("csb %0, %1($c%2)" : : \ - "r" (rs), "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("csb %0, %1, %2($c%3)" : : \ + "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CSH(rs, rt, offset, cb) do { \ - __asm__ __volatile__ ("csh %0, %1($c%2)" : : \ - "r" (rs), "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("csh %0, %1, %2($c%3)" : : \ + "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CSW(rs, rt, offset, cb) do { \ - __asm__ __volatile__ ("csw %0, %1($c%2)" : : \ - "r" (rs), "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("csw %0, %1, %2($c%3)" : : \ + "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CSD(rs, rt, offset, cb) do { \ - __asm__ __volatile__ ("csd %0, %1($c%2)" : : \ - "r" (rs), "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("csd %0, %1, %2($c%3)" : : \ + "r" (rs), "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) /* * Data loads: while these don't much with c0, they do require memory * clobbers. - * - * XXXRW: immediates not yet supported by the assembler. */ #define CHERI_CLB(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clb %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clb %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset),"i" (cb) : "memory"); \ } while (0) #define CHERI_CLH(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clh %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clh %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CLW(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clw %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clw %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CLD(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("cld %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("cld %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CLBU(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clbu %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clbu %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CLHU(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clhu %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clhu %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) #define CHERI_CLWU(rd, rt, offset, cb) do { \ - __asm__ __volatile__ ("clwu %0, %1($c%2)" : \ - "=r" (rd) : "r" (rt), "i" (cb) : "memory"); \ + __asm__ __volatile__ ("clwu %0, %1, %2($c%3)" : \ + "=r" (rd) : "r" (rt), "i" (offset), "i" (cb) : "memory"); \ } while (0) /* From owner-p4-projects@FreeBSD.ORG Wed Dec 5 21:33:12 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7F3D639A; Wed, 5 Dec 2012 21:33: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 3A2B1398 for ; Wed, 5 Dec 2012 21:33:12 +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 1E9AB8FC13 for ; Wed, 5 Dec 2012 21:33:12 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB5LXBlm086243 for ; Wed, 5 Dec 2012 21:33:11 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB5LXBSK086240 for perforce@freebsd.org; Wed, 5 Dec 2012 21:33:11 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 5 Dec 2012 21:33:11 GMT Message-Id: <201212052133.qB5LXBSK086240@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 219889 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: Wed, 05 Dec 2012 21:33:12 -0000 http://p4web.freebsd.org/@@219889?ac=10 Change 219889 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2012/12/05 21:33:03 Remove a comment about immediates and the CHERI version of gas; no longer the case. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#16 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/sys/mips/include/cheri.h#16 (text+ko) ==== @@ -163,8 +163,6 @@ /* * Data stores; while these don't muck with c0, they do require memory * clobbers. - * - * XXXRW: immediates not yet supported by the assembler. */ #define CHERI_CSB(rs, rt, offset, cb) do { \ __asm__ __volatile__ ("csb %0, %1, %2($c%3)" : : \ From owner-p4-projects@FreeBSD.ORG Thu Dec 6 21:05:42 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9D213D64; Thu, 6 Dec 2012 21:05:42 +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 5179CD62 for ; Thu, 6 Dec 2012 21:05:42 +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 35CB18FC08 for ; Thu, 6 Dec 2012 21:05:42 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB6L5gML059074 for ; Thu, 6 Dec 2012 21:05:42 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB6L5f6r059071 for perforce@freebsd.org; Thu, 6 Dec 2012 21:05:41 GMT (envelope-from brooks@freebsd.org) Date: Thu, 6 Dec 2012 21:05:41 GMT Message-Id: <201212062105.qB6L5f6r059071@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219891 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: Thu, 06 Dec 2012 21:05:42 -0000 http://p4web.freebsd.org/@@219891?ac=10 Change 219891 by brooks@brooks_zenith on 2012/12/06 21:04:43 Make all file matches case insensitive for more reliable FAT support. Extend the edges of full height normal slides. Make the radio button style controls look slighly more like radio buttons by using (*) instead of [*]. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#18 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#18 (text+ko) ==== @@ -74,7 +74,7 @@ uint32_t header_height; uint32_t *busyarea, *hourglass; enum sbtype sb = SB_CHERI; -enum mtl_display_mode res = MTL_DM_720x480; +enum mtl_display_mode res = MTL_DM_800x480; static int zombies_waiting = 0; int *slidep; @@ -184,10 +184,10 @@ * The screen looks like: * * Sandbox Resolution - * [*] None [ ] 800x480 - * [ ] Capsicum [*] 720x480 - * [ ] CHERI [ ] 640x480 (Left) - * [ ] 640x480 (Centered) + * (*) None ( ) 800x480 + * ( ) Capsicum (*) 720x480 + * ( ) CHERI ( ) 640x480 (Left) + * ( ) 640x480 (Centered) * [ ] Visible * */ @@ -258,7 +258,7 @@ textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); - sprintf(text, "[%c] None", sb == SB_NONE ? '*' : ' '); + sprintf(text, "(%c) None", sb == SB_NONE ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -266,7 +266,7 @@ textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); - sprintf(text, "[%c] Capsicum", sb == SB_CAPSICUM ? '*' : ' '); + sprintf(text, "(%c) Capsicum", sb == SB_CAPSICUM ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -274,7 +274,7 @@ textbuf, f_width * CD_SB_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_SB_COLS, f_height); - sprintf(text, "[%c] CHERI", sb == SB_CHERI ? '*' : ' '); + sprintf(text, "(%c) CHERI", sb == SB_CHERI ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_SB_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -297,7 +297,7 @@ textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); - sprintf(text, "[%c] 800x480", res == MTL_DM_800x480 ? '*' : ' '); + sprintf(text, "(%c) 800x480", res == MTL_DM_800x480 ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -305,7 +305,7 @@ textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); - sprintf(text, "[%c] 720x480", res == MTL_DM_720x480 ? '*' : ' '); + sprintf(text, "(%c) 720x480", res == MTL_DM_720x480 ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -313,7 +313,7 @@ textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); - sprintf(text, "[%c] 640x480 (Left)", res == MTL_DM_640x480 ? '*' : ' '); + sprintf(text, "(%c) 640x480 (Left)", res == MTL_DM_640x480 ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); fb_composite(dbuf, d_width, d_height, @@ -321,7 +321,7 @@ textbuf, f_width * CD_RES_COLS, f_height); fb_fill_buf(textbuf, white, f_width * CD_RES_COLS, f_height); - sprintf(text, "[%c] 640x480 (Centered)", + sprintf(text, "(%c) 640x480 (Centered)", res == MTL_DM_640x480_CENTER ? '*' : ' '); fb_render_text(text, 2, black, white, textbuf, f_width * CD_RES_COLS, f_height); @@ -471,7 +471,7 @@ fb_fill_region(is->buffer[r * is->width], 0, r, fcol, 1); } - if (is->width < (uint)fb_width) { + if (is->width < (uint)fb_width - fcol) { /* Right extend the image if needed */ for (r = 0; r < is->height; r++) fb_fill_region(is->buffer[((r + 1) * is->width) - 1], @@ -564,14 +564,33 @@ default: break; } - iboxstate_free(is); - /* Skip the rest in the full height image case */ + /* + * If the image is full height, then left and right extend the + * edges and skip further compositing + */ if (y == 0) { + if (x > 0) { + /* Left extend the image if needed */ + for (r = 0; r < is->height; r++) + fb_fill_region(is->buffer[r * is->width], + 0, r, x, 1); + } + if (x + is->width < (uint)fb_width) { + /* Right extend the image if needed */ + for (r = 0; r < is->height; r++) + fb_fill_region(is->buffer[((r + 1) * + is->width) - 1], + x + is->width, r, + fb_width - (x + is->width), 1); + } + iboxstate_free(is); unbusy(); return (0); } + iboxstate_free(is); + busy(0); /* put an SRI logo in the lower left corner */ @@ -890,10 +909,10 @@ if (entry->d_type != DT_REG) continue; /* Skip obvious non-PNGs */ - if (fnmatch("*.[pP][nN][gG]", entry->d_name, 0) != 0) + if (fnmatch("*.png", entry->d_name, FNM_CASEFOLD) != 0) continue; - if (fnmatch("*-cover-*.png", entry->d_name, 0) == 0) + if (fnmatch("*-cover-*.png", entry->d_name, FNM_CASEFOLD) == 0) addslide(&ncovers, &maxcovers, &covers, entry->d_name); else addslide(&nslides, &maxslides, &slides, entry->d_name); @@ -906,10 +925,15 @@ slide = *slidep; for (;;) { gesture = 0; + /* If there isn't a cover, skip over it */ + if (slide == 0 && ncovers == 0) + slide = 1; + if (slide == 0) { asprintf(&coverpat, "*-cover-%d.png", slide_width); for (cover = 0; cover < ncovers; cover++) - if (fnmatch(coverpat, covers[cover], 0) == 0) + if (fnmatch(coverpat, covers[cover], + FNM_CASEFOLD) == 0) break; free(coverpat); if (cover == ncovers) @@ -981,7 +1005,7 @@ set_display_mode(res); break; case TSG_EAST: - if (slide == 0) + if (slide == 0 || (slide == 1 && ncovers == 0)) slide = nslides; else slide--; From owner-p4-projects@FreeBSD.ORG Thu Dec 6 21:22:00 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D167E477; Thu, 6 Dec 2012 21:21:59 +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 8E314475 for ; Thu, 6 Dec 2012 21:21:59 +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 5972F8FC15 for ; Thu, 6 Dec 2012 21:21:59 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB6LLxj6060245 for ; Thu, 6 Dec 2012 21:21:59 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB6LLx96060242 for perforce@freebsd.org; Thu, 6 Dec 2012 21:21:59 GMT (envelope-from brooks@freebsd.org) Date: Thu, 6 Dec 2012 21:21:59 GMT Message-Id: <201212062121.qB6LLx96060242@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219892 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: Thu, 06 Dec 2012 21:22:00 -0000 http://p4web.freebsd.org/@@219892?ac=10 Change 219892 by brooks@brooks_zenith on 2012/12/06 21:21:35 In practice, all the functionality of render_cover() has been subsumed by render_slide()'s non-composite rendering of full height slides. Remove it accordingly. Fix incorrect sandbox indicators for full height slides. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#19 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#19 (text+ko) ==== @@ -440,54 +440,6 @@ } static int -render_cover(int dfd, const char *cover) -{ - int pfd; - uint32_t r, fcol; - struct iboxstate *is; - - busy(1); - - if ((pfd = openat(dfd, cover, O_RDONLY)) == -1) { - warn("Failed to open %s", cover); - return (-1); - } - if ((is = png_read_start(pfd, slide_width, fb_height, sb)) == - NULL) { - warn("Failed to start PNG decode for %s", cover); - return (-1); - } - if (png_read_finish(is) != 0) { - warnx("png_read_finish() failed for %s", cover); - return (-1); - } - fcol = slide_fcol + ((slide_width - is->width) / 2); - fb_fill_region(white, 0, 0, fb_width, fb_height); - fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), fcol, 0, - is->width, is->height); - if (fcol > 0) { - /* Left extend the image if needed */ - for (r = 0; r < is->height; r++) - fb_fill_region(is->buffer[r * is->width], - 0, r, fcol, 1); - } - if (is->width < (uint)fb_width - fcol) { - /* Right extend the image if needed */ - for (r = 0; r < is->height; r++) - fb_fill_region(is->buffer[((r + 1) * is->width) - 1], - fcol + is->width, r, - fb_width - (fcol + is->width), 1); - } - if (sb_vis && sb != SB_NONE) - fb_rectangle(red, 2, fcol, 0, is->width, is->height); - iboxstate_free(is); - - unbusy(); - - return (0); -} - -static int render_slide(int dfd, int slidenum, const char *slide) { int error, pfd; @@ -546,9 +498,9 @@ fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), x, y, w, h); if (sb_vis && sb != SB_NONE) fb_rectangle(red, 2, - slide_fcol + ((slide_width - is->width) / 2), - header_height, is->width, - is->height < slide_height ? is->height : slide_height); + x, y, is->width, + is->height < (u_int)fb_height - y ? + (u_int)fb_height - y : is->height); switch (sb) { case SB_CAPSICUM: if (is->error == 99) @@ -938,7 +890,7 @@ free(coverpat); if (cover == ncovers) cover = 0; /* Smallest cover due to sort */ - render_cover(dirfd(dirp), covers[cover]); + render_slide(dirfd(dirp), 1, covers[cover]); *slidep = slide; /* Update post success */ } else { error = render_slide(dirfd(dirp), From owner-p4-projects@FreeBSD.ORG Thu Dec 6 22:57:39 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EF701FC4; Thu, 6 Dec 2012 22:57:38 +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 A759EFC2 for ; Thu, 6 Dec 2012 22:57:38 +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 8531C8FC08 for ; Thu, 6 Dec 2012 22:57:38 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB6MvcF6064496 for ; Thu, 6 Dec 2012 22:57:38 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB6MvctJ064493 for perforce@freebsd.org; Thu, 6 Dec 2012 22:57:38 GMT (envelope-from brooks@freebsd.org) Date: Thu, 6 Dec 2012 22:57:38 GMT Message-Id: <201212062257.qB6MvctJ064493@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219893 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: Thu, 06 Dec 2012 22:57:39 -0000 http://p4web.freebsd.org/@@219893?ac=10 Change 219893 by brooks@brooks_zenith on 2012/12/06 22:56:43 Resolve a race in starting the shell with sending the first character by starting the shell during the general startup code instead of when the terminal is first used. This should make the race impractical to trigger by accident if not outright impossible. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#9 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#9 (text+ko) ==== @@ -54,6 +54,8 @@ #include #include +static void start_keyboard_shell(void); + static pid_t browser_pid; static pid_t kbd_pid; @@ -72,9 +74,10 @@ else { if (pid == browser_pid) browser_pid = 0; - else if (pid == kbd_pid) + else if (pid == kbd_pid) { kbd_pid = 0; - else + kbdfd = -1; + } else warnx("unexpected pid from wait4(): %d", pid); } } @@ -167,6 +170,8 @@ read_png_file("/usr/share/images/keyboardS.png", keyboard_imgs[1], keyboard_width, keyboard_height); read_png_file("/usr/share/images/keyboardN.png", keyboard_imgs[2], keyboard_width, keyboard_height); read_png_file("/usr/share/images/keyboardC.png", keyboard_imgs[3], keyboard_width, keyboard_height); + + start_keyboard_shell(); } static void @@ -184,6 +189,31 @@ } } +static void +start_keyboard_shell(void) +{ + int pmaster, pslave; + + if (openpty(&pmaster, &pslave, NULL, NULL, NULL) == -1) + err(1, "openpty"); + kbd_pid = fork(); + if (kbd_pid < 0) + err(1, "fork()"); + else if (kbd_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()"); + } +} + void keyboard_on(void) { @@ -198,8 +228,7 @@ const int poll_timeout = touch_timeout; int wait_poll_timeout = poll_timeout; - static int pmaster; - int pslave, n; + int n; char *devpath, buf[1024]; ssize_t rlen; struct pollfd pfd[1]; @@ -232,26 +261,8 @@ keymap[1][1][3] = '\xff'; keymap[2][1][3] = '\xff'; - if (kbdfd < 0) { - if (openpty(&pmaster, &pslave, NULL, NULL, NULL) == -1) - err(1, "openpty"); - kbd_pid = fork(); - if (kbd_pid < 0) - err(1, "fork()"); - else if (kbd_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()"); - } - } + if (kbdfd < 0) + start_keyboard_shell(); fb_fade2off(); fb_fade2text(127); @@ -339,7 +350,7 @@ wait_poll_timeout = poll_timeout; /* Check for output from the child and post it if needed */ - pfd[0].fd = pmaster; + pfd[0].fd = kbdfd; pfd[0].events = POLLIN; n = poll(pfd, 1, 0); if (n == 0) From owner-p4-projects@FreeBSD.ORG Fri Dec 7 22:41:22 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AD98B5DB; Fri, 7 Dec 2012 22:41:22 +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 6A92C5D9 for ; Fri, 7 Dec 2012 22:41:22 +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 363B98FC13 for ; Fri, 7 Dec 2012 22:41:22 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qB7MfMVS019808 for ; Fri, 7 Dec 2012 22:41:22 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qB7MfLHi019805 for perforce@freebsd.org; Fri, 7 Dec 2012 22:41:21 GMT (envelope-from brooks@freebsd.org) Date: Fri, 7 Dec 2012 22:41:21 GMT Message-Id: <201212072241.qB7MfLHi019805@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219896 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: Fri, 07 Dec 2012 22:41:22 -0000 http://p4web.freebsd.org/@@219896?ac=10 Change 219896 by brooks@brooks_zenith on 2012/12/07 22:40:49 Remove a bogus link against libvuln_magic. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/mtlctl/Makefile#2 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/mtlctl/Makefile#2 (text+ko) ==== @@ -9,6 +9,6 @@ WARNS= 6 -LDADD+= -lde4tc -lvuln_png -lz -lm -lvuln_magic +LDADD+= -lde4tc -lvuln_png -lz -lm .include