diff options
author | Eric Northup <digitaleric@google.com> | 2010-04-26 20:00:05 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-19 04:36:22 -0400 |
commit | 5a7388c2d2faa2cc70c2d4717c8d7836d55459e0 (patch) | |
tree | 3ae800c68c7f66ea340ddcecedd081d0b828011d /arch/x86/kvm/mmu.c | |
parent | c4bd09b28907ca17cdb307c32bbcc9882c280feb (diff) |
KVM: MMU: fix hashing for TDP and non-paging modes
For TDP mode, avoid creating multiple page table roots for the single
guest-to-host physical address map by fixing the inputs used for the
shadow page table hash in mmu_alloc_roots().
Signed-off-by: Eric Northup <digitaleric@google.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r-- | arch/x86/kvm/mmu.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index ddfa8658fb6d..9696d654b01f 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -2059,10 +2059,12 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
2059 | hpa_t root = vcpu->arch.mmu.root_hpa; | 2059 | hpa_t root = vcpu->arch.mmu.root_hpa; |
2060 | 2060 | ||
2061 | ASSERT(!VALID_PAGE(root)); | 2061 | ASSERT(!VALID_PAGE(root)); |
2062 | if (tdp_enabled) | ||
2063 | direct = 1; | ||
2064 | if (mmu_check_root(vcpu, root_gfn)) | 2062 | if (mmu_check_root(vcpu, root_gfn)) |
2065 | return 1; | 2063 | return 1; |
2064 | if (tdp_enabled) { | ||
2065 | direct = 1; | ||
2066 | root_gfn = 0; | ||
2067 | } | ||
2066 | sp = kvm_mmu_get_page(vcpu, root_gfn, 0, | 2068 | sp = kvm_mmu_get_page(vcpu, root_gfn, 0, |
2067 | PT64_ROOT_LEVEL, direct, | 2069 | PT64_ROOT_LEVEL, direct, |
2068 | ACC_ALL, NULL); | 2070 | ACC_ALL, NULL); |
@@ -2072,8 +2074,6 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
2072 | return 0; | 2074 | return 0; |
2073 | } | 2075 | } |
2074 | direct = !is_paging(vcpu); | 2076 | direct = !is_paging(vcpu); |
2075 | if (tdp_enabled) | ||
2076 | direct = 1; | ||
2077 | for (i = 0; i < 4; ++i) { | 2077 | for (i = 0; i < 4; ++i) { |
2078 | hpa_t root = vcpu->arch.mmu.pae_root[i]; | 2078 | hpa_t root = vcpu->arch.mmu.pae_root[i]; |
2079 | 2079 | ||
@@ -2089,6 +2089,10 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
2089 | root_gfn = 0; | 2089 | root_gfn = 0; |
2090 | if (mmu_check_root(vcpu, root_gfn)) | 2090 | if (mmu_check_root(vcpu, root_gfn)) |
2091 | return 1; | 2091 | return 1; |
2092 | if (tdp_enabled) { | ||
2093 | direct = 1; | ||
2094 | root_gfn = i << 30; | ||
2095 | } | ||
2092 | sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, | 2096 | sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, |
2093 | PT32_ROOT_LEVEL, direct, | 2097 | PT32_ROOT_LEVEL, direct, |
2094 | ACC_ALL, NULL); | 2098 | ACC_ALL, NULL); |