diff options
author | Avi Kivity <avi@redhat.com> | 2009-05-31 15:58:47 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:32:46 -0400 |
commit | 6de4f3ada40b336522250a7832a0cc4de8856589 (patch) | |
tree | 90920846774aa0fb0fb47ac245fcf5f8b73afcee /arch/x86/kvm/mmu.c | |
parent | 8f5d549f028056d6ad6044f2d9e27ecf361d955e (diff) |
KVM: Cache pdptrs
Instead of reloading the pdptrs on every entry and exit (vmcs writes on vmx,
guest memory access on svm) extract them on demand.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r-- | arch/x86/kvm/mmu.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0ef5bb2b4043..8ee67e3fb9d0 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "mmu.h" | 20 | #include "mmu.h" |
21 | #include "kvm_cache_regs.h" | ||
21 | 22 | ||
22 | #include <linux/kvm_host.h> | 23 | #include <linux/kvm_host.h> |
23 | #include <linux/types.h> | 24 | #include <linux/types.h> |
@@ -1954,6 +1955,7 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
1954 | gfn_t root_gfn; | 1955 | gfn_t root_gfn; |
1955 | struct kvm_mmu_page *sp; | 1956 | struct kvm_mmu_page *sp; |
1956 | int direct = 0; | 1957 | int direct = 0; |
1958 | u64 pdptr; | ||
1957 | 1959 | ||
1958 | root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT; | 1960 | root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT; |
1959 | 1961 | ||
@@ -1981,11 +1983,12 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
1981 | 1983 | ||
1982 | ASSERT(!VALID_PAGE(root)); | 1984 | ASSERT(!VALID_PAGE(root)); |
1983 | if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { | 1985 | if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { |
1984 | if (!is_present_pte(vcpu->arch.pdptrs[i])) { | 1986 | pdptr = kvm_pdptr_read(vcpu, i); |
1987 | if (!is_present_pte(pdptr)) { | ||
1985 | vcpu->arch.mmu.pae_root[i] = 0; | 1988 | vcpu->arch.mmu.pae_root[i] = 0; |
1986 | continue; | 1989 | continue; |
1987 | } | 1990 | } |
1988 | root_gfn = vcpu->arch.pdptrs[i] >> PAGE_SHIFT; | 1991 | root_gfn = pdptr >> PAGE_SHIFT; |
1989 | } else if (vcpu->arch.mmu.root_level == 0) | 1992 | } else if (vcpu->arch.mmu.root_level == 0) |
1990 | root_gfn = 0; | 1993 | root_gfn = 0; |
1991 | if (mmu_check_root(vcpu, root_gfn)) | 1994 | if (mmu_check_root(vcpu, root_gfn)) |