All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Cc: vtolkm@googlemail.com, Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] mm/highmem: Take kmap_high_get() properly into account
Date: Thu, 12 Nov 2020 12:38:50 +0100	[thread overview]
Message-ID: <94783ef1-7b1c-d657-d7ee-cd6a91504efc@samsung.com> (raw)
In-Reply-To: <87y2j6n8mj.fsf@nanos.tec.linutronix.de>

Hi Thomas,

On 12.11.2020 11:59, Thomas Gleixner wrote:
> kunmap_local() warns when the virtual address to unmap is below
> PAGE_OFFSET. This is correct except for the case that the mapping was
> obtained via kmap_high_get() because the PKMAP addresses are right below
> PAGE_OFFSET.
>
> Cure it by skipping the WARN_ON() when the unmap was handled by
> kunmap_high().
>
> Fixes: 298fa1ad5571 ("highmem: Provide generic variant of kmap_atomic*")
> Reported-by: vtolkm@googlemail.com
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

This fixes the issue I've reported here: 
https://lore.kernel.org/dri-devel/c07bae0c-68dd-2693-948f-00e8a50f3053@samsung.com/ 
Thanks!

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   mm/highmem.c |   19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
>
> --- a/mm/highmem.c
> +++ b/mm/highmem.c
> @@ -426,12 +426,15 @@ static inline void *arch_kmap_local_high
>   #endif
>   
>   /* Unmap a local mapping which was obtained by kmap_high_get() */
> -static inline void kmap_high_unmap_local(unsigned long vaddr)
> +static inline bool kmap_high_unmap_local(unsigned long vaddr)
>   {
>   #ifdef ARCH_NEEDS_KMAP_HIGH_GET
> -	if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP))
> +	if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
>   		kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
> +		return true;
> +	}
>   #endif
> +	return false;
>   }
>   
>   static inline int kmap_local_calc_idx(int idx)
> @@ -491,10 +494,14 @@ void kunmap_local_indexed(void *vaddr)
>   
>   	if (addr < __fix_to_virt(FIX_KMAP_END) ||
>   	    addr > __fix_to_virt(FIX_KMAP_BEGIN)) {
> -		WARN_ON_ONCE(addr < PAGE_OFFSET);
> -
> -		/* Handle mappings which were obtained by kmap_high_get() */
> -		kmap_high_unmap_local(addr);
> +		/*
> +		 * Handle mappings which were obtained by kmap_high_get()
> +		 * first as the virtual address of such mappings is below
> +		 * PAGE_OFFSET. Warn for all other addresses which are in
> +		 * the user space part of the virtual address space.
> +		 */
> +		if (!kmap_high_unmap_local(addr))
> +			WARN_ON_ONCE(addr < PAGE_OFFSET);
>   		return;
>   	}
>   
>
>
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


  parent reply	other threads:[~2020-11-12 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 10:59 [PATCH] mm/highmem: Take kmap_high_get() properly into account Thomas Gleixner
2020-11-12 10:59 ` Thomas Gleixner
     [not found] ` <CGME20201112113851eucas1p296c130142450daf91d5903362db53daa@eucas1p2.samsung.com>
2020-11-12 11:38   ` Marek Szyprowski [this message]
2020-11-12 13:48 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner

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=94783ef1-7b1c-d657-d7ee-cd6a91504efc@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vtolkm@googlemail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.