From patchwork Wed Nov 15 17:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13457134 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 60507C072A2 for ; Wed, 15 Nov 2023 17:17:31 +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=CaALFya7i019RnQ1BcLy3yBL97WpuKEd4xGYEPQnQGg=; b=qNaQD1/xCFKwpNxj7Y/Xih8QLq ki7C5STCSUu8qMtGeCBi+ci/1jKF9eKnGmsOvB2bMDMufcUTRzXhAwzIgP5WndmHH4AKfm99vXetO Lq1eorM+JohWXcv0dUCXcr+5/tHYa+A7I9Z41PuEAq0oqgFsdkABLFPmQ8ohWZtdVgtdA8DDP1pZo fk1wYOkv3Piv9BVXiaCd3RKBOWEN5AaEHEbKLPSYyi2Y3XtomkyjDZJR5c1r6dQrESCIFs+T+a7Se K+ZagdUPHrGTUhJlEy2n+Lu8C5jqnQ/w99Ibdpeukg+j1a6xq9ZloWzinSJT2VVEfXp3Qki+G7VMR 3r5E5J5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3JVh-001PTf-2b; Wed, 15 Nov 2023 17:17:05 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3JVb-001PRB-38 for linux-arm-kernel@lists.infradead.org; Wed, 15 Nov 2023 17:17:01 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dae71322ed4so8914471276.1 for ; Wed, 15 Nov 2023 09:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700068618; x=1700673418; 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=y0A/JzsGt28jdcT80BavCxCwKvAhE81Bu7nGud0PArE=; b=d/7WfDIdmBe+RqJyCLjqw/lblKMY1pkeqA0v0+6OvZQgZaU+TAMciL7u8YS8EWtJWk crNMotk18j9Xo550lBX4RLLrc6hIKzBPmxS2dD3qStAPL/ojLBeZx8HDnFE8jPg6P5oB 2+H1xl+ZvuLmljKSslLen5ovVnQZqULVFgForn/sgN4g5hXPmMKBiENylNOYTYQnAA08 /wZdZHNN9WLJz0IUNKz1XPBLrR6SWabRhabP8HNa6uAuhQq1PlUA/nGbgfStjkyAMvGT nPtsNlHwnWEXkko5dY3GUGj1qPMTtErQFfqiwRhDYvoVSeYYFgKna2yuxTg8HbL5doq3 Tr5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700068618; x=1700673418; 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=y0A/JzsGt28jdcT80BavCxCwKvAhE81Bu7nGud0PArE=; b=DPE0PdSVuoDxMVVk2ypt0LznoauKdG87lP0gTyMoIi9BwbeiolVodxky/dnubye9Gu Mh/4rJCCUev5RYLB6hEazS9Zsaojlyt+Yor471e/wbngdODM4cUgHhw91YzkkYHjdYjP gqZ+cLZAS1TTDKYCet77Uq4DBVOnSmfuwtD06erLuhha8U9kazQDCjY317vKlzGkziX1 Zg+NCvdJ5XGAJcXPJMZ74FlNOenaDqvTEYIDBHiQqCNJVZFb8lnwQ2XujMOSv6njym/G QKPb7uwAO+aIb6I5QXHTu9YepQ3GXWfXZzXZsNEcptCuJDqjMdqNM28DwoGFHWTTaiKY a8dw== X-Gm-Message-State: AOJu0YzBbfyp8M1g++DA4QKkMLA5krZgd/60u63vaFis/0KU5ln01xnG u+njUnnqEWGkG7nsyfXrfrp2F+eYuc+F+sTI9Nc= X-Google-Smtp-Source: AGHT+IHvlCAUAQ7rynEQW7WXWvObMDPO+YBhC2cqr0pMjotcdPVLuo899EzI/e2mZHuLUOn3sEwympOD+yO+Oto2Btk= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a25:3206:0:b0:da0:3da9:ce08 with SMTP id y6-20020a253206000000b00da03da9ce08mr324716yby.10.1700068618426; Wed, 15 Nov 2023 09:16:58 -0800 (PST) Date: Wed, 15 Nov 2023 17:16:32 +0000 In-Reply-To: <20231115171639.2852644-2-sebastianene@google.com> Mime-Version: 1.0 References: <20231115171639.2852644-2-sebastianene@google.com> X-Mailer: git-send-email 2.43.0.rc0.421.g78406f8d94-goog Message-ID: <20231115171639.2852644-4-sebastianene@google.com> Subject: [PATCH v3 02/10] arm64: ptdump: Use the mask from the state structure From: Sebastian Ene To: will@kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org Cc: kvmarm@lists.linux.dev, 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-20231115_091700_023142_253923C2 X-CRM114-Status: GOOD ( 18.64 ) 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 = {