Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1754982rwd; Thu, 1 Jun 2023 22:43:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tgYEH2N/mtt/jx5cNfXGOJW/oPoAF+0oJua/HOmEt/XIaAelmBIiN1KOcAzDqxRN+lx1N X-Received: by 2002:a05:6358:c626:b0:127:ee7a:cb96 with SMTP id fd38-20020a056358c62600b00127ee7acb96mr519163rwb.25.1685684620486; Thu, 01 Jun 2023 22:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685684620; cv=none; d=google.com; s=arc-20160816; b=zDpBCEq56YyVmw+y93M3PHIHQVV05LhDuGhlilcjOao/tcjQlvoHbkrTU57uh4zDkb HMDkT9TNvoROQWbZob+HK7r8dtQQYwryQUyvadjd2OBICyuRet036ySsOM+RAbghhzj9 0qhDldf/23ugyCmU6zBvTnahZJHpajSw2JnBAJ9fwmuXuzQmWxtaoZue/21yoWZl8dTU db6wLmRku7W8TLzb4KW6GVRTvFgKqg75urupfsN0z7retOio4c/TNBZgRLzROFNFyKwG btOcSl0Mqop4Hyospf3IMcZxCN78c/VxB8zDQdBOu3TQNvt3ik+Yi45gozDUY5jhHBCl PDxA== 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=BlaitmpXRewCMQojclut1KWFgZpzrF4XDGrxy0b7AoI=; b=UphcqjpYQIxAPyfGhSRQLonpiSLU158UjABOsYoDBhIJ1uSqNRcD4aPeRr97uApSCu lg2svefY8gIsitQbht+3xwS3/Z7s/x3FBgXNj+mDvyFkuigxpyxd1y4nBCsA3VwtyWAy l8XH8GWim3hovcEqN/5AZ7Cm7UupnEjhc9+DaPyUfnrnHYi2LVxF6GIfssdRIrTN6pGz xEvnmJobqV3qesUIA06dmdCIx2nAWkKm/4X+rYGhaezeMhDMLFpl+wC6yuF1On8Yvyo8 yns9EyZTOH7X7QgC3PwcBIxsY6OeGiwiIYTrx/nzzYQDWMNve77DjndSjwA8n8dYZNzv Tg9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=E3a6AaZ3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b00540102a876csi435928pgs.73.2023.06.01.22.43.25; Thu, 01 Jun 2023 22:43: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=E3a6AaZ3; 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 S233488AbjFBFfV (ORCPT + 99 others); Fri, 2 Jun 2023 01:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbjFBFfT (ORCPT ); Fri, 2 Jun 2023 01:35:19 -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 CE68219A for ; Thu, 1 Jun 2023 22:35:16 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-568bb833462so17672367b3.1 for ; Thu, 01 Jun 2023 22:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685684115; x=1688276115; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=BlaitmpXRewCMQojclut1KWFgZpzrF4XDGrxy0b7AoI=; b=E3a6AaZ3Wcq1lZLp7NnGxoPP+Sqqvy1yK8I8U7Sr9m03K8dydeKVdp3X09jrk0mT5l Z4gWsI110+w/R9oqWgJirwZU62nrDu5xK430A1Pp9R8v9LU5xUjKK27fq63Q3dCxL+lK EOER3xk6WvrcmWXOqAulAYp17HQSfpWOFuD7ebF2cknb9e8VMLdEW32HSGJvwKQf98ax d5K0yw+++hRSZJGGAi/XlfXqyPj54C4Vo4rdV5xGmJz6P6/NDq2CFGmLHSiJzR8ezKb9 GO3Du3RsU6exq6DpYJrcN85L+5XjKkr2C7r3tznXuV+dxaowhBTIMhoLLvmKkcXrv/cl 1/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685684115; x=1688276115; 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=BlaitmpXRewCMQojclut1KWFgZpzrF4XDGrxy0b7AoI=; b=DvQcxeyoT+kW3lKyJ1a2wbigZNC7iEZ6LxdUuN3jyN2lqZqyyrxOqN8wdFpcOoRofc ahY4d6X7V5ENV+1uQD4GhOvnlSnqF3rqVHRiuew9bBiE1lFhkuQYCaQNAg8rp0h9+bZS yXfj4JUNj7fvcC2QM7M34+wsNbUP2q1AuX8uH0nMnafK0lANdjutM9LA88YDT2gOjAtp bK/Of921ACcXtO++Cr5ISeBxQ7WSrPL5XB88mkOu/Wbxtb9Hd/0qZ5mUh3/Z+9PwPG37 zEsmfMyFiVlsSpRLA1XQUByFYrKmmXhAV9THG/4M+P/eNECV5eJ/s8kIqPanTApfaAoT OYAA== X-Gm-Message-State: AC+VfDxnD2C63SEJIa6feDV5m9G6TF9w9EvFFqmINS+u406K02ucNJFU 3Dp0ve+40Z6/Q0OILy+lb4C8eg== X-Received: by 2002:a0d:fdc6:0:b0:561:e944:a559 with SMTP id n189-20020a0dfdc6000000b00561e944a559mr10559756ywf.31.1685684115539; Thu, 01 Jun 2023 22:35: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 j188-20020a0df9c5000000b0055a07e36659sm122944ywf.145.2023.06.01.22.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 22:35:14 -0700 (PDT) Date: Thu, 1 Jun 2023 22:35:10 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Jason Gunthorpe cc: Hugh Dickins , Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Russell King , "David S. Miller" , Michael Ellerman , "Aneesh Kumar K.V" , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , Jann Horn , linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 02/12] mm/pgtable: add PAE safety to __pte_offset_map() In-Reply-To: Message-ID: <40349492-6f33-2a19-4a5-eabbe6b48aca@google.com> References: <35e983f5-7ed3-b310-d949-9ae8b130cdab@google.com> <923480d5-35ab-7cac-79d0-343d16e29318@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 On Wed, 31 May 2023, Jason Gunthorpe wrote: > On Sun, May 28, 2023 at 11:16:16PM -0700, Hugh Dickins wrote: > > There is a faint risk that __pte_offset_map(), on a 32-bit architecture > > with a 64-bit pmd_t e.g. x86-32 with CONFIG_X86_PAE=y, would succeed on > > a pmdval assembled from a pmd_low and a pmd_high which never belonged > > together: their combination not pointing to a page table at all, perhaps > > not even a valid pfn. pmdp_get_lockless() is not enough to prevent that. > > > > Guard against that (on such configs) by local_irq_save() blocking TLB > > flush between present updates, as linux/pgtable.h suggests. It's only > > needed around the pmdp_get_lockless() in __pte_offset_map(): a race when > > __pte_offset_map_lock() repeats the pmdp_get_lockless() after getting the > > lock, would just send it back to __pte_offset_map() again. > > What about the other places calling pmdp_get_lockless ? It seems like > this is quietly making it part of the API that the caller must hold > the IPIs off. No, I'm making no judgment of other places where pmdp_get_lockless() is used: examination might show that some need more care, but I'll just assume that each is taking as much care as it needs. But here where I'm making changes, I do see that we need this extra care. > > And Jann had a note that this approach used by the lockless functions > doesn't work anyhow: > > https://lore.kernel.org/linux-mm/CAG48ez3h-mnp9ZFC10v+-BW_8NQvxbwBsMYJFP8JX31o0B17Pg@mail.gmail.com/ Thanks a lot for the link: I don't know why, but I never saw that mail thread at all before. I have not fully digested it yet, to be honest: MADV_DONTNEED, doesn't flush TLB yet, etc - I'll have to get into the right frame of mind for that. > > Though we never fixed it, AFAIK.. I'm certainly depending very much on pmdp_get_lockless(): and hoping to find its case is easier to defend than at the ptep_get_lockless() level. Thanks, Hugh