From patchwork Wed Feb 7 14:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13548614 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 91C59C4828F for ; Wed, 7 Feb 2024 14:49:39 +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=ntBv9f+yRSRF1rt8EDB5XBI+6yoMnggt/P7qgfIv9X4=; b=xkChdcgetBf2HPGs4YBDXxSIsi +HHLwjVwxnM68xBxoL2eSFyTPxw1XmeMdgswm142qkLMHZLkfpxIJ2HfJ/pHF7ZrUMOFvxKFbZnBz es1YLc5dghh1jyzjcwO0+su+KXDlqGiFgqAn3WpoScH+IXuAmYDdrp/lh6NMC1HmhSZASIsIhkRsD t3y4xsom8Vyru6LGAiyhURHZsr5EVTrb+dHmtDno984BVDAz35iWRan6Q/1VH+dM1sCfotInYhQDs at7mEVb94nNuSgu7oAoofEPljS5V4G4zT84SfQJtn89Uc27KEVqjhYijFAv3CuNvQeDRVI4kOtw/Z XOf0uhjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXjEw-0000000AxnO-4AwI; Wed, 07 Feb 2024 14:49:31 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXjEq-0000000AxjL-2iqo for linux-arm-kernel@lists.infradead.org; Wed, 07 Feb 2024 14:49:25 +0000 Received: by mail-wm1-x349.google.com with SMTP id 5b1f17b1804b1-40fb1690f94so3405055e9.0 for ; Wed, 07 Feb 2024 06:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707317362; x=1707922162; 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=8tIUh8e7+u6fe/L9d2IoiyaWpJieVgDcIoakNbd8hrU=; b=ZcijRlmEPjelLzklaCQlgZ2jbfRr7kOI4P/tGf9alt/bDN0/juMIdmOTSdVhQADXsF ZXpCNMvPYLlaipNQb7+y5lUPcrKPc5fAIU8E7IRXx+6odFC2Zj5qCCSumWlhr20aCri8 63ObaL22jhgYeSszPrW2Y4EyUqUbf9F6+lFYShwW+CLwcuaEI9w3Mfuzp+btzbMCOVsN 1H5eRvKfRYfrifr5WujTc3RCJWndsqvGiediSiGNmqGqzDFn2q4nK/ypj0aJmAdPKE8X eiLW2yw0FgTX55Eno7yr+MB/sCUONFWNcCOmuvuvsedFjOsL3WtQGaDilBIFcAvnjWMo O20A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707317362; x=1707922162; 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=8tIUh8e7+u6fe/L9d2IoiyaWpJieVgDcIoakNbd8hrU=; b=qnmik4suQpLNVeJDkcbEvTspSIfmPPxMyDQQS+8NeQbOUuBzWwPK8WxoLFx26B8KGF MhFNsq0Iknw2ZiCdcXv1L2xkBYy6SQacDDoHfc+woZ2pEiDW5vyQHSd5aVQT1zZObd9l 4MtvqdN4uicOhLEZku2YksZzIaZ+/DvELet2LqrFcc00KOqKTI2AnSoUE1flRXgihrv3 u3l2O8J+AaGJWYYGvDZ3yWWEzGqpg0+yfiZC3m7ySy5FTkcSpYooidWi/iJ50Fn8LAC9 9x0m/Vfatf0y2XR9QoHw5V1qi2VOSAURarQPZTYrsqP/88gpV2phdNSsC2htR6GzTnlB 9WIw== X-Gm-Message-State: AOJu0YxTEyM5bs3/j5Ej9XEWZs0sxaiH0EhGO89e3/UQClzxjhUaxODv jmcs6UBzfDFhH0rG48RX5EIksmcCpkK5IU0gOLydzl4zfnOTJ4m/cZpf++OcLhWJGn41K4gnR7g AcCcJQQh3D97c9IzqA9+cBq//Jg== X-Google-Smtp-Source: AGHT+IHZWozJw6iEdHYJvbi8rYI97x/8VSLY+PehA27Gu1vNkYuY53+7wudnkk76X2VvuGrFo0tvrbQt62XM8gjTJX0= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:600c:518b:b0:40f:e205:9868 with SMTP id fa11-20020a05600c518b00b0040fe2059868mr158210wmb.0.1707317361885; Wed, 07 Feb 2024 06:49:21 -0800 (PST) Date: Wed, 7 Feb 2024 14:48:31 +0000 In-Reply-To: <20240207144832.1017815-2-sebastianene@google.com> Mime-Version: 1.0 References: <20240207144832.1017815-2-sebastianene@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240207144832.1017815-4-sebastianene@google.com> Subject: [PATCH v5 2/4] arm64: ptdump: Use the mask from the state structure From: Sebastian Ene To: catalin.marinas@arm.com, gshan@redhat.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, rananta@google.com, ricarkol@google.com, ryan.roberts@arm.com, shahuang@redhat.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vdonnefort@google.com, Sebastian Ene X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240207_064924_740813_CAC53E2C X-CRM114-Status: GOOD ( 18.55 ) 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/include/asm/ptdump.h | 1 + arch/arm64/mm/ptdump.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h index 23510be35084..4e728d2a1f2c 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -45,6 +45,7 @@ struct pg_level { */ struct pg_state { struct ptdump_state ptdump; + struct pg_level *pg_level; struct seq_file *seq; const struct addr_marker *marker; unsigned long start_address; diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 64127c70b109..015ed65d3e9b 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -220,11 +220,12 @@ 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; @@ -250,10 +251,10 @@ 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) { @@ -284,6 +285,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, @@ -321,6 +323,7 @@ void ptdump_check_wx(void) { 0, NULL}, { -1, NULL}, }, + .pg_level = &pg_level[0], .level = -1, .check_wx = true, .ptdump = {