From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 1/1] KVM: Fix kernel allocated memory slot Date: Tue, 11 Nov 2008 19:59:30 -0600 Message-ID: <491A3882.5040908@codemonkey.ws> References: <1226388640-32200-1-git-send-email-sheng@linux.intel.com> <1226415505.458.5.camel@localhost.localdomain> <200811120952.30232.sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Cc: Hollis Blanchard , Avi Kivity , kvm@vger.kernel.org To: Sheng Yang Return-path: Received: from yx-out-2324.google.com ([74.125.44.29]:61950 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbYKLB7f (ORCPT ); Tue, 11 Nov 2008 20:59:35 -0500 Received: by yx-out-2324.google.com with SMTP id 8so111456yxm.1 for ; Tue, 11 Nov 2008 17:59:34 -0800 (PST) In-Reply-To: <200811120952.30232.sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Sheng Yang wrote: > On Tuesday 11 November 2008 22:58:25 Hollis Blanchard wrote: > >> On Tue, 2008-11-11 at 15:30 +0800, Sheng Yang wrote: >> >>> Commit 7fd49de9773fdcb7b75e823b21c1c5dc1e218c14 "KVM: ensure that memslot >>> userspace addresses are page-aligned" broke kernel space allocated memory >>> slot, for the userspace_addr is invalid. >>> >>> Signed-off-by: Sheng Yang >>> --- >>> virt/kvm/kvm_main.c | 2 +- >>> 1 files changed, 1 insertions(+), 1 deletions(-) >>> >>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >>> index 0a0a959..4727c08 100644 >>> --- a/virt/kvm/kvm_main.c >>> +++ b/virt/kvm/kvm_main.c >>> @@ -715,7 +715,7 @@ int __kvm_set_memory_region(struct kvm *kvm, >>> goto out; >>> if (mem->guest_phys_addr & (PAGE_SIZE - 1)) >>> goto out; >>> - if (mem->userspace_addr & (PAGE_SIZE - 1)) >>> + if (user_alloc && (mem->userspace_addr & (PAGE_SIZE - 1))) >>> goto out; >>> if (mem->slot >= KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS) >>> goto out; >>> >> Wow, I didn't realize we still had kernel-allocated guest memory. Why is >> that? >> >> Anyways, the above patch seems fine to me. >> Acked-by: Hollis Blanchard >> > > it's for VMX EPT and APIC access page, as well as TSS pages. We are planning > to change that in the future, but I think it's a quick fix for now. > It's also there to support older userspaces that still rely on the kernel allocating guest memory. This is only applicable to x86 though. Regards, Anthony Liguori > Thanks. > >