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: <404173f2-62ff-7953-2ce1-20ac9fde2aed@amd.com>
Date:   Thu, 4 Mar 2021 18:42:13 +0100
From:   Christian König <christian.koenig@....com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     Huang Rui <ray.huang@....com>, David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org,
        VMware Graphics <linux-graphics-maintainer@...are.com>,
        Roland Scheidegger <sroland@...are.com>,
        Zack Rusin <zackr@...are.com>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        Gerd Hoffmann <kraxel@...hat.com>,
        virtualization@...ts.linux-foundation.org,
        spice-devel@...ts.freedesktop.org, Ben Skeggs <bskeggs@...hat.com>,
        nouveau@...ts.freedesktop.org,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        Chris Wilson <chris@...is-wilson.co.uk>,
        intel-gfx@...ts.freedesktop.org
Subject: Re: [patch 1/7] drm/ttm: Replace kmap_atomic() usage



Am 03.03.21 um 14:20 schrieb Thomas Gleixner:
> From: Thomas Gleixner <tglx@...utronix.de>
>
> There is no reason to disable pagefaults and preemption as a side effect of
> kmap_atomic_prot().
>
> Use kmap_local_page_prot() instead and document the reasoning for the
> mapping usage with the given pgprot.
>
> Remove the NULL pointer check for the map. These functions return a valid
> address for valid pages and the return was bogus anyway as it would have
> left preemption and pagefaults disabled.
>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> Cc: Christian Koenig <christian.koenig@....com>
> Cc: Huang Rui <ray.huang@....com>
> Cc: David Airlie <airlied@...ux.ie>
> Cc: Daniel Vetter <daniel@...ll.ch>
> Cc: dri-devel@...ts.freedesktop.org
> ---
>   drivers/gpu/drm/ttm/ttm_bo_util.c |   20 ++++++++++++--------
>   1 file changed, 12 insertions(+), 8 deletions(-)
>
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -181,13 +181,15 @@ static int ttm_copy_io_ttm_page(struct t
>   		return -ENOMEM;
>   
>   	src = (void *)((unsigned long)src + (page << PAGE_SHIFT));
> -	dst = kmap_atomic_prot(d, prot);
> -	if (!dst)
> -		return -ENOMEM;
> +	/*
> +	 * Ensure that a highmem page is mapped with the correct
> +	 * pgprot. For non highmem the mapping is already there.
> +	 */

I find the comment a bit misleading. Maybe write:

/*
  * Locally map highmem pages with the correct pgprot.
  * Normal memory should already have the correct pgprot in the linear 
mapping.
  */

Apart from that looks good to me.

Regards,
Christian.

> +	dst = kmap_local_page_prot(d, prot);
>   
>   	memcpy_fromio(dst, src, PAGE_SIZE);
>   
> -	kunmap_atomic(dst);
> +	kunmap_local(dst);
>   
>   	return 0;
>   }
> @@ -203,13 +205,15 @@ static int ttm_copy_ttm_io_page(struct t
>   		return -ENOMEM;
>   
>   	dst = (void *)((unsigned long)dst + (page << PAGE_SHIFT));
> -	src = kmap_atomic_prot(s, prot);
> -	if (!src)
> -		return -ENOMEM;
> +	/*
> +	 * Ensure that a highmem page is mapped with the correct
> +	 * pgprot. For non highmem the mapping is already there.
> +	 */
> +	src = kmap_local_page_prot(s, prot);
>   
>   	memcpy_toio(dst, src, PAGE_SIZE);
>   
> -	kunmap_atomic(src);
> +	kunmap_local(src);
>   
>   	return 0;
>   }
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ