From patchwork Thu Oct 19 14:40:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13429339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEAA4CDB483 for ; Thu, 19 Oct 2023 14:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SCMiyrqN6uordkiSxdOBSnS1f/rF+P+UmFZ09CpLL5Q=; b=N4xZqxgkD5CtN9qzhRQWkOCliw 3OaY/s2I58ebZGAPgKblvU9sF+zGJ5IzjPrqHonn6MfF4lwP28HIWxb1FW65FsEOWduBP+gTHrrnN KLmMDQwt/xPJn+GWVlRVV/Uzbu+CsFAW/Xhl7xmm+uX7uSC7h1ONXeGxTSJ39zRVBYCgn7IgA4/oN 5SMq+1c/z0hqvecCKldH5HJK+GJqHokkSQAE5JEdG8NtB5lt7GkHf/FOcl6YCClCzQzIcPn2YmKKf 79AE3CYlydCn78Ssbp/vuMULczoT1/Ry+xSXf1BjMznVpfV4V3Z7CA3wil9OxmIqWm18/z7Io2Pz8 8L1MgVsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtUCp-0006Hk-1I; Thu, 19 Oct 2023 14:40:59 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtUCh-0006Cw-1a for linux-arm-kernel@lists.infradead.org; Thu, 19 Oct 2023 14:40:52 +0000 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-4084a9e637eso3190835e9.2 for ; Thu, 19 Oct 2023 07:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697726449; x=1698331249; darn=lists.infradead.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=VveSIU8JYKB/5xEaudWcBTfyzaRnPWmMG3dfs8XdtD8=; b=b1jArCgiQy765Ux4d8Bx5xOyvYyEMzboQXtuk8sdgraebcJb/1ZL0iudnwtobYlO7g zsTwMuTsCahKxQDhBKIY5DSZrJgyo07szqgsFBcnFM87gT3/3mnT5U4eIrW82OSOfSYv jqf505qTttINyPYG2tz0xBIvXYQgLHp2+HWdN0fJjLdTU2ANDQWI+6VBK5pdQCxT/rgu 0hemTji01kqQCMA2FT1jHFPu7DZdBDyZb+GK+VbryBaGri0Np3paVBgr6+2f8rZv2b9x X4uYDDUIZp1OaJZL48rSL/B0YaHMjCkrebxNdoZ1pTO+XXGugcBVqpi2scZ3BQKuMGLx 0Spw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697726449; x=1698331249; 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=VveSIU8JYKB/5xEaudWcBTfyzaRnPWmMG3dfs8XdtD8=; b=b8zjF6U8/iV1PGWY9Lp6xTTB/RVtCIpVrjTC/VKtru5oKz0x/mLw6qoiqxOQxf/tqC /dFNhGIy170nF3VjDa8WYzNKNId9xBCZxKTyNqrDd729YL6wwEwBv1U60z/Nm0zXMQCl HmRRR24pPMmaUKYeYPd7FT5RPTosfadl4y5ndS1XK4+RB6/ofnfq6LWNZ9G+lnsxbSLg Hc1tx4ieHi4FW9K3j65V6YSkexMwGWs1W2Wue310JUgx34/Ml+UttIGc7x+H46eNUPBZ xLOtCqSOeUbYOw1ZtV2JcNs5/9QdeIU9j5Iu8SpNBycJF4eDC2Dmqg0bbi1/EJZn6Gz8 Svhg== X-Gm-Message-State: AOJu0YwDO4fnnP+khTphRggdyH/eMOAkyJxcgiWuIBLB/REQc2KKO6MX WF5qXJV3ZBu77WjD7B5PXDfTx/Y9lheTqD6nNxE= X-Google-Smtp-Source: AGHT+IFqK8L1G2PrWrUkVEFgks/xU9XIe7Fi7Mf6EMwliRg4fKVtpO97kPUB2tKYc4VoRxZAAgOHvgA1f+Ug30MC3us= X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:a5d:54d0:0:b0:32d:9a30:4d79 with SMTP id x16-20020a5d54d0000000b0032d9a304d79mr20981wrv.3.1697726449420; Thu, 19 Oct 2023 07:40:49 -0700 (PDT) Date: Thu, 19 Oct 2023 14:40:24 +0000 In-Reply-To: <20231019144032.2943044-1-sebastianene@google.com> Mime-Version: 1.0 References: <20231019144032.2943044-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231019144032.2943044-4-sebastianene@google.com> Subject: [PATCH v2 02/11] arm64: ptdump: Use the mask from the state structure From: Sebastian Ene To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com, qperret@google.com, smostafa@google.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231019_074051_527446_1FA9CFCF X-CRM114-Status: GOOD ( 18.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 = {