From: Julien Grall <julien.grall@linaro.org>
To: Julien Grall <julien.grall@linaro.org>
Cc: ian.campbell@citrix.com, tim@xen.org,
stefano.stabellini@citrix.com, Jan Beulich <jbeulich@suse.com>,
xen-devel@lists.xenproject.org,
Xiantao Zhang <xiantao.zhang@intel.com>
Subject: Re: [PATCH v4 18/21] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk
Date: Mon, 28 Apr 2014 17:34:35 +0100 [thread overview]
Message-ID: <535E831B.1030700@linaro.org> (raw)
In-Reply-To: <1398172475-27873-19-git-send-email-julien.grall@linaro.org>
I forgot to cc Jan and Xiantao on this patch.
On 04/22/2014 02:14 PM, Julien Grall wrote:
> Some IOMMU doesn't suppport coherent PT walk. When the p2m is shared with
> the CPU, Xen has to make sure the PT changes have reached the memory.
>
> Introduce new IOMMU callback that will retrieve the IOMMU feature for a
> specified domain.
>
> On ARM, the platform can contain multiple IOMMUs. Each of them may not
> have the same set of feature. The domain parameter will be used to get the
> set of features for IOMMUs used by this domain.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>
> ---
> Changes in v4:
> - Patch added
> ---
> xen/arch/arm/p2m.c | 24 ++++++++++++++++++------
> xen/drivers/passthrough/iommu.c | 11 +++++++++++
> xen/include/xen/iommu.h | 5 +++++
> 3 files changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 21219de..996d2bd 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -274,6 +274,18 @@ enum p2m_operation {
> CACHEFLUSH,
> };
>
> +static void unmap_coherent_domain_page(struct domain *d, const void *va)
> +{
> + /* Some IOMMU doesn't support coherent PT walk. When the p2m is
> + * shared with the CPU, Xen has to make sure that the PT changes have
> + * reached the memory
> + */
> + if ( need_iommu(d) && !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK) )
> + clean_xen_dcache_va_range(va, PAGE_SIZE);
> +
> + unmap_domain_page(va);
> +}
> +
> static int apply_p2m_changes(struct domain *d,
> enum p2m_operation op,
> paddr_t start_gpaddr,
> @@ -301,7 +313,7 @@ static int apply_p2m_changes(struct domain *d,
> {
> if ( cur_first_page != p2m_first_level_index(addr) )
> {
> - if ( first ) unmap_domain_page(first);
> + if ( first ) unmap_coherent_domain_page(d, first);
> first = p2m_map_first(p2m, addr);
> if ( !first )
> {
> @@ -331,7 +343,7 @@ static int apply_p2m_changes(struct domain *d,
>
> if ( cur_first_offset != first_table_offset(addr) )
> {
> - if (second) unmap_domain_page(second);
> + if (second) unmap_coherent_domain_page(d, second);
> second = map_domain_page(first[first_table_offset(addr)].p2m.base);
> cur_first_offset = first_table_offset(addr);
> }
> @@ -357,7 +369,7 @@ static int apply_p2m_changes(struct domain *d,
> if ( cur_second_offset != second_table_offset(addr) )
> {
> /* map third level */
> - if (third) unmap_domain_page(third);
> + if (third) unmap_coherent_domain_page(d, third);
> third = map_domain_page(second[second_table_offset(addr)].p2m.base);
> cur_second_offset = second_table_offset(addr);
> }
> @@ -480,9 +492,9 @@ static int apply_p2m_changes(struct domain *d,
> rc = 0;
>
> out:
> - if (third) unmap_domain_page(third);
> - if (second) unmap_domain_page(second);
> - if (first) unmap_domain_page(first);
> + if (third) unmap_coherent_domain_page(d, third);
> + if (second) unmap_coherent_domain_page(d, second);
> + if (first) unmap_coherent_domain_page(d, first);
>
> spin_unlock(&p2m->lock);
>
> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> index f93dc79..f24fb46 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -344,6 +344,17 @@ void iommu_crash_shutdown(void)
> iommu_enabled = iommu_intremap = 0;
> }
>
> +bool_t iommu_has_feature(struct domain *d, uint32_t feature)
> +{
> + const struct iommu_ops *ops = domain_hvm_iommu(d)->platform_ops;
> + uint32_t features = 0;
> +
> + if ( iommu_enabled && ops && ops->features )
> + features = ops->features(d);
> +
> + return !!(features & feature);
> +}
> +
> static void iommu_dump_p2m_table(unsigned char key)
> {
> struct domain *d;
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index e119379..9ad909f 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -67,6 +67,10 @@ int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn,
> unsigned int flags);
> int iommu_unmap_page(struct domain *d, unsigned long gfn);
>
> +#define IOMMU_FEAT_COHERENT_WALK (1U<<0)
> +bool_t iommu_has_feature(struct domain *d, uint32_t feature);
> +
> +
> #ifdef HAS_PCI
> void pt_pci_init(void);
>
> @@ -139,6 +143,7 @@ struct iommu_ops {
> void (*iotlb_flush)(struct domain *d, unsigned long gfn, unsigned int page_count);
> void (*iotlb_flush_all)(struct domain *d);
> void (*dump_p2m_table)(struct domain *d);
> + uint32_t (*features)(struct domain *d);
> };
>
> void iommu_suspend(void);
>
--
Julien Grall
next prev parent reply other threads:[~2014-04-28 16:34 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 13:14 [PATCH v4 00/21] IOMMU support for ARM Julien Grall
2014-04-22 13:14 ` [PATCH v4 01/21] xen/arm: map_device: Don't hardcode dom0 in print message Julien Grall
2014-04-28 13:49 ` Ian Campbell
2014-04-22 13:14 ` [PATCH v4 02/21] xen/arm: Constify address pointer for cache helpers Julien Grall
2014-04-28 13:52 ` Ian Campbell
2014-04-22 13:14 ` [PATCH v4 03/21] xen/arm: p2m: Move comment that was misplaced Julien Grall
2014-04-28 13:52 ` Ian Campbell
2014-04-22 13:14 ` [PATCH v4 04/21] xen/arm: p2m: apply_p2m_changes: Only load domain P2M when we flush TLBs Julien Grall
2014-04-28 13:54 ` Ian Campbell
2014-04-28 13:57 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 05/21] xen/common: grant-table: only call IOMMU if paging mode translate is disabled Julien Grall
2014-04-22 13:14 ` [PATCH v4 06/21] xen/passthrough: amd: Remove domain_id from hvm_iommu Julien Grall
2014-04-28 16:38 ` Julien Grall
2014-04-29 7:43 ` Jan Beulich
2014-04-30 4:02 ` Suravee Suthikulpanit
2014-04-30 3:56 ` Suravee Suthikulpanit
2014-04-30 11:32 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 07/21] xen/passthrough: amd: rename iommu_has_feature into amd_iommu_has_feature Julien Grall
2014-04-28 13:56 ` Ian Campbell
2014-04-28 16:38 ` Julien Grall
2014-05-02 13:11 ` Julien Grall
2014-05-02 16:35 ` Aravind Gopalakrishnan
2014-04-22 13:14 ` [PATCH v4 08/21] xen/passthrough: vtd: iommu_set_hwdom_mapping is VTD specific Julien Grall
2014-04-22 13:41 ` Jan Beulich
2014-04-22 14:47 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 09/21] xen/dts: Add dt_property_read_bool Julien Grall
2014-04-22 13:14 ` [PATCH v4 10/21] xen/dts: Add dt_parse_phandle_with_args and dt_parse_phandle Julien Grall
2014-04-22 13:14 ` [PATCH v4 11/21] xen/passthrough: rework hwdom_pvh_reqs to use it also on ARM Julien Grall
2014-04-28 13:57 ` Ian Campbell
2014-04-22 13:14 ` [PATCH v4 12/21] xen/passthrough: iommu: Split generic IOMMU code Julien Grall
2014-04-22 13:48 ` Jan Beulich
2014-04-22 13:52 ` Jan Beulich
2014-04-22 14:58 ` Julien Grall
2014-04-22 16:33 ` Jan Beulich
2014-04-22 16:45 ` Julien Grall
2014-04-22 16:59 ` Jan Beulich
2014-04-22 18:02 ` Julien Grall
2014-04-23 8:43 ` Jan Beulich
2014-04-23 12:42 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 13/21] xen/passthrough: iommu: Introduce arch specific code Julien Grall
2014-04-28 16:39 ` Julien Grall
[not found] ` <CAAAAutDRYoqdSBdDsETqtzVDdXmy6jq1Jnm1ck8c5eTqbkMUFw@mail.gmail.com>
2014-05-05 21:12 ` Fwd: " Aravind Gopalakrishnan
2014-04-22 13:14 ` [PATCH v4 14/21] xen/passthrough: iommu: Basic support of device tree assignment Julien Grall
2014-04-28 14:01 ` Ian Campbell
2014-04-28 14:12 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 15/21] xen/passthrough: Introduce IOMMU ARM architecture Julien Grall
2014-04-28 14:04 ` Ian Campbell
2014-04-28 14:21 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 16/21] MAINTAINERS: Add drivers/passthrough/arm Julien Grall
2014-04-22 13:50 ` Jan Beulich
2014-04-22 15:02 ` Julien Grall
2014-04-22 16:35 ` Jan Beulich
2014-04-22 18:02 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 17/21] xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled Julien Grall
2014-04-22 13:14 ` [PATCH v4 18/21] xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk Julien Grall
2014-04-28 14:09 ` Ian Campbell
2014-04-28 14:46 ` Julien Grall
2014-04-28 16:34 ` Julien Grall [this message]
2014-04-29 7:40 ` Jan Beulich
2014-05-02 15:15 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 19/21] xen/arm: grant: Add another entry to map MFN 1:1 in dom0 p2m Julien Grall
2014-04-28 14:11 ` Ian Campbell
2014-04-28 14:47 ` Julien Grall
2014-04-22 13:14 ` [PATCH v4 20/21] drivers/passthrough: arm: Add support for SMMU drivers Julien Grall
2014-04-28 14:13 ` Ian Campbell
2014-04-22 13:14 ` [PATCH v4 21/21] xen/arm: Add the property "protected-devices" in the hypervisor node Julien Grall
2014-05-02 12:54 ` [PATCH v4 00/21] IOMMU support for ARM Ian Campbell
2014-05-02 13:09 ` Julien Grall
2014-05-02 13:15 ` Julien Grall
2014-05-02 13:25 ` Ian Campbell
2014-05-02 13:29 ` Julien Grall
2014-05-02 14: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=535E831B.1030700@linaro.org \
--to=julien.grall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xiantao.zhang@intel.com \
/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).