* [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
@ 2008-07-22 19:38 ` Julia Lawall
0 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2008-07-22 19:38 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 finds this problem 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>
---
.../julia/linuxcopy}/arch/ia64/kvm/kvm-ia64.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
index 2672f4d..7a37d06 100644
--- a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
+++ b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
@@ -125,9 +125,9 @@ 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);
+ local_irq_restore(saved_psr);
if (slot < 0)
return;
- local_irq_restore(saved_psr);
spin_lock(&vp_lock);
status = ia64_pal_vp_init_env(kvm_vsa_base ?
@@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
+ local_irq_restore(saved_psr);
if (slot < 0)
return;
- local_irq_restore(saved_psr);
status = ia64_pal_vp_exit_env(host_iva);
if (status)
@@ -1253,6 +1253,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 related [flat|nested] 10+ messages in thread* Re: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
2008-07-22 19:38 ` [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
@ 2008-07-22 19:53 ` Matthew Wilcox
-1 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2008-07-22 19:53 UTC (permalink / raw)
To: Julia Lawall; +Cc: avi, kvm, xiantao.zhang, linux-kernel, kernel-janitors
On Tue, Jul 22, 2008 at 09:38:18PM +0200, Julia Lawall wrote:
> 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.
Patch looks good to me:
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
@ 2008-07-22 19:53 ` Matthew Wilcox
0 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2008-07-22 19:53 UTC (permalink / raw)
To: Julia Lawall; +Cc: avi, kvm, xiantao.zhang, linux-kernel, kernel-janitors
On Tue, Jul 22, 2008 at 09:38:18PM +0200, Julia Lawall wrote:
> 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.
Patch looks good to me:
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
2008-07-22 19:38 ` [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
@ 2008-07-23 1:26 ` Zhang, Xiantao
-1 siblings, 0 replies; 10+ messages in thread
From: Zhang, Xiantao @ 2008-07-23 1:26 UTC (permalink / raw)
To: Julia Lawall, avi, kvm, linux-kernel, kernel-janitors
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 finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
Good catch! Excellent patch to find such issues!
Xiantao
>
> // <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>
>
> ---
> .../julia/linuxcopy}/arch/ia64/kvm/kvm-ia64.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
> b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c index 2672f4d..7a37d06
> 100644 --- a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
> +++ b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
> @@ -125,9 +125,9 @@ 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);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> spin_lock(&vp_lock);
> status = ia64_pal_vp_init_env(kvm_vsa_base ?
> @@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
>
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> status = ia64_pal_vp_exit_env(host_iva);
> if (status)
> @@ -1253,6 +1253,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] 10+ messages in thread* RE: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code
@ 2008-07-23 1:26 ` Zhang, Xiantao
0 siblings, 0 replies; 10+ messages in thread
From: Zhang, Xiantao @ 2008-07-23 1:26 UTC (permalink / raw)
To: Julia Lawall, avi, kvm, linux-kernel, kernel-janitors
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 finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
Good catch! Excellent patch to find such issues!
Xiantao
>
> // <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>
>
> ---
> .../julia/linuxcopy}/arch/ia64/kvm/kvm-ia64.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
> b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c index 2672f4d..7a37d06
> 100644 --- a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
> +++ b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
> @@ -125,9 +125,9 @@ 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);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> spin_lock(&vp_lock);
> status = ia64_pal_vp_init_env(kvm_vsa_base ?
> @@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
>
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> status = ia64_pal_vp_exit_env(host_iva);
> if (status)
> @@ -1253,6 +1253,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] 10+ messages in thread
* Re: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore
2008-07-22 19:38 ` [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
` (2 preceding siblings ...)
(?)
@ 2008-07-24 11:35 ` walter harms
-1 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2008-07-24 11:35 UTC (permalink / raw)
To: kernel-janitors
local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
local_irq_restore(saved_psr);
maybe it is posible to move that local_irq_save() into ia64_itr_entry() directly ?
re,
wh
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 finds this problem 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>
>
> ---
> .../julia/linuxcopy}/arch/ia64/kvm/kvm-ia64.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
> index 2672f4d..7a37d06 100644
> --- a/home/julia/linux-2.6/arch/ia64/kvm/kvm-ia64.c
> +++ b/var/julia/linuxcopy/arch/ia64/kvm/kvm-ia64.c
> @@ -125,9 +125,9 @@ 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);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> spin_lock(&vp_lock);
> status = ia64_pal_vp_init_env(kvm_vsa_base ?
> @@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
>
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> + local_irq_restore(saved_psr);
> if (slot < 0)
> return;
> - local_irq_restore(saved_psr);
>
> status = ia64_pal_vp_exit_env(host_iva);
> if (status)
> @@ -1253,6 +1253,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 kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore
2008-07-22 19:38 ` [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
` (3 preceding siblings ...)
(?)
@ 2008-07-24 12:27 ` Julia Lawall
-1 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2008-07-24 12:27 UTC (permalink / raw)
To: kernel-janitors
On Thu, 24 Jul 2008, walter harms wrote:
> local_irq_save(saved_psr);
> slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
> local_irq_restore(saved_psr);
>
> maybe it is posible to move that local_irq_save() into ia64_itr_entry() directly ?
How would one make that decision? At the moment, the function is only
called in four places, all in the same file (arch/ia64/kvm/kvm-ia64.c).
In two places, the code has the above pattern. In the other two, the
turning off of interrupts is around several levels of enclosing fuction
calls.
In the defining file (arch/ia64/mm/tlb.c), there is also the function
ia64_ptr_entry. One seems to allocate and the other deallocates. Both
have the comment "Must be called with preemption disabled." So perhaps if
one is changed, the other should be changed as well?
julia
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore
2008-07-22 19:38 ` [PATCH retry] arch/ia64/kvm/kvm-ia64.c: Add local_irq_restore in error handling code Julia Lawall
@ 2008-07-26 9:10 ` Avi Kivity
-1 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2008-07-26 9:10 UTC (permalink / raw)
To: Julia Lawall; +Cc: kvm, xiantao.zhang, linux-kernel, kernel-janitors
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 finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
>
Applied, thanks.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 10+ messages in thread