aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-06-05 08:53:05 -0400
committerAvi Kivity <avi@qumranet.com>2007-07-16 05:05:46 -0400
commitd3bef15f84f91c73a5515ad4c6a1749f8f63afcf (patch)
tree3349c121f16a5fe0e1c30d4370573c2a9ed88bb9 /drivers/kvm
parentef9254df0b3aeba729e26a062803ee7d90437b5e (diff)
KVM: Move duplicate halt handling code into kvm_main.c
Will soon have a thid user. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c11
-rw-r--r--drivers/kvm/svm.c7
-rw-r--r--drivers/kvm/vmx.c7
4 files changed, 14 insertions, 12 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index e665f5500159..ac358b8d3de8 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -504,6 +504,7 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
504 int size, unsigned long count, int string, int down, 504 int size, unsigned long count, int string, int down,
505 gva_t address, int rep, unsigned port); 505 gva_t address, int rep, unsigned port);
506void kvm_emulate_cpuid(struct kvm_vcpu *vcpu); 506void kvm_emulate_cpuid(struct kvm_vcpu *vcpu);
507int kvm_emulate_halt(struct kvm_vcpu *vcpu);
507int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address); 508int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address);
508int emulate_clts(struct kvm_vcpu *vcpu); 509int emulate_clts(struct kvm_vcpu *vcpu);
509int emulator_get_dr(struct x86_emulate_ctxt* ctxt, int dr, 510int emulator_get_dr(struct x86_emulate_ctxt* ctxt, int dr,
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 230b25aa469c..556416962541 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1285,6 +1285,17 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
1285} 1285}
1286EXPORT_SYMBOL_GPL(emulate_instruction); 1286EXPORT_SYMBOL_GPL(emulate_instruction);
1287 1287
1288int kvm_emulate_halt(struct kvm_vcpu *vcpu)
1289{
1290 if (vcpu->irq_summary)
1291 return 1;
1292
1293 vcpu->run->exit_reason = KVM_EXIT_HLT;
1294 ++vcpu->stat.halt_exits;
1295 return 0;
1296}
1297EXPORT_SYMBOL_GPL(kvm_emulate_halt);
1298
1288int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run) 1299int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run)
1289{ 1300{
1290 unsigned long nr, a0, a1, a2, a3, a4, a5, ret; 1301 unsigned long nr, a0, a1, a2, a3, a4, a5, ret;
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index ec040e2f8c58..70f386e04cbe 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1115,12 +1115,7 @@ static int halt_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1115{ 1115{
1116 vcpu->svm->next_rip = vcpu->svm->vmcb->save.rip + 1; 1116 vcpu->svm->next_rip = vcpu->svm->vmcb->save.rip + 1;
1117 skip_emulated_instruction(vcpu); 1117 skip_emulated_instruction(vcpu);
1118 if (vcpu->irq_summary) 1118 return kvm_emulate_halt(vcpu);
1119 return 1;
1120
1121 kvm_run->exit_reason = KVM_EXIT_HLT;
1122 ++vcpu->stat.halt_exits;
1123 return 0;
1124} 1119}
1125 1120
1126static int vmmcall_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1121static int vmmcall_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index a534e6fe8184..90abd3c58c65 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1896,12 +1896,7 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu,
1896static int handle_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1896static int handle_halt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1897{ 1897{
1898 skip_emulated_instruction(vcpu); 1898 skip_emulated_instruction(vcpu);
1899 if (vcpu->irq_summary) 1899 return kvm_emulate_halt(vcpu);
1900 return 1;
1901
1902 kvm_run->exit_reason = KVM_EXIT_HLT;
1903 ++vcpu->stat.halt_exits;
1904 return 0;
1905} 1900}
1906 1901
1907static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 1902static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)