From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nadav Amit Subject: [PATCH 11/21] KVM: x86: Emulate push sreg as done in Core Date: Sun, 2 Nov 2014 11:54:51 +0200 Message-ID: <1414922101-17626-12-git-send-email-namit@cs.technion.ac.il> References: <1414922101-17626-1-git-send-email-namit@cs.technion.ac.il> Cc: kvm@vger.kernel.org, nadav.amit@gmail.com, Nadav Amit To: pbonzini@redhat.com Return-path: Received: from mailgw12.technion.ac.il ([132.68.225.12]:46469 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbaKBJzT (ORCPT ); Sun, 2 Nov 2014 04:55:19 -0500 In-Reply-To: <1414922101-17626-1-git-send-email-namit@cs.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- arch/x86/kvm/emulate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 9dfd286..d45a57b 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1797,6 +1797,10 @@ static int em_push_sreg(struct x86_emulate_ctxt *ctxt) int seg = ctxt->src2.val; ctxt->src.val = get_segment_selector(ctxt, seg); + if (ctxt->op_bytes == 4) { + rsp_increment(ctxt, -2); + ctxt->op_bytes = 2; + } return em_push(ctxt); } -- 1.9.1