Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1793750rdb; Tue, 20 Feb 2024 07:14:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVl5Xmd1HUmk/c0FCz2cnlwS0daRRM6IHr+bejXsPGoahbFbfWlkyHz8qTy5p9qHKZFVwhmpfchoCr+lEh8MEej+CX8bp8FbY+gRjOhWQ== X-Google-Smtp-Source: AGHT+IHIBwth7rYCYPtSpfqD7CSv/9dwAOGUqMpinFDogkkPbyIP90lSgOmr/Hk2pcM3q6oZNCwI X-Received: by 2002:a05:6a21:9101:b0:1a0:9ab5:1e83 with SMTP id tn1-20020a056a21910100b001a09ab51e83mr11254952pzb.24.1708442071156; Tue, 20 Feb 2024 07:14:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708442071; cv=pass; d=google.com; s=arc-20160816; b=xRdNnmDNd1AN5zLrS+XY3UV0UekAUTtLcMJK5qAM7+R3PFzvIWIdrPuZlEBbtYjsb8 36hfhD5wZ6tsG8yB9Q/JTgmYCTDzYqViBhfrckLAkcBEFrRF+Wb4s0OEdQeABjhhg40l s8Z+B4oWk9IKlXf5EbTqo6WFlpJxxGhYPuc3j5UOFtoi17L7pc7MHSI8CwEHz0q7fEGx gSiyhrWJXXch1Bio0UlTys9g0f0AXTkIJlvwkXDALqVUbZztheSlctbfPvqLjLw2yTdw JGv33yYmdxobhPVjDrOOuAd44AopIjg7KzQP2ZH3mCdoPridxgPNWnX2cifzwz/KNv+I jiuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=I0gsyti8lKhCK+AHvAHuyBhR7vYZPhP9z/P4jDBYvrE=; fh=GJqd/6Iz5mVURNv3BJUh7cjZ8tyBWD/BXj0zV8y4pfU=; b=VJVVO97K++WXz8UVfo6fw3SgDj+wihrO8k851dYVeCCzJz4l4Gdt+MnZc4XdEEsVe/ 9b20uuUOjWNzdUkw6mjkeiJMBVfgr0oteAUQjGA1W2+5tuLoh9HSA3nE/LKfZGcZZpYP /prNxIBlrADpomcmejkk9NFh5xt1R9tmg+en3n0Ry2kgrPjUalMijig02wHwsmfiSw81 AykY2x0tRuDa6Fcw/UT+TMdtFa9UqX6Bd0Oc/NuvsH1oILDpmJEIRbOutHo9gOHmCY4Y Y8yGMnVVwy7EIh/Ge+5ZMa2hD/ehB5+/SYrqW2HaO7M/qE+CUvwLjZd9ai/eZtmCVtlk ViGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rO9wEC1s; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l123-20020a632581000000b005dc88c4700dsi6265667pgl.31.2024.02.20.07.14.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 07:14:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rO9wEC1s; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-73223-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4A37EB226FB for ; Tue, 20 Feb 2024 15:12:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B868B762C6; Tue, 20 Feb 2024 15:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rO9wEC1s" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EC3776042 for ; Tue, 20 Feb 2024 15:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708441899; cv=none; b=G43yCCl9fI+oM5F6w+q88Fj+ik6EckIoftQNJ/Mq4ppq+sttHkFZJj3BxxVfkIYI06e/Qvduw/6iz0aG/8pPsf9bhBpksmICDVLL72mfeeElCfu95ZAmx9x5eYtNjsUqzMvjVuLyozLasJH4F73+IADR06dtlXD1LQdBHWFONzE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708441899; c=relaxed/simple; bh=NJa1BLuTC1M9IXyS8cUBmrPvfsMqCbFinRO8836TETA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mhtOPd5ka9VS+5uqKrlnx4lpt/3J1wWZyEIzScM05DXHlnBgTWtskQxe2QF7MwLyAB6GjkrZ6S6miBi78BZSeroq9nHZhhGqBJnM92M5REWZbZyxUQGCZjNsE6GXcpbAdcDuIvM1stSVCGni5P26H41SF2IrTTlrfexnUznck7w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rO9wEC1s; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60810219282so33832377b3.0 for ; Tue, 20 Feb 2024 07:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708441897; x=1709046697; 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=I0gsyti8lKhCK+AHvAHuyBhR7vYZPhP9z/P4jDBYvrE=; b=rO9wEC1stMjKD+nC93Wopn4tp7d/GfLbZcL64kamuL+nXtFGG6xu09gUwZGOkfVub3 SM6PVwkUAcx5CxwgTnlArj67Omb3jQj6OK63++xXva4RgKd4dLl3fkygoL0d/W25Cno9 bhw6Y3ieKBJi8mBmRdK5SiF4sevZ7DCpy1s/9UOyTpUQtLFsZxdAz1zA369GUbev/rA0 u9+s2xarpbRTsusZC1Z+MLDt1tcLFMhjKVtey93fPC+5FIuqCQ+SySofOkfLxH41nlPy IZ+P1nThKRRITmujBCKx+y6OxEAxO7nUkRkFZmP9fozOdkEba3MwF+jWXGpBhXVc1OFp W1hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708441897; x=1709046697; 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=I0gsyti8lKhCK+AHvAHuyBhR7vYZPhP9z/P4jDBYvrE=; b=vQzgWRlsbc0KlgqCeXMiW+sqN1tcke3KsRt1inCGuEKtlRy+9kO4as9ZJ+ktwx8uSe ErkIVmYkK2Dw3oc5c6bsYyoJ6W4rvt+F6IOUT8idNjXJzdfPK1GTBl+2I2VBgEgj1g+S /CaDJUrK85GyarG6Ub2QneLGMQhLYl5K19Vrt6a21JF6rfXOga319dQv8O0/RdSMId36 OkMVSeOTzpB/hHUiJaUePFqysd3xxAZH0IMbfhkuGRCFTT3U87yWIC1RsNvRD30eFlup 7qyBa7J8tjkSgDuUSGYyd9ZSEVxdQcEWxrpmTgDr+7bwJkcp6e+TGONoyKdFHdCKNeee pxJw== X-Forwarded-Encrypted: i=1; AJvYcCURGlFqUiBp+H/45Ju6FCxcCAjKIV7b1Dp2512LwqjGnWQxxJrnDoF5ejvPvqZgujrppMe3RgIJndoPttG4slfaKtfwswS/cgjP+1z8 X-Gm-Message-State: AOJu0YxyaRuTpF4lSAJh/Bn3w1zjzdC11s9o7uuAtCXKZcR6yxlmpJpZ j4lNu0i6HQ/b6yxoeAbFHC25FaN3WtrqgfFrcvDPolQrKidDuDRqQPBpWyizchNE2jIB4+k7v2s Z6ecInHLyKkK8WoewSV2g3+nuyg== X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:1008:b0:dbe:a0c2:df25 with SMTP id w8-20020a056902100800b00dbea0c2df25mr871279ybt.8.1708441897282; Tue, 20 Feb 2024 07:11:37 -0800 (PST) Date: Tue, 20 Feb 2024 15:10:31 +0000 In-Reply-To: <20240220151035.327199-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240220151035.327199-1-sebastianene@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220151035.327199-3-sebastianene@google.com> Subject: [PATCH v6 2/6] arm64: ptdump: Expose the attribute parsing functionality 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 Content-Type: text/plain; charset="UTF-8" To keep the same output format as the arch specific ptdump and for the sake of reusability, move the parser's state tracking code out of the arch specific. Signed-off-by: Sebastian Ene --- arch/arm64/include/asm/ptdump.h | 41 ++++++++++++++++++++++++++++++++- arch/arm64/mm/ptdump.c | 36 ++--------------------------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h index 581caac525b0..23510be35084 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -9,6 +9,8 @@ #include #include +#include + struct addr_marker { unsigned long start_address; @@ -21,15 +23,52 @@ struct ptdump_info { unsigned long base_addr; }; +struct prot_bits { + u64 mask; + u64 val; + const char *set; + const char *clear; +}; + +struct pg_level { + const struct prot_bits *bits; + const char *name; + size_t num; + u64 mask; +}; + +/* + * The page dumper groups page table entries of the same type into a single + * description. It uses pg_state to track the range information while + * iterating over the pte entries. When the continuity is broken it then + * dumps out a description of the range. + */ +struct pg_state { + struct ptdump_state ptdump; + struct seq_file *seq; + const struct addr_marker *marker; + unsigned long start_address; + int level; + u64 current_prot; + bool check_wx; + unsigned long wx_pages; + unsigned long uxn_pages; +}; + void ptdump_walk(struct seq_file *s, struct ptdump_info *info); +void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, + u64 val); #ifdef CONFIG_PTDUMP_DEBUGFS #define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64 void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name); #else static inline void ptdump_debugfs_register(struct ptdump_info *info, const char *name) { } -#endif +#endif /* CONFIG_PTDUMP_DEBUGFS */ void ptdump_check_wx(void); +#else +static inline void note_page(void *pt_st, unsigned long addr, + int level, u64 val) { } #endif /* CONFIG_PTDUMP_CORE */ #ifdef CONFIG_DEBUG_WX diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index e305b6593c4e..64127c70b109 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -66,31 +66,6 @@ static struct addr_marker address_markers[] = { seq_printf(m, fmt); \ }) -/* - * The page dumper groups page table entries of the same type into a single - * description. It uses pg_state to track the range information while - * iterating over the pte entries. When the continuity is broken it then - * dumps out a description of the range. - */ -struct pg_state { - struct ptdump_state ptdump; - struct seq_file *seq; - const struct addr_marker *marker; - unsigned long start_address; - int level; - u64 current_prot; - bool check_wx; - unsigned long wx_pages; - unsigned long uxn_pages; -}; - -struct prot_bits { - u64 mask; - u64 val; - const char *set; - const char *clear; -}; - static const struct prot_bits pte_bits[] = { { .mask = PTE_VALID, @@ -170,13 +145,6 @@ static const struct prot_bits pte_bits[] = { } }; -struct pg_level { - const struct prot_bits *bits; - const char *name; - size_t num; - u64 mask; -}; - static struct pg_level pg_level[] = { { /* pgd */ .name = "PGD", @@ -248,8 +216,8 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) st->wx_pages += (addr - st->start_address) / PAGE_SIZE; } -static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, - u64 val) +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); static const char units[] = "KMGTPE"; -- 2.44.0.rc0.258.g7320e95886-goog