Avi Kivity wrote:
> I rebased the lapic2 branch onto current master.  Because there were
> many nontrivial changes, the result is in a new branch,
> lapic3.  This is
> for both kernel and userspace.
> 

lapic3 clearly crashes after the rebase due to APIC register
    access earlier than APIC instance is created, because
vcpu is dynamic created now.
    
    Fix crash by moving APIC creation code into
    VMX/SVM creation code.
    
    Signed-off-by: Yaozu (Eddie) Dong <[EMAIL PROTECTED]>




diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index b09595e..cb244f6 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2470,11 +2470,6 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm
*kvm, int n)
        /* We do fxsave: this must be aligned. */
        BUG_ON((unsigned long)&vcpu->host_fx_image & 0xF);
 
-       if (irqchip_in_kernel(vcpu->kvm)) {
-               r = kvm_create_lapic(vcpu);
-               if (r < 0)
-                       goto free_vcpu;
-       }
        vcpu_load(vcpu);
        r = kvm_mmu_setup(vcpu);
        vcpu_put(vcpu);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index e3db1cd..7f60bf3 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -944,6 +944,7 @@ nomem:
        kvm_free_apic(apic);
        return -ENOMEM;
 }
+EXPORT_SYMBOL_GPL(kvm_create_lapic);
 
 int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu)
 {
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 015ab4b..6bf0c21 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -587,6 +587,12 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm
*kvm, unsigned int id)
        if (err)
                goto free_svm;
 
+       if (irqchip_in_kernel(kvm)) {
+               err = kvm_create_lapic(&svm->vcpu);
+               if (err < 0)
+                       goto free_svm;
+       }
+
        page = alloc_page(GFP_KERNEL);
        if (!page) {
                err = -ENOMEM;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 9bb8867..667c9cd 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -2439,6 +2439,12 @@ static struct kvm_vcpu *vmx_create_vcpu(struct
kvm *kvm, unsigned int id)
        if (err)
                goto free_vcpu;
 
+       if (irqchip_in_kernel(kvm)) {
+               err = kvm_create_lapic(&vmx->vcpu);
+               if (err < 0)
+                       goto free_vcpu;
+       }
+
        vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!vmx->guest_msrs) {
                err = -ENOMEM;

Attachment: lapic3_rebase_fix.patch
Description: lapic3_rebase_fix.patch

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to