[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.