From patchwork Wed Sep 27 11:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 145512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2813655vqu; Wed, 27 Sep 2023 11:18:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwxy2VlVlZ+PQwisNo1po0rKo5rWQ3ZItFxgPlXm1R0Y9nnBsbk/zSUanHUVfVqNyoXJzx X-Received: by 2002:a17:903:268c:b0:1c0:d7a9:1c48 with SMTP id jf12-20020a170903268c00b001c0d7a91c48mr2599560plb.49.1695838694583; Wed, 27 Sep 2023 11:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695838694; cv=none; d=google.com; s=arc-20160816; b=a3f1Q6gQJZ2BI9AvzJXI9G4tnPFs44PAIVRoB/5kWPQPeub6uiRWgDZ2W9Hot+CYcl eVazfyztjrNH2KBRQFIW1SH5eiB70XB2OwproPVjVLvUx++l0UM7iDDMfoZ165cxEV0n a2gxKej6ek9T++AnG1jdFxPecJmOe4Y1hKsBdj7dfnYNMcITvufmxScNsy0J0IRNm3xT Vk4orQBgCyTeYI3fhddZjwDASrKobmHd2tjEZvXTtBDQvbm8nU8UDp9rccgKKaUd6Pz3 dRa0YRAr3sKlAc25OClXQZmRKoV3XfF/3q/oBU7kJ2VKqyUcPKKKFHiVlb6wS22nLw1w qQ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=yFhKKi5b0kZOlGKtkzEc+xU7GiAAYZeYNUbkjyCvZbk=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=HazayE8+Ps0HNlpnJB92UfZUEwnnPvHXs1p+za6/iO+O7UYu5v78GD8RiwPKCr3fwt M5lkiQT6mkItoL++nCZMtXMvF6sCs4E6/m9Fh9fzEwM5jDwT1rl/R+Sc34OdnC2UyvNO dRzQ13Sb7MTsTczWwQaRMklOjoqKIDsCL73pNSfcV23wZF1XMZOFkNbM91a0mUXPARyM f81LO9PrtBaaD1MSPB3itNEdtTYSxNlVIdBwLOvpHV13kcYMfesQuclA5qYmPHacudYn d+V5C23o2S2uEzHknggzdnRYbhc9TAajX85DMSARj9zZT0laklu2cNfqfkeKocSr3Uol coAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eddof2vA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id m1-20020a170902d18100b001b83767e879si14887729plb.266.2023.09.27.11.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eddof2vA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1D68D80266BE; Wed, 27 Sep 2023 04:26:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231501AbjI0LZ4 (ORCPT + 22 others); Wed, 27 Sep 2023 07:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbjI0LZo (ORCPT ); Wed, 27 Sep 2023 07:25:44 -0400 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65A3196 for ; Wed, 27 Sep 2023 04:25:42 -0700 (PDT) Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-321726b0238so7932156f8f.2 for ; Wed, 27 Sep 2023 04:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813941; x=1696418741; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yFhKKi5b0kZOlGKtkzEc+xU7GiAAYZeYNUbkjyCvZbk=; b=eddof2vAUlqPkEr0fgFU+VyV/kH9YKQrI6vugFkq2P7bvCTTgESwfHGFil4bzhtMl0 KrH9kuV8IY3X2d80TCPVBiKOK+tYv/+lqKeXfiTyefIppllUELvK6FvVZNimyg31Olic jdlqZ7ewidZClJDrDt3nJb/zs+CMd38QsKccdiqiKIRkmyqybZsF3Uy1zj2pQ+jfnvdk t8uCZQhTgzzC2CljsWnD0F8UgT7xmiRRXJqVg97d4XWY3LEivnBYGP3UEIjtYgUBUA29 tHTwe3KFfmT/7jHelg5PKKdU13b4rLKSw+AWsK1nJlw96JUAGsSJkMqiv+Ic+SLMza5y LDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813941; x=1696418741; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yFhKKi5b0kZOlGKtkzEc+xU7GiAAYZeYNUbkjyCvZbk=; b=e1OAHmETGbhjyjcgq/kXPq4DI2Mbnzex/n2U76u4uSVONzax9Cpnf3z3GKua/KiUk0 DMxifo5NV8RLHbzNZr+QkZFRM7rf2jxXM6zMfbh3K+nqpdZDWy9lVFemkDFHrFaNi01o Cw5Cc3hoNAUqSj7C99oO/ZMFBN9/cpLxzla7kL6bMgtAW0US1/W3aVx3VAQxe8GTDVAD UxgEPGqTl0eLJeTjZARN0apN2L3zv72U6ArRnabMruIUxurS2TrXysWq/uwZ3ArwdePb djB07UrlpwSE5HaxJJYqEcpFxFOilygpHG792lRe+2vF2/f/XuFDZhE69eQpqLgSWSqP bfpQ== X-Gm-Message-State: AOJu0YzfrDlwopyu03AdTjsGvXTO9TZvshseCIIVzvk+AAv+an2e3WB/ fEwVaWVoOBx6OsqhA6GS8E1k3SQX7SDl0yB8QBPdBsV749lufbE0x3YZTr5oz/Wy0ViU6HVrhj9 ce/2McXpeNtzF6tkpVRPy1mebj7Tl8ijUb8OkGF2UzV6xgzuUbj/Ak1tqSLv08MONayviwNtjlq tV96y6o343Pw== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:a5d:6142:0:b0:321:6a06:8d1c with SMTP id y2-20020a5d6142000000b003216a068d1cmr7122wrt.1.1695813941137; Wed, 27 Sep 2023 04:25:41 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:08 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-3-sebastianene@google.com> Subject: [PATCH 02/11] arm64: ptdump: Use the mask from the state structure From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com, Sebastian Ene X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778215755243882257 X-GMAIL-MSGID: 1778215755243882257 Printing the descriptor attributes requires accessing a mask which has a different set of attributes for stage-2. In preparation for adding support for the stage-2 pagetables dumping, use the mask from the local context and not from the globally defined pg_level array. Store a pointer to the pg_level array in the ptdump state structure. This will allow us to extract the mask which is wrapped in the pg_level array and use it for descriptor parsing in the note_page. Signed-off-by: Sebastian Ene --- arch/arm64/mm/ptdump.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index e305b6593c4e..8761a70f916f 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -75,6 +75,7 @@ static struct addr_marker address_markers[] = { struct pg_state { struct ptdump_state ptdump; struct seq_file *seq; + struct pg_level *pg_level; const struct addr_marker *marker; unsigned long start_address; int level; @@ -252,11 +253,12 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) { struct pg_state *st = container_of(pt_st, struct pg_state, ptdump); + struct pg_level *pg_info = st->pg_level; static const char units[] = "KMGTPE"; u64 prot = 0; if (level >= 0) - prot = val & pg_level[level].mask; + prot = val & pg_info[level].mask; if (st->level == -1) { st->level = level; @@ -282,10 +284,10 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, unit++; } pt_dump_seq_printf(st->seq, "%9lu%c %s", delta, *unit, - pg_level[st->level].name); - if (st->current_prot && pg_level[st->level].bits) - dump_prot(st, pg_level[st->level].bits, - pg_level[st->level].num); + pg_info[st->level].name); + if (st->current_prot && pg_info[st->level].bits) + dump_prot(st, pg_info[st->level].bits, + pg_info[st->level].num); pt_dump_seq_puts(st->seq, "\n"); if (addr >= st->marker[1].start_address) { @@ -316,6 +318,7 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info *info) st = (struct pg_state){ .seq = s, .marker = info->markers, + .pg_level = &pg_level[0], .level = -1, .ptdump = { .note_page = note_page, @@ -353,6 +356,7 @@ void ptdump_check_wx(void) { 0, NULL}, { -1, NULL}, }, + .pg_level = &pg_level[0], .level = -1, .check_wx = true, .ptdump = {