aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2014-04-16 12:46:09 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-11 03:13:59 -0400
commit1498507a47867596de158d4db8728e92385a4919 (patch)
tree142c955f4accbcc4c41453ef6fe6be4b033177d8 /arch
parentf5f87dfbc777f89148c3c66438741139845d3ac6 (diff)
KVM: emulate: move init_decode_cache to emulate.c
Core emulator functions all belong in emulator.c, x86 should have no knowledge of emulator internals Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/kvm_emulate.h1
-rw-r--r--arch/x86/kvm/emulate.c13
-rw-r--r--arch/x86/kvm/x86.c13
3 files changed, 14 insertions, 13 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 432447370044..c22bd9af4311 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -409,6 +409,7 @@ bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt);
409#define EMULATION_OK 0 409#define EMULATION_OK 0
410#define EMULATION_RESTART 1 410#define EMULATION_RESTART 1
411#define EMULATION_INTERCEPTED 2 411#define EMULATION_INTERCEPTED 2
412void init_decode_cache(struct x86_emulate_ctxt *ctxt);
412int x86_emulate_insn(struct x86_emulate_ctxt *ctxt); 413int x86_emulate_insn(struct x86_emulate_ctxt *ctxt);
413int emulator_task_switch(struct x86_emulate_ctxt *ctxt, 414int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
414 u16 tss_selector, int idt_index, int reason, 415 u16 tss_selector, int idt_index, int reason,
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 32d3da82da2e..851315d93bf7 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4534,6 +4534,19 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *))
4534 return X86EMUL_CONTINUE; 4534 return X86EMUL_CONTINUE;
4535} 4535}
4536 4536
4537void init_decode_cache(struct x86_emulate_ctxt *ctxt)
4538{
4539 memset(&ctxt->opcode_len, 0,
4540 (void *)&ctxt->_regs - (void *)&ctxt->opcode_len);
4541
4542 ctxt->fetch.start = 0;
4543 ctxt->fetch.end = 0;
4544 ctxt->io_read.pos = 0;
4545 ctxt->io_read.end = 0;
4546 ctxt->mem_read.pos = 0;
4547 ctxt->mem_read.end = 0;
4548}
4549
4537int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) 4550int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
4538{ 4551{
4539 const struct x86_emulate_ops *ops = ctxt->ops; 4552 const struct x86_emulate_ops *ops = ctxt->ops;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cd9316786dca..905edf8557e7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4888,19 +4888,6 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu)
4888 kvm_queue_exception(vcpu, ctxt->exception.vector); 4888 kvm_queue_exception(vcpu, ctxt->exception.vector);
4889} 4889}
4890 4890
4891static void init_decode_cache(struct x86_emulate_ctxt *ctxt)
4892{
4893 memset(&ctxt->opcode_len, 0,
4894 (void *)&ctxt->_regs - (void *)&ctxt->opcode_len);
4895
4896 ctxt->fetch.start = 0;
4897 ctxt->fetch.end = 0;
4898 ctxt->io_read.pos = 0;
4899 ctxt->io_read.end = 0;
4900 ctxt->mem_read.pos = 0;
4901 ctxt->mem_read.end = 0;
4902}
4903
4904static void init_emulate_ctxt(struct kvm_vcpu *vcpu) 4891static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
4905{ 4892{
4906 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; 4893 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;