From patchwork Fri Feb 19 18:22:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 80790 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1JIMxCN028946 for ; Fri, 19 Feb 2010 18:23:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755401Ab0BSSW7 (ORCPT ); Fri, 19 Feb 2010 13:22:59 -0500 Received: from goliath.siemens.de ([192.35.17.28]:22358 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755409Ab0BSSWw (ORCPT ); Fri, 19 Feb 2010 13:22:52 -0500 Received: from mail3.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMSU0003826; Fri, 19 Feb 2010 19:22:28 +0100 Received: from localhost.localdomain (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JIMRG8025400; Fri, 19 Feb 2010 19:22:28 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Anthony Liguori , Gleb Natapov Subject: [PATCH 3/9] qemu-kvm: Use upstream kvm_enabled and cpu_synchronize_state Date: Fri, 19 Feb 2010 19:22:21 +0100 Message-Id: X-Mailer: git-send-email 1.6.0.2 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 19 Feb 2010 18:23:04 +0000 (UTC) diff --git a/hw/i8254.c b/hw/i8254.c index c4f8d2e..db9e94a 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -25,7 +25,7 @@ #include "pc.h" #include "isa.h" #include "qemu-timer.h" -#include "qemu-kvm.h" +#include "kvm.h" #include "i8254.h" //#define DEBUG_PIT diff --git a/hw/i8259.c b/hw/i8259.c index 7a484c0..b64c6fb 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -27,7 +27,7 @@ #include "monitor.h" #include "qemu-timer.h" -#include "qemu-kvm.h" +#include "kvm.h" /* debug PIC */ //#define DEBUG_PIC diff --git a/hw/ioapic.c b/hw/ioapic.c index a66325d..0adb0ac 100644 --- a/hw/ioapic.c +++ b/hw/ioapic.c @@ -26,7 +26,7 @@ #include "qemu-timer.h" #include "host-utils.h" -#include "qemu-kvm.h" +#include "kvm.h" //#define DEBUG_IOAPIC diff --git a/hw/msix.c b/hw/msix.c index 87f125b..faee0b2 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -14,8 +14,7 @@ #include "hw.h" #include "msix.h" #include "pci.h" -#define QEMU_KVM_NO_CPU -#include "qemu-kvm.h" +#include "kvm.h" /* Declaration from linux/pci_regs.h */ #define PCI_CAP_ID_MSIX 0x11 /* MSI-X */ diff --git a/hw/pc.c b/hw/pc.c index 6c98797..55df58d 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -47,7 +47,7 @@ #include "multiboot.h" #include "device-assignment.h" -#include "qemu-kvm.h" +#include "kvm.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS diff --git a/hw/piix_pci.c b/hw/piix_pci.c index 155587b..170f858 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -28,7 +28,7 @@ #include "pci_host.h" #include "isa.h" #include "sysbus.h" -#include "qemu-kvm.h" +#include "kvm.h" /* * I440FX chipset data sheet. diff --git a/kvm.h b/kvm.h index f6e4087..f97efa3 100644 --- a/kvm.h +++ b/kvm.h @@ -18,8 +18,6 @@ #include "qemu-queue.h" #include "qemu-kvm.h" -#ifdef KVM_UPSTREAM - #ifdef CONFIG_KVM extern int kvm_allowed; @@ -28,6 +26,7 @@ extern int kvm_allowed; #define kvm_enabled() (0) #endif +#ifdef KVM_UPSTREAM struct kvm_run; /* external API */ @@ -133,6 +132,8 @@ int kvm_check_extension(KVMState *s, unsigned int extension); uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg); +#endif + void kvm_cpu_synchronize_state(CPUState *env); /* generic hooks - to be moved/refactored once there are more users */ @@ -145,5 +146,3 @@ static inline void cpu_synchronize_state(CPUState *env) } #endif - -#endif diff --git a/qemu-kvm.h b/qemu-kvm.h index 9c132da..069d2c6 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -8,9 +8,7 @@ #ifndef THE_ORIGINAL_AND_TRUE_QEMU_KVM_H #define THE_ORIGINAL_AND_TRUE_QEMU_KVM_H -#ifndef QEMU_KVM_NO_CPU #include "cpu.h" -#endif #include #include @@ -94,8 +92,6 @@ void kvm_show_code(CPUState *env); int handle_halt(CPUState *env); -#ifndef QEMU_KVM_NO_CPU - int handle_shutdown(kvm_context_t kvm, CPUState *env); void post_kvm_run(kvm_context_t kvm, CPUState *env); int pre_kvm_run(kvm_context_t kvm, CPUState *env); @@ -113,8 +109,6 @@ struct kvm_x86_mce; int kvm_set_mce(CPUState *env, struct kvm_x86_mce *mce); #endif -#endif - /*! * \brief Create new KVM context * @@ -880,8 +874,6 @@ static inline int kvm_init(int smp_cpus) return 0; } -#ifndef QEMU_KVM_NO_CPU - static inline void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, uint64_t mcg_status, uint64_t addr, uint64_t misc, @@ -891,16 +883,11 @@ static inline void kvm_inject_x86_mce(CPUState *cenv, int bank, abort(); } -#endif - -extern int kvm_allowed; - #endif /* !CONFIG_KVM */ int kvm_main_loop(void); int kvm_init_ap(void); -#ifndef QEMU_KVM_NO_CPU int kvm_vcpu_inited(CPUState *env); void kvm_load_mpstate(CPUState *env); void kvm_save_mpstate(CPUState *env); @@ -914,7 +901,6 @@ int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap); void kvm_apic_init(CPUState *env); /* called from vcpu initialization */ void qemu_kvm_load_lapic(CPUState *env); -#endif void kvm_hpet_enable_kpit(void); void kvm_hpet_disable_kpit(void); @@ -923,13 +909,11 @@ int kvm_set_irq(int irq, int level, int *status); int kvm_physical_memory_set_dirty_tracking(int enable); int kvm_update_dirty_pages_log(void); -#ifndef QEMU_KVM_NO_CPU void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *env); void qemu_kvm_cpuid_on_env(CPUState *env); void kvm_inject_interrupt(CPUState *env, int mask); void kvm_update_after_sipi(CPUState *env); void kvm_update_interrupt_request(CPUState *env); -#endif void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size, ram_addr_t phys_offset); void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr, unsigned long size, @@ -946,7 +930,6 @@ int kvm_qemu_destroy_memory_alias(uint64_t phys_start); int kvm_arch_qemu_create_context(void); -#ifndef QEMU_KVM_NO_CPU void kvm_arch_save_regs(CPUState *env); void kvm_arch_load_regs(CPUState *env); void kvm_arch_load_mpstate(CPUState *env); @@ -988,19 +971,15 @@ int kvm_arch_remove_hw_breakpoint(target_ulong addr, target_ulong len, void kvm_arch_remove_all_hw_breakpoints(void); void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); -#endif - void qemu_kvm_aio_wait_start(void); void qemu_kvm_aio_wait(void); void qemu_kvm_aio_wait_end(void); void qemu_kvm_notify_work(void); -#ifndef QEMU_KVM_NO_CPU void kvm_tpr_opt_setup(void); void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write); void kvm_tpr_vcpu_start(CPUState *env); -#endif int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf); int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size); @@ -1022,14 +1001,11 @@ void kvm_arch_do_ioperm(void *_data); #endif #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) -#ifndef QEMU_KVM_NO_CPU #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8) -#endif #ifdef CONFIG_KVM #include "qemu-queue.h" -extern int kvm_allowed; extern int kvm_irqchip; extern int kvm_pit; extern int kvm_pit_reinject; @@ -1049,7 +1025,6 @@ int handle_tpr_access(void *opaque, CPUState *env, uint64_t rip, int is_write); int kvm_has_sync_mmu(void); -#define kvm_enabled() (kvm_allowed) #define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context) #define qemu_kvm_has_gsi_routing() kvm_has_gsi_routing(kvm_context) #ifdef TARGET_I386 @@ -1059,11 +1034,9 @@ void kvm_init_vcpu(CPUState *env); void kvm_load_tsc(CPUState *env); #else #define kvm_has_sync_mmu() (0) -#define kvm_enabled() (0) #define kvm_nested 0 #define qemu_kvm_pit_in_kernel() (0) #define qemu_kvm_has_gsi_routing() (0) -#ifndef QEMU_KVM_NO_CPU #ifdef TARGET_I386 #define qemu_kvm_has_pit_state2() (0) #endif @@ -1077,7 +1050,6 @@ static inline void kvm_load_tsc(CPUState *env) { } #endif -#endif void kvm_mutex_unlock(void); void kvm_mutex_lock(void); @@ -1094,22 +1066,9 @@ static inline int kvm_sync_vcpus(void) return 0; } -#ifndef QEMU_KVM_NO_CPU -void kvm_cpu_synchronize_state(CPUState *env); - -static inline void cpu_synchronize_state(CPUState *env) -{ - if (kvm_enabled()) { - kvm_cpu_synchronize_state(env); - } -} - uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, int reg); - -#endif - static inline int kvm_set_migration_log(int enable) { return kvm_physical_memory_set_dirty_tracking(enable); diff --git a/vl.c b/vl.c index 79c33b4..f7f388f 100644 --- a/vl.c +++ b/vl.c @@ -157,7 +157,6 @@ int main(int argc, char **argv) #include "qemu-option.h" #include "qemu-config.h" #include "qemu-objects.h" -#include "qemu-kvm.h" #include "hw/device-assignment.h" #include "disas.h" @@ -5825,8 +5824,10 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "failed to initialize KVM\n"); exit(1); #endif +#ifdef CONFIG_KVM fprintf(stderr, "Could not initialize KVM, will disable KVM support\n"); kvm_allowed = 0; +#endif } }