lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49bae447-d662-e6cf-7500-ab78e3b75dc4@arm.com>
Date:   Wed, 25 Nov 2020 16:38:35 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Yong Wu <yong.wu@...iatek.com>, Joerg Roedel <joro@...tes.org>,
        Will Deacon <will@...nel.org>
Cc:     Matthias Brugger <matthias.bgg@...il.com>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        Tomasz Figa <tfiga@...gle.com>,
        linux-mediatek@...ts.infradead.org, srv_heupstream@...iatek.com,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        iommu@...ts.linux-foundation.org, youlin.pei@...iatek.com,
        Nicolas Boichat <drinkcat@...omium.org>, anan.sun@...iatek.com,
        chao.hao@...iatek.com, jun.wen@...iatek.com
Subject: Re: [PATCH v2 4/6] iommu: Add granule_ignore when tlb gather

On 2020-11-19 06:18, Yong Wu wrote:
> Add a granule_ignore option when tlb gather for some HW which don't care
> about granule when it flush tlb.
> 
> Signed-off-by: Yong Wu <yong.wu@...iatek.com>
> ---
>   include/linux/iommu.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index 794d4085edd3..1aad32238510 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -171,6 +171,7 @@ enum iommu_dev_features {
>    * @start: IOVA representing the start of the range to be flushed
>    * @end: IOVA representing the end of the range to be flushed (exclusive)
>    * @pgsize: The interval at which to perform the flush
> + * @granule_ignore: For tlb flushing that could be regardless of granule.
>    *
>    * This structure is intended to be updated by multiple calls to the
>    * ->unmap() function in struct iommu_ops before eventually being passed
> @@ -180,6 +181,7 @@ struct iommu_iotlb_gather {
>   	unsigned long		start;
>   	unsigned long		end;
>   	size_t			pgsize;
> +	bool			granule_ignore;

I can't see that this would ever need to vary on a per-unmap-operation 
basis, so this doesn't seem like the right level of abstraction. AFAICS 
it should simply be hard-coded in the driver logic.

>   };
>   
>   /**
> @@ -544,7 +546,7 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,
>   	 * a different granularity, then sync the TLB so that the gather
>   	 * structure can be rewritten.
>   	 */
> -	if (gather->pgsize != size ||
> +	if ((!gather->granule_ignore && gather->pgsize != size) ||

I also think this is a slippery slope in the wrong direction anyway - 
there is likely to be a fair bit of hardware-dependent variation around 
how low-level TLB maintenance works (also consider drivers that may want 
to convert a sufficiently large range to an "invalidate all" operation), 
so if a generic helper function doesn't do the right thing for a given 
driver, that driver should simply not use the helper, and directly 
implement the logic it does need.

Robin.

>   	    end < gather->start || start > gather->end) {
>   		if (gather->pgsize)
>   			iommu_iotlb_sync(domain, gather);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ