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

Re: [Xen-devel] fsincos emulation on AMD CPUs



>>> On 15.12.11 at 09:54, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
> On 12/15/2011 09:38 AM, Jan Beulich wrote:
>> in the light of erratum #573 I'm wondering if we need to tweak or
>> conditionally suppress fsincos emulation. The question is whether there
>> is any possibility for getting the emulator to hit this instruction on AMD
>> (as no real mode emulation ought to be taking place there), i.e.
>> whether there are places where emulation gets continued eagerly
>> in anticipation of the need for emulation on a nearby instruction.
> 
> This can happen with PAE + shadow pagetables.

Ah okay. In that case we ought to add some workaround here.

> There's also the case when a user process issues an instruction to an 
> MMIO region, and another thread replaces the instruction with another 
> (fsincos in this case), racing with the emulator until the emulator sees 
> fsincos instead of the MMIO instruction.

Indeed, didn't think of this possibility.

> If you really cared, perhaps fsincos can be replaced by this sequence in 
> the emulator:
> 
>                      ; x
>      fld   %st       ; x x
>      fsin            ; x sin(x)
>      fxch  %st(1)    ; sin(x) x
>      fcos            ; sin(x) cos(x)

I had thought of this at first too, but this is problematic in terms of
exception handling: fpu_handle_exception() expects to see an
exception only on the very first instruction (as it's assumed to be
the only one), and aborts the rest of the sequence if the exception
doesn't happen on the last instruction.

All of this can be fixed of course, but I wonder whether it's worth
it when we really could just bail from the emulator without causing
any harm.

Jan


_______________________________________________
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®.