17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 25*a6a74e0eSMatthew Ahrens /* 26*a6a74e0eSMatthew Ahrens * Copyright (c) 2014 by Delphix. All rights reserved. 27*a6a74e0eSMatthew Ahrens */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _VM_HTABLE_H 307c478bd9Sstevel@tonic-gate #define _VM_HTABLE_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL) 377c478bd9Sstevel@tonic-gate #include <asm/htable.h> 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate extern void atomic_andb(uint8_t *addr, uint8_t value); 417c478bd9Sstevel@tonic-gate extern void atomic_orb(uint8_t *addr, uint8_t value); 427c478bd9Sstevel@tonic-gate extern void atomic_inc16(uint16_t *addr); 437c478bd9Sstevel@tonic-gate extern void atomic_dec16(uint16_t *addr); 447c478bd9Sstevel@tonic-gate extern void mmu_tlbflush_entry(caddr_t addr); 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * Each hardware page table has an htable_t describing it. 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * We use a reference counter mechanism to detect when we can free an htable. 507c478bd9Sstevel@tonic-gate * In the implmentation the reference count is split into 2 separate counters: 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * ht_busy is a traditional reference count of uses of the htable pointer 537c478bd9Sstevel@tonic-gate * 547c478bd9Sstevel@tonic-gate * ht_valid_cnt is a count of how references are implied by valid PTE/PTP 557c478bd9Sstevel@tonic-gate * entries in the pagetable 567c478bd9Sstevel@tonic-gate * 577c478bd9Sstevel@tonic-gate * ht_busy is only incremented by htable_lookup() or htable_create() 587c478bd9Sstevel@tonic-gate * while holding the appropriate hash_table mutex. While installing a new 597c478bd9Sstevel@tonic-gate * valid PTE or PTP, in order to increment ht_valid_cnt a thread must have 607c478bd9Sstevel@tonic-gate * done an htable_lookup() or htable_create() but not the htable_release yet. 617c478bd9Sstevel@tonic-gate * 627c478bd9Sstevel@tonic-gate * htable_release(), while holding the mutex, can know that if 637c478bd9Sstevel@tonic-gate * busy == 1 and valid_cnt == 0, the htable can be free'd. 647c478bd9Sstevel@tonic-gate * 657c478bd9Sstevel@tonic-gate * The fields have been ordered to make htable_lookup() fast. Hence, 667c478bd9Sstevel@tonic-gate * ht_hat, ht_vaddr, ht_level and ht_next need to be clustered together. 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate struct htable { 697c478bd9Sstevel@tonic-gate struct htable *ht_next; /* forward link for hash table */ 707c478bd9Sstevel@tonic-gate struct hat *ht_hat; /* hat this mapping comes from */ 717c478bd9Sstevel@tonic-gate uintptr_t ht_vaddr; /* virt addr at start of this table */ 72ae115bc7Smrj int8_t ht_level; /* page table level: 0=4K, 1=2M, ... */ 73ae115bc7Smrj uint8_t ht_flags; /* see below */ 747c478bd9Sstevel@tonic-gate int16_t ht_busy; /* implements locking protocol */ 757c478bd9Sstevel@tonic-gate int16_t ht_valid_cnt; /* # of valid entries in this table */ 767c478bd9Sstevel@tonic-gate uint32_t ht_lock_cnt; /* # of locked entries in this table */ 777c478bd9Sstevel@tonic-gate /* never used for kernel hat */ 787c478bd9Sstevel@tonic-gate pfn_t ht_pfn; /* pfn of page of the pagetable */ 797c478bd9Sstevel@tonic-gate struct htable *ht_prev; /* backward link for hash table */ 807c478bd9Sstevel@tonic-gate struct htable *ht_parent; /* htable that points to this htable */ 817c478bd9Sstevel@tonic-gate struct htable *ht_shares; /* for HTABLE_SHARED_PFN only */ 827c478bd9Sstevel@tonic-gate }; 837c478bd9Sstevel@tonic-gate typedef struct htable htable_t; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Flags values for htable ht_flags field: 877c478bd9Sstevel@tonic-gate * 887c478bd9Sstevel@tonic-gate * HTABLE_VLP - this is the top level htable of a VLP HAT. 897c478bd9Sstevel@tonic-gate * 90ae115bc7Smrj * HTABLE_SHARED_PFN - this htable had its PFN assigned from sharing another 917c478bd9Sstevel@tonic-gate * htable. Used by hat_share() for ISM. 927c478bd9Sstevel@tonic-gate */ 93ae115bc7Smrj #define HTABLE_VLP (0x01) 94ae115bc7Smrj #define HTABLE_SHARED_PFN (0x02) 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * The htable hash table hashing function. The 28 is so that high 987c478bd9Sstevel@tonic-gate * order bits are include in the hash index to skew the wrap 997c8868c1Sjosephb * around of addresses. Even though the hash buckets are stored per 1007c8868c1Sjosephb * hat we include the value of hat pointer in the hash function so 1017c8868c1Sjosephb * that the secondary hash for the htable mutex winds up begin different in 1027c8868c1Sjosephb * every address space. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate #define HTABLE_HASH(hat, va, lvl) \ 1057c8868c1Sjosephb ((((va) >> LEVEL_SHIFT(1)) + ((va) >> 28) + (lvl) + \ 1067c8868c1Sjosephb ((uintptr_t)(hat) >> 4)) & ((hat)->hat_num_hash - 1)) 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * Each CPU gets a unique hat_cpu_info structure in cpu_hat_info. 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate struct hat_cpu_info { 1127c478bd9Sstevel@tonic-gate kmutex_t hci_mutex; /* mutex to ensure sequential usage */ 1137c478bd9Sstevel@tonic-gate #if defined(__amd64) 1147c478bd9Sstevel@tonic-gate pfn_t hci_vlp_pfn; /* pfn of hci_vlp_l3ptes */ 1157c478bd9Sstevel@tonic-gate x86pte_t *hci_vlp_l3ptes; /* VLP Level==3 pagetable (top) */ 1167c478bd9Sstevel@tonic-gate x86pte_t *hci_vlp_l2ptes; /* VLP Level==2 pagetable */ 1177c478bd9Sstevel@tonic-gate #endif /* __amd64 */ 1187c478bd9Sstevel@tonic-gate }; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * Compute the last page aligned VA mapped by an htable. 1237c478bd9Sstevel@tonic-gate * 1247c478bd9Sstevel@tonic-gate * Given a va and a level, compute the virtual address of the start of the 1257c478bd9Sstevel@tonic-gate * next page at that level. 1267c478bd9Sstevel@tonic-gate * 1277c478bd9Sstevel@tonic-gate * XX64 - The check for the VA hole needs to be better generalized. 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate #if defined(__amd64) 130843e1988Sjohnlev #define HTABLE_NUM_PTES(ht) (((ht)->ht_flags & HTABLE_VLP) ? 4 : 512) 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #define HTABLE_LAST_PAGE(ht) \ 1337c478bd9Sstevel@tonic-gate ((ht)->ht_level == mmu.max_level ? ((uintptr_t)0UL - MMU_PAGESIZE) :\ 1347c478bd9Sstevel@tonic-gate ((ht)->ht_vaddr - MMU_PAGESIZE + \ 135ae115bc7Smrj ((uintptr_t)HTABLE_NUM_PTES(ht) << LEVEL_SHIFT((ht)->ht_level)))) 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #define NEXT_ENTRY_VA(va, l) \ 1387c478bd9Sstevel@tonic-gate ((va & LEVEL_MASK(l)) + LEVEL_SIZE(l) == mmu.hole_start ? \ 1397c478bd9Sstevel@tonic-gate mmu.hole_end : (va & LEVEL_MASK(l)) + LEVEL_SIZE(l)) 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #elif defined(__i386) 1427c478bd9Sstevel@tonic-gate 143843e1988Sjohnlev #define HTABLE_NUM_PTES(ht) \ 144843e1988Sjohnlev (!mmu.pae_hat ? 1024 : ((ht)->ht_level == 2 ? 4 : 512)) 145ae115bc7Smrj 1467c478bd9Sstevel@tonic-gate #define HTABLE_LAST_PAGE(ht) ((ht)->ht_vaddr - MMU_PAGESIZE + \ 147ae115bc7Smrj ((uintptr_t)HTABLE_NUM_PTES(ht) << LEVEL_SHIFT((ht)->ht_level))) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #define NEXT_ENTRY_VA(va, l) ((va & LEVEL_MASK(l)) + LEVEL_SIZE(l)) 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #endif 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* 1567c478bd9Sstevel@tonic-gate * initialization function called from hat_init() 1577c478bd9Sstevel@tonic-gate */ 1587c478bd9Sstevel@tonic-gate extern void htable_init(void); 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * Functions to lookup, or "lookup and create", the htable corresponding 1627c478bd9Sstevel@tonic-gate * to the virtual address "vaddr" in the "hat" at the given "level" of 1637c478bd9Sstevel@tonic-gate * page tables. htable_lookup() may return NULL if no such entry exists. 1647c478bd9Sstevel@tonic-gate * 1657c478bd9Sstevel@tonic-gate * On return the given htable is marked busy (a shared lock) - this prevents 1667c478bd9Sstevel@tonic-gate * the htable from being stolen or freed) until htable_release() is called. 1677c478bd9Sstevel@tonic-gate * 1687c478bd9Sstevel@tonic-gate * If kalloc_flag is set on an htable_create() we can't call kmem allocation 1697c478bd9Sstevel@tonic-gate * routines for this htable, since it's for the kernel hat itself. 1707c478bd9Sstevel@tonic-gate * 1717c478bd9Sstevel@tonic-gate * htable_acquire() is used when an htable pointer has been extracted from 1727c478bd9Sstevel@tonic-gate * an hment and we need to get a reference to the htable. 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate extern htable_t *htable_lookup(struct hat *hat, uintptr_t vaddr, level_t level); 1757c478bd9Sstevel@tonic-gate extern htable_t *htable_create(struct hat *hat, uintptr_t vaddr, level_t level, 1767c478bd9Sstevel@tonic-gate htable_t *shared); 1777c478bd9Sstevel@tonic-gate extern void htable_acquire(htable_t *); 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate extern void htable_release(htable_t *ht); 180ae115bc7Smrj extern void htable_destroy(htable_t *ht); 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Code to free all remaining htables for a hat. Called after the hat is no 1847c478bd9Sstevel@tonic-gate * longer in use by any thread. 1857c478bd9Sstevel@tonic-gate */ 1867c478bd9Sstevel@tonic-gate extern void htable_purge_hat(struct hat *hat); 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate /* 1897c478bd9Sstevel@tonic-gate * Find the htable, page table entry index, and PTE of the given virtual 1907c478bd9Sstevel@tonic-gate * address. If not found returns NULL. When found, returns the htable_t *, 1917c478bd9Sstevel@tonic-gate * sets entry, and has a hold on the htable. 1927c478bd9Sstevel@tonic-gate */ 1937c478bd9Sstevel@tonic-gate extern htable_t *htable_getpte(struct hat *, uintptr_t, uint_t *, x86pte_t *, 1947c478bd9Sstevel@tonic-gate level_t); 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * Similar to hat_getpte(), except that this only succeeds if a valid 1987c478bd9Sstevel@tonic-gate * page mapping is present. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate extern htable_t *htable_getpage(struct hat *hat, uintptr_t va, uint_t *entry); 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * Called to allocate initial/additional htables for reserve. 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate extern void htable_initial_reserve(uint_t); 2067c478bd9Sstevel@tonic-gate extern void htable_reserve(uint_t); 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* 2097c478bd9Sstevel@tonic-gate * Used to readjust the htable reserve after the reserve list has been used. 2107c478bd9Sstevel@tonic-gate * Also called after boot to release left over boot reserves. 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate extern void htable_adjust_reserve(void); 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate /* 215843e1988Sjohnlev * return number of bytes mapped by all the htables in a given hat 216843e1988Sjohnlev */ 217843e1988Sjohnlev extern size_t htable_mapped(struct hat *); 218843e1988Sjohnlev 219843e1988Sjohnlev 220843e1988Sjohnlev /* 221ae115bc7Smrj * Attach initial pagetables as htables 222ae115bc7Smrj */ 223ae115bc7Smrj extern void htable_attach(struct hat *, uintptr_t, level_t, struct htable *, 224ae115bc7Smrj pfn_t); 225ae115bc7Smrj 226ae115bc7Smrj /* 2277c478bd9Sstevel@tonic-gate * Routine to find the next populated htable at or above a given virtual 2287c478bd9Sstevel@tonic-gate * address. Can specify an upper limit, or HTABLE_WALK_TO_END to indicate 2297c478bd9Sstevel@tonic-gate * that it should search the entire address space. Similar to 2307c478bd9Sstevel@tonic-gate * hat_getpte(), but used for walking through address ranges. It can be 2317c478bd9Sstevel@tonic-gate * used like this: 2327c478bd9Sstevel@tonic-gate * 2337c478bd9Sstevel@tonic-gate * va = ... 2347c478bd9Sstevel@tonic-gate * ht = NULL; 2357c478bd9Sstevel@tonic-gate * while (va < end_va) { 2367c478bd9Sstevel@tonic-gate * pte = htable_walk(hat, &ht, &va, end_va); 2377c478bd9Sstevel@tonic-gate * if (!pte) 2387c478bd9Sstevel@tonic-gate * break; 2397c478bd9Sstevel@tonic-gate * 2407c478bd9Sstevel@tonic-gate * ... code to operate on page at va ... 2417c478bd9Sstevel@tonic-gate * 2427c478bd9Sstevel@tonic-gate * va += LEVEL_SIZE(ht->ht_level); 2437c478bd9Sstevel@tonic-gate * } 2447c478bd9Sstevel@tonic-gate * if (ht) 2457c478bd9Sstevel@tonic-gate * htable_release(ht); 2467c478bd9Sstevel@tonic-gate * 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate extern x86pte_t htable_walk(struct hat *hat, htable_t **ht, uintptr_t *va, 2497c478bd9Sstevel@tonic-gate uintptr_t eaddr); 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate #define HTABLE_WALK_TO_END ((uintptr_t)-1) 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* 2547c478bd9Sstevel@tonic-gate * Utilities convert between virtual addresses and page table entry indeces. 2557c478bd9Sstevel@tonic-gate */ 2567c478bd9Sstevel@tonic-gate extern uint_t htable_va2entry(uintptr_t va, htable_t *ht); 2577c478bd9Sstevel@tonic-gate extern uintptr_t htable_e2va(htable_t *ht, uint_t entry); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* 2607c478bd9Sstevel@tonic-gate * Interfaces that provide access to page table entries via the htable. 2617c478bd9Sstevel@tonic-gate * 2627c478bd9Sstevel@tonic-gate * Note that all accesses except x86pte_copy() and x86pte_zero() are atomic. 2637c478bd9Sstevel@tonic-gate */ 264ae115bc7Smrj extern void x86pte_cpu_init(cpu_t *); 265ae115bc7Smrj extern void x86pte_cpu_fini(cpu_t *); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate extern x86pte_t x86pte_get(htable_t *, uint_t entry); 2687c478bd9Sstevel@tonic-gate 269ae115bc7Smrj /* 270ae115bc7Smrj * x86pte_set returns LPAGE_ERROR if it's asked to overwrite a page table 271ae115bc7Smrj * link with a large page mapping. 272ae115bc7Smrj */ 273ae115bc7Smrj #define LPAGE_ERROR (-(x86pte_t)1) 2747c478bd9Sstevel@tonic-gate extern x86pte_t x86pte_set(htable_t *, uint_t entry, x86pte_t new, void *); 2757c478bd9Sstevel@tonic-gate 276ae115bc7Smrj extern x86pte_t x86pte_inval(htable_t *ht, uint_t entry, 277*a6a74e0eSMatthew Ahrens x86pte_t old, x86pte_t *ptr, boolean_t tlb); 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate extern x86pte_t x86pte_update(htable_t *ht, uint_t entry, 2807c478bd9Sstevel@tonic-gate x86pte_t old, x86pte_t new); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate extern void x86pte_copy(htable_t *src, htable_t *dest, uint_t entry, 2837c478bd9Sstevel@tonic-gate uint_t cnt); 2847c478bd9Sstevel@tonic-gate 285ae115bc7Smrj /* 286ae115bc7Smrj * access to a pagetable knowing only the pfn 287ae115bc7Smrj */ 288ae115bc7Smrj extern x86pte_t *x86pte_mapin(pfn_t, uint_t, htable_t *); 289ae115bc7Smrj extern void x86pte_mapout(void); 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate /* 2927c478bd9Sstevel@tonic-gate * these are actually inlines for "lock; incw", "lock; decw", etc. instructions. 2937c478bd9Sstevel@tonic-gate */ 2947c478bd9Sstevel@tonic-gate #define HTABLE_INC(x) atomic_inc16((uint16_t *)&x) 2957c478bd9Sstevel@tonic-gate #define HTABLE_DEC(x) atomic_dec16((uint16_t *)&x) 2961a5e258fSJosef 'Jeff' Sipek #define HTABLE_LOCK_INC(ht) atomic_inc_32(&(ht)->ht_lock_cnt) 2971a5e258fSJosef 'Jeff' Sipek #define HTABLE_LOCK_DEC(ht) atomic_dec_32(&(ht)->ht_lock_cnt) 2987c478bd9Sstevel@tonic-gate 299843e1988Sjohnlev #ifdef __xpv 300843e1988Sjohnlev extern void xen_flush_va(caddr_t va); 301843e1988Sjohnlev extern void xen_gflush_va(caddr_t va, cpuset_t); 302843e1988Sjohnlev extern void xen_flush_tlb(void); 303843e1988Sjohnlev extern void xen_gflush_tlb(cpuset_t); 304843e1988Sjohnlev extern void xen_pin(pfn_t, level_t); 305843e1988Sjohnlev extern void xen_unpin(pfn_t); 306843e1988Sjohnlev extern int xen_kpm_page(pfn_t, uint_t); 307843e1988Sjohnlev 308843e1988Sjohnlev /* 309843e1988Sjohnlev * The hypervisor maps all page tables into our address space read-only. 310843e1988Sjohnlev * Under normal circumstances, the hypervisor then handles all updates to 311843e1988Sjohnlev * the page tables underneath the covers for us. However, when we are 312843e1988Sjohnlev * trying to dump core after a hypervisor panic, the hypervisor is no 313843e1988Sjohnlev * longer available to do these updates. To work around the protection 314843e1988Sjohnlev * problem, we simply disable write-protect checking for the duration of a 315843e1988Sjohnlev * pagetable update operation. 316843e1988Sjohnlev */ 317843e1988Sjohnlev #define XPV_ALLOW_PAGETABLE_UPDATES() \ 318843e1988Sjohnlev { \ 319843e1988Sjohnlev if (IN_XPV_PANIC()) \ 320843e1988Sjohnlev setcr0((getcr0() & ~CR0_WP) & 0xffffffff); \ 321843e1988Sjohnlev } 322843e1988Sjohnlev #define XPV_DISALLOW_PAGETABLE_UPDATES() \ 323843e1988Sjohnlev { \ 324843e1988Sjohnlev if (IN_XPV_PANIC() > 0) \ 325843e1988Sjohnlev setcr0((getcr0() | CR0_WP) & 0xffffffff); \ 326843e1988Sjohnlev } 327843e1988Sjohnlev 328843e1988Sjohnlev #else /* __xpv */ 329843e1988Sjohnlev 330843e1988Sjohnlev #define XPV_ALLOW_PAGETABLE_UPDATES() 331843e1988Sjohnlev #define XPV_DISALLOW_PAGETABLE_UPDATES() 332843e1988Sjohnlev 333843e1988Sjohnlev #endif 334843e1988Sjohnlev 3357c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate #endif 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate #endif /* _VM_HTABLE_H */ 343