Skip to contentSkip to conversation

2.6.38-x86: Make KVM I-pipe-aware

GIT PULL Jan Kiszka 1 participant 1 message Oct 14, 2011

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

The following changes since commit 0bfe9ae6181af28018a9052d332057aa1aaf1b4f:

ipipe-2.6.38.8-x86-2.10-01 (2011-07-21 09:52:35 +0200)

are available in the git repository at:
git://git.kiszka.org/ipipe queues/2.6.38-x86

Jan Kiszka (3):
ipipe: Re-add root preemption notifier Merge branch 'queues/2.6.38-noarch' into HEAD
ipipe: x86: Make KVM I-pipe-aware

 arch/x86/kvm/svm.c         |    4 +-
 arch/x86/kvm/vmx.c         |   10 ++++++-
 arch/x86/kvm/x86.c         |   61 ++++++++++++++++++++++++++++++++++++--------
 include/linux/ipipe.h      |   35 +++++++++++++++++++++++++
 include/linux/ipipe_base.h |    2 +-
 kernel/ipipe/core.c        |    6 ++++
 6 files changed, 102 insertions(+), 16 deletions(-)

This is finally the stabilized version of [1], additionally rebased over 2.6.38.

The original patch was missing some more synchronization around shared MSR writeback when we preempt a KVM host thread (see patch below). Now that this is fixed, even a non-Linux guest (here: Win7) runs fine on a host CPU that is executing a Xenomai task as well. On the Xenomai side, there is just a tiny additional patch require that I'll post separately.

Note that there are still quite a few open issues when it comes to assigning PCI devices to a guest on an I-pipe host. But if your setup does not depend on that feature, KVM is now usable together with I-pipe/Xenomai (tested on Intel only, but AMD is much simpler, so I'm optimistic :) ).

Jan

[1] http://thread.gmane.org/gmane.linux.kernel.adeos.general/1571

---

ipipe: x86: Make KVM I-pipe-aware

In order to use KVM on an I-pipe kernel, we need to harden some code paths to truly disable interrupts and we have to install a root preemption notifier once the guest CPU state is loaded. That notifier will be called by a higher domain once it is about to switch in one of its own tasks.

---
 arch/x86/kvm/svm.c |    4 +-
 arch/x86/kvm/vmx.c |   10 ++++++-
 arch/x86/kvm/x86.c |   61 ++++++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 60 insertions(+), 15 deletions(-)
arch/x86/kvm/svm.c +2 -2
index d8a15a1..15482e6 100644
@@ -3572,7 +3572,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 
 	clgi();
 
-	local_irq_enable();
+	local_irq_enable_hw();
 
 	asm volatile (
 		"push %%"R"bp; \n\t"
@@ -3653,7 +3653,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
 
 	reload_tss(vcpu);
 
-	local_irq_disable();
+	local_irq_disable_hw();
 
 	stgi();
 
arch/x86/kvm/vmx.c +8 -2
index bf89ec2..5ef8af9 100644
@@ -883,9 +883,11 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
 
 static void vmx_load_host_state(struct vcpu_vmx *vmx)
 {
-	preempt_disable();
+	unsigned long flags;
+
+	ipipe_preempt_disable(flags);
 	__vmx_load_host_state(vmx);
-	preempt_enable();
+	ipipe_preempt_enable(flags);
 }
 
 /*
@@ -1097,6 +1099,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
 	unsigned long *msr_bitmap;
 
 	vmx_load_host_state(vmx);
+	local_irq_disable_hw_cond();
 	save_nmsrs = 0;
 #ifdef CONFIG_X86_64
 	if (is_long_mode(&vmx->vcpu)) {
@@ -1126,6 +1129,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
 		move_msr_up(vmx, index, save_nmsrs++);
 
 	vmx->save_nmsrs = save_nmsrs;
+	local_irq_enable_hw_cond();
 
 	if (cpu_has_vmx_msr_bitmap()) {
 		if (is_long_mode(&vmx->vcpu))
@@ -4171,7 +4175,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 	vmx_vcpu_load(&vmx->vcpu, cpu);
 	vmx->vcpu.cpu = cpu;
 	err = vmx_vcpu_setup(vmx);
+	local_irq_disable_hw_cond();
 	vmx_vcpu_put(&vmx->vcpu);
+	local_irq_enable_hw_cond();
 	put_cpu();
 	if (err)
 		goto free_vmcs;
arch/x86/kvm/x86.c +50 -11

123 lines not on this page · raw message

Signature · 1 line
1.7.3.4