All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Mohammed Gamal <m.gamal005@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] x86 emulator: Add 'push/pop sreg' instructions
Date: Wed, 19 Aug 2009 11:32:42 +0300	[thread overview]
Message-ID: <4A8BB8AA.5020401@redhat.com> (raw)
In-Reply-To: <1250655104-437-1-git-send-email-m.gamal005@gmail.com>

On 08/19/2009 07:11 AM, Mohammed Gamal wrote:
>
> +static void emulate_push_sreg(struct x86_emulate_ctxt *ctxt, int seg)
> +{
> +	struct decode_cache *c =&ctxt->decode;
> +	struct kvm_segment segment;
> +	
> +	if (ctxt->mode == X86EMUL_MODE_PROT64&&  (seg != VCPU_SREG_FS ||
> +						   seg != VCPU_SREG_GS)) {
> +		kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
> +		return;
> +	}
>    

It's better to check at the callsite, in case the opcode is ever reused 
for a new instruction.  Or even better, add a new decode flag No64 so we 
can do this during the decode stage.

> +
> +static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt,
> +			     struct x86_emulate_ops *ops, int seg)
> +{
> +	struct decode_cache *c =&ctxt->decode;
> +	struct kvm_segment segment;
> +	int rc;
> +
> +	if (ctxt->mode == X86EMUL_MODE_PROT64&&  (seg != VCPU_SREG_FS ||
> +						    seg != VCPU_SREG_GS)) {
> +		kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
> +		return -1;
> +	}
> +
> +	kvm_x86_ops->get_segment(ctxt->vcpu,&segment, seg);
> +	rc = emulate_pop(ctxt, ops,&segment.selector, c->op_bytes);
> +	if (rc != 0)
> +		return rc;
> +	
> +	rc = kvm_load_segment_descriptor(ctxt->vcpu, segment.selector, 1, seg);
> +	return rc;
> +}
>    

Why do the ->get_segment() at all?  pop into a temporary variable, and 
call kvm_load_segment_descriptor() with that.


-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2009-08-19  8:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19  4:11 [PATCH] x86 emulator: Add 'push/pop sreg' instructions Mohammed Gamal
2009-08-19  8:32 ` Avi Kivity [this message]
2009-08-19 12:52   ` Mohammed Gamal
2009-08-19 13:03     ` Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2009-08-19 13:26 Mohammed Gamal
2009-08-18 12:48 Mohammed Gamal
2009-08-18 14:39 ` Avi Kivity
2009-08-18 19:40   ` Mohammed Gamal
2009-08-19  8:23     ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A8BB8AA.5020401@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=m.gamal005@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.