From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCHv2] KVM: x86 emulator: fix pusha instruction emulation Date: Tue, 15 Jun 2010 14:00:20 +0300 Message-ID: <4C175D44.9090104@redhat.com> References: <4C16D0A0.2090203@cn.fujitsu.com> <4C16D165.8020406@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Wei Yongjun Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1025 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754094Ab0FOLAc (ORCPT ); Tue, 15 Jun 2010 07:00:32 -0400 In-Reply-To: <4C16D165.8020406@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/15/2010 04:03 AM, Wei Yongjun wrote: > emulate pusha instruction only writeback the last > EDI register, but the other registers which need > to be writeback is ignored. This patch fixed it. > > Ouch. > > -static void emulate_pusha(struct x86_emulate_ctxt *ctxt, > +static int emulate_pusha(struct x86_emulate_ctxt *ctxt, > struct x86_emulate_ops *ops) > { > struct decode_cache *c = &ctxt->decode; > unsigned long old_esp = c->regs[VCPU_REGS_RSP]; > + int rc = X86EMUL_CONTINUE; > int reg = VCPU_REGS_RAX; > > while (reg <= VCPU_REGS_RDI) { > @@ -1663,8 +1722,18 @@ static void emulate_pusha(struct x86_emulate_ctxt *ctxt, > (c->src.val = old_esp) : (c->src.val = c->regs[reg]); > > emulate_push(ctxt, ops); > + > + rc = writeback(ctxt, ops); > + if (rc != X86EMUL_CONTINUE) > + return rc; > + > We might have partial completion if we fault on the one the second or later register. Still, it's an improvement over what we have now. > ++reg; > } > + > + /* Disable writeback. */ > + c->dst.type = OP_NONE; > + > + return rc; > } > > -- error compiling committee.c: too many arguments to function