From patchwork Thu Jun 8 19:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E62FC7EE23 for ; Thu, 8 Jun 2023 19:11:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F295A8E0003; Thu, 8 Jun 2023 15:11:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFFDE8E0001; Thu, 8 Jun 2023 15:11:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC8DA8E0003; Thu, 8 Jun 2023 15:11:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CD75C8E0001 for ; Thu, 8 Jun 2023 15:11:05 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A10F516045F for ; Thu, 8 Jun 2023 19:11:05 +0000 (UTC) X-FDA: 80880523290.25.9FB3FA1 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by imf14.hostedemail.com (Postfix) with ESMTP id 9FA0D100019 for ; Thu, 8 Jun 2023 19:11:03 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=zI2n2c7O; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.210.53 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251463; a=rsa-sha256; cv=none; b=3ZDdUJLSMEPoXGJmVJ8vsE+HFeuFpJhAJ5HSMCL+4k+x7W2Zthd/IK+fE0ZrRlD6zNFSF8 vk+2FlpUiQlOfh7tLjMEgl0Ip7s6sw2UQX7gYO4JZNrPWIftx8SDLyg6yFcuww8ufqRSoN XGxdAA8/kB0UHRCHqFUj0ePdvkJcMPA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=zI2n2c7O; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.210.53 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251463; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=KdsE56mUCj2jf7CAL64Tj6DAWLv23jTglJiOUDtqIjodDJcTe/Sca6zjiygTeflzJ0qU+z m1/6KHhS8w5mmJKs48Q8PmuVG6BVrazW5su1voD4LmR+AdoY2f7/6OhQYtTzA+FEPjjw52 1aPjGvgiHUpxnKllVO3e+ssJ0uaZZt4= Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6af8b25fc72so28243a34.3 for ; Thu, 08 Jun 2023 12:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251462; x=1688843462; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=zI2n2c7OkddkeoVughk/breFog0Z+EugvTVCVE29AxlIwAuw/EXjuVVrGwHMRC2bhf x0zQuSLbArDGG85kKSwsyOqR0pmFFom/E7xSbaqroxyuObbaGosDK+M/+SoF1AtELCEy bwiSK0YoqwXYs8RFX4mr6F5bpRQfVt01fhKCwqENzESWm7Dhrz7vfiQry977lpQgtzrZ wnC//NTYAzqdTpQsJYqSSYM/JJ1rR9aCAEjxg8RoVlpIwLkFMrqySi29YtVXSpE8PojR NAOs9BLAS5JJ+VzpPEvMOGrhcKbJ9tQKHA0AjGKdBMYv+rB/+u255TZMPygFcoEpIAK5 9xvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251462; x=1688843462; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=EBAbGjZsFb4Y9nCegkJ7moFo7qlpNgr+vst9Ru4h8AnGGxBG9XwNsJMiPgDA5jgxlG jOynwfYmoKUWkqkBdavGHZ6T91pRXwAg8iRc6d1dYyqecEfcvSJliD3Nx6RsG5DnqMVO sPpaPp+o1iE7w5lAevMTd1XozG/siUei7jHgis+yQlfIcOppoI0rOrb4yh8z8YjJSJRr ZgTFziDgzu2eGkyhKlYuU834c0rP3fCLF+mXi1dNdTHBEpNgfdjWVVVXVZboFTHY3Vsy v4hOHA70luYML82s40W1qgd79gJzze93Kw45liICrD+XiOkL52zU6XkW+++hzvT4eaOg F4rg== X-Gm-Message-State: AC+VfDwvGvFYhwDd1bzJwIJoAGSTmJkCeMMdWeCzIrSFH8M1FeLUv24M +N4uYCAsZspbGXcEwIHJHJNlFg== X-Google-Smtp-Source: ACHHUZ5JMT1Kov7YopWmoAdbj6VCmy1YpW57EN24ghxD3DbymGPoxfTUoK+9WA1xlwUdsIzRTkW8Cg== X-Received: by 2002:a05:6359:38f:b0:128:7ef8:805f with SMTP id eg15-20020a056359038f00b001287ef8805fmr5080226rwb.6.1686251462249; Thu, 08 Jun 2023 12:11:02 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a17-20020a81bb51000000b00545a08184fdsm87881ywl.141.2023.06.08.12.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:11:01 -0700 (PDT) Date: Thu, 8 Jun 2023 12:10:57 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 01/23] arm: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <813429a1-204a-1844-eeae-7fd72826c28@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9FA0D100019 X-Stat-Signature: 4p6ekrig3fn98zedqiy38on4pkygnejm X-Rspam-User: X-HE-Tag: 1686251463-422904 X-HE-Meta: U2FsdGVkX18D2DS2XaIgNdqKsuqm3isUuHncYp95jD1+Yuy3cKRJnmiGq04DaYaALcU289bXCjapgGn60p5lo8WCtwBBdp3EC2URKcVeZGVnDpfQtX6ZeE7Ipn7uXQQL+GMdRJBTC4wU+094uLbFTAAjqNfzUuzIDhAx8sRPDSleHVqB7S4PHbHIEEr7sET/kbGHnnY9/pd3D95yOQJgqD8xtZ0+2u2fXEWvOU2Qx/1yAjnlL0otKwdDRw7sB370jvDEpde0DvIu0wJTPdcZxlOZLj+iTR1ekce5qOAZOGcwx6yN32ZlKYBOTchQNreuMwPpPIhYBr5dI4OVV7Hcu4I5VOkHODsRQNRRxjXN7u1trxcanw57dvuPwFeb9XzUGD4a0BsxgjA2y8z9+qNkoIL6FoWTPQqrgShjBtGHW0KRHgKDcbDcFCun47iutyuqIl+a2IZ5T/oARBfCzaGuQQ0nFSvX9XKnljHH3LI7a+duSA8ZNCukmQ10eK/NeXaLgf2oUsgRFWwLOsmdbRQ0Q+qNFWme3pdlmXFMGDOqnrVLGAfD8ZZ7lnQqqiR6YlcN/4N7e1r7LWs2dgpwLOr8/BZx7KqXOM5/s4T1V8j+qiuWFPenLmKgmkoJflJ1SL06vy9h5/zf2iZuG2SH5454JHzWbYDzOqNq1STpUxvTxUg2ua6bVtKUKNoHcuKp4e2HNGHZEibXsh91EllZUsTZpJiwYd2gesB1xoIFJM2M6DYdqvCo4bzGpNUEN4SYRLMEAZBugbX1T1aZ31OMcn9jwCyIH8E55CZhh+KtoVzqQkhisCZn8tQEc4Q7gSpi2hzs+qFTUnMiiz38mX8+pGsKUcdWPod+LpoYle33TDMWtVXHrmf5KE1qDiA6fNBdVfEn/O/meRZWzHctDyWziRNAH36RwKl/4BFg6FzoCkBbL2GX7aOg88EK32pWE3MsFmrhItiWIJP/Iydr+4glrXd 9kYu4uLA uY+pHdoml+6jfsTNexHMSJLwD+d5E72XQh83uhFrz61XyNfRhBkg6+r0yWGQ89DIy2+RhalGdj4q1ISwml9RMYdOKFfxzNC3IoGkS4c9DaVFk/Ks7XF6I0qv5z7TPu1qdcYjbBsAqRqtZKwwliLUoH0Oz1ROEcjbJXVVaXMxrstx0TL3gffJS8pRsGRHlsnTYlRcrvysgRypzjZEKU1YIZxZxAgNPeCFUEUZS23k3Lh3icQ960T8xIZQ7vVEAWa7er4TAcnjBuifOqNnJKCfxbOGf3HxAUAFlnz4ved3vzI1SQBDWkK1WuohaSaQ1xrG2irnVHq36IplxP76ENRN6F+MPQw== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/arm/lib/uaccess_with_memcpy.c | 3 +++ arch/arm/mm/fault-armv.c | 5 ++++- arch/arm/mm/fault.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c index e4c2677cc1e9..2f6163f05e93 100644 --- a/arch/arm/lib/uaccess_with_memcpy.c +++ b/arch/arm/lib/uaccess_with_memcpy.c @@ -74,6 +74,9 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp) return 0; pte = pte_offset_map_lock(current->mm, pmd, addr, &ptl); + if (unlikely(!pte)) + return 0; + if (unlikely(!pte_present(*pte) || !pte_young(*pte) || !pte_write(*pte) || !pte_dirty(*pte))) { pte_unmap_unlock(pte, ptl); diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c index 0e49154454a6..ca5302b0b7ee 100644 --- a/arch/arm/mm/fault-armv.c +++ b/arch/arm/mm/fault-armv.c @@ -117,8 +117,11 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address, * must use the nested version. This also means we need to * open-code the spin-locking. */ - ptl = pte_lockptr(vma->vm_mm, pmd); pte = pte_offset_map(pmd, address); + if (!pte) + return 0; + + ptl = pte_lockptr(vma->vm_mm, pmd); do_pte_lock(ptl); ret = do_adjust_pte(vma, address, pfn, pte); diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 2418f1efabd8..83598649a094 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -85,6 +85,9 @@ void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr) break; pte = pte_offset_map(pmd, addr); + if (!pte) + break; + pr_cont(", *pte=%08llx", (long long)pte_val(*pte)); #ifndef CONFIG_ARM_LPAE pr_cont(", *ppte=%08llx", From patchwork Thu Jun 8 19:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAC0FC7EE29 for ; Thu, 8 Jun 2023 19:12:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7117B8E0002; Thu, 8 Jun 2023 15:12:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C1E28E0001; Thu, 8 Jun 2023 15:12:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 562F28E0002; Thu, 8 Jun 2023 15:12:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 455C68E0001 for ; Thu, 8 Jun 2023 15:12:07 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1B4EAA0369 for ; Thu, 8 Jun 2023 19:12:07 +0000 (UTC) X-FDA: 80880525894.21.6FE03CB Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by imf19.hostedemail.com (Postfix) with ESMTP id 072401A000B for ; Thu, 8 Jun 2023 19:12:04 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=1l3g323z; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251525; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=zpRraqBzK0zn9aZ2cGKUgLNRgFI142AdRlYq3u51FrZKStoKSSTxoD3QIOzTMBPUDf9u/P tk9huIXbaG/cdJPFsZoQk/56YchzhhWAfvYc6t3JfNf6J1jSQ6emVs74TB7oM+vf1dJ8pe Xpw8Xnn/TtXlCd5l44T9a/LI+hS65wA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=1l3g323z; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251525; a=rsa-sha256; cv=none; b=MaJxnItVp5TGE8EiR7cPvmx2P2nvozUEL9U9JuEqUQNxMJ4U4RmVJN825TQDZQNNaYNmp7 0lHzeumfyVJ1xQ+bdY7IeayzNIUywpQSH5voqGOi3bYfbAaUhNKr/iG9x77d6OVCFNKRU5 L5mhc7QeurNQptDo31jxr3ZumazpFeY= Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-565de553de1so14703607b3.0 for ; Thu, 08 Jun 2023 12:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251524; x=1688843524; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=1l3g323zHExDgYGww0zFXmVgic3jDwyc0JAOaU14MB4NUoruSezWtFEVocvA8VR+wP D+bOPBhVpeN5TR7Q94HiD/7UXFwgvkn75HwqVtdM3hi/WhalPJUwiHRXSp3bpeKIuRdm orIqBvL0rae06pUEOxuRX8a0MpgqpKjI5TTzLJ98WQmBBEIDz4RhToD7qotfuISdygmL gKqyyQ61v8JQcZhpfriPzCyTWiXBbfQnLuFCKxtspZkjhV60I7fgSoyr0iHs2+KGMqLW csaRWwWg7YMEgY5GV8POPk7y+6y3olAQXOM6liWFfJYYRJ0sFo+4jM2u98tnCjYnFP0Y 93kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251524; x=1688843524; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=FFUCpCm57ez+hoeyN64a9RESve4jmUh4nAC1c8cpDWphXUpcUZxu4o1EjxE7xvUK2M s0CpWIU5g86sqih4Bs9SrSH98GDaAmKQ5Bszs612BOQRmHXJ3T9p1MWjH+dfo0jo5sag aiaK4R9c5zbvMOP0ali4WzLCI8girs907k+6B0Tu13O26LX2J/okQcVPzsS1HDc43uwb tAoOX+Xx/M+TtrlhVJTWyzmg0n8ohoAhlBEbUuEtG8ArgQmEahW4cObGQRE1fWCGQRz9 UFOABV29bypw1smfTX46cKQe5dlMKp545tmE4fTIaD+DrMpuoXl76qX6n9tS7uGnUWta ga4A== X-Gm-Message-State: AC+VfDzK3ElXnKbxebiac9cagVoe+w5YhRvQTzvBMF+pwIhwW0o/qkj7 h8+Ur5ZYUa4a8QYo7iO4Wj3nbQ== X-Google-Smtp-Source: ACHHUZ6kOJKeygbedx9f6pcNR03LNZvYC4ZecjCRxiqOz1IuKMf5mVIHIRdEhOcWlcOzm+o3M8bu5Q== X-Received: by 2002:a0d:ead2:0:b0:569:ec03:14eb with SMTP id t201-20020a0dead2000000b00569ec0314ebmr668029ywe.23.1686251523870; Thu, 08 Jun 2023 12:12:03 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d144-20020a814f96000000b00559f1cb8444sm106718ywb.70.2023.06.08.12.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:12:03 -0700 (PDT) Date: Thu, 8 Jun 2023 12:11:59 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 02/23] arm64: allow pte_offset_map() to fail In-Reply-To: Message-ID: <35e46485-8499-4337-c51f-b8fa495a1a93@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 072401A000B X-Rspam-User: X-Stat-Signature: 381qm9wkpkxuzdbssetpbgd1p599s4eg X-Rspamd-Server: rspam01 X-HE-Tag: 1686251524-703752 X-HE-Meta: U2FsdGVkX19Yqt6uf127UPX11OE9nuD+PLeGBSnIZkIvT9XyVew+WoWhXh9q/7PCrRbYhVpko/TR/EjY62mOUKIxdXU/nF7F3saja5RbXZn6WF6epKx9lopXLG1grKM4cVmy589sdG8/tavKfhSjwUq+mmzS3tBZmwIrgPCpZPfumsIVnzQ0aQBLSlphaL+H+bu8Dhvqu3/GK/cB8FGC8cI4Z/z2qxjSadowPrBboEG3/sjkEWiYqAijatWmCQlz4+U1yccHi6uQO3YGXApexotk9zroNlsV1iPnxqlL1Sei8u7/WJbTtrfKHitO5J6kQusWfmpReGiznkWKOcMlY+nNTEpO844B1VA/CTcv7N4iW6miYujOSJUUgvC7lx0k8gBwG5uVvWN1vfcwsOUuXz4oA+3AO213c+lRnOvF/w9GjrgTi6glOmLOgeqf20fkvPGvgm6pOyUvJ2Wwa9cnp+iycdMR0kuUX23QRR339VnfJBsSE41lI7DhUA7XuBXkE+B6m3FxScLRK6ySvQgbvxyyKK/OI+Nzj1N6XHl/aCI1npJ/8wPbx8O9GSZ8ghe6+2Wy+ZGN65wVLbkUo8echs/5SWRxW/ItH6wNjXJU6G8GpZ49Sa0RHZApHH2Cndutv4OtfWVjGu3Jcs+N1ArpFQvf7PdSUzstqttXFRF+MsBztBhL2YTfjHW/3FBYp2ANdJC9QZV4l3FVZk9D8TtUZ0aOeIksFPaDnqga/6sYF4Co44o0a6J3/MbDrWuqT/XGIgiws6w4RdglHD6FX+mxBBTOoH4yQZuK7Zx1hw9CSCV3DV89XynFEQ443VOozium0h0Otk540BtmBrWX962/oTFbINt7IWF4krPHRWloBzCCdhuRpMVBHyKL+eB71xDTGOdCUCtLNKH7AmnaSrMjeSZqbgOF+J+MvY+R2Bc+Df4JcpXpqCJsEbt9VnWyJtNC+sn4yx4epJ1eX2xNcRV n4wpp2EA ypLruDfanMF03Ww2zFxcRquE8gQdvItVSF1BHTvh37Bs/od/AEQU7kvqE3rFx4g0OQqheBybd2zhWKzGHSIn+nzTGrPXn8yaz59p3hq9RLHBlEsLV3orgWgnB+hY41hVpbwVxRfCjq3NTPSBmIdaDLKpHaVaJX4CoWz93u7eJgpboUqaZc4zYkM6z86on2rEuMY5cbKlKQ5iO4/Pup3TB1SiY/nMUuXAIbeOH2Ex5mMRi7GnLtyopEk3dYXVTOv5UUbNPNiHgzKiluRrrU612qDnBSOXzyHlx+pspSbPs6epGTwsme9b8z9Q+6vfvQCQB6asjLN3/ERsyYAVlOTZDqBjwvJt8xBsfIJi8qAhe/VEXdggfrWxKQiuQoF6aLUw1iTL8ay25hKYtwGibOrSdYPdEoSuojEqrse8OhjHXXMqREefvVTD7MMZQ+BMwfxfGSbx2QIWol8nvveTkBZrQ0zKatWoA5Jq4gdlObfX2HiONU/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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins Acked-by: Catalin Marinas --- arch/arm64/mm/fault.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index cb21ccd7940d..f3aaba853547 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -177,6 +177,9 @@ static void show_pte(unsigned long addr) break; ptep = pte_offset_map(pmdp, addr); + if (!ptep) + break; + pte = READ_ONCE(*ptep); pr_cont(", pte=%016llx", pte_val(pte)); pte_unmap(ptep); From patchwork Thu Jun 8 19:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C4F9C7EE2E for ; Thu, 8 Jun 2023 19:13:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00C928E0003; Thu, 8 Jun 2023 15:13:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EFEF58E0001; Thu, 8 Jun 2023 15:13:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9F978E0003; Thu, 8 Jun 2023 15:13:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C858C8E0001 for ; Thu, 8 Jun 2023 15:13:20 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F80680336 for ; Thu, 8 Jun 2023 19:13:20 +0000 (UTC) X-FDA: 80880528960.29.18E337B Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf19.hostedemail.com (Postfix) with ESMTP id D41381A0007 for ; Thu, 8 Jun 2023 19:13:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=dJgo7fXP; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251598; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=MTMETqOmHX9QMlC68DMhM9FrSxv6MqcdEHzT496E7ZtJ3ekQXpwqzHK8vjS+J+AoEhrngw oYka30K5mnjBd3cFZPmyv8+ixbIwOrs4ypC9gJPWv/NfGYTjGn1v6ZxfwuVXRrLqd+fof6 9rFXmS5DXJOJpK52YPtZzy/AhGUM9Hg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251598; a=rsa-sha256; cv=none; b=YuNzAGfzsPshXiXPoTTmWPn0YLEj8wDy1x3MxKyKKtLk8x3OiFi1GBYP7nU6XOAXHphAUe Kf30J6H8N331lBcsa411C+gGRFqzzinflY6zylQY3oeh5eLffyqXiKF9VG+CaGn70VVPsV MztAe4iiOBYGCYyUI54SHHmHF4Pxy9g= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=dJgo7fXP; spf=pass (imf19.hostedemail.com: domain of hughd@google.com designates 209.85.210.54 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6b280319df5so31652a34.3 for ; Thu, 08 Jun 2023 12:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251598; x=1688843598; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=dJgo7fXPVEPfP5aOx2rlF6fhL0MOp6kKeclo0mcv4zTOiWrzHWntcp0lBZsfoj54Se XolJoU7BuSvwRUfmeldzR5qRMBOJZmJVG9boQPdpvF4oDnjII17h4IF7WTHJDAtPgKTK wCc48eCwjyNX1CCKOKbCJn6rCHbIrfq0gOAhHT/Cld5PzM9jgz6HhRaRcDPho1O+ftQz NYl5ZbGuf+ZDQqB6/nkOeRBoiE7Z3JRWHBfKCJGlqU4xYE9mQ0/j0JkL0Hi8bff5nmw2 hyNF+dGcaX/VDgXb0gWmoFHLFIjjowl5ieph5brNA6Ro0AVROhwI1SIjSa8mT9DDlpOJ kD5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251598; x=1688843598; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=WAJiMea4g4DFyNL4su370dquxTeZtId63DMTqFrGASYQNwLFWFSidHh+5nq3XcEmOY 7OZSyaeKKZBZmmF4iuIrkGwTvIOHlcrebrI0jH2gDgkCvSQKtR7To5CzYdDFjjXku07o RlJe45VdT0+/76VWEK8S9uENfd4rf6huGXqkcpTIjKuwlBsqujCCZP8twHLdUAZCXih9 +b7lAjxfUCzc1atXyM0YLYRE2nGsOutvvroAkIps4Ff+XzxaQVmuefL4VR66sXuKMcwe 57y081FV0cG5nAN0OJYVawbNz/8MB2MjknAigDXxHVe/2P35VGd3TU5S59sScprLVh8Z ypPw== X-Gm-Message-State: AC+VfDwZNgprJBbEZES6vzv2iAfz/2qGTDapAArMuTsDxtgjD1d1jZ6j UVKFoJwVKrh5XIwXJoPctTzXpA== X-Google-Smtp-Source: ACHHUZ7k4j5F178ZxkLqaj/gNdJycBqILZgmndfFTMZvJsxEKmjnaCgTvlswNo/GmMXGG825y1l48g== X-Received: by 2002:a9d:7849:0:b0:6b2:a879:406a with SMTP id c9-20020a9d7849000000b006b2a879406amr5080795otm.18.1686251597829; Thu, 08 Jun 2023 12:13:17 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d188-20020a2568c5000000b00b9def138173sm449426ybc.1.2023.06.08.12.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:13:17 -0700 (PDT) Date: Thu, 8 Jun 2023 12:13:13 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 03/23] arm64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <5849464-7191-40c5-c55f-fba9c3802e5d@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: D41381A0007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: swu37q4pzb4bpyoqt1o9w4uccwnb4ry3 X-HE-Tag: 1686251598-498229 X-HE-Meta: U2FsdGVkX18r/0wE7IROeDkQvTkbklpbCJGkCcjfWnaV9l3zVE+ttCRbANWOTbQhfptvE16nIUmOn8yd7EHxFJgpQoPXBvx5loPkGfj5mdcybt50Q55W+pnSLhUtpUq8gjIPqwa2Hgzrheh551gD8bvFKi/jJJa8bPpmDgvmqLJ9Dgi3dwJnFrRB4gsgC7dmBAz5Co2GXaAYirowPLtQbd4fWgoIm+6afN+qcsjDuAFpm/vuAbdVjN31gFYa3DF22Xsk0pOOyGdWcIYrf7upz/N85UCJBioQCtaSFMzhMFxr25/kyIJd0SOMSezHqA6NG1Tkb0hXv072hcnIvparG+TjwmHrofZpALjZ3iPpC937OfYV7rMw1ZeeELbGAQD2noIvvUofFBK7YnMbv1BRCPPlh1XFEiN/eX6vPDNo9zy3LcMx+DPXrsklPZhtSKJNI4xfmaZGlOCsszo4TSmDmaptyXVgD3Y0OJsSkJb/m7Noj/W2N/9ReB2Xfv4kQv8VsIRaLPc5ypC86C8QE8lMD4czltQWgTXhe7mdYBGCbM40GvN3lhkNH4S1C6C0BvPXeyzM2oIBIImesVvUQxQBhwwHkIvi0avgW+DSQEFEprZS2cVDyTrCfvoXbqlcJpqIHVRldP1slOuAgTz+DlU52mNeWFJx53MXayanOZPmWf1rlH+TJ844Wrr5WVhTX0wAX7GWUrPOBRs0qaE8+xVhBNCQB5p+IrjdIqxY/Qgq9EOA0oEOY8P8EVYFYZr3gF/LzXJlMBGVIJ8iddstFDRp2F+qofUqbl30GNUmEBJ3XigQOkjh8W6EiUTGQk+7NvdqXdB2qsIhtkNO7iOc1JpKMLPtI4QQA77kYSqWd/D/n84UgJA7Pjq64ZLn6uk7qDOSJAfsrWNbI3YyxAu+r/4EqbbwDtPs+nWBD9QF9/qIIuh7yy1tLwYVUlpf1epTjMedr6qsWex0kZw6I2vSETN veoH+cG9 KzgYIOzCj+3YlYqZchcPdf8FGZ+DmBDAxY6fR27tXYhLlb5ULQl4Kpb81P2HQInxGHODoBDJbT7bLYhBQ8IktrNpbTHvLId9s/m0ESFdCDwSIqapM0rnhn+9Z/g0oAyJRNaxCNy6rX5Z8iBnTDqJccNLlYF/yuKkZZo8LTy8+skcQ7DV3QqUzYLVc5ADdTxmou4Gc9s9XPW3u4F2RR71TdahsbxAAEuRO97UmsL6C2DuSDqklSyt7vAmPfnRMxmkFaXnrAPtXlZ5O9CQFDGYnvOY3VKb7rjx0O782qUHkR9QemTN7aZt0EqVNAh6yoXEInt75Z5NcxGNzkWEPoqykwI83br6dH7XZGZ2wW9juLjn7F+y29r39aczEd2XoxRyygVR0KkcMssqhNd6s0yop1vnc8fmXEm38U9fyHWM2ITq0Z36PQV/Q8YKAwu2Deu+fXmQPhEXNGjkvGJfl+y8QQoT0/E6RwCf7ukyo+DRRzQEJNHY= 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins Acked-by: Catalin Marinas --- arch/arm64/mm/hugetlbpage.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 95364e8bdc19..21716c940682 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -307,14 +307,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; WARN_ON(addr & (sz - 1)); - /* - * Note that if this code were ever ported to the - * 32-bit arm platform then it will cause trouble in - * the case where CONFIG_HIGHPTE is set, since there - * will be no pte_unmap() to correspond with this - * pte_alloc_map(). - */ - ptep = pte_alloc_map(mm, pmdp, addr); + ptep = pte_alloc_huge(mm, pmdp, addr); } else if (sz == PMD_SIZE) { if (want_pmd_share(vma, addr) && pud_none(READ_ONCE(*pudp))) ptep = huge_pmd_share(mm, vma, addr, pudp); @@ -366,7 +359,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return (pte_t *)pmdp; if (sz == CONT_PTE_SIZE) - return pte_offset_kernel(pmdp, (addr & CONT_PTE_MASK)); + return pte_offset_huge(pmdp, (addr & CONT_PTE_MASK)); return NULL; } From patchwork Thu Jun 8 19:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F32DC7EE29 for ; Thu, 8 Jun 2023 19:14:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0A7E8E0002; Thu, 8 Jun 2023 15:14:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADF518E0001; Thu, 8 Jun 2023 15:14:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A82E8E0002; Thu, 8 Jun 2023 15:14:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8AFC38E0001 for ; Thu, 8 Jun 2023 15:14:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 645021C79AE for ; Thu, 8 Jun 2023 19:14:33 +0000 (UTC) X-FDA: 80880532026.26.0B6FCF5 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf12.hostedemail.com (Postfix) with ESMTP id 6E7CC4000F for ; Thu, 8 Jun 2023 19:14:31 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="2n/XtD7A"; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251671; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=2ObKoI0cIRXvt2AF+ZDfLa9ChpMyRQ3NcqEzhlmdetIzvR35v+ntbH2VvJluSdTbFM7DAq QtXZRZuyZf0ddSoQYEiJM0RdlTPdSMsgAZX1RULPqDDGSSmknUjtgmv5DG4PjlNAH4rsgA UMygWN9FvnmFroL7YJeq8sPHGTySKTg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251671; a=rsa-sha256; cv=none; b=m1Tn2MIm4K96uUfN+7BhfFVh9Ly6vFtMdkTtJmm42bcUWIhr7kiWjNAM2JUVfsXRyY+WfQ 9iUjZAob/nFPM/MDBWnjWn3QrxJTlrep55xdzR3//x0rJ4fchEbLZCnWebYDapBJ6v2ziM 9PBkN9Q+fDuB3OA/ok09708Yx9sjOCw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="2n/XtD7A"; spf=pass (imf12.hostedemail.com: domain of hughd@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-bad010e1e50so1054150276.1 for ; Thu, 08 Jun 2023 12:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251670; x=1688843670; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=2n/XtD7AqYzwMObmNTcTXdhdmtrivr6xS0a6hxh2028Gq3sNV9XO29gB5O2y3L9l/t L2rqH6x4Pz17FgKoR1Y4rQPo+pjlVHFvq4Uxf6V5Z1hVLY+dk3dbsKixOg2g0+O6MH3o wHR7UhzFBUpyNSTJP8nVTqWIyYA0el7GHtc3GU+0DrUYPDVBZCtJf3wyrCUqLLZR09lv VqBAJ8/LNlL6ViTV2apFi54AS+jw7a1Zjo/eBl1kmHqeluHIV3N/nqy10dITHeklJsgD IGKWlS4umLi9ypWs+T7OEHIYU3YkWJ3FbGyXJ6NMN9TADYksX23kqJlAINxQPvIJDTtX gwNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251670; x=1688843670; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=Qq/IfhE5fMM5cjIcRw1V+Z2IvbpcpRWNe9gorl6gQmRjbsvVhkUFlJHE40Ume6Tx4P yBtRvSp/BWkXJ/dWJgNtYyrBVVXC7A4fUOlBu0KOwlEy9mlr0kq79V7J8iJfnMxnu6KK hylI63VP6/o6a+HGQbrGqXu7K9nQOKyDUh8uG+BKNECbylH2QcZT9VR1JQuDYhb9s8jl jWXmYq3GJiDb1ckfBkeXxhRj8BKzsCQ3z45W4C9sXSZ84ljVuvfEhdTDVxv1CpAXyXWz hND4cM8st14Upyy3MEN2m+V+qJWp5kwthist6wtf21WCrAMHPwPQUMD2dpJfhQipchYd t/Cw== X-Gm-Message-State: AC+VfDzAieXutunWPEWBpHg3q6n9vtkBdJqMDmS0FLhl6qa68RA5E9p3 TjK48ve3OZlOrmwlhByQudcfiQ== X-Google-Smtp-Source: ACHHUZ7aUiIh5IKg+O5kgdrTnFDUinQat6T8kg6GewL/1W4sBHj9jDkDghROqTlVL3SjDvy6zEmR9Q== X-Received: by 2002:a25:e302:0:b0:bb1:5a06:70ed with SMTP id z2-20020a25e302000000b00bb15a0670edmr543635ybd.19.1686251670430; Thu, 08 Jun 2023 12:14:30 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e10-20020a25874a000000b00b9e5b28dbd8sm429689ybn.17.2023.06.08.12.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:14:29 -0700 (PDT) Date: Thu, 8 Jun 2023 12:14:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 04/23] ia64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <1c2c7837-bfea-9640-a74-985379fcc5a@google.com> References: MIME-Version: 1.0 X-Stat-Signature: 89yeym8xh6odaabs6nh74jqddkuj81hn X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6E7CC4000F X-Rspam-User: X-HE-Tag: 1686251671-786516 X-HE-Meta: U2FsdGVkX19tFd3HEaq/AURy6BE0dimxUV9MnoVHLsGW3zIHNIU/2VYzkvUo6X0YJiRdXTwLrCD/R5WU2Ox2ow1YyM0/02xyyhc+7FL49wA94XNNcs6suAkiS3ZXsdBqIxOHMs2wQmj22iLyUFxPTeVuLB0LKu7+/ueuT3Y3iD1WP6INx/1HxPENVnFIw/mSe87pd1Sxp8xOiZbzsy0gFcd0IrAX5LNH1dj/HJepj5iEER3i7mXlnWBhD8v8ewpDpNo9QgveGh7O8S/wvp732C4WHKKS1xOvESc6evYFDU6iweOzBo8kt5tH42Wz7uHGMl0XwMDOJbpT55CPcQjXhDIhrqmCY1z0AdtQRjfdd3NR3ZLUA1W7lX7rXVQVhz9720G/d1vFzRlG+DiMpt43WrSx+zF7XReTAMlpX4Lqv+OBorLIeqW1sNyd/KGCKcsrp3+75wje5gsN6tLVLkevLw9VI8cX7oD8LP3I8m7vjUDjFnSD9xEDXACaFeJZRHT7jUhmkZ5Nf9fVcIgL8Yec+QPN1uBYRrfuX107D8nJAti6gf85GDCD1YrVfbck6BgairSu15aTPXO640VILQDCir7Q1P4Z4GFP5poRV8OyttG6m9s5XppIz8+t3BJEvz18q/w4/fbo0Oyx2FNklN0TIFo0lZO1yPHFf+912ieZLRB87hYyqhehqWQOhX2xtfR8fAu7ge5jtsAtApf6lBh5MKZWydFKfvKTGBpwoBJ3YevopEeBqWCiEBZB7JQIuKgO5MKXzov0KMF86uSiqoWOj9ZcRkJIngWNXG1JzrX+o/0gY2QBxt+gPQzIpvAeNLuF+b0bGeDTPRej+uquTEg3h4sdZABvaTlzYjubSA+GdkoQyO/V1Jp38t2s3R9dMI/CO1xwTwjyJr0KLQWXL3cjaeJph0fbdMaaOpOMfiU+bjNOrjmgLzPLUAh/49S967xL00UYq0CJ9GrK2h3CKXu QsBrvSV1 /PD8b63qlyx6bEGKKyk+nNFJL5lSugKWOeYrdBQmlyxFlTT8/anHyQE97OrjHGrpfN6T3CMg8SGlkqoUS7fKvY9ja2kjHaC1yNjasXIkXQusL6frqJwdXewuQk3FxL1evrRqPd2WEzXnGXgoIfmeQST4Xj2jPnF0D/KqTDYKkKdVJsFp+UiO9fiseWrjK8hW+FgAiF27l0uULDjijJMzOTMQy32JpqIgaG6xJ1CuqBlpctpdMsG7+AEXA71l8wlo9m9OwPKen2VbEHrNWFEsEbJ79KTkDxR22NLLJkgZiDwFbDX+gpPAzZQblpKxi55+Bg8PN9YYuUrp12Ioqm+xribdtsyCjWRN9GAfY/diiEyTlsaO5tXXG6y/GQ4NNQRdJi5khSdrrzpTWaVf6Uhv7KlUGng9Zd5RqxzN1/vfW5D4VAwXzLk8psnzLng== 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/ia64/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c index 78a02e026164..adc49f2d22e8 100644 --- a/arch/ia64/mm/hugetlbpage.c +++ b/arch/ia64/mm/hugetlbpage.c @@ -41,7 +41,7 @@ huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, taddr); if (pmd) - pte = pte_alloc_map(mm, pmd, taddr); + pte = pte_alloc_huge(mm, pmd, taddr); } return pte; } @@ -64,7 +64,7 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr, unsigned long sz) if (pud_present(*pud)) { pmd = pmd_offset(pud, taddr); if (pmd_present(*pmd)) - pte = pte_offset_map(pmd, taddr); + pte = pte_offset_huge(pmd, taddr); } } } From patchwork Thu Jun 8 19:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46EA5C7EE29 for ; Thu, 8 Jun 2023 19:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D76AA8E0002; Thu, 8 Jun 2023 15:21:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D26C78E0001; Thu, 8 Jun 2023 15:21:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEEDB8E0002; Thu, 8 Jun 2023 15:21:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B19058E0001 for ; Thu, 8 Jun 2023 15:21:34 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 89BB6AF439 for ; Thu, 8 Jun 2023 19:21:34 +0000 (UTC) X-FDA: 80880549708.15.DAB3D1E Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf22.hostedemail.com (Postfix) with ESMTP id B755AC000B for ; Thu, 8 Jun 2023 19:21:32 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XBBTuR3P; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252092; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WK0F+BrKreVsJ5WKZMSSwYtM+YC+fc99jiRjqR8qAzI=; b=mFISxaCcKovCEnBt6P8LjgWH2UKIgbGTfMyKy/CeIwx4eSWYIX6jWS4kaDTB5/IxY05dXv xRl+sE8RwWeZJRIlELtRORkJCdA8G0K2lJPc39aZ1NUNZ0Qf6qrvoy/h+Jy1HBRF40gdy0 pc5JP2PKKzP0O027KMpCrGvjAfNgYSo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XBBTuR3P; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252092; a=rsa-sha256; cv=none; b=Yf3s5a9hSYEDJQt9BQElSFL1bvOxsYkalIvhpCbeWwekJICysbsQWBUoi7MAM7uZ4925PW 6CgImXCMm7BENdsrzr/DIGxZ3cSCs8Wf5ghyMgdb0cNfgYIy4sVVpBl5lsAyVNJCap3CA1 mBIU0HrjYFUKTLiYwSXtcNvAKsmy0ok= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-565c9109167so9107167b3.2 for ; Thu, 08 Jun 2023 12:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252092; x=1688844092; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=WK0F+BrKreVsJ5WKZMSSwYtM+YC+fc99jiRjqR8qAzI=; b=XBBTuR3Po8s8oggxusLC9+4cDljv5yh3iTM+Llr0kL0YG3PlH/qzpGX6gv/PUP76MR eTUMPaMKfHxzAdmNXJxDHSVKcZ4LHobBVYHVPN1k8yUjKGrgwroooXlMcklQ1J87JV4H 28qnFK1ESbADbt0QaL3KCb+v1+8KFziZJfdE4s4QuQQtjaaHutW3Upsp9VEkYfq7AUqK +QynXdx8iqJqmbH6vUia9Mh8pp1NzZFAKGSF9XfD6YiOaPkHP83DudRGpzvoIXsfhRqf TzAbY7Sx3956pUdr2GqB/QyrabX75ITT+uhZh6g9MMaTQYuYAsgrBKn1Rsnz/Y7vosPj cW7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252092; x=1688844092; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WK0F+BrKreVsJ5WKZMSSwYtM+YC+fc99jiRjqR8qAzI=; b=JCejbY3nP0a6IMkAxrC7+s/9s/ttr/4vDVy16CuSUOa6JYUNK0IK3RWjqs8elojC08 08nRet43hdZ3l8c4jpz5P3E39tUBjoqJWmE0ICmBZm1XOSOzpmGzNIxjylUYGVyR2IvU OxO3kzdibpBlLsTF8myGciKLQcCfd2Sppi/FehvzAKKLsfvjEmO6+M3s9k5hiioIbXK5 /1/du5xVRaaU7X+5cUzw/0Lu9NHGEDAlVy2rWtLIci+AIZI1gkQLEe4iClLZsHrTuFf/ cMxVMMihftL/Kz9/GDWOyvBubsxfc2dbsEMEiQWe8Is3ArZOxMQP6xDIPWF4ojMw4ujl KFlw== X-Gm-Message-State: AC+VfDzTKrsxKpEcw4vtvMHHQHtyAkTmo0os2L0nNA555Z96LcD5OIrP T1YjbUHX9x72/NG45njs2m6Z8AXGU1y74x+w724V+QOH X-Google-Smtp-Source: ACHHUZ4GiCiA0/Y6MKCFg7CaDp1TXejdH2N2rUDPBFAR/nPzuleTjqZzDRxE6rsfXkK23/Kmg+ycrg== X-Received: by 2002:a54:4893:0:b0:39a:b35b:a06c with SMTP id r19-20020a544893000000b0039ab35ba06cmr9888918oic.30.1686251720727; Thu, 08 Jun 2023 12:15:20 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a17-20020a81bb51000000b00545a08184fdsm89974ywl.141.2023.06.08.12.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:15:20 -0700 (PDT) Date: Thu, 8 Jun 2023 12:15:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 05/23] m68k: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <795f6a7-bcca-cdf-ad2a-fbdaa232998c@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: B755AC000B X-Rspam-User: X-Stat-Signature: 6ozcbbgouwp1yyg8aqpcpntrabby3byd X-Rspamd-Server: rspam01 X-HE-Tag: 1686252092-468033 X-HE-Meta: U2FsdGVkX18XDZYdghjY5WiXd83BuD0Dgu+hqRPnXSSEU4Zr9qG98Go4X+4PEKmKCNuTNXjelvK+kwJI0APEC23LpsvuumxndnP8DGdbrf28KYgd8lwFTX6dG7WFyaflBSw21Y/KoJo+OiAZ7wFrNndTcbzfVgDIZ5PiU+DOJEkYaalnWI9FFsfqgU3Ds+bS2zJVnIVJxza6f+I3RkRKkZNRjTe5HXJLjh4Rp8kruCzD/GfMcP0NBTFQlwioPFvTQ4T7C5sosvKPaV2oFaTlyCW/ZUUuELJ+ILWrenw6E7KKGQ7Qbp68Q7bcuNVAqmBUaHy9QchPDjtt45JAtb9kK8zm52YSr/BLtNAUP3RsHX+v3UEzevckNkSgX7mX/L9aPmU1kVw6CGxnuOAAsFqcYB2QXCw1p/GjI75oZA9x+eDpG61R+0aZPldMFu0nJrp9XM2g8drPCd2UJ3yZcmxVrIaly9Z4rr4o8pXTM2Se06S6WQb+fMXgvtyXPw4Gwqzwy8UuTEYCK/cnLIOjTDqOh4tPskmjh2jz4Vvi2cENVVpPrIpgfRL1rkzFur/7v/r+8jZjZkiqbUvdEmlEc2d5XDdwKCHmTUMbU3l0wumZQty+0iuzPFDIhWQUFmz6ReaD+lQ6DB498ZYdHC68Ztzc/Q9egKNuH5tKgi5QZNWRlYOLPpOpyXbQgIY13t8EkIEv/mZ6asOs1yQmYOS3RlI3bSGkY1TlWobLHxb5h6LWiYsJKdRKs569RnXPGTsRITyNMdx5Jii01O0+X3+E/kvTMZDlwYFRQui/ynPszDw/PzxfAkALfC/76rJMmk9xD7hw3Yh3RNzHqNK7hwdpztT3sC6LnC7Iv9NoXDVdJVJft9Mscr8jcIBPk8tuJLyh9Kac7ZWINyWF+dJYgcfFkVDF0GUMGx4e8vKWmd+pn4LXG4euw0pU4Mjb6eB6TJoFgaMYGgj8jNTTPh9PXcbh+GJ VppWXV/G eJyL+BOoDt3vgVXV9GHLUHJQHM9BXuoLMVH+eoiC2r/Fuxt60FQtoFWh/N99f6Qn741NTupbhk9LIAw32GVD2vJULACQ2RqURGNltCY7WQzAptEBFQ21LCAuxQEqJnwX/K2mASO5l3TH+tmL5K43QLSusvkdz9V/pOnlkQBIvmjjzv/Jp+qeajMhqZG2k/dQdDoaLbFUw3TM9GIrUDMA7e+7EDJ1CwOM+lAUU1x5c1vMX95tV2wiwpRWyo0IIKZ1TGiUsl+1Ux8J69k0GSXW3rp7SGf8WG/BeuK4jLs6v4I1pbFGL6c3TThy03EiI1qKZyZoj+sA8BorSCArrAuIEejj1R4W7vp8tvL7RrtNsgaakP13Lx7Qdtnks+1GTV5niWdqLthMVrTEOJSPkfCb2kXfdHQbtcOCm0E1hZYLQHANHEr0Jwaug10KhIg== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Restructure cf_tlb_miss() with a pte_unmap() (previously omitted) at label out, followed by one local_irq_restore() for all. Signed-off-by: Hugh Dickins --- arch/m68k/include/asm/mmu_context.h | 6 ++-- arch/m68k/kernel/sys_m68k.c | 2 ++ arch/m68k/mm/mcfmmu.c | 52 ++++++++++++----------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/arch/m68k/include/asm/mmu_context.h b/arch/m68k/include/asm/mmu_context.h index 8ed6ac14d99f..141bbdfad960 100644 --- a/arch/m68k/include/asm/mmu_context.h +++ b/arch/m68k/include/asm/mmu_context.h @@ -99,7 +99,7 @@ static inline void load_ksp_mmu(struct task_struct *task) p4d_t *p4d; pud_t *pud; pmd_t *pmd; - pte_t *pte; + pte_t *pte = NULL; unsigned long mmuar; local_irq_save(flags); @@ -139,7 +139,7 @@ static inline void load_ksp_mmu(struct task_struct *task) pte = (mmuar >= PAGE_OFFSET) ? pte_offset_kernel(pmd, mmuar) : pte_offset_map(pmd, mmuar); - if (pte_none(*pte) || !pte_present(*pte)) + if (!pte || pte_none(*pte) || !pte_present(*pte)) goto bug; set_pte(pte, pte_mkyoung(*pte)); @@ -161,6 +161,8 @@ static inline void load_ksp_mmu(struct task_struct *task) bug: pr_info("ksp load failed: mm=0x%p ksp=0x08%lx\n", mm, mmuar); end: + if (pte && mmuar < PAGE_OFFSET) + pte_unmap(pte); local_irq_restore(flags); } diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c index bd0274c7592e..c586034d2a7a 100644 --- a/arch/m68k/kernel/sys_m68k.c +++ b/arch/m68k/kernel/sys_m68k.c @@ -488,6 +488,8 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, if (!pmd_present(*pmd)) goto bad_access; pte = pte_offset_map_lock(mm, pmd, (unsigned long)mem, &ptl); + if (!pte) + goto bad_access; if (!pte_present(*pte) || !pte_dirty(*pte) || !pte_write(*pte)) { pte_unmap_unlock(pte, ptl); diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index 70aa0979e027..42f45abea37a 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c @@ -91,7 +91,8 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) p4d_t *p4d; pud_t *pud; pmd_t *pmd; - pte_t *pte; + pte_t *pte = NULL; + int ret = -1; int asid; local_irq_save(flags); @@ -100,47 +101,33 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) regs->pc + (extension_word * sizeof(long)); mm = (!user_mode(regs) && KMAPAREA(mmuar)) ? &init_mm : current->mm; - if (!mm) { - local_irq_restore(flags); - return -1; - } + if (!mm) + goto out; pgd = pgd_offset(mm, mmuar); - if (pgd_none(*pgd)) { - local_irq_restore(flags); - return -1; - } + if (pgd_none(*pgd)) + goto out; p4d = p4d_offset(pgd, mmuar); - if (p4d_none(*p4d)) { - local_irq_restore(flags); - return -1; - } + if (p4d_none(*p4d)) + goto out; pud = pud_offset(p4d, mmuar); - if (pud_none(*pud)) { - local_irq_restore(flags); - return -1; - } + if (pud_none(*pud)) + goto out; pmd = pmd_offset(pud, mmuar); - if (pmd_none(*pmd)) { - local_irq_restore(flags); - return -1; - } + if (pmd_none(*pmd)) + goto out; pte = (KMAPAREA(mmuar)) ? pte_offset_kernel(pmd, mmuar) : pte_offset_map(pmd, mmuar); - if (pte_none(*pte) || !pte_present(*pte)) { - local_irq_restore(flags); - return -1; - } + if (!pte || pte_none(*pte) || !pte_present(*pte)) + goto out; if (write) { - if (!pte_write(*pte)) { - local_irq_restore(flags); - return -1; - } + if (!pte_write(*pte)) + goto out; set_pte(pte, pte_mkdirty(*pte)); } @@ -161,9 +148,12 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) mmu_write(MMUOR, MMUOR_ACC | MMUOR_UAA); else mmu_write(MMUOR, MMUOR_ITLB | MMUOR_ACC | MMUOR_UAA); - + ret = 0; +out: + if (pte && !KMAPAREA(mmuar)) + pte_unmap(pte); local_irq_restore(flags); - return 0; + return ret; } void __init cf_bootmem_alloc(void) From patchwork Thu Jun 8 19:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF42EC7EE23 for ; Thu, 8 Jun 2023 19:16:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 589298E0002; Thu, 8 Jun 2023 15:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5129F8E0001; Thu, 8 Jun 2023 15:16:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38C688E0002; Thu, 8 Jun 2023 15:16:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2605F8E0001 for ; Thu, 8 Jun 2023 15:16:22 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EF6E9120461 for ; Thu, 8 Jun 2023 19:16:21 +0000 (UTC) X-FDA: 80880536562.18.8C667F8 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf29.hostedemail.com (Postfix) with ESMTP id 289F3120024 for ; Thu, 8 Jun 2023 19:16:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Xts+xHOk; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251780; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=kuY+sWvkW86rfRj2roSMY7+shYQzgOeIgu/9WVBsSuUFSaFk76fCl9o9+rIBXTCMPhczjg yvtohvUvADY6qMM9zN8A2cOUKXIqEdVUBxJEm+XyhIRnEIw1DLXaDzUQTfkVybhuC/HcYD U9/d6vP3g0ZX3C5kFHkmU6LwjD8BT3Q= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Xts+xHOk; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251780; a=rsa-sha256; cv=none; b=UHNBtljGVlr7iHZXwU96kCZiv7Hb60fuvu0V6N6wae7Ll91xT6sYqa5hmpxcPzRBN3hNTf zt6GSuDzYYW2j6huxNsdjmiAcb+dAbEtXo6liIp1VPI2FYBxqgB6j/pKSjoCTsWvKGTNpJ 8XSXVmZA4wL5FRjAKijlyuwesoI7x1c= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-390723f815fso27250b6e.3 for ; Thu, 08 Jun 2023 12:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251779; x=1688843779; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=Xts+xHOkrh/u1lklJ9jF3D7S9f/kLV8GPG892l7zD8MlHgN8wPrMqgrCwto/Q1X+Pk W1+dBhBpd/nxZGkRw7Je76Rv8ScIxWS7YhmGg7SCpWHyKB1Cka/5vVCHo+mJDQWdRl3m u500Id80G1EkjsXNB0mtCuxFaZBYzNUs8Dvvd2LdfZ44ADa4Y8aQBNX2j9WdcdQ881QF GqyzpCVHN9rDUPFg5SeHYjmoNQ/CJXz81UrJdT3zX813tHx7kBAl3bNlJp8cLIqFQaDy L3QDpbP/aGZ6VEQHFKJzDm28XHlRNu1JajJiE2WmrxtPA9CVcv6EWsa+OLyEs2Vz0giA l8jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251779; x=1688843779; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=b3Hqbvjl92Fg8MFsEMt8OzecKyLzONyO/BOzy5kS7MA9kysIq0clj2z9Y6Xxg2SdYe 2VcPib0Ni/lFN50kSILsgdXj6kyyR+5Y9f111mK/wFRCIAwrNZqp0GSvhiQWMJnf9Gq7 9eIf78oPfi4xW+1Jl6kW43s/FUzhs69LkgtAzdAai9EdewyLmWx0upV0SRnmL51OX9a+ vW17LQVbJ8g5Tndf8NyMHuxYZjn2u7CmDOm5Cp76XYIPp19ZD4VXlkF9/7Xcrw1r999I bCJVFEymHVAuQY5/HyK21hqCxnk6kH/l2uA6Qkopz8GF3AyL2Jbs1UglR+BZGQbiyvo5 a5dA== X-Gm-Message-State: AC+VfDwHDdEitItsqFb7Hb2TYfXRnkjISzGOt/5Fy1fGqYbt8H1vmpZH xG0OkgTVtlKZ4+I8jqvCXLpRzQ== X-Google-Smtp-Source: ACHHUZ7LNWBjev2z0u+SFnM7tyBRgdoNXbEUc0/f74NGgApbHQPTQerveZROpTXi1Z/8SDXbKzu99A== X-Received: by 2002:aca:650c:0:b0:39b:da91:8749 with SMTP id m12-20020aca650c000000b0039bda918749mr6427430oim.50.1686251778936; Thu, 08 Jun 2023 12:16:18 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h200-20020a816cd1000000b0055aafcef659sm120593ywc.5.2023.06.08.12.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:16:18 -0700 (PDT) Date: Thu, 8 Jun 2023 12:16:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 06/23] microblaze: allow pte_offset_map() to fail In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 289F3120024 X-Stat-Signature: urs8x3mc6zmddk5rfisquojorzd9ijs1 X-Rspam-User: X-HE-Tag: 1686251779-619073 X-HE-Meta: U2FsdGVkX1/eimBfRvy1d5rWI5AW95D3Mechjgbh78fjRoi4v17MXifkWNbxSEgKo5f/XQ6ph0rzgHJUFiVW4ARn/zgPIT0FP/OM6PpbNnsmUrXhZKJHqpPp+9CQC84LFqk1nK/ye2GyiSlc/uaP7PTkYf3PTvaKDlMsSgdiYyA6Mi0TwaS6Y8qhftxZbagEOGK55Vihyxfyw/lSoDSpm4barorGU28hiLttEaJaN8J+b6J1fl8icuNuZZ7OoXFLuRvBjNqwbBjoUaPd23GfdrdFnjRhlcnPZHw1J1xychBEM+Xq5jbjFM/IF12ZYrKozi76ZZKE6tnWNkSR+cG7BJB60KFVmmZIU7Q92YiVQBYdrpMxWgP1VZWCvPu9+2T7/pDiA9iT0ePiA4IliYAc1lnEW77Kb5vFQYfLqgg2kAXt0vLantBvtb61cTfWmSlW4RPO1JhKPHDWC/ytbpf72PgpE49EfwaJjvy2n9RG64dOP2dtn2ufJpC5jnUqQNT0kPaeMBqQgvxoXs1TXq0NosdUD4tR3I1O/RffnhD3nQUrK/1Jx5AO+9Xl+/sdZJvrHlzpUJj7Kd+Th7zv1ZzhR9Kz6mmmaHw//TQ3EhWkKJHQJm5M1DchrxnV2CWjyar0EKxDkBcix3Aw8Bpx6ajMZRtOHb0jD5FX9JI/8UxH2R6PEkPcpCiDiLBZNz865w2VRVkdJHMRxyYl+6EcEiMR7qcznntw/GWzTo61zRdvPajm+6geEYANz+jMZSd3XZ5IXpRL6rjS0FEbN8L5ybVOb2QC8IVSLCce6HRY3qnFXTECDG63yJ5YRqkK8QwtwJmA9GQbsrJwczStk+1vImuv+7olbISfxLkcgHmxjBoA6wZ861HRXzF9R8uTrNfUIdjxBH9oG5OkB8hzrtGx1Yz/Q5Am6FP9mBPuuUgecFOGHRB+yK/EaturM5gWiArk3xXI0ZoKh6OMVeh2sGMr8GJ xhibaBtX pAML2M6kgJBJZZLS4ymBxlaQy2xrOdkF9pu2HSy1bJ03AaWG7SOcC16QHedtylcLfiu9xdg2tPSb26n12lXXS4Ep80o1SIF2JMs3uM573M71v7z73cUIiHvpu6VVkPN1bvrncQWs7L3ln7s7R6rDFhAUt79uTmFdqeyWL8bU68DrZeMhw2wSXK8pfqn9etZwDaIXXDyWmn1TQdrqdvqsHSW3+5/ggOIrnkyYlI6lMOo+w1CiwBtfaanl/8WjHsOllz+TcVaWNPVP3tavAS7DGsHiRItNM6CmVgyOthFaXWETP1ZnNIYnGRslof4v8Rv9DSkkFsJL7pWVYo8HzVzQ8z90R2/U55sTtNTkwHMB9thlXY1WHGJ+w1tvit5in6fmoDriig75U3RSE9oPUpfNB8wdGtneyrcEW5HE1lt9eivsI+R9FuChNAs+27w== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/microblaze/kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c index c3aebec71c0c..c78a0ff48066 100644 --- a/arch/microblaze/kernel/signal.c +++ b/arch/microblaze/kernel/signal.c @@ -194,7 +194,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, preempt_disable(); ptep = pte_offset_map(pmdp, address); - if (pte_present(*ptep)) { + if (ptep && pte_present(*ptep)) { address = (unsigned long) page_address(pte_page(*ptep)); /* MS: I need add offset in page */ address += ((unsigned long)frame->tramp) & ~PAGE_MASK; @@ -203,7 +203,8 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, invalidate_icache_range(address, address + 8); flush_dcache_range(address, address + 8); } - pte_unmap(ptep); + if (ptep) + pte_unmap(ptep); preempt_enable(); if (err) return -EFAULT; From patchwork Thu Jun 8 19:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9D8C7EE29 for ; Thu, 8 Jun 2023 19:17:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 514D18E0002; Thu, 8 Jun 2023 15:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49DC18E0001; Thu, 8 Jun 2023 15:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 317F78E0002; Thu, 8 Jun 2023 15:17:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 211AD8E0001 for ; Thu, 8 Jun 2023 15:17:32 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EAFC31603FA for ; Thu, 8 Jun 2023 19:17:31 +0000 (UTC) X-FDA: 80880539502.28.60909EA Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 27AC7100019 for ; Thu, 8 Jun 2023 19:17:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OjxQxSGd; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.128.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251850; a=rsa-sha256; cv=none; b=L4O66GRJWLN7QU/jN79AZ1BD3aPKWv90qvuik1QOFr67PQidaIFCD4I0M+YzJzvq/319sZ fClNp/jeG9ov+6VDN43voAWgnWCne4OeRk2g7dq+/GDHA4R8WDREhRc0xI0mGkhvlKIVFl BL9BV6o5fQXD/xGazWCcNlkeG884t80= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OjxQxSGd; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.128.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251850; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=CmBhCBpogpEO1HMj+oHsF8Dgk5SQSut5iq+3ukWkn5FxGiXDY0F0wqYC+ewW12KqXkSXcw NtdWnwcbsAInyHqg7GVLBiiPSF6GFDoDdHVL34qB5k+8JeZvydwXuxKVXBiG1y+U3rMBM4 pcPnvkLjF4oFVUDnRRnbEsLoS6jjF7o= Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-569fc874498so9294177b3.1 for ; Thu, 08 Jun 2023 12:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251849; x=1688843849; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=OjxQxSGdY41m5JGioPLRRMHlbu1bKK9U/XvtQSsWn2huryMGbscAYfOgTPbtYvU/cY 9huVOVy1gs221HXHTdTxeIS9YVBJM8bmeWwNXcHAGGu+nicpq5iZ05fikYyLmvX7+Ico B0dGfyyHLd/L99UUQOPdqJWluT143yDr4HPWe/IeSwrOdmo8Ey9hr6IWcFOUOcdRjD89 uj2YuuaPnH3mhSN3ywyQu3CK8kSeEgGczYiudwTD8Jm0Ztvk+Qzx/bR/vvgb6aHZfoxB UdhBn1Xz2Oa9JpVFDtQjB5jQNwvMAbW3dNrfQzUbl4VOBwdYKLYYm2tmZUitVw+SniVU 1QQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251849; x=1688843849; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=eOC6X51wG27mcpZJx/6epY6DoW5TLMHJMR5hrZERGnWCR5UgV34RfJQ4Ze8U3xiloY yjXnoYs8R1r0XMbDHPtikyKqgrh3b768VZZW5csP1b1Vb1+Lu0cgOnjrb5KnVreExhjJ Sq1/xajk6ykiu1J1YtR/M6DVYRhRqzXxX7R9ZCqtp2hizDkdJFudEE3K1pMd60qFR5y+ +0e14UXUWxT8Slw1qxVjLlMr+4jcZUJKkylhrzxmNuKtLW4F42bp/eg2hYfdzyVESQBh +XEL/SkIReYBiwgTOGjtcwQYflE4X9c3eVvQtD0XrkvEULGZNPJ78taTMH8H9xzSDogi 7VaQ== X-Gm-Message-State: AC+VfDyMpMbn9b12eq5TnfFnGCveJoM3cWTWG56bCvt1N1NdgEFLxZCJ 7g0+RKV2ToBmmBMpRwKRUfHELA== X-Google-Smtp-Source: ACHHUZ4FKrGElLGHi5/eSiT2fDophUzi3i/RSv3jkZHU9DU5gGJq5nlHfaRL95gf++/3qBOcCkTajg== X-Received: by 2002:a81:8403:0:b0:565:eae8:793b with SMTP id u3-20020a818403000000b00565eae8793bmr567910ywf.25.1686251849019; Thu, 08 Jun 2023 12:17:29 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d190-20020a814fc7000000b00568b941e5e3sm109329ywb.72.2023.06.08.12.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:17:28 -0700 (PDT) Date: Thu, 8 Jun 2023 12:17:24 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 07/23] mips: update_mmu_cache() can replace __update_tlb() In-Reply-To: Message-ID: <178970b0-1539-8aac-76fd-972c6c46ec17@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 27AC7100019 X-Stat-Signature: zdo7a751f99474xssqoycquhsoezr4zk X-Rspam-User: X-HE-Tag: 1686251849-851029 X-HE-Meta: U2FsdGVkX18NkKrfwYT2wrlcoIQucBTb7/JrukGzMhLKMttJ2JFNUK5QI5h7+MKaC2CmfpaQHh8LuZgFIu1LcysYCeO9sRdqGqK4/S+S7G6QnnvXlwTJOuqXYz7DwC2uO2s01ZQ5qa9ksgOEISj3iFQDfKoF+Gb2y4H1S7vFzwUSMRGNILZlArEJ5B1WRxD/c0+z6CldMZGQIMGzZNtB5kzLuhlJlQxahLuYA3yqx6PuT0Gi7KL8mNCHl7GWfEUSIgeumGQcupE/qrmeGK/9QDT4UfOhYb9ZGrcMgt06FeqET4VJf5xGEU25T/6yXSScWO7LDuIkm5xxX8qtR0pO7pFuHL9HG+HfWGYP/QvTOBPkfmQRuTzgtXcyNUDm1lDzZfN6+qOYmbFoFurcr7N82qp00s8Y8UwwYRhdfmxUItGTDfuKMovsZggavftbmiJPl8B0S6hOEE+n6tVFsM0E2yyCFM00XlJdePhvPB2yWu1ziAqnr/JS4Emqklb/90uNMumgxr8XOxYyt7EEg2UrOW2LrAg/QaWTaqhWaQoHqkVOnhfVDg2Y7euxNm+QJl4N352RxaW6x7DylAvoRd9mFW49GSacPUMNAK4DjOc4q2QHY+QcvJ1p7UrcOmPBEzJCWJ0+xZyhlMpBrG2NnRlk8zHA5kyrN8OO4xRQTasoLciZeGzQJ/1u8YUQ/rMKZPmDdRvSgINUiFwLQo8MqTmtw4MvIl9Eybz5QSin0I/r9flYTh3A/n5n44WMCv+t6G5eVA2d/s+lM7qj42IDzs0GO/gZAdwX+WTKaldwC+mpJDMOqveWyWxYS3kVs7shKd/2biTcqpmfa5ZghJq6WHqzLOP+7mXbn8xdNzADyDxqd+YDuaeRl7aiTMDMXIQqxklLnEpCHcksNPSS7mxKacNiPHvEI1f8BWsTZNjn8ZpCdSnFvsb30MLlcj2S3rqtKDQoc7zjINvCPEQYQ6d3sb0 VRqQ74iQ pEH4PJLzNvKBdG0Zdt4fNOK7wgn9wnAodk6yqhiW91MGUoHK7TRkVMCcD98HT1t5eRwtG6RBc5628EXA6cgNJtuOIgL2l6tjJhHfvexOhse3IMdHboJDzVMasZtDnzHMKqSXlj4yV58xZaqwZ+5z7ArvGLKvDZXyhsoR6uG3u7a9bPQk8o633CeEsAXGad3QSaKagrgsEvo+dhwldaE4OADoVuFJ8SkJ7IsDs59YfFpK9oSBVoNzDr8hXkiFewPAOTHG30W2tIwWijt6iJb262ielDEZmjLcUQulz/yDYKkYj1IzGbB4THqRVCmUT/Zk9SZrStrEGo1N4OMt0DQUTn1AEOsSJhUj1P/l9boSvfgcyCDVI9Mdv2ICru3Lgl5mW66qGMKIabqpM6v8Thu8R1F3j9LEfovUC9jpbghYQpaRFnHbhuU9OcFV95Q== 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: Don't make update_mmu_cache() a wrapper around __update_tlb(): call it directly, and use the ptep (or pmdp) provided by the caller, instead of re-calling pte_offset_map() - which would raise a question of whether a pte_unmap() is needed to balance it. Check whether the "ptep" provided by the caller is actually the pmdp, instead of testing pmd_huge(): or test pmd_huge() too and warn if it disagrees? This is "hazardous" territory: needs review and testing. Signed-off-by: Hugh Dickins --- arch/mips/include/asm/pgtable.h | 15 +++------------ arch/mips/mm/tlb-r3k.c | 5 +++-- arch/mips/mm/tlb-r4k.c | 9 +++------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index 574fa14ac8b2..9175dfab08d5 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -565,15 +565,8 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) } #endif -extern void __update_tlb(struct vm_area_struct *vma, unsigned long address, - pte_t pte); - -static inline void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) -{ - pte_t pte = *ptep; - __update_tlb(vma, address, pte); -} +extern void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep); #define __HAVE_ARCH_UPDATE_MMU_TLB #define update_mmu_tlb update_mmu_cache @@ -581,9 +574,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma, static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - pte_t pte = *(pte_t *)pmdp; - - __update_tlb(vma, address, pte); + update_mmu_cache(vma, address, (pte_t *)pmdp); } /* diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 53dfa2b9316b..e5722cd8dd6d 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -176,7 +176,8 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) } } -void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) +void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) { unsigned long asid_mask = cpu_asid_mask(¤t_cpu_data); unsigned long flags; @@ -203,7 +204,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) BARRIER; tlb_probe(); idx = read_c0_index(); - write_c0_entrylo0(pte_val(pte)); + write_c0_entrylo0(pte_val(*ptep)); write_c0_entryhi(address | pid); if (idx < 0) { /* BARRIER */ tlb_write_random(); diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 1b939abbe4ca..c96725d17cab 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -290,14 +290,14 @@ void local_flush_tlb_one(unsigned long page) * updates the TLB with the new pte(s), and another which also checks * for the R4k "end of page" hardware bug and does the needy. */ -void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) +void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) { unsigned long flags; pgd_t *pgdp; p4d_t *p4dp; pud_t *pudp; pmd_t *pmdp; - pte_t *ptep; int idx, pid; /* @@ -326,10 +326,9 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) idx = read_c0_index(); #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT /* this could be a huge page */ - if (pmd_huge(*pmdp)) { + if (ptep == (pte_t *)pmdp) { unsigned long lo; write_c0_pagemask(PM_HUGE_MASK); - ptep = (pte_t *)pmdp; lo = pte_to_entrylo(pte_val(*ptep)); write_c0_entrylo0(lo); write_c0_entrylo1(lo + (HPAGE_SIZE >> 7)); @@ -344,8 +343,6 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) } else #endif { - ptep = pte_offset_map(pmdp, address); - #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32) #ifdef CONFIG_XPA write_c0_entrylo0(pte_to_entrylo(ptep->pte_high)); From patchwork Thu Jun 8 19:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B850C7EE29 for ; Thu, 8 Jun 2023 19:18:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11BAD8E0002; Thu, 8 Jun 2023 15:18:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CE1C8E0001; Thu, 8 Jun 2023 15:18:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB00A8E0002; Thu, 8 Jun 2023 15:18:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D89418E0001 for ; Thu, 8 Jun 2023 15:18:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5A1051C7993 for ; Thu, 8 Jun 2023 19:18:43 +0000 (UTC) X-FDA: 80880542526.29.95AD213 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf30.hostedemail.com (Postfix) with ESMTP id 7B9EA80012 for ; Thu, 8 Jun 2023 19:18:41 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=HEwZycAE; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686251921; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=L81/Qpi86rd12Vcvj6pXdl5LdTXczY5RkBCwzrmETVzQpm5Br2crQLfqtwWLDxKDCbmanC 4icNB2el49MvnRk4gjSZTRI9tDtroRjZmv/yrcawOVYZ73qneC7SuM+7BZyRBQVnU1nl2Q Uxx+bD+iGCGhyG9uL/THVJfgTWwwhNE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=HEwZycAE; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686251921; a=rsa-sha256; cv=none; b=lQvzmgZ+YkUaCG+X5rvbxdWZsDBELBebhVZ+1moDJOj1huzEZgIq9SmMFDx+KwazqcGHdT nVoQy6aYPdY2vOkV6mw7yvuiBaf0TIA9pK+O58OchAYuLcmpM9x5quvWxGXROC875ym7X7 eWAcYcQxeEkCJm2CmoO7TAo/4DF0xjU= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-565ba2c7554so8639727b3.3 for ; Thu, 08 Jun 2023 12:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251920; x=1688843920; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=HEwZycAEZshzMQG1RY6xWzkEzRNEN/UEaemUkYXNmWskdkmVKrA8S+97io6IqWp9/V /Ki/r1s4TSfiiefdOd1an7zeCiAQCXani7OPWb0Yu0dH1JXoMBV7ddckrsj8wmhXsvpX lxVVQwwTUjyQXS/CCeF4VIDT1g2/zM6/NDtUcqQOoZLozwlnlFrDor/PrqoADqkak2qo deaYgmKHf6xqfmf4KVoYNd/vj1wQpn8eoXEC4WQqeZC4WPbGo41LYWdy4IN4tXqheqG/ 6B0lxLrh+XpboJCYpvDK5+1gNhnxK8xFzRPNdKypeMnMcoGI/ayoAWXa0T/S7aKkyUXg eIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251920; x=1688843920; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=T9wPlx7KCeZMsmt0T9D7X5ZndSOTNFN6vtEZhxD6XjGX8YVJHULTogdpuxOrYqiRVc FkfXIJhX3c5Bb1V0Lau20OVox7PZEjqPTSr1jT/IukoUBK7+LulijL/bnTIjfKLTw0C5 d4ZKk6vAY1Hat3y1QVzypRof/V5kIZGyDHT5ZFFqPBOJS57H8y4LiZSCxnY/nyLPQIeS oeRYUjneAIFZwT88uI/P+XVVZK4TvjSvV3FunDkYp2AdZKkFtqrxY66jn7N5x0QuX6lD zvVJL+JkAItMgpkbvle5cZuEBQSSD902UMSXuhZMj/nPyyOYY95Jb0E7edij5aG5k19Y O8rQ== X-Gm-Message-State: AC+VfDz88/oj6S2kcFC7oacHX+AFdoThL+HITMip/lX6IdKbCFRJElQm Vqs+CNSG43dkASXusY1NGNrIkQ== X-Google-Smtp-Source: ACHHUZ78uQ3KAa2UlmiLkPkJ1ItAoVICWyvDzVcoJt54uwUIKvQ1XvbxMYD2Oe7/oQdSR2X0isfU0g== X-Received: by 2002:a25:e307:0:b0:ba8:7f98:4afa with SMTP id z7-20020a25e307000000b00ba87f984afamr579046ybd.26.1686251920409; Thu, 08 Jun 2023 12:18:40 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 22-20020a250316000000b00bb2f5dda19bsm432908ybd.47.2023.06.08.12.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:18:39 -0700 (PDT) Date: Thu, 8 Jun 2023 12:18:35 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 08/23] parisc: add pte_unmap() to balance get_ptep() In-Reply-To: Message-ID: <653369-95ef-acd2-d6ea-e95f5a997493@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7B9EA80012 X-Stat-Signature: 7qis6sjwzfpaso8shtqz5qm44phs9chd X-Rspam-User: X-HE-Tag: 1686251921-655008 X-HE-Meta: U2FsdGVkX1/ODuCW6lTJ7KBSW+hRpwgFs8aJ/8dLx0Md6H9mtQi3NILvo3WimVDZ61GFGr0AS74ywgwQDFLiHstYWpW7FRUKCpNAA10h63w7d9SG6n0NQcT/I8eGRwmHQiKQsAHXCvlpujsEPf8bJrACwTdANdbov8QdBlhxPDDUclR8RDfEdMn/+73b+xnjTmvCIkbnmPEHNXP2eqrtMAh/MHJDWE+JyBCKVJDmSDf4nUpIOsLlX5mzaq06QkQnYyzKCT29TlskHGgQD4PmK2X/IcokG6BV9mE7fQKJatILYkZvZ+Fqxx8B903aQhUAzMu/lnxuABSh7nxSga0o0BJdkWpwke+nQcF5AaHyDlqB+/C5/nGS3oapMOUxdciC39HWOw9qii5RYeQnMN7mXbe27b/2RmpMIaf7rU0R1bjoAQFQjIqr6QLv097N6H8oafN/LbhWhqRBIjQ4P39EbSUyHVg/WCKrGRuLanM90Cb7GA9FqnHq0Aefy1eBQXfMigxOgGMumDhulZwvKw6rwsSA7ZvhuVXC8D3n3tquJIq2IRh2m+y5RqyeaDb86Azw+uCySHoD2u/xJqQs5IsDHuLez/65i3INM+/PJjVfuTAMfcp+MEmv0T9tVCUTeiopXrutVLa2Jjt2a+H0DbSyEqP4H/7ETFrboAZ/wbfoXU6a3c96izB9nh4Il116UDmwfc9cjVgKYItzYGpLX7vqU7ziJbDBCzB++LLnfcawPCUJt1V71qFbGASY4Is5Jlbmu+XjaIyw1x9/J4tzP/VPeBFwyXEtlSZuSjijjiKwFnX2lKrpa3hFMQZhWZtQk6yhbueVrs+UsmYetiO3EEpppBngYnqEJOOrrSbFmJHKnEwW9tXSOE/n2ZKLSybp7dp6BQ1naL9veJVdyQqWt1d5jRVWvsSWbobEUpPKJ+T7oU09+Zf4TwEDuWFlsgvxUaK215dzYhqMqlEtTDf9aD9 hhJH9JUw 31/VV3MEvfDu5rK2ScLOhTlLVtBrCg6fL+oh83EzLweIMzyIx/+lI2IaYI4DOMMc2bvefFo/Q69sDlonU0HT8JOuRN5DoV0G66d7sTv9uJ5DC9ZzkLUqlN02+DcEEfqIb1V3tq655g5qIT0OIQoqbmJv0JkEVUrWH1wJj30etDx3vD4sNtmRw+DuUQA0GkN0f/Ueqb5hGdHky5UievvvAGNxsIvxhygBrg9aJbdZY7+fs/dFsSA4srm1laoqt44BILz8sOCQW67dW2svREALu62FeGZzcUO6T8Ug+ZXOLAtExihBH0yDtOoWaWY2aaT5zkfpAG4P/UHXxHebx/YiNwDEsYHjk6Q+QRO4quQ8EyH3FDDPJx2UttSrQ85sToc41SisTRodit3EEX3SLsYR3wYyLE2Jijif9ESlfVyfXEmpyxyaP/6XHHOrchA== 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: To keep balance in future, remember to pte_unmap() after a successful get_ptep(). And act as if flush_cache_pages() really needs a map there, to read the pfn before "unmapping", to be sure page table is not removed. Signed-off-by: Hugh Dickins Acked-by: Helge Deller # parisc --- arch/parisc/kernel/cache.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index ca4a302d4365..501160250bb7 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -426,10 +426,15 @@ void flush_dcache_page(struct page *page) offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT; addr = mpnt->vm_start + offset; if (parisc_requires_coherency()) { + bool needs_flush = false; pte_t *ptep; ptep = get_ptep(mpnt->vm_mm, addr); - if (ptep && pte_needs_flush(*ptep)) + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pte_unmap(ptep); + } + if (needs_flush) flush_user_cache_page(mpnt, addr); } else { /* @@ -561,14 +566,20 @@ EXPORT_SYMBOL(flush_kernel_dcache_page_addr); static void flush_cache_page_if_present(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn) { - pte_t *ptep = get_ptep(vma->vm_mm, vmaddr); + bool needs_flush = false; + pte_t *ptep; /* * The pte check is racy and sometimes the flush will trigger * a non-access TLB miss. Hopefully, the page has already been * flushed. */ - if (ptep && pte_needs_flush(*ptep)) + ptep = get_ptep(vma->vm_mm, vmaddr); + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pte_unmap(ptep); + } + if (needs_flush) flush_cache_page(vma, vmaddr, pfn); } @@ -635,17 +646,22 @@ static void flush_cache_pages(struct vm_area_struct *vma, unsigned long start, u pte_t *ptep; for (addr = start; addr < end; addr += PAGE_SIZE) { + bool needs_flush = false; /* * The vma can contain pages that aren't present. Although * the pte search is expensive, we need the pte to find the * page pfn and to check whether the page should be flushed. */ ptep = get_ptep(vma->vm_mm, addr); - if (ptep && pte_needs_flush(*ptep)) { + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pfn = pte_pfn(*ptep); + pte_unmap(ptep); + } + if (needs_flush) { if (parisc_requires_coherency()) { flush_user_cache_page(vma, addr); } else { - pfn = pte_pfn(*ptep); if (WARN_ON(!pfn_valid(pfn))) return; __flush_cache_page(vma, addr, PFN_PHYS(pfn)); From patchwork Thu Jun 8 19:20:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB72C7EE23 for ; Thu, 8 Jun 2023 19:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDBD98E0002; Thu, 8 Jun 2023 15:20:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8B6F8E0001; Thu, 8 Jun 2023 15:20:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B545D8E0002; Thu, 8 Jun 2023 15:20:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A36B08E0001 for ; Thu, 8 Jun 2023 15:20:08 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6E4481403CF for ; Thu, 8 Jun 2023 19:20:08 +0000 (UTC) X-FDA: 80880546096.11.74CAFDA Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf04.hostedemail.com (Postfix) with ESMTP id 74FCE40002 for ; Thu, 8 Jun 2023 19:20:06 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=mXQ7UC6c; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252006; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=4fFJHMuwHpwbFcdI17I7e1Dga7TCrFgx52Sr+HYrT0AN0kei5mbG2yfsERGHA8Gvrku4Vf 4XxicPnuFUSClKWP+jp4GisdvgKkt4qVraYwC4mPywxFa6yZOueiEFhdfhcSToAZwz1Hz/ 4RxzN6QN0rFeD/JL9Btwa+XlF02j3v4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252006; a=rsa-sha256; cv=none; b=WGcUzRYlccIc79aebmiq6sgXRlNhan1U286pnK2aqgyIY9TS/3fV5kq0cTuu38QYvB/vQH 2lvJzRejCaEvARrCT7MB2MG2sdD6MC6bU6gJ8lcxoV2tvJk4Pf4EpL4I2ZaRZoPwrKXU6f LeuZ54rPY4qAwYnzTJj0j17sVtIyQpY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=mXQ7UC6c; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-ba829e17aacso1100565276.0 for ; Thu, 08 Jun 2023 12:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252005; x=1688844005; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=mXQ7UC6cKQLLZIQ28oFk9gQ5KxeKVwwY9rk3e7MKP3JMMgFBUS0Y4Ow9xYO3QBbWBp OG1o7JhalsKeTrmK+H6URVPXbxrefFexNILlJOVSmAp7Qw//UVTcssC14O2AbNOpA95o 3fphns61QjibpjRegZHBgnDNFY4BaX8z0yU2Yg9FB0o8UxxLFxwBrXonk679QJW2NVtL a5CA3hBH6G8j2p1GNpc9/KN99Dv4NvapDgXnvT++Pvq7LeadMsdSuwcoq6yEHgW25m/P tlZmPB8WvPaouvvNC3jzVDH6WgeuI0e6ggHbT3c4Xpt7le2+MhNk3DZW5USJxtb/KL2r qm0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252005; x=1688844005; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=bF3kOk4+hU5l9H4vquDeILcG3uxjAQH0UdG0Q8QdsTOUoEoyzuVTxLjONbgZGpNqoy M/tn/SNHuhTZ3MyHk3zCsnjZ1m0lFSN7mJdMjxIMdVlJE2Urm4TOrmx8orMes5uIfIPF pRRMAa74EMuPtj+z22ZNviYxti3t2H7f3BGs+/VQGetKp0qaVhNCqtjnViSqc3/aThZo ejrumxpO28kYwQA5fn52uUXSHKhXVk+NkejTB5JDACJOrG65EG8acX8n5Nlzw2q+Sq6y ui8Cw43pM/EuloAwUIE8RchrTGAoOg8998wf8I5X0RwpazkxFmVY0C8yRgQg3Ev1HzN8 vu9g== X-Gm-Message-State: AC+VfDzajwhttbbNvqsdg3uo9i3ei4F/NfaiVU6M6PNKQRzDxPqmAtyA 9ZucY+4hFOJAYK/mkDzSL110Bg== X-Google-Smtp-Source: ACHHUZ4wGfYoiszAK487KBc/kae1dH0iFiJPU4oIJDoWEvbSOVI5OJwBbX6lcOBaT8/42nfo55JclQ== X-Received: by 2002:a25:ce90:0:b0:ba8:16df:e3f5 with SMTP id x138-20020a25ce90000000b00ba816dfe3f5mr700600ybe.0.1686252005314; Thu, 08 Jun 2023 12:20:05 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 2-20020a251802000000b00b9dfcc7a1fasm446566yby.7.2023.06.08.12.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:20:04 -0700 (PDT) Date: Thu, 8 Jun 2023 12:20:00 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 09/23] parisc: unmap_uncached_pte() use pte_offset_kernel() In-Reply-To: Message-ID: <358dfe21-a47f-9d3-bf21-9c454735944@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 74FCE40002 X-Rspam-User: X-Stat-Signature: f59ksgxjsrtcrth8wjgnkkd646ep4ddm X-Rspamd-Server: rspam03 X-HE-Tag: 1686252006-578845 X-HE-Meta: U2FsdGVkX1+biKWIknwtaVHs4dyJRlNgicrdE3B8sGW0wehoSvoVQuJX7B+sSrEVeGy01WJNT4QiY+wvZYjfAGLtbK+xxte+/IQYHKrQsACi0rVNuaT2dNMpCTQEtk9cGvyEHTSbW6wy6KMXGCiDeHAYufoAg0POrOHm3Jch/JmOH1qNXyGqWrFpeEPu/7rFb/TBU8qmkvl5Ae4eY87EMPWf5jyu8bTZnxUkL9UIDsdiOi2xUnP7MQjI6JFi10TW+Tf6wc76X26KJx3MZ563B79JZ3sQZay2wvLlbvD2Teu6kdi6hKe7Tn0sfAzLfVMxA0HyyzCFthY3m8BpvWAgxoJs/QkMGFvCz/xocqvUSKqPfCce2P+RMd/PkeOS6Mh7YtXm7WHsQMM/naO9AeYhDCWlSW8oxVWzwoKqu7loPA064P/uQc346Sa/sVezslbKpDS1Hkq7GK19mrgtErhImwtMWZE32fSsmv+q7WO0P5daAFKzNYHlOQ0SSvS7X8D+8rPuOFt1w04mKVyB0kklA+GYkjetLgJ1jholILU9kDhnF8mU9i5DgWj2AdEvbN7AtcLWR7B5Pav5U5qTWuKijS+FYYZ/4F4PMtdyDw/0wFObaUVJLpwP6ap3VKJ5HHc099YM3I28cK8sXOeQWB/JD/ynfi9EL30MrHXRBuAy00b2H05EfDiUXJe9M7YoDfv57y7OBmtt0fdbEJwo1XoPxPGhXkZ2rjrG6tQQky7uyMVA0WB9pH12MCJvMkFAQp6exQ6AXbsKGlqj4dm22B1cDOPSXznZwb23IklSGKwmlnc0ye4uCFPF/SNOsGn0AvWspbYTP9sdPlnij1jottyYbY42q8cJTMbwhy0RJDJeEkXPSri59MSjRFPM4nth+kRUqBkq1LjgazCy6svOSGTNzcX9pUZC6hNHATcD2lHuZnje9vmB/OuN2gmupEOpY5yG1cVWYLrV2Pc+wPRJTXy P4B+xRhY fGk/9usCVVeCAtCOzEp9xLF1VmkME7j39vlLHAN/Sc+jPjIwH7Q3nztZqK+Nk8jwqRjdhjhNd+ZA2fcqiWHx8OypuA97e8yuAnHZnbYw9KuNY6HOAaFndleOdLwn0nAxaW5B9U50v5dTZiqUZujOQWJuy29dpejb4UdwYMurFRKG/R7X1ekn7Qa0rpqG/8cOqMOImfv/hjIcU4kZyISpQ8uMECRG47YrmLVvRzZ/fPLE80LN7hGt7z7tlvjjAsmk1AUK+AG9/G34ED/cl4WzIuvRSq2g62RJWAURjiYKsrYDCe4cLyzbetyiRlAR3i7XAsYZed8wgBYVwnGxVJrfthtlcnx49Z1tEotJ2KPzkrJe1NyX2tl86P2kjR/vLNIZQFZU24HXPy0/iYTblVU9AAIcvpyMnPnOaTvFK5MS/ZQwu8SL9TyXiKwVPrCAXOq8MvmxNasEystgjtCw= 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: unmap_uncached_pte() is working from pgd_offset_k(vaddr), so it should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/parisc/kernel/pci-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c index 71ed5391f29d..415f12d5bab3 100644 --- a/arch/parisc/kernel/pci-dma.c +++ b/arch/parisc/kernel/pci-dma.c @@ -164,7 +164,7 @@ static inline void unmap_uncached_pte(pmd_t * pmd, unsigned long vaddr, pmd_clear(pmd); return; } - pte = pte_offset_map(pmd, vaddr); + pte = pte_offset_kernel(pmd, vaddr); vaddr &= ~PMD_MASK; end = vaddr + size; if (end > PMD_SIZE) From patchwork Thu Jun 8 19:21:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E9BC7EE23 for ; Thu, 8 Jun 2023 19:21:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 671E78E0002; Thu, 8 Jun 2023 15:21:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 622558E0001; Thu, 8 Jun 2023 15:21:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5118F8E0002; Thu, 8 Jun 2023 15:21:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 420F28E0001 for ; Thu, 8 Jun 2023 15:21:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 14F171C7A08 for ; Thu, 8 Jun 2023 19:21:15 +0000 (UTC) X-FDA: 80880548910.02.F709DAD Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf25.hostedemail.com (Postfix) with ESMTP id 414EFA0011 for ; Thu, 8 Jun 2023 19:21:13 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=HKd31Lqv; spf=pass (imf25.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252073; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=HUHoZ/aBAOCl16zTkenD7mEg4Ghdr5zJgx/UL9k71h42w93oybFyYSdNpHNfNRa36hrCbh fl0Tanv7Ahq5JE57iTOQFVwOyb768jbjnxV1U0RPihq6xW+qSOVNfCdXLsA+XMxY7EvaM9 /w1ZCbJbUOyi35IhA44ytmXJ8O+Afu8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252073; a=rsa-sha256; cv=none; b=aLE3i660qN/9iN79KyFw+cbMQsJcmuEsf9dEaonvTjDIadUAlKuy3j50Wx9AL3FEPgVucr BLXbNXEpwVUAV7eHUt/XxGMNskOdDSkdhxAiF8VKUh8BZ4tfeij1hHnv8WOdeWzo+eisdx +dvgb9vyVTdhZFgki+bLHEDTCTNhQyU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=HKd31Lqv; spf=pass (imf25.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-565c7399afaso9156227b3.1 for ; Thu, 08 Jun 2023 12:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252072; x=1688844072; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=HKd31LqvAwT3pdB9H8RTJjakAJAT9HvglTvKC+OkvKmv5VhsoaZHAtLpo2tFkCpDhK eaJn1uAawotb3pLd5xLGg7DzD6kDQrKAHxas7kU/r2KN0gO+8LwEgaLotjlfcSI+ExXP OsTJ1O2tfGB1hyPd2BGfO1Hv0XjmUpnPR5LgmonoIasqGq2fAG/aN3V/iTrXbCwGdrUM I50yE5ZJKvbdrlam2CeJEmfXKvbJkG9Wl49W11ZHf6B9xR5DJRVBfUy3eWMAtZhLeFU3 MFev89ALFBnRCYsOlrl0s+V0pK/HvUPQhOTjtpCkmArqzAHuVaF4G3AF2HiTPrlcql5n hmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252072; x=1688844072; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=ieMgSw56JgZMkC78S2zssyQK1kkVemfzKxVlqv5fCpZI9HVzmECk4u9meW+p1vpNeB oZDHOY+UByFuKqr7u1fNOLfdYx3qQhM82NdYEJ/EBGHA5q93sKVmArVP9Rp6+TKClv+5 JSLBvr0l8BmWiliGKltqURm2IMHZjG+7p0RmIMNRV2a6Hx6AS+zHBuIokAojrbxUX8rO MrCHwgMyfGwd4c6MTVbHitp08dddhokcANSznZCZAnDpacdV4fHK84xCr8Ft1EWLAo5K kESOytk/CYSxCvqzfkrB53hTmQaRAv8Sf1/fJ3yiJ2Ap7JnbclkHSc2l36ak1/+MmoFL 1d3A== X-Gm-Message-State: AC+VfDzi+xK2bPRH52xPO2W/QzzzCXQjx5XuZDaEOYMPMV+nRWvZmqfg NhEYlmz4D/f/59b+wB3b6EYPJA== X-Google-Smtp-Source: ACHHUZ6osQDL46P3M+nFsTgwfoyN2ZCBLpMaIBhxVjRNKZnry7+6/FcNKdRpu6hPkSNVLheeDpiVWQ== X-Received: by 2002:a0d:d98f:0:b0:565:ba4b:aa81 with SMTP id b137-20020a0dd98f000000b00565ba4baa81mr612161ywe.45.1686252072277; Thu, 08 Jun 2023 12:21:12 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f184-20020a0ddcc1000000b00552ccda9bb3sm108635ywe.92.2023.06.08.12.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:21:11 -0700 (PDT) Date: Thu, 8 Jun 2023 12:21:07 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 10/23] parisc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <7963aeed-f7d2-e0-f3c6-3680c5572444@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 414EFA0011 X-Rspam-User: X-Stat-Signature: sex6fqn7zdred45fmmesn94et7w6qo6n X-Rspamd-Server: rspam03 X-HE-Tag: 1686252073-530389 X-HE-Meta: U2FsdGVkX18N9OlSV9WLYpYuktaPMfmQpbpdnfGgx2gETZqgrABDPIoA9KveDau1pAZybCKuNwH+eFE7IRNJAtcM6v7o0TkHIs5x1EhqhzCRA9Z9JHamAnOTyqyGSGJZ9mTpA3qXw6UtbVRY6LndX9cgdoJy7ZrQOwFmmWlBPvfqF8drofFf0e/wn/Y7GXaaESsLAu4yNUmM+Ay1M68F6LFWKLNoQtcJ850NdOsTuDAdpsL1RdeZBbseBrrKCPjbITeLrK79E5tynbUXH9GfZV2KdQAWokPSUsrvzjL2Tb9mX+d3DSWfqM3SssYgZUdztuffBK5W3gj4BWYfcxkRgCC81zsu1mlwmjU9yVuSDWqd0xlFyHN4scvPPWpFZgcgusVj7HiW/yAl2cg37jnlpA7xpxUuDIGkra48VSFeMY0ijOQz/F27eFGY8QGsfNX+iR1PjuhXAhMAKb+x3q369q58i/Cqewe5csO7YMEQOCY3IgZ4bkXVCugk9kprdVrOiyf8rVcdOLgrd2H/LY4gRfIehGyz72RAAl6lhS7FG9vKu5Jiap3AGBw5utuRxwkYEZWZneQVLnhuIeHKd4YOIdDe3ZNuswPIppxNBFdICFxCiGCLuY1uixxxim97n3mURm23huepjmEzCIJPoaSs8NbW91572NRJBebIVf/PUkTLVEtptBhtiWvpRlq1cn++30CJbovQAlRGYE0OGNJZcG3ZuCw/NCqz1FVq18+d7FTc8dykISoLhIWHeuk5cDLvviMrnbDV8vP+p0snK73YjLLv/JB38nNzTrQjFlubUk54ir2OaGu7rkw7GpZYxIcuCJhy+qXD/lYYXicECa/F/8eApmzneTY32+KC6Q2VxWuGrZccaUMZHSa90wmDEeDEfJoWjI8OQv3TW3qSqYBs2j4x3mqxU4s0nagrUQbQLsYKL8O4mx/76/ejDGXc3ObDn4pkm5GZjW6Kyf5Izg7 iipYaqfy 1KgwNPRxOnfjI75+I+5zi5u/4szmrJZmQpDFgBPDe7qEtGeeorNoQSxCuTlaw31tYGApw/LigbzcceaDUrTUNETmiY/ECXa/m9bsRhBZGTohXCMM6qw/mYav7ozqdicspeUH3kbpsu4dvjcmc+Isg1IWKc2RGZPfG4FfKVdBZS4dBz2YnS7LQKHmgmxqlyvgqT1DBvNYKvHXfbFY0P71lga9+yPpe2w5HQTlgtsWDXvR0TYakxSe8es8CpQ3nP5g+05tHG/LHkffClu6n3pbiA6Uz9sY9LzmduLIEsM3GziCu/ZpN2Pdfeag5f32VB+2XjIQi9N0ZP6PrQeiAqkoRK3Yi9rTnZmRoLc9AVl+MIy+AdXKfKwFc5Df2uhLCFtlLIj9Yd05bAFrsX5lebsISAM4+pzjyoTAPB4gxt5xjimcvuIaqPVbJ8an5rg== 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/parisc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index d1d3990b83f6..a8a1a7c1e16e 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -66,7 +66,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_map(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr); } return pte; } @@ -90,7 +90,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (!pud_none(*pud)) { pmd = pmd_offset(pud, addr); if (!pmd_none(*pmd)) - pte = pte_offset_map(pmd, addr); + pte = pte_offset_huge(pmd, addr); } } } From patchwork Thu Jun 8 19:22:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87330C7EE23 for ; Thu, 8 Jun 2023 19:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2526A8E0002; Thu, 8 Jun 2023 15:22:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 202AE8E0001; Thu, 8 Jun 2023 15:22:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CABA8E0002; Thu, 8 Jun 2023 15:22:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EFD6F8E0001 for ; Thu, 8 Jun 2023 15:22:46 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C15551A0312 for ; Thu, 8 Jun 2023 19:22:46 +0000 (UTC) X-FDA: 80880552732.08.0703B1D Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf11.hostedemail.com (Postfix) with ESMTP id EFA464001B for ; Thu, 8 Jun 2023 19:22:44 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=5jRACtmO; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252165; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=p2pRgG7qjHxzOwpMwrsZUZvDJ+2oKg+ODH2epb9nl6HLyhU1YzCFi7ruCek5p/UmX1x1I/ SUrzsT9xBRunt0hWdiUVah0EBxra1vZrWNB9ewhPoA0y0MoX6AkZQvNdaYMwdJqLbkdhUU AJhcPpCJWFOrEPDO7VEBYrqpspudS6g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252165; a=rsa-sha256; cv=none; b=gZJTBPlbYzE7OS3pVjvfBG3BsalpyWY/Tq0auF85hjoz0jos9VCS4TaWAt0m9YIJ4HlYVm +ihVCkjKlJp4K+BtCCbAcmb5YlyHgKno0gzJvstSddMUgzZmeay7v8FdZSMKehzjmWQYgU qusVlkcCEhMRP4EIdvZ6+vFOWrcgrEA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=5jRACtmO; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-561b7729a12so31109707b3.1 for ; Thu, 08 Jun 2023 12:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252164; x=1688844164; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=5jRACtmOYl24iPoTbIjNRpyUFAC/FI9lpuvtUNHnC43m7VYioQ/BjHL7bdRB1Sderj Ku/HQKtR0qPfeCfubIqZ/AIBxONFw9MhEvcLPL8cbaxLn3mTiR/nWL6P2PCLjm+BwcQW 0EgQz3QqN/pDsKtdmzyltGWnacSj5IwEptrUle8FLf/akecGFE+OR3UMPvCEsj1BvLU9 B+ORl75p95EI9Mde8VL9yv1b1t+G7YgfanAmLLFyt7bpvhgPlWiVhcJ7Ue5u8gtJ1wSb o7+vcjNZQIk2HsdRh5Pl//khJzNempIfA/Kf3RkDsGtD4+XKnKjXxiMtp0DlEfTwETu/ 3u+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252164; x=1688844164; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=Qg2J3dNGM28lNV5r/9zVOkW3RwhJ9GRwwqSZT+8RlU6+sHirQqlohHN+bmSisUQD0J MCmQEgcQ38KVAbUfiGhgBQNkkDqMyX+07hexJJtDryF58iLr818WBrOxZrVut6sm3Ydz Bm+z4QWHAa8dZFdO3zJJfENjMSEnP29Om0vB3BoM4z02kDQjPBnovGUL3my1yfqTDOKE jzqF2h2Qk+bjNc+xlUek/T4fSKDtHGL5qG6sLaqZRRs9lLqxptyigYaoYELeg8hrHTFK DzIuoiqruxIQNk0A38jn4whNa5BnDmzBhVVlI28xLuIbBfJEIMrY9at/TNI2bvddTy6t 0aBQ== X-Gm-Message-State: AC+VfDzhg/sI8QOx8VEXwNo32v7aDAhXZPA1bJYLRse7Gf9WEAkMW76r wtsyVp442OouD5axNEM9s3o+8Q== X-Google-Smtp-Source: ACHHUZ40hyaOIkdH7B5oJObv6N1cySgcI9o6+PKHZNW5ZVazdwvrvX10Wz2CSgkv/8emrW9KOXZU2A== X-Received: by 2002:a81:a08c:0:b0:569:ef9b:eda with SMTP id x134-20020a81a08c000000b00569ef9b0edamr823988ywg.10.1686252163900; Thu, 08 Jun 2023 12:22:43 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id n126-20020a817284000000b00561949f713fsm118018ywc.39.2023.06.08.12.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:22:43 -0700 (PDT) Date: Thu, 8 Jun 2023 12:22:39 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 11/23] powerpc: kvmppc_unmap_free_pmd() pte_offset_kernel() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Stat-Signature: idqcd78ecxmbpkypuc88dgemkobhe8w7 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EFA464001B X-Rspam-User: X-HE-Tag: 1686252164-14950 X-HE-Meta: U2FsdGVkX18KvJJ7w273bqTfxWxMHDKjc5R70ia5zMpWFbKBZhjHsX7olOqVsPWNsasd+Gg0O7ZUfHsiIINfmcCgyaogS7m9iefNiz2dJpRSqncUEH44DkA6jgW9rfyIoLagZYK0F2adTNRTo8PZs+0AE7NRZKHfNlm3xPBoBzHX0U0v3f16m7h6OEA86X2xPckeveFyRnWFwCl7JYZQ2xG+fpMbC/hX9fGBmzl4H0D2UGAF/R6/0OeyklEQT2ZWc5ezBw72TLz4+rqGAIAZdRZFPFHaaM6thr2lupYcB6VGgnGpFecyQhleHiR3Uz+o6WqycrN2ZnV9+J9wJgcm7AWXSWOkpsOSC4bRbKcnd8h+OcIgMqb6gNNsHfiM7/SlZMjtlIwxVreh/7Jx0jxsSf2V3zVz6g3r96/6w9LBUWF4BfbzERITQaNujGBwHKDDPEo41ASOROLdtJDxrFcH+r5EAyzulU6GUP9FTRXJON/YUSbCsCntgPp0XPC/9OL+vT+5FkQ2uh9s9s8rTpCOfLUtJu7kM77io1uC6klJ+MViD8SeUjV3M5nl3JOPmWbf/2Y/6iuzW3I3VukUVN6lkrbe37yAwiHzf0BbuLhGwiwzDzenoiydXPnCdrN5EO41Jh6HhSlTrW3dw7iBuysCibz2Us3dIU951YbOJtu3khv/8IDbvVLL32ZSo3ifHvewdZWV3o37sEA4fxvkbC3rS6WDGV7oAVNh8advy3do3vPyaKZaCaEAvPQywgvY93xOx07+7rWcIzE47D0RmTZT2xA1BV4sClqsCeJDz1oeL5Ib2lpsmVfBWcsyUzQsLkxfEJ5X24gdY7kVo6vt8QRElZKNpM2nmsZmwLr47VrxBQUZjhQ5xJ71WLsy9I15h4yE7C/IbjiINs7as0ErsbVVf42bJTTlj+dgPxHs4il3Pv/EOI9/6c8mAwFwXqLhTrP6kPZW7iD+hdNWC9ojOU9 P3JzMFOZ 98g5Jl7y903+SGxwRq6uFT98tSG3uA3562r4FbQy+Z2hl8M7iw0D3edf26sPVGgDhqyDlJDmh1iNcj1E6KiK+gStRwwk6m9HyFM9MFmMsZ/TO1w4sYjrR8+mnMeNbA0M5XT/Xuh0AOIU98guFQmkQmxfMBsd6mcruqBU0ZtN6pokg9r4702SViN3cJ+wL8UnCP2neOyIWQr4pT7QyRm66ljvpnXSiqU+Lf4Vhop8YLmRQNUAx8z6N0694Ju8iRiIV3NsHMo2N4/Eo5qEQcEtQu52LNuwwuIh+Idrw4rSJobCOBk54nPB8ve9jmCAIw5u+aWGTqCcvEe0ZmcMqChO9WS6bN9o2jIlh4s13UKNYQ4r86ifrYTr+p5s/1YUHMOk14EkUuzgNbvnDXFlYPajHz8CouKbhcXKx6Dn5wiSix+W+RNdz1ualWI8gBQ== 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: kvmppc_unmap_free_pmd() use pte_offset_kernel(), like everywhere else in book3s_64_mmu_radix.c: instead of pte_offset_map(), which will come to need a pte_unmap() to balance it. But note that this is a more complex case than most: see those -EAGAINs in kvmppc_create_pte(), which is coping with kvmppc races beween page table and huge entry, of the kind which we are expecting to address in pte_offset_map() - this might want to be revisited in future. Signed-off-by: Hugh Dickins --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index 461307b89c3a..572707858d65 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -509,7 +509,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full, } else { pte_t *pte; - pte = pte_offset_map(p, 0); + pte = pte_offset_kernel(p, 0); kvmppc_unmap_free_pte(kvm, pte, full, lpid); pmd_clear(p); } From patchwork Thu Jun 8 19:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D919C7EE2E for ; Thu, 8 Jun 2023 19:23:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E39B48E0002; Thu, 8 Jun 2023 15:23:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE9C18E0001; Thu, 8 Jun 2023 15:23:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB18F8E0002; Thu, 8 Jun 2023 15:23:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BAF378E0001 for ; Thu, 8 Jun 2023 15:23:42 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87032160492 for ; Thu, 8 Jun 2023 19:23:42 +0000 (UTC) X-FDA: 80880555084.22.9493059 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf15.hostedemail.com (Postfix) with ESMTP id AFB3BA0012 for ; Thu, 8 Jun 2023 19:23:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=bsqS2Hso; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252220; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=3Ula9pttfLAL+C2x55Uv6zL59EmWiJ99pii+uBmSLYq2Ae6vlLMnizAWGnvGiFsL3L0gCR tiG/7PNeTMQHh2FwAphV/+cTxPG0aZBLB8IdusrAeN6EtjV52MdpydAFZulTKU2P3Hlr9O gxD2QtdHpKztfXnrX0d4zyHKkLSbITA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=bsqS2Hso; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf15.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252220; a=rsa-sha256; cv=none; b=pnqbubz/WHgeyMdsONNNzYRtNJWMTQkPrFDAuPode96XNwDGtwfuhva6SJquv4VSelu8qo GQlASTo9wKuFoKZwyxgM5UyAsCG+YhZnRJts0wJ43/szjMMyaHOzQuGac2sKBPRbFVPeIA QPdRP48mcAjW9csxGVIZhikKlCaywbs= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-565c7399afaso9178357b3.1 for ; Thu, 08 Jun 2023 12:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252220; x=1688844220; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=bsqS2HsoK/j3AkqW2YwOMMKXyawvBNLxJHVA5gOfV85QJu1lSu6OT/EudsU4V/Y2rp SVDrhg0mebSfRzfMSx1MBgwwDrAuWoy9LCmuC/2umX7ttwWByA3dcTWU9wXJ/cBuk8p1 IBLsaSZQWTiGTy2fVfGTVTLpxXSu83YUCgCeShfLhLQEtHAObGCmd/2pMwHoVzhnbL+s R/RqL9aWefb7+V22j+wCoHy3L9k9iU7LsdUzazOEG+iBjRzVfoBnNonp+eUMgHPu99EP wikBPo2R7DnOhGnbBte9FiJ408IVODR7hjXz04IiqDN6B3KGc/TbdicQd+c7pqZBIdYk E3bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252220; x=1688844220; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=R/8NVUf6R5bxSo/lOgS5FyIr9DVaFlo76SAe1XJv9IEajlNfPakqvXIa6+sc/+3lEb M5IsYiUPuGqCvYf/P14tpkh2F/6+jRoTyJVZ7imAY49GIuAP+d9kkw4QOsS2UKLg3DxG AUNCCfzoPWjrEtRAkh8Ak1aKBUxDTLyBPUk3uDJGYnECfqgWJguQDbTlburfkKvqZjKQ EkLl3xC4YdzaJHPnLpcoiGo6Pkm+mk5JKoBHO7/hKTVfJJ5eqPhvQTVIC/AkoYGR36aq eaJ5ZqBDWGilinD6PZAAv4IJ98nlGEZS1q87USyT6B+d1185BQowydYe/eaLkYIi2xpM rhzA== X-Gm-Message-State: AC+VfDwJeAian9sdxTAcQ3V5p0HM/nwY6O4/Vrk/6Vzzfshep/DwfN0y XGc3KAI7Q2BQnwJH5n6DLPepqA== X-Google-Smtp-Source: ACHHUZ5B2AQmlb0Co/ti6j7UtSZsz6kvSjI4SOSm5MiJUvPHp7lW170oPhZmXl+FiXgmdx/jiLqYOA== X-Received: by 2002:a0d:d843:0:b0:565:8c16:a0e1 with SMTP id a64-20020a0dd843000000b005658c16a0e1mr683325ywe.13.1686252219629; Thu, 08 Jun 2023 12:23:39 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id j65-20020a0df944000000b00545a08184e0sm102947ywf.112.2023.06.08.12.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:23:39 -0700 (PDT) Date: Thu, 8 Jun 2023 12:23:35 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 12/23] powerpc: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <54c8b578-ca9-a0f-bfd2-d72976f8d73a@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AFB3BA0012 X-Stat-Signature: 64oh87aa4h4jo497z8wewtxs99ypdgo3 X-Rspam-User: X-HE-Tag: 1686252220-140270 X-HE-Meta: U2FsdGVkX1/j2yXOzKVvFJZRLZ4WhskB2GxYMjYTQnZ4OhCfkOxVfjBQSRPw24fdZOzTC6vQSdC6rT6ll1gWxQSn5KVSTeJIcnTk59FJ4m8pXkwZ4M6Nm4U4BuON1Sx6ziCNwQP/qSFipXZXx086j3G2HTcH31+BRvGBFco5dJzlb5ykcVdoSjokjS6GVHhuK9M9G9NmsDyvV2HGuO5G+WZ/+Zqpitp3BifOW0Iicd37hrNPMHWyH3BxZQjxi0j2Ic/Z/JPiVbke8qXp3WQkTlILH2hDiiMIZ9wjW0NwLaTrcLiAPQRyCOv8L+oLoN6JO4hJbkzFTg9B5Vp1nv8HXUpD0LplDAk3CygFAwJAPP21jLGS+bu9h+BhyvP8KraTOd/WuMOBcwrfUYzTMYEhUS/LcNgv6RluXn5iOdg5pHYB4QyM4c6N92Z3J4LKw3Ov1T5SN25+qlGozO9PiCMzKHyM3I3HweoHe0Ubly0QW1n8fqZ9FUXgtHqlyR66PmSc0zh18rgTwZAoewEEj0lK1b8BXLduevXYyCWlv/S4u0SCZBMnItATvQBFCI4CyWxlqzgxBkClSTC/CETGCMsdCxC3VeAi7b4gBjfXls6tSRdX9Tfpw0lK+2foa2NvoHic+OCu4z5bF3xzahybFWisqIRG1PVmhdqQfLQzUd29i2Gm0sOQQOZ1in47jRs2hKfksGZI2beE23YUakJS0B9Pc2wNb2jS2aIMAnuM3Pk5i5gF/f6yaaEuekeivlFFzMoXqLrYr38xcJzxZ3L4vNgoYzKFB3T9zBUdW/b5a06ee4SFxUv5JTURK2uYGGb8JRu30Jqed5GPJrRfjPPH9U52R8pOO330nEYYHtE+INEIBnfK73R/jxMoJmm2+xURvs0QRRF+a58d+OQuxLe2GjK/cFfLeKpKDnAqngQtVEG+vuKE6jXYPPKeZdBMnKwqWpyZCeOqzZxL+R/wRchrypf LZTKVXzF +uZBINziXgTOdGyxQgQxiIX4d1yDJA3UjSKwE+oJoVykZP899YAy+7vlUSNut9f8BbuwNN7+a/6t0r4E+SuoBV4yd80799UccQcwWFKjEev2WF5lSnFshMZtv2Mw8NepFKCWvF2FT7wSSzT3fIsDz2qGhVyDmwiSRDch46bQy+DywTJkA8c3Jz2xNiwpnmzbdgYqIm8KZJHMEbqRlcoL+Ml2aIbTzYPNOPR9fSCb0ucKBLI4FFlp5O9/vRycGhNeVxL+GJVtblQR5WGotT7hN+yAWeGw0iEemefbmNEndmd5IPnqak8AN+26euAPYrPCc+7mbUVni3t9oO9z5QJtw/I4hbAD9pPmnRK5RW045n+Wo0WMSyTSWSV8QlbnEDDBkoqoVmkSU5qo+jzS3uhuOdfTeQyYeYVLQQZW5KN8mQgAG+by4AfLLWG7LeQ== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Balance successful pte_offset_map() with pte_unmap() where omitted. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/book3s64/hash_tlb.c | 4 ++++ arch/powerpc/mm/book3s64/subpage_prot.c | 2 ++ arch/powerpc/xmon/xmon.c | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c index a64ea0a7ef96..21fcad97ae80 100644 --- a/arch/powerpc/mm/book3s64/hash_tlb.c +++ b/arch/powerpc/mm/book3s64/hash_tlb.c @@ -239,12 +239,16 @@ void flush_hash_table_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long local_irq_save(flags); arch_enter_lazy_mmu_mode(); start_pte = pte_offset_map(pmd, addr); + if (!start_pte) + goto out; for (pte = start_pte; pte < start_pte + PTRS_PER_PTE; pte++) { unsigned long pteval = pte_val(*pte); if (pteval & H_PAGE_HASHPTE) hpte_need_flush(mm, addr, pte, pteval, 0); addr += PAGE_SIZE; } + pte_unmap(start_pte); +out: arch_leave_lazy_mmu_mode(); local_irq_restore(flags); } diff --git a/arch/powerpc/mm/book3s64/subpage_prot.c b/arch/powerpc/mm/book3s64/subpage_prot.c index b75a9fb99599..0dc85556dec5 100644 --- a/arch/powerpc/mm/book3s64/subpage_prot.c +++ b/arch/powerpc/mm/book3s64/subpage_prot.c @@ -71,6 +71,8 @@ static void hpte_flush_range(struct mm_struct *mm, unsigned long addr, if (pmd_none(*pmd)) return; pte = pte_offset_map_lock(mm, pmd, addr, &ptl); + if (!pte) + return; arch_enter_lazy_mmu_mode(); for (; npages > 0; --npages) { pte_update(mm, addr, pte, 0, 0, 0); diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 70c4c59a1a8f..fae747cc57d2 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3376,12 +3376,15 @@ static void show_pte(unsigned long addr) printf("pmdp @ 0x%px = 0x%016lx\n", pmdp, pmd_val(*pmdp)); ptep = pte_offset_map(pmdp, addr); - if (pte_none(*ptep)) { + if (!ptep || pte_none(*ptep)) { + if (ptep) + pte_unmap(ptep); printf("no valid PTE\n"); return; } format_pte(ptep, pte_val(*ptep)); + pte_unmap(ptep); sync(); __delay(200); From patchwork Thu Jun 8 19:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20C00C7EE29 for ; Thu, 8 Jun 2023 19:24:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A90188E0002; Thu, 8 Jun 2023 15:24:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3FF78E0001; Thu, 8 Jun 2023 15:24:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 908838E0002; Thu, 8 Jun 2023 15:24:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8250C8E0001 for ; Thu, 8 Jun 2023 15:24:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5835F16048E for ; Thu, 8 Jun 2023 19:24:39 +0000 (UTC) X-FDA: 80880557478.13.63CD717 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf29.hostedemail.com (Postfix) with ESMTP id 81EED120010 for ; Thu, 8 Jun 2023 19:24:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Fizq3Xl2; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252277; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=5il7rSG7SaGfv8CHVujWTyebY3bWaqLQSXR5xzwdyo7gspSvDWDPTzSqzO5QrIncFum0Iy rTWbwdqESQwgA3eNT1rViGdnRrgTZO8WxeEMr3W9R11QkM/vy7z+tDl2Xsa4eWmL4swblV xmckDWya5FqfCSYh8lP2gx1Hxzmtszc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252277; a=rsa-sha256; cv=none; b=YNog+H9blGHusgA2xTGTN4T5g25OWvHqXEBD0jL2WaclXdb8HgjWnzFNCaOZ8i1yUo1S1s 28NK6LCUIMHSBkcMRyjRgLegaQteLait/li5AddD9Uajr5uPQ8SHFsr55DvEJSERvV9KAA BI+x/AqL+pLDwiodLewF8HcfEQ7DzH8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Fizq3Xl2; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-39c7f78c237so36098b6e.3 for ; Thu, 08 Jun 2023 12:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252276; x=1688844276; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=Fizq3Xl20k0s99bdV61+X0NES9CrzdKWOse7eCbwtn1uu9/h4mE0n0kQt9PwBBK2XD BLlYV7LOU26RY2UNjTt4eTKg2MiSFQ+mNE44PGkBbtphVk3O0XARXhUyyawmE+XPjZkM EIuZgR8dgqHGa9xPUigE/FawhK1QiFlabNgVMomZeu9AjaWaPJZt0b1g6ImgUkyGd5Ls fLctCunPng5YblGLwKbDucX0igX9BBdDWTKtQ02LRRmnejkHdR4rcW59H7SIyTy+bUtn UJH+uR4By3Rz8RGak7Nu20/xco5IlkAXPoTxOravmVmGg5IIQRwIeYxmwmVdJLgwdVhQ Kkaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252276; x=1688844276; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=RZd38jvoMIEr0fWLM97mQzSHnZYmQQTwR4sUWNJyPBo+UEaZDBROzFjvWHXVxJWCyD Wy1kbhjJYUse+heH/jxnIHZszTjlegkL9ZczO6DoXG/kuVGAq+HXDlB88IqiqzdLoXgj MsCJhqUmvYzeELeTQpJvIsqvBAEsHOb6OHkxNDpxf0s0nztaGVQ3tF3XDC4ccdgyIpXW HQJGTFk8MmPmxBA9uiTg9CEh0loNGB6cL7Bx/faqoJs0FBXVSITVapsd6v495rLnJ/yR GgKdQIdDKZpKNUNRsW7WtSEUy1hQl0NaQf+4WhdPUMbANXtv1PWcQRGCke9zF9Kb7uGg UPBA== X-Gm-Message-State: AC+VfDzL2B8m2ZI5sLI2n6OSbbbgMa6K8UjmM4J5JnTJDoVF14NaK+9O ErsrPyTjp9HqXK7RRFvk5bus8A== X-Google-Smtp-Source: ACHHUZ7q/V1z+M3JmfzPQUSgwqST3P0/aMtaG97EoZD5q0BXyKYRTA5dvNNFRGy2eGKWgHikkJ/mpQ== X-Received: by 2002:aca:231a:0:b0:398:2e8d:3ca8 with SMTP id e26-20020aca231a000000b003982e8d3ca8mr9311006oie.52.1686252276532; Thu, 08 Jun 2023 12:24:36 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id p127-20020a0dcd85000000b0055db91a6ddfsm111980ywd.73.2023.06.08.12.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:24:35 -0700 (PDT) Date: Thu, 8 Jun 2023 12:24:32 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 13/23] powerpc/hugetlb: pte_alloc_huge() In-Reply-To: Message-ID: <36b4e5d-954b-8569-4fe2-bd1797362441@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 81EED120010 X-Rspam-User: X-Stat-Signature: 19h7zspju1gx41nrm7k7ujtjxra48ked X-Rspamd-Server: rspam03 X-HE-Tag: 1686252277-204170 X-HE-Meta: U2FsdGVkX183xQsC7OjWN1t7QQgwudBKbBRbWawxwgy8frHbs+5we5X/sKgLDruwsj+0oqqMuqxjdl7gqgJUd8c4AYubO7L+gJ9oEqK86nIVifMdQFAa9d7WUJ9HZFWVhIoFAGMLtGb2rgCRPF8DY4MxSxPUvzffJE8Ajit55v+uG7ThvvBtMO7GBBLbtQqBMtcRdwRshZwfncCsvXZNIbhzFIvs94ilXuD1L7/L0yfFyahocgMOxA4X50MrFJdZmnJBewU/O7VyisuSn8tRaQGZwnPkynRIyGyLhghtCIssXQ+SJpgn6CB4E++tMYuAJm3scoDHqN/quAdQ7AmvJbOxT+MQwL/e/nQg4khhHfzKNOpTkPcGfhfQR6PsOH5lMHJfm9+GQlYH+MuEVxXTJBFrWR0zri6aA+8voC7cJnhEZsA8kdqqiD4pPpXr7DCGtKDsyqX9Ch+2tioD4BCpTlBNskuL6wo9JsWaWQ4ASuLopv74Xi1DfG0bGE2yo8EYlWefUUChNrzHCQ9nxEoOQc0mfM+buHQqC1AmMj/pYX9/ZZgEX6Q1nFn2T6XX8GiMX/9lAlOg3fuudeGtlO6J/8pPfGdnOOjchd5lPgO9HP1VuiG3gSqSJCX5Pn+YueFUp3ILTa8V+gLN1FVUy0g6NtZBt3fMvMXMEtqscROS4Eu9iTXERutDJeVFpMcODUwe0zf5MRqE2SUrxkNkmYpwGWybUaP93MYyQ0DP5uwIi1WruHPZO8q1pf+Pa1aABkP3ORTAwPc7rwOXFsApVYJY+6JHldz2WbJxnD+UgMCCiIj7X24xI58sxIorhraiI0X1moRS8RxfViG6G015M/JWKnLE+zpOcLlh3ngUpo8OQGsAiox9SqICtKnLbVmgle/KRzs0N8xob/H59u03Iy2T6qJo2cFRdwzCIJMQWhK6YqOeiSJoOhpl/524faxY4SmA1xCooHvAyOdTi0y4YPM CutW6jVe eGV3h1rndH9RzB714ehmx/5M7fKzcGlpNSGW/8sLkAo5b0DYP69b9aHaet11QMB7YrOyW54l63SHjzkrdDKH7uZ4kOzeWX8kcClXSG/S4mAdLBvsCqF+YZR87+YalZ0NG1u4JgdXWBHWgf5Sz2wseFcItk03JURON6YfoijJca5Pxs1xt84IW6/K7Wtq777688uAg8zcwO00+sZIWvcLk6wIzoUYjLUOwBgqPuUr8VEBXufkfflBFX5GlPC1edB2iVjONNjMb1fAw10TyEfruOkgnwVgXTZAtCefZxhiIypcoAv42G8zTCcaxi3tS5tjA+gHybxWUsj63wmXX2gwlcsX62zMc61akS5lhK34ATx1J22lSYHoidzUOzgV6MxXIi5DEOWyNeILMmgJ5j8uq9hOr3yKFRx27QlBQo+eiMIzm9aYqQ+pKy48RcA== 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead. huge_pte_offset() is using __find_linux_pte(), which is using pte_offset_kernel() - don't rename that to _huge, it's more complicated. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index b900933507da..f7c683b672c1 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -183,7 +183,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (IS_ENABLED(CONFIG_PPC_8xx) && pshift < PMD_SHIFT) - return pte_alloc_map(mm, (pmd_t *)hpdp, addr); + return pte_alloc_huge(mm, (pmd_t *)hpdp, addr); BUG_ON(!hugepd_none(*hpdp) && !hugepd_ok(*hpdp)); From patchwork Thu Jun 8 19:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC28C7EE23 for ; Thu, 8 Jun 2023 19:25:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8933C8E0002; Thu, 8 Jun 2023 15:25:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81C198E0001; Thu, 8 Jun 2023 15:25:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6967C8E0002; Thu, 8 Jun 2023 15:25:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 548C58E0001 for ; Thu, 8 Jun 2023 15:25:51 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2D92880367 for ; Thu, 8 Jun 2023 19:25:51 +0000 (UTC) X-FDA: 80880560502.21.BB2D8C3 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf18.hostedemail.com (Postfix) with ESMTP id 3C7061C001E for ; Thu, 8 Jun 2023 19:25:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=WSe0O+xW; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=zc/dxe23oliiBDjl6FA++UP8WJ2BN/yE2Vr8HRi9WRWSABMA9Y/4qtougooT1lAlyFEpH9 InNIAg1RTFn3xpCNnJS8k2GE/NOcQ2avtoAE/pswmrfdMRJienBBXoZI6H+5HgES9X61+A VGde2CPuXGMINU3YU7DwxBIXHmmbKz0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252348; a=rsa-sha256; cv=none; b=Vc9b6dqF9n+s/109Kp47maufMpihukhTxZW6lq7KFlAq+AS9mozB79DR4P60q4d4ZjOjHp aDbRIt7X5j5UDOQN/MEU6K2hs7eOoQM6zOjFBXIzWCaj+WtAIpVFUr00LMVu0a60IWp9/t CBWjKEDhuSHkXvG8gzb8hDiZpJ1LOl8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=WSe0O+xW; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-569fc874498so9368617b3.1 for ; Thu, 08 Jun 2023 12:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252347; x=1688844347; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=WSe0O+xWHB2ydCbpeLzjHJf6lubD6yWbrbalQ09CW2PLGKbnuv/YCHcTjEklbftlDZ Bn+TBag489vYl0Kx/QEnd/hNvW0BHOeSak/CZxA051qj0HRROKgCePvrRb9MuwQ21RPo UFNVPP0fFgD2zP3vXEkAAHs7IbIEd7kCFa41GIq/o5fS7gcYFt1t9fsorCogUddAyQAa gvgPXc4Mu6L9KlRIpGfWDTGDmUnx/ZwV5Hsai5H4jlYjdflYF6WjfS5QYRdpLJc33lMM tuIWNkxAGrXRoIS+Re+Ik8k2cuYZR70rphrz9RjLzYXiNApKIhKEFjqSjiunuGbiEcPL 13ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252347; x=1688844347; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=cCNE2zqhc/M8lselLjJkJTeExMjhOAO2xHoXd2YGRV8s/lUSC9W8y8QGPN+7Xa5+sX kQYU3/rSpfRTf87oWEzk2ejcXCkQ3YFPAOVtU2WgTdfpr80KL8uofpR3vJZXsj4cyVBn GblnJiUkIglfwzZX5DZzFnQ1cCtblFbck1QMWwzTkIhvD97IpmdZtvfEU73eCjtWgwbF skS4qscni1Fim9qOs+5Vry+rA2+mClqpsHzRL98njGMu7QevGGFYBVDUAETua8ibBuo3 kkfDzI51sW1mwAmKI0mhLKsHXplZycZzg97LEEFlOEE/3tj01PVXUKJmf/4YlFTLyM1F m8bQ== X-Gm-Message-State: AC+VfDyxUOEhULitA/K4+cMr6dayPo9p5N6FnJx1hLMQqOtGoaSRr95M pzV0MBwJUNK/U0C9MS3GvvBWTg== X-Google-Smtp-Source: ACHHUZ7VI0tdmqfD7RJHlpvasneu0EKZSOUA0Xhotxo3WPVI6HmobTXuS5JzWFFLHVldGCNyYtlCDw== X-Received: by 2002:a81:9144:0:b0:561:da0d:6488 with SMTP id i65-20020a819144000000b00561da0d6488mr460871ywg.50.1686252347196; Thu, 08 Jun 2023 12:25:47 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id y62-20020a0dd641000000b00568938ca41bsm117859ywd.53.2023.06.08.12.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:25:46 -0700 (PDT) Date: Thu, 8 Jun 2023 12:25:42 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 14/23] riscv/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <291f20-5947-9f5f-ec7f-96a18df336d9@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 3C7061C001E X-Rspam-User: X-Stat-Signature: 11tqsodgwf9a9858c3qgsqah1gpybj7y X-Rspamd-Server: rspam03 X-HE-Tag: 1686252348-158229 X-HE-Meta: U2FsdGVkX1/zsrVbj5WvEav4/CMyOLmJgjGy03DyrwU3JvfHFxd0PRL0HK31SuYtJeOTJNddL8wuuN3LvACpj9wmDJxUeyTg/LOmvcU2aYoRDff+78DXOuZ+Mm9LuVwtR5rinTI/MPxF/bRkEWTNW5F7GgactxP3cqKuErrVIv9ua3icAghE52+xECjgtILVNvN2/YSQrYh03iO5F5GgSRhoIF6fIWfwOMjS015doWbGCk9f9P5UVabAPF5mKJ7i8D6uJMUu0Lwry139RL8TKASAim7CdHXo4ISIhIaEO8ZwzQBewXWiufGG6X0As1kJEkrDTbKZDhO1pzWkeis8ElfNcEBikjTF8jPO0fkcRTvWdRpeXjSHezx68+QlvEQySDV6kv432aKlLuetMd027Bu4gdonvXJ1D0rkdQjXrMGDpj2etir9RsnryuEKLO40M1wI5P/rBD1J6oOyixYOEeV8lJm27s6z84aS6FzLBpG927xbSJ+IlOZqFo9ssZ2Wc7bXEfrHfFso5A+iphkqPVo9MaGYDcARzCZhill21R5PHK+nGdrg6OFQgp9DbErO+NNNFc7qkyl7CYNmS3NtYw0NSZPtd6yxTVc6QYg/NN7ZWONfk1ilW5XEJMeZvwQKUsK2HPKRGNuDwW5+qOPWEDffnA/yrau3EtERwFx5WI70jBp7/LIbNGSjW2FQfw+Pwj+HkNxFO6sXJTYgtkR2tlzC6nJ/pOQGdZhO9mpIrE7/aItynYcL/l+y6ZeHbCeQybMrBQ+KktEdrcdt1+qLdRJHqtmSErlCocM87TfzF5h5USNt8l3bZVSkjBxTLIb/i69LNSbAYLkd46P5OcNReJNshOOTb/TCvNUvEc4gJ/9x3c4x4+tmZS7p4XyR7zH8l0Eehh+sJZaEGaGwcvdrnQY/DP2g0jIGFRNSOGAauZbs+wYnd47nBz4v8am/tHyzZq81iWoAZavfZlRXrOQ /UR/P0P4 8S8pEFbrpXvkhCY32y76f0gVpZxkbc2T6rpHg7gUd9quhh1ZakubDzNpxRVVjAE6pIr40kxB1lMTHWIvdjTKqL/IlvQQJCarw+5J7f6f8szv+SXBdJf8R0eQEv1HERVBaP313CTPqbHVwglrHj39m1dypb5rTTdjssTZHqPVA99QQWdNG7DSPoUnD6FlcgWWiJFYWtZLlpKpxqilJDE+gF5vohUnwgX9U03llZQ6cYOESejLJ2TUp7AT/OUCVSTXwiylkjBiNdkxC4kHwpps+c9ftcRHKtLQz2KxNm8mdYUgP1zA+F7AELDHhbt21RP63d5tkpOHuR6jKfzpCGXTqfLLbSiRspcTfrStB1V9SjAoFGSAoT+YjG4HM2QpIloeda7+1ephTeew9DodKIiJlKB9y++l9WiHw4uZDtH1slsk1eE6V25NWVOGUzv4tgXoL1aujFUkLBNDOoeTvS4kHUGNjkbGNHMH2/u/Wgoc71K4JrI5h0F3DEcwbM5rJgevFSezIpTriEQMH10HI/cXTzTIBuKAuVnA6aFyJ6FWnoRfb4eI= 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins Reviewed-by: Alexandre Ghiti Acked-by: Palmer Dabbelt --- arch/riscv/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index e0ef56dc57b9..542883b3b49b 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -67,7 +67,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, for_each_napot_order(order) { if (napot_cont_size(order) == sz) { - pte = pte_alloc_map(mm, pmd, addr & napot_cont_mask(order)); + pte = pte_alloc_huge(mm, pmd, addr & napot_cont_mask(order)); break; } } @@ -114,7 +114,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, for_each_napot_order(order) { if (napot_cont_size(order) == sz) { - pte = pte_offset_kernel(pmd, addr & napot_cont_mask(order)); + pte = pte_offset_huge(pmd, addr & napot_cont_mask(order)); break; } } From patchwork Thu Jun 8 19:27:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FC95C7EE23 for ; Thu, 8 Jun 2023 19:27:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BED8B8E0002; Thu, 8 Jun 2023 15:27:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B76FA8E0001; Thu, 8 Jun 2023 15:27:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F1538E0002; Thu, 8 Jun 2023 15:27:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8D4728E0001 for ; Thu, 8 Jun 2023 15:27:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 56AADC046B for ; Thu, 8 Jun 2023 19:27:30 +0000 (UTC) X-FDA: 80880564660.18.A54D9F9 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf17.hostedemail.com (Postfix) with ESMTP id 7AEDF4001E for ; Thu, 8 Jun 2023 19:27:28 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=qeZyDOuR; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252448; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=cRheE3cQUnRVKRVk9NpnVuC+0UYdNQFXto7ZyudMcid510gJLyL58t1s9NGy7qqOQIuHhE 62L2qPkDPbuUQB11i4Ius+muYjIRAv1ui1+OtSPSzUp9Dep+VmTKyRBKfzuhORXgXzdjDL jYMcODHYreJCblvyLfb3unE+iAC0+18= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=qeZyDOuR; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of hughd@google.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252448; a=rsa-sha256; cv=none; b=xwsrQMpJ7UaFhb6A3w+Ug2jtq0X27CyGBvqEs9JJdD8yyAflU2lNb2VlRLmCmKe4bsSWEJ dtTY6clEre96H33GuT4v+1PKsQ91py/mkJoy+Rj7GNPkJhp42JkR4genLgcXXt8UxtcjYY eLwGqQacIqo5l4uaOVAkM6MulElh2sM= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-568f9caff33so8716667b3.2 for ; Thu, 08 Jun 2023 12:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252447; x=1688844447; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=qeZyDOuR1Ocm6uD+TD8H/qooj7RzNFAiwCA/UqStNTHWJ9eTjvcv/8Jq76xJdFB16m 9vZjnF1AyEaJnSc8jl/F1i1cVEQ7u2Ksx/OtGK4kAnOQneochRX+8Uo2nfHZ+IrggDdD 8+N7/1JLxtH1E0e/CwR5x6nt/ET/TtrIOFNieXovV1RuuXkZkQgSV5Jae+9SGKAEV2ls YNv4h9+C2a+hHml6224b2D5gDdWuYPDND/n0XtPM1ecc2OJLce4FWSFBO4HGDd7/83bC 7o6bLjq43ZCC/kx1k33o8ly3OOe+X/CVjUPlD/YBOO/8+E1ljdocxCQmjAw/takWi4D5 1nfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252447; x=1688844447; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=HpSrPBHO10PGYI7I7gyO945IdroHvUMAR8B8dcrn6HM2loY9agRBhkbRtN0Mmc2131 pfdGu/4sk2SylwTxhvZTJ+aTu9EAZdGWkV23cTxYzyWaIBlBcRcoEg+YbxI1RPVXqeJj IaPa1tRPtEvJR9EueKvg49cy0qYdgoQzrZaZku+w6Hj1uv7ZIKy5aI0Tge2uxfO9uBjx TgV5SdcCD2tpJvRr+iXBVMS+wz03wYrRrGYrrdVxdVGrfHLo1yXk+Ae+y2VMIxbdu+2L Ue3vDICQihsAmIEmhwusA+6e7mZXdg9MDZxKSYcMRoHZLDgNpxrRdweLp2AJNRQrp1ch rQlA== X-Gm-Message-State: AC+VfDwHULlgu5U9S8Xh2Pbv0HTSOVYJvqduKyMjhdeKzaYbT2lVnThf mWdLZSuVKfeUnYxgfKQEoB2JaA== X-Google-Smtp-Source: ACHHUZ4CKoILR2pPYJTWor9o0GBjI/ipQ0oNmgXRrLGWYF5f0T4KrdmmHl6o2FyAVA33XKtCaimxFg== X-Received: by 2002:a0d:ca88:0:b0:569:fdd1:24a7 with SMTP id m130-20020a0dca88000000b00569fdd124a7mr493494ywd.51.1686252447226; Thu, 08 Jun 2023 12:27:27 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f123-20020a0dc381000000b0054bfc94a10dsm119559ywd.47.2023.06.08.12.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:27:26 -0700 (PDT) Date: Thu, 8 Jun 2023 12:27:22 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 15/23] s390: allow pte_offset_map_lock() to fail In-Reply-To: Message-ID: <3ff29363-336a-9733-12a1-5c31a45c8aeb@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7AEDF4001E X-Stat-Signature: 3mnod3wu3ffub4bqdwbx5i4wshbu6r74 X-Rspam-User: X-HE-Tag: 1686252448-853575 X-HE-Meta: U2FsdGVkX1916M2FasEIRZjHfqzgo5Hw2UwsgYyPYFWCBl54Voj9h1Ko4IBdzZ6x6X63P17s82/aNiHYvc4iWZochS6jXnKMbL4xCf1CSbEG11F7m2r0E/E99ibbPRujbTZVyZbA9UDFLY12noQj41GEbuLKyQv5kIQ8uneBeV716WXP9P9TXL5lr9bLHGFHsV3lE/heH1caST+m5nQV/Y/JHM2yLhvQJv0+EZzPYp06tdhmCZXwCnGTPoM6Lez6alDKFXZgj4H4ArEW7Zrbi9oOkus2jIQ3JaZRBng/mEMO0xJsPAwaEdWOssw5r6KqCAjUIxQaxNqdgtTQ0wFLyjOzvdxX2H4HWJcgiBx/5yqu6apSkx4vul0cHu56eMIXUXi7jv1k/a49Lo9q/oIsf99Cxep3Ya+9Ga45/lMWx1lbwuc/dVv/ZdXJDi1WQOaCfhR9C8GRyYZJoLi0OlNekwyGAjcylST3aTSuLxpa4VgRMWhVov5kCNT3deVjdAHZ2sYe3/alQPY846tZgrseyS4euNJUJPbrLuAA6wCvsa+BxwX8mYAhqmBkWunZTSlc1cK6mPM7lkX+qAkuKeQDqWcgVY2r6sp1QuJUFNlrbxYLEQbKbuM+IVomtKzOXqD/kbdpW5sHfvC2ripwRoC5aNfyVYIi0F2e3PS+iYtsa+3uQlurV1t8DNF9XKwIqYk8MKs+YyPsNfzyZN9p2US692Ae5X1Hd3lyUdli31w802uXUC95REFXBhoX1Fxgi6pX8omQSm6+vUsLVjQWhRN4s/U/6BMtLaw4iRkUOcB3+ud9FEBJ/FPMeW7LMbRLdmjLRQpnE76Gzn9nNp9Ux1lnJ9N5YHlHxRM9eRvD1CQC5qrq6p5YwJIbhQOG0jpwSZyyItFJYx5H0MM2f/PHyNQkT6Fx9Ue7BZayKgfNJGgBEpMyX/aXHo6byjBe1x+avPKUqXm0o4pNPiRJnNro2MV TuvifAzT OfyzSWTaHQrtTDFHNfxpbC07hxwPWC5gqGMmuyHjCFBCocggLrc2WFufLCq3qfup4d7rt7HcqQvQeWZmM6J3gcvGwSzezGm4kJNEKTZzUKTBk255iaeBumn+3Au3LxvxW0meq6MizFl2u4Tpyx0bLXgpVqMzA7ME014gZQujJhHJbVZrA3d/azV5Jpk5cX1tRgTv9kDMqvs3aPQ9v8+EAjZgFKiT/DmVZG32HxTe4W/edWMiVc3v5TFs5PH6hILFnFHfEwuxJ1uuiSoD6X9Igm/5FxNqD4Ad3wqcwMVWJ1XnMTG7USKdtboinjgDRHKSObMMpUTXCXwisn+C2Q8VM1cgsgt2CLVBL7K3zks0OK2IeC1AoRdua0uiF62/yYiHhEZ5WmN076jSgvVFM0aD6sgIpIG4gNy99kySuUbe8aMHuTpGFDadu6zkYLg== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Add comment on mm's contract with s390 above __zap_zero_pages(), and fix old comment there: must be called after THP was disabled. Signed-off-by: Hugh Dickins Acked-by: Claudio Imbrenda --- arch/s390/kernel/uv.c | 2 ++ arch/s390/mm/gmap.c | 9 ++++++++- arch/s390/mm/pgtable.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c index cb2ee06df286..3c62d1b218b1 100644 --- a/arch/s390/kernel/uv.c +++ b/arch/s390/kernel/uv.c @@ -294,6 +294,8 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb) rc = -ENXIO; ptep = get_locked_pte(gmap->mm, uaddr, &ptelock); + if (!ptep) + goto out; if (pte_present(*ptep) && !(pte_val(*ptep) & _PAGE_INVALID) && pte_write(*ptep)) { page = pte_page(*ptep); rc = -EAGAIN; diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index dc90d1eb0d55..3a2a31a15ea8 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -2537,7 +2537,12 @@ static inline void thp_split_mm(struct mm_struct *mm) * Remove all empty zero pages from the mapping for lazy refaulting * - This must be called after mm->context.has_pgste is set, to avoid * future creation of zero pages - * - This must be called after THP was enabled + * - This must be called after THP was disabled. + * + * mm contracts with s390, that even if mm were to remove a page table, + * racing with the loop below and so causing pte_offset_map_lock() to fail, + * it will never insert a page table containing empty zero pages once + * mm_forbids_zeropage(mm) i.e. mm->context.has_pgste is set. */ static int __zap_zero_pages(pmd_t *pmd, unsigned long start, unsigned long end, struct mm_walk *walk) @@ -2549,6 +2554,8 @@ static int __zap_zero_pages(pmd_t *pmd, unsigned long start, spinlock_t *ptl; ptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); + if (!ptep) + break; if (is_zero_pfn(pte_pfn(*ptep))) ptep_xchg_direct(walk->mm, addr, ptep, __pte(_PAGE_INVALID)); pte_unmap_unlock(ptep, ptl); diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 6effb24de6d9..3bd2ab2a9a34 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -829,7 +829,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -850,6 +850,8 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | PGSTE_ACC_BITS | PGSTE_FP_BIT); @@ -938,7 +940,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -955,6 +957,8 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); /* Reset guest reference bit only */ pgste_val(new) &= ~PGSTE_GR_BIT; @@ -1000,7 +1004,7 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -1017,6 +1021,8 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; pgste = pgste_get_lock(ptep); *key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56; paddr = pte_val(*ptep) & PAGE_MASK; From patchwork Thu Jun 8 19:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23E68C7EE23 for ; Thu, 8 Jun 2023 19:29:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B511D8E0002; Thu, 8 Jun 2023 15:29:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B02618E0001; Thu, 8 Jun 2023 15:29:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C8DA8E0002; Thu, 8 Jun 2023 15:29:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8992F8E0001 for ; Thu, 8 Jun 2023 15:29:21 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5806B1604A5 for ; Thu, 8 Jun 2023 19:29:21 +0000 (UTC) X-FDA: 80880569322.20.7C7B7FA Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by imf03.hostedemail.com (Postfix) with ESMTP id 658F12001A for ; Thu, 8 Jun 2023 19:29:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=WqCUQyh4; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.210.47 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252559; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=i6YWArHdXFw1pp1hezH/4wYTStTDkJztNwXHhwljSCHTFasXm5wywlPWi9nqMXTloGrH5T BWtqxSk3fCftjJ2+MosWtVzrT26/3tXO2+Ho1at37QbojQRRpzZCDJhwleXSMW/jHd4lqm cgHVdK15F7C5IRiqTXa/crWvvzIqbNE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=WqCUQyh4; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.210.47 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252559; a=rsa-sha256; cv=none; b=E8sOcQtP5Xarc45lpKYCudlQfKQbQbtasMCM3H7IyuCmG011qGY8Ty2LXGXJWIMEKV5s0n yA7Z1eSEupty1IYXAdmJxKFV2imB+SBsUI8ZR+uFUehMNrmPLLHu2DxOovMBGo9nRcAM/+ CxweNYclnVqqIN1TzuBTsrGFIuJcZLQ= Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6b280319df5so44212a34.3 for ; Thu, 08 Jun 2023 12:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252558; x=1688844558; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=WqCUQyh4fb72P3Kw38oeD34IYgDMZUJWpeeOOH7KwWFkTIkJBfiV3ibZz3gZzYLVxl lU1gDOTGIJCl22/qWpu3I54yHV8hXoWsW3bLvMizUe696eD4+w5NMItSw+ZsMJ2if+3a 8lw8VtiSVvPlHQ/Z7+Qgoipy0NwOKSeRkxeZtlOJSgMtgwHhJFZs8ezKvYFf04NNKV0B o9SvBbVJSNYcgeP1FcAifK+xGopk05Di+EjON5dZeXWscPS5ozLfdvYQvh8DkNTWidtB R65qDn5ks7oQgy0HqDzv818p/gf4omkafkLcO+z9CO+/iNtMlszDRH4pSfFhaygbIVXY l7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252558; x=1688844558; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=MGJM0a43DrvbGs3ZHFfZOvHwqpTWiTDC1M1VvakllD7+ED7T+1yRTMuGnUAlRJonTX vyzGCpwEMysAclaRPQMYilSe9fw1j51U1iDrpcF2VVOsH2V8BFpnLQm7rFaSlPky9bD7 gOeZ4ZmBi74fHYUgyYhFtHWaKa1sdwvcS5IY0xYXtFPMi1hF+89Z2JjhLfQ4zKBq1CcD eynVcy7Kt2o+4NKO8TV2TFXGx0CSMUkWUVI6xA1tEuxLbHsnF66IQ0X67jO7zrmDMN5x aBWIqv15spDBI11ls9+OIO6gA9rM0Qx1b/gPb3j3m9arG7Rvb5NEbpECpSZt7fvqd1GX f6MA== X-Gm-Message-State: AC+VfDwyR9/zWu6aQkCNymViTrjP10vKBcuoc4yPGRKUvqNUqyCmHNjz yl4NCMpQ+6/AMIlGKKIrkoO+GA== X-Google-Smtp-Source: ACHHUZ6Glpn+/SneQe2ShIc4+J53+hKNrejmkpSzC+zjJkZt31rnqX9eMZTl3ydPFwIMIfpDuEYaQQ== X-Received: by 2002:a05:6830:86:b0:6b2:94a2:2236 with SMTP id a6-20020a056830008600b006b294a22236mr9332824oto.29.1686252558452; Thu, 08 Jun 2023 12:29:18 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id o199-20020a2573d0000000b00bb09977b0basm455193ybc.6.2023.06.08.12.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:29:17 -0700 (PDT) Date: Thu, 8 Jun 2023 12:29:13 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 16/23] s390: gmap use pte_unmap_unlock() not spin_unlock() In-Reply-To: Message-ID: <78873af-e1ec-4f9-47ac-483940ac6daa@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 658F12001A X-Rspam-User: X-Stat-Signature: jieufb66qc51px7xigj869jnwmshqhy6 X-Rspamd-Server: rspam01 X-HE-Tag: 1686252559-796774 X-HE-Meta: U2FsdGVkX18qPIWZdEAyPGIL/ZzujuPukJYioEa9mzRZb8imJE6nBkzdFfZUdPdROlt0o4HlPsfXaA6CVGAuffRjK++eSeZHnCmbadxpPhjeGHi9KmjC8Jykvcu3a734/uc7hFt5K/a2XZPqAw3v2SyNkaQMxCL8erAHozuSuRF6c6+wSMlVHaM2aA6lCum15VwQ2KuHOFvj/n7byWDH3HMkHfnBjL3qUAf5WsOYsLvm87t7aGbGo6Y4HIHoFN/5inVzAOyQm4L4Jdq8mydIjj7Fuak54F28/DcLCCme7WYQWMUvVDc2J88kR2Neg06eFhCnwDfUhy4Cd4xziJA/ZBgGdLoVOV+OBtUvpTLpvtqKmH7Kj5853e0Yn5IzJATVgh9NXFZwUgQdDBpVD6S4kNRRAVuabL+X/SHg7I4z8G2O/2QVj0k3bYL1YvAuRaeXPzl+UHMsZtg4Z9zbxBjRf2Dg15e8GFG/xxbLyJrAyZasq8ZI+NbYf2xi1DwczBTGodkmazqV1OxtfGYAKn0UqVJ9y+ljSmAfxPvI+eRHfSKrg+foZtPdpVHruZ3KcX4jypOHN5mHbG0iMo5CzCs4aMdzSHjfuCNmiXIBIfc28dCYbr2VSzeTEqEwClsc3k0lXByFhz7d56BO4q/dt/p9V8WlW6rYq54Lj9d9ZFmpV7hVFpHyz8KasRoxHAfxXC6ZTL2lDh/3nqISS1DCauW10WlT9h2rOKFnA38Lsh5i5ouY6GhU6sxytQFk3bDKCkh8KVE21z/2BkVyH4D5vK70FaKuigVJj8+EJ21XpNKZn6Q0E2bc+E8M7P76yJ+MN/3xOf2QhZB9q8Ysa5mBKhhFLXqA3V695kMVK/b6KNnhrZE9nCcfIIy9ETxOcQtzzqBW9Y6vAL+durisXJmj19EeJiSWn9irf2rrmfTiCSndUdq+tD8Oq6ARqF5Yzk7adtVYIkiaHaEUDtwFnyQqRru IpDxcPI1 MYcOTd7MtXj8Q5ceKxKg4DK2lh4rPZBluT/QFYIB8tzRxqVelrzDffDTbs1s8SQCVGMxwd8erlHKgydmdoFNB3jpaMRaOxUrySFP0aaTh7yy2RC8Otcoxzrfr98/0ReTqHouPmud/ASLif1/+XFQD3D6RurJZc+hnJYLo5m4XxeinNNmofYzykiM7o8OrzlMObU2RJ4Dink+dklQapfPDOrOWoryoGITrySBCdyCWafqGjw12r9Y5s8SCNUy4r6bSR1PoaOUlHvS9hBYKcCWBTzH4lnMJQH3LNRq7yPxx5NpPB0f25IYi4xwLAdGljN8tbDU2WMVptJWDc7cylarTbWg+dJ9XnjHrrQiNiy4JOnE4sC5OQaxSXx/TN2EIaOgpp9F1dm9KYscKhd4iZwaF37J7+IkU5/dDm8HZH28xt80FNyxWtERBZY/x+GSURq+Y7n0aWmRHs6/iVfU= 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: pte_alloc_map_lock() expects to be followed by pte_unmap_unlock(): to keep balance in future, pass ptep as well as ptl to gmap_pte_op_end(), and use pte_unmap_unlock() instead of direct spin_unlock() (even though ptep ends up unused inside the macro). Signed-off-by: Hugh Dickins Acked-by: Alexander Gordeev --- arch/s390/mm/gmap.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 3a2a31a15ea8..f4b6fc746fce 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -895,12 +895,12 @@ static int gmap_pte_op_fixup(struct gmap *gmap, unsigned long gaddr, /** * gmap_pte_op_end - release the page table lock - * @ptl: pointer to the spinlock pointer + * @ptep: pointer to the locked pte + * @ptl: pointer to the page table spinlock */ -static void gmap_pte_op_end(spinlock_t *ptl) +static void gmap_pte_op_end(pte_t *ptep, spinlock_t *ptl) { - if (ptl) - spin_unlock(ptl); + pte_unmap_unlock(ptep, ptl); } /** @@ -1011,7 +1011,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, { int rc; pte_t *ptep; - spinlock_t *ptl = NULL; + spinlock_t *ptl; unsigned long pbits = 0; if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) @@ -1025,7 +1025,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, pbits |= (bits & GMAP_NOTIFY_SHADOW) ? PGSTE_VSIE_BIT : 0; /* Protect and unlock. */ rc = ptep_force_prot(gmap->mm, gaddr, ptep, prot, pbits); - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); return rc; } @@ -1154,7 +1154,7 @@ int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val) /* Do *NOT* clear the _PAGE_INVALID bit! */ rc = 0; } - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); } if (!rc) break; @@ -1248,7 +1248,7 @@ static int gmap_protect_rmap(struct gmap *sg, unsigned long raddr, if (!rc) gmap_insert_rmap(sg, vmaddr, rmap); spin_unlock(&sg->guest_table_lock); - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); } radix_tree_preload_end(); if (rc) { @@ -2156,7 +2156,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte) tptep = (pte_t *) gmap_table_walk(sg, saddr, 0); if (!tptep) { spin_unlock(&sg->guest_table_lock); - gmap_pte_op_end(ptl); + gmap_pte_op_end(sptep, ptl); radix_tree_preload_end(); break; } @@ -2167,7 +2167,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte) rmap = NULL; rc = 0; } - gmap_pte_op_end(ptl); + gmap_pte_op_end(sptep, ptl); spin_unlock(&sg->guest_table_lock); } radix_tree_preload_end(); @@ -2495,7 +2495,7 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long bitmap[4], continue; if (ptep_test_and_clear_uc(gmap->mm, vmaddr, ptep)) set_bit(i, bitmap); - spin_unlock(ptl); + pte_unmap_unlock(ptep, ptl); } } gmap_pmd_op_end(gmap, pmdp); From patchwork Thu Jun 8 19:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44DE3C7EE29 for ; Thu, 8 Jun 2023 19:30:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3B628E0002; Thu, 8 Jun 2023 15:30:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEB458E0001; Thu, 8 Jun 2023 15:30:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8CE48E0002; Thu, 8 Jun 2023 15:30:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 95E1C8E0001 for ; Thu, 8 Jun 2023 15:30:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3F4C91604A9 for ; Thu, 8 Jun 2023 19:30:22 +0000 (UTC) X-FDA: 80880571884.07.1A3AF8A Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by imf07.hostedemail.com (Postfix) with ESMTP id 427E040028 for ; Thu, 8 Jun 2023 19:30:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Z+1ROWx9; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.166.170 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252620; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=fje5jr6ZYD0VAfpYophYZ7CRTSIYde/9MiFwhE6RO68UHR7Z2xJFmCV28hd88USflFeWTs U0QkKdsFBwo1MqaA9Prco7U20swZPvvwiN9CcpgFdbCDm0GYchXytwNbI2U/SNT6ZQhVDZ KIT4CTEAnydTLiT78CWhxiVsjaqPPVc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252620; a=rsa-sha256; cv=none; b=4sAeNLgxvq93ulhwKnepudi9XzuTQPru488Yp137F8Z/jVGMIr6SnsMFKrXFdapwX5bYUD 5TDUzJAVXCmdDzvPvAwNh8Bpg+sRtITrbe2kgy9N4csLfEE+Hjpp/Djr2S8cbXJ78NyBrK XQWAU5Hwl4AQ12jzjAtuW4S2kwHuvXo= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Z+1ROWx9; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.166.170 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-33b04c8f3eeso4381485ab.0 for ; Thu, 08 Jun 2023 12:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252619; x=1688844619; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=Z+1ROWx9LnxdX5nt3Yo9Gw9A1LjKJHFc2WtgcRAYaFIpj6m1+MueknjL2tetH/Yt/E Jkma5NMQVv2CGzmJBnvKYmHLILgxFTZBZe29Vg5F330+u2fSbBPVEtX3NRx2YFJBGUmp kCJjjc7KvjHhyEDucY5j+/eHT1OpuVlzl/VgAMVyKWRQ9P9ksfEE7oKQrQHB2ZVzogis AlGkparAM9e3I8OX/wc+UGRKJ9WTDNWGaUDF7YaTiCVpSxpo1NNn2hyrTeXSAmMOPutQ TUN3B1UmJFKBBqlJCwM8cMmQBeV6xJ4ogL/1WbFBc8kxJTJPQLfJ0hWbM0sLcNxIcm/D dTzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252619; x=1688844619; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=W5ehwXcAeSh6ijgjAvSMuIBVo/4ryxEsqHNyNI544Gw53CzeOazvLf6Vl6ujgG/le2 mgIp54hsTSoxtCVEMUBqp00SuqlUfDTEx/9lURzY6MNzigLP+xeNVjTUEDStoGWe6sWC 1hbf4SnigXH3lP1MrVlFkh0btx9kD3KjEezYzYgsWlDwjAFbi3gMZtRVfnb63xPSaoLJ +Vp0FikjlB2F4Lf5HoD0ykRW+cppHxwf67GvdtP3X+9gyrO4YdcJU/Xfv3fJUqnFWihj 7s2UNd9q6dROMkdvMQm8S8VQOQotMln4OQaWQvmF5v27QzcZkObWC4zxiaIvs7q9pQwV PkTw== X-Gm-Message-State: AC+VfDwyCWsOIX933rrvGdn/HEs726MubPOa7MjruVUayZhfSnYdyjty pgGgULKT+a5q0aBQHKyaU1oBIg== X-Google-Smtp-Source: ACHHUZ5FLPawoStHwp2n90KOP3LMuG/l1wNARr8CXyW4COytL00Jtvx4PAa220fnQj49mz7p+WoCNQ== X-Received: by 2002:a92:d34a:0:b0:33b:820:41ad with SMTP id a10-20020a92d34a000000b0033b082041admr8096921ilh.9.1686252619199; Thu, 08 Jun 2023 12:30:19 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h184-20020a256cc1000000b00bad07875d9bsm450282ybc.11.2023.06.08.12.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:30:18 -0700 (PDT) Date: Thu, 8 Jun 2023 12:30:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 17/23] sh/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 427E040028 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qaymrxopyfk8gq36jyf1icne7fifxekq X-HE-Tag: 1686252619-113444 X-HE-Meta: U2FsdGVkX1/WP189P0Blisw+YkgfhE8gsfL4fmCdBeoHc1FfYPnacQ08MwU36+CXQHlf+iq5iliwLnNqwHW7fayuOYiZRB7X09QrGQxonwERnD8tf0QpVAvXsvwijXELKHtI10vSvxCyEokH1jcyMTYyCTKQm8Mj9f+05TTojay8YeTG/6vnduAN6CnZGg1hvaosvZ4j20bDT6eTF510ZsWFtiRHq10IGR2Qg/KzYryzQ74U6Kt1XS5MA6G7Xawd/h3XYmpeoNWJFPTXX0ogLEfD/KYJhabp8Khiso3z2agN/YwUU3ToA4lmq+M2WEM6f3x4XITg/zboOxE+Kz1lgEKQIlWx2dXkyfH/k7qdRiolvUMzWgW2gV3D3p6SvX8WomlteVKh9UqjdorjpCze/WKqMO2D0IBOujC9Grz+1nXlCSEj8CqLhNo6bciq2J9PsYTqibj0K3CmyJeFKdkXY/mdXjbDwsUL/Bl49ya7teGdPzpYKbDl0P73IxYN/6dlNlJ2iA9zch1vdVG3OpPHWmtBolKIL2N6GqQgcjZ1yj6bDkuj5pDzLYfz5kPijOAtNnkjDshPVTkmKFKwnEeWxcq9Jd1OTU2eV+O8SXo0nLBEVCvA/IQSU1ZABqzON0oivv0HvdpWLp3vQt1rl671IDC94P4PTb8W7e9wQBeYJwhyLJxdYo0essWqfNtL6NZn/F9J5hIKixay1Kyq1RqSuRVXKQdBydfLV3fQ83J3/1MB9TffnyFgoEGNPCNPEXhcxckCOFWzf+6BWuFXl/nfKXUKkmI/PrywqH9lAro729jo8NPjIwkLU2rpUWkY97xZsYL+EfoVkfWOhu7cdxD/99fUWAOyJAJhI24l+5zpmBD3jw4eUapXQc0bJG/z5cSyrYKkpPuLCRjJ9EkrBVJmix1/GKdsY2VMJequmFwQAJ6IB2kxEHOngePNvhq5PqtBScnDcenwlr9qHxjKThR aw6xMtNM PpO8Rn9T4Io3DRdU2+VPlyIx0BiMDCKB5fiZvUz4uXHJigPb7RierCCipKOsHZhtnEf+kWJ2lMlQsp0/8vm30LUiQgaDAXI+IZvQgv3VU/f4C37T1pRIUNB4t4rZw/8se4u8y6btv40XYDFDdoPyJg8d2Z7fc47YGptiOTFz6VGvcwnb8oZP7r3HXDRSSuX2hci/OTmXlvkDEXyeSsZTT3Xju31SKNmzcX7aCVcftS9p2LNPNsiR5LvI9ivWOYxbOM7pDR0+TAgcAEV+sEck5vZGP+hzHB3pylhrkPidSmFI0cvfoClanjmMDL2BY0J3Pz+NCa22Vj79gLNC4LfdiU4PrTRLN0XyUx4jqEB0hfHUP1q7Ki2K55jBeldzeF2tdV4ki49wGE/1/V7BpinnFh+RWTjXlkOkVElnK8SuwW6ELwULh0kpaDrxT4A== 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/sh/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 999ab5916e69..6cb0ad73dbb9 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -38,7 +38,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_map(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr); } } } @@ -63,7 +63,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (pud) { pmd = pmd_offset(pud, addr); if (pmd) - pte = pte_offset_map(pmd, addr); + pte = pte_offset_huge(pmd, addr); } } } From patchwork Thu Jun 8 19:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB98C7EE23 for ; Thu, 8 Jun 2023 19:31:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFE4B8E0002; Thu, 8 Jun 2023 15:31:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD59F8E0001; Thu, 8 Jun 2023 15:31:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9DCA8E0002; Thu, 8 Jun 2023 15:31:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AAA508E0001 for ; Thu, 8 Jun 2023 15:31:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 77EFBAF47D for ; Thu, 8 Jun 2023 19:31:18 +0000 (UTC) X-FDA: 80880574236.07.7F192E2 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf03.hostedemail.com (Postfix) with ESMTP id 760BF2001A for ; Thu, 8 Jun 2023 19:31:16 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xraoP+ub; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252676; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=5NkG2CDPHMniI1Yo6xhXgvyVOGA2WazyNoYXHly/j8Ri4SQRFve3OlhTjHl64pbpTxNBLT EZSfpCthKOIEo5wLzogAKJ4uBjf8Ro6clKUbgwggIxmGQZMLe5kIETFtfvd579pq/QMJ2F J27cQoXsLgqnZHQYu3vVS6/2obNgUIo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xraoP+ub; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252676; a=rsa-sha256; cv=none; b=R01ZPm9HflsX71R4LGwLnuMPGBf0nPebMw+xSbxuhFvZ0/Q8YrlVzycva+FVt8tHKWMnPw J7R7PMHqQESbCZOY1o9XaStX2ss5Fq/Ad7Pr33nKWt2Qh3hyWqAq0ZB8j03R9ScQqz1TnQ 5BQFnJorgp0Z9lx/JtX+Un9ksOX90CA= Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-565a3cdba71so8897097b3.0 for ; Thu, 08 Jun 2023 12:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252675; x=1688844675; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=xraoP+ub8QawPiBDd1NtmoCJ7Yde5e/+U+FNO1p7rYE1UZXZOAo1PDwcjZq5EwJthR dV+vHCNMFKAoTdxBpkTX1DtrPJTkyYQzzcTJ6+Hvz6BbVAyle5wD2VnxGl+fo8KRjuW1 6lph5KG8FATG8Els+mnLkzVfzKtCZbvKkrDIrFy8tA1swRHwRpg7mlfmIfHBFYp2tEz0 /MtFJlEM4CazKliayJD7LKXK8RlITlLW8oxbTF1Qs6fFP4vrk+enY/g6/q9Fbkg7+DmC flfsqeHeLuLJ1bEDqfGSKk77gUrt/I37di/bcF7XR9pfVd+mrCw58/52flYr3BiOm9us kFmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252675; x=1688844675; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=i2xe7wxLCPIasedrjwXVr23eF31oanwaUbaZpk1BJnh3LX9VxnYqOZckaDziVJC2aS NKoOeimmDFfRmIc8YkRwXaf93+vhnEiEqUo/eOXr5wna05aZJqIotjDJRH0nduouqG44 Wbegw8WF96nL3gWVmb5k1msScbUtZScyYM7aqk0AH9LOC2fEy7/6GkITNps98gprIO9z Va2C91lO3lkoNG9vOCXKdy2qneMZgclXoRUDlKuR+0KYs63tbi5aRYARlJGvn5YDCI24 ODnHp60Img5gF2g98ilhczGx8RMuzIpDZB4165qpqJ16xWmHnY0ZD1/f3ST87jenu9bZ Qvow== X-Gm-Message-State: AC+VfDy+xgiqZ8XEf6FubooyNBLdXUnH15w8nSO5j8FwsIvoXwJ/qK7+ Byc1zWfAb9vgDxL+8zFwkOTNUA== X-Google-Smtp-Source: ACHHUZ7QSwZkgLD2hJa5LAg1G48lqiWohJ5hVZ29HKnSz0REpapDpLCYy6czmfzJtz/zE4Z2iELuXA== X-Received: by 2002:a81:8986:0:b0:561:d1ef:3723 with SMTP id z128-20020a818986000000b00561d1ef3723mr688963ywf.38.1686252675399; Thu, 08 Jun 2023 12:31:15 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a6-20020a816606000000b0055aaccfa2c7sm114090ywc.91.2023.06.08.12.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:31:14 -0700 (PDT) Date: Thu, 8 Jun 2023 12:31:10 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 18/23] sparc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 760BF2001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bt7rrwaks9surm8b6owx1556z9jwwn4a X-HE-Tag: 1686252676-296449 X-HE-Meta: U2FsdGVkX1/C5QkRYQ7STtIU2iH8e8NlbC0QrnkDQiIrew8Z3Tmo4bP31dLlsTiuNdOjcD2W9aZOVx6iHOSABameSRtGWGsGKxm0F+YYgh+jMRAuQocxJbhyQRjsekFhva0B2OzAP7czr6JFCpjyPvmfZKjVxb5vbol+JEhlphXF5DgPL2fQWhruikoKPpTwTg1xWHNPU9gDXzxppUDhl/MHuCHTD6JA+fmdu1ZUrHXFOERJ+joPDZYM+fahNq2n4zl6n+/8PZix6TXX4VaB6wwwEn7hNszWymfICqowsfG5BnfKfz+AoHdkfInw7gFsowBWpleYo83sbG7R/4IX8rvNfrvGsJazJsMoxpEORoOxotUS2IW8be3a1nkmuGgMue4trBtQ+E5RZpf2gWWsPGxBTpFmHxc1d71mhIfwLWOPcpolgtGQ1cDf8u6VcZ1crkJlpXf5QM3WKPooZ7m+RY9kjbvXrmdq7tXYh8gzPnvB/y2lWpXdy9FFBpb7VRScsj5yqBC1fabd8ge1AiaRAl916aqTxeQ6c+e1H10E7y6aqZ42Ew2z2X2kj0D3L3IbnyUGGLDr5j67ZjgjwlXn37LkK2KB1BJrjjRv+ZhRvP51viP1qcaQHz6iPkEEN5qTSRHdblP5ab2JaEKW9qQkgEnNA+2XDDMBx2zJd3BkSeoBxbBsknvGE6/JF/l9UGCdZltI9JesL3jwcbhEuf1Zvt+A6clF8R+skt0gvzG/cdlvYdgOgp2XjNWfXlqdRzrUA3hs6zeO5qRQ7qr5LUUG8PniE14vLisWuWmOkxdejixll4njNS2Skp7ac0eUUBD+qhiAmlWWuy5UgSEam07gpNSEBViaoD/pEFC0nTwZJyDCvrjZjzB7SphbK1P/cz/TNVUzm1xYvosoXwB55/n91ZS938AnZRGLrViFGPu98ej7QstYyguMSa/JtC0ZPttdGzl+MBBiWdK7W+oy0Ll kqcrKAdH aZJKPPJtwGiMs1vAUeoqdbRoRAKuPiGfMDHLbIrfu1LMsdEadGBsRRQqmcNSXWi8NyFAMS/iVdsqIJk5vXyj9o+ZHnCYph9KTEFeRk/3dis/ZA4edxcupGJ5QCrf90JlX5tXRyxi9Fiu1lX6uc0dMrjgEdFgATU9IQ8V4CKwhYNV8UoqjK8LcWqlyo5yndR4ECI9yFyL3Y1YrAEV0rWl3WkHDcPNPrCpuRstCoYQjSAyakIGG6k4DT8Ye0m2T0IgsV1fSvUEwsxzHGLcrAHRRtrow2qpw1u2o2kPRP4TbdAIo4Mm0MQMFStNOnib0HmBZnl0N5Emn50y6VNtjAaTSSv1EcSzw1ykcH7gBOCo8gyPkr1vqjo/+Vb+8hPbvLTCJm1zaph2wghltdIq0UQZwC5LnvUOxdYG9jgTVQ0uf1CDCreYlyYhN/8CalQ== 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: pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/sparc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index d8e0e3c7038d..d7018823206c 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -298,7 +298,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (sz >= PMD_SIZE) return (pte_t *)pmd; - return pte_alloc_map(mm, pmd, addr); + return pte_alloc_huge(mm, pmd, addr); } pte_t *huge_pte_offset(struct mm_struct *mm, @@ -325,7 +325,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return NULL; if (is_hugetlb_pmd(*pmd)) return (pte_t *)pmd; - return pte_offset_map(pmd, addr); + return pte_offset_huge(pmd, addr); } void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, From patchwork Thu Jun 8 19:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 666CCC7EE29 for ; Thu, 8 Jun 2023 19:32:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 053768E0002; Thu, 8 Jun 2023 15:32:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0039E8E0001; Thu, 8 Jun 2023 15:32:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0E258E0002; Thu, 8 Jun 2023 15:32:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D453F8E0001 for ; Thu, 8 Jun 2023 15:32:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A8F88C0475 for ; Thu, 8 Jun 2023 19:32:43 +0000 (UTC) X-FDA: 80880577806.26.FE51C66 Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by imf16.hostedemail.com (Postfix) with ESMTP id CAF4B180010 for ; Thu, 8 Jun 2023 19:32:41 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=24t2BtFN; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of hughd@google.com designates 209.85.219.174 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252761; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=RRyHSgZWMlAn3nu1+3dpIlAUsMNJ1CGb9VJUPNtNHN/hXz0B3pRIKPL+jMju5+xtL0WZVa Q0zb82r83oBHMUe+qqQMf8TS6RsAqcgvfV5WEHosAQfSOMS68YxPdicLybIR20ejAq9VfJ Z5dD1pyUIMaRnnRKk2DDFQmOG4EgeDo= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=24t2BtFN; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of hughd@google.com designates 209.85.219.174 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252761; a=rsa-sha256; cv=none; b=JSZy1U9RqJVn8XA4aNjTTzkeSETOIoe6OEuXo/VC+vqCUwWW8A53jh5qnuJPa0vhFmPRll FfKVjmTvhEw3KE0gEchvh1sgl8Iwzt9Lg8XQQ0DT6WV9onOds3J4CLcpsej9TDZ9tc1Gjj t/5nG4lDLCH2PCM4Ej9vxKvjkSWZaMA= Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-bacfb7acdb7so1080730276.0 for ; Thu, 08 Jun 2023 12:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=24t2BtFN5HXeEnWp4wmjqaz3ba7RZTv3BWN8E2lDsHPicXiEJRz9TlH2WLVzGd8CdE of2yNqyqdnSUhfcGIlOsfvovWhpuG53taZz/x9DR/Th5PIOmYH7IKtDML+zGnAiDR7yW CrmldFZSb2omivw75gysl+pOyy7IV7uE8SzN+doaYOlbMw3OdLZlcS0TMi0ZgvmIeRDQ MJq/tuPeT8xPnNmBXjEKmMP3qPQGwnStEjRQklqNa0dtkxFHtF5PvuvrSEAvR9DPSdcW McnyT5sGz87Djsd0XbZMK04rqnZG7iDmeQmmJXSZxSQJU2i6hoMEpfITW8x1lOY4n4VU tBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=cOxMuPoIVgKO9TpFguuLAhF37ZBPbGPsmBS8+mqv1K8OzzXPfupojM3pst9vNqveuG O3XRJVj8eCzjTM5rV5wVwr5JGpYtKL/EZvLI0k6H+Os0wRzL56kA1ok/P+GUtfwiS5zf W8CZ8+d1ouEIt2NTWlnDf6GN5XjCkibgyf6FRowR6H0DMWtpXRZgDAQOG9Cgoh2m+EqU mXF6ib3hRd6R4JagCwBQarxrDhFoClMUbBnQGG3TBAk5G9pZsjD8U45yuFWkr6v9m0R/ x9hRVirKLjzGmgCidnSelLsJs/o6ee20o7OdFD620TXnXdJSxMvtTV9lmix+Qhzd3la/ QmlQ== X-Gm-Message-State: AC+VfDzEeBVPEeK264nMFvN+i71YmLvojzStCZzTc4YcuwjmPl4WCodN mD6fkOIg5Ve3qv5fx0QTlHy9NQ== X-Google-Smtp-Source: ACHHUZ6ZLPO3tFN/Ri9lGF19A4q4QfMsE5CXjcYyyqXlwc0QGFL9qBHigDBgxXippDMgVek84lg5YA== X-Received: by 2002:a25:f40b:0:b0:ba8:54c4:3136 with SMTP id q11-20020a25f40b000000b00ba854c43136mr602795ybd.52.1686252760634; Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k7-20020a258c07000000b00bb0ae4221b8sm428913ybl.43.2023.06.08.12.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Date: Thu, 8 Jun 2023 12:32:36 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 19/23] sparc: allow pte_offset_map() to fail In-Reply-To: Message-ID: <22165adb-581c-9ce1-8aa6-a3385cd39055@google.com> References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CAF4B180010 X-Stat-Signature: pzpdbrcjf3a88tahbd5acr1d7k4p1e3u X-HE-Tag: 1686252761-565537 X-HE-Meta: U2FsdGVkX1/HBey7IHS3eSt66s9mhtiSRYvyQ0n2oyu4eFdzDfyQvGT8WZR1sNjsu9Y++CSMBtQkGpo1jjViwpXe8gnHBDNG/NIq7aGe1ULkXD9ad2uC+2PserC5BSzwttk4jxq78KlVyaVlqm/lBrtbYkuf6FrVQfYxPGFFppGAHMsVQ4q39DGDTJ9o8fm7U92zDzGcanvGanyuTbueoiqsnIfD6iuuoJSDDUoWVdSbHnt6UQQvV3iBV5FFNZKpiPdpwetcPVgtnlUtwH6a3OGfAX234fBJxp9yCmm5CkI5AFTRZl7TJIMO4ZKIlGU1mwA0sxbdRw3sznpwTevAN7Q43snIkvU4KlQbczrxYL7QGMClmpN5mfTX8i5CacMGhut61cZ5VNFX6/L6IVWjhp2Bm9+X518IiNKvIeRHBxMb/udnLUNKWsFhDxczSf04PopuXOvvn7Ou/+bXcli/eruABT8LDUxO6cDZR9wzDWLWC/3N6AV3MbgVHp3pLdnxraJ9xJtxtMGmj9Bz5Vve3zJsoJp0jHrLhnrvIUJrv3LW0UBFl94AdkZXpJ/xZHEd4G7VdXYWCTAloR/Nf3vtzXtmj2ABHk9lXP9w2EJdvdDCxITDDrFgTs8/BmbI2E/0TNfHfVbGj+P6f2HxKQU0yD3cnfLHD34IdBWg0RtygTVo0RTAq7/0iBFSM5//xw6iK+RKwPoLpeDaTbTDFGE7OeBLxFnBfRl7zuHVch90Jct0dPrGvSZ2prZppDEGADG0vZIWFr/o+LLxjtV5eETS2Rd6NDace6IJoBvokmKGX6golsYI9OvNqCfU2M1P44VyUoxR+BV1B6PinTku3ZkmlWWFnC3VOOxQDeOJzfJiiC6AUsCplRXppWHat8VNkRcljvrx7jdhDwh9yFEN9DXeAGkdgiyJ0pwm9F03p4sUU/Sz06Fp9DGfPgFJYW5i0toT3lJMemXS8REa/5qUpYR 2V+YywOz +lFTBi/KwnzzOoJCPRTrX8PD0uRA7tSLIXRQvDQx1WSyyzA6plmmOyyhpTZYAv0tYPoiRUrgEhxSTezGL91kPSc2OMWxzdrxOf/2Xcv7Ptz5Urdry0S9fXQFSBaOJR3YYe4bIYPRpIq5BMmEs8ITnkGixKKtLzc2ImEOe65ummqb9/0/FtgCyFtB1A2JjoatguvLJ54RQUQfQCY4s0TY2UfzAwZp07jrEEIEAAq7fxJESf+Q8AahGT2EYSuELRcNHE0zWYp17FqcpOnmEjieG2L3/Fm69z7KljVG7gWPVOOcJwXKm5p63tbu4Y0n9ANy2KdK0SH2/cGWhehUM4ErYmZdVqIs6LtOw232/gr2GsfzmdmVQkW2fgpIuLAuvfnY2Eipv9Ag0fMZzx+dC0ezI415H3DdycW4vk/Ue0KFkWAF0hJah10XQOXQ2OQ== 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/sparc/kernel/signal32.c | 2 ++ arch/sparc/mm/fault_64.c | 3 +++ arch/sparc/mm/tlb.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c index dad38960d1a8..ca450c7bc53f 100644 --- a/arch/sparc/kernel/signal32.c +++ b/arch/sparc/kernel/signal32.c @@ -328,6 +328,8 @@ static void flush_signal_insns(unsigned long address) goto out_irqs_on; ptep = pte_offset_map(pmdp, address); + if (!ptep) + goto out_irqs_on; pte = *ptep; if (!pte_present(pte)) goto out_unmap; diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index d91305de694c..d8a407fbe350 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -99,6 +99,7 @@ static unsigned int get_user_insn(unsigned long tpc) local_irq_disable(); pmdp = pmd_offset(pudp, tpc); +again: if (pmd_none(*pmdp) || unlikely(pmd_bad(*pmdp))) goto out_irq_enable; @@ -115,6 +116,8 @@ static unsigned int get_user_insn(unsigned long tpc) #endif { ptep = pte_offset_map(pmdp, tpc); + if (!ptep) + goto again; pte = *ptep; if (pte_present(pte)) { pa = (pte_pfn(pte) << PAGE_SHIFT); diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 9a725547578e..7ecf8556947a 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -149,6 +149,8 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, pte_t *pte; pte = pte_offset_map(&pmd, vaddr); + if (!pte) + return; end = vaddr + HPAGE_SIZE; while (vaddr < end) { if (pte_val(*pte) & _PAGE_VALID) { From patchwork Thu Jun 8 19:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEEF5C7EE2E for ; Thu, 8 Jun 2023 19:33:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F4508E0005; Thu, 8 Jun 2023 15:33:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A4068E0001; Thu, 8 Jun 2023 15:33:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66E918E0005; Thu, 8 Jun 2023 15:33:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 599408E0001 for ; Thu, 8 Jun 2023 15:33:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2D28D1C7A1C for ; Thu, 8 Jun 2023 19:33:48 +0000 (UTC) X-FDA: 80880580536.28.78D22C9 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf18.hostedemail.com (Postfix) with ESMTP id 59A661C001E for ; Thu, 8 Jun 2023 19:33:46 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=1MipXBHl; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252826; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=tes8uNJzICiy/IatO/OUHG2XqoxjlZMuE1qtM2GPwsM0hpVV7bDEy2kN0Z/V3U+LkgMi+5 LYPu3E2iZdkYBIrTDcNyWsB2LdOeKokfVXXz+zYlyQKpdgJLRRO58uM24/3Aw8AwZ84QRt q0gPOS5s2yOzkktmXBCsgSoRpY4RiIQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=1MipXBHl; spf=pass (imf18.hostedemail.com: domain of hughd@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252826; a=rsa-sha256; cv=none; b=Shl+Vjh3G3f91akQPameHdRH2jEoLwOoaP+wl/6Rkjj4YfAJrSkJsKATuJGcm/1nnxeSAu l8RP3HspNjVO62fftrUR5Z3zJvMpsGdw8HvXP13WfqbYcIsUc5ldYMZBlTr47+2xnmDqTA 2oAyu/5k+dc6tW2F/+IaBfcBssDXmUI= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-bad142be0ebso1045118276.3 for ; Thu, 08 Jun 2023 12:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252825; x=1688844825; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=1MipXBHlCgYLfuzhfDW5ZwUI8FUsKSE60AsqsEXw+S0tSnJg5UOmjRzYFHDLdCAJt8 yMkipeQIgxyZw78rcQRYlMT5UpzdJcWoIksfCpz/ydUZz6ZkI9xKVrX6kds0LvhIjEzt HS+XptOf+RYBmq4zm9J7IFzhbS7dVhum1cFHfBZOiQ+s0XEOXeKn/G9+gcrTCmXECFnx 8UoS3IHRM3ERDzeB2SU7OV6jhVelmg9iMKHzFrc8fJmEIq5uTYUBI9N7JZJvtQPChnnD 4+2NEzxtpjJGm4NjJthMMPpAkAfI8kDJwzbA28gjtv0iKudNeA4e3nFqgNhPbC/JEIjR C7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252825; x=1688844825; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=HDG7sRnL3aSakEqzHHEpe/6sI2z6Lrqovl+FMcrMfYtVXTO0A+BJrtYgYHNqFkJNJ4 VdXKRKCtU8tnxPRNEyWdzV1xbSrU2msrcYLNk+lFaoT88OWpzKt14kKV+gBBHOvQ92BL X7ngZXmBN3FNF8jbbGJD8ooQjFKMhVqPzBNSPR127Nh/TlZmt5NjvQFKmyfVNAvE1aTV gIVvNd7jYWKgBa0974zGE0+Aa69NEEF2rrfIGANS1iMQR3hlLpiD1vajNPClDnKm3qhi TIFUp/lTIjTvNTi8pX+IEsmoMynTR1ULgLYjlAnYE4A1RMf447BtZ5shEWUEG9Wjy3ia HmAw== X-Gm-Message-State: AC+VfDynrUODJvF7rmZFGEWREuOMUjbWGkyBKsF/08V5DTn6M2lWKJMo HDtqF7aktSAA9SJv2U4UUBzXfg== X-Google-Smtp-Source: ACHHUZ5fRes1KtQJuT48o2Wy/FuADD12yA75OXTij0wfUrs7MG5//8NY8cIlqChq28IRelwNgydDPg== X-Received: by 2002:a25:868e:0:b0:bad:1055:c9fd with SMTP id z14-20020a25868e000000b00bad1055c9fdmr569763ybk.49.1686252825296; Thu, 08 Jun 2023 12:33:45 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e188-20020a251ec5000000b00baca49c80dcsm448503ybe.28.2023.06.08.12.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:33:44 -0700 (PDT) Date: Thu, 8 Jun 2023 12:33:40 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 20/23] sparc: iounit and iommu use pte_offset_kernel() In-Reply-To: Message-ID: <99962272-12ff-975d-bf7f-7fd5d95a2df5@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 59A661C001E X-Rspam-User: X-Stat-Signature: 1i4swzo5q63xqjzyas67pbdx8wqy1zty X-Rspamd-Server: rspam01 X-HE-Tag: 1686252826-618491 X-HE-Meta: U2FsdGVkX1+GWZsATPt2FDy2aOrSpheE/pMFfzTREgsCc4IILSGQO9rO+TTb8DlWwJwiGOA+1E1oF4R1Ghh79nwR9p96k0elf9JmFqbaLoPGVRzcQhN6waOQh+Frk9FKupncY5278wr6SdetNdfkaItOY44lBe1zzv2O2nJHp1Q+gCfewizdC4yQhXqntQL3L1WGR5vvQo/kndwlFGuKSEd/nur9XGX/NLV9nwt9FrW50HjPHhtUOi0EtfFadp96LVj67aml1hq2ITqOeOUzKllE0mKHIwJL4MjlyGEN0BdB1lLwYbFJygXzUTqncNxslsDnCs4XpUV4VBHNjU4DVQGUHVICLED2TQ1dp/DUwxiE2Oij8vCVT+4CKKDNToRkAuzt6mkbApmgsHgudxg1CTFBkc/Ml1C1D0Npg5P+Uvxmn1JbGUpfttK4TzrFNFRZoxZX3JFwPxf9YxQdYPvGlyYA9fiExyeIlPEsQOwr3+3iMeFe6DNbiyLu/8mwZyqsuwpWn1abjh+K0PT45B0V7fnZb/GmH4ND7wyXbn1Diu0kmifHdX3S7nHU11+Qq+AcE9UokERMilInCcrihBOV/lmmUsDfFR0QqESxLbcLsawpA0Lte7czkQTO46tr9BaCS3d1nutwuWey/uqNDFS61vB2RWvde40wodwRqyifbHxpT8g7CYHDXZuITh17ULgrsPXrfMmZxEJRfmaZ+3S7GyAqh++dWbgYUIqIrejlHZd1Hte4xNuRt3FKzQZa9uIR0XPNmLV1aU6bvPDR3hoK4y0WqRnXU/Sz+zvUMj/+eiow6tXePdIDo57PiL5KXshx96At3cBFeaYfyjX8tBiu/7sTLVKxnndcZslvEMxhibXZkPbbMhx0xGNP10Xv349fQek20brBTYbdnWg+jlhj5OuSkwx7tsgtqZyClApFKhIwgQsZbT4aPiUha001ipIU7bIAv5uVUZAIuO6oAo/ 430+IrVD 6n5Qra8EH/6PQVrJUMKTfyvPPvK5HGCmDajaAx1W5tcuc9MIpU9W69OmFUWvVQvTK8vWQYkClRE0p7UpQd018mK5x6jFpLDIwvLfZ9uofl0Tgksio+4/6JvtwxzicFtnTljetX/sV8EMbcdY3mu/fbJorMKOnup3zBzKzlLdmZf+3EvOTokTeTYnBBj+pzNWa8JwJOR8UD9/Lnrg88GFhNDZiPilMWvMgD1OUz8HUWqOlO8Ss+BelOwCBCVYjFHyrCEkwSXs0TZsoxQyvJE1QuHW/D1CPhqcIMHL8tJfifgHlqIq7NbCfT2TxySMR2kZ6mltmgm1tCCIfibvu6vhPUtLF4sPV03IRSaUL28Y/bnubRvxU2rzlneK0AjPE0NKdFfEgKvgvm9ToFO3s/jE8vrNAhGhWhw5EbQzx+JV6/+gMmmfuXh/vJXS4Kg== 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: iounit_alloc() and sbus_iommu_alloc() are working from pmd_off_k(), so should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/sparc/mm/io-unit.c | 2 +- arch/sparc/mm/iommu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index bf3e6d2fe5d9..133dd42570d6 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c @@ -244,7 +244,7 @@ static void *iounit_alloc(struct device *dev, size_t len, long i; pmdp = pmd_off_k(addr); - ptep = pte_offset_map(pmdp, addr); + ptep = pte_offset_kernel(pmdp, addr); set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot)); diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 9e3f6933ca13..3a6caef68348 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c @@ -358,7 +358,7 @@ static void *sbus_iommu_alloc(struct device *dev, size_t len, __flush_page_to_ram(page); pmdp = pmd_off_k(addr); - ptep = pte_offset_map(pmdp, addr); + ptep = pte_offset_kernel(pmdp, addr); set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot)); } From patchwork Thu Jun 8 19:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03581C7EE29 for ; Thu, 8 Jun 2023 19:35:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A11D8E0005; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92A878E0001; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5AC8E0005; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 64F4A8E0001 for ; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 342921C7A1F for ; Thu, 8 Jun 2023 19:35:17 +0000 (UTC) X-FDA: 80880584274.03.DF6125D Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf09.hostedemail.com (Postfix) with ESMTP id 27098140011 for ; Thu, 8 Jun 2023 19:35:14 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=IGMMSO5m; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252915; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=VDGVwRPswRdgA2P1vgl7cbUEtRXfeNo3RcPbiQIXyW9KqP40mE3Ln3o6TWzXLRe95rNbpW 1LPFivViPQu4OAPJT8zQU3WUxNfDgrf+QEdyCQmpgFDT7EIn+cjmV+RbqxgPfufxyrCAaz Q65mIc0yk2fLvVZXcKYnORuA7e2NY7c= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=IGMMSO5m; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252915; a=rsa-sha256; cv=none; b=IaymTKboqb3ubE2FPbDwE2OSrcZbjCreEVtTWdYRq+KzldjkWwhkJr4KyyjpuSEGQUbsFX LdN47Z8fLDzhLWjY55un33VsI5paN915HHQG4oYm1fgPpfW8aS5ioB3Esrhhott5PIHRhp KmEIlU8+34RnAyxOL1cUL2mDPVon1Tc= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-392116b8f31so42196b6e.2 for ; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252914; x=1688844914; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=IGMMSO5mseD7tMe+rRtOIzITR5LLF6gSj6DDkJB5GA4sfv+l0xQcNm+4SRn9cSTA+K bzPDoNl4QAtanNBNtw4EO4Jh9TOBqBvtAeMzqVR0kpqSUA/L/bvTchhidEBh3MP4oHsE 7zzo3x/NewiOg3sZOatxsUi0TcVM8A38QB4oSQfrmI5m9Mp6eOh1v9F27aPIV0BM3Y9m jqm85o0LQ0rhNRucFZ0i7HQcaeWJpsz64iPtGPt0XsZOnDRNlY3xajIra5PnrJSK9OoE jKjJyQ6PxwcJN3nFoobZxXBieXcQTT3OQ2VZ4F5eEeV/iMRllpjt6DpnkAeaktGC324Y dn+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252914; x=1688844914; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=jNrHYvqR8I1uJTS2HtZyuirOVuSa5QqSA8EmnSSaX3YDXiyxiczQwanNOCGo+c5hbe 1l3kAM5Soi9ePPg+bi+FsTOIC835HuLa2aJsngOjS02DKQOKE7GNVikXt69UEVPdjrKt S+Qslk52TLwDWiHRDcWKN5o2pQf09gPhhC+JdptFdnVBYIPfYgoQW8S2jxSqgFqECw+3 +kbguGUWrqteooqGpzGbElw0NUZwIswqPxNV8XjEZ045flCvVp40IEJkMCQmQNQIjqPq /eYsqVUPtrPD3UvQ7SCipIldezpELeJkjKO4ycoCs9wdt4tZHj8i27m7LI6Mp/psw5kZ KlUQ== X-Gm-Message-State: AC+VfDy12DfawMcKIksW9neuesH6bXZ8uScnw2axgCZAb9Itov7loOJU mou9Qg4dg7wZyMS/Xpfp+D6QCg== X-Google-Smtp-Source: ACHHUZ7gdIjuH/6E76ySqRN8WufhpANLQ+j2jIa26lg+ERfDlrQvd+huECUh9/LluoEXiOqTeuRs9w== X-Received: by 2002:a05:6808:cd:b0:39a:519c:2a6a with SMTP id t13-20020a05680800cd00b0039a519c2a6amr6836715oic.43.1686252914190; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id g137-20020a0ddd8f000000b0055d8768408dsm108055ywe.105.2023.06.08.12.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:35:13 -0700 (PDT) Date: Thu, 8 Jun 2023 12:35:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 21/23] x86: Allow get_locked_pte() to fail In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 27098140011 X-Stat-Signature: 7zu47zkaexc65y6os8gndqnqobk69bzz X-Rspam-User: X-HE-Tag: 1686252914-93952 X-HE-Meta: U2FsdGVkX1/TrZg17wGb3u8HRosv5cAMR6EXjZ5rfJjnYepVmir4JoxsNlquO5ISnhwBTwdZoisUhePuhjUM0QAdkUwdK2GQi++f/7PFm+9UCayrMATSDU2wE0ewHPHt/DGRz9XHN5yWc1MYbyOC4UeQ5uRvvbZXYAiEqCPZT3294GsONlB/yoLPQPSlag/TgpnfK9klNGfYoUrXQ7mLJWRPBmEHRlAxY7nE5yf+784UN8nJu2i7NI7HpodalXkAfqGaNr3aPl4o9aPu4jq4R1KylAaTv/f9S1kpRSO7bkv9IJgGDHYX09q2dRcVTeBf486qxeKQTS0c6gF4D86WPUFPynbeAiX96bpQwonHaHGpAUUPI0BSVGZeKLM8R3AHTGWV/idrshua1XHISDa2rS06bKadDMH1i9pLS7p6muPmTQdARcxr7tAaKgHW2Z/zJc+2WG+jueiPaHxI7W3HbXFYv0O5hN4qckF7rGP/XQYJAIg84hFvwOvTNEHDobu1oV/uN+grawelAzo1y8s9f/gRhm4QQofO5Fgn65tQn3th63/x6n11L23/TboNErqIG0+OpQKpaStVaSIYHQJxeN/iUVp/d7Hal4cTEcQrbE1TAywws3f51fDjBWSVmRLDbdXaoEtGTRPlFnxCui1vWLuSh9t1LnufkFDvtmGYOxtHOQ+xe5Qh/OqfKlIAFkU+crLIPX3jhj5kllKOrFkgk7kGiRSPXOnyvI1FNnDt41EzH6DWKzfkk5q6fSHyVGT7kasUS3OQ7msH1PdqYutgTve64V0YJ4UXXBAvXMW0JDjH8WhoquwUxEYmIQmg9261KMX8OVpQdgeWTnglwYCJ10pRpi+xGzen4Xa2lrFFzTPctMwXZgF30H/Xot3WsdB9RJh4LQuGNhouJt8JiYWv8ElEsctY1hdRqxJ7tgNEHfLw9fiDG9biFu+zRqzFoBpBj0WkOgKCSZkiBYL04Nu U3yWZukG UDl+gTCIJchdGOuFRFbJSnLiYt1CzAhftzhvo0aUX252S9HlKEuGMvzMI9vevYHFviE0BOA8ycOwQk36bEeQ1vljHHlkXXTrpEEGgIB5pViELhBAcXQ6vEnfmNI4agsrTSy4E4YljIaeYNsGeVbs+UNVWw10u9GigjLkNyoUKtNbwjLv7RffNYcCC5Z2xW8h5nkYVmofgK5SaNrKgWrqA1EYTrEUNFbdYl1HVOP3P433V7vuAvjP7tadepZB2qD6fI6T+/o0wyzgbz23UFQb7svwBpZjCMolPernR5MCG6h3jPbz9hMNNzD5N9Djs5ic8buFFEOO1IitI4Rw3Q10PxdMRG0Sph496aQ1Pbc7STG+kXX6JuZZWqW4XSXYRtyrGeKekEyAD3JNwGdKuCGpGIJO+Fhbvmr/gw2EI8uafaEc9TUbJlwYEL++mWJseQSypQnOL/HYV4gIrt60= 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: In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/x86/kernel/ldt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index 525876e7b9f4..adc67f98819a 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -367,8 +367,10 @@ static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt) va = (unsigned long)ldt_slot_va(ldt->slot) + offset; ptep = get_locked_pte(mm, va, &ptl); - pte_clear(mm, va, ptep); - pte_unmap_unlock(ptep, ptl); + if (!WARN_ON_ONCE(!ptep)) { + pte_clear(mm, va, ptep); + pte_unmap_unlock(ptep, ptl); + } } va = (unsigned long)ldt_slot_va(ldt->slot); From patchwork Thu Jun 8 19:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D585C7EE29 for ; Thu, 8 Jun 2023 19:36:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EE228E0002; Thu, 8 Jun 2023 15:36:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0778D8E0001; Thu, 8 Jun 2023 15:36:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E33798E0002; Thu, 8 Jun 2023 15:36:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D1B998E0001 for ; Thu, 8 Jun 2023 15:36:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9B77BC0492 for ; Thu, 8 Jun 2023 19:36:33 +0000 (UTC) X-FDA: 80880587466.26.381CB64 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf21.hostedemail.com (Postfix) with ESMTP id A01F31C000F for ; Thu, 8 Jun 2023 19:36:31 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=7iZl7qFo; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252991; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=WCIPs6gvaZAEyYrc6z6IxqbNbjAlzAj2o71lMRh2oBayiVVUMAVMlyrKDo1PHYV7JUyCjh 7KzLBKNlYHqPUhWPFrZLDfsvrE1iCU7lBQuuXgCovsmnaINDD2hhmqRZqiFSXlAwvbEQ82 2kaSmD3Bpo6XEgP+s++FTYkbpZ/YZlo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=7iZl7qFo; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252991; a=rsa-sha256; cv=none; b=M4dT/fwTOA7E7r0R7JLhbYwFnVzX1gQq3MV4Qv3iXGBw1NJAzir0VkAWm51/Jhy+gwb9wk lbP/vR6F1Q02Z4D2jwLw94AXUt0eW3nFcYSHpm9CTSkhBMZl5YH7bx1GrxkOcRlT0fDyn3 TsKPcrteyJvlO9tX8AqPpbZtuTilWUk= Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-569fc874498so9483357b3.1 for ; Thu, 08 Jun 2023 12:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252991; x=1688844991; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=7iZl7qFoE643/vqqfaylOOM4UugSzxQOXfGxIkvhFgrLBJMpREbmLbhzK1Dfpeq7sW vLxMNbMxtYruESXi/vLA/FRPFy86oy/Rlv/K+QRhWyPjxrgHE6clF71I8HICL+Wbu4D8 52TIPF5OsTmaSTlVcpOmlJ2hXgN4iVitvobit3uBB1+XryThJwAiK1B3ovBLWTXnWBEi ML7bTpBpfErXrO5jZn41yk5x35HzdiBPWQx9RrfkGfIWSKYY13HndzOzcbi8dz53N7Pe Ykc3xEYKN/aDtb36dEI3aYN9owd5brP5GXTjP0NKjFTbVVbOSNnZMLMGudJLdaSlcXEi 8u1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252991; x=1688844991; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=RLYWJFHcUhQEC0dEY1MfMnx8qIdOBbmaHfEl058+XexPQUa2fNjwcMvS6lVQKN2uCv l5baJpK3Xk+L1iCl518mXlp7wjwmPBlbP43vPfBIwzG4M6dSqdBQVgeXgP7WsKtpazfc k6i2emI8rpX4gmiojn7BR80zBs3nfANa3cwQ6f8Nnqsa8EyLoPMJEhhkqJGzODKZYK4p VyH4aplmuVCeGWq6CBSvbhr1qTE/TrUXuqdlXPTYdqajRM6ntpV6Plco+m4lbMGqxCr+ KaaHsnDebZ6wtuOCAZIqigTa1kCJ8A7xSMgWJscgJlcpFY6kY7sihBwrbR/SB2CYdABc 0xuA== X-Gm-Message-State: AC+VfDxBxQLxH2NPAwDDypLNud3YUvxgZXi+0qsmcGdM4nt+q8yle0zK o9fnoy6D0ol3hB/V2WqgUbqz8w== X-Google-Smtp-Source: ACHHUZ5QdxKuy9jo3MUvUBLJWa7hkCRN4WqLqFRikF/N35P5/sjJc9i1Jxr6DqBjKGQqjHCt1+UtTA== X-Received: by 2002:a0d:ef01:0:b0:568:d586:77bb with SMTP id y1-20020a0def01000000b00568d58677bbmr743298ywe.14.1686252990588; Thu, 08 Jun 2023 12:36:30 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a11-20020a81bb4b000000b00545dc7c4a9esm108298ywl.111.2023.06.08.12.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:36:30 -0700 (PDT) Date: Thu, 8 Jun 2023 12:36:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 22/23] x86: sme_populate_pgd() use pte_offset_kernel() In-Reply-To: Message-ID: <497d7777-736e-85f2-c37-aa6bcf155e4@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: A01F31C000F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ji3q3urre34fsfhsctzuiq7fy8d5kpto X-HE-Tag: 1686252991-371228 X-HE-Meta: U2FsdGVkX1/q50oqrhLuL3ZRZeTgK7Fm6ce3rGWWlxyF4DYyj3IgckaE2KD+/wFz39Cbj1KAA0cFH5Z6fnOL4KkwFP7PuQYQb3F+m3fD5y2QU6pPRtqsKHbaMw9qUwkMLzPpAQXEF83CqozkuW1nb/jAvrKWqlNOmxl0IX6J40u5usIo4+7aWVHOe/TXmjJFU4+PacQW7c7S8k7NT7WK3y6KLWQ5V4VMqeXcwY6wKWDGBbGsRa8n/DFONi41YazcDEMzCiLMExALH1BMTzuiNf3UvzbdQwNmypYadXhejj0pr3BWfUbp4OE5jTytpkbWKavyNPH7I9tlGuo72Xch9XiEI1wKJ72n6l8crIwC2S4VtbSOKqhtfikMyKaIKvPaQXVwvhcOZjV5Cx7WPbUTDMtCCuuRVDW63cnkccwcPSMGcpEn5nG1ACg/c3o27vdcjPGa3OVjvLRAUSeu34Teu3sbPGqDfcPQ1UPuERmfdftuVUI8ZOw2az8ME80kXeP0JIh9wNWTPXCP+rWitFdkffsEptqAYfKDnleet42MB+ociR0DM/7wfnYMe5LCLwCCP/G+aFlmIPWsaS39Xn0joiEfKnYW4+fSj9xFyTN4BgXBTe02AFWd8l0tStxpnq9X72BmceOYVk/fKGxcbbvMED6nZo/5cRLm8nDgiHn4ceLlksmryChHCEc0iLK9L5jN2J1PzgEbW/n1bFm33EsmJQ4ms7hee/brkgYD+dPYyE9Yt4z6VTWcYmGbaSF91sdE94FXRx+Kf8SNxD8tjvsicrWUXvc7429w13RczyCYMuinaNDfUJI/xojoA4z6uxUYMSnQK3wcst0fBKfrY2IS7OLtIKb4GtLzw66VBC7vM5MpjnSov1MfnVxVcUpJziaFdwsmxc2qml1GUgVvpztUAGVclYjGltvJ1C7c0ETgCkCahXXhR3nCpLW3uZu5AgAkUwPMVJy/BXER0yFHvWf NBGvGsVw XYYUrQb9kj8ZlmFJLkf5npHt+jOdAGOZFqGkzbQJz1dJtsR4J0pTCPUTi0mN4OGfjGlxHrCOvhr66JEKwdePsXL30qmRalLXsfTBM32ecknW55FHs20vC/9ZL9sZx1mwEK1CSL7aObTNbi5qOkRArYpBROjWCblH1Rl47Jir/lg5aoI3v3rGxv1LrFY5Y+B2r3SCwDxxc+GH+ov+Fat/BnzSFnlnU2sn/nMfCpKXIGC8kojfNGYtEAfh1yoSYBdT2lTev+UTU5fyizYvAjzkfVTgsanm+bMgE8igErp7iIWhVQV8PLOFYBHivjO2M0kG8AC7NmKYM3s5CV6QvZkJpdYyFjBjyFHJAYUpWCOSpF2drHK9dhBNHkLtTJJyztbw68EkzR2jOEOOtKOCgauBMiCACorrrjZpN/zAmK4Ev+RauEOcWAcE/kDSqpH9YPA5sUQ9tZQEcj3MyhJo= 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: sme_populate_pgd() is an __init function for sme_encrypt_kernel(): it should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/x86/mm/mem_encrypt_identity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index c6efcf559d88..a1ab542bdfd6 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -188,7 +188,7 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) if (pmd_large(*pmd)) return; - pte = pte_offset_map(pmd, ppd->vaddr); + pte = pte_offset_kernel(pmd, ppd->vaddr); if (pte_none(*pte)) set_pte(pte, __pte(ppd->paddr | ppd->pte_flags)); } From patchwork Thu Jun 8 19:37:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13272845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D80A4C7EE23 for ; Thu, 8 Jun 2023 19:37:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A5E38E0001; Thu, 8 Jun 2023 15:37:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 755336B0074; Thu, 8 Jun 2023 15:37:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D2C8E0001; Thu, 8 Jun 2023 15:37:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4EEFD6B0072 for ; Thu, 8 Jun 2023 15:37:57 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2092E8033A for ; Thu, 8 Jun 2023 19:37:57 +0000 (UTC) X-FDA: 80880590994.07.CDDD400 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf01.hostedemail.com (Postfix) with ESMTP id 51B0240011 for ; Thu, 8 Jun 2023 19:37:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=wrjU6S4E; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686253074; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=eUUEExrfrwmOcWVoGwNf7N0oFqRUUPPcslAtZlyGBEHcksM4gS+Q7TpJhfFOeJe9UFHz/+ v4chvwwx44nMOZIFWDeC8v7LThPxo0/Um04Bf3E4/xAA6S50yzG2Phh+8zCR97TdHSOnZ7 Ev3HbOdK50Vu/0yBaRzTLbXzxMO2jGE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=wrjU6S4E; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686253074; a=rsa-sha256; cv=none; b=IapfYMfsVMiEJ+RqZRaj3YHr7Y9PGPFTH/+LJsBIeWyJ7FwNT35Mc8Ai41K8znqPHxlsT1 uHkonpHs+VEpAhfyDP0yxtvoSK+9UIOeq1IivCMGQ02T8M3750XR2NDb+n8o4A9k4BY5ux B0jfi+zMdu+Pw52ZSfTrYEpz5cjwL3s= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-56896c77434so8890497b3.0 for ; Thu, 08 Jun 2023 12:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686253073; x=1688845073; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=wrjU6S4EMiU3Ufcg2KZPT551Y8sNhg4QKjD2hAgSPlGh9yj39Rxf3Ke0FjcZO6VxtG ALh4CVjSqM9GtJPRdIfEgNIlV/EEkptkG6e4IMSsrcpQSqGrj44uojyylNmPW3FhQBzm h+3YVxQpJctPazelaypN7o1DBk1YFmyjCLOyVuE0ZSJNDZN1IWkDf39Bng35IMFfYc2S OuTO6+N3JH4bhYslynL29X9VjGEwK1A0ffza+fgs91l3oerVxPUep2x461PcKgDhp6i7 yNPgK4idQjhQRO3vK4IICQL9mYykeSLt5G3Lqvr2ymPPunZsH8KwR6J1BbGlfhLHc47C HKFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686253073; x=1688845073; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=Y3UsTvwxtQDDvTm3Y3UJSkULIztyxj8G8Y3vLbkRXQ9rzOmZk3goy0V8h8n45bjdDH 61hSPsfC0yDvoXv2+abpaHvIre2lv8nX3dwtsXD3JJcooUjMaMYOgsRyX7fhbUA8M7IC u6HS3Ii4okpbN+40S5m3q8YMD3tIkpNbq5i0SyxzRuLQwlboJcpk1skTus/jrYsrI708 CfeczBvAWAJl/9vDahuKYDWrodD+uCToVRZDUHtZKzgfqwZ+JT1VPmVeEOfoS7Pv4pTA So+EMW2Pp7cnkeduTxp2U4YPsS1AoFOlf/JuXQ7XucMbUx5tqWYXVpFw7fNm+QhZemxi cogA== X-Gm-Message-State: AC+VfDySFmXtddnHGsrjm41ATvPvw/hW9zOdujGKrg+bSHT/xQVwosSj LT97eUZRdEDUIJWGbGZa2bIeZg== X-Google-Smtp-Source: ACHHUZ7Ebli0p9041CLEfO4CyQQvBmxN41VJwJsuM0MQnf822wu8ZsrJRZ2ru1aILLAWUog5xqYpmw== X-Received: by 2002:a81:72d4:0:b0:560:f6ae:a71b with SMTP id n203-20020a8172d4000000b00560f6aea71bmr508956ywc.48.1686253073290; Thu, 08 Jun 2023 12:37:53 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id i133-20020a816d8b000000b0056953ab06c5sm114950ywc.95.2023.06.08.12.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:37:52 -0700 (PDT) Date: Thu, 8 Jun 2023 12:37:48 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 23/23] xtensa: add pte_unmap() to balance pte_offset_map() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 51B0240011 X-Rspam-User: X-Stat-Signature: iz1cc71p5ouhpy9rmy9xf879n4p6shkk X-Rspamd-Server: rspam01 X-HE-Tag: 1686253074-460703 X-HE-Meta: U2FsdGVkX186xcIxBIxyaIuNGCddSGRhQivpGYj36MtSTQuXRusTPth1JQV1fJw4mlFdSSIaqSpnyjrYMql6M6ZQ3iSeq9s7W44IE9eWxG1byR7L+QbfGVvUqCgDd0gtIKcfahp8PrOpGY0clBtPPuZZYacXgMZvqXugPjvaEE58WxTuhrhmAYM3/K+hinnTkvpde0kn0uXublvw1WecsSN01uRzX/7FUX+egjd2j+tAkiQn1BPB5c1Y2ZMRVlej8lH6RQCgfxrsSSP6cIKTtP7fup6NgvSnlTc/cvWPlxTPkkVBAO8EUUux6Rf+cEjrUbfWCwNJlBKoELqqlIX81rUIG3QqcuLN3oYZT1DXICKG5C+eNW3D94og1bCBl3VUCyxXdIt5Fs6ZqPpRKimE/17GW/3MWRVLke8fmQ47mojB5IKVR2W/5NVNfSLQMRZ/aecIDRMLIcVISdnB2W3zffHTjFDJ+gxICTzvD5JRjXAYtGg0mKSb3y30rM05Vun4AdSBCe3gfgCi//NZn7ARiPxifqPVs5CkqeQ4r2uW/muB7BNWcwWjg5VLU03JetdgbBHYLnZm7DT6cFtRX04xvy7sweMIyAkIMh8NCRweKC07DOd7y7LzxaYn/qLPxZnsa0RYcnBc+htM2sJQDRRw1FGKEu7smZevDvGhf1FuPCOELpkYIr2obtDWA83ekm3RxXG5164foTeBDPcrHT3pS0XaJed/ah8TBRGlOJzX0+FIdF07mZ0yZbh+MksFSpVMeM1UhWQ7ugruI6fGoMCGxlB6yZcObWY3Yc/JWxtUARpkL0hNz7YgqK4QbVOkriyHDzS5h9+3/NfB8IKTdePyK8Weq26BLDYmf4te9F91QJGJFlDxGkYoCxmVTxqd2af8ycrjCW0NmMMotLO+71bD44k8ROLV/LfNTuNKvFfqmdC9iYJcKcOgeB4NPvh3PdjqneAsgIvlZMOvFNdt9h/ sITS53SS 4gN9MSl0oQiZ8/EYmrLuaS6EUX9wamKgc/Qz7uqnN0vSJ9OZV34NMDiXoklpUr70xdkMn7qyGVJh7Wi3GLzEHPc0LNUpaTZQxpfMh0Jl1qDhSfzo/MXNWfZDThBFzzoipKZK+l/jejW9r6P56X428rqs6/ka/OMZaRhJrbRg32lpezoTMBCsNEPYzNhjo1Ucgqdf+XMkaFv+pz4YpBP1k2Vn7WrrUwTbIC4J2WSO6rL9xkap4cPK8JZlQprJ/GqyNJzFWzoNVvQSKq0eMML5RKt85bDYzCPLDDy4ao+VbjqsJtFiKiXzEt6IUj/UynY4VPDzs26jKYQAA6MAszrm9Uk8PY0kVVSMq0UddGSl+oEFDZkH3PICsipYlVP6UhXy15KcaxVaSqvqBRFbV0m3ffRldgFQl1TRWeGYfeSvVAjcOI/8kNueKE/VxYg== 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: To keep balance in future, remember to pte_unmap() after a successful pte_offset_map(). And act as if get_pte_for_vaddr() really needs a map there, to read the pteval before "unmapping", to be sure page table is not removed. Signed-off-by: Hugh Dickins --- arch/xtensa/mm/tlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index 27a477dae232..0a11fc5f185b 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c @@ -179,6 +179,7 @@ static unsigned get_pte_for_vaddr(unsigned vaddr) pud_t *pud; pmd_t *pmd; pte_t *pte; + unsigned int pteval; if (!mm) mm = task->active_mm; @@ -197,7 +198,9 @@ static unsigned get_pte_for_vaddr(unsigned vaddr) pte = pte_offset_map(pmd, vaddr); if (!pte) return 0; - return pte_val(*pte); + pteval = pte_val(*pte); + pte_unmap(pte); + return pteval; } enum {