From patchwork Wed May 10 04:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236318 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 1B5D6C77B7C for ; Wed, 10 May 2023 04:42:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C35A6B0071; Wed, 10 May 2023 00:42:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 373136B0072; Wed, 10 May 2023 00:42:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2132B6B0074; Wed, 10 May 2023 00:42:58 -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 112196B0071 for ; Wed, 10 May 2023 00:42:58 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D0DAB120455 for ; Wed, 10 May 2023 04:42:57 +0000 (UTC) X-FDA: 80773100394.28.A9ABA9F Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by imf10.hostedemail.com (Postfix) with ESMTP id 10D52C0008 for ; Wed, 10 May 2023 04:42:55 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=ATuPznBP; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.219.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=1683693776; 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=3JX1FpvyES7EcRdMa2LTZg48facKu+cmcsldQrPKmgjjKx76cHomm7wUsoAA2p8HCeWaxe vavmZ9p8XarerV9O+TCh/ciIgjJ9+CkTCVAhzBfjBF7G9OKGfeWI9788gBR0BcY1TtKf/A guScOHWeo1HfpwuFJhzbcKF+8hv3KBM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=ATuPznBP; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.219.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=1683693776; a=rsa-sha256; cv=none; b=weUgIFX+iTMUPfvYGcqf2trHGzFAetfNkPkdg43Mame4Smxi6GpMqDqIaOHCEtbWb9LH76 K54QiYiWQM/pbP/cYYDJlf3367SXPv3CLTYMyKhtGFGaUoxcAI4wBu2LjuCAHS8kuhgJSH RnctYN+FtmkED5WpS8NiEz7Ce0Tfx78= Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-b9a879cd49cso8811486276.0 for ; Tue, 09 May 2023 21:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683693775; x=1686285775; 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=ATuPznBP6lohY0dnWFYXaaNOQNunJEFtD7eF3OFa8KJJUXbFYwyofisXF7mtL2ymFH oTBz56agCcLhFx8YonoqBW6ZmAtrhlvPrmdJAcSpRqyP2mLR5Z/WoSQhVEg2s8MVqDuy Ip95cEIMx73t6Gdt8YSQEVRJTa89FntSD+Di4V6VUK9+4KRIMxTr8+RCmD6ANZu4Rjel BJF/aQ9/sAdSWOQreL897UcsYcMJJWTONr2aX5YmKG/bIAxUtAEn1GX4Jh5f4y/r990Z htjctO7o35ZbKLLksPTYN1h3aK5mSo9ZrVIIV1mS/G/Fv32O9W6ivMXImV5mGNDY0z+m 21CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683693775; x=1686285775; 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=S0cZx1ZVvbGztGhwmw35er76b5qiowQ6B9SME/p6bLFqQYq6kmXWmS+25Th/zVbnKu dTlMzrEw7uE+9f3oMNHalIXZNV5L+m8IhAEX0hE6UKQ3Fy09Jzj9pPmqtlE+KY/WBBpV wEDvXFldZUWzmpuNXJrL9Uaxm/VWhRwzE6wh+ZVuLITXnFeamCDsn3CUgvFAwyChZu5u iCklJ952iOHf4YJ28vLDdKSoyaEDCjDkuKVCjWKomvjn3To6Qcz3wr2TOfpMebPeqgm4 Dgg5voIIRlbfcJKi76/8lqBfmfCp3eCB6yoD/RJs9UvzWcYt5YbCYQeUGsGoqpedSLq9 wMNQ== X-Gm-Message-State: AC+VfDwX5VBBhddgscTw2ZWh+kOVyoPKBoxoXposSzzffMaobj7gFyQe SNDwlfFOnVyOr4KoYROv2CXd9w== X-Google-Smtp-Source: ACHHUZ7fYX2z0RAKmyNqdeM/8QuAhHW9rcUGOaUpv5crEQfaAc/gCUyRWpV2+01J2c8XG3m8+G8szg== X-Received: by 2002:a25:ad98:0:b0:b9d:a8fa:fd6d with SMTP id z24-20020a25ad98000000b00b9da8fafd6dmr17660831ybi.12.1683693775053; Tue, 09 May 2023 21:42:55 -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 x4-20020a056902102400b00b9def138173sm3425234ybt.1.2023.05.09.21.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:42:54 -0700 (PDT) Date: Tue, 9 May 2023 21:42:44 -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 , 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 , 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 01/23] arm: allow pte_offset_map[_lock]() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <5011977-d876-6a24-a3fc-c7e6a02877b8@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: 94fuhhc44dm6rgfx85sk1rg3fef3szwi X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 10D52C0008 X-Rspam-User: X-HE-Tag: 1683693775-342448 X-HE-Meta: U2FsdGVkX18VMJ143ST2tQ7O3Oqi2KhCPElrbT8dloi1W4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/PKyardoDAdBcGhnqLSAdh4w+TJ0ijKv8ED6Em6E5V6pmApK7NGpB1Z3Xkofsu2xMxk6Qy6RnDv2vW9SclgSYLPKtfwdRGNlBEyxKIgRvUymgRcB1uXxYGYbkwlrpfkKbnzGVb+UAifybVdd5SvL3jOOBQomVMYLRDLY56mRcErhfb6Ij040wjezgdwNinG0myoAnb/z2FYAsRPFhOZYbCU8LywOLTzDydaFI6UyxqXRHHLibWQL43fyV5Yt37t7yje5WoMwqSB2G6B35T2gb6FEWjLAGLvw== 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 Wed May 10 04:43:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236319 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 B9DADC7EE22 for ; Wed, 10 May 2023 04:43:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23B0E6B0072; Wed, 10 May 2023 00:43:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EC126B0074; Wed, 10 May 2023 00:43:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B46B6B0075; Wed, 10 May 2023 00:43:54 -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 F2ED36B0072 for ; Wed, 10 May 2023 00:43:53 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B9D8F1A0492 for ; Wed, 10 May 2023 04:43:53 +0000 (UTC) X-FDA: 80773102746.24.50BA60C Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf30.hostedemail.com (Postfix) with ESMTP id E8B9D80005 for ; Wed, 10 May 2023 04:43:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XSdzuZPh; spf=pass (imf30.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=1683693832; a=rsa-sha256; cv=none; b=60HnuMcUcY5XmHm7T8ftHiEjAgdwNX0xZmMB6LpP3KiQPkrfN/jwIFcjJig61iNIoJI46y N49OhoU6RW15DIBKFLW2y1ITao9BkefZENtSk4QnkSiBq7u+J030FsciA5i9GS0kl/RltE nj4ch8fgC5sVU11o7Ylot97KlBCzD8E= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=XSdzuZPh; spf=pass (imf30.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=1683693832; 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=Qgvg6hJeX3BMksFNsRntaPo5LAnqTckLGOVnbotKcuE=; b=mqugUOqPDyb69QhubAacb6je6SFSOg/xQiV7S1cIsNxgafGCJv3YlwWh6tfCL2UM/RpOmm WGWruXN5OpH/tjMAwQQYVRBfbTT/l2R/v4tjs7fat2zhDWAar062CIerjvWWrSmcfgF+Ks lGRn4/FBCuDTbCT/Km6YBpmx+6Pgo9E= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-55aa1da9d4aso120819907b3.2 for ; Tue, 09 May 2023 21:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683693831; x=1686285831; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Qgvg6hJeX3BMksFNsRntaPo5LAnqTckLGOVnbotKcuE=; b=XSdzuZPhWyo8ejurmvHVm33GJPjVUgijuALNChj5du7O2iYt4Q9Jq2Q59opuXgmszK vq4MYv/Ooq0tJSiRkeuI3pPx9DX2hUCIacbsKIYs/Pr4tOgH5bBu2nqMFCUfyb6E02pf jBk8Kt3LARkTDDVXin2DqNhLRNsinTPL45U22h6RflNgwq03hTBYZXyT9mTDfKsms4Zh 4IIRYWo2iyv3RHOXtIB0KC/5A3EJw7nNYEHLsDPx36g0ObzRlzcFoxapfv0z0w7dMYbs CoJBrp445oAQqRN0sKHpj5OzjqC03ok8JMyhyd58GQQ6Bw92QvpdqQzmSHjTpSRLST1k j19g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683693831; x=1686285831; 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=Qgvg6hJeX3BMksFNsRntaPo5LAnqTckLGOVnbotKcuE=; b=BvAfvOMCCDLnwZ6IPLu6Z20TX2aY88exIQH0WFtCNPkuviVJfHKPutjuyZUdmzar0b 1J5gNucSkQ5oIR2cBQ+8yFD2bDLpRZi9K+wqHrD6LA5OD1fe/kOM3ECKDgU2ns0oU90N jrjhRWufHdrL6AraHEoxwU5FHpjUHowc27D33yYN70FWcyUb2E54BSEj46CZVNWq/6Zg 5SuV1AmkEAx2Ono25QXoCkeZSSVT2m/hAA7OcyUPAVw/xVCDKIrUIijYLdEQESytsYVg ilLmiiClAJqQ3zbj1+0xCTx4mXhzhE97vipNmCBtqF5HI1/627PcNl0qy4qe2jnN5ceE hB0w== X-Gm-Message-State: AC+VfDwT7dgClGUOJPNgD6xmZozY2mN+FEi6w6eMbVb9XDGtWosEmzR4 SwrAK2oW6y2BACMHsZRrCphr4g== X-Google-Smtp-Source: ACHHUZ4VcJ8uys5Wg+XhQi/AqGcqZN5zPbzkOujNssPmQqlmUArRuZ8YDG3LYugsQYwQAHxQcBQMpA== X-Received: by 2002:a0d:d955:0:b0:55a:ad0a:766 with SMTP id b82-20020a0dd955000000b0055aad0a0766mr17833906ywe.10.1683693830970; Tue, 09 May 2023 21:43:50 -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 p185-20020a0dcdc2000000b0055a72f6a462sm2214413ywd.19.2023.05.09.21.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:43:50 -0700 (PDT) Date: Tue, 9 May 2023 21:43:47 -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 , 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 , 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 02/23] arm64: allow pte_offset_map() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E8B9D80005 X-Stat-Signature: h9iir36inrqz8ddkws6s7i4b86wbpxze X-HE-Tag: 1683693831-411345 X-HE-Meta: U2FsdGVkX18ZpZ4zCOvscklIqT5i0ronCsQhIUEXGuTIeTpdwSpq1vDbAxzDs1lxcAQeZ3o4agIPSF7TSMwt3EQapCauHmBxAwjgvQuzlfbrp7V8KiqLfPVbUzYF6ZVolG0nruHJhIh+uzpmcrDqyc0nsesheQP2tpZltBGIBBbZA5oGu8uyp/PfBxaEtWk1JB8vYwWzjB6gTJvQ+J/+xXzkj968rSS5zglHRhFpzV5ZHkl+7a0y1GGSbb9N0Zg4lhUGTWB5Vr5NDGbRXiIV2fWAgQN0ISslMcCCFulIq0yKZtNH8FpD1oZNluo/wXOeCGAKK3kAvM4arGWvJ3HBi5bCSEbGNNq7/c4HSMgMmjng+J7ZBGJIpkZ2tSloG8GuKMjkYrpQfTluG8yGNSHVY4eU1laEmavvgCejA2uimB9d0WHLSiJ2r1Az+XZuvgKLpUiydChWKY/KRc6RNiVekdCUeyEQ63Q0Vm333oL6TRdFQwf/XPkbMQuqd2wYWWVmYbfpy+2mpqH4mEGdevcei12HrVDkG+PpcUq76JZEUA9H8CmXjVDS9+ax2FLSdhrq8gUrtaSkFcrNGHYKjB/t23tldaf2a0cjpQ2Gx20pWUShQfRpExjW06Nf041oTrTiIv8QHl7FrPAnqAFwDVAjYV2QqTwlbIFmHji/TDp9n+Zoe/J7LQ3H1EayjxuOEfhfy+en2baxGT2cFPj5ur3unsMiksv7vz69mNpbiAQAnKLUjd5+37Igb8Hx85AGK6lt0gsneQM8rSL5XyIydo3moGkKbJWrrqAu/z4JvSITghHvTure4GgNGuplauREDAfAz/3Jj9Yw6ZXNFJIVYkkne1ZvtWlpCBPT1k32/i6WEDK7gbNipv6UPhEH62+qUei6u++D1BwCnXaHWRzYRYVwILC/9P2XMSmk7Pk/a8PNe2qGOlX3hv6BzJl9NNvVXhcW7ydI8cDHoI+9W/rI02s ugfmar3p VG9KUmkVRyZ5iS7cT3tMtpkviVUUwUWf9sUEAv8zO5dVGVRX26zy6FNIBrYBcTRJxpjBiCYEgGd0PBFaWbl5n5JY9CJPNRz3f8mmH1l6YzEhI7O/0zyp+zxRdVuE1jlxdAtV/d1CrZgnZWGS/wXo2Bu5vn/2yJD4+m1gbNvSFm+3oxVg2YLnHJnOiup659nG9npu/vSCNZ7eoEyj6TTpW2xRRYRLH3i6NmAbvrNcrBlVOZErwYoTy+/PY6eVAHxBOmM/grzU9DMN0NctRCOtZg0M2JAc3UAbpnsslLfsQRb5R4BbdeHJX5tc8DCSZN0cRlzJQvKKnh/ZnT2L71IpQ2zkg8tSdLMk2oDuizEwu2GFxZkigem2Z+fqhLfDzzxZ2su7v+jys5HdQmhYttohF+dV/rf/eSbz4W1eZaeR+hmBbggkac5tOPTmAsg== 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 9e0db5c387e3..a58780d5fac4 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 Wed May 10 04:45: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: 13236332 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 0F689C7EE22 for ; Wed, 10 May 2023 04:46:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B4D96B0072; Wed, 10 May 2023 00:46:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 916786B0074; Wed, 10 May 2023 00:46:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76A566B0075; Wed, 10 May 2023 00:46:04 -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 5A8DF6B0072 for ; Wed, 10 May 2023 00:46:04 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1D1D340275 for ; Wed, 10 May 2023 04:46:04 +0000 (UTC) X-FDA: 80773108248.07.12BCBAD Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf28.hostedemail.com (Postfix) with ESMTP id 42EA3C0002 for ; Wed, 10 May 2023 04:46:02 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=X3r36dHH; spf=pass (imf28.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=1683693962; 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=2Y3cIigX+Nl9tLTZ0FqCTIXHUTdUKJPmRsHmBn2kODQ=; b=ZwtutPdcDmHwDks163owCPWh6C22XSjTIB3FjzzE+sFoylLTJkbMiLsuNJPrKN1CjzUTO3 /HNph7Lbs2qOaB0k7VuMn9lbNc1JS47FlYn37D3M1v09YYvl6Upq5AAgnEM68CsXyF0q5a bwW9LrhQfdHczRa0j1ns7V544Ok0b7U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683693962; a=rsa-sha256; cv=none; b=ErBhNOk4Avzsk0nK1Mv+amVVgoNsbRGyDfO6m7L+SeHrUHlx4SVQacCyJ4RTJdUGaKUYFI FHNyiNJB0Aie63lrbTOlFDZpkNEYR0TBxGlx63ozXT32gq9mVSs66u3AJvK05EoKagRH6G tMWHJ15If2qxTc/lbbeRvGH+QtO5r7o= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=X3r36dHH; spf=pass (imf28.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-55c939fb24dso62446537b3.2 for ; Tue, 09 May 2023 21:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683693961; x=1686285961; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=2Y3cIigX+Nl9tLTZ0FqCTIXHUTdUKJPmRsHmBn2kODQ=; b=X3r36dHHiJLgvp7jU0d4K3JzjfQ3mFZ409XlDfQRUNXPcZqJbsAuZzM3s3dqfqjzC7 8KZfl7/K1d5O90p8GZrKYknrba26nw1LDXST+K7c2aBIUL4D4zJxqgAKfbG2qxu2Yo5u /0/dJOnRitUjxODeANtGQgBQxAoaXYK9cmTYbd/KEH4Bma0mqugbvo9G65UfkX3CZvm4 /qVdLnQuXbtkydB1O0CAPyBH6Uxg3CoJyNGPZLXWNXdI0kdPUkxDZks6+sU3ASKIjHEF kaGykgOemp+4zkq4W/ysBBuFcBH4LTuAgjoNUoWbJlUwxz7uYcWBFSnWP85ZFQDgSIRR fYQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683693961; x=1686285961; 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=2Y3cIigX+Nl9tLTZ0FqCTIXHUTdUKJPmRsHmBn2kODQ=; b=JVHR6K13DRQ8lFKpF8yZO+ihibmmev2xp6eH0AneiYQhOOM3sUdYZJfU8H2GUnNp9Y xAmHQRn/VR0gO1KxUUmxt6ahXiMPf47t4YlL3lM2WvFCocthJFDCGl2Jmql4oL5MyngR U8+El6rv4bu1dSqUjTMkAlAQ4GbI4Zjn/gW42oEm07QczKopAj1j34C8iAXODIlIntjq VZIn7SuivcNqwJ1Lb5lHb88Snpolk6Ge0yYSeTbKXOUnFGen88BcJMwmQDe3XkkFgd37 QxVsdiK2/aL5jh67NThltafAFW9DgkH05mukMu7RWRemNEge+knpQCde9C0j8ilCb6IQ SwvA== X-Gm-Message-State: AC+VfDx3IcuUzeKjDi3/1cLJHOHxFGoXPWDe4Vrc8GBLcLq3d1z+5+u2 quoEADqkPGYlQRgRAB/VzPmHVQ== X-Google-Smtp-Source: ACHHUZ7XGWNGIkPY+5hFXQ4Kt5/NxLbXPMIaWsRvM1j0AuAelIXLbwAPwZwsOjvzazAJBFrFLzpKOA== X-Received: by 2002:a0d:e242:0:b0:52e:f109:ba7a with SMTP id l63-20020a0de242000000b0052ef109ba7amr17438159ywe.51.1683693961209; Tue, 09 May 2023 21:46:01 -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 s126-20020a815e84000000b0054c0c9e4043sm3833116ywb.95.2023.05.09.21.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:46:00 -0700 (PDT) Date: Tue, 9 May 2023 21:45: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 , 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 , 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 03/23] arm64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 42EA3C0002 X-Stat-Signature: 75781txic16nafaqemmy1jw9k86codfa X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1683693962-877094 X-HE-Meta: U2FsdGVkX18R+m84CkPhcS9HHPEU+zaCsnHwPWOzft6cY8JPOIA/57t1JqPJNyoc3UaE33SwJv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EoG38CpNZM1EPCP8DFiROnYVoljsGdk5SvtciSg1nfRck2/bayz3+eGPMfdogFH98EmKIS51J82C0401yLa3WC38ThrQpxdDhNQM0sVvMxNDRx//uhIh2eTVyA9AMVOFeIxOKYkvah9fYPWWrnhL9+RXZ2WVZLhyyhxktchNyRkUAdCfL+mXjyRJ8mYc0pNT6pCXcatxmdYGdXI4PqN4W/bVJa8+cCAgYZZkEAoklJSu303xh0vqtnVoRqq1gJYTW5GBQtvxfHHl2v9N9DyVz3A4Gd6u7h7TrUxzfSdA== 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 Wed May 10 04:47:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236333 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 E19A8C77B7C for ; Wed, 10 May 2023 04:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BE576B0074; Wed, 10 May 2023 00:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 545B86B0075; Wed, 10 May 2023 00:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E6D66B0078; Wed, 10 May 2023 00:47:19 -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 2B6E26B0074 for ; Wed, 10 May 2023 00:47:19 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EAC9714020D for ; Wed, 10 May 2023 04:47:18 +0000 (UTC) X-FDA: 80773111356.28.EA5385D Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf08.hostedemail.com (Postfix) with ESMTP id F15F5160016 for ; Wed, 10 May 2023 04:47:16 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="o+pw/Fxe"; spf=pass (imf08.hostedemail.com: domain of hughd@google.com designates 209.85.219.179 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=1683694037; 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=CCVYX0NHrX1W5STXQLS9/0ogsEmTil70z4PNZBFNkWYDDXtA0uL/JKKpOh5MVQBQtvtfRF ZIpQD7j7PCFAaSXrIjtMOaCu0w+EUXOJ9pLn6SVs/b2gs8abliyTTrHNgej1mp/TeprxW9 kARCTtRPdKUOFMwh3siIQLyIJrM8jLk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694037; a=rsa-sha256; cv=none; b=UsBBOCg3B/pSUdazjkdZp7/jvrXqSaQ2LTzsxhdBC3A/t0VVZqVZQD0+V+TPAlkhQngMc/ 0spRZH+kFamoz0INh4r/7IK6m1YwbCeOFMDI/iA+EzUdAS8uNRmy7L32OnBxfiIpATtPe3 7UXFIIkei2kx0W3EgDZnxXchZynIdfk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="o+pw/Fxe"; spf=pass (imf08.hostedemail.com: domain of hughd@google.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-b9246a5f3feso10156291276.1 for ; Tue, 09 May 2023 21:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694036; x=1686286036; 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=o+pw/FxefUIAOoasXSGcewgZKtzCiK6gey4asLS52yE6RcSKCLcg/5+Oke4t4tL5mt WY+uEeh7LusBVdVQVoeJLXBzhVEJAgg/+wrnr5YnLWD3Y+xgGcCb1JLs6JvP8/f0rR6I tOIJAEnPqeFziCHRIMxBgLXFbcRpC1yoUKiEwz+VxRsKMOaCzI+eqG6JH5jyJ802ZkSp N+BiAknrKD5ka0lvzxWcjKQzAZAWQASg3Zoa2F4mVxsPlzCTR7qCguvvguU/AtX+AHcL WDe1lJ7cP45MCFknO9sG2YoZVBoQ/kny4LfOudEYqHVSkK2nfJ78GhDEjEHbvmzj6Rt9 PQHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694036; x=1686286036; 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=NPsxTVEMo3PPv40fPV+mkYPEUO5fhaxuzZDIsPvlD+oKT7sPnerQXnmg3oNO0ppf5a x454jHaUiwVvBW6xBRxS9BOmUc6AQ5+yYxkms2f9hvAi4cdnz918Bg8fZJxxnhpChdh+ g9XI5PecCXhDZP9EQ6m2FiTUGZ/hRunggdbneN3S+bFlu8M7fqrYE7GvBoIOaVV6VTP8 T6nNIB+dKgzm5QKiFe+sTqZk6+ZYVUn+YetU5GPKZSyEXznm3H50LZVnGOKyhsHXeKKJ F2i9OfJWbKc3BGIMYFuzYBRNCHG5C6gZ1hcbBAO7VqSqivJmMWa0qAqN5Br4RQ4D4kVz xM2A== X-Gm-Message-State: AC+VfDw9go0fXexJYvkp+VTniz4wABGKXnGTbvDS/fQY3uVyrEAenB0n H+hYfRthcD+GJ2BNIsDiUAYXrw== X-Google-Smtp-Source: ACHHUZ7chwpqHYv2bkU0Ao/t6DWECrNjxiYg/IB0spMttiifVb5o/XZ8DrM/lCVX0msD4U/PtCIM9g== X-Received: by 2002:a05:6902:1883:b0:b9d:58d9:8c with SMTP id cj3-20020a056902188300b00b9d58d9008cmr22251628ybb.11.1683694035986; Tue, 09 May 2023 21:47: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 185-20020a2506c2000000b00b9dc4620f95sm3505720ybg.6.2023.05.09.21.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:47:15 -0700 (PDT) Date: Tue, 9 May 2023 21:47:11 -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 , 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 , 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 04/23] ia64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F15F5160016 X-Stat-Signature: 3onqspbcyyw3t4cpp46ko4uqtmyrtjpi X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-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bvq70XUnuZwvdc2sdb7MLyHLrXJYisiwL46SVizGt9Lm9TeE05aqMLgCz5nqgLz4tzNHIbdTs8QYViv2GCNQGdp4/T3g+c3Scfh3+Ct2O+harNmuz6V3dK6IRfVAhC62CCZOgWUf0BsvN1p+nn3G24m4ubeHJ06ss0Ff+heNM0higjpfqUzUEwiG1wXn3ViplnSkNSsqn+n64tRzeS2vbtvrZJlKxXwdNVKRQj10hHcdkbr4k6m7suukRktkXX0zADye+7zbRWm1mdtO5a+NnAhMIS6BR5tc87PlXRlvMt+GdiVuy4jTHw/2f05k1hRD24TUxXclX+1x0wH1OLvCkC8kMR+m0u9q65qw== 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 Wed May 10 04:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236334 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 82F12C7EE22 for ; Wed, 10 May 2023 04:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23A006B0071; Wed, 10 May 2023 00:48:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C32A6B0075; Wed, 10 May 2023 00:48:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03C806B0078; Wed, 10 May 2023 00:48: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 E84EB6B0071 for ; Wed, 10 May 2023 00:48:22 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B4D0BA0274 for ; Wed, 10 May 2023 04:48:22 +0000 (UTC) X-FDA: 80773114044.23.DCF36B7 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf22.hostedemail.com (Postfix) with ESMTP id DE778C0003 for ; Wed, 10 May 2023 04:48:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=x1Kja1XT; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 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=1683694100; a=rsa-sha256; cv=none; b=iCAfO0d6FAl94RoDjFwW0ZzXA2hdJd0/j384fGx2dB87Ixxu+rVe2CDcVdarr5bcPkfWzI za7lKHt/orsNPvHzRX+REEqZ5ZcI7vJf3dAW3eJFNsdmNoLVxRrRaUdxNoY7Hr0SZL9j/g Erw0JxLDfC182EFtAvOnOYrB2QpSvMw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=x1Kja1XT; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.128.172 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=1683694100; 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=S27J4t3ZMbuwjZug/rkqfNJLMizgAhzLs2ejPS6zwWrH6t38F4Ai9V946R1eY4ZLf3ifJf zYk9AFFM9adM3sAbRKuKJd6Bivsn4Xm+bhkSa9ZJvdfQAgZPXm+EH8OFspxam4A2YsiGA2 cQyYF2Xs5/dzh6TueC7A4MWyTpD5aGw= Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-55a83e80262so100414877b3.3 for ; Tue, 09 May 2023 21:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694100; x=1686286100; 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=x1Kja1XThhFtvtapStbHVJ6cIUWnFQTRjS3yIZzqOBvbeW6lJ6r2OcIKehyGaLcOR9 EO0E+0lmjwsTzqZxX1CuaA3LV6vt/w6iCNhoZh4KzBI6fttCsMHb9y2nN6JpG9VX1Pvu 8ApPtVrHr2EJz5uY9tEAZbLvczJvLYwI/1UR0oNRlUsYV0jCTgbzXwAHPMVjgrMird8t M8XDWCM/7D47BFX5TCmJBag01ePrcoMjLvbNAO+qlqmYphOA1hsCm6/eE7yT79eAzjKv cgR618qRb92LOun4z6/AVV6yQ+EpsB9LlzYitvITxDtPFVAQvvWGldL+/y5mKG2o+OCf +34A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694100; x=1686286100; 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=Mfwl9Flyv1Ms4sia1H7EOK7ICAbNPqgGUNUvhH2R5LbfHwnliqiKY8l44D0RfZFpbI oN3+dMY5HUBgT2/pnrsMK5DPaPqg6Vitv5xpjIgHtlf1ywaM/CnYzXbwvpjDKra3jGtG vCeRHHKppPMuUQNJvC4iaeiuaEOHahIUnOYHO4etc90HDLRhbpZMDjCUR4gG43knOpmu ZF1F/3zDcgRirC+xM4XL5P3QIjhZUxNIzE81PtQ/R3KSGiZVVf81znQe3Ni1KIyweAg6 l0hRAyVwuMA0WMQLkre64CPyLpEIOLxiP0p1Ex056Jznmu9Niwx4Uj+TU10dGuH+t7mO SMCQ== X-Gm-Message-State: AC+VfDwKtcwfnZsutRZqqbalexHbP9wFApBczpTNTcNKHgHwvAyukurh hUlwq2+eK05Bs+GmhhW/uE5Qsw== X-Google-Smtp-Source: ACHHUZ48eni6W+ZapWVvICeeqiNsZB+sf9Vl0Czmi3DPbU/8P8IxchHCcuzQFPjInzrwD5bjAbGJ8g== X-Received: by 2002:a0d:c741:0:b0:559:d3a0:4270 with SMTP id j62-20020a0dc741000000b00559d3a04270mr16231065ywd.34.1683694099774; Tue, 09 May 2023 21:48: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 c68-20020a0df347000000b0054f83731ad2sm3844954ywf.0.2023.05.09.21.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:48:19 -0700 (PDT) Date: Tue, 9 May 2023 21:48:15 -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 , 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 , 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 05/23] m68k: allow pte_offset_map[_lock]() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <237c8410-ce61-94c-4260-7318ad6a4f3@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: dkg8zuxd9uuqu5apo8ekuh3319rqucou X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: DE778C0003 X-HE-Tag: 1683694100-303245 X-HE-Meta: U2FsdGVkX1+Lq42Eyov9oWq4N71tUejtIcxoyHZ1L1M+f/ZVw3Nfv7C//NClQ8WP6SAbfWvAiHR56HppJVccGKdiOxXte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Xz+MLRixrQUT5Jpkle/C90+9pLO2lGbBU5esXC3J/1/u4z2LzFbk/sncTVV1+13ektQWjbL4lS/mUNPiVeXj3LSVrGOGW59J0UG4l2zSdUmSs33hdMxkE+Ln4VNDhTC+WoIWy5uDeKI4zrGEfaAFCdTCF15ehK0BXQ71YSJsy7BuQXluCtEGtbKZPfRZHqmJ9XLWpegK5WosAbm20qyXWSYP1CoHqKbSnblhNl+T3awO/9g== 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 Wed May 10 04:49: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: 13236335 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 5D752C77B7C for ; Wed, 10 May 2023 04:49:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F31986B0071; Wed, 10 May 2023 00:49:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE1E36B0072; Wed, 10 May 2023 00:49:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAA6E6B0074; Wed, 10 May 2023 00:49:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CC3DB6B0071 for ; Wed, 10 May 2023 00:49:29 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 99C6F80336 for ; Wed, 10 May 2023 04:49:29 +0000 (UTC) X-FDA: 80773116858.27.D10B5A5 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf05.hostedemail.com (Postfix) with ESMTP id CA6D510000D for ; Wed, 10 May 2023 04:49:27 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=UYgN7SHJ; spf=pass (imf05.hostedemail.com: domain of hughd@google.com designates 209.85.219.178 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=1683694167; a=rsa-sha256; cv=none; b=skI3qfBIzuJB2N0U4y1RL8wts5uzVMQxNDweMFBMjum6qz+1QctcWcQ4s9gylqnDpjfQCY A2gpIl+rWB11sx4sG2JY2K4FMBiKigsTwHzrNwvVbfBQMIr1b3aF/qwqRS40D174jTlJar 5TMuTr6gnhGU0o5PIzKw6iR5ix22hUU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=UYgN7SHJ; spf=pass (imf05.hostedemail.com: domain of hughd@google.com designates 209.85.219.178 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=1683694167; 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=dtKB6Nrfw426cOcopVFraM2VJqUYpF1Cpbwd+2/1zLbvYImnbVDXv8vy6GGa+yj3h0o299 QxMbpVRAsWcSaykbjGIrn6nI7Wz1UhsyMEK/s2U+VWnd88ao/SebzJZxT22C6rdtOdx/Ql Vcgzz05It/PVRSYel+X8PoXEjPctfxI= Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-b9a6f17f2b6so34047373276.1 for ; Tue, 09 May 2023 21:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694167; x=1686286167; 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=UYgN7SHJ+Kw138ag8h0xP8PheSyb+TyI5VHSIDjj4n9RShp4GncXL3XJ5EHxhXiibK bWM2WA341yCPavofD2L+dwTh/k8wbtnqGHGh+6b5/c/SY6HIHVlS/8x1ncbIt6FJFxer ySWLGEH9EXtIKdzeP4dp9W7nQnr+88zaaLX+AbAlYcn/Ke5bUTdA+Amtpc+UhTK8ZOe6 nlHKHHzGDYa0yETI6dqk3ia7Fkbq7SWABYpcMHvXrsQB+4fKcTN3DFHn/90Y6UPXvP9F JN8mOaRS8n0XqBndVMSP+yTIoj8bABXUPMMg0RRYx7fWa70GyDb3jL+GXnDzUgXw6flR jauA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694167; x=1686286167; 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=O9AVX+QYjB07aOJZ46l5inzFaK/ZM58DJXUPaiHBwz0C+H20F5ZzssNjImeUBPo61e i4O5gKL4xIAfFNyk4O0dtwokdwNLkwgB+AowyVB7x7OL4vkutkiRDrIVDlTRBDP7dQdk +S9PkhlKWNjAETc1vKeKAOCVuuZz7NdG6TyqVjviOrMUul8j3Kz6ETZO+2If5w6omPhV 0wHpcHwxpgcCn2fbmS1TmY2DF13sgDm9k4co05sPqMSSgTTZUtZcJVm1GTi0IuOMh54/ kPUjcuJZoC3yAYzI/5A2KamCf9CZgzF6L6JNiFmi7l+t7jFxRmp4WqkjPde+pJ78oYmV 2glA== X-Gm-Message-State: AC+VfDx14Bv8hXvRH3+JnKoMoIVuvYnm8ZZLThTtJ4FpIAJKB5snepoQ oRA5+gVuS7vgH+J6tEV5bkUHeg== X-Google-Smtp-Source: ACHHUZ4tqpw6+aM6rxWFz6kp/xXo9T82LwXaR685ltqxNG0QuiQjYqghFAwvEDZVatjZsBeLNAG4xw== X-Received: by 2002:a0d:c604:0:b0:55a:3502:d2ca with SMTP id i4-20020a0dc604000000b0055a3502d2camr16180522ywd.13.1683694166794; Tue, 09 May 2023 21:49:26 -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 h67-20020a0df746000000b0054601a8399csm18738ywf.119.2023.05.09.21.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:49:26 -0700 (PDT) Date: Tue, 9 May 2023 21:49: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 , 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 , 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 06/23] microblaze: allow pte_offset_map() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <12141321-df3-a8bf-18e-e27d13f24b74@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: CA6D510000D X-Stat-Signature: i68jgu9esw6fxczhx1zbun7yumr57jrx X-HE-Tag: 1683694167-903996 X-HE-Meta: U2FsdGVkX1+FboqixlDuinDIRVT+/hfsFC6Z30R4tzOgpOXU/M7Kl0HXvgJEVqeA+xSbDEo+qqirhceKsUYtUX0OcFxCDAfL5MNzn6jeg7wb1mUfIMHFAjadG13LcWaqt4l+tJ299MzyvGgRbid04jOv6rBhFk51gBTWvjIEctdGqgDqXImXM6uwd+YNj6DNDvfrgr8/pWA3hcprQvYcjGNjN24aAbLrhDqr3YRId4FgP8+4hBL7a8lCQX7W2wnreW9OAoVw0yQfEyA22+93IyESN9eKrSYXaRHoalmNWDu+s7t6PC4w0RMN+mHYvoScj7x7wqVgRKXM08r1R0eVTOgwa39ZjDyUd99n3MnXYI7Le7riUYdAZw/M8KFPDacwlATZBtyxEQ9q+z4FoVnz5HMkuxehSAjH49EvLOVNyd6ONrUpFPnwl5lY7kutAz9JHWGDIqDFQuh9/avmAhyDMrpcPjhEnhQgvoKum/HusKG3k/dPq8QFG6fH8jPccQu3iUfJaet7Nx79DU4PtXDyv77o+SrwtvqL4XOOMsFkdKXceqW3JVJd4Jnzt5NUo8XOfH3k6t/nm4IN9yaszjjxzd9XLmh5LS9mHE9+Zfc618A04ASfsTWXIOCdACCtEsx0MIimLGt4d/hzawilRuH2fbkYwOoUENJ72MprQ7P4OM+YRpNB3atpVHqzrBanwCdx4GdIpF2Ples7e6puga03mB6ub/YnX8/T8d029lrt0GNFqGMO7SKEx396V331fxr2FA1MPtTekAr6+0peCtTtkNyVDt7O7tAYOlgZdvAMQrtIq/gUWe9TPSthDHUmeH/0VW+r5Zblo7tounMTdBkJB+CZZWqIL6Z6P9jVG+yc9El4tuBHbvS6ni888W3PBmAVyAgypOtmShZo5/Ck8ddeIcjFikN3ZwxAjeD0fdQXwgfS1mQ7842cPQ2rhNzPrQ4Jb7ka8RmMvfOOpS0Nb+f 846wWOQ0 GggRxlyrY4Cms31YMwYawlMtXZ+q20/5pBqthcv0oe8fEpoJ2xvY5RP8NsxXaJ2QUWQPoRh4+Apjllvy78tsuiuvCHJbZJHljQrwxJYjUpR/AtuXOvBLJhUWFyocaxJOkI9TJGOQbCEzbcA4xFOBEicEIu6vG/INrE+SfxBbdZYeRbVfSMrG9M11V2mUt+FAR+lBPqAG1cMwThynH97I5gV+dnEND2wjIyjpcjQtzxKN94/ClE3Wh09Po9BezsnBQEq9xZ5je2KoTnVtZwHSXgPmJDLg1nwnxETq9zozBIqsPgn8paSOs58fjWlR4RC41q//h6/5x3toKDAwYx13A+r/bl4/NzaMfy8mDebJHjCE2e3yz+JyMmzaaR1XO11O9jAoa9wM0KlvUbWY+CRCGNRQlDvsNzBGCry+Ra0Qqt3RnnUhXAlQEJqmSIw== 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 Wed May 10 04:51: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: 13236350 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 8E438C77B7C for ; Wed, 10 May 2023 04:51:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B1BF6B0071; Wed, 10 May 2023 00:51:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 061E66B0072; Wed, 10 May 2023 00:51:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6B936B0074; Wed, 10 May 2023 00:51:23 -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 D81246B0071 for ; Wed, 10 May 2023 00:51:23 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A324416024B for ; Wed, 10 May 2023 04:51:23 +0000 (UTC) X-FDA: 80773121646.06.3C304D9 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by imf09.hostedemail.com (Postfix) with ESMTP id CF318140002 for ; Wed, 10 May 2023 04:51:21 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="5cXf/P6B"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 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=1683694281; 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=JugxqGah5zmOdFPxOYRov4Li3y4jtZmzTWt/QXy0GxwYIJrBftLoF/QU8Bida7+FLFMcbo /fb2JsHrVk7VAC1b0Tqznzbwb7Nsda9Hve5pFE4H/2/P0K0MUdDmXNrTgzJ/572H+ZlHJy AEXjZqV+YCoD0pypS2i+gPFWbMTHDOQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="5cXf/P6B"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694281; a=rsa-sha256; cv=none; b=f1a22eSwdXqnC4vy5lq7DFMKPSO++JGvSHbBZ+2J8vA37BkG8QBjxMYvObEcuRE7hRCdmX /ytOs0KdeRzLmkSxiLcwOcddgGiC9sdJsvB8vxX1GJhFXejX4ZpI03kI+kRxu0qx/EyWks lW6Xk92QzCy0R0cM/SBvQXsC9TMgzUE= Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-55a5a830238so62393577b3.3 for ; Tue, 09 May 2023 21:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694281; x=1686286281; 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=5cXf/P6BxU1x2jWAw1XE7lRFR5Hz1XREgrw/VEMhvVcJnXcjM36N/6ukWbrtQrBqKA zSa2Sv7JIhhIHw0jqecJCQ0I3KFtNtFTtcWEm3Dd1ej1SIUJwcKbmfe+obSPbeDZo8gC 6xQBKG42nA4UxjHlH/bbWapoijTCEdQ0FWMFygpKibtGLht3vBtUJrxtZLXSikEjAohO 9Mt4H98I/XZmLwWtASWfmWRRB+ep6DPhrFoxb6sbiSMAPWqCSJ6PoFgtTXczonMbB8CK fEydvLzJU1eBlheYQjHQZRb6dlhSRwpD8khHEgpaWJ2Nq+jcZ1v9u6pbHABwaFooYDMC SQUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694281; x=1686286281; 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=mHmYXP7Ks0ERTX4qnoTC0rmWnVr/VSiTIozOW4NAIQNaWuFoau+bbEFv4VILjydYDR KZsSQjbPvsHpI9jDDQXM3NBYN54EF8r4NAc8YKgU+3Xzy1Z6hvKssAjN9MGc1n6UOPUp Pjnx7kNesDPtfNujMUkMvCJ7bljoQb82i/sApwUCTb2HfLNm4sKC81WxV64GmbYxXFKf 1U4lXQ6lYWoYXgVc/2EwjfkwwJiz16C69qip0h7+r0g5DFT05Fn5HSOAx8npBRsvzRG+ TSDCz6q1vEoJKvD9tAi9gDO5P4TBuTokZQ3qnYFFGt0mIn5rPSfNA8TQjtgLQWr43wSM PpTw== X-Gm-Message-State: AC+VfDzYayY1Zs+pt27Xwfwj2Ph8dVhnziCuQkMQhuq6TQS+6YFyrfK7 6+g2Gx6Gy9e5s0q4TJ2yLhugBw== X-Google-Smtp-Source: ACHHUZ4qY6ip5x2yFLoBtebXka29+LgP7DYegkav9AGhNOLhqnLW12B3RwfHAHhI/1xbUzIiGo2rmQ== X-Received: by 2002:a0d:f347:0:b0:556:1065:e6a8 with SMTP id c68-20020a0df347000000b005561065e6a8mr19687163ywf.2.1683694280881; Tue, 09 May 2023 21:51: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 x186-20020a81a0c3000000b0054eff15530asm3831597ywg.90.2023.05.09.21.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:51:20 -0700 (PDT) Date: Tue, 9 May 2023 21:51: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 , 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 , 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 07/23] mips: update_mmu_cache() can replace __update_tlb() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: 8eztko3o1fn1f6afobziejzkujzbukbp X-Rspam-User: X-Rspamd-Queue-Id: CF318140002 X-Rspamd-Server: rspam07 X-HE-Tag: 1683694281-897986 X-HE-Meta: U2FsdGVkX18NFCww8bCvapF82c8rdci3mfbG7m5cNg2s8WiBHXri4Wa0wgo5indq7Jtf8WhDL9Gjcwfp6UPgMxG8/k/OagESBF9jgQ4/DOkbMFi/iFUfTr0T3A7J1rkYMEjY8h50Rz6vFfDFUeR7zturJK2neLkdNRss9a+bk/qx+upzwliGiFzj7+JD+V/14vum1uCLqMHYo+LH7b0TvwYJVceIQqori8h9O+St3MIkRj50FlSZa7UuUce5h07T/XE7GIB/Ke5PEw6qQPKCIMQ529jv/54Gbd+b/iqlPgzo3ky23RjbQqgAooRzI/K1G5VVGWUkz2k6AL79k9sIZtIUIQJvOylg2ih9Lmhjr4QRzgfkvBYykFj4l1Q0wS0pZ75R3A2cmAmKdMuhddBvV3yyTRRdVZYFvdgBSdU2OC8AJoi/MHA7z6i3+gGhS9a25+quss9g3KfRgU3DfCyKQ5zmr1Ud0X0qjH1ZXEVTlzyKfuBgNgy0aRUwtGk/ezHlaEUkLlSSDk/8BN4EKERH3aXPFHnMUCK5mL4FR8f+cwyb3K2sQYVtzx0VuE8B0kna3OQrpgNVY5kKA0lpqhWiOuxN306zXYEBeb5Rxt8jUpxP+B+RHxE/BwQnv+oDgJjmXRdbhuzrB/2ZFMn7lmHKRMGDTkILO0DHNB19VEgORVbUhWgKtweaigOl+DDixV1qt6EEDwqDDkYnLctb3ZHJ4v4pz0N25WAOmICb9wYoq8sihW+pDLi3U5e6O9wlcoTy5PX7EEsAumZ3LZ9Skz+eixwAj5ALiB9P1F0TzuQ4J4irgZ3Sg0BbDFE4pO/v1sYT41f+sqDKjDNX+/KRPI/NHm962UI8stJYimXpSxEYMewv6A9qPzAaCmvyOiQ8JB7fWQ+IPMm7fj+/Jgmbz0YGHc6QuJZcrWvgnBBryoXGeyY7ULIviPIQKqTvuPD3bCnEbpQubmiIuUzdjg01M2Q DJsJuZF/ TZ1YNFU4GGJza/NGjLpFu05Vtpnz+d4WiFE9hZaRjkBR3nV+vVc3Mb6Ph+Bt6xGyAGDq5tMdzwjtRMRPLkUoRpr3TwEI3AiI39vxKUjNF7L6UwVeUGw1JzCNO25nbU5e+g7vNJJOHsoY3Ue8NdloaDUBVbVgFXHyT1v8k5wzK1PwIs+m6I8DAsLIJwTfF2YXlujpgQG7nKsudlw0EdqcThhAVnzVl5XLVE/k6F/GV2xSjO15IW2MiH/esyxq1dJm5RaF8rhAZyHkVHYa76s1RrQsxU18Y7tFo3pI8/Xj7RQbWPwjbBPM1Kfwi+n2fpnTKPtGAlpmd7xfDrAArm3+osohQQwKK+gBKFps/J3iRxeOfkOh1EBeeKKXAh91AU8S+FY0Q4Qe49U0coHFM5NLfnpglTMADj2FbYOmsMbJXuwA4dBOc6MffT0dMxA== 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 Wed May 10 04:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236351 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 7DE90C7EE22 for ; Wed, 10 May 2023 04:52:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2102D6B0071; Wed, 10 May 2023 00:52:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0F96B0072; Wed, 10 May 2023 00:52:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 088AE6B0074; Wed, 10 May 2023 00:52: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 EE2276B0071 for ; Wed, 10 May 2023 00:52:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BF797C03F0 for ; Wed, 10 May 2023 04:52:38 +0000 (UTC) X-FDA: 80773124796.27.05896E6 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by imf03.hostedemail.com (Postfix) with ESMTP id D6DDC20006 for ; Wed, 10 May 2023 04:52:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xdSNWZzA; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.128.176 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=1683694356; 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=q/pWRyMl+DKjSxR+96RJZ1aR1tS5RvJyhJKXen2hGiQ=; b=DmToU9hd2i73opxQRImGjFCi0yFg2D6nkMFPxH34rA9dRE1Fvw2XK79STKtRpOdpi6irhz daviQJm7QJp5doXvDYEbG+0Zl42pfZgZy8jrNWRnexOeYS2rQMCIZfHCGCiFiOHRZg156l otWHAl7FusBbNCZ6q67FoVqc8N9eNWE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xdSNWZzA; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.128.176 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=1683694356; a=rsa-sha256; cv=none; b=1o1CZPuPePNMJm8BJoLENCT0ShdF3CXo2KDPCIQf0XF7+oubyBZY7m4GCya+unRNbt8Ki2 TDvscCnYJfavXXhx4oBmYGDHM9R3Hsf/WRIoQ5EoDgknmsxqnTJbEQaKROPE59hPuksH6J srVu4aK4iTOwCMYPrUySwwUk8d97z5g= Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-55a10577911so98074667b3.0 for ; Tue, 09 May 2023 21:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694356; x=1686286356; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=q/pWRyMl+DKjSxR+96RJZ1aR1tS5RvJyhJKXen2hGiQ=; b=xdSNWZzA71Dn4PjSJ/2LhqeF5r1JevaGaRgpoS69f1WOD9bhyOsVwChSsl62EbUoE2 9cnM7TV7zP/+dkaQIS04gEZsgS+3y2H8ZK/Bphg85NyOLG7YB4uljYqtMwzBINkb9uAc Qg8lSbjmhMLr4mA9fzJNs5WYmacpWClDgIdvFtjewDeSGePxRCKcQAns2EMoohHps9+8 S/YpDXqiv4vPhVzyygfg06y+shcq7WCfEpVB4klTCpxP9lMZUivNHG3zXi2wJbvPV+fq bKOy9gNDnov9JiPlPv0RSMj3z9ndQZvcZqYURqj9IDWet3DFKA/Lg6LIl2Rd/fMVxLQn 5Dvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694356; x=1686286356; 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=q/pWRyMl+DKjSxR+96RJZ1aR1tS5RvJyhJKXen2hGiQ=; b=ldlDIgAGvDljvhSemhNb+5FuUGuH6Xm+FiMIZlE7oapZ1XCwuztvn2EGjGqRM2nv4I dTzW0t6K8ygqBjmHOCr8zWAZ5Y6iLo11qG1ffeq7gI1NnZ3lfJslLQ5XLlYhLtg9feoR 7DAVedx8J/o6OpbakNF1Id8oZYNwSJTRCgDzwbXFTidmzzCguQYRoOtKSjlQe56FwHRg BI6dntHAkbECeQ1B1QAnNjlZG3f08Zrh/Vtu2AzM5NMrldUHHBhRlhJA7SEnBAWF56JZ RqQHCFEM0VS8zgjRVIaZxeFJ1JP5vtw4HSY/gIlj41XIAmSMWfcdfZQVlN0Z6Htjl+Ej XtfA== X-Gm-Message-State: AC+VfDwCXo4xn+UYFjCUQkkPJQhgqHm4bp9R8PmFrxmI1Xb9O9S98Nei MBwJL0gdViMC35zRvn/R7/XdMQ== X-Google-Smtp-Source: ACHHUZ6J+F8J+T+3sf+ZeNloEZY2mqXZ4z6wckfThiZ54x80vQ+jP1v1hMPi/dn45eihWxG2Dt7Wzw== X-Received: by 2002:a25:344e:0:b0:b9d:b79b:3b89 with SMTP id b75-20020a25344e000000b00b9db79b3b89mr17243065yba.18.1683694355907; Tue, 09 May 2023 21:52:35 -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 h6-20020a258a86000000b00b9a80b9e08esm3435393ybl.12.2023.05.09.21.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:52:35 -0700 (PDT) Date: Tue, 9 May 2023 21:52:31 -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 , 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 , 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 08/23] parisc: add pte_unmap() to balance get_ptep() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <44ebbf90-5fbb-2815-17c7-fcfe3c87d78e@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: 3trx45mm7o3zjjgcxtdjp4bzhz5r4foj X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D6DDC20006 X-Rspam-User: X-HE-Tag: 1683694356-14884 X-HE-Meta: U2FsdGVkX198Z/UToW93NjyQmkC3Dgls8tZWJiUxpTu/qDRLOx9E4AaXrvkQGK2sobEXECGZ8qKZF8uKVY6bhPNWJNIjJT63sI5GaoNjkqxjTmndEftxISVhw2wYEtcLF8zUFh5nhlwV4YuvtJrdf04SDmO+hmgXcd6LGKk8W/KTD2lIvmdeBvdjrEahr6uraXYRjqHWO0UIjW0iQ5tzAhaXS6dbXvYBhUqZUBY4o19c9otdJv1WsM6NP4/UQthJNT1g7Sz3fnch+7UkQ/1Z0eWsj+zcQ2ekGukfH0U9frlpGqjnVEcVBoSfF83maJZRUKZBr2BxXbaLgl75cYg9oflyj73FYKCmrG+21MLBglSK4TwM1w95HndVqFM5mBCsA/jRz0DLVfGyr1bIK2lcioyMTYUouLKfwEyT4sTQM2FK/5ReqMHrB81+y3RoBQmgG2Dts6J13mSdTzoCL0iVNW8XcA2EDArt6EZhkJeNuhf//fLHZxQK78N1SdGxcGLKOTrhf7TgBKee2nAXwAOuStqM42meFvJo+0jM93wDiIMSFOAPXSBRX/DYkWymbo8rbyw/phkOFZbBE1iCGoJxsvYIGVPPIEjgWgqmicXQm/8PcK+joz2/IQXC3dyPZjcq86ZdlSGMC+c7g5w2bB533mp6rzyq6kvDKXsipejugMi0tGDj7x0sHtq83X8VJhIouqXUzgkURxpVSPw6xqlizWPEVugQnOb6IQCg4yyjze8qMKnY7+NSe+LzR9qrfKrPdUtUweEKll66cJPZLfMZSsC5fRi2Ji4r084J+sVHQkjUmGbTNlgJoiv1ZJ/Jpxj8Blunoxos5k15DCiyj4ip9XEDhUMjwQo4QoYhULyKtLoLhkLCR6jST9I1m3rmSc5u5u0pzl+M+1KBcPR4P8CEga6UgLZaxAHCHzPzapUaG254yMSb83WwgCz4iazYdaeYB0UUQac4rsoWLfz6SDX cNbrkBms eVJjfumgxBxZIC1yZCkpnheQZoXdOs/k0wsQH7Kprk448vPBMqVxgV5hvw6x++bGQN1qKO6Y8GvRBHMsJ/JgVA6IpzAb5cw3TcQWnaPjnICj+dK+gBJMp0yYBGDqWEdNcqQ4NIYOacAN3mRLM4eejDsWSdXP4t/Js6e1JG5UUAH/qxyxU/RVJC6wkWum5XNDsIv1d6V7Zdb31Us0Yyzn7T/0aKfibREvSH0PgnDNaomeX927JV3p8iJWI1kiLSIOmN3d9glHhmtLTrdRc5y3zntqRUdXBNUO3A7nbheAv1muLxbnG480dZQVI7q9gDuCWSG36gxk4GrXanYZuCUAE5vpe+bbt8Bxm9vv0+NJWuSy0+QzWTUkbhWRYSfDTlf/e7K3HviZGiz+N4lsOOjBpmTa68LqJ8AygXZNPvv1L9xophZTsu0/+wvSiEA== 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 (we might as well) pretend that flush_cache_pages() really needed a map there, to read the pfn before "unmapping". Signed-off-by: Hugh Dickins --- 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 1d3b8bc8a623..b0c969b3a300 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -425,10 +425,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 { /* @@ -560,14 +565,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); } @@ -634,17 +645,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 Wed May 10 04:54: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: 13236352 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 9BC40C77B7C for ; Wed, 10 May 2023 04:54:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40BA36B0071; Wed, 10 May 2023 00:54:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BC536B0072; Wed, 10 May 2023 00:54:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ABE96B0074; Wed, 10 May 2023 00:54:07 -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 1E2146B0071 for ; Wed, 10 May 2023 00:54:07 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EED3D1602B4 for ; Wed, 10 May 2023 04:54:06 +0000 (UTC) X-FDA: 80773128492.14.3F56502 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf07.hostedemail.com (Postfix) with ESMTP id 2E82340003 for ; Wed, 10 May 2023 04:54:04 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=nx2nVYMV; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 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=1683694445; a=rsa-sha256; cv=none; b=3VKMCQB6DSC67kDOQTRj4Gbq/IQFFKudswHwte7yedoWFqyqhqDiYZuQ/kS9QAaUqQIsIw LK1zQziFEXj118MW1bA9KrRqQEMJnd2+9VN/5Bbzcen5sCwIAcD5QDH9xDwsuf3sLy3uIv OErLUfjPE5eW1LBzSVMj7VjsluAVoC8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=nx2nVYMV; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.169 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=1683694445; 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=8E7TU+EpCMsIU6CqnZRd0vWJGC9oqEXRuUswowSWl1o=; b=wTaZ4Z/zOsOfJMJmhlgiJic/GK3LBlsLKBZkWS9ON/3J9aHk9ZpSr8QyY3bafjJSIY3cMH 45rij9ErWM91XYSCUBqhZqYmgX7u8KWCGa91d0Guw3btEwf6PN6N8lFqcxnkSNnsvhqGZB /tyAS7mhdSiQXfPO94CQZABf6arKnUI= Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-55a20a56a01so120889007b3.3 for ; Tue, 09 May 2023 21:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694444; x=1686286444; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=8E7TU+EpCMsIU6CqnZRd0vWJGC9oqEXRuUswowSWl1o=; b=nx2nVYMVrNHZwwSl8w3NSmhsRvWihgBOt84R2c16JqiYC4KBl38YHxIAdhEkbKIKU+ 3KinRet9UKewX1U+bJzN/HA2S7KOTkCF4X7wqaw/K7+S17drzHhQwyGVptzSW8CKp+rn 7n/QckVxFQIds+kKrngIuvcYjerJY8U+pP0nKt9JbKkli09JNKT1dmegLnEsv/7gGsJF Qp1n5E/tb+Ovu77mxoxN3oLzT8n8iySQ8FxtBPgBcz8wTrqYdAKrqvMBlZ96CIsNIEnp 6lPBYSKwbzZLj7KAL6W20hrNmnnmTZNvlsZaMnXbJsKFp6VCUGJP8Oy+j1QTC9dUJ6vO gsZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694444; x=1686286444; 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=8E7TU+EpCMsIU6CqnZRd0vWJGC9oqEXRuUswowSWl1o=; b=JEVnD05XIJgqQ/j4hoy16LF1SUYGirNFesk5qTBUl8F6Yrgs5gG6A8GF0KKhgEF9/b zr0fwNTTA0FDvmbXlpiTFpbsn3Cjhcd3WQOXLMmckroCDPS3x+Q409cTuMjX+/8a7l+o H5wkutPclbSPuhbPk8E9IARK5gIszvr/oFIwR8/xKvfFhPZVR/BclrIPxAemj/+X86q7 g6FSeBu5Jn7e5bhPH1br+o3qlPIdBVivlSFqNo1AqgUqNeVLa4ezTcfzA6SdgUazPT0m MG3TTsFmx8CFrYilBm/16DFNLD5GL34uctad2o64iQi7R2QWGs2HC1/T8qnXuj788zV7 ot2w== X-Gm-Message-State: AC+VfDxwh5Fq/Ko6ELwhJAtSdH35Dq/A5GIP93WVQ0VmG5yhEpCT+gJj JiKgoztxonyJ7TicUlADUFzdAA== X-Google-Smtp-Source: ACHHUZ57Dsib2dNeEkcs0nwSe68HvlbijE2Qa11Gh7g4OTrdhlBqOZhC7lvqfUbJMl49On6qtViJzQ== X-Received: by 2002:a0d:d955:0:b0:55a:ad0a:766 with SMTP id b82-20020a0dd955000000b0055aad0a0766mr17847236ywe.10.1683694444181; Tue, 09 May 2023 21:54:04 -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 l4-20020a81d544000000b0055b46dac76esm3814196ywj.116.2023.05.09.21.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:54:03 -0700 (PDT) Date: Tue, 9 May 2023 21:54: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 , 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 , 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 09/23] parisc: unmap_uncached_pte() use pte_offset_kernel() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <12c4693d-8bb3-2852-8cf5-9777b427d770@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2E82340003 X-Stat-Signature: umdafkwj7fhorsgtwkkiujdan5hazgpf X-HE-Tag: 1683694444-564551 X-HE-Meta: U2FsdGVkX1+EHoHVyeOCVSU95868PZ4nfKgaPSKwvnQV9JSJJMWOsQnrC3J4kmxgo5jLigu2VVvAeN5h3nK8gi+pydwHSYWKHmcySHacV7qdpAVfEC3k5Ox9/mUiFyjKxihaOc7TG0+5vycbO+nZmSZwyscdAVA/ZnTOlTRw53JaZNMe6gIYrvvzK4zqzar+CCQK+FLe6pvrYe7iJnsBYPieqj9xZHK/am7SbHE39sH5SpK51MUh56ZW2WLNkvcQsErIC3RwI1TrDjlUGet66lS2Rw33hgvrKa9fJCSpk1jlHBPJfzA/mXrlqxCT9r0GkCF7f2Buzsa2Zm4pyb1616yTlMZMt0je8v6lkihfQjUVKMVZQY3pxB0J/fU2cIqKoCaR0pSrUVWASYG6vH4VyWR1l/9pkCHT2uCj/iBapGM1my2H8k+GMke5zU52tYtSM8oFkH9Rd9mConBXMkr+VYhM4Bir/j0vTjZ12CMfBGTkvnGdYg+Vy6Ewar/gajXQnrLWcDkEsICawodK8UA/4bfwBPbzfOW4HKg2s9e4x3d3IAeBTjMJTjHQ/LAcuz4dnJAhlpMVbJkX82gYwpUYEqAZIb2iC8IPqve4jlznFqzfxfVtKVv7AIXJRNzjCh13+0zi17WV6f91hkHFgI7/KVdNXX7eDt4UoO3SB/4J0qDaq7uWn0virw98jeNCzmv9WglPE5Fe1rNo6+0LixK7cJ1UsK10q2mQLgZ1FwrHImzlicqjD1E2SBqlvZgXQRDybAqE+jyuvLXQw5vX1NLgKUwXpTwiaNB+TjIk+socbqnCshVT15SU+igSadRbXvttzTBdU2azSJclcoPYNgP/09OpezO7jNI6yfyou3c80iuicVacvnP1cBipcqsPXLHQ/qTp/rASfT2/RJDu0KcGxtIZoZfLnfaEyWdy9BkqcVQyazR1k5WlcFSsPru+EMeit/EdnPf1SRl31N0wZ80 A7VabRds KMpUCqf27OGt2sQzF/jIw2wv8SQBywT75dCl6iP+ZjYaOpyqwpnxf2debTdxl/aezlUp12cuqk4FlZhopO3D3IIvh/aLsCi060VsJjBfIq9QR8+Cs3ROMH4YpMIHr1NXE3Vt2A8oZkNBXzcI4uRnoGl38Kv+orOB9Hj1i3esLpdQAW3natqKXgtV8WoSl3m51ELZ/HEq1KbxdvoLN0sJrFgHpM9A4IhC4uqDo5xtSSnSQq9pRE+1uNkgPb4B0gQrCj4DpCTofG09QW0Eu3Y63DorhnOAHIYkWpOkGenZyNPKF2xo4oLr3Cs6fe5m65pwg/gqYBbvr86hAYZWZQjyVpXdYlrkaO1pZfzolKUz9bhCeYBhRN15nOho6yR3hK3caOhkcYImKu0VmsjUmIx5fm6B3ktM9D5Lj9f3qTeV/hgJo7KKmgpZb34fVMhyxsvOPpUXrvyepN13lKqY= 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 ba87f791323b..52d5f8a5cdd2 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 Wed May 10 04:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236380 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 E2945C7EE22 for ; Wed, 10 May 2023 04:55:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82AB96B0071; Wed, 10 May 2023 00:55:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DA5F6B0072; Wed, 10 May 2023 00:55:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A2286B0074; Wed, 10 May 2023 00:55:27 -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 5F08F6B0071 for ; Wed, 10 May 2023 00:55:27 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 36EF31A0492 for ; Wed, 10 May 2023 04:55:27 +0000 (UTC) X-FDA: 80773131894.12.D8CA69F Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf24.hostedemail.com (Postfix) with ESMTP id 5DFDD180009 for ; Wed, 10 May 2023 04:55:25 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=x62YCY0V; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 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=1683694525; 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=wZO6aq/9W5gFekwTyC/DZPk3uyJH4prf9rBdbQbxWH8f+CZ8cjm4QoxMqRT554m/5F0et2 aJYwDz4+SUNV/aNitq3Cndcwo156o0+NdHHmuZ8sEL+7MIxYC1AxeDkxJvPorh3h38UUnx 1LKQ9CVfrmS3JZjSU/OXI6wkeZtxp48= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=x62YCY0V; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694525; a=rsa-sha256; cv=none; b=G989TPD5zXwmKXkzIYIXen/dyCjH9GO8HujuSyinweEENIBMQbO05C9XadEVU0q0OviSXv XYNtf6pSUTOUrAGWVCmPdPh/IF+PQlLtT0qUuM7kggeu25Ks15rhJNQ1XWfbECfCrzErTB GufRGU5wXVPdVEpjoP10wa9ETgXAg/4= Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-55a14807e4cso121007387b3.1 for ; Tue, 09 May 2023 21:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694524; x=1686286524; 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=x62YCY0VbtXBlAlTlrXst8L8I4Klp5jHuIkAXWeopDmvUXAbp7vfKzA00bYNToXaoh jicsfIaPz1O7U+TdGvn8r6E/DcCNuMjdSP+L+rcocZxL69l/kttcZnaGKZv3QHFP73NA pwziDs2dpT8TywS3eBGCmWf5OZTvKDvRn5iqAcCmFi7ZDxOpEnJaXZsg4chuls0Conw6 1BHyDKqM9ymKdiyVbkRMd5EkORJUOPu5k/Dt9X7/wDI/4JSqAZEDqusgNEXsSQSkAunQ L5ABejKB++Tm9XQd6rM3WeiGICDJg3QSoGYLUowekQIKv98a1U+1e3RQQ2gzWsEHyeuU f9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694524; x=1686286524; 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=TY7kj9DYini3Y0o4CZkZCRHPVuekKXsCMtoPKDBYQo7EannmLKrzHDwMGDrgB6oD5Z PlMujtS2mhMA3JDE+hfWYtUhtlSx7Z184Zdd3oyi6leXkixS5lmAIWCOjtPrOyaxarUb fMNBy5T1DT148rV0u5nwP7wv/KEJ9/fSCPlQCu9X9YFrjSURfqisfcjXzbSAdjIc193e /TzuyraJRYp+SSa2qOOVqwPvhsqfvOqkEph6kUesNalG5n7g0Zh7CXfTAbqfDDUAJ6AI 7GNxNVOU1xtaU0TMeJaSDqbaEmPvJx7TDa2oDiB3Mn6BH/Q6oLz8EBk4pC2qSyl3/rqk BV5w== X-Gm-Message-State: AC+VfDyPPHvua00Sn3TKhhd9Sz8OCh90xdJhsZDWz+y4pIQLSnmNeiDf GZ7QAeFU176/suxjEslMyjGm8g== X-Google-Smtp-Source: ACHHUZ64xP5yCWBSXd1pkCU9S6oVULY9BGDq0OyW51W97Dv6Ixjw6iQVWcUZjR+Rvr+uTi8eh8kq2A== X-Received: by 2002:a0d:f545:0:b0:55a:ab98:a2ef with SMTP id e66-20020a0df545000000b0055aab98a2efmr17944134ywf.40.1683694524456; Tue, 09 May 2023 21:55:24 -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 c1-20020a81df01000000b0055a29ec6504sm3793706ywn.81.2023.05.09.21.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:55:24 -0700 (PDT) Date: Tue, 9 May 2023 21:55:20 -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 , 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 , 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 10/23] parisc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <8552705d-e0c1-a3a6-c26b-b887d4f61288@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: ng6o89ehp4tas18xu8gdpm3hogcjstpb X-Rspam-User: X-Rspamd-Queue-Id: 5DFDD180009 X-Rspamd-Server: rspam07 X-HE-Tag: 1683694525-766534 X-HE-Meta: U2FsdGVkX19KpPVvDNqAWlnESQNOc24AQl7mASwJrR+/u20Y3VGELaISR4adeJwcr5EWMD5krXkQL9HtsuyXCeJxn/RfnKR9FGv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MA5XN/61Z2vc5xotDTauzt62zin1t4kczxZHZPK7IKzL+e19L+YGXwXm3czFGq0t+bhgVX5l+SsgBUSNXP1IHP3YtpO1s7/Rb8tVdXGc7107aZoUmwai7w71IHsYTnmQavsvyjiW5VL4gJAVLNimveQFjDMhn39JD2+SNy2clent8PgmNNNFeda0iS9qpTLHxe8ZRpV866tRSdFjE2+DGCjhwLyMCxuYj/6IkovULSUNvArmoW1uRJ/YS3Pzy0VrA== 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 Wed May 10 04:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236381 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 B2103C7EE22 for ; Wed, 10 May 2023 04:56:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E4356B0071; Wed, 10 May 2023 00:56:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36D0E6B0072; Wed, 10 May 2023 00:56:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20E1C6B0074; Wed, 10 May 2023 00:56:51 -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 108BD6B0071 for ; Wed, 10 May 2023 00:56:51 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D112CAD863 for ; Wed, 10 May 2023 04:56:50 +0000 (UTC) X-FDA: 80773135380.25.9130085 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf01.hostedemail.com (Postfix) with ESMTP id F19E14000F for ; Wed, 10 May 2023 04:56:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=r94LQDZt; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 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=1683694609; a=rsa-sha256; cv=none; b=DHIx24UVivgkNJF5MkIiIZ4FDPXkksKSRYFiB9hPHDLGC7ObnV6MVVy6BC0NeJzr+lMgiF VRKH+6wbBB9L7YSd/lUWXlP3oDc7/3l92PL+ZLJZ5E3SGPCwZHoujhkxzMHgnE7L7Hp7ni RGK6KBlz3aWYTYCWzOhTTrPjACY3EBg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=r94LQDZt; spf=pass (imf01.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 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=1683694609; 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=HSRTlLTXTCR5yk5xde2Xx4stKhpkr1eh7O/SMmicu7LOvdBqT/rvhCP+F6lRqIjMuez4Cy WEmys17GYlBMXHbbIN/Yafza0KqrQqHO9Kz/FR8wQW6+F6nbC7Gut76zj16PZnF4bCAaLu W4EFLllDY+eS2TflxuAl+MiS1Q7uPIY= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-55b7630a736so101758507b3.1 for ; Tue, 09 May 2023 21:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694608; x=1686286608; 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=r94LQDZtq2Ahs+pJ02XRyENxJHGD3oe8r85F2aY3lvsikc/je1Po6VKiCqGzvG34y8 kIuRE1yIIechhFDgP3aPNUwpsvddbLpTk1K5K+zsi9h4zTnxpk/JVyiDuMs9BN+OFeXh nh4AqDsTEXGceRxF3pEZTvbfDGAiIr5yaqLJ7E2ZoOdKC1Zkn5Abo0ezT8CCDEe5hzan c+lECJHpRVibRO6qY89AP62g051JuNBSBft2ut/t1eSbSZxO5Og6LOCNCOMTH+prHdN+ QRgICMzswpXaaxM5lmYItFqDFDCHtHoD+lRFcRdM6eNSSTq3389JYb3eyyNp72I0hHaA zjZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694608; x=1686286608; 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=hO68zXTO4TlGZxr86kDW3gKPb+8ju8Pq2IXuZlSSLtOO0mSUFY4BgZfLBg37x37LMo 0N5jdLEXS7LKYCLr+7YKdSTjtKmKWJRIiX0jelCk3EVFxP+YgmFpohsB91LIcV809mAg ZQsRLg+sZKoZVtxNLhIGYP69mRnH1Su6ZbBtWJZT/7QTF1wmI3N1fC4y/vNulQhjYKTP loQCBt1rkDLqQgwkkNfgvYF1JHv0iAzVB3vu5JiHT3reCCj1mYUwgGLU7c8cNOFtHLTF zG/vuX2lIdAyAPpVC+ff7S8vlwMCYSkzJYUSm/mO+HmdotWUe4FgywxkvEemAb0SMxSW iS3g== X-Gm-Message-State: AC+VfDxk8O84ffc03wstGPNi9PcKw9CpS287gzGK+zFOWv+jhdQ97iiv kjfbh6AQyA9f8+HG8AeaGI6Rcw== X-Google-Smtp-Source: ACHHUZ7AyL+rmns/Ft/OH9KHX6GHbff2/XDcrKV9m3YxNF0ibK6GlQcG44pT8V6Ez5OWany7qS8Crw== X-Received: by 2002:a0d:db49:0:b0:55a:314d:afdc with SMTP id d70-20020a0ddb49000000b0055a314dafdcmr18425257ywe.37.1683694608059; Tue, 09 May 2023 21:56:48 -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 f206-20020a816ad7000000b00559fb950d9fsm3842735ywc.45.2023.05.09.21.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:56:47 -0700 (PDT) Date: Tue, 9 May 2023 21:56:44 -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 , 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 , 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 11/23] powerpc: kvmppc_unmap_free_pmd() pte_offset_kernel() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <8bc72262-3771-4fbf-8738-44d9a8a1ba6a@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: cic5jbzkopch9x7gibqrnaph5mkzk5cg X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: F19E14000F X-HE-Tag: 1683694608-319810 X-HE-Meta: U2FsdGVkX1+qMqpmi9SeM3MmgyLnLGB5MkjTHxtnsjDU2P2wIxTGaAqjjEXRdPlqSCl2dszxTGQy21rsUKQD2S4Yu/W+NjSUPjmSHqBoRNHX3mx0CSo/lNWZToolcE8BSZan1pYZOYLvitMpSsbbvvr0fP0NqnjMrMnP05hNU0Roq4D2SX0Et0Puwiut9rUQwu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UaUHTDip6WqSZF8PL81cEbZNG+MqGIbnGhwus0WSzbDlrD9swDDRd/fqySCxBDs1jG0KsiFGmRQeonOF0Tuk1M/8JtEy3VI+mmzr18AGHFhvM1i9baUQmbJvUC0++cemRm5DPqPBBxpFCmUcfA== 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 Wed May 10 04:57:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236382 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 C1FE2C7EE22 for ; Wed, 10 May 2023 04:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62D106B0071; Wed, 10 May 2023 00:57:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B6706B0072; Wed, 10 May 2023 00:57:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 409CB6B0074; Wed, 10 May 2023 00:57:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 313706B0071 for ; Wed, 10 May 2023 00:57:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 083591A01F9 for ; Wed, 10 May 2023 04:57:51 +0000 (UTC) X-FDA: 80773137942.20.5FC47F3 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by imf14.hostedemail.com (Postfix) with ESMTP id 38C28100004 for ; Wed, 10 May 2023 04:57:48 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=i6tseWUg; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.169 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=1683694669; 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=9SgMoVTm6P3R+1xCqI0Wv3sobczW81YJURPfTY0JVMk=; b=EiXZ7nuiAzPOClZdaQ2kvfIwa15rXeSl7zpnT7QIzTtk5rDnv2yN5wBCVS+4iEzbcBGbk8 nm+GI1EDPz5hPM8mEpY0Mi0IIHoWGsEsgZsZ18/O0n1lMP7oJvgq4Db8jGX1BUwYzlBeAv faqks99NNI5xHme/Y/Gr0im9oMIAwgI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694669; a=rsa-sha256; cv=none; b=vkznc/93RCQ2ZDDKBAccspm5hN1UIoBwaHVHi2L1yPNCjkCOuBLMOBr0CSDC41GxwQtU2a PabRYty6fcp9kPksQSZ2XssqOX2xHf86zmKIJkO1Aj8jZLI34DsT1rCZW1xK8na3fw7+/F 09eEEQJsfZTSQ4TqKOq9oMCksDX3gfg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=i6tseWUg; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.169 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-b9e2b65d006so10156550276.3 for ; Tue, 09 May 2023 21:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694668; x=1686286668; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=9SgMoVTm6P3R+1xCqI0Wv3sobczW81YJURPfTY0JVMk=; b=i6tseWUgvEolfXZtL5Oh35hld4r7UV7sxfAxp1Wi6J/AehneZgxtbpNMAbNVTBMmUI qj7UvqeEgFSQZ2qZW0AaYuuFH6wgQTMaPrP4VLoxCobR28SZjACKnu9c6qIW0PnqI4Hr Cld1tJ0wYqRvaAQ5bpmGPde8cyPQwKjxVNuL2CFu9bbXCawQw2nI4D6D+XCv12mgx2PV ij2tQ1g5xq9+W7BXEvJIwPrFkB6RWDWF/jzluSASWAsWg+TJDk0nuDAAmqQM+N4N23X5 wmyc1MG831sFfWvE1Fo8gZjKKd7Tp0yVdZJzwu/TKEXh0IxxU0wZHa09QO6ZhQjWluyJ QdrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694668; x=1686286668; 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=9SgMoVTm6P3R+1xCqI0Wv3sobczW81YJURPfTY0JVMk=; b=idqMow8ZzmQdR/QvgwqkDEnq3L4F7mpQbLELMrOOpOhci1O3Qw5jrdKeewauCGuFWh H8NLIHKnye9wvQ/0lR7+IkHINbyO2MbNiUs9od2Mrp5jIi9atMNwC2Qq1GQTKyekwQH2 jz4t8ZEBDWLfucM8kCznsWjjHyEj5giswElAFeAzMeaqZciH7Scx2K0MUzpPPGNzwCKd p/6zn/bf08+/fiBHUxqc847fhjf+tZ2Guxk9oTa3DqxtWlqTILIKM/fIb9C/pgK6fYic ZmtpZ0Bv3rIX22qfzRL2m9S3FvVuwG3NikMI55uS/p+PTFzZyiDQ72V05m9Rx/Ydb1ie 7F8w== X-Gm-Message-State: AC+VfDwhSkIqdWy7KVF2Ic9Mz9oxogweROnbotQbtP/SQkE35wT4c1Kx s5yYv3p4ejv8ty9v615VXaQQDQ== X-Google-Smtp-Source: ACHHUZ65a43Tqu6pm6F2C+WJXeNuyd8nzb4UZ4DSWVXhBJktpHLfzKFfcKlkmv0fFRrnRgtDBOnq8Q== X-Received: by 2002:a25:4d87:0:b0:b9d:5691:3ef6 with SMTP id a129-20020a254d87000000b00b9d56913ef6mr14812915ybb.27.1683694668013; Tue, 09 May 2023 21:57:48 -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 23-20020a250d17000000b00b9e4a9b91b9sm3508848ybn.30.2023.05.09.21.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:57:47 -0700 (PDT) Date: Tue, 9 May 2023 21:57:44 -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 , 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 , 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 12/23] powerpc: allow pte_offset_map[_lock]() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: 7dzidbhs5wrsmtoofmxnxqkumm3smp6i X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 38C28100004 X-Rspam-User: X-HE-Tag: 1683694668-602119 X-HE-Meta: U2FsdGVkX19K4/zqpk89Bg/X9XjS6EAAiTdunQ7maPHimuQhcAUwt6oOnKDl1we1RT1k7A3HdjGB0ShSgxBH+B7lSX24Xh1pFrC9PS0bYUqV46B0K9KqYRp1PUY0sCUfXy2Du81fxfNozIr3QNdcSC7mGH9mtFIspQH/08vA2zuLiyupjIY3+C19r7p0Kykjx/jHFujrhbX50m+H/axhsgUe5S7+Okghnatz8VgL/ILmIbawkJKSp7kMyB9HBVXkUSxmI6Pghj3kLgjRdw1y9sIi5jOIbLD2jHU8dx/Re2pkEp1lLB1I390E+xaqqZjCDCfwKdZ5MoKlkjRgS5Eg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Vpl5ww/1hx1f6w== 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 728d3c257e4a..69447bdf0bcf 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 Wed May 10 04:58: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: 13236383 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 29CC3C77B7C for ; Wed, 10 May 2023 04:58:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAAE26B0071; Wed, 10 May 2023 00:58:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5B706B0072; Wed, 10 May 2023 00:58:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FCFD6B0074; Wed, 10 May 2023 00:58:55 -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 91FE56B0071 for ; Wed, 10 May 2023 00:58:55 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 646101A04C9 for ; Wed, 10 May 2023 04:58:55 +0000 (UTC) X-FDA: 80773140630.27.C9D5CA3 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by imf02.hostedemail.com (Postfix) with ESMTP id 974F580007 for ; Wed, 10 May 2023 04:58:53 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=P9kK3Ha7; spf=pass (imf02.hostedemail.com: domain of hughd@google.com designates 209.85.219.169 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=1683694733; a=rsa-sha256; cv=none; b=OS1DPox38E6WWyoz3weHLTOa+J9Qlpar7pRS6hEt4D+bM0PJ93PRk/rSubt5eu2xXHQg/t A8piKaKF4o4ptnYKT2A3Xr4AyJIj9VN0OlLQ0LvE5tTT4sJmJF8/jmWFSC0bSEOOIAAs7f APrhR0nutcOtF1BfxCNkbNEt625bvW4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=P9kK3Ha7; spf=pass (imf02.hostedemail.com: domain of hughd@google.com designates 209.85.219.169 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=1683694733; 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=AlnjKQ4cA4GMJrSprVqE/7dSa/AYYsD3KRgv+LWWp+07QHgoVFwte0OUCB7wMd2LqfizpN IKh+xQKy1vF2OYye9Awro/xS5LY8spOeWCqfptrfYE3brC1+eJ5V48mIhybbALOXBBjHN+ qkakAanFuMIUeCddy/hDjdOqBrk/W/M= Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-b9e6ec482b3so8690389276.3 for ; Tue, 09 May 2023 21:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694732; x=1686286732; 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=P9kK3Ha7kM6a70P/N9uB2lWXrssqQgUHBWNV/ZpJwPmg2mPzx8gUi6+Y5U3HPMDHz9 0fAlFOi/bTART9baPPENUGYRX+MazYzuiDcAIMOosxi9lXkJsm3mNsaLjOWtnLwgcry5 sP0r/lFyFBNCqz3voFtKwARlNZyj767HfljqLFdQYp3UaORt42cJzHdk0VN4kJ5NQH/7 DWlXvI97puE4OaBtmUgMd/qH5Lin+XJ2aRjT13gN8vWtWVfPYNVNo8e918/mLGqALa1y O7U3+kDK92dAzqxBb57AmVgMsRrk/0cmMw+aKo8waotZHzpB3mgtMwAgWyIj42FB5uoU 5erQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694732; x=1686286732; 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=gDDFML35qybhOFRIw8QskUwx8I3Gco8clMFleyFcSQXv+B0DxKEoZILGkxcJWrpBCw cvywJD9ZCVa/SqCP53cLDBGOjzKksUS/b15Lz1LfW2utubwidbWiqicovVpWodK5NvuF uKLitmU5J6y38vpBND1+u58owhIjgrfqbguFLdVZU1aX8EAHY1JuQGaXbJz8hSyJeAyG mBSLPM04sjsga5X0OTFABcy7INVLAuHAJqfuVjhWfJVVpX0NVLsWlfaFSb9rRKJ+S2qX NbfGzhCZbA1qZ5in5hpbXihmpp5reMsz0j0iARr90QgpqajZ0AOjTQbuad8Ivdwqr/3h mykw== X-Gm-Message-State: AC+VfDxr4lzeyxW8LSRb0yiyR3TVnnsBCPLb5uMOWRJVPJRSCxGs78er bWDKLbrZYiJuCJmy4GHhgsoyQw== X-Google-Smtp-Source: ACHHUZ6HrZAnm+aaG2sOhULY3F7mb+ht2GRzSsBKsJ/KT5tYwkiRpQQy7lJKEHctJdijcfVx9gaq3w== X-Received: by 2002:a25:d352:0:b0:ba2:16b6:b11e with SMTP id e79-20020a25d352000000b00ba216b6b11emr16144172ybf.0.1683694732647; Tue, 09 May 2023 21:58:52 -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 h66-20020a252145000000b00b9550fcb12fsm3461906ybh.64.2023.05.09.21.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 21:58:52 -0700 (PDT) Date: Tue, 9 May 2023 21:58: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 , 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 , 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 13/23] powerpc/hugetlb: pte_alloc_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <1a3ee4d4-a829-35d4-d94e-885d5d4d6a8a@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 974F580007 X-Stat-Signature: zmufpzkjybpygroso9bxn11pxk695cts X-HE-Tag: 1683694733-144469 X-HE-Meta: U2FsdGVkX1++oscSneIu9koFrSXwQ9gU78n81Z34xT5KgnHONmhq/NJNi38yIu+B9I8FmYVRaXMqQkgVNmf5jwGAcNlE1vjfRCbL+ozy5c6w0l+7ckz2CPI8+ZT9TYdbn+LjRSsexsnnLtd6ShRaVBzzfI9qMZPl8QmC6YciJuqebUeMSerHVypw+tgTDjauzR0dx9MLMUX9z2gVLKXSTCZzMKQhB85LuJe3IpLgPqYGeh2tJ+ZekLOm2YQUB6VCyQ8P7HO5bOFYrG+Fpa+PkYIojkJABqBifoCDszBQoAAFcPSH5+DP43sK9EbiZsDe1rBgeKnMW7XZcIZmgRdgWUYFktwpM3v0+MiNCgbBtHJlZ36VO4OmcO79RSAAQWyFQnQtHD1niAW+tiwI5MNKYmzyoN+vs/AkhIRbhB5/3dlJo4Tl4W5ia4uuFyq2UF5eMeBJlQdKPzaKNvO8youH3zvU6MrJPr8LTOmOtE5kVLhS/uTsVlXqnvlkDtYBus7eCN0RlcEPi/2km3q55lT3H3K/lPUrJVlCVI41Hm7+rIaA9IbVVU7bwoAFkUd9BlN2c84I2DklD4UVMPGOXn8ibj5gU8dad5WpAgbtCCY5KXNN0rI2X8XvUwa3ObTCiyJyfLYUImORHFQ5wG3U08wxO0Vmkr1+BYFu4cgvMygakiZfVaYfxebgLH863aSKznOFVC7Ky5oxDbMTvxp6ScSCPAwABccTxivPw4Q5bJftKZMbhglilKLY5skwULQfWUvFHYYlEAf51Rck45xuNYX4QtGz6zlo4WPBmElPXe+wfdloLvTxNCkGh2sw0w5JFnX7VjkL8b5FHKPHFFt+nhYH8kl7UW7fSlnKZ7n4VMaugZdXzVqtMM7jEp5xcvKJjfXrRSLar50N16u44InyQyeCnLYrbGltRfa2weNEg5sqC2HObkhzi3iPd15xWLIXRTWjbcmkCL2voAGfxRH0hrL 0TMiaFQV kfb3gJ1yvuZKwUAR3Utdx+ng+tdimyVZSBkPVrV6ITXKrK3LwgQv0jGHjZaiu0FdGJaPfKKBwwEQj8VzKtPJlpU0d8RaD2Cm4WQWNa1VbOLAui/yH7n6szIIobzHXd85kHQIDDwlpI6qFys7cyV2c3nZ+ozR1rwrpoN9VPBX/uoKX5FSiqE8pKgvZrQR9OwTogB2b4D2EFsm/n9c82l4Y1WdZSPhvsT3IcmjYZkK1Gg5acFlwM10MkZSBKLtDPe3FL0Befc91J/6iSZZDjvZYf4r68XPwj84bxi7VurZW/vgICeQdpX5EuefasHsD+Zdbz0AfkGpeFrwMxPYsiFzVcCtEWB7bt6Mh4PgppnBWP3ZoY3401ZZvVCGZSqxdWB+2pA7Q5FPmF/C5PpMJxxE6Q0898i++YPJR8DBRGw/08+E7or4Ieh0Jgt6XPQ== 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 Wed May 10 04:59: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: 13236400 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 5F8D5C7EE22 for ; Wed, 10 May 2023 05:00:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA6D96B0071; Wed, 10 May 2023 01:00:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D56D26B0072; Wed, 10 May 2023 01:00:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1EA96B0074; Wed, 10 May 2023 01:00:04 -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 AF4D76B0071 for ; Wed, 10 May 2023 01:00:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 69C9EC04F0 for ; Wed, 10 May 2023 05:00:04 +0000 (UTC) X-FDA: 80773143528.28.B755B2F Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 9292E4000D for ; Wed, 10 May 2023 05:00:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="v/0fedI9"; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.219.172 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=1683694802; 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=ZMaWjOOzBzTq25y2V3ItGl/gYmS8RRtg1cvEbj+mQng=; b=eb/1TR0abg0n2iiRCKyT3Wq+IaoCzLRpRcYDIaAiOK+A1BnPMhkIwkEEnreH9muqSUdVB7 pm0paw01zptzK9Qq915VWrTycJWjKgEqAb1epuBZIYYk1YzRKimaLlxCMaYezzOxQJYjeE RZWFSV77sdRbi1Hu+Sao6S3g9b9cOl8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="v/0fedI9"; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.219.172 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=1683694802; a=rsa-sha256; cv=none; b=pp1OEhLwrnWlxtfU96LYY5h0XcFZcO9XXKA6ri4fb46laynTsDI6mxzEkYEIsTHSgCwFOM IRjNsfVgNjtApAYR6ijjsK4VClhEyktoDzUxIdF7WKUsM99dpH1hT+zeJAmsyrBUngnxle 12crToDt1WN9DfBhHEywDh+vj2cHos8= Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-b9a7e639656so10177365276.0 for ; Tue, 09 May 2023 22:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694801; x=1686286801; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=ZMaWjOOzBzTq25y2V3ItGl/gYmS8RRtg1cvEbj+mQng=; b=v/0fedI97pPSEeG4JjmhWFM2zERS146SPiMJXKFktyRt8gcu3XnU9flpdOBzk+uwM5 s0LxqY4B95aIsZsh2mJFZGGaGczJQ5vlt2ZTVgohuP0YCEpkq6BqvaluTpoYqvCHZPxl zKN6HOjwjx0yrNqF5dlqaMyYDGE2Vrd5Uv3cHsjFUAt+EAmeWDDRNYI0YlpbNo86b8bG Aipz8AqM9zEa9JBFP7+dKHJaNOyMjOSxB2cpapkuH6PjkheDE/u4eOtK4ivf5fV5d230 xxAVZ1lBfR2A1vI9J151/+XOuCwLBzeq8s5a10eXtHtu5Hbfr7aLXi+072D/bPReNYVX IS4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694801; x=1686286801; 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=ZMaWjOOzBzTq25y2V3ItGl/gYmS8RRtg1cvEbj+mQng=; b=HdRvF1Xu5RZjrvB9lv/eIYcN2UgP/0ks2cL3vcuSSgHraJB2XMjD/PMv/xPPf6hw27 HA0rWvN18pI+rrKoGc3icNYg5JkRApzW9UuIjDbDHozmXAZhp/WerAAcnbuu6NZV/ghs NXpkrulDU/uPhiBMPds84OTx5lyBmqc8r0TtjUk36wDxWha7lJ/FWEMam9XivNFiGlhj 1TlT850MXZrucxsb0v45NF889uMhNh1yYn7igGAlRr5tO5TRncg0JanP5dFh+6up/4hZ 2Nx3HayEr1c/c2vJey6SHbTtwqMVXA9zH7Fo2pYuYgecuxldOF0FDKBk5W/UjDBsW9eH 72fQ== X-Gm-Message-State: AC+VfDyKHEDZn/qb9Gs8eIsiMtK2Vbb5eiTaksGj8xSNuaANlvf8IOBV e3aJ26Ux9FVPxr1P4+9AZIQ7Fg== X-Google-Smtp-Source: ACHHUZ52JqpHXNjwopV1qONCz4ZhxlIYDhhrgvgpvQjGO/cy7NhTIg/35E50jddhJVH/CVSemNKwJA== X-Received: by 2002:a25:a1c8:0:b0:b9d:9500:9d29 with SMTP id a66-20020a25a1c8000000b00b9d95009d29mr17308461ybi.45.1683694801383; Tue, 09 May 2023 22:00:01 -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 b4-20020a256704000000b00ba2da98431fsm1603597ybc.56.2023.05.09.21.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:00:01 -0700 (PDT) Date: Tue, 9 May 2023 21:59: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 , 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 , 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 14/23] riscv/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rsp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pkucerJgqzY2Ixo1pQ0Mxq8uNef1OT+h82zufbKQtl0dOVAg67f8pvLyfr2kOnw8lCfA+T4b228VlSdIeJyhdxrnTPL2mBpTWwT6ezBKxN9QgnY8IrYaOc3SSaRxuZ3sz36dJjTrt5ellk7YtD94cbRiRAPNNFe6U7gjM/2mZPcTYDNSYpIFOYiCoQ2DsephmstKaLwON3WnQvR71B0lNFV+xu1uttVtmxHM1x+5eMs0BcAcwy2mGO/q7DPEWhC/BJzPI8pDA5KebgKY2hPMeu1wEB/IOnuVTBodR3PwoO4V4KECxHZhZGpD8TLMCdtzdU3/v43M+WVK02k3ewp8zNolkqNb3Dv5x8iRWbNCb3LtYTlKdZPR44HZcGganaS8ClvhTCfNPrmkytk8Sy/bMs4jNsEGgFE2NLDNzHynsWN4Q6w== 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 a163a3e0f0d4..80926946759f 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -43,7 +43,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; } } @@ -90,7 +90,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 Wed May 10 05:01: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: 13236401 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 092F7C7EE22 for ; Wed, 10 May 2023 05:01:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4AC26B0071; Wed, 10 May 2023 01:01:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FB426B0072; Wed, 10 May 2023 01:01:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EA776B0074; Wed, 10 May 2023 01:01:23 -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 7DCDF6B0071 for ; Wed, 10 May 2023 01:01:23 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4BF3480555 for ; Wed, 10 May 2023 05:01:23 +0000 (UTC) X-FDA: 80773146846.14.55086CF Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 7173C18000A for ; Wed, 10 May 2023 05:01:21 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=vuo7rYDM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.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=1683694881; 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=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=gQfSs6xgYnbtu6B5Pub6R5g8WpUJ2V/IG2+StDGVE06DqaVFBx3v3fWnkQ5+pVO/enKxQf hI+7D9PaMzXdgZAxMq2qV1JHBQue24UBht8CHPjNBfhxrvqxlq/5eA+BeyyIK+72m29Ktt i5coo4G/+P9JmZKbBX7X3s8g+oiW3P4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=vuo7rYDM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694881; a=rsa-sha256; cv=none; b=5gZ7sM+vkcxz6eZk/z2rEJTTL/TAZLVzLGLUHqbgY8NK+WEy02KDBOy0aZ27lhDCca+D/e MYmyLJDKtH7DaVZ4tk+fWz9remyeUXFCIk2Is6PCAJ7J6JIUEBdv7PxRkUEBjDF42p97Cv Hfa6pEIPQZ30uGPcge4bby9aWVrMST4= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-55a829411b5so62527597b3.1 for ; Tue, 09 May 2023 22:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694880; x=1686286880; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=vuo7rYDMzaDeDPZgzHMtVp+kDDpzRoF+cP2Qnr93hh+pF6J9q5tC6QhVWjQR/dpJZs St4YSsmW5E0SKuQmRdibMqMztrKviA12bUxhXRBvVCQgZMikD8H0uj5+E9csqviYPTTF W/MWYfjHA/1NssscvDoyXC6tVcA1ciumq+qFhN9YZhl/AUe/TYRGPOpbxUr3CzSoAwDs 9ZIJx+k2kcTyg+8Yd6pO3A43gfTS5JygrpCg5CjFhHivuRBYVd+ivlToDlbyQHOK26G6 DP8KUWo0VQTsOYmO3ProNs6agiD4J9mWFi/qWhwm90YAcZbtyMXr/cNFlm/A7CEZL/+P HUIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694880; x=1686286880; 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=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=YEDXpDe6nlRzVDRW0HhySZcjGN6adB06xe7UT8dB4NZLBJ70ndW+L+phGRjarf9lZO u6KMTKAHTAOCSOhQZXXe5kA3vVYjDFqbCXfKFnR6bGl2Tqpc+f1eIUMROBZBZHA5MpKy Geu2yD3EM75Tj2TD4lhk2rICjGI3GzbTrG+/+I3hFHNBAh5ni4N/MBO1PlXaP0tX3cMQ C1OmCQb//mjX3ibryoOcY2vIOsIsN345uegu5IX4Ghm+pABuJiIyQNEDtg/ADiLH1XZj FkHw11I2VZCD02yyr8o/oywDXrnViXpfCFKPHDocAouONsiV/+luHrkmT60ruWh4Dwyr V3MA== X-Gm-Message-State: AC+VfDxkS76eUH5pgsEJvBf4PUcTahEhIXXk6Bl1rQfPhb/ZTKvOhTgs /SplBNIYGdN74PmZ0w7UC1BtFA== X-Google-Smtp-Source: ACHHUZ5AoVobUeVID967V3Jmnothc2qu5Os8b3JQyJT6HUqgLFH4b1VRwh/1toL1vvMbGclLD2jjcg== X-Received: by 2002:a0d:d4c3:0:b0:55a:9d84:2e4e with SMTP id w186-20020a0dd4c3000000b0055a9d842e4emr17674451ywd.18.1683694880477; Tue, 09 May 2023 22:01: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 e2-20020a81dd02000000b00559f9e9eabcsm3815388ywn.98.2023.05.09.22.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:01:20 -0700 (PDT) Date: Tue, 9 May 2023 22:01: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 , 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 , 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 15/23] s390: allow pte_offset_map_lock() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <94aec8fe-383f-892-dcbf-d4c14e460a7@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: ay8ssnpqgxwdh6rekxeeywpf76xpb135 X-Rspam-User: X-Rspamd-Queue-Id: 7173C18000A X-Rspamd-Server: rspam07 X-HE-Tag: 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NT6iraYNAqw2Ap3izo/y6RaDUONggKFIPtFPhnDXNRFMmSqBo7krCvL8MPAccIYOM/7dtBCgekwxVGJnbx9k7j1eloM8YiOEIxjT3EMbUN5h5H+RW9PxjmvRcsx5doXlhOoi+4sRD2ry0SgtM9vFN4cejcKdPAAlPhRsWwZ62+EiaBzGQ/OOJz99jKPeiIAP9s0MHOxZV5bKAGzAvMBnvbQvYz7DS9A+hqdoOoqZR/Z1o6+9VnUOKYXLXQZOP5olmrELYY9/BKYW9kP0Ye8fR5EOaJ4mgBk3briZX5QG6R3s9tEtbxqas7o7+J3VMHMWthcut1Q6c6JeYJr1bMonehizd60bVES3ODQA== 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/s390/kernel/uv.c | 2 ++ arch/s390/mm/gmap.c | 2 ++ arch/s390/mm/pgtable.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 3 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..d198fc9475a2 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -2549,6 +2549,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 Wed May 10 05:02: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: 13236402 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 068F6C7EE22 for ; Wed, 10 May 2023 05:02:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AD946B0072; Wed, 10 May 2023 01:02:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95ECC6B0074; Wed, 10 May 2023 01:02:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FF2C6B0075; Wed, 10 May 2023 01:02:39 -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 71CE56B0072 for ; Wed, 10 May 2023 01:02:39 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0F01AA0502 for ; Wed, 10 May 2023 05:02:39 +0000 (UTC) X-FDA: 80773150038.15.DBBF6B7 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf11.hostedemail.com (Postfix) with ESMTP id 404214000B for ; Wed, 10 May 2023 05:02:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=MZLldLeo; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 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=1683694957; 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=yuPIUnxI15Nal18dmzcm2R5Hbe23rg/L/N54Quf1VSM=; b=ERi4YMaMm3LCrNrDViuuBl1aJSKcYiGLOsMEQp95rijCdGIQoHAcEK0hUza6pFZuEM9A0n dElJoMu0emDSdezNMQgcl2dt8IJh7GkA35ZQju28EJLyY8DEMqP6kmvOwT1r1Uq59i23Xa DPISb41VtGoUB49cANYgsRgjvrIyuSg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694957; a=rsa-sha256; cv=none; b=f+mDA0NPoQ3+kseCPZetNq+brV7zvJhz3obvjXaOPTpG8ucGys1oBoWSkv7RmaE65PqPoO FYEvlY28MzNXS/7cZA+XJlRSYVKL3cBf1EY4RU6gj0Mn82Zb4fGZk/4R2z4Xgokqx8DRLf ZZIG4gKTihWpcHzawBPYHhNW4kHywt8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=MZLldLeo; spf=pass (imf11.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-55a829411b5so62535977b3.1 for ; Tue, 09 May 2023 22:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694956; x=1686286956; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=yuPIUnxI15Nal18dmzcm2R5Hbe23rg/L/N54Quf1VSM=; b=MZLldLeoTchJRg8ULRaH6L2y47XhBLxMJs1Go7faNFAGJ60D+vvC/iJb0Buc77Bpr6 JAiUBm+hO4tciOyskyTHDu8zHoxcS+nRd9yRDDrgu8RadfICeTJTrI6xGxTJWG3gg8GE GihvOxn2/FrCq9mvWrB4PViVv+smaQj46irSMOCeG8hhbs3XZFgG9gfnNhAREX7BTIuo FwBNusKFw2CdGBlovtbF9aK1ipGeDHjgN+1rN8m5K9X1QHfWeGyfS7n8ZLK61yxirERs wzLOW0oOQaCrKrTFBkqyll9ZBkBC8WcWqedcyO11Xuqtw+I5+Pp9ph9gkiqNZDE1+7z0 OmmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694956; x=1686286956; 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=yuPIUnxI15Nal18dmzcm2R5Hbe23rg/L/N54Quf1VSM=; b=JtnaIeKiUAUWZxEanDLZN2+SLdrDRpXGHoihrzruQCLxkHYnPEMpHwLxKyGs8LKyml oveoGTtOapNiSS7yCWqzWtAuZvRG6pIZ9Yb7q1awEVem8GRJAf1p6BQuniiEZbj6mNFc dOIKQQCLcoymUSEkyolWpVDsUSARDYrW+0Mj8iC0UPFc7ROQXkJRhjUGcyroLml9n2FC WisfXfLCZNhxqVWwqwAAvu1bHLsV6b9Okqg/cl25XNRM3RDkPeLuu6czM3pEoAljjSVE xBNS7LDI7AhZwnJTjpmRL+9ROcWy6DB4ZIUcTD832b7n4DNuX1evT5UzN3LeHTctlsxg Ifvg== X-Gm-Message-State: AC+VfDzu5hxmlZ+WnWE/EtIxZi/OyrESmWyTKaZ34n31M3nNgN8PqFE+ jTUwKKpWy1W2obcRhdE8kOtrcg== X-Google-Smtp-Source: ACHHUZ4mq7HDDHYHVt/QFmXvmAJMqlmdCFbymB1fCkEy74WyI9jP3Nyoly+MUZg8u6u5wehMYgk8Zg== X-Received: by 2002:a0d:c4c2:0:b0:556:d398:870f with SMTP id g185-20020a0dc4c2000000b00556d398870fmr16786959ywd.47.1683694956234; Tue, 09 May 2023 22:02: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 v133-20020a81618b000000b00545b02d4af5sm3822297ywb.48.2023.05.09.22.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:02:35 -0700 (PDT) Date: Tue, 9 May 2023 22:02: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 , 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 , 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 16/23] s390: gmap use pte_unmap_unlock() not spin_unlock() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <5579873-d7b-65e-5de0-a2ba8a144e7@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: 7sgk1bbg8p7o63rikf57iqmg1o6siafw X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 404214000B X-HE-Tag: 1683694957-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WCTcWcwRWK/QOetfIzniCHtL39M8LPc+AleDIqQETCN/1xiQ5UnS9Yjopbb6uhbyS0GZaV8q+WRUDxsWdrxidCZPNFg9n4PnT7Q482rSrv06GGNOihsYklehdQhj2fPvB3bpzYXZ2bw/zgwQ33HafAKAVTXr0M7UgHeoNmpbj6iZhxHZ9jRoNJ7/UQwotVJVPoJawezQX2jW+DqugRRZJSSgScV7kHTjkU41ID3Np4CuFtyhW0u8cA7bFMLR3OPF6IfWVvuefJweVFbpy4lSzAupxn4BN2MAvd7yJT8V54KUbdXnLeiS57Q1Z1Ktjzb+n9T8zmcPBSQ5u9we+nMvUZ4qZpe5G9YeVXMazRtIJSANVw== 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 d198fc9475a2..638dcd9bc820 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 Wed May 10 05:03: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: 13236403 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 EBA6DC7EE22 for ; Wed, 10 May 2023 05:03:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C3DA6B0074; Wed, 10 May 2023 01:03:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 873FF6B0075; Wed, 10 May 2023 01:03:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73BEE6B0078; Wed, 10 May 2023 01:03:47 -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 66A246B0074 for ; Wed, 10 May 2023 01:03:47 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BD09FA0502 for ; Wed, 10 May 2023 05:03:46 +0000 (UTC) X-FDA: 80773152852.17.3AC0FC5 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by imf16.hostedemail.com (Postfix) with ESMTP id DFCC418000D for ; Wed, 10 May 2023 05:03:44 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=f+IDJIOx; spf=pass (imf16.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 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=1683695024; a=rsa-sha256; cv=none; b=Tkaos9B6HzvXueny7h/uX3bwSxfG5OO2s8WJMCxszy/MX7zRwKRuyOXUuo1pexzbe0Pd6+ GL2ILd/HCMWtp7Cj9qLcfHAuSdZlfJAlk1FkF/r7LBEthrYjBm7wp6f1xgkxZ5bQusUrN2 a68VuOrJI/tDFILzOhMQd+JrjUmuAcw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=f+IDJIOx; spf=pass (imf16.hostedemail.com: domain of hughd@google.com designates 209.85.128.181 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=1683695024; 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=RgTEYGp+WXE5WG+5OTmpZCEyi4ijbJjTB2V0GHbtCBK2uHcQNzNW7b7MCSSOM4aIKi1rwB 8xzSVaCK51tpcBQ6IpkqmktstZCIh1JWhX3LKIBk9M8zFp6SCt09yRj42lw5h1zhGtDM2L dO6l3BHj+GeCVTrp4YWMCIATxaH/QuU= Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-55a010774a5so104197547b3.3 for ; Tue, 09 May 2023 22:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695024; x=1686287024; 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=f+IDJIOxeE7pBv/ncUF3Dg8yBdNeigyWPgONUVZVc2EQnlwiXg/VQTMZqIyi1FwbhF hB12dPYWMlW78XVP1iXq4ueyFowA50D/X9k7kSng633zgtc6Ft9O69KyiELqvbNIUVet ZV3CNBYMAMk1NaEigxnnVZgnTZDfN2Zgt7qDs5DqEMg/xKQN3cvE2DpHKAZxvYja2q57 EzxbR8ATmL4FQRq126r5Vter9+9PB+pvzYqq8Q0Kq08+IAz0Ct1bpmRKsD6HzoQSgfyW CVzetCsMpC4GogX7r4Ise+/fDJ+qVHJTfa1OEDnQ873jx9nxbHKiO6uVblFCp5x/gnEx bWfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695024; x=1686287024; 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=W9y5WA5RjLWAX081NCODBFR9MbnHknsAO3eY9V7jThoLhpA8CX+hQSyu3R8O6XxBUw 1nnkcyDDtYyy0MOul87p5cCMlH/LZDleDjK6Gvskxv4sY1B/0gDujoON14DbeAS7gw8y GEmAbkbFHikov8jNbCoJx7jX4hp4OMDJx6Yc2sRwEGXNrX+EkKMd0+0uwJGrNMlet+Z4 rixXUV/qiUfc/FdJe6MdSIQzrSRvYqzKca32tNF14vWu3m7MJOuhZpG+uI6GPELRdDCD c9pFaqsJWlguUUkBbskLBTseG7q60A/BB4He/tdd12/wi7KyFxuPPJdnRlpsoR/oO/we cBkA== X-Gm-Message-State: AC+VfDxKgsV+EGdEwcG3rlc/6NpEzjBtrKvCskf7nVA34NqvW8juWJ2Z fOKI1XPUATpPuMf/k5HBJTvDzQ== X-Google-Smtp-Source: ACHHUZ57BibEP8l5nJ6F5+RjmWOH1yRU/GU0ORzVTyycrrSkC73g/4H986WkI3WYpSdD5+TSi7jmbQ== X-Received: by 2002:a81:6c42:0:b0:55a:1022:7814 with SMTP id h63-20020a816c42000000b0055a10227814mr19292393ywc.28.1683695023901; Tue, 09 May 2023 22:03: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 i189-20020a816dc6000000b005463239c01esm3871312ywc.51.2023.05.09.22.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:03:43 -0700 (PDT) Date: Tue, 9 May 2023 22:03: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 , 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 , 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 17/23] sh/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <85eeffe5-95f2-2574-365e-c9af663c8672@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: fg4nkhg98af1bg6arhrkti4nea8oe65h X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: DFCC418000D X-HE-Tag: 1683695024-556638 X-HE-Meta: U2FsdGVkX1+qHGPI1CYXOdWwSkcnlgX0mwInA3Y0tEttUOya0B17EaZcb/LqpPgG7Yr4IFaof2S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y/p3aR2P8vGqCqK8a/hGgkIOq/KHTevTOHxDtbN+Az316NvBAW7pKZ9YnozaWQYWTj2H1eYnN58XouxVAEdx2NX2T/6F1mZEIquUW4rMZxlLoLkRKrOAA0zrTp6gLksQCMleyeTVc0j+CqmiyLQ6AwTNu+NuggftHMxmO0aLpuPHEarJicXW4YRVsgYrXRrWmwq0/WL+v/mB8VHxNonbBWlqj7ObIjUxYVGn6rIpzw6SmaOaFbbvpFy9mtAd4aeOIg== 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 Wed May 10 05:04:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236419 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 BBE70C7EE22 for ; Wed, 10 May 2023 05:04:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62B326B0075; Wed, 10 May 2023 01:04:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB186B0078; Wed, 10 May 2023 01:04:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47C216B007B; Wed, 10 May 2023 01:04:53 -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 3BC986B0075 for ; Wed, 10 May 2023 01:04:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1F662C0428 for ; Wed, 10 May 2023 05:04:53 +0000 (UTC) X-FDA: 80773155666.23.901CD03 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf20.hostedemail.com (Postfix) with ESMTP id 5062E1C000B for ; Wed, 10 May 2023 05:04:51 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=QuBkLiQN; spf=pass (imf20.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 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=1683695091; a=rsa-sha256; cv=none; b=307Obo7AxodbkGSHETaj0FUK/PYea/3Y/BdOuHxvRIhVyPUScH0KYktpycw052BxhuLeaN N4epQu2Krtq0JlsW6QHOmkaUJAkC1qqlZc40P3P1F+Lma9xgGAuV0ZK3xW117HRxNyjbqR MF440FQHpC9vmwy8VnzkO5Y2jaJSecA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=QuBkLiQN; spf=pass (imf20.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 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=1683695091; 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=FIXBUB4pCUQ9R162n/0ydK4slNShFzbL51qfZeqMdnt0o016wTMPw7LKyhPIczjHAnqXDf crMPxYD5CJWdBXftIA8zM5rX1U7HTQauTrh9+Wl1tD3G+7JwDItQaabOg2lojIMJkIR89s 9+g6/HjKXyCQMIAcIpTTto/T8nKyndE= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-55a010774a5so104213407b3.3 for ; Tue, 09 May 2023 22:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695090; x=1686287090; 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=QuBkLiQNgKJXlZ/XtUu/Zcc1TO/yNvtmxeCEZWPuo0Ut+/Dr2uj7N/fYaVeLSLWaoT dm0LsrTZl+fdsuIU70XZlX8Jdat219pOrdD5tmXxlOJq6I9xvJ8OBX2I3sC2/GzC7pIG XUtWl6K8CddosokWCD5JWnq8C0Qt/Y0GNquPBcUW8sOkTJGqV76KRSYlIi1jOPSqgjjT xhQu7yGeLyA8b6NgZMivw3GAn6e1+z3lgr3LgyDkQncSxt5H12sTmgDyT6BBdhQ0rxwG mDoCtTBYmNMU6XzQs1MJn/66oGLzS3WRb3BIObV6fJVnQHGlEpGSXCP7I8vkrI+sg4mt TgtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695090; x=1686287090; 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=SNdPVs4/Wa+K+Xa7OLg1rPgdCDJ58ATj+z5jNcs+DBMIzG5ujSDSkT9oog2ZMotNeT 9yE/MNyOv1+oaoEL/ds6WZh61CfiCwDja7dEKqPR6RnW+8QWR/6qyjVcbW2TnL7gg2xi JHTfwW4NdoXdPr8MZJyyZ78ff4DCIS/nN75/COthKKEojtPN6nm//vqEEwvh0Qg4q+YM 218kuq4waHY6Ur56nvszsgsY6Vc+VkvKgXfhtcoxmN6uwLzbH7jlscKfU5JMmZGzGFg+ 0/7nBOXvBF+pdwZgn+6UhATi0N4x3nFojVkpjaeCEDtRmCnY4sdodE6kwASOwTMEtjNa T4bg== X-Gm-Message-State: AC+VfDxZ+b9GVbnZmjqk2o8xDZ7EFDq3gEQdjXFsVAIWEgXuvu+JdfMn br7rQDDxlf/H3x2D9rc55SlM0g== X-Google-Smtp-Source: ACHHUZ53GGioj5bo+FVmOpbhwfbbVyWZfbgJBuIz6ozNT3hKZWLtYauVGFRQKbnj4naBNbfMS7YmUw== X-Received: by 2002:a81:488c:0:b0:55a:6769:1197 with SMTP id v134-20020a81488c000000b0055a67691197mr18307004ywa.41.1683695090358; Tue, 09 May 2023 22:04:50 -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 z184-20020a8189c1000000b00560beb1c97bsm948270ywf.97.2023.05.09.22.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:04:50 -0700 (PDT) Date: Tue, 9 May 2023 22:04:46 -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 , 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 , 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 18/23] sparc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: coomagbrg15s7r86gpdjk89jqhrcti9y X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5062E1C000B X-HE-Tag: 1683695091-162485 X-HE-Meta: U2FsdGVkX1+ga9IqMtR0jmbPcruqtMhyyTn8LUQff2Vh2mndO85ZGf3T2UB65X8YMVsfGmlmqyxWjC8n5/FWt3mH033O8mzu+/RkI415td7jMJhsbWzmZAVBh9j493RW/pAefBwo7JW0ayRJNRlWiSeHgS0fER6TnERDkE+XHmqW/5/YI2LHep5QSwmLPtg7SSzzDHx21q9IrTFcr5DqJsjWpexhze/PfiBm2skx/4u2PEMxefPboju+3PfPCVfKhjMsorf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nm6ovzqfD/wfSZ61RyWYQRvXbPOcvzhSsEmVMgvRaaAmZlmA92KGsozX/WhZvkbhVV/p+bIBgdp7fr8wQ== 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 Wed May 10 05:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236420 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 A251BC77B7C for ; Wed, 10 May 2023 05:06:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 232DA6B0075; Wed, 10 May 2023 01:06:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BBFD6B0078; Wed, 10 May 2023 01:06:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 036296B007B; Wed, 10 May 2023 01:06:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E88B46B0075 for ; Wed, 10 May 2023 01:06:01 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B692716021C for ; Wed, 10 May 2023 05:06:01 +0000 (UTC) X-FDA: 80773158522.03.57B553C Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf13.hostedemail.com (Postfix) with ESMTP id F085B20003 for ; Wed, 10 May 2023 05:05:59 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=N0ccCCld; spf=pass (imf13.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 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=1683695160; 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=HBPftqCccRVjgaRyqTZrcCP6knrouiOwA3pnhgoiYWJsYjyoAnsLKnTMQ2Zx3z2xjd4RAw EBSF46eOPD5cP5UPHRSqTXt7NyLbQW1y7ivPAZxpI48vyT/7Yx6LQyl9BFwCWTqsIqy+yD Q4735tELrhPwhiF1JOVVagtL5EvRCSk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=N0ccCCld; spf=pass (imf13.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 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=1683695160; a=rsa-sha256; cv=none; b=dAqptEtQxdRkn179HoRMYi4dG1aWpBK/1z+cVbbPprQ9wDxG2Cm2kznYyCcQEpyr16bCV4 PHpDtFEJrkNJ38idaXgjanmwphFy6y4kOr/Q97HeIk2V0IkC7PFgyuezFq2EsZ2EUgC4bh iMQp48FPBv/BXquxx6sa4aJUhsl0r3Q= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-55a8e9e2c53so64576527b3.1 for ; Tue, 09 May 2023 22:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695159; x=1686287159; 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=N0ccCCldJapvDLseC6Ae/gJD9q2DIxAAw3KJfS7S7+Q6UO+MDy+UPXowXV56kKNmBh 3Mokmi2EfuhYkE861agEU1f2+N38vFtBHN3adZPFSiNymcRq542MbJVdXHAXiJKHJj6j PW5BTFVqGg6WFWoU7ktsXhOWcUHvRDHGQ80ER3IipejgH466kSQjsSlWFLeYSYGuMRUz 5wZRydrye3Efl1dYbQY0dngm8iOQ+1rBqJUd0qyj5Y3wp8X11XeCTxr6rq2XWmLrCq9U m9ccZupOhFtmx78yl7pPnJqam79iz8vb7MqRUPeR4jlUG408eYqlsqjsYTCBLZhrcSbS fkRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695159; x=1686287159; 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=QcfjKZrvj7lkDVVxrt0PhxmPwxFK3SFVclMIGA+gBQdy62in/yQalhshfeCoBKsaF4 C7FMIO7abbvSPrK0bDok0c6zNVz6Jv36t4O73+rjOjhmvYGO1p2ajZADS68dvQnh5Ipo 8RuXFNfz6LbZJIbbctB8lnbuGvAw7/gpjFzS5sWcKH0rsSMlL6puvCSyYqjC2QIuXiTN QEJEKyiMvtQTN8bGPRzg6W13IZ5YUVmVmuoQTKktGtRELy+wFQ3QHXvj1QerYpJwtEym iSyuTACqV+JznHkZGT6GGso1dp+CveMPR9rzFx7eGpVBUw71NoVbqyVCK+hEUqXzW/Q3 g3YQ== X-Gm-Message-State: AC+VfDyuhiIHrWq9TmYoU7nvoR+fmc9YTqDz4DLNnqpGCbDV7o3inGgz 3JLi2mSgY8LlO0blHZN8Vum3fA== X-Google-Smtp-Source: ACHHUZ4VqfeD37+8vGXb4Tz4frVt9EXwydQ25483WjEBunDFIHM7rsDjQYcLcdYu9I7uAgIFi9akfA== X-Received: by 2002:a81:4897:0:b0:55a:e0db:5604 with SMTP id v145-20020a814897000000b0055ae0db5604mr17598841ywa.26.1683695159017; Tue, 09 May 2023 22:05:59 -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 l186-20020a0dc9c3000000b0055d8768408dsm3772359ywd.105.2023.05.09.22.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:05:58 -0700 (PDT) Date: Tue, 9 May 2023 22:05:55 -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 , 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 , 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 19/23] sparc: allow pte_offset_map() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <552ae7db-9c88-6f6b-aa6-45337d64447f@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F085B20003 X-Stat-Signature: aat9z69fqnj5iaq8hnhkxqqq3knicq4c X-HE-Tag: 1683695159-686234 X-HE-Meta: U2FsdGVkX1+R2Ukt4lvfGjAsi/epYzrHvlG/u8ese55kClwTzv1mwoF12VEjEdXs8v/dwLMgUq5Ei/C2xWcGMbwRKI13aTiOv/bXw2jL5BDo7clzXkUD+z+e6/KQ+QyADhNcDs+zK8m8FcguqRDclqWnoOLi8c7jBXz3U7nL9St9A/AFJcQrxPBdKL58ZYbEJ8ILwoY/7YQiCc018qiPSqEMtNq+8OSx2OB6/3qCDgw6AGim+ihEqH/P5hwgAD+jG1IkXB+P6Pue9yJbC1pYTAz8pthcJGiwea9kHTxwvbiGUz9xokkD7OWswk436dSpqz+4HI+vB1zsjdq4Y6kU81RKZhQKTWF+eB15DFp9M3OtPso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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 Wed May 10 05:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236421 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 41B9BC7EE22 for ; Wed, 10 May 2023 05:07:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B33616B0071; Wed, 10 May 2023 01:07:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABC806B0075; Wed, 10 May 2023 01:07:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95D126B0078; Wed, 10 May 2023 01:07:18 -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 84DEB6B0071 for ; Wed, 10 May 2023 01:07:18 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4E91DA0115 for ; Wed, 10 May 2023 05:07:18 +0000 (UTC) X-FDA: 80773161756.20.E308F76 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf03.hostedemail.com (Postfix) with ESMTP id 7DE1320002 for ; Wed, 10 May 2023 05:07:16 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=S6w9KIHh; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.219.181 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=1683695236; a=rsa-sha256; cv=none; b=Uz07TjLaLu3XmdS0jghV2GyvX9b+FPKuFYqtkyNtQCv/fvod4MJmuHSyrLH9lzqv623a+M lQaEBep0+fXJEz8BHbaeb7NZuWExMMwo9nWYVeTaexozC/h9+gBN8MKgAs2WPk8a6/43Gz uiJLkc28PRus8MLq52UZl56y3hiDt8o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=S6w9KIHh; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.219.181 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=1683695236; 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=ePNQzxrltBAnExdHyv7ntusnz6ELfhNjSHNH/VjwovOO6muDneWO301egm8SFVtILlJYmj IasLeqWmtXbPpfohihsH8kCxE1YWhVHY5v1aXTaYwvkrLx1aUzk3HpupAxF/IfBsZ5tU4L c0zvuLhvpHfnJpskylq3fZIuhiiMjLY= Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-b980e16b27bso5839399276.2 for ; Tue, 09 May 2023 22:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695235; x=1686287235; 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=S6w9KIHhVJNT1kfpH+CUQlKS0lqLbNW2sjOBWirezocHkXz48EoJrIXM28PJV5vm9/ 2IKW7KEx40R4sNFdhRCA79Q4DhbKDdFLB3FgyR3tFeJ93PW/6Nj70i7kVvMQyXQV/Eg6 g+52YfmHhke7+sazfpIRwUSNXlxrgB0TXY5awNjnSJrSmQkBkwlsZpKuYTtxmU5X5rbM qMqKwQoK0rcCOG5LK7I/q4x4RfW+gqW8hxUEuUs6WrZ6huYWyzA0eBrWurtLVkyq8+rs BH6Tq3wNedbL7gmT0QCOruJR/a85R9e5ddGQi0eR0moWYsK+a+xYsl7ixIrgRtJQdod3 eejw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695235; x=1686287235; 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=PN7lBnMu2NIXNuIAO4csZKurn7hI1RdxOG2acP7lmts3lEcYhmtHpkfPR/mIoHCK8z ElgFJDhjeNGLbIUVHXrOdKZ9OrX5gD/XVQJFZGebpGo98hmkzYc1OTMCJTahFug5gZ8k Zw1ooFu/6a3kXvoYcAK/u4pEWGBTC43Kjofe55iHhlMbjbIcS5jcOjZCKj0IqxWyiey2 e5bw4Z77IhQxV1NH2Gve6JfchA8PI09e/kh8zSW9wLvvkDtSDf2+FVBIxVz3nJr1jQA/ I1cxDM/ag2F4skP8V8BqqWkX3Wr8oDdhNtqg+8uu0q0nDYy57lIS/CMTfcIqiRGYQAEZ 6G/w== X-Gm-Message-State: AC+VfDzEctRMr5ykBk/gevTc8vNtWVt9YriKmTnRyNGaFvjW1c8AC0Tm 49bJKsVP8mKABzRTFZQWh8lGeQ== X-Google-Smtp-Source: ACHHUZ7O+RQwO6EUyGZuwP0aiZ///c7pXxA4KLKL9a6yKbaYGakuuwEnBLT515Jc9UpNtzb0LrlfGg== X-Received: by 2002:a25:6c4:0:b0:ba2:6aea:2ba with SMTP id 187-20020a2506c4000000b00ba26aea02bamr10201500ybg.23.1683695235431; Tue, 09 May 2023 22:07: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 k142-20020a252494000000b00b8bcaf1e660sm3553476ybk.4.2023.05.09.22.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:07:15 -0700 (PDT) Date: Tue, 9 May 2023 22:07:11 -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 , 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 , 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 20/23] sparc: iounit and iommu use pte_offset_kernel() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <43c7b4b1-3719-93de-dc3e-33625fa2ad@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: ytoctsh87rsh7yczseu9ohea1hgqh3z3 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7DE1320002 X-HE-Tag: 1683695236-217300 X-HE-Meta: U2FsdGVkX1+y7pT5D+H03VPaLPQ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H41dEEcFQZ9TGqnoWdinXFz+ma4osP/D4+ZPZiO2DxjLpaTjJ47DasJuK0XIqLE8inwJnSUYAmqSYiOV9QR+X7cXcOjePWXeJ6gm1oYc9m1yqRlG5tx8E05/+qGsuDtEgSWOwZP7N4l/RyB55i4UIZ5QAFnmZHGPkbH5oWMfW818dl2QCzVOiSVTp9x+IprHwqkb6WNVqz519SQQ+xVrArU93V/8TAJ3LEkineyc/h6QcAHCvvkorAkN2ea47g1XA+fz06Z1W9RqQrYCO6WraTunU1FmSfGcGwoTcytKj47ET/EARfpfbKkspwHmXDaGJz+fP4Iw== 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 Wed May 10 05:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236422 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 B1A71C77B7D for ; Wed, 10 May 2023 05:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4553E6B0071; Wed, 10 May 2023 01:08:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42CE26B0072; Wed, 10 May 2023 01:08:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CE666B0074; Wed, 10 May 2023 01:08:44 -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 1E61F6B0071 for ; Wed, 10 May 2023 01:08:44 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E620AC0440 for ; Wed, 10 May 2023 05:08:43 +0000 (UTC) X-FDA: 80773165326.06.604DFFC Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf22.hostedemail.com (Postfix) with ESMTP id 1DEEFC0003 for ; Wed, 10 May 2023 05:08:41 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (imf22.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=1683695322; a=rsa-sha256; cv=none; b=8mwtA6qlgw95aOoDV0+/Dh9x8TSBPOkBryVu9/LrLYB9ZebMeN327/COwqoGc1Msv5S6RH H8quLAzODQYXRrSa46AbEIBUe65lauSZftoPhsixLU5zMKlRdc/zIN/GaFIvVf2oCJmHbF rocQ4kcvkbAS8DvNdgTwO3Lwv241kLg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (imf22.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=1683695322; 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=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=FYYzrthB4xHTWIfGRML1YM/RYGGVfMpcwMADtD7/Ec3soG+iaSzM8c1V9xE1LmoScWHl+R DKdJdcxaskHOa8CA0MoysbdFCKZPeMd5e/TP2I4+8+lwECkdMYsTa/NtSYHvcHuvUnytwc EyusMuVXzihfrQg2tb11OSUrAjU+mgY= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-b9d8730fe5aso8894671276.1 for ; Tue, 09 May 2023 22:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695321; x=1686287321; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=xhQbPYpkUzDX8XU9iKlY3Y4428jn5y6GTm9xV45/y6OmNC04/3wNqkNgSXK3AJIxCv nf/3Kcyf7jXHraRNp8V/ThTGssm80Jrj1vFIVRl/eHnHIKGHX0llNwJFmswFPBKeszPS 4ERvsVZvFaG63Gj8ZvkLnyoFsbatfd0tOGpnHcmb7QKy8F/PI1niiK9/bIJQ3clEICAC OKKiuKdx+Nga+KesCEIBcMETZuPReDAYyeYXYun87fEO018ylr/CbkSFeoHJtNA1RKEB SehH79xiSdMYH54KoBHTNvBbumLZBWgNKrjc9IJ4jvy2Xlbglq/VfxJ2yKtHyPoLu9Db naUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695321; x=1686287321; 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=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=FvanmQFRF5aYbSQKDkmrFNxV8cfi/CT87OMf2SgY9AXrobeTPAZeqyh8wP80NhB4lO AUYXeE2wAzWOxGUQGyMCGI7Y3FJlmCFwwGfor4/nJXddluCU3ch5Ip+3tccHgs44dsNB TPzQgGSs61N66C1s/Bqdo+nG22oPtwBlyiI0x6HE6WGJFG3VHh123C4DI5+9o0uW8q3e 6kNB9l8dwJO0b9u3fswdlxn2csOqlyKfVgRN4dUVuYe52vWW/7hJC/dUDiDLYSi2dMi4 LdtPu/Ch2Zqt/qesUxoHxTAJLERlqu1BFdHqGO7RMPsocmmkYFJrOk6hbOW8nazZa/o4 i0Og== X-Gm-Message-State: AC+VfDz85w0ZCvto3rZljV8a9gQ9d5KC//04zfI6dOQ6k2c8JDZG8x59 L8iLNcbWHpRYniOsKPQbtIZGKQ== X-Google-Smtp-Source: ACHHUZ4Nr7JCTjKD9JrQLs38TYvzUeemCSYHOU0HaXL9Z0TKs+cs2kkX5Dm1CGmBCetCdz6AhjKuwg== X-Received: by 2002:a25:b228:0:b0:b92:2e22:aba5 with SMTP id i40-20020a25b228000000b00b922e22aba5mr17628224ybj.11.1683695321141; Tue, 09 May 2023 22:08:41 -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 7-20020a250a07000000b00b9dcd17cc2dsm3512897ybk.46.2023.05.09.22.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:08:40 -0700 (PDT) Date: Tue, 9 May 2023 22:08:37 -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 , 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 , 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 21/23] x86: Allow get_locked_pte() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: rcdy16iwwkmqep1fxrnuygfafsya9o3e X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1DEEFC0003 X-HE-Tag: 1683695321-209004 X-HE-Meta: U2FsdGVkX180T6cPoTtxrZuk4BhdBoqT+e5d5tKrRpNkLuqwbFK/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jtssma/alUNEbjujVPZe17Xgwni+UL8iHum61hnwGgsriEhyaq5MaTKL2umT6bZd0oJxRGZhzwocwOwC6B3ztxDfzMtmOGF7HnThYsE4kciHjL+VltKlUzP4zcuBnuoGsw9Xz/jvTOD1yJi+TM5xUpIJr+tyxZCL4DGhGARu1Acc9SrUefT2C07SsPjw0XenBHqYkK+2K48Pf4boaC4sPqUefXwsvOo7C2LwBUKXCh4ApFy4SkowLYWeTuoz5elyIT+xp50oubrz3oRlsQvts8kJ8B6E+NzHjljA5rbEmSv1rt15SfuPkuohF3Dp9xp0= 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..eb844549cd83 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 (ptep) { + pte_clear(mm, va, ptep); + pte_unmap_unlock(ptep, ptl); + } } va = (unsigned long)ldt_slot_va(ldt->slot); From patchwork Wed May 10 05:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236437 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 49DFDC77B7C for ; Wed, 10 May 2023 05:09:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7BEE6B0071; Wed, 10 May 2023 01:09:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2C6F6B0072; Wed, 10 May 2023 01:09:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF48C6B0074; Wed, 10 May 2023 01:09:57 -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 B1F6E6B0071 for ; Wed, 10 May 2023 01:09:57 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 727DE1C7451 for ; Wed, 10 May 2023 05:09:57 +0000 (UTC) X-FDA: 80773168434.01.0712777 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf04.hostedemail.com (Postfix) with ESMTP id A029840007 for ; Wed, 10 May 2023 05:09:55 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=ceZayvLc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 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=1683695395; 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=aid0ThOfFnch180HtB0i1pm7fQtBwCL0l1Yp1bqyekst5GOxoEjjfwi5gPO1aN01GKSayX zb63Z7/ASrNH+AVei3oW5+0cX/GaxnxxZSba07G9oosBN0484b1cgQQQE6KGZMGwU+Us2X t5CFoBceoe8VbZJkLXEXuY/FWSiAYa8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=ceZayvLc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf04.hostedemail.com: domain of hughd@google.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683695395; a=rsa-sha256; cv=none; b=qAnsN479Is7jk2XHQhxDcfmzMG5A6BWCSGaLobdx1CDiOwr/pphv6CuatKxPWUDOgCbcNl 0etgb6APP+jS7RcFc3gotFtcky6NZbE9huKKK6IHQZvPl7bwbBsgptsCvu+V38KLnYslG+ y4ZPO3Kui513Na83na6zu6KLHSnpbyE= Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-55a76ed088aso101755677b3.2 for ; Tue, 09 May 2023 22:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695395; x=1686287395; 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=ceZayvLcQzK/jEmDGFktdiBeLmAfZAcJomtj6b8LZ7UVBhK1PGvRLGtv3raaIkoA69 8du4wIfy3LTg4noNW6T56a8rTdYN7Kpn5/bm4yjB4emMMTggN1PcgpP7ET0zc6Ogox7V PacpXMb40YNuRMAqf3IboaGbQzDmk/4AhKXM1jLiRZe7o3tGAOJ6z3OSnXWDEM8MmOjy leDcr9V/CMd1mPfM2iHPwMwcuDGyHWo5yaj5bkj6ZD28Zg+yk0+3HzvQJBuo9qxnWea2 qCcGWwBxF4a0/bB7X0FeLhxKH1U3vpEQVW9dVdnIidnAwcXxE3l++8L3bRK0NJ7IyPS8 JZIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695395; x=1686287395; 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=b+zjgwSg71r/skYDWgO+wYBlYJ7OGaKCgObddI8rMgIXQSupVbCtccmfj4X5yV4Xf/ A/QFyNnF5kkpa/y/YaTzn/7i+J8J3/3zcMg/MEtb5W0vaZVJrArjQ6HVE6vJ270uUShI MPbitIm1TlAG0uOHkE9ZPA5N4WHVF0K5h5pppOG7ZkxbSDZwxC0Ystznt+6yDfl3gfT5 8NrnZtBDjPuW/O4t9n0kck9IJSs4PwQvgpPkvH7++OlVMmTwmw33Df3zUxl8k3tn/YT2 JdrGq3AJZFo45MWNG1r3UPRpxcpqywA/9jgTZhuMpsklMXutlL7tZzdFGAMqBE4ctOoy qeMQ== X-Gm-Message-State: AC+VfDybOHegt1swnr4evySdXTwhDFtmm/SLwjuKBLk5dsd0146oClj5 H397XPVNvhzzp9jU7lAXTk4bEg== X-Google-Smtp-Source: ACHHUZ6AHFxady081B2wan1G2AdvRI+je11F7XC2fK+PaWqaZjZVH5+mul53az7NeaRbK79eLrDOFQ== X-Received: by 2002:a81:92d7:0:b0:55a:4828:182a with SMTP id j206-20020a8192d7000000b0055a4828182amr18309481ywg.36.1683695394676; Tue, 09 May 2023 22:09:54 -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 l64-20020a0dc943000000b0055aad7d3f34sm3766659ywd.142.2023.05.09.22.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:09:54 -0700 (PDT) Date: Tue, 9 May 2023 22:09:50 -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 , 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 , 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 22/23] x86: sme_populate_pgd() use pte_offset_kernel() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <6d75e7f-2266-1dda-8a70-c52c27f44da7@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: zducwwxq48a4uw75bxd4n468rh77o5kr X-Rspam-User: X-Rspamd-Queue-Id: A029840007 X-Rspamd-Server: rspam07 X-HE-Tag: 1683695395-11566 X-HE-Meta: U2FsdGVkX1/BQfzXJ/FKsye1DIiYFpjgDvHfS6NDTZnjyglJpvXOKtxRkDX0KpkuDVQHlOvNjw/cQpPk0HvHHwJE1xKnAtnC1mNk3jaqGqj/vQ6SeTQKdljLSAvhc/9hVN2S07XExg7R6HY7nITrRlJ+W22KfIbXgrPjA0wCK4Iw/TGUJaOyhb6dBwgdtZKMrfBvoprpfsHyywOudL1HKnujHS0bFTuFj0Rt3ObctoPha8UAjLDtC5zJ1vZuRS8ExIN3tp7vAwD2luvhu0JVZMf2k/X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6i5A4kCFS8NSlRun8eMei4n3VPuxZ8HL5y/otaaL7NTc/zduk0xkeT75+n3EQ9C0EsspuEIlfup4= 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 Wed May 10 05:11:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236438 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 084C7C77B7D for ; Wed, 10 May 2023 05:11:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95CDB6B0071; Wed, 10 May 2023 01:11:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90D716B0072; Wed, 10 May 2023 01:11:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AEF96B0074; Wed, 10 May 2023 01:11:10 -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 6DC8D6B0071 for ; Wed, 10 May 2023 01:11:10 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4104180173 for ; Wed, 10 May 2023 05:11:10 +0000 (UTC) X-FDA: 80773171500.09.37D664D Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by imf29.hostedemail.com (Postfix) with ESMTP id 7192A120003 for ; Wed, 10 May 2023 05:11:08 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=2vB4gHPv; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.128.170 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=1683695468; a=rsa-sha256; cv=none; b=Cvf8GO3VspCZkKYEPwZkdJFh3UH8q5uwRRM51S835IVIHAn7IPyah4c/eQFDlnNxjjaRkM Ff5kJT0fJsgXxS/q/PAzkMFZRxIJXcl+YOip3vc+ATaMiJatlT0K6DI4i2N0dOHgZn2upP Hrufx7i+WeG200uj7PDD0tfMZdf1Gx4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=2vB4gHPv; spf=pass (imf29.hostedemail.com: domain of hughd@google.com designates 209.85.128.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=1683695468; 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=5t5YV0zKgmgEyAUPKTSjojlBVWu7n9Z5EbrT7MCf/bI=; b=XOPqS32qcPwhYYcVyE8I/zC7539ePj/Mvv0QxHb9EKI/tHjAasKryKp3WGtYq5X8jNa1Bl Yqmn1IaRXkoS/q8I4f1Bm/+jW+2V11StaPf4o0rWd/ElFOeP1Cw6Wjq+datb5KzSu3CyhG mAkQvAX5wW3fU0dWHNmspB5bvwwgUlM= Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-55a5a830238so62499247b3.3 for ; Tue, 09 May 2023 22:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695467; x=1686287467; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=5t5YV0zKgmgEyAUPKTSjojlBVWu7n9Z5EbrT7MCf/bI=; b=2vB4gHPvdrYwpepEfO1nF7s17T93hgvovaDeIEtq/j7tZEKBAX6MfSFdULN3s1RrSv XbcEaHE4RfnjNOR2bGTDUPbkUVKLAEh7Z60FKXcJrN5AB5F5sDrBlIYfucGi5YFq3CRE x2J76JMa1KrQtFzkek9dhFVhgpBZ4hkaFn0t/tEhn6Lp6XTc2qq6OFMsvbIv1u0qf83/ DuPOrKKE39rYYW8ERQAhpQjY3kAUjmEo/2XpafFM5jSnKHS+15Ix6XCgfH0XnW/sjbs8 PlPBuW0lMaTsO4yfeYWj+it6wzwQ+thFBn+MFXcJGic5E+ghFwv9VEoF4ainQyun9oWL kbxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695467; x=1686287467; 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=5t5YV0zKgmgEyAUPKTSjojlBVWu7n9Z5EbrT7MCf/bI=; b=YZ0cbtVYXn9ghScLruhrwZhfj8LrxZWiolwH0jMso85D3soVopHAFC/wTMRXaoOwuQ 11nTm1dIW/f69zit7YUV96Ux2KxRXYHXMb6CWsQvbbJzbLtm7YbgimCSaD3x4Bzm1njZ JfDFwX4Van7j6Kz9PyX4w8Xb44/ivGDJleWFFF4ceChiqJiS/eaBeU5AaL99tXv7YGFZ pNUpZ+tMKhyvSJBF6XcjKrdy5iEfCuP3A76udksXSvdEp2maOdEYrsCSuWEhvmbXKbzY lUiwkgnDeC1jBrEBstPwhAh6rclaDTeUzlB4qjcuIO8Ks8ZQPiehZTEFFnlT3UT+q2Cz VfzQ== X-Gm-Message-State: AC+VfDy5WJ1a6w37DCwW6bnOnauSVdHCqVVV8MA+tq3qD3fplBOkQpSO 0HRZ9ayvqzh8rNixMp8oeQr4CQ== X-Google-Smtp-Source: ACHHUZ5S12uJTV3RgA8xdSJdxWq0jDZ0XleloV6/dK1s9NkYAdupH7Dq2nQz0anegdxAtAS1U2ZfRQ== X-Received: by 2002:a0d:d4c3:0:b0:55a:9d84:2e4e with SMTP id w186-20020a0dd4c3000000b0055a9d842e4emr17689769ywd.18.1683695467357; Tue, 09 May 2023 22:11:07 -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 l65-20020a0dfb44000000b005461671a79csm978797ywf.138.2023.05.09.22.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:11:07 -0700 (PDT) Date: Tue, 9 May 2023 22:11:03 -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 , 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 , 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 23/23] xtensa: add pte_unmap() to balance pte_offset_map() In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7192A120003 X-Stat-Signature: br9fgw45wz44rzeb3btjhf34onsfmq8s X-HE-Tag: 1683695468-348842 X-HE-Meta: U2FsdGVkX1/auX84r9m4qI8vuOcoZSoNoSeAkueL3iLOJeJPjRyXFjOGOnL3TvrqUQYgPDjHpygAkYdjL/VIseta9LzhgrXVs9CWJak2H/ABwgiecDOy3jTwFUoqs9Tzw92dvdCCejLrY9PmSlNYt2anR9N+GZTePkDmQJjikAnhft3YNH6G6l58AJt2N45Fe4o4D/qym4rNZZ/QFo/4Eu3BkVpzAUVNTr5tC/aQjl6GO99OHVpg98VO4ka49qHMekZvLaD9cPgnrLfsyZ2Zszu+Ld3jfnGF4HewDc2ZFo8/K+pvsamnJSX1IRfq/cKhGwvy65DW7ZKy6ilchaC01JCWcFPvvkag36MO4//0Om+xY+CrSqcFDzE8qkYT24jfLnlztzN6zHyM3OYgQrGlYla/eaWWSqF3kNzTpDHQ5kfE6tNpAxBzPZoQPK/9943G1kfC3z1dJr8F3+ZjbgfCGtXd48fWienvhWjBV12YhghUb91EiKNgGgj3IvyKjwd5yZxfLrM+pIijXbXRP7/odE0bwBHGGjSj3r8mEUiY7B+o3RnrUJMyp+uziCBTzStjom0fShl7vpPU7xjsxtuCEnWlXICZobVM7bXDulxvdc0B6OqAG2MW/3b2+ipZQiLpZLjmY+drCua/1lkAl9wr9gNbIteSZhHtlu1/mZmZxJj2OKEYVAMB61zsO5vlYYL2VC7yYGqVuecEJBUErsS5qadeibTvXTn7RuOU3G7ZFrAx9+siQ7niBJ/NQ9yttJb8o4zamwvZbtBASn23kfKsabCqWrWzLmrAEamtaDZRWlWNncAPGBgoXapc6SF1uqh6tLvR1z55kSHbpE6mmH32n7djUR+PyqGB0Ib+CFJ6GxQIXYEbNURWmirnDddutzwNM2CdZvsmuw3bsE1YUqxnkfVc0qhNec29BMI96e6ubdyDXFfaCb/GJvDE6sOi77EL78iUOT7BzCpTCEddmUj L9hloDUK WQd7IKoN0c79hjgyLY8W+UUGTQw+uX5kP8So55GaRrLvcqDz0aCM5RAbwotxeQ4wDRA6mExwUXtylNJ6yPRkliVR6kWertF7P0+Z0yq3+V5zIl+sRJGw8gUNg9NwzlXoLZuyi1KUKD7A/8E+IU85kjnOsl8dC5w+GJMN5efvQxAmL8V8JjLxdsyHDgXnzGwdr+wZBKsxwdGdy1Huwk5lHg+hu+zw8cE9tjqulgViVUUFbKk3pYVTHSyGvmQWm0AaxuqMY22d+S/Z+4GdDBzFRLBA3XqB9XHl7ZRh+qpiBtfgqOqeG8svnFQ6h8m0TuaVBuZuFjBvOizXk2jF+Fdarq6wXs3QlfTDfzNjk3w9shnHlcTdgsc/HfN6Cm1VWzT2rVUVziB0lpkqTxysYy4Wyx6VCtELFzkfVHYQ6Sb0Vtxw7Po9ECMD9Uo/C1A== 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 (might as well) pretend that get_pte_for_vaddr() really needed a map there, to read the pteval before "unmapping". 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 {