From: Avi Kivity Subject: [PATCH 11/21] KVM: Fix SS default ESP/EBP based addressing Date: Tue, 12 Jun 2012 20:34:28 +0300 Message-ID: <1339522478-2872-12-git-send-email-avi@redhat.com> References: <1339522478-2872-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2954 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753966Ab2FLRe6 (ORCPT ); Tue, 12 Jun 2012 13:34:58 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5CHYvI6027212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Jun 2012 13:34:58 -0400 In-Reply-To: <1339522478-2872-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: We correctly default to SS when BP is used as a base in 16-bit address mode, but we don't do that for 32-bit mode. Fix by adjusting the default to SS when either ESP or EBP is used as the base register. Signed-off-by: Avi Kivity --- arch/x86/kvm/emulate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 5b6f99d..0088e2d 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1077,8 +1077,12 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt, if ((base_reg & 7) == 5 && ctxt->modrm_mod == 0) modrm_ea += insn_fetch(s32, ctxt); - else + else { modrm_ea += ctxt->regs[base_reg]; + if (base_reg == VCPU_REGS_RSP + || base_reg == VCPU_REGS_RBP) + ctxt->modrm_seg = VCPU_SREG_SS; + } if (index_reg != 4) modrm_ea += ctxt->regs[index_reg] << scale; } else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) { -- 1.7.10.1