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] [day] [month] [year] [list]
Message-ID: <00bcebba-4955-cbbd-e7f4-e344f9b932a0@arm.com>
Date:   Tue, 5 Apr 2022 11:18:23 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     Jonathan Marek <jonathan@...ek.ca>, freedreno@...ts.freedesktop.org
Cc:     David Airlie <airlied@...ux.ie>,
        "open list:DRM DRIVER FOR MSM ADRENO GPU" 
        <linux-arm-msm@...r.kernel.org>,
        Jordan Crouse <jordan@...micpenguin.net>, dpiliaiev@...lia.com,
        "open list:DRM DRIVER FOR MSM ADRENO GPU" 
        <dri-devel@...ts.freedesktop.org>,
        Abhinav Kumar <quic_abhinavk@...cinc.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Sean Paul <sean@...rly.run>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/msm: use orig_nents to iterate over scatterlist with
 per-process tables

On 2022-03-28 13:55, Jonathan Marek wrote:
> This matches the implementation of iommu_map_sgtable() used for the
> non-per-process page tables path.
> 
> This works around the dma_map_sgtable() call (used to invalidate cache)
> overwriting sgt->nents with 1 (which is probably a separate issue).

FWIW that's expected behaviour. The sgtable APIs use nents to keep track 
of the number of DMA segments, while orig_nents represents the physical 
segments. IIUC you're not actually using the DMA mapping, just relying 
on its side-effects, so it's still the physical segments that you care 
about for your private IOMMU mapping here.

> Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
> Signed-off-by: Jonathan Marek <jonathan@...ek.ca>
> ---
>   drivers/gpu/drm/msm/msm_iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
> index bcaddbba564df..22935ef26a3a1 100644
> --- a/drivers/gpu/drm/msm/msm_iommu.c
> +++ b/drivers/gpu/drm/msm/msm_iommu.c
> @@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 iova,
>   	u64 addr = iova;
>   	unsigned int i;
>   
> -	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
> +	for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {

Even better would be to use for_each_sgtable_sg(), which exists 
primarily for the sake of avoiding this exact confusion.

Robin.

>   		size_t size = sg->length;
>   		phys_addr_t phys = sg_phys(sg);
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ