From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 10 07:23:45 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77378106566B; Sun, 10 Jun 2012 07:23:45 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 604858FC08; Sun, 10 Jun 2012 07:23:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5A7Njww080133; Sun, 10 Jun 2012 07:23:45 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5A7NjaC080129; Sun, 10 Jun 2012 07:23:45 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206100723.q5A7NjaC080129@svn.freebsd.org> From: Martin Matuska Date: Sun, 10 Jun 2012 07:23:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236837 - in stable/9/cddl/contrib/opensolaris: cmd/ztest lib/libzfs/common X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2012 07:23:45 -0000 Author: mm Date: Sun Jun 10 07:23:45 2012 New Revision: 236837 URL: http://svn.freebsd.org/changeset/base/236837 Log: MFC r236143, r236705: MFC r236143 [1]: Import illumos changeset 13571:a5771a96228c 1950 ztest backwards compatibility testing option MFC r236705 [2]: Import Illumos revision 13715:351036203e4b 2803 zfs get guid pretty-prints the output References: https://www.illumos.org/issues/1950 [1] https://www.illumos.org/issues/2803 [2] Obtained from: illumos (issue #1950 [1], #2803 [2]) Modified: stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c Sun Jun 10 07:15:13 2012 (r236836) +++ stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c Sun Jun 10 07:23:45 2012 (r236837) @@ -20,8 +20,9 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2012 Martin Matuska . All rights reserved. */ /* @@ -51,7 +52,9 @@ * At random times, the child self-immolates with a SIGKILL. * This is the software equivalent of pulling the power cord. * The parent then runs the test again, using the existing - * storage pool, as many times as desired. + * storage pool, as many times as desired. If backwards compatability + * testing is enabled ztest will sometimes run the "older" version + * of ztest after a SIGKILL. * * (6) To verify that we don't have future leaks or temporal incursions, * many of the functional tests record the transaction group number @@ -68,9 +71,15 @@ * You can ask more more vdevs [-v], datasets [-d], or threads [-t] * to increase the pool capacity, fanout, and overall stress level. * - * The -N(okill) option will suppress kills, so each child runs to completion. - * This can be useful when you're trying to distinguish temporal incursions - * from plain old race conditions. + * Use the -k option to set the desired frequency of kills. + * + * When ztest invokes itself it passes all relevant information through a + * temporary file which is mmap-ed in the child process. This allows shared + * memory to survive the exec syscall. The ztest_shared_hdr_t struct is always + * stored at offset 0 of this file and contains information on the size and + * number of shared structures in the file. The information stored in this file + * must remain backwards compatible with older versions of ztest so that + * ztest can invoke them during backwards compatibility testing (-B). */ #include @@ -111,29 +120,82 @@ #include #include -static char cmdname[] = "ztest"; -static char *zopt_pool = cmdname; -static char *progname; - -static uint64_t zopt_vdevs = 5; -static uint64_t zopt_vdevtime; -static int zopt_ashift = SPA_MINBLOCKSHIFT; -static int zopt_mirrors = 2; -static int zopt_raidz = 4; -static int zopt_raidz_parity = 1; -static size_t zopt_vdev_size = SPA_MINDEVSIZE; -static int zopt_datasets = 7; -static int zopt_threads = 23; -static uint64_t zopt_passtime = 60; /* 60 seconds */ -static uint64_t zopt_killrate = 70; /* 70% kill rate */ -static int zopt_verbose = 0; -static int zopt_init = 1; -static char *zopt_dir = "/tmp"; -static uint64_t zopt_time = 300; /* 5 minutes */ -static uint64_t zopt_maxloops = 50; /* max loops during spa_freeze() */ +#define ZTEST_FD_DATA 3 +#define ZTEST_FD_RAND 4 + +typedef struct ztest_shared_hdr { + uint64_t zh_hdr_size; + uint64_t zh_opts_size; + uint64_t zh_size; + uint64_t zh_stats_size; + uint64_t zh_stats_count; + uint64_t zh_ds_size; + uint64_t zh_ds_count; +} ztest_shared_hdr_t; + +static ztest_shared_hdr_t *ztest_shared_hdr; + +typedef struct ztest_shared_opts { + char zo_pool[MAXNAMELEN]; + char zo_dir[MAXNAMELEN]; + char zo_alt_ztest[MAXNAMELEN]; + char zo_alt_libpath[MAXNAMELEN]; + uint64_t zo_vdevs; + uint64_t zo_vdevtime; + size_t zo_vdev_size; + int zo_ashift; + int zo_mirrors; + int zo_raidz; + int zo_raidz_parity; + int zo_datasets; + int zo_threads; + uint64_t zo_passtime; + uint64_t zo_killrate; + int zo_verbose; + int zo_init; + uint64_t zo_time; + uint64_t zo_maxloops; + uint64_t zo_metaslab_gang_bang; +} ztest_shared_opts_t; + +static const ztest_shared_opts_t ztest_opts_defaults = { + .zo_pool = { 'z', 't', 'e', 's', 't', '\0' }, + .zo_dir = { '/', 't', 'm', 'p', '\0' }, + .zo_alt_ztest = { '\0' }, + .zo_alt_libpath = { '\0' }, + .zo_vdevs = 5, + .zo_ashift = SPA_MINBLOCKSHIFT, + .zo_mirrors = 2, + .zo_raidz = 4, + .zo_raidz_parity = 1, + .zo_vdev_size = SPA_MINDEVSIZE, + .zo_datasets = 7, + .zo_threads = 23, + .zo_passtime = 60, /* 60 seconds */ + .zo_killrate = 70, /* 70% kill rate */ + .zo_verbose = 0, + .zo_init = 1, + .zo_time = 300, /* 5 minutes */ + .zo_maxloops = 50, /* max loops during spa_freeze() */ + .zo_metaslab_gang_bang = 32 << 10 +}; + +extern uint64_t metaslab_gang_bang; +extern uint64_t metaslab_df_alloc_threshold; + +static ztest_shared_opts_t *ztest_shared_opts; +static ztest_shared_opts_t ztest_opts; + +typedef struct ztest_shared_ds { + uint64_t zd_seq; +} ztest_shared_ds_t; + +static ztest_shared_ds_t *ztest_shared_ds; +#define ZTEST_GET_SHARED_DS(d) (&ztest_shared_ds[d]) #define BT_MAGIC 0x123456789abcdefULL -#define MAXFAULTS() (MAX(zs->zs_mirrors, 1) * (zopt_raidz_parity + 1) - 1) +#define MAXFAULTS() \ + (MAX(zs->zs_mirrors, 1) * (ztest_opts.zo_raidz_parity + 1) - 1) enum ztest_io_type { ZTEST_IO_WRITE_TAG, @@ -205,10 +267,10 @@ typedef struct ztest_od { * Per-dataset state. */ typedef struct ztest_ds { + ztest_shared_ds_t *zd_shared; objset_t *zd_os; rwlock_t zd_zilog_lock; zilog_t *zd_zilog; - uint64_t zd_seq; ztest_od_t *zd_od; /* debugging aid */ char zd_name[MAXNAMELEN]; mutex_t zd_dirobj_lock; @@ -225,11 +287,17 @@ typedef struct ztest_info { ztest_func_t *zi_func; /* test function */ uint64_t zi_iters; /* iterations per execution */ uint64_t *zi_interval; /* execute every seconds */ - uint64_t zi_call_count; /* per-pass count */ - uint64_t zi_call_time; /* per-pass time */ - uint64_t zi_call_next; /* next time to call this function */ } ztest_info_t; +typedef struct ztest_shared_callstate { + uint64_t zc_count; /* per-pass count */ + uint64_t zc_time; /* per-pass time */ + uint64_t zc_next; /* next time to call this function */ +} ztest_shared_callstate_t; + +static ztest_shared_callstate_t *ztest_shared_callstate; +#define ZTEST_GET_SHARED_CALLSTATE(c) (&ztest_shared_callstate[c]) + /* * Note: these aren't static because we want dladdr() to work. */ @@ -297,8 +365,10 @@ ztest_info_t ztest_info[] = { { ztest_dsl_dataset_promote_busy, 1, &zopt_rarely }, { ztest_vdev_attach_detach, 1, &zopt_rarely }, { ztest_vdev_LUN_growth, 1, &zopt_rarely }, - { ztest_vdev_add_remove, 1, &zopt_vdevtime }, - { ztest_vdev_aux_add_remove, 1, &zopt_vdevtime }, + { ztest_vdev_add_remove, 1, + &ztest_opts.zo_vdevtime }, + { ztest_vdev_aux_add_remove, 1, + &ztest_opts.zo_vdevtime }, }; #define ZTEST_FUNCS (sizeof (ztest_info) / sizeof (ztest_info_t)) @@ -316,8 +386,7 @@ typedef struct ztest_cb_list { * Stuff we need to share writably between parent and child. */ typedef struct ztest_shared { - char *zs_pool; - spa_t *zs_spa; + boolean_t zs_do_init; hrtime_t zs_proc_start; hrtime_t zs_proc_stop; hrtime_t zs_thread_start; @@ -328,13 +397,11 @@ typedef struct ztest_shared { uint64_t zs_vdev_aux; uint64_t zs_alloc; uint64_t zs_space; - uint64_t zs_guid; - mutex_t zs_vdev_lock; - rwlock_t zs_name_lock; - ztest_info_t zs_info[ZTEST_FUNCS]; uint64_t zs_splits; uint64_t zs_mirrors; - ztest_ds_t zs_zd[]; + uint64_t zs_metaslab_sz; + uint64_t zs_metaslab_df_alloc_threshold; + uint64_t zs_guid; } ztest_shared_t; #define ID_PARALLEL -1ULL @@ -342,20 +409,19 @@ typedef struct ztest_shared { static char ztest_dev_template[] = "%s/%s.%llua"; static char ztest_aux_template[] = "%s/%s.%s.%llu"; ztest_shared_t *ztest_shared; -uint64_t *ztest_seq; -static int ztest_random_fd; -static int ztest_dump_core = 1; +static spa_t *ztest_spa = NULL; +static ztest_ds_t *ztest_ds; +static mutex_t ztest_vdev_lock; +static rwlock_t ztest_name_lock; + +static boolean_t ztest_dump_core = B_TRUE; static boolean_t ztest_exiting; /* Global commit callback list */ static ztest_cb_list_t zcl; -extern uint64_t metaslab_gang_bang; -extern uint64_t metaslab_df_alloc_threshold; -static uint64_t metaslab_sz; - enum ztest_object { ZTEST_META_DNODE = 0, ZTEST_DIROBJ, @@ -468,12 +534,14 @@ nicenumtoull(const char *buf) static void usage(boolean_t requested) { + const ztest_shared_opts_t *zo = &ztest_opts_defaults; + char nice_vdev_size[10]; char nice_gang_bang[10]; FILE *fp = requested ? stdout : stderr; - nicenum(zopt_vdev_size, nice_vdev_size); - nicenum(metaslab_gang_bang, nice_gang_bang); + nicenum(zo->zo_vdev_size, nice_vdev_size); + nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang); (void) fprintf(fp, "Usage: %s\n" "\t[-v vdevs (default: %llu)]\n" @@ -494,42 +562,43 @@ usage(boolean_t requested) "\t[-T time (default: %llu sec)] total run time\n" "\t[-F freezeloops (default: %llu)] max loops in spa_freeze()\n" "\t[-P passtime (default: %llu sec)] time per pass\n" + "\t[-B alt_ztest (default: )] alternate ztest path\n" "\t[-h] (print help)\n" "", - cmdname, - (u_longlong_t)zopt_vdevs, /* -v */ + zo->zo_pool, + (u_longlong_t)zo->zo_vdevs, /* -v */ nice_vdev_size, /* -s */ - zopt_ashift, /* -a */ - zopt_mirrors, /* -m */ - zopt_raidz, /* -r */ - zopt_raidz_parity, /* -R */ - zopt_datasets, /* -d */ - zopt_threads, /* -t */ + zo->zo_ashift, /* -a */ + zo->zo_mirrors, /* -m */ + zo->zo_raidz, /* -r */ + zo->zo_raidz_parity, /* -R */ + zo->zo_datasets, /* -d */ + zo->zo_threads, /* -t */ nice_gang_bang, /* -g */ - zopt_init, /* -i */ - (u_longlong_t)zopt_killrate, /* -k */ - zopt_pool, /* -p */ - zopt_dir, /* -f */ - (u_longlong_t)zopt_time, /* -T */ - (u_longlong_t)zopt_maxloops, /* -F */ - (u_longlong_t)zopt_passtime); /* -P */ + zo->zo_init, /* -i */ + (u_longlong_t)zo->zo_killrate, /* -k */ + zo->zo_pool, /* -p */ + zo->zo_dir, /* -f */ + (u_longlong_t)zo->zo_time, /* -T */ + (u_longlong_t)zo->zo_maxloops, /* -F */ + (u_longlong_t)zo->zo_passtime); exit(requested ? 0 : 1); } static void process_options(int argc, char **argv) { + char *path; + ztest_shared_opts_t *zo = &ztest_opts; + int opt; uint64_t value; + char altdir[MAXNAMELEN] = { 0 }; - /* Remember program name. */ - progname = argv[0]; - - /* By default, test gang blocks for blocks 32K and greater */ - metaslab_gang_bang = 32 << 10; + bcopy(&ztest_opts_defaults, zo, sizeof (*zo)); while ((opt = getopt(argc, argv, - "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:")) != EOF) { + "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:")) != EOF) { value = 0; switch (opt) { case 'v': @@ -550,58 +619,71 @@ process_options(int argc, char **argv) } switch (opt) { case 'v': - zopt_vdevs = value; + zo->zo_vdevs = value; break; case 's': - zopt_vdev_size = MAX(SPA_MINDEVSIZE, value); + zo->zo_vdev_size = MAX(SPA_MINDEVSIZE, value); break; case 'a': - zopt_ashift = value; + zo->zo_ashift = value; break; case 'm': - zopt_mirrors = value; + zo->zo_mirrors = value; break; case 'r': - zopt_raidz = MAX(1, value); + zo->zo_raidz = MAX(1, value); break; case 'R': - zopt_raidz_parity = MIN(MAX(value, 1), 3); + zo->zo_raidz_parity = MIN(MAX(value, 1), 3); break; case 'd': - zopt_datasets = MAX(1, value); + zo->zo_datasets = MAX(1, value); break; case 't': - zopt_threads = MAX(1, value); + zo->zo_threads = MAX(1, value); break; case 'g': - metaslab_gang_bang = MAX(SPA_MINBLOCKSIZE << 1, value); + zo->zo_metaslab_gang_bang = MAX(SPA_MINBLOCKSIZE << 1, + value); break; case 'i': - zopt_init = value; + zo->zo_init = value; break; case 'k': - zopt_killrate = value; + zo->zo_killrate = value; break; case 'p': - zopt_pool = strdup(optarg); + (void) strlcpy(zo->zo_pool, optarg, + sizeof (zo->zo_pool)); break; case 'f': - zopt_dir = strdup(optarg); + path = realpath(optarg, NULL); + if (path == NULL) { + (void) fprintf(stderr, "error: %s: %s\n", + optarg, strerror(errno)); + usage(B_FALSE); + } else { + (void) strlcpy(zo->zo_dir, path, + sizeof (zo->zo_dir)); + } break; case 'V': - zopt_verbose++; + zo->zo_verbose++; break; case 'E': - zopt_init = 0; + zo->zo_init = 0; break; case 'T': - zopt_time = value; + zo->zo_time = value; break; case 'P': - zopt_passtime = MAX(1, value); + zo->zo_passtime = MAX(1, value); break; case 'F': - zopt_maxloops = MAX(1, value); + zo->zo_maxloops = MAX(1, value); + break; + case 'B': + (void) strlcpy(altdir, optarg, sizeof (altdir)); break; case 'h': usage(B_TRUE); @@ -613,17 +695,59 @@ process_options(int argc, char **argv) } } - zopt_raidz_parity = MIN(zopt_raidz_parity, zopt_raidz - 1); + zo->zo_raidz_parity = MIN(zo->zo_raidz_parity, zo->zo_raidz - 1); - zopt_vdevtime = (zopt_vdevs > 0 ? zopt_time * NANOSEC / zopt_vdevs : + zo->zo_vdevtime = + (zo->zo_vdevs > 0 ? zo->zo_time * NANOSEC / zo->zo_vdevs : UINT64_MAX >> 2); + + if (strlen(altdir) > 0) { + char cmd[MAXNAMELEN]; + char realaltdir[MAXNAMELEN]; + char *bin; + char *ztest; + char *isa; + int isalen; + + (void) realpath(getexecname(), cmd); + if (0 != access(altdir, F_OK)) { + ztest_dump_core = B_FALSE; + fatal(B_TRUE, "invalid alternate ztest path: %s", + altdir); + } + VERIFY(NULL != realpath(altdir, realaltdir)); + + /* + * 'cmd' should be of the form "/usr/bin//ztest". + * We want to extract to determine if we should use + * 32 or 64 bit binaries. + */ + bin = strstr(cmd, "/usr/bin/"); + ztest = strstr(bin, "/ztest"); + isa = bin + 9; + isalen = ztest - isa; + (void) snprintf(zo->zo_alt_ztest, sizeof (zo->zo_alt_ztest), + "%s/usr/bin/%.*s/ztest", realaltdir, isalen, isa); + (void) snprintf(zo->zo_alt_libpath, sizeof (zo->zo_alt_libpath), + "%s/usr/lib/%.*s", realaltdir, isalen, isa); + + if (0 != access(zo->zo_alt_ztest, X_OK)) { + ztest_dump_core = B_FALSE; + fatal(B_TRUE, "invalid alternate ztest: %s", + zo->zo_alt_ztest); + } else if (0 != access(zo->zo_alt_libpath, X_OK)) { + ztest_dump_core = B_FALSE; + fatal(B_TRUE, "invalid alternate lib directory %s", + zo->zo_alt_libpath); + } + } } static void ztest_kill(ztest_shared_t *zs) { - zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(zs->zs_spa)); - zs->zs_space = metaslab_class_get_space(spa_normal_class(zs->zs_spa)); + zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(ztest_spa)); + zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa)); (void) kill(getpid(), SIGKILL); } @@ -635,7 +759,7 @@ ztest_random(uint64_t range) if (range == 0) return (0); - if (read(ztest_random_fd, &r, sizeof (r)) != sizeof (r)) + if (read(ZTEST_FD_RAND, &r, sizeof (r)) != sizeof (r)) fatal(1, "short read from /dev/urandom"); return (r % range); @@ -651,9 +775,9 @@ ztest_record_enospc(const char *s) static uint64_t ztest_get_ashift(void) { - if (zopt_ashift == 0) + if (ztest_opts.zo_ashift == 0) return (SPA_MINBLOCKSHIFT + ztest_random(3)); - return (zopt_ashift); + return (ztest_opts.zo_ashift); } static nvlist_t * @@ -671,12 +795,14 @@ make_vdev_file(char *path, char *aux, si if (aux != NULL) { vdev = ztest_shared->zs_vdev_aux; - (void) sprintf(path, ztest_aux_template, - zopt_dir, zopt_pool, aux, vdev); + (void) snprintf(path, sizeof (pathbuf), + ztest_aux_template, ztest_opts.zo_dir, + ztest_opts.zo_pool, aux, vdev); } else { vdev = ztest_shared->zs_vdev_next_leaf++; - (void) sprintf(path, ztest_dev_template, - zopt_dir, zopt_pool, vdev); + (void) snprintf(path, sizeof (pathbuf), + ztest_dev_template, ztest_opts.zo_dir, + ztest_opts.zo_pool, vdev); } } @@ -714,7 +840,7 @@ make_vdev_raidz(char *path, char *aux, s VERIFY(nvlist_add_string(raidz, ZPOOL_CONFIG_TYPE, VDEV_TYPE_RAIDZ) == 0); VERIFY(nvlist_add_uint64(raidz, ZPOOL_CONFIG_NPARITY, - zopt_raidz_parity) == 0); + ztest_opts.zo_raidz_parity) == 0); VERIFY(nvlist_add_nvlist_array(raidz, ZPOOL_CONFIG_CHILDREN, child, r) == 0); @@ -852,7 +978,7 @@ ztest_dsl_prop_set_uint64(char *osname, VERIFY3U(dsl_prop_get(osname, propname, sizeof (curval), 1, &curval, setpoint), ==, 0); - if (zopt_verbose >= 6) { + if (ztest_opts.zo_verbose >= 6) { VERIFY(zfs_prop_index_to_string(prop, curval, &valname) == 0); (void) printf("%s %s = %s at '%s'\n", osname, propname, valname, setpoint); @@ -862,9 +988,9 @@ ztest_dsl_prop_set_uint64(char *osname, } static int -ztest_spa_prop_set_uint64(ztest_shared_t *zs, zpool_prop_t prop, uint64_t value) +ztest_spa_prop_set_uint64(zpool_prop_t prop, uint64_t value) { - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; nvlist_t *props = NULL; int error; @@ -986,13 +1112,16 @@ ztest_range_unlock(rl_t *rl) } static void -ztest_zd_init(ztest_ds_t *zd, objset_t *os) +ztest_zd_init(ztest_ds_t *zd, ztest_shared_ds_t *szd, objset_t *os) { zd->zd_os = os; zd->zd_zilog = dmu_objset_zil(os); - zd->zd_seq = 0; + zd->zd_shared = szd; dmu_objset_name(os, zd->zd_name); + if (zd->zd_shared != NULL) + zd->zd_shared->zd_seq = 0; + VERIFY(rwlock_init(&zd->zd_zilog_lock, USYNC_THREAD, NULL) == 0); VERIFY(_mutex_init(&zd->zd_dirobj_lock, USYNC_THREAD, NULL) == 0); @@ -2076,8 +2205,9 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_ * will verify that the log really does contain this record. */ mutex_enter(&zilog->zl_lock); - ASSERT(zd->zd_seq <= zilog->zl_commit_lr_seq); - zd->zd_seq = zilog->zl_commit_lr_seq; + ASSERT(zd->zd_shared != NULL); + ASSERT3U(zd->zd_shared->zd_seq, <=, zilog->zl_commit_lr_seq); + zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq; mutex_exit(&zilog->zl_lock); (void) rw_unlock(&zd->zd_zilog_lock); @@ -2114,7 +2244,7 @@ ztest_zil_remount(ztest_ds_t *zd, uint64 void ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id) { - ztest_shared_t *zs = ztest_shared; + ztest_shared_opts_t *zo = &ztest_opts; spa_t *spa; nvlist_t *nvroot; @@ -2138,15 +2268,15 @@ ztest_spa_create_destroy(ztest_ds_t *zd, * Attempt to create an existing pool. It shouldn't matter * what's in the nvroot; we should fail with EEXIST. */ - (void) rw_rdlock(&zs->zs_name_lock); + (void) rw_rdlock(&ztest_name_lock); nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1); - VERIFY3U(EEXIST, ==, spa_create(zs->zs_pool, nvroot, NULL, NULL, NULL)); + VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL)); nvlist_free(nvroot); - VERIFY3U(0, ==, spa_open(zs->zs_pool, &spa, FTAG)); - VERIFY3U(EBUSY, ==, spa_destroy(zs->zs_pool)); + VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG)); + VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool)); spa_close(spa, FTAG); - (void) rw_unlock(&zs->zs_name_lock); + (void) rw_unlock(&ztest_name_lock); } static vdev_t * @@ -2193,14 +2323,15 @@ void ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) { ztest_shared_t *zs = ztest_shared; - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; uint64_t leaves; uint64_t guid; nvlist_t *nvroot; int error; - VERIFY(mutex_lock(&zs->zs_vdev_lock) == 0); - leaves = MAX(zs->zs_mirrors + zs->zs_splits, 1) * zopt_raidz; + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + leaves = + MAX(zs->zs_mirrors + zs->zs_splits, 1) * ztest_opts.zo_raidz; spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); @@ -2225,9 +2356,9 @@ ztest_vdev_add_remove(ztest_ds_t *zd, ui * dmu_objset_destroy() to fail with EBUSY thus * leaving the dataset in an inconsistent state. */ - VERIFY(rw_wrlock(&ztest_shared->zs_name_lock) == 0); + VERIFY(rw_wrlock(&ztest_name_lock) == 0); error = spa_vdev_remove(spa, guid, B_FALSE); - VERIFY(rw_unlock(&ztest_shared->zs_name_lock) == 0); + VERIFY(rw_unlock(&ztest_name_lock) == 0); if (error && error != EEXIST) fatal(0, "spa_vdev_remove() = %d", error); @@ -2237,8 +2368,10 @@ ztest_vdev_add_remove(ztest_ds_t *zd, ui /* * Make 1/4 of the devices be log devices. */ - nvroot = make_vdev_root(NULL, NULL, zopt_vdev_size, 0, - ztest_random(4) == 0, zopt_raidz, zs->zs_mirrors, 1); + nvroot = make_vdev_root(NULL, NULL, + ztest_opts.zo_vdev_size, 0, + ztest_random(4) == 0, ztest_opts.zo_raidz, + zs->zs_mirrors, 1); error = spa_vdev_add(spa, nvroot); nvlist_free(nvroot); @@ -2249,7 +2382,7 @@ ztest_vdev_add_remove(ztest_ds_t *zd, ui fatal(0, "spa_vdev_add() = %d", error); } - VERIFY(mutex_unlock(&ztest_shared->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } /* @@ -2260,7 +2393,7 @@ void ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id) { ztest_shared_t *zs = ztest_shared; - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; vdev_t *rvd = spa->spa_root_vdev; spa_aux_vdev_t *sav; char *aux; @@ -2275,7 +2408,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd aux = ZPOOL_CONFIG_L2CACHE; } - VERIFY(mutex_lock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); @@ -2292,8 +2425,9 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd for (;;) { char path[MAXPATHLEN]; int c; - (void) sprintf(path, ztest_aux_template, zopt_dir, - zopt_pool, aux, zs->zs_vdev_aux); + (void) snprintf(path, sizeof (path), ztest_aux_template, + ztest_opts.zo_dir, ztest_opts.zo_pool, aux, + zs->zs_vdev_aux); for (c = 0; c < sav->sav_count; c++) if (strcmp(sav->sav_vdevs[c]->vdev_path, path) == 0) @@ -2312,7 +2446,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd * Add a new device. */ nvlist_t *nvroot = make_vdev_root(NULL, aux, - (zopt_vdev_size * 5) / 4, 0, 0, 0, 0, 1); + (ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1); error = spa_vdev_add(spa, nvroot); if (error != 0) fatal(0, "spa_vdev_add(%p) = %d", nvroot, error); @@ -2331,7 +2465,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd fatal(0, "spa_vdev_remove(%llu) = %d", guid, error); } - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } /* @@ -2342,17 +2476,17 @@ void ztest_split_pool(ztest_ds_t *zd, uint64_t id) { ztest_shared_t *zs = ztest_shared; - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; vdev_t *rvd = spa->spa_root_vdev; nvlist_t *tree, **child, *config, *split, **schild; uint_t c, children, schildren = 0, lastlogid = 0; int error = 0; - VERIFY(mutex_lock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); /* ensure we have a useable config; mirrors of raidz aren't supported */ - if (zs->zs_mirrors < 3 || zopt_raidz > 1) { - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + if (zs->zs_mirrors < 3 || ztest_opts.zo_raidz > 1) { + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); return; } @@ -2411,9 +2545,9 @@ ztest_split_pool(ztest_ds_t *zd, uint64_ spa_config_exit(spa, SCL_VDEV, FTAG); - (void) rw_wrlock(&zs->zs_name_lock); + (void) rw_wrlock(&ztest_name_lock); error = spa_vdev_split_mirror(spa, "splitp", config, NULL, B_FALSE); - (void) rw_unlock(&zs->zs_name_lock); + (void) rw_unlock(&ztest_name_lock); nvlist_free(config); @@ -2426,7 +2560,7 @@ ztest_split_pool(ztest_ds_t *zd, uint64_ ++zs->zs_splits; --zs->zs_mirrors; } - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } @@ -2438,7 +2572,7 @@ void ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) { ztest_shared_t *zs = ztest_shared; - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; spa_aux_vdev_t *sav = &spa->spa_spares; vdev_t *rvd = spa->spa_root_vdev; vdev_t *oldvd, *newvd, *pvd; @@ -2455,8 +2589,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, int oldvd_is_log; int error, expected_error; - VERIFY(mutex_lock(&zs->zs_vdev_lock) == 0); - leaves = MAX(zs->zs_mirrors, 1) * zopt_raidz; + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + leaves = MAX(zs->zs_mirrors, 1) * ztest_opts.zo_raidz; spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); @@ -2482,12 +2616,12 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, if (zs->zs_mirrors >= 1) { ASSERT(oldvd->vdev_ops == &vdev_mirror_ops); ASSERT(oldvd->vdev_children >= zs->zs_mirrors); - oldvd = oldvd->vdev_child[leaf / zopt_raidz]; + oldvd = oldvd->vdev_child[leaf / ztest_opts.zo_raidz]; } - if (zopt_raidz > 1) { + if (ztest_opts.zo_raidz > 1) { ASSERT(oldvd->vdev_ops == &vdev_raidz_ops); - ASSERT(oldvd->vdev_children == zopt_raidz); - oldvd = oldvd->vdev_child[leaf % zopt_raidz]; + ASSERT(oldvd->vdev_children == ztest_opts.zo_raidz); + oldvd = oldvd->vdev_child[leaf % ztest_opts.zo_raidz]; } /* @@ -2516,7 +2650,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, if (error != 0 && error != ENODEV && error != EBUSY && error != ENOTSUP) fatal(0, "detach (%s) returned %d", oldpath, error); - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); return; } @@ -2530,7 +2664,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, (void) strcpy(newpath, newvd->vdev_path); } else { (void) snprintf(newpath, sizeof (newpath), ztest_dev_template, - zopt_dir, zopt_pool, top * leaves + leaf); + ztest_opts.zo_dir, ztest_opts.zo_pool, + top * leaves + leaf); if (ztest_random(2) == 0) newpath[strlen(newpath) - 1] = 'b'; newvd = vdev_lookup_by_path(rvd, newpath); @@ -2609,7 +2744,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, (longlong_t)newsize, replacing, error, expected_error); } - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } /* @@ -2632,7 +2767,7 @@ grow_vdev(vdev_t *vd, void *arg) fsize = lseek(fd, 0, SEEK_END); (void) ftruncate(fd, *newsize); - if (zopt_verbose >= 6) { + if (ztest_opts.zo_verbose >= 6) { (void) printf("%s grew from %lu to %lu bytes\n", vd->vdev_path, (ulong_t)fsize, (ulong_t)*newsize); } @@ -2668,7 +2803,7 @@ online_vdev(vdev_t *vd, void *arg) * vdev_open fails is by checking the returned newstate. */ if (error || newstate != VDEV_STATE_HEALTHY) { - if (zopt_verbose >= 5) { + if (ztest_opts.zo_verbose >= 5) { (void) printf("Unable to expand vdev, state %llu, " "error %d\n", (u_longlong_t)newstate, error); } @@ -2683,7 +2818,7 @@ online_vdev(vdev_t *vd, void *arg) * trying to online it. */ if (generation != spa->spa_config_generation) { - if (zopt_verbose >= 5) { + if (ztest_opts.zo_verbose >= 5) { (void) printf("vdev configuration has changed, " "guid %llu, state %llu, expected gen %llu, " "got gen %llu\n", @@ -2729,8 +2864,7 @@ vdev_walk_tree(vdev_t *vd, vdev_t *(*fun void ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) { - ztest_shared_t *zs = ztest_shared; - spa_t *spa = zs->zs_spa; + spa_t *spa = ztest_spa; vdev_t *vd, *tvd; metaslab_class_t *mc; metaslab_group_t *mg; @@ -2738,7 +2872,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui uint64_t top; uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count; - VERIFY(mutex_lock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); spa_config_enter(spa, SCL_STATE, spa, RW_READER); top = ztest_random_vdev_top(spa, B_TRUE); @@ -2764,16 +2898,16 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui * original size, and it has a valid psize. */ if (tvd->vdev_state != VDEV_STATE_HEALTHY || - psize == 0 || psize >= 4 * zopt_vdev_size) { + psize == 0 || psize >= 4 * ztest_opts.zo_vdev_size) { spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); return; } ASSERT(psize > 0); newsize = psize + psize / 8; ASSERT3U(newsize, >, psize); - if (zopt_verbose >= 6) { + if (ztest_opts.zo_verbose >= 6) { (void) printf("Expanding LUN %s from %lu to %lu\n", vd->vdev_path, (ulong_t)psize, (ulong_t)newsize); } @@ -2786,12 +2920,12 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui if (vdev_walk_tree(tvd, grow_vdev, &newsize) != NULL || vdev_walk_tree(tvd, online_vdev, NULL) != NULL || tvd->vdev_state != VDEV_STATE_HEALTHY) { - if (zopt_verbose >= 5) { + if (ztest_opts.zo_verbose >= 5) { (void) printf("Could not expand LUN because " "the vdev configuration changed.\n"); } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); return; } @@ -2820,12 +2954,12 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui new_class_space = metaslab_class_get_space(mc); if (tvd->vdev_mg != mg || mg->mg_class != mc) { - if (zopt_verbose >= 5) { + if (ztest_opts.zo_verbose >= 5) { (void) printf("Could not verify LUN expansion due to " "intervening vdev offline or remove.\n"); } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); return; } @@ -2843,7 +2977,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui fatal(0, "LUN expansion failed: class_space %llu <= %llu\n", old_class_space, new_class_space); - if (zopt_verbose >= 5) { + if (ztest_opts.zo_verbose >= 5) { char oldnumbuf[6], newnumbuf[6]; nicenum(old_class_space, oldnumbuf); @@ -2853,7 +2987,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, ui } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&zs->zs_vdev_lock) == 0); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } /* @@ -2880,7 +3014,8 @@ ztest_dataset_create(char *dsname) if (err || zilset < 80) return (err); - (void) printf("Setting dataset %s to sync always\n", dsname); + if (ztest_opts.zo_verbose >= 6) + (void) printf("Setting dataset %s to sync always\n", dsname); return (ztest_dsl_prop_set_uint64(dsname, ZFS_PROP_SYNC, ZFS_SYNC_ALWAYS, B_FALSE)); } @@ -2952,7 +3087,6 @@ ztest_snapshot_destroy(char *osname, uin void ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) { - ztest_shared_t *zs = ztest_shared; ztest_ds_t zdtmp; int iters; int error; @@ -2960,10 +3094,10 @@ ztest_dmu_objset_create_destroy(ztest_ds char name[MAXNAMELEN]; zilog_t *zilog; - (void) rw_rdlock(&zs->zs_name_lock); + (void) rw_rdlock(&ztest_name_lock); (void) snprintf(name, MAXNAMELEN, "%s/temp_%llu", - zs->zs_pool, (u_longlong_t)id); + ztest_opts.zo_pool, (u_longlong_t)id); /* * If this dataset exists from a previous run, process its replay log @@ -2972,7 +3106,7 @@ ztest_dmu_objset_create_destroy(ztest_ds */ if (ztest_random(2) == 0 && dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, FTAG, &os) == 0) { - ztest_zd_init(&zdtmp, os); + ztest_zd_init(&zdtmp, NULL, os); zil_replay(os, &zdtmp, ztest_replay_vector); ztest_zd_fini(&zdtmp); dmu_objset_disown(os, FTAG); @@ -2998,7 +3132,7 @@ ztest_dmu_objset_create_destroy(ztest_ds if (error) { if (error == ENOSPC) { ztest_record_enospc(FTAG); - (void) rw_unlock(&zs->zs_name_lock); + (void) rw_unlock(&ztest_name_lock); return; } fatal(0, "dmu_objset_create(%s) = %d", name, error); @@ -3007,7 +3141,7 @@ ztest_dmu_objset_create_destroy(ztest_ds VERIFY3U(0, ==, dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, FTAG, &os)); - ztest_zd_init(&zdtmp, os); + ztest_zd_init(&zdtmp, NULL, os); /* * Open the intent log for it. @@ -3047,7 +3181,7 @@ ztest_dmu_objset_create_destroy(ztest_ds dmu_objset_disown(os, FTAG); ztest_zd_fini(&zdtmp); - (void) rw_unlock(&zs->zs_name_lock); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 10 07:40:26 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2E49106566B; Sun, 10 Jun 2012 07:40:26 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C93E28FC21; Sun, 10 Jun 2012 07:40:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5A7eQHp080975; Sun, 10 Jun 2012 07:40:26 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5A7eQO1080957; Sun, 10 Jun 2012 07:40:26 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206100740.q5A7eQO1080957@svn.freebsd.org> From: Martin Matuska Date: Sun, 10 Jun 2012 07:40:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236839 - in stable/9: cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contrib/opensolaris/uts/common/fs/z... X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2012 07:40:27 -0000 Author: mm Date: Sun Jun 10 07:40:26 2012 New Revision: 236839 URL: http://svn.freebsd.org/changeset/base/236839 Log: MFC r236155: Import illumos changeset 13570:3411fd5f1589 1948 zpool list should show more detailed pool information Display per-vdev information with "zpool list -v". The added expandsize property has currently no value on FreeBSD. This changeset allows adding expansion support to individual vdevs in the future. References: https://www.illumos.org/issues/1948 Obtained from: illumos (issue #1948) Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c stable/9/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c stable/9/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Sun Jun 10 07:40:26 2012 (r236839) @@ -537,6 +537,8 @@ value of 1.76 indicates that 1.76 units for a description of the deduplication feature. .It Sy free Number of blocks within the pool that are not allocated. +.It Sy expandsize +This property has currently no value on FreeBSD. .It Sy guid A unique identifier for the pool. .It Sy health @@ -1275,7 +1277,7 @@ Treat exported or foreign devices as ina .It Xo .Nm .Cm list -.Op Fl H +.Op Fl Hv .Op Fl o Ar property Ns Op , Ns Ar ... .Op Fl T Cm d Ns | Ns Cm u .Op Ar pool Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Sun Jun 10 07:40:26 2012 (r236839) @@ -22,9 +22,9 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2012 by Frederik Wessels. All rights reserved. - * Copyright (c) 2011 Martin Matuska . All rights reserved. + * Copyright (c) 2012 Martin Matuska . All rights reserved. */ #include @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,7 @@ static int zpool_do_status(int, char **) static int zpool_do_online(int, char **); static int zpool_do_offline(int, char **); static int zpool_do_clear(int, char **); +static int zpool_do_reopen(int, char **); static int zpool_do_reguid(int, char **); @@ -132,7 +134,8 @@ typedef enum { HELP_GET, HELP_SET, HELP_SPLIT, - HELP_REGUID + HELP_REGUID, + HELP_REOPEN } zpool_help_t; @@ -167,6 +170,7 @@ static zpool_command_t command_table[] = { "online", zpool_do_online, HELP_ONLINE }, { "offline", zpool_do_offline, HELP_OFFLINE }, { "clear", zpool_do_clear, HELP_CLEAR }, + { "reopen", zpool_do_reopen, HELP_REOPEN }, { NULL }, { "attach", zpool_do_attach, HELP_ATTACH }, { "detach", zpool_do_detach, HELP_DETACH }, @@ -241,6 +245,8 @@ get_usage(zpool_help_t idx) { "[new-device]\n")); case HELP_REMOVE: return (gettext("\tremove ...\n")); + case HELP_REOPEN: + return (""); /* Undocumented command */ case HELP_SCRUB: return (gettext("\tscrub [-s] ...\n")); case HELP_STATUS: @@ -2109,10 +2115,10 @@ error: } typedef struct iostat_cbdata { - zpool_list_t *cb_list; - int cb_verbose; - int cb_iteration; + boolean_t cb_verbose; int cb_namewidth; + int cb_iteration; + zpool_list_t *cb_list; } iostat_cbdata_t; static void @@ -2582,8 +2588,9 @@ zpool_do_iostat(int argc, char **argv) } typedef struct list_cbdata { + boolean_t cb_verbose; + int cb_namewidth; boolean_t cb_scripted; - boolean_t cb_first; zprop_list_t *cb_proplist; } list_cbdata_t; @@ -2591,16 +2598,27 @@ typedef struct list_cbdata { * Given a list of columns to display, output appropriate headers for each one. */ static void -print_header(zprop_list_t *pl) +print_header(list_cbdata_t *cb) { + zprop_list_t *pl = cb->cb_proplist; const char *header; boolean_t first = B_TRUE; boolean_t right_justify; + size_t width = 0; for (; pl != NULL; pl = pl->pl_next) { if (pl->pl_prop == ZPROP_INVAL) continue; + width = pl->pl_width; + if (first && cb->cb_verbose) { + /* + * Reset the width to accommodate the verbose listing + * of devices. + */ + width = cb->cb_namewidth; + } + if (!first) (void) printf(" "); else @@ -2612,9 +2630,10 @@ print_header(zprop_list_t *pl) if (pl->pl_next == NULL && !right_justify) (void) printf("%s", header); else if (right_justify) - (void) printf("%*s", pl->pl_width, header); + (void) printf("%*s", width, header); else - (void) printf("%-*s", pl->pl_width, header); + (void) printf("%-*s", width, header); + } (void) printf("\n"); @@ -2625,17 +2644,28 @@ print_header(zprop_list_t *pl) * to the described layout. */ static void -print_pool(zpool_handle_t *zhp, zprop_list_t *pl, int scripted) +print_pool(zpool_handle_t *zhp, list_cbdata_t *cb) { + zprop_list_t *pl = cb->cb_proplist; boolean_t first = B_TRUE; char property[ZPOOL_MAXPROPLEN]; char *propstr; boolean_t right_justify; - int width; + size_t width; for (; pl != NULL; pl = pl->pl_next) { + + width = pl->pl_width; + if (first && cb->cb_verbose) { + /* + * Reset the width to accommodate the verbose listing + * of devices. + */ + width = cb->cb_namewidth; + } + if (!first) { - if (scripted) + if (cb->cb_scripted) (void) printf("\t"); else (void) printf(" "); @@ -2645,7 +2675,10 @@ print_pool(zpool_handle_t *zhp, zprop_li right_justify = B_FALSE; if (pl->pl_prop != ZPROP_INVAL) { - if (zpool_get_prop(zhp, pl->pl_prop, property, + if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ && + zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0) + propstr = "-"; + else if (zpool_get_prop(zhp, pl->pl_prop, property, sizeof (property), NULL) != 0) propstr = "-"; else @@ -2656,14 +2689,13 @@ print_pool(zpool_handle_t *zhp, zprop_li propstr = "-"; } - width = pl->pl_width; /* * If this is being called in scripted mode, or if this is the * last column and it is left-justified, don't include a width * format specifier. */ - if (scripted || (pl->pl_next == NULL && !right_justify)) + if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify)) (void) printf("%s", propstr); else if (right_justify) (void) printf("%*s", width, propstr); @@ -2674,6 +2706,101 @@ print_pool(zpool_handle_t *zhp, zprop_li (void) printf("\n"); } +static void +print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted) +{ + char propval[64]; + boolean_t fixed; + size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL); + + zfs_nicenum(value, propval, sizeof (propval)); + + if (prop == ZPOOL_PROP_EXPANDSZ && value == 0) + (void) strlcpy(propval, "-", sizeof (propval)); + + if (scripted) + (void) printf("\t%s", propval); + else + (void) printf(" %*s", width, propval); +} + +void +print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, + list_cbdata_t *cb, int depth) +{ + nvlist_t **child; + vdev_stat_t *vs; + uint_t c, children; + char *vname; + boolean_t scripted = cb->cb_scripted; + + verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, + (uint64_t **)&vs, &c) == 0); + + if (name != NULL) { + if (scripted) + (void) printf("\t%s", name); + else if (strlen(name) + depth > cb->cb_namewidth) + (void) printf("%*s%s", depth, "", name); + else + (void) printf("%*s%s%*s", depth, "", name, + (int)(cb->cb_namewidth - strlen(name) - depth), ""); + + /* only toplevel vdevs have capacity stats */ + if (vs->vs_space == 0) { + if (scripted) + (void) printf("\t-\t-\t-"); + else + (void) printf(" - - -"); + } else { + print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, + scripted); + print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc, + scripted); + print_one_column(ZPOOL_PROP_FREE, + vs->vs_space - vs->vs_alloc, scripted); + } + print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, + scripted); + (void) printf("\n"); + } + + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, + &child, &children) != 0) + return; + + for (c = 0; c < children; c++) { + uint64_t ishole = B_FALSE; + + if (nvlist_lookup_uint64(child[c], + ZPOOL_CONFIG_IS_HOLE, &ishole) == 0 && ishole) + continue; + + vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE); + print_list_stats(zhp, vname, child[c], cb, depth + 2); + free(vname); + } + + /* + * Include level 2 ARC devices in iostat output + */ + if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, + &child, &children) != 0) + return; + + if (children > 0) { + (void) printf("%-*s - - - - - " + "-\n", cb->cb_namewidth, "cache"); + for (c = 0; c < children; c++) { + vname = zpool_vdev_name(g_zfs, zhp, child[c], + B_FALSE); + print_list_stats(zhp, vname, child[c], cb, depth + 2); + free(vname); + } + } +} + + /* * Generic callback function to list a pool. */ @@ -2681,14 +2808,18 @@ int list_callback(zpool_handle_t *zhp, void *data) { list_cbdata_t *cbp = data; + nvlist_t *config; + nvlist_t *nvroot; - if (cbp->cb_first) { - if (!cbp->cb_scripted) - print_header(cbp->cb_proplist); - cbp->cb_first = B_FALSE; - } + config = zpool_get_config(zhp, NULL); - print_pool(zhp, cbp->cb_proplist, cbp->cb_scripted); + print_pool(zhp, cbp); + if (!cbp->cb_verbose) + return (0); + + verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, + &nvroot) == 0); + print_list_stats(zhp, NULL, nvroot, cbp, 0); return (0); } @@ -2712,12 +2843,15 @@ zpool_do_list(int argc, char **argv) int ret; list_cbdata_t cb = { 0 }; static char default_props[] = - "name,size,allocated,free,capacity,dedupratio,health,altroot"; + "name,size,allocated,free,capacity,dedupratio," + "health,altroot"; char *props = default_props; unsigned long interval = 0, count = 0; + zpool_list_t *list; + boolean_t first = B_TRUE; /* check options */ - while ((c = getopt(argc, argv, ":Ho:T:")) != -1) { + while ((c = getopt(argc, argv, ":Ho:T:v")) != -1) { switch (c) { case 'H': cb.cb_scripted = B_TRUE; @@ -2728,6 +2862,9 @@ zpool_do_list(int argc, char **argv) case 'T': get_timestamp_arg(*optarg); break; + case 'v': + cb.cb_verbose = B_TRUE; + break; case ':': (void) fprintf(stderr, gettext("missing argument for " "'%c' option\n"), optopt); @@ -2748,21 +2885,32 @@ zpool_do_list(int argc, char **argv) if (zprop_get_list(g_zfs, props, &cb.cb_proplist, ZFS_TYPE_POOL) != 0) usage(B_FALSE); - cb.cb_first = B_TRUE; + if ((list = pool_list_get(argc, argv, &cb.cb_proplist, &ret)) == NULL) + return (1); + + if (argc == 0 && !cb.cb_scripted && pool_list_count(list) == 0) { + (void) printf(gettext("no pools available\n")); + zprop_free_list(cb.cb_proplist); + return (0); + } for (;;) { + pool_list_update(list); + + if (pool_list_count(list) == 0) + break; + + cb.cb_namewidth = 0; + (void) pool_list_iter(list, B_FALSE, get_namewidth, &cb); if (timestamp_fmt != NODATE) print_timestamp(timestamp_fmt); - ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist, - list_callback, &cb); - - if (argc == 0 && cb.cb_first && !cb.cb_scripted) { - (void) printf(gettext("no pools available\n")); - zprop_free_list(cb.cb_proplist); - return (0); + if (!cb.cb_scripted && (first || cb.cb_verbose)) { + print_header(&cb); + first = B_FALSE; } + ret = pool_list_iter(list, B_TRUE, list_callback, &cb); if (interval == 0) break; @@ -3382,6 +3530,36 @@ zpool_do_reguid(int argc, char **argv) } +/* + * zpool reopen + * + * Reopen the pool so that the kernel can update the sizes of all vdevs. + * + * NOTE: This command is currently undocumented. If the command is ever + * exposed then the appropriate usage() messages will need to be made. + */ +int +zpool_do_reopen(int argc, char **argv) +{ + int ret = 0; + zpool_handle_t *zhp; + char *pool; + + argc--; + argv++; + + if (argc != 1) + return (2); + + pool = argv[0]; + if ((zhp = zpool_open_canfail(g_zfs, pool)) == NULL) + return (1); + + ret = zpool_reopen(zhp); + zpool_close(zhp); + return (ret); +} + typedef struct scrub_cbdata { int cb_type; int cb_argc; Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Sun Jun 10 07:40:26 2012 (r236839) @@ -24,7 +24,7 @@ * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. */ @@ -237,6 +237,7 @@ typedef struct splitflags { extern int zpool_scan(zpool_handle_t *, pool_scan_func_t); extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *); extern int zpool_reguid(zpool_handle_t *); +extern int zpool_reopen(zpool_handle_t *); extern int zpool_vdev_online(zpool_handle_t *, const char *, int, vdev_state_t *); Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Sun Jun 10 07:40:26 2012 (r236839) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -301,6 +301,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpoo case ZPOOL_PROP_SIZE: case ZPOOL_PROP_ALLOCATED: case ZPOOL_PROP_FREE: + case ZPOOL_PROP_EXPANDSZ: (void) zfs_nicenum(intval, buf, len); break; @@ -390,8 +391,8 @@ pool_uses_efi(nvlist_t *config) return (B_FALSE); } -static boolean_t -pool_is_bootable(zpool_handle_t *zhp) +boolean_t +zpool_is_bootable(zpool_handle_t *zhp) { char bootfs[ZPOOL_MAXNAMELEN]; @@ -1126,7 +1127,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t return (zfs_error(hdl, EZFS_BADVERSION, msg)); } - if (pool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, + if (zpool_is_bootable(zhp) && nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES, &spares, &nspares) == 0) { uint64_t s; @@ -2412,7 +2413,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, uint_t children; nvlist_t *config_root; libzfs_handle_t *hdl = zhp->zpool_hdl; - boolean_t rootpool = pool_is_bootable(zhp); + boolean_t rootpool = zpool_is_bootable(zhp); if (replacing) (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, @@ -3054,6 +3055,26 @@ zpool_reguid(zpool_handle_t *zhp) } /* + * Reopen the pool. + */ +int +zpool_reopen(zpool_handle_t *zhp) +{ + zfs_cmd_t zc = { 0 }; + char msg[1024]; + libzfs_handle_t *hdl = zhp->zpool_hdl; + + (void) snprintf(msg, sizeof (msg), + dgettext(TEXT_DOMAIN, "cannot reopen '%s'"), + zhp->zpool_name); + + (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); + if (zfs_ioctl(hdl, ZFS_IOC_POOL_REOPEN, &zc) == 0) + return (0); + return (zpool_standard_error(hdl, errno, msg)); +} + +/* * Convert from a devid string to a path. */ static char * @@ -3703,7 +3724,7 @@ zpool_label_disk(libzfs_handle_t *hdl, z if (zhp) { nvlist_t *nvroot; - if (pool_is_bootable(zhp)) { + if (zpool_is_bootable(zhp)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "EFI labeled devices are not supported on root " "pools.")); Modified: stable/9/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c Sun Jun 10 07:40:26 2012 (r236839) @@ -21,7 +21,7 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -81,6 +81,8 @@ zpool_prop_init(void) ZFS_TYPE_POOL, "", "FREE"); zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0, PROP_READONLY, ZFS_TYPE_POOL, "", "ALLOC"); + zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0, + PROP_READONLY, ZFS_TYPE_POOL, "", "EXPANDSZ"); zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY, ZFS_TYPE_POOL, "", "CAP"); zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY, Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Sun Jun 10 07:40:26 2012 (r236839) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ /* @@ -175,15 +175,17 @@ spa_prop_add_list(nvlist_t *nvl, zpool_p static void spa_prop_get_config(spa_t *spa, nvlist_t **nvp) { + vdev_t *rvd = spa->spa_root_vdev; uint64_t size; uint64_t alloc; + uint64_t space; uint64_t cap, version; zprop_source_t src = ZPROP_SRC_NONE; spa_config_dirent_t *dp; ASSERT(MUTEX_HELD(&spa->spa_props_lock)); - if (spa->spa_root_vdev != NULL) { + if (rvd != NULL) { alloc = metaslab_class_get_alloc(spa_normal_class(spa)); size = metaslab_class_get_space(spa_normal_class(spa)); spa_prop_add_list(*nvp, ZPOOL_PROP_NAME, spa_name(spa), 0, src); @@ -191,6 +193,15 @@ spa_prop_get_config(spa_t *spa, nvlist_t spa_prop_add_list(*nvp, ZPOOL_PROP_ALLOCATED, NULL, alloc, src); spa_prop_add_list(*nvp, ZPOOL_PROP_FREE, NULL, size - alloc, src); + + space = 0; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *tvd = rvd->vdev_child[c]; + space += tvd->vdev_max_asize - tvd->vdev_asize; + } + spa_prop_add_list(*nvp, ZPOOL_PROP_EXPANDSZ, NULL, space, + src); + spa_prop_add_list(*nvp, ZPOOL_PROP_READONLY, NULL, (spa_mode(spa) == FREAD), src); @@ -201,7 +212,7 @@ spa_prop_get_config(spa_t *spa, nvlist_t ddt_get_pool_dedup_ratio(spa), src); spa_prop_add_list(*nvp, ZPOOL_PROP_HEALTH, NULL, - spa->spa_root_vdev->vdev_state, src); + rvd->vdev_state, src); version = spa_version(spa); if (version == zpool_prop_default_numeric(ZPOOL_PROP_VERSION)) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Sun Jun 10 07:40:26 2012 (r236839) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #ifndef _SYS_VDEV_IMPL_H @@ -55,7 +56,8 @@ typedef struct vdev_cache_entry vdev_cac /* * Virtual device operations */ -typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *ashift); +typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size, + uint64_t *ashift); typedef void vdev_close_func_t(vdev_t *vd); typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize); typedef int vdev_io_start_func_t(zio_t *zio); @@ -118,6 +120,7 @@ struct vdev { uint64_t vdev_orig_guid; /* orig. guid prior to remove */ uint64_t vdev_asize; /* allocatable device capacity */ uint64_t vdev_min_asize; /* min acceptable asize */ + uint64_t vdev_max_asize; /* max acceptable asize */ uint64_t vdev_ashift; /* block alignment shift */ uint64_t vdev_state; /* see VDEV_STATE_* #defines */ uint64_t vdev_prevstate; /* used when reopening a vdev */ Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Sun Jun 10 07:40:26 2012 (r236839) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -119,7 +119,7 @@ vdev_get_min_asize(vdev_t *vd) vdev_t *pvd = vd->vdev_parent; /* - * The our parent is NULL (inactive spare or cache) or is the root, + * If our parent is NULL (inactive spare or cache) or is the root, * just return our own asize. */ if (pvd == NULL) @@ -748,6 +748,7 @@ vdev_add_parent(vdev_t *cvd, vdev_ops_t mvd->vdev_asize = cvd->vdev_asize; mvd->vdev_min_asize = cvd->vdev_min_asize; + mvd->vdev_max_asize = cvd->vdev_max_asize; mvd->vdev_ashift = cvd->vdev_ashift; mvd->vdev_state = cvd->vdev_state; mvd->vdev_crtxg = cvd->vdev_crtxg; @@ -1119,7 +1120,8 @@ vdev_open(vdev_t *vd) spa_t *spa = vd->vdev_spa; int error; uint64_t osize = 0; - uint64_t asize, psize; + uint64_t max_osize = 0; + uint64_t asize, max_asize, psize; uint64_t ashift = 0; ASSERT(vd->vdev_open_thread == curthread || @@ -1150,7 +1152,7 @@ vdev_open(vdev_t *vd) return (ENXIO); } - error = vd->vdev_ops->vdev_op_open(vd, &osize, &ashift); + error = vd->vdev_ops->vdev_op_open(vd, &osize, &max_osize, &ashift); /* * Reset the vdev_reopening flag so that we actually close @@ -1208,6 +1210,7 @@ vdev_open(vdev_t *vd) } osize = P2ALIGN(osize, (uint64_t)sizeof (vdev_label_t)); + max_osize = P2ALIGN(max_osize, (uint64_t)sizeof (vdev_label_t)); if (vd->vdev_children == 0) { if (osize < SPA_MINDEVSIZE) { @@ -1217,6 +1220,8 @@ vdev_open(vdev_t *vd) } psize = osize; asize = osize - (VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE); + max_asize = max_osize - (VDEV_LABEL_START_SIZE + + VDEV_LABEL_END_SIZE); } else { if (vd->vdev_parent != NULL && osize < SPA_MINDEVSIZE - (VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE)) { @@ -1226,6 +1231,7 @@ vdev_open(vdev_t *vd) } psize = 0; asize = osize; + max_asize = max_osize; } vd->vdev_psize = psize; @@ -1245,6 +1251,7 @@ vdev_open(vdev_t *vd) * For testing purposes, a higher ashift can be requested. */ vd->vdev_asize = asize; + vd->vdev_max_asize = max_asize; vd->vdev_ashift = MAX(ashift, vd->vdev_ashift); } else { /* @@ -1255,6 +1262,7 @@ vdev_open(vdev_t *vd) VDEV_AUX_BAD_LABEL); return (EINVAL); } + vd->vdev_max_asize = max_asize; } /* @@ -2478,6 +2486,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t * vs->vs_rsize = vdev_get_min_asize(vd); if (vd->vdev_ops->vdev_op_leaf) vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize; mutex_exit(&vd->vdev_stat_lock); /* Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Sun Jun 10 07:40:26 2012 (r236839) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -30,6 +31,7 @@ #include #include #include +#include #include /* @@ -102,8 +104,39 @@ vdev_disk_rele(vdev_t *vd) } } +static uint64_t +vdev_disk_get_space(vdev_t *vd, uint64_t capacity, uint_t blksz) +{ + ASSERT(vd->vdev_wholedisk); + + vdev_disk_t *dvd = vd->vdev_tsd; + dk_efi_t dk_ioc; + efi_gpt_t *efi; + uint64_t avail_space = 0; + int efisize = EFI_LABEL_SIZE * 2; + + dk_ioc.dki_data = kmem_alloc(efisize, KM_SLEEP); + dk_ioc.dki_lba = 1; + dk_ioc.dki_length = efisize; + dk_ioc.dki_data_64 = (uint64_t)(uintptr_t)dk_ioc.dki_data; + efi = dk_ioc.dki_data; + + if (ldi_ioctl(dvd->vd_lh, DKIOCGETEFI, (intptr_t)&dk_ioc, + FKIOCTL, kcred, NULL) == 0) { + uint64_t efi_altern_lba = LE_64(efi->efi_gpt_AlternateLBA); + + zfs_dbgmsg("vdev %s, capacity %llu, altern lba %llu", + vd->vdev_path, capacity, efi_altern_lba); + if (capacity > efi_altern_lba) + avail_space = (capacity - efi_altern_lba) * blksz; + } + kmem_free(dk_ioc.dki_data, efisize); + return (avail_space); +} + static int -vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) +vdev_disk_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, + uint64_t *ashift) { spa_t *spa = vd->vdev_spa; vdev_disk_t *dvd; @@ -274,16 +307,6 @@ skip_open: } /* - * If we own the whole disk, try to enable disk write caching. - * We ignore errors because it's OK if we can't do it. - */ - if (vd->vdev_wholedisk == 1) { - int wce = 1; - (void) ldi_ioctl(dvd->vd_lh, DKIOCSETWCE, (intptr_t)&wce, - FKIOCTL, kcred, NULL); - } - - /* * Determine the device's minimum transfer size. * If the ioctl isn't supported, assume DEV_BSIZE. */ @@ -293,6 +316,25 @@ skip_open: *ashift = highbit(MAX(dkmext.dki_pbsize, SPA_MINBLOCKSIZE)) - 1; + if (vd->vdev_wholedisk == 1) { + uint64_t capacity = dkmext.dki_capacity - 1; + uint64_t blksz = dkmext.dki_lbsize; + int wce = 1; + + /* + * If we own the whole disk, try to enable disk write caching. + * We ignore errors because it's OK if we can't do it. + */ + (void) ldi_ioctl(dvd->vd_lh, DKIOCSETWCE, (intptr_t)&wce, + FKIOCTL, kcred, NULL); + + *max_psize = *psize + vdev_disk_get_space(vd, capacity, blksz); + zfs_dbgmsg("capacity change: vdev %s, psize %llu, " + "max_psize %llu", vd->vdev_path, *psize, *max_psize); + } else { + *max_psize = *psize; + } + /* * Clear the nowritecache bit, so that on a vdev_reopen() we will * try again. Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c Sun Jun 10 07:40:26 2012 (r236839) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -47,7 +48,8 @@ vdev_file_rele(vdev_t *vd) } static int -vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) +vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, + uint64_t *ashift) { vdev_file_t *vf; vnode_t *vp; @@ -125,7 +127,7 @@ skip_open: return (error); } - *psize = vattr.va_size; + *max_psize = *psize = vattr.va_size; *ashift = SPA_MINBLOCKSHIFT; return (0); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sun Jun 10 07:40:26 2012 (r236839) @@ -21,6 +21,8 @@ /* * Copyright (c) 2006 Pawel Jakub Dawidek * All rights reserved. + * + * Portions Copyright (c) 2012 Martin Matuska */ #include @@ -405,7 +407,8 @@ vdev_geom_open_by_path(vdev_t *vd, int c } static int -vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) +vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, + uint64_t *ashift) { struct g_provider *pp; struct g_consumer *cp; @@ -488,7 +491,7 @@ vdev_geom_open(vdev_t *vd, uint64_t *psi /* * Determine the actual size of the device. */ - *psize = pp->mediasize; + *max_psize = *psize = pp->mediasize; /* * Determine the device's minimum transfer size. Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c Sun Jun 10 07:40:26 2012 (r236839) @@ -23,6 +23,10 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + #include #include #include @@ -127,7 +131,8 @@ vdev_mirror_map_alloc(zio_t *zio) } static int -vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift) +vdev_mirror_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize, + uint64_t *ashift) { int numerrors = 0; int lasterror = 0; @@ -149,6 +154,7 @@ vdev_mirror_open(vdev_t *vd, uint64_t *a } *asize = MIN(*asize - 1, cvd->vdev_asize - 1) + 1; + *max_asize = MIN(*max_asize - 1, cvd->vdev_max_asize - 1) + 1; *ashift = MAX(*ashift, cvd->vdev_ashift); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c Sun Jun 10 07:40:26 2012 (r236839) @@ -24,6 +24,10 @@ */ /* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +/* * The 'missing' vdev is a special vdev type used only during import. It * signifies a placeholder in the root vdev for some vdev that we know is * missing. We pass it down to the kernel to allow the rest of the @@ -40,7 +44,8 @@ /* ARGSUSED */ static int -vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *ashift) +vdev_missing_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, + uint64_t *ashift) { /* * Really this should just fail. But then the root vdev will be in the @@ -49,6 +54,7 @@ vdev_missing_open(vdev_t *vd, uint64_t * * will fail the GUID sum check before ever trying to open the pool. */ *psize = 0; + *max_psize = 0; *ashift = 0; return (0); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c Sun Jun 10 07:40:26 2012 (r236839) @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include @@ -1441,7 +1442,8 @@ vdev_raidz_reconstruct(raidz_map_t *rm, } static int -vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *ashift) +vdev_raidz_open(vdev_t *vd, uint64_t *asize, uint64_t *max_asize, + uint64_t *ashift) { vdev_t *cvd; uint64_t nparity = vd->vdev_nparity; @@ -1469,10 +1471,12 @@ vdev_raidz_open(vdev_t *vd, uint64_t *as } *asize = MIN(*asize - 1, cvd->vdev_asize - 1) + 1; + *max_asize = MIN(*max_asize - 1, cvd->vdev_max_asize - 1) + 1; *ashift = MAX(*ashift, cvd->vdev_ashift); } *asize *= vd->vdev_children; + *max_asize *= vd->vdev_children; if (numerrors > nparity) { vd->vdev_stat.vs_aux = VDEV_AUX_NO_REPLICAS; Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c Sun Jun 10 07:24:04 2012 (r236838) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c Sun Jun 10 07:40:26 2012 (r236839) @@ -23,6 +23,10 @@ * Use is subject to license terms. */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 10 13:28:14 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E97291065676; Sun, 10 Jun 2012 13:28:14 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D35F08FC14; Sun, 10 Jun 2012 13:28:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5ADSE0O099609; Sun, 10 Jun 2012 13:28:14 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5ADSEO7099606; Sun, 10 Jun 2012 13:28:14 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201206101328.q5ADSEO7099606@svn.freebsd.org> From: Dimitry Andric Date: Sun, 10 Jun 2012 13:28:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236851 - in stable/9: . share/mk X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2012 13:28:15 -0000 Author: dim Date: Sun Jun 10 13:28:14 2012 New Revision: 236851 URL: http://svn.freebsd.org/changeset/base/236851 Log: MFC r236528: During buildworld and buildkernel, define EARLY_BUILD in the earlier stages (build-tools, cross-tools, etc) of the build, so we can detect in bsd.*.mk whether to pass compiler-specific flags to ${CC}. In particular, this commit will allow using WITH_CLANG_IS_CC when the base compiler is still gcc, and when ${CC}, ${CXX} and ${CPP} are left at their defaults. The early stages will then be built using gcc, and no clang-specific flags will be passed to it. The later stages will be built as usual. The EARLY_BUILD define can also serve other uses, such as building the world stage C++ executables with libc++ instead of libstdc++: during the early build stages, we cannot assume libc++ is already available, so we must still build with libstdc++ at that time. Modified: stable/9/Makefile.inc1 (contents, props changed) stable/9/share/mk/bsd.sys.mk (contents, props changed) Directory Properties: stable/9/share/mk/ (props changed) Modified: stable/9/Makefile.inc1 ============================================================================== --- stable/9/Makefile.inc1 Sun Jun 10 13:15:13 2012 (r236850) +++ stable/9/Makefile.inc1 Sun Jun 10 13:28:14 2012 (r236851) @@ -240,7 +240,7 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ SSP_CFLAGS= \ -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \ -DNO_PIC -DWITHOUT_PROFILE -DNO_SHARED \ - -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF + -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD # build-tools stage TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ @@ -250,7 +250,7 @@ TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ BOOTSTRAPPING=${OSRELDATE} \ SSP_CFLAGS= \ -DNO_LINT \ - -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF + -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD # cross-tools stage XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ @@ -492,7 +492,8 @@ build32: .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic cd ${.CURDIR}/${_dir}; \ MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \ - DIRPRFX=${_dir}/ build-tools + DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \ + -DEARLY_BUILD build-tools .endfor cd ${.CURDIR}; \ ${LIB32WMAKE} -f Makefile.inc1 libraries @@ -834,7 +835,7 @@ buildkernel: cd ${KRNLOBJDIR}/${_kernel}; \ PATH=${BPATH}:${PATH} \ MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \ - ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \ + ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \ -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case. .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules) @@ -842,7 +843,7 @@ buildkernel: cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \ PATH=${BPATH}:${PATH} \ MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \ - ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF ${target} + ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target} .endfor .endif .if !defined(NO_KERNELDEPEND) Modified: stable/9/share/mk/bsd.sys.mk ============================================================================== --- stable/9/share/mk/bsd.sys.mk Sun Jun 10 13:15:13 2012 (r236850) +++ stable/9/share/mk/bsd.sys.mk Sun Jun 10 13:28:14 2012 (r236851) @@ -61,7 +61,8 @@ CWARNFLAGS+= -Wno-uninitialized CWARNFLAGS+= -Wno-pointer-sign # Clang has more warnings enabled by default, and when using -Wall, so if WARNS # is set to low values, these have to be disabled explicitly. -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" +.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ + !defined(EARLY_BUILD) .if ${WARNS} <= 6 CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int .endif # WARNS <= 6 @@ -88,7 +89,8 @@ WFORMAT= 1 .if ${WFORMAT} > 0 #CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" +.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ + !defined(EARLY_BUILD) .if ${WARNS} <= 3 CWARNFLAGS+= -Wno-format-nonliteral .endif # WARNS <= 3 @@ -109,7 +111,8 @@ CWARNFLAGS+= -Wno-format CWARNFLAGS+= -Wno-unknown-pragmas .endif # IGNORE_PRAGMA -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" +.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ + !defined(EARLY_BUILD) CLANG_NO_IAS= -no-integrated-as CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret From owner-svn-src-stable-9@FreeBSD.ORG Sun Jun 10 19:44:09 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0DA30106564A; Sun, 10 Jun 2012 19:44:09 +0000 (UTC) (envelope-from wblock@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC7428FC12; Sun, 10 Jun 2012 19:44:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5AJi8lL017388; Sun, 10 Jun 2012 19:44:08 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5AJi8di017386; Sun, 10 Jun 2012 19:44:08 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201206101944.q5AJi8di017386@svn.freebsd.org> From: Warren Block Date: Sun, 10 Jun 2012 19:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236857 - stable/9/share/man/man4 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2012 19:44:09 -0000 Author: wblock (doc committer) Date: Sun Jun 10 19:44:08 2012 New Revision: 236857 URL: http://svn.freebsd.org/changeset/base/236857 Log: MFC r236716: Add specific supported revision of ASUS USB-N13 ver. A1. http://lists.freebsd.org/pipermail/freebsd-doc/2012-June/019960.html Submitted by: PseudoCylon (AK) Approved by: gjb (mentor) Modified: stable/9/share/man/man4/run.4 Directory Properties: stable/9/share/man/man4/ (props changed) Modified: stable/9/share/man/man4/run.4 ============================================================================== --- stable/9/share/man/man4/run.4 Sun Jun 10 19:43:32 2012 (r236856) +++ stable/9/share/man/man4/run.4 Sun Jun 10 19:44:08 2012 (r236857) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2011 +.Dd June 7, 2012 .Dt RUN 4 .Os .Sh NAME @@ -112,7 +112,7 @@ driver supports the following wireless a .Bl -tag -width Ds -offset indent -compact .It Airlink101 AWLL6090 .It ASUS USB-N11 -.It ASUS USB-N13 +.It ASUS USB-N13 ver. A1 .It ASUS WL-160N .It Belkin F5D8051 ver 3000 .It Belkin F5D8053 From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 01:38:35 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F3A951065673; Mon, 11 Jun 2012 01:38:34 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE0FF8FC16; Mon, 11 Jun 2012 01:38:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5B1cYv7033720; Mon, 11 Jun 2012 01:38:34 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5B1cYhR033718; Mon, 11 Jun 2012 01:38:34 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201206110138.q5B1cYhR033718@svn.freebsd.org> From: Kevin Lo Date: Mon, 11 Jun 2012 01:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236864 - stable/9/sys/dev/jme X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 01:38:35 -0000 Author: kevlo Date: Mon Jun 11 01:38:34 2012 New Revision: 236864 URL: http://svn.freebsd.org/changeset/base/236864 Log: MFC r236700: Fix a logic error when use PCIY_PMG capability Reviewed by: yongari Modified: stable/9/sys/dev/jme/if_jme.c Directory Properties: stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/jme/if_jme.c ============================================================================== --- stable/9/sys/dev/jme/if_jme.c Mon Jun 11 00:16:05 2012 (r236863) +++ stable/9/sys/dev/jme/if_jme.c Mon Jun 11 01:38:34 2012 (r236864) @@ -1661,7 +1661,7 @@ jme_resume(device_t dev) sc = device_get_softc(dev); JME_LOCK(sc); - if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) != 0) { + if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) == 0) { pmstat = pci_read_config(sc->jme_dev, pmc + PCIR_POWER_STATUS, 2); /* Disable PME clear PME status. */ From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 01:44:17 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D4B31065672; Mon, 11 Jun 2012 01:44:17 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 879548FC08; Mon, 11 Jun 2012 01:44:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5B1iHqs034042; Mon, 11 Jun 2012 01:44:17 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5B1iH1m034040; Mon, 11 Jun 2012 01:44:17 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201206110144.q5B1iH1m034040@svn.freebsd.org> From: Kevin Lo Date: Mon, 11 Jun 2012 01:44:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236865 - stable/9/sys/dev/ae X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 01:44:17 -0000 Author: kevlo Date: Mon Jun 11 01:44:17 2012 New Revision: 236865 URL: http://svn.freebsd.org/changeset/base/236865 Log: MFC r236649,236670: Check the return value of pci_find_cap() Modified: stable/9/sys/dev/ae/if_ae.c Directory Properties: stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/ae/if_ae.c ============================================================================== --- stable/9/sys/dev/ae/if_ae.c Mon Jun 11 01:38:34 2012 (r236864) +++ stable/9/sys/dev/ae/if_ae.c Mon Jun 11 01:44:17 2012 (r236865) @@ -1381,12 +1381,13 @@ ae_pm_init(ae_softc_t *sc) /* * Configure PME. */ - pci_find_cap(sc->dev, PCIY_PMG, &pmc); - pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); - pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); - if ((ifp->if_capenable & IFCAP_WOL) != 0) - pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; - pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); + if (pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0) { + pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); + pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); + if ((ifp->if_capenable & IFCAP_WOL) != 0) + pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; + pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); + } } static int From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 07:11:35 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4CA7F106566B; Mon, 11 Jun 2012 07:11:35 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1CB498FC08; Mon, 11 Jun 2012 07:11:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5B7BYSl049452; Mon, 11 Jun 2012 07:11:34 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5B7BYWn049449; Mon, 11 Jun 2012 07:11:34 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206110711.q5B7BYWn049449@svn.freebsd.org> From: Xin LI Date: Mon, 11 Jun 2012 07:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236875 - in stable: 7/usr.sbin/inetd 8/usr.sbin/inetd 9/usr.sbin/inetd X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 07:11:35 -0000 Author: delphij Date: Mon Jun 11 07:11:34 2012 New Revision: 236875 URL: http://svn.freebsd.org/changeset/base/236875 Log: MFC r236572: Replace the use of wall clock time with monotonically increasing clock. In general, gettimeofday() is not appropriate interface when accounting for elasped time because it can go backward, in which case the policy code could errornously consider the limit as exceeded. Reported by: Mahesh Arumugam Submitted by: Dorr H. Clark via gnn Sponsored by: Citrix / NetScaler Modified: stable/9/usr.sbin/inetd/inetd.c stable/9/usr.sbin/inetd/inetd.h Directory Properties: stable/9/usr.sbin/inetd/ (props changed) Changes in other areas also in this revision: Modified: stable/7/usr.sbin/inetd/inetd.c stable/7/usr.sbin/inetd/inetd.h stable/8/usr.sbin/inetd/inetd.c stable/8/usr.sbin/inetd/inetd.h Directory Properties: stable/7/usr.sbin/inetd/ (props changed) stable/8/usr.sbin/inetd/ (props changed) Modified: stable/9/usr.sbin/inetd/inetd.c ============================================================================== --- stable/9/usr.sbin/inetd/inetd.c Mon Jun 11 07:08:40 2012 (r236874) +++ stable/9/usr.sbin/inetd/inetd.c Mon Jun 11 07:11:34 2012 (r236875) @@ -688,11 +688,11 @@ main(int argc, char **argv) */ if (dofork) { if (sep->se_count++ == 0) - (void)gettimeofday(&sep->se_time, (struct timezone *)NULL); + (void)clock_gettime(CLOCK_MONOTONIC_FAST, &sep->se_time); else if (toomany > 0 && sep->se_count >= toomany) { - struct timeval now; + struct timespec now; - (void)gettimeofday(&now, (struct timezone *)NULL); + (void)clock_gettime(CLOCK_MONOTONIC_FAST, &now); if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) { sep->se_time = now; Modified: stable/9/usr.sbin/inetd/inetd.h ============================================================================== --- stable/9/usr.sbin/inetd/inetd.h Mon Jun 11 07:08:40 2012 (r236874) +++ stable/9/usr.sbin/inetd/inetd.h Mon Jun 11 07:11:34 2012 (r236875) @@ -109,7 +109,7 @@ struct servtab { u_int se_rpc_lowvers; /* RPC low version */ u_int se_rpc_highvers; /* RPC high version */ int se_count; /* number started since se_time */ - struct timeval se_time; /* start of se_count */ + struct timespec se_time; /* start of se_count */ struct servtab *se_next; struct se_flags { u_int se_nomapped : 1; From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 11:59:30 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5E5011065673; Mon, 11 Jun 2012 11:59:30 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4837F8FC18; Mon, 11 Jun 2012 11:59:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BBxUo1083028; Mon, 11 Jun 2012 11:59:30 GMT (envelope-from ache@svn.freebsd.org) Received: (from ache@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BBxUw2083026; Mon, 11 Jun 2012 11:59:30 GMT (envelope-from ache@svn.freebsd.org) Message-Id: <201206111159.q5BBxUw2083026@svn.freebsd.org> From: "Andrey A. Chernov" Date: Mon, 11 Jun 2012 11:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236885 - stable/9/lib/libc/stdlib X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 11:59:30 -0000 Author: ache Date: Mon Jun 11 11:59:29 2012 New Revision: 236885 URL: http://svn.freebsd.org/changeset/base/236885 Log: MFC 236582,236618 - remove unused serrno variable Modified: stable/9/lib/libc/stdlib/realpath.c (contents, props changed) Modified: stable/9/lib/libc/stdlib/realpath.c ============================================================================== --- stable/9/lib/libc/stdlib/realpath.c Mon Jun 11 11:35:22 2012 (r236884) +++ stable/9/lib/libc/stdlib/realpath.c Mon Jun 11 11:59:29 2012 (r236885) @@ -54,7 +54,7 @@ realpath(const char * __restrict path, c char *p, *q, *s; size_t left_len, resolved_len; unsigned symlinks; - int m, serrno, slen; + int m, slen; char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX]; if (path == NULL) { @@ -65,7 +65,6 @@ realpath(const char * __restrict path, c errno = ENOENT; return (NULL); } - serrno = errno; if (resolved == NULL) { resolved = malloc(PATH_MAX); if (resolved == NULL) From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 12:34:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5938B1065748; Mon, 11 Jun 2012 12:34:15 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A8EA8FC17; Mon, 11 Jun 2012 12:34:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BCYFGZ084580; Mon, 11 Jun 2012 12:34:15 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BCYFGj084578; Mon, 11 Jun 2012 12:34:15 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201206111234.q5BCYFGj084578@svn.freebsd.org> From: Rick Macklem Date: Mon, 11 Jun 2012 12:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236887 - stable/9/sys/fs/nfsserver X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 12:34:15 -0000 Author: rmacklem Date: Mon Jun 11 12:34:14 2012 New Revision: 236887 URL: http://svn.freebsd.org/changeset/base/236887 Log: MFC: r235381 Fix two cases in the new NFS server where a tsleep() is used, when the code should actually protect the tested variable with a mutex. Since the tsleep()s had a 10sec timeout, the race would have only delayed the allocation of a new clientid for a client. The sleeps will also rarely occur, since having a callback in progress when a client acquires a new clientid, is unlikely. in practice, since having a callback in progress when a fresh clientid is being acquired by a client is unlikely. Modified: stable/9/sys/fs/nfsserver/nfs_nfsdstate.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- stable/9/sys/fs/nfsserver/nfs_nfsdstate.c Mon Jun 11 12:26:23 2012 (r236886) +++ stable/9/sys/fs/nfsserver/nfs_nfsdstate.c Mon Jun 11 12:34:14 2012 (r236887) @@ -331,11 +331,13 @@ nfsrv_setclient(struct nfsrv_descript *n * Must wait until any outstanding callback on the old clp * completes. */ + NFSLOCKSTATE(); while (clp->lc_cbref) { clp->lc_flags |= LCL_WAKEUPWANTED; - (void) tsleep((caddr_t)clp, PZERO - 1, + (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1, "nfsd clp", 10 * hz); } + NFSUNLOCKSTATE(); nfsrv_zapclient(clp, p); *new_clpp = NULL; goto out; @@ -385,10 +387,13 @@ nfsrv_setclient(struct nfsrv_descript *n * Must wait until any outstanding callback on the old clp * completes. */ + NFSLOCKSTATE(); while (clp->lc_cbref) { clp->lc_flags |= LCL_WAKEUPWANTED; - (void) tsleep((caddr_t)clp, PZERO - 1, "nfsd clp", 10 * hz); + (void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1, "nfsd clp", + 10 * hz); } + NFSUNLOCKSTATE(); nfsrv_zapclient(clp, p); *new_clpp = NULL; @@ -3816,11 +3821,9 @@ nfsrv_docallback(struct nfsclient *clp, clp->lc_cbref--; if ((clp->lc_flags & LCL_WAKEUPWANTED) && clp->lc_cbref == 0) { clp->lc_flags &= ~LCL_WAKEUPWANTED; - NFSUNLOCKSTATE(); - wakeup((caddr_t)clp); - } else { - NFSUNLOCKSTATE(); + wakeup(clp); } + NFSUNLOCKSTATE(); NFSEXITCODE(error); return (error); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 17:18:31 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E5A771065670; Mon, 11 Jun 2012 17:18:31 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B5F098FC1B; Mon, 11 Jun 2012 17:18:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BHIV8B098288; Mon, 11 Jun 2012 17:18:31 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BHIVev098285; Mon, 11 Jun 2012 17:18:31 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201206111718.q5BHIVev098285@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 11 Jun 2012 17:18:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236895 - stable/9/sys/dev/usb X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 17:18:32 -0000 Author: hselasky Date: Mon Jun 11 17:18:31 2012 New Revision: 236895 URL: http://svn.freebsd.org/changeset/base/236895 Log: MFC r236407: Improve support for detaching kernel drivers on a per interface basis. Modified: stable/9/sys/dev/usb/usb_device.c stable/9/sys/dev/usb/usb_generic.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usb_device.c ============================================================================== --- stable/9/sys/dev/usb/usb_device.c Mon Jun 11 17:17:28 2012 (r236894) +++ stable/9/sys/dev/usb/usb_device.c Mon Jun 11 17:18:31 2012 (r236895) @@ -750,10 +750,13 @@ usb_config_parse(struct usb_device *udev if (do_init) { /* setup the USB interface structure */ iface->idesc = id; - /* default setting */ - iface->parent_iface_index = USB_IFACE_INDEX_ANY; /* set alternate index */ iface->alt_index = alt_index; + /* set default interface parent */ + if (iface_index == USB_IFACE_INDEX_ANY) { + iface->parent_iface_index = + USB_IFACE_INDEX_ANY; + } } DPRINTFN(5, "found idesc nendpt=%d\n", id->bNumEndpoints); @@ -1229,10 +1232,13 @@ usbd_set_parent_iface(struct usb_device { struct usb_interface *iface; + if (udev == NULL) { + /* nothing to do */ + return; + } iface = usbd_get_iface(udev, iface_index); - if (iface) { + if (iface != NULL) iface->parent_iface_index = parent_index; - } } static void Modified: stable/9/sys/dev/usb/usb_generic.c ============================================================================== --- stable/9/sys/dev/usb/usb_generic.c Mon Jun 11 17:17:28 2012 (r236894) +++ stable/9/sys/dev/usb/usb_generic.c Mon Jun 11 17:18:31 2012 (r236895) @@ -2166,7 +2166,16 @@ ugen_ioctl_post(struct usb_fifo *f, u_lo break; } + /* + * Detach the currently attached driver. + */ usb_detach_device(f->udev, n, 0); + + /* + * Set parent to self, this should keep attach away + * until the next set configuration event. + */ + usbd_set_parent_iface(f->udev, n, n); break; case USB_SET_POWER_MODE: From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 17:23:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 81AC41065672; Mon, 11 Jun 2012 17:23:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B9048FC17; Mon, 11 Jun 2012 17:23:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BHNPsG098601; Mon, 11 Jun 2012 17:23:25 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BHNPf3098597; Mon, 11 Jun 2012 17:23:25 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201206111723.q5BHNPf3098597@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 11 Jun 2012 17:23:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236897 - stable/9/sys/dev/usb/wlan X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 17:23:25 -0000 Author: hselasky Date: Mon Jun 11 17:23:24 2012 New Revision: 236897 URL: http://svn.freebsd.org/changeset/base/236897 Log: MFC r236439: Add appropriate checks for ic_bsschan being set to IEEE80211_CHAN_ANYC in some of the USB WLAN drivers. This fixes a panic when using monitor mode. Modified: stable/9/sys/dev/usb/wlan/if_rum.c stable/9/sys/dev/usb/wlan/if_run.c stable/9/sys/dev/usb/wlan/if_ural.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/wlan/if_rum.c ============================================================================== --- stable/9/sys/dev/usb/wlan/if_rum.c Mon Jun 11 17:22:27 2012 (r236896) +++ stable/9/sys/dev/usb/wlan/if_rum.c Mon Jun 11 17:23:24 2012 (r236897) @@ -726,6 +726,12 @@ rum_newstate(struct ieee80211vap *vap, e ni = ieee80211_ref_node(vap->iv_bss); if (vap->iv_opmode != IEEE80211_M_MONITOR) { + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { + RUM_UNLOCK(sc); + IEEE80211_LOCK(ic); + ieee80211_free_node(ni); + return (-1); + } rum_update_slot(ic->ic_ifp); rum_enable_mrr(sc); rum_set_txpreamble(sc); @@ -2135,11 +2141,12 @@ rum_prepare_beacon(struct rum_softc *sc, if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC) return; + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) + return; m0 = ieee80211_beacon_alloc(vap->iv_bss, &RUM_VAP(vap)->bo); - if (m0 == NULL) { + if (m0 == NULL) return; - } tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_bsschan)]; rum_setup_tx_desc(sc, &desc, RT2573_TX_TIMESTAMP, RT2573_TX_HWSEQ, Modified: stable/9/sys/dev/usb/wlan/if_run.c ============================================================================== --- stable/9/sys/dev/usb/wlan/if_run.c Mon Jun 11 17:22:27 2012 (r236896) +++ stable/9/sys/dev/usb/wlan/if_run.c Mon Jun 11 17:23:24 2012 (r236897) @@ -1830,6 +1830,11 @@ run_newstate(struct ieee80211vap *vap, e if (vap->iv_opmode != IEEE80211_M_MONITOR) { struct ieee80211_node *ni; + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { + RUN_UNLOCK(sc); + IEEE80211_LOCK(ic); + return (-1); + } run_updateslot(ic->ic_ifp); run_enable_mrr(sc); run_set_txpreamble(sc); @@ -2523,8 +2528,8 @@ run_rx_frame(struct run_softc *sc, struc struct run_rx_radiotap_header *tap = &sc->sc_rxtap; tap->wr_flags = 0; - tap->wr_chan_freq = htole16(ic->ic_bsschan->ic_freq); - tap->wr_chan_flags = htole16(ic->ic_bsschan->ic_flags); + tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); tap->wr_antsignal = rssi; tap->wr_antenna = ant; tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); @@ -2778,8 +2783,8 @@ tr_setup: tap->wt_flags = 0; tap->wt_rate = rt2860_rates[data->ridx].rate; - tap->wt_chan_freq = htole16(vap->iv_bss->ni_chan->ic_freq); - tap->wt_chan_flags = htole16(vap->iv_bss->ni_chan->ic_flags); + tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags); tap->wt_hwqueue = index; if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; @@ -3967,6 +3972,8 @@ run_update_beacon_cb(void *arg) if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC) return; + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) + return; /* * No need to call ieee80211_beacon_update(), run_update_beacon() Modified: stable/9/sys/dev/usb/wlan/if_ural.c ============================================================================== --- stable/9/sys/dev/usb/wlan/if_ural.c Mon Jun 11 17:22:27 2012 (r236896) +++ stable/9/sys/dev/usb/wlan/if_ural.c Mon Jun 11 17:23:24 2012 (r236897) @@ -713,6 +713,12 @@ ural_newstate(struct ieee80211vap *vap, ni = ieee80211_ref_node(vap->iv_bss); if (vap->iv_opmode != IEEE80211_M_MONITOR) { + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { + RAL_UNLOCK(sc); + IEEE80211_LOCK(ic); + ieee80211_free_node(ni); + return (-1); + } ural_update_slot(ic->ic_ifp); ural_set_txpreamble(sc); ural_set_basicrates(sc, ic->ic_bsschan); @@ -1054,7 +1060,12 @@ ural_tx_bcn(struct ural_softc *sc, struc ifp->if_drv_flags |= IFF_DRV_OACTIVE; m_freem(m0); ieee80211_free_node(ni); - return EIO; + return (EIO); + } + if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { + m_freem(m0); + ieee80211_free_node(ni); + return (ENXIO); } data = STAILQ_FIRST(&sc->tx_free); STAILQ_REMOVE_HEAD(&sc->tx_free, next); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 17:27:54 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9426D106566C; Mon, 11 Jun 2012 17:27:54 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7583D8FC17; Mon, 11 Jun 2012 17:27:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BHRsqC098845; Mon, 11 Jun 2012 17:27:54 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BHRsSc098841; Mon, 11 Jun 2012 17:27:54 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201206111727.q5BHRsSc098841@svn.freebsd.org> From: Hans Petter Selasky Date: Mon, 11 Jun 2012 17:27:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236898 - stable/9/sys/dev/usb X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 17:27:54 -0000 Author: hselasky Date: Mon Jun 11 17:27:53 2012 New Revision: 236898 URL: http://svn.freebsd.org/changeset/base/236898 Log: MFC r233771: Add definitions and structures for USB 2.0 Link Power Management, LPM. Modified: stable/9/sys/dev/usb/usb.h stable/9/sys/dev/usb/usb_request.c stable/9/sys/dev/usb/usb_request.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/usb.h ============================================================================== --- stable/9/sys/dev/usb/usb.h Mon Jun 11 17:23:24 2012 (r236897) +++ stable/9/sys/dev/usb/usb.h Mon Jun 11 17:27:53 2012 (r236898) @@ -225,7 +225,8 @@ typedef struct usb_device_request usb_de #define UR_RESET_TT 0x09 #define UR_GET_TT_STATE 0x0a #define UR_STOP_TT 0x0b -#define UR_SET_HUB_DEPTH 0x0c +#define UR_SET_AND_TEST 0x0c /* USB 2.0 only */ +#define UR_SET_HUB_DEPTH 0x0c /* USB 3.0 only */ #define USB_SS_HUB_DEPTH_MAX 5 #define UR_GET_PORT_ERR_COUNT 0x0d @@ -248,6 +249,7 @@ typedef struct usb_device_request usb_de #define UHF_PORT_LINK_STATE 5 #define UHF_PORT_POWER 8 #define UHF_PORT_LOW_SPEED 9 +#define UHF_PORT_L1 10 #define UHF_C_PORT_CONNECTION 16 #define UHF_C_PORT_ENABLE 17 #define UHF_C_PORT_SUSPEND 18 @@ -255,6 +257,7 @@ typedef struct usb_device_request usb_de #define UHF_C_PORT_RESET 20 #define UHF_PORT_TEST 21 #define UHF_PORT_INDICATOR 22 +#define UHF_C_PORT_L1 23 /* SuperSpeed HUB specific features */ #define UHF_PORT_U1_TIMEOUT 23 @@ -324,7 +327,12 @@ struct usb_devcap_usb2ext_descriptor { uByte bDescriptorType; uByte bDevCapabilityType; uDWord bmAttributes; -#define USB_V2EXT_LPM 0x02 +#define USB_V2EXT_LPM (1U << 1) +#define USB_V2EXT_BESL_SUPPORTED (1U << 2) +#define USB_V2EXT_BESL_BASELINE_VALID (1U << 3) +#define USB_V2EXT_BESL_DEEP_VALID (1U << 4) +#define USB_V2EXT_BESL_BASELINE_GET(x) (((x) >> 8) & 0xF) +#define USB_V2EXT_BESL_DEEP_GET(x) (((x) >> 12) & 0xF) } __packed; typedef struct usb_devcap_usb2ext_descriptor usb_devcap_usb2ext_descriptor_t; @@ -671,6 +679,7 @@ struct usb_port_status { #define UPS_SUSPEND 0x0004 #define UPS_OVERCURRENT_INDICATOR 0x0008 #define UPS_RESET 0x0010 +#define UPS_PORT_L1 0x0020 /* USB 2.0 only */ /* The link-state bits are valid for Super-Speed USB HUBs */ #define UPS_PORT_LINK_STATE_GET(x) (((x) >> 5) & 0xF) #define UPS_PORT_LINK_STATE_SET(x) (((x) & 0xF) << 5) @@ -701,7 +710,8 @@ struct usb_port_status { #define UPS_C_SUSPEND 0x0004 #define UPS_C_OVERCURRENT_INDICATOR 0x0008 #define UPS_C_PORT_RESET 0x0010 -#define UPS_C_BH_PORT_RESET 0x0020 +#define UPS_C_PORT_L1 0x0020 /* USB 2.0 only */ +#define UPS_C_BH_PORT_RESET 0x0020 /* USB 3.0 only */ #define UPS_C_PORT_LINK_STATE 0x0040 #define UPS_C_PORT_CONFIG_ERROR 0x0080 } __packed; Modified: stable/9/sys/dev/usb/usb_request.c ============================================================================== --- stable/9/sys/dev/usb/usb_request.c Mon Jun 11 17:23:24 2012 (r236897) +++ stable/9/sys/dev/usb/usb_request.c Mon Jun 11 17:27:53 2012 (r236898) @@ -2226,3 +2226,57 @@ usbd_req_set_port_link_state(struct usb_ USETW(req.wLength, 0); return (usbd_do_request(udev, mtx, &req, 0)); } + +/*------------------------------------------------------------------------* + * usbd_req_set_lpm_info + * + * USB 2.0 specific request for Link Power Management. + * + * Returns: + * 0: Success + * USB_ERR_PENDING_REQUESTS: NYET + * USB_ERR_TIMEOUT: TIMEOUT + * USB_ERR_STALL: STALL + * Else: Failure + *------------------------------------------------------------------------*/ +usb_error_t +usbd_req_set_lpm_info(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t besl, uint8_t addr, uint8_t rwe) +{ + struct usb_device_request req; + usb_error_t err; + uint8_t buf[1]; + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_SET_AND_TEST; + USETW(req.wValue, UHF_PORT_L1); + req.wIndex[0] = (port & 0xF) | ((besl & 0xF) << 4); + req.wIndex[1] = (addr & 0x7F) | (rwe ? 0x80 : 0x00); + USETW(req.wLength, sizeof(buf)); + + /* set default value in case of short transfer */ + buf[0] = 0x00; + + err = usbd_do_request(udev, mtx, &req, buf); + if (err) + return (err); + + switch (buf[0]) { + case 0x00: /* SUCCESS */ + break; + case 0x10: /* NYET */ + err = USB_ERR_PENDING_REQUESTS; + break; + case 0x11: /* TIMEOUT */ + err = USB_ERR_TIMEOUT; + break; + case 0x30: /* STALL */ + err = USB_ERR_STALLED; + break; + default: /* reserved */ + err = USB_ERR_IOERROR; + break; + } + return (err); +} + Modified: stable/9/sys/dev/usb/usb_request.h ============================================================================== --- stable/9/sys/dev/usb/usb_request.h Mon Jun 11 17:23:24 2012 (r236897) +++ stable/9/sys/dev/usb/usb_request.h Mon Jun 11 17:27:53 2012 (r236898) @@ -91,5 +91,7 @@ usb_error_t usbd_req_clear_tt_buffer(str uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint); usb_error_t usbd_req_set_port_link_state(struct usb_device *udev, struct mtx *mtx, uint8_t port, uint8_t link_state); +usb_error_t usbd_req_set_lpm_info(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t besl, uint8_t addr, uint8_t rwe); #endif /* _USB_REQUEST_H_ */ From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 17:54:41 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 359801065687; Mon, 11 Jun 2012 17:54:41 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1FD4A8FC0A; Mon, 11 Jun 2012 17:54:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BHseKI000983; Mon, 11 Jun 2012 17:54:40 GMT (envelope-from mjg@svn.freebsd.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BHseTd000979; Mon, 11 Jun 2012 17:54:40 GMT (envelope-from mjg@svn.freebsd.org) Message-Id: <201206111754.q5BHseTd000979@svn.freebsd.org> From: Mateusz Guzik Date: Mon, 11 Jun 2012 17:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236900 - stable/9/sys/kern X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 17:54:41 -0000 Author: mjg Date: Mon Jun 11 17:54:40 2012 New Revision: 236900 URL: http://svn.freebsd.org/changeset/base/236900 Log: MFC r236738: Plug socket refcount leak on error in sys_sctp_peeloff. Modified: stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Mon Jun 11 17:42:39 2012 (r236899) +++ stable/9/sys/kern/uipc_syscalls.c Mon Jun 11 17:54:40 2012 (r236900) @@ -2323,11 +2323,11 @@ sys_sctp_peeloff(td, uap) goto done2; if (head->so_proto->pr_protocol != IPPROTO_SCTP) { error = EOPNOTSUPP; - goto done2; + goto done; } error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name); if (error) - goto done2; + goto done; /* * At this point we know we do have a assoc to pull * we proceed to get the fd setup. This may block From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 20:58:24 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74E22106564A; Mon, 11 Jun 2012 20:58:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F3868FC12; Mon, 11 Jun 2012 20:58:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BKwO8G009583; Mon, 11 Jun 2012 20:58:24 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BKwO5R009580; Mon, 11 Jun 2012 20:58:24 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112058.q5BKwO5R009580@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 20:58:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236920 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 20:58:24 -0000 Author: kib Date: Mon Jun 11 20:58:23 2012 New Revision: 236920 URL: http://svn.freebsd.org/changeset/base/236920 Log: MFC r235356: Make the vm_page_array_size long. Remove redundand zero initialization for vm_page_array_size and nearby variables. MFC r235359: Commit the change forgotten in r235356. Modified: stable/9/sys/vm/vm_page.c stable/9/sys/vm/vm_page.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_page.c ============================================================================== --- stable/9/sys/vm/vm_page.c Mon Jun 11 20:27:52 2012 (r236919) +++ stable/9/sys/vm/vm_page.c Mon Jun 11 20:58:23 2012 (r236920) @@ -121,10 +121,10 @@ struct vpglocks vm_page_queue_free_lock; struct vpglocks pa_lock[PA_LOCK_COUNT]; -vm_page_t vm_page_array = 0; -int vm_page_array_size = 0; -long first_page = 0; -int vm_page_zero_count = 0; +vm_page_t vm_page_array; +long vm_page_array_size; +long first_page; +int vm_page_zero_count; static int boot_pages = UMA_BOOT_PAGES; TUNABLE_INT("vm.boot_pages", &boot_pages); Modified: stable/9/sys/vm/vm_page.h ============================================================================== --- stable/9/sys/vm/vm_page.h Mon Jun 11 20:27:52 2012 (r236919) +++ stable/9/sys/vm/vm_page.h Mon Jun 11 20:58:23 2012 (r236920) @@ -312,7 +312,7 @@ struct vnode; extern int vm_page_zero_count; extern vm_page_t vm_page_array; /* First resident page in table */ -extern int vm_page_array_size; /* number of vm_page_t's */ +extern long vm_page_array_size; /* number of vm_page_t's */ extern long first_page; /* first physical page number */ #define VM_PAGE_IS_FREE(m) (((m)->flags & PG_FREE) != 0) From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:06:11 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14C9A1065670; Mon, 11 Jun 2012 21:06:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F38168FC1F; Mon, 11 Jun 2012 21:06:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BL6An5009989; Mon, 11 Jun 2012 21:06:10 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BL6ApP009987; Mon, 11 Jun 2012 21:06:10 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112106.q5BL6ApP009987@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:06:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236921 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:06:11 -0000 Author: kib Date: Mon Jun 11 21:06:10 2012 New Revision: 236921 URL: http://svn.freebsd.org/changeset/base/236921 Log: MFC r235362: Assert that fictitious or unmanaged pages do not appear on active/inactive lists. Modified: stable/9/sys/vm/vm_pageout.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_pageout.c ============================================================================== --- stable/9/sys/vm/vm_pageout.c Mon Jun 11 20:58:23 2012 (r236920) +++ stable/9/sys/vm/vm_pageout.c Mon Jun 11 21:06:10 2012 (r236921) @@ -805,6 +805,11 @@ rescan0: if (m->flags & PG_MARKER) continue; + KASSERT((m->flags & PG_FICTITIOUS) == 0, + ("Fictitious page %p cannot be in inactive queue", m)); + KASSERT((m->oflags & VPO_UNMANAGED) == 0, + ("Unmanaged page %p cannot be in inactive queue", m)); + /* * Lock the page. */ @@ -1143,6 +1148,10 @@ unlock_and_continue: m = next; continue; } + KASSERT((m->flags & PG_FICTITIOUS) == 0, + ("Fictitious page %p cannot be in active queue", m)); + KASSERT((m->oflags & VPO_UNMANAGED) == 0, + ("Unmanaged page %p cannot be in active queue", m)); if (!vm_pageout_page_lock(m, &next)) { vm_page_unlock(m); m = next; From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:08:53 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 750DD1065670; Mon, 11 Jun 2012 21:08:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5FE318FC08; Mon, 11 Jun 2012 21:08:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BL8rqT010147; Mon, 11 Jun 2012 21:08:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BL8ruU010145; Mon, 11 Jun 2012 21:08:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112108.q5BL8ruU010145@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:08:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236922 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:08:53 -0000 Author: kib Date: Mon Jun 11 21:08:52 2012 New Revision: 236922 URL: http://svn.freebsd.org/changeset/base/236922 Log: MFC r235365: Assert that the page passed to vm_page_putfake() is unmanaged. Modified: stable/9/sys/vm/vm_page.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_page.c ============================================================================== --- stable/9/sys/vm/vm_page.c Mon Jun 11 21:06:10 2012 (r236921) +++ stable/9/sys/vm/vm_page.c Mon Jun 11 21:08:52 2012 (r236922) @@ -665,6 +665,7 @@ void vm_page_putfake(vm_page_t m) { + KASSERT((m->oflags & VPO_UNMANAGED) != 0, ("managed %p", m)); KASSERT((m->flags & PG_FICTITIOUS) != 0, ("vm_page_putfake: bad page %p", m)); uma_zfree(fakepg_zone, m); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:12:53 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07F6A1065670; Mon, 11 Jun 2012 21:12:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB2428FC22; Mon, 11 Jun 2012 21:12:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLCqlk010379; Mon, 11 Jun 2012 21:12:52 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLCqWu010376; Mon, 11 Jun 2012 21:12:52 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112112.q5BLCqWu010376@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:12:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236923 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:12:53 -0000 Author: kib Date: Mon Jun 11 21:12:52 2012 New Revision: 236923 URL: http://svn.freebsd.org/changeset/base/236923 Log: MFC r235366: Split the code from vm_page_getfake() to initialize the fake page struct vm_page into new interface vm_page_initfake(). Handle the case of fake page re-initialization with changed memattr. Modified: stable/9/sys/vm/vm_page.c stable/9/sys/vm/vm_page.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_page.c ============================================================================== --- stable/9/sys/vm/vm_page.c Mon Jun 11 21:08:52 2012 (r236922) +++ stable/9/sys/vm/vm_page.c Mon Jun 11 21:12:52 2012 (r236923) @@ -645,6 +645,22 @@ vm_page_getfake(vm_paddr_t paddr, vm_mem vm_page_t m; m = uma_zalloc(fakepg_zone, M_WAITOK | M_ZERO); + vm_page_initfake(m, paddr, memattr); + return (m); +} + +void +vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr) +{ + + if ((m->flags & PG_FICTITIOUS) != 0) { + /* + * The page's memattr might have changed since the + * previous initialization. Update the pmap to the + * new memattr. + */ + goto memattr; + } m->phys_addr = paddr; m->queue = PQ_NONE; /* Fictitious pages don't use "segind". */ @@ -652,8 +668,8 @@ vm_page_getfake(vm_paddr_t paddr, vm_mem /* Fictitious pages don't use "order" or "pool". */ m->oflags = VPO_BUSY | VPO_UNMANAGED; m->wire_count = 1; +memattr: pmap_page_set_memattr(m, memattr); - return (m); } /* Modified: stable/9/sys/vm/vm_page.h ============================================================================== --- stable/9/sys/vm/vm_page.h Mon Jun 11 21:08:52 2012 (r236922) +++ stable/9/sys/vm/vm_page.h Mon Jun 11 21:12:52 2012 (r236923) @@ -390,6 +390,7 @@ void vm_page_dontneed(vm_page_t); void vm_page_deactivate (vm_page_t); vm_page_t vm_page_find_least(vm_object_t, vm_pindex_t); vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr); +void vm_page_initfake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t memattr); void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t); boolean_t vm_page_is_cached(vm_object_t object, vm_pindex_t pindex); vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:20:01 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C1472106564A; Mon, 11 Jun 2012 21:20:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A58018FC17; Mon, 11 Jun 2012 21:20:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLK0vG010736; Mon, 11 Jun 2012 21:20:00 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLK0SD010731; Mon, 11 Jun 2012 21:20:00 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112120.q5BLK0SD010731@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:20:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236924 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:20:01 -0000 Author: kib Date: Mon Jun 11 21:19:59 2012 New Revision: 236924 URL: http://svn.freebsd.org/changeset/base/236924 Log: MFC r235372: Add a facility to register a range of physical addresses to be used for allocation of fictitious pages, for which PHYS_TO_VM_PAGE() returns proper fictitious vm_page_t. The range should be de-registered after consumer stopped using it. De-inline the PHYS_TO_VM_PAGE() since it now carries code to iterate over registered ranges. MFC r235776 (by andrew): In PHYS_TO_VM_PAGE() when VM_PHYSSEG_DENSE is set the check if we are past the end of vm_page_array was incorrect causing it to return NULL. This value is then used in vm_phys_add_page causing a data abort. Modified: stable/9/sys/vm/vm_page.c stable/9/sys/vm/vm_page.h stable/9/sys/vm/vm_phys.c stable/9/sys/vm/vm_phys.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_page.c ============================================================================== --- stable/9/sys/vm/vm_page.c Mon Jun 11 21:12:52 2012 (r236923) +++ stable/9/sys/vm/vm_page.c Mon Jun 11 21:19:59 2012 (r236924) @@ -632,6 +632,30 @@ vm_page_unhold_pages(vm_page_t *ma, int mtx_unlock(mtx); } +vm_page_t +PHYS_TO_VM_PAGE(vm_paddr_t pa) +{ + vm_page_t m; + +#ifdef VM_PHYSSEG_SPARSE + m = vm_phys_paddr_to_vm_page(pa); + if (m == NULL) + m = vm_phys_fictitious_to_vm_page(pa); + return (m); +#elif defined(VM_PHYSSEG_DENSE) + long pi; + + pi = atop(pa); + if (pi >= first_page && (pi - first_page) < vm_page_array_size) { + m = &vm_page_array[pi - first_page]; + return (m); + } + return (vm_phys_fictitious_to_vm_page(pa)); +#else +#error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined." +#endif +} + /* * vm_page_getfake: * Modified: stable/9/sys/vm/vm_page.h ============================================================================== --- stable/9/sys/vm/vm_page.h Mon Jun 11 21:12:52 2012 (r236923) +++ stable/9/sys/vm/vm_page.h Mon Jun 11 21:19:59 2012 (r236924) @@ -321,19 +321,7 @@ extern long first_page; /* first physi vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa); -static __inline vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); - -static __inline vm_page_t -PHYS_TO_VM_PAGE(vm_paddr_t pa) -{ -#ifdef VM_PHYSSEG_SPARSE - return (vm_phys_paddr_to_vm_page(pa)); -#elif defined(VM_PHYSSEG_DENSE) - return (&vm_page_array[atop(pa) - first_page]); -#else -#error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined." -#endif -} +vm_page_t PHYS_TO_VM_PAGE(vm_paddr_t pa); extern struct vpglocks vm_page_queue_lock; Modified: stable/9/sys/vm/vm_phys.c ============================================================================== --- stable/9/sys/vm/vm_phys.c Mon Jun 11 21:12:52 2012 (r236923) +++ stable/9/sys/vm/vm_phys.c Mon Jun 11 21:19:59 2012 (r236924) @@ -83,6 +83,15 @@ static struct vm_phys_seg vm_phys_segs[V static int vm_phys_nsegs; +#define VM_PHYS_FICTITIOUS_NSEGS 8 +static struct vm_phys_fictitious_seg { + vm_paddr_t start; + vm_paddr_t end; + vm_page_t first_page; +} vm_phys_fictitious_segs[VM_PHYS_FICTITIOUS_NSEGS]; +static struct mtx vm_phys_fictitious_reg_mtx; +MALLOC_DEFINE(M_FICT_PAGES, "", ""); + static struct vm_freelist vm_phys_free_queues[VM_RAW_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER]; static struct vm_freelist @@ -362,6 +371,8 @@ vm_phys_init(void) for (flind = 0; flind < vm_nfreelists; flind++) vm_phys_lookup_lists[0][flind] = &vm_phys_free_queues[flind]; #endif + + mtx_init(&vm_phys_fictitious_reg_mtx, "vmfctr", NULL, MTX_DEF); } /* @@ -526,6 +537,112 @@ vm_phys_paddr_to_vm_page(vm_paddr_t pa) return (NULL); } +vm_page_t +vm_phys_fictitious_to_vm_page(vm_paddr_t pa) +{ + struct vm_phys_fictitious_seg *seg; + vm_page_t m; + int segind; + + m = NULL; + for (segind = 0; segind < VM_PHYS_FICTITIOUS_NSEGS; segind++) { + seg = &vm_phys_fictitious_segs[segind]; + if (pa >= seg->start && pa < seg->end) { + m = &seg->first_page[atop(pa - seg->start)]; + KASSERT((m->flags & PG_FICTITIOUS) != 0, + ("%p not fictitious", m)); + break; + } + } + return (m); +} + +int +vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, + vm_memattr_t memattr) +{ + struct vm_phys_fictitious_seg *seg; + vm_page_t fp; + long i, page_count; + int segind; +#ifdef VM_PHYSSEG_DENSE + long pi; + boolean_t malloced; +#endif + + page_count = (end - start) / PAGE_SIZE; + +#ifdef VM_PHYSSEG_DENSE + pi = atop(start); + if (pi >= first_page && atop(end) < vm_page_array_size) { + fp = &vm_page_array[pi - first_page]; + malloced = FALSE; + } else +#endif + { + fp = malloc(page_count * sizeof(struct vm_page), M_FICT_PAGES, + M_WAITOK | M_ZERO); +#ifdef VM_PHYSSEG_DENSE + malloced = TRUE; +#endif + } + for (i = 0; i < page_count; i++) { + vm_page_initfake(&fp[i], start + PAGE_SIZE * i, memattr); + pmap_page_init(&fp[i]); + fp[i].oflags &= ~(VPO_BUSY | VPO_UNMANAGED); + } + mtx_lock(&vm_phys_fictitious_reg_mtx); + for (segind = 0; segind < VM_PHYS_FICTITIOUS_NSEGS; segind++) { + seg = &vm_phys_fictitious_segs[segind]; + if (seg->start == 0 && seg->end == 0) { + seg->start = start; + seg->end = end; + seg->first_page = fp; + mtx_unlock(&vm_phys_fictitious_reg_mtx); + return (0); + } + } + mtx_unlock(&vm_phys_fictitious_reg_mtx); +#ifdef VM_PHYSSEG_DENSE + if (malloced) +#endif + free(fp, M_FICT_PAGES); + return (EBUSY); +} + +void +vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end) +{ + struct vm_phys_fictitious_seg *seg; + vm_page_t fp; + int segind; +#ifdef VM_PHYSSEG_DENSE + long pi; +#endif + +#ifdef VM_PHYSSEG_DENSE + pi = atop(start); +#endif + + mtx_lock(&vm_phys_fictitious_reg_mtx); + for (segind = 0; segind < VM_PHYS_FICTITIOUS_NSEGS; segind++) { + seg = &vm_phys_fictitious_segs[segind]; + if (seg->start == start && seg->end == end) { + seg->start = seg->end = 0; + fp = seg->first_page; + seg->first_page = NULL; + mtx_unlock(&vm_phys_fictitious_reg_mtx); +#ifdef VM_PHYSSEG_DENSE + if (pi < first_page || atop(end) >= vm_page_array_size) +#endif + free(fp, M_FICT_PAGES); + return; + } + } + mtx_unlock(&vm_phys_fictitious_reg_mtx); + KASSERT(0, ("Unregistering not registered fictitious range")); +} + /* * Find the segment containing the given physical address. */ Modified: stable/9/sys/vm/vm_phys.h ============================================================================== --- stable/9/sys/vm/vm_phys.h Mon Jun 11 21:12:52 2012 (r236923) +++ stable/9/sys/vm/vm_phys.h Mon Jun 11 21:19:59 2012 (r236924) @@ -56,6 +56,10 @@ vm_page_t vm_phys_alloc_contig(unsigned vm_page_t vm_phys_alloc_freelist_pages(int flind, int pool, int order); vm_page_t vm_phys_alloc_pages(int pool, int order); vm_paddr_t vm_phys_bootstrap_alloc(vm_size_t size, unsigned long alignment); +int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, + vm_memattr_t memattr); +void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); +vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); void vm_phys_free_pages(vm_page_t m, int order); void vm_phys_init(void); void vm_phys_set_pool(int pool, vm_page_t m, int order); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:25:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 63736106567D; Mon, 11 Jun 2012 21:25:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45A848FC0C; Mon, 11 Jun 2012 21:25:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLPLRt011056; Mon, 11 Jun 2012 21:25:21 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLPLxS011051; Mon, 11 Jun 2012 21:25:21 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112125.q5BLPLxS011051@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:25:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236925 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:25:21 -0000 Author: kib Date: Mon Jun 11 21:25:20 2012 New Revision: 236925 URL: http://svn.freebsd.org/changeset/base/236925 Log: MFC r235375: Add new pager type, OBJT_MGTDEVICE. It provides the device pager which carries fictitous managed pges. In particular, the consumers of the new object type can remove all mappings of the device page with pmap_remove_all(). The range of physical addresses used for fake page allocation shall be registered with vm_phys_fictitious_reg_range() interface to allow the PHYS_TO_VM_PAGE() to work in pmap. Modified: stable/9/sys/vm/device_pager.c stable/9/sys/vm/vm.h stable/9/sys/vm/vm_pager.c stable/9/sys/vm/vm_pager.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/device_pager.c ============================================================================== --- stable/9/sys/vm/device_pager.c Mon Jun 11 21:19:59 2012 (r236924) +++ stable/9/sys/vm/device_pager.c Mon Jun 11 21:25:20 2012 (r236925) @@ -61,6 +61,7 @@ static void dev_pager_putpages(vm_object boolean_t, int *); static boolean_t dev_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); +static void dev_pager_free_page(vm_object_t object, vm_page_t m); /* list of device pager objects */ static struct pagerlst dev_pager_object_list; @@ -76,6 +77,14 @@ struct pagerops devicepagerops = { .pgo_haspage = dev_pager_haspage, }; +struct pagerops mgtdevicepagerops = { + .pgo_alloc = dev_pager_alloc, + .pgo_dealloc = dev_pager_dealloc, + .pgo_getpages = dev_pager_getpages, + .pgo_putpages = dev_pager_putpages, + .pgo_haspage = dev_pager_haspage, +}; + static int old_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred, u_short *color); static void old_dev_pager_dtor(void *handle); @@ -114,7 +123,7 @@ cdev_pager_allocate(void *handle, enum o vm_pindex_t pindex; u_short color; - if (tp != OBJT_DEVICE) + if (tp != OBJT_DEVICE && tp != OBJT_MGTDEVICE) return (NULL); /* @@ -195,6 +204,24 @@ cdev_pager_free_page(vm_object_t object, { VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); + if (object->type == OBJT_MGTDEVICE) { + KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("unmanaged %p", m)); + pmap_remove_all(m); + vm_page_lock(m); + vm_page_remove(m); + vm_page_unlock(m); + } else if (object->type == OBJT_DEVICE) + dev_pager_free_page(object, m); +} + +static void +dev_pager_free_page(vm_object_t object, vm_page_t m) +{ + + VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); + KASSERT((object->type == OBJT_DEVICE && + (m->oflags & VPO_UNMANAGED) != 0), + ("Managed device or page obj %p m %p", object, m)); TAILQ_REMOVE(&object->un_pager.devp.devp_pglist, m, pageq); vm_page_putfake(m); } @@ -212,11 +239,15 @@ dev_pager_dealloc(object) TAILQ_REMOVE(&dev_pager_object_list, object, pager_object_list); mtx_unlock(&dev_pager_mtx); VM_OBJECT_LOCK(object); - /* - * Free up our fake pages. - */ - while ((m = TAILQ_FIRST(&object->un_pager.devp.devp_pglist)) != NULL) - cdev_pager_free_page(object, m); + + if (object->type == OBJT_DEVICE) { + /* + * Free up our fake pages. + */ + while ((m = TAILQ_FIRST(&object->un_pager.devp.devp_pglist)) + != NULL) + dev_pager_free_page(object, m); + } } static int @@ -239,8 +270,15 @@ dev_pager_getpages(vm_object_t object, v } if (error == VM_PAGER_OK) { - TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, - ma[reqpage], pageq); + KASSERT((object->type == OBJT_DEVICE && + (ma[reqpage]->oflags & VPO_UNMANAGED) != 0) || + (object->type == OBJT_MGTDEVICE && + (ma[reqpage]->oflags & VPO_UNMANAGED) == 0), + ("Wrong page type %p %p", ma[reqpage], object)); + if (object->type == OBJT_DEVICE) { + TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, + ma[reqpage], pageq); + } } return (error); Modified: stable/9/sys/vm/vm.h ============================================================================== --- stable/9/sys/vm/vm.h Mon Jun 11 21:19:59 2012 (r236924) +++ stable/9/sys/vm/vm.h Mon Jun 11 21:25:20 2012 (r236925) @@ -83,7 +83,7 @@ typedef u_char vm_prot_t; /* protection #define VM_PROT_DEFAULT VM_PROT_ALL enum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_PHYS, - OBJT_DEAD, OBJT_SG }; + OBJT_DEAD, OBJT_SG, OBJT_MGTDEVICE }; typedef u_char objtype_t; union vm_map_object; Modified: stable/9/sys/vm/vm_pager.c ============================================================================== --- stable/9/sys/vm/vm_pager.c Mon Jun 11 21:19:59 2012 (r236924) +++ stable/9/sys/vm/vm_pager.c Mon Jun 11 21:25:20 2012 (r236925) @@ -159,7 +159,8 @@ struct pagerops *pagertab[] = { &devicepagerops, /* OBJT_DEVICE */ &physpagerops, /* OBJT_PHYS */ &deadpagerops, /* OBJT_DEAD */ - &sgpagerops /* OBJT_SG */ + &sgpagerops, /* OBJT_SG */ + &mgtdevicepagerops, /* OBJT_MGTDEVICE */ }; static const int npagers = sizeof(pagertab) / sizeof(pagertab[0]); Modified: stable/9/sys/vm/vm_pager.h ============================================================================== --- stable/9/sys/vm/vm_pager.h Mon Jun 11 21:19:59 2012 (r236924) +++ stable/9/sys/vm/vm_pager.h Mon Jun 11 21:25:20 2012 (r236925) @@ -71,6 +71,7 @@ extern struct pagerops vnodepagerops; extern struct pagerops devicepagerops; extern struct pagerops physpagerops; extern struct pagerops sgpagerops; +extern struct pagerops mgtdevicepagerops; /* * get/put return values From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:33:03 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 33373106564A; Mon, 11 Jun 2012 21:33:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D0578FC0A; Mon, 11 Jun 2012 21:33:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLX3nS011432; Mon, 11 Jun 2012 21:33:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLX29S011428; Mon, 11 Jun 2012 21:33:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112133.q5BLX29S011428@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:33:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236926 - in stable/9/sys: dev/agp modules/agp sys X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:33:03 -0000 Author: kib Date: Mon Jun 11 21:33:02 2012 New Revision: 236926 URL: http://svn.freebsd.org/changeset/base/236926 Log: MFC r235782: A rewrite of the i810 bits of the agp(4) driver. New driver supports operations required by GEMified i915.ko. It also attaches to SandyBridge and IvyBridge CPU northbridges now. Added: stable/9/sys/dev/agp/agp_i810.h - copied unchanged from r235782, head/sys/dev/agp/agp_i810.h Modified: stable/9/sys/dev/agp/agp.c stable/9/sys/dev/agp/agp_i810.c stable/9/sys/dev/agp/agp_if.m stable/9/sys/dev/agp/agppriv.h stable/9/sys/dev/agp/agpreg.h stable/9/sys/dev/agp/agpvar.h stable/9/sys/modules/agp/Makefile stable/9/sys/sys/agpio.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/dev/agp/agp.c ============================================================================== --- stable/9/sys/dev/agp/agp.c Mon Jun 11 21:25:20 2012 (r236925) +++ stable/9/sys/dev/agp/agp.c Mon Jun 11 21:33:02 2012 (r236926) @@ -239,7 +239,8 @@ agp_generic_attach(device_t dev) if (memsize <= agp_max[i][0]) break; } - if (i == agp_max_size) i = agp_max_size - 1; + if (i == agp_max_size) + i = agp_max_size - 1; sc->as_maxmem = agp_max[i][1] << 20U; /* @@ -803,6 +804,13 @@ agp_unbind_user(device_t dev, agp_unbind } static int +agp_chipset_flush(device_t dev) +{ + + return (AGP_CHIPSET_FLUSH(dev)); +} + +static int agp_open(struct cdev *kdev, int oflags, int devtype, struct thread *td) { device_t dev = kdev->si_drv1; @@ -869,6 +877,8 @@ agp_ioctl(struct cdev *kdev, u_long cmd, case AGPIOC_UNBIND: return agp_unbind_user(dev, (agp_unbind *)data); + case AGPIOC_CHIPSET_FLUSH: + return agp_chipset_flush(dev); } return EINVAL; Modified: stable/9/sys/dev/agp/agp_i810.c ============================================================================== --- stable/9/sys/dev/agp/agp_i810.c Mon Jun 11 21:25:20 2012 (r236925) +++ stable/9/sys/dev/agp/agp_i810.c Mon Jun 11 21:33:02 2012 (r236926) @@ -1,8 +1,12 @@ /*- * Copyright (c) 2000 Doug Rabson * Copyright (c) 2000 Ruslan Ermilov + * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -28,6 +32,9 @@ /* * Fixes for 830/845G support: David Dawes * 852GM/855GM/865G support added by David Dawes + * + * This is generic Intel GTT handling code, morphed from the AGP + * bridge code. */ #include @@ -35,10 +42,17 @@ __FBSDID("$FreeBSD$"); #include "opt_bus.h" +#if 0 +#define KTR_AGP_I810 KTR_DEV +#else +#define KTR_AGP_I810 0 +#endif + #include #include #include #include +#include #include #include #include @@ -47,8 +61,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include +#include #include #include @@ -63,6 +79,88 @@ __FBSDID("$FreeBSD$"); MALLOC_DECLARE(M_AGP); +struct agp_i810_match; + +static int agp_i810_check_active(device_t bridge_dev); +static int agp_i830_check_active(device_t bridge_dev); +static int agp_i915_check_active(device_t bridge_dev); +static int agp_sb_check_active(device_t bridge_dev); + +static void agp_82852_set_desc(device_t dev, + const struct agp_i810_match *match); +static void agp_i810_set_desc(device_t dev, const struct agp_i810_match *match); + +static void agp_i810_dump_regs(device_t dev); +static void agp_i830_dump_regs(device_t dev); +static void agp_i855_dump_regs(device_t dev); +static void agp_i915_dump_regs(device_t dev); +static void agp_i965_dump_regs(device_t dev); +static void agp_sb_dump_regs(device_t dev); + +static int agp_i810_get_stolen_size(device_t dev); +static int agp_i830_get_stolen_size(device_t dev); +static int agp_i915_get_stolen_size(device_t dev); +static int agp_sb_get_stolen_size(device_t dev); + +static int agp_i810_get_gtt_mappable_entries(device_t dev); +static int agp_i830_get_gtt_mappable_entries(device_t dev); +static int agp_i915_get_gtt_mappable_entries(device_t dev); + +static int agp_i810_get_gtt_total_entries(device_t dev); +static int agp_i965_get_gtt_total_entries(device_t dev); +static int agp_gen5_get_gtt_total_entries(device_t dev); +static int agp_sb_get_gtt_total_entries(device_t dev); + +static int agp_i810_install_gatt(device_t dev); +static int agp_i830_install_gatt(device_t dev); + +static void agp_i810_deinstall_gatt(device_t dev); +static void agp_i830_deinstall_gatt(device_t dev); + +static void agp_i810_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); +static void agp_i830_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); +static void agp_i915_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); +static void agp_i965_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); +static void agp_g4x_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); +static void agp_sb_install_gtt_pte(device_t dev, u_int index, + vm_offset_t physical, int flags); + +static void agp_i810_write_gtt(device_t dev, u_int index, uint32_t pte); +static void agp_i915_write_gtt(device_t dev, u_int index, uint32_t pte); +static void agp_i965_write_gtt(device_t dev, u_int index, uint32_t pte); +static void agp_g4x_write_gtt(device_t dev, u_int index, uint32_t pte); +static void agp_sb_write_gtt(device_t dev, u_int index, uint32_t pte); + +static u_int32_t agp_i810_read_gtt_pte(device_t dev, u_int index); +static u_int32_t agp_i915_read_gtt_pte(device_t dev, u_int index); +static u_int32_t agp_i965_read_gtt_pte(device_t dev, u_int index); +static u_int32_t agp_g4x_read_gtt_pte(device_t dev, u_int index); + +static vm_paddr_t agp_i810_read_gtt_pte_paddr(device_t dev, u_int index); +static vm_paddr_t agp_i915_read_gtt_pte_paddr(device_t dev, u_int index); +static vm_paddr_t agp_sb_read_gtt_pte_paddr(device_t dev, u_int index); + +static int agp_i810_set_aperture(device_t dev, u_int32_t aperture); +static int agp_i830_set_aperture(device_t dev, u_int32_t aperture); +static int agp_i915_set_aperture(device_t dev, u_int32_t aperture); + +static int agp_i810_chipset_flush_setup(device_t dev); +static int agp_i915_chipset_flush_setup(device_t dev); +static int agp_i965_chipset_flush_setup(device_t dev); + +static void agp_i810_chipset_flush_teardown(device_t dev); +static void agp_i915_chipset_flush_teardown(device_t dev); +static void agp_i965_chipset_flush_teardown(device_t dev); + +static void agp_i810_chipset_flush(device_t dev); +static void agp_i830_chipset_flush(device_t dev); +static void agp_i915_chipset_flush(device_t dev); + enum { CHIP_I810, /* i810/i815 */ CHIP_I830, /* 830M/845G */ @@ -72,6 +170,7 @@ enum { CHIP_G33, /* G33/Q33/Q35 */ CHIP_IGD, /* Pineview */ CHIP_G4X, /* G45/Q45 */ + CHIP_SB, /* SandyBridge */ }; /* The i810 through i855 have the registers at BAR 1, and the GATT gets @@ -96,19 +195,308 @@ static struct resource_spec agp_i965_res { -1, 0 } }; +static struct resource_spec agp_g4x_res_spec[] = { + { SYS_RES_MEMORY, AGP_G4X_MMADR, RF_ACTIVE | RF_SHAREABLE }, + { SYS_RES_MEMORY, AGP_G4X_GTTADR, RF_ACTIVE | RF_SHAREABLE }, + { -1, 0 } +}; + struct agp_i810_softc { struct agp_softc agp; u_int32_t initial_aperture; /* aperture size at startup */ struct agp_gatt *gatt; - int chiptype; /* i810-like or i830 */ u_int32_t dcache_size; /* i810 only */ - u_int32_t stolen; /* number of i830/845 gtt entries for stolen memory */ + u_int32_t stolen; /* number of i830/845 gtt + entries for stolen memory */ + u_int stolen_size; /* BIOS-reserved graphics memory */ + u_int gtt_total_entries; /* Total number of gtt ptes */ + u_int gtt_mappable_entries; /* Number of gtt ptes mappable by CPU */ device_t bdev; /* bridge device */ - void *argb_cursor; /* contigmalloc area for ARGB cursor */ - - struct resource_spec * sc_res_spec; struct resource *sc_res[2]; + const struct agp_i810_match *match; + int sc_flush_page_rid; + struct resource *sc_flush_page_res; + void *sc_flush_page_vaddr; + int sc_bios_allocated_flush_page; +}; + +static device_t intel_agp; + +struct agp_i810_driver { + int chiptype; + int gen; + int busdma_addr_mask_sz; + struct resource_spec *res_spec; + int (*check_active)(device_t); + void (*set_desc)(device_t, const struct agp_i810_match *); + void (*dump_regs)(device_t); + int (*get_stolen_size)(device_t); + int (*get_gtt_total_entries)(device_t); + int (*get_gtt_mappable_entries)(device_t); + int (*install_gatt)(device_t); + void (*deinstall_gatt)(device_t); + void (*write_gtt)(device_t, u_int, uint32_t); + void (*install_gtt_pte)(device_t, u_int, vm_offset_t, int); + u_int32_t (*read_gtt_pte)(device_t, u_int); + vm_paddr_t (*read_gtt_pte_paddr)(device_t , u_int); + int (*set_aperture)(device_t, u_int32_t); + int (*chipset_flush_setup)(device_t); + void (*chipset_flush_teardown)(device_t); + void (*chipset_flush)(device_t); +}; + +static const struct agp_i810_driver agp_i810_i810_driver = { + .chiptype = CHIP_I810, + .gen = 1, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i810_res_spec, + .check_active = agp_i810_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i810_dump_regs, + .get_stolen_size = agp_i810_get_stolen_size, + .get_gtt_mappable_entries = agp_i810_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i810_install_gatt, + .deinstall_gatt = agp_i810_deinstall_gatt, + .write_gtt = agp_i810_write_gtt, + .install_gtt_pte = agp_i810_install_gtt_pte, + .read_gtt_pte = agp_i810_read_gtt_pte, + .read_gtt_pte_paddr = agp_i810_read_gtt_pte_paddr, + .set_aperture = agp_i810_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i810_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_i815_driver = { + .chiptype = CHIP_I810, + .gen = 2, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i810_res_spec, + .check_active = agp_i810_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i810_dump_regs, + .get_stolen_size = agp_i810_get_stolen_size, + .get_gtt_mappable_entries = agp_i830_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i810_install_gatt, + .deinstall_gatt = agp_i810_deinstall_gatt, + .write_gtt = agp_i810_write_gtt, + .install_gtt_pte = agp_i810_install_gtt_pte, + .read_gtt_pte = agp_i810_read_gtt_pte, + .read_gtt_pte_paddr = agp_i810_read_gtt_pte_paddr, + .set_aperture = agp_i810_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i830_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_i830_driver = { + .chiptype = CHIP_I830, + .gen = 2, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i810_res_spec, + .check_active = agp_i830_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i830_dump_regs, + .get_stolen_size = agp_i830_get_stolen_size, + .get_gtt_mappable_entries = agp_i830_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i810_write_gtt, + .install_gtt_pte = agp_i830_install_gtt_pte, + .read_gtt_pte = agp_i810_read_gtt_pte, + .read_gtt_pte_paddr = agp_i810_read_gtt_pte_paddr, + .set_aperture = agp_i830_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i830_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_i855_driver = { + .chiptype = CHIP_I855, + .gen = 2, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i810_res_spec, + .check_active = agp_i830_check_active, + .set_desc = agp_82852_set_desc, + .dump_regs = agp_i855_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i810_write_gtt, + .install_gtt_pte = agp_i830_install_gtt_pte, + .read_gtt_pte = agp_i810_read_gtt_pte, + .read_gtt_pte_paddr = agp_i810_read_gtt_pte_paddr, + .set_aperture = agp_i830_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i830_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_i865_driver = { + .chiptype = CHIP_I855, + .gen = 2, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i810_res_spec, + .check_active = agp_i830_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i855_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i810_write_gtt, + .install_gtt_pte = agp_i830_install_gtt_pte, + .read_gtt_pte = agp_i810_read_gtt_pte, + .read_gtt_pte_paddr = agp_i810_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i830_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_i915_driver = { + .chiptype = CHIP_I915, + .gen = 3, + .busdma_addr_mask_sz = 32, + .res_spec = agp_i915_res_spec, + .check_active = agp_i915_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i915_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i810_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i915_write_gtt, + .install_gtt_pte = agp_i915_install_gtt_pte, + .read_gtt_pte = agp_i915_read_gtt_pte, + .read_gtt_pte_paddr = agp_i915_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i915_chipset_flush_setup, + .chipset_flush_teardown = agp_i915_chipset_flush_teardown, + .chipset_flush = agp_i915_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_g965_driver = { + .chiptype = CHIP_I965, + .gen = 4, + .busdma_addr_mask_sz = 36, + .res_spec = agp_i965_res_spec, + .check_active = agp_i915_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i965_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i965_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i965_write_gtt, + .install_gtt_pte = agp_i965_install_gtt_pte, + .read_gtt_pte = agp_i965_read_gtt_pte, + .read_gtt_pte_paddr = agp_i915_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i965_chipset_flush_setup, + .chipset_flush_teardown = agp_i965_chipset_flush_teardown, + .chipset_flush = agp_i915_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_g33_driver = { + .chiptype = CHIP_G33, + .gen = 3, + .busdma_addr_mask_sz = 36, + .res_spec = agp_i915_res_spec, + .check_active = agp_i915_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i965_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i965_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i915_write_gtt, + .install_gtt_pte = agp_i915_install_gtt_pte, + .read_gtt_pte = agp_i915_read_gtt_pte, + .read_gtt_pte_paddr = agp_i915_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i965_chipset_flush_setup, + .chipset_flush_teardown = agp_i965_chipset_flush_teardown, + .chipset_flush = agp_i915_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_igd_driver = { + .chiptype = CHIP_IGD, + .gen = 3, + .busdma_addr_mask_sz = 36, + .res_spec = agp_i915_res_spec, + .check_active = agp_i915_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i915_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_i965_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_i915_write_gtt, + .install_gtt_pte = agp_i915_install_gtt_pte, + .read_gtt_pte = agp_i915_read_gtt_pte, + .read_gtt_pte_paddr = agp_i915_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i965_chipset_flush_setup, + .chipset_flush_teardown = agp_i965_chipset_flush_teardown, + .chipset_flush = agp_i915_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_g4x_driver = { + .chiptype = CHIP_G4X, + .gen = 5, + .busdma_addr_mask_sz = 36, + .res_spec = agp_i965_res_spec, + .check_active = agp_i915_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_i965_dump_regs, + .get_stolen_size = agp_i915_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_gen5_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_g4x_write_gtt, + .install_gtt_pte = agp_g4x_install_gtt_pte, + .read_gtt_pte = agp_g4x_read_gtt_pte, + .read_gtt_pte_paddr = agp_i915_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i965_chipset_flush_setup, + .chipset_flush_teardown = agp_i965_chipset_flush_teardown, + .chipset_flush = agp_i915_chipset_flush, +}; + +static const struct agp_i810_driver agp_i810_sb_driver = { + .chiptype = CHIP_SB, + .gen = 6, + .busdma_addr_mask_sz = 40, + .res_spec = agp_g4x_res_spec, + .check_active = agp_sb_check_active, + .set_desc = agp_i810_set_desc, + .dump_regs = agp_sb_dump_regs, + .get_stolen_size = agp_sb_get_stolen_size, + .get_gtt_mappable_entries = agp_i915_get_gtt_mappable_entries, + .get_gtt_total_entries = agp_sb_get_gtt_total_entries, + .install_gatt = agp_i830_install_gatt, + .deinstall_gatt = agp_i830_deinstall_gatt, + .write_gtt = agp_sb_write_gtt, + .install_gtt_pte = agp_sb_install_gtt_pte, + .read_gtt_pte = agp_g4x_read_gtt_pte, + .read_gtt_pte_paddr = agp_sb_read_gtt_pte_paddr, + .set_aperture = agp_i915_set_aperture, + .chipset_flush_setup = agp_i810_chipset_flush_setup, + .chipset_flush_teardown = agp_i810_chipset_flush_teardown, + .chipset_flush = agp_i810_chipset_flush, }; /* For adding new devices, devid is the id of the graphics controller @@ -118,75 +506,232 @@ struct agp_i810_softc { */ static const struct agp_i810_match { int devid; - int chiptype; - int bridge_offset; char *name; + const struct agp_i810_driver *driver; } agp_i810_matches[] = { - {0x71218086, CHIP_I810, 0x00010000, - "Intel 82810 (i810 GMCH) SVGA controller"}, - {0x71238086, CHIP_I810, 0x00010000, - "Intel 82810-DC100 (i810-DC100 GMCH) SVGA controller"}, - {0x71258086, CHIP_I810, 0x00010000, - "Intel 82810E (i810E GMCH) SVGA controller"}, - {0x11328086, CHIP_I810, 0x00020000, - "Intel 82815 (i815 GMCH) SVGA controller"}, - {0x35778086, CHIP_I830, 0x00020000, - "Intel 82830M (830M GMCH) SVGA controller"}, - {0x25628086, CHIP_I830, 0x00020000, - "Intel 82845M (845M GMCH) SVGA controller"}, - {0x35828086, CHIP_I855, 0x00020000, - "Intel 82852/855GM SVGA controller"}, - {0x25728086, CHIP_I855, 0x00020000, - "Intel 82865G (865G GMCH) SVGA controller"}, - {0x25828086, CHIP_I915, 0x00020000, - "Intel 82915G (915G GMCH) SVGA controller"}, - {0x258A8086, CHIP_I915, 0x00020000, - "Intel E7221 SVGA controller"}, - {0x25928086, CHIP_I915, 0x00020000, - "Intel 82915GM (915GM GMCH) SVGA controller"}, - {0x27728086, CHIP_I915, 0x00020000, - "Intel 82945G (945G GMCH) SVGA controller"}, - {0x27A28086, CHIP_I915, 0x00020000, - "Intel 82945GM (945GM GMCH) SVGA controller"}, - {0x27AE8086, CHIP_I915, 0x00020000, - "Intel 945GME SVGA controller"}, - {0x29728086, CHIP_I965, 0x00020000, - "Intel 946GZ SVGA controller"}, - {0x29828086, CHIP_I965, 0x00020000, - "Intel G965 SVGA controller"}, - {0x29928086, CHIP_I965, 0x00020000, - "Intel Q965 SVGA controller"}, - {0x29A28086, CHIP_I965, 0x00020000, - "Intel G965 SVGA controller"}, - {0x29B28086, CHIP_G33, 0x00020000, - "Intel Q35 SVGA controller"}, - {0x29C28086, CHIP_G33, 0x00020000, - "Intel G33 SVGA controller"}, - {0x29D28086, CHIP_G33, 0x00020000, - "Intel Q33 SVGA controller"}, - {0xA0018086, CHIP_IGD, 0x00010000, - "Intel Pineview SVGA controller"}, - {0xA0118086, CHIP_IGD, 0x00010000, - "Intel Pineview (M) SVGA controller"}, - {0x2A028086, CHIP_I965, 0x00020000, - "Intel GM965 SVGA controller"}, - {0x2A128086, CHIP_I965, 0x00020000, - "Intel GME965 SVGA controller"}, - {0x2A428086, CHIP_G4X, 0x00020000, - "Intel GM45 SVGA controller"}, - {0x2E028086, CHIP_G4X, 0x00020000, - "Intel Eaglelake SVGA controller"}, - {0x2E128086, CHIP_G4X, 0x00020000, - "Intel Q45 SVGA controller"}, - {0x2E228086, CHIP_G4X, 0x00020000, - "Intel G45 SVGA controller"}, - {0x2E328086, CHIP_G4X, 0x00020000, - "Intel G41 SVGA controller"}, - {0x00428086, CHIP_G4X, 0x00020000, - "Intel Ironlake (D) SVGA controller"}, - {0x00468086, CHIP_G4X, 0x00020000, - "Intel Ironlake (M) SVGA controller"}, - {0, 0, 0, NULL} + { + .devid = 0x71218086, + .name = "Intel 82810 (i810 GMCH) SVGA controller", + .driver = &agp_i810_i810_driver + }, + { + .devid = 0x71238086, + .name = "Intel 82810-DC100 (i810-DC100 GMCH) SVGA controller", + .driver = &agp_i810_i810_driver + }, + { + .devid = 0x71258086, + .name = "Intel 82810E (i810E GMCH) SVGA controller", + .driver = &agp_i810_i810_driver + }, + { + .devid = 0x11328086, + .name = "Intel 82815 (i815 GMCH) SVGA controller", + .driver = &agp_i810_i815_driver + }, + { + .devid = 0x35778086, + .name = "Intel 82830M (830M GMCH) SVGA controller", + .driver = &agp_i810_i830_driver + }, + { + .devid = 0x25628086, + .name = "Intel 82845M (845M GMCH) SVGA controller", + .driver = &agp_i810_i830_driver + }, + { + .devid = 0x35828086, + .name = "Intel 82852/855GM SVGA controller", + .driver = &agp_i810_i855_driver + }, + { + .devid = 0x25728086, + .name = "Intel 82865G (865G GMCH) SVGA controller", + .driver = &agp_i810_i865_driver + }, + { + .devid = 0x25828086, + .name = "Intel 82915G (915G GMCH) SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x258A8086, + .name = "Intel E7221 SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x25928086, + .name = "Intel 82915GM (915GM GMCH) SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x27728086, + .name = "Intel 82945G (945G GMCH) SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x27A28086, + .name = "Intel 82945GM (945GM GMCH) SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x27AE8086, + .name = "Intel 945GME SVGA controller", + .driver = &agp_i810_i915_driver + }, + { + .devid = 0x29728086, + .name = "Intel 946GZ SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x29828086, + .name = "Intel G965 SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x29928086, + .name = "Intel Q965 SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x29A28086, + .name = "Intel G965 SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x29B28086, + .name = "Intel Q35 SVGA controller", + .driver = &agp_i810_g33_driver + }, + { + .devid = 0x29C28086, + .name = "Intel G33 SVGA controller", + .driver = &agp_i810_g33_driver + }, + { + .devid = 0x29D28086, + .name = "Intel Q33 SVGA controller", + .driver = &agp_i810_g33_driver + }, + { + .devid = 0xA0018086, + .name = "Intel Pineview SVGA controller", + .driver = &agp_i810_igd_driver + }, + { + .devid = 0xA0118086, + .name = "Intel Pineview (M) SVGA controller", + .driver = &agp_i810_igd_driver + }, + { + .devid = 0x2A028086, + .name = "Intel GM965 SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x2A128086, + .name = "Intel GME965 SVGA controller", + .driver = &agp_i810_g965_driver + }, + { + .devid = 0x2A428086, + .name = "Intel GM45 SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x2E028086, + .name = "Intel Eaglelake SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x2E128086, + .name = "Intel Q45 SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x2E228086, + .name = "Intel G45 SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x2E328086, + .name = "Intel G41 SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x00428086, + .name = "Intel Ironlake (D) SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x00468086, + .name = "Intel Ironlake (M) SVGA controller", + .driver = &agp_i810_g4x_driver + }, + { + .devid = 0x01028086, + .name = "SandyBridge desktop GT1 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01128086, + .name = "SandyBridge desktop GT2 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01228086, + .name = "SandyBridge desktop GT2+ IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01068086, + .name = "SandyBridge mobile GT1 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01168086, + .name = "SandyBridge mobile GT2 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01268086, + .name = "SandyBridge mobile GT2+ IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01088086, + .name = "SandyBridge server IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01528086, + .name = "IvyBridge desktop GT1 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01628086, + .name = "IvyBridge desktop GT2 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01568086, + .name = "IvyBridge mobile GT1 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x01668086, + .name = "IvyBridge mobile GT2 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0x015a8086, + .name = "IvyBridge server GT1 IG", + .driver = &agp_i810_sb_driver + }, + { + .devid = 0, + } }; static const struct agp_i810_match* @@ -196,17 +741,17 @@ agp_i810_match(device_t dev) if (pci_get_class(dev) != PCIC_DISPLAY || pci_get_subclass(dev) != PCIS_DISPLAY_VGA) - return NULL; + return (NULL); devid = pci_get_devid(dev); for (i = 0; agp_i810_matches[i].devid != 0; i++) { if (agp_i810_matches[i].devid == devid) - break; + break; } if (agp_i810_matches[i].devid == 0) - return NULL; + return (NULL); else - return &agp_i810_matches[i]; + return (&agp_i810_matches[i]); } /* @@ -215,28 +760,8 @@ agp_i810_match(device_t dev) static device_t agp_i810_find_bridge(device_t dev) { - device_t *children, child; - int nchildren, i; - u_int32_t devid; - const struct agp_i810_match *match; - - match = agp_i810_match(dev); - devid = match->devid - match->bridge_offset; - if (device_get_children(device_get_parent(device_get_parent(dev)), - &children, &nchildren)) - return 0; - - for (i = 0; i < nchildren; i++) { - child = children[i]; - - if (pci_get_devid(child) == devid) { - free(children, M_TEMP); - return child; - } - } - free(children, M_TEMP); - return 0; + return (pci_find_dbsf(0, 0, 0, 0)); } static void @@ -249,92 +774,116 @@ agp_i810_identify(driver_t *driver, devi } static int +agp_i810_check_active(device_t bridge_dev) +{ + u_int8_t smram; + + smram = pci_read_config(bridge_dev, AGP_I810_SMRAM, 1); + if ((smram & AGP_I810_SMRAM_GMS) == AGP_I810_SMRAM_GMS_DISABLED) + return (ENXIO); + return (0); +} + +static int +agp_i830_check_active(device_t bridge_dev) +{ + int gcc1; + + gcc1 = pci_read_config(bridge_dev, AGP_I830_GCC1, 1); + if ((gcc1 & AGP_I830_GCC1_DEV2) == AGP_I830_GCC1_DEV2_DISABLED) + return (ENXIO); + return (0); +} + +static int +agp_i915_check_active(device_t bridge_dev) +{ + int deven; + + deven = pci_read_config(bridge_dev, AGP_I915_DEVEN, 4); + if ((deven & AGP_I915_DEVEN_D2F0) == AGP_I915_DEVEN_D2F0_DISABLED) + return (ENXIO); + return (0); +} + +static int +agp_sb_check_active(device_t bridge_dev) +{ + int deven; + + deven = pci_read_config(bridge_dev, AGP_I915_DEVEN, 4); + if ((deven & AGP_SB_DEVEN_D2EN) == AGP_SB_DEVEN_D2EN_DISABLED) + return (ENXIO); + return (0); +} + +static void +agp_82852_set_desc(device_t dev, const struct agp_i810_match *match) +{ + + switch (pci_read_config(dev, AGP_I85X_CAPID, 1)) { + case AGP_I855_GME: + device_set_desc(dev, + "Intel 82855GME (855GME GMCH) SVGA controller"); + break; + case AGP_I855_GM: + device_set_desc(dev, + "Intel 82855GM (855GM GMCH) SVGA controller"); + break; + case AGP_I852_GME: + device_set_desc(dev, + "Intel 82852GME (852GME GMCH) SVGA controller"); + break; + case AGP_I852_GM: + device_set_desc(dev, + "Intel 82852GM (852GM GMCH) SVGA controller"); + break; + default: + device_set_desc(dev, + "Intel 8285xM (85xGM GMCH) SVGA controller"); + break; + } +} + +static void +agp_i810_set_desc(device_t dev, const struct agp_i810_match *match) +{ + + device_set_desc(dev, match->name); +} + +static int agp_i810_probe(device_t dev) { device_t bdev; const struct agp_i810_match *match; - u_int8_t smram; - int gcc1, deven; + int err; if (resource_disabled("agp", device_get_unit(dev))) return (ENXIO); match = agp_i810_match(dev); if (match == NULL) - return ENXIO; + return (ENXIO); bdev = agp_i810_find_bridge(dev); - if (!bdev) { + if (bdev == NULL) { if (bootverbose) printf("I810: can't find bridge device\n"); - return ENXIO; + return (ENXIO); } /* * checking whether internal graphics device has been activated. */ - switch (match->chiptype) { - case CHIP_I810: - smram = pci_read_config(bdev, AGP_I810_SMRAM, 1); - if ((smram & AGP_I810_SMRAM_GMS) == - AGP_I810_SMRAM_GMS_DISABLED) { - if (bootverbose) - printf("I810: disabled, not probing\n"); - return ENXIO; - } - break; - case CHIP_I830: - case CHIP_I855: - gcc1 = pci_read_config(bdev, AGP_I830_GCC1, 1); - if ((gcc1 & AGP_I830_GCC1_DEV2) == - AGP_I830_GCC1_DEV2_DISABLED) { - if (bootverbose) - printf("I830: disabled, not probing\n"); - return ENXIO; - } - break; - case CHIP_I915: - case CHIP_I965: - case CHIP_G33: - case CHIP_IGD: - case CHIP_G4X: - deven = pci_read_config(bdev, AGP_I915_DEVEN, 4); - if ((deven & AGP_I915_DEVEN_D2F0) == - AGP_I915_DEVEN_D2F0_DISABLED) { - if (bootverbose) - printf("I915: disabled, not probing\n"); - return ENXIO; - } - break; - } - - if (match->devid == 0x35828086) { - switch (pci_read_config(dev, AGP_I85X_CAPID, 1)) { - case AGP_I855_GME: *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:35:28 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88EA2106564A; Mon, 11 Jun 2012 21:35:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A4678FC17; Mon, 11 Jun 2012 21:35:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLZSuV011582; Mon, 11 Jun 2012 21:35:28 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLZS8d011581; Mon, 11 Jun 2012 21:35:28 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112135.q5BLZS8d011581@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:35:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236927 - stable/9/sys/dev/drm2 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:35:28 -0000 Author: kib Date: Mon Jun 11 21:35:27 2012 New Revision: 236927 URL: http://svn.freebsd.org/changeset/base/236927 Log: MFC r235783: Add the code for new Intel GPU driver, which supports GEM, KMS and works with new generations of GPUs (IronLake, SandyBridge and supposedly IvyBridge). The driver is not connected to the build yet. Added: stable/9/sys/dev/drm2/ - copied from r235783, head/sys/dev/drm2/ Modified: Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:38:37 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 10F98106564A; Mon, 11 Jun 2012 21:38:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F03928FC14; Mon, 11 Jun 2012 21:38:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLcasb011758; Mon, 11 Jun 2012 21:38:36 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLcaTd011756; Mon, 11 Jun 2012 21:38:36 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112138.q5BLcaTd011756@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:38:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236928 - stable/9/sys/dev/pci X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:38:37 -0000 Author: kib Date: Mon Jun 11 21:38:36 2012 New Revision: 236928 URL: http://svn.freebsd.org/changeset/base/236928 Log: MFC r235846: Add 'drmn' device as another drm child, to allow drm2 drivers to live in parallel with drm1. Modified: stable/9/sys/dev/pci/vga_pci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/pci/vga_pci.c ============================================================================== --- stable/9/sys/dev/pci/vga_pci.c Mon Jun 11 21:35:27 2012 (r236927) +++ stable/9/sys/dev/pci/vga_pci.c Mon Jun 11 21:38:36 2012 (r236928) @@ -105,6 +105,7 @@ vga_pci_attach(device_t dev) /* Always create a drm child for now to make it easier on drm. */ device_add_child(dev, "drm", -1); + device_add_child(dev, "drmn", -1); bus_generic_attach(dev); return (0); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:40:03 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13505106564A; Mon, 11 Jun 2012 21:40:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D31B28FC23; Mon, 11 Jun 2012 21:40:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLe29l011871; Mon, 11 Jun 2012 21:40:02 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLe2tG011870; Mon, 11 Jun 2012 21:40:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112140.q5BLe2tG011870@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:40:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236929 - stable/9/sys/modules/drm2 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:40:03 -0000 Author: kib Date: Mon Jun 11 21:40:02 2012 New Revision: 236929 URL: http://svn.freebsd.org/changeset/base/236929 Log: MFC r235847: The drm2 modules makefiles commit. Added: stable/9/sys/modules/drm2/ - copied from r235847, head/sys/modules/drm2/ Modified: Directory Properties: stable/9/sys/ (props changed) stable/9/sys/modules/ (props changed) From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:41:46 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74A7E1065674; Mon, 11 Jun 2012 21:41:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5FB0B8FC32; Mon, 11 Jun 2012 21:41:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLfjSq012026; Mon, 11 Jun 2012 21:41:45 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLfj5G012024; Mon, 11 Jun 2012 21:41:45 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112141.q5BLfj5G012024@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:41:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236931 - stable/9/sys/dev/drm2/i915 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:41:46 -0000 Author: kib Date: Mon Jun 11 21:41:45 2012 New Revision: 236931 URL: http://svn.freebsd.org/changeset/base/236931 Log: MFC r235925 (by dim): Fix a clang warning in drm2. Modified: stable/9/sys/dev/drm2/i915/intel_display.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/drm2/i915/intel_display.c ============================================================================== --- stable/9/sys/dev/drm2/i915/intel_display.c Mon Jun 11 21:41:16 2012 (r236930) +++ stable/9/sys/dev/drm2/i915/intel_display.c Mon Jun 11 21:41:45 2012 (r236931) @@ -8858,7 +8858,7 @@ static void ironlake_disable_rc6(struct if (I915_READ(PWRCTXA)) { /* Wake the GPU, prevent RC6, then restore RSTDBYCTL */ I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT); - _intel_wait_for(dev, + (void)_intel_wait_for(dev, ((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON), 50, 1, "915pro"); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:43:17 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8FDD8106564A; Mon, 11 Jun 2012 21:43:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7AABB8FC1B; Mon, 11 Jun 2012 21:43:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLhHdH012148; Mon, 11 Jun 2012 21:43:17 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLhHYL012146; Mon, 11 Jun 2012 21:43:17 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112143.q5BLhHYL012146@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:43:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236932 - stable/9/sys/dev/drm2/i915 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:43:17 -0000 Author: kib Date: Mon Jun 11 21:43:17 2012 New Revision: 236932 URL: http://svn.freebsd.org/changeset/base/236932 Log: MFC r236182: Fix calculation of the execution buffer end in the mapped pages when it is spilled into the next page. Modified: stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c ============================================================================== --- stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Mon Jun 11 21:41:45 2012 (r236931) +++ stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Mon Jun 11 21:43:17 2012 (r236932) @@ -1069,7 +1069,8 @@ i915_gem_fix_mi_batchbuffer_end(struct d po_r -= 4; mkva = pmap_mapdev_attr(trunc_page(po_r), 2 * PAGE_SIZE, PAT_WRITE_COMBINING); - cmd = *(uint32_t *)(mkva + (po_r & PAGE_MASK)); + po_r &= PAGE_MASK; + cmd = *(uint32_t *)(mkva + po_r); if (cmd != MI_BATCH_BUFFER_END) { /* @@ -1083,8 +1084,7 @@ i915_gem_fix_mi_batchbuffer_end(struct d po_w = po_r; DRM_DEBUG("batchbuffer does not end by MI_BATCH_BUFFER_END, overwriting last bo cmd !\n"); } - - *(uint32_t *)(mkva + (po_w & PAGE_MASK)) = MI_BATCH_BUFFER_END; + *(uint32_t *)(mkva + po_w) = MI_BATCH_BUFFER_END; } pmap_unmapdev((vm_offset_t)mkva, 2 * PAGE_SIZE); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 11 21:44:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54D4E106566B; Mon, 11 Jun 2012 21:44:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3FF4F8FC1B; Mon, 11 Jun 2012 21:44:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BLiPWf012260; Mon, 11 Jun 2012 21:44:25 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BLiP3a012258; Mon, 11 Jun 2012 21:44:25 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206112144.q5BLiP3a012258@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 11 Jun 2012 21:44:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236933 - stable/9/sys/dev/drm2/i915 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 21:44:25 -0000 Author: kib Date: Mon Jun 11 21:44:24 2012 New Revision: 236933 URL: http://svn.freebsd.org/changeset/base/236933 Log: MFC r236183: Disable end of buffer fixup by default. Modified: stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c ============================================================================== --- stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Mon Jun 11 21:43:17 2012 (r236932) +++ stable/9/sys/dev/drm2/i915/i915_gem_execbuffer.c Mon Jun 11 21:44:24 2012 (r236933) @@ -1090,7 +1090,7 @@ DRM_DEBUG("batchbuffer does not end by M pmap_unmapdev((vm_offset_t)mkva, 2 * PAGE_SIZE); } -int i915_fix_mi_batchbuffer_end = 1; +int i915_fix_mi_batchbuffer_end = 0; static int i915_reset_gen7_sol_offsets(struct drm_device *dev, From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 12 08:08:34 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 25BA2106564A; Tue, 12 Jun 2012 08:08:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 073278FC18; Tue, 12 Jun 2012 08:08:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5C88X4g038797; Tue, 12 Jun 2012 08:08:33 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5C88XWK038792; Tue, 12 Jun 2012 08:08:33 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206120808.q5C88XWK038792@svn.freebsd.org> From: Alexander Motin Date: Tue, 12 Jun 2012 08:08:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236947 - in stable/9/sys/dev: ahci ata mvs siis X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 08:08:34 -0000 Author: mav Date: Tue Jun 12 08:08:33 2012 New Revision: 236947 URL: http://svn.freebsd.org/changeset/base/236947 Log: MFC r236847: Partially revert r236666: Return PROTO_ATA protocol in response to XPT_PATH_INQ. smartmontools uses it to identify ATA devices and I don't know any other place now where it is important. It could probably use XPT_GDEV_TYPE instead for more accurate protocol information, but let it live for now. Modified: stable/9/sys/dev/ahci/ahci.c stable/9/sys/dev/ata/ata-all.c stable/9/sys/dev/mvs/mvs.c stable/9/sys/dev/siis/siis.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/ahci/ahci.c ============================================================================== --- stable/9/sys/dev/ahci/ahci.c Tue Jun 12 07:53:39 2012 (r236946) +++ stable/9/sys/dev/ahci/ahci.c Tue Jun 12 08:08:33 2012 (r236947) @@ -2967,7 +2967,7 @@ ahciaction(struct cam_sim *sim, union cc cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; - cpi->protocol = PROTO_UNSPECIFIED; + cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; /* ATI SB600 can't handle 256 sectors with FPDMA (NCQ). */ Modified: stable/9/sys/dev/ata/ata-all.c ============================================================================== --- stable/9/sys/dev/ata/ata-all.c Tue Jun 12 07:53:39 2012 (r236946) +++ stable/9/sys/dev/ata/ata-all.c Tue Jun 12 08:08:33 2012 (r236947) @@ -1875,7 +1875,7 @@ ataaction(struct cam_sim *sim, union ccb else cpi->transport = XPORT_ATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; - cpi->protocol = PROTO_UNSPECIFIED; + cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = ch->dma.max_iosize ? ch->dma.max_iosize : DFLTPHYS; if (device_get_devclass(device_get_parent(parent)) == Modified: stable/9/sys/dev/mvs/mvs.c ============================================================================== --- stable/9/sys/dev/mvs/mvs.c Tue Jun 12 07:53:39 2012 (r236946) +++ stable/9/sys/dev/mvs/mvs.c Tue Jun 12 08:08:33 2012 (r236947) @@ -2385,7 +2385,7 @@ mvsaction(struct cam_sim *sim, union ccb cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; - cpi->protocol = PROTO_UNSPECIFIED; + cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; if ((ch->quirks & MVS_Q_SOC) == 0) { Modified: stable/9/sys/dev/siis/siis.c ============================================================================== --- stable/9/sys/dev/siis/siis.c Tue Jun 12 07:53:39 2012 (r236946) +++ stable/9/sys/dev/siis/siis.c Tue Jun 12 08:08:33 2012 (r236947) @@ -1960,7 +1960,7 @@ siisaction(struct cam_sim *sim, union cc cpi->unit_number = cam_sim_unit(sim); cpi->transport = XPORT_SATA; cpi->transport_version = XPORT_VERSION_UNSPECIFIED; - cpi->protocol = PROTO_UNSPECIFIED; + cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = MAXPHYS; cpi->hba_vendor = pci_get_vendor(parent); From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 12 12:10:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE4071065672; Tue, 12 Jun 2012 12:10:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4AE5D8FC15; Tue, 12 Jun 2012 12:10:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5CCAC08052402; Tue, 12 Jun 2012 12:10:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5CCACFm052400; Tue, 12 Jun 2012 12:10:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201206121210.q5CCACFm052400@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 12 Jun 2012 12:10:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236953 - head/sys/amd64/amd64 releng/7.4 releng/7.4/contrib/bind9/lib/dns releng/7.4/sys/amd64/amd64 releng/7.4/sys/conf releng/8.1 releng/8.1/contrib/bind9/lib/dns releng/8.1/sys/amd6... X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 12:10:12 -0000 Author: bz Date: Tue Jun 12 12:10:10 2012 New Revision: 236953 URL: http://svn.freebsd.org/changeset/base/236953 Log: Fix a problem where zero-length RDATA fields can cause named(8) to crash. [12:03] Correct a privilege escalation when returning from kernel if running FreeBSD/amd64 on non-AMD processors. [12:04] Fix reference count errors in IPv6 code. [EN-12:02] Security: CVE-2012-1667 Security: FreeBSD-SA-12:03.bind Security: CVE-2012-0217 Security: FreeBSD-SA-12:04.sysret Security: FreeBSD-EN-12:02.ipv6refcount Approved by: so (simon, bz) Modified: stable/9/sys/amd64/amd64/trap.c Changes in other areas also in this revision: Modified: head/sys/amd64/amd64/trap.c releng/7.4/UPDATING releng/7.4/contrib/bind9/lib/dns/rdata.c releng/7.4/contrib/bind9/lib/dns/rdataslab.c releng/7.4/sys/amd64/amd64/trap.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/contrib/bind9/lib/dns/rdata.c releng/8.1/contrib/bind9/lib/dns/rdataslab.c releng/8.1/sys/amd64/amd64/trap.c releng/8.1/sys/conf/newvers.sh releng/8.1/sys/netinet/tcp_input.c releng/8.1/sys/netinet6/in6.c releng/8.1/sys/netinet6/ip6_input.c releng/8.2/UPDATING releng/8.2/contrib/bind9/lib/dns/rdata.c releng/8.2/contrib/bind9/lib/dns/rdataslab.c releng/8.2/sys/amd64/amd64/trap.c releng/8.2/sys/conf/newvers.sh releng/8.2/sys/netinet/tcp_input.c releng/8.2/sys/netinet6/in6.c releng/8.2/sys/netinet6/ip6_input.c releng/8.3/UPDATING releng/8.3/contrib/bind9/lib/dns/rdata.c releng/8.3/contrib/bind9/lib/dns/rdataslab.c releng/8.3/sys/amd64/amd64/trap.c releng/8.3/sys/conf/newvers.sh releng/8.3/sys/netinet/tcp_input.c releng/8.3/sys/netinet6/in6.c releng/8.3/sys/netinet6/ip6_input.c releng/9.0/UPDATING releng/9.0/contrib/bind9/lib/dns/rdata.c releng/9.0/contrib/bind9/lib/dns/rdataslab.c releng/9.0/sys/amd64/amd64/trap.c releng/9.0/sys/conf/newvers.sh releng/9.0/sys/netinet/tcp_input.c releng/9.0/sys/netinet6/in6.c releng/9.0/sys/netinet6/ip6_input.c stable/7/contrib/bind9/lib/dns/rdata.c stable/7/contrib/bind9/lib/dns/rdataslab.c stable/7/sys/amd64/amd64/trap.c stable/8/sys/amd64/amd64/trap.c Modified: stable/9/sys/amd64/amd64/trap.c ============================================================================== --- stable/9/sys/amd64/amd64/trap.c Tue Jun 12 11:08:51 2012 (r236952) +++ stable/9/sys/amd64/amd64/trap.c Tue Jun 12 12:10:10 2012 (r236953) @@ -977,4 +977,21 @@ amd64_syscall(struct thread *td, int tra syscallname(td->td_proc, sa.code))); syscallret(td, error, &sa); + + /* + * If the user-supplied value of %rip is not a canonical + * address, then some CPUs will trigger a ring 0 #GP during + * the sysret instruction. However, the fault handler would + * execute with the user's %gs and %rsp in ring 0 which would + * not be safe. Instead, preemptively kill the thread with a + * SIGBUS. + */ + if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)td->td_frame->tf_rip; + trapsignal(td, &ksi); + } } From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 12 20:01:29 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA8B31065674; Tue, 12 Jun 2012 20:01:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D56008FC17; Tue, 12 Jun 2012 20:01:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5CK1Tj8072829; Tue, 12 Jun 2012 20:01:29 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5CK1Tsb072826; Tue, 12 Jun 2012 20:01:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206122001.q5CK1Tsb072826@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 12 Jun 2012 20:01:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236969 - in stable/9/sys: i386/conf modules X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 20:01:30 -0000 Author: kib Date: Tue Jun 12 20:01:29 2012 New Revision: 236969 URL: http://svn.freebsd.org/changeset/base/236969 Log: MFC r235859: Enable drm2 modules build. Modified: stable/9/sys/i386/conf/XEN stable/9/sys/modules/Makefile Directory Properties: stable/9/sys/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/i386/conf/XEN ============================================================================== --- stable/9/sys/i386/conf/XEN Tue Jun 12 18:19:46 2012 (r236968) +++ stable/9/sys/i386/conf/XEN Tue Jun 12 20:01:29 2012 (r236969) @@ -7,7 +7,7 @@ cpu I686_CPU ident XEN makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions WITHOUT_MODULES="aha ahb amd cxgb dpt drm hptmv ida malo mps mwl nve sound sym trm xfs" +makeoptions WITHOUT_MODULES="aha ahb amd cxgb dpt drm drm2 hptmv ida malo mps mwl nve sound sym trm xfs" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption Modified: stable/9/sys/modules/Makefile ============================================================================== --- stable/9/sys/modules/Makefile Tue Jun 12 18:19:46 2012 (r236968) +++ stable/9/sys/modules/Makefile Tue Jun 12 20:01:29 2012 (r236969) @@ -84,6 +84,7 @@ SUBDIR= ${_3dfx} \ ${_dpms} \ ${_dpt} \ ${_drm} \ + ${_drm2} \ ${_dtrace} \ dummynet \ ${_ed} \ @@ -452,6 +453,7 @@ _cyclic= cyclic .endif _dpms= dpms _drm= drm +_drm2= drm2 .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _dtrace= dtrace .endif @@ -620,6 +622,7 @@ _cyclic= cyclic .endif _dpms= dpms _drm= drm +_drm2= drm2 .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _dtrace= dtrace .endif From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 12 20:04:24 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51ED4106564A; Tue, 12 Jun 2012 20:04:24 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C7B98FC0A; Tue, 12 Jun 2012 20:04:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5CK4ODB072980; Tue, 12 Jun 2012 20:04:24 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5CK4OMs072977; Tue, 12 Jun 2012 20:04:24 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201206122004.q5CK4OMs072977@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 12 Jun 2012 20:04:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236970 - stable/9/usr.sbin/daemon X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 20:04:24 -0000 Author: trociny Date: Tue Jun 12 20:04:23 2012 New Revision: 236970 URL: http://svn.freebsd.org/changeset/base/236970 Log: MFC r236550, r236551: r236550: On a child exit, call waitpid(2) to clean up the process table. Submitted by: Andrey Zonov r236551: Document -r option in SYNOPSIS and usage statement. Submitted by: Andrey Zonov Modified: stable/9/usr.sbin/daemon/daemon.8 stable/9/usr.sbin/daemon/daemon.c Directory Properties: stable/9/usr.sbin/daemon/ (props changed) Modified: stable/9/usr.sbin/daemon/daemon.8 ============================================================================== --- stable/9/usr.sbin/daemon/daemon.8 Tue Jun 12 20:01:29 2012 (r236969) +++ stable/9/usr.sbin/daemon/daemon.8 Tue Jun 12 20:04:23 2012 (r236970) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 19, 2012 +.Dd June 4, 2012 .Dt DAEMON 8 .Os .Sh NAME @@ -34,7 +34,7 @@ .Nd run detached from the controlling terminal .Sh SYNOPSIS .Nm -.Op Fl cf +.Op Fl cfr .Op Fl p Ar pidfile .Op Fl u Ar user .Ar command arguments ... Modified: stable/9/usr.sbin/daemon/daemon.c ============================================================================== --- stable/9/usr.sbin/daemon/daemon.c Tue Jun 12 20:01:29 2012 (r236969) +++ stable/9/usr.sbin/daemon/daemon.c Tue Jun 12 20:04:23 2012 (r236970) @@ -217,6 +217,10 @@ wait_child(pid_t pid, sigset_t *mask) } switch (signo) { case SIGCHLD: + if (waitpid(pid, NULL, WNOHANG) == -1) { + warn("waitpid"); + return (-1); + } return (terminate); case SIGTERM: terminate = 1; @@ -236,7 +240,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: daemon [-cf] [-p pidfile] [-u user] command " + "usage: daemon [-cfr] [-p pidfile] [-u user] command " "arguments ...\n"); exit(1); } From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 12 21:03:25 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7EB27106568E; Tue, 12 Jun 2012 21:03:25 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6933E8FC0C; Tue, 12 Jun 2012 21:03:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5CL3P4c075605; Tue, 12 Jun 2012 21:03:25 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5CL3PSY075603; Tue, 12 Jun 2012 21:03:25 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201206122103.q5CL3PSY075603@svn.freebsd.org> From: Dimitry Andric Date: Tue, 12 Jun 2012 21:03:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236975 - stable/9/sys/dev/aic7xxx/aicasm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 21:03:25 -0000 Author: dim Date: Tue Jun 12 21:03:24 2012 New Revision: 236975 URL: http://svn.freebsd.org/changeset/base/236975 Log: MFC r236578: Fix build of aicasm when CC=clang. This was due to a side-effect of the EARLY_BUILD macro: the -Qunused-arguments flag isn't passed anymore when building this particular program. However, with clang 3.1 and -Werror, such unused argument warnings are flagged as errors, causing buildkernel to fail at this stage, due to the -nostdinc flag passed during linking. Since the -nostdinc flag isn't actually needed, just remove it. Modified: stable/9/sys/dev/aic7xxx/aicasm/Makefile Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/aic7xxx/aicasm/Makefile ============================================================================== --- stable/9/sys/dev/aic7xxx/aicasm/Makefile Tue Jun 12 20:55:57 2012 (r236974) +++ stable/9/sys/dev/aic7xxx/aicasm/Makefile Tue Jun 12 21:03:24 2012 (r236975) @@ -24,8 +24,7 @@ WARNS?= 5 DEPENDFILE= .depend_aicasm .endif -NOSTDINC= -nostdinc -CFLAGS+= ${NOSTDINC} -I/usr/include -I. +CFLAGS+= -I. .ifdef MAKESRCPATH CFLAGS+= -I${MAKESRCPATH} .endif From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 00:12:48 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 00062106566C; Wed, 13 Jun 2012 00:12:47 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C4C7F8FC08; Wed, 13 Jun 2012 00:12:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D0ClAJ083895; Wed, 13 Jun 2012 00:12:47 GMT (envelope-from ache@svn.freebsd.org) Received: (from ache@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D0Clth083894; Wed, 13 Jun 2012 00:12:47 GMT (envelope-from ache@svn.freebsd.org) Message-Id: <201206130012.q5D0Clth083894@svn.freebsd.org> From: "Andrey A. Chernov" Date: Wed, 13 Jun 2012 00:12:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236978 - stable/9/lib/libc/stdlib X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 00:12:48 -0000 Author: ache Date: Wed Jun 13 00:12:47 2012 New Revision: 236978 URL: http://svn.freebsd.org/changeset/base/236978 Log: Forget to propogate mergeinfo to directories Modified: Directory Properties: stable/9/lib/libc/ (props changed) stable/9/lib/libc/stdlib/realpath.c (props changed) From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 03:18:48 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7497D106579D; Wed, 13 Jun 2012 03:18:48 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F0408FC0C; Wed, 13 Jun 2012 03:18:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D3Im8K092068; Wed, 13 Jun 2012 03:18:48 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D3ImAN092066; Wed, 13 Jun 2012 03:18:48 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206130318.q5D3ImAN092066@svn.freebsd.org> From: Eitan Adler Date: Wed, 13 Jun 2012 03:18:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236979 - stable/9/share/man/man5 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 03:18:48 -0000 Author: eadler Date: Wed Jun 13 03:18:47 2012 New Revision: 236979 URL: http://svn.freebsd.org/changeset/base/236979 Log: MFC r236290: Document daily_status_security_chkportsum_enable PR: docs/167980 Approved by: cperciva (implicit) Modified: stable/9/share/man/man5/periodic.conf.5 Directory Properties: stable/9/share/man/man5/ (props changed) Modified: stable/9/share/man/man5/periodic.conf.5 ============================================================================== --- stable/9/share/man/man5/periodic.conf.5 Wed Jun 13 00:12:47 2012 (r236978) +++ stable/9/share/man/man5/periodic.conf.5 Wed Jun 13 03:18:47 2012 (r236979) @@ -504,6 +504,12 @@ Set to .Dq Li YES to compare the modes and modification times of setuid executables with the previous day's values. +.It Va daily_status_security_chkportsum_enable +.Pq Vt bool +Set to +.Dq Li YES +to verify checksums of all installed packages against the known checksums in +.Pa /var/db/pkg . .It Va daily_status_security_neggrpperm_enable .Pq Vt bool Set to From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 03:34:43 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EDDD1065673; Wed, 13 Jun 2012 03:34:43 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 59CE38FC17; Wed, 13 Jun 2012 03:34:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D3Yhc9092916; Wed, 13 Jun 2012 03:34:43 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D3Yhdo092914; Wed, 13 Jun 2012 03:34:43 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206130334.q5D3Yhdo092914@svn.freebsd.org> From: Eitan Adler Date: Wed, 13 Jun 2012 03:34:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236983 - stable/9/lib/libc/stdio X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 03:34:43 -0000 Author: eadler Date: Wed Jun 13 03:34:42 2012 New Revision: 236983 URL: http://svn.freebsd.org/changeset/base/236983 Log: MFC r236288: Only set _w to 0 when the file stream is not currently reading. Without this fflush may fail to write data in the buffer. PR: kern/137819 Approved by: cperciva (implicit) Modified: stable/9/lib/libc/stdio/fpurge.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/stdio/fpurge.c ============================================================================== --- stable/9/lib/libc/stdio/fpurge.c Wed Jun 13 03:30:24 2012 (r236982) +++ stable/9/lib/libc/stdio/fpurge.c Wed Jun 13 03:34:42 2012 (r236983) @@ -62,7 +62,7 @@ fpurge(fp) FREEUB(fp); fp->_p = fp->_bf._base; fp->_r = 0; - fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; + fp->_w = fp->_flags & (__SLBF|__SNBF|__SRD) ? 0 : fp->_bf._size; retval = 0; } FUNLOCKFILE(fp); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 03:41:00 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 09AD31065674; Wed, 13 Jun 2012 03:41:00 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E8BBA8FC0A; Wed, 13 Jun 2012 03:40:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D3exNw093235; Wed, 13 Jun 2012 03:40:59 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D3exH6093233; Wed, 13 Jun 2012 03:40:59 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206130340.q5D3exH6093233@svn.freebsd.org> From: Eitan Adler Date: Wed, 13 Jun 2012 03:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236984 - stable/9/usr.bin/mail X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 03:41:00 -0000 Author: eadler Date: Wed Jun 13 03:40:59 2012 New Revision: 236984 URL: http://svn.freebsd.org/changeset/base/236984 Log: MFC r236286: Fix likely race condition if wait_child() is interrupted by sigchild() PR: bin/102834 Approved by: cperciva (implicit) Modified: stable/9/usr.bin/mail/popen.c Directory Properties: stable/9/usr.bin/mail/ (props changed) Modified: stable/9/usr.bin/mail/popen.c ============================================================================== --- stable/9/usr.bin/mail/popen.c Wed Jun 13 03:34:42 2012 (r236983) +++ stable/9/usr.bin/mail/popen.c Wed Jun 13 03:40:59 2012 (r236984) @@ -336,12 +336,14 @@ int wait_child(int pid) { sigset_t nset, oset; - struct child *cp = findchild(pid); + struct child *cp; (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGCHLD); (void)sigprocmask(SIG_BLOCK, &nset, &oset); + cp = findchild(pid); + while (!cp->done) (void)sigsuspend(&oset); wait_status = cp->status; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 06:42:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9DAD0106568A; Wed, 13 Jun 2012 06:42:36 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 8890B8FC18; Wed, 13 Jun 2012 06:42:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D6gaaY001894; Wed, 13 Jun 2012 06:42:36 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D6ga9v001892; Wed, 13 Jun 2012 06:42:36 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201206130642.q5D6ga9v001892@svn.freebsd.org> From: Fabien Thomas Date: Wed, 13 Jun 2012 06:42:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236998 - stable/9/usr.sbin/pmcstat X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 06:42:36 -0000 Author: fabient Date: Wed Jun 13 06:42:36 2012 New Revision: 236998 URL: http://svn.freebsd.org/changeset/base/236998 Log: MFC r236669: Remove spurious ARM symbols from lookup table. Modified: stable/9/usr.sbin/pmcstat/pmcstat_log.c Directory Properties: stable/9/usr.sbin/pmcstat/ (props changed) Modified: stable/9/usr.sbin/pmcstat/pmcstat_log.c ============================================================================== --- stable/9/usr.sbin/pmcstat/pmcstat_log.c Wed Jun 13 06:38:25 2012 (r236997) +++ stable/9/usr.sbin/pmcstat/pmcstat_log.c Wed Jun 13 06:42:36 2012 (r236998) @@ -554,6 +554,14 @@ pmcstat_image_add_symbols(struct pmcstat if ((fnname = elf_strptr(e, sh->sh_link, sym.st_name)) == NULL) continue; +#ifdef __arm__ + /* Remove spurious ARM function name. */ + if (fnname[0] == '$' && + (fnname[1] == 'a' || fnname[1] == 't' || + fnname[1] == 'd') && + fnname[2] == '\0') + continue; +#endif symptr->ps_name = pmcstat_string_intern(fnname); symptr->ps_start = sym.st_value - image->pi_vaddr; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 14:47:03 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B61A21065677; Wed, 13 Jun 2012 14:47:03 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 9FE4E8FC15; Wed, 13 Jun 2012 14:47:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5DEl3cj030491; Wed, 13 Jun 2012 14:47:03 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5DEl3Dk030488; Wed, 13 Jun 2012 14:47:03 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201206131447.q5DEl3Dk030488@svn.freebsd.org> From: Sergey Kandaurov Date: Wed, 13 Jun 2012 14:47:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237007 - stable/9/share/man/man9 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 14:47:03 -0000 Author: pluknet Date: Wed Jun 13 14:47:03 2012 New Revision: 237007 URL: http://svn.freebsd.org/changeset/base/237007 Log: MFC r234188,r234463,r234465: - Update the swi_add prototype after struct ithd was split up into struct intr_event and struct intr_thread. [1] - Update the rest of struct ithd references. - net_ih and softclock_ih cookies have gone away. - Document swi_remove(9). PR: docs/166864 [1] Modified: stable/9/share/man/man9/Makefile stable/9/share/man/man9/swi.9 Directory Properties: stable/9/share/man/man9/ (props changed) Modified: stable/9/share/man/man9/Makefile ============================================================================== --- stable/9/share/man/man9/Makefile Wed Jun 13 11:59:47 2012 (r237006) +++ stable/9/share/man/man9/Makefile Wed Jun 13 14:47:03 2012 (r237007) @@ -1245,6 +1245,7 @@ MLINKS+=store.9 subyte.9 \ store.9 suword32.9 \ store.9 suword64.9 MLINKS+=swi.9 swi_add.9 \ + swi.9 swi_remove.9 \ swi.9 swi_sched.9 MLINKS+=sx.9 sx_assert.9 \ sx.9 sx_destroy.9 \ Modified: stable/9/share/man/man9/swi.9 ============================================================================== --- stable/9/share/man/man9/swi.9 Wed Jun 13 11:59:47 2012 (r237006) +++ stable/9/share/man/man9/swi.9 Wed Jun 13 14:47:03 2012 (r237007) @@ -24,25 +24,24 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2000 +.Dd April 19, 2012 .Dt SWI 9 .Os .Sh NAME .Nm swi_add , +.Nm swi_remove , .Nm swi_sched .Nd register and schedule software interrupt handlers .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .In sys/interrupt.h -.Vt "extern struct ithd *tty_ithd" ; -.Vt "extern struct ithd *clk_ithd" ; -.Vt "extern void *net_ih" ; -.Vt "extern void *softclock_ih" ; +.Vt "extern struct intr_event *tty_intr_event" ; +.Vt "extern struct intr_event *clk_intr_event" ; .Vt "extern void *vm_ih" ; .Ft int .Fo swi_add -.Fa "struct ithd **ithdp" +.Fa "struct intr_event **eventp" .Fa "const char *name" .Fa "driver_intr_t handler" .Fa "void *arg" @@ -50,6 +49,8 @@ .Fa "enum intr_type flags" .Fa "void **cookiep" .Fc +.Ft int +.Fn swi_remove "void *cookie" .Ft void .Fn swi_sched "void *cookie" "int flags" .Sh DESCRIPTION @@ -67,20 +68,21 @@ time, and that they can be run via a lig .Pp The .Fn swi_add -function is used to register a new software interrupt handler. +function is used to add a new software interrupt handler to a specified +interrupt event. The -.Fa ithdp +.Fa eventp argument is an optional pointer to a -.Vt struct ithd +.Vt struct intr_event pointer. -If this argument points to an existing software interrupt thread, then this -handler will be attached to that thread. -Otherwise a new thread will be created, and if -.Fa ithdp +If this argument points to an existing event that holds a list of +interrupt handlers, then this handler will be attached to that event. +Otherwise a new event will be created, and if +.Fa eventp is not .Dv NULL , then the pointer at that address to will be modified to point to the -newly created thread. +newly created event. The .Fa name argument is used to associate a name with a specific handler. @@ -99,7 +101,7 @@ The .Fa pri value specifies the priority of this interrupt handler relative to other software interrupt handlers. -If an interrupt thread is created, then this value is used as the vector, +If an interrupt event is created, then this value is used as the vector, and the .Fa flags argument is used to specify the attributes of a handler such as @@ -113,6 +115,14 @@ This cookie will be set to a value that and is used to schedule the handler for execution later on. .Pp The +.Fn swi_remove +function is used to teardown an interrupt handler pointed to by the +.Fa cookie +argument. +It detaches the interrupt handler from the associated interrupt event +and frees its memory. +.Pp +The .Fn swi_sched function is used to schedule an interrupt handler and its associated thread to run. @@ -140,30 +150,29 @@ in earlier versions of .El .Pp The -.Va tty_ithd +.Va tty_intr_event and -.Va clk_ithd -variables contain pointers to the software interrupt threads for the tty and +.Va clk_intr_event +variables contain pointers to the software interrupt handlers for the tty and clock software interrupts, respectively. -.Va tty_ithd +.Va tty_intr_event is used to hang tty software interrupt handlers off of the same thread. -.Va clk_ithd +.Va clk_intr_event is used to hang delayed handlers off of the clock software interrupt thread so that the functionality of .Fn setdelayed can be obtained in conjunction with .Dv SWI_DELAY . The -.Va net_ih , -.Va softclock_ih , -and .Va vm_ih -handler cookies are used to schedule software interrupt threads to run for the -networking stack, clock interrupt, and VM subsystem respectively. +handler cookie is used to schedule software interrupt threads to run for the +VM subsystem. .Sh RETURN VALUES The .Fn swi_add -function returns zero on success and non-zero on failure. +and +.Fn swi_remove +functions return zero on success and non-zero on failure. .Sh ERRORS The .Fn swi_add @@ -183,7 +192,7 @@ argument specifies .Dv INTR_ENTROPY . .It Bq Er EINVAL The -.Fa ithdp +.Fa eventp argument points to a hardware interrupt thread. .It Bq Er EINVAL Either of the @@ -195,11 +204,22 @@ arguments are .It Bq Er EINVAL The .Dv INTR_EXCL -flag is specified and the interrupt thread pointed to by -.Fa ithdp -already has at least one handler, or the interrupt thread already has an +flag is specified and the interrupt event pointed to by +.Fa eventp +already has at least one handler, or the interrupt event already has an exclusive handler. .El +.Pp +The +.Fn swi_remove +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +A software interrupt handler pointed to by +.Fa cookie +is +.Dv NULL . +.El .Sh SEE ALSO .Xr ithread 9 , .Xr taskqueue 9 @@ -220,6 +240,10 @@ and .Fn schedsoft* functions which date back to at least .Bx 4.4 . +The +.Fn swi_remove +function first appeared in +.Fx 6.1 . .Sh BUGS Most of the global variables described in this manual page should not be global, or at the very least should not be declared in From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 19:04:40 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B0591065670; Wed, 13 Jun 2012 19:04:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 152D28FC08; Wed, 13 Jun 2012 19:04:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5DJ4dZn042927; Wed, 13 Jun 2012 19:04:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5DJ4dOX042925; Wed, 13 Jun 2012 19:04:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206131904.q5DJ4dOX042925@svn.freebsd.org> From: John Baldwin Date: Wed, 13 Jun 2012 19:04:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237017 - stable/9/lib/libc/stdlib X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 19:04:40 -0000 Author: jhb Date: Wed Jun 13 19:04:39 2012 New Revision: 237017 URL: http://svn.freebsd.org/changeset/base/237017 Log: Ensure that the beginning of the DSS is aligned on a chunk boundary. If the _end symbol used an address with the low bit set, then the initial arena could end up with corrupted rb trees causing a crash during the first call to malloc(). This is a direct commit to stable/9 as it does not affect the version of malloc in HEAD. Reviewed by: jasone MFC after: 1 week Modified: stable/9/lib/libc/stdlib/malloc.c Modified: stable/9/lib/libc/stdlib/malloc.c ============================================================================== --- stable/9/lib/libc/stdlib/malloc.c Wed Jun 13 19:00:29 2012 (r237016) +++ stable/9/lib/libc/stdlib/malloc.c Wed Jun 13 19:04:39 2012 (r237017) @@ -5790,6 +5790,9 @@ MALLOC_OUT: #ifdef MALLOC_DSS malloc_mutex_init(&dss_mtx); dss_base = sbrk(0); + i = (uintptr_t)dss_base & QUANTUM_MASK; + if (i != 0) + dss_base = sbrk(QUANTUM - i); dss_prev = dss_base; dss_max = dss_base; extent_tree_szad_new(&dss_chunks_szad); From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 19:53:30 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 00E25106566C; Wed, 13 Jun 2012 19:53:30 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id E0A338FC14; Wed, 13 Jun 2012 19:53:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5DJrTbX045164; Wed, 13 Jun 2012 19:53:29 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5DJrTSt045162; Wed, 13 Jun 2012 19:53:29 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201206131953.q5DJrTSt045162@svn.freebsd.org> From: Dimitry Andric Date: Wed, 13 Jun 2012 19:53:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237019 - stable/9 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 19:53:30 -0000 Author: dim Date: Wed Jun 13 19:53:29 2012 New Revision: 237019 URL: http://svn.freebsd.org/changeset/base/237019 Log: MFC r233098: Make sure libgcc_s is finished building in _startup_libs before building libcxxrt with high -j levels. The workaround in libc++/Makefile isn't necessary once that race is solved. Reviewed by: theraven Modified: stable/9/Makefile.inc1 (contents, props changed) Modified: stable/9/Makefile.inc1 ============================================================================== --- stable/9/Makefile.inc1 Wed Jun 13 19:08:00 2012 (r237018) +++ stable/9/Makefile.inc1 Wed Jun 13 19:53:29 2012 (r237019) @@ -1244,6 +1244,9 @@ _startup_libs+= lib/libcxxrt .endif gnu/lib/libgcc__L: lib/libc__L +.if ${MK_LIBCPLUSPLUS} != "no" +lib/libcxxrt__L: gnu/lib/libgcc__L +.endif _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libhdb} \ ${_kerberos5_lib_libheimntlm} \ From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 13 20:31:30 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E9171065672; Wed, 13 Jun 2012 20:31:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 780598FC16; Wed, 13 Jun 2012 20:31:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5DKVUUh047022; Wed, 13 Jun 2012 20:31:30 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5DKVUqT047020; Wed, 13 Jun 2012 20:31:30 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206132031.q5DKVUqT047020@svn.freebsd.org> From: Alexander Motin Date: Wed, 13 Jun 2012 20:31:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237023 - stable/9/lib/libc/arm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 20:31:30 -0000 Author: mav Date: Wed Jun 13 20:31:30 2012 New Revision: 237023 URL: http://svn.freebsd.org/changeset/base/237023 Log: MFC r230188i (by das): Correct some bugs that resulted from arm/_fpmath.h being blindly copied from the x86 version, which has a completely different long double format. Modified: stable/9/lib/libc/arm/_fpmath.h Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/arm/_fpmath.h ============================================================================== --- stable/9/lib/libc/arm/_fpmath.h Wed Jun 13 20:30:25 2012 (r237022) +++ stable/9/lib/libc/arm/_fpmath.h Wed Jun 13 20:31:30 2012 (r237023) @@ -55,9 +55,10 @@ union IEEEl2bits { }; #define LDBL_NBIT 0 +#define LDBL_IMPLICIT_NBIT #define mask_nbit_l(u) ((void)0) -#define LDBL_MANH_SIZE 32 +#define LDBL_MANH_SIZE 20 #define LDBL_MANL_SIZE 32 #define LDBL_TO_ARRAY32(u, a) do { \ From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 06:26:58 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6F4B106564A; Thu, 14 Jun 2012 06:26:58 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id BFFE28FC0A; Thu, 14 Jun 2012 06:26:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E6QwEd074769; Thu, 14 Jun 2012 06:26:58 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E6QwJs074766; Thu, 14 Jun 2012 06:26:58 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206140626.q5E6QwJs074766@svn.freebsd.org> From: Eitan Adler Date: Thu, 14 Jun 2012 06:26:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237047 - stable/9/sbin/mca X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 06:26:59 -0000 Author: eadler Date: Thu Jun 14 06:26:58 2012 New Revision: 237047 URL: http://svn.freebsd.org/changeset/base/237047 Log: MFC r236355: Fix a variety of compile errors with gcc48 and clang PR: bin/165699 Approved by: cperciva (implicit) Modified: stable/9/sbin/mca/Makefile stable/9/sbin/mca/mca.c Directory Properties: stable/9/sbin/mca/ (props changed) Modified: stable/9/sbin/mca/Makefile ============================================================================== --- stable/9/sbin/mca/Makefile Thu Jun 14 04:24:13 2012 (r237046) +++ stable/9/sbin/mca/Makefile Thu Jun 14 06:26:58 2012 (r237047) @@ -1,6 +1,5 @@ # $FreeBSD$ PROG= mca -WARNS?= 4 MAN= mca.8 .include Modified: stable/9/sbin/mca/mca.c ============================================================================== --- stable/9/sbin/mca/mca.c Thu Jun 14 04:24:13 2012 (r237046) +++ stable/9/sbin/mca/mca.c Thu Jun 14 06:26:58 2012 (r237047) @@ -55,10 +55,10 @@ __FBSDID("$FreeBSD$"); #define HW_MCA_MAX_CPUID 255 -static char hw_mca_count[] = "hw.mca.count"; -static char hw_mca_first[] = "hw.mca.first"; -static char hw_mca_last[] = "hw.mca.last"; -static char hw_mca_recid[] = "hw.mca.%lu.%u"; +static const char hw_mca_count[] = "hw.mca.count"; +static const char hw_mca_first[] = "hw.mca.first"; +static const char hw_mca_last[] = "hw.mca.last"; +static const char hw_mca_recid[] = "hw.mca.%d.%u"; static char default_dumpfile[] = "/var/log/mca.log"; @@ -162,7 +162,9 @@ show_cpu(struct mca_cpu_record *cpu) char var[16]; struct mca_cpu_mod *mod; struct mca_cpu_cpuid *cpuid; +#ifdef notyet struct mca_cpu_psi *psi; +#endif int i, n; printf(" \n"); @@ -200,8 +202,10 @@ show_cpu(struct mca_cpu_record *cpu) show_value(6, var, "0x%016llx", (long long)cpuid->cpuid[i]); } - psi = (struct mca_cpu_psi*)(cpuid + 1); - /* TODO: Dump PSI */ +#ifdef notyet + psi = (struct mca_cpu_psi*)(cpuid + 1); +#endif + /* TODO: Dump PSI */ printf(" \n"); } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 06:54:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1C1A71065688; Thu, 14 Jun 2012 06:54:36 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 06C088FC0A; Thu, 14 Jun 2012 06:54:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E6sZFt076614; Thu, 14 Jun 2012 06:54:35 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E6sZAb076612; Thu, 14 Jun 2012 06:54:35 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206140654.q5E6sZAb076612@svn.freebsd.org> From: Eitan Adler Date: Thu, 14 Jun 2012 06:54:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237048 - stable/9/usr.sbin/mptutil X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 06:54:36 -0000 Author: eadler Date: Thu Jun 14 06:54:35 2012 New Revision: 237048 URL: http://svn.freebsd.org/changeset/base/237048 Log: MFC r236287: add missing variable declaration when DEBUG is defined forgotten in r215046 PR: bin/166404 Approved by: cperciva (implicit) Modified: stable/9/usr.sbin/mptutil/mpt_show.c Directory Properties: stable/9/usr.sbin/mptutil/ (props changed) Modified: stable/9/usr.sbin/mptutil/mpt_show.c ============================================================================== --- stable/9/usr.sbin/mptutil/mpt_show.c Thu Jun 14 06:26:58 2012 (r237047) +++ stable/9/usr.sbin/mptutil/mpt_show.c Thu Jun 14 06:54:35 2012 (r237048) @@ -538,7 +538,7 @@ show_physdisks(int ac, char **av) { CONFIG_PAGE_RAID_PHYS_DISK_0 *pinfo; U16 IOCStatus; - int fd, i; + int error, fd, i; if (ac != 1) { warnx("show drives: extra arguments"); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 07:40:18 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA72A106564A; Thu, 14 Jun 2012 07:40:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id B47BF8FC0C; Thu, 14 Jun 2012 07:40:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E7eIFr078863; Thu, 14 Jun 2012 07:40:18 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E7eIBx078861; Thu, 14 Jun 2012 07:40:18 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206140740.q5E7eIBx078861@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 14 Jun 2012 07:40:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237053 - stable/9/sys/contrib/pf/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 07:40:18 -0000 Author: glebius Date: Thu Jun 14 07:40:18 2012 New Revision: 237053 URL: http://svn.freebsd.org/changeset/base/237053 Log: Merge r236671 from head: Merge revision 1.715 from OpenBSD: date: 2010/12/24 20:12:56; author: henning; state: Exp; lines: +3 -3 in pf_src_connlimit, the indices to sk->addr were swapped. tracked down and diff sent by Robert B Mills thanks, very good work! ok claudio Impact is that the "flush" keyword didn't work. Obtained from: OpenBSD Modified: stable/9/sys/contrib/pf/net/pf.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/contrib/pf/ (props changed) Modified: stable/9/sys/contrib/pf/net/pf.c ============================================================================== --- stable/9/sys/contrib/pf/net/pf.c Thu Jun 14 07:12:41 2012 (r237052) +++ stable/9/sys/contrib/pf/net/pf.c Thu Jun 14 07:40:18 2012 (r237053) @@ -643,10 +643,10 @@ pf_src_connlimit(struct pf_state **state (*state)->key[PF_SK_WIRE]->af && (((*state)->direction == PF_OUT && PF_AEQ(&(*state)->src_node->addr, - &sk->addr[0], sk->af)) || + &sk->addr[1], sk->af)) || ((*state)->direction == PF_IN && PF_AEQ(&(*state)->src_node->addr, - &sk->addr[1], sk->af))) && + &sk->addr[0], sk->af))) && ((*state)->rule.ptr->flush & PF_FLUSH_GLOBAL || (*state)->rule.ptr == st->rule.ptr)) { From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 07:51:38 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 353D7106564A; Thu, 14 Jun 2012 07:51:38 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 1F80B8FC0A; Thu, 14 Jun 2012 07:51:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E7pb34079425; Thu, 14 Jun 2012 07:51:37 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E7pb1T079423; Thu, 14 Jun 2012 07:51:37 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206140751.q5E7pb1T079423@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 14 Jun 2012 07:51:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237054 - stable/9/sys/kern X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 07:51:38 -0000 Author: glebius Date: Thu Jun 14 07:51:37 2012 New Revision: 237054 URL: http://svn.freebsd.org/changeset/base/237054 Log: Merge 236560 and following 236563,236598 from head: Optimise kern_sendfile(): skip cycling through the entire mbuf chain in m_cat(), storing pointer to last mbuf in chain in local variable and attaching new mbuf to the end of chain. Submitter reports that CPU load dropped for > 10% on a web server serving large files with this optimisation. Submitted by: Sergey Budnevitch Modified: stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Thu Jun 14 07:40:18 2012 (r237053) +++ stable/9/sys/kern/uipc_syscalls.c Thu Jun 14 07:51:37 2012 (r237054) @@ -1962,6 +1962,7 @@ kern_sendfile(struct thread *td, struct * and takes care of the overall progress. */ for (off = uap->offset, rem = uap->nbytes; ; ) { + struct mbuf *mtail = NULL; int loopbytes = 0; int space = 0; int done = 0; @@ -2181,10 +2182,13 @@ retry_space: m0->m_len = xfsize; /* Append to mbuf chain. */ - if (m != NULL) - m_cat(m, m0); + if (mtail != NULL) + mtail->m_next = m0; + else if (m != NULL) + m_last(m)->m_next = m0; else m = m0; + mtail = m0; /* Keep track of bits processed. */ loopbytes += xfsize; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 15:39:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 588F51065678; Thu, 14 Jun 2012 15:39:15 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 43CAC8FC17; Thu, 14 Jun 2012 15:39:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EFdF8r003282; Thu, 14 Jun 2012 15:39:15 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EFdFSR003280; Thu, 14 Jun 2012 15:39:15 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <201206141539.q5EFdFSR003280@svn.freebsd.org> From: Maksim Yevmenkin Date: Thu, 14 Jun 2012 15:39:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237078 - stable/9/contrib/bsnmp/snmp_mibII X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 15:39:15 -0000 Author: emax Date: Thu Jun 14 15:39:14 2012 New Revision: 237078 URL: http://svn.freebsd.org/changeset/base/237078 Log: MFC r236693 Count both IPv4 and IPv6 TCP connections in tcpCurrEstab Timeout from: current, syrinx Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII_tcp.c Directory Properties: stable/9/contrib/bsnmp/ (props changed) Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII_tcp.c ============================================================================== --- stable/9/contrib/bsnmp/snmp_mibII/mibII_tcp.c Thu Jun 14 15:37:15 2012 (r237077) +++ stable/9/contrib/bsnmp/snmp_mibII/mibII_tcp.c Thu Jun 14 15:39:14 2012 (r237078) @@ -109,10 +109,12 @@ fetch_tcp(void) ptr = (struct xinpgen *)(void *)((char *)ptr + ptr->xig_len)) { tp = (struct xtcpcb *)ptr; if (tp->xt_inp.inp_gencnt > xinpgen->xig_gen || - (tp->xt_inp.inp_vflag & INP_IPV4) == 0) + (tp->xt_inp.inp_vflag & (INP_IPV4|INP_IPV6)) == 0) continue; - tcp_total++; + if (tp->xt_inp.inp_vflag & INP_IPV4) + tcp_total++; + if (tp->xt_tp.t_state == TCPS_ESTABLISHED || tp->xt_tp.t_state == TCPS_CLOSE_WAIT) tcp_count++; From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 18:16:36 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3183A106564A; Thu, 14 Jun 2012 18:16:36 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 1BE8B8FC0C; Thu, 14 Jun 2012 18:16:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EIGZQG010792; Thu, 14 Jun 2012 18:16:35 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EIGZaX010790; Thu, 14 Jun 2012 18:16:35 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206141816.q5EIGZaX010790@svn.freebsd.org> From: Martin Matuska Date: Thu, 14 Jun 2012 18:16:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237088 - stable/9/lib/libc/locale X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 18:16:36 -0000 Author: mm Date: Thu Jun 14 18:16:35 2012 New Revision: 237088 URL: http://svn.freebsd.org/changeset/base/237088 Log: MFC r236889 (theraven): Fix a leak when setting the global character locale to "C" from something else. Reported by: mm (myself) Approved by: theraven (IRC) Modified: stable/9/lib/libc/locale/setrunelocale.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/locale/setrunelocale.c ============================================================================== --- stable/9/lib/libc/locale/setrunelocale.c Thu Jun 14 17:54:52 2012 (r237087) +++ stable/9/lib/libc/locale/setrunelocale.c Thu Jun 14 18:16:35 2012 (r237088) @@ -89,6 +89,17 @@ const _RuneLocale *__getCurrentRuneLocal return XLOCALE_CTYPE(__get_locale())->runes; } +static void free_runes(_RuneLocale *rl) +{ + /* FIXME: The "EUC" check here is a hideous abstraction violation. */ + if ((rl != &_DefaultRuneLocale) && (rl)) { + if (strcmp(rl->__encoding, "EUC") == 0) { + free(rl->__variable); + } + free(rl); + } +} + static int __setrunelocale(struct xlocale_ctype *l, const char *encoding) { @@ -102,6 +113,7 @@ __setrunelocale(struct xlocale_ctype *l, * The "C" and "POSIX" locale are always here. */ if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) { + free_runes(saved.runes); (void) _none_init(l, (_RuneLocale*)&_DefaultRuneLocale); return (0); } @@ -153,13 +165,7 @@ __setrunelocale(struct xlocale_ctype *l, if (ret == 0) { /* Free the old runes if it exists. */ - /* FIXME: The "EUC" check here is a hideous abstraction violation. */ - if ((saved.runes != &_DefaultRuneLocale) && (saved.runes)) { - if (strcmp(saved.runes->__encoding, "EUC") == 0) { - free(saved.runes->__variable); - } - free(saved.runes); - } + free_runes(saved.runes); } else { /* Restore the saved version if this failed. */ memcpy(l, &saved, sizeof(struct xlocale_ctype)); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 19:55:19 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3AE31065670; Thu, 14 Jun 2012 19:55:19 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id BD9238FC14; Thu, 14 Jun 2012 19:55:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EJtJp9015432; Thu, 14 Jun 2012 19:55:19 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EJtJFh015430; Thu, 14 Jun 2012 19:55:19 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206141955.q5EJtJFh015430@svn.freebsd.org> From: Marius Strobl Date: Thu, 14 Jun 2012 19:55:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237091 - stable/9/sys/boot/ofw/libofw X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 19:55:20 -0000 Author: marius Date: Thu Jun 14 19:55:19 2012 New Revision: 237091 URL: http://svn.freebsd.org/changeset/base/237091 Log: MFC: r236579 The workaround added in r151650 for handling firmwares that don't allow a single device to be opened multiple times concurrently unfortunately isn't sufficient with ZFS. This is due to the fact, that ZFS may open different partitions of a single device simultaneously. So the best we can do in this case is to cache the lastly used device path and close and open devices in ofwd_strategy() as needed. PR: 165025 Submitted by: Gavin Mu Modified: stable/9/sys/boot/ofw/libofw/ofw_disk.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/boot/ofw/libofw/ofw_disk.c ============================================================================== --- stable/9/sys/boot/ofw/libofw/ofw_disk.c Thu Jun 14 19:30:31 2012 (r237090) +++ stable/9/sys/boot/ofw/libofw/ofw_disk.c Thu Jun 14 19:55:19 2012 (r237091) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); */ #include -#include #include @@ -43,8 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libofw.h" static int ofwd_init(void); -static int ofwd_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); +static int ofwd_strategy(void *devdata, int flag, daddr_t dblk, + size_t size, char *buf, size_t *rsize); static int ofwd_open(struct open_file *f, ...); static int ofwd_close(struct open_file *f); static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data); @@ -61,120 +60,109 @@ struct devsw ofwdisk = { ofwd_print }; -struct opened_dev { - ihandle_t handle; - u_int count; - SLIST_ENTRY(opened_dev) link; -}; - -SLIST_HEAD(, opened_dev) opened_devs = SLIST_HEAD_INITIALIZER(opened_devs); +/* + * We're not guaranteed to be able to open a device more than once and there + * is no OFW standard method to determine whether a device is already opened. + * Opening a device multiple times simultaneously happens to work with most + * OFW block device drivers but triggers a trap with at least the driver for + * the on-board controllers of Sun Fire V100 and Ultra 1. Upper layers and MI + * code expect to be able to open a device more than once however. Given that + * different partitions of the same device might be opened at the same time as + * done by ZFS, we can't generally just keep track of the opened devices and + * reuse the instance handle when asked to open an already opened device. So + * the best we can do is to cache the lastly used device path and close and + * open devices in ofwd_strategy() as needed. + */ +static struct ofw_devdesc *kdp; static int ofwd_init(void) { - return 0; + return (0); } static int -ofwd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, - size_t *rsize) +ofwd_strategy(void *devdata, int flag __unused, daddr_t dblk, size_t size, + char *buf, size_t *rsize) { struct ofw_devdesc *dp = (struct ofw_devdesc *)devdata; daddr_t pos; int n; + if (dp != kdp) { + if (kdp != NULL) { +#if !defined(__powerpc__) + OF_close(kdp->d_handle); +#endif + kdp = NULL; + } + if ((dp->d_handle = OF_open(dp->d_path)) == -1) + return (ENOENT); + kdp = dp; + } + pos = dblk * 512; do { if (OF_seek(dp->d_handle, pos) < 0) - return EIO; + return (EIO); n = OF_read(dp->d_handle, buf, size); if (n < 0 && n != -2) - return EIO; + return (EIO); } while (n == -2); *rsize = size; - return 0; + return (0); } static int ofwd_open(struct open_file *f, ...) { - char path[256]; struct ofw_devdesc *dp; - struct opened_dev *odp; va_list vl; va_start(vl, f); dp = va_arg(vl, struct ofw_devdesc *); va_end(vl); - /* - * We're not guaranteed to be able to open a device more than once - * simultaneously and there is no OFW standard method to determine - * whether a device is already opened. Opening a device more than - * once happens to work with most OFW block device drivers but - * triggers a trap with at least the driver for the on-board SCSI - * controller in Sun Ultra 1. Upper layers and MI code expect to - * be able to open a device more than once however. As a workaround - * keep track of the opened devices and reuse the instance handle - * when asked to open an already opened device. - */ - SLIST_FOREACH(odp, &opened_devs, link) { - if (OF_instance_to_path(odp->handle, path, sizeof(path)) == -1) - continue; - if (strcmp(path, dp->d_path) == 0) { - odp->count++; - dp->d_handle = odp->handle; - return 0; + + if (dp != kdp) { + if (kdp != NULL) { + OF_close(kdp->d_handle); + kdp = NULL; } + if ((dp->d_handle = OF_open(dp->d_path)) == -1) { + printf("%s: Could not open %s\n", __func__, + dp->d_path); + return (ENOENT); + } + kdp = dp; } - odp = malloc(sizeof(struct opened_dev)); - if (odp == NULL) { - printf("ofwd_open: malloc failed\n"); - return ENOMEM; - } - if ((odp->handle = OF_open(dp->d_path)) == -1) { - printf("ofwd_open: Could not open %s\n", dp->d_path); - free(odp); - return ENOENT; - } - odp->count = 1; - SLIST_INSERT_HEAD(&opened_devs, odp, link); - dp->d_handle = odp->handle; - return 0; + return (0); } static int ofwd_close(struct open_file *f) { struct ofw_devdesc *dev = f->f_devdata; - struct opened_dev *odp; - SLIST_FOREACH(odp, &opened_devs, link) { - if (odp->handle == dev->d_handle) { - odp->count--; - if (odp->count == 0) { - SLIST_REMOVE(&opened_devs, odp, opened_dev, - link); - #if !defined(__powerpc__) - OF_close(odp->handle); - #endif - free(odp); - } - break; - } + if (dev == kdp) { +#if !defined(__powerpc__) + OF_close(dev->d_handle); +#endif + kdp = NULL; } - return 0; + return (0); } static int -ofwd_ioctl(struct open_file *f, u_long cmd, void *data) +ofwd_ioctl(struct open_file *f __unused, u_long cmd __unused, + void *data __unused) { return (EINVAL); } static void -ofwd_print(int verbose) +ofwd_print(int verbose __unused) { } From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 20:02:54 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13B6E106566C; Thu, 14 Jun 2012 20:02:54 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id F12998FC1A; Thu, 14 Jun 2012 20:02:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EK2rWN015972; Thu, 14 Jun 2012 20:02:53 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EK2rSU015963; Thu, 14 Jun 2012 20:02:53 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206142002.q5EK2rSU015963@svn.freebsd.org> From: Marius Strobl Date: Thu, 14 Jun 2012 20:02:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237093 - in stable/9/sys/arm: at91 econa X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 20:02:54 -0000 Author: marius Date: Thu Jun 14 20:02:53 2012 New Revision: 237093 URL: http://svn.freebsd.org/changeset/base/237093 Log: MFC: r225882 Remove pointless semicolons after label Modified: stable/9/sys/arm/at91/at91_mci.c stable/9/sys/arm/at91/at91_pio.c stable/9/sys/arm/at91/at91_rtc.c stable/9/sys/arm/at91/at91_spi.c stable/9/sys/arm/at91/at91_ssc.c stable/9/sys/arm/at91/at91_twi.c stable/9/sys/arm/at91/uart_dev_at91usart.c stable/9/sys/arm/econa/if_ece.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/arm/at91/at91_mci.c ============================================================================== --- stable/9/sys/arm/at91/at91_mci.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_mci.c Thu Jun 14 20:02:53 2012 (r237093) @@ -249,7 +249,7 @@ at91_mci_attach(device_t dev) child = device_add_child(dev, "mmc", 0); device_set_ivars(dev, &sc->host); err = bus_generic_attach(dev); -out:; +out: if (err) at91_mci_deactivate(dev); return (err); Modified: stable/9/sys/arm/at91/at91_pio.c ============================================================================== --- stable/9/sys/arm/at91/at91_pio.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_pio.c Thu Jun 14 20:02:53 2012 (r237093) @@ -165,7 +165,7 @@ at91_pio_attach(device_t dev) goto out; } sc->cdev->si_drv1 = sc; -out:; +out: if (err) at91_pio_deactivate(dev); return (err); Modified: stable/9/sys/arm/at91/at91_rtc.c ============================================================================== --- stable/9/sys/arm/at91/at91_rtc.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_rtc.c Thu Jun 14 20:02:53 2012 (r237093) @@ -118,7 +118,7 @@ at91_rtc_attach(device_t dev) goto out; } clock_register(dev, 1000000); -out:; +out: if (err) at91_rtc_deactivate(dev); return (err); Modified: stable/9/sys/arm/at91/at91_spi.c ============================================================================== --- stable/9/sys/arm/at91/at91_spi.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_spi.c Thu Jun 14 20:02:53 2012 (r237093) @@ -134,7 +134,7 @@ at91_spi_attach(device_t dev) device_add_child(dev, "spibus", -1); bus_generic_attach(dev); -out:; +out: if (err) at91_spi_deactivate(dev); return (err); @@ -259,7 +259,7 @@ at91_spi_transfer(device_t dev, device_t for (j = 0; j < i; j++) bus_dmamap_unload(sc->dmatag, sc->map[j]); return (err); -out:; +out: for (j = 0; j < i; j++) bus_dmamap_unload(sc->dmatag, sc->map[j]); return (EIO); Modified: stable/9/sys/arm/at91/at91_ssc.c ============================================================================== --- stable/9/sys/arm/at91/at91_ssc.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_ssc.c Thu Jun 14 20:02:53 2012 (r237093) @@ -150,7 +150,7 @@ at91_ssc_attach(device_t dev) WR4(sc, SSC_TFMR, 0x1f | SSC_TFMR_DATDEF | SSC_TFMR_MSFBF | SSC_TFMR_FSOS_NEG_PULSE); -out:; +out: if (err) at91_ssc_deactivate(dev); return (err); Modified: stable/9/sys/arm/at91/at91_twi.c ============================================================================== --- stable/9/sys/arm/at91/at91_twi.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/at91_twi.c Thu Jun 14 20:02:53 2012 (r237093) @@ -142,7 +142,7 @@ at91_twi_attach(device_t dev) device_printf(dev, "could not allocate iicbus instance\n"); /* probe and attach the iicbus */ bus_generic_attach(dev); -out:; +out: if (err) at91_twi_deactivate(dev); return (err); @@ -369,7 +369,7 @@ at91_twi_transfer(device_t dev, struct i if ((err = at91_twi_wait(sc, TWI_SR_TXCOMP))) break; } -out:; +out: if (err) { WR4(sc, TWI_CR, TWI_CR_SWRST); WR4(sc, TWI_CR, TWI_CR_MSEN | TWI_CR_SVDIS); Modified: stable/9/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- stable/9/sys/arm/at91/uart_dev_at91usart.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/at91/uart_dev_at91usart.c Thu Jun 14 20:02:53 2012 (r237093) @@ -428,7 +428,7 @@ at91_usart_bus_attach(struct uart_softc WR4(&sc->sc_bas, USART_IER, USART_CSR_RXRDY); } WR4(&sc->sc_bas, USART_IER, USART_CSR_RXBRK); -errout:; +errout: return (err); } Modified: stable/9/sys/arm/econa/if_ece.c ============================================================================== --- stable/9/sys/arm/econa/if_ece.c Thu Jun 14 19:55:22 2012 (r237092) +++ stable/9/sys/arm/econa/if_ece.c Thu Jun 14 20:02:53 2012 (r237093) @@ -441,7 +441,7 @@ ece_attach(device_t dev) taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", device_get_nameunit(sc->dev)); -out:; +out: if (err) ece_deactivate(dev); if (err && ifp) From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 20:05:12 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 814DA1065679; Thu, 14 Jun 2012 20:05:12 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 6A7218FC18; Thu, 14 Jun 2012 20:05:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EK5C6v016209; Thu, 14 Jun 2012 20:05:12 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EK5C2k016201; Thu, 14 Jun 2012 20:05:12 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201206142005.q5EK5C2k016201@svn.freebsd.org> From: Marius Strobl Date: Thu, 14 Jun 2012 20:05:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237095 - stable/9/sys/arm/at91 X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 20:05:12 -0000 Author: marius Date: Thu Jun 14 20:05:12 2012 New Revision: 237095 URL: http://svn.freebsd.org/changeset/base/237095 Log: MFC: r236495 - Prepend the device description with "AT91" to reflect its nature. [1] - Move DMA tag and map creature to at91_spi_activate() where the other resource allocation also lives. [1] - Flesh out at91_spi_deactivate(). [1] - Work around the "Software Reset must be Written Twice" erratum. - For now, run the bus at the slowest speed possible in order to work around data corruption on transit even seen with 9 MHz on ETHERNUT5 (15 MHz maximum) and AT45DB321D (20 MHz maximum). This also serves as a poor man's work-around for the "NPCSx rises if no data data is to be transmitted" erratum of RM9200. Being able to use the appropriate bus speed would require: 1) Adding a proper work-around for the RM9200 bug consisting of taking the chip select control away from the SPI peripheral and managing it directly as a GPIO line. 2) Taking the maximum frequencies supported by the actual board and the slave devices into account and basing the whole thing on the master clock instead of hardcoding a divisor as previously done. 3) Fixing the above mentioned data corruption. - KASSERT that TX/RX command and data sizes match on transfers. - Introduce a mutex ensuring that only one child device is running a SPI transfer at a time. [1] - Add preliminary, #ifdef'ed out support for setting the chip select. [1] - Use the RX instead of the TX commando size when setting up the RX side of a transfer. - For controllers having SPI_SR_TXEMPTY, i.e. !RM9200, also wait for the completion of the TX part of transfers before stopping the whole thing again. - Use DEVMETHOD_END. [1] - Use NULL instead of 0 for pointers. [1, partially] Additional testing by: Ian Lepore Submitted by: Ian Lepore [1] Modified: stable/9/sys/arm/at91/at91_spi.c stable/9/sys/arm/at91/at91_spireg.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/arm/at91/at91_spi.c ============================================================================== --- stable/9/sys/arm/at91/at91_spi.c Thu Jun 14 20:02:54 2012 (r237094) +++ stable/9/sys/arm/at91/at91_spi.c Thu Jun 14 20:05:12 2012 (r237095) @@ -1,5 +1,7 @@ /*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. + * Copyright (c) 2006 M. Warner Losh. + * Copyright (c) 2011-2012 Ian Lepore. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,17 +33,21 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include -#include #include +#include + #include #include #include +#include #include + #include "spibus_if.h" struct at91_spi_softc @@ -50,29 +56,39 @@ struct at91_spi_softc void *intrhand; /* Interrupt handle */ struct resource *irq_res; /* IRQ resource */ struct resource *mem_res; /* Memory resource */ - bus_dma_tag_t dmatag; /* bus dma tag for mbufs */ + bus_dma_tag_t dmatag; /* bus dma tag for transfers */ bus_dmamap_t map[4]; /* Maps for the transaction */ - int rxdone; + struct sx xfer_mtx; /* Enforce one transfer at a time */ + uint32_t xfer_mask; /* Bits to wait on for completion */ + uint32_t xfer_done; /* interrupt<->mainthread signaling */ }; +#define CS_TO_MR(cs) ((~(1 << (cs)) & 0x0f) << 16) + static inline uint32_t RD4(struct at91_spi_softc *sc, bus_size_t off) { - return bus_read_4(sc->mem_res, off); + + return (bus_read_4(sc->mem_res, off)); } static inline void WR4(struct at91_spi_softc *sc, bus_size_t off, uint32_t val) { + bus_write_4(sc->mem_res, off, val); } /* bus entry points */ -static int at91_spi_probe(device_t dev); static int at91_spi_attach(device_t dev); static int at91_spi_detach(device_t dev); +static int at91_spi_probe(device_t dev); +static int at91_spi_transfer(device_t dev, device_t child, + struct spi_command *cmd); /* helper routines */ +static void at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, + int error); static int at91_spi_activate(device_t dev); static void at91_spi_deactivate(device_t dev); static void at91_spi_intr(void *arg); @@ -80,43 +96,64 @@ static void at91_spi_intr(void *arg); static int at91_spi_probe(device_t dev) { - device_set_desc(dev, "SPI"); + + device_set_desc(dev, "AT91 SPI"); return (0); } static int at91_spi_attach(device_t dev) { - struct at91_spi_softc *sc = device_get_softc(dev); - int err, i; + struct at91_spi_softc *sc; + int err; + uint32_t csr; + + sc = device_get_softc(dev); sc->dev = dev; + sx_init(&sc->xfer_mtx, device_get_nameunit(dev)); + + /* + * Allocate resources. + */ err = at91_spi_activate(dev); if (err) goto out; /* - * Allocate DMA tags and maps + * Set up the hardware. */ - err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 2058, 1, - 2048, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->dmatag); - if (err != 0) - goto out; - for (i = 0; i < 4; i++) { - err = bus_dmamap_create(sc->dmatag, 0, &sc->map[i]); - if (err != 0) - goto out; - } - // reset the SPI + sc->xfer_mask = SPI_SR_RXBUFF | (at91_is_rm92() ? 0 : SPI_SR_TXEMPTY); + WR4(sc, SPI_CR, SPI_CR_SWRST); + /* "Software Reset must be Written Twice" erratum */ WR4(sc, SPI_CR, SPI_CR_SWRST); WR4(sc, SPI_IDR, 0xffffffff); WR4(sc, SPI_MR, (0xf << 24) | SPI_MR_MSTR | SPI_MR_MODFDIS | - (0xE << 16)); + CS_TO_MR(0)); + + /* + * For now, run the bus at the slowest speed possible as otherwise we + * may encounter data corruption on transmit as seen with ETHERNUT5 + * and AT45DB321D even though both board and slave device can take + * more. + * This also serves as a work-around for the "NPCSx rises if no data + * data is to be transmitted" erratum. The ideal workaround for the + * latter is to take the chip select control away from the peripheral + * and manage it directly as a GPIO line. The easy solution is to + * slow down the bus so dramatically that it just never gets starved + * as may be seen when the OCHI controller is running and consuming + * memory and APB bandwidth. + * Also, currently we lack a way for lettting both the board and the + * slave devices take their maximum supported SPI clocks into account. + */ + csr = SPI_CSR_CPOL | (4 << 16) | (0xff << 8); + WR4(sc, SPI_CSR0, csr); + WR4(sc, SPI_CSR1, csr); + WR4(sc, SPI_CSR2, csr); + WR4(sc, SPI_CSR3, csr); - WR4(sc, SPI_CSR0, SPI_CSR_CPOL | (4 << 16) | (2 << 8)); WR4(sc, SPI_CR, SPI_CR_SPIEN); WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS); @@ -143,6 +180,7 @@ out: static int at91_spi_detach(device_t dev) { + return (EBUSY); /* XXX */ } @@ -150,26 +188,41 @@ static int at91_spi_activate(device_t dev) { struct at91_spi_softc *sc; - int rid, err = ENOMEM; + int err, i, rid; sc = device_get_softc(dev); + err = ENOMEM; + rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->mem_res == NULL) - goto errout; + goto out; + rid = 0; sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->irq_res == NULL) - goto errout; + goto out; err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, at91_spi_intr, sc, &sc->intrhand); if (err != 0) - goto errout; - return (0); -errout: - at91_spi_deactivate(dev); + goto out; + + err = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, 2048, 1, + 2048, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->dmatag); + if (err != 0) + goto out; + + for (i = 0; i < 4; i++) { + err = bus_dmamap_create(sc->dmatag, 0, &sc->map[i]); + if (err != 0) + goto out; + } +out: + if (err != 0) + at91_spi_deactivate(dev); return (err); } @@ -177,26 +230,37 @@ static void at91_spi_deactivate(device_t dev) { struct at91_spi_softc *sc; + int i; sc = device_get_softc(dev); + bus_generic_detach(dev); + + for (i = 0; i < 4; i++) + if (sc->map[i]) + bus_dmamap_destroy(sc->dmatag, sc->map[i]); + + if (sc->dmatag) + bus_dma_tag_destroy(sc->dmatag); + if (sc->intrhand) bus_teardown_intr(dev, sc->irq_res, sc->intrhand); - sc->intrhand = 0; - bus_generic_detach(sc->dev); - if (sc->mem_res) - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(sc->mem_res), sc->mem_res); - sc->mem_res = 0; + sc->intrhand = NULL; if (sc->irq_res) bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq_res), sc->irq_res); - sc->irq_res = 0; - return; + sc->irq_res = NULL; + + if (sc->mem_res) + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->mem_res), sc->mem_res); + sc->mem_res = NULL; } static void -at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs __unused, + int error) { + if (error != 0) return; *(bus_addr_t *)arg = segs[0].ds_addr; @@ -206,80 +270,133 @@ static int at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct at91_spi_softc *sc; - int i, j, rxdone, err, mode[4]; bus_addr_t addr; + int err, i, j, mode[4]; + uint32_t mask; + + KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, + ("%s: TX/RX command sizes should be equal", __func__)); + KASSERT(cmd->tx_data_sz == cmd->rx_data_sz, + ("%s: TX/RX data sizes should be equal", __func__)); sc = device_get_softc(dev); - WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS); i = 0; - if (bus_dmamap_load(sc->dmatag, sc->map[i], cmd->tx_cmd, - cmd->tx_cmd_sz, at91_getaddr, &addr, 0) != 0) + + sx_xlock(&sc->xfer_mtx); + + /* + * Disable transfers while we set things up. + */ + WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS); + +#ifdef SPI_CHIPSEL_SUPPORT + if (cmd->cs < 0 || cmd->cs > 3) { + device_printf(dev, + "Invalid chip select %d requested by %s\n", cmd->cs, + device_get_nameunit(child)); + err = EINVAL; + goto out; + } +#ifdef SPI_CHIP_SELECT_HIGH_SUPPORT + if (at91_is_rm92() && cmd->cs == 0 && + (cmd->flags & SPI_CHIP_SELECT_HIGH) != 0) { + device_printf(dev, + "Invalid chip select high requested by %s\n", + device_get_nameunit(child)); + err = EINVAL; + goto out; + } +#endif + WR4(sc, SPI_MR, (RD4(sc, SPI_MR) & ~0x000f0000) | CS_TO_MR(cmd->cs)); +#endif + + /* + * Set up the TX side of the transfer. + */ + if ((err = bus_dmamap_load(sc->dmatag, sc->map[i], cmd->tx_cmd, + cmd->tx_cmd_sz, at91_getaddr, &addr, 0)) != 0) goto out; WR4(sc, PDC_TPR, addr); WR4(sc, PDC_TCR, cmd->tx_cmd_sz); bus_dmamap_sync(sc->dmatag, sc->map[i], BUS_DMASYNC_PREWRITE); mode[i++] = BUS_DMASYNC_POSTWRITE; if (cmd->tx_data_sz > 0) { - if (bus_dmamap_load(sc->dmatag, sc->map[i], cmd->tx_data, - cmd->tx_data_sz, at91_getaddr, &addr, 0) != 0) + if ((err = bus_dmamap_load(sc->dmatag, sc->map[i], + cmd->tx_data, cmd->tx_data_sz, at91_getaddr, &addr, 0)) != + 0) goto out; WR4(sc, PDC_TNPR, addr); WR4(sc, PDC_TNCR, cmd->tx_data_sz); bus_dmamap_sync(sc->dmatag, sc->map[i], BUS_DMASYNC_PREWRITE); mode[i++] = BUS_DMASYNC_POSTWRITE; } - if (bus_dmamap_load(sc->dmatag, sc->map[i], cmd->rx_cmd, - cmd->tx_cmd_sz, at91_getaddr, &addr, 0) != 0) + + /* + * Set up the RX side of the transfer. + */ + if ((err = bus_dmamap_load(sc->dmatag, sc->map[i], cmd->rx_cmd, + cmd->rx_cmd_sz, at91_getaddr, &addr, 0)) != 0) goto out; WR4(sc, PDC_RPR, addr); - WR4(sc, PDC_RCR, cmd->tx_cmd_sz); + WR4(sc, PDC_RCR, cmd->rx_cmd_sz); bus_dmamap_sync(sc->dmatag, sc->map[i], BUS_DMASYNC_PREREAD); mode[i++] = BUS_DMASYNC_POSTREAD; if (cmd->rx_data_sz > 0) { - if (bus_dmamap_load(sc->dmatag, sc->map[i], cmd->rx_data, - cmd->tx_data_sz, at91_getaddr, &addr, 0) != 0) + if ((err = bus_dmamap_load(sc->dmatag, sc->map[i], + cmd->rx_data, cmd->rx_data_sz, at91_getaddr, &addr, 0)) != + 0) goto out; WR4(sc, PDC_RNPR, addr); WR4(sc, PDC_RNCR, cmd->rx_data_sz); bus_dmamap_sync(sc->dmatag, sc->map[i], BUS_DMASYNC_PREREAD); mode[i++] = BUS_DMASYNC_POSTREAD; } - WR4(sc, SPI_IER, SPI_SR_ENDRX); + + /* + * Start the transfer, wait for it to complete. + */ + sc->xfer_done = 0; + mask = sc->xfer_mask; + WR4(sc, SPI_IER, mask); WR4(sc, PDC_PTCR, PDC_PTCR_TXTEN | PDC_PTCR_RXTEN); + do + err = tsleep(&sc->xfer_done, PCATCH | PZERO, "at91_spi", hz); + while (sc->xfer_done != mask && err != EINTR); - rxdone = sc->rxdone; - do { - err = tsleep(&sc->rxdone, PCATCH | PZERO, "spi", hz); - } while (rxdone == sc->rxdone && err != EINTR); + /* + * Stop the transfer and clean things up. + */ WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS); - if (err == 0) { - for (j = 0; j < i; j++) + if (err == 0) + for (j = 0; j < i; j++) bus_dmamap_sync(sc->dmatag, sc->map[j], mode[j]); - } - for (j = 0; j < i; j++) - bus_dmamap_unload(sc->dmatag, sc->map[j]); - return (err); out: for (j = 0; j < i; j++) bus_dmamap_unload(sc->dmatag, sc->map[j]); - return (EIO); + + sx_xunlock(&sc->xfer_mtx); + + return (err); } static void at91_spi_intr(void *arg) { - struct at91_spi_softc *sc = (struct at91_spi_softc*)arg; - uint32_t sr; + struct at91_spi_softc *sc; + uint32_t mask, sr; + sc = (struct at91_spi_softc*)arg; + + mask = sc->xfer_mask; sr = RD4(sc, SPI_SR) & RD4(sc, SPI_IMR); - if (sr & SPI_SR_ENDRX) { - sc->rxdone++; - WR4(sc, SPI_IDR, SPI_SR_ENDRX); - wakeup(&sc->rxdone); + if ((sr & mask) != 0) { + sc->xfer_done |= sr & mask; + WR4(sc, SPI_IDR, mask); + wakeup(&sc->xfer_done); } - if (sr & ~SPI_SR_ENDRX) { + if ((sr & ~mask) != 0) { device_printf(sc->dev, "Unexpected ISR %#x\n", sr); - WR4(sc, SPI_IDR, sr & ~SPI_SR_ENDRX); + WR4(sc, SPI_IDR, sr & ~mask); } } @@ -293,7 +410,8 @@ static device_method_t at91_spi_methods[ /* spibus interface */ DEVMETHOD(spibus_transfer, at91_spi_transfer), - { 0, 0 } + + DEVMETHOD_END }; static driver_t at91_spi_driver = { @@ -302,4 +420,5 @@ static driver_t at91_spi_driver = { sizeof(struct at91_spi_softc), }; -DRIVER_MODULE(at91_spi, atmelarm, at91_spi_driver, at91_spi_devclass, 0, 0); +DRIVER_MODULE(at91_spi, atmelarm, at91_spi_driver, at91_spi_devclass, NULL, + NULL); Modified: stable/9/sys/arm/at91/at91_spireg.h ============================================================================== --- stable/9/sys/arm/at91/at91_spireg.h Thu Jun 14 20:02:54 2012 (r237094) +++ stable/9/sys/arm/at91/at91_spireg.h Thu Jun 14 20:05:12 2012 (r237095) @@ -54,6 +54,8 @@ #define SPI_SR_ENDTX 0x00020 #define SPI_SR_RXBUFF 0x00040 #define SPI_SR_TXBUFE 0x00080 +#define SPI_SR_NSSR 0x00100 +#define SPI_SR_TXEMPTY 0x00200 #define SPI_SR_SPIENS 0x10000 #define SPI_IER 0x14 /* IER: Interrupt Enable Regsiter */ #define SPI_IDR 0x18 /* IDR: Interrupt Disable Regsiter */ From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 20:44:57 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A4831065672; Thu, 14 Jun 2012 20:44:57 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 51BC38FC1A; Thu, 14 Jun 2012 20:44:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EKivqt018285; Thu, 14 Jun 2012 20:44:57 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EKivWa018281; Thu, 14 Jun 2012 20:44:57 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201206142044.q5EKivWa018281@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 14 Jun 2012 20:44:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237100 - in stable/9: tools/regression/usr.bin/make tools/regression/usr.bin/make/variables/modifier_t tools/regression/usr.bin/make/variables/opt_V usr.bin/make X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 20:44:57 -0000 Author: obrien Date: Thu Jun 14 20:44:56 2012 New Revision: 237100 URL: http://svn.freebsd.org/changeset/base/237100 Log: MFC: r236338, r236339, r236346, r236347, r236365, & r236977 * Deprecate the FreeBSD make's ":U" (to-upper case) and ":L" (to-lower case) modifiers for ":tu" and ":tl". * make it easier to test newly-built make. * Add "-V '${VAR}'" variable expansion from Portable Berkeley Make. * regression test for '-V' command line option and the :t[lu] modifiers. Added: stable/9/tools/regression/usr.bin/make/test-new.mk - copied unchanged from r236339, head/tools/regression/usr.bin/make/test-new.mk stable/9/tools/regression/usr.bin/make/variables/modifier_t/ - copied from r236977, head/tools/regression/usr.bin/make/variables/modifier_t/ stable/9/tools/regression/usr.bin/make/variables/opt_V/ - copied from r236347, head/tools/regression/usr.bin/make/variables/opt_V/ Modified: stable/9/usr.bin/make/Makefile stable/9/usr.bin/make/make.1 stable/9/usr.bin/make/var.c Directory Properties: stable/9/ (props changed) stable/9/tools/ (props changed) stable/9/tools/regression/usr.bin/make/all.sh (props changed) stable/9/usr.bin/ (props changed) stable/9/usr.bin/make/ (props changed) Copied: stable/9/tools/regression/usr.bin/make/test-new.mk (from r236339, head/tools/regression/usr.bin/make/test-new.mk) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/9/tools/regression/usr.bin/make/test-new.mk Thu Jun 14 20:44:56 2012 (r237100, copy of r236339, head/tools/regression/usr.bin/make/test-new.mk) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +NEW_DIR!= make -C ${.CURDIR}/../../../../usr.bin/make -V .OBJDIR + +all: + rm -rf /tmp/${USER}.make.test + env MAKE_PROG=${NEW_DIR}/make ${.SHELL} ./all.sh + +.include Modified: stable/9/usr.bin/make/Makefile ============================================================================== --- stable/9/usr.bin/make/Makefile Thu Jun 14 20:29:49 2012 (r237099) +++ stable/9/usr.bin/make/Makefile Thu Jun 14 20:44:56 2012 (r237100) @@ -14,7 +14,9 @@ SRCS= arch.c buf.c cond.c dir.c for.c ha NO_SHARED?= YES .endif -CFLAGS+=-DMAKE_VERSION=\"5200408120\" +# Version has the RYYYYMMDDX format, where R is from RELENG_ +CFLAGS+=-DMAKE_VERSION=\"9201120530\" + # There is no obvious performance improvement currently. # CFLAGS+=-DUSE_KQUEUE Modified: stable/9/usr.bin/make/make.1 ============================================================================== --- stable/9/usr.bin/make/make.1 Thu Jun 14 20:29:49 2012 (r237099) +++ stable/9/usr.bin/make/make.1 Thu Jun 14 20:44:56 2012 (r237100) @@ -32,7 +32,7 @@ .\" @(#)make.1 8.8 (Berkeley) 6/13/95 .\" $FreeBSD$ .\" -.Dd November 5, 2011 +.Dd May 30, 2012 .Dt MAKE 1 .Os .Sh NAME @@ -320,6 +320,11 @@ Do not build any targets. Multiple instances of this option may be specified; the variables will be printed one per line, with a blank line for each null or undefined variable. +If +.Ar variable +contains a +.Sq Ic $ +then the value will be expanded before printing. .It Fl v Be extra verbose. Print any extra information. @@ -902,6 +907,7 @@ Replaces each word in the variable with Replaces each word in the variable with everything but the last component. .It Cm :L Converts variable to lower-case letters. +(deprecated) .It Cm :M Ns Ar pattern Select only those words that match the rest of the modifier. The standard shell wildcard characters @@ -993,8 +999,13 @@ to be replaced in .Ar new_string . .It Cm :T Replaces each word in the variable with its last component. +.It Cm :tl +Converts variable to lower-case letters. +.It Cm :tu +Converts variable to upper-case letters. .It Cm :U Converts variable to upper-case letters. +(deprecated) .It Cm :u Remove adjacent duplicate words (like .Xr uniq 1 ) . @@ -1742,6 +1753,19 @@ is set to the same value as .Va .MAKE ; support for this may be removed in the future. .Pp +The use of the +.Cm :L +and +.Cm :U +modifiers will be deprecated +in +.Fx 10.0 +and the more portable (among Pmake decedents) +.Cm :tl +and +.Cm :tu +should be used instead. +.Pp Most of the more esoteric features of .Nm should probably be avoided for greater compatibility. Modified: stable/9/usr.bin/make/var.c ============================================================================== --- stable/9/usr.bin/make/var.c Thu Jun 14 20:29:49 2012 (r237099) +++ stable/9/usr.bin/make/var.c Thu Jun 14 20:44:56 2012 (r237100) @@ -1746,6 +1746,19 @@ ParseModifier(VarParser *vp, char startc case 'C': newStr = modifier_C(vp, value, v); break; + case 't': + /* :tl :tu for OSF ODE & NetBSD make compatibility */ + switch (vp->ptr[1]) { + case 'l': + vp->ptr++; + goto mod_lower; + break; + case 'u': + vp->ptr++; + goto mod_upper; + break; + } + /* FALLTHROUGH */ default: if (vp->ptr[1] != endc && vp->ptr[1] != ':') { #ifdef SUNSHCMD @@ -1774,6 +1787,7 @@ ParseModifier(VarParser *vp, char startc switch (vp->ptr[0]) { case 'L': + mod_lower: { const char *cp; Buffer *buf; @@ -1799,6 +1813,7 @@ ParseModifier(VarParser *vp, char startc vp->ptr++; break; case 'U': + mod_upper: { const char *cp; Buffer *buf; @@ -2578,7 +2593,7 @@ void Var_Print(Lst *vlist, Boolean expandVars) { LstNode *n; - const char *name; + char *name; LST_FOREACH(n, vlist) { name = Lst_Datum(n); @@ -2586,13 +2601,17 @@ Var_Print(Lst *vlist, Boolean expandVars char *value; char *v; - v = emalloc(strlen(name) + 1 + 3); - sprintf(v, "${%s}", name); - + if (*name == '$') { + v = name; + } else { + v = emalloc(strlen(name) + 1 + 3); + sprintf(v, "${%s}", name); + } value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE)); printf("%s\n", value); - free(v); + if (v != name) + free(v); free(value); } else { const char *value = Var_Value(name, VAR_GLOBAL); From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 21:35:21 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A4DE1065672; Thu, 14 Jun 2012 21:35:21 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 346AA8FC14; Thu, 14 Jun 2012 21:35:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5ELZLWd022272; Thu, 14 Jun 2012 21:35:21 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5ELZLpc022270; Thu, 14 Jun 2012 21:35:21 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201206142135.q5ELZLpc022270@svn.freebsd.org> From: Andrew Thompson Date: Thu, 14 Jun 2012 21:35:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237103 - stable/9/sys/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 21:35:21 -0000 Author: thompsa Date: Thu Jun 14 21:35:20 2012 New Revision: 237103 URL: http://svn.freebsd.org/changeset/base/237103 Log: MFC r236916 Fix a panic I introduced in r234487, the bridge softc pointer is set to null early in the detach so rearrange things not to explode. Reported by: David Roffiaen, Gustau Perez Querol Modified: stable/9/sys/net/if_bridge.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/net/if_bridge.c ============================================================================== --- stable/9/sys/net/if_bridge.c Thu Jun 14 21:16:19 2012 (r237102) +++ stable/9/sys/net/if_bridge.c Thu Jun 14 21:35:20 2012 (r237103) @@ -334,6 +334,7 @@ static int bridge_ip6_checkbasic(struct static int bridge_fragment(struct ifnet *, struct mbuf *, struct ether_header *, int, struct llc *); static void bridge_linkstate(struct ifnet *ifp); +static void bridge_linkcheck(struct bridge_softc *sc); extern void (*bridge_linkstate_p)(struct ifnet *ifp); @@ -964,6 +965,7 @@ bridge_delete_member(struct bridge_softc EVENTHANDLER_INVOKE(iflladdr_event, sc->sc_ifp); } + bridge_linkcheck(sc); bridge_mutecaps(sc); /* recalcuate now this interface is removed */ bridge_rtdelete(sc, ifs, IFBF_FLUSHALL); KASSERT(bif->bif_addrcnt == 0, @@ -993,7 +995,6 @@ bridge_delete_member(struct bridge_softc bridge_set_ifcap(sc, bif, bif->bif_savedcaps); } bstp_destroy(&bif->bif_stp); /* prepare to free */ - bridge_linkstate(ifs); BRIDGE_LOCK(sc); free(bif, M_DEVBUF); } @@ -1092,18 +1093,17 @@ bridge_ioctl_add(struct bridge_softc *sc /* Set interface capabilities to the intersection set of all members */ bridge_mutecaps(sc); + bridge_linkcheck(sc); - BRIDGE_UNLOCK(sc); - /* Update the linkstate for the bridge */ - bridge_linkstate(ifs); /* Place the interface into promiscuous mode */ switch (ifs->if_type) { case IFT_ETHER: case IFT_L2VLAN: + BRIDGE_UNLOCK(sc); error = ifpromisc(ifs, 1); + BRIDGE_LOCK(sc); break; } - BRIDGE_LOCK(sc); if (error) bridge_delete_member(sc, bif, 0); out: @@ -3486,8 +3486,7 @@ static void bridge_linkstate(struct ifnet *ifp) { struct bridge_softc *sc = ifp->if_bridge; - struct bridge_iflist *bif, *bif2; - int new_link, hasls; + struct bridge_iflist *bif; BRIDGE_LOCK(sc); bif = bridge_lookup_member_if(sc, ifp); @@ -3495,13 +3494,26 @@ bridge_linkstate(struct ifnet *ifp) BRIDGE_UNLOCK(sc); return; } + bridge_linkcheck(sc); + BRIDGE_UNLOCK(sc); + + bstp_linkstate(&bif->bif_stp); +} + +static void +bridge_linkcheck(struct bridge_softc *sc) +{ + struct bridge_iflist *bif; + int new_link, hasls; + + BRIDGE_LOCK_ASSERT(sc); new_link = LINK_STATE_DOWN; hasls = 0; /* Our link is considered up if at least one of our ports is active */ - LIST_FOREACH(bif2, &sc->sc_iflist, bif_next) { - if (bif2->bif_ifp->if_capabilities & IFCAP_LINKSTATE) + LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + if (bif->bif_ifp->if_capabilities & IFCAP_LINKSTATE) hasls++; - if (bif2->bif_ifp->if_link_state == LINK_STATE_UP) { + if (bif->bif_ifp->if_link_state == LINK_STATE_UP) { new_link = LINK_STATE_UP; break; } @@ -3511,8 +3523,4 @@ bridge_linkstate(struct ifnet *ifp) new_link = LINK_STATE_UP; } if_link_state_change(sc->sc_ifp, new_link); - BRIDGE_UNLOCK(sc); - - bstp_linkstate(&bif->bif_stp); } - From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 14 21:48:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E5F4106566B; Thu, 14 Jun 2012 21:48:15 +0000 (UTC) (envelope-from ghelmer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 4808C8FC08; Thu, 14 Jun 2012 21:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5ELmFOa023004; Thu, 14 Jun 2012 21:48:15 GMT (envelope-from ghelmer@svn.freebsd.org) Received: (from ghelmer@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5ELmFul023002; Thu, 14 Jun 2012 21:48:15 GMT (envelope-from ghelmer@svn.freebsd.org) Message-Id: <201206142148.q5ELmFul023002@svn.freebsd.org> From: Guy Helmer Date: Thu, 14 Jun 2012 21:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237106 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 21:48:15 -0000 Author: ghelmer Date: Thu Jun 14 21:48:14 2012 New Revision: 237106 URL: http://svn.freebsd.org/changeset/base/237106 Log: MFC 235739-235740,236402: Apply style(9) to return and switch/case statements. Add checks for memory allocation failures in appropriate places, and avoid creating bad entries in the grp list as a result of memory allocation failures while building new entries. Style(9) improvements: remove unnecessary parenthesis, improve order of local variable declarations, remove bogus casts, and resolve long lines. PR: bin/83340 Modified: stable/9/lib/libc/gen/getnetgrent.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/gen/getnetgrent.c ============================================================================== --- stable/9/lib/libc/gen/getnetgrent.c Thu Jun 14 21:40:14 2012 (r237105) +++ stable/9/lib/libc/gen/getnetgrent.c Thu Jun 14 21:48:14 2012 (r237106) @@ -203,9 +203,7 @@ setnetgrent(const char *group) if (parse_netgrp(group)) endnetgrent(); else { - grouphead.grname = (char *) - malloc(strlen(group) + 1); - strcpy(grouphead.grname, group); + grouphead.grname = strdup(group); } if (netf) fclose(netf); @@ -292,12 +290,12 @@ _listmatch(const char *list, const char while(*ptr != ',' && *ptr != '\0' && !isspace((unsigned char)*ptr)) ptr++; if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr)) - return(1); + return (1); while(*ptr == ',' || isspace((unsigned char)*ptr)) ptr++; } - return(0); + return (0); } static int @@ -311,32 +309,37 @@ _revnetgr_lookup(char* lookupdom, char* for (rot = 0; ; rot++) { switch (rot) { - case(0): snprintf(key, MAXHOSTNAMELEN, "%s.%s", - str, dom?dom:lookupdom); - break; - case(1): snprintf(key, MAXHOSTNAMELEN, "%s.*", - str); - break; - case(2): snprintf(key, MAXHOSTNAMELEN, "*.%s", - dom?dom:lookupdom); - break; - case(3): snprintf(key, MAXHOSTNAMELEN, "*.*"); - break; - default: return(0); + case 0: + snprintf(key, MAXHOSTNAMELEN, "%s.%s", str, + dom ? dom : lookupdom); + break; + case 1: + snprintf(key, MAXHOSTNAMELEN, "%s.*", str); + break; + case 2: + snprintf(key, MAXHOSTNAMELEN, "*.%s", + dom ? dom : lookupdom); + break; + case 3: + snprintf(key, MAXHOSTNAMELEN, "*.*"); + break; + default: + return (0); } y = yp_match(lookupdom, map, key, strlen(key), &result, - &resultlen); + &resultlen); if (y == 0) { rv = _listmatch(result, group, resultlen); free(result); - if (rv) return(1); + if (rv) + return (1); } else if (y != YPERR_KEY) { /* * If we get an error other than 'no * such key in map' then something is * wrong and we should stop the search. */ - return(-1); + return (-1); } } } @@ -386,14 +389,14 @@ innetgr(const char *group, const char *h if (_use_only_yp && (host == NULL) != (user == NULL)) { int ret; if(yp_get_default_domain(&_netgr_yp_domain)) - return(0); + return (0); ret = _revnetgr_lookup(_netgr_yp_domain, host?"netgroup.byhost":"netgroup.byuser", host?host:user, dom, group); if (ret == 1) - return(1); + return (1); else if (ret == 0 && dom != NULL) - return(0); + return (0); } setnetgrent(group); @@ -416,14 +419,14 @@ innetgr(const char *group, const char *h static int parse_netgrp(const char *group) { - char *spos, *epos; - int len, strpos; + struct netgrp *grp; + struct linelist *lp = linehead; + char **ng; + char *epos, *gpos, *pos, *spos; + int freepos, len, strpos; #ifdef DEBUG int fields; #endif - char *pos, *gpos; - struct netgrp *grp; - struct linelist *lp = linehead; /* * First, see if the line has already been read in. @@ -453,43 +456,51 @@ parse_netgrp(const char *group) /* Watch for null pointer dereferences, dammit! */ while (pos != NULL && *pos != '\0') { if (*pos == '(') { - grp = (struct netgrp *)malloc(sizeof (struct netgrp)); - bzero((char *)grp, sizeof (struct netgrp)); - grp->ng_next = grouphead.gr; - grouphead.gr = grp; + grp = malloc(sizeof(*grp)); + if (grp == NULL) + return (1); + ng = grp->ng_str; + bzero(grp, sizeof(*grp)); pos++; gpos = strsep(&pos, ")"); #ifdef DEBUG fields = 0; #endif for (strpos = 0; strpos < 3; strpos++) { - if ((spos = strsep(&gpos, ","))) { -#ifdef DEBUG - fields++; -#endif - while (*spos == ' ' || *spos == '\t') - spos++; - if ((epos = strpbrk(spos, " \t"))) { - *epos = '\0'; - len = epos - spos; - } else - len = strlen(spos); - if (len > 0) { - grp->ng_str[strpos] = (char *) - malloc(len + 1); - bcopy(spos, grp->ng_str[strpos], - len + 1); - } - } else { + if ((spos = strsep(&gpos, ",")) == NULL) { /* * All other systems I've tested * return NULL for empty netgroup * fields. It's up to user programs * to handle the NULLs appropriately. */ - grp->ng_str[strpos] = NULL; + ng[strpos] = NULL; + continue; } +#ifdef DEBUG + fields++; +#endif + while (*spos == ' ' || *spos == '\t') + spos++; + if ((epos = strpbrk(spos, " \t"))) { + *epos = '\0'; + len = epos - spos; + } else + len = strlen(spos); + if (len <= 0) + continue; + ng[strpos] = malloc(len + 1); + if (ng[strpos] == NULL) { + for (freepos = 0; freepos < strpos; + freepos++) + free(ng[freepos]); + free(grp); + return (1); + } + bcopy(spos, ng[strpos], len + 1); } + grp->ng_next = grouphead.gr; + grouphead.gr = grp; #ifdef DEBUG /* * Note: on other platforms, malformed netgroup @@ -497,14 +508,15 @@ parse_netgrp(const char *group) * can catch bad entries and report them, we should * stay silent by default for compatibility's sake. */ - if (fields < 3) - fprintf(stderr, "Bad entry (%s%s%s%s%s) in netgroup \"%s\"\n", - grp->ng_str[NG_HOST] == NULL ? "" : grp->ng_str[NG_HOST], - grp->ng_str[NG_USER] == NULL ? "" : ",", - grp->ng_str[NG_USER] == NULL ? "" : grp->ng_str[NG_USER], - grp->ng_str[NG_DOM] == NULL ? "" : ",", - grp->ng_str[NG_DOM] == NULL ? "" : grp->ng_str[NG_DOM], - lp->l_groupname); + if (fields < 3) { + fprintf(stderr, + "Bad entry (%s%s%s%s%s) in netgroup \"%s\"\n", + ng[NG_HOST] == NULL ? "" : ng[NG_HOST], + ng[NG_USER] == NULL ? "" : ",", + ng[NG_USER] == NULL ? "" : ng[NG_USER], + ng[NG_DOM] == NULL ? "" : ",", + ng[NG_DOM] == NULL ? "" : ng[NG_DOM], + lp->l_groupname); #endif } else { spos = strsep(&pos, ", \t"); @@ -526,7 +538,7 @@ parse_netgrp(const char *group) static struct linelist * read_for_group(const char *group) { - char *pos, *spos, *linep, *olinep; + char *pos, *spos, *linep; int len, olen; int cont; struct linelist *lp; @@ -534,6 +546,7 @@ read_for_group(const char *group) #ifdef YP char *result; int resultlen; + linep = NULL; while (_netgr_yp_enabled || fgets(line, LINSIZ, netf) != NULL) { if (_netgr_yp_enabled) { @@ -541,7 +554,7 @@ read_for_group(const char *group) if(yp_get_default_domain(&_netgr_yp_domain)) continue; if (yp_match(_netgr_yp_domain, "netgroup", group, - strlen(group), &result, &resultlen)) { + strlen(group), &result, &resultlen)) { free(result); if (_use_only_yp) return ((struct linelist *)0); @@ -554,6 +567,7 @@ read_for_group(const char *group) free(result); } #else + linep = NULL; while (fgets(line, LINSIZ, netf) != NULL) { #endif pos = (char *)&line; @@ -576,8 +590,14 @@ read_for_group(const char *group) pos++; if (*pos != '\n' && *pos != '\0') { lp = (struct linelist *)malloc(sizeof (*lp)); + if (lp == NULL) + return (NULL); lp->l_parsed = 0; lp->l_groupname = (char *)malloc(len + 1); + if (lp->l_groupname == NULL) { + free(lp); + return (NULL); + } bcopy(spos, lp->l_groupname, len); *(lp->l_groupname + len) = '\0'; len = strlen(pos); @@ -595,15 +615,15 @@ read_for_group(const char *group) } else cont = 0; if (len > 0) { - linep = (char *)malloc(olen + len + 1); - if (olen > 0) { - bcopy(olinep, linep, olen); - free(olinep); + linep = reallocf(linep, olen + len + 1); + if (linep == NULL) { + free(lp->l_groupname); + free(lp); + return (NULL); } bcopy(pos, linep + olen, len); olen += len; *(linep + olen) = '\0'; - olinep = linep; } if (cont) { if (fgets(line, LINSIZ, netf)) { @@ -634,5 +654,5 @@ read_for_group(const char *group) */ rewind(netf); #endif - return ((struct linelist *)0); + return (NULL); } From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 06:13:13 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D65B106566B; Fri, 15 Jun 2012 06:13:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 37DD38FC1A; Fri, 15 Jun 2012 06:13:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5F6DDXt047377; Fri, 15 Jun 2012 06:13:13 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5F6DCYD047375; Fri, 15 Jun 2012 06:13:12 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206150613.q5F6DCYD047375@svn.freebsd.org> From: Alexander Motin Date: Fri, 15 Jun 2012 06:13:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237113 - stable/9/sys/dev/ahci X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 06:13:13 -0000 Author: mav Date: Fri Jun 15 06:13:12 2012 New Revision: 237113 URL: http://svn.freebsd.org/changeset/base/237113 Log: MFC r236737: Add IDs for Marvell 88SE9220/9230/9235 PCIe 2.0 x2 6Gbps SATA controllers. Marvell 88SE9230 was confirmed to work, the rest two are just guessed. Modified: stable/9/sys/dev/ahci/ahci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/ahci/ahci.c ============================================================================== --- stable/9/sys/dev/ahci/ahci.c Fri Jun 15 06:00:56 2012 (r237112) +++ stable/9/sys/dev/ahci/ahci.c Fri Jun 15 06:13:12 2012 (r237113) @@ -202,6 +202,9 @@ static struct { {0x91301b4b, 0x00, "Marvell 88SE9130", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, {0x91721b4b, 0x00, "Marvell 88SE9172", AHCI_Q_NOBSYRES}, {0x91821b4b, 0x00, "Marvell 88SE9182", AHCI_Q_NOBSYRES}, + {0x92201b4b, 0x00, "Marvell 88SE9220", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, + {0x92301b4b, 0x00, "Marvell 88SE9230", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, + {0x92351b4b, 0x00, "Marvell 88SE9235", AHCI_Q_NOBSYRES}, {0x06201103, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, {0x06201b4b, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, {0x06221103, 0x00, "HighPoint RocketRAID 622", AHCI_Q_NOBSYRES}, From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 07:14:17 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0704A1065701; Fri, 15 Jun 2012 07:14:17 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id E51458FC12; Fri, 15 Jun 2012 07:14:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5F7EGxt050185; Fri, 15 Jun 2012 07:14:16 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5F7EGtS050182; Fri, 15 Jun 2012 07:14:16 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201206150714.q5F7EGtS050182@svn.freebsd.org> From: Martin Matuska Date: Fri, 15 Jun 2012 07:14:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237116 - stable/9/cddl/contrib/opensolaris/cmd/zpool X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 07:14:17 -0000 Author: mm Date: Fri Jun 15 07:14:16 2012 New Revision: 237116 URL: http://svn.freebsd.org/changeset/base/237116 Log: MFC r236960: Document the -v flag for zpool list. PR: 168970 Suggested by: Marcelo Araujo Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Fri Jun 15 06:38:55 2012 (r237115) +++ stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Fri Jun 15 07:14:16 2012 (r237116) @@ -1301,6 +1301,8 @@ reports are printed. .It Fl H Scripted mode. Do not display headers, and separate fields by a single tab instead of arbitrary space. +.It Fl v +Show more detailed information. .It Fl o Ar property Ns Op , Ns Ar ... Comma-separated list of properties to display. See the .Qq Sx Properties Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Fri Jun 15 06:38:55 2012 (r237115) +++ stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Fri Jun 15 07:14:16 2012 (r237116) @@ -234,7 +234,7 @@ get_usage(zpool_help_t idx) { case HELP_LABELCLEAR: return (gettext("\tlabelclear [-f] \n")); case HELP_LIST: - return (gettext("\tlist [-H] [-o property[,...]] " + return (gettext("\tlist [-Hv] [-o property[,...]] " "[-T d|u] [pool] ... [interval [count]]\n")); case HELP_OFFLINE: return (gettext("\toffline [-t] ...\n")); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 10:38:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A6634106566B; Fri, 15 Jun 2012 10:38:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 906468FC17; Fri, 15 Jun 2012 10:38:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5FAcFs2070572; Fri, 15 Jun 2012 10:38:15 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5FAcFts070560; Fri, 15 Jun 2012 10:38:15 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206151038.q5FAcFts070560@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 15 Jun 2012 10:38:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237134 - in stable/9/sys: compat/freebsd32 kern sys vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 10:38:15 -0000 Author: kib Date: Fri Jun 15 10:38:14 2012 New Revision: 237134 URL: http://svn.freebsd.org/changeset/base/237134 Log: MFC r226342 (by marcel): In elf32_trans_prot() and when compiling for amd64 or ia64, add PROT_EXECUTE when PROT_READ is needed. By default i386 allows execution when reading is allowed and JDK 1.4.x depends on that. MFC r226343 (by marcel): In sys_obreak() and when compiling for amd64 or ia64, when the process is ILP32 (i.e. i386) grant execute permissions by default. The JDK 1.4.x depends on being able to execute from the heap on i386. MFC r226347 (by marcel): In freebsd32_mmap() and when compiling for amd64 or ia64, also ask for execute permissions when read permissions are wanted. This is needed for JDK 1.4.x on i386. MFC r226348 (by marcel): Wrap mprotect(2). MFC r226349 (by marcel): Wrap mprotect(2) so that we can add execute permissions when read permissions are requested. This is needed on amd64 and ia64 for JDK 1.4.x. MFC r226353 (by marcel): Use PTRIN(). MFC r226388: Control the execution permission of the readable segments for i386 binaries on the amd64 and ia64 with the sysctl, instead of unconditionally enabling it. MFC note: the syscall tables were regenerated in r226349 and committed together with changes to non-generated files. The merge includes syscall tables regenerated after the merge, for stable/9. Modified: stable/9/sys/compat/freebsd32/freebsd32_misc.c stable/9/sys/compat/freebsd32/freebsd32_proto.h stable/9/sys/compat/freebsd32/freebsd32_syscall.h stable/9/sys/compat/freebsd32/freebsd32_syscalls.c stable/9/sys/compat/freebsd32/freebsd32_sysent.c stable/9/sys/compat/freebsd32/freebsd32_systrace_args.c stable/9/sys/compat/freebsd32/syscalls.master stable/9/sys/kern/imgact_elf.c stable/9/sys/sys/sysent.h stable/9/sys/vm/vm_unix.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_misc.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_misc.c Fri Jun 15 10:38:14 2012 (r237134) @@ -437,6 +437,21 @@ freebsd32_mmap_partial(struct thread *td #endif int +freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap) +{ + struct mprotect_args ap; + + ap.addr = PTRIN(uap->addr); + ap.len = uap->len; + ap.prot = uap->prot; +#if defined(__amd64__) || defined(__ia64__) + if (i386_read_exec && (ap.prot & PROT_READ) != 0) + ap.prot |= PROT_EXEC; +#endif + return (sys_mprotect(td, &ap)); +} + +int freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap) { struct mmap_args ap; @@ -520,6 +535,11 @@ freebsd32_mmap(struct thread *td, struct } #endif +#if defined(__amd64__) || defined(__ia64__) + if (i386_read_exec && (prot & PROT_READ)) + prot |= PROT_EXEC; +#endif + ap.addr = (void *) addr; ap.len = len; ap.prot = prot; Modified: stable/9/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_proto.h Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_proto.h Fri Jun 15 10:38:14 2012 (r237134) @@ -76,6 +76,11 @@ struct freebsd32_execve_args { char argv_l_[PADL_(u_int32_t *)]; u_int32_t * argv; char argv_r_[PADR_(u_int32_t *)]; char envv_l_[PADL_(u_int32_t *)]; u_int32_t * envv; char envv_r_[PADR_(u_int32_t *)]; }; +struct freebsd32_mprotect_args { + char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(int)]; int prot; char prot_r_[PADR_(int)]; +}; struct freebsd32_setitimer_args { char which_l_[PADL_(u_int)]; u_int which; char which_r_[PADR_(u_int)]; char itv_l_[PADL_(struct itimerval32 *)]; struct itimerval32 * itv; char itv_r_[PADR_(struct itimerval32 *)]; @@ -593,6 +598,7 @@ int freebsd32_recvfrom(struct thread *, int freebsd32_sigaltstack(struct thread *, struct freebsd32_sigaltstack_args *); int freebsd32_ioctl(struct thread *, struct freebsd32_ioctl_args *); int freebsd32_execve(struct thread *, struct freebsd32_execve_args *); +int freebsd32_mprotect(struct thread *, struct freebsd32_mprotect_args *); int freebsd32_setitimer(struct thread *, struct freebsd32_setitimer_args *); int freebsd32_getitimer(struct thread *, struct freebsd32_getitimer_args *); int freebsd32_select(struct thread *, struct freebsd32_select_args *); @@ -952,6 +958,7 @@ int freebsd7_freebsd32_shmctl(struct thr #define FREEBSD32_SYS_AUE_freebsd32_execve AUE_EXECVE #define FREEBSD32_SYS_AUE_ofreebsd32_fstat AUE_FSTAT #define FREEBSD32_SYS_AUE_ofreebsd32_getpagesize AUE_NULL +#define FREEBSD32_SYS_AUE_freebsd32_mprotect AUE_MPROTECT #define FREEBSD32_SYS_AUE_freebsd32_setitimer AUE_SETITIMER #define FREEBSD32_SYS_AUE_freebsd32_getitimer AUE_GETITIMER #define FREEBSD32_SYS_AUE_freebsd32_select AUE_SELECT Modified: stable/9/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_syscall.h Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_syscall.h Fri Jun 15 10:38:14 2012 (r237134) @@ -80,7 +80,7 @@ /* 71 is obsolete ommap */ #define FREEBSD32_SYS_vadvise 72 #define FREEBSD32_SYS_munmap 73 -#define FREEBSD32_SYS_mprotect 74 +#define FREEBSD32_SYS_freebsd32_mprotect 74 #define FREEBSD32_SYS_madvise 75 /* 76 is obsolete vhangup */ /* 77 is obsolete vlimit */ Modified: stable/9/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_syscalls.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_syscalls.c Fri Jun 15 10:38:14 2012 (r237134) @@ -84,7 +84,7 @@ const char *freebsd32_syscallnames[] = { "obs_ommap", /* 71 = obsolete ommap */ "vadvise", /* 72 = vadvise */ "munmap", /* 73 = munmap */ - "mprotect", /* 74 = mprotect */ + "freebsd32_mprotect", /* 74 = freebsd32_mprotect */ "madvise", /* 75 = madvise */ "obs_vhangup", /* 76 = obsolete vhangup */ "obs_vlimit", /* 77 = obsolete vlimit */ Modified: stable/9/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_sysent.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_sysent.c Fri Jun 15 10:38:14 2012 (r237134) @@ -121,7 +121,7 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 71 = obsolete ommap */ { AS(ovadvise_args), (sy_call_t *)sys_ovadvise, AUE_O_VADVISE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 72 = vadvise */ { AS(munmap_args), (sy_call_t *)sys_munmap, AUE_MUNMAP, NULL, 0, 0, 0, SY_THR_STATIC }, /* 73 = munmap */ - { AS(mprotect_args), (sy_call_t *)sys_mprotect, AUE_MPROTECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 74 = mprotect */ + { AS(freebsd32_mprotect_args), (sy_call_t *)freebsd32_mprotect, AUE_MPROTECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 74 = freebsd32_mprotect */ { AS(madvise_args), (sy_call_t *)sys_madvise, AUE_MADVISE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 75 = madvise */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 76 = obsolete vhangup */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 77 = obsolete vlimit */ Modified: stable/9/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- stable/9/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Jun 15 10:38:14 2012 (r237134) @@ -464,9 +464,9 @@ systrace_args(int sysnum, void *params, *n_args = 2; break; } - /* mprotect */ + /* freebsd32_mprotect */ case 74: { - struct mprotect_args *p = params; + struct freebsd32_mprotect_args *p = params; uarg[0] = (intptr_t) p->addr; /* const void * */ uarg[1] = p->len; /* size_t */ iarg[2] = p->prot; /* int */ @@ -3749,7 +3749,7 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; - /* mprotect */ + /* freebsd32_mprotect */ case 74: switch(ndx) { case 0: Modified: stable/9/sys/compat/freebsd32/syscalls.master ============================================================================== --- stable/9/sys/compat/freebsd32/syscalls.master Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/compat/freebsd32/syscalls.master Fri Jun 15 10:38:14 2012 (r237134) @@ -172,7 +172,7 @@ 72 AUE_O_VADVISE NOPROTO { int ovadvise(int anom); } vadvise \ ovadvise_args int 73 AUE_MUNMAP NOPROTO { int munmap(void *addr, size_t len); } -74 AUE_MPROTECT NOPROTO { int mprotect(const void *addr, \ +74 AUE_MPROTECT STD { int freebsd32_mprotect(const void *addr, \ size_t len, int prot); } 75 AUE_MADVISE NOPROTO { int madvise(void *addr, size_t len, \ int behav); } Modified: stable/9/sys/kern/imgact_elf.c ============================================================================== --- stable/9/sys/kern/imgact_elf.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/kern/imgact_elf.c Fri Jun 15 10:38:14 2012 (r237134) @@ -123,6 +123,14 @@ SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WOR nxstack, CTLFLAG_RW, &__elfN(nxstack), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable stack"); +#if __ELF_WORD_SIZE == 32 +#if defined(__amd64__) || defined(__ia64__) +int i386_read_exec = 0; +SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, &i386_read_exec, 0, + "enable execution from readable segments"); +#endif +#endif + static Elf_Brandinfo *elf_brand_list[MAX_BRANDS]; #define trunc_page_ps(va, ps) ((va) & ~(ps - 1)) @@ -1671,6 +1679,12 @@ __elfN(trans_prot)(Elf_Word flags) prot |= VM_PROT_WRITE; if (flags & PF_R) prot |= VM_PROT_READ; +#if __ELF_WORD_SIZE == 32 +#if defined(__amd64__) || defined(__ia64__) + if (i386_read_exec && (flags & PF_R)) + prot |= VM_PROT_EXECUTE; +#endif +#endif return (prot); } Modified: stable/9/sys/sys/sysent.h ============================================================================== --- stable/9/sys/sys/sysent.h Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/sys/sysent.h Fri Jun 15 10:38:14 2012 (r237134) @@ -151,6 +151,10 @@ extern struct sysentvec null_sysvec; extern struct sysent sysent[]; extern const char *syscallnames[]; +#if defined(__amd64__) || defined(__ia64__) +extern int i386_read_exec; +#endif + #define NO_SYSCALL (-1) struct module; Modified: stable/9/sys/vm/vm_unix.c ============================================================================== --- stable/9/sys/vm/vm_unix.c Fri Jun 15 10:00:29 2012 (r237133) +++ stable/9/sys/vm/vm_unix.c Fri Jun 15 10:38:14 2012 (r237134) @@ -36,6 +36,8 @@ * @(#)vm_unix.c 8.1 (Berkeley) 6/11/93 */ +#include "opt_compat.h" + /* * Traditional sbrk/grow interface to VM */ @@ -49,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -75,7 +78,7 @@ sys_obreak(td, uap) struct vmspace *vm = td->td_proc->p_vmspace; vm_offset_t new, old, base; rlim_t datalim, vmemlim; - int rv; + int prot, rv; int error = 0; boolean_t do_map_wirefuture; @@ -135,8 +138,15 @@ sys_obreak(td, uap) } PROC_UNLOCK(td->td_proc); #endif + prot = VM_PROT_RW; +#ifdef COMPAT_FREEBSD32 +#if defined(__amd64__) || defined(__ia64__) + if (i386_read_exec && SV_PROC_FLAG(td->td_proc, SV_ILP32)) + prot |= VM_PROT_EXECUTE; +#endif +#endif rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, - VM_PROT_RW, VM_PROT_ALL, 0); + prot, VM_PROT_ALL, 0); if (rv != KERN_SUCCESS) { #ifdef RACCT PROC_LOCK(td->td_proc); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 17:31:16 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52A9A106566C; Fri, 15 Jun 2012 17:31:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 3C9918FC1B; Fri, 15 Jun 2012 17:31:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5FHVGb0094675; Fri, 15 Jun 2012 17:31:16 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5FHVF8v094670; Fri, 15 Jun 2012 17:31:15 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206151731.q5FHVF8v094670@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 15 Jun 2012 17:31:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237140 - in stable/9/sys: i386/i386 kern powerpc/aim powerpc/booke X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 17:31:16 -0000 Author: kib Date: Fri Jun 15 17:31:15 2012 New Revision: 237140 URL: http://svn.freebsd.org/changeset/base/237140 Log: MFC r230767: Enable nxstacks where supported. Modified: stable/9/sys/i386/i386/initcpu.c stable/9/sys/kern/imgact_elf.c stable/9/sys/powerpc/aim/mmu_oea64.c stable/9/sys/powerpc/booke/machdep.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/i386/i386/initcpu.c ============================================================================== --- stable/9/sys/i386/i386/initcpu.c Fri Jun 15 17:16:41 2012 (r237139) +++ stable/9/sys/i386/i386/initcpu.c Fri Jun 15 17:31:15 2012 (r237140) @@ -649,6 +649,8 @@ enable_sse(void) #endif } +extern int elf32_nxstack; + void initializecpu(void) { @@ -738,6 +740,7 @@ initializecpu(void) msr = rdmsr(MSR_EFER) | EFER_NXE; wrmsr(MSR_EFER, msr); pg_nx = PG_NX; + elf32_nxstack = 1; } #endif break; Modified: stable/9/sys/kern/imgact_elf.c ============================================================================== --- stable/9/sys/kern/imgact_elf.c Fri Jun 15 17:16:41 2012 (r237139) +++ stable/9/sys/kern/imgact_elf.c Fri Jun 15 17:31:15 2012 (r237140) @@ -118,7 +118,12 @@ static int elf_legacy_coredump = 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, &elf_legacy_coredump, 0, ""); -static int __elfN(nxstack) = 0; +int __elfN(nxstack) = +#if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 bit */ + 1; +#else + 0; +#endif SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, nxstack, CTLFLAG_RW, &__elfN(nxstack), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable stack"); Modified: stable/9/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- stable/9/sys/powerpc/aim/mmu_oea64.c Fri Jun 15 17:16:41 2012 (r237139) +++ stable/9/sys/powerpc/aim/mmu_oea64.c Fri Jun 15 17:31:15 2012 (r237140) @@ -1448,6 +1448,8 @@ moea64_uma_page_alloc(uma_zone_t zone, i return (void *)va; } +extern int elf32_nxstack; + void moea64_init(mmu_t mmu) { @@ -1467,6 +1469,8 @@ moea64_init(mmu_t mmu) uma_zone_set_allocf(moea64_mpvo_zone,moea64_uma_page_alloc); } + elf32_nxstack = 1; + moea64_initialized = TRUE; } Modified: stable/9/sys/powerpc/booke/machdep.c ============================================================================== --- stable/9/sys/powerpc/booke/machdep.c Fri Jun 15 17:16:41 2012 (r237139) +++ stable/9/sys/powerpc/booke/machdep.c Fri Jun 15 17:31:15 2012 (r237140) @@ -192,6 +192,8 @@ void print_kernel_section_addr(void); void print_kenv(void); u_int booke_init(uint32_t, uint32_t); +extern int elf32_nxstack; + static void cpu_e500_startup(void *dummy) { @@ -227,6 +229,9 @@ cpu_e500_startup(void *dummy) /* Set up buffers, so they can be used to read disk labels. */ bufinit(); vm_pager_bufferinit(); + + /* Cpu supports execution permissions on the pages. */ + elf32_nxstack = 1; } static char * From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 20:25:44 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5CBC1065672; Fri, 15 Jun 2012 20:25:44 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B6EF78FC16; Fri, 15 Jun 2012 20:25:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5FKPikd002009; Fri, 15 Jun 2012 20:25:44 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5FKPiKc002007; Fri, 15 Jun 2012 20:25:44 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201206152025.q5FKPiKc002007@svn.freebsd.org> From: Mikolaj Golub Date: Fri, 15 Jun 2012 20:25:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237144 - stable/9/sys/net X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 20:25:45 -0000 Author: trociny Date: Fri Jun 15 20:25:44 2012 New Revision: 237144 URL: http://svn.freebsd.org/changeset/base/237144 Log: MFC 236724, 236725: MFC 236724: Add VIMAGE support to if_tap. PR: kern/152047, kern/158686 Submitted by: Daan Vreeken MFC 236725: Sort includes. Submitted by: Daan Vreeken Modified: stable/9/sys/net/if_tap.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/net/if_tap.c ============================================================================== --- stable/9/sys/net/if_tap.c Fri Jun 15 20:08:13 2012 (r237143) +++ stable/9/sys/net/if_tap.c Fri Jun 15 20:25:44 2012 (r237144) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -64,8 +65,9 @@ #include #include #include -#include #include +#include +#include #include @@ -214,6 +216,7 @@ tap_destroy(struct tap_softc *tp) KASSERT(!(tp->tap_flags & TAP_OPEN), ("%s flags is out of sync", ifp->if_xname)); + CURVNET_SET(ifp->if_vnet); seldrain(&tp->tap_rsel); knlist_destroy(&tp->tap_rsel.si_note); destroy_dev(tp->tap_dev); @@ -222,6 +225,7 @@ tap_destroy(struct tap_softc *tp) mtx_destroy(&tp->tap_mtx); free(tp, M_TAP); + CURVNET_RESTORE(); } static void @@ -363,6 +367,7 @@ tapclone(void *arg, struct ucred *cred, if (unit == -1) append_unit = 1; + CURVNET_SET(CRED_TO_VNET(cred)); /* find any existing device, or allocate new unit number */ i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra); if (i) { @@ -381,6 +386,7 @@ tapclone(void *arg, struct ucred *cred, } if_clone_create(name, namelen, NULL); + CURVNET_RESTORE(); } /* tapclone */ @@ -521,6 +527,7 @@ tapclose(struct cdev *dev, int foo, int /* junk all pending output */ mtx_lock(&tp->tap_mtx); + CURVNET_SET(ifp->if_vnet); IF_DRAIN(&ifp->if_snd); /* @@ -544,6 +551,8 @@ tapclose(struct cdev *dev, int foo, int } if_link_state_change(ifp, LINK_STATE_DOWN); + CURVNET_RESTORE(); + funsetown(&tp->tap_sigio); selwakeuppri(&tp->tap_rsel, PZERO+1); KNOTE_LOCKED(&tp->tap_rsel.si_note, 0); @@ -945,7 +954,9 @@ tapwrite(struct cdev *dev, struct uio *u } /* Pass packet up to parent. */ + CURVNET_SET(ifp->if_vnet); (*ifp->if_input)(ifp, m); + CURVNET_RESTORE(); ifp->if_ipackets ++; /* ibytes are counted in parent */ return (0); From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 21:27:05 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 809CD1065674; Fri, 15 Jun 2012 21:27:05 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id D26038FC1C; Fri, 15 Jun 2012 21:27:03 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5FLQq93064740; Sat, 16 Jun 2012 00:26:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5FLQqZL068859; Sat, 16 Jun 2012 00:26:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5FLQppg068858; Sat, 16 Jun 2012 00:26:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 16 Jun 2012 00:26:51 +0300 From: Konstantin Belousov To: Guy Helmer Message-ID: <20120615212651.GH2337@deviant.kiev.zoral.com.ua> References: <201206142148.q5ELmFul023002@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WFYXJKyHTUiGqOmp" Content-Disposition: inline In-Reply-To: <201206142148.q5ELmFul023002@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r237106 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 21:27:05 -0000 --WFYXJKyHTUiGqOmp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 14, 2012 at 09:48:15PM +0000, Guy Helmer wrote: > Author: ghelmer > Date: Thu Jun 14 21:48:14 2012 > New Revision: 237106 > URL: http://svn.freebsd.org/changeset/base/237106 >=20 > Log: > MFC 235739-235740,236402: > Apply style(9) to return and switch/case statements. > =20 > Add checks for memory allocation failures in appropriate places, and > avoid creating bad entries in the grp list as a result of memory alloca= tion > failures while building new entries. > =20 > Style(9) improvements: remove unnecessary parenthesis, improve order > of local variable declarations, remove bogus casts, and resolve long > lines. > =20 > PR: bin/83340 >=20 > Modified: > stable/9/lib/libc/gen/getnetgrent.c > Directory Properties: > stable/9/lib/libc/ (props changed) >=20 This broke mountd(8) for me. It dies with SIGSEGV on start. Autopsy has shown that this happen due to free(3) on an unallocated pointer. I have two netgroups in my /etc/netgroup: testboxes (solo.home, , ) (x.home, , ) (nv.home, , ) (sandy.home, , ) (tom.= home, ,) laptops (alf.home, , ) (alf.home-air, , ) (sirion.home, , ) (sirion.home-ai= r, , ) The http://people.freebsd.org/~kib/misc/netgr.c shows the issue. Run it as "netgr testboxes laptops". Your change below makes lp->l_lines pointer for already processed groups invalid because you reallocf(3) the memory pointed by it. Then 1. accessing the l_lines later causes undefined behaviour; 2. free(3) call in endnetgrent() dies because pointer is dandling. > @@ -595,15 +615,15 @@ read_for_group(const char *group) > } else > cont =3D 0; > if (len > 0) { > - linep =3D (char *)malloc(olen + len + 1); > - if (olen > 0) { > - bcopy(olinep, linep, olen); > - free(olinep); > + linep =3D reallocf(linep, olen + len + 1); > + if (linep =3D=3D NULL) { > + free(lp->l_groupname); > + free(lp); > + return (NULL); > } > bcopy(pos, linep + olen, len); > olen +=3D len; > *(linep + olen) =3D '\0'; > - olinep =3D linep; > } > if (cont) { > if (fgets(line, LINSIZ, netf)) { Below is partial revert of your changes that cures mountd for me. Also, the second patch does some further cleanup of the getnetgrent.c. Do you agree ? commit d5cb6720e8d12b281e89f2487561fe95addd0e34 Author: Konstantin Belousov Date: Sat Jun 16 00:21:11 2012 +0300 Partially revert r235740, namely, allocate separate blocks of memory for each group' l_line. Using the reallocf(3) invalidates l_line's of the previously read groups. diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 933a7d3..8cad6c4 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -538,7 +538,7 @@ parse_netgrp(const char *group) static struct linelist * read_for_group(const char *group) { - char *pos, *spos, *linep; + char *pos, *spos, *linep, *olinep; int len, olen; int cont; struct linelist *lp; @@ -615,15 +615,20 @@ read_for_group(const char *group) } else cont =3D 0; if (len > 0) { - linep =3D reallocf(linep, olen + len + 1); + linep =3D malloc(olen + len + 1); if (linep =3D=3D NULL) { free(lp->l_groupname); free(lp); return (NULL); } + if (olen > 0) { + bcopy(olinep, linep, olen); + free(olinep); + } bcopy(pos, linep + olen, len); olen +=3D len; *(linep + olen) =3D '\0'; + olinep =3D linep; } if (cont) { if (fgets(line, LINSIZ, netf)) { commit 5946753b4b094d5f7ac41792df64915434567fd8 Author: Konstantin Belousov Date: Sat Jun 16 00:23:01 2012 +0300 More style. diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index 8cad6c4..d94fff7 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -161,8 +161,7 @@ setnetgrent(const char *group) if (group =3D=3D NULL || !strlen(group)) return; =20 - if (grouphead.gr =3D=3D (struct netgrp *)0 || - strcmp(group, grouphead.grname)) { + if (grouphead.gr =3D=3D NULL || strcmp(group, grouphead.grname)) { endnetgrent(); #ifdef YP /* Presumed guilty until proven innocent. */ @@ -172,7 +171,7 @@ setnetgrent(const char *group) * use NIS exclusively. */ if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) && - errno =3D=3D ENOENT) || _yp_statp.st_size =3D=3D 0) + errno =3D=3D ENOENT) || _yp_statp.st_size =3D=3D 0) _use_only_yp =3D _netgr_yp_enabled =3D 1; if ((netf =3D fopen(_PATH_NETGROUP,"r")) !=3D NULL ||_use_only_yp){ /* @@ -247,27 +246,24 @@ endnetgrent(void) lp =3D lp->l_next; free(olp->l_groupname); free(olp->l_line); - free((char *)olp); + free(olp); } - linehead =3D (struct linelist *)0; + linehead =3D NULL; if (grouphead.grname) { free(grouphead.grname); - grouphead.grname =3D (char *)0; + grouphead.grname =3D NULL; } gp =3D grouphead.gr; while (gp) { ogp =3D gp; gp =3D gp->ng_next; - if (ogp->ng_str[NG_HOST]) - free(ogp->ng_str[NG_HOST]); - if (ogp->ng_str[NG_USER]) - free(ogp->ng_str[NG_USER]); - if (ogp->ng_str[NG_DOM]) - free(ogp->ng_str[NG_DOM]); - free((char *)ogp); + free(ogp->ng_str[NG_HOST]); + free(ogp->ng_str[NG_USER]); + free(ogp->ng_str[NG_DOM]); + free(ogp); } - grouphead.gr =3D (struct netgrp *)0; - nextgrp =3D (struct netgrp *)0; + grouphead.gr =3D NULL; + nextgrp =3D NULL; #ifdef YP _netgr_yp_enabled =3D 0; #endif @@ -282,7 +278,7 @@ _listmatch(const char *list, const char *group, int len) int glen =3D strlen(group); =20 /* skip possible leading whitespace */ - while(isspace((unsigned char)*ptr)) + while (isspace((unsigned char)*ptr)) ptr++; =20 while (ptr < list + len) { @@ -291,7 +287,7 @@ _listmatch(const char *list, const char *group, int len) ptr++; if (strncmp(cptr, group, glen) =3D=3D 0 && glen =3D=3D (ptr - cptr)) return (1); - while(*ptr =3D=3D ',' || isspace((unsigned char)*ptr)) + while (*ptr =3D=3D ',' || isspace((unsigned char)*ptr)) ptr++; } =20 @@ -436,8 +432,7 @@ parse_netgrp(const char *group) break; lp =3D lp->l_next; } - if (lp =3D=3D (struct linelist *)0 && - (lp =3D read_for_group(group)) =3D=3D (struct linelist *)0) + if (lp =3D=3D NULL && (lp =3D read_for_group(group)) =3D=3D NULL) return (1); if (lp->l_parsed) { #ifdef DEBUG --WFYXJKyHTUiGqOmp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/bqJsACgkQC3+MBN1Mb4g0OgCeICn8JafwTeuEFyX6W/832Vdo 5t8An0ruEzvPgjB1ESel21VkvL/cSyH0 =AIOB -----END PGP SIGNATURE----- --WFYXJKyHTUiGqOmp-- From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 22:49:19 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B67691065677; Fri, 15 Jun 2012 22:49:19 +0000 (UTC) (envelope-from ghelmer@palisadesystems.com) Received: from mail.palisadesystems.com (mail.palisadesystems.com [216.81.178.129]) by mx1.freebsd.org (Postfix) with ESMTP id 6CC988FC14; Fri, 15 Jun 2012 22:49:19 +0000 (UTC) Received: from [192.168.1.107] (173-25-206-151.client.mchsi.com [173.25.206.151]) (authenticated bits=0) by mail.palisadesystems.com (8.14.3/8.14.3) with ESMTP id q5FMXRLt036836 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 15 Jun 2012 17:33:27 -0500 (CDT) (envelope-from ghelmer@palisadesystems.com) X-DKIM: Sendmail DKIM Filter v2.8.3 mail.palisadesystems.com q5FMXRLt036836 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=palisadesystems.com; s=mail; t=1339799608; bh=yoBitkjwxK1TY+PxvpZnl1H4Zvpybj3K6cfAErUHLzM=; l=128; h=Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc: Content-Transfer-Encoding:Message-Id:References:To; b=iuSFZISkdLjkeRGyxcpFx8D4Gc3YWCsDraVTpT0hzW8XFvWXHiWe2NPIREXwpqF0Q xq7KVrg/XrZPo1M9tlPa6FPm9Jv9Jea0WqAYJdTvPsx201rn74gh9UMGHldxUocnUb 4iHtnbkIK0UtaoGFfE6svzQwx6ytF8hWDbSQReM8= Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=windows-1252 From: Guy Helmer In-Reply-To: <20120615212651.GH2337@deviant.kiev.zoral.com.ua> Date: Fri, 15 Jun 2012 17:33:27 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <880C698D-7620-48CB-B0EB-68BBC7FECDBB@palisadesystems.com> References: <201206142148.q5ELmFul023002@svn.freebsd.org> <20120615212651.GH2337@deviant.kiev.zoral.com.ua> To: Konstantin Belousov X-Mailer: Apple Mail (2.1278) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.5 (mail.palisadesystems.com [172.16.1.5]); Fri, 15 Jun 2012 17:33:28 -0500 (CDT) X-Palisade-MailScanner-Information: Please contact the ISP for more information X-Palisade-MailScanner-ID: q5FMXRLt036836 X-Palisade-MailScanner: Found to be clean X-Palisade-MailScanner-SpamCheck: not spam, SpamAssassin (score=2.084, required 5, ALL_TRUSTED -1.00, BAYES_00 -1.90, J_CHICKENPOX_53 0.60, J_CHICKENPOX_56 0.60, J_CHICKENPOX_64 0.60, J_CHICKENPOX_65 0.60, J_CHICKENPOX_92 0.60, RP_8BIT 1.98) X-Palisade-MailScanner-SpamScore: ss X-Palisade-MailScanner-From: ghelmer@palisadesystems.com X-Spam-Status: No Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r237106 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 22:49:19 -0000 On Jun 15, 2012, at 4:26 PM, Konstantin Belousov wrote: > On Thu, Jun 14, 2012 at 09:48:15PM +0000, Guy Helmer wrote: >> Author: ghelmer >> Date: Thu Jun 14 21:48:14 2012 >> New Revision: 237106 >> URL: http://svn.freebsd.org/changeset/base/237106 >>=20 >> Log: >> MFC 235739-235740,236402: >> Apply style(9) to return and switch/case statements. >>=20 >> Add checks for memory allocation failures in appropriate places, and >> avoid creating bad entries in the grp list as a result of memory = allocation >> failures while building new entries. >>=20 >> Style(9) improvements: remove unnecessary parenthesis, improve order >> of local variable declarations, remove bogus casts, and resolve long >> lines. >>=20 >> PR: bin/83340 >>=20 >> Modified: >> stable/9/lib/libc/gen/getnetgrent.c >> Directory Properties: >> stable/9/lib/libc/ (props changed) >>=20 > This broke mountd(8) for me. It dies with SIGSEGV on start. Autopsy = has > shown that this happen due to free(3) on an unallocated pointer. >=20 > I have two netgroups in my /etc/netgroup: > testboxes (solo.home, , ) (x.home, , ) (nv.home, , ) (sandy.home, , ) = (tom.home, ,) > laptops (alf.home, , ) (alf.home-air, , ) (sirion.home, , ) = (sirion.home-air, , ) >=20 > The http://people.freebsd.org/~kib/misc/netgr.c shows the issue. Run = it > as "netgr testboxes laptops". >=20 > Your change below makes lp->l_lines pointer for already processed = groups > invalid because you reallocf(3) the memory pointed by it. Then > 1. accessing the l_lines later causes undefined behaviour; > 2. free(3) call in endnetgrent() dies because pointer is dandling. >=20 >> @@ -595,15 +615,15 @@ read_for_group(const char *group) >> } else >> cont =3D 0; >> if (len > 0) { >> - linep =3D (char *)malloc(olen + = len + 1); >> - if (olen > 0) { >> - bcopy(olinep, linep, = olen); >> - free(olinep); >> + linep =3D reallocf(linep, olen + = len + 1); >> + if (linep =3D=3D NULL) { >> + free(lp->l_groupname); >> + free(lp); >> + return (NULL); >> } >> bcopy(pos, linep + olen, len); >> olen +=3D len; >> *(linep + olen) =3D '\0'; >> - olinep =3D linep; >> } >> if (cont) { >> if (fgets(line, LINSIZ, netf)) { >=20 > Below is partial revert of your changes that cures mountd for me. = Also, > the second patch does some further cleanup of the getnetgrent.c. >=20 > Do you agree ? Sorry for the breakage. FWIW, I am having difficulty seeing how: linep =3D malloc(olen + len + = 1); =85 if (olen > 0) { bcopy(olinep, linep, = olen); free(olinep); } is different from: linep =3D reallocf(linep, olen + = len + 1); but if it fixes the issue, it is good. I would beware the disorder in = the sorting of the variables in the line: char *pos, *spos, *linep, *olinep;". Thank you for researching and resolving the issue. Guy >=20 > commit d5cb6720e8d12b281e89f2487561fe95addd0e34 > Author: Konstantin Belousov > Date: Sat Jun 16 00:21:11 2012 +0300 >=20 > Partially revert r235740, namely, allocate separate blocks of = memory > for each group' l_line. Using the reallocf(3) invalidates l_line's = of > the previously read groups. >=20 > diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c > index 933a7d3..8cad6c4 100644 > --- a/lib/libc/gen/getnetgrent.c > +++ b/lib/libc/gen/getnetgrent.c > @@ -538,7 +538,7 @@ parse_netgrp(const char *group) > static struct linelist * > read_for_group(const char *group) > { > - char *pos, *spos, *linep; > + char *pos, *spos, *linep, *olinep; > int len, olen; > int cont; > struct linelist *lp; > @@ -615,15 +615,20 @@ read_for_group(const char *group) > } else > cont =3D 0; > if (len > 0) { > - linep =3D reallocf(linep, olen + = len + 1); > + linep =3D malloc(olen + len + = 1); > if (linep =3D=3D NULL) { > free(lp->l_groupname); > free(lp); > return (NULL); > } > + if (olen > 0) { > + bcopy(olinep, linep, = olen); > + free(olinep); > + } > bcopy(pos, linep + olen, len); > olen +=3D len; > *(linep + olen) =3D '\0'; > + olinep =3D linep; > } > if (cont) { > if (fgets(line, LINSIZ, netf)) { >=20 >=20 > commit 5946753b4b094d5f7ac41792df64915434567fd8 > Author: Konstantin Belousov > Date: Sat Jun 16 00:23:01 2012 +0300 >=20 > More style. >=20 > diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c > index 8cad6c4..d94fff7 100644 > --- a/lib/libc/gen/getnetgrent.c > +++ b/lib/libc/gen/getnetgrent.c > @@ -161,8 +161,7 @@ setnetgrent(const char *group) > if (group =3D=3D NULL || !strlen(group)) > return; >=20 > - if (grouphead.gr =3D=3D (struct netgrp *)0 || > - strcmp(group, grouphead.grname)) { > + if (grouphead.gr =3D=3D NULL || strcmp(group, grouphead.grname)) = { > endnetgrent(); > #ifdef YP > /* Presumed guilty until proven innocent. */ > @@ -172,7 +171,7 @@ setnetgrent(const char *group) > * use NIS exclusively. > */ > if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) && > - errno =3D=3D ENOENT) || _yp_statp.st_size =3D=3D = 0) > + errno =3D=3D ENOENT) || _yp_statp.st_size =3D=3D 0) > _use_only_yp =3D _netgr_yp_enabled =3D 1; > if ((netf =3D fopen(_PATH_NETGROUP,"r")) !=3D NULL = ||_use_only_yp){ > /* > @@ -247,27 +246,24 @@ endnetgrent(void) > lp =3D lp->l_next; > free(olp->l_groupname); > free(olp->l_line); > - free((char *)olp); > + free(olp); > } > - linehead =3D (struct linelist *)0; > + linehead =3D NULL; > if (grouphead.grname) { > free(grouphead.grname); > - grouphead.grname =3D (char *)0; > + grouphead.grname =3D NULL; > } > gp =3D grouphead.gr; > while (gp) { > ogp =3D gp; > gp =3D gp->ng_next; > - if (ogp->ng_str[NG_HOST]) > - free(ogp->ng_str[NG_HOST]); > - if (ogp->ng_str[NG_USER]) > - free(ogp->ng_str[NG_USER]); > - if (ogp->ng_str[NG_DOM]) > - free(ogp->ng_str[NG_DOM]); > - free((char *)ogp); > + free(ogp->ng_str[NG_HOST]); > + free(ogp->ng_str[NG_USER]); > + free(ogp->ng_str[NG_DOM]); > + free(ogp); > } > - grouphead.gr =3D (struct netgrp *)0; > - nextgrp =3D (struct netgrp *)0; > + grouphead.gr =3D NULL; > + nextgrp =3D NULL; > #ifdef YP > _netgr_yp_enabled =3D 0; > #endif > @@ -282,7 +278,7 @@ _listmatch(const char *list, const char *group, = int len) > int glen =3D strlen(group); >=20 > /* skip possible leading whitespace */ > - while(isspace((unsigned char)*ptr)) > + while (isspace((unsigned char)*ptr)) > ptr++; >=20 > while (ptr < list + len) { > @@ -291,7 +287,7 @@ _listmatch(const char *list, const char *group, = int len) > ptr++; > if (strncmp(cptr, group, glen) =3D=3D 0 && glen =3D=3D = (ptr - cptr)) > return (1); > - while(*ptr =3D=3D ',' || isspace((unsigned char)*ptr)) > + while (*ptr =3D=3D ',' || isspace((unsigned char)*ptr)) > ptr++; > } >=20 > @@ -436,8 +432,7 @@ parse_netgrp(const char *group) > break; > lp =3D lp->l_next; > } > - if (lp =3D=3D (struct linelist *)0 && > - (lp =3D read_for_group(group)) =3D=3D (struct linelist *)0) > + if (lp =3D=3D NULL && (lp =3D read_for_group(group)) =3D=3D = NULL) > return (1); > if (lp->l_parsed) { > #ifdef DEBUG From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 22:56:16 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F6E7106566B; Fri, 15 Jun 2012 22:56:16 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 387E58FC0A; Fri, 15 Jun 2012 22:56:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5FMuGlm008340; Fri, 15 Jun 2012 22:56:16 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5FMuGFJ008338; Fri, 15 Jun 2012 22:56:16 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201206152256.q5FMuGFJ008338@svn.freebsd.org> From: Glen Barber Date: Fri, 15 Jun 2012 22:56:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237148 - stable/9/cddl/contrib/opensolaris/cmd/zpool X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 22:56:16 -0000 Author: gjb (doc committer) Date: Fri Jun 15 22:56:15 2012 New Revision: 237148 URL: http://svn.freebsd.org/changeset/base/237148 Log: MFC r236776, r236777: r236776: Fix a typo: s/deafult/default r236777: Clean up trailing whitespace. Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Fri Jun 15 21:48:17 2012 (r237147) +++ stable/9/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Fri Jun 15 22:56:15 2012 (r237148) @@ -189,7 +189,7 @@ for information on managing datasets. A .Qq virtual device .Pq No vdev -describes a single device or a collection of devices organized according to +describes a single device or a collection of devices organized according to certain performance and fault characteristics. The following virtual devices are supported: .Bl -tag @@ -237,7 +237,7 @@ A group can have single-, double- , or triple parity, meaning that the .No raidz group can sustain one, two, or three failures, respectively, without -losing any data. The +losing any data. The .Sy raidz1 No vdev type specifies a single-parity .No raidz @@ -287,7 +287,7 @@ writes are load-balanced between devices .No raidz .No vdev types are not supported for the intent log. For more information, -see the +see the .Qq Sx Intent Log section. .It Sy cache @@ -309,13 +309,13 @@ A pool can have any number of virtual de (known as .Qq root .No vdev Ns s). -Data is dynamically distributed across all top-level devices to balance data +Data is dynamically distributed across all top-level devices to balance data among devices. As new virtual devices are added, .Tn ZFS automatically places data on the newly available devices. .Pp Virtual devices are specified one at a time on the command line, separated by -whitespace. The keywords +whitespace. The keywords .Qq mirror and .Qq raidz @@ -428,7 +428,7 @@ allows devices to be associated with poo .Qq hot spares . These devices are not actively used in the pool, but when an active device fails, it is automatically replaced by a hot spare. To create a pool with hot -spares, specify a +spares, specify a .Qq spare .No vdev with any number of devices. For example, @@ -458,7 +458,7 @@ pools. .Pp Spares cannot replace log devices. .Ss Intent Log -The +The .Tn ZFS Intent Log .Pq Tn ZIL @@ -582,7 +582,7 @@ the typical paths are not valid. .Sy altroot is not a persistent property. It is valid only while the system is up. Setting -.Sy altroot +.Sy altroot defaults to using .Cm cachefile=none , though this may be overridden using an explicit setting. @@ -627,9 +627,9 @@ This property can also be referred to by .It Sy autoreplace Ns = Ns Cm on No | Cm off Controls automatic device replacement. If set to .Qq Cm off , -device replacement must be initiated by the administrator by using the +device replacement must be initiated by the administrator by using the .Qq Nm Cm replace -command. If set to +command. If set to .Qq Cm on , any new device, found in the same physical location as a device that previously belonged to the pool, is @@ -650,13 +650,13 @@ pool configuration in a different locati .Qq Nm Cm import Fl c . Setting it to the special value .Qq Cm none -creates a temporary pool that is never cached, and the special value +creates a temporary pool that is never cached, and the special value .Cm '' (empty string) uses the default location. .It Sy dedupditto Ns = Ns Ar number Threshold for the number of block ditto copies. If the reference count for a deduplicated block increases above this number, a new ditto copy of this block -is automatically stored. Deafult setting is +is automatically stored. Default setting is .Cm 0 . .It Sy delegation Ns = Ns Cm on No | Cm off Controls whether a non-privileged user is granted access based on the dataset @@ -861,7 +861,7 @@ root dataset cannot be mounted. This can option. .Bl -tag -width indent .It Fl f -Forces use of +Forces use of .Ar vdev Ns s, even if they appear in use or specify a conflicting replication level. Not all devices can be overridden in this manner. @@ -897,7 +897,7 @@ or .Qq Cm altroot Ns Pa /pool if .Sy altroot -is specified. The mount point must be an absolute path, +is specified. The mount point must be an absolute path, .Qq Cm legacy , or .Qq Cm none . @@ -1234,7 +1234,7 @@ seconds until .Sy Ctrl-C is pressed. If no .Ar pools -are specified, statistics for every pool in the system is shown. If +are specified, statistics for every pool in the system is shown. If .Ar count is specified, the command exits after .Ar count @@ -1292,7 +1292,7 @@ When given an interval, the output is pr .Ar interval seconds until .Sy Ctrl-C -is pressed. If +is pressed. If .Ar count is specified, the command exits after .Ar count @@ -1398,7 +1398,7 @@ This is equivalent to attaching waiting for it to resilver, and then detaching .Ar old_device . .Pp -The size of +The size of .Ar new_device must be greater than or equal to the minimum size of all the devices in a mirror or @@ -1409,7 +1409,7 @@ configuration. is required if the pool is not redundant. If .Ar new_device is not specified, it defaults to -.Ar old_device . +.Ar old_device . This form of replacement is useful after an existing disk has failed and has been physically replaced. In this case, the new disk may have the same .Pa /dev @@ -1496,12 +1496,12 @@ unless overridden by a device specificat .Pp When using a .Ar device -argument, +argument, .Cm split -includes the specified device(s) in a new pool and, should any devices remain +includes the specified device(s) in a new pool and, should any devices remain unspecified, assigns the last device in each mirror .No vdev -to that pool, as it does normally. If you are uncertain about the outcome of a +to that pool, as it does normally. If you are uncertain about the outcome of a .Cm split command, use the .Fl n @@ -1554,7 +1554,7 @@ When given an interval, the output is pr .Ar interval seconds until .Sy Ctrl-C -is pressed. If +is pressed. If .Ar count is specified, the command exits after .Ar count From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 23:02:39 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 465ED106566B; Fri, 15 Jun 2012 23:02:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B6B248FC0A; Fri, 15 Jun 2012 23:02:38 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5FN2PFa086395; Sat, 16 Jun 2012 02:02:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5FN2Otj036027; Sat, 16 Jun 2012 02:02:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5FN2O3S036026; Sat, 16 Jun 2012 02:02:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 16 Jun 2012 02:02:24 +0300 From: Konstantin Belousov To: Guy Helmer Message-ID: <20120615230224.GI2337@deviant.kiev.zoral.com.ua> References: <201206142148.q5ELmFul023002@svn.freebsd.org> <20120615212651.GH2337@deviant.kiev.zoral.com.ua> <880C698D-7620-48CB-B0EB-68BBC7FECDBB@palisadesystems.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OtZJUqNUNrB9XA/T" Content-Disposition: inline In-Reply-To: <880C698D-7620-48CB-B0EB-68BBC7FECDBB@palisadesystems.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org Subject: Re: svn commit: r237106 - stable/9/lib/libc/gen X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 23:02:39 -0000 --OtZJUqNUNrB9XA/T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 15, 2012 at 05:33:27PM -0500, Guy Helmer wrote: >=20 > On Jun 15, 2012, at 4:26 PM, Konstantin Belousov wrote: >=20 > > On Thu, Jun 14, 2012 at 09:48:15PM +0000, Guy Helmer wrote: > >> Author: ghelmer > >> Date: Thu Jun 14 21:48:14 2012 > >> New Revision: 237106 > >> URL: http://svn.freebsd.org/changeset/base/237106 > >>=20 > >> Log: > >> MFC 235739-235740,236402: > >> Apply style(9) to return and switch/case statements. > >>=20 > >> Add checks for memory allocation failures in appropriate places, and > >> avoid creating bad entries in the grp list as a result of memory allo= cation > >> failures while building new entries. > >>=20 > >> Style(9) improvements: remove unnecessary parenthesis, improve order > >> of local variable declarations, remove bogus casts, and resolve long > >> lines. > >>=20 > >> PR: bin/83340 > >>=20 > >> Modified: > >> stable/9/lib/libc/gen/getnetgrent.c > >> Directory Properties: > >> stable/9/lib/libc/ (props changed) > >>=20 > > This broke mountd(8) for me. It dies with SIGSEGV on start. Autopsy has > > shown that this happen due to free(3) on an unallocated pointer. > >=20 > > I have two netgroups in my /etc/netgroup: > > testboxes (solo.home, , ) (x.home, , ) (nv.home, , ) (sandy.home, , ) (= tom.home, ,) > > laptops (alf.home, , ) (alf.home-air, , ) (sirion.home, , ) (sirion.hom= e-air, , ) > >=20 > > The http://people.freebsd.org/~kib/misc/netgr.c shows the issue. Run it > > as "netgr testboxes laptops". > >=20 > > Your change below makes lp->l_lines pointer for already processed groups > > invalid because you reallocf(3) the memory pointed by it. Then > > 1. accessing the l_lines later causes undefined behaviour; > > 2. free(3) call in endnetgrent() dies because pointer is dandling. > >=20 > >> @@ -595,15 +615,15 @@ read_for_group(const char *group) > >> } else > >> cont =3D 0; > >> if (len > 0) { > >> - linep =3D (char *)malloc(olen + len + 1); > >> - if (olen > 0) { > >> - bcopy(olinep, linep, olen); > >> - free(olinep); > >> + linep =3D reallocf(linep, olen + len + 1); > >> + if (linep =3D=3D NULL) { > >> + free(lp->l_groupname); > >> + free(lp); > >> + return (NULL); > >> } > >> bcopy(pos, linep + olen, len); > >> olen +=3D len; > >> *(linep + olen) =3D '\0'; > >> - olinep =3D linep; > >> } > >> if (cont) { > >> if (fgets(line, LINSIZ, netf)) { > >=20 > > Below is partial revert of your changes that cures mountd for me. Also, > > the second patch does some further cleanup of the getnetgrent.c. > >=20 > > Do you agree ? >=20 > Sorry for the breakage. FWIW, I am having difficulty seeing how: >=20 > linep =3D malloc(olen + len + 1); > ? > if (olen > 0) { > bcopy(olinep, linep, olen); > free(olinep); > } >=20 > is different from: >=20 > linep =3D reallocf(linep, olen + len + 1); >=20 The old value of linep is invalid after the call to reallocf() and must be not used further. But it is saved as l_line value, so it gets free()d. You de-facto use very long line, containing lines for all groups, with l_line pointing in the middle of it. It is some luck that in my case reallocf() was able to extend original chunk, otherwise I would also get garbage in l_lines. >=20 > but if it fixes the issue, it is good. I would beware the disorder in the= sorting of the variables in the line: >=20 > char *pos, *spos, *linep, *olinep;". Fixed. --OtZJUqNUNrB9XA/T Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/bvwAACgkQC3+MBN1Mb4hrHwCfZuxLndQKUvjGXpuROMnTrxlg 9AoAn3Q7rGBlwe6Xkpk9hhancGAtFP4R =JoUY -----END PGP SIGNATURE----- --OtZJUqNUNrB9XA/T-- From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 15 23:07:51 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EB900106566B; Fri, 15 Jun 2012 23:07:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5B368FC08; Fri, 15 Jun 2012 23:07:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5FN7pBu008902; Fri, 15 Jun 2012 23:07:51 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5FN7piK008900; Fri, 15 Jun 2012 23:07:51 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206152307.q5FN7piK008900@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 15 Jun 2012 23:07:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237150 - stable/9/sys/powerpc/aim X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 23:07:52 -0000 Author: kib Date: Fri Jun 15 23:07:51 2012 New Revision: 237150 URL: http://svn.freebsd.org/changeset/base/237150 Log: MFC r230779: Fix build for the case of powerpc64 kernel without COMPAT_FREEBSD32. Pointy hat to: kib Modified: stable/9/sys/powerpc/aim/mmu_oea64.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/powerpc/aim/mmu_oea64.c ============================================================================== --- stable/9/sys/powerpc/aim/mmu_oea64.c Fri Jun 15 22:56:28 2012 (r237149) +++ stable/9/sys/powerpc/aim/mmu_oea64.c Fri Jun 15 23:07:51 2012 (r237150) @@ -114,6 +114,7 @@ __FBSDID("$FreeBSD$"); * correct. */ +#include "opt_compat.h" #include "opt_kstack_pages.h" #include @@ -1469,7 +1470,9 @@ moea64_init(mmu_t mmu) uma_zone_set_allocf(moea64_mpvo_zone,moea64_uma_page_alloc); } +#ifdef COMPAT_FREEBSD32 elf32_nxstack = 1; +#endif moea64_initialized = TRUE; } From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 16 13:22:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BF1451065674; Sat, 16 Jun 2012 13:22:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A832B8FC12; Sat, 16 Jun 2012 13:22:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5GDMt00046368; Sat, 16 Jun 2012 13:22:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5GDMtee046365; Sat, 16 Jun 2012 13:22:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206161322.q5GDMtee046365@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 16 Jun 2012 13:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237161 - in stable/9/sys: amd64/include i386/include X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2012 13:22:55 -0000 Author: kib Date: Sat Jun 16 13:22:55 2012 New Revision: 237161 URL: http://svn.freebsd.org/changeset/base/237161 Log: MFC r236456: Use plain store for atomic_store_rel on x86, instead of implicitly locked xchg instruction. IA32 memory model guarantees that store has release semantic, since stores cannot pass loads or stores. Modified: stable/9/sys/amd64/include/atomic.h stable/9/sys/i386/include/atomic.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/include/atomic.h ============================================================================== --- stable/9/sys/amd64/include/atomic.h Sat Jun 16 13:11:10 2012 (r237160) +++ stable/9/sys/amd64/include/atomic.h Sat Jun 16 13:22:55 2012 (r237161) @@ -81,8 +81,9 @@ int atomic_cmpset_long(volatile u_long * u_int atomic_fetchadd_int(volatile u_int *p, u_int v); u_long atomic_fetchadd_long(volatile u_long *p, u_long v); -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ -u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \ +#define ATOMIC_LOAD(TYPE, LOP) \ +u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p) +#define ATOMIC_STORE(TYPE) \ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) #else /* !KLD_MODULE && __GNUCLIKE_ASM */ @@ -210,37 +211,43 @@ atomic_fetchadd_long(volatile u_long *p, return (v); } -#if defined(_KERNEL) && !defined(SMP) - /* - * We assume that a = b will do atomic loads and stores. However, on a - * PentiumPro or higher, reads may pass writes, so for that case we have - * to use a serializing instruction (i.e. with LOCK) to do the load in - * SMP kernels. For UP kernels, however, the cache of the single processor - * is always consistent, so we only need to take care of compiler. + * We assume that a = b will do atomic loads and stores. Due to the + * IA32 memory model, a simple store guarantees release semantics. + * + * However, loads may pass stores, so for atomic_load_acq we have to + * ensure a Store/Load barrier to do the load in SMP kernels. We use + * "lock cmpxchg" as recommended by the AMD Software Optimization + * Guide, and not mfence. For UP kernels, however, the cache of the + * single processor is always consistent, so we only need to take care + * of the compiler. */ -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ +#define ATOMIC_STORE(TYPE) \ +static __inline void \ +atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ +{ \ + __asm __volatile("" : : : "memory"); \ + *p = v; \ +} \ +struct __hack + +#if defined(_KERNEL) && !defined(SMP) + +#define ATOMIC_LOAD(TYPE, LOP) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ u_##TYPE tmp; \ \ tmp = *p; \ - __asm __volatile ("" : : : "memory"); \ + __asm __volatile("" : : : "memory"); \ return (tmp); \ } \ - \ -static __inline void \ -atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ -{ \ - __asm __volatile ("" : : : "memory"); \ - *p = v; \ -} \ struct __hack #else /* !(_KERNEL && !SMP) */ -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ +#define ATOMIC_LOAD(TYPE, LOP) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ @@ -254,19 +261,6 @@ atomic_load_acq_##TYPE(volatile u_##TYPE \ return (res); \ } \ - \ -/* \ - * The XCHG instruction asserts LOCK automagically. \ - */ \ -static __inline void \ -atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ -{ \ - __asm __volatile(SOP \ - : "=m" (*p), /* 0 */ \ - "+r" (v) /* 1 */ \ - : "m" (*p) /* 2 */ \ - : "memory"); \ -} \ struct __hack #endif /* _KERNEL && !SMP */ @@ -293,13 +287,19 @@ ATOMIC_ASM(clear, long, "andq %1,%0" ATOMIC_ASM(add, long, "addq %1,%0", "ir", v); ATOMIC_ASM(subtract, long, "subq %1,%0", "ir", v); -ATOMIC_STORE_LOAD(char, "cmpxchgb %b0,%1", "xchgb %b1,%0"); -ATOMIC_STORE_LOAD(short,"cmpxchgw %w0,%1", "xchgw %w1,%0"); -ATOMIC_STORE_LOAD(int, "cmpxchgl %0,%1", "xchgl %1,%0"); -ATOMIC_STORE_LOAD(long, "cmpxchgq %0,%1", "xchgq %1,%0"); +ATOMIC_LOAD(char, "cmpxchgb %b0,%1"); +ATOMIC_LOAD(short, "cmpxchgw %w0,%1"); +ATOMIC_LOAD(int, "cmpxchgl %0,%1"); +ATOMIC_LOAD(long, "cmpxchgq %0,%1"); + +ATOMIC_STORE(char); +ATOMIC_STORE(short); +ATOMIC_STORE(int); +ATOMIC_STORE(long); #undef ATOMIC_ASM -#undef ATOMIC_STORE_LOAD +#undef ATOMIC_LOAD +#undef ATOMIC_STORE #ifndef WANT_FUNCTIONS Modified: stable/9/sys/i386/include/atomic.h ============================================================================== --- stable/9/sys/i386/include/atomic.h Sat Jun 16 13:11:10 2012 (r237160) +++ stable/9/sys/i386/include/atomic.h Sat Jun 16 13:22:55 2012 (r237161) @@ -32,9 +32,9 @@ #error this file needs sys/cdefs.h as a prerequisite #endif -#define mb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory") -#define wmb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory") -#define rmb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory") +#define mb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory", "cc") +#define wmb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory", "cc") +#define rmb() __asm __volatile("lock; addl $0,(%%esp)" : : : "memory", "cc") /* * Various simple operations on memory, each of which is atomic in the @@ -79,8 +79,9 @@ void atomic_##NAME##_barr_##TYPE(volatil int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); u_int atomic_fetchadd_int(volatile u_int *p, u_int v); -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ -u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \ +#define ATOMIC_LOAD(TYPE, LOP) \ +u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p) +#define ATOMIC_STORE(TYPE) \ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) #else /* !KLD_MODULE && __GNUCLIKE_ASM */ @@ -280,16 +281,29 @@ atomic_fetchadd_int(volatile u_int *p, u return (v); } -#if defined(_KERNEL) && !defined(SMP) - /* - * We assume that a = b will do atomic loads and stores. However, on a - * PentiumPro or higher, reads may pass writes, so for that case we have - * to use a serializing instruction (i.e. with LOCK) to do the load in - * SMP kernels. For UP kernels, however, the cache of the single processor - * is always consistent, so we only need to take care of compiler. + * We assume that a = b will do atomic loads and stores. Due to the + * IA32 memory model, a simple store guarantees release semantics. + * + * However, loads may pass stores, so for atomic_load_acq we have to + * ensure a Store/Load barrier to do the load in SMP kernels. We use + * "lock cmpxchg" as recommended by the AMD Software Optimization + * Guide, and not mfence. For UP kernels, however, the cache of the + * single processor is always consistent, so we only need to take care + * of the compiler. */ -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ +#define ATOMIC_STORE(TYPE) \ +static __inline void \ +atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ +{ \ + __asm __volatile("" : : : "memory"); \ + *p = v; \ +} \ +struct __hack + +#if defined(_KERNEL) && !defined(SMP) + +#define ATOMIC_LOAD(TYPE, LOP) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ @@ -299,18 +313,11 @@ atomic_load_acq_##TYPE(volatile u_##TYPE __asm __volatile("" : : : "memory"); \ return (tmp); \ } \ - \ -static __inline void \ -atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ -{ \ - __asm __volatile("" : : : "memory"); \ - *p = v; \ -} \ struct __hack #else /* !(_KERNEL && !SMP) */ -#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \ +#define ATOMIC_LOAD(TYPE, LOP) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ @@ -324,19 +331,6 @@ atomic_load_acq_##TYPE(volatile u_##TYPE \ return (res); \ } \ - \ -/* \ - * The XCHG instruction asserts LOCK automagically. \ - */ \ -static __inline void \ -atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ -{ \ - __asm __volatile(SOP \ - : "=m" (*p), /* 0 */ \ - "+r" (v) /* 1 */ \ - : "m" (*p) /* 2 */ \ - : "memory"); \ -} \ struct __hack #endif /* _KERNEL && !SMP */ @@ -363,13 +357,19 @@ ATOMIC_ASM(clear, long, "andl %1,%0" ATOMIC_ASM(add, long, "addl %1,%0", "ir", v); ATOMIC_ASM(subtract, long, "subl %1,%0", "ir", v); -ATOMIC_STORE_LOAD(char, "cmpxchgb %b0,%1", "xchgb %b1,%0"); -ATOMIC_STORE_LOAD(short,"cmpxchgw %w0,%1", "xchgw %w1,%0"); -ATOMIC_STORE_LOAD(int, "cmpxchgl %0,%1", "xchgl %1,%0"); -ATOMIC_STORE_LOAD(long, "cmpxchgl %0,%1", "xchgl %1,%0"); +ATOMIC_LOAD(char, "cmpxchgb %b0,%1"); +ATOMIC_LOAD(short, "cmpxchgw %w0,%1"); +ATOMIC_LOAD(int, "cmpxchgl %0,%1"); +ATOMIC_LOAD(long, "cmpxchgl %0,%1"); + +ATOMIC_STORE(char); +ATOMIC_STORE(short); +ATOMIC_STORE(int); +ATOMIC_STORE(long); #undef ATOMIC_ASM -#undef ATOMIC_STORE_LOAD +#undef ATOMIC_LOAD +#undef ATOMIC_STORE #ifndef WANT_FUNCTIONS