Print this page
13026 SMB and NFS use the global zone's IDMAP when they shouldn't
Change-Id: I3b5f7bc68bb77764aa7cb59a48dd1740a8387ccf

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/sun4u/chicago/io/fpc/fpc-impl-4u.c
          +++ new/usr/src/uts/sun4u/chicago/io/fpc/fpc-impl-4u.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright 2020 Nexenta by DDN, Inc. All rights reserved.
       29 + */
       30 +
  27   31  #include <sys/file.h>
  28   32  #include <sys/sunndi.h>
  29   33  #include <sys/sunddi.h>
  30   34  #include <sys/sunldi.h>
  31   35  #include <io/px/px_regs.h>
  32   36  #include <sys/pci_tools.h>
  33   37  #include <fpc.h>
  34   38  #include <fpc-impl.h>
  35   39  
  36   40  #define CHIP_COMPATIBLE_NAME    "pciex108e,80f0"
↓ open down ↓ 57 lines elided ↑ open up ↑
  94   98  #define LPU_LINK_PERFCTR_WRITE_OFFSET   0x8
  95   99  
  96  100  /*
  97  101   * Note that LPU_LINK_PERFORMANCE_COUNTER_CONTROL register is hard-reset to
  98  102   * zeros and this is the value we want.  This register isn't touched by this
  99  103   * module, and as long as it remains untouched by other modules we're OK.
 100  104   */
 101  105  
 102  106  static ldi_ident_t ldi_identifier;
 103  107  static boolean_t ldi_identifier_valid = B_FALSE;
 104      -static cred_t *credentials = NULL;
 105  108  
 106  109  /* Called by _init to determine if it is OK to install driver. */
 107  110  int
 108  111  fpc_platform_check()
 109  112  {
 110  113          return (SUCCESS);
 111  114  }
 112  115  
 113  116  /* Called during attach to do module-wide initialization. */
 114  117  int
 115  118  fpc_platform_module_init(dev_info_t *dip)
 116  119  {
 117  120          int status;
 118  121  
 119      -        credentials = crget();
 120  122          status = ldi_ident_from_dip(dip, &ldi_identifier);
 121  123          if (status == 0)
 122  124                  ldi_identifier_valid = B_TRUE;
 123  125          return ((status == 0) ? DDI_SUCCESS : DDI_FAILURE);
 124  126  }
 125  127  
 126  128  int
 127  129  fpc_platform_node_init(dev_info_t *dip, int *avail)
 128  130  {
 129  131          int index;
↓ open down ↓ 74 lines elided ↑ open up ↑
 204  206                  kmem_free(plat_arg->nodename, strlen(plat_arg->nodename)+1);
 205  207          kmem_free(plat_arg, sizeof (fire4u_specific_t));
 206  208  }
 207  209  
 208  210  /*ARGSUSED*/
 209  211  void
 210  212  fpc_platform_module_fini(dev_info_t *dip)
 211  213  {
 212  214          if (ldi_identifier_valid)
 213  215                  ldi_ident_release(ldi_identifier);
 214      -        if (credentials)
 215      -                crfree(credentials);
 216  216  }
 217  217  
 218  218  fire_perfreg_handle_t
 219  219  fpc_get_perfreg_handle(int devnum)
 220  220  {
 221  221          int rval = EINVAL;
 222  222  
 223  223          fire_counter_handle_impl_t *handle_impl =
 224  224              kmem_zalloc(sizeof (fire_counter_handle_impl_t), KM_SLEEP);
 225  225  
 226  226          if ((handle_impl->devspec =
 227  227              fpc_get_platform_data_by_number(devnum)) != NULL) {
 228  228                  rval = ldi_open_by_name(handle_impl->devspec->nodename,
 229      -                    OPEN_FLAGS, credentials, &handle_impl->devhandle,
      229 +                    OPEN_FLAGS, kcred, &handle_impl->devhandle,
 230  230                      ldi_identifier);
 231  231          }
 232  232  
 233  233          if (rval != SUCCESS) {
 234  234                  kmem_free(handle_impl, sizeof (fire_counter_handle_impl_t));
 235  235                  return ((fire_perfreg_handle_t)-1);
 236  236          } else {
 237  237                  return ((fire_perfreg_handle_t)handle_impl);
 238  238          }
 239  239  }
 240  240  
 241  241  int
 242  242  fpc_free_counter_handle(fire_perfreg_handle_t handle)
 243  243  {
 244  244          fire_counter_handle_impl_t *handle_impl =
 245  245              (fire_counter_handle_impl_t *)handle;
 246      -        (void) ldi_close(handle_impl->devhandle, OPEN_FLAGS, credentials);
      246 +        (void) ldi_close(handle_impl->devhandle, OPEN_FLAGS, kcred);
 247  247          kmem_free(handle_impl, sizeof (fire_counter_handle_impl_t));
 248  248          return (SUCCESS);
 249  249  }
 250  250  
 251  251  int
 252  252  fpc_event_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
 253  253      uint64_t *reg_data, boolean_t is_write)
 254  254  {
 255  255          int rval;
 256  256          int ioctl_rval;
↓ open down ↓ 17 lines elided ↑ open up ↑
 274  274                   * base needs to be subtracted to get the relative offset that
 275  275                   * pcitool ioctls want.
 276  276                   */
 277  277                  prg.offset = counter_select_offsets[group];
 278  278          }
 279  279          prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 | PCITOOL_ACC_ATTR_ENDN_BIG;
 280  280          prg.data = *reg_data;
 281  281  
 282  282          /* Read original value. */
 283  283          if (((rval = ldi_ioctl(handle_impl->devhandle, cmd, (intptr_t)&prg,
 284      -            FKIOCTL, credentials, &ioctl_rval)) == SUCCESS) && (!is_write)) {
      284 +            FKIOCTL, kcred, &ioctl_rval)) == SUCCESS) && (!is_write)) {
 285  285                  *reg_data = prg.data;
 286  286          }
 287  287  
 288  288          return (rval);
 289  289  }
 290  290  
 291  291  int
 292  292  fpc_counter_io(fire_perfreg_handle_t handle, fire_perfcnt_t group,
 293  293      int counter_index, uint64_t *value, boolean_t is_write)
 294  294  {
↓ open down ↓ 20 lines elided ↑ open up ↑
 315  315          }
 316  316  
 317  317          if ((group == lpu) && (is_write)) {
 318  318                  prg.offset += LPU_LINK_PERFCTR_WRITE_OFFSET;
 319  319          }
 320  320  
 321  321          prg.acc_attr = PCITOOL_ACC_ATTR_SIZE_8 | PCITOOL_ACC_ATTR_ENDN_BIG;
 322  322          prg.data = *value;
 323  323  
 324  324          if (((rval = ldi_ioctl(handle_impl->devhandle, command, (intptr_t)&prg,
 325      -            FKIOCTL, credentials, &ioctl_rval)) == SUCCESS) && (!is_write)) {
      325 +            FKIOCTL, kcred, &ioctl_rval)) == SUCCESS) && (!is_write)) {
 326  326                  *value = prg.data;
 327  327          }
 328  328  
 329  329          return (rval);
 330  330  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX