mmu.h 843 B

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