Skip to content

Commit 0fcc207

Browse files
anadavbonzini
authored andcommitted
KVM: x86: Emulate push sreg as done in Core
According to Intel SDM push of segment selectors is done in the following manner: "if the operand size is 32-bits, either a zero-extended value is pushed on the stack or the segment selector is written on the stack using a 16-bit move. For the last case, all recent Core and Atom processors perform a 16-bit move, leaving the upper portion of the stack location unmodified." This patch modifies the behavior to match the core behavior. Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 5aca372 commit 0fcc207

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kvm/emulate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ static int em_push_sreg(struct x86_emulate_ctxt *ctxt)
18171817
int seg = ctxt->src2.val;
18181818

18191819
ctxt->src.val = get_segment_selector(ctxt, seg);
1820+
if (ctxt->op_bytes == 4) {
1821+
rsp_increment(ctxt, -2);
1822+
ctxt->op_bytes = 2;
1823+
}
18201824

18211825
return em_push(ctxt);
18221826
}

0 commit comments

Comments
 (0)