logo       

[patch] kvm: fix GFP_KERNEL allocation in atomic section in kvm_dev_ioctl_c: msg#00262

emulators.kvm.devel

Subject: [patch] kvm: fix GFP_KERNEL allocation in atomic section in kvm_dev_ioctl_create_vcpu()

Subject: [patch] kvm: fix GFP_KERNEL allocation in atomic section in
kvm_dev_ioctl_create_vcpu()
From: Ingo Molnar <mingo@xxxxxxx>

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 <mingo@xxxxxxx>
---
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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise