From: "Jan Beulich" <JBeulich@suse.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
IanJackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>,
xen-devel <xen-devel@lists.xenproject.org>,
Daniel de Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v3] passthrough: give XEN_DOMCTL_test_assign_device more sane semantics
Date: Fri, 25 Aug 2017 09:54:18 -0600 [thread overview]
Message-ID: <59A0644A0200007800173F2D@prv-mh.provo.novell.com> (raw)
In-Reply-To: <20170825152552.earul2kwsiutlyan@citrix.com>
>>> On 25.08.17 at 17:25, <wei.liu2@citrix.com> wrote:
> On Wed, Aug 16, 2017 at 06:20:01AM -0600, Jan Beulich wrote:
>> So far callers of the libxc interface passed in a domain ID which was
>> then ignored in the hypervisor. Instead, make the hypervisor honor it
>> (accepting DOMID_INVALID to obtain original behavior), allowing to
>> query whether a device can be assigned to a particular domain.
>>
>> Drop XSM's test_assign_{,dt}device hooks as no longer being
>> individually useful.
>
> Can you also say in the commit message that you consolidate some code as
> well?
Am I consolidating code beyond what is reasonable to achieve
the intended effect? I don't view the merging of the two case
blocks
> Assuming the disagreement on the semantics of the call is settled:
>
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
>
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> ---
>> v3: Drop test-assign XSM hooks.
>> v2: Alter the semantics to check whether the device can be assigned to
>> the passed in domain.
>>
>> --- a/xen/common/domctl.c
>> +++ b/xen/common/domctl.c
>> @@ -391,11 +391,15 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe
>>
>> switch ( op->cmd )
>> {
>> - case XEN_DOMCTL_createdomain:
>> case XEN_DOMCTL_test_assign_device:
>> + if ( op->domain == DOMID_INVALID )
>> + {
>> + case XEN_DOMCTL_createdomain:
>> case XEN_DOMCTL_gdbsx_guestmemio:
>> - d = NULL;
>> - break;
>> + d = NULL;
>> + break;
>> + }
>> + /* fall through */
>
> I know there is already code like this but I would rather not mix if and
> case labels. Anyway, that's just my personal taste and I won't block
> this patch because of that.
Understood. I, otoh, prefer this style to limit code duplication.
>> --- a/xen/drivers/passthrough/device_tree.c
>> +++ b/xen/drivers/passthrough/device_tree.c
>> @@ -143,12 +143,15 @@ int iommu_do_dt_domctl(struct xen_domctl
>> switch ( domctl->cmd )
>> {
>> case XEN_DOMCTL_assign_device:
>> + ASSERT(d);
>> + /* fall through */
>> + case XEN_DOMCTL_test_assign_device:
>> ret = -ENODEV;
>> if ( domctl->u.assign_device.dev != XEN_DOMCTL_DEV_DT )
>> break;
>>
>> ret = -EINVAL;
>> - if ( d->is_dying || domctl->u.assign_device.flags )
>> + if ( (d && d->is_dying) || domctl->u.assign_device.flags )
>> break;
>>
>> ret = dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path,
>> @@ -161,6 +164,17 @@ int iommu_do_dt_domctl(struct xen_domctl
>> if ( ret )
>> break;
>>
>> + if ( domctl->cmd == XEN_DOMCTL_test_assign_device )
>> + {
>> + if ( iommu_dt_device_is_assigned(dev) )
>> + {
>> + printk(XENLOG_G_ERR "%s already assigned.\n",
>> + dt_node_full_name(dev));
>> + ret = -EINVAL;
>> + }
>> + break;
>> + }
>> +
>
> Move the ASSERT(d) here?
That would be a possibility, but personally I think it's better placed
where it is now. It helps, for example, understanding why there is
a NULL check of d somewhere in the middle. In a domctl handler d
being NULL isn't a usual thing.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-25 15:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 12:20 [PATCH v3] passthrough: give XEN_DOMCTL_test_assign_device more sane semantics Jan Beulich
2017-08-16 14:22 ` Daniel De Graaf
2017-08-25 14:58 ` Ping: " Jan Beulich
2017-08-25 15:25 ` Wei Liu
2017-08-25 15:54 ` Jan Beulich [this message]
2017-08-25 16:00 ` Jan Beulich
2017-08-25 16:05 ` [PATCH v3] passthrough: give XEN_DOMCTL_test_assign_device more sane semantics (and 1 more message) Wei Liu
2017-08-28 7:27 ` Jan Beulich
2017-08-28 15:39 ` Wei Liu
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=59A0644A0200007800173F2D@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.