Commit 82024135 authored by Brian Gerst's avatar Brian Gerst Committed by H. Peter Anvin

x86-64, fpu: Simplify constraints for fxsave/fxtstor

Use the "R" constraint (legacy register) instead of listing all the
possible registers.  Clean up the comments as well.
Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
Acked-by: default avatarPekka Enberg <penberg@kernel.org>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <1283563039-3466-8-git-send-email-brgerst@gmail.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 10c11f30
...@@ -81,6 +81,7 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx) ...@@ -81,6 +81,7 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
{ {
int err; int err;
/* See comment in fxsave() below. */
asm volatile("1: rex64/fxrstor (%[fx])\n\t" asm volatile("1: rex64/fxrstor (%[fx])\n\t"
"2:\n" "2:\n"
".section .fixup,\"ax\"\n" ".section .fixup,\"ax\"\n"
...@@ -89,11 +90,7 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx) ...@@ -89,11 +90,7 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
".previous\n" ".previous\n"
_ASM_EXTABLE(1b, 3b) _ASM_EXTABLE(1b, 3b)
: [err] "=r" (err) : [err] "=r" (err)
#if 0 /* See comment in fxsave() below. */ : [fx] "R" (fx), "m" (*fx), "0" (0));
: [fx] "r" (fx), "m" (*fx), "0" (0));
#else
: [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));
#endif
return err; return err;
} }
...@@ -140,6 +137,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx) ...@@ -140,6 +137,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
if (unlikely(err)) if (unlikely(err))
return -EFAULT; return -EFAULT;
/* See comment in fxsave() below. */
asm volatile("1: rex64/fxsave (%[fx])\n\t" asm volatile("1: rex64/fxsave (%[fx])\n\t"
"2:\n" "2:\n"
".section .fixup,\"ax\"\n" ".section .fixup,\"ax\"\n"
...@@ -148,11 +146,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx) ...@@ -148,11 +146,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
".previous\n" ".previous\n"
_ASM_EXTABLE(1b, 3b) _ASM_EXTABLE(1b, 3b)
: [err] "=r" (err), "=m" (*fx) : [err] "=r" (err), "=m" (*fx)
#if 0 /* See comment in fxsave() below. */ : [fx] "R" (fx), "0" (0));
: [fx] "r" (fx), "0" (0));
#else
: [fx] "cdaSDb" (fx), "0" (0));
#endif
if (unlikely(err) && if (unlikely(err) &&
__clear_user(fx, sizeof(struct i387_fxsave_struct))) __clear_user(fx, sizeof(struct i387_fxsave_struct)))
err = -EFAULT; err = -EFAULT;
...@@ -165,26 +159,22 @@ static inline void fpu_fxsave(struct fpu *fpu) ...@@ -165,26 +159,22 @@ static inline void fpu_fxsave(struct fpu *fpu)
/* Using "rex64; fxsave %0" is broken because, if the memory operand /* Using "rex64; fxsave %0" is broken because, if the memory operand
uses any extended registers for addressing, a second REX prefix uses any extended registers for addressing, a second REX prefix
will be generated (to the assembler, rex64 followed by semicolon will be generated (to the assembler, rex64 followed by semicolon
is a separate instruction), and hence the 64-bitness is lost. */ is a separate instruction), and hence the 64-bitness is lost.
#if 0 Using "fxsaveq %0" would be the ideal choice, but is only supported
/* Using "fxsaveq %0" would be the ideal choice, but is only supported starting with gas 2.16.
starting with gas 2.16. */ asm volatile("fxsaveq %0"
__asm__ __volatile__("fxsaveq %0"
: "=m" (fpu->state->fxsave)); : "=m" (fpu->state->fxsave));
#elif 0 Using, as a workaround, the properly prefixed form below isn't
/* Using, as a workaround, the properly prefixed form below isn't
accepted by any binutils version so far released, complaining that accepted by any binutils version so far released, complaining that
the same type of prefix is used twice if an extended register is the same type of prefix is used twice if an extended register is
needed for addressing (fix submitted to mainline 2005-11-21). */ needed for addressing (fix submitted to mainline 2005-11-21).
__asm__ __volatile__("rex64/fxsave %0" asm volatile("rex64/fxsave %0"
: "=m" (fpu->state->fxsave)); : "=m" (fpu->state->fxsave));
#else This, however, we can work around by forcing the compiler to select
/* This, however, we can work around by forcing the compiler to select
an addressing mode that doesn't require extended registers. */ an addressing mode that doesn't require extended registers. */
__asm__ __volatile__("rex64/fxsave (%1)" asm volatile("rex64/fxsave (%[fx])"
: "=m" (fpu->state->fxsave) : "=m" (fpu->state->fxsave)
: "cdaSDb" (&fpu->state->fxsave)); : [fx] "R" (&fpu->state->fxsave));
#endif
} }
static inline void fpu_save_init(struct fpu *fpu) static inline void fpu_save_init(struct fpu *fpu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment