All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Use WARN() in uasm for better diagnostics.
@ 2010-12-28  2:18 David Daney
  2010-12-28 15:31 ` Ralf Baechle
  2010-12-28 15:44 ` Sergei Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: David Daney @ 2010-12-28  2:18 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: David Daney

On the off chance that uasm ever warns about overflow, there is no way
to know what the offending instruction is.

Change the printks to WARNs, so we can get a nice stack trace.  It has
the added benefit of being much more noticeable than the short single
line warning message, so is less likely to be ignored.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/mm/uasm.c |   40 ++++++++++++++++------------------------
 1 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 357916d..4008c79 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -156,91 +156,83 @@ static struct insn insn_table[] __uasminitdata = {
 
 static inline __uasminit u32 build_rs(u32 arg)
 {
-	if (arg & ~RS_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg & RS_MASK) << RS_SH;
 }
 
 static inline __uasminit u32 build_rt(u32 arg)
 {
-	if (arg & ~RT_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg & RT_MASK) << RT_SH;
 }
 
 static inline __uasminit u32 build_rd(u32 arg)
 {
-	if (arg & ~RD_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg & RD_MASK) << RD_SH;
 }
 
 static inline __uasminit u32 build_re(u32 arg)
 {
-	if (arg & ~RE_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg & RE_MASK) << RE_SH;
 }
 
 static inline __uasminit u32 build_simm(s32 arg)
 {
-	if (arg > 0x7fff || arg < -0x8000)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg > 0x7fff || arg < -0x8000,
+	     KERN_WARNING "Micro-assembler field overflow\n");
 
 	return arg & 0xffff;
 }
 
 static inline __uasminit u32 build_uimm(u32 arg)
 {
-	if (arg & ~IMM_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return arg & IMM_MASK;
 }
 
 static inline __uasminit u32 build_bimm(s32 arg)
 {
-	if (arg > 0x1ffff || arg < -0x20000)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg > 0x1ffff || arg < -0x20000,
+	     KERN_WARNING "Micro-assembler field overflow\n");
 
-	if (arg & 0x3)
-		printk(KERN_WARNING "Invalid micro-assembler branch target\n");
+	WARN(arg & 0x3, KERN_WARNING "Invalid micro-assembler branch target\n");
 
 	return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
 }
 
 static inline __uasminit u32 build_jimm(u32 arg)
 {
-	if (arg & ~((JIMM_MASK) << 2))
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~((JIMM_MASK) << 2),
+	     KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg >> 2) & JIMM_MASK;
 }
 
 static inline __uasminit u32 build_scimm(u32 arg)
 {
-	if (arg & ~SCIMM_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~SCIMM_MASK,
+	     KERN_WARNING "Micro-assembler field overflow\n");
 
 	return (arg & SCIMM_MASK) << SCIMM_SH;
 }
 
 static inline __uasminit u32 build_func(u32 arg)
 {
-	if (arg & ~FUNC_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return arg & FUNC_MASK;
 }
 
 static inline __uasminit u32 build_set(u32 arg)
 {
-	if (arg & ~SET_MASK)
-		printk(KERN_WARNING "Micro-assembler field overflow\n");
+	WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
 	return arg & SET_MASK;
 }
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] MIPS: Use WARN() in uasm for better diagnostics.
  2010-12-28  2:18 [PATCH] MIPS: Use WARN() in uasm for better diagnostics David Daney
@ 2010-12-28 15:31 ` Ralf Baechle
  2010-12-28 15:44 ` Sergei Shtylyov
  1 sibling, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2010-12-28 15:31 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips

On Mon, Dec 27, 2010 at 06:18:29PM -0800, David Daney wrote:

> On the off chance that uasm ever warns about overflow, there is no way
> to know what the offending instruction is.
> 
> Change the printks to WARNs, so we can get a nice stack trace.  It has
> the added benefit of being much more noticeable than the short single
> line warning message, so is less likely to be ignored.

Time to interrupt vacation for some patches :-)

Queued for 2.6.38.  Thanks!

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] MIPS: Use WARN() in uasm for better diagnostics.
  2010-12-28  2:18 [PATCH] MIPS: Use WARN() in uasm for better diagnostics David Daney
  2010-12-28 15:31 ` Ralf Baechle
@ 2010-12-28 15:44 ` Sergei Shtylyov
  2010-12-28 15:54   ` Ralf Baechle
  1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2010-12-28 15:44 UTC (permalink / raw)
  To: David Daney; +Cc: linux-mips, ralf

Hello.

David Daney wrote:

> On the off chance that uasm ever warns about overflow, there is no way
> to know what the offending instruction is.

> Change the printks to WARNs, so we can get a nice stack trace.  It has
> the added benefit of being much more noticeable than the short single
> line warning message, so is less likely to be ignored.

> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> ---
>  arch/mips/mm/uasm.c |   40 ++++++++++++++++------------------------
>  1 files changed, 16 insertions(+), 24 deletions(-)

> diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
> index 357916d..4008c79 100644
> --- a/arch/mips/mm/uasm.c
> +++ b/arch/mips/mm/uasm.c
> @@ -156,91 +156,83 @@ static struct insn insn_table[] __uasminitdata = {
[...]
>  static inline __uasminit u32 build_jimm(u32 arg)
>  {
> -	if (arg & ~((JIMM_MASK) << 2))
> -		printk(KERN_WARNING "Micro-assembler field overflow\n");
> +	WARN(arg & ~((JIMM_MASK) << 2),

    Could drop parens around JIMM_MASK while at it...

WBR, Sergei

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] MIPS: Use WARN() in uasm for better diagnostics.
  2010-12-28 15:44 ` Sergei Shtylyov
@ 2010-12-28 15:54   ` Ralf Baechle
  0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2010-12-28 15:54 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: David Daney, linux-mips

On Tue, Dec 28, 2010 at 06:44:25PM +0300, Sergei Shtylyov wrote:

> > static inline __uasminit u32 build_jimm(u32 arg)
> > {
> >-	if (arg & ~((JIMM_MASK) << 2))
> >-		printk(KERN_WARNING "Micro-assembler field overflow\n");
> >+	WARN(arg & ~((JIMM_MASK) << 2),
> 
>    Could drop parens around JIMM_MASK while at it...

Done.

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-28 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28  2:18 [PATCH] MIPS: Use WARN() in uasm for better diagnostics David Daney
2010-12-28 15:31 ` Ralf Baechle
2010-12-28 15:44 ` Sergei Shtylyov
2010-12-28 15:54   ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.