Print this page
patch lower-case-segops

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/urw.c
          +++ new/usr/src/uts/common/os/urw.c
↓ open down ↓ 64 lines elided ↑ open up ↑
  65   65          struct segvn_data *svd;
  66   66          vnode_t *vp;
  67   67          vattr_t vattr;
  68   68  
  69   69          /*
  70   70           * Fail if the page doesn't map to a page in the underlying
  71   71           * mapped file, if an underlying mapped file exists.
  72   72           */
  73   73          vattr.va_mask = AT_SIZE;
  74   74          if (seg->s_ops == &segvn_ops &&
  75      -            SEGOP_GETVP(seg, addr, &vp) == 0 &&
       75 +            segop_getvp(seg, addr, &vp) == 0 &&
  76   76              vp != NULL && vp->v_type == VREG &&
  77   77              VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
  78   78                  u_offset_t size = roundup(vattr.va_size, (u_offset_t)PAGESIZE);
  79      -                u_offset_t offset = SEGOP_GETOFFSET(seg, addr);
       79 +                u_offset_t offset = segop_getoffset(seg, addr);
  80   80  
  81   81                  if (offset >= size)
  82   82                          return (0);
  83   83          }
  84   84  
  85   85          /*
  86   86           * Fail if this is an ISM shared segment and the address is
  87   87           * not within the real size of the spt segment that backs it.
  88   88           */
  89   89          if (seg->s_ops == &segspt_shmops &&
  90   90              addr >= seg->s_base + spt_realsize(seg))
  91   91                  return (0);
  92   92  
  93   93          /*
  94   94           * Fail if the segment is mapped from /dev/null.
  95   95           * The key is that the mapping comes from segdev and the
  96   96           * type is neither MAP_SHARED nor MAP_PRIVATE.
  97   97           */
  98   98          if (seg->s_ops == &segdev_ops &&
  99      -            ((SEGOP_GETTYPE(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
       99 +            ((segop_gettype(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
 100  100                  return (0);
 101  101  
 102  102          /*
 103  103           * Fail if the page is a MAP_NORESERVE page that has
 104  104           * not actually materialized.
 105  105           * We cheat by knowing that segvn is the only segment
 106  106           * driver that supports MAP_NORESERVE.
 107  107           */
 108  108          if (seg->s_ops == &segvn_ops &&
 109  109              (svd = (struct segvn_data *)seg->s_data) != NULL &&
 110  110              (svd->vp == NULL || svd->vp->v_type != VREG) &&
 111  111              (svd->flags & MAP_NORESERVE)) {
 112  112                  /*
 113  113                   * Guilty knowledge here.  We know that
 114  114                   * segvn_incore returns more than just the
 115  115                   * low-order bit that indicates the page is
 116  116                   * actually in memory.  If any bits are set,
 117  117                   * then there is backing store for the page.
 118  118                   */
 119  119                  char incore = 0;
 120      -                (void) SEGOP_INCORE(seg, addr, PAGESIZE, &incore);
      120 +                (void) segop_incore(seg, addr, PAGESIZE, &incore);
 121  121                  if (incore == 0)
 122  122                          return (0);
 123  123          }
 124  124          return (1);
 125  125  }
 126  126  
 127  127  /*
 128  128   * Map address "addr" in address space "as" into a kernel virtual address.
 129  129   * The memory is guaranteed to be resident and locked down.
 130  130   */
↓ open down ↓ 71 lines elided ↑ open up ↑
 202  202           */
 203  203          page = (caddr_t)(uintptr_t)((uintptr_t)addr & PAGEMASK);
 204  204          retrycnt = 0;
 205  205          AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 206  206  retry:
 207  207          if ((seg = as_segat(as, page)) == NULL ||
 208  208              !page_valid(seg, page)) {
 209  209                  AS_LOCK_EXIT(as, &as->a_lock);
 210  210                  return (ENXIO);
 211  211          }
 212      -        SEGOP_GETPROT(seg, page, 0, &prot);
      212 +        segop_getprot(seg, page, 0, &prot);
 213  213  
 214  214          protchanged = 0;
 215  215          if ((prot & prot_rw) == 0) {
 216  216                  protchanged = 1;
 217      -                err = SEGOP_SETPROT(seg, page, PAGESIZE, prot | prot_rw);
      217 +                err = segop_setprot(seg, page, PAGESIZE, prot | prot_rw);
 218  218  
 219  219                  if (err == IE_RETRY) {
 220  220                          protchanged = 0;
 221  221                          ASSERT(retrycnt == 0);
 222  222                          retrycnt++;
 223  223                          goto retry;
 224  224                  }
 225  225  
 226  226                  if (err != 0) {
 227  227                          AS_LOCK_EXIT(as, &as->a_lock);
↓ open down ↓ 9 lines elided ↑ open up ↑
 237  237           * access type to tell segvn that it's ok not to do a copy-on-write
 238  238           * for this SOFTLOCK fault.
 239  239           */
 240  240          if (writing)
 241  241                  rw = S_WRITE;
 242  242          else if (seg->s_ops == &segvn_ops)
 243  243                  rw = S_READ_NOCOW;
 244  244          else
 245  245                  rw = S_READ;
 246  246  
 247      -        if (SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
      247 +        if (segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
 248  248                  if (protchanged)
 249      -                        (void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
      249 +                        (void) segop_setprot(seg, page, PAGESIZE, prot);
 250  250                  AS_LOCK_EXIT(as, &as->a_lock);
 251  251                  return (ENXIO);
 252  252          }
 253  253          CPU_STATS_ADD_K(vm, softlock, 1);
 254  254  
 255  255          /*
 256  256           * Make sure we're not trying to read or write off the end of the page.
 257  257           */
 258  258          ASSERT(len <= page + PAGESIZE - addr);
 259  259  
↓ open down ↓ 36 lines elided ↑ open up ↑
 296  296           * the I$ with the modifications we made through the D$.
 297  297           */
 298  298          if (writing && (prot & PROT_EXEC))
 299  299                  sync_icache(vaddr, (uint_t)len);
 300  300  
 301  301          mapout(as, addr, vaddr, writing);
 302  302  
 303  303          if (rw == S_READ_NOCOW)
 304  304                  rw = S_READ;
 305  305  
 306      -        (void) SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
      306 +        (void) segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
 307  307  
 308  308          if (protchanged)
 309      -                (void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
      309 +                (void) segop_setprot(seg, page, PAGESIZE, prot);
 310  310  
 311  311          AS_LOCK_EXIT(as, &as->a_lock);
 312  312  
 313  313          return (error);
 314  314  }
 315  315  
 316  316  int
 317  317  uread(proc_t *p, void *buf, size_t len, uintptr_t a)
 318  318  {
 319  319          return (urw(p, 0, buf, len, a));
 320  320  }
 321  321  
 322  322  int
 323  323  uwrite(proc_t *p, void *buf, size_t len, uintptr_t a)
 324  324  {
 325  325          return (urw(p, 1, buf, len, a));
 326  326  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX