x86/fpu: Get rid of x87 math exception helpers

... and integrate their functionality into their single user
fpu__exception_code().

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1459837795-2588-7-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Borislav Petkov 2016-04-05 08:29:55 +02:00 committed by Ingo Molnar
parent de82fbc382
commit 6aa6dbfced

View File

@ -506,33 +506,6 @@ void fpu__clear(struct fpu *fpu)
* x87 math exception handling: * x87 math exception handling:
*/ */
static inline unsigned short get_fpu_cwd(struct fpu *fpu)
{
if (boot_cpu_has(X86_FEATURE_FXSR)) {
return fpu->state.fxsave.cwd;
} else {
return (unsigned short)fpu->state.fsave.cwd;
}
}
static inline unsigned short get_fpu_swd(struct fpu *fpu)
{
if (boot_cpu_has(X86_FEATURE_FXSR)) {
return fpu->state.fxsave.swd;
} else {
return (unsigned short)fpu->state.fsave.swd;
}
}
static inline unsigned short get_fpu_mxcsr(struct fpu *fpu)
{
if (boot_cpu_has(X86_FEATURE_XMM)) {
return fpu->state.fxsave.mxcsr;
} else {
return MXCSR_DEFAULT;
}
}
int fpu__exception_code(struct fpu *fpu, int trap_nr) int fpu__exception_code(struct fpu *fpu, int trap_nr)
{ {
int err; int err;
@ -547,10 +520,15 @@ int fpu__exception_code(struct fpu *fpu, int trap_nr)
* so if this combination doesn't produce any single exception, * so if this combination doesn't produce any single exception,
* then we have a bad program that isn't synchronizing its FPU usage * then we have a bad program that isn't synchronizing its FPU usage
* and it will suffer the consequences since we won't be able to * and it will suffer the consequences since we won't be able to
* fully reproduce the context of the exception * fully reproduce the context of the exception.
*/ */
cwd = get_fpu_cwd(fpu); if (boot_cpu_has(X86_FEATURE_FXSR)) {
swd = get_fpu_swd(fpu); cwd = fpu->state.fxsave.cwd;
swd = fpu->state.fxsave.swd;
} else {
cwd = (unsigned short)fpu->state.fsave.cwd;
swd = (unsigned short)fpu->state.fsave.swd;
}
err = swd & ~cwd; err = swd & ~cwd;
} else { } else {
@ -560,7 +538,11 @@ int fpu__exception_code(struct fpu *fpu, int trap_nr)
* unmasked exception was caught we must mask the exception mask bits * unmasked exception was caught we must mask the exception mask bits
* at 0x1f80, and then use these to mask the exception bits at 0x3f. * at 0x1f80, and then use these to mask the exception bits at 0x3f.
*/ */
unsigned short mxcsr = get_fpu_mxcsr(fpu); unsigned short mxcsr = MXCSR_DEFAULT;
if (boot_cpu_has(X86_FEATURE_XMM))
mxcsr = fpu->state.fxsave.mxcsr;
err = ~(mxcsr >> 7) & mxcsr; err = ~(mxcsr >> 7) & mxcsr;
} }