KVM ARM Archive on lore.kernel.org
 help / color / Atom feed
From: Zhenyu Ye <yezhenyu2@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: gleb@redhat.com, kvm@vger.kernel.org, "S. Tsirkin,
	Michael" <mst@redhat.com>,
	linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [Question] the check of ioeventfd collision in kvm_*assign_ioeventfd_idx
Date: Fri, 31 Jul 2020 16:21:40 +0800
Message-ID: <18baa777-7f28-8f57-e815-11175bf4c59a@huawei.com> (raw)
In-Reply-To: <cffcf9e1-6675-6815-ccfc-f48497ade818@redhat.com>

On 2020/7/31 14:44, Paolo Bonzini wrote:
> On 31/07/20 08:39, Zhenyu Ye wrote:
>> On 2020/7/31 2:03, Paolo Bonzini wrote:
>>> Yes, I think it's not needed. Probably the deassign check can be turned into an assertion?
>>>
>>> Paolo
>>>
>>
>> I think we can do this in the same function, and turnt he check of
>> p->eventfd into assertion in kvm_deassign_ioeventfd_idx(). Just like:
>>
>> ---8<---
>> static inline struct _ioeventfd *
>> get_ioeventfd(struct kvm *kvm, enum kvm_bus bus_idx,
>>               struct kvm_ioeventfd *args)
>> {
>>         static struct _ioeventfd *_p;
>>         bool wildcard = !(args->flags & KVM_IOEVENTFD_FLAG_DATAMATCH);
>>
>>         list_for_each_entry(_p, &kvm->ioeventfds, list)
>>                 if (_p->bus_idx == bus_idx &&
>>                     _p->addr == args->addr &&
>>                     (!_p->length || !args->len ||
>>                      (_p->length == args->len &&
>>                       (_p->wildcard || wildcard ||
>>                        _p->datamatch == args->datamatch))))
>>                         return _p;
>>
>>         return NULL;
>> }
>>
>> kvm_deassign_ioeventfd_idx() {
>> 	...
>> 	p = get_ioeventfd(kvm, bus_idx, args);
>> 	if (p) {
>> 		assert(p->eventfd == eventfd);
>> 		...
>> 	}
>>
>> ---8<----
>>
>> This may be easier to understand (keep the same logic in assign/deassign).
> 
> I think you should also warn if:
> 
> 1) p->length != args->len
>
> 2) p->wildcard != args->wildcard if p->length
>
> 3) p->datamatch != args->datamatch if p->length && !p->wildcard
> 
> but yeah it sounds like a plan.
> 

I will try to do this. :)

Zhenyu

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

      reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 14:19 Zhenyu Ye
2020-07-30 18:03 ` Paolo Bonzini
2020-07-31  6:39   ` Zhenyu Ye
2020-07-31  6:44     ` Paolo Bonzini
2020-07-31  8:21       ` Zhenyu Ye [this message]

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=18baa777-7f28-8f57-e815-11175bf4c59a@huawei.com \
    --to=yezhenyu2@huawei.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@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

KVM ARM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvmarm/0 kvmarm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvmarm kvmarm/ https://lore.kernel.org/kvmarm \
		kvmarm@lists.cs.columbia.edu
	public-inbox-index kvmarm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/edu.columbia.cs.lists.kvmarm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git