spte.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #ifndef KVM_X86_MMU_SPTE_H
  3. #define KVM_X86_MMU_SPTE_H
  4. #include "mmu_internal.h"
  5. /*
  6. * A MMU present SPTE is backed by actual memory and may or may not be present
  7. * in hardware. E.g. MMIO SPTEs are not considered present. Use bit 11, as it
  8. * is ignored by all flavors of SPTEs and checking a low bit often generates
  9. * better code than for a high bit, e.g. 56+. MMU present checks are pervasive
  10. * enough that the improved code generation is noticeable in KVM's footprint.
  11. */
  12. #define SPTE_MMU_PRESENT_MASK BIT_ULL(11)
  13. /*
  14. * TDP SPTES (more specifically, EPT SPTEs) may not have A/D bits, and may also
  15. * be restricted to using write-protection (for L2 when CPU dirty logging, i.e.
  16. * PML, is enabled). Use bits 52 and 53 to hold the type of A/D tracking that
  17. * is must be employed for a given TDP SPTE.
  18. *
  19. * Note, the "enabled" mask must be '0', as bits 62:52 are _reserved_ for PAE
  20. * paging, including NPT PAE. This scheme works because legacy shadow paging
  21. * is guaranteed to have A/D bits and write-protection is forced only for
  22. * TDP with CPU dirty logging (PML). If NPT ever gains PML-like support, it
  23. * must be restricted to 64-bit KVM.
  24. */
  25. #define SPTE_TDP_AD_SHIFT 52
  26. #define SPTE_TDP_AD_MASK (3ULL << SPTE_TDP_AD_SHIFT)
  27. #define SPTE_TDP_AD_ENABLED_MASK (0ULL << SPTE_TDP_AD_SHIFT)
  28. #define SPTE_TDP_AD_DISABLED_MASK (1ULL << SPTE_TDP_AD_SHIFT)
  29. #define SPTE_TDP_AD_WRPROT_ONLY_MASK (2ULL << SPTE_TDP_AD_SHIFT)
  30. static_assert(SPTE_TDP_AD_ENABLED_MASK == 0);
  31. #ifdef CONFIG_DYNAMIC_PHYSICAL_MASK
  32. #define SPTE_BASE_ADDR_MASK (physical_mask & ~(u64)(PAGE_SIZE-1))
  33. #else
  34. #define SPTE_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1))
  35. #endif
  36. #define SPTE_PERM_MASK (PT_PRESENT_MASK | PT_WRITABLE_MASK | shadow_user_mask \
  37. | shadow_x_mask | shadow_nx_mask | shadow_me_mask)
  38. #define ACC_EXEC_MASK 1
  39. #define ACC_WRITE_MASK PT_WRITABLE_MASK
  40. #define ACC_USER_MASK PT_USER_MASK
  41. #define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK)
  42. /* The mask for the R/X bits in EPT PTEs */
  43. #define SPTE_EPT_READABLE_MASK 0x1ull
  44. #define SPTE_EPT_EXECUTABLE_MASK 0x4ull
  45. #define SPTE_LEVEL_BITS 9
  46. #define SPTE_LEVEL_SHIFT(level) __PT_LEVEL_SHIFT(level, SPTE_LEVEL_BITS)
  47. #define SPTE_INDEX(address, level) __PT_INDEX(address, level, SPTE_LEVEL_BITS)
  48. #define SPTE_ENT_PER_PAGE __PT_ENT_PER_PAGE(SPTE_LEVEL_BITS)
  49. /*
  50. * The mask/shift to use for saving the original R/X bits when marking the PTE
  51. * as not-present for access tracking purposes. We do not save the W bit as the
  52. * PTEs being access tracked also need to be dirty tracked, so the W bit will be
  53. * restored only when a write is attempted to the page. This mask obviously
  54. * must not overlap the A/D type mask.
  55. */
  56. #define SHADOW_ACC_TRACK_SAVED_BITS_MASK (SPTE_EPT_READABLE_MASK | \
  57. SPTE_EPT_EXECUTABLE_MASK)
  58. #define SHADOW_ACC_TRACK_SAVED_BITS_SHIFT 54
  59. #define SHADOW_ACC_TRACK_SAVED_MASK (SHADOW_ACC_TRACK_SAVED_BITS_MASK << \
  60. SHADOW_ACC_TRACK_SAVED_BITS_SHIFT)
  61. static_assert(!(SPTE_TDP_AD_MASK & SHADOW_ACC_TRACK_SAVED_MASK));
  62. /*
  63. * {DEFAULT,EPT}_SPTE_{HOST,MMU}_WRITABLE are used to keep track of why a given
  64. * SPTE is write-protected. See is_writable_pte() for details.
  65. */
  66. /* Bits 9 and 10 are ignored by all non-EPT PTEs. */
  67. #define DEFAULT_SPTE_HOST_WRITABLE BIT_ULL(9)
  68. #define DEFAULT_SPTE_MMU_WRITABLE BIT_ULL(10)
  69. /*
  70. * Low ignored bits are at a premium for EPT, use high ignored bits, taking care
  71. * to not overlap the A/D type mask or the saved access bits of access-tracked
  72. * SPTEs when A/D bits are disabled.
  73. */
  74. #define EPT_SPTE_HOST_WRITABLE BIT_ULL(57)
  75. #define EPT_SPTE_MMU_WRITABLE BIT_ULL(58)
  76. static_assert(!(EPT_SPTE_HOST_WRITABLE & SPTE_TDP_AD_MASK));
  77. static_assert(!(EPT_SPTE_MMU_WRITABLE & SPTE_TDP_AD_MASK));
  78. static_assert(!(EPT_SPTE_HOST_WRITABLE & SHADOW_ACC_TRACK_SAVED_MASK));
  79. static_assert(!(EPT_SPTE_MMU_WRITABLE & SHADOW_ACC_TRACK_SAVED_MASK));
  80. /* Defined only to keep the above static asserts readable. */
  81. #undef SHADOW_ACC_TRACK_SAVED_MASK
  82. /*
  83. * Due to limited space in PTEs, the MMIO generation is a 19 bit subset of
  84. * the memslots generation and is derived as follows:
  85. *
  86. * Bits 0-7 of the MMIO generation are propagated to spte bits 3-10
  87. * Bits 8-18 of the MMIO generation are propagated to spte bits 52-62
  88. *
  89. * The KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS flag is intentionally not included in
  90. * the MMIO generation number, as doing so would require stealing a bit from
  91. * the "real" generation number and thus effectively halve the maximum number
  92. * of MMIO generations that can be handled before encountering a wrap (which
  93. * requires a full MMU zap). The flag is instead explicitly queried when
  94. * checking for MMIO spte cache hits.
  95. */
  96. #define MMIO_SPTE_GEN_LOW_START 3
  97. #define MMIO_SPTE_GEN_LOW_END 10
  98. #define MMIO_SPTE_GEN_HIGH_START 52
  99. #define MMIO_SPTE_GEN_HIGH_END 62
  100. #define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \
  101. MMIO_SPTE_GEN_LOW_START)
  102. #define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \
  103. MMIO_SPTE_GEN_HIGH_START)
  104. static_assert(!(SPTE_MMU_PRESENT_MASK &
  105. (MMIO_SPTE_GEN_LOW_MASK | MMIO_SPTE_GEN_HIGH_MASK)));
  106. /*
  107. * The SPTE MMIO mask must NOT overlap the MMIO generation bits or the
  108. * MMU-present bit. The generation obviously co-exists with the magic MMIO
  109. * mask/value, and MMIO SPTEs are considered !MMU-present.
  110. *
  111. * The SPTE MMIO mask is allowed to use hardware "present" bits (i.e. all EPT
  112. * RWX bits), all physical address bits (legal PA bits are used for "fast" MMIO
  113. * and so they're off-limits for generation; additional checks ensure the mask
  114. * doesn't overlap legal PA bits), and bit 63 (carved out for future usage).
  115. */
  116. #define SPTE_MMIO_ALLOWED_MASK (BIT_ULL(63) | GENMASK_ULL(51, 12) | GENMASK_ULL(2, 0))
  117. static_assert(!(SPTE_MMIO_ALLOWED_MASK &
  118. (SPTE_MMU_PRESENT_MASK | MMIO_SPTE_GEN_LOW_MASK | MMIO_SPTE_GEN_HIGH_MASK)));
  119. #define MMIO_SPTE_GEN_LOW_BITS (MMIO_SPTE_GEN_LOW_END - MMIO_SPTE_GEN_LOW_START + 1)
  120. #define MMIO_SPTE_GEN_HIGH_BITS (MMIO_SPTE_GEN_HIGH_END - MMIO_SPTE_GEN_HIGH_START + 1)
  121. /* remember to adjust the comment above as well if you change these */
  122. static_assert(MMIO_SPTE_GEN_LOW_BITS == 8 && MMIO_SPTE_GEN_HIGH_BITS == 11);
  123. #define MMIO_SPTE_GEN_LOW_SHIFT (MMIO_SPTE_GEN_LOW_START - 0)
  124. #define MMIO_SPTE_GEN_HIGH_SHIFT (MMIO_SPTE_GEN_HIGH_START - MMIO_SPTE_GEN_LOW_BITS)
  125. #define MMIO_SPTE_GEN_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_BITS + MMIO_SPTE_GEN_HIGH_BITS - 1, 0)
  126. extern u64 __read_mostly shadow_host_writable_mask;
  127. extern u64 __read_mostly shadow_mmu_writable_mask;
  128. extern u64 __read_mostly shadow_nx_mask;
  129. extern u64 __read_mostly shadow_x_mask; /* mutual exclusive with nx_mask */
  130. extern u64 __read_mostly shadow_user_mask;
  131. extern u64 __read_mostly shadow_accessed_mask;
  132. extern u64 __read_mostly shadow_dirty_mask;
  133. extern u64 __read_mostly shadow_mmio_value;
  134. extern u64 __read_mostly shadow_mmio_mask;
  135. extern u64 __read_mostly shadow_mmio_access_mask;
  136. extern u64 __read_mostly shadow_present_mask;
  137. extern u64 __read_mostly shadow_memtype_mask;
  138. extern u64 __read_mostly shadow_me_value;
  139. extern u64 __read_mostly shadow_me_mask;
  140. /*
  141. * SPTEs in MMUs without A/D bits are marked with SPTE_TDP_AD_DISABLED_MASK;
  142. * shadow_acc_track_mask is the set of bits to be cleared in non-accessed
  143. * pages.
  144. */
  145. extern u64 __read_mostly shadow_acc_track_mask;
  146. /*
  147. * This mask must be set on all non-zero Non-Present or Reserved SPTEs in order
  148. * to guard against L1TF attacks.
  149. */
  150. extern u64 __read_mostly shadow_nonpresent_or_rsvd_mask;
  151. /*
  152. * The number of high-order 1 bits to use in the mask above.
  153. */
  154. #define SHADOW_NONPRESENT_OR_RSVD_MASK_LEN 5
  155. /*
  156. * If a thread running without exclusive control of the MMU lock must perform a
  157. * multi-part operation on an SPTE, it can set the SPTE to REMOVED_SPTE as a
  158. * non-present intermediate value. Other threads which encounter this value
  159. * should not modify the SPTE.
  160. *
  161. * Use a semi-arbitrary value that doesn't set RWX bits, i.e. is not-present on
  162. * bot AMD and Intel CPUs, and doesn't set PFN bits, i.e. doesn't create a L1TF
  163. * vulnerability. Use only low bits to avoid 64-bit immediates.
  164. *
  165. * Only used by the TDP MMU.
  166. */
  167. #define REMOVED_SPTE 0x5a0ULL
  168. /* Removed SPTEs must not be misconstrued as shadow present PTEs. */
  169. static_assert(!(REMOVED_SPTE & SPTE_MMU_PRESENT_MASK));
  170. static inline bool is_removed_spte(u64 spte)
  171. {
  172. return spte == REMOVED_SPTE;
  173. }
  174. /* Get an SPTE's index into its parent's page table (and the spt array). */
  175. static inline int spte_index(u64 *sptep)
  176. {
  177. return ((unsigned long)sptep / sizeof(*sptep)) & (SPTE_ENT_PER_PAGE - 1);
  178. }
  179. /*
  180. * In some cases, we need to preserve the GFN of a non-present or reserved
  181. * SPTE when we usurp the upper five bits of the physical address space to
  182. * defend against L1TF, e.g. for MMIO SPTEs. To preserve the GFN, we'll
  183. * shift bits of the GFN that overlap with shadow_nonpresent_or_rsvd_mask
  184. * left into the reserved bits, i.e. the GFN in the SPTE will be split into
  185. * high and low parts. This mask covers the lower bits of the GFN.
  186. */
  187. extern u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask;
  188. static inline bool is_mmio_spte(u64 spte)
  189. {
  190. return (spte & shadow_mmio_mask) == shadow_mmio_value &&
  191. likely(enable_mmio_caching);
  192. }
  193. static inline bool is_shadow_present_pte(u64 pte)
  194. {
  195. return !!(pte & SPTE_MMU_PRESENT_MASK);
  196. }
  197. /*
  198. * Returns true if A/D bits are supported in hardware and are enabled by KVM.
  199. * When enabled, KVM uses A/D bits for all non-nested MMUs. Because L1 can
  200. * disable A/D bits in EPTP12, SP and SPTE variants are needed to handle the
  201. * scenario where KVM is using A/D bits for L1, but not L2.
  202. */
  203. static inline bool kvm_ad_enabled(void)
  204. {
  205. return !!shadow_accessed_mask;
  206. }
  207. static inline bool sp_ad_disabled(struct kvm_mmu_page *sp)
  208. {
  209. return sp->role.ad_disabled;
  210. }
  211. static inline bool spte_ad_enabled(u64 spte)
  212. {
  213. MMU_WARN_ON(!is_shadow_present_pte(spte));
  214. return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_DISABLED_MASK;
  215. }
  216. static inline bool spte_ad_need_write_protect(u64 spte)
  217. {
  218. MMU_WARN_ON(!is_shadow_present_pte(spte));
  219. /*
  220. * This is benign for non-TDP SPTEs as SPTE_TDP_AD_ENABLED_MASK is '0',
  221. * and non-TDP SPTEs will never set these bits. Optimize for 64-bit
  222. * TDP and do the A/D type check unconditionally.
  223. */
  224. return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_ENABLED_MASK;
  225. }
  226. static inline u64 spte_shadow_accessed_mask(u64 spte)
  227. {
  228. MMU_WARN_ON(!is_shadow_present_pte(spte));
  229. return spte_ad_enabled(spte) ? shadow_accessed_mask : 0;
  230. }
  231. static inline u64 spte_shadow_dirty_mask(u64 spte)
  232. {
  233. MMU_WARN_ON(!is_shadow_present_pte(spte));
  234. return spte_ad_enabled(spte) ? shadow_dirty_mask : 0;
  235. }
  236. static inline bool is_access_track_spte(u64 spte)
  237. {
  238. return !spte_ad_enabled(spte) && (spte & shadow_acc_track_mask) == 0;
  239. }
  240. static inline bool is_large_pte(u64 pte)
  241. {
  242. return pte & PT_PAGE_SIZE_MASK;
  243. }
  244. static inline bool is_last_spte(u64 pte, int level)
  245. {
  246. return (level == PG_LEVEL_4K) || is_large_pte(pte);
  247. }
  248. static inline bool is_executable_pte(u64 spte)
  249. {
  250. return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask;
  251. }
  252. static inline kvm_pfn_t spte_to_pfn(u64 pte)
  253. {
  254. return (pte & SPTE_BASE_ADDR_MASK) >> PAGE_SHIFT;
  255. }
  256. static inline bool is_accessed_spte(u64 spte)
  257. {
  258. u64 accessed_mask = spte_shadow_accessed_mask(spte);
  259. return accessed_mask ? spte & accessed_mask
  260. : !is_access_track_spte(spte);
  261. }
  262. static inline bool is_dirty_spte(u64 spte)
  263. {
  264. u64 dirty_mask = spte_shadow_dirty_mask(spte);
  265. return dirty_mask ? spte & dirty_mask : spte & PT_WRITABLE_MASK;
  266. }
  267. static inline u64 get_rsvd_bits(struct rsvd_bits_validate *rsvd_check, u64 pte,
  268. int level)
  269. {
  270. int bit7 = (pte >> 7) & 1;
  271. return rsvd_check->rsvd_bits_mask[bit7][level-1];
  272. }
  273. static inline bool __is_rsvd_bits_set(struct rsvd_bits_validate *rsvd_check,
  274. u64 pte, int level)
  275. {
  276. return pte & get_rsvd_bits(rsvd_check, pte, level);
  277. }
  278. static inline bool __is_bad_mt_xwr(struct rsvd_bits_validate *rsvd_check,
  279. u64 pte)
  280. {
  281. return rsvd_check->bad_mt_xwr & BIT_ULL(pte & 0x3f);
  282. }
  283. static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,
  284. u64 spte, int level)
  285. {
  286. return __is_bad_mt_xwr(rsvd_check, spte) ||
  287. __is_rsvd_bits_set(rsvd_check, spte, level);
  288. }
  289. /*
  290. * A shadow-present leaf SPTE may be non-writable for 4 possible reasons:
  291. *
  292. * 1. To intercept writes for dirty logging. KVM write-protects huge pages
  293. * so that they can be split be split down into the dirty logging
  294. * granularity (4KiB) whenever the guest writes to them. KVM also
  295. * write-protects 4KiB pages so that writes can be recorded in the dirty log
  296. * (e.g. if not using PML). SPTEs are write-protected for dirty logging
  297. * during the VM-iotcls that enable dirty logging.
  298. *
  299. * 2. To intercept writes to guest page tables that KVM is shadowing. When a
  300. * guest writes to its page table the corresponding shadow page table will
  301. * be marked "unsync". That way KVM knows which shadow page tables need to
  302. * be updated on the next TLB flush, INVLPG, etc. and which do not.
  303. *
  304. * 3. To prevent guest writes to read-only memory, such as for memory in a
  305. * read-only memslot or guest memory backed by a read-only VMA. Writes to
  306. * such pages are disallowed entirely.
  307. *
  308. * 4. To emulate the Accessed bit for SPTEs without A/D bits. Note, in this
  309. * case, the SPTE is access-protected, not just write-protected!
  310. *
  311. * For cases #1 and #4, KVM can safely make such SPTEs writable without taking
  312. * mmu_lock as capturing the Accessed/Dirty state doesn't require taking it.
  313. * To differentiate #1 and #4 from #2 and #3, KVM uses two software-only bits
  314. * in the SPTE:
  315. *
  316. * shadow_mmu_writable_mask, aka MMU-writable -
  317. * Cleared on SPTEs that KVM is currently write-protecting for shadow paging
  318. * purposes (case 2 above).
  319. *
  320. * shadow_host_writable_mask, aka Host-writable -
  321. * Cleared on SPTEs that are not host-writable (case 3 above)
  322. *
  323. * Note, not all possible combinations of PT_WRITABLE_MASK,
  324. * shadow_mmu_writable_mask, and shadow_host_writable_mask are valid. A given
  325. * SPTE can be in only one of the following states, which map to the
  326. * aforementioned 3 cases:
  327. *
  328. * shadow_host_writable_mask | shadow_mmu_writable_mask | PT_WRITABLE_MASK
  329. * ------------------------- | ------------------------ | ----------------
  330. * 1 | 1 | 1 (writable)
  331. * 1 | 1 | 0 (case 1)
  332. * 1 | 0 | 0 (case 2)
  333. * 0 | 0 | 0 (case 3)
  334. *
  335. * The valid combinations of these bits are checked by
  336. * check_spte_writable_invariants() whenever an SPTE is modified.
  337. *
  338. * Clearing the MMU-writable bit is always done under the MMU lock and always
  339. * accompanied by a TLB flush before dropping the lock to avoid corrupting the
  340. * shadow page tables between vCPUs. Write-protecting an SPTE for dirty logging
  341. * (which does not clear the MMU-writable bit), does not flush TLBs before
  342. * dropping the lock, as it only needs to synchronize guest writes with the
  343. * dirty bitmap. Similarly, making the SPTE inaccessible (and non-writable) for
  344. * access-tracking via the clear_young() MMU notifier also does not flush TLBs.
  345. *
  346. * So, there is the problem: clearing the MMU-writable bit can encounter a
  347. * write-protected SPTE while CPUs still have writable mappings for that SPTE
  348. * cached in their TLB. To address this, KVM always flushes TLBs when
  349. * write-protecting SPTEs if the MMU-writable bit is set on the old SPTE.
  350. *
  351. * The Host-writable bit is not modified on present SPTEs, it is only set or
  352. * cleared when an SPTE is first faulted in from non-present and then remains
  353. * immutable.
  354. */
  355. static inline bool is_writable_pte(unsigned long pte)
  356. {
  357. return pte & PT_WRITABLE_MASK;
  358. }
  359. /* Note: spte must be a shadow-present leaf SPTE. */
  360. static inline void check_spte_writable_invariants(u64 spte)
  361. {
  362. if (spte & shadow_mmu_writable_mask)
  363. WARN_ONCE(!(spte & shadow_host_writable_mask),
  364. "kvm: MMU-writable SPTE is not Host-writable: %llx",
  365. spte);
  366. else
  367. WARN_ONCE(is_writable_pte(spte),
  368. "kvm: Writable SPTE is not MMU-writable: %llx", spte);
  369. }
  370. static inline bool is_mmu_writable_spte(u64 spte)
  371. {
  372. return spte & shadow_mmu_writable_mask;
  373. }
  374. static inline u64 get_mmio_spte_generation(u64 spte)
  375. {
  376. u64 gen;
  377. gen = (spte & MMIO_SPTE_GEN_LOW_MASK) >> MMIO_SPTE_GEN_LOW_SHIFT;
  378. gen |= (spte & MMIO_SPTE_GEN_HIGH_MASK) >> MMIO_SPTE_GEN_HIGH_SHIFT;
  379. return gen;
  380. }
  381. bool spte_has_volatile_bits(u64 spte);
  382. bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
  383. const struct kvm_memory_slot *slot,
  384. unsigned int pte_access, gfn_t gfn, kvm_pfn_t pfn,
  385. u64 old_spte, bool prefetch, bool can_unsync,
  386. bool host_writable, u64 *new_spte);
  387. u64 make_huge_page_split_spte(struct kvm *kvm, u64 huge_spte,
  388. union kvm_mmu_page_role role, int index);
  389. u64 make_nonleaf_spte(u64 *child_pt, bool ad_disabled);
  390. u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access);
  391. u64 mark_spte_for_access_track(u64 spte);
  392. /* Restore an acc-track PTE back to a regular PTE */
  393. static inline u64 restore_acc_track_spte(u64 spte)
  394. {
  395. u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT)
  396. & SHADOW_ACC_TRACK_SAVED_BITS_MASK;
  397. spte &= ~shadow_acc_track_mask;
  398. spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK <<
  399. SHADOW_ACC_TRACK_SAVED_BITS_SHIFT);
  400. spte |= saved_bits;
  401. return spte;
  402. }
  403. u64 kvm_mmu_changed_pte_notifier_make_spte(u64 old_spte, kvm_pfn_t new_pfn);
  404. void __init kvm_mmu_spte_module_init(void);
  405. void kvm_mmu_reset_all_pte_masks(void);
  406. #endif