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: 91850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3363113vqo; Tue, 9 May 2023 21:48:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55yGAJdLZKv0Y+j4zRwA5KLGBR8iud2EyVJdSt9GHi7fN2WMZBNn0uInaJB7D81wb+6yPR X-Received: by 2002:a17:902:f693:b0:1ac:8148:8c42 with SMTP id l19-20020a170902f69300b001ac81488c42mr9797242plg.62.1683694084504; Tue, 09 May 2023 21:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694084; cv=none; d=google.com; s=arc-20160816; b=nUs/2xhOiN9re6d/x75AIp5kF9oUg9Ni/6JYhkHoV/oWa3QGsOmv4WC8iJkWaqNhtq 3f/dzuyIGheG026t/Up8py7zjS5/rKg71qxkv+Rx7YnWrCZwypsTmTefrIJgQNFNriny zcn8w7fwV6JKAeBvcElHb7toPK71XKJZf4t4cvUiwu6/ZYwj3uyT6Cpo2oBScp8yc/D6 WWsfvf5hf/0f3+6XqXmfTnxhZEEsk2FLZ2loe4gMW06m07FPOoGYWWjK606wZaKpPDzV EdXkWjhj7ymtCUJ1GUiU7VBdLoOgww7/94t4dsoBmKJc2hr5R4fK6/DA+RR6VQWqkIcB 6I1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=i9Ml3xzP5wcDVB6iPQ2d/FNYSpsMiviab/I3LSUOsaynWPdfCVUWhBwf8sYdVEiSqa ePiErXRKNXXCM4dYXEhpA7FRxObMdolKf6bqtbcmctXPGnSHY41JYr8npjNZ6i3ReqZv HFxvz3DoafMBY0ty4T/Shp0nnPAzIldtJGGEx7qpkTis8Y/6bgP5Lhg1TUShrXIK8j27 VS/cNt8op4si//H+KCWG6/etBEQzOnjXvNLPyQnFRgm1NKRzk8mx+io8vFmYQ9vLvmuM lOLRzyZvxjW/Yej74aoLoB0ngSMkLY0I5qCiDZb8uyycO49z3U5/g0ZlwdF2bq7f2jG0 BkYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ATuPznBP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902b94600b001a531f29044si2955489pls.521.2023.05.09.21.47.52; Tue, 09 May 2023 21:48:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ATuPznBP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235407AbjEJEnB (ORCPT + 99 others); Wed, 10 May 2023 00:43:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjEJEm5 (ORCPT ); Wed, 10 May 2023 00:42:57 -0400 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2A844203 for ; Tue, 9 May 2023 21:42:55 -0700 (PDT) Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-b9ddcf0afb3so8787072276.3 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=MCmlqY4JU+uKsWjLHLcVgBSfhVucDbtxKwKTgcsmz6lsFY1hnmH7CiDu/eEFhKN48e kMMwHjZTTn0zYpxipWq6r4tx+VMbvW5IgYacwgplholqQiFl3Ml+H/1rLb152AlC6M0w Qqc4ONNkLqfH2yVASCMOcJi4XUChN82N8av6FvX8Dz7izt5jN3T1KE4xOvBJvi5F74Gc VGWDDFykGBbu0Bdzi1x0lSz32pFd5MnJH9dZfWGFOYPvRJvS+Q3QRi6fSWZguPRYY9Ki j90aR+Ke7TIw1gGAHCLT4Dap4vm374C4aAEemSoHFzy5xgMZxiFXsVaWtEfcCO7fakJ6 R48g== X-Gm-Message-State: AC+VfDz0vPMgLYCC9Mvgh4Iwc4K3PkgMuk6kmH5C6UtccK1kuTuQw16+ K9Veoulw1P3pUJsGV33bQ2teOg== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481208324262979?= X-GMAIL-MSGID: =?utf-8?q?1765481208324262979?= 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: 91849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3362964vqo; Tue, 9 May 2023 21:47:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MK5Qo5G5nPY683ZXRN5dotrN8uSGCoGdUtsNC2EqI+gmF//CySXjvCp5m0on83QmaGDzp X-Received: by 2002:a17:902:cece:b0:1a6:413c:4a3e with SMTP id d14-20020a170902cece00b001a6413c4a3emr20961376plg.5.1683694056294; Tue, 09 May 2023 21:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694056; cv=none; d=google.com; s=arc-20160816; b=WaPbuAxiEbWfiaqg/PMWBXjzLP3a9hzoyLhE7L9nvvqAgtXAnrPAuhvQ1lrLsyBa7d 6gE59MyQ7mHcJoONWVIpCfE4BxS75T1DxjA1YvmDi/Zapvj6nzzQp6AyEP8aiP4i0X18 qkUtGV8h1fHtbpuKn15RTaTcu5x7hO5VzLcHFjtYaMEaXP/+LYj9f7xNDgoEh4Ln5NbQ Vb90bK6Thfw4aohAjn75gHjgT7nveLPGWBIQLFtTuVcZd7mMvdeUXAi+kEOMrgP08m3g hDw2ZOM1ayWvjHcEMra/KsXxc3AXJ4QywIRAFV3Nf5vXYF3MZa2/KeXakYkFKMy07Tet wIOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=Qgvg6hJeX3BMksFNsRntaPo5LAnqTckLGOVnbotKcuE=; b=avpl3IWIbsqwJyaRRcRXeeF3EKSTK/A2CXiKbQs34qbtShuRVtOaTsq9nEc22T8rJi kCC3NywalqkwzjAdKkQjiFYWhBfdNd8HaL+q6C9r/Q/AxhAwZSYRrt8PbIsZqWw/FVWg VJiAm6jBZ2wiMzN9rMxo+4M/3lJBygKQvhAGR/41CTdm2OanUnSuZWXp3c/5PaAIH+px vspuwiF51hJr1ChmHxw2m6xFQ4ztfpXR2yzANaktM+f08LdLVpL8ytMIt2uXQmersCCR b8vTmsotebz2R+1VkP3DeGcTyY9nnlvxDuv9s7JwECsZu9WTtbrFUxqipR8ntIsfcATN N4Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=XSdzuZPh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020a170902e54500b001a8173f468fsi3464263plf.314.2023.05.09.21.47.24; Tue, 09 May 2023 21:47:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=XSdzuZPh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234216AbjEJEoA (ORCPT + 99 others); Wed, 10 May 2023 00:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbjEJEny (ORCPT ); Wed, 10 May 2023 00:43:54 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C94BF40EB for ; Tue, 9 May 2023 21:43:51 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-55a20a56a01so120775387b3.3 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=k2VaXXj4IMX/S5r+nliEovK/Rilc1vpSqOCnTximAd+GKrb9g3hafTrfe8SN5OctMO EME/Lsa7C0WZwnxuvYsm31XpiLLaKtpcQbUXuPsAEtyQRr0g0U2pQWLL9xZmHktiH2ot AfX6TRQBpeAEb58OQIz258GOSEfvKpdZHSlUv32ePeNeD032MhzJcb7RXSkC0lPRSmqF xKLEXCai7MTLIJ3lnlRJXSyz6K17onM6juYMkNgESUEpoRsTnDJ0Wyj/PVT24aYxgwiq ikqfhyKvN//PF63Ei/m1k1s7oIcLS7MGSMwNXQOmk7h5+yWRbY43LYNDzeHU6ZvsBH24 XtGg== X-Gm-Message-State: AC+VfDxS49hCZXxKmNXwwd8xe+wVRQp9JlATNBRp+WlCR5nr42HiOKvf cWWquWY0fj8/70a0tnBmWC1EoQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481178911571086?= X-GMAIL-MSGID: =?utf-8?q?1765481178911571086?= 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: 91851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3363813vqo; Tue, 9 May 2023 21:50:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6jL3e+zTr9/68rnyWTQUf/ZogShJ+dacuMI5RCuEwNJQGPQ21otoQdtmTrAlfmU1zS5Qfj X-Received: by 2002:a17:90a:6c46:b0:234:889f:c35d with SMTP id x64-20020a17090a6c4600b00234889fc35dmr16890101pjj.3.1683694209493; Tue, 09 May 2023 21:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694209; cv=none; d=google.com; s=arc-20160816; b=Xx8VEcce3+s+aVtHkMyaphjs/50qFiAa5pCXyvrgp32eFt0Q7JM/I1cIrB1xuodHe7 Z9xCum5E409Ic09jlbcPSeQ89Jv4Q1ON5YDkd8CFAqtg12cg5q6HJ3a8URw6znzCVG0P Nmoo0K8AHi29sc+zgvane6/pb55yIKGg+/PJo2bqBbbg0OczpmqEr19V9jVgyaxZ59qa Ot3nUpgfVCUjgba6eV6oKQtIKJuKvOnoKus8j4UM1PJonlBCT4tWAandAFoGLORUUdPb HzXMCDv5w7594d9iZIV3qPdxCj8hktBlFt1vf08RrwgWYD+oIeUAW6GJCOtZPhqxLRvf X89Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=2Y3cIigX+Nl9tLTZ0FqCTIXHUTdUKJPmRsHmBn2kODQ=; b=RAatW4qqcfgfIWgpNaNnATAJyHRomZqQMTregTW/id6oqg/ycs6Pwr/JB4f6h3cvgH VIkWcHQiw83kN0iH0uZvyEIwmWWd/Z5gH+Y5JQUrQZH3ChMLagYPOGPgKbzGgHrYe6aE oDzCmTTsf2jhJwmVpV9WRecN72xfl0rwOx1NBmHGHSDr/xzz7FqYuDuRzI/7DcBOC2uJ CchCfzaA4HvqdkGtO2SU2sawSbvkcaZITOSsYURit52F87Rns98w1AW7eNFmn3ALU9/h 8BPoHr2apK72Fuumb8QfIfU1Ab/b2xIkogIbc6QkTTSka8/BrzsmlfL8kr9H0Qw969zO JnGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=X3r36dHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6301c2000000b0053048bd0669si2138537pgb.445.2023.05.09.21.49.56; Tue, 09 May 2023 21:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=X3r36dHH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbjEJEqI (ORCPT + 99 others); Wed, 10 May 2023 00:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjEJEqE (ORCPT ); Wed, 10 May 2023 00:46:04 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423724201 for ; Tue, 9 May 2023 21:46:02 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-55a5a830238so62370247b3.3 for ; Tue, 09 May 2023 21:46:02 -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=Qoq+QGHPMcB9Dh6NuQUVrGBh04sPghoH+N738Y8mHGjEqZtvvXdDXEu3lBf0t9jqD0 FQGL9ypX4n34ANaatpBdko82SFz0LAI3AUU23lFvzfX8GFDJJX5hHfDbNNytI9ACLNcv HiW7N+3dhcVppikGd36tIZjN+BzuqQpUAMyKAkpdYeHmvgNs/ffKhqThVs+2vxeZp1j8 jfqya0aHJydIqfvilz6bPFwIPBX+aTPtQrxoG4nGTwqVZzKJ1irszZXP3y+3lMWg4AK7 xzP5Vbi4GZsghQvLKIXiP/OkDoHY/fKvg0MfMquAWPwAsQqsKJ2JFa2vOdfOCMgF69DA rQtQ== X-Gm-Message-State: AC+VfDzcpY6M3Ie7h2gz/pFLSq/XPYrSqti48KTaU/Ax2nKUrTumjRkN twfdkfTAKZ/R1MPTwOq92nopag== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481339168665453?= X-GMAIL-MSGID: =?utf-8?q?1765481339168665453?= 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: 91852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3364893vqo; Tue, 9 May 2023 21:53:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cFFpwCVC3GVC3fu1DGhuOEqAj20i5zqcXtCv44dUOK6CL/cioXvHbf2xnthX0v5t921FK X-Received: by 2002:a05:6a20:1587:b0:100:af1c:f6b4 with SMTP id h7-20020a056a20158700b00100af1cf6b4mr11350051pzj.41.1683694389677; Tue, 09 May 2023 21:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694389; cv=none; d=google.com; s=arc-20160816; b=fDes8OEfx9wOYARFDQBme1yX0dnVOYw5WM2AnAIc1Pdoa3ckYTuwTlu2suSq8W+hIX O6EdDj2SxWMKF6tB4bT0nRhdJ6+6djIOkTOs6vKo5SKEOtyu9od1R0KAMbxsDZKmpr0h XVn/JkGddHPK2xh+AONnLIpNZMBvxgosTEMKAOsFjUgJbHlRyzYPxewwlPRcN5v9vwmU N+6cYOBpIcUp7C+hIpyNQfl+Q3IYCsrt385Wvhz+cpWLEiz6MHrgeV8Nh3H3Jhewq3Az rKMJFQ08t1KcrJQAuJv6mHcKCGNSanyWFZKAvLdvjsqsM4IpTsgVAwPsfZc8k0ehumYA jo/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=KfDsMIBirhBzDXZDOxHtx565XrTOoIsl53YvzvpcvBntm58IXJgtxQAV0QRMlLOBH+ RUP7eLvsHT3RjfGV9KGg4W/oNIPhf6XlSXmnPXpuRvZltONObiHY89uXe+EsdWlQDYKo cZKJdOxqCOnHCghtSH20/sJGJ/eHCdAFtDZE4r75Az+qLsWfa50gGtfDeyF9xGR+6EdR 2+AtqLHlvtSDLiNXH+J7ZuNGvBUqjFrxodFWR2+LyZBPuQMPhjGjyCD5gCIdC2kUz+gF gJ+Hp8qDk7m9Ikd9HA++ewGnauI39cofxpYqomM3/6inVUlibvFlUWmpSXsnL/+F1rKM dnkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="o+pw/Fxe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x190-20020a6386c7000000b005303a78b41asi3196573pgd.75.2023.05.09.21.52.57; Tue, 09 May 2023 21:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="o+pw/Fxe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbjEJEr1 (ORCPT + 99 others); Wed, 10 May 2023 00:47:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235093AbjEJErT (ORCPT ); Wed, 10 May 2023 00:47:19 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1F2940CE for ; Tue, 9 May 2023 21:47:16 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-b9a7e639656so10168422276.0 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=PvbMZx8fNUsbmu+m0cDLTBymGgjYjxc2Ivx4qq2JMFGbQWHsyGn4GEFajiiks0GrqZ Jzss23XmdSLSEXiU/pKCTF1De5vbo599Qxc/TOBYeBvodZn0y+XvEiV3KCGAUvnhg6Tq jNwZ/0zZlT4nj0MTNrzRGoaYPQ7ATTqXNfuf1xQzFdq7KltF+g9dwQhMCUa6yawSmzHI yNg7RuYuySeTcQJUB+HYDPWyJT+ejkWEQUV94L6qCAkLo4PukgfNVAEfYfQyffDza45k 6PGesLxF8KTVA4ncZgvAy2Rig47/6/GnzdByvgJecSI/uaIxC5oVKBm56z++FbPIF1Vp oMkw== X-Gm-Message-State: AC+VfDx3ad0d/+NeugEcERsjI64fZZ03gBq6xnGDGLxqyxcvhEwrAuml 7AUoREOoNLMfH0Ks4NLOkI2lVA== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481528019970241?= X-GMAIL-MSGID: =?utf-8?q?1765481528019970241?= 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: 91858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3367725vqo; Tue, 9 May 2023 22:01:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4eKFiuWa/NdOYjG45PNaFy8dLSFkFYHefBzCevys+ke1qHKrk7VsD5I+JMaETv2XQxJVbS X-Received: by 2002:a05:6a00:8c5:b0:647:4dee:62a4 with SMTP id s5-20020a056a0008c500b006474dee62a4mr5004095pfu.34.1683694903344; Tue, 09 May 2023 22:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694903; cv=none; d=google.com; s=arc-20160816; b=sMPL/ZexbN3+DsSO/fQFNwALS7rr3dcic9AzQvOPYVsGoxYWNjfCo88e66Hhgn0LHx 5m5hgxvmmdDvzQU/z7ZvVdNOszZkCFS/5r7MQcrv7k3vRuDP545L+SRJjXVBff8lGnnh GvsvK6MhV+L/OGZle9Hz8PFDauAYygGLFoHQmdhBFUEduZ9VludWf/IHyler5QoNtoXZ HnAfqMJf4I6ErbNYquEPDmKXI2y+TyWeefKeIumv/7OYrrR/ngNBv4VeDdA+LNjX6shW vVy5fZ20oBxAVuHTmsRJS7Na5T9G6rRhyqhChwO6CD4wQRUJIVHyq7OkwDwjdcJUUkN1 eNVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=WK0F+BrKreVsJ5WKZMSSwYtM+YC+fc99jiRjqR8qAzI=; b=1Gc32HB/CmkaA5lLqankXJRpolCltf085WqcsJe7Xb8TRYyvoxjfpN3Jut82uXs73e +3z+Z9Hfq4c+0bohXFo177qFJcZgAbNkLTaSMHjk1q6N1ixEBloFW4914Jn29o2v2KMb DQYbdjfTWfuTFyIVnq5rwzcYwVOuZhG7/U0jZ/+22C0czi2yUKpxKloOf8lPjSFg7a9S BgIZ9JtRvcrp5VrQYx/NEaPQ8rxhemVIYsm7Lmh+qUkao1YGcP2ebZ/avuMaW3Lfkg/c a5K4ti7bbm3MsdV1zmluGGJ4YH2RWlibbpDVg/U2cSkruSXnGAvOtf+Zf2yZIkBBcU0E F6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=x1Kja1XT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 72-20020a62184b000000b005a8c65d57a0si4129122pfy.257.2023.05.09.22.01.29; Tue, 09 May 2023 22:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=x1Kja1XT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjEJEs0 (ORCPT + 99 others); Wed, 10 May 2023 00:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjEJEsX (ORCPT ); Wed, 10 May 2023 00:48:23 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA1591BD1 for ; Tue, 9 May 2023 21:48:20 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-55a83e80262so100414817b3.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=dZ3YjB4Y7ora60m5RjmSR3OG2KNKHr80pmiP7x3qEMQlLnuboscKRM4xhIYrZ6LZky sDeBGjeSMl+wK3SsIbNLSfeDyO7dQysVOgx3LG0DE3Mvh9616Nmme9z+E9KgPkd/48ba Msy/2POVNzty4Z24bnlZhKvuRHXdw/Mc/apnw2xx74NyqfM8mLC+RXoKT2XSRrYo/ExH oRKDXrCtUEZPwTNqKs6Ebu30w5o2eJ+gw+SUoRVxYTGiMMGoX3k6fV9+3dItOO6YE5ha 54dB4+chFsaT8WTAKxAFYPCGettoBUsH6d/8V5QA/Dea/Z65+9UFIisHW7hy6CHhdzMS SkTg== X-Gm-Message-State: AC+VfDxYwsg8JgoL+wLXROluPvfuhFNgeCP438MZw7F47PWQzluUD93L CKk3Dvt8lHfaje5/LM4Juso/XQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482067248183763?= X-GMAIL-MSGID: =?utf-8?q?1765482067248183763?= 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: 91853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3365097vqo; Tue, 9 May 2023 21:53:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4z1q1fSvHlwHUuKywpGUEZy4P/IgBVkCSSQvaBrthYMYOmGqtBO5bzSFZ1VeAqO9tDeGw6 X-Received: by 2002:a17:903:2349:b0:1ac:a88a:70b6 with SMTP id c9-20020a170903234900b001aca88a70b6mr3782402plh.31.1683694430441; Tue, 09 May 2023 21:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694430; cv=none; d=google.com; s=arc-20160816; b=bp4hZeRWYPj7KGodtlylRpgW/DF3aN8Rxn3r8gPylhKnQREp6OuvlBJasJQDgCfCUB MxiQ8MbhTogtHRXNGAZ8WBE/kyotTM4msPKYx5gzbcRQtrqUh2L68994PZ9L9C2vwjqM l5/IpvHuPIhPPB7JpN24EEzzVSbgMaCqrTgbQxEwHkivuyQ3saskos6pVoA9aYmXk8+X vfiMpFE7nCcY1+w1g2GUxYjvYUL4tnRTnIvrg3Zxqsa6UsjDvyU/V0w1lN149gKAsDUl h71juNLlnSLkTl9IEMzcVqJjDZUmlppW9DN4uUhG+vh2nrroEOXbDB6BLQb8tt+h1RHz eRbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=gjDkagAfpEuC98uz6++cPdFvg3CZLhKw1gtvmLHCE1YxP5h9KRIHYgQU4VvAiK/XaX b36A4b6SbajltbFbsohohLsW7vu17TlVyU18keUCgbvGKSZ4mJAqdFwBqplHj8EqNIaS W9YfqzCWcmbxSfhv/iAL4n8nz+BCCuOg9ZsD9CyCGJ2kNF+d1dABPWxzDpBjGPNlahrF Dz7FuFVWEBspdbQR3zPbpJCPXpz1aR4UTxHnYSEbKlKrDGku0b3NhHiJ6N0639z9zikL +hbnjwuLi3ynUTPiQdPrkmJUR1ZfNyiuLoDnnG0+RY2xVSWM5DN8cmSZBFJzgoKUboa0 IpoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=UYgN7SHJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g67-20020a636b46000000b005030006a2desi3039935pgc.182.2023.05.09.21.53.37; Tue, 09 May 2023 21:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=UYgN7SHJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235579AbjEJEty (ORCPT + 99 others); Wed, 10 May 2023 00:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235595AbjEJEt3 (ORCPT ); Wed, 10 May 2023 00:49:29 -0400 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD0CF49D9 for ; Tue, 9 May 2023 21:49:27 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-b9a6eec8611so34126248276.0 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=Mtf6Veu4sEJz8PXvm01B0KvmL7PCzK2g55a2BO8WKbVrMuH+f1Lq2TOiBREVU9WdfH 8z52W0fpriESZyBDN5suG5Euf+F5xV+j9HMTHfEhD9ufrjuln/hUvbzeMOQXX9mi15ua g7BdWjL/45fYX5B172OUxsDMqY4U0GfLdsjHeJeenwRf6wDg1Offoi++Fas+qMMYy+MB MbS2P42gXEIq3c1vX5fTZxWnoprfsH3Sp3PUJBby56Re1XG3UdO7KiAQiAcY4VPHqlqu phxKTYfzQYD/SY4/79vUotSXkTOqnO+7S1FzxPzu1x3DqjDHJR/9dKrnFnE8DHBG2UDz 3BGQ== X-Gm-Message-State: AC+VfDzDjPV/EZhFlTlraSD15ovV/OGy0C8OwU432KbHRftNf525SWcl lN0+JbF37JVPhkOKi8kuvPY+/Q== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481570979500282?= X-GMAIL-MSGID: =?utf-8?q?1765481570979500282?= 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: 91860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3368896vqo; Tue, 9 May 2023 22:04:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vsth1DLg2SCg34gABdjM1SIM/9MQus0z5f4oaZScHWCeJIzhVvllMY+RG4I4PZmI2EVN5 X-Received: by 2002:a05:6a20:430a:b0:101:a435:a38 with SMTP id h10-20020a056a20430a00b00101a4350a38mr3105591pzk.57.1683695060463; Tue, 09 May 2023 22:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695060; cv=none; d=google.com; s=arc-20160816; b=lCk3BjTLyG4jOSSc39b8JNHXbnWfaBJqfPOK6gZpN29eIFptAb4Pwr8dQtInNeUw7a PwerP/D3cW5tpBZE4sD1k2fMxgNvsOQaPY7fQcutZXLpBi+/z5CvivLScMlqy7hBv0ui 52zQxVwZnuXC2SIjneNRTcNmnvJXJ34N3X/yU9aKEyLrxal+SHxRM9PqX+f63GQ80e/Q qiGji9h2HAcpjfNDiaBlQsTGxYpAQcAj64lC57Th3JseauI3RROMf3niVMumAju0ohqN Rwqn7I3Fu3ERFeDZ+9r8Xtg/9ycqYjUwc9ojPm5XW7iytntWxgypUPTiK+uVS4in7l4K YNpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=c45rXbKQlCN34Ggp08vYvkLlUbXjM9XMlrk4wFG1QIBMyGQu+Ry7bYQ4MseB/CfFxL O5okoWkgSzfUqPJpfszrmEOXOoCPbwZ3a1rzIpKTlF87pDAiGu5J3ZQkKruuio86VCPi JG8WOrb5RJpepyrCIOC3vl07zhcS6HQ0shp9p2jDVcSVu5g3XjxLs2qtgdqCpS8H3RH+ uYd+QmrOASJv5B1i74XkZ+Er3BXq5b/BvCH/oMaSzrDwKBwMGUGi7ym0pMPGxXWq8s5p 5uGTAvJWy3jdYaSLhIXO9EcunjJAWcyR005eLwJ7ivYsK3nLV5ExI+sPEVQQMTXnY8oD e3RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="5cXf/P6B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a638c57000000b0051b54dccffbsi3157124pgn.859.2023.05.09.22.04.07; Tue, 09 May 2023 22:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="5cXf/P6B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235531AbjEJEva (ORCPT + 99 others); Wed, 10 May 2023 00:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235642AbjEJEvY (ORCPT ); Wed, 10 May 2023 00:51:24 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C743B4486 for ; Tue, 9 May 2023 21:51:21 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-55c939fb24dso62468227b3.2 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=DetIlqQpNbVJrXksITSjiQuJNmqYUFJjfGQw+7XP6HxaMv79Ha//NRgp0vr4pPUur1 1s3KSTnBQt18V40CGG6GNMC7cQRhti+GGW2Dk4Cf6YEkCFtKp4vFUg+VQavwNiJPSpct Ru341QOqmtdl60mwYm1JgJuRSr8KBXMXFcnQJc0efq4PJxEwYJGQTGownh/Q7MveH1UV Rc0CGjG92UwPOtAnMxn04R+DxDEZlT8lOg3MutYzzVyLi/VcuPiHirmNYzwUfo6FtetG EbLh5YCt7ex15HZ2mwlFc+QdEC3U7a0OVQhmm8NO2HteCe1+HMZDwPcqZAPqDWUFEDeW pxvQ== X-Gm-Message-State: AC+VfDw3sIJSC3m4C5D6HPo7pYcvpQekAYjx+kq6FVIW3xhBcYQ5f8el kl3rblhquLmMkbqUBDG6s0XW5g== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482231581281707?= X-GMAIL-MSGID: =?utf-8?q?1765482231581281707?= 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: 91856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3366518vqo; Tue, 9 May 2023 21:58:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/3BuXqtzbHfXlyOUrHN1WGvqTVro+DEyn/I4WfBinUCJc3KpsKYdehxIEc2kZH8gnROvh X-Received: by 2002:a17:902:9049:b0:1ab:19db:f2b with SMTP id w9-20020a170902904900b001ab19db0f2bmr17881743plz.36.1683694718768; Tue, 09 May 2023 21:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694718; cv=none; d=google.com; s=arc-20160816; b=CnUl5Lml3WuEJLPFV7lCVChI0BKLqfZu4xDZL1S9iE6GRH48EPY+QrslaF0LF+oi+2 3g3QcwCaL4Vd7nqyUbNFLD06prXMs1x1+BQTlPKaqgtcqw3jfKkgIycwIEwHnsv67Hl6 sUsacB6mxsDJ36RmVnemFOu4JC7MaCH9rNvMwtsZUHIjwecTohKE7B3uv3/4QG23u9lc ldUt3WR2tLOlwokQ3vuaVOpdvg9h85aGzm0FEf8k6H47LfbOpnt+fdLcAmb1+QP8ZGrF PAlHvSoWYT2vldUs5PwcuEGcBlytSaYSAXYO9qYtMBlrFJ/oXqWYGdDht9h8o/J7sAdN sRKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=q/pWRyMl+DKjSxR+96RJZ1aR1tS5RvJyhJKXen2hGiQ=; b=GO9ZpKlJOT6iD/WlGIboS8yx+VCmEwzBdCc7ONrLRLmfx0gArGykKJPofJtdLQF8ZH 9dQ4yWuL/AfzL+reI5UB2sH2vkSdc4Cy8jvd+xxAibWP0Nss74TiO/YDLXdYDgB8bnta w8yoms//E9+bvVaY8+OqfvWqlDdzofCj+jisGCoBgT1Amgrh6m9RoFBJdoTRLx/JU/4Z ofh8UnotN71pGbwnbPyxpMObc3zQ9Y9LkEHN2yFsiLRECmTFYuoBZfRWXf+Ic7pR7Zu1 0v95F+IOPB+yebwQHZWJbFhCpib6zSHLxlgBcDYIA2lzn96d6LBI0bVZzAdX6zA9GtFM 0/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xdSNWZzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a17090276c400b001a95babe3c0si3094006plt.371.2023.05.09.21.58.26; Tue, 09 May 2023 21:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xdSNWZzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235709AbjEJEwp (ORCPT + 99 others); Wed, 10 May 2023 00:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235637AbjEJEwj (ORCPT ); Wed, 10 May 2023 00:52:39 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65C0E5C for ; Tue, 9 May 2023 21:52:36 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-559e53d1195so97963327b3.2 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=BcMZLwhdL8obvzoENaoksHnt5qTFiLmzRLLmyLqQPZY/zAO+LS9eyMkt4QYKd8zmdF owtzYZtTn2a1IPZ1dkCNySx9OTwxWeauIJyqo07wKIObu5jQUqdmiKQdKxZMyXm/JItx xErFCzYXEAKR7Qw0avJjbtomKleqsr7u6HuiaRCBXlaQgU4Vl12O1JhmbWMoMnkM1lVb TLjLquIb8aCkFlzN/sC+8y0lR1IJfGIiGmq96BxM9Vf5dVHP+SGtderpwr9VUsz6xvGL G+xUyCV1Fl2zYkBelM7WCHkQCqdTikNAt9LsnC7WolmaptQajhfeBLzB2vfrlvQ1/piB kxdQ== X-Gm-Message-State: AC+VfDyQhRghl7n8RmDGd0Hekc3zhp8Y0UYBJl2j1jY2tL2N4WakL219 TWdMT3NFugxPZPR/BYHCgNBXTQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481873591743882?= X-GMAIL-MSGID: =?utf-8?q?1765481873591743882?= 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: 91855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3366402vqo; Tue, 9 May 2023 21:58:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WkylYCV0Nakcx5aVeKZrmlO0VWjI/4mR56eBIxeN64OjZZGV0+L3N/0DmtVM0T4D75+gk X-Received: by 2002:a17:90a:ea18:b0:249:7224:41cb with SMTP id w24-20020a17090aea1800b00249722441cbmr16326468pjy.31.1683694688985; Tue, 09 May 2023 21:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683694688; cv=none; d=google.com; s=arc-20160816; b=x7dlPFrS+Se9ljBoFBUMVg8D3KtSe9j7WhuUH7V7kGDw/gtlTM+eTGk7ichRxSKbZe ywrEreAlCadp8dlTtjx8ysztYHpXSA7z45nxT0PqVsG4tqL5kD+DcV2agZVJSDtiFBpC LaaqCDMa+/bnkNnC9r5o/D6225mPpSHlX/bnYC3/oZgN3aN1l6r2UQFm99LMxAxK2YPP jcUoMQSfN7rxJEq02q2uuDIlcKZ++o58+sk/eAXomkjS/oyjI0MUGK4S3xTBsMWDUtQ6 RoT4zKX1WAgfhFdodSy44mMOVH3Ohb3R21V/58jVWWBAtBHtr1f/5/teJ/hiea0w3CBB hPyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=8E7TU+EpCMsIU6CqnZRd0vWJGC9oqEXRuUswowSWl1o=; b=nBd9yQPKXn2EsFb23YdSALwXyIkYOJd/2sRAzjufHEwHK9Vtldn0XqAgJVxn7x7Ubn Ii9sZhT7UgQBjri4geDwCOSbyLaa+wQqv4FNtI4GKxY8WusDdqS7Yd7V2C9qqLBxeHQ5 SIkK684xLu0ARk+YPdUYZWBGizEC9lMzOy1HzidWSoJ0EnWCEc23FvSp5IUTBLFzVxb1 XqNz0hNow6XGG7GJoZOstoiZn5RDA4OxIvQ9wJA9DUr8H003UT8itlJIXeVyQH2jAWW/ H6gsV/KB80uFrU8FJPowSWV9L9w8Bcg6V1iyU4yKPQxzMq1V5swPYhF4PsouSFL80tFE ApEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=nx2nVYMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a17090adb8100b0024e29c5c06dsi18949336pjv.12.2023.05.09.21.57.56; Tue, 09 May 2023 21:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=nx2nVYMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235726AbjEJEyN (ORCPT + 99 others); Wed, 10 May 2023 00:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbjEJEyH (ORCPT ); Wed, 10 May 2023 00:54:07 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3BB1BD1 for ; Tue, 9 May 2023 21:54:05 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-55a14807e4cso120989447b3.1 for ; Tue, 09 May 2023 21:54:05 -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=c6e9SaTPx6JxExVUPlh2n96WVZNLOm1PH8OS8cRLPjjneAOoi7LzzcxY5NzyMOBXYw DbBa2pJ9lLrKCodp9BgMZaS2ZpPRzT774qgJCqdq4602gQvsJjaNOeXgQmifUGgBw5F7 Eqn5jkP3pa+G95PRhAgtf56Qnx8O8IeelhiX/8N9Zgd0oBCu4E9nf2J1AQBa2v9MdcMM IOoN8MLUgmz8C8CM00tP5gMxYfCXNPqIt2ESWQM6BPMDOCThAjwfyLBuxd2AyMuG1OTj 1YmpdZfPjaQIM5vxatJNxAxXLODegIA8wgElMxoSf9pharku21SZ0zOQtkVQJz5kG2em K1LQ== X-Gm-Message-State: AC+VfDw5m8QcV/5Fn5aeYYrpqUURD4Orun/Tp6MqrfZyg2mhqaB97116 RbwbsdEOCN9+vC6BGfMvVfkdiA== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765481842074115273?= X-GMAIL-MSGID: =?utf-8?q?1765481842074115273?= 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: 91859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3368807vqo; Tue, 9 May 2023 22:04:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NMYkf1OhEKU+VHIFQGg5yqPlnORjouVWQxvcN/FSrsDFvBVtTjEkUa7Dkr2oY7gmM6AZi X-Received: by 2002:a05:6a00:88b:b0:644:18fe:91cc with SMTP id q11-20020a056a00088b00b0064418fe91ccmr16230912pfj.12.1683695049502; Tue, 09 May 2023 22:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695049; cv=none; d=google.com; s=arc-20160816; b=DF31aHWapOjH3vlaW29mtErQKOajUu5anruAXYVfGE8T0oTNjLSlAZzhWKaElY8hAb +0B+zWekKxvafB9jaVi9vXt6tCb84QdIQkVMxtyL3txA6WG1ds++xi/7GoktEL2fKiPm BsqU/KgcvIIeKLW3IqJqt02+5HCgPPoReiL/JwJBnlbsZN7EkyvU0yg/8OP2AnyJpeuC cfbqVVceEJwoEh20uILxafL504EoT3sJMzDMZuaCRmVNV5ONmYiBhyIv0eA+HTTdj7nX lNh4InlxDdQFxAwAedLUlmuTT024whnJff2jb9kuSRWvLhv+3Yr6NoxXn4YnlgnlEVs3 hlIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=R313AF+MDN3yalQF1CyQb1bjRQn4Wo4/VXd/210F8YFZ4YUqmiv8q6z9QETG/RuL6n vCoOdpzufqYpF6OfxI2OsleeegJWL1icsLeTiKRWRZ1qKGW+9xZySvACKuDZUiTGBRsl ZCFt6XkUNKVn/wrPIEJJJ2IKREDJuhiSooXJUtuMWds+XYIXSRcXkgM81kDaakteT7i2 qJK/7tij4fJONvqBhH+pndQqCyKtyf7GWs3hJeO86iegIahOFaELWduCZzKvLTCWeIzY dWMCF9zdkD6Uenq0BcrwkAoHnCZvwHrGSvSrYKWDfYfl7bLakYMGOUJhKIluH5dXiklG 3zrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=x62YCY0V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a63780b000000b0051f74e18927si3092234pgc.184.2023.05.09.22.03.53; Tue, 09 May 2023 22:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=x62YCY0V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235637AbjEJEzb (ORCPT + 99 others); Wed, 10 May 2023 00:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjEJEz1 (ORCPT ); Wed, 10 May 2023 00:55:27 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5F9F3 for ; Tue, 9 May 2023 21:55:25 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-55a20a56a01so120908297b3.3 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=QpO7f9qtqlzZ0tj1pK+ogROzfz4NJFebO0AlbefLgG8Aq8JwnESlP6Y9m+yjUpNxXx SyRlLHYjljgSL2jIFFCwcgeSl1Odt/gdHaXQyJcvT2wWA204HZte+7mzPTj2KrqVDJec 3vBtSNfwDFFJjYWwOdG2uCKZ5oFb8NaLI+sAatAJAgCCsqqmdv3kfPlPwDVBjb8CjsU8 YzdVlZr2M8sWs8JCZvwAAuTHTbTQFFFRdkLtvxjGlpoy6PMrW7kPrjRX+0e6UtrCUgep ZWQFtKZ7zNHwprKxccvB3jgMIzCPmU4EoIs4yCUACMq5IG0PpniexwX+YA0J6L7mTOwV Vw6w== X-Gm-Message-State: AC+VfDySs5f0kszscLN1M5gqd0uPfPzEEDjItof6CsLwzGwNoNgtteKk /cFgPMcBnOCAnKSe17p9tKMnUQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482220256124890?= X-GMAIL-MSGID: =?utf-8?q?1765482220256124890?= 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: 91868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3372165vqo; Tue, 9 May 2023 22:12:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zpjAukSzW9b4otHA/+rshpKMPw8fD7TQAqUXyDk55xzLcJc2Jan5mZF2IoVtMBz5A6B7I X-Received: by 2002:a17:903:2289:b0:1a6:84be:a08f with SMTP id b9-20020a170903228900b001a684bea08fmr20093754plh.64.1683695521103; Tue, 09 May 2023 22:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695521; cv=none; d=google.com; s=arc-20160816; b=Eb5BdcoODF7haaZ2O/TeQjQ7tkvbs48FQAR8igjP4QI6AGBRADWz0HFcA3+aux0ets /+QpbNsZPjxOV/FR9HLy7F+ZOCSCLqb3fFk+om7wicGxuuVnO3ZuSoxBgYCyeRiNDKLa 7alsifJYLbmWiLk5DBeHRmKZ9rK69LnCVI08RdFo+HizjDFIIq3fvvge7S/i9stakZKV rdoaQbXLt0xrRaZef6BQWroRFFS5hFTnqyUXhS99MlqVMJ4CKydFXzuXcy1teH1DX2WE UGpUPM5CABhNJXrSQ84NWN9N78V1aC7AG6OZYU16WqdOmMK6fyY+tB93vzL20/RiKVV/ IMSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=RXmNJsLxwqUxvz6EWyw44QtD375LrKHSUhjYKK5CV6XDKlJG6pSv/PL6vvcfyYE5PG X10D+owOp0dJG0qNsuA+C0s2+/ZG8nUD6FYzQWGKWMPx/VWvDjKPCaOdIKoZZE+y9415 JVp7BdZoTh5Zi7gIvQMDssOvVwS+AlyIS85oqD5qzCyV3EwpF5uhMMAYG4Aa3+syB+fi Pcf3gytm0P0gRNCOJEiV8V7ADU6kJg1Go2T3cA+xMrCsqA409qKknFeSPTcw64DLAJ1b rXzM3jFwdFTZkTyiUnDccRUD8c8MLLHnH5OsVIzAr584mqiTFvrHYHYCA32DcwxH+Vdd 1Fdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=r94LQDZt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a170902d34200b0019e6b2ed4basi3067171plk.483.2023.05.09.22.11.46; Tue, 09 May 2023 22:12:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=r94LQDZt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235524AbjEJE4y (ORCPT + 99 others); Wed, 10 May 2023 00:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbjEJE4v (ORCPT ); Wed, 10 May 2023 00:56:51 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E668B1FDA for ; Tue, 9 May 2023 21:56:48 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-559f1819c5dso101858777b3.0 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=kKWhqPxGYSluIuNLOYnY17hb6XcpQyucVLM1xw5mBKi/PUc7fsgVWuiH2xdeQ5TMSH qC1nwlfvaBJBuOIAtFcqbXATfLXrSM7Xt3xwC5U0+SJ1VIFPVsCI1yoOM1/Z7NDr0ZMW R0SL08kPC9BdaUW+rwxdsAdyyRk92bJ4NwnhHh/fObeYysbuEx7DgVpk9kCA0F9yUFIG rpbHd9tYMydemquxjF5C4Nb7rRub+PAqArMrZq7wwnrbnIbZAsd6YSHOBK+T3WsaDjOS 8o06PsVuESl6zA3RKjVueppux55SVWmBiN3cSZEsLy4KmGG73dWcdnLZztjKqDhksiJr rTEA== X-Gm-Message-State: AC+VfDxPA9Uy2UbhfkggLBJNDn3YjzYJec++1Y9VFoj/DGlNQlPky8ch 8oJv9cQvD+9qZcrj872mSb8y6w== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482714917451433?= X-GMAIL-MSGID: =?utf-8?q?1765482714917451433?= 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: 91862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3369814vqo; Tue, 9 May 2023 22:06:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6gFksVJRNr9xzXIBmDr/dLPsTYTaFjB8aLPLamjopfqYR9qst9IM0iOEa/UyCD5r0DcNL2 X-Received: by 2002:a17:902:e741:b0:1a6:77b8:23e0 with SMTP id p1-20020a170902e74100b001a677b823e0mr20631673plf.60.1683695193956; Tue, 09 May 2023 22:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695193; cv=none; d=google.com; s=arc-20160816; b=eHnIyMFloGDgHQud3i9jPFhFJM6Sc3NeZwVk2k85ZjF/K7GWNRLEEpbOkx9f/DPekr FTSWvs9ifOhdz/RBKfslI4ovwgiYL96aHReh5RsGtLgY6ieqz/++4lUp0tAuZxZfbhy3 fyc32/PYMDGjZlZj8s7D4ZUqOjsmHTA1w9hLYr469ZaA2K60Ep3yR+6sf0URH9KZVkX1 oD7S82Yo4nxiss0/zYdVF+kCNiuDWsUBPCTYkl6ZVL39p8aCkzKceKTEzp+z01aYsct1 7e9Sw3FJZ8Ibh7O/njULirOZGeOSVLKOZX/msys9hBPlqbdTtk/hXMY3yB6+zDb9zrlH n4WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=9SgMoVTm6P3R+1xCqI0Wv3sobczW81YJURPfTY0JVMk=; b=aUajSOMs0WdtYNdi/T9DwAwzB0IBLOSDPTwC1m/QcqalZAvSwol8hTfW7jCjw5KvKL m5Q9aCVj4CJqNAk1I1b8DpsclotoFnd3/+sZZ9U2reBBVZAvWg1IPGQlP8ilgl42FqPV dbyh46uOeSmkPSP6qca6sT1F4wd2qlV6mBwBdyh6AbCaFGktt9UpddJ2Ttm3lj9cmdwE DpaQrK09/t+4oRvFiPVaa6yhOTIwilGID43yA0XwdEVfKSQwhny+1XvyIqe4ourISih8 QrRWo0aouSq2P+meI/4txDWKmttDqu6N/8dm11HD8LUam5cgp8c8UDw9tCtiiFbaOV0h zTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=i6tseWUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a170902c94200b001ac9d63028esi3248847pla.575.2023.05.09.22.06.21; Tue, 09 May 2023 22:06:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=i6tseWUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235735AbjEJE5w (ORCPT + 99 others); Wed, 10 May 2023 00:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjEJE5u (ORCPT ); Wed, 10 May 2023 00:57:50 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053201FD2 for ; Tue, 9 May 2023 21:57:49 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-b9e2b65d006so10156545276.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=C6CUbNZGDweOQWAgQgYNzfdPNtSpXnW/BH5BYfWGhCJUt77Wz3D9n7fj/UjTEHrXSL sCX33PNQKAt6aYQntaQvmQhGscTiAfYMH/MQ6pYI4C9hRUYINXCZ8ar4pFkmfS6SGmiK 2JNyjC269ZG6DWKfpdugzOSjbuerJdP424P7F8T/YcjorwSNCmS0rx3AJ3qlnKI/4JNz 7XvrTgTeFTu/zkgtRbXELz0vvb2m3T2nwgfAQg88g1KKPgWsvODPvD+r8WkGsZeKaw+7 KZqVwJRnwhRluYOkjf2mlaB6EjI1S+ng0H88Eg9VVwxwCfngdlBJQkYjzXowzZ23nqcc /djQ== X-Gm-Message-State: AC+VfDzSo0WzWB9vLOm2xkI4MO6OFEmDzYTLj7kOoMTEQ25kuNPePyNY tOYhVklOWVd39bOwNMXJ4QCxKg== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482371817111024?= X-GMAIL-MSGID: =?utf-8?q?1765482371817111024?= 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: 91864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3370301vqo; Tue, 9 May 2023 22:07:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Ok28bsgolM0ymr+Jc8O3+skeHKD+ShT7tINKzSsZFkcO2qKb8Wjv3YHFRRmsi2pLt/93T X-Received: by 2002:a05:6a00:244e:b0:634:7ba3:d142 with SMTP id d14-20020a056a00244e00b006347ba3d142mr22128410pfj.10.1683695265128; Tue, 09 May 2023 22:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695265; cv=none; d=google.com; s=arc-20160816; b=sNN9pWGqde5sNaucO1kV/jqQFdJiLspsGv9NsMuDVMrFpMsgdao/hMkPKv/v8RTiZa kMDOYiiTkiLCcTh5VymUh0VQYElisqiaaHiZ/iWj3YPM5h9xh32b4EIj5CkQNH39Ku0Y u8RBcU14MLAvR1Z8OkpY2cRLANGeZ8FHSKuT6a2BVr/Q1f8BhVHUZMZLhU0Dub80Qwwv cTXeu6b1npytzXsjgVn+hdfJOtNJrLm19tLd3XDQ4mL5L6sGvPK9Byg1O4rY9gKZUioO Bf1KLBpFvBz701xpYXF9JBfZKmex+amovgW+Kdhkj0SfyfWzKaSexj8BJFn2yKkHiI0M 1Euw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=TGsYySrpxK0Q/c6xl2L5OWtip7S1bVoQQ0Qab/j6dN7X2WKapQkBJAkST+ySRltqEa S9Ac+TWVMHyGTTJpMEoF9Jv38DQtUJxF5rrYHqNqW98fxDOEyxv4QYT+HVxLB4qwNepU iNJOBf6s/2F58YOtMfQ55y8kkx7bZ5NVT8FvrZ8CtdhH3BAFC6ok5GBTgatYF+jTNBaM fnyi5dsNKgJe+jEZnqITn9/M9u2ZAELyDTWs+VNfK7lvhTwSaBkCNzS6sjYhtMwvieqY p4ss8gjk37GuW3R+2CWOqmxbc4hXu2jempxJaBEp5a1jdA6tIjrtwu8oolLj0sKV+022 VpRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=P9kK3Ha7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y187-20020a638ac4000000b005142038a8c7si3280680pgd.291.2023.05.09.22.07.32; Tue, 09 May 2023 22:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=P9kK3Ha7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235734AbjEJE7A (ORCPT + 99 others); Wed, 10 May 2023 00:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235687AbjEJE6z (ORCPT ); Wed, 10 May 2023 00:58:55 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE5F1FD2 for ; Tue, 9 May 2023 21:58:53 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-b9d881ad689so8687594276.2 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=dKagHNSJhP60IthC1u6m9rVMbdJm/H13InEaVSeH87C569jdtlhEmrCMa8Ec7umuhz yFvm7AENMNuDWNS/dTcvNc5wfNHgLrKq3EuQ/Ya0Gwk6AE4+zFPxhcHkZ7FtDruWANz/ s3i8h0OTJydCIAMzEqgv/B4jTzzHH229xrFblAcv0wISx/VcAXRcNKjxTF+KAJ5c0rMB h4E7VuSbvCgRVi2LowePPnK6OdKuKrpTVg2NpdUVZ+Evf89iGy4Nedc9DkuaufZvCwEC fg57+iDSpU9vQnP77Ajvn6RQHQrx7JfR3OT2WiZBstD4mFR3mhFDiRfEbtZSy1GITcFP 78Fg== X-Gm-Message-State: AC+VfDwX4ujmPfvFtVmKxj7Tjt7LX47UrHvRnDAbd7JyKB2Ko59R9TRm 0UNnfZILemAQ/5DD85RcIlO6lQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482446015588775?= X-GMAIL-MSGID: =?utf-8?q?1765482446015588775?= 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: 91863 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3370225vqo; Tue, 9 May 2023 22:07:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7EP/LQynBQgz4GQitBWwSBRSVkUH30pxarWm7mLbqfndg79+dj+uTa8oXG940YulkQeOSk X-Received: by 2002:a05:6a21:3a92:b0:fd:afba:9728 with SMTP id zv18-20020a056a213a9200b000fdafba9728mr16182000pzb.45.1683695255302; Tue, 09 May 2023 22:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695255; cv=none; d=google.com; s=arc-20160816; b=IinT1blB0oKNF9s+3XeQN5qyVkwiNqIdOB2dIeH7F1BYtq8u2ZmlzLFiB0Rmx/PCyi aGDT2Nyi3sWBSUxM5lYcCT+8xb36JNr4oWVjA2zfRqWwjLQCipH/GuNEjqUxGjf3VbHN 9sIB4BXGfV4p/4TJZaWv+ue6ul8W4wASeaMsRY5cMnA7KTz4ui+ZyXV4Du3TaT7OmlXI 0Q//cj48lGW0nHsUwnWGG48Gx3t3Z1ujUBtp5V1njSq401GPo6AIf83b76oLqv5z26zn LTeguA0/axTgMHQqEgwfbUnDka5um1DbOcqvRVAMGqXuCWz5jpvAZw4Jl9JBm1CxT74u xQwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=ZMaWjOOzBzTq25y2V3ItGl/gYmS8RRtg1cvEbj+mQng=; b=lPT/CDLHgBL/YV9jWKCz16W7Gl0rugc3vsLHbhCzx67CtGSftLcOFsFMlikzAUKHOD jXFkJgLlni5CvyT7AlpClSPnyvPqFaQ6uOfw3fD/1T0Oy3ZFvH0K5uAeXIP7ujzjUgXV Mq9RgVmMGpB5ekp1AU2SpQcYQ8TtHfXZMr9FZd7dXkPce8JlpvZ5G2KZAJQA+NCcE93Q gNa/a/V97nWuGTJQxoTqHlmsX9rirEAooVzka8VOdEmJhPdTLe5KehZY6NjSZqKhsBGD kHHoIfG9m+o3I5ICC7o+ZA1JC62Jf/YC2t1dkeCBVUAf2C2HuTF6xCjnsBR+ArPkrVue YsSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="v/0fedI9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a63bc11000000b00519d69a233csi3314148pge.626.2023.05.09.22.07.23; Tue, 09 May 2023 22:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="v/0fedI9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235687AbjEJFAF (ORCPT + 99 others); Wed, 10 May 2023 01:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235642AbjEJFAE (ORCPT ); Wed, 10 May 2023 01:00:04 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6118D1FE1 for ; Tue, 9 May 2023 22:00:02 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-b9246a5f3feso10165144276.1 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=OtblqB7DhEVaX4lUXMpDcPoxeikvZTvfO/wCPTsNTuQ4njwciIaZRrOUhzgGZiO5bK jKgv/iDlZBLQiSB1WdvB7WqTtpJD5XaBPN1BrgD4C33FWIf3xmDCFgG9/1KBWB2k4nZ1 IWudz1ZPcE9hqnCeT46H9e/Hpuf412Kit8ke+EOa84vg4LYM8fKewDP5Kr+jhmjmReP5 TMKWcQkdmeOME2i9w+CJt8iQGXuyDSvd+QlvEE3WKtvR3MFy/IkPGuzQriCIMaxGZXmt BCAhttgmnas9IvbdCLb1hioexyHtn0hyCcJ0TQS8rPdA3GCD9WSVkzbZtql8env+gEtC ipZw== X-Gm-Message-State: AC+VfDzFnmJRDBm2IcUr4vBXHuv2+LK0WtgnekwnmPatgo/7VbfNnAvm kK9XrO8XWbIs/0tZfgnb/XJ8gw== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482436126199408?= X-GMAIL-MSGID: =?utf-8?q?1765482436126199408?= 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: 91861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3369706vqo; Tue, 9 May 2023 22:06:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JJ5ffeNEiNc7KFKSsXXb0kAqUcX7dJOc5ETzm5qil8Tv4wu0tCOY9mmQYA2+BzNbEZGeN X-Received: by 2002:a05:6a00:21d1:b0:647:e708:a512 with SMTP id t17-20020a056a0021d100b00647e708a512mr2301099pfj.6.1683695178943; Tue, 09 May 2023 22:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695178; cv=none; d=google.com; s=arc-20160816; b=ppLFd+PngJ1vRiQ5Pm0YKJRaqSfhYOMkBiwR6agPrZNUQELMB95HBxQUgtkv9wRP4z XKV8PUAHNokXYbbWM+9GLZf5mdVPbO73luZ3sRiZjSPZPtFNnm113+6QAYHDfkI+uANy TxlMSI/+aCFBZH3Y7TWSHb1EuMTo6aw84xCZAqfDYX4ZFvKBp3brPU39ZClCKJLalaD/ Q/OhS6AsXoIsZNnr3BOGW/fO72zq0Cz9pp6uvk0tg7viSVPRFpOt4tC2bU5ibqEpfIFn vLYRP0+992oi5uwFtZ/axnkfTg6Anp5LqLe8y/SgKdToguq2pe1MsMbH7YfhB/NUBZFC 7NFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=zKr8qNXTOBqiFMX2lYugzMXp6JdOZWzUB+4SlPAtSzAkYWk/yE39EfKHY9dOapfbAj HqBwSuM48hqQdCcAM7Zrvvp+/h3DxTUsjGOQ1BzDLGYeOLLwIMynHheRcCk3Tb53GoEe pJeT6xPffIbCe6aGplOYfWtWhRz8awuif4hYQUOYRk/po6isLn7xUsQqpBXPiKCRmdwl 5+ZS16vwB0YRezfSc+0TtNqMHBbl1me/M+XPGIn5Q1khCmw3UArv+6JNYZABQAr6f5jr bXgriwGNef+qFrpwcM+tphUCxSaDTT6zXexzYI//7I/lhSChVWqhcqZtBjaXsYvCelQW Yo0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vuo7rYDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020aa79ad0000000b006435b08fee8si4016327pfp.196.2023.05.09.22.06.06; Tue, 09 May 2023 22:06:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vuo7rYDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235755AbjEJFB2 (ORCPT + 99 others); Wed, 10 May 2023 01:01:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235824AbjEJFBY (ORCPT ); Wed, 10 May 2023 01:01:24 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEA649D5 for ; Tue, 9 May 2023 22:01:21 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-55a829411b5so62527657b3.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=SzixfgxI5Ei2e/Rd9pwFlJE8tRzvP9H+O4+H1TQ+XXQw5sF7gkH5mAIzCOh+JcIEI3 hFOMXVmee07undxfk+ToANPyQMox3mYrjhH0nPJAiEw46tbxgymPnfiQ+KSppMPR6DXP OH7LZLMdlfCa6+jHRYroWB0ok/GASUn6KRIiEKPijawuJ3O7GVQmHZnmHAEnIjIrKMsu Y9MJ/fVaPcC4KothoSn4tZGh/dEox39ExJH+pCcSGP23WI7EISYN62LZIyuBp1zYRXt3 N0ifNAxUE16EI9dZ47cTx8ArWJEjZ/xFvlTfREpjrGZ25AvfTWuF0953JctDLZ4z5LU0 zsWA== X-Gm-Message-State: AC+VfDyeSNbGQrqm4ij6vdJSPlJkOjDTF2QTtjys+Zm9deMhtiicUZOY CedeOHjMH6QExXVVQD8P5MySKA== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482355833949112?= X-GMAIL-MSGID: =?utf-8?q?1765482355833949112?= 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: 91867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3372025vqo; Tue, 9 May 2023 22:11:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VFTaOVfnQpDGz07V4PUTziKAJZKbB5dapafW9x1Mpl+x+cz8t6mocA1AdFZiSvZOEXJym X-Received: by 2002:a17:902:bf47:b0:1aa:ebaa:51ce with SMTP id u7-20020a170902bf4700b001aaebaa51cemr14143076pls.14.1683695500496; Tue, 09 May 2023 22:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695500; cv=none; d=google.com; s=arc-20160816; b=Sg1vO0ElWuegM4L8kFISfwLJUupAjR2D6JR/R/RdagM3yNr9Zsm020yScn12NOE65b 2S6htkgY+YedyPqs7iN6rw5o5mIduI1nUIledFLNyH4BnfxuvCOWCqQUg3k8lInhs8qX nt/NjucsVxW/RVzZO2gwhVGYWpeO9cwb8lx1W3leuQkEKObHWscBFEZlJsgI6a7rWvsL FYlePtA/MTcA/q2R+MhZoFIIg1a8wFRhr4sdkQTsV5Nl1gAQlFCmpFVY7WezHKG83Qqq 0bcdAGufLO4ADMRwy7gt+aQnZulwtnfAvlaIvoo1am4SFHOlj0BLycTvnVpJWRzPBysf 08jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=yuPIUnxI15Nal18dmzcm2R5Hbe23rg/L/N54Quf1VSM=; b=VF1ET2KppYWAJxf0FkpWCwHXMqcNCGdPLFdDXCmzSxZsEH+fmCyY/YXlkq0tQgcE9j CJQueIGpRgYKKUXxuxGxKuSyjuM/7erNtTIj3rCaqbUcrsGlkmYlTPmRrALrfemgvqOA g9bQeXmHEILBx0EjpcYtHnsTYboT1SKElXpqSmvlD3BTuhfxphsiqWI3YT+YW0mReTEp zYiY5Avw/9hdsXS0VuA7AcdMdvalU1jYiYqVo6ROJ2RPA3weo+wGX0qcRNkWQgdz7RvP TCYiUe/c0shQ/0eDJAD0xjuxAzP8bl3c3QQcGmSyHmw4qw17eNUvCfOcbgm/sp5CJLWw xKBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=MZLldLeo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a170902f54d00b001ac698fb6acsi3552462plf.572.2023.05.09.22.11.26; Tue, 09 May 2023 22:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=MZLldLeo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235726AbjEJFCm (ORCPT + 99 others); Wed, 10 May 2023 01:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233128AbjEJFCj (ORCPT ); Wed, 10 May 2023 01:02:39 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7793410E5 for ; Tue, 9 May 2023 22:02:37 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-55c939fb24dso62526927b3.2 for ; Tue, 09 May 2023 22:02:37 -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=UwMEHonRehrrNUBBiWhDiqkCKmq/NJcI6Gpidv11Gj48PTXfHtumE6vvJPrTHd3NPp l8zc90id385t5w9FE++RT6a3vLkMQ6e6yhd+7wv2PLFpcO11ozM7yZ2NvNYtGixKB9ff IBbQq3dCFYZZ5qCWMEaCWLkkmko0MufLev2IRYtwgAZaFvrrPpHNV7fIys8iRuYNlVaK s30VRa7BDP4qYvSccuW9FosCFaDeNUynOCe6HTXz60oytBYJfrHTA7uw9wr52IvCFcXQ tDpAzdLAgWEAUS/Zg9GjTbW7giGJodML8KcRX5gFJOwpiGEtTagUhlesiGKJOeJRL/sY oh6A== X-Gm-Message-State: AC+VfDzATnRafN/rmCUvn0yVqtuj9zCQ+CI4uPfWyVnSFeNQ6v1xLi73 zdQZFUzapuHMrPNCjB0fm4a3iw== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482693247715406?= X-GMAIL-MSGID: =?utf-8?q?1765482693247715406?= 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: 91866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3371371vqo; Tue, 9 May 2023 22:10:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fPlARLKgwT0QQIgwObMVpLEWbS5dpQ993UChtcjFTui6OHIz6MYnLo1LsQ1EL+rYr78vg X-Received: by 2002:a05:6a21:32a5:b0:f2:c90a:9e0 with SMTP id yt37-20020a056a2132a500b000f2c90a09e0mr21534726pzb.3.1683695430533; Tue, 09 May 2023 22:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695430; cv=none; d=google.com; s=arc-20160816; b=jYlhW3q8uCHqX0JGXCIH04vQ1p6REmG7gL18DEyLD9CZ/idEZlUMgIagKOyMpGZ1tX jVCfW7a8cwwOjHXrD51zR9hFEht8yELagHCK/Q/jroYZUWJT1j70YVxKVhSzYnj2A9vs n4godjWLdDGmgMkq30JeijU6K8/H/YBfX0/ib08kRV7TBIO2AeeI1wml6R1BOFg49q5w pzVOAHp5NMlAPW7fYWRgx3i7PlP8iGC9NwFgiwwPNzetSIeEK/eMM0OKHGu0C12dHBjR DjLL2GfDm1oU+es/9Ap/+AtiW1TGMDwH7h1yCy3lwIrnm5fmBsSxXbDeMIWfMm60mv1Q vuHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=WguVNWbe7g+SE8eLKcilt1n/kxxL8yJPaBgUsfg3rjql1IXSR4iASel/vqqB4yT9Jq oBG/2d/h1CmxXAPFooDLot1Ug1UNOvqHOHAYk9rYtCwYZO9c/y5fPfLwClJXk5Sb7r3I 5nCi4mCr4bF4RfEJZ36um1v4wh2w6FW3J1VOXHYXDovaxBYcdtYEezvjhIWsXr0ANyKG 4AhExDCZFA61JbUh7Y0zPNaaaSTL6FRrcWcOMLpGp45TQEMRbVYGwEi4PYHuEeVMKJ0E Zt3jjGPQm58p3nTegeIpDYdwfdyoqRvU0kWMhp99KiiJffB+xLTodJhYGI+m2d/sV8yu GwRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=f+IDJIOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j190-20020a638bc7000000b00528519a4371si3216873pge.516.2023.05.09.22.10.17; Tue, 09 May 2023 22:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=f+IDJIOx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235447AbjEJFDw (ORCPT + 99 others); Wed, 10 May 2023 01:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235752AbjEJFDs (ORCPT ); Wed, 10 May 2023 01:03:48 -0400 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4CA31FE8 for ; Tue, 9 May 2023 22:03:44 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-55af4277904so104230967b3.1 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=UPVJBM+5CVO0GVJtAYca8Wzkc2jaR6WwwfjW2sZO3ZwimC6FWf27/i96/agE9x27Wz eQFswQSlC1yvVGy1A1QHGu1KlwAb+kct8Hhmv7i9MK/rYeMzCNVOmVjXiIG1y/faMwY0 NnCrNQhPPocE/XNn3uNYRABu1VQFMx2/FiNanQWylcNHmbNl/UW5qgUUEyS7/EMGmiCz w5BnixfZAsF13kn32Rlrg0UTiyktLyxV4nU1XEOcyE0RlV8f/I3iDi1SIRYsQL0PeN7/ I2ufXPwLPVycW5myUTVZuDsIc8RzaDeHI1wuNdxukSUPknwyb82yIhzQvFcWZauS0Z5P mDDQ== X-Gm-Message-State: AC+VfDzeGLNVjCErzQJeuNigbWaz0LysxuT3iTY9IzeygyDIky3EBZ6G PU1fagq7cPX82XBMzoHaRKwiIQ== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482619824692720?= X-GMAIL-MSGID: =?utf-8?q?1765482619824692720?= 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: 91873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3377399vqo; Tue, 9 May 2023 22:25:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pBvyCC/QF92y6CXlhOsE0nWZIfLviwfH8zcrfVeIBCFjThJtV4eYs+XibnvmL7beYotJs X-Received: by 2002:a17:903:1c6:b0:1ac:946e:468e with SMTP id e6-20020a17090301c600b001ac946e468emr6125016plh.57.1683696355967; Tue, 09 May 2023 22:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683696355; cv=none; d=google.com; s=arc-20160816; b=I0Mt9ox08q5fAZbeUzePtYj4gwTQQN72EUQstpV6Vaz75hkUzTVSpsrOV//eoCxKJy ZgXM+U1D7Gv23z/U3qnTH8WgfN+19+X1lbJnZcawRvHvpH4T9PIiIVxLar7jEAbW8vsY P2x/d6PNmdVp/dR1DPR2j94Hjh4V4/7pTAxa1wYWtLnW1p+tl1aVFX2IcXcNxKwz647G wZmll/5rbTTzbzozeWlJhZyv7V28pRLwi+Jlr/6cBZ8VZGqbyZlaOVul9FdBKffXWfMI Cov0M35IhfhLR6gUKsyWuG8y+1+AXFBevnpnETHYJ5Byb7+6BMhV3m0Km41C2advpI2v wtyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=QogZkSDI6C6g53/LHGmlejDM8uMe5Ulx08xAF5qndMxHab7aHH4GDk/F1YcfPyoqHC 1BYZZINgrB9hPt+cl7KpNha0m5V9aSkb81tiX7gqVUhyy+JQe6Y3nVMPTPBeb7XHfApe 0DxZTjUUxiLx6H3kM3joxIN7IQZ0MzHPras5ZF7i9Uy5lKQzhfotR16F44cuONssBOOk 8XwcpOYAu2gyfuaD5RZ47u1vmPVhcCbkCUvLSpodzT+0zX3k4RH07UYHkFLW1+UY+Ijy 8p0ALT/J/nGIO9BwxUSkI0ALRAoyntrDhenJyFPyNJda+fqz/s1hikAfUic72jJ1N46U pcnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=QuBkLiQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a170902d2d200b001a1e4051da5si3607105plc.498.2023.05.09.22.25.42; Tue, 09 May 2023 22:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=QuBkLiQN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235795AbjEJFFE (ORCPT + 99 others); Wed, 10 May 2023 01:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235820AbjEJFEx (ORCPT ); Wed, 10 May 2023 01:04:53 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCBE1BFE for ; Tue, 9 May 2023 22:04:51 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-55a214572e8so104475847b3.0 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=HdWxkAwxg8iSHFlgCU+K/MUirp/cdACELI+Nh4JcRaGhpjWUhyqs3Plwlo21h3fL4Z +VfLyccWtlRzCmmnvLmt/re4c/uJARLafp+5U1AFC2nd0/OZ5A9qIubYX6MfWXA0zhig kdM50FUIC2QTRTs1ugFGAD4sttYAMjmGUriQdE+VIp39IEiRHeSDNiVA+lE8nc3U2f2w GwBPzC69SUNB5s89AD3uNM0IGy2DcF5pRmgGw+ZYk37fmPOm5LRyxMGI8cfb6FnpT35z JItQRdld7l1vbo/kgRXwhAqau4oByEvDrupTUpRESdccLA4hu2xyu1+sFWsUosf3ocAV VqbQ== X-Gm-Message-State: AC+VfDxJXkkXWcwPeaqKnrcJSK0LluXOTDSwLS849Gn1aKT4QLeh+EkS YtAlyFWVeF0tHodK5T0q5Zelfw== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765483590474748585?= X-GMAIL-MSGID: =?utf-8?q?1765483590474748585?= 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: 91869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3373186vqo; Tue, 9 May 2023 22:14:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58jW++PsmQsZHJzhgwPvWcUr248IzmGXF5COBYE9DDFCBUrdsvSAl0JYiLwsscIQYHcOL+ X-Received: by 2002:a05:6a21:338e:b0:101:6f60:11fe with SMTP id yy14-20020a056a21338e00b001016f6011femr4987362pzb.9.1683695679918; Tue, 09 May 2023 22:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683695679; cv=none; d=google.com; s=arc-20160816; b=k27zA/6rQWleyqvFVx8D3/xFqa6qqIpbarl8K3MMbqhvjR/i6/H/+LwPPEhvZePh9P DauE5DRuQ2M1LJxyY7kgUTE8Gq9eS527rIkuOaawQMc3u+FZTloUrWwQDFVzkCYpRUVW l3+pGo9GZufFKOO1haiMVKvjYADYcKK4JgTcNZHkUsNQfGhzmter1+A9FwRHcskTgG6A jApokoSl1hnIihBNoK+tCfbwqbePOOOTjeZ/jBBOF00uOtMS/isKNdxKNjXebQOjQc9o +UksxpdT3YRH3GkuEy6DCZ78s6ixQ+XH1ojAXF5kR6rKD/wGSyA1Hq0ShLmf4kJJ7g3u XaRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=ag2EZPS30BAtGGPc2bNTfb7aZ6v6AUTVAnhZA8GoQY28pkaCt/NA9KkuxLgxQUJrsc 0DvTHu4kjOc9wHU0S1LAH2MNtA6t6MoITqVOGMIRWSchBEybXEnnQmR5dYCUOBvpamzK pIuJ4/qLBpWdPeOMIXLXX2paoZ23f0GUWHSyi+5cxJqJJabbmVGAZxebbEqTQzYz3Lz7 idLbmV72zORS7ML2Kvj6UYli6v61mpLoKs7zTKAipTIxzQbRsH+CAvX7FedLznMjxknB FhJaX8mEnqcrt3sJP33ydHrBzM4g4gRs4zceObzH6RRtNuZ83i7cdh94pz3MH61Y5RLA RTfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=N0ccCCld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j190-20020a638bc7000000b00528519a4371si3216873pge.516.2023.05.09.22.14.26; Tue, 09 May 2023 22:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=N0ccCCld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235830AbjEJFGG (ORCPT + 99 others); Wed, 10 May 2023 01:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235689AbjEJFGB (ORCPT ); Wed, 10 May 2023 01:06:01 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF061708 for ; Tue, 9 May 2023 22:05:59 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-55a1462f9f6so64598397b3.3 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=EE8528XZ2l+rxIFBWbUj9CLLoq+0pQtqwy0d9rFNS9EE0Y/T5VNQ5dX2ibzT7wxxup aazPXJVzddlgsRcNP3XSlXjQxLMxh8Bup8WrNVUK9r9gdnpcKfC98Mh4BuSbXxQ3XI0E /upf6wM2VMjm/e9pASv667QJHtvt2jJVnPmRb1KVku6CcLVtKdbw1/+SPzARaRoayyRM vcl2GSELyMYC8Ff3soRaAjddIVzTTAuNKW4ofWsNFVUAQrQNhHTbEgct7x3zaPP8Af0K CLSMtc5hlH7wPja5aISRCSPJNsr6qSldgFijFDoh+apmywWalQKj9kvgMdwu8zhxSrKa vUvA== X-Gm-Message-State: AC+VfDy12vexD80/H2VAMD7penlFGYnT1qqfZsVn1m0vIYILYu+Ztqwi HGy0lwQMunGtP9p99aoL6tF4IA== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765482880884384168?= X-GMAIL-MSGID: =?utf-8?q?1765482880884384168?= 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: 91872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3376034vqo; Tue, 9 May 2023 22:21:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/F5ueCLwkAzVfnauH/pKqAkWeCCOgziY02b9GGrr4wMKT1f8aFyZmxDhUyD8voTCty3wH X-Received: by 2002:a17:902:ce8d:b0:1aa:fc8c:8f1f with SMTP id f13-20020a170902ce8d00b001aafc8c8f1fmr20670635plg.50.1683696115749; Tue, 09 May 2023 22:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683696115; cv=none; d=google.com; s=arc-20160816; b=x2tdYAeXhIbvK9G9qy/RXuEcIJyTEclrRCi95uP7vpYy8VRSVoqGUQDLvp9T0I7S0x J7Ok24RKYG+nBCR2z5sCufDpn+6pfdZFJbTJ1MuOiuCZUXm70kRFFrkwydxpMONDLxSj f5rfvSWsAuaRP6CHpJpiNVNDx60JQtlmFKO5l5SEy9wFJIkTCgB9cbkiFCOFJDKK/C1W qnJZtuQd7ZZZt3xIQ9Vq6K85WG/EecYlBXlq0L5TyCBbVruwg66WlyvvBCB//jQntrws YXLPz/zvwMc95DNy19ySiJo4Ze4UjnXbR/xGqIr/pS7QCpU0tbvDTb1f8UMW2ex9oB+4 BjjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=dQM27eMw54oy1lwZPsSV7C6J/zGZcobIz0w3rZiAzuAolcANuAPhvaPtLG+eV0LygG 0Q+gTZDZDWSY4DQTuzKukExsT91qQD+L+UTVnwpBukWOpTN65JZw1htB9BPNHYTUzTVL lJDpC3+oKww+FmNzZOFKZ/rm9qfV/WdLsEenDSd6HMdvysgIxOwRijRlIi/Nnry/KOMI acLUss9uiIAOvTu7bJTB5BCKk/YJ1CdW62V2yJSRxqAtScRz3euwgTK7F0nlGBcjGqlt a45YKg0d9JfkQLfQ3xnyEb8iiBaIyUtEgzx1gT73wilyVn8E/qoRquJytafXxGe7srmP Bz5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S6w9KIHh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a170902684f00b001a20c983d21si3191957pln.51.2023.05.09.22.21.40; Tue, 09 May 2023 22:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S6w9KIHh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235908AbjEJFHW (ORCPT + 99 others); Wed, 10 May 2023 01:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235873AbjEJFHT (ORCPT ); Wed, 10 May 2023 01:07:19 -0400 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AA04ED3 for ; Tue, 9 May 2023 22:07:16 -0700 (PDT) Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-ba1815e12efso5848677276.3 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=HfOLBicnpfQShBNpkRrjP9b1LPXAMQhlipEuu5PFdwG7+2RS1ZR2wQOKoFMBqNDrIy Krc4LCa0kOnVMPzcJK0bdlYt7UgLoOjz0GKl4UxNzvqERTZd94VIP6qFds1RLoyqpS3l VgXRXNJhP23o5JR65UBqNCLiqkjFAgeKNGDX0Er+NsBoL7YKnNO1AYoeX929GZdgnnEJ E3BkEgltCw0y5qqE3iWmNMp+LmCADWdSsxG5Grqcqt5mWedlWP64UkXVmesVC5X4w4p8 xmhp2Oqvq3xAPblFltRrZ+rL3syewjxGSE8X3Wf5BEdMMJ8sskt55bgX35TlA1iGp9HC PUig== X-Gm-Message-State: AC+VfDxjzbb6PdigUyQvSMx0180C/QGyBFlK79VEpEArY74V8DplC2OL fctRa48u6oVTAGTOxOcz1bpwTg== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765483338742885210?= X-GMAIL-MSGID: =?utf-8?q?1765483338742885210?= 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: 91871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3375788vqo; Tue, 9 May 2023 22:21:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xAbp+MbdOoRQvlKOiJ+l3eSxPv1njPqFkVx4yuE9s0LotCjgPjRtlhdeKwLKGkIMuIJz6 X-Received: by 2002:a17:903:32cb:b0:1ac:94a9:941a with SMTP id i11-20020a17090332cb00b001ac94a9941amr6448426plr.30.1683696072024; Tue, 09 May 2023 22:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683696072; cv=none; d=google.com; s=arc-20160816; b=yZwIfX1lXw4H+XLa3ACIqe5u2Oo/Tv1hSiTNBu/micRVp7keLPZMlKpmhiFZfqs0/K 71BXf6UpNRS0pEfCq022x4fla/kPR+hLGLLAw+i6TylxY9pRBxEmqnXwsYB+kMguUGPJ cQlb5bnEevqqju1Fx8Gns0z4b0nGF/v2S5mUTycS3tBH0+Kit+cKKfmZRpQEYhJ0HJNK g27mRpgg24v3ePIeWgqIhaqBwdstmFpY6MJLpjZCLgnn9vXxDH7m8PCRm5nDB8Lz7gEI sBqz5iQi8NaE9njYr/ZToley8GYDhrubBA1zO1kgOVA/VKCU7YmvVh8L0xIz1G2Ip/kT RdXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=OwKgtfPqzzpYDuT22880lFVuFuLYHehNRIlk/RqAja+SznbJc3O4kZA/mNqxwMTYls 1BCjb73p/p7+PpScZyhB+znqg4qd2xMdRHZfn69LzFp5bEMIKUIG7CR+mbV4Gz95K090 5BAiFLceZ7M0r0Inu8S6qLosrB0E98+Cgv4AZ26LjPITnpi4yjz31TZ88kOqsBwAOk26 qBjeygdxomlaSHvxswsK1JtXIrE7bw5V+xDOROUYwFfW93rqv1zCc95FH/VBpSDBCkvo s3HGqCSd2ywfeDvZiuu4CTxTdXaTxuY8TexE6TnJou3IoEWbhNKgyoDHFf/slehDoZBv MDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a170902684f00b001a20c983d21si3191957pln.51.2023.05.09.22.20.57; Tue, 09 May 2023 22:21:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbjEJFIt (ORCPT + 99 others); Wed, 10 May 2023 01:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbjEJFIp (ORCPT ); Wed, 10 May 2023 01:08:45 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1D0525A for ; Tue, 9 May 2023 22:08:42 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-b9e66ce80acso8883689276.3 for ; Tue, 09 May 2023 22:08:42 -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=h0sQRQPAg9yBfSKRbdF7gT8nN4tjYyCDrDvLyo/4TZiIHkBkODXSV1GsIMHvFNtSey OICQN7C3ww/AX/ECvtfCR0fwyEwiUmpqyncBSLvc2jBKYgL0Hv0L60jH0uxEO3A3v8K4 yQveLCmW4wTn9rmPuBbpIO4/KFVFtwXnVxRPk2Efay2BcCx8t+GBznuKdbKj2SL9JZwP X1Lg8joWNPM2JVffnkgXAeQxX7VjwU03m+dxuniw9WXAxiNV/uoxu6BSatRlfoUjOfkS Yuhx5X6c2eiI5b5tqb3NGpD7cZpBK8gYAVQhydrPqEzP6fSy67eJiT/0+vQSNRwMPbmB v9vw== X-Gm-Message-State: AC+VfDyf75FlzpkAcWHBn+JDixMz5bfMxARMDyduQh4e0DS8e6n+Wmb/ EONC6oVOnWT6EuQ5Ywq6c5Z70Q== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765483292284724004?= X-GMAIL-MSGID: =?utf-8?q?1765483292284724004?= 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: 91877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3382282vqo; Tue, 9 May 2023 22:39:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pHwMWE4k0HVT0UWwaGtn8PjpcY1FmLQYeroe71dbP+YvzAW2bwp11wDpuIFPH0jyz5yEz X-Received: by 2002:a05:6a20:3d84:b0:ee:6dc9:e794 with SMTP id s4-20020a056a203d8400b000ee6dc9e794mr20781343pzi.56.1683697152795; Tue, 09 May 2023 22:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683697152; cv=none; d=google.com; s=arc-20160816; b=wmazsxJ7ZVHtiCqNw4YokcXo7iEleuJVkwsDSOMYiGEqb1yfPsNTM3Qw5fqfVmJPnk EM1TfAGKKl1aS4dskq+8fyIde4wQFcMI6qpwPsBw+l4xUayjDGONd6sbIqLFeMQjhKcQ FtTFQkLKobizWfS5eR2WXGjrG+VvkdW8IYnoX/ClHuuSat15NukDLvfdfA/xMLYl49tK SVf38a5xROoh+QWcYD10g89OkOcVI+Xm9UcWFxCjLTdjeFWy4iEHgOgFSsomkeS8NQJN tt24vHN3VySB2SZQCx4P4tMA1FT9FELLc5b2ePcLi+Sh17Nd0yB9pVVEPyOewzZ5EWQ2 675g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=zVzL702X99Cp/ixoxnptl/3OhBkIK3WxMpPH/uOWhCKD/5Q/S+xaq1EaD2RdZI2Hhg GszTgUaTl0PXp/NaOTm1yYfVl3BYkHwKJgiaUEkYuZMtnUT7FFEEKzOmwdjeJoyAetXj DepUbGuZXU+wQ0Jud/D32grnqokuOeIhTkeYNgEeVkn/nxvqunWhyIWR7PRXSNHw8bKn DUUIgnc71ppa4yyj4qECHvtM5CEG7rFaPaAAhCPiqeZWmtMqqVRPz7EiNyz21SPHduBd hFYyMAvGqVLKvtxYb6lWRbP4XN76WdspsyoCLfpYKzP5qW3aYW7WXszh+7PD3Qx2f287 rL1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ceZayvLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s28-20020a63525c000000b0051b28ed8df2si1003874pgl.571.2023.05.09.22.38.55; Tue, 09 May 2023 22:39:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ceZayvLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235950AbjEJFKB (ORCPT + 99 others); Wed, 10 May 2023 01:10:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235935AbjEJFJ6 (ORCPT ); Wed, 10 May 2023 01:09:58 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8944D4EE3 for ; Tue, 9 May 2023 22:09:55 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-559f1819c5dso101998077b3.0 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=TmAWhsAZPQK0rkrmverZ3Z/krFCZe+A1B7B9U5qTxy10lGSIYgQbzKCG5cAIQV/0/p +DDkcfFxOvloyJD898SSE5DH3XdCtpvrSdPUZSUSIkP62LyUtdLe1CA0qGNx8izNAPU2 uKEsta6fM71vyVxtf6BnTKa1z7zpOyZX3W48tY/OtE7RYCp7V2HAS44VsmsE0HZG8GmL 7FYMDFJC58JB9xyNzRCr/67qkQbRYIpAZMmictBVbkt/ZxMsSyWSsGEls98gTm1+kIG3 A01iHkI4oIRhXAiF7lSMp0ISQpAj0gqLBNSC28pT4zyd0pwhd605/pWmuznHEMC2HgBW I60w== X-Gm-Message-State: AC+VfDzmGpEtCMn0vU/71JwoVmlse2SzTYdxzm5nMuh9s4QzRu7/YWCE aGY+KcFi9rf/u1WjB7e2krTYvA== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765484425780542807?= X-GMAIL-MSGID: =?utf-8?q?1765484425780542807?= 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: 91870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3375753vqo; Tue, 9 May 2023 22:21:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NSiVE23zaB0N2ATs+pF9szV+z5WQYiJ0QoNSgfzScRzFShGSBNpcQG5wCPxn6ZKV85fmj X-Received: by 2002:a05:6a00:ccb:b0:63d:315f:560f with SMTP id b11-20020a056a000ccb00b0063d315f560fmr23866468pfv.13.1683696067149; Tue, 09 May 2023 22:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683696067; cv=none; d=google.com; s=arc-20160816; b=p88N0uWtbyxRHiGa2Ufh+1uk+aCK0S9tB7DeAnj65U4AoDG+c7wbUF0UVgaAbNSt6U C2wjbHLbxiBAXNW1jHfAjJpjGbPIEmjcJvugdeYYp4kh0YUtq3Jm/nA4GA8gyOEgbMq1 G3lhxc9iATUiXTkDnhUOoQWq4paSYXz2Ov7INzi/B1FO/U53gYpYhwcnuVreHnZkC80x S6uRVHTOrn2muX12fAO1J1pYe5XMQPIs/PKnrHMoriIybZdNLVm/EkQpbORJBrJPj03O bHHR97Azyf2R1MeqdwZINosQUH9QPE8IxxWURXjuUiP7PR9/FH4R0aVCSD00hOym2ytn njMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=5t5YV0zKgmgEyAUPKTSjojlBVWu7n9Z5EbrT7MCf/bI=; b=mez5OIQ3UnDpWHKQz0lYRB4/DePhxxNItN7vQjihetmXlKzgrZ2xbJv2FTvMav8Yf1 M8/D9WEoVGjqC5rDOvqGammU+Czlp2coLS8OY2Zx7A/zu4sJE058kx5gUZkaRc1sCJZN viVhwF2Rv2X/EwdiRe9U2tnbzhFX66ddNCyp+g4siH0m6vQV72WhCJiom3yMVmeEtLAC FrvDZp9G+oPrrQxhdnZtEdR6H1fZKCGv75gWWB9d+SHG/Q/QGoqriVQD5N+C61otzHzr bZtUeWscVXNIS2noXJtwKaxM6t7Fbdvq4d09y79awhhpbCddSRElmkGM1BCbsNA0ialb 6ToQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2vB4gHPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63a74c000000b00524d543a9d5si3008635pgo.689.2023.05.09.22.20.28; Tue, 09 May 2023 22:21:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2vB4gHPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235571AbjEJFLP (ORCPT + 99 others); Wed, 10 May 2023 01:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbjEJFLK (ORCPT ); Wed, 10 May 2023 01:11:10 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48DB15253 for ; Tue, 9 May 2023 22:11:08 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-55a8019379fso62739087b3.0 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=kZ8m3jIGk6dGM3COyKIxxchL0RbrsLDmtKvP4hPbq29vbTABivPzZB2V4MBzx03wf8 SpGY2eOtxAgWp0XcQHUSiJB7L1v+OTvOSnrpC5T6op9cO4TczYCmH/VUcW60LsYAjzCU CNNsBcJzprgycGb329NuwZO+/6KBqzjT3Pg1wuUUBGppzHPvYBLjff3VkHcHeV44UpxV qpKJwydA6XjUbGXuMbtdMWixHTLlWDGSFWsQfA4qS8zKPVzufMKQHASbY8+GMo4YL+pU G47P5/5znxDMSe8lAJ2ays4nohVu3WNpKey/TuSYoNaVVFAutLRAXTQHZ++E4oF3knay 8GhA== X-Gm-Message-State: AC+VfDzVr7Zj6fWNccB80IrcLoJT8B+pwmJGHIbY/6fB7LGKKFDqGrMF oZm47OdoI2n3773lAZ2eVbLS4g== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765483287359267235?= X-GMAIL-MSGID: =?utf-8?q?1765483287359267235?= 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 {