aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h4
-rw-r--r--arch/x86/kvm/mmu.c2
-rw-r--r--include/linux/kvm_host.h7
-rw-r--r--virt/kvm/kvm_main.c2
4 files changed, 10 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 69b652547489..1769f3dde611 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -31,6 +31,8 @@
31#define KVM_MEMORY_SLOTS 32 31#define KVM_MEMORY_SLOTS 32
32/* memory slots that does not exposed to userspace */ 32/* memory slots that does not exposed to userspace */
33#define KVM_PRIVATE_MEM_SLOTS 4 33#define KVM_PRIVATE_MEM_SLOTS 4
34#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
35
34#define KVM_MMIO_SIZE 16 36#define KVM_MMIO_SIZE 16
35 37
36#define KVM_PIO_PAGE_OFFSET 1 38#define KVM_PIO_PAGE_OFFSET 1
@@ -228,7 +230,7 @@ struct kvm_mmu_page {
228 * One bit set per slot which has memory 230 * One bit set per slot which has memory
229 * in this shadow page. 231 * in this shadow page.
230 */ 232 */
231 DECLARE_BITMAP(slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS); 233 DECLARE_BITMAP(slot_bitmap, KVM_MEM_SLOTS_NUM);
232 bool unsync; 234 bool unsync;
233 int root_count; /* Currently serving as active root */ 235 int root_count; /* Currently serving as active root */
234 unsigned int unsync_children; 236 unsigned int unsync_children;
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index aecdea265f7e..715dcb4fb798 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1349,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
1349 PAGE_SIZE); 1349 PAGE_SIZE);
1350 set_page_private(virt_to_page(sp->spt), (unsigned long)sp); 1350 set_page_private(virt_to_page(sp->spt), (unsigned long)sp);
1351 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages); 1351 list_add(&sp->link, &vcpu->kvm->arch.active_mmu_pages);
1352 bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS); 1352 bitmap_zero(sp->slot_bitmap, KVM_MEM_SLOTS_NUM);
1353 sp->parent_ptes = 0; 1353 sp->parent_ptes = 0;
1354 mmu_page_add_parent_pte(vcpu, sp, parent_pte); 1354 mmu_page_add_parent_pte(vcpu, sp, parent_pte);
1355 kvm_mod_used_mmu_pages(vcpu->kvm, +1); 1355 kvm_mod_used_mmu_pages(vcpu->kvm, +1);
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 7c654aa46b6c..924df0d7ac5f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -227,11 +227,14 @@ struct kvm_irq_routing_table {};
227 227
228#endif 228#endif
229 229
230#ifndef KVM_MEM_SLOTS_NUM
231#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
232#endif
233
230struct kvm_memslots { 234struct kvm_memslots {
231 int nmemslots; 235 int nmemslots;
232 u64 generation; 236 u64 generation;
233 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + 237 struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM];
234 KVM_PRIVATE_MEM_SLOTS];
235}; 238};
236 239
237struct kvm { 240struct kvm {
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index af5c988cafcc..9ad94c9996e7 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -663,7 +663,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
663 (void __user *)(unsigned long)mem->userspace_addr, 663 (void __user *)(unsigned long)mem->userspace_addr,
664 mem->memory_size))) 664 mem->memory_size)))
665 goto out; 665 goto out;
666 if (mem->slot >= KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS) 666 if (mem->slot >= KVM_MEM_SLOTS_NUM)
667 goto out; 667 goto out;
668 if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr) 668 if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr)
669 goto out; 669 goto out;