Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80723
b: refs/heads/master
c: f8c16bb
h: refs/heads/master
i:
  80721: 29f5227
  80719: 6df0c6c
v: v3
  • Loading branch information
Zhang Xiantao authored and Avi Kivity committed Jan 30, 2008
1 parent 3aa0059 commit 0c2f6b5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb498ea2ce1d3f3c0bc0a2522241dca10263e437
refs/heads/master: f8c16bbaa9e14b309ffcf29cac0ea377a35b0dd2
5 changes: 3 additions & 2 deletions trunk/drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ void vcpu_put(struct kvm_vcpu *vcpu);
void decache_vcpus_on_cpu(int cpu);


int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
int kvm_init(void *opaque, unsigned int vcpu_size,
struct module *module);
void kvm_exit(void);

Expand Down Expand Up @@ -649,7 +649,8 @@ int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
struct kvm_debug_guest *dbg);
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);

__init void kvm_arch_init(void);
int kvm_arch_init(void *opaque);
void kvm_arch_exit(void);

int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
Expand Down
26 changes: 6 additions & 20 deletions trunk/drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
kvm_arch_vcpu_put(vcpu);
}

int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
int kvm_init(void *opaque, unsigned int vcpu_size,
struct module *module)
{
int r;
Expand All @@ -1446,7 +1446,9 @@ int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,

kvm_init_debug();

kvm_arch_init();
r = kvm_arch_init(opaque);
if (r)
goto out4;

bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);

Expand All @@ -1455,22 +1457,6 @@ int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
goto out;
}

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;

r = kvm_arch_hardware_setup();
if (r < 0)
goto out;
Expand Down Expand Up @@ -1534,7 +1520,7 @@ int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
out_free_0:
kvm_arch_hardware_unsetup();
out:
kvm_x86_ops = NULL;
kvm_arch_exit();
kvm_exit_debug();
kvm_mmu_module_exit();
out4:
Expand All @@ -1552,7 +1538,7 @@ void kvm_exit(void)
unregister_cpu_notifier(&kvm_cpu_notifier);
on_each_cpu(hardware_disable, NULL, 0, 1);
kvm_arch_hardware_unsetup();
kvm_x86_ops = NULL;
kvm_arch_exit();
kvm_exit_debug();
__free_page(bad_page);
kvm_mmu_module_exit();
Expand Down
27 changes: 26 additions & 1 deletion trunk/drivers/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0c2f6b5

Please sign in to comment.