From patchwork Tue Jul 11 10:52:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Shuai X-Patchwork-Id: 118422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp403049vqm; Tue, 11 Jul 2023 04:24:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHLSv7ZO3ps8y4dpPG4qIA3UNI8etGo3iy2Kb+RfHrCdGOg7PVXNSRuuo6kXPaQsW24ZRO1 X-Received: by 2002:a17:90b:33d2:b0:25b:ea12:a2f5 with SMTP id lk18-20020a17090b33d200b0025bea12a2f5mr14773592pjb.35.1689074689510; Tue, 11 Jul 2023 04:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689074689; cv=none; d=google.com; s=arc-20160816; b=w5W4uYPVIl53HMp3WffPXdtSUYZuzKnM14/dGu7h9zA+NXX0TogyCqgOFMgilO3/aU rVdGwYxhOdIEbZia181MLa6duf4SlmiXmT2Exq5l+t4SzeukVrxkPW/6X5QkHCkl278U LWsNx/SpKbuYo0II9wOtdUJdeWLvbeV4hkJG7QxY54njMPZQm3nNW8sktS6F1CVz9hZk L6b1bam48kUya35fH77CgCXDISU1m2HmDSh1Nx0BHt/Pcja8UAAGEf/0gbN9ukN3WxiJ 8bYPZfQmlH/XZ0p1V1edp06djA9NjqVwBsHJ6f7sW4MLuLfWPW2aySp9iFcDgErO3PH5 f+9g== 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:date:subject:cc:to:from:dkim-signature; bh=2lUqyNFR/3dbpsLATQPRyo4SUfiIO9bHmuUGRrxMZ08=; fh=otInFdcAR84tfzGffWmeVHywlsAW/Sj/ccJnl8ca1Bs=; b=VwHFEXeUtnmkT9y27jIhjLDGTBkYyktjp0DAmF7fMK+kKb9wEBEM/msx8kRWqQ3ecK z6F9dNGqlWDs3f/IYh0BXAVciZS7S8aD5aX+naZNWRRoi46EOz3TuUpvIfLynkfgIcKL YuhbONbvMC4xsw1o0nHu1oPriLJJ0ScV0CHlDicUND+MEQruKcJe55N+oauH44vI+Ijv GNmfum26kZgvjIIlEwxmHDVY9G9P2Hq+UPznl5YcqxN06tIP6qVuDV7gU4FGPlCoQdPj 7Z97uENZoj1Brp/S+25cft7gR8xYn10I/a6VCpsTePUGTUNCHVJkRXMuPdGr3LLj2ZKo 7+fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=lAtnbdoF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u186-20020a6385c3000000b00553828d0361si1294522pgd.588.2023.07.11.04.24.36; Tue, 11 Jul 2023 04:24:49 -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=@gmail.com header.s=20221208 header.b=lAtnbdoF; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbjGKKwL (ORCPT + 99 others); Tue, 11 Jul 2023 06:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjGKKwJ (ORCPT ); Tue, 11 Jul 2023 06:52:09 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 325C0E69 for ; Tue, 11 Jul 2023 03:52:08 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-34570ed4cb8so21035415ab.1 for ; Tue, 11 Jul 2023 03:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689072727; x=1691664727; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2lUqyNFR/3dbpsLATQPRyo4SUfiIO9bHmuUGRrxMZ08=; b=lAtnbdoFrngPAW5pUeXeJEeAvltQ++NgRMGvvUHaIp+rkJH2muolPGXKrMLNjH3cWf tDfDjf4rpr6uJUZd8QRB1Q1jMTFsQ26a9ehpmiXESXGgKl96LdereHIl1nIcHIg2PzuL jrG4ihC/baeZoNyCpS+aVcMxFSAuY1fKCKi5XGx6ZxjHl4djODDc7hmvytVLyz9MN9An Aeo90RvRF/IUdnQSNuVmlKyqjdIR3a3EZtS+AZPy+Cg0ajBbIMvN8Sv/4btQ4fqwNfmM 4pncVSlwd74vz3B7B9E1tgK6D1D41ifUSnQYV9LmKyWJeg5iFIBpIdG+oUVFIXLtwdvl txng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689072727; x=1691664727; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2lUqyNFR/3dbpsLATQPRyo4SUfiIO9bHmuUGRrxMZ08=; b=HtDsErIqq/Ht0XDagXh0ncgQAR9INLdbb39HUgvQVAewnEjbQi8wnk+7j7WUwO5WIC odY2L1gaVR6kkhjllD9Pm+9YCOL5GgIeQxUZesfyrTHNG6TkSu+05DNQGvpo/Bg3Rhqs hM0a2xaLlUcOwTxaavzNRRT02VNJ2h6TFr/ZKxnI4jF+TyJmru+piJ/K3ATBPGXjnopC zDRPqz3InUT79JJYZ1Zz8tB6k0kIibsopyPYGVOEbfw2uOO/2xwUBk4IFfYVYVlha/5W 7kiXck+W+Gqn1Ch5oaSNcFg6KzTwWAzRS/c2Nfy5cDQVgSO9h9GeIIEMQVVZTPvVJ/18 ATbw== X-Gm-Message-State: ABy/qLbPFLAwgoOmwhoIEqt/awqToMML33AuWpJo8Dy4OUZXm2+ntRW0 94XdR/HidVYHnpKdHsN3t1w= X-Received: by 2002:a92:c987:0:b0:346:6afb:c9f5 with SMTP id y7-20020a92c987000000b003466afbc9f5mr3093263iln.1.1689072727475; Tue, 11 Jul 2023 03:52:07 -0700 (PDT) Received: from localhost.localdomain ([58.240.82.166]) by smtp.gmail.com with ESMTPSA id z12-20020aa785cc000000b0064cca73d911sm1422601pfn.103.2023.07.11.03.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 03:52:07 -0700 (PDT) From: Song Shuai To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, alexghiti@rivosinc.com, bjorn@rivosinc.com, suagrfillet@gmail.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: correct pt_level name via pgtable_l5/4_enabled Date: Tue, 11 Jul 2023 18:52:02 +0800 Message-Id: <20230711105202.842408-1-suagrfillet@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123181301712722 X-GMAIL-MSGID: 1771123181301712722 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 Reviewed-by: Alexandre Ghiti --- 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 + 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;