KVM: x86 emulator: add ->fix_hypercall() callback
authorAvi Kivity <avi@redhat.com>
Wed, 20 Apr 2011 12:47:13 +0000 (15:47 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 22 May 2011 12:39:18 +0000 (08:39 -0400)
Artificial, but needed to remove direct calls to KVM.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index d30f1e9b7544ccf74a069992598817f4bd7a74a7..d30840ddd2f3ddcee4a012cc670e4b01d47bb6cf 100644 (file)
@@ -187,6 +187,7 @@ struct x86_emulate_ops {
        int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data);
        int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata);
        void (*halt)(struct x86_emulate_ctxt *ctxt);
+       int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt);
        void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */
        void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */
        int (*intercept)(struct x86_emulate_ctxt *ctxt,
index d957d0d06562e5330064ba91b16e64d72df23269..6cfc1ab2cdd63910955ef8caaa6d9a35ebd6ce27 100644 (file)
@@ -752,8 +752,6 @@ gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva,
 
 int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
 
-int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
-
 int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
                       void *insn, int insn_len);
 void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva);
index 210df51b76a4557b45f9b56bf958755195c91d6f..64e7373d3b2b019cb7584134fab3cd9bc84d4dfd 100644 (file)
@@ -4025,7 +4025,7 @@ twobyte_insn:
                        if (c->modrm_mod != 3 || c->modrm_rm != 1)
                                goto cannot_emulate;
 
-                       rc = kvm_fix_hypercall(ctxt->vcpu);
+                       rc = ctxt->ops->fix_hypercall(ctxt);
                        if (rc != X86EMUL_CONTINUE)
                                goto done;
 
@@ -4048,7 +4048,7 @@ twobyte_insn:
                        if (c->modrm_mod == 3) {
                                switch (c->modrm_rm) {
                                case 1:
-                                       rc = kvm_fix_hypercall(ctxt->vcpu);
+                                       rc = ctxt->ops->fix_hypercall(ctxt);
                                        break;
                                default:
                                        goto cannot_emulate;
index 2246cf1a4ee07b58bc2477ff8b4df211f3fdb44a..4a2b40e2502160a5321119cc84e02307b6412b0d 100644 (file)
@@ -152,6 +152,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
 
 u64 __read_mostly host_xcr0;
 
+int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt);
+
 static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu)
 {
        int i;
@@ -4406,6 +4408,7 @@ static struct x86_emulate_ops emulate_ops = {
        .set_msr             = emulator_set_msr,
        .get_msr             = emulator_get_msr,
        .halt                = emulator_halt,
+       .fix_hypercall       = emulator_fix_hypercall,
        .get_fpu             = emulator_get_fpu,
        .put_fpu             = emulator_put_fpu,
        .intercept           = emulator_intercept,
@@ -5042,8 +5045,9 @@ out:
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_hypercall);
 
-int kvm_fix_hypercall(struct kvm_vcpu *vcpu)
+int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt)
 {
+       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
        char instruction[3];
        unsigned long rip = kvm_rip_read(vcpu);