xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: mjaggi@caviumnetworks.com, xen-devel@lists.xenproject.org
Cc: Andre.Przywara@arm.com, julien.grall@arm.com,
	sstabellini@kernel.org, Manish Jaggi <mjaggi@cavium.com>
Subject: Re: [PATCH v5 3/5] ARM: ITS: Deny hardware domain access to ITS
Date: Tue, 10 Oct 2017 11:11:01 +0100	[thread overview]
Message-ID: <71d14bac-fa7b-0f1c-3bf3-f0e29159f2bf@linaro.org> (raw)
In-Reply-To: <1507616218-2478-4-git-send-email-mjaggi@caviumnetworks.com>

Hi Manish,

I just spotted an issue in this patch.

On 10/10/17 07:16, mjaggi@caviumnetworks.com wrote:
> From: Manish Jaggi <mjaggi@cavium.com>
> 
> This patch extends the gicv3_iomem_deny_access functionality by adding
> support for ITS region as well. Add function gicv3_its_deny_access.
> 
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
> Acked-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Manish Jaggi <mjaggi@cavium.com>
> ---
>   xen/arch/arm/gic-v3-its.c        | 22 ++++++++++++++++++++++
>   xen/arch/arm/gic-v3.c            |  3 +++
>   xen/include/asm-arm/gic_v3_its.h |  9 +++++++++
>   3 files changed, 34 insertions(+)
> 
> diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
> index 3023ee5..7746ae8 100644
> --- a/xen/arch/arm/gic-v3-its.c
> +++ b/xen/arch/arm/gic-v3-its.c
> @@ -21,6 +21,7 @@
>   #include <xen/acpi.h>
>   #include <xen/lib.h>
>   #include <xen/delay.h>
> +#include <xen/iocap.h>
>   #include <xen/libfdt/libfdt.h>
>   #include <xen/mm.h>
>   #include <xen/rbtree.h>
> @@ -905,6 +906,27 @@ struct pending_irq *gicv3_assign_guest_event(struct domain *d,
>       return pirq;
>   }
>   
> +int gicv3_its_deny_access(const struct domain *d)
> +{
> +    int rc = 0;
> +    unsigned long mfn, nr;
> +    const struct host_its *its_data;
> +
> +    list_for_each_entry( its_data, &host_its_list, entry )
> +    {
> +        mfn = paddr_to_pfn(its_data->addr);
> +        nr = PFN_UP(GICV3_ITS_SIZE);

While you fix the bug (see below), please use its_data->size here.

> +        rc = iomem_deny_access(d, mfn, mfn + nr);
> +        if ( rc )
> +        {
> +            printk( "iomem_deny_access failed for %lx:%lx \r\n", mfn, nr);

And here the spurious space between ( and ".

> +            break;
> +        }
> +    }
> +
> +    return rc;
> +}
> +
>   /*
>    * Create the respective guest DT nodes from a list of host ITSes.
>    * This copies the reg property, so the guest sees the ITS at the same address
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 6f562f4..b3d605d 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1308,6 +1308,9 @@ static int gicv3_iomem_deny_access(const struct domain *d)
>       if ( rc )
>           return rc;
>   
> +    if ( gicv3_its_deny_access(d) )
> +        return rc;

you return rc here in case of an error, however you don't set it before. 
So this will always return 0 and Xen will continue to boot as nothing 
happen.

The best way to fix it would be:

rc = gicv3_its_deny_access(d);
if ( rc )
   return rc;

> +
>       for ( i = 0; i < gicv3.rdist_count; i++ )
>       {
>           mfn = gicv3.rdist_regions[i].base >> PAGE_SHIFT;
> diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h
> index e1be33c..31fca66 100644
> --- a/xen/include/asm-arm/gic_v3_its.h
> +++ b/xen/include/asm-arm/gic_v3_its.h
> @@ -139,6 +139,10 @@ void gicv3_its_dt_init(const struct dt_device_node *node);
>   #ifdef CONFIG_ACPI
>   void gicv3_its_acpi_init(void);
>   #endif
> +
> +/* Deny iomem access for its */
> +int gicv3_its_deny_access(const struct domain *d);
> +
>   bool gicv3_its_host_has_its(void);
>   
>   unsigned int vgic_v3_its_count(const struct domain *d);
> @@ -206,6 +210,11 @@ static inline void gicv3_its_acpi_init(void)
>   }
>   #endif
>   
> +static inline int gicv3_its_deny_access(const struct domain *d)
> +{
> +    return 0;
> +}
> +
>   static inline bool gicv3_its_host_has_its(void)
>   {
>       return false;
> 

Cheers,

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-10-10 10:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10  6:16 [PATCH v5 0/5] ARM: ACPI: ITS: Add ITS Support for ACPI hardware domain mjaggi
2017-10-10  6:16 ` [PATCH v5 1/5] ARM: ITS: Introduce common function add_to_host_its_list mjaggi
2017-10-10  6:16 ` [PATCH v5 2/5] ARM: ITS: Populate host_its_list from ACPI MADT Table mjaggi
2017-10-10 10:04   ` Julien Grall
2017-10-10  6:16 ` [PATCH v5 3/5] ARM: ITS: Deny hardware domain access to ITS mjaggi
2017-10-10 10:11   ` Julien Grall [this message]
2017-10-10  6:16 ` [PATCH v5 4/5] ARM: Update Formula to compute MADT size using new callbacks in gic_hw_operations mjaggi
2017-10-10  9:10   ` Andre Przywara
2017-10-10 10:14   ` Julien Grall
2017-10-10 10:33     ` Manish Jaggi
2017-10-10 10:42       ` Julien Grall
2017-10-10  6:16 ` [PATCH v5 5/5] ARM: ITS: Expose ITS in the MADT table mjaggi
2017-10-10 10:17   ` Julien Grall

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=71d14bac-fa7b-0f1c-3bf3-f0e29159f2bf@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Andre.Przywara@arm.com \
    --cc=julien.grall@arm.com \
    --cc=mjaggi@cavium.com \
    --cc=mjaggi@caviumnetworks.com \
    --cc=sstabellini@kernel.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 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).