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: 165518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2687217vqg; Wed, 15 Nov 2023 09:17:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfDiBCfCDsppUvSSC0sERyLpd7zkfxSiZVaW6ZTRSi0TFl+n0HFMWkPMZm7J+FufLFDPvJ X-Received: by 2002:a05:6a21:6d96:b0:186:4430:5d16 with SMTP id wl22-20020a056a216d9600b0018644305d16mr14071345pzb.61.1700068657071; Wed, 15 Nov 2023 09:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700068657; cv=none; d=google.com; s=arc-20160816; b=dhCEjknvNUpmTlVRkOKG90QnI8RWaHjRUM/S+iAx+nTEOeYyS73wrgGL+5hE17uhzM hOoLkmmZ9fmFtK6Jgat4aqg89TWMY80O/n8lVGghJPioQRmeadhREZO966aTUZ1zAVEp nRCfNqopjFarpMso3XzmXvuXzsu/YFx6ExHFskuKNj6i//bRvLl/CyXMEEbPA0zIwD/e n2IrvPfGHeaUVgT+MQv9fwCbNCPXDFBLzJ+NOdp9H2nGv5DaVeLnrODDkM3tCRxyGPic eyQHuWDM7Mab/f1F3neVj5D996/nTp4+68Ogepwb7LijPJaox/FMtNn5EOEgzJ8jWhoW fjFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=y0A/JzsGt28jdcT80BavCxCwKvAhE81Bu7nGud0PArE=; fh=4RXM1FFjr/2FDx2f50K7N78eRirWaG15JMQkQwGVT00=; b=GsdOg845ZLm+phGijcaziIgDfFd55c8w1DEEOQYaYUjABuDc6Jr/5pl+Pqjx8hCaF5 +P4c2DpC/kWRIJmbJoYw/cJVfQylXDayOhwzuQb7iwXMytrVqs/rpBXH8noIurCzl5zN hMgTd4kuPT3GvT9rktHsQ92igoxxqjyMgsC6Dl4GuIhYsv62EKUREKz0u2B7D+A4OFL7 ZK04gxI09wG95ajtB8BzLm1sNin+rfYFoNtmSa5cEjc4bDPB71HeYSBcgjPLtdzvCHSA aaIkK9ss43Ae0eUChBC8vkf0sEhKMy2RB782OKK4fYZsQa2R97UTJHSY+2o2qEDKB2ev Al/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WWo5FwtP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k184-20020a6384c1000000b005be0a705478si10416387pgd.89.2023.11.15.09.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 09:17:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WWo5FwtP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C0B1E816EBD7; Wed, 15 Nov 2023 09:17:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbjKORRE (ORCPT + 29 others); Wed, 15 Nov 2023 12:17:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbjKORRC (ORCPT ); Wed, 15 Nov 2023 12:17:02 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E715127 for ; Wed, 15 Nov 2023 09:16:59 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da307fb7752so8929774276.0 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=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=y0A/JzsGt28jdcT80BavCxCwKvAhE81Bu7nGud0PArE=; b=WWo5FwtPlJqJm5DvQ3UAKpvrkNXOxnLvErKLqK7nAaEjDyqK8WG2nKPnBsRgUWWgk4 JJpqpr8+5NvPaLXK3spIW68zcfV6GMVb4KXgzggr/PR0pw3eU9XgSmH9XdNRoCmZiang vIVhuLhmMeOJMpFnaCg1Nw2A4D6yJYS/7ytD7+WVWxZ+55c9eQZPQffjEO1NamHYwcJw SHGwQDizgPSSemTLQk31jv++6LlXuh8nAUrIyCEXFwxWBceg4ThWfrlh8e0TVBq0JRDP DP0sStsjpLIK3rSDeNBFycQwAFKguEJDiVsdAPR3slmHrdppj+ewIz08DV6E/5vgp+8v OlKw== 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=dXeAOqdBOYt+JxEH23fnVA1viHuzqe/XBtkGwal5Ga8k5kKPklJJ2Rr/sAcsfduVmN 7BvhtRtkpMw9WBP1FLq8UchjpG5Te4ykETohV331DttW/zo+jVt/mPIXJ6vzGV2wtH+l 94vkZevMNrrQXBj0B3IgHVUtsEcBQB0GekP0Qzq08f5Dcq7m5DJ37ofeJftKcaYvHqhQ 5/BVNV6aldVqTHM6VYl2Y/k4a8I4nUoC8hMfJHEP2udheQEdF0S+PBcmggRUB6FLgTgk tbGI8g69vFINF5vz0gmTlDMcq0iPr/hxVQJVtwNM6ek0DefJa7fdq3VG5XafIQWH9MwR Xvww== X-Gm-Message-State: AOJu0Yx13j9EKTDqRPZgvXtf3Xn3BaLAhESYnoN8/3/nxXsIks0VNsfc rjEhCRNBwnvuWqxj/9ArT0DI5xlYdxv+jUhCbgQ= 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-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 09:17:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782651191979198528 X-GMAIL-MSGID: 1782651191979198528 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 = {