xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Oleksandr Tyshchenko <olekstysh@gmail.com>,
	xen-devel@lists.xenproject.org
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	sstabellini@kernel.org, Volodymyr_Babchuk@epam.com
Subject: Re: [Xen-devel] [RFC PATCH V3] xen/arm: Restrict "p2m_ipa_bits" according to the IOMMU requirements
Date: Tue, 24 Sep 2019 10:36:16 +0100	[thread overview]
Message-ID: <f328bc9a-8466-c87e-a00c-223172823ac3@arm.com> (raw)
In-Reply-To: <1568224770-25402-1-git-send-email-olekstysh@gmail.com>

Hi,

On 11/09/2019 18:59, Oleksandr Tyshchenko wrote:
> ---
>   xen/arch/arm/p2m.c                       | 41 ++++++++++++++++++++++++++++----
>   xen/arch/arm/setup.c                     |  9 +++++--
>   xen/drivers/passthrough/arm/ipmmu-vmsa.c | 18 ++------------
>   xen/drivers/passthrough/arm/smmu.c       | 11 +++------
>   xen/include/asm-arm/p2m.h                |  9 +++++++
>   5 files changed, 58 insertions(+), 30 deletions(-)
> 
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 2374e92..d5e2539 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -34,7 +34,11 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
>   
>   #define P2M_ROOT_PAGES    (1<<P2M_ROOT_ORDER)
>   
> -unsigned int __read_mostly p2m_ipa_bits;
> +/*
> + * Set larger than any possible value, so the number of IPA bits can be
> + * restricted by external entity (e.g. IOMMU).
> + */
> +unsigned int __read_mostly p2m_ipa_bits = 64;
>   
>   /* Helpers to lookup the properties of each level */
>   static const paddr_t level_masks[] =
> @@ -1912,6 +1916,16 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
>       return page;
>   }
>   
> +void __init p2m_restrict_ipa_bits(unsigned int ipa_bits)
> +{
> +    /*
> +     * Calculate the minimum of the maximum IPA bits that any external entity
> +     * can support.
> +     */
> +    if ( ipa_bits < p2m_ipa_bits )
> +        p2m_ipa_bits = ipa_bits;
> +}
> +
>   /* VTCR value to be configured by all CPUs. Set only once by the boot CPU */
>   static uint32_t __read_mostly vtcr;
>   
> @@ -1966,15 +1980,24 @@ void __init setup_virt_paging(void)
>           [7] = { 0 }  /* Invalid */
>       };
>   
> -    unsigned int cpu;
> +    unsigned int i, cpu;
>       unsigned int pa_range = 0x10; /* Larger than any possible value */
>       bool vmid_8_bit = false;
>   
> +    if ( p2m_ipa_bits < 40 )
> +        panic("P2M IPA size must be at least 40-bit (p2m_ipa_bits=%u)\n",
> +              p2m_ipa_bits);

Isn't this check meant to be for Arm32? If so, this path is not called by arm32. 
See the #ifdef CONFIG_ARM_32 above.

Also, I would suggest to reword the message to:

"P2M: Not able to support %⁻bit IPA at the moment.\n"

The rest of the code looks good to me.

Cheers,

-- 
Julien Grall

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

  reply	other threads:[~2019-09-24 11:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 17:59 [Xen-devel] [RFC PATCH V3] xen/arm: Restrict "p2m_ipa_bits" according to the IOMMU requirements Oleksandr Tyshchenko
2019-09-24  9:36 ` Julien Grall [this message]
2019-09-24  9:55   ` Oleksandr
2019-09-24  9:56     ` 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=f328bc9a-8466-c87e-a00c-223172823ac3@arm.com \
    --to=julien.grall@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=olekstysh@gmail.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).