* [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
@ 2008-11-07 10:25 Zhang, Xiantao
2008-11-09 10:07 ` Avi Kivity
2008-11-10 5:47 ` Amit Shah
0 siblings, 2 replies; 4+ messages in thread
From: Zhang, Xiantao @ 2008-11-07 10:25 UTC (permalink / raw)
To: Avi Kivity, kvm-ia64@vger.kernel.org; +Cc: kvm@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 6476 bytes --]
>From 45b40eecff85b9a7ae4caf4ae184905a79e5a139 Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Fri, 7 Nov 2008 18:13:13 +0800
Subject: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
kvm/ia64 have supported vt-d from 2.6.28rc1, this patch
enables its userspace's support.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
kernel/ia64/Kbuild | 4 ++++
qemu/Makefile.target | 7 ++++---
qemu/hw/device-assignment.c | 4 ++++
qemu/hw/ipf.c | 27 +++++++++++++++++++++++++--
qemu/hw/pc.h | 2 ++
qemu/vl.c | 8 ++++----
6 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/kernel/ia64/Kbuild b/kernel/ia64/Kbuild
index e9660ba..88eaa39 100644
--- a/kernel/ia64/Kbuild
+++ b/kernel/ia64/Kbuild
@@ -3,6 +3,10 @@ obj-m := kvm.o kvm-intel.o
kvm-objs := kvm_main.o ioapic.o coalesced_mmio.o kvm-ia64.o kvm_fw.o \
irq_comm.o ../anon_inodes.o ../external-module-compat.o
+ifeq ($(CONFIG_DMAR),y)
+kvm-objs += vtd.o
+endif
+
EXTRA_CFLAGS_vcpu.o += -mfixed-range=f2-f5,f12-f127
kvm-intel-objs := vmm.o vmm_ivt.o trampoline.o vcpu.o optvfault.o mmio.o \
vtlb.o process.o memset.o memcpy.o
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
index d504b75..229b1c6 100644
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -720,15 +720,16 @@ OBJS += virtio.o virtio-net.o virtio-blk.o virtio-balloon.o
OBJS += device-hotplug.o
+ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
+OBJS+= device-assignment.o
+endif
+
ifeq ($(TARGET_BASE_ARCH), i386)
# Hardware support
OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o
-ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
-OBJS+= device-assignment.o
-endif
ifeq ($(USE_KVM_PIT), 1)
OBJS+= i8254-kvm.o
endif
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 78b7e14..5cda7d9 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -457,6 +457,10 @@ void assigned_dev_update_irq(PCIDevice *d)
irq = pci_map_irq(&assigned_dev->dev, assigned_dev->intpin);
irq = piix_get_irq(irq);
+#ifdef TARGET_IA64
+ irq = ipf_map_irq(d, irq);
+#endif
+
if (irq != assigned_dev->girq) {
struct kvm_assigned_irq assigned_irq_data;
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index 337c854..f4a2853 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -38,6 +38,7 @@
#include "firmware.h"
#include "ia64intrin.h"
#include <unistd.h>
+#include "device-assignment.h"
#include "qemu-kvm.h"
@@ -450,7 +451,6 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
/*Load firware to its proper position.*/
if (kvm_enabled()) {
- int r;
unsigned long image_size;
char *image = NULL;
uint8_t *fw_image_start;
@@ -645,8 +645,26 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
unit_id++;
}
}
-}
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
+ if (kvm_enabled()) {
+ int i;
+ for (i = 0; i < assigned_devices_index; i++) {
+ if (add_assigned_device(assigned_devices[i]) < 0) {
+ fprintf(stderr, "Warning: could not add assigned device %s\n",
+ assigned_devices[i]);
+ }
+ }
+
+ if (init_all_assigned_devices(pci_bus)) {
+ fprintf(stderr, "Failed to initialize assigned devices\n");
+ exit (1);
+ }
+ }
+#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+
+}
+
static void ipf_init_pci(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char *kernel_filename,
@@ -695,3 +713,8 @@ void ioapic_set_irq(void *opaque, int irq_num, int level)
return;
}
}
+
+int ipf_map_irq(PCIDevice *pci_dev, int irq_num)
+{
+ return ioapic_map_irq(pci_dev->devfn, irq_num);
+}
diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h
index fddfdfa..074195d 100644
--- a/qemu/hw/pc.h
+++ b/qemu/hw/pc.h
@@ -118,6 +118,8 @@ int piix4_init(PCIBus *bus, int devfn);
int piix_get_irq(int pin);
+int ipf_map_irq(PCIDevice *pci_dev, int irq_num);
+
/* vga.c */
enum vga_retrace_method {
VGA_RETRACE_DUMB,
diff --git a/qemu/vl.c b/qemu/vl.c
index 561e254..c383587 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8694,7 +8694,7 @@ static void help(int exitcode)
#endif
"-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
"-no-kvm-pit disable KVM kernel mode PIT\n"
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
"-pcidevice host=bus:dev.func[,dma=none][,name=string]\n"
" expose a PCI device to the guest OS.\n"
" dma=none: don't perform any dma translations (default is to use an iommu)\n"
@@ -8819,7 +8819,7 @@ enum {
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
QEMU_OPTION_no_kvm_pit,
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
QEMU_OPTION_pcidevice,
#endif
QEMU_OPTION_no_reboot,
@@ -8911,7 +8911,7 @@ static const QEMUOption qemu_options[] = {
#endif
{ "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
{ "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
{ "pcidevice", HAS_ARG, QEMU_OPTION_pcidevice },
#endif
#endif
@@ -9859,7 +9859,7 @@ int main(int argc, char **argv)
kvm_pit = 0;
break;
}
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
case QEMU_OPTION_pcidevice:
if (assigned_devices_index >= MAX_DEV_ASSIGN_CMDLINE) {
fprintf(stderr, "Too many assigned devices\n");
--
1.6.0
[-- Attachment #2: 0001-KVM-Userspace-Make-device-assignment-work-for-kvm.patch --]
[-- Type: application/octet-stream, Size: 6300 bytes --]
From 45b40eecff85b9a7ae4caf4ae184905a79e5a139 Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Fri, 7 Nov 2008 18:13:13 +0800
Subject: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
kvm/ia64 have supported vt-d support from 2.6.28rc1, this patch
enables its userspace's support.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
kernel/ia64/Kbuild | 4 ++++
qemu/Makefile.target | 7 ++++---
qemu/hw/device-assignment.c | 4 ++++
qemu/hw/ipf.c | 27 +++++++++++++++++++++++++--
qemu/hw/pc.h | 2 ++
qemu/vl.c | 8 ++++----
6 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/kernel/ia64/Kbuild b/kernel/ia64/Kbuild
index e9660ba..88eaa39 100644
--- a/kernel/ia64/Kbuild
+++ b/kernel/ia64/Kbuild
@@ -3,6 +3,10 @@ obj-m := kvm.o kvm-intel.o
kvm-objs := kvm_main.o ioapic.o coalesced_mmio.o kvm-ia64.o kvm_fw.o \
irq_comm.o ../anon_inodes.o ../external-module-compat.o
+ifeq ($(CONFIG_DMAR),y)
+kvm-objs += vtd.o
+endif
+
EXTRA_CFLAGS_vcpu.o += -mfixed-range=f2-f5,f12-f127
kvm-intel-objs := vmm.o vmm_ivt.o trampoline.o vcpu.o optvfault.o mmio.o \
vtlb.o process.o memset.o memcpy.o
diff --git a/qemu/Makefile.target b/qemu/Makefile.target
index d504b75..229b1c6 100644
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -720,15 +720,16 @@ OBJS += virtio.o virtio-net.o virtio-blk.o virtio-balloon.o
OBJS += device-hotplug.o
+ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
+OBJS+= device-assignment.o
+endif
+
ifeq ($(TARGET_BASE_ARCH), i386)
# Hardware support
OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o extboot.o
-ifeq ($(USE_KVM_DEVICE_ASSIGNMENT), 1)
-OBJS+= device-assignment.o
-endif
ifeq ($(USE_KVM_PIT), 1)
OBJS+= i8254-kvm.o
endif
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 78b7e14..5cda7d9 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -457,6 +457,10 @@ void assigned_dev_update_irq(PCIDevice *d)
irq = pci_map_irq(&assigned_dev->dev, assigned_dev->intpin);
irq = piix_get_irq(irq);
+#ifdef TARGET_IA64
+ irq = ipf_map_irq(d, irq);
+#endif
+
if (irq != assigned_dev->girq) {
struct kvm_assigned_irq assigned_irq_data;
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index 337c854..f4a2853 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -38,6 +38,7 @@
#include "firmware.h"
#include "ia64intrin.h"
#include <unistd.h>
+#include "device-assignment.h"
#include "qemu-kvm.h"
@@ -450,7 +451,6 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
/*Load firware to its proper position.*/
if (kvm_enabled()) {
- int r;
unsigned long image_size;
char *image = NULL;
uint8_t *fw_image_start;
@@ -645,8 +645,26 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size,
unit_id++;
}
}
-}
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
+ if (kvm_enabled()) {
+ int i;
+ for (i = 0; i < assigned_devices_index; i++) {
+ if (add_assigned_device(assigned_devices[i]) < 0) {
+ fprintf(stderr, "Warning: could not add assigned device %s\n",
+ assigned_devices[i]);
+ }
+ }
+
+ if (init_all_assigned_devices(pci_bus)) {
+ fprintf(stderr, "Failed to initialize assigned devices\n");
+ exit (1);
+ }
+ }
+#endif /* USE_KVM_DEVICE_ASSIGNMENT */
+
+}
+
static void ipf_init_pci(ram_addr_t ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char *kernel_filename,
@@ -695,3 +713,8 @@ void ioapic_set_irq(void *opaque, int irq_num, int level)
return;
}
}
+
+int ipf_map_irq(PCIDevice *pci_dev, int irq_num)
+{
+ return ioapic_map_irq(pci_dev->devfn, irq_num);
+}
diff --git a/qemu/hw/pc.h b/qemu/hw/pc.h
index fddfdfa..074195d 100644
--- a/qemu/hw/pc.h
+++ b/qemu/hw/pc.h
@@ -118,6 +118,8 @@ int piix4_init(PCIBus *bus, int devfn);
int piix_get_irq(int pin);
+int ipf_map_irq(PCIDevice *pci_dev, int irq_num);
+
/* vga.c */
enum vga_retrace_method {
VGA_RETRACE_DUMB,
diff --git a/qemu/vl.c b/qemu/vl.c
index 561e254..c383587 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8694,7 +8694,7 @@ static void help(int exitcode)
#endif
"-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
"-no-kvm-pit disable KVM kernel mode PIT\n"
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
"-pcidevice host=bus:dev.func[,dma=none][,name=string]\n"
" expose a PCI device to the guest OS.\n"
" dma=none: don't perform any dma translations (default is to use an iommu)\n"
@@ -8819,7 +8819,7 @@ enum {
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
QEMU_OPTION_no_kvm_pit,
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
QEMU_OPTION_pcidevice,
#endif
QEMU_OPTION_no_reboot,
@@ -8911,7 +8911,7 @@ static const QEMUOption qemu_options[] = {
#endif
{ "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
{ "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
{ "pcidevice", HAS_ARG, QEMU_OPTION_pcidevice },
#endif
#endif
@@ -9859,7 +9859,7 @@ int main(int argc, char **argv)
kvm_pit = 0;
break;
}
-#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64) || defined(__linux__)
case QEMU_OPTION_pcidevice:
if (assigned_devices_index >= MAX_DEV_ASSIGN_CMDLINE) {
fprintf(stderr, "Too many assigned devices\n");
--
1.6.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
2008-11-07 10:25 [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64 Zhang, Xiantao
@ 2008-11-09 10:07 ` Avi Kivity
2008-11-10 5:47 ` Amit Shah
1 sibling, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2008-11-09 10:07 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-ia64@vger.kernel.org, kvm@vger.kernel.org
Zhang, Xiantao wrote:
> From 45b40eecff85b9a7ae4caf4ae184905a79e5a139 Mon Sep 17 00:00:00 2001
> From: Xiantao Zhang <xiantao.zhang@intel.com>
> Date: Fri, 7 Nov 2008 18:13:13 +0800
> Subject: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
>
> kvm/ia64 have supported vt-d from 2.6.28rc1, this patch
> enables its userspace's support.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
2008-11-07 10:25 [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64 Zhang, Xiantao
2008-11-09 10:07 ` Avi Kivity
@ 2008-11-10 5:47 ` Amit Shah
2008-11-10 5:51 ` Zhang, Xiantao
1 sibling, 1 reply; 4+ messages in thread
From: Amit Shah @ 2008-11-10 5:47 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: Avi Kivity, kvm-ia64@vger.kernel.org, kvm@vger.kernel.org
* On Friday 07 Nov 2008 15:55:18 Zhang, Xiantao wrote:
> --- a/qemu/vl.c
> +++ b/qemu/vl.c
> @@ -8694,7 +8694,7 @@ static void help(int exitcode)
> #endif
> "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
> "-no-kvm-pit disable KVM kernel mode PIT\n"
> -#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(__linux__)
> +#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_IA64)
> || defined(__linux__) "-pcidevice
It would be better to use #if defined (USE_KVM_DEVICE_ASSIGNMENT) here (and in
the rest of the file) instead of adding architectures to this list as is done
in the Makefile.
Amit
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64.
2008-11-10 5:47 ` Amit Shah
@ 2008-11-10 5:51 ` Zhang, Xiantao
0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Xiantao @ 2008-11-10 5:51 UTC (permalink / raw)
To: Amit Shah; +Cc: Avi Kivity, kvm-ia64@vger.kernel.org, kvm@vger.kernel.org
Amit Shah wrote:
> * On Friday 07 Nov 2008 15:55:18 Zhang, Xiantao wrote:
>
>> --- a/qemu/vl.c
>> +++ b/qemu/vl.c
>> @@ -8694,7 +8694,7 @@ static void help(int exitcode) #endif
>> "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
>> "-no-kvm-pit disable KVM kernel mode PIT\n"
>> -#if defined(TARGET_I386) || defined(TARGET_X86_64) ||
>> defined(__linux__) +#if defined(TARGET_I386) ||
>> defined(TARGET_X86_64) || defined(TARGET_IA64)
>>>> defined(__linux__) "-pcidevice
>
> It would be better to use #if defined (USE_KVM_DEVICE_ASSIGNMENT)
> here (and in the rest of the file) instead of adding architectures to
> this list as is done in the Makefile.
Agree. Good suggestion! And I just follow the original style, maybe needs a cleanup.
Xiantao
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-10 5:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-07 10:25 [PATCH] KVM: Userspace: Make device-assignment work for kvm/ia64 Zhang, Xiantao
2008-11-09 10:07 ` Avi Kivity
2008-11-10 5:47 ` Amit Shah
2008-11-10 5:51 ` Zhang, Xiantao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox