All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Julien Grall <julien.grall@citrix.com>
Cc: Julien Grall <julien.grall@linaro.org>,
	tim@xen.org, stefano.stabellini@citrix.com,
	Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v5 p2 04/19] xen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq
Date: Fri, 17 Apr 2015 10:47:19 +0100	[thread overview]
Message-ID: <1429264039.25195.229.camel@citrix.com> (raw)
In-Reply-To: <5530A1E9.6060304@citrix.com>

On Fri, 2015-04-17 at 07:02 +0100, Julien Grall wrote:
> Hi Ian,
> 
> On 16/04/2015 16:40, Ian Campbell wrote:
> > On Thu, 2015-04-16 at 16:20 +0100, Julien Grall wrote:
> >>>> Concerning XSM, even if ARM is using one hypercall rather than 2, the
> >>>> resulting check is nearly the same.
> >>>>
> >>>> XSM PHYSDEVOP_map_pirq:
> >>>>       1) Check if the current domain can add resource to the domain
> >>>>       2) Check if the current domain has permission to add the IRQ
> >>>>       3) Check if the target domain has permission to use the IRQ
> >>>>
> >>>> XSM DOMCTL_bind_pirq_irq:
> >>>>       1) Check if the current domain can add resource to the domain
> >>>>       2) Check if the current domain has permission to bind the IRQ
> >>>>       3) Check if the target domain has permission to use the IRQ
> >>>>
> >>>> In order to keep the same XSM checks done by the 2 hypercalls on x86,
> >>>> call both xsm_map_domain_irq & xsm_bind_pt_irq in the ARM implementation.
> >>>
> >>> I think this paragraph makes the previous bit obsolete?
> >>
> >> Do you mean: "Concerning XSM..." until and the 2 paragraphs for XSM
> >> hypercalls?
> >
> > That's right.
> 
> Ok. I will drop it.
> 
> >>>> @@ -1878,6 +1913,25 @@ int xc_domain_bind_pt_isa_irq(
> >>>>                                      PT_IRQ_TYPE_ISA, 0, 0, 0, machine_irq));
> >>>>    }
> >>>>
> >>>> +int xc_domain_bind_pt_spi_irq(
> >>>> +    xc_interface *xch,
> >>>> +    uint32_t domid,
> >>>> +    uint16_t spi)
> >>>> +{
> >>>> +    /* vSPI == SPI */
> >>>
> >>> I wonder if to avoid API churn later we should accept both machine and
> >>> guest IRQ here and rely on the check that htey are the same in the
> >>> hypervisor to reject?
> >>>
> >>> Fair enough we can change libxc interface if we want, but avoiding a
> >>> little churn later on seems reasonable and it makes it a better fit with
> >>> the existing interfaces.
> >>
> >> what about the following prototype:
> >>
> >> int xc_domain_bind_pt_spi_irq(
> >>       xc_interface *xch,
> >>       uint32_t domid,
> >>       uint16_t spi,
> >>       uint16_t vspi)
> >>
> >> I didn't reuse the current name i.e (machine_irq) because I find the
> >> name confusing.
> >
> > Sure. Although you hit machine_irq again at the next level in the stack
> > so I think it's rather moot.
> >
> >>
> >> [..]
> >>
> >>>> +    case XEN_DOMCTL_unbind_pt_irq:
> >>>> +    {
> >>>> +        int rc;
> >>>> +        xen_domctl_bind_pt_irq_t *bind = &domctl->u.bind_pt_irq;
> >>>> +        uint32_t irq = bind->u.spi.spi;
> >>>> +        uint32_t virq = bind->machine_irq;
> >>>> +
> >>>> +        /* We only support PT_IRQ_TYPE_SPI */
> >>>> +        if ( bind->irq_type != PT_IRQ_TYPE_SPI )
> >>>> +            return -EOPNOTSUPP;
> >>>> +
> >>>> +        /* For now map the interrupt 1:1 */
> >>>> +        if ( irq != virq )
> >>>> +            return -EINVAL;
> >>>
> >>> The x86 version doesn't appear to consider irq_type or irq, only virq
> >>> (from ->machine_irq). That seems to be logical to me (if a little
> >>> underdocumented) and I think we should be consistent.
> >>
> >> On x86, the parameters are used later in pt_create_bind which take the
> >> hypercall data in parameter.
> >
> > Ah yes, (although you mean pt_irq_destroy_bind I think?)
> 
> No I mean pt_irq_create_bind.

My initial comment was talking specifically about
XEN_DOMCTL_unbind_pt_irq, which AFAICT does not call pt_irq_create_bind
(which is why I assumed you must mean unbind).

I agree that XEN_DOMCTL_bind_pt_irq should contain checks of all its
inputs, of course.

>  The function makes usage of machine_irq 
> and irq_type. Although, there is no clear switch case, just an if in the 
> code.
> 
> >> The both check are required in order to avoid future issue if we
> >> introduce new type and when we will support virq != irq.
> >
> > Shouldn't they be in pt_irq_destroy_bind then?
> 
> I'm not following you. pt_irq_destroy_bind is an x86 specific function.
> 
> The check "virq != irq" is done in both DOMCTL_{,un}bind_irq on ARM even 
> though the one in unbind is not necessary useful.

This was exactly my point, on x86 XEN_DOMCTL_unbind_pt_irq didn't appear
to pay attention to anything other than the virq provided, I assumed
since it doesn't need any other information from the caller to do as it
has been asked.

But it seems like maybe I was wrong and pt_irq_destroy_bind (called from
XEN_DOMCTL_unbind_pt_irq on x86) does actually need other info (I'm not
sure why, it seems like it ought to know these things without being told
by the toolstack). In which case having your check for consistency with
x86 is probably tolerable.

Ian.

  reply	other threads:[~2015-04-17  9:47 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 15:09 [PATCH v5 p2 00/19] xen/arm Add support for non-PCI passthrough Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 01/19] xen/arm: Let the toolstack configure the number of SPIs Julien Grall
2015-04-16 14:39   ` Ian Campbell
2015-04-16 15:10     ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 02/19] xen/arm: vgic: Add spi_to_pending Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 03/19] xen/arm: Release IRQ routed to a domain when it's destroying Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 04/19] xen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq Julien Grall
2015-04-16 14:55   ` Ian Campbell
2015-04-16 15:20     ` Julien Grall
2015-04-16 15:40       ` Ian Campbell
2015-04-17  6:02         ` Julien Grall
2015-04-17  9:47           ` Ian Campbell [this message]
2015-04-17 23:05     ` Daniel De Graaf
2015-04-09 15:09 ` [PATCH v5 p2 05/19] xen: guestcopy: Provide an helper to safely copy string from guest Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 06/19] xen/dts: Provide an helper to get a DT node from a path provided by a guest Julien Grall
2015-04-16 14:57   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 07/19] xen/passthrough: Introduce iommu_construct Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 08/19] xen/passthrough: arm: release the DT devices assigned to a guest earlier Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 09/19] xen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 10/19] xen/iommu: arm: Wire iommu DOMCTL for ARM Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 11/19] xen/xsm: Add helpers to check permission for device tree passthrough Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 12/19] xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device Julien Grall
2015-04-16 15:11   ` Ian Campbell
2015-04-16 15:21     ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 13/19] tools/libxl: Create a per-arch function to map IRQ to a domain Julien Grall
2015-04-16 15:12   ` Ian Campbell
2015-04-16 15:26     ` Julien Grall
2015-04-16 15:42       ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 14/19] tools/libxl: Check if fdt_{first, next}_subnode are present in libfdt Julien Grall
2015-04-16 15:13   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 15/19] tools/(lib)xl: Add partial device tree support for ARM Julien Grall
2015-04-09 16:13   ` Ian Jackson
2015-04-28 13:30     ` Julien Grall
2015-04-16 15:17   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 16/19] tools/libxl: arm: Use an higher value for the GIC phandle Julien Grall
2015-04-09 16:17   ` Ian Jackson
2015-04-09 16:33     ` Julien Grall
2015-04-09 16:52       ` Ian Jackson
2015-04-09 17:00         ` Julien Grall
2015-04-09 17:02           ` Julien Grall
2015-04-09 17:04           ` Ian Jackson
2015-04-13 12:07             ` Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 17/19] libxl: Add support for Device Tree passthrough Julien Grall
2015-04-09 16:14   ` Ian Jackson
2015-04-16 15:19   ` Ian Campbell
2015-04-09 15:09 ` [PATCH v5 p2 18/19] xl: Add new option dtdev Julien Grall
2015-04-09 15:09 ` [PATCH v5 p2 19/19] docs/misc: arm: Add documentation about Device Tree passthrough Julien Grall
2015-04-16 15:20   ` Ian Campbell

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=1429264039.25195.229.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --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.