lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1356363072.3224.604.camel@bling.home>
Date:	Mon, 24 Dec 2012 08:31:12 -0700
From:	Alex Williamson <alex.williamson@...hat.com>
To:	Gleb Natapov <gleb@...hat.com>
Cc:	kvm@...r.kernel.org, yoshikawa_takuya_b1@....ntt.co.jp,
	mtosatti@...hat.com, linux-kernel@...r.kernel.org,
	takuya.yoshikawa@...il.com
Subject: Re: [PATCH] kvm: Fix memory slot generation updates

On Sun, 2012-12-23 at 10:55 +0200, Gleb Natapov wrote:
> On Fri, Dec 21, 2012 at 08:20:16AM -0700, Alex Williamson wrote:
> > Previous patch "kvm: Minor memory slot optimization" overlooked the
> > generation field of the memory slots.  Re-using the original memory
> > slots left us with with two slightly different memory slots with the
> > same generation.  To fix this, make update_memslots() take a new
> > parameter to specify the last generation.  This also makes generation
> > management more explicit to avoid such problems in the future.
> > 
> > Reported-by: Takuya Yoshikawa <yoshikawa_takuya_b1@....ntt.co.jp>
> > Signed-off-by: Alex Williamson <alex.williamson@...hat.com>
> Applied, thanks. What about this small cleanup on to of the patch:

Nice cleanup

Reviewed-by: Alex Williamson <alex.williamson@...hat.com>

> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 14cbae8..e45c20c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -702,6 +702,17 @@ static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
>  	return 0;
>  }
>  
> +static struct kvm_memslots *install_new_memslots(struct kvm *kvm,
> +		struct kvm_memslots *slots, struct kvm_memory_slot *new)
> +{
> +	struct kvm_memslots *old_memslots = kvm->memslots;
> +
> +	update_memslots(slots, new, kvm->memslots->generation);
> +	rcu_assign_pointer(kvm->memslots, slots);
> +	synchronize_srcu_expedited(&kvm->srcu);
> +	return old_memslots; 
> +}
> +
>  /*
>   * Allocate some memory and give it an address in the guest physical address
>   * space.
> @@ -820,11 +831,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		slot = id_to_memslot(slots, mem->slot);
>  		slot->flags |= KVM_MEMSLOT_INVALID;
>  
> -		update_memslots(slots, NULL, kvm->memslots->generation);
> +		old_memslots = install_new_memslots(kvm, slots, NULL);
>  
> -		old_memslots = kvm->memslots;
> -		rcu_assign_pointer(kvm->memslots, slots);
> -		synchronize_srcu_expedited(&kvm->srcu);
>  		/* slot was deleted or moved, clear iommu mapping */
>  		kvm_iommu_unmap_pages(kvm, &old);
>  		/* From this point no new shadow pages pointing to a deleted,
> @@ -868,10 +876,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
>  		memset(&new.arch, 0, sizeof(new.arch));
>  	}
>  
> -	update_memslots(slots, &new, kvm->memslots->generation);
> -	old_memslots = kvm->memslots;
> -	rcu_assign_pointer(kvm->memslots, slots);
> -	synchronize_srcu_expedited(&kvm->srcu);
> +	old_memslots = install_new_memslots(kvm, slots, &new);
>  
>  	kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);
>  
> --
> 			Gleb.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ