// SPDX-License-Identifier: GPL-2.0-only12#ifndef KVM_X86_MMU_SPTE_H3#define KVM_X86_MMU_SPTE_H45#include <asm/vmx.h>67#include "mmu.h"8#include "mmu_internal.h"910/*11* A MMU present SPTE is backed by actual memory and may or may not be present12* in hardware. E.g. MMIO SPTEs are not considered present. Use bit 11, as it13* is ignored by all flavors of SPTEs and checking a low bit often generates14* better code than for a high bit, e.g. 56+. MMU present checks are pervasive15* enough that the improved code generation is noticeable in KVM's footprint.16*/17#define SPTE_MMU_PRESENT_MASK BIT_ULL(11)1819/*20* TDP SPTES (more specifically, EPT SPTEs) may not have A/D bits, and may also21* be restricted to using write-protection (for L2 when CPU dirty logging, i.e.22* PML, is enabled). Use bits 52 and 53 to hold the type of A/D tracking that23* is must be employed for a given TDP SPTE.24*25* Note, the "enabled" mask must be '0', as bits 62:52 are _reserved_ for PAE26* paging, including NPT PAE. This scheme works because legacy shadow paging27* is guaranteed to have A/D bits and write-protection is forced only for28* TDP with CPU dirty logging (PML). If NPT ever gains PML-like support, it29* must be restricted to 64-bit KVM.30*/31#define SPTE_TDP_AD_SHIFT 5232#define SPTE_TDP_AD_MASK (3ULL << SPTE_TDP_AD_SHIFT)33#define SPTE_TDP_AD_ENABLED (0ULL << SPTE_TDP_AD_SHIFT)34#define SPTE_TDP_AD_DISABLED (1ULL << SPTE_TDP_AD_SHIFT)35#define SPTE_TDP_AD_WRPROT_ONLY (2ULL << SPTE_TDP_AD_SHIFT)36static_assert(SPTE_TDP_AD_ENABLED == 0);3738#ifdef CONFIG_DYNAMIC_PHYSICAL_MASK39#define SPTE_BASE_ADDR_MASK (physical_mask & ~(u64)(PAGE_SIZE-1))40#else41#define SPTE_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1))42#endif4344#define SPTE_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \45| shadow_x_mask | shadow_nx_mask | shadow_me_mask)4647#define ACC_EXEC_MASK 148#define ACC_WRITE_MASK PT_WRITABLE_MASK49#define ACC_USER_MASK PT_USER_MASK50#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK)5152/* The mask for the R/X bits in EPT PTEs */53#define SPTE_EPT_READABLE_MASK 0x1ull54#define SPTE_EPT_EXECUTABLE_MASK 0x4ull5556#define SPTE_LEVEL_BITS 957#define SPTE_LEVEL_SHIFT(level) __PT_LEVEL_SHIFT(level, SPTE_LEVEL_BITS)58#define SPTE_INDEX(address, level) __PT_INDEX(address, level, SPTE_LEVEL_BITS)59#define SPTE_ENT_PER_PAGE __PT_ENT_PER_PAGE(SPTE_LEVEL_BITS)6061/*62* The mask/shift to use for saving the original R/X bits when marking the PTE63* as not-present for access tracking purposes. We do not save the W bit as the64* PTEs being access tracked also need to be dirty tracked, so the W bit will be65* restored only when a write is attempted to the page. This mask obviously66* must not overlap the A/D type mask.67*/68#define SHADOW_ACC_TRACK_SAVED_BITS_MASK (SPTE_EPT_READABLE_MASK | \69SPTE_EPT_EXECUTABLE_MASK)70#define SHADOW_ACC_TRACK_SAVED_BITS_SHIFT 5471#define SHADOW_ACC_TRACK_SAVED_MASK (SHADOW_ACC_TRACK_SAVED_BITS_MASK << \72SHADOW_ACC_TRACK_SAVED_BITS_SHIFT)73static_assert(!(SPTE_TDP_AD_MASK & SHADOW_ACC_TRACK_SAVED_MASK));7475/*76* {DEFAULT,EPT}_SPTE_{HOST,MMU}_WRITABLE are used to keep track of why a given77* SPTE is write-protected. See is_writable_pte() for details.78*/7980/* Bits 9 and 10 are ignored by all non-EPT PTEs. */81#define DEFAULT_SPTE_HOST_WRITABLE BIT_ULL(9)82#define DEFAULT_SPTE_MMU_WRITABLE BIT_ULL(10)8384/*85* Low ignored bits are at a premium for EPT, use high ignored bits, taking care86* to not overlap the A/D type mask or the saved access bits of access-tracked87* SPTEs when A/D bits are disabled.88*/89#define EPT_SPTE_HOST_WRITABLE BIT_ULL(57)90#define EPT_SPTE_MMU_WRITABLE BIT_ULL(58)9192static_assert(!(EPT_SPTE_HOST_WRITABLE & SPTE_TDP_AD_MASK));93static_assert(!(EPT_SPTE_MMU_WRITABLE & SPTE_TDP_AD_MASK));94static_assert(!(EPT_SPTE_HOST_WRITABLE & SHADOW_ACC_TRACK_SAVED_MASK));95static_assert(!(EPT_SPTE_MMU_WRITABLE & SHADOW_ACC_TRACK_SAVED_MASK));9697/* Defined only to keep the above static asserts readable. */98#undef SHADOW_ACC_TRACK_SAVED_MASK99100/*101* Due to limited space in PTEs, the MMIO generation is a 19 bit subset of102* the memslots generation and is derived as follows:103*104* Bits 0-7 of the MMIO generation are propagated to spte bits 3-10105* Bits 8-18 of the MMIO generation are propagated to spte bits 52-62106*107* The KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS flag is intentionally not included in108* the MMIO generation number, as doing so would require stealing a bit from109* the "real" generation number and thus effectively halve the maximum number110* of MMIO generations that can be handled before encountering a wrap (which111* requires a full MMU zap). The flag is instead explicitly queried when112* checking for MMIO spte cache hits.113*/114115#define MMIO_SPTE_GEN_LOW_START 3116#define MMIO_SPTE_GEN_LOW_END 10117118#define MMIO_SPTE_GEN_HIGH_START 52119#define MMIO_SPTE_GEN_HIGH_END 62120121#define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \122MMIO_SPTE_GEN_LOW_START)123#define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \124MMIO_SPTE_GEN_HIGH_START)125static_assert(!(SPTE_MMU_PRESENT_MASK &126(MMIO_SPTE_GEN_LOW_MASK | MMIO_SPTE_GEN_HIGH_MASK)));127128/*129* The SPTE MMIO mask must NOT overlap the MMIO generation bits or the130* MMU-present bit. The generation obviously co-exists with the magic MMIO131* mask/value, and MMIO SPTEs are considered !MMU-present.132*133* The SPTE MMIO mask is allowed to use hardware "present" bits (i.e. all EPT134* RWX bits), all physical address bits (legal PA bits are used for "fast" MMIO135* and so they're off-limits for generation; additional checks ensure the mask136* doesn't overlap legal PA bits), and bit 63 (carved out for future usage).137*/138#define SPTE_MMIO_ALLOWED_MASK (BIT_ULL(63) | GENMASK_ULL(51, 12) | GENMASK_ULL(2, 0))139static_assert(!(SPTE_MMIO_ALLOWED_MASK &140(SPTE_MMU_PRESENT_MASK | MMIO_SPTE_GEN_LOW_MASK | MMIO_SPTE_GEN_HIGH_MASK)));141142#define MMIO_SPTE_GEN_LOW_BITS (MMIO_SPTE_GEN_LOW_END - MMIO_SPTE_GEN_LOW_START + 1)143#define MMIO_SPTE_GEN_HIGH_BITS (MMIO_SPTE_GEN_HIGH_END - MMIO_SPTE_GEN_HIGH_START + 1)144145/* remember to adjust the comment above as well if you change these */146static_assert(MMIO_SPTE_GEN_LOW_BITS == 8 && MMIO_SPTE_GEN_HIGH_BITS == 11);147148#define MMIO_SPTE_GEN_LOW_SHIFT (MMIO_SPTE_GEN_LOW_START - 0)149#define MMIO_SPTE_GEN_HIGH_SHIFT (MMIO_SPTE_GEN_HIGH_START - MMIO_SPTE_GEN_LOW_BITS)150151#define MMIO_SPTE_GEN_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_BITS + MMIO_SPTE_GEN_HIGH_BITS - 1, 0)152153/*154* Non-present SPTE value needs to set bit 63 for TDX, in order to suppress155* #VE and get EPT violations on non-present PTEs. We can use the156* same value also without TDX for both VMX and SVM:157*158* For SVM NPT, for non-present spte (bit 0 = 0), other bits are ignored.159* For VMX EPT, bit 63 is ignored if #VE is disabled. (EPT_VIOLATION_VE=0)160* bit 63 is #VE suppress if #VE is enabled. (EPT_VIOLATION_VE=1)161*/162#ifdef CONFIG_X86_64163#define SHADOW_NONPRESENT_VALUE BIT_ULL(63)164static_assert(!(SHADOW_NONPRESENT_VALUE & SPTE_MMU_PRESENT_MASK));165#else166#define SHADOW_NONPRESENT_VALUE 0ULL167#endif168169170/*171* True if A/D bits are supported in hardware and are enabled by KVM. When172* enabled, KVM uses A/D bits for all non-nested MMUs. Because L1 can disable173* A/D bits in EPTP12, SP and SPTE variants are needed to handle the scenario174* where KVM is using A/D bits for L1, but not L2.175*/176extern bool __read_mostly kvm_ad_enabled;177178extern u64 __read_mostly shadow_host_writable_mask;179extern u64 __read_mostly shadow_mmu_writable_mask;180extern u64 __read_mostly shadow_nx_mask;181extern u64 __read_mostly shadow_x_mask; /* mutual exclusive with nx_mask */182extern u64 __read_mostly shadow_user_mask;183extern u64 __read_mostly shadow_accessed_mask;184extern u64 __read_mostly shadow_dirty_mask;185extern u64 __read_mostly shadow_mmio_value;186extern u64 __read_mostly shadow_mmio_mask;187extern u64 __read_mostly shadow_mmio_access_mask;188extern u64 __read_mostly shadow_present_mask;189extern u64 __read_mostly shadow_me_value;190extern u64 __read_mostly shadow_me_mask;191192/*193* SPTEs in MMUs without A/D bits are marked with SPTE_TDP_AD_DISABLED;194* shadow_acc_track_mask is the set of bits to be cleared in non-accessed195* pages.196*/197extern u64 __read_mostly shadow_acc_track_mask;198199/*200* This mask must be set on all non-zero Non-Present or Reserved SPTEs in order201* to guard against L1TF attacks.202*/203extern u64 __read_mostly shadow_nonpresent_or_rsvd_mask;204205/*206* The number of high-order 1 bits to use in the mask above.207*/208#define SHADOW_NONPRESENT_OR_RSVD_MASK_LEN 5209210/*211* If a thread running without exclusive control of the MMU lock must perform a212* multi-part operation on an SPTE, it can set the SPTE to FROZEN_SPTE as a213* non-present intermediate value. Other threads which encounter this value214* should not modify the SPTE.215*216* Use a semi-arbitrary value that doesn't set RWX bits, i.e. is not-present on217* both AMD and Intel CPUs, and doesn't set PFN bits, i.e. doesn't create a L1TF218* vulnerability.219*220* Only used by the TDP MMU.221*/222#define FROZEN_SPTE (SHADOW_NONPRESENT_VALUE | 0x5a0ULL)223224/* Frozen SPTEs must not be misconstrued as shadow present PTEs. */225static_assert(!(FROZEN_SPTE & SPTE_MMU_PRESENT_MASK));226227static inline bool is_frozen_spte(u64 spte)228{229return spte == FROZEN_SPTE;230}231232/* Get an SPTE's index into its parent's page table (and the spt array). */233static inline int spte_index(u64 *sptep)234{235return ((unsigned long)sptep / sizeof(*sptep)) & (SPTE_ENT_PER_PAGE - 1);236}237238/*239* In some cases, we need to preserve the GFN of a non-present or reserved240* SPTE when we usurp the upper five bits of the physical address space to241* defend against L1TF, e.g. for MMIO SPTEs. To preserve the GFN, we'll242* shift bits of the GFN that overlap with shadow_nonpresent_or_rsvd_mask243* left into the reserved bits, i.e. the GFN in the SPTE will be split into244* high and low parts. This mask covers the lower bits of the GFN.245*/246extern u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask;247248static inline hpa_t kvm_mmu_get_dummy_root(void)249{250return my_zero_pfn(0) << PAGE_SHIFT;251}252253static inline bool kvm_mmu_is_dummy_root(hpa_t shadow_page)254{255return is_zero_pfn(shadow_page >> PAGE_SHIFT);256}257258static inline struct kvm_mmu_page *to_shadow_page(hpa_t shadow_page)259{260struct page *page = pfn_to_page((shadow_page) >> PAGE_SHIFT);261262return (struct kvm_mmu_page *)page_private(page);263}264265static inline struct kvm_mmu_page *spte_to_child_sp(u64 spte)266{267return to_shadow_page(spte & SPTE_BASE_ADDR_MASK);268}269270static inline struct kvm_mmu_page *sptep_to_sp(u64 *sptep)271{272return to_shadow_page(__pa(sptep));273}274275static inline struct kvm_mmu_page *root_to_sp(hpa_t root)276{277if (kvm_mmu_is_dummy_root(root))278return NULL;279280/*281* The "root" may be a special root, e.g. a PAE entry, treat it as a282* SPTE to ensure any non-PA bits are dropped.283*/284return spte_to_child_sp(root);285}286287static inline bool is_mirror_sptep(tdp_ptep_t sptep)288{289return is_mirror_sp(sptep_to_sp(rcu_dereference(sptep)));290}291292static inline bool kvm_vcpu_can_access_host_mmio(struct kvm_vcpu *vcpu)293{294struct kvm_mmu_page *root = root_to_sp(vcpu->arch.mmu->root.hpa);295296if (root)297return READ_ONCE(root->has_mapped_host_mmio);298299return READ_ONCE(vcpu->kvm->arch.has_mapped_host_mmio);300}301302static inline bool is_mmio_spte(struct kvm *kvm, u64 spte)303{304return (spte & shadow_mmio_mask) == kvm->arch.shadow_mmio_value &&305likely(enable_mmio_caching);306}307308static inline bool is_shadow_present_pte(u64 pte)309{310return !!(pte & SPTE_MMU_PRESENT_MASK);311}312313static inline bool is_ept_ve_possible(u64 spte)314{315return (shadow_present_mask & VMX_EPT_SUPPRESS_VE_BIT) &&316!(spte & VMX_EPT_SUPPRESS_VE_BIT) &&317(spte & VMX_EPT_RWX_MASK) != VMX_EPT_MISCONFIG_WX_VALUE;318}319320static inline bool sp_ad_disabled(struct kvm_mmu_page *sp)321{322return sp->role.ad_disabled;323}324325static inline bool spte_ad_enabled(u64 spte)326{327KVM_MMU_WARN_ON(!is_shadow_present_pte(spte));328return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_DISABLED;329}330331static inline bool spte_ad_need_write_protect(u64 spte)332{333KVM_MMU_WARN_ON(!is_shadow_present_pte(spte));334/*335* This is benign for non-TDP SPTEs as SPTE_TDP_AD_ENABLED is '0',336* and non-TDP SPTEs will never set these bits. Optimize for 64-bit337* TDP and do the A/D type check unconditionally.338*/339return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_ENABLED;340}341342static inline bool is_access_track_spte(u64 spte)343{344return !spte_ad_enabled(spte) && (spte & shadow_acc_track_mask) == 0;345}346347static inline bool is_large_pte(u64 pte)348{349return pte & PT_PAGE_SIZE_MASK;350}351352static inline bool is_last_spte(u64 pte, int level)353{354return (level == PG_LEVEL_4K) || is_large_pte(pte);355}356357static inline bool is_executable_pte(u64 spte)358{359return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask;360}361362static inline kvm_pfn_t spte_to_pfn(u64 pte)363{364return (pte & SPTE_BASE_ADDR_MASK) >> PAGE_SHIFT;365}366367static inline bool is_accessed_spte(u64 spte)368{369return spte & shadow_accessed_mask;370}371372static inline u64 get_rsvd_bits(struct rsvd_bits_validate *rsvd_check, u64 pte,373int level)374{375int bit7 = (pte >> 7) & 1;376377return rsvd_check->rsvd_bits_mask[bit7][level-1];378}379380static inline bool __is_rsvd_bits_set(struct rsvd_bits_validate *rsvd_check,381u64 pte, int level)382{383return pte & get_rsvd_bits(rsvd_check, pte, level);384}385386static inline bool __is_bad_mt_xwr(struct rsvd_bits_validate *rsvd_check,387u64 pte)388{389return rsvd_check->bad_mt_xwr & BIT_ULL(pte & 0x3f);390}391392static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,393u64 spte, int level)394{395return __is_bad_mt_xwr(rsvd_check, spte) ||396__is_rsvd_bits_set(rsvd_check, spte, level);397}398399/*400* A shadow-present leaf SPTE may be non-writable for 4 possible reasons:401*402* 1. To intercept writes for dirty logging. KVM write-protects huge pages403* so that they can be split down into the dirty logging404* granularity (4KiB) whenever the guest writes to them. KVM also405* write-protects 4KiB pages so that writes can be recorded in the dirty log406* (e.g. if not using PML). SPTEs are write-protected for dirty logging407* during the VM-iotcls that enable dirty logging.408*409* 2. To intercept writes to guest page tables that KVM is shadowing. When a410* guest writes to its page table the corresponding shadow page table will411* be marked "unsync". That way KVM knows which shadow page tables need to412* be updated on the next TLB flush, INVLPG, etc. and which do not.413*414* 3. To prevent guest writes to read-only memory, such as for memory in a415* read-only memslot or guest memory backed by a read-only VMA. Writes to416* such pages are disallowed entirely.417*418* 4. To emulate the Accessed bit for SPTEs without A/D bits. Note, in this419* case, the SPTE is access-protected, not just write-protected!420*421* For cases #1 and #4, KVM can safely make such SPTEs writable without taking422* mmu_lock as capturing the Accessed/Dirty state doesn't require taking it.423* To differentiate #1 and #4 from #2 and #3, KVM uses two software-only bits424* in the SPTE:425*426* shadow_mmu_writable_mask, aka MMU-writable -427* Cleared on SPTEs that KVM is currently write-protecting for shadow paging428* purposes (case 2 above).429*430* shadow_host_writable_mask, aka Host-writable -431* Cleared on SPTEs that are not host-writable (case 3 above)432*433* Note, not all possible combinations of PT_WRITABLE_MASK,434* shadow_mmu_writable_mask, and shadow_host_writable_mask are valid. A given435* SPTE can be in only one of the following states, which map to the436* aforementioned 3 cases:437*438* shadow_host_writable_mask | shadow_mmu_writable_mask | PT_WRITABLE_MASK439* ------------------------- | ------------------------ | ----------------440* 1 | 1 | 1 (writable)441* 1 | 1 | 0 (case 1)442* 1 | 0 | 0 (case 2)443* 0 | 0 | 0 (case 3)444*445* The valid combinations of these bits are checked by446* check_spte_writable_invariants() whenever an SPTE is modified.447*448* Clearing the MMU-writable bit is always done under the MMU lock and always449* accompanied by a TLB flush before dropping the lock to avoid corrupting the450* shadow page tables between vCPUs. Write-protecting an SPTE for dirty logging451* (which does not clear the MMU-writable bit), does not flush TLBs before452* dropping the lock, as it only needs to synchronize guest writes with the453* dirty bitmap. Similarly, making the SPTE inaccessible (and non-writable) for454* access-tracking via the clear_young() MMU notifier also does not flush TLBs.455*456* So, there is the problem: clearing the MMU-writable bit can encounter a457* write-protected SPTE while CPUs still have writable mappings for that SPTE458* cached in their TLB. To address this, KVM always flushes TLBs when459* write-protecting SPTEs if the MMU-writable bit is set on the old SPTE.460*461* The Host-writable bit is not modified on present SPTEs, it is only set or462* cleared when an SPTE is first faulted in from non-present and then remains463* immutable.464*/465static inline bool is_writable_pte(unsigned long pte)466{467return pte & PT_WRITABLE_MASK;468}469470/* Note: spte must be a shadow-present leaf SPTE. */471static inline void check_spte_writable_invariants(u64 spte)472{473if (spte & shadow_mmu_writable_mask)474WARN_ONCE(!(spte & shadow_host_writable_mask),475KBUILD_MODNAME ": MMU-writable SPTE is not Host-writable: %llx",476spte);477else478WARN_ONCE(is_writable_pte(spte),479KBUILD_MODNAME ": Writable SPTE is not MMU-writable: %llx", spte);480}481482static inline bool is_mmu_writable_spte(u64 spte)483{484return spte & shadow_mmu_writable_mask;485}486487/*488* Returns true if the access indicated by @fault is allowed by the existing489* SPTE protections. Note, the caller is responsible for checking that the490* SPTE is a shadow-present, leaf SPTE (either before or after).491*/492static inline bool is_access_allowed(struct kvm_page_fault *fault, u64 spte)493{494if (fault->exec)495return is_executable_pte(spte);496497if (fault->write)498return is_writable_pte(spte);499500/* Fault was on Read access */501return spte & PT_PRESENT_MASK;502}503504/*505* If the MMU-writable flag is cleared, i.e. the SPTE is write-protected for506* write-tracking, remote TLBs must be flushed, even if the SPTE was read-only,507* as KVM allows stale Writable TLB entries to exist. When dirty logging, KVM508* flushes TLBs based on whether or not dirty bitmap/ring entries were reaped,509* not whether or not SPTEs were modified, i.e. only the write-tracking case510* needs to flush at the time the SPTEs is modified, before dropping mmu_lock.511*512* Don't flush if the Accessed bit is cleared, as access tracking tolerates513* false negatives, e.g. KVM x86 omits TLB flushes even when aging SPTEs for a514* mmu_notifier.clear_flush_young() event.515*516* Lastly, don't flush if the Dirty bit is cleared, as KVM unconditionally517* flushes when enabling dirty logging (see kvm_mmu_slot_apply_flags()), and518* when clearing dirty logs, KVM flushes based on whether or not dirty entries519* were reaped from the bitmap/ring, not whether or not dirty SPTEs were found.520*521* Note, this logic only applies to shadow-present leaf SPTEs. The caller is522* responsible for checking that the old SPTE is shadow-present, and is also523* responsible for determining whether or not a TLB flush is required when524* modifying a shadow-present non-leaf SPTE.525*/526static inline bool leaf_spte_change_needs_tlb_flush(u64 old_spte, u64 new_spte)527{528return is_mmu_writable_spte(old_spte) && !is_mmu_writable_spte(new_spte);529}530531static inline u64 get_mmio_spte_generation(u64 spte)532{533u64 gen;534535gen = (spte & MMIO_SPTE_GEN_LOW_MASK) >> MMIO_SPTE_GEN_LOW_SHIFT;536gen |= (spte & MMIO_SPTE_GEN_HIGH_MASK) >> MMIO_SPTE_GEN_HIGH_SHIFT;537return gen;538}539540bool spte_needs_atomic_update(u64 spte);541542bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,543const struct kvm_memory_slot *slot,544unsigned int pte_access, gfn_t gfn, kvm_pfn_t pfn,545u64 old_spte, bool prefetch, bool synchronizing,546bool host_writable, u64 *new_spte);547u64 make_small_spte(struct kvm *kvm, u64 huge_spte,548union kvm_mmu_page_role role, int index);549u64 make_huge_spte(struct kvm *kvm, u64 small_spte, int level);550u64 make_nonleaf_spte(u64 *child_pt, bool ad_disabled);551u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access);552u64 mark_spte_for_access_track(u64 spte);553554/* Restore an acc-track PTE back to a regular PTE */555static inline u64 restore_acc_track_spte(u64 spte)556{557u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT)558& SHADOW_ACC_TRACK_SAVED_BITS_MASK;559560spte &= ~shadow_acc_track_mask;561spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK <<562SHADOW_ACC_TRACK_SAVED_BITS_SHIFT);563spte |= saved_bits;564565return spte;566}567568void __init kvm_mmu_spte_module_init(void);569void kvm_mmu_reset_all_pte_masks(void);570571#endif572573574