Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9502032rwb; Thu, 24 Nov 2022 14:07:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fBVaJ5t9Vhve+PZ8Ke9oBL6Qoqpb5r+G3EGbSZ9XzECvrKrJpV5KqBlXHghzU9J822+L0 X-Received: by 2002:a05:6402:3785:b0:461:e598:e0bb with SMTP id et5-20020a056402378500b00461e598e0bbmr32317965edb.21.1669327647239; Thu, 24 Nov 2022 14:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669327647; cv=none; d=google.com; s=arc-20160816; b=aYA/vh2+3DM8cnLP5SbAbaY0zMTZ0cQKm5WCA5Chdr7ZLQswtc+C6DTnlLeBL/0bcm ia0l8GjfNu8fAIrQFpZfKpALAxtSa9rK6HIFYtxhxQ4WwyPjkLXjcSyozMvyJu2GBQME euCkCzoI3fcus7LQq7LuF2450TpiJo5buABbNBtHfPHlp0rFhSGFohoJmk3BkucZNSBF 8ZEGXPm3ccw+fgF76RawjTonTTrizFUmb7fxV3htQ7YcTQocgf+I3JbqbsSkwhVvyJQi w8+ALU1Aj4VEFCoMbRR4lRrhJGr7PIy9+6Fa12uA4/vkKe8NstwOJK36++mnBO4thcG9 fHTQ== 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 :dkim-signature; bh=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=lVA/J59o+1mWy8BrkFCTC1HO27O8ZXKfi1quyjXyjbIPwAj6bJQ64LaZhiT9LJi/vK U8xlL9DP0yPymfVePqJPP88mkvYlnWgyQuJazxtNEULzSdyEDXISLK4gPhmrnmA6k/3Z iMY1ijYRUEk77zKrrshhmeTHtez68w1lsFAtfn0eVfqC0biQj1rAdMWfT9fn7NSsxGkr oobBTZ/kUoYoUAjhHVSSvOcwLRgkadsAttNlosKomK2Cm6KXivL4KVIRRj6s/8jsuCw8 kR+CZfV8nVZRwSFff/GQ3tSexVrKbg48xmchOWmCgBCFIq/bJV3LeTGqzHCe93AZ1GX0 ig3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="GbHa/hQq"; 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 z21-20020aa7cf95000000b0046753759be6si1935347edx.617.2022.11.24.14.07.04; Thu, 24 Nov 2022 14:07:27 -0800 (PST) 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=20210112 header.b="GbHa/hQq"; 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 S229645AbiKXV1Q (ORCPT + 87 others); Thu, 24 Nov 2022 16:27:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiKXV1O (ORCPT ); Thu, 24 Nov 2022 16:27:14 -0500 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C565F71F2A for ; Thu, 24 Nov 2022 13:27:13 -0800 (PST) Received: by mail-vs1-xe2e.google.com with SMTP id i11so1521210vsr.7 for ; Thu, 24 Nov 2022 13:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=GbHa/hQqiNB8uEN5hR06CtMISUCk0+DFPYBaPzprj2cbOIt0q9mQGnPzI6StE+f+w1 5gkxjit+Yafa9jRoElTfiGKyOiKEO/vCsLn9PbP+MJewxX+igI5Hq8C5sO6UE2CmxqWo Ea5ew7UUXgyzyiTntfH3siZuqb79Io8P7DAErhnMEby6tH/s4tXkgtmmvxESluGnKfqh k2Ny/v+BmhIFBaT70hqkodeJLCBf/3/GAwIwJDAwb/nk+oLNxgkYuXKuSgX5tb2VjSTP srWaNlgTbqqzm4yBJx95uLT7U6DhjRqNMja20tXksmMpNM7PCo9+yY0Xv6PJ5NHtsl21 Zm9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=bAz5vqHdYwQ3v4Q5cAvYuq04SMMZKzzy21oVDjmslanuIjq7odie3uP2UuH8x2Glyp JxchSiXnSafqC8tXx+hXPUU0rCrbt1K8UCa8RMLXYiKIBtMge5V+HeS9yqMfR/eNFsBk rU1XpRAe4x/yoflalnrQWccWdvoxvHPD/BqUZfb8SY+gKZ8G/yDMEFnUZLv+/0nsBNqZ IOMnljfi5m1i0Z+5Sgl7zFlnM/0ZoepyGzikGxk8RBoGujgB66aebw1aCVlVpBEHTUMr uLqDLTDLPWod0hLgNoKqPjcVKRDHjLs6L/9fR6Xcisduj92NJOi2MBnAmAst574/msbV FIeQ== X-Gm-Message-State: ANoB5pnsuEVL6aNMuTDH51gGtA3UeqoZlLYVUfF43db6eWxDTX6Bn0Mr RRXpANc0XMF/fvsM+9+7TzX77QYVYkYKtEYOea/2Sg== X-Received: by 2002:a67:fe01:0:b0:3af:5ff9:ed51 with SMTP id l1-20020a67fe01000000b003af5ff9ed51mr12230257vsr.46.1669325232670; Thu, 24 Nov 2022 13:27:12 -0800 (PST) MIME-Version: 1.0 References: <20221123064510.16225-1-jgross@suse.com> In-Reply-To: From: Yu Zhao Date: Thu, 24 Nov 2022 14:26:36 -0700 Message-ID: Subject: Re: [PATCH v2] mm: introduce arch_has_hw_nonleaf_pmd_young() To: Juergen Gross Cc: Geert Uytterhoeven , linux-kernel@vger.kernel.org, x86@kernel.org, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andrew Morton , Sander Eikelenboom Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, 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 On Thu, Nov 24, 2022 at 7:30 AM Juergen Gross wrote: > > Hi, > > On 24.11.22 15:08, Geert Uytterhoeven wrote: > > Hi J=C3=BCrgen, > > > > On Wed, Nov 23, 2022 at 7:53 AM Juergen Gross wrote: > >> When running as a Xen PV guests commit eed9a328aa1a ("mm: x86: add > >> CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG") can cause a protection violation > >> in pmdp_test_and_clear_young(): > >> > >> BUG: unable to handle page fault for address: ffff8880083374d0 > >> #PF: supervisor write access in kernel mode > >> #PF: error_code(0x0003) - permissions violation > >> PGD 3026067 P4D 3026067 PUD 3027067 PMD 7fee5067 PTE 801000000833706= 5 > >> Oops: 0003 [#1] PREEMPT SMP NOPTI > >> CPU: 7 PID: 158 Comm: kswapd0 Not tainted 6.1.0-rc5-20221118-doflr+ = #1 > >> RIP: e030:pmdp_test_and_clear_young+0x25/0x40 > >> > >> This happens because the Xen hypervisor can't emulate direct writes to > >> page table entries other than PTEs. > >> > >> This can easily be fixed by introducing arch_has_hw_nonleaf_pmd_young(= ) > >> similar to arch_has_hw_pte_young() and test that instead of > >> CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG. > >> > >> Fixes: eed9a328aa1a ("mm: x86: add CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG") > >> Reported-by: Sander Eikelenboom > >> Signed-off-by: Juergen Gross > >> Acked-by: Yu Zhao > >> Tested-by: Sander Eikelenboom > >> --- > >> V2: > >> - correct function name in commit message to match patch > > > > Thanks for your patch, which is now commit 3f85e711d5af4fb4 ("mm: > > introduce arch_has_hw_nonleaf_pmd_young()") in next-20221124. > > > > noreply@ellerman.id.au reported a build failure for m68k/allmodconfig, > > which I have bisected to this commit. > > > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > > > >> @@ -4073,14 +4073,14 @@ static void walk_pmd_range(pud_t *pud, unsigne= d long start, unsigned long end, > >> #endif > >> walk->mm_stats[MM_NONLEAF_TOTAL]++; > >> > >> -#ifdef CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG > >> - if (get_cap(LRU_GEN_NONLEAF_YOUNG)) { > >> + if (arch_has_hw_nonleaf_pmd_young() && > >> + get_cap(LRU_GEN_NONLEAF_YOUNG)) { > >> if (!pmd_young(val)) > > > > mm/vmscan.c:4102:30: error: implicit declaration of function > > 'pmd_young'; did you mean 'pte_young'? > > [-Werror=3Dimplicit-function-declaration] > > > > pmd_young() seems to be defined only on a handful of architectures. > > What would be the preferred fix for that? > > I could offer: > > - use V1 of the patch > - add the #ifdefs again to this patch (which would be kind of weird) > - use the attached patch Your patch looks good to me: Acked-by: Yu Zhao Thanks.