Print this page
2915 DTrace in a zone should see "cpu", "curpsinfo", et al
2916 DTrace in a zone should be able to access fds[]
2917 DTrace in a zone should have limited provider access
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Adam Leventhal <ahl@delphix.com>


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 



  26 
  27 #include <sys/modctl.h>
  28 #include <sys/sunddi.h>
  29 #include <sys/dtrace.h>
  30 #include <sys/kobj.h>
  31 #include <sys/stat.h>
  32 #include <sys/conf.h>
  33 #include <vm/seg_kmem.h>
  34 #include <sys/stack.h>
  35 #include <sys/sdt_impl.h>
  36 
  37 static dev_info_t               *sdt_devi;
  38 
  39 int sdt_verbose = 0;
  40 
  41 #define SDT_REG_G0              0
  42 #define SDT_REG_O0              8
  43 #define SDT_REG_O1              9
  44 #define SDT_REG_O2              10
  45 #define SDT_REG_O3              11


 356 
 357         switch (cmd) {
 358         case DDI_ATTACH:
 359                 break;
 360         case DDI_RESUME:
 361                 return (DDI_SUCCESS);
 362         default:
 363                 return (DDI_FAILURE);
 364         }
 365 
 366         if (ddi_create_minor_node(devi, "sdt", S_IFCHR, 0,
 367             DDI_PSEUDO, NULL) == DDI_FAILURE) {
 368                 ddi_remove_minor_node(devi, NULL);
 369                 return (DDI_FAILURE);
 370         }
 371 
 372         ddi_report_dev(devi);
 373         sdt_devi = devi;
 374 
 375         for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {











 376                 if (dtrace_register(prov->sdtp_name, prov->sdtp_attr,
 377                     DTRACE_PRIV_KERNEL, NULL,
 378                     &sdt_pops, prov, &prov->sdtp_id) != 0) {
 379                         cmn_err(CE_WARN, "failed to register sdt provider %s",
 380                             prov->sdtp_name);
 381                 }
 382         }
 383 
 384         return (DDI_SUCCESS);
 385 }
 386 
 387 static int
 388 sdt_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
 389 {
 390         sdt_provider_t *prov;
 391 
 392         switch (cmd) {
 393         case DDI_DETACH:
 394                 break;
 395         case DDI_SUSPEND:
 396                 return (DDI_SUCCESS);
 397         default:
 398                 return (DDI_FAILURE);




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  28  */
  29 
  30 #include <sys/modctl.h>
  31 #include <sys/sunddi.h>
  32 #include <sys/dtrace.h>
  33 #include <sys/kobj.h>
  34 #include <sys/stat.h>
  35 #include <sys/conf.h>
  36 #include <vm/seg_kmem.h>
  37 #include <sys/stack.h>
  38 #include <sys/sdt_impl.h>
  39 
  40 static dev_info_t               *sdt_devi;
  41 
  42 int sdt_verbose = 0;
  43 
  44 #define SDT_REG_G0              0
  45 #define SDT_REG_O0              8
  46 #define SDT_REG_O1              9
  47 #define SDT_REG_O2              10
  48 #define SDT_REG_O3              11


 359 
 360         switch (cmd) {
 361         case DDI_ATTACH:
 362                 break;
 363         case DDI_RESUME:
 364                 return (DDI_SUCCESS);
 365         default:
 366                 return (DDI_FAILURE);
 367         }
 368 
 369         if (ddi_create_minor_node(devi, "sdt", S_IFCHR, 0,
 370             DDI_PSEUDO, NULL) == DDI_FAILURE) {
 371                 ddi_remove_minor_node(devi, NULL);
 372                 return (DDI_FAILURE);
 373         }
 374 
 375         ddi_report_dev(devi);
 376         sdt_devi = devi;
 377 
 378         for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {
 379                 uint32_t priv;
 380 
 381                 if (prov->sdtp_priv == DTRACE_PRIV_NONE) {
 382                         priv = DTRACE_PRIV_KERNEL;
 383                         sdt_pops.dtps_mode = NULL;
 384                 } else {
 385                         priv = prov->sdtp_priv;
 386                         ASSERT(priv == DTRACE_PRIV_USER);
 387                         sdt_pops.dtps_mode = sdt_mode;
 388                 }
 389 
 390                 if (dtrace_register(prov->sdtp_name, prov->sdtp_attr,
 391                     priv, NULL, &sdt_pops, prov, &prov->sdtp_id) != 0) {

 392                         cmn_err(CE_WARN, "failed to register sdt provider %s",
 393                             prov->sdtp_name);
 394                 }
 395         }
 396 
 397         return (DDI_SUCCESS);
 398 }
 399 
 400 static int
 401 sdt_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
 402 {
 403         sdt_provider_t *prov;
 404 
 405         switch (cmd) {
 406         case DDI_DETACH:
 407                 break;
 408         case DDI_SUSPEND:
 409                 return (DDI_SUCCESS);
 410         default:
 411                 return (DDI_FAILURE);