[COMMIT master] Flush icache after dma operations for ia64
From: Jes Sorensen j...@sgi.com ia64 system depends on that platform issues snoop cycle to flush icache for memory touched by DMA write operations, but virtual DMA operations is emulated by memcpy, so use explict instrustions to flush the related icache, otherwise, guest may use obsolete icache. Signed-off-by: Xiantao Zhang xiantao.zh...@intel.com Signed-off-by: Jes Sorensen j...@sgi.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/cache-utils.h b/cache-utils.h index b45fde4..e4f27ef 100644 --- a/cache-utils.h +++ b/cache-utils.h @@ -34,7 +34,28 @@ static inline void flush_icache_range(unsigned long start, unsigned long stop) asm volatile (isync : : : memory); } +/* + * Is this correct for PPC? + */ +static inline void dma_flush_range(unsigned long start, unsigned long stop) +{ +} + +#elif defined(__ia64__) +static inline void flush_icache_range(unsigned long start, unsigned long stop) +{ +while (start stop) { + asm volatile (fc %0 :: r(start)); + start += 32; +} +asm volatile (;;sync.i;;srlz.i;;); +} +#define dma_flush_range(start, end) flush_icache_range(start, end) +#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) #else +static inline void dma_flush_range(unsigned long start, unsigned long stop) +{ +} #define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) #endif diff --git a/cutils.c b/cutils.c index 0623cf7..6ea0c49 100644 --- a/cutils.c +++ b/cutils.c @@ -164,6 +164,11 @@ void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf) } } +/* + * No dma flushing needed here, as the aio code will call dma_bdrv_cb() + * on completion as well, which will result in a call to + * dma_bdrv_unmap() which will do the flushing + */ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count) { const uint8_t *p = (const uint8_t *)buf; diff --git a/dma-helpers.c b/dma-helpers.c index 712ed89..d4fc077 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -160,6 +160,10 @@ static BlockDriverAIOCB *dma_bdrv_io( dbs-is_write = is_write; dbs-bh = NULL; qemu_iovec_init(dbs-iov, sg-nsg); +/* + * DMA flushing is handled in dma_bdrv_cb() calling dma_bdrv_unmap() + * so we don't need to do that here. + */ dma_bdrv_cb(dbs, 0); if (!dbs-acb) { qemu_aio_release(dbs); diff --git a/exec.c b/exec.c index c024b8b..7c777c2 100644 --- a/exec.c +++ b/exec.c @@ -35,6 +35,7 @@ #include cpu.h #include exec-all.h #include qemu-common.h +#include cache-utils.h #if !defined(TARGET_IA64) #include tcg.h @@ -3500,6 +3501,8 @@ void *cpu_physical_memory_map(target_phys_addr_t addr, void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, int is_write, target_phys_addr_t access_len) { +unsigned long flush_len = (unsigned long)access_len; + if (buffer != bounce.buffer) { if (is_write) { ram_addr_t addr1 = qemu_ram_addr_from_host(buffer); @@ -3517,7 +3520,9 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, } addr1 += l; access_len -= l; -} + } + dma_flush_range((unsigned long)buffer, + (unsigned long)buffer + flush_len); } return; } diff --git a/target-ia64/cpu.h b/target-ia64/cpu.h index e002d56..fb51463 100644 --- a/target-ia64/cpu.h +++ b/target-ia64/cpu.h @@ -71,7 +71,6 @@ static inline int cpu_mmu_index (CPUState *env) * These ones really should go to the appropriate tcg header file, if/when * tcg support is added for ia64. */ -void flush_icache_range(unsigned long start, unsigned long stop); void tcg_dump_info(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); diff --git a/target-ia64/fake-exec.c b/target-ia64/fake-exec.c index c11cc32..8d6ded0 100644 --- a/target-ia64/fake-exec.c +++ b/target-ia64/fake-exec.c @@ -41,15 +41,6 @@ void tcg_dump_info(FILE *f, return; } -void flush_icache_range(unsigned long start, unsigned long stop) -{ -while (start stop) { - asm volatile (fc %0 :: r(start)); - start += 32; -} -asm volatile (;;sync.i;;srlz.i;;); -} - int cpu_restore_state(TranslationBlock *tb, CPUState *env, unsigned long searched_pc, void *puc) -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] Make qemu-kvm build and run again on ia64
From: Jes Sorensen j...@sgi.com Update ipf.c and Makefile.target for QEMU/ia64 to match recent changes in QEMU. Signed-off-by: Jes Sorensen j...@sgi.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/Makefile.target b/Makefile.target index 7811444..da18f48 100644 --- a/Makefile.target +++ b/Makefile.target @@ -641,13 +641,10 @@ CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif ifeq ($(TARGET_BASE_ARCH), ia64) # Hardware support -OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) +OBJS+= ide.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) OBJS+= fdc.o mc146818rtc.o serial.o i8259.o ipf.o OBJS+= cirrus_vga.o parallel.o acpi.o piix_pci.o -OBJS+= usb-uhci.o smbus_eeprom.o -# virtio support -OBJS+= virtio.o virtio-blk.o virtio-balloon.o -OBJS+= virtio-net.o +OBJS+= usb-uhci.o endif ifeq ($(TARGET_BASE_ARCH), ppc) CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE diff --git a/hw/ipf.c b/hw/ipf.c index d051666..8aec258 100644 --- a/hw/ipf.c +++ b/hw/ipf.c @@ -373,7 +373,7 @@ static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic) } /* Itanium hardware initialisation */ -static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, +static void ipf_init1(ram_addr_t ram_size, const char *boot_device, DisplayState *ds, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, @@ -381,7 +381,7 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, { char buf[1024]; int i; -ram_addr_t ram_addr, vga_ram_addr; +ram_addr_t ram_addr; ram_addr_t above_4g_mem_size = 0; PCIBus *pci_bus; int piix3_devfn = -1; @@ -421,7 +421,7 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, if (i != 0) env-hflags |= HF_HALTED_MASK; register_savevm(cpu, i, 4, cpu_save, cpu_load, env); -qemu_register_reset(main_cpu_reset, env); +qemu_register_reset(main_cpu_reset, 0, env); } /* allocate RAM */ @@ -440,8 +440,6 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, ram_addr = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_addr); } -/* allocate VGA RAM */ -vga_ram_addr = qemu_ram_alloc(vga_ram_size); /* above 4giga memory allocation */ if (above_4g_mem_size 0) { @@ -498,7 +496,7 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, ipf_legacy_io_mem); cpu_irq = qemu_allocate_irqs(pic_irq_request, first_cpu, 1); -i8259 = i8259_init(cpu_irq[0]); +i8259 = kvm_i8259_init(cpu_irq[0]); if (pci_enabled) { pci_bus = i440fx_init(i440fx_state, i8259); @@ -509,14 +507,14 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, if (cirrus_vga_enabled) { if (pci_enabled) -pci_cirrus_vga_init(pci_bus, vga_ram_size); +pci_cirrus_vga_init(pci_bus); else -isa_cirrus_vga_init(vga_ram_size); +isa_cirrus_vga_init(); } else { if (pci_enabled) -pci_vga_init(pci_bus, vga_ram_size, 0, 0); +pci_vga_init(pci_bus, 0, 0); else -isa_vga_init(vga_ram_size); +isa_vga_init(); } rtc_state = rtc_init(0x70, i8259[8], 2000); @@ -603,7 +601,11 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, /* TODO: Populate SPD eeprom data. */ smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, i8259[9]); for (i = 0; i 8; i++) { -smbus_eeprom_device_init(smbus, 0x50 + i, eeprom_buf + (i * 256)); +DeviceState *eeprom; +eeprom = qdev_create((BusState *)smbus, smbus-eeprom); +qdev_set_prop_int(eeprom, address, 0x50 + i); +qdev_set_prop_ptr(eeprom, data, eeprom_buf + (i * 256)); +qdev_init(eeprom); } } @@ -613,19 +615,11 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, if (pci_enabled) { int max_bus; -int bus, unit; -void *scsi; +int bus; max_bus = drive_get_max_bus(IF_SCSI); - for (bus = 0; bus = max_bus; bus++) { -scsi = lsi_scsi_init(pci_bus, -1); -for (unit = 0; unit LSI_MAX_DEVS; unit++) { - index = drive_get_index(IF_SCSI, bus, unit); - if (index == -1) - continue; - lsi_scsi_attach(scsi, drives_table[index].bdrv, unit); - } +pci_create_simple(pci_bus, -1, lsi53c895a); } } /* Add virtio block devices */ @@ -634,7 +628,7 @@ static void ipf_init1(ram_addr_t ram_size, int vga_ram_size, int unit_id = 0; while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { - virtio_blk_init(pci_bus, drives_table[index].bdrv); +pci_create_simple(pci_bus, -1, virtio-blk-pci);
[COMMIT master] KVM: ppc: e500: Add MMUCFG and PVR emulation
From: Liu Yu yu@freescale.com Latest kernel started to use these two registers. Signed-off-by: Liu Yu yu@freescale.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c index 3f76041..be95b8d 100644 --- a/arch/powerpc/kvm/e500_emulate.c +++ b/arch/powerpc/kvm/e500_emulate.c @@ -180,6 +180,9 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt) case SPRN_MMUCSR0: vcpu-arch.gpr[rt] = 0; break; + case SPRN_MMUCFG: + vcpu-arch.gpr[rt] = mfspr(SPRN_MMUCFG); break; + /* extra exceptions */ case SPRN_IVOR32: vcpu-arch.gpr[rt] = vcpu-arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL]; diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c index f8b8248..28a8237 100644 --- a/arch/powerpc/kvm/emulate.c +++ b/arch/powerpc/kvm/emulate.c @@ -188,6 +188,8 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu) vcpu-arch.gpr[rt] = vcpu-arch.srr1; break; case SPRN_PVR: vcpu-arch.gpr[rt] = mfspr(SPRN_PVR); break; + case SPRN_PIR: + vcpu-arch.gpr[rt] = mfspr(SPRN_PIR); break; /* Note: mftb and TBRL/TBWL are user-accessible, so * the guest can always access the real TB anyways. -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: VMX: Rename rmode.active to rmode.vm86_active
From: Nitin A Kamble nitin.a.kam...@intel.com That way the interpretation of rmode.active becomes more clear with unrestricted guest code. Signed-off-by: Nitin A Kamble nitin.a.kam...@intel.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 1951d39..1cc901e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -339,7 +339,7 @@ struct kvm_vcpu_arch { } interrupt; struct { - int active; + int vm86_active; u8 save_iopl; struct kvm_save_segment { u16 selector; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7eb98e5..77a43c0 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -497,7 +497,7 @@ static void update_exception_bitmap(struct kvm_vcpu *vcpu) if (vcpu-guest_debug KVM_GUESTDBG_USE_SW_BP) eb |= 1u BP_VECTOR; } - if (vcpu-arch.rmode.active) + if (vcpu-arch.rmode.vm86_active) eb = ~0; if (enable_ept) eb = ~(1u PF_VECTOR); /* bypass_guest_pf = 0 */ @@ -733,7 +733,7 @@ static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu) static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) { - if (vcpu-arch.rmode.active) + if (vcpu-arch.rmode.vm86_active) rflags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM; vmcs_writel(GUEST_RFLAGS, rflags); } @@ -790,7 +790,7 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, intr_info |= INTR_INFO_DELIVER_CODE_MASK; } - if (vcpu-arch.rmode.active) { + if (vcpu-arch.rmode.vm86_active) { vmx-rmode.irq.pending = true; vmx-rmode.irq.vector = nr; vmx-rmode.irq.rip = kvm_rip_read(vcpu); @@ -1370,7 +1370,7 @@ static void enter_pmode(struct kvm_vcpu *vcpu) struct vcpu_vmx *vmx = to_vmx(vcpu); vmx-emulation_required = 1; - vcpu-arch.rmode.active = 0; + vcpu-arch.rmode.vm86_active = 0; vmcs_writel(GUEST_TR_BASE, vcpu-arch.rmode.tr.base); vmcs_write32(GUEST_TR_LIMIT, vcpu-arch.rmode.tr.limit); @@ -1432,7 +1432,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu) struct vcpu_vmx *vmx = to_vmx(vcpu); vmx-emulation_required = 1; - vcpu-arch.rmode.active = 1; + vcpu-arch.rmode.vm86_active = 1; vcpu-arch.rmode.tr.base = vmcs_readl(GUEST_TR_BASE); vmcs_writel(GUEST_TR_BASE, rmode_tss_base(vcpu-kvm)); @@ -1616,10 +1616,10 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) vmx_fpu_deactivate(vcpu); - if (vcpu-arch.rmode.active (cr0 X86_CR0_PE)) + if (vcpu-arch.rmode.vm86_active (cr0 X86_CR0_PE)) enter_pmode(vcpu); - if (!vcpu-arch.rmode.active !(cr0 X86_CR0_PE)) + if (!vcpu-arch.rmode.vm86_active !(cr0 X86_CR0_PE)) enter_rmode(vcpu); #ifdef CONFIG_X86_64 @@ -1675,7 +1675,7 @@ static void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) { - unsigned long hw_cr4 = cr4 | (vcpu-arch.rmode.active ? + unsigned long hw_cr4 = cr4 | (vcpu-arch.rmode.vm86_active ? KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON); vcpu-arch.cr4 = cr4; @@ -1758,7 +1758,7 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_vmx_segment_field *sf = kvm_vmx_segment_fields[seg]; u32 ar; - if (vcpu-arch.rmode.active seg == VCPU_SREG_TR) { + if (vcpu-arch.rmode.vm86_active seg == VCPU_SREG_TR) { vcpu-arch.rmode.tr.selector = var-selector; vcpu-arch.rmode.tr.base = var-base; vcpu-arch.rmode.tr.limit = var-limit; @@ -1768,7 +1768,7 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, vmcs_writel(sf-base, var-base); vmcs_write32(sf-limit, var-limit); vmcs_write16(sf-selector, var-selector); - if (vcpu-arch.rmode.active var-s) { + if (vcpu-arch.rmode.vm86_active var-s) { /* * Hack real-mode segments into vm86 compatibility. */ @@ -2337,7 +2337,7 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) goto out; } - vmx-vcpu.arch.rmode.active = 0; + vmx-vcpu.arch.rmode.vm86_active = 0; vmx-soft_vnmi_blocked = 0; @@ -2475,7 +2475,7 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu) KVMTRACE_1D(INJ_VIRQ, vcpu, (u32)irq, handler); ++vcpu-stat.irq_injections; - if (vcpu-arch.rmode.active) { + if (vcpu-arch.rmode.vm86_active) { vmx-rmode.irq.pending = true; vmx-rmode.irq.vector = irq; vmx-rmode.irq.rip = kvm_rip_read(vcpu); @@ -2516,7 +2516,7 @@
[COMMIT master] Fix include paths when the kernel source and build directory are different
From: James Pike ja...@chilon.net Use correct architecture includes when kernel source and build directory are different. Signed-off-by: James Pike ja...@chilon.net Acked-by: Jan Kiszka jan.kis...@siemens.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/Makefile b/Makefile index 95e4c81..ad08c45 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,9 @@ all:: prerequisite # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat $(MAKE) -C $(KERNELDIR) M=`pwd` \ LINUXINCLUDE=-I`pwd`/include -Iinclude \ - $(if $(KERNELSOURCEDIR),-Iinclude2 -I$(KERNELSOURCEDIR)/include) \ - -Iarch/${ARCH_DIR}/include -I`pwd`/include-compat \ + $(if $(KERNELSOURCEDIR),\ + -Iinclude2 -I$(KERNELSOURCEDIR)/include -I$(KERNELSOURCEDIR)/arch/${ARCH_DIR}/include, \ + -Iarch/${ARCH_DIR}/include) -I`pwd`/include-compat \ -include include/linux/autoconf.h \ -include `pwd`/$(ARCH_DIR)/external-module-compat.h $(module_defines) \ $$@ -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] Backwards compatibility for do_machine_check()
From: Avi Kivity a...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/sync b/sync index c4c4078..b12fb8a 100755 --- a/sync +++ b/sync @@ -37,6 +37,7 @@ def __hack(data): 'on_each_cpu relay_open request_irq free_irq ' 'init_srcu_struct cleanup_srcu_struct srcu_read_lock ' 'srcu_read_unlock synchronize_srcu srcu_batches_completed ' +'do_machine_check ' ) anon_inodes = anon_inodes_exit = False result = [] diff --git a/x86/external-module-compat.h b/x86/external-module-compat.h index 0e26743..273bfee 100644 --- a/x86/external-module-compat.h +++ b/x86/external-module-compat.h @@ -553,3 +553,19 @@ struct mtrr_state_type { #define MCI_STATUS_OVER (1ULL62) #define MCI_STATUS_UC(1ULL61) #endif + +/* do_machine_check() exported in 2.6.31 */ + +#if LINUX_VERSION_CODE KERNEL_VERSION(2,6,31) + +static inline void kvm_do_machine_check(struct pt_regs *regs, long error_code) +{ + panic(kvm machine check!\n); +} + +#else + +#define kvm_do_machine_check do_machine_check + +#endif + -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] Update source link
From: Avi Kivity a...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/linux-2.6 b/linux-2.6 index 28ddf0a..8fecb97 16 --- a/linux-2.6 +++ b/linux-2.6 @@ -1 +1 @@ -Subproject commit 28ddf0aebbf546e56efd1951725d5457ce1ebf98 +Subproject commit 8fecb979727b1582ba2c1a35c34c0bb6d341fa15 -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] Don't compile srcu on newer kernels
From: Avi Kivity a...@redhat.com Causes conflicts with kernel symbols. Signed-off-by: Avi Kivity a...@redhat.com diff --git a/srcu.c b/srcu.c index 3243adf..e9734bc 100644 --- a/srcu.c +++ b/srcu.c @@ -24,6 +24,8 @@ * */ +#if LINUX_VERSION_CODE KERNEL_VERSION(2,6,19) + #include linux/module.h #include linux/mutex.h #include linux/percpu.h @@ -261,3 +263,5 @@ EXPORT_SYMBOL_GPL(kvm_srcu_read_lock); EXPORT_SYMBOL_GPL(kvm_srcu_read_unlock); EXPORT_SYMBOL_GPL(kvm_synchronize_srcu); EXPORT_SYMBOL_GPL(kvm_srcu_batches_completed); + +#endif -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: Cleanup LAPIC interface
From: Jan Kiszka jan.kis...@siemens.com None of the interface services the LAPIC emulation provides need to be exported to modules, and kvm_lapic_get_base is even totally unused today. Signed-off-by: Jan Kiszka jan.kis...@siemens.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 4bfd458..a23f42e 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -194,7 +194,6 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) return highest_irr; } -EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr); static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode, int vector, int level, int trig_mode); @@ -768,7 +767,6 @@ void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8) apic_set_tpr(apic, ((cr8 0x0f) 4) | (apic_get_reg(apic, APIC_TASKPRI) 4)); } -EXPORT_SYMBOL_GPL(kvm_lapic_set_tpr); u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu) { @@ -781,7 +779,6 @@ u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu) return (tpr 0xf0) 4; } -EXPORT_SYMBOL_GPL(kvm_lapic_get_cr8); void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) { @@ -805,12 +802,6 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) } -u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu) -{ - return vcpu-arch.apic_base; -} -EXPORT_SYMBOL_GPL(kvm_lapic_get_base); - void kvm_lapic_reset(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic; @@ -860,7 +851,6 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) vcpu, kvm_apic_id(apic), vcpu-arch.apic_base, apic-base_address); } -EXPORT_SYMBOL_GPL(kvm_lapic_reset); bool kvm_apic_present(struct kvm_vcpu *vcpu) { @@ -871,7 +861,6 @@ int kvm_lapic_enabled(struct kvm_vcpu *vcpu) { return kvm_apic_present(vcpu) apic_sw_enabled(vcpu-arch.apic); } -EXPORT_SYMBOL_GPL(kvm_lapic_enabled); /* *-- @@ -970,7 +959,6 @@ nomem_free_apic: nomem: return -ENOMEM; } -EXPORT_SYMBOL_GPL(kvm_create_lapic); int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu) { -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: make sure we select EVENTFD for any arch that declares HAVE_KVM_EVENTFD
From: Gregory Haskins ghask...@novell.com Signed-off-by: Gregory Haskins ghask...@novell.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index b166f30..56c6848 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -8,3 +8,4 @@ config HAVE_KVM_IRQCHIP config HAVE_KVM_EVENTFD bool + select EVENTFD -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: introduce irq_lock, use it to protect ioapic
From: Marcelo Tosatti mtosa...@redhat.com Introduce irq_lock, and use to protect ioapic data structures. Signed-off-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index bcb94eb..c32df81 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -123,7 +123,6 @@ struct kvm_kernel_irq_routing_entry { }; struct kvm { - struct mutex lock; /* protects the vcpus array and APIC accesses */ spinlock_t mmu_lock; struct rw_semaphore slots_lock; struct mm_struct *mm; /* userspace tied to this vm */ @@ -132,6 +131,7 @@ struct kvm { KVM_PRIVATE_MEM_SLOTS]; struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; struct list_head vm_list; + struct mutex lock; struct kvm_io_bus mmio_bus; struct kvm_io_bus pio_bus; #ifdef CONFIG_HAVE_KVM_EVENTFD @@ -145,6 +145,7 @@ struct kvm { struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; #endif + struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ struct hlist_head mask_notifier_list; diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 6b00433..1665961 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -243,6 +243,7 @@ static void ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len, ioapic_debug(addr %lx\n, (unsigned long)addr); ASSERT(!(addr 0xf)); /* check alignment */ + mutex_lock(ioapic-kvm-irq_lock); addr = 0xff; switch (addr) { case IOAPIC_REG_SELECT: @@ -269,6 +270,7 @@ static void ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len, default: printk(KERN_WARNING ioapic: wrong length %d\n, len); } + mutex_unlock(ioapic-kvm-irq_lock); } static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len, @@ -280,6 +282,8 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len, ioapic_debug(ioapic_mmio_write addr=%p len=%d val=%p\n, (void*)addr, len, val); ASSERT(!(addr 0xf)); /* check alignment */ + + mutex_lock(ioapic-kvm-irq_lock); if (len == 4 || len == 8) data = *(u32 *) val; else { @@ -305,6 +309,7 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len, default: break; } + mutex_unlock(ioapic-kvm-irq_lock); } void kvm_ioapic_reset(struct kvm_ioapic *ioapic) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3dca047..e1032fd 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -979,6 +979,7 @@ static struct kvm *kvm_create_vm(void) kvm_io_bus_init(kvm-pio_bus); kvm_irqfd_init(kvm); mutex_init(kvm-lock); + mutex_init(kvm-irq_lock); kvm_io_bus_init(kvm-mmio_bus); init_rwsem(kvm-slots_lock); atomic_set(kvm-users_count, 1); -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: switch irq injection/acking data structures to irq_lock
From: Marcelo Tosatti mtosa...@redhat.com Protect irq injection/acking data structures with a separate irq_lock mutex. This fixes the following deadlock: CPU A CPU B kvm_vm_ioctl_deassign_dev_irq() mutex_lock(kvm-lock);worker_thread() - kvm_deassign_irq()- kvm_assigned_dev_interrupt_work_handler() - deassign_host_irq() mutex_lock(kvm-lock); - cancel_work_sync() [blocked] Reported-by: Alex Williamson alex.william...@hp.com Signed-off-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index f91b0e3..9749ec3 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -651,10 +651,10 @@ static void __inject_pit_timer_intr(struct kvm *kvm) struct kvm_vcpu *vcpu; int i; - mutex_lock(kvm-lock); + mutex_lock(kvm-irq_lock); kvm_set_irq(kvm, kvm-arch.vpit-irq_source_id, 0, 1); kvm_set_irq(kvm, kvm-arch.vpit-irq_source_id, 0, 0); - mutex_unlock(kvm-lock); + mutex_unlock(kvm-irq_lock); /* * Provides NMI watchdog support via Virtual Wire mode. diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index a23f42e..44f20cd 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -424,7 +424,9 @@ static void apic_set_eoi(struct kvm_lapic *apic) trigger_mode = IOAPIC_LEVEL_TRIG; else trigger_mode = IOAPIC_EDGE_TRIG; + mutex_lock(apic-vcpu-kvm-irq_lock); kvm_ioapic_update_eoi(apic-vcpu-kvm, vector, trigger_mode); + mutex_unlock(apic-vcpu-kvm-irq_lock); } static void apic_send_ipi(struct kvm_lapic *apic) @@ -448,7 +450,9 @@ static void apic_send_ipi(struct kvm_lapic *apic) irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode, irq.vector); + mutex_lock(apic-vcpu-kvm-irq_lock); kvm_irq_delivery_to_apic(apic-vcpu-kvm, apic, irq); + mutex_unlock(apic-vcpu-kvm-irq_lock); } static u32 apic_get_tmcct(struct kvm_lapic *apic) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c1ed485..272e2e8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2099,10 +2099,10 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; if (irqchip_in_kernel(kvm)) { __s32 status; - mutex_lock(kvm-lock); + mutex_lock(kvm-irq_lock); status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irq_event.irq, irq_event.level); - mutex_unlock(kvm-lock); + mutex_unlock(kvm-irq_lock); if (ioctl == KVM_IRQ_LINE_STATUS) { irq_event.status = status; if (copy_to_user(argp, irq_event, @@ -2348,12 +2348,11 @@ mmio: */ mutex_lock(vcpu-kvm-lock); mmio_dev = vcpu_find_mmio_dev(vcpu, gpa, bytes, 0); + mutex_unlock(vcpu-kvm-lock); if (mmio_dev) { kvm_iodevice_read(mmio_dev, gpa, bytes, val); - mutex_unlock(vcpu-kvm-lock); return X86EMUL_CONTINUE; } - mutex_unlock(vcpu-kvm-lock); vcpu-mmio_needed = 1; vcpu-mmio_phys_addr = gpa; @@ -2403,12 +2402,11 @@ mmio: */ mutex_lock(vcpu-kvm-lock); mmio_dev = vcpu_find_mmio_dev(vcpu, gpa, bytes, 1); + mutex_unlock(vcpu-kvm-lock); if (mmio_dev) { kvm_iodevice_write(mmio_dev, gpa, bytes, val); - mutex_unlock(vcpu-kvm-lock); return X86EMUL_CONTINUE; } - mutex_unlock(vcpu-kvm-lock); vcpu-mmio_needed = 1; vcpu-mmio_phys_addr = gpa; @@ -2731,7 +2729,6 @@ static void kernel_pio(struct kvm_io_device *pio_dev, { /* TODO: String I/O for in kernel device */ - mutex_lock(vcpu-kvm-lock); if (vcpu-arch.pio.in) kvm_iodevice_read(pio_dev, vcpu-arch.pio.port, vcpu-arch.pio.size, @@ -2740,7 +2737,6 @@ static void kernel_pio(struct kvm_io_device *pio_dev, kvm_iodevice_write(pio_dev, vcpu-arch.pio.port, vcpu-arch.pio.size, pd); - mutex_unlock(vcpu-kvm-lock); } static void pio_string_write(struct kvm_io_device *pio_dev, @@ -2750,14 +2746,12 @@ static void pio_string_write(struct kvm_io_device *pio_dev, void *pd = vcpu-arch.pio_data; int i; - mutex_lock(vcpu-kvm-lock); for (i = 0; i io-cur_count; i++) { kvm_iodevice_write(pio_dev, io-port, io-size, pd); pd += io-size; } - mutex_unlock(vcpu-kvm-lock); }