* [PATCH 1/2] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
@ 2008-07-22 16:44 Julia Lawall
2008-07-22 19:11 ` Simon Holm Thøgersen
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2008-07-22 16:44 UTC (permalink / raw)
To: avi, kvm, xiantao.zhang, 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/ia64/kvm/kvm-ia64.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 318b811..14e5c99 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -125,8 +125,10 @@ void kvm_arch_hardware_enable(void *garbage)
PAGE_KERNEL));
local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
- if (slot < 0)
+ if (slot < 0) {
+ local_irq_restore(saved_psr);
return;
+ }
local_irq_restore(saved_psr);
spin_lock(&vp_lock);
@@ -160,8 +162,10 @@ void kvm_arch_hardware_disable(void *garbage)
local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
- if (slot < 0)
+ if (slot < 0) {
+ local_irq_restore(saved_psr);
return;
+ }
local_irq_restore(saved_psr);
status = ia64_pal_vp_exit_env(host_iva);
@@ -1258,6 +1262,7 @@ static int vti_vcpu_setup(struct kvm_vcpu *vcpu, int id)
uninit:
kvm_vcpu_uninit(vcpu);
fail:
+ local_irq_restore(psr);
return r;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
2008-07-22 16:44 [PATCH 1/2] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
@ 2008-07-22 19:11 ` Simon Holm Thøgersen
2008-07-22 19:18 ` Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Simon Holm Thøgersen @ 2008-07-22 19:11 UTC (permalink / raw)
To: Julia Lawall; +Cc: avi, kvm, xiantao.zhang, linux-kernel, kernel-janitors
tir, 22 07 2008 kl. 18:44 +0200, skrev Julia Lawall:
> 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/ia64/kvm/kvm-ia64.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
> index 318b811..14e5c99 100644
> --- a/arch/ia64/kvm/kvm-ia64.c
> +++ b/arch/ia64/kvm/kvm-ia64.c
> @@ -125,8 +125,10 @@ void kvm_arch_hardware_enable(void *garbage)
> PAGE_KERNEL));
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> - if (slot < 0)
> + if (slot < 0) {
> + local_irq_restore(saved_psr);
> return;
> + }
> local_irq_restore(saved_psr);
If this change makes sense, how about merging the two local_irq_restore
calls and put them before the if? And shouldn't your checker be able to
figure this?
>
> spin_lock(&vp_lock);
> @@ -160,8 +162,10 @@ void kvm_arch_hardware_disable(void *garbage)
>
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> - if (slot < 0)
> + if (slot < 0) {
> + local_irq_restore(saved_psr);
> return;
> + }
> local_irq_restore(saved_psr);
>
Same as above.
> status = ia64_pal_vp_exit_env(host_iva);
> @@ -1258,6 +1262,7 @@ static int vti_vcpu_setup(struct kvm_vcpu *vcpu, int id)
> uninit:
> kvm_vcpu_uninit(vcpu);
> fail:
> + local_irq_restore(psr);
> return r;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
2008-07-22 19:11 ` Simon Holm Thøgersen
@ 2008-07-22 19:18 ` Julia Lawall
0 siblings, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2008-07-22 19:18 UTC (permalink / raw)
To: Simon Holm Thøgersen
Cc: avi, kvm, xiantao.zhang, linux-kernel, kernel-janitors
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2066 bytes --]
On Tue, 22 Jul 2008, Simon Holm Thøgersen wrote:
> tir, 22 07 2008 kl. 18:44 +0200, skrev Julia Lawall:
> > 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/ia64/kvm/kvm-ia64.c | 9 +++++++--
> > 1 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
> > index 318b811..14e5c99 100644
> > --- a/arch/ia64/kvm/kvm-ia64.c
> > +++ b/arch/ia64/kvm/kvm-ia64.c
> > @@ -125,8 +125,10 @@ void kvm_arch_hardware_enable(void *garbage)
> > PAGE_KERNEL));
> > local_irq_save(saved_psr);
> > slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> > - if (slot < 0)
> > + if (slot < 0) {
> > + local_irq_restore(saved_psr);
> > return;
> > + }
> > local_irq_restore(saved_psr);
>
> If this change makes sense, how about merging the two local_irq_restore
> calls and put them before the if? And shouldn't your checker be able to
> figure this?
No, it pretty much only does what it's told, which is to put a
local_irq_restore before the return.
Since slot is a local variable, it does seem like the call to
local_irq_restore could be safely moved upwards, so I will do that
instead.
thanks,
julia
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-22 19:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-22 16:44 [PATCH 1/2] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
2008-07-22 19:11 ` Simon Holm Thøgersen
2008-07-22 19:18 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®