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/frame.h>
  36 #include <sys/dtrace_impl.h>
  37 #include <sys/cmn_err.h>
  38 #include <sys/sysmacros.h>
  39 #include <sys/privregs.h>
  40 #include <sys/sdt_impl.h>
  41 
  42 #define SDT_PATCHVAL    0xf0
  43 #define SDT_ADDR2NDX(addr)      ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask)
  44 #define SDT_PROBETAB_SIZE       0x1000          /* 4k entries -- 16K total */
  45 


 402 
 403         if (ddi_create_minor_node(devi, "sdt", S_IFCHR,
 404             0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
 405                 cmn_err(CE_NOTE, "/dev/sdt couldn't create minor node");
 406                 ddi_remove_minor_node(devi, NULL);
 407                 return (DDI_FAILURE);
 408         }
 409 
 410         ddi_report_dev(devi);
 411         sdt_devi = devi;
 412 
 413         if (sdt_probetab_size == 0)
 414                 sdt_probetab_size = SDT_PROBETAB_SIZE;
 415 
 416         sdt_probetab_mask = sdt_probetab_size - 1;
 417         sdt_probetab =
 418             kmem_zalloc(sdt_probetab_size * sizeof (sdt_probe_t *), KM_SLEEP);
 419         dtrace_invop_add(sdt_invop);
 420 
 421         for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {











 422                 if (dtrace_register(prov->sdtp_name, prov->sdtp_attr,
 423                     DTRACE_PRIV_KERNEL, NULL,
 424                     &sdt_pops, prov, &prov->sdtp_id) != 0) {
 425                         cmn_err(CE_WARN, "failed to register sdt provider %s",
 426                             prov->sdtp_name);
 427                 }
 428         }
 429 
 430         return (DDI_SUCCESS);
 431 }
 432 
 433 /*ARGSUSED*/
 434 static int
 435 sdt_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
 436 {
 437         sdt_provider_t *prov;
 438 
 439         switch (cmd) {
 440         case DDI_DETACH:
 441                 break;
 442 
 443         case DDI_SUSPEND:
 444                 return (DDI_SUCCESS);




   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/frame.h>
  39 #include <sys/dtrace_impl.h>
  40 #include <sys/cmn_err.h>
  41 #include <sys/sysmacros.h>
  42 #include <sys/privregs.h>
  43 #include <sys/sdt_impl.h>
  44 
  45 #define SDT_PATCHVAL    0xf0
  46 #define SDT_ADDR2NDX(addr)      ((((uintptr_t)(addr)) >> 4) & sdt_probetab_mask)
  47 #define SDT_PROBETAB_SIZE       0x1000          /* 4k entries -- 16K total */
  48 


 405 
 406         if (ddi_create_minor_node(devi, "sdt", S_IFCHR,
 407             0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
 408                 cmn_err(CE_NOTE, "/dev/sdt couldn't create minor node");
 409                 ddi_remove_minor_node(devi, NULL);
 410                 return (DDI_FAILURE);
 411         }
 412 
 413         ddi_report_dev(devi);
 414         sdt_devi = devi;
 415 
 416         if (sdt_probetab_size == 0)
 417                 sdt_probetab_size = SDT_PROBETAB_SIZE;
 418 
 419         sdt_probetab_mask = sdt_probetab_size - 1;
 420         sdt_probetab =
 421             kmem_zalloc(sdt_probetab_size * sizeof (sdt_probe_t *), KM_SLEEP);
 422         dtrace_invop_add(sdt_invop);
 423 
 424         for (prov = sdt_providers; prov->sdtp_name != NULL; prov++) {
 425                 uint32_t priv;
 426 
 427                 if (prov->sdtp_priv == DTRACE_PRIV_NONE) {
 428                         priv = DTRACE_PRIV_KERNEL;
 429                         sdt_pops.dtps_mode = NULL;
 430                 } else {
 431                         priv = prov->sdtp_priv;
 432                         ASSERT(priv == DTRACE_PRIV_USER);
 433                         sdt_pops.dtps_mode = sdt_mode;
 434                 }
 435 
 436                 if (dtrace_register(prov->sdtp_name, prov->sdtp_attr,
 437                     priv, NULL, &sdt_pops, prov, &prov->sdtp_id) != 0) {

 438                         cmn_err(CE_WARN, "failed to register sdt provider %s",
 439                             prov->sdtp_name);
 440                 }
 441         }
 442 
 443         return (DDI_SUCCESS);
 444 }
 445 
 446 /*ARGSUSED*/
 447 static int
 448 sdt_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
 449 {
 450         sdt_provider_t *prov;
 451 
 452         switch (cmd) {
 453         case DDI_DETACH:
 454                 break;
 455 
 456         case DDI_SUSPEND:
 457                 return (DDI_SUCCESS);