uq/master: Introduce basic irqchip support
RFC PATCH 3/16 apic: Stop timer on reset
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
All LVTs are masked on reset, so the timer becomes ineffective. Letting it tick nevertheless is harmless, but will at least create a spurious trace event.
--- hw/apic.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
hw/apic.c +2 -0
@@ -528,6 +528,8 @@ void apic_init_reset(DeviceState *d) s->initial_count_load_time =0 ; s->next_time =0 ; s->wait_for_sipi =1 ; + +qemu_del_timer (s->timer); }static void apic_startup (APICState *s,int vector_num)
Signature · 1 line
1.7.3.4
RFC PATCH 5/16 apic: Open-code timer save/restore
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
To enable migration between accelerated and non-accelerated APIC models, we will need to handle the timer saving and restoring specially and can no longer rely on the automatics of VMSTATE_TIMER. Specifically, accelerated model will not start any QEMUTimer.
This patch therefore factors out the generic bits into apic_next_timer and introduces a post-load callback that can be implemented differently by both models.
--- hw/apic.c | 30 ++++++++++++------------------ hw/apic_common.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- hw/apic_internal.h | 3 +++ 3 files changed, 64 insertions(+), 20 deletions(-)
hw/apic.c +12 -18
@@ -516,25 +516,9 @@ static uint32_t apic_get_current_count(APICState *s)static void apic_timer_update (APICState *s,int64_t current_time) { -int64_t next_time, d; - -if (!(s->lvt[APIC_LVT_TIMER ] &APIC_LVT_MASKED )) { - d = (current_time - s->initial_count_load_time) >> - s->count_shift; -if (s->lvt[APIC_LVT_TIMER ] &APIC_LVT_TIMER_PERIODIC ) { -if (!s->initial_count) - goto no_timer; - d = ((d / ((uint64_t )s->initial_count +1 )) +1 ) * ((uint64_t )s->initial_count +1 ); - }else { -if (d >= s->initial_count) - goto no_timer; - d = (uint64_t )s->initial_count +1 ; - } - next_time = s->initial_count_load_time + (d << s->count_shift); -qemu_mod_timer (s->timer, next_time); - s->next_time = next_time; +if (apic_next_timer (s, current_time)) { +qemu_mod_timer (s->timer, s->next_time); }else { - no_timer:qemu_del_timer (s->timer); } }
@@ -756,6 +740,15 @@ static const MemoryRegionOps apic_io_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static void apic_post_load (APICState *s) +{ +if (s->timer_expiry !=-1 ) { +qemu_mod_timer (s->timer, s->timer_expiry); + }else { +qemu_del_timer (s->timer); + } +} +static int apic_init (SysBusDevice *dev) {APICState *s =FROM_SYSBUS (APICState, dev);
@@ -772,6 +765,7 @@ static int apic_init(SysBusDevice *dev) s->timer =qemu_new_timer_ns (vm_clock, apic_timer, s); s->set_base = apic_set_base; s->set_tpr = apic_set_tpr; + s->post_load = apic_post_load; local_apics[s->idx] = s;return 0 ; }
hw/apic_common.c +49 -2
81 lines not on this page · raw message
hw/apic_internal.h +3 -0
@@ -92,17 +92,20 @@ struct APICState {int64_t next_time;int idx;QEMUTimer *timer; +int64_t timer_expiry;int sipi_vector;int wait_for_sipi;void (*set_base)(APICState *s,uint64_t val);void (*set_tpr)(APICState *s,uint8_t val); + void (*post_load)(APICState *s); };extern const VMStateDescription vmstate_apic;int apic_init_common (APICState *s);void apic_reset (DeviceState *d); +bool apic_next_timer (APICState *s,int64_t current_time);void apic_set_irq_delivered (int delivered);#endif /* !QEMU_APIC_INTERNAL_H */
Signature · 1 line
1.7.3.4
RFC PATCH 10/16 memory: Introduce memory_region_init_reservation
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Introduce a memory region type that can reserve I/O space. Such regions are useful for modeling I/O that is only handled outside of QEMU, i.e. in the context of an accelerator like KVM. Any access to such a region from QEMU is a bug and will be reported as such.
--- memory.c | 35 +++++++++++++++++++++++++++++++++++ memory.h | 15 +++++++++++++++ 2 files changed, 50 insertions(+), 0 deletions(-)
memory.c +35 -0
@@ -1003,6 +1003,41 @@ void memory_region_init_rom_device(MemoryRegion *mr, mr->backend_registered = true; } +static uint64_t invalid_read (void *opaque,target_phys_addr_t addr, +unsigned size) +{ +MemoryRegion *mr = opaque; + +fprintf (stderr,"Invalid read from memory region %s\n" , mr->name); +abort (); +} + +static void invalid_write (void *opaque,target_phys_addr_t addr,uint64_t data, +unsigned size) +{ +MemoryRegion *mr = opaque; + +fprintf (stderr,"Invalid write to memory region %s\n" , mr->name); +abort (); +} + +static const MemoryRegionOps reservation_ops = { + .read = invalid_read, + .write = invalid_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; + +void memory_region_init_reservation (MemoryRegion *mr, +const char *name, +uint64_t size) +{ +memory_region_init (mr, name, size); + mr->ops = &reservation_ops; + mr->opaque = mr; + mr->terminates = true; + mr->backend_registered = false; +} +void memory_region_destroy (MemoryRegion *mr) {assert (QTAILQ_EMPTY (&mr->subregions));
memory.h +15 -0
@@ -242,6 +242,21 @@ void memory_region_init_rom_device(MemoryRegion *mr, uint64_t size);/** +* memory_region_init_reservation: Initialize a memory region that reserves +* I/O space. +* +* A reservation region primariy serves debugging purposes. It claims I/O +* space that is not supposed to be handled by QEMU itself. Any access via +* the memory API will cause an abort(). +* +* @mr: the #MemoryRegion to be initialized +* @name: used for debugging; not visible to the user or ABI +* @size: size of the region. +*/ +void memory_region_init_reservation (MemoryRegion *mr, +const char *name, +uint64_t size); +/** * memory_region_destroy: Destroy a memory region and relaim all resources. * * @mr: the region to be destroyed. May not currently be a subregion
Signature · 1 line
1.7.3.4
cover uq/master: Introduce basic irqchip support
Some weeks back I posted my MSI rework for qemu-kvm that shall once help integrating those bits into upstream. After that I wondered how a rewritten in-kernel irqchip model could look like and make use of this. But then I realized that there is actually no technical need to role out a first version of kvm irqchips that already support MSI. As the MSI thing will likely take a few more iterations, I now decided to rush forward with basic kvm irqchip for QEMU upstream. Here we go.
My idea was always to create proper alternatives to the existing user space device models while keeping the vmstates 100% compatible. I think I succeeded in this, tests worked fine so far. The kvm and the user space models now have a common core where they share logic and specific code modules where they differ. Also, I moved all kvm devices into hw/kvm.
The in-kernel irqchip support can be controlled via a machine property (-machine ...,kernel_irqchip=on), in contrast to qemu-kvm's dedicated command line switch. This series keeps the support off by default because we still lack the MSI bits as I explained. Also, in-kernel PIT is not yet implemented and TPR patching/VAPIC (for Windows guests).
The merge story would basically look similar to what we did before with the clean-room reimplementation of kvm for QEMU: Merge into upstream, merge back into qemu-kvm, disabling the new bits for now, then gradually switching over to the new services, specifically once they are feature-equivalent. Of course, I will support these steps as usual.
So, feedback and review welcome!
Jan Kiszka (16):
msi: Generalize msix_supported to msi_supported
kvm: Move kvmclock into hw/kvm folder
apic: Stop timer on reset
apic: Factor out core for KVM reuse
apic: Open-code timer save/restore
i8259: Factor out core for KVM reuse
ioapic: Convert to memory API
ioapic: Reject non-dword accesses to IOWIN register
ioapic: Factor out core for KVM reuse
memory: Introduce memory_region_init_reservation
kvm: Introduce core services for in-kernel irqchip support
kvm: x86: Establish IRQ0 override control
kvm: x86: Add user space part for in-kernel APIC
kvm: x86: Add user space part for in-kernel i8259
kvm: x86: Add user space part for in-kernel IOAPIC
kvm: Arm in-kernel irqchip support
Makefile.objs | 2 +-
Makefile.target | 6 +-
configure | 1 +
hw/apic.c | 288 ++++------------------------------------
hw/apic_common.c | 262 ++++++++++++++++++++++++++++++++++++
hw/apic_internal.h | 111 +++++++++++++++
hw/i8259.c | 78 +-----------
hw/i8259_common.c | 103 ++++++++++++++
hw/i8259_internal.h | 67 +++++++++
hw/ioapic.c | 136 +++----------------
hw/ioapic_common.c | 89 ++++++++++++
hw/ioapic_internal.h | 94 +++++++++++++
hw/kvm/apic.c | 147 ++++++++++++++++++++
hw/{kvmclock.c => kvm/clock.c} | 10 +-
hw/{kvmclock.h => kvm/clock.h} | 0
hw/kvm/i8259.c | 154 +++++++++++++++++++++
hw/kvm/ioapic.c | 120 +++++++++++++++++
hw/msi.c | 8 +
hw/msi.h | 2 +
hw/msix.c | 9 +-
hw/msix.h | 2 -
hw/pc.c | 20 ++-
hw/pc.h | 1 +
hw/pc_piix.c | 67 +++++++++-
kvm-all.c | 154 +++++++++++++++++++++
kvm-stub.c | 5 +
kvm.h | 13 ++
memory.c | 35 +++++
memory.h | 15 ++
qemu-config.c | 4 +
qemu-options.hx | 5 +-
sysemu.h | 1 -
target-i386/kvm.c | 19 +++
trace-events | 2 +-
vl.c | 1 -
35 files changed, 1548 insertions(+), 483 deletions(-)
create mode 100644 hw/apic_common.c
create mode 100644 hw/apic_internal.h
create mode 100644 hw/i8259_common.c
create mode 100644 hw/i8259_internal.h
create mode 100644 hw/ioapic_common.c
create mode 100644 hw/ioapic_internal.h
create mode 100644 hw/kvm/apic.c
rename hw/{kvmclock.c => kvm/clock.c} (96%)
rename hw/{kvmclock.h => kvm/clock.h} (100%)
create mode 100644 hw/kvm/i8259.c
create mode 100644 hw/kvm/ioapic.cSignature · 1 line
1.7.3.4
RFC PATCH 1/16 msi: Generalize msix_supported to msi_supported
From: Jan Kiszka <[email protected]>
Rename msix_supported to msi_supported and control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.
--- hw/msi.c | 8 ++++++++ hw/msi.h | 2 ++ hw/msix.c | 9 ++++----- hw/msix.h | 2 -- hw/pc.c | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-)
hw/msi.c +8 -0
@@ -36,6 +36,9 @@#define PCI_MSI_VECTORS_MAX 32 +/* Flag for interrupt controller to declare MSI/MSI-X support */ +bool msi_supported; +/* If we get rid of cap allocator, we won't need this. */ static inline uint8_t msi_cap_sizeof (uint16_t flags) {
@@ -116,6 +119,11 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,uint16_t flags;uint8_t cap_size;int config_offset; + +if (!msi_supported) { +return -ENOTSUP ; + } + MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n",
hw/msi.h +2 -0
@@ -24,6 +24,8 @@#include "qemu-common.h" #include "pci.h" +extern bool msi_supported; +bool msi_enabled (const PCIDevice *dev);int msi_init (struct PCIDevice *dev,uint8_t offset,unsigned int nr_vectors,bool msi64bit,bool msi_per_vector_mask);
hw/msix.c +4 -5
@@ -12,6 +12,7 @@*/ #include "hw.h" +#include "msi.h" #include "msix.h" #include "pci.h" #include "range.h"
@@ -32,9 +33,6 @@#define MSIX_MAX_ENTRIES 32 -/* Flag for interrupt controller to declare MSI-X support */ -int msix_supported; -/* Add MSI-X capability to the config space for the device. */ /* Given a bar and its size, add MSI-X table on top of it * and fill MSI-X capability in the config space.
@@ -212,10 +210,11 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, unsigned bar_nr, unsigned bar_size) { int ret; +/* Nothing to do if MSI is not supported by interrupt controller */ -if (!msix_supported) +if (!msi_supported) {return -ENOTSUP ; - + }if (nentries >MSIX_MAX_ENTRIES )return -EINVAL ;
hw/msix.h +0 -2
@@ -29,6 +29,4 @@ void msix_notify(PCIDevice *dev, unsigned vector);void msix_reset (PCIDevice *dev); -extern int msix_supported; -#endif
hw/pc.c +2 -2
@@ -36,7 +36,7 @@#include "elf.h" #include "multiboot.h" #include "mc146818rtc.h" -#include "msix.h" +#include "msi.h" #include "sysbus.h" #include "sysemu.h" #include "blockdev.h"
@@ -896,7 +896,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) apic_mapped =1 ; } - msix_supported =1 ; + msi_supported = true;return dev; }
Signature · 1 line
1.7.3.4
RFC PATCH 2/16 kvm: Move kvmclock into hw/kvm folder
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
More KVM-specific devices will come, so let's start with moving the kvmclock into a dedicated folder.
---
Makefile.target | 4 ++--
configure | 1 +
hw/{kvmclock.c => kvm/clock.c} | 10 +++++-----
hw/{kvmclock.h => kvm/clock.h} | 0
hw/pc_piix.c | 2 +-
5 files changed, 9 insertions(+), 8 deletions(-)
rename hw/{kvmclock.c => kvm/clock.c} (96%)
rename hw/{kvmclock.h => kvm/clock.h} (100%)Makefile.target +2 -2
@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvmclock.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objects
@@ -421,7 +421,7 @@ qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx clean: rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o - rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o + rm -f *.d */*.d tcg/*.o ide/*.o 9pfs/*.o kvm/*.o rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c ifdef CONFIG_TRACE_SYSTEMTAP rm -f *.stp
configure +1 -0
@@ -3220,6 +3220,7 @@ mkdir -p $target_dir/fpu mkdir -p $target_dir/tcg mkdir -p $target_dir/ide mkdir -p $target_dir/9pfs +mkdir -p $target_dir/kvm if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then mkdir -p $target_dir/nwfpe fi
hw/kvm/clock.c renamed from hw/kvmclock.c +5 -5
@@ -11,11 +11,11 @@* */ -#include "qemu-common.h" -#include "sysemu.h" -#include "sysbus.h" -#include "kvm.h" -#include "kvmclock.h" +#include <qemu-common.h> +#include <sysemu.h> +#include <kvm.h> +#include <hw/sysbus.h> +#include <hw/kvm/clock.h> #include <linux/kvm.h> #include <linux/kvm_para.h>
hw/kvm/clock.h renamed from hw/kvmclock.h +0 -0
hw/pc_piix.c +1 -1
@@ -34,7 +34,7 @@#include "boards.h" #include "ide.h" #include "kvm.h" -#include "kvmclock.h" +#include "kvm/clock.h" #include "sysemu.h" #include "sysbus.h" #include "arch_init.h"
Signature · 1 line
1.7.3.4
RFC PATCH 4/16 apic: Factor out core for KVM reuse
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
The KVM in-kernel APIC model will reuse parts of the user space model, namely the vmstate, reset handling, IRQ coalescing tracker, some init steps and the base and tpr set/get routines. For the latter, we also prepare set callbacks as KVM will override those.
--- Makefile.target | 2 +- hw/apic.c | 260 +++------------------------------------------------- hw/apic_common.c | 215 +++++++++++++++++++++++++++++++++++++++++++ hw/apic_internal.h | 108 ++++++++++++++++++++++ trace-events | 2 +- 5 files changed, 339 insertions(+), 248 deletions(-) create mode 100644 hw/apic_common.c create mode 100644 hw/apic_internal.h
Makefile.target +1 -1
@@ -226,7 +226,7 @@ obj-$(CONFIG_IVSHMEM) += ivshmem.o # Hardware support obj-i386-y += vga.o obj-i386-y += mc146818rtc.o pc.o -obj-i386-y += cirrus_vga.o sga.o apic.o ioapic.o piix_pci.o +obj-i386-y += cirrus_vga.o sga.o apic_common.o apic.o ioapic.o piix_pci.o obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o
hw/apic.c +14 -246
335 lines not on this page · raw message
hw/apic_common.c new file +215 -0
215 lines not on this page · raw message
hw/apic_internal.h new file +108 -0
108 lines not on this page · raw message
trace-events +1 -1
@@ -97,7 +97,7 @@ apic_mem_writel(uint64_t addr, uint32_t val) "%"PRIx64" = %08x" # coalescing apic_reset_irq_delivered(int apic_irq_delivered) "old coalescing %d" apic_get_irq_delivered(int apic_irq_delivered) "returning coalescing %d" -apic_set_irq(int apic_irq_delivered) "coalescing %d" +apic_set_irq_delivered(int apic_irq_delivered) "coalescing %d" # hw/cs4231.c cs4231_mem_readl_dreg(uint32_t reg, uint32_t ret) "read dreg %d: 0x%02x"
Signature · 1 line
1.7.3.4
RFC PATCH 6/16 i8259: Factor out core for KVM reuse
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Analogously to the APIC, we will reuse some parts of the user space i8259 model for KVM. In this case it is the PicState, vmstate description, a reset core and some init bits.
--- Makefile.objs | 2 +- hw/i8259.c | 78 +------------------------------------- hw/i8259_common.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/i8259_internal.h | 67 +++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+), 76 deletions(-) create mode 100644 hw/i8259_common.c create mode 100644 hw/i8259_internal.h
Makefile.objs +1 -1
@@ -220,7 +220,7 @@ hw-obj-$(CONFIG_APPLESMC) += applesmc.o hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o hw-obj-$(CONFIG_USB_REDIR) += usb-redir.o -hw-obj-$(CONFIG_I8259) += i8259.o +hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o # PPC devices hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o
hw/i8259.c +3 -75
112 lines not on this page · raw message
hw/i8259_common.c new file +103 -0
103 lines not on this page · raw message
hw/i8259_internal.h new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
1.7.3.4
RFC PATCH 7/16 ioapic: Convert to memory API
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This maintains the old imprecise access size handling.
--- hw/ioapic.c | 28 +++++++++++----------------- 1 files changed, 11 insertions(+), 17 deletions(-)
hw/ioapic.c +11 -17
@@ -86,6 +86,7 @@ typedef struct IOAPICState IOAPICState;struct IOAPICState {SysBusDevice busdev; +MemoryRegion io_memory;uint8_t id;uint8_t ioregsel;uint32_t irr;
@@ -195,7 +196,8 @@ void ioapic_eoi_broadcast(int vector) } } -static uint32_t ioapic_mem_readl (void *opaque,target_phys_addr_t addr) +static uint64_t +ioapic_mem_read (void *opaque,target_phys_addr_t addr,unsigned int size) {IOAPICState *s = opaque;int index;
@@ -234,7 +236,8 @@ static uint32_t ioapic_mem_readl(void *opaque, target_phys_addr_t addr) }static void -ioapic_mem_writel (void *opaque,target_phys_addr_t addr,uint32_t val) +ioapic_mem_write (void *opaque,target_phys_addr_t addr,uint64_t val, +unsigned int size) {IOAPICState *s = opaque;int index;
@@ -309,32 +312,23 @@ static void ioapic_reset(DeviceState *d) } } -static CPUReadMemoryFunc *const ioapic_mem_read[3 ] = { - ioapic_mem_readl, - ioapic_mem_readl, - ioapic_mem_readl, -}; - -static CPUWriteMemoryFunc *const ioapic_mem_write[3 ] = { - ioapic_mem_writel, - ioapic_mem_writel, - ioapic_mem_writel, +static const MemoryRegionOps ioapic_io_ops = { + .read = ioapic_mem_read, + .write = ioapic_mem_write, + .endianness =DEVICE_NATIVE_ENDIAN , };static int ioapic_init1 (SysBusDevice *dev) {IOAPICState *s =FROM_SYSBUS (IOAPICState, dev); -int io_memory;static int ioapic_no;if (ioapic_no >=MAX_IOAPICS ) {return -1 ; } - io_memory =cpu_register_io_memory (ioapic_mem_read, - ioapic_mem_write, s, -DEVICE_NATIVE_ENDIAN ); -sysbus_init_mmio (dev,0x1000 , io_memory); +memory_region_init_io (&s->io_memory, &ioapic_io_ops, s,"ioapic" ,0x1000 ); +sysbus_init_mmio_region (dev, &s->io_memory);qdev_init_gpio_in (&dev->qdev, ioapic_set_irq,IOAPIC_NUM_PINS );
Signature · 1 line
1.7.3.4
RFC PATCH 8/16 ioapic: Reject non-dword accesses to IOWIN register
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Aligns the model with the spec.
--- hw/ioapic.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/ioapic.c +6 -0
@@ -208,6 +208,9 @@ ioapic_mem_read(void *opaque, target_phys_addr_t addr, unsigned int size) val = s->ioregsel;break ;case IOAPIC_IOWIN : +if (size !=4 ) { +break ; + }switch (s->ioregsel) {case IOAPIC_REG_ID : val = s->id <<IOAPIC_ID_SHIFT ;
@@ -247,6 +250,9 @@ ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val, s->ioregsel = val;break ;case IOAPIC_IOWIN : +if (size !=4 ) { +break ; + }DPRINTF ("write: %08x = %08x\n" , s->ioregsel, val);switch (s->ioregsel) {case IOAPIC_REG_ID :
Signature · 1 line
1.7.3.4
RFC PATCH 9/16 ioapic: Factor out core for KVM reuse
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
KVM will share the IOAPICState, the vmstate, the reset logic and certain init parts with the user space model.
--- Makefile.target | 2 +- hw/ioapic.c | 108 ++++--------------------------------------------- hw/ioapic_common.c | 89 +++++++++++++++++++++++++++++++++++++++++ hw/ioapic_internal.h | 93 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 192 insertions(+), 100 deletions(-) create mode 100644 hw/ioapic_common.c create mode 100644 hw/ioapic_internal.h
Makefile.target +1 -1
@@ -226,7 +226,7 @@ obj-$(CONFIG_IVSHMEM) += ivshmem.o # Hardware support obj-i386-y += vga.o obj-i386-y += mc146818rtc.o pc.o -obj-i386-y += cirrus_vga.o sga.o apic_common.o apic.o ioapic.o piix_pci.o +obj-i386-y += cirrus_vga.o sga.o apic_common.o apic.o ioapic_common.o ioapic.o piix_pci.o obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o
hw/ioapic.c +9 -99
142 lines not on this page · raw message
hw/ioapic_common.c new file +89 -0
89 lines not on this page · raw message
hw/ioapic_internal.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
1.7.3.4
RFC PATCH 11/16 kvm: Introduce core services for in-kernel irqchip support
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes.
Routing is optional and depends on the host arch supporting KVM_CAP_IRQ_ROUTING. When it's not available on x86, we loose the HPET as we can't route GSI0 to IOAPIC pin 2.
In-kernel irqchip support will once be controlled by the machine property 'kernel_irqchip', but this is not yet wired up.
--- kvm-all.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ kvm.h | 8 +++ target-i386/kvm.c | 11 ++++ 3 files changed, 168 insertions(+), 0 deletions(-)
kvm-all.c +149 -0
@@ -76,6 +76,13 @@ struct KVMStateint pit_in_kernel;int xsave, xcrs;int many_ioeventfds; +int irqchip_inject_ioctl; +#ifdef KVM_CAP_IRQ_ROUTING +struct kvm_irq_routing *irq_routes; +int nr_allocated_irq_routes; +uint32_t *used_gsi_bitmap; +unsigned int max_gsi; +#endif };KVMState *kvm_state;
@@ -692,6 +699,138 @@ static void kvm_handle_interrupt(CPUState *env, int mask) } } +int kvm_irqchip_set_irq (KVMState *s,int irq,int level) +{ +struct kvm_irq_level event; +int ret; + +assert (s->irqchip_in_kernel); + + event.level = level; + event.irq = irq; + ret =kvm_vm_ioctl (s, s->irqchip_inject_ioctl, &event); +if (ret <0 ) { +perror ("kvm_set_irqchip_line" ); +abort (); + } + +return (s->irqchip_inject_ioctl ==KVM_IRQ_LINE ) ?1 : event.status; +} + +#ifdef KVM_CAP_IRQ_ROUTING +static void set_gsi (KVMState *s,unsigned int gsi) +{ +assert (gsi < s->max_gsi); + + s->used_gsi_bitmap[gsi /32 ] |=1U << (gsi %32 ); +} + +static void kvm_init_irq_routing (KVMState *s) +{ +int gsi_count; + + gsi_count =kvm_check_extension (s,KVM_CAP_IRQ_ROUTING ); +if (gsi_count >0 ) { +unsigned int gsi_bits, i; + +/* Round up so we can search ints using ffs */ + gsi_bits = (gsi_count +31 ) /32 ; + s->used_gsi_bitmap =g_malloc0 (gsi_bits /8 ); + s->max_gsi = gsi_bits; + +/* Mark any over-allocated bits as already in use */ +for (i = gsi_count; i < gsi_bits; i++) { +set_gsi (s, i); + } + } + + s->irq_routes =g_malloc0 (sizeof (*s->irq_routes)); + s->nr_allocated_irq_routes =0 ; + +kvm_arch_init_irq_routing (s); +} + +static void kvm_add_routing_entry (KVMState *s, +struct kvm_irq_routing_entry *entry) +{ +struct kvm_irq_routing_entry *new; +int n, size; + +if (s->irq_routes->nr == s->nr_allocated_irq_routes) { + n = s->nr_allocated_irq_routes *2 ; +if (n <64 ) { + n =64 ; + } + size =sizeof (struct kvm_irq_routing ); + size += n *sizeof (*new); + s->irq_routes =g_realloc (s->irq_routes, size); + s->nr_allocated_irq_routes = n; + } + n = s->irq_routes->nr++; + new = &s->irq_routes->entries[n]; +memset (new,0 ,sizeof (*new)); + new->gsi = entry->gsi; + new->type = entry->type; + new->flags = entry->flags; + new->u = entry->u; + +set_gsi (s, entry->gsi); +} + +void kvm_irqchip_add_route (KVMState *s,int irq,int irqchip,int pin) +{ +struct kvm_irq_routing_entry e; + + e.gsi = irq; + e.type =KVM_IRQ_ROUTING_IRQCHIP ; + e.flags =0 ; + e.u.irqchip.irqchip = irqchip; + e.u.irqchip.pin = pin; +kvm_add_routing_entry (s, &e); +} + +int kvm_irqchip_commit_routes (KVMState *s) +{ + s->irq_routes->flags =0 ; +return kvm_vm_ioctl (s,KVM_SET_GSI_ROUTING , s->irq_routes); +} + +#else /* !KVM_CAP_IRQ_ROUTING */ + +static void kvm_init_irq_routing (KVMState *s) +{ +} +#endif /* !KVM_CAP_IRQ_ROUTING */ + +static int kvm_irqchip_create (KVMState *s) +{ +QemuOptsList *list =qemu_find_opts ("machine" ); +int ret; + +if (QTAILQ_EMPTY (&list->head) || + !qemu_opt_get_bool (QTAILQ_FIRST (&list->head), +"kernel_irqchip" , false) || + !kvm_check_extension (s,KVM_CAP_IRQCHIP )) { +return 0 ; + } + + ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP ); +if (ret <0 ) { +fprintf (stderr,"Create kernel irqchip failed\n" ); +return ret; + } + + s->irqchip_inject_ioctl =KVM_IRQ_LINE ; +if (kvm_check_extension (s,KVM_CAP_IRQ_INJECT_STATUS )) { + s->irqchip_inject_ioctl =KVM_IRQ_LINE_STATUS ; + } + s->irqchip_in_kernel =1 ; + +kvm_init_irq_routing (s); + +return 0 ; +} +int kvm_init (void ) { static const char upgrade_note[] =
@@ -786,6 +925,11 @@ int kvm_init(void) goto err; } + ret =kvm_irqchip_create (s); +if (ret <0 ) { + goto err; + } + kvm_state = s;cpu_register_phys_memory_client (&kvm_cpu_phys_memory_client);
@@ -1111,6 +1255,11 @@ int kvm_has_many_ioeventfds(void)return kvm_state->many_ioeventfds; } +int kvm_has_gsi_routing (void ) +{ +return kvm_check_extension (kvm_state,KVM_CAP_IRQ_ROUTING ); +} +void kvm_setup_guest_memory (void *start,size_t size) {if (!kvm_has_sync_mmu ()) {
kvm.h +8 -0
@@ -51,6 +51,7 @@ int kvm_has_debugregs(void);int kvm_has_xsave (void );int kvm_has_xcrs (void );int kvm_has_many_ioeventfds (void ); +int kvm_has_gsi_routing (void );#ifdef NEED_CPU_H int kvm_init_vcpu (CPUState *env);
@@ -124,6 +125,13 @@ void kvm_arch_reset_vcpu(CPUState *env);int kvm_arch_on_sigbus_vcpu (CPUState *env,int code,void *addr);int kvm_arch_on_sigbus (int code,void *addr); +void kvm_arch_init_irq_routing (KVMState *s); + +int kvm_irqchip_set_irq (KVMState *s,int irq,int level); + +void kvm_irqchip_add_route (KVMState *s,int gsi,int irqchip,int pin); +int kvm_irqchip_commit_routes (KVMState *s); +struct kvm_guest_debug ;struct kvm_debug_exit_arch ;
target-i386/kvm.c +11 -0
@@ -1864,3 +1864,14 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env)return !(env->cr[0 ] &CR0_PE_MASK ) || ((env->segs[R_CS ].selector &3 ) !=3 ); } + +void kvm_arch_init_irq_routing (KVMState *s) +{ +if (!kvm_check_extension (s,KVM_CAP_IRQ_ROUTING )) { +/* If kernel can't do irq routing, interrupt source +* override 0->2 cannot be set up as required by HPET. +* So we have to disable it. +*/ + no_hpet =1 ; + } +}
Signature · 1 line
1.7.3.4
RFC PATCH 12/16 kvm: x86: Establish IRQ0 override control
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
KVM is forced to disable the IRQ0 override when we run with in-kernel irqchip but without IRQ routing support of the kernel. Set the fwcfg value correspondingly. This aligns us with qemu-kvm.
--- hw/pc.c | 3 ++- kvm-all.c | 5 +++++ kvm-stub.c | 5 +++++ kvm.h | 2 ++ sysemu.h | 1 - vl.c | 1 - 6 files changed, 14 insertions(+), 3 deletions(-)
hw/pc.c +2 -1
@@ -39,6 +39,7 @@#include "msi.h" #include "sysbus.h" #include "sysemu.h" +#include "kvm.h" #include "blockdev.h" #include "ui/qemu-spice.h" #include "memory.h"
@@ -609,7 +610,7 @@ static void *bochs_bios_init(void)fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size);fw_cfg_add_bytes (fw_cfg,FW_CFG_ACPI_TABLES , (uint8_t *)acpi_tables, acpi_tables_len); -fw_cfg_add_bytes (fw_cfg,FW_CFG_IRQ0_OVERRIDE , &irq0override,1 ); +fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); smbios_table =smbios_get_table (&smbios_len);if (smbios_table)
kvm-all.c +5 -0
@@ -1260,6 +1260,11 @@ int kvm_has_gsi_routing(void)return kvm_check_extension (kvm_state,KVM_CAP_IRQ_ROUTING ); } +int kvm_allows_irq0_override (void ) +{ +return !kvm_enabled () || !kvm_irqchip_in_kernel () ||kvm_has_gsi_routing (); +} +void kvm_setup_guest_memory (void *start,size_t size) {if (!kvm_has_sync_mmu ()) {
kvm-stub.c +5 -0
@@ -78,6 +78,11 @@ int kvm_has_many_ioeventfds(void)return 0 ; } +int kvm_allows_irq0_override (void ) +{ +return 1 ; +} +void kvm_setup_guest_memory (void *start,size_t size) { }
kvm.h +2 -0
@@ -53,6 +53,8 @@ int kvm_has_xcrs(void);int kvm_has_many_ioeventfds (void );int kvm_has_gsi_routing (void ); +int kvm_allows_irq0_override (void ); +#ifdef NEED_CPU_H int kvm_init_vcpu (CPUState *env);
sysemu.h +0 -1
@@ -102,7 +102,6 @@ extern int vga_interface_type;extern int graphic_width;extern int graphic_height;extern int graphic_depth; -extern uint8_t irq0override;extern DisplayType display_type;extern const char *keyboard_layout;extern int win2k_install_hack;
vl.c +0 -1
@@ -218,7 +218,6 @@ int no_reboot = 0;int no_shutdown =0 ;int cursor_hide =1 ;int graphic_rotate =0 ; -uint8_t irq0override =1 ;const char *watchdog;QEMUOptionRom option_rom[MAX_OPTION_ROMS ];int nb_option_roms;
Signature · 1 line
1.7.3.4
RFC PATCH 13/16 kvm: x86: Add user space part for in-kernel APIC
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This introduces the alternative APIC model 'kvm-apic' which makes use of KVM's in-kernel device model. MSI is not yet supported, so we disable this when the in-kernel model is in use.
--- Makefile.target | 2 +- hw/kvm/apic.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pc.c | 15 ++++-- kvm.h | 3 + target-i386/kvm.c | 8 +++ 5 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 hw/kvm/apic.c
Makefile.target +1 -1
@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvm/clock.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objects
hw/kvm/apic.c new file +147 -0
147 lines not on this page · raw message
hw/pc.c +10 -5
@@ -879,25 +879,30 @@ DeviceState *cpu_get_current_apic(void)static DeviceState *apic_init (void *env,uint8_t apic_id) {DeviceState *dev; -SysBusDevice *d;static int apic_mapped; - dev =qdev_create (NULL ,"apic" ); +if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { + dev =qdev_create (NULL ,"kvm-apic" ); + }else { + dev =qdev_create (NULL ,"apic" ); + }qdev_prop_set_uint8 (dev,"id" , apic_id);qdev_prop_set_ptr (dev,"cpu_env" , env);qdev_init_nofail (dev); - d =sysbus_from_qdev (dev);/* XXX: mapping more APICs at the same memory location */ if (apic_mapped ==0 ) {/* NOTE: the APIC is directly connected to the CPU - it is not on the global memory bus. */ /* XXX: what if the base changes? */ -sysbus_mmio_map (d,0 ,MSI_ADDR_BASE ); +sysbus_mmio_map (sysbus_from_qdev (dev),0 ,MSI_ADDR_BASE ); apic_mapped =1 ; } - msi_supported = true; +/* KVM does not support MSI yet. */ +if (!kvm_enabled () || !kvm_irqchip_in_kernel ()) { + msi_supported = true; + }return dev; }
kvm.h +3 -0
@@ -134,6 +134,9 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level);void kvm_irqchip_add_route (KVMState *s,int gsi,int irqchip,int pin);int kvm_irqchip_commit_routes (KVMState *s); +int kvm_put_apic (CPUState *env); +int kvm_get_apic (CPUState *env); +struct kvm_guest_debug ;struct kvm_debug_exit_arch ;
target-i386/kvm.c +8 -0
@@ -1435,6 +1435,10 @@ int kvm_arch_put_registers(CPUState *env, int level)if (ret <0 ) {return ret; } + ret =kvm_put_apic (env); +if (ret <0 ) { +return ret; + } } ret =kvm_put_vcpu_events (env, level);if (ret <0 ) {
@@ -1482,6 +1486,10 @@ int kvm_arch_get_registers(CPUState *env)if (ret <0 ) {return ret; } + ret =kvm_get_apic (env); +if (ret <0 ) { +return ret; + } ret =kvm_get_vcpu_events (env);if (ret <0 ) {return ret;
Signature · 1 line
1.7.3.4
RFC PATCH 14/16 kvm: x86: Add user space part for in-kernel i8259
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Introduce the alternative 'kvm-i8259' device model that exploits KVM in-kernel acceleration.
The PIIX3 initialization code is furthermore extended by KVM specific IRQ route setup. Moreover, GSI injection differs in KVM mode from the user space model. As we can dispatch ISA-range IRQs to both IOAPIC and PIC inside the kernel, we do not need to inject them separately. This is reflected by a KVM-specific GSI handler.
--- Makefile.target | 2 +- hw/kvm/i8259.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pc.h | 1 + hw/pc_piix.c | 50 ++++++++++++++++-- 4 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 hw/kvm/i8259.c
Makefile.target +1 -1
@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objects
hw/kvm/i8259.c new file +154 -0
154 lines not on this page · raw message
hw/pc.h +1 -0
@@ -63,6 +63,7 @@ bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,typedef struct PicState PicState ;extern PicState *isa_pic;qemu_irq *i8259_init (qemu_irq parent_irq); +qemu_irq *kvm_i8259_init (void );int pic_read_irq (PicState *s);int pic_get_output (PicState *s);void pic_info (Monitor *mon);
hw/pc_piix.c +46 -4
70 lines not on this page · raw message
Signature · 1 line
1.7.3.4
RFC PATCH 15/16 kvm: x86: Add user space part for in-kernel IOAPIC
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This introduces the KVM-accelerated IOAPIC model 'kvm-ioapic' and extends the IRQ routing setup by the 0->2 redirection when needed.
The kvm-ioapic model has a property that allows to define its GSI base for injecting interrupts into the kernel model. This will allow to disentangle PIC and IOAPIC pins for chipsets that support more sophisticated IRQ routes than the PIIX3. So far the base is kept at 0, i.e. PIC and IOAPIC share pins 0..15.
--- Makefile.target | 2 +- hw/ioapic_internal.h | 1 + hw/kvm/ioapic.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pc_piix.c | 15 ++++++- 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 hw/kvm/ioapic.c
Makefile.target +1 -1
@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o kvm/ioapic.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objects
hw/ioapic_internal.h +1 -0
@@ -83,6 +83,7 @@ struct IOAPICState {void (*pre_save)(IOAPICState *s);void (*post_load)(IOAPICState *s); +uint32_t kvm_gsi_base; };extern const VMStateDescription vmstate_ioapic;
hw/kvm/ioapic.c new file +120 -0
120 lines not on this page · raw message
hw/pc_piix.c +14 -1
@@ -68,6 +68,15 @@ static void kvm_piix3_setup_irq_routing(bool pci_enabled)for (i =8 ; i <16 ; ++i) {kvm_irqchip_add_route (s, i,KVM_IRQCHIP_PIC_SLAVE , i -8 ); } +if (pci_enabled) { +for (i =0 ; i <24 ; ++i) { +if (i ==0 ) { +kvm_irqchip_add_route (s, i,KVM_IRQCHIP_IOAPIC ,2 ); + }else if (i !=2 ) { +kvm_irqchip_add_route (s, i,KVM_IRQCHIP_IOAPIC , i); + } + } + } ret =kvm_irqchip_commit_routes (s);if (ret <0 ) {hw_error ("KVM IRQ routing setup failed" );
@@ -93,7 +102,11 @@ static void ioapic_init(GSIState *gsi_state)SysBusDevice *d;unsigned int i; - dev =qdev_create (NULL ,"ioapic" ); +if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { + dev =qdev_create (NULL ,"kvm-ioapic" ); + }else { + dev =qdev_create (NULL ,"ioapic" ); + }qdev_init_nofail (dev); d =sysbus_from_qdev (dev);sysbus_mmio_map (d,0 ,0xfec00000 );
Signature · 1 line
1.7.3.4
RFC PATCH 16/16 kvm: Arm in-kernel irqchip support
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Make the basic in-kernel irqchip support selectable via -machine ...,kernel_irqchip=on. Leave it off by default until it can fully replace user space models.
--- qemu-config.c | 4 ++++ qemu-options.hx | 5 ++++- 2 files changed, 8 insertions(+), 1 deletions(-)
qemu-config.c +4 -0
@@ -483,6 +483,10 @@ static QemuOptsList qemu_machine_opts = { .name = "accel", .type = QEMU_OPT_STRING, .help = "accelerator list", + }, { + .name = "kernel_irqchip", + .type = QEMU_OPT_BOOL, + .help = "use KVM in-kernel irqchip", }, {/* End of list */ } },
qemu-options.hx +4 -1
@@ -31,7 +31,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=]name[,prop[=value][,...]]\n" " selects emulated machine (-machine ? for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" - " supported accelerators are kvm, xen, tcg (default: tcg)\n", + " supported accelerators are kvm, xen, tcg (default: tcg)\n" + " kernel_irqchip=on|off controls accelerated irqchip support\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
@@ -44,6 +45,8 @@ This is used to enable an accelerator. Depending on the target architecture, kvm, xen, or tcg can be available. By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. +@item kernel_irqchip=on|off +Enables in-kernel irqchip support for the chosen accelerator when available. @end table ETEXI
Signature · 1 line
1.7.3.4
Re: [Qemu-devel] [RFC][PATCH 02/16] kvm: Move kvmclock into hw/kvm folder
In reply to Jan KiszkaAm 03.12.2011 12:17, schrieb Jan Kiszka:
Quoted 36 lines
From: Jan Kiszka <[email protected]>
More KVM-specific devices will come, so let's start with moving the kvmclock into a dedicated folder.
Signed-off-by Jan Kiszka <[email protected]>---
Makefile.target +1
-1@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvmclock.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objectshw/kvm/clock.c renamed from hw/kvmclock.c +0
-3@@ -11,11 +11,11 @@* */ -#include "qemu-common.h" -#include "sysemu.h" -#include "sysbus.h"
hw/kvm/clock.c line 21
Quoted 10 lines
hw/kvm/clock.c renamed from hw/kvmclock.c +5
-2-#include "kvm.h" -#include "kvmclock.h" +#include <qemu-common.h> +#include <sysemu.h> +#include <kvm.h> +#include <hw/sysbus.h> +#include <hw/kvm/clock.h> #include <linux/kvm.h> #include <linux/kvm_para.h>
Please don't start using system includes for everything. Rather extend QEMU_CFLAGS to contain the right user include path(s).
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [RFC][PATCH 02/16] kvm: Move kvmclock into hw/kvm folder
Quoted 45 lines · Andreas Färber
Am 03.12.2011 12:17, schrieb Jan Kiszka:
Quoted 44 lines
From: Jan Kiszka <[email protected]>
More KVM-specific devices will come, so let's start with moving the kvmclock into a dedicated folder.
Signed-off-by Jan Kiszka <[email protected]>---
Makefile.target +1
-1@@ -231,7 +231,7 @@ obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o obj-i386-y += pc_piix.o -obj-i386-$(CONFIG_KVM) += kvmclock.o +obj-i386-$(CONFIG_KVM) += kvm/clock.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o # shared objectshw/kvm/clock.c renamed from hw/kvmclock.c +5
-5@@ -11,11 +11,11 @@* */ -#include "qemu-common.h" -#include "sysemu.h" -#include "sysbus.h" -#include "kvm.h" -#include "kvmclock.h" +#include <qemu-common.h> +#include <sysemu.h> +#include <kvm.h> +#include <hw/sysbus.h> +#include <hw/kvm/clock.h>
Quoted 5 lines
hw/kvm/clock.c line 21
Quoted 2 lines
hw/kvm/clock.c renamed from hw/kvmclock.c +0
-0#include <linux/kvm.h> #include <linux/kvm_para.h> Please don't start using system includes for everything. Rather extend
QEMU_CFLAGSto contain the right user include path(s).
No problem - and no need to tweak any CFLAGS ("" only adds . to the header search paths).
Do we have a convention that every include in <> is considered system header? Should probably be documented then (and code should be converted gradually).
Jan
Re: [RFC][PATCH 01/16] msi: Generalize msix_supported to msi_supported
In reply to Jan KiszkaQuoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Rename
msix_supportedtomsi_supportedand control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.Signed-off-by Jan Kiszka <[email protected]>
This patch should go into qemu.git, right?
Quoted 118 lines
--- hw/msi.c | 8 ++++++++ hw/msi.h | 2 ++ hw/msix.c | 9 ++++----- hw/msix.h | 2 -- hw/pc.c | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-)hw/msi.c +8
-0@@ -36,6 +36,9 @@#define PCI_MSI_VECTORS_MAX 32 +/* Flag for interrupt controller to declare MSI/MSI-X support */ +bool msi_supported; +/* If we get rid of cap allocator, we won't need this. */ static inline uint8_t msi_cap_sizeof (uint16_t flags) {@@ -116,6 +119,11 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,uint16_t flags;uint8_t cap_size;int config_offset; + +if (!msi_supported) { +return -ENOTSUP ; + } + MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n",hw/msi.h +2
-0@@ -24,6 +24,8 @@#include "qemu-common.h" #include "pci.h" +extern bool msi_supported; +bool msi_enabled (const PCIDevice *dev);int msi_init (struct PCIDevice *dev,uint8_t offset,unsigned int nr_vectors,bool msi64bit,bool msi_per_vector_mask);hw/msix.c +4
-5@@ -12,6 +12,7 @@*/ #include "hw.h" +#include "msi.h" #include "msix.h" #include "pci.h" #include "range.h" @@ -32,9 +33,6 @@#define MSIX_MAX_ENTRIES 32 -/* Flag for interrupt controller to declare MSI-X support */ -int msix_supported; -/* Add MSI-X capability to the config space for the device. */ /* Given a bar and its size, add MSI-X table on top of it * and fill MSI-X capability in the config space. @@ -212,10 +210,11 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, unsigned bar_nr, unsigned bar_size) { int ret; +/* Nothing to do if MSI is not supported by interrupt controller */ -if (!msix_supported) +if (!msi_supported) {return -ENOTSUP ; - + }if (nentries >MSIX_MAX_ENTRIES )return -EINVAL ;hw/msix.h +0
-2@@ -29,6 +29,4 @@ void msix_notify(PCIDevice *dev, unsigned vector);void msix_reset (PCIDevice *dev); -extern int msix_supported; -#endif hw/pc.c +2
-2@@ -36,7 +36,7 @@#include "elf.h" #include "multiboot.h" #include "mc146818rtc.h" -#include "msix.h" +#include "msi.h" #include "sysbus.h" #include "sysemu.h" #include "blockdev.h" @@ -896,7 +896,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) apic_mapped =1 ; } - msix_supported =1 ; + msi_supported = true;return dev; }Signature · 1 line
1.7.3.4
Re: [RFC][PATCH 01/16] msi: Generalize msix_supported to msi_supported
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Rename
msix_supportedtomsi_supportedand control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.
Quoted 5 lines
Quoted 1 line
Signed-off-by Jan Kiszka <[email protected]>This patch should go into qemu.git, right?
Right. It was just that this series depends on it. Feel free to pick it up earlier.
Jan
Re: [Qemu-devel] [RFC][PATCH 02/16] kvm: Move kvmclock into hw/kvm folder
In reply to Jan KiszkaQuoted 3 lines · Jan Kiszka
Do we have a convention that every include in <> is considered system header? Should probably be documented then (and code should be converted gradually).
It's documented in "The C Programming Language", by K&R.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC][PATCH 02/16] kvm: Move kvmclock into hw/kvm folder
Quoted 6 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Do we have a convention that every include in <> is considered system header? Should probably be documented then (and code should be converted gradually).
It's documented in "The C Programming Language", by K&R.
It's just a convention, nothing more. If you consider certain parts of QEMU's API as system (e.g. the parts that may once make our modular API), it makes some sense to use <> for. Right now this happens for some parts of the hw API. But inconsistently.
Jan
Re: [RFC][PATCH 01/16] msi: Generalize msix_supported to msi_supported
In reply to Jan KiszkaQuoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Rename
msix_supportedtomsi_supportedand control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.
'and' is a dangerous word in a changelog entry.
hw/msi.c int msi_init(struct PCIDevice *dev, uint8_t offset, · line 126
Quoted 7 lines
hw/msi.c +5
-0+ +if (!msi_supported) { +return -ENOTSUP ; + } +
This changes behaviour. qemu 1.0 -M pc-1.0 and qemu-1.1 -M pc-1.0 will be different after this, no?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 01/16] msi: Generalize msix_supported to msi_supported
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Rename
msix_supportedtomsi_supportedand control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.'and' is a dangerous word in a changelog entry.
This patch hardly qualifies for two IMHO.
Quoted 12 lines
hw/msi.c int msi_init(struct PCIDevice *dev, uint8_t offset, · line 126
Quoted 8 lines
hw/msi.c +5
-0+ +if (!msi_supported) { +return -ENOTSUP ; + } +This changes behaviour. qemu 1.0 -M pc-1.0 and qemu-1.1 -M pc-1.0 will be different after this, no?
Only isapc had msix_supported = 0, and I doubt we got there (msi_init) for that machine. Or am I missing something?
Jan
Re: [RFC][PATCH 10/16] memory: Introduce memory_region_init_reservation
In reply to Jan KiszkaQuoted 6 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce a memory region type that can reserve I/O space. Such regions are useful for modeling I/O that is only handled outside of QEMU, i.e. in the context of an accelerator like KVM. Any access to such a region from QEMU is a bug and will be reported as such.
This is guest triggerable (DMA into the region), so abort() is too drastic.
memory.c void memory_region_init_rom_device(MemoryRegion *mr, · line 1039
Quoted 10 lines
memory.c +10
-0+void memory_region_init_reservation (MemoryRegion *mr, +const char *name, +uint64_t size) +{ +memory_region_init (mr, name, size); + mr->ops = &reservation_ops; + mr->opaque = mr; + mr->terminates = true; + mr->backend_registered = false; +}
Just calling memory_region_init_io() is simpler, no?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 11/16] kvm: Introduce core services for in-kernel irqchip support
In reply to Jan KiszkaQuoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes.
Routing is optional and depends on the host arch supporting
KVM_CAP_IRQ_ROUTING. When it's not available on x86, we loose the HPET
lose
Quoted 6 lines
as we can't route GSI0 to IOAPIC pin 2.
In-kernel irqchip support will once be controlled by the machine property '
kernel_irqchip', but this is not yet wired up.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 10/16] memory: Introduce memory_region_init_reservation
In reply to Avi KivityQuoted 9 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce a memory region type that can reserve I/O space. Such regions are useful for modeling I/O that is only handled outside of QEMU, i.e. in the context of an accelerator like KVM. Any access to such a region from QEMU is a bug and will be reported as such.
This is guest triggerable (DMA into the region), so
abort()is too drastic.
Mmh, true. Will turn it into a print-once warning.
Quoted 13 lines
memory.c void memory_region_init_rom_device(MemoryRegion *mr, · line 1039
Quoted 11 lines
memory.c +10
-0+void memory_region_init_reservation (MemoryRegion *mr, +const char *name, +uint64_t size) +{ +memory_region_init (mr, name, size); + mr->ops = &reservation_ops; + mr->opaque = mr; + mr->terminates = true; + mr->backend_registered = false; +}Just calling
memory_region_init_io()is simpler, no?
Yep.
Thanks,
Jan
Re: [RFC][PATCH 13/16] kvm: x86: Add user space part for in-kernel APIC
In reply to Jan Kiszkahw/pc.c DeviceState *cpu_get_current_apic(void) · line 888
Quoted 13 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This introduces the alternative APIC model 'kvm-apic' which makes use of KVM's in-kernel device model. MSI is not yet supported, so we disable this when the in-kernel model is in use.
hw/pc.c +5
-1- dev =qdev_create (NULL ,"apic" ); +if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { + dev =qdev_create (NULL ,"kvm-apic" ); + }else { + dev =qdev_create (NULL ,"apic" ); + }
Is there anything that makes those two devices incompatible?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 01/16] msi: Generalize msix_supported to msi_supported
In reply to Jan KiszkaQuoted 11 lines · Jan Kiszka
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Rename
msix_supportedtomsi_supportedand control MSI and MSI-X activation this way. That was likely to original intention for this flag, but MSI support came after MSI-X.'and' is a dangerous word in a changelog entry.
This patch hardly qualifies for two IMHO.
If we don't have to change it, no.
Quoted 14 lines
Quoted 13 lines
hw/msi.c int msi_init(struct PCIDevice *dev, uint8_t offset, · line 126
Quoted 9 lines
hw/msi.c +5
-0+ +if (!msi_supported) { +return -ENOTSUP ; + } +This changes behaviour. qemu 1.0 -M pc-1.0 and qemu-1.1 -M pc-1.0 will be different after this, no?
Quoted 3 lines
Only isapc had
msix_supported= 0, and I doubt we got there (msi_init) for that machine. Or am I missing something?
Ah, I thought it was a user-settable property, but it isn't.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 11/16] kvm: Introduce core services for in-kernel irqchip support
In reply to Avi KivityQuoted 10 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes.
Routing is optional and depends on the host arch supporting
KVM_CAP_IRQ_ROUTING. When it's not available on x86, we loose the HPETlose
/me is still looking for a semantic proofreader plugin...
Quoted 8 lines
Quoted 7 lines
as we can't route GSI0 to IOAPIC pin 2.
In-kernel irqchip support will once be controlled by the machine property '
kernel_irqchip', but this is not yet wired up.
Re: [RFC][PATCH 11/16] kvm: Introduce core services for in-kernel irqchip support
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Routing is optional and depends on the host arch supporting
KVM_CAP_IRQ_ROUTING. When it's not available on x86, we loose the HPETlose
/me is still looking for a semantic proofreader plugin...
Well, I have to comment on something. If you don't want spelling corrections, leave some trailing whitespace.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 11/16] kvm: Introduce core services for in-kernel irqchip support
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Add the basic infrastructure to active in-kernel irqchip support, inject interrupts into these models, and maintain IRQ routes.
Routing is optional and depends on the host arch supporting
KVM_CAP_IRQ_ROUTING. When it's not available on x86, we loose the HPET
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
lose
/me is still looking for a semantic proofreader plugin...
Well, I have to comment on something. If you don't want spelling corrections, leave some trailing whitespace.
I could create a messpatch.pl...
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
In reply to Jan KiszkaQuoted 12 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce the alternative 'kvm-i8259' device model that exploits KVM in-kernel acceleration.
The PIIX3 initialization code is furthermore extended by KVM specific IRQ route setup. Moreover, GSI injection differs in KVM mode from the user space model. As we can dispatch ISA-range IRQs to both IOAPIC and PIC inside the kernel, we do not need to inject them separately. This is reflected by a KVM-specific GSI handler.
hw/kvm/i8259.c line 120
Quoted 6 lines
hw/kvm/i8259.c new file +6
-0+ +qemu_irq *kvm_i8259_init (void ) +{ +ISADevice *dev; + + dev =isa_create ("kvm-i8259" );
Same issue. Is this a different device, or an different implementation of the same device?
We're forcing migration from 1.0 to 1.1 to disable in-kernel irqchip on the target. For qemu itself, that's no issue. But for qemu-kvm, it will result in loss of performance, or hacks to alias the two back together.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 11/16] kvm: Introduce core services for in-kernel irqchip support
In reply to Jan KiszkaQuoted 4 lines · Jan Kiszka
Quoted 2 lines
Well, I have to comment on something. If you don't want spelling corrections, leave some trailing whitespace.
I could create a messpatch.pl...
Ah, and with a --reverse flag we could go through the motions of patch review without requiring a repost.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
In reply to Avi KivityQuoted 12 lines · Avi Kivity
Quoted 11 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce the alternative 'kvm-i8259' device model that exploits KVM in-kernel acceleration.
The PIIX3 initialization code is furthermore extended by KVM specific IRQ route setup. Moreover, GSI injection differs in KVM mode from the user space model. As we can dispatch ISA-range IRQs to both IOAPIC and PIC inside the kernel, we do not need to inject them separately. This is reflected by a KVM-specific GSI handler.
Quoted 10 lines
hw/kvm/i8259.c line 120
Quoted 7 lines
hw/kvm/i8259.c new file +6
-0+ +qemu_irq *kvm_i8259_init (void ) +{ +ISADevice *dev; + + dev =isa_create ("kvm-i8259" );Same issue. Is this a different device, or an different implementation of the same device?
They are theoretically the same from guest perspective (therefore you can migrate between machines that differ in this).
Quoted 4 lines
We're forcing migration from 1.0 to 1.1 to disable in-kernel irqchip on the target. For qemu itself, that's no issue. But for qemu-kvm, it will result in loss of performance, or hacks to alias the two back together.
We should this happen with qemu-kvm? The vmstates are compatible, thus you can migration from old qemu-kvm in-kernel devices to the new kvm-* ones (once they are feature-equivalent). Not sure how much hacks this may require to qemu-kvm, but I don't think it should make the situation worse for that tree.
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 24 lines · Jan Kiszka
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce the alternative 'kvm-i8259' device model that exploits KVM in-kernel acceleration.
The PIIX3 initialization code is furthermore extended by KVM specific IRQ route setup. Moreover, GSI injection differs in KVM mode from the user space model. As we can dispatch ISA-range IRQs to both IOAPIC and PIC inside the kernel, we do not need to inject them separately. This is reflected by a KVM-specific GSI handler.
Quoted 10 lines
hw/kvm/i8259.c line 120
Quoted 7 lines
hw/kvm/i8259.c new file +6
-0+ +qemu_irq *kvm_i8259_init (void ) +{ +ISADevice *dev; + + dev =isa_create ("kvm-i8259" );Same issue. Is this a different device, or an different implementation of the same device?
Quoted 2 lines
They are theoretically the same from guest perspective (therefore you can migrate between machines that differ in this).
But the name becomes part of the save/restore ABI, so you can't.
Quoted 10 lines
Quoted 4 lines
We're forcing migration from 1.0 to 1.1 to disable in-kernel irqchip on the target. For qemu itself, that's no issue. But for qemu-kvm, it will result in loss of performance, or hacks to alias the two back together.
We should this happen with qemu-kvm? The vmstates are compatible, thus you can migration from old qemu-kvm in-kernel devices to the new kvm-* ones (once they are feature-equivalent). Not sure how much hacks this may require to qemu-kvm, but I don't think it should make the situation worse for that tree.
They aren't compatible due to the name clash. The hack won't be large (add an alias for the name), but just one hack is enough to keep the tree alive for a long while. Better not to add it in the first place.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 25 lines · Avi Kivity
Quoted 24 lines · Jan Kiszka
Quoted 22 lines · Avi Kivity
Quoted 12 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Introduce the alternative 'kvm-i8259' device model that exploits KVM in-kernel acceleration.
The PIIX3 initialization code is furthermore extended by KVM specific IRQ route setup. Moreover, GSI injection differs in KVM mode from the user space model. As we can dispatch ISA-range IRQs to both IOAPIC and PIC inside the kernel, we do not need to inject them separately. This is reflected by a KVM-specific GSI handler.
hw/kvm/i8259.c line 120
Quoted 6 lines
hw/kvm/i8259.c new file +6
-0+ +qemu_irq *kvm_i8259_init (void ) +{ +ISADevice *dev; + + dev =isa_create ("kvm-i8259" );Same issue. Is this a different device, or an different implementation of the same device?
Quoted 4 lines
Quoted 2 lines
They are theoretically the same from guest perspective (therefore you can migrate between machines that differ in this).
But the name becomes part of the save/restore ABI, so you can't.
Nope, the vmstate names are identical. That would ruin migration otherwise. It's just the output of info qtree & co. that changes.
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 5 lines · Jan Kiszka
Quoted 2 lines
But the name becomes part of the save/restore ABI, so you can't.
Nope, the vmstate names are identical. That would ruin migration otherwise. It's just the output of info qtree & co. that changes.
Oh, okay. I still think it's wrong, but now it's just a matter of taste, and I can live with it.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 2 lines
But the name becomes part of the save/restore ABI, so you can't.
Nope, the vmstate names are identical. That would ruin migration otherwise. It's just the output of info qtree & co. that changes.
Oh, okay. I still think it's wrong, but now it's just a matter of taste, and I can live with it.
Wrong in what sense?
I think the way of merging kvm support into the user space models in qemu-kvm is not particularly beautiful. But that's my taste, and therefore I modeled the upstream proposal differently. :)
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Quoted 2 lines
But the name becomes part of the save/restore ABI, so you can't.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Nope, the vmstate names are identical. That would ruin migration otherwise. It's just the output of info qtree & co. that changes.
Oh, okay. I still think it's wrong, but now it's just a matter of taste, and I can live with it.
Wrong in what sense?
In the sense that kernel-apic is just an accelerated apic. From the guest point of view, there's no difference, and that should be reflected in the device model.
If I'm reading an apic register, either from the guest or via a monitor debug interface, I shouldn't care whether it's accelerated or not. The guest part already holds, of course.
Quoted 3 lines
I think the way of merging kvm support into the user space models in qemu-kvm is not particularly beautiful. But that's my taste, and therefore I modeled the upstream proposal differently. :)
Oh, qemu-kvm was not meant to be an example of engineering elegance, just minimal changes.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 2 lines
But the name becomes part of the save/restore ABI, so you can't.
Nope, the vmstate names are identical. That would ruin migration otherwise. It's just the output of info qtree & co. that changes.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Oh, okay. I still think it's wrong, but now it's just a matter of taste, and I can live with it.
Wrong in what sense?
In the sense that kernel-apic is just an accelerated apic. From the guest point of view, there's no difference, and that should be reflected in the device model.
That was my goal as well: The guest should not notice the difference, but the admin on the host side should still be able to tell both internally fairly different models apart. Plus the code should be clearly split where there are differences and explicitly shared where there aren't.
Quoted 4 lines
If I'm reading an apic register, either from the guest or via a monitor debug interface, I shouldn't care whether it's accelerated or not. The guest part already holds, of course.
Specifically for the debug scenario, I'd prefer the clear differentiation by name as there can always remain subtle differences in the implementation of kernel vs. user space. Someone debugging the guest and/or qemu/kvm should remain aware of this.
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 8 lines · Jan Kiszka
Quoted 4 lines
In the sense that kernel-apic is just an accelerated apic. From the guest point of view, there's no difference, and that should be reflected in the device model.
That was my goal as well: The guest should not notice the difference, but the admin on the host side should still be able to tell both internally fairly different models apart.
This should be some attribute, not the name.
Quoted 3 lines
Plus the code should be
clearly split where there are differences and explicitly shared where there aren't.
That's a good goal, yes.
Quoted 10 lines
Quoted 5 lines
If I'm reading an apic register, either from the guest or via a monitor debug interface, I shouldn't care whether it's accelerated or not. The guest part already holds, of course.
Specifically for the debug scenario, I'd prefer the clear differentiation by name as there can always remain subtle differences in the implementation of kernel vs. user space. Someone debugging the guest and/or qemu/kvm should remain aware of this.
Aware, yes, but the name change is too drastic.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 4 lines
In the sense that kernel-apic is just an accelerated apic. From the guest point of view, there's no difference, and that should be reflected in the device model.
That was my goal as well: The guest should not notice the difference, but the admin on the host side should still be able to tell both internally fairly different models apart.
Quoted 7 lines
This should be some attribute, not the name.
Quoted 3 lines
Plus the code should be
clearly split where there are differences and explicitly shared where there aren't.That's a good goal, yes.
I'd prefer an unified device built from a single source file if possible. This conflicts with the build-once model though.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If I'm reading an apic register, either from the guest or via a monitor debug interface, I shouldn't care whether it's accelerated or not. The guest part already holds, of course.
Quoted 6 lines
Quoted 4 lines
Specifically for the debug scenario, I'd prefer the clear differentiation by name as there can always remain subtle differences in the implementation of kernel vs. user space. Someone debugging the guest and/or qemu/kvm should remain aware of this.
Aware, yes, but the name change is too drastic.
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 13 lines · Blue Swirl
Quoted 12 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 4 lines
In the sense that kernel-apic is just an accelerated apic. From the guest point of view, there's no difference, and that should be reflected in the device model.
That was my goal as well: The guest should not notice the difference, but the admin on the host side should still be able to tell both internally fairly different models apart.
This should be some attribute, not the name.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Plus the code should be
clearly split where there are differences and explicitly shared where there aren't.That's a good goal, yes.
I'd prefer an unified device built from a single source file if possible. This conflicts with the build-once model though.
Right, another reason to not do this.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
If I'm reading an apic register, either from the guest or via a monitor debug interface, I shouldn't care whether it's accelerated or not. The guest part already holds, of course.
Specifically for the debug scenario, I'd prefer the clear differentiation by name as there can always remain subtle differences in the implementation of kernel vs. user space. Someone debugging the guest and/or qemu/kvm should remain aware of this.
Quoted 4 lines
Quoted 1 line
Aware, yes, but the name change is too drastic.
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
It is (theoretically) possible with these patches as the vmstate names are the same. KVM to TCG migration does not work right now, so I was only able to test in-kernel <-> user space irqchip model migrations.
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
It is (theoretically) possible with these patches as the vmstate names are the same. KVM to TCG migration does not work right now, so I was only able to test in-kernel <-> user space irqchip model migrations.
btw, for the next-gen migration protocol, we'd probably be using QOM paths, not vmstate names; the QOM paths would include the device name?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC][PATCH 02/16] kvm: Move kvmclock into hw/kvm folder
In reply to Jan Kiszka-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 03.12.2011 23:33, schrieb Jan Kiszka:
Quoted 12 lines · Andreas Färber
Quoted 11 lines
Am 03.12.2011 12:17, schrieb Jan Kiszka:
Quoted 10 lines
hw/kvm/clock.c similarity index renamed from hw/kvmclock.c +0
-096% rename from
hw/kvmclock.crename tohw/kvm/clock.cindex 5388bc4..aa37c5d 100644 ---a/hw/kvmclock.c+++b/hw/kvm/clock.c@@ -11,11 +11,11 @@ * */-#include "
qemu-common.h" -#include "sysemu.h" -#include "sysbus.h" -#include "kvm.h" -#include "kvmclock.h" +#include <qemu-common.h> +#include <sysemu.h> +#include <kvm.h> +#include <hw/sysbus.h> +#include <hw/kvm/clock.h>
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
#include <
linux/kvm.h> #include <linux/kvm_para.h>Please don't start using system includes for everything. Rather extend
QEMU_CFLAGSto contain the right user include path(s).No problem - and no need to tweak any CFLAGS
Right, I had recursion into kvm/ in mind - would've required -I ../.. to be added to CFLAGS.
Quoted 1 line
("" only adds . to the header search paths).
By default that is. -iquote can add further paths. (Unfortunately didn't solve the Cocoa Block.h vs. block.h problem since Objective-C frameworks use quotes, too.)
Quoted 3 lines
Do we have a convention that every include in <> is considered system header? Should probably be documented then (and code should be converted gradually).
The convention I perceived was that everything QEMU was in quotes whereas POSIX, Linux, zlib, glib, etc. were in angle brackets. Didn't check for documentation.
Andreas
- --
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iQIcBAEBAgAGBQJO3KA6AAoJEPou0S0+fgE/izQP/1q0Oje72FdXyUyVxPZw2Ypi zp+2TFYJ3FJUrTLkkDBjmsaMT0sdIoI/wXxDTrrif9QI1gfRhNlxw9qES+En4xDG 3ClCl6UMNrcq35WrejIvPOXQMvVH6tTnliHBKmG6TSsQXPEFLS/BbWA1Y3gV7nZ4 KXmMHdNqVzmo66AU0FGQPSZyE/u+w8PKnfOIea961tMFtYodny69lzuoBWIaC/oT 8neCRT6U4BVX6hEy6QgY1651IM0KUOUC0fbBwFMwiy+NeL5KgB+GWsrnVq+U0hpM gDtE09L1IKzuppMLlsx1DmxAZYHX12ZlW5W3np13+qDOkFx+4JqT3AU1MGBDhVQ+ ylbYXAINpcXsV8hTyCv1xoWlCJTUreD5+vVgAe5IN3jJUuXttR867YZHS6w0Xkh2 saTYRdkaywNpb9Jm/8RdP0Nepjq2YKdjP99/Da5/GOlVBOqASycKmtAyKQKerhAx 2n+Os8Ekji9fLM7S1FFWe2i/v/bUiVKb9TPRw98tDaDd9V0RW2AkBrJcL2BlFBC4 nqM57ndpv3phGLbVoin2yo32P6iTqL/bS7iyJap+IeklSzxSyW0bBcJyT0oIZMQ2 TdeZNSS2aF9+SmIp91aNRIWhXDAZGggls5AvrS3FTbyzY0jb4HXLIYVGyLCdzfar uHBpp0n3XZsqieTYP+f0
=zA/a
-----END PGP SIGNATURE-----
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
In reply to Avi KivityQuoted 11 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
It is (theoretically) possible with these patches as the vmstate names are the same. KVM to TCG migration does not work right now, so I was only able to test in-kernel <-> user space irqchip model migrations.
btw, for the next-gen migration protocol, we'd probably be using QOM paths, not vmstate names; the QOM paths would include the device name?
That would be a very bad idea IMHO. Every refactoring of your device tree, e.g. to model CPU hotplug and the ICC bus more accurately, would risk to create a migration crack. At least we would need some stable naming and/or alias concept then.
Jan
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
It is (theoretically) possible with these patches as the vmstate names are the same. KVM to TCG migration does not work right now, so I was only able to test in-kernel <-> user space irqchip model migrations.
Quoted 6 lines
Quoted 2 lines
btw, for the next-gen migration protocol, we'd probably be using QOM paths, not vmstate names; the QOM paths would include the device name?
That would be a very bad idea IMHO. Every refactoring of your device tree, e.g. to model CPU hotplug and the ICC bus more accurately, would risk to create a migration crack.
At some point, something has to be stable. We can't have an infinite number of layers giving names to things. I propose we have just one layer.
Quoted 2 lines
At least we would need some stable
naming and/or alias concept then.
We should be able to transform a path to backward compatible names, yes. But if something has an unstable name, let's omit it in the first place.
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 24 lines · Avi Kivity
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Avi Kivity
Quoted 7 lines · Jan Kiszka
Quoted 3 lines
It should be also possible to migrate from non-KVM device to KVM version, different names would prevent that for ever.
It is (theoretically) possible with these patches as the vmstate names are the same. KVM to TCG migration does not work right now, so I was only able to test in-kernel <-> user space irqchip model migrations.
Quoted 6 lines
Quoted 2 lines
btw, for the next-gen migration protocol, we'd probably be using QOM paths, not vmstate names; the QOM paths would include the device name?
That would be a very bad idea IMHO. Every refactoring of your device tree, e.g. to model CPU hotplug and the ICC bus more accurately, would risk to create a migration crack.
At some point, something has to be stable. We can't have an infinite number of layers giving names to things. I propose we have just one layer.
Quoted 2 lines
At least we would need some stable
naming and/or alias concept then.
Quoted 7 lines
We should be able to transform a path to backward compatible names, yes. But if something has an unstable name, let's omit it in the first place.
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
OK, maybe - or likely - we should make those device models have the same names in QOM once instantiated. But I'm still convinced they should remain separated models in contrast to a single model with a property.
The kvm ioapic, e.g., requires an additional property (gsi_base) that is meaningless for user space devices. And its interrupts have to be wired&configured differently at board model level. So, from the QEMU POV, it is a very different device. Just the guest does not notice.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 8 lines · Jan Kiszka
Quoted 4 lines
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
OK, maybe - or likely - we should make those device models have the same names in QOM once instantiated. But I'm still convinced they should remain separated models in contrast to a single model with a property.
What do you mean by separate models? You share all the code you can, and don't share the code you can't. To me, single model == single name.
Quoted 4 lines
The kvm ioapic, e.g., requires an additional property (
gsi_base) that is meaningless for user space devices. And its interrupts have to be wired&configured differently at board model level. So, from the QEMU POV, it is a very different device. Just the guest does not notice.
It's like qcow2 and raw/native IO are wire differently, or virtio-net and vhost-net. But it's the same IDE device or virtio NIC.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 4 lines
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
Quoted 6 lines
Quoted 3 lines
OK, maybe - or likely - we should make those device models have the same names in QOM once instantiated. But I'm still convinced they should remain separated models in contrast to a single model with a property.
What do you mean by separate models? You share all the code you can, and don't share the code you can't. To me, single model == single name.
But different configuration.
Quoted 8 lines
Quoted 5 lines
The kvm ioapic, e.g., requires an additional property (
gsi_base) that is meaningless for user space devices. And its interrupts have to be wired&configured differently at board model level. So, from the QEMU POV, it is a very different device. Just the guest does not notice.It's like qcow2 and raw/native IO are wire differently, or virtio-net and vhost-net. But it's the same IDE device or virtio NIC.
That would mean introducing a backend/frontend concept for irqchips.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 7 lines · Jan Kiszka
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Jan Kiszka
Quoted 4 lines
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
OK, maybe - or likely - we should make those device models have the same names in QOM once instantiated. But I'm still convinced they should remain separated models in contrast to a single model with a property.
What do you mean by separate models? You share all the code you can, and don't share the code you can't. To me, single model == single name.
But different configuration.
Right, just like IDE with different backends.
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
The kvm ioapic, e.g., requires an additional property (
gsi_base) that is meaningless for user space devices. And its interrupts have to be wired&configured differently at board model level. So, from the QEMU POV, it is a very different device. Just the guest does not notice.It's like qcow2 and raw/native IO are wire differently, or virtio-net and vhost-net. But it's the same IDE device or virtio NIC.
That would mean introducing a backend/frontend concept for irqchips.
We could do it, have one ioapic model with ioapic_ops->eoi_broadcast(). Most of the interfaces already dispatch dynamically (qdev gpio/irq) so there wouldn't be much more there.
To me, how it's actually implemented is not important. What is important is that save/restore, the monitor, and the guest don't notice any changes.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [RFC][PATCH 14/16] kvm: x86: Add user space part for in-kernel i8259
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Jan Kiszka
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Jan Kiszka
Quoted 4 lines
(the memory API added unstable names, hopefully the QOM can take over the stable ones and we'll have a good way to denote the unstable ones).
OK, maybe - or likely - we should make those device models have the same names in QOM once instantiated. But I'm still convinced they should remain separated models in contrast to a single model with a property.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
What do you mean by separate models? You share all the code you can, and don't share the code you can't. To me, single model == single name.
But different configuration.
Right, just like IDE with different backends.
Except that there is a comparably large infrastructure to manage those backends.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
The kvm ioapic, e.g., requires an additional property (
gsi_base) that is meaningless for user space devices. And its interrupts have to be wired&configured differently at board model level. So, from the QEMU POV, it is a very different device. Just the guest does not notice.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
It's like qcow2 and raw/native IO are wire differently, or virtio-net and vhost-net. But it's the same IDE device or virtio NIC.
That would mean introducing a backend/frontend concept for irqchips.
We could do it, have one ioapic model with
ioapic_ops->eoi_broadcast(). Most of the interfaces already dispatch dynamically (qdev gpio/irq) so there wouldn't be much more there.
The problem is configuration. Just by setting ioapic.backend=xxx, we cannot pass down parameters that are backend-specific. We could ignore this issue and make all specific parameters visible via the frontend. Would be slightly ugly.
Quoted 4 lines
To me, how it's actually implemented is not important. What is important is that save/restore, the monitor, and the guest don't notice any changes.
I widely agree, except that differentiation (or backend awareness) has to be preserved in the monitor.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux