From owner-svn-src-user@FreeBSD.ORG Mon Mar 2 14:58:05 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9F3504C1; Mon, 2 Mar 2015 14:58:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B27D1F4; Mon, 2 Mar 2015 14:58:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t22Ew5m3003505; Mon, 2 Mar 2015 14:58:05 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t22Ew5iX003504; Mon, 2 Mar 2015 14:58:05 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503021458.t22Ew5iX003504@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Mon, 2 Mar 2015 14:58:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279521 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2015 14:58:05 -0000 Author: pho Date: Mon Mar 2 14:58:04 2015 New Revision: 279521 URL: https://svnweb.freebsd.org/changeset/base/279521 Log: Added a regression test. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/core4.sh (contents, props changed) Added: user/pho/stress2/misc/core4.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/core4.sh Mon Mar 2 14:58:04 2015 (r279521) @@ -0,0 +1,97 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Test multiple (parallel) core dumps and umount -f + +# "panic: vn_finished_write: neg cnt" seen. +# http://people.freebsd.org/~pho/core4.sh +# Fixed in r274501 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +mntpoint=/mnt +mdstart=5 +part=a +newfs_flags="-U" +testuser=stress +[ -r ../default.cfg ] && . ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > core4.c +mycc -o core4 -Wall -Wextra -O0 -g core4.c || exit 1 +rm -f core4.c + +mount | grep -q "$mntpoint" && umount $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 2g -u $mdstart +bsdlabel -w md${mdstart} auto + +newfs $newfs_flags md${mdstart}$part > /dev/null +for i in `jot 20`; do + mount /dev/md${mdstart}$part $mntpoint + chmod 777 $mntpoint + su $testuser -c "(cd $mntpoint; /tmp/core4)" & + su $testuser -c "(cd $mntpoint; /tmp/core4)" & + su $testuser -c "(cd $mntpoint; /tmp/core4)" & + sleep .5 + sleep .`jot -r 1 1 9` + umount -f $mntpoint + wait +done 2>/dev/null + +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart +rm -f /tmp/core4 +exit 0 +EOF +#include +#include + +#include +#include +#include + +#define SIZ (1024L * 1024 * 1024) + +int +main(void) +{ + void *p; + + p = mmap(NULL, SIZ, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + usleep(1000); + raise(SIGSEGV); + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Mon Mar 2 14:59:22 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3162D5B6; Mon, 2 Mar 2015 14:59:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1CB86202; Mon, 2 Mar 2015 14:59:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t22ExLgU003690; Mon, 2 Mar 2015 14:59:21 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t22ExL8Y003689; Mon, 2 Mar 2015 14:59:21 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503021459.t22ExL8Y003689@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Mon, 2 Mar 2015 14:59:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279522 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2015 14:59:22 -0000 Author: pho Date: Mon Mar 2 14:59:21 2015 New Revision: 279522 URL: https://svnweb.freebsd.org/changeset/base/279522 Log: Added a fts(3) test scenario. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/fts2.sh (contents, props changed) Added: user/pho/stress2/misc/fts2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/fts2.sh Mon Mar 2 14:59:21 2015 (r279522) @@ -0,0 +1,289 @@ +#!/bin/sh + +# +# Copyright (c) 2015 EMC Corp. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Show invalid fts_info value: + +# FAULT +# -rw------- 1 root wheel - 4 13 jan 09:25 ./lockf.0.3676 +# fts_path: ./lockf.0.3676 +# fts_info: 13 FTS_SLNONE +# fts_errno: 0 No error: 0 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +cat > /tmp/fts2.c < +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 1 +#define PARALLEL 7 + +pid_t pid; +time_t start; +int fd; +char file[128]; + +char *txt[] = { + "NULL", + "FTS_D", + "FTS_DC", + "FTS_DEFAULT", + "FTS_DNR", + "FTS_DOT", + "FTS_DP", + "FTS_ERR", + "FTS_F", + "FTS_INIT", + "FTS_NS", + "FTS_NSOK", + "FTS_SL", + "FTS_SLNONE", + "FTS_W", + "15", + "16", + "17", +}; + + +int +get(void) { + int sem; + if (lockf(fd, F_LOCK, 0) == -1) + err(1, "lockf(%s, F_LOCK)", file); + if (read(fd, &sem, sizeof(sem)) != sizeof(sem)) + err(1, "get: read(%d)", fd); + if (lseek(fd, 0, SEEK_SET) == -1) + err(1, "lseek"); + if (lockf(fd, F_ULOCK, 0) == -1) + err(1, "lockf(%s, F_ULOCK)", file); + return (sem); +} + +void +incr(void) { + int sem; + if (lockf(fd, F_LOCK, 0) == -1) + err(1, "lockf(%s, F_LOCK)", file); + if (read(fd, &sem, sizeof(sem)) != sizeof(sem)) + err(1, "incr: read(%d)", fd); + if (lseek(fd, 0, SEEK_SET) == -1) + err(1, "lseek"); + sem++; + if (write(fd, &sem, sizeof(sem)) != sizeof(sem)) + err(1, "incr: read"); + if (lseek(fd, 0, SEEK_SET) == -1) + err(1, "lseek"); + if (lockf(fd, F_ULOCK, 0) == -1) + err(1, "lockf(%s, F_ULOCK)", file); +} + + +void +tlockf(void) +{ + int i; + int sem = 0; + + usleep(arc4random() % 10000); + sprintf(file, "lockf.0.%d", getpid()); + if ((fd = open(file,O_CREAT | O_TRUNC | O_RDWR, 0600)) == -1) + err(1, "creat(%s)", file); + if (write(fd, &sem, sizeof(sem)) != sizeof(sem)) + err(1, "write"); + if (lseek(fd, 0, SEEK_SET) == -1) + err(1, "lseek"); + + pid = fork(); + if (pid == -1) { + perror("fork"); + exit(2); + } + + if (pid == 0) { /* child */ + for (i = 0; i < 100; i++) { + while ((get() & 1) == 0) + ; + incr(); + } + exit(0); + } else { /* parent */ + for (i = 0; i < 100; i++) { + while ((get() & 1) == 1) + ; + incr(); + } + } + close(fd); + waitpid(pid, &i, 0); + unlink(file); +} + +void +tmkdir(void) +{ + pid_t pid; + int i, j; + char name[80]; + + setproctitle(__func__); + usleep(arc4random() % 10000); + pid = getpid(); + for (j = 0; j < LOOPS; j++) { + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); + if (mkdir(name, 0644) == -1) + err(1, "mkfifo(%s)", name); + } + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); + if (rmdir(name) == -1) + err(1, "unlink(%s)", name); + } + } +} + +void +tfts(void) +{ + FTS *fts; + FTSENT *p; + int ftsoptions, i; + char *args[2]; + char help[80]; + + usleep(arc4random() % 10000); + ftsoptions = FTS_LOGICAL; + args[0] = "."; + args[1] = 0; + + for (i = 0; i < 10; i++) { + if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) + err(1, "fts_open"); + + while ((p = fts_read(fts)) != NULL) { + if (p->fts_info == FTS_D || /* preorder directory */ + p->fts_info == FTS_DNR || /* unreadable directory */ + p->fts_info == FTS_DOT || /* dot or dot-dot */ + p->fts_info == FTS_DP || /* postorder directory */ + p->fts_info == FTS_F || /* regular file */ + p->fts_info == FTS_NS) /* stat(2) failed */ + continue; + fprintf(stderr, "FAULT\n"); + sprintf(help, "ls -lo %s", p->fts_path); + system(help); + fprintf(stderr, "fts_path: %s\n", p->fts_path); + fprintf(stderr, "fts_info: %d %s\n", p->fts_info, + txt[p->fts_info]); + fprintf(stderr, "fts_errno: %d %s\n", p->fts_errno, + strerror(p->fts_errno)); + } + + if (errno != 0 && errno != ENOENT) + err(1, "fts_read"); + if (fts_close(fts) == -1) + err(1, "fts_close()"); + } +} + +void +test(void) +{ + + start = time(NULL); + if (fork() == 0) { + while (time(NULL) - start < 60) + tmkdir(); + _exit(0); + } + if (fork() == 0) { + while (time(NULL) - start < 60) + tlockf(); + _exit(0); + } + if (fork() == 0) { + while (time(NULL) - start < 60) + tfts(); + _exit(0); + } + + wait(NULL); + wait(NULL); + wait(NULL); + + _exit(0); +} + +int +main(void) +{ + int i; + + for (i = 0; i < PARALLEL; i++) + if (fork() == 0) + test(); + for (i = 0; i < PARALLEL; i++) + wait(NULL); + + return (0); +} +EOF +mycc -o /tmp/fts2 -Wall -Wextra -O0 -g /tmp/fts2.c || exit 1 + +mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 1g -u $mdstart || exit 1 +bsdlabel -w md$mdstart auto +newfs md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +(cd $mntpoint; /tmp/fts2) + +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart +rm /tmp/fts2 /tmp/fts2.c From owner-svn-src-user@FreeBSD.ORG Mon Mar 2 15:03:09 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2C876859; Mon, 2 Mar 2015 15:03:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17C3530B; Mon, 2 Mar 2015 15:03:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t22F38dV007861; Mon, 2 Mar 2015 15:03:08 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t22F38SZ007860; Mon, 2 Mar 2015 15:03:08 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503021503.t22F38SZ007860@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Mon, 2 Mar 2015 15:03:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279523 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2015 15:03:09 -0000 Author: pho Date: Mon Mar 2 15:03:08 2015 New Revision: 279523 URL: https://svnweb.freebsd.org/changeset/base/279523 Log: One more fts(3) test. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/fifo3.sh (contents, props changed) Added: user/pho/stress2/misc/fifo3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/fifo3.sh Mon Mar 2 15:03:08 2015 (r279523) @@ -0,0 +1,211 @@ +#!/bin/sh + +# +# Copyright (c) 2014 EMC Corp. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Demonstrate that fts_read(3) will open a fifo for read. +# Not seen on a pristine FreeBSD. + +# $ while ./fifo.sh; do date; done +# Wed Oct 1 14:07:41 CEST 2014 +# Wed Oct 1 14:09:58 CEST 2014 +# FAIL +# $ ps -l19547 +# UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND +# 0 19547 19544 0 25 0 12176 3996 fifoor I 0 0:08.19 /tmp/fifo +# $ gdb /tmp/fifo 19547 +# GNU gdb 6.1.1 [FreeBSD] +# Copyright 2004 Free Software Foundation, Inc. +# GDB is free software, covered by the GNU General Public License, and you are +# welcome to change it and/or distribute copies of it under certain conditions. +# Type "show copying" to see the conditions. +# There is absolutely no warranty for GDB. Type "show warranty" for details. +# This GDB was configured as "amd64-marcel-freebsd"... +# Attaching to program: /tmp/fifo, process 19547 +# Reading symbols from /lib/libc.so.7...done. +# Loaded symbols for /lib/libc.so.7 +# Reading symbols from /libexec/ld-elf.so.1...done. +# Loaded symbols for /libexec/ld-elf.so.1 +# 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 +# (gdb) bt +# #0 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 +# #1 0x00000008008a581b in fts_read () from /lib/libc.so.7 +# #2 0x00000008008a4f24 in fts_read () from /lib/libc.so.7 +# #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 +# #4 0x0000000000400fd8 in main () at /tmp/fifo.c:108 +# (gdb) f 3 +# #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 +# 86 while ((p = fts_read(fts)) != NULL) { +# Current language: auto; currently minimal +# (gdb) +# + +. ../default.cfg + +cat > /tmp/fifo3.c < +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define LOOPS 50 +#define PARALLEL 4 + +void +tmkfifo(void) +{ + pid_t pid; + int i, j; + char name[80]; + + setproctitle(__func__); + pid = getpid(); + for (j = 0; j < LOOPS; j++) { + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); + if (mkfifo(name, 0644) == -1) + err(1, "mkfifo(%s)", name); + } + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); + if (unlink(name) == -1) + err(1, "unlink(%s)", name); + } + } + _exit(0); +} + +void +tmkdir(void) +{ + pid_t pid; + int i, j; + char name[80]; + + setproctitle(__func__); + pid = getpid(); + for (j = 0; j < LOOPS; j++) { + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); + if (mkdir(name, 0644) == -1) + err(1, "mkfifo(%s)", name); + } + for (i = 0; i < 1000; i++) { + snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); + if (rmdir(name) == -1) + err(1, "unlink(%s)", name); + } + } + _exit(0); +} + + +void +test(void) +{ + FTS *fts; + FTSENT *p; + int ftsoptions, i; + char *args[2]; + + if (fork() == 0) + tmkfifo(); + if (fork() == 0) + tmkdir(); + + ftsoptions = 0; + args[0] = "."; + args[1] = 0; + + for (i = 0; i < LOOPS; i++) { + if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) + err(1, "fts_open"); + + while ((p = fts_read(fts)) != NULL) { +#if defined(TEST) + fprintf(stdout, "%s\n", p->fts_path); +#endif + } + + if (errno != 0 && errno != ENOENT) + err(1, "fts_read"); + if (fts_close(fts) == -1) + err(1, "fts_close()"); + } + wait(NULL); + wait(NULL); + + _exit(0); +} + +int +main(void) +{ + int i; + + for (i = 0; i < PARALLEL; i++) + if (fork() == 0) + test(); + for (i = 0; i < PARALLEL; i++) + wait(NULL); + + return (0); +} +EOF +mycc -o /tmp/fifo3 -Wall -Wextra -O0 -g /tmp/fifo3.c || exit 1 + +mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint +[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart + +mdconfig -a -t swap -s 1g -u $mdstart || exit 1 +bsdlabel -w md$mdstart auto +newfs md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint + +(cd $mntpoint; /tmp/fifo3 ) & + +while pgrep -q fifo3; do + ps -l | grep -v grep | grep -q fifoor && + { echo FAIL; exit 1; } + sleep 2 +done + +wait + +while mount | grep $mntpoint | grep -q /dev/md; do + umount $mntpoint || sleep 1 +done +mdconfig -d -u $mdstart +rm /tmp/fifo3 /tmp/fifo3.c From owner-svn-src-user@FreeBSD.ORG Mon Mar 2 20:14:57 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 88691BA5; Mon, 2 Mar 2015 20:14:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 736A0ED6; Mon, 2 Mar 2015 20:14:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t22KEvPr068830; Mon, 2 Mar 2015 20:14:57 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t22KEvac068829; Mon, 2 Mar 2015 20:14:57 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201503022014.t22KEvac068829@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Mon, 2 Mar 2015 20:14:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279541 - user/dchagin/lemul/sys/fs/pseudofs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2015 20:14:57 -0000 Author: dchagin Date: Mon Mar 2 20:14:56 2015 New Revision: 279541 URL: https://svnweb.freebsd.org/changeset/base/279541 Log: Avoid using of an uninitialized variable. Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Modified: user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Mon Mar 2 20:13:49 2015 (r279540) +++ user/dchagin/lemul/sys/fs/pseudofs/pseudofs_vnops.c Mon Mar 2 20:14:56 2015 (r279541) @@ -904,12 +904,13 @@ pfs_readdir(struct vop_readdir_args *va) /* PFS_DELEN was picked to fit PFS_NAMLEN */ if (pn->pn_type != pfstype_procdir && - pn->pn_type != pfstype_fdlink) + pn->pn_type != pfstype_fdlink) { for (i = 0; i < PFS_NAMELEN - 1 && pn->pn_name[i] != '\0'; ++i) pfsent->entry.d_name[i] = pn->pn_name[i]; - pfsent->entry.d_name[i] = 0; - pfsent->entry.d_namlen = i; + pfsent->entry.d_name[i] = 0; + pfsent->entry.d_namlen = i; + } switch (pn->pn_type) { case pfstype_procdir: KASSERT(p != NULL, From owner-svn-src-user@FreeBSD.ORG Wed Mar 4 02:44:22 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2B0BC937; Wed, 4 Mar 2015 02:44:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16B8918E; Wed, 4 Mar 2015 02:44:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t242iLxE057699; Wed, 4 Mar 2015 02:44:21 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t242iL3h057698; Wed, 4 Mar 2015 02:44:21 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201503040244.t242iL3h057698@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Wed, 4 Mar 2015 02:44:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279574 - user/marcel/libvdsk/libvdsk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 02:44:22 -0000 Author: marcel Date: Wed Mar 4 02:44:21 2015 New Revision: 279574 URL: https://svnweb.freebsd.org/changeset/base/279574 Log: s/align/aligned/ Modified: user/marcel/libvdsk/libvdsk/vdsk_int.h Modified: user/marcel/libvdsk/libvdsk/vdsk_int.h ============================================================================== --- user/marcel/libvdsk/libvdsk/vdsk_int.h Wed Mar 4 02:17:36 2015 (r279573) +++ user/marcel/libvdsk/libvdsk/vdsk_int.h Wed Mar 4 02:44:21 2015 (r279574) @@ -67,6 +67,6 @@ struct vdsk { struct stat fsbuf; off_t capacity; int sectorsize; -} __attribute__((align(16))); +} __attribute__((aligned(16))); #endif /* __VDSK_INT_H__ */ From owner-svn-src-user@FreeBSD.ORG Wed Mar 4 02:47:16 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75529A28; Wed, 4 Mar 2015 02:47:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FF2E19E; Wed, 4 Mar 2015 02:47:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t242lG4d058109; Wed, 4 Mar 2015 02:47:16 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t242lE4F058098; Wed, 4 Mar 2015 02:47:14 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201503040247.t242lE4F058098@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Wed, 4 Mar 2015 02:47:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279575 - user/marcel/libvdsk/bhyve X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 02:47:16 -0000 Author: marcel Date: Wed Mar 4 02:47:13 2015 New Revision: 279575 URL: https://svnweb.freebsd.org/changeset/base/279575 Log: Sync with ^/head Modified: user/marcel/libvdsk/bhyve/bhyve.8 user/marcel/libvdsk/bhyve/bhyverun.c user/marcel/libvdsk/bhyve/bhyverun.h user/marcel/libvdsk/bhyve/inout.c user/marcel/libvdsk/bhyve/pci_ahci.c user/marcel/libvdsk/bhyve/rtc.c user/marcel/libvdsk/bhyve/rtc.h user/marcel/libvdsk/bhyve/task_switch.c user/marcel/libvdsk/bhyve/xmsr.c Directory Properties: user/marcel/libvdsk/bhyve/ (props changed) user/marcel/libvdsk/bhyveload/ (props changed) Modified: user/marcel/libvdsk/bhyve/bhyve.8 ============================================================================== --- user/marcel/libvdsk/bhyve/bhyve.8 Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/bhyve.8 Wed Mar 4 02:47:13 2015 (r279575) @@ -32,7 +32,7 @@ .Nd "run a guest operating system inside a virtual machine" .Sh SYNOPSIS .Nm -.Op Fl abehwxACHPWY +.Op Fl abehuwxACHPWY .Op Fl c Ar numcpus .Op Fl g Ar gdbport .Op Fl l Ar lpcdev Ns Op , Ns Ar conf @@ -239,6 +239,8 @@ The host device must have been reserved loader variable as described in .Xr vmm 4 . .El +.It Fl u +RTC keeps UTC time. .It Fl U Ar uuid Set the universally unique identifier .Pq UUID Modified: user/marcel/libvdsk/bhyve/bhyverun.c ============================================================================== --- user/marcel/libvdsk/bhyve/bhyverun.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/bhyverun.c Wed Mar 4 02:47:13 2015 (r279575) @@ -122,7 +122,7 @@ usage(int code) { fprintf(stderr, - "Usage: %s [-abehwxACHPWY] [-c vcpus] [-g ] [-l ]\n" + "Usage: %s [-abehuwxACHPWY] [-c vcpus] [-g ] [-l ]\n" " %*s [-m mem] [-p vcpu:hostcpu] [-s ] [-U uuid] \n" " -a: local apic is in xAPIC mode (deprecated)\n" " -A: create ACPI tables\n" @@ -137,6 +137,7 @@ usage(int code) " -p: pin 'vcpu' to 'hostcpu'\n" " -P: vmexit from the guest on pause\n" " -s: PCI slot config\n" + " -u: RTC keeps UTC time\n" " -U: uuid\n" " -w: ignore unimplemented MSRs\n" " -W: force virtio to use single-vector MSI\n" @@ -185,20 +186,14 @@ vm_inject_fault(void *arg, int vcpu, int int errcode) { struct vmctx *ctx; - int error; + int error, restart_instruction; ctx = arg; - if (errcode_valid) - error = vm_inject_exception2(ctx, vcpu, vector, errcode); - else - error = vm_inject_exception(ctx, vcpu, vector); - assert(error == 0); + restart_instruction = 1; - /* - * Set the instruction length to 0 to ensure that the instruction is - * restarted when the fault handler returns. - */ - vmexit[vcpu].inst_length = 0; + error = vm_inject_exception(ctx, vcpu, vector, errcode_valid, errcode, + restart_instruction); + assert(error == 0); } void * @@ -329,12 +324,6 @@ vmexit_inout(struct vmctx *ctx, struct v } error = emulate_inout(ctx, vcpu, vme, strictio); - if (!error && in && !string) { - error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, - vme->u.inout.eax); - assert(error == 0); - } - if (error) { fprintf(stderr, "Unhandled %s%c 0x%04x\n", in ? "in" : "out", bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), port); @@ -358,7 +347,7 @@ vmexit_rdmsr(struct vmctx *ctx, struct v vme->u.msr.code, *pvcpu); if (strictmsr) { vm_inject_gp(ctx, *pvcpu); - return (VMEXIT_RESTART); + return (VMEXIT_CONTINUE); } } @@ -384,7 +373,7 @@ vmexit_wrmsr(struct vmctx *ctx, struct v vme->u.msr.code, vme->u.msr.wval, *pvcpu); if (strictmsr) { vm_inject_gp(ctx, *pvcpu); - return (VMEXIT_RESTART); + return (VMEXIT_CONTINUE); } } return (VMEXIT_CONTINUE); @@ -462,9 +451,11 @@ static int vmexit_bogus(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) { + assert(vmexit->inst_length == 0); + stats.vmexit_bogus++; - return (VMEXIT_RESTART); + return (VMEXIT_CONTINUE); } static int @@ -494,9 +485,11 @@ static int vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) { + assert(vmexit->inst_length == 0); + stats.vmexit_mtrap++; - return (VMEXIT_RESTART); + return (VMEXIT_CONTINUE); } static int @@ -581,7 +574,7 @@ static vmexit_handler_t handler[VM_EXITC }; static void -vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) +vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip) { int error, rc, prevcpu; enum vm_exitcode exitcode; @@ -596,8 +589,11 @@ vm_loop(struct vmctx *ctx, int vcpu, uin error = vm_active_cpus(ctx, &active_cpus); assert(CPU_ISSET(vcpu, &active_cpus)); + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, startrip); + assert(error == 0); + while (1) { - error = vm_run(ctx, vcpu, rip, &vmexit[vcpu]); + error = vm_run(ctx, vcpu, &vmexit[vcpu]); if (error != 0) break; @@ -614,10 +610,6 @@ vm_loop(struct vmctx *ctx, int vcpu, uin switch (rc) { case VMEXIT_CONTINUE: - rip = vmexit[vcpu].rip + vmexit[vcpu].inst_length; - break; - case VMEXIT_RESTART: - rip = vmexit[vcpu].rip; break; case VMEXIT_ABORT: abort(); @@ -694,6 +686,7 @@ main(int argc, char *argv[]) { int c, error, gdb_port, err, bvmcons; int dump_guest_memory, max_vcpus, mptgen; + int rtc_localtime; struct vmctx *ctx; uint64_t rip; size_t memsize; @@ -705,8 +698,9 @@ main(int argc, char *argv[]) guest_ncpus = 1; memsize = 256 * MB; mptgen = 1; + rtc_localtime = 1; - while ((c = getopt(argc, argv, "abehwxACHIPWYp:g:c:s:m:l:U:")) != -1) { + while ((c = getopt(argc, argv, "abehuwxACHIPWYp:g:c:s:m:l:U:")) != -1) { switch (c) { case 'a': x2apic_mode = 0; @@ -766,6 +760,9 @@ main(int argc, char *argv[]) case 'e': strictio = 1; break; + case 'u': + rtc_localtime = 0; + break; case 'U': guest_uuid_str = optarg; break; @@ -829,7 +826,7 @@ main(int argc, char *argv[]) pci_irq_init(ctx); ioapic_init(ctx); - rtc_init(ctx); + rtc_init(ctx, rtc_localtime); sci_init(ctx); /* Modified: user/marcel/libvdsk/bhyve/bhyverun.h ============================================================================== --- user/marcel/libvdsk/bhyve/bhyverun.h Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/bhyverun.h Wed Mar 4 02:47:13 2015 (r279575) @@ -35,9 +35,8 @@ #define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] #endif -#define VMEXIT_CONTINUE 1 /* continue from next instruction */ -#define VMEXIT_RESTART 2 /* restart current instruction */ -#define VMEXIT_ABORT 3 /* abort the vm run loop */ +#define VMEXIT_CONTINUE (0) +#define VMEXIT_ABORT (-1) struct vmctx; extern int guest_ncpus; Modified: user/marcel/libvdsk/bhyve/inout.c ============================================================================== --- user/marcel/libvdsk/bhyve/inout.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/inout.c Wed Mar 4 02:47:13 2015 (r279575) @@ -104,7 +104,7 @@ int emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict) { int addrsize, bytes, flags, in, port, prot, rep; - uint32_t val; + uint32_t eax, val; inout_func_t handler; void *arg; int error, retval; @@ -214,16 +214,20 @@ emulate_inout(struct vmctx *ctx, int vcp } /* Restart the instruction if more iterations remain */ - if (retval == 0 && count != 0) - vmexit->inst_length = 0; - } else { - if (!in) { - val = vmexit->u.inout.eax & vie_size2mask(bytes); + if (retval == 0 && count != 0) { + error = vm_restart_instruction(ctx, vcpu); + assert(error == 0); } + } else { + eax = vmexit->u.inout.eax; + val = eax & vie_size2mask(bytes); retval = handler(ctx, vcpu, in, port, bytes, &val, arg); if (retval == 0 && in) { - vmexit->u.inout.eax &= ~vie_size2mask(bytes); - vmexit->u.inout.eax |= val & vie_size2mask(bytes); + eax &= ~vie_size2mask(bytes); + eax |= val & vie_size2mask(bytes); + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, + eax); + assert(error == 0); } } return (retval); Modified: user/marcel/libvdsk/bhyve/pci_ahci.c ============================================================================== --- user/marcel/libvdsk/bhyve/pci_ahci.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/pci_ahci.c Wed Mar 4 02:47:13 2015 (r279575) @@ -1968,7 +1968,8 @@ pci_ahci_init(struct vmctx *ctx, struct open_fail: if (ret) { - blockif_close(sc->port[0].bctx); + if (sc->port[0].bctx != NULL) + blockif_close(sc->port[0].bctx); free(sc); } Modified: user/marcel/libvdsk/bhyve/rtc.c ============================================================================== --- user/marcel/libvdsk/bhyve/rtc.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/rtc.c Wed Mar 4 02:47:13 2015 (r279575) @@ -30,10 +30,7 @@ __FBSDID("$FreeBSD$"); #include -#include -#include -#include #include #include @@ -41,47 +38,11 @@ __FBSDID("$FreeBSD$"); #include #include "acpi.h" -#include "inout.h" #include "pci_lpc.h" #include "rtc.h" -#define IO_RTC 0x70 +#define IO_RTC 0x70 -#define RTC_SEC 0x00 /* seconds */ -#define RTC_SEC_ALARM 0x01 -#define RTC_MIN 0x02 -#define RTC_MIN_ALARM 0x03 -#define RTC_HRS 0x04 -#define RTC_HRS_ALARM 0x05 -#define RTC_WDAY 0x06 -#define RTC_DAY 0x07 -#define RTC_MONTH 0x08 -#define RTC_YEAR 0x09 -#define RTC_CENTURY 0x32 /* current century */ - -#define RTC_STATUSA 0xA -#define RTCSA_TUP 0x80 /* time update, don't look now */ - -#define RTC_STATUSB 0xB -#define RTCSB_DST 0x01 -#define RTCSB_24HR 0x02 -#define RTCSB_BIN 0x04 /* 0 = BCD, 1 = Binary */ -#define RTCSB_PINTR 0x40 /* 1 = enable periodic clock interrupt */ -#define RTCSB_HALT 0x80 /* stop clock updates */ - -#define RTC_INTR 0x0c /* status register C (R) interrupt source */ - -#define RTC_STATUSD 0x0d /* status register D (R) Lost Power */ -#define RTCSD_PWR 0x80 /* clock power OK */ - -#define RTC_NVRAM_START 0x0e -#define RTC_NVRAM_END 0x7f -#define RTC_NVRAM_SZ (128 - RTC_NVRAM_START) -#define nvoff(x) ((x) - RTC_NVRAM_START) - -#define RTC_DIAG 0x0e -#define RTC_RSTCODE 0x0f -#define RTC_EQUIPMENT 0x14 #define RTC_LMEM_LSB 0x34 #define RTC_LMEM_MSB 0x35 #define RTC_HMEM_LSB 0x5b @@ -92,249 +53,30 @@ __FBSDID("$FreeBSD$"); #define m_16MB (16*1024*1024) #define m_4GB (4ULL*1024*1024*1024) -static int addr; - -static uint8_t rtc_nvram[RTC_NVRAM_SZ]; - -/* XXX initialize these to default values as they would be from BIOS */ -static uint8_t status_a, status_b; - -static struct { - uint8_t hours; - uint8_t mins; - uint8_t secs; -} rtc_alarm; - -static u_char const bin2bcd_data[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 -}; -#define bin2bcd(bin) (bin2bcd_data[bin]) - -#define rtcout(val) ((status_b & RTCSB_BIN) ? (val) : bin2bcd((val))) - -static void -timevalfix(struct timeval *t1) -{ - - if (t1->tv_usec < 0) { - t1->tv_sec--; - t1->tv_usec += 1000000; - } - if (t1->tv_usec >= 1000000) { - t1->tv_sec++; - t1->tv_usec -= 1000000; - } -} - -static void -timevalsub(struct timeval *t1, const struct timeval *t2) -{ - - t1->tv_sec -= t2->tv_sec; - t1->tv_usec -= t2->tv_usec; - timevalfix(t1); -} - -static int -rtc_addr_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, - uint32_t *eax, void *arg) -{ - if (bytes != 1) - return (-1); - - if (in) { - /* straight read of this register will return 0xFF */ - *eax = 0xff; - return (0); - } - - switch (*eax & 0x7f) { - case RTC_SEC: - case RTC_SEC_ALARM: - case RTC_MIN: - case RTC_MIN_ALARM: - case RTC_HRS: - case RTC_HRS_ALARM: - case RTC_WDAY: - case RTC_DAY: - case RTC_MONTH: - case RTC_YEAR: - case RTC_STATUSA: - case RTC_STATUSB: - case RTC_INTR: - case RTC_STATUSD: - case RTC_NVRAM_START ... RTC_NVRAM_END: - break; - default: - return (-1); - } - - addr = *eax & 0x7f; - return (0); -} - -static int -rtc_data_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, - uint32_t *eax, void *arg) +/* + * Returns the current RTC time as number of seconds since 00:00:00 Jan 1, 1970 + */ +static time_t +rtc_time(struct vmctx *ctx, int use_localtime) { - int hour; + struct tm tm; time_t t; - struct timeval cur, delta; - - static struct timeval last; - static struct tm tm; - if (bytes != 1) - return (-1); - - gettimeofday(&cur, NULL); - - /* - * Increment the cached time only once per second so we can guarantee - * that the guest has at least one second to read the hour:min:sec - * separately and still get a coherent view of the time. - */ - delta = cur; - timevalsub(&delta, &last); - if (delta.tv_sec >= 1 && (status_b & RTCSB_HALT) == 0) { - t = cur.tv_sec; + time(&t); + if (use_localtime) { localtime_r(&t, &tm); - last = cur; - } - - if (in) { - switch (addr) { - case RTC_SEC_ALARM: - *eax = rtc_alarm.secs; - break; - case RTC_MIN_ALARM: - *eax = rtc_alarm.mins; - break; - case RTC_HRS_ALARM: - *eax = rtc_alarm.hours; - break; - case RTC_SEC: - *eax = rtcout(tm.tm_sec); - return (0); - case RTC_MIN: - *eax = rtcout(tm.tm_min); - return (0); - case RTC_HRS: - if (status_b & RTCSB_24HR) - hour = tm.tm_hour; - else - hour = (tm.tm_hour % 12) + 1; - - *eax = rtcout(hour); - - /* - * If we are representing time in the 12-hour format - * then set the MSB to indicate PM. - */ - if ((status_b & RTCSB_24HR) == 0 && tm.tm_hour >= 12) - *eax |= 0x80; - - return (0); - case RTC_WDAY: - *eax = rtcout(tm.tm_wday + 1); - return (0); - case RTC_DAY: - *eax = rtcout(tm.tm_mday); - return (0); - case RTC_MONTH: - *eax = rtcout(tm.tm_mon + 1); - return (0); - case RTC_YEAR: - *eax = rtcout(tm.tm_year % 100); - return (0); - case RTC_STATUSA: - *eax = status_a; - return (0); - case RTC_STATUSB: - *eax = status_b; - return (0); - case RTC_INTR: - *eax = 0; - return (0); - case RTC_STATUSD: - *eax = RTCSD_PWR; - return (0); - case RTC_NVRAM_START ... RTC_NVRAM_END: - *eax = rtc_nvram[addr - RTC_NVRAM_START]; - return (0); - default: - return (-1); - } + t = timegm(&tm); } - - switch (addr) { - case RTC_STATUSA: - status_a = *eax & ~RTCSA_TUP; - break; - case RTC_STATUSB: - /* XXX not implemented yet XXX */ - if (*eax & RTCSB_PINTR) - return (-1); - status_b = *eax; - break; - case RTC_STATUSD: - /* ignore write */ - break; - case RTC_SEC_ALARM: - rtc_alarm.secs = *eax; - break; - case RTC_MIN_ALARM: - rtc_alarm.mins = *eax; - break; - case RTC_HRS_ALARM: - rtc_alarm.hours = *eax; - break; - case RTC_SEC: - case RTC_MIN: - case RTC_HRS: - case RTC_WDAY: - case RTC_DAY: - case RTC_MONTH: - case RTC_YEAR: - /* - * Ignore writes to the time of day registers - */ - break; - case RTC_NVRAM_START ... RTC_NVRAM_END: - rtc_nvram[addr - RTC_NVRAM_START] = *eax; - break; - default: - return (-1); - } - return (0); + return (t); } void -rtc_init(struct vmctx *ctx) +rtc_init(struct vmctx *ctx, int use_localtime) { - struct timeval cur; - struct tm tm; size_t himem; size_t lomem; int err; - err = gettimeofday(&cur, NULL); - assert(err == 0); - (void) localtime_r(&cur.tv_sec, &tm); - - memset(rtc_nvram, 0, sizeof(rtc_nvram)); - - rtc_nvram[nvoff(RTC_CENTURY)] = bin2bcd((tm.tm_year + 1900) / 100); - /* XXX init diag/reset code/equipment/checksum ? */ /* @@ -344,17 +86,22 @@ rtc_init(struct vmctx *ctx) * 0x5b/0x5c/0x5d - 64KB chunks above 4GB */ lomem = (vm_get_lowmem_size(ctx) - m_16MB) / m_64KB; - rtc_nvram[nvoff(RTC_LMEM_LSB)] = lomem; - rtc_nvram[nvoff(RTC_LMEM_MSB)] = lomem >> 8; + err = vm_rtc_write(ctx, RTC_LMEM_LSB, lomem); + assert(err == 0); + err = vm_rtc_write(ctx, RTC_LMEM_MSB, lomem >> 8); + assert(err == 0); himem = vm_get_highmem_size(ctx) / m_64KB; - rtc_nvram[nvoff(RTC_HMEM_LSB)] = himem; - rtc_nvram[nvoff(RTC_HMEM_SB)] = himem >> 8; - rtc_nvram[nvoff(RTC_HMEM_MSB)] = himem >> 16; -} + err = vm_rtc_write(ctx, RTC_HMEM_LSB, himem); + assert(err == 0); + err = vm_rtc_write(ctx, RTC_HMEM_SB, himem >> 8); + assert(err == 0); + err = vm_rtc_write(ctx, RTC_HMEM_MSB, himem >> 16); + assert(err == 0); -INOUT_PORT(rtc, IO_RTC, IOPORT_F_INOUT, rtc_addr_handler); -INOUT_PORT(rtc, IO_RTC + 1, IOPORT_F_INOUT, rtc_data_handler); + err = vm_rtc_settime(ctx, rtc_time(ctx, use_localtime)); + assert(err == 0); +} static void rtc_dsdt(void) Modified: user/marcel/libvdsk/bhyve/rtc.h ============================================================================== --- user/marcel/libvdsk/bhyve/rtc.h Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/rtc.h Wed Mar 4 02:47:13 2015 (r279575) @@ -29,6 +29,6 @@ #ifndef _RTC_H_ #define _RTC_H_ -void rtc_init(struct vmctx *ctx); +void rtc_init(struct vmctx *ctx, int use_localtime); #endif /* _RTC_H_ */ Modified: user/marcel/libvdsk/bhyve/task_switch.c ============================================================================== --- user/marcel/libvdsk/bhyve/task_switch.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/task_switch.c Wed Mar 4 02:47:13 2015 (r279575) @@ -725,21 +725,11 @@ vmexit_task_switch(struct vmctx *ctx, st assert(paging->cpu_mode == CPU_MODE_PROTECTED); /* - * Calculate the %eip to store in the old TSS before modifying the - * 'inst_length'. + * Calculate the instruction pointer to store in the old TSS. */ eip = vmexit->rip + vmexit->inst_length; /* - * Set the 'inst_length' to '0'. - * - * If an exception is triggered during emulation of the task switch - * then the exception handler should return to the instruction that - * caused the task switch as opposed to the subsequent instruction. - */ - vmexit->inst_length = 0; - - /* * Section 4.6, "Access Rights" in Intel SDM Vol 3. * The following page table accesses are implicitly supervisor mode: * - accesses to GDT or LDT to load segment descriptors @@ -883,8 +873,8 @@ vmexit_task_switch(struct vmctx *ctx, st * after this point will be handled in the context of the new task and * the saved instruction pointer will belong to the new task. */ - vmexit->rip = newtss.tss_eip; - assert(vmexit->inst_length == 0); + error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, newtss.tss_eip); + assert(error == 0); /* Load processor state from new TSS */ error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov); Modified: user/marcel/libvdsk/bhyve/xmsr.c ============================================================================== --- user/marcel/libvdsk/bhyve/xmsr.c Wed Mar 4 02:44:21 2015 (r279574) +++ user/marcel/libvdsk/bhyve/xmsr.c Wed Mar 4 02:47:13 2015 (r279575) @@ -188,6 +188,15 @@ emulate_rdmsr(struct vmctx *ctx, int vcp *val = 0; break; + /* + * OpenBSD guests test bit 0 of this MSR to detect if the + * workaround for erratum 721 is already applied. + * http://support.amd.com/TechDocs/41322_10h_Rev_Gd.pdf + */ + case 0xC0011029: + *val = 1; + break; + default: error = -1; break; From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 08:47:55 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF70C3D6; Thu, 5 Mar 2015 08:47:55 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9C1F71A6; Thu, 5 Mar 2015 08:47:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t258lsxp016921; Thu, 5 Mar 2015 08:47:54 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t258lsG6016920; Thu, 5 Mar 2015 08:47:54 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503050847.t258lsG6016920@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 5 Mar 2015 08:47:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279627 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 08:47:55 -0000 Author: pho Date: Thu Mar 5 08:47:54 2015 New Revision: 279627 URL: https://svnweb.freebsd.org/changeset/base/279627 Log: Do not assume we can write to /dev/tty. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/syscall.sh Modified: user/pho/stress2/misc/syscall.sh ============================================================================== --- user/pho/stress2/misc/syscall.sh Thu Mar 5 07:40:41 2015 (r279626) +++ user/pho/stress2/misc/syscall.sh Thu Mar 5 08:47:54 2015 (r279627) @@ -48,7 +48,8 @@ n=$syscall rm -f /tmp/syscall.log while [ $n -gt 0 ]; do - echo "`date '+%T'` syscall $n" | tee /dev/tty >> /tmp/syscall.log + echo "`date '+%T'` syscall $n" + echo "`date '+%T'` syscall $n" >> /tmp/syscall.log for i in `jot 5`; do su ${testuser} -c "sh -c \"../testcases/syscall/syscall -t 30s -i 100 -h -l 100 -k $n\"" done From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 08:49:39 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8FF044EE; Thu, 5 Mar 2015 08:49:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D5671C7; Thu, 5 Mar 2015 08:49:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t258ndLH017161; Thu, 5 Mar 2015 08:49:39 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t258nds3017160; Thu, 5 Mar 2015 08:49:39 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503050849.t258nds3017160@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 5 Mar 2015 08:49:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279628 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 08:49:39 -0000 Author: pho Date: Thu Mar 5 08:49:38 2015 New Revision: 279628 URL: https://svnweb.freebsd.org/changeset/base/279628 Log: Remove debug code. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/suj33.sh Modified: user/pho/stress2/misc/suj33.sh ============================================================================== --- user/pho/stress2/misc/suj33.sh Thu Mar 5 08:47:54 2015 (r279627) +++ user/pho/stress2/misc/suj33.sh Thu Mar 5 08:49:38 2015 (r279628) @@ -37,7 +37,6 @@ mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart -set -x mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null @@ -55,6 +54,5 @@ wait while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done -set +x checkfs /dev/md${mdstart}$part mdconfig -d -u $mdstart From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 08:51:28 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9F0BD5F6; Thu, 5 Mar 2015 08:51:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80DD3270; Thu, 5 Mar 2015 08:51:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t258pSqk018549; Thu, 5 Mar 2015 08:51:28 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t258pSR3018548; Thu, 5 Mar 2015 08:51:28 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503050851.t258pSR3018548@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 5 Mar 2015 08:51:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279629 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 08:51:28 -0000 Author: pho Date: Thu Mar 5 08:51:27 2015 New Revision: 279629 URL: https://svnweb.freebsd.org/changeset/base/279629 Log: Look for the right mount point. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/pfl2.sh Modified: user/pho/stress2/misc/pfl2.sh ============================================================================== --- user/pho/stress2/misc/pfl2.sh Thu Mar 5 08:49:38 2015 (r279628) +++ user/pho/stress2/misc/pfl2.sh Thu Mar 5 08:51:27 2015 (r279629) @@ -43,7 +43,7 @@ md1=$mdstart md2=$((mdstart + 1)) opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-j" || echo "-U") -mount | grep $mp1 | grep -q /dev/md && umount -f $mp1 +mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 mdconfig -l | grep -q md$md1 && mdconfig -d -u $md1 mdconfig -a -t swap -s 2g -u $md1 bsdlabel -w md$md1 auto @@ -51,7 +51,7 @@ newfs $opt md${md1}$part > /dev/null mount /dev/md${md1}$part $mp1 chmod 777 $mp1 -mount | grep $mp2 | grep -q /dev/md && umount -f $mp2 +mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2 mdconfig -l | grep -q md$md2 && mdconfig -d -u $md2 mdconfig -a -t swap -s 2g -u $md2 bsdlabel -w md$md2 auto From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 08:53:11 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A33AA6E2; Thu, 5 Mar 2015 08:53:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9043F27C; Thu, 5 Mar 2015 08:53:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t258rBGC021103; Thu, 5 Mar 2015 08:53:11 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t258rBOG021102; Thu, 5 Mar 2015 08:53:11 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503050853.t258rBOG021102@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 5 Mar 2015 08:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279630 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 08:53:11 -0000 Author: pho Date: Thu Mar 5 08:53:10 2015 New Revision: 279630 URL: https://svnweb.freebsd.org/changeset/base/279630 Log: Added more findings and clean up code. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/nfs6.sh Modified: user/pho/stress2/misc/nfs6.sh ============================================================================== --- user/pho/stress2/misc/nfs6.sh Thu Mar 5 08:51:27 2015 (r279629) +++ user/pho/stress2/misc/nfs6.sh Thu Mar 5 08:53:10 2015 (r279630) @@ -29,13 +29,17 @@ # # panic: vn_finished_write: neg cnt +# http://people.freebsd.org/~pho/stress/log/kostik500.txt +# http://people.freebsd.org/~pho/stress/log/nfs6.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +grep -q $mntpoint /etc/exports || + { echo "$mntpoint missing from /etc/exports"; exit 0; } D=$diskimage -dede $D 1m 128 || exit +dede $D 1m 128 || exit mount | grep "${mntpoint}2" | grep nfs > /dev/null && umount -f ${mntpoint}2 mount | grep "$mntpoint" | grep /md > /dev/null && umount -f ${mntpoint} From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 09:47:00 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7C0CF73; Thu, 5 Mar 2015 09:47:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B9BCA47; Thu, 5 Mar 2015 09:47:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t259l0Kr046221; Thu, 5 Mar 2015 09:47:00 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t259l0cC046219; Thu, 5 Mar 2015 09:47:00 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201503050947.t259l0cC046219@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 5 Mar 2015 09:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279641 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 09:47:00 -0000 Author: pho Date: Thu Mar 5 09:46:59 2015 New Revision: 279641 URL: https://svnweb.freebsd.org/changeset/base/279641 Log: Added /etc/exports check, fixed trailing white space errors and use $part for partition name. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/nfs2.sh Modified: user/pho/stress2/misc/nfs2.sh ============================================================================== --- user/pho/stress2/misc/nfs2.sh Thu Mar 5 09:41:49 2015 (r279640) +++ user/pho/stress2/misc/nfs2.sh Thu Mar 5 09:46:59 2015 (r279641) @@ -34,10 +34,12 @@ . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +grep -q $mntpoint /etc/exports || + { echo "$mntpoint missing from /etc/exports"; exit 0; } [ -x /sbin/mount_msdosfs ] || exit D=$diskimage -dede $D 1m 128 || exit +dede $D 1m 128 || exit mount | grep "${mntpoint}2" | grep nfs > /dev/null && umount -f ${mntpoint}2 mount | grep "$mntpoint" | grep /md > /dev/null && umount -f ${mntpoint} @@ -46,8 +48,8 @@ mdconfig -l | grep -q ${mdstart} && md mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md${mdstart} auto -newfs_msdos -F 16 -b 8192 /dev/md${mdstart}a > /dev/null -mount -t msdosfs -o rw /dev/md${mdstart}a $mntpoint +newfs_msdos -F 16 -b 8192 /dev/md${mdstart}$part > /dev/null +mount -t msdosfs -o rw /dev/md${mdstart}$part $mntpoint mkdir ${mntpoint}/stressX chmod 777 ${mntpoint}/stressX @@ -55,12 +57,13 @@ chmod 777 ${mntpoint}/stressX [ ! -d ${mntpoint}2 ] && mkdir ${mntpoint}2 chmod 777 ${mntpoint}2 -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:$mntpoint ${mntpoint}2 +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw \ + 127.0.0.1:$mntpoint ${mntpoint}2 export INODES=9999 # No inodes on a msdos fs export RUNDIR=${mntpoint}2/stressX export runRUNTIME=10m # Run tests for 10 minutes -(cd ..; ./run.sh disk.cfg) +(cd ..; ./run.sh disk.cfg) umount -f ${mntpoint}2 > /dev/null 2>&1 umount -f $mntpoint > /dev/null 2>&1 From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 20:45:59 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D7DADD16; Thu, 5 Mar 2015 20:45:58 +0000 (UTC) Received: from mail-wi0-x229.google.com (mail-wi0-x229.google.com [IPv6:2a00:1450:400c:c05::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 768716CF; Thu, 5 Mar 2015 20:45:58 +0000 (UTC) Received: by wivr20 with SMTP id r20so9781128wiv.3; Thu, 05 Mar 2015 12:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=eDegR5nbQHeLG8yBDJgCHFrykCvsYjlMieqvssiBlIE=; b=d+t25Hr7zUsgrunUC9XSrG4pU8tmfJdUVLNZZPa2vFPiRfDO6oJuA8NR/SHTp2YbiJ 7WbL5tkEPnwJq+ntJLyx80IirgNf/Mm+PPue09AvjU8PB+F2ML17HCij+IxSf4UkRmzf DxQJdOsDg7C8tqLQdKGL16nQWQb59bZKNv5y27AuaYptgNLueIJgSCu4zcO9esCGf2c3 gEwqXbTV0qe9U4aHSyM9tMXjlrANibONXxzyRhrQVvIiC+hUNIcKbpkhBdJrOZ0SynDq YS/CzS16Dk/h7/+cObPFUNAGD/m2xp9c6KdtSRYqHNqGvGY3hJHN/crGXUZ6nwcF4Lr5 3TPg== X-Received: by 10.180.149.206 with SMTP id uc14mr69297830wib.57.1425588356845; Thu, 05 Mar 2015 12:45:56 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id u6sm13179930wix.12.2015.03.05.12.45.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Mar 2015 12:45:55 -0800 (PST) Date: Thu, 5 Mar 2015 21:45:52 +0100 From: Mateusz Guzik To: Chagin Dmitry Subject: Re: svn commit: r279335 - in user/dchagin/lemul/sys: compat/linprocfs fs/procfs fs/pseudofs modules/procfs Message-ID: <20150305204552.GC11164@dft-labs.eu> References: <201502262130.t1QLUfwf027872@svn.freebsd.org> <20150226220342.GC3799@dft-labs.eu> <20150227195329.GA7995@dchagin.static.corbina.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150227195329.GA7995@dchagin.static.corbina.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 20:45:59 -0000 On Fri, Feb 27, 2015 at 10:53:29PM +0300, Chagin Dmitry wrote: > On Thu, Feb 26, 2015 at 11:03:42PM +0100, Mateusz Guzik wrote: > > On Thu, Feb 26, 2015 at 09:30:41PM +0000, Dmitry Chagin wrote: > > > +int > > > +procfs_dofdlink(PFS_FILL_ARGS) > > > +{ > > > + char *fullpath, *freepath, *endfileno; > > > + struct filedesc *fdp; > > > + struct vnode *vp; > > > + struct file *fp; > > > + int fileno, error; > > > + > > > + if (vnode_name == NULL) > > > + return (ENOENT); > > > + > > > + fileno = (int)strtol(vnode_name, &endfileno, 10); > > > + if (fileno == 0 && (vnode_namelen > 1 || > > > + (vnode_namelen == 1 && vnode_name[0] != '0'))) > > > + return (ENOENT); > > > + if (vnode_namelen != endfileno - vnode_name) > > > + return (ENOENT); > > > + > > > + fdp = fdhold(p); > > > + if (fdp == NULL) > > > + return (ENOENT); > > > + > > > + error = fget_unlocked(fdp, fileno, NULL, &fp, NULL); > > > + if (error != 0) > > > + goto out; > > > + > > > + freepath = NULL; > > > + fullpath = "-"; > > > + vp = fp->f_vnode; > > > + if (vp != NULL) { > > > + vref(vp); > > > + error = vn_fullpath(td, vp, &fullpath, &freepath); > > > + vrele(vp); > > > + } > > > + if (error == 0) > > > + error = sbuf_printf(sb, "%s", fullpath); > > > + if (freepath != NULL) > > > + free(freepath, M_TEMP); > > > + fdrop(fp, td); > > > + > > > + out: > > > + fddrop(fdp); > > > + return (error); > > > +} > > > > > > > > > fdhold does not protect file descriptor table, it only makes sure struct > > filedesc itself is not freed. > > > > Here you need to lock it and inspect fd_refcnt. See e.g. > > kern_proc_filedesc_out. > > > pfs_readlink does a PHOLD and PRELE around calling fill method, is > this not enought? > This does not prevent execve, so you can dump data for a now-privileged process. > > While this guarantees data consistency, is in fact still incorrect since > > the process you are inspecing can exec setuid in the meantime and thus > > make security checks (if any performed) stale. > > > > I have an old WIP patch which provides appropriate interfaces to ensure > > stability of the process (no exit, no exec), but this needs additional > > changes. HOpefully i'll have the time to deal with it in March. > ok, give me see the patch, pls. http://people.freebsd.org/~mjg/patches/sx-imagelock.patch afair there was a lor which needs to be resolved. something in devfs was taking proctree or allproc lock, which could be avoided. I don't remember the details, maybe i'll work on this this month. Feel free to debug it yourslef. :) -- Mateusz Guzik From owner-svn-src-user@FreeBSD.ORG Thu Mar 5 21:57:14 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DC076C0A; Thu, 5 Mar 2015 21:57:13 +0000 (UTC) Received: from dchagin.static.corbina.net (dchagin.static.corbina.ru [78.107.232.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "dchagin.static.corbina.net", Issuer "dchagin.static.corbina.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 73FBAE12; Thu, 5 Mar 2015 21:57:12 +0000 (UTC) Received: from dchagin.static.corbina.net (localhost [127.0.0.1]) by dchagin.static.corbina.net (8.14.9/8.14.9) with ESMTP id t25Lv9Ku004311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 6 Mar 2015 00:57:10 +0300 (MSK) (envelope-from dchagin@dchagin.static.corbina.net) Received: (from dchagin@localhost) by dchagin.static.corbina.net (8.14.9/8.14.9/Submit) id t25Lv90F004310; Fri, 6 Mar 2015 00:57:09 +0300 (MSK) (envelope-from dchagin) Date: Fri, 6 Mar 2015 00:57:09 +0300 From: Chagin Dmitry To: Mateusz Guzik Subject: Re: svn commit: r279335 - in user/dchagin/lemul/sys: compat/linprocfs fs/procfs fs/pseudofs modules/procfs Message-ID: <20150305215709.GA4287@dchagin.static.corbina.net> References: <201502262130.t1QLUfwf027872@svn.freebsd.org> <20150226220342.GC3799@dft-labs.eu> <20150227195329.GA7995@dchagin.static.corbina.net> <20150305204552.GC11164@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150305204552.GC11164@dft-labs.eu> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 21:57:14 -0000 On Thu, Mar 05, 2015 at 09:45:52PM +0100, Mateusz Guzik wrote: > On Fri, Feb 27, 2015 at 10:53:29PM +0300, Chagin Dmitry wrote: > > On Thu, Feb 26, 2015 at 11:03:42PM +0100, Mateusz Guzik wrote: > > > On Thu, Feb 26, 2015 at 09:30:41PM +0000, Dmitry Chagin wrote: > > > > +int > > > > +procfs_dofdlink(PFS_FILL_ARGS) > > > > +{ > > > > + char *fullpath, *freepath, *endfileno; > > > > + struct filedesc *fdp; > > > > + struct vnode *vp; > > > > + struct file *fp; > > > > + int fileno, error; > > > > + > > > > + if (vnode_name == NULL) > > > > + return (ENOENT); > > > > + > > > > + fileno = (int)strtol(vnode_name, &endfileno, 10); > > > > + if (fileno == 0 && (vnode_namelen > 1 || > > > > + (vnode_namelen == 1 && vnode_name[0] != '0'))) > > > > + return (ENOENT); > > > > + if (vnode_namelen != endfileno - vnode_name) > > > > + return (ENOENT); > > > > + > > > > + fdp = fdhold(p); > > > > + if (fdp == NULL) > > > > + return (ENOENT); > > > > + > > > > + error = fget_unlocked(fdp, fileno, NULL, &fp, NULL); > > > > + if (error != 0) > > > > + goto out; > > > > + > > > > + freepath = NULL; > > > > + fullpath = "-"; > > > > + vp = fp->f_vnode; > > > > + if (vp != NULL) { > > > > + vref(vp); > > > > + error = vn_fullpath(td, vp, &fullpath, &freepath); > > > > + vrele(vp); > > > > + } > > > > + if (error == 0) > > > > + error = sbuf_printf(sb, "%s", fullpath); > > > > + if (freepath != NULL) > > > > + free(freepath, M_TEMP); > > > > + fdrop(fp, td); > > > > + > > > > + out: > > > > + fddrop(fdp); > > > > + return (error); > > > > +} > > > > > > > > > > > > > fdhold does not protect file descriptor table, it only makes sure struct > > > filedesc itself is not freed. > > > > > > Here you need to lock it and inspect fd_refcnt. See e.g. > > > kern_proc_filedesc_out. > > > > > pfs_readlink does a PHOLD and PRELE around calling fill method, is > > this not enought? > > > > This does not prevent execve, so you can dump data for a now-privileged > process. hmm, I think I begin to understand. Thanks > > > > While this guarantees data consistency, is in fact still incorrect since > > > the process you are inspecing can exec setuid in the meantime and thus > > > make security checks (if any performed) stale. > > > > > > I have an old WIP patch which provides appropriate interfaces to ensure > > > stability of the process (no exit, no exec), but this needs additional > > > changes. HOpefully i'll have the time to deal with it in March. > > ok, give me see the patch, pls. > > http://people.freebsd.org/~mjg/patches/sx-imagelock.patch > modifying struct proc this way you break KBI > afair there was a lor which needs to be resolved. something in devfs was > taking proctree or allproc lock, which could be avoided. > > I don't remember the details, maybe i'll work on this this month. > > Feel free to debug it yourslef. :) > > -- > Mateusz Guzik -- Have fun! chd