--- zzzz-none-000/linux-3.10.107/arch/mips/kernel/signal32.c 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/kernel/signal32.c 2021-11-10 11:53:54.000000000 +0000 @@ -83,10 +83,12 @@ static int protected_save_fp_context32(struct sigcontext32 __user *sc) { int err; +#ifndef CONFIG_EVA while (1) { lock_fpu_owner(); - own_fpu_inatomic(1); - err = save_fp_context32(sc); /* this might fail */ + err = own_fpu_inatomic(1); + if (!err) + err = save_fp_context32(sc); /* this might fail */ unlock_fpu_owner(); if (likely(!err)) break; @@ -97,16 +99,22 @@ if (err) break; /* really bad sigcontext */ } +#else + lose_fpu(1); + err = save_fp_context32(sc); /* this might fail */ +#endif return err; } static int protected_restore_fp_context32(struct sigcontext32 __user *sc) { int err, tmp __maybe_unused; +#ifndef CONFIG_EVA while (1) { lock_fpu_owner(); - own_fpu_inatomic(0); - err = restore_fp_context32(sc); /* this might fail */ + err = own_fpu_inatomic(0); + if (!err) + err = restore_fp_context32(sc); /* this might fail */ unlock_fpu_owner(); if (likely(!err)) break; @@ -117,6 +125,10 @@ if (err) break; /* really bad sigcontext */ } +#else + lose_fpu(0); + err = restore_fp_context32(sc); /* this might fail */ +#endif /* CONFIG_EVA */ return err; } @@ -556,8 +568,30 @@ .restart = __NR_O32_restart_syscall }; +#ifdef CONFIG_SMP +static int smp_save_fp_context32(struct sigcontext32 __user *sc) +{ + return raw_cpu_has_fpu + ? _save_fp_context32(sc) + : fpu_emulator_save_context32(sc); +} + +static int smp_restore_fp_context32(struct sigcontext32 __user *sc) +{ + return raw_cpu_has_fpu + ? _restore_fp_context32(sc) + : fpu_emulator_restore_context32(sc); +} +#endif + static int signal32_init(void) { +#ifndef CONFIG_EVA +#ifdef CONFIG_SMP + /* For now just do the cpu_has_fpu check when the functions are invoked */ + save_fp_context32 = smp_save_fp_context32; + restore_fp_context32 = smp_restore_fp_context32; +#else if (cpu_has_fpu) { save_fp_context32 = _save_fp_context32; restore_fp_context32 = _restore_fp_context32; @@ -565,6 +599,11 @@ save_fp_context32 = fpu_emulator_save_context32; restore_fp_context32 = fpu_emulator_restore_context32; } +#endif /* CONFIG_SMP */ +#else + save_fp_context32 = fpu_emulator_save_context32; + restore_fp_context32 = fpu_emulator_restore_context32; +#endif /* CONFIG_EVA */ return 0; }