From patchwork Thu Nov 12 10:59:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11899681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21455697 for ; Thu, 12 Nov 2020 10:59:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE5652222F 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 BE5652222F 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7C74B6B006C; Thu, 12 Nov 2020 05:59:36 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,f224d0710c497513,d41d8cd98f00b204,tglx@linutronix.de,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1534:1541:1711:1730:1747:1777:1792:1981:2194:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:3872:3874:4250:5007:6261:6653:7903:9592:10004:10400:11026:11232:11473:11658:11914:12043:12160:12295:12296:12297:12438:12679:13069:13221:13229:13311:13357:13846:14096:14097:14181:14394:14721:21080:21433:21451:21627:21660:21795:21990:30001:30003:30051:30054,0,RBL:193.142.43.55:@linutronix.de:.lbl8.mailshell.net-62.2.6.100 64.100.201.201;04yfa9npuwxer1sn95876493g9tafopmadm1gwkx397n1a43yjn4rqbwiauxhw8.1ua5i14mwri8fkoa5ips7o9cbu7gkwxqaj8qzttrwkshqamwo1ktdrgwbjqij6r.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:123,LUA_SUMMARY:none 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 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 Tested-by: Marek Szyprowski --- 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; }