Commit d6aa1000 authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: add ->fix_hypercall() callback

Artificial, but needed to remove direct calls to KVM.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 6c3287f7
...@@ -187,6 +187,7 @@ struct x86_emulate_ops { ...@@ -187,6 +187,7 @@ struct x86_emulate_ops {
int (*set_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 data); 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); int (*get_msr)(struct x86_emulate_ctxt *ctxt, u32 msr_index, u64 *pdata);
void (*halt)(struct x86_emulate_ctxt *ctxt); 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 (*get_fpu)(struct x86_emulate_ctxt *ctxt); /* disables preempt */
void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */ void (*put_fpu)(struct x86_emulate_ctxt *ctxt); /* reenables preempt */
int (*intercept)(struct x86_emulate_ctxt *ctxt, int (*intercept)(struct x86_emulate_ctxt *ctxt,
......
...@@ -752,8 +752,6 @@ gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, ...@@ -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_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, int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
void *insn, int insn_len); void *insn, int insn_len);
void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva);
......
...@@ -4025,7 +4025,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -4025,7 +4025,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
if (c->modrm_mod != 3 || c->modrm_rm != 1) if (c->modrm_mod != 3 || c->modrm_rm != 1)
goto cannot_emulate; goto cannot_emulate;
rc = kvm_fix_hypercall(ctxt->vcpu); rc = ctxt->ops->fix_hypercall(ctxt);
if (rc != X86EMUL_CONTINUE) if (rc != X86EMUL_CONTINUE)
goto done; goto done;
...@@ -4048,7 +4048,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -4048,7 +4048,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
if (c->modrm_mod == 3) { if (c->modrm_mod == 3) {
switch (c->modrm_rm) { switch (c->modrm_rm) {
case 1: case 1:
rc = kvm_fix_hypercall(ctxt->vcpu); rc = ctxt->ops->fix_hypercall(ctxt);
break; break;
default: default:
goto cannot_emulate; goto cannot_emulate;
......
...@@ -152,6 +152,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -152,6 +152,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
u64 __read_mostly host_xcr0; 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) static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu)
{ {
int i; int i;
...@@ -4406,6 +4408,7 @@ static struct x86_emulate_ops emulate_ops = { ...@@ -4406,6 +4408,7 @@ static struct x86_emulate_ops emulate_ops = {
.set_msr = emulator_set_msr, .set_msr = emulator_set_msr,
.get_msr = emulator_get_msr, .get_msr = emulator_get_msr,
.halt = emulator_halt, .halt = emulator_halt,
.fix_hypercall = emulator_fix_hypercall,
.get_fpu = emulator_get_fpu, .get_fpu = emulator_get_fpu,
.put_fpu = emulator_put_fpu, .put_fpu = emulator_put_fpu,
.intercept = emulator_intercept, .intercept = emulator_intercept,
...@@ -5042,8 +5045,9 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) ...@@ -5042,8 +5045,9 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
} }
EXPORT_SYMBOL_GPL(kvm_emulate_hypercall); 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]; char instruction[3];
unsigned long rip = kvm_rip_read(vcpu); unsigned long rip = kvm_rip_read(vcpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment