From: laurent.pinchart@ideasonboard.com (Laurent Pinchart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] iommu/io-pgtable: Rationalise quirk handling
Date: Fri, 12 Feb 2016 19:24:06 +0200 [thread overview]
Message-ID: <27989114.h36RDrXrhS@avalon> (raw)
In-Reply-To: <62860b753f304beef7b4b6f1e13d7094252f2f37.1455294748.git.robin.murphy@arm.com>
Hi Robin,
Thank you for the patch.
On Friday 12 February 2016 17:09:46 Robin Murphy wrote:
> As the number of io-pgtable implementations grows beyond 1, it's time
> to rationalise the quirks mechanism before things have a chance to
> start getting really ugly and out-of-hand.
>
> To that end:
> - Indicate exactly which quirks each format can/does support.
> - Fail creating a table if a caller wants unsupported quirks.
> - Properly document where each quirk applies and why.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>
> Just to allay any confusion, I intend this as a followup to the
> short-descriptor[1] and Mediatek IOMMU[2] patches, rather than a
> crucial addition, so it can either get picked up along with those
> or wait 'til later.
>
> v2:
> - Use unsigned long for the bitmap.
> - Do format-specific checks inline.
> - Enough of a difference that I don't feel comfortable putting
> Laurent's reviewed-by from v1 on it...
Here it is again.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> [1]:http://thread.gmane.org/gmane.linux.kernel.iommu/12007
> [2]:http://thread.gmane.org/gmane.linux.kernel.iommu/11974
>
> drivers/iommu/io-pgtable-arm-v7s.c | 5 +++++
> drivers/iommu/io-pgtable-arm.c | 13 +++++++++++--
> drivers/iommu/io-pgtable.h | 22 ++++++++++++++++++----
> 3 files changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/io-pgtable-arm-v7s.c
> b/drivers/iommu/io-pgtable-arm-v7s.c index d39a021..9fcceb1 100644
> --- a/drivers/iommu/io-pgtable-arm-v7s.c
> +++ b/drivers/iommu/io-pgtable-arm-v7s.c
> @@ -623,6 +623,11 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct
> io_pgtable_cfg *cfg, if (cfg->ias > ARM_V7S_ADDR_BITS || cfg->oas >
> ARM_V7S_ADDR_BITS) return NULL;
>
> + if (cfg->quirks & ~(IO_PGTABLE_QUIRK_ARM_NS |
> + IO_PGTABLE_QUIRK_NO_PERMS |
> + IO_PGTABLE_QUIRK_TLBI_ON_MAP))
> + return NULL;
> +
> data = kmalloc(sizeof(*data), GFP_KERNEL);
> if (!data)
> return NULL;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 4095af2..debdf04 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -658,8 +658,12 @@ static struct io_pgtable *
> arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie)
> {
> u64 reg;
> - struct arm_lpae_io_pgtable *data = arm_lpae_alloc_pgtable(cfg);
> + struct arm_lpae_io_pgtable *data;
>
> + if (cfg->quirks & ~IO_PGTABLE_QUIRK_ARM_NS)
> + return NULL;
> +
> + data = arm_lpae_alloc_pgtable(cfg);
> if (!data)
> return NULL;
>
> @@ -742,8 +746,13 @@ static struct io_pgtable *
> arm_64_lpae_alloc_pgtable_s2(struct io_pgtable_cfg *cfg, void *cookie)
> {
> u64 reg, sl;
> - struct arm_lpae_io_pgtable *data = arm_lpae_alloc_pgtable(cfg);
> + struct arm_lpae_io_pgtable *data;
>
> + /* The NS quirk doesn't apply at stage 2 */
> + if (cfg->quirks)
> + return NULL;
> +
> + data = arm_lpae_alloc_pgtable(cfg);
> if (!data)
> return NULL;
>
> diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h
> index 4faee7d..d4f5027 100644
> --- a/drivers/iommu/io-pgtable.h
> +++ b/drivers/iommu/io-pgtable.h
> @@ -47,10 +47,24 @@ struct iommu_gather_ops {
> * page table walker.
> */
> struct io_pgtable_cfg {
> - #define IO_PGTABLE_QUIRK_ARM_NS BIT(0) /* Set NS bit in PTEs */
> - #define IO_PGTABLE_QUIRK_NO_PERMS BIT(1) /* No AP/XN bits */
> - #define IO_PGTABLE_QUIRK_TLBI_ON_MAP BIT(2) /* TLB Inv. on map */
> - int quirks;
> + /*
> + * IO_PGTABLE_QUIRK_ARM_NS: (ARM formats) Set NS and NSTABLE bits in
> + * stage 1 PTEs, for hardware which insists on validating them
> + * even in non-secure state where they should normally be ignored.
> + *
> + * IO_PGTABLE_QUIRK_NO_PERMS: Ignore the IOMMU_READ, IOMMU_WRITE and
> + * IOMMU_NOEXEC flags and map everything with full access, for
> + * hardware which does not implement the permissions of a given
> + * format, and/or requires some format-specific default value.
> + *
> + * IO_PGTABLE_QUIRK_TLBI_ON_MAP: If the format forbids caching invalid
> + * (unmapped) entries but the hardware might do so anyway, perform
> + * TLB maintenance when mapping as well as when unmapping.
> + */
> + #define IO_PGTABLE_QUIRK_ARM_NS BIT(0)
> + #define IO_PGTABLE_QUIRK_NO_PERMS BIT(1)
> + #define IO_PGTABLE_QUIRK_TLBI_ON_MAP BIT(2)
> + unsigned long quirks;
> unsigned long pgsize_bitmap;
> unsigned int ias;
> unsigned int oas;
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2016-02-12 17:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 17:13 [PATCH v3 0/3] io-pgtable ARM short descriptor format Robin Murphy
2016-01-26 17:13 ` [PATCH v3 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support Robin Murphy
2016-01-27 1:16 ` Yong Wu
2016-01-28 13:41 ` Robin Murphy
2016-02-17 14:31 ` Will Deacon
2016-02-17 14:34 ` Robin Murphy
2016-02-10 15:48 ` Will Deacon
2016-02-11 16:13 ` [PATCH 4/3] iommu/io-pgtable: Rationalise quirk handling Robin Murphy
2016-02-11 20:39 ` Laurent Pinchart
2016-02-12 12:08 ` Will Deacon
2016-02-12 12:32 ` Laurent Pinchart
2016-02-12 15:23 ` Robin Murphy
2016-02-12 15:55 ` Will Deacon
2016-03-01 12:01 ` [PATCH v3 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support Geert Uytterhoeven
2016-03-01 13:13 ` Laurent Pinchart
2016-03-01 13:51 ` Robin Murphy
2016-01-26 17:13 ` [PATCH v3 2/3] iommu/io-pgtable: Add helper functions for TLB ops Robin Murphy
2016-01-26 17:13 ` [PATCH v3 3/3] iommu/io-pgtable: Avoid redundant TLB syncs Robin Murphy
2016-02-10 14:21 ` Will Deacon
2016-02-12 17:09 ` [PATCH v2] iommu/io-pgtable: Rationalise quirk handling Robin Murphy
2016-02-12 17:24 ` Laurent Pinchart [this message]
2016-02-12 17:25 ` Robin Murphy
2016-02-12 17:27 ` Will Deacon
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=27989114.h36RDrXrhS@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.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).