From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] KVM: Prevent internal slots from being COWed Date: Tue, 22 Jun 2010 14:17:44 +0300 Message-ID: <4C209BD8.8030104@redhat.com> References: <1277108293-9918-1-git-send-email-avi@redhat.com> <1277108293-9918-3-git-send-email-avi@redhat.com> <20100621202334.GA17362@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47340 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949Ab0FVLRq (ORCPT ); Tue, 22 Jun 2010 07:17:46 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5MBHju8022790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Jun 2010 07:17:46 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5MBHiLu012677 for ; Tue, 22 Jun 2010 07:17:45 -0400 In-Reply-To: <20100621202334.GA17362@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 06/21/2010 11:23 PM, Marcelo Tosatti wrote: > 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 >> --- >> 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. > > Ouch, corrected and applied. -- error compiling committee.c: too many arguments to function