2008-06-20 02:26:19 +08:00
|
|
|
#ifndef _SPARC64_VISASM_H
|
|
|
|
#define _SPARC64_VISASM_H
|
|
|
|
|
|
|
|
/* visasm.h: FPU saving macros for VIS routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/pstate.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
|
|
/* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc */
|
|
|
|
|
|
|
|
#define VISEntry \
|
|
|
|
rd %fprs, %o5; \
|
|
|
|
andcc %o5, (FPRS_FEF|FPRS_DU), %g0; \
|
|
|
|
be,pt %icc, 297f; \
|
|
|
|
sethi %hi(297f), %g7; \
|
|
|
|
sethi %hi(VISenter), %g1; \
|
|
|
|
jmpl %g1 + %lo(VISenter), %g0; \
|
|
|
|
or %g7, %lo(297f), %g7; \
|
|
|
|
297: wr %g0, FPRS_FEF, %fprs; \
|
|
|
|
|
|
|
|
#define VISExit \
|
|
|
|
wr %g0, 0, %fprs;
|
|
|
|
|
|
|
|
/* Clobbers %o5, %g1, %g2, %g3, %g7, %icc, %xcc.
|
|
|
|
* Must preserve %o5 between VISEntryHalf and VISExitHalf */
|
|
|
|
|
|
|
|
#define VISEntryHalf \
|
2015-08-07 10:13:25 +08:00
|
|
|
VISEntry
|
|
|
|
|
|
|
|
#define VISExitHalf \
|
|
|
|
VISExit
|
2008-06-20 02:26:19 +08:00
|
|
|
|
sparc64: Fix FPU register corruption with AES crypto offload.
The AES loops in arch/sparc/crypto/aes_glue.c use a scheme where the
key material is preloaded into the FPU registers, and then we loop
over and over doing the crypt operation, reusing those pre-cooked key
registers.
There are intervening blkcipher*() calls between the crypt operation
calls. And those might perform memcpy() and thus also try to use the
FPU.
The sparc64 kernel FPU usage mechanism is designed to allow such
recursive uses, but with a catch.
There has to be a trap between the two FPU using threads of control.
The mechanism works by, when the FPU is already in use by the kernel,
allocating a slot for FPU saving at trap time. Then if, within the
trap handler, we try to use the FPU registers, the pre-trap FPU
register state is saved into the slot. Then at trap return time we
notice this and restore the pre-trap FPU state.
Over the long term there are various more involved ways we can make
this work, but for a quick fix let's take advantage of the fact that
the situation where this happens is very limited.
All sparc64 chips that support the crypto instructiosn also are using
the Niagara4 memcpy routine, and that routine only uses the FPU for
large copies where we can't get the source aligned properly to a
multiple of 8 bytes.
We look to see if the FPU is already in use in this context, and if so
we use the non-large copy path which only uses integer registers.
Furthermore, we also limit this special logic to when we are doing
kernel copy, rather than a user copy.
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-10-15 10:37:58 +08:00
|
|
|
#define VISEntryHalfFast(fail_label) \
|
|
|
|
rd %fprs, %o5; \
|
|
|
|
andcc %o5, FPRS_FEF, %g0; \
|
|
|
|
be,pt %icc, 297f; \
|
|
|
|
nop; \
|
|
|
|
ba,a,pt %xcc, fail_label; \
|
|
|
|
297: wr %o5, FPRS_FEF, %fprs;
|
|
|
|
|
2015-08-07 10:13:25 +08:00
|
|
|
#define VISExitHalfFast \
|
2008-06-20 02:26:19 +08:00
|
|
|
wr %o5, 0, %fprs;
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
static inline void save_and_clear_fpu(void) {
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
" rd %%fprs, %%o5\n"
|
|
|
|
" andcc %%o5, %0, %%g0\n"
|
|
|
|
" be,pt %%icc, 299f\n"
|
|
|
|
" sethi %%hi(298f), %%g7\n"
|
|
|
|
" sethi %%hi(VISenter), %%g1\n"
|
|
|
|
" jmpl %%g1 + %%lo(VISenter), %%g0\n"
|
|
|
|
" or %%g7, %%lo(298f), %%g7\n"
|
|
|
|
" 298: wr %%g0, 0, %%fprs\n"
|
|
|
|
" 299:\n"
|
|
|
|
" " : : "i" (FPRS_FEF|FPRS_DU) :
|
|
|
|
"o5", "g1", "g2", "g3", "g7", "cc");
|
|
|
|
}
|
2014-05-17 05:25:50 +08:00
|
|
|
|
|
|
|
int vis_emul(struct pt_regs *, unsigned int);
|
2008-06-20 02:26:19 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SPARC64_ASI_H */
|