Print this page
patch lower-case-segops


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 #include <sys/types.h>
  30 #include <sys/t_lock.h>
  31 #include <sys/param.h>
  32 #include <sys/cred.h>
  33 #include <sys/debug.h>
  34 #include <sys/inline.h>
  35 #include <sys/kmem.h>
  36 #include <sys/proc.h>
  37 #include <sys/regset.h>
  38 #include <sys/sysmacros.h>
  39 #include <sys/systm.h>
  40 #include <sys/prsystm.h>
  41 #include <sys/buf.h>
  42 #include <sys/signal.h>
  43 #include <sys/user.h>
  44 #include <sys/cpuvar.h>
  45 
  46 #include <sys/fault.h>
  47 #include <sys/syscall.h>
  48 #include <sys/procfs.h>


 294                                         /* cannot have write-only protection */
 295                                         prot |= PROT_READ|PROT_WRITE;
 296 #if 0   /* damned broken mmu feature! */
 297                                 if (sum(pwp->wp_umap) == 0)
 298                                         prot &= ~PROT_USER;
 299 #endif
 300                         }
 301                 }
 302 
 303 
 304                 if (pwp->wp_oprot != 0) {    /* if page exists */
 305                         struct seg *seg;
 306                         uint_t oprot;
 307                         int err, retrycnt = 0;
 308 
 309                         AS_LOCK_EXIT(as, &as->a_lock);
 310                         AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 311                 retry:
 312                         seg = as_segat(as, addr);
 313                         ASSERT(seg != NULL);
 314                         SEGOP_GETPROT(seg, addr, 0, &oprot);
 315                         if (prot != oprot) {
 316                                 err = SEGOP_SETPROT(seg, addr, PAGESIZE, prot);
 317                                 if (err == IE_RETRY) {
 318                                         ASSERT(retrycnt == 0);
 319                                         retrycnt++;
 320                                         goto retry;
 321                                 }
 322                         }
 323                         AS_LOCK_EXIT(as, &as->a_lock);
 324                 } else
 325                         AS_LOCK_EXIT(as, &as->a_lock);
 326 
 327                 /*
 328                  * When all pages are mapped back to their normal state,
 329                  * continue the other lwps.
 330                  */
 331                 if (!mapin) {
 332                         ASSERT(p->p_mapcnt > 0);
 333                         p->p_mapcnt--;
 334                         if (p->p_mapcnt == 0) {
 335                                 mutex_exit(&p->p_maplock);
 336                                 mutex_enter(&p->p_lock);


 389         uint_t prot;
 390         int err, retrycnt;
 391 
 392         if (p->p_wprot == NULL)
 393                 return;
 394 
 395         ASSERT(MUTEX_NOT_HELD(&curproc->p_lock));
 396 
 397         AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 398 
 399         pwp = p->p_wprot;
 400         while (pwp != NULL) {
 401 
 402                 vaddr = pwp->wp_vaddr;
 403                 retrycnt = 0;
 404         retry:
 405                 ASSERT(pwp->wp_flags & WP_SETPROT);
 406                 if ((seg = as_segat(as, vaddr)) != NULL &&
 407                     !(pwp->wp_flags & WP_NOWATCH)) {
 408                         prot = pwp->wp_prot;
 409                         err = SEGOP_SETPROT(seg, vaddr, PAGESIZE, prot);
 410                         if (err == IE_RETRY) {
 411                                 ASSERT(retrycnt == 0);
 412                                 retrycnt++;
 413                                 goto retry;
 414                         }
 415                 }
 416 
 417                 next = pwp->wp_list;
 418 
 419                 if (pwp->wp_read + pwp->wp_write + pwp->wp_exec == 0) {
 420                         /*
 421                          * No watched areas remain in this page.
 422                          * Free the watched_page structure.
 423                          */
 424                         avl_remove(&as->a_wpage, pwp);
 425                         kmem_free(pwp, sizeof (struct watched_page));
 426                 } else {
 427                         pwp->wp_flags &= ~WP_SETPROT;
 428                 }
 429 




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


  27 #include <sys/types.h>
  28 #include <sys/t_lock.h>
  29 #include <sys/param.h>
  30 #include <sys/cred.h>
  31 #include <sys/debug.h>
  32 #include <sys/inline.h>
  33 #include <sys/kmem.h>
  34 #include <sys/proc.h>
  35 #include <sys/regset.h>
  36 #include <sys/sysmacros.h>
  37 #include <sys/systm.h>
  38 #include <sys/prsystm.h>
  39 #include <sys/buf.h>
  40 #include <sys/signal.h>
  41 #include <sys/user.h>
  42 #include <sys/cpuvar.h>
  43 
  44 #include <sys/fault.h>
  45 #include <sys/syscall.h>
  46 #include <sys/procfs.h>


 292                                         /* cannot have write-only protection */
 293                                         prot |= PROT_READ|PROT_WRITE;
 294 #if 0   /* damned broken mmu feature! */
 295                                 if (sum(pwp->wp_umap) == 0)
 296                                         prot &= ~PROT_USER;
 297 #endif
 298                         }
 299                 }
 300 
 301 
 302                 if (pwp->wp_oprot != 0) {    /* if page exists */
 303                         struct seg *seg;
 304                         uint_t oprot;
 305                         int err, retrycnt = 0;
 306 
 307                         AS_LOCK_EXIT(as, &as->a_lock);
 308                         AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 309                 retry:
 310                         seg = as_segat(as, addr);
 311                         ASSERT(seg != NULL);
 312                         (void) segop_getprot(seg, addr, 0, &oprot);
 313                         if (prot != oprot) {
 314                                 err = segop_setprot(seg, addr, PAGESIZE, prot);
 315                                 if (err == IE_RETRY) {
 316                                         ASSERT(retrycnt == 0);
 317                                         retrycnt++;
 318                                         goto retry;
 319                                 }
 320                         }
 321                         AS_LOCK_EXIT(as, &as->a_lock);
 322                 } else
 323                         AS_LOCK_EXIT(as, &as->a_lock);
 324 
 325                 /*
 326                  * When all pages are mapped back to their normal state,
 327                  * continue the other lwps.
 328                  */
 329                 if (!mapin) {
 330                         ASSERT(p->p_mapcnt > 0);
 331                         p->p_mapcnt--;
 332                         if (p->p_mapcnt == 0) {
 333                                 mutex_exit(&p->p_maplock);
 334                                 mutex_enter(&p->p_lock);


 387         uint_t prot;
 388         int err, retrycnt;
 389 
 390         if (p->p_wprot == NULL)
 391                 return;
 392 
 393         ASSERT(MUTEX_NOT_HELD(&curproc->p_lock));
 394 
 395         AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 396 
 397         pwp = p->p_wprot;
 398         while (pwp != NULL) {
 399 
 400                 vaddr = pwp->wp_vaddr;
 401                 retrycnt = 0;
 402         retry:
 403                 ASSERT(pwp->wp_flags & WP_SETPROT);
 404                 if ((seg = as_segat(as, vaddr)) != NULL &&
 405                     !(pwp->wp_flags & WP_NOWATCH)) {
 406                         prot = pwp->wp_prot;
 407                         err = segop_setprot(seg, vaddr, PAGESIZE, prot);
 408                         if (err == IE_RETRY) {
 409                                 ASSERT(retrycnt == 0);
 410                                 retrycnt++;
 411                                 goto retry;
 412                         }
 413                 }
 414 
 415                 next = pwp->wp_list;
 416 
 417                 if (pwp->wp_read + pwp->wp_write + pwp->wp_exec == 0) {
 418                         /*
 419                          * No watched areas remain in this page.
 420                          * Free the watched_page structure.
 421                          */
 422                         avl_remove(&as->a_wpage, pwp);
 423                         kmem_free(pwp, sizeof (struct watched_page));
 424                 } else {
 425                         pwp->wp_flags &= ~WP_SETPROT;
 426                 }
 427