This patch applies to the preempt-hooks branch to enable KVM to function properly on VMX. With preemption enabled, the KVM context can get scheduled out at arbitrary points. The preempt-hooks allow us to correctly restore the host state while being preemptible, but preemption causes problems on the schedule-in side if the vcpu-task migrates to a new pCPU.
Ideally we can handle the migration scenario better (patch for this in progress). However, this patch provides correctness in the interim at the expense of a small amount of flexibility. E.g. we can only migrate when the vcpu_lock is not held. Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]> --- drivers/kvm/kvm.h | 1 + drivers/kvm/kvm_main.c | 3 +++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 03f374e..d18537c 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h @@ -318,6 +318,7 @@ struct kvm_vcpu { struct vcpu_svm *svm; }; struct mutex mutex; + cpumask_t cpumask; int cpu; int launched; u64 host_tsc; diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index ef67572..4a19f6f 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -245,6 +245,8 @@ static void vcpu_load(struct kvm_vcpu *vcpu) mutex_lock(&vcpu->mutex); cpu = get_cpu(); + vcpu->cpumask = current->cpus_allowed; + set_cpus_allowed(current, cpumask_of_cpu(cpu)); preempt_hook_register(&vcpu->preempt_hook); kvm_arch_ops->vcpu_load(vcpu, cpu); put_cpu(); @@ -255,6 +257,7 @@ static void vcpu_put(struct kvm_vcpu *vcpu) preempt_disable(); kvm_arch_ops->vcpu_put(vcpu); preempt_hook_unregister(&vcpu->preempt_hook); + set_cpus_allowed(current, vcpu->cpumask); preempt_enable(); mutex_unlock(&vcpu->mutex); } ------------------------------------------------------------------------- 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 kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel