From mboxrd@z Thu Jan 1 00:00:00 1970 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 7B314C3DA59 for ; Fri, 19 Jul 2024 13:28:11 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From: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=x5Rnu8xhOiOGKULhvQEsLnF6NFu8gN2o/irl+R632WU=; b=4EbMDJM0PSnaiQe9/ccnG3h/VS gePd6QJcYPPmiO85RkVN8WJCsa8QpJeyPKmlVrCFCXZVY1TmS2Ixc2K8JocfOuuMmb6v8ZcFNNIQ5 UXwigFhOPaSDDAavR2kLdTY1OykB/tY4MWRQFFQyie1pHEF2kQT1QgtQ0TCCS9+bauIInwIdAFRhX 0oKgaN9PZtM2R7Cbkj501CO0jWRgK/9UamI/u4HdtgWIQyLd4FLIc7uZP4+KpLEEVo/LUntSuJkky hie2n8+AFIURAH+94d/e85ed2qkIOhI0b5L4SC+0cr6aL2mLYQ4YiB5MzBky6j6Bqyz9M3vAShpmx chxH8neg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUneH-00000002mNQ-1o60; Fri, 19 Jul 2024 13:27:49 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUndv-00000002mEp-2ic7 for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2024 13:27:29 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4266f796e67so34305e9.1 for ; Fri, 19 Jul 2024 06:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721395646; x=1722000446; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x5Rnu8xhOiOGKULhvQEsLnF6NFu8gN2o/irl+R632WU=; b=U8Ki9RHFz/NRcoBTmaIhfMfDyjzhKqWzKt5eguxQlRx+8y4e8atLUXDgljLcDHR0vj 3kKCzRCePt3EjgWVd+X/q74haB3j/UEfyRC+bkStIgQ/wQ3NwP4e2fqoSb+yjySiqimg phOSvMu0O2cXM9R3qnklZ9HL2pnN813FtXP+Te+NV2XpdgSVnEwmO17Zyp0mHBv2RODu aG7eqJn/KjMPrmG9qCMsRXOjALBszbXXmvclkJy7KxSsamby/9LuZ92GtTnvlYKgJqDG nWg2+z23UfmZazCk4NNVbCqtJhfijrXnka/mLTRIlqZoGr3VZgIBdFv1fc3Oz4mFB5p1 bURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721395646; x=1722000446; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x5Rnu8xhOiOGKULhvQEsLnF6NFu8gN2o/irl+R632WU=; b=CWlL+baGh185cTGzjHd1Cyd9Gbw29qlCS9MsGT7KI7xJokzu9N1zjyEZxQyV46tkb1 kZs/9Ag17hPlr3+AoLlBnoTRpwskfE68HxWobxC8+tLEs/68gy23Mf9QkKqb1EQx78Rv WQkKjBLLgVF8W3vn3H08bFsRYLWjYF3LBKmq6sq59bodL5Jibdp63n7X8QTbnu6YZpR1 lYlbmcw432hdD54n/2tW2ELtsyhWpQ4IgJQK9bWfEASoJC1InSAq/nXruoY3AaANih0n m7t83l9nJcYUXic/Fdu4Dul1GRWe00qUek3Im8HZTnHjykjvBDNInrAbT/hg+czghrjf fl3Q== X-Forwarded-Encrypted: i=1; AJvYcCVjL1+0bLhXuXvG3Zy2KYlCmqGQ7eG5qAXDdLtrSZ3q9AjbEQ8NGGf3pxwxh9ta2gjiJByRdbB0g8JpKg4uJ04E1Xw9w1v2R0DNePeviqXHs2SEGgA= X-Gm-Message-State: AOJu0Yx7yxM5p0dMWcBj9CKxdJu0QeZkUqD+IXo/Z/DhPabHXABKnSHy tydlLsQsDHDHbdHP4+2nKtaoNfm8pnCQBlp+cGt14KKJnfgZ+jMcVe4ggdbr/A== X-Google-Smtp-Source: AGHT+IEbXOwh/C+c3oBafmb5O72ZdYCNr8vSQJ5zdk2fN1eXD/y2lF+GXyUY+3bMQVkSL6rtmL4cOQ== X-Received: by 2002:a05:600c:1ca2:b0:426:66fd:5fac with SMTP id 5b1f17b1804b1-427d5b43181mr1331635e9.2.1721395645600; Fri, 19 Jul 2024 06:27:25 -0700 (PDT) Received: from google.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b262sm1637346f8f.30.2024.07.19.06.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 06:27:25 -0700 (PDT) Date: Fri, 19 Jul 2024 13:27:23 +0000 From: Sebastian Ene To: Will Deacon Cc: 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, shahuang@redhat.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v7 3/6] arm64: ptdump: Use the mask from the state structure Message-ID: References: <20240621123230.1085265-1-sebastianene@google.com> <20240621123230.1085265-4-sebastianene@google.com> <20240705111229.GB9231@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240705111229.GB9231@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240719_062727_712512_33B8AF22 X-CRM114-Status: GOOD ( 31.94 ) 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 On Fri, Jul 05, 2024 at 12:12:29PM +0100, Will Deacon wrote: > On Fri, Jun 21, 2024 at 12:32:27PM +0000, Sebastian Ene wrote: > > 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 c550b2afcab7..a4125d8d5a32 100644 > > --- a/arch/arm64/include/asm/ptdump.h > > +++ b/arch/arm64/include/asm/ptdump.h > > @@ -44,6 +44,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; > > const struct mm_struct *mm; > > diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c > > index e370b7a945de..9637a6415ea7 100644 > > --- a/arch/arm64/mm/ptdump.c > > +++ b/arch/arm64/mm/ptdump.c > > @@ -192,6 +192,7 @@ 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; > > > > @@ -201,7 +202,7 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, > > level = 0; > > > > if (level >= 0) > > - prot = val & pg_level[level].mask; > > + prot = val & pg_info[level].mask; > > If you rename the existing 'pg_level' array to something like > 'kernel_pg_levels' then I think your local 'pg_info' variable can be > called 'pg_level' and this line doesn't need to change. > This is a good ideea, thanks. I applied your suggestion > > > > if (st->level == -1) { > > st->level = level; > > @@ -227,10 +228,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); > > I think this could then stay as-is too. > > > pt_dump_seq_puts(st->seq, "\n"); > > > > if (addr >= st->marker[1].start_address) { > > @@ -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 = &pg_level[0], > > Can't this just be '.pg_level = kernel_pg_levels'? > > Will Seb