All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] : Add local_irq_restore in error handling code
@ 2008-07-22 16:44 ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2008-07-22 16:44 UTC (permalink / raw)
  To: ralf, linux-mips, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

There is a call to local_irq_restore in the normal exit case, so it would
seem that there should be one on an error return as well.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression l;
expression E,E1,E2;
@@

local_irq_save(l);
... when != local_irq_restore(l)
    when != spin_unlock_irqrestore(E,l)
    when any
    when strict
(
if (...) { ... when != local_irq_restore(l)
               when != spin_unlock_irqrestore(E1,l)
+   local_irq_restore(l);
    return ...;
}
|
if (...)
+   {local_irq_restore(l);
    return ...;
+   }
|
spin_unlock_irqrestore(E2,l);
|
local_irq_restore(l);
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/mips/mm/tlb-r3k.c        |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
index a782549..7d7e822 100644
--- a/arch/mips/mm/tlb-r3k.c
+++ b/arch/mips/mm/tlb-r3k.c
@@ -247,6 +247,7 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
 		w = read_c0_wired();
 		write_c0_wired(w + 1);
 		if (read_c0_wired() != w + 1) {
+			local_irq_restore(flags);
 			printk("[tlbwired] No WIRED reg?\n");
 			return;
 		}

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

* [PATCH 2/2] : Add local_irq_restore in error handling code
@ 2008-07-22 16:44 ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2008-07-22 16:44 UTC (permalink / raw)
  To: ralf, linux-mips, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

There is a call to local_irq_restore in the normal exit case, so it would
seem that there should be one on an error return as well.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression l;
expression E,E1,E2;
@@

local_irq_save(l);
... when != local_irq_restore(l)
    when != spin_unlock_irqrestore(E,l)
    when any
    when strict
(
if (...) { ... when != local_irq_restore(l)
               when != spin_unlock_irqrestore(E1,l)
+   local_irq_restore(l);
    return ...;
}
|
if (...)
+   {local_irq_restore(l);
    return ...;
+   }
|
spin_unlock_irqrestore(E2,l);
|
local_irq_restore(l);
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/mips/mm/tlb-r3k.c        |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
index a782549..7d7e822 100644
--- a/arch/mips/mm/tlb-r3k.c
+++ b/arch/mips/mm/tlb-r3k.c
@@ -247,6 +247,7 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
 		w = read_c0_wired();
 		write_c0_wired(w + 1);
 		if (read_c0_wired() != w + 1) {
+			local_irq_restore(flags);
 			printk("[tlbwired] No WIRED reg?\n");
 			return;
 		}

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

* Re: [PATCH 2/2] : Add local_irq_restore in error handling code
  2008-07-22 16:44 ` Julia Lawall
@ 2008-07-22 17:10   ` Ralf Baechle
  -1 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2008-07-22 17:10 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mips, linux-kernel, kernel-janitors

Hi Julia,

On Tue, Jul 22, 2008 at 06:44:48PM +0200, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> There is a call to local_irq_restore in the normal exit case, so it would
> seem that there should be one on an error return as well.
> 
> The semantic patch that makes this change is as follows:
> (http://www.emn.fr/x-info/coccinelle/)

Correctly spotted - but I decieded to go for below patch instead.

Thanks,

  Ralf

From: Ralf Baechle <ralf@linux-mips.org>

[MIPS] tlb-r4k: Nuke broken paranoia error test.

Bug originally found and reported by Julia Lawall <julia@diku.dk>.  I
decieded that the whole error check was mostly useless paranoia and should
be discarded.  It would only ever trigger if r3k_have_wired_reg has a wrong
value.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
index a782549..f0cf46a 100644
--- a/arch/mips/mm/tlb-r3k.c
+++ b/arch/mips/mm/tlb-r3k.c
@@ -246,10 +246,6 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
 		old_pagemask = read_c0_pagemask();
 		w = read_c0_wired();
 		write_c0_wired(w + 1);
-		if (read_c0_wired() != w + 1) {
-			printk("[tlbwired] No WIRED reg?\n");
-			return;
-		}
 		write_c0_index(w << 8);
 		write_c0_pagemask(pagemask);
 		write_c0_entryhi(entryhi);

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

* Re: [PATCH 2/2] : Add local_irq_restore in error handling code
@ 2008-07-22 17:10   ` Ralf Baechle
  0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2008-07-22 17:10 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mips, linux-kernel, kernel-janitors

Hi Julia,

On Tue, Jul 22, 2008 at 06:44:48PM +0200, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> There is a call to local_irq_restore in the normal exit case, so it would
> seem that there should be one on an error return as well.
> 
> The semantic patch that makes this change is as follows:
> (http://www.emn.fr/x-info/coccinelle/)

Correctly spotted - but I decieded to go for below patch instead.

Thanks,

  Ralf

From: Ralf Baechle <ralf@linux-mips.org>

[MIPS] tlb-r4k: Nuke broken paranoia error test.

Bug originally found and reported by Julia Lawall <julia@diku.dk>.  I
decieded that the whole error check was mostly useless paranoia and should
be discarded.  It would only ever trigger if r3k_have_wired_reg has a wrong
value.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c
index a782549..f0cf46a 100644
--- a/arch/mips/mm/tlb-r3k.c
+++ b/arch/mips/mm/tlb-r3k.c
@@ -246,10 +246,6 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
 		old_pagemask = read_c0_pagemask();
 		w = read_c0_wired();
 		write_c0_wired(w + 1);
-		if (read_c0_wired() != w + 1) {
-			printk("[tlbwired] No WIRED reg?\n");
-			return;
-		}
 		write_c0_index(w << 8);
 		write_c0_pagemask(pagemask);
 		write_c0_entryhi(entryhi);

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

end of thread, other threads:[~2008-07-22 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 16:44 [PATCH 2/2] : Add local_irq_restore in error handling code Julia Lawall
2008-07-22 16:44 ` Julia Lawall
2008-07-22 17:10 ` Ralf Baechle
2008-07-22 17:10   ` 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.