WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] [PATCH] x86 emulation: fix bswap

To: "Keir Fraser" <keir@xxxxxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: RE: [Xen-devel] [PATCH] x86 emulation: fix bswap
From: "Petersson, Mats" <Mats.Petersson@xxxxxxx>
Date: Thu, 15 Feb 2007 13:12:44 +0100
Delivery-date: Thu, 15 Feb 2007 04:12:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C1F9FA73.977E%keir@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcdQ7LFF74/AALzfEdu/0gAX8io7RQACKPMwAACtewoAAGO2MA==
Thread-topic: [Xen-devel] [PATCH] x86 emulation: fix bswap
 

> -----Original Message-----
> From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx 
> [mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Keir Fraser
> Sent: 15 February 2007 11:54
> To: Petersson, Mats; Jan Beulich; xen-devel@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [Xen-devel] [PATCH] x86 emulation: fix bswap
> 
> 
> 
> 
> On 15/2/07 11:46, "Petersson, Mats" <Mats.Petersson@xxxxxxx> wrote:
> 
> > I just wrote a little bit of code to test it:
> > int x = 0x12345678;
> > __asm__(".byte 0x66; bswap %0": "=r"(x): "0"(x))
> > printf("x=%x", x);
> > 
> > Prints 12340000, so the data is "zerod". (and it looks like the code
> > generated by gcc is correct!).
> 
> Same behaviour as on an Intel CPU. I am quite inclined to do 
> that directly
> in the emulator, with a comment explaining why, rather than 
> do an undefined
> operation. That just seems unnecessarily scary. Direct 32- 
> and 64-bit BSWAP
> is okay though and does reduce the code size.

Whilst this is following the (sampled) architecture, wouldn't it be just
as easy to just IGNORE that case? 

It's not going to occur unless:
1. Someone likes to play games with code (it's easier to do "mov $0,
%ax" or "xor %ax,%ax" if that's what you actually want to do). And it's
not impossible that for example a 486, 386 or the latest quad-core [or
processors of other manufacturers (via, national->amd->discontinued)]
does something completely different on the same instruction, so it's not
a reliable way to clear that register.
2. Some code has gone astray and is executing random data - well, that's
going to crash pretty soon anyways!
3. Bugs in compiler/assembler. 

[Those are listed in order of importance/likelyhood to be needed, in my
personal opinion]. 

--
Mats
> 
>  -- Keir
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
> 
> 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel