diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-11-14 20:40:21 +0800 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 17:53:03 +0200 |
commit | f8c16bbaa9e14b309ffcf29cac0ea377a35b0dd2 (patch) | |
tree | fde560989f7c3aa77d0f869a90084369c72d7dc4 /drivers/kvm/x86.c | |
parent | cb498ea2ce1d3f3c0bc0a2522241dca10263e437 (diff) | |
download | lwn-f8c16bbaa9e14b309ffcf29cac0ea377a35b0dd2.tar.gz lwn-f8c16bbaa9e14b309ffcf29cac0ea377a35b0dd2.zip |
KVM: Portability: Move x86 specific code from kvm_init() to kvm_arch()
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Acked-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r-- | drivers/kvm/x86.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c index 4902b35060f5..bbfa810bf8bd 100644 --- a/drivers/kvm/x86.c +++ b/drivers/kvm/x86.c @@ -1645,11 +1645,36 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, } EXPORT_SYMBOL_GPL(kvm_emulate_pio_string); -__init void kvm_arch_init(void) +int kvm_arch_init(void *opaque) { + struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque; + kvm_init_msr_list(); + + if (kvm_x86_ops) { + printk(KERN_ERR "kvm: already loaded the other module\n"); + return -EEXIST; + } + + if (!ops->cpu_has_kvm_support()) { + printk(KERN_ERR "kvm: no hardware support\n"); + return -EOPNOTSUPP; + } + if (ops->disabled_by_bios()) { + printk(KERN_ERR "kvm: disabled by bios\n"); + return -EOPNOTSUPP; + } + + kvm_x86_ops = ops; + + return 0; } +void kvm_arch_exit(void) +{ + kvm_x86_ops = NULL; + } + int kvm_emulate_halt(struct kvm_vcpu *vcpu) { ++vcpu->stat.halt_exits; |