From patchwork Thu Jun 8 19:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp492852vqr; Thu, 8 Jun 2023 12:22:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6q914jxs3bDwNFOtB30sC8inVPvBEWxZwJOUP23fXXXl0bHdmBShFtQ7YhFwqdR/NML0Vp X-Received: by 2002:a05:6a00:180c:b0:65b:bb3b:3c02 with SMTP id y12-20020a056a00180c00b0065bbb3b3c02mr8016698pfa.29.1686252125543; Thu, 08 Jun 2023 12:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252125; cv=none; d=google.com; s=arc-20160816; b=pDFwG/5UAbRA9NHtNz8D9r/xPHLV/kElThpVWuS7Ao7wkj9wLCKJOIMNCzHh/SBnwH KfIQDN7IKfgmNgSkJlLM0sI0vdy7whrz+V39XWEgZ3/BCqcbKL3+vfWtKElNnpR/4zhn f7XL0nAqVIOLgzy+4sLi0SdKMiz7Pdt3ZcNwkrGU/7lWfrgjNQHhft6teLJj3shn23iE QjU6O2gu+UtI8HwDNSNaTBxQVBZE6osUX9l8pF4bdlDGKD5phLYn3rEjm+dL9u6EN1Ac oaoXrS52yxTPD2QREMNKeeUxf1c5C+z7EPo40WateDtnm/L5VhP4gc3jBotXaeI8sGOF xoGg== 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=GTXCFZCdRGCamQRa0Qrn1AbTd72ZttiVdQcumGk4/qJzG4/V1f0N5zHd/RQu4Rwws7 ymjJTbvcb6BeppveDqQa3CutABl6VTjueM19r6nOwQ4ucPNvCKbmI1GuP6xUAhuDJoUg M9xWU4X5x3zB6gLhqJAPPigWmgIuAkWh+2kw3a2EathY0D7mQBJouBFF9KsILA7JY+lb YDdYYerPTVMfdYsS+8R4uI9E/hF05tWIhaE+UktiEFfJAju5hZmPxpzGf7X3K0F444O4 W/lBYYGwKwEc/kSovLAMLWZtZXr3NzD5v0QQ16zG1iWStRT0XYWVh5877GvweFz+H2fY YGAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=zI2n2c7O; 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 i69-20020a638748000000b0053f1387ecfcsi1384661pge.356.2023.06.08.12.21.52; Thu, 08 Jun 2023 12:22:05 -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=zI2n2c7O; 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 S232938AbjFHTLM (ORCPT + 99 others); Thu, 8 Jun 2023 15:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235582AbjFHTLK (ORCPT ); Thu, 8 Jun 2023 15:11:10 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D65912D7F for ; Thu, 8 Jun 2023 12:11:03 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-558a79941c6so633487eaf.3 for ; Thu, 08 Jun 2023 12:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251462; x=1688843462; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=zI2n2c7OkddkeoVughk/breFog0Z+EugvTVCVE29AxlIwAuw/EXjuVVrGwHMRC2bhf x0zQuSLbArDGG85kKSwsyOqR0pmFFom/E7xSbaqroxyuObbaGosDK+M/+SoF1AtELCEy bwiSK0YoqwXYs8RFX4mr6F5bpRQfVt01fhKCwqENzESWm7Dhrz7vfiQry977lpQgtzrZ wnC//NTYAzqdTpQsJYqSSYM/JJ1rR9aCAEjxg8RoVlpIwLkFMrqySi29YtVXSpE8PojR NAOs9BLAS5JJ+VzpPEvMOGrhcKbJ9tQKHA0AjGKdBMYv+rB/+u255TZMPygFcoEpIAK5 9xvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251462; x=1688843462; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1YvWeTkG3kfP7WDkFLxY3Kk7w85fUEyISH4lFagFGGw=; b=KPuW+BrmIYG1FSAZ+Pt0dKYZZ9nK8q9Jn+1sZkuW170VMsv5xsixou62ms6UNpYoMf jm1kVRQQpwie5ldpy+P2DkX8SZWRFk7IHSevD/nwoo6XzzX+B/2eXt87Mha/qX12AXzQ b0TBQiZ9rSqQ35WdOcLIZqHwOwEZVmi02dfyCOenY3GhHCJKe1OKDq3TYxoD0MPO9iVB 9hmntQ36cWGbRkSM4PyvHoPknyjgOK3AZCQrTyxIfVJJV2Ed9yJZA2aY9ZUgFjz73dfV TB8lkKJ/yRaWD9yaObDs+I0Zhw7NRPGMNPYW0jrofvETBu+b8skcKVKWI7zPVTi0EAZz E1uA== X-Gm-Message-State: AC+VfDxVf1jfmSwm4WSXOPHxXtl7BtL0B3eZihcOEL7tcyfEMcchAH9e 7qlJ8vulq5USVmV32AkfveI0LQ== X-Received: by 2002:a05:6359:38f:b0:128:7ef8:805f with SMTP id eg15-20020a056359038f00b001287ef8805fmr5080226rwb.6.1686251462249; Thu, 08 Jun 2023 12:11:02 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a17-20020a81bb51000000b00545a08184fdsm87881ywl.141.2023.06.08.12.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:11:01 -0700 (PDT) Date: Thu, 8 Jun 2023 12:10:57 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 01/23] arm: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <813429a1-204a-1844-eeae-7fd72826c28@google.com> References: MIME-Version: 1.0 X-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?1768163508697173826?= X-GMAIL-MSGID: =?utf-8?q?1768163508697173826?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/arm/lib/uaccess_with_memcpy.c | 3 +++ arch/arm/mm/fault-armv.c | 5 ++++- arch/arm/mm/fault.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c index e4c2677cc1e9..2f6163f05e93 100644 --- a/arch/arm/lib/uaccess_with_memcpy.c +++ b/arch/arm/lib/uaccess_with_memcpy.c @@ -74,6 +74,9 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp) return 0; pte = pte_offset_map_lock(current->mm, pmd, addr, &ptl); + if (unlikely(!pte)) + return 0; + if (unlikely(!pte_present(*pte) || !pte_young(*pte) || !pte_write(*pte) || !pte_dirty(*pte))) { pte_unmap_unlock(pte, ptl); diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c index 0e49154454a6..ca5302b0b7ee 100644 --- a/arch/arm/mm/fault-armv.c +++ b/arch/arm/mm/fault-armv.c @@ -117,8 +117,11 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address, * must use the nested version. This also means we need to * open-code the spin-locking. */ - ptl = pte_lockptr(vma->vm_mm, pmd); pte = pte_offset_map(pmd, address); + if (!pte) + return 0; + + ptl = pte_lockptr(vma->vm_mm, pmd); do_pte_lock(ptl); ret = do_adjust_pte(vma, address, pfn, pte); diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 2418f1efabd8..83598649a094 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -85,6 +85,9 @@ void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr) break; pte = pte_offset_map(pmd, addr); + if (!pte) + break; + pr_cont(", *pte=%08llx", (long long)pte_val(*pte)); #ifndef CONFIG_ARM_LPAE pr_cont(", *ppte=%08llx", From patchwork Thu Jun 8 19:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp494908vqr; Thu, 8 Jun 2023 12:26:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73mmH56xBiqQ2pp7OWxqQbmtLS09lbFVLlfaGVJoWn9PZ8r9ihksT9n/IDxnMssGXJLzP+ X-Received: by 2002:a05:6a20:7346:b0:10b:aeff:aa00 with SMTP id v6-20020a056a20734600b0010baeffaa00mr3347519pzc.28.1686252387427; Thu, 08 Jun 2023 12:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252387; cv=none; d=google.com; s=arc-20160816; b=tQ8ANeifUgNuCiD71UkDYtb52fXk1cqeVInCtwSg4hHpi9voKke+ygJybOwzkxjSiO M16ZLT7DZpJWCsPbVkQq82qkgkosn8xC/4lFAn2tSTIFjjKNnw5JRipFO70/spvetPF3 5tTVK+XyEfGV2w1Ijm69ZHJmdOTYpMmCF5dtlHUYheryEjiMohCDACO7aDkhObHY/ZLe TDxB8P3FBKUjRVPa1qhBPKYufgv8mnu9Hbel5uf1Nwb2Ms7o9F7UuG+Co7PHnvP+DcwM 0mcNxhEzZdNoVKujgEOeOWOu1zHXCLDH4adkMZMeKHA83jl6gUo0CU8iyS4gRGRw0PJa 4+rw== 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=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=GEIdR4gHdsTD4arf0X9V3W5e/nqB72LjOhEcZbMp6h3CZ84RvFgYjwkGm8UYpjVZ2R X8FoWaHmX9iJo28rfRXtP9njSTfW2GF0QQOyRfaFFktKrVHYbi8LFQ62bv1ucajBl6ua stu0vzKOiyW6EerEDnpJDazVN8c8Wv2vZaWRtyxE0QTFvtBDBxw/zDiuUto/IaGdIbZL mbsLmRi5Tiiw4iwEkSe0koAzvlhTPRPfqShk2gmg2DiuclWUvDYFf7chpX7DzOybxi+I e8ODyh/R8ek2NVv5xT8RM3PVbwdkay9GBuu9uFOlhPeBYVS28P/q4n1ogRZ0VzLzG0PQ Q0AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=1l3g323z; 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 v135-20020a63618d000000b0053ef5472637si1411524pgb.150.2023.06.08.12.26.15; Thu, 08 Jun 2023 12:26:27 -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=1l3g323z; 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 S236100AbjFHTMS (ORCPT + 99 others); Thu, 8 Jun 2023 15:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235928AbjFHTML (ORCPT ); Thu, 8 Jun 2023 15:12:11 -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 3572F2D7C for ; Thu, 8 Jun 2023 12:12:05 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-565de553de1so14703657b3.0 for ; Thu, 08 Jun 2023 12:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251524; x=1688843524; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=1l3g323zHExDgYGww0zFXmVgic3jDwyc0JAOaU14MB4NUoruSezWtFEVocvA8VR+wP D+bOPBhVpeN5TR7Q94HiD/7UXFwgvkn75HwqVtdM3hi/WhalPJUwiHRXSp3bpeKIuRdm orIqBvL0rae06pUEOxuRX8a0MpgqpKjI5TTzLJ98WQmBBEIDz4RhToD7qotfuISdygmL gKqyyQ61v8JQcZhpfriPzCyTWiXBbfQnLuFCKxtspZkjhV60I7fgSoyr0iHs2+KGMqLW csaRWwWg7YMEgY5GV8POPk7y+6y3olAQXOM6liWFfJYYRJ0sFo+4jM2u98tnCjYnFP0Y 93kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251524; x=1688843524; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zVLRceEeXaiGvlgxdYbIgAo+AcDyW1dS+jDGBb+h1UA=; b=KDqAl8fhTocZHQ7v36L0meK+90AQBiFK3i5OBsuYNl/EGTu03L2VpilEmSZkXD6/9v nSVG9KHOjHobW2wdpSrYpEtsN2wu85kMDt0LDQLYepYF2mxbDaqRGKPt1wDOQi2mKLJ9 qlIXQmZrqYFfs85HN7zskIpt7//OqQuDHYcoshxwWqQiG33gidauETAhDnWW+1L8rAlJ Wbnme/Zj8a4mm9fAoHYUIedjvsWChsmrrgLnNbpIv6K9/x+qRD+jzT5vxHos7QvLGQKw nSKhW10M4O3W5paTCpIMPFkvb2SXm7o2IPLrSrLXpZOtvj2XLGlu5UrKd5YDDJCO1mRd hVfQ== X-Gm-Message-State: AC+VfDz0668+H7YCE4Q9uBScD0PwfP8EBxpM77j/NAv6vhhl82FGeYSa dUTyNi6OH14GJ9wHdS81mIGBlQ== X-Received: by 2002:a0d:ead2:0:b0:569:ec03:14eb with SMTP id t201-20020a0dead2000000b00569ec0314ebmr668029ywe.23.1686251523870; Thu, 08 Jun 2023 12:12:03 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d144-20020a814f96000000b00559f1cb8444sm106718ywb.70.2023.06.08.12.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:12:03 -0700 (PDT) Date: Thu, 8 Jun 2023 12:11:59 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 02/23] arm64: allow pte_offset_map() to fail In-Reply-To: Message-ID: <35e46485-8499-4337-c51f-b8fa495a1a93@google.com> References: MIME-Version: 1.0 X-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?1768163783521106466?= X-GMAIL-MSGID: =?utf-8?q?1768163783521106466?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins Acked-by: Catalin Marinas --- arch/arm64/mm/fault.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index cb21ccd7940d..f3aaba853547 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -177,6 +177,9 @@ static void show_pte(unsigned long addr) break; ptep = pte_offset_map(pmdp, addr); + if (!ptep) + break; + pte = READ_ONCE(*ptep); pr_cont(", pte=%016llx", pte_val(pte)); pte_unmap(ptep); From patchwork Thu Jun 8 19:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp494935vqr; Thu, 8 Jun 2023 12:26:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sXOmY+jaboliHW7MvIH0IFcqYfUaeDIBqFURbLWLVNw86yHHPpqqZH3HyxlJbWzN3q8As X-Received: by 2002:a05:6a20:3d27:b0:115:e834:7bc1 with SMTP id y39-20020a056a203d2700b00115e8347bc1mr4996543pzi.30.1686252391067; Thu, 08 Jun 2023 12:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252391; cv=none; d=google.com; s=arc-20160816; b=ceO/N5qld/fWEosfBw6V/mw+SA4LToPqCNSA18VfSV9Hdj5nZnwyZ1UoEKG3iNgxd4 TDpb5I2NxbYalTKRRHukD1z/2ozuTOd2EV+XvB+cC2cduuGegDpwI2eVN88Q95rugP3u eElBI5Wvs2UUAZCgXudI5+KbwicXNTpjBd6OyjCGFWOsx/0gCdFhy1hwDc86Sy0mZSbo xViaTvVEXJvllm0Da8XpNUDjEpRB/NLqF0BtUgo3M4iCv9Yv+F62EExv5kUG49/XcxRh MbtMur858wE0TUMvVod0PillDVAyhcrU+G1utiwvJi4466LBYaqrng06SgNSm12AQSkz nXwQ== 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=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=v3x9xGr5RsDDApi4AYxLVGKxYUHN4YvxJqcp47BBdl++RveIbvwJA53Qk9bnfqoVFg ZOSOC5RxpSBJ/oftPiYhZFlu1EMlnIXJqvpfyc60FW/CrZWYY6OkYk7NN0hGSM//BUZQ 1dg76YoOPtR3PTgBpfiBHQKvQjEVpKosw5HoN0iuo5ZyuG8CidNUuw7KxddfSGP22W4w YtjilbY/Atev3fYBHLyQgPdAc2e1hAKsLjmftaQcjhCxw3j0wvJ9OXHgIserv8N0MVWX 6zHQdPNKusOMeEONGSh5NbOQ3dOQ/qzZpXXux/PxtFxUkYsv1/7HWMwKXtcBH9jb0yGC 7FvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dJgo7fXP; 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 s15-20020a63af4f000000b0053febd41e7esi1447025pgo.380.2023.06.08.12.26.18; Thu, 08 Jun 2023 12:26:31 -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=dJgo7fXP; 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 S236932AbjFHTOu (ORCPT + 99 others); Thu, 8 Jun 2023 15:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236494AbjFHTOd (ORCPT ); Thu, 8 Jun 2023 15:14:33 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A437A2D52 for ; Thu, 8 Jun 2023 12:13:34 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6b2b7ca1c5eso46261a34.0 for ; Thu, 08 Jun 2023 12:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251598; x=1688843598; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=dJgo7fXPVEPfP5aOx2rlF6fhL0MOp6kKeclo0mcv4zTOiWrzHWntcp0lBZsfoj54Se XolJoU7BuSvwRUfmeldzR5qRMBOJZmJVG9boQPdpvF4oDnjII17h4IF7WTHJDAtPgKTK wCc48eCwjyNX1CCKOKbCJn6rCHbIrfq0gOAhHT/Cld5PzM9jgz6HhRaRcDPho1O+ftQz NYl5ZbGuf+ZDQqB6/nkOeRBoiE7Z3JRWHBfKCJGlqU4xYE9mQ0/j0JkL0Hi8bff5nmw2 hyNF+dGcaX/VDgXb0gWmoFHLFIjjowl5ieph5brNA6Ro0AVROhwI1SIjSa8mT9DDlpOJ kD5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251598; x=1688843598; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H3hlbyYK7pDzwaZxcFIBlWQ9GVphTFdOhlIQXeLYhe0=; b=JmE9xY0r5H0JxWtMS/eCjDLMZCgm6VS+s4MiFrCdogzocOYYK6h6YwpYkv/uK9KGI6 oPYU7o/cvfnTFLwaV4XIvtC8t61RzS1smMdZvgfz1nvUYKI3/2h1ReOr8d4XWEnhl8OU vHM0NtanaLNgsVcv2hLsDXH97+Vq9FphdvpwONO53AMLdCDEb1kh8KMkC7DhT0qJamR/ 2TqFVxDF4FXiDIuUvtDFpO69k3aZB+JxZRTO2/1phF/+KpXeNtGrhugQWSnI+wu9q7Kx NYfc0HMP2IgQ/nv0UYOR8R10p7GKMev2dTiIeMz/ihRK223vunx7J7j+zHFNWPoQzO7S Ceqg== X-Gm-Message-State: AC+VfDyTc7YQdQcp/D/agdzdQ2QE5kHPiM3KR/0ueenWBQ8H+KtzkbcG /j1gluuQDyop0pCsMcTpZngKdw== X-Received: by 2002:a9d:7849:0:b0:6b2:a879:406a with SMTP id c9-20020a9d7849000000b006b2a879406amr5080795otm.18.1686251597829; Thu, 08 Jun 2023 12:13:17 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d188-20020a2568c5000000b00b9def138173sm449426ybc.1.2023.06.08.12.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:13:17 -0700 (PDT) Date: Thu, 8 Jun 2023 12:13:13 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 03/23] arm64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <5849464-7191-40c5-c55f-fba9c3802e5d@google.com> References: MIME-Version: 1.0 X-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?1768163787276492081?= X-GMAIL-MSGID: =?utf-8?q?1768163787276492081?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins Acked-by: Catalin Marinas --- arch/arm64/mm/hugetlbpage.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 95364e8bdc19..21716c940682 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -307,14 +307,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; WARN_ON(addr & (sz - 1)); - /* - * Note that if this code were ever ported to the - * 32-bit arm platform then it will cause trouble in - * the case where CONFIG_HIGHPTE is set, since there - * will be no pte_unmap() to correspond with this - * pte_alloc_map(). - */ - ptep = pte_alloc_map(mm, pmdp, addr); + ptep = pte_alloc_huge(mm, pmdp, addr); } else if (sz == PMD_SIZE) { if (want_pmd_share(vma, addr) && pud_none(READ_ONCE(*pudp))) ptep = huge_pmd_share(mm, vma, addr, pudp); @@ -366,7 +359,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return (pte_t *)pmdp; if (sz == CONT_PTE_SIZE) - return pte_offset_kernel(pmdp, (addr & CONT_PTE_MASK)); + return pte_offset_huge(pmdp, (addr & CONT_PTE_MASK)); return NULL; } From patchwork Thu Jun 8 19:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp494040vqr; Thu, 8 Jun 2023 12:24:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58859BfIZGFhRGwWKQVnvphEtYuYPVd1KYewjMOeDhidKQ9sKpY3FXKvbkgKvHWaJDLGrU X-Received: by 2002:a17:902:b701:b0:1b0:499f:7a8d with SMTP id d1-20020a170902b70100b001b0499f7a8dmr4749697pls.9.1686252278345; Thu, 08 Jun 2023 12:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252278; cv=none; d=google.com; s=arc-20160816; b=vexBGxWvKMOaIYYC3qze4qm4r7y0kAXkQwQEL3fKKDUXT64NGsvedhzkhwOsGchPze 3BOe5G2xnlnTFhzrNbMuWGYI/IIo0IH/ZS2+8XeH82leEH8YGJ62Ipwsixa7g/yHm6a5 vwn5CJ/qVOylsQqYIWjCZ2LZq5+5H58FhqFOHIe1sLNm2Ye4C1loJ2E0Lq9+NXreCUDb Gn5N2lFkqzJKg8PoNIYoLOvi0iQFQjqZMvYEAiVRG834RFqB9ToAljPBTEXriARYftUx NJahZp7ruHdd3amEqv2MaUYuIakCy8Z3/LJQB0fJaTGbGmkRLTGrtcNIcpakw39uiUFL hwOA== 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=B4FIkrG2Fazd98TajOhy2CBvsw4DYuK/8Hk1Yo8+t3XQvrfUKCJ7pi7sl/bJ9MlTHb 0Q7q2+zgp8JITUor0WaC2drhi2/uVAu8s2/yLC8J7TQLJ0sYr4k8H/CYFnhSJXK4Ovd1 rQeVblna7n4SyYpiw7YE0eTm9Awp90bYF3wgd7xExjTBHmef1B60xwtk1WmKQcemsh/z yE1Aq2d2kDyBX8wyfeuWeCmizrcwScBfVUM7AkRvu0vpRnpnBxjK0Zmw2AMLsEBPtHO/ oznQJSXSQbXt6M6d9/yS6WsWE5GurKowfJ2vZ/uOstSY/BNeqH8DcbIAlEQPJuvelqv6 hFbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="2n/XtD7A"; 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 j5-20020a17090a734500b002564edc1320si1470942pjs.51.2023.06.08.12.24.25; Thu, 08 Jun 2023 12:24: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="2n/XtD7A"; 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 S235269AbjFHTQv (ORCPT + 99 others); Thu, 8 Jun 2023 15:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbjFHTQt (ORCPT ); Thu, 8 Jun 2023 15:16:49 -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 545852733 for ; Thu, 8 Jun 2023 12:16:14 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-ba81ded8d3eso1042812276.3 for ; Thu, 08 Jun 2023 12:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251670; x=1688843670; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=2n/XtD7AqYzwMObmNTcTXdhdmtrivr6xS0a6hxh2028Gq3sNV9XO29gB5O2y3L9l/t L2rqH6x4Pz17FgKoR1Y4rQPo+pjlVHFvq4Uxf6V5Z1hVLY+dk3dbsKixOg2g0+O6MH3o wHR7UhzFBUpyNSTJP8nVTqWIyYA0el7GHtc3GU+0DrUYPDVBZCtJf3wyrCUqLLZR09lv VqBAJ8/LNlL6ViTV2apFi54AS+jw7a1Zjo/eBl1kmHqeluHIV3N/nqy10dITHeklJsgD IGKWlS4umLi9ypWs+T7OEHIYU3YkWJ3FbGyXJ6NMN9TADYksX23kqJlAINxQPvIJDTtX gwNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251670; x=1688843670; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hqbvyW6crf6toTfKG311uSxHzLZVjYgM3m9zpPIhyDA=; b=QF+TKxHOeWjnutrhEgwHahkOWAobUx0zXupdCu+ET4vh6hlOiihO8obiPDVpmHjQkx uT/QETLrIoEI/OA9ESdt7Zl3x8PCUfcHJohuQ0RWouJjUTSf0elTaUkIfYhzuK+J10aa leJkMNGXBPo2QaVsUjLBHE1DMAJQJU21ZNojAU9n354d5hFzoNKGuXZKIWe7VQEdD0uF dAR0IiSbMmhYEBFvMsg/rj4ehm0RNfhTSJIEEMX3zTmi18A4H3T779mW29s7DP0y/tAp 42jvbwDdnmPsX1EiBuiQTaU/ktvki3EXh8SBhyD1oNriy5/m7u2zDWNE6zQQy4B8qQAJ tUyg== X-Gm-Message-State: AC+VfDyBWVx9WOevYAzIG4nscaPchHHD2eFqBQzHG5/sRkuim+quCMnF LZE9+IitjniTJtmQVUc6CLCbsw== X-Received: by 2002:a25:e302:0:b0:bb1:5a06:70ed with SMTP id z2-20020a25e302000000b00bb15a0670edmr543635ybd.19.1686251670430; Thu, 08 Jun 2023 12:14:30 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e10-20020a25874a000000b00b9e5b28dbd8sm429689ybn.17.2023.06.08.12.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:14:29 -0700 (PDT) Date: Thu, 8 Jun 2023 12:14:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 04/23] ia64/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <1c2c7837-bfea-9640-a74-985379fcc5a@google.com> References: MIME-Version: 1.0 X-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?1768163669075170558?= X-GMAIL-MSGID: =?utf-8?q?1768163669075170558?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/ia64/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c index 78a02e026164..adc49f2d22e8 100644 --- a/arch/ia64/mm/hugetlbpage.c +++ b/arch/ia64/mm/hugetlbpage.c @@ -41,7 +41,7 @@ huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, taddr); if (pmd) - pte = pte_alloc_map(mm, pmd, taddr); + pte = pte_alloc_huge(mm, pmd, taddr); } return pte; } @@ -64,7 +64,7 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr, unsigned long sz) if (pud_present(*pud)) { pmd = pmd_offset(pud, taddr); if (pmd_present(*pmd)) - pte = pte_offset_map(pmd, taddr); + pte = pte_offset_huge(pmd, taddr); } } } From patchwork Thu Jun 8 19:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp492851vqr; Thu, 8 Jun 2023 12:22:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CXNJUdubxRdMqhMvhRWX6mvSdwtCJ75/VbI24ZhQiDE5gm8dvM8nikjST+RTiSnF8Wn6s X-Received: by 2002:a05:6a21:7894:b0:10b:b5cc:6348 with SMTP id bf20-20020a056a21789400b0010bb5cc6348mr4864025pzc.20.1686252125625; Thu, 08 Jun 2023 12:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252125; cv=none; d=google.com; s=arc-20160816; b=WoVGqLaC4V6lj8N1HJkwbfxQgnNoqkL1PxaDtUSzXIThXrKfXPeZ3FB++c4upg7bi/ MzhivczQLVrdlXyNrSYh8lg9WPRVCQzq5Uq264YA5Wokcu8pnbJOWoDx7mBXhff+2caX NVZZcIsOv8wXCt4n1yP5vB7VUUZpvbmwURQRwam2AgKuDjfo3cJRNl4V9Sy9hIbnf3td 42yFBT9ykpm60ltLhLjuMwy8JOieg7veSuSBIoXtQ56U7OQev1tKkzVuM/30uU31rp5h 9AsHQoP4yUNabzE55Ryuv5qa6iyHKWQjtwN3DnpVgHElo8cWESbd0JmedptFRzUXXJ6D 9ojA== 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=TJNJRcM5sekd8SFzTjOrpGXXhS1voStE3rhDQsrS3ramJ92rTEhC5U2D2AgOrwTVaF 7GkLqhH38Wfh3DXVNKPswFnp6WZYBhNH04Ub4djFVPcMHeQMqx4xj8q4Ujjx6Aqp72F5 JeaeBMU5svWaGuU9Vm0rcvmHIERB6kc2BoNiCJ1lfHrICwM7AuSqMvda+yke0Tx1nKsZ UIJelpwuQj/iL2TT0nCNhyKue43Iyv6Pi2ppHurMKGpPmet2G55nAQmeBzWku7/CrOZs BaQTMVOAi+vvktMIGlScCrHw4e1A5gPj2JDNfBM8lfSUsIVilz61AFAauvxnBEh80wk/ Qd0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=RcRjFaFt; 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 w20-20020a63af14000000b005347fcb785dsi1377201pge.181.2023.06.08.12.21.51; Thu, 08 Jun 2023 12:22:05 -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=RcRjFaFt; 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 S233367AbjFHTRc (ORCPT + 99 others); Thu, 8 Jun 2023 15:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbjFHTRa (ORCPT ); Thu, 8 Jun 2023 15:17:30 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 621732D4F for ; Thu, 8 Jun 2023 12:17:03 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-39aa8a055e0so43779b6e.0 for ; Thu, 08 Jun 2023 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251721; x=1688843721; 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=RcRjFaFt7MTsXYJ14yWo4U5eA6pVqkDXz8EgSw8rQFycQ7pMspld1gf0LfqrvmcfQ5 wTF2Paqcgla4R0ay3/D+SBW87kCEr4gikKdylaKnD0ifdUg5uzvb81mHOycuMKL93pbu +4jYc+S9ZIa5rCOofCbRs+g+NjpuL2HFQoI0VVvcn9kL+J6N1marZJvlyS6H29Uy9XP9 eG8fQcR/05AwiXrOcow804IstbsNP+1l3OZiN8NosONtubhmvXmzHlK/q5JRXElO9Al1 ir/ohc+1TCFZSM0rluyKdy7OGTLktO3/SESE0MYOh7msrNKoSiowE8nv54l9tGtZ2JpY LUCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251721; x=1688843721; 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=FERnktyobmW45Y38fkdV7jDjWixMscImTdbfhW1cBfVn7uKKIV9Ifk5GgjnAGbQoau kQtd/0SgRK4vzmR+fa7cFXYBW4qDo8mHTL1zxLDzC6wOgbAZAWIhRYNe/+QpSWN64XTb twTnanszdc798rqKpL41nPeN1hf+NX6kFHacBhI6Shtew+zrzdKiuy51EbZTZTyIURPu oiBnuwyXkOhYj7RheA/1VDraOBkTrdet2xORVcn8CRKiJAuSGr5aH4tbXviKeJeqNLKg 84qcb5dIAcskKYETBH6opQE8RrcIzBfs2kB8JlRdvIH3CqgqFvJbJggpfvzYF+BO0BOx R+Ww== X-Gm-Message-State: AC+VfDwMtg5ecUfTa8fRsdBDkJIL95R/kTLE4bkmMXMkLJlvJMI+5DRm ZxkVc/9zFEcD9oNoy5XECwdOBQ== X-Received: by 2002:a54:4893:0:b0:39a:b35b:a06c with SMTP id r19-20020a544893000000b0039ab35ba06cmr9888918oic.30.1686251720727; Thu, 08 Jun 2023 12:15:20 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a17-20020a81bb51000000b00545a08184fdsm89974ywl.141.2023.06.08.12.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:15:20 -0700 (PDT) Date: Thu, 8 Jun 2023 12:15:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 05/23] m68k: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <795f6a7-bcca-cdf-ad2a-fbdaa232998c@google.com> References: MIME-Version: 1.0 X-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?1768163508452326419?= X-GMAIL-MSGID: =?utf-8?q?1768163508452326419?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Restructure cf_tlb_miss() with a pte_unmap() (previously omitted) at label out, followed by one local_irq_restore() for all. Signed-off-by: Hugh Dickins --- arch/m68k/include/asm/mmu_context.h | 6 ++-- arch/m68k/kernel/sys_m68k.c | 2 ++ arch/m68k/mm/mcfmmu.c | 52 ++++++++++++----------------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/arch/m68k/include/asm/mmu_context.h b/arch/m68k/include/asm/mmu_context.h index 8ed6ac14d99f..141bbdfad960 100644 --- a/arch/m68k/include/asm/mmu_context.h +++ b/arch/m68k/include/asm/mmu_context.h @@ -99,7 +99,7 @@ static inline void load_ksp_mmu(struct task_struct *task) p4d_t *p4d; pud_t *pud; pmd_t *pmd; - pte_t *pte; + pte_t *pte = NULL; unsigned long mmuar; local_irq_save(flags); @@ -139,7 +139,7 @@ static inline void load_ksp_mmu(struct task_struct *task) pte = (mmuar >= PAGE_OFFSET) ? pte_offset_kernel(pmd, mmuar) : pte_offset_map(pmd, mmuar); - if (pte_none(*pte) || !pte_present(*pte)) + if (!pte || pte_none(*pte) || !pte_present(*pte)) goto bug; set_pte(pte, pte_mkyoung(*pte)); @@ -161,6 +161,8 @@ static inline void load_ksp_mmu(struct task_struct *task) bug: pr_info("ksp load failed: mm=0x%p ksp=0x08%lx\n", mm, mmuar); end: + if (pte && mmuar < PAGE_OFFSET) + pte_unmap(pte); local_irq_restore(flags); } diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c index bd0274c7592e..c586034d2a7a 100644 --- a/arch/m68k/kernel/sys_m68k.c +++ b/arch/m68k/kernel/sys_m68k.c @@ -488,6 +488,8 @@ sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5, if (!pmd_present(*pmd)) goto bad_access; pte = pte_offset_map_lock(mm, pmd, (unsigned long)mem, &ptl); + if (!pte) + goto bad_access; if (!pte_present(*pte) || !pte_dirty(*pte) || !pte_write(*pte)) { pte_unmap_unlock(pte, ptl); diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index 70aa0979e027..42f45abea37a 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c @@ -91,7 +91,8 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) p4d_t *p4d; pud_t *pud; pmd_t *pmd; - pte_t *pte; + pte_t *pte = NULL; + int ret = -1; int asid; local_irq_save(flags); @@ -100,47 +101,33 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) regs->pc + (extension_word * sizeof(long)); mm = (!user_mode(regs) && KMAPAREA(mmuar)) ? &init_mm : current->mm; - if (!mm) { - local_irq_restore(flags); - return -1; - } + if (!mm) + goto out; pgd = pgd_offset(mm, mmuar); - if (pgd_none(*pgd)) { - local_irq_restore(flags); - return -1; - } + if (pgd_none(*pgd)) + goto out; p4d = p4d_offset(pgd, mmuar); - if (p4d_none(*p4d)) { - local_irq_restore(flags); - return -1; - } + if (p4d_none(*p4d)) + goto out; pud = pud_offset(p4d, mmuar); - if (pud_none(*pud)) { - local_irq_restore(flags); - return -1; - } + if (pud_none(*pud)) + goto out; pmd = pmd_offset(pud, mmuar); - if (pmd_none(*pmd)) { - local_irq_restore(flags); - return -1; - } + if (pmd_none(*pmd)) + goto out; pte = (KMAPAREA(mmuar)) ? pte_offset_kernel(pmd, mmuar) : pte_offset_map(pmd, mmuar); - if (pte_none(*pte) || !pte_present(*pte)) { - local_irq_restore(flags); - return -1; - } + if (!pte || pte_none(*pte) || !pte_present(*pte)) + goto out; if (write) { - if (!pte_write(*pte)) { - local_irq_restore(flags); - return -1; - } + if (!pte_write(*pte)) + goto out; set_pte(pte, pte_mkdirty(*pte)); } @@ -161,9 +148,12 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word) mmu_write(MMUOR, MMUOR_ACC | MMUOR_UAA); else mmu_write(MMUOR, MMUOR_ITLB | MMUOR_ACC | MMUOR_UAA); - + ret = 0; +out: + if (pte && !KMAPAREA(mmuar)) + pte_unmap(pte); local_irq_restore(flags); - return 0; + return ret; } void __init cf_bootmem_alloc(void) From patchwork Thu Jun 8 19:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp494024vqr; Thu, 8 Jun 2023 12:24:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73YHr/RhnHaoX7+VzMziRMxBfV9fh2KUkphclEiF5yqRE7SQ+GZz0fvLFwSH/VLJIImmBx X-Received: by 2002:a05:6a20:9388:b0:114:6993:5a3b with SMTP id x8-20020a056a20938800b0011469935a3bmr6442156pzh.13.1686252276139; Thu, 08 Jun 2023 12:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252276; cv=none; d=google.com; s=arc-20160816; b=tS57G1VODS5YBvy1X0iu2Tw6UkostEMPQj6LLzYxYIYXVxH/TJS9iSWUSs1zXnyCQ6 kbMM0N1aBv5KiktMtcSUV+2onqngQ6T2wGb/yz09Yp+g4bpJdacyUM5wCsS7LE/gUOyC lV8VvI8esBz/aHOukUS+C/H49BkRy2fLj60qr87yUWTmcaEsJtO2JdJcYbiAhLzO8BrQ fJno/ek4fUxxp6sfGgIk3LwmLYFGtI1FFXqqUJBuyzIDNIsihkidV4W7apwxNHp4ZFy8 teyH/XJfMV2DdFMyUqQ+4pdSTKdy5R/WAPp8IDvj5ucqGxffDic5DAng31JiEqb/OIdz q+qg== 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=rkLbgr1Xh7HXW3bjd7srICM3/FvawiBIyy23ov/U3X9716/IuG/246BBcZlu1cRDbT AOUHuZKwLlpOXLAmi+kuX6UqoxRTpjoDsBay9NDfzbiRfRXZWhjxKUNyiIe9pUOhQ13P jB6qqls+PMoOPX4tWMyNPfM7Y+9U5fzIjuPxtK7oOX10FPt9TtuVDxILxZQR4yj96UNa IwZ92cFtPVUxi3UFyrvnjGearsuphe7RLlG6lSXRZiZjwW15ql2yU4wCxGN74NRm0CKS C0kMSrx6SkYdkRta9fgKVyjXDLWck9l5u+7ItJ6icUyk9TfD1BnmBJ0EAN2AGq07IfWp 8TJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Xts+xHOk; 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 i133-20020a639d8b000000b005030a59a81dsi1367069pgd.159.2023.06.08.12.24.23; Thu, 08 Jun 2023 12:24: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=Xts+xHOk; 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 S236511AbjFHTRo (ORCPT + 99 others); Thu, 8 Jun 2023 15:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbjFHTRm (ORCPT ); Thu, 8 Jun 2023 15:17:42 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 454872D70 for ; Thu, 8 Jun 2023 12:17:09 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-390723f815fso27245b6e.3 for ; Thu, 08 Jun 2023 12:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251779; x=1688843779; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=Xts+xHOkrh/u1lklJ9jF3D7S9f/kLV8GPG892l7zD8MlHgN8wPrMqgrCwto/Q1X+Pk W1+dBhBpd/nxZGkRw7Je76Rv8ScIxWS7YhmGg7SCpWHyKB1Cka/5vVCHo+mJDQWdRl3m u500Id80G1EkjsXNB0mtCuxFaZBYzNUs8Dvvd2LdfZ44ADa4Y8aQBNX2j9WdcdQ881QF GqyzpCVHN9rDUPFg5SeHYjmoNQ/CJXz81UrJdT3zX813tHx7kBAl3bNlJp8cLIqFQaDy L3QDpbP/aGZ6VEQHFKJzDm28XHlRNu1JajJiE2WmrxtPA9CVcv6EWsa+OLyEs2Vz0giA l8jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251779; x=1688843779; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fUQgmWpeb8XZ+Q95Ceu0Qoh2H5+Z0fgN6mScmqt4vh8=; b=hclkyaL3BXUJ5LXP4UNqZAiib4mZdReVkJ63xSnzB2qjYuGmWVtJg5tboSIiY/DCoM fCYqAMf4hdkkZSREZ1yfsmfCBzlTnFJntV329aQxppVkClhmg8DRcK2T/X7lcoJiQC1J cVxHqUET0mHIVzE3qmlsq9zsoVaeFZA28w4RDm+JXiJnuv7Dr8tTzPjyF9wWEYIT5MAg p+ZFsTKzhe1l9TMOPXCFjkeHKzmukN6lgXHrR4xyYAeJxNk1jcH9oQs3pxOCNpA25BR7 o9sB/Kgy2Kixv3SvKzJPJoOIRrBRW2z1/Q6gRZqeEcFPbNc84+zyfjfEt6W28bJno/g1 AeaQ== X-Gm-Message-State: AC+VfDzgxdtN+JUaXLUY6PBZ+855umOKTjsx2lC6uVnXAOMNsDE5evHK KPuBnXKLlY9rvX+/eMNZQOQ5yg== X-Received: by 2002:aca:650c:0:b0:39b:da91:8749 with SMTP id m12-20020aca650c000000b0039bda918749mr6427430oim.50.1686251778936; Thu, 08 Jun 2023 12:16:18 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h200-20020a816cd1000000b0055aafcef659sm120593ywc.5.2023.06.08.12.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:16:18 -0700 (PDT) Date: Thu, 8 Jun 2023 12:16:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 06/23] microblaze: allow pte_offset_map() to fail In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768163666426220209?= X-GMAIL-MSGID: =?utf-8?q?1768163666426220209?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/microblaze/kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c index c3aebec71c0c..c78a0ff48066 100644 --- a/arch/microblaze/kernel/signal.c +++ b/arch/microblaze/kernel/signal.c @@ -194,7 +194,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, preempt_disable(); ptep = pte_offset_map(pmdp, address); - if (pte_present(*ptep)) { + if (ptep && pte_present(*ptep)) { address = (unsigned long) page_address(pte_page(*ptep)); /* MS: I need add offset in page */ address += ((unsigned long)frame->tramp) & ~PAGE_MASK; @@ -203,7 +203,8 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, invalidate_icache_range(address, address + 8); flush_dcache_range(address, address + 8); } - pte_unmap(ptep); + if (ptep) + pte_unmap(ptep); preempt_enable(); if (err) return -EFAULT; From patchwork Thu Jun 8 19:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp492855vqr; Thu, 8 Jun 2023 12:22:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70HTsldaCtVPJ2Q8Ihb6VxGllAF20Qyy6AqfSrTd1QhK2JGGQXWlfmKaIfxX5H4LhN7SGo X-Received: by 2002:a05:6359:12:b0:129:ce83:d541 with SMTP id en18-20020a056359001200b00129ce83d541mr6695600rwb.21.1686252125798; Thu, 08 Jun 2023 12:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252125; cv=none; d=google.com; s=arc-20160816; b=B1GNgVTAXzyugtnIx3npn65N5JKgOQrXauKSjmTmD1IVmXdqWIMfx7So09u4I4I9tg HBLU1yymef6kNr0ygo0gQmRxr4J9nrUBtxxA52bXl7NZMk6CfdiD52pw2C+/6X9+K5Vi RCTSBHvOLleV8rAhHigXAvcnsfMgK0dizAVuLXgSLl91Dvi9OiipG28eMv1WVY/b1mO7 yED+msyrBA3/mnaWTHdKG5jjoQinTa1cHYncRB+FsIe9I/X82GVnNRNB6I0ap1dQxIS4 YUMN/SvByiYOiFnYPS8ktWGuhoTSlig4jJJuWwYc/HLP+stuIjmVDui4tGFXSeyakrH1 amKw== 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=qaDdizw+6kuZh3wUftX12qvbo7uytc9LiLfTAG2GoZgiTUFgVhH6ZXXF0esTdCfrvm l2jL3OMGeU4HK14Glqo5LFY3dl+eWskLCXzEAeOkLPDbsPF80RXGqBWds1cnP8GNqmol tleg9ug08vVyEgEo1fqJwkxRBbq6M/0ZA3AJX1qbvG5nfhjvbPXFdXhVCJxinLOf+wdY ExKjZqDFGSo2b4z9moHX8OeBBheNtEEK1xEtt+SFE21sYGzxPGBNKbIvCmPqUna5W07a pbcuj4d0nNjlB/SZWv/Og+UM5TFDSkCrl6aDdX5j8Ait9ycUtYybsjGNfEuulLCcClwA nVlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OjxQxSGd; 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 v29-20020a63b95d000000b005098590f1edsi1346770pgo.757.2023.06.08.12.21.51; Thu, 08 Jun 2023 12:22:05 -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=OjxQxSGd; 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 S236879AbjFHTSR (ORCPT + 99 others); Thu, 8 Jun 2023 15:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236819AbjFHTSE (ORCPT ); Thu, 8 Jun 2023 15:18:04 -0400 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4A4A2 for ; Thu, 8 Jun 2023 12:17:33 -0700 (PDT) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-568900c331aso9233667b3.3 for ; Thu, 08 Jun 2023 12:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251849; x=1688843849; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=OjxQxSGdY41m5JGioPLRRMHlbu1bKK9U/XvtQSsWn2huryMGbscAYfOgTPbtYvU/cY 9huVOVy1gs221HXHTdTxeIS9YVBJM8bmeWwNXcHAGGu+nicpq5iZ05fikYyLmvX7+Ico B0dGfyyHLd/L99UUQOPdqJWluT143yDr4HPWe/IeSwrOdmo8Ey9hr6IWcFOUOcdRjD89 uj2YuuaPnH3mhSN3ywyQu3CK8kSeEgGczYiudwTD8Jm0Ztvk+Qzx/bR/vvgb6aHZfoxB UdhBn1Xz2Oa9JpVFDtQjB5jQNwvMAbW3dNrfQzUbl4VOBwdYKLYYm2tmZUitVw+SniVU 1QQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251849; x=1688843849; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b7UlqbgxG6/xaVRAtCCqUssmJjUq670TXTguXR1OYLA=; b=jX5zpHFpEzA/oHJtaJ5Hekq2bTsONRTzqj1+zTB4B0tLgkFKQKGJ3h4rKzNIa1aaxZ XScpqvfDxgBBXY+Pw+X3lwBgI6j8vPWJFK70VhKRCLxxqHBqEnAemEZKu1gmZKd3j7m3 S0w9xjgqJwf3OOZRwbHj8QYu6yir3GL9D/ZvaY1iYozkHRQaGHqilXnL6kzwO1HrasSM 63eW01BIUF+0jEgT88lM+e1midkDRoV9ameiZDtIJicQcqghVPmZNX/GrnzDDeJTx/k1 hp8dpkY/Z5sNNyCRerCN+/q0nUWznnljaMrQnDndQafrQYlFPsxD3OVmNY+TER8a8bUE PqQw== X-Gm-Message-State: AC+VfDxg3FscpZZW1o0EcEdMLVNnbXlvuOj9NIz64PmzKl9SVplH6XHe bO2X4EslFbtg2MrwASifXr3XmA== X-Received: by 2002:a81:8403:0:b0:565:eae8:793b with SMTP id u3-20020a818403000000b00565eae8793bmr567910ywf.25.1686251849019; Thu, 08 Jun 2023 12:17:29 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id d190-20020a814fc7000000b00568b941e5e3sm109329ywb.72.2023.06.08.12.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:17:28 -0700 (PDT) Date: Thu, 8 Jun 2023 12:17:24 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 07/23] mips: update_mmu_cache() can replace __update_tlb() In-Reply-To: Message-ID: <178970b0-1539-8aac-76fd-972c6c46ec17@google.com> References: MIME-Version: 1.0 X-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?1768163509110969790?= X-GMAIL-MSGID: =?utf-8?q?1768163509110969790?= Don't make update_mmu_cache() a wrapper around __update_tlb(): call it directly, and use the ptep (or pmdp) provided by the caller, instead of re-calling pte_offset_map() - which would raise a question of whether a pte_unmap() is needed to balance it. Check whether the "ptep" provided by the caller is actually the pmdp, instead of testing pmd_huge(): or test pmd_huge() too and warn if it disagrees? This is "hazardous" territory: needs review and testing. Signed-off-by: Hugh Dickins --- arch/mips/include/asm/pgtable.h | 15 +++------------ arch/mips/mm/tlb-r3k.c | 5 +++-- arch/mips/mm/tlb-r4k.c | 9 +++------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index 574fa14ac8b2..9175dfab08d5 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -565,15 +565,8 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) } #endif -extern void __update_tlb(struct vm_area_struct *vma, unsigned long address, - pte_t pte); - -static inline void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) -{ - pte_t pte = *ptep; - __update_tlb(vma, address, pte); -} +extern void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep); #define __HAVE_ARCH_UPDATE_MMU_TLB #define update_mmu_tlb update_mmu_cache @@ -581,9 +574,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma, static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - pte_t pte = *(pte_t *)pmdp; - - __update_tlb(vma, address, pte); + update_mmu_cache(vma, address, (pte_t *)pmdp); } /* diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 53dfa2b9316b..e5722cd8dd6d 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -176,7 +176,8 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) } } -void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) +void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) { unsigned long asid_mask = cpu_asid_mask(¤t_cpu_data); unsigned long flags; @@ -203,7 +204,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) BARRIER; tlb_probe(); idx = read_c0_index(); - write_c0_entrylo0(pte_val(pte)); + write_c0_entrylo0(pte_val(*ptep)); write_c0_entryhi(address | pid); if (idx < 0) { /* BARRIER */ tlb_write_random(); diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 1b939abbe4ca..c96725d17cab 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -290,14 +290,14 @@ void local_flush_tlb_one(unsigned long page) * updates the TLB with the new pte(s), and another which also checks * for the R4k "end of page" hardware bug and does the needy. */ -void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) +void update_mmu_cache(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) { unsigned long flags; pgd_t *pgdp; p4d_t *p4dp; pud_t *pudp; pmd_t *pmdp; - pte_t *ptep; int idx, pid; /* @@ -326,10 +326,9 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) idx = read_c0_index(); #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT /* this could be a huge page */ - if (pmd_huge(*pmdp)) { + if (ptep == (pte_t *)pmdp) { unsigned long lo; write_c0_pagemask(PM_HUGE_MASK); - ptep = (pte_t *)pmdp; lo = pte_to_entrylo(pte_val(*ptep)); write_c0_entrylo0(lo); write_c0_entrylo1(lo + (HPAGE_SIZE >> 7)); @@ -344,8 +343,6 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) } else #endif { - ptep = pte_offset_map(pmdp, address); - #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32) #ifdef CONFIG_XPA write_c0_entrylo0(pte_to_entrylo(ptep->pte_high)); From patchwork Thu Jun 8 19:18:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp497445vqr; Thu, 8 Jun 2023 12:31:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nWBKm2aCp95G/xKhn0NIcKnSadFTt8/OWQHEwZEKxx9Krc/6mknGci9dIdkFp31yFJyPt X-Received: by 2002:a05:6a00:180f:b0:663:13a9:9504 with SMTP id y15-20020a056a00180f00b0066313a99504mr4745287pfa.10.1686252719570; Thu, 08 Jun 2023 12:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252719; cv=none; d=google.com; s=arc-20160816; b=wN+TC9T15Xs3RWL9nWE0VIp8hQEdzk8hBVNmlFFisIzrzEnqgQR95Ara78JXwz08iw +VATqAo1xoPNTV/2UFuqMMDYu5s2g0zuXkN0Tmw64FWH+zF4m/fTPT3njkcSjouWiDPC 9yLPfyZMw/HjR3CR1Nm4WhfEH+QjGnOZ8qpBe77V2UM+Rh/Hbzo9t0o62va/wMHNMGDK sfdPYPHBxfxJ8w0+oBj5Ia0ByUF3MOhQz1yl5ghl+hz07JSjktPH/Ws+We5ZHcDGVaVQ vRiLHxp8R8vcLLvjIJZZQocHB5lHvqhrS44AKxvZJgJyWDcEwSRD8z3KcqM2fuhb+rRA o8Og== 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=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=heGezd2XVkBiLgAQYpzojYCuF4HloBuBs96v1c+Uhpnbu6/+Q6eIzIZDZUBmW5JTF4 8eSVXzu44KAdy2CKSFT+iX69ZfH1JNvdnGnd9U5enoP9wgSngabhAPXjKbyo84WRJF7P IY38Op9gKemm0rpi1JMI4R5nR+FxlB4resgsepl4jZWmDTixuawPbsqH+H0VdNQxXMH7 7I5P9PeuPyfQs5PFqC8unOg5ADtDu63Ka2YUSvq8fjfMeWtvHEswbfMROb1E0v2hqBmo iH2LvFQW1DnxJ4Xvxeou1zHkVnVy6Y+6nrWDoDP2YIPvVeEanhQvOSqQfQpbwlqJT5dg u16Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=HEwZycAE; 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 b18-20020aa79512000000b0065addb172e3si1225443pfp.206.2023.06.08.12.31.47; Thu, 08 Jun 2023 12:31:59 -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=HEwZycAE; 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 S236320AbjFHTTU (ORCPT + 99 others); Thu, 8 Jun 2023 15:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234046AbjFHTTS (ORCPT ); Thu, 8 Jun 2023 15:19:18 -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 927BE35A5 for ; Thu, 8 Jun 2023 12:18:43 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-ba81deea9c2so1060670276.2 for ; Thu, 08 Jun 2023 12:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686251920; x=1688843920; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=HEwZycAEZshzMQG1RY6xWzkEzRNEN/UEaemUkYXNmWskdkmVKrA8S+97io6IqWp9/V /Ki/r1s4TSfiiefdOd1an7zeCiAQCXani7OPWb0Yu0dH1JXoMBV7ddckrsj8wmhXsvpX lxVVQwwTUjyQXS/CCeF4VIDT1g2/zM6/NDtUcqQOoZLozwlnlFrDor/PrqoADqkak2qo deaYgmKHf6xqfmf4KVoYNd/vj1wQpn8eoXEC4WQqeZC4WPbGo41LYWdy4IN4tXqheqG/ 6B0lxLrh+XpboJCYpvDK5+1gNhnxK8xFzRPNdKypeMnMcoGI/ayoAWXa0T/S7aKkyUXg eIPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686251920; x=1688843920; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLKDOkdQ4oq0ww1Vlfy/KRTEhctwBXtXyzZrgpalkvM=; b=BwFsmBVPmRhHmW6jz0KON42+GJBvVdJeCOtWe3klIbRSnfaAMAW5YZT1H6+w7KHrq8 9MX9V6NH+ccSrJC/uVg3dOx/SjsKzeWY8e0iv7/NKhVpE56D/VBFhuDOM9Mfl8O5I0+n wafq+LMAmnBHCRyoHpii08h2CF9lnwW7QwPoQasWA/UV/nkt3SmJtVsUkU3/O8unESie n1NKU2BmTDrHmLJW6B1M9OyFetaZFV4cP/7ofWxozMmJi6vQmEZ9V1fHrUIRX9MP6vYz 6j07PrPS6l80Q4OweZzcl+QxpafR3aHSn4V11p8JrynRgcYK0vPNsfZjyHmAP54ncct+ LQ1g== X-Gm-Message-State: AC+VfDyFDLonZ4N4H3qJj6m/lS42ttxNSii6LqTWHz+Pm1wAZYBDvNWW J9DdA5UkKjT9gCrIJumwQC5IPw== X-Received: by 2002:a25:e307:0:b0:ba8:7f98:4afa with SMTP id z7-20020a25e307000000b00ba87f984afamr579046ybd.26.1686251920409; Thu, 08 Jun 2023 12:18:40 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 22-20020a250316000000b00bb2f5dda19bsm432908ybd.47.2023.06.08.12.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:18:39 -0700 (PDT) Date: Thu, 8 Jun 2023 12:18:35 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 08/23] parisc: add pte_unmap() to balance get_ptep() In-Reply-To: Message-ID: <653369-95ef-acd2-d6ea-e95f5a997493@google.com> References: MIME-Version: 1.0 X-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?1768164131330079718?= X-GMAIL-MSGID: =?utf-8?q?1768164131330079718?= To keep balance in future, remember to pte_unmap() after a successful get_ptep(). And act as if flush_cache_pages() really needs a map there, to read the pfn before "unmapping", to be sure page table is not removed. Signed-off-by: Hugh Dickins Acked-by: Helge Deller # parisc --- arch/parisc/kernel/cache.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index ca4a302d4365..501160250bb7 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -426,10 +426,15 @@ void flush_dcache_page(struct page *page) offset = (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT; addr = mpnt->vm_start + offset; if (parisc_requires_coherency()) { + bool needs_flush = false; pte_t *ptep; ptep = get_ptep(mpnt->vm_mm, addr); - if (ptep && pte_needs_flush(*ptep)) + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pte_unmap(ptep); + } + if (needs_flush) flush_user_cache_page(mpnt, addr); } else { /* @@ -561,14 +566,20 @@ EXPORT_SYMBOL(flush_kernel_dcache_page_addr); static void flush_cache_page_if_present(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn) { - pte_t *ptep = get_ptep(vma->vm_mm, vmaddr); + bool needs_flush = false; + pte_t *ptep; /* * The pte check is racy and sometimes the flush will trigger * a non-access TLB miss. Hopefully, the page has already been * flushed. */ - if (ptep && pte_needs_flush(*ptep)) + ptep = get_ptep(vma->vm_mm, vmaddr); + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pte_unmap(ptep); + } + if (needs_flush) flush_cache_page(vma, vmaddr, pfn); } @@ -635,17 +646,22 @@ static void flush_cache_pages(struct vm_area_struct *vma, unsigned long start, u pte_t *ptep; for (addr = start; addr < end; addr += PAGE_SIZE) { + bool needs_flush = false; /* * The vma can contain pages that aren't present. Although * the pte search is expensive, we need the pte to find the * page pfn and to check whether the page should be flushed. */ ptep = get_ptep(vma->vm_mm, addr); - if (ptep && pte_needs_flush(*ptep)) { + if (ptep) { + needs_flush = pte_needs_flush(*ptep); + pfn = pte_pfn(*ptep); + pte_unmap(ptep); + } + if (needs_flush) { if (parisc_requires_coherency()) { flush_user_cache_page(vma, addr); } else { - pfn = pte_pfn(*ptep); if (WARN_ON(!pfn_valid(pfn))) return; __flush_cache_page(vma, addr, PFN_PHYS(pfn)); From patchwork Thu Jun 8 19:20:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp498466vqr; Thu, 8 Jun 2023 12:34:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dGaz9oQ7kYJOpzOBb94fyMDV5ZgyHuOvmWiF2vc1kqXx6BcE8qPp8M8gaYAoN5pD9dWfv X-Received: by 2002:a05:6a00:c84:b0:64f:5406:d59e with SMTP id a4-20020a056a000c8400b0064f5406d59emr12094731pfv.17.1686252847752; Thu, 08 Jun 2023 12:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252847; cv=none; d=google.com; s=arc-20160816; b=qxPq7FlccY6RuKM1UlhRxhcY0zdxG23nTmu2NgAvAlOBfslmnOOQxY12qC1ziSvYBn ucSxnllCTnXtNNXEzloN4FgNPRj91fB8ExMYK0NwAs765wW93eA2DJkA/0mXe4MMX6yO q0EVzS09+2u60m5AUKzps0XXHuChbbEpQ4kPmnwdTZV6+D8/rWcHxwUraNn2MI4pRqLn rTqDfK94qA4ehXXZQGGeXf4nAaHyu68EJlQLuLLm2imz4akxY9c9likKvqJZROhlTC+U x9sZKsxEL9Za7xW3OJQzwZXjrSIitBI1SjoqxsqFXpPZI8riS6cN3ZpBCc72EseBWpVO IPXg== 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=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=Rjt7y19q9H8a85hKI5Uy06yAQ9Slc7I5QGx8q2NHguFSzj2hqpoJU6w8WmCHiJBt0+ U0I/k8SvXQ6e+F9F13hNZu0HAXhTwd50b0Nnprl8F6b8lFFZc2qhqttAvPqkoQGN2cBS UlrL+pgnCazWVyjDGRzPjyAdbejfOyOr2WJ/Jv45TwM/9zm/TZMyn3Uu8t5/fIdkaHya Sc1Z1vaEq2d3jG6lyxh6bzlyjwQ1+btnHe+UUMQjwTEQ1WnDY5nmVMdWtvIEUtaYqa8U PXt5015da/eu27JNVFLdgUwlQ2MFG2P5v5AkGNcfh5yxS9wQmoOSmqK+ibtsf8Z+/Sz8 BEOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=mXQ7UC6c; 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 t189-20020a6381c6000000b005346d98e741si1457415pgd.50.2023.06.08.12.33.54; Thu, 08 Jun 2023 12:34: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=mXQ7UC6c; 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 S236644AbjFHTUr (ORCPT + 99 others); Thu, 8 Jun 2023 15:20:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236465AbjFHTUp (ORCPT ); Thu, 8 Jun 2023 15:20:45 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DC1530C3 for ; Thu, 8 Jun 2023 12:20:09 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-bb167972cffso1090998276.1 for ; Thu, 08 Jun 2023 12:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252005; x=1688844005; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=mXQ7UC6cKQLLZIQ28oFk9gQ5KxeKVwwY9rk3e7MKP3JMMgFBUS0Y4Ow9xYO3QBbWBp OG1o7JhalsKeTrmK+H6URVPXbxrefFexNILlJOVSmAp7Qw//UVTcssC14O2AbNOpA95o 3fphns61QjibpjRegZHBgnDNFY4BaX8z0yU2Yg9FB0o8UxxLFxwBrXonk679QJW2NVtL a5CA3hBH6G8j2p1GNpc9/KN99Dv4NvapDgXnvT++Pvq7LeadMsdSuwcoq6yEHgW25m/P tlZmPB8WvPaouvvNC3jzVDH6WgeuI0e6ggHbT3c4Xpt7le2+MhNk3DZW5USJxtb/KL2r qm0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252005; x=1688844005; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E/dR8Qg9bFHe49vUjKvOi0Rl/4IhXWfwv6MExDzA+GE=; b=Ce8Itk5xjP3Ngyi63G4RKDyj+UvIllO1EWkOoUGzgpf88Rx4pdvwGbFYcciy6KnsSs VBnHod6IS0zSu+8oBreSYKjJohqmTUHCRJs5brX4s3I9hh7dHEP37gQt7X5+i360WazD nRAU8eYy7ib8/R+iIk+GCziKbRSa4KSMC3u+Aozp1ge6m53hRTXvXYK4zlNHVKgxCg/w siYUzP/L0INQLHqHf0w5z40RzWH5r7haHXa8ho2zwTzd02JvoL/GX+7z++VJuZ9O8vyD 9Dp4msHCLhYW6NTKyU88Asjdp0LG4wOFl/C0g/5oXwo1X/+dAaHJ5mz/vZ5M82R4o0kD LVwA== X-Gm-Message-State: AC+VfDy1+jUn3xCslgqecsXVjdDnjK5BUWBrAP7zAgfggJEi2BFcy74y cYbkqumkT8TUVYV3Uya420h8gw== X-Received: by 2002:a25:ce90:0:b0:ba8:16df:e3f5 with SMTP id x138-20020a25ce90000000b00ba816dfe3f5mr700600ybe.0.1686252005314; Thu, 08 Jun 2023 12:20:05 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 2-20020a251802000000b00b9dfcc7a1fasm446566yby.7.2023.06.08.12.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:20:04 -0700 (PDT) Date: Thu, 8 Jun 2023 12:20:00 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 09/23] parisc: unmap_uncached_pte() use pte_offset_kernel() In-Reply-To: Message-ID: <358dfe21-a47f-9d3-bf21-9c454735944@google.com> References: MIME-Version: 1.0 X-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?1768164266189236771?= X-GMAIL-MSGID: =?utf-8?q?1768164266189236771?= unmap_uncached_pte() is working from pgd_offset_k(vaddr), so it should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/parisc/kernel/pci-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c index 71ed5391f29d..415f12d5bab3 100644 --- a/arch/parisc/kernel/pci-dma.c +++ b/arch/parisc/kernel/pci-dma.c @@ -164,7 +164,7 @@ static inline void unmap_uncached_pte(pmd_t * pmd, unsigned long vaddr, pmd_clear(pmd); return; } - pte = pte_offset_map(pmd, vaddr); + pte = pte_offset_kernel(pmd, vaddr); vaddr &= ~PMD_MASK; end = vaddr + size; if (end > PMD_SIZE) From patchwork Thu Jun 8 19:21:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp506389vqr; Thu, 8 Jun 2023 12:53:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4RqLD5xw7Z3qZYo+kjbe7W7hXPGqy7gx5bDu6+LvXA3/7pr1zB3ozLx5l8tyDI6ahgzjBa X-Received: by 2002:a17:90a:e645:b0:258:8731:4e3f with SMTP id ep5-20020a17090ae64500b0025887314e3fmr5073207pjb.44.1686253994557; Thu, 08 Jun 2023 12:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253994; cv=none; d=google.com; s=arc-20160816; b=gIuYZytYO0Zpcln+QzEb9oaEMOIa8mboEz4ilHqQRerVmlznchwlvzw9XbhO0H/3Bx X3uSdOVHkgcTz6z+LTWRSK28H0PlgBgNMwAXGMwPqeAIoZriV3ett05Db4LnBLqFij0R EOMxtIPTC6NI7M5gN5F3a5obpKzP6mOnJmmVwH4uzn16R+vihLwMaByInlMPf1C5tGJG pHTriZWDywrd9sZuSOHEOhz4n8udyvAmS9J9B7CV7dZ8ci5N0XLwaB+itmxCAUo18abL bcRAAN9ASjRUEAgP+WMuyRs/7vEkveX59u6E61Tn5VVOf3JwchTZVdXKUGduoFhTDjAT IBOA== 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=hY+oJXGAOCqFB/7xS7JFtkO/ujJZXVZMCz2BusV2vV3qDaRxPhMkyKwAStsOZabBXn s0kTHdSYFolwdbFuiNpZO3thsjL68Qg8nHg7Nls/Zv5rsfHAqh+VsPzl7cj0XXjSk12A Mi6JwLkOuXe7A+7R5azGi0Rr8PQqQTNdBCWvUOl8N1r3VyqV6SeKfycARC8NM3/p9gor CclA3zGoZQhHzMwkBMsjhYYeXMldePWVuvrMmG1PhFC9Kx4NhTFRsYHn8tMS9UoHDacj zwBFARx+AD0kM9Gyl/eSQ4DY3AnekYHJW0nbhUfOtMv6jQaeKC9pq4Ynf1gfJz0VIjYF g6BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=HKd31Lqv; 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 125-20020a630083000000b0050bea5bf413si1468805pga.705.2023.06.08.12.53.00; Thu, 08 Jun 2023 12:53:14 -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=HKd31Lqv; 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 S236828AbjFHTVz (ORCPT + 99 others); Thu, 8 Jun 2023 15:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235928AbjFHTVw (ORCPT ); Thu, 8 Jun 2023 15:21:52 -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 604D930C4 for ; Thu, 8 Jun 2023 12:21:18 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-565cd2fc9acso9199057b3.0 for ; Thu, 08 Jun 2023 12:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252072; x=1688844072; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=HKd31LqvAwT3pdB9H8RTJjakAJAT9HvglTvKC+OkvKmv5VhsoaZHAtLpo2tFkCpDhK eaJn1uAawotb3pLd5xLGg7DzD6kDQrKAHxas7kU/r2KN0gO+8LwEgaLotjlfcSI+ExXP OsTJ1O2tfGB1hyPd2BGfO1Hv0XjmUpnPR5LgmonoIasqGq2fAG/aN3V/iTrXbCwGdrUM I50yE5ZJKvbdrlam2CeJEmfXKvbJkG9Wl49W11ZHf6B9xR5DJRVBfUy3eWMAtZhLeFU3 MFev89ALFBnRCYsOlrl0s+V0pK/HvUPQhOTjtpCkmArqzAHuVaF4G3AF2HiTPrlcql5n hmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252072; x=1688844072; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=alKFmwAdxdkIViw1WjkjX/OCKeQtR2IpGs2zcY6rd0M=; b=mBi/91iAv6hG8C1SnzgCzqkgUHCIw53Usi8wBiAygpVzV0IQys+3YrzBDtrP8iOB0k eiTWtJqPYgAJrY7KN8jmp6gk4ir4wMIT02rDyjjHFd8w8zHPxuRFHOmBI1youSotgm04 /9SbfqPirPQI0xbJ52RVxu+YQ2eQwClatv1rxp9ifXz9zDfPObVxfdkNdCJBB7c2ykjc 6bhXqnYgFTCN35moj4AbjkBOF1+NjADk+VPoe3RHEOvzi83ptpS60/a1+BoiXXBG4TgR r0ySbsJ2HTweNDBV1LgnHCfyjQYFOB4gEaw5lglWDp2f4Z83RVdQfkgsn4mCHjN82KC3 kSsA== X-Gm-Message-State: AC+VfDzwnNay7q6syx+NO1VRrrp/TqFgfwMvAun2oMTjN2q0JIMe5X90 HB/dLwV0pAmlW9veUDgNLA7wAw== X-Received: by 2002:a0d:d98f:0:b0:565:ba4b:aa81 with SMTP id b137-20020a0dd98f000000b00565ba4baa81mr612161ywe.45.1686252072277; Thu, 08 Jun 2023 12:21:12 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f184-20020a0ddcc1000000b00552ccda9bb3sm108635ywe.92.2023.06.08.12.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:21:11 -0700 (PDT) Date: Thu, 8 Jun 2023 12:21:07 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 10/23] parisc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <7963aeed-f7d2-e0-f3c6-3680c5572444@google.com> References: MIME-Version: 1.0 X-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?1768165469047471514?= X-GMAIL-MSGID: =?utf-8?q?1768165469047471514?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/parisc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index d1d3990b83f6..a8a1a7c1e16e 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -66,7 +66,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_map(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr); } return pte; } @@ -90,7 +90,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (!pud_none(*pud)) { pmd = pmd_offset(pud, addr); if (!pmd_none(*pmd)) - pte = pte_offset_map(pmd, addr); + pte = pte_offset_huge(pmd, addr); } } } From patchwork Thu Jun 8 19:22:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp497431vqr; Thu, 8 Jun 2023 12:31:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78UBF5Qt9Mbr2kxU6ZcGaootlR4TIX8PUrQqEnnezNV2ngB3IODtib35S0AsutlaZ9QMDX X-Received: by 2002:a05:6a20:5482:b0:10b:60c1:2999 with SMTP id i2-20020a056a20548200b0010b60c12999mr4062957pzk.22.1686252717807; Thu, 08 Jun 2023 12:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252717; cv=none; d=google.com; s=arc-20160816; b=NuyyNRlnDuQNTOrdQccSfgcpcuKxSdDgVngGezdVebKBmH1Guicoa5AwCgcXARjDyA jv4u+EeWgPzsyKG6XJWTYIju4eyjlRot33KJN8bhqITWsNcA0eNUFdHkmuLx3olUNIvd vbys58y/+uN8KRAmWm8eiNWHPYwl1KMvZcUIbLKwocukbPnETkCE/79qLnflpClnxyWc VtUup7N7mWx35zZvg49j1gdT8G9JlAVS/FIMjr4lgZ4upzmeUTl3DVXsFE+x7AmSJb2K dfVQg9GvC2OtSlnLm6CxH0gZOrfhO3WnKFT/uDqrM9N0ICq99jt9urnTUOcI/XBRweRT akzw== 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=AaeZuUVBfmnJYKBnECwxHMg2ZqET9Q9+U5NUK8rUZ9F4q5LOazN1QZA2Ssmw9rYAwM TDOjY3BBbCSpkoYwxcGF5TqocxIcB6NZqPi0eDwQcIHU4A6XkaqzeIzV1g1iUXf+wn+f TJ1kNBV6QsJVlCVuxUKh56dQYrtIkN9Q+k/mTSrkjdDK9FnoR2KQo3mpD+Y3Xw3GnTfv NWaKNy3DiQ5agjDVMW6KSxwuX/1za0g3ZLdwaU1GS98PdFLeob8hc3ZNdH3+YCNoSExp /qNUZ7w4I2em0pF0epH4abxcsiPXgzEAakAkFSO/EcNQPh/sR87kD3hiynWyV3GezlTo 5lEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=5jRACtmO; 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 k137-20020a636f8f000000b00543a6b76431si1371193pgc.326.2023.06.08.12.31.44; Thu, 08 Jun 2023 12:31:57 -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=5jRACtmO; 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 S234442AbjFHTXQ (ORCPT + 99 others); Thu, 8 Jun 2023 15:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjFHTXL (ORCPT ); Thu, 8 Jun 2023 15:23:11 -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 8EE1F30FE for ; Thu, 8 Jun 2023 12:22:46 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-569386b7861so31293947b3.0 for ; Thu, 08 Jun 2023 12:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252164; x=1688844164; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=5jRACtmOYl24iPoTbIjNRpyUFAC/FI9lpuvtUNHnC43m7VYioQ/BjHL7bdRB1Sderj Ku/HQKtR0qPfeCfubIqZ/AIBxONFw9MhEvcLPL8cbaxLn3mTiR/nWL6P2PCLjm+BwcQW 0EgQz3QqN/pDsKtdmzyltGWnacSj5IwEptrUle8FLf/akecGFE+OR3UMPvCEsj1BvLU9 B+ORl75p95EI9Mde8VL9yv1b1t+G7YgfanAmLLFyt7bpvhgPlWiVhcJ7Ue5u8gtJ1wSb o7+vcjNZQIk2HsdRh5Pl//khJzNempIfA/Kf3RkDsGtD4+XKnKjXxiMtp0DlEfTwETu/ 3u+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252164; x=1688844164; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VvuiwGfmHxTbGTIrjZEu2Atjrxfj5l7d/xiFwRLchQg=; b=RfQCK/jP5myon2RirKe5OBEfXyeae7ocfKDmNXL3f7bZONdBELRgep4KcYQedoJXxO blRuigHCMsq9ieLhszMFQaCAbx0cCmd02ZxwZgOLLA3Ihscit9JC2EvqGALzLfmJHMH2 E1c7kPyqyR+lZ7woc7wWHnZzNAYQHPpnyKpnw7HF9aJJ6GyDQUu1vGtD1JXYORgCz4CT j6MuCiipoXoYT4QBdVqbKWMM74TDLcVHtVBeVSyCHF5B6KhLSYbhYrGL1tEObiAUTXPL 6l8jYgr19nMECYqyXatwwSoa3WJy39hs3K1jMAfb7PZS2P3pX85N4VDU8r5M2fkuDfWN g76Q== X-Gm-Message-State: AC+VfDwvHXcl9JlNADc45xN5+exmFyRZurlcQAobmfU1ULBdDuLwbMxz K6MP3CQ/1n4ad2irjInhMh/1EA== X-Received: by 2002:a81:a08c:0:b0:569:ef9b:eda with SMTP id x134-20020a81a08c000000b00569ef9b0edamr823988ywg.10.1686252163900; Thu, 08 Jun 2023 12:22:43 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id n126-20020a817284000000b00561949f713fsm118018ywc.39.2023.06.08.12.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:22:43 -0700 (PDT) Date: Thu, 8 Jun 2023 12:22:39 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 11/23] powerpc: kvmppc_unmap_free_pmd() pte_offset_kernel() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768164130077364773?= X-GMAIL-MSGID: =?utf-8?q?1768164130077364773?= kvmppc_unmap_free_pmd() use pte_offset_kernel(), like everywhere else in book3s_64_mmu_radix.c: instead of pte_offset_map(), which will come to need a pte_unmap() to balance it. But note that this is a more complex case than most: see those -EAGAINs in kvmppc_create_pte(), which is coping with kvmppc races beween page table and huge entry, of the kind which we are expecting to address in pte_offset_map() - this might want to be revisited in future. Signed-off-by: Hugh Dickins --- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index 461307b89c3a..572707858d65 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -509,7 +509,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full, } else { pte_t *pte; - pte = pte_offset_map(p, 0); + pte = pte_offset_kernel(p, 0); kvmppc_unmap_free_pte(kvm, pte, full, lpid); pmd_clear(p); } From patchwork Thu Jun 8 19:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp499006vqr; Thu, 8 Jun 2023 12:35:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rBG8ht0JbQfiTk0EyXzlEKKLek85jrqcDWiL3OlmirfJHgGuqGuiG5cS0QkIplskHF7zc X-Received: by 2002:a17:90b:4a89:b0:252:bb8d:3dce with SMTP id lp9-20020a17090b4a8900b00252bb8d3dcemr4932346pjb.39.1686252914763; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252914; cv=none; d=google.com; s=arc-20160816; b=y3c+h8DKjC6S4u9Hp4N0PTAkoC0q7p5JTpgp50wXd+c4v6RUbChoHNhC0PD84252aq 95RTafET/OcD5GeMYiDqbwmGbM/3SzY7C1M+7faANZTuUDJs4n+vfBD5OlTu7k9yputm rNfMOwJMG/BJWrepQCp+oG3GEgUf41O34/5zbLwfsQtne+P/ky6XdH/IUeGPvBuRSKpl g9jxocdt1JwaP3xtJHDeB9iBBQNll8gKQ/tFxMBhApPn4ev+HVXSw4/apKNQpSPLsZ8P kbPCYVMfrS5Hqhr4SBX7zE/8M/kqC6p0QsUEW7m/OWxo8ktHlNi+x9voMc3W6Vz93I85 zCoQ== 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=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=VXVDhXVnW/57sd5zOaNpBi7fPSyK44Rg8UBYbMQugsOoRvOxToT4NNsCh23mUwh5+c Tmu/OHE1Dw1rCUjTzBQpOIo0Wh1ccEYVVKBHejej6KjwNHE18EZsXdofN/3tM3mBQ/br UMGx+M8KjcHj6JwxBnKa9aoYcqbZ9M+l7IolMocpYs8+MK9GPxczMEvBInUeY3r/Azzk ZBxQQb9WzLE3R4r/P/pLzBYiV7n+pZ6Lc/om+yyLm0vE0HHDp2fkUjrXYRF1+aPm7YA5 QMLNL9PgKFE3PvhsIsRKS8Rb4os3Fe8Gk51JY4Y5C9T67+mOnPd6GPji0riVBekDcJm/ cCGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=bsqS2Hso; 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 u21-20020a17090a891500b00253326d4e5bsi1483284pjn.57.2023.06.08.12.35.02; Thu, 08 Jun 2023 12:35:14 -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=bsqS2Hso; 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 S233419AbjFHTYX (ORCPT + 99 others); Thu, 8 Jun 2023 15:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236509AbjFHTYT (ORCPT ); Thu, 8 Jun 2023 15:24:19 -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 966563592 for ; Thu, 8 Jun 2023 12:23:40 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-565a63087e9so9111197b3.2 for ; Thu, 08 Jun 2023 12:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252220; x=1688844220; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=bsqS2HsoK/j3AkqW2YwOMMKXyawvBNLxJHVA5gOfV85QJu1lSu6OT/EudsU4V/Y2rp SVDrhg0mebSfRzfMSx1MBgwwDrAuWoy9LCmuC/2umX7ttwWByA3dcTWU9wXJ/cBuk8p1 IBLsaSZQWTiGTy2fVfGTVTLpxXSu83YUCgCeShfLhLQEtHAObGCmd/2pMwHoVzhnbL+s R/RqL9aWefb7+V22j+wCoHy3L9k9iU7LsdUzazOEG+iBjRzVfoBnNonp+eUMgHPu99EP wikBPo2R7DnOhGnbBte9FiJ408IVODR7hjXz04IiqDN6B3KGc/TbdicQd+c7pqZBIdYk E3bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252220; x=1688844220; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qDN5tZO3L77JzaZm0GUojeVr1G6nDfqvfBbmKnfTG1k=; b=LWFUc3e0vZYz5uio+Z+uIZmej9etMpVL2zcQ6i1N9rmJwHnX3+9/cHUpA0ko93cGvH 4s1CFAPa5RVH+AwQ0OkdkRtAfzBqEW/NNK2TJlpv3ImFOMV9Yo0FD4SE9X+4USFqEbge FMMR/TQLYAhJCiKleSwC0U5gva/PVPyuFsiCUOOcI2+t6MoeOoaOWCxcXP1/j6+3spmo wsAVXSyeWySABcd5GAPRAa6DZZLwsDtvKLt8sHuNp2ehYkL94q7yUGQWlB1JGq2SY0xl g/flzRpxi8Tv/8qGQObYbgCTiNIPPjhkMnBMpsU8fGRdHAAQbhF1WCszn2rRT10kHdHm qlkw== X-Gm-Message-State: AC+VfDy+734q0Os2xil3f8lcWtjV9dsIKj5fSYht9Yio6+kcpniDwRx8 +srQN/CVJeHlctkYHqdjmRcGTg== X-Received: by 2002:a0d:d843:0:b0:565:8c16:a0e1 with SMTP id a64-20020a0dd843000000b005658c16a0e1mr683325ywe.13.1686252219629; Thu, 08 Jun 2023 12:23:39 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id j65-20020a0df944000000b00545a08184e0sm102947ywf.112.2023.06.08.12.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:23:39 -0700 (PDT) Date: Thu, 8 Jun 2023 12:23:35 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 12/23] powerpc: allow pte_offset_map[_lock]() to fail In-Reply-To: Message-ID: <54c8b578-ca9-a0f-bfd2-d72976f8d73a@google.com> References: MIME-Version: 1.0 X-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?1768164336661837581?= X-GMAIL-MSGID: =?utf-8?q?1768164336661837581?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Balance successful pte_offset_map() with pte_unmap() where omitted. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/book3s64/hash_tlb.c | 4 ++++ arch/powerpc/mm/book3s64/subpage_prot.c | 2 ++ arch/powerpc/xmon/xmon.c | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c index a64ea0a7ef96..21fcad97ae80 100644 --- a/arch/powerpc/mm/book3s64/hash_tlb.c +++ b/arch/powerpc/mm/book3s64/hash_tlb.c @@ -239,12 +239,16 @@ void flush_hash_table_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long local_irq_save(flags); arch_enter_lazy_mmu_mode(); start_pte = pte_offset_map(pmd, addr); + if (!start_pte) + goto out; for (pte = start_pte; pte < start_pte + PTRS_PER_PTE; pte++) { unsigned long pteval = pte_val(*pte); if (pteval & H_PAGE_HASHPTE) hpte_need_flush(mm, addr, pte, pteval, 0); addr += PAGE_SIZE; } + pte_unmap(start_pte); +out: arch_leave_lazy_mmu_mode(); local_irq_restore(flags); } diff --git a/arch/powerpc/mm/book3s64/subpage_prot.c b/arch/powerpc/mm/book3s64/subpage_prot.c index b75a9fb99599..0dc85556dec5 100644 --- a/arch/powerpc/mm/book3s64/subpage_prot.c +++ b/arch/powerpc/mm/book3s64/subpage_prot.c @@ -71,6 +71,8 @@ static void hpte_flush_range(struct mm_struct *mm, unsigned long addr, if (pmd_none(*pmd)) return; pte = pte_offset_map_lock(mm, pmd, addr, &ptl); + if (!pte) + return; arch_enter_lazy_mmu_mode(); for (; npages > 0; --npages) { pte_update(mm, addr, pte, 0, 0, 0); diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index 70c4c59a1a8f..fae747cc57d2 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3376,12 +3376,15 @@ static void show_pte(unsigned long addr) printf("pmdp @ 0x%px = 0x%016lx\n", pmdp, pmd_val(*pmdp)); ptep = pte_offset_map(pmdp, addr); - if (pte_none(*ptep)) { + if (!ptep || pte_none(*ptep)) { + if (ptep) + pte_unmap(ptep); printf("no valid PTE\n"); return; } format_pte(ptep, pte_val(*ptep)); + pte_unmap(ptep); sync(); __delay(200); From patchwork Thu Jun 8 19:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp500517vqr; Thu, 8 Jun 2023 12:38:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5nfLLGvzNM1PllrRnI6HfQWgNO7oMlh9hgvvS3z8dMXLN+qkqB0j9oR2VpvC8SOg6EQYaW X-Received: by 2002:a17:90b:e93:b0:255:6c5b:3660 with SMTP id fv19-20020a17090b0e9300b002556c5b3660mr4549058pjb.20.1686253120620; Thu, 08 Jun 2023 12:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253120; cv=none; d=google.com; s=arc-20160816; b=GNYSO7VuSz6GEhqNi0IuffQ38paiXIDfYgQIHdxSlMzeGluOXtXczfUsBcPW5Gi0NV X+goyDHvZXawkSAAwujcIFbZsOXLE2sJq2G4RMi3Yg7jwD6DkwRBFIEvbMOV/Zf0vKxD 16Pvbfo2A66Ot7UAqGXGRnm4OilOIhTQn5opFV8T8kcooo3N0oxO2w2KrHQiy6RqBWKs MKZP0H6TNvcAEl4wmB4e6399ci/+aAR1g1CkCCkbEyDHlRClOlsmNOwTIT75KUBv+AQq i5t+ybTVrxdpjD9ducecDxBKj679WauqM1T2gh6Ks04BV49/VxvyruOw/DU6FPCV3nCz kR5Q== 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=T8W/lxfRNMuSiMPi4VVK/nF+vlFbEQ4cibUBYwTfFRql4JEpnvWnNZdHxK9dheYFg7 8jGNWfWYDFwTOEYzJJ5Nq0u5YQgKGnxvw5Jt/zDYx9qpZ3s0QKHzfpmHkMm50Z7pBzkM zsU44f8Hy0Aco53HP1zcvgpEePJBaOzXoSbBIKSs7wrFBZYCIy1OJNLzvNzw3f0nUJpa PXtcxKaf6A21TEtSgSvkP2kWJAP+CfZT0YStwyzH0hj0Y5TBtJdewGeb89f6svAgwwOH BSCNUt83zkAi6EKGWtoQD3kM2jq4KpbfJT0LhgNJSYY0/DeLWkQ9mo9FntHbUaTs27+d 0NaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Fizq3Xl2; 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 lb14-20020a17090b4a4e00b0024bc03cfa95si3136947pjb.156.2023.06.08.12.38.27; Thu, 08 Jun 2023 12:38: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=Fizq3Xl2; 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 S236639AbjFHTZY (ORCPT + 99 others); Thu, 8 Jun 2023 15:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236902AbjFHTZU (ORCPT ); Thu, 8 Jun 2023 15:25:20 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031EF2D68 for ; Thu, 8 Jun 2023 12:24:48 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-39c84863e34so36943b6e.2 for ; Thu, 08 Jun 2023 12:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252276; x=1688844276; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=Fizq3Xl20k0s99bdV61+X0NES9CrzdKWOse7eCbwtn1uu9/h4mE0n0kQt9PwBBK2XD BLlYV7LOU26RY2UNjTt4eTKg2MiSFQ+mNE44PGkBbtphVk3O0XARXhUyyawmE+XPjZkM EIuZgR8dgqHGa9xPUigE/FawhK1QiFlabNgVMomZeu9AjaWaPJZt0b1g6ImgUkyGd5Ls fLctCunPng5YblGLwKbDucX0igX9BBdDWTKtQ02LRRmnejkHdR4rcW59H7SIyTy+bUtn UJH+uR4By3Rz8RGak7Nu20/xco5IlkAXPoTxOravmVmGg5IIQRwIeYxmwmVdJLgwdVhQ Kkaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252276; x=1688844276; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i7vs80eeAHoowuGiB3IXr1R0pQ52ZVhylKFRPge1iSc=; b=G/nDSg0JsyX/vTAmDBIioOzGVmXtsHa0z0RyU973voyVz1i8BImYU2WTSJIBD7EIj+ hSTnbNK7zM2VIaqKpUUqy5H5gSfXG6aFSMKiEtN9Aq1jWgwDD1XI72un5OVsNgkCi29k hpyaG2YKDpF5dbPblfTOyXf4CzsoNHb45qgZFZ2BKEw8b1VCViRpx2x+SBfjui6I5wl+ LRr71aZWlXlR+2uu8qhAsqxqI4P2X8y2n7aH6SnQR8YX7pv07dvV5Te0oBNIPH3s/Dqw rQ1Q/6QTKBqxmJbiCWrJ9RTqxSjinBRMDQXhP4Bq/+L24siRp068QQxPm2PoWsdxDyux 7fhQ== X-Gm-Message-State: AC+VfDwWaVxKpPlgR7mb3+dltDQj0L9XlevjAUcFxO4V+QYL3UR/IVvo qtX0/7dFEYE/oO0c98T074/EEw== X-Received: by 2002:aca:231a:0:b0:398:2e8d:3ca8 with SMTP id e26-20020aca231a000000b003982e8d3ca8mr9311006oie.52.1686252276532; Thu, 08 Jun 2023 12:24:36 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id p127-20020a0dcd85000000b0055db91a6ddfsm111980ywd.73.2023.06.08.12.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:24:35 -0700 (PDT) Date: Thu, 8 Jun 2023 12:24:32 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 13/23] powerpc/hugetlb: pte_alloc_huge() In-Reply-To: Message-ID: <36b4e5d-954b-8569-4fe2-bd1797362441@google.com> References: MIME-Version: 1.0 X-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?1768164552255001983?= X-GMAIL-MSGID: =?utf-8?q?1768164552255001983?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead. huge_pte_offset() is using __find_linux_pte(), which is using pte_offset_kernel() - don't rename that to _huge, it's more complicated. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index b900933507da..f7c683b672c1 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -183,7 +183,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (IS_ENABLED(CONFIG_PPC_8xx) && pshift < PMD_SHIFT) - return pte_alloc_map(mm, (pmd_t *)hpdp, addr); + return pte_alloc_huge(mm, (pmd_t *)hpdp, addr); BUG_ON(!hugepd_none(*hpdp) && !hugepd_ok(*hpdp)); From patchwork Thu Jun 8 19:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp499092vqr; Thu, 8 Jun 2023 12:35:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tjs6hv68V4FXNrxBQRR4X3UMqLkKa6wxxwnGjVzKhxbsVaHNltDKp3VAiB8CHzrWUnrgd X-Received: by 2002:a05:6a20:2d10:b0:107:1f22:10d5 with SMTP id g16-20020a056a202d1000b001071f2210d5mr4683817pzl.52.1686252928512; Thu, 08 Jun 2023 12:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252928; cv=none; d=google.com; s=arc-20160816; b=vPRamg41IQVZBBorbiGEzYm8lf6vCa+DLdh+COTW06u+OewSB24+j7sBheHwan6I/7 axPzxZtcaImIofhdi0+cYf8FvPI8ghU8aHFiVrc6LhnJKJzefijZEYAb6gKQm0JKWyZf BeJ+pIo+gbLU0yqFrVjYIp/Mx81WSwrItjdts3I9uCdoGwlYcS8j6BwwvCdFWhxkxZcs hJ6m4EfhCI/4mvCXvPUaU5hrzieNkyVpb+zNBCZcqwNnkB2uDwJcv1FMsMMzpUbQUMSh QTSrXBSf2MJHKWNFTUfoYQEK5LNWdHhHIFa4uCaFEU4ae8AADMo0iTRUSYtb/GNcLwnm 8idw== 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=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=WGJQpfpEw3CqAbyIF5Kz4bU0bDjT8iNDQSoEiLrmNRrx2c/dHwS1mftZhnZY7mbiMW f5fCxznEVSPgXULrKbPO6DMMVVh4lYFSB0kGC4bMTGDa9YsvAjoKnDsUjsbQHLI1pIPB j3juSwel4YMRJHw8QAx2jD2U1bSmzzheSn3KF4ZSs/FmMOhxpzEUCKh0uaHNRZkjJDUS U2xFQiUUEqDvmlMXq9wKPqr5XB2Z0CBTBO5Apnkr1R4y/hOrnevZ1xpx71UrPCY6mFub lVsO49LtVvKy11t8d+gK1+9aP4HkpT9zgzqGXigaj/al7VZiDS9H6m/rhHwckVtxLmxV ZGYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=WSe0O+xW; 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 t1-20020a639541000000b0051b48085aaasi1324898pgn.858.2023.06.08.12.35.15; Thu, 08 Jun 2023 12:35:28 -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=WSe0O+xW; 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 S236396AbjFHT0Q (ORCPT + 99 others); Thu, 8 Jun 2023 15:26:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbjFHT0O (ORCPT ); Thu, 8 Jun 2023 15:26:14 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AE9B30FB for ; Thu, 8 Jun 2023 12:25:48 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-bb3a77abd7bso1056884276.0 for ; Thu, 08 Jun 2023 12:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252347; x=1688844347; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=WSe0O+xWHB2ydCbpeLzjHJf6lubD6yWbrbalQ09CW2PLGKbnuv/YCHcTjEklbftlDZ Bn+TBag489vYl0Kx/QEnd/hNvW0BHOeSak/CZxA051qj0HRROKgCePvrRb9MuwQ21RPo UFNVPP0fFgD2zP3vXEkAAHs7IbIEd7kCFa41GIq/o5fS7gcYFt1t9fsorCogUddAyQAa gvgPXc4Mu6L9KlRIpGfWDTGDmUnx/ZwV5Hsai5H4jlYjdflYF6WjfS5QYRdpLJc33lMM tuIWNkxAGrXRoIS+Re+Ik8k2cuYZR70rphrz9RjLzYXiNApKIhKEFjqSjiunuGbiEcPL 13ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252347; x=1688844347; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OY1uPF9EWokdB4SqfwvScqZ05vH5KIzX3bnt2mFlrzM=; b=hsZrFC9EwTBxZHYAH2m4E3Szt31NeWJ2EwwqnVqXV62lbi8tSccLoGHmkfZXFrZ6lt Z/ER53ai79EIZO+rXEhLxHK0fBpZH9twIyj+t5KW9fxpDCyx4Yn2lmhpsnlUqtzcMYAi yOT0jb4saMJV0HRKUIAlouiMOGzDumx2tjMReOF/NRN4AhPXbzOtPhP0NVfJOFexuZao z6mFn3abf0it/FVK870AvTJxhwlkagJ9IizhCD7VzQK93nY8nqbTmkxQdAOQjVfLEPD3 Wlw1XGwRNLu37aFIU4hJhxOLqYPHXKP+Q8hbjyY2dqoJNhHDjTCgt/AllwkTo5euUS/s xW/w== X-Gm-Message-State: AC+VfDwA+ZcyLzubd25raO2TucrkoKvKFcJhNdSGCk8wxMTrD0Olbz3c hp+WneAcmjWBgVmuqGdo+J5WwQ== X-Received: by 2002:a81:9144:0:b0:561:da0d:6488 with SMTP id i65-20020a819144000000b00561da0d6488mr460871ywg.50.1686252347196; Thu, 08 Jun 2023 12:25:47 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id y62-20020a0dd641000000b00568938ca41bsm117859ywd.53.2023.06.08.12.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:25:46 -0700 (PDT) Date: Thu, 8 Jun 2023 12:25:42 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 14/23] riscv/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: <291f20-5947-9f5f-ec7f-96a18df336d9@google.com> References: MIME-Version: 1.0 X-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?1768164350729932675?= X-GMAIL-MSGID: =?utf-8?q?1768164350729932675?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins Reviewed-by: Alexandre Ghiti Acked-by: Palmer Dabbelt --- arch/riscv/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index e0ef56dc57b9..542883b3b49b 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -67,7 +67,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, for_each_napot_order(order) { if (napot_cont_size(order) == sz) { - pte = pte_alloc_map(mm, pmd, addr & napot_cont_mask(order)); + pte = pte_alloc_huge(mm, pmd, addr & napot_cont_mask(order)); break; } } @@ -114,7 +114,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, for_each_napot_order(order) { if (napot_cont_size(order) == sz) { - pte = pte_offset_kernel(pmd, addr & napot_cont_mask(order)); + pte = pte_offset_huge(pmd, addr & napot_cont_mask(order)); break; } } From patchwork Thu Jun 8 19:27:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp506230vqr; Thu, 8 Jun 2023 12:52:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7j4mgCgBhaVQuvu4OIYtXIInWDahyr2FbxSqIFg/NUF1b1DcKO5gCPM2jHHBTaL5QdGRzh X-Received: by 2002:a05:6a00:ad5:b0:649:93a7:571b with SMTP id c21-20020a056a000ad500b0064993a7571bmr12008694pfl.13.1686253971721; Thu, 08 Jun 2023 12:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253971; cv=none; d=google.com; s=arc-20160816; b=A8gVC1JsegnOsYX6woDdbH3NM/cgKdfwJCQw4BEcPkueMxsLry0u1+Nvfi9LUN3tCV yvoPmk5XccpHFdgRo89cWYHengFeXf2gJswwd7B1dXq70lt99tCp3izmCOAevJrehpk/ N07mzR7F2hfn9HiY3Qk9fWactxpqW3AbU5tn2HRBy6Ur68Fbx0Pa1WSOzyVGHQxhdT1q dDm+OxpERmaexcfdRXxB1nyzBSAElw4z/bs1T7CfwLbIKgV5X07reixgsZJ0wZeV9dkt ewxiCvdR+3GFeR34P8we6P4+YMyq2KlD+lCPWRoXd3YwO+NCjP1cSSKkindZteg99JcS p2sw== 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=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=wuHLtQT2bfKdQ4L1X2lHUAUYcyCkJUluJh2WEEh2/o04mbsbdZykmmvvFAKt5u4ocM 92zfwL9Q8bPW5W/yJ2ur+hrC8yf/0uqmGD4AQynasS9F85mSKIhR+JLplkkmmQBL/ZjP voia2SEhsduwsi96UenQmyMIbRa6DY6DrA3zVbbQJwdJxte7RLjLWtipSiHZpYdfeTCq SO9SB9qf0yRCxgphSbVVM3SoV1n7y09blf4qgWgB3+b6Sf2hLCIcqytXz5PBfrGra1cg n2Rq5d6aBMDAWQ1MTUOswfPkAmBTjuJL9NPxHCvM2vBUKg0KOW20zo80smgfGdnv7pjY LQAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=qeZyDOuR; 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 y17-20020aa78f31000000b00662ba7f8a5fsi1250411pfr.170.2023.06.08.12.52.38; Thu, 08 Jun 2023 12:52:51 -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=qeZyDOuR; 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 S231569AbjFHT1o (ORCPT + 99 others); Thu, 8 Jun 2023 15:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233333AbjFHT1e (ORCPT ); Thu, 8 Jun 2023 15:27:34 -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 336E62D55 for ; Thu, 8 Jun 2023 12:27:28 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-565ba2c7554so8716187b3.3 for ; Thu, 08 Jun 2023 12:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252447; x=1688844447; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=qeZyDOuR1Ocm6uD+TD8H/qooj7RzNFAiwCA/UqStNTHWJ9eTjvcv/8Jq76xJdFB16m 9vZjnF1AyEaJnSc8jl/F1i1cVEQ7u2Ksx/OtGK4kAnOQneochRX+8Uo2nfHZ+IrggDdD 8+N7/1JLxtH1E0e/CwR5x6nt/ET/TtrIOFNieXovV1RuuXkZkQgSV5Jae+9SGKAEV2ls YNv4h9+C2a+hHml6224b2D5gDdWuYPDND/n0XtPM1ecc2OJLce4FWSFBO4HGDd7/83bC 7o6bLjq43ZCC/kx1k33o8ly3OOe+X/CVjUPlD/YBOO/8+E1ljdocxCQmjAw/takWi4D5 1nfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252447; x=1688844447; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jq3xrA6xvDVzvCSVs0I+t9KBGN0vgt1rJHLesOzHUeM=; b=BXhh9QBW5MHlcaMxklyG8+d7Dk6hlCJMmpuvLg1t//+/pdochjmsKMxwJTOqiVzC95 QmiMHmgIVR8ADa2kZCzakm2eeKJyVcaro67cgQyV/K8Ehrxq0zmdst9NjXHuaRLjXZNF KIz/VZrlY13zJEjq6fEMy54CUu7zUquZgOe7xgiOpEdSZuZAUBqbTg0u9hdTflsPv0n+ 9TG3mv4q2Fi0a+83F1VpmGsv1rbIa4Z9pkKGN33sVHavMQLhMFldbIIbnYbcrhNssapA 3vZ5IcB46Yt1DsO7evjJv40y0WNPXNICoC7n/717sialzwdy6cRiqaaszteLdlEKKzPP Q6CQ== X-Gm-Message-State: AC+VfDzUyhfPk8MU2r73cmoT4IYsn2wIELrYYCaztUhbxGKQOt8gSqXF cdK6P3siRnU9egi1aryclFjF8g== X-Received: by 2002:a0d:ca88:0:b0:569:fdd1:24a7 with SMTP id m130-20020a0dca88000000b00569fdd124a7mr493494ywd.51.1686252447226; Thu, 08 Jun 2023 12:27:27 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id f123-20020a0dc381000000b0054bfc94a10dsm119559ywd.47.2023.06.08.12.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:27:26 -0700 (PDT) Date: Thu, 8 Jun 2023 12:27:22 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 15/23] s390: allow pte_offset_map_lock() to fail In-Reply-To: Message-ID: <3ff29363-336a-9733-12a1-5c31a45c8aeb@google.com> References: MIME-Version: 1.0 X-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?1768165444408316321?= X-GMAIL-MSGID: =?utf-8?q?1768165444408316321?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Add comment on mm's contract with s390 above __zap_zero_pages(), and fix old comment there: must be called after THP was disabled. Signed-off-by: Hugh Dickins Acked-by: Claudio Imbrenda --- arch/s390/kernel/uv.c | 2 ++ arch/s390/mm/gmap.c | 9 ++++++++- arch/s390/mm/pgtable.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c index cb2ee06df286..3c62d1b218b1 100644 --- a/arch/s390/kernel/uv.c +++ b/arch/s390/kernel/uv.c @@ -294,6 +294,8 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb) rc = -ENXIO; ptep = get_locked_pte(gmap->mm, uaddr, &ptelock); + if (!ptep) + goto out; if (pte_present(*ptep) && !(pte_val(*ptep) & _PAGE_INVALID) && pte_write(*ptep)) { page = pte_page(*ptep); rc = -EAGAIN; diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index dc90d1eb0d55..3a2a31a15ea8 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -2537,7 +2537,12 @@ static inline void thp_split_mm(struct mm_struct *mm) * Remove all empty zero pages from the mapping for lazy refaulting * - This must be called after mm->context.has_pgste is set, to avoid * future creation of zero pages - * - This must be called after THP was enabled + * - This must be called after THP was disabled. + * + * mm contracts with s390, that even if mm were to remove a page table, + * racing with the loop below and so causing pte_offset_map_lock() to fail, + * it will never insert a page table containing empty zero pages once + * mm_forbids_zeropage(mm) i.e. mm->context.has_pgste is set. */ static int __zap_zero_pages(pmd_t *pmd, unsigned long start, unsigned long end, struct mm_walk *walk) @@ -2549,6 +2554,8 @@ static int __zap_zero_pages(pmd_t *pmd, unsigned long start, spinlock_t *ptl; ptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); + if (!ptep) + break; if (is_zero_pfn(pte_pfn(*ptep))) ptep_xchg_direct(walk->mm, addr, ptep, __pte(_PAGE_INVALID)); pte_unmap_unlock(ptep, ptl); diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 6effb24de6d9..3bd2ab2a9a34 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -829,7 +829,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -850,6 +850,8 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | PGSTE_ACC_BITS | PGSTE_FP_BIT); @@ -938,7 +940,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -955,6 +957,8 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); /* Reset guest reference bit only */ pgste_val(new) &= ~PGSTE_GR_BIT; @@ -1000,7 +1004,7 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -1017,6 +1021,8 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; pgste = pgste_get_lock(ptep); *key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56; paddr = pte_val(*ptep) & PAGE_MASK; From patchwork Thu Jun 8 19:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp501057vqr; Thu, 8 Jun 2023 12:39:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xmfksBf6lS0kb/fW3rxfhrstA1r30w2TyTDO1/ey5Hc/I5u24/toDOzTGvEhbaoJn0li/ X-Received: by 2002:a05:6a20:d90c:b0:10f:a954:47d1 with SMTP id jd12-20020a056a20d90c00b0010fa95447d1mr4518351pzb.38.1686253193024; Thu, 08 Jun 2023 12:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253193; cv=none; d=google.com; s=arc-20160816; b=0AEkvyF9vKrEVy78TSEJaelghcMQ6WZtXI1bnd43HSYTi624S/mOUIX9YE8Jf694Ey 46Tdx3CUmSHzhDplN0lXq0A52YkKd8VBSRoOwFvAnS5wX7sc/ZPTMk8QRcDgoW3/w2dJ QZHlp2z09xkef6vznbsjbpBHdJePmob3EtSsSDBu+WxgR3/6+3OqJBGzE5v2eOgcp3MI i8Q2C8Trji00J6vItJvdOzT9RY0fBbd1sgivXWv8z038hn0LUiO1iShpFMSJyegtuZNb EH/wiT9Jbf6yITXf+wocnt1+OqZ/ubPoqZhFp91p9zmOu32L+BDOZpaWQiPW/CvuQODq 9FNA== 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=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=l5FvAYnBTyjPMTcjUx5f+FHwuvOHiJKF/ziH3Yz1FdeXWM6srBuXqtRexOE7lr4V/3 9uKXqjtiTnlobyy/68Pz2iSxX0pBceVEpBmDczbCq9rTcGbatExN3nKWE61GlyuubUiP BUNOlhemFR9pbT2baHDmBxKKiSHbUNfkiVh1X+CiNf/pbv9UP3WQ8bcmcaXvBUhLuJQy 6wU9PsQxWOjEdFGIlSq2eQYjZbB05WoYlULhD9mU2W9/d0rQQQ7vmEvy7c3B8od3pHp+ FfHssRvzQVNIWK3ow/dn2dKI00+kIW0bD/V1hJPldIWrdqefPmQ1+KU0Y9wyLC6Ga65l URlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=WqCUQyh4; 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 b27-20020a63931b000000b005304a8af2adsi1430187pge.392.2023.06.08.12.39.39; Thu, 08 Jun 2023 12:39:52 -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=WqCUQyh4; 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 S234171AbjFHT3Z (ORCPT + 99 others); Thu, 8 Jun 2023 15:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjFHT3V (ORCPT ); Thu, 8 Jun 2023 15:29:21 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC562113 for ; Thu, 8 Jun 2023 12:29:19 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6b2b7ca1c5eso58482a34.0 for ; Thu, 08 Jun 2023 12:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252558; x=1688844558; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=WqCUQyh4fb72P3Kw38oeD34IYgDMZUJWpeeOOH7KwWFkTIkJBfiV3ibZz3gZzYLVxl lU1gDOTGIJCl22/qWpu3I54yHV8hXoWsW3bLvMizUe696eD4+w5NMItSw+ZsMJ2if+3a 8lw8VtiSVvPlHQ/Z7+Qgoipy0NwOKSeRkxeZtlOJSgMtgwHhJFZs8ezKvYFf04NNKV0B o9SvBbVJSNYcgeP1FcAifK+xGopk05Di+EjON5dZeXWscPS5ozLfdvYQvh8DkNTWidtB R65qDn5ks7oQgy0HqDzv818p/gf4omkafkLcO+z9CO+/iNtMlszDRH4pSfFhaygbIVXY l7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252558; x=1688844558; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=htP458HkQOxv1YJRD6pA18DA04i7K6/u04f92CnMfB0=; b=gclMxU0Pxq/0/HAXLqxeS685cIQiGMv2GLex5yHL82e1qhE3PJWbrFqJJW1vW/Bp+S XjsiQ00p9MtDLs35d0E8CBkj9EimFK5hNrc4KaTJAj43IUeDodqKgERKSaWcUnprK1pw +TcVInsIsu8UxYqNDFf1rkWcjXDE9W4NGEeR0kh2xJHMq6dHl9mFfv6oINeaMOgeW9ci GQMQwztLgM02/ghqFdfPlJ6ZBio8IfzqySw5ekVuRX5GQii4zS+8nzRCWyqAS2azoGgS rSm2IUgD4sPuePKh4MhSDrdxNheFQsg5N80sUxO0tNwPhwpszf38Al4ujVzAR8BYmG8F IFfQ== X-Gm-Message-State: AC+VfDz5q9347ED5MWxxma0GsgC/mv73WrLKdQifohgSgYCTWAHBOwVJ bOza2bcQa1LXk3tauF2/gf2Ffg== X-Received: by 2002:a05:6830:86:b0:6b2:94a2:2236 with SMTP id a6-20020a056830008600b006b294a22236mr9332824oto.29.1686252558452; Thu, 08 Jun 2023 12:29:18 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id o199-20020a2573d0000000b00bb09977b0basm455193ybc.6.2023.06.08.12.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:29:17 -0700 (PDT) Date: Thu, 8 Jun 2023 12:29:13 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 16/23] s390: gmap use pte_unmap_unlock() not spin_unlock() In-Reply-To: Message-ID: <78873af-e1ec-4f9-47ac-483940ac6daa@google.com> References: MIME-Version: 1.0 X-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?1768164627929530218?= X-GMAIL-MSGID: =?utf-8?q?1768164627929530218?= pte_alloc_map_lock() expects to be followed by pte_unmap_unlock(): to keep balance in future, pass ptep as well as ptl to gmap_pte_op_end(), and use pte_unmap_unlock() instead of direct spin_unlock() (even though ptep ends up unused inside the macro). Signed-off-by: Hugh Dickins Acked-by: Alexander Gordeev --- arch/s390/mm/gmap.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 3a2a31a15ea8..f4b6fc746fce 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -895,12 +895,12 @@ static int gmap_pte_op_fixup(struct gmap *gmap, unsigned long gaddr, /** * gmap_pte_op_end - release the page table lock - * @ptl: pointer to the spinlock pointer + * @ptep: pointer to the locked pte + * @ptl: pointer to the page table spinlock */ -static void gmap_pte_op_end(spinlock_t *ptl) +static void gmap_pte_op_end(pte_t *ptep, spinlock_t *ptl) { - if (ptl) - spin_unlock(ptl); + pte_unmap_unlock(ptep, ptl); } /** @@ -1011,7 +1011,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, { int rc; pte_t *ptep; - spinlock_t *ptl = NULL; + spinlock_t *ptl; unsigned long pbits = 0; if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) @@ -1025,7 +1025,7 @@ static int gmap_protect_pte(struct gmap *gmap, unsigned long gaddr, pbits |= (bits & GMAP_NOTIFY_SHADOW) ? PGSTE_VSIE_BIT : 0; /* Protect and unlock. */ rc = ptep_force_prot(gmap->mm, gaddr, ptep, prot, pbits); - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); return rc; } @@ -1154,7 +1154,7 @@ int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val) /* Do *NOT* clear the _PAGE_INVALID bit! */ rc = 0; } - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); } if (!rc) break; @@ -1248,7 +1248,7 @@ static int gmap_protect_rmap(struct gmap *sg, unsigned long raddr, if (!rc) gmap_insert_rmap(sg, vmaddr, rmap); spin_unlock(&sg->guest_table_lock); - gmap_pte_op_end(ptl); + gmap_pte_op_end(ptep, ptl); } radix_tree_preload_end(); if (rc) { @@ -2156,7 +2156,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte) tptep = (pte_t *) gmap_table_walk(sg, saddr, 0); if (!tptep) { spin_unlock(&sg->guest_table_lock); - gmap_pte_op_end(ptl); + gmap_pte_op_end(sptep, ptl); radix_tree_preload_end(); break; } @@ -2167,7 +2167,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte) rmap = NULL; rc = 0; } - gmap_pte_op_end(ptl); + gmap_pte_op_end(sptep, ptl); spin_unlock(&sg->guest_table_lock); } radix_tree_preload_end(); @@ -2495,7 +2495,7 @@ void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long bitmap[4], continue; if (ptep_test_and_clear_uc(gmap->mm, vmaddr, ptep)) set_bit(i, bitmap); - spin_unlock(ptl); + pte_unmap_unlock(ptep, ptl); } } gmap_pmd_op_end(gmap, pmdp); From patchwork Thu Jun 8 19:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp506581vqr; Thu, 8 Jun 2023 12:53:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tdohfEITNlUmMN0KeF/bNWJnPHaP4YYQHYkb10lFN1xl+jp4OdfRSzv+UKC2Vc/tUHhGy X-Received: by 2002:a05:6a00:cd4:b0:64c:e899:dcd1 with SMTP id b20-20020a056a000cd400b0064ce899dcd1mr13620786pfv.5.1686254026460; Thu, 08 Jun 2023 12:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686254026; cv=none; d=google.com; s=arc-20160816; b=WkNhWHv0F6NQLHKYqPUVB/b6QTeLMOPSelMTLejh0Bvu26mlAFMKxGwD5ItngYPHaP yD2PSdfS0TJKHsYmTbAhBJOtk2+nc+nvcS1kA68ctQ4T1lWroF9giNjm1nKzySDyL86x rF4n+Th5cL0M81/jEtqWo+Y12GBT79Cx8SIBpazlJ1fTHGKG0hUKKQQW9sqSrGEm+Dy0 H8ICiEtlE6lWZgytz202OEOr7Kh+Tpizjw1VwQVIuTwD676NOGyk3TWqdIEa8QY2S94B BEbcNq8WVLhxp2Hmb54xUhIVAg+M8RegqOxMOEaST/dWW02iERQbv4FHSO81lJgbEdlK c/Bg== 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=na7gGtVBd8MRHgcUfTN1SCar6ToANLp++QKM81bpVTuzhltBhhFeWCieiH2F/hkP4c kKDc3yu06/e8ANlO0i+q4/xItMmU0U0jv1LlIc3aX/frTUTkITi78O6uDGcBpp8zhsM3 6IUri4gOl4yOii5asCgntGkbFz+jqRc8iTPar9Qa6vbErG/xKpx6FnsIBcZoh5Btnlqo bUAR1LJWkcvejE91d046IYPXzf9Upb7y8UqpJ/NgdeAasD64sGFhYS5DTk7+zDp0fyif go8HZolgq8eLj91BxW5G0qcMEAhMgcUTy7EjOuohM0gVMC2noZQK7peT+jkGVSQnAbwe 5ThQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Z+1ROWx9; 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 z17-20020a637e11000000b005348549fae5si1451879pgc.252.2023.06.08.12.53.32; Thu, 08 Jun 2023 12:53:46 -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=Z+1ROWx9; 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 S233422AbjFHTad (ORCPT + 99 others); Thu, 8 Jun 2023 15:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235589AbjFHTa2 (ORCPT ); Thu, 8 Jun 2023 15:30:28 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF9312134 for ; Thu, 8 Jun 2023 12:30:19 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-33b04c8f3eeso4381495ab.0 for ; Thu, 08 Jun 2023 12:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252619; x=1688844619; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=Z+1ROWx9LnxdX5nt3Yo9Gw9A1LjKJHFc2WtgcRAYaFIpj6m1+MueknjL2tetH/Yt/E Jkma5NMQVv2CGzmJBnvKYmHLILgxFTZBZe29Vg5F330+u2fSbBPVEtX3NRx2YFJBGUmp kCJjjc7KvjHhyEDucY5j+/eHT1OpuVlzl/VgAMVyKWRQ9P9ksfEE7oKQrQHB2ZVzogis AlGkparAM9e3I8OX/wc+UGRKJ9WTDNWGaUDF7YaTiCVpSxpo1NNn2hyrTeXSAmMOPutQ TUN3B1UmJFKBBqlJCwM8cMmQBeV6xJ4ogL/1WbFBc8kxJTJPQLfJ0hWbM0sLcNxIcm/D dTzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252619; x=1688844619; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mCwP+3tlZqvvMSbN25I242CI8N2o4w3/6RVIlVlj13g=; b=HOM2GwKIR67WYuX8Vnyx9M97cqzy+DLF/lehMWxTlMG6vRJLbyGM+isz6mngd/lG74 4aeTewjkJ1LAt+z5nBVCWsUm0033HsWl2ugHlYFgfEJhltf/EP/+g2aQDzzzyn2d/Qhv AVWNtz0NuVaEGsy69/s33Og7MampQaZsjd/5VP6hVUF8RlfhnwR0zfn9NdU+Yr8aMKZb 29jfU8ma7sE3sH5odE0OGN6Aje5AM3tjc/Wb4XYsRw9rhlpYq84KB8piRl9kubXrS8Mw 8dO55eFj0E8w7bQGgFOqEV0vuuiGUx/m46aDPCSQxS3KYp21mXbM9OEkFAwTAZ8QE/pz IQSA== X-Gm-Message-State: AC+VfDwuRIV4q0SYiDOiUkRWFYpZZe4cp92MUg+JlkBWtSxSpcsYpcYa P7m8GhFqz4Ny/HLSsDCdahMnWQ== X-Received: by 2002:a92:d34a:0:b0:33b:820:41ad with SMTP id a10-20020a92d34a000000b0033b082041admr8096921ilh.9.1686252619199; Thu, 08 Jun 2023 12:30:19 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h184-20020a256cc1000000b00bad07875d9bsm450282ybc.11.2023.06.08.12.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:30:18 -0700 (PDT) Date: Thu, 8 Jun 2023 12:30:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 17/23] sh/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768165501863022803?= X-GMAIL-MSGID: =?utf-8?q?1768165501863022803?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/sh/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 999ab5916e69..6cb0ad73dbb9 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -38,7 +38,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, if (pud) { pmd = pmd_alloc(mm, pud, addr); if (pmd) - pte = pte_alloc_map(mm, pmd, addr); + pte = pte_alloc_huge(mm, pmd, addr); } } } @@ -63,7 +63,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (pud) { pmd = pmd_offset(pud, addr); if (pmd) - pte = pte_offset_map(pmd, addr); + pte = pte_offset_huge(pmd, addr); } } } From patchwork Thu Jun 8 19:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105112 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp498845vqr; Thu, 8 Jun 2023 12:34:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ781n5RECZbdpAAs82+P5NLDRx4pEWu3/u80EcvfQTZpIhFr92OnGp8h+MMTuxQcYn96jgD X-Received: by 2002:a05:6a20:a5a7:b0:10c:6dbc:2806 with SMTP id bc39-20020a056a20a5a700b0010c6dbc2806mr7960135pzb.46.1686252893463; Thu, 08 Jun 2023 12:34:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686252893; cv=none; d=google.com; s=arc-20160816; b=ccd7I1d0K6GqHE0bIGY+RSbxaBOuwxRNeL15tawDvNf8RKwYZvhYUiGQgENgft2v1m Anflz71TI5TLMLed5loDozPpmSJTzSEKtO0XhoulupevpikQ1N0rqRuk8E4xPf1akf/5 vCluPgPDhJFwxkOr12tz5zEL6AMV247gWyRNNzTMkgYKtO7n6ZsGpylG6rjCmNyY4sQ4 jwhAJSawhEKvN1MmaxhqqCFNoR+zaIzf2C/3AfrJhuNokPF3L5UEaAbSYsJYZewG8+Ws hnBE6+qZZtJA67qqaBvSwO1d9EbeDtAfX3krMnBgfkzkTBBxAnrEzcq/UQp4m3WDGw6n 5CPQ== 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=bgZjNOCDtPX/T12BVlaHx1iXBgaZRVk6rHql+VRXbSlrzMIRQvrFn8ZupRTwvJSFbl GH//s59njne7ZCLEheiWNHcFmqLIO9BqKks0708+OwURx4KnixqKTCjgl1E5VtUBxUir TULdDQLfpt2o1uvGw9K9rr4bHMkCbVqMdq3pynSsvPhF3a6Ubb1TgCx9S+rqHZT8mkwm QHNUO6Qbb0MdR5bROwUONcYVeRVGY8a4a9vRYpJ6de+m7mhl04wMidaGQ537fZNoFoMO h53Gk4FCurdqJQTdwX55e2kZp3ShRR8oBui/zMh0n4BFPXyfysBOj75G1p/izMQOVoJX YCpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xraoP+ub; 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 t189-20020a6381c6000000b005346d98e741si1457415pgd.50.2023.06.08.12.34.39; Thu, 08 Jun 2023 12:34:53 -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=xraoP+ub; 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 S230459AbjFHTbo (ORCPT + 99 others); Thu, 8 Jun 2023 15:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbjFHTbm (ORCPT ); Thu, 8 Jun 2023 15:31:42 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDC52D72 for ; Thu, 8 Jun 2023 12:31:16 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5664b14966bso8804877b3.1 for ; Thu, 08 Jun 2023 12:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252675; x=1688844675; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=xraoP+ub8QawPiBDd1NtmoCJ7Yde5e/+U+FNO1p7rYE1UZXZOAo1PDwcjZq5EwJthR dV+vHCNMFKAoTdxBpkTX1DtrPJTkyYQzzcTJ6+Hvz6BbVAyle5wD2VnxGl+fo8KRjuW1 6lph5KG8FATG8Els+mnLkzVfzKtCZbvKkrDIrFy8tA1swRHwRpg7mlfmIfHBFYp2tEz0 /MtFJlEM4CazKliayJD7LKXK8RlITlLW8oxbTF1Qs6fFP4vrk+enY/g6/q9Fbkg7+DmC flfsqeHeLuLJ1bEDqfGSKk77gUrt/I37di/bcF7XR9pfVd+mrCw58/52flYr3BiOm9us kFmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252675; x=1688844675; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LRrENG7fj4nSEA3qiqmp7KZ6RwcG7U0j5SldGyBNlNI=; b=P3E3Gh2GxTFGjSIgw4VyeqGMmBundosxNwyieNExClAI5KIgocVOxreoMXLIZ9mARB ss9jpbXDQXUCppjj3rbrRvVUCFZxzlfj10sZtVQs9PcgdNFnnEd2+MNILoq868xDskIg ffwxTthWRA+B5/8bJAkGFt8L3Y4/GX1UEGvmsqVuJfgABQ9f2cIe3NHLbvFjdeM5jbh7 dg4ZMpYICKuF/fkTY3p+dEp2/oamj9zJqt4gEC1DwRc39mkQKuNmXl/8JPGMWUq77VKE GOiGxPIjoixvjKitgbS0gkTozQ4NMwLWMabmW4o1YaEj9jLaXL96acT3M3iIDKEPxsXx 81fw== X-Gm-Message-State: AC+VfDzIlV1TZaW9SE7KWj2CNlQx8FUjLlVUTJPym3x/xBj1e4zGb8qI PG2iSMJOlioPYC5kWE+VIiq0YA== X-Received: by 2002:a81:8986:0:b0:561:d1ef:3723 with SMTP id z128-20020a818986000000b00561d1ef3723mr688963ywf.38.1686252675399; Thu, 08 Jun 2023 12:31:15 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a6-20020a816606000000b0055aaccfa2c7sm114090ywc.91.2023.06.08.12.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:31:14 -0700 (PDT) Date: Thu, 8 Jun 2023 12:31:10 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 18/23] sparc/hugetlb: pte_alloc_huge() pte_offset_huge() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768164314032668633?= X-GMAIL-MSGID: =?utf-8?q?1768164314032668633?= pte_alloc_map() expects to be followed by pte_unmap(), but hugetlb omits that: to keep balance in future, use the recently added pte_alloc_huge() instead; with pte_offset_huge() a better name for pte_offset_kernel(). Signed-off-by: Hugh Dickins --- arch/sparc/mm/hugetlbpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index d8e0e3c7038d..d7018823206c 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -298,7 +298,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, return NULL; if (sz >= PMD_SIZE) return (pte_t *)pmd; - return pte_alloc_map(mm, pmd, addr); + return pte_alloc_huge(mm, pmd, addr); } pte_t *huge_pte_offset(struct mm_struct *mm, @@ -325,7 +325,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return NULL; if (is_hugetlb_pmd(*pmd)) return (pte_t *)pmd; - return pte_offset_map(pmd, addr); + return pte_offset_huge(pmd, addr); } void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, From patchwork Thu Jun 8 19:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp503442vqr; Thu, 8 Jun 2023 12:45:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Kfiv2pU4DP/+Njt3AENdRoSKSLAYPZDa+T+6lAI+fGP2v5JJFVzRqQJ9YnzFbQSe4Pzhu X-Received: by 2002:a05:6a20:7351:b0:118:e60:35 with SMTP id v17-20020a056a20735100b001180e600035mr4919093pzc.5.1686253546379; Thu, 08 Jun 2023 12:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253546; cv=none; d=google.com; s=arc-20160816; b=l5raSP2NUdyrFwJ+FHzDeuY35BFcaU20WWOe1ldySMjES8G3u1Q1jiIi3VTiJR93+J 1Sv/0B0Zv5grm3WKGSOfeMih78krFzPUkWtGPpdIcsTnXJVovxYOz9B7wuWPvafsJmcv 5Q6HsHCbzyivkjWAaSjLteqtmBxYz0fCc0ULnQdaOjW/hcyi7mC4cAxPUe7Bj1voe8cz EejAwPNWSKODv26qRmPpDnHhmjYfpx2cF0GmdSlGuzTrphLQYiR0pf054AJZYcelD5o7 AAKdRqQm+dIi2Gmo+VNW2EnMBZUic8nrnyNz1rBXWPv4YYqIxqrMUnaV6SeBujQ0zIdA sovQ== 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=wkSC5+zhHHcmbwA6+UKlemItsEx621QsMp9fIUTABqvHOtPdG1mvYvQRqj9ge4XYmJ X9rA3SWKWbEBrqUc5SPtSFlqRLNtFmV3s47dtI9tuf2BrFUCc2RBazVyxK5G+wx/n6Ny xGb1baUOpjizXewKAaNKdaKs1WxX92rinoUBgdfJzkE6E4a81OspsvJdFEHh96dckwAW vpwQp3Zc9Uzo0YrTn59wf7o/bM1A6tVKrDmgytKG1i8+VXLRIzVAhL0Hrjx6NCPAQNaT cqkYJi5hL9KxcuuzaEyGhMJ0MyE9UlJgGU/3FgLqgwa/U2xg5qhLzpQTtz7FvRD4mXXv XDtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=24t2BtFN; 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 g2-20020a636b02000000b0053eedcc332esi1323584pgc.763.2023.06.08.12.45.29; Thu, 08 Jun 2023 12:45:46 -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=24t2BtFN; 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 S232280AbjFHTcq (ORCPT + 99 others); Thu, 8 Jun 2023 15:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbjFHTco (ORCPT ); Thu, 8 Jun 2023 15:32:44 -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 C17542119 for ; Thu, 8 Jun 2023 12:32:41 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-bacfb7acdb7so1080729276.0 for ; Thu, 08 Jun 2023 12:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=24t2BtFN5HXeEnWp4wmjqaz3ba7RZTv3BWN8E2lDsHPicXiEJRz9TlH2WLVzGd8CdE of2yNqyqdnSUhfcGIlOsfvovWhpuG53taZz/x9DR/Th5PIOmYH7IKtDML+zGnAiDR7yW CrmldFZSb2omivw75gysl+pOyy7IV7uE8SzN+doaYOlbMw3OdLZlcS0TMi0ZgvmIeRDQ MJq/tuPeT8xPnNmBXjEKmMP3qPQGwnStEjRQklqNa0dtkxFHtF5PvuvrSEAvR9DPSdcW McnyT5sGz87Djsd0XbZMK04rqnZG7iDmeQmmJXSZxSQJU2i6hoMEpfITW8x1lOY4n4VU tBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=URbUJKr4cMZjMx4TR2n9tL/v81bSHKXUtg+/ki0rThbhK/zmx6uri/LkaPD6vBmMyk xl1po7uo1nd3cwQEXVCFHZGNEat93zA1pqFcPdjHxIefzkWgX2CG5ovf+L3s+6/X0BKY wShSUBw/OmH/CwhoQ951VdHqiJyFP7wXGm7XCfrU6DfOwjsE6AFl3isndtJts9WkXidh 4ZluH+vHwizsrpnNdYU4pL7/KqF02sdbLVG8tqJc/wrKT9/G20Ob0DtJ41Vqm3T5gUvY EzUrDe4RL/rfzQx/6Xicbt/CvK/EpEftHQBcRTaszDwjJRS4UR2McEfQPn4XqNJtGShD itVA== X-Gm-Message-State: AC+VfDwyVpXPDK3q65zt0hlfa1ysr5FoXC11o+X19DOTntW3zaLrx/TM TE9ZGYR8VHt8OT6jwVQdRs/vpA== X-Received: by 2002:a25:f40b:0:b0:ba8:54c4:3136 with SMTP id q11-20020a25f40b000000b00ba854c43136mr602795ybd.52.1686252760634; Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k7-20020a258c07000000b00bb0ae4221b8sm428913ybl.43.2023.06.08.12.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Date: Thu, 8 Jun 2023 12:32:36 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 19/23] sparc: allow pte_offset_map() to fail In-Reply-To: Message-ID: <22165adb-581c-9ce1-8aa6-a3385cd39055@google.com> References: MIME-Version: 1.0 X-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?1768164998453146053?= X-GMAIL-MSGID: =?utf-8?q?1768164998453146053?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/sparc/kernel/signal32.c | 2 ++ arch/sparc/mm/fault_64.c | 3 +++ arch/sparc/mm/tlb.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c index dad38960d1a8..ca450c7bc53f 100644 --- a/arch/sparc/kernel/signal32.c +++ b/arch/sparc/kernel/signal32.c @@ -328,6 +328,8 @@ static void flush_signal_insns(unsigned long address) goto out_irqs_on; ptep = pte_offset_map(pmdp, address); + if (!ptep) + goto out_irqs_on; pte = *ptep; if (!pte_present(pte)) goto out_unmap; diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index d91305de694c..d8a407fbe350 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -99,6 +99,7 @@ static unsigned int get_user_insn(unsigned long tpc) local_irq_disable(); pmdp = pmd_offset(pudp, tpc); +again: if (pmd_none(*pmdp) || unlikely(pmd_bad(*pmdp))) goto out_irq_enable; @@ -115,6 +116,8 @@ static unsigned int get_user_insn(unsigned long tpc) #endif { ptep = pte_offset_map(pmdp, tpc); + if (!ptep) + goto again; pte = *ptep; if (pte_present(pte)) { pa = (pte_pfn(pte) << PAGE_SHIFT); diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 9a725547578e..7ecf8556947a 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -149,6 +149,8 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, pte_t *pte; pte = pte_offset_map(&pmd, vaddr); + if (!pte) + return; end = vaddr + HPAGE_SIZE; while (vaddr < end) { if (pte_val(*pte) & _PAGE_VALID) { From patchwork Thu Jun 8 19:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp522586vqr; Thu, 8 Jun 2023 13:25:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4CvxtsnooSKOpq5O1OPCHB2PF1nbFnc4SNL3D2jddcrI6E8XB/an0xCPt+F239Z7g+3hS/ X-Received: by 2002:a92:cb05:0:b0:331:763b:b3a1 with SMTP id s5-20020a92cb05000000b00331763bb3a1mr11399994ilo.6.1686255932118; Thu, 08 Jun 2023 13:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686255932; cv=none; d=google.com; s=arc-20160816; b=hB9Sd+hnlFByYQzh2eUYOKSbSWmGbaOza/RuSIpaMJXit1zL0m7FafE2oFSl402AWa bgq92PSir+RDIWfitSut8G18iGd5Qg7bvJ6dZQVpxSpA/2vcsBM9fUBZXt1CNlHTz8l7 bp9t0QGhYTzOcaZsdgj7WXAdplv0X2Jn4uO53pzK8TQujCiVfGLrWei8V/Wa8cgTH4vg YMRfxRCjojXCdeyQdpYkYyHPMsAqxbtZLWvA2yn80MwBHvuSRSVnoOXq4/tIOvDtyFis 7uxGB5r4BSXcbpsEjR7VxiZVAGhQyAdvE1sWvd8CMHOh5cSSr+lWtiMZR59GEqbne+nQ 4EyQ== 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=dVqq3TlqmLJ8kFIBEjvAsOhhVmgZ9Wfd1Ac5Nt2VHvQ36KA5qVqUHYMjDBZTOu+FAU ccAOrCovUg/vedoH2VRII0hJsIxehh79PSJ9iPo6wuU6dWtq8BLEVsiYECNujEVMie9o GN86XYLVmQapvuG4jJO8TlDpdbiLohtgFxpzVeCtQz23qiLPfQz1GHEsMhODEYokawmd Rw8XHlxb+sYP6UGEqWlEHcukS6r/F9dNnap2fcKOjQ4f4szT33QNwkATsTY2E1K+1KzA GWG8iW/YAQvGniIANtAPwWV9M0/3iGQ27avcSw4UCB2t0w85gVybz8jAUpluDVkiqZzj Q5sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=1MipXBHl; 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 b24-20020a17090a8c9800b0023d23393318si1530251pjo.55.2023.06.08.13.25.16; Thu, 08 Jun 2023 13:25:32 -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=1MipXBHl; 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 S234892AbjFHTdu (ORCPT + 99 others); Thu, 8 Jun 2023 15:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbjFHTds (ORCPT ); Thu, 8 Jun 2023 15:33:48 -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 42A142129 for ; Thu, 8 Jun 2023 12:33:46 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-bad1ae90c2eso1048596276.2 for ; Thu, 08 Jun 2023 12:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252825; x=1688844825; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=1MipXBHlCgYLfuzhfDW5ZwUI8FUsKSE60AsqsEXw+S0tSnJg5UOmjRzYFHDLdCAJt8 yMkipeQIgxyZw78rcQRYlMT5UpzdJcWoIksfCpz/ydUZz6ZkI9xKVrX6kds0LvhIjEzt HS+XptOf+RYBmq4zm9J7IFzhbS7dVhum1cFHfBZOiQ+s0XEOXeKn/G9+gcrTCmXECFnx 8UoS3IHRM3ERDzeB2SU7OV6jhVelmg9iMKHzFrc8fJmEIq5uTYUBI9N7JZJvtQPChnnD 4+2NEzxtpjJGm4NjJthMMPpAkAfI8kDJwzbA28gjtv0iKudNeA4e3nFqgNhPbC/JEIjR C7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252825; x=1688844825; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Tza8VZpBdDATlz3Dj70XvbHnC1ZhEpBq1MlG3gUrqGw=; b=Twer0s44dElTE3uNPUEoqE5JQ1P7NO04rkW6LjQTMWbYcqV1HtZU/OXQLueyoVd8YR UBThm0Kt2+MseRv09KO0T/wTC7uDQevW9oSol5QsqVFg3EPem1w5ez2OmIOpGa5xSm7X 7R2h4SxhF5hGQcSFgMR46r6EIqtTJG3ATnK6MEJfu4wibUAMNSWI3S3JOV6jLZ6aVt87 +4U9VzT9+c3LPrAZQlUeVA0R1tM5kgQkBFEzTEb9R6LXzFatZmGHcRlDo23vfz8VGCZ1 Mh75niEOB90NkOEwDzrBkslVF8mBZm/nXusIyjttS9efDDhAht/2eqf/e6FV8fVt8XN9 1gdw== X-Gm-Message-State: AC+VfDxMNCOQRDDBil23XPwoUJhL8yuSTmSpIqmDTB9VwfS1R1gTybXX APD7EnH6X2ymKUAb84qw08NUmg== X-Received: by 2002:a25:868e:0:b0:bad:1055:c9fd with SMTP id z14-20020a25868e000000b00bad1055c9fdmr569763ybk.49.1686252825296; Thu, 08 Jun 2023 12:33:45 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e188-20020a251ec5000000b00baca49c80dcsm448503ybe.28.2023.06.08.12.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:33:44 -0700 (PDT) Date: Thu, 8 Jun 2023 12:33:40 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 20/23] sparc: iounit and iommu use pte_offset_kernel() In-Reply-To: Message-ID: <99962272-12ff-975d-bf7f-7fd5d95a2df5@google.com> References: MIME-Version: 1.0 X-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?1768167500466634041?= X-GMAIL-MSGID: =?utf-8?q?1768167500466634041?= iounit_alloc() and sbus_iommu_alloc() are working from pmd_off_k(), so should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/sparc/mm/io-unit.c | 2 +- arch/sparc/mm/iommu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index bf3e6d2fe5d9..133dd42570d6 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c @@ -244,7 +244,7 @@ static void *iounit_alloc(struct device *dev, size_t len, long i; pmdp = pmd_off_k(addr); - ptep = pte_offset_map(pmdp, addr); + ptep = pte_offset_kernel(pmdp, addr); set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot)); diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 9e3f6933ca13..3a6caef68348 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c @@ -358,7 +358,7 @@ static void *sbus_iommu_alloc(struct device *dev, size_t len, __flush_page_to_ram(page); pmdp = pmd_off_k(addr); - ptep = pte_offset_map(pmdp, addr); + ptep = pte_offset_kernel(pmdp, addr); set_pte(ptep, mk_pte(virt_to_page(page), dvma_prot)); } From patchwork Thu Jun 8 19:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp518895vqr; Thu, 8 Jun 2023 13:16:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Mq25GcdxD2+XZE1eJBd2QvCf3R4788ZyFh7FS+mHkJVzdDdpyOrARc2FvNRX63v7IVBqb X-Received: by 2002:a05:6358:e81a:b0:129:c25e:1caf with SMTP id gi26-20020a056358e81a00b00129c25e1cafmr4971098rwb.3.1686255413997; Thu, 08 Jun 2023 13:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686255413; cv=none; d=google.com; s=arc-20160816; b=QOXL0/25Y/OMV3D+024Z6cYlPOMipI9XqRDRnABGR/svtvuTRrPNdwA2p3Hpsbyys8 tVop4MAN5W1uvIs7NItMG4FsZYwOk8o+t+TjnV6MshUZJLxqOhlO5T/21KmOBho+c2Gx NDezcbftTv2vRVSWCeWJ84X8VoyJMdzxPQRlp0Lxf7gr+nzj5sAfttPuzQ28gbwaP2tM xaTdqk8zaLigg9MdaOnt0f20/FMjWr1AgrIYEPcmBtAxDuFpkletcpMRPmba6GuugGPL HNwZAVlRX3aDc+AJwq8g8AYxvyFQCSz8/pTAVT+YcacofcOEcRbddGM4+xvIRNMpQGVa ni0A== 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=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=WgFTmCpuXCgYCcSIhNrbI9y+MM4MhATuRiXIdowpUN314txGM685SEnDAgW5kT/v8+ Zn5x1xY266LroEZ5PVwwJweHCIr5MG/1LL5U7cD0vsE+AmgVtYCBGW9eJvZwE4SJWnej m7zrimFHwFo8n70qcaERGjWFkO3pFdPc1DXh2TJ1oixwXm8g81Emg21ALdIxqE7H37u4 3Za1q/A118+yGEZ+Hhwqz6aLRv+AfIeyYZQncs5FzR8uSzDBAxnxFG4DwJUnzTZbGPaz cPR+1FzGjWVLexuHk3FYCD5VajESGIwA8v7iUx8PPdtToty0oA76CwZfGMshTEKR2M0C kpNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IGMMSO5m; 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 z12-20020a63b90c000000b0053ff2ca1b24si1344837pge.843.2023.06.08.13.16.39; Thu, 08 Jun 2023 13:16:53 -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=IGMMSO5m; 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 S236605AbjFHTfX (ORCPT + 99 others); Thu, 8 Jun 2023 15:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236332AbjFHTfU (ORCPT ); Thu, 8 Jun 2023 15:35:20 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E90172D51 for ; Thu, 8 Jun 2023 12:35:14 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-390723f815fso41003b6e.3 for ; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252914; x=1688844914; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=IGMMSO5mseD7tMe+rRtOIzITR5LLF6gSj6DDkJB5GA4sfv+l0xQcNm+4SRn9cSTA+K bzPDoNl4QAtanNBNtw4EO4Jh9TOBqBvtAeMzqVR0kpqSUA/L/bvTchhidEBh3MP4oHsE 7zzo3x/NewiOg3sZOatxsUi0TcVM8A38QB4oSQfrmI5m9Mp6eOh1v9F27aPIV0BM3Y9m jqm85o0LQ0rhNRucFZ0i7HQcaeWJpsz64iPtGPt0XsZOnDRNlY3xajIra5PnrJSK9OoE jKjJyQ6PxwcJN3nFoobZxXBieXcQTT3OQ2VZ4F5eEeV/iMRllpjt6DpnkAeaktGC324Y dn+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252914; x=1688844914; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=N3SH54DnlCPlG7hklAlvtv91NHn7yWujypfq8D/o8rUYseOHoUG6vH3M9o6nErTWJ0 NzDYglXGsZ+fto08ddKlH0oNkqmPOo5wwcjdHFWXhQSF44tfmxGnw/AG7zSxFNDmP4Xm KCWyumnkwbaZzyU4+ivRWdR33cmHDHSFMJIyox5mx8kjlP0vuIe08/kKGH/Xqd1d5dgj 7EwppJ06U8Q53UlS8gpF5AIQ3TkQnucM/9TEjFmaE7nFHaewxRJibVGR1npCIn+1SMBp vo743TuMYHZs9UIclG/U3/B6KiXRCqgZktRdW8xRKfPtjXu/AC5kzz+MfLf04xI1Eiz8 goxA== X-Gm-Message-State: AC+VfDxIWCL2LsC/XcwhEViIY54gKjEuj1KQ8C1wyyfgYM43c9qJKhBb ppg3vBXx6iwlF4j2Zu5jEN9UZQ== X-Received: by 2002:a05:6808:cd:b0:39a:519c:2a6a with SMTP id t13-20020a05680800cd00b0039a519c2a6amr6836715oic.43.1686252914190; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id g137-20020a0ddd8f000000b0055d8768408dsm108055ywe.105.2023.06.08.12.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:35:13 -0700 (PDT) Date: Thu, 8 Jun 2023 12:35:09 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 21/23] x86: Allow get_locked_pte() to fail In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768166956932786850?= X-GMAIL-MSGID: =?utf-8?q?1768166956932786850?= In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/x86/kernel/ldt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index 525876e7b9f4..adc67f98819a 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -367,8 +367,10 @@ static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt) va = (unsigned long)ldt_slot_va(ldt->slot) + offset; ptep = get_locked_pte(mm, va, &ptl); - pte_clear(mm, va, ptep); - pte_unmap_unlock(ptep, ptl); + if (!WARN_ON_ONCE(!ptep)) { + pte_clear(mm, va, ptep); + pte_unmap_unlock(ptep, ptl); + } } va = (unsigned long)ldt_slot_va(ldt->slot); From patchwork Thu Jun 8 19:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp521952vqr; Thu, 8 Jun 2023 13:24:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WVPb4NWwiPQ7p5u1qP0mysb1ZFOdh0Wlxx+kw0h3kqz3EuO2zmNWBPgN9Z9G9MbdNGkVN X-Received: by 2002:a05:6a20:e48f:b0:112:bdd3:9b81 with SMTP id ni15-20020a056a20e48f00b00112bdd39b81mr3874636pzb.15.1686255840377; Thu, 08 Jun 2023 13:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686255840; cv=none; d=google.com; s=arc-20160816; b=CM9jSn7F2afEZRI+HoG+zkmOgfuqBqF/NCMLM8w9t1IqGVOyvzZdTI/BY0iGh8OQox esXFSGkXjhDZUQb7eosEyl6oaDa8LgzV6OJqtFziLVzi4MUAyvEiuR21FwJIcRzOKbDV kYc2xF8dkT5pT8CT6xl+JcyuT9byKXpNpxuFBwbt6JUaUmc46nhfbp4hB8ANBoFDnCuT LfOvyCWlY+kV5pEx2j+kCq76OT0Xr2MHIZ4BiIZSajJ/z+C/TXjL3UcTKJ7lpLfnfnch LnIZxGMJdRVcUQTeUiM9PQ4q/j9lGrlQKz17w20RY5tZohyxHoYiAUQVX8gVIOstaKK+ 5goQ== 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=TudUMTtuz7TwoHhWN8DKhOATNk5Lt4LoeR3j0kwo+PIbHL8Zzy15WULzXkcjNQLT+C jTxysK1M+7RL5TGCgiri583ACWVeabWE0DSrjJ5lYskrl6OItoIDv6PBXZLWu6/1sU4c Eywd1nxAWOJMuAKKkowIq73GdhDzRrfuawqhvJ9ddeJ/A801Zt3UCSwApHvCmeMbrklv f5gFJQOBq+pvwIjM4KfLQg6lcs1Vw1m8pqG4LfY4RyG6f5HKXYPO/uKOLMstI8toHGeS kLyo8fuWgmUW2AbprkepRFpgs8jzujtrd45cqtjnGtHOuaTacH9O91q4YHT3XlcV2xUH 7gnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=7iZl7qFo; 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 i14-20020a633c4e000000b0053ef158b0c3si1459135pgn.25.2023.06.08.13.23.44; Thu, 08 Jun 2023 13:24:00 -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=7iZl7qFo; 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 S234262AbjFHTgg (ORCPT + 99 others); Thu, 8 Jun 2023 15:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235282AbjFHTgd (ORCPT ); Thu, 8 Jun 2023 15:36:33 -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 905C82733 for ; Thu, 8 Jun 2023 12:36:31 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-565c3aa9e82so9448347b3.2 for ; Thu, 08 Jun 2023 12:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252991; x=1688844991; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=7iZl7qFoE643/vqqfaylOOM4UugSzxQOXfGxIkvhFgrLBJMpREbmLbhzK1Dfpeq7sW vLxMNbMxtYruESXi/vLA/FRPFy86oy/Rlv/K+QRhWyPjxrgHE6clF71I8HICL+Wbu4D8 52TIPF5OsTmaSTlVcpOmlJ2hXgN4iVitvobit3uBB1+XryThJwAiK1B3ovBLWTXnWBEi ML7bTpBpfErXrO5jZn41yk5x35HzdiBPWQx9RrfkGfIWSKYY13HndzOzcbi8dz53N7Pe Ykc3xEYKN/aDtb36dEI3aYN9owd5brP5GXTjP0NKjFTbVVbOSNnZMLMGudJLdaSlcXEi 8u1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252991; x=1688844991; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UmemeLuI+WpEQXgz9TQT0mwehV8FTU9BDTa5EhoH+Rw=; b=GR8NkwAIfwDGJb8ViRrsuw++iOjUgvtoV5uXzaHoxfnL81r1ezvIyxcvWuFapKB2om 0wyKnzzgPyH34Leu1FkdyvfO3oAGeHruoVnTlZQkx46Y/Zpopapdnzb2VuJ4Rz0nygAo cCNsYsEgMsW+OyJK/o1eQdCUo+kd6/NpJwnjNRgJIyzEhFdIXA/dZJuNipkvxAQ4VfKL 3dOAwlaRI2MSqGGEeFfsQACFoA7p3MC0DlOqkY2257g/7K6hmcQ8s1U7a7lbc7A38YRn IY7QZ1356x+6HRLXEz4ECpL5lHLGq2Dlu1aEv5eoYu78woB+VGAeFBCn/I58qv3rGESi 2+ig== X-Gm-Message-State: AC+VfDy9AckfDHckSaszms+W29F7JoZzaLD1ajNAoPSd7Ae2MXEN86Jt qtoFSpvkyktpNYUwqmG3o/0dHg== X-Received: by 2002:a0d:ef01:0:b0:568:d586:77bb with SMTP id y1-20020a0def01000000b00568d58677bbmr743298ywe.14.1686252990588; Thu, 08 Jun 2023 12:36:30 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id a11-20020a81bb4b000000b00545dc7c4a9esm108298ywl.111.2023.06.08.12.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:36:30 -0700 (PDT) Date: Thu, 8 Jun 2023 12:36:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 22/23] x86: sme_populate_pgd() use pte_offset_kernel() In-Reply-To: Message-ID: <497d7777-736e-85f2-c37-aa6bcf155e4@google.com> References: MIME-Version: 1.0 X-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?1768167404171252794?= X-GMAIL-MSGID: =?utf-8?q?1768167404171252794?= sme_populate_pgd() is an __init function for sme_encrypt_kernel(): it should use pte_offset_kernel() instead of pte_offset_map(), to avoid the question of whether a pte_unmap() will be needed to balance. Signed-off-by: Hugh Dickins --- arch/x86/mm/mem_encrypt_identity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index c6efcf559d88..a1ab542bdfd6 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -188,7 +188,7 @@ static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) if (pmd_large(*pmd)) return; - pte = pte_offset_map(pmd, ppd->vaddr); + pte = pte_offset_kernel(pmd, ppd->vaddr); if (pte_none(*pte)) set_pte(pte, __pte(ppd->paddr | ppd->pte_flags)); } From patchwork Thu Jun 8 19:37:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp520006vqr; Thu, 8 Jun 2023 13:19:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KiKOWZ+2IIZZUJP3FrI+shpVM67aM478F5pOVrrUb1jsY3GqeNW/jE2NsLiv2MhcZDb89 X-Received: by 2002:a17:903:486:b0:1af:9b8a:9c79 with SMTP id jj6-20020a170903048600b001af9b8a9c79mr9976947plb.34.1686255564591; Thu, 08 Jun 2023 13:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686255564; cv=none; d=google.com; s=arc-20160816; b=QaVACMMlE+sKKhxSRdBCmi89t26V52BLyMxSvkqrN6VSyMScg0UR3moQ0xMxVF26p/ GPFoTbk0LXymwPps8zIxtJQNzbt1CkMghFAj756sbe48DyQyxhT8wx0n/ZOf36FEUAWa aDd8uoqD6uugQ1M02aGkDEslP0svuaVv9H8gf6ENnZZTHH6YqFUGsACh2fWZLeGCp2Lp wTPE0QZLHjqapOXURoCN4tW9IulO1U9gTbqeOBTOM4k2FScwInMTU6NGYQNqLGu45LFB naG8VzVAINuyPUyQkzITPcofWFjgBuNLt9Iz/F/+om+zZ0XRTaOA1lwSAQYhBvSPF7R3 aPog== 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=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=o6UsGphjX4VK1JsIDplGtbviv8bHeSaG3MbORwuSHbh/3P8IQBYdzDeiTJajVlU1cD 2ZysSwHy0YXC/q5wCEYZLVQPBCkrJWYQ5PtrfK6ehHYAWURITBmtf48hLYFQSAk1Sh2t fYPfovmX/szsKJmDMuRCGShzVZtYb/yF+UlBnW8QC/uk8YyLCJ+1nkZ0c5NiCsBPyU3f UdFEo8Bc4VXGy21Xp8//qkEFTIpFO+/Ph2Ytrwe+Yt15gMIqk3JWlw+eJbhkQZmKLewl EZYeTMmlm0+UcT5IqWczHrS/kCbBzMPbrnCa1Szqvjso9YfakVZv7WCwNvVk0KV+pA0/ qCbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=wrjU6S4E; 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 r2-20020a170903410200b001a1d78af685si1449019pld.466.2023.06.08.13.19.08; Thu, 08 Jun 2023 13:19:24 -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=wrjU6S4E; 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 S236900AbjFHTiC (ORCPT + 99 others); Thu, 8 Jun 2023 15:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234086AbjFHTh4 (ORCPT ); Thu, 8 Jun 2023 15:37:56 -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 400802D4B for ; Thu, 8 Jun 2023 12:37:54 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-56896c77434so8890467b3.0 for ; Thu, 08 Jun 2023 12:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686253073; x=1688845073; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=wrjU6S4EMiU3Ufcg2KZPT551Y8sNhg4QKjD2hAgSPlGh9yj39Rxf3Ke0FjcZO6VxtG ALh4CVjSqM9GtJPRdIfEgNIlV/EEkptkG6e4IMSsrcpQSqGrj44uojyylNmPW3FhQBzm h+3YVxQpJctPazelaypN7o1DBk1YFmyjCLOyVuE0ZSJNDZN1IWkDf39Bng35IMFfYc2S OuTO6+N3JH4bhYslynL29X9VjGEwK1A0ffza+fgs91l3oerVxPUep2x461PcKgDhp6i7 yNPgK4idQjhQRO3vK4IICQL9mYykeSLt5G3Lqvr2ymPPunZsH8KwR6J1BbGlfhLHc47C HKFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686253073; x=1688845073; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4B5saBu/vw3gaGnlmIPZ9pQkqfzbj7+JgYM5jpygjcc=; b=VC+owECeUVekddahb6c4socRWXHmO9k5ayU/AjfLwNED4ybYs4j/SuEs00WV/sOs3v r5/Cb8ep0isgBvXlQXPfD6qxx1qQVBschyG00yFL8SCyyYx/cL01iJgMWyfV915Xsv3l 3U2evenENQyKB/xdxXyrq0zLpE0wprdWGD61U6sZF7tDAn/M4ghAVsUNeFl+28vAZINa dskpX51ymp7prhgrQ13fyG+7vFoAHA+X7xpNate5nKlHDUNg73N2rsgoFhYvf9u90c4K dCGNThEZlRjnWAI4A6NxZ/nWw/SKd/ONolwVmFzKKvpcqGKoth/VQWZ7wnzfvLw2YMWu WiWA== X-Gm-Message-State: AC+VfDxMNIKesUYfrxgsXzmDLOAHHrwatUGf1i86RnBHjaZkdUgcseQl b+bMifsC3qCiGaUWrru36Sztfw== X-Received: by 2002:a81:72d4:0:b0:560:f6ae:a71b with SMTP id n203-20020a8172d4000000b00560f6aea71bmr508956ywc.48.1686253073290; Thu, 08 Jun 2023 12:37:53 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id i133-20020a816d8b000000b0056953ab06c5sm114950ywc.95.2023.06.08.12.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:37:52 -0700 (PDT) Date: Thu, 8 Jun 2023 12:37:48 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 23/23] xtensa: add pte_unmap() to balance pte_offset_map() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-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?1768167114895467480?= X-GMAIL-MSGID: =?utf-8?q?1768167114895467480?= To keep balance in future, remember to pte_unmap() after a successful pte_offset_map(). And act as if get_pte_for_vaddr() really needs a map there, to read the pteval before "unmapping", to be sure page table is not removed. Signed-off-by: Hugh Dickins --- arch/xtensa/mm/tlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c index 27a477dae232..0a11fc5f185b 100644 --- a/arch/xtensa/mm/tlb.c +++ b/arch/xtensa/mm/tlb.c @@ -179,6 +179,7 @@ static unsigned get_pte_for_vaddr(unsigned vaddr) pud_t *pud; pmd_t *pmd; pte_t *pte; + unsigned int pteval; if (!mm) mm = task->active_mm; @@ -197,7 +198,9 @@ static unsigned get_pte_for_vaddr(unsigned vaddr) pte = pte_offset_map(pmd, vaddr); if (!pte) return 0; - return pte_val(*pte); + pteval = pte_val(*pte); + pte_unmap(pte); + return pteval; } enum {