Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38385322rwd; Wed, 12 Jul 2023 07:04:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlHVwQUshFK/SZ27N9X53MpSpwBE8dPjxBCoo9QXGuK0fXsKZTf1qW7EgF+nvH7P0a1RFnjT X-Received: by 2002:a05:6a00:1487:b0:668:97bf:5ed7 with SMTP id v7-20020a056a00148700b0066897bf5ed7mr24920429pfu.22.1689170678900; Wed, 12 Jul 2023 07:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689170678; cv=none; d=google.com; s=arc-20160816; b=wnk93DEEfpZeXynadUbYZNJDOEzn9WDePaAgzimx+K/16lSIG95OeFDsbPyDCp6d9o eGEVqfy7aHOIQDENZaYogF39JEtYev0m3zfoEN73QOOVNxmRtuL2DSO1wVbbVTEhWF5C edryXZJLYlzx9POB6re8P3BJTzxc2qgbP5in0au8ZAHbuxTmgZQM0yrNOtdu7Ns0ygvW MCJwak69SrCTNJ0m4hgblz0U2c0Ii251J1iisi0RCg/cx4PAbb6+xbKUeewH2rqMNZlY ddcu1Mx3Li0wy6zc/K6du/J4TkKzQI035Y2n4a55j3D+IVyivgCkK512UxI9pfakfn8W +7Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=5oC9OkzryYNUsrIJJk91LArI6yaBglzBIZ57i2Rttt4=; fh=qU9yrZ+MNeDCMPPbU8CZOKxcJhk4cIEZvy601eh3tGM=; b=tlh8CwRaBr/6sIAWciSvtL7wMig/ueAaFfMkgZs3r6iD+LINcQUPqYZfY4LhcqDAWD MoMOHMkDrTDE9Qhe+qPPV/r+Cnn7al2oiiaT9WjrTM4pbcWRoaiT2+QExn04dYzv9O1b oi215i5n5XmCLdhv8X3GeXiS7Hbqx7tPBwh+OPRBhkyguZXFULJ6l7Y8FizN/HSmWGcI jl+OObfXC9czQqLyy4lu1PDeNhVfQvknjfL3mB2eORq+qSGbQ0rZHu5jueit7voZzxeO wKp+YtrYfzlTpWY7NmLDNT9BgnaS2cKGz93tLS0JMCEE99QMmmukwKyoS5J2bMif8oW3 NPkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20221208.gappssmtp.com header.s=20221208 header.b=0I6prQ+o; 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 x7-20020a056a00270700b006823a64b0a6si3197083pfv.350.2023.07.12.07.04.25; Wed, 12 Jul 2023 07:04: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=@dabbelt-com.20221208.gappssmtp.com header.s=20221208 header.b=0I6prQ+o; 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 S230434AbjGLN6Q (ORCPT + 99 others); Wed, 12 Jul 2023 09:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233319AbjGLN6I (ORCPT ); Wed, 12 Jul 2023 09:58:08 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0EA19A7 for ; Wed, 12 Jul 2023 06:58:01 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-553a1f13d9fso5329701a12.1 for ; Wed, 12 Jul 2023 06:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20221208.gappssmtp.com; s=20221208; t=1689170281; x=1691762281; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=5oC9OkzryYNUsrIJJk91LArI6yaBglzBIZ57i2Rttt4=; b=0I6prQ+o9hBKlVQK65s7zJ7P1j/BlSBXRgq9K89ET4q1kyAVoaQNR057+BT5H0+Fcq sE9AyJJP2iqUTpTvQhPV30I84yZm8zaxaV4tFF5Dbwg6bFr2Smh0E5Ed1NmksRxcTInD gKswgUhD4v7fWEpGm/hxipkDqNxf85J2bdnuH0emePe9I3bOTrvB7kFM0J7dyfgmELvj P5aY3YG3ZtRdiU3OK6jUTjqzTK0/RlW5GR4/zP1+/ogqDLhgJ3WnzTztmsthnyDusg1s z3H3A2BfuKxZlqDxtNJNjpaEM3BvwKAN8aIH9YPfMlA9+srHGi8GmOeuW2U/b9EY96yQ A1lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689170281; x=1691762281; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5oC9OkzryYNUsrIJJk91LArI6yaBglzBIZ57i2Rttt4=; b=Ns1hlDXQSeC/xONzPiO1Shs1PQ1tAZRzYlRftsLnV28QAsbNak+Qxn2SagE12dpsgl 89G+DNI4pVNgF0civmbpna/N0ojbaC7TRR1oJYnGCjMMaFBCRHnqlABD/iTaJFbJzrS2 LNY9AcJk5pRJ7DMv7ipMbRteydlXS1nuEI6e7FSFmIrNNL1ZwJgpyKEoW7bdlmKZiv50 Oho+FjGjmOUMMhVe74rer1toCydlMSQIlo17jEcBviq3sdNJKXtyV7lz1WkuyUcFciXd 4/utLjJt6AMT1pSszzrfDSDUFeAho+z5zPN0xd5xJMg503qUWArXheh4G7wKPb9sX2Iy W8Kg== X-Gm-Message-State: ABy/qLY7bNZ9PBcNqFZqaX4BJEjx1jmnnrJuOsKLf80oVEGbP5uhXeAL hYJnpkTv5Azs4NMiZXWCpwUPNw== X-Received: by 2002:a17:90a:b011:b0:263:4164:dfba with SMTP id x17-20020a17090ab01100b002634164dfbamr17923406pjq.6.1689170280755; Wed, 12 Jul 2023 06:58:00 -0700 (PDT) Received: from localhost ([50.38.6.230]) by smtp.gmail.com with ESMTPSA id g7-20020a63b147000000b00553b9e0510esm3551363pgp.60.2023.07.12.06.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 06:58:00 -0700 (PDT) Date: Wed, 12 Jul 2023 06:58:00 -0700 (PDT) X-Google-Original-Date: Wed, 12 Jul 2023 06:57:13 PDT (-0700) Subject: Re: [PATCH] riscv: correct pt_level name via pgtable_l5/4_enabled In-Reply-To: CC: Paul Walmsley , aou@eecs.berkeley.edu, alexghiti@rivosinc.com, Bjorn Topel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: alex@ghiti.fr, suagrfillet@gmail.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Tue, 11 Jul 2023 04:14:10 PDT (-0700), alex@ghiti.fr wrote: > Hi Song, > > > On 11/07/2023 12:52, Song Shuai wrote: >> The pt_level uses CONFIG_PGTABLE_LEVELS to display page table names. >> But if downgrading page mode from kernel cmdline in 64BIT, it will >> give a wrong name. >> >> Like, using no4lvl for sv39, ptdump named the 1G-mapping as "PUD" >> that should be "PGD": >> >> 0xffffffd840000000-0xffffffd900000000 0x00000000c0000000 3G PUD D A G . . W R V >> >> So select "P4D/PUD" or "PGD" via pgtable_l5/4_enabled to correct it. >> >> Fixes: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the command line") >> Signed-off-by: Song Shuai >> --- >> arch/riscv/mm/ptdump.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c >> index 20a9f991a6d7..cfdd327981ee 100644 >> --- a/arch/riscv/mm/ptdump.c >> +++ b/arch/riscv/mm/ptdump.c >> @@ -384,6 +384,11 @@ static int __init ptdump_init(void) >> >> kernel_ptd_info.base_addr = KERN_VIRT_START; >> >> +#ifdef CONFIG_64BIT >> + pg_level[1].name = pgtable_l5_enabled ? "P4D" : "PGD"; >> + pg_level[2].name = pgtable_l4_enabled ? "PUD" : "PGD"; >> +#endif > > > You don't need the #ifdef here as pgtable_lX_enabled are always declared. > > >> + >> for (i = 0; i < ARRAY_SIZE(pg_level); i++) >> for (j = 0; j < ARRAY_SIZE(pte_bits); j++) >> pg_level[i].mask |= pte_bits[j].mask; > > > The Fixes tag is wrong to me, if satp mode is restricted by the hardware > itself (not from the command line), the same problem happens. Maybe that > should be the sv48 introduction patch? Or the sv57? It will be more > cumbersome to backport with the sv48 introduction though as this patch > won't apply as-is. Sometimes it's easier to base the fix on the original offending commit and then forward-port it via a merge, I haven't looked at this one to know for sure though. > Otherwise, you can add: > > Reviewed-by: Alexandre Ghiti Thanks. Song: do you have a v2 that addresses the comments? > > Thanks, > > Alex