Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8382736rwr; Wed, 10 May 2023 23:56:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7r0BzkIFVqEmGplt8onModYlr63KZrCf8X+EuYGdza4f12SeBBKRCaoMTLT4kCSRBHBwE0 X-Received: by 2002:a17:902:e5ce:b0:1a6:68fe:2ea2 with SMTP id u14-20020a170902e5ce00b001a668fe2ea2mr26153158plf.2.1683788188034; Wed, 10 May 2023 23:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683788188; cv=none; d=google.com; s=arc-20160816; b=ZNOPh9jr26aZ0aZu6eK9QNifx/pHlnagDZhWe7AUsESa3oIyXrjeLJ6TlM+rzDL5sv JsU3vkIvBYFgmVVfHRZR0sHqZe9lsZFjy/UCeBra51Omy0yyRPj51ADUFGAylcx5jbKG hqvimN9xyncHctWRIPOxpxbznBwoMfz74yoiGS8Q6hY+SF7ojr2gSkEDjGtTbW5/4/Cb Dky/pLyhGaH6MCsfDSd+/e1NtX5tPaT/xiwKJ3NS4MD+5tZEGk1BEfxihs2knU6/FhU7 OBliaQwCsbWimtwxoW5Gen0B5HEgx5O0xlGWwgpnWl6NBFs+HxJBn8nFqoPNht8Xom2Z gVHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=LIaeGJLpIvd0QPIZmrcTbGMIiF8UyMQzXRI5Qg9jnF0=; b=VtAC/NadSzvM8TVhwgdJ5uImutEs/EE8p+mC8DcXGqbSTwb8ByL5N2yW4iVGMZoG9N XS2m768YwxvVNT91lBsJP+JmRMuuPz8r4VgHGskpQHwcztRfQ1199Nx+FeZrWsilIPXG j+U0he3oizeM4NxH0HQ9f/Ba5f22POAtKTJcn43r9Vn/l1KE/FnUTPx0sLTPGVJt3EDQ AQmIycXTfFD1NrWbbuQIw92FCDxu5DWavQOnIU+Wn0eWewC3DWSAefaDQtOlrYSHYZ03 PAqe4ByxAabJA8Tz8Na4RZ++puQflBU/wTir430hQRGfHJDXW/4gxSSA0QZr/Fl6BCGB 0phQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a170902d51200b001a988a09b6esi6577200plg.252.2023.05.10.23.56.15; Wed, 10 May 2023 23:56: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236672AbjEKGyJ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 02:54:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237197AbjEKGxo (ORCPT ); Thu, 11 May 2023 02:53:44 -0400 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63FD94EEB; Wed, 10 May 2023 23:53:42 -0700 (PDT) Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-61b79b9f45bso74861116d6.3; Wed, 10 May 2023 23:53:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683788021; x=1686380021; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MblyuSVWD0Rw/dgsETYZNoTE8y2XjkYZe4ysDLt2Njg=; b=O/cLH8sVcrgf6Paui9keCwceEcmNVA9suEraLo+PiuQ1+mfY6PLm3wuMxN96CakfYu +4Aa1I80iYB9e+YHaceZuS2DkalUPqsoTNQxDdAa3ZMoujfhZzMmf5U5B+6DtOYCNP4O F5VbcUTwI5ao5A76ZvlBthAB3QqLHZnX0jNIxYqDiqDF2tT8vPRLzeGym1Fca4NDljRI QiLRZWUVkwQjGIrV2o07ResmWryvgjudAgJbIwrtsc9uADe5YZXDO8wzjO43DZaab7hE WSwlGzrSPrxNwF7lV7ALvk9Be8J22PuLEbDYABD3fKx7dgPUThWfrKsS0LOXxpPqqTKB pB/Q== X-Gm-Message-State: AC+VfDyECUBZG1PWkToATZ9kDdj8Vwm6EqcFGCnb68QcQpSbkdqElbQC itVcLd2RGpXrAriVO3xFNjqiRGPtOQ57bA== X-Received: by 2002:ad4:5dc2:0:b0:60e:98be:8694 with SMTP id m2-20020ad45dc2000000b0060e98be8694mr28831866qvh.46.1683788021160; Wed, 10 May 2023 23:53:41 -0700 (PDT) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com. [209.85.160.174]) by smtp.gmail.com with ESMTPSA id w14-20020a0562140b2e00b005f9a0018360sm2103665qvj.11.2023.05.10.23.53.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 May 2023 23:53:40 -0700 (PDT) Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-3ef5b5d322dso82386311cf.2; Wed, 10 May 2023 23:53:40 -0700 (PDT) X-Received: by 2002:a25:aaa6:0:b0:b9d:a27c:3fc9 with SMTP id t35-20020a25aaa6000000b00b9da27c3fc9mr17668190ybi.33.1683787999800; Wed, 10 May 2023 23:53:19 -0700 (PDT) MIME-Version: 1.0 References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> <237c8410-ce61-94c-4260-7318ad6a4f3@google.com> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 11 May 2023 08:53:07 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/23] m68k: allow pte_offset_map[_lock]() to fail To: Hugh Dickins Cc: Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Russell King , Catalin Marinas , Will Deacon , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Hugh, On Thu, May 11, 2023 at 4:58 AM Hugh Dickins wrote: > On Wed, 10 May 2023, Geert Uytterhoeven wrote: > > On Wed, May 10, 2023 at 6:48 AM Hugh Dickins wrote: > > > 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. > > > > That's a bug fix, which should be a separate patch? > > No, that's not a bug fix for the current tree, since m68k does not > offer CONFIG_HIGHPTE, so pte_unmap() is never anything but a no-op > for m68k (see include/linux/pgtable.h). > > But I want to change pte_unmap() to do something even without > CONFIG_HIGHPTE, so have to fix up any such previously harmless > omissions in this series first. OK. > > > --- 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; > > > > If the absence of a pte is to become a non-abnormal case, it should > > probably jump to "end" instead, to avoid spamming the kernel log. > > I don't think so (but of course it's hard for you to tell, without > seeing all completed series of series). If pmd_none(*pmd) can safely > goto bug just above, and pte_none(*pte) goto bug here, well, the !pte > case is going to be stranger than either of those. > > My understanding of this function, load_ksp_mmu(), is that it's dealing > at context switch with a part of userspace which very much needs to be > present: whatever keeps that from being swapped out or migrated at > present, will be sure to keep the !pte case away - we cannot steal its > page table just at random (and a THP on m68k would be surprising too). > > Though there is one case I can think of which will cause !pte here, > and so goto bug: if the pmd entry has got corrupted, and counts as > pmd_bad(), which will be tested (and cleared) in pte_offset_map(). > But it is okay to report a bug in that case. > > I can certainly change this to goto end instead if you still prefer, > no problem; but I'd rather keep it as is, if only for me to be proved > wrong by you actually seeing spam there. OK, makes sense. > > > @@ -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); > > > > Is this also a bugfix, not mentioned in the patch description? > > I'm not sure whether you're referring to the pte_unmap() which we > already discussed above, or you're seeing something else in addition; > but I don't think there's a bugfix here, just a rearrangement because > we now want lots of cases to do the pte_unmap() and local_irq_restore(). I was referring to the addition of pte_unmap(). As per your explanation above, this is not a bugfix. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds