Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp354459rdh; Wed, 7 Feb 2024 06:49:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/AgYkFtcNhh9e+mS4/CWTA2cN2DinsXnM2iooFgPq4ZoX5Y398Gt39qeUequIXVknzjUb4wEVdgf7uYSiq3yMwKKw9J2UUkOcnVc8vQ== X-Google-Smtp-Source: AGHT+IGsYQIpkcmo+6Jnu2XIvQVrnyni2+Dmixcvztyfd4BvbD677C+pDgbEZtOFxWsa1i0O0Qj7 X-Received: by 2002:a05:6122:3904:b0:4bd:3606:c7aa with SMTP id ep4-20020a056122390400b004bd3606c7aamr2834103vkb.5.1707317382155; Wed, 07 Feb 2024 06:49:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707317382; cv=pass; d=google.com; s=arc-20160816; b=m55B1+GyXFT+UwtMIaZVW8Odri/y2xtGcJHwQLH1C1kEMzLOWL5xQx2tlGTT1KT5Br 9KUfPFOoMo7AfsS0GM1r/YTZ/lZL4MPur/XqkUe5NUqz288+VEC+wa3qpMAUsBCW1UmK EPizNEw2f9Pe/7EeK+Sp9X1iCzR8XJfaO2fmpIvI2GwqgvaduLW376Ztf0VVz/9bKXv5 bjjETniLuSpiQt4369EKHHUjnJM7KShyyOgK2lIBzSp+Dx6hlRNFi78aoglvSncpKtWn APV7AUQvN6Ltu+Ur4wN1tZ7++G+/BpHKlVaLDx7UlUinRU74/wAxq4CIbHZEyKvQDNyK btfQ== 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=KuSad3U75XWRyrG0hVFC7e1TsgCe+6P5oSqEz6h0Hdo=; fh=iGPi3H2mmgHhnfFJ35EuS+glmBh7IOzGI4JiZIqExA0=; b=MO1j1kzN8NjdqinbiE6WWl3DX6Mh13gx0ccO0XteogXlK2ueDzVolUzOTg0nhacdqQ yiTO4r9djLKASvvPJNQ5jOcAcwfU5SVpTBVsYGNAVdUTO12M/mdHYbyZ3VxdYCW09YTX k2WE6YocxVWS+GEo+zU1iAPXi6C6JWgJI9zT7pWfHoEkEnODJJDKiUip9HbKV1jlZnrf 5lgOzyyhh3NxeYnvwYbxqEJmmdhxsWQrXNS6BhH5Ig2L51oVjkHXa3s9PGoaJ+h4VXQ+ xPTq/F9arJYtwBYxBR7vMZFSpq5QkGjZUPhtP5XPv7ioucp8e2SXKxWnXMfJrd6HMLIo P8dQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=V+6LXN51; 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-56651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56651-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXvRvNSTkervzCY36WK0sJnJJYTVmZ6dtBJbMtkCHiX5jFvRBGBcx0POvnu6nDKRzr2CFmjB8icnSk8GhEzM3Ba0KEEwCIEoZWn/EU/Pw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u9-20020a0562141c0900b0068c68e9a5a9si1280982qvc.544.2024.02.07.06.49.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 06:49:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=V+6LXN51; 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-56651-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56651-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D278C1C253DB for ; Wed, 7 Feb 2024 14:49:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B87B7F7C6; Wed, 7 Feb 2024 14:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="V+6LXN51" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 87B647E788 for ; Wed, 7 Feb 2024 14:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317362; cv=none; b=P9EOzuqlwA3MRLGvPR5Mws35BvtcscH87H8UdZyIZTv9pSbwmHutCoCDDShmSKJS0KaMGURTsBtrMNPwN/Z8suZgFX6AdOwLq6CbaiFAsQR5MdPeBWjPy+/5GGoSnTc4i3PG7jcwBXAWT20LeoAVQ9PhH875tBR/DAw+J4eeeRU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317362; c=relaxed/simple; bh=6vzgHsVxuihU3g4TMAduWqr1ZW75RviyAlTg5U5fA5M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sOfVXlgGCM9GhDtJKkwmpaKUMwkKMlt8sctJZOguQ1bCCrXvyEhiHWmxM2qDxI9DqzkxSw+Ex5mBKBGCpaJFdeAEpILKtTKih1+Ira8po7cf8CvKvFdfjh7K74KBjVfeVZFjtk4sRnElZSVPM4w+PbsMxC+Ki59eaboNRiYJae4= 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=V+6LXN51; arc=none smtp.client-ip=209.85.219.201 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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc64b659a9cso1170664276.3 for ; Wed, 07 Feb 2024 06:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707317359; x=1707922159; 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=KuSad3U75XWRyrG0hVFC7e1TsgCe+6P5oSqEz6h0Hdo=; b=V+6LXN51egocelhYpPCGC0FSCX3O9qOcgbKQeueTaPfPCCUdXooa8sH6hTR4s8ZqdH sf3qWUxWDiMJ/3NNf7b4pKoMv95h77K1HqzL/5FPVSLh1eKOqnz3WCzq1mh5I2h44MDz 7vDGFIeZC0Th9ngqu75h6GDro6aDxL9zBENFMnsp6jeiozra+94th9FpWRBCPe51TSLA 7dKgZ+Pfs6OjwpTNYJ3v9mAlSNfn8denk0ik0uMYJjGic05ugTcM/qZVr5h2l0KbIYcH 4L0+3tHfXh5Dto/M3X5PENBJXSm1Gww8KNg4hMr9w4W2MgPWUsMJCKtvm4mU/IIUvFHu Y/Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707317359; x=1707922159; 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=KuSad3U75XWRyrG0hVFC7e1TsgCe+6P5oSqEz6h0Hdo=; b=XOT7T/3CaDMFK/ezKHGftWt/6BZl18bXWYqd5R/xRTqv2T9CDyDerM2L6ijklorVXv TBJaKS5I+b5LhJ74dOnax9lMqm2ukaV9BBC4MVn0DA7qLGdGll2O9HDMvjisZBaZrqWM ZJapE4pmkaVNAN/QcHFlumieezpVm6XmjHMSKuQlScpAXGGvtgPERmMv6+x2zY0SDIgz xwRnK7fBvb6FpdSYTIJcw61Fqg7is5GVJZfkByKxPAiiJQHak8VLDopIcT5NyvO5/5z2 r//6RBhesLFTULdqZtLr/orsU11qPCVr3RmrVPz0nG/Vw9BV2tVOCALubDn6Cx2VLfF4 xKjw== X-Forwarded-Encrypted: i=1; AJvYcCUQ9T2IhfyJHjM/oGVIpWVufPTNA4RWG+AKWDRR7wEwxr0L6tjlIvFN0mSAWFCECRUANQQBQ/pxl06I1IoF6mdMZNQ2GvxaYhOQ6zHQ X-Gm-Message-State: AOJu0YwmTtaZsoLpT5sC7KZRqylAd4FrSM+cRHDEIuLonIYd5iWDXj0W asKEnbcfdYh2+dG7QkY3FUZsIssRw1uOk6m15V2pgMZwy+Mjc65AmWi5Luxi55BxcAFtAlObphK dobnzHE60mrF5lq2iuocflGCKmQ== X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:200c:b0:dc6:53c3:bcbd with SMTP id dh12-20020a056902200c00b00dc653c3bcbdmr1272474ybb.7.1707317359551; Wed, 07 Feb 2024 06:49:19 -0800 (PST) Date: Wed, 7 Feb 2024 14:48:30 +0000 In-Reply-To: <20240207144832.1017815-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-3-sebastianene@google.com> Subject: [PATCH v5 1/4] 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.43.0.594.gd9cf4e227d-goog