From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: [patch] kvm: fix GFP_KERNEL allocation in atomic section in kvm_dev_ioctl_create_vcpu() Date: Thu, 28 Dec 2006 13:42:24 +0100 Message-ID: <20061228124224.GA28573@elte.hu> References: <45939755.7010603@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel , Andrew Morton , Linus Torvalds , linux-kernel Return-path: To: Avi Kivity Content-Disposition: inline In-Reply-To: <45939755.7010603-atKUWr5tajBWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Subject: [patch] kvm: fix GFP_KERNEL allocation in atomic section in kvm_dev_ioctl_create_vcpu() From: Ingo Molnar fix a GFP_KERNEL allocation in atomic section bug: kvm_dev_ioctl_create_vcpu() called kvm_mmu_init(), which calls alloc_pages(), while holding the vcpu. The fix is to set up the MMU state earlier, it does not require a loaded CPU state. (NOTE: free_vcpus does an kvm_mmu_destroy() call so there's no need for any extra teardown branch on allocation failure here.) found in 2.6.20-rc2-rt1. Signed-off-by: Ingo Molnar --- drivers/kvm/kvm_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux/drivers/kvm/kvm_main.c =================================================================== --- linux.orig/drivers/kvm/kvm_main.c +++ linux/drivers/kvm/kvm_main.c @@ -522,12 +522,12 @@ static int kvm_dev_ioctl_create_vcpu(str if (r < 0) goto out_free_vcpus; - kvm_arch_ops->vcpu_load(vcpu); + r = kvm_mmu_init(vcpu); + if (r < 0) + goto out_free_vcpus; + kvm_arch_ops->vcpu_load(vcpu); r = kvm_arch_ops->vcpu_setup(vcpu); - if (r >= 0) - r = kvm_mmu_init(vcpu); - vcpu_put(vcpu); if (r < 0) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV