Re: [PATCH 1/3] KVM: Expose get_eoi_gsi for IRQ acking for assigned devices.

Previous thread: sync_file_range(SYNC_FILE_RANGE_WRITE) blocks? by Pavel Machek on Friday, May 30, 2008 - 6:26 am. (25 messages)

Next thread: Xen/paravirt_ops page on Xen wiki by Jeremy Fitzhardinge on Friday, May 30, 2008 - 7:10 am. (1 message)
To: <kvm@...>
Cc: <linux-kernel@...>, <muli@...>, <benami@...>, <allen.m.kay@...>, <chrisw@...>, Amit Shah <amit.shah@...>
Date: Friday, May 30, 2008 - 6:27 am

Also add kvm_ prefix.

Signed-off-by: Amit Shah <amit.shah@qumranet.com>
---
virt/kvm/ioapic.c | 4 ++--
virt/kvm/ioapic.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 99a1736..4c41a00 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -284,7 +284,7 @@ void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)
}
}

-static int get_eoi_gsi(struct kvm_ioapic *ioapic, int vector)
+int kvm_get_eoi_gsi(struct kvm_ioapic *ioapic, int vector)
{
int i;

@@ -300,7 +300,7 @@ void kvm_ioapic_update_eoi(struct kvm *kvm, int vector)
union ioapic_redir_entry *ent;
int gsi;

- gsi = get_eoi_gsi(ioapic, vector);
+ gsi = kvm_get_eoi_gsi(ioapic, vector);
if (gsi == -1) {
printk(KERN_WARNING "Can't find redir item for %d EOI\n",
vector);
diff --git a/virt/kvm/ioapic.h b/virt/kvm/ioapic.h
index 7f16675..a744572 100644
--- a/virt/kvm/ioapic.h
+++ b/virt/kvm/ioapic.h
@@ -91,5 +91,6 @@ void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
int kvm_ioapic_init(struct kvm *kvm);
void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
void kvm_ioapic_reset(struct kvm_ioapic *ioapic);
+int kvm_get_eoi_gsi(struct kvm_ioapic *ioapic, int vector);

#endif
--
1.5.5.1

--

To: Amit Shah <amit.shah@...>
Cc: <kvm@...>, <linux-kernel@...>, <muli@...>, <benami@...>, <allen.m.kay@...>, <chrisw@...>
Date: Wednesday, June 18, 2008 - 10:25 am

de53f0e48a1ec9880613a9bdbc5d1d3dcfada0f7 kills get_eoi_gsi, since there
can be more than one irq mapped to a vector. I guess the right way to
deal with this is to install a callback in the pic and apic, to be
called when the guest acks the interrupt.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--

To: <kvm@...>
Cc: <linux-kernel@...>, <muli@...>, <benami@...>, <allen.m.kay@...>, <chrisw@...>, Amit Shah <amit.shah@...>
Date: Friday, May 30, 2008 - 6:27 am

This function injects an interrupt into the guest given the kvm struct,
the (guest) irq number and the interrupt level.

Signed-off-by: Amit Shah <amit.shah@qumranet.com>
---
arch/x86/kvm/irq.c | 11 +++++++++++
arch/x86/kvm/irq.h | 2 ++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 76d736b..0d9e552 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -100,3 +100,14 @@ void __kvm_migrate_timers(struct kvm_vcpu *vcpu)
__kvm_migrate_apic_timer(vcpu);
__kvm_migrate_pit_timer(vcpu);
}
+
+/* This should be called with the kvm->lock mutex held */
+void kvm_set_irq(struct kvm *kvm, int irq, int level)
+{
+ /* Not possible to detect if the guest uses the PIC or the
+ * IOAPIC. So set the bit in both. The guest will ignore
+ * writes to the unused one.
+ */
+ kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
+ kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
+}
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 2a15be2..ba4e3bf 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -80,6 +80,8 @@ static inline int irqchip_in_kernel(struct kvm *kvm)

void kvm_pic_reset(struct kvm_kpic_state *s);

+void kvm_set_irq(struct kvm *kvm, int irq, int level);
+
void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
--
1.5.5.1

--

To: <kvm@...>
Cc: <linux-kernel@...>, <muli@...>, <benami@...>, <allen.m.kay@...>, <chrisw@...>, Amit Shah <amit.shah@...>
Date: Friday, May 30, 2008 - 6:27 am

From: Amit Shah <amit.shah@qumranet.com>
From: Ben-Ami Yassour <benami@il.ibm.com>

This patch adds support for handling PCI devices that are assigned to the guest
("PCI passthrough").

The device to be assigned to the guest is registered in the host kernel and
interrupt delivery is handled. It is expected the module for the device in the
host is not loaded.

Devices that share their interrupt line are not supported at the moment.

By itself, this patch will not make devices work within the guest. There has to
be some mechanism of translating guest DMA addresses into machine addresses. This
support comes from one of three approaches:

1. If you have recent Intel hardware with VT-d support, you can use the patches
in

git.kernel.org/pub/scm/linux/kernel/git/amit/kvm.git vtd
git.kernel.org/pub/scm/linux/kernel/git/amit/kvm-userspace.git vtd

Patch your host kernel. These patches are expected to hit mainline soon.

2. For paravirtualised Linux guests, you can use the patches in

git.kernel.org/pub/scm/linux/kernel/git/amit/kvm.git pvdma
git.kernel.org/pub/scm/linux/kernel/git/amit/kvm-userspace.git pvdma

This kernel tree has patches for host as well as guest kernels.

3. 1-1 mapping of guest in host address space

The patch to do this against older kernels is available (on the kvm / lkml list
archives).

Signed-off-by: Amit Shah <amit.shah@qumranet.com>
---
arch/x86/kvm/lapic.c | 2 +
arch/x86/kvm/x86.c | 271 ++++++++++++++++++++++++++++++++++++++++++++
include/asm-x86/kvm_host.h | 39 +++++++
include/asm-x86/kvm_para.h | 16 +++-
include/linux/kvm.h | 3 +
virt/kvm/ioapic.c | 11 ++-
6 files changed, 339 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 8fcd84e..030053b 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -451,6 +451,8 @@ static void apic_set_eoi(struct kvm_lapic *apic)

if (apic_test_and_clear_vector(vector, apic->regs + AP...

Previous thread: sync_file_range(SYNC_FILE_RANGE_WRITE) blocks? by Pavel Machek on Friday, May 30, 2008 - 6:26 am. (25 messages)

Next thread: Xen/paravirt_ops page on Xen wiki by Jeremy Fitzhardinge on Friday, May 30, 2008 - 7:10 am. (1 message)