Re: [PATCH 2/2] KVM: Prevent internal slots from being COWed

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

 



On Mon, Jun 21, 2010 at 11:18:13AM +0300, Avi Kivity wrote:
> If a process with a memory slot is COWed, the page will change its address
> (despite having an elevated reference count).  This breaks internal memory
> slots which have their physical addresses loaded into vmcs registers (see
> the APIC access memory slot).
> 
> Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
> ---
>  arch/x86/kvm/x86.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 33156a3..d9a33e6 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5633,6 +5633,11 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
>  				int user_alloc)
>  {
>  	int npages = memslot->npages;
> +	int map_flags = MAP_PRIVATE | MAP_ANONYMOUS;
> +
> +	/* Prevent internal slot pages from being moved by fork()/COW. */
> +	if (memslot->id >= KVM_MEMORY_SLOTS)
> +		map_flags = MAP_SHARED | MAP_ANONYMOUS;
>  
>  	/*To keep backward compatibility with older userspace,
>  	 *x86 needs to hanlde !user_alloc case.

Forgot to use map_flags below.

--
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