13446Smrj /* 23446Smrj * CDDL HEADER START 33446Smrj * 43446Smrj * The contents of this file are subject to the terms of the 53446Smrj * Common Development and Distribution License (the "License"). 63446Smrj * You may not use this file except in compliance with the License. 73446Smrj * 83446Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93446Smrj * or http://www.opensolaris.org/os/licensing. 103446Smrj * See the License for the specific language governing permissions 113446Smrj * and limitations under the License. 123446Smrj * 133446Smrj * When distributing Covered Code, include this CDDL HEADER in each 143446Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153446Smrj * If applicable, add the following below this CDDL HEADER, with the 163446Smrj * fields enclosed by brackets "[]" replaced with your own identifying 173446Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 183446Smrj * 193446Smrj * CDDL HEADER END 203446Smrj */ 213446Smrj /* 223446Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 233446Smrj * Use is subject to license terms. 243446Smrj */ 253446Smrj 263446Smrj #ifndef _SYS_HOLD_PAGE_H 273446Smrj #define _SYS_HOLD_PAGE_H 283446Smrj 293446Smrj #pragma ident "%Z%%M% %I% %E% SMI" 303446Smrj 313446Smrj #ifdef __cplusplus 323446Smrj extern "C" { 333446Smrj #endif 343446Smrj 353446Smrj #include <sys/types.h> 363446Smrj #include <vm/page.h> 373446Smrj 383446Smrj /* 393446Smrj * swrand generates entropy by mapping different pages in the system. This 403446Smrj * can create problems for some hypervisors, as certain pages may be removed 413446Smrj * from the system at any time. The following interfaces allow swrand to 423446Smrj * check the validity and make sure a page is not given away while it is mapped. 433446Smrj * 443446Smrj * int plat_hold_page(pfn_t pfn, int lock, page_t **pp_ret) 453446Smrj * 463446Smrj * If lock is PLAT_HOLD_NO_LOCK, simply check if the page pfn is valid 473446Smrj * in the system. If the page is valid, PLAT_HOLD_OK will be returned. 483446Smrj * pp_ret is ignored if lock is PLAT_HOLD_NO_LOCK. 493446Smrj * 503446Smrj * If lock is PLAT_HOLD_LOCK, in addition to the above, attempt to lock 513446Smrj * the page exclusively. Again, if the lock is successful, the page 52*5084Sjohnlev * pointer will be put in pp_ret, and PLAT_HOLD_OK will be returned. 53*5084Sjohnlev * pp_ret must be passed to a later call to plat_release_page. If the 54*5084Sjohnlev * page wasn't found, or the lock couldn't be grabbed, the return value 55*5084Sjohnlev * will be PLAT_HOLD_FAIL. 563446Smrj * 573446Smrj * void plat_release_page(page_t *pp) 583446Smrj * 593446Smrj * Unlock the page pp. Should only be called after a previous, 60*5084Sjohnlev * successful call to plat_hold_page(pfn, PLAT_HOLD_LOCK, &pp); 613446Smrj */ 623446Smrj 633446Smrj #define PLAT_HOLD_NO_LOCK 0 643446Smrj #define PLAT_HOLD_LOCK 1 653446Smrj 663446Smrj #define PLAT_HOLD_OK 0 673446Smrj #define PLAT_HOLD_FAIL 1 683446Smrj 693446Smrj extern int plat_hold_page(pfn_t, int, page_t **); 703446Smrj extern void plat_release_page(page_t *); 713446Smrj 723446Smrj #ifdef __cplusplus 733446Smrj } 743446Smrj #endif 753446Smrj 763446Smrj #endif /* _SYS_HOLD_PAGE_H */ 77