From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] x86 emulator: Add 'push/pop sreg' instructions Date: Tue, 18 Aug 2009 17:39:21 +0300 Message-ID: <4A8ABD19.1000807@redhat.com> References: <1250599685-2351-1-git-send-email-m.gamal005@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx2.redhat.com ([66.187.237.31]:49500 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbZHROjX (ORCPT ); Tue, 18 Aug 2009 10:39:23 -0400 In-Reply-To: <1250599685-2351-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/18/2009 03:48 PM, Mohammed Gamal wrote: > + > +static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt, > + struct x86_emulate_ops *ops, int seg) > +{ > + struct kvm_segment segment; > + int rc; > + > + kvm_x86_ops->get_segment(ctxt->vcpu,&segment, seg); > + rc = emulate_pop(ctxt, ops,&segment.selector, sizeof(uint16_t)); > 'pop seg' is still subject to the operand size (I think). > + kvm_x86_ops->set_segment(ctxt->vcpu,&segment, seg); > You need to call kvm_load_segment_descriptor() so that the segment cache is also loaded correctly. Note some of these instructions are not encodable in long mode; need to check for that instead of emulating the wrong instruction. > @@ -1707,18 +1732,45 @@ special_insn: > add: /* add */ > emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags); > break; > + case 0x06: /* push es */ > + emulate_push_sreg(ctxt, VCPU_SREG_ES); > + break; > + case 0x07: /* pop es */ > + rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_ES); > + if (rc != 0) > + goto done; > + break; > case 0x08 ... 0x0d: > or: /* or */ > emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags); > break; > + case 0x0e: /* push cs */ > + emulate_push_sreg(ctxt, VCPU_SREG_CS); > + break; > case 0x10 ... 0x15: > adc: /* adc */ > emulate_2op_SrcV("adc", c->src, c->dst, ctxt->eflags); > break; > + case 0x16: /* push ss */ > + emulate_push_sreg(ctxt, VCPU_SREG_SS); > + break; > + case 0x17: /* pop ss */ > + rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_SS); > + if (rc != 0) > + goto done; > + break; > case 0x18 ... 0x1d: > sbb: /* sbb */ > emulate_2op_SrcV("sbb", c->src, c->dst, ctxt->eflags); > break; > + case 0x1e: /* push ds */ > + emulate_push_sreg(ctxt, VCPU_SREG_DS); > + break; > + case 0x1f: /* pop ds */ > + rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_DS); > + if (rc != 0) > + goto done; > + break; > case 0x20 ... 0x25: > and: /* and */ > emulate_2op_SrcV("and", c->src, c->dst, ctxt->eflags); > -- error compiling committee.c: too many arguments to function