diff options
author | Nadav Amit <namit@cs.technion.ac.il> | 2014-09-18 15:39:37 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-10-24 07:21:15 -0400 |
commit | 05c83ec9b73c8124555b706f6af777b10adf0862 (patch) | |
tree | 21a9438789f3de20ca325371359333a26791e0cc /arch/x86 | |
parent | 2febc839133280d5a5e8e1179c94ea674489dae2 (diff) |
KVM: x86: Fix wrong masking on relative jump/call
Relative jumps and calls do the masking according to the operand size, and not
according to the address size as the KVM emulator does today.
This patch fixes KVM behavior.
Cc: stable@vger.kernel.org
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/emulate.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index a46207a05835..047698974799 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -504,11 +504,6 @@ static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc) | |||
504 | masked_increment(reg_rmw(ctxt, VCPU_REGS_RSP), stack_mask(ctxt), inc); | 504 | masked_increment(reg_rmw(ctxt, VCPU_REGS_RSP), stack_mask(ctxt), inc); |
505 | } | 505 | } |
506 | 506 | ||
507 | static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) | ||
508 | { | ||
509 | register_address_increment(ctxt, &ctxt->_eip, rel); | ||
510 | } | ||
511 | |||
512 | static u32 desc_limit_scaled(struct desc_struct *desc) | 507 | static u32 desc_limit_scaled(struct desc_struct *desc) |
513 | { | 508 | { |
514 | u32 limit = get_desc_limit(desc); | 509 | u32 limit = get_desc_limit(desc); |
@@ -569,6 +564,28 @@ static int emulate_nm(struct x86_emulate_ctxt *ctxt) | |||
569 | return emulate_exception(ctxt, NM_VECTOR, 0, false); | 564 | return emulate_exception(ctxt, NM_VECTOR, 0, false); |
570 | } | 565 | } |
571 | 566 | ||
567 | static inline void assign_eip_near(struct x86_emulate_ctxt *ctxt, ulong dst) | ||
568 | { | ||
569 | switch (ctxt->op_bytes) { | ||
570 | case 2: | ||
571 | ctxt->_eip = (u16)dst; | ||
572 | break; | ||
573 | case 4: | ||
574 | ctxt->_eip = (u32)dst; | ||
575 | break; | ||
576 | case 8: | ||
577 | ctxt->_eip = dst; | ||
578 | break; | ||
579 | default: | ||
580 | WARN(1, "unsupported eip assignment size\n"); | ||
581 | } | ||
582 | } | ||
583 | |||
584 | static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) | ||
585 | { | ||
586 | assign_eip_near(ctxt, ctxt->_eip + rel); | ||
587 | } | ||
588 | |||
572 | static u16 get_segment_selector(struct x86_emulate_ctxt *ctxt, unsigned seg) | 589 | static u16 get_segment_selector(struct x86_emulate_ctxt *ctxt, unsigned seg) |
573 | { | 590 | { |
574 | u16 selector; | 591 | u16 selector; |