From patchwork Fri Aug 16 12:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 13766074 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 25A85C52D7D for ; Fri, 16 Aug 2024 12:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TOVsSjbkFKkupVHDdUClsSrj3QZ/4GeILHKaUawEmW8=; b=A2N5YUpJPDBbbDfp4ik7+WVdTV cL1/wd/JvxrHz2RMc7Ehd6lBskic3BZND8SsVpd3gxi/rNjeafZMWjrd5thHUc7Jgg51DmsMDDYJn jimMStZ+a1NO5JZl07RmP8X19adYByJXTI/jQKCHEuAilmsVs+FvFyPhEin3BjbnbrqZES0BatAzq Xed6xz+gLdrgvv7ZmssWQuMLBwk57MAcalPwmxNWmrUNxn8dEvKnjsAVRdt1e2HiFCUd8GbtEyMm2 uaGxxD7Caug2MMMFlolY2DkkOuMK/h6ekeqoehruoQf9wCD8kmvlBGOBQRIzf0ZcpqAb2Z4aPDoel d5cE5o8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewHD-0000000CubR-0zq3; Fri, 16 Aug 2024 12:41:55 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewEm-0000000Cu3F-4188 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:39:26 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-3719ee7c72eso98163f8f.0 for ; Fri, 16 Aug 2024 05:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723811961; x=1724416761; 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=TOVsSjbkFKkupVHDdUClsSrj3QZ/4GeILHKaUawEmW8=; b=O4VZDn+jgTyKw0jw4CULKqiZvSAMyLSNbw0vjfswCiMCeM+gMPSF4auRbkdjYTi2aB raBsQWHIXC2ChXpfiEcwUzaZB665smZSVfHx2eckVKy4VxG8IJNopPp/UcMd/QmBa/6e vGzMFh+rIy0Jf2nRZ9vPmD3WAk1lvE/kFT7H7XFyZ3GR/4NbuGXMpLbbXlRiV2ub+9e0 YGFwmt9HL0VQMbjpww21SUllulGkKXLnKKNSiF0favRio1lWDCD5Xu+J1OnpIv4ZQzgt m3j3WUi+IvpDAZGinGeIZzSskqrW4GwjmZZz2Fy/pMcAiilidt0aErSE299CaGC8vsrt WUQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811961; x=1724416761; 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=TOVsSjbkFKkupVHDdUClsSrj3QZ/4GeILHKaUawEmW8=; b=mOEhT677y2kvH8ge58hJBvMfgjICZjTeVVbqxrCZgYXZK1MtD3Q9ZWUOZ8BlOtRtft NcR69hl6KBiqGEE5CPv53ylhnTOJ2tOGVSGJv8u2lL2/I65zx6+kPw0lOdR1EwZTFvEb CnLM+P3grWI8SmNCOkb5XslAE0P9ALD0n1Y+HIJ/Qyx8+FGKT3fKFL3/BpDn/FoEScTH lfKxEywLCF+UeSNd1niD7FiNxOb7j+pyddmqYQCGyUCj4URjyxZRXq0Odr6ztJ+0yawI q4XWqwnYCd+6ayTW0vtU5SxngZNyKxBKHURDKcgzPrHSA95QO4KJta78DnF9Pm4GRyGe WrSw== X-Forwarded-Encrypted: i=1; AJvYcCWGfM+Y53bM7Fhqk7YZzKWfqZMDmM3xuti1snOKiKzVcBy87GOSGYLpfbk3HH61YTfTwvs5BAUksNj3ovl33l8e5fZjfeqJcw3P89EiVJ526GYaywA= X-Gm-Message-State: AOJu0YxldxUjmOxBNoz/VwHRrvjeKQleFU8WkK/uuj1o5gAHlNbvupXY HbfYxCPE+9+FCIDqZDQyZK8eXK4kl3q5VnqxtshNm8Ykn1faTpfdp83Cm7CaVoGDaaqe7GpDmat YljodjAVfpVVp7squcnti0+kq8g== X-Google-Smtp-Source: AGHT+IHcICbWJmK89n8rtw3CIsZCVnNXfh2Wfm6YpkzCdhB56aOnbSeNarXn8GFhkvmcCHzcvJ1/hlKucHN9pFgTZco= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a5d:6449:0:b0:371:8685:846 with SMTP id ffacd0b85a97d-3719465d24fmr4614f8f.8.1723811960947; Fri, 16 Aug 2024 05:39:20 -0700 (PDT) Date: Fri, 16 Aug 2024 12:39:03 +0000 In-Reply-To: <20240816123906.3683425-1-sebastianene@google.com> Mime-Version: 1.0 References: <20240816123906.3683425-1-sebastianene@google.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog Message-ID: <20240816123906.3683425-4-sebastianene@google.com> Subject: [PATCH v8 3/6] arm64: ptdump: Use the mask from the state structure From: Sebastian Ene To: akpm@linux-foundation.org, alexghiti@rivosinc.com, ankita@nvidia.com, ardb@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, james.morse@arm.com, vdonnefort@google.com, mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev, rananta@google.com, ryan.roberts@arm.com, sebastianene@google.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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_053925_023164_FAB2B0BC X-CRM114-Status: GOOD ( 20.27 ) 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 bd5d3ee3e8dc..71a7ed01153a 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -44,6 +44,7 @@ struct ptdump_pg_level { */ struct ptdump_pg_state { struct ptdump_state ptdump; + struct ptdump_pg_level *pg_level; struct seq_file *seq; const struct addr_marker *marker; const struct mm_struct *mm; diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 404751fd30fe..ca53ef274a8b 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -117,7 +117,7 @@ static const struct ptdump_prot_bits pte_bits[] = { } }; -static struct ptdump_pg_level pg_level[] __ro_after_init = { +static struct ptdump_pg_level kernel_pg_levels[] __ro_after_init = { { /* pgd */ .name = "PGD", .bits = pte_bits, @@ -192,6 +192,7 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) { struct ptdump_pg_state *st = container_of(pt_st, struct ptdump_pg_state, ptdump); + struct ptdump_pg_level *pg_level = st->pg_level; static const char units[] = "KMGTPE"; u64 prot = 0; @@ -262,6 +263,7 @@ void ptdump_walk(struct seq_file *s, struct ptdump_info *info) .seq = s, .marker = info->markers, .mm = info->mm, + .pg_level = &kernel_pg_levels[0], .level = -1, .ptdump = { .note_page = note_page, @@ -279,10 +281,10 @@ static void __init ptdump_initialize(void) { unsigned i, j; - for (i = 0; i < ARRAY_SIZE(pg_level); i++) - if (pg_level[i].bits) - for (j = 0; j < pg_level[i].num; j++) - pg_level[i].mask |= pg_level[i].bits[j].mask; + for (i = 0; i < ARRAY_SIZE(kernel_pg_levels); i++) + if (kernel_pg_levels[i].bits) + for (j = 0; j < kernel_pg_levels[i].num; j++) + kernel_pg_levels[i].mask |= kernel_pg_levels[i].bits[j].mask; } static struct ptdump_info kernel_ptdump_info __ro_after_init = { @@ -297,6 +299,7 @@ bool ptdump_check_wx(void) { 0, NULL}, { -1, NULL}, }, + .pg_level = &kernel_pg_levels[0], .level = -1, .check_wx = true, .ptdump = {