aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2011-05-14 11:54:58 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 04:44:56 -0400
commit67cbc90db5c0f03aa5e54204c388403ec8c25862 (patch)
tree105b1c9dfac9b34f5232852784cdc2f94113a238 /arch/x86
parente76779339ba9c3d56f1a39ff0bfb1dfe7614b062 (diff)
KVM: x86 emulator: Place insn_fetch helpers together
The two macros need special care to use: Assume rc, ctxt, ops and done exist outside of them. Can goto outside. Considering the fact that these are used only in decode functions, moving these right after do_insn_fetch() seems to be a right thing to improve the readability. We also rename do_fetch_insn_byte() to do_insn_fetch_byte() to be consistent. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/emulate.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index adc98675cda0..6e4722c3dcdb 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -407,23 +407,6 @@ struct gprefix {
407 } \ 407 } \
408 } while (0) 408 } while (0)
409 409
410/* Fetch next part of the instruction being emulated. */
411#define insn_fetch(_type, _size, _eip) \
412({ unsigned long _x; \
413 rc = do_insn_fetch(ctxt, ops, (_eip), &_x, (_size)); \
414 if (rc != X86EMUL_CONTINUE) \
415 goto done; \
416 (_eip) += (_size); \
417 (_type)_x; \
418})
419
420#define insn_fetch_arr(_arr, _size, _eip) \
421({ rc = do_insn_fetch(ctxt, ops, (_eip), _arr, (_size)); \
422 if (rc != X86EMUL_CONTINUE) \
423 goto done; \
424 (_eip) += (_size); \
425})
426
427static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt, 410static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
428 enum x86_intercept intercept, 411 enum x86_intercept intercept,
429 enum x86_intercept_stage stage) 412 enum x86_intercept_stage stage)
@@ -671,7 +654,7 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
671 return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception); 654 return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
672} 655}
673 656
674static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, 657static int do_insn_fetch_byte(struct x86_emulate_ctxt *ctxt,
675 struct x86_emulate_ops *ops, 658 struct x86_emulate_ops *ops,
676 unsigned long eip, u8 *dest) 659 unsigned long eip, u8 *dest)
677{ 660{
@@ -707,13 +690,30 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt,
707 if (eip + size - ctxt->eip > 15) 690 if (eip + size - ctxt->eip > 15)
708 return X86EMUL_UNHANDLEABLE; 691 return X86EMUL_UNHANDLEABLE;
709 while (size--) { 692 while (size--) {
710 rc = do_fetch_insn_byte(ctxt, ops, eip++, dest++); 693 rc = do_insn_fetch_byte(ctxt, ops, eip++, dest++);
711 if (rc != X86EMUL_CONTINUE) 694 if (rc != X86EMUL_CONTINUE)
712 return rc; 695 return rc;
713 } 696 }
714 return X86EMUL_CONTINUE; 697 return X86EMUL_CONTINUE;
715} 698}
716 699
700/* Fetch next part of the instruction being emulated. */
701#define insn_fetch(_type, _size, _eip) \
702({ unsigned long _x; \
703 rc = do_insn_fetch(ctxt, ops, (_eip), &_x, (_size)); \
704 if (rc != X86EMUL_CONTINUE) \
705 goto done; \
706 (_eip) += (_size); \
707 (_type)_x; \
708})
709
710#define insn_fetch_arr(_arr, _size, _eip) \
711({ rc = do_insn_fetch(ctxt, ops, (_eip), _arr, (_size)); \
712 if (rc != X86EMUL_CONTINUE) \
713 goto done; \
714 (_eip) += (_size); \
715})
716
717/* 717/*
718 * Given the 'reg' portion of a ModRM byte, and a register block, return a 718 * Given the 'reg' portion of a ModRM byte, and a register block, return a
719 * pointer into the block that addresses the relevant register. 719 * pointer into the block that addresses the relevant register.