From: Paolo Bonzini <pbonzini@redhat.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: kvm@vger.kernel.org, "Andre Przywara" <andre.przywara@arm.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Alexander Graf" <agraf@suse.de>,
borntraeger@de.ibm.com, paulus@ozlabs.org,
kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 2/2] KVM: Protect device ops->create and list_add with kvm->lock
Date: Tue, 9 Aug 2016 15:16:26 +0200 [thread overview]
Message-ID: <44eacdbf-5ec2-6b8c-d2cb-4fe09dbf001d@redhat.com> (raw)
In-Reply-To: <20160809125519.GG9175@cbox>
On 09/08/2016 14:55, Christoffer Dall wrote:
> On Tue, Aug 09, 2016 at 02:37:43PM +0200, Paolo Bonzini wrote:
>>
>>
>> On 09/08/2016 14:20, Christoffer Dall wrote:
>>> KVM devices were manipulating list data structures without any form of
>>> synchronization, and some implementations of the create operations also
>>> suffered from a lack of synchronization.
>>>
>>> Now when we've split the xics create operation into create and init, we
>>> can hold the kvm->lock mutex while calling the create operation and when
>>> manipulating the devices list.
>>>
>>> The error path in the generic code gets slightly ugly because we have to
>>> take the mutex again and delete the device from the list, but holding
>>> the mutex during anon_inode_getfd or releasing/locking the mutex in the
>>> common non-error path seemed wrong.
>>>
>>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>>
>> Very nice (and small), but please add a comment to the create member in
>> kvm_device_ops.
>
> Like this?:
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index d3c9b82..9c28b4d 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1113,6 +1113,12 @@ struct kvm_device {
> /* create, destroy, and name are mandatory */
> struct kvm_device_ops {
> const char *name;
> +
> + /*
> + * create is called holding kvm->lock and any operations not suitable
> + * to do while holding the lock should be deferred to init (see
> + * below).
> + */
> int (*create)(struct kvm_device *dev, u32 type);
>
> /*
>
That's okay, series
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2016-08-09 13:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 12:20 [PATCH 0/2] KVM: Synchronize KVM devices list access and create ops Christoffer Dall
2016-08-09 12:20 ` [PATCH 1/2] KVM: PPC: Move xics_debugfs_init out of create Christoffer Dall
2016-08-09 12:20 ` [PATCH 2/2] KVM: Protect device ops->create and list_add with kvm->lock Christoffer Dall
2016-08-09 12:37 ` Paolo Bonzini
2016-08-09 12:55 ` Christoffer Dall
2016-08-09 13:16 ` Paolo Bonzini [this message]
2016-08-09 14:49 ` Christoffer Dall
2016-08-09 15:20 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44eacdbf-5ec2-6b8c-d2cb-4fe09dbf001d@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=andre.przywara@arm.com \
--cc=borntraeger@de.ibm.com \
--cc=christoffer.dall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=paulus@ozlabs.org \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).