Zhang Xiantao | 1d737c8 | 2007-12-14 09:35:10 +0800 | [diff] [blame] | 1 | #ifndef __KVM_X86_MMU_H |
| 2 | #define __KVM_X86_MMU_H |
| 3 | |
Avi Kivity | edf8841 | 2007-12-16 11:02:48 +0200 | [diff] [blame] | 4 | #include <linux/kvm_host.h> |
Zhang Xiantao | 1d737c8 | 2007-12-14 09:35:10 +0800 | [diff] [blame] | 5 | |
Joerg Roedel | fb72d16 | 2008-02-07 13:47:44 +0100 | [diff] [blame] | 6 | #ifdef CONFIG_X86_64 |
| 7 | #define TDP_ROOT_LEVEL PT64_ROOT_LEVEL |
| 8 | #else |
| 9 | #define TDP_ROOT_LEVEL PT32E_ROOT_LEVEL |
| 10 | #endif |
| 11 | |
Zhang Xiantao | 1d737c8 | 2007-12-14 09:35:10 +0800 | [diff] [blame] | 12 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) |
| 13 | { |
Zhang Xiantao | f05e70a | 2007-12-14 10:01:48 +0800 | [diff] [blame] | 14 | if (unlikely(vcpu->kvm->arch.n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) |
Zhang Xiantao | 1d737c8 | 2007-12-14 09:35:10 +0800 | [diff] [blame] | 15 | __kvm_mmu_free_some_pages(vcpu); |
| 16 | } |
| 17 | |
| 18 | static inline int kvm_mmu_reload(struct kvm_vcpu *vcpu) |
| 19 | { |
| 20 | if (likely(vcpu->arch.mmu.root_hpa != INVALID_PAGE)) |
| 21 | return 0; |
| 22 | |
| 23 | return kvm_mmu_load(vcpu); |
| 24 | } |
| 25 | |
| 26 | static inline int is_long_mode(struct kvm_vcpu *vcpu) |
| 27 | { |
| 28 | #ifdef CONFIG_X86_64 |
| 29 | return vcpu->arch.shadow_efer & EFER_LME; |
| 30 | #else |
| 31 | return 0; |
| 32 | #endif |
| 33 | } |
| 34 | |
| 35 | static inline int is_pae(struct kvm_vcpu *vcpu) |
| 36 | { |
| 37 | return vcpu->arch.cr4 & X86_CR4_PAE; |
| 38 | } |
| 39 | |
| 40 | static inline int is_pse(struct kvm_vcpu *vcpu) |
| 41 | { |
| 42 | return vcpu->arch.cr4 & X86_CR4_PSE; |
| 43 | } |
| 44 | |
| 45 | static inline int is_paging(struct kvm_vcpu *vcpu) |
| 46 | { |
| 47 | return vcpu->arch.cr0 & X86_CR0_PG; |
| 48 | } |
| 49 | |
| 50 | #endif |