All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keir Fraser <keir@xen.org>
To: Jan Beulich <JBeulich@suse.com>, xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] x86/emul: only emulate possibly operand sizes for POPA
Date: Wed, 07 Nov 2012 17:10:37 +0000	[thread overview]
Message-ID: <CCC0468D.51958%keir@xen.org> (raw)
In-Reply-To: <509A958E02000078000A7039@nat28.tlf.novell.com>

On 07/11/2012 16:08, "Jan Beulich" <JBeulich@suse.com> wrote:

> This opcode neither support 1-byte operands, nor does it support 8-byte
> ones (since the opcode is undefined in 64-bit mode). Simplify the code
> accordingly.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -1996,13 +1996,10 @@ x86_emulate(
>              if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
>                                    &dst.val, op_bytes, ctxt, ops)) != 0 )
>                  goto done;
> -            switch ( op_bytes )
> -            {
> -            case 1: *(uint8_t  *)regs[i] = (uint8_t)dst.val; break;
> -            case 2: *(uint16_t *)regs[i] = (uint16_t)dst.val; break;
> -            case 4: *regs[i] = (uint32_t)dst.val; break; /* 64b: zero-ext */
> -            case 8: *regs[i] = dst.val; break;
> -            }
> +            if ( op_bytes != 2 )
> +                *regs[i] = (uint32_t)dst.val; /* 64b: zero-ext */
> +            else
> +                *(uint16_t *)regs[i] = (uint16_t)dst.val;

Would prefer:
 if ( op_bytes == 2 )
     *(uint16_t *)regs[i] = (uint16_t)dst.val;
 else
     *regs[i] = dst.val;

Handles the exceptional case immediately after its predicate. And the cast
from uint32_t, and 64b-related comment, are pointless and in fact misleading
in the default case, since as you say the instruction is invalid in 64-bit
mode.

Apart from that:
Acked-by: Keir Fraser <keir@xen.org>

 -- Keir

>          }
>          break;
>      }
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  reply	other threads:[~2012-11-07 17:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 16:08 [PATCH] x86/emul: only emulate possibly operand sizes for POPA Jan Beulich
2012-11-07 17:10 ` Keir Fraser [this message]
2012-11-08  7:34   ` Jan Beulich
2012-11-08  7:48     ` Keir Fraser
2012-11-08  8:34       ` Jan Beulich
2012-11-08  9:08         ` Keir Fraser

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=CCC0468D.51958%keir@xen.org \
    --to=keir@xen.org \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /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.