diff mbox

KVM: use correct accessor function for __kvm_memslots

Message ID 1499435437-6427-1-git-send-email-borntraeger@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Borntraeger July 7, 2017, 1:50 p.m. UTC
kvm memslots are protected by srcu and not by rcu. We must use
srcu_dereference_check instead of rcu_dereference_check.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/linux/kvm_host.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini July 7, 2017, 4:56 p.m. UTC | #1
On 07/07/2017 15:50, Christian Borntraeger wrote:
> kvm memslots are protected by srcu and not by rcu. We must use
> srcu_dereference_check instead of rcu_dereference_check.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/linux/kvm_host.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index b3ca77a..3561e41 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -568,7 +568,7 @@ void kvm_put_kvm(struct kvm *kvm);
>  
>  static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id)
>  {
> -	return rcu_dereference_check(kvm->memslots[as_id],
> +	return srcu_dereference_check(kvm->memslots[as_id], &kvm->srcu,
>  			srcu_read_lock_held(&kvm->srcu)
>  			|| lockdep_is_held(&kvm->slots_lock));

The condition can be simplified, since srcu_dereference_check is exactly
calling srcu_read_lock_held.

Paolo

>  }
>
diff mbox

Patch

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b3ca77a..3561e41 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -568,7 +568,7 @@  void kvm_put_kvm(struct kvm *kvm);
 
 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id)
 {
-	return rcu_dereference_check(kvm->memslots[as_id],
+	return srcu_dereference_check(kvm->memslots[as_id], &kvm->srcu,
 			srcu_read_lock_held(&kvm->srcu)
 			|| lockdep_is_held(&kvm->slots_lock));
 }