lkml.org 
[lkml]   [2006]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    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@elte.hu>

    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@elte.hu>
    ---
    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)
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-12-28 13:47    [W:0.021 / U:60.256 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site