All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Roger Pau Monne <roger.pau@citrix.com>, xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	boris.ostrovsky@oracle.com,
	Stefano Stabellini <sstabellini@kernel.org>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v2 3/9] xen/mm: move modify_identity_mmio to global file and drop __init
Date: Mon, 24 Apr 2017 15:42:08 +0100	[thread overview]
Message-ID: <219593bd-e49e-ecee-0bfa-e10d67251e4c@arm.com> (raw)
In-Reply-To: <20170420151743.90889-4-roger.pau@citrix.com>

Hi Roger,

On 20/04/17 16:17, Roger Pau Monne wrote:
> And also allow it to do non-identity mappings by adding a new parameter. This
> function will be needed in other parts apart from PVH Dom0 build.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
>  xen/arch/x86/hvm/dom0_build.c | 22 +---------------------
>  xen/common/memory.c           | 34 ++++++++++++++++++++++++++++++++++
>  xen/include/xen/p2m-common.h  |  4 ++++
>  3 files changed, 39 insertions(+), 21 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
> index ca88c5835e..65f606d33a 100644
> --- a/xen/arch/x86/hvm/dom0_build.c
> +++ b/xen/arch/x86/hvm/dom0_build.c
> @@ -64,27 +64,7 @@ static struct acpi_madt_nmi_source __initdata *nmisrc;
>  static int __init modify_identity_mmio(struct domain *d, unsigned long pfn,
>                                         unsigned long nr_pages, const bool map)
>  {
> -    int rc;
> -
> -    for ( ; ; )
> -    {
> -        rc = (map ? map_mmio_regions : unmap_mmio_regions)
> -             (d, _gfn(pfn), nr_pages, _mfn(pfn));
> -        if ( rc == 0 )
> -            break;
> -        if ( rc < 0 )
> -        {
> -            printk(XENLOG_WARNING
> -                   "Failed to identity %smap [%#lx,%#lx) for d%d: %d\n",
> -                   map ? "" : "un", pfn, pfn + nr_pages, d->domain_id, rc);
> -            break;
> -        }
> -        nr_pages -= rc;
> -        pfn += rc;
> -        process_pending_softirqs();
> -    }
> -
> -    return rc;
> +    return modify_mmio(d, pfn, pfn, nr_pages, map);
>  }
>
>  /* Populate a HVM memory range using the biggest possible order. */
> diff --git a/xen/common/memory.c b/xen/common/memory.c
> index 52879e7438..0d970482cb 100644
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -1438,6 +1438,40 @@ int prepare_ring_for_helper(
>      return 0;
>  }
>
> +int modify_mmio(struct domain *d, unsigned long gfn, unsigned long pfn,

Whilst you introduce this new function, please use mfn_t and gfn_t.

Also s/pfn/mfn/

> +                unsigned long nr_pages, const bool map)
> +{
> +    int rc;
> +
> +    /*
> +     * Make sure this function is only used by the hardware domain, because it
> +     * can take an arbitrary long time, and could DoS the whole system.
> +     */
> +    ASSERT(is_hardware_domain(d));

What would be the plan for guest if we decide to use vpci?

> +
> +    for ( ; ; )
> +    {
> +        rc = (map ? map_mmio_regions : unmap_mmio_regions)

On ARM, map_mmio_regions and unmap_mmio_regions will map the MMIO with 
very strict attribute. I think we would need an extra argument to know 
the wanted memory attribute (maybe p2m_type_t?).

> +             (d, _gfn(gfn), nr_pages, _mfn(pfn));
> +        if ( rc == 0 )
> +            break;
> +        if ( rc < 0 )
> +        {
> +            printk(XENLOG_WARNING

I would probably use XENLOG_G_WARNING.

> +                   "Failed to %smap [%#lx, %#lx) -> [%#lx,%#lx) for d%d: %d\n",
> +                   map ? "" : "un", gfn, gfn + nr_pages, pfn, pfn + nr_pages,
> +                   d->domain_id, rc);
> +            break;
> +        }
> +        nr_pages -= rc;
> +        pfn += rc;
> +        gfn += rc;
> +        process_pending_softirqs();
> +    }
> +
> +    return rc;
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h
> index 8cd5a6b503..1308da44e7 100644
> --- a/xen/include/xen/p2m-common.h
> +++ b/xen/include/xen/p2m-common.h
> @@ -13,4 +13,8 @@ int unmap_mmio_regions(struct domain *d,
>                         unsigned long nr,
>                         mfn_t mfn);
>
> +

Spurious newline.

> +int modify_mmio(struct domain *d, unsigned long gfn, unsigned long pfn,
> +                unsigned long nr_pages, const bool map);
> +
>  #endif /* _XEN_P2M_COMMON_H */
>

Cheers,

-- 
Julien Grall

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

  reply	other threads:[~2017-04-24 14:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 15:17 [PATCH v2 0/9] vpci: PCI config space emulation Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 1/9] xen/vpci: introduce basic handlers to trap accesses to the PCI config space Roger Pau Monne
2017-04-21 16:07   ` Paul Durrant
2017-04-24  9:09     ` Roger Pau Monne
2017-04-24  9:34       ` Paul Durrant
2017-04-24 10:08         ` Roger Pau Monne
2017-04-24 10:19           ` Paul Durrant
2017-04-24 11:02             ` Roger Pau Monne
2017-04-24 11:50               ` Paul Durrant
2017-04-25  8:27                 ` Roger Pau Monne
2017-04-25  8:35                   ` Paul Durrant
2017-04-21 16:23   ` Paul Durrant
2017-04-24  9:42     ` Roger Pau Monne
2017-04-24  9:55       ` Paul Durrant
2017-04-24  9:58       ` Paul Durrant
2017-04-24 10:11         ` Roger Pau Monne
2017-04-24 10:12           ` Paul Durrant
2017-04-20 15:17 ` [PATCH v2 2/9] x86/ecam: add handlers for the PVH Dom0 MMCFG areas Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 3/9] xen/mm: move modify_identity_mmio to global file and drop __init Roger Pau Monne
2017-04-24 14:42   ` Julien Grall [this message]
2017-04-25  8:01     ` Roger Pau Monne
2017-04-25  9:09       ` Julien Grall
2017-04-25  9:25         ` Roger Pau Monne
2017-04-25  9:32           ` Jan Beulich
2017-04-26  8:26             ` Roger Pau Monne
2017-04-26  8:51               ` Jan Beulich
2017-04-27  8:58             ` Roger Pau Monne
2017-04-27  9:08               ` Julien Grall
2017-04-27  9:29               ` Jan Beulich
2017-04-20 15:17 ` [PATCH v2 4/9] xen/pci: split code to size BARs from pci_add_device Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 5/9] xen/vpci: add handlers to map the BARs Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 6/9] xen/vpci: trap access to the list of PCI capabilities Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 7/9] vpci: add a priority field to the vPCI register initializer Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 8/9] vpci/msi: add MSI handlers Roger Pau Monne
2017-04-21  8:38   ` Roger Pau Monne
2017-04-24 15:31   ` Julien Grall
2017-04-25 11:49     ` Roger Pau Monne
2017-04-25 12:00       ` Julien Grall
2017-04-25 13:19         ` Roger Pau Monne
2017-04-20 15:17 ` [PATCH v2 9/9] vpci/msix: add MSI-X handlers Roger Pau Monne

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=219593bd-e49e-ecee-0bfa-e10d67251e4c@arm.com \
    --to=julien.grall@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.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 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.