aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSheng Yang <sheng@linux.intel.com>2008-10-16 05:30:57 -0400
committerAvi Kivity <avi@redhat.com>2008-12-31 09:51:45 -0500
commit291f26bc0f89518ad7ee3207c09eb8a743ac8fcc (patch)
treed0ce8ff4d0a4b88b656db0f559a00c5b25738ed2 /arch
parentd73fa29a9b75b2af7f69dae276d2c602a23b329b (diff)
KVM: MMU: Extend kvm_mmu_page->slot_bitmap size
Otherwise set_bit() for private memory slot(above KVM_MEMORY_SLOTS) would corrupted memory in 32bit host. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_host.h8
-rw-r--r--arch/x86/kvm/mmu.c6
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 93040b5eed96..59c3ae10de6c 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -192,9 +192,11 @@ struct kvm_mmu_page {
192 u64 *spt; 192 u64 *spt;
193 /* hold the gfn of each spte inside spt */ 193 /* hold the gfn of each spte inside spt */
194 gfn_t *gfns; 194 gfn_t *gfns;
195 unsigned long slot_bitmap; /* One bit set per slot which has memory 195 /*
196 * in this shadow page. 196 * One bit set per slot which has memory
197 */ 197 * in this shadow page.
198 */
199 DECLARE_BITMAP(slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
198 int multimapped; /* More than one parent_pte? */ 200 int multimapped; /* More than one parent_pte? */
199 int root_count; /* Currently serving as active root */ 201 int root_count; /* Currently serving as active root */
200 bool unsync; 202 bool unsync;
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 09d05f57bf66..8687758b5295 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -789,7 +789,7 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
789 set_page_private(virt_to_page(sp->spt), (unsigned long)sp); 789 set_page_private(virt_to_page(sp->spt), (unsigned long)sp);
790 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages); 790 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages);
791 ASSERT(is_empty_shadow_page(sp->spt)); 791 ASSERT(is_empty_shadow_page(sp->spt));
792 sp->slot_bitmap = 0; 792 bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
793 sp->multimapped = 0; 793 sp->multimapped = 0;
794 sp->parent_pte = parent_pte; 794 sp->parent_pte = parent_pte;
795 --vcpu->kvm->arch.n_free_mmu_pages; 795 --vcpu->kvm->arch.n_free_mmu_pages;
@@ -1364,7 +1364,7 @@ static void page_header_update_slot(struct kvm *kvm, void *pte, gfn_t gfn)
1364 int slot = memslot_id(kvm, gfn_to_memslot(kvm, gfn)); 1364 int slot = memslot_id(kvm, gfn_to_memslot(kvm, gfn));
1365 struct kvm_mmu_page *sp = page_header(__pa(pte)); 1365 struct kvm_mmu_page *sp = page_header(__pa(pte));
1366 1366
1367 __set_bit(slot, &sp->slot_bitmap); 1367 __set_bit(slot, sp->slot_bitmap);
1368} 1368}
1369 1369
1370static void mmu_convert_notrap(struct kvm_mmu_page *sp) 1370static void mmu_convert_notrap(struct kvm_mmu_page *sp)
@@ -2564,7 +2564,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
2564 int i; 2564 int i;
2565 u64 *pt; 2565 u64 *pt;
2566 2566
2567 if (!test_bit(slot, &sp->slot_bitmap)) 2567 if (!test_bit(slot, sp->slot_bitmap))
2568 continue; 2568 continue;
2569 2569
2570 pt = sp->spt; 2570 pt = sp->spt;