Skip to contentSkip to conversation

MIPS: return after handling coprocessor 2 exception

PATCH Jesper Nilsson 4 participants 7 messages Jun 17, 2010 – Jun 18, 2010 MIPS

lore
Share & tools
lore
#0 lore raw

Breaking here dropped us to the default code which always sends a SIGILL to the current process, no matter what the CU2 notifier says.

---
 traps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/traps.c +1 -1
index 8bdd6a6..8527808 100644
@@ -976,7 +976,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
 
 	case 2:
 		raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
-		break;
+		return;
 
 	case 3:
 		break;

/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper_at_jni.nu

#1 lore raw
Quoted 13 lines · Jesper Nilsson

Breaking here dropped us to the default code which always sends a SIGILL to the current process, no matter what the CU2 notifier says.

---
  traps.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/traps.c +0 -0
index 8bdd6a6..8527808 100644

arch/mips/kernel/traps.c asmlinkage void do_cpu(struct pt_regs *regs) · line 980

Quoted 6 lines
arch/mips/kernel/traps.c +1 -1
@@ -976,7 +976,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
 
  	case 2:
  		raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
-		break;
+		return;
 

What happens when the call chain is empty, and the proper action *is* SIGILL?

David Daney

#2 lore raw
Quoted 15 lines · David Daney
Quoted 14 lines · Jesper Nilsson

Breaking here dropped us to the default code which always sends a SIGILL to the current process, no matter what the CU2 notifier says.

---
 traps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/traps.c +0 -0
index 8bdd6a6..8527808 100644
@@ -976,7 +976,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
 
Quoted 8 lines

arch/mips/kernel/traps.c asmlinkage void do_cpu(struct pt_regs *regs) · line 980

Quoted 5 lines
arch/mips/kernel/traps.c +1 -1
 	case 2:
 		raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
-		break;
+		return;
 

What happens when the call chain is empty, and the proper action *is* SIGILL?

Well, since there is a default notifier installed at the end, it will correctly return SIGILL.

See the definition of default_cu2_call in the same file.

Quoted 1 line

David Daney

/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper_at_jni.nu

#3 lore raw
In reply to David Daney
Quoted 5 lines · David Daney
Quoted 4 lines · Jesper Nilsson

Breaking here dropped us to the default code which always sends a SIGILL to the current process, no matter what the CU2 notifier says.

[...]

Quoted 8 lines
Quoted 5 lines

case 2:
raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
- break;
+ return;

What happens when the call chain is empty, and the proper action *is* SIGILL?

It's never empty, in fact. The default notifier declared at top of traps.c sends SIGILL. The problem that current code is sending SIGILL in all cases.

Gleb.

#4 lore raw
Quoted 6 lines · Gleb O. Raiko
Quoted 2 lines

What happens when the call chain is empty, and the proper action *is* SIGILL?

It's never empty, in fact. The default notifier declared at top of traps.c sends SIGILL. The problem that current code is sending SIGILL in all cases.

That's not really a problem. The design idea is that a the default notifier has the lowest priority, that is any user notifier installed should have higher priority resulting in it getting run first. To avoid the default notifier from getting executed such an extra notifier should set NOTIFY_STOP_MASK in its return like:

static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
void *data)

{
	...

	return NOTIFY_OK | NOTIFY_STOP;
}

The notifier list could also be used for example by perf but there it we'd want the notifier function not to return NOTIFY_STOP as the result;

Arguably sending the signal for CU2 instructions has been delegated to the hook so the I agree that the break stateement should be replaced with a return and will apply the patch.

Ralf

#5 lore raw
Quoted 6 lines · Ralf Baechle

static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
void *data)

{
	...

	return NOTIFY_OK | NOTIFY_STOP;

NOTIFY_STOP implies NOTIFY_OK, so

	return NOTIFY_STOP;

shall be enough.

Quoted 3 lines

}

The notifier list could also be used for example by perf

Or octeon cop2 handler that just sends NOTIFY_BAD for getting the same behavior.

Gleb.

#6 lore raw
Quoted 9 lines · Gleb O. Raiko
Quoted 6 lines

static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
void *data)

{
	...

	return NOTIFY_OK | NOTIFY_STOP;

NOTIFY_STOP implies NOTIFY_OK, so

	return NOTIFY_STOP;

shall be enough.

Correct - I was thinking NOTIFY_STOP_MASK.

Quoted 6 lines
Quoted 3 lines

}

The notifier list could also be used for example by perf

Or octeon cop2 handler that just sends NOTIFY_BAD for getting the same behavior.

Bad karma to return an error for where none happened.

Ralf