aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@amd.com>2010-12-21 05:12:01 -0500
committerAvi Kivity <avi@redhat.com>2011-01-12 04:30:59 -0500
commitdb8fcefaa704ccb40b6dcd24e3b75bad3ce7dde3 (patch)
tree7915835b4ebe513bbb9ad08388db5a45fa0355f0 /arch/x86/kvm
parenteea1cff9ab732ea56358ff5e1bd8b99db2e8402d (diff)
KVM: move complete_insn_gp() into x86.c
move the complete_insn_gp() helper function out of the VMX part into the generic x86 part to make it usable by SVM. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx.c16
-rw-r--r--arch/x86/kvm/x86.c9
2 files changed, 13 insertions, 12 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8e87bae09a7a..fd8ffde73755 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3147,14 +3147,6 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall)
3147 hypercall[2] = 0xc1; 3147 hypercall[2] = 0xc1;
3148} 3148}
3149 3149
3150static void complete_insn_gp(struct kvm_vcpu *vcpu, int err)
3151{
3152 if (err)
3153 kvm_inject_gp(vcpu, 0);
3154 else
3155 skip_emulated_instruction(vcpu);
3156}
3157
3158static int handle_cr(struct kvm_vcpu *vcpu) 3150static int handle_cr(struct kvm_vcpu *vcpu)
3159{ 3151{
3160 unsigned long exit_qualification, val; 3152 unsigned long exit_qualification, val;
@@ -3172,21 +3164,21 @@ static int handle_cr(struct kvm_vcpu *vcpu)
3172 switch (cr) { 3164 switch (cr) {
3173 case 0: 3165 case 0:
3174 err = kvm_set_cr0(vcpu, val); 3166 err = kvm_set_cr0(vcpu, val);
3175 complete_insn_gp(vcpu, err); 3167 kvm_complete_insn_gp(vcpu, err);
3176 return 1; 3168 return 1;
3177 case 3: 3169 case 3:
3178 err = kvm_set_cr3(vcpu, val); 3170 err = kvm_set_cr3(vcpu, val);
3179 complete_insn_gp(vcpu, err); 3171 kvm_complete_insn_gp(vcpu, err);
3180 return 1; 3172 return 1;
3181 case 4: 3173 case 4:
3182 err = kvm_set_cr4(vcpu, val); 3174 err = kvm_set_cr4(vcpu, val);
3183 complete_insn_gp(vcpu, err); 3175 kvm_complete_insn_gp(vcpu, err);
3184 return 1; 3176 return 1;
3185 case 8: { 3177 case 8: {
3186 u8 cr8_prev = kvm_get_cr8(vcpu); 3178 u8 cr8_prev = kvm_get_cr8(vcpu);
3187 u8 cr8 = kvm_register_read(vcpu, reg); 3179 u8 cr8 = kvm_register_read(vcpu, reg);
3188 err = kvm_set_cr8(vcpu, cr8); 3180 err = kvm_set_cr8(vcpu, cr8);
3189 complete_insn_gp(vcpu, err); 3181 kvm_complete_insn_gp(vcpu, err);
3190 if (irqchip_in_kernel(vcpu->kvm)) 3182 if (irqchip_in_kernel(vcpu->kvm))
3191 return 1; 3183 return 1;
3192 if (cr8_prev <= cr8) 3184 if (cr8_prev <= cr8)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2dbf68cd46e3..1d54cb7f3358 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -334,6 +334,15 @@ void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr)
334} 334}
335EXPORT_SYMBOL_GPL(kvm_requeue_exception); 335EXPORT_SYMBOL_GPL(kvm_requeue_exception);
336 336
337void kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err)
338{
339 if (err)
340 kvm_inject_gp(vcpu, 0);
341 else
342 kvm_x86_ops->skip_emulated_instruction(vcpu);
343}
344EXPORT_SYMBOL_GPL(kvm_complete_insn_gp);
345
337void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault) 346void kvm_inject_page_fault(struct kvm_vcpu *vcpu, struct x86_exception *fault)
338{ 347{
339 ++vcpu->stat.pf_guest; 348 ++vcpu->stat.pf_guest;