diff options
author | Avi Kivity <avi@redhat.com> | 2011-04-20 08:47:13 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-22 08:39:18 -0400 |
commit | d6aa10003b0cded5a538af0d198460e89dc2d6d2 (patch) | |
tree | 1a98dd6a65d5c9deaa83616b3a74fdcff5ca00fd /arch/x86 | |
parent | 6c3287f7c5050076b554145f11bdba058de287d1 (diff) |
KVM: x86 emulator: add ->fix_hypercall() callback
Artificial, but needed to remove direct calls to KVM.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 4 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 6 |
4 files changed, 8 insertions, 5 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index d30f1e9b7544..d30840ddd2f3 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -187,6 +187,7 @@ struct x86_emulate_ops { | |||
187 | int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data); | 187 | int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data); |
188 | int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata); | 188 | int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata); |
189 | void (*halt)(struct x86_emulate_ctxt *ctxt); | 189 | void (*halt)(struct x86_emulate_ctxt *ctxt); |
190 | int (*fix_hypercall)(struct x86_emulate_ctxt *ctxt); | ||
190 | void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */ | 191 | void (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */ |
191 | void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */ | 192 | void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */ |
192 | int (*intercept)(struct x86_emulate_ctxt *ctxt, | 193 | int (*intercept)(struct x86_emulate_ctxt *ctxt, |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index d957d0d06562..6cfc1ab2cdd6 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -752,8 +752,6 @@ gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, | |||
752 | 752 | ||
753 | int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); | 753 | int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); |
754 | 754 | ||
755 | int kvm_fix_hypercall(struct kvm_vcpu *vcpu); | ||
756 | |||
757 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, | 755 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, |
758 | void *insn, int insn_len); | 756 | void *insn, int insn_len); |
759 | void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); | 757 | void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 210df51b76a4..64e7373d3b2b 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -4025,7 +4025,7 @@ twobyte_insn: | |||
4025 | if (c->modrm_mod != 3 || c->modrm_rm != 1) | 4025 | if (c->modrm_mod != 3 || c->modrm_rm != 1) |
4026 | goto cannot_emulate; | 4026 | goto cannot_emulate; |
4027 | 4027 | ||
4028 | rc = kvm_fix_hypercall(ctxt->vcpu); | 4028 | rc = ctxt->ops->fix_hypercall(ctxt); |
4029 | if (rc != X86EMUL_CONTINUE) | 4029 | if (rc != X86EMUL_CONTINUE) |
4030 | goto done; | 4030 | goto done; |
4031 | 4031 | ||
@@ -4048,7 +4048,7 @@ twobyte_insn: | |||
4048 | if (c->modrm_mod == 3) { | 4048 | if (c->modrm_mod == 3) { |
4049 | switch (c->modrm_rm) { | 4049 | switch (c->modrm_rm) { |
4050 | case 1: | 4050 | case 1: |
4051 | rc = kvm_fix_hypercall(ctxt->vcpu); | 4051 | rc = ctxt->ops->fix_hypercall(ctxt); |
4052 | break; | 4052 | break; |
4053 | default: | 4053 | default: |
4054 | goto cannot_emulate; | 4054 | goto cannot_emulate; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2246cf1a4ee0..4a2b40e25021 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -152,6 +152,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
152 | 152 | ||
153 | u64 __read_mostly host_xcr0; | 153 | u64 __read_mostly host_xcr0; |
154 | 154 | ||
155 | int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt); | ||
156 | |||
155 | static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu) | 157 | static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu) |
156 | { | 158 | { |
157 | int i; | 159 | int i; |
@@ -4406,6 +4408,7 @@ static struct x86_emulate_ops emulate_ops = { | |||
4406 | .set_msr = emulator_set_msr, | 4408 | .set_msr = emulator_set_msr, |
4407 | .get_msr = emulator_get_msr, | 4409 | .get_msr = emulator_get_msr, |
4408 | .halt = emulator_halt, | 4410 | .halt = emulator_halt, |
4411 | .fix_hypercall = emulator_fix_hypercall, | ||
4409 | .get_fpu = emulator_get_fpu, | 4412 | .get_fpu = emulator_get_fpu, |
4410 | .put_fpu = emulator_put_fpu, | 4413 | .put_fpu = emulator_put_fpu, |
4411 | .intercept = emulator_intercept, | 4414 | .intercept = emulator_intercept, |
@@ -5042,8 +5045,9 @@ out: | |||
5042 | } | 5045 | } |
5043 | EXPORT_SYMBOL_GPL(kvm_emulate_hypercall); | 5046 | EXPORT_SYMBOL_GPL(kvm_emulate_hypercall); |
5044 | 5047 | ||
5045 | int kvm_fix_hypercall(struct kvm_vcpu *vcpu) | 5048 | int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt) |
5046 | { | 5049 | { |
5050 | struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); | ||
5047 | char instruction[3]; | 5051 | char instruction[3]; |
5048 | unsigned long rip = kvm_rip_read(vcpu); | 5052 | unsigned long rip = kvm_rip_read(vcpu); |
5049 | 5053 | ||