Print this page
patch sccs-keywords
patch vm-cleanup


   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 2004 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 
  30 #include <sys/types.h>
  31 #include <sys/cmn_err.h>
  32 #include <sys/mman.h>
  33 #include <sys/systm.h>
  34 #include <vm/xhat.h>
  35 #include <vm/page.h>
  36 #include <vm/as.h>
  37 
  38 int xhat_debug = 0;
  39 
  40 krwlock_t xhat_provider_rwlock;
  41 xhat_provider_t *xhat_provider = NULL;
  42 
  43 void
  44 xhat_init()
  45 {
  46         rw_init(&xhat_provider_rwlock, NULL, RW_DEFAULT, NULL);
  47 }
  48 
  49 


 361 
 362         mutex_exit(&as->a_contents);
 363 }
 364 
 365 
 366 /* Assumes that address space is already locked */
 367 
 368 /* ARGSUSED */
 369 int
 370 xhat_dup_all(struct as *as, struct as *newas, caddr_t addr, size_t len,
 371     uint_t flag)
 372 {
 373         /* This is not supported. Should we return some sort of error? */
 374 
 375         ASSERT(AS_ISBUSY(as));
 376 
 377         return (0);
 378 }
 379 
 380 
 381 /* Assumes that address space is already locked */
 382 void
 383 xhat_swapout_all(struct as *as)
 384 {
 385         struct xhat *xh, *xh_nxt;
 386 
 387 
 388         ASSERT(AS_ISBUSY(as));
 389 
 390         mutex_enter(&as->a_contents);
 391         xh = (struct xhat *)as->a_xhat;
 392 
 393         if (xh != NULL) {
 394                 xhat_hat_hold(xh);
 395                 ASSERT(xh->holder == NULL);
 396                 xh->holder = curthread;
 397         }
 398 
 399 
 400         while (xh != NULL) {
 401 
 402                 xh_nxt = xh->next;
 403                 if (xh_nxt != NULL) {
 404                         ASSERT(xh_nxt->holder == NULL);
 405                         xhat_hat_hold(xh_nxt);
 406                         xh_nxt->holder = curthread;
 407                 }
 408 
 409                 mutex_exit(&as->a_contents);
 410 
 411                 XHAT_SWAPOUT(xh);
 412 
 413                 mutex_enter(&as->a_contents);
 414 
 415                 /*
 416                  * If the xh is still there (i.e. swapout did not
 417                  * destroy it), clear the holder field.
 418                  * xh_nxt->prev couldn't have been changed in xhat_attach_xhat()
 419                  * because AS_BUSY is set. xhat_detach_xhat() also couldn't
 420                  * have modified it because (holder != NULL).
 421                  * If there is only one XHAT, just see if a_xhat still
 422                  * points to us.
 423                  */
 424                 if (((xh_nxt != NULL) && (xh_nxt->prev == xh)) ||
 425                     ((as->a_xhat != NULL) && (as->a_xhat == xh))) {
 426                         xhat_hat_rele(xh);
 427                         xh->holder = NULL;
 428                 }
 429 
 430                 xh = xh_nxt;
 431         }
 432 
 433         mutex_exit(&as->a_contents);
 434 }
 435 
 436 
 437 
 438 
 439 /*
 440  * In the following routines, the appropriate xhat_op
 441  * should never attempt to call xhat_detach_xhat(): it will
 442  * never succeed since the XHAT is held.
 443  */
 444 
 445 
 446 #define XHAT_UNLOAD_CALLBACK_OP (0)
 447 #define XHAT_SETATTR_OP         (1)
 448 #define XHAT_CLRATTR_OP         (2)
 449 #define XHAT_CHGATTR_OP         (3)
 450 #define XHAT_CHGPROT_OP         (4)
 451 #define XHAT_UNSHARE_OP         (5)
 452 
 453 
 454 static void
 455 xhat_op_all(int op, struct as *as, caddr_t addr,
 456     size_t len, uint_t flags, void *ptr)
 457 {
 458         struct xhat *xh, *xh_nxt;




   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 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 



  27 #include <sys/types.h>
  28 #include <sys/cmn_err.h>
  29 #include <sys/mman.h>
  30 #include <sys/systm.h>
  31 #include <vm/xhat.h>
  32 #include <vm/page.h>
  33 #include <vm/as.h>
  34 
  35 int xhat_debug = 0;
  36 
  37 krwlock_t xhat_provider_rwlock;
  38 xhat_provider_t *xhat_provider = NULL;
  39 
  40 void
  41 xhat_init()
  42 {
  43         rw_init(&xhat_provider_rwlock, NULL, RW_DEFAULT, NULL);
  44 }
  45 
  46 


 358 
 359         mutex_exit(&as->a_contents);
 360 }
 361 
 362 
 363 /* Assumes that address space is already locked */
 364 
 365 /* ARGSUSED */
 366 int
 367 xhat_dup_all(struct as *as, struct as *newas, caddr_t addr, size_t len,
 368     uint_t flag)
 369 {
 370         /* This is not supported. Should we return some sort of error? */
 371 
 372         ASSERT(AS_ISBUSY(as));
 373 
 374         return (0);
 375 }
 376 
 377 


























































 378 /*
 379  * In the following routines, the appropriate xhat_op
 380  * should never attempt to call xhat_detach_xhat(): it will
 381  * never succeed since the XHAT is held.
 382  */
 383 
 384 
 385 #define XHAT_UNLOAD_CALLBACK_OP (0)
 386 #define XHAT_SETATTR_OP         (1)
 387 #define XHAT_CLRATTR_OP         (2)
 388 #define XHAT_CHGATTR_OP         (3)
 389 #define XHAT_CHGPROT_OP         (4)
 390 #define XHAT_UNSHARE_OP         (5)
 391 
 392 
 393 static void
 394 xhat_op_all(int op, struct as *as, caddr_t addr,
 395     size_t len, uint_t flags, void *ptr)
 396 {
 397         struct xhat *xh, *xh_nxt;