From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8D30C2D0A3 for ; Thu, 12 Nov 2020 10:59:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37C2A2223C for ; Thu, 12 Nov 2020 10:59:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rnSUJLuo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K9BJVwmA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37C2A2223C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 83DF16B005D; Thu, 12 Nov 2020 05:59:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C74B6B006C; Thu, 12 Nov 2020 05:59:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 668826B006E; Thu, 12 Nov 2020 05:59:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 35D376B005D for ; Thu, 12 Nov 2020 05:59:36 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D8CEF180AD801 for ; Thu, 12 Nov 2020 10:59:35 +0000 (UTC) X-FDA: 77475470310.18.floor87_5a0feba27305 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id BFA0D100ED3DA for ; Thu, 12 Nov 2020 10:59:35 +0000 (UTC) X-HE-Tag: floor87_5a0feba27305 X-Filterd-Recvd-Size: 3571 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Nov 2020 10:59:34 +0000 (UTC) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1605178772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=ZJnfN4cEcmAybNcReCL20ykTWT83n5GELAdx9PmafPs=; b=rnSUJLuoocKyE3IDBUNRdgzKwaVLju/BGPUrfVUlfIbvGPmteIVN5IEnlidHYPxKXUUD0k ONjJyYQOkU2u/zgp7VXQ+wyXOcSzx25hy2j5+lCoVHit4068+msluljQu3b6n7sFHEiHZg Wn2jhZv+QKX+NHCP3YF2WNRpRZYmKDUrhaPjHpEO4rL9LxGE+jwM/fIOsG0nv2LsRUcqq+ TIa61czX8+eWglWPpf7mnnhGWC5pwl+Gn5X7rP8OYHT0UJmNjL9WtRdMwvftw6xRz6CUiD yhqD/Yaf0x520k5WccmvSlO6Uu5hEtIZrdiutzjVKj1wcEQWcP0/K2z0/A7v8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1605178772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=ZJnfN4cEcmAybNcReCL20ykTWT83n5GELAdx9PmafPs=; b=K9BJVwmATy5vvdIAs0scj4+Fy0vmxBSLcSu8W3avSFTXYvMna4xCpd/OUiNC3f+eWZQKf9 Vq7hMMe9o+BSQ9Dw== To: LKML Cc: vtolkm@googlemail.com,Andrew Morton ,linux-mm@kvack.org,Sebastian Andrzej Siewior ,Peter Zijlstra Subject: [PATCH] mm/highmem: Take kmap_high_get() properly into account Date: Thu, 12 Nov 2020 11:59:32 +0100 Message-ID: <87y2j6n8mj.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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; }