linux-mips
[Top] [All Lists]

[PATCH 2/5] MIPS: Allow kernel to use coprocessor 2

To: linux-mips@linux-mips.org, ralf@linux-mips.org, ddaney.cavm@gmail.com
Subject: [PATCH 2/5] MIPS: Allow kernel to use coprocessor 2
From: "Jayachandran C" <jchandra@broadcom.com>
Date: Mon, 10 Jun 2013 13:00:01 +0530
Cc: "Jayachandran C" <jchandra@broadcom.com>
In-reply-to: <1370849404-4918-1-git-send-email-jchandra@broadcom.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1370849404-4918-1-git-send-email-jchandra@broadcom.com>
Sender: linux-mips-bounce@linux-mips.org
Kernel threads should be able to use COP2 if the platform needs it.
Do not call die_if_kernel() for a coprocessor unusable exception if
the exception due to COP2 usage.  Instead, the default notifier for
COP2 exceptions is updated to call die_if_kernel.

Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
 arch/mips/kernel/traps.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index beba1e6..142d2be 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1056,15 +1056,9 @@ static int default_cu2_call(struct notifier_block *nfb, 
unsigned long action,
 {
        struct pt_regs *regs = data;
 
-       switch (action) {
-       default:
-               die_if_kernel("Unhandled kernel unaligned access or invalid "
+       die_if_kernel("COP2: Unhandled kernel unaligned access or invalid "
                              "instruction", regs);
-               /* Fall through  */
-
-       case CU2_EXCEPTION:
-               force_sig(SIGILL, current);
-       }
+       force_sig(SIGILL, current);
 
        return NOTIFY_OK;
 }
@@ -1080,10 +1074,11 @@ asmlinkage void do_cpu(struct pt_regs *regs)
        unsigned long __maybe_unused flags;
 
        prev_state = exception_enter();
-       die_if_kernel("do_cpu invoked from kernel context!", regs);
-
        cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
 
+       if (cpid != 2)
+               die_if_kernel("do_cpu invoked from kernel context!", regs);
+
        switch (cpid) {
        case 0:
                epc = (unsigned int __user *)exception_epc(regs);
-- 
1.7.9.5



<Prev in Thread] Current Thread [Next in Thread>