mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Burton <paul.burton@imgtec.com>
To: <linux-mips@linux-mips.org>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Matthew Fortune <matthew.fortune@imgtec.com>,
	Paul Burton <paul.burton@imgtec.com>,
	"Markos Chandras" <markos.chandras@imgtec.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	<linux-kernel@vger.kernel.org>,
	Richard Weinberger <richard@nod.at>,
	"Andy Lutomirski" <luto@amacapital.net>,
	Ralf Baechle <ralf@linux-mips.org>,
	"Maciej W. Rozycki" <macro@codesourcery.com>
Subject: [PATCH v2 02/16] MIPS: simplify EVA FP context handling code
Date: Mon, 27 Jul 2015 12:58:13 -0700	[thread overview]
Message-ID: <1438027107-24420-3-git-send-email-paul.burton@imgtec.com> (raw)
In-Reply-To: <1438027107-24420-1-git-send-email-paul.burton@imgtec.com>

The protected_{save,restore}_fp_context functions had effectively
different implementations for EVA. Simplify & unify the code somewhat
such that EVA configurations simply guarantee the FPU-not-owned path
through the standard code path.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
---

Changes in v2: None

 arch/mips/kernel/signal.c | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 6a28c79..796c7d8 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -101,7 +101,14 @@ static int copy_fp_from_sigcontext(struct sigcontext __user *sc)
 static int protected_save_fp_context(struct sigcontext __user *sc)
 {
 	int err;
-#ifndef CONFIG_EVA
+
+	/*
+	 * EVA does not have userland equivalents of ldc1 or sdc1, so
+	 * save to the kernel FP context & copy that to userland below.
+	 */
+	if (config_enabled(CONFIG_EVA))
+		lose_fpu(1);
+
 	while (1) {
 		lock_fpu_owner();
 		if (is_fpu_owner()) {
@@ -120,21 +127,22 @@ static int protected_save_fp_context(struct sigcontext __user *sc)
 		if (err)
 			break;	/* really bad sigcontext */
 	}
-#else
-	/*
-	 * EVA does not have FPU EVA instructions so saving fpu context directly
-	 * does not work.
-	 */
-	lose_fpu(1);
-	err = save_fp_context(sc); /* this might fail */
-#endif
+
 	return err;
 }
 
 static int protected_restore_fp_context(struct sigcontext __user *sc)
 {
 	int err, tmp __maybe_unused;
-#ifndef CONFIG_EVA
+
+	/*
+	 * EVA does not have userland equivalents of ldc1 or sdc1, so we
+	 * disable the FPU here such that the code below simply copies to
+	 * the kernel FP context.
+	 */
+	if (config_enabled(CONFIG_EVA))
+		lose_fpu(0);
+
 	while (1) {
 		lock_fpu_owner();
 		if (is_fpu_owner()) {
@@ -153,14 +161,7 @@ static int protected_restore_fp_context(struct sigcontext __user *sc)
 		if (err)
 			break;	/* really bad sigcontext */
 	}
-#else
-	/*
-	 * EVA does not have FPU EVA instructions so restoring fpu context
-	 * directly does not work.
-	 */
-	lose_fpu(0);
-	err = restore_fp_context(sc); /* this might fail */
-#endif
+
 	return err;
 }
 
@@ -629,7 +630,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
 }
 
 #ifdef CONFIG_SMP
-#ifndef CONFIG_EVA
 static int smp_save_fp_context(struct sigcontext __user *sc)
 {
 	return raw_cpu_has_fpu
@@ -643,12 +643,10 @@ static int smp_restore_fp_context(struct sigcontext __user *sc)
 	       ? _restore_fp_context(sc)
 	       : copy_fp_from_sigcontext(sc);
 }
-#endif /* CONFIG_EVA */
 #endif
 
 static int signal_setup(void)
 {
-#ifndef CONFIG_EVA
 #ifdef CONFIG_SMP
 	/* For now just do the cpu_has_fpu check when the functions are invoked */
 	save_fp_context = smp_save_fp_context;
@@ -662,10 +660,6 @@ static int signal_setup(void)
 		restore_fp_context = copy_fp_from_sigcontext;
 	}
 #endif /* CONFIG_SMP */
-#else
-	save_fp_context = copy_fp_to_sigcontext;
-	restore_fp_context = copy_fp_from_sigcontext;
-#endif
 
 	return 0;
 }
-- 
2.4.6


  parent reply	other threads:[~2015-07-27 19:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 19:58 [PATCH v2 00/16] MSA vector context signal handling & HWCAPs Paul Burton
2015-07-27 19:58 ` [PATCH v2 01/16] MIPS: remove outdated comments in sigcontext.h Paul Burton
2015-07-28  8:39   ` Ralf Baechle
2015-07-27 19:58 ` Paul Burton [this message]
2015-07-27 19:58 ` [PATCH v2 03/16] MIPS: add offsets to sigcontext FP fields to struct mips_abi Paul Burton
2015-07-27 19:58 ` [PATCH v2 04/16] MIPS: use struct mips_abi offsets to save FP context Paul Burton
2015-07-27 19:58 ` [PATCH v2 05/16] MIPS: move FP usage checks into protected_{save,restore}_fp_context Paul Burton
2015-07-27 19:58 ` [PATCH v2 06/16] MIPS: skip odd double FP registers when copying FP32 sigcontext Paul Burton
2015-07-27 19:58 ` [PATCH v2 07/16] MIPS: use common FP sigcontext code for O32 compat Paul Burton
2015-07-27 19:58 ` [PATCH v2 08/16] MIPS: remove unused {get,put}_sigset functions Paul Burton
2015-07-27 19:58 ` [PATCH v2 09/16] MIPS: indicate FP mode in sigcontext sc_used_math Paul Burton
2015-07-27 19:58 ` [PATCH v2 10/16] MIPS: add definitions for extended context Paul Burton
2015-07-27 19:58 ` [PATCH v2 11/16] MIPS: save MSA extended context around signals Paul Burton
2015-07-27 19:58 ` [PATCH v2 12/16] MIPS: AT_HWCAP aux vector infrastructure Paul Burton
2015-07-27 19:58 ` [PATCH v2 13/16] MIPS: advertise MIPSr6 via HWCAP when appropriate Paul Burton
2015-07-27 19:58 ` [PATCH v2 14/16] MIPS: advertise MSA support via HWCAP when present Paul Burton
2015-07-27 19:58 ` [PATCH v2 15/16] MIPS: require O32 FP64 support for MIPS64 with O32 compat Paul Burton
2015-07-27 19:58 ` [PATCH v2 16/16] MIPS: drop EXPERIMENTAL tag from O32+FP64 & MSA Paul Burton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438027107-24420-3-git-send-email-paul.burton@imgtec.com \
    --to=paul.burton@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux@roeck-us.net \
    --cc=luto@amacapital.net \
    --cc=macro@codesourcery.com \
    --cc=markos.chandras@imgtec.com \
    --cc=matthew.fortune@imgtec.com \
    --cc=mpe@ellerman.id.au \
    --cc=ralf@linux-mips.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®