All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: vijay.kilari@gmail.com
Cc: stefano.stabellini@eu.citrix.com,
	Prasun.Kapoor@caviumnetworks.com,
	vijaya.kumar@caviumnetworks.com, tim@xen.org,
	xen-devel@lists.xen.org, julien.grall@citrix.com,
	stefano.stabellini@citrix.com, manish.jaggi@caviumnetworks.com
Subject: Re: [RFC PATCH v3 13/18] xen/arm: ITS: Add irq descriptors for LPIs
Date: Mon, 29 Jun 2015 13:58:23 +0100	[thread overview]
Message-ID: <1435582703.32500.317.camel@citrix.com> (raw)
In-Reply-To: <1434974517-12136-14-git-send-email-vijay.kilari@gmail.com>

On Mon, 2015-06-22 at 17:31 +0530, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
> 
> Add irq descriptors for LPIs and route

This seems to also do interrupt injection for LPIs and more. Please
check that your commit messages are accurately describing the contents
of the patch. If it turns into a long list of unrelated sounding things
then that might suggest the patch should be split up.

> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
> ---
>  xen/arch/arm/gic-v3.c         |    8 +++-
>  xen/arch/arm/gic.c            |   17 +++++++-
>  xen/arch/arm/irq.c            |   38 +++++++++++++----
>  xen/arch/arm/vgic-v3-its.c    |    9 +++++
>  xen/arch/arm/vgic.c           |   90 ++++++++++++++++++++++++++++++++++++++---
>  xen/include/asm-arm/domain.h  |    2 +
>  xen/include/asm-arm/gic-its.h |    6 +++
>  xen/include/asm-arm/gic.h     |    3 ++
>  xen/include/asm-arm/vgic.h    |    1 +
>  9 files changed, 157 insertions(+), 17 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 737646c..793f2f0 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -899,9 +899,13 @@ static void gicv3_update_lr(int lr, const struct pending_irq *p,
>  
>      val =  (((uint64_t)state & 0x3) << GICH_LR_STATE_SHIFT) | grp;
>      val |= ((uint64_t)p->priority & 0xff) << GICH_LR_PRIORITY_SHIFT;
> -    val |= ((uint64_t)p->irq & GICH_LR_VIRTUAL_MASK) << GICH_LR_VIRTUAL_SHIFT;
>  
> -   if ( p->desc != NULL )
> +    if ( is_lpi(p->irq) )
> +        val |= ((uint64_t)p->irq & GICH_LR_VIRTUAL_MASK) << GICH_LR_VIRTUAL_SHIFT;
> +    else
> +        val |= ((uint64_t)p->irq & GICH_LR_VIRTUAL_MASK) << GICH_LR_VIRTUAL_SHIFT;

Is there supposed to be something different between these two cases? (Or
am I missing it?)

> +
> +   if ( p->desc != NULL && !(is_lpi(p->irq)) )
>         val |= GICH_LR_HW | (((uint64_t)p->desc->irq & GICH_LR_PHYSICAL_MASK)
>                             << GICH_LR_PHYSICAL_SHIFT);
>  
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index cfc9c42..091f7e5 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -124,18 +124,31 @@ void gic_route_irq_to_xen(struct irq_desc *desc, const cpumask_t *cpu_mask,
>                            unsigned int priority)
>  {
>      ASSERT(priority <= 0xff);     /* Only 8 bits of priority */
> -    ASSERT(desc->irq < gic_number_lines());/* Can't route interrupts that don't exist */
> +    /* Can't route interrupts that don't exist */
> +    ASSERT(desc->irq < gic_number_lines() && is_lpi(desc->irq));

||, surely? Otherwise doesn't this hit for every possible irq?

>      ASSERT(test_bit(_IRQ_DISABLED, &desc->status));
>      ASSERT(spin_is_locked(&desc->lock));
>  
>      desc->handler = gic_hw_ops->gic_host_irq_type;
>  
> -    gic_set_irq_properties(desc, cpu_mask, priority);
> +    if ( !is_lpi(desc->irq) )
> +        gic_set_irq_properties(desc, cpu_mask, priority);

I think any lack of support for affinity or priority should be pushed
down into the lower level drivers, rather than encoding that lack of
current support in the pits driver into the generic code.

>  int gic_route_irq_to_guest(struct domain *d, unsigned int virq,
>                             struct irq_desc *desc, unsigned int priority)
>  {
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 9dbdf7d..105ef85 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -57,12 +57,22 @@ hw_irq_controller no_irq_type = {
>  };
>  
>  static irq_desc_t irq_desc[NR_IRQS];
> +static irq_desc_t irq_desc_lpi[MAX_NR_LPIS];
>  static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc);
>  
>  irq_desc_t *__irq_to_desc(int irq)
>  {
> +    struct irq_desc *desc = NULL;
>      if (irq < NR_LOCAL_IRQS) return &this_cpu(local_irq_desc)[irq];
> -    return &irq_desc[irq-NR_LOCAL_IRQS];
> +    else if ( irq >= NR_LOCAL_IRQS && irq < NR_IRQS)
> +        return &irq_desc[irq-NR_LOCAL_IRQS];
> +    else
> +    {
> +        if ( is_lpi(irq) )
> +            return &irq_desc_lpi[irq - NR_GIC_LPI];
> +    }
> +
> +    return desc;

I'd write this as just a chain of "if (...) return", no need for else or
{}s.

> +void vgic_vcpu_inject_lpi(struct domain *d, unsigned int irq)
> +{
> +    struct irq_desc *desc;
> +    struct pending_irq *p;
> +    struct its_device *dev;
> +    struct vitt vitt_entry;
> +    struct vdevice_table dt_entry;
> +    uint32_t devid, col_id;
> +    int event;
> +
> +    desc = irq_to_desc(irq);
> +    event =  irq_to_virq(desc);
> +
> +    dev = get_irq_device(desc);
> +    devid = dev->device_id;
> +    event = irq - dev->lpi_base;
> +    if ( event < 0  && event > dev->nr_lpis)
> +    {
> +        dprintk(XENLOG_WARNING, 
> +               "LPI %d received for dev 0x%x is not valid..dropping \n",
> +               irq, devid);
> +        return;
> +    }
> +
> +    /* validity of device is checheck on vitt entry request */    

Typo

Also trailing whitespace, please clean that up everywhere.

> +    vits_get_vdevice_entry(d, devid, &dt_entry);
> +    if ( dt_entry.vitt_ipa != INVALID_PADDR )
> +    {
> +        dprintk(XENLOG_WARNING,
> +                "LPI %d received for dev 0x%x which is disabled..dropping \n",
> +                irq, devid);

This drops if the entry is _not_ invalid, is that really right?


> +        return;
> +    }
> +
> +    if ( vits_get_vitt_entry(d, devid, event, &vitt_entry) )
> +    {
> +        dprintk(XENLOG_WARNING,
> +                "LPI %d received for dev 0x%x which is disabled..dropping \n",
> +                irq, devid);
> +        return;
> +    }
> +    if ( !vitt_entry.valid )
> +    {
> +        dprintk(XENLOG_WARNING,
> +                "LPI %d received for dev 0x%x which is not valid..dropping \n",
> +                irq, devid);
> +        return;
> +    }
> +    p = irq_to_pending(d->vcpu[0], vitt_entry.vlpi);

Need to bounds check vitt_entry.vlpi somewhere, since the guest might
have messed with it.

> +    col_id = vitt_entry.vcollection;
> +
> +    ASSERT(col_id < d->max_vcpus);

Likewise a guest which writes vitt_entry.vcollection can now crash the
host.

Very great care needs to be taken with both dt_entry and vitt_entry and
all of their fields.

> +int vits_get_vitt_entry(struct domain *d, uint32_t devid,
> +                        uint32_t event, struct vitt *entry);
> +int vits_get_vdevice_entry(struct domain *d, uint32_t devid,
> +                           struct vdevice_table *entry);

Please add all prototypes in the same patch as the implementation of the
function, not the addition of the first caller.

Ian.

  reply	other threads:[~2015-06-29 12:58 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 12:01 [RFC PATCH v3 00/18] Add ITS support vijay.kilari
2015-06-22 12:01 ` [RFC PATCH v3 01/18] xen/arm: Add bitmap_find_next_zero_area helper function vijay.kilari
2015-06-22 14:14   ` Julien Grall
2015-06-22 12:01 ` [RFC PATCH v3 02/18] xen: Add log2 functionality vijay.kilari
2015-06-22 13:17   ` Jan Beulich
2015-06-24 13:05     ` Vijay Kilari
2015-06-24 13:21       ` Jan Beulich
2015-06-22 12:01 ` [RFC PATCH v3 03/18] xen: console: Add ratelimit support for error message vijay.kilari
2015-06-22 13:21   ` Jan Beulich
2015-06-25 13:14     ` Vijay Kilari
2015-06-25 13:21       ` Andrew Cooper
2015-06-25 13:31       ` Jan Beulich
2015-06-22 12:01 ` [RFC PATCH v3 04/18] xen/arm: gicv3: Refactor redistributor information vijay.kilari
2015-06-22 15:00   ` Julien Grall
2015-06-29 11:09   ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 05/18] xen/arm: ITS: Port ITS driver to xen vijay.kilari
2015-06-22 17:16   ` Julien Grall
2015-06-26  9:19     ` Vijay Kilari
2015-06-26  9:52       ` Julien Grall
2015-06-29 11:39   ` Ian Campbell
2015-06-29 15:43     ` Vijay Kilari
2015-06-29 15:47       ` Vijay Kilari
2015-06-29 16:49         ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 06/18] xen/arm: ITS: Add helper functions to manage its_devices vijay.kilari
2015-06-23 10:21   ` Julien Grall
2015-06-22 12:01 ` [RFC PATCH v3 07/18] xen/arm: ITS: implement hw_irq_controller for LPIs vijay.kilari
2015-06-23 14:32   ` Julien Grall
2015-06-26 12:54     ` Vijay Kilari
2015-06-26 15:05       ` Julien Grall
2015-06-29 11:53         ` Ian Campbell
2015-06-29 12:46           ` Julien Grall
2015-07-02 12:15         ` Vijay Kilari
2015-06-26 14:25     ` Vijay Kilari
2015-06-26 15:15       ` Julien Grall
2015-06-29 11:59     ` Ian Campbell
2015-07-02 12:21       ` Vijay Kilari
2015-07-02 12:35         ` Ian Campbell
2015-07-02 12:44           ` Vijay Kilari
2015-07-02 12:59             ` Ian Campbell
2015-07-02 16:11               ` Julien Grall
2015-06-22 12:01 ` [RFC PATCH v3 08/18] xen/arm: vITS: Add virtual ITS driver vijay.kilari
2015-06-23 16:39   ` Julien Grall
2015-07-02 13:33     ` Vijay Kilari
2015-07-02 14:30       ` Ian Campbell
2015-06-24  9:20   ` Julien Grall
2015-06-29 12:13   ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 09/18] xen/arm: ITS: Add virtual ITS commands support vijay.kilari
2015-06-24 10:29   ` Julien Grall
2015-06-29 12:16     ` Ian Campbell
2015-06-29 12:18   ` Ian Campbell
2015-06-29 12:23   ` Ian Campbell
2015-07-03  6:50     ` Vijay Kilari
2015-07-03  8:41       ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 10/18] xen/arm: ITS: Add APIs to add and assign device vijay.kilari
2015-06-24 11:38   ` Julien Grall
2015-06-29 12:25     ` Ian Campbell
2015-06-29 12:29   ` Ian Campbell
2015-07-02  8:40     ` Vijay Kilari
2015-07-02  9:01       ` Ian Campbell
2015-07-02 10:30         ` Julien Grall
2015-06-22 12:01 ` [RFC PATCH v3 11/18] xen/arm: ITS: Add GITS registers emulation vijay.kilari
2015-06-26 12:51   ` Julien Grall
2015-07-08 12:11   ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 12/18] xen/arm: ITS: Add GICR register emulation vijay.kilari
2015-06-22 12:01 ` [RFC PATCH v3 13/18] xen/arm: ITS: Add irq descriptors for LPIs vijay.kilari
2015-06-29 12:58   ` Ian Campbell [this message]
2015-06-29 13:11     ` Julien Grall
2015-07-07 11:00       ` Vijay Kilari
2015-07-07 11:16         ` Julien Grall
2015-07-07 15:50           ` Ian Campbell
2015-07-07 15:52             ` Julien Grall
2015-07-07 16:04               ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 14/18] xen/arm: ITS: Initialize physical ITS vijay.kilari
2015-06-22 12:01 ` [RFC PATCH v3 15/18] xen/arm: ITS: Add domain specific ITS initialization vijay.kilari
2015-06-29 13:01   ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 16/18] xen/arm: ITS: Handle LPI interrupts vijay.kilari
2015-06-29 13:03   ` Ian Campbell
2015-06-22 12:01 ` [RFC PATCH v3 17/18] xen/arm: ITS: Generate ITS node for Dom0 vijay.kilari
2015-06-29 13:06   ` Ian Campbell
2015-07-07  5:31     ` Vijay Kilari
2015-07-07  8:21       ` Julien Grall
2015-07-07 10:25         ` Vijay Kilari
2015-07-07 11:07           ` Julien Grall
2015-06-22 12:01 ` [RFC PATCH v3 18/18] xen/arm: ITS: Map ITS translation space vijay.kilari
2015-06-22 13:52 ` [RFC PATCH v3 00/18] Add ITS support Julien Grall
2015-06-22 13:56   ` Ian Campbell
2015-06-24 10:02 ` Ian Campbell
2015-06-29 13:11 ` 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=1435582703.32500.317.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Prasun.Kapoor@caviumnetworks.com \
    --cc=julien.grall@citrix.com \
    --cc=manish.jaggi@caviumnetworks.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=vijay.kilari@gmail.com \
    --cc=vijaya.kumar@caviumnetworks.com \
    --cc=xen-devel@lists.xen.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.