* [PATCH] MIPS: Trap exception handling fixes
@ 2013-05-23 15:31 Maciej W. Rozycki
2013-05-23 15:31 ` Maciej W. Rozycki
2013-05-23 15:50 ` Ralf Baechle
0 siblings, 2 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 15:31 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
2a0b24f56c2492b932f1aed617ae80fb23500d21 broke Trap exception handling in
the standard MIPS mode. Additionally the microMIPS-mode trap code mask is
wrong, as it's a 4-bit field. Here's a fix.
Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
---
Ralf, please apply. Also the mention of: "A few NOP instructions are used
to maintain the correct alignment[...]" in the commit referred makes me
feel scared -- there is that .align pseudo-op, you know... Maciej
linux-mips-do-tr.diff
arch/mips/kernel/traps.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index e3be670..a75ae40 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -897,22 +897,24 @@ out_sigsegv:
asmlinkage void do_tr(struct pt_regs *regs)
{
- unsigned int opcode, tcode = 0;
+ u32 opcode, tcode = 0;
u16 instr[2];
- unsigned long epc = exception_epc(regs);
+ unsigned long epc = msk_isa16_mode(exception_epc(regs));
- if ((__get_user(instr[0], (u16 __user *)msk_isa16_mode(epc))) ||
- (__get_user(instr[1], (u16 __user *)msk_isa16_mode(epc + 2))))
+ if (get_isa16_mode(regs->cp0_epc)) {
+ if (__get_user(instr[0], (u16 __user *)(epc + 0)) ||
+ __get_user(instr[1], (u16 __user *)(epc + 2)))
goto out_sigsegv;
- opcode = (instr[0] << 16) | instr[1];
-
- /* Immediate versions don't provide a code. */
- if (!(opcode & OPCODE)) {
- if (get_isa16_mode(regs->cp0_epc))
- /* microMIPS */
- tcode = (opcode >> 12) & 0x1f;
- else
- tcode = ((opcode >> 6) & ((1 << 10) - 1));
+ opcode = (instr[0] << 16) | instr[1];
+ /* Immediate versions don't provide a code. */
+ if (!(opcode & OPCODE))
+ tcode = (opcode >> 12) & ((1 << 4) - 1);
+ } else {
+ if (__get_user(opcode, (u32 __user *)epc))
+ goto out_sigsegv;
+ /* Immediate versions don't provide a code. */
+ if (!(opcode & OPCODE))
+ tcode = (opcode >> 6) & ((1 << 10) - 1);
}
do_trap_or_bp(regs, tcode, "Trap");
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH] MIPS: Trap exception handling fixes
2013-05-23 15:31 [PATCH] MIPS: Trap exception handling fixes Maciej W. Rozycki
@ 2013-05-23 15:31 ` Maciej W. Rozycki
2013-05-23 15:50 ` Ralf Baechle
1 sibling, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 15:31 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
2a0b24f56c2492b932f1aed617ae80fb23500d21 broke Trap exception handling in
the standard MIPS mode. Additionally the microMIPS-mode trap code mask is
wrong, as it's a 4-bit field. Here's a fix.
Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
---
Ralf, please apply. Also the mention of: "A few NOP instructions are used
to maintain the correct alignment[...]" in the commit referred makes me
feel scared -- there is that .align pseudo-op, you know... Maciej
linux-mips-do-tr.diff
arch/mips/kernel/traps.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index e3be670..a75ae40 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -897,22 +897,24 @@ out_sigsegv:
asmlinkage void do_tr(struct pt_regs *regs)
{
- unsigned int opcode, tcode = 0;
+ u32 opcode, tcode = 0;
u16 instr[2];
- unsigned long epc = exception_epc(regs);
+ unsigned long epc = msk_isa16_mode(exception_epc(regs));
- if ((__get_user(instr[0], (u16 __user *)msk_isa16_mode(epc))) ||
- (__get_user(instr[1], (u16 __user *)msk_isa16_mode(epc + 2))))
+ if (get_isa16_mode(regs->cp0_epc)) {
+ if (__get_user(instr[0], (u16 __user *)(epc + 0)) ||
+ __get_user(instr[1], (u16 __user *)(epc + 2)))
goto out_sigsegv;
- opcode = (instr[0] << 16) | instr[1];
-
- /* Immediate versions don't provide a code. */
- if (!(opcode & OPCODE)) {
- if (get_isa16_mode(regs->cp0_epc))
- /* microMIPS */
- tcode = (opcode >> 12) & 0x1f;
- else
- tcode = ((opcode >> 6) & ((1 << 10) - 1));
+ opcode = (instr[0] << 16) | instr[1];
+ /* Immediate versions don't provide a code. */
+ if (!(opcode & OPCODE))
+ tcode = (opcode >> 12) & ((1 << 4) - 1);
+ } else {
+ if (__get_user(opcode, (u32 __user *)epc))
+ goto out_sigsegv;
+ /* Immediate versions don't provide a code. */
+ if (!(opcode & OPCODE))
+ tcode = (opcode >> 6) & ((1 << 10) - 1);
}
do_trap_or_bp(regs, tcode, "Trap");
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 15:31 [PATCH] MIPS: Trap exception handling fixes Maciej W. Rozycki
2013-05-23 15:31 ` Maciej W. Rozycki
@ 2013-05-23 15:50 ` Ralf Baechle
2013-05-23 16:07 ` Maciej W. Rozycki
1 sibling, 1 reply; 10+ messages in thread
From: Ralf Baechle @ 2013-05-23 15:50 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: linux-mips
On Thu, May 23, 2013 at 04:31:23PM +0100, Maciej W. Rozycki wrote:
> 2a0b24f56c2492b932f1aed617ae80fb23500d21 broke Trap exception handling in
> the standard MIPS mode. Additionally the microMIPS-mode trap code mask is
> wrong, as it's a 4-bit field. Here's a fix.
>
> Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
> ---
> Ralf, please apply. Also the mention of: "A few NOP instructions are used
> to maintain the correct alignment[...]" in the commit referred makes me
> feel scared -- there is that .align pseudo-op, you know... Maciej
Thanks, applied.
Seems that whole bloody patchset was painfully unripe :-(
Ralf
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 15:50 ` Ralf Baechle
@ 2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
0 siblings, 2 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 16:07 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On Thu, 23 May 2013, Ralf Baechle wrote:
> Seems that whole bloody patchset was painfully unripe :-(
Sigh, I meant to at least skim over the patches to review them, but these
days I can hardly find time for smaller changes even. This particular
issue was found in GCC regression testing. I think at least running the
GCC and glibc test suites across the three ABIs and both endiannesses each
to make sure MIPS16/microMIPS support didn't regress standard MIPS support
was due. This would have avoided this problem. It looks to me do_bp
would benefit from some polishing too.
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 16:07 ` Maciej W. Rozycki
@ 2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
1 sibling, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 16:07 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On Thu, 23 May 2013, Ralf Baechle wrote:
> Seems that whole bloody patchset was painfully unripe :-(
Sigh, I meant to at least skim over the patches to review them, but these
days I can hardly find time for smaller changes even. This particular
issue was found in GCC regression testing. I think at least running the
GCC and glibc test suites across the three ABIs and both endiannesses each
to make sure MIPS16/microMIPS support didn't regress standard MIPS support
was due. This would have avoided this problem. It looks to me do_bp
would benefit from some polishing too.
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:07 ` Maciej W. Rozycki
@ 2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 17:00 ` David Daney
1 sibling, 2 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 16:54 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On Thu, 23 May 2013, Maciej W. Rozycki wrote:
> It looks to me do_bp would benefit from some polishing too.
To make myself more clear here -- there are two microMIPS BREAK encodings
of which do_bp assumes (without checking!) the 32-bit one, that is
actually unlikely to be ever present in compiler-generated code (so how
was this change validated?), and also the MIPS16 path is special-cased
(makes a separate call to do_trap_or_bp), which I find error-prone in
long-term maintenance.
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 16:54 ` Maciej W. Rozycki
@ 2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 17:00 ` David Daney
1 sibling, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-23 16:54 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On Thu, 23 May 2013, Maciej W. Rozycki wrote:
> It looks to me do_bp would benefit from some polishing too.
To make myself more clear here -- there are two microMIPS BREAK encodings
of which do_bp assumes (without checking!) the 32-bit one, that is
actually unlikely to be ever present in compiler-generated code (so how
was this change validated?), and also the MIPS16 path is special-cased
(makes a separate call to do_trap_or_bp), which I find error-prone in
long-term maintenance.
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
@ 2013-05-23 17:00 ` David Daney
2013-05-24 6:23 ` Steven J. Hill
1 sibling, 1 reply; 10+ messages in thread
From: David Daney @ 2013-05-23 17:00 UTC (permalink / raw)
To: Maciej W. Rozycki, Steven J. Hill; +Cc: Ralf Baechle, linux-mips
On 05/23/2013 09:54 AM, Maciej W. Rozycki wrote:
> On Thu, 23 May 2013, Maciej W. Rozycki wrote:
>
>> It looks to me do_bp would benefit from some polishing too.
>
> To make myself more clear here -- there are two microMIPS BREAK encodings
> of which do_bp assumes (without checking!) the 32-bit one, that is
> actually unlikely to be ever present in compiler-generated code (so how
> was this change validated?),
Probably sjhill should answer that, as they are his patches.
David Daney
> and also the MIPS16 path is special-cased
> (makes a separate call to do_trap_or_bp), which I find error-prone in
> long-term maintenance.
>
> Maciej
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] MIPS: Trap exception handling fixes
2013-05-23 17:00 ` David Daney
@ 2013-05-24 6:23 ` Steven J. Hill
2013-05-24 6:45 ` Maciej W. Rozycki
0 siblings, 1 reply; 10+ messages in thread
From: Steven J. Hill @ 2013-05-24 6:23 UTC (permalink / raw)
To: David Daney, Maciej W. Rozycki; +Cc: Ralf Baechle, linux-mips@linux-mips.org
I am working on a patch to fix the microMIPS BREAK encoding. This was already discovered when we were regression testing for our 'linux-mti-3.8' branch release. With regards to the MIPS16e path, I will need to take a closer look.
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] MIPS: Trap exception handling fixes
2013-05-24 6:23 ` Steven J. Hill
@ 2013-05-24 6:45 ` Maciej W. Rozycki
0 siblings, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2013-05-24 6:45 UTC (permalink / raw)
To: Steven J. Hill; +Cc: David Daney, Ralf Baechle, linux-mips@linux-mips.org
On Fri, 24 May 2013, Steven J. Hill wrote:
> I am working on a patch to fix the microMIPS BREAK encoding. This was
> already discovered when we were regression testing for our
> 'linux-mti-3.8' branch release. With regards to the MIPS16e path, I will
> need to take a closer look.
Great, thanks!
Maciej
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-05-24 6:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23 15:31 [PATCH] MIPS: Trap exception handling fixes Maciej W. Rozycki
2013-05-23 15:31 ` Maciej W. Rozycki
2013-05-23 15:50 ` Ralf Baechle
2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:07 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 16:54 ` Maciej W. Rozycki
2013-05-23 17:00 ` David Daney
2013-05-24 6:23 ` Steven J. Hill
2013-05-24 6:45 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox