Subject: [PATCH v2] arm64: fpsimd: avoid restoring fpcr if the contents haven't changed

From: [email-masked] (Will Deacon)
Date: Mon, 30 Jun 2014 10:03:18 +0100

On Fri, Jun 27, 2014 at 06:33:58PM +0100, Ard Biesheuvel wrote:
> On 27 June 2014 17:53, Will Deacon <[email-masked]> wrote:
> > Writing to the FPCR is commonly implemented as a self-synchronising
> > operation in the CPU, so avoid writing to the register when the saved
> > value matches that in the hardware already.

[...]

> >  .macro fpsimd_restore_partial state, tmpnr1, tmpnr2
> >         ldp     w\tmpnr1, w\tmpnr2, [\state]
> >         msr     fpsr, x\tmpnr1
> > -       msr     fpcr, x\tmpnr2
> > +       fpsimd_restore_fpcr x\tmpnr1, x\tmpnr2
> 
> Ehm, isn't this the wrong way around?

Yup, well spotted. I'll give the crypto selftests a run to test this path
with the fix (I was just running paranoia in userspace before).

Will