191eaf3e1SJohn Birrell /*
291eaf3e1SJohn Birrell * CDDL HEADER START
391eaf3e1SJohn Birrell *
491eaf3e1SJohn Birrell * The contents of this file are subject to the terms of the
591eaf3e1SJohn Birrell * Common Development and Distribution License (the "License").
691eaf3e1SJohn Birrell * You may not use this file except in compliance with the License.
791eaf3e1SJohn Birrell *
891eaf3e1SJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
991eaf3e1SJohn Birrell * or http://www.opensolaris.org/os/licensing.
1091eaf3e1SJohn Birrell * See the License for the specific language governing permissions
1191eaf3e1SJohn Birrell * and limitations under the License.
1291eaf3e1SJohn Birrell *
1391eaf3e1SJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each
1491eaf3e1SJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1591eaf3e1SJohn Birrell * If applicable, add the following below this CDDL HEADER, with the
1691eaf3e1SJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying
1791eaf3e1SJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner]
1891eaf3e1SJohn Birrell *
1991eaf3e1SJohn Birrell * CDDL HEADER END
2091eaf3e1SJohn Birrell *
2191eaf3e1SJohn Birrell */
2291eaf3e1SJohn Birrell
2391eaf3e1SJohn Birrell /* Report registered DTrace providers. */
2491eaf3e1SJohn Birrell static int
sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)2591eaf3e1SJohn Birrell sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
2691eaf3e1SJohn Birrell {
2791eaf3e1SJohn Birrell char *p_name = NULL;
2891eaf3e1SJohn Birrell dtrace_provider_t
2991eaf3e1SJohn Birrell *prov = dtrace_provider;
3091eaf3e1SJohn Birrell int error = 0;
3191eaf3e1SJohn Birrell size_t len = 0;
3291eaf3e1SJohn Birrell
3391eaf3e1SJohn Birrell mutex_enter(&dtrace_provider_lock);
3491eaf3e1SJohn Birrell mutex_enter(&dtrace_lock);
3591eaf3e1SJohn Birrell
3691eaf3e1SJohn Birrell /* Compute the length of the space-separated provider name string. */
3791eaf3e1SJohn Birrell while (prov != NULL) {
3891eaf3e1SJohn Birrell len += strlen(prov->dtpv_name) + 1;
3991eaf3e1SJohn Birrell prov = prov->dtpv_next;
4091eaf3e1SJohn Birrell }
4191eaf3e1SJohn Birrell
4291eaf3e1SJohn Birrell if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
4391eaf3e1SJohn Birrell error = ENOMEM;
4491eaf3e1SJohn Birrell else {
4591eaf3e1SJohn Birrell /* Start with an empty string. */
4691eaf3e1SJohn Birrell *p_name = '\0';
4791eaf3e1SJohn Birrell
4891eaf3e1SJohn Birrell /* Point to the first provider again. */
4991eaf3e1SJohn Birrell prov = dtrace_provider;
5091eaf3e1SJohn Birrell
5191eaf3e1SJohn Birrell /* Loop through the providers, appending the names. */
5291eaf3e1SJohn Birrell while (prov != NULL) {
5391eaf3e1SJohn Birrell if (prov != dtrace_provider)
5491eaf3e1SJohn Birrell (void) strlcat(p_name, " ", len);
5591eaf3e1SJohn Birrell
5691eaf3e1SJohn Birrell (void) strlcat(p_name, prov->dtpv_name, len);
5791eaf3e1SJohn Birrell
5891eaf3e1SJohn Birrell prov = prov->dtpv_next;
5991eaf3e1SJohn Birrell }
6091eaf3e1SJohn Birrell }
6191eaf3e1SJohn Birrell
6291eaf3e1SJohn Birrell mutex_exit(&dtrace_lock);
6391eaf3e1SJohn Birrell mutex_exit(&dtrace_provider_lock);
6491eaf3e1SJohn Birrell
6591eaf3e1SJohn Birrell if (p_name != NULL) {
6691eaf3e1SJohn Birrell error = sysctl_handle_string(oidp, p_name, len, req);
6791eaf3e1SJohn Birrell
6891eaf3e1SJohn Birrell kmem_free(p_name, 0);
6991eaf3e1SJohn Birrell }
7091eaf3e1SJohn Birrell
7191eaf3e1SJohn Birrell return (error);
7291eaf3e1SJohn Birrell }
7391eaf3e1SJohn Birrell
747029da5cSPawel Biernacki SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
757029da5cSPawel Biernacki "DTrace debug parameters");
76cd8bbc38SMark Johnston
77638af813SMateusz Guzik SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers,
78638af813SMateusz Guzik CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers,
79638af813SMateusz Guzik "A", "available DTrace providers");
8091eaf3e1SJohn Birrell
817029da5cSPawel Biernacki SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
827029da5cSPawel Biernacki "DTrace parameters");
83b53bfbbaSMark Johnston
84cd8bbc38SMark Johnston SYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW,
85cd8bbc38SMark Johnston &dtrace_err_verbose, 0,
86cd8bbc38SMark Johnston "print DIF and DOF validation errors to the message buffer");
87cd8bbc38SMark Johnston
88b53bfbbaSMark Johnston SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max,
89e572bc11SMark Johnston 0, "largest allowed argument to memstr(), 0 indicates no limit");
90b53bfbbaSMark Johnston
91f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
92b53bfbbaSMark Johnston &dtrace_dof_maxsize, 0, "largest allowed DOF table");
93b53bfbbaSMark Johnston
94f0188618SHans Petter Selasky SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
95b53bfbbaSMark Johnston &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
96cdaa8777SGeorge V. Neville-Neil
97*7fdf0e88SAndriy Gapon SYSCTL_INT(_kern_dtrace, OID_AUTO, bufsize_max, CTLFLAG_RWTUN,
98*7fdf0e88SAndriy Gapon &dtrace_bufsize_max_frac, 0,
99*7fdf0e88SAndriy Gapon "maximum fraction (1/n-th) of physical memory for principal buffers");
100*7fdf0e88SAndriy Gapon
101cdaa8777SGeorge V. Neville-Neil SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,
102cdaa8777SGeorge V. Neville-Neil &dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");
103