svn commit: r238092 - in head/sys: net netinet netinet6

2012-07-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Jul  4 07:37:53 2012
New Revision: 238092
URL: http://svn.freebsd.org/changeset/base/238092

Log:
  When ip_output()/ip6_output() is supplied a struct route *ro argument,
  it skips FLOWTABLE lookup. However, the non-NULL ro has dual meaning
  here: it may be supplied to provide route, and it may be supplied to
  store and return to caller the route that ip_output()/ip6_output()
  finds. In the latter case skipping FLOWTABLE lookup is pessimisation.
  
  The difference between struct route filled by FLOWTABLE and filled
  by rtalloc() family is that the former doesn't hold a reference on
  its rtentry. Reference is hold by flow entry, and it is about to
  be released in future. Thus, route filled by FLOWTABLE shouldn't
  be passed to RTFREE() macro.
  
  - Introduce new flag for struct route/route_in6, that marks route
not holding a reference on rtentry.
  - Introduce new macro RO_RTFREE() that cleans up a struct route
depending on its kind.
  - All callers to ip_output()/ip6_output() that do supply non-NULL
but empty route should use RO_RTFREE() to free results of
lookup.
  - ip_output()/ip6_output() now do FLOWTABLE lookup always when
ro->ro_rt == NULL.
  
  Tested by:tuexen (SCTP part)

Modified:
  head/sys/net/flowtable.c
  head/sys/net/route.h
  head/sys/netinet/ip_input.c
  head/sys/netinet/ip_output.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet6/ip6_output.c
  head/sys/netinet6/nd6_nbr.c

Modified: head/sys/net/flowtable.c
==
--- head/sys/net/flowtable.cWed Jul  4 06:29:56 2012(r238091)
+++ head/sys/net/flowtable.cWed Jul  4 07:37:53 2012(r238092)
@@ -619,6 +619,7 @@ flow_to_route(struct flentry *fle, struc
sin->sin_addr.s_addr = hashkey[2];
ro->ro_rt = __DEVOLATILE(struct rtentry *, fle->f_rt);
ro->ro_lle = __DEVOLATILE(struct llentry *, fle->f_lle);
+   ro->ro_flags |= RT_NORTREF;
 }
 #endif /* INET */
 
@@ -826,7 +827,7 @@ flow_to_route_in6(struct flentry *fle, s
memcpy(&sin6->sin6_addr, &hashkey[5], sizeof (struct in6_addr));
ro->ro_rt = __DEVOLATILE(struct rtentry *, fle->f_rt);
ro->ro_lle = __DEVOLATILE(struct llentry *, fle->f_lle);
-
+   ro->ro_flags |= RT_NORTREF;
 }
 #endif /* INET6 */
 

Modified: head/sys/net/route.h
==
--- head/sys/net/route.hWed Jul  4 06:29:56 2012(r238091)
+++ head/sys/net/route.hWed Jul  4 07:37:53 2012(r238092)
@@ -54,7 +54,8 @@ struct route {
struct  sockaddr ro_dst;
 };
 
-#define RT_CACHING_CONTEXT 0x1
+#defineRT_CACHING_CONTEXT  0x1 /* XXX: not used anywhere */
+#defineRT_NORTREF  0x2 /* doesn't hold reference on 
ro_rt */
 
 /*
  * These numbers are used by reliable protocols for determining
@@ -341,6 +342,18 @@ struct rt_addrinfo {
RTFREE_LOCKED(_rt); \
 } while (0)
 
+#defineRO_RTFREE(_ro) do { \
+   if ((_ro)->ro_rt) { \
+   if ((_ro)->ro_flags & RT_NORTREF) { \
+   (_ro)->ro_flags &= ~RT_NORTREF; \
+   (_ro)->ro_rt = NULL;\
+   } else {\
+   RT_LOCK((_ro)->ro_rt);  \
+   RTFREE_LOCKED((_ro)->ro_rt);\
+   }   \
+   }   \
+} while (0)
+
 struct radix_node_head *rt_tables_get_rnh(int, int);
 
 struct ifmultiaddr;

Modified: head/sys/netinet/ip_input.c
==
--- head/sys/netinet/ip_input.c Wed Jul  4 06:29:56 2012(r238091)
+++ head/sys/netinet/ip_input.c Wed Jul  4 07:37:53 2012(r238092)
@@ -1495,8 +1495,7 @@ ip_forward(struct mbuf *m, int srcrt)
 
if (error == EMSGSIZE && ro.ro_rt)
mtu = ro.ro_rt->rt_rmx.rmx_mtu;
-   if (ro.ro_rt)
-   RTFREE(ro.ro_rt);
+   RO_RTFREE(&ro);
 
if (error)
IPSTAT_INC(ips_cantforward);

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cWed Jul  4 06:29:56 2012
(r238091)
+++ head/sys/netinet/ip_output.cWed Jul  4 07:37:53 2012
(r238092)
@@ -105,6 +105,10 @@ extern struct protosw inetsw[];
  * ip_len and ip_off are in host format.
  * The mbuf chain containing the packet will be freed.
  * The mbuf opt, if present, will not be freed.
+ * If route ro is present and has ro_rt initialized, route lookup would be
+ * skipped and ro->ro_rt wo

svn commit: r238093 - head/share/man/man9

2012-07-04 Thread Gleb Smirnoff
Author: glebius
Date: Wed Jul  4 07:42:12 2012
New Revision: 238093
URL: http://svn.freebsd.org/changeset/base/238093

Log:
  Document RO_RTFREE() macro.

Modified:
  head/share/man/man9/rtalloc.9

Modified: head/share/man/man9/rtalloc.9
==
--- head/share/man/man9/rtalloc.9   Wed Jul  4 07:37:53 2012
(r238092)
+++ head/share/man/man9/rtalloc.9   Wed Jul  4 07:42:12 2012
(r238093)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 14, 2011
+.Dd July 4, 2012
 .Dt RTALLOC 9
 .Os
 .Sh NAME
@@ -52,6 +52,7 @@
 .Fn RT_UNLOCK "struct rt_entry *rt"
 .Fn RT_ADDREF "struct rt_entry *rt"
 .Fn RT_REMREF "struct rt_entry *rt"
+.Fn RO_RTFREE "struct route *ro"
 .Ft void
 .Fn rtfree "struct rt_entry *rt"
 .Ft "struct rtentry *"
@@ -203,6 +204,14 @@ Its usage is contrary to
 .Fn RT_ADDREF .
 .Pp
 The
+.Fn RO_RTFREE
+macro is used to free route entry that is referenced by struct route.
+At certain circumstances the latter may not hold a reference on rtentry,
+and
+.Fn RO_RTFREE
+treats such routes correctly.
+.Pp
+The
 .Fn rtfree
 function does the actual free of the routing table entry, and shouldn't
 be called directly by facilities, that just perform routing table lookups.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238094 - head/usr.sbin/nscd

2012-07-04 Thread Stefan Esser
Author: se
Date: Wed Jul  4 09:02:12 2012
New Revision: 238094
URL: http://svn.freebsd.org/changeset/base/238094

Log:
  Add the possibility to specify a threshold for the number of negative cache
  results required to have the cache return lookup failure.
  
  A new configuration parameter is introduced, which must be set to a value
  greater than 1 to activate this feature. The default behavior is unchanged.
  
  The purpose of this change is to allow probes for the existence of an entry
  (which are expected to fail), before that entry is added to one of the
  queried databases, without the cache returning the stale information from
  the probe query until that cache entry expires. If, for example, a new user
  account is created after checking that the new account name is available,
  the negative cache entry would prevent immediate access to the account.
  
  For that example, the new configuration option
  
  negative-confidence-threshold passwd 2
  
  will require a second negative query result to consider the negative cache
  entry for a passwd entry valid, but if the user account has been created
  between the queries, then the positive query result from the second query
  will be cached and returned.

Modified:
  head/usr.sbin/nscd/cachelib.c
  head/usr.sbin/nscd/cachelib.h
  head/usr.sbin/nscd/config.c
  head/usr.sbin/nscd/config.h
  head/usr.sbin/nscd/nscd.conf.5
  head/usr.sbin/nscd/parser.c

Modified: head/usr.sbin/nscd/cachelib.c
==
--- head/usr.sbin/nscd/cachelib.c   Wed Jul  4 07:42:12 2012
(r238093)
+++ head/usr.sbin/nscd/cachelib.c   Wed Jul  4 09:02:12 2012
(r238094)
@@ -726,6 +726,12 @@ cache_read(struct cache_entry_ *entry, c
TRACE_OUT(cache_read);
return (-1);
}
+   /* pretend that entry was not found if confidence is below threshold*/
+   if (find_res->confidence < 
+   common_entry->common_params.confidence_threshold) {
+   TRACE_OUT(cache_read);
+   return (-1);
+   }
 
if ((common_entry->common_params.max_lifetime.tv_sec != 0) ||
(common_entry->common_params.max_lifetime.tv_usec != 0)) {
@@ -826,6 +832,24 @@ cache_write(struct cache_entry_ *entry, 
item = HASHTABLE_GET_ENTRY(&(common_entry->items), hash);
find_res = HASHTABLE_ENTRY_FIND(cache_ht_, item, &item_data);
if (find_res != NULL) {
+   if (find_res->confidence < 
common_entry->common_params.confidence_threshold) {
+   /* duplicate entry is no error, if confidence is low */
+   if ((find_res->value_size == value_size) &&
+   (memcmp(find_res->value, value, value_size) == 0)) {
+   /* increase confidence on exact match (key and 
values) */
+   find_res->confidence++;
+   } else {
+   /* create new entry with low confidence, if 
value changed */
+   free(item_data.value);
+   item_data.value = malloc(value_size);
+   assert(item_data.value != NULL);
+   memcpy(item_data.value, value, value_size);
+   item_data.value_size = value_size;
+   find_res->confidence = 1;
+   }
+   TRACE_OUT(cache_write);
+   return (0);
+   }
TRACE_OUT(cache_write);
return (-1);
}
@@ -839,6 +863,8 @@ cache_write(struct cache_entry_ *entry, 
memcpy(item_data.value, value, value_size);
item_data.value_size = value_size;
 
+   item_data.confidence = 1;
+
policy_item = common_entry->policies[0]->create_item_func();
policy_item->key = item_data.key;
policy_item->key_size = item_data.key_size;

Modified: head/usr.sbin/nscd/cachelib.h
==
--- head/usr.sbin/nscd/cachelib.h   Wed Jul  4 07:42:12 2012
(r238093)
+++ head/usr.sbin/nscd/cachelib.h   Wed Jul  4 09:02:12 2012
(r238094)
@@ -92,6 +92,7 @@ struct common_cache_entry_params {
size_t  satisf_elemsize;/* if entry size is exceeded,
 * this number of elements will be left,
 * others will be deleted */
+   int confidence_threshold;   /* number matching replies required */
struct timeval  max_lifetime;   /* if 0 then no check is made */
enum cache_policy_t policy; /* policy used for transformations */
 };
@@ -116,6 +117,7 @@ struct cache_ht_item_data_ {
size_t  value_size;
 
struct cache_policy_item_ *fifo_policy_item;
+   int confidence; 

svn commit: r238095 - head/usr.sbin/nscd

2012-07-04 Thread Joel Dahl
Author: joel (doc committer)
Date: Wed Jul  4 10:17:02 2012
New Revision: 238095
URL: http://svn.freebsd.org/changeset/base/238095

Log:
  Remove end of line whitespace.

Modified:
  head/usr.sbin/nscd/nscd.conf.5

Modified: head/usr.sbin/nscd/nscd.conf.5
==
--- head/usr.sbin/nscd/nscd.conf.5  Wed Jul  4 09:02:12 2012
(r238094)
+++ head/usr.sbin/nscd/nscd.conf.5  Wed Jul  4 10:17:02 2012
(r238095)
@@ -105,13 +105,13 @@ The default policy is fifo.
 .It Va negative-confidence-threshold Oo Ar cachename Oc Op Ar value
 The number of times a query must have failed before the cache accepts
 that the element can not be found.
-At the default value of 1 each negative query result is cached and 
+At the default value of 1 each negative query result is cached and
 immediately returned from the cache on further queries.
-Higher numbers cause queries to be retried at the configured data 
-sources the given number of times, before the negative result is 
+Higher numbers cause queries to be retried at the configured data
+sources the given number of times, before the negative result is
 returned from the cache on further queries.
-This allows to probe for the existence of an entry, and then to create 
-it if it did not exist, without the negative probe result preventing 
+This allows to probe for the existence of an entry, and then to create
+it if it did not exist, without the negative probe result preventing
 access to the new entry for the duration of the negative TTL.
 .It Va suggested-size Oo Ar cachename Oc Op Ar value
 This is the internal hash table size.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238102 - head/etc/rc.d

2012-07-04 Thread Dag-Erling Smorgrav
Author: des
Date: Wed Jul  4 13:37:44 2012
New Revision: 238102
URL: http://svn.freebsd.org/changeset/base/238102

Log:
  Name jails automatically.
  
  MFC after:1 week

Modified:
  head/etc/rc.d/jail

Modified: head/etc/rc.d/jail
==
--- head/etc/rc.d/jail  Wed Jul  4 13:00:48 2012(r238101)
+++ head/etc/rc.d/jail  Wed Jul  4 13:37:44 2012(r238102)
@@ -641,7 +641,7 @@ jail_start()
i=$((i + 1))
done
 
-   eval ${_setfib} jail ${_flags} -i ${_rootdir} ${_hostname} \
+   eval ${_setfib} jail ${_flags} -n ${_jail} -i ${_rootdir} 
${_hostname} \
\"${_addrl}\" ${_exec_start} > ${_tmp_jail} 2>&1 \
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238108 - head/usr.bin/sort

2012-07-04 Thread Gabor Kovesdan
Author: gabor
Date: Wed Jul  4 16:25:11 2012
New Revision: 238108
URL: http://svn.freebsd.org/changeset/base/238108

Log:
  - Change --nthreads parameter to --parallel for GNU compatibility
  - Change default sort method to mergesort, which has a better worst case
performance than qsort
  
  Submitted by: Oleg Moskalenko 

Modified:
  head/usr.bin/sort/file.c
  head/usr.bin/sort/file.h
  head/usr.bin/sort/radixsort.c
  head/usr.bin/sort/sort.1.in
  head/usr.bin/sort/sort.c

Modified: head/usr.bin/sort/file.c
==
--- head/usr.bin/sort/file.cWed Jul  4 14:25:14 2012(r238107)
+++ head/usr.bin/sort/file.cWed Jul  4 16:25:11 2012(r238108)
@@ -1297,7 +1297,7 @@ sort_list_to_file(struct sort_list *list
}
 
if (sort_opts_vals.sort_method == SORT_DEFAULT)
-   sort_opts_vals.sort_method = SORT_QSORT;
+   sort_opts_vals.sort_method = DEFAULT_SORT_ALGORITHM;
 
if (debug_sort)
printf("sort_method=%s\n",
@@ -1314,9 +1314,12 @@ sort_list_to_file(struct sort_list *list
case SORT_HEAPSORT:
mt_sort(list, heapsort, outfile);
break;
-   default:
+   case SORT_QSORT:
mt_sort(list, sort_qsort, outfile);
break;
+   default:
+   mt_sort(list, DEFAULT_SORT_FUNC, outfile);
+   break;
}
 }
 

Modified: head/usr.bin/sort/file.h
==
--- head/usr.bin/sort/file.hWed Jul  4 14:25:14 2012(r238107)
+++ head/usr.bin/sort/file.hWed Jul  4 16:25:11 2012(r238108)
@@ -39,6 +39,9 @@
 #defineSORT_HEAPSORT   3
 #defineSORT_RADIXSORT  4
 
+#define DEFAULT_SORT_ALGORITHM SORT_HEAPSORT
+#define DEFAULT_SORT_FUNC heapsort
+
 /*
  * List of data to be sorted.
  */

Modified: head/usr.bin/sort/radixsort.c
==
--- head/usr.bin/sort/radixsort.c   Wed Jul  4 14:25:14 2012
(r238107)
+++ head/usr.bin/sort/radixsort.c   Wed Jul  4 16:25:11 2012
(r238108)
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
 #include "coll.h"
 #include "radixsort.h"
 
+#define DEFAULT_SORT_FUNC_RADIXSORT mergesort
+
 #define TINY_NODE(sl) ((sl)->tosort_num < 65)
 #define SMALL_NODE(sl) ((sl)->tosort_num < 5)
 
@@ -349,7 +351,7 @@ run_sort_level_next(struct sort_level *s
/* NOTREACHED */
err(2, "Radix sort error 3");
} else
-   qsort(sl->leaves, sl->leaves_num,
+   DEFAULT_SORT_FUNC_RADIXSORT(sl->leaves, 
sl->leaves_num,
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) func);
 
@@ -389,12 +391,12 @@ run_sort_level_next(struct sort_level *s
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll);
} else {
-   qsort(sl->leaves, sl->leaves_num,
+   DEFAULT_SORT_FUNC_RADIXSORT(sl->leaves, 
sl->leaves_num,
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll);
}
} else if (!sort_opts_vals.sflag && 
sort_opts_vals.complex_sort) {
-   qsort(sl->leaves, sl->leaves_num,
+   DEFAULT_SORT_FUNC_RADIXSORT(sl->leaves, sl->leaves_num,
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll_by_str_only);
}
@@ -541,12 +543,12 @@ run_top_sort_level(struct sort_level *sl
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll);
} else {
-   qsort(sl->leaves, sl->leaves_num,
+   DEFAULT_SORT_FUNC_RADIXSORT(sl->leaves, 
sl->leaves_num,
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll);
}
} else if (!sort_opts_vals.sflag && 
sort_opts_vals.complex_sort) {
-   qsort(sl->leaves, sl->leaves_num,
+   DEFAULT_SORT_FUNC_RADIXSORT(sl->leaves, sl->leaves_num,
sizeof(struct sort_list_item *),
(int(*)(const void *, const void *)) 
list_coll_by_str_only);
}

Modified: head/usr.bin/sort/sort.1.in

svn commit: r238109 - head/sys/amd64/amd64

2012-07-04 Thread John Baldwin
Author: jhb
Date: Wed Jul  4 16:47:39 2012
New Revision: 238109
URL: http://svn.freebsd.org/changeset/base/238109

Log:
  Decode the 'xsave', 'xrstor', 'xsaveopt', 'xgetbv', 'xsetbv', and
  'rdtscp' instructions.
  
  MFC after:1 month

Modified:
  head/sys/amd64/amd64/db_disasm.c

Modified: head/sys/amd64/amd64/db_disasm.c
==
--- head/sys/amd64/amd64/db_disasm.cWed Jul  4 16:25:11 2012
(r238108)
+++ head/sys/amd64/amd64/db_disasm.cWed Jul  4 16:47:39 2012
(r238109)
@@ -169,9 +169,9 @@ static const char * const db_Grp15[] = {
"fxrstor",
"ldmxcsr",
"stmxcsr",
-   "",
-   "",
-   "",
+   "xsave",
+   "xrstor",
+   "xsaveopt",
"clflush"
 };
 
@@ -1279,11 +1279,26 @@ db_disasm(loc, altfmt)
i_size = NONE;
i_mode = 0;
break;
+   case 0xd0:
+   i_name = "xgetbv";
+   i_size = NONE;
+   i_mode = 0;
+   break;
+   case 0xd1:
+   i_name = "xsetbv";
+   i_size = NONE;
+   i_mode = 0;
+   break;
case 0xf8:
i_name = "swapgs";
i_size = NONE;
i_mode = 0;
break;
+   case 0xf9:
+   i_name = "rdtscp";
+   i_size = NONE;
+   i_mode = 0;
+   break;
}
}
if (ip->i_extra == db_Grp15 && f_mod(rex, regmodrm) == 3) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238110 - head/tools/regression/pjdfstest

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:31:53 2012
New Revision: 238110
URL: http://svn.freebsd.org/changeset/base/238110

Log:
  Recognize 'none' or '0' as no flags.

Modified:
  head/tools/regression/pjdfstest/pjdfstest.c

Modified: head/tools/regression/pjdfstest/pjdfstest.c
==
--- head/tools/regression/pjdfstest/pjdfstest.c Wed Jul  4 16:47:39 2012
(r238109)
+++ head/tools/regression/pjdfstest/pjdfstest.c Wed Jul  4 17:31:53 2012
(r238110)
@@ -350,10 +350,10 @@ str2flags(struct flag *tflags, char *sfl
unsigned int i;
char *f;
 
-   for (f = strtok(sflags, ","); f != NULL; f = strtok(NULL, ",")) {
-   /* Support magic 'none' flag which just reset all flags. */
-   if (strcmp(f, "none") == 0)
-   return (0);
+   /* 'none' or '0' means no flags */
+   if (strcmp(sflags, "none") == 0 || strcmp(sflags, "0") == 0)
+   return (0);
+   for (f = strtok(sflags, ",|"); f != NULL; f = strtok(NULL, ",|")) {
for (i = 0; tflags[i].f_str != NULL; i++) {
if (strcmp(tflags[i].f_str, f) == 0)
break;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238111 - in head: include lib/libc/stdio

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:35:07 2012
New Revision: 238111
URL: http://svn.freebsd.org/changeset/base/238111

Log:
  The register_printf_render_std() function expects regular string.
  Change argument type from 'const unsigned char *' to 'const char *'.
  
  MFC after:2 weeks

Modified:
  head/include/printf.h
  head/lib/libc/stdio/xprintf.c

Modified: head/include/printf.h
==
--- head/include/printf.h   Wed Jul  4 17:31:53 2012(r238110)
+++ head/include/printf.h   Wed Jul  4 17:35:07 2012(r238111)
@@ -123,7 +123,7 @@ int register_printf_function(int spec, p
 
 /* FreeBSD */
 int register_printf_render(int spec, printf_render *render, 
printf_arginfo_function *arginfo);
-int register_printf_render_std(const unsigned char *specs);
+int register_printf_render_std(const char *specs);
 
 /* vprintf_errno.c */
 printf_arginfo_function__printf_arginfo_errno;

Modified: head/lib/libc/stdio/xprintf.c
==
--- head/lib/libc/stdio/xprintf.c   Wed Jul  4 17:31:53 2012
(r238110)
+++ head/lib/libc/stdio/xprintf.c   Wed Jul  4 17:35:07 2012
(r238111)
@@ -651,7 +651,7 @@ register_printf_render(int spec, printf_
 }
 
 int
-register_printf_render_std(const unsigned char *specs)
+register_printf_render_std(const char *specs)
 {
 
for (; *specs != '\0'; specs++) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238112 - head/cddl/compat/opensolaris/misc

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:36:26 2012
New Revision: 238112
URL: http://svn.freebsd.org/changeset/base/238112

Log:
  Fix an obvious typo.
  
  MFC after:3 days

Modified:
  head/cddl/compat/opensolaris/misc/deviceid.c

Modified: head/cddl/compat/opensolaris/misc/deviceid.c
==
--- head/cddl/compat/opensolaris/misc/deviceid.cWed Jul  4 17:35:07 
2012(r238111)
+++ head/cddl/compat/opensolaris/misc/deviceid.cWed Jul  4 17:36:26 
2012(r238112)
@@ -45,7 +45,7 @@ devid_str_decode(char *devidstr, ddi_dev
return (EINVAL);
}
*retminor_name = strdup("");
-   if (*retminor_name == NULL);
+   if (*retminor_name == NULL)
return (ENOMEM);
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238113 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:39:29 2012
New Revision: 238113
URL: http://svn.freebsd.org/changeset/base/238113

Log:
  vdev_io_done stage is not used for ioctls.
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h  Wed Jul 
 4 17:36:26 2012(r238112)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h  Wed Jul 
 4 17:39:29 2012(r238113)
@@ -61,7 +61,7 @@ enum zio_stage {
ZIO_STAGE_READY = 1 << 15,  /* RWFCI */
 
ZIO_STAGE_VDEV_IO_START = 1 << 16,  /* RW--I */
-   ZIO_STAGE_VDEV_IO_DONE  = 1 << 17,  /* RW--I */
+   ZIO_STAGE_VDEV_IO_DONE  = 1 << 17,  /* RW--- */
ZIO_STAGE_VDEV_IO_ASSESS= 1 << 18,  /* RW--I */
 
ZIO_STAGE_CHECKSUM_VERIFY   = 1 << 19,  /* R */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238114 - head/sys/geom/eli

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:43:25 2012
New Revision: 238114
URL: http://svn.freebsd.org/changeset/base/238114

Log:
  Correct a comment and correct style of a flag check.
  
  MFC after:3 days

Modified:
  head/sys/geom/eli/g_eli_key.c

Modified: head/sys/geom/eli/g_eli_key.c
==
--- head/sys/geom/eli/g_eli_key.c   Wed Jul  4 17:39:29 2012
(r238113)
+++ head/sys/geom/eli/g_eli_key.c   Wed Jul  4 17:43:25 2012
(r238114)
@@ -197,7 +197,7 @@ g_eli_mkey_propagate(struct g_eli_softc 
mkey += sizeof(sc->sc_ivkey);
 
/*
-* The authentication key is: akey = HMAC_SHA512(Master-Key, 0x11)
+* The authentication key is: akey = HMAC_SHA512(Data-Key, 0x11)
 */
if ((sc->sc_flags & G_ELI_FLAG_AUTH) != 0) {
g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x11", 1,
@@ -209,7 +209,7 @@ g_eli_mkey_propagate(struct g_eli_softc 
/* Initialize encryption keys. */
g_eli_key_init(sc);
 
-   if (sc->sc_flags & G_ELI_FLAG_AUTH) {
+   if ((sc->sc_flags & G_ELI_FLAG_AUTH) != 0) {
/*
 * Precalculate SHA256 for HMAC key generation.
 * This is expensive operation and we can do it only once now or
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238115 - head/sys/geom/eli

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:44:39 2012
New Revision: 238115
URL: http://svn.freebsd.org/changeset/base/238115

Log:
  Correct comment.
  
  MFC after:3 days

Modified:
  head/sys/geom/eli/g_eli_key_cache.c

Modified: head/sys/geom/eli/g_eli_key_cache.c
==
--- head/sys/geom/eli/g_eli_key_cache.c Wed Jul  4 17:43:25 2012
(r238114)
+++ head/sys/geom/eli/g_eli_key_cache.c Wed Jul  4 17:44:39 2012
(r238115)
@@ -200,7 +200,7 @@ g_eli_key_init(struct g_eli_softc *sc)
bcopy(mkey, sc->sc_ekey, G_ELI_DATAKEYLEN);
else {
/*
-* The encryption key is: ekey = 
HMAC_SHA512(Master-Key, 0x10)
+* The encryption key is: ekey = HMAC_SHA512(Data-Key, 
0x10)
 */
g_eli_crypto_hmac(mkey, G_ELI_MAXKEYLEN, "\x10", 1,
sc->sc_ekey, 0);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238116 - head/sys/geom/eli

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:54:17 2012
New Revision: 238116
URL: http://svn.freebsd.org/changeset/base/238116

Log:
  Use correct part of the Master-Key for generating encryption keys.
  Before this change the IV-Key was used to generate encryption keys,
  which was incorrect, but safe - for the XTS mode this key was unused
  anyway and for CBC mode it was used differently to generate IV
  vectors, so there is no risk that IV vector collides with encryption
  key somehow.
  
  Bump version number and keep compatibility for older versions.
  
  MFC after:2 weeks

Modified:
  head/sys/geom/eli/g_eli.c
  head/sys/geom/eli/g_eli.h
  head/sys/geom/eli/g_eli_ctl.c
  head/sys/geom/eli/g_eli_key_cache.c

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Wed Jul  4 17:44:39 2012(r238115)
+++ head/sys/geom/eli/g_eli.c   Wed Jul  4 17:54:17 2012(r238116)
@@ -726,6 +726,8 @@ g_eli_create(struct gctl_req *req, struc
(sc->sc_flags & G_ELI_FLAG_AUTH) != 0) {
sc->sc_flags |= G_ELI_FLAG_FIRST_KEY;
}
+   if (md->md_version < G_ELI_VERSION_07)
+   sc->sc_flags |= G_ELI_FLAG_ENC_IVKEY;
sc->sc_ealgo = md->md_ealgo;
sc->sc_nkey = nkey;
 

Modified: head/sys/geom/eli/g_eli.h
==
--- head/sys/geom/eli/g_eli.h   Wed Jul  4 17:44:39 2012(r238115)
+++ head/sys/geom/eli/g_eli.h   Wed Jul  4 17:54:17 2012(r238116)
@@ -68,6 +68,8 @@
  * 5 - Added multiple encrypton keys and AES-XTS support.
  * 6 - Fixed usage of multiple keys for authenticated providers (the
  * G_ELI_FLAG_FIRST_KEY flag will be set for older versions).
+ * 7 - Encryption keys are now generated from the Data Key and not from the
+ * IV Key (the G_ELI_FLAG_ENC_IVKEY flag will be set for older versions).
  */
 #defineG_ELI_VERSION_000
 #defineG_ELI_VERSION_011
@@ -76,7 +78,8 @@
 #defineG_ELI_VERSION_044
 #defineG_ELI_VERSION_055
 #defineG_ELI_VERSION_066
-#defineG_ELI_VERSION   G_ELI_VERSION_06
+#defineG_ELI_VERSION_077
+#defineG_ELI_VERSION   G_ELI_VERSION_07
 
 /* ON DISK FLAGS. */
 /* Use random, onetime keys. */
@@ -104,6 +107,8 @@
 #defineG_ELI_FLAG_SUSPEND  0x0010
 /* Provider uses first encryption key. */
 #defineG_ELI_FLAG_FIRST_KEY0x0020
+/* Provider uses IV-Key for encryption key generation. */
+#defineG_ELI_FLAG_ENC_IVKEY0x0040
 
 #defineG_ELI_NEW_BIO   255
 
@@ -237,7 +242,7 @@ eli_metadata_encode_v0(struct g_eli_meta
*datap = p;
 }
 static __inline void
-eli_metadata_encode_v1v2v3v4v5v6(struct g_eli_metadata *md, u_char **datap)
+eli_metadata_encode_v1v2v3v4v5v6v7(struct g_eli_metadata *md, u_char **datap)
 {
u_char *p;
 
@@ -275,7 +280,8 @@ eli_metadata_encode(struct g_eli_metadat
case G_ELI_VERSION_04:
case G_ELI_VERSION_05:
case G_ELI_VERSION_06:
-   eli_metadata_encode_v1v2v3v4v5v6(md, &p);
+   case G_ELI_VERSION_07:
+   eli_metadata_encode_v1v2v3v4v5v6v7(md, &p);
break;
default:
 #ifdef _KERNEL
@@ -315,7 +321,7 @@ eli_metadata_decode_v0(const u_char *dat
 }
 
 static __inline int
-eli_metadata_decode_v1v2v3v4v5v6(const u_char *data, struct g_eli_metadata *md)
+eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata 
*md)
 {
MD5_CTX ctx;
const u_char *p;
@@ -357,7 +363,8 @@ eli_metadata_decode(const u_char *data, 
case G_ELI_VERSION_04:
case G_ELI_VERSION_05:
case G_ELI_VERSION_06:
-   error = eli_metadata_decode_v1v2v3v4v5v6(data, md);
+   case G_ELI_VERSION_07:
+   error = eli_metadata_decode_v1v2v3v4v5v6v7(data, md);
break;
default:
error = EOPNOTSUPP;

Modified: head/sys/geom/eli/g_eli_ctl.c
==
--- head/sys/geom/eli/g_eli_ctl.c   Wed Jul  4 17:44:39 2012
(r238115)
+++ head/sys/geom/eli/g_eli_ctl.c   Wed Jul  4 17:54:17 2012
(r238116)
@@ -1020,6 +1020,12 @@ g_eli_config(struct gctl_req *req, struc
/* Compatible. */
break;
}
+   if (G_ELI_VERSION == G_ELI_VERSION_07 &&
+   (*version == G_ELI_VERSION_05 ||
+*version == G_ELI_VERSION_06)) {
+   /* Compatible. */
+   break;
+   }
gctl_error(req, "Userland and kernel parts are out of sync.");
return;
}

Modified: head/sys/geom/eli/g_eli_key_cache.c

svn commit: r238117 - head/sbin/geom/class/eli

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 17:59:26 2012
New Revision: 238117
URL: http://svn.freebsd.org/changeset/base/238117

Log:
  Improve description of various key used by GELI.
  
  PR:   docs/169089
  Submitted by: John W. O'Brien 
  MFC after:3 days

Modified:
  head/sbin/geom/class/eli/geli.8

Modified: head/sbin/geom/class/eli/geli.8
==
--- head/sbin/geom/class/eli/geli.8 Wed Jul  4 17:54:17 2012
(r238116)
+++ head/sbin/geom/class/eli/geli.8 Wed Jul  4 17:59:26 2012
(r238117)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 28, 2012
+.Dd June 18, 2012
 .Dt GELI 8
 .Os
 .Sh NAME
@@ -186,14 +186,15 @@ one of the following algorithms:
 or
 .Nm HMAC/SHA512 .
 .It
-Can create a key from a couple of components (user entered passphrase, random
-bits from a file, etc.).
+Can create a User Key from up to two, piecewise components: a passphrase
+entered via prompt or read from one or more passfiles; a keyfile read from
+one or more files.
 .It
 Allows encryption of the root partition.
 The user will be asked for the
 passphrase before the root file system is mounted.
 .It
-The passphrase of the user is strengthened with:
+Strengthens the passphrase component of the User Key with:
 .Rs
 .%A B. Kaliski
 .%T "PKCS #5: Password-Based Cryptography Specification, Version 2.0."
@@ -201,7 +202,7 @@ The passphrase of the user is strengthen
 .%N 2898
 .Re
 .It
-Allows the use of two independent keys (e.g., a
+Allows the use of two independent User Keys (e.g., a
 .Qq "user key"
 and a
 .Qq "company key" ) .
@@ -210,8 +211,8 @@ It is fast -
 .Nm
 performs simple sector-to-sector encryption.
 .It
-Allows Master Keys to be backed up and restored,
-so that if a user has to quickly destroy his keys,
+Allows the encrypted Master Key to be backed up and restored,
+so that if a user has to quickly destroy key material,
 it is possible to get the data back by restoring keys from
 backup.
 .It
@@ -219,8 +220,8 @@ Providers can be configured to automatic
 (so users do not have to remember to detach providers after unmounting
 the file systems).
 .It
-Allows attaching a provider with a random, one-time key - useful for swap
-partitions and temporary file systems.
+Allows attaching a provider with a random, one-time Master Key -
+useful for swap partitions and temporary file systems.
 .It
 Allows verification of data integrity (data authentication).
 .It
@@ -233,7 +234,8 @@ indicates an action to be performed:
 .Bl -tag -width ".Cm configure"
 .It Cm init
 Initialize the provider which needs to be encrypted.
-Here you can set up the cryptographic algorithm to use, key length, etc.
+Here you can set up the cryptographic algorithm to use, Data Key length,
+etc.
 The last sector of the provider is used to store metadata.
 The
 .Cm init
@@ -289,37 +291,58 @@ and
 The default and recommended algorithm is
 .Nm AES-XTS .
 .It Fl i Ar iterations
-Number of iterations to use with PKCS#5v2.
+Number of iterations to use with PKCS#5v2 when processing User Key
+passphrase component.
 If this option is not specified,
 .Nm
 will find the number of iterations which is equal to 2 seconds of crypto work.
 If 0 is given, PKCS#5v2 will not be used.
+PKCS#5v2 processing is performed once, after all parts of the passphrase
+component have been read.
 .It Fl J Ar newpassfile
-Specifies a file which contains the passphrase or its part.
+Specifies a file which contains the passphrase component of the User Key
+(or part of it).
 If
 .Ar newpassfile
 is given as -, standard input will be used.
 Only the first line (excluding new-line character) is taken from the given 
file.
-This argument can be specified multiple times.
+This argument can be specified multiple times, which has the effect of
+reassembling a single passphrase split across multiple files.
+Cannot be combined with the
+.Fl P
+option.
 .It Fl K Ar newkeyfile
-Specifies a file which contains part of the key.
+Specifies a file which contains the keyfile component of the User Key
+(or part of it).
 If
 .Ar newkeyfile
 is given as -, standard input will be used.
-This argument can be specified multiple times.
+This argument can be specified multiple times, which has the effect of
+reassembling a single keyfile split across multiple keyfile parts.
 .It Fl l Ar keylen
-Key length to use with the given cryptographic algorithm.
-If not given, the default key length for the given algorithm is used, which is:
-128 for
-.Nm AES-XTS ,
-.Nm AES-CBC ,
-.Nm Blowfish-CBC
-and
-.Nm Camellia-CBC
-and 192 for
-.Nm 3DES-CBC .
+Data Key length to use with the given cryptographic algorithm.
+If the length is not specified, the selected algorithm uses its
+.Em default
+key length.
+.Bl -ohang -offset indent
+.It Nm AES-XTS
+.Em 128 ,
+256
+.It Nm AES-CBC , Nm Camilla-CBC
+.Em 128 ,
+192,
+256
+.It Nm Blowfish-CBC
+.Em 128
++ n * 32, for n=[0..10]
+.It Nm 3DES-CBC
+.Em 192
+.El
 .It Fl P
-Do not use passphrase as

svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 19:51:25 2012
New Revision: 238118
URL: http://svn.freebsd.org/changeset/base/238118

Log:
  Prefer sysctl to open/read/close for obtaining random data.
  This method is more sandbox-friendly and also should be faster as only
  one syscall is needed instead of three.
  In case of an error fall back to the old method.
  
  Reviewed by:  simon, gleb
  MFC after:2 weeks

Modified:
  head/lib/libc/gen/arc4random.c

Modified: head/lib/libc/gen/arc4random.c
==
--- head/lib/libc/gen/arc4random.c  Wed Jul  4 17:59:26 2012
(r238117)
+++ head/lib/libc/gen/arc4random.c  Wed Jul  4 19:51:25 2012
(r238118)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -78,6 +79,9 @@ static struct arc4_stream rs;
 static pid_t arc4_stir_pid;
 static int arc4_count;
 
+extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+void *newp, size_t newlen);
+
 static inline u_int8_t arc4_getbyte(void);
 static void arc4_stir(void);
 
@@ -109,6 +113,28 @@ arc4_addrandom(u_char *dat, int datlen)
rs.j = rs.i;
 }
 
+static size_t
+arc4_sysctl(u_char *buf, size_t size)
+{
+   int mib[2];
+   size_t len, done;
+
+   mib[0] = CTL_KERN;
+   mib[1] = KERN_ARND;
+   done = 0;
+
+   do {
+   len = size;
+   if (__sysctl(mib, 2, buf, &len, NULL, 0) == -1)
+   return (done);
+   done += len;
+   buf += len;
+   size -= len;
+   } while (size > 0);
+
+   return (done);
+}
+
 static void
 arc4_stir(void)
 {
@@ -123,12 +149,16 @@ arc4_stir(void)
arc4_init();
rs_initialized = 1;
}
-   fd = _open(RANDOMDEV, O_RDONLY, 0);
done = 0;
-   if (fd >= 0) {
-   if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
-   done = 1;
-   (void)_close(fd);
+   if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE)
+   done = 1;
+   if (!done) {
+   fd = _open(RANDOMDEV, O_RDONLY, 0);
+   if (fd >= 0) {
+   if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
+   done = 1;
+   (void)_close(fd);
+   }
}
if (!done) {
(void)gettimeofday(&rdat.tv, NULL);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Konstantin Belousov
On Wed, Jul 04, 2012 at 07:51:25PM +, Pawel Jakub Dawidek wrote:
> Author: pjd
> Date: Wed Jul  4 19:51:25 2012
> New Revision: 238118
> URL: http://svn.freebsd.org/changeset/base/238118
> 
> Log:
>   Prefer sysctl to open/read/close for obtaining random data.
>   This method is more sandbox-friendly and also should be faster as only
>   one syscall is needed instead of three.
>   In case of an error fall back to the old method.
>   
>   Reviewed by:simon, gleb
>   MFC after:  2 weeks
IMO it is weird and against a purpose of sysctl that kern.arand sysctl
exists at all. I would prefer to not spread its usage more. We have
to keep it to preserve ABI compatibility, but I do not think that the
location for random data provider is right, not to mention higher
overhead of sysctl machinery.

I do think that /dev/random is the right approach, or (less preferable)
you could consider adding syscall to get randomness.


pgprp69c4ZNzH.pgp
Description: PGP signature


svn commit: r238119 - head/sys/geom/gate

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 20:16:28 2012
New Revision: 238119
URL: http://svn.freebsd.org/changeset/base/238119

Log:
  Extend GEOM Gate class to handle read I/O requests directly within the kernel.
  This will allow HAST to read directly from the local component without
  even communicating userland daemon.
  
  Sponsored by: Panzura, http://www.panzura.com
  MFC after:1 month

Modified:
  head/sys/geom/gate/g_gate.c
  head/sys/geom/gate/g_gate.h

Modified: head/sys/geom/gate/g_gate.c
==
--- head/sys/geom/gate/g_gate.c Wed Jul  4 19:51:25 2012(r238118)
+++ head/sys/geom/gate/g_gate.c Wed Jul  4 20:16:28 2012(r238119)
@@ -60,7 +60,7 @@ static MALLOC_DEFINE(M_GATE, "gg_data", 
 
 SYSCTL_DECL(_kern_geom);
 static SYSCTL_NODE(_kern_geom, OID_AUTO, gate, CTLFLAG_RW, 0,
-"GEOM_GATE stuff");
+"GEOM_GATE configuration");
 static int g_gate_debug = 0;
 TUNABLE_INT("kern.geom.gate.debug", &g_gate_debug);
 SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RW, &g_gate_debug, 0,
@@ -92,6 +92,7 @@ static int
 g_gate_destroy(struct g_gate_softc *sc, boolean_t force)
 {
struct g_provider *pp;
+   struct g_consumer *cp;
struct g_geom *gp;
struct bio *bp;
 
@@ -138,6 +139,12 @@ g_gate_destroy(struct g_gate_softc *sc, 
mtx_unlock(&g_gate_units_lock);
mtx_destroy(&sc->sc_queue_mtx);
g_topology_lock();
+   if ((cp = sc->sc_readcons) != NULL) {
+   sc->sc_readcons = NULL;
+   (void)g_access(cp, -1, 0, 0);
+   g_detach(cp);
+   g_destroy_consumer(cp);
+   }
G_GATE_DEBUG(1, "Device %s destroyed.", gp->name);
gp->softc = NULL;
g_wither_geom(gp, ENXIO);
@@ -167,7 +174,7 @@ g_gate_access(struct g_provider *pp, int
 }
 
 static void
-g_gate_start(struct bio *bp)
+g_gate_queue_io(struct bio *bp)
 {
struct g_gate_softc *sc;
 
@@ -176,27 +183,9 @@ g_gate_start(struct bio *bp)
g_io_deliver(bp, ENXIO);
return;
}
-   G_GATE_LOGREQ(2, bp, "Request received.");
-   switch (bp->bio_cmd) {
-   case BIO_READ:
-   break;
-   case BIO_DELETE:
-   case BIO_WRITE:
-   case BIO_FLUSH:
-   /* XXX: Hack to allow read-only mounts. */
-   if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) {
-   g_io_deliver(bp, EPERM);
-   return;
-   }
-   break;
-   case BIO_GETATTR:
-   default:
-   G_GATE_LOGREQ(2, bp, "Ignoring request.");
-   g_io_deliver(bp, EOPNOTSUPP);
-   return;
-   }
 
mtx_lock(&sc->sc_queue_mtx);
+
if (sc->sc_queue_size > 0 && sc->sc_queue_count > sc->sc_queue_size) {
mtx_unlock(&sc->sc_queue_mtx);
G_GATE_LOGREQ(1, bp, "Queue full, request canceled.");
@@ -214,6 +203,74 @@ g_gate_start(struct bio *bp)
mtx_unlock(&sc->sc_queue_mtx);
 }
 
+static void
+g_gate_done(struct bio *cbp)
+{
+   struct bio *pbp;
+
+   pbp = cbp->bio_parent;
+   if (cbp->bio_error == 0) {
+   pbp->bio_completed = cbp->bio_completed;
+   g_destroy_bio(cbp);
+   pbp->bio_inbed++;
+   g_io_deliver(pbp, 0);
+   } else {
+   /* If direct read failed, pass it through userland daemon. */
+   g_destroy_bio(cbp);
+   pbp->bio_children--;
+   g_gate_queue_io(pbp);
+   }
+}
+
+static void
+g_gate_start(struct bio *pbp)
+{
+   struct g_gate_softc *sc;
+
+   sc = pbp->bio_to->geom->softc;
+   if (sc == NULL || (sc->sc_flags & G_GATE_FLAG_DESTROY) != 0) {
+   g_io_deliver(pbp, ENXIO);
+   return;
+   }
+   G_GATE_LOGREQ(2, pbp, "Request received.");
+   switch (pbp->bio_cmd) {
+   case BIO_READ:
+   if (sc->sc_readcons != NULL) {
+   struct bio *cbp;
+
+   cbp = g_clone_bio(pbp);
+   if (cbp == NULL) {
+   g_io_deliver(pbp, ENOMEM);
+   return;
+   }
+   cbp->bio_done = g_gate_done;
+   cbp->bio_offset = pbp->bio_offset + sc->sc_readoffset;
+   cbp->bio_data = pbp->bio_data;
+   cbp->bio_length = pbp->bio_length;
+   cbp->bio_to = sc->sc_readcons->provider;
+   g_io_request(cbp, sc->sc_readcons);
+   return;
+   }
+   break;
+   case BIO_DELETE:
+   case BIO_WRITE:
+   case BIO_FLUSH:
+   /* XXX: Hack to allow read-only mounts. */
+   if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) {
+   g_io_deliver(pbp, EPERM);
+   return;
+ 

svn commit: r238120 - head/sbin/hastd

2012-07-04 Thread Pawel Jakub Dawidek
Author: pjd
Date: Wed Jul  4 20:20:48 2012
New Revision: 238120
URL: http://svn.freebsd.org/changeset/base/238120

Log:
  Make use of GEOM Gate direct reads feature. This allows HAST to serve
  reads with native speed of the underlying provider.
  There are three situations when direct reads are not used:
  1. Data is being synchronized and synchronization source is the secondary
 node, which means secondary node has more recent data and we should read
 from it.
  2. Local read failed and we have to try to read from the secondary node.
  3. Local component is unavailable and all I/O requests are served from the
 secondary node.
  
  Sponsored by: Panzura, http://www.panzura.com
  MFC after:1 month

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Wed Jul  4 20:16:28 2012(r238119)
+++ head/sbin/hastd/primary.c   Wed Jul  4 20:20:48 2012(r238120)
@@ -543,6 +543,27 @@ primary_connect(struct hast_resource *re
 
return (0);
 }
+ 
+/*
+ * Function instructs GEOM_GATE to handle reads directly from within the 
kernel.
+ */
+static void
+enable_direct_reads(struct hast_resource *res)
+{
+   struct g_gate_ctl_modify ggiomodify;
+
+   bzero(&ggiomodify, sizeof(ggiomodify));
+   ggiomodify.gctl_version = G_GATE_VERSION;
+   ggiomodify.gctl_unit = res->hr_ggateunit;
+   ggiomodify.gctl_modify = GG_MODIFY_READPROV | GG_MODIFY_READOFFSET;
+   strlcpy(ggiomodify.gctl_readprov, res->hr_localpath,
+   sizeof(ggiomodify.gctl_readprov));
+   ggiomodify.gctl_readoffset = res->hr_localoff;
+   if (ioctl(res->hr_ggatefd, G_GATE_CMD_MODIFY, &ggiomodify) == 0)
+   pjdlog_debug(1, "Direct reads enabled.");
+   else
+   pjdlog_errno(LOG_WARNING, "Failed to enable direct reads");
+}
 
 static int
 init_remote(struct hast_resource *res, struct proto_conn **inp,
@@ -692,6 +713,8 @@ init_remote(struct hast_resource *res, s
res->hr_secondary_localcnt = nv_get_uint64(nvin, "localcnt");
res->hr_secondary_remotecnt = nv_get_uint64(nvin, "remotecnt");
res->hr_syncsrc = nv_get_uint8(nvin, "syncsrc");
+   if (res->hr_syncsrc == HAST_SYNCSRC_PRIMARY)
+   enable_direct_reads(res);
if (nv_exists(nvin, "virgin")) {
/*
 * Secondary was reinitialized, bump localcnt if it is 0 as
@@ -1789,13 +1812,14 @@ sync_thread(void *arg __unused)
struct timeval tstart, tend, tdiff;
unsigned int ii, ncomp, ncomps;
off_t offset, length, synced;
-   bool dorewind;
+   bool dorewind, directreads;
int syncext;
 
ncomps = HAST_NCOMPONENTS;
dorewind = true;
synced = 0;
offset = -1;
+   directreads = false;
 
for (;;) {
mtx_lock(&sync_lock);
@@ -1867,6 +1891,8 @@ sync_thread(void *arg __unused)
event_send(res, EVENT_SYNCDONE);
}
mtx_lock(&metadata_lock);
+   if (res->hr_syncsrc == HAST_SYNCSRC_SECONDARY)
+   directreads = true;
res->hr_syncsrc = HAST_SYNCSRC_UNDEF;
res->hr_primary_localcnt =
res->hr_secondary_remotecnt;
@@ -1880,6 +1906,10 @@ sync_thread(void *arg __unused)
mtx_unlock(&metadata_lock);
}
rw_unlock(&hio_remote_lock[ncomp]);
+   if (directreads) {
+   directreads = false;
+   enable_direct_reads(res);
+   }
continue;
}
pjdlog_debug(2, "sync: Taking free request.");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238121 - head/sys/netinet

2012-07-04 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  4 20:29:16 2012
New Revision: 238121
URL: http://svn.freebsd.org/changeset/base/238121

Log:
  Use CSUM_SCTP_IPV6 for IPv6.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Wed Jul  4 20:20:48 2012
(r238120)
+++ head/sys/netinet/sctp_output.c  Wed Jul  4 20:29:16 2012
(r238121)
@@ -4471,7 +4471,7 @@ sctp_lowlevel_chunk_output(struct sctp_i
 #if defined(SCTP_WITH_NO_CSUM)
SCTP_STAT_INCR(sctps_sendnocrc);
 #else
-   m->m_pkthdr.csum_flags = CSUM_SCTP;
+   m->m_pkthdr.csum_flags = CSUM_SCTP_IPV6;
m->m_pkthdr.csum_data = 0;
SCTP_STAT_INCR(sctps_sendhwcrc);
 #endif
@@ -11025,7 +11025,7 @@ sctp_send_resp_msg(struct sockaddr *src,
 #if defined(SCTP_WITH_NO_CSUM)
SCTP_STAT_INCR(sctps_sendnocrc);
 #else
-   mout->m_pkthdr.csum_flags = CSUM_SCTP;
+   mout->m_pkthdr.csum_flags = CSUM_SCTP_IPV6;
mout->m_pkthdr.csum_data = 0;
SCTP_STAT_INCR(sctps_sendhwcrc);
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Andrey Chernov
On Wed, Jul 04, 2012 at 11:02:20PM +0300, Konstantin Belousov wrote:
> On Wed, Jul 04, 2012 at 07:51:25PM +, Pawel Jakub Dawidek wrote:
> > Author: pjd
> > Date: Wed Jul  4 19:51:25 2012
> > New Revision: 238118
> > URL: http://svn.freebsd.org/changeset/base/238118
> > 
> > Log:
> >   Prefer sysctl to open/read/close for obtaining random data.
> >   This method is more sandbox-friendly and also should be faster as only
> >   one syscall is needed instead of three.
> >   In case of an error fall back to the old method.
> >   
> >   Reviewed by:  simon, gleb
> >   MFC after:2 weeks
> IMO it is weird and against a purpose of sysctl that kern.arand sysctl
> exists at all. I would prefer to not spread its usage more. We have
> to keep it to preserve ABI compatibility, but I do not think that the
> location for random data provider is right, not to mention higher
> overhead of sysctl machinery.

1) /dev/urandom may not exist in jails/sandboxes while sysctls (or old way 
initialization) always exists.
2) Current NetBSD code uses KERN_URND we don't have.
3) Current OpenBSD code uses KERN_ARND as in the change committed.
4) Our KERN_ARND initially is initialized only from from the weak value at 
the boot stage.
5) I already provide two working patches (one with atomic and another 
one without) to bypass issue 4) but they are never committed by person 
who promise to handle them (markm@ CCed) for the reason unknown and I 
can't do it by myself due to stupid secteam@ 5 years old ban.
6) So, current KERN_ARND way gives weak randomness for just started after 
boot programs and should be fixed by either my patches mentioned in 5) or 
by implementing KERN_URND as in NetBSD.
Note that the initial ARND seeding problem does not exist in OpenBSD since 
they use different KERN_ARND implementation.

(besides usage in arc4random code I think KERN_ARND should be fixed in 
anycase)

-- 
http://ache.vniz.net/


pgpyrYimDeGuF.pgp
Description: PGP signature


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread David Chisnall
On 4 Jul 2012, at 21:32, Andrey Chernov wrote:

> 1) /dev/urandom may not exist in jails/sandboxes while sysctls (or old way 
> initialization) always exists.

From the perspective of Capsicum sandboxes, a device node is better than a 
sysctl.  The kernel must hard-code policy about which sysctls are permitted, 
but access to file descriptors is decided on a per-sandbox basis and is 
configurable by the user.  The same applies to jails, although it's slightly 
more effort to make device nodes appear inside a jail.

David___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Attilio Rao
2012/7/4 David Chisnall :
> On 4 Jul 2012, at 21:32, Andrey Chernov wrote:
>
>> 1) /dev/urandom may not exist in jails/sandboxes while sysctls (or old way
>> initialization) always exists.
>
> From the perspective of Capsicum sandboxes, a device node is better than a 
> sysctl.  The kernel must hard-code policy about which sysctls are permitted, 
> but access to file descriptors is decided on a per-sandbox basis and is 
> configurable by the user.  The same applies to jails, although it's slightly 
> more effort to make device nodes appear inside a jail.

Also don't understimate the locking factor here.
I recall that at some point /dev/random was introducing some
scalability penalty on php (maybe related to the suhosin patch) until
kib made shared lookups available on devfs. IIRC, sysctls are still
Giant locked.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Doug Barton
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 07/04/2012 13:32, Andrey Chernov wrote:
> 1) /dev/urandom may not exist in jails/sandboxes

That would be a pretty serious configuration error.

- -- 

This .signature sanitized for your protection


-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBCAAGBQJP9Kw9AAoJEFzGhvEaGryEATEH/RbxtNiNYy+Ki/DL0JWVTTwq
f+kEK8bASCfJGmA+Vb+1cjEGcMT64QOvV3n4ow0xjn9xctmWVtoA8Y4Q4dRomOh6
vOlJfu5aRsZsAxsf9sV3k1psuO5IXuYBfAeGVtGBjgNMnDG46PiNBE+4q5rVntHw
sUsuyupxgRbYrCvTVbeET2wAZ+G9j8ceK56nA63KN3azAIpCktCDzSm3FlDrVWYh
zk+LpIHdpE4pbpH8znxDQoRqF+V9n6pryGiFNzkzLODvtoiL7qgrJtNEdfu3GCQI
J7tolXvMmxljYW+V3PUP5abO6RS1uCMiZi3wvo+HaZqhPVUVTw98tx+qRwBJ7zs=
=1MvW
-END PGP SIGNATURE-
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Konstantin Belousov
On Wed, Jul 04, 2012 at 09:45:54PM +0100, Attilio Rao wrote:
> 2012/7/4 David Chisnall :
> > On 4 Jul 2012, at 21:32, Andrey Chernov wrote:
> >
> >> 1) /dev/urandom may not exist in jails/sandboxes while sysctls (or old way
> >> initialization) always exists.
> >
> > From the perspective of Capsicum sandboxes, a device node is better than a 
> > sysctl.  The kernel must hard-code policy about which sysctls are 
> > permitted, but access to file descriptors is decided on a per-sandbox basis 
> > and is configurable by the user.  The same applies to jails, although it's 
> > slightly more effort to make device nodes appear inside a jail.
> 
> Also don't understimate the locking factor here.
> I recall that at some point /dev/random was introducing some
> scalability penalty on php (maybe related to the suhosin patch) until
> kib made shared lookups available on devfs. IIRC, sysctls are still
> Giant locked.

/dev/random has further optimizations which eliminate the dev_mtx
aquisitions as well. KERN_ARND is mpsafe.


pgp6loglNYja5.pgp
Description: PGP signature


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Andrey Chernov
On Wed, Jul 04, 2012 at 01:49:01PM -0700, Doug Barton wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
> 
> On 07/04/2012 13:32, Andrey Chernov wrote:
> > 1) /dev/urandom may not exist in jails/sandboxes
> 
> That would be a pretty serious configuration error.
> 

It may be true, but old POLA is that *BSD arc4random() should works nice 
in such situations.

-- 
http://ache.vniz.net/
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238122 - head/sys/netinet

2012-07-04 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  4 20:59:30 2012
New Revision: 238122
URL: http://svn.freebsd.org/changeset/base/238122

Log:
  Use consistent method to determine IPV4_OUTPUT/IPV6_OUTPUT.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Wed Jul  4 20:29:16 2012
(r238121)
+++ head/sys/netinet/sctp_output.c  Wed Jul  4 20:59:30 2012
(r238122)
@@ -10971,8 +10971,9 @@ sctp_send_resp_msg(struct sockaddr *src,
return;
}
SCTP_ATTACH_CHAIN(o_pak, mout, len);
+   switch (dst->sa_family) {
 #ifdef INET
-   if (ip != NULL) {
+   case AF_INET:
if (port) {
if (V_udp_cksum) {
udp->uh_sum = in_pseudo(ip->ip_src.s_addr, 
ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
@@ -11006,10 +11007,10 @@ sctp_send_resp_msg(struct sockaddr *src,
}
 #endif
SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id);
-   }
+   break;
 #endif
 #ifdef INET6
-   if (ip6 != NULL) {
+   case AF_INET6:
ip6->ip6_plen = len - sizeof(struct ip6_hdr);
if (port) {
 #if defined(SCTP_WITH_NO_CSUM)
@@ -11036,8 +11037,15 @@ sctp_send_resp_msg(struct sockaddr *src,
}
 #endif
SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id);
-   }
+   break;
 #endif
+   default:
+   SCTPDBG(SCTP_DEBUG_OUTPUT1, "Unknown protocol (TSNH) type %d\n",
+   dst->sa_family);
+   sctp_m_freem(mout);
+   SCTP_LTRACE_ERR_RET_PKT(mout, NULL, NULL, NULL, 
SCTP_FROM_SCTP_OUTPUT, EFAULT);
+   return;
+   }
SCTP_STAT_INCR(sctps_sendpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r238118 - head/lib/libc/gen

2012-07-04 Thread Colin Percival
On 07/04/12 13:45, Attilio Rao wrote:
> I recall that at some point /dev/random was introducing some
> scalability penalty on php [...]

... thus reinforcing the stereotype that PHP Does Stuff Wrong.

Userland processes should get entropy from the kernel *once* at launch
time and place it into an entropy pool which is *occasionally* reseeded
later.  If even a very slow /dev/random becomes a scalability problem,
an application is doing something very very wrong.

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238123 - in head/contrib/binutils: gas/config opcodes

2012-07-04 Thread John Baldwin
Author: jhb
Date: Wed Jul  4 22:12:10 2012
New Revision: 238123
URL: http://svn.freebsd.org/changeset/base/238123

Log:
  Add support for the 'xsave', 'xrstor', 'xsaveopt', 'xgetbv', and 'xsetbv'
  instructions.  I reimplemented this from scratch based on the Intel
  manuals and the existing support for handling the fxsave and fxrstor
  instructions.  This will let us use these instructions natively with GCC
  rather than hardcoding the opcodes in hex.
  
  Reviewed by:  kib
  MFC after:1 month

Modified:
  head/contrib/binutils/gas/config/tc-i386.c
  head/contrib/binutils/opcodes/i386-dis.c
  head/contrib/binutils/opcodes/i386-opc.h
  head/contrib/binutils/opcodes/i386-opc.tbl
  head/contrib/binutils/opcodes/i386-tbl.h

Modified: head/contrib/binutils/gas/config/tc-i386.c
==
--- head/contrib/binutils/gas/config/tc-i386.c  Wed Jul  4 20:59:30 2012
(r238122)
+++ head/contrib/binutils/gas/config/tc-i386.c  Wed Jul  4 22:12:10 2012
(r238123)
@@ -517,7 +517,9 @@ static const arch_entry cpu_arch[] =
   {".sse4a", PROCESSOR_UNKNOWN,
CpuMMX|CpuMMX2|CpuSSE|CpuSSE2|CpuSSE3|CpuSSE4a},
   {".abm", PROCESSOR_UNKNOWN,
-   CpuABM}
+   CpuABM},
+  {".xsave", PROCESSOR_UNKNOWN,
+   CpuXSAVE}
 };
 
 const pseudo_typeS md_pseudo_table[] =

Modified: head/contrib/binutils/opcodes/i386-dis.c
==
--- head/contrib/binutils/opcodes/i386-dis.cWed Jul  4 20:59:30 2012
(r238122)
+++ head/contrib/binutils/opcodes/i386-dis.cWed Jul  4 22:12:10 2012
(r238123)
@@ -93,6 +93,7 @@ static void OP_3DNowSuffix (int, int);
 static void OP_SIMD_Suffix (int, int);
 static void SIMD_Fixup (int, int);
 static void PNI_Fixup (int, int);
+static void XCR_Fixup (int, int);
 static void SVME_Fixup (int, int);
 static void INVLPG_Fixup (int, int);
 static void BadOp (void);
@@ -1693,7 +1694,7 @@ static const struct dis386 grps[][8] = {
   {
 { "sgdt{Q|IQ||}", { { VMX_Fixup, 0 } } },
 { "sidt{Q|IQ||}", { { PNI_Fixup, 0 } } },
-{ "lgdt{Q|Q||}",{ M } },
+{ "lgdt{Q|Q||}",{ { XCR_Fixup, 0 }  } },
 { "lidt{Q|Q||}",{ { SVME_Fixup, 0 } } },
 { "smswD", { Sv } },
 { "(bad)", { XX } },
@@ -1783,9 +1784,9 @@ static const struct dis386 grps[][8] = {
 { "fxrstor",   { Ev } },
 { "ldmxcsr",   { Ev } },
 { "stmxcsr",   { Ev } },
-{ "(bad)", { XX } },
-{ "lfence",{ { OP_0fae, 0 } } },
-{ "mfence",{ { OP_0fae, 0 } } },
+{ "xsave", { Ev } },
+{ "xrstor",{ { OP_0fae, v_mode } } },
+{ "xsaveopt",  { { OP_0fae, v_mode } } },
 { "clflush",   { { OP_0fae, 0 } } },
   },
   /* GRP16 */
@@ -5905,17 +5906,17 @@ OP_0fae (int bytemode, int sizeflag)
 {
   if (modrm.reg == 7)
strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
+  else if (modrm.reg == 6)
+   strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence");
+  else if (modrm.reg == 5)
+   strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence");
 
   if (modrm.reg < 5 || modrm.rm != 0)
{
  BadOp (); /* bad sfence, mfence, or lfence */
  return;
}
-}
-  else if (modrm.reg != 7)
-{
-  BadOp ();/* bad clflush */
-  return;
+  bytemode = 0;
 }
 
   OP_E (bytemode, sizeflag);
@@ -6170,6 +6171,43 @@ PNI_Fixup (int extrachar ATTRIBUTE_UNUSE
 }
 
 static void
+XCR_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag)
+{
+  if (modrm.mod == 3 && modrm.reg == 2 && modrm.rm <= 1)
+{
+  /* Override "lgdt".  */
+  size_t olen = strlen (obuf);
+  char *p = obuf + olen - 4;
+
+  /* We might have a suffix when disassembling with -Msuffix.  */
+  if (*p == 'i')
+   --p;
+
+  /* Remove "addr16/addr32" if we aren't in Intel mode.  */
+  if (!intel_syntax
+ && (prefixes & PREFIX_ADDR)
+ && olen >= (4 + 7)
+ && *(p - 1) == ' '
+ && CONST_STRNEQ (p - 7, "addr")
+ && (CONST_STRNEQ (p - 3, "16")
+ || CONST_STRNEQ (p - 3, "32")))
+   p -= 7;
+
+  if (modrm.rm)
+   {
+ strcpy (p, "xsetbv");
+   }
+  else
+   {
+ strcpy (p, "xgetbv");
+   }
+
+  codep++;
+}
+  else
+OP_M (0, sizeflag);
+}
+static void
 SVME_Fixup (int bytemode, int sizeflag)
 {
   const char *alt;

Modified: head/contrib/binutils/opcodes/i386-opc.h
==
--- head/contrib/binutils/opcodes/i386-opc.hWed Jul  4 20:59:30 2012
(r238122)
+++ head/contrib/binutils/opcodes/i386-opc.hWed Jul  4 22:12:10 2012
(r238123)
@@ -71,6 +71,7 @@ typedef struct template
 #define CpuABM   0x20   /* ABM New Instructions required */
 #define CpuSSE4_10x40  /

svn commit: r238124 - head/sys/amd64/amd64

2012-07-04 Thread Alan Cox
Author: alc
Date: Thu Jul  5 00:08:47 2012
New Revision: 238124
URL: http://svn.freebsd.org/changeset/base/238124

Log:
  Correct an error in r237513.  The call to reserve_pv_entries() must come
  before pmap_demote_pde() updates the PDE.  Otherwise, pmap_pv_demote_pde()
  can crash.
  
  Crash reported by:kib
  Patch tested by:  kib

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Jul  4 22:12:10 2012(r238123)
+++ head/sys/amd64/amd64/pmap.c Thu Jul  5 00:08:47 2012(r238124)
@@ -2491,7 +2491,6 @@ pmap_pv_demote_pde(pmap_t pmap, vm_offse
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
KASSERT((pa & PDRMASK) == 0,
("pmap_pv_demote_pde: pa is not 2mpage aligned"));
-   reserve_pv_entries(pmap, NPTEPG - 1, lockp);
CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, pa);
 
/*
@@ -2751,6 +2750,17 @@ pmap_demote_pde_locked(pmap_t pmap, pd_e
pmap_fill_ptp(firstpte, newpte);
 
/*
+* The spare PV entries must be reserved prior to demoting the
+* mapping, that is, prior to changing the PDE.  Otherwise, the state
+* of the PDE and the PV lists will be inconsistent, which can result
+* in reclaim_pv_chunk() attempting to remove a PV entry from the
+* wrong PV list and pmap_pv_demote_pde() failing to find the expected
+* PV entry for the 2MB page mapping that is being demoted.
+*/
+   if ((oldpde & PG_MANAGED) != 0)
+   reserve_pv_entries(pmap, NPTEPG - 1, lockp);
+
+   /*
 * Demote the mapping.  This pmap is locked.  The old PDE has
 * PG_A set.  If the old PDE has PG_RW set, it also has PG_M
 * set.  Thus, there is no danger of a race with another
@@ -2769,13 +2779,7 @@ pmap_demote_pde_locked(pmap_t pmap, pd_e
pmap_invalidate_page(pmap, (vm_offset_t)vtopte(va));
 
/*
-* Demote the pv entry.  This depends on the earlier demotion
-* of the mapping.  Specifically, the (re)creation of a per-
-* page pv entry might trigger the execution of reclaim_pv_chunk(),
-* which might reclaim a newly (re)created per-page pv entry
-* and destroy the associated mapping.  In order to destroy
-* the mapping, the PDE must have already changed from mapping
-* the 2mpage to referencing the page table page.
+* Demote the PV entry.
 */
if ((oldpde & PG_MANAGED) != 0)
pmap_pv_demote_pde(pmap, va, oldpde & PG_PS_FRAME, lockp);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r238125 - head/cddl/contrib/dtracetoolkit

2012-07-04 Thread Ed Maste
Author: emaste
Date: Thu Jul  5 00:52:23 2012
New Revision: 238125
URL: http://svn.freebsd.org/changeset/base/238125

Log:
  Restore r211786 by rpaulo:
  
Port dtruss to FreeBSD.
  
Sponsored by:   The FreeBSD Foundation
  
  It appears the change was reverted by r235380.

Modified:
  head/cddl/contrib/dtracetoolkit/dtruss

Modified: head/cddl/contrib/dtracetoolkit/dtruss
==
--- head/cddl/contrib/dtracetoolkit/dtruss  Thu Jul  5 00:08:47 2012
(r238124)
+++ head/cddl/contrib/dtracetoolkit/dtruss  Thu Jul  5 00:52:23 2012
(r238125)
@@ -240,7 +240,7 @@ syscall:::entry
  */
 
 /* print 3 args, return as hex */
-syscall::lwp_sigmask:return
+syscall::sigprocmask:return
 /self->start/
 {
/* calculate elapsed time */
@@ -268,10 +268,11 @@ syscall::lwp_sigmask:return
 }
 
 /* print 3 args, arg0 as a string */
+syscall::access*:return,
 syscall::stat*:return, 
 syscall::lstat*:return, 
-syscall::open*:return,
-syscall::resolvepath:return
+syscall::readlink*:return,
+syscall::open*:return
 /self->start/
 {
/* calculate elapsed time */
@@ -329,7 +330,6 @@ syscall::*read*:return
 }
 
 /* print 0 arg output */
-syscall::gtime:return,
 syscall::*fork*:return
 /self->start/
 {
@@ -357,9 +357,6 @@ syscall::*fork*:return
 }
 
 /* print 1 arg output */
-syscall::brk:return,
-syscall::times:return,
-syscall::stime:return,
 syscall::close:return
 /self->start/
 {
@@ -387,7 +384,7 @@ syscall::close:return
 }
 
 /* print 2 arg output */
-syscall::utime:return,
+syscall::utimes:return,
 syscall::munmap:return
 /self->start/
 {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"