mmu.h 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef __KVM_X86_MMU_H
  2. #define __KVM_X86_MMU_H
  3. #include <linux/kvm_host.h>
  4. #ifdef CONFIG_X86_64
  5. #define TDP_ROOT_LEVEL PT64_ROOT_LEVEL
  6. #else
  7. #define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL
  8. #endif
  9. static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
  10. {
  11. if (unlikely(vcpu->kvm->arch.n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES))
  12. __kvm_mmu_free_some_pages(vcpu);
  13. }
  14. static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu)
  15. {
  16. if (likely(vcpu->arch.mmu.root_hpa != INVALID_PAGE))
  17. return 0;
  18. return kvm_mmu_load(vcpu);
  19. }
  20. static inline int is_long_mode(struct kvm_vcpu *vcpu)
  21. {
  22. #ifdef CONFIG_X86_64
  23. return vcpu->arch.shadow_efer & EFER_LME;
  24. #else
  25. return 0;
  26. #endif
  27. }
  28. static inline int is_pae(struct kvm_vcpu *vcpu)
  29. {
  30. return vcpu->arch.cr4 & X86_CR4_PAE;
  31. }
  32. static inline int is_pse(struct kvm_vcpu *vcpu)
  33. {
  34. return vcpu->arch.cr4 & X86_CR4_PSE;
  35. }
  36. static inline int is_paging(struct kvm_vcpu *vcpu)
  37. {
  38. return vcpu->arch.cr0 & X86_CR0_PG;
  39. }
  40. #endif