[patch 4/4] KVM: x86: disallow changing a slots size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Support to shrinking aliases complicates kernel code unnecessarily,
while userspace can do the same with two operations, delete an alias,
and create a new alias.

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

Index: kvm-pending/arch/x86/kvm/x86.c
===================================================================
--- kvm-pending.orig/arch/x86/kvm/x86.c
+++ kvm-pending/arch/x86/kvm/x86.c
@@ -1669,6 +1669,7 @@ static int kvm_vm_ioctl_set_memory_alias
 {
 	int r, n;
 	struct kvm_mem_alias *p;
+	unsigned long npages;
 
 	r = -EINVAL;
 	/* General sanity checks */
@@ -1690,9 +1691,12 @@ static int kvm_vm_ioctl_set_memory_alias
 
 	p = &kvm->arch.aliases[alias->slot];
 
-	/* FIXME: either disallow shrinking alias slots or disable
- 	 * size changes as done with memslots
- 	 */
+	/* Disallow changing an alias slot's size. */
+	npages = alias->memory_size >> PAGE_SHIFT;
+	r = -EINVAL;
+	if (npages && p->npages && npages != p->npages)
+		goto out_unlock;
+
 	if (!alias->memory_size) {
 		r = -EBUSY;
 		if (kvm_root_gfn_in_range(kvm, p->base_gfn,


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux