From: "Jan Beulich" <jbeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86 emulation: fix bswap
Date: Thu, 15 Feb 2007 10:22:38 +0000 [thread overview]
Message-ID: <45D4427E.76E4.0078.0@novell.com> (raw)
REX.R needs to be decoded and since bswap on a 16-bit operand is undefined,
it is best to have hardware execute this so the emulation result matches
hardware behavior. Since it is simple to do, faster, and smaller, also let hardware
do 32- and 64-bit ones.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Index: 2007-02-07/xen/arch/x86/x86_emulate.c
===================================================================
--- 2007-02-07.orig/xen/arch/x86/x86_emulate.c 2007-02-08 08:46:39.000000000 +0100
+++ 2007-02-07/xen/arch/x86/x86_emulate.c 2007-02-08 09:32:00.000000000 +0100
@@ -2326,32 +2326,22 @@ x86_emulate(
case 0xc8 ... 0xcf: /* bswap */
dst.type = OP_REG;
- dst.reg = decode_register(b & 7, &_regs, 0);
+ dst.reg = decode_register(
+ (b & 7) | ((rex_prefix & 1) << 3), &_regs, 0);
dst.val = *dst.reg;
switch ( dst.bytes = op_bytes )
{
case 2:
- dst.val = (((dst.val & 0x00FFUL) << 8) |
- ((dst.val & 0xFF00UL) >> 8));
+ __asm__("data16 bswap %k0" : "+r" (dst.val));
break;
case 4:
- dst.val = (((dst.val & 0x000000FFUL) << 24) |
- ((dst.val & 0x0000FF00UL) << 8) |
- ((dst.val & 0x00FF0000UL) >> 8) |
- ((dst.val & 0xFF000000UL) >> 24));
- break;
#ifdef __x86_64__
- case 8:
- dst.val = (((dst.val & 0x00000000000000FFUL) << 56) |
- ((dst.val & 0x000000000000FF00UL) << 40) |
- ((dst.val & 0x0000000000FF0000UL) << 24) |
- ((dst.val & 0x00000000FF000000UL) << 8) |
- ((dst.val & 0x000000FF00000000UL) >> 8) |
- ((dst.val & 0x0000FF0000000000UL) >> 24) |
- ((dst.val & 0x00FF000000000000UL) >> 40) |
- ((dst.val & 0xFF00000000000000UL) >> 56));
+ __asm__("bswap %k0" : "+r" (dst.val));
break;
+ case 8:
#endif
+ __asm__("bswap %0" : "+r" (dst.val));
+ break;
}
break;
}
next reply other threads:[~2007-02-15 10:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-15 10:22 Jan Beulich [this message]
2007-02-15 10:33 ` [PATCH] x86 emulation: fix bswap Keir Fraser
2007-02-15 11:37 ` Jan Beulich
2007-02-15 11:46 ` Petersson, Mats
2007-02-15 11:54 ` Keir Fraser
2007-02-15 12:12 ` Petersson, Mats
2007-02-16 7:32 ` Error with vfb Xen 3.0.4 Kaushik Barde
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=45D4427E.76E4.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=xen-devel@lists.xensource.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.