diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2009-06-11 11:07:42 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:32:56 -0400 |
commit | 94d8b056a20bac4f9905d6dafcf7b7005207684a (patch) | |
tree | 8ab6678b7c9e8372a314f88a0b61572c19a3b992 /arch/x86 | |
parent | 4d88954d6246d7d43bb8903981731002179f1a1c (diff) |
KVM: MMU: add kvm_mmu_get_spte_hierarchy helper
Required by EPT misconfiguration handler.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/mmu.c | 18 | ||||
-rw-r--r-- | arch/x86/kvm/mmu.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index e18f65bf2de7..12974de88aa5 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -3038,6 +3038,24 @@ out: | |||
3038 | return r; | 3038 | return r; |
3039 | } | 3039 | } |
3040 | 3040 | ||
3041 | int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4]) | ||
3042 | { | ||
3043 | struct kvm_shadow_walk_iterator iterator; | ||
3044 | int nr_sptes = 0; | ||
3045 | |||
3046 | spin_lock(&vcpu->kvm->mmu_lock); | ||
3047 | for_each_shadow_entry(vcpu, addr, iterator) { | ||
3048 | sptes[iterator.level-1] = *iterator.sptep; | ||
3049 | nr_sptes++; | ||
3050 | if (!is_shadow_present_pte(*iterator.sptep)) | ||
3051 | break; | ||
3052 | } | ||
3053 | spin_unlock(&vcpu->kvm->mmu_lock); | ||
3054 | |||
3055 | return nr_sptes; | ||
3056 | } | ||
3057 | EXPORT_SYMBOL_GPL(kvm_mmu_get_spte_hierarchy); | ||
3058 | |||
3041 | #ifdef AUDIT | 3059 | #ifdef AUDIT |
3042 | 3060 | ||
3043 | static const char *audit_msg; | 3061 | static const char *audit_msg; |
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index 016bf7183e9f..61a1b3884b49 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h | |||
@@ -37,6 +37,8 @@ | |||
37 | #define PT32_ROOT_LEVEL 2 | 37 | #define PT32_ROOT_LEVEL 2 |
38 | #define PT32E_ROOT_LEVEL 3 | 38 | #define PT32E_ROOT_LEVEL 3 |
39 | 39 | ||
40 | int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4]); | ||
41 | |||
40 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) | 42 | static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) |
41 | { | 43 | { |
42 | if (unlikely(vcpu->kvm->arch.n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) | 44 | if (unlikely(vcpu->kvm->arch.n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) |